-
Notifications
You must be signed in to change notification settings - Fork 237
Expand file tree
/
Copy pathinputPoint.svelte
More file actions
57 lines (53 loc) · 1.72 KB
/
inputPoint.svelte
File metadata and controls
57 lines (53 loc) · 1.72 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
<script lang="ts">
import { Input } from '@appwrite.io/pink-svelte';
import { Layout, Icon } from '@appwrite.io/pink-svelte';
import Button from './button.svelte';
import { IconX } from '@appwrite.io/pink-icons-svelte';
interface Props {
values: number[];
nullable?: boolean;
deletePoints?: boolean;
onDeletePoint?: () => void;
disableDelete?: boolean;
disabled?: boolean;
onChangePoint: (index: number, newValue: number) => void;
}
const nullableSkeletonShape: number[] = [0, 0];
let {
values,
nullable = false,
deletePoints = false,
disableDelete = false,
onDeletePoint,
onChangePoint,
disabled
}: Props = $props();
</script>
<Layout.Stack>
<Layout.Stack direction="row" gap="m">
{#if nullable}
{#each nullableSkeletonShape as _, index}
<Input.Number id={`default-${index}`} placeholder="0" disabled />
{/each}
{:else}
{#each values as _, index}
<Input.Number
id={`point-${index}`}
placeholder="Enter value"
step={0.0001}
value={values[index]}
{disabled}
on:change={(e) => onChangePoint(index, Number.parseFloat(`${e.detail}`))} />
{/each}
{/if}
{#if deletePoints}
<Button
size="s"
secondary
disabled={nullable || disableDelete || disabled}
on:click={() => onDeletePoint?.()}>
<Icon icon={IconX} size="s" />
</Button>
{/if}
</Layout.Stack>
</Layout.Stack>