shirkasoft-ui-components 1.3.10 → 1.3.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +117 -7
- package/fesm2022/shirkasoft-ui-components-date-picker.mjs +66 -5
- package/fesm2022/shirkasoft-ui-components-date-picker.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-modal.mjs +5 -2
- package/fesm2022/shirkasoft-ui-components-modal.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-rail-sidebar.mjs +96 -10
- package/fesm2022/shirkasoft-ui-components-rail-sidebar.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-table.mjs +862 -212
- package/fesm2022/shirkasoft-ui-components-table.mjs.map +1 -1
- package/fesm2022/shirkasoft-ui-components-utils.mjs +2 -1
- package/fesm2022/shirkasoft-ui-components-utils.mjs.map +1 -1
- package/package.json +1 -1
- package/types/shirkasoft-ui-components-date-picker.d.ts +23 -0
- package/types/shirkasoft-ui-components-modal.d.ts +4 -1
- package/types/shirkasoft-ui-components-rail-sidebar.d.ts +41 -7
- package/types/shirkasoft-ui-components-table.d.ts +305 -41
|
@@ -1,18 +1,49 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject, ChangeDetectorRef, DestroyRef, input, model, output, signal, linkedSignal, computed, afterEveryRender, effect, untracked, HostListener, ChangeDetectionStrategy, Component } 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
3
|
import * as i1 from '@angular/common';
|
|
4
4
|
import { CommonModule } from '@angular/common';
|
|
5
5
|
import { toSignal, takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
6
|
-
import * as i2 from '@
|
|
7
|
-
import { FormBuilder, ReactiveFormsModule } from '@angular/forms';
|
|
8
|
-
import * as i3 from '@jsverse/transloco';
|
|
6
|
+
import * as i2 from '@jsverse/transloco';
|
|
9
7
|
import { TranslocoService, TranslocoModule } from '@jsverse/transloco';
|
|
10
8
|
import { Subject, debounceTime } from 'rxjs';
|
|
11
|
-
import { LucidePlus, LucideDynamicIcon } from '@lucide/angular';
|
|
9
|
+
import { LucidePlus, LucideTrash2, LucideCircleX, LucideCircleCheck, LucideFunnelX, LucideDynamicIcon } from '@lucide/angular';
|
|
12
10
|
import { TagComponent } from 'shirkasoft-ui-components/tag';
|
|
13
11
|
import { TooltipComponent } from 'shirkasoft-ui-components/tooltip';
|
|
14
12
|
import { getIcon, PortalDirective } from 'shirkasoft-ui-components/utils';
|
|
15
13
|
|
|
14
|
+
/** Match modes offered by each filter kind that has a match mode selector. */
|
|
15
|
+
const MATCH_MODES = {
|
|
16
|
+
text: ['startsWith', 'contains', 'notContains', 'endsWith', 'equals', 'notEquals'],
|
|
17
|
+
numeric: ['equals', 'notEquals', 'lt', 'lte', 'gt', 'gte'],
|
|
18
|
+
date: ['dateIs', 'dateIsNot', 'dateBefore', 'dateAfter'],
|
|
19
|
+
};
|
|
20
|
+
/** Fallback labels used when the `table.filter.*` translations are missing. */
|
|
21
|
+
const FILTER_LABELS = {
|
|
22
|
+
startsWith: 'Empieza con',
|
|
23
|
+
contains: 'Contiene',
|
|
24
|
+
notContains: 'No contiene',
|
|
25
|
+
endsWith: 'Termina con',
|
|
26
|
+
equals: 'Igual a',
|
|
27
|
+
notEquals: 'Distinto de',
|
|
28
|
+
lt: 'Menor que',
|
|
29
|
+
lte: 'Menor o igual que',
|
|
30
|
+
gt: 'Mayor que',
|
|
31
|
+
gte: 'Mayor o igual que',
|
|
32
|
+
dateIs: 'La fecha es',
|
|
33
|
+
dateIsNot: 'La fecha no es',
|
|
34
|
+
dateBefore: 'La fecha es anterior a',
|
|
35
|
+
dateAfter: 'La fecha es posterior a',
|
|
36
|
+
matchAll: 'Coincidir todas',
|
|
37
|
+
matchAny: 'Coincidir alguna',
|
|
38
|
+
addRule: 'Agregar regla',
|
|
39
|
+
removeRule: 'Quitar regla',
|
|
40
|
+
apply: 'Aplicar',
|
|
41
|
+
clear: 'Limpiar',
|
|
42
|
+
any: 'Cualquiera',
|
|
43
|
+
selectedCount: '{{count}} seleccionados',
|
|
44
|
+
yes: 'Sí',
|
|
45
|
+
no: 'No',
|
|
46
|
+
};
|
|
16
47
|
/**
|
|
17
48
|
* Shirkasoft UI Components.
|
|
18
49
|
* Authors: Roberto Valladares Martin (Ansem13), Julio César García García (Sanjuli14).
|
|
@@ -21,23 +52,60 @@ import { getIcon, PortalDirective } from 'shirkasoft-ui-components/utils';
|
|
|
21
52
|
/** Counter used to generate unique element ids per table instance. */
|
|
22
53
|
let nextTableId = 0;
|
|
23
54
|
/**
|
|
24
|
-
* Data table with sorting, column
|
|
25
|
-
*
|
|
55
|
+
* Data table with sorting, column filter menus (match modes,
|
|
56
|
+
* multiple rules, typed filters), global search, pagination, row/header
|
|
57
|
+
* actions, tag/progress/boolean cells and optional server-side mode.
|
|
26
58
|
*/
|
|
27
59
|
class TableComponent {
|
|
28
60
|
/** Returns the effective CSS width for a column ('actions' included). */
|
|
29
61
|
getColumnWidth(col) {
|
|
30
|
-
return col.width || this.DEFAULT_COLUMN_WIDTH;
|
|
62
|
+
return this.resizedWidth(col) || col.width || this.DEFAULT_COLUMN_WIDTH;
|
|
63
|
+
}
|
|
64
|
+
/** Whether a value counts as missing: null, undefined, blank text or empty array. */
|
|
65
|
+
isEmptyValue(value) {
|
|
66
|
+
if (value === null || value === undefined)
|
|
67
|
+
return true;
|
|
68
|
+
if (typeof value === 'string')
|
|
69
|
+
return value.trim() === '';
|
|
70
|
+
if (Array.isArray(value))
|
|
71
|
+
return value.length === 0;
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
columnMissing(col, row) {
|
|
75
|
+
return col.isMissing ? !!col.isMissing(row) : this.isEmptyValue(this.resolveField(row, col.field));
|
|
76
|
+
}
|
|
77
|
+
/** Required columns that are empty in the row. */
|
|
78
|
+
missingFields(row) {
|
|
79
|
+
return this.missingByRow().get(row) ?? [];
|
|
80
|
+
}
|
|
81
|
+
/** Whether a cell is a required field without value. */
|
|
82
|
+
isCellMissing(col, row) {
|
|
83
|
+
return !!col.required && this.missingFields(row).includes(col);
|
|
84
|
+
}
|
|
85
|
+
missingCellMessage(col) {
|
|
86
|
+
return col.missingMessage || this.tr('table.missing.cell', 'Falta {{field}}', { field: col.header });
|
|
87
|
+
}
|
|
88
|
+
missingRowMessage(missing) {
|
|
89
|
+
return this.tr('table.missing.row', 'Faltan datos: {{fields}}', {
|
|
90
|
+
fields: missing.map((c) => c.header).join(', '),
|
|
91
|
+
});
|
|
31
92
|
}
|
|
32
93
|
constructor() {
|
|
33
94
|
/** Unique id prefix so several tables on the same page don't share element ids. */
|
|
34
95
|
this.uid = `shk-table-${nextTableId++}`;
|
|
35
|
-
this.fb = inject(FormBuilder);
|
|
36
96
|
this.cdr = inject(ChangeDetectorRef);
|
|
37
97
|
this.transloco = inject(TranslocoService);
|
|
38
98
|
this.destroyRef = inject(DestroyRef);
|
|
99
|
+
this.injector = inject(Injector);
|
|
39
100
|
/** Maps icon names to lucide components, falling back to a plus icon. */
|
|
40
101
|
this.getIcon = (name) => getIcon(name, LucidePlus);
|
|
102
|
+
/** Icons used directly by the template (not part of the central map). */
|
|
103
|
+
this.icons = {
|
|
104
|
+
clear: LucideFunnelX,
|
|
105
|
+
yes: LucideCircleCheck,
|
|
106
|
+
no: LucideCircleX,
|
|
107
|
+
trash: LucideTrash2,
|
|
108
|
+
};
|
|
41
109
|
/**
|
|
42
110
|
* Minimum width applied to each column (except `actions`, which keeps its
|
|
43
111
|
* own computed width) only on narrow screens. On wide screens columns
|
|
@@ -83,6 +151,11 @@ class TableComponent {
|
|
|
83
151
|
this.showSearch = input(true, ...(ngDevMode ? [{ debugName: "showSearch" }] : /* istanbul ignore next */ []));
|
|
84
152
|
/** Placeholder for the global search input. */
|
|
85
153
|
this.searchPlaceholder = input('', ...(ngDevMode ? [{ debugName: "searchPlaceholder" }] : /* istanbul ignore next */ []));
|
|
154
|
+
/**
|
|
155
|
+
* Fields (dot paths allowed) searched by the global search. When empty,
|
|
156
|
+
* every primitive top-level value of the row is searched.
|
|
157
|
+
*/
|
|
158
|
+
this.globalFilterFields = input([], ...(ngDevMode ? [{ debugName: "globalFilterFields" }] : /* istanbul ignore next */ []));
|
|
86
159
|
/** Message shown when there are no rows. */
|
|
87
160
|
this.emptyMessage = input('', ...(ngDevMode ? [{ debugName: "emptyMessage" }] : /* istanbul ignore next */ []));
|
|
88
161
|
/** Enables server-side pagination/filtering/sorting mode. */
|
|
@@ -93,6 +166,38 @@ class TableComponent {
|
|
|
93
166
|
this.filters = input([], ...(ngDevMode ? [{ debugName: "filters" }] : /* istanbul ignore next */ []));
|
|
94
167
|
/** Currently active filter chip value. */
|
|
95
168
|
this.activeFilter = input('', ...(ngDevMode ? [{ debugName: "activeFilter" }] : /* istanbul ignore next */ []));
|
|
169
|
+
/** Draws vertical lines between columns (grid look). */
|
|
170
|
+
this.showGridlines = input(false, ...(ngDevMode ? [{ debugName: "showGridlines" }] : /* istanbul ignore next */ []));
|
|
171
|
+
/**
|
|
172
|
+
* With `showGridlines`, lets the user widen/narrow columns by dragging the
|
|
173
|
+
* header border (double click resets, arrow keys adjust).
|
|
174
|
+
*/
|
|
175
|
+
this.resizableColumns = input(true, ...(ngDevMode ? [{ debugName: "resizableColumns" }] : /* istanbul ignore next */ []));
|
|
176
|
+
/**
|
|
177
|
+
* Highlights rows where a `required` column is empty: warning row, an icon
|
|
178
|
+
* listing the missing fields and a "Falta …" text in the empty cell.
|
|
179
|
+
*/
|
|
180
|
+
this.validateRequired = input(false, ...(ngDevMode ? [{ debugName: "validateRequired" }] : /* istanbul ignore next */ []));
|
|
181
|
+
/**
|
|
182
|
+
* Column widths (px) keyed by field. Two-way bindable via
|
|
183
|
+
* `[(columnWidths)]` to restore/save them yourself.
|
|
184
|
+
*/
|
|
185
|
+
this.columnWidths = model({}, ...(ngDevMode ? [{ debugName: "columnWidths" }] : /* istanbul ignore next */ []));
|
|
186
|
+
/**
|
|
187
|
+
* When set, column widths are saved in the browser storage under this key
|
|
188
|
+
* and restored on load (they take precedence over `columnWidths`).
|
|
189
|
+
*/
|
|
190
|
+
this.stateKey = input('', ...(ngDevMode ? [{ debugName: "stateKey" }] : /* istanbul ignore next */ []));
|
|
191
|
+
/** Storage used with `stateKey`. */
|
|
192
|
+
this.stateStorage = input('local', ...(ngDevMode ? [{ debugName: "stateStorage" }] : /* istanbul ignore next */ []));
|
|
193
|
+
/** Highlights the row under the pointer. */
|
|
194
|
+
this.rowHover = input(true, ...(ngDevMode ? [{ debugName: "rowHover" }] : /* istanbul ignore next */ []));
|
|
195
|
+
/** Shows the "Clear" button that resets search, column filters and sort. */
|
|
196
|
+
this.showClearButton = input(true, ...(ngDevMode ? [{ debugName: "showClearButton" }] : /* istanbul ignore next */ []));
|
|
197
|
+
/** Shows the "X to Y of Z" report in the paginator. */
|
|
198
|
+
this.showPageReport = input(true, ...(ngDevMode ? [{ debugName: "showPageReport" }] : /* istanbul ignore next */ []));
|
|
199
|
+
/** Shows the rows-per-page selector in the paginator. */
|
|
200
|
+
this.showRowsPerPage = input(true, ...(ngDevMode ? [{ debugName: "showRowsPerPage" }] : /* istanbul ignore next */ []));
|
|
96
201
|
/** Whether to render the leading checkbox column for multi-row selection. */
|
|
97
202
|
this.selectable = input(false, ...(ngDevMode ? [{ debugName: "selectable" }] : /* istanbul ignore next */ []));
|
|
98
203
|
/**
|
|
@@ -110,12 +215,14 @@ class TableComponent {
|
|
|
110
215
|
this.refresh = output();
|
|
111
216
|
/** Emits page changes (server-side mode) with first/rows/page info. */
|
|
112
217
|
this.pageChange = output();
|
|
113
|
-
/** Emits the active column filters. */
|
|
218
|
+
/** Emits the active column filters (server-side mode). */
|
|
114
219
|
this.filterChange = output();
|
|
115
220
|
/** Emits the debounced global search term. */
|
|
116
221
|
this.searchChange = output();
|
|
117
222
|
/** Emits when a filter chip is clicked. */
|
|
118
223
|
this.filterClick = output();
|
|
224
|
+
/** Emits when a column is resized (`width` in px, `null` when reset to auto). */
|
|
225
|
+
this.columnResize = output();
|
|
119
226
|
/** Internal copy of the input data used as the base for search/filter. */
|
|
120
227
|
this.originalData = signal([], ...(ngDevMode ? [{ debugName: "originalData" }] : /* istanbul ignore next */ []));
|
|
121
228
|
/** Rows after the global search is applied. */
|
|
@@ -128,8 +235,6 @@ class TableComponent {
|
|
|
128
235
|
this.localTotalRecords = signal(0, ...(ngDevMode ? [{ debugName: "localTotalRecords" }] : /* istanbul ignore next */ []));
|
|
129
236
|
/** Index of the first row of the current page. */
|
|
130
237
|
this.first = signal(0, ...(ngDevMode ? [{ debugName: "first" }] : /* istanbul ignore next */ []));
|
|
131
|
-
/** Visibility map for each column filter input. */
|
|
132
|
-
this.showFilterInput = signal({}, ...(ngDevMode ? [{ debugName: "showFilterInput" }] : /* istanbul ignore next */ []));
|
|
133
238
|
/** Current global search term. */
|
|
134
239
|
this.searchQuery = signal('', ...(ngDevMode ? [{ debugName: "searchQuery" }] : /* istanbul ignore next */ []));
|
|
135
240
|
/** Currently sorted field. */
|
|
@@ -138,19 +243,28 @@ class TableComponent {
|
|
|
138
243
|
this.sortOrder = signal(1, ...(ngDevMode ? [{ debugName: "sortOrder" }] : /* istanbul ignore next */ []));
|
|
139
244
|
/** Local rows per page, kept in sync with the `rowsPerPage` input. */
|
|
140
245
|
this.rowsPerPageLocal = linkedSignal(() => this.rowsPerPage(), ...(ngDevMode ? [{ debugName: "rowsPerPageLocal" }] : /* istanbul ignore next */ []));
|
|
246
|
+
/** Applied filter state of each filterable column, keyed by field. */
|
|
247
|
+
this.filterState = signal({}, ...(ngDevMode ? [{ debugName: "filterState" }] : /* istanbul ignore next */ []));
|
|
248
|
+
/** Field whose filter menu is open (only one at a time). */
|
|
249
|
+
this.openFilterField = signal(null, ...(ngDevMode ? [{ debugName: "openFilterField" }] : /* istanbul ignore next */ []));
|
|
250
|
+
/** Filter being edited in the open menu (committed on Apply). */
|
|
251
|
+
this.filterDraft = signal(null, ...(ngDevMode ? [{ debugName: "filterDraft" }] : /* istanbul ignore next */ []));
|
|
252
|
+
/** Whether the option list of the multiselect filter is expanded. */
|
|
253
|
+
this.multiselectOpen = signal(false, ...(ngDevMode ? [{ debugName: "multiselectOpen" }] : /* istanbul ignore next */ []));
|
|
141
254
|
/** Total number of pages based on the effective record count. */
|
|
142
255
|
this.totalPages = computed(() => Math.max(1, Math.ceil(this.effectiveTotalRecords() / this.rowsPerPageLocal())), ...(ngDevMode ? [{ debugName: "totalPages" }] : /* istanbul ignore next */ []));
|
|
143
256
|
/** Current page number (1-based). */
|
|
144
257
|
this.currentPage = computed(() => Math.floor(this.first() / this.rowsPerPageLocal()) + 1, ...(ngDevMode ? [{ debugName: "currentPage" }] : /* istanbul ignore next */ []));
|
|
258
|
+
/** Whether any column can be filtered. */
|
|
259
|
+
this.hasFilterableColumns = computed(() => this.columns().some((c) => c.filter), ...(ngDevMode ? [{ debugName: "hasFilterableColumns" }] : /* istanbul ignore next */ []));
|
|
145
260
|
/** Subjects used to debounce column filters (server mode) and search. */
|
|
146
261
|
this.filterSubject = new Subject();
|
|
147
262
|
this.searchSubject = new Subject();
|
|
148
263
|
/**
|
|
149
264
|
* Signature of the last built set of filterable fields (+filter type) to
|
|
150
|
-
* avoid
|
|
265
|
+
* avoid resetting the filters (and losing user input) on reference changes.
|
|
151
266
|
*/
|
|
152
267
|
this.lastFilterFieldsSignature = '';
|
|
153
|
-
this.columnFilterSubscriptions = [];
|
|
154
268
|
/** Columns array with the leading `actions` column when row actions exist. */
|
|
155
269
|
this.columnsWithActions = computed(() => {
|
|
156
270
|
const columnsArray = this.columns();
|
|
@@ -208,7 +322,36 @@ class TableComponent {
|
|
|
208
322
|
return this.bulkActions().filter((a) => (a.isVisible ? a.isVisible(selected) : true));
|
|
209
323
|
}, ...(ngDevMode ? [{ debugName: "visibleBulkActions" }] : /* istanbul ignore next */ []));
|
|
210
324
|
/** Number of rendered columns, including the selection column. */
|
|
211
|
-
this.totalColspan = computed(() => this.columnsWithActions().length +
|
|
325
|
+
this.totalColspan = computed(() => this.columnsWithActions().length +
|
|
326
|
+
(this.selectable() ? 1 : 0) +
|
|
327
|
+
(this.validateRequired() ? 1 : 0), ...(ngDevMode ? [{ debugName: "totalColspan" }] : /* istanbul ignore next */ []));
|
|
328
|
+
// ---------------------------------------------------------------------------
|
|
329
|
+
// Required fields validation
|
|
330
|
+
// ---------------------------------------------------------------------------
|
|
331
|
+
/** Columns checked by the validation (empty when it's disabled). */
|
|
332
|
+
this.requiredColumns = computed(() => this.validateRequired() ? this.columns().filter((c) => c.required) : [], ...(ngDevMode ? [{ debugName: "requiredColumns" }] : /* istanbul ignore next */ []));
|
|
333
|
+
/** Missing required columns of each displayed row (cached per render). */
|
|
334
|
+
this.missingByRow = computed(() => {
|
|
335
|
+
const cols = this.requiredColumns();
|
|
336
|
+
const map = new Map();
|
|
337
|
+
if (!cols.length)
|
|
338
|
+
return map;
|
|
339
|
+
for (const row of this.effectiveDisplayedData()) {
|
|
340
|
+
map.set(row, cols.filter((c) => this.columnMissing(c, row)));
|
|
341
|
+
}
|
|
342
|
+
return map;
|
|
343
|
+
}, ...(ngDevMode ? [{ debugName: "missingByRow" }] : /* istanbul ignore next */ []));
|
|
344
|
+
/**
|
|
345
|
+
* Number of rows with missing data in the whole dataset (client mode) or in
|
|
346
|
+
* the current page (server mode).
|
|
347
|
+
*/
|
|
348
|
+
this.missingRowsCount = computed(() => {
|
|
349
|
+
const cols = this.requiredColumns();
|
|
350
|
+
if (!cols.length)
|
|
351
|
+
return 0;
|
|
352
|
+
const rows = this.serverSide() ? this.data() : this.originalData();
|
|
353
|
+
return rows.filter((row) => cols.some((c) => this.columnMissing(c, row))).length;
|
|
354
|
+
}, ...(ngDevMode ? [{ debugName: "missingRowsCount" }] : /* istanbul ignore next */ []));
|
|
212
355
|
/** Total records: server-provided in server mode, locally computed otherwise. */
|
|
213
356
|
this.effectiveTotalRecords = computed(() => {
|
|
214
357
|
return this.serverSide() ? this.totalRecords() : this.localTotalRecords();
|
|
@@ -239,10 +382,32 @@ class TableComponent {
|
|
|
239
382
|
const to = Math.min(this.first() + this.rowsPerPageLocal(), total);
|
|
240
383
|
return this.transloco.translate('table.pageReport', { from, to, total });
|
|
241
384
|
}, ...(ngDevMode ? [{ debugName: "pageReport" }] : /* istanbul ignore next */ []));
|
|
385
|
+
// ---------------------------------------------------------------------------
|
|
386
|
+
// Column resizing
|
|
387
|
+
// ---------------------------------------------------------------------------
|
|
388
|
+
/** Minimum width (px) a column can be resized to. */
|
|
389
|
+
this.MIN_COLUMN_WIDTH = 60;
|
|
390
|
+
/** Field being resized right now (for the active handle style). */
|
|
391
|
+
this.resizingField = signal(null, ...(ngDevMode ? [{ debugName: "resizingField" }] : /* istanbul ignore next */ []));
|
|
392
|
+
/** Set right after a drag so the click that ends it doesn't sort the column. */
|
|
393
|
+
this.suppressHeaderClick = false;
|
|
394
|
+
/** Whether columns can be resized (only with gridlines). */
|
|
395
|
+
this.isResizable = computed(() => this.showGridlines() && this.resizableColumns(), ...(ngDevMode ? [{ debugName: "isResizable" }] : /* istanbul ignore next */ []));
|
|
396
|
+
/** Whether any column filter or the global search is active. */
|
|
397
|
+
this.hasActiveFilters = computed(() => {
|
|
398
|
+
if (this.searchQuery())
|
|
399
|
+
return true;
|
|
400
|
+
const state = this.filterState();
|
|
401
|
+
return this.columns().some((c) => c.filter && this.activeRules(c, state[c.field]).length > 0);
|
|
402
|
+
}, ...(ngDevMode ? [{ debugName: "hasActiveFilters" }] : /* istanbul ignore next */ []));
|
|
242
403
|
/** Width (px) of the column filter popup, used to keep it inside the viewport. */
|
|
243
|
-
this.FILTER_POPUP_WIDTH =
|
|
404
|
+
this.FILTER_POPUP_WIDTH = 240;
|
|
244
405
|
/** Viewport position of the open column filter popup. */
|
|
245
|
-
this.filterPopupPosition = signal({
|
|
406
|
+
this.filterPopupPosition = signal({
|
|
407
|
+
top: 0,
|
|
408
|
+
left: 0,
|
|
409
|
+
maxHeight: 400,
|
|
410
|
+
}, ...(ngDevMode ? [{ debugName: "filterPopupPosition" }] : /* istanbul ignore next */ []));
|
|
246
411
|
/** Filter button the open popup is anchored to, and its scroll/resize listener cleanup. */
|
|
247
412
|
this.filterAnchor = null;
|
|
248
413
|
this.filterListenersCleanup = null;
|
|
@@ -252,7 +417,6 @@ class TableComponent {
|
|
|
252
417
|
this.actionsDropdownOpen = signal({}, ...(ngDevMode ? [{ debugName: "actionsDropdownOpen" }] : /* istanbul ignore next */ []));
|
|
253
418
|
/** Computes the fixed position of the dropdown so it's not clipped by overflow. */
|
|
254
419
|
this.dropdownPosition = signal({ top: 0, left: 0 }, ...(ngDevMode ? [{ debugName: "dropdownPosition" }] : /* istanbul ignore next */ []));
|
|
255
|
-
this.columnFiltersForm = this.fb.group({});
|
|
256
420
|
this.destroyRef.onDestroy(() => this.filterListenersCleanup?.());
|
|
257
421
|
// Close the filter popup if its header cell was removed (e.g. the column
|
|
258
422
|
// disappeared). Re-renders of the same columns keep the cell (tracked by
|
|
@@ -302,7 +466,29 @@ class TableComponent {
|
|
|
302
466
|
this.pruneSelection(newData);
|
|
303
467
|
});
|
|
304
468
|
});
|
|
305
|
-
//
|
|
469
|
+
// Restore the saved column widths whenever the state key/storage changes.
|
|
470
|
+
effect(() => {
|
|
471
|
+
const key = this.stateKey();
|
|
472
|
+
const storage = this.stateStorage();
|
|
473
|
+
untracked(() => {
|
|
474
|
+
if (!key)
|
|
475
|
+
return;
|
|
476
|
+
const saved = this.readStoredWidths(key, storage);
|
|
477
|
+
if (saved)
|
|
478
|
+
this.columnWidths.set(saved);
|
|
479
|
+
});
|
|
480
|
+
});
|
|
481
|
+
// Save the column widths when they change (not on every pixel of a drag).
|
|
482
|
+
effect(() => {
|
|
483
|
+
const widths = this.columnWidths();
|
|
484
|
+
const resizing = this.resizingField();
|
|
485
|
+
const key = this.stateKey();
|
|
486
|
+
const storage = this.stateStorage();
|
|
487
|
+
if (!key || resizing)
|
|
488
|
+
return;
|
|
489
|
+
untracked(() => this.writeStoredWidths(key, storage, widths));
|
|
490
|
+
});
|
|
491
|
+
// Rebuild the column filter state whenever the columns change.
|
|
306
492
|
effect(() => {
|
|
307
493
|
const cols = this.columns();
|
|
308
494
|
untracked(() => {
|
|
@@ -326,7 +512,7 @@ class TableComponent {
|
|
|
326
512
|
});
|
|
327
513
|
// Apply the global search locally whenever the term changes.
|
|
328
514
|
effect(() => {
|
|
329
|
-
|
|
515
|
+
this.searchQuery();
|
|
330
516
|
untracked(() => {
|
|
331
517
|
if (!this.serverSide()) {
|
|
332
518
|
this.applySearch();
|
|
@@ -334,85 +520,288 @@ class TableComponent {
|
|
|
334
520
|
});
|
|
335
521
|
});
|
|
336
522
|
}
|
|
523
|
+
// ---------------------------------------------------------------------------
|
|
524
|
+
// Translations
|
|
525
|
+
// ---------------------------------------------------------------------------
|
|
337
526
|
/**
|
|
338
|
-
*
|
|
339
|
-
*
|
|
340
|
-
*
|
|
341
|
-
* user otherwise. Previous subscriptions are unsubscribed to avoid leaks.
|
|
527
|
+
* Translates a key, falling back to a built-in (Spanish) label when the app
|
|
528
|
+
* doesn't provide it. Reads the translation signals so template calls are
|
|
529
|
+
* re-evaluated when the language or the loaded translations change.
|
|
342
530
|
*/
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
531
|
+
tr(key, fallback, params) {
|
|
532
|
+
this.translations();
|
|
533
|
+
this.currentLang();
|
|
534
|
+
const value = this.transloco.translate(key, params);
|
|
535
|
+
if (value && value !== key)
|
|
536
|
+
return value;
|
|
537
|
+
return fallback.replace(/\{\{\s*(\w+)\s*\}\}/g, (_, name) => String(params?.[name] ?? ''));
|
|
538
|
+
}
|
|
539
|
+
/** Translated label of a filter menu text (`table.filter.<name>`). */
|
|
540
|
+
filterLabel(name, params) {
|
|
541
|
+
return this.tr(`table.filter.${name}`, FILTER_LABELS[name] ?? name, params);
|
|
542
|
+
}
|
|
543
|
+
/** Translated label of a match mode (`table.filter.matchModes.<mode>`). */
|
|
544
|
+
matchModeLabel(mode) {
|
|
545
|
+
return this.tr(`table.filter.matchModes.${mode}`, FILTER_LABELS[mode] ?? mode);
|
|
546
|
+
}
|
|
547
|
+
// ---------------------------------------------------------------------------
|
|
548
|
+
// Field helpers
|
|
549
|
+
// ---------------------------------------------------------------------------
|
|
550
|
+
/** Reads a row value by field name or dot path (`'country.name'`). */
|
|
551
|
+
resolveField(row, path) {
|
|
552
|
+
if (row == null || !path)
|
|
553
|
+
return undefined;
|
|
554
|
+
if (typeof row === 'object' && path in row)
|
|
555
|
+
return row[path];
|
|
556
|
+
return path.split('.').reduce((obj, key) => (obj == null ? undefined : obj[key]), row);
|
|
557
|
+
}
|
|
558
|
+
/** Field used to filter/sort a column. */
|
|
559
|
+
filterFieldOf(col) {
|
|
560
|
+
return col.filterField || col.field;
|
|
561
|
+
}
|
|
562
|
+
/** Lowercases and strips diacritics so "garcia" matches "García". */
|
|
563
|
+
normalize(value) {
|
|
564
|
+
return String(value ?? '')
|
|
565
|
+
.normalize('NFD')
|
|
566
|
+
.replace(/[̀-ͯ]/g, '')
|
|
567
|
+
.toLocaleLowerCase();
|
|
568
|
+
}
|
|
569
|
+
// ---------------------------------------------------------------------------
|
|
570
|
+
// Column filter state
|
|
571
|
+
// ---------------------------------------------------------------------------
|
|
572
|
+
/** Internal filter kind of a column. */
|
|
573
|
+
filterKind(col) {
|
|
574
|
+
const type = col.filterType ?? 'text';
|
|
575
|
+
return type === 'exact' ? 'text' : type;
|
|
576
|
+
}
|
|
577
|
+
/** Match modes offered by a column's filter menu. */
|
|
578
|
+
matchModesFor(col) {
|
|
579
|
+
return MATCH_MODES[this.filterKind(col)] ?? [];
|
|
580
|
+
}
|
|
581
|
+
/** Default match mode of a column's filter. */
|
|
582
|
+
defaultMatchMode(col) {
|
|
583
|
+
if (col.filterMatchMode)
|
|
584
|
+
return col.filterMatchMode;
|
|
585
|
+
switch (this.filterKind(col)) {
|
|
586
|
+
case 'text':
|
|
587
|
+
return col.filterType === 'exact' ? 'equals' : 'contains';
|
|
588
|
+
case 'numeric':
|
|
589
|
+
return 'equals';
|
|
590
|
+
case 'date':
|
|
591
|
+
return 'dateIs';
|
|
592
|
+
case 'multiselect':
|
|
593
|
+
return 'in';
|
|
594
|
+
case 'range':
|
|
595
|
+
return 'between';
|
|
596
|
+
default:
|
|
597
|
+
return 'equals';
|
|
348
598
|
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
this.
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
599
|
+
}
|
|
600
|
+
/** Whether the column's filter kind supports match modes / several rules. */
|
|
601
|
+
supportsRules(col) {
|
|
602
|
+
return !!MATCH_MODES[this.filterKind(col)];
|
|
603
|
+
}
|
|
604
|
+
showMatchModesFor(col) {
|
|
605
|
+
return this.supportsRules(col) && col.showMatchModes !== false;
|
|
606
|
+
}
|
|
607
|
+
showOperatorFor(col) {
|
|
608
|
+
return this.supportsRules(col) && col.showOperator !== false;
|
|
609
|
+
}
|
|
610
|
+
canAddRule(col) {
|
|
611
|
+
const draft = this.filterDraft();
|
|
612
|
+
return (this.supportsRules(col) &&
|
|
613
|
+
col.showAddButton !== false &&
|
|
614
|
+
!!draft &&
|
|
615
|
+
draft.rules.length < (col.maxConstraints ?? 2));
|
|
616
|
+
}
|
|
617
|
+
/** Whether changes are applied as soon as the value changes (no Apply needed). */
|
|
618
|
+
appliesImmediately(col) {
|
|
619
|
+
return !this.supportsRules(col);
|
|
620
|
+
}
|
|
621
|
+
/** Empty filter state of a column. */
|
|
622
|
+
emptyFilterState(col) {
|
|
623
|
+
return { operator: 'and', rules: [{ matchMode: this.defaultMatchMode(col), value: null }] };
|
|
624
|
+
}
|
|
625
|
+
cloneState(state) {
|
|
626
|
+
return {
|
|
627
|
+
operator: state.operator,
|
|
628
|
+
rules: state.rules.map((r) => ({
|
|
629
|
+
matchMode: r.matchMode,
|
|
630
|
+
value: Array.isArray(r.value) ? [...r.value] : r.value,
|
|
631
|
+
})),
|
|
632
|
+
};
|
|
633
|
+
}
|
|
634
|
+
/** Bounds of a `range` filter. */
|
|
635
|
+
rangeBounds(col) {
|
|
636
|
+
return [col.filterMin ?? 0, col.filterMax ?? 100];
|
|
637
|
+
}
|
|
638
|
+
/** Whether a rule has a value that actually filters. */
|
|
639
|
+
isRuleActive(col, rule) {
|
|
640
|
+
const value = rule.value;
|
|
641
|
+
if (value === null || value === undefined || value === '')
|
|
642
|
+
return false;
|
|
643
|
+
if (this.filterKind(col) === 'range') {
|
|
644
|
+
if (!Array.isArray(value) || value.length !== 2)
|
|
645
|
+
return false;
|
|
646
|
+
const [min, max] = this.rangeBounds(col);
|
|
647
|
+
return value[0] > min || value[1] < max;
|
|
358
648
|
}
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
649
|
+
if (Array.isArray(value))
|
|
650
|
+
return value.length > 0;
|
|
651
|
+
return true;
|
|
652
|
+
}
|
|
653
|
+
activeRules(col, state) {
|
|
654
|
+
return (state?.rules ?? []).filter((r) => this.isRuleActive(col, r));
|
|
655
|
+
}
|
|
656
|
+
/** Converts a Date / ISO string / timestamp into a local midnight timestamp. */
|
|
657
|
+
toDay(value) {
|
|
658
|
+
if (value === null || value === undefined || value === '')
|
|
659
|
+
return null;
|
|
660
|
+
let date;
|
|
661
|
+
if (value instanceof Date) {
|
|
662
|
+
date = value;
|
|
663
|
+
}
|
|
664
|
+
else if (typeof value === 'string' && /^\d{4}-\d{2}-\d{2}$/.test(value)) {
|
|
665
|
+
const [y, m, d] = value.split('-').map(Number);
|
|
666
|
+
date = new Date(y, m - 1, d);
|
|
667
|
+
}
|
|
668
|
+
else {
|
|
669
|
+
date = new Date(value);
|
|
670
|
+
}
|
|
671
|
+
if (isNaN(date.getTime()))
|
|
672
|
+
return null;
|
|
673
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime();
|
|
674
|
+
}
|
|
675
|
+
/** Evaluates one rule against a cell value. */
|
|
676
|
+
matchRule(col, cell, rule) {
|
|
677
|
+
const value = rule.value;
|
|
678
|
+
switch (rule.matchMode) {
|
|
679
|
+
case 'startsWith':
|
|
680
|
+
return this.normalize(cell).startsWith(this.normalize(value));
|
|
681
|
+
case 'contains':
|
|
682
|
+
return this.normalize(cell).includes(this.normalize(value));
|
|
683
|
+
case 'notContains':
|
|
684
|
+
return !this.normalize(cell).includes(this.normalize(value));
|
|
685
|
+
case 'endsWith':
|
|
686
|
+
return this.normalize(cell).endsWith(this.normalize(value));
|
|
687
|
+
case 'equals':
|
|
688
|
+
case 'notEquals': {
|
|
689
|
+
let equal;
|
|
690
|
+
const kind = this.filterKind(col);
|
|
691
|
+
if (kind === 'numeric') {
|
|
692
|
+
equal = cell !== null && cell !== undefined && cell !== '' && Number(cell) === Number(value);
|
|
693
|
+
}
|
|
694
|
+
else if (kind === 'boolean') {
|
|
695
|
+
equal = Boolean(cell) === Boolean(value);
|
|
696
|
+
}
|
|
697
|
+
else if (kind === 'select') {
|
|
698
|
+
equal = cell == value;
|
|
381
699
|
}
|
|
382
700
|
else {
|
|
383
|
-
this.
|
|
701
|
+
equal = this.normalize(cell) === this.normalize(value);
|
|
384
702
|
}
|
|
385
|
-
|
|
386
|
-
});
|
|
387
|
-
if (sub) {
|
|
388
|
-
this.columnFilterSubscriptions.push(sub);
|
|
703
|
+
return rule.matchMode === 'equals' ? equal : !equal;
|
|
389
704
|
}
|
|
705
|
+
case 'lt':
|
|
706
|
+
case 'lte':
|
|
707
|
+
case 'gt':
|
|
708
|
+
case 'gte': {
|
|
709
|
+
if (cell === null || cell === undefined || cell === '')
|
|
710
|
+
return false;
|
|
711
|
+
const a = Number(cell);
|
|
712
|
+
const b = Number(value);
|
|
713
|
+
if (isNaN(a) || isNaN(b))
|
|
714
|
+
return false;
|
|
715
|
+
if (rule.matchMode === 'lt')
|
|
716
|
+
return a < b;
|
|
717
|
+
if (rule.matchMode === 'lte')
|
|
718
|
+
return a <= b;
|
|
719
|
+
if (rule.matchMode === 'gt')
|
|
720
|
+
return a > b;
|
|
721
|
+
return a >= b;
|
|
722
|
+
}
|
|
723
|
+
case 'dateIs':
|
|
724
|
+
case 'dateIsNot':
|
|
725
|
+
case 'dateBefore':
|
|
726
|
+
case 'dateAfter': {
|
|
727
|
+
const a = this.toDay(cell);
|
|
728
|
+
const b = this.toDay(value);
|
|
729
|
+
if (b === null)
|
|
730
|
+
return true;
|
|
731
|
+
if (a === null)
|
|
732
|
+
return rule.matchMode === 'dateIsNot';
|
|
733
|
+
if (rule.matchMode === 'dateIs')
|
|
734
|
+
return a === b;
|
|
735
|
+
if (rule.matchMode === 'dateIsNot')
|
|
736
|
+
return a !== b;
|
|
737
|
+
if (rule.matchMode === 'dateBefore')
|
|
738
|
+
return a < b;
|
|
739
|
+
return a > b;
|
|
740
|
+
}
|
|
741
|
+
case 'in':
|
|
742
|
+
return value.some((v) => v == cell);
|
|
743
|
+
case 'between': {
|
|
744
|
+
if (cell === null || cell === undefined || cell === '')
|
|
745
|
+
return false;
|
|
746
|
+
const n = Number(cell);
|
|
747
|
+
return n >= value[0] && n <= value[1];
|
|
748
|
+
}
|
|
749
|
+
default:
|
|
750
|
+
return true;
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
/**
|
|
754
|
+
* Keeps one filter state per filterable column. The state is only reset
|
|
755
|
+
* when the set of filterable fields/filter types changes, preserving what
|
|
756
|
+
* the user already applied otherwise.
|
|
757
|
+
*/
|
|
758
|
+
setupColumnFilters(cols) {
|
|
759
|
+
const filterableCols = cols.filter((c) => c.filter);
|
|
760
|
+
const signature = filterableCols.map((c) => `${c.field}:${c.filterType ?? 'text'}`).join('|');
|
|
761
|
+
if (signature === this.lastFilterFieldsSignature)
|
|
762
|
+
return;
|
|
763
|
+
this.lastFilterFieldsSignature = signature;
|
|
764
|
+
const previous = this.filterState();
|
|
765
|
+
const next = {};
|
|
766
|
+
filterableCols.forEach((col) => {
|
|
767
|
+
next[col.field] = previous[col.field] ?? this.emptyFilterState(col);
|
|
390
768
|
});
|
|
769
|
+
this.filterState.set(next);
|
|
391
770
|
}
|
|
392
|
-
/** Collects the
|
|
771
|
+
/** Collects the active column filters and emits them. */
|
|
393
772
|
emitFilterChange() {
|
|
394
773
|
const filters = {};
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
774
|
+
const filterMeta = {};
|
|
775
|
+
const state = this.filterState();
|
|
776
|
+
this.columns().forEach((col) => {
|
|
777
|
+
if (!col.filter)
|
|
778
|
+
return;
|
|
779
|
+
const rules = this.activeRules(col, state[col.field]);
|
|
780
|
+
if (rules.length === 0)
|
|
781
|
+
return;
|
|
782
|
+
const key = this.filterFieldOf(col);
|
|
783
|
+
filters[key] = rules[0].value;
|
|
784
|
+
filterMeta[key] = this.cloneState({ operator: state[col.field].operator, rules });
|
|
400
785
|
});
|
|
401
|
-
this.filterChange.emit({ filters });
|
|
786
|
+
this.filterChange.emit({ filters, filterMeta });
|
|
402
787
|
}
|
|
403
788
|
/** Applies the global search over the original data (client mode). */
|
|
404
789
|
applySearch() {
|
|
405
790
|
const original = this.originalData();
|
|
406
|
-
const query = this.searchQuery().
|
|
791
|
+
const query = this.normalize(this.searchQuery().trim());
|
|
407
792
|
if (!query) {
|
|
408
793
|
this.searchedData.set([...original]);
|
|
409
794
|
}
|
|
410
795
|
else {
|
|
796
|
+
const fields = this.globalFilterFields();
|
|
411
797
|
const filtered = original.filter((item) => {
|
|
412
|
-
|
|
798
|
+
const values = fields.length
|
|
799
|
+
? fields.map((f) => this.resolveField(item, f))
|
|
800
|
+
: Object.values(item ?? {}).filter((v) => v === null || typeof v !== 'object' || v instanceof Date);
|
|
801
|
+
return values.some((val) => {
|
|
413
802
|
if (val === null || val === undefined)
|
|
414
803
|
return false;
|
|
415
|
-
return
|
|
804
|
+
return this.normalize(val).includes(query);
|
|
416
805
|
});
|
|
417
806
|
});
|
|
418
807
|
this.searchedData.set(filtered);
|
|
@@ -424,43 +813,53 @@ class TableComponent {
|
|
|
424
813
|
this.applySearch();
|
|
425
814
|
}
|
|
426
815
|
/**
|
|
427
|
-
* Applies every column filter on top of the searched data
|
|
428
|
-
* column
|
|
816
|
+
* Applies every column filter on top of the searched data. The active rules
|
|
817
|
+
* of a column are combined with its operator (Match All / Match Any).
|
|
429
818
|
*/
|
|
430
819
|
applyColumnFilters() {
|
|
431
|
-
|
|
432
|
-
|
|
820
|
+
let filtered = [...this.searchedData()];
|
|
821
|
+
const state = this.filterState();
|
|
433
822
|
this.columns().forEach((col) => {
|
|
434
|
-
if (col.filter)
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
}
|
|
823
|
+
if (!col.filter)
|
|
824
|
+
return;
|
|
825
|
+
const colState = state[col.field];
|
|
826
|
+
const rules = this.activeRules(col, colState);
|
|
827
|
+
if (rules.length === 0)
|
|
828
|
+
return;
|
|
829
|
+
const field = this.filterFieldOf(col);
|
|
830
|
+
filtered = filtered.filter((item) => {
|
|
831
|
+
const cell = this.resolveField(item, field);
|
|
832
|
+
return colState.operator === 'or'
|
|
833
|
+
? rules.some((r) => this.matchRule(col, cell, r))
|
|
834
|
+
: rules.every((r) => this.matchRule(col, cell, r));
|
|
835
|
+
});
|
|
450
836
|
});
|
|
451
837
|
this.filteredData.set(filtered);
|
|
452
838
|
this.localTotalRecords.set(filtered.length);
|
|
453
839
|
this.applySort();
|
|
454
840
|
this.updateDisplayedData();
|
|
455
841
|
}
|
|
842
|
+
/** Re-runs filtering after a filter state change. */
|
|
843
|
+
onFiltersChanged() {
|
|
844
|
+
this.first.set(0);
|
|
845
|
+
if (this.serverSide()) {
|
|
846
|
+
this.filterSubject.next();
|
|
847
|
+
}
|
|
848
|
+
else {
|
|
849
|
+
this.applyFilters();
|
|
850
|
+
}
|
|
851
|
+
this.cdr.markForCheck();
|
|
852
|
+
}
|
|
456
853
|
/** Slices the filtered rows for the current page. */
|
|
457
854
|
updateDisplayedData() {
|
|
458
855
|
const filtered = this.filteredData();
|
|
459
856
|
const firstIndex = this.first();
|
|
460
857
|
const rows = this.rowsPerPageLocal();
|
|
461
|
-
|
|
462
|
-
this.displayedData.set(displayed);
|
|
858
|
+
this.displayedData.set(filtered.slice(firstIndex, firstIndex + rows));
|
|
463
859
|
}
|
|
860
|
+
// ---------------------------------------------------------------------------
|
|
861
|
+
// Selection
|
|
862
|
+
// ---------------------------------------------------------------------------
|
|
464
863
|
/** Identity used for a row inside the selection. */
|
|
465
864
|
getSelectionKey(row) {
|
|
466
865
|
const key = this.dataKey();
|
|
@@ -526,6 +925,158 @@ class TableComponent {
|
|
|
526
925
|
this.selection.set(next);
|
|
527
926
|
}
|
|
528
927
|
}
|
|
928
|
+
/** CSS width of a resized column, or null when it uses the automatic width. */
|
|
929
|
+
resizedWidth(col) {
|
|
930
|
+
const width = this.isResizable() ? this.columnWidths()[col.field] : undefined;
|
|
931
|
+
return width ? `${width}px` : null;
|
|
932
|
+
}
|
|
933
|
+
resizedWidthPx(col) {
|
|
934
|
+
return this.columnWidths()[col.field] ?? null;
|
|
935
|
+
}
|
|
936
|
+
/** Header click: sorts unless the click is the end of a resize drag. */
|
|
937
|
+
onHeaderClick(col) {
|
|
938
|
+
if (this.suppressHeaderClick)
|
|
939
|
+
return;
|
|
940
|
+
if (col.field !== 'actions' && col.sortable)
|
|
941
|
+
this.toggleSort(col.field);
|
|
942
|
+
}
|
|
943
|
+
/** Starts dragging the right border of a header cell. */
|
|
944
|
+
startResize(event, col) {
|
|
945
|
+
if (event.button !== 0)
|
|
946
|
+
return;
|
|
947
|
+
event.preventDefault();
|
|
948
|
+
event.stopPropagation();
|
|
949
|
+
const th = event.target.closest('th');
|
|
950
|
+
if (!th)
|
|
951
|
+
return;
|
|
952
|
+
const startX = event.clientX;
|
|
953
|
+
const startWidth = th.getBoundingClientRect().width;
|
|
954
|
+
let moved = false;
|
|
955
|
+
this.resizingField.set(col.field);
|
|
956
|
+
const body = document.body;
|
|
957
|
+
const previousCursor = body.style.cursor;
|
|
958
|
+
const previousSelect = body.style.userSelect;
|
|
959
|
+
body.style.cursor = 'col-resize';
|
|
960
|
+
body.style.userSelect = 'none';
|
|
961
|
+
const onMove = (e) => {
|
|
962
|
+
const dx = e.clientX - startX;
|
|
963
|
+
if (Math.abs(dx) > 2)
|
|
964
|
+
moved = true;
|
|
965
|
+
this.setColumnWidth(col, startWidth + dx, false);
|
|
966
|
+
};
|
|
967
|
+
const onUp = () => {
|
|
968
|
+
document.removeEventListener('pointermove', onMove);
|
|
969
|
+
document.removeEventListener('pointerup', onUp);
|
|
970
|
+
document.removeEventListener('pointercancel', onUp);
|
|
971
|
+
body.style.cursor = previousCursor;
|
|
972
|
+
body.style.userSelect = previousSelect;
|
|
973
|
+
this.resizingField.set(null);
|
|
974
|
+
// Keep the width actually rendered (content can't shrink below its minimum).
|
|
975
|
+
if (moved)
|
|
976
|
+
this.syncRenderedWidth(col, th);
|
|
977
|
+
if (moved) {
|
|
978
|
+
this.suppressHeaderClick = true;
|
|
979
|
+
setTimeout(() => (this.suppressHeaderClick = false));
|
|
980
|
+
this.columnResize.emit({ field: col.field, width: this.columnWidths()[col.field] ?? null });
|
|
981
|
+
}
|
|
982
|
+
this.cdr.markForCheck();
|
|
983
|
+
};
|
|
984
|
+
document.addEventListener('pointermove', onMove);
|
|
985
|
+
document.addEventListener('pointerup', onUp);
|
|
986
|
+
document.addEventListener('pointercancel', onUp);
|
|
987
|
+
}
|
|
988
|
+
/** Arrow keys on the handle widen/narrow the column (Shift = bigger steps). */
|
|
989
|
+
onResizerKeydown(event, col) {
|
|
990
|
+
if (event.key !== 'ArrowLeft' && event.key !== 'ArrowRight') {
|
|
991
|
+
if (event.key === 'Enter' || event.key === ' ')
|
|
992
|
+
event.stopPropagation();
|
|
993
|
+
return;
|
|
994
|
+
}
|
|
995
|
+
event.preventDefault();
|
|
996
|
+
event.stopPropagation();
|
|
997
|
+
const th = event.target.closest('th');
|
|
998
|
+
if (!th)
|
|
999
|
+
return;
|
|
1000
|
+
const step = event.shiftKey ? 50 : 10;
|
|
1001
|
+
const base = this.columnWidths()[col.field] ?? th.getBoundingClientRect().width;
|
|
1002
|
+
this.setColumnWidth(col, base + (event.key === 'ArrowRight' ? step : -step), true);
|
|
1003
|
+
this.syncRenderedWidth(col, th);
|
|
1004
|
+
}
|
|
1005
|
+
/** Stores the width the column really has (it may be wider than requested). */
|
|
1006
|
+
syncRenderedWidth(col, th) {
|
|
1007
|
+
// Read it after the requested width has been rendered.
|
|
1008
|
+
afterNextRender({
|
|
1009
|
+
read: () => {
|
|
1010
|
+
const rendered = Math.round(th.getBoundingClientRect().width);
|
|
1011
|
+
if (rendered && this.columnWidths()[col.field] !== rendered) {
|
|
1012
|
+
this.columnWidths.update((w) => ({ ...w, [col.field]: rendered }));
|
|
1013
|
+
this.cdr.markForCheck();
|
|
1014
|
+
}
|
|
1015
|
+
},
|
|
1016
|
+
}, { injector: this.injector });
|
|
1017
|
+
}
|
|
1018
|
+
/** Resets every column to its automatic width (also clears the saved state). */
|
|
1019
|
+
resetColumnWidths() {
|
|
1020
|
+
this.columnWidths.set({});
|
|
1021
|
+
}
|
|
1022
|
+
storageFor(type) {
|
|
1023
|
+
try {
|
|
1024
|
+
return type === 'session' ? window.sessionStorage : window.localStorage;
|
|
1025
|
+
}
|
|
1026
|
+
catch {
|
|
1027
|
+
return null; // storage blocked (privacy mode, sandboxed iframe...)
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
/** Reads saved widths, ignoring missing, invalid or blocked storage. */
|
|
1031
|
+
readStoredWidths(key, type) {
|
|
1032
|
+
try {
|
|
1033
|
+
const raw = this.storageFor(type)?.getItem(`${key}:columnWidths`);
|
|
1034
|
+
if (!raw)
|
|
1035
|
+
return null;
|
|
1036
|
+
const parsed = JSON.parse(raw);
|
|
1037
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed))
|
|
1038
|
+
return null;
|
|
1039
|
+
const widths = {};
|
|
1040
|
+
Object.entries(parsed).forEach(([field, width]) => {
|
|
1041
|
+
if (typeof width === 'number' && isFinite(width) && width > 0)
|
|
1042
|
+
widths[field] = width;
|
|
1043
|
+
});
|
|
1044
|
+
return widths;
|
|
1045
|
+
}
|
|
1046
|
+
catch {
|
|
1047
|
+
return null;
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
writeStoredWidths(key, type, widths) {
|
|
1051
|
+
try {
|
|
1052
|
+
const storage = this.storageFor(type);
|
|
1053
|
+
if (!storage)
|
|
1054
|
+
return;
|
|
1055
|
+
if (Object.keys(widths).length === 0)
|
|
1056
|
+
storage.removeItem(`${key}:columnWidths`);
|
|
1057
|
+
else
|
|
1058
|
+
storage.setItem(`${key}:columnWidths`, JSON.stringify(widths));
|
|
1059
|
+
}
|
|
1060
|
+
catch {
|
|
1061
|
+
// Quota exceeded or storage blocked: widths just aren't persisted.
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
/** Resets a column to its automatic width (double click on the handle). */
|
|
1065
|
+
resetColumnWidth(col) {
|
|
1066
|
+
const { [col.field]: _removed, ...rest } = this.columnWidths();
|
|
1067
|
+
this.columnWidths.set(rest);
|
|
1068
|
+
this.columnResize.emit({ field: col.field, width: null });
|
|
1069
|
+
}
|
|
1070
|
+
setColumnWidth(col, width, emit) {
|
|
1071
|
+
const next = Math.max(this.MIN_COLUMN_WIDTH, Math.round(width));
|
|
1072
|
+
this.columnWidths.update((w) => ({ ...w, [col.field]: next }));
|
|
1073
|
+
if (emit)
|
|
1074
|
+
this.columnResize.emit({ field: col.field, width: next });
|
|
1075
|
+
this.cdr.markForCheck();
|
|
1076
|
+
}
|
|
1077
|
+
// ---------------------------------------------------------------------------
|
|
1078
|
+
// Sorting & search
|
|
1079
|
+
// ---------------------------------------------------------------------------
|
|
529
1080
|
/** Emits the filter chip clicked in the template. */
|
|
530
1081
|
onFilterClick(value) {
|
|
531
1082
|
this.filterClick.emit(value);
|
|
@@ -554,16 +1105,21 @@ class TableComponent {
|
|
|
554
1105
|
const order = this.sortOrder();
|
|
555
1106
|
if (!field)
|
|
556
1107
|
return;
|
|
1108
|
+
const col = this.columns().find((c) => c.field === field);
|
|
1109
|
+
const path = col ? this.filterFieldOf(col) : field;
|
|
557
1110
|
const data = [...this.filteredData()];
|
|
558
1111
|
data.sort((a, b) => {
|
|
559
|
-
const va = a
|
|
560
|
-
const vb = b
|
|
1112
|
+
const va = this.resolveField(a, path);
|
|
1113
|
+
const vb = this.resolveField(b, path);
|
|
561
1114
|
if (va == null && vb == null)
|
|
562
1115
|
return 0;
|
|
563
1116
|
if (va == null)
|
|
564
1117
|
return 1; // nulls always at the end
|
|
565
1118
|
if (vb == null)
|
|
566
1119
|
return -1;
|
|
1120
|
+
if (typeof va === 'string' && typeof vb === 'string') {
|
|
1121
|
+
return va.localeCompare(vb, undefined, { numeric: true, sensitivity: 'base' }) * order;
|
|
1122
|
+
}
|
|
567
1123
|
if (va < vb)
|
|
568
1124
|
return -1 * order;
|
|
569
1125
|
if (va > vb)
|
|
@@ -580,26 +1136,171 @@ class TableComponent {
|
|
|
580
1136
|
this.searchSubject.next(value);
|
|
581
1137
|
}
|
|
582
1138
|
}
|
|
583
|
-
|
|
1139
|
+
// ---------------------------------------------------------------------------
|
|
1140
|
+
// Filter menu
|
|
1141
|
+
// ---------------------------------------------------------------------------
|
|
1142
|
+
/** Whether a column has an applied (non-empty) filter. */
|
|
1143
|
+
hasFilterValue(field) {
|
|
1144
|
+
const col = this.columns().find((c) => c.field === field);
|
|
1145
|
+
if (!col)
|
|
1146
|
+
return false;
|
|
1147
|
+
return this.activeRules(col, this.filterState()[field]).length > 0;
|
|
1148
|
+
}
|
|
1149
|
+
/** Commits the draft of a column into the applied filter state. */
|
|
1150
|
+
commitDraft(col) {
|
|
1151
|
+
const draft = this.filterDraft();
|
|
1152
|
+
if (!draft)
|
|
1153
|
+
return;
|
|
1154
|
+
this.filterState.update((s) => ({ ...s, [col.field]: this.cloneState(draft) }));
|
|
1155
|
+
this.onFiltersChanged();
|
|
1156
|
+
}
|
|
1157
|
+
setDraftOperator(operator) {
|
|
1158
|
+
this.filterDraft.update((d) => (d ? { ...d, operator } : d));
|
|
1159
|
+
}
|
|
1160
|
+
setDraftMatchMode(col, index, matchMode) {
|
|
1161
|
+
this.filterDraft.update((d) => d ? { ...d, rules: d.rules.map((r, i) => (i === index ? { ...r, matchMode } : r)) } : d);
|
|
1162
|
+
}
|
|
1163
|
+
setDraftValue(col, index, value) {
|
|
1164
|
+
this.filterDraft.update((d) => d ? { ...d, rules: d.rules.map((r, i) => (i === index ? { ...r, value } : r)) } : d);
|
|
1165
|
+
if (this.appliesImmediately(col))
|
|
1166
|
+
this.commitDraft(col);
|
|
1167
|
+
}
|
|
1168
|
+
/** Raw value typed in a rule input, converted for its filter kind. */
|
|
1169
|
+
onRuleInput(col, index, raw) {
|
|
1170
|
+
const kind = this.filterKind(col);
|
|
1171
|
+
const value = kind === 'numeric' ? this.numericValue(raw) : kind === 'date' ? raw || null : raw;
|
|
1172
|
+
this.setDraftValue(col, index, value);
|
|
1173
|
+
}
|
|
1174
|
+
/** Value of a numeric input (`null` when empty). */
|
|
1175
|
+
numericValue(raw) {
|
|
1176
|
+
return raw === '' || raw === null || isNaN(Number(raw)) ? null : Number(raw);
|
|
1177
|
+
}
|
|
1178
|
+
addRule(col) {
|
|
1179
|
+
if (!this.canAddRule(col))
|
|
1180
|
+
return;
|
|
1181
|
+
this.filterDraft.update((d) => d ? { ...d, rules: [...d.rules, { matchMode: this.defaultMatchMode(col), value: null }] } : d);
|
|
1182
|
+
}
|
|
1183
|
+
removeRule(index) {
|
|
1184
|
+
this.filterDraft.update((d) => d && d.rules.length > 1 ? { ...d, rules: d.rules.filter((_, i) => i !== index) } : d);
|
|
1185
|
+
}
|
|
1186
|
+
/** Applies the draft (Apply button / Enter) and closes the menu. */
|
|
1187
|
+
applyFilter(col) {
|
|
1188
|
+
this.commitDraft(col);
|
|
1189
|
+
this.closeFilters();
|
|
1190
|
+
}
|
|
1191
|
+
/** Clears a column filter and closes its menu. */
|
|
584
1192
|
clearFilter(field) {
|
|
585
|
-
const
|
|
586
|
-
|
|
587
|
-
|
|
1193
|
+
const col = this.columns().find((c) => c.field === field);
|
|
1194
|
+
if (!col)
|
|
1195
|
+
return;
|
|
1196
|
+
this.filterState.update((s) => ({ ...s, [field]: this.emptyFilterState(col) }));
|
|
1197
|
+
this.onFiltersChanged();
|
|
588
1198
|
this.closeFilters();
|
|
589
1199
|
}
|
|
1200
|
+
/** Multiselect helpers. */
|
|
1201
|
+
isOptionSelected(value) {
|
|
1202
|
+
const current = this.filterDraft()?.rules[0]?.value;
|
|
1203
|
+
return Array.isArray(current) && current.some((v) => v == value);
|
|
1204
|
+
}
|
|
1205
|
+
toggleOption(col, value) {
|
|
1206
|
+
const current = this.filterDraft()?.rules[0]?.value ?? [];
|
|
1207
|
+
const next = current.some((v) => v == value)
|
|
1208
|
+
? current.filter((v) => v != value)
|
|
1209
|
+
: [...current, value];
|
|
1210
|
+
this.setDraftValue(col, 0, next.length ? next : null);
|
|
1211
|
+
}
|
|
1212
|
+
selectedOptionsLabel(col) {
|
|
1213
|
+
const current = this.filterDraft()?.rules[0]?.value ?? [];
|
|
1214
|
+
if (!current.length)
|
|
1215
|
+
return '';
|
|
1216
|
+
const labels = (col.filterOptions ?? [])
|
|
1217
|
+
.filter((o) => current.some((v) => v == o.value))
|
|
1218
|
+
.map((o) => o.label);
|
|
1219
|
+
return labels.length > 2
|
|
1220
|
+
? this.filterLabel('selectedCount', { count: labels.length })
|
|
1221
|
+
: labels.join(', ');
|
|
1222
|
+
}
|
|
1223
|
+
/** Select filter: picks an option (clicking the selected one clears it) and collapses the list. */
|
|
1224
|
+
selectOption(col, value) {
|
|
1225
|
+
const current = this.filterDraft()?.rules[0]?.value;
|
|
1226
|
+
this.setDraftValue(col, 0, current != null && current == value ? null : value);
|
|
1227
|
+
this.multiselectOpen.set(false);
|
|
1228
|
+
}
|
|
1229
|
+
selectedSingleLabel(col) {
|
|
1230
|
+
const current = this.filterDraft()?.rules[0]?.value;
|
|
1231
|
+
if (current === null || current === undefined)
|
|
1232
|
+
return '';
|
|
1233
|
+
return (col.filterOptions ?? []).find((o) => o.value == current)?.label ?? String(current);
|
|
1234
|
+
}
|
|
1235
|
+
/** Boolean filter: cycles any → true → false → any. */
|
|
1236
|
+
cycleBoolean(col) {
|
|
1237
|
+
const current = this.filterDraft()?.rules[0]?.value;
|
|
1238
|
+
const next = current === null || current === undefined ? true : current === true ? false : null;
|
|
1239
|
+
this.setDraftValue(col, 0, next);
|
|
1240
|
+
}
|
|
1241
|
+
/** Current [low, high] of a range filter draft. */
|
|
1242
|
+
rangeValue(col) {
|
|
1243
|
+
const value = this.filterDraft()?.rules[0]?.value;
|
|
1244
|
+
return Array.isArray(value) ? [value[0], value[1]] : this.rangeBounds(col);
|
|
1245
|
+
}
|
|
1246
|
+
/** Updates one thumb of the range slider; `commit` applies it (on release). */
|
|
1247
|
+
onRangeInput(col, thumb, raw, commit) {
|
|
1248
|
+
const [low, high] = this.rangeValue(col);
|
|
1249
|
+
const n = Number(raw);
|
|
1250
|
+
const next = thumb === 0 ? [Math.min(n, high), high] : [low, Math.max(n, low)];
|
|
1251
|
+
// A range covering the full bounds is treated as "no filter" (see isRuleActive).
|
|
1252
|
+
this.filterDraft.update((d) => d ? { ...d, rules: d.rules.map((r, i) => (i === 0 ? { ...r, value: next } : r)) } : d);
|
|
1253
|
+
if (commit)
|
|
1254
|
+
this.commitDraft(col);
|
|
1255
|
+
}
|
|
1256
|
+
/** Position (0-100%) of a range value on the track. */
|
|
1257
|
+
rangePercent(col, value) {
|
|
1258
|
+
const [min, max] = this.rangeBounds(col);
|
|
1259
|
+
return max === min ? 0 : ((value - min) / (max - min)) * 100;
|
|
1260
|
+
}
|
|
590
1261
|
/**
|
|
591
|
-
*
|
|
592
|
-
*
|
|
593
|
-
* header cell (`overflow: hidden`) and the scroll wrapper can't clip it.
|
|
1262
|
+
* Resets the global search, every column filter, the sort and the page
|
|
1263
|
+
* (the "Clear" button).
|
|
594
1264
|
*/
|
|
595
|
-
|
|
596
|
-
const
|
|
1265
|
+
clearAll() {
|
|
1266
|
+
const state = {};
|
|
1267
|
+
this.columns()
|
|
1268
|
+
.filter((c) => c.filter)
|
|
1269
|
+
.forEach((col) => (state[col.field] = this.emptyFilterState(col)));
|
|
1270
|
+
this.filterState.set(state);
|
|
1271
|
+
this.closeFilters();
|
|
1272
|
+
const hadSearch = !!this.searchQuery();
|
|
1273
|
+
this.searchQuery.set('');
|
|
1274
|
+
this.sortField.set(this.defaultSortField());
|
|
1275
|
+
this.sortOrder.set(this.defaultSortOrder());
|
|
1276
|
+
this.first.set(0);
|
|
1277
|
+
if (this.serverSide()) {
|
|
1278
|
+
this.emitFilterChange();
|
|
1279
|
+
if (hadSearch)
|
|
1280
|
+
this.searchChange.emit('');
|
|
1281
|
+
}
|
|
1282
|
+
else {
|
|
1283
|
+
this.applyFilters();
|
|
1284
|
+
}
|
|
1285
|
+
this.cdr.markForCheck();
|
|
1286
|
+
}
|
|
1287
|
+
/**
|
|
1288
|
+
* Toggles a column filter menu. Only one menu is open at a time. The menu
|
|
1289
|
+
* uses `position: fixed` anchored to the filter button, so the header cell
|
|
1290
|
+
* and the scroll wrapper can't clip it. Edits go to a draft that is applied
|
|
1291
|
+
* with the Apply button (select/multiselect/boolean/range apply instantly).
|
|
1292
|
+
*/
|
|
1293
|
+
toggleFilter(col, event) {
|
|
1294
|
+
const wasOpen = this.openFilterField() === col.field;
|
|
597
1295
|
this.closeFilters();
|
|
598
1296
|
if (wasOpen)
|
|
599
1297
|
return;
|
|
600
1298
|
this.filterAnchor = event?.currentTarget ?? null;
|
|
601
1299
|
this.updateFilterPopupPosition();
|
|
602
|
-
|
|
1300
|
+
const applied = this.filterState()[col.field] ?? this.emptyFilterState(col);
|
|
1301
|
+
this.filterDraft.set(this.cloneState(applied));
|
|
1302
|
+
this.multiselectOpen.set(false);
|
|
1303
|
+
this.openFilterField.set(col.field);
|
|
603
1304
|
const reposition = () => this.updateFilterPopupPosition();
|
|
604
1305
|
window.addEventListener('scroll', reposition, true);
|
|
605
1306
|
window.addEventListener('resize', reposition);
|
|
@@ -607,94 +1308,73 @@ class TableComponent {
|
|
|
607
1308
|
window.removeEventListener('scroll', reposition, true);
|
|
608
1309
|
window.removeEventListener('resize', reposition);
|
|
609
1310
|
};
|
|
610
|
-
setTimeout(() => document.
|
|
1311
|
+
setTimeout(() => document.querySelector(`#${this.uid}-filter-${this.safeId(col.field)}-0`)?.focus());
|
|
611
1312
|
this.cdr.markForCheck();
|
|
612
1313
|
}
|
|
613
|
-
/**
|
|
1314
|
+
/** Field name usable inside an element id. */
|
|
1315
|
+
safeId(field) {
|
|
1316
|
+
return field.replace(/[^a-zA-Z0-9_-]/g, '_');
|
|
1317
|
+
}
|
|
1318
|
+
/** Closes the column filter menu (unapplied draft changes are discarded). */
|
|
614
1319
|
closeFilters() {
|
|
615
1320
|
this.filterListenersCleanup?.();
|
|
616
1321
|
this.filterListenersCleanup = null;
|
|
617
1322
|
this.filterAnchor = null;
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
Object.keys(visibility).forEach((key) => (closed[key] = false));
|
|
622
|
-
this.showFilterInput.set(closed);
|
|
1323
|
+
if (this.openFilterField() !== null) {
|
|
1324
|
+
this.openFilterField.set(null);
|
|
1325
|
+
this.filterDraft.set(null);
|
|
623
1326
|
this.cdr.markForCheck();
|
|
624
1327
|
}
|
|
625
1328
|
}
|
|
626
|
-
/** Places the filter
|
|
1329
|
+
/** Places the filter menu under its button, clamped to the viewport. */
|
|
627
1330
|
updateFilterPopupPosition() {
|
|
628
1331
|
if (!this.filterAnchor)
|
|
629
1332
|
return;
|
|
630
1333
|
const rect = this.filterAnchor.getBoundingClientRect();
|
|
631
1334
|
const maxLeft = window.innerWidth - this.FILTER_POPUP_WIDTH - 8;
|
|
632
|
-
const left = Math.max(8, Math.min(rect.
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
hasFilterValue(field) {
|
|
640
|
-
const value = this.columnFiltersForm.get(field)?.value;
|
|
641
|
-
return value !== null && value !== undefined && value !== '';
|
|
1335
|
+
const left = Math.max(8, Math.min(rect.left, maxLeft));
|
|
1336
|
+
const top = rect.bottom + 6;
|
|
1337
|
+
this.filterPopupPosition.set({
|
|
1338
|
+
top,
|
|
1339
|
+
left,
|
|
1340
|
+
maxHeight: Math.max(200, window.innerHeight - top - 12),
|
|
1341
|
+
});
|
|
642
1342
|
}
|
|
1343
|
+
// ---------------------------------------------------------------------------
|
|
1344
|
+
// Pagination
|
|
1345
|
+
// ---------------------------------------------------------------------------
|
|
643
1346
|
/** Returns the reactive page report string (template helper). */
|
|
644
1347
|
getPageReport() {
|
|
645
1348
|
return this.pageReport();
|
|
646
1349
|
}
|
|
647
|
-
/** Goes to
|
|
648
|
-
|
|
1350
|
+
/** Goes to a page (0-based), emitting pageChange in server-side mode. */
|
|
1351
|
+
goToPage(page) {
|
|
649
1352
|
const rows = this.rowsPerPageLocal();
|
|
650
|
-
this.
|
|
1353
|
+
const total = this.effectiveTotalRecords();
|
|
1354
|
+
const pageCount = Math.max(1, Math.ceil(total / rows));
|
|
1355
|
+
const target = Math.min(Math.max(0, page), pageCount - 1);
|
|
1356
|
+
const first = target * rows;
|
|
1357
|
+
this.first.set(first);
|
|
651
1358
|
if (this.serverSide()) {
|
|
652
|
-
this.pageChange.emit({
|
|
653
|
-
first: 0,
|
|
654
|
-
rows,
|
|
655
|
-
page: 0,
|
|
656
|
-
pageCount: Math.ceil(this.totalRecords() / rows),
|
|
657
|
-
});
|
|
1359
|
+
this.pageChange.emit({ first, rows, page: target, pageCount: Math.ceil(total / rows) });
|
|
658
1360
|
}
|
|
659
1361
|
else {
|
|
660
1362
|
this.updateDisplayedData();
|
|
661
1363
|
}
|
|
662
1364
|
}
|
|
1365
|
+
/** Goes to the first page (emits pageChange in server-side mode). */
|
|
1366
|
+
goToFirst() {
|
|
1367
|
+
this.goToPage(0);
|
|
1368
|
+
}
|
|
663
1369
|
/** Goes to the last page (emits pageChange in server-side mode). */
|
|
664
1370
|
goToLast() {
|
|
665
|
-
|
|
666
|
-
const rows = this.rowsPerPageLocal();
|
|
667
|
-
const lastFirst = Math.max(0, Math.ceil(total / rows) * rows - rows);
|
|
668
|
-
this.first.set(lastFirst);
|
|
669
|
-
if (this.serverSide()) {
|
|
670
|
-
const page = Math.floor(lastFirst / rows);
|
|
671
|
-
this.pageChange.emit({
|
|
672
|
-
first: lastFirst,
|
|
673
|
-
rows,
|
|
674
|
-
page,
|
|
675
|
-
pageCount: Math.ceil(total / rows),
|
|
676
|
-
});
|
|
677
|
-
}
|
|
678
|
-
else {
|
|
679
|
-
this.updateDisplayedData();
|
|
680
|
-
}
|
|
1371
|
+
this.goToPage(this.totalPages() - 1);
|
|
681
1372
|
}
|
|
682
1373
|
/** Updates rows-per-page and resets to the first page. */
|
|
683
1374
|
onRowsPerPageChange(rows) {
|
|
684
1375
|
rows = Number(rows);
|
|
685
1376
|
this.rowsPerPageLocal.set(rows);
|
|
686
|
-
this.
|
|
687
|
-
if (this.serverSide()) {
|
|
688
|
-
this.pageChange.emit({
|
|
689
|
-
first: 0,
|
|
690
|
-
rows,
|
|
691
|
-
page: 0,
|
|
692
|
-
pageCount: Math.ceil(this.totalRecords() / rows),
|
|
693
|
-
});
|
|
694
|
-
}
|
|
695
|
-
else {
|
|
696
|
-
this.updateDisplayedData();
|
|
697
|
-
}
|
|
1377
|
+
this.goToPage(0);
|
|
698
1378
|
}
|
|
699
1379
|
/** Emits the refresh output. */
|
|
700
1380
|
refreshData() {
|
|
@@ -706,57 +1386,23 @@ class TableComponent {
|
|
|
706
1386
|
}
|
|
707
1387
|
/** Whether the current page is the last one. */
|
|
708
1388
|
isLastPage() {
|
|
709
|
-
|
|
710
|
-
return this.first() + this.rowsPerPageLocal() >= total;
|
|
1389
|
+
return this.first() + this.rowsPerPageLocal() >= this.effectiveTotalRecords();
|
|
711
1390
|
}
|
|
712
1391
|
/** Moves to the next page (emits pageChange in server-side mode). */
|
|
713
1392
|
next() {
|
|
714
|
-
|
|
715
|
-
const rows = this.rowsPerPageLocal();
|
|
716
|
-
let first = this.first() + rows;
|
|
717
|
-
if (first >= total) {
|
|
718
|
-
first = total - rows;
|
|
719
|
-
}
|
|
720
|
-
this.first.set(first);
|
|
721
|
-
if (this.serverSide()) {
|
|
722
|
-
const page = Math.floor(first / rows);
|
|
723
|
-
this.pageChange.emit({
|
|
724
|
-
first,
|
|
725
|
-
rows,
|
|
726
|
-
page,
|
|
727
|
-
pageCount: Math.ceil(total / rows),
|
|
728
|
-
});
|
|
729
|
-
}
|
|
730
|
-
else {
|
|
731
|
-
this.updateDisplayedData();
|
|
732
|
-
}
|
|
1393
|
+
this.goToPage(this.currentPage());
|
|
733
1394
|
}
|
|
734
1395
|
/** Moves to the previous page (emits pageChange in server mode). */
|
|
735
1396
|
prev() {
|
|
736
|
-
|
|
737
|
-
let first = this.first() - rows;
|
|
738
|
-
const total = this.serverSide() ? this.totalRecords() : this.filteredData().length;
|
|
739
|
-
if (first < 0) {
|
|
740
|
-
first = 0;
|
|
741
|
-
}
|
|
742
|
-
this.first.set(first);
|
|
743
|
-
if (this.serverSide()) {
|
|
744
|
-
const page = Math.floor(first / rows);
|
|
745
|
-
this.pageChange.emit({
|
|
746
|
-
first,
|
|
747
|
-
rows,
|
|
748
|
-
page,
|
|
749
|
-
pageCount: Math.ceil(total / rows),
|
|
750
|
-
});
|
|
751
|
-
}
|
|
752
|
-
else {
|
|
753
|
-
this.updateDisplayedData();
|
|
754
|
-
}
|
|
1397
|
+
this.goToPage(this.currentPage() - 2);
|
|
755
1398
|
}
|
|
756
1399
|
/** Resets the table to the first page. */
|
|
757
1400
|
reset() {
|
|
758
1401
|
this.goToFirst();
|
|
759
1402
|
}
|
|
1403
|
+
// ---------------------------------------------------------------------------
|
|
1404
|
+
// Actions & cells
|
|
1405
|
+
// ---------------------------------------------------------------------------
|
|
760
1406
|
/** Resolves the row action label, static or per-row function. */
|
|
761
1407
|
getRowActionLabel(action, rowData) {
|
|
762
1408
|
return typeof action.label === 'function' ? action.label(rowData) : action.label;
|
|
@@ -802,11 +1448,16 @@ class TableComponent {
|
|
|
802
1448
|
if (value === null || value === undefined)
|
|
803
1449
|
return '';
|
|
804
1450
|
const str = String(value);
|
|
805
|
-
return str.length > limit ? str.slice(0, limit) + '
|
|
1451
|
+
return str.length > limit ? str.slice(0, limit) + '…' : str;
|
|
1452
|
+
}
|
|
1453
|
+
/** Value of a `progress` cell clamped to 0-100. */
|
|
1454
|
+
getProgress(col, rowData) {
|
|
1455
|
+
const n = Number(this.resolveField(rowData, col.field));
|
|
1456
|
+
return isNaN(n) ? 0 : Math.max(0, Math.min(100, n));
|
|
806
1457
|
}
|
|
807
1458
|
/** Resolves the value displayed inside a tag cell, static or per-row function. */
|
|
808
1459
|
getTagValue(col, rowData) {
|
|
809
|
-
return col.tagValue ? col.tagValue(rowData) : String(rowData
|
|
1460
|
+
return col.tagValue ? col.tagValue(rowData) : String(this.resolveField(rowData, col.field) ?? '');
|
|
810
1461
|
}
|
|
811
1462
|
/** Resolves and validates the tag severity, falling back to 'secondary'. */
|
|
812
1463
|
getTagSeverity(col, rowData) {
|
|
@@ -847,7 +1498,7 @@ class TableComponent {
|
|
|
847
1498
|
onHeaderKeydown(event, col) {
|
|
848
1499
|
if (col.field === 'actions' || !col.sortable)
|
|
849
1500
|
return;
|
|
850
|
-
// Ignore keys typed inside the
|
|
1501
|
+
// Ignore keys typed inside the header buttons.
|
|
851
1502
|
if (event.target !== event.currentTarget)
|
|
852
1503
|
return;
|
|
853
1504
|
if (event.key === 'Enter' || event.key === ' ') {
|
|
@@ -922,25 +1573,24 @@ class TableComponent {
|
|
|
922
1573
|
}
|
|
923
1574
|
this.closeFilters();
|
|
924
1575
|
}
|
|
925
|
-
/** Closes the column filter
|
|
1576
|
+
/** Closes the column filter menu with Escape. */
|
|
926
1577
|
onEscape() {
|
|
927
1578
|
this.closeFilters();
|
|
928
1579
|
}
|
|
929
1580
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.23", ngImport: i0, type: TableComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
930
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.23", 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 }, 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 }, 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 }, bulkActions: { classPropertyName: "bulkActions", publicName: "bulkActions", isSignal: true, isRequired: false, transformFunction: null }, selection: { classPropertyName: "selection", publicName: "selection", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { selection: "selectionChange", refresh: "refresh", pageChange: "pageChange", filterChange: "filterChange", searchChange: "searchChange", filterClick: "filterClick" }, 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 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 [lucideIcon]=\"getIcon('search')\"\n class=\"w-3.5 h-3.5 _shk-text-surface-400 dark:[color:var(--shk-surface-500)]\"\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 dark:[border-color:var(--shk-surface-200)] rounded-md leading-5 _shk-bg-surface-50 dark:[background-color:var(--shk-surface-100)] placeholder:[color:var(--shk-surface-400)] dark:placeholder:[color:var(--shk-surface-500)] _shk-text-surface-700 dark:[color:var(--shk-surface-700)] focus:outline-none focus:bg-white dark:focus:[background-color:var(--shk-surface-800)] focus:[border-color:var(--shk-primary-500)] focus:ring-1 focus:[--tw-ring-color:var(--shk-primary-500)]\"\n />\n </div>\n }\n @if (filters().length > 0) {\n <div\n class=\"flex _shk-bg-surface-100 dark:[background-color:var(--shk-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 dark:[color:var(--shk-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 dark:[color:var(--shk-surface-400)] 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 dark:[color:var(--shk-surface-400)] hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)]\"\n >\n <svg [lucideIcon]=\"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 [lucideIcon]=\"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 [lucideIcon]=\"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 <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 dark:[background-color:var(--shk-surface-100)] border-b _shk-border dark:[border-color:var(--shk-surface-200)]\"\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)=\"col.field !== 'actions' && col.sortable && toggleSort(col.field)\"\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]=\"col.field === 'actions' ? col.width : null\"\n [style.min-width]=\"col.field === 'actions' ? col.width : 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 dark:[color:var(--shk-surface-400)] uppercase tracking-wider _shk-bg-surface-50 dark:[background-color:var(--shk-surface-100)] border-b _shk-border dark:[border-color:var(--shk-surface-200)] 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 [lucideIcon]=\"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 [lucideIcon]=\"getIcon('arrow-up-down')\"\n class=\"w-3.5 h-3.5 _shk-text-surface-400 dark:[color:var(--shk-surface-500)]\"\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.field, $event)\"\n [attr.aria-label]=\"'table.tooltips.filter' | transloco\"\n [attr.aria-expanded]=\"showFilterInput()[col.field] || false\"\n class=\"_shk-text-surface-400 dark:[color:var(--shk-surface-500)] hover:[color:var(--shk-surface-600)] dark:hover:[color:var(--shk-surface-300)] transition-colors\"\n >\n <svg\n [lucideIcon]=\"getIcon('filter')\"\n class=\"w-3.5 h-3.5\"\n [class._shk-text-primary]=\"hasFilterValue(col.field)\"\n ></svg>\n </button>\n </shk-tooltip>\n }\n </div>\n </div>\n @if (col.filter && showFilterInput()[col.field]) {\n <div\n shkPortal\n class=\"fixed z-[9999] p-2 w-[200px] normal-case tracking-normal font-normal bg-white dark:[background-color:var(--shk-surface-100)] border _shk-border dark:[border-color:var(--shk-surface-200)] rounded-lg shadow-lg\"\n [style.top]=\"filterPopupPosition().top + 'px'\"\n [style.left]=\"filterPopupPosition().left + 'px'\"\n [formGroup]=\"columnFiltersForm\"\n (click)=\"$event.stopPropagation()\"\n (keydown)=\"$event.stopPropagation()\"\n (keydown.escape)=\"closeFilters()\"\n >\n <div class=\"relative\">\n @if (col.filterType !== 'select') {\n <label [for]=\"uid + '-filter-' + col.field\" class=\"sr-only\">{{\n col.filterPlaceholder || ('common.search_placeholder' | transloco)\n }}</label>\n <input\n [id]=\"uid + '-filter-' + col.field\"\n type=\"text\"\n [formControlName]=\"col.field\"\n class=\"w-full px-3 py-1.5 text-sm rounded-md border _shk-border dark:[border-color:var(--shk-surface-200)] bg-white dark:[background-color:var(--shk-surface-100)] _shk-text-surface-700 dark:[color:var(--shk-surface-700)] focus:[border-color:var(--shk-primary-500)] focus:ring-1 focus:[--tw-ring-color:var(--shk-primary-500)] placeholder:[color:var(--shk-surface-400)] dark:placeholder:[color:var(--shk-surface-500)]\"\n [placeholder]=\"\n col.filterPlaceholder || ('common.search_placeholder' | transloco)\n \"\n />\n }\n @if (col.filterType === 'select') {\n <label [for]=\"uid + '-filter-' + col.field\" class=\"sr-only\">{{\n col.filterPlaceholder || ('common.search_placeholder' | transloco)\n }}</label>\n <select\n [id]=\"uid + '-filter-' + col.field\"\n [formControlName]=\"col.field\"\n class=\"w-full px-2 py-1 text-xs rounded-md border _shk-border dark:[border-color:var(--shk-surface-200)] bg-white dark:[background-color:var(--shk-surface-100)] _shk-text-surface-700 dark:[color:var(--shk-surface-700)] focus:[border-color:var(--shk-primary-500)] focus:ring-1 focus:[--tw-ring-color:var(--shk-primary-500)] appearance-none\"\n >\n <option [ngValue]=\"null\">{{ 'table.filterAll' | transloco }}</option>\n @for (opt of col.filterOptions || []; track opt.value) {\n <option [ngValue]=\"opt.value\">{{ opt.label }}</option>\n }\n </select>\n }\n @if (hasFilterValue(col.field) && col.filterType !== 'select') {\n <button\n type=\"button\"\n class=\"absolute right-2 top-1/2 -translate-y-1/2 _shk-text-surface-400 dark:[color:var(--shk-surface-500)] hover:[color:var(--shk-surface-600)] dark:hover:[color:var(--shk-surface-300)]\"\n (click)=\"clearFilter(col.field)\"\n >\n <svg [lucideIcon]=\"getIcon('x')\" class=\"w-3.5 h-3.5\"></svg>\n </button>\n }\n </div>\n </div>\n }\n } @else {\n <div class=\"flex items-center justify-center\">\n <span>{{ col.header }}</span>\n </div>\n }\n </th>\n }\n </tr>\n </thead>\n @if (loading()) {\n <tbody class=\"border-b _shk-border dark:[border-color:var(--shk-surface-100)]\">\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 [lucideIcon]=\"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 dark:[border-color:var(--shk-surface-100)]\">\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 dark:[background-color:var(--shk-surface-100)] rounded-full flex items-center justify-center mb-4\"\n >\n <svg\n [lucideIcon]=\"getIcon('inbox')\"\n class=\"w-8 h-8 _shk-text-surface-400 dark:[color:var(--shk-surface-500)]\"\n ></svg>\n </div>\n <p\n class=\"text-lg font-semibold _shk-text-surface-600 dark:[color:var(--shk-surface-300)]\"\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 <tr\n [attr.aria-selected]=\"selectable() ? isRowSelected(rowData) : null\"\n [class.shk-row-selected]=\"selectable() && isRowSelected(rowData)\"\n class=\"hover:[background-color:color-mix(in srgb,var(--shk-primary-50)30%,transparent)] dark:hover:[background-color:color-mix(in srgb,var(--shk-primary-900)10%,transparent)] transition-colors duration-200 border-b _shk-border dark:[border-color:var(--shk-surface-100)]\"\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.overflow]=\"col.field === 'actions' ? 'visible' : 'visible'\"\n [style.text-overflow]=\"'clip'\"\n [style.--shk-col-width]=\"col.field !== 'actions' ? getColumnWidth(col) : null\"\n >\n @if (col.field !== 'actions') {\n @if (col.template === '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 } @else 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 } @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 [lucideIcon]=\"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 [lucideIcon]=\"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 dark:[border-color:var(--shk-surface-200)] 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 [lucideIcon]=\"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 </div>\n }\n </td>\n }\n </tr>\n }\n </tbody>\n }\n </table>\n <ng-template #defaultTemplate let-rowData let-field=\"field\">\n {{ rowData[field] }}\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 dark:[border-color:var(--shk-surface-100)]\"\n >\n <div class=\"text-xs _shk-text-surface-600 dark:[color:var(--shk-surface-400)]\">\n {{ pageReport() }}\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 class=\"shk-page-btn p-1 _shk-text-surface-500 hover:[color:var(--shk-surface-700)] dark:[color:var(--shk-surface-400)] dark:hover:[color:var(--shk-surface-200)] disabled:opacity-30 disabled:cursor-not-allowed rounded transition-colors\"\n >\n <svg [lucideIcon]=\"getIcon('chevrons-left')\" class=\"w-4 h-4\"></svg>\n </button>\n <button\n type=\"button\"\n (click)=\"prev()\"\n [disabled]=\"isFirstPage()\"\n class=\"shk-page-btn p-1 _shk-text-surface-500 hover:[color:var(--shk-surface-700)] dark:[color:var(--shk-surface-400)] dark:hover:[color:var(--shk-surface-200)] disabled:opacity-30 disabled:cursor-not-allowed rounded transition-colors\"\n >\n <svg [lucideIcon]=\"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 dark:[color:var(--shk-surface-700)]\"\n >{{ currentPage() }} / {{ totalPages() }}</span\n >\n <button\n type=\"button\"\n (click)=\"next()\"\n [disabled]=\"isLastPage()\"\n class=\"shk-page-btn p-1 _shk-text-surface-500 hover:[color:var(--shk-surface-700)] dark:[color:var(--shk-surface-400)] dark:hover:[color:var(--shk-surface-200)] disabled:opacity-30 disabled:cursor-not-allowed rounded transition-colors\"\n >\n <svg [lucideIcon]=\"getIcon('chevron-right')\" class=\"w-4 h-4\"></svg>\n </button>\n <button\n type=\"button\"\n (click)=\"goToLast()\"\n [disabled]=\"isLastPage()\"\n class=\"shk-page-btn p-1 _shk-text-surface-500 hover:[color:var(--shk-surface-700)] dark:[color:var(--shk-surface-400)] dark:hover:[color:var(--shk-surface-200)] disabled:opacity-30 disabled:cursor-not-allowed rounded transition-colors\"\n >\n <svg [lucideIcon]=\"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 dark:[color:var(--shk-surface-400)]\"\n >\n <label [for]=\"uid + '-rows-per-page'\">{{ 'table.rows' | transloco }}</label>\n <select\n [id]=\"uid + '-rows-per-page'\"\n [value]=\"rowsPerPageLocal()\"\n (change)=\"onRowsPerPageChange($any($event.target).value)\"\n class=\"border _shk-border dark:[border-color:var(--shk-surface-200)] rounded px-2 py-1 text-xs bg-white dark:[background-color:var(--shk-surface-100)] _shk-text-surface-700 dark:[color:var(--shk-surface-700)] focus:outline-none focus:[border-color:var(--shk-primary-500)]\"\n >\n @for (opt of rowsPerPageOptions(); track opt) {\n <option [value]=\"opt\">{{ opt }}</option>\n }\n </select>\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}\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: ReactiveFormsModule }, { kind: "directive", type: i2.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i2.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i2.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i2.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "ngmodule", type: TranslocoModule }, { kind: "component", type: LucideDynamicIcon, selector: "svg[lucideIcon]", inputs: ["lucideIcon"] }, { 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: i3.TranslocoPipe, name: "transloco" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
1581
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.23", 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 }, validateRequired: { classPropertyName: "validateRequired", publicName: "validateRequired", 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 }, 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 missingRowsCount() > 0 ||\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 (missingRowsCount() > 0) {\n <span\n class=\"shk-missing-summary inline-flex items-center gap-1.5 px-2.5 py-1.5 text-xs font-medium rounded-md whitespace-nowrap order-last\"\n role=\"status\"\n >\n <svg [lucideIcon]=\"getIcon('triangle-alert')\" class=\"w-3.5 h-3.5 shrink-0\"></svg>\n {{ tr('table.missing.summary', '{{count}} fila(s) con datos faltantes', { count: missingRowsCount() }) }}\n </span>\n }\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 [lucideIcon]=\"getIcon('search')\"\n class=\"w-3.5 h-3.5 _shk-text-surface-400 dark:[color:var(--shk-surface-500)]\"\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 dark:[border-color:var(--shk-surface-200)] rounded-md leading-5 _shk-bg-surface-50 dark:[background-color:var(--shk-surface-100)] placeholder:[color:var(--shk-surface-400)] dark:placeholder:[color:var(--shk-surface-500)] _shk-text-surface-700 dark:[color:var(--shk-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 dark:[border-color:var(--shk-surface-200)] _shk-text-surface-600 dark:[color:var(--shk-surface-500)] 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 [lucideIcon]=\"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 dark:[background-color:var(--shk-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 dark:[color:var(--shk-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 dark:[color:var(--shk-surface-400)] 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 dark:[color:var(--shk-surface-400)] hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)]\"\n >\n <svg [lucideIcon]=\"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 [lucideIcon]=\"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 [lucideIcon]=\"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 [class.shk-gridlines]=\"showGridlines()\" [class.shk-row-hover]=\"rowHover()\">\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 dark:[background-color:var(--shk-surface-100)] border-b _shk-border dark:[border-color:var(--shk-surface-200)]\"\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 @if (validateRequired()) {\n <th\n scope=\"col\"\n data-shk-status\n class=\"w-8 px-1 py-2 min-[1440px]:py-2.5 _shk-bg-surface-50 dark:[background-color:var(--shk-surface-100)] border-b _shk-border dark:[border-color:var(--shk-surface-200)]\"\n >\n <span class=\"sr-only\">{{ tr('table.missing.column', 'Datos faltantes') }}</span>\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]=\"col.field === 'actions' ? col.width : resizedWidth(col)\"\n [style.min-width]=\"col.field === 'actions' ? col.width : resizedWidth(col) || 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 dark:[color:var(--shk-surface-400)] uppercase tracking-wider _shk-bg-surface-50 dark:[background-color:var(--shk-surface-100)] border-b _shk-border dark:[border-color:var(--shk-surface-200)] 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 [lucideIcon]=\"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 [lucideIcon]=\"getIcon('arrow-up-down')\"\n class=\"w-3.5 h-3.5 _shk-text-surface-400 dark:[color:var(--shk-surface-500)]\"\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 dark:[color:var(--shk-surface-500)] hover:[color:var(--shk-surface-600)] dark:hover:[color:var(--shk-surface-300)] transition-colors\"\n >\n <svg\n [lucideIcon]=\"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 @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\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 dark:[color:var(--shk-surface-700)] bg-white dark:[background-color:var(--shk-surface-100)] border _shk-border dark:[border-color:var(--shk-surface-200)] 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 dark:[color:var(--shk-surface-800)]\">\n {{ col.filterMenuTitle }}\n </div>\n }\n @if (showOperatorFor(col)) {\n <div class=\"p-2 border-b _shk-border dark:[border-color:var(--shk-surface-200)]\">\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 [lucideIcon]=\"getIcon('check')\"></svg>\n } @else if (boolValue === false) {\n <svg [lucideIcon]=\"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 dark:[color:var(--shk-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 [lucideIcon]=\"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 [lucideIcon]=\"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 dark:[border-color:var(--shk-surface-200)]\">\n <button\n type=\"button\"\n class=\"px-3 py-1.5 font-medium rounded-md border _shk-border dark:[border-color:var(--shk-surface-200)] _shk-text-surface-600 dark:[color:var(--shk-surface-500)] 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 </th>\n }\n </tr>\n </thead>\n @if (loading()) {\n <tbody class=\"border-b _shk-border dark:[border-color:var(--shk-surface-100)]\">\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 [lucideIcon]=\"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 dark:[border-color:var(--shk-surface-100)]\">\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 dark:[background-color:var(--shk-surface-100)] rounded-full flex items-center justify-center mb-4\"\n >\n <svg\n [lucideIcon]=\"getIcon('inbox')\"\n class=\"w-8 h-8 _shk-text-surface-400 dark:[color:var(--shk-surface-500)]\"\n ></svg>\n </div>\n <p\n class=\"text-lg font-semibold _shk-text-surface-600 dark:[color:var(--shk-surface-300)]\"\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 <tr\n [attr.aria-selected]=\"selectable() ? isRowSelected(rowData) : null\"\n [class.shk-row-selected]=\"selectable() && isRowSelected(rowData)\"\n [class.shk-row-missing]=\"missingFields(rowData).length > 0\"\n class=\"shk-data-row transition-colors duration-200 border-b _shk-border dark:[border-color:var(--shk-surface-100)]\"\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 @if (validateRequired()) {\n <td data-shk-status class=\"w-8 px-1 py-2 text-center\">\n @if (missingFields(rowData); as missing) {\n @if (missing.length > 0) {\n <shk-tooltip [text]=\"missingRowMessage(missing)\" position=\"right\" mode=\"fixed\">\n <svg\n [lucideIcon]=\"getIcon('triangle-alert')\"\n class=\"shk-missing-icon w-4 h-4 inline-block\"\n role=\"img\"\n [attr.aria-label]=\"missingRowMessage(missing)\"\n ></svg>\n </shk-tooltip>\n }\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' && isCellMissing(col, rowData)) {\n <span class=\"shk-missing-cell inline-flex items-center gap-1 italic\">\n <svg [lucideIcon]=\"getIcon('triangle-alert')\" class=\"w-3.5 h-3.5 shrink-0\"></svg>\n {{ missingCellMessage(col) }}\n </span>\n } @else 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 [lucideIcon]=\"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 [lucideIcon]=\"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 {{ resolveField(rowData, col.field) | date: col.dateFormat || 'dd/MM/yyyy' }}\n }\n @case ('currency') {\n {{ resolveField(rowData, col.field) | currency: col.currency || 'USD' : 'symbol' }}\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 [lucideIcon]=\"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 [lucideIcon]=\"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 dark:[border-color:var(--shk-surface-200)] 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 [lucideIcon]=\"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 </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 [lucideIcon]=\"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 dark:[border-color:var(--shk-surface-200)] 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 [lucideIcon]=\"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 dark:[border-color:var(--shk-surface-100)]\"\n >\n <div class=\"text-xs _shk-text-surface-600 dark:[color:var(--shk-surface-400)]\">\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:[color:var(--shk-surface-400)] dark:hover:[color:var(--shk-surface-200)] disabled:opacity-30 disabled:cursor-not-allowed rounded transition-colors\"\n >\n <svg [lucideIcon]=\"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:[color:var(--shk-surface-400)] dark:hover:[color:var(--shk-surface-200)] disabled:opacity-30 disabled:cursor-not-allowed rounded transition-colors\"\n >\n <svg [lucideIcon]=\"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 dark:[color:var(--shk-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:[color:var(--shk-surface-400)] dark:hover:[color:var(--shk-surface-200)] disabled:opacity-30 disabled:cursor-not-allowed rounded transition-colors\"\n >\n <svg [lucideIcon]=\"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:[color:var(--shk-surface-400)] dark:hover:[color:var(--shk-surface-200)] disabled:opacity-30 disabled:cursor-not-allowed rounded transition-colors\"\n >\n <svg [lucideIcon]=\"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 dark:[color:var(--shk-surface-400)]\"\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 dark:[border-color:var(--shk-surface-200)] rounded px-2 py-1 text-xs bg-white dark:[background-color:var(--shk-surface-100)] _shk-text-surface-700 dark:[color:var(--shk-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]):not([data-shk-status]){min-width:var(--shk-col-width, 140px)}.table-scroll-wrapper td:not([data-shk-actions]):not([data-shk-select]):not([data-shk-status]){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}th[data-shk-status],td[data-shk-status]{width:2rem;min-width:2rem}tr.shk-row-missing{background-color:color-mix(in srgb,var(--shk-warning-400) 9%,transparent)}tr.shk-row-missing>td:first-child{box-shadow:inset 3px 0 0 var(--shk-warning-400)}table.shk-row-hover tbody tr.shk-row-missing.shk-data-row:hover{background-color:color-mix(in srgb,var(--shk-warning-400) 15%,transparent)}.shk-missing-icon,.shk-missing-cell{color:var(--shk-warning-600)}:host-context(.dark) .shk-missing-icon,:host-context(.dark) .shk-missing-cell{color:var(--shk-warning-400)}.shk-missing-summary{color:var(--shk-warning-800);background-color:var(--shk-warning-50);border:1px solid color-mix(in srgb,var(--shk-warning-400) 45%,transparent)}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: "component", type: LucideDynamicIcon, selector: "svg[lucideIcon]", inputs: ["lucideIcon"] }, { 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: i1.CurrencyPipe, name: "currency" }, { kind: "pipe", type: i1.DatePipe, name: "date" }, { kind: "pipe", type: i2.TranslocoPipe, name: "transloco" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
931
1582
|
}
|
|
932
1583
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.23", ngImport: i0, type: TableComponent, decorators: [{
|
|
933
1584
|
type: Component,
|
|
934
1585
|
args: [{ selector: 'shk-table', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, imports: [
|
|
935
1586
|
PortalDirective,
|
|
936
1587
|
CommonModule,
|
|
937
|
-
ReactiveFormsModule,
|
|
938
1588
|
TranslocoModule,
|
|
939
1589
|
LucideDynamicIcon,
|
|
940
1590
|
TagComponent,
|
|
941
1591
|
TooltipComponent,
|
|
942
|
-
], 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 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 [lucideIcon]=\"getIcon('search')\"\n class=\"w-3.5 h-3.5 _shk-text-surface-400 dark:[color:var(--shk-surface-500)]\"\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 dark:[border-color:var(--shk-surface-200)] rounded-md leading-5 _shk-bg-surface-50 dark:[background-color:var(--shk-surface-100)] placeholder:[color:var(--shk-surface-400)] dark:placeholder:[color:var(--shk-surface-500)] _shk-text-surface-700 dark:[color:var(--shk-surface-700)] focus:outline-none focus:bg-white dark:focus:[background-color:var(--shk-surface-800)] focus:[border-color:var(--shk-primary-500)] focus:ring-1 focus:[--tw-ring-color:var(--shk-primary-500)]\"\n />\n </div>\n }\n @if (filters().length > 0) {\n <div\n class=\"flex _shk-bg-surface-100 dark:[background-color:var(--shk-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 dark:[color:var(--shk-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 dark:[color:var(--shk-surface-400)] 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 dark:[color:var(--shk-surface-400)] hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)]\"\n >\n <svg [lucideIcon]=\"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 [lucideIcon]=\"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 [lucideIcon]=\"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 <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 dark:[background-color:var(--shk-surface-100)] border-b _shk-border dark:[border-color:var(--shk-surface-200)]\"\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)=\"col.field !== 'actions' && col.sortable && toggleSort(col.field)\"\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]=\"col.field === 'actions' ? col.width : null\"\n [style.min-width]=\"col.field === 'actions' ? col.width : 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 dark:[color:var(--shk-surface-400)] uppercase tracking-wider _shk-bg-surface-50 dark:[background-color:var(--shk-surface-100)] border-b _shk-border dark:[border-color:var(--shk-surface-200)] 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 [lucideIcon]=\"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 [lucideIcon]=\"getIcon('arrow-up-down')\"\n class=\"w-3.5 h-3.5 _shk-text-surface-400 dark:[color:var(--shk-surface-500)]\"\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.field, $event)\"\n [attr.aria-label]=\"'table.tooltips.filter' | transloco\"\n [attr.aria-expanded]=\"showFilterInput()[col.field] || false\"\n class=\"_shk-text-surface-400 dark:[color:var(--shk-surface-500)] hover:[color:var(--shk-surface-600)] dark:hover:[color:var(--shk-surface-300)] transition-colors\"\n >\n <svg\n [lucideIcon]=\"getIcon('filter')\"\n class=\"w-3.5 h-3.5\"\n [class._shk-text-primary]=\"hasFilterValue(col.field)\"\n ></svg>\n </button>\n </shk-tooltip>\n }\n </div>\n </div>\n @if (col.filter && showFilterInput()[col.field]) {\n <div\n shkPortal\n class=\"fixed z-[9999] p-2 w-[200px] normal-case tracking-normal font-normal bg-white dark:[background-color:var(--shk-surface-100)] border _shk-border dark:[border-color:var(--shk-surface-200)] rounded-lg shadow-lg\"\n [style.top]=\"filterPopupPosition().top + 'px'\"\n [style.left]=\"filterPopupPosition().left + 'px'\"\n [formGroup]=\"columnFiltersForm\"\n (click)=\"$event.stopPropagation()\"\n (keydown)=\"$event.stopPropagation()\"\n (keydown.escape)=\"closeFilters()\"\n >\n <div class=\"relative\">\n @if (col.filterType !== 'select') {\n <label [for]=\"uid + '-filter-' + col.field\" class=\"sr-only\">{{\n col.filterPlaceholder || ('common.search_placeholder' | transloco)\n }}</label>\n <input\n [id]=\"uid + '-filter-' + col.field\"\n type=\"text\"\n [formControlName]=\"col.field\"\n class=\"w-full px-3 py-1.5 text-sm rounded-md border _shk-border dark:[border-color:var(--shk-surface-200)] bg-white dark:[background-color:var(--shk-surface-100)] _shk-text-surface-700 dark:[color:var(--shk-surface-700)] focus:[border-color:var(--shk-primary-500)] focus:ring-1 focus:[--tw-ring-color:var(--shk-primary-500)] placeholder:[color:var(--shk-surface-400)] dark:placeholder:[color:var(--shk-surface-500)]\"\n [placeholder]=\"\n col.filterPlaceholder || ('common.search_placeholder' | transloco)\n \"\n />\n }\n @if (col.filterType === 'select') {\n <label [for]=\"uid + '-filter-' + col.field\" class=\"sr-only\">{{\n col.filterPlaceholder || ('common.search_placeholder' | transloco)\n }}</label>\n <select\n [id]=\"uid + '-filter-' + col.field\"\n [formControlName]=\"col.field\"\n class=\"w-full px-2 py-1 text-xs rounded-md border _shk-border dark:[border-color:var(--shk-surface-200)] bg-white dark:[background-color:var(--shk-surface-100)] _shk-text-surface-700 dark:[color:var(--shk-surface-700)] focus:[border-color:var(--shk-primary-500)] focus:ring-1 focus:[--tw-ring-color:var(--shk-primary-500)] appearance-none\"\n >\n <option [ngValue]=\"null\">{{ 'table.filterAll' | transloco }}</option>\n @for (opt of col.filterOptions || []; track opt.value) {\n <option [ngValue]=\"opt.value\">{{ opt.label }}</option>\n }\n </select>\n }\n @if (hasFilterValue(col.field) && col.filterType !== 'select') {\n <button\n type=\"button\"\n class=\"absolute right-2 top-1/2 -translate-y-1/2 _shk-text-surface-400 dark:[color:var(--shk-surface-500)] hover:[color:var(--shk-surface-600)] dark:hover:[color:var(--shk-surface-300)]\"\n (click)=\"clearFilter(col.field)\"\n >\n <svg [lucideIcon]=\"getIcon('x')\" class=\"w-3.5 h-3.5\"></svg>\n </button>\n }\n </div>\n </div>\n }\n } @else {\n <div class=\"flex items-center justify-center\">\n <span>{{ col.header }}</span>\n </div>\n }\n </th>\n }\n </tr>\n </thead>\n @if (loading()) {\n <tbody class=\"border-b _shk-border dark:[border-color:var(--shk-surface-100)]\">\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 [lucideIcon]=\"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 dark:[border-color:var(--shk-surface-100)]\">\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 dark:[background-color:var(--shk-surface-100)] rounded-full flex items-center justify-center mb-4\"\n >\n <svg\n [lucideIcon]=\"getIcon('inbox')\"\n class=\"w-8 h-8 _shk-text-surface-400 dark:[color:var(--shk-surface-500)]\"\n ></svg>\n </div>\n <p\n class=\"text-lg font-semibold _shk-text-surface-600 dark:[color:var(--shk-surface-300)]\"\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 <tr\n [attr.aria-selected]=\"selectable() ? isRowSelected(rowData) : null\"\n [class.shk-row-selected]=\"selectable() && isRowSelected(rowData)\"\n class=\"hover:[background-color:color-mix(in srgb,var(--shk-primary-50)30%,transparent)] dark:hover:[background-color:color-mix(in srgb,var(--shk-primary-900)10%,transparent)] transition-colors duration-200 border-b _shk-border dark:[border-color:var(--shk-surface-100)]\"\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.overflow]=\"col.field === 'actions' ? 'visible' : 'visible'\"\n [style.text-overflow]=\"'clip'\"\n [style.--shk-col-width]=\"col.field !== 'actions' ? getColumnWidth(col) : null\"\n >\n @if (col.field !== 'actions') {\n @if (col.template === '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 } @else 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 } @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 [lucideIcon]=\"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 [lucideIcon]=\"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 dark:[border-color:var(--shk-surface-200)] 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 [lucideIcon]=\"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 </div>\n }\n </td>\n }\n </tr>\n }\n </tbody>\n }\n </table>\n <ng-template #defaultTemplate let-rowData let-field=\"field\">\n {{ rowData[field] }}\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 dark:[border-color:var(--shk-surface-100)]\"\n >\n <div class=\"text-xs _shk-text-surface-600 dark:[color:var(--shk-surface-400)]\">\n {{ pageReport() }}\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 class=\"shk-page-btn p-1 _shk-text-surface-500 hover:[color:var(--shk-surface-700)] dark:[color:var(--shk-surface-400)] dark:hover:[color:var(--shk-surface-200)] disabled:opacity-30 disabled:cursor-not-allowed rounded transition-colors\"\n >\n <svg [lucideIcon]=\"getIcon('chevrons-left')\" class=\"w-4 h-4\"></svg>\n </button>\n <button\n type=\"button\"\n (click)=\"prev()\"\n [disabled]=\"isFirstPage()\"\n class=\"shk-page-btn p-1 _shk-text-surface-500 hover:[color:var(--shk-surface-700)] dark:[color:var(--shk-surface-400)] dark:hover:[color:var(--shk-surface-200)] disabled:opacity-30 disabled:cursor-not-allowed rounded transition-colors\"\n >\n <svg [lucideIcon]=\"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 dark:[color:var(--shk-surface-700)]\"\n >{{ currentPage() }} / {{ totalPages() }}</span\n >\n <button\n type=\"button\"\n (click)=\"next()\"\n [disabled]=\"isLastPage()\"\n class=\"shk-page-btn p-1 _shk-text-surface-500 hover:[color:var(--shk-surface-700)] dark:[color:var(--shk-surface-400)] dark:hover:[color:var(--shk-surface-200)] disabled:opacity-30 disabled:cursor-not-allowed rounded transition-colors\"\n >\n <svg [lucideIcon]=\"getIcon('chevron-right')\" class=\"w-4 h-4\"></svg>\n </button>\n <button\n type=\"button\"\n (click)=\"goToLast()\"\n [disabled]=\"isLastPage()\"\n class=\"shk-page-btn p-1 _shk-text-surface-500 hover:[color:var(--shk-surface-700)] dark:[color:var(--shk-surface-400)] dark:hover:[color:var(--shk-surface-200)] disabled:opacity-30 disabled:cursor-not-allowed rounded transition-colors\"\n >\n <svg [lucideIcon]=\"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 dark:[color:var(--shk-surface-400)]\"\n >\n <label [for]=\"uid + '-rows-per-page'\">{{ 'table.rows' | transloco }}</label>\n <select\n [id]=\"uid + '-rows-per-page'\"\n [value]=\"rowsPerPageLocal()\"\n (change)=\"onRowsPerPageChange($any($event.target).value)\"\n class=\"border _shk-border dark:[border-color:var(--shk-surface-200)] rounded px-2 py-1 text-xs bg-white dark:[background-color:var(--shk-surface-100)] _shk-text-surface-700 dark:[color:var(--shk-surface-700)] focus:outline-none focus:[border-color:var(--shk-primary-500)]\"\n >\n @for (opt of rowsPerPageOptions(); track opt) {\n <option [value]=\"opt\">{{ opt }}</option>\n }\n </select>\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}\n"] }]
|
|
943
|
-
}], 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 }] }], 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 }] }], 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 }] }], 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"] }], onDocumentClick: [{
|
|
1592
|
+
], 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 missingRowsCount() > 0 ||\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 (missingRowsCount() > 0) {\n <span\n class=\"shk-missing-summary inline-flex items-center gap-1.5 px-2.5 py-1.5 text-xs font-medium rounded-md whitespace-nowrap order-last\"\n role=\"status\"\n >\n <svg [lucideIcon]=\"getIcon('triangle-alert')\" class=\"w-3.5 h-3.5 shrink-0\"></svg>\n {{ tr('table.missing.summary', '{{count}} fila(s) con datos faltantes', { count: missingRowsCount() }) }}\n </span>\n }\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 [lucideIcon]=\"getIcon('search')\"\n class=\"w-3.5 h-3.5 _shk-text-surface-400 dark:[color:var(--shk-surface-500)]\"\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 dark:[border-color:var(--shk-surface-200)] rounded-md leading-5 _shk-bg-surface-50 dark:[background-color:var(--shk-surface-100)] placeholder:[color:var(--shk-surface-400)] dark:placeholder:[color:var(--shk-surface-500)] _shk-text-surface-700 dark:[color:var(--shk-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 dark:[border-color:var(--shk-surface-200)] _shk-text-surface-600 dark:[color:var(--shk-surface-500)] 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 [lucideIcon]=\"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 dark:[background-color:var(--shk-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 dark:[color:var(--shk-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 dark:[color:var(--shk-surface-400)] 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 dark:[color:var(--shk-surface-400)] hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)]\"\n >\n <svg [lucideIcon]=\"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 [lucideIcon]=\"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 [lucideIcon]=\"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 [class.shk-gridlines]=\"showGridlines()\" [class.shk-row-hover]=\"rowHover()\">\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 dark:[background-color:var(--shk-surface-100)] border-b _shk-border dark:[border-color:var(--shk-surface-200)]\"\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 @if (validateRequired()) {\n <th\n scope=\"col\"\n data-shk-status\n class=\"w-8 px-1 py-2 min-[1440px]:py-2.5 _shk-bg-surface-50 dark:[background-color:var(--shk-surface-100)] border-b _shk-border dark:[border-color:var(--shk-surface-200)]\"\n >\n <span class=\"sr-only\">{{ tr('table.missing.column', 'Datos faltantes') }}</span>\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]=\"col.field === 'actions' ? col.width : resizedWidth(col)\"\n [style.min-width]=\"col.field === 'actions' ? col.width : resizedWidth(col) || 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 dark:[color:var(--shk-surface-400)] uppercase tracking-wider _shk-bg-surface-50 dark:[background-color:var(--shk-surface-100)] border-b _shk-border dark:[border-color:var(--shk-surface-200)] 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 [lucideIcon]=\"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 [lucideIcon]=\"getIcon('arrow-up-down')\"\n class=\"w-3.5 h-3.5 _shk-text-surface-400 dark:[color:var(--shk-surface-500)]\"\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 dark:[color:var(--shk-surface-500)] hover:[color:var(--shk-surface-600)] dark:hover:[color:var(--shk-surface-300)] transition-colors\"\n >\n <svg\n [lucideIcon]=\"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 @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\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 dark:[color:var(--shk-surface-700)] bg-white dark:[background-color:var(--shk-surface-100)] border _shk-border dark:[border-color:var(--shk-surface-200)] 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 dark:[color:var(--shk-surface-800)]\">\n {{ col.filterMenuTitle }}\n </div>\n }\n @if (showOperatorFor(col)) {\n <div class=\"p-2 border-b _shk-border dark:[border-color:var(--shk-surface-200)]\">\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 [lucideIcon]=\"getIcon('check')\"></svg>\n } @else if (boolValue === false) {\n <svg [lucideIcon]=\"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 dark:[color:var(--shk-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 [lucideIcon]=\"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 [lucideIcon]=\"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 dark:[border-color:var(--shk-surface-200)]\">\n <button\n type=\"button\"\n class=\"px-3 py-1.5 font-medium rounded-md border _shk-border dark:[border-color:var(--shk-surface-200)] _shk-text-surface-600 dark:[color:var(--shk-surface-500)] 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 </th>\n }\n </tr>\n </thead>\n @if (loading()) {\n <tbody class=\"border-b _shk-border dark:[border-color:var(--shk-surface-100)]\">\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 [lucideIcon]=\"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 dark:[border-color:var(--shk-surface-100)]\">\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 dark:[background-color:var(--shk-surface-100)] rounded-full flex items-center justify-center mb-4\"\n >\n <svg\n [lucideIcon]=\"getIcon('inbox')\"\n class=\"w-8 h-8 _shk-text-surface-400 dark:[color:var(--shk-surface-500)]\"\n ></svg>\n </div>\n <p\n class=\"text-lg font-semibold _shk-text-surface-600 dark:[color:var(--shk-surface-300)]\"\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 <tr\n [attr.aria-selected]=\"selectable() ? isRowSelected(rowData) : null\"\n [class.shk-row-selected]=\"selectable() && isRowSelected(rowData)\"\n [class.shk-row-missing]=\"missingFields(rowData).length > 0\"\n class=\"shk-data-row transition-colors duration-200 border-b _shk-border dark:[border-color:var(--shk-surface-100)]\"\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 @if (validateRequired()) {\n <td data-shk-status class=\"w-8 px-1 py-2 text-center\">\n @if (missingFields(rowData); as missing) {\n @if (missing.length > 0) {\n <shk-tooltip [text]=\"missingRowMessage(missing)\" position=\"right\" mode=\"fixed\">\n <svg\n [lucideIcon]=\"getIcon('triangle-alert')\"\n class=\"shk-missing-icon w-4 h-4 inline-block\"\n role=\"img\"\n [attr.aria-label]=\"missingRowMessage(missing)\"\n ></svg>\n </shk-tooltip>\n }\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' && isCellMissing(col, rowData)) {\n <span class=\"shk-missing-cell inline-flex items-center gap-1 italic\">\n <svg [lucideIcon]=\"getIcon('triangle-alert')\" class=\"w-3.5 h-3.5 shrink-0\"></svg>\n {{ missingCellMessage(col) }}\n </span>\n } @else 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 [lucideIcon]=\"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 [lucideIcon]=\"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 {{ resolveField(rowData, col.field) | date: col.dateFormat || 'dd/MM/yyyy' }}\n }\n @case ('currency') {\n {{ resolveField(rowData, col.field) | currency: col.currency || 'USD' : 'symbol' }}\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 [lucideIcon]=\"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 [lucideIcon]=\"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 dark:[border-color:var(--shk-surface-200)] 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 [lucideIcon]=\"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 </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 [lucideIcon]=\"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 dark:[border-color:var(--shk-surface-200)] 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 [lucideIcon]=\"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 dark:[border-color:var(--shk-surface-100)]\"\n >\n <div class=\"text-xs _shk-text-surface-600 dark:[color:var(--shk-surface-400)]\">\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:[color:var(--shk-surface-400)] dark:hover:[color:var(--shk-surface-200)] disabled:opacity-30 disabled:cursor-not-allowed rounded transition-colors\"\n >\n <svg [lucideIcon]=\"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:[color:var(--shk-surface-400)] dark:hover:[color:var(--shk-surface-200)] disabled:opacity-30 disabled:cursor-not-allowed rounded transition-colors\"\n >\n <svg [lucideIcon]=\"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 dark:[color:var(--shk-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:[color:var(--shk-surface-400)] dark:hover:[color:var(--shk-surface-200)] disabled:opacity-30 disabled:cursor-not-allowed rounded transition-colors\"\n >\n <svg [lucideIcon]=\"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:[color:var(--shk-surface-400)] dark:hover:[color:var(--shk-surface-200)] disabled:opacity-30 disabled:cursor-not-allowed rounded transition-colors\"\n >\n <svg [lucideIcon]=\"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 dark:[color:var(--shk-surface-400)]\"\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 dark:[border-color:var(--shk-surface-200)] rounded px-2 py-1 text-xs bg-white dark:[background-color:var(--shk-surface-100)] _shk-text-surface-700 dark:[color:var(--shk-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]):not([data-shk-status]){min-width:var(--shk-col-width, 140px)}.table-scroll-wrapper td:not([data-shk-actions]):not([data-shk-select]):not([data-shk-status]){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}th[data-shk-status],td[data-shk-status]{width:2rem;min-width:2rem}tr.shk-row-missing{background-color:color-mix(in srgb,var(--shk-warning-400) 9%,transparent)}tr.shk-row-missing>td:first-child{box-shadow:inset 3px 0 0 var(--shk-warning-400)}table.shk-row-hover tbody tr.shk-row-missing.shk-data-row:hover{background-color:color-mix(in srgb,var(--shk-warning-400) 15%,transparent)}.shk-missing-icon,.shk-missing-cell{color:var(--shk-warning-600)}:host-context(.dark) .shk-missing-icon,:host-context(.dark) .shk-missing-cell{color:var(--shk-warning-400)}.shk-missing-summary{color:var(--shk-warning-800);background-color:var(--shk-warning-50);border:1px solid color-mix(in srgb,var(--shk-warning-400) 45%,transparent)}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"] }]
|
|
1593
|
+
}], 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 }] }], validateRequired: [{ type: i0.Input, args: [{ isSignal: true, alias: "validateRequired", 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 }] }], 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: [{
|
|
944
1594
|
type: HostListener,
|
|
945
1595
|
args: ['document:click']
|
|
946
1596
|
}], onEscape: [{
|