|
17 | 17 | import { IconPlus } from '@appwrite.io/pink-icons-svelte';
|
18 | 18 |
|
19 | 19 | let {
|
| 20 | + // eslint-disable-next-line @typescript-eslint/no-explicit-any |
20 | 21 | value = $bindable(null),
|
21 | 22 | columns,
|
22 | 23 | columnId = $bindable(null),
|
23 | 24 | arrayValues = $bindable([]),
|
24 | 25 | operatorKey = $bindable(null),
|
25 | 26 | singleCondition = false
|
26 | 27 | }: {
|
27 |
| - value?: string | number | string[] | null; |
| 28 | + // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 29 | + value?: any; |
28 | 30 | columns: Writable<Column[]>;
|
29 | 31 | columnId?: string | null;
|
30 | 32 | arrayValues?: string[];
|
|
34 | 36 |
|
35 | 37 | let columnsArray = $derived($columns);
|
36 | 38 | let column = $derived(columnsArray.find((c) => c.id === columnId));
|
37 |
| -
|
38 |
| - let operatorsForColumn = $derived(() => { |
| 39 | + let operatorsForColumn = $derived.by(() => { |
39 | 40 | if (!column?.type) return [];
|
40 | 41 | return Object.entries(operators)
|
41 | 42 | .filter(([, v]) => v.types.includes(column.type))
|
42 | 43 | .map(([k]) => ({ label: k, value: k }));
|
43 | 44 | });
|
44 |
| -
|
45 | 45 | let operator = $derived(operatorKey ? operators[operatorKey] : null);
|
46 | 46 | let isDisabled = $derived(!operator);
|
47 | 47 | let appliedTags = $derived($tags);
|
48 |
| -
|
49 |
| - let columnOptions = $derived(() => |
50 |
| - columnsArray |
51 |
| - .filter((c) => c.filter !== false) |
52 |
| - .map((c) => ({ |
53 |
| - label: c.title, |
54 |
| - value: c.id |
55 |
| - })) |
| 48 | + let columnOptions = $derived.by(() => |
| 49 | + columnsArray.filter((c) => c.filter !== false).map((c) => ({ label: c.title, value: c.id })) |
56 | 50 | );
|
57 |
| -
|
58 |
| - let enumOptions = $derived(() => { |
| 51 | + let enumOptions = $derived.by(() => { |
59 | 52 | if (!column?.elements) return [];
|
60 |
| - return column.elements.map((e) => ({ |
61 |
| - label: e?.label ?? e, |
62 |
| - value: e?.value ?? e |
63 |
| - })); |
| 53 | + return column.elements.map((e) => ({ label: e?.label ?? e, value: e?.value ?? e })); |
64 | 54 | });
|
65 |
| -
|
66 |
| - let enumOptionsWithChecked = $derived(() => { |
| 55 | + let enumOptionsWithChecked = $derived.by(() => { |
67 | 56 | if (!column?.elements) return [];
|
68 | 57 | return column.elements.map((e) => ({
|
69 | 58 | label: e?.label ?? e,
|
|
100 | 89 | <Layout.Stack gap="s" direction="row" alignItems="flex-start">
|
101 | 90 | <InputSelect
|
102 | 91 | id="column"
|
103 |
| - options={columnOptions()} |
| 92 | + options={columnOptions} |
104 | 93 | placeholder="Select column"
|
105 | 94 | bind:value={columnId} />
|
106 | 95 | <InputSelect
|
107 | 96 | id="operator"
|
108 | 97 | disabled={!column}
|
109 |
| - options={operatorsForColumn()} |
| 98 | + options={operatorsForColumn} |
110 | 99 | placeholder="Select operator"
|
111 | 100 | bind:value={operatorKey} />
|
112 | 101 | </Layout.Stack>
|
|
117 | 106 | name="value"
|
118 | 107 | bind:tags={arrayValues}
|
119 | 108 | placeholder="Select value"
|
120 |
| - options={enumOptionsWithChecked()}> |
| 109 | + options={enumOptionsWithChecked}> |
121 | 110 | </InputSelectCheckbox>
|
122 | 111 | {:else}
|
123 | 112 | <InputTags
|
|
131 | 120 | {#if column.format === 'enum'}
|
132 | 121 | <InputSelect
|
133 | 122 | id="value"
|
134 |
| - bind:value={value as string} |
| 123 | + bind:value |
135 | 124 | placeholder="Select value"
|
136 |
| - options={enumOptions()} /> |
| 125 | + options={enumOptions} /> |
137 | 126 | {:else if column.type === 'integer' || column.type === 'double'}
|
138 |
| - <InputNumber |
139 |
| - id="value" |
140 |
| - bind:value={value as number} |
141 |
| - placeholder="Enter value" /> |
| 127 | + <InputNumber id="value" bind:value placeholder="Enter value" /> |
142 | 128 | {:else if column.type === 'boolean'}
|
143 | 129 | <InputSelect
|
144 | 130 | id="value"
|
|
148 | 134 | { label: 'True', value: true },
|
149 | 135 | { label: 'False', value: false }
|
150 | 136 | ]}
|
151 |
| - bind:value={value as unknown as boolean} /> |
| 137 | + bind:value /> |
152 | 138 | {:else if column.type === 'datetime'}
|
153 | 139 | {#key value}
|
154 |
| - <InputDateTime id="value" bind:value={value as string} step={60} /> |
| 140 | + <InputDateTime id="value" bind:value step={60} /> |
155 | 141 | {/key}
|
156 | 142 | {:else}
|
157 |
| - <InputText |
158 |
| - id="value" |
159 |
| - bind:value={value as string} |
160 |
| - placeholder="Enter value" /> |
| 143 | + <InputText id="value" bind:value placeholder="Enter value" /> |
161 | 144 | {/if}
|
162 | 145 | </ul>
|
163 | 146 | {/if}
|
|
0 commit comments