compote-ui 0.36.0 → 0.36.2
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.
- package/dist/components/data-table/create-table.d.ts +2 -4
- package/dist/components/data-table/create-table.js +13 -6
- package/dist/components/data-table/data-table.svelte +7 -7
- package/package.json +1 -1
- package/dist/components/data-table-old/core/cells.d.ts +0 -78
- package/dist/components/data-table-old/core/cells.js +0 -66
- package/dist/components/data-table-old/core/create-table.svelte.d.ts +0 -24
- package/dist/components/data-table-old/core/create-table.svelte.js +0 -74
- package/dist/components/data-table-old/core/index.d.ts +0 -3
- package/dist/components/data-table-old/core/index.js +0 -2
- package/dist/components/data-table-old/data-table-column-visibility.svelte +0 -79
- package/dist/components/data-table-old/data-table-column-visibility.svelte.d.ts +0 -29
- package/dist/components/data-table-old/data-table-filters.svelte +0 -285
- package/dist/components/data-table-old/data-table-filters.svelte.d.ts +0 -29
- package/dist/components/data-table-old/data-table-title.svelte +0 -16
- package/dist/components/data-table-old/data-table-title.svelte.d.ts +0 -10
- package/dist/components/data-table-old/data-table-toolbar.svelte +0 -16
- package/dist/components/data-table-old/data-table-toolbar.svelte.d.ts +0 -10
- package/dist/components/data-table-old/data-table.svelte +0 -342
- package/dist/components/data-table-old/data-table.svelte.d.ts +0 -32
- package/dist/components/data-table-old/index.d.ts +0 -7
- package/dist/components/data-table-old/index.js +0 -7
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type ColumnResizeMode, type Row, type RowData, type SvelteTable, type TableState } from '@tanstack/svelte-table';
|
|
2
2
|
import type { DataTableColumn, DataTableLeafColumn } from './types';
|
|
3
3
|
declare const dataTableFeatures: {
|
|
4
4
|
columnVisibilityFeature: import("@tanstack/table-core").TableFeature<import("@tanstack/table-core").ColumnVisibilityFeatureConstructors<import("@tanstack/table-core").TableFeatures, RowData>>;
|
|
@@ -18,9 +18,7 @@ export type CreateDataTableOptions<T extends RowData> = {
|
|
|
18
18
|
data: T[];
|
|
19
19
|
columns: DataTableColumn<T>[];
|
|
20
20
|
columnResizeMode?: ColumnResizeMode;
|
|
21
|
-
|
|
22
|
-
initialRowSelection?: RowSelectionState;
|
|
23
|
-
initialColumnFilters?: ColumnFiltersState;
|
|
21
|
+
initialState?: Partial<TableState<DataTableFeatures>>;
|
|
24
22
|
getRowId?: (row: T, index: number, parent?: Row<DataTableFeatures, T>) => string;
|
|
25
23
|
enableRowSelection?: boolean | ((row: Row<DataTableFeatures, T>) => boolean);
|
|
26
24
|
enableMultiRowSelection?: boolean | ((row: Row<DataTableFeatures, T>) => boolean);
|
|
@@ -39,12 +39,19 @@ export function createTable(options) {
|
|
|
39
39
|
return createColumns(options.columns, localeCtx);
|
|
40
40
|
},
|
|
41
41
|
initialState: {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
...options.initialState,
|
|
43
|
+
columnVisibility: {
|
|
44
|
+
...createColumnVisibility(options.columns),
|
|
45
|
+
...options.initialState?.columnVisibility
|
|
46
|
+
},
|
|
47
|
+
columnSizing: {
|
|
48
|
+
...createColumnSizing(options.columns),
|
|
49
|
+
...options.initialState?.columnSizing
|
|
50
|
+
},
|
|
51
|
+
columnPinning: options.initialState?.columnPinning ?? createColumnPinning(options.columns),
|
|
52
|
+
rowSelection: options.initialState?.rowSelection ?? {},
|
|
53
|
+
sorting: options.initialState?.sorting ?? [],
|
|
54
|
+
columnFilters: options.initialState?.columnFilters ?? []
|
|
48
55
|
}
|
|
49
56
|
}, (state) => ({
|
|
50
57
|
columnVisibility: state.columnVisibility,
|
|
@@ -223,7 +223,7 @@
|
|
|
223
223
|
{/if}
|
|
224
224
|
|
|
225
225
|
<div class="min-h-0 flex-1 overflow-auto">
|
|
226
|
-
<table class="table-fixed border-
|
|
226
|
+
<table class="table-fixed border-separate border-spacing-0 text-sm" style={tableSizeStyle()}>
|
|
227
227
|
<colgroup>
|
|
228
228
|
{#if isRowSelectionEnabled}
|
|
229
229
|
<col style={selectionColumnSizeStyle()} />
|
|
@@ -239,10 +239,10 @@
|
|
|
239
239
|
<thead class="sticky top-0 z-20 bg-surface-2 text-left text-ink-dim">
|
|
240
240
|
{#each headerGroups as headerGroup, headerGroupIndex (headerGroup.id)}
|
|
241
241
|
{@const visibleHeaders = headerGroup.headers.filter((header) => header.colSpan > 0)}
|
|
242
|
-
<tr>
|
|
242
|
+
<tr class="h-9">
|
|
243
243
|
{#if isRowSelectionEnabled && headerGroupIndex === 0}
|
|
244
244
|
<th
|
|
245
|
-
class="border-b border-surface-3 bg-surface-2 px-3 py-
|
|
245
|
+
class="h-9 border-b border-surface-3 bg-surface-2 px-3 py-0 text-center align-middle leading-5 font-medium"
|
|
246
246
|
style="position: sticky; left: 0; z-index: 15"
|
|
247
247
|
rowspan={headerGroupCount}
|
|
248
248
|
>
|
|
@@ -262,7 +262,7 @@
|
|
|
262
262
|
{@const sortDirection = getHeaderSortDirection(header, table.store.state.sorting)}
|
|
263
263
|
<th
|
|
264
264
|
class={cn(
|
|
265
|
-
'relative border-b border-surface-3 bg-surface-2 px-3 py-
|
|
265
|
+
'relative h-9 border-b border-surface-3 bg-surface-2 px-3 py-0 align-middle leading-5 font-medium',
|
|
266
266
|
alignClass(columnDef?.align)
|
|
267
267
|
)}
|
|
268
268
|
colspan={header.colSpan}
|
|
@@ -276,7 +276,7 @@
|
|
|
276
276
|
<button
|
|
277
277
|
type="button"
|
|
278
278
|
class={cn(
|
|
279
|
-
'inline-flex max-w-full items-center gap-1 rounded-sm outline-none hover:text-ink data-focus-visible:outline-2 data-focus-visible:outline-offset-2 data-focus-visible:outline-ring',
|
|
279
|
+
'inline-flex max-w-full appearance-none items-center gap-1 rounded-sm border-0 bg-transparent p-0 align-middle text-sm leading-5 text-inherit outline-none hover:text-ink data-focus-visible:outline-2 data-focus-visible:outline-offset-2 data-focus-visible:outline-ring',
|
|
280
280
|
justifyClass(columnDef?.align),
|
|
281
281
|
sortButtonDirectionClass(columnDef?.align)
|
|
282
282
|
)}
|
|
@@ -312,7 +312,7 @@
|
|
|
312
312
|
{/if}
|
|
313
313
|
</th>
|
|
314
314
|
{/each}
|
|
315
|
-
<th aria-hidden="true" class="border-b border-surface-3 bg-surface-2 p-0"></th>
|
|
315
|
+
<th aria-hidden="true" class="h-9 border-b border-surface-3 bg-surface-2 p-0"></th>
|
|
316
316
|
</tr>
|
|
317
317
|
{/each}
|
|
318
318
|
</thead>
|
|
@@ -380,7 +380,7 @@
|
|
|
380
380
|
<button
|
|
381
381
|
type="button"
|
|
382
382
|
class={cn(
|
|
383
|
-
'inline-flex max-w-full items-center gap-1.5 rounded-sm font-medium text-ink underline decoration-border decoration-dotted underline-offset-4 outline-none hover:text-primary focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring',
|
|
383
|
+
'inline-flex max-w-full appearance-none items-center gap-1.5 rounded-sm border-0 bg-transparent p-0 align-middle leading-5 font-medium text-ink underline decoration-border decoration-dotted underline-offset-4 outline-none hover:text-primary focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring',
|
|
384
384
|
justifyClass(columnDef.align)
|
|
385
385
|
)}
|
|
386
386
|
onclick={() => openUrlCell(value)}
|
package/package.json
CHANGED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import type { AccessorFnColumnDef, AccessorKeyColumnDef, Cell, CellData, ColumnDef, DisplayColumnDef, GroupColumnDef, RowData } from '@tanstack/svelte-table';
|
|
2
|
-
import type { DataTableFeatures } from './create-table.svelte';
|
|
3
|
-
type NumericFormat = {
|
|
4
|
-
locale?: string;
|
|
5
|
-
minimumFractionDigits?: number;
|
|
6
|
-
maximumFractionDigits?: number;
|
|
7
|
-
fractionDigits?: number;
|
|
8
|
-
};
|
|
9
|
-
export type DataTableCellConfig<TData extends RowData = RowData, TValue = unknown> = ({
|
|
10
|
-
type: 'text';
|
|
11
|
-
} & {
|
|
12
|
-
fallback?: string;
|
|
13
|
-
}) | ({
|
|
14
|
-
type: 'number';
|
|
15
|
-
} & NumericFormat) | ({
|
|
16
|
-
type: 'currency';
|
|
17
|
-
currency: string;
|
|
18
|
-
currencyDisplay?: Intl.NumberFormatOptions['currencyDisplay'];
|
|
19
|
-
} & NumericFormat) | ({
|
|
20
|
-
type: 'percentage';
|
|
21
|
-
} & NumericFormat) | {
|
|
22
|
-
type: 'boolean';
|
|
23
|
-
trueLabel?: string;
|
|
24
|
-
falseLabel?: string;
|
|
25
|
-
nullLabel?: string;
|
|
26
|
-
} | {
|
|
27
|
-
type: 'link';
|
|
28
|
-
href?: string | ((value: TValue, row: TData) => string);
|
|
29
|
-
target?: HTMLAnchorElement['target'];
|
|
30
|
-
fallback?: string;
|
|
31
|
-
};
|
|
32
|
-
export type DataTableCellType<TData extends RowData = RowData, TValue = unknown> = DataTableCellConfig<TData, TValue> | Exclude<DataTableCellConfig<TData, TValue>['type'], 'currency' | 'link'>;
|
|
33
|
-
export type DataTableColumnMeta<TData extends RowData = RowData, TValue = unknown> = {
|
|
34
|
-
dataTable?: {
|
|
35
|
-
align?: DataTableColumnAlign;
|
|
36
|
-
cell?: DataTableCellConfig<TData, TValue>;
|
|
37
|
-
filter?: DataTableFilterConfig<TValue>;
|
|
38
|
-
hasCustomCell?: boolean;
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
export type DataTableColumnAlign = 'left' | 'center' | 'right';
|
|
42
|
-
export type DataTableFilterOption<TValue = unknown> = {
|
|
43
|
-
label: string;
|
|
44
|
-
value: TValue;
|
|
45
|
-
};
|
|
46
|
-
export type DataTableFilterConfig<TValue = unknown> = {
|
|
47
|
-
type: 'text';
|
|
48
|
-
placeholder?: string;
|
|
49
|
-
} | {
|
|
50
|
-
type: 'facet';
|
|
51
|
-
options?: DataTableFilterOption<TValue>[];
|
|
52
|
-
maxOptions?: number;
|
|
53
|
-
} | {
|
|
54
|
-
type: 'number-range';
|
|
55
|
-
min?: number;
|
|
56
|
-
max?: number;
|
|
57
|
-
step?: number;
|
|
58
|
-
formatOptions?: Intl.NumberFormatOptions;
|
|
59
|
-
} | {
|
|
60
|
-
type: 'boolean';
|
|
61
|
-
trueLabel?: string;
|
|
62
|
-
falseLabel?: string;
|
|
63
|
-
};
|
|
64
|
-
export type DataTableFilterType<TValue = unknown> = DataTableFilterConfig<TValue> | DataTableFilterConfig<TValue>['type'];
|
|
65
|
-
type DataTableColumnDefOptions<TData extends RowData, TValue> = {
|
|
66
|
-
align?: DataTableColumnAlign;
|
|
67
|
-
cellType?: DataTableCellType<TData, TValue>;
|
|
68
|
-
filter?: DataTableFilterType<TValue>;
|
|
69
|
-
};
|
|
70
|
-
export type DataTableColumnDef<TData extends RowData, TValue extends CellData = CellData> = (AccessorKeyColumnDef<DataTableFeatures, TData, TValue> & DataTableColumnDefOptions<TData, TValue>) | (AccessorFnColumnDef<DataTableFeatures, TData, TValue> & DataTableColumnDefOptions<TData, TValue>) | (DisplayColumnDef<DataTableFeatures, TData, TValue> & DataTableColumnDefOptions<TData, TValue>) | (Omit<GroupColumnDef<DataTableFeatures, TData, TValue>, 'columns'> & DataTableColumnDefOptions<TData, TValue> & {
|
|
71
|
-
columns?: DataTableColumnDef<TData, CellData>[];
|
|
72
|
-
});
|
|
73
|
-
export type DataTableCell<TData extends RowData = RowData, TValue = unknown> = Cell<DataTableFeatures, TData, TValue>;
|
|
74
|
-
export declare function getDataTableCellConfig<TData extends RowData, TValue>(cell: DataTableCell<TData, TValue>): DataTableCellConfig<TData, TValue> | undefined;
|
|
75
|
-
export declare function getDataTableFilterConfig<TData extends RowData, TValue>(columnDef: ColumnDef<DataTableFeatures, TData, TValue>): DataTableFilterConfig<TValue> | undefined;
|
|
76
|
-
export declare function hasCustomDataTableCell<TData extends RowData, TValue>(cell: DataTableCell<TData, TValue>): boolean;
|
|
77
|
-
export declare function normalizeDataTableColumns<TData extends RowData>(columns: DataTableColumnDef<TData>[]): ColumnDef<DataTableFeatures, TData, CellData>[];
|
|
78
|
-
export {};
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
export function getDataTableCellConfig(cell) {
|
|
2
|
-
return cell.column.columnDef.meta?.dataTable
|
|
3
|
-
?.cell;
|
|
4
|
-
}
|
|
5
|
-
export function getDataTableFilterConfig(columnDef) {
|
|
6
|
-
return columnDef.meta?.dataTable?.filter;
|
|
7
|
-
}
|
|
8
|
-
export function hasCustomDataTableCell(cell) {
|
|
9
|
-
return (cell.column.columnDef.meta?.dataTable
|
|
10
|
-
?.hasCustomCell ?? false);
|
|
11
|
-
}
|
|
12
|
-
export function normalizeDataTableColumns(columns) {
|
|
13
|
-
return columns.map((columnDef) => {
|
|
14
|
-
const { cellType, filter, align, columns: childColumns, meta, ...column } = columnDef;
|
|
15
|
-
const cell = normalizeDataTableCellType(cellType);
|
|
16
|
-
const filterConfig = normalizeDataTableFilterType(filter);
|
|
17
|
-
const hasCustomCell = 'cell' in column;
|
|
18
|
-
const filterFn = 'filterFn' in column ? column.filterFn : getDefaultDataTableFilterFn(filterConfig);
|
|
19
|
-
const nextMeta = cell || align || filterConfig
|
|
20
|
-
? {
|
|
21
|
-
...(meta ?? {}),
|
|
22
|
-
dataTable: {
|
|
23
|
-
...(meta?.dataTable ?? {}),
|
|
24
|
-
...(align ? { align } : {}),
|
|
25
|
-
...(cell ? { cell } : {}),
|
|
26
|
-
...(filterConfig ? { filter: filterConfig } : {}),
|
|
27
|
-
hasCustomCell
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
: meta;
|
|
31
|
-
return {
|
|
32
|
-
...column,
|
|
33
|
-
...(childColumns ? { columns: normalizeDataTableColumns(childColumns) } : {}),
|
|
34
|
-
...(filterFn ? { filterFn } : {}),
|
|
35
|
-
...(nextMeta ? { meta: nextMeta } : {})
|
|
36
|
-
};
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
function normalizeDataTableCellType(cellType) {
|
|
40
|
-
if (!cellType)
|
|
41
|
-
return undefined;
|
|
42
|
-
return typeof cellType === 'string' ? { type: cellType } : cellType;
|
|
43
|
-
}
|
|
44
|
-
function normalizeDataTableFilterType(filter) {
|
|
45
|
-
if (!filter)
|
|
46
|
-
return undefined;
|
|
47
|
-
return typeof filter === 'string' ? { type: filter } : filter;
|
|
48
|
-
}
|
|
49
|
-
function getDefaultDataTableFilterFn(filter) {
|
|
50
|
-
if (!filter)
|
|
51
|
-
return undefined;
|
|
52
|
-
if (filter.type === 'facet')
|
|
53
|
-
return dataTableFacetFilter;
|
|
54
|
-
if (filter.type === 'number-range')
|
|
55
|
-
return 'inNumberRange';
|
|
56
|
-
if (filter.type === 'boolean')
|
|
57
|
-
return 'equals';
|
|
58
|
-
return 'includesString';
|
|
59
|
-
}
|
|
60
|
-
const dataTableFacetFilter = (row, columnId, filterValue) => {
|
|
61
|
-
if (!Array.isArray(filterValue) || filterValue.length === 0)
|
|
62
|
-
return true;
|
|
63
|
-
const value = row.getValue(columnId);
|
|
64
|
-
return filterValue.some((filterItem) => Object.is(filterItem, value));
|
|
65
|
-
};
|
|
66
|
-
dataTableFacetFilter.autoRemove = (filterValue) => !Array.isArray(filterValue) || filterValue.length === 0;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { RowData, SvelteTable, TableOptions, TableState, Updater } from '@tanstack/svelte-table';
|
|
2
|
-
import { type DataTableColumnDef } from './cells';
|
|
3
|
-
declare const dataTableFeatures: {
|
|
4
|
-
columnFilteringFeature: import("@tanstack/table-core").TableFeature<import("@tanstack/table-core").ColumnFilteringFeatureConstructors<import("@tanstack/table-core").TableFeatures, RowData>>;
|
|
5
|
-
columnFacetingFeature: import("@tanstack/table-core").TableFeature<import("@tanstack/table-core").ColumnFacetingFeatureConstructors<import("@tanstack/table-core").TableFeatures, RowData>>;
|
|
6
|
-
columnVisibilityFeature: import("@tanstack/table-core").TableFeature<import("@tanstack/table-core").ColumnVisibilityFeatureConstructors<import("@tanstack/table-core").TableFeatures, RowData>>;
|
|
7
|
-
columnSizingFeature: import("@tanstack/table-core").TableFeature<import("@tanstack/table-core").ColumnSizingFeatureConstructors<import("@tanstack/table-core").TableFeatures, RowData>>;
|
|
8
|
-
columnResizingFeature: import("@tanstack/table-core").TableFeature<import("@tanstack/table-core").ColumnResizingFeatureConstructors<import("@tanstack/table-core").TableFeatures, RowData>>;
|
|
9
|
-
rowSelectionFeature: import("@tanstack/table-core").TableFeature<import("@tanstack/table-core").RowSelectionFeatureConstructors<import("@tanstack/table-core").TableFeatures, RowData>>;
|
|
10
|
-
rowSortingFeature: import("@tanstack/table-core").TableFeature<import("@tanstack/table-core").RowSortingFeatureConstructors<import("@tanstack/table-core").TableFeatures, RowData>>;
|
|
11
|
-
};
|
|
12
|
-
export type DataTableFeatures = typeof dataTableFeatures;
|
|
13
|
-
type DataTableData<TData extends RowData> = ReadonlyArray<TData> | (() => ReadonlyArray<TData>);
|
|
14
|
-
export type DataTableSelectedState = Pick<TableState<DataTableFeatures>, 'columnFilters' | 'columnResizing' | 'columnVisibility' | 'rowSelection' | 'sorting'>;
|
|
15
|
-
export type DataTableOptions<TData extends RowData> = Omit<TableOptions<DataTableFeatures, TData>, '_features' | 'data' | 'columns'> & {
|
|
16
|
-
data: DataTableData<TData>;
|
|
17
|
-
columns: DataTableColumnDef<TData>[];
|
|
18
|
-
} & Partial<Pick<TableOptions<DataTableFeatures, TData>, '_features'>>;
|
|
19
|
-
export type DataTable<TData extends RowData, TSelected = DataTableSelectedState> = SvelteTable<DataTableFeatures, TData, TSelected> & {
|
|
20
|
-
setData: (data: ReadonlyArray<TData>) => void;
|
|
21
|
-
updateData: (updater: Updater<ReadonlyArray<TData>>) => void;
|
|
22
|
-
};
|
|
23
|
-
export declare function createDataTable<TData extends RowData, TSelected = DataTableSelectedState>(options: DataTableOptions<TData>, selector?: (state: TableState<DataTableFeatures>) => TSelected): DataTable<TData, TSelected>;
|
|
24
|
-
export {};
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { columnFacetingFeature, columnFilteringFeature, columnVisibilityFeature, columnResizingFeature, columnSizingFeature, createFacetedMinMaxValues, createFacetedRowModel, createFacetedUniqueValues, createCoreRowModel, createFilteredRowModel, createSortedRowModel, createTable as createTanStackTable, filterFns, functionalUpdate, rowSortingFeature, rowSelectionFeature, sortFns, tableFeatures } from '@tanstack/svelte-table';
|
|
2
|
-
import { normalizeDataTableColumns } from './cells';
|
|
3
|
-
const dataTableFeatures = tableFeatures({
|
|
4
|
-
columnFilteringFeature,
|
|
5
|
-
columnFacetingFeature,
|
|
6
|
-
columnVisibilityFeature,
|
|
7
|
-
columnSizingFeature,
|
|
8
|
-
columnResizingFeature,
|
|
9
|
-
rowSelectionFeature,
|
|
10
|
-
rowSortingFeature
|
|
11
|
-
});
|
|
12
|
-
const dataTableStateSelector = (state) => ({
|
|
13
|
-
columnFilters: state.columnFilters,
|
|
14
|
-
columnResizing: state.columnResizing,
|
|
15
|
-
columnVisibility: state.columnVisibility,
|
|
16
|
-
rowSelection: state.rowSelection,
|
|
17
|
-
sorting: state.sorting
|
|
18
|
-
});
|
|
19
|
-
class DataTableState {
|
|
20
|
-
#options = $state.raw({});
|
|
21
|
-
#table;
|
|
22
|
-
#columns;
|
|
23
|
-
constructor(options, selector) {
|
|
24
|
-
this.#options = options;
|
|
25
|
-
this.#columns = normalizeDataTableColumns(options.columns);
|
|
26
|
-
const getData = () => this.#getData();
|
|
27
|
-
this.#table = createTanStackTable({
|
|
28
|
-
...options,
|
|
29
|
-
columns: this.#columns,
|
|
30
|
-
enableRowSelection: options.enableRowSelection ?? false,
|
|
31
|
-
get data() {
|
|
32
|
-
return getData();
|
|
33
|
-
},
|
|
34
|
-
_features: options._features ?? dataTableFeatures,
|
|
35
|
-
_rowModels: {
|
|
36
|
-
coreRowModel: createCoreRowModel(),
|
|
37
|
-
filteredRowModel: createFilteredRowModel(filterFns),
|
|
38
|
-
facetedRowModel: createFacetedRowModel(),
|
|
39
|
-
facetedUniqueValues: createFacetedUniqueValues(),
|
|
40
|
-
facetedMinMaxValues: createFacetedMinMaxValues(),
|
|
41
|
-
sortedRowModel: createSortedRowModel(sortFns),
|
|
42
|
-
...options._rowModels
|
|
43
|
-
}
|
|
44
|
-
}, selector ?? dataTableStateSelector);
|
|
45
|
-
}
|
|
46
|
-
get table() {
|
|
47
|
-
const table = this.#table;
|
|
48
|
-
table.setData = (data) => {
|
|
49
|
-
this.setData(data);
|
|
50
|
-
};
|
|
51
|
-
table.updateData = (updater) => {
|
|
52
|
-
this.updateData(updater);
|
|
53
|
-
};
|
|
54
|
-
return table;
|
|
55
|
-
}
|
|
56
|
-
setData(data) {
|
|
57
|
-
this.#options = {
|
|
58
|
-
...this.#options,
|
|
59
|
-
data
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
updateData(updater) {
|
|
63
|
-
this.setData(functionalUpdate(updater, this.#getData()));
|
|
64
|
-
}
|
|
65
|
-
#resolveData(data) {
|
|
66
|
-
return typeof data === 'function' ? data() : data;
|
|
67
|
-
}
|
|
68
|
-
#getData() {
|
|
69
|
-
return this.#resolveData(this.#options.data);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
export function createDataTable(options, selector) {
|
|
73
|
-
return new DataTableState(options, selector).table;
|
|
74
|
-
}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export { createDataTable } from './create-table.svelte';
|
|
2
|
-
export type { DataTable, DataTableFeatures, DataTableOptions, DataTableSelectedState } from './create-table.svelte';
|
|
3
|
-
export { getDataTableCellConfig, getDataTableFilterConfig, hasCustomDataTableCell, normalizeDataTableColumns, type DataTableCell, type DataTableCellConfig, type DataTableCellType, type DataTableColumnAlign, type DataTableColumnDef, type DataTableColumnMeta, type DataTableFilterConfig, type DataTableFilterOption, type DataTableFilterType } from './cells';
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
<script lang="ts" generics="TData extends RowData, TSelected = object">
|
|
2
|
-
import * as Popover from '../popover';
|
|
3
|
-
import * as ScrollArea from '../scroll-area';
|
|
4
|
-
import Checkbox from '../checkbox/checkbox.svelte';
|
|
5
|
-
import type { Column, RowData } from '@tanstack/svelte-table';
|
|
6
|
-
import type { DataTable, DataTableFeatures, DataTableSelectedState } from './core';
|
|
7
|
-
|
|
8
|
-
type Props = {
|
|
9
|
-
table: DataTable<TData, TSelected>;
|
|
10
|
-
triggerLabel?: string;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
let { table, triggerLabel = 'Columns' }: Props = $props();
|
|
14
|
-
|
|
15
|
-
const columnVisibility = $derived(
|
|
16
|
-
(table.state as unknown as DataTableSelectedState).columnVisibility
|
|
17
|
-
);
|
|
18
|
-
const allColumnsVisible = $derived(table.getIsAllColumnsVisible());
|
|
19
|
-
const someColumnsVisible = $derived(
|
|
20
|
-
table.getAllLeafColumns().some((column) => column.getCanHide() && column.getIsVisible())
|
|
21
|
-
);
|
|
22
|
-
const allColumnsVisibilityState = $derived(
|
|
23
|
-
allColumnsVisible ? true : someColumnsVisible ? 'indeterminate' : false
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
function getColumnLabel(column: Column<DataTableFeatures, TData, unknown>) {
|
|
27
|
-
return typeof column.columnDef.header === 'string' ? column.columnDef.header : column.id;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function getColumnIsVisible(
|
|
31
|
-
column: Column<DataTableFeatures, TData, unknown>,
|
|
32
|
-
visibilityState: unknown
|
|
33
|
-
) {
|
|
34
|
-
void visibilityState;
|
|
35
|
-
return column.getIsVisible();
|
|
36
|
-
}
|
|
37
|
-
</script>
|
|
38
|
-
|
|
39
|
-
<Popover.Root positioning={{ placement: 'bottom-end' }}>
|
|
40
|
-
<Popover.Trigger
|
|
41
|
-
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"
|
|
42
|
-
>
|
|
43
|
-
{triggerLabel}
|
|
44
|
-
</Popover.Trigger>
|
|
45
|
-
|
|
46
|
-
<Popover.Content class="w-56 p-2" showArrow={false}>
|
|
47
|
-
<div class="border-b border-surface-3 px-2 pb-2">
|
|
48
|
-
<Checkbox
|
|
49
|
-
size="sm"
|
|
50
|
-
label="All columns"
|
|
51
|
-
checked={allColumnsVisibilityState}
|
|
52
|
-
onCheckedChange={({ checked }) => table.toggleAllColumnsVisible(checked === true)}
|
|
53
|
-
/>
|
|
54
|
-
</div>
|
|
55
|
-
|
|
56
|
-
<ScrollArea.Root class="h-72">
|
|
57
|
-
<ScrollArea.Viewport>
|
|
58
|
-
<ScrollArea.Content class="py-1 pe-3">
|
|
59
|
-
<div class="flex flex-col">
|
|
60
|
-
{#each table.getAllLeafColumns() as column (column.id)}
|
|
61
|
-
<Checkbox
|
|
62
|
-
size="md"
|
|
63
|
-
label={getColumnLabel(column)}
|
|
64
|
-
class="min-h-8 rounded-sm px-2 hover:bg-surface-2"
|
|
65
|
-
checked={getColumnIsVisible(column, columnVisibility)}
|
|
66
|
-
disabled={!column.getCanHide()}
|
|
67
|
-
onCheckedChange={({ checked }) => column.toggleVisibility(checked === true)}
|
|
68
|
-
/>
|
|
69
|
-
{/each}
|
|
70
|
-
</div>
|
|
71
|
-
</ScrollArea.Content>
|
|
72
|
-
</ScrollArea.Viewport>
|
|
73
|
-
<ScrollArea.Scrollbar orientation="vertical">
|
|
74
|
-
<ScrollArea.Thumb />
|
|
75
|
-
</ScrollArea.Scrollbar>
|
|
76
|
-
<ScrollArea.Corner />
|
|
77
|
-
</ScrollArea.Root>
|
|
78
|
-
</Popover.Content>
|
|
79
|
-
</Popover.Root>
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { RowData } from '@tanstack/svelte-table';
|
|
2
|
-
import type { DataTable } from './core';
|
|
3
|
-
declare function $$render<TData extends RowData, TSelected = object>(): {
|
|
4
|
-
props: {
|
|
5
|
-
table: DataTable<TData, TSelected>;
|
|
6
|
-
triggerLabel?: string;
|
|
7
|
-
};
|
|
8
|
-
exports: {};
|
|
9
|
-
bindings: "";
|
|
10
|
-
slots: {};
|
|
11
|
-
events: {};
|
|
12
|
-
};
|
|
13
|
-
declare class __sveltets_Render<TData extends RowData, TSelected = object> {
|
|
14
|
-
props(): ReturnType<typeof $$render<TData, TSelected>>['props'];
|
|
15
|
-
events(): ReturnType<typeof $$render<TData, TSelected>>['events'];
|
|
16
|
-
slots(): ReturnType<typeof $$render<TData, TSelected>>['slots'];
|
|
17
|
-
bindings(): "";
|
|
18
|
-
exports(): {};
|
|
19
|
-
}
|
|
20
|
-
interface $$IsomorphicComponent {
|
|
21
|
-
new <TData extends RowData, TSelected = object>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<TData, TSelected>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<TData, TSelected>['props']>, ReturnType<__sveltets_Render<TData, TSelected>['events']>, ReturnType<__sveltets_Render<TData, TSelected>['slots']>> & {
|
|
22
|
-
$$bindings?: ReturnType<__sveltets_Render<TData, TSelected>['bindings']>;
|
|
23
|
-
} & ReturnType<__sveltets_Render<TData, TSelected>['exports']>;
|
|
24
|
-
<TData extends RowData, TSelected = object>(internal: unknown, props: ReturnType<__sveltets_Render<TData, TSelected>['props']> & {}): ReturnType<__sveltets_Render<TData, TSelected>['exports']>;
|
|
25
|
-
z_$$bindings?: ReturnType<__sveltets_Render<any, any>['bindings']>;
|
|
26
|
-
}
|
|
27
|
-
declare const DataTableColumnVisibility: $$IsomorphicComponent;
|
|
28
|
-
type DataTableColumnVisibility<TData extends RowData, TSelected = object> = InstanceType<typeof DataTableColumnVisibility<TData, TSelected>>;
|
|
29
|
-
export default DataTableColumnVisibility;
|
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
<script lang="ts" generics="TData extends RowData, TSelected = object">
|
|
2
|
-
import * as Field from '../field';
|
|
3
|
-
import * as Popover from '../popover';
|
|
4
|
-
import * as ScrollArea from '../scroll-area';
|
|
5
|
-
import * as Fieldset from '../fieldset';
|
|
6
|
-
import Checkbox from '../checkbox/checkbox.svelte';
|
|
7
|
-
import Button from '../button/button.svelte';
|
|
8
|
-
import NumberInput from '../number-input/number-input.svelte';
|
|
9
|
-
import Select from '../select/select.svelte';
|
|
10
|
-
import type { Column, RowData } from '@tanstack/svelte-table';
|
|
11
|
-
import {
|
|
12
|
-
getDataTableFilterConfig,
|
|
13
|
-
type DataTable,
|
|
14
|
-
type DataTableFeatures,
|
|
15
|
-
type DataTableFilterConfig,
|
|
16
|
-
type DataTableFilterOption,
|
|
17
|
-
type DataTableSelectedState
|
|
18
|
-
} from './core';
|
|
19
|
-
|
|
20
|
-
type Props = {
|
|
21
|
-
table: DataTable<TData, TSelected>;
|
|
22
|
-
triggerLabel?: string;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
type FilterableColumn = Column<DataTableFeatures, TData, unknown>;
|
|
26
|
-
|
|
27
|
-
let { table, triggerLabel = 'Filters' }: Props = $props();
|
|
28
|
-
|
|
29
|
-
const columnFilters = $derived((table.state as unknown as DataTableSelectedState).columnFilters);
|
|
30
|
-
const activeFilterCount = $derived(columnFilters.length);
|
|
31
|
-
const filterableColumns = $derived(
|
|
32
|
-
table
|
|
33
|
-
.getAllLeafColumns()
|
|
34
|
-
.filter((column) => column.getCanFilter() && getDataTableFilterConfig(column.columnDef))
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
function getColumnLabel(column: FilterableColumn) {
|
|
38
|
-
return typeof column.columnDef.header === 'string' ? column.columnDef.header : column.id;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function getFilterConfig(column: FilterableColumn, filtersState: unknown) {
|
|
42
|
-
void filtersState;
|
|
43
|
-
return getDataTableFilterConfig(column.columnDef);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function getFilterValue(column: FilterableColumn, filtersState: unknown) {
|
|
47
|
-
void filtersState;
|
|
48
|
-
return column.getFilterValue();
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function setTextFilter(column: FilterableColumn, value: string) {
|
|
52
|
-
column.setFilterValue(value || undefined);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function setBooleanFilter(column: FilterableColumn, value: string) {
|
|
56
|
-
if (value === 'true') {
|
|
57
|
-
column.setFilterValue(true);
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (value === 'false') {
|
|
62
|
-
column.setFilterValue(false);
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
column.setFilterValue(undefined);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function setNumberRangeFilter(column: FilterableColumn, index: 0 | 1, value: number | null) {
|
|
70
|
-
const currentValue = column.getFilterValue();
|
|
71
|
-
const current = Array.isArray(currentValue) ? currentValue : [];
|
|
72
|
-
const next = [current[0], current[1]] as [number | undefined, number | undefined];
|
|
73
|
-
next[index] = value ?? undefined;
|
|
74
|
-
|
|
75
|
-
column.setFilterValue(next[0] === undefined && next[1] === undefined ? undefined : next);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function getNumberRangeValue(
|
|
79
|
-
column: FilterableColumn,
|
|
80
|
-
filtersState: unknown
|
|
81
|
-
): [number | undefined, number | undefined] {
|
|
82
|
-
const value = getFilterValue(column, filtersState);
|
|
83
|
-
return Array.isArray(value) ? [value[0], value[1]] : [undefined, undefined];
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function getFacetOptions(
|
|
87
|
-
column: FilterableColumn,
|
|
88
|
-
config: DataTableFilterConfig,
|
|
89
|
-
filtersState: unknown
|
|
90
|
-
): DataTableFilterOption[] {
|
|
91
|
-
void filtersState;
|
|
92
|
-
|
|
93
|
-
if (config.type !== 'facet') return [];
|
|
94
|
-
if (config.options) return config.options;
|
|
95
|
-
|
|
96
|
-
return Array.from(column.getFacetedUniqueValues().entries())
|
|
97
|
-
.sort(([a], [b]) => String(a).localeCompare(String(b)))
|
|
98
|
-
.slice(0, config.maxOptions ?? 20)
|
|
99
|
-
.map(([value, count]) => ({
|
|
100
|
-
value,
|
|
101
|
-
label: `${String(value)} (${count})`
|
|
102
|
-
}));
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function getFacetFilterValue(column: FilterableColumn, filtersState: unknown) {
|
|
106
|
-
const value = getFilterValue(column, filtersState);
|
|
107
|
-
return Array.isArray(value) ? value : [];
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function getFacetOptionChecked(
|
|
111
|
-
column: FilterableColumn,
|
|
112
|
-
option: DataTableFilterOption,
|
|
113
|
-
filtersState: unknown
|
|
114
|
-
) {
|
|
115
|
-
return getFacetFilterValue(column, filtersState).some((value) =>
|
|
116
|
-
Object.is(value, option.value)
|
|
117
|
-
);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
function toggleFacetFilterValue(
|
|
121
|
-
column: FilterableColumn,
|
|
122
|
-
option: DataTableFilterOption,
|
|
123
|
-
checked: boolean
|
|
124
|
-
) {
|
|
125
|
-
const currentValue = column.getFilterValue();
|
|
126
|
-
const current = Array.isArray(currentValue) ? currentValue : [];
|
|
127
|
-
const next = checked
|
|
128
|
-
? [...current, option.value]
|
|
129
|
-
: current.filter((value) => !Object.is(value, option.value));
|
|
130
|
-
|
|
131
|
-
column.setFilterValue(next.length > 0 ? next : undefined);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
function getBooleanFilterValue(column: FilterableColumn, filtersState: unknown) {
|
|
135
|
-
const value = getFilterValue(column, filtersState);
|
|
136
|
-
if (value === true) return 'true';
|
|
137
|
-
if (value === false) return 'false';
|
|
138
|
-
return null;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
function getBooleanLabel(config: DataTableFilterConfig, value: boolean) {
|
|
142
|
-
if (config.type !== 'boolean') return value ? 'True' : 'False';
|
|
143
|
-
return value ? (config.trueLabel ?? 'True') : (config.falseLabel ?? 'False');
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
function getBooleanFilterItems(config: DataTableFilterConfig) {
|
|
147
|
-
return [
|
|
148
|
-
{ value: 'true', label: getBooleanLabel(config, true) },
|
|
149
|
-
{ value: 'false', label: getBooleanLabel(config, false) }
|
|
150
|
-
];
|
|
151
|
-
}
|
|
152
|
-
</script>
|
|
153
|
-
|
|
154
|
-
<Popover.Root positioning={{ placement: 'bottom-end' }}>
|
|
155
|
-
<Popover.Trigger
|
|
156
|
-
class="flex h-9 cursor-pointer items-center gap-2 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"
|
|
157
|
-
>
|
|
158
|
-
<span>{triggerLabel}</span>
|
|
159
|
-
{#if activeFilterCount > 0}
|
|
160
|
-
<span class="rounded-full bg-surface-3 px-1.5 text-xs text-ink-dim">
|
|
161
|
-
{activeFilterCount}
|
|
162
|
-
</span>
|
|
163
|
-
{/if}
|
|
164
|
-
</Popover.Trigger>
|
|
165
|
-
|
|
166
|
-
<Popover.Content class="w-80 p-0" showArrow={false}>
|
|
167
|
-
<Popover.Title class="flex items-center justify-between gap-3 border-b px-4 py-2">
|
|
168
|
-
<div class="text-sm font-medium text-ink">Filters</div>
|
|
169
|
-
<Button
|
|
170
|
-
variant="ghost"
|
|
171
|
-
disabled={activeFilterCount === 0}
|
|
172
|
-
onclick={() => table.resetColumnFilters(true)}
|
|
173
|
-
>
|
|
174
|
-
Clear
|
|
175
|
-
</Button>
|
|
176
|
-
</Popover.Title>
|
|
177
|
-
|
|
178
|
-
{#if filterableColumns.length === 0}
|
|
179
|
-
<div class="py-2 text-sm text-ink-dim">No filters available</div>
|
|
180
|
-
{:else}
|
|
181
|
-
<ScrollArea.Root class="h-96">
|
|
182
|
-
<ScrollArea.Viewport>
|
|
183
|
-
<ScrollArea.Content>
|
|
184
|
-
<div class="flex flex-col gap-4">
|
|
185
|
-
{#each filterableColumns as column (column.id)}
|
|
186
|
-
{@const config = getFilterConfig(column, columnFilters)}
|
|
187
|
-
{#if config}
|
|
188
|
-
<div class="space-y-2">
|
|
189
|
-
{#if config.type === 'text'}
|
|
190
|
-
<Field.Root>
|
|
191
|
-
<Field.Label>{getColumnLabel(column)}</Field.Label>
|
|
192
|
-
<Field.Input
|
|
193
|
-
type="search"
|
|
194
|
-
placeholder={config.placeholder ?? `Search ${getColumnLabel(column)}`}
|
|
195
|
-
value={String(getFilterValue(column, columnFilters) ?? '')}
|
|
196
|
-
oninput={(event) =>
|
|
197
|
-
setTextFilter(column, (event.currentTarget as HTMLInputElement).value)}
|
|
198
|
-
/>
|
|
199
|
-
</Field.Root>
|
|
200
|
-
{:else if config.type === 'number-range'}
|
|
201
|
-
{@const rangeValue = getNumberRangeValue(column, columnFilters)}
|
|
202
|
-
<div class="text-sm font-medium text-ink">{getColumnLabel(column)}</div>
|
|
203
|
-
<div class="grid grid-cols-2 gap-2">
|
|
204
|
-
<NumberInput
|
|
205
|
-
label="Min"
|
|
206
|
-
min={config.min}
|
|
207
|
-
max={config.max}
|
|
208
|
-
step={config.step}
|
|
209
|
-
formatOptions={config.formatOptions ?? { minimumFractionDigits: 0 }}
|
|
210
|
-
value={rangeValue[0] ?? null}
|
|
211
|
-
onValueChange={({ valueAsNumber }) =>
|
|
212
|
-
setNumberRangeFilter(
|
|
213
|
-
column,
|
|
214
|
-
0,
|
|
215
|
-
Number.isNaN(valueAsNumber) ? null : valueAsNumber
|
|
216
|
-
)}
|
|
217
|
-
/>
|
|
218
|
-
<NumberInput
|
|
219
|
-
label="Max"
|
|
220
|
-
min={config.min}
|
|
221
|
-
max={config.max}
|
|
222
|
-
step={config.step}
|
|
223
|
-
formatOptions={config.formatOptions ?? { minimumFractionDigits: 0 }}
|
|
224
|
-
value={rangeValue[1] ?? null}
|
|
225
|
-
onValueChange={({ valueAsNumber }) =>
|
|
226
|
-
setNumberRangeFilter(
|
|
227
|
-
column,
|
|
228
|
-
1,
|
|
229
|
-
Number.isNaN(valueAsNumber) ? null : valueAsNumber
|
|
230
|
-
)}
|
|
231
|
-
/>
|
|
232
|
-
</div>
|
|
233
|
-
{:else if config.type === 'boolean'}
|
|
234
|
-
<Select
|
|
235
|
-
label={getColumnLabel(column)}
|
|
236
|
-
items={getBooleanFilterItems(config)}
|
|
237
|
-
placeholder="All"
|
|
238
|
-
value={getBooleanFilterValue(column, columnFilters)}
|
|
239
|
-
onValueChange={({ value }) =>
|
|
240
|
-
setBooleanFilter(
|
|
241
|
-
column,
|
|
242
|
-
Array.isArray(value) && value.length > 0 ? value[0] : ''
|
|
243
|
-
)}
|
|
244
|
-
/>
|
|
245
|
-
{:else if config.type === 'facet'}
|
|
246
|
-
<Fieldset.Root class="max-h-44">
|
|
247
|
-
<Fieldset.Legend>{getColumnLabel(column)}</Fieldset.Legend>
|
|
248
|
-
<ScrollArea.Root class="hrounded-md border border-surface-3">
|
|
249
|
-
<ScrollArea.Viewport>
|
|
250
|
-
<ScrollArea.Content class="p-1 pe-3">
|
|
251
|
-
<div class="flex flex-col">
|
|
252
|
-
{#each getFacetOptions(column, config, columnFilters) as option (String(option.value))}
|
|
253
|
-
<Checkbox
|
|
254
|
-
size="sm"
|
|
255
|
-
label={option.label}
|
|
256
|
-
class="min-h-8 rounded-sm px-2 hover:bg-surface-2"
|
|
257
|
-
checked={getFacetOptionChecked(column, option, columnFilters)}
|
|
258
|
-
onCheckedChange={({ checked }) =>
|
|
259
|
-
toggleFacetFilterValue(column, option, checked === true)}
|
|
260
|
-
/>
|
|
261
|
-
{/each}
|
|
262
|
-
</div>
|
|
263
|
-
</ScrollArea.Content>
|
|
264
|
-
</ScrollArea.Viewport>
|
|
265
|
-
<ScrollArea.Scrollbar orientation="vertical">
|
|
266
|
-
<ScrollArea.Thumb />
|
|
267
|
-
</ScrollArea.Scrollbar>
|
|
268
|
-
<ScrollArea.Corner />
|
|
269
|
-
</ScrollArea.Root>
|
|
270
|
-
</Fieldset.Root>
|
|
271
|
-
{/if}
|
|
272
|
-
</div>
|
|
273
|
-
{/if}
|
|
274
|
-
{/each}
|
|
275
|
-
</div>
|
|
276
|
-
</ScrollArea.Content>
|
|
277
|
-
</ScrollArea.Viewport>
|
|
278
|
-
<ScrollArea.Scrollbar orientation="vertical">
|
|
279
|
-
<ScrollArea.Thumb />
|
|
280
|
-
</ScrollArea.Scrollbar>
|
|
281
|
-
<ScrollArea.Corner />
|
|
282
|
-
</ScrollArea.Root>
|
|
283
|
-
{/if}
|
|
284
|
-
</Popover.Content>
|
|
285
|
-
</Popover.Root>
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { RowData } from '@tanstack/svelte-table';
|
|
2
|
-
import { type DataTable } from './core';
|
|
3
|
-
declare function $$render<TData extends RowData, TSelected = object>(): {
|
|
4
|
-
props: {
|
|
5
|
-
table: DataTable<TData, TSelected>;
|
|
6
|
-
triggerLabel?: string;
|
|
7
|
-
};
|
|
8
|
-
exports: {};
|
|
9
|
-
bindings: "";
|
|
10
|
-
slots: {};
|
|
11
|
-
events: {};
|
|
12
|
-
};
|
|
13
|
-
declare class __sveltets_Render<TData extends RowData, TSelected = object> {
|
|
14
|
-
props(): ReturnType<typeof $$render<TData, TSelected>>['props'];
|
|
15
|
-
events(): ReturnType<typeof $$render<TData, TSelected>>['events'];
|
|
16
|
-
slots(): ReturnType<typeof $$render<TData, TSelected>>['slots'];
|
|
17
|
-
bindings(): "";
|
|
18
|
-
exports(): {};
|
|
19
|
-
}
|
|
20
|
-
interface $$IsomorphicComponent {
|
|
21
|
-
new <TData extends RowData, TSelected = object>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<TData, TSelected>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<TData, TSelected>['props']>, ReturnType<__sveltets_Render<TData, TSelected>['events']>, ReturnType<__sveltets_Render<TData, TSelected>['slots']>> & {
|
|
22
|
-
$$bindings?: ReturnType<__sveltets_Render<TData, TSelected>['bindings']>;
|
|
23
|
-
} & ReturnType<__sveltets_Render<TData, TSelected>['exports']>;
|
|
24
|
-
<TData extends RowData, TSelected = object>(internal: unknown, props: ReturnType<__sveltets_Render<TData, TSelected>['props']> & {}): ReturnType<__sveltets_Render<TData, TSelected>['exports']>;
|
|
25
|
-
z_$$bindings?: ReturnType<__sveltets_Render<any, any>['bindings']>;
|
|
26
|
-
}
|
|
27
|
-
declare const DataTableFilters: $$IsomorphicComponent;
|
|
28
|
-
type DataTableFilters<TData extends RowData, TSelected = object> = InstanceType<typeof DataTableFilters<TData, TSelected>>;
|
|
29
|
-
export default DataTableFilters;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { cn, type ClassValue } from 'tailwind-variants';
|
|
3
|
-
import type { HTMLAttributes } from 'svelte/elements';
|
|
4
|
-
import type { Snippet } from 'svelte';
|
|
5
|
-
|
|
6
|
-
type Props = Omit<HTMLAttributes<HTMLHeadingElement>, 'class'> & {
|
|
7
|
-
class?: ClassValue;
|
|
8
|
-
children?: Snippet;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
let { class: className, children, ...rest }: Props = $props();
|
|
12
|
-
</script>
|
|
13
|
-
|
|
14
|
-
<h2 class={cn('text-lg font-semibold text-ink', className)} {...rest}>
|
|
15
|
-
{@render children?.()}
|
|
16
|
-
</h2>
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type ClassValue } from 'tailwind-variants';
|
|
2
|
-
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
-
import type { Snippet } from 'svelte';
|
|
4
|
-
type Props = Omit<HTMLAttributes<HTMLHeadingElement>, 'class'> & {
|
|
5
|
-
class?: ClassValue;
|
|
6
|
-
children?: Snippet;
|
|
7
|
-
};
|
|
8
|
-
declare const DataTableTitle: import("svelte").Component<Props, {}, "">;
|
|
9
|
-
type DataTableTitle = ReturnType<typeof DataTableTitle>;
|
|
10
|
-
export default DataTableTitle;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { cn, type ClassValue } from 'tailwind-variants';
|
|
3
|
-
import type { HTMLAttributes } from 'svelte/elements';
|
|
4
|
-
import type { Snippet } from 'svelte';
|
|
5
|
-
|
|
6
|
-
type Props = Omit<HTMLAttributes<HTMLDivElement>, 'class'> & {
|
|
7
|
-
class?: ClassValue;
|
|
8
|
-
children?: Snippet;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
let { class: className, children, ...rest }: Props = $props();
|
|
12
|
-
</script>
|
|
13
|
-
|
|
14
|
-
<div class={cn('mb-4 flex flex-wrap items-center justify-between gap-3', className)} {...rest}>
|
|
15
|
-
{@render children?.()}
|
|
16
|
-
</div>
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type ClassValue } from 'tailwind-variants';
|
|
2
|
-
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
-
import type { Snippet } from 'svelte';
|
|
4
|
-
type Props = Omit<HTMLAttributes<HTMLDivElement>, 'class'> & {
|
|
5
|
-
class?: ClassValue;
|
|
6
|
-
children?: Snippet;
|
|
7
|
-
};
|
|
8
|
-
declare const DataTableToolbar: import("svelte").Component<Props, {}, "">;
|
|
9
|
-
type DataTableToolbar = ReturnType<typeof DataTableToolbar>;
|
|
10
|
-
export default DataTableToolbar;
|
|
@@ -1,342 +0,0 @@
|
|
|
1
|
-
<script lang="ts" generics="TData extends RowData, TSelected = object">
|
|
2
|
-
import { useLocaleContext } from '@ark-ui/svelte/locale';
|
|
3
|
-
import { FlexRender } from '@tanstack/svelte-table';
|
|
4
|
-
import { cn, type ClassValue } from 'tailwind-variants';
|
|
5
|
-
import { PhArrowSquareOut, PhCaretDown, PhCaretUp } from '../../icons';
|
|
6
|
-
import Checkbox from '../checkbox/checkbox.svelte';
|
|
7
|
-
import type { HTMLAttributes } from 'svelte/elements';
|
|
8
|
-
import type { Header, RowData } from '@tanstack/svelte-table';
|
|
9
|
-
import {
|
|
10
|
-
getDataTableCellConfig,
|
|
11
|
-
hasCustomDataTableCell,
|
|
12
|
-
type DataTable,
|
|
13
|
-
type DataTableCell,
|
|
14
|
-
type DataTableCellConfig,
|
|
15
|
-
type DataTableColumnAlign,
|
|
16
|
-
type DataTableColumnMeta,
|
|
17
|
-
type DataTableFeatures
|
|
18
|
-
} from './core';
|
|
19
|
-
|
|
20
|
-
type Props = Omit<HTMLAttributes<HTMLDivElement>, 'class'> & {
|
|
21
|
-
table: DataTable<TData, TSelected>;
|
|
22
|
-
class?: ClassValue;
|
|
23
|
-
tableClass?: ClassValue;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
let { table, class: className, tableClass, ...rest }: Props = $props();
|
|
27
|
-
|
|
28
|
-
const locale = useLocaleContext();
|
|
29
|
-
const columnCount = $derived(table.getVisibleLeafColumns().length);
|
|
30
|
-
const headerGroupCount = $derived(table.getHeaderGroups().length);
|
|
31
|
-
const isRowSelectionEnabled = $derived(Boolean(table.options.enableRowSelection));
|
|
32
|
-
const isMultiRowSelectionEnabled = $derived(table.options.enableMultiRowSelection !== false);
|
|
33
|
-
const tableColumnCount = $derived(columnCount + (isRowSelectionEnabled ? 1 : 0));
|
|
34
|
-
const allRowsSelected = $derived(table.getIsAllRowsSelected());
|
|
35
|
-
const someRowsSelected = $derived(table.getIsSomeRowsSelected());
|
|
36
|
-
const allRowsSelectionState = $derived(
|
|
37
|
-
allRowsSelected ? true : someRowsSelected ? 'indeterminate' : false
|
|
38
|
-
);
|
|
39
|
-
const rowSelectionColumnSize = 40;
|
|
40
|
-
const tableSize = $derived(
|
|
41
|
-
table.getTotalSize() + (isRowSelectionEnabled ? rowSelectionColumnSize : 0)
|
|
42
|
-
);
|
|
43
|
-
const isColumnResizing = $derived(table.store.state.columnResizing.isResizingColumn !== false);
|
|
44
|
-
|
|
45
|
-
function formatNumericValue(
|
|
46
|
-
value: unknown,
|
|
47
|
-
options: Intl.NumberFormatOptions & { locale?: string }
|
|
48
|
-
) {
|
|
49
|
-
if (typeof value !== 'number') return formatTextValue(value);
|
|
50
|
-
const { locale: optionLocale, ...numberFormatOptions } = options;
|
|
51
|
-
return new Intl.NumberFormat(optionLocale ?? locale().locale, numberFormatOptions).format(
|
|
52
|
-
value
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function formatTextValue(value: unknown, fallback = '') {
|
|
57
|
-
if (value === null || value === undefined || value === '') return fallback;
|
|
58
|
-
return String(value);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function fractionOptions(options: { fractionDigits?: number }) {
|
|
62
|
-
if (options.fractionDigits === undefined) return {};
|
|
63
|
-
|
|
64
|
-
return {
|
|
65
|
-
minimumFractionDigits: options.fractionDigits,
|
|
66
|
-
maximumFractionDigits: options.fractionDigits
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function isNumericCellConfig(cellConfig: DataTableCellConfig<TData> | undefined) {
|
|
71
|
-
return (
|
|
72
|
-
cellConfig?.type === 'number' ||
|
|
73
|
-
cellConfig?.type === 'currency' ||
|
|
74
|
-
cellConfig?.type === 'percentage'
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function getLinkHref<TValue>(
|
|
79
|
-
cell: DataTableCell<TData, TValue>,
|
|
80
|
-
href: string | ((value: TValue, row: TData) => string) | undefined
|
|
81
|
-
) {
|
|
82
|
-
const value = cell.getValue();
|
|
83
|
-
if (!href) return formatTextValue(value);
|
|
84
|
-
return typeof href === 'function' ? href(value, cell.row.original) : href;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function getLinkLabel(value: unknown, fallback = 'Open link') {
|
|
88
|
-
return formatTextValue(value, fallback);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function getCellMeta<TValue>(cell: DataTableCell<TData, TValue>) {
|
|
92
|
-
return (cell.column.columnDef.meta as DataTableColumnMeta<TData, TValue> | undefined)
|
|
93
|
-
?.dataTable;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function getHeaderMeta(header: Header<DataTableFeatures, TData, unknown>) {
|
|
97
|
-
return header.column.columnDef.meta as DataTableColumnMeta<TData> | undefined;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function getColumnAlign(
|
|
101
|
-
align: DataTableColumnAlign | undefined,
|
|
102
|
-
cellConfig: DataTableCellConfig<TData> | undefined
|
|
103
|
-
) {
|
|
104
|
-
return align ?? (isNumericCellConfig(cellConfig) ? 'right' : 'left');
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function alignClass(align: DataTableColumnAlign | undefined) {
|
|
108
|
-
return {
|
|
109
|
-
left: 'text-left',
|
|
110
|
-
center: 'text-center',
|
|
111
|
-
right: 'text-right'
|
|
112
|
-
}[align ?? 'left'];
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function justifyClass(align: DataTableColumnAlign | undefined) {
|
|
116
|
-
return {
|
|
117
|
-
left: 'justify-start',
|
|
118
|
-
center: 'justify-center',
|
|
119
|
-
right: 'justify-end'
|
|
120
|
-
}[align ?? 'left'];
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
function sortButtonDirectionClass(align: DataTableColumnAlign | undefined) {
|
|
124
|
-
return align === 'right' ? 'flex-row-reverse' : 'flex-row';
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function columnSizeStyle(size: number) {
|
|
128
|
-
return `width: ${size}px`;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function tableSizeStyle() {
|
|
132
|
-
return `width: max(100%, ${tableSize}px)`;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
function resizeHandleStyle(header: Header<DataTableFeatures, TData, unknown>) {
|
|
136
|
-
if (table.options.columnResizeMode !== 'onEnd') return undefined;
|
|
137
|
-
const deltaOffset = table.store.state.columnResizing.deltaOffset;
|
|
138
|
-
if (!header.column.getIsResizing() || deltaOffset === null) return undefined;
|
|
139
|
-
return `transform: translateX(${deltaOffset}px)`;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function getHeaderSortDirection(
|
|
143
|
-
header: Header<DataTableFeatures, TData, unknown>,
|
|
144
|
-
sortingState: unknown
|
|
145
|
-
) {
|
|
146
|
-
void sortingState;
|
|
147
|
-
return header.column.getIsSorted();
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
function getHeaderSortLabel(sortDirection: false | 'asc' | 'desc') {
|
|
151
|
-
if (sortDirection === 'asc') return 'Sorted ascending';
|
|
152
|
-
if (sortDirection === 'desc') return 'Sorted descending';
|
|
153
|
-
return 'Not sorted';
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
function getHeaderAriaSort(sortDirection: false | 'asc' | 'desc') {
|
|
157
|
-
if (sortDirection === 'asc') return 'ascending';
|
|
158
|
-
if (sortDirection === 'desc') return 'descending';
|
|
159
|
-
return 'none';
|
|
160
|
-
}
|
|
161
|
-
</script>
|
|
162
|
-
|
|
163
|
-
<div
|
|
164
|
-
class={cn('max-h-full min-h-0 overflow-auto rounded-lg border border-surface-3', className)}
|
|
165
|
-
{...rest}
|
|
166
|
-
>
|
|
167
|
-
{#if isColumnResizing}
|
|
168
|
-
<div aria-hidden="true" class="fixed inset-0 z-50 cursor-col-resize select-none"></div>
|
|
169
|
-
{/if}
|
|
170
|
-
|
|
171
|
-
<table class={cn('table-fixed border-collapse text-sm', tableClass)} style={tableSizeStyle()}>
|
|
172
|
-
<colgroup>
|
|
173
|
-
{#if isRowSelectionEnabled}
|
|
174
|
-
<col style={columnSizeStyle(rowSelectionColumnSize)} />
|
|
175
|
-
{/if}
|
|
176
|
-
{#each table.getVisibleLeafColumns() as column (column.id)}
|
|
177
|
-
<col style={columnSizeStyle(column.getSize())} />
|
|
178
|
-
{/each}
|
|
179
|
-
</colgroup>
|
|
180
|
-
<thead class="sticky top-0 z-20 bg-surface-2 text-left text-ink-dim">
|
|
181
|
-
{#each table.getHeaderGroups() as headerGroup, headerGroupIndex (headerGroup.id)}
|
|
182
|
-
<tr>
|
|
183
|
-
{#if isRowSelectionEnabled && headerGroupIndex === 0}
|
|
184
|
-
<th
|
|
185
|
-
class="border-b border-surface-3 bg-surface-2 px-3 py-2 text-center align-middle font-medium"
|
|
186
|
-
rowspan={headerGroupCount}
|
|
187
|
-
>
|
|
188
|
-
{#if isMultiRowSelectionEnabled}
|
|
189
|
-
<Checkbox
|
|
190
|
-
size="sm"
|
|
191
|
-
aria-label="Select all rows"
|
|
192
|
-
class="mx-auto size-4"
|
|
193
|
-
checked={allRowsSelectionState}
|
|
194
|
-
onCheckedChange={({ checked }) => table.toggleAllRowsSelected(checked === true)}
|
|
195
|
-
/>
|
|
196
|
-
{/if}
|
|
197
|
-
</th>
|
|
198
|
-
{/if}
|
|
199
|
-
{#each headerGroup.headers as header (header.id)}
|
|
200
|
-
{@const headerMeta = getHeaderMeta(header)?.dataTable}
|
|
201
|
-
{@const headerAlign = getColumnAlign(headerMeta?.align, headerMeta?.cell)}
|
|
202
|
-
{@const sortDirection = getHeaderSortDirection(header, table.store.state.sorting)}
|
|
203
|
-
<th
|
|
204
|
-
class={cn(
|
|
205
|
-
'relative border-b border-surface-3 bg-surface-2 px-3 py-2 font-medium',
|
|
206
|
-
alignClass(headerAlign)
|
|
207
|
-
)}
|
|
208
|
-
colspan={header.colSpan}
|
|
209
|
-
aria-sort={header.column.getCanSort() ? getHeaderAriaSort(sortDirection) : undefined}
|
|
210
|
-
>
|
|
211
|
-
{#if !header.isPlaceholder}
|
|
212
|
-
{#if header.column.getCanSort()}
|
|
213
|
-
<button
|
|
214
|
-
type="button"
|
|
215
|
-
class={cn(
|
|
216
|
-
'inline-flex max-w-full items-center gap-1 rounded-sm outline-none hover:text-ink data-focus-visible:outline-2 data-focus-visible:outline-offset-2 data-focus-visible:outline-ring',
|
|
217
|
-
justifyClass(headerAlign),
|
|
218
|
-
sortButtonDirectionClass(headerAlign)
|
|
219
|
-
)}
|
|
220
|
-
aria-label={`${getHeaderSortLabel(sortDirection)}. Toggle sorting.`}
|
|
221
|
-
onclick={header.column.getToggleSortingHandler()}
|
|
222
|
-
>
|
|
223
|
-
<span class="min-w-0 truncate">
|
|
224
|
-
<FlexRender {header} />
|
|
225
|
-
</span>
|
|
226
|
-
<span
|
|
227
|
-
class="inline-flex size-3.5 shrink-0 items-center justify-center text-ink-dim"
|
|
228
|
-
>
|
|
229
|
-
{#if sortDirection === 'asc'}
|
|
230
|
-
<PhCaretUp class="size-3.5" />
|
|
231
|
-
{:else if sortDirection === 'desc'}
|
|
232
|
-
<PhCaretDown class="size-3.5" />
|
|
233
|
-
{/if}
|
|
234
|
-
</span>
|
|
235
|
-
</button>
|
|
236
|
-
{:else}
|
|
237
|
-
<FlexRender {header} />
|
|
238
|
-
{/if}
|
|
239
|
-
{/if}
|
|
240
|
-
{#if header.column.getCanResize()}
|
|
241
|
-
<div
|
|
242
|
-
aria-hidden="true"
|
|
243
|
-
class={cn(
|
|
244
|
-
'absolute top-0 -right-1 z-10 flex h-full w-2 cursor-col-resize touch-none items-center justify-center select-none before:h-4 before:w-px before:bg-border before:content-[""]'
|
|
245
|
-
)}
|
|
246
|
-
style={resizeHandleStyle(header)}
|
|
247
|
-
ondblclick={() => header.column.resetSize()}
|
|
248
|
-
onmousedown={header.getResizeHandler()}
|
|
249
|
-
ontouchstart={header.getResizeHandler()}
|
|
250
|
-
></div>
|
|
251
|
-
{/if}
|
|
252
|
-
</th>
|
|
253
|
-
{/each}
|
|
254
|
-
</tr>
|
|
255
|
-
{/each}
|
|
256
|
-
</thead>
|
|
257
|
-
<tbody>
|
|
258
|
-
{#each table.getRowModel().rows as row (row.id)}
|
|
259
|
-
<tr class="border-b border-surface-3 last:border-b-0">
|
|
260
|
-
{#if isRowSelectionEnabled}
|
|
261
|
-
<td class="px-3 py-2 text-center align-middle">
|
|
262
|
-
<Checkbox
|
|
263
|
-
size="sm"
|
|
264
|
-
aria-label="Select row"
|
|
265
|
-
class="mx-auto size-4"
|
|
266
|
-
checked={row.getIsSelected()}
|
|
267
|
-
disabled={!row.getCanSelect()}
|
|
268
|
-
onCheckedChange={({ checked }) => row.toggleSelected(checked === true)}
|
|
269
|
-
/>
|
|
270
|
-
</td>
|
|
271
|
-
{/if}
|
|
272
|
-
{#each row.getVisibleCells() as cell (cell.id)}
|
|
273
|
-
{@const cellMeta = getCellMeta(cell)}
|
|
274
|
-
{@const cellConfig = getDataTableCellConfig(cell)}
|
|
275
|
-
{@const cellAlign = getColumnAlign(cellMeta?.align, cellConfig)}
|
|
276
|
-
<td
|
|
277
|
-
class={cn(
|
|
278
|
-
'px-3 py-2',
|
|
279
|
-
alignClass(cellAlign),
|
|
280
|
-
isNumericCellConfig(cellConfig) && 'tabular-nums'
|
|
281
|
-
)}
|
|
282
|
-
>
|
|
283
|
-
{#if cellConfig && !hasCustomDataTableCell(cell)}
|
|
284
|
-
{@const value = cell.getValue()}
|
|
285
|
-
{#if cellConfig.type === 'number'}
|
|
286
|
-
{formatNumericValue(value, {
|
|
287
|
-
...cellConfig,
|
|
288
|
-
...fractionOptions(cellConfig)
|
|
289
|
-
})}
|
|
290
|
-
{:else if cellConfig.type === 'currency'}
|
|
291
|
-
{formatNumericValue(value, {
|
|
292
|
-
...cellConfig,
|
|
293
|
-
...fractionOptions(cellConfig),
|
|
294
|
-
style: 'currency'
|
|
295
|
-
})}
|
|
296
|
-
{:else if cellConfig.type === 'percentage'}
|
|
297
|
-
{formatNumericValue(value, {
|
|
298
|
-
...cellConfig,
|
|
299
|
-
...fractionOptions(cellConfig),
|
|
300
|
-
style: 'percent'
|
|
301
|
-
})}
|
|
302
|
-
{:else if cellConfig.type === 'boolean'}
|
|
303
|
-
{value === true
|
|
304
|
-
? (cellConfig.trueLabel ?? 'Yes')
|
|
305
|
-
: value === false
|
|
306
|
-
? (cellConfig.falseLabel ?? 'No')
|
|
307
|
-
: (cellConfig.nullLabel ?? '')}
|
|
308
|
-
{:else if cellConfig.type === 'link'}
|
|
309
|
-
{@const href = getLinkHref(cell, cellConfig.href)}
|
|
310
|
-
{#if href}
|
|
311
|
-
<a
|
|
312
|
-
class="inline-flex size-7 items-center justify-center rounded-md text-primary hover:bg-surface-2"
|
|
313
|
-
{href}
|
|
314
|
-
target={cellConfig.target ?? '_blank'}
|
|
315
|
-
rel="external noreferrer"
|
|
316
|
-
aria-label={getLinkLabel(value, cellConfig.fallback)}
|
|
317
|
-
title={getLinkLabel(value, cellConfig.fallback)}
|
|
318
|
-
>
|
|
319
|
-
<PhArrowSquareOut class="size-4" />
|
|
320
|
-
</a>
|
|
321
|
-
{:else}
|
|
322
|
-
{formatTextValue(value, cellConfig.fallback)}
|
|
323
|
-
{/if}
|
|
324
|
-
{:else}
|
|
325
|
-
{formatTextValue(value, cellConfig.fallback)}
|
|
326
|
-
{/if}
|
|
327
|
-
{:else}
|
|
328
|
-
<FlexRender {cell} />
|
|
329
|
-
{/if}
|
|
330
|
-
</td>
|
|
331
|
-
{/each}
|
|
332
|
-
</tr>
|
|
333
|
-
{:else}
|
|
334
|
-
<tr>
|
|
335
|
-
<td class="px-3 py-6 text-center text-ink-dim" colspan={tableColumnCount}>
|
|
336
|
-
No results.
|
|
337
|
-
</td>
|
|
338
|
-
</tr>
|
|
339
|
-
{/each}
|
|
340
|
-
</tbody>
|
|
341
|
-
</table>
|
|
342
|
-
</div>
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { type ClassValue } from 'tailwind-variants';
|
|
2
|
-
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
-
import type { RowData } from '@tanstack/svelte-table';
|
|
4
|
-
import { type DataTable } from './core';
|
|
5
|
-
declare function $$render<TData extends RowData, TSelected = object>(): {
|
|
6
|
-
props: Omit<HTMLAttributes<HTMLDivElement>, "class"> & {
|
|
7
|
-
table: DataTable<TData, TSelected>;
|
|
8
|
-
class?: ClassValue;
|
|
9
|
-
tableClass?: ClassValue;
|
|
10
|
-
};
|
|
11
|
-
exports: {};
|
|
12
|
-
bindings: "";
|
|
13
|
-
slots: {};
|
|
14
|
-
events: {};
|
|
15
|
-
};
|
|
16
|
-
declare class __sveltets_Render<TData extends RowData, TSelected = object> {
|
|
17
|
-
props(): ReturnType<typeof $$render<TData, TSelected>>['props'];
|
|
18
|
-
events(): ReturnType<typeof $$render<TData, TSelected>>['events'];
|
|
19
|
-
slots(): ReturnType<typeof $$render<TData, TSelected>>['slots'];
|
|
20
|
-
bindings(): "";
|
|
21
|
-
exports(): {};
|
|
22
|
-
}
|
|
23
|
-
interface $$IsomorphicComponent {
|
|
24
|
-
new <TData extends RowData, TSelected = object>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<TData, TSelected>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<TData, TSelected>['props']>, ReturnType<__sveltets_Render<TData, TSelected>['events']>, ReturnType<__sveltets_Render<TData, TSelected>['slots']>> & {
|
|
25
|
-
$$bindings?: ReturnType<__sveltets_Render<TData, TSelected>['bindings']>;
|
|
26
|
-
} & ReturnType<__sveltets_Render<TData, TSelected>['exports']>;
|
|
27
|
-
<TData extends RowData, TSelected = object>(internal: unknown, props: ReturnType<__sveltets_Render<TData, TSelected>['props']> & {}): ReturnType<__sveltets_Render<TData, TSelected>['exports']>;
|
|
28
|
-
z_$$bindings?: ReturnType<__sveltets_Render<any, any>['bindings']>;
|
|
29
|
-
}
|
|
30
|
-
declare const DataTable: $$IsomorphicComponent;
|
|
31
|
-
type DataTable<TData extends RowData, TSelected = object> = InstanceType<typeof DataTable<TData, TSelected>>;
|
|
32
|
-
export default DataTable;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export { default as Root } from './data-table.svelte';
|
|
2
|
-
export { default as Toolbar } from './data-table-toolbar.svelte';
|
|
3
|
-
export { default as Title } from './data-table-title.svelte';
|
|
4
|
-
export { default as ColumnVisibility } from './data-table-column-visibility.svelte';
|
|
5
|
-
export { default as Filters } from './data-table-filters.svelte';
|
|
6
|
-
export * from './core';
|
|
7
|
-
export * from '@tanstack/svelte-table';
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export { default as Root } from './data-table.svelte';
|
|
2
|
-
export { default as Toolbar } from './data-table-toolbar.svelte';
|
|
3
|
-
export { default as Title } from './data-table-title.svelte';
|
|
4
|
-
export { default as ColumnVisibility } from './data-table-column-visibility.svelte';
|
|
5
|
-
export { default as Filters } from './data-table-filters.svelte';
|
|
6
|
-
export * from './core';
|
|
7
|
-
export * from '@tanstack/svelte-table';
|