@sd-angular/core 1.3.146 → 1.3.147

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 (132) hide show
  1. package/bundles/sd-angular-core-table.umd.js +4004 -0
  2. package/bundles/sd-angular-core-table.umd.js.map +1 -0
  3. package/bundles/sd-angular-core-table.umd.min.js +2 -0
  4. package/bundles/sd-angular-core-table.umd.min.js.map +1 -0
  5. package/bundles/sd-angular-core.umd.js +6 -4
  6. package/bundles/sd-angular-core.umd.js.map +1 -1
  7. package/bundles/sd-angular-core.umd.min.js +1 -1
  8. package/bundles/sd-angular-core.umd.min.js.map +1 -1
  9. package/esm2015/lib/core.module.js +4 -1
  10. package/esm2015/public-api.js +2 -1
  11. package/esm2015/table/index.js +2 -0
  12. package/esm2015/table/sd-angular-core-table.js +40 -0
  13. package/esm2015/table/src/lib/components/column-inline-filter/column-inline-filter.component.js +74 -0
  14. package/esm2015/table/src/lib/components/desktop-cell/desktop-cell.component.js +25 -0
  15. package/esm2015/table/src/lib/components/desktop-cell-view/desktop-cell-view.component.js +21 -0
  16. package/esm2015/table/src/lib/components/desktop-command/desktop-command.component.js +20 -0
  17. package/esm2015/table/src/lib/components/grid-filter/grid-filter.component.js +99 -0
  18. package/esm2015/table/src/lib/components/popup-filter/popup-filter.component.js +79 -0
  19. package/esm2015/table/src/lib/components/popup-grid-configuration/popup-grid-configuration.component.js +96 -0
  20. package/esm2015/table/src/lib/components/quick-action/quick-action.component.js +24 -0
  21. package/esm2015/table/src/lib/directives/sd-material-cell-def.directive.js +18 -0
  22. package/esm2015/table/src/lib/directives/sd-material-empty-data-def.directive.js +15 -0
  23. package/esm2015/table/src/lib/directives/sd-material-filter-def.directive.js +22 -0
  24. package/esm2015/table/src/lib/directives/sd-material-footer-def.directive.js +18 -0
  25. package/esm2015/table/src/lib/directives/sd-material-sub-information-def.directive.js +15 -0
  26. package/esm2015/table/src/lib/models/grid-cell.model.js +2 -0
  27. package/esm2015/table/src/lib/models/index.js +4 -0
  28. package/esm2015/table/src/lib/models/table-column.model.js +39 -0
  29. package/esm2015/table/src/lib/models/table-command.model.js +2 -0
  30. package/esm2015/table/src/lib/models/table-configuration.model.js +9 -0
  31. package/esm2015/table/src/lib/models/table-item.model.js +15 -0
  32. package/esm2015/table/src/lib/models/table-option-config.model.js +2 -0
  33. package/esm2015/table/src/lib/models/table-option-expand.model.js +2 -0
  34. package/esm2015/table/src/lib/models/table-option-export.model.js +2 -0
  35. package/esm2015/table/src/lib/models/table-option-group.model.js +2 -0
  36. package/esm2015/table/src/lib/models/table-option-paginate.model.js +2 -0
  37. package/esm2015/table/src/lib/models/table-option-reload.model.js +2 -0
  38. package/esm2015/table/src/lib/models/table-option-selector.model.js +2 -0
  39. package/esm2015/table/src/lib/models/table-option-sort.model.js +2 -0
  40. package/esm2015/table/src/lib/models/table-option-style.model.js +2 -0
  41. package/esm2015/table/src/lib/models/table-option.model.js +2 -0
  42. package/esm2015/table/src/lib/pipes/cell-view.pipe.js +180 -0
  43. package/esm2015/table/src/lib/pipes/column-badge.pipe.js +43 -0
  44. package/esm2015/table/src/lib/pipes/column-children-filter.pipe.js +31 -0
  45. package/esm2015/table/src/lib/pipes/column-html-template.pipe.js +23 -0
  46. package/esm2015/table/src/lib/pipes/column-tooltip.pipe.js +17 -0
  47. package/esm2015/table/src/lib/pipes/column-transform.pipe.js +35 -0
  48. package/esm2015/table/src/lib/pipes/column-values.pipe.js +63 -0
  49. package/esm2015/table/src/lib/pipes/command-disable.pipe.js +18 -0
  50. package/esm2015/table/src/lib/pipes/command-filter.pipe.js +79 -0
  51. package/esm2015/table/src/lib/pipes/command-icon.pipe.js +18 -0
  52. package/esm2015/table/src/lib/pipes/command-title.pipe.js +18 -0
  53. package/esm2015/table/src/lib/pipes/filter-column.pipe.js +30 -0
  54. package/esm2015/table/src/lib/pipes/filter-external.pipe.js +19 -0
  55. package/esm2015/table/src/lib/pipes/grid-configuration-result.pipe.js +21 -0
  56. package/esm2015/table/src/lib/pipes/sd-group.pipe.js +45 -0
  57. package/esm2015/table/src/lib/pipes/selection-action-filter.pipe.js +72 -0
  58. package/esm2015/table/src/lib/pipes/selection-disable.pipe.js +55 -0
  59. package/esm2015/table/src/lib/pipes/selection-visible-select-all.pipe.js +34 -0
  60. package/esm2015/table/src/lib/pipes/selection-visible.pipe.js +82 -0
  61. package/esm2015/table/src/lib/services/table-configuration.service.js +292 -0
  62. package/esm2015/table/src/lib/services/table-filter/table-filter.model.js +3 -0
  63. package/esm2015/table/src/lib/services/table-filter/table-filter.service.js +229 -0
  64. package/esm2015/table/src/lib/table.component.js +816 -0
  65. package/esm2015/table/src/lib/table.module.js +175 -0
  66. package/esm2015/table/src/public-api.js +5 -0
  67. package/fesm2015/sd-angular-core-table.js +2865 -0
  68. package/fesm2015/sd-angular-core-table.js.map +1 -0
  69. package/fesm2015/sd-angular-core.js +3 -0
  70. package/fesm2015/sd-angular-core.js.map +1 -1
  71. package/package.json +1 -1
  72. package/public-api.d.ts +1 -0
  73. package/{sd-angular-core-1.3.146.tgz → sd-angular-core-1.3.147.tgz} +0 -0
  74. package/sd-angular-core.metadata.json +1 -1
  75. package/table/index.d.ts +1 -0
  76. package/table/package.json +12 -0
  77. package/table/sd-angular-core-table.d.ts +39 -0
  78. package/table/sd-angular-core-table.metadata.json +1 -0
  79. package/table/src/lib/components/column-inline-filter/column-inline-filter.component.d.ts +22 -0
  80. package/table/src/lib/components/desktop-cell/desktop-cell.component.d.ts +17 -0
  81. package/table/src/lib/components/desktop-cell-view/desktop-cell-view.component.d.ts +11 -0
  82. package/table/src/lib/components/desktop-command/desktop-command.component.d.ts +7 -0
  83. package/table/src/lib/components/grid-filter/grid-filter.component.d.ts +35 -0
  84. package/table/src/lib/components/popup-filter/popup-filter.component.d.ts +27 -0
  85. package/table/src/lib/components/popup-grid-configuration/popup-grid-configuration.component.d.ts +39 -0
  86. package/table/src/lib/components/quick-action/quick-action.component.d.ts +9 -0
  87. package/table/src/lib/directives/sd-material-cell-def.directive.d.ts +6 -0
  88. package/table/src/lib/directives/sd-material-empty-data-def.directive.d.ts +5 -0
  89. package/table/src/lib/directives/sd-material-filter-def.directive.d.ts +8 -0
  90. package/table/src/lib/directives/sd-material-footer-def.directive.d.ts +6 -0
  91. package/table/src/lib/directives/sd-material-sub-information-def.directive.d.ts +5 -0
  92. package/table/src/lib/models/grid-cell.model.d.ts +16 -0
  93. package/table/src/lib/models/index.d.ts +3 -0
  94. package/table/src/lib/models/table-column.model.d.ts +124 -0
  95. package/table/src/lib/models/table-command.model.d.ts +19 -0
  96. package/table/src/lib/models/table-configuration.model.d.ts +13 -0
  97. package/table/src/lib/models/table-item.model.d.ts +25 -0
  98. package/table/src/lib/models/table-option-config.model.d.ts +62 -0
  99. package/table/src/lib/models/table-option-expand.model.d.ts +6 -0
  100. package/table/src/lib/models/table-option-export.model.d.ts +31 -0
  101. package/table/src/lib/models/table-option-group.model.d.ts +4 -0
  102. package/table/src/lib/models/table-option-paginate.model.d.ts +6 -0
  103. package/table/src/lib/models/table-option-reload.model.d.ts +5 -0
  104. package/table/src/lib/models/table-option-selector.model.d.ts +32 -0
  105. package/table/src/lib/models/table-option-sort.model.d.ts +3 -0
  106. package/table/src/lib/models/table-option-style.model.d.ts +6 -0
  107. package/table/src/lib/models/table-option.model.d.ts +44 -0
  108. package/table/src/lib/pipes/cell-view.pipe.d.ts +15 -0
  109. package/table/src/lib/pipes/column-badge.pipe.d.ts +11 -0
  110. package/table/src/lib/pipes/column-children-filter.pipe.d.ts +8 -0
  111. package/table/src/lib/pipes/column-html-template.pipe.d.ts +8 -0
  112. package/table/src/lib/pipes/column-tooltip.pipe.d.ts +6 -0
  113. package/table/src/lib/pipes/column-transform.pipe.d.ts +8 -0
  114. package/table/src/lib/pipes/column-values.pipe.d.ts +6 -0
  115. package/table/src/lib/pipes/command-disable.pipe.d.ts +5 -0
  116. package/table/src/lib/pipes/command-filter.pipe.d.ts +6 -0
  117. package/table/src/lib/pipes/command-icon.pipe.d.ts +5 -0
  118. package/table/src/lib/pipes/command-title.pipe.d.ts +5 -0
  119. package/table/src/lib/pipes/filter-column.pipe.d.ts +5 -0
  120. package/table/src/lib/pipes/filter-external.pipe.d.ts +5 -0
  121. package/table/src/lib/pipes/grid-configuration-result.pipe.d.ts +10 -0
  122. package/table/src/lib/pipes/sd-group.pipe.d.ts +6 -0
  123. package/table/src/lib/pipes/selection-action-filter.pipe.d.ts +7 -0
  124. package/table/src/lib/pipes/selection-disable.pipe.d.ts +6 -0
  125. package/table/src/lib/pipes/selection-visible-select-all.pipe.d.ts +6 -0
  126. package/table/src/lib/pipes/selection-visible.pipe.d.ts +6 -0
  127. package/table/src/lib/services/table-configuration.service.d.ts +13 -0
  128. package/table/src/lib/services/table-filter/table-filter.model.d.ts +117 -0
  129. package/table/src/lib/services/table-filter/table-filter.service.d.ts +15 -0
  130. package/table/src/lib/table.component.d.ts +87 -0
  131. package/table/src/lib/table.module.d.ts +11 -0
  132. package/table/src/public-api.d.ts +5 -0
@@ -0,0 +1,2865 @@
1
+ import { SdScrollDirective, SdCommonModule } from '@sd-angular/core/common';
2
+ import { InjectionToken, Directive, TemplateRef, Input, Component, ChangeDetectionStrategy, ChangeDetectorRef, ViewChild, Injectable, Inject, Optional, Pipe, QueryList, ContentChild, ContentChildren, EventEmitter, HostListener, Output, NgModule } from '@angular/core';
3
+ import { CommonModule, DatePipe, DecimalPipe } from '@angular/common';
4
+ import { FormsModule, ReactiveFormsModule } from '@angular/forms';
5
+ import { MatFormFieldModule } from '@angular/material/form-field';
6
+ import { MatIconModule } from '@angular/material/icon';
7
+ import { MatInputModule } from '@angular/material/input';
8
+ import { __classPrivateFieldGet, __classPrivateFieldSet, __awaiter, __rest } from 'tslib';
9
+ import { MatPaginator, MatPaginatorIntl, MatPaginatorModule } from '@angular/material/paginator';
10
+ import { MatSort, MatSortModule } from '@angular/material/sort';
11
+ import { trigger, state, style, transition, animate } from '@angular/animations';
12
+ import { v4 } from 'uuid';
13
+ import { BehaviorSubject, Subscription, Subject, isObservable, combineLatest } from 'rxjs';
14
+ import { SdNotifyService } from '@sd-angular/core/notify';
15
+ import { startWith, map, debounceTime, switchMap } from 'rxjs/operators';
16
+ import { SdModal } from '@sd-angular/core/modal';
17
+ import { DeviceDetectorService } from 'ngx-device-detector';
18
+ import { SdExportService } from '@sd-angular/core/export';
19
+ import * as hash from 'object-hash';
20
+ import hash__default from 'object-hash';
21
+ import { SdSettingService } from '@sd-angular/core/setting';
22
+ import { SdQuickAction } from '@sd-angular/core/quick-action';
23
+ import { MatTableModule } from '@angular/material/table';
24
+ import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
25
+ import { CdkTableModule, CdkColumnDef } from '@angular/cdk/table';
26
+ import { ScrollingModule } from '@angular/cdk/scrolling';
27
+ import { moveItemInArray, DragDropModule } from '@angular/cdk/drag-drop';
28
+ import { MatMenuModule } from '@angular/material/menu';
29
+ import { MatSliderModule } from '@angular/material/slider';
30
+ import { MatButtonModule } from '@angular/material/button';
31
+ import { SdServiceModule } from '@sd-angular/core/service';
32
+ import { MatTooltipModule } from '@angular/material/tooltip';
33
+ import { MatChipsModule } from '@angular/material/chips';
34
+ import { MatRadioModule } from '@angular/material/radio';
35
+ import { MatSlideToggleModule } from '@angular/material/slide-toggle';
36
+ import { SdFormModule } from '@sd-angular/core/form';
37
+ import { MatCheckboxModule } from '@angular/material/checkbox';
38
+ import { SdTranslateService } from '@sd-angular/core/translate';
39
+ import { MatListModule } from '@angular/material/list';
40
+ import { MatDividerModule } from '@angular/material/divider';
41
+ import { SdUtilityService } from '@sd-angular/core/utility';
42
+ import { SdGroupModule } from '@sd-angular/core/group';
43
+
44
+ const DEFAULT_TABLE_CONFIG = {
45
+ paginate: {
46
+ pageSize: 50,
47
+ pages: [50, 100, 200]
48
+ }
49
+ };
50
+ const TABLE_CONFIG = new InjectionToken('sd-table.configuration');
51
+
52
+ class SdMaterialCellDefDirective {
53
+ constructor(templateRef) {
54
+ this.templateRef = templateRef;
55
+ }
56
+ }
57
+ SdMaterialCellDefDirective.decorators = [
58
+ { type: Directive, args: [{
59
+ selector: '[sdMaterialCellDef]'
60
+ },] }
61
+ ];
62
+ SdMaterialCellDefDirective.ctorParameters = () => [
63
+ { type: TemplateRef }
64
+ ];
65
+ SdMaterialCellDefDirective.propDecorators = {
66
+ sdMaterialCellDef: [{ type: Input }]
67
+ };
68
+
69
+ var _filterRegister;
70
+ class SdPopupFilter {
71
+ constructor(cdRef) {
72
+ this.cdRef = cdRef;
73
+ _filterRegister.set(this, void 0);
74
+ this.externalFilters = [];
75
+ this.externalFilter = {};
76
+ this.inlineExternal = {};
77
+ this.columns = [];
78
+ this.columnFilter = {};
79
+ this.inlineColumn = {};
80
+ this.filterDefs = [];
81
+ this.filterDef = {};
82
+ this.inlineFilterDef = {};
83
+ this.open = () => {
84
+ const configuration = __classPrivateFieldGet(this, _filterRegister).configuration.get();
85
+ this.inlineColumn = JSON.parse(JSON.stringify(configuration.inlineColumn));
86
+ this.inlineExternal = JSON.parse(JSON.stringify(configuration.inlineExternal));
87
+ this.inlineFilterDef = JSON.parse(JSON.stringify(configuration.inlineFilterDef));
88
+ const filterValue = __classPrivateFieldGet(this, _filterRegister).value.get();
89
+ this.columnFilter = JSON.parse(JSON.stringify(filterValue.columnFilter));
90
+ this.externalFilter = JSON.parse(JSON.stringify(filterValue.externalFilter));
91
+ this.filterDef = JSON.parse(JSON.stringify(filterValue.filterDef));
92
+ this.modal.open();
93
+ this.cdRef.markForCheck();
94
+ };
95
+ this.close = () => {
96
+ this.modal.close();
97
+ this.cdRef.markForCheck();
98
+ };
99
+ this.onApply = () => {
100
+ __classPrivateFieldGet(this, _filterRegister).configuration.set({
101
+ inlineColumn: this.inlineColumn,
102
+ inlineExternal: this.inlineExternal,
103
+ inlineFilterDef: this.inlineFilterDef,
104
+ });
105
+ __classPrivateFieldGet(this, _filterRegister).value.set({
106
+ columnFilter: this.columnFilter,
107
+ externalFilter: this.externalFilter,
108
+ filterDef: this.filterDef,
109
+ });
110
+ this.modal.close();
111
+ this.cdRef.markForCheck();
112
+ };
113
+ }
114
+ set filterRegister(value) {
115
+ __classPrivateFieldSet(this, _filterRegister, value);
116
+ }
117
+ ngAfterViewInit() { }
118
+ ngOnDestroy() { }
119
+ onClear() {
120
+ __classPrivateFieldGet(this, _filterRegister).value.remove();
121
+ this.modal.close();
122
+ this.cdRef.markForCheck();
123
+ }
124
+ }
125
+ _filterRegister = new WeakMap();
126
+ SdPopupFilter.decorators = [
127
+ { type: Component, args: [{
128
+ selector: 'sd-popup-filter',
129
+ template: "<sd-modal width=\"500px\" [title]=\"'Filter' | sdTranslate\">\r\n <sd-modal-body class=\"c-popup-filter\">\r\n <ng-container *ngFor=\"let column of columns | sdFilterColumn\">\r\n <div class=\"d-flex align-items-baseline\">\r\n <ng-container>\r\n <div *sdDesktop class=\"c-checkable\">\r\n <mat-slide-toggle [(ngModel)]=\"inlineColumn[column.field]\" color=\"primary\"></mat-slide-toggle>\r\n </div>\r\n </ng-container>\r\n <div class=\"c-filterable\">\r\n <sd-input\r\n *ngIf=\"column.type === 'string'\"\r\n [label]=\"column.title\"\r\n type=\"text\"\r\n [(model)]=\"columnFilter[column.field]\"\r\n appearance=\"outline\">\r\n </sd-input>\r\n <sd-input\r\n *ngIf=\"column.type === 'number'\"\r\n [label]=\"column.title\"\r\n type=\" number\"\r\n [(model)]=\"columnFilter[column.field]\"\r\n appearance=\"outline\">\r\n </sd-input>\r\n <sd-select\r\n *ngIf=\"column.type === 'bool'\"\r\n [label]=\"column.title\"\r\n [items]=\"[\r\n { value: '1', display: column.trueValue || 'True' },\r\n { value: '0', display: column.falseValue || 'False' }\r\n ]\"\r\n valueField=\"value\"\r\n displayField=\"display\"\r\n [(model)]=\"columnFilter[column.field]\"\r\n appearance=\"outline\">\r\n </sd-select>\r\n <sd-select\r\n *ngIf=\"column.type === 'values' && !column?.editor?.autocomplete\"\r\n [label]=\"column.title\"\r\n [items]=\"column.option.items\"\r\n [valueField]=\"column.option.valueField\"\r\n [displayField]=\"column.option.displayField\"\r\n [(model)]=\"columnFilter[column.field]\"\r\n appearance=\"outline\">\r\n </sd-select>\r\n <sd-autocomplete\r\n *ngIf=\"column.type === 'values' && column?.editor?.autocomplete\"\r\n [label]=\"column.title\"\r\n [items]=\"column.option.items\"\r\n [valueField]=\"column.option.valueField\"\r\n [displayField]=\"column.option.displayField\"\r\n [(model)]=\"columnFilter[column.field]\"\r\n appearance=\"outline\">\r\n </sd-autocomplete>\r\n <sd-date-time\r\n *ngIf=\"column.type === 'date' || column.type === 'datetime' || column.type === 'time'\"\r\n [label]=\"column.title\"\r\n [(model)]=\"columnFilter[column.field]\"\r\n type=\"date\"\r\n appearance=\"outline\">\r\n </sd-date-time>\r\n </div>\r\n </div>\r\n </ng-container>\r\n <ng-container *ngFor=\"let item of externalFilters | sdFilterExternal\">\r\n <div class=\"d-flex align-items-baseline\">\r\n <ng-container>\r\n <div *sdDesktop class=\"c-checkable\">\r\n <mat-slide-toggle [(ngModel)]=\"inlineExternal[item.field]\" color=\"primary\"></mat-slide-toggle>\r\n </div>\r\n </ng-container>\r\n <div class=\"c-filterable\">\r\n <sd-input\r\n [label]=\"item.title\"\r\n *ngIf=\"item.type === 'string'\"\r\n type=\"text\"\r\n [(model)]=\"externalFilter[item.field]\"\r\n appearance=\"outline\">\r\n </sd-input>\r\n <sd-input-number [label]=\"item.title\" *ngIf=\"item.type === 'number'\" [(model)]=\"externalFilter[item.field]\" appearance=\"outline\">\r\n </sd-input-number>\r\n <sd-select\r\n [label]=\"item.title\"\r\n *ngIf=\"item.type === 'bool'\"\r\n [items]=\"[\r\n { value: '1', display: item.option?.displayOnTrue || 'True' },\r\n { value: '0', display: item.option?.displayOnFalse || 'False' }\r\n ]\"\r\n valueField=\"value\"\r\n displayField=\"display\"\r\n [(model)]=\"externalFilter[item.field]\"\r\n appearance=\"outline\">\r\n </sd-select>\r\n <ng-container *ngIf=\"item.type === 'values'\">\r\n <sd-select\r\n *ngIf=\"item.option?.selection === 'MULTIPLE'\"\r\n [label]=\"item.title\"\r\n [items]=\"item.option.items\"\r\n [valueField]=\"item.option.valueField\"\r\n [displayField]=\"item.option.displayField\"\r\n [(model)]=\"externalFilter[item.field]\"\r\n appearance=\"outline\"\r\n multiple>\r\n </sd-select>\r\n <sd-autocomplete\r\n *ngIf=\"item.option?.selection === 'AUTOCOMPLETE'\"\r\n [label]=\"item.title\"\r\n [items]=\"item.option.items\"\r\n [valueField]=\"item.option.valueField\"\r\n [displayField]=\"item.option.displayField\"\r\n appearance=\"outline\"\r\n [(model)]=\"externalFilter[item.field]\">\r\n </sd-autocomplete>\r\n <sd-select\r\n *ngIf=\"item.option?.selection === 'MULTIPLEAUTOCOMPLETE'\"\r\n [label]=\"item.title\"\r\n [items]=\"item.option.items\"\r\n [valueField]=\"item.option.valueField\"\r\n [displayField]=\"item.option.displayField\"\r\n appearance=\"outline\"\r\n [(model)]=\"externalFilter[item.field]\"\r\n filtered=\"true\"\r\n multiple>\r\n </sd-select>\r\n <sd-select\r\n *ngIf=\"!item.option?.selection\"\r\n [label]=\"item.title\"\r\n [items]=\"item.values\"\r\n [items]=\"item.option.items\"\r\n [valueField]=\"item.option.valueField\"\r\n [displayField]=\"item.option.displayField\"\r\n appearance=\"outline\"\r\n [(model)]=\"externalFilter[item.field]\">\r\n </sd-select>\r\n </ng-container>\r\n <sd-date-time\r\n [label]=\"item.title\"\r\n *ngIf=\"item.type === 'date' || item.type === 'datetime'\"\r\n [(model)]=\"externalFilter[item.field]\"\r\n [type]=\"item.type\"\r\n appearance=\"outline\">\r\n </sd-date-time>\r\n <sd-date-range\r\n [label]=\"item.title\"\r\n *ngIf=\"item.type === 'daterange' && externalFilter[item.field]\"\r\n [(from)]=\"externalFilter[item.field].from\"\r\n [(to)]=\"externalFilter[item.field].to\"\r\n [min]=\"item.minDate\"\r\n [max]=\"item.maxDate\"\r\n appearance=\"outline\">\r\n </sd-date-range>\r\n </div>\r\n </div>\r\n </ng-container>\r\n <ng-container *ngFor=\"let filter of filterDefs\">\r\n <div class=\"d-flex align-items-baseline\">\r\n <ng-container>\r\n <div *sdDesktop class=\"c-checkable\">\r\n <mat-slide-toggle [(ngModel)]=\"inlineFilterDef[filter.sdMaterialFilterDef]\" color=\"primary\"> </mat-slide-toggle>\r\n </div>\r\n </ng-container>\r\n <div class=\"c-filterable\">\r\n <ng-container *ngTemplateOutlet=\"filter.templateRef; context: { filterDef: filterDef }\"> </ng-container>\r\n </div>\r\n </div>\r\n </ng-container>\r\n </sd-modal-body>\r\n <sd-modal-footer *sdDesktop>\r\n <sd-button class=\"mr-auto\" (action)=\"onClear()\" title=\"M\u1EB7c \u0111\u1ECBnh\" size=\"sm\" type=\"link\"> </sd-button>\r\n <sd-button (action)=\"onApply()\" title=\"\u0110\u1ED3ng \u00FD\" color=\"primary\" size=\"sm\" type=\"fill\"></sd-button>\r\n </sd-modal-footer>\r\n <sd-modal-footer *sdMobileTablet>\r\n <sd-button style=\"flex: 1; padding-right: 5px\" (action)=\"onClear()\" title=\"M\u1EB7c \u0111\u1ECBnh\" width=\"100%\" size=\"sm\" type=\"link\"></sd-button>\r\n <sd-button\r\n style=\"flex: 1; padding-left: 5px\"\r\n (action)=\"onApply()\"\r\n title=\"\u0110\u1ED3ng \u00FD\"\r\n color=\"primary\"\r\n width=\"100%\"\r\n size=\"sm\"\r\n type=\"fill\"></sd-button>\r\n </sd-modal-footer>\r\n</sd-modal>\r\n",
130
+ changeDetection: ChangeDetectionStrategy.OnPush,
131
+ styles: [".c-checkable{width:50px}.c-filterable{flex:1}::ng-deep sd-modal-body.c-popup-filter .mat-form-field-wrapper{padding-bottom:0}"]
132
+ },] }
133
+ ];
134
+ SdPopupFilter.ctorParameters = () => [
135
+ { type: ChangeDetectorRef }
136
+ ];
137
+ SdPopupFilter.propDecorators = {
138
+ modal: [{ type: ViewChild, args: [SdModal,] }],
139
+ filterRegister: [{ type: Input }],
140
+ externalFilters: [{ type: Input }],
141
+ columns: [{ type: Input }],
142
+ filterDefs: [{ type: Input }]
143
+ };
144
+
145
+ var _subscription;
146
+ class SdGridFilter {
147
+ constructor(ref, deviceService) {
148
+ this.ref = ref;
149
+ this.deviceService = deviceService;
150
+ this.columns = [];
151
+ this.externalFilters = [];
152
+ this.filterDefs = [];
153
+ this.filterRegisterChange = new BehaviorSubject(null);
154
+ this.filterDef = {};
155
+ this.inlineFilterDef = {};
156
+ this.columnFilter = {};
157
+ this.inlineColumn = {};
158
+ this.externalFilter = {};
159
+ this.inlineExternal = {};
160
+ _subscription.set(this, new Subscription());
161
+ this.onFilter = (item) => {
162
+ this.filterRegister.value.set({
163
+ columnFilter: this.columnFilter,
164
+ externalFilter: this.externalFilter,
165
+ filterDef: this.filterDef,
166
+ });
167
+ };
168
+ this.updateFilter = () => {
169
+ this.filterRegister.value.set({
170
+ columnFilter: this.columnFilter,
171
+ externalFilter: this.externalFilter,
172
+ filterDef: this.filterDef,
173
+ notReload: true
174
+ });
175
+ };
176
+ this.open = () => {
177
+ this.popupFilter.open();
178
+ };
179
+ this.isMobileOrTablet = !this.deviceService.isDesktop();
180
+ this.ref.markForCheck();
181
+ }
182
+ set _filter(filter) {
183
+ this.filter = filter;
184
+ }
185
+ set _externalFilters(value) {
186
+ this.externalFilters = value || [];
187
+ }
188
+ set _filterRegister(value) {
189
+ this.filterRegister = value;
190
+ this.filterRegisterChange.next(this.filterRegister);
191
+ }
192
+ ngAfterViewInit() {
193
+ __classPrivateFieldGet(this, _subscription).add(this.filterRegisterChange.pipe(startWith(this.filterRegister)).subscribe(filterRegister => {
194
+ if (this.filterRegister) {
195
+ __classPrivateFieldGet(this, _subscription).add(this.filterRegister.configuration.observer.subscribe(configuration => {
196
+ const { inlineColumn, inlineExternal, inlineFilterDef } = configuration;
197
+ this.inlineColumn = inlineColumn;
198
+ this.inlineExternal = inlineExternal;
199
+ this.inlineFilterDef = inlineFilterDef;
200
+ this.ref.markForCheck();
201
+ }));
202
+ __classPrivateFieldGet(this, _subscription).add(this.filterRegister.value.observer.subscribe(value => {
203
+ const { columnFilter, externalFilter, filterDef } = value;
204
+ this.columnFilter = columnFilter;
205
+ this.externalFilter = externalFilter;
206
+ this.filterDef = filterDef;
207
+ this.ref.markForCheck();
208
+ }));
209
+ }
210
+ }));
211
+ }
212
+ ngOnDestroy() {
213
+ __classPrivateFieldGet(this, _subscription).unsubscribe();
214
+ }
215
+ }
216
+ _subscription = new WeakMap();
217
+ SdGridFilter.decorators = [
218
+ { type: Component, args: [{
219
+ selector: 'sd-grid-filter',
220
+ template: "<ng-container *ngIf=\"!filter?.disabled\">\r\n <ng-container *ngIf=\"filter?.enableCollapse;else noCollapse\">\r\n <sd-group class=\"p-12\" [isExpanded]=\"false\" title=\"T\u00ECm ki\u1EBFm\" expandable>\r\n <div sdGroupBody>\r\n <ng-container *ngTemplateOutlet=\"noCollapse\"></ng-container>\r\n </div>\r\n </sd-group>\r\n </ng-container>\r\n <ng-template #noCollapse>\r\n <div\r\n *ngIf=\"!isMobileOrTablet && ((columns?.length && !filter?.inlineColumn) || externalFilters?.length || filterDefs?.length)\"\r\n class=\"row mx-0\">\r\n <ng-container *ngIf=\"filter?.sorts?.length\">\r\n <ng-container *ngFor=\"let field of filter?.sorts\">\r\n <ng-container *ngIf=\"columns?.length && !filter?.inlineColumn\">\r\n <ng-container *ngFor=\"let item of columns | sdFilterColumn:field\">\r\n <ng-container *ngTemplateOutlet=\"filterColumn; context: {item: item}\"></ng-container>\r\n </ng-container>\r\n </ng-container>\r\n <ng-container *ngIf=\"externalFilters?.length\">\r\n <ng-container *ngFor=\"let item of externalFilters | sdFilterExternal:field\">\r\n <ng-container *ngTemplateOutlet=\"filterExternal; context: {item: item}\"></ng-container>\r\n </ng-container>\r\n </ng-container>\r\n <ng-container *ngFor=\"let item of filterDefs\">\r\n <div *ngIf=\"inlineFilterDef[item.sdMaterialFilterDef] && item.sdMaterialFilterDef === field\"\r\n class=\"col-lg-2 col-md-3 col-sm-6 px-8\">\r\n <ng-container *ngTemplateOutlet=\"item.templateRef;context:{filterDef:filterDef, isInline: true}\">\r\n </ng-container>\r\n </div>\r\n </ng-container>\r\n </ng-container>\r\n </ng-container>\r\n <ng-container *ngIf=\"!filter?.sorts?.length\">\r\n <ng-container *ngIf=\"columns?.length && !filter?.inlineColumn\">\r\n <ng-container *ngFor=\"let item of columns | sdFilterColumn\">\r\n <ng-container *ngTemplateOutlet=\"filterColumn; context: {item: item}\"></ng-container>\r\n </ng-container>\r\n </ng-container>\r\n <ng-container *ngIf=\"externalFilters?.length\">\r\n <ng-container *ngFor=\"let item of externalFilters | sdFilterExternal\">\r\n <ng-container *ngTemplateOutlet=\"filterExternal; context: {item: item}\"></ng-container>\r\n </ng-container>\r\n </ng-container>\r\n <ng-container *ngFor=\"let item of filterDefs\">\r\n <div *ngIf=\"inlineFilterDef[item.sdMaterialFilterDef]\" class=\"col-lg-2 col-md-3 col-sm-6 px-8\">\r\n <ng-container *ngTemplateOutlet=\"item.templateRef;context:{filterDef:filterDef, isInline: true}\">\r\n </ng-container>\r\n </div>\r\n </ng-container>\r\n </ng-container>\r\n </div>\r\n <ng-template #filterColumn let-item=\"item\">\r\n <div *ngIf=\"inlineColumn[item.field]\" class=\"col-lg-2 col-md-3 col-sm-6 px-8\">\r\n <sd-input [label]=\"item.title\" *ngIf=\"item.type === 'string'\" type=\"text\" [(model)]=\"columnFilter[item.field]\"\r\n (keyupEnter)=\"onFilter(item)\" appearance=\"outline\">\r\n </sd-input>\r\n <sd-input-number [label]=\"item.title\" *ngIf=\"item.type === 'number'\" [(model)]=\"columnFilter[item.field]\"\r\n (keyupEnter)=\"onFilter(item)\" appearance=\"outline\">\r\n </sd-input-number>\r\n <sd-select [label]=\"item.title\" *ngIf=\"item.type === 'bool'\" [items]=\"[{value:'1',display:item.option?.displayOnTrue || 'True' },\r\n {value:'0',display:item.option?.displayOnFalse || 'False' }]\" valueField=\"value\" displayField=\"display\"\r\n [(model)]=\"columnFilter[item.field]\" (sdChange)=\"onFilter(item)\" appearance=\"outline\">\r\n </sd-select>\r\n <sd-select *ngIf=\"item.type === 'values' && item?.option?.selection !== 'AUTOCOMPLETE'\"\r\n [items]=\"item.option?.items\" [valueField]=\"item.option?.valueField\" [displayField]=\"item.option.displayField\"\r\n [(model)]=\"columnFilter[item.field]\" (sdChange)=\"onFilter(item)\" [disabled]=\"item.filter?.disabled\"\r\n [multiple]=\"item?.option?.selection === 'MULTIPLE' || item?.item?.selection === 'MULTIPLEAUTOCOMPLETE'\"\r\n [filtered]=\"item?.option?.selection === 'MULTIPLEAUTOCOMPLETE'\" appearance=\"outline\">\r\n </sd-select>\r\n <sd-autocomplete *ngIf=\"item.type === 'values' && item?.option?.selection === 'AUTOCOMPLETE'\"\r\n [items]=\"item.option?.items\" [valueField]=\"item.option?.valueField\" [displayField]=\"item.option?.displayField\"\r\n [(model)]=\"columnFilter[item.field]\" (sdChange)=\"onFilter(item)\" [disabled]=\"item.filter?.disabled\"\r\n appearance=\"outline\">\r\n </sd-autocomplete>\r\n <sd-date-time *ngIf=\"item.type === 'date' || item.type === 'datetime' || item.type === 'time'\"\r\n [label]=\"item.title\" [(model)]=\"columnFilter[item.field]\" [type]=\"item.type\" (sdChange)=\"onFilter(item)\"\r\n appearance=\"outline\">\r\n </sd-date-time>\r\n </div>\r\n </ng-template>\r\n <ng-template #filterExternal let-item=\"item\">\r\n <div *ngIf=\"inlineExternal[item.field]\" class=\"col-lg-2 col-md-3 col-sm-6 px-8\">\r\n <sd-input [label]=\"item.title\" *ngIf=\"item.type === 'string'\" type=\"text\" [(model)]=\"externalFilter[item.field]\"\r\n (keyupEnter)=\"onFilter(item)\" appearance=\"outline\">\r\n </sd-input>\r\n <sd-input-number [label]=\"item.title\" *ngIf=\"item.type === 'number'\" [(model)]=\"externalFilter[item.field]\"\r\n (keyupEnter)=\"onFilter(item)\" appearance=\"outline\">\r\n </sd-input-number>\r\n <sd-select [label]=\"item.title\" *ngIf=\"item.type === 'bool'\" [items]=\"[{value:'1',display:item.option?.displayOnTrue || 'True' },\r\n {value:'0',display:item.option?.displayOnFalse || 'False' }]\" valueField=\"value\" displayField=\"display\"\r\n [(model)]=\"externalFilter[item.field]\" (sdChange)=\"onFilter(item)\" appearance=\"outline\">\r\n </sd-select>\r\n <ng-container *ngIf=\"item.type === 'values' && item.option\">\r\n <sd-select *ngIf=\"item.option?.selection === 'MULTIPLE'\" [label]=\"item.title\" [items]=\"item.option.items\"\r\n [valueField]=\"item.option.valueField\" [displayField]=\"item.option.displayField\"\r\n [(model)]=\"externalFilter[item.field]\" (sdChange)=\"onFilter(item)\" [selectAll]=\"item.option.selectAll\"\r\n appearance=\"outline\" multiple>\r\n </sd-select>\r\n <sd-autocomplete *ngIf=\"item.option?.selection === 'AUTOCOMPLETE'\" [label]=\"item.title\"\r\n [items]=\"item.option.items\" [valueField]=\"item.option.valueField\" [displayField]=\"item.option.displayField\"\r\n [(model)]=\"externalFilter[item.field]\" (sdChange)=\"onFilter(item)\" appearance=\"outline\">\r\n </sd-autocomplete>\r\n <sd-select *ngIf=\"item.option?.selection === 'MULTIPLEAUTOCOMPLETE'\" [label]=\"item.title\"\r\n [items]=\"item.option.items\" [valueField]=\"item.option.valueField\" [displayField]=\"item.option.displayField\"\r\n [(model)]=\"externalFilter[item.field]\" (sdChange)=\"onFilter(item)\" filtered=\"true\" appearance=\"outline\"\r\n multiple>\r\n </sd-select>\r\n <sd-select *ngIf=\"!item.option?.selection\" [label]=\"item.title\" [items]=\"item.option.items\"\r\n [valueField]=\"item.option.valueField\" [displayField]=\"item.option.displayField\"\r\n [(model)]=\"externalFilter[item.field]\" (sdChange)=\"onFilter(item)\" appearance=\"outline\">\r\n </sd-select>\r\n </ng-container>\r\n <sd-date-time [label]=\"item.title\" *ngIf=\"item.type ==='date' || item.type ==='datetime'\"\r\n [(model)]=\"externalFilter[item.field]\" [type]=\"item.type\" (sdChange)=\"onFilter(item)\" appearance=\"outline\">\r\n </sd-date-time>\r\n <sd-date-range [label]=\"item.title\" *ngIf=\"item.type ==='daterange' && externalFilter[item.field]\"\r\n [(from)]=\"externalFilter[item.field].from\" [(to)]=\"externalFilter[item.field].to\" [min]=\"item.minDate\"\r\n [max]=\"item.maxDate\" (sdChange)=\"onFilter(item)\" appearance=\"outline\">\r\n </sd-date-range>\r\n </div>\r\n </ng-template>\r\n <sd-popup-filter [filterRegister]=\"filterRegister\" [columns]=\"columns\"\r\n [externalFilters]=\"externalFilters\" [filterDefs]=\"filterDefs\">\r\n </sd-popup-filter>\r\n </ng-template>\r\n</ng-container>",
221
+ changeDetection: ChangeDetectionStrategy.OnPush,
222
+ styles: [":host{display:block;padding-bottom:10px;padding-left:0;padding-right:0}:host ::ng-deep .mat-form-field-wrapper{padding-bottom:0}"]
223
+ },] }
224
+ ];
225
+ SdGridFilter.ctorParameters = () => [
226
+ { type: ChangeDetectorRef },
227
+ { type: DeviceDetectorService }
228
+ ];
229
+ SdGridFilter.propDecorators = {
230
+ popupFilter: [{ type: ViewChild, args: [SdPopupFilter,] }],
231
+ _filter: [{ type: Input, args: ['filter',] }],
232
+ columns: [{ type: Input }],
233
+ _externalFilters: [{ type: Input, args: ['externalFilters',] }],
234
+ filterDefs: [{ type: Input }],
235
+ _filterRegister: [{ type: Input, args: ['filterRegister',] }]
236
+ };
237
+
238
+ class SdMaterialFilterDefDirective {
239
+ constructor(templateRef) {
240
+ this.templateRef = templateRef;
241
+ }
242
+ set showing(val) {
243
+ this.defaultShowing = (val === '') || val;
244
+ }
245
+ }
246
+ SdMaterialFilterDefDirective.decorators = [
247
+ { type: Directive, args: [{
248
+ selector: '[sdMaterialFilterDef]'
249
+ },] }
250
+ ];
251
+ SdMaterialFilterDefDirective.ctorParameters = () => [
252
+ { type: TemplateRef }
253
+ ];
254
+ SdMaterialFilterDefDirective.propDecorators = {
255
+ sdMaterialFilterDef: [{ type: Input }],
256
+ showing: [{ type: Input, args: ['defaultShowing',] }]
257
+ };
258
+
259
+ class SdMaterialSubInformationDefDirective {
260
+ constructor(templateRef) {
261
+ this.templateRef = templateRef;
262
+ }
263
+ }
264
+ SdMaterialSubInformationDefDirective.decorators = [
265
+ { type: Directive, args: [{
266
+ selector: '[sdMaterialSubInformationDef]'
267
+ },] }
268
+ ];
269
+ SdMaterialSubInformationDefDirective.ctorParameters = () => [
270
+ { type: TemplateRef }
271
+ ];
272
+
273
+ class SdMaterialFooterDefDirective {
274
+ constructor(templateRef) {
275
+ this.templateRef = templateRef;
276
+ }
277
+ }
278
+ SdMaterialFooterDefDirective.decorators = [
279
+ { type: Directive, args: [{
280
+ selector: '[sdMaterialFooterDef]'
281
+ },] }
282
+ ];
283
+ SdMaterialFooterDefDirective.ctorParameters = () => [
284
+ { type: TemplateRef }
285
+ ];
286
+ SdMaterialFooterDefDirective.propDecorators = {
287
+ sdMaterialFooterDef: [{ type: Input }]
288
+ };
289
+
290
+ class SdMaterialEmptyDataDefDirective {
291
+ constructor(templateRef) {
292
+ this.templateRef = templateRef;
293
+ }
294
+ }
295
+ SdMaterialEmptyDataDefDirective.decorators = [
296
+ { type: Directive, args: [{
297
+ selector: '[sdMaterialEmptyDataDef]'
298
+ },] }
299
+ ];
300
+ SdMaterialEmptyDataDefDirective.ctorParameters = () => [
301
+ { type: TemplateRef }
302
+ ];
303
+
304
+ var _COLUMNS, _cache, _getKey, _default, _load, _get, _set, _remove;
305
+ class SdTableConfigurationService {
306
+ constructor(settingService, gridMaterialConfiguration) {
307
+ this.settingService = settingService;
308
+ this.gridMaterialConfiguration = gridMaterialConfiguration;
309
+ _COLUMNS.set(this, {
310
+ EDITORVALIDATION: 'sdEditorValidation',
311
+ EDITOR: 'sdEditor',
312
+ SUBINFORMATION: 'sdSubInformationAction',
313
+ COMMAND: 'sdCommand',
314
+ SELECTION: 'sdSelection',
315
+ GROUP: 'sdGroup',
316
+ });
317
+ _cache.set(this, {});
318
+ this.init = (key, gridOption) => {
319
+ if (!__classPrivateFieldGet(this, _cache)[key]) {
320
+ const subject = new Subject();
321
+ __classPrivateFieldGet(this, _cache)[key] = {
322
+ load: __classPrivateFieldGet(this, _load).call(this, gridOption, subject),
323
+ get: __classPrivateFieldGet(this, _get).call(this, gridOption),
324
+ set: (configuration) => {
325
+ configuration = __classPrivateFieldGet(this, _set).call(this, gridOption, configuration);
326
+ subject.next(Object.assign({}, configuration));
327
+ return configuration;
328
+ },
329
+ remove: () => {
330
+ __classPrivateFieldGet(this, _remove).call(this, gridOption)();
331
+ subject.next(__classPrivateFieldGet(this, _default).call(this, gridOption));
332
+ },
333
+ observer: subject,
334
+ };
335
+ }
336
+ return __classPrivateFieldGet(this, _cache)[key];
337
+ };
338
+ _getKey.set(this, (gridOption) => {
339
+ var _a, _b;
340
+ const prefix = 'c9e94836-6ace-4aeb-b148-4f0be63589ee';
341
+ if (!((_a = gridOption === null || gridOption === void 0 ? void 0 : gridOption.config) === null || _a === void 0 ? void 0 : _a.key) && !(gridOption === null || gridOption === void 0 ? void 0 : gridOption.key)) {
342
+ return null;
343
+ }
344
+ return hash__default({
345
+ prefix,
346
+ key: ((_b = gridOption === null || gridOption === void 0 ? void 0 : gridOption.config) === null || _b === void 0 ? void 0 : _b.key) || !(gridOption === null || gridOption === void 0 ? void 0 : gridOption.key),
347
+ });
348
+ });
349
+ _default.set(this, (gridOption) => {
350
+ var _a;
351
+ const columns = ((_a = gridOption === null || gridOption === void 0 ? void 0 : gridOption.columns) === null || _a === void 0 ? void 0 : _a.filter(e => !e.hidden).map(e => ({
352
+ origin: {
353
+ field: e.field,
354
+ title: e.title,
355
+ width: e.width,
356
+ invisible: e.invisible,
357
+ },
358
+ invisible: e.invisible,
359
+ fixed: false,
360
+ }))) || [];
361
+ return {
362
+ columns,
363
+ };
364
+ });
365
+ _load.set(this, (gridOption, subject) => {
366
+ return () => __awaiter(this, void 0, void 0, function* () {
367
+ const get = __classPrivateFieldGet(this, _get).call(this, gridOption);
368
+ const configuration = yield get();
369
+ subject.next(Object.assign({}, configuration));
370
+ });
371
+ });
372
+ _get.set(this, (gridOption) => {
373
+ return () => __awaiter(this, void 0, void 0, function* () {
374
+ const key = __classPrivateFieldGet(this, _getKey).call(this, gridOption);
375
+ if (!key) {
376
+ return __classPrivateFieldGet(this, _default).call(this, gridOption);
377
+ }
378
+ const { columns, config } = gridOption;
379
+ let configuration;
380
+ if ((config === null || config === void 0 ? void 0 : config.storage) === 'server') {
381
+ const { get, remove } = this.settingService.createServer(key, {
382
+ args: config === null || config === void 0 ? void 0 : config.args,
383
+ });
384
+ configuration = yield get().catch(() => undefined);
385
+ if (!(configuration === null || configuration === void 0 ? void 0 : configuration.columns)) {
386
+ remove().catch(console.error);
387
+ return __classPrivateFieldGet(this, _default).call(this, gridOption);
388
+ }
389
+ }
390
+ else {
391
+ const { get, remove } = this.settingService.create(key, {
392
+ type: config === null || config === void 0 ? void 0 : config.storage,
393
+ args: config === null || config === void 0 ? void 0 : config.args,
394
+ });
395
+ configuration = get();
396
+ if (!(configuration === null || configuration === void 0 ? void 0 : configuration.columns)) {
397
+ remove();
398
+ return __classPrivateFieldGet(this, _default).call(this, gridOption);
399
+ }
400
+ }
401
+ configuration.columns = configuration.columns.filter(column => columns.some(e => !e.hidden && e.field === column.origin.field));
402
+ // Thêm những column mới vào storage nếu có
403
+ columns.forEach(column => {
404
+ const col = configuration.columns.find(e => { var _a; return ((_a = e.origin) === null || _a === void 0 ? void 0 : _a.field) === column.field; });
405
+ if (!col) {
406
+ configuration.columns.push({
407
+ origin: {
408
+ field: column.field,
409
+ title: column.title,
410
+ width: column.width,
411
+ invisible: column.invisible,
412
+ },
413
+ invisible: column.invisible,
414
+ fixed: false,
415
+ });
416
+ }
417
+ else {
418
+ col.origin = {
419
+ field: column.field,
420
+ title: column.title,
421
+ width: column.width,
422
+ invisible: column.invisible,
423
+ };
424
+ }
425
+ });
426
+ return configuration;
427
+ });
428
+ });
429
+ _set.set(this, (gridOption, configuration) => {
430
+ var _a, _b, _c, _d;
431
+ const key = __classPrivateFieldGet(this, _getKey).call(this, gridOption);
432
+ if (key) {
433
+ if (((_a = gridOption === null || gridOption === void 0 ? void 0 : gridOption.config) === null || _a === void 0 ? void 0 : _a.storage) === 'server') {
434
+ const { set } = this.settingService.createServer(key, {
435
+ args: (_b = gridOption === null || gridOption === void 0 ? void 0 : gridOption.config) === null || _b === void 0 ? void 0 : _b.args,
436
+ });
437
+ set(configuration);
438
+ }
439
+ else {
440
+ const { set } = this.settingService.create(key, {
441
+ type: (_c = gridOption === null || gridOption === void 0 ? void 0 : gridOption.config) === null || _c === void 0 ? void 0 : _c.storage,
442
+ args: (_d = gridOption === null || gridOption === void 0 ? void 0 : gridOption.config) === null || _d === void 0 ? void 0 : _d.args,
443
+ });
444
+ set(configuration);
445
+ }
446
+ }
447
+ return JSON.parse(JSON.stringify(configuration));
448
+ });
449
+ _remove.set(this, (gridOption) => {
450
+ return () => {
451
+ var _a, _b, _c, _d;
452
+ const key = __classPrivateFieldGet(this, _getKey).call(this, gridOption);
453
+ if (key) {
454
+ if (((_a = gridOption === null || gridOption === void 0 ? void 0 : gridOption.config) === null || _a === void 0 ? void 0 : _a.storage) === 'server') {
455
+ const { remove } = this.settingService.createServer(key, {
456
+ args: (_b = gridOption === null || gridOption === void 0 ? void 0 : gridOption.config) === null || _b === void 0 ? void 0 : _b.args,
457
+ });
458
+ remove();
459
+ }
460
+ else {
461
+ const { remove } = this.settingService.create(key, {
462
+ type: (_c = gridOption === null || gridOption === void 0 ? void 0 : gridOption.config) === null || _c === void 0 ? void 0 : _c.storage,
463
+ args: (_d = gridOption === null || gridOption === void 0 ? void 0 : gridOption.config) === null || _d === void 0 ? void 0 : _d.args,
464
+ });
465
+ remove();
466
+ }
467
+ }
468
+ };
469
+ });
470
+ // get = async (gridOption: SdGridMaterialOption): Promise<SdGridConfiguration> => {
471
+ // if (!gridOption?.key) {
472
+ // return this.#getDefaultConfiguration(gridOption);
473
+ // }
474
+ // const { key, columns } = gridOption;
475
+ // const configuration: SdGridConfiguration = await this.settingService.get(this.#getKey(key)).catch(() => undefined);
476
+ // if (!configuration?.columns) {
477
+ // this.settingService.remove(this.#getKey(key)).catch(console.error);
478
+ // return this.#getDefaultConfiguration(gridOption);
479
+ // }
480
+ // configuration.columns = configuration.columns
481
+ // .filter(column => columns.some(e => !e.hidden && e.field === column.origin.field));
482
+ // // Thêm những column mới vào storage nếu có
483
+ // columns.forEach(column => {
484
+ // const col = configuration.columns.find(e => e.origin?.field === column.field);
485
+ // if (!col) {
486
+ // configuration.columns.push({
487
+ // origin: {
488
+ // field: column.field,
489
+ // title: column.title,
490
+ // width: column.width,
491
+ // invisible: column.invisible,
492
+ // },
493
+ // invisible: column.invisible,
494
+ // fixed: false
495
+ // });
496
+ // } else {
497
+ // col.origin = {
498
+ // field: column.field,
499
+ // title: column.title,
500
+ // width: column.width,
501
+ // invisible: column.invisible
502
+ // };
503
+ // }
504
+ // });
505
+ // return configuration;
506
+ // }
507
+ // set = async (key: string, configuration: SdGridConfiguration): Promise<SdGridConfiguration> => {
508
+ // if (key) {
509
+ // this.settingService.set(this.#getKey(key), configuration);
510
+ // }
511
+ // return configuration;
512
+ // }
513
+ // remove = (key: string) => {
514
+ // if (key) {
515
+ // this.settingService.remove(this.#getKey(key));
516
+ // }
517
+ // }
518
+ this.generateConfigurationResult = (configuration, gridOption, sdSubInformation) => {
519
+ var _a, _b;
520
+ const result = {
521
+ column: {},
522
+ fixedColumn: {},
523
+ firstColumns: [],
524
+ secondColumns: [],
525
+ firstHeaders: [],
526
+ secondHeaders: [],
527
+ displayedColumns: [],
528
+ displayedFooters: [],
529
+ multipleHeader: false,
530
+ };
531
+ const { selector, commands, group } = gridOption || {};
532
+ if (selector === null || selector === void 0 ? void 0 : selector.visible) {
533
+ result.firstHeaders.push(__classPrivateFieldGet(this, _COLUMNS).SELECTION);
534
+ result.displayedColumns.push(__classPrivateFieldGet(this, _COLUMNS).SELECTION);
535
+ }
536
+ if (commands === null || commands === void 0 ? void 0 : commands.length) {
537
+ result.firstHeaders.push(__classPrivateFieldGet(this, _COLUMNS).COMMAND);
538
+ result.displayedColumns.push(__classPrivateFieldGet(this, _COLUMNS).COMMAND);
539
+ }
540
+ if ((_a = group === null || group === void 0 ? void 0 : group.fields) === null || _a === void 0 ? void 0 : _a.length) {
541
+ result.firstHeaders.push(__classPrivateFieldGet(this, _COLUMNS).GROUP);
542
+ result.displayedColumns.push(__classPrivateFieldGet(this, _COLUMNS).GROUP);
543
+ }
544
+ (_b = configuration === null || configuration === void 0 ? void 0 : configuration.columns) === null || _b === void 0 ? void 0 : _b.filter(col => !col.invisible).forEach(col => {
545
+ var _a;
546
+ const column = gridOption === null || gridOption === void 0 ? void 0 : gridOption.columns.find(e => e.field === col.origin.field);
547
+ if (column) {
548
+ result.column[col.origin.field] = {
549
+ title: col.title || col.origin.title,
550
+ width: col.width || col.origin.width,
551
+ };
552
+ if (col.fixed) {
553
+ result.fixedColumn[col.origin.field] = {
554
+ title: col.title || col.origin.title,
555
+ width: col.width || col.origin.width,
556
+ };
557
+ }
558
+ result.firstColumns.push(Object.assign(Object.assign({}, column), { title: col.title || col.origin.title, width: col.width || col.origin.width }));
559
+ result.firstHeaders.push(col.origin.field);
560
+ result.displayedColumns.push(col.origin.field);
561
+ if (column.type === 'children') {
562
+ (_a = column.children) === null || _a === void 0 ? void 0 : _a.forEach(childColumn => {
563
+ result.secondColumns.push(childColumn);
564
+ result.secondHeaders.push(childColumn.field);
565
+ result.displayedColumns.push(childColumn.field);
566
+ });
567
+ }
568
+ }
569
+ });
570
+ if (sdSubInformation === null || sdSubInformation === void 0 ? void 0 : sdSubInformation.templateRef) {
571
+ result.firstHeaders.push(__classPrivateFieldGet(this, _COLUMNS).SUBINFORMATION);
572
+ result.displayedColumns.push(__classPrivateFieldGet(this, _COLUMNS).SUBINFORMATION);
573
+ }
574
+ result.multipleHeader = result.secondHeaders.length > 0;
575
+ // Sub infomation không thể có footer
576
+ result.displayedFooters = result.displayedColumns.filter(val => val !== __classPrivateFieldGet(this, _COLUMNS).SUBINFORMATION);
577
+ return result;
578
+ };
579
+ }
580
+ }
581
+ _COLUMNS = new WeakMap(), _cache = new WeakMap(), _getKey = new WeakMap(), _default = new WeakMap(), _load = new WeakMap(), _get = new WeakMap(), _set = new WeakMap(), _remove = new WeakMap();
582
+ SdTableConfigurationService.decorators = [
583
+ { type: Injectable }
584
+ ];
585
+ SdTableConfigurationService.ctorParameters = () => [
586
+ { type: SdSettingService },
587
+ { type: undefined, decorators: [{ type: Inject, args: [TABLE_CONFIG,] }, { type: Optional }] }
588
+ ];
589
+
590
+ const MapToSdTableItem = (item) => ({
591
+ current: JSON.parse(JSON.stringify(item)),
592
+ origin: item,
593
+ meta: {
594
+ id: hash(item),
595
+ expand: {
596
+ isExpanding: false,
597
+ isExpanded: false,
598
+ },
599
+ group: {},
600
+ selector: { actions: [], isSelected: false, selectable: false },
601
+ },
602
+ });
603
+
604
+ var _prefix, _cache$1;
605
+ class SdColumnValuesPipe {
606
+ constructor() {
607
+ _prefix.set(this, 'a1e67660-8aa2-4c11-b02d-71a32188719f');
608
+ _cache$1.set(this, {});
609
+ this.transform = (value, column) => __awaiter(this, void 0, void 0, function* () {
610
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
611
+ if (column.type !== 'values' || !((_a = column.option) === null || _a === void 0 ? void 0 : _a.items) || !((_b = column.option) === null || _b === void 0 ? void 0 : _b.valueField) || !((_c = column.option) === null || _c === void 0 ? void 0 : _c.displayField)) {
612
+ return value;
613
+ }
614
+ const _l = column.option, { items, valueField, displayField, selection } = _l, remain = __rest(_l, ["items", "valueField", "displayField", "selection"]);
615
+ const key = hash__default({
616
+ prefix: __classPrivateFieldGet(this, _prefix),
617
+ valueField,
618
+ displayField,
619
+ selection,
620
+ remain,
621
+ value
622
+ });
623
+ const isMultible = ['MULTIPLE', 'MULTIPLEAUTOCOMPLETE', 'MULTIPLE_EDITOR', 'MULTIPLEAUTOCOMPLETE_EDITOR'].includes(selection);
624
+ if (typeof (items) === 'function') {
625
+ if (!__classPrivateFieldGet(this, _cache$1)[key]) {
626
+ const values = yield items(value, true);
627
+ let result = '';
628
+ if (isMultible && Array.isArray(value)) {
629
+ result = ((_e = (_d = values === null || values === void 0 ? void 0 : values.filter(e => value === null || value === void 0 ? void 0 : value.includes(e === null || e === void 0 ? void 0 : e[valueField]))) === null || _d === void 0 ? void 0 : _d.map(e => e === null || e === void 0 ? void 0 : e[displayField])) === null || _e === void 0 ? void 0 : _e.join(', ')) || (value === null || value === void 0 ? void 0 : value.join(', '));
630
+ }
631
+ else {
632
+ result = ((_f = values === null || values === void 0 ? void 0 : values.find(e => (e === null || e === void 0 ? void 0 : e[valueField]) === value)) === null || _f === void 0 ? void 0 : _f[displayField]) || value;
633
+ }
634
+ __classPrivateFieldGet(this, _cache$1)[key] = {
635
+ result
636
+ };
637
+ }
638
+ }
639
+ else {
640
+ if (!__classPrivateFieldGet(this, _cache$1)[key]) {
641
+ let result = '';
642
+ if (isMultible && Array.isArray(value)) {
643
+ result = (_j = (_h = (_g = items === null || items === void 0 ? void 0 : items.filter(e => value === null || value === void 0 ? void 0 : value.includes(e === null || e === void 0 ? void 0 : e[valueField]))) === null || _g === void 0 ? void 0 : _g.map(e => e === null || e === void 0 ? void 0 : e[displayField])) === null || _h === void 0 ? void 0 : _h.join(', ')) !== null && _j !== void 0 ? _j : value === null || value === void 0 ? void 0 : value.join(', ');
644
+ }
645
+ else {
646
+ result = ((_k = items === null || items === void 0 ? void 0 : items.find(e => (e === null || e === void 0 ? void 0 : e[valueField]) === value)) === null || _k === void 0 ? void 0 : _k[displayField]) || value;
647
+ }
648
+ __classPrivateFieldGet(this, _cache$1)[key] = {
649
+ result
650
+ };
651
+ }
652
+ }
653
+ return __classPrivateFieldGet(this, _cache$1)[key].result;
654
+ });
655
+ }
656
+ }
657
+ _prefix = new WeakMap(), _cache$1 = new WeakMap();
658
+ SdColumnValuesPipe.decorators = [
659
+ { type: Pipe, args: [{
660
+ name: 'columnValues'
661
+ },] }
662
+ ];
663
+
664
+ var _filterConfiguration, _filterValue, _cache$2, _defaultConfiguration, _defaultValue, _initConfiguration, _initValue;
665
+ class SdTableFilterService {
666
+ constructor(settingService) {
667
+ this.settingService = settingService;
668
+ _filterConfiguration.set(this, 'GRID-FILTER-CONFIGURATION');
669
+ _filterValue.set(this, 'GRID-FILTER-VALUE');
670
+ _cache$2.set(this, {});
671
+ this.register = (filter, args) => {
672
+ let cacheSession = false;
673
+ const { id, columns, externalFilters } = args;
674
+ const tempKey = hash__default({
675
+ id,
676
+ columns: (columns === null || columns === void 0 ? void 0 : columns.map(e => e.field).filter(field => !!field)) || [],
677
+ externalFilters: (externalFilters === null || externalFilters === void 0 ? void 0 : externalFilters.map(e => e.field).filter(field => !!field)) || [],
678
+ });
679
+ const key = (filter === null || filter === void 0 ? void 0 : filter.key) || tempKey;
680
+ if (!(filter === null || filter === void 0 ? void 0 : filter.key)) {
681
+ cacheSession = true; // Nếu không có key thì chỉ lưu theo session
682
+ }
683
+ if (!__classPrivateFieldGet(this, _cache$2)[key]) {
684
+ // Setting của filter configuration
685
+ const filterConfiguration = this.settingService.create({
686
+ prefix: __classPrivateFieldGet(this, _filterConfiguration),
687
+ key,
688
+ }, {
689
+ default: __classPrivateFieldGet(this, _defaultConfiguration).call(this, args),
690
+ type: cacheSession ? 'session' : undefined,
691
+ });
692
+ // Lấy giá trị configuration merge với giá trị defaultShowing của args nếu như args có thay đổi
693
+ filterConfiguration.set(__classPrivateFieldGet(this, _initConfiguration).call(this, args, filterConfiguration.get()));
694
+ // Setting của filter value
695
+ const filterValue = this.settingService.create({
696
+ prefix: __classPrivateFieldGet(this, _filterValue),
697
+ key: !(filter === null || filter === void 0 ? void 0 : filter.cacheFilter) ? tempKey : key,
698
+ }, {
699
+ default: __classPrivateFieldGet(this, _defaultValue).call(this, args),
700
+ type: cacheSession || !(filter === null || filter === void 0 ? void 0 : filter.cacheFilter) ? 'session' : undefined,
701
+ });
702
+ // Lấy giá trị value merge với giá trị default của args nếu như args có thay đổi
703
+ filterValue.set(__classPrivateFieldGet(this, _initValue).call(this, args, filterValue.get()));
704
+ __classPrivateFieldGet(this, _cache$2)[key] = {
705
+ configuration: {
706
+ get: () => {
707
+ return filterConfiguration.get();
708
+ },
709
+ set: (configuration) => {
710
+ const { inlineColumn, inlineExternal, inlineFilterDef } = configuration;
711
+ filterConfiguration.set({
712
+ inlineColumn,
713
+ inlineExternal,
714
+ inlineFilterDef,
715
+ });
716
+ return {
717
+ inlineColumn,
718
+ inlineExternal,
719
+ inlineFilterDef,
720
+ };
721
+ },
722
+ remove: () => {
723
+ filterConfiguration.set(__classPrivateFieldGet(this, _defaultConfiguration).call(this, args));
724
+ },
725
+ observer: filterConfiguration.observer.pipe(startWith(filterConfiguration.get()),
726
+ // Sử dụng mặc định nếu bị reset
727
+ map(configuration => configuration || __classPrivateFieldGet(this, _defaultConfiguration).call(this, args))),
728
+ },
729
+ value: {
730
+ get: () => {
731
+ return filterValue.get();
732
+ },
733
+ set: (value) => {
734
+ const keys = Object.keys(value || {});
735
+ const current = filterValue.get();
736
+ const { columnOperator, columnFilter, externalFilter, filterDef, notReload } = current;
737
+ const updatedFilter = {
738
+ // Filter column
739
+ columnOperator: keys.includes('columnOperator') ? (value === null || value === void 0 ? void 0 : value.columnOperator) || {} : columnOperator,
740
+ columnFilter: keys.includes('columnFilter') ? (value === null || value === void 0 ? void 0 : value.columnFilter) || {} : columnFilter,
741
+ // Filter external
742
+ externalFilter: keys.includes('externalFilter') ? (value === null || value === void 0 ? void 0 : value.externalFilter) || {} : externalFilter,
743
+ // Filter def
744
+ filterDef: keys.includes('filterDef') ? (value === null || value === void 0 ? void 0 : value.filterDef) || {} : filterDef,
745
+ // Force
746
+ notReload: !!notReload,
747
+ };
748
+ filterValue.set(updatedFilter);
749
+ return updatedFilter;
750
+ },
751
+ remove: () => {
752
+ filterValue.set(__classPrivateFieldGet(this, _defaultValue).call(this, args));
753
+ },
754
+ observer: filterValue.observer.pipe(startWith(filterValue.get()),
755
+ // Sử dụng mặc định nếu bị reset
756
+ map(value => value || __classPrivateFieldGet(this, _defaultValue).call(this, args))),
757
+ },
758
+ };
759
+ }
760
+ return __classPrivateFieldGet(this, _cache$2)[key];
761
+ };
762
+ _defaultConfiguration.set(this, (args) => {
763
+ var _a;
764
+ const { columns, externalFilters, filterDefs } = args;
765
+ const inlineColumn = {};
766
+ const inlineExternal = {};
767
+ const inlineFilterDef = {};
768
+ // Filter column
769
+ for (const item of columns || []) {
770
+ inlineColumn[item.field] = (_a = item === null || item === void 0 ? void 0 : item.filter) === null || _a === void 0 ? void 0 : _a.defaultShowing;
771
+ }
772
+ // Filter external
773
+ for (const item of externalFilters || []) {
774
+ inlineExternal[item.field] = item === null || item === void 0 ? void 0 : item.defaultShowing;
775
+ }
776
+ // Filter def
777
+ for (const item of filterDefs || []) {
778
+ inlineFilterDef[item.sdMaterialFilterDef] = item === null || item === void 0 ? void 0 : item.defaultShowing;
779
+ }
780
+ return {
781
+ // Filter column
782
+ inlineColumn,
783
+ // Filter external
784
+ inlineExternal,
785
+ // Filter def
786
+ inlineFilterDef,
787
+ };
788
+ });
789
+ _defaultValue.set(this, (args) => {
790
+ var _a;
791
+ const columnFilter = {};
792
+ const externalFilter = {};
793
+ const filterDef = {};
794
+ const { columns, externalFilters, filterDefs } = args;
795
+ // Filter column
796
+ for (const item of columns || []) {
797
+ columnFilter[item.field] = (_a = item === null || item === void 0 ? void 0 : item.filter) === null || _a === void 0 ? void 0 : _a.default;
798
+ }
799
+ // Filter external
800
+ for (const item of externalFilters || []) {
801
+ externalFilter[item.field] = item === null || item === void 0 ? void 0 : item.default;
802
+ }
803
+ // Filter def
804
+ for (const item of filterDefs || []) {
805
+ filterDef[item.sdMaterialFilterDef] = undefined;
806
+ }
807
+ return {
808
+ // Filter column
809
+ columnFilter,
810
+ // Filter external
811
+ externalFilter,
812
+ // Filter def
813
+ filterDef,
814
+ };
815
+ });
816
+ _initConfiguration.set(this, (args, configuration) => {
817
+ var _a, _b, _c, _d, _e, _f, _g;
818
+ const { columns, externalFilters, filterDefs } = args;
819
+ const inlineColumn = {};
820
+ const inlineExternal = {};
821
+ const inlineFilterDef = {};
822
+ // Filter column
823
+ for (const item of columns || []) {
824
+ inlineColumn[item.field] = (_b = (_a = configuration === null || configuration === void 0 ? void 0 : configuration.inlineColumn) === null || _a === void 0 ? void 0 : _a[item.field]) !== null && _b !== void 0 ? _b : (_c = item === null || item === void 0 ? void 0 : item.filter) === null || _c === void 0 ? void 0 : _c.defaultShowing;
825
+ }
826
+ // Filter external
827
+ for (const item of externalFilters || []) {
828
+ inlineExternal[item.field] = (_e = (_d = configuration === null || configuration === void 0 ? void 0 : configuration.inlineExternal) === null || _d === void 0 ? void 0 : _d[item.field]) !== null && _e !== void 0 ? _e : item === null || item === void 0 ? void 0 : item.defaultShowing;
829
+ }
830
+ // Filter def
831
+ for (const item of filterDefs || []) {
832
+ inlineFilterDef[item.sdMaterialFilterDef] = (_g = (_f = configuration === null || configuration === void 0 ? void 0 : configuration.inlineFilterDef) === null || _f === void 0 ? void 0 : _f[item.sdMaterialFilterDef]) !== null && _g !== void 0 ? _g : item === null || item === void 0 ? void 0 : item.defaultShowing;
833
+ }
834
+ return {
835
+ // Filter column
836
+ inlineColumn,
837
+ // Filter external
838
+ inlineExternal,
839
+ // Filter def
840
+ inlineFilterDef,
841
+ };
842
+ });
843
+ _initValue.set(this, (args, value) => {
844
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
845
+ const columnFilter = {};
846
+ const externalFilter = {};
847
+ const filterDef = {};
848
+ const { columns, externalFilters, filterDefs } = args;
849
+ // Filter column
850
+ for (const item of columns || []) {
851
+ columnFilter[item.field] = (_b = (_a = value === null || value === void 0 ? void 0 : value.columnFilter) === null || _a === void 0 ? void 0 : _a[item.field]) !== null && _b !== void 0 ? _b : (_c = item === null || item === void 0 ? void 0 : item.filter) === null || _c === void 0 ? void 0 : _c.default;
852
+ }
853
+ // Filter external
854
+ for (const item of externalFilters || []) {
855
+ if (item.type === 'daterange') {
856
+ externalFilter[item.field] = {
857
+ from: (_f = (_e = (_d = value === null || value === void 0 ? void 0 : value.externalFilter) === null || _d === void 0 ? void 0 : _d[item.field]) === null || _e === void 0 ? void 0 : _e.from) !== null && _f !== void 0 ? _f : (_g = item.default) === null || _g === void 0 ? void 0 : _g.from,
858
+ to: (_k = (_j = (_h = value === null || value === void 0 ? void 0 : value.externalFilter) === null || _h === void 0 ? void 0 : _h[item.field]) === null || _j === void 0 ? void 0 : _j.to) !== null && _k !== void 0 ? _k : (_l = item.default) === null || _l === void 0 ? void 0 : _l.to,
859
+ };
860
+ }
861
+ else {
862
+ externalFilter[item.field] = (_o = (_m = value === null || value === void 0 ? void 0 : value.externalFilter) === null || _m === void 0 ? void 0 : _m[item.field]) !== null && _o !== void 0 ? _o : item === null || item === void 0 ? void 0 : item.default;
863
+ }
864
+ }
865
+ // Filter def
866
+ for (const item of filterDefs || []) {
867
+ filterDef[item.sdMaterialFilterDef] = (_q = (_p = value === null || value === void 0 ? void 0 : value.filterDef) === null || _p === void 0 ? void 0 : _p[item.sdMaterialFilterDef]) !== null && _q !== void 0 ? _q : undefined;
868
+ }
869
+ return {
870
+ // Filter column
871
+ columnFilter,
872
+ // Filter external
873
+ externalFilter,
874
+ // Filter def
875
+ filterDef,
876
+ };
877
+ });
878
+ }
879
+ }
880
+ _filterConfiguration = new WeakMap(), _filterValue = new WeakMap(), _cache$2 = new WeakMap(), _defaultConfiguration = new WeakMap(), _defaultValue = new WeakMap(), _initConfiguration = new WeakMap(), _initValue = new WeakMap();
881
+ SdTableFilterService.decorators = [
882
+ { type: Injectable }
883
+ ];
884
+ SdTableFilterService.ctorParameters = () => [
885
+ { type: SdSettingService }
886
+ ];
887
+
888
+ var _gridId, _optionChanges, _localItems, _paginator, _sort, _subscription$1, _reload, _loadCompleted, _initCellDef, _initFilterDef, _initFooterDef, _filterExportInfo, _initConfiguration$1, _loadFilterRegister, _filterLocal, _getFilter, _load$1, _render, _exportedItems, _allColumns, _allExportedColumns, _onExport, _getExportColumns, _updateSelectedItems;
889
+ class SdTable {
890
+ constructor(ref, configuration, gridConfigurationService, exportService, notifyService, columnValuesPipe, gridFilterService) {
891
+ this.ref = ref;
892
+ this.configuration = configuration;
893
+ this.gridConfigurationService = gridConfigurationService;
894
+ this.exportService = exportService;
895
+ this.notifyService = notifyService;
896
+ this.columnValuesPipe = columnValuesPipe;
897
+ this.gridFilterService = gridFilterService;
898
+ _gridId.set(this, v4());
899
+ this.key = v4();
900
+ _optionChanges.set(this, new Subject());
901
+ _localItems.set(this, []);
902
+ this.items = [];
903
+ this.selectedItems = [];
904
+ // Loading
905
+ this.isLoading = false;
906
+ // Paginate
907
+ this.isHiddenPaginator = false;
908
+ _paginator.set(this, void 0);
909
+ // Sorting
910
+ _sort.set(this, void 0);
911
+ // Cell Def
912
+ this.sdCellDefs = new QueryList();
913
+ this.cellDef = {};
914
+ // Footer Def
915
+ this.sdFooterDefs = new QueryList();
916
+ this.footerDef = {};
917
+ this.hasFooter = false;
918
+ // Filter Def
919
+ this.sdFilterDefs = new QueryList();
920
+ this.filterDefs = [];
921
+ // Filter
922
+ this.columnOperator = {};
923
+ this.columnFilter = {};
924
+ // Subcription
925
+ _subscription$1.set(this, new Subscription());
926
+ _reload.set(this, new Subject());
927
+ this.isExporting = false;
928
+ this.isSelectAll = false;
929
+ this.exportTitle = 'Export';
930
+ _loadCompleted.set(this, false);
931
+ _initCellDef.set(this, () => {
932
+ this.cellDef = {};
933
+ for (const cellDef of this.sdCellDefs) {
934
+ if (cellDef.sdMaterialCellDef) {
935
+ this.cellDef[cellDef.sdMaterialCellDef] = cellDef;
936
+ }
937
+ }
938
+ });
939
+ _initFilterDef.set(this, () => {
940
+ this.filterDefs = [];
941
+ for (const filterDef of this.sdFilterDefs) {
942
+ this.filterDefs.push(filterDef);
943
+ }
944
+ });
945
+ _initFooterDef.set(this, () => {
946
+ this.footerDef = {};
947
+ this.hasFooter = false;
948
+ for (const footerDef of this.sdFooterDefs) {
949
+ if (footerDef.sdMaterialFooterDef) {
950
+ this.hasFooter = true;
951
+ this.footerDef[footerDef.sdMaterialFooterDef] = footerDef;
952
+ }
953
+ }
954
+ });
955
+ _filterExportInfo.set(this, (pageNumber, pageSize) => {
956
+ var _a, _b;
957
+ const { columnOperator, columnFilter, externalFilter, filterDef } = this.filterRegister.value.get();
958
+ return {
959
+ columnOperator: columnOperator || {},
960
+ rawColumnFilter: columnFilter || {},
961
+ rawExternalFilter: externalFilter || {},
962
+ rawFilterDef: filterDef || {},
963
+ orderBy: ((_a = __classPrivateFieldGet(this, _sort)) === null || _a === void 0 ? void 0 : _a.active) || '',
964
+ orderDirection: ((_b = __classPrivateFieldGet(this, _sort)) === null || _b === void 0 ? void 0 : _b.direction) || '',
965
+ pageNumber,
966
+ pageSize,
967
+ isExported: true,
968
+ };
969
+ });
970
+ _initConfiguration$1.set(this, (option) => {
971
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
972
+ // Init pagination
973
+ option.paginate = {
974
+ hidden: (_a = option === null || option === void 0 ? void 0 : option.paginate) === null || _a === void 0 ? void 0 : _a.hidden,
975
+ pageSize: (_f = (_c = (_b = option === null || option === void 0 ? void 0 : option.paginate) === null || _b === void 0 ? void 0 : _b.pageSize) !== null && _c !== void 0 ? _c : (_e = (_d = this.configuration) === null || _d === void 0 ? void 0 : _d.paginate) === null || _e === void 0 ? void 0 : _e.pageSize) !== null && _f !== void 0 ? _f : (_g = DEFAULT_TABLE_CONFIG.paginate) === null || _g === void 0 ? void 0 : _g.pageSize,
976
+ pages: (_m = (_j = (_h = option === null || option === void 0 ? void 0 : option.paginate) === null || _h === void 0 ? void 0 : _h.pages) !== null && _j !== void 0 ? _j : (_l = (_k = this.configuration) === null || _k === void 0 ? void 0 : _k.paginate) === null || _l === void 0 ? void 0 : _l.pages) !== null && _m !== void 0 ? _m : (_o = DEFAULT_TABLE_CONFIG.paginate) === null || _o === void 0 ? void 0 : _o.pages,
977
+ showFirstLastButtons: (_q = (_p = option === null || option === void 0 ? void 0 : option.paginate) === null || _p === void 0 ? void 0 : _p.showFirstLastButtons) !== null && _q !== void 0 ? _q : false,
978
+ };
979
+ return option;
980
+ });
981
+ _loadFilterRegister.set(this, () => {
982
+ var _a, _b, _c, _d;
983
+ // Init filter
984
+ if (this.gridOption) {
985
+ if (!this.filterRegister) {
986
+ this.filterRegister = this.gridFilterService.register((_a = this.gridOption) === null || _a === void 0 ? void 0 : _a.filter, {
987
+ id: __classPrivateFieldGet(this, _gridId),
988
+ columns: (_b = this.gridOption) === null || _b === void 0 ? void 0 : _b.columns,
989
+ externalFilters: (_d = (_c = this.gridOption) === null || _c === void 0 ? void 0 : _c.filter) === null || _d === void 0 ? void 0 : _d.externalFilters,
990
+ filterDefs: this.filterDefs,
991
+ });
992
+ __classPrivateFieldGet(this, _subscription$1).add(this.filterRegister.value.observer
993
+ .pipe(debounceTime(500), map(filterValue => {
994
+ const { columnOperator, columnFilter, notReload } = filterValue;
995
+ this.columnOperator = columnOperator;
996
+ this.columnFilter = columnFilter;
997
+ if (!notReload) {
998
+ __classPrivateFieldGet(this, _paginator).pageIndex = 0;
999
+ __classPrivateFieldGet(this, _reload).next({
1000
+ force: false,
1001
+ });
1002
+ }
1003
+ }))
1004
+ .subscribe());
1005
+ }
1006
+ }
1007
+ });
1008
+ _filterLocal.set(this, (localItems, filterInfo) => {
1009
+ const { columns } = this.gridOption;
1010
+ const { rawColumnFilter, orderBy, orderDirection, pageSize, pageNumber } = filterInfo;
1011
+ const items = localItems.filter(tableItem => {
1012
+ var _a, _b, _c, _d;
1013
+ const item = tableItem.current;
1014
+ for (const column of columns) {
1015
+ const { field, type } = column;
1016
+ const filterValue = (rawColumnFilter[field] || '').toString().trim().toLowerCase();
1017
+ const columnValue = (item[field] || '').toString().trim().toLowerCase();
1018
+ if (filterValue) {
1019
+ if (!columnValue && type !== 'datetime' && type !== 'date' && type !== 'time') {
1020
+ return false;
1021
+ }
1022
+ if (type === 'string') {
1023
+ if (columnValue.indexOf(filterValue) === -1) {
1024
+ return false;
1025
+ }
1026
+ }
1027
+ else if (type === 'values') {
1028
+ if (columnValue !== filterValue) {
1029
+ return false;
1030
+ }
1031
+ }
1032
+ else if (type === 'number') {
1033
+ const fValue = +filterValue.replace('>=', '').replace('<=', '').replace('>', '').replace('<', '');
1034
+ const cValue = +columnValue;
1035
+ if (fValue || fValue === 0) {
1036
+ if (!cValue && cValue !== 0) {
1037
+ return false;
1038
+ }
1039
+ if (filterValue.indexOf('>=') > -1 && cValue < fValue) {
1040
+ return false;
1041
+ }
1042
+ else if (filterValue.indexOf('<=') > -1 && cValue > fValue) {
1043
+ return false;
1044
+ }
1045
+ else if (filterValue.indexOf('<') > -1 && cValue >= fValue) {
1046
+ return false;
1047
+ }
1048
+ else if (filterValue.indexOf('>') > -1 && cValue <= fValue) {
1049
+ return false;
1050
+ }
1051
+ else if (cValue !== fValue) {
1052
+ return false;
1053
+ }
1054
+ }
1055
+ }
1056
+ else if (type === 'bool') {
1057
+ if (filterValue === '1' && columnValue !== '1' && columnValue !== 'true') {
1058
+ return false;
1059
+ }
1060
+ else if (filterValue === '0' && columnValue !== '0' && columnValue !== 'false') {
1061
+ return false;
1062
+ }
1063
+ }
1064
+ else if (type === 'datetime' || type === 'date' || type === 'time') {
1065
+ const from = (_b = (_a = rawColumnFilter[field]) === null || _a === void 0 ? void 0 : _a.from) !== null && _b !== void 0 ? _b : rawColumnFilter[field];
1066
+ const to = (_d = (_c = rawColumnFilter[field]) === null || _c === void 0 ? void 0 : _c.to) !== null && _d !== void 0 ? _d : rawColumnFilter[field];
1067
+ const fromDate = Date.begin(from);
1068
+ const toDate = Date.end(to);
1069
+ if (fromDate || toDate) {
1070
+ if (!columnValue) {
1071
+ return false;
1072
+ }
1073
+ const columnTime = new Date(columnValue).getTime();
1074
+ const fromDateTime = (fromDate === null || fromDate === void 0 ? void 0 : fromDate.getTime()) || null;
1075
+ const toDateTime = (toDate === null || toDate === void 0 ? void 0 : toDate.getTime()) || null;
1076
+ if (fromDateTime && fromDateTime > columnTime) {
1077
+ return false;
1078
+ }
1079
+ if (toDateTime && columnTime > toDateTime) {
1080
+ return false;
1081
+ }
1082
+ }
1083
+ }
1084
+ }
1085
+ }
1086
+ return true;
1087
+ });
1088
+ // Sort
1089
+ if (orderBy && orderDirection) {
1090
+ const column = columns.find(e => e.field === orderBy);
1091
+ if (column) {
1092
+ const { type, field } = column;
1093
+ items.sort((tableItemCurrent, tableItemNext) => {
1094
+ const current = tableItemCurrent.current;
1095
+ const next = tableItemNext.current;
1096
+ if (type === 'number') {
1097
+ return (current[field] || 0) - (next[field] || 0);
1098
+ }
1099
+ if (type === 'date' || type === 'datetime' || type === 'time') {
1100
+ const d1 = new Date(current[field] || '').getTime();
1101
+ const d2 = new Date(current[field] || '').getTime();
1102
+ return d1 - d2;
1103
+ }
1104
+ const s1 = (current[field] || '').toString();
1105
+ const s2 = (next[field] || '').toString();
1106
+ if (s1 > s2) {
1107
+ return 1;
1108
+ }
1109
+ if (s1 < s2) {
1110
+ return -1;
1111
+ }
1112
+ return 0;
1113
+ });
1114
+ if (orderDirection === 'desc') {
1115
+ items.reverse();
1116
+ }
1117
+ }
1118
+ }
1119
+ return {
1120
+ items: items.filter((item, index) => {
1121
+ return index >= pageNumber * pageSize && index < (pageNumber + 1) * pageSize;
1122
+ }),
1123
+ total: items.length,
1124
+ };
1125
+ });
1126
+ _getFilter.set(this, () => {
1127
+ var _a, _b, _c, _d, _e, _f;
1128
+ const { columnOperator, columnFilter, externalFilter, filterDef } = this.filterRegister.value.get();
1129
+ return {
1130
+ columnOperator: columnOperator || {},
1131
+ rawColumnFilter: columnFilter || {},
1132
+ rawExternalFilter: externalFilter || {},
1133
+ rawFilterDef: filterDef || {},
1134
+ orderBy: ((_a = __classPrivateFieldGet(this, _sort)) === null || _a === void 0 ? void 0 : _a.active) || '',
1135
+ orderDirection: ((_b = __classPrivateFieldGet(this, _sort)) === null || _b === void 0 ? void 0 : _b.direction) || '',
1136
+ pageNumber: ((_c = __classPrivateFieldGet(this, _paginator)) === null || _c === void 0 ? void 0 : _c.pageIndex) || 0,
1137
+ pageSize: ((_d = __classPrivateFieldGet(this, _paginator)) === null || _d === void 0 ? void 0 : _d.pageSize) || ((_f = (_e = this.gridOption) === null || _e === void 0 ? void 0 : _e.paginate) === null || _f === void 0 ? void 0 : _f.pageSize) || 50,
1138
+ };
1139
+ });
1140
+ _load$1.set(this, (filterReq, force = true) => __awaiter(this, void 0, void 0, function* () {
1141
+ this.isLoading = true;
1142
+ if (this.gridOption.type === 'server') {
1143
+ const { items } = this.gridOption;
1144
+ const data = yield items(filterReq).catch(err => {
1145
+ this.notifyService.notify.warning('Có lỗi xảy ra');
1146
+ console.error(err);
1147
+ return {
1148
+ items: [],
1149
+ total: 0,
1150
+ };
1151
+ });
1152
+ this.isLoading = false;
1153
+ return {
1154
+ items: (data === null || data === void 0 ? void 0 : data.items.map(MapToSdTableItem)) || [],
1155
+ total: (data === null || data === void 0 ? void 0 : data.total) || 0,
1156
+ };
1157
+ }
1158
+ if (force) {
1159
+ const { items } = this.gridOption;
1160
+ const results = items();
1161
+ let data = [];
1162
+ if (results instanceof Promise) {
1163
+ data = yield results.catch(err => {
1164
+ this.notifyService.notify.warning('Có lỗi xảy ra');
1165
+ console.error(err);
1166
+ return [];
1167
+ });
1168
+ }
1169
+ else {
1170
+ data = results;
1171
+ }
1172
+ if (!Array.isArray(data)) {
1173
+ this.notifyService.notify.warning('Dữ liệu không phải là một mảng');
1174
+ data = [];
1175
+ }
1176
+ __classPrivateFieldSet(this, _localItems, data.map(MapToSdTableItem));
1177
+ this.isLoading = false;
1178
+ }
1179
+ return __classPrivateFieldGet(this, _filterLocal).call(this, __classPrivateFieldGet(this, _localItems), filterReq);
1180
+ }));
1181
+ _render.set(this, (args) => __awaiter(this, void 0, void 0, function* () {
1182
+ var _a, _b, _c, _d;
1183
+ (_a = this.sdScroll) === null || _a === void 0 ? void 0 : _a.scrollTop();
1184
+ this.items = (args === null || args === void 0 ? void 0 : args.items) || [];
1185
+ this.total = (args === null || args === void 0 ? void 0 : args.total) || 0;
1186
+ yield ((_d = (_c = (_b = this.gridOption) === null || _b === void 0 ? void 0 : _b.reload) === null || _c === void 0 ? void 0 : _c.onReload) === null || _d === void 0 ? void 0 : _d.call(_c, this.items));
1187
+ this.isSelectAll = this.items.every(e => e.meta.selector.isSelected);
1188
+ __classPrivateFieldGet(this, _updateSelectedItems).call(this);
1189
+ }));
1190
+ this.reload = (force = true) => __awaiter(this, void 0, void 0, function* () {
1191
+ var _e, _f;
1192
+ (_f = (_e = this.gridFilter) === null || _e === void 0 ? void 0 : _e.updateFilter) === null || _f === void 0 ? void 0 : _f.call(_e);
1193
+ const data = yield __classPrivateFieldGet(this, _load$1).call(this, __classPrivateFieldGet(this, _getFilter).call(this), force);
1194
+ __classPrivateFieldGet(this, _render).call(this, data);
1195
+ });
1196
+ _exportedItems.set(this, (pageNumber = 0, pageSize = 10000) => __awaiter(this, void 0, void 0, function* () {
1197
+ var _g, _h;
1198
+ if ((_g = this.gridOption.export) === null || _g === void 0 ? void 0 : _g.items) {
1199
+ // const exportedItems = this.gridOption.export?.items(this.#filterExportInfo(pageNumber, pageSize));
1200
+ let result = (_h = this.gridOption.export) === null || _h === void 0 ? void 0 : _h.items(__classPrivateFieldGet(this, _filterExportInfo).call(this, pageNumber, pageSize));
1201
+ if (Array.isArray(result)) {
1202
+ return result;
1203
+ }
1204
+ if (isObservable(result)) {
1205
+ result = result.toPromise();
1206
+ }
1207
+ if (isObservable(result)) {
1208
+ result = result.toPromise();
1209
+ }
1210
+ return yield result;
1211
+ }
1212
+ else {
1213
+ const filterInfo = __classPrivateFieldGet(this, _filterExportInfo).call(this, pageNumber, pageSize);
1214
+ if (this.gridOption.type === 'server') {
1215
+ let result = this.gridOption.items(filterInfo);
1216
+ return yield result;
1217
+ }
1218
+ else {
1219
+ let exportedItems = [];
1220
+ if (typeof this.gridOption.items === 'function') {
1221
+ const results = this.gridOption.items();
1222
+ if (results instanceof Promise) {
1223
+ exportedItems = yield results;
1224
+ }
1225
+ else {
1226
+ exportedItems = results;
1227
+ }
1228
+ }
1229
+ else {
1230
+ exportedItems = this.gridOption.items;
1231
+ }
1232
+ return __classPrivateFieldGet(this, _filterLocal).call(this, exportedItems, filterInfo);
1233
+ }
1234
+ }
1235
+ }));
1236
+ _allColumns.set(this, () => {
1237
+ const columns = [];
1238
+ this.gridOption.columns
1239
+ .filter(e => { var _a; return !((_a = e.export) === null || _a === void 0 ? void 0 : _a.disabled); })
1240
+ .forEach(column => {
1241
+ var _a;
1242
+ if (column.type === 'children') {
1243
+ (_a = column.children) === null || _a === void 0 ? void 0 : _a.filter(e => { var _a; return !((_a = e.export) === null || _a === void 0 ? void 0 : _a.disabled); }).forEach(childColumn => {
1244
+ columns.push(childColumn);
1245
+ });
1246
+ return;
1247
+ }
1248
+ columns.push(column);
1249
+ });
1250
+ return columns;
1251
+ });
1252
+ _allExportedColumns.set(this, () => {
1253
+ var _a, _b;
1254
+ return ((_b = (_a = this.gridOption.export) === null || _a === void 0 ? void 0 : _a.columns) === null || _b === void 0 ? void 0 : _b.filter(e => { var _a; return !((_a = e.export) === null || _a === void 0 ? void 0 : _a.disabled); })) || [];
1255
+ });
1256
+ _onExport.set(this, (isCSV) => __awaiter(this, void 0, void 0, function* () {
1257
+ var _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
1258
+ try {
1259
+ let columns = __classPrivateFieldGet(this, _getExportColumns).call(this);
1260
+ const pageSize = ((_k = (_j = this.gridOption) === null || _j === void 0 ? void 0 : _j.export) === null || _k === void 0 ? void 0 : _k.maxItemsPerRequest) || 1000;
1261
+ const batch = ((_m = (_l = this.gridOption) === null || _l === void 0 ? void 0 : _l.export) === null || _m === void 0 ? void 0 : _m.batch) || 1;
1262
+ let total = this.total;
1263
+ let pageNumber = 0;
1264
+ let exportItems = [];
1265
+ this.isExporting = true;
1266
+ const items = [];
1267
+ let promises = [];
1268
+ const handleData = () => __awaiter(this, void 0, void 0, function* () {
1269
+ var _u;
1270
+ const results = yield Promise.all(promises);
1271
+ promises = [];
1272
+ exportItems = [];
1273
+ for (const result of results) {
1274
+ if ('items' in result) {
1275
+ exportItems = [...exportItems, ...result.items];
1276
+ total = result.total;
1277
+ }
1278
+ else {
1279
+ exportItems = [...exportItems, ...result];
1280
+ }
1281
+ }
1282
+ if ((_u = this.gridOption.export) === null || _u === void 0 ? void 0 : _u.mapping) {
1283
+ const results = this.gridOption.export.mapping(exportItems);
1284
+ if (results instanceof Promise) {
1285
+ exportItems = yield results;
1286
+ }
1287
+ else {
1288
+ exportItems = results;
1289
+ }
1290
+ }
1291
+ const totalPage = total / pageSize;
1292
+ const percent = Math.round(((pageNumber - 1) * 100.0) / totalPage);
1293
+ this.exportTitle = `Exporting...${percent}%`;
1294
+ const allColumns = __classPrivateFieldGet(this, _allColumns).call(this);
1295
+ const allExportedColumns = __classPrivateFieldGet(this, _allExportedColumns).call(this);
1296
+ for (const item of exportItems) {
1297
+ const obj = {};
1298
+ const handle = (exportColumn) => __awaiter(this, void 0, void 0, function* () {
1299
+ var _v, _w, _x;
1300
+ obj[exportColumn.field] = item[exportColumn.field];
1301
+ const column = allColumns.find(e => e.field === exportColumn.field);
1302
+ const exportedColumn = allExportedColumns.find(e => e.field === exportColumn.field);
1303
+ if (exportedColumn === null || exportedColumn === void 0 ? void 0 : exportedColumn.transform) {
1304
+ obj[exportedColumn.field] = exportedColumn.transform(item[exportedColumn.field], item);
1305
+ return;
1306
+ }
1307
+ if (!column) {
1308
+ return;
1309
+ }
1310
+ if (column.type === 'children') {
1311
+ column === null || column === void 0 ? void 0 : column.children.forEach(childColumn => handle(childColumn));
1312
+ return;
1313
+ }
1314
+ if (!columns.some(e => e.field === column.field)) {
1315
+ return;
1316
+ }
1317
+ if (column.transform) {
1318
+ const transform = column.transform(item[column.field], item, {
1319
+ isExport: true,
1320
+ });
1321
+ if (transform instanceof Promise) {
1322
+ obj[column.field] = yield transform;
1323
+ }
1324
+ else {
1325
+ obj[column.field] = transform;
1326
+ }
1327
+ obj[column.field] = (_v = obj[column.field]) !== null && _v !== void 0 ? _v : '';
1328
+ }
1329
+ else if (item[column.field] === undefined || item[column.field] === null || item[column.field] === '') {
1330
+ obj[column.field] = '';
1331
+ }
1332
+ else if (column.type === 'string' || column.type === 'number') {
1333
+ // Nếu cell là string hoặc number thì gán bằng chính nó
1334
+ obj[column.field] = item[column.field];
1335
+ }
1336
+ else if (column.type === 'bool') {
1337
+ // Nếu là bool thì gán bằng giá trị trueValue và falseValue (nếu có), mặc định là TRUE/FALSE
1338
+ if (item[column.field]) {
1339
+ obj[column.field] = ((_w = column.option) === null || _w === void 0 ? void 0 : _w.displayOnTrue) || 'True';
1340
+ }
1341
+ else if (obj[column.field] !== undefined && obj[column.field] !== null) {
1342
+ obj[column.field] = ((_x = column.option) === null || _x === void 0 ? void 0 : _x.displayOnFalse) || 'False';
1343
+ }
1344
+ }
1345
+ else if (column.type === 'date') {
1346
+ let date = item[column.field];
1347
+ const { transformDate } = column;
1348
+ if (transformDate) {
1349
+ date = transformDate(date, item);
1350
+ }
1351
+ // Nếu là date thì convert theo đúng format
1352
+ obj[column.field] = Date.toFormat(date, 'dd/MM/yyyy');
1353
+ }
1354
+ else if (column.type === 'datetime') {
1355
+ let date = item[column.field];
1356
+ const { transformDate } = column;
1357
+ if (transformDate) {
1358
+ date = transformDate(date, item);
1359
+ }
1360
+ // Nếu là datetime thì convert theo đúng format
1361
+ obj[column.field] = Date.toFormat(date, 'dd/MM/yyyy HH:mm');
1362
+ }
1363
+ else if (column.type === 'time') {
1364
+ let date = item[column.field];
1365
+ const { transformDate } = column;
1366
+ if (transformDate) {
1367
+ date = transformDate(date, item);
1368
+ }
1369
+ // Nếu là time thì convert theo đúng format
1370
+ obj[column.field] = Date.toFormat(date, 'HH:mm');
1371
+ }
1372
+ else if (column.type === 'values') {
1373
+ // Nếu là values thì lấy giá trị của value được chọn
1374
+ obj[column.field] = yield this.columnValuesPipe.transform(item[column.field], column);
1375
+ }
1376
+ else {
1377
+ obj[column.field] = item[column.field];
1378
+ }
1379
+ });
1380
+ // this.gridOption.columns.forEach(handle);
1381
+ for (const exportColumn of columns) {
1382
+ yield handle(exportColumn);
1383
+ }
1384
+ items.push(obj);
1385
+ }
1386
+ });
1387
+ while (pageNumber * pageSize < total) {
1388
+ promises.push(__classPrivateFieldGet(this, _exportedItems).call(this, pageNumber, pageSize));
1389
+ pageNumber++;
1390
+ if (promises.length < batch) {
1391
+ continue;
1392
+ }
1393
+ yield handleData();
1394
+ }
1395
+ if (promises.length > 0) {
1396
+ yield handleData();
1397
+ }
1398
+ if (isCSV) {
1399
+ yield this.exportService.exportCSV({
1400
+ columns,
1401
+ items,
1402
+ fileName: (_p = (_o = this.gridOption) === null || _o === void 0 ? void 0 : _o.export) === null || _p === void 0 ? void 0 : _p.fileName,
1403
+ });
1404
+ return;
1405
+ }
1406
+ const sheets = [];
1407
+ if (Array.isArray((_r = (_q = this.gridOption) === null || _q === void 0 ? void 0 : _q.export) === null || _r === void 0 ? void 0 : _r.sheets)) {
1408
+ for (const sheet of this.gridOption.export.sheets) {
1409
+ if (sheet.name && sheet.items && sheet.fields) {
1410
+ if (Array.isArray(sheet.items)) {
1411
+ sheets.push({
1412
+ name: sheet.name,
1413
+ items: sheet.items,
1414
+ fields: sheet.fields,
1415
+ });
1416
+ }
1417
+ else {
1418
+ sheets.push({
1419
+ name: sheet.name,
1420
+ items: yield sheet.items(),
1421
+ fields: sheet.fields,
1422
+ });
1423
+ }
1424
+ }
1425
+ }
1426
+ }
1427
+ yield this.exportService.export({
1428
+ columns,
1429
+ items,
1430
+ fileName: (_t = (_s = this.gridOption) === null || _s === void 0 ? void 0 : _s.export) === null || _t === void 0 ? void 0 : _t.fileName,
1431
+ sheets,
1432
+ });
1433
+ return;
1434
+ }
1435
+ finally {
1436
+ this.isExporting = false;
1437
+ this.exportTitle = `Export`;
1438
+ this.ref.detectChanges();
1439
+ }
1440
+ }));
1441
+ _getExportColumns.set(this, () => {
1442
+ var _a, _b;
1443
+ const columns = [
1444
+ ...this.gridOption.columns.filter(e => { var _a; return !((_a = e.export) === null || _a === void 0 ? void 0 : _a.disabled); }),
1445
+ ...(((_b = (_a = this.gridOption.export) === null || _a === void 0 ? void 0 : _a.columns) === null || _b === void 0 ? void 0 : _b.filter(e => { var _a; return !((_a = e.export) === null || _a === void 0 ? void 0 : _a.disabled); })) || []),
1446
+ ];
1447
+ return columns;
1448
+ });
1449
+ this.exportExcel = () => {
1450
+ __classPrivateFieldGet(this, _onExport).call(this);
1451
+ };
1452
+ this.exportCSV = () => {
1453
+ __classPrivateFieldGet(this, _onExport).call(this, true);
1454
+ };
1455
+ this.onFilterChange = () => {
1456
+ var _a, _b, _c, _d;
1457
+ (_b = (_a = this.gridFilter) === null || _a === void 0 ? void 0 : _a.updateFilter) === null || _b === void 0 ? void 0 : _b.call(_a);
1458
+ if ((_d = (_c = this.gridOption) === null || _c === void 0 ? void 0 : _c.filter) === null || _d === void 0 ? void 0 : _d.inlineColumn) {
1459
+ this.filterRegister.value.set({
1460
+ columnOperator: this.columnOperator,
1461
+ columnFilter: this.columnFilter,
1462
+ });
1463
+ }
1464
+ else {
1465
+ this.filterRegister.value.set({});
1466
+ }
1467
+ };
1468
+ this.onExpand = (rowData) => __awaiter(this, void 0, void 0, function* () {
1469
+ var _y, _z, _0, _1, _2;
1470
+ if ((_y = this.gridOption.expand) === null || _y === void 0 ? void 0 : _y.always) {
1471
+ return;
1472
+ }
1473
+ if (rowData.meta.expand.isExpanding) {
1474
+ return;
1475
+ }
1476
+ if (rowData.meta.expand.isExpanded) {
1477
+ rowData.meta.expand.isExpanded = false;
1478
+ return;
1479
+ }
1480
+ const data = (_1 = (_0 = (_z = this.gridOption) === null || _z === void 0 ? void 0 : _z.expand) === null || _0 === void 0 ? void 0 : _0.onExpand) === null || _1 === void 0 ? void 0 : _1.call(_0, rowData.current);
1481
+ if (!((_2 = this.gridOption.expand) === null || _2 === void 0 ? void 0 : _2.multiple)) {
1482
+ this.items.forEach(item => (item.meta.expand.isExpanding = item.meta.expand.isExpanded = false));
1483
+ }
1484
+ if (data instanceof Promise) {
1485
+ rowData.meta.expand.isExpanding = true;
1486
+ data
1487
+ .then(res => {
1488
+ rowData.meta.expand.data = res;
1489
+ rowData.meta.expand.isExpanded = true;
1490
+ })
1491
+ .finally(() => (rowData.meta.expand.isExpanding = false));
1492
+ }
1493
+ else {
1494
+ rowData.meta.expand.data = data;
1495
+ rowData.meta.expand.isExpanded = true;
1496
+ }
1497
+ });
1498
+ this.onSelect = (rowData) => {
1499
+ var _a, _b, _c, _d, _e, _f, _g;
1500
+ if ((_b = (_a = rowData.meta.group) === null || _a === void 0 ? void 0 : _a.items) === null || _b === void 0 ? void 0 : _b.length) {
1501
+ rowData.meta.group.items.forEach(e => (e.meta.selector.isSelected = rowData.meta.selector.isSelected));
1502
+ (_d = (_c = this.gridOption.selector) === null || _c === void 0 ? void 0 : _c.onSelect) === null || _d === void 0 ? void 0 : _d.call(_c, rowData.current, this.items.filter(e => e.meta.selector.isSelected).map(e => e.current));
1503
+ this.isSelectAll = this.items.every(e => e.meta.selector.isSelected);
1504
+ __classPrivateFieldGet(this, _updateSelectedItems).call(this);
1505
+ }
1506
+ else {
1507
+ if ((_e = this.gridOption.selector) === null || _e === void 0 ? void 0 : _e.single) {
1508
+ this.items.filter(e => e !== rowData).forEach(e => (e.meta.selector.isSelected = false));
1509
+ __classPrivateFieldGet(this, _updateSelectedItems).call(this);
1510
+ return;
1511
+ }
1512
+ (_g = (_f = this.gridOption.selector) === null || _f === void 0 ? void 0 : _f.onSelect) === null || _g === void 0 ? void 0 : _g.call(_f, rowData.current, this.items.filter(e => e.meta.selector.isSelected).map(e => e.current));
1513
+ this.isSelectAll = this.items.every(e => e.meta.selector.isSelected);
1514
+ __classPrivateFieldGet(this, _updateSelectedItems).call(this);
1515
+ }
1516
+ };
1517
+ this.onSelectAll = () => {
1518
+ var _a, _b, _c;
1519
+ (_a = this.items) === null || _a === void 0 ? void 0 : _a.forEach(e => {
1520
+ var _a, _b, _c, _d;
1521
+ if (e.meta.selector.selectable && (!((_c = (_b = (_a = this.gridOption) === null || _a === void 0 ? void 0 : _a.selector) === null || _b === void 0 ? void 0 : _b.actions) === null || _c === void 0 ? void 0 : _c.length) || ((_d = e.meta.selector.actions) === null || _d === void 0 ? void 0 : _d.length))) {
1522
+ e.meta.selector.isSelected = this.isSelectAll;
1523
+ }
1524
+ });
1525
+ (_c = (_b = this.gridOption.selector) === null || _b === void 0 ? void 0 : _b.onSelectAll) === null || _c === void 0 ? void 0 : _c.call(_b, this.items.filter(e => e.meta.selector.isSelected).map(e => e.current));
1526
+ __classPrivateFieldGet(this, _updateSelectedItems).call(this);
1527
+ };
1528
+ this.onClearSelection = (items) => {
1529
+ items = items || this.items;
1530
+ this.isSelectAll = false;
1531
+ items === null || items === void 0 ? void 0 : items.forEach(e => (e.meta.selector.isSelected = false));
1532
+ __classPrivateFieldGet(this, _updateSelectedItems).call(this);
1533
+ };
1534
+ _updateSelectedItems.set(this, () => {
1535
+ this.selectedItems = this.items.filter(item => item.meta.selector.isSelected).map(item => item.current);
1536
+ this.ref.detectChanges();
1537
+ });
1538
+ this.clearFilter = () => {
1539
+ this.filterRegister.value.remove();
1540
+ };
1541
+ this.setFilter = (args) => {
1542
+ var _a, _b;
1543
+ const { columnFilter, externalFilter, filterDef } = args || {};
1544
+ if (((_b = (_a = this.gridOption) === null || _a === void 0 ? void 0 : _a.filter) === null || _b === void 0 ? void 0 : _b.inlineColumn) && columnFilter) {
1545
+ this.columnFilter = columnFilter;
1546
+ }
1547
+ this.filterRegister.value.set({
1548
+ columnFilter,
1549
+ externalFilter,
1550
+ filterDef,
1551
+ });
1552
+ };
1553
+ this.detectChanges = () => this.ref.detectChanges();
1554
+ }
1555
+ set _gridFilter(gridFilter) {
1556
+ if (gridFilter && this.gridFilter !== gridFilter) {
1557
+ this.gridFilter = gridFilter;
1558
+ // this.#subscription.add(gridFilter.filterChange.pipe(
1559
+ // filter(reload => reload),
1560
+ // debounceTime(500),
1561
+ // map(() => {
1562
+ // this.#paginator.pageIndex = 0;
1563
+ // this.#reload.next({
1564
+ // force: false,
1565
+ // source: 'FILTER'
1566
+ // });
1567
+ // }),
1568
+ // ).subscribe());
1569
+ }
1570
+ }
1571
+ set option(option) {
1572
+ if (option) {
1573
+ option = __classPrivateFieldGet(this, _initConfiguration$1).call(this, option);
1574
+ this.gridOption = option;
1575
+ __classPrivateFieldSet(this, _loadCompleted, false);
1576
+ const configuration = this.gridConfigurationService.init(this.key, this.gridOption);
1577
+ this.gridConfigurationObserver = configuration.observer;
1578
+ configuration.load();
1579
+ __classPrivateFieldGet(this, _optionChanges).next(this.gridOption);
1580
+ }
1581
+ }
1582
+ set paginator(paginator) {
1583
+ if (paginator && __classPrivateFieldGet(this, _paginator) !== paginator) {
1584
+ __classPrivateFieldSet(this, _paginator, paginator);
1585
+ __classPrivateFieldGet(this, _subscription$1).add(paginator.page
1586
+ .pipe(map(() => {
1587
+ __classPrivateFieldGet(this, _reload).next({
1588
+ force: false,
1589
+ });
1590
+ }))
1591
+ .subscribe());
1592
+ }
1593
+ }
1594
+ set sort(sort) {
1595
+ if (sort && __classPrivateFieldGet(this, _sort) !== sort) {
1596
+ __classPrivateFieldSet(this, _sort, sort);
1597
+ __classPrivateFieldGet(this, _subscription$1).add(sort.sortChange
1598
+ .pipe(map(() => {
1599
+ __classPrivateFieldGet(this, _reload).next({
1600
+ force: false,
1601
+ });
1602
+ }))
1603
+ .subscribe());
1604
+ }
1605
+ }
1606
+ ngOnInit() {
1607
+ __classPrivateFieldGet(this, _initCellDef).call(this);
1608
+ }
1609
+ ngAfterViewInit() {
1610
+ __classPrivateFieldGet(this, _subscription$1).add(__classPrivateFieldGet(this, _reload).pipe(debounceTime(200), switchMap((data) => __awaiter(this, void 0, void 0, function* () {
1611
+ const filterInfo = __classPrivateFieldGet(this, _getFilter).call(this);
1612
+ const result = yield __classPrivateFieldGet(this, _load$1).call(this, filterInfo, !__classPrivateFieldGet(this, _loadCompleted) || data.force);
1613
+ __classPrivateFieldSet(this, _loadCompleted, true);
1614
+ return result;
1615
+ })))
1616
+ .subscribe(__classPrivateFieldGet(this, _render)));
1617
+ __classPrivateFieldGet(this, _subscription$1).add(this.sdCellDefs.changes.pipe(startWith([])).subscribe(__classPrivateFieldGet(this, _initCellDef)));
1618
+ __classPrivateFieldGet(this, _subscription$1).add(this.sdFooterDefs.changes.pipe(startWith([])).subscribe(__classPrivateFieldGet(this, _initFooterDef)));
1619
+ __classPrivateFieldGet(this, _subscription$1).add(this.sdFilterDefs.changes.pipe(startWith([])).subscribe(__classPrivateFieldGet(this, _initFilterDef)));
1620
+ __classPrivateFieldGet(this, _subscription$1).add(combineLatest([
1621
+ __classPrivateFieldGet(this, _optionChanges).pipe(startWith(this.gridOption)),
1622
+ this.sdFilterDefs.changes.pipe(startWith(this.filterDefs)),
1623
+ ]).subscribe(() => {
1624
+ __classPrivateFieldGet(this, _loadFilterRegister).call(this);
1625
+ }));
1626
+ __classPrivateFieldGet(this, _subscription$1).add(__classPrivateFieldGet(this, _optionChanges).subscribe(() => {
1627
+ if (this.filterRegister) {
1628
+ __classPrivateFieldGet(this, _reload).next({
1629
+ force: true,
1630
+ });
1631
+ }
1632
+ }));
1633
+ this.ref.detectChanges();
1634
+ }
1635
+ ngOnDestroy() {
1636
+ __classPrivateFieldGet(this, _subscription$1).unsubscribe();
1637
+ }
1638
+ get gridItems() {
1639
+ return this.items.map(item => item.current);
1640
+ }
1641
+ }
1642
+ _gridId = new WeakMap(), _optionChanges = new WeakMap(), _localItems = new WeakMap(), _paginator = new WeakMap(), _sort = new WeakMap(), _subscription$1 = new WeakMap(), _reload = new WeakMap(), _loadCompleted = new WeakMap(), _initCellDef = new WeakMap(), _initFilterDef = new WeakMap(), _initFooterDef = new WeakMap(), _filterExportInfo = new WeakMap(), _initConfiguration$1 = new WeakMap(), _loadFilterRegister = new WeakMap(), _filterLocal = new WeakMap(), _getFilter = new WeakMap(), _load$1 = new WeakMap(), _render = new WeakMap(), _exportedItems = new WeakMap(), _allColumns = new WeakMap(), _allExportedColumns = new WeakMap(), _onExport = new WeakMap(), _getExportColumns = new WeakMap(), _updateSelectedItems = new WeakMap();
1643
+ SdTable.decorators = [
1644
+ { type: Component, args: [{
1645
+ selector: 'sd-table',
1646
+ template: "<ng-container *ngIf=\"gridConfigurationObserver | async as gridConfiguration\">\r\n <ng-container *ngIf=\"gridConfiguration | sdGridConfigurationResult : gridOption : sdSubInformation as configuration\">\r\n <sd-grid-filter\r\n *ngIf=\"!gridOption.filter?.disabled && filterRegister\"\r\n [filterRegister]=\"filterRegister\"\r\n [filter]=\"gridOption?.filter\"\r\n [columns]=\"configuration.firstColumns\"\r\n [externalFilters]=\"gridOption?.filter?.externalFilters\"\r\n [filterDefs]=\"filterDefs\"\r\n #gridFilter>\r\n </sd-grid-filter>\r\n <ng-container *ngIf=\"items | sdGroup : gridOption; $implicit as groupedItems\">\r\n <div class=\"c-container\">\r\n <div class=\"c-loading\" *ngIf=\"isLoading\">\r\n <mat-spinner *ngIf=\"isLoading\"></mat-spinner>\r\n </div>\r\n <ng-container>\r\n <div\r\n class=\"c-table\"\r\n sdScroll\r\n [ngStyle]=\"{\r\n 'max-height': gridOption?.style?.maxHeight,\r\n 'min-height': gridOption?.style?.minHeight\r\n }\">\r\n <table\r\n *ngIf=\"items?.length; else elseEmpty\"\r\n mat-table\r\n [dataSource]=\"groupedItems\"\r\n matSort\r\n [matSortDisabled]=\"!gridOption.sort?.enable\"\r\n multiTemplateDataRows>\r\n <ng-container matColumnDef=\"sdSubInformation\" sticky>\r\n <td class=\"p-0\" mat-cell *matCellDef=\"let item\" [attr.colspan]=\"configuration.displayedColumns.length\">\r\n <ng-container *ngIf=\"sdSubInformation?.templateRef\">\r\n <ng-container *ngIf=\"gridOption?.expand?.always; else useExpandCollapse\">\r\n <ng-container *ngTemplateOutlet=\"sdSubInformation.templateRef; context: { item: item }\"> </ng-container>\r\n </ng-container>\r\n <ng-template #useExpandCollapse>\r\n <div [@detailExpand]=\"item.isExpanded ? 'expanded' : 'collapsed'\">\r\n <ng-container *ngIf=\"item.isExpanded\">\r\n <ng-container *ngTemplateOutlet=\"sdSubInformation.templateRef; context: { item: item }\"> </ng-container>\r\n </ng-container>\r\n </div>\r\n </ng-template>\r\n </ng-container>\r\n </td>\r\n <td mat-footer-cell *matFooterCellDef></td>\r\n </ng-container>\r\n <ng-container matColumnDef=\"sdSubInformationAction\" stickyEnd>\r\n <th\r\n class=\"p-0\"\r\n mat-header-cell\r\n *matHeaderCellDef\r\n style=\"width: 1px\"\r\n [attr.rowspan]=\"configuration.multipleHeader ? 2 : 1\"></th>\r\n <td mat-cell *matCellDef=\"let element\">\r\n <button\r\n *ngIf=\"!element.isExpanding && !gridOption?.expand?.always\"\r\n mat-icon-button\r\n aria-label=\"Expand & Collapse\"\r\n (click)=\"onExpand(element)\">\r\n <mat-icon *ngIf=\"!element.isExpanded\">expand_more</mat-icon>\r\n <mat-icon *ngIf=\"element.isExpanded\">expand_less</mat-icon>\r\n </button>\r\n <div *ngIf=\"element.isExpanding\" class=\"lds-ring\">\r\n <div></div>\r\n <div></div>\r\n <div></div>\r\n <div></div>\r\n </div>\r\n </td>\r\n </ng-container>\r\n <ng-container matColumnDef=\"sdSelection\" sticky>\r\n <th\r\n class=\"text-center px-15\"\r\n mat-header-cell\r\n *matHeaderCellDef\r\n style=\"min-width: 50px; max-width: 50px\"\r\n [attr.rowspan]=\"configuration.multipleHeader ? 2 : 1\">\r\n <ng-container *ngIf=\"items | selectionVisibleSelectAll : gridOption?.selector | async\">\r\n <mat-checkbox\r\n *ngIf=\"!gridOption.selector?.single\"\r\n class=\"c-selection\"\r\n color=\"primary\"\r\n [(ngModel)]=\"isSelectAll\"\r\n (change)=\"onSelectAll()\">\r\n </mat-checkbox>\r\n </ng-container>\r\n </th>\r\n <td class=\"text-center px-15\" mat-cell *matCellDef=\"let item\" style=\"min-width: 50px; max-width: 50px\">\r\n <ng-container *ngIf=\"item | selectionVisible : gridOption?.selector\">\r\n <mat-checkbox\r\n class=\"c-selection\"\r\n color=\"primary\"\r\n [(ngModel)]=\"item.isSelected\"\r\n (change)=\"onSelect(item)\"\r\n [disabled]=\"selectedItems | selectionDisable : item : gridOption?.selector\">\r\n </mat-checkbox>\r\n </ng-container>\r\n </td>\r\n <td mat-footer-cell *matFooterCellDef></td>\r\n </ng-container>\r\n <ng-container matColumnDef=\"sdCommand\">\r\n <th\r\n class=\"px-8 py-8\"\r\n mat-header-cell\r\n *matHeaderCellDef\r\n style=\"width: 50px\"\r\n [attr.rowspan]=\"configuration.multipleHeader ? 2 : 1\"></th>\r\n <td class=\"px-8\" mat-cell *matCellDef=\"let item\">\r\n <sd-desktop-command [commands]=\"gridOption.commands\" [item]=\"item\"></sd-desktop-command>\r\n </td>\r\n <td mat-footer-cell *matFooterCellDef></td>\r\n </ng-container>\r\n <ng-container matColumnDef=\"sdGroup\">\r\n <th mat-header-cell *matHeaderCellDef class=\"px-8 py-8\" [attr.rowspan]=\"configuration.multipleHeader ? 2 : 1\"></th>\r\n <td class=\"p-0\" mat-cell *matCellDef=\"let item\" [attr.colspan]=\"!item?.sdGroup ? 1 : configuration.displayedColumns.length\">\r\n <div [innerHtml]=\"item?.sdGroup?.htmlTemplate | safeHtml\"></div>\r\n </td>\r\n <td mat-footer-cell *matFooterCellDef></td>\r\n </ng-container>\r\n <ng-container\r\n *ngFor=\"let column of configuration.firstColumns; let i = index\"\r\n [matColumnDef]=\"column.field\"\r\n [sticky]=\"configuration.fixedColumn[column.field]\">\r\n <th\r\n mat-header-cell\r\n *matHeaderCellDef\r\n cdkDrag\r\n class=\"px-8 py-8 c-th\"\r\n [ngStyle]=\"{ 'min-width': configuration.firstColumns[i].width }\"\r\n [attr.rowspan]=\"configuration.multipleHeader && column.type !== 'children-col' ? 2 : 1\"\r\n [attr.colspan]=\"column.type === 'children-col' ? column.children?.length : 1\">\r\n <div>\r\n <div\r\n aria-hidden=\"false\"\r\n role=\"presentation\"\r\n mat-sort-header\r\n [disabled]=\"!column.sortable || column.type === 'children-col'\"\r\n [class.text-right]=\"column.align === 'right' || (!column.align && column.type === 'number')\"\r\n [class.text-center]=\"column.align === 'center'\"\r\n [innerHTML]=\"configuration.firstColumns[i].titleHtml || configuration.firstColumns[i].title\"></div>\r\n <sd-column-inline-filter\r\n *ngIf=\"gridOption.filter?.inlineColumn\"\r\n [value]=\"columnFilter[column.field]\"\r\n [columnOperator]=\"columnOperator\"\r\n [columnFilter]=\"columnFilter\"\r\n [column]=\"column\"\r\n (filterChange)=\"onFilterChange()\">\r\n </sd-column-inline-filter>\r\n </div>\r\n </th>\r\n <td class=\"c-td px-0\" mat-cell *matCellDef=\"let item\">\r\n <sd-desktop-cell\r\n class=\"d-block px-8\"\r\n *ngIf=\"!item?.sdGroup\"\r\n [sdId]=\"item.meta.id\"\r\n [key]=\"key\"\r\n [value]=\"item[column.field]\"\r\n [column]=\"column\"\r\n [item]=\"item\"\r\n [idx]=\"i\"\r\n [cellDef]=\"cellDef\"\r\n [gridOption]=\"gridOption\">\r\n </sd-desktop-cell>\r\n </td>\r\n <td mat-footer-cell *matFooterCellDef>\r\n <ng-container *ngIf=\"footerDef[column.field]\">\r\n <ng-container *ngTemplateOutlet=\"footerDef[column.field].templateRef; context: { items: items, column: column }\">\r\n </ng-container>\r\n </ng-container>\r\n </td>\r\n </ng-container>\r\n <ng-container *ngFor=\"let column of configuration.secondColumns; let i = index\" [matColumnDef]=\"column.field\">\r\n <th mat-header-cell *matHeaderCellDef mat-sort-header class=\"c-th px-8\" [ngStyle]=\"{ 'min-width': column.width }\">\r\n <div>\r\n <div\r\n [class.text-right]=\"column.align === 'right' || (!column.align && column.type === 'number')\"\r\n [class.text-center]=\"column.align === 'center'\"\r\n [innerHTML]=\"column.titleHtml || column.title\"></div>\r\n <sd-column-inline-filter\r\n *ngIf=\"gridOption.filter?.inlineColumn\"\r\n [value]=\"columnFilter[column.field]\"\r\n [columnFilter]=\"columnFilter\"\r\n [column]=\"column\"\r\n (filterChange)=\"onFilterChange()\">\r\n </sd-column-inline-filter>\r\n </div>\r\n </th>\r\n <td class=\"c-td px-0\" mat-cell *matCellDef=\"let item\">\r\n <sd-desktop-cell\r\n class=\"d-block px-8\"\r\n [sdId]=\"item.meta.id\"\r\n [key]=\"key\"\r\n [value]=\"item[column.field]\"\r\n [column]=\"column\"\r\n [item]=\"item\"\r\n [idx]=\"i\"\r\n [cellDef]=\"cellDef\"\r\n [gridOption]=\"gridOption\">\r\n </sd-desktop-cell>\r\n </td>\r\n <td mat-footer-cell *matFooterCellDef>\r\n <ng-container *ngIf=\"footerDef[column.field]\">\r\n <ng-container *ngTemplateOutlet=\"footerDef[column.field].templateRef; context: { items: items, column: column }\">\r\n </ng-container>\r\n </ng-container>\r\n </td>\r\n </ng-container>\r\n <tr class=\"c-first-header\" mat-header-row *matHeaderRowDef=\"configuration.firstHeaders; sticky: true\"></tr>\r\n <ng-container *ngIf=\"configuration.secondHeaders?.length\">\r\n <tr class=\"c-second-header\" mat-header-row *matHeaderRowDef=\"configuration.secondHeaders; sticky: true\"></tr>\r\n </ng-container>\r\n <tr\r\n mat-row\r\n *matRowDef=\"let row; columns: configuration.displayedColumns\"\r\n matRipple\r\n class=\"c-row\"\r\n [class.selected]=\"row.isSelected\"></tr>\r\n\r\n <tr mat-row *matRowDef=\"let row; columns: ['sdSubInformation']\" class=\"c-detail-row\"></tr>\r\n <ng-container *ngIf=\"hasFooter && configuration.displayedFooters?.length\">\r\n <tr mat-footer-row *matFooterRowDef=\"configuration.displayedFooters; sticky: true\"></tr>\r\n </ng-container>\r\n </table>\r\n <ng-template #elseEmpty>\r\n <table mat-table [dataSource]=\"[{}]\">\r\n <ng-container matColumnDef=\"sdSelection\" sticky>\r\n <th\r\n class=\"px-15\"\r\n mat-header-cell\r\n *matHeaderCellDef\r\n style=\"min-width: 50px; max-width: 50px\"\r\n [attr.rowspan]=\"configuration.multipleHeader ? 2 : 1\"></th>\r\n </ng-container>\r\n <ng-container matColumnDef=\"sdCommand\">\r\n <th\r\n class=\"px-8\"\r\n mat-header-cell\r\n *matHeaderCellDef\r\n style=\"min-width: 50px; max-width: 50px\"\r\n [attr.rowspan]=\"configuration.multipleHeader ? 2 : 1\"></th>\r\n </ng-container>\r\n <ng-container matColumnDef=\"sdSubInformationAction\">\r\n <th\r\n class=\"p-0\"\r\n mat-header-cell\r\n *matHeaderCellDef\r\n style=\"width: 1px\"\r\n [attr.rowspan]=\"configuration.multipleHeader ? 2 : 1\"></th>\r\n </ng-container>\r\n <ng-container matColumnDef=\"sdEmpty\">\r\n <td class=\"c-empty\" mat-cell *matCellDef=\"let item\" [attr.colspan]=\"configuration.displayedColumns.length\">\r\n <ng-container *ngIf=\"sdEmptyData?.templateRef; else sdEmptyDataNoRef\">\r\n <ng-container *ngTemplateOutlet=\"sdEmptyData.templateRef; context: { item: item }\"> </ng-container>\r\n </ng-container>\r\n <ng-template #sdEmptyDataNoRef>\r\n <mat-icon fontSet=\"material-icons-outlined\">leaderboard</mat-icon>\r\n </ng-template>\r\n </td>\r\n </ng-container>\r\n <ng-container matColumnDef=\"sdGroup\">\r\n <th mat-header-cell *matHeaderCellDef class=\"px-8 py-8\" [attr.rowspan]=\"configuration.multipleHeader ? 2 : 1\"></th>\r\n <td class=\"p-0\" mat-cell *matCellDef=\"let item\"></td>\r\n <td mat-footer-cell *matFooterCellDef></td>\r\n </ng-container>\r\n <ng-container\r\n *ngFor=\"let column of configuration.columns\"\r\n [matColumnDef]=\"column.field\"\r\n [sticky]=\"configuration.fixedColumn[column.field]\">\r\n <th mat-header-cell *matHeaderCellDef class=\"c-th px-8 py-8\" [ngStyle]=\"{ 'min-width': column.width }\">\r\n <div\r\n [class.text-right]=\"column.align === 'right' || (!column.align && column.type === 'number')\"\r\n [class.text-center]=\"column.align === 'center'\"\r\n [innerHTML]=\"column.titleHtml || column.title\"></div>\r\n </th>\r\n </ng-container>\r\n <ng-container\r\n *ngFor=\"let column of configuration.firstColumns; let i = index\"\r\n [matColumnDef]=\"column.field\"\r\n [sticky]=\"configuration.fixedColumn[column.field]\">\r\n <th\r\n mat-header-cell\r\n *matHeaderCellDef\r\n class=\"c-th px-8 py-8\"\r\n [ngStyle]=\"{ 'min-width': configuration.firstColumns[i].width }\"\r\n [attr.rowspan]=\"configuration.multipleHeader && column.type !== 'children-col' ? 2 : 1\"\r\n [attr.colspan]=\"column.type === 'children-col' ? column.children?.length : 1\">\r\n <div>\r\n <div\r\n [class.text-right]=\"column.align === 'right' || (!column.align && column.type === 'number')\"\r\n [class.text-center]=\"column.align === 'center'\"\r\n [innerHTML]=\"configuration.firstColumns[i].titleHtml || configuration.firstColumns[i].title\"></div>\r\n <sd-column-inline-filter\r\n *ngIf=\"gridOption.filter?.inlineColumn\"\r\n [value]=\"columnFilter[column.field]\"\r\n [columnFilter]=\"columnFilter\"\r\n [column]=\"column\"\r\n (filterChange)=\"onFilterChange()\"></sd-column-inline-filter>\r\n </div>\r\n </th>\r\n </ng-container>\r\n <ng-container *ngFor=\"let column of configuration.secondColumns\" [matColumnDef]=\"column.field\">\r\n <th mat-header-cell *matHeaderCellDef class=\"c-th px-8 py-8\" [ngStyle]=\"{ 'min-width': column.width }\">\r\n <div>\r\n <div\r\n [class.text-right]=\"column.align === 'right' || (!column.align && column.type === 'number')\"\r\n [class.text-center]=\"column.align === 'center'\"\r\n [innerHTML]=\"column.titleHtml || column.title\"></div>\r\n <sd-column-inline-filter\r\n *ngIf=\"gridOption.filter?.inlineColumn\"\r\n [value]=\"columnFilter[column.field]\"\r\n [columnFilter]=\"columnFilter\"\r\n [column]=\"column\"\r\n (filterChange)=\"onFilterChange()\"></sd-column-inline-filter>\r\n </div>\r\n </th>\r\n </ng-container>\r\n <tr class=\"c-first-header\" mat-header-row *matHeaderRowDef=\"configuration.firstHeaders; sticky: true\"></tr>\r\n <tr class=\"c-second-header\" mat-header-row *matHeaderRowDef=\"configuration.secondHeaders; sticky: true\"></tr>\r\n <tr mat-row *matRowDef=\"let row; columns: ['sdEmpty']\"></tr>\r\n </table>\r\n </ng-template>\r\n </div>\r\n </ng-container>\r\n <div class=\"c-paginator\">\r\n <div class=\"c-action\">\r\n <sd-button\r\n *ngIf=\"gridFilter && !gridOption.filter?.inlineColumn\"\r\n class=\"mr-10\"\r\n [title]=\"'Filter' | sdTranslate\"\r\n icon=\"filter_alt\"\r\n size=\"sm\"\r\n (action)=\"gridFilter.open()\"\r\n type=\"link\">\r\n </sd-button>\r\n <sd-button\r\n *ngIf=\"gridOption.reload?.visible\"\r\n class=\"mr-10\"\r\n [title]=\"'Reload' | sdTranslate\"\r\n icon=\"refresh\"\r\n size=\"sm\"\r\n (action)=\"reload()\"\r\n [disabled]=\"!items?.length\"\r\n type=\"link\">\r\n </sd-button>\r\n <ng-container *ngIf=\"gridOption.export?.visible && items?.length\">\r\n <ng-container *ngIf=\"isExporting; else unExporting\">\r\n <sd-button class=\"mr-10\" [loading]=\"isExporting\" [title]=\"exportTitle | sdTranslate\" icon=\"get_app\" size=\"sm\" type=\"link\">\r\n </sd-button>\r\n </ng-container>\r\n <ng-template #unExporting>\r\n <sd-button\r\n class=\"mr-10\"\r\n [title]=\"exportTitle | sdTranslate\"\r\n icon=\"get_app\"\r\n size=\"sm\"\r\n [matMenuTriggerFor]=\"menu\"\r\n type=\"link\">\r\n </sd-button>\r\n </ng-template>\r\n\r\n <mat-menu #menu=\"matMenu\">\r\n <button mat-menu-item (click)=\"exportExcel()\" type=\"button\">\r\n <mat-icon fontSet=\"material-icons-outlined\">file_download</mat-icon>\r\n <span> Xu\u1EA5t excel</span>\r\n </button>\r\n <button mat-menu-item (click)=\"exportCSV()\" type=\"button\">\r\n <mat-icon fontSet=\"material-icons-outlined\">file_download</mat-icon>\r\n <span> Xu\u1EA5t CSV</span>\r\n </button>\r\n </mat-menu>\r\n </ng-container>\r\n <sd-button\r\n *ngIf=\"gridOption.config?.visible\"\r\n class=\"mr-10\"\r\n [title]=\"'Configure' | sdTranslate\"\r\n icon=\"settings\"\r\n size=\"sm\"\r\n (action)=\"popupGridConfiguration.open()\"\r\n type=\"link\">\r\n </sd-button>\r\n </div>\r\n <mat-paginator\r\n [class.d-none]=\"gridOption.paginate?.hidden\"\r\n [length]=\"total\"\r\n [pageSize]=\"gridOption.paginate?.pageSize\"\r\n [pageSizeOptions]=\"gridOption.paginate?.pages\"\r\n [showFirstLastButtons]=\"gridOption.paginate?.showFirstLastButtons\"></mat-paginator>\r\n </div>\r\n </div>\r\n <sd-grid-quick-action [gridOption]=\"gridOption\" [selectedItems]=\"selectedItems\" (clear)=\"onClearSelection(groupedItems)\">\r\n </sd-grid-quick-action>\r\n <sd-popup-grid-configuration [gridOption]=\"gridOption\" [key]=\"key\" #popupGridConfiguration> </sd-popup-grid-configuration>\r\n </ng-container>\r\n </ng-container>\r\n</ng-container>\r\n",
1647
+ changeDetection: ChangeDetectionStrategy.OnPush,
1648
+ animations: [
1649
+ trigger('detailExpand', [
1650
+ state('collapsed', style({ height: '0', minHeight: '0', visibility: 'hidden' })),
1651
+ state('expanded', style({ height: '*', visibility: 'visible' })),
1652
+ transition('expanded <=> collapsed', animate('225ms cubic-bezier(0.4, 0.0, 0.2, 1)')),
1653
+ ]),
1654
+ ],
1655
+ styles: [".text-black400{color:#757575}:host{display:flex;flex-direction:column;height:100%;overflow:auto}:host .c-container{display:flex;flex:1;flex-direction:column;min-height:200px;position:relative}:host .c-container .c-table{flex:1;min-height:300px;position:relative}:host .c-container .c-table table{border-collapse:separate;width:100%}:host .c-container .c-table table tr.c-first-header.mat-header-row,:host .c-container .c-table table tr.c-second-header.mat-header-row{height:40px}:host .c-container .c-table table tr.c-detail-row{height:0}:host .c-container .c-table table tr.c-row.activated{background-color:#e5ecff}:host .c-container .c-table table tr.c-row.selected{background-color:#eef2ff}:host .c-container .c-table table tr.c-row:not(.selected):not(.activated):hover{background-color:#f5f5f5}:host .c-container .c-table table tr.c-row td{border-bottom-width:0}:host .c-container .c-table table tr.c-row.c-expandable{cursor:pointer}:host .c-container .c-table table tr.c-row.c-expandable:hover{background:#f5f5f5}:host .c-container .c-table table th.mat-header-cell{background-color:#f2f3f4;border-bottom:0!important}:host .c-container .c-table table td.mat-cell,:host .c-container .c-table table td.mat-footer-cell,:host .c-container .c-table table th.mat-header-cell{border-bottom-color:#f2f2f2!important}:host .c-container .c-table .c-th{color:#212121;font-size:14px;font-weight:500;line-height:20px;vertical-align:middle}:host .c-container .c-table .c-td:first{padding-left:10px}:host .c-container .c-loading{align-items:center;background:rgba(0,0,0,.15);bottom:56px;display:flex;justify-content:center;left:0;position:absolute;right:0;top:0;z-index:2}:host .c-container .c-paginator{align-items:center;background-color:#fff;display:flex;flex-direction:row;justify-content:space-between}:host .c-container .c-paginator .c-action{padding:5px}:host .c-container .c-empty{background-color:#fff;border:none!important;text-align:center}:host .c-container .c-empty mat-icon{font-size:150px;height:auto;margin-bottom:30px;margin-top:30px;opacity:.2;width:auto}:host button.c-btn-add{background-color:#fff;box-shadow:0 2px 4px rgba(47,49,54,.16)}:host mat-icon.c-icon{color:rgba(0,0,0,.54)!important}:host mat-icon.c-icon-add{color:#2962ff!important}:host .lds-ring{display:inline-block;height:40px;position:relative;width:40px}:host .lds-ring div{-webkit-animation:lds-ring 1.2s cubic-bezier(.5,0,.5,1) infinite;animation:lds-ring 1.2s cubic-bezier(.5,0,.5,1) infinite;border:4px solid transparent;border-radius:50%;border-top-color:#cef;box-sizing:border-box;display:block;height:32px;margin:4px;position:absolute;width:32px}:host .lds-ring div:first-child{-webkit-animation-delay:-.45s;animation-delay:-.45s}:host .lds-ring div:nth-child(2){-webkit-animation-delay:-.3s;animation-delay:-.3s}:host .lds-ring div:nth-child(3){-webkit-animation-delay:-.15s;animation-delay:-.15s}@-webkit-keyframes lds-ring{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}@keyframes lds-ring{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}:host ::ng-deep .mat-sort-header-content{display:block;text-align:left;width:100%}:host ::ng-deep .mat-select-arrow{color:#a6a6a6}:host ::ng-deep .mat-sort-header-disabled{background-image:none!important;cursor:default!important;padding-right:0!important}:host ::ng-deep .mat-sort-header-container{align-items:start!important}:host ::ng-deep .mat-sort-header-arrow{margin-top:4px!important}:host ::ng-deep .mat-sort-header{cursor:pointer}:host ::ng-deep .mat-sort-header[aria-sort]{background-position:center right 0;background-repeat:no-repeat;background-size:16px 16px;cursor:pointer;padding-right:24px}:host ::ng-deep .mat-sort-header[aria-sort=none]{background-image:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24px' viewBox='0 0 24 24' width='24px' fill='%23000000'%3E%3Cpath d='M0 0h24v24H0V0z' fill='none'/%3E%3Cpath fill='%237A7A7A' d='M12 5.83L15.17 9l1.41-1.41L12 3 7.41 7.59 8.83 9 12 5.83zm0 12.34L8.83 15l-1.41 1.41L12 21l4.59-4.59L15.17 15 12 18.17z'/%3E%3C/svg%3E\")}:host ::ng-deep .mat-sort-header[aria-sort=ascending]{background-image:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24px' viewBox='0 0 24 24' width='24px' fill='%23000000'%3E%3Cpath d='M0 0h24v24H0V0z' fill='none'/%3E%3Cpath fill='%237A7A7A' d='M4 12l1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8-8 8z'/%3E%3C/svg%3E\")}:host ::ng-deep .mat-sort-header[aria-sort=descending]{background-image:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24px' viewBox='0 0 24 24' width='24px' fill='%23000000'%3E%3Cpath d='M0 0h24v24H0V0z' fill='none'/%3E%3Cpath fill='%237A7A7A' d='M20 12l-1.41-1.41L13 16.17V4h-2v12.17l-5.58-5.59L4 12l8 8 8-8z'/%3E%3C/svg%3E\")}"]
1656
+ },] }
1657
+ ];
1658
+ SdTable.ctorParameters = () => [
1659
+ { type: ChangeDetectorRef },
1660
+ { type: undefined, decorators: [{ type: Inject, args: [TABLE_CONFIG,] }, { type: Optional }] },
1661
+ { type: SdTableConfigurationService },
1662
+ { type: SdExportService },
1663
+ { type: SdNotifyService },
1664
+ { type: SdColumnValuesPipe },
1665
+ { type: SdTableFilterService }
1666
+ ];
1667
+ SdTable.propDecorators = {
1668
+ sdScroll: [{ type: ViewChild, args: [SdScrollDirective,] }],
1669
+ quickAction: [{ type: ViewChild, args: [SdQuickAction,] }],
1670
+ _gridFilter: [{ type: ViewChild, args: [SdGridFilter,] }],
1671
+ option: [{ type: Input }],
1672
+ paginator: [{ type: ViewChild, args: [MatPaginator,] }],
1673
+ sort: [{ type: ViewChild, args: [MatSort,] }],
1674
+ sdSubInformation: [{ type: ContentChild, args: [SdMaterialSubInformationDefDirective,] }],
1675
+ sdEmptyData: [{ type: ContentChild, args: [SdMaterialEmptyDataDefDirective,] }],
1676
+ sdCellDefs: [{ type: ContentChildren, args: [SdMaterialCellDefDirective,] }],
1677
+ sdFooterDefs: [{ type: ContentChildren, args: [SdMaterialFooterDefDirective,] }],
1678
+ sdFilterDefs: [{ type: ContentChildren, args: [SdMaterialFilterDefDirective,] }]
1679
+ };
1680
+
1681
+ class SdCommandFilterPipe {
1682
+ transform(item, commands) {
1683
+ return __awaiter(this, void 0, void 0, function* () {
1684
+ const results = [];
1685
+ if (!commands) {
1686
+ return results;
1687
+ }
1688
+ for (const command of commands) {
1689
+ let flag = false;
1690
+ const { hidden } = command;
1691
+ if (hidden === undefined) {
1692
+ flag = true;
1693
+ }
1694
+ else if (typeof (hidden) === 'boolean') {
1695
+ if (!hidden) {
1696
+ flag = true;
1697
+ }
1698
+ }
1699
+ else {
1700
+ const isHidden = hidden(item);
1701
+ if (isHidden instanceof Promise) {
1702
+ if (!(yield isHidden)) {
1703
+ flag = true;
1704
+ }
1705
+ }
1706
+ else {
1707
+ if (!isHidden) {
1708
+ flag = true;
1709
+ }
1710
+ }
1711
+ }
1712
+ if (flag) {
1713
+ if ('children' in command) {
1714
+ const children = [];
1715
+ for (const childCommand of command.children) {
1716
+ const { hidden } = childCommand;
1717
+ if (hidden === undefined) {
1718
+ children.push(childCommand);
1719
+ }
1720
+ else if (typeof (hidden) === 'boolean') {
1721
+ if (!hidden) {
1722
+ children.push(childCommand);
1723
+ }
1724
+ }
1725
+ else {
1726
+ const isHidden = hidden(item);
1727
+ if (isHidden instanceof Promise) {
1728
+ if (!(yield isHidden)) {
1729
+ children.push(childCommand);
1730
+ }
1731
+ }
1732
+ else {
1733
+ if (!isHidden) {
1734
+ children.push(childCommand);
1735
+ }
1736
+ }
1737
+ }
1738
+ }
1739
+ if (children.length > 0) {
1740
+ results.push(Object.assign(Object.assign({}, command), { children }));
1741
+ }
1742
+ }
1743
+ else {
1744
+ results.push(command);
1745
+ }
1746
+ }
1747
+ }
1748
+ return results;
1749
+ });
1750
+ }
1751
+ }
1752
+ SdCommandFilterPipe.decorators = [
1753
+ { type: Pipe, args: [{
1754
+ name: 'commandFilter'
1755
+ },] }
1756
+ ];
1757
+
1758
+ class SdCommandDisablePipe {
1759
+ transform(item, command) {
1760
+ if (!(command === null || command === void 0 ? void 0 : command.disabled)) {
1761
+ return false;
1762
+ }
1763
+ if (typeof (command.disabled) === 'boolean') {
1764
+ return command.disabled;
1765
+ }
1766
+ return command.disabled(item);
1767
+ }
1768
+ }
1769
+ SdCommandDisablePipe.decorators = [
1770
+ { type: Pipe, args: [{
1771
+ name: 'commandDisable'
1772
+ },] }
1773
+ ];
1774
+
1775
+ class SdCommandIconPipe {
1776
+ transform(command, item) {
1777
+ if (!(command === null || command === void 0 ? void 0 : command.icon)) {
1778
+ return '';
1779
+ }
1780
+ if (typeof (command.icon) === 'string') {
1781
+ return command.icon;
1782
+ }
1783
+ return command.icon(item);
1784
+ }
1785
+ }
1786
+ SdCommandIconPipe.decorators = [
1787
+ { type: Pipe, args: [{
1788
+ name: 'commandIcon'
1789
+ },] }
1790
+ ];
1791
+
1792
+ class SdCommandTitlePipe {
1793
+ transform(command, item) {
1794
+ if (!(command === null || command === void 0 ? void 0 : command.title)) {
1795
+ return '';
1796
+ }
1797
+ if (typeof (command.title) === 'string') {
1798
+ return command.title;
1799
+ }
1800
+ return command.title(item);
1801
+ }
1802
+ }
1803
+ SdCommandTitlePipe.decorators = [
1804
+ { type: Pipe, args: [{
1805
+ name: 'commandTitle'
1806
+ },] }
1807
+ ];
1808
+
1809
+ class SdColumnHtmlTemplatePipe {
1810
+ constructor(deviceService) {
1811
+ this.isMobileOrTablet = false;
1812
+ this.isMobileOrTablet = !deviceService.isDesktop();
1813
+ }
1814
+ transform(value, rowData, column) {
1815
+ if (typeof (column === null || column === void 0 ? void 0 : column.htmlTemplate) !== 'function') {
1816
+ return value;
1817
+ }
1818
+ return column === null || column === void 0 ? void 0 : column.htmlTemplate(value, rowData, this.isMobileOrTablet);
1819
+ }
1820
+ }
1821
+ SdColumnHtmlTemplatePipe.decorators = [
1822
+ { type: Pipe, args: [{
1823
+ name: 'columnHtmlTemplate'
1824
+ },] }
1825
+ ];
1826
+ SdColumnHtmlTemplatePipe.ctorParameters = () => [
1827
+ { type: DeviceDetectorService }
1828
+ ];
1829
+
1830
+ class SdDesktopCellView {
1831
+ constructor() { }
1832
+ }
1833
+ SdDesktopCellView.decorators = [
1834
+ { type: Component, args: [{
1835
+ selector: 'sd-desktop-cell-view',
1836
+ template: "<ng-container *ngIf=\"item.current[column.field] | cellView : item : column : gridOption | async as view\">\r\n <ng-container *ngIf=\"view.display.hasHtml; else useValue\">\r\n <div\r\n *ngIf=\"view.click\"\r\n (click)=\"view.click()\"\r\n class=\"text-break cursor-pointer\"\r\n [matTooltip]=\"view.tooltip\"\r\n [class.text-center]=\"view.display.align === 'center'\"\r\n [class.text-right]=\"view.display.align === 'right'\"\r\n [innerHTML]=\"view.display.html | safeHtml\"></div>\r\n <div\r\n *ngIf=\"!view.click\"\r\n class=\"text-break\"\r\n [matTooltip]=\"view.tooltip\"\r\n [class.text-center]=\"view.display.align === 'center'\"\r\n [class.text-right]=\"view.display.align === 'right'\"\r\n [innerHTML]=\"view.display.html | safeHtml\"></div>\r\n </ng-container>\r\n <ng-template #useValue>\r\n <ng-container *ngIf=\"!!view.badge; else noBadge\">\r\n <sd-badge\r\n *ngIf=\"view.display.value\"\r\n [type]=\"view.badge.type\"\r\n [title]=\"view.display.value\"\r\n [color]=\"view.badge.color\"\r\n [icon]=\"view.badge.icon\"\r\n [tooltip]=\"view.tooltip\"\r\n (sdClick)=\"!!view.click && view.click()\"></sd-badge>\r\n </ng-container>\r\n <ng-template #noBadge>\r\n <div\r\n class=\"text-break\"\r\n [class.text-center]=\"view.display.align === 'center'\"\r\n [class.text-right]=\"view.display.align === 'right'\"\r\n [matTooltip]=\"view.tooltip\">\r\n <a *ngIf=\"!!view.click\" href=\"javascript:;\" (click)=\"view.click()\">{{ view.display.value }}</a>\r\n <ng-container *ngIf=\"!view.click\">{{ view.display.value }} </ng-container>\r\n </div>\r\n </ng-template>\r\n </ng-template>\r\n</ng-container>\r\n",
1837
+ changeDetection: ChangeDetectionStrategy.OnPush,
1838
+ styles: [".text-black400{color:#757575}.c-color-success{color:#4caf50}.c-color-danger{color:#f82c13}.c-image{-o-object-fit:contain;margin:5px 0;object-fit:contain}.c-img{font-size:30px;opacity:.5}.c-img.pointer:hover{opacity:.9}"]
1839
+ },] }
1840
+ ];
1841
+ SdDesktopCellView.ctorParameters = () => [];
1842
+ SdDesktopCellView.propDecorators = {
1843
+ sdId: [{ type: Input }],
1844
+ key: [{ type: Input }],
1845
+ column: [{ type: Input }],
1846
+ item: [{ type: Input }],
1847
+ gridOption: [{ type: Input }]
1848
+ };
1849
+
1850
+ class SdColumnTransformPipe {
1851
+ constructor(columnValuesPipe) {
1852
+ this.columnValuesPipe = columnValuesPipe;
1853
+ }
1854
+ transform(value, rowData, column, key) {
1855
+ var _a, _b;
1856
+ return __awaiter(this, void 0, void 0, function* () {
1857
+ if (column === null || column === void 0 ? void 0 : column.transform) {
1858
+ return column.transform(value, rowData);
1859
+ }
1860
+ if (column.type === 'values') {
1861
+ return yield this.columnValuesPipe.transform(value, column);
1862
+ }
1863
+ if (column.type === 'number' && Number.isNumber(value)) {
1864
+ return Number.toVNCurrency(value); // this.decimalPipe.transform(value, '1.0-2');
1865
+ }
1866
+ if (column.type === 'bool') {
1867
+ return value === true ? (((_a = column.option) === null || _a === void 0 ? void 0 : _a.displayOnTrue) || 'True') : (((_b = column.option) === null || _b === void 0 ? void 0 : _b.displayOnFalse) || 'False');
1868
+ }
1869
+ return value;
1870
+ });
1871
+ }
1872
+ }
1873
+ SdColumnTransformPipe.decorators = [
1874
+ { type: Pipe, args: [{
1875
+ name: 'columnTransform'
1876
+ },] }
1877
+ ];
1878
+ SdColumnTransformPipe.ctorParameters = () => [
1879
+ { type: SdColumnValuesPipe }
1880
+ ];
1881
+
1882
+ class SdFilterExternalPipe {
1883
+ transform(externalFilters, field) {
1884
+ const results = [];
1885
+ if (!externalFilters) {
1886
+ return results;
1887
+ }
1888
+ for (const filter of externalFilters) {
1889
+ results.push(filter);
1890
+ }
1891
+ return results.filter(e => !field || e.field === field);
1892
+ }
1893
+ }
1894
+ SdFilterExternalPipe.decorators = [
1895
+ { type: Pipe, args: [{
1896
+ name: 'sdFilterExternal'
1897
+ },] }
1898
+ ];
1899
+
1900
+ class SdFilterColumnPipe {
1901
+ transform(columns, field) {
1902
+ var _a, _b;
1903
+ const results = [];
1904
+ if (!columns) {
1905
+ return results;
1906
+ }
1907
+ for (const column of columns) {
1908
+ if (column.type === 'children') {
1909
+ for (const columnChildren of column === null || column === void 0 ? void 0 : column.children) {
1910
+ if (!((_a = columnChildren.filter) === null || _a === void 0 ? void 0 : _a.disabled)) {
1911
+ results.push(columnChildren);
1912
+ }
1913
+ }
1914
+ continue;
1915
+ }
1916
+ if (!((_b = column.filter) === null || _b === void 0 ? void 0 : _b.disabled)) {
1917
+ results.push(column);
1918
+ }
1919
+ }
1920
+ return results.filter(e => !field || e.field === field);
1921
+ }
1922
+ }
1923
+ SdFilterColumnPipe.decorators = [
1924
+ { type: Pipe, args: [{
1925
+ name: 'sdFilterColumn'
1926
+ },] }
1927
+ ];
1928
+
1929
+ var _isMobileOrTablet;
1930
+ class SdColumnChildrenFilterPipe {
1931
+ constructor(deviceService) {
1932
+ _isMobileOrTablet.set(this, false);
1933
+ __classPrivateFieldSet(this, _isMobileOrTablet, !deviceService.isDesktop());
1934
+ }
1935
+ transform(columns, item) {
1936
+ return columns.filter(column => {
1937
+ var _a, _b;
1938
+ const value = item === null || item === void 0 ? void 0 : item[column.field];
1939
+ const transformValue = (_a = column.transform) === null || _a === void 0 ? void 0 : _a.call(column, item[column.field], item);
1940
+ const templateValue = (_b = column.htmlTemplate) === null || _b === void 0 ? void 0 : _b.call(column, item[column.field], item, __classPrivateFieldGet(this, _isMobileOrTablet));
1941
+ return (value !== undefined && value !== null && value !== '')
1942
+ || (transformValue !== undefined && transformValue !== null && transformValue !== '')
1943
+ || (templateValue !== undefined && templateValue !== null && templateValue !== '');
1944
+ });
1945
+ }
1946
+ }
1947
+ _isMobileOrTablet = new WeakMap();
1948
+ SdColumnChildrenFilterPipe.decorators = [
1949
+ { type: Pipe, args: [{
1950
+ name: 'columnChildrenFilter'
1951
+ },] }
1952
+ ];
1953
+ SdColumnChildrenFilterPipe.ctorParameters = () => [
1954
+ { type: DeviceDetectorService }
1955
+ ];
1956
+
1957
+ class SdDesktopCommand {
1958
+ constructor() {
1959
+ this.commands = [];
1960
+ }
1961
+ }
1962
+ SdDesktopCommand.decorators = [
1963
+ { type: Component, args: [{
1964
+ selector: 'sd-desktop-command',
1965
+ template: "<ng-container *ngIf=\"item | commandFilter:commands | async; $implicit as filteredCommands\">\r\n <ng-container *ngFor=\"let command of filteredCommands\">\r\n <ng-container *ngIf=\"command?.click; else elseChildren\">\r\n <button (click)=\"command.click(item)\" [matTooltip]=\"command | commandTitle:item\" aria-hidden=\"true\"\r\n [disabled]=\"item | commandDisable:command\" mat-icon-button>\r\n <mat-icon class=\"c-icon\" [fontSet]=\"command.fontSet\">{{command | commandIcon:item}}</mat-icon>\r\n </button>\r\n </ng-container>\r\n <ng-template #elseChildren>\r\n <button [matMenuTriggerFor]=\"menu\" aria-hidden=\"true\" mat-icon-button>\r\n <mat-icon *ngIf=\"command?.icon\" class=\"c-icon\" [fontSet]=\"command.fontSet\">{{command | commandIcon:item}}\r\n </mat-icon>\r\n <mat-icon *ngIf=\"!command?.icon\" class=\"c-icon\">more_vert</mat-icon>\r\n </button>\r\n <mat-menu #menu=\"matMenu\">\r\n <span>\r\n <button *ngFor=\"let childCommand of command.children\" mat-menu-item (click)=\"childCommand.click(item)\"\r\n [disabled]=\"item | commandDisable:childCommand\">\r\n <ng-container *ngIf=\"!childCommand.htmlTemplate\">\r\n <mat-icon [fontSet]=\"command.fontSet\" class=\"c-icon\">{{childCommand | commandIcon:item}}\r\n </mat-icon>\r\n <span> {{childCommand | commandTitle:item}}</span>\r\n </ng-container>\r\n <ng-container *ngIf=\"childCommand.htmlTemplate\">\r\n <div [innerHTML]=\"childCommand.htmlTemplate(item)\"></div>\r\n </ng-container>\r\n </button>\r\n </span>\r\n </mat-menu>\r\n </ng-template>\r\n </ng-container>\r\n</ng-container>\r\n",
1966
+ changeDetection: ChangeDetectionStrategy.OnPush,
1967
+ styles: [":host{align-items:center;display:flex}mat-icon.c-icon{color:rgba(0,0,0,.54)!important}"]
1968
+ },] }
1969
+ ];
1970
+ SdDesktopCommand.ctorParameters = () => [];
1971
+ SdDesktopCommand.propDecorators = {
1972
+ item: [{ type: Input }],
1973
+ commands: [{ type: Input }]
1974
+ };
1975
+
1976
+ class SdColumnBadgePipe {
1977
+ constructor() { }
1978
+ transform(value, rowData, column) {
1979
+ var _a, _b, _c;
1980
+ if (column.type === 'string' && (column === null || column === void 0 ? void 0 : column.badge)) {
1981
+ return {
1982
+ type: !(column === null || column === void 0 ? void 0 : column.badgeType) ? 'round' : column.badgeType,
1983
+ color: column.badge(value, rowData),
1984
+ icon: (_a = column === null || column === void 0 ? void 0 : column.badgeIcon) === null || _a === void 0 ? void 0 : _a.call(column, value, rowData)
1985
+ };
1986
+ }
1987
+ if (column.type === 'number' && (column === null || column === void 0 ? void 0 : column.badge)) {
1988
+ return {
1989
+ type: !(column === null || column === void 0 ? void 0 : column.badgeType) ? 'round' : column.badgeType,
1990
+ color: column.badge(value, rowData),
1991
+ icon: (_b = column === null || column === void 0 ? void 0 : column.badgeIcon) === null || _b === void 0 ? void 0 : _b.call(column, value, rowData)
1992
+ };
1993
+ }
1994
+ if (column.type === 'bool') {
1995
+ return {
1996
+ type: !(column === null || column === void 0 ? void 0 : column.badgeType) ? 'round' : column.badgeType,
1997
+ color: !!value ? 'success' : 'danger',
1998
+ icon: null
1999
+ };
2000
+ }
2001
+ if (column.type === 'values' && (column === null || column === void 0 ? void 0 : column.badge)) {
2002
+ return {
2003
+ type: !(column === null || column === void 0 ? void 0 : column.badgeType) ? 'round' : column.badgeType,
2004
+ color: column.badge(value, rowData),
2005
+ icon: (_c = column === null || column === void 0 ? void 0 : column.badgeIcon) === null || _c === void 0 ? void 0 : _c.call(column, value, rowData)
2006
+ };
2007
+ }
2008
+ return null;
2009
+ }
2010
+ }
2011
+ SdColumnBadgePipe.decorators = [
2012
+ { type: Pipe, args: [{
2013
+ name: 'columnBadge'
2014
+ },] }
2015
+ ];
2016
+ SdColumnBadgePipe.ctorParameters = () => [];
2017
+
2018
+ class SdGridConfigurationResultPipe {
2019
+ constructor(gridConfigurationService) {
2020
+ this.gridConfigurationService = gridConfigurationService;
2021
+ }
2022
+ transform(configuration, gridOption, sdSubInformation) {
2023
+ const a = this.gridConfigurationService.generateConfigurationResult(configuration, gridOption, sdSubInformation);
2024
+ console.log(a);
2025
+ return a;
2026
+ }
2027
+ }
2028
+ SdGridConfigurationResultPipe.decorators = [
2029
+ { type: Pipe, args: [{
2030
+ name: 'sdGridConfigurationResult'
2031
+ },] }
2032
+ ];
2033
+ SdGridConfigurationResultPipe.ctorParameters = () => [
2034
+ { type: SdTableConfigurationService }
2035
+ ];
2036
+
2037
+ var _cache$3;
2038
+ class SdPopupGridConfiguration {
2039
+ constructor(ref, notifyService, translateService, gridConfigurationService) {
2040
+ this.ref = ref;
2041
+ this.notifyService = notifyService;
2042
+ this.translateService = translateService;
2043
+ this.gridConfigurationService = gridConfigurationService;
2044
+ this.changes = new EventEmitter();
2045
+ _cache$3.set(this, void 0);
2046
+ this.isCreatingColumn = false;
2047
+ this.selected = {};
2048
+ this.disabledDrag = true;
2049
+ this.open = () => __awaiter(this, void 0, void 0, function* () {
2050
+ __classPrivateFieldSet(this, _cache$3, this.gridConfigurationService.init(this.key, this.gridOption));
2051
+ this.configuration = yield __classPrivateFieldGet(this, _cache$3).get();
2052
+ this.modal.open();
2053
+ });
2054
+ this.onSave = () => {
2055
+ __classPrivateFieldGet(this, _cache$3).set(this.configuration);
2056
+ this.modal.close();
2057
+ this.ref.detectChanges();
2058
+ };
2059
+ this.onReset = () => __awaiter(this, void 0, void 0, function* () {
2060
+ const { translate } = this.translateService;
2061
+ this.notifyService.confirm(translate('Reset grid configuration to default')).then(() => {
2062
+ __classPrivateFieldGet(this, _cache$3).remove();
2063
+ this.modal.close();
2064
+ this.ref.detectChanges();
2065
+ });
2066
+ });
2067
+ this.createColumn = () => __awaiter(this, void 0, void 0, function* () {
2068
+ this.selected = {};
2069
+ this.isCreatingColumn = true;
2070
+ });
2071
+ this.confirm = () => __awaiter(this, void 0, void 0, function* () {
2072
+ const generatedColumn = {
2073
+ origin: {
2074
+ field: v4(),
2075
+ title: 'Generated',
2076
+ width: '300px',
2077
+ },
2078
+ fixed: false,
2079
+ invisible: false,
2080
+ title: 'Generated',
2081
+ width: '300px',
2082
+ };
2083
+ this.configuration.columns.push(generatedColumn);
2084
+ this.configuration = __classPrivateFieldGet(this, _cache$3).set(this.configuration);
2085
+ this.isCreatingColumn = false;
2086
+ });
2087
+ }
2088
+ ngOnInit() { }
2089
+ mouseUp(event) {
2090
+ this.disabledDrag = true;
2091
+ }
2092
+ dropTable(event) {
2093
+ moveItemInArray(this.configuration.columns, event.previousIndex, event.currentIndex);
2094
+ this.table.renderRows();
2095
+ }
2096
+ handleMouseDown() {
2097
+ this.disabledDrag = false;
2098
+ }
2099
+ handleMouseUp() {
2100
+ this.disabledDrag = true;
2101
+ }
2102
+ }
2103
+ _cache$3 = new WeakMap();
2104
+ SdPopupGridConfiguration.decorators = [
2105
+ { type: Component, args: [{
2106
+ selector: 'sd-popup-grid-configuration',
2107
+ template: "<sd-modal width=\"sm\" [title]=\"'Configuration' | sdTranslate\" #modal>\r\n <sd-modal-body *ngIf=\"configuration\">\r\n <div *ngIf=\"!isCreatingColumn\" class=\"c-container\">\r\n <div class=\"c-table\" style=\"max-height:70vh\">\r\n <table #table mat-table [dataSource]=\"configuration.columns\"\r\n cdkDropList\r\n [cdkDropListData]=\"configuration.columns\"\r\n (cdkDropListDropped)=\"dropTable($event)\">\r\n >\r\n <ng-container matColumnDef=\"stt\">\r\n <th mat-header-cell class=\"c-th text-center px-5\" *matHeaderCellDef style=\"width:50px\">#\r\n </th>\r\n <td class=\"text-center px-5\" mat-cell *matCellDef=\"let item; let idx = index\">\r\n <div class=\"c-handle\" (mousedown) = \"handleMouseDown()\" (mouseup)=\"handleMouseUp()\">\r\n <svg width=\"24px\" fill=\"currentColor\" viewBox=\"0 0 24 24\">\r\n <path d=\"M10 9h4V6h3l-5-5-5 5h3v3zm-1 1H6V7l-5 5 5 5v-3h3v-4zm14 2l-5-5v3h-3v4h3v3l5-5zm-9 3h-4v3H7l5 5 5-5h-3v-3z\"></path>\r\n <path d=\"M0 0h24v24H0z\" fill=\"none\"></path>\r\n </svg>\r\n </div>\r\n\r\n </td>\r\n </ng-container>\r\n <ng-container matColumnDef=\"title\">\r\n <th mat-header-cell class=\"c-th px-5\" *matHeaderCellDef>{{'Title' | sdTranslate}}\r\n </th>\r\n <td class=\"px-5\" mat-cell *matCellDef=\"let item;\">\r\n <sd-input [placeholder]=\"item?.origin?.title\" [(model)]=\"item.title\" disableErrorMessage></sd-input>\r\n </td>\r\n </ng-container>\r\n <ng-container matColumnDef=\"width\">\r\n <th mat-header-cell class=\"c-th px-5\" *matHeaderCellDef style=\"width:80px\">{{'Width' | sdTranslate}}\r\n </th>\r\n <td class=\"px-5\" mat-cell *matCellDef=\"let item;\">\r\n <!-- <span>{{item.width}}</span>\r\n <mat-slider\r\n step=\"1\"\r\n min=\"0\"\r\n [max]=\"+item?.origin?.width*3\"\r\n [(ngModel)]=\"+item.width\"\r\n aria-label=\"units\">\r\n </mat-slider> -->\r\n <sd-input [placeholder]=\"item?.origin?.width\" [(model)]=\"item.width\" disableErrorMessage></sd-input>\r\n </td>\r\n </ng-container>\r\n <ng-container matColumnDef=\"invisible\">\r\n <th mat-header-cell class=\"c-th text-center px-5\" *matHeaderCellDef style=\"width:80px\">{{'Hidden' |\r\n sdTranslate}}\r\n </th>\r\n <td class=\"text-center px-5\" mat-cell *matCellDef=\"let item;\">\r\n <mat-slide-toggle [(ngModel)]=\"item.invisible\" color=\"primary\">\r\n </mat-slide-toggle>\r\n </td>\r\n </ng-container>\r\n <ng-container matColumnDef=\"fixed\">\r\n <th mat-header-cell class=\"c-th text-center px-5\" *matHeaderCellDef style=\"width:80px\">{{'Freeze' |\r\n sdTranslate}}\r\n </th>\r\n <td class=\"text-center px-5\" mat-cell *matCellDef=\"let item;\">\r\n <mat-slide-toggle [(ngModel)]=\"item.fixed\" color=\"primary\"></mat-slide-toggle>\r\n </td>\r\n </ng-container>\r\n <tr mat-header-row *matHeaderRowDef=\"['stt', 'title', 'width', 'invisible', 'fixed']; sticky: true\"></tr>\r\n <tr mat-row *matRowDef=\"let row; columns: ['stt', 'title', 'width', 'invisible', 'fixed'];\" cdkDrag [cdkDragData]=\"row\" cdkDragLockAxis=\"y\" [cdkDragDisabled] = \"disabledDrag\"></tr>\r\n </table>\r\n </div>\r\n </div>\r\n <div *ngIf=\"isCreatingColumn\">\r\n <div class=\"c-table\" style=\"max-height:50vh\">\r\n <table mat-table [dataSource]=\"configuration.columns\">\r\n <ng-container matColumnDef=\"stt\">\r\n <th mat-header-cell class=\"c-th text-center px-5\" *matHeaderCellDef style=\"width:50px\">#\r\n </th>\r\n <td class=\"text-center px-5\" mat-cell *matCellDef=\"let item; let idx = index\">\r\n <sd-checkbox *ngIf=\"isCreatingColumn\" [(model)]=\"selected[item.origin?.field]\"></sd-checkbox>\r\n </td>\r\n </ng-container>\r\n <ng-container matColumnDef=\"title\">\r\n <th mat-header-cell class=\"c-th px-5\" *matHeaderCellDef>{{'Title' | sdTranslate}}\r\n </th>\r\n <td class=\"px-5\" mat-cell *matCellDef=\"let item;\">\r\n <span *ngIf=\"isCreatingColumn\">{{item.title || item?.origin?.title}}</span>\r\n </td>\r\n </ng-container>\r\n <tr mat-header-row *matHeaderRowDef=\"['stt', 'title']; sticky: true\"></tr>\r\n <tr mat-row *matRowDef=\"let row; columns: ['stt', 'title'];\"></tr>\r\n </table>\r\n </div>\r\n </div>\r\n </sd-modal-body>\r\n <sd-modal-footer>\r\n <ng-container *ngIf=\"!isCreatingColumn\">\r\n <!-- <sd-button class=\"mr-auto\" (action)=\"createColumn()\" [title]=\"'Create column' | sdTranslate\" color=\"info\"\r\n size=\"sm\">\r\n </sd-button> -->\r\n <sd-button class=\"mr-5\" (action)=\"onReset()\" [title]=\"'Default' | sdTranslate\" color=\"info\" size=\"sm\">\r\n </sd-button>\r\n <sd-button (action)=\"onSave()\" [title]=\"'Save' | sdTranslate\" type=\"fill\" color=\"info\" size=\"sm\">\r\n </sd-button>\r\n </ng-container>\r\n <ng-container *ngIf=\"isCreatingColumn\">\r\n <sd-button class=\"mr-auto\" (action)=\"isCreatingColumn = false\" [title]=\"'Cancel' | sdTranslate\" color=\"info\"\r\n size=\"sm\">\r\n </sd-button>\r\n <sd-button (action)=\"confirm()\" [title]=\"'Confirm' | sdTranslate\" type=\"fill\" color=\"info\" size=\"sm\">\r\n </sd-button>\r\n </ng-container>\r\n </sd-modal-footer>\r\n</sd-modal>",
2108
+ styles: [".c-table{overflow:auto;position:relative}.c-table table{width:100%}.c-table .c-th{color:#000;font-size:14px;font-weight:500;line-height:20px}.c-container{min-height:200px;position:relative}.c-handle{color:#ccc;cursor:move}"]
2109
+ },] }
2110
+ ];
2111
+ SdPopupGridConfiguration.ctorParameters = () => [
2112
+ { type: ChangeDetectorRef },
2113
+ { type: SdNotifyService },
2114
+ { type: SdTranslateService },
2115
+ { type: SdTableConfigurationService }
2116
+ ];
2117
+ SdPopupGridConfiguration.propDecorators = {
2118
+ gridOption: [{ type: Input }],
2119
+ key: [{ type: Input }],
2120
+ modal: [{ type: ViewChild, args: ['modal',] }],
2121
+ table: [{ type: ViewChild, args: ['table',] }],
2122
+ mouseUp: [{ type: HostListener, args: ['window:mouseup', ['$event'],] }]
2123
+ };
2124
+
2125
+ class SdColumnTooltipPipe {
2126
+ constructor() { }
2127
+ transform(value, rowData, column) {
2128
+ if (column === null || column === void 0 ? void 0 : column.tooltip) {
2129
+ return column.tooltip(value, rowData);
2130
+ }
2131
+ return null;
2132
+ }
2133
+ }
2134
+ SdColumnTooltipPipe.decorators = [
2135
+ { type: Pipe, args: [{
2136
+ name: 'columnTooltip'
2137
+ },] }
2138
+ ];
2139
+ SdColumnTooltipPipe.ctorParameters = () => [];
2140
+
2141
+ var _convert;
2142
+ class SdSelectionActionFilterPipe {
2143
+ constructor() {
2144
+ _convert.set(this, (action) => {
2145
+ if ('children' in action) {
2146
+ return {
2147
+ title: action.title,
2148
+ icon: action.icon,
2149
+ fontSet: action.fontSet,
2150
+ tooltip: action.tooltip,
2151
+ color: action.color,
2152
+ type: action.type,
2153
+ children: action.children.map(e => ({
2154
+ title: e.title,
2155
+ icon: e.icon,
2156
+ color: action.color,
2157
+ type: action.type,
2158
+ fontSet: e.fontSet,
2159
+ tooltip: e.tooltip,
2160
+ click: e.click
2161
+ }))
2162
+ };
2163
+ }
2164
+ return {
2165
+ title: action.title,
2166
+ icon: action.icon,
2167
+ color: action.color,
2168
+ type: action.type,
2169
+ fontSet: action.fontSet,
2170
+ tooltip: action.tooltip,
2171
+ click: action.click
2172
+ };
2173
+ });
2174
+ this.transform = (selectedItems, actions) => {
2175
+ const results = [];
2176
+ if (!(actions === null || actions === void 0 ? void 0 : actions.length) || !(selectedItems === null || selectedItems === void 0 ? void 0 : selectedItems.length)) {
2177
+ return [];
2178
+ }
2179
+ for (const action of actions) {
2180
+ if ('children' in action) {
2181
+ const children = [];
2182
+ for (const childAction of action.children) {
2183
+ const key = hash__default(childAction);
2184
+ if (selectedItems.every(e => e.meta.selector.actions.includes(key))) {
2185
+ children.push(childAction);
2186
+ }
2187
+ }
2188
+ if (children.length > 0) {
2189
+ results.push(Object.assign(Object.assign({}, action), { children }));
2190
+ }
2191
+ }
2192
+ else {
2193
+ const key = hash__default(action);
2194
+ if (selectedItems.every(e => e.meta.selector.actions.includes(key))) {
2195
+ results.push(action);
2196
+ }
2197
+ }
2198
+ }
2199
+ return results.map(result => __classPrivateFieldGet(this, _convert).call(this, result));
2200
+ };
2201
+ }
2202
+ }
2203
+ _convert = new WeakMap();
2204
+ SdSelectionActionFilterPipe.decorators = [
2205
+ { type: Pipe, args: [{
2206
+ name: 'selectionActionFilter'
2207
+ },] }
2208
+ ];
2209
+
2210
+ class SdSelectionDisablePipe {
2211
+ constructor() {
2212
+ this.transform = (selectedItems, rowData, selection) => {
2213
+ const { disabled, actions } = selection;
2214
+ if (!(actions === null || actions === void 0 ? void 0 : actions.length)) {
2215
+ if (!disabled) {
2216
+ rowData.meta.selector.selectable = true;
2217
+ return false;
2218
+ }
2219
+ rowData.meta.selector.selectable = !disabled(rowData, selectedItems);
2220
+ return !rowData.meta.selector.selectable;
2221
+ }
2222
+ // Lọc các action theo selectedItems hiện tại
2223
+ const availableActions = actions.filter(action => {
2224
+ if ('children' in action) {
2225
+ for (const childAction of action.children) {
2226
+ const key = hash__default(childAction);
2227
+ if (selectedItems.every(e => e.meta.selector.actions.includes(key))) {
2228
+ return true;
2229
+ }
2230
+ }
2231
+ return false;
2232
+ }
2233
+ else {
2234
+ const key = hash__default(action);
2235
+ return selectedItems.every(e => e.meta.selector.actions.includes(key));
2236
+ }
2237
+ });
2238
+ // Kiểm tra rowData có action nào thỏa hay ko, nếu ko thì disabled
2239
+ for (const action of availableActions) {
2240
+ if ('children' in action) {
2241
+ for (const childAction of action.children) {
2242
+ if (rowData.meta.selector.actions.includes(hash__default(childAction))) {
2243
+ return false;
2244
+ }
2245
+ }
2246
+ }
2247
+ else {
2248
+ if (rowData.meta.selector.actions.includes(hash__default(action))) {
2249
+ return false;
2250
+ }
2251
+ }
2252
+ }
2253
+ return true;
2254
+ };
2255
+ }
2256
+ }
2257
+ SdSelectionDisablePipe.decorators = [
2258
+ { type: Pipe, args: [{
2259
+ name: 'selectionDisable'
2260
+ },] }
2261
+ ];
2262
+
2263
+ class SdSelectionVisibleSelectAllPipe {
2264
+ constructor() {
2265
+ this.transform = (items, selection) => __awaiter(this, void 0, void 0, function* () {
2266
+ const { actions } = selection;
2267
+ if (!(actions === null || actions === void 0 ? void 0 : actions.length)) {
2268
+ return true;
2269
+ }
2270
+ if (!items.length) {
2271
+ return false;
2272
+ }
2273
+ if (actions.some(e => ('children' in e && e.children.some(e1 => e1.isGrouped)) || e.isGrouped)) {
2274
+ return false;
2275
+ }
2276
+ yield new Promise(resolve => setTimeout(resolve, 500));
2277
+ const first = items.find(t => { var _a; return (_a = t.meta.selector.actions) === null || _a === void 0 ? void 0 : _a.length; });
2278
+ if (first) {
2279
+ for (const action of first.meta.selector.actions) {
2280
+ if (items.filter(t => { var _a; return (_a = t.meta.selector.actions) === null || _a === void 0 ? void 0 : _a.length; }).every(e => e.meta.selector.actions.includes(action))) {
2281
+ return true;
2282
+ }
2283
+ }
2284
+ }
2285
+ return false;
2286
+ });
2287
+ }
2288
+ }
2289
+ SdSelectionVisibleSelectAllPipe.decorators = [
2290
+ { type: Pipe, args: [{
2291
+ name: 'selectionVisibleSelectAll'
2292
+ },] }
2293
+ ];
2294
+
2295
+ class SdDesktopCell {
2296
+ constructor() {
2297
+ this.cellDef = {};
2298
+ }
2299
+ }
2300
+ SdDesktopCell.decorators = [
2301
+ { type: Component, args: [{
2302
+ selector: 'sd-desktop-cell',
2303
+ template: "<ng-container *ngIf=\"cellDef[column.field]\">\r\n <ng-container *ngTemplateOutlet=\"cellDef[column.field].templateRef; context: { item: item, column: column, idx: idx }\"> </ng-container>\r\n</ng-container>\r\n<sd-desktop-cell-view\r\n *ngIf=\"!cellDef[column.field]\"\r\n [sdId]=\"item.meta.id\"\r\n [key]=\"key\"\r\n [column]=\"column\"\r\n [gridOption]=\"gridOption\"\r\n [item]=\"item\">\r\n</sd-desktop-cell-view>\r\n",
2304
+ changeDetection: ChangeDetectionStrategy.OnPush
2305
+ },] }
2306
+ ];
2307
+ SdDesktopCell.ctorParameters = () => [];
2308
+ SdDesktopCell.propDecorators = {
2309
+ sdId: [{ type: Input }],
2310
+ value: [{ type: Input }],
2311
+ key: [{ type: Input }],
2312
+ column: [{ type: Input }],
2313
+ item: [{ type: Input }],
2314
+ gridOption: [{ type: Input }],
2315
+ cellDef: [{ type: Input }],
2316
+ idx: [{ type: Input }]
2317
+ };
2318
+
2319
+ const SdFilterOperators = [
2320
+ {
2321
+ value: 'EQUAL',
2322
+ display: '=',
2323
+ },
2324
+ {
2325
+ value: 'NOT_EQUAL',
2326
+ display: '!=',
2327
+ },
2328
+ {
2329
+ value: 'CONTAIN',
2330
+ display: '∈',
2331
+ },
2332
+ // {
2333
+ // value: 'START_WITH';
2334
+ // display: '=';
2335
+ // },
2336
+ // {
2337
+ // value: 'END_WITH';
2338
+ // display: '=';
2339
+ // },
2340
+ {
2341
+ value: 'GREATER_THAN',
2342
+ display: '>',
2343
+ },
2344
+ {
2345
+ value: 'LESS_THAN',
2346
+ display: '<',
2347
+ },
2348
+ {
2349
+ value: 'GREATER_OR_EQUAL',
2350
+ display: '>=',
2351
+ },
2352
+ {
2353
+ value: 'LESS_OR_EQUAL',
2354
+ display: '<=',
2355
+ },
2356
+ ];
2357
+
2358
+ var _valueChanges, _subcription;
2359
+ class SdColumnInlineFilter {
2360
+ constructor() {
2361
+ this.columnOperator = {};
2362
+ this.columnFilter = {};
2363
+ this.operators = [];
2364
+ this.filterChange = new EventEmitter();
2365
+ _valueChanges.set(this, new Subject());
2366
+ _subcription.set(this, new Subscription());
2367
+ this.onFilterChange = () => {
2368
+ this.filterChange.emit();
2369
+ };
2370
+ }
2371
+ _value(value) {
2372
+ this.value = value;
2373
+ __classPrivateFieldGet(this, _valueChanges).next();
2374
+ }
2375
+ set _columnOperator(columnOperator) {
2376
+ this.columnOperator = columnOperator || {};
2377
+ }
2378
+ set _columnFilter(columnFilter) {
2379
+ this.columnFilter = columnFilter || {};
2380
+ __classPrivateFieldGet(this, _valueChanges).next();
2381
+ }
2382
+ set _column(column) {
2383
+ var _a, _b, _c;
2384
+ this.column = column;
2385
+ if (!((_a = column === null || column === void 0 ? void 0 : column.filter) === null || _a === void 0 ? void 0 : _a.disabled) && ((_c = (_b = column === null || column === void 0 ? void 0 : column.filter) === null || _b === void 0 ? void 0 : _b.operator) === null || _c === void 0 ? void 0 : _c.enable)) {
2386
+ this.operators = SdFilterOperators.filter(e => { var _a, _b; return (_b = (_a = column.filter.operator.list) === null || _a === void 0 ? void 0 : _a.includes) === null || _b === void 0 ? void 0 : _b.call(_a, e.value); });
2387
+ }
2388
+ else {
2389
+ this.operators = [];
2390
+ }
2391
+ }
2392
+ ngOnInit() {
2393
+ __classPrivateFieldGet(this, _subcription).add(__classPrivateFieldGet(this, _valueChanges).pipe(startWith(this.columnFilter)).subscribe(() => {
2394
+ var _a, _b;
2395
+ if (this.column.type === 'date' || this.column.type === 'time' || this.column.type === 'datetime') {
2396
+ if (!((_b = (_a = this.column) === null || _a === void 0 ? void 0 : _a.option) === null || _b === void 0 ? void 0 : _b.useFilterDate)) {
2397
+ this.columnFilter[this.column.field] = this.columnFilter[this.column.field] || {
2398
+ from: null,
2399
+ to: null,
2400
+ };
2401
+ }
2402
+ }
2403
+ }));
2404
+ }
2405
+ ngOnDestroy() {
2406
+ __classPrivateFieldGet(this, _subcription).unsubscribe();
2407
+ }
2408
+ }
2409
+ _valueChanges = new WeakMap(), _subcription = new WeakMap();
2410
+ SdColumnInlineFilter.decorators = [
2411
+ { type: Component, args: [{
2412
+ selector: 'sd-column-inline-filter',
2413
+ template: "<div class=\"d-flex c-inline-column\">\r\n <ng-container\r\n *ngIf=\"\r\n column.type === 'string' ||\r\n column.type === 'number' ||\r\n column.type === 'bool' ||\r\n column.type === 'values' ||\r\n column.type === 'date' ||\r\n column.type === 'datetime' ||\r\n column.type === 'time';\r\n else noFilter\r\n \">\r\n <sd-select\r\n *ngIf=\"operators.length\"\r\n style=\"width: 60px; margin-right: 4px\"\r\n size=\"sm\"\r\n [items]=\"operators\"\r\n valueField=\"value\"\r\n displayField=\"display\"\r\n required\r\n [(model)]=\"columnOperator[column.field]\"></sd-select>\r\n <sd-input\r\n *ngIf=\"column.type === 'string'\"\r\n style=\"flex: 1\"\r\n size=\"sm\"\r\n type=\"text\"\r\n [(model)]=\"columnFilter[column.field]\"\r\n (keyupEnter)=\"onFilterChange()\"\r\n [disabled]=\"column.filter?.disabled\">\r\n </sd-input>\r\n <sd-input-number\r\n *ngIf=\"column.type === 'number'\"\r\n style=\"flex: 1\"\r\n size=\"sm\"\r\n [(model)]=\"columnFilter[column.field]\"\r\n (keyupEnter)=\"onFilterChange()\"\r\n [disabled]=\"column.filter?.disabled\">\r\n </sd-input-number>\r\n <sd-select\r\n *ngIf=\"column.type === 'bool'\"\r\n style=\"flex: 1\"\r\n size=\"sm\"\r\n [items]=\"[\r\n { value: '1', display: column.option?.displayOnTrue || 'True' },\r\n { value: '0', display: column.option?.displayOnFalse || 'False' }\r\n ]\"\r\n valueField=\"value\"\r\n displayField=\"display\"\r\n [(model)]=\"columnFilter[column.field]\"\r\n (sdChange)=\"onFilterChange()\"\r\n [disabled]=\"column.filter?.disabled\">\r\n <ng-template sdSelectDisplayDef let-item=\"item\">\r\n <sd-badge *ngIf=\"item.value === '1'\" color=\"success\" [title]=\"column.option?.displayOnTrue || 'True'\"> </sd-badge>\r\n <sd-badge *ngIf=\"item.value === '0'\" color=\"danger\" [title]=\"column.option?.displayOnFalse || 'False'\"> </sd-badge>\r\n </ng-template>\r\n </sd-select>\r\n <sd-select\r\n *ngIf=\"column.type === 'values' && column?.option?.selection !== 'AUTOCOMPLETE'\"\r\n style=\"flex: 1\"\r\n size=\"sm\"\r\n [items]=\"column.option.items\"\r\n [valueField]=\"column.option.valueField\"\r\n [displayField]=\"column.option.displayField\"\r\n [(model)]=\"columnFilter[column.field]\"\r\n (sdChange)=\"onFilterChange()\"\r\n [disabled]=\"column.filter?.disabled\"\r\n [multiple]=\"column?.option?.selection === 'MULTIPLE' || column?.option?.selection === 'MULTIPLEAUTOCOMPLETE'\"\r\n [filtered]=\"column?.option?.selection === 'MULTIPLEAUTOCOMPLETE'\">\r\n </sd-select>\r\n <sd-autocomplete\r\n *ngIf=\"column.type === 'values' && column?.option?.selection === 'AUTOCOMPLETE'\"\r\n style=\"flex: 1\"\r\n size=\"sm\"\r\n [items]=\"column.option.items\"\r\n [valueField]=\"column.option.valueField\"\r\n [displayField]=\"column.option.displayField\"\r\n [(model)]=\"columnFilter[column.field]\"\r\n (sdChange)=\"onFilterChange()\"\r\n [disabled]=\"column.filter?.disabled\">\r\n </sd-autocomplete>\r\n <ng-container *ngIf=\"column.type === 'date' || column.type === 'datetime' || column.type === 'time'\">\r\n <sd-date-range\r\n *ngIf=\"!column.option?.useFilterDate\"\r\n style=\"flex: 1\"\r\n size=\"sm\"\r\n [(from)]=\"columnFilter[column.field].from\"\r\n [(to)]=\"columnFilter[column.field].to\"\r\n (sdChange)=\"onFilterChange()\"\r\n [disabled]=\"column.filter?.disabled\">\r\n </sd-date-range>\r\n <sd-date-time\r\n *ngIf=\"column.option?.useFilterDate\"\r\n style=\"flex: 1\"\r\n type=\"date\"\r\n size=\"sm\"\r\n [(model)]=\"columnFilter[column.field]\"\r\n (sdChange)=\"onFilterChange()\"\r\n [disabled]=\"column.filter?.disabled\">\r\n </sd-date-time>\r\n </ng-container>\r\n </ng-container>\r\n <ng-template #noFilter>\r\n <sd-input type=\"text\" size=\"sm\" disabled> </sd-input>\r\n </ng-template>\r\n</div>\r\n",
2414
+ changeDetection: ChangeDetectionStrategy.OnPush,
2415
+ styles: [":host ::ng-deep .c-inline-column .mat-form-field-wrapper{background-color:#fff;border-radius:8px;margin:8px 0 0!important;padding:0!important}"]
2416
+ },] }
2417
+ ];
2418
+ SdColumnInlineFilter.ctorParameters = () => [];
2419
+ SdColumnInlineFilter.propDecorators = {
2420
+ _value: [{ type: Input, args: ['value',] }],
2421
+ _columnOperator: [{ type: Input, args: ['columnOperator',] }],
2422
+ _columnFilter: [{ type: Input, args: ['columnFilter',] }],
2423
+ _column: [{ type: Input, args: ['column',] }],
2424
+ filterChange: [{ type: Output }]
2425
+ };
2426
+
2427
+ class SdSelectionVisiblePipe {
2428
+ constructor() {
2429
+ this.transform = (rowData, selection) => {
2430
+ var _a, _b, _c;
2431
+ const { actions } = selection;
2432
+ const groupedActions = [];
2433
+ rowData.meta.selector.actions = rowData.meta.selector.actions || [];
2434
+ if (!(actions === null || actions === void 0 ? void 0 : actions.length)) {
2435
+ rowData.meta.selector.selectable = true;
2436
+ return rowData.meta.selector.selectable;
2437
+ }
2438
+ for (const action of actions) {
2439
+ if ('children' in action) {
2440
+ let flag = false;
2441
+ let hasGroup = false;
2442
+ for (const childAction of action.children) {
2443
+ const { hidden, isGrouped } = childAction;
2444
+ const key = hash__default(childAction);
2445
+ if (isGrouped) {
2446
+ hasGroup = true;
2447
+ }
2448
+ if (typeof (hidden) === 'function') {
2449
+ if (!hidden(rowData)) {
2450
+ flag = true;
2451
+ rowData.meta.selector.actions.push(key);
2452
+ if (isGrouped) {
2453
+ groupedActions.push(key);
2454
+ }
2455
+ }
2456
+ }
2457
+ else if (!hidden) {
2458
+ flag = true;
2459
+ rowData.meta.selector.actions.push(key);
2460
+ if (isGrouped) {
2461
+ groupedActions.push(key);
2462
+ }
2463
+ }
2464
+ }
2465
+ if (flag) {
2466
+ rowData.meta.selector.actions.push(hash__default(action));
2467
+ if (hasGroup) {
2468
+ groupedActions.push(hash__default(action));
2469
+ }
2470
+ }
2471
+ }
2472
+ else {
2473
+ const { hidden, isGrouped } = action;
2474
+ const key = hash__default(action);
2475
+ if (typeof (hidden) === 'function') {
2476
+ if (!hidden(rowData)) {
2477
+ rowData.meta.selector.actions.push(key);
2478
+ if (isGrouped) {
2479
+ groupedActions.push(key);
2480
+ }
2481
+ }
2482
+ }
2483
+ else if (!hidden) {
2484
+ rowData.meta.selector.actions.push(key);
2485
+ if (isGrouped) {
2486
+ groupedActions.push(key);
2487
+ }
2488
+ }
2489
+ }
2490
+ }
2491
+ rowData.meta.selector.selectable = !!((_a = rowData.meta.selector.actions) === null || _a === void 0 ? void 0 : _a.length);
2492
+ if (!rowData.meta.selector.selectable || !groupedActions.length || ((_c = (_b = rowData === null || rowData === void 0 ? void 0 : rowData.meta.group) === null || _b === void 0 ? void 0 : _b.items) === null || _c === void 0 ? void 0 : _c.length)) {
2493
+ return rowData.meta.selector.selectable;
2494
+ }
2495
+ // Đối với trường hợp grouped, tuy selectable là true nhưng vẫn ẩn đi checkbox
2496
+ // nếu các action đều thuộc groupedActions và rowData ko phải là dòng group
2497
+ return rowData.meta.selector.actions.some(action => !groupedActions.includes(action));
2498
+ };
2499
+ }
2500
+ }
2501
+ SdSelectionVisiblePipe.decorators = [
2502
+ { type: Pipe, args: [{
2503
+ name: 'selectionVisible'
2504
+ },] }
2505
+ ];
2506
+
2507
+ class SdGridQuickAction {
2508
+ constructor() {
2509
+ this.clear = new EventEmitter();
2510
+ this.onClear = () => {
2511
+ this.clear.emit();
2512
+ };
2513
+ }
2514
+ }
2515
+ SdGridQuickAction.decorators = [
2516
+ { type: Component, args: [{
2517
+ selector: 'sd-grid-quick-action',
2518
+ template: "<sd-quick-action *ngIf=\"selectedItems | selectionActionFilter: gridOption?.selector?.actions as actions\"\r\n [isOpened]=\"actions?.length\">\r\n <div class=\"d-flex align-items-center\" sdMessage>\r\n <div class=\"c-bg-length\">\r\n <span class=\"c-length\">{{ selectedItems.length }}</span>\r\n </div>\r\n <div class=\"c-message\">{{ gridOption?.selector?.message || 'd\u1EEF li\u1EC7u \u0111\u01B0\u1EE3c ch\u1ECDn' }}</div>\r\n </div>\r\n <div class=\"d-flex align-items-center mr-8\" sdAction>\r\n <ng-container *ngFor=\"let action of actions\">\r\n <sd-button *ngIf=\"action.click\" class=\"ml-5\" [tooltip]=\"action.tooltip\" [icon]=\"action.icon\"\r\n [color]=\"action.color || 'secondary'\" [type]=\"action.type || 'light'\" [fontSet]=\"action.fontSet\"\r\n [title]=\"action.title\" size=\"sm\" (action)=\"action.click(selectedItems)\"></sd-button>\r\n <ng-container *ngIf=\"action.children?.length\">\r\n <sd-button class=\"ml-5\" [tooltip]=\"action.tooltip\" [icon]=\"action.icon || 'more_vert'\"\r\n [color]=\"action.color || 'secondary'\" [type]=\"action.type || 'light'\" [fontSet]=\"action.fontSet\"\r\n [title]=\"action.title\" size=\"sm\" [matMenuTriggerFor]=\"menu\">\r\n </sd-button>\r\n <mat-menu #menu=\"matMenu\">\r\n <span>\r\n <button *ngFor=\"let childAction of action.children\" mat-menu-item (click)=\"childAction.click(selectedItems)\"\r\n [disabled]=\"childAction.disabled\">\r\n <mat-icon [fontSet]=\"childAction.fontSet\" class=\"c-icon\">{{ childAction.icon }}\r\n </mat-icon>\r\n <span> {{ childAction.title }}</span>\r\n </button>\r\n </span>\r\n </mat-menu>\r\n </ng-container>\r\n </ng-container>\r\n <sd-button class=\"ml-5\" icon=\"close\" color=\"secondary\" type=\"outline\" size=\"sm\"\r\n (action)=\"onClear()\" width=\"35px\"></sd-button>\r\n </div>\r\n</sd-quick-action>",
2519
+ changeDetection: ChangeDetectionStrategy.OnPush,
2520
+ styles: [".c-bg-length{align-items:flex-start;background:#2962ff;border-radius:4px 0 0 4px;display:flex;flex-direction:column;height:48px;left:0;min-width:48px;padding:12px 8px;position:static;top:0;width:auto}.c-bg-length .c-length{color:#fff;font-size:16px;font-weight:500;height:24px;left:8px;line-height:24px;min-width:32px;text-align:center;top:12px;width:auto}.c-bg-length .c-length,.c-message{font-family:Roboto;font-style:normal;position:static}.c-message{color:#000;font-size:14px;font-weight:400;height:20px;left:0;line-height:20px;margin:0 0 0 16px;min-width:200px;top:6px}"]
2521
+ },] }
2522
+ ];
2523
+ SdGridQuickAction.ctorParameters = () => [];
2524
+ SdGridQuickAction.propDecorators = {
2525
+ gridOption: [{ type: Input }],
2526
+ selectedItems: [{ type: Input }],
2527
+ clear: [{ type: Output }]
2528
+ };
2529
+
2530
+ var _maxSecond, _maxMinute, _maxHour, _maxDay, _maxMonth, _isMobileOrTablet$1;
2531
+ class SdCellViewPipe {
2532
+ constructor(deviceService, utilityService, columnValuesPipe) {
2533
+ this.utilityService = utilityService;
2534
+ this.columnValuesPipe = columnValuesPipe;
2535
+ _maxSecond.set(this, 60);
2536
+ _maxMinute.set(this, __classPrivateFieldGet(this, _maxSecond) * 60);
2537
+ _maxHour.set(this, __classPrivateFieldGet(this, _maxMinute) * 24);
2538
+ _maxDay.set(this, __classPrivateFieldGet(this, _maxHour) * 30);
2539
+ _maxMonth.set(this, __classPrivateFieldGet(this, _maxHour) * 365);
2540
+ _isMobileOrTablet$1.set(this, false);
2541
+ __classPrivateFieldSet(this, _isMobileOrTablet$1, !deviceService.isDesktop());
2542
+ }
2543
+ transform(value, tableItem, column, gridOption) {
2544
+ var _a;
2545
+ return __awaiter(this, void 0, void 0, function* () {
2546
+ const { displayOnEmpty } = gridOption;
2547
+ const rowData = tableItem.current;
2548
+ const { align, click, tooltip, htmlTemplate, transform } = column;
2549
+ const result = {
2550
+ badge: null,
2551
+ tooltip: null,
2552
+ display: {
2553
+ align: align || (column.type === 'number' ? 'right' : 'left'),
2554
+ value
2555
+ },
2556
+ click: null
2557
+ };
2558
+ // Display
2559
+ if (typeof (htmlTemplate) === 'function') {
2560
+ result.display.hasHtml = true;
2561
+ result.display.html = htmlTemplate(value, rowData, __classPrivateFieldGet(this, _isMobileOrTablet$1));
2562
+ }
2563
+ else {
2564
+ if (column.type === 'datetime' || column.type === 'date' || column.type === 'time') {
2565
+ const { transformDate } = column;
2566
+ if (transformDate) {
2567
+ value = transformDate(value, rowData);
2568
+ }
2569
+ }
2570
+ if (typeof (transform) === 'function') {
2571
+ const val = transform(value, rowData);
2572
+ if (val instanceof Promise) {
2573
+ result.display.value = yield val;
2574
+ }
2575
+ else {
2576
+ result.display.value = val;
2577
+ }
2578
+ }
2579
+ else {
2580
+ if (column.type === 'date' || column.type === 'datetime') {
2581
+ const { option } = column;
2582
+ const seconds = Math.round((new Date().getTime() - new Date(value).getTime()) / 1000);
2583
+ if ((option === null || option === void 0 ? void 0 : option.timeDifferent) === 'month' && seconds < __classPrivateFieldGet(this, _maxMonth)) {
2584
+ result.display.value = this.utilityService.timeDifference(value);
2585
+ result.tooltip = Date.toFormat(value, column.type === 'date' ? 'dd/MM/yyyy' : 'dd/MM/yyyy HH:mm');
2586
+ }
2587
+ else if ((option === null || option === void 0 ? void 0 : option.timeDifferent) === 'day' && seconds < __classPrivateFieldGet(this, _maxDay)) {
2588
+ result.display.value = this.utilityService.timeDifference(value);
2589
+ result.tooltip = Date.toFormat(value, column.type === 'date' ? 'dd/MM/yyyy' : 'dd/MM/yyyy HH:mm');
2590
+ }
2591
+ else if ((option === null || option === void 0 ? void 0 : option.timeDifferent) === 'hour' && seconds < __classPrivateFieldGet(this, _maxHour)) {
2592
+ result.display.value = this.utilityService.timeDifference(value);
2593
+ result.tooltip = Date.toFormat(value, column.type === 'date' ? 'dd/MM/yyyy' : 'dd/MM/yyyy HH:mm');
2594
+ }
2595
+ else if ((option === null || option === void 0 ? void 0 : option.timeDifferent) === 'minute' && seconds < __classPrivateFieldGet(this, _maxMinute)) {
2596
+ result.display.value = this.utilityService.timeDifference(value);
2597
+ result.tooltip = Date.toFormat(value, column.type === 'date' ? 'dd/MM/yyyy' : 'dd/MM/yyyy HH:mm');
2598
+ }
2599
+ else if ((option === null || option === void 0 ? void 0 : option.timeDifferent) === 'second' && seconds < __classPrivateFieldGet(this, _maxSecond)) {
2600
+ result.display.value = this.utilityService.timeDifference(value);
2601
+ result.tooltip = Date.toFormat(value, column.type === 'date' ? 'dd/MM/yyyy' : 'dd/MM/yyyy HH:mm');
2602
+ }
2603
+ else {
2604
+ const date = Date.toFormat(value, 'dd/MM/yyyy');
2605
+ const time = Date.toFormat(value, 'HH:mm');
2606
+ const dateTime = Date.toFormat(value, 'HH:mm');
2607
+ if (column.type === 'datetime' && time && time !== '00:00') {
2608
+ result.display.value = dateTime;
2609
+ result.display.hasHtml = true;
2610
+ result.display.html = `<span class="d-block T14R text-black400">${Date.toFormat(value, 'HH:mm')}</span><span class="d-block T14R">${Date.toFormat(value, 'dd/MM/yyyy')}</span>`;
2611
+ }
2612
+ else {
2613
+ result.display.value = date;
2614
+ }
2615
+ }
2616
+ }
2617
+ if (column.type === 'time') {
2618
+ result.display.value = Date.toFormat(value, 'HH:mm');
2619
+ }
2620
+ if (column.type === 'values') {
2621
+ result.display.value = yield this.columnValuesPipe.transform(value, column);
2622
+ }
2623
+ else if (column.type === 'number' && Number.isNumber(value)) {
2624
+ result.display.value = Number.toVNCurrency(value);
2625
+ }
2626
+ if (column.type === 'bool') {
2627
+ const { option } = column;
2628
+ if (value !== undefined && value !== null && value !== '') {
2629
+ result.display.value = value === true ? ((option === null || option === void 0 ? void 0 : option.displayOnTrue) || 'True') : ((option === null || option === void 0 ? void 0 : option.displayOnFalse) || 'False');
2630
+ }
2631
+ else {
2632
+ result.display.value = null;
2633
+ }
2634
+ }
2635
+ }
2636
+ if (displayOnEmpty) {
2637
+ let values = [null, undefined, ''];
2638
+ if (typeof (displayOnEmpty) === 'object') {
2639
+ const { display, emptyValues } = displayOnEmpty;
2640
+ values = [null, undefined, '', ...emptyValues];
2641
+ if (values.includes(result.display.value)) {
2642
+ if (typeof (display) === 'function') {
2643
+ result.display.hasHtml = true;
2644
+ result.display.html = display(rowData, column);
2645
+ }
2646
+ else {
2647
+ result.display.hasHtml = true;
2648
+ result.display.html = `<div class="T16R text-black400">--</div>`;
2649
+ }
2650
+ }
2651
+ }
2652
+ else {
2653
+ if (values.includes(result.display.value)) {
2654
+ if (typeof (displayOnEmpty) === 'function') {
2655
+ result.display.hasHtml = true;
2656
+ result.display.html = displayOnEmpty(rowData, column);
2657
+ }
2658
+ else {
2659
+ result.display.hasHtml = true;
2660
+ result.display.html = `<div class="T16R text-black400">--</div>`;
2661
+ }
2662
+ }
2663
+ }
2664
+ }
2665
+ }
2666
+ // Badge
2667
+ if ((column.type === 'string' || column.type === 'number' || column.type === 'values') && column.badge) {
2668
+ result.badge = {
2669
+ type: !(column === null || column === void 0 ? void 0 : column.badgeType) ? 'round' : column.badgeType,
2670
+ color: column.badge(value, rowData),
2671
+ icon: (_a = column === null || column === void 0 ? void 0 : column.badgeIcon) === null || _a === void 0 ? void 0 : _a.call(column, value, rowData)
2672
+ };
2673
+ }
2674
+ else if (column.type === 'bool') {
2675
+ result.badge = {
2676
+ type: !(column === null || column === void 0 ? void 0 : column.badgeType) ? 'round' : column.badgeType,
2677
+ color: !!value ? 'success' : 'danger',
2678
+ icon: null
2679
+ };
2680
+ }
2681
+ // Tooltip
2682
+ if (typeof (tooltip) === 'function') {
2683
+ result.tooltip = tooltip(value, rowData);
2684
+ }
2685
+ // Clickable
2686
+ if (typeof (click) === 'function') {
2687
+ result.click = () => click(value, rowData);
2688
+ }
2689
+ return result;
2690
+ });
2691
+ }
2692
+ }
2693
+ _maxSecond = new WeakMap(), _maxMinute = new WeakMap(), _maxHour = new WeakMap(), _maxDay = new WeakMap(), _maxMonth = new WeakMap(), _isMobileOrTablet$1 = new WeakMap();
2694
+ SdCellViewPipe.decorators = [
2695
+ { type: Pipe, args: [{
2696
+ name: 'cellView'
2697
+ },] }
2698
+ ];
2699
+ SdCellViewPipe.ctorParameters = () => [
2700
+ { type: DeviceDetectorService },
2701
+ { type: SdUtilityService },
2702
+ { type: SdColumnValuesPipe }
2703
+ ];
2704
+
2705
+ class SdGroupPipe {
2706
+ transform(items, gridOption) {
2707
+ var _a;
2708
+ const { group } = gridOption;
2709
+ if (!group) {
2710
+ return items;
2711
+ }
2712
+ const { fields, htmlTemplate } = group;
2713
+ if (!(fields === null || fields === void 0 ? void 0 : fields.length)) {
2714
+ return items;
2715
+ }
2716
+ const groupItem = {};
2717
+ for (const item of items) {
2718
+ let obj = {};
2719
+ for (const field of fields) {
2720
+ obj = Object.assign(Object.assign({}, obj), ((_a = item[field]) !== null && _a !== void 0 ? _a : { [field]: item[field] }));
2721
+ }
2722
+ const key = hash__default(obj);
2723
+ if (!groupItem[key]) {
2724
+ groupItem[key] = [];
2725
+ }
2726
+ groupItem[key].push(item);
2727
+ }
2728
+ const results = [];
2729
+ for (const key of Object.keys(groupItem)) {
2730
+ const result = MapToSdTableItem({});
2731
+ result.meta.group.items = groupItem[key];
2732
+ result.meta.group.htmlTemplate = htmlTemplate(groupItem[key]);
2733
+ results.push(result);
2734
+ for (const item of groupItem[key]) {
2735
+ results.push(item);
2736
+ }
2737
+ }
2738
+ return results;
2739
+ }
2740
+ }
2741
+ SdGroupPipe.decorators = [
2742
+ { type: Pipe, args: [{
2743
+ name: 'sdGroup',
2744
+ },] }
2745
+ ];
2746
+
2747
+ class MatPaginatorIntlCro extends MatPaginatorIntl {
2748
+ constructor() {
2749
+ super(...arguments);
2750
+ this.firstPageLabel = 'Trang đầu';
2751
+ this.lastPageLabel = 'Trang cuối';
2752
+ this.itemsPerPageLabel = 'Kích thước trang';
2753
+ this.nextPageLabel = 'Trang sau';
2754
+ this.previousPageLabel = 'Trang trước';
2755
+ this.getRangeLabel = (page, pageSize, length) => {
2756
+ if (length === 0 || pageSize === 0) {
2757
+ return '';
2758
+ }
2759
+ const from = page * pageSize + 1;
2760
+ const to = from + (length - page * pageSize > pageSize ? pageSize : length - page * pageSize) - 1;
2761
+ return `${from}-${to} trên ${length}`;
2762
+ };
2763
+ }
2764
+ }
2765
+ MatPaginatorIntlCro.decorators = [
2766
+ { type: Injectable }
2767
+ ];
2768
+ class SdTableModule {
2769
+ }
2770
+ SdTableModule.decorators = [
2771
+ { type: NgModule, args: [{
2772
+ imports: [
2773
+ CommonModule,
2774
+ FormsModule,
2775
+ ReactiveFormsModule,
2776
+ MatInputModule,
2777
+ MatFormFieldModule,
2778
+ MatSortModule,
2779
+ MatPaginatorModule,
2780
+ MatTableModule,
2781
+ MatMenuModule,
2782
+ MatIconModule,
2783
+ MatButtonModule,
2784
+ MatTooltipModule,
2785
+ MatProgressSpinnerModule,
2786
+ MatChipsModule,
2787
+ MatRadioModule,
2788
+ MatSlideToggleModule,
2789
+ MatCheckboxModule,
2790
+ MatListModule,
2791
+ MatDividerModule,
2792
+ CdkTableModule,
2793
+ DragDropModule,
2794
+ SdFormModule,
2795
+ SdServiceModule,
2796
+ MatSliderModule,
2797
+ ScrollingModule,
2798
+ SdCommonModule,
2799
+ SdGroupModule,
2800
+ ],
2801
+ declarations: [
2802
+ SdGridQuickAction,
2803
+ SdDesktopCell,
2804
+ SdDesktopCellView,
2805
+ SdDesktopCommand,
2806
+ SdColumnInlineFilter,
2807
+ SdTable,
2808
+ SdMaterialFooterDefDirective,
2809
+ SdMaterialCellDefDirective,
2810
+ SdMaterialFilterDefDirective,
2811
+ SdMaterialSubInformationDefDirective,
2812
+ SdMaterialEmptyDataDefDirective,
2813
+ SdPopupGridConfiguration,
2814
+ SdGridFilter,
2815
+ SdPopupFilter,
2816
+ // Pipes
2817
+ SdGridConfigurationResultPipe,
2818
+ SdColumnChildrenFilterPipe,
2819
+ SdCommandFilterPipe,
2820
+ SdCommandDisablePipe,
2821
+ SdCommandIconPipe,
2822
+ SdCommandTitlePipe,
2823
+ SdColumnValuesPipe,
2824
+ SdColumnHtmlTemplatePipe,
2825
+ SdColumnTransformPipe,
2826
+ SdColumnTooltipPipe,
2827
+ SdColumnBadgePipe,
2828
+ SdFilterColumnPipe,
2829
+ SdFilterExternalPipe,
2830
+ SdSelectionActionFilterPipe,
2831
+ SdSelectionVisiblePipe,
2832
+ SdSelectionDisablePipe,
2833
+ SdSelectionVisibleSelectAllPipe,
2834
+ SdCellViewPipe,
2835
+ SdGroupPipe,
2836
+ ],
2837
+ exports: [
2838
+ SdTable,
2839
+ SdMaterialFooterDefDirective,
2840
+ SdMaterialCellDefDirective,
2841
+ SdMaterialFilterDefDirective,
2842
+ SdMaterialEmptyDataDefDirective,
2843
+ SdMaterialSubInformationDefDirective,
2844
+ ],
2845
+ providers: [
2846
+ DatePipe,
2847
+ DecimalPipe,
2848
+ CdkColumnDef,
2849
+ SdTableFilterService,
2850
+ SdTableConfigurationService,
2851
+ SdColumnValuesPipe,
2852
+ {
2853
+ provide: MatPaginatorIntl,
2854
+ useClass: MatPaginatorIntlCro,
2855
+ },
2856
+ ],
2857
+ },] }
2858
+ ];
2859
+
2860
+ /**
2861
+ * Generated bundle index. Do not edit.
2862
+ */
2863
+
2864
+ export { MatPaginatorIntlCro, SdFilterOperators, SdTable, SdTableModule, SdGridQuickAction as ɵa, SdDesktopCell as ɵb, SdColumnTooltipPipe as ɵba, SdColumnBadgePipe as ɵbb, SdFilterColumnPipe as ɵbc, SdFilterExternalPipe as ɵbd, SdSelectionActionFilterPipe as ɵbe, SdSelectionVisiblePipe as ɵbf, SdSelectionDisablePipe as ɵbg, SdSelectionVisibleSelectAllPipe as ɵbh, SdCellViewPipe as ɵbi, SdGroupPipe as ɵbj, SdDesktopCellView as ɵc, SdDesktopCommand as ɵd, SdColumnInlineFilter as ɵe, SdGridFilter as ɵf, SdPopupFilter as ɵg, SdMaterialSubInformationDefDirective as ɵh, SdMaterialEmptyDataDefDirective as ɵi, SdMaterialCellDefDirective as ɵj, SdMaterialFooterDefDirective as ɵk, SdMaterialFilterDefDirective as ɵl, TABLE_CONFIG as ɵn, SdTableConfigurationService as ɵo, SdColumnValuesPipe as ɵp, SdTableFilterService as ɵq, SdPopupGridConfiguration as ɵr, SdGridConfigurationResultPipe as ɵs, SdColumnChildrenFilterPipe as ɵt, SdCommandFilterPipe as ɵu, SdCommandDisablePipe as ɵv, SdCommandIconPipe as ɵw, SdCommandTitlePipe as ɵx, SdColumnHtmlTemplatePipe as ɵy, SdColumnTransformPipe as ɵz };
2865
+ //# sourceMappingURL=sd-angular-core-table.js.map