@tekus/design-system 5.38.1 → 5.40.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.
@@ -0,0 +1,193 @@
1
+ import * as _angular_cdk_layout from '@angular/cdk/layout';
2
+ import * as _angular_core from '@angular/core';
3
+ import { TagSeverity } from '@tekus/design-system/components/tag';
4
+
5
+ /**
6
+ * How the pairs are arranged.
7
+ *
8
+ * - `'list'`: a single vertical column at 100% width. Each item lays out
9
+ * horizontally — term on the left, value on the right — with a divider between items.
10
+ * - `'grid'`: a responsive multi-column grid with no dividers. Each item stacks
11
+ * vertically — term above value. The column count is owned by the component
12
+ * (see `DataListComponent.gridColumnCount`), not by the consumer.
13
+ */
14
+ type TkDataListLayout = 'list' | 'grid';
15
+ /**
16
+ * The closed set of value types a data list can render.
17
+ *
18
+ * This union is deliberately closed: a value is governed, typed data, not free-form
19
+ * content. Adding a type is a system-level change, never something a consumer does
20
+ * inline.
21
+ *
22
+ * It expresses the same idea as `tk-table`'s `TableColumnType` — typed values rather
23
+ * than free-form content — but the two unions are independent and only overlap on
24
+ * `'text'` and `'tag'`. Do not expect parity: `'link'` and `'number'` exist only here,
25
+ * and table's `'image'`, `'actions'`, `'checkbox'`, `'selection'`, `'action-group'` and
26
+ * `'connection-status'` exist only there. Unifying the vocabulary would be a
27
+ * system-level decision affecting both components.
28
+ */
29
+ type TkDataListValueType = 'text' | 'link' | 'tag' | 'number';
30
+ /**
31
+ * A single term→value pair rendered by `tk-data-list`.
32
+ */
33
+ interface TkDataListItem {
34
+ /** The term naming the value. Required. */
35
+ label: string;
36
+ /**
37
+ * The value to render.
38
+ *
39
+ * `null`, `undefined` and blank strings all render as the `--` placeholder,
40
+ * uniformly across every `type`. Note that `0` is a real value, not an empty one.
41
+ */
42
+ value: string | number | null | undefined;
43
+ /**
44
+ * How the value is rendered.
45
+ * @default 'text'
46
+ */
47
+ type?: TkDataListValueType;
48
+ /** An optional secondary line beneath the label. */
49
+ description?: string;
50
+ /**
51
+ * An optional icon shown in a secondary icon avatar before the label.
52
+ * Forwarded to `tk-avatar` as `variant="icon"`; decorative and hidden from
53
+ * assistive technology.
54
+ */
55
+ leadingIcon?: string;
56
+ /**
57
+ * The colour scheme of the tag. Only used when `type` is `'tag'`.
58
+ * @default 'primary'
59
+ */
60
+ tagSeverity?: TagSeverity;
61
+ /**
62
+ * Invoked when the value is activated. Required in practice for `type: 'link'`.
63
+ *
64
+ * Link values render a `tk-button` in its link variant, so they are
65
+ * action-based rather than href-based: this callback is the navigation or
66
+ * action hook. Assistive technology announces them as buttons.
67
+ *
68
+ * A `'link'` without a handler would be a button that does nothing, so it is
69
+ * rendered as plain text instead — no dead control reaches the accessibility
70
+ * tree or the tab order.
71
+ */
72
+ handler?: () => void;
73
+ }
74
+
75
+ /** Rendered in place of a value that is `null`, `undefined` or a blank string. */
76
+ declare const DATA_LIST_EMPTY_PLACEHOLDER = "--";
77
+ /**
78
+ * @component DataListComponent
79
+ * @description
80
+ * Displays a collection of read-only term→value pairs, where each value is a typed
81
+ * piece of data (text, link, tag or number). It is the pair-oriented sibling of
82
+ * `tk-table`: both render governed, typed values, but the data list presents them as
83
+ * label→value pairs instead of rows and columns. Use it for detail panels, record
84
+ * summaries and entity overviews.
85
+ *
86
+ * This component supports:
87
+ * - `items`: the pairs to render. See {@link TkDataListItem}.
88
+ * - `layout`: `'list'` (one column, dividers, term left / value right) or `'grid'`
89
+ * (responsive multi-column, no dividers, term above value).
90
+ * - `emptyPlaceholder`: the text rendered in place of an empty value.
91
+ *
92
+ * The consumer only chooses the layout. Everything that follows from it — item
93
+ * orientation, dividers and the responsive column count — is owned by the component.
94
+ * To vary the layout across breakpoints (e.g. list on mobile, grid on desktop), switch
95
+ * the `layout` input at your own breakpoint.
96
+ *
97
+ * Renders as a description list (`<dl>`) so assistive technology announces each entry
98
+ * as a term→value pair. Interactivity lives inside the value, never on the item — the
99
+ * item itself is neither focusable nor clickable.
100
+ *
101
+ * @usage
102
+ * ### Basic Usage
103
+ * ```html
104
+ * <tk-data-list [items]="details" layout="list"></tk-data-list>
105
+ * ```
106
+ * ```ts
107
+ * details: TkDataListItem[] = [
108
+ * { label: 'Owner', value: 'Ana Bermúdez' },
109
+ * { label: 'Status', value: 'Active', type: 'tag' },
110
+ * { label: 'Devices', value: 2322, type: 'number' },
111
+ * { label: 'Contract', value: 'Open', type: 'link', handler: () => this.openContract() },
112
+ * ];
113
+ * ```
114
+ */
115
+ declare class DataListComponent {
116
+ /**
117
+ * The term→value pairs to render, in order.
118
+ * @default []
119
+ */
120
+ items: _angular_core.InputSignal<TkDataListItem[]>;
121
+ /**
122
+ * How the pairs are arranged.
123
+ * @default 'list'
124
+ */
125
+ layout: _angular_core.InputSignal<TkDataListLayout>;
126
+ /**
127
+ * The text rendered in place of a value that is `null`, `undefined` or blank.
128
+ *
129
+ * Exposed as an input so it can be localised (`'N/A'`, `'Sin dato'`, …). The
130
+ * default is the system-wide placeholder.
131
+ * @default '--'
132
+ */
133
+ emptyPlaceholder: _angular_core.InputSignal<string>;
134
+ private readonly breakpointObserver;
135
+ /**
136
+ * Reactive viewport state across every breakpoint the design system defines.
137
+ *
138
+ * Grid mode sizes off the viewport rather than the component's own width, matching
139
+ * `tk-grid-container`. A consequence worth knowing: a data list inside a narrow
140
+ * drawer still reports the viewport's column count.
141
+ */
142
+ readonly screenChanges: _angular_core.Signal<_angular_cdk_layout.BreakpointState | undefined>;
143
+ /** Whether the grid layout is active. */
144
+ readonly isGrid: _angular_core.Signal<boolean>;
145
+ /**
146
+ * The number of grid columns for the current viewport.
147
+ *
148
+ * Mobile 1 · Tablet 2 · Small 2 · Normal 3 · Extra large 5. Falls back to a single
149
+ * column when the observer has not reported yet, so the first paint is mobile-first
150
+ * rather than over-wide.
151
+ */
152
+ readonly gridColumnCount: _angular_core.Signal<1 | 5 | 3 | 2>;
153
+ /**
154
+ * The `grid-template-columns` value bound on the `<dl>`, or `null` in list layout
155
+ * so the property is left off the element entirely.
156
+ *
157
+ * The track count is capped at the number of items: a data list usually holds fewer
158
+ * pairs than the viewport allows columns, and emitting the full count would leave
159
+ * empty tracks that squeeze every value into a fraction of the available width
160
+ * (e.g. three items over five tracks). Never drops below one, so an empty list still
161
+ * produces a valid value.
162
+ */
163
+ readonly gridTemplateColumns: _angular_core.Signal<string | null>;
164
+ /**
165
+ * Whether a value should render as the `--` placeholder.
166
+ *
167
+ * Applied before the type is considered, so the rule holds uniformly across every
168
+ * type. `0` and `false`-ish numbers are real values and are not treated as empty.
169
+ */
170
+ isEmpty(value: TkDataListItem['value']): boolean;
171
+ /**
172
+ * The effective value type, defaulting to `'text'`.
173
+ *
174
+ * A `'link'` with no `handler` has nothing to invoke, so it resolves to `'text'`: it
175
+ * renders as plain data instead of as a button that does nothing. That keeps a dead
176
+ * control out of the accessibility tree and the tab order entirely, which `disabled`
177
+ * would not do — and `disabled` would also claim the action merely is unavailable
178
+ * right now, which is not the case.
179
+ */
180
+ resolveType(item: TkDataListItem): TkDataListValueType;
181
+ /** The effective tag severity, defaulting to the one used in the design. */
182
+ resolveTagSeverity(item: TkDataListItem): TagSeverity;
183
+ /**
184
+ * The value as a string, for the child components that require one
185
+ * (`tk-tag.value` and `tk-button.label` are both typed `string`).
186
+ */
187
+ asText(value: TkDataListItem['value']): string;
188
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<DataListComponent, never>;
189
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<DataListComponent, "tk-data-list", never, { "items": { "alias": "items"; "required": false; "isSignal": true; }; "layout": { "alias": "layout"; "required": false; "isSignal": true; }; "emptyPlaceholder": { "alias": "emptyPlaceholder"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
190
+ }
191
+
192
+ export { DATA_LIST_EMPTY_PLACEHOLDER, DataListComponent };
193
+ export type { TkDataListItem, TkDataListLayout, TkDataListValueType };
@@ -0,0 +1,161 @@
1
+ import * as _angular_core from '@angular/core';
2
+ import { Signal, InjectionToken } from '@angular/core';
3
+ import { TagSeverity } from '@tekus/design-system/components/tag';
4
+
5
+ /**
6
+ * The feedback intent of a stat. It drives the color of the value — and only the
7
+ * value: the surface, the label, the description and the progress bar are
8
+ * identical across every severity.
9
+ */
10
+ type StatSeverity = 'secondary' | 'primary' | 'success' | 'warn' | 'danger';
11
+ /**
12
+ * How a `tk-stat-group` lays its children out.
13
+ * - `auto`: a row that collapses to a column on small screens.
14
+ * - `row`: always horizontal.
15
+ * - `column`: always vertical.
16
+ */
17
+ type StatGroupOrientation = 'auto' | 'row' | 'column';
18
+ /** The contract a `tk-stat-group` exposes to the `tk-stat` children it projects. */
19
+ interface StatGroupContext {
20
+ readonly orientation: Signal<StatGroupOrientation>;
21
+ }
22
+ /**
23
+ * Provided by `tk-stat-group`, injected optionally by `tk-stat`.
24
+ *
25
+ * This is how a stat discovers that it lives inside a group and must drop its own
26
+ * surface — the group owns the background, so the children must not paint their
27
+ * own. A stat never sets its grouped appearance itself, and a consumer never has
28
+ * to hand it down.
29
+ */
30
+ declare const TK_STAT_GROUP: InjectionToken<StatGroupContext>;
31
+
32
+ /**
33
+ * @component StatComponent
34
+ * @description
35
+ * Displays a single highlighted metric: a large dominant value, a small label above
36
+ * it, and optionally a status tag, a description and a progress bar. Used at the top
37
+ * of listings, summaries and dashboards to surface a key figure at a glance.
38
+ *
39
+ * This component supports:
40
+ * - `label` / `value`: the two required parts. The value is the dominant figure.
41
+ * - `severity`: the feedback intent. Colors the value — and nothing else.
42
+ * - `prefix` / `suffix`: small muted affixes flanking the value (e.g. `'$'`, `'/200'`).
43
+ * - `description`: a secondary line below the value.
44
+ * - `tagValue` / `tagSeverity`: a trailing tag in the header, via `tk-tag`.
45
+ * - `progress`: shows a `tk-progress-bar` below the content when set.
46
+ * - `severityLabel`: screen-reader-only text so `severity` is not color-only.
47
+ *
48
+ * There is no `grouped` input: wrapping stats in `tk-stat-group` applies the grouped
49
+ * appearance automatically.
50
+ *
51
+ * @usage
52
+ * ### Basic Usage
53
+ * ```html
54
+ * <tk-stat label="Usuarios mensuales" [value]="500" description="Audiencia estimada" />
55
+ * <tk-stat label="Slots" [value]="25" suffix="/200" [progress]="12" tagValue="Disponible" tagSeverity="success" />
56
+ * ```
57
+ */
58
+ declare class StatComponent {
59
+ /** The small title shown above the value. */
60
+ label: _angular_core.InputSignal<string>;
61
+ /**
62
+ * The dominant figure. Accepts a number or an already-formatted string
63
+ * (`'1.2K'`, `'99,9 %'`) so the consumer keeps control of formatting and locale.
64
+ */
65
+ value: _angular_core.InputSignal<string | number>;
66
+ /**
67
+ * The feedback intent of the stat, which colors the value.
68
+ * @default 'secondary'
69
+ */
70
+ severity: _angular_core.InputSignal<StatSeverity>;
71
+ /** Small muted text rendered immediately before the value (e.g. `'$'`). */
72
+ prefix: _angular_core.InputSignal<string>;
73
+ /** Small muted text rendered immediately after the value (e.g. `'/200'`, `'/GB'`). */
74
+ suffix: _angular_core.InputSignal<string>;
75
+ /** A secondary line below the value, giving context or the origin of the figure. */
76
+ description: _angular_core.InputSignal<string>;
77
+ /** The text of the trailing header tag. The tag is only rendered when this is set. */
78
+ tagValue: _angular_core.InputSignal<string>;
79
+ /**
80
+ * The severity of the trailing header tag.
81
+ * @default 'secondary'
82
+ */
83
+ tagSeverity: _angular_core.InputSignal<TagSeverity>;
84
+ /**
85
+ * The completion percentage (0-100) shown as a progress bar below the content.
86
+ * Leave `undefined` to omit the bar — `0` is a valid value and renders an empty bar.
87
+ */
88
+ progress: _angular_core.InputSignal<number | undefined>;
89
+ /**
90
+ * Screen-reader-only text describing what this stat's `severity` means (e.g.
91
+ * `'sobre la cuota'`). Set it whenever `severity` is not `'secondary'`, so the
92
+ * meaning is not carried by color alone. Saying it visibly through `tagValue` or
93
+ * `description` is usually better, since it serves sighted users too.
94
+ */
95
+ severityLabel: _angular_core.InputSignal<string>;
96
+ /**
97
+ * The group this stat is projected into, if any. Injected optionally: a standalone
98
+ * stat resolves `null` and keeps its own surface.
99
+ */
100
+ private readonly group;
101
+ /** Whether this stat is projected inside a `tk-stat-group`. */
102
+ readonly grouped: boolean;
103
+ /** Unique DOM id linking the rendered label to the host's `aria-labelledby`. */
104
+ readonly labelId: string;
105
+ /**
106
+ * Whether a progress bar should be rendered. Tests for `null`/`undefined` rather
107
+ * than truthiness so that `progress = 0` still renders an empty bar.
108
+ */
109
+ hasProgress: _angular_core.Signal<boolean>;
110
+ /** Computed host class: the BEM block plus the severity and grouped modifiers. */
111
+ hostClass: _angular_core.Signal<string>;
112
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<StatComponent, never>;
113
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<StatComponent, "tk-stat", never, { "label": { "alias": "label"; "required": true; "isSignal": true; }; "value": { "alias": "value"; "required": true; "isSignal": true; }; "severity": { "alias": "severity"; "required": false; "isSignal": true; }; "prefix": { "alias": "prefix"; "required": false; "isSignal": true; }; "suffix": { "alias": "suffix"; "required": false; "isSignal": true; }; "description": { "alias": "description"; "required": false; "isSignal": true; }; "tagValue": { "alias": "tagValue"; "required": false; "isSignal": true; }; "tagSeverity": { "alias": "tagSeverity"; "required": false; "isSignal": true; }; "progress": { "alias": "progress"; "required": false; "isSignal": true; }; "severityLabel": { "alias": "severityLabel"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
114
+ }
115
+
116
+ /**
117
+ * @component StatGroupComponent
118
+ * @description
119
+ * Wraps a row of related `tk-stat` into a single shared surface, inserting a
120
+ * separator between each pair. The group owns the background and the radius; every
121
+ * stat projected into it drops its own surface automatically, through the
122
+ * {@link TK_STAT_GROUP} token this component provides.
123
+ *
124
+ * This component supports:
125
+ * - `orientation`: `'auto'` (a row that collapses to a column on small screens),
126
+ * `'row'` or `'column'`.
127
+ * - `ariaLabel`: names the group for assistive tech. Only when set does the group
128
+ * expose `role="group"` — an unnamed group is noise.
129
+ *
130
+ * @usage
131
+ * ### Basic Usage
132
+ * ```html
133
+ * <tk-stat-group ariaLabel="Resumen de la campaña">
134
+ * <tk-stat label="Usuarios mensuales" [value]="500" description="Audiencia estimada" />
135
+ * <tk-stat label="Estado de la pantalla" [value]="500" severity="success" description="12 de 12 días" />
136
+ * <tk-stat label="Slots" [value]="25" suffix="/200" [progress]="12" />
137
+ * </tk-stat-group>
138
+ * ```
139
+ */
140
+ declare class StatGroupComponent implements StatGroupContext {
141
+ /**
142
+ * How the stats are laid out.
143
+ * - `'auto'`: horizontal, collapsing to a column on viewports narrower than a
144
+ * vertical tablet. This is the responsive default the design calls for.
145
+ * - `'row'` / `'column'`: force one direction — for a group inside a narrow
146
+ * sidebar on a wide screen, or one that must stay horizontal on mobile.
147
+ * @default 'auto'
148
+ */
149
+ orientation: _angular_core.InputSignal<StatGroupOrientation>;
150
+ /**
151
+ * The accessible name of the group. When set, the group exposes itself as
152
+ * `role="group"` with this label; when omitted it stays structurally invisible to
153
+ * assistive tech, since an unnamed group adds nothing but noise.
154
+ */
155
+ ariaLabel: _angular_core.InputSignal<string>;
156
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<StatGroupComponent, never>;
157
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<StatGroupComponent, "tk-stat-group", never, { "orientation": { "alias": "orientation"; "required": false; "isSignal": true; }; "ariaLabel": { "alias": "ariaLabel"; "required": false; "isSignal": true; }; }, {}, never, ["*"], true, never>;
158
+ }
159
+
160
+ export { StatComponent, StatGroupComponent, TK_STAT_GROUP };
161
+ export type { StatGroupContext, StatGroupOrientation, StatSeverity };
@@ -4,7 +4,7 @@ import { TagSeverity } from '@tekus/design-system/components/tag';
4
4
  import { SortEvent } from 'primeng/api';
5
5
  import { TkAction } from '@tekus/design-system/components/action-group';
6
6
 
7
- type TableColumnType = 'text' | 'tag' | 'actions' | 'selection' | 'checkbox' | 'action-group' | 'connection-status' | 'image';
7
+ type TableColumnType = 'text' | 'tag' | 'actions' | 'selection' | 'checkbox' | 'action-group' | 'connection-status' | 'image' | 'counter';
8
8
  interface TableColumn<T = unknown> {
9
9
  field?: string;
10
10
  header: string;
@@ -32,6 +32,19 @@ interface TableColumn<T = unknown> {
32
32
  imageHeight?: string;
33
33
  imageFallback?: string;
34
34
  imageAction?: (row: T) => void;
35
+ counterMin?: number;
36
+ counterMax?: number;
37
+ counterStep?: number;
38
+ counterDisabled?: boolean | ((row: T) => boolean);
39
+ /** Accessible name for the cell's counter. Falls back to the column `header`. */
40
+ counterAriaLabel?: (row: T) => string;
41
+ counterDecreaseLabel?: string;
42
+ counterIncreaseLabel?: string;
43
+ /**
44
+ * Called after the cell has written the clamped value into `row[field]`.
45
+ * The hook to persist a quantity change.
46
+ */
47
+ counterChange?: (row: T, value: number) => void;
35
48
  }
36
49
 
37
50
  declare class TableComponent<T = unknown> {
@@ -215,6 +228,27 @@ declare class TableComponent<T = unknown> {
215
228
  * @param row {T} - The data row associated with the clicked image.
216
229
  */
217
230
  handleImageClick(event: Event, col: TableColumn<T>, row: T): void;
231
+ /**
232
+ * @method isCounterDisabled
233
+ * @description
234
+ * Resolves a counter column's `counterDisabled`, which may be a boolean or a
235
+ * per-row predicate — the same shape `getActionGroup` already accepts.
236
+ * @param col {TableColumn<T>} - The counter column definition.
237
+ * @param row {T} - The data row being rendered.
238
+ * @returns Whether this row's counter should be disabled.
239
+ */
240
+ isCounterDisabled(col: TableColumn<T>, row: T): boolean;
241
+ /**
242
+ * @method onCounterChange
243
+ * @description
244
+ * Writes a counter cell's new value into the row and notifies the consumer.
245
+ * The value arrives already clamped into the column's range by `tk-counter`.
246
+ * Mutating the row in place matches how the `checkbox` column type behaves.
247
+ * @param col {TableColumn<T>} - The counter column definition.
248
+ * @param row {T} - The data row being edited.
249
+ * @param value {number} - The new, clamped value.
250
+ */
251
+ onCounterChange(col: TableColumn<T>, row: T, value: number): void;
218
252
  /**
219
253
  * @method onImageError
220
254
  * @description