@urbicon-ui/table 6.1.4
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/README.md +153 -0
- package/dist/cells/ActionButtons.svelte +224 -0
- package/dist/cells/ActionButtons.svelte.d.ts +74 -0
- package/dist/cells/CopyButton.svelte +89 -0
- package/dist/cells/CopyButton.svelte.d.ts +33 -0
- package/dist/cells/CustomCell.svelte +136 -0
- package/dist/cells/CustomCell.svelte.d.ts +44 -0
- package/dist/cells/DateCell.svelte +194 -0
- package/dist/cells/DateCell.svelte.d.ts +39 -0
- package/dist/cells/LinkCell.svelte +240 -0
- package/dist/cells/LinkCell.svelte.d.ts +42 -0
- package/dist/cells/NumberCell.svelte +225 -0
- package/dist/cells/NumberCell.svelte.d.ts +47 -0
- package/dist/cells/StatusBadge.svelte +121 -0
- package/dist/cells/StatusBadge.svelte.d.ts +44 -0
- package/dist/cells/UserAvatar.svelte +71 -0
- package/dist/cells/UserAvatar.svelte.d.ts +37 -0
- package/dist/cells/index.d.ts +8 -0
- package/dist/cells/index.js +9 -0
- package/dist/core/EmptyState.svelte +161 -0
- package/dist/core/EmptyState.svelte.d.ts +16 -0
- package/dist/core/ErrorState.svelte +158 -0
- package/dist/core/ErrorState.svelte.d.ts +15 -0
- package/dist/core/GroupedRow.svelte +239 -0
- package/dist/core/GroupedRow.svelte.d.ts +18 -0
- package/dist/core/LoadingState.svelte +75 -0
- package/dist/core/LoadingState.svelte.d.ts +14 -0
- package/dist/core/MobileCard.svelte +151 -0
- package/dist/core/MobileCard.svelte.d.ts +15 -0
- package/dist/core/TableCell.svelte +105 -0
- package/dist/core/TableCell.svelte.d.ts +14 -0
- package/dist/core/TableDesktop.svelte +480 -0
- package/dist/core/TableDesktop.svelte.d.ts +26 -0
- package/dist/core/TableHead.svelte +314 -0
- package/dist/core/TableHead.svelte.d.ts +7 -0
- package/dist/core/TableMobile.svelte +112 -0
- package/dist/core/TableMobile.svelte.d.ts +13 -0
- package/dist/core/TableProvider.svelte +271 -0
- package/dist/core/TableProvider.svelte.d.ts +40 -0
- package/dist/core/TableRow.svelte +171 -0
- package/dist/core/TableRow.svelte.d.ts +16 -0
- package/dist/core/index.d.ts +17 -0
- package/dist/core/index.js +14 -0
- package/dist/core/sticky-context.svelte.d.ts +48 -0
- package/dist/core/sticky-context.svelte.js +88 -0
- package/dist/core/table/Table.svelte +304 -0
- package/dist/core/table/Table.svelte.d.ts +26 -0
- package/dist/core/table/index.d.ts +448 -0
- package/dist/core/table/index.js +1 -0
- package/dist/core/table-style-context.d.ts +66 -0
- package/dist/core/table-style-context.js +26 -0
- package/dist/factories/ColumnValidation.d.ts +49 -0
- package/dist/factories/ColumnValidation.js +188 -0
- package/dist/factories/TableColumns.d.ts +97 -0
- package/dist/factories/TableColumns.js +262 -0
- package/dist/factories/TypedColumnBuilder.d.ts +41 -0
- package/dist/factories/TypedColumnBuilder.js +72 -0
- package/dist/factories/index.d.ts +12 -0
- package/dist/factories/index.js +13 -0
- package/dist/features/HeaderMenu.svelte +236 -0
- package/dist/features/HeaderMenu.svelte.d.ts +8 -0
- package/dist/features/LiveUpdateBanner.svelte +66 -0
- package/dist/features/LiveUpdateBanner.svelte.d.ts +6 -0
- package/dist/features/SearchHighlight.svelte +21 -0
- package/dist/features/SearchHighlight.svelte.d.ts +8 -0
- package/dist/features/SmartFilterBar/ChipsField.svelte +104 -0
- package/dist/features/SmartFilterBar/ChipsField.svelte.d.ts +5 -0
- package/dist/features/SmartFilterBar/ColumnVisibilityMenu.svelte +84 -0
- package/dist/features/SmartFilterBar/ColumnVisibilityMenu.svelte.d.ts +3 -0
- package/dist/features/SmartFilterBar/FilterMenu.svelte +367 -0
- package/dist/features/SmartFilterBar/FilterMenu.svelte.d.ts +3 -0
- package/dist/features/SmartFilterBar/GroupingMenu.svelte +82 -0
- package/dist/features/SmartFilterBar/GroupingMenu.svelte.d.ts +3 -0
- package/dist/features/SmartFilterBar/SmartFilterBar.svelte +109 -0
- package/dist/features/SmartFilterBar/SmartFilterBar.svelte.d.ts +11 -0
- package/dist/features/SmartFilterBar/SummaryMenu.svelte +118 -0
- package/dist/features/SmartFilterBar/SummaryMenu.svelte.d.ts +3 -0
- package/dist/features/SummaryRow.svelte +97 -0
- package/dist/features/SummaryRow.svelte.d.ts +8 -0
- package/dist/features/index.d.ts +4 -0
- package/dist/features/index.js +4 -0
- package/dist/i18n/index.d.ts +366 -0
- package/dist/i18n/index.js +21 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +41 -0
- package/dist/stores/TableStore.svelte.d.ts +192 -0
- package/dist/stores/TableStore.svelte.js +362 -0
- package/dist/stores/concerns/index.d.ts +15 -0
- package/dist/stores/concerns/index.js +14 -0
- package/dist/stores/concerns/types.d.ts +31 -0
- package/dist/stores/concerns/types.js +1 -0
- package/dist/stores/concerns/useColumnOrder.svelte.d.ts +16 -0
- package/dist/stores/concerns/useColumnOrder.svelte.js +81 -0
- package/dist/stores/concerns/useColumnVisibility.svelte.d.ts +16 -0
- package/dist/stores/concerns/useColumnVisibility.svelte.js +58 -0
- package/dist/stores/concerns/useExpansion.svelte.d.ts +9 -0
- package/dist/stores/concerns/useExpansion.svelte.js +32 -0
- package/dist/stores/concerns/useFiltering.svelte.d.ts +20 -0
- package/dist/stores/concerns/useFiltering.svelte.js +109 -0
- package/dist/stores/concerns/useFocusManagement.svelte.d.ts +15 -0
- package/dist/stores/concerns/useFocusManagement.svelte.js +52 -0
- package/dist/stores/concerns/useGrouping.svelte.d.ts +15 -0
- package/dist/stores/concerns/useGrouping.svelte.js +86 -0
- package/dist/stores/concerns/useLiveUpdates.svelte.d.ts +45 -0
- package/dist/stores/concerns/useLiveUpdates.svelte.js +175 -0
- package/dist/stores/concerns/usePagination.svelte.d.ts +18 -0
- package/dist/stores/concerns/usePagination.svelte.js +54 -0
- package/dist/stores/concerns/usePersistence.svelte.d.ts +36 -0
- package/dist/stores/concerns/usePersistence.svelte.js +167 -0
- package/dist/stores/concerns/useRemoteData.svelte.d.ts +21 -0
- package/dist/stores/concerns/useRemoteData.svelte.js +64 -0
- package/dist/stores/concerns/useSearch.svelte.d.ts +8 -0
- package/dist/stores/concerns/useSearch.svelte.js +16 -0
- package/dist/stores/concerns/useSelection.svelte.d.ts +21 -0
- package/dist/stores/concerns/useSelection.svelte.js +110 -0
- package/dist/stores/concerns/useSorting.svelte.d.ts +11 -0
- package/dist/stores/concerns/useSorting.svelte.js +70 -0
- package/dist/stores/concerns/useSummary.svelte.d.ts +18 -0
- package/dist/stores/concerns/useSummary.svelte.js +96 -0
- package/dist/stores/index.d.ts +1 -0
- package/dist/stores/index.js +1 -0
- package/dist/style/index.css +137 -0
- package/dist/style/index.d.ts +2 -0
- package/dist/style/index.js +2 -0
- package/dist/style/table-theme.css +131 -0
- package/dist/style/themes/comfortable.css +20 -0
- package/dist/style/themes/compact.css +20 -0
- package/dist/translations/de.d.ts +177 -0
- package/dist/translations/de.js +176 -0
- package/dist/translations/en.d.ts +177 -0
- package/dist/translations/en.js +176 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/tableTypes.d.ts +262 -0
- package/dist/types/tableTypes.js +1 -0
- package/dist/utils/index.d.ts +165 -0
- package/dist/utils/index.js +330 -0
- package/dist/utils/sticky-measure.d.ts +54 -0
- package/dist/utils/sticky-measure.js +107 -0
- package/dist/utils/virtualizer.d.ts +43 -0
- package/dist/utils/virtualizer.js +43 -0
- package/dist/variants/index.d.ts +11 -0
- package/dist/variants/index.js +15 -0
- package/dist/variants/table-cells.variants.d.ts +827 -0
- package/dist/variants/table-cells.variants.js +627 -0
- package/dist/variants/table-features.variants.d.ts +547 -0
- package/dist/variants/table-features.variants.js +412 -0
- package/dist/variants/table-states.variants.d.ts +594 -0
- package/dist/variants/table-states.variants.js +394 -0
- package/dist/variants/table.system.d.ts +301 -0
- package/dist/variants/table.system.js +314 -0
- package/dist/variants/table.variants.d.ts +428 -0
- package/dist/variants/table.variants.js +360 -0
- package/package.json +93 -0
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { Column, SummaryConfig, TableItem, TablePersistenceConfig, TableQuery, TableQueryResult } from '../..';
|
|
3
|
+
import type { TableSlotClasses } from '../table-style-context';
|
|
4
|
+
/**
|
|
5
|
+
* Props interface for Table component
|
|
6
|
+
*
|
|
7
|
+
* @description Advanced data table component with smart filtering, column factories, responsive design,
|
|
8
|
+
* and extensible features for complex data visualization. Supports row selection, keyboard navigation,
|
|
9
|
+
* virtual scrolling, column reorder, server-side data, live updates, and custom cell components.
|
|
10
|
+
*
|
|
11
|
+
* @tag data
|
|
12
|
+
* @related Pagination
|
|
13
|
+
*
|
|
14
|
+
* @example Basic usage
|
|
15
|
+
* ```svelte
|
|
16
|
+
* <Table
|
|
17
|
+
* items={data}
|
|
18
|
+
* columns={columns}
|
|
19
|
+
* itemsPerPage={25}
|
|
20
|
+
* enableSmartFilter={true}
|
|
21
|
+
* />
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @example Per-column custom cell rendering (recommended)
|
|
25
|
+
* ```svelte
|
|
26
|
+
* {#snippet statusCell(item, value)}
|
|
27
|
+
* <Badge intent={value === 'active' ? 'success' : 'danger'}>{value}</Badge>
|
|
28
|
+
* {/snippet}
|
|
29
|
+
*
|
|
30
|
+
* <Table items={data} columns={[
|
|
31
|
+
* { accessor: 'name', title: 'Name', sortable: true },
|
|
32
|
+
* { accessor: 'status', title: 'Status', cell: statusCell }
|
|
33
|
+
* ]} />
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @example Row selection with callback
|
|
37
|
+
* ```svelte
|
|
38
|
+
* <Table
|
|
39
|
+
* items={data}
|
|
40
|
+
* columns={columns}
|
|
41
|
+
* selectionMode="multi"
|
|
42
|
+
* onSelectionChange={(selected) => console.log(selected)}
|
|
43
|
+
* />
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @example Server-side data with queryFn
|
|
47
|
+
* ```svelte
|
|
48
|
+
* <Table
|
|
49
|
+
* mode="server"
|
|
50
|
+
* columns={columns}
|
|
51
|
+
* queryFn={async (query, { signal }) => {
|
|
52
|
+
* const res = await fetch(`/api/users?page=${query.page}`, { signal });
|
|
53
|
+
* return await res.json();
|
|
54
|
+
* }}
|
|
55
|
+
* />
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @example Virtual scrolling for large datasets
|
|
59
|
+
* ```svelte
|
|
60
|
+
* <Table items={tenThousandRows} columns={columns} virtualized virtualHeight="500px" />
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* @example Persist view state across reloads (filters, search, group,
|
|
64
|
+
* summaries, sort, hidden columns, column order — all in `localStorage`
|
|
65
|
+
* by default):
|
|
66
|
+
* ```svelte
|
|
67
|
+
* <Table {items} {columns} persistenceConfig={{ tableId: 'expenses' }} />
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export interface TableProps<T = TableItem> {
|
|
71
|
+
/**
|
|
72
|
+
* Array of data items to display in the table.
|
|
73
|
+
* Items with an `id` property get better key stability for animations.
|
|
74
|
+
* If no `id` is present, the array index is used as fallback key.
|
|
75
|
+
* @default []
|
|
76
|
+
*/
|
|
77
|
+
items?: T[];
|
|
78
|
+
/**
|
|
79
|
+
* Column configuration array defining the table structure
|
|
80
|
+
* @default []
|
|
81
|
+
*/
|
|
82
|
+
columns?: Column<T>[];
|
|
83
|
+
/**
|
|
84
|
+
* Additional CSS class names for the table container
|
|
85
|
+
* @default undefined
|
|
86
|
+
*/
|
|
87
|
+
class?: string;
|
|
88
|
+
/**
|
|
89
|
+
* Accessible label for the table, announced by screen readers.
|
|
90
|
+
* @default undefined
|
|
91
|
+
*/
|
|
92
|
+
ariaLabel?: string;
|
|
93
|
+
/**
|
|
94
|
+
* Size variant for the table
|
|
95
|
+
* @default "md"
|
|
96
|
+
*/
|
|
97
|
+
size?: 'sm' | 'md' | 'lg';
|
|
98
|
+
/**
|
|
99
|
+
* Visual appearance of the table chrome (see docs/MIGRATION-v5.md §3):
|
|
100
|
+
* - `flush` (default): no outer frame, sits inline in the reading flow
|
|
101
|
+
* - `surface`: gentle `surface-quiet` tinted zone, no border
|
|
102
|
+
* - `framed`: bordered + rounded + shadowed standalone block
|
|
103
|
+
* @default "flush"
|
|
104
|
+
*/
|
|
105
|
+
appearance?: 'flush' | 'surface' | 'framed';
|
|
106
|
+
/**
|
|
107
|
+
* Number of items to display per page
|
|
108
|
+
* @default 10
|
|
109
|
+
*/
|
|
110
|
+
itemsPerPage?: number;
|
|
111
|
+
/**
|
|
112
|
+
* Initial page number
|
|
113
|
+
* @default 1
|
|
114
|
+
*/
|
|
115
|
+
initialPage?: number;
|
|
116
|
+
/**
|
|
117
|
+
* Snippet to render expanded row content
|
|
118
|
+
* @default undefined
|
|
119
|
+
*/
|
|
120
|
+
expandedRowContent?: Snippet<[item: T]>;
|
|
121
|
+
/**
|
|
122
|
+
* Allow multiple rows to be expanded simultaneously.
|
|
123
|
+
* When false (default), expanding a row collapses the previously expanded one.
|
|
124
|
+
* @default false
|
|
125
|
+
*/
|
|
126
|
+
multiExpand?: boolean;
|
|
127
|
+
/**
|
|
128
|
+
* Callback fired when a row is clicked.
|
|
129
|
+
* Receives the clicked row's data item.
|
|
130
|
+
* @default undefined
|
|
131
|
+
*/
|
|
132
|
+
onRowClick?: (item: T) => void;
|
|
133
|
+
/**
|
|
134
|
+
* Enable virtualization for large datasets.
|
|
135
|
+
* When enabled, only visible rows are rendered for performance with >1000 items.
|
|
136
|
+
* Pagination is bypassed — all filtered/sorted items are virtualized in a scrollable container.
|
|
137
|
+
* Not compatible with grouping (grouping takes precedence).
|
|
138
|
+
* @default false
|
|
139
|
+
*/
|
|
140
|
+
virtualized?: boolean;
|
|
141
|
+
/**
|
|
142
|
+
* Height of the virtual scroll container. Only used when `virtualized` is true.
|
|
143
|
+
* Accepts any CSS height value.
|
|
144
|
+
* @default "600px"
|
|
145
|
+
*/
|
|
146
|
+
virtualHeight?: string;
|
|
147
|
+
/**
|
|
148
|
+
* Custom order for group display
|
|
149
|
+
* @default []
|
|
150
|
+
*/
|
|
151
|
+
groupOrder?: string[];
|
|
152
|
+
/**
|
|
153
|
+
* Initial grouping key (if no persisted value exists).
|
|
154
|
+
* When grouping is active, pagination is disabled — all grouped items are shown at once.
|
|
155
|
+
* @default null
|
|
156
|
+
*/
|
|
157
|
+
initialGroupBy?: string | null;
|
|
158
|
+
/**
|
|
159
|
+
* Initial summary configurations (if no persisted value exists).
|
|
160
|
+
* Each entry defines a column + aggregation type (sum, avg, count, min, max).
|
|
161
|
+
* @default []
|
|
162
|
+
*/
|
|
163
|
+
initialSummaryConfigs?: SummaryConfig[];
|
|
164
|
+
/**
|
|
165
|
+
* Enable smart filtering functionality
|
|
166
|
+
* @default true
|
|
167
|
+
*/
|
|
168
|
+
enableSmartFilter?: boolean;
|
|
169
|
+
/**
|
|
170
|
+
* Placeholder text for search input
|
|
171
|
+
* @default "Search..."
|
|
172
|
+
*/
|
|
173
|
+
searchPlaceholder?: string;
|
|
174
|
+
/**
|
|
175
|
+
* Debounce delay for search in milliseconds
|
|
176
|
+
* @default 300
|
|
177
|
+
*/
|
|
178
|
+
searchDebounceMs?: number;
|
|
179
|
+
/**
|
|
180
|
+
* Text displayed during loading state
|
|
181
|
+
* @default "Loading data..."
|
|
182
|
+
*/
|
|
183
|
+
loadingText?: string;
|
|
184
|
+
/**
|
|
185
|
+
* Text displayed on error
|
|
186
|
+
* @default "Error loading data"
|
|
187
|
+
*/
|
|
188
|
+
errorText?: string;
|
|
189
|
+
/**
|
|
190
|
+
* Text displayed when no data is available
|
|
191
|
+
* @default "No data found."
|
|
192
|
+
*/
|
|
193
|
+
noDataText?: string;
|
|
194
|
+
/**
|
|
195
|
+
* Global cell snippet that overrides rendering for ALL columns.
|
|
196
|
+
* For per-column customization, prefer `column.cell` instead.
|
|
197
|
+
* @default undefined
|
|
198
|
+
*/
|
|
199
|
+
cell?: Snippet<[item: T, value: unknown, column: Column<T>]>;
|
|
200
|
+
/**
|
|
201
|
+
* Custom header snippet
|
|
202
|
+
* @default undefined
|
|
203
|
+
*/
|
|
204
|
+
header?: Snippet;
|
|
205
|
+
/**
|
|
206
|
+
* Custom body snippet
|
|
207
|
+
* @default undefined
|
|
208
|
+
*/
|
|
209
|
+
body?: Snippet;
|
|
210
|
+
/**
|
|
211
|
+
* Custom pagination snippet
|
|
212
|
+
* @default undefined
|
|
213
|
+
*/
|
|
214
|
+
pagination?: Snippet;
|
|
215
|
+
/**
|
|
216
|
+
* Custom empty state snippet
|
|
217
|
+
* @default undefined
|
|
218
|
+
*/
|
|
219
|
+
empty?: Snippet;
|
|
220
|
+
/**
|
|
221
|
+
* Custom loading state snippet
|
|
222
|
+
* @default undefined
|
|
223
|
+
*/
|
|
224
|
+
loading?: Snippet;
|
|
225
|
+
/**
|
|
226
|
+
* Custom error state snippet
|
|
227
|
+
* @default undefined
|
|
228
|
+
*/
|
|
229
|
+
error?: Snippet;
|
|
230
|
+
/**
|
|
231
|
+
* Custom content for group headers
|
|
232
|
+
* @default null
|
|
233
|
+
*/
|
|
234
|
+
groupHeaderContent?: Snippet<[groupName: string, items: T[], isExpanded: boolean]>;
|
|
235
|
+
/**
|
|
236
|
+
* Data processing mode.
|
|
237
|
+
* - `'client'` (default): Filtering, sorting, and pagination are done locally.
|
|
238
|
+
* - `'server'`: The table delegates all data operations to the server. Items passed via
|
|
239
|
+
* `items` prop (or returned by `queryFn`) are displayed as-is.
|
|
240
|
+
* @default "client"
|
|
241
|
+
*/
|
|
242
|
+
mode?: 'client' | 'server';
|
|
243
|
+
/**
|
|
244
|
+
* Total number of items on the server. Required when `mode` is `'server'`
|
|
245
|
+
* and manual control is used (without `queryFn`). Drives pagination calculation.
|
|
246
|
+
* @default 0
|
|
247
|
+
*/
|
|
248
|
+
serverTotalItems?: number;
|
|
249
|
+
/**
|
|
250
|
+
* Async function for managed server-side fetching. When provided in `mode: 'server'`,
|
|
251
|
+
* the table calls this function automatically when the query changes (debounced).
|
|
252
|
+
* The table manages loading/error states and request cancellation via `AbortSignal`.
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* ```ts
|
|
256
|
+
* queryFn={async (query, { signal }) => {
|
|
257
|
+
* const params = new URLSearchParams({ page: String(query.page), ... });
|
|
258
|
+
* const res = await fetch(`/api/users?${params}`, { signal });
|
|
259
|
+
* const data = await res.json();
|
|
260
|
+
* return { items: data.results, totalItems: data.total };
|
|
261
|
+
* }}
|
|
262
|
+
* ```
|
|
263
|
+
*/
|
|
264
|
+
queryFn?: (query: TableQuery, options: {
|
|
265
|
+
signal: AbortSignal;
|
|
266
|
+
}) => Promise<TableQueryResult>;
|
|
267
|
+
/**
|
|
268
|
+
* Callback fired when the table query changes in `mode: 'server'`.
|
|
269
|
+
* Use this for manual control — fetch data yourself and update `items`,
|
|
270
|
+
* `serverTotalItems`, `loading`, and `error` props accordingly.
|
|
271
|
+
* Fires after debounce (controlled by `queryDebounceMs`).
|
|
272
|
+
* @default undefined
|
|
273
|
+
*/
|
|
274
|
+
onQueryChange?: (query: TableQuery) => void;
|
|
275
|
+
/**
|
|
276
|
+
* Debounce delay in milliseconds for server query changes.
|
|
277
|
+
* Prevents excessive requests during rapid filter/search input.
|
|
278
|
+
* @default 300
|
|
279
|
+
*/
|
|
280
|
+
queryDebounceMs?: number;
|
|
281
|
+
/**
|
|
282
|
+
* Enable live update support. When enabled, a `LiveUpdateBanner` is shown
|
|
283
|
+
* when pending inserts/updates/deletes are buffered. Use `getTableContext()`
|
|
284
|
+
* to access `pushInsert`, `pushUpdate`, `pushDelete` from WebSocket/SSE handlers.
|
|
285
|
+
* @default false
|
|
286
|
+
*/
|
|
287
|
+
enableLiveUpdates?: boolean;
|
|
288
|
+
/**
|
|
289
|
+
* Automatically apply pending live updates when the user navigates
|
|
290
|
+
* (page change, sort, filter, search). Since the view is already changing,
|
|
291
|
+
* applying buffered changes at this point is non-disruptive.
|
|
292
|
+
* @default true
|
|
293
|
+
*/
|
|
294
|
+
autoApplyOnNavigation?: boolean;
|
|
295
|
+
/**
|
|
296
|
+
* Persist table view state across reloads. Pass `{ tableId: 'foo' }` to
|
|
297
|
+
* opt in — every axis (filters, search, group, summary, sort, column
|
|
298
|
+
* visibility, column order) is persisted by default into `localStorage`
|
|
299
|
+
* under keys scoped to `tableId`. Set individual `persist*` flags to
|
|
300
|
+
* `false` to keep an axis volatile.
|
|
301
|
+
*
|
|
302
|
+
* Pagination (current page) is intentionally never persisted — page 1
|
|
303
|
+
* on navigation is standard UX.
|
|
304
|
+
*
|
|
305
|
+
* @example
|
|
306
|
+
* ```svelte
|
|
307
|
+
* <Table {items} {columns} persistenceConfig={{ tableId: 'expenses' }} />
|
|
308
|
+
* ```
|
|
309
|
+
*
|
|
310
|
+
* @example Keep sort and column order, but always start filter-free:
|
|
311
|
+
* ```svelte
|
|
312
|
+
* <Table
|
|
313
|
+
* {items}
|
|
314
|
+
* {columns}
|
|
315
|
+
* persistenceConfig={{
|
|
316
|
+
* tableId: 'expenses',
|
|
317
|
+
* persistFilters: false,
|
|
318
|
+
* persistSearch: false
|
|
319
|
+
* }}
|
|
320
|
+
* />
|
|
321
|
+
* ```
|
|
322
|
+
*
|
|
323
|
+
* @default undefined
|
|
324
|
+
*/
|
|
325
|
+
persistenceConfig?: TablePersistenceConfig;
|
|
326
|
+
/**
|
|
327
|
+
* Remove default tailwind-variants classes. Only user-provided `slotClasses` apply.
|
|
328
|
+
* @default false
|
|
329
|
+
*/
|
|
330
|
+
unstyled?: boolean;
|
|
331
|
+
/**
|
|
332
|
+
* Per-slot class overrides merged with (or replacing, if `unstyled`) variant styles.
|
|
333
|
+
* Available slots: `container`, `toolbar`, `scrollArea`, `table`, `thead`, `tbody`,
|
|
334
|
+
* `headerRow`, `headerCell`, `row`, `cell`, `groupHeader`, `summaryRow`,
|
|
335
|
+
* `emptyState`, `loadingState`, `errorState`, `filterBar`, `mobileCard`.
|
|
336
|
+
*
|
|
337
|
+
* **Breaking change in v1.5:** the former `wrapper` slot has been replaced by
|
|
338
|
+
* `scrollArea`. The former hardcoded `overflow-hidden` on `wrapper` blocked
|
|
339
|
+
* `position: sticky`, see [docs/STICKY-PINNING.md](../../../../../docs/STICKY-PINNING.md).
|
|
340
|
+
*
|
|
341
|
+
* @default {}
|
|
342
|
+
*/
|
|
343
|
+
slotClasses?: Partial<TableSlotClasses>;
|
|
344
|
+
/**
|
|
345
|
+
* Pin toolbar/header/group-header to the top of the scroll ancestor on scroll.
|
|
346
|
+
* - `false` (default): no pinning, layout matches v1.4.x
|
|
347
|
+
* - `true` / `'both'`: toolbar + thead + group-header all pin
|
|
348
|
+
* - `'toolbar'`: only the toolbar pins
|
|
349
|
+
* - `'header'`: only the thead (and group-header when grouping is active) pins
|
|
350
|
+
*
|
|
351
|
+
* Pair with `stickyOffset` for app shells that have a fixed top bar.
|
|
352
|
+
*
|
|
353
|
+
* For tables wider than the viewport, prefer `fit="viewport"` — it contains
|
|
354
|
+
* horizontal scroll inside the table instead of falling back to page-level
|
|
355
|
+
* horizontal scroll (a sticky pin host cannot also be a horizontal scroll
|
|
356
|
+
* ancestor). `fit="viewport"` supersedes `sticky` when set.
|
|
357
|
+
*
|
|
358
|
+
* @default false
|
|
359
|
+
* @example
|
|
360
|
+
* ```svelte
|
|
361
|
+
* <Table {items} {columns} sticky stickyOffset={64} />
|
|
362
|
+
* ```
|
|
363
|
+
*/
|
|
364
|
+
sticky?: boolean | 'toolbar' | 'header' | 'both';
|
|
365
|
+
/**
|
|
366
|
+
* Make the table its own scroll container so wide **and** long lists scroll
|
|
367
|
+
* *within* the table instead of pushing overflow onto the page.
|
|
368
|
+
*
|
|
369
|
+
* - `'content'` (default): the table grows with its content; vertical overflow
|
|
370
|
+
* scrolls the page. Pair with `sticky` for page-relative pinning.
|
|
371
|
+
* - `'viewport'`: the table is height-capped to the viewport and becomes a
|
|
372
|
+
* self-contained scroll box. The column header (and group header when
|
|
373
|
+
* grouping) pin to the top of the box, while the toolbar and pagination stay
|
|
374
|
+
* fixed outside the scrolling area — only the rows scroll, in both axes. The
|
|
375
|
+
* available height is measured automatically (the container's distance from
|
|
376
|
+
* the top of the viewport), so no magic `max-height` is needed in the
|
|
377
|
+
* consumer, and it adapts to whatever sits above the table (tabs, banners).
|
|
378
|
+
*
|
|
379
|
+
* Notes for `'viewport'`:
|
|
380
|
+
* - Desktop only (`md`+); mobile keeps normal document-level scroll.
|
|
381
|
+
* - Supersedes `sticky`: header/group pinning is intrinsic to the box, so the
|
|
382
|
+
* `sticky` prop is ignored. `stickyOffset` is ignored too — the measured top
|
|
383
|
+
* absorbs app-shell offsets automatically.
|
|
384
|
+
* - Mutually exclusive with `virtualized`, which manages its own bounded
|
|
385
|
+
* scroll via `virtualHeight`; `fit` has no effect when `virtualized`.
|
|
386
|
+
*
|
|
387
|
+
* @default "content"
|
|
388
|
+
* @example
|
|
389
|
+
* ```svelte
|
|
390
|
+
* <!-- Full-height list page: header pinned, toolbar + pagination fixed -->
|
|
391
|
+
* <Table {items} {columns} fit="viewport" />
|
|
392
|
+
* ```
|
|
393
|
+
*/
|
|
394
|
+
fit?: 'content' | 'viewport';
|
|
395
|
+
/**
|
|
396
|
+
* Pixel offset for the topmost sticky layer (toolbar, or thead when no toolbar).
|
|
397
|
+
* Writes the CSS custom property `--blocks-table-sticky-top` on the container.
|
|
398
|
+
* Use this to push the pin below a fixed app shell top bar.
|
|
399
|
+
*
|
|
400
|
+
* @default 0
|
|
401
|
+
*/
|
|
402
|
+
stickyOffset?: number;
|
|
403
|
+
/**
|
|
404
|
+
* Custom toolbar snippet. Replaces the default `SmartFilterBar`.
|
|
405
|
+
* Renders inside the sticky toolbar wrapper when `sticky` is enabled — so a
|
|
406
|
+
* custom toolbar inherits the pinning behavior without extra wiring.
|
|
407
|
+
*
|
|
408
|
+
* Access the table context via `getTableContext()` to wire up custom filter UIs.
|
|
409
|
+
*
|
|
410
|
+
* @default undefined (renders default SmartFilterBar when enableSmartFilter)
|
|
411
|
+
* @example
|
|
412
|
+
* ```svelte
|
|
413
|
+
* <Table {items} {columns} sticky enableSmartFilter={false}>
|
|
414
|
+
* {#snippet toolbar()}
|
|
415
|
+
* <MyCustomToolbar />
|
|
416
|
+
* {/snippet}
|
|
417
|
+
* </Table>
|
|
418
|
+
* ```
|
|
419
|
+
*/
|
|
420
|
+
toolbar?: Snippet;
|
|
421
|
+
/**
|
|
422
|
+
* Enable drag-and-drop column reordering on desktop.
|
|
423
|
+
* Users can drag column headers to rearrange them. Also supports keyboard
|
|
424
|
+
* reorder via Shift+ArrowLeft/Right on focused headers.
|
|
425
|
+
* @default false
|
|
426
|
+
*/
|
|
427
|
+
enableColumnReorder?: boolean;
|
|
428
|
+
/**
|
|
429
|
+
* Row selection mode.
|
|
430
|
+
* - `'none'`: No selection (default)
|
|
431
|
+
* - `'single'`: Only one row can be selected at a time
|
|
432
|
+
* - `'multi'`: Multiple rows can be selected with checkboxes
|
|
433
|
+
* @default "none"
|
|
434
|
+
*/
|
|
435
|
+
selectionMode?: 'none' | 'single' | 'multi';
|
|
436
|
+
/**
|
|
437
|
+
* Controlled selected row IDs. When provided, the component reflects this value
|
|
438
|
+
* instead of managing selection internally.
|
|
439
|
+
* @default undefined
|
|
440
|
+
*/
|
|
441
|
+
selectedIds?: Array<string | number>;
|
|
442
|
+
/**
|
|
443
|
+
* Callback fired when the selection changes.
|
|
444
|
+
* Receives the array of currently selected items.
|
|
445
|
+
* @default undefined
|
|
446
|
+
*/
|
|
447
|
+
onSelectionChange?: (selectedItems: T[]) => void;
|
|
448
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-slot class overrides for the Table component.
|
|
3
|
+
* Each key corresponds to a rendering slot in the component tree.
|
|
4
|
+
*/
|
|
5
|
+
export interface TableSlotClasses {
|
|
6
|
+
/** Outer container (flex-column, holds toolbar + scrollArea) */
|
|
7
|
+
container?: string;
|
|
8
|
+
/** Toolbar wrapper around `SmartFilterBar` or custom `toolbar` snippet (Sticky-Layer L1) */
|
|
9
|
+
toolbar?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Visible table frame (border, radius, shadow). Holds `<table>`.
|
|
12
|
+
* Replaces the former `wrapper` slot from v1.4.x — see docs/STICKY-PINNING.md.
|
|
13
|
+
*/
|
|
14
|
+
scrollArea?: string;
|
|
15
|
+
/** `<table>` element */
|
|
16
|
+
table?: string;
|
|
17
|
+
/** `<thead>` */
|
|
18
|
+
thead?: string;
|
|
19
|
+
/** `<tbody>` */
|
|
20
|
+
tbody?: string;
|
|
21
|
+
/** `<tr>` in thead */
|
|
22
|
+
headerRow?: string;
|
|
23
|
+
/** `<th>` */
|
|
24
|
+
headerCell?: string;
|
|
25
|
+
/** `<tr>` in tbody */
|
|
26
|
+
row?: string;
|
|
27
|
+
/** `<td>` */
|
|
28
|
+
cell?: string;
|
|
29
|
+
/** Group header row */
|
|
30
|
+
groupHeader?: string;
|
|
31
|
+
/** Summary row */
|
|
32
|
+
summaryRow?: string;
|
|
33
|
+
/** Empty state container */
|
|
34
|
+
emptyState?: string;
|
|
35
|
+
/** Loading state container */
|
|
36
|
+
loadingState?: string;
|
|
37
|
+
/** Error state container */
|
|
38
|
+
errorState?: string;
|
|
39
|
+
/** Default SmartFilterBar inner container */
|
|
40
|
+
filterBar?: string;
|
|
41
|
+
/** Mobile card wrapper */
|
|
42
|
+
mobileCard?: string;
|
|
43
|
+
}
|
|
44
|
+
export type TableAppearance = 'flush' | 'surface' | 'framed';
|
|
45
|
+
export interface TableStyleConfig {
|
|
46
|
+
unstyled: boolean;
|
|
47
|
+
slotClasses: Partial<TableSlotClasses>;
|
|
48
|
+
appearance: TableAppearance;
|
|
49
|
+
}
|
|
50
|
+
declare const setTableStyleContext: any;
|
|
51
|
+
/**
|
|
52
|
+
* Sets the table style context. Called by `Table.svelte`.
|
|
53
|
+
*/
|
|
54
|
+
export { setTableStyleContext };
|
|
55
|
+
/**
|
|
56
|
+
* Retrieves the table style context. Used by subcomponents to apply `unstyled` + `slotClasses`.
|
|
57
|
+
*/
|
|
58
|
+
export declare function getTableStyleConfig(): TableStyleConfig;
|
|
59
|
+
/**
|
|
60
|
+
* Resolves classes for a slot, respecting `unstyled` mode.
|
|
61
|
+
* @param variantClasses - Classes from `tv()` variant (e.g. `styles.row()`)
|
|
62
|
+
* @param slotClass - User-provided class for this slot from `slotClasses`
|
|
63
|
+
* @param unstyled - Whether to strip variant classes
|
|
64
|
+
* @param extra - Additional classes (e.g. from `className` prop)
|
|
65
|
+
*/
|
|
66
|
+
export declare function resolveSlotClass(variantClasses: string, slotClass: string | undefined, unstyled: boolean, extra?: string): string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { createOptionalContext } from '@urbicon-ui/blocks';
|
|
2
|
+
// Optional — sub-components have a sane default when used outside Table.svelte.
|
|
3
|
+
const [getTableStyleContextRaw, setTableStyleContext] = createOptionalContext();
|
|
4
|
+
/**
|
|
5
|
+
* Sets the table style context. Called by `Table.svelte`.
|
|
6
|
+
*/
|
|
7
|
+
export { setTableStyleContext };
|
|
8
|
+
/**
|
|
9
|
+
* Retrieves the table style context. Used by subcomponents to apply `unstyled` + `slotClasses`.
|
|
10
|
+
*/
|
|
11
|
+
export function getTableStyleConfig() {
|
|
12
|
+
return getTableStyleContextRaw() ?? { unstyled: false, slotClasses: {}, appearance: 'flush' };
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Resolves classes for a slot, respecting `unstyled` mode.
|
|
16
|
+
* @param variantClasses - Classes from `tv()` variant (e.g. `styles.row()`)
|
|
17
|
+
* @param slotClass - User-provided class for this slot from `slotClasses`
|
|
18
|
+
* @param unstyled - Whether to strip variant classes
|
|
19
|
+
* @param extra - Additional classes (e.g. from `className` prop)
|
|
20
|
+
*/
|
|
21
|
+
export function resolveSlotClass(variantClasses, slotClass, unstyled, extra) {
|
|
22
|
+
if (unstyled) {
|
|
23
|
+
return [slotClass, extra].filter(Boolean).join(' ');
|
|
24
|
+
}
|
|
25
|
+
return [variantClasses, slotClass, extra].filter(Boolean).join(' ');
|
|
26
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Column } from '../types/tableTypes';
|
|
2
|
+
/**
|
|
3
|
+
* Validation utilities for column configurations.
|
|
4
|
+
*
|
|
5
|
+
* In the 2.x column shape, identification is the column's `id` (with a
|
|
6
|
+
* string-accessor fallback). Validation enforces that every column resolves
|
|
7
|
+
* to a non-empty id, that ids are unique within a set, and that no column
|
|
8
|
+
* fails the basic structural checks.
|
|
9
|
+
*/
|
|
10
|
+
export declare class ColumnValidation {
|
|
11
|
+
/**
|
|
12
|
+
* Validates a single column configuration
|
|
13
|
+
*/
|
|
14
|
+
static validateColumn(column: Column): {
|
|
15
|
+
isValid: boolean;
|
|
16
|
+
errors: string[];
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Validates an array of columns
|
|
20
|
+
*/
|
|
21
|
+
static validateColumns(columns: Column[]): {
|
|
22
|
+
isValid: boolean;
|
|
23
|
+
errors: string[];
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Validates column configuration for specific use cases
|
|
27
|
+
*/
|
|
28
|
+
static validateForUseCase(columns: Column[], useCase: 'mobile' | 'desktop' | 'print'): {
|
|
29
|
+
isValid: boolean;
|
|
30
|
+
warnings: string[];
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Helper functions for common validation patterns
|
|
35
|
+
*/
|
|
36
|
+
export declare const ValidationHelpers: {
|
|
37
|
+
/**
|
|
38
|
+
* Checks if columns are suitable for mobile display
|
|
39
|
+
*/
|
|
40
|
+
isMobileFriendly: (columns: Column[]) => boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Gets recommended mobile columns (priority 1 and 2)
|
|
43
|
+
*/
|
|
44
|
+
getMobileColumns: (columns: Column[]) => Column[];
|
|
45
|
+
/**
|
|
46
|
+
* Suggests improvements for column configuration
|
|
47
|
+
*/
|
|
48
|
+
suggestImprovements: (columns: Column[]) => string[];
|
|
49
|
+
};
|