@masterteam/components 0.0.131 → 0.0.133

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/fesm2022/masterteam-components-business-fields.mjs +597 -0
  2. package/fesm2022/masterteam-components-business-fields.mjs.map +1 -0
  3. package/fesm2022/masterteam-components-button-group.mjs +20 -0
  4. package/fesm2022/masterteam-components-button-group.mjs.map +1 -0
  5. package/fesm2022/masterteam-components-chip.mjs +35 -0
  6. package/fesm2022/masterteam-components-chip.mjs.map +1 -0
  7. package/fesm2022/masterteam-components-client-page-menu.mjs +92 -0
  8. package/fesm2022/masterteam-components-client-page-menu.mjs.map +1 -0
  9. package/fesm2022/masterteam-components-client-page.mjs +160 -0
  10. package/fesm2022/masterteam-components-client-page.mjs.map +1 -0
  11. package/fesm2022/masterteam-components-color-picker-field.mjs +94 -0
  12. package/fesm2022/masterteam-components-color-picker-field.mjs.map +1 -0
  13. package/fesm2022/masterteam-components-date-field.mjs +93 -0
  14. package/fesm2022/masterteam-components-date-field.mjs.map +1 -0
  15. package/fesm2022/masterteam-components-drawer.mjs +69 -0
  16. package/fesm2022/masterteam-components-drawer.mjs.map +1 -0
  17. package/fesm2022/masterteam-components-editor-field.mjs +96 -0
  18. package/fesm2022/masterteam-components-editor-field.mjs.map +1 -0
  19. package/fesm2022/masterteam-components-entities.mjs +864 -0
  20. package/fesm2022/masterteam-components-entities.mjs.map +1 -0
  21. package/fesm2022/masterteam-components-formula.mjs +3116 -0
  22. package/fesm2022/masterteam-components-formula.mjs.map +1 -0
  23. package/fesm2022/masterteam-components-list.mjs +31 -0
  24. package/fesm2022/masterteam-components-list.mjs.map +1 -0
  25. package/fesm2022/masterteam-components-progress.mjs +49 -0
  26. package/fesm2022/masterteam-components-progress.mjs.map +1 -0
  27. package/fesm2022/masterteam-components-table.mjs +1153 -0
  28. package/fesm2022/masterteam-components-table.mjs.map +1 -0
  29. package/fesm2022/masterteam-components-toggle-field.mjs +2 -2
  30. package/fesm2022/masterteam-components-toggle-field.mjs.map +1 -1
  31. package/fesm2022/masterteam-components-tree.mjs +5 -2
  32. package/fesm2022/masterteam-components-tree.mjs.map +1 -1
  33. package/fesm2022/masterteam-components-upload-field.mjs +554 -0
  34. package/fesm2022/masterteam-components-upload-field.mjs.map +1 -0
  35. package/fesm2022/masterteam-components-user-search-field.mjs +153 -0
  36. package/fesm2022/masterteam-components-user-search-field.mjs.map +1 -0
  37. package/package.json +1 -1
  38. package/types/masterteam-components-business-fields.d.ts +213 -0
  39. package/types/masterteam-components-button-group.d.ts +8 -0
  40. package/types/masterteam-components-chip.d.ts +19 -0
  41. package/types/masterteam-components-client-page-menu.d.ts +35 -0
  42. package/types/masterteam-components-client-page.d.ts +56 -0
  43. package/types/masterteam-components-color-picker-field.d.ts +35 -0
  44. package/types/masterteam-components-date-field.d.ts +41 -0
  45. package/types/masterteam-components-drawer.d.ts +30 -0
  46. package/types/masterteam-components-editor-field.d.ts +34 -0
  47. package/types/masterteam-components-entities.d.ts +367 -0
  48. package/types/masterteam-components-formula.d.ts +656 -0
  49. package/types/masterteam-components-list.d.ts +18 -0
  50. package/types/masterteam-components-progress.d.ts +22 -0
  51. package/types/masterteam-components-table.d.ts +255 -0
  52. package/types/masterteam-components-upload-field.d.ts +77 -0
  53. package/types/masterteam-components-user-search-field.d.ts +61 -0
@@ -0,0 +1,1153 @@
1
+ import * as i0 from '@angular/core';
2
+ import { input, output, signal, computed, forwardRef, ChangeDetectionStrategy, Component, model, booleanAttribute, contentChild, viewChild, inject } from '@angular/core';
3
+ import { NgTemplateOutlet, DatePipe } from '@angular/common';
4
+ import * as i1 from '@angular/forms';
5
+ import { FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms';
6
+ import { Button } from '@masterteam/components/button';
7
+ import { DateField } from '@masterteam/components/date-field';
8
+ import { SelectField } from '@masterteam/components/select-field';
9
+ import { TextField } from '@masterteam/components/text-field';
10
+ import { UserSearchField } from '@masterteam/components/user-search-field';
11
+ import * as i3 from '@jsverse/transloco';
12
+ import { TranslocoModule } from '@jsverse/transloco';
13
+ import * as i2 from 'primeng/popover';
14
+ import { PopoverModule } from 'primeng/popover';
15
+ import { ToggleField } from '@masterteam/components/toggle-field';
16
+ import { Paginator } from '@masterteam/components/paginator';
17
+ import { CheckboxField } from '@masterteam/components/checkbox-field';
18
+ import * as i1$1 from 'primeng/table';
19
+ import { TableModule } from 'primeng/table';
20
+ import { Tabs } from '@masterteam/components/tabs';
21
+ import * as i3$1 from 'primeng/skeleton';
22
+ import { SkeletonModule } from 'primeng/skeleton';
23
+ import * as i4 from 'primeng/progressbar';
24
+ import { ProgressBarModule } from 'primeng/progressbar';
25
+ import { ConfirmationService } from '@masterteam/components/confirmation';
26
+ import { EntityPreview } from '@masterteam/components/entities';
27
+ import { Icon } from '@masterteam/icons';
28
+
29
+ class TableValueResolver {
30
+ static ALL_ENTITY_VIEW_TYPES = [
31
+ 'Text',
32
+ 'LongText',
33
+ 'Date',
34
+ 'DateTime',
35
+ 'Percentage',
36
+ 'Status',
37
+ 'Currency',
38
+ 'Checkbox',
39
+ 'User',
40
+ 'Lookup',
41
+ 'Attachment',
42
+ ];
43
+ static UNSORTABLE_ENTITY_VIEW_TYPES = new Set(['Attachment', 'Checkbox']);
44
+ static EXPORTABLE_ENTITY_VIEW_TYPES = new Set([
45
+ 'Text',
46
+ 'LongText',
47
+ 'Date',
48
+ 'DateTime',
49
+ 'Percentage',
50
+ 'Status',
51
+ 'Currency',
52
+ 'Checkbox',
53
+ 'User',
54
+ 'Lookup',
55
+ ]);
56
+ static FILTERABLE_ENTITY_VIEW_TYPES = new Set(TableValueResolver.ALL_ENTITY_VIEW_TYPES.filter((viewType) => viewType !== 'Attachment'));
57
+ static getProperty(obj, key) {
58
+ return key.split('.').reduce((current, segment) => {
59
+ if (!current || typeof current !== 'object') {
60
+ return undefined;
61
+ }
62
+ return current[segment];
63
+ }, obj);
64
+ }
65
+ static getColumnFilterType(column, row) {
66
+ if (column.filterConfig?.type) {
67
+ return column.filterConfig.type;
68
+ }
69
+ if (column.type === 'date') {
70
+ return 'date';
71
+ }
72
+ if (column.type === 'boolean') {
73
+ return 'boolean';
74
+ }
75
+ if (column.type === 'user') {
76
+ return 'user';
77
+ }
78
+ if (column.type === 'status') {
79
+ return 'select';
80
+ }
81
+ if (column.type !== 'entity') {
82
+ return null;
83
+ }
84
+ const viewType = TableValueResolver.getEntityViewType(column, row);
85
+ if (!viewType ||
86
+ !TableValueResolver.FILTERABLE_ENTITY_VIEW_TYPES.has(viewType)) {
87
+ return null;
88
+ }
89
+ switch (viewType) {
90
+ case 'Date':
91
+ case 'DateTime':
92
+ return 'date';
93
+ case 'Checkbox':
94
+ return 'boolean';
95
+ case 'Status':
96
+ case 'Lookup':
97
+ case 'User':
98
+ return 'select';
99
+ case 'Text':
100
+ case 'LongText':
101
+ case 'Currency':
102
+ case 'Percentage':
103
+ default:
104
+ return 'text';
105
+ }
106
+ }
107
+ static getColumnFilterValue(row, column) {
108
+ const cellValue = TableValueResolver.getProperty(row, column.key);
109
+ if (cellValue === null || cellValue === undefined) {
110
+ return null;
111
+ }
112
+ if (column.type === 'entity') {
113
+ const filterType = TableValueResolver.getColumnFilterType(column, row);
114
+ if (filterType === 'date') {
115
+ return TableValueResolver.getEntityValueByType(cellValue, 'sort');
116
+ }
117
+ return TableValueResolver.getEntityValueByType(cellValue, 'filter');
118
+ }
119
+ if (column.type === 'boolean') {
120
+ return TableValueResolver.resolveBooleanValue(cellValue);
121
+ }
122
+ return TableValueResolver.resolveDisplayValue(cellValue);
123
+ }
124
+ static getEntityValueByType(value, usage) {
125
+ if (value === null || value === undefined) {
126
+ return null;
127
+ }
128
+ if (typeof value !== 'object') {
129
+ return TableValueResolver.resolveDisplayValue(value);
130
+ }
131
+ const entityData = value;
132
+ if (usage === 'sort' &&
133
+ TableValueResolver.UNSORTABLE_ENTITY_VIEW_TYPES.has(entityData.viewType)) {
134
+ return null;
135
+ }
136
+ if (usage === 'export' &&
137
+ !TableValueResolver.EXPORTABLE_ENTITY_VIEW_TYPES.has(entityData.viewType)) {
138
+ return TableValueResolver.resolveDisplayValue(entityData.value);
139
+ }
140
+ switch (entityData.viewType) {
141
+ case 'Currency':
142
+ case 'Percentage':
143
+ return usage === 'sort'
144
+ ? TableValueResolver.normalizeNumericSortValue(entityData.rawValue ?? entityData.value)
145
+ : TableValueResolver.resolveDisplayValue(entityData.value);
146
+ case 'Date':
147
+ case 'DateTime':
148
+ return usage === 'sort'
149
+ ? TableValueResolver.normalizeDateSortValue(entityData.rawValue ?? entityData.value)
150
+ : TableValueResolver.resolveDisplayValue(entityData.value);
151
+ case 'Checkbox':
152
+ return TableValueResolver.resolveBooleanValue(entityData.rawValue ?? entityData.value);
153
+ case 'Status':
154
+ case 'Lookup':
155
+ case 'User':
156
+ case 'Text':
157
+ case 'LongText':
158
+ default:
159
+ return TableValueResolver.resolveDisplayValue(entityData.value);
160
+ }
161
+ }
162
+ static resolveDisplayValue(value) {
163
+ if (value === null || value === undefined || value === '') {
164
+ return null;
165
+ }
166
+ if (typeof value === 'string' ||
167
+ typeof value === 'number' ||
168
+ typeof value === 'boolean') {
169
+ return value;
170
+ }
171
+ if (value instanceof Date) {
172
+ return value.toISOString();
173
+ }
174
+ if (typeof value === 'object') {
175
+ const objectValue = value;
176
+ const displayCandidate = objectValue['display'] ??
177
+ objectValue['displayValue'] ??
178
+ objectValue['displayName'] ??
179
+ objectValue['name'] ??
180
+ objectValue['label'] ??
181
+ objectValue['value'];
182
+ return TableValueResolver.resolveDisplayValue(displayCandidate);
183
+ }
184
+ return String(value);
185
+ }
186
+ static resolveBooleanValue(value) {
187
+ if (value === null || value === undefined || value === '') {
188
+ return null;
189
+ }
190
+ if (typeof value === 'boolean') {
191
+ return value;
192
+ }
193
+ if (typeof value === 'string') {
194
+ return ['true', '1', 'yes', 'on'].includes(value.toLowerCase());
195
+ }
196
+ if (typeof value === 'number') {
197
+ return value === 1;
198
+ }
199
+ return null;
200
+ }
201
+ static normalizeTextSortValue(value) {
202
+ if (value === null || value === undefined || value === '') {
203
+ return null;
204
+ }
205
+ return String(value).toLocaleLowerCase();
206
+ }
207
+ static normalizeNumericSortValue(value) {
208
+ if (value === null || value === undefined || value === '') {
209
+ return null;
210
+ }
211
+ const numericValue = typeof value === 'number'
212
+ ? value
213
+ : Number.parseFloat(String(value).replace(/[^0-9.-]/g, ''));
214
+ return Number.isNaN(numericValue) ? null : numericValue;
215
+ }
216
+ static normalizeDateSortValue(value) {
217
+ if (value === null || value === undefined || value === '') {
218
+ return null;
219
+ }
220
+ const timestamp = value instanceof Date
221
+ ? value.getTime()
222
+ : new Date(String(value)).getTime();
223
+ return Number.isNaN(timestamp) ? null : timestamp;
224
+ }
225
+ static getEntityViewType(column, row) {
226
+ const explicitViewType = column.viewType;
227
+ if (TableValueResolver.isEntityViewType(explicitViewType)) {
228
+ return explicitViewType;
229
+ }
230
+ const cellValue = row
231
+ ? TableValueResolver.getProperty(row, column.key)
232
+ : undefined;
233
+ if (cellValue &&
234
+ typeof cellValue === 'object' &&
235
+ 'viewType' in cellValue) {
236
+ const viewType = cellValue.viewType;
237
+ if (TableValueResolver.isEntityViewType(viewType)) {
238
+ return viewType;
239
+ }
240
+ }
241
+ return null;
242
+ }
243
+ static isEntityViewType(value) {
244
+ return (typeof value === 'string' &&
245
+ TableValueResolver.ALL_ENTITY_VIEW_TYPES.includes(value));
246
+ }
247
+ }
248
+
249
+ class TableFilter {
250
+ columns = input.required(...(ngDevMode ? [{ debugName: "columns" }] : []));
251
+ data = input([], ...(ngDevMode ? [{ debugName: "data" }] : []));
252
+ filterApplied = output();
253
+ filterReset = output();
254
+ pendingFilters = signal({}, ...(ngDevMode ? [{ debugName: "pendingFilters" }] : []));
255
+ appliedFilters = signal({}, ...(ngDevMode ? [{ debugName: "appliedFilters" }] : []));
256
+ booleanOptions = [
257
+ { label: 'Yes', value: true },
258
+ { label: 'No', value: false },
259
+ ];
260
+ onChange = () => { };
261
+ onTouched = () => { };
262
+ filterableColumns = computed(() => this.columns()
263
+ .filter((col) => TableValueResolver.getColumnFilterType(col, this.data()[0]) !== null)
264
+ .map((col) => {
265
+ const filterType = TableValueResolver.getColumnFilterType(col, this.data()[0]);
266
+ // Auto-generate select options from data if not provided
267
+ if (filterType === 'select' && !col.filterConfig?.options?.length) {
268
+ const uniqueOptions = Array.from(this.data().reduce((options, row) => {
269
+ const value = TableValueResolver.getColumnFilterValue(row, col);
270
+ if (value === null || value === undefined || value === '') {
271
+ return options;
272
+ }
273
+ const optionKey = `${typeof value}:${String(value)}`;
274
+ if (!options.has(optionKey)) {
275
+ options.set(optionKey, {
276
+ label: String(value),
277
+ value,
278
+ });
279
+ }
280
+ return options;
281
+ }, new Map()))
282
+ .map(([, option]) => option)
283
+ .sort((a, b) => a.label.localeCompare(b.label));
284
+ return {
285
+ ...col,
286
+ filterConfig: {
287
+ ...col.filterConfig,
288
+ type: filterType,
289
+ options: uniqueOptions,
290
+ },
291
+ };
292
+ }
293
+ return {
294
+ ...col,
295
+ filterConfig: {
296
+ ...col.filterConfig,
297
+ type: filterType ?? col.filterConfig?.type ?? 'text',
298
+ },
299
+ };
300
+ }), ...(ngDevMode ? [{ debugName: "filterableColumns" }] : []));
301
+ activeFilterCount = computed(() => {
302
+ const filters = this.appliedFilters();
303
+ return Object.values(filters).filter((v) => this.hasValue(v)).length;
304
+ }, ...(ngDevMode ? [{ debugName: "activeFilterCount" }] : []));
305
+ getFilterType(col) {
306
+ return (TableValueResolver.getColumnFilterType(col, this.data()[0]) ?? 'text');
307
+ }
308
+ getFilterValue(key) {
309
+ const value = this.pendingFilters()[key];
310
+ return value?.value ?? value ?? null;
311
+ }
312
+ getDateRangeValue(key, part) {
313
+ const value = this.pendingFilters()[key];
314
+ if (!value || typeof value !== 'object')
315
+ return null;
316
+ return part === 'from' ? (value.from ?? null) : (value.to ?? null);
317
+ }
318
+ updateFilter(key, value) {
319
+ this.pendingFilters.update((filters) => ({
320
+ ...filters,
321
+ [key]: value,
322
+ }));
323
+ this.onTouched();
324
+ }
325
+ updateDateFilter(key, part, value) {
326
+ this.pendingFilters.update((filters) => {
327
+ const current = filters[key] ?? {};
328
+ return {
329
+ ...filters,
330
+ [key]: {
331
+ ...current,
332
+ [part]: value,
333
+ },
334
+ };
335
+ });
336
+ this.onTouched();
337
+ }
338
+ apply() {
339
+ const filters = { ...this.pendingFilters() };
340
+ this.appliedFilters.set(filters);
341
+ this.onChange(filters);
342
+ this.filterApplied.emit(filters);
343
+ }
344
+ reset() {
345
+ this.pendingFilters.set({});
346
+ this.appliedFilters.set({});
347
+ this.onChange({});
348
+ this.filterReset.emit();
349
+ }
350
+ hasValue(value) {
351
+ if (value === null || value === undefined || value === '')
352
+ return false;
353
+ if (typeof value === 'object') {
354
+ return value.from != null || value.to != null || value.value != null;
355
+ }
356
+ return true;
357
+ }
358
+ // ControlValueAccessor
359
+ writeValue(value) {
360
+ const filters = value ?? {};
361
+ this.pendingFilters.set(filters);
362
+ this.appliedFilters.set(filters);
363
+ }
364
+ registerOnChange(fn) {
365
+ this.onChange = fn;
366
+ }
367
+ registerOnTouched(fn) {
368
+ this.onTouched = fn;
369
+ }
370
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: TableFilter, deps: [], target: i0.ɵɵFactoryTarget.Component });
371
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.3", type: TableFilter, isStandalone: true, selector: "mt-table-filter", inputs: { columns: { classPropertyName: "columns", publicName: "columns", isSignal: true, isRequired: true, transformFunction: null }, data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { filterApplied: "filterApplied", filterReset: "filterReset" }, providers: [
372
+ {
373
+ provide: NG_VALUE_ACCESSOR,
374
+ useExisting: forwardRef(() => TableFilter),
375
+ multi: true,
376
+ },
377
+ ], ngImport: i0, template: "<mt-button\r\n (click)=\"popover.toggle($event)\"\r\n [label]=\"'components.table.filter' | transloco\"\r\n [badge]=\"activeFilterCount()\"\r\n severity=\"primary\"\r\n icon=\"general.filter-funnel-01\"\r\n/>\r\n\r\n<p-popover #popover [style]=\"{ width: '320px' }\" appendTo=\"body\">\r\n <div class=\"flex flex-col max-h-[50vh]\">\r\n <h4\r\n class=\"text-lg py-2 font-semibold border-b border-surface-200 dark:border-surface-700 shrink-0\"\r\n >\r\n {{ \"components.table.filterOptions\" | transloco }}\r\n </h4>\r\n\r\n <div\r\n class=\"space-y-3 overflow-y-auto flex-1 py-3\"\r\n (keydown.enter)=\"apply(); popover.hide()\"\r\n >\r\n @for (col of filterableColumns(); track col.key) {\r\n <div class=\"space-y-1\">\r\n <label\r\n class=\"block text-sm font-medium text-gray-700 dark:text-gray-300\"\r\n >\r\n {{ col.filterConfig?.label || col.label }}\r\n </label>\r\n\r\n @switch (getFilterType(col)) {\r\n @case (\"text\") {\r\n <mt-text-field\r\n [ngModel]=\"getFilterValue(col.key)\"\r\n (ngModelChange)=\"updateFilter(col.key, $event)\"\r\n [placeholder]=\"\r\n ('components.table.select' | transloco) +\r\n ' ' +\r\n (col.filterConfig?.label || col.label)\r\n \"\r\n />\r\n }\r\n @case (\"select\") {\r\n <mt-select-field\r\n [ngModel]=\"getFilterValue(col.key)\"\r\n (ngModelChange)=\"updateFilter(col.key, $event)\"\r\n [options]=\"col.filterConfig?.options ?? []\"\r\n [placeholder]=\"\r\n ('components.table.select' | transloco) +\r\n ' ' +\r\n (col.filterConfig?.label || col.label)\r\n \"\r\n [hasPlaceholderPrefix]=\"false\"\r\n showClear\r\n />\r\n }\r\n @case (\"date\") {\r\n <div class=\"space-y-3\">\r\n <div class=\"space-y-1\">\r\n <label\r\n class=\"block text-sm font-medium text-gray-700 dark:text-gray-300\"\r\n >\r\n {{ \"components.table.from\" | transloco }}\r\n </label>\r\n <mt-date-field\r\n [ngModel]=\"getDateRangeValue(col.key, 'from')\"\r\n (ngModelChange)=\"updateDateFilter(col.key, 'from', $event)\"\r\n [placeholder]=\"'components.table.from' | transloco\"\r\n />\r\n </div>\r\n <div class=\"space-y-1\">\r\n <label\r\n class=\"block text-sm font-medium text-gray-700 dark:text-gray-300\"\r\n >\r\n {{ \"components.table.to\" | transloco }}\r\n </label>\r\n <mt-date-field\r\n [ngModel]=\"getDateRangeValue(col.key, 'to')\"\r\n (ngModelChange)=\"updateDateFilter(col.key, 'to', $event)\"\r\n [placeholder]=\"'components.table.to' | transloco\"\r\n />\r\n </div>\r\n </div>\r\n }\r\n @case (\"boolean\") {\r\n <mt-select-field\r\n [ngModel]=\"getFilterValue(col.key)\"\r\n (ngModelChange)=\"updateFilter(col.key, $event)\"\r\n [options]=\"booleanOptions\"\r\n [placeholder]=\"'components.table.select' | transloco\"\r\n [hasPlaceholderPrefix]=\"false\"\r\n showClear\r\n />\r\n }\r\n @case (\"user\") {\r\n <mt-user-search-field\r\n [ngModel]=\"getFilterValue(col.key)\"\r\n (ngModelChange)=\"updateFilter(col.key, $event)\"\r\n [placeholder]=\"col.filterConfig?.label || col.label\"\r\n [apiUrl]=\"col.filterConfig?.apiUrl ?? ''\"\r\n [context]=\"col.filterConfig?.context\"\r\n />\r\n }\r\n }\r\n </div>\r\n }\r\n </div>\r\n\r\n <div\r\n class=\"flex justify-end gap-2 pt-4 border-t border-surface-200 dark:border-surface-700 shrink-0\"\r\n >\r\n <mt-button\r\n variant=\"outlined\"\r\n (click)=\"reset(); popover.hide()\"\r\n [label]=\"'components.table.reset' | transloco\"\r\n />\r\n <mt-button\r\n (click)=\"apply(); popover.hide()\"\r\n [label]=\"'components.table.apply' | transloco\"\r\n />\r\n </div>\r\n </div>\r\n</p-popover>\r\n", dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: TextField, selector: "mt-text-field", inputs: ["field", "hint", "label", "placeholder", "class", "type", "readonly", "pInputs", "required", "icon", "iconPosition"] }, { kind: "component", type: SelectField, selector: "mt-select-field", inputs: ["field", "label", "placeholder", "hasPlaceholderPrefix", "class", "readonly", "pInputs", "options", "optionValue", "optionLabel", "filter", "filterBy", "dataKey", "showClear", "clearAfterSelect", "required", "group", "size", "optionGroupLabel", "optionGroupChildren", "loading", "optionIcon", "optionIconColor", "optionIconShape", "optionAvatarShape", "optionGroupIcon", "optionGroupIconColor", "optionGroupIconShape", "optionGroupAvatarShape"], outputs: ["onChange"] }, { kind: "component", type: DateField, selector: "mt-date-field", inputs: ["field", "label", "placeholder", "class", "readonly", "showIcon", "showClear", "showTime", "pInputs", "required"] }, { kind: "component", type: UserSearchField, selector: "mt-user-search-field", inputs: ["hint", "label", "placeholder", "class", "readonly", "required", "apiUrl", "dataKey", "paramName", "context", "size"] }, { kind: "component", type: Button, selector: "mt-button", inputs: ["icon", "label", "tooltip", "class", "type", "styleClass", "severity", "badge", "variant", "badgeSeverity", "size", "iconPos", "autofocus", "fluid", "raised", "rounded", "text", "plain", "outlined", "link", "disabled", "loading", "pInputs"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "ngmodule", type: PopoverModule }, { kind: "component", type: i2.Popover, selector: "p-popover", inputs: ["ariaLabel", "ariaLabelledBy", "dismissable", "style", "styleClass", "appendTo", "autoZIndex", "ariaCloseLabel", "baseZIndex", "focusOnShow", "showTransitionOptions", "hideTransitionOptions", "motionOptions"], outputs: ["onShow", "onHide"] }, { kind: "ngmodule", type: TranslocoModule }, { kind: "pipe", type: i3.TranslocoPipe, name: "transloco" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
378
+ }
379
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: TableFilter, decorators: [{
380
+ type: Component,
381
+ args: [{ selector: 'mt-table-filter', standalone: true, imports: [
382
+ FormsModule,
383
+ TextField,
384
+ SelectField,
385
+ DateField,
386
+ UserSearchField,
387
+ Button,
388
+ PopoverModule,
389
+ TranslocoModule,
390
+ ], changeDetection: ChangeDetectionStrategy.OnPush, providers: [
391
+ {
392
+ provide: NG_VALUE_ACCESSOR,
393
+ useExisting: forwardRef(() => TableFilter),
394
+ multi: true,
395
+ },
396
+ ], template: "<mt-button\r\n (click)=\"popover.toggle($event)\"\r\n [label]=\"'components.table.filter' | transloco\"\r\n [badge]=\"activeFilterCount()\"\r\n severity=\"primary\"\r\n icon=\"general.filter-funnel-01\"\r\n/>\r\n\r\n<p-popover #popover [style]=\"{ width: '320px' }\" appendTo=\"body\">\r\n <div class=\"flex flex-col max-h-[50vh]\">\r\n <h4\r\n class=\"text-lg py-2 font-semibold border-b border-surface-200 dark:border-surface-700 shrink-0\"\r\n >\r\n {{ \"components.table.filterOptions\" | transloco }}\r\n </h4>\r\n\r\n <div\r\n class=\"space-y-3 overflow-y-auto flex-1 py-3\"\r\n (keydown.enter)=\"apply(); popover.hide()\"\r\n >\r\n @for (col of filterableColumns(); track col.key) {\r\n <div class=\"space-y-1\">\r\n <label\r\n class=\"block text-sm font-medium text-gray-700 dark:text-gray-300\"\r\n >\r\n {{ col.filterConfig?.label || col.label }}\r\n </label>\r\n\r\n @switch (getFilterType(col)) {\r\n @case (\"text\") {\r\n <mt-text-field\r\n [ngModel]=\"getFilterValue(col.key)\"\r\n (ngModelChange)=\"updateFilter(col.key, $event)\"\r\n [placeholder]=\"\r\n ('components.table.select' | transloco) +\r\n ' ' +\r\n (col.filterConfig?.label || col.label)\r\n \"\r\n />\r\n }\r\n @case (\"select\") {\r\n <mt-select-field\r\n [ngModel]=\"getFilterValue(col.key)\"\r\n (ngModelChange)=\"updateFilter(col.key, $event)\"\r\n [options]=\"col.filterConfig?.options ?? []\"\r\n [placeholder]=\"\r\n ('components.table.select' | transloco) +\r\n ' ' +\r\n (col.filterConfig?.label || col.label)\r\n \"\r\n [hasPlaceholderPrefix]=\"false\"\r\n showClear\r\n />\r\n }\r\n @case (\"date\") {\r\n <div class=\"space-y-3\">\r\n <div class=\"space-y-1\">\r\n <label\r\n class=\"block text-sm font-medium text-gray-700 dark:text-gray-300\"\r\n >\r\n {{ \"components.table.from\" | transloco }}\r\n </label>\r\n <mt-date-field\r\n [ngModel]=\"getDateRangeValue(col.key, 'from')\"\r\n (ngModelChange)=\"updateDateFilter(col.key, 'from', $event)\"\r\n [placeholder]=\"'components.table.from' | transloco\"\r\n />\r\n </div>\r\n <div class=\"space-y-1\">\r\n <label\r\n class=\"block text-sm font-medium text-gray-700 dark:text-gray-300\"\r\n >\r\n {{ \"components.table.to\" | transloco }}\r\n </label>\r\n <mt-date-field\r\n [ngModel]=\"getDateRangeValue(col.key, 'to')\"\r\n (ngModelChange)=\"updateDateFilter(col.key, 'to', $event)\"\r\n [placeholder]=\"'components.table.to' | transloco\"\r\n />\r\n </div>\r\n </div>\r\n }\r\n @case (\"boolean\") {\r\n <mt-select-field\r\n [ngModel]=\"getFilterValue(col.key)\"\r\n (ngModelChange)=\"updateFilter(col.key, $event)\"\r\n [options]=\"booleanOptions\"\r\n [placeholder]=\"'components.table.select' | transloco\"\r\n [hasPlaceholderPrefix]=\"false\"\r\n showClear\r\n />\r\n }\r\n @case (\"user\") {\r\n <mt-user-search-field\r\n [ngModel]=\"getFilterValue(col.key)\"\r\n (ngModelChange)=\"updateFilter(col.key, $event)\"\r\n [placeholder]=\"col.filterConfig?.label || col.label\"\r\n [apiUrl]=\"col.filterConfig?.apiUrl ?? ''\"\r\n [context]=\"col.filterConfig?.context\"\r\n />\r\n }\r\n }\r\n </div>\r\n }\r\n </div>\r\n\r\n <div\r\n class=\"flex justify-end gap-2 pt-4 border-t border-surface-200 dark:border-surface-700 shrink-0\"\r\n >\r\n <mt-button\r\n variant=\"outlined\"\r\n (click)=\"reset(); popover.hide()\"\r\n [label]=\"'components.table.reset' | transloco\"\r\n />\r\n <mt-button\r\n (click)=\"apply(); popover.hide()\"\r\n [label]=\"'components.table.apply' | transloco\"\r\n />\r\n </div>\r\n </div>\r\n</p-popover>\r\n" }]
397
+ }], propDecorators: { columns: [{ type: i0.Input, args: [{ isSignal: true, alias: "columns", required: true }] }], data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: false }] }], filterApplied: [{ type: i0.Output, args: ["filterApplied"] }], filterReset: [{ type: i0.Output, args: ["filterReset"] }] } });
398
+
399
+ class Table {
400
+ selectionChange = output();
401
+ cellChange = output();
402
+ lazyLoad = output();
403
+ columnReorder = output();
404
+ rowReorder = output();
405
+ rowClick = output();
406
+ filters = model({}, ...(ngDevMode ? [{ debugName: "filters" }] : []));
407
+ data = input.required(...(ngDevMode ? [{ debugName: "data" }] : []));
408
+ columns = input.required(...(ngDevMode ? [{ debugName: "columns" }] : []));
409
+ rowActions = input([], ...(ngDevMode ? [{ debugName: "rowActions" }] : []));
410
+ size = input(undefined, ...(ngDevMode ? [{ debugName: "size" }] : []));
411
+ showGridlines = input(false, { ...(ngDevMode ? { debugName: "showGridlines" } : {}), transform: booleanAttribute });
412
+ stripedRows = input(false, { ...(ngDevMode ? { debugName: "stripedRows" } : {}), transform: booleanAttribute });
413
+ selectableRows = input(false, { ...(ngDevMode ? { debugName: "selectableRows" } : {}), transform: booleanAttribute });
414
+ clickableRows = input(false, { ...(ngDevMode ? { debugName: "clickableRows" } : {}), transform: booleanAttribute });
415
+ generalSearch = input(false, { ...(ngDevMode ? { debugName: "generalSearch" } : {}), transform: booleanAttribute });
416
+ lazyLocalSearch = input(false, { ...(ngDevMode ? { debugName: "lazyLocalSearch" } : {}), transform: booleanAttribute });
417
+ showFilters = input(false, { ...(ngDevMode ? { debugName: "showFilters" } : {}), transform: booleanAttribute });
418
+ loading = input(false, { ...(ngDevMode ? { debugName: "loading" } : {}), transform: booleanAttribute });
419
+ updating = input(false, { ...(ngDevMode ? { debugName: "updating" } : {}), transform: booleanAttribute });
420
+ lazy = input(false, { ...(ngDevMode ? { debugName: "lazy" } : {}), transform: booleanAttribute });
421
+ lazyLocalSort = input(false, { ...(ngDevMode ? { debugName: "lazyLocalSort" } : {}), transform: booleanAttribute });
422
+ lazyTotalRecords = input(...(ngDevMode ? [undefined, { debugName: "lazyTotalRecords" }] : []));
423
+ reorderableColumns = input(false, { ...(ngDevMode ? { debugName: "reorderableColumns" } : {}), transform: booleanAttribute });
424
+ reorderableRows = input(false, { ...(ngDevMode ? { debugName: "reorderableRows" } : {}), transform: booleanAttribute });
425
+ dataKey = input(...(ngDevMode ? [undefined, { debugName: "dataKey" }] : []));
426
+ exportable = input(false, { ...(ngDevMode ? { debugName: "exportable" } : {}), transform: booleanAttribute });
427
+ exportFilename = input('download', ...(ngDevMode ? [{ debugName: "exportFilename" }] : []));
428
+ actionShape = input('flat', ...(ngDevMode ? [{ debugName: "actionShape" }] : []));
429
+ // Tabs inputs and outputs
430
+ tabs = input(...(ngDevMode ? [undefined, { debugName: "tabs" }] : []));
431
+ tabsOptionLabel = input(...(ngDevMode ? [undefined, { debugName: "tabsOptionLabel" }] : []));
432
+ tabsOptionValue = input(...(ngDevMode ? [undefined, { debugName: "tabsOptionValue" }] : []));
433
+ activeTab = model(...(ngDevMode ? [undefined, { debugName: "activeTab" }] : []));
434
+ onTabChange = output();
435
+ // Table actions inputs and outputs
436
+ actions = input([], ...(ngDevMode ? [{ debugName: "actions" }] : []));
437
+ // Content TemplateRefs
438
+ captionStartContent = contentChild('captionStart', ...(ngDevMode ? [{ debugName: "captionStartContent" }] : []));
439
+ captionEndContent = contentChild('captionEnd', ...(ngDevMode ? [{ debugName: "captionEndContent" }] : []));
440
+ emptyContent = contentChild('empty', ...(ngDevMode ? [{ debugName: "emptyContent" }] : []));
441
+ // Table reference for export
442
+ tableRef = viewChild('dt', ...(ngDevMode ? [{ debugName: "tableRef" }] : []));
443
+ paginatorPosition = input('end', ...(ngDevMode ? [{ debugName: "paginatorPosition" }] : []));
444
+ pageSize = model(10, ...(ngDevMode ? [{ debugName: "pageSize" }] : []));
445
+ currentPage = model(0, ...(ngDevMode ? [{ debugName: "currentPage" }] : []));
446
+ first = model(0, ...(ngDevMode ? [{ debugName: "first" }] : []));
447
+ filterTerm = model('', ...(ngDevMode ? [{ debugName: "filterTerm" }] : []));
448
+ sortField = signal(null, ...(ngDevMode ? [{ debugName: "sortField" }] : []));
449
+ sortDirection = signal(null, ...(ngDevMode ? [{ debugName: "sortDirection" }] : []));
450
+ confirmationService = inject(ConfirmationService);
451
+ selectedRows = signal(new Set(), ...(ngDevMode ? [{ debugName: "selectedRows" }] : []));
452
+ // Map columns for PrimeNG export (key -> field)
453
+ exportColumns = computed(() => this.columns()
454
+ .filter((col) => col.type !== 'custom')
455
+ .map((col) => ({ ...col, field: col.key, header: col.label })), ...(ngDevMode ? [{ debugName: "exportColumns" }] : []));
456
+ activeFilterCount = computed(() => {
457
+ const filters = this.filters();
458
+ return Object.values(filters).filter((value) => value !== null && value !== undefined && value !== '').length;
459
+ }, ...(ngDevMode ? [{ debugName: "activeFilterCount" }] : []));
460
+ filteredData = computed(() => {
461
+ const data = this.data();
462
+ const applyLocalSearch = !this.lazy() || this.lazyLocalSearch();
463
+ const applyLocalSort = !this.lazy() || this.lazyLocalSort();
464
+ const searchTerm = applyLocalSearch ? this.filterTerm().toLowerCase() : '';
465
+ const filters = this.filters();
466
+ const filterKeys = this.lazy() ? [] : Object.keys(filters);
467
+ let result = data;
468
+ // Apply search term
469
+ if (searchTerm !== '') {
470
+ result = result.filter((item) => Object.values(item).some((value) => typeof value === 'string' &&
471
+ value.toLowerCase().includes(searchTerm)));
472
+ }
473
+ // Apply column filters
474
+ if (filterKeys.length > 0) {
475
+ result = result.filter((item) => filterKeys.every((key) => this.matchesFilter(item, key, filters[key])));
476
+ }
477
+ return applyLocalSort ? this.sortData(result) : result;
478
+ }, ...(ngDevMode ? [{ debugName: "filteredData" }] : []));
479
+ displayData = computed(() => {
480
+ if (this.loading()) {
481
+ return Array.from({ length: this.pageSize() }, () => ({}));
482
+ }
483
+ return this.filteredData();
484
+ }, ...(ngDevMode ? [{ debugName: "displayData" }] : []));
485
+ totalRecords = computed(() => {
486
+ if (this.lazy() && this.lazyTotalRecords() !== undefined) {
487
+ return this.lazyTotalRecords();
488
+ }
489
+ return this.filteredData().length;
490
+ }, ...(ngDevMode ? [{ debugName: "totalRecords" }] : []));
491
+ // TODO: remove after updating the toggle and checkbox logic
492
+ paginatedData = computed(() => {
493
+ const data = this.filteredData();
494
+ const first = this.first();
495
+ const pageSize = this.pageSize();
496
+ if (this.lazy()) {
497
+ return data;
498
+ }
499
+ return data.slice(first, first + pageSize);
500
+ }, ...(ngDevMode ? [{ debugName: "paginatedData" }] : []));
501
+ allSelectedOnPage = computed(() => {
502
+ const pageData = this.paginatedData();
503
+ if (pageData.length === 0)
504
+ return false;
505
+ return pageData.every((row) => this.selectedRows().has(row));
506
+ }, ...(ngDevMode ? [{ debugName: "allSelectedOnPage" }] : []));
507
+ onFilterApplied(filters) {
508
+ this.filters.set(filters);
509
+ this.first.set(0);
510
+ this.currentPage.set(0);
511
+ if (this.lazy()) {
512
+ this.emitLazyLoad({});
513
+ }
514
+ }
515
+ onFilterReset() {
516
+ this.filters.set({});
517
+ this.first.set(0);
518
+ this.currentPage.set(0);
519
+ if (this.lazy()) {
520
+ this.emitLazyLoad({});
521
+ }
522
+ }
523
+ matchesFilter(item, key, filterValue) {
524
+ if (filterValue === null ||
525
+ filterValue === undefined ||
526
+ filterValue === '') {
527
+ return true;
528
+ }
529
+ const column = this.columns().find((col) => col.key === key);
530
+ const itemValue = this.getProperty(item, key);
531
+ const normalizedFilterValue = column
532
+ ? TableValueResolver.getColumnFilterValue(item, column)
533
+ : TableValueResolver.resolveDisplayValue(itemValue);
534
+ const filterType = column
535
+ ? TableValueResolver.getColumnFilterType(column, item)
536
+ : null;
537
+ // Date range filter
538
+ if (typeof filterValue === 'object') {
539
+ if (filterValue.from || filterValue.to) {
540
+ const itemDateValue = filterType === 'date'
541
+ ? typeof normalizedFilterValue === 'number'
542
+ ? normalizedFilterValue
543
+ : null
544
+ : itemValue instanceof Date
545
+ ? itemValue.getTime()
546
+ : new Date(String(itemValue)).getTime();
547
+ if (itemDateValue === null ||
548
+ itemDateValue === undefined ||
549
+ Number.isNaN(itemDateValue)) {
550
+ return true;
551
+ }
552
+ if (filterValue.from &&
553
+ itemDateValue < new Date(filterValue.from).getTime()) {
554
+ return false;
555
+ }
556
+ if (filterValue.to &&
557
+ itemDateValue > new Date(filterValue.to).getTime()) {
558
+ return false;
559
+ }
560
+ return true;
561
+ }
562
+ else if (filterValue?.userName) {
563
+ const normalizedItemUser = itemValue;
564
+ if (!normalizedItemUser)
565
+ return false;
566
+ return (normalizedItemUser.id === filterValue?.id ||
567
+ normalizedItemUser.userName === filterValue?.userName ||
568
+ normalizedItemUser.displayName === filterValue?.displayName);
569
+ }
570
+ }
571
+ // Boolean filter
572
+ if (typeof filterValue === 'boolean') {
573
+ return normalizedFilterValue === filterValue;
574
+ }
575
+ // Text filter
576
+ if (typeof normalizedFilterValue === 'string' ||
577
+ typeof normalizedFilterValue === 'number') {
578
+ return String(normalizedFilterValue)
579
+ .toLowerCase()
580
+ .includes(String(filterValue).toLowerCase());
581
+ }
582
+ return normalizedFilterValue === filterValue;
583
+ }
584
+ toggleRow(row) {
585
+ const newSet = new Set(this.selectedRows());
586
+ if (newSet.has(row))
587
+ newSet.delete(row);
588
+ else
589
+ newSet.add(row);
590
+ this.selectedRows.set(newSet);
591
+ this.selectionChange.emit(Array.from(this.selectedRows()));
592
+ }
593
+ toggleAllRowsOnPage() {
594
+ const currentSelection = new Set(this.selectedRows());
595
+ const pageData = this.paginatedData();
596
+ const allSelected = this.allSelectedOnPage();
597
+ if (allSelected) {
598
+ pageData.forEach((row) => currentSelection.delete(row));
599
+ }
600
+ else {
601
+ pageData.forEach((row) => currentSelection.add(row));
602
+ }
603
+ this.selectedRows.set(currentSelection);
604
+ this.selectionChange.emit(Array.from(this.selectedRows()));
605
+ }
606
+ getProperty(obj, key) {
607
+ return TableValueResolver.getProperty(obj, key);
608
+ }
609
+ getEntityPreviewData(row, col) {
610
+ const cellValue = this.getProperty(row, col.key);
611
+ if (col.type === 'user') {
612
+ return this.buildUserEntityData(cellValue, col.label);
613
+ }
614
+ if (col.type === 'status') {
615
+ return this.buildStatusEntityData(cellValue, col);
616
+ }
617
+ return null;
618
+ }
619
+ tabChanged(tab) {
620
+ this.filterTerm.set('');
621
+ this.first.set(0);
622
+ this.currentPage.set(0);
623
+ this.onTabChange.emit(tab);
624
+ }
625
+ onTablePage(event) {
626
+ if (this.lazy()) {
627
+ this.handleLazyLoad(event);
628
+ return;
629
+ }
630
+ this.updatePagingFromEvent(event);
631
+ }
632
+ handleLazyLoad(event) {
633
+ this.updatePagingFromEvent(event);
634
+ this.emitLazyLoad(event);
635
+ }
636
+ onPaginatorPage(event) {
637
+ if (this.lazy()) {
638
+ this.handleLazyLoad(event);
639
+ return;
640
+ }
641
+ this.updatePagingFromEvent(event);
642
+ }
643
+ onSearchChange(searchTerm) {
644
+ this.filterTerm.set(searchTerm);
645
+ this.first.set(0);
646
+ this.currentPage.set(0);
647
+ if (this.lazy() && !this.lazyLocalSearch()) {
648
+ this.filters.set({ ...this.filters(), generalSearch: searchTerm });
649
+ this.emitLazyLoad({});
650
+ }
651
+ }
652
+ toggleSort(column) {
653
+ if (!this.isColumnSortable(column)) {
654
+ return;
655
+ }
656
+ if (this.sortField() !== column.key) {
657
+ this.sortField.set(column.key);
658
+ this.sortDirection.set('asc');
659
+ }
660
+ else {
661
+ this.sortDirection.set(this.sortDirection() === 'asc' ? 'desc' : 'asc');
662
+ }
663
+ }
664
+ isColumnSortable(column) {
665
+ return column.sortable === true && (!this.lazy() || this.lazyLocalSort());
666
+ }
667
+ getSortIcon(column) {
668
+ if (this.sortField() !== column.key || !this.sortDirection()) {
669
+ return 'arrow.chevron-selector-vertical';
670
+ }
671
+ return this.sortDirection() === 'asc'
672
+ ? 'arrow.arrow-up'
673
+ : 'arrow.arrow-down';
674
+ }
675
+ onCellChange(row, columnKey, newValue, type) {
676
+ this.setProperty(row, columnKey, newValue);
677
+ this.cellChange.emit({
678
+ row,
679
+ column: columnKey,
680
+ value: newValue,
681
+ type: type,
682
+ });
683
+ }
684
+ resolveActionLoading(action, row) {
685
+ if (typeof action.loading === 'function') {
686
+ return action.loading(row);
687
+ }
688
+ return action.loading;
689
+ }
690
+ getVisibleRowActions(row) {
691
+ return this.rowActions().filter((action) => !action.hidden?.(row));
692
+ }
693
+ onColumnReorder(event) {
694
+ this.columnReorder.emit(event);
695
+ }
696
+ onRowReorder(event) {
697
+ this.rowReorder.emit({
698
+ ...event,
699
+ value: event.value ?? this.data(),
700
+ });
701
+ }
702
+ onRowClick(event, row) {
703
+ if (!this.clickableRows() || this.loading()) {
704
+ return;
705
+ }
706
+ const target = event.target;
707
+ if (target?.closest('button, a, input, textarea, select, label, [role="button"], [data-row-click-ignore="true"]')) {
708
+ return;
709
+ }
710
+ this.rowClick.emit(row);
711
+ }
712
+ updatePagingFromEvent(event) {
713
+ const first = event?.first ?? this.first();
714
+ const rows = event?.rows ?? this.pageSize();
715
+ this.first.set(first);
716
+ this.pageSize.set(rows);
717
+ const page = typeof event?.page === 'number'
718
+ ? event.page
719
+ : Math.floor((first ?? 0) / (rows || 1));
720
+ this.currentPage.set(page);
721
+ }
722
+ emitLazyLoad(event) {
723
+ this.lazyLoad.emit({
724
+ ...event,
725
+ pageSize: this.pageSize(),
726
+ currentPage: this.currentPage() + 1,
727
+ first: this.first(),
728
+ filters: this.filters(),
729
+ });
730
+ }
731
+ exportCSV() {
732
+ const table = this.tableRef();
733
+ if (table && !this.loading()) {
734
+ const exportColumns = this.exportColumns();
735
+ const sourceColumns = this.columns().filter((column) => column.type !== 'custom');
736
+ const originalColumns = table.columns;
737
+ const originalValue = table.value;
738
+ try {
739
+ table.columns = exportColumns;
740
+ table.value = this.buildExportRows(this.displayData(), sourceColumns);
741
+ table.exportCSV();
742
+ }
743
+ finally {
744
+ table.columns = originalColumns;
745
+ table.value = originalValue;
746
+ }
747
+ }
748
+ }
749
+ rowAction(event, action, row) {
750
+ if (!action.confirmation) {
751
+ action.action(row);
752
+ }
753
+ else if (action.confirmation?.confirmationType === 'delete') {
754
+ this.confirmationService.confirmDelete({
755
+ event: event,
756
+ ...action.confirmation,
757
+ accept: () => {
758
+ action.action(row);
759
+ },
760
+ reject: () => { },
761
+ });
762
+ }
763
+ else {
764
+ this.confirmationService.confirm({
765
+ event: event,
766
+ ...action.confirmation,
767
+ accept: () => {
768
+ action.action(row);
769
+ },
770
+ reject: () => { },
771
+ });
772
+ }
773
+ }
774
+ buildUserEntityData(value, columnLabel) {
775
+ const userValue = value;
776
+ if (!userValue)
777
+ return null;
778
+ return {
779
+ name: columnLabel,
780
+ viewType: 'User',
781
+ value: userValue,
782
+ configuration: {
783
+ showDisplayName: true,
784
+ showPhoneNumber: false,
785
+ showEmail: false,
786
+ },
787
+ };
788
+ }
789
+ buildStatusEntityData(value, column) {
790
+ const statusValue = this.resolveStatusValue(value, column);
791
+ return {
792
+ name: column.label,
793
+ viewType: 'Status',
794
+ value: statusValue ?? '',
795
+ configuration: {
796
+ hideName: true,
797
+ },
798
+ };
799
+ }
800
+ resolveStatusValue(value, column) {
801
+ const unwrappedValue = this.unwrapStatusValue(value, column);
802
+ if (unwrappedValue === null ||
803
+ unwrappedValue === undefined ||
804
+ unwrappedValue === '') {
805
+ return null;
806
+ }
807
+ if (typeof unwrappedValue === 'object') {
808
+ const objectValue = unwrappedValue;
809
+ const statusKey = this.readStringProperty(objectValue, 'key') ??
810
+ this.readStringProperty(objectValue, 'code') ??
811
+ this.readStringProperty(objectValue, 'value') ??
812
+ this.readStringProperty(objectValue, 'id') ??
813
+ this.readStringProperty(objectValue, 'display') ??
814
+ this.readStringProperty(objectValue, 'displayValue') ??
815
+ this.readStringProperty(objectValue, 'displayName') ??
816
+ this.readStringProperty(objectValue, 'label') ??
817
+ this.readStringProperty(objectValue, 'name');
818
+ const mappedStatus = this.resolveStatusMapValue(column, statusKey);
819
+ const display = this.readStringProperty(objectValue, 'display') ??
820
+ this.readStringProperty(objectValue, 'displayValue') ??
821
+ this.readStringProperty(objectValue, 'displayName') ??
822
+ this.readStringProperty(objectValue, 'label') ??
823
+ this.readStringProperty(objectValue, 'name') ??
824
+ mappedStatus?.display ??
825
+ statusKey;
826
+ if (!display) {
827
+ return null;
828
+ }
829
+ return {
830
+ key: statusKey ?? display,
831
+ display,
832
+ color: this.readStringProperty(objectValue, 'color') ??
833
+ mappedStatus?.color ??
834
+ this.resolveDefaultStatusColor(statusKey ?? display),
835
+ description: this.readStringProperty(objectValue, 'description') ??
836
+ mappedStatus?.description,
837
+ };
838
+ }
839
+ const normalizedValue = TableValueResolver.resolveDisplayValue(unwrappedValue);
840
+ if (normalizedValue === null || normalizedValue === undefined) {
841
+ return null;
842
+ }
843
+ const statusKey = String(normalizedValue);
844
+ const mappedStatus = this.resolveStatusMapValue(column, statusKey);
845
+ return {
846
+ key: statusKey,
847
+ display: mappedStatus?.display ?? statusKey,
848
+ color: mappedStatus?.color ?? this.resolveDefaultStatusColor(statusKey),
849
+ description: mappedStatus?.description,
850
+ };
851
+ }
852
+ unwrapStatusValue(value, column) {
853
+ if (!value || typeof value !== 'object') {
854
+ return value;
855
+ }
856
+ const entityValue = value;
857
+ if (!('value' in value)) {
858
+ return value;
859
+ }
860
+ if (entityValue.viewType === 'Status' ||
861
+ this.isEntityStatusCompatibilityColumn(column)) {
862
+ return entityValue.value;
863
+ }
864
+ return value;
865
+ }
866
+ isEntityStatusCompatibilityColumn(column) {
867
+ return column?.type === 'entity' && this.isStatusColumnKey(column.key);
868
+ }
869
+ isStatusColumnKey(key) {
870
+ return typeof key === 'string' && key.trim().toLowerCase() === 'status';
871
+ }
872
+ resolveStatusMapValue(column, key) {
873
+ if (!column?.statusMap || !key) {
874
+ return undefined;
875
+ }
876
+ const directMatch = column.statusMap[key];
877
+ if (directMatch) {
878
+ return directMatch;
879
+ }
880
+ const normalizedKey = this.normalizeStatusToken(key);
881
+ return Object.entries(column.statusMap).find(([entryKey]) => this.normalizeStatusToken(entryKey) === normalizedKey)?.[1];
882
+ }
883
+ resolveDefaultStatusColor(value) {
884
+ const normalizedValue = this.normalizeStatusToken(value);
885
+ if ([
886
+ 'active',
887
+ 'approved',
888
+ 'completed',
889
+ 'create',
890
+ 'created',
891
+ 'done',
892
+ 'enabled',
893
+ 'healthy',
894
+ 'low',
895
+ 'open',
896
+ 'published',
897
+ 'runtime',
898
+ 'success',
899
+ ].includes(normalizedValue)) {
900
+ return '#047857';
901
+ }
902
+ if ([
903
+ 'change',
904
+ 'current',
905
+ 'draft',
906
+ 'inprogress',
907
+ 'info',
908
+ 'medium',
909
+ 'process',
910
+ 'progress',
911
+ 'running',
912
+ 'update',
913
+ 'updated',
914
+ ].includes(normalizedValue)) {
915
+ return '#0369a1';
916
+ }
917
+ if ([
918
+ 'bulkupdate',
919
+ 'comment',
920
+ 'configure',
921
+ 'configured',
922
+ 'controlpanel',
923
+ 'discussion',
924
+ ].includes(normalizedValue)) {
925
+ return '#4338ca';
926
+ }
927
+ if ([
928
+ 'awaiting',
929
+ 'escalation',
930
+ 'high',
931
+ 'hold',
932
+ 'move',
933
+ 'moved',
934
+ 'pending',
935
+ 'phasegate',
936
+ 'queued',
937
+ 'warning',
938
+ ].includes(normalizedValue)) {
939
+ return '#b45309';
940
+ }
941
+ if ([
942
+ 'blocked',
943
+ 'cancelled',
944
+ 'canceled',
945
+ 'close',
946
+ 'closed',
947
+ 'critical',
948
+ 'delete',
949
+ 'deleted',
950
+ 'error',
951
+ 'failed',
952
+ 'governance',
953
+ 'inactive',
954
+ 'rejected',
955
+ ].includes(normalizedValue)) {
956
+ return '#be123c';
957
+ }
958
+ return '#475569';
959
+ }
960
+ normalizeStatusToken(value) {
961
+ return value
962
+ .trim()
963
+ .toLocaleLowerCase()
964
+ .replace(/[\s_-]+/g, '');
965
+ }
966
+ readStringProperty(value, key) {
967
+ const propertyValue = value[key];
968
+ return typeof propertyValue === 'string' && propertyValue.trim().length > 0
969
+ ? propertyValue.trim()
970
+ : null;
971
+ }
972
+ /**
973
+ * Gets the entity data for an 'entity' type column.
974
+ * The row data is expected to already be in EntityData format.
975
+ * Automatically hides entity name and configures User entities
976
+ * to show only avatar + displayName.
977
+ */
978
+ getEntityColumnData(row, col) {
979
+ const cellValue = this.getProperty(row, col.key);
980
+ if (!cellValue || typeof cellValue !== 'object')
981
+ return null;
982
+ const entityData = cellValue;
983
+ if (this.isEntityStatusCompatibilityColumn(col)) {
984
+ return this.buildStatusEntityData(cellValue, col);
985
+ }
986
+ // For User entities: show avatar + displayName only
987
+ if (entityData.viewType === 'User') {
988
+ return {
989
+ ...entityData,
990
+ configuration: {
991
+ ...entityData.configuration,
992
+ hideName: true,
993
+ showDisplayName: true,
994
+ showPhoneNumber: false,
995
+ showEmail: false,
996
+ },
997
+ };
998
+ }
999
+ // For all other entities: hide the name label
1000
+ return {
1001
+ ...entityData,
1002
+ configuration: {
1003
+ ...entityData.configuration,
1004
+ hideName: true,
1005
+ },
1006
+ };
1007
+ }
1008
+ getStatusEntityAccentColor(row) {
1009
+ const statusColumn = this.columns().find((column) => this.isStatusColumnKey(column.key));
1010
+ if (!statusColumn) {
1011
+ return null;
1012
+ }
1013
+ return this.resolveStatusEntityAccentColor(this.getProperty(row, statusColumn.key), statusColumn);
1014
+ }
1015
+ resolveStatusEntityAccentColor(value, column) {
1016
+ return this.resolveStatusValue(value, column)?.color ?? null;
1017
+ }
1018
+ getBooleanProperty(obj, key) {
1019
+ const value = this.getProperty(obj, key);
1020
+ if (typeof value === 'boolean') {
1021
+ return value;
1022
+ }
1023
+ return TableValueResolver.resolveBooleanValue(value) ?? false;
1024
+ }
1025
+ setProperty(obj, key, value) {
1026
+ const path = key.split('.');
1027
+ const lastKey = path.pop();
1028
+ if (!lastKey) {
1029
+ return;
1030
+ }
1031
+ const target = path.reduce((current, segment) => {
1032
+ if (!current?.[segment] || typeof current[segment] !== 'object') {
1033
+ current[segment] = {};
1034
+ }
1035
+ return current[segment];
1036
+ }, obj);
1037
+ if (target && typeof target === 'object') {
1038
+ target[lastKey] = value;
1039
+ }
1040
+ }
1041
+ sortData(data) {
1042
+ const field = this.sortField();
1043
+ const direction = this.sortDirection();
1044
+ if (!field || !direction) {
1045
+ return data;
1046
+ }
1047
+ const column = this.columns().find((item) => item.key === field);
1048
+ if (!column || !this.isColumnSortable(column)) {
1049
+ return data;
1050
+ }
1051
+ return [...data].sort((leftRow, rightRow) => {
1052
+ const leftValue = this.getSortValue(leftRow, column);
1053
+ const rightValue = this.getSortValue(rightRow, column);
1054
+ if (leftValue === rightValue)
1055
+ return 0;
1056
+ if (leftValue === null || leftValue === undefined || leftValue === '') {
1057
+ return 1;
1058
+ }
1059
+ if (rightValue === null ||
1060
+ rightValue === undefined ||
1061
+ rightValue === '') {
1062
+ return -1;
1063
+ }
1064
+ const comparison = leftValue < rightValue ? -1 : 1;
1065
+ return direction === 'asc' ? comparison : -comparison;
1066
+ });
1067
+ }
1068
+ getSortValue(row, column) {
1069
+ const cellValue = this.getProperty(row, column.key);
1070
+ const resolvedValue = this.getColumnResolvedValue(row, column);
1071
+ if (resolvedValue === null ||
1072
+ resolvedValue === undefined ||
1073
+ resolvedValue === '') {
1074
+ return null;
1075
+ }
1076
+ if (column.type === 'date') {
1077
+ const timestamp = new Date(String(cellValue)).getTime();
1078
+ return Number.isNaN(timestamp) ? null : timestamp;
1079
+ }
1080
+ if (typeof resolvedValue === 'number') {
1081
+ return resolvedValue;
1082
+ }
1083
+ if (typeof resolvedValue === 'boolean') {
1084
+ return resolvedValue ? 1 : 0;
1085
+ }
1086
+ if (cellValue instanceof Date) {
1087
+ return cellValue.getTime();
1088
+ }
1089
+ return TableValueResolver.normalizeTextSortValue(resolvedValue);
1090
+ }
1091
+ getColumnResolvedValue(row, column) {
1092
+ const cellValue = this.getProperty(row, column.key);
1093
+ if (cellValue === null || cellValue === undefined) {
1094
+ return null;
1095
+ }
1096
+ if (column.type === 'entity') {
1097
+ return TableValueResolver.getEntityValueByType(cellValue, 'sort');
1098
+ }
1099
+ if (column.type === 'boolean') {
1100
+ return this.getBooleanProperty(row, column.key);
1101
+ }
1102
+ if (typeof cellValue === 'number' || typeof cellValue === 'boolean') {
1103
+ return cellValue;
1104
+ }
1105
+ if (cellValue instanceof Date) {
1106
+ return cellValue.toISOString();
1107
+ }
1108
+ return TableValueResolver.resolveDisplayValue(cellValue);
1109
+ }
1110
+ buildExportRows(rows, columns) {
1111
+ return rows.map((row) => {
1112
+ const exportRow = {};
1113
+ columns.forEach((column) => {
1114
+ exportRow[column.key] =
1115
+ column.type === 'entity'
1116
+ ? TableValueResolver.getEntityValueByType(this.getProperty(row, column.key), 'export')
1117
+ : this.getColumnResolvedValue(row, column);
1118
+ });
1119
+ return exportRow;
1120
+ });
1121
+ }
1122
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: Table, deps: [], target: i0.ɵɵFactoryTarget.Component });
1123
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.3", type: Table, isStandalone: true, selector: "mt-table", inputs: { filters: { classPropertyName: "filters", publicName: "filters", isSignal: true, isRequired: false, transformFunction: null }, data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: true, transformFunction: null }, columns: { classPropertyName: "columns", publicName: "columns", isSignal: true, isRequired: true, transformFunction: null }, rowActions: { classPropertyName: "rowActions", publicName: "rowActions", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, showGridlines: { classPropertyName: "showGridlines", publicName: "showGridlines", isSignal: true, isRequired: false, transformFunction: null }, stripedRows: { classPropertyName: "stripedRows", publicName: "stripedRows", isSignal: true, isRequired: false, transformFunction: null }, selectableRows: { classPropertyName: "selectableRows", publicName: "selectableRows", isSignal: true, isRequired: false, transformFunction: null }, clickableRows: { classPropertyName: "clickableRows", publicName: "clickableRows", isSignal: true, isRequired: false, transformFunction: null }, generalSearch: { classPropertyName: "generalSearch", publicName: "generalSearch", isSignal: true, isRequired: false, transformFunction: null }, lazyLocalSearch: { classPropertyName: "lazyLocalSearch", publicName: "lazyLocalSearch", isSignal: true, isRequired: false, transformFunction: null }, showFilters: { classPropertyName: "showFilters", publicName: "showFilters", isSignal: true, isRequired: false, transformFunction: null }, loading: { classPropertyName: "loading", publicName: "loading", isSignal: true, isRequired: false, transformFunction: null }, updating: { classPropertyName: "updating", publicName: "updating", isSignal: true, isRequired: false, transformFunction: null }, lazy: { classPropertyName: "lazy", publicName: "lazy", isSignal: true, isRequired: false, transformFunction: null }, lazyLocalSort: { classPropertyName: "lazyLocalSort", publicName: "lazyLocalSort", isSignal: true, isRequired: false, transformFunction: null }, lazyTotalRecords: { classPropertyName: "lazyTotalRecords", publicName: "lazyTotalRecords", isSignal: true, isRequired: false, transformFunction: null }, reorderableColumns: { classPropertyName: "reorderableColumns", publicName: "reorderableColumns", isSignal: true, isRequired: false, transformFunction: null }, reorderableRows: { classPropertyName: "reorderableRows", publicName: "reorderableRows", isSignal: true, isRequired: false, transformFunction: null }, dataKey: { classPropertyName: "dataKey", publicName: "dataKey", isSignal: true, isRequired: false, transformFunction: null }, exportable: { classPropertyName: "exportable", publicName: "exportable", isSignal: true, isRequired: false, transformFunction: null }, exportFilename: { classPropertyName: "exportFilename", publicName: "exportFilename", isSignal: true, isRequired: false, transformFunction: null }, actionShape: { classPropertyName: "actionShape", publicName: "actionShape", isSignal: true, isRequired: false, transformFunction: null }, tabs: { classPropertyName: "tabs", publicName: "tabs", isSignal: true, isRequired: false, transformFunction: null }, tabsOptionLabel: { classPropertyName: "tabsOptionLabel", publicName: "tabsOptionLabel", isSignal: true, isRequired: false, transformFunction: null }, tabsOptionValue: { classPropertyName: "tabsOptionValue", publicName: "tabsOptionValue", isSignal: true, isRequired: false, transformFunction: null }, activeTab: { classPropertyName: "activeTab", publicName: "activeTab", isSignal: true, isRequired: false, transformFunction: null }, actions: { classPropertyName: "actions", publicName: "actions", isSignal: true, isRequired: false, transformFunction: null }, paginatorPosition: { classPropertyName: "paginatorPosition", publicName: "paginatorPosition", isSignal: true, isRequired: false, transformFunction: null }, pageSize: { classPropertyName: "pageSize", publicName: "pageSize", isSignal: true, isRequired: false, transformFunction: null }, currentPage: { classPropertyName: "currentPage", publicName: "currentPage", isSignal: true, isRequired: false, transformFunction: null }, first: { classPropertyName: "first", publicName: "first", isSignal: true, isRequired: false, transformFunction: null }, filterTerm: { classPropertyName: "filterTerm", publicName: "filterTerm", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { selectionChange: "selectionChange", cellChange: "cellChange", lazyLoad: "lazyLoad", columnReorder: "columnReorder", rowReorder: "rowReorder", rowClick: "rowClick", filters: "filtersChange", activeTab: "activeTabChange", onTabChange: "onTabChange", pageSize: "pageSizeChange", currentPage: "currentPageChange", first: "firstChange", filterTerm: "filterTermChange" }, queries: [{ propertyName: "captionStartContent", first: true, predicate: ["captionStart"], descendants: true, isSignal: true }, { propertyName: "captionEndContent", first: true, predicate: ["captionEnd"], descendants: true, isSignal: true }, { propertyName: "emptyContent", first: true, predicate: ["empty"], descendants: true, isSignal: true }], viewQueries: [{ propertyName: "tableRef", first: true, predicate: ["dt"], descendants: true, isSignal: true }], ngImport: i0, template: "<div class=\"space-y-4 rounded-2xl\">\r\n <div>\r\n @if (\r\n captionStartContent() ||\r\n captionEndContent() ||\r\n generalSearch() ||\r\n showFilters() ||\r\n tabs()?.length > 0 ||\r\n actions()?.length > 0\r\n ) {\r\n <div class=\"p-datatable-header rounded-t-2xl\">\r\n <div\r\n class=\"flex relative\"\r\n [class]=\"!generalSearch() ? 'justify-end' : 'justify-between'\"\r\n >\r\n <div class=\"flex items-center gap-2\">\r\n <ng-container\r\n *ngTemplateOutlet=\"captionStartContent()\"\r\n ></ng-container>\r\n @if (tabs()) {\r\n <mt-tabs\r\n [(active)]=\"activeTab\"\r\n [options]=\"tabs()\"\r\n [optionLabel]=\"tabsOptionLabel()\"\r\n [optionValue]=\"tabsOptionValue()\"\r\n (onChange)=\"tabChanged($event)\"\r\n size=\"large\"\r\n ></mt-tabs>\r\n }\r\n @if (generalSearch()) {\r\n <mt-text-field\r\n [(ngModel)]=\"filterTerm\"\r\n (ngModelChange)=\"onSearchChange($event)\"\r\n icon=\"general.search-lg\"\r\n [placeholder]=\"'components.table.search' | transloco\"\r\n ></mt-text-field>\r\n }\r\n </div>\r\n <div class=\"flex items-center gap-2\">\r\n @if (showFilters()) {\r\n <mt-table-filter\r\n [columns]=\"columns()\"\r\n [data]=\"data()\"\r\n [ngModel]=\"filters()\"\r\n (filterApplied)=\"onFilterApplied($event)\"\r\n (filterReset)=\"onFilterReset()\"\r\n />\r\n }\r\n @if (exportable()) {\r\n <mt-button\r\n icon=\"file.file-x-03\"\r\n [tooltip]=\"'components.table.export' | transloco\"\r\n (click)=\"exportCSV()\"\r\n />\r\n }\r\n @if (actions()?.length > 0) {\r\n <div class=\"flex items-center space-x-2\">\r\n @for (action of actions(); track action.label) {\r\n <mt-button\r\n [icon]=\"action.icon\"\r\n [severity]=\"action.color\"\r\n [variant]=\"action.variant\"\r\n [size]=\"action.size\"\r\n (click)=\"action.action(row)\"\r\n [label]=\"action.label\"\r\n [tooltip]=\"action.tooltip\"\r\n ></mt-button>\r\n }\r\n </div>\r\n }\r\n <ng-container\r\n *ngTemplateOutlet=\"captionEndContent()\"\r\n ></ng-container>\r\n </div>\r\n </div>\r\n </div>\r\n }\r\n @if (!loading() && emptyContent() && data().length === 0) {\r\n <div\r\n class=\"p-4 bg-content rounded-md text-center text-gray-600 dark:text-gray-300\"\r\n >\r\n <ng-container *ngTemplateOutlet=\"emptyContent()\"></ng-container>\r\n </div>\r\n } @else {\r\n <div class=\"overflow-x-auto bg-content\">\r\n <p-table\r\n #dt\r\n [value]=\"displayData()\"\r\n [columns]=\"columns()\"\r\n [size]=\"size()\"\r\n [showGridlines]=\"showGridlines()\"\r\n [stripedRows]=\"stripedRows()\"\r\n [lazy]=\"lazy()\"\r\n [totalRecords]=\"totalRecords()\"\r\n [reorderableColumns]=\"reorderableColumns()\"\r\n [reorderableRows]=\"reorderableRows()\"\r\n [dataKey]=\"dataKey()\"\r\n [first]=\"first()\"\r\n [rows]=\"pageSize()\"\r\n [exportFilename]=\"exportFilename()\"\r\n (onPage)=\"onTablePage($event)\"\r\n (onLazyLoad)=\"handleLazyLoad($event)\"\r\n (onColReorder)=\"onColumnReorder($event)\"\r\n (onRowReorder)=\"onRowReorder($event)\"\r\n paginator\r\n paginatorStyleClass=\"hidden!\"\r\n class=\"min-w-full text-sm align-middle table-fixed\"\r\n >\r\n <ng-template\r\n #header\r\n let-columns\r\n class=\"bg-surface-50 dark:bg-surface-950 border-b border-surface-300 dark:border-surface-500\"\r\n >\r\n <tr>\r\n @if (reorderableRows()) {\r\n <th class=\"w-10\"></th>\r\n }\r\n @if (selectableRows()) {\r\n <th class=\"w-12 text-start\">\r\n <mt-checkbox-field\r\n [ngModel]=\"allSelectedOnPage()\"\r\n (ngModelChange)=\"toggleAllRowsOnPage()\"\r\n ></mt-checkbox-field>\r\n </th>\r\n }\r\n\r\n @for (col of columns; track col.key || col.label || $index) {\r\n @if (reorderableColumns()) {\r\n <th\r\n pReorderableColumn\r\n class=\"text-start font-semibold text-gray-600 dark:text-gray-50 uppercase tracking-wider\"\r\n >\r\n <div class=\"flex items-center gap-2\">\r\n {{ col.label }}\r\n <!-- <mt-icon-->\r\n <!-- icon=\"general.menu-05\"-->\r\n <!-- class=\"text-xs text-gray-400\"-->\r\n <!-- ></mt-icon>-->\r\n <mt-button\r\n styleClass=\"cursor-move!\"\r\n severity=\"secondary\"\r\n variant=\"outlined\"\r\n size=\"small\"\r\n icon=\"general.menu-05\"\r\n ></mt-button>\r\n </div>\r\n </th>\r\n } @else {\r\n <th\r\n class=\"text-start font-semibold text-gray-600 dark:text-gray-50 uppercase tracking-wider\"\r\n [style.width]=\"col.width ?? null\"\r\n [style.minWidth]=\"col.width ?? null\"\r\n >\r\n @if (isColumnSortable(col)) {\r\n <button\r\n type=\"button\"\r\n class=\"inline-flex items-center gap-2 cursor-pointer\"\r\n (click)=\"toggleSort(col)\"\r\n >\r\n <span>{{ col.label }}</span>\r\n <mt-icon\r\n [icon]=\"getSortIcon(col)\"\r\n class=\"text-xs text-gray-400\"\r\n />\r\n </button>\r\n } @else {\r\n {{ col.label }}\r\n }\r\n </th>\r\n }\r\n }\r\n\r\n @if (rowActions().length > 0) {\r\n <th\r\n class=\"text-end! font-semibold text-gray-600 dark:text-gray-50 uppercase tracking-wider\"\r\n >\r\n {{ \"components.table.actions\" | transloco }}\r\n </th>\r\n }\r\n </tr>\r\n @if (updating()) {\r\n <tr>\r\n <th\r\n [attr.colspan]=\"\r\n columns.length +\r\n (reorderableRows() ? 1 : 0) +\r\n (selectableRows() ? 1 : 0) +\r\n (rowActions().length > 0 ? 1 : 0)\r\n \"\r\n class=\"!p-0\"\r\n >\r\n <p-progressBar\r\n mode=\"indeterminate\"\r\n [style]=\"{ height: '4px' }\"\r\n />\r\n </th>\r\n </tr>\r\n }\r\n </ng-template>\r\n <ng-template\r\n #body\r\n let-row\r\n let-columns=\"columns\"\r\n let-index=\"rowIndex\"\r\n class=\"divide-y divide-gray-200\"\r\n >\r\n @if (loading()) {\r\n <tr>\r\n @if (reorderableRows()) {\r\n <td><p-skeleton /></td>\r\n }\r\n @if (selectableRows()) {\r\n <td><p-skeleton /></td>\r\n }\r\n @for (col of columns; track col.key || col.label || $index) {\r\n <td><p-skeleton /></td>\r\n }\r\n @if (rowActions().length > 0) {\r\n <td><p-skeleton /></td>\r\n }\r\n </tr>\r\n } @else {\r\n <tr\r\n class=\"border-surface-300 transition-colors duration-150 dark:border-surface-500\"\r\n [class.mt-table-clickable-row]=\"clickableRows()\"\r\n [class.mt-table-status-entity-row]=\"\r\n getStatusEntityAccentColor(row)\r\n \"\r\n [style.--mt-table-status-accent]=\"\r\n getStatusEntityAccentColor(row)\r\n \"\r\n [class.cursor-pointer]=\"clickableRows()\"\r\n [pReorderableRow]=\"index\"\r\n (click)=\"onRowClick($event, row)\"\r\n >\r\n @if (reorderableRows()) {\r\n <td class=\"w-10 text-center\">\r\n <mt-button\r\n styleClass=\"cursor-move!\"\r\n pReorderableRowHandle\r\n severity=\"secondary\"\r\n variant=\"outlined\"\r\n size=\"small\"\r\n icon=\"general.menu-05\"\r\n ></mt-button>\r\n <!-- <mt-icon-->\r\n <!-- icon=\"general.menu-05\"-->\r\n <!-- class=\"cursor-move text-gray-500\"-->\r\n <!-- pReorderableRowHandle-->\r\n <!-- ></mt-icon>-->\r\n </td>\r\n }\r\n @if (selectableRows()) {\r\n <td class=\"w-12\">\r\n <mt-checkbox-field\r\n [ngModel]=\"selectedRows().has(row)\"\r\n (ngModelChange)=\"toggleRow(row)\"\r\n ></mt-checkbox-field>\r\n </td>\r\n }\r\n\r\n @for (col of columns; track col.key || col.label || $index) {\r\n <td\r\n class=\"text-gray-700 dark:text-gray-100\"\r\n [style.width]=\"col.width ?? null\"\r\n [style.minWidth]=\"col.width ?? null\"\r\n >\r\n @switch (col.type) {\r\n @case (\"boolean\") {\r\n <mt-toggle-field\r\n [ngModel]=\"getBooleanProperty(row, col.key)\"\r\n (ngModelChange)=\"\r\n onCellChange(row, col.key, $event, 'boolean')\r\n \"\r\n [readonly]=\"col.readonly ?? false\"\r\n ></mt-toggle-field>\r\n }\r\n @case (\"date\") {\r\n {{ getProperty(row, col.key) | date: \"mediumDate\" }}\r\n }\r\n @case (\"user\") {\r\n @if (getEntityPreviewData(row, col); as entityData) {\r\n <mt-entity-preview\r\n [data]=\"entityData\"\r\n attachmentShape=\"compact\"\r\n ></mt-entity-preview>\r\n } @else {\r\n {{ getProperty(row, col.key) }}\r\n }\r\n }\r\n @case (\"status\") {\r\n @if (getEntityPreviewData(row, col); as entityData) {\r\n <mt-entity-preview\r\n [data]=\"entityData\"\r\n attachmentShape=\"compact\"\r\n ></mt-entity-preview>\r\n } @else {\r\n {{ getProperty(row, col.key) }}\r\n }\r\n }\r\n @case (\"entity\") {\r\n @if (getEntityColumnData(row, col); as entityData) {\r\n <mt-entity-preview\r\n [data]=\"entityData\"\r\n attachmentShape=\"compact\"\r\n ></mt-entity-preview>\r\n } @else {\r\n {{ getProperty(row, col.key) }}\r\n }\r\n }\r\n @case (\"custom\") {\r\n <ng-container\r\n *ngTemplateOutlet=\"\r\n col.customCellTpl;\r\n context: { $implicit: row }\r\n \"\r\n >\r\n </ng-container>\r\n }\r\n @default {\r\n {{ getProperty(row, col.key) }}\r\n }\r\n }\r\n </td>\r\n }\r\n\r\n @if (rowActions().length > 0) {\r\n <td class=\"text-right\">\r\n @if (actionShape() === \"popover\") {\r\n <div class=\"flex items-center justify-end\">\r\n <mt-button\r\n icon=\"general.dots-vertical\"\r\n severity=\"secondary\"\r\n variant=\"text\"\r\n size=\"large\"\r\n (click)=\"rowPopover.toggle($event)\"\r\n data-row-click-ignore=\"true\"\r\n ></mt-button>\r\n <p-popover #rowPopover appendTo=\"body\">\r\n <div class=\"flex flex-col min-w-40\">\r\n @for (\r\n action of getVisibleRowActions(row);\r\n track $index\r\n ) {\r\n <button\r\n class=\"flex items-center gap-2 px-2 cursor-pointer py-2 text-sm rounded transition-colors\"\r\n [class]=\"\r\n action.color === 'danger'\r\n ? 'text-red-600 hover:bg-red-50 dark:hover:bg-red-950'\r\n : 'text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-surface-700'\r\n \"\r\n (click)=\"\r\n rowAction($event, action, row);\r\n rowPopover.hide()\r\n \"\r\n >\r\n @if (action.icon) {\r\n <mt-icon\r\n [icon]=\"action.icon\"\r\n class=\"text-base\"\r\n />\r\n }\r\n <span>{{\r\n action.label || action.tooltip\r\n }}</span>\r\n </button>\r\n }\r\n </div>\r\n </p-popover>\r\n </div>\r\n } @else {\r\n <div class=\"flex items-center justify-end space-x-2\">\r\n @for (action of rowActions(); track $index) {\r\n @let hidden = action.hidden?.(row);\r\n @if (!hidden) {\r\n <mt-button\r\n [icon]=\"action.icon\"\r\n [severity]=\"action.color\"\r\n [variant]=\"action.variant\"\r\n [size]=\"action.size || 'small'\"\r\n (click)=\"rowAction($event, action, row)\"\r\n [tooltip]=\"action.tooltip\"\r\n [label]=\"action.label\"\r\n [loading]=\"resolveActionLoading(action, row)\"\r\n ></mt-button>\r\n }\r\n }\r\n </div>\r\n }\r\n </td>\r\n }\r\n </tr>\r\n }\r\n </ng-template>\r\n <ng-template #emptymessage>\r\n <tr>\r\n <td colspan=\"20\" class=\"text-center\">\r\n <div class=\"flex justify-center\">No data found.</div>\r\n </td>\r\n </tr>\r\n </ng-template>\r\n </p-table>\r\n </div>\r\n }\r\n </div>\r\n\r\n <div\r\n class=\"flex flex-col gap-3 pb-3 px-4\"\r\n [class]=\"'items-' + paginatorPosition()\"\r\n >\r\n <mt-paginator\r\n [(rows)]=\"pageSize\"\r\n [(first)]=\"first\"\r\n [(page)]=\"currentPage\"\r\n [totalRecords]=\"totalRecords()\"\r\n [alwaysShow]=\"false\"\r\n [rowsPerPageOptions]=\"[5, 10, 20, 50]\"\r\n (onPageChange)=\"onPaginatorPage($event)\"\r\n ></mt-paginator>\r\n </div>\r\n</div>\r\n", styles: [".mt-table-clickable-row>td{transition:background-color .16s ease,color .16s ease,border-color .16s ease}.mt-table-clickable-row:hover>td,.mt-table-clickable-row:focus-within>td{background:color-mix(in srgb,var(--p-primary-color) 6%,var(--p-surface-0))}.mt-table-clickable-row:hover>td:first-child,.mt-table-clickable-row:focus-within>td:first-child{border-inline-start:3px solid var(--p-primary-color)}.mt-table-status-entity-row>td{background:color-mix(in srgb,var(--mt-table-status-accent) 4%,var(--p-surface-0))}.mt-table-status-entity-row>td:first-child{position:relative}.mt-table-status-entity-row>td:first-child:before{content:\"\";position:absolute;inset-block:.4rem;inset-inline-start:.35rem;width:4px;border-radius:999px;background:var(--mt-table-status-accent)}.mt-table-clickable-row.mt-table-status-entity-row:hover>td,.mt-table-clickable-row.mt-table-status-entity-row:focus-within>td{background:color-mix(in srgb,var(--mt-table-status-accent) 6%,color-mix(in srgb,var(--p-primary-color) 6%,var(--p-surface-0)))}.mt-table-clickable-row.mt-table-status-entity-row:hover>td:first-child,.mt-table-clickable-row.mt-table-status-entity-row:focus-within>td:first-child{border-inline-start:none}\n"], dependencies: [{ kind: "ngmodule", type: TableModule }, { kind: "component", type: i1$1.Table, selector: "p-table", inputs: ["frozenColumns", "frozenValue", "styleClass", "tableStyle", "tableStyleClass", "paginator", "pageLinks", "rowsPerPageOptions", "alwaysShowPaginator", "paginatorPosition", "paginatorStyleClass", "paginatorDropdownAppendTo", "paginatorDropdownScrollHeight", "currentPageReportTemplate", "showCurrentPageReport", "showJumpToPageDropdown", "showJumpToPageInput", "showFirstLastIcon", "showPageLinks", "defaultSortOrder", "sortMode", "resetPageOnSort", "selectionMode", "selectionPageOnly", "contextMenuSelection", "contextMenuSelectionMode", "dataKey", "metaKeySelection", "rowSelectable", "rowTrackBy", "lazy", "lazyLoadOnInit", "compareSelectionBy", "csvSeparator", "exportFilename", "filters", "globalFilterFields", "filterDelay", "filterLocale", "expandedRowKeys", "editingRowKeys", "rowExpandMode", "scrollable", "rowGroupMode", "scrollHeight", "virtualScroll", "virtualScrollItemSize", "virtualScrollOptions", "virtualScrollDelay", "frozenWidth", "contextMenu", "resizableColumns", "columnResizeMode", "reorderableColumns", "loading", "loadingIcon", "showLoader", "rowHover", "customSort", "showInitialSortBadge", "exportFunction", "exportHeader", "stateKey", "stateStorage", "editMode", "groupRowsBy", "size", "showGridlines", "stripedRows", "groupRowsByOrder", "responsiveLayout", "breakpoint", "paginatorLocale", "value", "columns", "first", "rows", "totalRecords", "sortField", "sortOrder", "multiSortMeta", "selection", "selectAll"], outputs: ["contextMenuSelectionChange", "selectAllChange", "selectionChange", "onRowSelect", "onRowUnselect", "onPage", "onSort", "onFilter", "onLazyLoad", "onRowExpand", "onRowCollapse", "onContextMenuSelect", "onColResize", "onColReorder", "onRowReorder", "onEditInit", "onEditComplete", "onEditCancel", "onHeaderCheckboxToggle", "sortFunction", "firstChange", "rowsChange", "onStateSave", "onStateRestore"] }, { kind: "directive", type: i1$1.ReorderableColumn, selector: "[pReorderableColumn]", inputs: ["pReorderableColumnDisabled"] }, { kind: "directive", type: i1$1.ReorderableRowHandle, selector: "[pReorderableRowHandle]" }, { kind: "directive", type: i1$1.ReorderableRow, selector: "[pReorderableRow]", inputs: ["pReorderableRow", "pReorderableRowDisabled"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: ToggleField, selector: "mt-toggle-field", inputs: ["label", "labelPosition", "placeholder", "readonly", "pInputs", "required", "toggleShape", "size", "icon", "descriptionCard"], outputs: ["onChange"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: Button, selector: "mt-button", inputs: ["icon", "label", "tooltip", "class", "type", "styleClass", "severity", "badge", "variant", "badgeSeverity", "size", "iconPos", "autofocus", "fluid", "raised", "rounded", "text", "plain", "outlined", "link", "disabled", "loading", "pInputs"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "component", type: TextField, selector: "mt-text-field", inputs: ["field", "hint", "label", "placeholder", "class", "type", "readonly", "pInputs", "required", "icon", "iconPosition"] }, { kind: "component", type: Paginator, selector: "mt-paginator", inputs: ["rows", "totalRecords", "first", "page", "rowsPerPageOptions", "showFirstLastIcon", "showCurrentPageReport", "fluid", "pageLinkSize", "alwaysShow"], outputs: ["rowsChange", "firstChange", "pageChange", "onPageChange"] }, { kind: "component", type: CheckboxField, selector: "mt-checkbox-field", inputs: ["label", "labelPosition", "placeholder", "readonly", "pInputs", "required"], outputs: ["onChange"] }, { kind: "component", type: Tabs, selector: "mt-tabs", inputs: ["options", "optionLabel", "optionValue", "active", "size", "fluid", "disabled"], outputs: ["activeChange", "onChange"] }, { kind: "ngmodule", type: SkeletonModule }, { kind: "component", type: i3$1.Skeleton, selector: "p-skeleton", inputs: ["styleClass", "shape", "animation", "borderRadius", "size", "width", "height"] }, { kind: "ngmodule", type: ProgressBarModule }, { kind: "component", type: i4.ProgressBar, selector: "p-progressBar, p-progressbar, p-progress-bar", inputs: ["value", "showValue", "styleClass", "valueStyleClass", "unit", "mode", "color"] }, { kind: "ngmodule", type: TranslocoModule }, { kind: "component", type: TableFilter, selector: "mt-table-filter", inputs: ["columns", "data"], outputs: ["filterApplied", "filterReset"] }, { kind: "component", type: EntityPreview, selector: "mt-entity-preview", inputs: ["data", "attachmentShape"] }, { kind: "ngmodule", type: PopoverModule }, { kind: "component", type: i2.Popover, selector: "p-popover", inputs: ["ariaLabel", "ariaLabelledBy", "dismissable", "style", "styleClass", "appendTo", "autoZIndex", "ariaCloseLabel", "baseZIndex", "focusOnShow", "showTransitionOptions", "hideTransitionOptions", "motionOptions"], outputs: ["onShow", "onHide"] }, { kind: "component", type: Icon, selector: "mt-icon", inputs: ["icon"] }, { kind: "pipe", type: DatePipe, name: "date" }, { kind: "pipe", type: i3.TranslocoPipe, name: "transloco" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1124
+ }
1125
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: Table, decorators: [{
1126
+ type: Component,
1127
+ args: [{ selector: 'mt-table', standalone: true, imports: [
1128
+ TableModule,
1129
+ NgTemplateOutlet,
1130
+ DatePipe,
1131
+ ToggleField,
1132
+ FormsModule,
1133
+ Button,
1134
+ TextField,
1135
+ Paginator,
1136
+ CheckboxField,
1137
+ Tabs,
1138
+ SkeletonModule,
1139
+ ProgressBarModule,
1140
+ TranslocoModule,
1141
+ TableFilter,
1142
+ EntityPreview,
1143
+ PopoverModule,
1144
+ Icon,
1145
+ ], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"space-y-4 rounded-2xl\">\r\n <div>\r\n @if (\r\n captionStartContent() ||\r\n captionEndContent() ||\r\n generalSearch() ||\r\n showFilters() ||\r\n tabs()?.length > 0 ||\r\n actions()?.length > 0\r\n ) {\r\n <div class=\"p-datatable-header rounded-t-2xl\">\r\n <div\r\n class=\"flex relative\"\r\n [class]=\"!generalSearch() ? 'justify-end' : 'justify-between'\"\r\n >\r\n <div class=\"flex items-center gap-2\">\r\n <ng-container\r\n *ngTemplateOutlet=\"captionStartContent()\"\r\n ></ng-container>\r\n @if (tabs()) {\r\n <mt-tabs\r\n [(active)]=\"activeTab\"\r\n [options]=\"tabs()\"\r\n [optionLabel]=\"tabsOptionLabel()\"\r\n [optionValue]=\"tabsOptionValue()\"\r\n (onChange)=\"tabChanged($event)\"\r\n size=\"large\"\r\n ></mt-tabs>\r\n }\r\n @if (generalSearch()) {\r\n <mt-text-field\r\n [(ngModel)]=\"filterTerm\"\r\n (ngModelChange)=\"onSearchChange($event)\"\r\n icon=\"general.search-lg\"\r\n [placeholder]=\"'components.table.search' | transloco\"\r\n ></mt-text-field>\r\n }\r\n </div>\r\n <div class=\"flex items-center gap-2\">\r\n @if (showFilters()) {\r\n <mt-table-filter\r\n [columns]=\"columns()\"\r\n [data]=\"data()\"\r\n [ngModel]=\"filters()\"\r\n (filterApplied)=\"onFilterApplied($event)\"\r\n (filterReset)=\"onFilterReset()\"\r\n />\r\n }\r\n @if (exportable()) {\r\n <mt-button\r\n icon=\"file.file-x-03\"\r\n [tooltip]=\"'components.table.export' | transloco\"\r\n (click)=\"exportCSV()\"\r\n />\r\n }\r\n @if (actions()?.length > 0) {\r\n <div class=\"flex items-center space-x-2\">\r\n @for (action of actions(); track action.label) {\r\n <mt-button\r\n [icon]=\"action.icon\"\r\n [severity]=\"action.color\"\r\n [variant]=\"action.variant\"\r\n [size]=\"action.size\"\r\n (click)=\"action.action(row)\"\r\n [label]=\"action.label\"\r\n [tooltip]=\"action.tooltip\"\r\n ></mt-button>\r\n }\r\n </div>\r\n }\r\n <ng-container\r\n *ngTemplateOutlet=\"captionEndContent()\"\r\n ></ng-container>\r\n </div>\r\n </div>\r\n </div>\r\n }\r\n @if (!loading() && emptyContent() && data().length === 0) {\r\n <div\r\n class=\"p-4 bg-content rounded-md text-center text-gray-600 dark:text-gray-300\"\r\n >\r\n <ng-container *ngTemplateOutlet=\"emptyContent()\"></ng-container>\r\n </div>\r\n } @else {\r\n <div class=\"overflow-x-auto bg-content\">\r\n <p-table\r\n #dt\r\n [value]=\"displayData()\"\r\n [columns]=\"columns()\"\r\n [size]=\"size()\"\r\n [showGridlines]=\"showGridlines()\"\r\n [stripedRows]=\"stripedRows()\"\r\n [lazy]=\"lazy()\"\r\n [totalRecords]=\"totalRecords()\"\r\n [reorderableColumns]=\"reorderableColumns()\"\r\n [reorderableRows]=\"reorderableRows()\"\r\n [dataKey]=\"dataKey()\"\r\n [first]=\"first()\"\r\n [rows]=\"pageSize()\"\r\n [exportFilename]=\"exportFilename()\"\r\n (onPage)=\"onTablePage($event)\"\r\n (onLazyLoad)=\"handleLazyLoad($event)\"\r\n (onColReorder)=\"onColumnReorder($event)\"\r\n (onRowReorder)=\"onRowReorder($event)\"\r\n paginator\r\n paginatorStyleClass=\"hidden!\"\r\n class=\"min-w-full text-sm align-middle table-fixed\"\r\n >\r\n <ng-template\r\n #header\r\n let-columns\r\n class=\"bg-surface-50 dark:bg-surface-950 border-b border-surface-300 dark:border-surface-500\"\r\n >\r\n <tr>\r\n @if (reorderableRows()) {\r\n <th class=\"w-10\"></th>\r\n }\r\n @if (selectableRows()) {\r\n <th class=\"w-12 text-start\">\r\n <mt-checkbox-field\r\n [ngModel]=\"allSelectedOnPage()\"\r\n (ngModelChange)=\"toggleAllRowsOnPage()\"\r\n ></mt-checkbox-field>\r\n </th>\r\n }\r\n\r\n @for (col of columns; track col.key || col.label || $index) {\r\n @if (reorderableColumns()) {\r\n <th\r\n pReorderableColumn\r\n class=\"text-start font-semibold text-gray-600 dark:text-gray-50 uppercase tracking-wider\"\r\n >\r\n <div class=\"flex items-center gap-2\">\r\n {{ col.label }}\r\n <!-- <mt-icon-->\r\n <!-- icon=\"general.menu-05\"-->\r\n <!-- class=\"text-xs text-gray-400\"-->\r\n <!-- ></mt-icon>-->\r\n <mt-button\r\n styleClass=\"cursor-move!\"\r\n severity=\"secondary\"\r\n variant=\"outlined\"\r\n size=\"small\"\r\n icon=\"general.menu-05\"\r\n ></mt-button>\r\n </div>\r\n </th>\r\n } @else {\r\n <th\r\n class=\"text-start font-semibold text-gray-600 dark:text-gray-50 uppercase tracking-wider\"\r\n [style.width]=\"col.width ?? null\"\r\n [style.minWidth]=\"col.width ?? null\"\r\n >\r\n @if (isColumnSortable(col)) {\r\n <button\r\n type=\"button\"\r\n class=\"inline-flex items-center gap-2 cursor-pointer\"\r\n (click)=\"toggleSort(col)\"\r\n >\r\n <span>{{ col.label }}</span>\r\n <mt-icon\r\n [icon]=\"getSortIcon(col)\"\r\n class=\"text-xs text-gray-400\"\r\n />\r\n </button>\r\n } @else {\r\n {{ col.label }}\r\n }\r\n </th>\r\n }\r\n }\r\n\r\n @if (rowActions().length > 0) {\r\n <th\r\n class=\"text-end! font-semibold text-gray-600 dark:text-gray-50 uppercase tracking-wider\"\r\n >\r\n {{ \"components.table.actions\" | transloco }}\r\n </th>\r\n }\r\n </tr>\r\n @if (updating()) {\r\n <tr>\r\n <th\r\n [attr.colspan]=\"\r\n columns.length +\r\n (reorderableRows() ? 1 : 0) +\r\n (selectableRows() ? 1 : 0) +\r\n (rowActions().length > 0 ? 1 : 0)\r\n \"\r\n class=\"!p-0\"\r\n >\r\n <p-progressBar\r\n mode=\"indeterminate\"\r\n [style]=\"{ height: '4px' }\"\r\n />\r\n </th>\r\n </tr>\r\n }\r\n </ng-template>\r\n <ng-template\r\n #body\r\n let-row\r\n let-columns=\"columns\"\r\n let-index=\"rowIndex\"\r\n class=\"divide-y divide-gray-200\"\r\n >\r\n @if (loading()) {\r\n <tr>\r\n @if (reorderableRows()) {\r\n <td><p-skeleton /></td>\r\n }\r\n @if (selectableRows()) {\r\n <td><p-skeleton /></td>\r\n }\r\n @for (col of columns; track col.key || col.label || $index) {\r\n <td><p-skeleton /></td>\r\n }\r\n @if (rowActions().length > 0) {\r\n <td><p-skeleton /></td>\r\n }\r\n </tr>\r\n } @else {\r\n <tr\r\n class=\"border-surface-300 transition-colors duration-150 dark:border-surface-500\"\r\n [class.mt-table-clickable-row]=\"clickableRows()\"\r\n [class.mt-table-status-entity-row]=\"\r\n getStatusEntityAccentColor(row)\r\n \"\r\n [style.--mt-table-status-accent]=\"\r\n getStatusEntityAccentColor(row)\r\n \"\r\n [class.cursor-pointer]=\"clickableRows()\"\r\n [pReorderableRow]=\"index\"\r\n (click)=\"onRowClick($event, row)\"\r\n >\r\n @if (reorderableRows()) {\r\n <td class=\"w-10 text-center\">\r\n <mt-button\r\n styleClass=\"cursor-move!\"\r\n pReorderableRowHandle\r\n severity=\"secondary\"\r\n variant=\"outlined\"\r\n size=\"small\"\r\n icon=\"general.menu-05\"\r\n ></mt-button>\r\n <!-- <mt-icon-->\r\n <!-- icon=\"general.menu-05\"-->\r\n <!-- class=\"cursor-move text-gray-500\"-->\r\n <!-- pReorderableRowHandle-->\r\n <!-- ></mt-icon>-->\r\n </td>\r\n }\r\n @if (selectableRows()) {\r\n <td class=\"w-12\">\r\n <mt-checkbox-field\r\n [ngModel]=\"selectedRows().has(row)\"\r\n (ngModelChange)=\"toggleRow(row)\"\r\n ></mt-checkbox-field>\r\n </td>\r\n }\r\n\r\n @for (col of columns; track col.key || col.label || $index) {\r\n <td\r\n class=\"text-gray-700 dark:text-gray-100\"\r\n [style.width]=\"col.width ?? null\"\r\n [style.minWidth]=\"col.width ?? null\"\r\n >\r\n @switch (col.type) {\r\n @case (\"boolean\") {\r\n <mt-toggle-field\r\n [ngModel]=\"getBooleanProperty(row, col.key)\"\r\n (ngModelChange)=\"\r\n onCellChange(row, col.key, $event, 'boolean')\r\n \"\r\n [readonly]=\"col.readonly ?? false\"\r\n ></mt-toggle-field>\r\n }\r\n @case (\"date\") {\r\n {{ getProperty(row, col.key) | date: \"mediumDate\" }}\r\n }\r\n @case (\"user\") {\r\n @if (getEntityPreviewData(row, col); as entityData) {\r\n <mt-entity-preview\r\n [data]=\"entityData\"\r\n attachmentShape=\"compact\"\r\n ></mt-entity-preview>\r\n } @else {\r\n {{ getProperty(row, col.key) }}\r\n }\r\n }\r\n @case (\"status\") {\r\n @if (getEntityPreviewData(row, col); as entityData) {\r\n <mt-entity-preview\r\n [data]=\"entityData\"\r\n attachmentShape=\"compact\"\r\n ></mt-entity-preview>\r\n } @else {\r\n {{ getProperty(row, col.key) }}\r\n }\r\n }\r\n @case (\"entity\") {\r\n @if (getEntityColumnData(row, col); as entityData) {\r\n <mt-entity-preview\r\n [data]=\"entityData\"\r\n attachmentShape=\"compact\"\r\n ></mt-entity-preview>\r\n } @else {\r\n {{ getProperty(row, col.key) }}\r\n }\r\n }\r\n @case (\"custom\") {\r\n <ng-container\r\n *ngTemplateOutlet=\"\r\n col.customCellTpl;\r\n context: { $implicit: row }\r\n \"\r\n >\r\n </ng-container>\r\n }\r\n @default {\r\n {{ getProperty(row, col.key) }}\r\n }\r\n }\r\n </td>\r\n }\r\n\r\n @if (rowActions().length > 0) {\r\n <td class=\"text-right\">\r\n @if (actionShape() === \"popover\") {\r\n <div class=\"flex items-center justify-end\">\r\n <mt-button\r\n icon=\"general.dots-vertical\"\r\n severity=\"secondary\"\r\n variant=\"text\"\r\n size=\"large\"\r\n (click)=\"rowPopover.toggle($event)\"\r\n data-row-click-ignore=\"true\"\r\n ></mt-button>\r\n <p-popover #rowPopover appendTo=\"body\">\r\n <div class=\"flex flex-col min-w-40\">\r\n @for (\r\n action of getVisibleRowActions(row);\r\n track $index\r\n ) {\r\n <button\r\n class=\"flex items-center gap-2 px-2 cursor-pointer py-2 text-sm rounded transition-colors\"\r\n [class]=\"\r\n action.color === 'danger'\r\n ? 'text-red-600 hover:bg-red-50 dark:hover:bg-red-950'\r\n : 'text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-surface-700'\r\n \"\r\n (click)=\"\r\n rowAction($event, action, row);\r\n rowPopover.hide()\r\n \"\r\n >\r\n @if (action.icon) {\r\n <mt-icon\r\n [icon]=\"action.icon\"\r\n class=\"text-base\"\r\n />\r\n }\r\n <span>{{\r\n action.label || action.tooltip\r\n }}</span>\r\n </button>\r\n }\r\n </div>\r\n </p-popover>\r\n </div>\r\n } @else {\r\n <div class=\"flex items-center justify-end space-x-2\">\r\n @for (action of rowActions(); track $index) {\r\n @let hidden = action.hidden?.(row);\r\n @if (!hidden) {\r\n <mt-button\r\n [icon]=\"action.icon\"\r\n [severity]=\"action.color\"\r\n [variant]=\"action.variant\"\r\n [size]=\"action.size || 'small'\"\r\n (click)=\"rowAction($event, action, row)\"\r\n [tooltip]=\"action.tooltip\"\r\n [label]=\"action.label\"\r\n [loading]=\"resolveActionLoading(action, row)\"\r\n ></mt-button>\r\n }\r\n }\r\n </div>\r\n }\r\n </td>\r\n }\r\n </tr>\r\n }\r\n </ng-template>\r\n <ng-template #emptymessage>\r\n <tr>\r\n <td colspan=\"20\" class=\"text-center\">\r\n <div class=\"flex justify-center\">No data found.</div>\r\n </td>\r\n </tr>\r\n </ng-template>\r\n </p-table>\r\n </div>\r\n }\r\n </div>\r\n\r\n <div\r\n class=\"flex flex-col gap-3 pb-3 px-4\"\r\n [class]=\"'items-' + paginatorPosition()\"\r\n >\r\n <mt-paginator\r\n [(rows)]=\"pageSize\"\r\n [(first)]=\"first\"\r\n [(page)]=\"currentPage\"\r\n [totalRecords]=\"totalRecords()\"\r\n [alwaysShow]=\"false\"\r\n [rowsPerPageOptions]=\"[5, 10, 20, 50]\"\r\n (onPageChange)=\"onPaginatorPage($event)\"\r\n ></mt-paginator>\r\n </div>\r\n</div>\r\n", styles: [".mt-table-clickable-row>td{transition:background-color .16s ease,color .16s ease,border-color .16s ease}.mt-table-clickable-row:hover>td,.mt-table-clickable-row:focus-within>td{background:color-mix(in srgb,var(--p-primary-color) 6%,var(--p-surface-0))}.mt-table-clickable-row:hover>td:first-child,.mt-table-clickable-row:focus-within>td:first-child{border-inline-start:3px solid var(--p-primary-color)}.mt-table-status-entity-row>td{background:color-mix(in srgb,var(--mt-table-status-accent) 4%,var(--p-surface-0))}.mt-table-status-entity-row>td:first-child{position:relative}.mt-table-status-entity-row>td:first-child:before{content:\"\";position:absolute;inset-block:.4rem;inset-inline-start:.35rem;width:4px;border-radius:999px;background:var(--mt-table-status-accent)}.mt-table-clickable-row.mt-table-status-entity-row:hover>td,.mt-table-clickable-row.mt-table-status-entity-row:focus-within>td{background:color-mix(in srgb,var(--mt-table-status-accent) 6%,color-mix(in srgb,var(--p-primary-color) 6%,var(--p-surface-0)))}.mt-table-clickable-row.mt-table-status-entity-row:hover>td:first-child,.mt-table-clickable-row.mt-table-status-entity-row:focus-within>td:first-child{border-inline-start:none}\n"] }]
1146
+ }], propDecorators: { selectionChange: [{ type: i0.Output, args: ["selectionChange"] }], cellChange: [{ type: i0.Output, args: ["cellChange"] }], lazyLoad: [{ type: i0.Output, args: ["lazyLoad"] }], columnReorder: [{ type: i0.Output, args: ["columnReorder"] }], rowReorder: [{ type: i0.Output, args: ["rowReorder"] }], rowClick: [{ type: i0.Output, args: ["rowClick"] }], filters: [{ type: i0.Input, args: [{ isSignal: true, alias: "filters", required: false }] }, { type: i0.Output, args: ["filtersChange"] }], data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: true }] }], columns: [{ type: i0.Input, args: [{ isSignal: true, alias: "columns", required: true }] }], rowActions: [{ type: i0.Input, args: [{ isSignal: true, alias: "rowActions", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], showGridlines: [{ type: i0.Input, args: [{ isSignal: true, alias: "showGridlines", required: false }] }], stripedRows: [{ type: i0.Input, args: [{ isSignal: true, alias: "stripedRows", required: false }] }], selectableRows: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectableRows", required: false }] }], clickableRows: [{ type: i0.Input, args: [{ isSignal: true, alias: "clickableRows", required: false }] }], generalSearch: [{ type: i0.Input, args: [{ isSignal: true, alias: "generalSearch", required: false }] }], lazyLocalSearch: [{ type: i0.Input, args: [{ isSignal: true, alias: "lazyLocalSearch", required: false }] }], showFilters: [{ type: i0.Input, args: [{ isSignal: true, alias: "showFilters", required: false }] }], loading: [{ type: i0.Input, args: [{ isSignal: true, alias: "loading", required: false }] }], updating: [{ type: i0.Input, args: [{ isSignal: true, alias: "updating", required: false }] }], lazy: [{ type: i0.Input, args: [{ isSignal: true, alias: "lazy", required: false }] }], lazyLocalSort: [{ type: i0.Input, args: [{ isSignal: true, alias: "lazyLocalSort", required: false }] }], lazyTotalRecords: [{ type: i0.Input, args: [{ isSignal: true, alias: "lazyTotalRecords", required: false }] }], reorderableColumns: [{ type: i0.Input, args: [{ isSignal: true, alias: "reorderableColumns", required: false }] }], reorderableRows: [{ type: i0.Input, args: [{ isSignal: true, alias: "reorderableRows", required: false }] }], dataKey: [{ type: i0.Input, args: [{ isSignal: true, alias: "dataKey", required: false }] }], exportable: [{ type: i0.Input, args: [{ isSignal: true, alias: "exportable", required: false }] }], exportFilename: [{ type: i0.Input, args: [{ isSignal: true, alias: "exportFilename", required: false }] }], actionShape: [{ type: i0.Input, args: [{ isSignal: true, alias: "actionShape", required: false }] }], tabs: [{ type: i0.Input, args: [{ isSignal: true, alias: "tabs", required: false }] }], tabsOptionLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "tabsOptionLabel", required: false }] }], tabsOptionValue: [{ type: i0.Input, args: [{ isSignal: true, alias: "tabsOptionValue", required: false }] }], activeTab: [{ type: i0.Input, args: [{ isSignal: true, alias: "activeTab", required: false }] }, { type: i0.Output, args: ["activeTabChange"] }], onTabChange: [{ type: i0.Output, args: ["onTabChange"] }], actions: [{ type: i0.Input, args: [{ isSignal: true, alias: "actions", required: false }] }], captionStartContent: [{ type: i0.ContentChild, args: ['captionStart', { isSignal: true }] }], captionEndContent: [{ type: i0.ContentChild, args: ['captionEnd', { isSignal: true }] }], emptyContent: [{ type: i0.ContentChild, args: ['empty', { isSignal: true }] }], tableRef: [{ type: i0.ViewChild, args: ['dt', { isSignal: true }] }], paginatorPosition: [{ type: i0.Input, args: [{ isSignal: true, alias: "paginatorPosition", required: false }] }], pageSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "pageSize", required: false }] }, { type: i0.Output, args: ["pageSizeChange"] }], currentPage: [{ type: i0.Input, args: [{ isSignal: true, alias: "currentPage", required: false }] }, { type: i0.Output, args: ["currentPageChange"] }], first: [{ type: i0.Input, args: [{ isSignal: true, alias: "first", required: false }] }, { type: i0.Output, args: ["firstChange"] }], filterTerm: [{ type: i0.Input, args: [{ isSignal: true, alias: "filterTerm", required: false }] }, { type: i0.Output, args: ["filterTermChange"] }] } });
1147
+
1148
+ /**
1149
+ * Generated bundle index. Do not edit.
1150
+ */
1151
+
1152
+ export { Table, TableFilter };
1153
+ //# sourceMappingURL=masterteam-components-table.mjs.map