@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 @@
|
|
|
1
|
+
export * from './tableTypes.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './tableTypes.js';
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import type { Component, Snippet } from 'svelte';
|
|
2
|
+
import type { TableProps } from '../core/table';
|
|
3
|
+
/**
|
|
4
|
+
* A table data item. Table items are arbitrary records — the Table component
|
|
5
|
+
* accesses values dynamically via a column's accessor. Values are typed as
|
|
6
|
+
* `unknown` to force explicit narrowing in formatters, cells, and components.
|
|
7
|
+
*/
|
|
8
|
+
export type TableItem = Record<string, unknown>;
|
|
9
|
+
/**
|
|
10
|
+
* Primitive value classes that are safe to stringify, sort, group, and
|
|
11
|
+
* summarise without losing information. Used to constrain string-accessor
|
|
12
|
+
* keys so that the compiler rejects column definitions that would silently
|
|
13
|
+
* fall into the `String({}) === '[object Object]'` trap.
|
|
14
|
+
*/
|
|
15
|
+
export type PrimitiveValue = string | number | bigint | boolean | Date | null | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Keys of `T` whose value is a {@link PrimitiveValue}. Use as a constraint
|
|
18
|
+
* for string-accessor columns to keep search/sort/group meaningful.
|
|
19
|
+
*
|
|
20
|
+
* If `T` is the unrestricted `TableItem` (i.e. `Record<string, unknown>`),
|
|
21
|
+
* the result collapses to `never` — see {@link DataAccessor} for the
|
|
22
|
+
* pragmatic fallback to plain `string` in that case.
|
|
23
|
+
*/
|
|
24
|
+
export type PrimitiveKeys<T> = {
|
|
25
|
+
[K in keyof T]: T[K] extends PrimitiveValue ? K : never;
|
|
26
|
+
}[keyof T] & string;
|
|
27
|
+
/**
|
|
28
|
+
* Resolves the allowed string-accessor type for `T`. For typed rows this is
|
|
29
|
+
* the union of primitive-valued property names; for the default
|
|
30
|
+
* `Record<string, unknown>` row type (where `PrimitiveKeys<T>` is `never`)
|
|
31
|
+
* we widen back to `string` to keep the unconstrained call sites usable.
|
|
32
|
+
*/
|
|
33
|
+
export type DataAccessor<T> = [PrimitiveKeys<T>] extends [never] ? string : PrimitiveKeys<T>;
|
|
34
|
+
/**
|
|
35
|
+
* Cell rendering priority (first match wins):
|
|
36
|
+
* 1. Table-level `cell` snippet (full override for all columns)
|
|
37
|
+
* 2. `column.cell` snippet (per-column snippet, defined in template)
|
|
38
|
+
* 3. `column.component` (dynamic Svelte component)
|
|
39
|
+
* 4. `column.formatter` (text transformation)
|
|
40
|
+
* 5. Raw accessor value
|
|
41
|
+
*
|
|
42
|
+
* Whichever path renders the cell, the value that search, sort, group and
|
|
43
|
+
* summary operate on is **always** the accessor's output. Display and
|
|
44
|
+
* derived operations are decoupled by design.
|
|
45
|
+
*
|
|
46
|
+
* `value` in `formatter`/`cell`/`component` is intentionally typed as
|
|
47
|
+
* `unknown` for all column shapes — the table cannot statically prove the
|
|
48
|
+
* runtime shape of a function accessor's return type to every consumer of
|
|
49
|
+
* the column type, and forcing the union-narrowing path on each render
|
|
50
|
+
* would block legitimate cell sharing across columns of different shapes.
|
|
51
|
+
* Consumers that want a concrete value type can narrow inside the snippet
|
|
52
|
+
* or cast on the call boundary.
|
|
53
|
+
*/
|
|
54
|
+
interface BaseColumn<T> {
|
|
55
|
+
/**
|
|
56
|
+
* Display title of the column. May be empty (`''`) for icon-only columns
|
|
57
|
+
* such as action columns — the header cell then stays blank by design.
|
|
58
|
+
*/
|
|
59
|
+
title: string;
|
|
60
|
+
/**
|
|
61
|
+
* Label used wherever the column is referenced *by name* in table chrome
|
|
62
|
+
* (column-visibility menu, header menu, filter/grouping/summary menus).
|
|
63
|
+
* Falls back to {@link title}; when that is empty too, a humanized form
|
|
64
|
+
* of the column id is used (`quickActions` → "Quick Actions"). Set this
|
|
65
|
+
* on icon-only columns to give them a proper (localized) menu name, e.g.
|
|
66
|
+
* `{ id: 'actions', title: '', menuTitle: 'Aktionen' }`.
|
|
67
|
+
*/
|
|
68
|
+
menuTitle?: string;
|
|
69
|
+
/** Optional column width (CSS value) */
|
|
70
|
+
width?: string;
|
|
71
|
+
/** Minimum column width (CSS value) */
|
|
72
|
+
minWidth?: string;
|
|
73
|
+
/** Column flexibility */
|
|
74
|
+
flex?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Priority for responsive layout
|
|
77
|
+
* - 1: Always visible
|
|
78
|
+
* - 2: Hidden on medium screens
|
|
79
|
+
* - 3: Hidden on larger screens
|
|
80
|
+
*/
|
|
81
|
+
priority?: 1 | 2 | 3;
|
|
82
|
+
/** Text alignment within the column */
|
|
83
|
+
align?: 'left' | 'center' | 'right';
|
|
84
|
+
/** Custom formatter for cell values (only when no component/cell is set) */
|
|
85
|
+
formatter?: (value: unknown, item: T) => string | null;
|
|
86
|
+
/**
|
|
87
|
+
* Per-column snippet for custom cell rendering. Define in the template area of your
|
|
88
|
+
* `.svelte` file and reference here. Receives the row item and the resolved cell value.
|
|
89
|
+
*
|
|
90
|
+
* For non-trivial cells, or when `eslint-plugin-svelte` chokes on snippet type
|
|
91
|
+
* annotations such as `{#snippet name(item: T, _value: unknown)}`, prefer
|
|
92
|
+
* `component` + `componentProps` — they keep typing intact without depending
|
|
93
|
+
* on the plugin's snippet-arg parser.
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```svelte
|
|
97
|
+
* {#snippet statusCell(item, value)}
|
|
98
|
+
* <Badge intent={value === 'active' ? 'success' : 'danger'}>{value}</Badge>
|
|
99
|
+
* {/snippet}
|
|
100
|
+
*
|
|
101
|
+
* <Table items={data} columns={[
|
|
102
|
+
* { accessor: 'status', title: 'Status', cell: statusCell }
|
|
103
|
+
* ]} />
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
cell?: Snippet<[item: T, value: unknown]>;
|
|
107
|
+
/** Custom Svelte component for rendering this column's cells (rendered dynamically) */
|
|
108
|
+
component?: Component<{
|
|
109
|
+
item: T;
|
|
110
|
+
[key: string]: unknown;
|
|
111
|
+
}>;
|
|
112
|
+
/** Props factory for the custom component (item is always passed automatically) */
|
|
113
|
+
componentProps?: (item: T) => Record<string, unknown>;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Mixin for derived-operation flags (search/sort/group/sum). Only data
|
|
117
|
+
* columns (string or function accessor) can be derived — synthetic columns
|
|
118
|
+
* structurally exclude these flags so callers cannot, for instance, request
|
|
119
|
+
* grouping by an actions column.
|
|
120
|
+
*/
|
|
121
|
+
interface DerivableMixin {
|
|
122
|
+
/** Whether this column is sortable */
|
|
123
|
+
sortable?: boolean;
|
|
124
|
+
/** Whether this column is searchable */
|
|
125
|
+
searchable?: boolean;
|
|
126
|
+
/** Whether this column is groupable (auto-detected if undefined) */
|
|
127
|
+
groupable?: boolean;
|
|
128
|
+
/** Whether this column is summable (auto-detected from data type if undefined) */
|
|
129
|
+
summable?: boolean;
|
|
130
|
+
/** Column data type for smart detection */
|
|
131
|
+
dataType?: 'text' | 'number' | 'date' | 'boolean' | 'email' | 'url';
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Data column with a string accessor that names a primitive-valued property
|
|
135
|
+
* on `T`. The accessor doubles as the default identifier — pass `id` only to
|
|
136
|
+
* override (e.g. when two columns access the same field with different
|
|
137
|
+
* formatters).
|
|
138
|
+
*/
|
|
139
|
+
export interface DataColumnString<T> extends BaseColumn<T>, DerivableMixin {
|
|
140
|
+
/** Stable column identifier. Defaults to {@link accessor} when omitted. */
|
|
141
|
+
id?: string;
|
|
142
|
+
/** Property name on `T` whose value is rendered/used. Must point to a primitive. */
|
|
143
|
+
accessor: DataAccessor<T>;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Data column with a function accessor that derives the cell value from the
|
|
147
|
+
* row. Use this for nested object lookups (`item.expenseType?.name`) or
|
|
148
|
+
* computed values (`${lastName}, ${firstName}`). `id` is required because a
|
|
149
|
+
* function carries no implicit identifier.
|
|
150
|
+
*/
|
|
151
|
+
export interface DataColumnFunction<T> extends BaseColumn<T>, DerivableMixin {
|
|
152
|
+
/** Stable column identifier (required — functions carry no implicit name). */
|
|
153
|
+
id: string;
|
|
154
|
+
/** Function that derives the value to render/use from a row. */
|
|
155
|
+
accessor: (item: T) => unknown;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Synthetic column without a data accessor — typical for action buttons,
|
|
159
|
+
* derived visuals, or other UI that is not tied to a row property.
|
|
160
|
+
* Synthetic columns are structurally excluded from search, sort, group and
|
|
161
|
+
* summary because there is no value to operate on — the type omits the
|
|
162
|
+
* Derivable mixin, so `sortable: true` / `searchable: true` on a synthetic
|
|
163
|
+
* column would fail to compile.
|
|
164
|
+
*/
|
|
165
|
+
export interface SyntheticColumn<T> extends BaseColumn<T> {
|
|
166
|
+
/** Stable column identifier (required for state targeting + persistence). */
|
|
167
|
+
id: string;
|
|
168
|
+
/** Synthetic columns must not declare an accessor. */
|
|
169
|
+
accessor?: never;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Defines a table column. One of three shapes, discriminated by the
|
|
173
|
+
* presence and type of `accessor`:
|
|
174
|
+
*
|
|
175
|
+
* - {@link DataColumnString} — `accessor: 'propertyName'` (primitive-valued
|
|
176
|
+
* key on `T`). `id` defaults to the accessor name.
|
|
177
|
+
* - {@link DataColumnFunction} — `accessor: (item) => value`. `id` is required.
|
|
178
|
+
* - {@link SyntheticColumn} — no `accessor`. `id` is required. Not
|
|
179
|
+
* searchable/sortable/groupable.
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* ```ts
|
|
183
|
+
* const columns: Column<Expense>[] = [
|
|
184
|
+
* // Primitive property → id is implicit
|
|
185
|
+
* { accessor: 'description', title: 'Beschreibung' },
|
|
186
|
+
* // Object property → function accessor + explicit id
|
|
187
|
+
* { id: 'expenseType',
|
|
188
|
+
* accessor: (e) => e.expenseType?.name ?? '',
|
|
189
|
+
* title: 'Typ',
|
|
190
|
+
* component: TypeCell },
|
|
191
|
+
* // Synthetic — no row data
|
|
192
|
+
* { id: 'actions', title: '', component: ActionButtons }
|
|
193
|
+
* ];
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
196
|
+
export type Column<T = TableItem> = DataColumnString<T> | DataColumnFunction<T> | SyntheticColumn<T>;
|
|
197
|
+
/**
|
|
198
|
+
* Filter for table rows.
|
|
199
|
+
*
|
|
200
|
+
* `value` is always a string — even for numeric operators (`greaterThan`,
|
|
201
|
+
* `lessThan`). The filtering concern converts via `Number()` at comparison
|
|
202
|
+
* time. This keeps filters serializable for persistence and consistent with
|
|
203
|
+
* the text-input UI.
|
|
204
|
+
*/
|
|
205
|
+
export interface Filter {
|
|
206
|
+
/** Column ID the filter applies to (must match a column's resolved id) */
|
|
207
|
+
column: string;
|
|
208
|
+
/** Filter operator */
|
|
209
|
+
operator: FilterOperator;
|
|
210
|
+
/** Filter value (string — numeric operators convert via Number() internally) */
|
|
211
|
+
value: string;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Supported filter operators
|
|
215
|
+
*/
|
|
216
|
+
export type FilterOperator = 'contains' | 'equals' | 'startsWith' | 'endsWith' | 'greaterThan' | 'lessThan';
|
|
217
|
+
/**
|
|
218
|
+
* Query object emitted by the table in server mode.
|
|
219
|
+
* Contains the full query state for server-side data fetching.
|
|
220
|
+
* Compatible with any HTTP library — convert to URL params, GraphQL variables, etc.
|
|
221
|
+
*/
|
|
222
|
+
export interface TableQuery {
|
|
223
|
+
/** Current page (1-based) */
|
|
224
|
+
page: number;
|
|
225
|
+
/** Number of items per page */
|
|
226
|
+
itemsPerPage: number;
|
|
227
|
+
/** Column ID to sort by, or empty string if no sort is active */
|
|
228
|
+
sortColumn: string;
|
|
229
|
+
/** Sort direction */
|
|
230
|
+
sortDirection: 'asc' | 'desc';
|
|
231
|
+
/** Full-text search term */
|
|
232
|
+
searchTerm: string;
|
|
233
|
+
/** Active column filters */
|
|
234
|
+
activeFilters: Filter[];
|
|
235
|
+
/** Column ID for grouping, or null if ungrouped */
|
|
236
|
+
groupByKey: string | null;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Result returned by `queryFn` in server mode.
|
|
240
|
+
*/
|
|
241
|
+
export interface TableQueryResult {
|
|
242
|
+
/** Items for the current page/query */
|
|
243
|
+
items: TableItem[];
|
|
244
|
+
/** Total number of items matching the query (for pagination) */
|
|
245
|
+
totalItems: number;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Options for grouping
|
|
249
|
+
*/
|
|
250
|
+
export interface GroupOption {
|
|
251
|
+
/** Column ID for grouping */
|
|
252
|
+
key: string;
|
|
253
|
+
/** Display title */
|
|
254
|
+
title: string;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Snippet for expanded row content.
|
|
258
|
+
* Receives the data item of the expanded row.
|
|
259
|
+
*/
|
|
260
|
+
export type ExpandedRowContent = Snippet<[item: TableItem]>;
|
|
261
|
+
export type TableAction = 'filter' | 'group' | 'summary';
|
|
262
|
+
export type { TableProps };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { type FilterPersistenceConfig } from '@urbicon-ui/blocks';
|
|
2
|
+
import type { SummaryConfig } from '../stores/TableStore.svelte';
|
|
3
|
+
import type { Column, Filter, TableItem } from '../types/tableTypes';
|
|
4
|
+
/**
|
|
5
|
+
* Retrieves a nested value from an object using dot notation
|
|
6
|
+
* e.g. getNestedValue(user, 'address.city')
|
|
7
|
+
*/
|
|
8
|
+
export declare function getNestedValue(item: unknown, key: string): unknown;
|
|
9
|
+
/**
|
|
10
|
+
* Resolves the stable identifier of a column. Mirrors the discriminated
|
|
11
|
+
* union shape from `tableTypes.ts`:
|
|
12
|
+
*
|
|
13
|
+
* - string accessor → defaults to `accessor` if `id` is omitted
|
|
14
|
+
* - function accessor → `id` is required
|
|
15
|
+
* - synthetic column → `id` is required
|
|
16
|
+
*
|
|
17
|
+
* Throws when neither `id` nor a string `accessor` is present — this
|
|
18
|
+
* combination can only occur when a caller bypasses the type system, and
|
|
19
|
+
* returning a sentinel (e.g. empty string) would silently corrupt the
|
|
20
|
+
* filter/sort/group/visibility state that targets columns by id.
|
|
21
|
+
*/
|
|
22
|
+
export declare function resolveColumnId<T>(column: Column<T>): string;
|
|
23
|
+
/**
|
|
24
|
+
* Resolves the human-readable label of a column for use in table chrome
|
|
25
|
+
* (column-visibility menu, header menu, filter/grouping/summary menus).
|
|
26
|
+
*
|
|
27
|
+
* Resolution order: `menuTitle` → `title` → humanized column id. The last
|
|
28
|
+
* step guarantees a non-empty label even for icon-only columns
|
|
29
|
+
* (`{ id: 'actions', title: '' }` → "Actions") so menu entries never render
|
|
30
|
+
* blank. Header cells render `title` verbatim on purpose — an empty header
|
|
31
|
+
* is a deliberate design choice, an empty menu entry is not.
|
|
32
|
+
*/
|
|
33
|
+
export declare function resolveColumnLabel<T>(column: Column<T>): string;
|
|
34
|
+
/**
|
|
35
|
+
* Resolves the canonical value of a cell — the single source of truth that
|
|
36
|
+
* search, sort, group, summary and the default cell renderer all read from.
|
|
37
|
+
* Display via `cell`/`component`/`formatter` is decoupled and may transform
|
|
38
|
+
* this value further for rendering, but the derived operations always
|
|
39
|
+
* operate on the accessor's output.
|
|
40
|
+
*
|
|
41
|
+
* - string accessor → property lookup (dot-paths supported via `getNestedValue`)
|
|
42
|
+
* - function accessor → invoke with the item
|
|
43
|
+
* - synthetic column (no accessor) → `undefined`
|
|
44
|
+
*/
|
|
45
|
+
export declare function resolveColumnValue<T>(column: Column<T>, item: T): unknown;
|
|
46
|
+
/**
|
|
47
|
+
* Looks up a column from the table's column list by its resolved id.
|
|
48
|
+
* Returns `undefined` when no column matches — used by concerns that
|
|
49
|
+
* keep only the id in their state (filters, sort, group, summary).
|
|
50
|
+
*/
|
|
51
|
+
export declare function findColumnById<T>(columns: ReadonlyArray<Column<T>>, id: string): Column<T> | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Resolves a column's value by its id, falling back to a raw nested-key
|
|
54
|
+
* lookup when no matching column is registered. The fallback preserves the
|
|
55
|
+
* pre-2.0 behaviour for transient state (e.g. persisted filters that
|
|
56
|
+
* reference a column which has since been removed from the definition).
|
|
57
|
+
*/
|
|
58
|
+
export declare function resolveValueById<T extends TableItem>(columns: ReadonlyArray<Column<T>>, item: T, id: string): unknown;
|
|
59
|
+
/**
|
|
60
|
+
* Formats a cell value based on the column definition. The displayed value
|
|
61
|
+
* starts from the accessor's output — `formatter` then has a chance to
|
|
62
|
+
* transform it into a presentation string.
|
|
63
|
+
*/
|
|
64
|
+
export declare function formatCellValue<T extends TableItem>(item: T, column: Column<T>): string;
|
|
65
|
+
/**
|
|
66
|
+
* Groups items by a column-id, routing the lookup through {@link resolveValueById}
|
|
67
|
+
* so that function-accessor columns aggregate the computed value (not the
|
|
68
|
+
* non-existent property of the same name). Returns `{ ungrouped: items }`
|
|
69
|
+
* when no group id is provided.
|
|
70
|
+
*/
|
|
71
|
+
export declare function groupItems<T extends TableItem>(items: T[], columns: ReadonlyArray<Column<T>>, groupByKey: string | null): Record<string, T[]>;
|
|
72
|
+
/**
|
|
73
|
+
* Normalizes items for table consumption. Items without an `id` property
|
|
74
|
+
* get an `__index` assigned as stable fallback key.
|
|
75
|
+
*/
|
|
76
|
+
export declare function normalizeItems<T extends TableItem>(items: T[]): T[];
|
|
77
|
+
/**
|
|
78
|
+
* Resolves the ID of an item
|
|
79
|
+
*/
|
|
80
|
+
export declare function getItemId(item: TableItem | null | undefined): number | string;
|
|
81
|
+
/**
|
|
82
|
+
* Computes aggregate summary values for a set of items given summary configs.
|
|
83
|
+
* Extracted from the store for testability.
|
|
84
|
+
*
|
|
85
|
+
* The optional `getValue` resolver lets callers supply a column-aware lookup
|
|
86
|
+
* (typically `(item, id) => resolveValueById(state.columns, item, id)`) so
|
|
87
|
+
* that summary aggregations honour function accessors and computed values.
|
|
88
|
+
* When omitted, the legacy `getNestedValue` fallback is used — sufficient
|
|
89
|
+
* for primitive property keys and required by the standalone unit tests.
|
|
90
|
+
*/
|
|
91
|
+
export declare function calculateSummary(items: TableItem[], configs: Array<{
|
|
92
|
+
column: string;
|
|
93
|
+
type: 'sum' | 'avg' | 'count' | 'min' | 'max';
|
|
94
|
+
}>, getValue?: (item: TableItem, columnId: string) => unknown): Record<string, number>;
|
|
95
|
+
/**
|
|
96
|
+
* Tests whether a single item value matches a filter condition.
|
|
97
|
+
*/
|
|
98
|
+
export declare function matchesFilter(itemValue: string, filterValue: string, operator: string): boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Segment of text with a flag indicating whether it matched the search term.
|
|
101
|
+
*/
|
|
102
|
+
export interface TextSegment {
|
|
103
|
+
text: string;
|
|
104
|
+
highlighted: boolean;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Splits text into segments based on a search term, marking matching parts as highlighted.
|
|
108
|
+
* Used by SearchHighlight to render matches without {@html} (XSS-safe).
|
|
109
|
+
*/
|
|
110
|
+
export declare function splitSearchSegments(text: string, searchTerm: string): TextSegment[];
|
|
111
|
+
export declare function createPersistentFilters(config: FilterPersistenceConfig): {
|
|
112
|
+
value: Filter[];
|
|
113
|
+
reset(): void;
|
|
114
|
+
forceSave(): void;
|
|
115
|
+
reload(): void;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Specialized hook for search term persistence
|
|
119
|
+
*/
|
|
120
|
+
export declare function createPersistentSearchTerm(config: FilterPersistenceConfig): {
|
|
121
|
+
value: string;
|
|
122
|
+
reset(): void;
|
|
123
|
+
forceSave(): void;
|
|
124
|
+
reload(): void;
|
|
125
|
+
};
|
|
126
|
+
export declare function createPersistentGroupByKey(config: FilterPersistenceConfig): {
|
|
127
|
+
value: string | null;
|
|
128
|
+
reset(): void;
|
|
129
|
+
forceSave(): void;
|
|
130
|
+
reload(): void;
|
|
131
|
+
};
|
|
132
|
+
export declare function createPersistentSummaryConfigs(config: FilterPersistenceConfig): {
|
|
133
|
+
value: SummaryConfig[];
|
|
134
|
+
reset(): void;
|
|
135
|
+
forceSave(): void;
|
|
136
|
+
reload(): void;
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* Sort state shape persisted across reloads. `column === ''` represents
|
|
140
|
+
* "no active sort" — `useSorting.handleSort` clears the column on the
|
|
141
|
+
* third click.
|
|
142
|
+
*/
|
|
143
|
+
export interface PersistedSortState {
|
|
144
|
+
column: string;
|
|
145
|
+
direction: 'asc' | 'desc';
|
|
146
|
+
}
|
|
147
|
+
export declare function createPersistentSortState(config: FilterPersistenceConfig): {
|
|
148
|
+
value: PersistedSortState;
|
|
149
|
+
reset(): void;
|
|
150
|
+
forceSave(): void;
|
|
151
|
+
reload(): void;
|
|
152
|
+
};
|
|
153
|
+
export declare function createPersistentHiddenColumns(config: FilterPersistenceConfig): {
|
|
154
|
+
value: string[];
|
|
155
|
+
reset(): void;
|
|
156
|
+
forceSave(): void;
|
|
157
|
+
reload(): void;
|
|
158
|
+
};
|
|
159
|
+
export declare function createPersistentColumnOrder(config: FilterPersistenceConfig): {
|
|
160
|
+
value: string[];
|
|
161
|
+
reset(): void;
|
|
162
|
+
forceSave(): void;
|
|
163
|
+
reload(): void;
|
|
164
|
+
};
|
|
165
|
+
export { measureToCssVar, measureViewportOffsetTop, observeStuck } from './sticky-measure';
|