@scion/components 22.6.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/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 +25 -2
- package/fesm2022/scion-components-common.mjs.map +1 -1
- package/fesm2022/scion-components-table.mjs +1202 -859
- package/fesm2022/scion-components-table.mjs.map +1 -1
- package/fesm2022/scion-components-tree.mjs +306 -0
- package/fesm2022/scion-components-tree.mjs.map +1 -0
- package/package.json +6 -2
- package/tree/package.json +4 -0
- package/types/scion-components-common.d.ts +22 -2
- package/types/scion-components-table.d.ts +686 -255
- package/types/scion-components-tree.d.ts +559 -0
|
@@ -1,12 +1,243 @@
|
|
|
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
243
|
text: string | number | boolean | SciEnumValueLike | SciEnumValueLike[];
|
|
@@ -15,37 +246,15 @@ 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
|
}
|
|
37
|
-
/**
|
|
38
|
-
* @docs-private Not public API. For internal use only.
|
|
39
|
-
* @experimental since 22.3.0; API and behavior may change in any version without notice.
|
|
40
|
-
*/
|
|
41
|
-
type SciTableDataLoaderFn<T> = (request: SciTablePageRequest) => MaybeAsync<SciTablePageResponse<T>>;
|
|
42
|
-
/**
|
|
43
|
-
* TODO [table] Remove after datasource is final.
|
|
44
|
-
*
|
|
45
|
-
* @docs-private Not public API. For internal use only.
|
|
46
|
-
* @experimental since 22.3.0; API and behavior may change in any version without notice.
|
|
47
|
-
*/
|
|
48
|
-
declare function ɵillegaldatasource<T>(): Signal<T[]>;
|
|
49
258
|
|
|
50
259
|
/**
|
|
51
260
|
* Provides row bindings to tables in the scope of the injector providing the bindings.
|
|
@@ -136,15 +345,43 @@ interface SciTableRowBindingFactory {
|
|
|
136
345
|
*/
|
|
137
346
|
addClassBinding(name: string | undefined): this;
|
|
138
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;
|
|
357
|
+
}
|
|
139
358
|
interface SciTableRowBindings {
|
|
140
359
|
icons: Signal<string[]>;
|
|
141
|
-
parts: Signal
|
|
360
|
+
parts: Signal<string[]>;
|
|
142
361
|
attributes: Signal<{
|
|
143
362
|
[name: string]: unknown;
|
|
144
363
|
}>;
|
|
145
364
|
classes: Signal<string[]>;
|
|
146
365
|
}
|
|
147
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;
|
|
383
|
+
}
|
|
384
|
+
|
|
148
385
|
interface SciTableColumnFactory<T> {
|
|
149
386
|
/**
|
|
150
387
|
* Adds a column to the table for displaying text.
|
|
@@ -631,7 +868,7 @@ interface SciEnumColumnDescriptor<T = unknown> extends SciTableColumnDescriptor
|
|
|
631
868
|
/**
|
|
632
869
|
* Configures the display of enumeration values.
|
|
633
870
|
*
|
|
634
|
-
* Defaults to displaying the label in cells, and both icon and label in the column filter menu. Defaults are unset
|
|
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.
|
|
635
872
|
*/
|
|
636
873
|
format?: {
|
|
637
874
|
/**
|
|
@@ -735,24 +972,6 @@ type SciTableColumnSortComparatorFn<T = unknown, VALUE = unknown> = (a: SciTable
|
|
|
735
972
|
*/
|
|
736
973
|
type SciTableColumnFilterMatcherFn<T = unknown, VALUE = unknown, FILTER = VALUE> = (filter: FILTER, context: SciTableCellContext<T, VALUE>) => boolean;
|
|
737
974
|
|
|
738
|
-
/**
|
|
739
|
-
* Represents the internal value of {@link SciDateColumn}.
|
|
740
|
-
*/
|
|
741
|
-
interface SciDateValue {
|
|
742
|
-
/**
|
|
743
|
-
* Full ISO 8601 date/time string.
|
|
744
|
-
*/
|
|
745
|
-
isoString: string;
|
|
746
|
-
/**
|
|
747
|
-
* Milliseconds since UTC epoch.
|
|
748
|
-
*/
|
|
749
|
-
millis: number;
|
|
750
|
-
/**
|
|
751
|
-
* Human-readable formatted date and time string.
|
|
752
|
-
*/
|
|
753
|
-
formatted: string;
|
|
754
|
-
}
|
|
755
|
-
|
|
756
975
|
/**
|
|
757
976
|
* Represents the internal value of {@link SciEnumColumn}.
|
|
758
977
|
*/
|
|
@@ -769,21 +988,97 @@ interface SciEnumValue {
|
|
|
769
988
|
* Represents supported column types of {@link SciTableComponent}.
|
|
770
989
|
*/
|
|
771
990
|
type SciTableColumnType = 'string' | 'number' | 'boolean' | 'date' | 'icon' | 'enum' | 'component' | 'template';
|
|
772
|
-
|
|
773
|
-
|
|
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> {
|
|
997
|
+
/**
|
|
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
|
|
1032
|
+
*/
|
|
1033
|
+
datasource: Signal<T[]> | SciTableDatasourceProvider<T, ID>;
|
|
774
1034
|
/**
|
|
775
|
-
*
|
|
776
|
-
*
|
|
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.
|
|
777
1052
|
*/
|
|
778
|
-
ɵdatasource?: Signal<T[]> | SciTableDataLoaderFn<T>;
|
|
779
1053
|
columns: SciTableColumnFactoryFn<T>;
|
|
1054
|
+
/**
|
|
1055
|
+
* Controls whether the user can sort rows by clicking column headers. Defaults to `true`.
|
|
1056
|
+
*/
|
|
780
1057
|
sortable?: boolean;
|
|
1058
|
+
/**
|
|
1059
|
+
* Controls whether the user can resize columns. Defaults to `true`.
|
|
1060
|
+
*/
|
|
781
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
|
+
*/
|
|
782
1067
|
filterable?: boolean;
|
|
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
|
+
*/
|
|
783
1073
|
selectable?: 'single' | 'multi' | false;
|
|
1074
|
+
/**
|
|
1075
|
+
* Controls whether column headers are displayed. Defaults to `true`.
|
|
1076
|
+
*/
|
|
784
1077
|
showHeader?: boolean;
|
|
785
1078
|
/**
|
|
786
|
-
* 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.
|
|
787
1082
|
*/
|
|
788
1083
|
wrapHeader?: boolean;
|
|
789
1084
|
/**
|
|
@@ -855,28 +1150,97 @@ interface SciTableDescriptor<T> {
|
|
|
855
1150
|
* Specifies the number of items to load per page. Defaults to 50.
|
|
856
1151
|
*/
|
|
857
1152
|
pageSize?: number;
|
|
858
|
-
|
|
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
|
+
*/
|
|
859
1163
|
injector?: Injector;
|
|
860
1164
|
}
|
|
861
|
-
|
|
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>;
|
|
862
1181
|
/**
|
|
863
|
-
*
|
|
1182
|
+
* Provides the selected items.
|
|
864
1183
|
*/
|
|
865
|
-
readonly
|
|
1184
|
+
readonly selectedItems: Signal<Array<ID>>;
|
|
866
1185
|
/**
|
|
867
|
-
*
|
|
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}.
|
|
868
1190
|
*/
|
|
869
|
-
readonly selectedItems: Signal<Array<T>>;
|
|
870
1191
|
readonly filterable: WritableSignal<boolean>;
|
|
1192
|
+
/**
|
|
1193
|
+
* Controls whether column headers are displayed.
|
|
1194
|
+
*
|
|
1195
|
+
* Initialized from {@link SciTableDescriptor.showHeader}. Defaults to `true`.
|
|
1196
|
+
*/
|
|
871
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
|
+
*/
|
|
872
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
|
+
*/
|
|
873
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
|
+
*/
|
|
874
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
|
+
*/
|
|
875
1223
|
readonly selectable: WritableSignal<'single' | 'multi' | false>;
|
|
876
1224
|
/**
|
|
877
1225
|
* Filters items cross-column, ignoring {@link SciTableDescriptor.filterable} and {@link SciTableColumnDescriptor.filterable} settings.
|
|
878
1226
|
*/
|
|
879
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;
|
|
880
1244
|
}
|
|
881
1245
|
interface SciTableColumn<T = unknown, VALUE = unknown, FILTER = VALUE> {
|
|
882
1246
|
type: SciTableColumnType;
|
|
@@ -936,19 +1300,23 @@ interface SciTemplateColumn<T = unknown> extends SciTableColumn<T, void, string>
|
|
|
936
1300
|
template: (item: T) => SciTemplateDescriptor;
|
|
937
1301
|
}
|
|
938
1302
|
type SciTableColumnLike<T = unknown> = SciStringColumn<T> | SciNumberColumn<T> | SciDateColumn<T> | SciEnumColumn<T> | SciComponentColumn<T> | SciTemplateColumn<T>;
|
|
1303
|
+
declare const skeletonRowId: unique symbol;
|
|
939
1304
|
/**
|
|
940
1305
|
* Mapped row, used as display state.
|
|
941
1306
|
*/
|
|
942
|
-
interface SciTableRow<T> {
|
|
1307
|
+
interface SciTableRow<T, ID> {
|
|
943
1308
|
index: number;
|
|
944
|
-
item
|
|
945
|
-
id
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
1309
|
+
item: T;
|
|
1310
|
+
id: ID | typeof skeletonRowId;
|
|
1311
|
+
level?: number;
|
|
1312
|
+
parentId?: ID;
|
|
1313
|
+
cells: SciTableCellLike[];
|
|
1314
|
+
bindings: SciTableRowBindings;
|
|
949
1315
|
active: Signal<boolean>;
|
|
950
1316
|
selected: Signal<boolean>;
|
|
951
1317
|
hovered: Signal<boolean>;
|
|
1318
|
+
expanded: Signal<boolean>;
|
|
1319
|
+
hasChildren: Signal<boolean>;
|
|
952
1320
|
}
|
|
953
1321
|
interface SciStringCell {
|
|
954
1322
|
type: 'string';
|
|
@@ -998,7 +1366,7 @@ type SciTableRowActionFactoryFn<T> = (toolbar: SciToolbarFactory, item: T, index
|
|
|
998
1366
|
/**
|
|
999
1367
|
* Represents an event emitted by {@link SciTableComponent}.
|
|
1000
1368
|
*/
|
|
1001
|
-
interface SciTableEvent<
|
|
1369
|
+
interface SciTableEvent<ID> {
|
|
1002
1370
|
/**
|
|
1003
1371
|
* The native browser event (`MouseEvent` or `KeyboardEvent`) that triggered the action.
|
|
1004
1372
|
*/
|
|
@@ -1006,7 +1374,7 @@ interface SciTableEvent<T> {
|
|
|
1006
1374
|
/**
|
|
1007
1375
|
* The items associated with the action.
|
|
1008
1376
|
*/
|
|
1009
|
-
items:
|
|
1377
|
+
items: ID[];
|
|
1010
1378
|
}
|
|
1011
1379
|
/**
|
|
1012
1380
|
* Represents the header of a table column, defined as a {@link Translatable} or an object with an optional icon, label, and tooltip.
|
|
@@ -1070,183 +1438,265 @@ type SciIconColumnValues = {
|
|
|
1070
1438
|
}[];
|
|
1071
1439
|
|
|
1072
1440
|
type SciTableColumnFactoryFn<T> = (table: SciTableColumnFactory<T>) => void;
|
|
1073
|
-
/**
|
|
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
|
+
*/
|
|
1074
1499
|
declare function table<T>(descriptor: SciTableDescriptor<T>): SciTable<T>;
|
|
1075
|
-
/**
|
|
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
|
+
*/
|
|
1076
1607
|
declare function table<T>(data: Signal<T[]>, columnFactoryFn: SciTableColumnFactoryFn<T>, options?: {
|
|
1077
1608
|
injector?: Injector;
|
|
1078
1609
|
}): SciTable<T>;
|
|
1079
1610
|
|
|
1080
|
-
declare class
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
readonly
|
|
1084
|
-
readonly columns: Signal<SciTableColumnLike<T>[]>;
|
|
1085
|
-
readonly rowActions?: SciTableRowActionFactoryFn<T>;
|
|
1086
|
-
private readonly _rowBindings;
|
|
1087
|
-
private readonly _dataLoaderFn;
|
|
1088
|
-
private readonly _trackBy?;
|
|
1089
|
-
readonly tableViewRef: WritableSignal<SciTableViewRef | undefined>;
|
|
1090
|
-
readonly userSettings: WritableSignal<SciTableUserSettings>;
|
|
1091
|
-
readonly bufferSize: number;
|
|
1092
|
-
readonly pageSize: number;
|
|
1093
|
-
readonly filterable: WritableSignal<boolean>;
|
|
1094
|
-
readonly showHeader: WritableSignal<boolean>;
|
|
1095
|
-
readonly wrapHeader: WritableSignal<boolean>;
|
|
1096
|
-
readonly sortable: WritableSignal<boolean>;
|
|
1097
|
-
readonly resizable: WritableSignal<boolean>;
|
|
1098
|
-
readonly selectable: WritableSignal<'single' | 'multi' | false>;
|
|
1099
|
-
readonly scrollRange: Signal<SciScrollRange | undefined>;
|
|
1100
|
-
readonly scrollTop: Signal<number>;
|
|
1101
|
-
readonly virtualScrollOffset: Signal<{
|
|
1102
|
-
top: number;
|
|
1103
|
-
bottom: number;
|
|
1104
|
-
}>;
|
|
1105
|
-
readonly viewportPageSize: Signal<number>;
|
|
1106
|
-
readonly scrolling: Signal<boolean>;
|
|
1107
|
-
readonly resizing: Signal<boolean>;
|
|
1108
|
-
readonly sortCriteria: WritableSignal<SciTableSortCriterion[]>;
|
|
1109
|
-
readonly filterCriteria: WritableSignal<SciTableColumnFilter[]>;
|
|
1110
|
-
private readonly _cache;
|
|
1111
|
-
private readonly _tableCellValuePreloader;
|
|
1112
|
-
private readonly _tableFilter;
|
|
1113
|
-
private readonly _selectedItems;
|
|
1114
|
-
readonly totalCount: WritableSignal<number | undefined>;
|
|
1115
|
-
readonly activeItem: WritableSignal<T | undefined>;
|
|
1116
|
-
readonly hoveredIndex: WritableSignal<number>;
|
|
1117
|
-
readonly criteria: Signal<{
|
|
1118
|
-
sort: SciTableSortCriterion[];
|
|
1119
|
-
filter: SciTableColumnFilter[];
|
|
1120
|
-
tableFilter: string | null;
|
|
1121
|
-
}>;
|
|
1122
|
-
readonly loading: Signal<boolean>;
|
|
1123
|
-
readonly error: Signal<Error | undefined>;
|
|
1124
|
-
readonly activeRow: Signal<SciTableRow<T> | undefined>;
|
|
1125
|
-
readonly hoveredRow: Signal<SciTableRow<T> | undefined>;
|
|
1126
|
-
readonly selectedItems: Signal<T[]>;
|
|
1127
|
-
readonly selectedIds: Signal<Set<unknown>>;
|
|
1128
|
-
readonly rowsByIndex: Signal<Map<number, SciTableRow<T>>>;
|
|
1129
|
-
readonly rows: Signal<SciTableRow<T>[]>;
|
|
1130
|
-
constructor(descriptor: SciTableDescriptor<T>);
|
|
1131
|
-
/**
|
|
1132
|
-
* Connects {@link SciTableComponent} to the model.
|
|
1133
|
-
*/
|
|
1134
|
-
connect(name: `table:${string}`, viewRef: SciTableViewRef): void;
|
|
1135
|
-
disconnect(): void;
|
|
1136
|
-
private computeColumns;
|
|
1137
|
-
/**
|
|
1138
|
-
* Computes the rows currently visible in the viewport (+buffer).
|
|
1139
|
-
*/
|
|
1140
|
-
private computeRows;
|
|
1141
|
-
/**
|
|
1142
|
-
* Computes the visible row count based on the viewport size.
|
|
1143
|
-
*/
|
|
1144
|
-
private computeScrollRange;
|
|
1145
|
-
private computeVirtualScrollOffset;
|
|
1146
|
-
private computeViewportPageSize;
|
|
1147
|
-
/**
|
|
1148
|
-
* Tracks {@link HTMLElement.scrollTop} of the viewport.
|
|
1149
|
-
*/
|
|
1150
|
-
private computeScrollTop;
|
|
1151
|
-
/**
|
|
1152
|
-
* Tracks whether currently scrolling the viewport.
|
|
1153
|
-
*/
|
|
1154
|
-
private computeScrolling;
|
|
1155
|
-
/**
|
|
1156
|
-
* Loads a range of rows, based on the current sort and filter criteria, into the cache.
|
|
1157
|
-
*/
|
|
1158
|
-
loadRange(start: number, end: number): Promise<void>;
|
|
1159
|
-
/**
|
|
1160
|
-
* Loads the requested page from the cache or datasource and returns its loading state with a cancelation handler.
|
|
1161
|
-
*/
|
|
1162
|
-
private loadPage;
|
|
1163
|
-
/**
|
|
1164
|
-
* Toggles sort on a column. ASC -> DESC -> No sort
|
|
1165
|
-
*
|
|
1166
|
-
* TODO [ego] Revisit API, do we really want a three-state and implicit toggling logic?
|
|
1167
|
-
*/
|
|
1168
|
-
sort(columnName: `column:${string}`, multi: boolean): void;
|
|
1169
|
-
/**
|
|
1170
|
-
* Applies a filter, either via global filter or on a specific column.
|
|
1171
|
-
*/
|
|
1172
|
-
filter(text: string | null): void;
|
|
1173
|
-
filter(text: string | number | boolean | SciEnumValueLike | SciEnumValueLike[] | null, options: {
|
|
1174
|
-
columnName: `column:${string}`;
|
|
1175
|
-
}): void;
|
|
1176
|
-
updateSelectedItems(updateFn: (ids: Map<unknown, T>) => Map<unknown, T>): void;
|
|
1177
|
-
/**
|
|
1178
|
-
* Indicates whether the built-in array datasource is used.
|
|
1179
|
-
*
|
|
1180
|
-
* Supports out-of-the-box filtering and sorting for built-in table columns.
|
|
1181
|
-
*/
|
|
1182
|
-
isArrayDatasource(): boolean;
|
|
1183
|
-
reset(): void;
|
|
1184
|
-
dispose(): void;
|
|
1185
|
-
/**
|
|
1186
|
-
* Loads a set of pages on criteria or viewport changes.
|
|
1187
|
-
*/
|
|
1188
|
-
private installPageLoader;
|
|
1189
|
-
/**
|
|
1190
|
-
* Resets cache on criteria changes.
|
|
1191
|
-
*/
|
|
1192
|
-
private installCriteriaWatcher;
|
|
1193
|
-
private mapItemsToRow;
|
|
1194
|
-
/**
|
|
1195
|
-
* Creates a signal to read and write table user settings.
|
|
1196
|
-
*/
|
|
1197
|
-
private computeUserSettings;
|
|
1198
|
-
/**
|
|
1199
|
-
* Call trackBy function or fallback to track by object reference.
|
|
1200
|
-
*/
|
|
1201
|
-
trackBy(item: T): unknown;
|
|
1202
|
-
private computeActiveRow;
|
|
1203
|
-
}
|
|
1204
|
-
interface SciScrollRange {
|
|
1205
|
-
/** incluse */
|
|
1206
|
-
start: number;
|
|
1207
|
-
/** exclusive */
|
|
1208
|
-
end: number;
|
|
1209
|
-
}
|
|
1210
|
-
interface SciTableUserSettings {
|
|
1211
|
-
columns?: {
|
|
1212
|
-
name: string;
|
|
1213
|
-
width?: number;
|
|
1214
|
-
}[];
|
|
1215
|
-
}
|
|
1216
|
-
interface SciTableViewRef {
|
|
1217
|
-
viewport: HTMLElement;
|
|
1218
|
-
viewportHeight: Signal<number>;
|
|
1219
|
-
viewportWidth: Signal<number>;
|
|
1220
|
-
viewportClientHeight: Signal<number>;
|
|
1221
|
-
viewportClientWidth: Signal<number>;
|
|
1222
|
-
headerHeight: Signal<number>;
|
|
1223
|
-
cellPadding: Signal<number>;
|
|
1224
|
-
itemHeight: Signal<number>;
|
|
1225
|
-
scrollToTop: () => void;
|
|
1226
|
-
}
|
|
1227
|
-
|
|
1228
|
-
declare class SciTableRowComponent<T> {
|
|
1229
|
-
readonly row: _angular_core.InputSignal<SciTableRow<T>>;
|
|
1230
|
-
readonly primaryAction: _angular_core.OutputEmitterRef<SciTableEvent<T>>;
|
|
1231
|
-
protected readonly table: _angular_core.Signal<ɵSciTable<unknown>>;
|
|
1232
|
-
protected readonly rowActionToolbar: _angular_core.Signal<SciToolbarComponent | undefined>;
|
|
1233
|
-
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>>;
|
|
1234
1615
|
private readonly _selectionService;
|
|
1616
|
+
protected readonly rowActionToolbar: Signal<SciToolbarComponent | undefined>;
|
|
1617
|
+
protected readonly rowActionsToolbarName: `toolbar:${string}`;
|
|
1235
1618
|
constructor();
|
|
1236
1619
|
protected onRowClick(event: PointerEvent): void;
|
|
1237
1620
|
protected onRowDblClick(event: MouseEvent): void;
|
|
1238
1621
|
protected onRowMouseEnter(): void;
|
|
1239
1622
|
protected onRowMouseLeave(event: MouseEvent): void;
|
|
1240
1623
|
protected onActionToolbarClick(event: PointerEvent): void;
|
|
1624
|
+
protected onTreeNodeHandle(event: PointerEvent): void;
|
|
1241
1625
|
private contributeRowActions;
|
|
1242
|
-
static ɵfac: _angular_core.ɵɵFactoryDeclaration<SciTableRowComponent<any>, never>;
|
|
1243
|
-
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>;
|
|
1244
1628
|
}
|
|
1245
1629
|
|
|
1246
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
|
+
*
|
|
1247
1697
|
* @experimental since 22.3.0; API and behavior may change in any version without notice.
|
|
1248
1698
|
*/
|
|
1249
|
-
declare class SciTableComponent<T = unknown> {
|
|
1699
|
+
declare class SciTableComponent<T = unknown, ID = T> {
|
|
1250
1700
|
/**
|
|
1251
1701
|
* Specifies a unique table identifier, used as the key for storing user preferences.
|
|
1252
1702
|
*/
|
|
@@ -1254,45 +1704,26 @@ declare class SciTableComponent<T = unknown> {
|
|
|
1254
1704
|
/**
|
|
1255
1705
|
* Specifies the table definition and datasource.
|
|
1256
1706
|
*/
|
|
1257
|
-
readonly table: _angular_core.InputSignalWithTransform<ɵSciTable<T>, SciTable<
|
|
1707
|
+
readonly table: _angular_core.InputSignalWithTransform<ɵSciTable<T, ID>, SciTable<ID>>;
|
|
1258
1708
|
/**
|
|
1259
1709
|
* Emits when the user double-clicks a row or presses `Enter` on selected rows.
|
|
1260
1710
|
*/
|
|
1261
|
-
readonly primaryAction: _angular_core.OutputEmitterRef<SciTableEvent<
|
|
1711
|
+
readonly primaryAction: _angular_core.OutputEmitterRef<SciTableEvent<ID>>;
|
|
1262
1712
|
private readonly _viewport;
|
|
1263
1713
|
private readonly _viewportClient;
|
|
1264
1714
|
private readonly _tableHeader;
|
|
1265
1715
|
private readonly _tableBody;
|
|
1266
1716
|
private readonly _itemSizeSyntheticElement;
|
|
1267
1717
|
private readonly _cellPaddingSyntheticElement;
|
|
1268
|
-
protected readonly rows: _angular_core.Signal<readonly SciTableRowComponent<any>[]>;
|
|
1718
|
+
protected readonly rows: _angular_core.Signal<readonly SciTableRowComponent<any, any>[]>;
|
|
1269
1719
|
constructor();
|
|
1270
|
-
protected onRowPrimaryAction(event: SciTableEvent<
|
|
1720
|
+
protected onRowPrimaryAction(event: SciTableEvent<ID>): void;
|
|
1271
1721
|
protected onRetry(): void;
|
|
1272
1722
|
private connectToModel;
|
|
1273
1723
|
private scrollActiveRowIntoViewport;
|
|
1274
|
-
static ɵfac: _angular_core.ɵɵFactoryDeclaration<SciTableComponent<any>, never>;
|
|
1275
|
-
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>;
|
|
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>;
|
|
1276
1726
|
}
|
|
1277
1727
|
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
*/
|
|
1281
|
-
interface SciTableStorage {
|
|
1282
|
-
/**
|
|
1283
|
-
* Method invoked to load a value from persisted storage.
|
|
1284
|
-
*/
|
|
1285
|
-
load(name: `scion.components.table:${string}`): Promise<string | null> | string | null;
|
|
1286
|
-
/**
|
|
1287
|
-
* Method invoked to write a value to persisted storage.
|
|
1288
|
-
*/
|
|
1289
|
-
store(name: `scion.components.table:${string}`, value: string): Promise<void> | void;
|
|
1290
|
-
}
|
|
1291
|
-
/**
|
|
1292
|
-
* Defaults to localStorage persistence.
|
|
1293
|
-
* @param storage
|
|
1294
|
-
*/
|
|
1295
|
-
declare function provideTableStorage(storage: Type<SciTableStorage>): EnvironmentProviders;
|
|
1296
|
-
|
|
1297
|
-
export { SciTableComponent, provideTableRowBinding, provideTableStorage, table, ɵillegaldatasource };
|
|
1298
|
-
export type { SciBooleanColumnDescriptor, SciColumnHeaderLike, SciComponentColumnDescriptor, SciDateColumnDescriptor, SciDateLike, SciEnumColumnDescriptor, SciEnumColumnValues, SciEnumValueLike, SciIconColumnDescriptor, SciIconColumnValues, SciNumberColumnDescriptor, SciStringColumnDescriptor, SciTable, SciTableCellContext, SciTableColumnDescriptor, SciTableColumnFactory, SciTableColumnFactoryFn, SciTableColumnFilter, SciTableColumnFilterMatcherFn, SciTableColumnSortComparatorFn, SciTableColumnType, SciTableDataLoaderFn, SciTableDescriptor, SciTableEvent, SciTablePageRequest, SciTablePageResponse, SciTableRowActionFactoryFn, SciTableRowBindingFactory, SciTableRowBindingFactoryFn, SciTableSortCriterion, SciTableStorage, SciTemplateColumnDescriptor };
|
|
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 };
|