@scion/components 22.5.0 → 22.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_index.scss +32 -88
- package/design/components/_scion-component-dark-tokens.scss +15 -0
- package/design/components/_scion-component-light-tokens.scss +15 -0
- package/fesm2022/scion-components-common.mjs +156 -5
- package/fesm2022/scion-components-common.mjs.map +1 -1
- package/fesm2022/scion-components-dimension.mjs +3 -3
- package/fesm2022/scion-components-dimension.mjs.map +1 -1
- package/fesm2022/scion-components-icon.mjs +134 -98
- package/fesm2022/scion-components-icon.mjs.map +1 -1
- package/fesm2022/scion-components-menu.mjs +58 -51
- package/fesm2022/scion-components-menu.mjs.map +1 -1
- package/fesm2022/scion-components-sashbox.mjs +1 -1
- package/fesm2022/scion-components-sashbox.mjs.map +1 -1
- package/fesm2022/scion-components-splitter.mjs +1 -1
- package/fesm2022/scion-components-splitter.mjs.map +1 -1
- package/fesm2022/scion-components-table.mjs +1544 -1008
- package/fesm2022/scion-components-table.mjs.map +1 -1
- package/fesm2022/scion-components-text.mjs +83 -40
- package/fesm2022/scion-components-text.mjs.map +1 -1
- package/fesm2022/scion-components-throbber.mjs +1 -1
- package/fesm2022/scion-components-throbber.mjs.map +1 -1
- package/fesm2022/scion-components-tree.mjs +306 -0
- package/fesm2022/scion-components-tree.mjs.map +1 -0
- package/fesm2022/scion-components-viewport.mjs +31 -18
- package/fesm2022/scion-components-viewport.mjs.map +1 -1
- package/package.json +6 -2
- package/tree/package.json +4 -0
- package/types/scion-components-common.d.ts +111 -4
- package/types/scion-components-icon.d.ts +42 -15
- package/types/scion-components-menu.d.ts +7 -2
- package/types/scion-components-sashbox.d.ts +1 -1
- package/types/scion-components-splitter.d.ts +1 -1
- package/types/scion-components-table.d.ts +1112 -300
- package/types/scion-components-text.d.ts +6 -5
- package/types/scion-components-throbber.d.ts +1 -1
- package/types/scion-components-tree.d.ts +559 -0
- package/types/scion-components-viewport.d.ts +20 -11
- package/viewport/scrollbar/_scrollbar.scss +12 -0
- package/design/icons/_scion-icon-font.scss +0 -50
|
@@ -1,68 +1,315 @@
|
|
|
1
1
|
import * as _angular_core from '@angular/core';
|
|
2
|
-
import { Signal, Provider,
|
|
3
|
-
import {
|
|
2
|
+
import { WritableSignal, Signal, Provider, Injector } from '@angular/core';
|
|
3
|
+
import { MaybeArray, MaybeAsync } from '@scion/toolkit/types';
|
|
4
4
|
import { MaybeSignal, SciComponentDescriptor, SciTemplateDescriptor } from '@scion/components/common';
|
|
5
5
|
import { SciToolbarFactory, SciToolbarComponent } from '@scion/components/menu';
|
|
6
6
|
import { Translatable } from '@scion/components/text';
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* @docs-private Not public API. For internal use only.
|
|
10
|
+
*/
|
|
11
|
+
declare class ɵSciTable<T = unknown, ID = T> implements SciTable<ID> {
|
|
12
|
+
private readonly _tableStorage;
|
|
13
|
+
private readonly _injector;
|
|
14
|
+
readonly name: WritableSignal<`table:${string}` | undefined>;
|
|
15
|
+
readonly columns: Signal<SciTableColumnLike<T>[]>;
|
|
16
|
+
readonly rowActions?: SciTableRowActionFactoryFn<T>;
|
|
17
|
+
private readonly _rowBindings;
|
|
18
|
+
private readonly _datasource;
|
|
19
|
+
private readonly _trackBy?;
|
|
20
|
+
readonly tableViewRef: WritableSignal<SciTableViewRef | undefined>;
|
|
21
|
+
readonly userSettings: WritableSignal<SciTableUserSettings>;
|
|
22
|
+
readonly type: 'table' | 'tree';
|
|
23
|
+
readonly bufferSize: number;
|
|
24
|
+
readonly pageSize: number;
|
|
25
|
+
readonly filterable: WritableSignal<boolean>;
|
|
26
|
+
readonly showHeader: WritableSignal<boolean>;
|
|
27
|
+
readonly wrapHeader: WritableSignal<boolean>;
|
|
28
|
+
readonly sortable: WritableSignal<boolean>;
|
|
29
|
+
readonly resizable: WritableSignal<boolean>;
|
|
30
|
+
readonly selectable: WritableSignal<'single' | 'multi' | false>;
|
|
31
|
+
readonly scrollRange: Signal<SciScrollRange | undefined>;
|
|
32
|
+
readonly scrollTop: Signal<number>;
|
|
33
|
+
readonly virtualScrollOffset: Signal<{
|
|
34
|
+
top: number;
|
|
35
|
+
bottom: number;
|
|
36
|
+
}>;
|
|
37
|
+
readonly viewportPageSize: Signal<number>;
|
|
38
|
+
readonly scrolling: Signal<boolean>;
|
|
39
|
+
readonly resizing: Signal<boolean>;
|
|
40
|
+
readonly sortCriteria: WritableSignal<SciTableSortCriterion[]>;
|
|
41
|
+
readonly columnFilters: WritableSignal<SciTableColumnFilter[]>;
|
|
42
|
+
private readonly _cache;
|
|
43
|
+
private readonly _tableCellValuePreloader;
|
|
44
|
+
private readonly _tableFilter;
|
|
45
|
+
private readonly _tableTree;
|
|
46
|
+
readonly hoveredIndex: WritableSignal<number>;
|
|
47
|
+
readonly criteria: Signal<{
|
|
48
|
+
sort: SciTableSortCriterion[];
|
|
49
|
+
filter: SciTableColumnFilter[];
|
|
50
|
+
tableFilter: string | null;
|
|
51
|
+
}>;
|
|
52
|
+
readonly loading: Signal<boolean>;
|
|
53
|
+
readonly error: Signal<boolean>;
|
|
54
|
+
readonly activeRow: Signal<SciTableRow<T, ID> | undefined>;
|
|
55
|
+
readonly selectedItems: Signal<ID[]>;
|
|
56
|
+
readonly rowsById: Signal<Map<ID, SciTableRow<T, ID>>>;
|
|
57
|
+
readonly rows: Signal<SciTableRow<T, ID>[]>;
|
|
58
|
+
readonly visibleRowCount: Signal<number>;
|
|
59
|
+
readonly visibleRows: Signal<SciTreeTableNode<ID>[] | undefined>;
|
|
60
|
+
readonly rowIndexById: Signal<Map<ID, number>>;
|
|
61
|
+
readonly activeItem: Signal<ID | undefined>;
|
|
62
|
+
readonly activeIndex: Signal<number>;
|
|
63
|
+
constructor(descriptor: SciTableDescriptor<T, ID> & {
|
|
64
|
+
type?: 'table' | 'tree';
|
|
65
|
+
});
|
|
66
|
+
/**
|
|
67
|
+
* Connects {@link SciTableComponent} to the model.
|
|
68
|
+
*/
|
|
69
|
+
connect(name: `table:${string}`, viewRef: SciTableViewRef): void;
|
|
70
|
+
disconnect(): void;
|
|
71
|
+
private computeColumns;
|
|
72
|
+
/**
|
|
73
|
+
* Computes the rows currently visible in the viewport (+buffer).
|
|
74
|
+
*/
|
|
75
|
+
private computeRows;
|
|
76
|
+
/**
|
|
77
|
+
* Computes the visible row count based on the viewport size.
|
|
78
|
+
*/
|
|
79
|
+
private computeScrollRange;
|
|
80
|
+
private computeVirtualScrollOffset;
|
|
81
|
+
private computeViewportPageSize;
|
|
82
|
+
/**
|
|
83
|
+
* Tracks {@link HTMLElement.scrollTop} of the viewport.
|
|
84
|
+
*/
|
|
85
|
+
private computeScrollTop;
|
|
86
|
+
/**
|
|
87
|
+
* Tracks whether currently scrolling the viewport.
|
|
88
|
+
*/
|
|
89
|
+
private computeScrolling;
|
|
90
|
+
/**
|
|
91
|
+
* Loads the requested page from the cache or datasource and returns its loading state with a cancelation handler.
|
|
92
|
+
*/
|
|
93
|
+
private loadPage;
|
|
94
|
+
/**
|
|
95
|
+
* Toggles sort on a column. ASC -> DESC -> No sort
|
|
96
|
+
*
|
|
97
|
+
* TODO [ego] Revisit API, do we really want a three-state and implicit toggling logic?
|
|
98
|
+
*/
|
|
99
|
+
sort(columnName: `column:${string}`, multi: boolean): void;
|
|
100
|
+
/**
|
|
101
|
+
* Applies a filter, either via global filter or on a specific column.
|
|
102
|
+
*/
|
|
103
|
+
filter(text: string | null): void;
|
|
104
|
+
filter(text: string | number | boolean | SciEnumValueLike | SciEnumValueLike[] | null, options: {
|
|
105
|
+
columnName: `column:${string}`;
|
|
106
|
+
}): void;
|
|
107
|
+
setActiveItem(id: ID | undefined): void;
|
|
108
|
+
updateSelectedItems(updateFn: (ids: Set<ID>) => Set<ID>): void;
|
|
109
|
+
/**
|
|
110
|
+
* Indicates whether the built-in in-memory datasource is used.
|
|
111
|
+
*/
|
|
112
|
+
isInMemoryDatasource(): boolean;
|
|
113
|
+
reload(): void;
|
|
114
|
+
reloadFailed(): void;
|
|
115
|
+
dispose(): void;
|
|
116
|
+
/**
|
|
117
|
+
* Loads a set of pages on criteria or viewport changes.
|
|
118
|
+
*/
|
|
119
|
+
private installPageLoader;
|
|
120
|
+
private mapItemsToRow;
|
|
121
|
+
/**
|
|
122
|
+
* Creates a signal to read and write table user settings.
|
|
123
|
+
*/
|
|
124
|
+
private computeUserSettings;
|
|
125
|
+
/**
|
|
126
|
+
* Call trackBy function or fallback to track by object reference.
|
|
127
|
+
*/
|
|
128
|
+
trackBy(item: T): ID;
|
|
129
|
+
private computeActiveRow;
|
|
130
|
+
select(ids: MaybeArray<ID>): void;
|
|
131
|
+
expand(ids: MaybeArray<ID>): void;
|
|
132
|
+
isExpanded(id: ID): boolean;
|
|
133
|
+
expandAll(): void;
|
|
134
|
+
collapse(ids: MaybeArray<ID>): void;
|
|
135
|
+
collapseAll(): void;
|
|
136
|
+
toggleRow(id: ID): void;
|
|
137
|
+
}
|
|
138
|
+
interface SciScrollRange {
|
|
139
|
+
/** inclusive */
|
|
140
|
+
start: number;
|
|
141
|
+
/** exclusive */
|
|
142
|
+
end: number;
|
|
143
|
+
}
|
|
144
|
+
interface SciTableUserSettings {
|
|
145
|
+
columns?: {
|
|
146
|
+
name: string;
|
|
147
|
+
width?: number;
|
|
148
|
+
}[];
|
|
149
|
+
}
|
|
150
|
+
interface SciTableViewRef {
|
|
151
|
+
viewport: HTMLElement;
|
|
152
|
+
viewportHeight: Signal<number>;
|
|
153
|
+
viewportWidth: Signal<number>;
|
|
154
|
+
viewportClientHeight: Signal<number>;
|
|
155
|
+
viewportClientWidth: Signal<number>;
|
|
156
|
+
headerHeight: Signal<number>;
|
|
157
|
+
cellPadding: Signal<number>;
|
|
158
|
+
itemHeight: Signal<number>;
|
|
159
|
+
scrollToTop: () => void;
|
|
160
|
+
}
|
|
9
161
|
|
|
162
|
+
/**
|
|
163
|
+
* Provides an in-memory datasource for {@link SciTable} with built-in filtering and sorting.
|
|
164
|
+
*
|
|
165
|
+
* A datasource provides data to {@link SciTable}, passing each item to columns for display. For a tree structure, additionally pass a child selector to the datasource.
|
|
166
|
+
*
|
|
167
|
+
* This datasource requires all data to be loaded upfront. The datasource filters and sorts data in memory.
|
|
168
|
+
*
|
|
169
|
+
* Custom columns must configure a filter matcher and sort comparator to be filterable and sortable.
|
|
170
|
+
*
|
|
171
|
+
* For large datasets requiring pagination or server-side filtering and sorting, prefer implementing a custom datasource using {@link ɵprovideTableDatasource}.
|
|
172
|
+
*
|
|
173
|
+
* @example - Usage
|
|
174
|
+
* ```ts
|
|
175
|
+
* import {table, provideTableDatasource} from '@scion/components/table';
|
|
176
|
+
* import {httpResource} from '@angular/common/http';
|
|
177
|
+
*
|
|
178
|
+
* const users = httpResource<User[]>(() => '/api/users', {defaultValue: []});
|
|
179
|
+
*
|
|
180
|
+
* table({
|
|
181
|
+
* datasource: provideTableDatasource(users.value),
|
|
182
|
+
* columns: table => table.addStringColumn('Name', user => user.name),
|
|
183
|
+
* });
|
|
184
|
+
* ```
|
|
185
|
+
*
|
|
186
|
+
* @example - Displaying hierarchical data
|
|
187
|
+
* ```ts
|
|
188
|
+
* import {table, provideTableDatasource} from '@scion/components/table';
|
|
189
|
+
* import {httpResource} from '@angular/common/http';
|
|
190
|
+
*
|
|
191
|
+
* const users = httpResource<User[]>(() => '/api/users', {defaultValue: []});
|
|
192
|
+
*
|
|
193
|
+
* table({
|
|
194
|
+
* datasource: provideTableDatasource(users.value, user => user.children),
|
|
195
|
+
* columns: table => table.addStringColumn('Name', user => user.name),
|
|
196
|
+
* });
|
|
197
|
+
* ```
|
|
198
|
+
*
|
|
199
|
+
* @param data - Provides items to display in the table, or root items if displaying a tree structure.
|
|
200
|
+
* @param children - Function required to display a tree structure, returning an item's children or an empty array if the item has no children or is a leaf.
|
|
201
|
+
* Called eagerly for each item when initializing the table, inside a reactive context that re-evaluates when tracked signals change.
|
|
202
|
+
*
|
|
203
|
+
* @see SciTableDescriptor.datasource
|
|
204
|
+
*/
|
|
205
|
+
declare function provideTableDatasource<T>(data: Signal<T[]>, children?: (item: T) => T[]): SciTableDatasourceProvider<T>;
|
|
206
|
+
/**
|
|
207
|
+
* @docs-private Not public API. For internal use only.
|
|
208
|
+
* @experimental since 22.7.0; API and behavior may change in any version without notice.
|
|
209
|
+
*/
|
|
210
|
+
declare function ɵprovideTableDatasource<T, ID = T>(tableDatasource: SciTableDatasource<T, ID>): SciTableDatasourceProvider<T, ID>;
|
|
211
|
+
declare function ɵprovideTableDatasource<T, ID = T>(treeTableDatasource: SciTreeTableDatasource<T, ID>): SciTableDatasourceProvider<T, ID>;
|
|
212
|
+
interface SciTableDatasource<T, ID> {
|
|
213
|
+
getIds: (query: SciTableDatasourceQuery) => MaybeAsync<ID[]>;
|
|
214
|
+
getItems: (ids: ID[]) => MaybeAsync<T[]>;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* @experimental since 22.7.0; API and behavior may change in any version without notice.
|
|
218
|
+
*/
|
|
219
|
+
interface SciTreeTableDatasource<T, ID> {
|
|
220
|
+
getTreeTableNodes(query: SciTableDatasourceQuery): MaybeAsync<SciTreeTableNode<ID>[]>;
|
|
221
|
+
getItems(ids: ID[]): MaybeAsync<T[]>;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Symbol for providing a {@link SciTreeTableDatasource}.
|
|
225
|
+
*/
|
|
226
|
+
declare const eSCI_TABLE_DATASOURCE_PROVIDER: unique symbol;
|
|
227
|
+
/**
|
|
228
|
+
* Symbol for providing type inference for the ID type.
|
|
229
|
+
*/
|
|
230
|
+
declare const eSCI_TABLE_DATASOURCE_ID_TYPE: unique symbol;
|
|
231
|
+
/**
|
|
232
|
+
* Provides a datasource to {@link SciTable}.
|
|
233
|
+
*/
|
|
234
|
+
type SciTableDatasourceProvider<T, ID = never> = {
|
|
235
|
+
readonly [eSCI_TABLE_DATASOURCE_ID_TYPE]?: ID;
|
|
236
|
+
} & ([ID] extends [never] ? {
|
|
237
|
+
readonly [eSCI_TABLE_DATASOURCE_PROVIDER]: <ID>(table: ɵSciTable<T, ID>) => SciTreeTableDatasource<T, ID>;
|
|
238
|
+
} : {
|
|
239
|
+
readonly [eSCI_TABLE_DATASOURCE_PROVIDER]: (table: ɵSciTable<T, ID>) => SciTreeTableDatasource<T, ID>;
|
|
240
|
+
});
|
|
10
241
|
interface SciTableColumnFilter {
|
|
11
242
|
columnName: `column:${string}`;
|
|
12
|
-
text: string | boolean |
|
|
243
|
+
text: string | number | boolean | SciEnumValueLike | SciEnumValueLike[];
|
|
13
244
|
}
|
|
14
245
|
interface SciTableSortCriterion {
|
|
15
246
|
columnName: `column:${string}`;
|
|
16
247
|
direction: 'asc' | 'desc';
|
|
17
248
|
}
|
|
18
|
-
interface
|
|
19
|
-
page: number;
|
|
20
|
-
pageSize: number;
|
|
21
|
-
start: number;
|
|
22
|
-
end: number;
|
|
249
|
+
interface SciTableDatasourceQuery {
|
|
23
250
|
sortCriteria: SciTableSortCriterion[];
|
|
24
251
|
columnFilters: SciTableColumnFilter[];
|
|
25
252
|
tableFilter?: string;
|
|
26
253
|
}
|
|
27
|
-
interface
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
*/
|
|
31
|
-
items: T[];
|
|
32
|
-
/**
|
|
33
|
-
* Total count of the source data, used to calculate the scroll size.
|
|
34
|
-
*/
|
|
35
|
-
totalCount: number;
|
|
254
|
+
interface SciTreeTableNode<ID> {
|
|
255
|
+
id: ID;
|
|
256
|
+
parentId?: ID;
|
|
36
257
|
}
|
|
258
|
+
|
|
37
259
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
260
|
+
* Provides row bindings to tables in the scope of the injector providing the bindings.
|
|
261
|
+
*
|
|
262
|
+
* Multiple providers can be registered. Providers at different injector tree levels form a hierarchy.
|
|
40
263
|
*/
|
|
41
|
-
|
|
264
|
+
declare function provideTableRowBinding<T = unknown>(bindings: SciTableRowBindingFactoryFn<T>): Provider[];
|
|
42
265
|
/**
|
|
43
|
-
*
|
|
266
|
+
* Signature of a function to configure row bindings.
|
|
44
267
|
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
268
|
+
* Called per item with a {@link SciTableRowBindingFactory} to register bindings.
|
|
269
|
+
*
|
|
270
|
+
* The function:
|
|
271
|
+
* - Runs in a reactive context and re-evaluates when tracked signals change.
|
|
272
|
+
* - Can call `inject` to get required dependencies.
|
|
273
|
+
*/
|
|
274
|
+
type SciTableRowBindingFactoryFn<T> = (row: SciTableRowBindingFactory, item: T, index: number) => void;
|
|
275
|
+
/**
|
|
276
|
+
* Factory for configuring row bindings.
|
|
277
|
+
*
|
|
278
|
+
* Row bindings enable associating metadata and icons with a row. Metadata includes CSS shadow parts, CSS classes, and HTML attributes.
|
|
47
279
|
*/
|
|
48
|
-
declare function ɵillegaldatasource<T>(): Signal<T[]>;
|
|
49
|
-
|
|
50
|
-
declare function provideTableRowBinding<T = unknown>(bindings: SciTableRowBindingFactoryFn<T>): Provider;
|
|
51
|
-
type SciTableRowBindingFactoryFn<T> = (bindings: SciTableRowBindingFactory, item: T, index: number) => void;
|
|
52
280
|
interface SciTableRowBindingFactory {
|
|
53
|
-
addAttributeBinding(name: string, value: unknown | undefined): this;
|
|
54
|
-
addClassBinding(name: string | undefined): this;
|
|
55
281
|
/**
|
|
56
|
-
*
|
|
282
|
+
* Binds an icon to the row, displayed in the first column.
|
|
283
|
+
*
|
|
284
|
+
* ```ts
|
|
285
|
+
* import {table} from '@scion/components/table';
|
|
286
|
+
*
|
|
287
|
+
* table({
|
|
288
|
+
* datasource: data,
|
|
289
|
+
* columns: table => ...,
|
|
290
|
+
* rowBindings: bindings => bindings.addIconBinding('account_circle'),
|
|
291
|
+
* });
|
|
292
|
+
* ```
|
|
293
|
+
*
|
|
294
|
+
* SCION uses icon providers to render icons. An icon provider can be registered using {@link provideIconProvider}.
|
|
295
|
+
*
|
|
296
|
+
* Defaults to a Material icon provider if the application has not registered an icon provider, interpreting the icon as a Material Icon font ligature.
|
|
297
|
+
* Refer to https://fonts.google.com/icons for available Material icons and instructions on including the Material icon font.
|
|
298
|
+
*/
|
|
299
|
+
addIconBinding(icon: string): this;
|
|
300
|
+
/**
|
|
301
|
+
* Binds a CSS shadow part to the row for custom row/cell styling using the `::part()` CSS pseudo-element selector.
|
|
57
302
|
*
|
|
58
303
|
* Example usage:
|
|
59
304
|
* ```ts
|
|
305
|
+
* import {table} from '@scion/components/table';
|
|
306
|
+
*
|
|
60
307
|
* table({
|
|
61
308
|
* datasource: data,
|
|
309
|
+
* columns: table => ...,
|
|
62
310
|
* rowBindings: (bindings, item, index) => bindings
|
|
63
311
|
* .addPartBinding(index % 2 === 0 ? 'row:even' : 'row:odd')
|
|
64
312
|
* .addPartBinding(item.active ? 'row:active' : undefined),
|
|
65
|
-
* columns: table => ...,
|
|
66
313
|
* });
|
|
67
314
|
* ```
|
|
68
315
|
*
|
|
@@ -77,21 +324,97 @@ interface SciTableRowBindingFactory {
|
|
|
77
324
|
* ```
|
|
78
325
|
*/
|
|
79
326
|
addPartBinding(name: `row:${string}` | undefined): this;
|
|
327
|
+
/**
|
|
328
|
+
* Binds an HTML attribute to the row.
|
|
329
|
+
*
|
|
330
|
+
* Useful for end-to-end testing, such as associating a row with an item's primary key.
|
|
331
|
+
*
|
|
332
|
+
* ```ts
|
|
333
|
+
* import {table} from '@scion/components/table';
|
|
334
|
+
*
|
|
335
|
+
* table({
|
|
336
|
+
* datasource: data,
|
|
337
|
+
* columns: table => ...,
|
|
338
|
+
* rowBindings: (bindings, item) => bindings.addAttributeBinding('data-id', item.id),
|
|
339
|
+
* });
|
|
340
|
+
* ```
|
|
341
|
+
*/
|
|
342
|
+
addAttributeBinding(name: string, value: unknown | undefined): this;
|
|
343
|
+
/**
|
|
344
|
+
* Binds a CSS class to the row.
|
|
345
|
+
*/
|
|
346
|
+
addClassBinding(name: string | undefined): this;
|
|
347
|
+
}
|
|
348
|
+
declare class ɵSciTableRowBindingFactory implements SciTableRowBindingFactory {
|
|
349
|
+
readonly icons: string[];
|
|
350
|
+
readonly parts: string[];
|
|
351
|
+
readonly attributes: [string, unknown][];
|
|
352
|
+
readonly classes: string[];
|
|
353
|
+
addIconBinding(icon: string | undefined): this;
|
|
354
|
+
addPartBinding(name: string | undefined): this;
|
|
355
|
+
addAttributeBinding(name: string, value: unknown | undefined): this;
|
|
356
|
+
addClassBinding(name: string | undefined): this;
|
|
80
357
|
}
|
|
81
358
|
interface SciTableRowBindings {
|
|
82
|
-
|
|
359
|
+
icons: Signal<string[]>;
|
|
360
|
+
parts: Signal<string[]>;
|
|
83
361
|
attributes: Signal<{
|
|
84
362
|
[name: string]: unknown;
|
|
85
363
|
}>;
|
|
86
|
-
|
|
364
|
+
classes: Signal<string[]>;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Represents the internal value of {@link SciDateColumn}.
|
|
369
|
+
*/
|
|
370
|
+
interface SciDateValue {
|
|
371
|
+
/**
|
|
372
|
+
* Full ISO 8601 date/time string.
|
|
373
|
+
*/
|
|
374
|
+
isoString: string;
|
|
375
|
+
/**
|
|
376
|
+
* Milliseconds since UTC epoch.
|
|
377
|
+
*/
|
|
378
|
+
millis: number;
|
|
379
|
+
/**
|
|
380
|
+
* Human-readable formatted date and time string.
|
|
381
|
+
*/
|
|
382
|
+
formatted: string;
|
|
87
383
|
}
|
|
88
384
|
|
|
89
385
|
interface SciTableColumnFactory<T> {
|
|
90
|
-
|
|
91
|
-
|
|
386
|
+
/**
|
|
387
|
+
* Adds a column to the table for displaying text.
|
|
388
|
+
*
|
|
389
|
+
* The value can be plain text or a translation key. A translation key starts with the percent symbol (`%`)
|
|
390
|
+
* and may include parameters in matrix notation for text interpolation.
|
|
391
|
+
*
|
|
392
|
+
* SCION uses text providers to resolve translation keys. A text provider can be registered using {@link provideTextProvider}.
|
|
393
|
+
*
|
|
394
|
+
* The function:
|
|
395
|
+
* - Can call `inject` to get required dependencies.
|
|
396
|
+
* - Can call `toSignal` to convert an {@link Observable} to a {@link Signal}.
|
|
397
|
+
*/
|
|
398
|
+
addStringColumn(header: SciColumnHeaderLike, value: (item: T) => MaybeSignal<Translatable | undefined>): this;
|
|
399
|
+
/**
|
|
400
|
+
* Adds a column to the table for displaying text.
|
|
401
|
+
*
|
|
402
|
+
* The value can be plain text or a translation key. A translation key starts with the percent symbol (`%`)
|
|
403
|
+
* and may include parameters in matrix notation for text interpolation.
|
|
404
|
+
*
|
|
405
|
+
* SCION uses text providers to resolve translation keys. A text provider can be registered using {@link provideTextProvider}.
|
|
406
|
+
*
|
|
407
|
+
* The function:
|
|
408
|
+
* - Can call `inject` to get required dependencies.
|
|
409
|
+
* - Can call `toSignal` to convert an {@link Observable} to a {@link Signal}.
|
|
410
|
+
*/
|
|
411
|
+
addStringColumn(value: (item: T) => MaybeSignal<Translatable | undefined>): this;
|
|
412
|
+
/**
|
|
413
|
+
* Adds a column to the table for displaying text.
|
|
414
|
+
*/
|
|
92
415
|
addStringColumn(descriptor: SciStringColumnDescriptor<T>): this;
|
|
93
416
|
/**
|
|
94
|
-
* Adds a
|
|
417
|
+
* Adds a column to the table for displaying numeric values.
|
|
95
418
|
*
|
|
96
419
|
* ### Tabular Figures
|
|
97
420
|
* Numbers are rendered using tabular (fixed-width) figures to align digits vertically in fonts with varying character widths. Has no effect on monospaced fonts.
|
|
@@ -111,10 +434,14 @@ interface SciTableColumnFactory<T> {
|
|
|
111
434
|
* font-variant-numeric: normal;
|
|
112
435
|
* }
|
|
113
436
|
* ```
|
|
437
|
+
*
|
|
438
|
+
* The function:
|
|
439
|
+
* - Can call `inject` to get required dependencies.
|
|
440
|
+
* - Can call `toSignal` to convert an {@link Observable} to a {@link Signal}.
|
|
114
441
|
*/
|
|
115
|
-
addNumberColumn(header:
|
|
442
|
+
addNumberColumn(header: SciColumnHeaderLike, value: (item: T) => MaybeSignal<number | undefined>): this;
|
|
116
443
|
/**
|
|
117
|
-
* Adds a
|
|
444
|
+
* Adds a column to the table for displaying numeric values.
|
|
118
445
|
*
|
|
119
446
|
* ### Tabular Figures
|
|
120
447
|
* Numbers are rendered using tabular (fixed-width) figures to align digits vertically in fonts with varying character widths. Has no effect on monospaced fonts.
|
|
@@ -134,10 +461,14 @@ interface SciTableColumnFactory<T> {
|
|
|
134
461
|
* font-variant-numeric: normal;
|
|
135
462
|
* }
|
|
136
463
|
* ```
|
|
464
|
+
*
|
|
465
|
+
* The function:
|
|
466
|
+
* - Can call `inject` to get required dependencies.
|
|
467
|
+
* - Can call `toSignal` to convert an {@link Observable} to a {@link Signal}.
|
|
137
468
|
*/
|
|
138
469
|
addNumberColumn(value: (item: T) => MaybeSignal<number | undefined>): this;
|
|
139
470
|
/**
|
|
140
|
-
* Adds a
|
|
471
|
+
* Adds a column to the table for displaying numeric values.
|
|
141
472
|
*
|
|
142
473
|
* ### Tabular Figures
|
|
143
474
|
* Numbers are rendered using tabular (fixed-width) figures to align digits vertically in fonts with varying character widths. Has no effect on monospaced fonts.
|
|
@@ -159,11 +490,37 @@ interface SciTableColumnFactory<T> {
|
|
|
159
490
|
* ```
|
|
160
491
|
*/
|
|
161
492
|
addNumberColumn(descriptor: SciNumberColumnDescriptor<T>): this;
|
|
162
|
-
|
|
493
|
+
/**
|
|
494
|
+
* Adds a column to the table for displaying boolean values.
|
|
495
|
+
*
|
|
496
|
+
* Cells display `true` as a checkmark and `false` as an 'X'. Filter options are labeled as 'Yes'/'No'.
|
|
497
|
+
* For custom display or filter options, use {@link addEnumColumn} instead.
|
|
498
|
+
*
|
|
499
|
+
* The function:
|
|
500
|
+
* - Can call `inject` to get required dependencies.
|
|
501
|
+
* - Can call `toSignal` to convert an {@link Observable} to a {@link Signal}.
|
|
502
|
+
*/
|
|
503
|
+
addBooleanColumn(header: SciColumnHeaderLike, value: (item: T) => MaybeSignal<boolean | undefined>): this;
|
|
504
|
+
/**
|
|
505
|
+
* Adds a column to the table for displaying boolean values.
|
|
506
|
+
*
|
|
507
|
+
* Cells display `true` as a checkmark and `false` as an 'X'. Filter options are labeled as 'Yes'/'No'.
|
|
508
|
+
* For custom display or filter options, use {@link addEnumColumn} instead.
|
|
509
|
+
*
|
|
510
|
+
* The function:
|
|
511
|
+
* - Can call `inject` to get required dependencies.
|
|
512
|
+
* - Can call `toSignal` to convert an {@link Observable} to a {@link Signal}.
|
|
513
|
+
*/
|
|
163
514
|
addBooleanColumn(value: (item: T) => MaybeSignal<boolean | undefined>): this;
|
|
515
|
+
/**
|
|
516
|
+
* Adds a column to the table for displaying boolean values.
|
|
517
|
+
*
|
|
518
|
+
* Cells display `true` as a checkmark and `false` as an 'X'. Filter options are labeled as 'Yes'/'No'.
|
|
519
|
+
* For custom display or filter options, use {@link addEnumColumn} instead.
|
|
520
|
+
*/
|
|
164
521
|
addBooleanColumn(descriptor: SciBooleanColumnDescriptor<T>): this;
|
|
165
522
|
/**
|
|
166
|
-
* Adds a
|
|
523
|
+
* Adds a column to the table for displaying dates, times, or both.
|
|
167
524
|
*
|
|
168
525
|
* Supports ISO 8601 date/time strings, milliseconds since the UTC epoch, and `Date` objects.
|
|
169
526
|
*
|
|
@@ -187,10 +544,14 @@ interface SciTableColumnFactory<T> {
|
|
|
187
544
|
* font-variant-numeric: normal;
|
|
188
545
|
* }
|
|
189
546
|
* ```
|
|
547
|
+
*
|
|
548
|
+
* The function:
|
|
549
|
+
* - Can call `inject` to get required dependencies.
|
|
550
|
+
* - Can call `toSignal` to convert an {@link Observable} to a {@link Signal}.
|
|
190
551
|
*/
|
|
191
|
-
addDateColumn(header:
|
|
552
|
+
addDateColumn(header: SciColumnHeaderLike, value: (item: T) => MaybeSignal<SciDateLike | undefined>): this;
|
|
192
553
|
/**
|
|
193
|
-
* Adds a
|
|
554
|
+
* Adds a column to the table for displaying dates, times, or both.
|
|
194
555
|
*
|
|
195
556
|
* Supports ISO 8601 date/time strings, milliseconds since the UTC epoch, and `Date` objects.
|
|
196
557
|
*
|
|
@@ -214,10 +575,14 @@ interface SciTableColumnFactory<T> {
|
|
|
214
575
|
* font-variant-numeric: normal;
|
|
215
576
|
* }
|
|
216
577
|
* ```
|
|
578
|
+
*
|
|
579
|
+
* The function:
|
|
580
|
+
* - Can call `inject` to get required dependencies.
|
|
581
|
+
* - Can call `toSignal` to convert an {@link Observable} to a {@link Signal}.
|
|
217
582
|
*/
|
|
218
583
|
addDateColumn(value: (item: T) => MaybeSignal<SciDateLike | undefined>): this;
|
|
219
584
|
/**
|
|
220
|
-
* Adds a
|
|
585
|
+
* Adds a column to the table for displaying dates, times, or both.
|
|
221
586
|
*
|
|
222
587
|
* Supports ISO 8601 date/time strings, milliseconds since the UTC epoch, and `Date` objects.
|
|
223
588
|
*
|
|
@@ -243,12 +608,31 @@ interface SciTableColumnFactory<T> {
|
|
|
243
608
|
* ```
|
|
244
609
|
*/
|
|
245
610
|
addDateColumn(descriptor: SciDateColumnDescriptor<T>): this;
|
|
611
|
+
/**
|
|
612
|
+
* Adds a column to the table for displaying values of an enumeration.
|
|
613
|
+
*
|
|
614
|
+
* An enumeration defines a fixed set of values, each with a label and an optional icon and tooltip.
|
|
615
|
+
*/
|
|
616
|
+
addEnumColumn(descriptor: SciEnumColumnDescriptor<T>): this;
|
|
617
|
+
/**
|
|
618
|
+
* Adds a column to the table for displaying icons.
|
|
619
|
+
*
|
|
620
|
+
* An icon column is a standardized enum column for displaying icons. If configured with only a header icon and no label,
|
|
621
|
+
* it defaults to non-resizable and sizes to fit the icon.
|
|
622
|
+
*/
|
|
623
|
+
addIconColumn(descriptor: SciIconColumnDescriptor<T>): this;
|
|
624
|
+
/**
|
|
625
|
+
* Adds a column to the table for displaying custom content using a component.
|
|
626
|
+
*/
|
|
246
627
|
addComponentColumn(descriptor: SciComponentColumnDescriptor<T>): this;
|
|
628
|
+
/**
|
|
629
|
+
* Adds a column to the table for displaying custom content using a template.
|
|
630
|
+
*/
|
|
247
631
|
addTemplateColumn(descriptor: SciTemplateColumnDescriptor<T>): this;
|
|
248
632
|
}
|
|
249
633
|
interface SciTableColumnDescriptor {
|
|
250
634
|
name?: `column:${string}`;
|
|
251
|
-
header?:
|
|
635
|
+
header?: SciColumnHeaderLike;
|
|
252
636
|
resizable?: boolean;
|
|
253
637
|
/**
|
|
254
638
|
* Preferred column size.
|
|
@@ -261,8 +645,22 @@ interface SciTableColumnDescriptor {
|
|
|
261
645
|
*/
|
|
262
646
|
minWidth?: number;
|
|
263
647
|
}
|
|
648
|
+
/**
|
|
649
|
+
* Configures a table column for displaying text.
|
|
650
|
+
*/
|
|
264
651
|
interface SciStringColumnDescriptor<T> extends SciTableColumnDescriptor {
|
|
265
|
-
|
|
652
|
+
/**
|
|
653
|
+
* Specifies the text to display for an item.
|
|
654
|
+
*
|
|
655
|
+
* Can be text or a translation key. A translation key starts with the percent symbol (`%`) and may include parameters in matrix notation for text interpolation.
|
|
656
|
+
*
|
|
657
|
+
* SCION uses text providers to resolve translation keys. A text provider can be registered using {@link provideTextProvider}.
|
|
658
|
+
*
|
|
659
|
+
* The function:
|
|
660
|
+
* - Can call `inject` to get required dependencies.
|
|
661
|
+
* - Can call `toSignal` to convert an {@link Observable} to a {@link Signal}.
|
|
662
|
+
*/
|
|
663
|
+
value: (item: T) => MaybeSignal<Translatable | undefined>;
|
|
266
664
|
sortable?: boolean | {
|
|
267
665
|
comparator: SciTableColumnSortComparatorFn<T, string>;
|
|
268
666
|
};
|
|
@@ -275,7 +673,11 @@ interface SciStringColumnDescriptor<T> extends SciTableColumnDescriptor {
|
|
|
275
673
|
*/
|
|
276
674
|
interface SciNumberColumnDescriptor<T> extends SciTableColumnDescriptor {
|
|
277
675
|
/**
|
|
278
|
-
* Specifies the number to display
|
|
676
|
+
* Specifies the number to display for an item.
|
|
677
|
+
*
|
|
678
|
+
* The function:
|
|
679
|
+
* - Can call `inject` to get required dependencies.
|
|
680
|
+
* - Can call `toSignal` to convert an {@link Observable} to a {@link Signal}.
|
|
279
681
|
*/
|
|
280
682
|
value: (item: T) => MaybeSignal<number | undefined>;
|
|
281
683
|
/**
|
|
@@ -366,9 +768,28 @@ interface SciNumberColumnDescriptor<T> extends SciTableColumnDescriptor {
|
|
|
366
768
|
*/
|
|
367
769
|
locale?: MaybeSignal<string>;
|
|
368
770
|
}
|
|
771
|
+
/**
|
|
772
|
+
* Configures a table column for displaying boolean values.
|
|
773
|
+
*/
|
|
369
774
|
interface SciBooleanColumnDescriptor<T> extends SciTableColumnDescriptor {
|
|
775
|
+
/**
|
|
776
|
+
* Specifies the boolean value to display for an item.
|
|
777
|
+
*
|
|
778
|
+
* Cells display `true` as a checkmark and `false` as an 'X'. Filter options are labeled as 'Yes'/'No'.
|
|
779
|
+
* For custom display or filter options, use {@link addEnumColumn} instead.
|
|
780
|
+
*
|
|
781
|
+
* The function:
|
|
782
|
+
* - Can call `inject` to get required dependencies.
|
|
783
|
+
* - Can call `toSignal` to convert an {@link Observable} to a {@link Signal}.
|
|
784
|
+
*/
|
|
370
785
|
value: (item: T) => MaybeSignal<boolean | undefined>;
|
|
786
|
+
/**
|
|
787
|
+
* Controls whether the user can sort this column. Defaults to `true`.
|
|
788
|
+
*/
|
|
371
789
|
sortable?: boolean;
|
|
790
|
+
/**
|
|
791
|
+
* Controls whether the user can filter this column. Defaults to `true`.
|
|
792
|
+
*/
|
|
372
793
|
filterable?: boolean;
|
|
373
794
|
}
|
|
374
795
|
/**
|
|
@@ -376,9 +797,13 @@ interface SciBooleanColumnDescriptor<T> extends SciTableColumnDescriptor {
|
|
|
376
797
|
*/
|
|
377
798
|
interface SciDateColumnDescriptor<T> extends SciTableColumnDescriptor {
|
|
378
799
|
/**
|
|
379
|
-
* Specifies the date value to display
|
|
800
|
+
* Specifies the date value to display for an item.
|
|
380
801
|
*
|
|
381
802
|
* Can be an ISO 8601 date/time string (e.g., `2026-10-06`, `2026-10-06T14:30:15Z`, `T14:30:15`), milliseconds since the UTC epoch, or a `Date` object.
|
|
803
|
+
*
|
|
804
|
+
* The function:
|
|
805
|
+
* - Can call `inject` to get required dependencies.
|
|
806
|
+
* - Can call `toSignal` to convert an {@link Observable} to a {@link Signal}.
|
|
382
807
|
*/
|
|
383
808
|
value: (item: T) => MaybeSignal<SciDateLike | undefined>;
|
|
384
809
|
/**
|
|
@@ -420,6 +845,94 @@ interface SciDateColumnDescriptor<T> extends SciTableColumnDescriptor {
|
|
|
420
845
|
*/
|
|
421
846
|
timezone?: string;
|
|
422
847
|
}
|
|
848
|
+
/**
|
|
849
|
+
* Configures a table column for displaying values of an enumeration.
|
|
850
|
+
*
|
|
851
|
+
* An enumeration defines a fixed set of values, each with a label and an optional icon and tooltip.
|
|
852
|
+
*/
|
|
853
|
+
interface SciEnumColumnDescriptor<T = unknown> extends SciTableColumnDescriptor {
|
|
854
|
+
/**
|
|
855
|
+
* Specifies the enumeration value to display for an item. Must be a value of an entry defined in {@link values}.
|
|
856
|
+
*
|
|
857
|
+
* The function:
|
|
858
|
+
* - Can call `inject` to get required dependencies.
|
|
859
|
+
* - Can call `toSignal` to convert an {@link Observable} to a {@link Signal}.
|
|
860
|
+
*/
|
|
861
|
+
value: (item: T) => MaybeSignal<SciEnumValueLike | undefined>;
|
|
862
|
+
/**
|
|
863
|
+
* Specifies the enumeration entries.
|
|
864
|
+
*
|
|
865
|
+
* The array order determines the sort order of the enumeration.
|
|
866
|
+
*/
|
|
867
|
+
values: MaybeSignal<SciEnumColumnValues>;
|
|
868
|
+
/**
|
|
869
|
+
* Configures the display of enumeration values.
|
|
870
|
+
*
|
|
871
|
+
* Defaults to displaying the label in cells, and both icon and label in the column filter menu. Defaults are unset if using a custom format.
|
|
872
|
+
*/
|
|
873
|
+
format?: {
|
|
874
|
+
/**
|
|
875
|
+
* Controls whether to display the icon in cells.
|
|
876
|
+
*/
|
|
877
|
+
icon?: true;
|
|
878
|
+
/**
|
|
879
|
+
* Controls whether to display the label in cells.
|
|
880
|
+
*/
|
|
881
|
+
label?: true;
|
|
882
|
+
/**
|
|
883
|
+
* Configures the display of entries in the column filter menu.
|
|
884
|
+
*/
|
|
885
|
+
filter?: {
|
|
886
|
+
/**
|
|
887
|
+
* Controls whether to display the icon in the column filter menu.
|
|
888
|
+
*/
|
|
889
|
+
icon?: true;
|
|
890
|
+
};
|
|
891
|
+
};
|
|
892
|
+
/**
|
|
893
|
+
* Controls whether the user can sort this column. Defaults to `true`.
|
|
894
|
+
*/
|
|
895
|
+
sortable?: boolean;
|
|
896
|
+
/**
|
|
897
|
+
* Controls whether the user can filter this column. Defaults to `multi`.
|
|
898
|
+
*/
|
|
899
|
+
filterable?: 'single' | 'multi' | false;
|
|
900
|
+
}
|
|
901
|
+
/**
|
|
902
|
+
* Configures a table column for displaying icons.
|
|
903
|
+
*
|
|
904
|
+
* An icon column is a standardized enum column for displaying icons. If configured with only a header icon and no label,
|
|
905
|
+
* it defaults to non-resizable and sizes to fit the icon.
|
|
906
|
+
*/
|
|
907
|
+
interface SciIconColumnDescriptor<T = unknown> extends SciTableColumnDescriptor {
|
|
908
|
+
/**
|
|
909
|
+
* Specifies the icon to display for an item.
|
|
910
|
+
*
|
|
911
|
+
* SCION uses icon providers to render icons. An icon provider can be registered using {@link provideIconProvider}.
|
|
912
|
+
*
|
|
913
|
+
* Defaults to a Material icon provider if the application has not registered an icon provider, interpreting the icon as a Material Icon font ligature.
|
|
914
|
+
* Refer to https://fonts.google.com/icons for available Material icons and instructions on including the Material icon font.
|
|
915
|
+
*
|
|
916
|
+
* The function:
|
|
917
|
+
* - Can call `inject` to get required dependencies.
|
|
918
|
+
* - Can call `toSignal` to convert an {@link Observable} to a {@link Signal}.
|
|
919
|
+
*/
|
|
920
|
+
value: (item: T) => MaybeSignal<string | number | boolean | undefined>;
|
|
921
|
+
/**
|
|
922
|
+
* Specifies the icons displayed in this column.
|
|
923
|
+
*
|
|
924
|
+
* The array order determines the sort order.
|
|
925
|
+
*/
|
|
926
|
+
values: MaybeSignal<SciIconColumnValues>;
|
|
927
|
+
/**
|
|
928
|
+
* Controls whether the user can sort this column. Defaults to `true`.
|
|
929
|
+
*/
|
|
930
|
+
sortable?: boolean;
|
|
931
|
+
/**
|
|
932
|
+
* Controls whether the user can filter this column. Defaults to `multi`.
|
|
933
|
+
*/
|
|
934
|
+
filterable?: 'single' | 'multi' | false;
|
|
935
|
+
}
|
|
423
936
|
interface SciComponentColumnDescriptor<T> extends SciTableColumnDescriptor {
|
|
424
937
|
component: (item: T) => SciComponentDescriptor;
|
|
425
938
|
sortable?: boolean | {
|
|
@@ -460,78 +973,173 @@ type SciTableColumnSortComparatorFn<T = unknown, VALUE = unknown> = (a: SciTable
|
|
|
460
973
|
type SciTableColumnFilterMatcherFn<T = unknown, VALUE = unknown, FILTER = VALUE> = (filter: FILTER, context: SciTableCellContext<T, VALUE>) => boolean;
|
|
461
974
|
|
|
462
975
|
/**
|
|
463
|
-
* Represents the internal value of {@link
|
|
976
|
+
* Represents the internal value of {@link SciEnumColumn}.
|
|
464
977
|
*/
|
|
465
|
-
interface
|
|
978
|
+
interface SciEnumValue {
|
|
979
|
+
value: SciEnumValueLike;
|
|
980
|
+
/** localized text */
|
|
981
|
+
label: string;
|
|
982
|
+
/** localized tooltip */
|
|
983
|
+
tooltip?: string;
|
|
984
|
+
icon?: string;
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
/**
|
|
988
|
+
* Represents supported column types of {@link SciTableComponent}.
|
|
989
|
+
*/
|
|
990
|
+
type SciTableColumnType = 'string' | 'number' | 'boolean' | 'date' | 'icon' | 'enum' | 'component' | 'template';
|
|
991
|
+
/**
|
|
992
|
+
* Represents a descriptor to configure {@link SciTableComponent}.
|
|
993
|
+
*
|
|
994
|
+
* Defines the columns, datasource, and display options. Requires at minimum a datasource and columns.
|
|
995
|
+
*/
|
|
996
|
+
interface SciTableDescriptor<T, ID = T> {
|
|
466
997
|
/**
|
|
467
|
-
*
|
|
998
|
+
* Specifies the datasource to provide data to {@link SciTable}.
|
|
999
|
+
*
|
|
1000
|
+
* Create a datasource using the {@link provideTableDatasource} function and pass a signal containing the items.
|
|
1001
|
+
* For a tree structure, additionally pass a child selector to the datasource.
|
|
1002
|
+
*
|
|
1003
|
+
* As a convenience for non-hierarchical tables, an array signal can be used directly as the datasource.
|
|
1004
|
+
*
|
|
1005
|
+
* @example - Usage
|
|
1006
|
+
* ```ts
|
|
1007
|
+
* import {table} from '@scion/components/table';
|
|
1008
|
+
* import {httpResource} from '@angular/common/http';
|
|
1009
|
+
*
|
|
1010
|
+
* const users = httpResource<User[]>(() => '/api/users', {defaultValue: []});
|
|
1011
|
+
*
|
|
1012
|
+
* table({
|
|
1013
|
+
* datasource: users.value,
|
|
1014
|
+
* columns: table => table.addStringColumn('Name', user => user.name),
|
|
1015
|
+
* });
|
|
1016
|
+
* ```
|
|
1017
|
+
*
|
|
1018
|
+
* @example - Displaying hierarchical data
|
|
1019
|
+
* ```ts
|
|
1020
|
+
* import {table, provideTableDatasource} from '@scion/components/table';
|
|
1021
|
+
* import {httpResource} from '@angular/common/http';
|
|
1022
|
+
*
|
|
1023
|
+
* const users = httpResource<User[]>(() => '/api/users', {defaultValue: []});
|
|
1024
|
+
*
|
|
1025
|
+
* table({
|
|
1026
|
+
* datasource: provideTableDatasource(users.value, user => user.children),
|
|
1027
|
+
* columns: table => table.addStringColumn('Name', user => user.name),
|
|
1028
|
+
* });
|
|
1029
|
+
* ```
|
|
1030
|
+
*
|
|
1031
|
+
* @see provideTableDatasource
|
|
468
1032
|
*/
|
|
469
|
-
|
|
1033
|
+
datasource: Signal<T[]> | SciTableDatasourceProvider<T, ID>;
|
|
470
1034
|
/**
|
|
471
|
-
*
|
|
1035
|
+
* Configures the table columns.
|
|
1036
|
+
*
|
|
1037
|
+
* @example
|
|
1038
|
+
* ```ts
|
|
1039
|
+
* import {table} from '@scion/components/table';
|
|
1040
|
+
*
|
|
1041
|
+
* table({
|
|
1042
|
+
* datasource: data,
|
|
1043
|
+
* columns: table => table
|
|
1044
|
+
* .addStringColumn('Name', item => item.name)
|
|
1045
|
+
* .addNumberColumn('Age', item => item.age),
|
|
1046
|
+
* });
|
|
1047
|
+
* ```
|
|
1048
|
+
*
|
|
1049
|
+
* The function:
|
|
1050
|
+
* - Runs in a reactive context and re-evaluates when tracked signals change.
|
|
1051
|
+
* - Can call `inject` to get required dependencies.
|
|
472
1052
|
*/
|
|
473
|
-
|
|
1053
|
+
columns: SciTableColumnFactoryFn<T>;
|
|
474
1054
|
/**
|
|
475
|
-
*
|
|
1055
|
+
* Controls whether the user can sort rows by clicking column headers. Defaults to `true`.
|
|
476
1056
|
*/
|
|
477
|
-
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
type SciTableColumnType = 'string' | 'number' | 'boolean' | 'date' | 'component' | 'template';
|
|
481
|
-
type SciTableRowActionFactoryFn<T> = (toolbar: SciToolbarFactory, item: T, index: number) => void;
|
|
482
|
-
interface SciTableDescriptor<T> {
|
|
483
|
-
datasource: Signal<T[]>;
|
|
1057
|
+
sortable?: boolean;
|
|
484
1058
|
/**
|
|
485
|
-
*
|
|
486
|
-
* @experimental since 22.3.0; API and behavior may change in any version without notice.
|
|
1059
|
+
* Controls whether the user can resize columns. Defaults to `true`.
|
|
487
1060
|
*/
|
|
488
|
-
ɵdatasource?: Signal<T[]> | SciTableDataLoaderFn<T>;
|
|
489
|
-
columns: SciTableColumnFactoryFn<T>;
|
|
490
|
-
sortable?: boolean;
|
|
491
1061
|
resizable?: boolean;
|
|
1062
|
+
/**
|
|
1063
|
+
* Controls whether the column filters are displayed. Defaults to `false`.
|
|
1064
|
+
*
|
|
1065
|
+
* Does not affect filtering via {@link SciTable.filter}.
|
|
1066
|
+
*/
|
|
492
1067
|
filterable?: boolean;
|
|
493
|
-
|
|
1068
|
+
/**
|
|
1069
|
+
* Controls whether the user can select a single row (`single`), multiple rows (`multi`), or no rows (`false`). Defaults to `multi`.
|
|
1070
|
+
*
|
|
1071
|
+
* Does not affect selection via {@link SciTable.select}.
|
|
1072
|
+
*/
|
|
1073
|
+
selectable?: 'single' | 'multi' | false;
|
|
1074
|
+
/**
|
|
1075
|
+
* Controls whether column headers are displayed. Defaults to `true`.
|
|
1076
|
+
*/
|
|
494
1077
|
showHeader?: boolean;
|
|
495
1078
|
/**
|
|
496
|
-
* Defaults to false
|
|
1079
|
+
* Controls whether column headers are wrapped if they overflow. Defaults to `false`.
|
|
1080
|
+
*
|
|
1081
|
+
* If not wrapped, the headers are truncated and ellipsis are shown on overflow.
|
|
497
1082
|
*/
|
|
498
1083
|
wrapHeader?: boolean;
|
|
499
1084
|
/**
|
|
500
1085
|
* Configures actions to show when hovering over a row.
|
|
501
1086
|
*
|
|
502
|
-
*
|
|
1087
|
+
* @example
|
|
503
1088
|
* ```ts
|
|
1089
|
+
* import {table} from '@scion/components/table';
|
|
1090
|
+
*
|
|
504
1091
|
* table({
|
|
505
1092
|
* datasource: data,
|
|
1093
|
+
* columns: table => ...,
|
|
506
1094
|
* rowActions: (toolbar, item) => toolbar.addToolbarButton({
|
|
507
1095
|
* icon: 'delete',
|
|
508
1096
|
* onSelect: () => ...,
|
|
509
1097
|
* }),
|
|
510
|
-
* columns: table => ...,
|
|
511
1098
|
* });
|
|
512
1099
|
* ```
|
|
1100
|
+
*
|
|
1101
|
+
* The function:
|
|
1102
|
+
* - Is called per item with a {@link SciToolbarFactory} to contribute actions.
|
|
1103
|
+
* - Runs in a reactive context and re-evaluates when tracked signals change.
|
|
1104
|
+
* - Can call `inject` to get required dependencies.
|
|
513
1105
|
*/
|
|
514
1106
|
rowActions?: SciTableRowActionFactoryFn<T>;
|
|
515
1107
|
/**
|
|
516
|
-
*
|
|
1108
|
+
* Configures row bindings for table rows.
|
|
517
1109
|
*
|
|
518
|
-
*
|
|
1110
|
+
* Row bindings enable associating metadata and icons with a row. Metadata includes CSS shadow parts, CSS classes, and HTML attributes.
|
|
1111
|
+
*
|
|
1112
|
+
* @example
|
|
519
1113
|
* ```ts
|
|
1114
|
+
* import {table} from '@scion/components/table';
|
|
1115
|
+
*
|
|
520
1116
|
* table({
|
|
521
1117
|
* datasource: data,
|
|
1118
|
+
* columns: table => ...,
|
|
522
1119
|
* rowBindings: (bindings, item, index) => bindings
|
|
1120
|
+
* .addIconBinding('account_circle')
|
|
523
1121
|
* .addPartBinding(index % 2 === 0 ? 'row:even' : 'row:odd')
|
|
524
1122
|
* .addAttributeBinding('data-id', item.id)
|
|
525
1123
|
* .addClassBinding(item.inactive ? 'inactive' : undefined),
|
|
526
|
-
* columns: table => ...,
|
|
527
1124
|
* });
|
|
528
1125
|
* ```
|
|
529
1126
|
*
|
|
1127
|
+
* Part attribute bindings make a row stylable by associating its cells with one or more HTML part attributes that can be referenced in CSS using the `::part()` CSS pseudo-element selector.
|
|
1128
|
+
*
|
|
530
1129
|
* ```scss
|
|
531
1130
|
* sci-table::part(row\:even row\:not\:selected) {
|
|
532
1131
|
* background-color: lightgray;
|
|
533
1132
|
* }
|
|
534
1133
|
* ```
|
|
1134
|
+
*
|
|
1135
|
+
* The function:
|
|
1136
|
+
* - Is called per item with a {@link SciTableRowBindingFactory} to register bindings.
|
|
1137
|
+
* - Runs in a reactive context and re-evaluates when tracked signals change.
|
|
1138
|
+
* - Can call `inject` to get required dependencies.
|
|
1139
|
+
*
|
|
1140
|
+
* @param bindings - Factory providing methods to register row bindings.
|
|
1141
|
+
* @param item - Item associated with the row.
|
|
1142
|
+
* @param index - Index of the row, zero-based.
|
|
535
1143
|
*/
|
|
536
1144
|
rowBindings?: SciTableRowBindingFactoryFn<T>;
|
|
537
1145
|
/**
|
|
@@ -542,33 +1150,106 @@ interface SciTableDescriptor<T> {
|
|
|
542
1150
|
* Specifies the number of items to load per page. Defaults to 50.
|
|
543
1151
|
*/
|
|
544
1152
|
pageSize?: number;
|
|
545
|
-
|
|
1153
|
+
/**
|
|
1154
|
+
* Computes a unique and stable identity for items in the table.
|
|
1155
|
+
*
|
|
1156
|
+
* Defaults to the item object reference. Used to identify items when loading data from the datasource and when tracking table selection.
|
|
1157
|
+
*/
|
|
1158
|
+
trackBy?: (item: T) => ID;
|
|
1159
|
+
/**
|
|
1160
|
+
* Specifies an injector used to create the table. Defaults to the current injection context.
|
|
1161
|
+
* The table is disposed when the passed injector is destroyed.
|
|
1162
|
+
*/
|
|
546
1163
|
injector?: Injector;
|
|
547
1164
|
}
|
|
548
|
-
|
|
1165
|
+
/**
|
|
1166
|
+
* Represents a table for {@link SciTableComponent}.
|
|
1167
|
+
*
|
|
1168
|
+
* Can be constructed using the {@link table} function.
|
|
1169
|
+
* Use to bind to `<sci-table>` and interact with the table.
|
|
1170
|
+
*
|
|
1171
|
+
* @see table
|
|
1172
|
+
* @see SciTableComponent
|
|
1173
|
+
*/
|
|
1174
|
+
interface SciTable<ID = unknown> {
|
|
1175
|
+
/**
|
|
1176
|
+
* Provides the active item, if any.
|
|
1177
|
+
*
|
|
1178
|
+
* The active item may differ from the selected items and is used as the target for keyboard navigation.
|
|
1179
|
+
*/
|
|
1180
|
+
readonly activeItem: Signal<ID | undefined>;
|
|
549
1181
|
/**
|
|
550
|
-
*
|
|
1182
|
+
* Provides the selected items.
|
|
551
1183
|
*/
|
|
552
|
-
readonly
|
|
1184
|
+
readonly selectedItems: Signal<Array<ID>>;
|
|
553
1185
|
/**
|
|
554
|
-
*
|
|
1186
|
+
* Controls whether the column filters are displayed.
|
|
1187
|
+
*
|
|
1188
|
+
* Initialized from {@link SciTableDescriptor.filterable}. Defaults to `false`.
|
|
1189
|
+
* Does not affect filtering via {@link SciTable.filter}.
|
|
555
1190
|
*/
|
|
556
|
-
readonly selectedItems: Signal<Array<T>>;
|
|
557
1191
|
readonly filterable: WritableSignal<boolean>;
|
|
1192
|
+
/**
|
|
1193
|
+
* Controls whether column headers are displayed.
|
|
1194
|
+
*
|
|
1195
|
+
* Initialized from {@link SciTableDescriptor.showHeader}. Defaults to `true`.
|
|
1196
|
+
*/
|
|
558
1197
|
readonly showHeader: WritableSignal<boolean>;
|
|
1198
|
+
/**
|
|
1199
|
+
* Controls whether column headers are wrapped if they overflow.
|
|
1200
|
+
*
|
|
1201
|
+
* If not wrapped, the headers are truncated with an ellipsis on overflow.
|
|
1202
|
+
* Initialized from {@link SciTableDescriptor.wrapHeader}. Defaults to `false`.
|
|
1203
|
+
*/
|
|
559
1204
|
readonly wrapHeader: WritableSignal<boolean>;
|
|
1205
|
+
/**
|
|
1206
|
+
* Controls whether the user can sort rows by clicking column headers.
|
|
1207
|
+
*
|
|
1208
|
+
* Initialized from {@link SciTableDescriptor.sortable}. Defaults to `true`.
|
|
1209
|
+
*/
|
|
560
1210
|
readonly sortable: WritableSignal<boolean>;
|
|
1211
|
+
/**
|
|
1212
|
+
* Controls whether the user can resize columns.
|
|
1213
|
+
*
|
|
1214
|
+
* Initialized from {@link SciTableDescriptor.resizable}. Defaults to `true`.
|
|
1215
|
+
*/
|
|
561
1216
|
readonly resizable: WritableSignal<boolean>;
|
|
1217
|
+
/**
|
|
1218
|
+
* Controls whether the user can select a single row (`single`), multiple rows (`multi`), or no rows (`false`).
|
|
1219
|
+
*
|
|
1220
|
+
* Initialized from {@link SciTableDescriptor.selectable}. Defaults to `multi`.
|
|
1221
|
+
* Does not affect selection via {@link SciTable.select}.
|
|
1222
|
+
*/
|
|
562
1223
|
readonly selectable: WritableSignal<'single' | 'multi' | false>;
|
|
563
1224
|
/**
|
|
564
1225
|
* Filters items cross-column, ignoring {@link SciTableDescriptor.filterable} and {@link SciTableColumnDescriptor.filterable} settings.
|
|
565
1226
|
*/
|
|
566
1227
|
filter(text: string | null): void;
|
|
1228
|
+
/**
|
|
1229
|
+
* Selects the specified rows, replacing the current selection.
|
|
1230
|
+
*
|
|
1231
|
+
* Expands parent rows for table tree (hierarchical) datasource.
|
|
1232
|
+
*
|
|
1233
|
+
* @param id - ID or IDs of the rows to select, or an empty array to clear the selection.
|
|
1234
|
+
*/
|
|
1235
|
+
select(id: MaybeArray<ID>): void;
|
|
1236
|
+
/**
|
|
1237
|
+
* Expands all rows in the tree. Only for table tree (hierarchical) datasource.
|
|
1238
|
+
*/
|
|
1239
|
+
expandAll(): void;
|
|
1240
|
+
/**
|
|
1241
|
+
* Collapses all rows in the tree. Only for table tree (hierarchical) datasource.
|
|
1242
|
+
*/
|
|
1243
|
+
collapseAll(): void;
|
|
567
1244
|
}
|
|
568
1245
|
interface SciTableColumn<T = unknown, VALUE = unknown, FILTER = VALUE> {
|
|
569
1246
|
type: SciTableColumnType;
|
|
570
1247
|
name: `column:${string}`;
|
|
571
|
-
header:
|
|
1248
|
+
header: {
|
|
1249
|
+
icon: string | undefined;
|
|
1250
|
+
label: Signal<string> | undefined;
|
|
1251
|
+
tooltip: Signal<string> | undefined;
|
|
1252
|
+
};
|
|
572
1253
|
sortable: Signal<boolean>;
|
|
573
1254
|
filterable: Signal<boolean>;
|
|
574
1255
|
resizable: Signal<boolean>;
|
|
@@ -586,54 +1267,56 @@ interface SciTableColumn<T = unknown, VALUE = unknown, FILTER = VALUE> {
|
|
|
586
1267
|
interface SciStringColumn<T = unknown> extends SciTableColumn<T, string> {
|
|
587
1268
|
type: 'string';
|
|
588
1269
|
value: (item: T) => Signal<string | undefined>;
|
|
589
|
-
compare: SciTableColumnSortComparatorFn<T, string>;
|
|
590
|
-
matches: SciTableColumnFilterMatcherFn<T, string>;
|
|
591
1270
|
}
|
|
592
1271
|
interface SciNumberColumn<T = unknown> extends SciTableColumn<T, number> {
|
|
593
1272
|
type: 'number';
|
|
594
1273
|
value: (item: T) => Signal<number | undefined>;
|
|
595
|
-
compare: SciTableColumnSortComparatorFn<T, number>;
|
|
596
|
-
matches: SciTableColumnFilterMatcherFn<T, number>;
|
|
597
1274
|
format: Signal<Intl.NumberFormat>;
|
|
598
1275
|
}
|
|
599
|
-
interface SciBooleanColumn<T = unknown> extends SciTableColumn<T, boolean> {
|
|
600
|
-
type: 'boolean';
|
|
601
|
-
value: (item: T) => Signal<boolean | undefined>;
|
|
602
|
-
compare: SciTableColumnSortComparatorFn<T, boolean>;
|
|
603
|
-
matches: SciTableColumnFilterMatcherFn<T, boolean>;
|
|
604
|
-
}
|
|
605
1276
|
interface SciDateColumn<T = unknown> extends SciTableColumn<T, SciDateValue, string> {
|
|
606
1277
|
type: 'date';
|
|
607
1278
|
value: (item: T) => Signal<SciDateValue | undefined>;
|
|
608
|
-
|
|
609
|
-
|
|
1279
|
+
}
|
|
1280
|
+
interface SciEnumColumn<T = unknown> extends Omit<SciTableColumn<T, SciEnumValue, SciEnumValueLike[] | string>, 'filterable'> {
|
|
1281
|
+
type: 'enum';
|
|
1282
|
+
value: (item: T) => Signal<SciEnumValue | undefined>;
|
|
1283
|
+
filterable: Signal<'single' | 'multi' | false>;
|
|
1284
|
+
enumeration: Signal<SciEnumColumnValues>;
|
|
1285
|
+
format: {
|
|
1286
|
+
icon: boolean;
|
|
1287
|
+
label: boolean;
|
|
1288
|
+
filter: {
|
|
1289
|
+
icon: boolean;
|
|
1290
|
+
};
|
|
1291
|
+
};
|
|
1292
|
+
referenceType: SciTableColumnType | undefined;
|
|
610
1293
|
}
|
|
611
1294
|
interface SciComponentColumn<T = unknown> extends SciTableColumn<T, void, string> {
|
|
612
1295
|
type: 'component';
|
|
613
1296
|
component: (item: T) => SciComponentDescriptor;
|
|
614
|
-
compare: SciTableColumnSortComparatorFn<T, void>;
|
|
615
|
-
matches: SciTableColumnFilterMatcherFn<T, void, string>;
|
|
616
1297
|
}
|
|
617
1298
|
interface SciTemplateColumn<T = unknown> extends SciTableColumn<T, void, string> {
|
|
618
1299
|
type: 'template';
|
|
619
1300
|
template: (item: T) => SciTemplateDescriptor;
|
|
620
|
-
compare: SciTableColumnSortComparatorFn<T, void>;
|
|
621
|
-
matches: SciTableColumnFilterMatcherFn<T, void, string>;
|
|
622
1301
|
}
|
|
623
|
-
type SciTableColumnLike<T = unknown> = SciStringColumn<T> | SciNumberColumn<T> |
|
|
1302
|
+
type SciTableColumnLike<T = unknown> = SciStringColumn<T> | SciNumberColumn<T> | SciDateColumn<T> | SciEnumColumn<T> | SciComponentColumn<T> | SciTemplateColumn<T>;
|
|
1303
|
+
declare const skeletonRowId: unique symbol;
|
|
624
1304
|
/**
|
|
625
1305
|
* Mapped row, used as display state.
|
|
626
1306
|
*/
|
|
627
|
-
interface SciTableRow<T> {
|
|
1307
|
+
interface SciTableRow<T, ID> {
|
|
628
1308
|
index: number;
|
|
629
|
-
item
|
|
630
|
-
id
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
1309
|
+
item: T;
|
|
1310
|
+
id: ID | typeof skeletonRowId;
|
|
1311
|
+
level?: number;
|
|
1312
|
+
parentId?: ID;
|
|
1313
|
+
cells: SciTableCellLike[];
|
|
1314
|
+
bindings: SciTableRowBindings;
|
|
634
1315
|
active: Signal<boolean>;
|
|
635
1316
|
selected: Signal<boolean>;
|
|
636
1317
|
hovered: Signal<boolean>;
|
|
1318
|
+
expanded: Signal<boolean>;
|
|
1319
|
+
hasChildren: Signal<boolean>;
|
|
637
1320
|
}
|
|
638
1321
|
interface SciStringCell {
|
|
639
1322
|
type: 'string';
|
|
@@ -645,16 +1328,16 @@ interface SciNumberCell {
|
|
|
645
1328
|
column: SciNumberColumn;
|
|
646
1329
|
value: Signal<number | undefined>;
|
|
647
1330
|
}
|
|
648
|
-
interface SciBooleanCell {
|
|
649
|
-
type: 'boolean';
|
|
650
|
-
column: SciBooleanColumn;
|
|
651
|
-
value: Signal<boolean | undefined>;
|
|
652
|
-
}
|
|
653
1331
|
interface SciDateCell {
|
|
654
1332
|
type: 'date';
|
|
655
1333
|
column: SciDateColumn;
|
|
656
1334
|
value: Signal<SciDateValue | undefined>;
|
|
657
1335
|
}
|
|
1336
|
+
interface SciEnumCell {
|
|
1337
|
+
type: 'enum';
|
|
1338
|
+
column: SciEnumColumn;
|
|
1339
|
+
value: Signal<SciEnumValue | undefined>;
|
|
1340
|
+
}
|
|
658
1341
|
interface SciComponentCell {
|
|
659
1342
|
type: 'component';
|
|
660
1343
|
column: SciComponentColumn;
|
|
@@ -665,15 +1348,25 @@ interface SciTemplateCell {
|
|
|
665
1348
|
column: SciTemplateColumn;
|
|
666
1349
|
template: SciTemplateDescriptor;
|
|
667
1350
|
}
|
|
668
|
-
type SciTableCellLike = SciStringCell | SciNumberCell |
|
|
1351
|
+
type SciTableCellLike = SciStringCell | SciNumberCell | SciDateCell | SciEnumCell | SciComponentCell | SciTemplateCell;
|
|
669
1352
|
interface SciTableCellContext<T = unknown, VALUE = unknown> {
|
|
670
1353
|
item: T;
|
|
671
1354
|
value: VALUE;
|
|
672
1355
|
}
|
|
1356
|
+
/**
|
|
1357
|
+
* Signature of a function to contribute row actions.
|
|
1358
|
+
*
|
|
1359
|
+
* Called per item with a {@link SciToolbarFactory} to contribute actions.
|
|
1360
|
+
*
|
|
1361
|
+
* The function:
|
|
1362
|
+
* - Runs in a reactive context and re-evaluates when tracked signals change.
|
|
1363
|
+
* - Can call `inject` to get required dependencies.
|
|
1364
|
+
*/
|
|
1365
|
+
type SciTableRowActionFactoryFn<T> = (toolbar: SciToolbarFactory, item: T, index: number) => void;
|
|
673
1366
|
/**
|
|
674
1367
|
* Represents an event emitted by {@link SciTableComponent}.
|
|
675
1368
|
*/
|
|
676
|
-
interface SciTableEvent<
|
|
1369
|
+
interface SciTableEvent<ID> {
|
|
677
1370
|
/**
|
|
678
1371
|
* The native browser event (`MouseEvent` or `KeyboardEvent`) that triggered the action.
|
|
679
1372
|
*/
|
|
@@ -681,191 +1374,329 @@ interface SciTableEvent<T> {
|
|
|
681
1374
|
/**
|
|
682
1375
|
* The items associated with the action.
|
|
683
1376
|
*/
|
|
684
|
-
items:
|
|
1377
|
+
items: ID[];
|
|
685
1378
|
}
|
|
686
1379
|
/**
|
|
687
|
-
* Represents
|
|
1380
|
+
* Represents the header of a table column, defined as a {@link Translatable} or an object with an optional icon, label, and tooltip.
|
|
1381
|
+
*
|
|
1382
|
+
* The label can be text or a translation key. A translation key starts with the percent symbol (`%`) and may include parameters in matrix notation for text interpolation.
|
|
1383
|
+
* SCION uses text providers to resolve translation keys. A text provider can be registered using {@link provideTextProvider}.
|
|
1384
|
+
*
|
|
1385
|
+
* SCION uses icon providers to render icons. An icon provider can be registered using {@link provideIconProvider}.
|
|
1386
|
+
*
|
|
1387
|
+
* Defaults to a Material icon provider if the application has not registered an icon provider, interpreting the icon as a Material Icon font ligature.
|
|
1388
|
+
* Refer to https://fonts.google.com/icons for available Material icons and instructions on including the Material icon font.
|
|
1389
|
+
*/
|
|
1390
|
+
type SciColumnHeaderLike = Translatable | {
|
|
1391
|
+
icon?: string;
|
|
1392
|
+
label?: Translatable;
|
|
1393
|
+
tooltip?: Translatable;
|
|
1394
|
+
};
|
|
1395
|
+
/**
|
|
1396
|
+
* An ISO 8601 date/time string, milliseconds since the UTC epoch, or a {@link Date} object.
|
|
688
1397
|
*/
|
|
689
1398
|
type SciDateLike = string | number | Date;
|
|
1399
|
+
/**
|
|
1400
|
+
* Supported data types for enumeration values used in an enum column.
|
|
1401
|
+
*/
|
|
1402
|
+
type SciEnumValueLike = string | number | boolean;
|
|
1403
|
+
/**
|
|
1404
|
+
* Defines the enumeration entries of an enum column.
|
|
1405
|
+
*
|
|
1406
|
+
* The array order determines the sort order of the enumeration.
|
|
1407
|
+
*
|
|
1408
|
+
* A label can be text or a translation key. A translation key starts with the percent symbol (`%`) and may include parameters in matrix notation for text interpolation.
|
|
1409
|
+
* SCION uses text providers to resolve translation keys. A text provider can be registered using {@link provideTextProvider}.
|
|
1410
|
+
*
|
|
1411
|
+
* SCION uses icon providers to render icons. An icon provider can be registered using {@link provideIconProvider}.
|
|
1412
|
+
* Defaults to a Material icon provider if the application has not registered an icon provider, interpreting the icon as a Material Icon font ligature.
|
|
1413
|
+
* Refer to https://fonts.google.com/icons for available Material icons and instructions on including the Material icon font.
|
|
1414
|
+
*/
|
|
1415
|
+
type SciEnumColumnValues = {
|
|
1416
|
+
value: SciEnumValueLike;
|
|
1417
|
+
label: Translatable;
|
|
1418
|
+
icon?: string;
|
|
1419
|
+
tooltip?: Translatable | null;
|
|
1420
|
+
}[];
|
|
1421
|
+
/**
|
|
1422
|
+
* Defines icons of an icon column.
|
|
1423
|
+
*
|
|
1424
|
+
* The array order determines the sort order.
|
|
1425
|
+
*
|
|
1426
|
+
* A label can be text or a translation key. A translation key starts with the percent symbol (`%`) and may include parameters in matrix notation for text interpolation.
|
|
1427
|
+
* SCION uses text providers to resolve translation keys. A text provider can be registered using {@link provideTextProvider}.
|
|
1428
|
+
*
|
|
1429
|
+
* SCION uses icon providers to render icons. An icon provider can be registered using {@link provideIconProvider}.
|
|
1430
|
+
* Defaults to a Material icon provider if the application has not registered an icon provider, interpreting the icon as a Material Icon font ligature.
|
|
1431
|
+
* Refer to https://fonts.google.com/icons for available Material icons and instructions on including the Material icon font.
|
|
1432
|
+
*/
|
|
1433
|
+
type SciIconColumnValues = {
|
|
1434
|
+
value: string | number | boolean;
|
|
1435
|
+
label: Translatable;
|
|
1436
|
+
icon: string;
|
|
1437
|
+
tooltip?: Translatable | null;
|
|
1438
|
+
}[];
|
|
690
1439
|
|
|
691
1440
|
type SciTableColumnFactoryFn<T> = (table: SciTableColumnFactory<T>) => void;
|
|
692
|
-
/**
|
|
1441
|
+
/**
|
|
1442
|
+
* Creates a table for displaying tabular or hierarchical data in {@link SciTableComponent}.
|
|
1443
|
+
*
|
|
1444
|
+
* Pass a descriptor to define the columns, datasource, and display options. Requires at minimum a datasource and columns.
|
|
1445
|
+
*
|
|
1446
|
+
* ```ts
|
|
1447
|
+
* import {table} from '@scion/components/table';
|
|
1448
|
+
* import {httpResource} from '@angular/common/http';
|
|
1449
|
+
*
|
|
1450
|
+
* const users = httpResource<User[]>(() => '/api/users', {defaultValue: []});
|
|
1451
|
+
*
|
|
1452
|
+
* const userTable = table({
|
|
1453
|
+
* datasource: users.value,
|
|
1454
|
+
* columns: table => table
|
|
1455
|
+
* .addStringColumn('Name', user => user.name)
|
|
1456
|
+
* .addBooleanColumn('Inactive', user => user.inactive)
|
|
1457
|
+
* .addDateColumn('Expiration', user => user.expiration),
|
|
1458
|
+
* });
|
|
1459
|
+
* ```
|
|
1460
|
+
*
|
|
1461
|
+
* In the HTML, bind the created table instance to `<sci-table>`.
|
|
1462
|
+
*
|
|
1463
|
+
* ```html
|
|
1464
|
+
* <sci-table name="table:users" [table]="userTable"/>
|
|
1465
|
+
* ```
|
|
1466
|
+
*
|
|
1467
|
+
* To display a tree structure, provide a hierarchical datasource via {@link provideTableDatasource}, passing a signal
|
|
1468
|
+
* containing the root items and a function that returns the children of a given item.
|
|
1469
|
+
*
|
|
1470
|
+
* ```ts
|
|
1471
|
+
* import {table, provideTableDatasource} from '@scion/components/table';
|
|
1472
|
+
* import {httpResource} from '@angular/common/http';
|
|
1473
|
+
*
|
|
1474
|
+
* const users = httpResource<User[]>(() => '/api/users', {defaultValue: []});
|
|
1475
|
+
*
|
|
1476
|
+
* const userTable = table({
|
|
1477
|
+
* datasource: provideTableDatasource(users.value, user => user.children),
|
|
1478
|
+
* columns: table => table
|
|
1479
|
+
* .addStringColumn('Name', user => user.name)
|
|
1480
|
+
* .addBooleanColumn('Inactive', user => user.inactive)
|
|
1481
|
+
* .addDateColumn('Expiration', user => user.expiration),
|
|
1482
|
+
* });
|
|
1483
|
+
* ```
|
|
1484
|
+
*
|
|
1485
|
+
* Callback functions:
|
|
1486
|
+
* - Run in a reactive context and re-evaluate when tracked signals change.
|
|
1487
|
+
* - Can call `inject` to get required dependencies. The injection context is destroyed each time the function is called anew.
|
|
1488
|
+
*
|
|
1489
|
+
* This function:
|
|
1490
|
+
* - Must be called within an injection context, or an explicit {@link Injector} passed.
|
|
1491
|
+
* - Must be called in a non-reactive (non-tracking) context.
|
|
1492
|
+
*
|
|
1493
|
+
* @see SciTableComponent
|
|
1494
|
+
* @experimental since 22.3.0; API and behavior may change in any version without notice.
|
|
1495
|
+
*
|
|
1496
|
+
* @param descriptor - Configures the table. Requires a datasource and columns.
|
|
1497
|
+
* @return Handle to bind to `<sci-table>` and interact with the table.
|
|
1498
|
+
*/
|
|
693
1499
|
declare function table<T>(descriptor: SciTableDescriptor<T>): SciTable<T>;
|
|
694
|
-
/**
|
|
1500
|
+
/**
|
|
1501
|
+
* Creates a table for displaying tabular or hierarchical data in {@link SciTableComponent}.
|
|
1502
|
+
*
|
|
1503
|
+
* Pass a descriptor to define the columns, datasource, and display options. Requires at minimum a datasource and columns.
|
|
1504
|
+
*
|
|
1505
|
+
* ```ts
|
|
1506
|
+
* import {table} from '@scion/components/table';
|
|
1507
|
+
* import {httpResource} from '@angular/common/http';
|
|
1508
|
+
*
|
|
1509
|
+
* const users = httpResource<User[]>(() => '/api/users', {defaultValue: []});
|
|
1510
|
+
*
|
|
1511
|
+
* const userTable = table({
|
|
1512
|
+
* datasource: users.value,
|
|
1513
|
+
* columns: table => table
|
|
1514
|
+
* .addStringColumn('Name', user => user.name)
|
|
1515
|
+
* .addBooleanColumn('Inactive', user => user.inactive)
|
|
1516
|
+
* .addDateColumn('Expiration', user => user.expiration),
|
|
1517
|
+
* });
|
|
1518
|
+
* ```
|
|
1519
|
+
*
|
|
1520
|
+
* In the HTML, bind the created table instance to `<sci-table>`.
|
|
1521
|
+
*
|
|
1522
|
+
* ```html
|
|
1523
|
+
* <sci-table name="table:users" [table]="userTable"/>
|
|
1524
|
+
* ```
|
|
1525
|
+
*
|
|
1526
|
+
* To display a tree structure, provide a hierarchical datasource via {@link provideTableDatasource}, passing a signal
|
|
1527
|
+
* containing the root items and a function that returns the children of a given item.
|
|
1528
|
+
*
|
|
1529
|
+
* ```ts
|
|
1530
|
+
* import {table, provideTableDatasource} from '@scion/components/table';
|
|
1531
|
+
* import {httpResource} from '@angular/common/http';
|
|
1532
|
+
*
|
|
1533
|
+
* const users = httpResource<User[]>(() => '/api/users', {defaultValue: []});
|
|
1534
|
+
*
|
|
1535
|
+
* const userTable = table({
|
|
1536
|
+
* datasource: provideTableDatasource(users.value, user => user.children),
|
|
1537
|
+
* columns: table => table
|
|
1538
|
+
* .addStringColumn('Name', user => user.name)
|
|
1539
|
+
* .addBooleanColumn('Inactive', user => user.inactive)
|
|
1540
|
+
* .addDateColumn('Expiration', user => user.expiration),
|
|
1541
|
+
* });
|
|
1542
|
+
* ```
|
|
1543
|
+
*
|
|
1544
|
+
* Callback functions:
|
|
1545
|
+
* - Run in a reactive context and re-evaluate when tracked signals change.
|
|
1546
|
+
* - Can call `inject` to get required dependencies. The injection context is destroyed each time the function is called anew.
|
|
1547
|
+
*
|
|
1548
|
+
* This function:
|
|
1549
|
+
* - Must be called within an injection context, or an explicit {@link Injector} passed.
|
|
1550
|
+
* - Must be called in a non-reactive (non-tracking) context.
|
|
1551
|
+
*
|
|
1552
|
+
* @see SciTableComponent
|
|
1553
|
+
* @experimental since 22.3.0; API and behavior may change in any version without notice.
|
|
1554
|
+
*
|
|
1555
|
+
* @param descriptor - Configures the table. Requires a datasource and columns.
|
|
1556
|
+
* @return Handle to bind to `<sci-table>` and interact with the table.
|
|
1557
|
+
*/
|
|
1558
|
+
declare function table<T, ID>(descriptor: SciTableDescriptor<T, ID> & {
|
|
1559
|
+
trackBy: (item: T) => ID;
|
|
1560
|
+
}): SciTable<ID>;
|
|
1561
|
+
/**
|
|
1562
|
+
* Creates a table for displaying tabular data in {@link SciTableComponent}.
|
|
1563
|
+
*
|
|
1564
|
+
* Pass a signal containing the items to display in the table and a factory function to define the columns.
|
|
1565
|
+
* The table calls the passed function with a factory that has methods for adding columns to the table.
|
|
1566
|
+
*
|
|
1567
|
+
* NOTE: This function is a shorthand for creating a table directly from data and columns; pass a descriptor instead to display a tree structure, configure a custom datasource, or set additional options.
|
|
1568
|
+
*
|
|
1569
|
+
* ```ts
|
|
1570
|
+
* import {SciTableComponent, table} from '@scion/components/table';
|
|
1571
|
+
* import {httpResource} from '@angular/common/http';
|
|
1572
|
+
*
|
|
1573
|
+
* // Load data to display in the table.
|
|
1574
|
+
* const users = httpResource<User[]>(() => '/api/users', {defaultValue: []});
|
|
1575
|
+
*
|
|
1576
|
+
* // Create the table and pass data.
|
|
1577
|
+
* const userTable = table(users.value, table => table
|
|
1578
|
+
* .addStringColumn('Name', user => user.name)
|
|
1579
|
+
* .addBooleanColumn('Inactive', user => user.inactive)
|
|
1580
|
+
* .addDateColumn('Expiration', user => user.expiration),
|
|
1581
|
+
* );
|
|
1582
|
+
* ```
|
|
1583
|
+
*
|
|
1584
|
+
* In the HTML, bind the created table instance to `<sci-table>`.
|
|
1585
|
+
*
|
|
1586
|
+
* ```html
|
|
1587
|
+
* <sci-table name="table:users" [table]="userTable"/>
|
|
1588
|
+
* ```
|
|
1589
|
+
*
|
|
1590
|
+
* Callback functions:
|
|
1591
|
+
* - Run in a reactive context and re-evaluate when tracked signals change.
|
|
1592
|
+
* - Can call `inject` to get required dependencies. The injection context is destroyed each time the function is called anew.
|
|
1593
|
+
*
|
|
1594
|
+
* This function:
|
|
1595
|
+
* - Must be called within an injection context, or an explicit {@link Injector} passed.
|
|
1596
|
+
* - Must be called in a non-reactive (non-tracking) context.
|
|
1597
|
+
*
|
|
1598
|
+
* @see SciTableComponent
|
|
1599
|
+
* @experimental since 22.3.0; API and behavior may change in any version without notice.
|
|
1600
|
+
*
|
|
1601
|
+
* @param data - Specifies items to display in the table.
|
|
1602
|
+
* @param columnFactoryFn - Specifies a factory function to add columns to the table.
|
|
1603
|
+
* @param options - Controls table creation.
|
|
1604
|
+
* @param options.injector - Injector used to create the table. Defaults to the current injection context. The table is disposed when the passed injector is destroyed.
|
|
1605
|
+
* @return Handle to bind to `<sci-table>` and interact with the table.
|
|
1606
|
+
*/
|
|
695
1607
|
declare function table<T>(data: Signal<T[]>, columnFactoryFn: SciTableColumnFactoryFn<T>, options?: {
|
|
696
1608
|
injector?: Injector;
|
|
697
1609
|
}): SciTable<T>;
|
|
698
1610
|
|
|
699
|
-
declare class
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
readonly
|
|
703
|
-
readonly columns: Signal<SciTableColumnLike<T>[]>;
|
|
704
|
-
readonly rowActions?: SciTableRowActionFactoryFn<T>;
|
|
705
|
-
private readonly _rowBindings;
|
|
706
|
-
private readonly _dataLoaderFn;
|
|
707
|
-
private readonly _trackBy?;
|
|
708
|
-
readonly tableViewRef: WritableSignal<SciTableViewRef | undefined>;
|
|
709
|
-
readonly userSettings: WritableSignal<SciTableUserSettings>;
|
|
710
|
-
readonly bufferSize: number;
|
|
711
|
-
readonly pageSize: number;
|
|
712
|
-
readonly filterable: WritableSignal<boolean>;
|
|
713
|
-
readonly showHeader: WritableSignal<boolean>;
|
|
714
|
-
readonly wrapHeader: WritableSignal<boolean>;
|
|
715
|
-
readonly sortable: WritableSignal<boolean>;
|
|
716
|
-
readonly resizable: WritableSignal<boolean>;
|
|
717
|
-
readonly selectable: WritableSignal<'single' | 'multi' | false>;
|
|
718
|
-
readonly scrollRange: Signal<SciScrollRange | undefined>;
|
|
719
|
-
readonly scrollTop: Signal<number>;
|
|
720
|
-
readonly virtualScrollOffset: Signal<{
|
|
721
|
-
top: number;
|
|
722
|
-
bottom: number;
|
|
723
|
-
}>;
|
|
724
|
-
readonly viewportPageSize: Signal<number>;
|
|
725
|
-
readonly scrolling: Signal<boolean>;
|
|
726
|
-
readonly resizing: Signal<boolean>;
|
|
727
|
-
readonly sortCriteria: WritableSignal<SciTableSortCriterion[]>;
|
|
728
|
-
readonly filterCriteria: WritableSignal<SciTableColumnFilter[]>;
|
|
729
|
-
private readonly _cache;
|
|
730
|
-
private readonly _tableCellValuePreloader;
|
|
731
|
-
private readonly _tableFilter;
|
|
732
|
-
private readonly _selectedItems;
|
|
733
|
-
readonly totalCount: WritableSignal<number | undefined>;
|
|
734
|
-
readonly activeItem: WritableSignal<T | undefined>;
|
|
735
|
-
readonly hoveredIndex: WritableSignal<number>;
|
|
736
|
-
readonly criteria: Signal<{
|
|
737
|
-
sort: SciTableSortCriterion[];
|
|
738
|
-
filter: SciTableColumnFilter[];
|
|
739
|
-
tableFilter: string | null;
|
|
740
|
-
}>;
|
|
741
|
-
readonly loading: Signal<boolean>;
|
|
742
|
-
readonly error: Signal<Error | undefined>;
|
|
743
|
-
readonly activeRow: Signal<SciTableRow<T> | undefined>;
|
|
744
|
-
readonly hoveredRow: Signal<SciTableRow<T> | undefined>;
|
|
745
|
-
readonly selectedItems: Signal<T[]>;
|
|
746
|
-
readonly selectedIds: Signal<Set<unknown>>;
|
|
747
|
-
readonly rowsByIndex: Signal<Map<number, SciTableRow<T>>>;
|
|
748
|
-
readonly rows: Signal<SciTableRow<T>[]>;
|
|
749
|
-
constructor(descriptor: SciTableDescriptor<T>);
|
|
750
|
-
/**
|
|
751
|
-
* Connects {@link SciTableComponent} to the model.
|
|
752
|
-
*/
|
|
753
|
-
connect(name: `table:${string}`, viewRef: SciTableViewRef): void;
|
|
754
|
-
disconnect(): void;
|
|
755
|
-
private computeColumns;
|
|
756
|
-
/**
|
|
757
|
-
* Computes the rows currently visible in the viewport (+buffer).
|
|
758
|
-
*/
|
|
759
|
-
private computeRows;
|
|
760
|
-
/**
|
|
761
|
-
* Computes the visible row count based on the viewport size.
|
|
762
|
-
*/
|
|
763
|
-
private computeScrollRange;
|
|
764
|
-
private computeVirtualScrollOffset;
|
|
765
|
-
private computeViewportPageSize;
|
|
766
|
-
/**
|
|
767
|
-
* Tracks {@link HTMLElement.scrollTop} of the viewport.
|
|
768
|
-
*/
|
|
769
|
-
private computeScrollTop;
|
|
770
|
-
/**
|
|
771
|
-
* Tracks whether currently scrolling the viewport.
|
|
772
|
-
*/
|
|
773
|
-
private computeScrolling;
|
|
774
|
-
/**
|
|
775
|
-
* Loads a range of rows, based on the current sort and filter criteria, into the cache.
|
|
776
|
-
*/
|
|
777
|
-
loadRange(start: number, end: number): Promise<void>;
|
|
778
|
-
/**
|
|
779
|
-
* Loads the requested page from the cache or datasource and returns its loading state with a cancelation handler.
|
|
780
|
-
*/
|
|
781
|
-
private loadPage;
|
|
782
|
-
/**
|
|
783
|
-
* Toggles sort on a column. ASC -> DESC -> No sort
|
|
784
|
-
*
|
|
785
|
-
* TODO [ego] Revisit API, do we really want a three-state and implicit toggling logic?
|
|
786
|
-
*/
|
|
787
|
-
sort(columnName: `column:${string}`, multi: boolean): void;
|
|
788
|
-
/**
|
|
789
|
-
* Applies a filter, either via global filter or on a specific column.
|
|
790
|
-
*/
|
|
791
|
-
filter(text: string | null): void;
|
|
792
|
-
filter(text: string | number | boolean | null, options: {
|
|
793
|
-
columnName: `column:${string}`;
|
|
794
|
-
}): void;
|
|
795
|
-
updateSelectedItems(updateFn: (ids: Map<unknown, T>) => Map<unknown, T>): void;
|
|
796
|
-
/**
|
|
797
|
-
* Indicates whether the built-in array datasource is used.
|
|
798
|
-
*
|
|
799
|
-
* Supports out-of-the-box filtering and sorting for built-in table columns.
|
|
800
|
-
*/
|
|
801
|
-
isArrayDatasource(): boolean;
|
|
802
|
-
reset(): void;
|
|
803
|
-
dispose(): void;
|
|
804
|
-
/**
|
|
805
|
-
* Loads a set of pages on criteria or viewport changes.
|
|
806
|
-
*/
|
|
807
|
-
private installPageLoader;
|
|
808
|
-
/**
|
|
809
|
-
* Resets cache on criteria changes.
|
|
810
|
-
*/
|
|
811
|
-
private installCriteriaWatcher;
|
|
812
|
-
private mapItemsToRow;
|
|
813
|
-
/**
|
|
814
|
-
* Creates a signal to read and write table user settings.
|
|
815
|
-
*/
|
|
816
|
-
private computeUserSettings;
|
|
817
|
-
/**
|
|
818
|
-
* Call trackBy function or fallback to track by object reference.
|
|
819
|
-
*/
|
|
820
|
-
trackBy(item: T): unknown;
|
|
821
|
-
private computeActiveRow;
|
|
822
|
-
}
|
|
823
|
-
interface SciScrollRange {
|
|
824
|
-
/** incluse */
|
|
825
|
-
start: number;
|
|
826
|
-
/** exclusive */
|
|
827
|
-
end: number;
|
|
828
|
-
}
|
|
829
|
-
interface SciTableUserSettings {
|
|
830
|
-
columns?: {
|
|
831
|
-
name: string;
|
|
832
|
-
width?: number;
|
|
833
|
-
}[];
|
|
834
|
-
}
|
|
835
|
-
interface SciTableViewRef {
|
|
836
|
-
viewport: HTMLElement;
|
|
837
|
-
viewportHeight: Signal<number>;
|
|
838
|
-
viewportWidth: Signal<number>;
|
|
839
|
-
viewportClientHeight: Signal<number>;
|
|
840
|
-
viewportClientWidth: Signal<number>;
|
|
841
|
-
headerHeight: Signal<number>;
|
|
842
|
-
cellPadding: Signal<number>;
|
|
843
|
-
itemHeight: Signal<number>;
|
|
844
|
-
scrollToTop: () => void;
|
|
845
|
-
}
|
|
846
|
-
|
|
847
|
-
declare class SciTableRowComponent<T> {
|
|
848
|
-
readonly row: _angular_core.InputSignal<SciTableRow<T>>;
|
|
849
|
-
readonly primaryAction: _angular_core.OutputEmitterRef<SciTableEvent<T>>;
|
|
850
|
-
protected readonly table: _angular_core.Signal<ɵSciTable<unknown>>;
|
|
851
|
-
protected readonly rowActionToolbar: _angular_core.Signal<SciToolbarComponent | undefined>;
|
|
852
|
-
protected readonly rowActionsToolbarName: `toolbar:${string}`;
|
|
1611
|
+
declare class SciTableRowComponent<T, ID> {
|
|
1612
|
+
readonly row: _angular_core.InputSignal<SciTableRow<T, ID>>;
|
|
1613
|
+
readonly primaryAction: _angular_core.OutputEmitterRef<SciTableEvent<ID>>;
|
|
1614
|
+
protected readonly table: Signal<ɵSciTable<T, ID>>;
|
|
853
1615
|
private readonly _selectionService;
|
|
1616
|
+
protected readonly rowActionToolbar: Signal<SciToolbarComponent | undefined>;
|
|
1617
|
+
protected readonly rowActionsToolbarName: `toolbar:${string}`;
|
|
854
1618
|
constructor();
|
|
855
1619
|
protected onRowClick(event: PointerEvent): void;
|
|
856
1620
|
protected onRowDblClick(event: MouseEvent): void;
|
|
857
1621
|
protected onRowMouseEnter(): void;
|
|
858
1622
|
protected onRowMouseLeave(event: MouseEvent): void;
|
|
859
1623
|
protected onActionToolbarClick(event: PointerEvent): void;
|
|
1624
|
+
protected onTreeNodeHandle(event: PointerEvent): void;
|
|
860
1625
|
private contributeRowActions;
|
|
861
|
-
static ɵfac: _angular_core.ɵɵFactoryDeclaration<SciTableRowComponent<any>, never>;
|
|
862
|
-
static ɵcmp: _angular_core.ɵɵComponentDeclaration<SciTableRowComponent<any>, "sci-table-row", never, { "row": { "alias": "row"; "required": true; "isSignal": true; }; }, { "primaryAction": "primaryAction"; }, never, never, true, never>;
|
|
1626
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<SciTableRowComponent<any, any>, never>;
|
|
1627
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<SciTableRowComponent<any, any>, "sci-table-row", never, { "row": { "alias": "row"; "required": true; "isSignal": true; }; }, { "primaryAction": "primaryAction"; }, never, never, true, never>;
|
|
863
1628
|
}
|
|
864
1629
|
|
|
865
1630
|
/**
|
|
1631
|
+
* Provides a table to display tabular or hierarchical data.
|
|
1632
|
+
*
|
|
1633
|
+
* ### Usage
|
|
1634
|
+
*
|
|
1635
|
+
* Create a table using the `table()` function, passing a signal containing the items to display in the table and a factory function to define the columns.
|
|
1636
|
+
* Alternatively, pass a descriptor to display a tree structure, configure a custom datasource, or set additional options.
|
|
1637
|
+
*
|
|
1638
|
+
* ```ts
|
|
1639
|
+
* import {SciTableComponent, table} from '@scion/components/table';
|
|
1640
|
+
* import {httpResource} from '@angular/common/http';
|
|
1641
|
+
*
|
|
1642
|
+
* // Load data to display in the table.
|
|
1643
|
+
* const users = httpResource<User[]>(() => '/api/users', {defaultValue: []});
|
|
1644
|
+
*
|
|
1645
|
+
* // Create the table and pass data.
|
|
1646
|
+
* const userTable = table(users.value, table => table
|
|
1647
|
+
* .addNumberColumn('ID', user => user.id)
|
|
1648
|
+
* .addStringColumn('Name', user => user.name)
|
|
1649
|
+
* .addBooleanColumn('Inactive', user => user.inactive)
|
|
1650
|
+
* .addDateColumn('Expiration', user => user.expiration),
|
|
1651
|
+
* );
|
|
1652
|
+
* ```
|
|
1653
|
+
*
|
|
1654
|
+
* In the HTML, bind the created table instance to `<sci-table>` and assign it a name.
|
|
1655
|
+
* The name must start with the `table:` prefix and is used to store user settings.
|
|
1656
|
+
*
|
|
1657
|
+
* ```html
|
|
1658
|
+
* <sci-table name="table:users" [table]="userTable"/>
|
|
1659
|
+
* ```
|
|
1660
|
+
*
|
|
1661
|
+
* ### Fixed Row Height
|
|
1662
|
+
*
|
|
1663
|
+
* All rows in the table must have equal height, which is `2em` by default. The height can be changed per table using the CSS variable `--sci-table-row-height`.
|
|
1664
|
+
*
|
|
1665
|
+
* ```scss
|
|
1666
|
+
* sci-table {
|
|
1667
|
+
* --sci-table-row-height: 30px;
|
|
1668
|
+
* }
|
|
1669
|
+
* ```
|
|
1670
|
+
*
|
|
1671
|
+
* ### Styling
|
|
1672
|
+
*
|
|
1673
|
+
* The appearance of the table can be customized using the following CSS variables, either globally in the `:root` or at the table level.
|
|
1674
|
+
*
|
|
1675
|
+
* - `--sci-table-gridline-color`
|
|
1676
|
+
* - `--sci-table-header-height`
|
|
1677
|
+
* - `--sci-table-header-cursor`
|
|
1678
|
+
* - `--sci-table-header-background-color`
|
|
1679
|
+
* - `--sci-table-header-background-color-hover`
|
|
1680
|
+
* - `--sci-table-header-font-family`
|
|
1681
|
+
* - `--sci-table-header-font-size`
|
|
1682
|
+
* - `--sci-table-header-font-weight`
|
|
1683
|
+
* - `--sci-table-header-text-color`
|
|
1684
|
+
* - `--sci-table-header-column-divider`
|
|
1685
|
+
* - `--sci-table-row-height`
|
|
1686
|
+
* - `--sci-table-row-indent`
|
|
1687
|
+
* - `--sci-table-row-background-color-hover`
|
|
1688
|
+
* - `--sci-table-row-background-color-selected`
|
|
1689
|
+
* - `--sci-table-row-border-radius`
|
|
1690
|
+
* - `--sci-table-row-outline-color`
|
|
1691
|
+
* - `--sci-table-row-outline-width`
|
|
1692
|
+
* - `--sci-table-row-outline-style`
|
|
1693
|
+
* - `--sci-table-row-action-background-color`
|
|
1694
|
+
* - `--sci-table-row-action-background-color-selected`
|
|
1695
|
+
* - `--sci-table-cell-padding-inline`
|
|
1696
|
+
*
|
|
866
1697
|
* @experimental since 22.3.0; API and behavior may change in any version without notice.
|
|
867
1698
|
*/
|
|
868
|
-
declare class SciTableComponent<T = unknown> {
|
|
1699
|
+
declare class SciTableComponent<T = unknown, ID = T> {
|
|
869
1700
|
/**
|
|
870
1701
|
* Specifies a unique table identifier, used as the key for storing user preferences.
|
|
871
1702
|
*/
|
|
@@ -873,45 +1704,26 @@ declare class SciTableComponent<T = unknown> {
|
|
|
873
1704
|
/**
|
|
874
1705
|
* Specifies the table definition and datasource.
|
|
875
1706
|
*/
|
|
876
|
-
readonly table: _angular_core.InputSignalWithTransform<ɵSciTable<T>, SciTable<
|
|
1707
|
+
readonly table: _angular_core.InputSignalWithTransform<ɵSciTable<T, ID>, SciTable<ID>>;
|
|
877
1708
|
/**
|
|
878
1709
|
* Emits when the user double-clicks a row or presses `Enter` on selected rows.
|
|
879
1710
|
*/
|
|
880
|
-
readonly primaryAction: _angular_core.OutputEmitterRef<SciTableEvent<
|
|
1711
|
+
readonly primaryAction: _angular_core.OutputEmitterRef<SciTableEvent<ID>>;
|
|
881
1712
|
private readonly _viewport;
|
|
882
1713
|
private readonly _viewportClient;
|
|
883
1714
|
private readonly _tableHeader;
|
|
884
1715
|
private readonly _tableBody;
|
|
885
1716
|
private readonly _itemSizeSyntheticElement;
|
|
886
1717
|
private readonly _cellPaddingSyntheticElement;
|
|
887
|
-
protected readonly rows: _angular_core.Signal<readonly SciTableRowComponent<any>[]>;
|
|
1718
|
+
protected readonly rows: _angular_core.Signal<readonly SciTableRowComponent<any, any>[]>;
|
|
888
1719
|
constructor();
|
|
889
|
-
protected onRowPrimaryAction(event: SciTableEvent<
|
|
1720
|
+
protected onRowPrimaryAction(event: SciTableEvent<ID>): void;
|
|
890
1721
|
protected onRetry(): void;
|
|
891
1722
|
private connectToModel;
|
|
892
1723
|
private scrollActiveRowIntoViewport;
|
|
893
|
-
static ɵfac: _angular_core.ɵɵFactoryDeclaration<SciTableComponent<any>, never>;
|
|
894
|
-
static ɵcmp: _angular_core.ɵɵComponentDeclaration<SciTableComponent<any>, "sci-table", never, { "name": { "alias": "name"; "required": true; "isSignal": true; }; "table": { "alias": "table"; "required": true; "isSignal": true; }; }, { "primaryAction": "primaryAction"; }, never, never, true, never>;
|
|
895
|
-
}
|
|
896
|
-
|
|
897
|
-
/**
|
|
898
|
-
* Provides persistent storage for the sci-table.
|
|
899
|
-
*/
|
|
900
|
-
interface SciTableStorage {
|
|
901
|
-
/**
|
|
902
|
-
* Method invoked to load a value from persisted storage.
|
|
903
|
-
*/
|
|
904
|
-
load(name: `scion.components.table:${string}`): Promise<string | null> | string | null;
|
|
905
|
-
/**
|
|
906
|
-
* Method invoked to write a value to persisted storage.
|
|
907
|
-
*/
|
|
908
|
-
store(name: `scion.components.table:${string}`, value: string): Promise<void> | void;
|
|
1724
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<SciTableComponent<any, any>, never>;
|
|
1725
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<SciTableComponent<any, any>, "sci-table", never, { "name": { "alias": "name"; "required": true; "isSignal": true; }; "table": { "alias": "table"; "required": true; "isSignal": true; }; }, { "primaryAction": "primaryAction"; }, never, never, true, never>;
|
|
909
1726
|
}
|
|
910
|
-
/**
|
|
911
|
-
* Defaults to localStorage persistence.
|
|
912
|
-
* @param storage
|
|
913
|
-
*/
|
|
914
|
-
declare function provideTableStorage(storage: Type<SciTableStorage>): EnvironmentProviders;
|
|
915
1727
|
|
|
916
|
-
export { SciTableComponent,
|
|
917
|
-
export type { SciBooleanColumnDescriptor, SciComponentColumnDescriptor, SciDateColumnDescriptor, SciDateLike, SciNumberColumnDescriptor, SciStringColumnDescriptor, SciTable, SciTableCellContext, SciTableColumnDescriptor, SciTableColumnFactory, SciTableColumnFactoryFn, SciTableColumnFilter, SciTableColumnFilterMatcherFn, SciTableColumnSortComparatorFn, SciTableColumnType,
|
|
1728
|
+
export { SciTableComponent, provideTableDatasource, provideTableRowBinding, table, ɵSciTable, ɵSciTableRowBindingFactory, ɵprovideTableDatasource };
|
|
1729
|
+
export type { SciBooleanColumnDescriptor, SciColumnHeaderLike, SciComponentColumnDescriptor, SciDateColumnDescriptor, SciDateLike, SciEnumColumnValues, SciEnumValueLike, SciIconColumnValues, SciNumberColumnDescriptor, SciStringColumnDescriptor, SciTable, SciTableCellContext, SciTableColumnDescriptor, SciTableColumnFactory, SciTableColumnFactoryFn, SciTableColumnFilter, SciTableColumnFilterMatcherFn, SciTableColumnSortComparatorFn, SciTableColumnType, SciTableDatasource, SciTableDatasourceProvider, SciTableDatasourceQuery, SciTableDescriptor, SciTableEvent, SciTableRowActionFactoryFn, SciTableRowBindingFactory, SciTableSortCriterion, SciTemplateColumnDescriptor, SciTreeTableDatasource, SciTreeTableNode };
|