@scion/components 22.3.0 → 22.4.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scion/components",
3
- "version": "22.3.0",
3
+ "version": "22.4.0",
4
4
  "description": "Provides a collection of Angular components and directives primarily for use in SCION libraries such as `@scion/workbench` and `@scion/microfrontend-platform`. This library is not a comprehensive component library as its focus is on SCION requirements.",
5
5
  "license": "EPL-2.0",
6
6
  "private": false,
@@ -83,7 +83,7 @@
83
83
  },
84
84
  "repository": {
85
85
  "type": "git",
86
- "url": "https://github.com/SchweizerischeBundesbahnen/scion-toolkit.git"
86
+ "url": "git+https://github.com/SchweizerischeBundesbahnen/scion-toolkit.git"
87
87
  },
88
88
  "sideEffects": false,
89
89
  "module": "fesm2022/scion-components.mjs",
@@ -60,61 +60,8 @@ declare class SciIconComponent {
60
60
  * @import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL@20..24,400,0&display=block');
61
61
  * ```
62
62
  *
63
- * SCION uses the following built-in icons:
64
- * - scion.add : Add an item
65
- * - scion.add_large : Add an item (large)
66
- * - scion.bin : Bin symbol
67
- * - scion.checkmark : Indicates a selected option
68
- * - scion.chevron_down : Chevron down symbol
69
- * - scion.chevron_left : Chevron left symbol
70
- * - scion.chevron_right : Chevron right symbol
71
- * - scion.chevron_up : Chevron up symbol
72
- * - scion.clear : Clear items
73
- * - scion.close : Close a popover
74
- * - scion.collapse_all : Collapse all items
75
- * - scion.copy : Copy an item
76
- * - scion.delete : Delete an item
77
- * - scion.dirty : Indicates unsaved data
78
- * - scion.drag_handle : Drag or move an item
79
- * - scion.duplicate : Duplicate an item
80
- * - scion.edit : Edit an item
81
- * - scion.emdash : Em dash symbol
82
- * - scion.envelope : Envelope symbol
83
- * - scion.envelope_closed : Indicates a closed envelope
84
- * - scion.envelope_opened : Indicates an opened envelope
85
- * - scion.expand_all : Expand an item
86
- * - scion.external_link : Open link in a new tab
87
- * - scion.filter : Set or change a filter
88
- * - scion.find : Find an item
89
- * - scion.folder : Directory symbol
90
- * - scion.help : Indicates help, support, or documentation
91
- * - scion.hide : Hide a panel
92
- * - scion.magnifier : Magnifier symbol
93
- * - scion.minimize : Minimize a panel
94
- * - scion.minus : Minus sign
95
- * - scion.modified : Indicates modified data
96
- * - scion.more_horizontal : Show a popover to the left or right
97
- * - scion.more_vertical : Show a popover above or below
98
- * - scion.new : Create an item
99
- * - scion.new_large : Create an item (large)
100
- * - scion.paste : Paste from clipboard
101
- * - scion.pen : Pen symbol
102
- * - scion.pin : Pin an item
103
- * - scion.pinned : Indicates a pinned item
104
- * - scion.placeholder_frame : Placeholder symbol
105
- * - scion.placeholder_image : Placeholder symbol for an image
106
- * - scion.plus : Plus sign
107
- * - scion.plus_large : Plus sign (large)
108
- * - scion.remove : Remove an item (x)
109
- * - scion.remove_minus : Remove an item (-)
110
- * - scion.reset : Reset a form
111
- * - scion.search : Search for an item
112
- * - scion.sort_ascending : Sort items in ascending order (A-Z, 0-9)
113
- * - scion.sort_by : Change sort order
114
- * - scion.sort_descending : Sort items in descending order (Z-A, 9-0)
115
- * - scion.user : User symbol
116
- *
117
- * To not replace built-in icons, the icon provider can return `undefined` for icons starting with the `scion.` prefix.
63
+ * Built-in SCION icons start with the `scion.` prefix. To not replace SCION icons, the icon provider can return `undefined` for icons starting with the `scion.` prefix.
64
+ * Refer to https://icons.scion.vercel.app for available SCION icons.
118
65
  *
119
66
  * The function can call `inject` to get any required dependencies.
120
67
  *
@@ -130,7 +77,7 @@ declare function provideIconProvider(iconProviderFn: SciIconProviderFn | undefin
130
77
  * Alternatively, the icon provider can return a descriptor, allowing for additional configuration such as inputs.
131
78
  * Inputs are available as input properties in the component. The component can use the inputs to render the icon.
132
79
  *
133
- * Icon keys used by SCION start with the `scion.` prefix. To not replace built-in icons, the icon provider can
80
+ * Icon keys used by SCION start with the `scion.` prefix. To not replace SCION icons, the icon provider can
134
81
  * return `undefined` for icons starting with the `scion.` prefix.
135
82
  *
136
83
  * An icon provider can be registered via {@link provideIconProvider} function.
@@ -86,6 +86,92 @@ interface SciTableRowBindings {
86
86
  part: Signal<`row:${string}`[]>;
87
87
  }
88
88
 
89
+ interface SciTableColumnFactory<T> {
90
+ addStringColumn(header: Translatable, value: (item: T) => string): this;
91
+ addStringColumn(value: (item: T) => string): this;
92
+ addStringColumn(descriptor: SciStringColumnDescriptor<T>): this;
93
+ addBooleanColumn(header: Translatable, value: (item: T) => boolean): this;
94
+ addBooleanColumn(value: (item: T) => boolean): this;
95
+ addBooleanColumn(descriptor: SciBooleanColumnDescriptor<T>): this;
96
+ addNumberColumn(header: Translatable, value: (item: T) => number): this;
97
+ addNumberColumn(value: (item: T) => number): this;
98
+ addNumberColumn(descriptor: SciNumberColumnDescriptor<T>): this;
99
+ addComponentColumn(descriptor: SciComponentColumnDescriptor<T>): this;
100
+ addTemplateColumn(descriptor: SciTemplateColumnDescriptor<T>): this;
101
+ }
102
+ interface SciTableColumnDescriptor {
103
+ name?: `column:${string}`;
104
+ header?: Translatable;
105
+ resizable?: boolean;
106
+ /**
107
+ * Preferred column size.
108
+ * Value which can be used inside `grid-template-columns` definition. Defaults to 1fr.
109
+ * Examples: `1fr`, `max-content`, `100px`.
110
+ */
111
+ width?: string;
112
+ /**
113
+ * Min column width in px. Defaults to 100.
114
+ */
115
+ minWidth?: number;
116
+ }
117
+ interface SciStringColumnDescriptor<T> extends SciTableColumnDescriptor {
118
+ value: (item: T) => MaybeSignal<string>;
119
+ sortable?: boolean | {
120
+ comparator: SciTableColumnSortComparatorFn<T, string>;
121
+ };
122
+ filterable?: boolean | {
123
+ matcher: SciTableColumnFilterMatcherFn<T, string>;
124
+ };
125
+ }
126
+ interface SciNumberColumnDescriptor<T> extends SciTableColumnDescriptor {
127
+ value: (item: T) => MaybeSignal<number>;
128
+ sortable?: boolean;
129
+ filterable?: boolean;
130
+ }
131
+ interface SciBooleanColumnDescriptor<T> extends SciTableColumnDescriptor {
132
+ value: (item: T) => MaybeSignal<boolean>;
133
+ sortable?: boolean;
134
+ filterable?: boolean;
135
+ }
136
+ interface SciComponentColumnDescriptor<T> extends SciTableColumnDescriptor {
137
+ component: (item: T) => SciComponentDescriptor;
138
+ sortable?: boolean | {
139
+ comparator: SciTableColumnSortComparatorFn<T, void>;
140
+ };
141
+ filterable?: boolean | {
142
+ matcher: SciTableColumnFilterMatcherFn<T, void, string>;
143
+ };
144
+ /**
145
+ * Controls whether cell padding is applied. Set to `false` to let content fill the entire cell (render to cell bounds).
146
+ *
147
+ * Defaults to `true`.
148
+ */
149
+ padding?: boolean;
150
+ }
151
+ interface SciTemplateColumnDescriptor<T> extends SciTableColumnDescriptor {
152
+ template: (item: T) => SciTemplateDescriptor;
153
+ sortable?: boolean | {
154
+ comparator: SciTableColumnSortComparatorFn<T, void>;
155
+ };
156
+ filterable?: boolean | {
157
+ matcher: SciTableColumnFilterMatcherFn<T, void, string>;
158
+ };
159
+ /**
160
+ * Controls whether cell padding is applied. Set to `false` to let content fill the entire cell (render to cell bounds).
161
+ *
162
+ * Defaults to `true`.
163
+ */
164
+ padding?: boolean;
165
+ }
166
+ /**
167
+ * Signature of a function used to configure a comparator for sorting a table column.
168
+ */
169
+ type SciTableColumnSortComparatorFn<T = unknown, VALUE = unknown> = (a: SciTableCellContext<T, VALUE>, b: SciTableCellContext<T, VALUE>) => number;
170
+ /**
171
+ * Signature of a function used to configure a matcher for filtering a table column.
172
+ */
173
+ type SciTableColumnFilterMatcherFn<T = unknown, VALUE = unknown, FILTER = VALUE> = (filter: FILTER, context: SciTableCellContext<T, VALUE>) => boolean;
174
+
89
175
  type SciTableColumnType = 'string' | 'number' | 'boolean' | 'component' | 'template';
90
176
  type SciTableRowActionFactoryFn<T> = (toolbar: SciToolbarFactory, item: T, index: number) => void;
91
177
  interface SciTableDescriptor<T> {
@@ -169,13 +255,16 @@ interface SciTable<T> {
169
255
  readonly sortable: WritableSignal<boolean>;
170
256
  readonly resizable: WritableSignal<boolean>;
171
257
  readonly selectable: WritableSignal<'single' | 'multi' | false>;
258
+ /**
259
+ * Filters items cross-column, ignoring {@link SciTableDescriptor.filterable} and {@link SciTableColumnDescriptor.filterable} settings.
260
+ */
172
261
  filter(text: string | null): void;
173
262
  }
174
- interface SciTableCellContext<T, VALUE> {
263
+ interface SciTableCellContext<T = unknown, VALUE = unknown> {
175
264
  item: T;
176
265
  value: VALUE;
177
266
  }
178
- interface SciTableColumn {
267
+ interface SciTableColumn<T = unknown, VALUE = unknown, FILTER = VALUE> {
179
268
  type: SciTableColumnType;
180
269
  name: `column:${string}`;
181
270
  header: Signal<string>;
@@ -190,36 +279,38 @@ interface SciTableColumn {
190
279
  x: number;
191
280
  width: number;
192
281
  };
282
+ compare: SciTableColumnSortComparatorFn<T, VALUE>;
283
+ matches: SciTableColumnFilterMatcherFn<T, VALUE, FILTER>;
193
284
  }
194
- interface SciStringColumn<T> extends SciTableColumn {
285
+ interface SciStringColumn<T> extends SciTableColumn<T, string> {
195
286
  type: 'string';
196
287
  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;
288
+ compare: SciTableColumnSortComparatorFn<T, string>;
289
+ matches: SciTableColumnFilterMatcherFn<T, string>;
199
290
  }
200
- interface SciNumberColumn<T> extends SciTableColumn {
291
+ interface SciNumberColumn<T> extends SciTableColumn<T, number> {
201
292
  type: 'number';
202
293
  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;
294
+ compare: SciTableColumnSortComparatorFn<T, number>;
295
+ matches: SciTableColumnFilterMatcherFn<T, number>;
205
296
  }
206
- interface SciBooleanColumn<T> extends SciTableColumn {
297
+ interface SciBooleanColumn<T> extends SciTableColumn<T, boolean> {
207
298
  type: 'boolean';
208
299
  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;
300
+ compare: SciTableColumnSortComparatorFn<T, boolean>;
301
+ matches: SciTableColumnFilterMatcherFn<T, boolean>;
211
302
  }
212
- interface SciComponentColumn<T> extends SciTableColumn {
303
+ interface SciComponentColumn<T> extends SciTableColumn<T, void, string> {
213
304
  type: 'component';
214
305
  component: (item: T) => SciComponentDescriptor;
215
- sort: (a: SciTableCellContext<T, void>, b: SciTableCellContext<T, void>) => number;
216
- filter: (text: string, context: SciTableCellContext<T, void>) => boolean;
306
+ compare: SciTableColumnSortComparatorFn<T, void>;
307
+ matches: SciTableColumnFilterMatcherFn<T, void, string>;
217
308
  }
218
- interface SciTemplateColumn<T> extends SciTableColumn {
309
+ interface SciTemplateColumn<T> extends SciTableColumn<T, void, string> {
219
310
  type: 'template';
220
311
  template: (item: T) => SciTemplateDescriptor;
221
- sort: (a: SciTableCellContext<T, void>, b: SciTableCellContext<T, void>) => number;
222
- filter: (text: string, context: SciTableCellContext<T, void>) => boolean;
312
+ compare: SciTableColumnSortComparatorFn<T, void>;
313
+ matches: SciTableColumnFilterMatcherFn<T, void, string>;
223
314
  }
224
315
  type SciTableColumnLike<T = unknown> = SciStringColumn<T> | SciNumberColumn<T> | SciBooleanColumn<T> | SciComponentColumn<T> | SciTemplateColumn<T>;
225
316
  /**
@@ -276,84 +367,6 @@ interface SciTableEvent<T> {
276
367
  items: T[];
277
368
  }
278
369
 
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
370
  type SciTableColumnFactoryFn<T> = (table: SciTableColumnFactory<T>) => void;
358
371
  /** @experimental since 22.3.0; API and behavior may change in any version without notice. */
359
372
  declare function table<T>(descriptor: SciTableDescriptor<T>): SciTable<T>;
@@ -458,6 +471,12 @@ declare class ɵSciTable<T = unknown> implements SciTable<T> {
458
471
  columnName: `column:${string}`;
459
472
  }): void;
460
473
  updateSelectedItems(updateFn: (ids: Map<unknown, T>) => Map<unknown, T>): void;
474
+ /**
475
+ * Indicates whether the built-in array datasource is used.
476
+ *
477
+ * Supports out-of-the-box filtering and sorting for built-in table columns.
478
+ */
479
+ isArrayDatasource(): boolean;
461
480
  reset(): void;
462
481
  dispose(): void;
463
482
  /**
@@ -468,7 +487,6 @@ declare class ɵSciTable<T = unknown> implements SciTable<T> {
468
487
  * Resets cache on criteria changes.
469
488
  */
470
489
  private installCriteriaWatcher;
471
- private initColumn;
472
490
  private mapItemsToRow;
473
491
  /**
474
492
  * Creates a signal to read and write table user settings.
@@ -574,4 +592,4 @@ interface SciTableStorage {
574
592
  declare function provideTableStorage(storage: Type<SciTableStorage>): EnvironmentProviders;
575
593
 
576
594
  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 };
595
+ export type { SciBooleanColumnDescriptor, SciComponentColumnDescriptor, SciNumberColumnDescriptor, SciStringColumnDescriptor, SciTable, SciTableCellContext, SciTableColumnDescriptor, SciTableColumnFactory, SciTableColumnFactoryFn, SciTableColumnFilter, SciTableColumnFilterMatcherFn, SciTableColumnSortComparatorFn, SciTableColumnType, SciTableDataLoaderFn, SciTableDescriptor, SciTableEvent, SciTablePageRequest, SciTablePageResponse, SciTableRowActionFactoryFn, SciTableRowBindingFactory, SciTableRowBindingFactoryFn, SciTableSortCriterion, SciTableStorage, SciTemplateColumnDescriptor };