shirkasoft-ui-components 1.14.0 → 2.0.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.
Files changed (92) hide show
  1. package/README.md +4 -8
  2. package/fesm2022/shirkasoft-ui-components-breadcrumb.mjs +189 -100
  3. package/fesm2022/shirkasoft-ui-components-breadcrumb.mjs.map +1 -1
  4. package/fesm2022/shirkasoft-ui-components-button.mjs +363 -69
  5. package/fesm2022/shirkasoft-ui-components-button.mjs.map +1 -1
  6. package/fesm2022/shirkasoft-ui-components-chart.mjs +206 -142
  7. package/fesm2022/shirkasoft-ui-components-chart.mjs.map +1 -1
  8. package/fesm2022/shirkasoft-ui-components-config.mjs +905 -843
  9. package/fesm2022/shirkasoft-ui-components-config.mjs.map +1 -1
  10. package/fesm2022/shirkasoft-ui-components-confirm-dialog.mjs +307 -142
  11. package/fesm2022/shirkasoft-ui-components-confirm-dialog.mjs.map +1 -1
  12. package/fesm2022/shirkasoft-ui-components-date-picker.mjs +1624 -1440
  13. package/fesm2022/shirkasoft-ui-components-date-picker.mjs.map +1 -1
  14. package/fesm2022/shirkasoft-ui-components-fieldset.mjs +347 -92
  15. package/fesm2022/shirkasoft-ui-components-fieldset.mjs.map +1 -1
  16. package/fesm2022/shirkasoft-ui-components-file-upload.mjs +484 -300
  17. package/fesm2022/shirkasoft-ui-components-file-upload.mjs.map +1 -1
  18. package/fesm2022/shirkasoft-ui-components-icons.mjs +1028 -533
  19. package/fesm2022/shirkasoft-ui-components-icons.mjs.map +1 -1
  20. package/fesm2022/shirkasoft-ui-components-knob.mjs +389 -201
  21. package/fesm2022/shirkasoft-ui-components-knob.mjs.map +1 -1
  22. package/fesm2022/shirkasoft-ui-components-loading.mjs +505 -128
  23. package/fesm2022/shirkasoft-ui-components-loading.mjs.map +1 -1
  24. package/fesm2022/shirkasoft-ui-components-modal.mjs +311 -314
  25. package/fesm2022/shirkasoft-ui-components-modal.mjs.map +1 -1
  26. package/fesm2022/shirkasoft-ui-components-notification.mjs +188 -142
  27. package/fesm2022/shirkasoft-ui-components-notification.mjs.map +1 -1
  28. package/fesm2022/shirkasoft-ui-components-price-input.mjs +517 -327
  29. package/fesm2022/shirkasoft-ui-components-price-input.mjs.map +1 -1
  30. package/fesm2022/shirkasoft-ui-components-rail-sidebar.mjs +669 -289
  31. package/fesm2022/shirkasoft-ui-components-rail-sidebar.mjs.map +1 -1
  32. package/fesm2022/shirkasoft-ui-components-select.mjs +1014 -819
  33. package/fesm2022/shirkasoft-ui-components-select.mjs.map +1 -1
  34. package/fesm2022/shirkasoft-ui-components-sidebar.mjs +508 -184
  35. package/fesm2022/shirkasoft-ui-components-sidebar.mjs.map +1 -1
  36. package/fesm2022/shirkasoft-ui-components-skeleton.mjs +197 -57
  37. package/fesm2022/shirkasoft-ui-components-skeleton.mjs.map +1 -1
  38. package/fesm2022/shirkasoft-ui-components-table.mjs +1916 -1698
  39. package/fesm2022/shirkasoft-ui-components-table.mjs.map +1 -1
  40. package/fesm2022/shirkasoft-ui-components-tabs.mjs +419 -175
  41. package/fesm2022/shirkasoft-ui-components-tabs.mjs.map +1 -1
  42. package/fesm2022/shirkasoft-ui-components-tag.mjs +175 -49
  43. package/fesm2022/shirkasoft-ui-components-tag.mjs.map +1 -1
  44. package/fesm2022/shirkasoft-ui-components-text-field.mjs +687 -402
  45. package/fesm2022/shirkasoft-ui-components-text-field.mjs.map +1 -1
  46. package/fesm2022/shirkasoft-ui-components-theme-picker.mjs +310 -124
  47. package/fesm2022/shirkasoft-ui-components-theme-picker.mjs.map +1 -1
  48. package/fesm2022/shirkasoft-ui-components-theme.mjs +141 -174
  49. package/fesm2022/shirkasoft-ui-components-theme.mjs.map +1 -1
  50. package/fesm2022/shirkasoft-ui-components-timeline.mjs +791 -203
  51. package/fesm2022/shirkasoft-ui-components-timeline.mjs.map +1 -1
  52. package/fesm2022/shirkasoft-ui-components-toggle.mjs +179 -109
  53. package/fesm2022/shirkasoft-ui-components-toggle.mjs.map +1 -1
  54. package/fesm2022/shirkasoft-ui-components-tooltip.mjs +244 -180
  55. package/fesm2022/shirkasoft-ui-components-tooltip.mjs.map +1 -1
  56. package/fesm2022/shirkasoft-ui-components-utils.mjs +95 -134
  57. package/fesm2022/shirkasoft-ui-components-utils.mjs.map +1 -1
  58. package/fesm2022/shirkasoft-ui-components-wizard.mjs +673 -165
  59. package/fesm2022/shirkasoft-ui-components-wizard.mjs.map +1 -1
  60. package/fesm2022/shirkasoft-ui-components.mjs +0 -9
  61. package/package.json +5 -5
  62. package/types/shirkasoft-ui-components-breadcrumb.d.ts +59 -44
  63. package/types/shirkasoft-ui-components-button.d.ts +142 -49
  64. package/types/shirkasoft-ui-components-chart.d.ts +59 -44
  65. package/types/shirkasoft-ui-components-config.d.ts +193 -204
  66. package/types/shirkasoft-ui-components-confirm-dialog.d.ts +107 -66
  67. package/types/shirkasoft-ui-components-date-picker.d.ts +527 -398
  68. package/types/shirkasoft-ui-components-fieldset.d.ts +135 -60
  69. package/types/shirkasoft-ui-components-file-upload.d.ts +176 -112
  70. package/types/shirkasoft-ui-components-icons.d.ts +1302 -1294
  71. package/types/shirkasoft-ui-components-knob.d.ts +144 -78
  72. package/types/shirkasoft-ui-components-loading.d.ts +155 -64
  73. package/types/shirkasoft-ui-components-modal.d.ts +134 -136
  74. package/types/shirkasoft-ui-components-notification.d.ts +63 -59
  75. package/types/shirkasoft-ui-components-price-input.d.ts +198 -113
  76. package/types/shirkasoft-ui-components-rail-sidebar.d.ts +262 -142
  77. package/types/shirkasoft-ui-components-select.d.ts +301 -196
  78. package/types/shirkasoft-ui-components-sidebar.d.ts +198 -93
  79. package/types/shirkasoft-ui-components-skeleton.d.ts +68 -27
  80. package/types/shirkasoft-ui-components-table.d.ts +849 -660
  81. package/types/shirkasoft-ui-components-tabs.d.ts +102 -61
  82. package/types/shirkasoft-ui-components-tag.d.ts +54 -23
  83. package/types/shirkasoft-ui-components-text-field.d.ts +231 -127
  84. package/types/shirkasoft-ui-components-theme-picker.d.ts +92 -58
  85. package/types/shirkasoft-ui-components-theme.d.ts +56 -64
  86. package/types/shirkasoft-ui-components-timeline.d.ts +325 -150
  87. package/types/shirkasoft-ui-components-toggle.d.ts +73 -49
  88. package/types/shirkasoft-ui-components-tooltip.d.ts +64 -43
  89. package/types/shirkasoft-ui-components-utils.d.ts +15 -16
  90. package/types/shirkasoft-ui-components-wizard.d.ts +236 -87
  91. package/types/shirkasoft-ui-components.d.ts +1 -2
  92. package/fesm2022/shirkasoft-ui-components.mjs.map +0 -1
@@ -1,1706 +1,1924 @@
1
- import * as i0 from '@angular/core';
2
- import { inject, ChangeDetectorRef, DestroyRef, Injector, input, model, output, signal, linkedSignal, computed, afterEveryRender, effect, untracked, afterNextRender, HostListener, ChangeDetectionStrategy, Component } from '@angular/core';
3
- import * as i1 from '@angular/common';
4
- import { CommonModule } from '@angular/common';
5
- import { toSignal, takeUntilDestroyed } from '@angular/core/rxjs-interop';
6
- import * as i2 from '@jsverse/transloco';
7
- import { TranslocoService, TranslocoModule } from '@jsverse/transloco';
8
- import { Subject, debounceTime } from 'rxjs';
9
- import { LucidePlus, LucideOctagonAlert, LucideTriangleAlert, LucideInfo, LucideTrash2, LucideCircleX, LucideCircleCheck, LucideFunnelX, ShkIconDirective } from 'shirkasoft-ui-components/icons';
10
- import { TagComponent } from 'shirkasoft-ui-components/tag';
11
- import { TooltipComponent } from 'shirkasoft-ui-components/tooltip';
12
- import { getIcon, isIconResolver, PortalDirective } from 'shirkasoft-ui-components/utils';
13
- import { ShkConfigService, formatDateStyle, resolveDateFormat, formatDate, formatCurrency } from 'shirkasoft-ui-components/config';
14
-
15
- /** Match modes offered by each filter kind that has a match mode selector. */
1
+ import * as i0 from "@angular/core";
2
+ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, DestroyRef, HostListener, Injector, afterEveryRender, afterNextRender, computed, effect, inject, input, linkedSignal, model, output, signal, untracked } from "@angular/core";
3
+ import * as i1 from "@angular/common";
4
+ import { CommonModule } from "@angular/common";
5
+ import { takeUntilDestroyed, toSignal } from "@angular/core/rxjs-interop";
6
+ import * as i2 from "@jsverse/transloco";
7
+ import { TranslocoModule, TranslocoService } from "@jsverse/transloco";
8
+ import { Subject, debounceTime } from "rxjs";
9
+ import { LucideCircleCheck, LucideCircleX, LucideFunnelX, LucideInfo, LucideOctagonAlert, LucidePlus, LucideTrash2, LucideTriangleAlert, ShkIconDirective } from "shirkasoft-ui-components/icons";
10
+ import { TagComponent } from "shirkasoft-ui-components/tag";
11
+ import { TooltipComponent } from "shirkasoft-ui-components/tooltip";
12
+ import { PortalDirective, getIcon, isIconResolver } from "shirkasoft-ui-components/utils";
13
+ import { ShkConfigService, formatCurrency, formatDate, formatDateStyle, resolveDateFormat } from "shirkasoft-ui-components/config";
16
14
  const MATCH_MODES = {
17
- text: ['startsWith', 'contains', 'notContains', 'endsWith', 'equals', 'notEquals'],
18
- numeric: ['equals', 'notEquals', 'lt', 'lte', 'gt', 'gte'],
19
- date: ['dateIs', 'dateIsNot', 'dateBefore', 'dateAfter'],
15
+ text: [
16
+ "startsWith",
17
+ "contains",
18
+ "notContains",
19
+ "endsWith",
20
+ "equals",
21
+ "notEquals"
22
+ ],
23
+ numeric: [
24
+ "equals",
25
+ "notEquals",
26
+ "lt",
27
+ "lte",
28
+ "gt",
29
+ "gte"
30
+ ],
31
+ date: [
32
+ "dateIs",
33
+ "dateIsNot",
34
+ "dateBefore",
35
+ "dateAfter"
36
+ ]
20
37
  };
21
- /** Fallback labels used when the `table.filter.*` translations are missing. */
22
38
  const FILTER_LABELS = {
23
- startsWith: 'Empieza con',
24
- contains: 'Contiene',
25
- notContains: 'No contiene',
26
- endsWith: 'Termina con',
27
- equals: 'Igual a',
28
- notEquals: 'Distinto de',
29
- lt: 'Menor que',
30
- lte: 'Menor o igual que',
31
- gt: 'Mayor que',
32
- gte: 'Mayor o igual que',
33
- dateIs: 'La fecha es',
34
- dateIsNot: 'La fecha no es',
35
- dateBefore: 'La fecha es anterior a',
36
- dateAfter: 'La fecha es posterior a',
37
- matchAll: 'Coincidir todas',
38
- matchAny: 'Coincidir alguna',
39
- addRule: 'Agregar regla',
40
- removeRule: 'Quitar regla',
41
- apply: 'Aplicar',
42
- clear: 'Limpiar',
43
- any: 'Cualquiera',
44
- selectedCount: '{{count}} seleccionados',
45
- yes: 'Sí',
46
- no: 'No',
39
+ startsWith: "Empieza con",
40
+ contains: "Contiene",
41
+ notContains: "No contiene",
42
+ endsWith: "Termina con",
43
+ equals: "Igual a",
44
+ notEquals: "Distinto de",
45
+ lt: "Menor que",
46
+ lte: "Menor o igual que",
47
+ gt: "Mayor que",
48
+ gte: "Mayor o igual que",
49
+ dateIs: "La fecha es",
50
+ dateIsNot: "La fecha no es",
51
+ dateBefore: "La fecha es anterior a",
52
+ dateAfter: "La fecha es posterior a",
53
+ matchAll: "Coincidir todas",
54
+ matchAny: "Coincidir alguna",
55
+ addRule: "Agregar regla",
56
+ removeRule: "Quitar regla",
57
+ apply: "Aplicar",
58
+ clear: "Limpiar",
59
+ any: "Cualquiera",
60
+ selectedCount: "{{count}} seleccionados",
61
+ yes: "Sí",
62
+ no: "No"
47
63
  };
48
- /**
49
- * Shirkasoft UI Components.
50
- * Authors: Roberto Valladares Martin (Ansem13), Julio César García García (Sanjuli14).
51
- * Belongs to Shirkasoft.
52
- */
53
- /** Counter used to generate unique element ids per table instance. */
54
- /**
55
- * Angular `DatePipe` named formats accepted in `Column.dateFormat`:
56
- * `[dateStyle, timeStyle?]` rendered with `Intl`.
57
- */
58
64
  const NAMED_DATE_STYLES = {
59
- shortDate: ['short'],
60
- mediumDate: ['medium'],
61
- longDate: ['long'],
62
- fullDate: ['full'],
63
- short: ['short', 'short'],
64
- medium: ['medium', 'medium'],
65
- long: ['long', 'long'],
66
- full: ['full', 'full'],
65
+ shortDate: ["short"],
66
+ mediumDate: ["medium"],
67
+ longDate: ["long"],
68
+ fullDate: ["full"],
69
+ short: ["short", "short"],
70
+ medium: ["medium", "medium"],
71
+ long: ["long", "long"],
72
+ full: ["full", "full"]
67
73
  };
68
74
  let nextTableId = 0;
69
- /**
70
- * Data table with sorting, column filter menus (match modes,
71
- * multiple rules, typed filters), global search, pagination, row/header
72
- * actions, tag/progress/boolean cells and optional server-side mode.
73
- */
74
- class TableComponent {
75
- /** Returns the effective CSS width for a column ('actions' included). */
76
- getColumnWidth(col) {
77
- return this.resizedWidth(col) || col.width || this.DEFAULT_COLUMN_WIDTH;
78
- }
79
- /** Evaluates the rules against a row and returns its violations (messages already translated). */
80
- collectViolations(row, entries = Object.entries(this.rowValidations())) {
81
- const violations = [];
82
- for (const [field, rule] of entries) {
83
- if (!rule || typeof rule.condition !== 'function')
84
- continue;
85
- const value = this.resolveField(row, field);
86
- let failed = false;
87
- try {
88
- failed = !!rule.condition(value, row);
89
- }
90
- catch {
91
- failed = false;
92
- }
93
- if (!failed)
94
- continue;
95
- violations.push({
96
- field,
97
- severity: rule.severity ?? 'critical',
98
- message: this.resolveViolationMessage(rule, value, row),
99
- });
100
- }
101
- return violations;
102
- }
103
- /** Message of a rule: translated when `message` is a registered key, literal otherwise. */
104
- resolveViolationMessage(rule, value, row) {
105
- if (!rule.message)
106
- return undefined;
107
- return this.tr(rule.message, rule.message, rule.messageParams?.(value, row));
108
- }
109
- /** Violations of a row (empty when it has no issues). */
110
- rowViolationsOf(row) {
111
- return this.violationsByRow().get(row) ?? this.collectViolations(row);
112
- }
113
- /**
114
- * Highest severity of a row: `'critical'` > `'moderate'` > `'low'`, or `null`
115
- * when the row has no issues.
116
- */
117
- rowSeverity(row) {
118
- let severity = null;
119
- for (const violation of this.rowViolationsOf(row)) {
120
- if (!severity || this.severityRank[violation.severity] > this.severityRank[severity]) {
121
- severity = violation.severity;
122
- }
123
- }
124
- return severity;
125
- }
126
- /**
127
- * Checks any object (e.g. the payload of a modal) against `rowValidations`,
128
- * returning its violations (empty = no issues). The row doesn't need to be
129
- * displayed, so it can be used before adding it.
130
- */
131
- validateRow(row) {
132
- return this.collectViolations(row);
133
- }
134
- /** Tooltip of a row: its violation messages, one per line. */
135
- rowValidationTitle(row) {
136
- const messages = this.rowViolationsOf(row)
137
- .map((violation) => violation.message)
138
- .filter((message) => !!message);
139
- return messages.length ? messages.join('\n') : null;
140
- }
141
- /** Icon of the severity indicator shown in the actions cell. */
142
- rowValidationIcon(row) {
143
- const severity = this.rowSeverity(row);
144
- return severity ? this.icons[severity] : this.icons.low;
145
- }
146
- /** Accessible label of the severity indicator (the messages, or the severity). */
147
- rowValidationLabel(row) {
148
- const title = this.rowValidationTitle(row);
149
- if (title)
150
- return title;
151
- const severity = this.rowSeverity(row);
152
- const fallbacks = {
153
- low: 'Fila con observaciones',
154
- moderate: 'Fila con advertencias',
155
- critical: 'Fila con errores',
156
- };
157
- return severity
158
- ? this.tr(`table.severity.${severity}`, fallbacks[severity])
159
- : '';
160
- }
161
- constructor() {
162
- /** Unique id prefix so several tables on the same page don't share element ids. */
163
- this.uid = `shk-table-${nextTableId++}`;
164
- this.cdr = inject(ChangeDetectorRef);
165
- this.transloco = inject(TranslocoService);
166
- /** Library-wide options: default date pattern, locale and currency of the cells. */
167
- this.config = inject(ShkConfigService);
168
- this.destroyRef = inject(DestroyRef);
169
- this.injector = inject(Injector);
170
- /** Maps icon names to SVG data, falling back to a plus icon. */
171
- this.getIcon = (name) => getIcon(name, LucidePlus);
172
- /** Icons used directly by the template (not part of the central map). */
173
- this.icons = {
174
- clear: LucideFunnelX,
175
- yes: LucideCircleCheck,
176
- no: LucideCircleX,
177
- trash: LucideTrash2,
178
- low: LucideInfo,
179
- moderate: LucideTriangleAlert,
180
- critical: LucideOctagonAlert,
181
- };
182
- /**
183
- * Minimum width applied to each column (except `actions`, which keeps its
184
- * own computed width) only on narrow screens. On wide screens columns
185
- * stretch normally to fill the container width. Can be overridden per
186
- * column via `col.width`.
187
- */
188
- this.DEFAULT_COLUMN_WIDTH = '140px';
189
- /** Signal with the translated "Actions" header label. */
190
- this.actionsHeaderLabel = toSignal(this.transloco.selectTranslate('common.actions'), {
191
- initialValue: 'Acciones',
192
- });
193
- /** Signal reacting to language changes so imperative translations are recomputed. */
194
- this.currentLang = toSignal(this.transloco.langChanges$, {
195
- initialValue: this.transloco.getActiveLang(),
196
- });
197
- /** Reactive signal of loaded translations so pageReport is not stuck with raw keys. */
198
- this.translations = toSignal(this.transloco.selectTranslation());
199
- /** Full dataset. In server-side mode only the current page rows. */
200
- this.data = input([], ...(ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []));
201
- /** Column definitions (field, header, filterable, tag cell options, etc.). */
202
- this.columns = input([], ...(ngDevMode ? [{ debugName: "columns" }] : /* istanbul ignore next */ []));
203
- /** Number of rows displayed per page. */
204
- this.rowsPerPage = input(10, ...(ngDevMode ? [{ debugName: "rowsPerPage" }] : /* istanbul ignore next */ []));
205
- /** Options shown in the rows-per-page selector. */
206
- this.rowsPerPageOptions = input([10, 25, 50], ...(ngDevMode ? [{ debugName: "rowsPerPageOptions" }] : /* istanbul ignore next */ []));
207
- /** Whether the table is in loading state (shows the overlay/skeleton). */
208
- this.loading = input(false, ...(ngDevMode ? [{ debugName: "loading" }] : /* istanbul ignore next */ []));
209
- /** Whether to render the row actions column. */
210
- this.showActionRow = input(true, ...(ngDevMode ? [{ debugName: "showActionRow" }] : /* istanbul ignore next */ []));
211
- /** Custom cell/header templates keyed by column field. */
212
- this.customTemplates = input({}, ...(ngDevMode ? [{ debugName: "customTemplates" }] : /* istanbul ignore next */ []));
213
- /** Actions rendered in the table header. */
214
- this.headerActions = input([], ...(ngDevMode ? [{ debugName: "headerActions" }] : /* istanbul ignore next */ []));
215
- /** Actions rendered per row (icon, label, class, visibility/disabled). */
216
- this.rowActions = input([], ...(ngDevMode ? [{ debugName: "rowActions" }] : /* istanbul ignore next */ []));
217
- /** Whether the table container renders a drop shadow. */
218
- this.hasShadow = input(true, ...(ngDevMode ? [{ debugName: "hasShadow" }] : /* istanbul ignore next */ []));
219
- /** Field used as the default initial sort. */
220
- this.defaultSortField = input('', ...(ngDevMode ? [{ debugName: "defaultSortField" }] : /* istanbul ignore next */ []));
221
- /** Order used by the default initial sort (1 asc, -1 desc). */
222
- this.defaultSortOrder = input(1, ...(ngDevMode ? [{ debugName: "defaultSortOrder" }] : /* istanbul ignore next */ []));
223
- /** Whether the global search input is shown. */
224
- this.showSearch = input(true, ...(ngDevMode ? [{ debugName: "showSearch" }] : /* istanbul ignore next */ []));
225
- /** Placeholder for the global search input. */
226
- this.searchPlaceholder = input('', ...(ngDevMode ? [{ debugName: "searchPlaceholder" }] : /* istanbul ignore next */ []));
227
- /**
228
- * Fields (dot paths allowed) searched by the global search. When empty,
229
- * every primitive top-level value of the row is searched.
230
- */
231
- this.globalFilterFields = input([], ...(ngDevMode ? [{ debugName: "globalFilterFields" }] : /* istanbul ignore next */ []));
232
- /** Message shown when there are no rows. */
233
- this.emptyMessage = input('', ...(ngDevMode ? [{ debugName: "emptyMessage" }] : /* istanbul ignore next */ []));
234
- /** Enables server-side pagination/filtering/sorting mode. */
235
- this.serverSide = input(false, ...(ngDevMode ? [{ debugName: "serverSide" }] : /* istanbul ignore next */ []));
236
- /** Total number of records in server-side mode (for pagination math). */
237
- this.totalRecords = input(0, ...(ngDevMode ? [{ debugName: "totalRecords" }] : /* istanbul ignore next */ []));
238
- /** Optional prebuilt filter chips (label + value) shown above the table. */
239
- this.filters = input([], ...(ngDevMode ? [{ debugName: "filters" }] : /* istanbul ignore next */ []));
240
- /** Currently active filter chip value. */
241
- this.activeFilter = input('', ...(ngDevMode ? [{ debugName: "activeFilter" }] : /* istanbul ignore next */ []));
242
- /** Draws vertical lines between columns (grid look). */
243
- this.showGridlines = input(false, ...(ngDevMode ? [{ debugName: "showGridlines" }] : /* istanbul ignore next */ []));
244
- /**
245
- * With `showGridlines`, lets the user widen/narrow columns by dragging the
246
- * header border (double click resets, arrow keys adjust).
247
- */
248
- this.resizableColumns = input(true, ...(ngDevMode ? [{ debugName: "resizableColumns" }] : /* istanbul ignore next */ []));
249
- /**
250
- * Rules to flag rows with problems, keyed by field of the payload. Each rule
251
- * applies a condition to the value of that field and paints the whole row:
252
- * `low` blue, `moderate` amber, `critical` red. When a row has several
253
- * issues the worst severity wins. See `RowValidation`.
254
- */
255
- this.rowValidations = input({}, ...(ngDevMode ? [{ debugName: "rowValidations" }] : /* istanbul ignore next */ []));
256
- /**
257
- * Column widths (px) keyed by field. Two-way bindable via
258
- * `[(columnWidths)]` to restore/save them yourself.
259
- */
260
- this.columnWidths = model({}, ...(ngDevMode ? [{ debugName: "columnWidths" }] : /* istanbul ignore next */ []));
261
- /**
262
- * When set, column widths are saved in the browser storage under this key
263
- * and restored on load (they take precedence over `columnWidths`).
264
- */
265
- this.stateKey = input('', ...(ngDevMode ? [{ debugName: "stateKey" }] : /* istanbul ignore next */ []));
266
- /** Storage used with `stateKey`. */
267
- this.stateStorage = input('local', ...(ngDevMode ? [{ debugName: "stateStorage" }] : /* istanbul ignore next */ []));
268
- /** Highlights the row under the pointer. */
269
- this.rowHover = input(true, ...(ngDevMode ? [{ debugName: "rowHover" }] : /* istanbul ignore next */ []));
270
- /** Shows the "Clear" button that resets search, column filters and sort. */
271
- this.showClearButton = input(false, ...(ngDevMode ? [{ debugName: "showClearButton" }] : /* istanbul ignore next */ []));
272
- /** Shows the "X to Y of Z" report in the paginator. */
273
- this.showPageReport = input(true, ...(ngDevMode ? [{ debugName: "showPageReport" }] : /* istanbul ignore next */ []));
274
- /** Shows the rows-per-page selector in the paginator. */
275
- this.showRowsPerPage = input(true, ...(ngDevMode ? [{ debugName: "showRowsPerPage" }] : /* istanbul ignore next */ []));
276
- /** Whether to render the leading checkbox column for multi-row selection. */
277
- this.selectable = input(false, ...(ngDevMode ? [{ debugName: "selectable" }] : /* istanbul ignore next */ []));
278
- /**
279
- * Field used to identify rows in the selection (keeps it stable across
280
- * pages and data reloads). Falls back to the row reference when missing.
281
- */
282
- this.dataKey = input('id', ...(ngDevMode ? [{ debugName: "dataKey" }] : /* istanbul ignore next */ []));
283
- /** Optional predicate to disable the checkbox of specific rows. */
284
- this.isRowSelectable = input(undefined, ...(ngDevMode ? [{ debugName: "isRowSelectable" }] : /* istanbul ignore next */ []));
285
- /**
286
- * With `selectable`, clicking anywhere on a row toggles its selection (not
287
- * only the checkbox). Clicks on buttons, links and form controls inside the
288
- * row (row actions, custom templates) are ignored.
289
- */
290
- this.selectOnRowClick = input(false, ...(ngDevMode ? [{ debugName: "selectOnRowClick" }] : /* istanbul ignore next */ []));
291
- /** Actions shown in the header while at least one row is selected. */
292
- this.bulkActions = input([], ...(ngDevMode ? [{ debugName: "bulkActions" }] : /* istanbul ignore next */ []));
293
- /** Selected rows. Supports two-way binding via `[(selection)]`. */
294
- this.selection = model([], ...(ngDevMode ? [{ debugName: "selection" }] : /* istanbul ignore next */ []));
295
- /** Emits when the user clicks the refresh button. */
296
- this.refresh = output();
297
- /** Emits page changes (server-side mode) with first/rows/page info. */
298
- this.pageChange = output();
299
- /** Emits the active column filters (server-side mode). */
300
- this.filterChange = output();
301
- /** Emits the debounced global search term. */
302
- this.searchChange = output();
303
- /** Emits when a filter chip is clicked. */
304
- this.filterClick = output();
305
- /** Emits when a column is resized (`width` in px, `null` when reset to auto). */
306
- this.columnResize = output();
307
- /** Internal copy of the input data used as the base for search/filter. */
308
- this.originalData = signal([], ...(ngDevMode ? [{ debugName: "originalData" }] : /* istanbul ignore next */ []));
309
- /** Rows after the global search is applied. */
310
- this.searchedData = signal([], ...(ngDevMode ? [{ debugName: "searchedData" }] : /* istanbul ignore next */ []));
311
- /** Rows after column filters are applied. */
312
- this.filteredData = signal([], ...(ngDevMode ? [{ debugName: "filteredData" }] : /* istanbul ignore next */ []));
313
- /** Rows belonging to the current page (after slicing). */
314
- this.displayedData = signal([], ...(ngDevMode ? [{ debugName: "displayedData" }] : /* istanbul ignore next */ []));
315
- /** Local total records after filtering (client mode). */
316
- this.localTotalRecords = signal(0, ...(ngDevMode ? [{ debugName: "localTotalRecords" }] : /* istanbul ignore next */ []));
317
- /** Index of the first row of the current page. */
318
- this.first = signal(0, ...(ngDevMode ? [{ debugName: "first" }] : /* istanbul ignore next */ []));
319
- /** Current global search term. */
320
- this.searchQuery = signal('', ...(ngDevMode ? [{ debugName: "searchQuery" }] : /* istanbul ignore next */ []));
321
- /** Currently sorted field. */
322
- this.sortField = signal('', ...(ngDevMode ? [{ debugName: "sortField" }] : /* istanbul ignore next */ []));
323
- /** Current sort direction (1 asc, -1 desc). */
324
- this.sortOrder = signal(1, ...(ngDevMode ? [{ debugName: "sortOrder" }] : /* istanbul ignore next */ []));
325
- /** Local rows per page, kept in sync with the `rowsPerPage` input. */
326
- this.rowsPerPageLocal = linkedSignal(() => this.rowsPerPage(), ...(ngDevMode ? [{ debugName: "rowsPerPageLocal" }] : /* istanbul ignore next */ []));
327
- /** Applied filter state of each filterable column, keyed by field. */
328
- this.filterState = signal({}, ...(ngDevMode ? [{ debugName: "filterState" }] : /* istanbul ignore next */ []));
329
- /** Field whose filter menu is open (only one at a time). */
330
- this.openFilterField = signal(null, ...(ngDevMode ? [{ debugName: "openFilterField" }] : /* istanbul ignore next */ []));
331
- /** Filter being edited in the open menu (committed on Apply). */
332
- this.filterDraft = signal(null, ...(ngDevMode ? [{ debugName: "filterDraft" }] : /* istanbul ignore next */ []));
333
- /** Whether the option list of the multiselect filter is expanded. */
334
- this.multiselectOpen = signal(false, ...(ngDevMode ? [{ debugName: "multiselectOpen" }] : /* istanbul ignore next */ []));
335
- /** Total number of pages based on the effective record count. */
336
- this.totalPages = computed(() => Math.max(1, Math.ceil(this.effectiveTotalRecords() / this.rowsPerPageLocal())), ...(ngDevMode ? [{ debugName: "totalPages" }] : /* istanbul ignore next */ []));
337
- /** Current page number (1-based). */
338
- this.currentPage = computed(() => Math.floor(this.first() / this.rowsPerPageLocal()) + 1, ...(ngDevMode ? [{ debugName: "currentPage" }] : /* istanbul ignore next */ []));
339
- /** Whether any column can be filtered. */
340
- this.hasFilterableColumns = computed(() => this.columns().some((c) => c.filter), ...(ngDevMode ? [{ debugName: "hasFilterableColumns" }] : /* istanbul ignore next */ []));
341
- /** Subjects used to debounce column filters (server mode) and search. */
342
- this.filterSubject = new Subject();
343
- this.searchSubject = new Subject();
344
- /**
345
- * Signature of the last built set of filterable fields (+filter type) to
346
- * avoid resetting the filters (and losing user input) on reference changes.
347
- */
348
- this.lastFilterFieldsSignature = '';
349
- /** Columns array with the leading `actions` column when row actions exist. */
350
- this.columnsWithActions = computed(() => {
351
- const columnsArray = this.columns();
352
- const showAction = this.showActionRow();
353
- const rowActionsArray = this.rowActions();
354
- const translatedHeader = this.actionsHeaderLabel();
355
- // The severity indicator lives in the actions cell, so the column is also
356
- // rendered when there are no row actions but a displayed row has issues.
357
- const rows = this.effectiveDisplayedData();
358
- const hasIndicator = rows.some((row) => this.rowViolationsOf(row).length > 0);
359
- if ((showAction && rowActionsArray.length > 0) || hasIndicator) {
360
- // Width from the actions really shown on the current page (each row can
361
- // hide some with `isVisible`), not from every action defined.
362
- let buttons = hasIndicator ? 1 : 0;
363
- if (rows.length) {
364
- for (const row of rows) {
365
- const n = rowActionsArray.filter((a) => this.isRowActionVisible(a, row)).length;
366
- const shown = n > this.MAX_VISIBLE_ACTIONS ? this.MAX_VISIBLE_ACTIONS + 1 : n; // +1 = "more" button
367
- if (shown + (hasIndicator ? 1 : 0) > buttons)
368
- buttons = shown + (hasIndicator ? 1 : 0);
369
- }
370
- }
371
- else {
372
- const n = rowActionsArray.length;
373
- const shown = n > this.MAX_VISIBLE_ACTIONS ? this.MAX_VISIBLE_ACTIONS + 1 : n;
374
- if (shown + (hasIndicator ? 1 : 0) > buttons)
375
- buttons = shown + (hasIndicator ? 1 : 0);
376
- }
377
- const actionsWidth = `${Math.max(this.MIN_ACTIONS_WIDTH, this.ACTIONS_CELL_PADDING + buttons * this.ACTION_BUTTON_WIDTH)}px`;
378
- return [
379
- {
380
- field: 'actions',
381
- header: translatedHeader || 'Acciones',
382
- width: actionsWidth,
383
- defaultSort: true,
384
- },
385
- ...columnsArray,
386
- ];
387
- }
388
- return [...columnsArray];
389
- }, ...(ngDevMode ? [{ debugName: "columnsWithActions" }] : /* istanbul ignore next */ []));
390
- /** Keys of the selected rows, for O(1) lookups in the template. */
391
- this.selectedKeys = computed(() => new Set(this.selection().map((row) => this.getSelectionKey(row))), ...(ngDevMode ? [{ debugName: "selectedKeys" }] : /* istanbul ignore next */ []));
392
- /** Whether non-empty data has been received (see the selection pruning effect). */
393
- this.hasReceivedData = false;
394
- /** Selectable rows of the current page. */
395
- this.selectablePageRows = computed(() => this.effectiveDisplayedData().filter((row) => this.canSelectRow(row)), ...(ngDevMode ? [{ debugName: "selectablePageRows" }] : /* istanbul ignore next */ []));
396
- /** Whether every selectable row of the current page is selected. */
397
- this.allPageSelected = computed(() => {
398
- const rows = this.selectablePageRows();
399
- const keys = this.selectedKeys();
400
- return rows.length > 0 && rows.every((row) => keys.has(this.getSelectionKey(row)));
401
- }, ...(ngDevMode ? [{ debugName: "allPageSelected" }] : /* istanbul ignore next */ []));
402
- /** Whether only part of the current page is selected (header checkbox indeterminate). */
403
- this.somePageSelected = computed(() => {
404
- const keys = this.selectedKeys();
405
- return (!this.allPageSelected() &&
406
- this.selectablePageRows().some((row) => keys.has(this.getSelectionKey(row))));
407
- }, ...(ngDevMode ? [{ debugName: "somePageSelected" }] : /* istanbul ignore next */ []));
408
- /** Visible bulk actions for the current selection. */
409
- this.visibleBulkActions = computed(() => {
410
- const selected = this.selection();
411
- return this.bulkActions().filter((a) => (a.isVisible ? a.isVisible(selected) : true));
412
- }, ...(ngDevMode ? [{ debugName: "visibleBulkActions" }] : /* istanbul ignore next */ []));
413
- /** Number of rendered columns, including the selection column. */
414
- this.totalColspan = computed(() => this.columnsWithActions().length + (this.selectable() ? 1 : 0), ...(ngDevMode ? [{ debugName: "totalColspan" }] : /* istanbul ignore next */ []));
415
- // ---------------------------------------------------------------------------
416
- // Row validation
417
- // ---------------------------------------------------------------------------
418
- /** Rank used to pick the worst severity of a row. */
419
- this.severityRank = {
420
- low: 0,
421
- moderate: 1,
422
- critical: 2,
423
- };
424
- /** Violations of each displayed row (cached per render, re-evaluated on i18n changes). */
425
- this.violationsByRow = computed(() => {
426
- const map = new Map();
427
- const entries = Object.entries(this.rowValidations());
428
- if (!entries.length)
429
- return map;
430
- for (const row of this.effectiveDisplayedData()) {
431
- map.set(row, this.collectViolations(row, entries));
432
- }
433
- return map;
434
- }, ...(ngDevMode ? [{ debugName: "violationsByRow" }] : /* istanbul ignore next */ []));
435
- /** Total records: server-provided in server mode, locally computed otherwise. */
436
- this.effectiveTotalRecords = computed(() => {
437
- return this.serverSide() ? this.totalRecords() : this.localTotalRecords();
438
- }, ...(ngDevMode ? [{ debugName: "effectiveTotalRecords" }] : /* istanbul ignore next */ []));
439
- /**
440
- * Rows rendered by the template: the input data in server-side mode or the
441
- * locally sliced/page current rows otherwise.
442
- */
443
- this.effectiveDisplayedData = computed(() => {
444
- return this.serverSide() ? this.data() : this.displayedData();
445
- }, ...(ngDevMode ? [{ debugName: "effectiveDisplayedData" }] : /* istanbul ignore next */ []));
446
- /**
447
- * Reactive "X to Y of Z" report. Depends on loaded translations and the
448
- * active language so it always reflects the translated template.
449
- */
450
- this.pageReport = computed(() => {
451
- this.translations(); // forces recomputation when translations finish loading
452
- this.currentLang(); // forces recomputation when the language changes
453
- const total = this.effectiveTotalRecords();
454
- if (total === 0) {
455
- return this.transloco.translate('table.pageReport', {
456
- from: 0,
457
- to: 0,
458
- total: 0,
459
- });
460
- }
461
- const from = this.first() + 1;
462
- const to = Math.min(this.first() + this.rowsPerPageLocal(), total);
463
- return this.transloco.translate('table.pageReport', { from, to, total });
464
- }, ...(ngDevMode ? [{ debugName: "pageReport" }] : /* istanbul ignore next */ []));
465
- // ---------------------------------------------------------------------------
466
- // Column resizing
467
- // ---------------------------------------------------------------------------
468
- /** Minimum width (px) a column can be resized to. */
469
- this.MIN_COLUMN_WIDTH = 60;
470
- /** Actions column auto width: button (2rem) + 1px gap, cell padding, header room. */
471
- this.ACTION_BUTTON_WIDTH = 33;
472
- this.ACTIONS_CELL_PADDING = 24;
473
- this.MIN_ACTIONS_WIDTH = 84;
474
- /** Field being resized right now (for the active handle style). */
475
- this.resizingField = signal(null, ...(ngDevMode ? [{ debugName: "resizingField" }] : /* istanbul ignore next */ []));
476
- /** Set right after a drag so the click that ends it doesn't sort the column. */
477
- this.suppressHeaderClick = false;
478
- /** Whether columns can be resized (only with gridlines). */
479
- this.isResizable = computed(() => this.showGridlines() && this.resizableColumns(), ...(ngDevMode ? [{ debugName: "isResizable" }] : /* istanbul ignore next */ []));
480
- /** Whether any column filter or the global search is active. */
481
- this.hasActiveFilters = computed(() => {
482
- if (this.searchQuery())
483
- return true;
484
- const state = this.filterState();
485
- return this.columns().some((c) => c.filter && this.activeRules(c, state[c.field]).length > 0);
486
- }, ...(ngDevMode ? [{ debugName: "hasActiveFilters" }] : /* istanbul ignore next */ []));
487
- /** Width (px) of the column filter popup, used to keep it inside the viewport. */
488
- this.FILTER_POPUP_WIDTH = 240;
489
- /** Viewport position of the open column filter popup. */
490
- this.filterPopupPosition = signal({
491
- top: 0,
492
- left: 0,
493
- maxHeight: 400,
494
- }, ...(ngDevMode ? [{ debugName: "filterPopupPosition" }] : /* istanbul ignore next */ []));
495
- /** Filter button the open popup is anchored to, and its scroll/resize listener cleanup. */
496
- this.filterAnchor = null;
497
- this.filterListenersCleanup = null;
498
- /** Maximum number of row actions shown directly before collapsing into a dropdown. */
499
- this.MAX_VISIBLE_ACTIONS = 4;
500
- /** Tracks which row's "more actions" dropdown is currently open (keyed by row identity). */
501
- this.actionsDropdownOpen = signal({}, ...(ngDevMode ? [{ debugName: "actionsDropdownOpen" }] : /* istanbul ignore next */ []));
502
- /** Computes the fixed position of the dropdown so it's not clipped by overflow. */
503
- this.dropdownPosition = signal({ top: 0, left: 0 }, ...(ngDevMode ? [{ debugName: "dropdownPosition" }] : /* istanbul ignore next */ []));
504
- this.destroyRef.onDestroy(() => this.filterListenersCleanup?.());
505
- // Close the filter popup if its header cell was removed (e.g. the column
506
- // disappeared). Re-renders of the same columns keep the cell (tracked by
507
- // field), so new `columns` references alone don't close it.
508
- afterEveryRender(() => {
509
- if (this.filterAnchor && !this.filterAnchor.isConnected) {
510
- this.closeFilters();
511
- }
512
- });
513
- // Debounced column-filter changes (server-side mode only).
514
- this.filterSubject
515
- .pipe(debounceTime(300), takeUntilDestroyed(this.destroyRef))
516
- .subscribe(() => {
517
- if (this.serverSide()) {
518
- this.emitFilterChange();
519
- }
520
- });
521
- // Debounced global search changes (server-side mode only).
522
- this.searchSubject
523
- .pipe(debounceTime(300), takeUntilDestroyed(this.destroyRef))
524
- .subscribe((value) => {
525
- this.searchChange.emit(value);
526
- });
527
- // When input data changes, refresh the internal copy and re-apply filters
528
- // unless the server already handles the filtering.
529
- effect(() => {
530
- const newData = this.data();
531
- untracked(() => {
532
- this.originalData.set([...newData]);
533
- if (!this.serverSide()) {
534
- this.applyFilters();
535
- }
536
- });
537
- });
538
- // Drop selected rows that disappeared from the data (client mode). Skipped
539
- // while loading and until the first non-empty data arrives, so a temporary
540
- // `[]` (initial value, async load, reload) doesn't wipe the selection.
541
- effect(() => {
542
- const newData = this.data();
543
- const loading = this.loading();
544
- untracked(() => {
545
- if (this.serverSide() || loading)
546
- return;
547
- if (newData.length > 0)
548
- this.hasReceivedData = true;
549
- if (this.hasReceivedData)
550
- this.pruneSelection(newData);
551
- });
552
- });
553
- // Restore the saved column widths whenever the state key/storage changes.
554
- effect(() => {
555
- const key = this.stateKey();
556
- const storage = this.stateStorage();
557
- untracked(() => {
558
- if (!key)
559
- return;
560
- const saved = this.readStoredWidths(key, storage);
561
- if (saved)
562
- this.columnWidths.set(saved);
563
- });
564
- });
565
- // Save the column widths when they change (not on every pixel of a drag).
566
- effect(() => {
567
- const widths = this.columnWidths();
568
- const resizing = this.resizingField();
569
- const key = this.stateKey();
570
- const storage = this.stateStorage();
571
- if (!key || resizing)
572
- return;
573
- untracked(() => this.writeStoredWidths(key, storage, widths));
574
- });
575
- // Rebuild the column filter state whenever the columns change.
576
- effect(() => {
577
- const cols = this.columns();
578
- untracked(() => {
579
- this.setupColumnFilters(cols);
580
- });
581
- });
582
- // Apply the default sort once when the default fields are provided.
583
- effect(() => {
584
- const field = this.defaultSortField();
585
- const order = this.defaultSortOrder();
586
- if (field) {
587
- untracked(() => {
588
- this.sortField.set(field);
589
- this.sortOrder.set(order);
590
- if (!this.serverSide()) {
591
- this.applySort();
592
- this.updateDisplayedData();
593
- }
594
- });
595
- }
596
- });
597
- // Apply the global search locally whenever the term changes.
598
- effect(() => {
599
- this.searchQuery();
600
- untracked(() => {
601
- if (!this.serverSide()) {
602
- this.applySearch();
603
- }
604
- });
605
- });
606
- }
607
- // ---------------------------------------------------------------------------
608
- // Translations
609
- // ---------------------------------------------------------------------------
610
- /**
611
- * Translates a key, falling back to a built-in (Spanish) label when the app
612
- * doesn't provide it. Reads the translation signals so template calls are
613
- * re-evaluated when the language or the loaded translations change.
614
- */
615
- tr(key, fallback, params) {
616
- this.translations();
617
- this.currentLang();
618
- const value = this.transloco.translate(key, params);
619
- if (value && value !== key)
620
- return value;
621
- return fallback.replace(/\{\{\s*(\w+)\s*\}\}/g, (_, name) => String(params?.[name] ?? ''));
622
- }
623
- /** Translated label of a filter menu text (`table.filter.<name>`). */
624
- filterLabel(name, params) {
625
- return this.tr(`table.filter.${name}`, FILTER_LABELS[name] ?? name, params);
626
- }
627
- /** Translated label of a match mode (`table.filter.matchModes.<mode>`). */
628
- matchModeLabel(mode) {
629
- return this.tr(`table.filter.matchModes.${mode}`, FILTER_LABELS[mode] ?? mode);
630
- }
631
- // ---------------------------------------------------------------------------
632
- // Field helpers
633
- // ---------------------------------------------------------------------------
634
- /** Reads a row value by field name or dot path (`'country.name'`). */
635
- resolveField(row, path) {
636
- if (row == null || !path)
637
- return undefined;
638
- if (typeof row === 'object' && path in row)
639
- return row[path];
640
- return path.split('.').reduce((obj, key) => (obj == null ? undefined : obj[key]), row);
641
- }
642
- /** Field used to filter/sort a column. */
643
- filterFieldOf(col) {
644
- return col.filterField || col.field;
645
- }
646
- /** Lowercases and strips diacritics so "garcia" matches "García". */
647
- normalize(value) {
648
- return String(value ?? '')
649
- .normalize('NFD')
650
- .replace(/[̀-ͯ]/g, '')
651
- .toLocaleLowerCase();
652
- }
653
- // ---------------------------------------------------------------------------
654
- // Column filter state
655
- // ---------------------------------------------------------------------------
656
- /** Internal filter kind of a column. */
657
- filterKind(col) {
658
- const type = col.filterType ?? 'text';
659
- return type === 'exact' ? 'text' : type;
660
- }
661
- /** Match modes offered by a column's filter menu. */
662
- matchModesFor(col) {
663
- return MATCH_MODES[this.filterKind(col)] ?? [];
664
- }
665
- /** Default match mode of a column's filter. */
666
- defaultMatchMode(col) {
667
- if (col.filterMatchMode)
668
- return col.filterMatchMode;
669
- switch (this.filterKind(col)) {
670
- case 'text':
671
- return col.filterType === 'exact' ? 'equals' : 'contains';
672
- case 'numeric':
673
- return 'equals';
674
- case 'date':
675
- return 'dateIs';
676
- case 'multiselect':
677
- return 'in';
678
- case 'range':
679
- return 'between';
680
- default:
681
- return 'equals';
682
- }
683
- }
684
- /** Whether the column's filter kind supports match modes / several rules. */
685
- supportsRules(col) {
686
- return !!MATCH_MODES[this.filterKind(col)];
687
- }
688
- showMatchModesFor(col) {
689
- return this.supportsRules(col) && col.showMatchModes !== false;
690
- }
691
- showOperatorFor(col) {
692
- return this.supportsRules(col) && col.showOperator !== false;
693
- }
694
- canAddRule(col) {
695
- const draft = this.filterDraft();
696
- return (this.supportsRules(col) &&
697
- col.showAddButton !== false &&
698
- !!draft &&
699
- draft.rules.length < (col.maxConstraints ?? 2));
700
- }
701
- /** Whether changes are applied as soon as the value changes (no Apply needed). */
702
- appliesImmediately(col) {
703
- return !this.supportsRules(col);
704
- }
705
- /** Empty filter state of a column. */
706
- emptyFilterState(col) {
707
- return { operator: 'and', rules: [{ matchMode: this.defaultMatchMode(col), value: null }] };
708
- }
709
- cloneState(state) {
710
- return {
711
- operator: state.operator,
712
- rules: state.rules.map((r) => ({
713
- matchMode: r.matchMode,
714
- value: Array.isArray(r.value) ? [...r.value] : r.value,
715
- })),
716
- };
717
- }
718
- /** Bounds of a `range` filter. */
719
- rangeBounds(col) {
720
- return [col.filterMin ?? 0, col.filterMax ?? 100];
721
- }
722
- /** Whether a rule has a value that actually filters. */
723
- isRuleActive(col, rule) {
724
- const value = rule.value;
725
- if (value === null || value === undefined || value === '')
726
- return false;
727
- if (this.filterKind(col) === 'range') {
728
- if (!Array.isArray(value) || value.length !== 2)
729
- return false;
730
- const [min, max] = this.rangeBounds(col);
731
- return value[0] > min || value[1] < max;
732
- }
733
- if (Array.isArray(value))
734
- return value.length > 0;
735
- return true;
736
- }
737
- activeRules(col, state) {
738
- return (state?.rules ?? []).filter((r) => this.isRuleActive(col, r));
739
- }
740
- /** Converts a Date / ISO string / timestamp into a local midnight timestamp. */
741
- toDay(value) {
742
- if (value === null || value === undefined || value === '')
743
- return null;
744
- let date;
745
- if (value instanceof Date) {
746
- date = value;
747
- }
748
- else if (typeof value === 'string' && /^\d{4}-\d{2}-\d{2}$/.test(value)) {
749
- const [y, m, d] = value.split('-').map(Number);
750
- date = new Date(y, m - 1, d);
751
- }
752
- else {
753
- date = new Date(value);
754
- }
755
- if (isNaN(date.getTime()))
756
- return null;
757
- return new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime();
758
- }
759
- /** Evaluates one rule against a cell value. */
760
- matchRule(col, cell, rule) {
761
- const value = rule.value;
762
- switch (rule.matchMode) {
763
- case 'startsWith':
764
- return this.normalize(cell).startsWith(this.normalize(value));
765
- case 'contains':
766
- return this.normalize(cell).includes(this.normalize(value));
767
- case 'notContains':
768
- return !this.normalize(cell).includes(this.normalize(value));
769
- case 'endsWith':
770
- return this.normalize(cell).endsWith(this.normalize(value));
771
- case 'equals':
772
- case 'notEquals': {
773
- let equal;
774
- const kind = this.filterKind(col);
775
- if (kind === 'numeric') {
776
- equal = cell !== null && cell !== undefined && cell !== '' && Number(cell) === Number(value);
777
- }
778
- else if (kind === 'boolean') {
779
- equal = Boolean(cell) === Boolean(value);
780
- }
781
- else if (kind === 'select') {
782
- equal = cell == value;
783
- }
784
- else {
785
- equal = this.normalize(cell) === this.normalize(value);
786
- }
787
- return rule.matchMode === 'equals' ? equal : !equal;
788
- }
789
- case 'lt':
790
- case 'lte':
791
- case 'gt':
792
- case 'gte': {
793
- if (cell === null || cell === undefined || cell === '')
794
- return false;
795
- const a = Number(cell);
796
- const b = Number(value);
797
- if (isNaN(a) || isNaN(b))
798
- return false;
799
- if (rule.matchMode === 'lt')
800
- return a < b;
801
- if (rule.matchMode === 'lte')
802
- return a <= b;
803
- if (rule.matchMode === 'gt')
804
- return a > b;
805
- return a >= b;
806
- }
807
- case 'dateIs':
808
- case 'dateIsNot':
809
- case 'dateBefore':
810
- case 'dateAfter': {
811
- const a = this.toDay(cell);
812
- const b = this.toDay(value);
813
- if (b === null)
814
- return true;
815
- if (a === null)
816
- return rule.matchMode === 'dateIsNot';
817
- if (rule.matchMode === 'dateIs')
818
- return a === b;
819
- if (rule.matchMode === 'dateIsNot')
820
- return a !== b;
821
- if (rule.matchMode === 'dateBefore')
822
- return a < b;
823
- return a > b;
824
- }
825
- case 'in':
826
- return value.some((v) => v == cell);
827
- case 'between': {
828
- if (cell === null || cell === undefined || cell === '')
829
- return false;
830
- const n = Number(cell);
831
- return n >= value[0] && n <= value[1];
832
- }
833
- default:
834
- return true;
835
- }
836
- }
837
- /**
838
- * Keeps one filter state per filterable column. The state is only reset
839
- * when the set of filterable fields/filter types changes, preserving what
840
- * the user already applied otherwise.
841
- */
842
- setupColumnFilters(cols) {
843
- const filterableCols = cols.filter((c) => c.filter);
844
- const signature = filterableCols.map((c) => `${c.field}:${c.filterType ?? 'text'}`).join('|');
845
- if (signature === this.lastFilterFieldsSignature)
846
- return;
847
- this.lastFilterFieldsSignature = signature;
848
- const previous = this.filterState();
849
- const next = {};
850
- filterableCols.forEach((col) => {
851
- next[col.field] = previous[col.field] ?? this.emptyFilterState(col);
852
- });
853
- this.filterState.set(next);
854
- }
855
- /** Collects the active column filters and emits them. */
856
- emitFilterChange() {
857
- const filters = {};
858
- const filterMeta = {};
859
- const state = this.filterState();
860
- this.columns().forEach((col) => {
861
- if (!col.filter)
862
- return;
863
- const rules = this.activeRules(col, state[col.field]);
864
- if (rules.length === 0)
865
- return;
866
- const key = this.filterFieldOf(col);
867
- filters[key] = rules[0].value;
868
- filterMeta[key] = this.cloneState({ operator: state[col.field].operator, rules });
869
- });
870
- this.filterChange.emit({ filters, filterMeta });
871
- }
872
- /** Applies the global search over the original data (client mode). */
873
- applySearch() {
874
- const original = this.originalData();
875
- const query = this.normalize(this.searchQuery().trim());
876
- if (!query) {
877
- this.searchedData.set([...original]);
878
- }
879
- else {
880
- const fields = this.globalFilterFields();
881
- const filtered = original.filter((item) => {
882
- const values = fields.length
883
- ? fields.map((f) => this.resolveField(item, f))
884
- : Object.values(item ?? {}).filter((v) => v === null || typeof v !== 'object' || v instanceof Date);
885
- return values.some((val) => {
886
- if (val === null || val === undefined)
887
- return false;
888
- return this.normalize(val).includes(query);
889
- });
890
- });
891
- this.searchedData.set(filtered);
892
- }
893
- this.applyColumnFilters();
894
- }
895
- /** Entry point that applies search (which cascades into column filters). */
896
- applyFilters() {
897
- this.applySearch();
898
- }
899
- /**
900
- * Applies every column filter on top of the searched data. The active rules
901
- * of a column are combined with its operator (Match All / Match Any).
902
- */
903
- applyColumnFilters() {
904
- let filtered = [...this.searchedData()];
905
- const state = this.filterState();
906
- this.columns().forEach((col) => {
907
- if (!col.filter)
908
- return;
909
- const colState = state[col.field];
910
- const rules = this.activeRules(col, colState);
911
- if (rules.length === 0)
912
- return;
913
- const field = this.filterFieldOf(col);
914
- filtered = filtered.filter((item) => {
915
- const cell = this.resolveField(item, field);
916
- return colState.operator === 'or'
917
- ? rules.some((r) => this.matchRule(col, cell, r))
918
- : rules.every((r) => this.matchRule(col, cell, r));
919
- });
920
- });
921
- this.filteredData.set(filtered);
922
- this.localTotalRecords.set(filtered.length);
923
- this.applySort();
924
- this.updateDisplayedData();
925
- }
926
- /** Re-runs filtering after a filter state change. */
927
- onFiltersChanged() {
928
- this.first.set(0);
929
- if (this.serverSide()) {
930
- this.filterSubject.next();
931
- }
932
- else {
933
- this.applyFilters();
934
- }
935
- this.cdr.markForCheck();
936
- }
937
- /** Slices the filtered rows for the current page. */
938
- updateDisplayedData() {
939
- const filtered = this.filteredData();
940
- const firstIndex = this.first();
941
- const rows = this.rowsPerPageLocal();
942
- this.displayedData.set(filtered.slice(firstIndex, firstIndex + rows));
943
- }
944
- // ---------------------------------------------------------------------------
945
- // Selection
946
- // ---------------------------------------------------------------------------
947
- /** Identity used for a row inside the selection. */
948
- getSelectionKey(row) {
949
- const key = this.dataKey();
950
- return key && row?.[key] !== undefined ? row[key] : row;
951
- }
952
- /** Whether the row's checkbox is enabled. */
953
- canSelectRow(row) {
954
- const predicate = this.isRowSelectable();
955
- return predicate ? predicate(row) : true;
956
- }
957
- /** Whether the row is currently selected. */
958
- isRowSelected(row) {
959
- return this.selectedKeys().has(this.getSelectionKey(row));
960
- }
961
- /** Selects/deselects a single row. */
962
- toggleRowSelection(row) {
963
- if (!this.canSelectRow(row))
964
- return;
965
- const key = this.getSelectionKey(row);
966
- if (this.isRowSelected(row)) {
967
- this.selection.set(this.selection().filter((r) => this.getSelectionKey(r) !== key));
968
- }
969
- else {
970
- this.selection.set([...this.selection(), row]);
971
- }
972
- }
973
- /** Row click: toggles the selection when `selectOnRowClick` is on. */
974
- onRowClick(event, row) {
975
- if (!this.selectable() || !this.selectOnRowClick())
976
- return;
977
- const target = event.target;
978
- if (target?.closest('button, a, input, select, textarea, label, [role="button"], [data-shk-select]'))
979
- return;
980
- this.toggleRowSelection(row);
981
- }
982
- /**
983
- * Header checkbox: selects every selectable row of the current page or,
984
- * when all of them are already selected, removes them from the selection.
985
- * Rows selected on other pages are kept.
986
- */
987
- toggleSelectAllPage() {
988
- const pageRows = this.selectablePageRows();
989
- const pageKeys = new Set(pageRows.map((row) => this.getSelectionKey(row)));
990
- const rest = this.selection().filter((r) => !pageKeys.has(this.getSelectionKey(r)));
991
- this.selection.set(this.allPageSelected() ? rest : [...rest, ...pageRows]);
992
- }
993
- /** Clears the whole selection. */
994
- clearSelection() {
995
- this.selection.set([]);
996
- }
997
- /** Runs a bulk action with the current selection. */
998
- runBulkAction(action) {
999
- action.onClick([...this.selection()]);
1000
- }
1001
- /** Whether a bulk action is disabled for the current selection. */
1002
- isBulkActionDisabled(action) {
1003
- return action.isDisabled ? action.isDisabled(this.selection()) : false;
1004
- }
1005
- /**
1006
- * Drops selected rows that no longer exist in the data (client mode, e.g.
1007
- * after a bulk delete) and refreshes kept rows with their new references.
1008
- */
1009
- pruneSelection(data) {
1010
- const current = this.selection();
1011
- if (current.length === 0)
1012
- return;
1013
- const byKey = new Map(data.map((row) => [this.getSelectionKey(row), row]));
1014
- const next = current
1015
- .map((row) => byKey.get(this.getSelectionKey(row)))
1016
- .filter((row) => row !== undefined);
1017
- if (next.length !== current.length || next.some((row, i) => row !== current[i])) {
1018
- this.selection.set(next);
1019
- }
1020
- }
1021
- /** CSS width of a resized column, or null when it uses the automatic width. */
1022
- resizedWidth(col) {
1023
- const width = this.isResizable() ? this.columnWidths()[col.field] : undefined;
1024
- return width ? `${width}px` : null;
1025
- }
1026
- resizedWidthPx(col) {
1027
- return this.columnWidths()[col.field] ?? null;
1028
- }
1029
- /** Header click: sorts unless the click is the end of a resize drag. */
1030
- onHeaderClick(col) {
1031
- if (this.suppressHeaderClick)
1032
- return;
1033
- if (col.field !== 'actions' && col.sortable)
1034
- this.toggleSort(col.field);
1035
- }
1036
- /** Starts dragging the right border of a header cell. */
1037
- startResize(event, col) {
1038
- if (event.button !== 0)
1039
- return;
1040
- event.preventDefault();
1041
- event.stopPropagation();
1042
- const th = event.target.closest('th');
1043
- if (!th)
1044
- return;
1045
- const startX = event.clientX;
1046
- const startWidth = th.getBoundingClientRect().width;
1047
- let moved = false;
1048
- this.resizingField.set(col.field);
1049
- const body = document.body;
1050
- const previousCursor = body.style.cursor;
1051
- const previousSelect = body.style.userSelect;
1052
- body.style.cursor = 'col-resize';
1053
- body.style.userSelect = 'none';
1054
- const onMove = (e) => {
1055
- const dx = e.clientX - startX;
1056
- if (Math.abs(dx) > 2)
1057
- moved = true;
1058
- this.setColumnWidth(col, startWidth + dx, false);
1059
- };
1060
- const onUp = () => {
1061
- document.removeEventListener('pointermove', onMove);
1062
- document.removeEventListener('pointerup', onUp);
1063
- document.removeEventListener('pointercancel', onUp);
1064
- body.style.cursor = previousCursor;
1065
- body.style.userSelect = previousSelect;
1066
- this.resizingField.set(null);
1067
- // Keep the width actually rendered (content can't shrink below its minimum).
1068
- if (moved)
1069
- this.syncRenderedWidth(col, th);
1070
- if (moved) {
1071
- this.suppressHeaderClick = true;
1072
- setTimeout(() => (this.suppressHeaderClick = false));
1073
- this.columnResize.emit({ field: col.field, width: this.columnWidths()[col.field] ?? null });
1074
- }
1075
- this.cdr.markForCheck();
1076
- };
1077
- document.addEventListener('pointermove', onMove);
1078
- document.addEventListener('pointerup', onUp);
1079
- document.addEventListener('pointercancel', onUp);
1080
- }
1081
- /** Arrow keys on the handle widen/narrow the column (Shift = bigger steps). */
1082
- onResizerKeydown(event, col) {
1083
- if (event.key !== 'ArrowLeft' && event.key !== 'ArrowRight') {
1084
- if (event.key === 'Enter' || event.key === ' ')
1085
- event.stopPropagation();
1086
- return;
1087
- }
1088
- event.preventDefault();
1089
- event.stopPropagation();
1090
- const th = event.target.closest('th');
1091
- if (!th)
1092
- return;
1093
- const step = event.shiftKey ? 50 : 10;
1094
- const base = this.columnWidths()[col.field] ?? th.getBoundingClientRect().width;
1095
- this.setColumnWidth(col, base + (event.key === 'ArrowRight' ? step : -step), true);
1096
- this.syncRenderedWidth(col, th);
1097
- }
1098
- /** Stores the width the column really has (it may be wider than requested). */
1099
- syncRenderedWidth(col, th) {
1100
- // Read it after the requested width has been rendered.
1101
- afterNextRender({
1102
- read: () => {
1103
- const rendered = Math.round(th.getBoundingClientRect().width);
1104
- if (rendered && this.columnWidths()[col.field] !== rendered) {
1105
- this.columnWidths.update((w) => ({ ...w, [col.field]: rendered }));
1106
- this.cdr.markForCheck();
1107
- }
1108
- },
1109
- }, { injector: this.injector });
1110
- }
1111
- /** Resets every column to its automatic width (also clears the saved state). */
1112
- resetColumnWidths() {
1113
- this.columnWidths.set({});
1114
- }
1115
- storageFor(type) {
1116
- try {
1117
- return type === 'session' ? window.sessionStorage : window.localStorage;
1118
- }
1119
- catch {
1120
- return null; // storage blocked (privacy mode, sandboxed iframe...)
1121
- }
1122
- }
1123
- /** Reads saved widths, ignoring missing, invalid or blocked storage. */
1124
- readStoredWidths(key, type) {
1125
- try {
1126
- const raw = this.storageFor(type)?.getItem(`${key}:columnWidths`);
1127
- if (!raw)
1128
- return null;
1129
- const parsed = JSON.parse(raw);
1130
- if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed))
1131
- return null;
1132
- const widths = {};
1133
- Object.entries(parsed).forEach(([field, width]) => {
1134
- if (typeof width === 'number' && isFinite(width) && width > 0)
1135
- widths[field] = width;
1136
- });
1137
- return widths;
1138
- }
1139
- catch {
1140
- return null;
1141
- }
1142
- }
1143
- writeStoredWidths(key, type, widths) {
1144
- try {
1145
- const storage = this.storageFor(type);
1146
- if (!storage)
1147
- return;
1148
- if (Object.keys(widths).length === 0)
1149
- storage.removeItem(`${key}:columnWidths`);
1150
- else
1151
- storage.setItem(`${key}:columnWidths`, JSON.stringify(widths));
1152
- }
1153
- catch {
1154
- // Quota exceeded or storage blocked: widths just aren't persisted.
1155
- }
1156
- }
1157
- /** Resets a column to its automatic width (double click on the handle). */
1158
- resetColumnWidth(col) {
1159
- const { [col.field]: _removed, ...rest } = this.columnWidths();
1160
- this.columnWidths.set(rest);
1161
- this.columnResize.emit({ field: col.field, width: null });
1162
- }
1163
- setColumnWidth(col, width, emit) {
1164
- const next = Math.max(this.MIN_COLUMN_WIDTH, Math.round(width));
1165
- this.columnWidths.update((w) => ({ ...w, [col.field]: next }));
1166
- if (emit)
1167
- this.columnResize.emit({ field: col.field, width: next });
1168
- this.cdr.markForCheck();
1169
- }
1170
- // ---------------------------------------------------------------------------
1171
- // Sorting & search
1172
- // ---------------------------------------------------------------------------
1173
- /** Emits the filter chip clicked in the template. */
1174
- onFilterClick(value) {
1175
- this.filterClick.emit(value);
1176
- }
1177
- /** Toggles the sort direction of a column (first click sorts ascending). */
1178
- toggleSort(field) {
1179
- if (this.sortField() === field) {
1180
- this.sortOrder.set(this.sortOrder() * -1);
1181
- }
1182
- else {
1183
- this.sortField.set(field);
1184
- this.sortOrder.set(1);
1185
- }
1186
- this.first.set(0);
1187
- if (!this.serverSide()) {
1188
- this.applySort();
1189
- this.updateDisplayedData();
1190
- }
1191
- }
1192
- /**
1193
- * Sorts the filtered rows by the current field. Rows with null/undefined
1194
- * values are always kept at the end regardless of sort direction.
1195
- */
1196
- applySort() {
1197
- const field = this.sortField();
1198
- const order = this.sortOrder();
1199
- if (!field)
1200
- return;
1201
- const col = this.columns().find((c) => c.field === field);
1202
- const path = col ? this.filterFieldOf(col) : field;
1203
- const data = [...this.filteredData()];
1204
- data.sort((a, b) => {
1205
- const va = this.resolveField(a, path);
1206
- const vb = this.resolveField(b, path);
1207
- if (va == null && vb == null)
1208
- return 0;
1209
- if (va == null)
1210
- return 1; // nulls always at the end
1211
- if (vb == null)
1212
- return -1;
1213
- if (typeof va === 'string' && typeof vb === 'string') {
1214
- return va.localeCompare(vb, undefined, { numeric: true, sensitivity: 'base' }) * order;
1215
- }
1216
- if (va < vb)
1217
- return -1 * order;
1218
- if (va > vb)
1219
- return 1 * order;
1220
- return 0;
1221
- });
1222
- this.filteredData.set(data);
1223
- }
1224
- /** Handles the global search input (updates query, resets page, debounces server mode). */
1225
- onSearchInput(value) {
1226
- this.searchQuery.set(value);
1227
- this.first.set(0);
1228
- if (this.serverSide()) {
1229
- this.searchSubject.next(value);
1230
- }
1231
- }
1232
- // ---------------------------------------------------------------------------
1233
- // Filter menu
1234
- // ---------------------------------------------------------------------------
1235
- /** Whether a column has an applied (non-empty) filter. */
1236
- hasFilterValue(field) {
1237
- const col = this.columns().find((c) => c.field === field);
1238
- if (!col)
1239
- return false;
1240
- return this.activeRules(col, this.filterState()[field]).length > 0;
1241
- }
1242
- /** Commits the draft of a column into the applied filter state. */
1243
- commitDraft(col) {
1244
- const draft = this.filterDraft();
1245
- if (!draft)
1246
- return;
1247
- this.filterState.update((s) => ({ ...s, [col.field]: this.cloneState(draft) }));
1248
- this.onFiltersChanged();
1249
- }
1250
- setDraftOperator(operator) {
1251
- this.filterDraft.update((d) => (d ? { ...d, operator } : d));
1252
- }
1253
- setDraftMatchMode(col, index, matchMode) {
1254
- this.filterDraft.update((d) => d ? { ...d, rules: d.rules.map((r, i) => (i === index ? { ...r, matchMode } : r)) } : d);
1255
- }
1256
- setDraftValue(col, index, value) {
1257
- this.filterDraft.update((d) => d ? { ...d, rules: d.rules.map((r, i) => (i === index ? { ...r, value } : r)) } : d);
1258
- if (this.appliesImmediately(col))
1259
- this.commitDraft(col);
1260
- }
1261
- /** Raw value typed in a rule input, converted for its filter kind. */
1262
- onRuleInput(col, index, raw) {
1263
- const kind = this.filterKind(col);
1264
- const value = kind === 'numeric' ? this.numericValue(raw) : kind === 'date' ? raw || null : raw;
1265
- this.setDraftValue(col, index, value);
1266
- }
1267
- /** Value of a numeric input (`null` when empty). */
1268
- numericValue(raw) {
1269
- return raw === '' || raw === null || isNaN(Number(raw)) ? null : Number(raw);
1270
- }
1271
- addRule(col) {
1272
- if (!this.canAddRule(col))
1273
- return;
1274
- this.filterDraft.update((d) => d ? { ...d, rules: [...d.rules, { matchMode: this.defaultMatchMode(col), value: null }] } : d);
1275
- }
1276
- removeRule(index) {
1277
- this.filterDraft.update((d) => d && d.rules.length > 1 ? { ...d, rules: d.rules.filter((_, i) => i !== index) } : d);
1278
- }
1279
- /** Applies the draft (Apply button / Enter) and closes the menu. */
1280
- applyFilter(col) {
1281
- this.commitDraft(col);
1282
- this.closeFilters();
1283
- }
1284
- /** Clears a column filter and closes its menu. */
1285
- clearFilter(field) {
1286
- const col = this.columns().find((c) => c.field === field);
1287
- if (!col)
1288
- return;
1289
- this.filterState.update((s) => ({ ...s, [field]: this.emptyFilterState(col) }));
1290
- this.onFiltersChanged();
1291
- this.closeFilters();
1292
- }
1293
- /** Multiselect helpers. */
1294
- isOptionSelected(value) {
1295
- const current = this.filterDraft()?.rules[0]?.value;
1296
- return Array.isArray(current) && current.some((v) => v == value);
1297
- }
1298
- toggleOption(col, value) {
1299
- const current = this.filterDraft()?.rules[0]?.value ?? [];
1300
- const next = current.some((v) => v == value)
1301
- ? current.filter((v) => v != value)
1302
- : [...current, value];
1303
- this.setDraftValue(col, 0, next.length ? next : null);
1304
- }
1305
- selectedOptionsLabel(col) {
1306
- const current = this.filterDraft()?.rules[0]?.value ?? [];
1307
- if (!current.length)
1308
- return '';
1309
- const labels = (col.filterOptions ?? [])
1310
- .filter((o) => current.some((v) => v == o.value))
1311
- .map((o) => o.label);
1312
- return labels.length > 2
1313
- ? this.filterLabel('selectedCount', { count: labels.length })
1314
- : labels.join(', ');
1315
- }
1316
- /** Select filter: picks an option (clicking the selected one clears it) and collapses the list. */
1317
- selectOption(col, value) {
1318
- const current = this.filterDraft()?.rules[0]?.value;
1319
- this.setDraftValue(col, 0, current != null && current == value ? null : value);
1320
- this.multiselectOpen.set(false);
1321
- }
1322
- selectedSingleLabel(col) {
1323
- const current = this.filterDraft()?.rules[0]?.value;
1324
- if (current === null || current === undefined)
1325
- return '';
1326
- return (col.filterOptions ?? []).find((o) => o.value == current)?.label ?? String(current);
1327
- }
1328
- /** Boolean filter: cycles any → true → false → any. */
1329
- cycleBoolean(col) {
1330
- const current = this.filterDraft()?.rules[0]?.value;
1331
- const next = current === null || current === undefined ? true : current === true ? false : null;
1332
- this.setDraftValue(col, 0, next);
1333
- }
1334
- /** Current [low, high] of a range filter draft. */
1335
- rangeValue(col) {
1336
- const value = this.filterDraft()?.rules[0]?.value;
1337
- return Array.isArray(value) ? [value[0], value[1]] : this.rangeBounds(col);
1338
- }
1339
- /** Updates one thumb of the range slider; `commit` applies it (on release). */
1340
- onRangeInput(col, thumb, raw, commit) {
1341
- const [low, high] = this.rangeValue(col);
1342
- const n = Number(raw);
1343
- const next = thumb === 0 ? [Math.min(n, high), high] : [low, Math.max(n, low)];
1344
- // A range covering the full bounds is treated as "no filter" (see isRuleActive).
1345
- this.filterDraft.update((d) => d ? { ...d, rules: d.rules.map((r, i) => (i === 0 ? { ...r, value: next } : r)) } : d);
1346
- if (commit)
1347
- this.commitDraft(col);
1348
- }
1349
- /** Position (0-100%) of a range value on the track. */
1350
- rangePercent(col, value) {
1351
- const [min, max] = this.rangeBounds(col);
1352
- return max === min ? 0 : ((value - min) / (max - min)) * 100;
1353
- }
1354
- /**
1355
- * Resets the global search, every column filter, the sort and the page
1356
- * (the "Clear" button).
1357
- */
1358
- clearAll() {
1359
- const state = {};
1360
- this.columns()
1361
- .filter((c) => c.filter)
1362
- .forEach((col) => (state[col.field] = this.emptyFilterState(col)));
1363
- this.filterState.set(state);
1364
- this.closeFilters();
1365
- const hadSearch = !!this.searchQuery();
1366
- this.searchQuery.set('');
1367
- this.sortField.set(this.defaultSortField());
1368
- this.sortOrder.set(this.defaultSortOrder());
1369
- this.first.set(0);
1370
- if (this.serverSide()) {
1371
- this.emitFilterChange();
1372
- if (hadSearch)
1373
- this.searchChange.emit('');
1374
- }
1375
- else {
1376
- this.applyFilters();
1377
- }
1378
- this.cdr.markForCheck();
1379
- }
1380
- /**
1381
- * Toggles a column filter menu. Only one menu is open at a time. The menu
1382
- * uses `position: fixed` anchored to the filter button, so the header cell
1383
- * and the scroll wrapper can't clip it. Edits go to a draft that is applied
1384
- * with the Apply button (select/multiselect/boolean/range apply instantly).
1385
- */
1386
- toggleFilter(col, event) {
1387
- const wasOpen = this.openFilterField() === col.field;
1388
- this.closeFilters();
1389
- if (wasOpen)
1390
- return;
1391
- this.filterAnchor = event?.currentTarget ?? null;
1392
- this.updateFilterPopupPosition();
1393
- const applied = this.filterState()[col.field] ?? this.emptyFilterState(col);
1394
- this.filterDraft.set(this.cloneState(applied));
1395
- this.multiselectOpen.set(false);
1396
- this.openFilterField.set(col.field);
1397
- const reposition = () => this.updateFilterPopupPosition();
1398
- window.addEventListener('scroll', reposition, true);
1399
- window.addEventListener('resize', reposition);
1400
- this.filterListenersCleanup = () => {
1401
- window.removeEventListener('scroll', reposition, true);
1402
- window.removeEventListener('resize', reposition);
1403
- };
1404
- setTimeout(() => document.querySelector(`#${this.uid}-filter-${this.safeId(col.field)}-0`)?.focus());
1405
- this.cdr.markForCheck();
1406
- }
1407
- /** Field name usable inside an element id. */
1408
- safeId(field) {
1409
- return field.replace(/[^a-zA-Z0-9_-]/g, '_');
1410
- }
1411
- /** Closes the column filter menu (unapplied draft changes are discarded). */
1412
- closeFilters() {
1413
- this.filterListenersCleanup?.();
1414
- this.filterListenersCleanup = null;
1415
- this.filterAnchor = null;
1416
- if (this.openFilterField() !== null) {
1417
- this.openFilterField.set(null);
1418
- this.filterDraft.set(null);
1419
- this.cdr.markForCheck();
1420
- }
1421
- }
1422
- /** Places the filter menu under its button, clamped to the viewport. */
1423
- updateFilterPopupPosition() {
1424
- if (!this.filterAnchor)
1425
- return;
1426
- const rect = this.filterAnchor.getBoundingClientRect();
1427
- const maxLeft = window.innerWidth - this.FILTER_POPUP_WIDTH - 8;
1428
- const left = Math.max(8, Math.min(rect.left, maxLeft));
1429
- const top = rect.bottom + 6;
1430
- this.filterPopupPosition.set({
1431
- top,
1432
- left,
1433
- maxHeight: Math.max(200, window.innerHeight - top - 12),
1434
- });
1435
- }
1436
- // ---------------------------------------------------------------------------
1437
- // Pagination
1438
- // ---------------------------------------------------------------------------
1439
- /** Returns the reactive page report string (template helper). */
1440
- getPageReport() {
1441
- return this.pageReport();
1442
- }
1443
- /** Goes to a page (0-based), emitting pageChange in server-side mode. */
1444
- goToPage(page) {
1445
- const rows = this.rowsPerPageLocal();
1446
- const total = this.effectiveTotalRecords();
1447
- const pageCount = Math.max(1, Math.ceil(total / rows));
1448
- const target = Math.min(Math.max(0, page), pageCount - 1);
1449
- const first = target * rows;
1450
- this.first.set(first);
1451
- if (this.serverSide()) {
1452
- this.pageChange.emit({ first, rows, page: target, pageCount: Math.ceil(total / rows) });
1453
- }
1454
- else {
1455
- this.updateDisplayedData();
1456
- }
1457
- }
1458
- /** Goes to the first page (emits pageChange in server-side mode). */
1459
- goToFirst() {
1460
- this.goToPage(0);
1461
- }
1462
- /** Goes to the last page (emits pageChange in server-side mode). */
1463
- goToLast() {
1464
- this.goToPage(this.totalPages() - 1);
1465
- }
1466
- /** Updates rows-per-page and resets to the first page. */
1467
- onRowsPerPageChange(rows) {
1468
- rows = Number(rows);
1469
- this.rowsPerPageLocal.set(rows);
1470
- this.goToPage(0);
1471
- }
1472
- /** Emits the refresh output. */
1473
- refreshData() {
1474
- this.refresh.emit();
1475
- }
1476
- /** Whether the current page is the first one. */
1477
- isFirstPage() {
1478
- return this.first() === 0;
1479
- }
1480
- /** Whether the current page is the last one. */
1481
- isLastPage() {
1482
- return this.first() + this.rowsPerPageLocal() >= this.effectiveTotalRecords();
1483
- }
1484
- /** Moves to the next page (emits pageChange in server-side mode). */
1485
- next() {
1486
- this.goToPage(this.currentPage());
1487
- }
1488
- /** Moves to the previous page (emits pageChange in server mode). */
1489
- prev() {
1490
- this.goToPage(this.currentPage() - 2);
1491
- }
1492
- /** Resets the table to the first page. */
1493
- reset() {
1494
- this.goToFirst();
1495
- }
1496
- // ---------------------------------------------------------------------------
1497
- // Actions & cells
1498
- // ---------------------------------------------------------------------------
1499
- /** Resolves the row action label, static or per-row function. */
1500
- /** Text of a `template: 'date'` cell (column pattern, else the `dates.*` options). */
1501
- formatDateCell(value, col) {
1502
- const locale = this.config.get('dates.locale')();
1503
- const named = col.dateFormat && NAMED_DATE_STYLES[col.dateFormat];
1504
- if (named)
1505
- return formatDateStyle(value, named[0], locale, named[1]);
1506
- const pattern = resolveDateFormat(col.dateFormat || this.config.get('dates.format')(), locale);
1507
- return formatDate(value, pattern, locale);
1508
- }
1509
- /** Text of a `template: 'currency'` cell (column currency, else the `numbers.*` options). */
1510
- formatCurrencyCell(value, col) {
1511
- return formatCurrency(value, col.currency || this.config.get('numbers.currency')(), this.config.get('numbers.locale')(), this.config.get('numbers.decimals')());
1512
- }
1513
- getRowActionLabel(action, rowData) {
1514
- return typeof action.label === 'function' ? action.label(rowData) : action.label;
1515
- }
1516
- /**
1517
- * Resolves the row action icon: `IconNode` data, a function returning the
1518
- * icon for the row, or a raw string resolved by the central icon map.
1519
- */
1520
- getRowActionIconName(action, rowData) {
1521
- const icon = action.icon;
1522
- return isIconResolver(icon) ? icon(rowData) : icon;
1523
- }
1524
- /** Resolves the CSS class of a row action, static or per-row function. */
1525
- getRowActionClass(action, rowData) {
1526
- if (!action.class)
1527
- return '';
1528
- return typeof action.class === 'function' ? action.class(rowData) : action.class;
1529
- }
1530
- /** Whether a header action is disabled. */
1531
- isHeaderActionDisabled(action) {
1532
- return action.isDisabled ? action.isDisabled() : false;
1533
- }
1534
- /** Whether a header action is visible. */
1535
- isHeaderActionVisible(action) {
1536
- return action.isVisible ? action.isVisible() : true;
1537
- }
1538
- /** Whether a row action is disabled for the given row. */
1539
- isRowActionDisabled(action, rowData) {
1540
- return action.isDisabled ? action.isDisabled(rowData) : false;
1541
- }
1542
- /** Whether a row action is visible for the given row. */
1543
- isRowActionVisible(action, rowData) {
1544
- return action.isVisible ? action.isVisible(rowData) : true;
1545
- }
1546
- /** Truncates a value with an ellipsis past the given character limit. */
1547
- truncate(value, limit = 30) {
1548
- if (value === null || value === undefined)
1549
- return '';
1550
- const str = String(value);
1551
- return str.length > limit ? str.slice(0, limit) + '…' : str;
1552
- }
1553
- /** Value of a `progress` cell clamped to 0-100. */
1554
- getProgress(col, rowData) {
1555
- const n = Number(this.resolveField(rowData, col.field));
1556
- return isNaN(n) ? 0 : Math.max(0, Math.min(100, n));
1557
- }
1558
- /** Resolves the value displayed inside a tag cell, static or per-row function. */
1559
- getTagValue(col, rowData) {
1560
- return col.tagValue ? col.tagValue(rowData) : String(this.resolveField(rowData, col.field) ?? '');
1561
- }
1562
- /** Resolves and validates the tag severity, falling back to 'secondary'. */
1563
- getTagSeverity(col, rowData) {
1564
- const raw = col.tagSeverity ? col.tagSeverity(rowData) : 'secondary';
1565
- const allowed = [
1566
- 'secondary',
1567
- 'success',
1568
- 'info',
1569
- 'warning',
1570
- 'danger',
1571
- 'contrast',
1572
- ];
1573
- return allowed.includes(raw) ? raw : 'secondary';
1574
- }
1575
- /** Resolves whether the tag in a cell is rounded, static or per-row function. */
1576
- getTagRounded(col, rowData) {
1577
- if (typeof col.tagRounded === 'function')
1578
- return col.tagRounded(rowData);
1579
- return col.tagRounded ?? false;
1580
- }
1581
- /** Resolves the icon shown inside a tag cell, static or per-row function. */
1582
- getTagIcon(col, rowData) {
1583
- if (typeof col.tagIcon === 'function')
1584
- return col.tagIcon(rowData);
1585
- return col.tagIcon ?? '';
1586
- }
1587
- /** Resolves the CSS styles of a tag cell, static or per-row function. */
1588
- getTagStyle(col, rowData) {
1589
- return col.tagStyle ? col.tagStyle(rowData) || {} : {};
1590
- }
1591
- /**
1592
- * trackBy for row identity: prefers `id`/`_id` and falls back to the index.
1593
- */
1594
- trackByRow(row, index) {
1595
- return row?.id ?? row?._id ?? index;
1596
- }
1597
- /** Keyboard support (Enter/Space) for sorting a column header. */
1598
- onHeaderKeydown(event, col) {
1599
- if (col.field === 'actions' || !col.sortable)
1600
- return;
1601
- // Ignore keys typed inside the header buttons.
1602
- if (event.target !== event.currentTarget)
1603
- return;
1604
- if (event.key === 'Enter' || event.key === ' ') {
1605
- event.preventDefault();
1606
- this.toggleSort(col.field);
1607
- }
1608
- }
1609
- /** Accessible aria-sort value for a given column header. */
1610
- getAriaSort(col) {
1611
- if (col.field === 'actions' || !col.sortable)
1612
- return 'none';
1613
- if (this.sortField() !== col.field)
1614
- return 'none';
1615
- return this.sortOrder() === 1 ? 'ascending' : 'descending';
1616
- }
1617
- /** Returns the row actions that should be displayed as direct icon buttons. */
1618
- getVisibleRowActions(rowData) {
1619
- const visible = this.rowActions().filter((a) => this.isRowActionVisible(a, rowData));
1620
- return visible.slice(0, this.MAX_VISIBLE_ACTIONS);
1621
- }
1622
- /** Returns the row actions that overflow into the "more" dropdown. */
1623
- getHiddenRowActions(rowData) {
1624
- const visible = this.rowActions().filter((a) => this.isRowActionVisible(a, rowData));
1625
- return visible.slice(this.MAX_VISIBLE_ACTIONS);
1626
- }
1627
- /** Toggles the "more actions" dropdown for a given row, closing any other open dropdown. */
1628
- toggleActionsDropdown(rowData, event) {
1629
- const key = this.getRowKey(rowData);
1630
- const current = this.actionsDropdownOpen();
1631
- const wasOpen = !!current[key];
1632
- const next = {};
1633
- if (!wasOpen) {
1634
- next[key] = true;
1635
- }
1636
- this.actionsDropdownOpen.set(next);
1637
- if (!wasOpen) {
1638
- this.computeDropdownPosition(event);
1639
- }
1640
- }
1641
- computeDropdownPosition(event) {
1642
- if (!event)
1643
- return;
1644
- const target = (event.currentTarget || event.target);
1645
- const rect = target.getBoundingClientRect();
1646
- const dropdownHeight = 180;
1647
- const spaceBelow = window.innerHeight - rect.bottom;
1648
- let top = rect.bottom + 4;
1649
- let left = rect.right - 160;
1650
- if (spaceBelow < dropdownHeight) {
1651
- top = rect.top - dropdownHeight - 4;
1652
- }
1653
- if (left < 8) {
1654
- left = 8;
1655
- }
1656
- this.dropdownPosition.set({ top, left });
1657
- }
1658
- /** Whether the "more actions" dropdown is open for a given row. */
1659
- isActionsDropdownOpen(rowData) {
1660
- const key = this.getRowKey(rowData);
1661
- return !!this.actionsDropdownOpen()[key];
1662
- }
1663
- /** Returns a unique key for a row to track dropdown state. */
1664
- getRowKey(rowData) {
1665
- return String(rowData?.id ?? rowData?._id ?? JSON.stringify(rowData));
1666
- }
1667
- /** Closes all open action dropdowns when clicking anywhere on the document. */
1668
- onDocumentClick() {
1669
- const current = this.actionsDropdownOpen();
1670
- const hasOpen = Object.values(current).some((v) => v);
1671
- if (hasOpen) {
1672
- this.actionsDropdownOpen.set({});
1673
- }
1674
- this.closeFilters();
1675
- }
1676
- /** Closes the column filter menu with Escape. */
1677
- onEscape() {
1678
- this.closeFilters();
1679
- }
1680
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.27", ngImport: i0, type: TableComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1681
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.27", type: TableComponent, isStandalone: true, selector: "shk-table", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, columns: { classPropertyName: "columns", publicName: "columns", isSignal: true, isRequired: false, transformFunction: null }, rowsPerPage: { classPropertyName: "rowsPerPage", publicName: "rowsPerPage", isSignal: true, isRequired: false, transformFunction: null }, rowsPerPageOptions: { classPropertyName: "rowsPerPageOptions", publicName: "rowsPerPageOptions", isSignal: true, isRequired: false, transformFunction: null }, loading: { classPropertyName: "loading", publicName: "loading", isSignal: true, isRequired: false, transformFunction: null }, showActionRow: { classPropertyName: "showActionRow", publicName: "showActionRow", isSignal: true, isRequired: false, transformFunction: null }, customTemplates: { classPropertyName: "customTemplates", publicName: "customTemplates", isSignal: true, isRequired: false, transformFunction: null }, headerActions: { classPropertyName: "headerActions", publicName: "headerActions", isSignal: true, isRequired: false, transformFunction: null }, rowActions: { classPropertyName: "rowActions", publicName: "rowActions", isSignal: true, isRequired: false, transformFunction: null }, hasShadow: { classPropertyName: "hasShadow", publicName: "hasShadow", isSignal: true, isRequired: false, transformFunction: null }, defaultSortField: { classPropertyName: "defaultSortField", publicName: "defaultSortField", isSignal: true, isRequired: false, transformFunction: null }, defaultSortOrder: { classPropertyName: "defaultSortOrder", publicName: "defaultSortOrder", isSignal: true, isRequired: false, transformFunction: null }, showSearch: { classPropertyName: "showSearch", publicName: "showSearch", isSignal: true, isRequired: false, transformFunction: null }, searchPlaceholder: { classPropertyName: "searchPlaceholder", publicName: "searchPlaceholder", isSignal: true, isRequired: false, transformFunction: null }, globalFilterFields: { classPropertyName: "globalFilterFields", publicName: "globalFilterFields", isSignal: true, isRequired: false, transformFunction: null }, emptyMessage: { classPropertyName: "emptyMessage", publicName: "emptyMessage", isSignal: true, isRequired: false, transformFunction: null }, serverSide: { classPropertyName: "serverSide", publicName: "serverSide", isSignal: true, isRequired: false, transformFunction: null }, totalRecords: { classPropertyName: "totalRecords", publicName: "totalRecords", isSignal: true, isRequired: false, transformFunction: null }, filters: { classPropertyName: "filters", publicName: "filters", isSignal: true, isRequired: false, transformFunction: null }, activeFilter: { classPropertyName: "activeFilter", publicName: "activeFilter", isSignal: true, isRequired: false, transformFunction: null }, showGridlines: { classPropertyName: "showGridlines", publicName: "showGridlines", isSignal: true, isRequired: false, transformFunction: null }, resizableColumns: { classPropertyName: "resizableColumns", publicName: "resizableColumns", isSignal: true, isRequired: false, transformFunction: null }, rowValidations: { classPropertyName: "rowValidations", publicName: "rowValidations", isSignal: true, isRequired: false, transformFunction: null }, columnWidths: { classPropertyName: "columnWidths", publicName: "columnWidths", isSignal: true, isRequired: false, transformFunction: null }, stateKey: { classPropertyName: "stateKey", publicName: "stateKey", isSignal: true, isRequired: false, transformFunction: null }, stateStorage: { classPropertyName: "stateStorage", publicName: "stateStorage", isSignal: true, isRequired: false, transformFunction: null }, rowHover: { classPropertyName: "rowHover", publicName: "rowHover", isSignal: true, isRequired: false, transformFunction: null }, showClearButton: { classPropertyName: "showClearButton", publicName: "showClearButton", isSignal: true, isRequired: false, transformFunction: null }, showPageReport: { classPropertyName: "showPageReport", publicName: "showPageReport", isSignal: true, isRequired: false, transformFunction: null }, showRowsPerPage: { classPropertyName: "showRowsPerPage", publicName: "showRowsPerPage", isSignal: true, isRequired: false, transformFunction: null }, selectable: { classPropertyName: "selectable", publicName: "selectable", isSignal: true, isRequired: false, transformFunction: null }, dataKey: { classPropertyName: "dataKey", publicName: "dataKey", isSignal: true, isRequired: false, transformFunction: null }, isRowSelectable: { classPropertyName: "isRowSelectable", publicName: "isRowSelectable", isSignal: true, isRequired: false, transformFunction: null }, selectOnRowClick: { classPropertyName: "selectOnRowClick", publicName: "selectOnRowClick", isSignal: true, isRequired: false, transformFunction: null }, bulkActions: { classPropertyName: "bulkActions", publicName: "bulkActions", isSignal: true, isRequired: false, transformFunction: null }, selection: { classPropertyName: "selection", publicName: "selection", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { columnWidths: "columnWidthsChange", selection: "selectionChange", refresh: "refresh", pageChange: "pageChange", filterChange: "filterChange", searchChange: "searchChange", filterClick: "filterClick", columnResize: "columnResize" }, host: { listeners: { "document:click": "onDocumentClick()", "document:keydown.escape": "onEscape()" } }, ngImport: i0, template: "<div class=\"space-y-2 min-[1440px]:space-y-3 mt-2 min-[1440px]:mt-3 animate-fade-in pb-8\">\n @if (\n showSearch() ||\n (showClearButton() && hasFilterableColumns()) ||\n filters().length > 0 ||\n headerActions().length > 0 ||\n (selectable() && bulkActions().length > 0 && selection().length > 0)\n ) {\n <div class=\"card p-2 min-[1440px]:p-2.5 flex flex-row items-center justify-between gap-2\">\n <div class=\"flex items-center gap-2 min-[1440px]:gap-3 flex-1 min-w-0\">\n @if (showSearch()) {\n <div class=\"relative w-full md:w-52 min-[1440px]:w-56\">\n <label [for]=\"uid + '-search'\" class=\"sr-only\">{{\n searchPlaceholder() || ('common.search_placeholder' | transloco)\n }}</label>\n <div class=\"absolute inset-y-0 left-0 pl-2.5 flex items-center pointer-events-none\">\n <svg\n [shkIcon]=\"getIcon('search')\"\n class=\"w-3.5 h-3.5 _shk-text-surface-400\"\n ></svg>\n </div>\n <input\n [id]=\"uid + '-search'\"\n type=\"text\"\n [value]=\"searchQuery()\"\n (input)=\"onSearchInput($any($event.target).value)\"\n [placeholder]=\"searchPlaceholder() || ('common.search_placeholder' | transloco)\"\n class=\"block w-full pl-8 pr-3 py-1.5 text-xs border _shk-border rounded-md leading-5 _shk-bg-surface-50 placeholder:[color:var(--shk-surface-400)] dark:placeholder:[color:var(--shk-surface-500)] _shk-text-surface-700 focus:outline-none focus:bg-white dark:focus:[background-color:var(--shk-surface-100)] focus:[border-color:var(--shk-primary-500)] focus:ring-1 focus:[--tw-ring-color:var(--shk-primary-500)]\"\n />\n </div>\n }\n @if (showClearButton() && (hasFilterableColumns() || showSearch())) {\n <shk-tooltip [text]=\"tr('table.clearFilters', 'Limpiar b\u00FAsqueda, filtros y orden')\">\n <button\n type=\"button\"\n (click)=\"clearAll()\"\n [disabled]=\"!hasActiveFilters()\"\n class=\"inline-flex items-center gap-1.5 px-2.5 py-1.5 text-xs font-medium rounded-md border _shk-border _shk-text-surface-600 hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] transition-colors disabled:opacity-40 disabled:cursor-not-allowed whitespace-nowrap\"\n >\n <svg [shkIcon]=\"icons.clear\" class=\"w-3.5 h-3.5\"></svg>\n {{ tr('table.clear', 'Limpiar') }}\n </button>\n </shk-tooltip>\n }\n @if (filters().length > 0) {\n <div\n class=\"flex _shk-bg-surface-100 p-0.5 rounded-md ml-auto\"\n role=\"group\"\n >\n @for (f of filters(); track f.value) {\n <button\n type=\"button\"\n (click)=\"onFilterClick(f.value)\"\n [attr.aria-pressed]=\"f.value === activeFilter()\"\n class=\"px-2.5 min-[1440px]:px-3 py-1 text-xs font-medium rounded _shk-text-surface-700 transition-all\"\n [class]=\"\n f.value === activeFilter()\n ? 'bg-white shadow-sm dark:[background-color:var(--shk-surface-700)]'\n : ''\n \"\n >\n {{ f.label }}\n </button>\n }\n </div>\n }\n </div>\n @if (selectable() && selection().length > 0 && bulkActions().length > 0) {\n <div\n class=\"flex items-center gap-1.5 shrink-0\"\n role=\"toolbar\"\n [attr.aria-label]=\"'table.selected' | transloco: { count: selection().length }\"\n >\n <span\n class=\"text-xs font-medium _shk-text-surface-600 whitespace-nowrap\"\n aria-live=\"polite\"\n >{{ 'table.selected' | transloco: { count: selection().length } }}</span\n >\n <button\n type=\"button\"\n (click)=\"clearSelection()\"\n [attr.aria-label]=\"'table.clearSelection' | transloco\"\n class=\"table-action-btn rounded-md _shk-text-surface-500 hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)]\"\n >\n <svg [shkIcon]=\"getIcon('x')\" class=\"w-3.5 h-3.5\"></svg>\n </button>\n @for (action of visibleBulkActions(); track $index) {\n <button\n type=\"button\"\n [class]=\"\n 'inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-md _shk-bg-primary text-white hover:[background-color:var(--shk-primary-700)] transition-colors disabled:opacity-50 disabled:cursor-not-allowed ' +\n (action.class || '')\n \"\n [disabled]=\"isBulkActionDisabled(action)\"\n [attr.aria-label]=\"action.label\"\n (click)=\"runBulkAction(action)\"\n >\n @if (action.icon) {\n <svg [shkIcon]=\"getIcon(action.icon)\" class=\"w-3.5 h-3.5\"></svg>\n }\n {{ action.label }}\n </button>\n }\n </div>\n }\n @if (headerActions().length > 0) {\n <div class=\"flex items-center gap-1.5 shrink-0\">\n @for (action of headerActions(); track $index) {\n @if (isHeaderActionVisible(action)) {\n <button\n type=\"button\"\n [class]=\"\n 'inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-md _shk-bg-primary text-white hover:[background-color:var(--shk-primary-700)] transition-colors disabled:opacity-50 disabled:cursor-not-allowed ' +\n (action.class || '')\n \"\n [disabled]=\"isHeaderActionDisabled(action)\"\n [attr.aria-label]=\"action.label\"\n (click)=\"action.onClick()\"\n >\n @if (action.icon) {\n <svg [shkIcon]=\"getIcon(action.icon)\" class=\"w-3.5 h-3.5\"></svg>\n }\n {{ action.label }}\n </button>\n }\n }\n </div>\n }\n </div>\n }\n <div class=\"card p-0 overflow-hidden table-card\" [class.shadow-lg]=\"hasShadow()\">\n <div class=\"table-scroll-wrapper _shk-scrollbar\">\n <table\n class=\"shk-data-table\"\n [class.shk-gridlines]=\"showGridlines()\"\n [class.shk-row-hover]=\"rowHover()\"\n >\n <thead>\n <tr>\n @if (selectable()) {\n <th\n scope=\"col\"\n data-shk-select\n class=\"w-10 px-2 min-[1440px]:px-3 py-2 min-[1440px]:py-2.5 text-center _shk-bg-surface-50 border-b _shk-border\"\n >\n <input\n type=\"checkbox\"\n class=\"shk-table-checkbox\"\n [checked]=\"allPageSelected()\"\n [indeterminate]=\"somePageSelected()\"\n [disabled]=\"loading() || selectablePageRows().length === 0\"\n (change)=\"toggleSelectAllPage()\"\n [attr.aria-label]=\"'table.selectAll' | transloco\"\n />\n </th>\n }\n @for (col of columnsWithActions(); track col.field) {\n <th\n scope=\"col\"\n (click)=\"onHeaderClick(col)\"\n (keydown)=\"onHeaderKeydown($event, col)\"\n [tabindex]=\"col.field !== 'actions' && col.sortable ? 0 : -1\"\n [attr.role]=\"col.field !== 'actions' && col.sortable ? 'button' : null\"\n [attr.aria-sort]=\"getAriaSort(col)\"\n [attr.data-shk-actions]=\"col.field === 'actions' ? '' : null\"\n [style.cursor]=\"col.field !== 'actions' && col.sortable ? 'pointer' : 'default'\"\n [style.width]=\"resizedWidth(col) || (col.field === 'actions' ? col.width : null)\"\n [style.min-width]=\"resizedWidth(col) || (col.field === 'actions' ? col.width : col.minWidth) || null\"\n [style.--shk-col-width]=\"col.field !== 'actions' ? getColumnWidth(col) : null\"\n class=\"relative px-2 min-[1440px]:px-3 py-2 min-[1440px]:py-2.5 text-left text-[10px] min-[1440px]:text-xs font-bold _shk-text-surface-500 uppercase tracking-wider _shk-bg-surface-50 border-b _shk-border focus:outline-none focus-visible:ring-1 focus-visible:[--tw-ring-color:var(--shk-primary-500)]\"\n >\n @if (col.field !== 'actions') {\n <div class=\"flex items-center justify-between gap-2\">\n <span>{{ col.header }}</span>\n <div class=\"flex items-center gap-1 shrink-0\">\n @if (col.sortable) {\n <shk-tooltip [text]=\"'table.tooltips.sort' | transloco\">\n @if (sortField() === col.field) {\n <svg\n [shkIcon]=\"getIcon(sortOrder() === 1 ? 'arrow-up' : 'arrow-down')\"\n class=\"w-3.5 h-3.5 _shk-text-primary\"\n ></svg>\n } @else {\n <svg\n [shkIcon]=\"getIcon('arrow-up-down')\"\n class=\"w-3.5 h-3.5 _shk-text-surface-400\"\n ></svg>\n }\n </shk-tooltip>\n }\n @if (col.filter) {\n <shk-tooltip [text]=\"'table.tooltips.filter' | transloco\">\n <button\n type=\"button\"\n (click)=\"$event.stopPropagation(); toggleFilter(col, $event)\"\n [attr.aria-label]=\"('table.tooltips.filter' | transloco) + ': ' + col.header\"\n [attr.aria-expanded]=\"openFilterField() === col.field\"\n aria-haspopup=\"dialog\"\n class=\"_shk-text-surface-400 hover:[color:var(--shk-surface-600)] dark:hover:[color:var(--shk-surface-300)] transition-colors\"\n >\n <svg\n [shkIcon]=\"getIcon('filter')\"\n class=\"w-3.5 h-3.5\"\n [class._shk-text-primary]=\"hasFilterValue(col.field) || openFilterField() === col.field\"\n ></svg>\n </button>\n </shk-tooltip>\n }\n </div>\n </div>\n\n\n <!-- Column filter menu -->\n @if (col.filter && openFilterField() === col.field && filterDraft(); as draft) {\n <div\n shkPortal\n class=\"shk-filter-overlay fixed z-[9999] w-[240px] overflow-y-auto normal-case tracking-normal font-normal text-xs _shk-text-surface-700 bg-white dark:[background-color:var(--shk-surface-100)] border _shk-border rounded-lg shadow-lg\"\n role=\"dialog\"\n [attr.aria-label]=\"('table.tooltips.filter' | transloco) + ': ' + col.header\"\n [style.top.px]=\"filterPopupPosition().top\"\n [style.left.px]=\"filterPopupPosition().left\"\n [style.max-height.px]=\"filterPopupPosition().maxHeight\"\n (click)=\"$event.stopPropagation()\"\n (keydown)=\"$event.stopPropagation()\"\n (keydown.escape)=\"closeFilters()\"\n >\n @if (col.filterMenuTitle) {\n <div class=\"px-2 pt-2 font-semibold _shk-text-surface-800\">\n {{ col.filterMenuTitle }}\n </div>\n }\n @if (showOperatorFor(col)) {\n <div class=\"p-2 border-b _shk-border\">\n <select\n class=\"shk-filter-select\"\n [attr.aria-label]=\"filterLabel('matchAll') + ' / ' + filterLabel('matchAny')\"\n (change)=\"setDraftOperator($any($event.target).value)\"\n >\n <option value=\"and\" [selected]=\"draft.operator === 'and'\">\n {{ filterLabel('matchAll') }}\n </option>\n <option value=\"or\" [selected]=\"draft.operator === 'or'\">\n {{ filterLabel('matchAny') }}\n </option>\n </select>\n </div>\n }\n\n @switch (filterKind(col)) {\n @case ('select') {\n <ng-container\n *ngTemplateOutlet=\"optionList; context: { $implicit: col, draft: draft, multiple: false }\"\n ></ng-container>\n }\n @case ('multiselect') {\n <ng-container\n *ngTemplateOutlet=\"optionList; context: { $implicit: col, draft: draft, multiple: true }\"\n ></ng-container>\n }\n @case ('boolean') {\n @let boolValue = draft.rules[0].value;\n <div class=\"p-2\">\n <button\n type=\"button\"\n role=\"checkbox\"\n [id]=\"uid + '-filter-' + safeId(col.field) + '-0'\"\n class=\"inline-flex items-center gap-2 rounded-md focus:outline-none focus-visible:ring-1 focus-visible:[--tw-ring-color:var(--shk-primary-500)]\"\n [attr.aria-checked]=\"\n boolValue === true ? 'true' : boolValue === false ? 'false' : 'mixed'\n \"\n (click)=\"cycleBoolean(col)\"\n >\n <span\n class=\"shk-checkbox-box\"\n [class.shk-checked]=\"boolValue === true || boolValue === false\"\n >\n @if (boolValue === true) {\n <svg [shkIcon]=\"getIcon('check')\"></svg>\n } @else if (boolValue === false) {\n <svg [shkIcon]=\"getIcon('x')\"></svg>\n }\n </span>\n <span>{{\n boolValue === true\n ? filterLabel('yes')\n : boolValue === false\n ? filterLabel('no')\n : filterLabel('any')\n }}</span>\n </button>\n </div>\n }\n @case ('range') {\n @let rv = rangeValue(col);\n @let bounds = rangeBounds(col);\n <div class=\"p-2\">\n <div class=\"shk-range\">\n <div class=\"shk-range-track\"></div>\n <div\n class=\"shk-range-fill\"\n [style.left.%]=\"rangePercent(col, rv[0])\"\n [style.width.%]=\"rangePercent(col, rv[1]) - rangePercent(col, rv[0])\"\n ></div>\n <input\n type=\"range\"\n [id]=\"uid + '-filter-' + safeId(col.field) + '-0'\"\n [min]=\"bounds[0]\"\n [max]=\"bounds[1]\"\n [step]=\"col.filterStep || 1\"\n [value]=\"rv[0]\"\n [style.z-index]=\"rv[0] >= bounds[1] ? 3 : null\"\n [attr.aria-label]=\"col.header + ' min'\"\n (input)=\"onRangeInput(col, 0, $any($event.target).value, false)\"\n (change)=\"onRangeInput(col, 0, $any($event.target).value, true)\"\n />\n <input\n type=\"range\"\n [min]=\"bounds[0]\"\n [max]=\"bounds[1]\"\n [step]=\"col.filterStep || 1\"\n [value]=\"rv[1]\"\n [attr.aria-label]=\"col.header + ' max'\"\n (input)=\"onRangeInput(col, 1, $any($event.target).value, false)\"\n (change)=\"onRangeInput(col, 1, $any($event.target).value, true)\"\n />\n </div>\n <div class=\"flex items-center justify-between px-0.5 _shk-text-surface-500\">\n <span>{{ rv[0] }}</span>\n <span>{{ rv[1] }}</span>\n </div>\n </div>\n }\n @default {\n <!-- text / numeric / date: one block per rule -->\n @for (rule of draft.rules; track $index; let i = $index) {\n <div\n class=\"flex flex-col gap-1.5 p-2\"\n [class.border-b]=\"i < draft.rules.length - 1\"\n [class._shk-border]=\"i < draft.rules.length - 1\"\n >\n @if (showMatchModesFor(col)) {\n <select\n class=\"shk-filter-select\"\n [attr.aria-label]=\"col.header\"\n (change)=\"setDraftMatchMode(col, i, $any($event.target).value)\"\n >\n @for (mode of matchModesFor(col); track mode) {\n <option [value]=\"mode\" [selected]=\"mode === rule.matchMode\">\n {{ matchModeLabel(mode) }}\n </option>\n }\n </select>\n }\n <input\n [id]=\"uid + '-filter-' + safeId(col.field) + '-' + i\"\n [type]=\"filterKind(col) === 'numeric' ? 'number' : filterKind(col) === 'date' ? 'date' : 'text'\"\n [attr.step]=\"filterKind(col) === 'numeric' ? 'any' : null\"\n class=\"shk-filter-input\"\n [value]=\"rule.value ?? ''\"\n [placeholder]=\"col.filterPlaceholder || ('common.search_placeholder' | transloco)\"\n [attr.aria-label]=\"col.header\"\n (input)=\"onRuleInput(col, i, $any($event.target).value)\"\n (keydown.enter)=\"applyFilter(col)\"\n />\n @if (draft.rules.length > 1) {\n <button\n type=\"button\"\n class=\"inline-flex items-center justify-center gap-1 py-1 rounded-md [color:var(--shk-error-600)] hover:[background-color:var(--shk-error-50)] transition-colors\"\n (click)=\"removeRule(i)\"\n >\n <svg [shkIcon]=\"icons.trash\" class=\"w-3.5 h-3.5\"></svg>\n {{ filterLabel('removeRule') }}\n </button>\n }\n </div>\n }\n @if (canAddRule(col)) {\n <div class=\"px-2 pb-1\">\n <button\n type=\"button\"\n class=\"w-full inline-flex items-center justify-center gap-1 py-1 rounded-md _shk-text-primary hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] transition-colors\"\n (click)=\"addRule(col)\"\n >\n <svg [shkIcon]=\"getIcon('plus')\" class=\"w-3.5 h-3.5\"></svg>\n {{ filterLabel('addRule') }}\n </button>\n </div>\n }\n }\n }\n\n <div class=\"flex items-center justify-between gap-2 p-2 border-t _shk-border\">\n <button\n type=\"button\"\n class=\"px-3 py-1.5 font-medium rounded-md border _shk-border _shk-text-surface-600 hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] transition-colors\"\n (click)=\"clearFilter(col.field)\"\n >\n {{ filterLabel('clear') }}\n </button>\n <button\n type=\"button\"\n class=\"px-3 py-1.5 font-medium rounded-md _shk-bg-primary text-white hover:[background-color:var(--shk-primary-700)] transition-colors\"\n (click)=\"applyFilter(col)\"\n >\n {{ filterLabel('apply') }}\n </button>\n </div>\n </div>\n }\n } @else {\n <div class=\"flex items-center justify-center\">\n <span>{{ col.header }}</span>\n </div>\n }\n @if (isResizable()) {\n <span\n class=\"shk-col-resizer\"\n [class.shk-resizing]=\"resizingField() === col.field\"\n role=\"separator\"\n aria-orientation=\"vertical\"\n tabindex=\"0\"\n [attr.aria-label]=\"tr('table.resizeColumn', 'Redimensionar columna') + ': ' + col.header\"\n [attr.aria-valuenow]=\"resizedWidthPx(col)\"\n (pointerdown)=\"startResize($event, col)\"\n (click)=\"$event.stopPropagation()\"\n (dblclick)=\"$event.stopPropagation(); resetColumnWidth(col)\"\n (keydown)=\"onResizerKeydown($event, col)\"\n ></span>\n }\n </th>\n }\n </tr>\n </thead>\n @if (loading()) {\n <tbody class=\"border-b _shk-border\">\n <tr>\n <td [attr.colspan]=\"totalColspan()\" class=\"text-center py-12\">\n <div\n class=\"flex items-center justify-center\"\n role=\"status\"\n [attr.aria-label]=\"'common.loading' | transloco\"\n >\n <svg\n [shkIcon]=\"getIcon('loader')\"\n class=\"w-6 h-6 animate-spin _shk-text-primary\"\n ></svg>\n </div>\n </td>\n </tr>\n </tbody>\n } @else if (effectiveDisplayedData().length === 0) {\n <tbody class=\"border-b _shk-border\">\n <tr>\n <td [attr.colspan]=\"totalColspan()\" class=\"text-center py-12\">\n <div class=\"flex flex-col items-center\">\n <div\n class=\"w-16 h-16 _shk-bg-surface-100 rounded-full flex items-center justify-center mb-4\"\n >\n <svg\n [shkIcon]=\"getIcon('inbox')\"\n class=\"w-8 h-8 _shk-text-surface-400\"\n ></svg>\n </div>\n <p\n class=\"text-lg font-semibold _shk-text-surface-600\"\n >\n {{ emptyMessage() || ('common.no_records' | transloco) }}\n </p>\n </div>\n </td>\n </tr>\n </tbody>\n } @else {\n <tbody>\n @for (rowData of effectiveDisplayedData(); track trackByRow(rowData, $index)) {\n @let rowSeverityValue = rowSeverity(rowData);\n <tr\n [attr.aria-selected]=\"selectable() ? isRowSelected(rowData) : null\"\n [class.shk-row-selected]=\"selectable() && isRowSelected(rowData)\"\n [class.shk-row-low]=\"rowSeverityValue === 'low'\"\n [class.shk-row-moderate]=\"rowSeverityValue === 'moderate'\"\n [class.shk-row-critical]=\"rowSeverityValue === 'critical'\"\n [class.cursor-pointer]=\"selectable() && selectOnRowClick() && canSelectRow(rowData)\"\n (click)=\"onRowClick($event, rowData)\"\n class=\"shk-data-row transition-colors duration-200 border-b _shk-border\"\n >\n @if (selectable()) {\n <td data-shk-select class=\"w-10 px-2 min-[1440px]:px-3 py-2 min-[1440px]:py-2.5 text-center\">\n <input\n type=\"checkbox\"\n class=\"shk-table-checkbox\"\n [checked]=\"isRowSelected(rowData)\"\n [disabled]=\"!canSelectRow(rowData)\"\n (change)=\"toggleRowSelection(rowData)\"\n [attr.aria-label]=\"'table.selectRow' | transloco: { index: first() + $index + 1 }\"\n />\n </td>\n }\n @for (col of columnsWithActions(); track col.field) {\n <td\n [attr.data-shk-actions]=\"col.field === 'actions' ? '' : null\"\n [class]=\"\n 'px-2 min-[1440px]:px-3 py-2 min-[1440px]:py-2.5 text-xs font-medium _shk-text-surface-700 dark:[color:var(--shk-surface-700)] ' +\n (col.field === 'actions' ? 'whitespace-nowrap' : 'whitespace-normal break-words')\n \"\n [style.--shk-col-width]=\"col.field !== 'actions' ? getColumnWidth(col) : null\"\n >\n @if (col.field !== 'actions') {\n @switch (col.template) {\n @case ('tag') {\n <shk-tag\n [value]=\"getTagValue(col, rowData)\"\n [severity]=\"getTagSeverity(col, rowData)\"\n [rounded]=\"getTagRounded(col, rowData)\"\n [icon]=\"getTagIcon(col, rowData)\"\n [style]=\"getTagStyle(col, rowData)\"\n />\n }\n @case ('progress') {\n <div\n class=\"shk-progress\"\n role=\"progressbar\"\n aria-valuemin=\"0\"\n aria-valuemax=\"100\"\n [attr.aria-valuenow]=\"getProgress(col, rowData)\"\n [attr.aria-label]=\"col.header\"\n >\n <div [style.width.%]=\"getProgress(col, rowData)\"></div>\n </div>\n }\n @case ('boolean') {\n @if (resolveField(rowData, col.field)) {\n <svg\n [shkIcon]=\"icons.yes\"\n class=\"w-4 h-4 [color:var(--shk-success-600)]\"\n role=\"img\"\n [attr.aria-label]=\"filterLabel('yes')\"\n ></svg>\n } @else {\n <svg\n [shkIcon]=\"icons.no\"\n class=\"w-4 h-4 [color:var(--shk-error-500)]\"\n role=\"img\"\n [attr.aria-label]=\"filterLabel('no')\"\n ></svg>\n }\n }\n @case ('date') {\n {{ formatDateCell(resolveField(rowData, col.field), col) }}\n }\n @case ('currency') {\n {{ formatCurrencyCell(resolveField(rowData, col.field), col) }}\n }\n @default {\n @if (col.image) {\n <div class=\"flex items-center gap-2\">\n @if (col.image(rowData); as src) {\n <img\n [src]=\"src\"\n alt=\"\"\n [width]=\"col.imageWidth || 24\"\n class=\"shrink-0 rounded-sm\"\n />\n }\n <span>\n <ng-container\n *ngTemplateOutlet=\"cellText; context: { $implicit: rowData, col: col }\"\n ></ng-container>\n </span>\n </div>\n } @else {\n <ng-container\n *ngTemplateOutlet=\"cellText; context: { $implicit: rowData, col: col }\"\n ></ng-container>\n }\n }\n }\n } @else {\n <div class=\"flex items-center justify-start gap-px\">\n @for (action of getVisibleRowActions(rowData); track $index) {\n @if (isRowActionVisible(action, rowData)) {\n <div class=\"relative group\">\n <shk-tooltip\n [text]=\"getRowActionLabel(action, rowData)\"\n position=\"top\"\n >\n <button\n type=\"button\"\n (click)=\"action.onClick(rowData)\"\n [class]=\"\n 'table-action-btn hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] rounded-md ' +\n getRowActionClass(action, rowData)\n \"\n [disabled]=\"isRowActionDisabled(action, rowData) || false\"\n [attr.aria-label]=\"getRowActionLabel(action, rowData)\"\n >\n <svg\n [shkIcon]=\"getIcon(getRowActionIconName(action, rowData))\"\n class=\"w-4 h-4\"\n ></svg>\n </button>\n </shk-tooltip>\n </div>\n }\n }\n @if (getHiddenRowActions(rowData).length > 0) {\n <div class=\"relative\">\n <shk-tooltip\n [text]=\"'common.more_options' | transloco\"\n position=\"top\"\n >\n <button\n type=\"button\"\n (click)=\"$event.stopPropagation(); toggleActionsDropdown(rowData, $event)\"\n class=\"table-action-btn hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] rounded-md\"\n [attr.aria-label]=\"'common.more_options' | transloco\"\n [attr.aria-expanded]=\"isActionsDropdownOpen(rowData)\"\n >\n <svg\n [shkIcon]=\"getIcon('ellipsis-vertical')\"\n class=\"w-4 h-4\"\n ></svg>\n </button>\n </shk-tooltip>\n @if (isActionsDropdownOpen(rowData)) {\n <div\n shkPortal\n class=\"fixed z-[9999] min-w-[160px] bg-white dark:[background-color:var(--shk-surface-100)] border _shk-border rounded-md shadow-lg py-1\"\n [style.top]=\"dropdownPosition().top + 'px'\"\n [style.left]=\"dropdownPosition().left + 'px'\"\n >\n @for (action of getHiddenRowActions(rowData); track $index) {\n <button\n type=\"button\"\n (click)=\"action.onClick(rowData); toggleActionsDropdown(rowData)\"\n [disabled]=\"isRowActionDisabled(action, rowData) || false\"\n [class]=\"\n 'w-full flex items-center gap-2 px-3 py-2 text-xs text-left _shk-text-surface-700 dark:[color:var(--shk-surface-700)] hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] disabled:opacity-40 disabled:cursor-not-allowed transition-colors ' +\n getRowActionClass(action, rowData)\n \"\n >\n <svg\n [shkIcon]=\"getIcon(getRowActionIconName(action, rowData))\"\n class=\"w-3.5 h-3.5 shrink-0\"\n ></svg>\n <span>{{ getRowActionLabel(action, rowData) }}</span>\n </button>\n }\n </div>\n }\n </div>\n }\n @if (rowSeverityValue) {\n <div class=\"relative group\">\n <shk-tooltip [text]=\"rowValidationTitle(rowData) || ''\" position=\"top\">\n <span\n class=\"shk-row-validation-btn\"\n [class.shk-sev-low]=\"rowSeverityValue === 'low'\"\n [class.shk-sev-moderate]=\"rowSeverityValue === 'moderate'\"\n [class.shk-sev-critical]=\"rowSeverityValue === 'critical'\"\n tabindex=\"0\"\n role=\"note\"\n [attr.aria-label]=\"rowValidationLabel(rowData)\"\n >\n <svg [shkIcon]=\"rowValidationIcon(rowData)\"></svg>\n </span>\n </shk-tooltip>\n </div>\n }\n </div>\n }\n </td>\n }\n </tr>\n }\n </tbody>\n }\n </table>\n\n <!-- Text content of a cell: format() \u00B7 custom template \u00B7 raw value -->\n <ng-template #cellText let-rowData let-col=\"col\">\n @if (col.format) {\n <span>{{ col.format(rowData) }}</span>\n } @else {\n <ng-container\n *ngTemplateOutlet=\"\n customTemplates()[col.field] || defaultTemplate;\n context: { $implicit: rowData, field: col.field }\n \"\n ></ng-container>\n }\n </ng-template>\n <ng-template #defaultTemplate let-rowData let-field=\"field\">\n {{ resolveField(rowData, field) }}\n </ng-template>\n\n <!-- Option list of the select / multiselect filters -->\n <ng-template #optionList let-col let-draft=\"draft\" let-multiple=\"multiple\">\n <div class=\"p-2 space-y-1.5\">\n @let selectedLabel = multiple ? selectedOptionsLabel(col) : selectedSingleLabel(col);\n <button\n type=\"button\"\n class=\"shk-filter-select flex items-center justify-between gap-2 text-left\"\n style=\"background-image: none\"\n [id]=\"uid + '-filter-' + safeId(col.field) + '-0'\"\n [attr.aria-expanded]=\"multiselectOpen()\"\n (click)=\"multiselectOpen.set(!multiselectOpen())\"\n >\n <span class=\"truncate\" [class._shk-text-surface-400]=\"!selectedLabel\">\n {{ selectedLabel || tr('table.filterAll', 'Todos') }}\n </span>\n <svg\n [shkIcon]=\"getIcon('chevron-down')\"\n class=\"w-3.5 h-3.5 shrink-0 _shk-text-surface-400 transition-transform\"\n [class.rotate-180]=\"multiselectOpen()\"\n ></svg>\n </button>\n @if (multiselectOpen()) {\n <div\n class=\"max-h-52 overflow-y-auto p-0.5 border _shk-border rounded-md _shk-scrollbar\"\n role=\"listbox\"\n [attr.aria-multiselectable]=\"multiple\"\n >\n @for (opt of col.filterOptions || []; track $index) {\n @let isSelected = multiple\n ? isOptionSelected(opt.value)\n : draft.rules[0].value != null && draft.rules[0].value == opt.value;\n <button\n type=\"button\"\n role=\"option\"\n class=\"w-full flex items-center gap-2 px-2 py-1.5 rounded text-left transition-colors hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)]\"\n [class._shk-bg-primary-soft]=\"isSelected\"\n [class._shk-text-primary-700]=\"isSelected\"\n [attr.aria-selected]=\"isSelected\"\n (click)=\"multiple ? toggleOption(col, opt.value) : selectOption(col, opt.value)\"\n >\n @if (multiple) {\n <span class=\"shk-checkbox-box\" [class.shk-checked]=\"isSelected\">\n @if (isSelected) {\n <svg [shkIcon]=\"getIcon('check')\"></svg>\n }\n </span>\n }\n @if (opt.image) {\n <img [src]=\"opt.image\" alt=\"\" width=\"22\" class=\"shrink-0 rounded-sm\" />\n }\n <span class=\"truncate\">{{ opt.label }}</span>\n </button>\n }\n </div>\n }\n </div>\n </ng-template>\n </div>\n <div\n class=\"table-pagination flex items-center justify-between gap-4 px-2 min-[1440px]:px-3 py-2 border-t _shk-border\"\n >\n <div class=\"text-xs _shk-text-surface-600\">\n @if (showPageReport()) {\n {{ pageReport() }}\n }\n </div>\n <div\n class=\"flex items-center gap-0.5\"\n role=\"navigation\"\n >\n <button\n type=\"button\"\n (click)=\"goToFirst()\"\n [disabled]=\"isFirstPage()\"\n [attr.aria-label]=\"tr('table.firstPage', 'Primera p\u00E1gina')\"\n class=\"shk-page-btn p-1 _shk-text-surface-500 hover:[color:var(--shk-surface-700)] dark:hover:[color:var(--shk-surface-200)] disabled:opacity-30 disabled:cursor-not-allowed rounded transition-colors\"\n >\n <svg [shkIcon]=\"getIcon('chevrons-left')\" class=\"w-4 h-4\"></svg>\n </button>\n <button\n type=\"button\"\n (click)=\"prev()\"\n [disabled]=\"isFirstPage()\"\n [attr.aria-label]=\"tr('table.prevPage', 'P\u00E1gina anterior')\"\n class=\"shk-page-btn p-1 _shk-text-surface-500 hover:[color:var(--shk-surface-700)] dark:hover:[color:var(--shk-surface-200)] disabled:opacity-30 disabled:cursor-not-allowed rounded transition-colors\"\n >\n <svg [shkIcon]=\"getIcon('chevron-left')\" class=\"w-4 h-4\"></svg>\n </button>\n <span\n class=\"px-2 text-xs font-medium _shk-text-surface-700\"\n >{{ currentPage() }} / {{ totalPages() }}</span\n >\n <button\n type=\"button\"\n (click)=\"next()\"\n [disabled]=\"isLastPage()\"\n [attr.aria-label]=\"tr('table.nextPage', 'P\u00E1gina siguiente')\"\n class=\"shk-page-btn p-1 _shk-text-surface-500 hover:[color:var(--shk-surface-700)] dark:hover:[color:var(--shk-surface-200)] disabled:opacity-30 disabled:cursor-not-allowed rounded transition-colors\"\n >\n <svg [shkIcon]=\"getIcon('chevron-right')\" class=\"w-4 h-4\"></svg>\n </button>\n <button\n type=\"button\"\n (click)=\"goToLast()\"\n [disabled]=\"isLastPage()\"\n [attr.aria-label]=\"tr('table.lastPage', '\u00DAltima p\u00E1gina')\"\n class=\"shk-page-btn p-1 _shk-text-surface-500 hover:[color:var(--shk-surface-700)] dark:hover:[color:var(--shk-surface-200)] disabled:opacity-30 disabled:cursor-not-allowed rounded transition-colors\"\n >\n <svg [shkIcon]=\"getIcon('chevrons-right')\" class=\"w-4 h-4\"></svg>\n </button>\n </div>\n <div\n class=\"flex items-center gap-1.5 text-xs _shk-text-surface-600\"\n >\n @if (showRowsPerPage()) {\n <label [for]=\"uid + '-rows-per-page'\">{{ 'table.rows' | transloco }}</label>\n <select\n [id]=\"uid + '-rows-per-page'\"\n (change)=\"onRowsPerPageChange($any($event.target).value)\"\n class=\"border _shk-border rounded px-2 py-1 text-xs bg-white dark:[background-color:var(--shk-surface-100)] _shk-text-surface-700 focus:outline-none focus:[border-color:var(--shk-primary-500)]\"\n >\n @for (opt of rowsPerPageOptions(); track opt) {\n <option [value]=\"opt\" [selected]=\"opt === rowsPerPageLocal()\">{{ opt }}</option>\n }\n </select>\n }\n </div>\n </div>\n </div>\n</div>\n", styles: ["input:focus{outline:none}input[type=text]{font-weight:400!important}table th{white-space:nowrap}table td{white-space:normal;overflow-wrap:break-word}.shk-page-btn{display:inline-flex;align-items:center;justify-content:center;width:1.75rem;height:1.75rem;border-radius:.375rem;transition:background-color .15s ease,color .15s ease}.shk-page-btn:hover:not(:disabled){background-color:var(--shk-surface-100)}:host-context(.dark) .shk-page-btn:hover:not(:disabled){background-color:var(--shk-surface-200)}.shk-page-btn:focus-visible{outline:none;box-shadow:0 0 0 2px color-mix(in srgb,var(--shk-primary-500) 45%,transparent)}td button svg{width:1.125rem!important;height:1.125rem!important}td button:disabled{opacity:.4;cursor:not-allowed}.table-action-btn svg{width:1rem!important;height:1rem!important;min-width:1rem!important;min-height:1rem!important}.table-action-btn{padding:.5rem!important;min-width:2rem!important;min-height:2rem!important;display:inline-flex!important;align-items:center!important;justify-content:center!important}.table-scroll-wrapper{width:100%;overflow-x:auto;overflow-y:hidden;border-radius:inherit;-webkit-overflow-scrolling:touch;container-type:inline-size}.table-card,.table-pagination{container-type:inline-size}@container (max-width: 640px){.table-pagination{flex-direction:column;align-items:center;gap:.5rem}.table-pagination>div{justify-content:center}}.table-scroll-wrapper table{table-layout:auto;width:100%}@container (max-width: 768px){.table-scroll-wrapper{scroll-snap-type:x mandatory}.table-scroll-wrapper table{table-layout:auto;width:100%}.table-scroll-wrapper th:not([data-shk-actions]):not([data-shk-select]){min-width:var(--shk-col-width, 140px)}.table-scroll-wrapper td:not([data-shk-actions]):not([data-shk-select]){min-width:var(--shk-col-width, 140px);max-width:var(--shk-col-width, 140px)}.table-scroll-wrapper th,.table-scroll-wrapper td{scroll-snap-align:start}}th[data-shk-select],td[data-shk-select]{width:2.5rem;min-width:2.5rem}.shk-table-checkbox{width:.875rem;height:.875rem;cursor:pointer;vertical-align:middle;accent-color:var(--shk-primary-500)}.shk-table-checkbox:disabled{opacity:.4;cursor:not-allowed}tr.shk-row-selected{background-color:color-mix(in srgb,var(--shk-primary-50) 60%,transparent)}tr.shk-row-selected:hover{background-color:color-mix(in srgb,var(--shk-primary-50) 90%,transparent)}:host-context(.dark) tr.shk-row-selected{background-color:color-mix(in srgb,var(--shk-primary-900) 20%,transparent)}:host-context(.dark) tr.shk-row-selected:hover{background-color:color-mix(in srgb,var(--shk-primary-900) 30%,transparent)}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.shk-data-table tr.shk-row-low{background-color:color-mix(in srgb,var(--shk-info-600) 22%,transparent)}.shk-data-table tr.shk-row-moderate{background-color:color-mix(in srgb,var(--shk-warning-400) 32%,transparent)}.shk-data-table tr.shk-row-critical{background-color:color-mix(in srgb,var(--shk-error-500) 20%,transparent)}:host-context(.dark) .shk-data-table tr.shk-row-low{background-color:color-mix(in srgb,var(--shk-info-600) 26%,transparent)}:host-context(.dark) .shk-data-table tr.shk-row-moderate{background-color:color-mix(in srgb,var(--shk-warning-400) 34%,transparent)}:host-context(.dark) .shk-data-table tr.shk-row-critical{background-color:color-mix(in srgb,var(--shk-error-500) 24%,transparent)}.shk-row-validation-btn{display:inline-flex;align-items:center;justify-content:center;padding:.25rem;border-radius:.375rem;cursor:help;color:var(--shk-surface-500)}.shk-row-validation-btn svg{width:1rem!important;height:1rem!important}.shk-row-validation-btn.shk-sev-low{color:var(--shk-info-600)}.shk-row-validation-btn.shk-sev-moderate{color:var(--shk-warning-600)}:host-context(.dark) .shk-row-validation-btn.shk-sev-moderate{color:var(--shk-warning-400)}.shk-row-validation-btn.shk-sev-critical{color:var(--shk-error-500)}.shk-row-validation-btn:focus-visible{outline:2px solid currentColor;outline-offset:1px}table.shk-row-hover tbody tr.shk-data-row:hover{background-color:color-mix(in srgb,var(--shk-primary-50) 30%,transparent)}:host-context(.dark) table.shk-row-hover tbody tr.shk-data-row:hover{background-color:color-mix(in srgb,var(--shk-primary-900) 10%,transparent)}table.shk-gridlines th,table.shk-gridlines td{border-right:1px solid var(--shk-surface-200)}table.shk-gridlines th:last-child,table.shk-gridlines td:last-child{border-right:0}:host-context(.dark) table.shk-gridlines th,:host-context(.dark) table.shk-gridlines td{border-right-color:var(--shk-surface-200)}.shk-col-resizer{position:absolute;top:0;right:-4px;z-index:1;width:8px;height:100%;cursor:col-resize;touch-action:none}.shk-col-resizer:after{content:\"\";position:absolute;top:20%;bottom:20%;left:3px;width:2px;border-radius:1px;background-color:transparent;transition:background-color .15s ease}.shk-col-resizer:hover:after,.shk-col-resizer:focus-visible:after,.shk-col-resizer.shk-resizing:after{background-color:var(--shk-primary-500)}.shk-col-resizer:focus-visible{outline:none}th:last-child .shk-col-resizer{right:0}.shk-filter-input,.shk-filter-select{width:100%;padding:.375rem .625rem;font-size:.75rem;line-height:1.25rem;border-radius:.375rem;border:1px solid var(--shk-surface-200);background-color:#fff;color:var(--shk-surface-700)}.dark .shk-filter-input,.dark .shk-filter-select{background-color:var(--shk-surface-100);border-color:var(--shk-surface-200);color-scheme:dark}.shk-filter-input::placeholder{color:var(--shk-surface-400)}select.shk-filter-select{appearance:none;padding-right:1.75rem;background-image:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E\");background-repeat:no-repeat;background-position:right .5rem center;cursor:pointer}button.shk-filter-select{cursor:pointer}.shk-filter-input:focus,.shk-filter-select:focus{outline:none;border-color:var(--shk-primary-500);box-shadow:0 0 0 1px var(--shk-primary-500)}.shk-checkbox-box{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;width:.875rem;height:.875rem;border-radius:.1875rem;border:1px solid var(--shk-surface-300);background-color:#fff;color:#fff}.dark .shk-checkbox-box{background-color:var(--shk-surface-100)}.shk-checkbox-box.shk-checked{background-color:var(--shk-primary-500);border-color:var(--shk-primary-500)}.shk-checkbox-box svg{width:.625rem;height:.625rem}.shk-range{position:relative;height:1rem;margin:.5rem .375rem .375rem}.shk-range-track,.shk-range-fill{position:absolute;top:50%;height:.1875rem;transform:translateY(-50%);border-radius:9999px}.shk-range-track{left:0;right:0;background-color:var(--shk-surface-200)}.shk-range-fill{background-color:var(--shk-primary-500)}.shk-range input[type=range]{position:absolute;inset:0;width:100%;margin:0;background:transparent;pointer-events:none;appearance:none;-webkit-appearance:none}.shk-range input[type=range]::-webkit-slider-thumb{pointer-events:auto;-webkit-appearance:none;width:.875rem;height:.875rem;border-radius:9999px;background:#fff;border:2px solid var(--shk-primary-500);cursor:grab}.shk-range input[type=range]::-moz-range-thumb{pointer-events:auto;width:.625rem;height:.625rem;border-radius:9999px;background:#fff;border:2px solid var(--shk-primary-500);cursor:grab}.shk-progress{height:.375rem;min-width:5rem;border-radius:9999px;background-color:var(--shk-surface-200);overflow:hidden}.shk-progress>div{height:100%;border-radius:inherit;background-color:var(--shk-primary-500)}\n"], dependencies: [{ kind: "directive", type: PortalDirective, selector: "[shkPortal]" }, { kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "ngmodule", type: TranslocoModule }, { kind: "directive", type: ShkIconDirective, selector: "svg[shkIcon]", inputs: ["shkIcon", "size", "strokeWidth", "color"] }, { kind: "component", type: TagComponent, selector: "shk-tag", inputs: ["value", "severity", "rounded", "icon", "style", "styleClass"] }, { kind: "component", type: TooltipComponent, selector: "shk-tooltip", inputs: ["text", "position", "mode", "offset"] }, { kind: "pipe", type: i2.TranslocoPipe, name: "transloco" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
1682
- }
1683
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.27", ngImport: i0, type: TableComponent, decorators: [{
1684
- type: Component,
1685
- args: [{ selector: 'shk-table', changeDetection: ChangeDetectionStrategy.OnPush, imports: [
1686
- PortalDirective,
1687
- CommonModule,
1688
- TranslocoModule,
1689
- ShkIconDirective,
1690
- TagComponent,
1691
- TooltipComponent,
1692
- ], template: "<div class=\"space-y-2 min-[1440px]:space-y-3 mt-2 min-[1440px]:mt-3 animate-fade-in pb-8\">\n @if (\n showSearch() ||\n (showClearButton() && hasFilterableColumns()) ||\n filters().length > 0 ||\n headerActions().length > 0 ||\n (selectable() && bulkActions().length > 0 && selection().length > 0)\n ) {\n <div class=\"card p-2 min-[1440px]:p-2.5 flex flex-row items-center justify-between gap-2\">\n <div class=\"flex items-center gap-2 min-[1440px]:gap-3 flex-1 min-w-0\">\n @if (showSearch()) {\n <div class=\"relative w-full md:w-52 min-[1440px]:w-56\">\n <label [for]=\"uid + '-search'\" class=\"sr-only\">{{\n searchPlaceholder() || ('common.search_placeholder' | transloco)\n }}</label>\n <div class=\"absolute inset-y-0 left-0 pl-2.5 flex items-center pointer-events-none\">\n <svg\n [shkIcon]=\"getIcon('search')\"\n class=\"w-3.5 h-3.5 _shk-text-surface-400\"\n ></svg>\n </div>\n <input\n [id]=\"uid + '-search'\"\n type=\"text\"\n [value]=\"searchQuery()\"\n (input)=\"onSearchInput($any($event.target).value)\"\n [placeholder]=\"searchPlaceholder() || ('common.search_placeholder' | transloco)\"\n class=\"block w-full pl-8 pr-3 py-1.5 text-xs border _shk-border rounded-md leading-5 _shk-bg-surface-50 placeholder:[color:var(--shk-surface-400)] dark:placeholder:[color:var(--shk-surface-500)] _shk-text-surface-700 focus:outline-none focus:bg-white dark:focus:[background-color:var(--shk-surface-100)] focus:[border-color:var(--shk-primary-500)] focus:ring-1 focus:[--tw-ring-color:var(--shk-primary-500)]\"\n />\n </div>\n }\n @if (showClearButton() && (hasFilterableColumns() || showSearch())) {\n <shk-tooltip [text]=\"tr('table.clearFilters', 'Limpiar b\u00FAsqueda, filtros y orden')\">\n <button\n type=\"button\"\n (click)=\"clearAll()\"\n [disabled]=\"!hasActiveFilters()\"\n class=\"inline-flex items-center gap-1.5 px-2.5 py-1.5 text-xs font-medium rounded-md border _shk-border _shk-text-surface-600 hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] transition-colors disabled:opacity-40 disabled:cursor-not-allowed whitespace-nowrap\"\n >\n <svg [shkIcon]=\"icons.clear\" class=\"w-3.5 h-3.5\"></svg>\n {{ tr('table.clear', 'Limpiar') }}\n </button>\n </shk-tooltip>\n }\n @if (filters().length > 0) {\n <div\n class=\"flex _shk-bg-surface-100 p-0.5 rounded-md ml-auto\"\n role=\"group\"\n >\n @for (f of filters(); track f.value) {\n <button\n type=\"button\"\n (click)=\"onFilterClick(f.value)\"\n [attr.aria-pressed]=\"f.value === activeFilter()\"\n class=\"px-2.5 min-[1440px]:px-3 py-1 text-xs font-medium rounded _shk-text-surface-700 transition-all\"\n [class]=\"\n f.value === activeFilter()\n ? 'bg-white shadow-sm dark:[background-color:var(--shk-surface-700)]'\n : ''\n \"\n >\n {{ f.label }}\n </button>\n }\n </div>\n }\n </div>\n @if (selectable() && selection().length > 0 && bulkActions().length > 0) {\n <div\n class=\"flex items-center gap-1.5 shrink-0\"\n role=\"toolbar\"\n [attr.aria-label]=\"'table.selected' | transloco: { count: selection().length }\"\n >\n <span\n class=\"text-xs font-medium _shk-text-surface-600 whitespace-nowrap\"\n aria-live=\"polite\"\n >{{ 'table.selected' | transloco: { count: selection().length } }}</span\n >\n <button\n type=\"button\"\n (click)=\"clearSelection()\"\n [attr.aria-label]=\"'table.clearSelection' | transloco\"\n class=\"table-action-btn rounded-md _shk-text-surface-500 hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)]\"\n >\n <svg [shkIcon]=\"getIcon('x')\" class=\"w-3.5 h-3.5\"></svg>\n </button>\n @for (action of visibleBulkActions(); track $index) {\n <button\n type=\"button\"\n [class]=\"\n 'inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-md _shk-bg-primary text-white hover:[background-color:var(--shk-primary-700)] transition-colors disabled:opacity-50 disabled:cursor-not-allowed ' +\n (action.class || '')\n \"\n [disabled]=\"isBulkActionDisabled(action)\"\n [attr.aria-label]=\"action.label\"\n (click)=\"runBulkAction(action)\"\n >\n @if (action.icon) {\n <svg [shkIcon]=\"getIcon(action.icon)\" class=\"w-3.5 h-3.5\"></svg>\n }\n {{ action.label }}\n </button>\n }\n </div>\n }\n @if (headerActions().length > 0) {\n <div class=\"flex items-center gap-1.5 shrink-0\">\n @for (action of headerActions(); track $index) {\n @if (isHeaderActionVisible(action)) {\n <button\n type=\"button\"\n [class]=\"\n 'inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-md _shk-bg-primary text-white hover:[background-color:var(--shk-primary-700)] transition-colors disabled:opacity-50 disabled:cursor-not-allowed ' +\n (action.class || '')\n \"\n [disabled]=\"isHeaderActionDisabled(action)\"\n [attr.aria-label]=\"action.label\"\n (click)=\"action.onClick()\"\n >\n @if (action.icon) {\n <svg [shkIcon]=\"getIcon(action.icon)\" class=\"w-3.5 h-3.5\"></svg>\n }\n {{ action.label }}\n </button>\n }\n }\n </div>\n }\n </div>\n }\n <div class=\"card p-0 overflow-hidden table-card\" [class.shadow-lg]=\"hasShadow()\">\n <div class=\"table-scroll-wrapper _shk-scrollbar\">\n <table\n class=\"shk-data-table\"\n [class.shk-gridlines]=\"showGridlines()\"\n [class.shk-row-hover]=\"rowHover()\"\n >\n <thead>\n <tr>\n @if (selectable()) {\n <th\n scope=\"col\"\n data-shk-select\n class=\"w-10 px-2 min-[1440px]:px-3 py-2 min-[1440px]:py-2.5 text-center _shk-bg-surface-50 border-b _shk-border\"\n >\n <input\n type=\"checkbox\"\n class=\"shk-table-checkbox\"\n [checked]=\"allPageSelected()\"\n [indeterminate]=\"somePageSelected()\"\n [disabled]=\"loading() || selectablePageRows().length === 0\"\n (change)=\"toggleSelectAllPage()\"\n [attr.aria-label]=\"'table.selectAll' | transloco\"\n />\n </th>\n }\n @for (col of columnsWithActions(); track col.field) {\n <th\n scope=\"col\"\n (click)=\"onHeaderClick(col)\"\n (keydown)=\"onHeaderKeydown($event, col)\"\n [tabindex]=\"col.field !== 'actions' && col.sortable ? 0 : -1\"\n [attr.role]=\"col.field !== 'actions' && col.sortable ? 'button' : null\"\n [attr.aria-sort]=\"getAriaSort(col)\"\n [attr.data-shk-actions]=\"col.field === 'actions' ? '' : null\"\n [style.cursor]=\"col.field !== 'actions' && col.sortable ? 'pointer' : 'default'\"\n [style.width]=\"resizedWidth(col) || (col.field === 'actions' ? col.width : null)\"\n [style.min-width]=\"resizedWidth(col) || (col.field === 'actions' ? col.width : col.minWidth) || null\"\n [style.--shk-col-width]=\"col.field !== 'actions' ? getColumnWidth(col) : null\"\n class=\"relative px-2 min-[1440px]:px-3 py-2 min-[1440px]:py-2.5 text-left text-[10px] min-[1440px]:text-xs font-bold _shk-text-surface-500 uppercase tracking-wider _shk-bg-surface-50 border-b _shk-border focus:outline-none focus-visible:ring-1 focus-visible:[--tw-ring-color:var(--shk-primary-500)]\"\n >\n @if (col.field !== 'actions') {\n <div class=\"flex items-center justify-between gap-2\">\n <span>{{ col.header }}</span>\n <div class=\"flex items-center gap-1 shrink-0\">\n @if (col.sortable) {\n <shk-tooltip [text]=\"'table.tooltips.sort' | transloco\">\n @if (sortField() === col.field) {\n <svg\n [shkIcon]=\"getIcon(sortOrder() === 1 ? 'arrow-up' : 'arrow-down')\"\n class=\"w-3.5 h-3.5 _shk-text-primary\"\n ></svg>\n } @else {\n <svg\n [shkIcon]=\"getIcon('arrow-up-down')\"\n class=\"w-3.5 h-3.5 _shk-text-surface-400\"\n ></svg>\n }\n </shk-tooltip>\n }\n @if (col.filter) {\n <shk-tooltip [text]=\"'table.tooltips.filter' | transloco\">\n <button\n type=\"button\"\n (click)=\"$event.stopPropagation(); toggleFilter(col, $event)\"\n [attr.aria-label]=\"('table.tooltips.filter' | transloco) + ': ' + col.header\"\n [attr.aria-expanded]=\"openFilterField() === col.field\"\n aria-haspopup=\"dialog\"\n class=\"_shk-text-surface-400 hover:[color:var(--shk-surface-600)] dark:hover:[color:var(--shk-surface-300)] transition-colors\"\n >\n <svg\n [shkIcon]=\"getIcon('filter')\"\n class=\"w-3.5 h-3.5\"\n [class._shk-text-primary]=\"hasFilterValue(col.field) || openFilterField() === col.field\"\n ></svg>\n </button>\n </shk-tooltip>\n }\n </div>\n </div>\n\n\n <!-- Column filter menu -->\n @if (col.filter && openFilterField() === col.field && filterDraft(); as draft) {\n <div\n shkPortal\n class=\"shk-filter-overlay fixed z-[9999] w-[240px] overflow-y-auto normal-case tracking-normal font-normal text-xs _shk-text-surface-700 bg-white dark:[background-color:var(--shk-surface-100)] border _shk-border rounded-lg shadow-lg\"\n role=\"dialog\"\n [attr.aria-label]=\"('table.tooltips.filter' | transloco) + ': ' + col.header\"\n [style.top.px]=\"filterPopupPosition().top\"\n [style.left.px]=\"filterPopupPosition().left\"\n [style.max-height.px]=\"filterPopupPosition().maxHeight\"\n (click)=\"$event.stopPropagation()\"\n (keydown)=\"$event.stopPropagation()\"\n (keydown.escape)=\"closeFilters()\"\n >\n @if (col.filterMenuTitle) {\n <div class=\"px-2 pt-2 font-semibold _shk-text-surface-800\">\n {{ col.filterMenuTitle }}\n </div>\n }\n @if (showOperatorFor(col)) {\n <div class=\"p-2 border-b _shk-border\">\n <select\n class=\"shk-filter-select\"\n [attr.aria-label]=\"filterLabel('matchAll') + ' / ' + filterLabel('matchAny')\"\n (change)=\"setDraftOperator($any($event.target).value)\"\n >\n <option value=\"and\" [selected]=\"draft.operator === 'and'\">\n {{ filterLabel('matchAll') }}\n </option>\n <option value=\"or\" [selected]=\"draft.operator === 'or'\">\n {{ filterLabel('matchAny') }}\n </option>\n </select>\n </div>\n }\n\n @switch (filterKind(col)) {\n @case ('select') {\n <ng-container\n *ngTemplateOutlet=\"optionList; context: { $implicit: col, draft: draft, multiple: false }\"\n ></ng-container>\n }\n @case ('multiselect') {\n <ng-container\n *ngTemplateOutlet=\"optionList; context: { $implicit: col, draft: draft, multiple: true }\"\n ></ng-container>\n }\n @case ('boolean') {\n @let boolValue = draft.rules[0].value;\n <div class=\"p-2\">\n <button\n type=\"button\"\n role=\"checkbox\"\n [id]=\"uid + '-filter-' + safeId(col.field) + '-0'\"\n class=\"inline-flex items-center gap-2 rounded-md focus:outline-none focus-visible:ring-1 focus-visible:[--tw-ring-color:var(--shk-primary-500)]\"\n [attr.aria-checked]=\"\n boolValue === true ? 'true' : boolValue === false ? 'false' : 'mixed'\n \"\n (click)=\"cycleBoolean(col)\"\n >\n <span\n class=\"shk-checkbox-box\"\n [class.shk-checked]=\"boolValue === true || boolValue === false\"\n >\n @if (boolValue === true) {\n <svg [shkIcon]=\"getIcon('check')\"></svg>\n } @else if (boolValue === false) {\n <svg [shkIcon]=\"getIcon('x')\"></svg>\n }\n </span>\n <span>{{\n boolValue === true\n ? filterLabel('yes')\n : boolValue === false\n ? filterLabel('no')\n : filterLabel('any')\n }}</span>\n </button>\n </div>\n }\n @case ('range') {\n @let rv = rangeValue(col);\n @let bounds = rangeBounds(col);\n <div class=\"p-2\">\n <div class=\"shk-range\">\n <div class=\"shk-range-track\"></div>\n <div\n class=\"shk-range-fill\"\n [style.left.%]=\"rangePercent(col, rv[0])\"\n [style.width.%]=\"rangePercent(col, rv[1]) - rangePercent(col, rv[0])\"\n ></div>\n <input\n type=\"range\"\n [id]=\"uid + '-filter-' + safeId(col.field) + '-0'\"\n [min]=\"bounds[0]\"\n [max]=\"bounds[1]\"\n [step]=\"col.filterStep || 1\"\n [value]=\"rv[0]\"\n [style.z-index]=\"rv[0] >= bounds[1] ? 3 : null\"\n [attr.aria-label]=\"col.header + ' min'\"\n (input)=\"onRangeInput(col, 0, $any($event.target).value, false)\"\n (change)=\"onRangeInput(col, 0, $any($event.target).value, true)\"\n />\n <input\n type=\"range\"\n [min]=\"bounds[0]\"\n [max]=\"bounds[1]\"\n [step]=\"col.filterStep || 1\"\n [value]=\"rv[1]\"\n [attr.aria-label]=\"col.header + ' max'\"\n (input)=\"onRangeInput(col, 1, $any($event.target).value, false)\"\n (change)=\"onRangeInput(col, 1, $any($event.target).value, true)\"\n />\n </div>\n <div class=\"flex items-center justify-between px-0.5 _shk-text-surface-500\">\n <span>{{ rv[0] }}</span>\n <span>{{ rv[1] }}</span>\n </div>\n </div>\n }\n @default {\n <!-- text / numeric / date: one block per rule -->\n @for (rule of draft.rules; track $index; let i = $index) {\n <div\n class=\"flex flex-col gap-1.5 p-2\"\n [class.border-b]=\"i < draft.rules.length - 1\"\n [class._shk-border]=\"i < draft.rules.length - 1\"\n >\n @if (showMatchModesFor(col)) {\n <select\n class=\"shk-filter-select\"\n [attr.aria-label]=\"col.header\"\n (change)=\"setDraftMatchMode(col, i, $any($event.target).value)\"\n >\n @for (mode of matchModesFor(col); track mode) {\n <option [value]=\"mode\" [selected]=\"mode === rule.matchMode\">\n {{ matchModeLabel(mode) }}\n </option>\n }\n </select>\n }\n <input\n [id]=\"uid + '-filter-' + safeId(col.field) + '-' + i\"\n [type]=\"filterKind(col) === 'numeric' ? 'number' : filterKind(col) === 'date' ? 'date' : 'text'\"\n [attr.step]=\"filterKind(col) === 'numeric' ? 'any' : null\"\n class=\"shk-filter-input\"\n [value]=\"rule.value ?? ''\"\n [placeholder]=\"col.filterPlaceholder || ('common.search_placeholder' | transloco)\"\n [attr.aria-label]=\"col.header\"\n (input)=\"onRuleInput(col, i, $any($event.target).value)\"\n (keydown.enter)=\"applyFilter(col)\"\n />\n @if (draft.rules.length > 1) {\n <button\n type=\"button\"\n class=\"inline-flex items-center justify-center gap-1 py-1 rounded-md [color:var(--shk-error-600)] hover:[background-color:var(--shk-error-50)] transition-colors\"\n (click)=\"removeRule(i)\"\n >\n <svg [shkIcon]=\"icons.trash\" class=\"w-3.5 h-3.5\"></svg>\n {{ filterLabel('removeRule') }}\n </button>\n }\n </div>\n }\n @if (canAddRule(col)) {\n <div class=\"px-2 pb-1\">\n <button\n type=\"button\"\n class=\"w-full inline-flex items-center justify-center gap-1 py-1 rounded-md _shk-text-primary hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] transition-colors\"\n (click)=\"addRule(col)\"\n >\n <svg [shkIcon]=\"getIcon('plus')\" class=\"w-3.5 h-3.5\"></svg>\n {{ filterLabel('addRule') }}\n </button>\n </div>\n }\n }\n }\n\n <div class=\"flex items-center justify-between gap-2 p-2 border-t _shk-border\">\n <button\n type=\"button\"\n class=\"px-3 py-1.5 font-medium rounded-md border _shk-border _shk-text-surface-600 hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] transition-colors\"\n (click)=\"clearFilter(col.field)\"\n >\n {{ filterLabel('clear') }}\n </button>\n <button\n type=\"button\"\n class=\"px-3 py-1.5 font-medium rounded-md _shk-bg-primary text-white hover:[background-color:var(--shk-primary-700)] transition-colors\"\n (click)=\"applyFilter(col)\"\n >\n {{ filterLabel('apply') }}\n </button>\n </div>\n </div>\n }\n } @else {\n <div class=\"flex items-center justify-center\">\n <span>{{ col.header }}</span>\n </div>\n }\n @if (isResizable()) {\n <span\n class=\"shk-col-resizer\"\n [class.shk-resizing]=\"resizingField() === col.field\"\n role=\"separator\"\n aria-orientation=\"vertical\"\n tabindex=\"0\"\n [attr.aria-label]=\"tr('table.resizeColumn', 'Redimensionar columna') + ': ' + col.header\"\n [attr.aria-valuenow]=\"resizedWidthPx(col)\"\n (pointerdown)=\"startResize($event, col)\"\n (click)=\"$event.stopPropagation()\"\n (dblclick)=\"$event.stopPropagation(); resetColumnWidth(col)\"\n (keydown)=\"onResizerKeydown($event, col)\"\n ></span>\n }\n </th>\n }\n </tr>\n </thead>\n @if (loading()) {\n <tbody class=\"border-b _shk-border\">\n <tr>\n <td [attr.colspan]=\"totalColspan()\" class=\"text-center py-12\">\n <div\n class=\"flex items-center justify-center\"\n role=\"status\"\n [attr.aria-label]=\"'common.loading' | transloco\"\n >\n <svg\n [shkIcon]=\"getIcon('loader')\"\n class=\"w-6 h-6 animate-spin _shk-text-primary\"\n ></svg>\n </div>\n </td>\n </tr>\n </tbody>\n } @else if (effectiveDisplayedData().length === 0) {\n <tbody class=\"border-b _shk-border\">\n <tr>\n <td [attr.colspan]=\"totalColspan()\" class=\"text-center py-12\">\n <div class=\"flex flex-col items-center\">\n <div\n class=\"w-16 h-16 _shk-bg-surface-100 rounded-full flex items-center justify-center mb-4\"\n >\n <svg\n [shkIcon]=\"getIcon('inbox')\"\n class=\"w-8 h-8 _shk-text-surface-400\"\n ></svg>\n </div>\n <p\n class=\"text-lg font-semibold _shk-text-surface-600\"\n >\n {{ emptyMessage() || ('common.no_records' | transloco) }}\n </p>\n </div>\n </td>\n </tr>\n </tbody>\n } @else {\n <tbody>\n @for (rowData of effectiveDisplayedData(); track trackByRow(rowData, $index)) {\n @let rowSeverityValue = rowSeverity(rowData);\n <tr\n [attr.aria-selected]=\"selectable() ? isRowSelected(rowData) : null\"\n [class.shk-row-selected]=\"selectable() && isRowSelected(rowData)\"\n [class.shk-row-low]=\"rowSeverityValue === 'low'\"\n [class.shk-row-moderate]=\"rowSeverityValue === 'moderate'\"\n [class.shk-row-critical]=\"rowSeverityValue === 'critical'\"\n [class.cursor-pointer]=\"selectable() && selectOnRowClick() && canSelectRow(rowData)\"\n (click)=\"onRowClick($event, rowData)\"\n class=\"shk-data-row transition-colors duration-200 border-b _shk-border\"\n >\n @if (selectable()) {\n <td data-shk-select class=\"w-10 px-2 min-[1440px]:px-3 py-2 min-[1440px]:py-2.5 text-center\">\n <input\n type=\"checkbox\"\n class=\"shk-table-checkbox\"\n [checked]=\"isRowSelected(rowData)\"\n [disabled]=\"!canSelectRow(rowData)\"\n (change)=\"toggleRowSelection(rowData)\"\n [attr.aria-label]=\"'table.selectRow' | transloco: { index: first() + $index + 1 }\"\n />\n </td>\n }\n @for (col of columnsWithActions(); track col.field) {\n <td\n [attr.data-shk-actions]=\"col.field === 'actions' ? '' : null\"\n [class]=\"\n 'px-2 min-[1440px]:px-3 py-2 min-[1440px]:py-2.5 text-xs font-medium _shk-text-surface-700 dark:[color:var(--shk-surface-700)] ' +\n (col.field === 'actions' ? 'whitespace-nowrap' : 'whitespace-normal break-words')\n \"\n [style.--shk-col-width]=\"col.field !== 'actions' ? getColumnWidth(col) : null\"\n >\n @if (col.field !== 'actions') {\n @switch (col.template) {\n @case ('tag') {\n <shk-tag\n [value]=\"getTagValue(col, rowData)\"\n [severity]=\"getTagSeverity(col, rowData)\"\n [rounded]=\"getTagRounded(col, rowData)\"\n [icon]=\"getTagIcon(col, rowData)\"\n [style]=\"getTagStyle(col, rowData)\"\n />\n }\n @case ('progress') {\n <div\n class=\"shk-progress\"\n role=\"progressbar\"\n aria-valuemin=\"0\"\n aria-valuemax=\"100\"\n [attr.aria-valuenow]=\"getProgress(col, rowData)\"\n [attr.aria-label]=\"col.header\"\n >\n <div [style.width.%]=\"getProgress(col, rowData)\"></div>\n </div>\n }\n @case ('boolean') {\n @if (resolveField(rowData, col.field)) {\n <svg\n [shkIcon]=\"icons.yes\"\n class=\"w-4 h-4 [color:var(--shk-success-600)]\"\n role=\"img\"\n [attr.aria-label]=\"filterLabel('yes')\"\n ></svg>\n } @else {\n <svg\n [shkIcon]=\"icons.no\"\n class=\"w-4 h-4 [color:var(--shk-error-500)]\"\n role=\"img\"\n [attr.aria-label]=\"filterLabel('no')\"\n ></svg>\n }\n }\n @case ('date') {\n {{ formatDateCell(resolveField(rowData, col.field), col) }}\n }\n @case ('currency') {\n {{ formatCurrencyCell(resolveField(rowData, col.field), col) }}\n }\n @default {\n @if (col.image) {\n <div class=\"flex items-center gap-2\">\n @if (col.image(rowData); as src) {\n <img\n [src]=\"src\"\n alt=\"\"\n [width]=\"col.imageWidth || 24\"\n class=\"shrink-0 rounded-sm\"\n />\n }\n <span>\n <ng-container\n *ngTemplateOutlet=\"cellText; context: { $implicit: rowData, col: col }\"\n ></ng-container>\n </span>\n </div>\n } @else {\n <ng-container\n *ngTemplateOutlet=\"cellText; context: { $implicit: rowData, col: col }\"\n ></ng-container>\n }\n }\n }\n } @else {\n <div class=\"flex items-center justify-start gap-px\">\n @for (action of getVisibleRowActions(rowData); track $index) {\n @if (isRowActionVisible(action, rowData)) {\n <div class=\"relative group\">\n <shk-tooltip\n [text]=\"getRowActionLabel(action, rowData)\"\n position=\"top\"\n >\n <button\n type=\"button\"\n (click)=\"action.onClick(rowData)\"\n [class]=\"\n 'table-action-btn hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] rounded-md ' +\n getRowActionClass(action, rowData)\n \"\n [disabled]=\"isRowActionDisabled(action, rowData) || false\"\n [attr.aria-label]=\"getRowActionLabel(action, rowData)\"\n >\n <svg\n [shkIcon]=\"getIcon(getRowActionIconName(action, rowData))\"\n class=\"w-4 h-4\"\n ></svg>\n </button>\n </shk-tooltip>\n </div>\n }\n }\n @if (getHiddenRowActions(rowData).length > 0) {\n <div class=\"relative\">\n <shk-tooltip\n [text]=\"'common.more_options' | transloco\"\n position=\"top\"\n >\n <button\n type=\"button\"\n (click)=\"$event.stopPropagation(); toggleActionsDropdown(rowData, $event)\"\n class=\"table-action-btn hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] rounded-md\"\n [attr.aria-label]=\"'common.more_options' | transloco\"\n [attr.aria-expanded]=\"isActionsDropdownOpen(rowData)\"\n >\n <svg\n [shkIcon]=\"getIcon('ellipsis-vertical')\"\n class=\"w-4 h-4\"\n ></svg>\n </button>\n </shk-tooltip>\n @if (isActionsDropdownOpen(rowData)) {\n <div\n shkPortal\n class=\"fixed z-[9999] min-w-[160px] bg-white dark:[background-color:var(--shk-surface-100)] border _shk-border rounded-md shadow-lg py-1\"\n [style.top]=\"dropdownPosition().top + 'px'\"\n [style.left]=\"dropdownPosition().left + 'px'\"\n >\n @for (action of getHiddenRowActions(rowData); track $index) {\n <button\n type=\"button\"\n (click)=\"action.onClick(rowData); toggleActionsDropdown(rowData)\"\n [disabled]=\"isRowActionDisabled(action, rowData) || false\"\n [class]=\"\n 'w-full flex items-center gap-2 px-3 py-2 text-xs text-left _shk-text-surface-700 dark:[color:var(--shk-surface-700)] hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] disabled:opacity-40 disabled:cursor-not-allowed transition-colors ' +\n getRowActionClass(action, rowData)\n \"\n >\n <svg\n [shkIcon]=\"getIcon(getRowActionIconName(action, rowData))\"\n class=\"w-3.5 h-3.5 shrink-0\"\n ></svg>\n <span>{{ getRowActionLabel(action, rowData) }}</span>\n </button>\n }\n </div>\n }\n </div>\n }\n @if (rowSeverityValue) {\n <div class=\"relative group\">\n <shk-tooltip [text]=\"rowValidationTitle(rowData) || ''\" position=\"top\">\n <span\n class=\"shk-row-validation-btn\"\n [class.shk-sev-low]=\"rowSeverityValue === 'low'\"\n [class.shk-sev-moderate]=\"rowSeverityValue === 'moderate'\"\n [class.shk-sev-critical]=\"rowSeverityValue === 'critical'\"\n tabindex=\"0\"\n role=\"note\"\n [attr.aria-label]=\"rowValidationLabel(rowData)\"\n >\n <svg [shkIcon]=\"rowValidationIcon(rowData)\"></svg>\n </span>\n </shk-tooltip>\n </div>\n }\n </div>\n }\n </td>\n }\n </tr>\n }\n </tbody>\n }\n </table>\n\n <!-- Text content of a cell: format() \u00B7 custom template \u00B7 raw value -->\n <ng-template #cellText let-rowData let-col=\"col\">\n @if (col.format) {\n <span>{{ col.format(rowData) }}</span>\n } @else {\n <ng-container\n *ngTemplateOutlet=\"\n customTemplates()[col.field] || defaultTemplate;\n context: { $implicit: rowData, field: col.field }\n \"\n ></ng-container>\n }\n </ng-template>\n <ng-template #defaultTemplate let-rowData let-field=\"field\">\n {{ resolveField(rowData, field) }}\n </ng-template>\n\n <!-- Option list of the select / multiselect filters -->\n <ng-template #optionList let-col let-draft=\"draft\" let-multiple=\"multiple\">\n <div class=\"p-2 space-y-1.5\">\n @let selectedLabel = multiple ? selectedOptionsLabel(col) : selectedSingleLabel(col);\n <button\n type=\"button\"\n class=\"shk-filter-select flex items-center justify-between gap-2 text-left\"\n style=\"background-image: none\"\n [id]=\"uid + '-filter-' + safeId(col.field) + '-0'\"\n [attr.aria-expanded]=\"multiselectOpen()\"\n (click)=\"multiselectOpen.set(!multiselectOpen())\"\n >\n <span class=\"truncate\" [class._shk-text-surface-400]=\"!selectedLabel\">\n {{ selectedLabel || tr('table.filterAll', 'Todos') }}\n </span>\n <svg\n [shkIcon]=\"getIcon('chevron-down')\"\n class=\"w-3.5 h-3.5 shrink-0 _shk-text-surface-400 transition-transform\"\n [class.rotate-180]=\"multiselectOpen()\"\n ></svg>\n </button>\n @if (multiselectOpen()) {\n <div\n class=\"max-h-52 overflow-y-auto p-0.5 border _shk-border rounded-md _shk-scrollbar\"\n role=\"listbox\"\n [attr.aria-multiselectable]=\"multiple\"\n >\n @for (opt of col.filterOptions || []; track $index) {\n @let isSelected = multiple\n ? isOptionSelected(opt.value)\n : draft.rules[0].value != null && draft.rules[0].value == opt.value;\n <button\n type=\"button\"\n role=\"option\"\n class=\"w-full flex items-center gap-2 px-2 py-1.5 rounded text-left transition-colors hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)]\"\n [class._shk-bg-primary-soft]=\"isSelected\"\n [class._shk-text-primary-700]=\"isSelected\"\n [attr.aria-selected]=\"isSelected\"\n (click)=\"multiple ? toggleOption(col, opt.value) : selectOption(col, opt.value)\"\n >\n @if (multiple) {\n <span class=\"shk-checkbox-box\" [class.shk-checked]=\"isSelected\">\n @if (isSelected) {\n <svg [shkIcon]=\"getIcon('check')\"></svg>\n }\n </span>\n }\n @if (opt.image) {\n <img [src]=\"opt.image\" alt=\"\" width=\"22\" class=\"shrink-0 rounded-sm\" />\n }\n <span class=\"truncate\">{{ opt.label }}</span>\n </button>\n }\n </div>\n }\n </div>\n </ng-template>\n </div>\n <div\n class=\"table-pagination flex items-center justify-between gap-4 px-2 min-[1440px]:px-3 py-2 border-t _shk-border\"\n >\n <div class=\"text-xs _shk-text-surface-600\">\n @if (showPageReport()) {\n {{ pageReport() }}\n }\n </div>\n <div\n class=\"flex items-center gap-0.5\"\n role=\"navigation\"\n >\n <button\n type=\"button\"\n (click)=\"goToFirst()\"\n [disabled]=\"isFirstPage()\"\n [attr.aria-label]=\"tr('table.firstPage', 'Primera p\u00E1gina')\"\n class=\"shk-page-btn p-1 _shk-text-surface-500 hover:[color:var(--shk-surface-700)] dark:hover:[color:var(--shk-surface-200)] disabled:opacity-30 disabled:cursor-not-allowed rounded transition-colors\"\n >\n <svg [shkIcon]=\"getIcon('chevrons-left')\" class=\"w-4 h-4\"></svg>\n </button>\n <button\n type=\"button\"\n (click)=\"prev()\"\n [disabled]=\"isFirstPage()\"\n [attr.aria-label]=\"tr('table.prevPage', 'P\u00E1gina anterior')\"\n class=\"shk-page-btn p-1 _shk-text-surface-500 hover:[color:var(--shk-surface-700)] dark:hover:[color:var(--shk-surface-200)] disabled:opacity-30 disabled:cursor-not-allowed rounded transition-colors\"\n >\n <svg [shkIcon]=\"getIcon('chevron-left')\" class=\"w-4 h-4\"></svg>\n </button>\n <span\n class=\"px-2 text-xs font-medium _shk-text-surface-700\"\n >{{ currentPage() }} / {{ totalPages() }}</span\n >\n <button\n type=\"button\"\n (click)=\"next()\"\n [disabled]=\"isLastPage()\"\n [attr.aria-label]=\"tr('table.nextPage', 'P\u00E1gina siguiente')\"\n class=\"shk-page-btn p-1 _shk-text-surface-500 hover:[color:var(--shk-surface-700)] dark:hover:[color:var(--shk-surface-200)] disabled:opacity-30 disabled:cursor-not-allowed rounded transition-colors\"\n >\n <svg [shkIcon]=\"getIcon('chevron-right')\" class=\"w-4 h-4\"></svg>\n </button>\n <button\n type=\"button\"\n (click)=\"goToLast()\"\n [disabled]=\"isLastPage()\"\n [attr.aria-label]=\"tr('table.lastPage', '\u00DAltima p\u00E1gina')\"\n class=\"shk-page-btn p-1 _shk-text-surface-500 hover:[color:var(--shk-surface-700)] dark:hover:[color:var(--shk-surface-200)] disabled:opacity-30 disabled:cursor-not-allowed rounded transition-colors\"\n >\n <svg [shkIcon]=\"getIcon('chevrons-right')\" class=\"w-4 h-4\"></svg>\n </button>\n </div>\n <div\n class=\"flex items-center gap-1.5 text-xs _shk-text-surface-600\"\n >\n @if (showRowsPerPage()) {\n <label [for]=\"uid + '-rows-per-page'\">{{ 'table.rows' | transloco }}</label>\n <select\n [id]=\"uid + '-rows-per-page'\"\n (change)=\"onRowsPerPageChange($any($event.target).value)\"\n class=\"border _shk-border rounded px-2 py-1 text-xs bg-white dark:[background-color:var(--shk-surface-100)] _shk-text-surface-700 focus:outline-none focus:[border-color:var(--shk-primary-500)]\"\n >\n @for (opt of rowsPerPageOptions(); track opt) {\n <option [value]=\"opt\" [selected]=\"opt === rowsPerPageLocal()\">{{ opt }}</option>\n }\n </select>\n }\n </div>\n </div>\n </div>\n</div>\n", styles: ["input:focus{outline:none}input[type=text]{font-weight:400!important}table th{white-space:nowrap}table td{white-space:normal;overflow-wrap:break-word}.shk-page-btn{display:inline-flex;align-items:center;justify-content:center;width:1.75rem;height:1.75rem;border-radius:.375rem;transition:background-color .15s ease,color .15s ease}.shk-page-btn:hover:not(:disabled){background-color:var(--shk-surface-100)}:host-context(.dark) .shk-page-btn:hover:not(:disabled){background-color:var(--shk-surface-200)}.shk-page-btn:focus-visible{outline:none;box-shadow:0 0 0 2px color-mix(in srgb,var(--shk-primary-500) 45%,transparent)}td button svg{width:1.125rem!important;height:1.125rem!important}td button:disabled{opacity:.4;cursor:not-allowed}.table-action-btn svg{width:1rem!important;height:1rem!important;min-width:1rem!important;min-height:1rem!important}.table-action-btn{padding:.5rem!important;min-width:2rem!important;min-height:2rem!important;display:inline-flex!important;align-items:center!important;justify-content:center!important}.table-scroll-wrapper{width:100%;overflow-x:auto;overflow-y:hidden;border-radius:inherit;-webkit-overflow-scrolling:touch;container-type:inline-size}.table-card,.table-pagination{container-type:inline-size}@container (max-width: 640px){.table-pagination{flex-direction:column;align-items:center;gap:.5rem}.table-pagination>div{justify-content:center}}.table-scroll-wrapper table{table-layout:auto;width:100%}@container (max-width: 768px){.table-scroll-wrapper{scroll-snap-type:x mandatory}.table-scroll-wrapper table{table-layout:auto;width:100%}.table-scroll-wrapper th:not([data-shk-actions]):not([data-shk-select]){min-width:var(--shk-col-width, 140px)}.table-scroll-wrapper td:not([data-shk-actions]):not([data-shk-select]){min-width:var(--shk-col-width, 140px);max-width:var(--shk-col-width, 140px)}.table-scroll-wrapper th,.table-scroll-wrapper td{scroll-snap-align:start}}th[data-shk-select],td[data-shk-select]{width:2.5rem;min-width:2.5rem}.shk-table-checkbox{width:.875rem;height:.875rem;cursor:pointer;vertical-align:middle;accent-color:var(--shk-primary-500)}.shk-table-checkbox:disabled{opacity:.4;cursor:not-allowed}tr.shk-row-selected{background-color:color-mix(in srgb,var(--shk-primary-50) 60%,transparent)}tr.shk-row-selected:hover{background-color:color-mix(in srgb,var(--shk-primary-50) 90%,transparent)}:host-context(.dark) tr.shk-row-selected{background-color:color-mix(in srgb,var(--shk-primary-900) 20%,transparent)}:host-context(.dark) tr.shk-row-selected:hover{background-color:color-mix(in srgb,var(--shk-primary-900) 30%,transparent)}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.shk-data-table tr.shk-row-low{background-color:color-mix(in srgb,var(--shk-info-600) 22%,transparent)}.shk-data-table tr.shk-row-moderate{background-color:color-mix(in srgb,var(--shk-warning-400) 32%,transparent)}.shk-data-table tr.shk-row-critical{background-color:color-mix(in srgb,var(--shk-error-500) 20%,transparent)}:host-context(.dark) .shk-data-table tr.shk-row-low{background-color:color-mix(in srgb,var(--shk-info-600) 26%,transparent)}:host-context(.dark) .shk-data-table tr.shk-row-moderate{background-color:color-mix(in srgb,var(--shk-warning-400) 34%,transparent)}:host-context(.dark) .shk-data-table tr.shk-row-critical{background-color:color-mix(in srgb,var(--shk-error-500) 24%,transparent)}.shk-row-validation-btn{display:inline-flex;align-items:center;justify-content:center;padding:.25rem;border-radius:.375rem;cursor:help;color:var(--shk-surface-500)}.shk-row-validation-btn svg{width:1rem!important;height:1rem!important}.shk-row-validation-btn.shk-sev-low{color:var(--shk-info-600)}.shk-row-validation-btn.shk-sev-moderate{color:var(--shk-warning-600)}:host-context(.dark) .shk-row-validation-btn.shk-sev-moderate{color:var(--shk-warning-400)}.shk-row-validation-btn.shk-sev-critical{color:var(--shk-error-500)}.shk-row-validation-btn:focus-visible{outline:2px solid currentColor;outline-offset:1px}table.shk-row-hover tbody tr.shk-data-row:hover{background-color:color-mix(in srgb,var(--shk-primary-50) 30%,transparent)}:host-context(.dark) table.shk-row-hover tbody tr.shk-data-row:hover{background-color:color-mix(in srgb,var(--shk-primary-900) 10%,transparent)}table.shk-gridlines th,table.shk-gridlines td{border-right:1px solid var(--shk-surface-200)}table.shk-gridlines th:last-child,table.shk-gridlines td:last-child{border-right:0}:host-context(.dark) table.shk-gridlines th,:host-context(.dark) table.shk-gridlines td{border-right-color:var(--shk-surface-200)}.shk-col-resizer{position:absolute;top:0;right:-4px;z-index:1;width:8px;height:100%;cursor:col-resize;touch-action:none}.shk-col-resizer:after{content:\"\";position:absolute;top:20%;bottom:20%;left:3px;width:2px;border-radius:1px;background-color:transparent;transition:background-color .15s ease}.shk-col-resizer:hover:after,.shk-col-resizer:focus-visible:after,.shk-col-resizer.shk-resizing:after{background-color:var(--shk-primary-500)}.shk-col-resizer:focus-visible{outline:none}th:last-child .shk-col-resizer{right:0}.shk-filter-input,.shk-filter-select{width:100%;padding:.375rem .625rem;font-size:.75rem;line-height:1.25rem;border-radius:.375rem;border:1px solid var(--shk-surface-200);background-color:#fff;color:var(--shk-surface-700)}.dark .shk-filter-input,.dark .shk-filter-select{background-color:var(--shk-surface-100);border-color:var(--shk-surface-200);color-scheme:dark}.shk-filter-input::placeholder{color:var(--shk-surface-400)}select.shk-filter-select{appearance:none;padding-right:1.75rem;background-image:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E\");background-repeat:no-repeat;background-position:right .5rem center;cursor:pointer}button.shk-filter-select{cursor:pointer}.shk-filter-input:focus,.shk-filter-select:focus{outline:none;border-color:var(--shk-primary-500);box-shadow:0 0 0 1px var(--shk-primary-500)}.shk-checkbox-box{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;width:.875rem;height:.875rem;border-radius:.1875rem;border:1px solid var(--shk-surface-300);background-color:#fff;color:#fff}.dark .shk-checkbox-box{background-color:var(--shk-surface-100)}.shk-checkbox-box.shk-checked{background-color:var(--shk-primary-500);border-color:var(--shk-primary-500)}.shk-checkbox-box svg{width:.625rem;height:.625rem}.shk-range{position:relative;height:1rem;margin:.5rem .375rem .375rem}.shk-range-track,.shk-range-fill{position:absolute;top:50%;height:.1875rem;transform:translateY(-50%);border-radius:9999px}.shk-range-track{left:0;right:0;background-color:var(--shk-surface-200)}.shk-range-fill{background-color:var(--shk-primary-500)}.shk-range input[type=range]{position:absolute;inset:0;width:100%;margin:0;background:transparent;pointer-events:none;appearance:none;-webkit-appearance:none}.shk-range input[type=range]::-webkit-slider-thumb{pointer-events:auto;-webkit-appearance:none;width:.875rem;height:.875rem;border-radius:9999px;background:#fff;border:2px solid var(--shk-primary-500);cursor:grab}.shk-range input[type=range]::-moz-range-thumb{pointer-events:auto;width:.625rem;height:.625rem;border-radius:9999px;background:#fff;border:2px solid var(--shk-primary-500);cursor:grab}.shk-progress{height:.375rem;min-width:5rem;border-radius:9999px;background-color:var(--shk-surface-200);overflow:hidden}.shk-progress>div{height:100%;border-radius:inherit;background-color:var(--shk-primary-500)}\n"] }]
1693
- }], ctorParameters: () => [], propDecorators: { data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: false }] }], columns: [{ type: i0.Input, args: [{ isSignal: true, alias: "columns", required: false }] }], rowsPerPage: [{ type: i0.Input, args: [{ isSignal: true, alias: "rowsPerPage", required: false }] }], rowsPerPageOptions: [{ type: i0.Input, args: [{ isSignal: true, alias: "rowsPerPageOptions", required: false }] }], loading: [{ type: i0.Input, args: [{ isSignal: true, alias: "loading", required: false }] }], showActionRow: [{ type: i0.Input, args: [{ isSignal: true, alias: "showActionRow", required: false }] }], customTemplates: [{ type: i0.Input, args: [{ isSignal: true, alias: "customTemplates", required: false }] }], headerActions: [{ type: i0.Input, args: [{ isSignal: true, alias: "headerActions", required: false }] }], rowActions: [{ type: i0.Input, args: [{ isSignal: true, alias: "rowActions", required: false }] }], hasShadow: [{ type: i0.Input, args: [{ isSignal: true, alias: "hasShadow", required: false }] }], defaultSortField: [{ type: i0.Input, args: [{ isSignal: true, alias: "defaultSortField", required: false }] }], defaultSortOrder: [{ type: i0.Input, args: [{ isSignal: true, alias: "defaultSortOrder", required: false }] }], showSearch: [{ type: i0.Input, args: [{ isSignal: true, alias: "showSearch", required: false }] }], searchPlaceholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "searchPlaceholder", required: false }] }], globalFilterFields: [{ type: i0.Input, args: [{ isSignal: true, alias: "globalFilterFields", required: false }] }], emptyMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "emptyMessage", required: false }] }], serverSide: [{ type: i0.Input, args: [{ isSignal: true, alias: "serverSide", required: false }] }], totalRecords: [{ type: i0.Input, args: [{ isSignal: true, alias: "totalRecords", required: false }] }], filters: [{ type: i0.Input, args: [{ isSignal: true, alias: "filters", required: false }] }], activeFilter: [{ type: i0.Input, args: [{ isSignal: true, alias: "activeFilter", required: false }] }], showGridlines: [{ type: i0.Input, args: [{ isSignal: true, alias: "showGridlines", required: false }] }], resizableColumns: [{ type: i0.Input, args: [{ isSignal: true, alias: "resizableColumns", required: false }] }], rowValidations: [{ type: i0.Input, args: [{ isSignal: true, alias: "rowValidations", required: false }] }], columnWidths: [{ type: i0.Input, args: [{ isSignal: true, alias: "columnWidths", required: false }] }, { type: i0.Output, args: ["columnWidthsChange"] }], stateKey: [{ type: i0.Input, args: [{ isSignal: true, alias: "stateKey", required: false }] }], stateStorage: [{ type: i0.Input, args: [{ isSignal: true, alias: "stateStorage", required: false }] }], rowHover: [{ type: i0.Input, args: [{ isSignal: true, alias: "rowHover", required: false }] }], showClearButton: [{ type: i0.Input, args: [{ isSignal: true, alias: "showClearButton", required: false }] }], showPageReport: [{ type: i0.Input, args: [{ isSignal: true, alias: "showPageReport", required: false }] }], showRowsPerPage: [{ type: i0.Input, args: [{ isSignal: true, alias: "showRowsPerPage", required: false }] }], selectable: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectable", required: false }] }], dataKey: [{ type: i0.Input, args: [{ isSignal: true, alias: "dataKey", required: false }] }], isRowSelectable: [{ type: i0.Input, args: [{ isSignal: true, alias: "isRowSelectable", required: false }] }], selectOnRowClick: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectOnRowClick", required: false }] }], bulkActions: [{ type: i0.Input, args: [{ isSignal: true, alias: "bulkActions", required: false }] }], selection: [{ type: i0.Input, args: [{ isSignal: true, alias: "selection", required: false }] }, { type: i0.Output, args: ["selectionChange"] }], refresh: [{ type: i0.Output, args: ["refresh"] }], pageChange: [{ type: i0.Output, args: ["pageChange"] }], filterChange: [{ type: i0.Output, args: ["filterChange"] }], searchChange: [{ type: i0.Output, args: ["searchChange"] }], filterClick: [{ type: i0.Output, args: ["filterClick"] }], columnResize: [{ type: i0.Output, args: ["columnResize"] }], onDocumentClick: [{
1694
- type: HostListener,
1695
- args: ['document:click']
1696
- }], onEscape: [{
1697
- type: HostListener,
1698
- args: ['document:keydown.escape']
1699
- }] } });
1700
-
1701
- /**
1702
- * Generated bundle index. Do not edit.
1703
- */
1704
-
75
+ var TableComponent = class TableComponent {
76
+ getColumnWidth(col) {
77
+ return this.resizedWidth(col) || col.width || this.DEFAULT_COLUMN_WIDTH;
78
+ }
79
+ collectViolations(row, entries = Object.entries(this.rowValidations())) {
80
+ const violations = [];
81
+ for (const [field, rule] of entries) {
82
+ if (!rule || typeof rule.condition !== "function") continue;
83
+ const value = this.resolveField(row, field);
84
+ let failed = false;
85
+ try {
86
+ failed = !!rule.condition(value, row);
87
+ } catch {
88
+ failed = false;
89
+ }
90
+ if (!failed) continue;
91
+ violations.push({
92
+ field,
93
+ severity: rule.severity ?? "critical",
94
+ message: this.resolveViolationMessage(rule, value, row)
95
+ });
96
+ }
97
+ return violations;
98
+ }
99
+ resolveViolationMessage(rule, value, row) {
100
+ if (!rule.message) return void 0;
101
+ return this.tr(rule.message, rule.message, rule.messageParams?.(value, row));
102
+ }
103
+ rowViolationsOf(row) {
104
+ return this.violationsByRow().get(row) ?? this.collectViolations(row);
105
+ }
106
+ rowSeverity(row) {
107
+ let severity = null;
108
+ for (const violation of this.rowViolationsOf(row)) if (!severity || this.severityRank[violation.severity] > this.severityRank[severity]) severity = violation.severity;
109
+ return severity;
110
+ }
111
+ validateRow(row) {
112
+ return this.collectViolations(row);
113
+ }
114
+ rowValidationTitle(row) {
115
+ const messages = this.rowViolationsOf(row).map((violation) => violation.message).filter((message) => !!message);
116
+ return messages.length ? messages.join("\n") : null;
117
+ }
118
+ rowValidationIcon(row) {
119
+ const severity = this.rowSeverity(row);
120
+ return severity ? this.icons[severity] : this.icons.low;
121
+ }
122
+ rowValidationLabel(row) {
123
+ const title = this.rowValidationTitle(row);
124
+ if (title) return title;
125
+ const severity = this.rowSeverity(row);
126
+ return severity ? this.tr(`table.severity.${severity}`, {
127
+ low: "Fila con observaciones",
128
+ moderate: "Fila con advertencias",
129
+ critical: "Fila con errores"
130
+ }[severity]) : "";
131
+ }
132
+ constructor() {
133
+ this.uid = `shk-table-${nextTableId++}`;
134
+ this.cdr = inject(ChangeDetectorRef);
135
+ this.transloco = inject(TranslocoService);
136
+ this.config = inject(ShkConfigService);
137
+ this.destroyRef = inject(DestroyRef);
138
+ this.injector = inject(Injector);
139
+ this.getIcon = (name) => getIcon(name, LucidePlus);
140
+ this.icons = {
141
+ clear: LucideFunnelX,
142
+ yes: LucideCircleCheck,
143
+ no: LucideCircleX,
144
+ trash: LucideTrash2,
145
+ low: LucideInfo,
146
+ moderate: LucideTriangleAlert,
147
+ critical: LucideOctagonAlert
148
+ };
149
+ this.DEFAULT_COLUMN_WIDTH = "140px";
150
+ this.actionsHeaderLabel = toSignal(this.transloco.selectTranslate("common.actions"), { initialValue: "Acciones" });
151
+ this.currentLang = toSignal(this.transloco.langChanges$, { initialValue: this.transloco.getActiveLang() });
152
+ this.translations = toSignal(this.transloco.selectTranslation());
153
+ this.data = input([], ...ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []);
154
+ this.columns = input([], ...ngDevMode ? [{ debugName: "columns" }] : /* istanbul ignore next */ []);
155
+ this.rowsPerPage = input(10, ...ngDevMode ? [{ debugName: "rowsPerPage" }] : /* istanbul ignore next */ []);
156
+ this.rowsPerPageOptions = input([
157
+ 10,
158
+ 25,
159
+ 50
160
+ ], ...ngDevMode ? [{ debugName: "rowsPerPageOptions" }] : /* istanbul ignore next */ []);
161
+ this.loading = input(false, ...ngDevMode ? [{ debugName: "loading" }] : /* istanbul ignore next */ []);
162
+ this.showActionRow = input(true, ...ngDevMode ? [{ debugName: "showActionRow" }] : /* istanbul ignore next */ []);
163
+ this.customTemplates = input({}, ...ngDevMode ? [{ debugName: "customTemplates" }] : /* istanbul ignore next */ []);
164
+ this.headerActions = input([], ...ngDevMode ? [{ debugName: "headerActions" }] : /* istanbul ignore next */ []);
165
+ this.rowActions = input([], ...ngDevMode ? [{ debugName: "rowActions" }] : /* istanbul ignore next */ []);
166
+ this.hasShadow = input(true, ...ngDevMode ? [{ debugName: "hasShadow" }] : /* istanbul ignore next */ []);
167
+ this.defaultSortField = input("", ...ngDevMode ? [{ debugName: "defaultSortField" }] : /* istanbul ignore next */ []);
168
+ this.defaultSortOrder = input(1, ...ngDevMode ? [{ debugName: "defaultSortOrder" }] : /* istanbul ignore next */ []);
169
+ this.showSearch = input(true, ...ngDevMode ? [{ debugName: "showSearch" }] : /* istanbul ignore next */ []);
170
+ this.searchPlaceholder = input("", ...ngDevMode ? [{ debugName: "searchPlaceholder" }] : /* istanbul ignore next */ []);
171
+ this.globalFilterFields = input([], ...ngDevMode ? [{ debugName: "globalFilterFields" }] : /* istanbul ignore next */ []);
172
+ this.emptyMessage = input("", ...ngDevMode ? [{ debugName: "emptyMessage" }] : /* istanbul ignore next */ []);
173
+ this.serverSide = input(false, ...ngDevMode ? [{ debugName: "serverSide" }] : /* istanbul ignore next */ []);
174
+ this.totalRecords = input(0, ...ngDevMode ? [{ debugName: "totalRecords" }] : /* istanbul ignore next */ []);
175
+ this.filters = input([], ...ngDevMode ? [{ debugName: "filters" }] : /* istanbul ignore next */ []);
176
+ this.activeFilter = input("", ...ngDevMode ? [{ debugName: "activeFilter" }] : /* istanbul ignore next */ []);
177
+ this.showGridlines = input(false, ...ngDevMode ? [{ debugName: "showGridlines" }] : /* istanbul ignore next */ []);
178
+ this.resizableColumns = input(true, ...ngDevMode ? [{ debugName: "resizableColumns" }] : /* istanbul ignore next */ []);
179
+ this.rowValidations = input({}, ...ngDevMode ? [{ debugName: "rowValidations" }] : /* istanbul ignore next */ []);
180
+ this.columnWidths = model({}, ...ngDevMode ? [{ debugName: "columnWidths" }] : /* istanbul ignore next */ []);
181
+ this.stateKey = input("", ...ngDevMode ? [{ debugName: "stateKey" }] : /* istanbul ignore next */ []);
182
+ this.stateStorage = input("local", ...ngDevMode ? [{ debugName: "stateStorage" }] : /* istanbul ignore next */ []);
183
+ this.rowHover = input(true, ...ngDevMode ? [{ debugName: "rowHover" }] : /* istanbul ignore next */ []);
184
+ this.showClearButton = input(false, ...ngDevMode ? [{ debugName: "showClearButton" }] : /* istanbul ignore next */ []);
185
+ this.showPageReport = input(true, ...ngDevMode ? [{ debugName: "showPageReport" }] : /* istanbul ignore next */ []);
186
+ this.showRowsPerPage = input(true, ...ngDevMode ? [{ debugName: "showRowsPerPage" }] : /* istanbul ignore next */ []);
187
+ this.selectable = input(false, ...ngDevMode ? [{ debugName: "selectable" }] : /* istanbul ignore next */ []);
188
+ this.dataKey = input("id", ...ngDevMode ? [{ debugName: "dataKey" }] : /* istanbul ignore next */ []);
189
+ this.isRowSelectable = input(void 0, ...ngDevMode ? [{ debugName: "isRowSelectable" }] : /* istanbul ignore next */ []);
190
+ this.selectOnRowClick = input(false, ...ngDevMode ? [{ debugName: "selectOnRowClick" }] : /* istanbul ignore next */ []);
191
+ this.bulkActions = input([], ...ngDevMode ? [{ debugName: "bulkActions" }] : /* istanbul ignore next */ []);
192
+ this.selection = model([], ...ngDevMode ? [{ debugName: "selection" }] : /* istanbul ignore next */ []);
193
+ this.refresh = output();
194
+ this.pageChange = output();
195
+ this.filterChange = output();
196
+ this.searchChange = output();
197
+ this.filterClick = output();
198
+ this.columnResize = output();
199
+ this.originalData = signal([], ...ngDevMode ? [{ debugName: "originalData" }] : /* istanbul ignore next */ []);
200
+ this.searchedData = signal([], ...ngDevMode ? [{ debugName: "searchedData" }] : /* istanbul ignore next */ []);
201
+ this.filteredData = signal([], ...ngDevMode ? [{ debugName: "filteredData" }] : /* istanbul ignore next */ []);
202
+ this.displayedData = signal([], ...ngDevMode ? [{ debugName: "displayedData" }] : /* istanbul ignore next */ []);
203
+ this.localTotalRecords = signal(0, ...ngDevMode ? [{ debugName: "localTotalRecords" }] : /* istanbul ignore next */ []);
204
+ this.first = signal(0, ...ngDevMode ? [{ debugName: "first" }] : /* istanbul ignore next */ []);
205
+ this.searchQuery = signal("", ...ngDevMode ? [{ debugName: "searchQuery" }] : /* istanbul ignore next */ []);
206
+ this.sortField = signal("", ...ngDevMode ? [{ debugName: "sortField" }] : /* istanbul ignore next */ []);
207
+ this.sortOrder = signal(1, ...ngDevMode ? [{ debugName: "sortOrder" }] : /* istanbul ignore next */ []);
208
+ this.rowsPerPageLocal = linkedSignal(() => this.rowsPerPage(), ...ngDevMode ? [{ debugName: "rowsPerPageLocal" }] : /* istanbul ignore next */ []);
209
+ this.filterState = signal({}, ...ngDevMode ? [{ debugName: "filterState" }] : /* istanbul ignore next */ []);
210
+ this.openFilterField = signal(null, ...ngDevMode ? [{ debugName: "openFilterField" }] : /* istanbul ignore next */ []);
211
+ this.filterDraft = signal(null, ...ngDevMode ? [{ debugName: "filterDraft" }] : /* istanbul ignore next */ []);
212
+ this.multiselectOpen = signal(false, ...ngDevMode ? [{ debugName: "multiselectOpen" }] : /* istanbul ignore next */ []);
213
+ this.totalPages = computed(() => Math.max(1, Math.ceil(this.effectiveTotalRecords() / this.rowsPerPageLocal())), ...ngDevMode ? [{ debugName: "totalPages" }] : /* istanbul ignore next */ []);
214
+ this.currentPage = computed(() => Math.floor(this.first() / this.rowsPerPageLocal()) + 1, ...ngDevMode ? [{ debugName: "currentPage" }] : /* istanbul ignore next */ []);
215
+ this.hasFilterableColumns = computed(() => this.columns().some((c) => c.filter), ...ngDevMode ? [{ debugName: "hasFilterableColumns" }] : /* istanbul ignore next */ []);
216
+ this.filterSubject = new Subject();
217
+ this.searchSubject = new Subject();
218
+ this.lastFilterFieldsSignature = "";
219
+ this.columnsWithActions = computed(() => {
220
+ const columnsArray = this.columns();
221
+ const showAction = this.showActionRow();
222
+ const rowActionsArray = this.rowActions();
223
+ const translatedHeader = this.actionsHeaderLabel();
224
+ const rows = this.effectiveDisplayedData();
225
+ const hasIndicator = rows.some((row) => this.rowViolationsOf(row).length > 0);
226
+ if (showAction && rowActionsArray.length > 0 || hasIndicator) {
227
+ let buttons = hasIndicator ? 1 : 0;
228
+ if (rows.length) for (const row of rows) {
229
+ const n = rowActionsArray.filter((a) => this.isRowActionVisible(a, row)).length;
230
+ const shown = n > this.MAX_VISIBLE_ACTIONS ? this.MAX_VISIBLE_ACTIONS + 1 : n;
231
+ if (shown + (hasIndicator ? 1 : 0) > buttons) buttons = shown + (hasIndicator ? 1 : 0);
232
+ }
233
+ else {
234
+ const n = rowActionsArray.length;
235
+ const shown = n > this.MAX_VISIBLE_ACTIONS ? this.MAX_VISIBLE_ACTIONS + 1 : n;
236
+ if (shown + (hasIndicator ? 1 : 0) > buttons) buttons = shown + (hasIndicator ? 1 : 0);
237
+ }
238
+ const actionsWidth = `${Math.max(this.MIN_ACTIONS_WIDTH, this.ACTIONS_CELL_PADDING + buttons * this.ACTION_BUTTON_WIDTH)}px`;
239
+ return [{
240
+ field: "actions",
241
+ header: translatedHeader || "Acciones",
242
+ width: actionsWidth,
243
+ defaultSort: true
244
+ }, ...columnsArray];
245
+ }
246
+ return [...columnsArray];
247
+ }, ...ngDevMode ? [{ debugName: "columnsWithActions" }] : /* istanbul ignore next */ []);
248
+ this.selectedKeys = computed(() => new Set(this.selection().map((row) => this.getSelectionKey(row))), ...ngDevMode ? [{ debugName: "selectedKeys" }] : /* istanbul ignore next */ []);
249
+ this.hasReceivedData = false;
250
+ this.selectablePageRows = computed(() => this.effectiveDisplayedData().filter((row) => this.canSelectRow(row)), ...ngDevMode ? [{ debugName: "selectablePageRows" }] : /* istanbul ignore next */ []);
251
+ this.allPageSelected = computed(() => {
252
+ const rows = this.selectablePageRows();
253
+ const keys = this.selectedKeys();
254
+ return rows.length > 0 && rows.every((row) => keys.has(this.getSelectionKey(row)));
255
+ }, ...ngDevMode ? [{ debugName: "allPageSelected" }] : /* istanbul ignore next */ []);
256
+ this.somePageSelected = computed(() => {
257
+ const keys = this.selectedKeys();
258
+ return !this.allPageSelected() && this.selectablePageRows().some((row) => keys.has(this.getSelectionKey(row)));
259
+ }, ...ngDevMode ? [{ debugName: "somePageSelected" }] : /* istanbul ignore next */ []);
260
+ this.visibleBulkActions = computed(() => {
261
+ const selected = this.selection();
262
+ return this.bulkActions().filter((a) => a.isVisible ? a.isVisible(selected) : true);
263
+ }, ...ngDevMode ? [{ debugName: "visibleBulkActions" }] : /* istanbul ignore next */ []);
264
+ this.totalColspan = computed(() => this.columnsWithActions().length + (this.selectable() ? 1 : 0), ...ngDevMode ? [{ debugName: "totalColspan" }] : /* istanbul ignore next */ []);
265
+ this.severityRank = {
266
+ low: 0,
267
+ moderate: 1,
268
+ critical: 2
269
+ };
270
+ this.violationsByRow = computed(() => {
271
+ const map = /* @__PURE__ */ new Map();
272
+ const entries = Object.entries(this.rowValidations());
273
+ if (!entries.length) return map;
274
+ for (const row of this.effectiveDisplayedData()) map.set(row, this.collectViolations(row, entries));
275
+ return map;
276
+ }, ...ngDevMode ? [{ debugName: "violationsByRow" }] : /* istanbul ignore next */ []);
277
+ this.effectiveTotalRecords = computed(() => {
278
+ return this.serverSide() ? this.totalRecords() : this.localTotalRecords();
279
+ }, ...ngDevMode ? [{ debugName: "effectiveTotalRecords" }] : /* istanbul ignore next */ []);
280
+ this.effectiveDisplayedData = computed(() => {
281
+ return this.serverSide() ? this.data() : this.displayedData();
282
+ }, ...ngDevMode ? [{ debugName: "effectiveDisplayedData" }] : /* istanbul ignore next */ []);
283
+ this.pageReport = computed(() => {
284
+ this.translations();
285
+ this.currentLang();
286
+ const total = this.effectiveTotalRecords();
287
+ if (total === 0) return this.transloco.translate("table.pageReport", {
288
+ from: 0,
289
+ to: 0,
290
+ total: 0
291
+ });
292
+ const from = this.first() + 1;
293
+ const to = Math.min(this.first() + this.rowsPerPageLocal(), total);
294
+ return this.transloco.translate("table.pageReport", {
295
+ from,
296
+ to,
297
+ total
298
+ });
299
+ }, ...ngDevMode ? [{ debugName: "pageReport" }] : /* istanbul ignore next */ []);
300
+ this.MIN_COLUMN_WIDTH = 60;
301
+ this.ACTION_BUTTON_WIDTH = 33;
302
+ this.ACTIONS_CELL_PADDING = 24;
303
+ this.MIN_ACTIONS_WIDTH = 84;
304
+ this.resizingField = signal(null, ...ngDevMode ? [{ debugName: "resizingField" }] : /* istanbul ignore next */ []);
305
+ this.suppressHeaderClick = false;
306
+ this.isResizable = computed(() => this.showGridlines() && this.resizableColumns(), ...ngDevMode ? [{ debugName: "isResizable" }] : /* istanbul ignore next */ []);
307
+ this.hasActiveFilters = computed(() => {
308
+ if (this.searchQuery()) return true;
309
+ const state = this.filterState();
310
+ return this.columns().some((c) => c.filter && this.activeRules(c, state[c.field]).length > 0);
311
+ }, ...ngDevMode ? [{ debugName: "hasActiveFilters" }] : /* istanbul ignore next */ []);
312
+ this.FILTER_POPUP_WIDTH = 240;
313
+ this.filterPopupPosition = signal({
314
+ top: 0,
315
+ left: 0,
316
+ maxHeight: 400
317
+ }, ...ngDevMode ? [{ debugName: "filterPopupPosition" }] : /* istanbul ignore next */ []);
318
+ this.filterAnchor = null;
319
+ this.filterListenersCleanup = null;
320
+ this.MAX_VISIBLE_ACTIONS = 4;
321
+ this.actionsDropdownOpen = signal({}, ...ngDevMode ? [{ debugName: "actionsDropdownOpen" }] : /* istanbul ignore next */ []);
322
+ this.dropdownPosition = signal({
323
+ top: 0,
324
+ left: 0
325
+ }, ...ngDevMode ? [{ debugName: "dropdownPosition" }] : /* istanbul ignore next */ []);
326
+ this.destroyRef.onDestroy(() => this.filterListenersCleanup?.());
327
+ afterEveryRender(() => {
328
+ if (this.filterAnchor && !this.filterAnchor.isConnected) this.closeFilters();
329
+ });
330
+ this.filterSubject.pipe(debounceTime(300), takeUntilDestroyed(this.destroyRef)).subscribe(() => {
331
+ if (this.serverSide()) this.emitFilterChange();
332
+ });
333
+ this.searchSubject.pipe(debounceTime(300), takeUntilDestroyed(this.destroyRef)).subscribe((value) => {
334
+ this.searchChange.emit(value);
335
+ });
336
+ effect(() => {
337
+ const newData = this.data();
338
+ untracked(() => {
339
+ this.originalData.set([...newData]);
340
+ if (!this.serverSide()) this.applyFilters();
341
+ });
342
+ });
343
+ effect(() => {
344
+ const newData = this.data();
345
+ const loading = this.loading();
346
+ untracked(() => {
347
+ if (this.serverSide() || loading) return;
348
+ if (newData.length > 0) this.hasReceivedData = true;
349
+ if (this.hasReceivedData) this.pruneSelection(newData);
350
+ });
351
+ });
352
+ effect(() => {
353
+ const key = this.stateKey();
354
+ const storage = this.stateStorage();
355
+ untracked(() => {
356
+ if (!key) return;
357
+ const saved = this.readStoredWidths(key, storage);
358
+ if (saved) this.columnWidths.set(saved);
359
+ });
360
+ });
361
+ effect(() => {
362
+ const widths = this.columnWidths();
363
+ const resizing = this.resizingField();
364
+ const key = this.stateKey();
365
+ const storage = this.stateStorage();
366
+ if (!key || resizing) return;
367
+ untracked(() => this.writeStoredWidths(key, storage, widths));
368
+ });
369
+ effect(() => {
370
+ const cols = this.columns();
371
+ untracked(() => {
372
+ this.setupColumnFilters(cols);
373
+ });
374
+ });
375
+ effect(() => {
376
+ const field = this.defaultSortField();
377
+ const order = this.defaultSortOrder();
378
+ if (field) untracked(() => {
379
+ this.sortField.set(field);
380
+ this.sortOrder.set(order);
381
+ if (!this.serverSide()) {
382
+ this.applySort();
383
+ this.updateDisplayedData();
384
+ }
385
+ });
386
+ });
387
+ effect(() => {
388
+ this.searchQuery();
389
+ untracked(() => {
390
+ if (!this.serverSide()) this.applySearch();
391
+ });
392
+ });
393
+ }
394
+ tr(key, fallback, params) {
395
+ this.translations();
396
+ this.currentLang();
397
+ const value = this.transloco.translate(key, params);
398
+ if (value && value !== key) return value;
399
+ return fallback.replace(/\{\{\s*(\w+)\s*\}\}/g, (_, name) => String(params?.[name] ?? ""));
400
+ }
401
+ filterLabel(name, params) {
402
+ return this.tr(`table.filter.${name}`, FILTER_LABELS[name] ?? name, params);
403
+ }
404
+ matchModeLabel(mode) {
405
+ return this.tr(`table.filter.matchModes.${mode}`, FILTER_LABELS[mode] ?? mode);
406
+ }
407
+ resolveField(row, path) {
408
+ if (row == null || !path) return void 0;
409
+ if (typeof row === "object" && path in row) return row[path];
410
+ return path.split(".").reduce((obj, key) => obj == null ? void 0 : obj[key], row);
411
+ }
412
+ filterFieldOf(col) {
413
+ return col.filterField || col.field;
414
+ }
415
+ normalize(value) {
416
+ return String(value ?? "").normalize("NFD").replace(/[̀-ͯ]/g, "").toLocaleLowerCase();
417
+ }
418
+ filterKind(col) {
419
+ const type = col.filterType ?? "text";
420
+ return type === "exact" ? "text" : type;
421
+ }
422
+ matchModesFor(col) {
423
+ return MATCH_MODES[this.filterKind(col)] ?? [];
424
+ }
425
+ defaultMatchMode(col) {
426
+ if (col.filterMatchMode) return col.filterMatchMode;
427
+ switch (this.filterKind(col)) {
428
+ case "text": return col.filterType === "exact" ? "equals" : "contains";
429
+ case "numeric": return "equals";
430
+ case "date": return "dateIs";
431
+ case "multiselect": return "in";
432
+ case "range": return "between";
433
+ default: return "equals";
434
+ }
435
+ }
436
+ supportsRules(col) {
437
+ return !!MATCH_MODES[this.filterKind(col)];
438
+ }
439
+ showMatchModesFor(col) {
440
+ return this.supportsRules(col) && col.showMatchModes !== false;
441
+ }
442
+ showOperatorFor(col) {
443
+ return this.supportsRules(col) && col.showOperator !== false;
444
+ }
445
+ canAddRule(col) {
446
+ const draft = this.filterDraft();
447
+ return this.supportsRules(col) && col.showAddButton !== false && !!draft && draft.rules.length < (col.maxConstraints ?? 2);
448
+ }
449
+ appliesImmediately(col) {
450
+ return !this.supportsRules(col);
451
+ }
452
+ emptyFilterState(col) {
453
+ return {
454
+ operator: "and",
455
+ rules: [{
456
+ matchMode: this.defaultMatchMode(col),
457
+ value: null
458
+ }]
459
+ };
460
+ }
461
+ cloneState(state) {
462
+ return {
463
+ operator: state.operator,
464
+ rules: state.rules.map((r) => ({
465
+ matchMode: r.matchMode,
466
+ value: Array.isArray(r.value) ? [...r.value] : r.value
467
+ }))
468
+ };
469
+ }
470
+ rangeBounds(col) {
471
+ return [col.filterMin ?? 0, col.filterMax ?? 100];
472
+ }
473
+ isRuleActive(col, rule) {
474
+ const value = rule.value;
475
+ if (value === null || value === void 0 || value === "") return false;
476
+ if (this.filterKind(col) === "range") {
477
+ if (!Array.isArray(value) || value.length !== 2) return false;
478
+ const [min, max] = this.rangeBounds(col);
479
+ return value[0] > min || value[1] < max;
480
+ }
481
+ if (Array.isArray(value)) return value.length > 0;
482
+ return true;
483
+ }
484
+ activeRules(col, state) {
485
+ return (state?.rules ?? []).filter((r) => this.isRuleActive(col, r));
486
+ }
487
+ toDay(value) {
488
+ if (value === null || value === void 0 || value === "") return null;
489
+ let date;
490
+ if (value instanceof Date) date = value;
491
+ else if (typeof value === "string" && /^\d{4}-\d{2}-\d{2}$/.test(value)) {
492
+ const [y, m, d] = value.split("-").map(Number);
493
+ date = new Date(y, m - 1, d);
494
+ } else date = new Date(value);
495
+ if (isNaN(date.getTime())) return null;
496
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime();
497
+ }
498
+ matchRule(col, cell, rule) {
499
+ const value = rule.value;
500
+ switch (rule.matchMode) {
501
+ case "startsWith": return this.normalize(cell).startsWith(this.normalize(value));
502
+ case "contains": return this.normalize(cell).includes(this.normalize(value));
503
+ case "notContains": return !this.normalize(cell).includes(this.normalize(value));
504
+ case "endsWith": return this.normalize(cell).endsWith(this.normalize(value));
505
+ case "equals":
506
+ case "notEquals": {
507
+ let equal;
508
+ const kind = this.filterKind(col);
509
+ if (kind === "numeric") equal = cell !== null && cell !== void 0 && cell !== "" && Number(cell) === Number(value);
510
+ else if (kind === "boolean") equal = Boolean(cell) === Boolean(value);
511
+ else if (kind === "select") equal = cell == value;
512
+ else equal = this.normalize(cell) === this.normalize(value);
513
+ return rule.matchMode === "equals" ? equal : !equal;
514
+ }
515
+ case "lt":
516
+ case "lte":
517
+ case "gt":
518
+ case "gte": {
519
+ if (cell === null || cell === void 0 || cell === "") return false;
520
+ const a = Number(cell);
521
+ const b = Number(value);
522
+ if (isNaN(a) || isNaN(b)) return false;
523
+ if (rule.matchMode === "lt") return a < b;
524
+ if (rule.matchMode === "lte") return a <= b;
525
+ if (rule.matchMode === "gt") return a > b;
526
+ return a >= b;
527
+ }
528
+ case "dateIs":
529
+ case "dateIsNot":
530
+ case "dateBefore":
531
+ case "dateAfter": {
532
+ const a = this.toDay(cell);
533
+ const b = this.toDay(value);
534
+ if (b === null) return true;
535
+ if (a === null) return rule.matchMode === "dateIsNot";
536
+ if (rule.matchMode === "dateIs") return a === b;
537
+ if (rule.matchMode === "dateIsNot") return a !== b;
538
+ if (rule.matchMode === "dateBefore") return a < b;
539
+ return a > b;
540
+ }
541
+ case "in": return value.some((v) => v == cell);
542
+ case "between": {
543
+ if (cell === null || cell === void 0 || cell === "") return false;
544
+ const n = Number(cell);
545
+ return n >= value[0] && n <= value[1];
546
+ }
547
+ default: return true;
548
+ }
549
+ }
550
+ setupColumnFilters(cols) {
551
+ const filterableCols = cols.filter((c) => c.filter);
552
+ const signature = filterableCols.map((c) => `${c.field}:${c.filterType ?? "text"}`).join("|");
553
+ if (signature === this.lastFilterFieldsSignature) return;
554
+ this.lastFilterFieldsSignature = signature;
555
+ const previous = this.filterState();
556
+ const next = {};
557
+ filterableCols.forEach((col) => {
558
+ next[col.field] = previous[col.field] ?? this.emptyFilterState(col);
559
+ });
560
+ this.filterState.set(next);
561
+ }
562
+ emitFilterChange() {
563
+ const filters = {};
564
+ const filterMeta = {};
565
+ const state = this.filterState();
566
+ this.columns().forEach((col) => {
567
+ if (!col.filter) return;
568
+ const rules = this.activeRules(col, state[col.field]);
569
+ if (rules.length === 0) return;
570
+ const key = this.filterFieldOf(col);
571
+ filters[key] = rules[0].value;
572
+ filterMeta[key] = this.cloneState({
573
+ operator: state[col.field].operator,
574
+ rules
575
+ });
576
+ });
577
+ this.filterChange.emit({
578
+ filters,
579
+ filterMeta
580
+ });
581
+ }
582
+ applySearch() {
583
+ const original = this.originalData();
584
+ const query = this.normalize(this.searchQuery().trim());
585
+ if (!query) this.searchedData.set([...original]);
586
+ else {
587
+ const fields = this.globalFilterFields();
588
+ const filtered = original.filter((item) => {
589
+ return (fields.length ? fields.map((f) => this.resolveField(item, f)) : Object.values(item ?? {}).filter((v) => v === null || typeof v !== "object" || v instanceof Date)).some((val) => {
590
+ if (val === null || val === void 0) return false;
591
+ return this.normalize(val).includes(query);
592
+ });
593
+ });
594
+ this.searchedData.set(filtered);
595
+ }
596
+ this.applyColumnFilters();
597
+ }
598
+ applyFilters() {
599
+ this.applySearch();
600
+ }
601
+ applyColumnFilters() {
602
+ let filtered = [...this.searchedData()];
603
+ const state = this.filterState();
604
+ this.columns().forEach((col) => {
605
+ if (!col.filter) return;
606
+ const colState = state[col.field];
607
+ const rules = this.activeRules(col, colState);
608
+ if (rules.length === 0) return;
609
+ const field = this.filterFieldOf(col);
610
+ filtered = filtered.filter((item) => {
611
+ const cell = this.resolveField(item, field);
612
+ return colState.operator === "or" ? rules.some((r) => this.matchRule(col, cell, r)) : rules.every((r) => this.matchRule(col, cell, r));
613
+ });
614
+ });
615
+ this.filteredData.set(filtered);
616
+ this.localTotalRecords.set(filtered.length);
617
+ this.applySort();
618
+ this.updateDisplayedData();
619
+ }
620
+ onFiltersChanged() {
621
+ this.first.set(0);
622
+ if (this.serverSide()) this.filterSubject.next();
623
+ else this.applyFilters();
624
+ this.cdr.markForCheck();
625
+ }
626
+ updateDisplayedData() {
627
+ const filtered = this.filteredData();
628
+ const firstIndex = this.first();
629
+ const rows = this.rowsPerPageLocal();
630
+ this.displayedData.set(filtered.slice(firstIndex, firstIndex + rows));
631
+ }
632
+ getSelectionKey(row) {
633
+ const key = this.dataKey();
634
+ return key && row?.[key] !== void 0 ? row[key] : row;
635
+ }
636
+ canSelectRow(row) {
637
+ const predicate = this.isRowSelectable();
638
+ return predicate ? predicate(row) : true;
639
+ }
640
+ isRowSelected(row) {
641
+ return this.selectedKeys().has(this.getSelectionKey(row));
642
+ }
643
+ toggleRowSelection(row) {
644
+ if (!this.canSelectRow(row)) return;
645
+ const key = this.getSelectionKey(row);
646
+ if (this.isRowSelected(row)) this.selection.set(this.selection().filter((r) => this.getSelectionKey(r) !== key));
647
+ else this.selection.set([...this.selection(), row]);
648
+ }
649
+ onRowClick(event, row) {
650
+ if (!this.selectable() || !this.selectOnRowClick()) return;
651
+ if (event.target?.closest("button, a, input, select, textarea, label, [role=\"button\"], [data-shk-select]")) return;
652
+ this.toggleRowSelection(row);
653
+ }
654
+ toggleSelectAllPage() {
655
+ const pageRows = this.selectablePageRows();
656
+ const pageKeys = new Set(pageRows.map((row) => this.getSelectionKey(row)));
657
+ const rest = this.selection().filter((r) => !pageKeys.has(this.getSelectionKey(r)));
658
+ this.selection.set(this.allPageSelected() ? rest : [...rest, ...pageRows]);
659
+ }
660
+ clearSelection() {
661
+ this.selection.set([]);
662
+ }
663
+ runBulkAction(action) {
664
+ action.onClick([...this.selection()]);
665
+ }
666
+ isBulkActionDisabled(action) {
667
+ return action.isDisabled ? action.isDisabled(this.selection()) : false;
668
+ }
669
+ pruneSelection(data) {
670
+ const current = this.selection();
671
+ if (current.length === 0) return;
672
+ const byKey = new Map(data.map((row) => [this.getSelectionKey(row), row]));
673
+ const next = current.map((row) => byKey.get(this.getSelectionKey(row))).filter((row) => row !== void 0);
674
+ if (next.length !== current.length || next.some((row, i) => row !== current[i])) this.selection.set(next);
675
+ }
676
+ resizedWidth(col) {
677
+ const width = this.isResizable() ? this.columnWidths()[col.field] : void 0;
678
+ return width ? `${width}px` : null;
679
+ }
680
+ resizedWidthPx(col) {
681
+ return this.columnWidths()[col.field] ?? null;
682
+ }
683
+ onHeaderClick(col) {
684
+ if (this.suppressHeaderClick) return;
685
+ if (col.field !== "actions" && col.sortable) this.toggleSort(col.field);
686
+ }
687
+ startResize(event, col) {
688
+ if (event.button !== 0) return;
689
+ event.preventDefault();
690
+ event.stopPropagation();
691
+ const th = event.target.closest("th");
692
+ if (!th) return;
693
+ const startX = event.clientX;
694
+ const startWidth = th.getBoundingClientRect().width;
695
+ let moved = false;
696
+ this.resizingField.set(col.field);
697
+ const body = document.body;
698
+ const previousCursor = body.style.cursor;
699
+ const previousSelect = body.style.userSelect;
700
+ body.style.cursor = "col-resize";
701
+ body.style.userSelect = "none";
702
+ const onMove = (e) => {
703
+ const dx = e.clientX - startX;
704
+ if (Math.abs(dx) > 2) moved = true;
705
+ this.setColumnWidth(col, startWidth + dx, false);
706
+ };
707
+ const onUp = () => {
708
+ document.removeEventListener("pointermove", onMove);
709
+ document.removeEventListener("pointerup", onUp);
710
+ document.removeEventListener("pointercancel", onUp);
711
+ body.style.cursor = previousCursor;
712
+ body.style.userSelect = previousSelect;
713
+ this.resizingField.set(null);
714
+ if (moved) this.syncRenderedWidth(col, th);
715
+ if (moved) {
716
+ this.suppressHeaderClick = true;
717
+ setTimeout(() => this.suppressHeaderClick = false);
718
+ this.columnResize.emit({
719
+ field: col.field,
720
+ width: this.columnWidths()[col.field] ?? null
721
+ });
722
+ }
723
+ this.cdr.markForCheck();
724
+ };
725
+ document.addEventListener("pointermove", onMove);
726
+ document.addEventListener("pointerup", onUp);
727
+ document.addEventListener("pointercancel", onUp);
728
+ }
729
+ onResizerKeydown(event, col) {
730
+ if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") {
731
+ if (event.key === "Enter" || event.key === " ") event.stopPropagation();
732
+ return;
733
+ }
734
+ event.preventDefault();
735
+ event.stopPropagation();
736
+ const th = event.target.closest("th");
737
+ if (!th) return;
738
+ const step = event.shiftKey ? 50 : 10;
739
+ const base = this.columnWidths()[col.field] ?? th.getBoundingClientRect().width;
740
+ this.setColumnWidth(col, base + (event.key === "ArrowRight" ? step : -step), true);
741
+ this.syncRenderedWidth(col, th);
742
+ }
743
+ syncRenderedWidth(col, th) {
744
+ afterNextRender({ read: () => {
745
+ const rendered = Math.round(th.getBoundingClientRect().width);
746
+ if (rendered && this.columnWidths()[col.field] !== rendered) {
747
+ this.columnWidths.update((w) => ({
748
+ ...w,
749
+ [col.field]: rendered
750
+ }));
751
+ this.cdr.markForCheck();
752
+ }
753
+ } }, { injector: this.injector });
754
+ }
755
+ resetColumnWidths() {
756
+ this.columnWidths.set({});
757
+ }
758
+ storageFor(type) {
759
+ try {
760
+ return type === "session" ? window.sessionStorage : window.localStorage;
761
+ } catch {
762
+ return null;
763
+ }
764
+ }
765
+ readStoredWidths(key, type) {
766
+ try {
767
+ const raw = this.storageFor(type)?.getItem(`${key}:columnWidths`);
768
+ if (!raw) return null;
769
+ const parsed = JSON.parse(raw);
770
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
771
+ const widths = {};
772
+ Object.entries(parsed).forEach(([field, width]) => {
773
+ if (typeof width === "number" && isFinite(width) && width > 0) widths[field] = width;
774
+ });
775
+ return widths;
776
+ } catch {
777
+ return null;
778
+ }
779
+ }
780
+ writeStoredWidths(key, type, widths) {
781
+ try {
782
+ const storage = this.storageFor(type);
783
+ if (!storage) return;
784
+ if (Object.keys(widths).length === 0) storage.removeItem(`${key}:columnWidths`);
785
+ else storage.setItem(`${key}:columnWidths`, JSON.stringify(widths));
786
+ } catch {}
787
+ }
788
+ resetColumnWidth(col) {
789
+ const { [col.field]: _removed, ...rest } = this.columnWidths();
790
+ this.columnWidths.set(rest);
791
+ this.columnResize.emit({
792
+ field: col.field,
793
+ width: null
794
+ });
795
+ }
796
+ setColumnWidth(col, width, emit) {
797
+ const next = Math.max(this.MIN_COLUMN_WIDTH, Math.round(width));
798
+ this.columnWidths.update((w) => ({
799
+ ...w,
800
+ [col.field]: next
801
+ }));
802
+ if (emit) this.columnResize.emit({
803
+ field: col.field,
804
+ width: next
805
+ });
806
+ this.cdr.markForCheck();
807
+ }
808
+ onFilterClick(value) {
809
+ this.filterClick.emit(value);
810
+ }
811
+ toggleSort(field) {
812
+ if (this.sortField() === field) this.sortOrder.set(this.sortOrder() * -1);
813
+ else {
814
+ this.sortField.set(field);
815
+ this.sortOrder.set(1);
816
+ }
817
+ this.first.set(0);
818
+ if (!this.serverSide()) {
819
+ this.applySort();
820
+ this.updateDisplayedData();
821
+ }
822
+ }
823
+ applySort() {
824
+ const field = this.sortField();
825
+ const order = this.sortOrder();
826
+ if (!field) return;
827
+ const col = this.columns().find((c) => c.field === field);
828
+ const path = col ? this.filterFieldOf(col) : field;
829
+ const data = [...this.filteredData()];
830
+ data.sort((a, b) => {
831
+ const va = this.resolveField(a, path);
832
+ const vb = this.resolveField(b, path);
833
+ if (va == null && vb == null) return 0;
834
+ if (va == null) return 1;
835
+ if (vb == null) return -1;
836
+ if (typeof va === "string" && typeof vb === "string") return va.localeCompare(vb, void 0, {
837
+ numeric: true,
838
+ sensitivity: "base"
839
+ }) * order;
840
+ if (va < vb) return -1 * order;
841
+ if (va > vb) return 1 * order;
842
+ return 0;
843
+ });
844
+ this.filteredData.set(data);
845
+ }
846
+ onSearchInput(value) {
847
+ this.searchQuery.set(value);
848
+ this.first.set(0);
849
+ if (this.serverSide()) this.searchSubject.next(value);
850
+ }
851
+ hasFilterValue(field) {
852
+ const col = this.columns().find((c) => c.field === field);
853
+ if (!col) return false;
854
+ return this.activeRules(col, this.filterState()[field]).length > 0;
855
+ }
856
+ commitDraft(col) {
857
+ const draft = this.filterDraft();
858
+ if (!draft) return;
859
+ this.filterState.update((s) => ({
860
+ ...s,
861
+ [col.field]: this.cloneState(draft)
862
+ }));
863
+ this.onFiltersChanged();
864
+ }
865
+ setDraftOperator(operator) {
866
+ this.filterDraft.update((d) => d ? {
867
+ ...d,
868
+ operator
869
+ } : d);
870
+ }
871
+ setDraftMatchMode(col, index, matchMode) {
872
+ this.filterDraft.update((d) => d ? {
873
+ ...d,
874
+ rules: d.rules.map((r, i) => i === index ? {
875
+ ...r,
876
+ matchMode
877
+ } : r)
878
+ } : d);
879
+ }
880
+ setDraftValue(col, index, value) {
881
+ this.filterDraft.update((d) => d ? {
882
+ ...d,
883
+ rules: d.rules.map((r, i) => i === index ? {
884
+ ...r,
885
+ value
886
+ } : r)
887
+ } : d);
888
+ if (this.appliesImmediately(col)) this.commitDraft(col);
889
+ }
890
+ onRuleInput(col, index, raw) {
891
+ const kind = this.filterKind(col);
892
+ const value = kind === "numeric" ? this.numericValue(raw) : kind === "date" ? raw || null : raw;
893
+ this.setDraftValue(col, index, value);
894
+ }
895
+ numericValue(raw) {
896
+ return raw === "" || raw === null || isNaN(Number(raw)) ? null : Number(raw);
897
+ }
898
+ addRule(col) {
899
+ if (!this.canAddRule(col)) return;
900
+ this.filterDraft.update((d) => d ? {
901
+ ...d,
902
+ rules: [...d.rules, {
903
+ matchMode: this.defaultMatchMode(col),
904
+ value: null
905
+ }]
906
+ } : d);
907
+ }
908
+ removeRule(index) {
909
+ this.filterDraft.update((d) => d && d.rules.length > 1 ? {
910
+ ...d,
911
+ rules: d.rules.filter((_, i) => i !== index)
912
+ } : d);
913
+ }
914
+ applyFilter(col) {
915
+ this.commitDraft(col);
916
+ this.closeFilters();
917
+ }
918
+ clearFilter(field) {
919
+ const col = this.columns().find((c) => c.field === field);
920
+ if (!col) return;
921
+ this.filterState.update((s) => ({
922
+ ...s,
923
+ [field]: this.emptyFilterState(col)
924
+ }));
925
+ this.onFiltersChanged();
926
+ this.closeFilters();
927
+ }
928
+ isOptionSelected(value) {
929
+ const current = this.filterDraft()?.rules[0]?.value;
930
+ return Array.isArray(current) && current.some((v) => v == value);
931
+ }
932
+ toggleOption(col, value) {
933
+ const current = this.filterDraft()?.rules[0]?.value ?? [];
934
+ const next = current.some((v) => v == value) ? current.filter((v) => v != value) : [...current, value];
935
+ this.setDraftValue(col, 0, next.length ? next : null);
936
+ }
937
+ selectedOptionsLabel(col) {
938
+ const current = this.filterDraft()?.rules[0]?.value ?? [];
939
+ if (!current.length) return "";
940
+ const labels = (col.filterOptions ?? []).filter((o) => current.some((v) => v == o.value)).map((o) => o.label);
941
+ return labels.length > 2 ? this.filterLabel("selectedCount", { count: labels.length }) : labels.join(", ");
942
+ }
943
+ selectOption(col, value) {
944
+ const current = this.filterDraft()?.rules[0]?.value;
945
+ this.setDraftValue(col, 0, current != null && current == value ? null : value);
946
+ this.multiselectOpen.set(false);
947
+ }
948
+ selectedSingleLabel(col) {
949
+ const current = this.filterDraft()?.rules[0]?.value;
950
+ if (current === null || current === void 0) return "";
951
+ return (col.filterOptions ?? []).find((o) => o.value == current)?.label ?? String(current);
952
+ }
953
+ cycleBoolean(col) {
954
+ const current = this.filterDraft()?.rules[0]?.value;
955
+ const next = current === null || current === void 0 ? true : current === true ? false : null;
956
+ this.setDraftValue(col, 0, next);
957
+ }
958
+ rangeValue(col) {
959
+ const value = this.filterDraft()?.rules[0]?.value;
960
+ return Array.isArray(value) ? [value[0], value[1]] : this.rangeBounds(col);
961
+ }
962
+ onRangeInput(col, thumb, raw, commit) {
963
+ const [low, high] = this.rangeValue(col);
964
+ const n = Number(raw);
965
+ const next = thumb === 0 ? [Math.min(n, high), high] : [low, Math.max(n, low)];
966
+ this.filterDraft.update((d) => d ? {
967
+ ...d,
968
+ rules: d.rules.map((r, i) => i === 0 ? {
969
+ ...r,
970
+ value: next
971
+ } : r)
972
+ } : d);
973
+ if (commit) this.commitDraft(col);
974
+ }
975
+ rangePercent(col, value) {
976
+ const [min, max] = this.rangeBounds(col);
977
+ return max === min ? 0 : (value - min) / (max - min) * 100;
978
+ }
979
+ clearAll() {
980
+ const state = {};
981
+ this.columns().filter((c) => c.filter).forEach((col) => state[col.field] = this.emptyFilterState(col));
982
+ this.filterState.set(state);
983
+ this.closeFilters();
984
+ const hadSearch = !!this.searchQuery();
985
+ this.searchQuery.set("");
986
+ this.sortField.set(this.defaultSortField());
987
+ this.sortOrder.set(this.defaultSortOrder());
988
+ this.first.set(0);
989
+ if (this.serverSide()) {
990
+ this.emitFilterChange();
991
+ if (hadSearch) this.searchChange.emit("");
992
+ } else this.applyFilters();
993
+ this.cdr.markForCheck();
994
+ }
995
+ toggleFilter(col, event) {
996
+ const wasOpen = this.openFilterField() === col.field;
997
+ this.closeFilters();
998
+ if (wasOpen) return;
999
+ this.filterAnchor = event?.currentTarget ?? null;
1000
+ this.updateFilterPopupPosition();
1001
+ const applied = this.filterState()[col.field] ?? this.emptyFilterState(col);
1002
+ this.filterDraft.set(this.cloneState(applied));
1003
+ this.multiselectOpen.set(false);
1004
+ this.openFilterField.set(col.field);
1005
+ const reposition = () => this.updateFilterPopupPosition();
1006
+ window.addEventListener("scroll", reposition, true);
1007
+ window.addEventListener("resize", reposition);
1008
+ this.filterListenersCleanup = () => {
1009
+ window.removeEventListener("scroll", reposition, true);
1010
+ window.removeEventListener("resize", reposition);
1011
+ };
1012
+ setTimeout(() => document.querySelector(`#${this.uid}-filter-${this.safeId(col.field)}-0`)?.focus());
1013
+ this.cdr.markForCheck();
1014
+ }
1015
+ safeId(field) {
1016
+ return field.replace(/[^a-zA-Z0-9_-]/g, "_");
1017
+ }
1018
+ closeFilters() {
1019
+ this.filterListenersCleanup?.();
1020
+ this.filterListenersCleanup = null;
1021
+ this.filterAnchor = null;
1022
+ if (this.openFilterField() !== null) {
1023
+ this.openFilterField.set(null);
1024
+ this.filterDraft.set(null);
1025
+ this.cdr.markForCheck();
1026
+ }
1027
+ }
1028
+ updateFilterPopupPosition() {
1029
+ if (!this.filterAnchor) return;
1030
+ const rect = this.filterAnchor.getBoundingClientRect();
1031
+ const maxLeft = window.innerWidth - this.FILTER_POPUP_WIDTH - 8;
1032
+ const left = Math.max(8, Math.min(rect.left, maxLeft));
1033
+ const top = rect.bottom + 6;
1034
+ this.filterPopupPosition.set({
1035
+ top,
1036
+ left,
1037
+ maxHeight: Math.max(200, window.innerHeight - top - 12)
1038
+ });
1039
+ }
1040
+ getPageReport() {
1041
+ return this.pageReport();
1042
+ }
1043
+ goToPage(page) {
1044
+ const rows = this.rowsPerPageLocal();
1045
+ const total = this.effectiveTotalRecords();
1046
+ const pageCount = Math.max(1, Math.ceil(total / rows));
1047
+ const target = Math.min(Math.max(0, page), pageCount - 1);
1048
+ const first = target * rows;
1049
+ this.first.set(first);
1050
+ if (this.serverSide()) this.pageChange.emit({
1051
+ first,
1052
+ rows,
1053
+ page: target,
1054
+ pageCount: Math.ceil(total / rows)
1055
+ });
1056
+ else this.updateDisplayedData();
1057
+ }
1058
+ goToFirst() {
1059
+ this.goToPage(0);
1060
+ }
1061
+ goToLast() {
1062
+ this.goToPage(this.totalPages() - 1);
1063
+ }
1064
+ onRowsPerPageChange(rows) {
1065
+ rows = Number(rows);
1066
+ this.rowsPerPageLocal.set(rows);
1067
+ this.goToPage(0);
1068
+ }
1069
+ refreshData() {
1070
+ this.refresh.emit();
1071
+ }
1072
+ isFirstPage() {
1073
+ return this.first() === 0;
1074
+ }
1075
+ isLastPage() {
1076
+ return this.first() + this.rowsPerPageLocal() >= this.effectiveTotalRecords();
1077
+ }
1078
+ next() {
1079
+ this.goToPage(this.currentPage());
1080
+ }
1081
+ prev() {
1082
+ this.goToPage(this.currentPage() - 2);
1083
+ }
1084
+ reset() {
1085
+ this.goToFirst();
1086
+ }
1087
+ formatDateCell(value, col) {
1088
+ const locale = this.config.get("dates.locale")();
1089
+ const named = col.dateFormat && NAMED_DATE_STYLES[col.dateFormat];
1090
+ if (named) return formatDateStyle(value, named[0], locale, named[1]);
1091
+ const pattern = resolveDateFormat(col.dateFormat || this.config.get("dates.format")(), locale);
1092
+ return formatDate(value, pattern, locale);
1093
+ }
1094
+ formatCurrencyCell(value, col) {
1095
+ return formatCurrency(value, col.currency || this.config.get("numbers.currency")(), this.config.get("numbers.locale")(), this.config.get("numbers.decimals")());
1096
+ }
1097
+ getRowActionLabel(action, rowData) {
1098
+ return typeof action.label === "function" ? action.label(rowData) : action.label;
1099
+ }
1100
+ getRowActionIconName(action, rowData) {
1101
+ const icon = action.icon;
1102
+ return isIconResolver(icon) ? icon(rowData) : icon;
1103
+ }
1104
+ getRowActionClass(action, rowData) {
1105
+ if (!action.class) return "";
1106
+ return typeof action.class === "function" ? action.class(rowData) : action.class;
1107
+ }
1108
+ isHeaderActionDisabled(action) {
1109
+ return action.isDisabled ? action.isDisabled() : false;
1110
+ }
1111
+ isHeaderActionVisible(action) {
1112
+ return action.isVisible ? action.isVisible() : true;
1113
+ }
1114
+ isRowActionDisabled(action, rowData) {
1115
+ return action.isDisabled ? action.isDisabled(rowData) : false;
1116
+ }
1117
+ isRowActionVisible(action, rowData) {
1118
+ return action.isVisible ? action.isVisible(rowData) : true;
1119
+ }
1120
+ truncate(value, limit = 30) {
1121
+ if (value === null || value === void 0) return "";
1122
+ const str = String(value);
1123
+ return str.length > limit ? str.slice(0, limit) + "…" : str;
1124
+ }
1125
+ getProgress(col, rowData) {
1126
+ const n = Number(this.resolveField(rowData, col.field));
1127
+ return isNaN(n) ? 0 : Math.max(0, Math.min(100, n));
1128
+ }
1129
+ getTagValue(col, rowData) {
1130
+ return col.tagValue ? col.tagValue(rowData) : String(this.resolveField(rowData, col.field) ?? "");
1131
+ }
1132
+ getTagSeverity(col, rowData) {
1133
+ const raw = col.tagSeverity ? col.tagSeverity(rowData) : "secondary";
1134
+ return [
1135
+ "secondary",
1136
+ "success",
1137
+ "info",
1138
+ "warning",
1139
+ "danger",
1140
+ "contrast"
1141
+ ].includes(raw) ? raw : "secondary";
1142
+ }
1143
+ getTagRounded(col, rowData) {
1144
+ if (typeof col.tagRounded === "function") return col.tagRounded(rowData);
1145
+ return col.tagRounded ?? false;
1146
+ }
1147
+ getTagIcon(col, rowData) {
1148
+ if (typeof col.tagIcon === "function") return col.tagIcon(rowData);
1149
+ return col.tagIcon ?? "";
1150
+ }
1151
+ getTagStyle(col, rowData) {
1152
+ return col.tagStyle ? col.tagStyle(rowData) || {} : {};
1153
+ }
1154
+ trackByRow(row, index) {
1155
+ return row?.id ?? row?._id ?? index;
1156
+ }
1157
+ onHeaderKeydown(event, col) {
1158
+ if (col.field === "actions" || !col.sortable) return;
1159
+ if (event.target !== event.currentTarget) return;
1160
+ if (event.key === "Enter" || event.key === " ") {
1161
+ event.preventDefault();
1162
+ this.toggleSort(col.field);
1163
+ }
1164
+ }
1165
+ getAriaSort(col) {
1166
+ if (col.field === "actions" || !col.sortable) return "none";
1167
+ if (this.sortField() !== col.field) return "none";
1168
+ return this.sortOrder() === 1 ? "ascending" : "descending";
1169
+ }
1170
+ getVisibleRowActions(rowData) {
1171
+ return this.rowActions().filter((a) => this.isRowActionVisible(a, rowData)).slice(0, this.MAX_VISIBLE_ACTIONS);
1172
+ }
1173
+ getHiddenRowActions(rowData) {
1174
+ return this.rowActions().filter((a) => this.isRowActionVisible(a, rowData)).slice(this.MAX_VISIBLE_ACTIONS);
1175
+ }
1176
+ toggleActionsDropdown(rowData, event) {
1177
+ const key = this.getRowKey(rowData);
1178
+ const wasOpen = !!this.actionsDropdownOpen()[key];
1179
+ const next = {};
1180
+ if (!wasOpen) next[key] = true;
1181
+ this.actionsDropdownOpen.set(next);
1182
+ if (!wasOpen) this.computeDropdownPosition(event);
1183
+ }
1184
+ computeDropdownPosition(event) {
1185
+ if (!event) return;
1186
+ const rect = (event.currentTarget || event.target).getBoundingClientRect();
1187
+ const dropdownHeight = 180;
1188
+ const spaceBelow = window.innerHeight - rect.bottom;
1189
+ let top = rect.bottom + 4;
1190
+ let left = rect.right - 160;
1191
+ if (spaceBelow < dropdownHeight) top = rect.top - dropdownHeight - 4;
1192
+ if (left < 8) left = 8;
1193
+ this.dropdownPosition.set({
1194
+ top,
1195
+ left
1196
+ });
1197
+ }
1198
+ isActionsDropdownOpen(rowData) {
1199
+ const key = this.getRowKey(rowData);
1200
+ return !!this.actionsDropdownOpen()[key];
1201
+ }
1202
+ getRowKey(rowData) {
1203
+ return String(rowData?.id ?? rowData?._id ?? JSON.stringify(rowData));
1204
+ }
1205
+ onDocumentClick() {
1206
+ const current = this.actionsDropdownOpen();
1207
+ if (Object.values(current).some((v) => v)) this.actionsDropdownOpen.set({});
1208
+ this.closeFilters();
1209
+ }
1210
+ onEscape() {
1211
+ this.closeFilters();
1212
+ }
1213
+ static {
1214
+ this.ɵfac = i0.ɵɵngDeclareFactory({
1215
+ minVersion: "12.0.0",
1216
+ version: "22.3.2",
1217
+ ngImport: i0,
1218
+ type: TableComponent,
1219
+ deps: [],
1220
+ target: i0.ɵɵFactoryTarget.Component
1221
+ });
1222
+ }
1223
+ static {
1224
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
1225
+ minVersion: "17.0.0",
1226
+ version: "22.3.2",
1227
+ type: TableComponent,
1228
+ isStandalone: true,
1229
+ selector: "shk-table",
1230
+ inputs: {
1231
+ data: {
1232
+ classPropertyName: "data",
1233
+ publicName: "data",
1234
+ isSignal: true,
1235
+ isRequired: false,
1236
+ transformFunction: null
1237
+ },
1238
+ columns: {
1239
+ classPropertyName: "columns",
1240
+ publicName: "columns",
1241
+ isSignal: true,
1242
+ isRequired: false,
1243
+ transformFunction: null
1244
+ },
1245
+ rowsPerPage: {
1246
+ classPropertyName: "rowsPerPage",
1247
+ publicName: "rowsPerPage",
1248
+ isSignal: true,
1249
+ isRequired: false,
1250
+ transformFunction: null
1251
+ },
1252
+ rowsPerPageOptions: {
1253
+ classPropertyName: "rowsPerPageOptions",
1254
+ publicName: "rowsPerPageOptions",
1255
+ isSignal: true,
1256
+ isRequired: false,
1257
+ transformFunction: null
1258
+ },
1259
+ loading: {
1260
+ classPropertyName: "loading",
1261
+ publicName: "loading",
1262
+ isSignal: true,
1263
+ isRequired: false,
1264
+ transformFunction: null
1265
+ },
1266
+ showActionRow: {
1267
+ classPropertyName: "showActionRow",
1268
+ publicName: "showActionRow",
1269
+ isSignal: true,
1270
+ isRequired: false,
1271
+ transformFunction: null
1272
+ },
1273
+ customTemplates: {
1274
+ classPropertyName: "customTemplates",
1275
+ publicName: "customTemplates",
1276
+ isSignal: true,
1277
+ isRequired: false,
1278
+ transformFunction: null
1279
+ },
1280
+ headerActions: {
1281
+ classPropertyName: "headerActions",
1282
+ publicName: "headerActions",
1283
+ isSignal: true,
1284
+ isRequired: false,
1285
+ transformFunction: null
1286
+ },
1287
+ rowActions: {
1288
+ classPropertyName: "rowActions",
1289
+ publicName: "rowActions",
1290
+ isSignal: true,
1291
+ isRequired: false,
1292
+ transformFunction: null
1293
+ },
1294
+ hasShadow: {
1295
+ classPropertyName: "hasShadow",
1296
+ publicName: "hasShadow",
1297
+ isSignal: true,
1298
+ isRequired: false,
1299
+ transformFunction: null
1300
+ },
1301
+ defaultSortField: {
1302
+ classPropertyName: "defaultSortField",
1303
+ publicName: "defaultSortField",
1304
+ isSignal: true,
1305
+ isRequired: false,
1306
+ transformFunction: null
1307
+ },
1308
+ defaultSortOrder: {
1309
+ classPropertyName: "defaultSortOrder",
1310
+ publicName: "defaultSortOrder",
1311
+ isSignal: true,
1312
+ isRequired: false,
1313
+ transformFunction: null
1314
+ },
1315
+ showSearch: {
1316
+ classPropertyName: "showSearch",
1317
+ publicName: "showSearch",
1318
+ isSignal: true,
1319
+ isRequired: false,
1320
+ transformFunction: null
1321
+ },
1322
+ searchPlaceholder: {
1323
+ classPropertyName: "searchPlaceholder",
1324
+ publicName: "searchPlaceholder",
1325
+ isSignal: true,
1326
+ isRequired: false,
1327
+ transformFunction: null
1328
+ },
1329
+ globalFilterFields: {
1330
+ classPropertyName: "globalFilterFields",
1331
+ publicName: "globalFilterFields",
1332
+ isSignal: true,
1333
+ isRequired: false,
1334
+ transformFunction: null
1335
+ },
1336
+ emptyMessage: {
1337
+ classPropertyName: "emptyMessage",
1338
+ publicName: "emptyMessage",
1339
+ isSignal: true,
1340
+ isRequired: false,
1341
+ transformFunction: null
1342
+ },
1343
+ serverSide: {
1344
+ classPropertyName: "serverSide",
1345
+ publicName: "serverSide",
1346
+ isSignal: true,
1347
+ isRequired: false,
1348
+ transformFunction: null
1349
+ },
1350
+ totalRecords: {
1351
+ classPropertyName: "totalRecords",
1352
+ publicName: "totalRecords",
1353
+ isSignal: true,
1354
+ isRequired: false,
1355
+ transformFunction: null
1356
+ },
1357
+ filters: {
1358
+ classPropertyName: "filters",
1359
+ publicName: "filters",
1360
+ isSignal: true,
1361
+ isRequired: false,
1362
+ transformFunction: null
1363
+ },
1364
+ activeFilter: {
1365
+ classPropertyName: "activeFilter",
1366
+ publicName: "activeFilter",
1367
+ isSignal: true,
1368
+ isRequired: false,
1369
+ transformFunction: null
1370
+ },
1371
+ showGridlines: {
1372
+ classPropertyName: "showGridlines",
1373
+ publicName: "showGridlines",
1374
+ isSignal: true,
1375
+ isRequired: false,
1376
+ transformFunction: null
1377
+ },
1378
+ resizableColumns: {
1379
+ classPropertyName: "resizableColumns",
1380
+ publicName: "resizableColumns",
1381
+ isSignal: true,
1382
+ isRequired: false,
1383
+ transformFunction: null
1384
+ },
1385
+ rowValidations: {
1386
+ classPropertyName: "rowValidations",
1387
+ publicName: "rowValidations",
1388
+ isSignal: true,
1389
+ isRequired: false,
1390
+ transformFunction: null
1391
+ },
1392
+ columnWidths: {
1393
+ classPropertyName: "columnWidths",
1394
+ publicName: "columnWidths",
1395
+ isSignal: true,
1396
+ isRequired: false,
1397
+ transformFunction: null
1398
+ },
1399
+ stateKey: {
1400
+ classPropertyName: "stateKey",
1401
+ publicName: "stateKey",
1402
+ isSignal: true,
1403
+ isRequired: false,
1404
+ transformFunction: null
1405
+ },
1406
+ stateStorage: {
1407
+ classPropertyName: "stateStorage",
1408
+ publicName: "stateStorage",
1409
+ isSignal: true,
1410
+ isRequired: false,
1411
+ transformFunction: null
1412
+ },
1413
+ rowHover: {
1414
+ classPropertyName: "rowHover",
1415
+ publicName: "rowHover",
1416
+ isSignal: true,
1417
+ isRequired: false,
1418
+ transformFunction: null
1419
+ },
1420
+ showClearButton: {
1421
+ classPropertyName: "showClearButton",
1422
+ publicName: "showClearButton",
1423
+ isSignal: true,
1424
+ isRequired: false,
1425
+ transformFunction: null
1426
+ },
1427
+ showPageReport: {
1428
+ classPropertyName: "showPageReport",
1429
+ publicName: "showPageReport",
1430
+ isSignal: true,
1431
+ isRequired: false,
1432
+ transformFunction: null
1433
+ },
1434
+ showRowsPerPage: {
1435
+ classPropertyName: "showRowsPerPage",
1436
+ publicName: "showRowsPerPage",
1437
+ isSignal: true,
1438
+ isRequired: false,
1439
+ transformFunction: null
1440
+ },
1441
+ selectable: {
1442
+ classPropertyName: "selectable",
1443
+ publicName: "selectable",
1444
+ isSignal: true,
1445
+ isRequired: false,
1446
+ transformFunction: null
1447
+ },
1448
+ dataKey: {
1449
+ classPropertyName: "dataKey",
1450
+ publicName: "dataKey",
1451
+ isSignal: true,
1452
+ isRequired: false,
1453
+ transformFunction: null
1454
+ },
1455
+ isRowSelectable: {
1456
+ classPropertyName: "isRowSelectable",
1457
+ publicName: "isRowSelectable",
1458
+ isSignal: true,
1459
+ isRequired: false,
1460
+ transformFunction: null
1461
+ },
1462
+ selectOnRowClick: {
1463
+ classPropertyName: "selectOnRowClick",
1464
+ publicName: "selectOnRowClick",
1465
+ isSignal: true,
1466
+ isRequired: false,
1467
+ transformFunction: null
1468
+ },
1469
+ bulkActions: {
1470
+ classPropertyName: "bulkActions",
1471
+ publicName: "bulkActions",
1472
+ isSignal: true,
1473
+ isRequired: false,
1474
+ transformFunction: null
1475
+ },
1476
+ selection: {
1477
+ classPropertyName: "selection",
1478
+ publicName: "selection",
1479
+ isSignal: true,
1480
+ isRequired: false,
1481
+ transformFunction: null
1482
+ }
1483
+ },
1484
+ outputs: {
1485
+ columnWidths: "columnWidthsChange",
1486
+ selection: "selectionChange",
1487
+ refresh: "refresh",
1488
+ pageChange: "pageChange",
1489
+ filterChange: "filterChange",
1490
+ searchChange: "searchChange",
1491
+ filterClick: "filterClick",
1492
+ columnResize: "columnResize"
1493
+ },
1494
+ host: { listeners: {
1495
+ "document:click": "onDocumentClick()",
1496
+ "document:keydown.escape": "onEscape()"
1497
+ } },
1498
+ ngImport: i0,
1499
+ template: "<div class=\"space-y-2 min-[1440px]:space-y-3 mt-2 min-[1440px]:mt-3 animate-fade-in pb-8\">\n @if (\n showSearch() ||\n (showClearButton() && hasFilterableColumns()) ||\n filters().length > 0 ||\n headerActions().length > 0 ||\n (selectable() && bulkActions().length > 0 && selection().length > 0)\n ) {\n <div class=\"card p-2 min-[1440px]:p-2.5 flex flex-row items-center justify-between gap-2\">\n <div class=\"flex items-center gap-2 min-[1440px]:gap-3 flex-1 min-w-0\">\n @if (showSearch()) {\n <div class=\"relative w-full md:w-52 min-[1440px]:w-56\">\n <label [for]=\"uid + '-search'\" class=\"sr-only\">{{\n searchPlaceholder() || ('common.search_placeholder' | transloco)\n }}</label>\n <div class=\"absolute inset-y-0 left-0 pl-2.5 flex items-center pointer-events-none\">\n <svg\n [shkIcon]=\"getIcon('search')\"\n class=\"w-3.5 h-3.5 _shk-text-surface-400\"\n ></svg>\n </div>\n <input\n [id]=\"uid + '-search'\"\n type=\"text\"\n [value]=\"searchQuery()\"\n (input)=\"onSearchInput($any($event.target).value)\"\n [placeholder]=\"searchPlaceholder() || ('common.search_placeholder' | transloco)\"\n class=\"block w-full pl-8 pr-3 py-1.5 text-xs border _shk-border rounded-md leading-5 _shk-bg-surface-50 placeholder:[color:var(--shk-surface-400)] dark:placeholder:[color:var(--shk-surface-500)] _shk-text-surface-700 focus:outline-none focus:bg-white dark:focus:[background-color:var(--shk-surface-100)] focus:[border-color:var(--shk-primary-500)] focus:ring-1 focus:[--tw-ring-color:var(--shk-primary-500)]\"\n />\n </div>\n }\n @if (showClearButton() && (hasFilterableColumns() || showSearch())) {\n <shk-tooltip [text]=\"tr('table.clearFilters', 'Limpiar búsqueda, filtros y orden')\">\n <button\n type=\"button\"\n (click)=\"clearAll()\"\n [disabled]=\"!hasActiveFilters()\"\n class=\"inline-flex items-center gap-1.5 px-2.5 py-1.5 text-xs font-medium rounded-md border _shk-border _shk-text-surface-600 hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] transition-colors disabled:opacity-40 disabled:cursor-not-allowed whitespace-nowrap\"\n >\n <svg [shkIcon]=\"icons.clear\" class=\"w-3.5 h-3.5\"></svg>\n {{ tr('table.clear', 'Limpiar') }}\n </button>\n </shk-tooltip>\n }\n @if (filters().length > 0) {\n <div\n class=\"flex _shk-bg-surface-100 p-0.5 rounded-md ml-auto\"\n role=\"group\"\n >\n @for (f of filters(); track f.value) {\n <button\n type=\"button\"\n (click)=\"onFilterClick(f.value)\"\n [attr.aria-pressed]=\"f.value === activeFilter()\"\n class=\"px-2.5 min-[1440px]:px-3 py-1 text-xs font-medium rounded _shk-text-surface-700 transition-all\"\n [class]=\"\n f.value === activeFilter()\n ? 'bg-white shadow-sm dark:[background-color:var(--shk-surface-700)]'\n : ''\n \"\n >\n {{ f.label }}\n </button>\n }\n </div>\n }\n </div>\n @if (selectable() && selection().length > 0 && bulkActions().length > 0) {\n <div\n class=\"flex items-center gap-1.5 shrink-0\"\n role=\"toolbar\"\n [attr.aria-label]=\"'table.selected' | transloco: { count: selection().length }\"\n >\n <span\n class=\"text-xs font-medium _shk-text-surface-600 whitespace-nowrap\"\n aria-live=\"polite\"\n >{{ 'table.selected' | transloco: { count: selection().length } }}</span\n >\n <button\n type=\"button\"\n (click)=\"clearSelection()\"\n [attr.aria-label]=\"'table.clearSelection' | transloco\"\n class=\"table-action-btn rounded-md _shk-text-surface-500 hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)]\"\n >\n <svg [shkIcon]=\"getIcon('x')\" class=\"w-3.5 h-3.5\"></svg>\n </button>\n @for (action of visibleBulkActions(); track $index) {\n <button\n type=\"button\"\n [class]=\"\n 'inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-md _shk-bg-primary text-white hover:[background-color:var(--shk-primary-700)] transition-colors disabled:opacity-50 disabled:cursor-not-allowed ' +\n (action.class || '')\n \"\n [disabled]=\"isBulkActionDisabled(action)\"\n [attr.aria-label]=\"action.label\"\n (click)=\"runBulkAction(action)\"\n >\n @if (action.icon) {\n <svg [shkIcon]=\"getIcon(action.icon)\" class=\"w-3.5 h-3.5\"></svg>\n }\n {{ action.label }}\n </button>\n }\n </div>\n }\n @if (headerActions().length > 0) {\n <div class=\"flex items-center gap-1.5 shrink-0\">\n @for (action of headerActions(); track $index) {\n @if (isHeaderActionVisible(action)) {\n <button\n type=\"button\"\n [class]=\"\n 'inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-md _shk-bg-primary text-white hover:[background-color:var(--shk-primary-700)] transition-colors disabled:opacity-50 disabled:cursor-not-allowed ' +\n (action.class || '')\n \"\n [disabled]=\"isHeaderActionDisabled(action)\"\n [attr.aria-label]=\"action.label\"\n (click)=\"action.onClick()\"\n >\n @if (action.icon) {\n <svg [shkIcon]=\"getIcon(action.icon)\" class=\"w-3.5 h-3.5\"></svg>\n }\n {{ action.label }}\n </button>\n }\n }\n </div>\n }\n </div>\n }\n <div class=\"card p-0 overflow-hidden table-card\" [class.shadow-lg]=\"hasShadow()\">\n <div class=\"table-scroll-wrapper _shk-scrollbar\">\n <table\n class=\"shk-data-table\"\n [class.shk-gridlines]=\"showGridlines()\"\n [class.shk-row-hover]=\"rowHover()\"\n >\n <thead>\n <tr>\n @if (selectable()) {\n <th\n scope=\"col\"\n data-shk-select\n class=\"w-10 px-2 min-[1440px]:px-3 py-2 min-[1440px]:py-2.5 text-center _shk-bg-surface-50 border-b _shk-border\"\n >\n <input\n type=\"checkbox\"\n class=\"shk-table-checkbox\"\n [checked]=\"allPageSelected()\"\n [indeterminate]=\"somePageSelected()\"\n [disabled]=\"loading() || selectablePageRows().length === 0\"\n (change)=\"toggleSelectAllPage()\"\n [attr.aria-label]=\"'table.selectAll' | transloco\"\n />\n </th>\n }\n @for (col of columnsWithActions(); track col.field) {\n <th\n scope=\"col\"\n (click)=\"onHeaderClick(col)\"\n (keydown)=\"onHeaderKeydown($event, col)\"\n [tabindex]=\"col.field !== 'actions' && col.sortable ? 0 : -1\"\n [attr.role]=\"col.field !== 'actions' && col.sortable ? 'button' : null\"\n [attr.aria-sort]=\"getAriaSort(col)\"\n [attr.data-shk-actions]=\"col.field === 'actions' ? '' : null\"\n [style.cursor]=\"col.field !== 'actions' && col.sortable ? 'pointer' : 'default'\"\n [style.width]=\"resizedWidth(col) || (col.field === 'actions' ? col.width : null)\"\n [style.min-width]=\"resizedWidth(col) || (col.field === 'actions' ? col.width : col.minWidth) || null\"\n [style.--shk-col-width]=\"col.field !== 'actions' ? getColumnWidth(col) : null\"\n class=\"relative px-2 min-[1440px]:px-3 py-2 min-[1440px]:py-2.5 text-left text-[10px] min-[1440px]:text-xs font-bold _shk-text-surface-500 uppercase tracking-wider _shk-bg-surface-50 border-b _shk-border focus:outline-none focus-visible:ring-1 focus-visible:[--tw-ring-color:var(--shk-primary-500)]\"\n >\n @if (col.field !== 'actions') {\n <div class=\"flex items-center justify-between gap-2\">\n <span>{{ col.header }}</span>\n <div class=\"flex items-center gap-1 shrink-0\">\n @if (col.sortable) {\n <shk-tooltip [text]=\"'table.tooltips.sort' | transloco\">\n @if (sortField() === col.field) {\n <svg\n [shkIcon]=\"getIcon(sortOrder() === 1 ? 'arrow-up' : 'arrow-down')\"\n class=\"w-3.5 h-3.5 _shk-text-primary\"\n ></svg>\n } @else {\n <svg\n [shkIcon]=\"getIcon('arrow-up-down')\"\n class=\"w-3.5 h-3.5 _shk-text-surface-400\"\n ></svg>\n }\n </shk-tooltip>\n }\n @if (col.filter) {\n <shk-tooltip [text]=\"'table.tooltips.filter' | transloco\">\n <button\n type=\"button\"\n (click)=\"$event.stopPropagation(); toggleFilter(col, $event)\"\n [attr.aria-label]=\"('table.tooltips.filter' | transloco) + ': ' + col.header\"\n [attr.aria-expanded]=\"openFilterField() === col.field\"\n aria-haspopup=\"dialog\"\n class=\"_shk-text-surface-400 hover:[color:var(--shk-surface-600)] dark:hover:[color:var(--shk-surface-300)] transition-colors\"\n >\n <svg\n [shkIcon]=\"getIcon('filter')\"\n class=\"w-3.5 h-3.5\"\n [class._shk-text-primary]=\"hasFilterValue(col.field) || openFilterField() === col.field\"\n ></svg>\n </button>\n </shk-tooltip>\n }\n </div>\n </div>\n\n\n <!-- Column filter menu -->\n @if (col.filter && openFilterField() === col.field && filterDraft(); as draft) {\n <div\n shkPortal\n class=\"shk-filter-overlay fixed z-[9999] w-[240px] overflow-y-auto normal-case tracking-normal font-normal text-xs _shk-text-surface-700 bg-white dark:[background-color:var(--shk-surface-100)] border _shk-border rounded-lg shadow-lg\"\n role=\"dialog\"\n [attr.aria-label]=\"('table.tooltips.filter' | transloco) + ': ' + col.header\"\n [style.top.px]=\"filterPopupPosition().top\"\n [style.left.px]=\"filterPopupPosition().left\"\n [style.max-height.px]=\"filterPopupPosition().maxHeight\"\n (click)=\"$event.stopPropagation()\"\n (keydown)=\"$event.stopPropagation()\"\n (keydown.escape)=\"closeFilters()\"\n >\n @if (col.filterMenuTitle) {\n <div class=\"px-2 pt-2 font-semibold _shk-text-surface-800\">\n {{ col.filterMenuTitle }}\n </div>\n }\n @if (showOperatorFor(col)) {\n <div class=\"p-2 border-b _shk-border\">\n <select\n class=\"shk-filter-select\"\n [attr.aria-label]=\"filterLabel('matchAll') + ' / ' + filterLabel('matchAny')\"\n (change)=\"setDraftOperator($any($event.target).value)\"\n >\n <option value=\"and\" [selected]=\"draft.operator === 'and'\">\n {{ filterLabel('matchAll') }}\n </option>\n <option value=\"or\" [selected]=\"draft.operator === 'or'\">\n {{ filterLabel('matchAny') }}\n </option>\n </select>\n </div>\n }\n\n @switch (filterKind(col)) {\n @case ('select') {\n <ng-container\n *ngTemplateOutlet=\"optionList; context: { $implicit: col, draft: draft, multiple: false }\"\n ></ng-container>\n }\n @case ('multiselect') {\n <ng-container\n *ngTemplateOutlet=\"optionList; context: { $implicit: col, draft: draft, multiple: true }\"\n ></ng-container>\n }\n @case ('boolean') {\n @let boolValue = draft.rules[0].value;\n <div class=\"p-2\">\n <button\n type=\"button\"\n role=\"checkbox\"\n [id]=\"uid + '-filter-' + safeId(col.field) + '-0'\"\n class=\"inline-flex items-center gap-2 rounded-md focus:outline-none focus-visible:ring-1 focus-visible:[--tw-ring-color:var(--shk-primary-500)]\"\n [attr.aria-checked]=\"\n boolValue === true ? 'true' : boolValue === false ? 'false' : 'mixed'\n \"\n (click)=\"cycleBoolean(col)\"\n >\n <span\n class=\"shk-checkbox-box\"\n [class.shk-checked]=\"boolValue === true || boolValue === false\"\n >\n @if (boolValue === true) {\n <svg [shkIcon]=\"getIcon('check')\"></svg>\n } @else if (boolValue === false) {\n <svg [shkIcon]=\"getIcon('x')\"></svg>\n }\n </span>\n <span>{{\n boolValue === true\n ? filterLabel('yes')\n : boolValue === false\n ? filterLabel('no')\n : filterLabel('any')\n }}</span>\n </button>\n </div>\n }\n @case ('range') {\n @let rv = rangeValue(col);\n @let bounds = rangeBounds(col);\n <div class=\"p-2\">\n <div class=\"shk-range\">\n <div class=\"shk-range-track\"></div>\n <div\n class=\"shk-range-fill\"\n [style.left.%]=\"rangePercent(col, rv[0])\"\n [style.width.%]=\"rangePercent(col, rv[1]) - rangePercent(col, rv[0])\"\n ></div>\n <input\n type=\"range\"\n [id]=\"uid + '-filter-' + safeId(col.field) + '-0'\"\n [min]=\"bounds[0]\"\n [max]=\"bounds[1]\"\n [step]=\"col.filterStep || 1\"\n [value]=\"rv[0]\"\n [style.z-index]=\"rv[0] >= bounds[1] ? 3 : null\"\n [attr.aria-label]=\"col.header + ' min'\"\n (input)=\"onRangeInput(col, 0, $any($event.target).value, false)\"\n (change)=\"onRangeInput(col, 0, $any($event.target).value, true)\"\n />\n <input\n type=\"range\"\n [min]=\"bounds[0]\"\n [max]=\"bounds[1]\"\n [step]=\"col.filterStep || 1\"\n [value]=\"rv[1]\"\n [attr.aria-label]=\"col.header + ' max'\"\n (input)=\"onRangeInput(col, 1, $any($event.target).value, false)\"\n (change)=\"onRangeInput(col, 1, $any($event.target).value, true)\"\n />\n </div>\n <div class=\"flex items-center justify-between px-0.5 _shk-text-surface-500\">\n <span>{{ rv[0] }}</span>\n <span>{{ rv[1] }}</span>\n </div>\n </div>\n }\n @default {\n <!-- text / numeric / date: one block per rule -->\n @for (rule of draft.rules; track $index; let i = $index) {\n <div\n class=\"flex flex-col gap-1.5 p-2\"\n [class.border-b]=\"i < draft.rules.length - 1\"\n [class._shk-border]=\"i < draft.rules.length - 1\"\n >\n @if (showMatchModesFor(col)) {\n <select\n class=\"shk-filter-select\"\n [attr.aria-label]=\"col.header\"\n (change)=\"setDraftMatchMode(col, i, $any($event.target).value)\"\n >\n @for (mode of matchModesFor(col); track mode) {\n <option [value]=\"mode\" [selected]=\"mode === rule.matchMode\">\n {{ matchModeLabel(mode) }}\n </option>\n }\n </select>\n }\n <input\n [id]=\"uid + '-filter-' + safeId(col.field) + '-' + i\"\n [type]=\"filterKind(col) === 'numeric' ? 'number' : filterKind(col) === 'date' ? 'date' : 'text'\"\n [attr.step]=\"filterKind(col) === 'numeric' ? 'any' : null\"\n class=\"shk-filter-input\"\n [value]=\"rule.value ?? ''\"\n [placeholder]=\"col.filterPlaceholder || ('common.search_placeholder' | transloco)\"\n [attr.aria-label]=\"col.header\"\n (input)=\"onRuleInput(col, i, $any($event.target).value)\"\n (keydown.enter)=\"applyFilter(col)\"\n />\n @if (draft.rules.length > 1) {\n <button\n type=\"button\"\n class=\"inline-flex items-center justify-center gap-1 py-1 rounded-md [color:var(--shk-error-600)] hover:[background-color:var(--shk-error-50)] transition-colors\"\n (click)=\"removeRule(i)\"\n >\n <svg [shkIcon]=\"icons.trash\" class=\"w-3.5 h-3.5\"></svg>\n {{ filterLabel('removeRule') }}\n </button>\n }\n </div>\n }\n @if (canAddRule(col)) {\n <div class=\"px-2 pb-1\">\n <button\n type=\"button\"\n class=\"w-full inline-flex items-center justify-center gap-1 py-1 rounded-md _shk-text-primary hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] transition-colors\"\n (click)=\"addRule(col)\"\n >\n <svg [shkIcon]=\"getIcon('plus')\" class=\"w-3.5 h-3.5\"></svg>\n {{ filterLabel('addRule') }}\n </button>\n </div>\n }\n }\n }\n\n <div class=\"flex items-center justify-between gap-2 p-2 border-t _shk-border\">\n <button\n type=\"button\"\n class=\"px-3 py-1.5 font-medium rounded-md border _shk-border _shk-text-surface-600 hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] transition-colors\"\n (click)=\"clearFilter(col.field)\"\n >\n {{ filterLabel('clear') }}\n </button>\n <button\n type=\"button\"\n class=\"px-3 py-1.5 font-medium rounded-md _shk-bg-primary text-white hover:[background-color:var(--shk-primary-700)] transition-colors\"\n (click)=\"applyFilter(col)\"\n >\n {{ filterLabel('apply') }}\n </button>\n </div>\n </div>\n }\n } @else {\n <div class=\"flex items-center justify-center\">\n <span>{{ col.header }}</span>\n </div>\n }\n @if (isResizable()) {\n <span\n class=\"shk-col-resizer\"\n [class.shk-resizing]=\"resizingField() === col.field\"\n role=\"separator\"\n aria-orientation=\"vertical\"\n tabindex=\"0\"\n [attr.aria-label]=\"tr('table.resizeColumn', 'Redimensionar columna') + ': ' + col.header\"\n [attr.aria-valuenow]=\"resizedWidthPx(col)\"\n (pointerdown)=\"startResize($event, col)\"\n (click)=\"$event.stopPropagation()\"\n (dblclick)=\"$event.stopPropagation(); resetColumnWidth(col)\"\n (keydown)=\"onResizerKeydown($event, col)\"\n ></span>\n }\n </th>\n }\n </tr>\n </thead>\n @if (loading()) {\n <tbody class=\"border-b _shk-border\">\n <tr>\n <td [attr.colspan]=\"totalColspan()\" class=\"text-center py-12\">\n <div\n class=\"flex items-center justify-center\"\n role=\"status\"\n [attr.aria-label]=\"'common.loading' | transloco\"\n >\n <svg\n [shkIcon]=\"getIcon('loader')\"\n class=\"w-6 h-6 animate-spin _shk-text-primary\"\n ></svg>\n </div>\n </td>\n </tr>\n </tbody>\n } @else if (effectiveDisplayedData().length === 0) {\n <tbody class=\"border-b _shk-border\">\n <tr>\n <td [attr.colspan]=\"totalColspan()\" class=\"text-center py-12\">\n <div class=\"flex flex-col items-center\">\n <div\n class=\"w-16 h-16 _shk-bg-surface-100 rounded-full flex items-center justify-center mb-4\"\n >\n <svg\n [shkIcon]=\"getIcon('inbox')\"\n class=\"w-8 h-8 _shk-text-surface-400\"\n ></svg>\n </div>\n <p\n class=\"text-lg font-semibold _shk-text-surface-600\"\n >\n {{ emptyMessage() || ('common.no_records' | transloco) }}\n </p>\n </div>\n </td>\n </tr>\n </tbody>\n } @else {\n <tbody>\n @for (rowData of effectiveDisplayedData(); track trackByRow(rowData, $index)) {\n @let rowSeverityValue = rowSeverity(rowData);\n <tr\n [attr.aria-selected]=\"selectable() ? isRowSelected(rowData) : null\"\n [class.shk-row-selected]=\"selectable() && isRowSelected(rowData)\"\n [class.shk-row-low]=\"rowSeverityValue === 'low'\"\n [class.shk-row-moderate]=\"rowSeverityValue === 'moderate'\"\n [class.shk-row-critical]=\"rowSeverityValue === 'critical'\"\n [class.cursor-pointer]=\"selectable() && selectOnRowClick() && canSelectRow(rowData)\"\n (click)=\"onRowClick($event, rowData)\"\n class=\"shk-data-row transition-colors duration-200 border-b _shk-border\"\n >\n @if (selectable()) {\n <td data-shk-select class=\"w-10 px-2 min-[1440px]:px-3 py-2 min-[1440px]:py-2.5 text-center\">\n <input\n type=\"checkbox\"\n class=\"shk-table-checkbox\"\n [checked]=\"isRowSelected(rowData)\"\n [disabled]=\"!canSelectRow(rowData)\"\n (change)=\"toggleRowSelection(rowData)\"\n [attr.aria-label]=\"'table.selectRow' | transloco: { index: first() + $index + 1 }\"\n />\n </td>\n }\n @for (col of columnsWithActions(); track col.field) {\n <td\n [attr.data-shk-actions]=\"col.field === 'actions' ? '' : null\"\n [class]=\"\n 'px-2 min-[1440px]:px-3 py-2 min-[1440px]:py-2.5 text-xs font-medium _shk-text-surface-700 dark:[color:var(--shk-surface-700)] ' +\n (col.field === 'actions' ? 'whitespace-nowrap' : 'whitespace-normal break-words')\n \"\n [style.--shk-col-width]=\"col.field !== 'actions' ? getColumnWidth(col) : null\"\n >\n @if (col.field !== 'actions') {\n @switch (col.template) {\n @case ('tag') {\n <shk-tag\n [value]=\"getTagValue(col, rowData)\"\n [severity]=\"getTagSeverity(col, rowData)\"\n [rounded]=\"getTagRounded(col, rowData)\"\n [icon]=\"getTagIcon(col, rowData)\"\n [style]=\"getTagStyle(col, rowData)\"\n />\n }\n @case ('progress') {\n <div\n class=\"shk-progress\"\n role=\"progressbar\"\n aria-valuemin=\"0\"\n aria-valuemax=\"100\"\n [attr.aria-valuenow]=\"getProgress(col, rowData)\"\n [attr.aria-label]=\"col.header\"\n >\n <div [style.width.%]=\"getProgress(col, rowData)\"></div>\n </div>\n }\n @case ('boolean') {\n @if (resolveField(rowData, col.field)) {\n <svg\n [shkIcon]=\"icons.yes\"\n class=\"w-4 h-4 [color:var(--shk-success-600)]\"\n role=\"img\"\n [attr.aria-label]=\"filterLabel('yes')\"\n ></svg>\n } @else {\n <svg\n [shkIcon]=\"icons.no\"\n class=\"w-4 h-4 [color:var(--shk-error-500)]\"\n role=\"img\"\n [attr.aria-label]=\"filterLabel('no')\"\n ></svg>\n }\n }\n @case ('date') {\n {{ formatDateCell(resolveField(rowData, col.field), col) }}\n }\n @case ('currency') {\n {{ formatCurrencyCell(resolveField(rowData, col.field), col) }}\n }\n @default {\n @if (col.image) {\n <div class=\"flex items-center gap-2\">\n @if (col.image(rowData); as src) {\n <img\n [src]=\"src\"\n alt=\"\"\n [width]=\"col.imageWidth || 24\"\n class=\"shrink-0 rounded-sm\"\n />\n }\n <span>\n <ng-container\n *ngTemplateOutlet=\"cellText; context: { $implicit: rowData, col: col }\"\n ></ng-container>\n </span>\n </div>\n } @else {\n <ng-container\n *ngTemplateOutlet=\"cellText; context: { $implicit: rowData, col: col }\"\n ></ng-container>\n }\n }\n }\n } @else {\n <div class=\"flex items-center justify-start gap-px\">\n @for (action of getVisibleRowActions(rowData); track $index) {\n @if (isRowActionVisible(action, rowData)) {\n <div class=\"relative group\">\n <shk-tooltip\n [text]=\"getRowActionLabel(action, rowData)\"\n position=\"top\"\n >\n <button\n type=\"button\"\n (click)=\"action.onClick(rowData)\"\n [class]=\"\n 'table-action-btn hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] rounded-md ' +\n getRowActionClass(action, rowData)\n \"\n [disabled]=\"isRowActionDisabled(action, rowData) || false\"\n [attr.aria-label]=\"getRowActionLabel(action, rowData)\"\n >\n <svg\n [shkIcon]=\"getIcon(getRowActionIconName(action, rowData))\"\n class=\"w-4 h-4\"\n ></svg>\n </button>\n </shk-tooltip>\n </div>\n }\n }\n @if (getHiddenRowActions(rowData).length > 0) {\n <div class=\"relative\">\n <shk-tooltip\n [text]=\"'common.more_options' | transloco\"\n position=\"top\"\n >\n <button\n type=\"button\"\n (click)=\"$event.stopPropagation(); toggleActionsDropdown(rowData, $event)\"\n class=\"table-action-btn hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] rounded-md\"\n [attr.aria-label]=\"'common.more_options' | transloco\"\n [attr.aria-expanded]=\"isActionsDropdownOpen(rowData)\"\n >\n <svg\n [shkIcon]=\"getIcon('ellipsis-vertical')\"\n class=\"w-4 h-4\"\n ></svg>\n </button>\n </shk-tooltip>\n @if (isActionsDropdownOpen(rowData)) {\n <div\n shkPortal\n class=\"fixed z-[9999] min-w-[160px] bg-white dark:[background-color:var(--shk-surface-100)] border _shk-border rounded-md shadow-lg py-1\"\n [style.top]=\"dropdownPosition().top + 'px'\"\n [style.left]=\"dropdownPosition().left + 'px'\"\n >\n @for (action of getHiddenRowActions(rowData); track $index) {\n <button\n type=\"button\"\n (click)=\"action.onClick(rowData); toggleActionsDropdown(rowData)\"\n [disabled]=\"isRowActionDisabled(action, rowData) || false\"\n [class]=\"\n 'w-full flex items-center gap-2 px-3 py-2 text-xs text-left _shk-text-surface-700 dark:[color:var(--shk-surface-700)] hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] disabled:opacity-40 disabled:cursor-not-allowed transition-colors ' +\n getRowActionClass(action, rowData)\n \"\n >\n <svg\n [shkIcon]=\"getIcon(getRowActionIconName(action, rowData))\"\n class=\"w-3.5 h-3.5 shrink-0\"\n ></svg>\n <span>{{ getRowActionLabel(action, rowData) }}</span>\n </button>\n }\n </div>\n }\n </div>\n }\n @if (rowSeverityValue) {\n <div class=\"relative group\">\n <shk-tooltip [text]=\"rowValidationTitle(rowData) || ''\" position=\"top\">\n <span\n class=\"shk-row-validation-btn\"\n [class.shk-sev-low]=\"rowSeverityValue === 'low'\"\n [class.shk-sev-moderate]=\"rowSeverityValue === 'moderate'\"\n [class.shk-sev-critical]=\"rowSeverityValue === 'critical'\"\n tabindex=\"0\"\n role=\"note\"\n [attr.aria-label]=\"rowValidationLabel(rowData)\"\n >\n <svg [shkIcon]=\"rowValidationIcon(rowData)\"></svg>\n </span>\n </shk-tooltip>\n </div>\n }\n </div>\n }\n </td>\n }\n </tr>\n }\n </tbody>\n }\n </table>\n\n <!-- Text content of a cell: format() · custom template · raw value -->\n <ng-template #cellText let-rowData let-col=\"col\">\n @if (col.format) {\n <span>{{ col.format(rowData) }}</span>\n } @else {\n <ng-container\n *ngTemplateOutlet=\"\n customTemplates()[col.field] || defaultTemplate;\n context: { $implicit: rowData, field: col.field }\n \"\n ></ng-container>\n }\n </ng-template>\n <ng-template #defaultTemplate let-rowData let-field=\"field\">\n {{ resolveField(rowData, field) }}\n </ng-template>\n\n <!-- Option list of the select / multiselect filters -->\n <ng-template #optionList let-col let-draft=\"draft\" let-multiple=\"multiple\">\n <div class=\"p-2 space-y-1.5\">\n @let selectedLabel = multiple ? selectedOptionsLabel(col) : selectedSingleLabel(col);\n <button\n type=\"button\"\n class=\"shk-filter-select flex items-center justify-between gap-2 text-left\"\n style=\"background-image: none\"\n [id]=\"uid + '-filter-' + safeId(col.field) + '-0'\"\n [attr.aria-expanded]=\"multiselectOpen()\"\n (click)=\"multiselectOpen.set(!multiselectOpen())\"\n >\n <span class=\"truncate\" [class._shk-text-surface-400]=\"!selectedLabel\">\n {{ selectedLabel || tr('table.filterAll', 'Todos') }}\n </span>\n <svg\n [shkIcon]=\"getIcon('chevron-down')\"\n class=\"w-3.5 h-3.5 shrink-0 _shk-text-surface-400 transition-transform\"\n [class.rotate-180]=\"multiselectOpen()\"\n ></svg>\n </button>\n @if (multiselectOpen()) {\n <div\n class=\"max-h-52 overflow-y-auto p-0.5 border _shk-border rounded-md _shk-scrollbar\"\n role=\"listbox\"\n [attr.aria-multiselectable]=\"multiple\"\n >\n @for (opt of col.filterOptions || []; track $index) {\n @let isSelected = multiple\n ? isOptionSelected(opt.value)\n : draft.rules[0].value != null && draft.rules[0].value == opt.value;\n <button\n type=\"button\"\n role=\"option\"\n class=\"w-full flex items-center gap-2 px-2 py-1.5 rounded text-left transition-colors hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)]\"\n [class._shk-bg-primary-soft]=\"isSelected\"\n [class._shk-text-primary-700]=\"isSelected\"\n [attr.aria-selected]=\"isSelected\"\n (click)=\"multiple ? toggleOption(col, opt.value) : selectOption(col, opt.value)\"\n >\n @if (multiple) {\n <span class=\"shk-checkbox-box\" [class.shk-checked]=\"isSelected\">\n @if (isSelected) {\n <svg [shkIcon]=\"getIcon('check')\"></svg>\n }\n </span>\n }\n @if (opt.image) {\n <img [src]=\"opt.image\" alt=\"\" width=\"22\" class=\"shrink-0 rounded-sm\" />\n }\n <span class=\"truncate\">{{ opt.label }}</span>\n </button>\n }\n </div>\n }\n </div>\n </ng-template>\n </div>\n <div\n class=\"table-pagination flex items-center justify-between gap-4 px-2 min-[1440px]:px-3 py-2 border-t _shk-border\"\n >\n <div class=\"text-xs _shk-text-surface-600\">\n @if (showPageReport()) {\n {{ pageReport() }}\n }\n </div>\n <div\n class=\"flex items-center gap-0.5\"\n role=\"navigation\"\n >\n <button\n type=\"button\"\n (click)=\"goToFirst()\"\n [disabled]=\"isFirstPage()\"\n [attr.aria-label]=\"tr('table.firstPage', 'Primera página')\"\n class=\"shk-page-btn p-1 _shk-text-surface-500 hover:[color:var(--shk-surface-700)] dark:hover:[color:var(--shk-surface-200)] disabled:opacity-30 disabled:cursor-not-allowed rounded transition-colors\"\n >\n <svg [shkIcon]=\"getIcon('chevrons-left')\" class=\"w-4 h-4\"></svg>\n </button>\n <button\n type=\"button\"\n (click)=\"prev()\"\n [disabled]=\"isFirstPage()\"\n [attr.aria-label]=\"tr('table.prevPage', 'Página anterior')\"\n class=\"shk-page-btn p-1 _shk-text-surface-500 hover:[color:var(--shk-surface-700)] dark:hover:[color:var(--shk-surface-200)] disabled:opacity-30 disabled:cursor-not-allowed rounded transition-colors\"\n >\n <svg [shkIcon]=\"getIcon('chevron-left')\" class=\"w-4 h-4\"></svg>\n </button>\n <span\n class=\"px-2 text-xs font-medium _shk-text-surface-700\"\n >{{ currentPage() }} / {{ totalPages() }}</span\n >\n <button\n type=\"button\"\n (click)=\"next()\"\n [disabled]=\"isLastPage()\"\n [attr.aria-label]=\"tr('table.nextPage', 'Página siguiente')\"\n class=\"shk-page-btn p-1 _shk-text-surface-500 hover:[color:var(--shk-surface-700)] dark:hover:[color:var(--shk-surface-200)] disabled:opacity-30 disabled:cursor-not-allowed rounded transition-colors\"\n >\n <svg [shkIcon]=\"getIcon('chevron-right')\" class=\"w-4 h-4\"></svg>\n </button>\n <button\n type=\"button\"\n (click)=\"goToLast()\"\n [disabled]=\"isLastPage()\"\n [attr.aria-label]=\"tr('table.lastPage', 'Última página')\"\n class=\"shk-page-btn p-1 _shk-text-surface-500 hover:[color:var(--shk-surface-700)] dark:hover:[color:var(--shk-surface-200)] disabled:opacity-30 disabled:cursor-not-allowed rounded transition-colors\"\n >\n <svg [shkIcon]=\"getIcon('chevrons-right')\" class=\"w-4 h-4\"></svg>\n </button>\n </div>\n <div\n class=\"flex items-center gap-1.5 text-xs _shk-text-surface-600\"\n >\n @if (showRowsPerPage()) {\n <label [for]=\"uid + '-rows-per-page'\">{{ 'table.rows' | transloco }}</label>\n <select\n [id]=\"uid + '-rows-per-page'\"\n (change)=\"onRowsPerPageChange($any($event.target).value)\"\n class=\"border _shk-border rounded px-2 py-1 text-xs bg-white dark:[background-color:var(--shk-surface-100)] _shk-text-surface-700 focus:outline-none focus:[border-color:var(--shk-primary-500)]\"\n >\n @for (opt of rowsPerPageOptions(); track opt) {\n <option [value]=\"opt\" [selected]=\"opt === rowsPerPageLocal()\">{{ opt }}</option>\n }\n </select>\n }\n </div>\n </div>\n </div>\n</div>\n",
1500
+ styles: ["input:focus{outline:none}input[type=text]{font-weight:400!important}table th{white-space:nowrap}table td{white-space:normal;overflow-wrap:break-word}.shk-page-btn{display:inline-flex;align-items:center;justify-content:center;width:1.75rem;height:1.75rem;border-radius:.375rem;transition:background-color .15s ease,color .15s ease}.shk-page-btn:hover:not(:disabled){background-color:var(--shk-surface-100)}:host-context(.dark) .shk-page-btn:hover:not(:disabled){background-color:var(--shk-surface-200)}.shk-page-btn:focus-visible{outline:none;box-shadow:0 0 0 2px color-mix(in srgb,var(--shk-primary-500) 45%,transparent)}td button svg{width:1.125rem!important;height:1.125rem!important}td button:disabled{opacity:.4;cursor:not-allowed}.table-action-btn svg{width:1rem!important;height:1rem!important;min-width:1rem!important;min-height:1rem!important}.table-action-btn{padding:.5rem!important;min-width:2rem!important;min-height:2rem!important;display:inline-flex!important;align-items:center!important;justify-content:center!important}.table-scroll-wrapper{width:100%;overflow-x:auto;overflow-y:hidden;border-radius:inherit;-webkit-overflow-scrolling:touch;container-type:inline-size}.table-card,.table-pagination{container-type:inline-size}@container (max-width: 640px){.table-pagination{flex-direction:column;align-items:center;gap:.5rem}.table-pagination>div{justify-content:center}}.table-scroll-wrapper table{table-layout:auto;width:100%}@container (max-width: 768px){.table-scroll-wrapper{scroll-snap-type:x mandatory}.table-scroll-wrapper table{table-layout:auto;width:100%}.table-scroll-wrapper th:not([data-shk-actions]):not([data-shk-select]){min-width:var(--shk-col-width, 140px)}.table-scroll-wrapper td:not([data-shk-actions]):not([data-shk-select]){min-width:var(--shk-col-width, 140px);max-width:var(--shk-col-width, 140px)}.table-scroll-wrapper th,.table-scroll-wrapper td{scroll-snap-align:start}}th[data-shk-select],td[data-shk-select]{width:2.5rem;min-width:2.5rem}.shk-table-checkbox{width:.875rem;height:.875rem;cursor:pointer;vertical-align:middle;accent-color:var(--shk-primary-500)}.shk-table-checkbox:disabled{opacity:.4;cursor:not-allowed}tr.shk-row-selected{background-color:color-mix(in srgb,var(--shk-primary-50) 60%,transparent)}tr.shk-row-selected:hover{background-color:color-mix(in srgb,var(--shk-primary-50) 90%,transparent)}:host-context(.dark) tr.shk-row-selected{background-color:color-mix(in srgb,var(--shk-primary-900) 20%,transparent)}:host-context(.dark) tr.shk-row-selected:hover{background-color:color-mix(in srgb,var(--shk-primary-900) 30%,transparent)}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.shk-data-table tr.shk-row-low{background-color:color-mix(in srgb,var(--shk-info-600) 22%,transparent)}.shk-data-table tr.shk-row-moderate{background-color:color-mix(in srgb,var(--shk-warning-400) 32%,transparent)}.shk-data-table tr.shk-row-critical{background-color:color-mix(in srgb,var(--shk-error-500) 20%,transparent)}:host-context(.dark) .shk-data-table tr.shk-row-low{background-color:color-mix(in srgb,var(--shk-info-600) 26%,transparent)}:host-context(.dark) .shk-data-table tr.shk-row-moderate{background-color:color-mix(in srgb,var(--shk-warning-400) 34%,transparent)}:host-context(.dark) .shk-data-table tr.shk-row-critical{background-color:color-mix(in srgb,var(--shk-error-500) 24%,transparent)}.shk-row-validation-btn{display:inline-flex;align-items:center;justify-content:center;padding:.25rem;border-radius:.375rem;cursor:help;color:var(--shk-surface-500)}.shk-row-validation-btn svg{width:1rem!important;height:1rem!important}.shk-row-validation-btn.shk-sev-low{color:var(--shk-info-600)}.shk-row-validation-btn.shk-sev-moderate{color:var(--shk-warning-600)}:host-context(.dark) .shk-row-validation-btn.shk-sev-moderate{color:var(--shk-warning-400)}.shk-row-validation-btn.shk-sev-critical{color:var(--shk-error-500)}.shk-row-validation-btn:focus-visible{outline:2px solid currentColor;outline-offset:1px}table.shk-row-hover tbody tr.shk-data-row:hover{background-color:color-mix(in srgb,var(--shk-primary-50) 30%,transparent)}:host-context(.dark) table.shk-row-hover tbody tr.shk-data-row:hover{background-color:color-mix(in srgb,var(--shk-primary-900) 10%,transparent)}table.shk-gridlines th,table.shk-gridlines td{border-right:1px solid var(--shk-surface-200)}table.shk-gridlines th:last-child,table.shk-gridlines td:last-child{border-right:0}:host-context(.dark) table.shk-gridlines th,:host-context(.dark) table.shk-gridlines td{border-right-color:var(--shk-surface-200)}.shk-col-resizer{position:absolute;top:0;right:-4px;z-index:1;width:8px;height:100%;cursor:col-resize;touch-action:none}.shk-col-resizer:after{content:\"\";position:absolute;top:20%;bottom:20%;left:3px;width:2px;border-radius:1px;background-color:transparent;transition:background-color .15s ease}.shk-col-resizer:hover:after,.shk-col-resizer:focus-visible:after,.shk-col-resizer.shk-resizing:after{background-color:var(--shk-primary-500)}.shk-col-resizer:focus-visible{outline:none}th:last-child .shk-col-resizer{right:0}.shk-filter-input,.shk-filter-select{width:100%;padding:.375rem .625rem;font-size:.75rem;line-height:1.25rem;border-radius:.375rem;border:1px solid var(--shk-surface-200);background-color:#fff;color:var(--shk-surface-700)}.dark .shk-filter-input,.dark .shk-filter-select{background-color:var(--shk-surface-100);border-color:var(--shk-surface-200);color-scheme:dark}.shk-filter-input::placeholder{color:var(--shk-surface-400)}select.shk-filter-select{appearance:none;padding-right:1.75rem;background-image:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E\");background-repeat:no-repeat;background-position:right .5rem center;cursor:pointer}button.shk-filter-select{cursor:pointer}.shk-filter-input:focus,.shk-filter-select:focus{outline:none;border-color:var(--shk-primary-500);box-shadow:0 0 0 1px var(--shk-primary-500)}.shk-checkbox-box{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;width:.875rem;height:.875rem;border-radius:.1875rem;border:1px solid var(--shk-surface-300);background-color:#fff;color:#fff}.dark .shk-checkbox-box{background-color:var(--shk-surface-100)}.shk-checkbox-box.shk-checked{background-color:var(--shk-primary-500);border-color:var(--shk-primary-500)}.shk-checkbox-box svg{width:.625rem;height:.625rem}.shk-range{position:relative;height:1rem;margin:.5rem .375rem .375rem}.shk-range-track,.shk-range-fill{position:absolute;top:50%;height:.1875rem;transform:translateY(-50%);border-radius:9999px}.shk-range-track{left:0;right:0;background-color:var(--shk-surface-200)}.shk-range-fill{background-color:var(--shk-primary-500)}.shk-range input[type=range]{position:absolute;inset:0;width:100%;margin:0;background:transparent;pointer-events:none;appearance:none;-webkit-appearance:none}.shk-range input[type=range]::-webkit-slider-thumb{pointer-events:auto;-webkit-appearance:none;width:.875rem;height:.875rem;border-radius:9999px;background:#fff;border:2px solid var(--shk-primary-500);cursor:grab}.shk-range input[type=range]::-moz-range-thumb{pointer-events:auto;width:.625rem;height:.625rem;border-radius:9999px;background:#fff;border:2px solid var(--shk-primary-500);cursor:grab}.shk-progress{height:.375rem;min-width:5rem;border-radius:9999px;background-color:var(--shk-surface-200);overflow:hidden}.shk-progress>div{height:100%;border-radius:inherit;background-color:var(--shk-primary-500)}\n"],
1501
+ dependencies: [
1502
+ {
1503
+ kind: "directive",
1504
+ type: PortalDirective,
1505
+ selector: "[shkPortal]"
1506
+ },
1507
+ {
1508
+ kind: "ngmodule",
1509
+ type: CommonModule
1510
+ },
1511
+ {
1512
+ kind: "directive",
1513
+ type: i1.NgTemplateOutlet,
1514
+ selector: "[ngTemplateOutlet]",
1515
+ inputs: [
1516
+ "ngTemplateOutletContext",
1517
+ "ngTemplateOutlet",
1518
+ "ngTemplateOutletInjector"
1519
+ ]
1520
+ },
1521
+ {
1522
+ kind: "ngmodule",
1523
+ type: TranslocoModule
1524
+ },
1525
+ {
1526
+ kind: "directive",
1527
+ type: ShkIconDirective,
1528
+ selector: "svg[shkIcon]",
1529
+ inputs: [
1530
+ "shkIcon",
1531
+ "size",
1532
+ "strokeWidth",
1533
+ "color"
1534
+ ]
1535
+ },
1536
+ {
1537
+ kind: "component",
1538
+ type: TagComponent,
1539
+ selector: "shk-tag",
1540
+ inputs: [
1541
+ "value",
1542
+ "severity",
1543
+ "rounded",
1544
+ "icon",
1545
+ "style",
1546
+ "styleClass"
1547
+ ]
1548
+ },
1549
+ {
1550
+ kind: "component",
1551
+ type: TooltipComponent,
1552
+ selector: "shk-tooltip",
1553
+ inputs: [
1554
+ "text",
1555
+ "position",
1556
+ "mode",
1557
+ "offset"
1558
+ ]
1559
+ },
1560
+ {
1561
+ kind: "pipe",
1562
+ type: i2.TranslocoPipe,
1563
+ name: "transloco"
1564
+ }
1565
+ ],
1566
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
1567
+ });
1568
+ }
1569
+ };
1570
+ i0.ɵɵngDeclareClassMetadata({
1571
+ minVersion: "12.0.0",
1572
+ version: "22.3.2",
1573
+ ngImport: i0,
1574
+ type: TableComponent,
1575
+ decorators: [{
1576
+ type: Component,
1577
+ args: [{
1578
+ selector: "shk-table",
1579
+ changeDetection: ChangeDetectionStrategy.OnPush,
1580
+ imports: [
1581
+ PortalDirective,
1582
+ CommonModule,
1583
+ TranslocoModule,
1584
+ ShkIconDirective,
1585
+ TagComponent,
1586
+ TooltipComponent
1587
+ ],
1588
+ template: "<div class=\"space-y-2 min-[1440px]:space-y-3 mt-2 min-[1440px]:mt-3 animate-fade-in pb-8\">\n @if (\n showSearch() ||\n (showClearButton() && hasFilterableColumns()) ||\n filters().length > 0 ||\n headerActions().length > 0 ||\n (selectable() && bulkActions().length > 0 && selection().length > 0)\n ) {\n <div class=\"card p-2 min-[1440px]:p-2.5 flex flex-row items-center justify-between gap-2\">\n <div class=\"flex items-center gap-2 min-[1440px]:gap-3 flex-1 min-w-0\">\n @if (showSearch()) {\n <div class=\"relative w-full md:w-52 min-[1440px]:w-56\">\n <label [for]=\"uid + '-search'\" class=\"sr-only\">{{\n searchPlaceholder() || ('common.search_placeholder' | transloco)\n }}</label>\n <div class=\"absolute inset-y-0 left-0 pl-2.5 flex items-center pointer-events-none\">\n <svg\n [shkIcon]=\"getIcon('search')\"\n class=\"w-3.5 h-3.5 _shk-text-surface-400\"\n ></svg>\n </div>\n <input\n [id]=\"uid + '-search'\"\n type=\"text\"\n [value]=\"searchQuery()\"\n (input)=\"onSearchInput($any($event.target).value)\"\n [placeholder]=\"searchPlaceholder() || ('common.search_placeholder' | transloco)\"\n class=\"block w-full pl-8 pr-3 py-1.5 text-xs border _shk-border rounded-md leading-5 _shk-bg-surface-50 placeholder:[color:var(--shk-surface-400)] dark:placeholder:[color:var(--shk-surface-500)] _shk-text-surface-700 focus:outline-none focus:bg-white dark:focus:[background-color:var(--shk-surface-100)] focus:[border-color:var(--shk-primary-500)] focus:ring-1 focus:[--tw-ring-color:var(--shk-primary-500)]\"\n />\n </div>\n }\n @if (showClearButton() && (hasFilterableColumns() || showSearch())) {\n <shk-tooltip [text]=\"tr('table.clearFilters', 'Limpiar búsqueda, filtros y orden')\">\n <button\n type=\"button\"\n (click)=\"clearAll()\"\n [disabled]=\"!hasActiveFilters()\"\n class=\"inline-flex items-center gap-1.5 px-2.5 py-1.5 text-xs font-medium rounded-md border _shk-border _shk-text-surface-600 hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] transition-colors disabled:opacity-40 disabled:cursor-not-allowed whitespace-nowrap\"\n >\n <svg [shkIcon]=\"icons.clear\" class=\"w-3.5 h-3.5\"></svg>\n {{ tr('table.clear', 'Limpiar') }}\n </button>\n </shk-tooltip>\n }\n @if (filters().length > 0) {\n <div\n class=\"flex _shk-bg-surface-100 p-0.5 rounded-md ml-auto\"\n role=\"group\"\n >\n @for (f of filters(); track f.value) {\n <button\n type=\"button\"\n (click)=\"onFilterClick(f.value)\"\n [attr.aria-pressed]=\"f.value === activeFilter()\"\n class=\"px-2.5 min-[1440px]:px-3 py-1 text-xs font-medium rounded _shk-text-surface-700 transition-all\"\n [class]=\"\n f.value === activeFilter()\n ? 'bg-white shadow-sm dark:[background-color:var(--shk-surface-700)]'\n : ''\n \"\n >\n {{ f.label }}\n </button>\n }\n </div>\n }\n </div>\n @if (selectable() && selection().length > 0 && bulkActions().length > 0) {\n <div\n class=\"flex items-center gap-1.5 shrink-0\"\n role=\"toolbar\"\n [attr.aria-label]=\"'table.selected' | transloco: { count: selection().length }\"\n >\n <span\n class=\"text-xs font-medium _shk-text-surface-600 whitespace-nowrap\"\n aria-live=\"polite\"\n >{{ 'table.selected' | transloco: { count: selection().length } }}</span\n >\n <button\n type=\"button\"\n (click)=\"clearSelection()\"\n [attr.aria-label]=\"'table.clearSelection' | transloco\"\n class=\"table-action-btn rounded-md _shk-text-surface-500 hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)]\"\n >\n <svg [shkIcon]=\"getIcon('x')\" class=\"w-3.5 h-3.5\"></svg>\n </button>\n @for (action of visibleBulkActions(); track $index) {\n <button\n type=\"button\"\n [class]=\"\n 'inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-md _shk-bg-primary text-white hover:[background-color:var(--shk-primary-700)] transition-colors disabled:opacity-50 disabled:cursor-not-allowed ' +\n (action.class || '')\n \"\n [disabled]=\"isBulkActionDisabled(action)\"\n [attr.aria-label]=\"action.label\"\n (click)=\"runBulkAction(action)\"\n >\n @if (action.icon) {\n <svg [shkIcon]=\"getIcon(action.icon)\" class=\"w-3.5 h-3.5\"></svg>\n }\n {{ action.label }}\n </button>\n }\n </div>\n }\n @if (headerActions().length > 0) {\n <div class=\"flex items-center gap-1.5 shrink-0\">\n @for (action of headerActions(); track $index) {\n @if (isHeaderActionVisible(action)) {\n <button\n type=\"button\"\n [class]=\"\n 'inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-md _shk-bg-primary text-white hover:[background-color:var(--shk-primary-700)] transition-colors disabled:opacity-50 disabled:cursor-not-allowed ' +\n (action.class || '')\n \"\n [disabled]=\"isHeaderActionDisabled(action)\"\n [attr.aria-label]=\"action.label\"\n (click)=\"action.onClick()\"\n >\n @if (action.icon) {\n <svg [shkIcon]=\"getIcon(action.icon)\" class=\"w-3.5 h-3.5\"></svg>\n }\n {{ action.label }}\n </button>\n }\n }\n </div>\n }\n </div>\n }\n <div class=\"card p-0 overflow-hidden table-card\" [class.shadow-lg]=\"hasShadow()\">\n <div class=\"table-scroll-wrapper _shk-scrollbar\">\n <table\n class=\"shk-data-table\"\n [class.shk-gridlines]=\"showGridlines()\"\n [class.shk-row-hover]=\"rowHover()\"\n >\n <thead>\n <tr>\n @if (selectable()) {\n <th\n scope=\"col\"\n data-shk-select\n class=\"w-10 px-2 min-[1440px]:px-3 py-2 min-[1440px]:py-2.5 text-center _shk-bg-surface-50 border-b _shk-border\"\n >\n <input\n type=\"checkbox\"\n class=\"shk-table-checkbox\"\n [checked]=\"allPageSelected()\"\n [indeterminate]=\"somePageSelected()\"\n [disabled]=\"loading() || selectablePageRows().length === 0\"\n (change)=\"toggleSelectAllPage()\"\n [attr.aria-label]=\"'table.selectAll' | transloco\"\n />\n </th>\n }\n @for (col of columnsWithActions(); track col.field) {\n <th\n scope=\"col\"\n (click)=\"onHeaderClick(col)\"\n (keydown)=\"onHeaderKeydown($event, col)\"\n [tabindex]=\"col.field !== 'actions' && col.sortable ? 0 : -1\"\n [attr.role]=\"col.field !== 'actions' && col.sortable ? 'button' : null\"\n [attr.aria-sort]=\"getAriaSort(col)\"\n [attr.data-shk-actions]=\"col.field === 'actions' ? '' : null\"\n [style.cursor]=\"col.field !== 'actions' && col.sortable ? 'pointer' : 'default'\"\n [style.width]=\"resizedWidth(col) || (col.field === 'actions' ? col.width : null)\"\n [style.min-width]=\"resizedWidth(col) || (col.field === 'actions' ? col.width : col.minWidth) || null\"\n [style.--shk-col-width]=\"col.field !== 'actions' ? getColumnWidth(col) : null\"\n class=\"relative px-2 min-[1440px]:px-3 py-2 min-[1440px]:py-2.5 text-left text-[10px] min-[1440px]:text-xs font-bold _shk-text-surface-500 uppercase tracking-wider _shk-bg-surface-50 border-b _shk-border focus:outline-none focus-visible:ring-1 focus-visible:[--tw-ring-color:var(--shk-primary-500)]\"\n >\n @if (col.field !== 'actions') {\n <div class=\"flex items-center justify-between gap-2\">\n <span>{{ col.header }}</span>\n <div class=\"flex items-center gap-1 shrink-0\">\n @if (col.sortable) {\n <shk-tooltip [text]=\"'table.tooltips.sort' | transloco\">\n @if (sortField() === col.field) {\n <svg\n [shkIcon]=\"getIcon(sortOrder() === 1 ? 'arrow-up' : 'arrow-down')\"\n class=\"w-3.5 h-3.5 _shk-text-primary\"\n ></svg>\n } @else {\n <svg\n [shkIcon]=\"getIcon('arrow-up-down')\"\n class=\"w-3.5 h-3.5 _shk-text-surface-400\"\n ></svg>\n }\n </shk-tooltip>\n }\n @if (col.filter) {\n <shk-tooltip [text]=\"'table.tooltips.filter' | transloco\">\n <button\n type=\"button\"\n (click)=\"$event.stopPropagation(); toggleFilter(col, $event)\"\n [attr.aria-label]=\"('table.tooltips.filter' | transloco) + ': ' + col.header\"\n [attr.aria-expanded]=\"openFilterField() === col.field\"\n aria-haspopup=\"dialog\"\n class=\"_shk-text-surface-400 hover:[color:var(--shk-surface-600)] dark:hover:[color:var(--shk-surface-300)] transition-colors\"\n >\n <svg\n [shkIcon]=\"getIcon('filter')\"\n class=\"w-3.5 h-3.5\"\n [class._shk-text-primary]=\"hasFilterValue(col.field) || openFilterField() === col.field\"\n ></svg>\n </button>\n </shk-tooltip>\n }\n </div>\n </div>\n\n\n <!-- Column filter menu -->\n @if (col.filter && openFilterField() === col.field && filterDraft(); as draft) {\n <div\n shkPortal\n class=\"shk-filter-overlay fixed z-[9999] w-[240px] overflow-y-auto normal-case tracking-normal font-normal text-xs _shk-text-surface-700 bg-white dark:[background-color:var(--shk-surface-100)] border _shk-border rounded-lg shadow-lg\"\n role=\"dialog\"\n [attr.aria-label]=\"('table.tooltips.filter' | transloco) + ': ' + col.header\"\n [style.top.px]=\"filterPopupPosition().top\"\n [style.left.px]=\"filterPopupPosition().left\"\n [style.max-height.px]=\"filterPopupPosition().maxHeight\"\n (click)=\"$event.stopPropagation()\"\n (keydown)=\"$event.stopPropagation()\"\n (keydown.escape)=\"closeFilters()\"\n >\n @if (col.filterMenuTitle) {\n <div class=\"px-2 pt-2 font-semibold _shk-text-surface-800\">\n {{ col.filterMenuTitle }}\n </div>\n }\n @if (showOperatorFor(col)) {\n <div class=\"p-2 border-b _shk-border\">\n <select\n class=\"shk-filter-select\"\n [attr.aria-label]=\"filterLabel('matchAll') + ' / ' + filterLabel('matchAny')\"\n (change)=\"setDraftOperator($any($event.target).value)\"\n >\n <option value=\"and\" [selected]=\"draft.operator === 'and'\">\n {{ filterLabel('matchAll') }}\n </option>\n <option value=\"or\" [selected]=\"draft.operator === 'or'\">\n {{ filterLabel('matchAny') }}\n </option>\n </select>\n </div>\n }\n\n @switch (filterKind(col)) {\n @case ('select') {\n <ng-container\n *ngTemplateOutlet=\"optionList; context: { $implicit: col, draft: draft, multiple: false }\"\n ></ng-container>\n }\n @case ('multiselect') {\n <ng-container\n *ngTemplateOutlet=\"optionList; context: { $implicit: col, draft: draft, multiple: true }\"\n ></ng-container>\n }\n @case ('boolean') {\n @let boolValue = draft.rules[0].value;\n <div class=\"p-2\">\n <button\n type=\"button\"\n role=\"checkbox\"\n [id]=\"uid + '-filter-' + safeId(col.field) + '-0'\"\n class=\"inline-flex items-center gap-2 rounded-md focus:outline-none focus-visible:ring-1 focus-visible:[--tw-ring-color:var(--shk-primary-500)]\"\n [attr.aria-checked]=\"\n boolValue === true ? 'true' : boolValue === false ? 'false' : 'mixed'\n \"\n (click)=\"cycleBoolean(col)\"\n >\n <span\n class=\"shk-checkbox-box\"\n [class.shk-checked]=\"boolValue === true || boolValue === false\"\n >\n @if (boolValue === true) {\n <svg [shkIcon]=\"getIcon('check')\"></svg>\n } @else if (boolValue === false) {\n <svg [shkIcon]=\"getIcon('x')\"></svg>\n }\n </span>\n <span>{{\n boolValue === true\n ? filterLabel('yes')\n : boolValue === false\n ? filterLabel('no')\n : filterLabel('any')\n }}</span>\n </button>\n </div>\n }\n @case ('range') {\n @let rv = rangeValue(col);\n @let bounds = rangeBounds(col);\n <div class=\"p-2\">\n <div class=\"shk-range\">\n <div class=\"shk-range-track\"></div>\n <div\n class=\"shk-range-fill\"\n [style.left.%]=\"rangePercent(col, rv[0])\"\n [style.width.%]=\"rangePercent(col, rv[1]) - rangePercent(col, rv[0])\"\n ></div>\n <input\n type=\"range\"\n [id]=\"uid + '-filter-' + safeId(col.field) + '-0'\"\n [min]=\"bounds[0]\"\n [max]=\"bounds[1]\"\n [step]=\"col.filterStep || 1\"\n [value]=\"rv[0]\"\n [style.z-index]=\"rv[0] >= bounds[1] ? 3 : null\"\n [attr.aria-label]=\"col.header + ' min'\"\n (input)=\"onRangeInput(col, 0, $any($event.target).value, false)\"\n (change)=\"onRangeInput(col, 0, $any($event.target).value, true)\"\n />\n <input\n type=\"range\"\n [min]=\"bounds[0]\"\n [max]=\"bounds[1]\"\n [step]=\"col.filterStep || 1\"\n [value]=\"rv[1]\"\n [attr.aria-label]=\"col.header + ' max'\"\n (input)=\"onRangeInput(col, 1, $any($event.target).value, false)\"\n (change)=\"onRangeInput(col, 1, $any($event.target).value, true)\"\n />\n </div>\n <div class=\"flex items-center justify-between px-0.5 _shk-text-surface-500\">\n <span>{{ rv[0] }}</span>\n <span>{{ rv[1] }}</span>\n </div>\n </div>\n }\n @default {\n <!-- text / numeric / date: one block per rule -->\n @for (rule of draft.rules; track $index; let i = $index) {\n <div\n class=\"flex flex-col gap-1.5 p-2\"\n [class.border-b]=\"i < draft.rules.length - 1\"\n [class._shk-border]=\"i < draft.rules.length - 1\"\n >\n @if (showMatchModesFor(col)) {\n <select\n class=\"shk-filter-select\"\n [attr.aria-label]=\"col.header\"\n (change)=\"setDraftMatchMode(col, i, $any($event.target).value)\"\n >\n @for (mode of matchModesFor(col); track mode) {\n <option [value]=\"mode\" [selected]=\"mode === rule.matchMode\">\n {{ matchModeLabel(mode) }}\n </option>\n }\n </select>\n }\n <input\n [id]=\"uid + '-filter-' + safeId(col.field) + '-' + i\"\n [type]=\"filterKind(col) === 'numeric' ? 'number' : filterKind(col) === 'date' ? 'date' : 'text'\"\n [attr.step]=\"filterKind(col) === 'numeric' ? 'any' : null\"\n class=\"shk-filter-input\"\n [value]=\"rule.value ?? ''\"\n [placeholder]=\"col.filterPlaceholder || ('common.search_placeholder' | transloco)\"\n [attr.aria-label]=\"col.header\"\n (input)=\"onRuleInput(col, i, $any($event.target).value)\"\n (keydown.enter)=\"applyFilter(col)\"\n />\n @if (draft.rules.length > 1) {\n <button\n type=\"button\"\n class=\"inline-flex items-center justify-center gap-1 py-1 rounded-md [color:var(--shk-error-600)] hover:[background-color:var(--shk-error-50)] transition-colors\"\n (click)=\"removeRule(i)\"\n >\n <svg [shkIcon]=\"icons.trash\" class=\"w-3.5 h-3.5\"></svg>\n {{ filterLabel('removeRule') }}\n </button>\n }\n </div>\n }\n @if (canAddRule(col)) {\n <div class=\"px-2 pb-1\">\n <button\n type=\"button\"\n class=\"w-full inline-flex items-center justify-center gap-1 py-1 rounded-md _shk-text-primary hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] transition-colors\"\n (click)=\"addRule(col)\"\n >\n <svg [shkIcon]=\"getIcon('plus')\" class=\"w-3.5 h-3.5\"></svg>\n {{ filterLabel('addRule') }}\n </button>\n </div>\n }\n }\n }\n\n <div class=\"flex items-center justify-between gap-2 p-2 border-t _shk-border\">\n <button\n type=\"button\"\n class=\"px-3 py-1.5 font-medium rounded-md border _shk-border _shk-text-surface-600 hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] transition-colors\"\n (click)=\"clearFilter(col.field)\"\n >\n {{ filterLabel('clear') }}\n </button>\n <button\n type=\"button\"\n class=\"px-3 py-1.5 font-medium rounded-md _shk-bg-primary text-white hover:[background-color:var(--shk-primary-700)] transition-colors\"\n (click)=\"applyFilter(col)\"\n >\n {{ filterLabel('apply') }}\n </button>\n </div>\n </div>\n }\n } @else {\n <div class=\"flex items-center justify-center\">\n <span>{{ col.header }}</span>\n </div>\n }\n @if (isResizable()) {\n <span\n class=\"shk-col-resizer\"\n [class.shk-resizing]=\"resizingField() === col.field\"\n role=\"separator\"\n aria-orientation=\"vertical\"\n tabindex=\"0\"\n [attr.aria-label]=\"tr('table.resizeColumn', 'Redimensionar columna') + ': ' + col.header\"\n [attr.aria-valuenow]=\"resizedWidthPx(col)\"\n (pointerdown)=\"startResize($event, col)\"\n (click)=\"$event.stopPropagation()\"\n (dblclick)=\"$event.stopPropagation(); resetColumnWidth(col)\"\n (keydown)=\"onResizerKeydown($event, col)\"\n ></span>\n }\n </th>\n }\n </tr>\n </thead>\n @if (loading()) {\n <tbody class=\"border-b _shk-border\">\n <tr>\n <td [attr.colspan]=\"totalColspan()\" class=\"text-center py-12\">\n <div\n class=\"flex items-center justify-center\"\n role=\"status\"\n [attr.aria-label]=\"'common.loading' | transloco\"\n >\n <svg\n [shkIcon]=\"getIcon('loader')\"\n class=\"w-6 h-6 animate-spin _shk-text-primary\"\n ></svg>\n </div>\n </td>\n </tr>\n </tbody>\n } @else if (effectiveDisplayedData().length === 0) {\n <tbody class=\"border-b _shk-border\">\n <tr>\n <td [attr.colspan]=\"totalColspan()\" class=\"text-center py-12\">\n <div class=\"flex flex-col items-center\">\n <div\n class=\"w-16 h-16 _shk-bg-surface-100 rounded-full flex items-center justify-center mb-4\"\n >\n <svg\n [shkIcon]=\"getIcon('inbox')\"\n class=\"w-8 h-8 _shk-text-surface-400\"\n ></svg>\n </div>\n <p\n class=\"text-lg font-semibold _shk-text-surface-600\"\n >\n {{ emptyMessage() || ('common.no_records' | transloco) }}\n </p>\n </div>\n </td>\n </tr>\n </tbody>\n } @else {\n <tbody>\n @for (rowData of effectiveDisplayedData(); track trackByRow(rowData, $index)) {\n @let rowSeverityValue = rowSeverity(rowData);\n <tr\n [attr.aria-selected]=\"selectable() ? isRowSelected(rowData) : null\"\n [class.shk-row-selected]=\"selectable() && isRowSelected(rowData)\"\n [class.shk-row-low]=\"rowSeverityValue === 'low'\"\n [class.shk-row-moderate]=\"rowSeverityValue === 'moderate'\"\n [class.shk-row-critical]=\"rowSeverityValue === 'critical'\"\n [class.cursor-pointer]=\"selectable() && selectOnRowClick() && canSelectRow(rowData)\"\n (click)=\"onRowClick($event, rowData)\"\n class=\"shk-data-row transition-colors duration-200 border-b _shk-border\"\n >\n @if (selectable()) {\n <td data-shk-select class=\"w-10 px-2 min-[1440px]:px-3 py-2 min-[1440px]:py-2.5 text-center\">\n <input\n type=\"checkbox\"\n class=\"shk-table-checkbox\"\n [checked]=\"isRowSelected(rowData)\"\n [disabled]=\"!canSelectRow(rowData)\"\n (change)=\"toggleRowSelection(rowData)\"\n [attr.aria-label]=\"'table.selectRow' | transloco: { index: first() + $index + 1 }\"\n />\n </td>\n }\n @for (col of columnsWithActions(); track col.field) {\n <td\n [attr.data-shk-actions]=\"col.field === 'actions' ? '' : null\"\n [class]=\"\n 'px-2 min-[1440px]:px-3 py-2 min-[1440px]:py-2.5 text-xs font-medium _shk-text-surface-700 dark:[color:var(--shk-surface-700)] ' +\n (col.field === 'actions' ? 'whitespace-nowrap' : 'whitespace-normal break-words')\n \"\n [style.--shk-col-width]=\"col.field !== 'actions' ? getColumnWidth(col) : null\"\n >\n @if (col.field !== 'actions') {\n @switch (col.template) {\n @case ('tag') {\n <shk-tag\n [value]=\"getTagValue(col, rowData)\"\n [severity]=\"getTagSeverity(col, rowData)\"\n [rounded]=\"getTagRounded(col, rowData)\"\n [icon]=\"getTagIcon(col, rowData)\"\n [style]=\"getTagStyle(col, rowData)\"\n />\n }\n @case ('progress') {\n <div\n class=\"shk-progress\"\n role=\"progressbar\"\n aria-valuemin=\"0\"\n aria-valuemax=\"100\"\n [attr.aria-valuenow]=\"getProgress(col, rowData)\"\n [attr.aria-label]=\"col.header\"\n >\n <div [style.width.%]=\"getProgress(col, rowData)\"></div>\n </div>\n }\n @case ('boolean') {\n @if (resolveField(rowData, col.field)) {\n <svg\n [shkIcon]=\"icons.yes\"\n class=\"w-4 h-4 [color:var(--shk-success-600)]\"\n role=\"img\"\n [attr.aria-label]=\"filterLabel('yes')\"\n ></svg>\n } @else {\n <svg\n [shkIcon]=\"icons.no\"\n class=\"w-4 h-4 [color:var(--shk-error-500)]\"\n role=\"img\"\n [attr.aria-label]=\"filterLabel('no')\"\n ></svg>\n }\n }\n @case ('date') {\n {{ formatDateCell(resolveField(rowData, col.field), col) }}\n }\n @case ('currency') {\n {{ formatCurrencyCell(resolveField(rowData, col.field), col) }}\n }\n @default {\n @if (col.image) {\n <div class=\"flex items-center gap-2\">\n @if (col.image(rowData); as src) {\n <img\n [src]=\"src\"\n alt=\"\"\n [width]=\"col.imageWidth || 24\"\n class=\"shrink-0 rounded-sm\"\n />\n }\n <span>\n <ng-container\n *ngTemplateOutlet=\"cellText; context: { $implicit: rowData, col: col }\"\n ></ng-container>\n </span>\n </div>\n } @else {\n <ng-container\n *ngTemplateOutlet=\"cellText; context: { $implicit: rowData, col: col }\"\n ></ng-container>\n }\n }\n }\n } @else {\n <div class=\"flex items-center justify-start gap-px\">\n @for (action of getVisibleRowActions(rowData); track $index) {\n @if (isRowActionVisible(action, rowData)) {\n <div class=\"relative group\">\n <shk-tooltip\n [text]=\"getRowActionLabel(action, rowData)\"\n position=\"top\"\n >\n <button\n type=\"button\"\n (click)=\"action.onClick(rowData)\"\n [class]=\"\n 'table-action-btn hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] rounded-md ' +\n getRowActionClass(action, rowData)\n \"\n [disabled]=\"isRowActionDisabled(action, rowData) || false\"\n [attr.aria-label]=\"getRowActionLabel(action, rowData)\"\n >\n <svg\n [shkIcon]=\"getIcon(getRowActionIconName(action, rowData))\"\n class=\"w-4 h-4\"\n ></svg>\n </button>\n </shk-tooltip>\n </div>\n }\n }\n @if (getHiddenRowActions(rowData).length > 0) {\n <div class=\"relative\">\n <shk-tooltip\n [text]=\"'common.more_options' | transloco\"\n position=\"top\"\n >\n <button\n type=\"button\"\n (click)=\"$event.stopPropagation(); toggleActionsDropdown(rowData, $event)\"\n class=\"table-action-btn hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] rounded-md\"\n [attr.aria-label]=\"'common.more_options' | transloco\"\n [attr.aria-expanded]=\"isActionsDropdownOpen(rowData)\"\n >\n <svg\n [shkIcon]=\"getIcon('ellipsis-vertical')\"\n class=\"w-4 h-4\"\n ></svg>\n </button>\n </shk-tooltip>\n @if (isActionsDropdownOpen(rowData)) {\n <div\n shkPortal\n class=\"fixed z-[9999] min-w-[160px] bg-white dark:[background-color:var(--shk-surface-100)] border _shk-border rounded-md shadow-lg py-1\"\n [style.top]=\"dropdownPosition().top + 'px'\"\n [style.left]=\"dropdownPosition().left + 'px'\"\n >\n @for (action of getHiddenRowActions(rowData); track $index) {\n <button\n type=\"button\"\n (click)=\"action.onClick(rowData); toggleActionsDropdown(rowData)\"\n [disabled]=\"isRowActionDisabled(action, rowData) || false\"\n [class]=\"\n 'w-full flex items-center gap-2 px-3 py-2 text-xs text-left _shk-text-surface-700 dark:[color:var(--shk-surface-700)] hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] disabled:opacity-40 disabled:cursor-not-allowed transition-colors ' +\n getRowActionClass(action, rowData)\n \"\n >\n <svg\n [shkIcon]=\"getIcon(getRowActionIconName(action, rowData))\"\n class=\"w-3.5 h-3.5 shrink-0\"\n ></svg>\n <span>{{ getRowActionLabel(action, rowData) }}</span>\n </button>\n }\n </div>\n }\n </div>\n }\n @if (rowSeverityValue) {\n <div class=\"relative group\">\n <shk-tooltip [text]=\"rowValidationTitle(rowData) || ''\" position=\"top\">\n <span\n class=\"shk-row-validation-btn\"\n [class.shk-sev-low]=\"rowSeverityValue === 'low'\"\n [class.shk-sev-moderate]=\"rowSeverityValue === 'moderate'\"\n [class.shk-sev-critical]=\"rowSeverityValue === 'critical'\"\n tabindex=\"0\"\n role=\"note\"\n [attr.aria-label]=\"rowValidationLabel(rowData)\"\n >\n <svg [shkIcon]=\"rowValidationIcon(rowData)\"></svg>\n </span>\n </shk-tooltip>\n </div>\n }\n </div>\n }\n </td>\n }\n </tr>\n }\n </tbody>\n }\n </table>\n\n <!-- Text content of a cell: format() · custom template · raw value -->\n <ng-template #cellText let-rowData let-col=\"col\">\n @if (col.format) {\n <span>{{ col.format(rowData) }}</span>\n } @else {\n <ng-container\n *ngTemplateOutlet=\"\n customTemplates()[col.field] || defaultTemplate;\n context: { $implicit: rowData, field: col.field }\n \"\n ></ng-container>\n }\n </ng-template>\n <ng-template #defaultTemplate let-rowData let-field=\"field\">\n {{ resolveField(rowData, field) }}\n </ng-template>\n\n <!-- Option list of the select / multiselect filters -->\n <ng-template #optionList let-col let-draft=\"draft\" let-multiple=\"multiple\">\n <div class=\"p-2 space-y-1.5\">\n @let selectedLabel = multiple ? selectedOptionsLabel(col) : selectedSingleLabel(col);\n <button\n type=\"button\"\n class=\"shk-filter-select flex items-center justify-between gap-2 text-left\"\n style=\"background-image: none\"\n [id]=\"uid + '-filter-' + safeId(col.field) + '-0'\"\n [attr.aria-expanded]=\"multiselectOpen()\"\n (click)=\"multiselectOpen.set(!multiselectOpen())\"\n >\n <span class=\"truncate\" [class._shk-text-surface-400]=\"!selectedLabel\">\n {{ selectedLabel || tr('table.filterAll', 'Todos') }}\n </span>\n <svg\n [shkIcon]=\"getIcon('chevron-down')\"\n class=\"w-3.5 h-3.5 shrink-0 _shk-text-surface-400 transition-transform\"\n [class.rotate-180]=\"multiselectOpen()\"\n ></svg>\n </button>\n @if (multiselectOpen()) {\n <div\n class=\"max-h-52 overflow-y-auto p-0.5 border _shk-border rounded-md _shk-scrollbar\"\n role=\"listbox\"\n [attr.aria-multiselectable]=\"multiple\"\n >\n @for (opt of col.filterOptions || []; track $index) {\n @let isSelected = multiple\n ? isOptionSelected(opt.value)\n : draft.rules[0].value != null && draft.rules[0].value == opt.value;\n <button\n type=\"button\"\n role=\"option\"\n class=\"w-full flex items-center gap-2 px-2 py-1.5 rounded text-left transition-colors hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)]\"\n [class._shk-bg-primary-soft]=\"isSelected\"\n [class._shk-text-primary-700]=\"isSelected\"\n [attr.aria-selected]=\"isSelected\"\n (click)=\"multiple ? toggleOption(col, opt.value) : selectOption(col, opt.value)\"\n >\n @if (multiple) {\n <span class=\"shk-checkbox-box\" [class.shk-checked]=\"isSelected\">\n @if (isSelected) {\n <svg [shkIcon]=\"getIcon('check')\"></svg>\n }\n </span>\n }\n @if (opt.image) {\n <img [src]=\"opt.image\" alt=\"\" width=\"22\" class=\"shrink-0 rounded-sm\" />\n }\n <span class=\"truncate\">{{ opt.label }}</span>\n </button>\n }\n </div>\n }\n </div>\n </ng-template>\n </div>\n <div\n class=\"table-pagination flex items-center justify-between gap-4 px-2 min-[1440px]:px-3 py-2 border-t _shk-border\"\n >\n <div class=\"text-xs _shk-text-surface-600\">\n @if (showPageReport()) {\n {{ pageReport() }}\n }\n </div>\n <div\n class=\"flex items-center gap-0.5\"\n role=\"navigation\"\n >\n <button\n type=\"button\"\n (click)=\"goToFirst()\"\n [disabled]=\"isFirstPage()\"\n [attr.aria-label]=\"tr('table.firstPage', 'Primera página')\"\n class=\"shk-page-btn p-1 _shk-text-surface-500 hover:[color:var(--shk-surface-700)] dark:hover:[color:var(--shk-surface-200)] disabled:opacity-30 disabled:cursor-not-allowed rounded transition-colors\"\n >\n <svg [shkIcon]=\"getIcon('chevrons-left')\" class=\"w-4 h-4\"></svg>\n </button>\n <button\n type=\"button\"\n (click)=\"prev()\"\n [disabled]=\"isFirstPage()\"\n [attr.aria-label]=\"tr('table.prevPage', 'Página anterior')\"\n class=\"shk-page-btn p-1 _shk-text-surface-500 hover:[color:var(--shk-surface-700)] dark:hover:[color:var(--shk-surface-200)] disabled:opacity-30 disabled:cursor-not-allowed rounded transition-colors\"\n >\n <svg [shkIcon]=\"getIcon('chevron-left')\" class=\"w-4 h-4\"></svg>\n </button>\n <span\n class=\"px-2 text-xs font-medium _shk-text-surface-700\"\n >{{ currentPage() }} / {{ totalPages() }}</span\n >\n <button\n type=\"button\"\n (click)=\"next()\"\n [disabled]=\"isLastPage()\"\n [attr.aria-label]=\"tr('table.nextPage', 'Página siguiente')\"\n class=\"shk-page-btn p-1 _shk-text-surface-500 hover:[color:var(--shk-surface-700)] dark:hover:[color:var(--shk-surface-200)] disabled:opacity-30 disabled:cursor-not-allowed rounded transition-colors\"\n >\n <svg [shkIcon]=\"getIcon('chevron-right')\" class=\"w-4 h-4\"></svg>\n </button>\n <button\n type=\"button\"\n (click)=\"goToLast()\"\n [disabled]=\"isLastPage()\"\n [attr.aria-label]=\"tr('table.lastPage', 'Última página')\"\n class=\"shk-page-btn p-1 _shk-text-surface-500 hover:[color:var(--shk-surface-700)] dark:hover:[color:var(--shk-surface-200)] disabled:opacity-30 disabled:cursor-not-allowed rounded transition-colors\"\n >\n <svg [shkIcon]=\"getIcon('chevrons-right')\" class=\"w-4 h-4\"></svg>\n </button>\n </div>\n <div\n class=\"flex items-center gap-1.5 text-xs _shk-text-surface-600\"\n >\n @if (showRowsPerPage()) {\n <label [for]=\"uid + '-rows-per-page'\">{{ 'table.rows' | transloco }}</label>\n <select\n [id]=\"uid + '-rows-per-page'\"\n (change)=\"onRowsPerPageChange($any($event.target).value)\"\n class=\"border _shk-border rounded px-2 py-1 text-xs bg-white dark:[background-color:var(--shk-surface-100)] _shk-text-surface-700 focus:outline-none focus:[border-color:var(--shk-primary-500)]\"\n >\n @for (opt of rowsPerPageOptions(); track opt) {\n <option [value]=\"opt\" [selected]=\"opt === rowsPerPageLocal()\">{{ opt }}</option>\n }\n </select>\n }\n </div>\n </div>\n </div>\n</div>\n",
1589
+ styles: ["input:focus{outline:none}input[type=text]{font-weight:400!important}table th{white-space:nowrap}table td{white-space:normal;overflow-wrap:break-word}.shk-page-btn{display:inline-flex;align-items:center;justify-content:center;width:1.75rem;height:1.75rem;border-radius:.375rem;transition:background-color .15s ease,color .15s ease}.shk-page-btn:hover:not(:disabled){background-color:var(--shk-surface-100)}:host-context(.dark) .shk-page-btn:hover:not(:disabled){background-color:var(--shk-surface-200)}.shk-page-btn:focus-visible{outline:none;box-shadow:0 0 0 2px color-mix(in srgb,var(--shk-primary-500) 45%,transparent)}td button svg{width:1.125rem!important;height:1.125rem!important}td button:disabled{opacity:.4;cursor:not-allowed}.table-action-btn svg{width:1rem!important;height:1rem!important;min-width:1rem!important;min-height:1rem!important}.table-action-btn{padding:.5rem!important;min-width:2rem!important;min-height:2rem!important;display:inline-flex!important;align-items:center!important;justify-content:center!important}.table-scroll-wrapper{width:100%;overflow-x:auto;overflow-y:hidden;border-radius:inherit;-webkit-overflow-scrolling:touch;container-type:inline-size}.table-card,.table-pagination{container-type:inline-size}@container (max-width: 640px){.table-pagination{flex-direction:column;align-items:center;gap:.5rem}.table-pagination>div{justify-content:center}}.table-scroll-wrapper table{table-layout:auto;width:100%}@container (max-width: 768px){.table-scroll-wrapper{scroll-snap-type:x mandatory}.table-scroll-wrapper table{table-layout:auto;width:100%}.table-scroll-wrapper th:not([data-shk-actions]):not([data-shk-select]){min-width:var(--shk-col-width, 140px)}.table-scroll-wrapper td:not([data-shk-actions]):not([data-shk-select]){min-width:var(--shk-col-width, 140px);max-width:var(--shk-col-width, 140px)}.table-scroll-wrapper th,.table-scroll-wrapper td{scroll-snap-align:start}}th[data-shk-select],td[data-shk-select]{width:2.5rem;min-width:2.5rem}.shk-table-checkbox{width:.875rem;height:.875rem;cursor:pointer;vertical-align:middle;accent-color:var(--shk-primary-500)}.shk-table-checkbox:disabled{opacity:.4;cursor:not-allowed}tr.shk-row-selected{background-color:color-mix(in srgb,var(--shk-primary-50) 60%,transparent)}tr.shk-row-selected:hover{background-color:color-mix(in srgb,var(--shk-primary-50) 90%,transparent)}:host-context(.dark) tr.shk-row-selected{background-color:color-mix(in srgb,var(--shk-primary-900) 20%,transparent)}:host-context(.dark) tr.shk-row-selected:hover{background-color:color-mix(in srgb,var(--shk-primary-900) 30%,transparent)}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.shk-data-table tr.shk-row-low{background-color:color-mix(in srgb,var(--shk-info-600) 22%,transparent)}.shk-data-table tr.shk-row-moderate{background-color:color-mix(in srgb,var(--shk-warning-400) 32%,transparent)}.shk-data-table tr.shk-row-critical{background-color:color-mix(in srgb,var(--shk-error-500) 20%,transparent)}:host-context(.dark) .shk-data-table tr.shk-row-low{background-color:color-mix(in srgb,var(--shk-info-600) 26%,transparent)}:host-context(.dark) .shk-data-table tr.shk-row-moderate{background-color:color-mix(in srgb,var(--shk-warning-400) 34%,transparent)}:host-context(.dark) .shk-data-table tr.shk-row-critical{background-color:color-mix(in srgb,var(--shk-error-500) 24%,transparent)}.shk-row-validation-btn{display:inline-flex;align-items:center;justify-content:center;padding:.25rem;border-radius:.375rem;cursor:help;color:var(--shk-surface-500)}.shk-row-validation-btn svg{width:1rem!important;height:1rem!important}.shk-row-validation-btn.shk-sev-low{color:var(--shk-info-600)}.shk-row-validation-btn.shk-sev-moderate{color:var(--shk-warning-600)}:host-context(.dark) .shk-row-validation-btn.shk-sev-moderate{color:var(--shk-warning-400)}.shk-row-validation-btn.shk-sev-critical{color:var(--shk-error-500)}.shk-row-validation-btn:focus-visible{outline:2px solid currentColor;outline-offset:1px}table.shk-row-hover tbody tr.shk-data-row:hover{background-color:color-mix(in srgb,var(--shk-primary-50) 30%,transparent)}:host-context(.dark) table.shk-row-hover tbody tr.shk-data-row:hover{background-color:color-mix(in srgb,var(--shk-primary-900) 10%,transparent)}table.shk-gridlines th,table.shk-gridlines td{border-right:1px solid var(--shk-surface-200)}table.shk-gridlines th:last-child,table.shk-gridlines td:last-child{border-right:0}:host-context(.dark) table.shk-gridlines th,:host-context(.dark) table.shk-gridlines td{border-right-color:var(--shk-surface-200)}.shk-col-resizer{position:absolute;top:0;right:-4px;z-index:1;width:8px;height:100%;cursor:col-resize;touch-action:none}.shk-col-resizer:after{content:\"\";position:absolute;top:20%;bottom:20%;left:3px;width:2px;border-radius:1px;background-color:transparent;transition:background-color .15s ease}.shk-col-resizer:hover:after,.shk-col-resizer:focus-visible:after,.shk-col-resizer.shk-resizing:after{background-color:var(--shk-primary-500)}.shk-col-resizer:focus-visible{outline:none}th:last-child .shk-col-resizer{right:0}.shk-filter-input,.shk-filter-select{width:100%;padding:.375rem .625rem;font-size:.75rem;line-height:1.25rem;border-radius:.375rem;border:1px solid var(--shk-surface-200);background-color:#fff;color:var(--shk-surface-700)}.dark .shk-filter-input,.dark .shk-filter-select{background-color:var(--shk-surface-100);border-color:var(--shk-surface-200);color-scheme:dark}.shk-filter-input::placeholder{color:var(--shk-surface-400)}select.shk-filter-select{appearance:none;padding-right:1.75rem;background-image:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E\");background-repeat:no-repeat;background-position:right .5rem center;cursor:pointer}button.shk-filter-select{cursor:pointer}.shk-filter-input:focus,.shk-filter-select:focus{outline:none;border-color:var(--shk-primary-500);box-shadow:0 0 0 1px var(--shk-primary-500)}.shk-checkbox-box{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;width:.875rem;height:.875rem;border-radius:.1875rem;border:1px solid var(--shk-surface-300);background-color:#fff;color:#fff}.dark .shk-checkbox-box{background-color:var(--shk-surface-100)}.shk-checkbox-box.shk-checked{background-color:var(--shk-primary-500);border-color:var(--shk-primary-500)}.shk-checkbox-box svg{width:.625rem;height:.625rem}.shk-range{position:relative;height:1rem;margin:.5rem .375rem .375rem}.shk-range-track,.shk-range-fill{position:absolute;top:50%;height:.1875rem;transform:translateY(-50%);border-radius:9999px}.shk-range-track{left:0;right:0;background-color:var(--shk-surface-200)}.shk-range-fill{background-color:var(--shk-primary-500)}.shk-range input[type=range]{position:absolute;inset:0;width:100%;margin:0;background:transparent;pointer-events:none;appearance:none;-webkit-appearance:none}.shk-range input[type=range]::-webkit-slider-thumb{pointer-events:auto;-webkit-appearance:none;width:.875rem;height:.875rem;border-radius:9999px;background:#fff;border:2px solid var(--shk-primary-500);cursor:grab}.shk-range input[type=range]::-moz-range-thumb{pointer-events:auto;width:.625rem;height:.625rem;border-radius:9999px;background:#fff;border:2px solid var(--shk-primary-500);cursor:grab}.shk-progress{height:.375rem;min-width:5rem;border-radius:9999px;background-color:var(--shk-surface-200);overflow:hidden}.shk-progress>div{height:100%;border-radius:inherit;background-color:var(--shk-primary-500)}\n"]
1590
+ }]
1591
+ }],
1592
+ ctorParameters: () => [],
1593
+ propDecorators: {
1594
+ data: [{
1595
+ type: i0.Input,
1596
+ args: [{
1597
+ isSignal: true,
1598
+ alias: "data",
1599
+ required: false
1600
+ }]
1601
+ }],
1602
+ columns: [{
1603
+ type: i0.Input,
1604
+ args: [{
1605
+ isSignal: true,
1606
+ alias: "columns",
1607
+ required: false
1608
+ }]
1609
+ }],
1610
+ rowsPerPage: [{
1611
+ type: i0.Input,
1612
+ args: [{
1613
+ isSignal: true,
1614
+ alias: "rowsPerPage",
1615
+ required: false
1616
+ }]
1617
+ }],
1618
+ rowsPerPageOptions: [{
1619
+ type: i0.Input,
1620
+ args: [{
1621
+ isSignal: true,
1622
+ alias: "rowsPerPageOptions",
1623
+ required: false
1624
+ }]
1625
+ }],
1626
+ loading: [{
1627
+ type: i0.Input,
1628
+ args: [{
1629
+ isSignal: true,
1630
+ alias: "loading",
1631
+ required: false
1632
+ }]
1633
+ }],
1634
+ showActionRow: [{
1635
+ type: i0.Input,
1636
+ args: [{
1637
+ isSignal: true,
1638
+ alias: "showActionRow",
1639
+ required: false
1640
+ }]
1641
+ }],
1642
+ customTemplates: [{
1643
+ type: i0.Input,
1644
+ args: [{
1645
+ isSignal: true,
1646
+ alias: "customTemplates",
1647
+ required: false
1648
+ }]
1649
+ }],
1650
+ headerActions: [{
1651
+ type: i0.Input,
1652
+ args: [{
1653
+ isSignal: true,
1654
+ alias: "headerActions",
1655
+ required: false
1656
+ }]
1657
+ }],
1658
+ rowActions: [{
1659
+ type: i0.Input,
1660
+ args: [{
1661
+ isSignal: true,
1662
+ alias: "rowActions",
1663
+ required: false
1664
+ }]
1665
+ }],
1666
+ hasShadow: [{
1667
+ type: i0.Input,
1668
+ args: [{
1669
+ isSignal: true,
1670
+ alias: "hasShadow",
1671
+ required: false
1672
+ }]
1673
+ }],
1674
+ defaultSortField: [{
1675
+ type: i0.Input,
1676
+ args: [{
1677
+ isSignal: true,
1678
+ alias: "defaultSortField",
1679
+ required: false
1680
+ }]
1681
+ }],
1682
+ defaultSortOrder: [{
1683
+ type: i0.Input,
1684
+ args: [{
1685
+ isSignal: true,
1686
+ alias: "defaultSortOrder",
1687
+ required: false
1688
+ }]
1689
+ }],
1690
+ showSearch: [{
1691
+ type: i0.Input,
1692
+ args: [{
1693
+ isSignal: true,
1694
+ alias: "showSearch",
1695
+ required: false
1696
+ }]
1697
+ }],
1698
+ searchPlaceholder: [{
1699
+ type: i0.Input,
1700
+ args: [{
1701
+ isSignal: true,
1702
+ alias: "searchPlaceholder",
1703
+ required: false
1704
+ }]
1705
+ }],
1706
+ globalFilterFields: [{
1707
+ type: i0.Input,
1708
+ args: [{
1709
+ isSignal: true,
1710
+ alias: "globalFilterFields",
1711
+ required: false
1712
+ }]
1713
+ }],
1714
+ emptyMessage: [{
1715
+ type: i0.Input,
1716
+ args: [{
1717
+ isSignal: true,
1718
+ alias: "emptyMessage",
1719
+ required: false
1720
+ }]
1721
+ }],
1722
+ serverSide: [{
1723
+ type: i0.Input,
1724
+ args: [{
1725
+ isSignal: true,
1726
+ alias: "serverSide",
1727
+ required: false
1728
+ }]
1729
+ }],
1730
+ totalRecords: [{
1731
+ type: i0.Input,
1732
+ args: [{
1733
+ isSignal: true,
1734
+ alias: "totalRecords",
1735
+ required: false
1736
+ }]
1737
+ }],
1738
+ filters: [{
1739
+ type: i0.Input,
1740
+ args: [{
1741
+ isSignal: true,
1742
+ alias: "filters",
1743
+ required: false
1744
+ }]
1745
+ }],
1746
+ activeFilter: [{
1747
+ type: i0.Input,
1748
+ args: [{
1749
+ isSignal: true,
1750
+ alias: "activeFilter",
1751
+ required: false
1752
+ }]
1753
+ }],
1754
+ showGridlines: [{
1755
+ type: i0.Input,
1756
+ args: [{
1757
+ isSignal: true,
1758
+ alias: "showGridlines",
1759
+ required: false
1760
+ }]
1761
+ }],
1762
+ resizableColumns: [{
1763
+ type: i0.Input,
1764
+ args: [{
1765
+ isSignal: true,
1766
+ alias: "resizableColumns",
1767
+ required: false
1768
+ }]
1769
+ }],
1770
+ rowValidations: [{
1771
+ type: i0.Input,
1772
+ args: [{
1773
+ isSignal: true,
1774
+ alias: "rowValidations",
1775
+ required: false
1776
+ }]
1777
+ }],
1778
+ columnWidths: [{
1779
+ type: i0.Input,
1780
+ args: [{
1781
+ isSignal: true,
1782
+ alias: "columnWidths",
1783
+ required: false
1784
+ }]
1785
+ }, {
1786
+ type: i0.Output,
1787
+ args: ["columnWidthsChange"]
1788
+ }],
1789
+ stateKey: [{
1790
+ type: i0.Input,
1791
+ args: [{
1792
+ isSignal: true,
1793
+ alias: "stateKey",
1794
+ required: false
1795
+ }]
1796
+ }],
1797
+ stateStorage: [{
1798
+ type: i0.Input,
1799
+ args: [{
1800
+ isSignal: true,
1801
+ alias: "stateStorage",
1802
+ required: false
1803
+ }]
1804
+ }],
1805
+ rowHover: [{
1806
+ type: i0.Input,
1807
+ args: [{
1808
+ isSignal: true,
1809
+ alias: "rowHover",
1810
+ required: false
1811
+ }]
1812
+ }],
1813
+ showClearButton: [{
1814
+ type: i0.Input,
1815
+ args: [{
1816
+ isSignal: true,
1817
+ alias: "showClearButton",
1818
+ required: false
1819
+ }]
1820
+ }],
1821
+ showPageReport: [{
1822
+ type: i0.Input,
1823
+ args: [{
1824
+ isSignal: true,
1825
+ alias: "showPageReport",
1826
+ required: false
1827
+ }]
1828
+ }],
1829
+ showRowsPerPage: [{
1830
+ type: i0.Input,
1831
+ args: [{
1832
+ isSignal: true,
1833
+ alias: "showRowsPerPage",
1834
+ required: false
1835
+ }]
1836
+ }],
1837
+ selectable: [{
1838
+ type: i0.Input,
1839
+ args: [{
1840
+ isSignal: true,
1841
+ alias: "selectable",
1842
+ required: false
1843
+ }]
1844
+ }],
1845
+ dataKey: [{
1846
+ type: i0.Input,
1847
+ args: [{
1848
+ isSignal: true,
1849
+ alias: "dataKey",
1850
+ required: false
1851
+ }]
1852
+ }],
1853
+ isRowSelectable: [{
1854
+ type: i0.Input,
1855
+ args: [{
1856
+ isSignal: true,
1857
+ alias: "isRowSelectable",
1858
+ required: false
1859
+ }]
1860
+ }],
1861
+ selectOnRowClick: [{
1862
+ type: i0.Input,
1863
+ args: [{
1864
+ isSignal: true,
1865
+ alias: "selectOnRowClick",
1866
+ required: false
1867
+ }]
1868
+ }],
1869
+ bulkActions: [{
1870
+ type: i0.Input,
1871
+ args: [{
1872
+ isSignal: true,
1873
+ alias: "bulkActions",
1874
+ required: false
1875
+ }]
1876
+ }],
1877
+ selection: [{
1878
+ type: i0.Input,
1879
+ args: [{
1880
+ isSignal: true,
1881
+ alias: "selection",
1882
+ required: false
1883
+ }]
1884
+ }, {
1885
+ type: i0.Output,
1886
+ args: ["selectionChange"]
1887
+ }],
1888
+ refresh: [{
1889
+ type: i0.Output,
1890
+ args: ["refresh"]
1891
+ }],
1892
+ pageChange: [{
1893
+ type: i0.Output,
1894
+ args: ["pageChange"]
1895
+ }],
1896
+ filterChange: [{
1897
+ type: i0.Output,
1898
+ args: ["filterChange"]
1899
+ }],
1900
+ searchChange: [{
1901
+ type: i0.Output,
1902
+ args: ["searchChange"]
1903
+ }],
1904
+ filterClick: [{
1905
+ type: i0.Output,
1906
+ args: ["filterClick"]
1907
+ }],
1908
+ columnResize: [{
1909
+ type: i0.Output,
1910
+ args: ["columnResize"]
1911
+ }],
1912
+ onDocumentClick: [{
1913
+ type: HostListener,
1914
+ args: ["document:click"]
1915
+ }],
1916
+ onEscape: [{
1917
+ type: HostListener,
1918
+ args: ["document:keydown.escape"]
1919
+ }]
1920
+ }
1921
+ });
1705
1922
  export { TableComponent };
1706
- //# sourceMappingURL=shirkasoft-ui-components-table.mjs.map
1923
+
1924
+ //# sourceMappingURL=shirkasoft-ui-components-table.mjs.map