@tekus/design-system 5.40.0 → 5.41.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.
@@ -1,10 +1,12 @@
1
1
  import * as _angular_core from '@angular/core';
2
2
  import { Table } from 'primeng/table';
3
3
  import { TagSeverity } from '@tekus/design-system/components/tag';
4
+ import { BadgeSeverity } from '@tekus/design-system/components/badge';
5
+ import { IconColors } from '@tekus/design-system/components/icon';
4
6
  import { SortEvent } from 'primeng/api';
5
7
  import { TkAction } from '@tekus/design-system/components/action-group';
6
8
 
7
- type TableColumnType = 'text' | 'tag' | 'actions' | 'selection' | 'checkbox' | 'action-group' | 'connection-status' | 'image' | 'counter';
9
+ type TableColumnType = 'text' | 'tag' | 'actions' | 'selection' | 'checkbox' | 'action-group' | 'connection-status' | 'image' | 'counter' | 'toggle';
8
10
  interface TableColumn<T = unknown> {
9
11
  field?: string;
10
12
  header: string;
@@ -12,6 +14,19 @@ interface TableColumn<T = unknown> {
12
14
  filterable?: boolean;
13
15
  type?: TableColumnType;
14
16
  width?: string;
17
+ /**
18
+ * Icon rendered before the value of a `'text'` (or default) cell.
19
+ * Uses the design system's IconCatalog names (same as `tk-icon`).
20
+ */
21
+ icon?: (row: T) => string;
22
+ /** Color of `icon`. Falls back to `tk-icon`'s own default. */
23
+ iconColor?: (row: T) => IconColors;
24
+ /**
25
+ * Truncates a `'text'` (or default) cell with an ellipsis instead of
26
+ * overflowing or wrapping. Uses `width` as the truncation point,
27
+ * falling back to `200px` when `width` is not set.
28
+ */
29
+ truncate?: boolean;
15
30
  tagSeverity?: (row: T) => TagSeverity;
16
31
  connectionStatusSeverity?: (row: T) => 'success' | 'warn' | 'danger' | 'gray';
17
32
  connectionStatusTooltipText?: (row: T) => string;
@@ -32,6 +47,17 @@ interface TableColumn<T = unknown> {
32
47
  imageHeight?: string;
33
48
  imageFallback?: string;
34
49
  imageAction?: (row: T) => void;
50
+ /**
51
+ * Total number of images available for the row (e.g. multiple evidence shots
52
+ * behind one thumbnail). When it resolves to more than 1, the cell overlays
53
+ * a `tk-badge` on the top-right corner of the thumbnail showing the count.
54
+ */
55
+ imageCount?: (row: T) => number;
56
+ /**
57
+ * Severity (color) of the `imageCount` overlay badge.
58
+ * @default 'primary'
59
+ */
60
+ imageCountSeverity?: (row: T) => BadgeSeverity;
35
61
  counterMin?: number;
36
62
  counterMax?: number;
37
63
  counterStep?: number;
@@ -45,6 +71,19 @@ interface TableColumn<T = unknown> {
45
71
  * The hook to persist a quantity change.
46
72
  */
47
73
  counterChange?: (row: T, value: number) => void;
74
+ toggleDisabled?: boolean | ((row: T) => boolean);
75
+ /** Optional label rendered next to the switch. Falls back to no label. */
76
+ toggleLabel?: (row: T) => string;
77
+ /**
78
+ * Called after the cell has written the new value into `row[field]`.
79
+ * The hook to persist a toggle change.
80
+ */
81
+ toggleChange?: (row: T, value: boolean) => void;
82
+ /**
83
+ * Tooltip text identifying the switch's current state, wrapping it in a
84
+ * `tk-tooltip`. Receives the row and the current (pre-toggle) value.
85
+ */
86
+ toggleTooltip?: (row: T, value: boolean) => string;
48
87
  }
49
88
 
50
89
  declare class TableComponent<T = unknown> {
@@ -104,6 +143,16 @@ declare class TableComponent<T = unknown> {
104
143
  * Property name to uniquely identify a row.
105
144
  */
106
145
  dataKey: _angular_core.InputSignal<string | undefined>;
146
+ /**
147
+ * @property {InputSignal<string | null>} minTableWidth
148
+ * @description
149
+ * CSS `min-width` applied to the underlying PrimeNG table. Pass `null` to
150
+ * remove the minimum entirely (e.g. inside a narrow container such as a
151
+ * wizard step or modal) so the table can shrink to fit instead of forcing
152
+ * horizontal overflow.
153
+ * @default '60rem'
154
+ */
155
+ minTableWidth: _angular_core.InputSignal<string | null>;
107
156
  readonly initialData: _angular_core.WritableSignal<T[]>;
108
157
  readonly internalData: _angular_core.WritableSignal<T[]>;
109
158
  readonly isSorted: _angular_core.WritableSignal<boolean | null>;
@@ -249,6 +298,36 @@ declare class TableComponent<T = unknown> {
249
298
  * @param value {number} - The new, clamped value.
250
299
  */
251
300
  onCounterChange(col: TableColumn<T>, row: T, value: number): void;
301
+ /**
302
+ * @method isToggleDisabled
303
+ * @description
304
+ * Resolves a toggle column's `toggleDisabled`, which may be a boolean or a
305
+ * per-row predicate — the same shape `isCounterDisabled` already accepts.
306
+ * @param col {TableColumn<T>} - The toggle column definition.
307
+ * @param row {T} - The data row being rendered.
308
+ * @returns Whether this row's toggle should be disabled.
309
+ */
310
+ isToggleDisabled(col: TableColumn<T>, row: T): boolean;
311
+ /**
312
+ * @method onToggleChange
313
+ * @description
314
+ * Writes a toggle cell's new value into the row and notifies the consumer.
315
+ * Mutating the row in place matches how the `checkbox` column type behaves.
316
+ * @param col {TableColumn<T>} - The toggle column definition.
317
+ * @param row {T} - The data row being edited.
318
+ * @param value {boolean} - The new switch value.
319
+ */
320
+ onToggleChange(col: TableColumn<T>, row: T, value: boolean): void;
321
+ /**
322
+ * @method getImageCount
323
+ * @description
324
+ * Resolves how many images are available for an image-type cell via the
325
+ * column's `imageCount` callback. Returns 0 when not configured, so the
326
+ * template only overlays a `tk-badge` when there is more than one image.
327
+ * @param col {TableColumn<T>} - The image column definition.
328
+ * @param row {T} - The data row being rendered.
329
+ */
330
+ getImageCount(col: TableColumn<T>, row: T): number;
252
331
  /**
253
332
  * @method onImageError
254
333
  * @description
@@ -259,7 +338,7 @@ declare class TableComponent<T = unknown> {
259
338
  */
260
339
  onImageError(event: Event, fallback?: string): void;
261
340
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<TableComponent<any>, never>;
262
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<TableComponent<any>, "tk-table", never, { "data": { "alias": "data"; "required": false; "isSignal": true; }; "columns": { "alias": "columns"; "required": false; "isSignal": true; }; "selectionMode": { "alias": "selectionMode"; "required": false; "isSignal": true; }; "selection": { "alias": "selection"; "required": false; "isSignal": true; }; "dataKey": { "alias": "dataKey"; "required": false; "isSignal": true; }; "columnFilters": { "alias": "columnFilters"; "required": false; "isSignal": true; }; "sortField": { "alias": "sortField"; "required": false; "isSignal": true; }; "sortOrder": { "alias": "sortOrder"; "required": false; "isSignal": true; }; }, { "selection": "selectionChange"; "columnFilters": "columnFiltersChange"; "sortField": "sortFieldChange"; "sortOrder": "sortOrderChange"; }, never, never, true, never>;
341
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<TableComponent<any>, "tk-table", never, { "data": { "alias": "data"; "required": false; "isSignal": true; }; "columns": { "alias": "columns"; "required": false; "isSignal": true; }; "selectionMode": { "alias": "selectionMode"; "required": false; "isSignal": true; }; "selection": { "alias": "selection"; "required": false; "isSignal": true; }; "dataKey": { "alias": "dataKey"; "required": false; "isSignal": true; }; "minTableWidth": { "alias": "minTableWidth"; "required": false; "isSignal": true; }; "columnFilters": { "alias": "columnFilters"; "required": false; "isSignal": true; }; "sortField": { "alias": "sortField"; "required": false; "isSignal": true; }; "sortOrder": { "alias": "sortOrder"; "required": false; "isSignal": true; }; }, { "selection": "selectionChange"; "columnFilters": "columnFiltersChange"; "sortField": "sortFieldChange"; "sortOrder": "sortOrderChange"; }, never, never, true, never>;
263
342
  }
264
343
 
265
344
  export { TableComponent };