@masterteam/components 0.0.70 → 0.0.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/common.css +1 -1
- package/assets/i18n/ar.json +4 -1
- package/assets/i18n/en.json +4 -1
- package/fesm2022/masterteam-components-table.mjs +236 -70
- package/fesm2022/masterteam-components-table.mjs.map +1 -1
- package/fesm2022/masterteam-components-tree.mjs +146 -0
- package/fesm2022/masterteam-components-tree.mjs.map +1 -0
- package/package.json +5 -1
- package/types/masterteam-components-table.d.ts +67 -14
- package/types/masterteam-components-tree.d.ts +91 -0
|
@@ -1,32 +1,175 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { output,
|
|
2
|
+
import { input, output, signal, computed, forwardRef, ChangeDetectionStrategy, Component, model, booleanAttribute, contentChild, viewChild, inject } from '@angular/core';
|
|
3
3
|
import { NgTemplateOutlet, DatePipe } from '@angular/common';
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { FormsModule } from '@angular/forms';
|
|
4
|
+
import * as i1 from '@angular/forms';
|
|
5
|
+
import { FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
7
6
|
import { Button } from '@masterteam/components/button';
|
|
8
|
-
import {
|
|
7
|
+
import { DateField } from '@masterteam/components/date-field';
|
|
9
8
|
import { SelectField } from '@masterteam/components/select-field';
|
|
9
|
+
import { TextField } from '@masterteam/components/text-field';
|
|
10
|
+
import * as i3 from '@jsverse/transloco';
|
|
11
|
+
import { TranslocoModule } from '@jsverse/transloco';
|
|
12
|
+
import * as i2 from 'primeng/popover';
|
|
13
|
+
import { PopoverModule } from 'primeng/popover';
|
|
14
|
+
import { ToggleField } from '@masterteam/components/toggle-field';
|
|
10
15
|
import { Paginator } from '@masterteam/components/paginator';
|
|
11
16
|
import { CheckboxField } from '@masterteam/components/checkbox-field';
|
|
12
|
-
import * as i1 from 'primeng/table';
|
|
17
|
+
import * as i1$1 from 'primeng/table';
|
|
13
18
|
import { TableModule } from 'primeng/table';
|
|
14
19
|
import { Tabs } from '@masterteam/components/tabs';
|
|
15
|
-
import * as i3 from 'primeng/skeleton';
|
|
20
|
+
import * as i3$1 from 'primeng/skeleton';
|
|
16
21
|
import { SkeletonModule } from 'primeng/skeleton';
|
|
17
22
|
import * as i4 from 'primeng/progressbar';
|
|
18
23
|
import { ProgressBarModule } from 'primeng/progressbar';
|
|
19
24
|
import { ConfirmationService } from '@masterteam/components/confirmation';
|
|
20
|
-
import * as i5 from '@jsverse/transloco';
|
|
21
|
-
import { TranslocoModule } from '@jsverse/transloco';
|
|
22
25
|
import { Icon } from '@masterteam/icons';
|
|
23
26
|
|
|
27
|
+
class TableFilter {
|
|
28
|
+
columns = input.required(...(ngDevMode ? [{ debugName: "columns" }] : []));
|
|
29
|
+
data = input([], ...(ngDevMode ? [{ debugName: "data" }] : []));
|
|
30
|
+
filterApplied = output();
|
|
31
|
+
filterReset = output();
|
|
32
|
+
pendingFilters = signal({}, ...(ngDevMode ? [{ debugName: "pendingFilters" }] : []));
|
|
33
|
+
appliedFilters = signal({}, ...(ngDevMode ? [{ debugName: "appliedFilters" }] : []));
|
|
34
|
+
booleanOptions = [
|
|
35
|
+
{ label: 'Yes', value: true },
|
|
36
|
+
{ label: 'No', value: false },
|
|
37
|
+
];
|
|
38
|
+
onChange = () => { };
|
|
39
|
+
onTouched = () => { };
|
|
40
|
+
filterableColumns = computed(() => this.columns()
|
|
41
|
+
.filter((col) => col.filterConfig || col.type === 'date' || col.type === 'boolean')
|
|
42
|
+
.map((col) => {
|
|
43
|
+
// Auto-generate select options from data if not provided
|
|
44
|
+
if (col.filterConfig?.type === 'select' &&
|
|
45
|
+
!col.filterConfig.options?.length) {
|
|
46
|
+
const data = this.data();
|
|
47
|
+
const uniqueValues = [...new Set(data.map((row) => row[col.key]))]
|
|
48
|
+
.filter((value) => value !== null && value !== undefined && value !== '')
|
|
49
|
+
.sort((a, b) => String(a).localeCompare(String(b)));
|
|
50
|
+
return {
|
|
51
|
+
...col,
|
|
52
|
+
filterConfig: {
|
|
53
|
+
...col.filterConfig,
|
|
54
|
+
options: uniqueValues.map((value) => ({
|
|
55
|
+
label: String(value),
|
|
56
|
+
value,
|
|
57
|
+
})),
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
return col;
|
|
62
|
+
}), ...(ngDevMode ? [{ debugName: "filterableColumns" }] : []));
|
|
63
|
+
activeFilterCount = computed(() => {
|
|
64
|
+
const filters = this.appliedFilters();
|
|
65
|
+
return Object.values(filters).filter((v) => this.hasValue(v)).length;
|
|
66
|
+
}, ...(ngDevMode ? [{ debugName: "activeFilterCount" }] : []));
|
|
67
|
+
getFilterType(col) {
|
|
68
|
+
if (col.filterConfig?.type)
|
|
69
|
+
return col.filterConfig.type;
|
|
70
|
+
if (col.type === 'date')
|
|
71
|
+
return 'date';
|
|
72
|
+
if (col.type === 'boolean')
|
|
73
|
+
return 'boolean';
|
|
74
|
+
return 'text';
|
|
75
|
+
}
|
|
76
|
+
getFilterValue(key) {
|
|
77
|
+
const value = this.pendingFilters()[key];
|
|
78
|
+
return value?.value ?? value ?? null;
|
|
79
|
+
}
|
|
80
|
+
getDateRangeValue(key, part) {
|
|
81
|
+
const value = this.pendingFilters()[key];
|
|
82
|
+
if (!value || typeof value !== 'object')
|
|
83
|
+
return null;
|
|
84
|
+
return part === 'from' ? (value.from ?? null) : (value.to ?? null);
|
|
85
|
+
}
|
|
86
|
+
updateFilter(key, value) {
|
|
87
|
+
this.pendingFilters.update((filters) => ({
|
|
88
|
+
...filters,
|
|
89
|
+
[key]: value,
|
|
90
|
+
}));
|
|
91
|
+
this.onTouched();
|
|
92
|
+
}
|
|
93
|
+
updateDateFilter(key, part, value) {
|
|
94
|
+
this.pendingFilters.update((filters) => {
|
|
95
|
+
const current = filters[key] ?? {};
|
|
96
|
+
return {
|
|
97
|
+
...filters,
|
|
98
|
+
[key]: {
|
|
99
|
+
...current,
|
|
100
|
+
[part]: value,
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
});
|
|
104
|
+
this.onTouched();
|
|
105
|
+
}
|
|
106
|
+
apply() {
|
|
107
|
+
const filters = { ...this.pendingFilters() };
|
|
108
|
+
this.appliedFilters.set(filters);
|
|
109
|
+
this.onChange(filters);
|
|
110
|
+
this.filterApplied.emit(filters);
|
|
111
|
+
}
|
|
112
|
+
reset() {
|
|
113
|
+
this.pendingFilters.set({});
|
|
114
|
+
this.appliedFilters.set({});
|
|
115
|
+
this.onChange({});
|
|
116
|
+
this.filterReset.emit();
|
|
117
|
+
}
|
|
118
|
+
hasValue(value) {
|
|
119
|
+
if (value === null || value === undefined || value === '')
|
|
120
|
+
return false;
|
|
121
|
+
if (typeof value === 'object') {
|
|
122
|
+
return value.from != null || value.to != null || value.value != null;
|
|
123
|
+
}
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
// ControlValueAccessor
|
|
127
|
+
writeValue(value) {
|
|
128
|
+
const filters = value ?? {};
|
|
129
|
+
this.pendingFilters.set(filters);
|
|
130
|
+
this.appliedFilters.set(filters);
|
|
131
|
+
}
|
|
132
|
+
registerOnChange(fn) {
|
|
133
|
+
this.onChange = fn;
|
|
134
|
+
}
|
|
135
|
+
registerOnTouched(fn) {
|
|
136
|
+
this.onTouched = fn;
|
|
137
|
+
}
|
|
138
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: TableFilter, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
139
|
+
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: [
|
|
140
|
+
{
|
|
141
|
+
provide: NG_VALUE_ACCESSOR,
|
|
142
|
+
useExisting: forwardRef(() => TableFilter),
|
|
143
|
+
multi: true,
|
|
144
|
+
},
|
|
145
|
+
], ngImport: i0, template: "<mt-button\r\n (click)=\"popover.toggle($event)\"\r\n [label]=\"'components.table.filter' | transloco\"\r\n [badge]=\"activeFilterCount()\"\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 class=\"space-y-3 overflow-y-auto flex-1 py-3\">\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 }\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", "optionGroupLabel", "optionGroupChildren", "loading"], outputs: ["onChange"] }, { kind: "component", type: DateField, selector: "mt-date-field", inputs: ["field", "label", "placeholder", "class", "readonly", "showIcon", "showClear", "showTime", "pInputs", "required"] }, { 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 });
|
|
146
|
+
}
|
|
147
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: TableFilter, decorators: [{
|
|
148
|
+
type: Component,
|
|
149
|
+
args: [{ selector: 'mt-table-filter', standalone: true, imports: [
|
|
150
|
+
FormsModule,
|
|
151
|
+
TextField,
|
|
152
|
+
SelectField,
|
|
153
|
+
DateField,
|
|
154
|
+
Button,
|
|
155
|
+
PopoverModule,
|
|
156
|
+
TranslocoModule,
|
|
157
|
+
], changeDetection: ChangeDetectionStrategy.OnPush, providers: [
|
|
158
|
+
{
|
|
159
|
+
provide: NG_VALUE_ACCESSOR,
|
|
160
|
+
useExisting: forwardRef(() => TableFilter),
|
|
161
|
+
multi: true,
|
|
162
|
+
},
|
|
163
|
+
], template: "<mt-button\r\n (click)=\"popover.toggle($event)\"\r\n [label]=\"'components.table.filter' | transloco\"\r\n [badge]=\"activeFilterCount()\"\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 class=\"space-y-3 overflow-y-auto flex-1 py-3\">\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 }\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" }]
|
|
164
|
+
}], 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"] }] } });
|
|
165
|
+
|
|
24
166
|
class Table {
|
|
25
167
|
selectionChange = output();
|
|
26
168
|
cellChange = output();
|
|
27
169
|
lazyLoad = output();
|
|
28
170
|
columnReorder = output();
|
|
29
171
|
rowReorder = output();
|
|
172
|
+
filters = model({}, ...(ngDevMode ? [{ debugName: "filters" }] : []));
|
|
30
173
|
data = input.required(...(ngDevMode ? [{ debugName: "data" }] : []));
|
|
31
174
|
columns = input.required(...(ngDevMode ? [{ debugName: "columns" }] : []));
|
|
32
175
|
rowActions = input([], ...(ngDevMode ? [{ debugName: "rowActions" }] : []));
|
|
@@ -43,6 +186,8 @@ class Table {
|
|
|
43
186
|
reorderableColumns = input(false, { ...(ngDevMode ? { debugName: "reorderableColumns" } : {}), transform: booleanAttribute });
|
|
44
187
|
reorderableRows = input(false, { ...(ngDevMode ? { debugName: "reorderableRows" } : {}), transform: booleanAttribute });
|
|
45
188
|
dataKey = input(...(ngDevMode ? [undefined, { debugName: "dataKey" }] : []));
|
|
189
|
+
exportable = input(false, { ...(ngDevMode ? { debugName: "exportable" } : {}), transform: booleanAttribute });
|
|
190
|
+
exportFilename = input('download', ...(ngDevMode ? [{ debugName: "exportFilename" }] : []));
|
|
46
191
|
// Tabs inputs and outputs
|
|
47
192
|
tabs = input(...(ngDevMode ? [undefined, { debugName: "tabs" }] : []));
|
|
48
193
|
tabsOptionLabel = input(...(ngDevMode ? [undefined, { debugName: "tabsOptionLabel" }] : []));
|
|
@@ -55,6 +200,8 @@ class Table {
|
|
|
55
200
|
captionStartContent = contentChild('captionStart', ...(ngDevMode ? [{ debugName: "captionStartContent" }] : []));
|
|
56
201
|
captionEndContent = contentChild('captionEnd', ...(ngDevMode ? [{ debugName: "captionEndContent" }] : []));
|
|
57
202
|
emptyContent = contentChild('empty', ...(ngDevMode ? [{ debugName: "emptyContent" }] : []));
|
|
203
|
+
// Table reference for export
|
|
204
|
+
tableRef = viewChild('dt', ...(ngDevMode ? [{ debugName: "tableRef" }] : []));
|
|
58
205
|
paginatorPosition = input('end', ...(ngDevMode ? [{ debugName: "paginatorPosition" }] : []));
|
|
59
206
|
pageSize = model(10, ...(ngDevMode ? [{ debugName: "pageSize" }] : []));
|
|
60
207
|
currentPage = model(0, ...(ngDevMode ? [{ debugName: "currentPage" }] : []));
|
|
@@ -62,52 +209,34 @@ class Table {
|
|
|
62
209
|
filterTerm = model('', ...(ngDevMode ? [{ debugName: "filterTerm" }] : []));
|
|
63
210
|
confirmationService = inject(ConfirmationService);
|
|
64
211
|
selectedRows = signal(new Set(), ...(ngDevMode ? [{ debugName: "selectedRows" }] : []));
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
212
|
+
// Map columns for PrimeNG export (key -> field)
|
|
213
|
+
exportColumns = computed(() => this.columns()
|
|
214
|
+
.filter((col) => col.type !== 'custom')
|
|
215
|
+
.map((col) => ({ ...col, field: col.key, header: col.label })), ...(ngDevMode ? [{ debugName: "exportColumns" }] : []));
|
|
69
216
|
activeFilterCount = computed(() => {
|
|
70
|
-
|
|
217
|
+
const filters = this.filters();
|
|
218
|
+
return Object.values(filters).filter((value) => value !== null && value !== undefined && value !== '').length;
|
|
71
219
|
}, ...(ngDevMode ? [{ debugName: "activeFilterCount" }] : []));
|
|
72
220
|
filteredData = computed(() => {
|
|
73
221
|
const data = this.data();
|
|
74
|
-
// Skip local filtering when lazy mode is enabled
|
|
222
|
+
// Skip local filtering when lazy mode is enabled
|
|
75
223
|
if (this.lazy()) {
|
|
76
224
|
return data;
|
|
77
225
|
}
|
|
78
226
|
const searchTerm = this.filterTerm().toLowerCase();
|
|
79
|
-
const filters = this.
|
|
227
|
+
const filters = this.filters();
|
|
80
228
|
const filterKeys = Object.keys(filters);
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
return false;
|
|
88
|
-
});
|
|
89
|
-
});
|
|
229
|
+
let result = data;
|
|
230
|
+
// Apply search term
|
|
231
|
+
if (searchTerm !== '') {
|
|
232
|
+
result = result.filter((item) => Object.values(item).some((value) => typeof value === 'string' &&
|
|
233
|
+
value.toLowerCase().includes(searchTerm)));
|
|
90
234
|
}
|
|
91
|
-
|
|
92
|
-
|
|
235
|
+
// Apply column filters
|
|
236
|
+
if (filterKeys.length > 0) {
|
|
237
|
+
result = result.filter((item) => filterKeys.every((key) => this.matchesFilter(item, key, filters[key])));
|
|
93
238
|
}
|
|
94
|
-
return
|
|
95
|
-
return filterKeys.every((key) => {
|
|
96
|
-
const filterValue = filters[key];
|
|
97
|
-
const itemValue = this.getProperty(item, key);
|
|
98
|
-
if (filterValue === null ||
|
|
99
|
-
filterValue === undefined ||
|
|
100
|
-
filterValue === '') {
|
|
101
|
-
return true;
|
|
102
|
-
}
|
|
103
|
-
if (typeof itemValue === 'string') {
|
|
104
|
-
return itemValue
|
|
105
|
-
.toLowerCase()
|
|
106
|
-
.includes(String(filterValue).toLowerCase());
|
|
107
|
-
}
|
|
108
|
-
return itemValue === filterValue;
|
|
109
|
-
});
|
|
110
|
-
});
|
|
239
|
+
return result;
|
|
111
240
|
}, ...(ngDevMode ? [{ debugName: "filteredData" }] : []));
|
|
112
241
|
displayData = computed(() => {
|
|
113
242
|
if (this.loading()) {
|
|
@@ -137,32 +266,54 @@ class Table {
|
|
|
137
266
|
return false;
|
|
138
267
|
return pageData.every((row) => this.selectedRows().has(row));
|
|
139
268
|
}, ...(ngDevMode ? [{ debugName: "allSelectedOnPage" }] : []));
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
if (!isOpen) {
|
|
143
|
-
this.pendingFilters.set({ ...this.appliedFilters() });
|
|
144
|
-
}
|
|
145
|
-
this.isFilterPanelOpen.set(!isOpen);
|
|
146
|
-
}
|
|
147
|
-
updatePendingFilter(key, value) {
|
|
148
|
-
if (value === 'true')
|
|
149
|
-
value = true;
|
|
150
|
-
if (value === 'false')
|
|
151
|
-
value = false;
|
|
152
|
-
this.pendingFilters.update((current) => ({ ...current, [key]: value }));
|
|
153
|
-
}
|
|
154
|
-
applyFilters() {
|
|
155
|
-
this.appliedFilters.set({ ...this.pendingFilters() });
|
|
269
|
+
onFilterApplied(filters) {
|
|
270
|
+
this.filters.set(filters);
|
|
156
271
|
this.first.set(0);
|
|
157
272
|
this.currentPage.set(0);
|
|
158
|
-
this.
|
|
273
|
+
if (this.lazy()) {
|
|
274
|
+
this.emitLazyLoad({});
|
|
275
|
+
}
|
|
159
276
|
}
|
|
160
|
-
|
|
161
|
-
this.
|
|
162
|
-
this.appliedFilters.set({});
|
|
277
|
+
onFilterReset() {
|
|
278
|
+
this.filters.set({});
|
|
163
279
|
this.first.set(0);
|
|
164
280
|
this.currentPage.set(0);
|
|
165
|
-
this.
|
|
281
|
+
if (this.lazy()) {
|
|
282
|
+
this.emitLazyLoad({});
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
matchesFilter(item, key, filterValue) {
|
|
286
|
+
if (filterValue === null ||
|
|
287
|
+
filterValue === undefined ||
|
|
288
|
+
filterValue === '') {
|
|
289
|
+
return true;
|
|
290
|
+
}
|
|
291
|
+
const itemValue = this.getProperty(item, key);
|
|
292
|
+
// Date range filter
|
|
293
|
+
if (typeof filterValue === 'object' &&
|
|
294
|
+
(filterValue.from || filterValue.to)) {
|
|
295
|
+
const itemDate = itemValue instanceof Date ? itemValue : new Date(itemValue);
|
|
296
|
+
if (isNaN(itemDate.getTime()))
|
|
297
|
+
return true;
|
|
298
|
+
if (filterValue.from && itemDate < new Date(filterValue.from)) {
|
|
299
|
+
return false;
|
|
300
|
+
}
|
|
301
|
+
if (filterValue.to && itemDate > new Date(filterValue.to)) {
|
|
302
|
+
return false;
|
|
303
|
+
}
|
|
304
|
+
return true;
|
|
305
|
+
}
|
|
306
|
+
// Boolean filter
|
|
307
|
+
if (typeof filterValue === 'boolean') {
|
|
308
|
+
return itemValue === filterValue;
|
|
309
|
+
}
|
|
310
|
+
// Text filter
|
|
311
|
+
if (typeof itemValue === 'string') {
|
|
312
|
+
return itemValue
|
|
313
|
+
.toLowerCase()
|
|
314
|
+
.includes(String(filterValue).toLowerCase());
|
|
315
|
+
}
|
|
316
|
+
return itemValue === filterValue;
|
|
166
317
|
}
|
|
167
318
|
toggleRow(row) {
|
|
168
319
|
const newSet = new Set(this.selectedRows());
|
|
@@ -238,7 +389,10 @@ class Table {
|
|
|
238
389
|
this.columnReorder.emit(event);
|
|
239
390
|
}
|
|
240
391
|
onRowReorder(event) {
|
|
241
|
-
this.rowReorder.emit(
|
|
392
|
+
this.rowReorder.emit({
|
|
393
|
+
...event,
|
|
394
|
+
value: event.value ?? this.data(),
|
|
395
|
+
});
|
|
242
396
|
}
|
|
243
397
|
updatePagingFromEvent(event) {
|
|
244
398
|
const first = event?.first ?? this.first();
|
|
@@ -256,8 +410,19 @@ class Table {
|
|
|
256
410
|
pageSize: this.pageSize(),
|
|
257
411
|
currentPage: this.currentPage() + 1,
|
|
258
412
|
first: this.first(),
|
|
413
|
+
filters: this.filters(),
|
|
259
414
|
});
|
|
260
415
|
}
|
|
416
|
+
exportCSV() {
|
|
417
|
+
const table = this.tableRef();
|
|
418
|
+
if (table) {
|
|
419
|
+
// Temporarily set columns with field property for PrimeNG export
|
|
420
|
+
const originalColumns = table.columns;
|
|
421
|
+
table.columns = this.exportColumns();
|
|
422
|
+
table.exportCSV();
|
|
423
|
+
table.columns = originalColumns;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
261
426
|
rowAction(event, action, row) {
|
|
262
427
|
if (!action.confirmation) {
|
|
263
428
|
action.action(row);
|
|
@@ -284,7 +449,7 @@ class Table {
|
|
|
284
449
|
}
|
|
285
450
|
}
|
|
286
451
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: Table, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
287
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.3", type: Table, isStandalone: true, selector: "mt-table", inputs: { 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 }, generalSearch: { classPropertyName: "generalSearch", publicName: "generalSearch", 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 }, 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 }, 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", 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 }], 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 (change)=\"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-button\r\n variant=\"outline\"\r\n (click)=\"toggleFilterPanel()\"\r\n [label]=\"'components.table.filter' | transloco\"\r\n [badge]=\"activeFilterCount()\"\r\n icon=\"general.filter-funnel-01\"\r\n >\r\n </mt-button>\r\n @if (isFilterPanelOpen()) {\r\n <div\r\n class=\"absolute top-full end-0 z-10 mt-2 w-72 origin-top-right rounded-md bg-content shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none\"\r\n role=\"menu\"\r\n >\r\n <div class=\"p-4\">\r\n <h3 class=\"text-base font-semibold\">\r\n {{ \"components.table.filterOptions\" | transloco }}\r\n </h3>\r\n </div>\r\n <div\r\n class=\"border-t border-surface-300 dark:border-surface-500 p-4 space-y-4\"\r\n >\r\n @for (\r\n col of filterableColumns();\r\n track col.key || col.label || $index\r\n ) {\r\n <div class=\"space-y-1\">\r\n <label class=\"block text-sm font-medium\">\r\n {{ col.filterConfig?.label }}\r\n </label>\r\n @switch (col.filterConfig?.type) {\r\n @case (\"text\") {\r\n <mt-text-field\r\n [(ngModel)]=\"pendingFilters()[col.key]\"\r\n (ngModelChange)=\"\r\n updatePendingFilter(col.key, $event)\r\n \"\r\n ></mt-text-field>\r\n }\r\n @case (\"select\") {\r\n <mt-select-field\r\n [(ngModel)]=\"pendingFilters()[col.key]\"\r\n (ngModelChange)=\"\r\n updatePendingFilter(col.key, $event)\r\n \"\r\n [options]=\"col.filterConfig?.options\"\r\n [hasPlaceholderPrefix]=\"false\"\r\n [placeholder]=\"\r\n ('components.table.select' | transloco) +\r\n ' ' +\r\n col.filterConfig?.label\r\n \"\r\n showClear\r\n ></mt-select-field>\r\n }\r\n }\r\n </div>\r\n }\r\n </div>\r\n <div\r\n class=\"flex items-center justify-end space-x-2 border-t border-surface-300 dark:border-surface-500 bg-surface-50 dark:bg-surface-950 p-4 rounded-b-md\"\r\n >\r\n <mt-button\r\n variant=\"outlined\"\r\n (click)=\"resetFilters()\"\r\n [label]=\"'components.table.reset' | transloco\"\r\n />\r\n <mt-button\r\n (click)=\"applyFilters()\"\r\n [label]=\"'components.table.apply' | transloco\"\r\n />\r\n </div>\r\n </div>\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 [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 (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 </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 >\r\n {{ col.label }}\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 Actions\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=\"hover:bg-gray-50 dark:hover:bg-surface-950 border-surface-300 dark:border-surface-500\"\r\n [pReorderableRow]=\"index\"\r\n >\r\n @if (reorderableRows()) {\r\n <td class=\"w-10 text-center\">\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 class=\"text-gray-700 dark:text-gray-100\">\r\n @switch (col.type) {\r\n @case (\"boolean\") {\r\n <mt-toggle-field\r\n [(ngModel)]=\"row[col.key]\"\r\n (ngModelChange)=\"\r\n onCellChange(row, col.key, $event, 'boolean')\r\n \"\r\n ></mt-toggle-field>\r\n }\r\n @case (\"date\") {\r\n {{ getProperty(row, col.key) | date: \"mediumDate\" }}\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 <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 </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: [""], dependencies: [{ kind: "ngmodule", type: TableModule }, { kind: "component", type: i1.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.ReorderableColumn, selector: "[pReorderableColumn]", inputs: ["pReorderableColumnDisabled"] }, { kind: "directive", type: i1.ReorderableRowHandle, selector: "[pReorderableRowHandle]" }, { kind: "directive", type: i1.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"], outputs: ["onChange"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.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: SelectField, selector: "mt-select-field", inputs: ["field", "label", "placeholder", "hasPlaceholderPrefix", "class", "readonly", "pInputs", "options", "optionValue", "optionLabel", "filter", "filterBy", "dataKey", "showClear", "clearAfterSelect", "required", "group", "optionGroupLabel", "optionGroupChildren", "loading"], outputs: ["onChange"] }, { 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.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: Icon, selector: "mt-icon", inputs: ["icon"] }, { kind: "pipe", type: DatePipe, name: "date" }, { kind: "pipe", type: i5.TranslocoPipe, name: "transloco" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
452
|
+
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 }, generalSearch: { classPropertyName: "generalSearch", publicName: "generalSearch", 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 }, 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 }, 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", 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 (change)=\"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=\"general.share-05\"\r\n [label]=\"'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 </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 >\r\n {{ col.label }}\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 Actions\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=\"hover:bg-gray-50 dark:hover:bg-surface-950 border-surface-300 dark:border-surface-500\"\r\n [pReorderableRow]=\"index\"\r\n >\r\n @if (reorderableRows()) {\r\n <td class=\"w-10 text-center\">\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 class=\"text-gray-700 dark:text-gray-100\">\r\n @switch (col.type) {\r\n @case (\"boolean\") {\r\n <mt-toggle-field\r\n [(ngModel)]=\"row[col.key]\"\r\n (ngModelChange)=\"\r\n onCellChange(row, col.key, $event, 'boolean')\r\n \"\r\n ></mt-toggle-field>\r\n }\r\n @case (\"date\") {\r\n {{ getProperty(row, col.key) | date: \"mediumDate\" }}\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 <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 </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: [""], 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"], 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: Icon, selector: "mt-icon", inputs: ["icon"] }, { kind: "component", type: TableFilter, selector: "mt-table-filter", inputs: ["columns", "data"], outputs: ["filterApplied", "filterReset"] }, { kind: "pipe", type: DatePipe, name: "date" }, { kind: "pipe", type: i3.TranslocoPipe, name: "transloco" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
288
453
|
}
|
|
289
454
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: Table, decorators: [{
|
|
290
455
|
type: Component,
|
|
@@ -304,12 +469,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.3", ngImpor
|
|
|
304
469
|
ProgressBarModule,
|
|
305
470
|
TranslocoModule,
|
|
306
471
|
Icon,
|
|
307
|
-
], 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 (change)=\"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-button\r\n variant=\"outline\"\r\n (click)=\"toggleFilterPanel()\"\r\n [label]=\"'components.table.filter' | transloco\"\r\n [badge]=\"activeFilterCount()\"\r\n icon=\"general.filter-funnel-01\"\r\n >\r\n </mt-button>\r\n @if (isFilterPanelOpen()) {\r\n <div\r\n class=\"absolute top-full end-0 z-10 mt-2 w-72 origin-top-right rounded-md bg-content shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none\"\r\n role=\"menu\"\r\n >\r\n <div class=\"p-4\">\r\n <h3 class=\"text-base font-semibold\">\r\n {{ \"components.table.filterOptions\" | transloco }}\r\n </h3>\r\n </div>\r\n <div\r\n class=\"border-t border-surface-300 dark:border-surface-500 p-4 space-y-4\"\r\n >\r\n @for (\r\n col of filterableColumns();\r\n track col.key || col.label || $index\r\n ) {\r\n <div class=\"space-y-1\">\r\n <label class=\"block text-sm font-medium\">\r\n {{ col.filterConfig?.label }}\r\n </label>\r\n @switch (col.filterConfig?.type) {\r\n @case (\"text\") {\r\n <mt-text-field\r\n [(ngModel)]=\"pendingFilters()[col.key]\"\r\n (ngModelChange)=\"\r\n updatePendingFilter(col.key, $event)\r\n \"\r\n ></mt-text-field>\r\n }\r\n @case (\"select\") {\r\n <mt-select-field\r\n [(ngModel)]=\"pendingFilters()[col.key]\"\r\n (ngModelChange)=\"\r\n updatePendingFilter(col.key, $event)\r\n \"\r\n [options]=\"col.filterConfig?.options\"\r\n [hasPlaceholderPrefix]=\"false\"\r\n [placeholder]=\"\r\n ('components.table.select' | transloco) +\r\n ' ' +\r\n col.filterConfig?.label\r\n \"\r\n showClear\r\n ></mt-select-field>\r\n }\r\n }\r\n </div>\r\n }\r\n </div>\r\n <div\r\n class=\"flex items-center justify-end space-x-2 border-t border-surface-300 dark:border-surface-500 bg-surface-50 dark:bg-surface-950 p-4 rounded-b-md\"\r\n >\r\n <mt-button\r\n variant=\"outlined\"\r\n (click)=\"resetFilters()\"\r\n [label]=\"'components.table.reset' | transloco\"\r\n />\r\n <mt-button\r\n (click)=\"applyFilters()\"\r\n [label]=\"'components.table.apply' | transloco\"\r\n />\r\n </div>\r\n </div>\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 [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 (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 </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 >\r\n {{ col.label }}\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 Actions\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=\"hover:bg-gray-50 dark:hover:bg-surface-950 border-surface-300 dark:border-surface-500\"\r\n [pReorderableRow]=\"index\"\r\n >\r\n @if (reorderableRows()) {\r\n <td class=\"w-10 text-center\">\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 class=\"text-gray-700 dark:text-gray-100\">\r\n @switch (col.type) {\r\n @case (\"boolean\") {\r\n <mt-toggle-field\r\n [(ngModel)]=\"row[col.key]\"\r\n (ngModelChange)=\"\r\n onCellChange(row, col.key, $event, 'boolean')\r\n \"\r\n ></mt-toggle-field>\r\n }\r\n @case (\"date\") {\r\n {{ getProperty(row, col.key) | date: \"mediumDate\" }}\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 <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 </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" }]
|
|
308
|
-
}], 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"] }], 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 }] }], generalSearch: [{ type: i0.Input, args: [{ isSignal: true, alias: "generalSearch", 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 }] }], 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 }] }], 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 }] }], 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"] }] } });
|
|
472
|
+
TableFilter,
|
|
473
|
+
], 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 (change)=\"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=\"general.share-05\"\r\n [label]=\"'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 </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 >\r\n {{ col.label }}\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 Actions\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=\"hover:bg-gray-50 dark:hover:bg-surface-950 border-surface-300 dark:border-surface-500\"\r\n [pReorderableRow]=\"index\"\r\n >\r\n @if (reorderableRows()) {\r\n <td class=\"w-10 text-center\">\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 class=\"text-gray-700 dark:text-gray-100\">\r\n @switch (col.type) {\r\n @case (\"boolean\") {\r\n <mt-toggle-field\r\n [(ngModel)]=\"row[col.key]\"\r\n (ngModelChange)=\"\r\n onCellChange(row, col.key, $event, 'boolean')\r\n \"\r\n ></mt-toggle-field>\r\n }\r\n @case (\"date\") {\r\n {{ getProperty(row, col.key) | date: \"mediumDate\" }}\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 <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 </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" }]
|
|
474
|
+
}], 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"] }], 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 }] }], generalSearch: [{ type: i0.Input, args: [{ isSignal: true, alias: "generalSearch", 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 }] }], 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 }] }], 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"] }] } });
|
|
309
475
|
|
|
310
476
|
/**
|
|
311
477
|
* Generated bundle index. Do not edit.
|
|
312
478
|
*/
|
|
313
479
|
|
|
314
|
-
export { Table };
|
|
480
|
+
export { Table, TableFilter };
|
|
315
481
|
//# sourceMappingURL=masterteam-components-table.mjs.map
|