compote-ui 0.56.0 → 0.57.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/components/data-table-v9/create-table.svelte.js +14 -10
  2. package/dist/index.d.ts +0 -2
  3. package/dist/index.js +0 -2
  4. package/package.json +6 -19
  5. package/dist/components/data-table-v8/column-helper.d.ts +0 -12
  6. package/dist/components/data-table-v8/column-helper.js +0 -42
  7. package/dist/components/data-table-v8/create-svelte-table.svelte.d.ts +0 -8
  8. package/dist/components/data-table-v8/create-svelte-table.svelte.js +0 -85
  9. package/dist/components/data-table-v8/create-table.svelte.d.ts +0 -35
  10. package/dist/components/data-table-v8/create-table.svelte.js +0 -234
  11. package/dist/components/data-table-v8/data-table-foot.svelte +0 -96
  12. package/dist/components/data-table-v8/data-table-foot.svelte.d.ts +0 -33
  13. package/dist/components/data-table-v8/data-table-head.svelte +0 -196
  14. package/dist/components/data-table-v8/data-table-head.svelte.d.ts +0 -35
  15. package/dist/components/data-table-v8/data-table-title.svelte +0 -16
  16. package/dist/components/data-table-v8/data-table-title.svelte.d.ts +0 -10
  17. package/dist/components/data-table-v8/data-table-utils.d.ts +0 -32
  18. package/dist/components/data-table-v8/data-table-utils.js +0 -160
  19. package/dist/components/data-table-v8/data-table.svelte +0 -273
  20. package/dist/components/data-table-v8/data-table.svelte.d.ts +0 -41
  21. package/dist/components/data-table-v8/flex-render.svelte +0 -35
  22. package/dist/components/data-table-v8/flex-render.svelte.d.ts +0 -28
  23. package/dist/components/data-table-v8/index.d.ts +0 -12
  24. package/dist/components/data-table-v8/index.js +0 -10
  25. package/dist/components/data-table-v8/render-helpers.d.ts +0 -13
  26. package/dist/components/data-table-v8/render-helpers.js +0 -23
  27. package/dist/components/data-table-v8/toolbar/data-table-column-filter.svelte +0 -373
  28. package/dist/components/data-table-v8/toolbar/data-table-column-filter.svelte.d.ts +0 -29
  29. package/dist/components/data-table-v8/toolbar/data-table-column-visibility.svelte +0 -73
  30. package/dist/components/data-table-v8/toolbar/data-table-column-visibility.svelte.d.ts +0 -29
  31. package/dist/components/data-table-v8/toolbar/data-table-search.svelte +0 -57
  32. package/dist/components/data-table-v8/toolbar/data-table-search.svelte.d.ts +0 -31
  33. package/dist/components/data-table-v8/toolbar/data-table-toolbar.svelte +0 -39
  34. package/dist/components/data-table-v8/toolbar/data-table-toolbar.svelte.d.ts +0 -12
  35. package/dist/components/data-table-v8/types.d.ts +0 -73
  36. package/dist/components/data-table-v8/types.js +0 -1
  37. package/dist/components/data-table-v8/virtual/data-table-virtual-rows.svelte +0 -176
  38. package/dist/components/data-table-v8/virtual/data-table-virtual-rows.svelte.d.ts +0 -40
  39. package/dist/components/data-table-v8/virtual/data-table-virtualized.svelte +0 -146
  40. package/dist/components/data-table-v8/virtual/data-table-virtualized.svelte.d.ts +0 -41
  41. package/dist/components/data-table-v8/virtual/index.d.ts +0 -3
  42. package/dist/components/data-table-v8/virtual/index.js +0 -2
@@ -1,373 +0,0 @@
1
- <script lang="ts" generics="T extends RowData">
2
- import { onDestroy } from 'svelte';
3
- import type { Column, RowData } from '@tanstack/table-core';
4
- import * as Popover from '../../popover';
5
- import * as ScrollArea from '../../scroll-area';
6
- import Checkbox from '../../checkbox/checkbox.svelte';
7
- import { cn } from 'tailwind-variants';
8
- import { getReactiveTableState, type DataTableInstance } from '../data-table-utils';
9
- import NumberInput from '../../number-input/number-input.svelte';
10
- import * as Field from '../../field';
11
- import { PhX, PhMagnifyingGlass } from '../../../icons';
12
-
13
- type Props = {
14
- table: DataTableInstance<T>;
15
- triggerLabel?: string;
16
- };
17
-
18
- let { table, triggerLabel = 'Filters' }: Props = $props();
19
-
20
- let localText: Record<string, string> = $state({});
21
- let localNumMin: Record<string, number> = $state({});
22
- let localNumMax: Record<string, number> = $state({});
23
- let localSelectSearch: Record<string, string> = $state({});
24
- const timers: Record<string, ReturnType<typeof setTimeout>> = {};
25
-
26
- const columnFilters = $derived(getReactiveTableState(table).columnFilters);
27
- const activeCount = $derived(columnFilters.length);
28
-
29
- let activeFilterIds: string[] = $derived(columnFilters.map((f) => f.id));
30
- let showColumnPicker = $state(false);
31
- let columnSearchText = $state('');
32
-
33
- const activeColumns = $derived.by(() => {
34
- getReactiveTableState(table);
35
- return activeFilterIds
36
- .map((id) => table.getColumn(id))
37
- .filter((col): col is Column<T, unknown> => col != null);
38
- });
39
-
40
- const availableColumns = $derived.by(() => {
41
- getReactiveTableState(table);
42
- return table
43
- .getAllLeafColumns()
44
- .filter((col) => col.getCanFilter() && !activeFilterIds.includes(col.id))
45
- .filter(
46
- (col) =>
47
- !columnSearchText ||
48
- getColumnLabel(col).toLowerCase().includes(columnSearchText.toLowerCase())
49
- );
50
- });
51
-
52
- onDestroy(() => {
53
- Object.values(timers).forEach(clearTimeout);
54
- });
55
-
56
- function getColumnType(column: Column<T, unknown>): string | undefined {
57
- return (column.columnDef.meta as Record<string, unknown> | undefined)?.type as
58
- | string
59
- | undefined;
60
- }
61
-
62
- function getColumnLabel(column: Column<T, unknown>): string {
63
- return typeof column.columnDef.header === 'string' ? column.columnDef.header : column.id;
64
- }
65
-
66
- function addFilter(column: Column<T, unknown>) {
67
- activeFilterIds = [...activeFilterIds, column.id];
68
- showColumnPicker = false;
69
- columnSearchText = '';
70
- }
71
-
72
- function removeFilter(column: Column<T, unknown>) {
73
- activeFilterIds = activeFilterIds.filter((id) => id !== column.id);
74
- column.setFilterValue(undefined);
75
- delete localText[column.id];
76
- delete localNumMin[column.id];
77
- delete localNumMax[column.id];
78
- delete localSelectSearch[column.id];
79
- clearTimeout(timers[column.id]);
80
- clearTimeout(timers[`${column.id}_min`]);
81
- clearTimeout(timers[`${column.id}_max`]);
82
- }
83
-
84
- function clearFilters() {
85
- Object.values(timers).forEach(clearTimeout);
86
- for (const key of Object.keys(timers)) delete timers[key];
87
- localText = {};
88
- localNumMin = {};
89
- localNumMax = {};
90
- localSelectSearch = {};
91
- showColumnPicker = false;
92
- columnSearchText = '';
93
- table.resetColumnFilters();
94
- }
95
-
96
- function handleTextInput(column: Column<T, unknown>, value: string) {
97
- localText[column.id] = value;
98
- clearTimeout(timers[column.id]);
99
- timers[column.id] = setTimeout(() => {
100
- column.setFilterValue(value || undefined);
101
- }, 300);
102
- }
103
-
104
- function handleNumericInput(
105
- column: Column<T, unknown>,
106
- which: 'min' | 'max',
107
- value: number | null
108
- ) {
109
- if (value === null) {
110
- if (which === 'min') delete localNumMin[column.id];
111
- else delete localNumMax[column.id];
112
- } else {
113
- if (which === 'min') localNumMin[column.id] = value;
114
- else localNumMax[column.id] = value;
115
- }
116
- clearTimeout(timers[`${column.id}_${which}`]);
117
- timers[`${column.id}_${which}`] = setTimeout(() => {
118
- const min = localNumMin[column.id];
119
- const max = localNumMax[column.id];
120
- column.setFilterValue(min === undefined && max === undefined ? undefined : [min, max]);
121
- }, 300);
122
- }
123
-
124
- function getSelectValues(column: Column<T, unknown>): string[] {
125
- return (column.getFilterValue() as string[] | undefined) ?? [];
126
- }
127
-
128
- function handleSelectChange(column: Column<T, unknown>, value: string, checked: boolean) {
129
- const current = getSelectValues(column);
130
- const next = checked ? [...current, value] : current.filter((v) => v !== value);
131
- column.setFilterValue(next.length ? next : undefined);
132
- }
133
-
134
- function getFacetedValues(column: Column<T, unknown>): string[] {
135
- return Array.from(column.getFacetedUniqueValues().keys()).map(String).sort();
136
- }
137
-
138
- function getFacetedMinMax(column: Column<T, unknown>): [number | undefined, number | undefined] {
139
- const vals = column.getFacetedMinMaxValues();
140
- return vals ? [vals[0] as number, vals[1] as number] : [undefined, undefined];
141
- }
142
-
143
- function getColumnFormatOptions(
144
- column: Column<T, unknown>
145
- ): Intl.NumberFormatOptions | undefined {
146
- return (column.columnDef.meta as Record<string, unknown> | undefined)?.formatOptions as
147
- | Intl.NumberFormatOptions
148
- | undefined;
149
- }
150
- </script>
151
-
152
- <Popover.Root positioning={{ placement: 'bottom-end' }}>
153
- <Popover.Trigger
154
- class="flex h-9 cursor-pointer items-center rounded-md border border-surface-3 bg-surface-1 px-3 text-sm font-medium text-ink shadow-sm outline-none hover:bg-surface-2 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring"
155
- >
156
- {triggerLabel}
157
- {#if activeCount > 0}
158
- ({activeCount})
159
- {/if}
160
- </Popover.Trigger>
161
-
162
- <Popover.Content class="w-70 p-3 flex flex-col gap-3" showArrow={false}>
163
- <div class="flex items-center justify-between py-2.5 mr-1">
164
- <span class="text-sm font-medium text-ink">Filters</span>
165
- {#if activeCount > 0}
166
- <button type="button" onclick={clearFilters} class="text-xs text-primary hover:underline">
167
- Clear all
168
- </button>
169
- {/if}
170
- </div>
171
-
172
- {#if activeColumns.length > 0}
173
- <div class="overflow-hidden border-t border-surface-2">
174
- <ScrollArea.Root class="h-96">
175
- <ScrollArea.Viewport>
176
- <ScrollArea.Content class="flex flex-col gap-3">
177
- {#each activeColumns as column (column.id)}
178
- <div class="border border-surface-3 p-3">
179
- <div class="mb-2 flex items-center justify-between">
180
- <span class="text-sm font-medium text-ink">{getColumnLabel(column)}</span>
181
- <button
182
- type="button"
183
- onclick={() => removeFilter(column)}
184
- class="text-ink-dim transition-colors hover:text-ink"
185
- >
186
- <PhX class="size-3.5" />
187
- </button>
188
- </div>
189
-
190
- {#if getColumnType(column) === 'number' || getColumnType(column) === 'currency' || getColumnType(column) === 'percent'}
191
- {@const [facetMin, facetMax] = getFacetedMinMax(column)}
192
- {@const colFormatOptions = getColumnFormatOptions(column)}
193
- <div class="flex flex-col gap-1.5">
194
- <div class="min-w-0 flex-1">
195
- <NumberInput
196
- layout="horizontal"
197
- label="From"
198
- value={localNumMin[column.id] ?? facetMin ?? null}
199
- min={facetMin}
200
- max={facetMax}
201
- formatOptions={colFormatOptions}
202
- onValueChange={({ valueAsNumber }) =>
203
- handleNumericInput(
204
- column,
205
- 'min',
206
- isNaN(valueAsNumber) ? null : valueAsNumber
207
- )}
208
- />
209
- </div>
210
- <div class="min-w-0 flex-1">
211
- <NumberInput
212
- layout="horizontal"
213
- label="To"
214
- value={localNumMax[column.id] ?? facetMax ?? null}
215
- min={facetMin}
216
- max={facetMax}
217
- formatOptions={colFormatOptions}
218
- onValueChange={({ valueAsNumber }) =>
219
- handleNumericInput(
220
- column,
221
- 'max',
222
- isNaN(valueAsNumber) ? null : valueAsNumber
223
- )}
224
- />
225
- </div>
226
- </div>
227
- {:else if getColumnType(column) === 'boolean'}
228
- {@const boolFilter = column.getFilterValue() as boolean | undefined}
229
- <div class="flex overflow-hidden rounded border border-border text-xs">
230
- <button
231
- type="button"
232
- onclick={() => column.setFilterValue(undefined)}
233
- class={cn(
234
- 'flex-1 px-2 py-1',
235
- boolFilter === undefined
236
- ? 'bg-surface-3 font-medium text-ink'
237
- : 'text-ink-dim hover:bg-surface-2'
238
- )}
239
- >
240
- All
241
- </button>
242
- <button
243
- type="button"
244
- onclick={() =>
245
- column.setFilterValue(boolFilter === true ? undefined : true)}
246
- class={cn(
247
- 'flex-1 border-x border-border px-2 py-1',
248
- boolFilter === true
249
- ? 'bg-surface-3 font-medium text-ink'
250
- : 'text-ink-dim hover:bg-surface-2'
251
- )}
252
- >
253
- Yes
254
- </button>
255
- <button
256
- type="button"
257
- onclick={() =>
258
- column.setFilterValue(boolFilter === false ? undefined : false)}
259
- class={cn(
260
- 'flex-1 px-2 py-1',
261
- boolFilter === false
262
- ? 'bg-surface-3 font-medium text-ink'
263
- : 'text-ink-dim hover:bg-surface-2'
264
- )}
265
- >
266
- No
267
- </button>
268
- </div>
269
- {:else if getColumnType(column) === 'select'}
270
- {const allOptions = getFacetedValues(column)}
271
- {const search = localSelectSearch[column.id] ?? ''}
272
- {const options = search
273
- ? allOptions.filter((o) => o.toLowerCase().includes(search.toLowerCase()))
274
- : allOptions}
275
- {const selected = getSelectValues(column)}
276
- <div class="flex flex-col gap-1">
277
- <Field.Root>
278
- <Field.Input
279
- placeholder="Search..."
280
- value={search}
281
- oninput={(e: Event) => {
282
- localSelectSearch[column.id] = (
283
- e.currentTarget as HTMLInputElement
284
- ).value;
285
- }}
286
- />
287
- </Field.Root>
288
- <ScrollArea.Root>
289
- <ScrollArea.Viewport class="max-h-40">
290
- <ScrollArea.Content>
291
- <div class="flex flex-col gap-0.5">
292
- {#each options as option (option)}
293
- <Checkbox
294
- size="sm"
295
- label={option}
296
- class="min-h-7 rounded-sm px-2 hover:bg-surface-2"
297
- checked={selected.includes(option)}
298
- onCheckedChange={({ checked }) =>
299
- handleSelectChange(column, option, checked === true)}
300
- />
301
- {/each}
302
- </div>
303
- </ScrollArea.Content>
304
- </ScrollArea.Viewport>
305
- <ScrollArea.Scrollbar orientation="vertical">
306
- <ScrollArea.Thumb />
307
- </ScrollArea.Scrollbar>
308
- <ScrollArea.Corner />
309
- </ScrollArea.Root>
310
- </div>
311
- {:else}
312
- <Field.Root>
313
- <Field.Input
314
- placeholder="Search..."
315
- value={localText[column.id] ?? ''}
316
- oninput={(e: Event) =>
317
- handleTextInput(column, (e.currentTarget as HTMLInputElement).value)}
318
- />
319
- </Field.Root>
320
- {/if}
321
- </div>
322
- {/each}
323
- </ScrollArea.Content>
324
- </ScrollArea.Viewport>
325
- <ScrollArea.Scrollbar orientation="vertical">
326
- <ScrollArea.Thumb />
327
- </ScrollArea.Scrollbar>
328
- <ScrollArea.Corner />
329
- </ScrollArea.Root>
330
- </div>
331
- {/if}
332
-
333
- {#if showColumnPicker}
334
- <div class="border-t border-surface-3 p-3">
335
- <div class="relative mb-1">
336
- <PhMagnifyingGlass
337
- class="pointer-events-none absolute top-1/2 left-2.5 size-3.5 -translate-y-1/2 text-ink-dim"
338
- />
339
- <input
340
- type="text"
341
- placeholder="Search columns..."
342
- bind:value={columnSearchText}
343
- class="h-8 w-full rounded border border-border bg-surface-1 pr-3 pl-7 text-sm text-ink outline-none placeholder:text-ink-dim focus:ring-1 focus:ring-ring"
344
- />
345
- </div>
346
- <div class="max-h-48 overflow-y-auto">
347
- {#each availableColumns as column (column.id)}
348
- <button
349
- type="button"
350
- onclick={() => addFilter(column)}
351
- class="w-full rounded px-2 py-1.5 text-left text-sm text-ink hover:bg-surface-2"
352
- >
353
- {getColumnLabel(column)}
354
- </button>
355
- {:else}
356
- <p class="px-2 py-3 text-center text-sm text-ink-dim">No more columns</p>
357
- {/each}
358
- </div>
359
- </div>
360
- {:else}
361
- <div class="border-t border-surface-3">
362
- <button
363
- type="button"
364
- onclick={() => (showColumnPicker = true)}
365
- class="flex w-full items-center gap-2 px-3 py-2.5 text-sm text-ink-dim hover:bg-surface-2 hover:text-ink"
366
- >
367
- <span class="text-base leading-none">+</span>
368
- Add Filter
369
- </button>
370
- </div>
371
- {/if}
372
- </Popover.Content>
373
- </Popover.Root>
@@ -1,29 +0,0 @@
1
- import type { RowData } from '@tanstack/table-core';
2
- import { type DataTableInstance } from '../data-table-utils';
3
- declare function $$render<T extends RowData>(): {
4
- props: {
5
- table: DataTableInstance<T>;
6
- triggerLabel?: string;
7
- };
8
- exports: {};
9
- bindings: "";
10
- slots: {};
11
- events: {};
12
- };
13
- declare class __sveltets_Render<T extends RowData> {
14
- props(): ReturnType<typeof $$render<T>>['props'];
15
- events(): ReturnType<typeof $$render<T>>['events'];
16
- slots(): ReturnType<typeof $$render<T>>['slots'];
17
- bindings(): "";
18
- exports(): {};
19
- }
20
- interface $$IsomorphicComponent {
21
- new <T extends RowData>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & {
22
- $$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
23
- } & ReturnType<__sveltets_Render<T>['exports']>;
24
- <T extends RowData>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
25
- z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
26
- }
27
- declare const DataTableColumnFilter: $$IsomorphicComponent;
28
- type DataTableColumnFilter<T extends RowData> = InstanceType<typeof DataTableColumnFilter<T>>;
29
- export default DataTableColumnFilter;
@@ -1,73 +0,0 @@
1
- <script lang="ts" generics="T extends RowData">
2
- import type { RowData } from '@tanstack/table-core';
3
- import * as Popover from '../../popover';
4
- import * as ScrollArea from '../../scroll-area';
5
- import Checkbox from '../../checkbox/checkbox.svelte';
6
- import { getReactiveTableState, type DataTableInstance } from '../data-table-utils';
7
-
8
- type Props = {
9
- table: DataTableInstance<T>;
10
- triggerLabel?: string;
11
- };
12
-
13
- let { table, triggerLabel = 'Columns' }: Props = $props();
14
-
15
- const columnVisibility = $derived(getReactiveTableState(table).columnVisibility);
16
- const allLeafColumns = $derived.by(() => {
17
- getReactiveTableState(table);
18
- return table.getAllLeafColumns();
19
- });
20
- const allColumnsVisible = $derived(
21
- allLeafColumns.every((c) => !c.getCanHide() || columnVisibility[c.id] !== false)
22
- );
23
- const someColumnsVisible = $derived(
24
- allLeafColumns.some((c) => c.getCanHide() && columnVisibility[c.id] !== false)
25
- );
26
- const allColumnsVisibilityState = $derived(
27
- allColumnsVisible ? true : someColumnsVisible ? ('indeterminate' as const) : false
28
- );
29
-
30
- function getColumnLabel(column: { columnDef: { header?: unknown }; id: string }) {
31
- return typeof column.columnDef.header === 'string' ? column.columnDef.header : column.id;
32
- }
33
- </script>
34
-
35
- <Popover.Root positioning={{ placement: 'bottom-end' }}>
36
- <Popover.Trigger
37
- class="flex h-9 cursor-pointer items-center rounded-md border border-surface-3 bg-surface-1 px-3 text-sm font-medium text-ink shadow-sm outline-none hover:bg-surface-2 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring"
38
- >
39
- {triggerLabel}
40
- </Popover.Trigger>
41
-
42
- <Popover.Content class="w-56 p-2" showArrow={false}>
43
- <div class="border-b border-surface-3 px-2 pb-2">
44
- <Checkbox
45
- label="All columns"
46
- checked={allColumnsVisibilityState}
47
- onCheckedChange={({ checked }) => table.toggleAllColumnsVisible(checked === true)}
48
- />
49
- </div>
50
-
51
- <ScrollArea.Root class="h-72">
52
- <ScrollArea.Viewport>
53
- <ScrollArea.Content class="py-1 pe-3">
54
- <div class="flex flex-col">
55
- {#each allLeafColumns as column (column.id)}
56
- <Checkbox
57
- label={getColumnLabel(column)}
58
- class="min-h-8 rounded-sm px-2 hover:bg-surface-2"
59
- checked={columnVisibility[column.id] !== false}
60
- disabled={!column.getCanHide()}
61
- onCheckedChange={({ checked }) => column.toggleVisibility(checked === true)}
62
- />
63
- {/each}
64
- </div>
65
- </ScrollArea.Content>
66
- </ScrollArea.Viewport>
67
- <ScrollArea.Scrollbar orientation="vertical">
68
- <ScrollArea.Thumb />
69
- </ScrollArea.Scrollbar>
70
- <ScrollArea.Corner />
71
- </ScrollArea.Root>
72
- </Popover.Content>
73
- </Popover.Root>
@@ -1,29 +0,0 @@
1
- import type { RowData } from '@tanstack/table-core';
2
- import { type DataTableInstance } from '../data-table-utils';
3
- declare function $$render<T extends RowData>(): {
4
- props: {
5
- table: DataTableInstance<T>;
6
- triggerLabel?: string;
7
- };
8
- exports: {};
9
- bindings: "";
10
- slots: {};
11
- events: {};
12
- };
13
- declare class __sveltets_Render<T extends RowData> {
14
- props(): ReturnType<typeof $$render<T>>['props'];
15
- events(): ReturnType<typeof $$render<T>>['events'];
16
- slots(): ReturnType<typeof $$render<T>>['slots'];
17
- bindings(): "";
18
- exports(): {};
19
- }
20
- interface $$IsomorphicComponent {
21
- new <T extends RowData>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & {
22
- $$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
23
- } & ReturnType<__sveltets_Render<T>['exports']>;
24
- <T extends RowData>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
25
- z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
26
- }
27
- declare const DataTableColumnVisibility: $$IsomorphicComponent;
28
- type DataTableColumnVisibility<T extends RowData> = InstanceType<typeof DataTableColumnVisibility<T>>;
29
- export default DataTableColumnVisibility;
@@ -1,57 +0,0 @@
1
- <script lang="ts" generics="T extends RowData">
2
- import { onDestroy } from 'svelte';
3
- import type { RowData } from '@tanstack/table-core';
4
- import { cn, type ClassValue } from 'tailwind-variants';
5
- import { PhMagnifyingGlass, PhX } from '../../../icons';
6
- import * as Field from '../../field';
7
- import { getReactiveTableState, type DataTableInstance } from '../data-table-utils';
8
-
9
- type Props = {
10
- table: DataTableInstance<T>;
11
- placeholder?: string;
12
- class?: ClassValue;
13
- };
14
-
15
- let { table, placeholder = 'Search...', class: className }: Props = $props();
16
-
17
- const globalFilter = $derived(
18
- (getReactiveTableState(table).globalFilter as string | undefined) ?? ''
19
- );
20
-
21
- let timer: ReturnType<typeof setTimeout> | undefined;
22
-
23
- onDestroy(() => clearTimeout(timer));
24
-
25
- function handleInput(e: Event) {
26
- const value = (e.currentTarget as HTMLInputElement).value;
27
- clearTimeout(timer);
28
- timer = setTimeout(() => {
29
- table.setGlobalFilter(value || undefined);
30
- }, 300);
31
- }
32
-
33
- function clearFilter() {
34
- clearTimeout(timer);
35
- table.setGlobalFilter(undefined);
36
- }
37
- </script>
38
-
39
- <Field.Root class={cn(className)}>
40
- <Field.Input {placeholder} value={globalFilter} oninput={handleInput}>
41
- {#snippet startIcon()}
42
- <PhMagnifyingGlass class="size-4" />
43
- {/snippet}
44
- {#snippet endIcon()}
45
- {#if globalFilter}
46
- <button
47
- type="button"
48
- onclick={clearFilter}
49
- aria-label="Clear search"
50
- class="flex size-5 items-center justify-center rounded text-ink-dim hover:text-ink focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring"
51
- >
52
- <PhX class="size-3.5" />
53
- </button>
54
- {/if}
55
- {/snippet}
56
- </Field.Input>
57
- </Field.Root>
@@ -1,31 +0,0 @@
1
- import type { RowData } from '@tanstack/table-core';
2
- import { type ClassValue } from 'tailwind-variants';
3
- import { type DataTableInstance } from '../data-table-utils';
4
- declare function $$render<T extends RowData>(): {
5
- props: {
6
- table: DataTableInstance<T>;
7
- placeholder?: string;
8
- class?: ClassValue;
9
- };
10
- exports: {};
11
- bindings: "";
12
- slots: {};
13
- events: {};
14
- };
15
- declare class __sveltets_Render<T extends RowData> {
16
- props(): ReturnType<typeof $$render<T>>['props'];
17
- events(): ReturnType<typeof $$render<T>>['events'];
18
- slots(): ReturnType<typeof $$render<T>>['slots'];
19
- bindings(): "";
20
- exports(): {};
21
- }
22
- interface $$IsomorphicComponent {
23
- new <T extends RowData>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & {
24
- $$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
25
- } & ReturnType<__sveltets_Render<T>['exports']>;
26
- <T extends RowData>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
27
- z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
28
- }
29
- declare const DataTableSearch: $$IsomorphicComponent;
30
- type DataTableSearch<T extends RowData> = InstanceType<typeof DataTableSearch<T>>;
31
- export default DataTableSearch;
@@ -1,39 +0,0 @@
1
- <script lang="ts">
2
- import type { Snippet } from 'svelte';
3
- import type { HTMLAttributes } from 'svelte/elements';
4
- import { cn, type ClassValue } from 'tailwind-variants';
5
-
6
- type Props = Omit<HTMLAttributes<HTMLDivElement>, 'class'> & {
7
- class?: ClassValue;
8
- children?: Snippet;
9
- center?: Snippet;
10
- right?: Snippet;
11
- };
12
-
13
- let { class: className, children, center, right, ...rest }: Props = $props();
14
- </script>
15
-
16
- <div
17
- class={cn('mb-4 grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center gap-3', className)}
18
- {...rest}
19
- >
20
- <div class="col-start-1 row-start-1 flex min-w-0 flex-wrap items-center gap-3 justify-self-start">
21
- {@render children?.()}
22
- </div>
23
-
24
- {#if center}
25
- <div
26
- class="col-start-2 row-start-1 flex min-w-0 flex-wrap items-center justify-center gap-3 justify-self-center"
27
- >
28
- {@render center()}
29
- </div>
30
- {/if}
31
-
32
- {#if right}
33
- <div
34
- class="col-start-3 row-start-1 flex min-w-0 flex-wrap items-center justify-end gap-3 justify-self-end"
35
- >
36
- {@render right()}
37
- </div>
38
- {/if}
39
- </div>
@@ -1,12 +0,0 @@
1
- import type { Snippet } from 'svelte';
2
- import type { HTMLAttributes } from 'svelte/elements';
3
- import { type ClassValue } from 'tailwind-variants';
4
- type Props = Omit<HTMLAttributes<HTMLDivElement>, 'class'> & {
5
- class?: ClassValue;
6
- children?: Snippet;
7
- center?: Snippet;
8
- right?: Snippet;
9
- };
10
- declare const DataTableToolbar: import("svelte").Component<Props, {}, "">;
11
- type DataTableToolbar = ReturnType<typeof DataTableToolbar>;
12
- export default DataTableToolbar;