-
Notifications
You must be signed in to change notification settings - Fork 237
Expand file tree
/
Copy pathinputPolygon.svelte
More file actions
62 lines (59 loc) · 1.95 KB
/
inputPolygon.svelte
File metadata and controls
62 lines (59 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<script lang="ts">
import { Icon, Layout } from '@appwrite.io/pink-svelte';
import Button from './button.svelte';
import { IconPlus } from '@appwrite.io/pink-icons-svelte';
import InputLine from './inputLine.svelte';
type Props = {
values: number[][][];
nullable?: boolean;
minDeletableIndex?: number;
onAddPoint: (index: number) => void;
onAddLine?: (index: number) => void;
onDeletePoint: (index: number) => void;
onChangePoint: (
lineIndex: number,
pointIndex: number,
coordIndex: number,
newValue: number
) => void;
disabled?: boolean;
};
let {
values,
nullable = false,
minDeletableIndex = 4,
onAddPoint,
onAddLine,
onDeletePoint,
onChangePoint,
disabled
}: Props = $props();
</script>
<Layout.Stack gap="s">
{#each values as value, index}
<Layout.Stack gap="xs">
<InputLine
{disabled}
values={value}
onAddPoint={() => onAddPoint(index)}
{nullable}
onDeletePoint={() => onDeletePoint(index)}
onChangePoint={(pointIndex, coordIndex, newValue) =>
onChangePoint(index, pointIndex, coordIndex, newValue)}
allowLineDelete={index < 2}
{minDeletableIndex}>
{#snippet addLineButton()}
{#if index === values.length - 1}
<Button
disabled={nullable}
size="xs"
compact
on:click={() => onAddLine?.(-1)}>
<Icon icon={IconPlus} size="s" /> Add line
</Button>
{/if}
{/snippet}
</InputLine>
</Layout.Stack>
{/each}
</Layout.Stack>