@scion/components 22.1.0 → 22.3.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 +75 -5
- package/common/package.json +4 -0
- package/design/_theming.scss +25 -10
- package/design/components/_scion-component-dark-tokens.scss +153 -0
- package/design/components/_scion-component-light-tokens.scss +153 -0
- package/design/icons/_scion-icon-font.scss +50 -0
- package/design/themes/_scion-dark-theme.scss +2 -7
- package/design/themes/_scion-light-theme.scss +3 -8
- package/fesm2022/scion-components-common.mjs +251 -0
- package/fesm2022/scion-components-common.mjs.map +1 -0
- package/fesm2022/scion-components-dimension.mjs +7 -6
- package/fesm2022/scion-components-dimension.mjs.map +1 -1
- package/fesm2022/scion-components-icon.mjs +380 -0
- package/fesm2022/scion-components-icon.mjs.map +1 -0
- package/fesm2022/scion-components-menu.mjs +3271 -0
- package/fesm2022/scion-components-menu.mjs.map +1 -0
- package/fesm2022/scion-components-sashbox.mjs +21 -21
- package/fesm2022/scion-components-sashbox.mjs.map +1 -1
- package/fesm2022/scion-components-splitter.mjs +16 -13
- package/fesm2022/scion-components-splitter.mjs.map +1 -1
- package/fesm2022/scion-components-table.mjs +2265 -0
- package/fesm2022/scion-components-table.mjs.map +1 -0
- package/fesm2022/scion-components-text.mjs +322 -0
- package/fesm2022/scion-components-text.mjs.map +1 -0
- package/fesm2022/scion-components-throbber.mjs +15 -15
- package/fesm2022/scion-components-throbber.mjs.map +1 -1
- package/fesm2022/scion-components-viewport.mjs +142 -125
- package/fesm2022/scion-components-viewport.mjs.map +1 -1
- package/icon/package.json +4 -0
- package/menu/package.json +4 -0
- package/package.json +22 -2
- package/table/package.json +4 -0
- package/text/package.json +4 -0
- package/types/scion-components-common.d.ts +185 -0
- package/types/scion-components-icon.d.ts +146 -0
- package/types/scion-components-menu.d.ts +1922 -0
- package/types/scion-components-sashbox.d.ts +4 -2
- package/types/scion-components-splitter.d.ts +4 -3
- package/types/scion-components-table.d.ts +577 -0
- package/types/scion-components-text.d.ts +131 -0
- package/types/scion-components-viewport.d.ts +32 -39
- package/viewport/scrollbar/_scrollbar.scss +4 -4
- package/design/components/_scion-component-tokens.scss +0 -48
|
@@ -41,8 +41,10 @@ import { SplitterMoveEvent } from '@scion/components/splitter';
|
|
|
41
41
|
* - --sci-sashbox-splitter-size: Sets the size of the splitter along the main axis.
|
|
42
42
|
* - --sci-sashbox-splitter-size-hover: Sets the size of the splitter along the main axis when hovering it.
|
|
43
43
|
* - --sci-sashbox-splitter-touch-target-size: Sets the touch target size to move the splitter (accessibility).
|
|
44
|
-
* - --sci-sashbox-splitter-cross-axis-size: Sets the splitter size along the cross
|
|
45
|
-
* - --sci-sashbox-splitter-
|
|
44
|
+
* - --sci-sashbox-splitter-cross-axis-size: Sets the splitter size along the cross-axis. Defaults to `100%`.
|
|
45
|
+
* - --sci-sashbox-splitter-cross-axis-start: Sets the splitter's start position. Defaults to `auto`.
|
|
46
|
+
* - --sci-sashbox-splitter-cross-axis-end: Sets the splitter's end position. Defaults to `auto`. Requires `--sci-sashbox-splitter-cross-axis-size: auto`.
|
|
47
|
+
* - --sci-sashbox-splitter-border-radius: Sets the border radius of the splitter. Defaults to 0.
|
|
46
48
|
* - --sci-sashbox-splitter-opacity-active: Sets the opacity of the splitter while the user moves the splitter.
|
|
47
49
|
* - --sci-sashbox-splitter-opacity-hover: Sets the opacity of the splitter when hovering it.
|
|
48
50
|
*
|
|
@@ -27,8 +27,10 @@ import * as _angular_core from '@angular/core';
|
|
|
27
27
|
* - --sci-splitter-size: Sets the size of the splitter along the main axis.
|
|
28
28
|
* - --sci-splitter-size-hover: Sets the size of the splitter along the main axis when hovering it.
|
|
29
29
|
* - --sci-splitter-touch-target-size: Sets the touch target size to move the splitter (accessibility).
|
|
30
|
-
* - --sci-splitter-cross-axis-size: Sets the splitter size along the cross
|
|
31
|
-
* - --sci-splitter-
|
|
30
|
+
* - --sci-splitter-cross-axis-size: Sets the splitter size along the cross-axis. Defaults to `100%`.
|
|
31
|
+
* - --sci-splitter-cross-axis-start: Sets the splitter's start position. Defaults to `auto`.
|
|
32
|
+
* - --sci-splitter-cross-axis-end: Sets the splitter's end position. Defaults to `auto`. Requires `--sci-splitter-cross-axis-size: auto`.
|
|
33
|
+
* - --sci-splitter-border-radius: Sets the border radius of the splitter. Defaults to 0.
|
|
32
34
|
* - --sci-splitter-opacity-active: Sets the opacity of the splitter while the user moves the splitter.
|
|
33
35
|
* - --sci-splitter-opacity-hover: Sets the opacity of the splitter when hovering it.
|
|
34
36
|
*
|
|
@@ -66,7 +68,6 @@ declare class SciSplitterComponent {
|
|
|
66
68
|
private readonly _cd;
|
|
67
69
|
private readonly _document;
|
|
68
70
|
private readonly _destroyRef;
|
|
69
|
-
private readonly _touchTarget;
|
|
70
71
|
protected readonly moving: _angular_core.WritableSignal<boolean>;
|
|
71
72
|
protected readonly isHorizontal: _angular_core.Signal<boolean>;
|
|
72
73
|
protected readonly isVertical: _angular_core.Signal<boolean>;
|
|
@@ -0,0 +1,577 @@
|
|
|
1
|
+
import * as _angular_core from '@angular/core';
|
|
2
|
+
import { Signal, Provider, WritableSignal, Injector, Type, EnvironmentProviders } from '@angular/core';
|
|
3
|
+
import { Observable } from 'rxjs';
|
|
4
|
+
import { MaybeSignal, SciComponentDescriptor, SciTemplateDescriptor } from '@scion/components/common';
|
|
5
|
+
import { SciToolbarFactory, SciToolbarComponent } from '@scion/components/menu';
|
|
6
|
+
import { Translatable } from '@scion/components/text';
|
|
7
|
+
|
|
8
|
+
type MaybeAsync<T> = T | Promise<T> | Observable<T>;
|
|
9
|
+
|
|
10
|
+
interface SciTableColumnFilter {
|
|
11
|
+
columnName: `column:${string}`;
|
|
12
|
+
text: string | boolean | number;
|
|
13
|
+
}
|
|
14
|
+
interface SciTableSortCriterion {
|
|
15
|
+
columnName: `column:${string}`;
|
|
16
|
+
direction: 'asc' | 'desc';
|
|
17
|
+
}
|
|
18
|
+
interface SciTablePageRequest {
|
|
19
|
+
page: number;
|
|
20
|
+
pageSize: number;
|
|
21
|
+
start: number;
|
|
22
|
+
end: number;
|
|
23
|
+
sortCriteria: SciTableSortCriterion[];
|
|
24
|
+
columnFilters: SciTableColumnFilter[];
|
|
25
|
+
tableFilter?: string;
|
|
26
|
+
}
|
|
27
|
+
interface SciTablePageResponse<T> {
|
|
28
|
+
/**
|
|
29
|
+
* Items of the requested page.
|
|
30
|
+
*/
|
|
31
|
+
items: T[];
|
|
32
|
+
/**
|
|
33
|
+
* Total count of the source data, used to calculate the scroll size.
|
|
34
|
+
*/
|
|
35
|
+
totalCount: number;
|
|
36
|
+
}
|
|
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
|
+
|
|
50
|
+
declare function provideTableRowBinding<T = unknown>(bindings: SciTableRowBindingFactoryFn<T>): Provider;
|
|
51
|
+
type SciTableRowBindingFactoryFn<T> = (bindings: SciTableRowBindingFactory, item: T, index: number) => void;
|
|
52
|
+
interface SciTableRowBindingFactory {
|
|
53
|
+
addAttributeBinding(name: string, value: unknown | undefined): this;
|
|
54
|
+
addClassBinding(name: string | undefined): this;
|
|
55
|
+
/**
|
|
56
|
+
* Adds the specified values as part attributes to the row, enabling for custom styling of the row, e.g., based on a condition.
|
|
57
|
+
*
|
|
58
|
+
* Example usage:
|
|
59
|
+
* ```ts
|
|
60
|
+
* table({
|
|
61
|
+
* datasource: data,
|
|
62
|
+
* rowBindings: (bindings, item, index) => bindings
|
|
63
|
+
* .addPartBinding(index % 2 === 0 ? 'row:even' : 'row:odd')
|
|
64
|
+
* .addPartBinding(item.active ? 'row:active' : undefined),
|
|
65
|
+
* columns: table => ...,
|
|
66
|
+
* });
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* ```scss
|
|
70
|
+
* sci-table::part(row\:even) {
|
|
71
|
+
* background-color: lightgray;
|
|
72
|
+
* }
|
|
73
|
+
*
|
|
74
|
+
* sci-table::part(row\:active) {
|
|
75
|
+
* background-color: green;
|
|
76
|
+
* }
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
addPartBinding(name: `row:${string}` | undefined): this;
|
|
80
|
+
}
|
|
81
|
+
interface SciTableRowBindings {
|
|
82
|
+
cssClass: Signal<string[]>;
|
|
83
|
+
attributes: Signal<{
|
|
84
|
+
[name: string]: unknown;
|
|
85
|
+
}>;
|
|
86
|
+
part: Signal<`row:${string}`[]>;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
type SciTableColumnType = 'string' | 'number' | 'boolean' | 'component' | 'template';
|
|
90
|
+
type SciTableRowActionFactoryFn<T> = (toolbar: SciToolbarFactory, item: T, index: number) => void;
|
|
91
|
+
interface SciTableDescriptor<T> {
|
|
92
|
+
datasource: Signal<T[]>;
|
|
93
|
+
/**
|
|
94
|
+
* @docs-private Not public API. For internal use only.
|
|
95
|
+
* @experimental since 22.3.0; API and behavior may change in any version without notice.
|
|
96
|
+
*/
|
|
97
|
+
ɵdatasource?: Signal<T[]> | SciTableDataLoaderFn<T>;
|
|
98
|
+
columns: SciTableColumnFactoryFn<T>;
|
|
99
|
+
sortable?: boolean;
|
|
100
|
+
resizable?: boolean;
|
|
101
|
+
filterable?: boolean;
|
|
102
|
+
selectable?: false | 'single' | 'multi';
|
|
103
|
+
showHeader?: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Defaults to false.
|
|
106
|
+
*/
|
|
107
|
+
wrapHeader?: boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Configures actions to show when hovering over a row.
|
|
110
|
+
*
|
|
111
|
+
* Example usage:
|
|
112
|
+
* ```ts
|
|
113
|
+
* table({
|
|
114
|
+
* datasource: data,
|
|
115
|
+
* rowActions: (toolbar, item) => toolbar.addToolbarButton({
|
|
116
|
+
* icon: 'delete',
|
|
117
|
+
* onSelect: () => ...,
|
|
118
|
+
* }),
|
|
119
|
+
* columns: table => ...,
|
|
120
|
+
* });
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
rowActions?: SciTableRowActionFactoryFn<T>;
|
|
124
|
+
/**
|
|
125
|
+
* Adds bindings to a table row, enabling custom styling, HTML attributes, and CSS classes.
|
|
126
|
+
*
|
|
127
|
+
* Example usage:
|
|
128
|
+
* ```ts
|
|
129
|
+
* table({
|
|
130
|
+
* datasource: data,
|
|
131
|
+
* rowBindings: (bindings, item, index) => bindings
|
|
132
|
+
* .addPartBinding(index % 2 === 0 ? 'row:even' : 'row:odd')
|
|
133
|
+
* .addAttributeBinding('data-id', item.id)
|
|
134
|
+
* .addClassBinding(item.inactive ? 'inactive' : undefined),
|
|
135
|
+
* columns: table => ...,
|
|
136
|
+
* });
|
|
137
|
+
* ```
|
|
138
|
+
*
|
|
139
|
+
* ```scss
|
|
140
|
+
* sci-table::part(row\:even) {
|
|
141
|
+
* background-color: lightgray;
|
|
142
|
+
* }
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
rowBindings?: SciTableRowBindingFactoryFn<T>;
|
|
146
|
+
/**
|
|
147
|
+
* Specifies the number of items to render before and after the viewport. Defaults to 10.
|
|
148
|
+
*/
|
|
149
|
+
bufferSize?: number;
|
|
150
|
+
/**
|
|
151
|
+
* Specifies the number of items to load per page. Defaults to 50.
|
|
152
|
+
*/
|
|
153
|
+
pageSize?: number;
|
|
154
|
+
trackBy?: (item: T) => unknown;
|
|
155
|
+
injector?: Injector;
|
|
156
|
+
}
|
|
157
|
+
interface SciTable<T> {
|
|
158
|
+
/**
|
|
159
|
+
* Currently active item.
|
|
160
|
+
*/
|
|
161
|
+
readonly activeItem: Signal<T | undefined>;
|
|
162
|
+
/**
|
|
163
|
+
* Selected items.
|
|
164
|
+
*/
|
|
165
|
+
readonly selectedItems: Signal<Array<T>>;
|
|
166
|
+
readonly filterable: WritableSignal<boolean>;
|
|
167
|
+
readonly showHeader: WritableSignal<boolean>;
|
|
168
|
+
readonly wrapHeader: WritableSignal<boolean>;
|
|
169
|
+
readonly sortable: WritableSignal<boolean>;
|
|
170
|
+
readonly resizable: WritableSignal<boolean>;
|
|
171
|
+
readonly selectable: WritableSignal<'single' | 'multi' | false>;
|
|
172
|
+
filter(text: string | null): void;
|
|
173
|
+
}
|
|
174
|
+
interface SciTableCellContext<T, VALUE> {
|
|
175
|
+
item: T;
|
|
176
|
+
value: VALUE;
|
|
177
|
+
}
|
|
178
|
+
interface SciTableColumn {
|
|
179
|
+
type: SciTableColumnType;
|
|
180
|
+
name: `column:${string}`;
|
|
181
|
+
header: Signal<string>;
|
|
182
|
+
sortable: Signal<boolean>;
|
|
183
|
+
filterable: Signal<boolean>;
|
|
184
|
+
resizable: Signal<boolean>;
|
|
185
|
+
padding: boolean;
|
|
186
|
+
width: Signal<string>;
|
|
187
|
+
minWidth: number;
|
|
188
|
+
resizing: WritableSignal<boolean>;
|
|
189
|
+
location: {
|
|
190
|
+
x: number;
|
|
191
|
+
width: number;
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
interface SciStringColumn<T> extends SciTableColumn {
|
|
195
|
+
type: 'string';
|
|
196
|
+
value: (item: T) => MaybeSignal<string>;
|
|
197
|
+
sort: (a: SciTableCellContext<T, string>, b: SciTableCellContext<T, string>) => number;
|
|
198
|
+
filter: (text: string, context: SciTableCellContext<T, string>) => boolean;
|
|
199
|
+
}
|
|
200
|
+
interface SciNumberColumn<T> extends SciTableColumn {
|
|
201
|
+
type: 'number';
|
|
202
|
+
value: (item: T) => MaybeSignal<number>;
|
|
203
|
+
sort: (a: SciTableCellContext<T, number>, b: SciTableCellContext<T, number>) => number;
|
|
204
|
+
filter: (text: number, context: SciTableCellContext<T, number>) => boolean;
|
|
205
|
+
}
|
|
206
|
+
interface SciBooleanColumn<T> extends SciTableColumn {
|
|
207
|
+
type: 'boolean';
|
|
208
|
+
value: (item: T) => MaybeSignal<boolean>;
|
|
209
|
+
sort: (a: SciTableCellContext<T, boolean>, b: SciTableCellContext<T, boolean>) => number;
|
|
210
|
+
filter: (text: boolean, context: SciTableCellContext<T, boolean>) => boolean;
|
|
211
|
+
}
|
|
212
|
+
interface SciComponentColumn<T> extends SciTableColumn {
|
|
213
|
+
type: 'component';
|
|
214
|
+
component: (item: T) => SciComponentDescriptor;
|
|
215
|
+
sort: (a: SciTableCellContext<T, void>, b: SciTableCellContext<T, void>) => number;
|
|
216
|
+
filter: (text: string, context: SciTableCellContext<T, void>) => boolean;
|
|
217
|
+
}
|
|
218
|
+
interface SciTemplateColumn<T> extends SciTableColumn {
|
|
219
|
+
type: 'template';
|
|
220
|
+
template: (item: T) => SciTemplateDescriptor;
|
|
221
|
+
sort: (a: SciTableCellContext<T, void>, b: SciTableCellContext<T, void>) => number;
|
|
222
|
+
filter: (text: string, context: SciTableCellContext<T, void>) => boolean;
|
|
223
|
+
}
|
|
224
|
+
type SciTableColumnLike<T = unknown> = SciStringColumn<T> | SciNumberColumn<T> | SciBooleanColumn<T> | SciComponentColumn<T> | SciTemplateColumn<T>;
|
|
225
|
+
/**
|
|
226
|
+
* Mapped row, used as display state.
|
|
227
|
+
*/
|
|
228
|
+
interface SciTableRow<T> {
|
|
229
|
+
index: number;
|
|
230
|
+
item?: T;
|
|
231
|
+
id?: unknown;
|
|
232
|
+
cells?: SciTableCellLike[];
|
|
233
|
+
bindings?: SciTableRowBindings;
|
|
234
|
+
loading: boolean;
|
|
235
|
+
active: Signal<boolean>;
|
|
236
|
+
selected: Signal<boolean>;
|
|
237
|
+
hovered: Signal<boolean>;
|
|
238
|
+
}
|
|
239
|
+
interface SciStringCell {
|
|
240
|
+
type: 'string';
|
|
241
|
+
column: SciTableColumnLike;
|
|
242
|
+
value: Signal<string>;
|
|
243
|
+
}
|
|
244
|
+
interface SciNumberCell {
|
|
245
|
+
type: 'number';
|
|
246
|
+
column: SciTableColumnLike;
|
|
247
|
+
value: Signal<number>;
|
|
248
|
+
}
|
|
249
|
+
interface SciBooleanCell {
|
|
250
|
+
type: 'boolean';
|
|
251
|
+
column: SciTableColumnLike;
|
|
252
|
+
value: Signal<boolean>;
|
|
253
|
+
}
|
|
254
|
+
interface SciComponentCell {
|
|
255
|
+
type: 'component';
|
|
256
|
+
column: SciTableColumnLike;
|
|
257
|
+
component: SciComponentDescriptor;
|
|
258
|
+
}
|
|
259
|
+
interface SciTemplateCell {
|
|
260
|
+
type: 'template';
|
|
261
|
+
column: SciTableColumnLike;
|
|
262
|
+
template: SciTemplateDescriptor;
|
|
263
|
+
}
|
|
264
|
+
type SciTableCellLike = SciStringCell | SciNumberCell | SciBooleanCell | SciComponentCell | SciTemplateCell;
|
|
265
|
+
/**
|
|
266
|
+
* Represents an event emitted by {@link SciTableComponent}.
|
|
267
|
+
*/
|
|
268
|
+
interface SciTableEvent<T> {
|
|
269
|
+
/**
|
|
270
|
+
* The native browser event (`MouseEvent` or `KeyboardEvent`) that triggered the action.
|
|
271
|
+
*/
|
|
272
|
+
sourceEvent: MouseEvent | KeyboardEvent;
|
|
273
|
+
/**
|
|
274
|
+
* The items associated with the action.
|
|
275
|
+
*/
|
|
276
|
+
items: T[];
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
interface SciTableColumnFactory<T> {
|
|
280
|
+
addStringColumn(header: Translatable, value: (item: T) => string): this;
|
|
281
|
+
addStringColumn(value: (item: T) => string): this;
|
|
282
|
+
addStringColumn(descriptor: SciStringColumnDescriptor<T>): this;
|
|
283
|
+
addBooleanColumn(header: Translatable, value: (item: T) => boolean): this;
|
|
284
|
+
addBooleanColumn(value: (item: T) => boolean): this;
|
|
285
|
+
addBooleanColumn(descriptor: SciBooleanColumnDescriptor<T>): this;
|
|
286
|
+
addNumberColumn(header: Translatable, value: (item: T) => number): this;
|
|
287
|
+
addNumberColumn(value: (item: T) => number): this;
|
|
288
|
+
addNumberColumn(descriptor: SciNumberColumnDescriptor<T>): this;
|
|
289
|
+
addComponentColumn(descriptor: SciComponentColumnDescriptor<T>): this;
|
|
290
|
+
addTemplateColumn(descriptor: SciTemplateColumnDescriptor<T>): this;
|
|
291
|
+
}
|
|
292
|
+
interface SciTableColumnDescriptor {
|
|
293
|
+
name?: `column:${string}`;
|
|
294
|
+
header?: Translatable;
|
|
295
|
+
resizable?: boolean;
|
|
296
|
+
/**
|
|
297
|
+
* Preferred column size.
|
|
298
|
+
* Value which can be used inside `grid-template-columns` definition. Defaults to 1fr.
|
|
299
|
+
* Examples: `1fr`, `max-content`, `100px`.
|
|
300
|
+
*/
|
|
301
|
+
width?: string;
|
|
302
|
+
/**
|
|
303
|
+
* Min column width in px. Defaults to 100.
|
|
304
|
+
*/
|
|
305
|
+
minWidth?: number;
|
|
306
|
+
}
|
|
307
|
+
interface SciStringColumnDescriptor<T> extends SciTableColumnDescriptor {
|
|
308
|
+
value: (item: T) => MaybeSignal<string>;
|
|
309
|
+
sortable?: boolean | {
|
|
310
|
+
comparator: (a: SciTableCellContext<T, string>, b: SciTableCellContext<T, string>) => number;
|
|
311
|
+
};
|
|
312
|
+
filterable?: boolean | {
|
|
313
|
+
matcher: (text: string, context: SciTableCellContext<T, string>) => boolean;
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
interface SciNumberColumnDescriptor<T> extends SciTableColumnDescriptor {
|
|
317
|
+
value: (item: T) => MaybeSignal<number>;
|
|
318
|
+
sortable?: boolean;
|
|
319
|
+
filterable?: boolean;
|
|
320
|
+
}
|
|
321
|
+
interface SciBooleanColumnDescriptor<T> extends SciTableColumnDescriptor {
|
|
322
|
+
value: (item: T) => MaybeSignal<boolean>;
|
|
323
|
+
sortable?: boolean;
|
|
324
|
+
filterable?: boolean;
|
|
325
|
+
}
|
|
326
|
+
interface SciComponentColumnDescriptor<T> extends SciTableColumnDescriptor {
|
|
327
|
+
component: (item: T) => SciComponentDescriptor;
|
|
328
|
+
sortable?: boolean | {
|
|
329
|
+
comparator: (a: SciTableCellContext<T, void>, b: SciTableCellContext<T, void>) => number;
|
|
330
|
+
};
|
|
331
|
+
filterable?: boolean | {
|
|
332
|
+
matcher: (text: string, context: SciTableCellContext<T, void>) => boolean;
|
|
333
|
+
};
|
|
334
|
+
/**
|
|
335
|
+
* Controls whether cell padding is applied. Set to `false` to let content fill the entire cell (render to cell bounds).
|
|
336
|
+
*
|
|
337
|
+
* Defaults to `true`.
|
|
338
|
+
*/
|
|
339
|
+
padding?: boolean;
|
|
340
|
+
}
|
|
341
|
+
interface SciTemplateColumnDescriptor<T> extends SciTableColumnDescriptor {
|
|
342
|
+
template: (item: T) => SciTemplateDescriptor;
|
|
343
|
+
sortable?: boolean | {
|
|
344
|
+
comparator: (a: SciTableCellContext<T, void>, b: SciTableCellContext<T, void>) => number;
|
|
345
|
+
};
|
|
346
|
+
filterable?: boolean | {
|
|
347
|
+
matcher: (text: string, context: SciTableCellContext<T, void>) => boolean;
|
|
348
|
+
};
|
|
349
|
+
/**
|
|
350
|
+
* Controls whether cell padding is applied. Set to `false` to let content fill the entire cell (render to cell bounds).
|
|
351
|
+
*
|
|
352
|
+
* Defaults to `true`.
|
|
353
|
+
*/
|
|
354
|
+
padding?: boolean;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
type SciTableColumnFactoryFn<T> = (table: SciTableColumnFactory<T>) => void;
|
|
358
|
+
/** @experimental since 22.3.0; API and behavior may change in any version without notice. */
|
|
359
|
+
declare function table<T>(descriptor: SciTableDescriptor<T>): SciTable<T>;
|
|
360
|
+
/** @experimental since 22.3.0; API and behavior may change in any version without notice. */
|
|
361
|
+
declare function table<T>(data: Signal<T[]>, columnFactoryFn: SciTableColumnFactoryFn<T>, options?: {
|
|
362
|
+
injector?: Injector;
|
|
363
|
+
}): SciTable<T>;
|
|
364
|
+
|
|
365
|
+
declare class ɵSciTable<T = unknown> implements SciTable<T> {
|
|
366
|
+
private readonly _tableStorage;
|
|
367
|
+
private readonly _injector;
|
|
368
|
+
readonly name: WritableSignal<`table:${string}` | undefined>;
|
|
369
|
+
readonly columns: Signal<SciTableColumnLike<T>[]>;
|
|
370
|
+
readonly rowActions?: SciTableRowActionFactoryFn<T>;
|
|
371
|
+
private readonly _rowBindings;
|
|
372
|
+
private readonly _dataLoaderFn;
|
|
373
|
+
private readonly _trackBy?;
|
|
374
|
+
readonly tableViewRef: WritableSignal<SciTableViewRef | undefined>;
|
|
375
|
+
readonly userSettings: WritableSignal<SciTableUserSettings>;
|
|
376
|
+
readonly bufferSize: number;
|
|
377
|
+
readonly pageSize: number;
|
|
378
|
+
readonly filterable: WritableSignal<boolean>;
|
|
379
|
+
readonly showHeader: WritableSignal<boolean>;
|
|
380
|
+
readonly wrapHeader: WritableSignal<boolean>;
|
|
381
|
+
readonly sortable: WritableSignal<boolean>;
|
|
382
|
+
readonly resizable: WritableSignal<boolean>;
|
|
383
|
+
readonly selectable: WritableSignal<'single' | 'multi' | false>;
|
|
384
|
+
readonly scrollRange: Signal<SciScrollRange | undefined>;
|
|
385
|
+
readonly scrollTop: Signal<number>;
|
|
386
|
+
readonly virtualScrollOffset: Signal<{
|
|
387
|
+
top: number;
|
|
388
|
+
bottom: number;
|
|
389
|
+
}>;
|
|
390
|
+
readonly viewportPageSize: Signal<number>;
|
|
391
|
+
readonly scrolling: Signal<boolean>;
|
|
392
|
+
readonly resizing: Signal<boolean>;
|
|
393
|
+
readonly sortCriteria: WritableSignal<SciTableSortCriterion[]>;
|
|
394
|
+
readonly filterCriteria: WritableSignal<SciTableColumnFilter[]>;
|
|
395
|
+
private readonly _cache;
|
|
396
|
+
private readonly _tableFilter;
|
|
397
|
+
private readonly _selectedItems;
|
|
398
|
+
readonly totalCount: WritableSignal<number | undefined>;
|
|
399
|
+
readonly activeItem: WritableSignal<T | undefined>;
|
|
400
|
+
readonly hoveredIndex: WritableSignal<number>;
|
|
401
|
+
readonly criteria: Signal<{
|
|
402
|
+
sort: SciTableSortCriterion[];
|
|
403
|
+
filter: SciTableColumnFilter[];
|
|
404
|
+
tableFilter: string | null;
|
|
405
|
+
}>;
|
|
406
|
+
readonly loading: Signal<boolean>;
|
|
407
|
+
readonly error: Signal<Error | undefined>;
|
|
408
|
+
readonly activeRow: Signal<SciTableRow<T> | undefined>;
|
|
409
|
+
readonly hoveredRow: Signal<SciTableRow<T> | undefined>;
|
|
410
|
+
readonly selectedItems: Signal<T[]>;
|
|
411
|
+
readonly selectedIds: Signal<Set<unknown>>;
|
|
412
|
+
readonly rowsByIndex: Signal<Map<number, SciTableRow<T>>>;
|
|
413
|
+
readonly rows: Signal<SciTableRow<T>[]>;
|
|
414
|
+
constructor(descriptor: SciTableDescriptor<T>);
|
|
415
|
+
/**
|
|
416
|
+
* Connects {@link SciTableComponent} to the model.
|
|
417
|
+
*/
|
|
418
|
+
connect(name: `table:${string}`, viewRef: SciTableViewRef): void;
|
|
419
|
+
disconnect(): void;
|
|
420
|
+
private computeColumns;
|
|
421
|
+
/**
|
|
422
|
+
* Computes the rows currently visible in the viewport (+buffer).
|
|
423
|
+
*/
|
|
424
|
+
private computeRows;
|
|
425
|
+
/**
|
|
426
|
+
* Computes the visible row count based on the viewport size.
|
|
427
|
+
*/
|
|
428
|
+
private computeScrollRange;
|
|
429
|
+
private computeVirtualScrollOffset;
|
|
430
|
+
private computeViewportPageSize;
|
|
431
|
+
/**
|
|
432
|
+
* Tracks {@link HTMLElement.scrollTop} of the viewport.
|
|
433
|
+
*/
|
|
434
|
+
private computeScrollTop;
|
|
435
|
+
/**
|
|
436
|
+
* Tracks whether currently scrolling the viewport.
|
|
437
|
+
*/
|
|
438
|
+
private computeScrolling;
|
|
439
|
+
/**
|
|
440
|
+
* Loads a range of rows, based on the current sort and filter criteria, into the cache.
|
|
441
|
+
*/
|
|
442
|
+
loadRange(start: number, end: number): Promise<void>;
|
|
443
|
+
/**
|
|
444
|
+
* Loads the requested page from the cache or datasource and returns its loading state with a cancelation handler.
|
|
445
|
+
*/
|
|
446
|
+
private loadPage;
|
|
447
|
+
/**
|
|
448
|
+
* Toggles sort on a column. ASC -> DESC -> No sort
|
|
449
|
+
*
|
|
450
|
+
* TODO [ego] Revisit API, do we really want a three-state and implicit toggling logic?
|
|
451
|
+
*/
|
|
452
|
+
sort(columnName: `column:${string}`, multi: boolean): void;
|
|
453
|
+
/**
|
|
454
|
+
* Applies a filter, either via global filter or on a specific column.
|
|
455
|
+
*/
|
|
456
|
+
filter(text: string | null): void;
|
|
457
|
+
filter(text: string | number | boolean | null, options: {
|
|
458
|
+
columnName: `column:${string}`;
|
|
459
|
+
}): void;
|
|
460
|
+
updateSelectedItems(updateFn: (ids: Map<unknown, T>) => Map<unknown, T>): void;
|
|
461
|
+
reset(): void;
|
|
462
|
+
dispose(): void;
|
|
463
|
+
/**
|
|
464
|
+
* Loads a set of pages on criteria or viewport changes.
|
|
465
|
+
*/
|
|
466
|
+
private installPageLoader;
|
|
467
|
+
/**
|
|
468
|
+
* Resets cache on criteria changes.
|
|
469
|
+
*/
|
|
470
|
+
private installCriteriaWatcher;
|
|
471
|
+
private initColumn;
|
|
472
|
+
private mapItemsToRow;
|
|
473
|
+
/**
|
|
474
|
+
* Creates a signal to read and write table user settings.
|
|
475
|
+
*/
|
|
476
|
+
private computeUserSettings;
|
|
477
|
+
/**
|
|
478
|
+
* Call trackBy function or fallback to track by object reference.
|
|
479
|
+
*/
|
|
480
|
+
trackBy(item: T): unknown;
|
|
481
|
+
private computeActiveRow;
|
|
482
|
+
}
|
|
483
|
+
interface SciScrollRange {
|
|
484
|
+
/** incluse */
|
|
485
|
+
start: number;
|
|
486
|
+
/** exclusive */
|
|
487
|
+
end: number;
|
|
488
|
+
}
|
|
489
|
+
interface SciTableUserSettings {
|
|
490
|
+
columns?: {
|
|
491
|
+
name: string;
|
|
492
|
+
width?: number;
|
|
493
|
+
}[];
|
|
494
|
+
}
|
|
495
|
+
interface SciTableViewRef {
|
|
496
|
+
viewport: HTMLElement;
|
|
497
|
+
viewportHeight: Signal<number>;
|
|
498
|
+
viewportWidth: Signal<number>;
|
|
499
|
+
viewportClientHeight: Signal<number>;
|
|
500
|
+
viewportClientWidth: Signal<number>;
|
|
501
|
+
headerHeight: Signal<number>;
|
|
502
|
+
cellPadding: Signal<number>;
|
|
503
|
+
itemHeight: Signal<number>;
|
|
504
|
+
scrollToTop: () => void;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
declare class SciTableRowComponent<T> {
|
|
508
|
+
readonly row: _angular_core.InputSignal<SciTableRow<T>>;
|
|
509
|
+
readonly primaryAction: _angular_core.OutputEmitterRef<SciTableEvent<T>>;
|
|
510
|
+
protected readonly table: _angular_core.Signal<ɵSciTable<unknown>>;
|
|
511
|
+
protected readonly rowActionToolbar: _angular_core.Signal<SciToolbarComponent | undefined>;
|
|
512
|
+
protected readonly rowActionsToolbarName: `toolbar:${string}`;
|
|
513
|
+
private readonly _selectionService;
|
|
514
|
+
constructor();
|
|
515
|
+
protected onRowClick(event: PointerEvent): void;
|
|
516
|
+
protected onRowDblClick(event: MouseEvent): void;
|
|
517
|
+
protected onRowMouseEnter(): void;
|
|
518
|
+
protected onRowMouseLeave(event: MouseEvent): void;
|
|
519
|
+
protected onActionToolbarClick(event: PointerEvent): void;
|
|
520
|
+
private contributeRowActions;
|
|
521
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<SciTableRowComponent<any>, never>;
|
|
522
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<SciTableRowComponent<any>, "sci-table-row", never, { "row": { "alias": "row"; "required": true; "isSignal": true; }; }, { "primaryAction": "primaryAction"; }, never, never, true, never>;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* @experimental since 22.3.0; API and behavior may change in any version without notice.
|
|
527
|
+
*/
|
|
528
|
+
declare class SciTableComponent<T = unknown> {
|
|
529
|
+
/**
|
|
530
|
+
* Specifies a unique table identifier, used as the key for storing user preferences.
|
|
531
|
+
*/
|
|
532
|
+
readonly name: _angular_core.InputSignal<`table:${string}`>;
|
|
533
|
+
/**
|
|
534
|
+
* Specifies the table definition and datasource.
|
|
535
|
+
*/
|
|
536
|
+
readonly table: _angular_core.InputSignalWithTransform<ɵSciTable<T>, SciTable<T>>;
|
|
537
|
+
/**
|
|
538
|
+
* Emits when the user double-clicks a row or presses `Enter` on selected rows.
|
|
539
|
+
*/
|
|
540
|
+
readonly primaryAction: _angular_core.OutputEmitterRef<SciTableEvent<T>>;
|
|
541
|
+
private readonly _viewport;
|
|
542
|
+
private readonly _viewportClient;
|
|
543
|
+
private readonly _tableHeader;
|
|
544
|
+
private readonly _tableBody;
|
|
545
|
+
private readonly _itemSizeSyntheticElement;
|
|
546
|
+
private readonly _cellPaddingSyntheticElement;
|
|
547
|
+
protected readonly rows: _angular_core.Signal<readonly SciTableRowComponent<any>[]>;
|
|
548
|
+
constructor();
|
|
549
|
+
protected onRowPrimaryAction(event: SciTableEvent<T>): void;
|
|
550
|
+
protected onRetry(): void;
|
|
551
|
+
private connectToModel;
|
|
552
|
+
private scrollActiveRowIntoViewport;
|
|
553
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<SciTableComponent<any>, never>;
|
|
554
|
+
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>;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
* Provides persistent storage for the sci-table.
|
|
559
|
+
*/
|
|
560
|
+
interface SciTableStorage {
|
|
561
|
+
/**
|
|
562
|
+
* Method invoked to load a value from persisted storage.
|
|
563
|
+
*/
|
|
564
|
+
load(name: `scion.components.table:${string}`): Promise<string | null> | string | null;
|
|
565
|
+
/**
|
|
566
|
+
* Method invoked to write a value to persisted storage.
|
|
567
|
+
*/
|
|
568
|
+
store(name: `scion.components.table:${string}`, value: string): Promise<void> | void;
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* Defaults to localStorage persistence.
|
|
572
|
+
* @param storage
|
|
573
|
+
*/
|
|
574
|
+
declare function provideTableStorage(storage: Type<SciTableStorage>): EnvironmentProviders;
|
|
575
|
+
|
|
576
|
+
export { SciTableComponent, provideTableRowBinding, provideTableStorage, table, ɵillegaldatasource };
|
|
577
|
+
export type { SciBooleanColumnDescriptor, SciComponentColumnDescriptor, SciNumberColumnDescriptor, SciStringColumnDescriptor, SciTable, SciTableCellContext, SciTableColumnDescriptor, SciTableColumnFactory, SciTableColumnFactoryFn, SciTableColumnFilter, SciTableColumnType, SciTableDataLoaderFn, SciTableDescriptor, SciTableEvent, SciTablePageRequest, SciTablePageResponse, SciTableRowActionFactoryFn, SciTableRowBindingFactory, SciTableRowBindingFactoryFn, SciTableSortCriterion, SciTableStorage, SciTemplateColumnDescriptor };
|