@zeedhi/vuetify 3.0.7 → 3.0.9

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 (133) hide show
  1. package/.package.json +54 -0
  2. package/dist/zd-vuetify.css +5462 -5462
  3. package/package.json +3 -3
  4. package/dist/components/tek-grid/TekGrid.js +0 -287
  5. package/dist/components/tek-grid/column-filter/TekGridColumnFilter.js +0 -201
  6. package/dist/components/tek-grid/column-header/TekGridHeaderRow.js +0 -134
  7. package/dist/components/tek-grid/columns-button/TekGridColumnsButton.js +0 -79
  8. package/dist/components/tek-grid/columns-button/TekGridColumnsOptionsController.js +0 -416
  9. package/dist/components/tek-grid/columns-button/TekGridColumnsOptionsModal.js +0 -501
  10. package/dist/components/tek-grid/filter-button/TekGridFilterButton.js +0 -36
  11. package/dist/components/tek-grid/indentation/TekGridIndentation.js +0 -20
  12. package/dist/components/tek-grid/layout-options/TekGridLayoutOptions.js +0 -101
  13. package/dist/components/tek-grid/row/TekGridFooterRow.js +0 -57
  14. package/dist/components/tek-grid/row/TekGridGroupRow.js +0 -58
  15. package/dist/composables/useTableLayout.js +0 -212
  16. package/dist/utils/isArrayOperation.js +0 -4
  17. package/types/components/tek-grid/TekGrid.d.ts +0 -7258
  18. package/types/components/tek-grid/TekGrid.ts.d.ts +0 -7258
  19. package/types/components/tek-grid/column-filter/TekGridColumnFilter.d.ts +0 -129
  20. package/types/components/tek-grid/column-filter/TekGridColumnFilter.ts.d.ts +0 -129
  21. package/types/components/tek-grid/column-header/TekGridHeaderRow.d.ts +0 -225
  22. package/types/components/tek-grid/column-header/TekGridHeaderRow.ts.d.ts +0 -225
  23. package/types/components/tek-grid/columns-button/TekGridColumnsButton.d.ts +0 -2432
  24. package/types/components/tek-grid/columns-button/TekGridColumnsButton.ts.d.ts +0 -2432
  25. package/types/components/tek-grid/columns-button/TekGridColumnsOptionsController.d.ts +0 -65
  26. package/types/components/tek-grid/columns-button/TekGridColumnsOptionsModal.d.ts +0 -9
  27. package/types/components/tek-grid/filter-button/TekGridFilterButton.d.ts +0 -2920
  28. package/types/components/tek-grid/filter-button/TekGridFilterButton.ts.d.ts +0 -2920
  29. package/types/components/tek-grid/indentation/TekGridIndentation.d.ts +0 -32
  30. package/types/components/tek-grid/indentation/TekGridIndentation.ts.d.ts +0 -32
  31. package/types/components/tek-grid/layout-options/TekGridLayoutOptions.d.ts +0 -1892
  32. package/types/components/tek-grid/layout-options/TekGridLayoutOptions.ts.d.ts +0 -1892
  33. package/types/components/tek-grid/row/TekGridFooterRow.d.ts +0 -90
  34. package/types/components/tek-grid/row/TekGridFooterRow.ts.d.ts +0 -90
  35. package/types/components/tek-grid/row/TekGridGroupRow.d.ts +0 -87
  36. package/types/components/tek-grid/row/TekGridGroupRow.ts.d.ts +0 -87
  37. package/types/components/tooltip-overflow/ZdTooltipOverflow.ts.d.ts +0 -50
  38. package/types/components/zd-activator-wrapper/ZdActivatorWrapper.ts.d.ts +0 -25
  39. package/types/components/zd-alert/ZdAlert.ts.d.ts +0 -884
  40. package/types/components/zd-badge/ZdBadge.ts.d.ts +0 -624
  41. package/types/components/zd-breadcrumbs/ZdBreadcrumbs.ts.d.ts +0 -697
  42. package/types/components/zd-button/ZdButton.ts.d.ts +0 -1158
  43. package/types/components/zd-button-group/ZdButtonGroup.ts.d.ts +0 -785
  44. package/types/components/zd-card/ZdCard.ts.d.ts +0 -1028
  45. package/types/components/zd-carousel/ZdCarousel.ts.d.ts +0 -2007
  46. package/types/components/zd-checkbox/ZdCheckbox.ts.d.ts +0 -642
  47. package/types/components/zd-checkbox-multiple/ZdCheckboxMultiple.ts.d.ts +0 -2010
  48. package/types/components/zd-chip/ZdChip.ts.d.ts +0 -1256
  49. package/types/components/zd-code-viewer/ZdCodeViewer.ts.d.ts +0 -791
  50. package/types/components/zd-col/ZdCol.ts.d.ts +0 -741
  51. package/types/components/zd-collapse-card/ZdCollapseCard.ts.d.ts +0 -1583
  52. package/types/components/zd-container/ZdContainer.ts.d.ts +0 -722
  53. package/types/components/zd-currency/ZdCurrency.ts.d.ts +0 -2024
  54. package/types/components/zd-date-input/ZdDateInput.ts.d.ts +0 -960
  55. package/types/components/zd-dialog/ZdDialog.ts.d.ts +0 -262
  56. package/types/components/zd-divider/ZdDivider.ts.d.ts +0 -623
  57. package/types/components/zd-dropdown/ZdDropdown.ts.d.ts +0 -836
  58. package/types/components/zd-footer/ZdFooter.ts.d.ts +0 -1262
  59. package/types/components/zd-form/ZdForm.ts.d.ts +0 -118
  60. package/types/components/zd-frame/ZdFrame.ts.d.ts +0 -138
  61. package/types/components/zd-frame-page/ZdFramePage.ts.d.ts +0 -805
  62. package/types/components/zd-grid/ZdGrid.ts.d.ts +0 -7304
  63. package/types/components/zd-grid/cell/ZdGridAction.ts.d.ts +0 -14
  64. package/types/components/zd-grid/cell/ZdGridCell.ts.d.ts +0 -68
  65. package/types/components/zd-grid/cell/ZdGridCellContent.ts.d.ts +0 -58
  66. package/types/components/zd-grid/cell/ZdGridCheckbox.ts.d.ts +0 -53
  67. package/types/components/zd-grid/column-header/ZdGridColumnHeader.ts.d.ts +0 -112
  68. package/types/components/zd-grid/column-header/ZdGridHeaderIcon.ts.d.ts +0 -46
  69. package/types/components/zd-grid/column-header/ZdGridHeaderRow.ts.d.ts +0 -165
  70. package/types/components/zd-grid/column-header/ZdGridSort.ts.d.ts +0 -47
  71. package/types/components/zd-grid/footer/ZdGridFooter.ts.d.ts +0 -2087
  72. package/types/components/zd-grid/helper/ZdGridHelper.ts.d.ts +0 -16
  73. package/types/components/zd-grid/row/TableRow.ts.d.ts +0 -34
  74. package/types/components/zd-grid/row/ZdGridRow.ts.d.ts +0 -105
  75. package/types/components/zd-grid/toolbar/ZdGridToolbar.ts.d.ts +0 -2086
  76. package/types/components/zd-grid-editable/ZdGridEditable.ts.d.ts +0 -8663
  77. package/types/components/zd-grid-editable/cell/ZdGridEditableCell.ts.d.ts +0 -637
  78. package/types/components/zd-grid-editable/row/ZdGridEditableRow.ts.d.ts +0 -126
  79. package/types/components/zd-header/ZdHeader.ts.d.ts +0 -1320
  80. package/types/components/zd-icon/ZdIcon.ts.d.ts +0 -383
  81. package/types/components/zd-image/ZdImage.ts.d.ts +0 -753
  82. package/types/components/zd-increment/ZdIncrement.ts.d.ts +0 -2069
  83. package/types/components/zd-iterable/ZdIterableNoData.ts.d.ts +0 -2089
  84. package/types/components/zd-iterable/zd-iterable-columns-button/ZdIterableColumnsButton.ts.d.ts +0 -1645
  85. package/types/components/zd-iterable/zd-iterable-page-info/ZdIterablePageInfo.ts.d.ts +0 -1081
  86. package/types/components/zd-iterable/zd-iterable-page-size/ZdIterablePageSize.ts.d.ts +0 -2763
  87. package/types/components/zd-iterable/zd-iterable-pagination/ZdIterablePagination.ts.d.ts +0 -1627
  88. package/types/components/zd-iterable/zd-search/ZdSearch.ts.d.ts +0 -766
  89. package/types/components/zd-iterable-component-render/ZdIterableComponentRender.ts.d.ts +0 -2484
  90. package/types/components/zd-layout/ZdLayout.ts.d.ts +0 -647
  91. package/types/components/zd-list/ZdList.ts.d.ts +0 -1140
  92. package/types/components/zd-list/ZdListGroup.ts.d.ts +0 -1332
  93. package/types/components/zd-list/ZdListItem.ts.d.ts +0 -848
  94. package/types/components/zd-loading/ZdLoading.ts.d.ts +0 -350
  95. package/types/components/zd-login/ZdLogin.ts.d.ts +0 -1072
  96. package/types/components/zd-login/ZdLoginButton.ts.d.ts +0 -1910
  97. package/types/components/zd-main/ZdMain.ts.d.ts +0 -619
  98. package/types/components/zd-master-detail/ZdMasterDetail.ts.d.ts +0 -684
  99. package/types/components/zd-menu/ZdMenu.ts.d.ts +0 -4484
  100. package/types/components/zd-menu/ZdMenuButton.ts.d.ts +0 -1142
  101. package/types/components/zd-menu/ZdMenuGroup.ts.d.ts +0 -6286
  102. package/types/components/zd-menu/ZdMenuLink.ts.d.ts +0 -10437
  103. package/types/components/zd-menu/ZdMenuSeparator.ts.d.ts +0 -600
  104. package/types/components/zd-modal/ZdModal.ts.d.ts +0 -10
  105. package/types/components/zd-modal/ZdModalCloseButton.ts.d.ts +0 -1137
  106. package/types/components/zd-month/ZdMonth.ts.d.ts +0 -2217
  107. package/types/components/zd-number-input/ZdNumberInput.ts.d.ts +0 -2021
  108. package/types/components/zd-password/ZdPassword.ts.d.ts +0 -2014
  109. package/types/components/zd-progress/ZdProgress.ts.d.ts +0 -859
  110. package/types/components/zd-radio/ZdRadio.ts.d.ts +0 -682
  111. package/types/components/zd-row/ZdRow.ts.d.ts +0 -734
  112. package/types/components/zd-select/ZdSelect.ts.d.ts +0 -313
  113. package/types/components/zd-select-multiple/ZdSelectMultiple.ts.d.ts +0 -333
  114. package/types/components/zd-svg-map/ZdSvgMap.ts.d.ts +0 -414
  115. package/types/components/zd-switch/ZdSwitch.ts.d.ts +0 -1918
  116. package/types/components/zd-table/ZdTable.ts.d.ts +0 -1092
  117. package/types/components/zd-tabs/ZdTab.ts.d.ts +0 -674
  118. package/types/components/zd-tabs/ZdTabItem.ts.d.ts +0 -268
  119. package/types/components/zd-tabs/ZdTabs.ts.d.ts +0 -929
  120. package/types/components/zd-tag/ZdTag.ts.d.ts +0 -613
  121. package/types/components/zd-text/ZdText.ts.d.ts +0 -670
  122. package/types/components/zd-text-input/ZdTextInput.ts.d.ts +0 -746
  123. package/types/components/zd-textarea/ZdTextarea.ts.d.ts +0 -877
  124. package/types/components/zd-time/ZdTime.ts.d.ts +0 -2224
  125. package/types/components/zd-tooltip/ZdTooltip.ts.d.ts +0 -781
  126. package/types/components/zd-tree/ZdTree.ts.d.ts +0 -1878
  127. package/types/components/zd-tree/ZdTreeAfterTitle.ts.d.ts +0 -26
  128. package/types/components/zd-tree/ZdTreeCheckbox.ts.d.ts +0 -74
  129. package/types/components/zd-tree-grid/ZdTreeGrid.ts.d.ts +0 -4178
  130. package/types/components/zd-tree-grid/cell/ZdTreeGridCell.ts.d.ts +0 -92
  131. package/types/components/zd-tree-grid/row/ZdTreeGridRow.ts.d.ts +0 -124
  132. package/types/composables/useTableLayout.d.ts +0 -25
  133. package/types/utils/isArrayOperation.d.ts +0 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeedhi/vuetify",
3
- "version": "3.0.7",
3
+ "version": "3.0.9",
4
4
  "description": "Zeedhi Components based on Vuetify",
5
5
  "author": "Zeedhi <zeedhi@teknisa.com>",
6
6
  "license": "ISC",
@@ -25,7 +25,7 @@
25
25
  "dependencies": {
26
26
  "@zeedhi/common": "^3.0.0",
27
27
  "@zeedhi/core": "^3.0.0",
28
- "@zeedhi/vue": "^3.0.7",
28
+ "@zeedhi/vue": "^3.0.9",
29
29
  "lodash.camelcase": "^4.3.0",
30
30
  "lodash.clonedeep": "^4.5.0",
31
31
  "lodash.debounce": "^4.0.*",
@@ -51,5 +51,5 @@
51
51
  "env": {
52
52
  "NODE_ENV": "production"
53
53
  },
54
- "gitHead": "dcb84a1fc749588a4a0b26fbb576e872df0afe5c"
54
+ "gitHead": "72192175bdfe55b7fb9e10b40c323f9e226a04e7"
55
55
  }
@@ -1,287 +0,0 @@
1
- import { TekGrid, TekMemoryDatasource, TekRestDatasource, } from '@zeedhi/common';
2
- import { Config, Utils } from '@zeedhi/core';
3
- import cloneDeep from 'lodash.clonedeep';
4
- import debounce from 'lodash.debounce';
5
- import { computed, defineComponent, nextTick } from 'vue';
6
- import { provideTableLayout, useGridColumns } from '../../composables';
7
- import { buildProps } from '../../utils';
8
- import { getRootElement, useCreateInstance } from '../zd-component/ZdComponent';
9
- import { ZdGridEditableProps, useGridEditableInstance } from '../zd-grid-editable/ZdGridEditable';
10
- export const TekGridProps = buildProps({
11
- ...ZdGridEditableProps,
12
- toolbarSlot: {
13
- type: Array,
14
- default: undefined,
15
- },
16
- title: {
17
- type: String,
18
- default: '',
19
- },
20
- addButton: {
21
- type: [Boolean, String],
22
- default: false,
23
- },
24
- deleteButton: {
25
- type: [String, Boolean],
26
- default: 'none',
27
- },
28
- columnsButton: {
29
- type: [Boolean, String],
30
- default: false,
31
- },
32
- columnsButtonIgnore: {
33
- type: [Array, String],
34
- default: () => [],
35
- },
36
- showEditButtons: {
37
- type: [Boolean, String],
38
- default: true,
39
- },
40
- filterButton: {
41
- type: [Boolean, String],
42
- default: false,
43
- },
44
- modalFilterProps: {
45
- type: Object,
46
- default: () => ({}),
47
- },
48
- showSearch: {
49
- type: [Boolean, String],
50
- default: true,
51
- },
52
- columnFilterButton: {
53
- type: [Boolean, String],
54
- default: false,
55
- },
56
- hideActions: {
57
- type: [Boolean, String],
58
- default: false,
59
- },
60
- actions: {
61
- type: Array,
62
- default: () => [],
63
- },
64
- dragColumns: {
65
- type: [Boolean, String],
66
- default: true,
67
- },
68
- resizeColumns: {
69
- type: [Boolean, String],
70
- default: true,
71
- },
72
- showLayoutOptions: {
73
- type: [Boolean, String],
74
- default: true,
75
- },
76
- showExport: {
77
- type: [String, Boolean],
78
- default: false,
79
- },
80
- showReload: {
81
- type: [Boolean, String],
82
- default: true,
83
- },
84
- exportConfig: {
85
- type: Array,
86
- },
87
- exportActions: {
88
- type: Array,
89
- },
90
- groupsOpened: {
91
- type: [Boolean, String],
92
- default: false,
93
- },
94
- showSummaryTotal: {
95
- type: [Boolean, String],
96
- default: true,
97
- },
98
- mainGrid: {
99
- type: [Boolean, String],
100
- default: true,
101
- },
102
- xlsDefaultType: {
103
- type: String,
104
- default: undefined,
105
- },
106
- showCheckboxAllFilter: {
107
- type: [Boolean, String],
108
- default: Config.gridShowCheckboxAllFilter,
109
- },
110
- toolbarOpened: {
111
- type: [Boolean],
112
- default: true,
113
- },
114
- defaultFilter: {
115
- type: Object,
116
- },
117
- reportTitle: {
118
- type: String,
119
- },
120
- editNewRowsOnly: {
121
- type: [Boolean, String],
122
- default: false,
123
- },
124
- });
125
- const gridEditableComponent = defineComponent({
126
- props: TekGridProps,
127
- inheritAttrs: false,
128
- setup(props, ctx) {
129
- const { instance, root } = useCreateInstance(props, ctx, TekGrid);
130
- const renderedData = computed(() => {
131
- if (instance.isGrouped()) {
132
- return instance.getGroupedData();
133
- }
134
- return instance.getData();
135
- });
136
- const visibleData = computed(() => {
137
- return renderedData.value.filter((row) => instance.isItemVisible(row));
138
- });
139
- const gridEditableScope = useGridEditableInstance({ instance, root, renderedData: visibleData });
140
- const rootEl = getRootElement(root);
141
- const { visibleColumns } = useGridColumns({
142
- instance,
143
- rootEl,
144
- visibilityCondition: (column) => column.isVisible && !column.grouped,
145
- });
146
- provideTableLayout({ instance, rootEl });
147
- const debouncedDatasourceGet = debounce((instance) => {
148
- const event = new Event('change', { cancelable: true });
149
- instance.callEvent('beforeApplyFilter', { component: instance, event });
150
- if (event.defaultPrevented)
151
- return;
152
- const { datasource } = instance;
153
- if (datasource instanceof TekRestDatasource || datasource instanceof TekMemoryDatasource) {
154
- datasource.updateDynamicFilter();
155
- }
156
- else {
157
- datasource.get();
158
- }
159
- }, 500);
160
- const filter = computed(() => {
161
- if (instance.datasource instanceof TekRestDatasource || instance.datasource instanceof TekMemoryDatasource) {
162
- return instance.datasource.dynamicFilter;
163
- }
164
- const datasourceFilter = instance.datasource.filter;
165
- const simpleFilter = {};
166
- Object.keys(datasourceFilter).forEach((key) => {
167
- simpleFilter[key] = [{ relation: 'AND', operation: 'CONTAINS', value: datasourceFilter[key] }];
168
- });
169
- return simpleFilter;
170
- });
171
- const setFilter = (newFilter) => {
172
- if (Utils.isEqual(filter, newFilter))
173
- return;
174
- if (instance.datasource instanceof TekRestDatasource || instance.datasource instanceof TekMemoryDatasource) {
175
- instance.datasource.dynamicFilter = cloneDeep(newFilter);
176
- }
177
- else {
178
- const normalFilter = {};
179
- Object.keys(newFilter).forEach((key) => {
180
- if (!newFilter[key][0].value)
181
- return;
182
- normalFilter[key] = newFilter[key][0].value;
183
- });
184
- instance.datasource.filter = normalFilter;
185
- }
186
- debouncedDatasourceGet(instance);
187
- instance.changeLayout();
188
- };
189
- const columnHasFilter = (columnName) => {
190
- return instance.columnHasFilter(columnName);
191
- };
192
- const isRowVisible = (row, index) => {
193
- return instance.isItemVisible(row) && gridEditableScope.shouldRender(index);
194
- };
195
- const isCurrentRowGroup = (row) => {
196
- const { uniqueKey, currentRow } = instance.datasource;
197
- return !!((row.group && row.groupValue === currentRow.groupValue) ||
198
- (row[uniqueKey] && row[uniqueKey] === currentRow[uniqueKey]));
199
- };
200
- const isGroupSelectIndeterminate = (item) => {
201
- let hasSelected = false;
202
- let hasNotSelected = false;
203
- const { uniqueKey } = instance.datasource;
204
- item.children.forEach((child) => {
205
- const idx = instance.selectedRows.findIndex((row) => child[uniqueKey] === row[uniqueKey]);
206
- hasSelected = hasSelected || idx !== -1;
207
- hasNotSelected = hasNotSelected || idx === -1;
208
- });
209
- return hasSelected && hasNotSelected;
210
- };
211
- const isGroupSelected = (item) => {
212
- return item.children.every((child) => {
213
- const { uniqueKey } = instance.datasource;
214
- const idx = instance.selectedRows.findIndex((row) => child[uniqueKey] === row[uniqueKey]);
215
- return idx !== -1;
216
- });
217
- };
218
- const selectGroupRowClick = (row, isSelected, event) => {
219
- nextTick(() => {
220
- const rootElement = getRootElement(root);
221
- instance.selectGroupClick(row, isSelected, event, rootElement.value);
222
- });
223
- };
224
- const selectGroup = (item, event) => {
225
- const { uniqueKey } = instance.datasource;
226
- const isSelected = isGroupSelected(item);
227
- if (!isSelected) {
228
- // here we fetch the item from renderedData because vuetify isSelected checks for object reference
229
- // so we need to find the item inside renderedData to call selectRow() with the correct reference
230
- // https://github.com/vuetifyjs/vuetify/blob/master/packages/vuetify/src/components/VDataTable/composables/select.ts#L128
231
- const items = item.children.map((child) => {
232
- return renderedData.value.find((row) => child[uniqueKey] === row[uniqueKey]);
233
- });
234
- items.forEach((child) => {
235
- if (!child)
236
- return;
237
- const idx = instance.selectedRows.findIndex((row) => child[uniqueKey] === row[uniqueKey]);
238
- if (idx === -1) {
239
- instance.selectRow(child, true);
240
- }
241
- });
242
- }
243
- else {
244
- item.children.forEach((child) => {
245
- const idx = instance.selectedRows.findIndex((row) => child[uniqueKey] === row[uniqueKey]);
246
- if (idx !== -1) {
247
- instance.selectRow(child, false);
248
- }
249
- });
250
- }
251
- selectGroupRowClick(item, !isSelected, event);
252
- };
253
- const openGroup = (item) => {
254
- instance.openGroup(item);
255
- };
256
- const isGroup = (item) => {
257
- return !!item.group;
258
- };
259
- const isFooter = (item) => {
260
- return !!item.groupFooter;
261
- };
262
- const groupColumnNames = computed(() => {
263
- return instance.columns.filter((column) => column.grouped).map((column) => column.name) || [];
264
- });
265
- return {
266
- ...gridEditableScope,
267
- instance,
268
- root,
269
- filter,
270
- setFilter,
271
- columnHasFilter,
272
- visibleColumns,
273
- isRowVisible,
274
- isCurrentRowGroup,
275
- isGroupSelectIndeterminate,
276
- selectGroup,
277
- isGroup,
278
- openGroup,
279
- renderedData,
280
- isGroupSelected,
281
- groupColumnNames,
282
- isFooter,
283
- visibleData,
284
- };
285
- },
286
- });
287
- export default gridEditableComponent;
@@ -1,201 +0,0 @@
1
- import { Config, Metadata, Utils, dayjs } from '@zeedhi/core';
2
- import cloneDeep from 'lodash.clonedeep';
3
- import debounce from 'lodash.debounce';
4
- import { computed, defineComponent, reactive } from 'vue';
5
- import { isArrayOperation } from '../../../utils';
6
- export const TekGridColumnFilterProps = {
7
- hasFilterData: {
8
- type: Boolean,
9
- default: false,
10
- },
11
- column: {
12
- type: Object,
13
- required: true,
14
- },
15
- modelValue: {
16
- type: Array,
17
- default: [],
18
- },
19
- instanceName: {
20
- type: String,
21
- required: true,
22
- },
23
- filterRelationsDatasource: {
24
- type: [Object, null],
25
- required: false,
26
- },
27
- filterOperationsDatasource: {
28
- type: [Object, null],
29
- required: false,
30
- },
31
- isHovering: {
32
- type: Boolean,
33
- default: false,
34
- },
35
- multiple: {
36
- type: Boolean,
37
- required: true,
38
- },
39
- };
40
- const tekGridColumnFilter = defineComponent({
41
- props: TekGridColumnFilterProps,
42
- inheritAttrs: false,
43
- emits: ['update:modelValue'],
44
- setup(props, ctx) {
45
- const getValueInputName = (index) => `${props.instanceName}-${props.column.name}-filter-value-${index}`;
46
- const focusValueInput = (index) => {
47
- const valueInputName = getValueInputName(index);
48
- const input = Metadata.getInstance(valueInputName);
49
- input.setFocus();
50
- };
51
- const createNewFilter = () => {
52
- return reactive({
53
- operation: 'CONTAINS',
54
- relation: 'AND',
55
- value: undefined,
56
- });
57
- };
58
- let newFilter = createNewFilter();
59
- const convertToDateFormat = (value, revert) => {
60
- const dateFormat = props.column.componentProps.dateFormat || Config.dateFormat;
61
- const displayFormat = props.column.componentProps.displayFormat || Config.displayFormat;
62
- if (revert) {
63
- if (dayjs(value, displayFormat).isValid() || !dayjs(value, dateFormat).isValid()) {
64
- return value;
65
- }
66
- return dayjs(value, dateFormat).format(displayFormat);
67
- }
68
- if (dayjs(value, dateFormat).isValid() || !dayjs(value, displayFormat).isValid()) {
69
- return value;
70
- }
71
- return dayjs(value, displayFormat).format(dateFormat);
72
- };
73
- const checkDateValueFormat = (value, revert = false) => {
74
- if (!['ZdDate', 'ZdDateRange'].includes(props.column.componentProps.component))
75
- return value;
76
- if (Array.isArray(value)) {
77
- return value.map((item) => convertToDateFormat(item, revert));
78
- }
79
- return convertToDateFormat(value, revert);
80
- };
81
- // use WeakMap to avoid memory leaks
82
- const idMap = new WeakMap();
83
- let idCounter = 0;
84
- // retrieves a unique id for each item
85
- const getId = (item) => {
86
- if (!idMap.has(item)) {
87
- idMap.set(item, `__item__${idCounter++}`);
88
- }
89
- return idMap.get(item);
90
- };
91
- // use computed to generate unique ids for each filter item
92
- // this is needed for the v-for :key updates
93
- const modelWithIds = computed(() => {
94
- if (!props.multiple) {
95
- if (props.modelValue.length > 0) {
96
- return [{ id: getId(props.modelValue[0]), item: props.modelValue[0] }];
97
- }
98
- return [{ id: getId(newFilter), item: newFilter }];
99
- }
100
- return [...props.modelValue, newFilter].map((item) => ({
101
- id: getId(item),
102
- item,
103
- }));
104
- });
105
- const debounceUpdateModel = debounce((modelValue) => {
106
- if (Utils.isEqual(modelValue, props.modelValue))
107
- return;
108
- ctx.emit('update:modelValue', modelValue);
109
- newFilter = createNewFilter();
110
- }, 500);
111
- const changeRelation = (index, { component }) => {
112
- const modelValue = cloneDeep(props.modelValue);
113
- const isNewFilter = index === modelValue.length;
114
- const filter = isNewFilter ? newFilter : modelValue[index];
115
- const { value } = component;
116
- focusValueInput(index);
117
- // update item type value
118
- filter.relation = value;
119
- if (isNewFilter)
120
- return;
121
- debounceUpdateModel(modelValue);
122
- };
123
- const changeOperation = (index, { component }) => {
124
- const modelValue = cloneDeep(props.modelValue);
125
- const filterItem = modelValue[index];
126
- const isNewFilter = index === modelValue.length;
127
- const filter = isNewFilter ? newFilter : filterItem;
128
- const { value } = component;
129
- focusValueInput(index);
130
- // if operation is IN, NOT_IN or BETWEEN, value should be an array
131
- if (isArrayOperation(value)) {
132
- filter.value = Array.isArray(filterItem.value) ? filterItem.value : [filterItem.value];
133
- }
134
- // update item type value
135
- filter.operation = value;
136
- if (isNewFilter)
137
- return;
138
- debounceUpdateModel(modelValue);
139
- };
140
- const changeValue = (item, index, { component }) => {
141
- const modelValue = cloneDeep(props.modelValue);
142
- const filter = cloneDeep(item);
143
- const { value } = component;
144
- const isNewFilter = props.multiple && index === modelValue.length;
145
- let formattedValue = value;
146
- if (value && isArrayOperation(filter.operation)) {
147
- formattedValue = value.split(';');
148
- }
149
- filter.value = checkDateValueFormat(formattedValue);
150
- if (!props.multiple) {
151
- debounceUpdateModel([filter]);
152
- return;
153
- }
154
- if (isNewFilter) {
155
- // only emit event when newFilter has value
156
- if (!filter.value)
157
- return;
158
- debounceUpdateModel([...modelValue, filter]);
159
- return;
160
- }
161
- if (!filter.value) {
162
- // when removing the last (not new) filter, should pass its operation and relation to the new filter
163
- if (index === modelValue.length - 1) {
164
- newFilter.operation = filter.operation;
165
- newFilter.relation = filter.relation;
166
- }
167
- modelValue.splice(index, 1);
168
- // if the removed filter was the first, should set the new first relation to AND
169
- if (modelValue.length > 0 && index === 0) {
170
- modelValue[0].relation = 'AND';
171
- }
172
- // if the removed filter was the last, should set the newFilter relation to AND
173
- if (modelValue.length === 0) {
174
- newFilter.relation = 'AND';
175
- }
176
- }
177
- debounceUpdateModel(modelValue);
178
- };
179
- const getComponentType = (operation) => {
180
- return isArrayOperation(operation) ? 'ZdTextInput' : props.column.componentProps.component;
181
- };
182
- const getComponentHint = (operation) => {
183
- return isArrayOperation(operation) ? 'TEKGRID_MULTIPLE_VALUE_HINT' : '';
184
- };
185
- const getItemValue = (item) => {
186
- return isArrayOperation(item.operation) ? item.value.join(';') : item.value;
187
- };
188
- return {
189
- changeValue,
190
- changeRelation,
191
- changeOperation,
192
- getValueInputName,
193
- newFilter,
194
- getComponentType,
195
- getComponentHint,
196
- modelWithIds,
197
- getItemValue,
198
- };
199
- },
200
- });
201
- export default tekGridColumnFilter;
@@ -1,134 +0,0 @@
1
- import { defineComponent, inject } from 'vue';
2
- export default defineComponent({
3
- props: {
4
- selectable: {
5
- type: Boolean,
6
- default: false,
7
- },
8
- headerBackground: {
9
- type: String,
10
- default: '',
11
- },
12
- showSelectAll: {
13
- type: Boolean,
14
- default: false,
15
- },
16
- allselectedState: {
17
- type: Number,
18
- default: 0,
19
- },
20
- visibleColumns: {
21
- type: Array,
22
- default: () => [],
23
- },
24
- dragColumns: {
25
- type: Boolean,
26
- default: false,
27
- },
28
- headerCellTextColor: {
29
- type: String,
30
- default: '',
31
- },
32
- resizeColumns: {
33
- type: Boolean,
34
- default: false,
35
- },
36
- getSortIcon: {
37
- type: Function,
38
- default: () => { },
39
- },
40
- isSorted: {
41
- type: Function,
42
- default: () => { },
43
- },
44
- toggleSort: {
45
- type: Function,
46
- default: () => { },
47
- },
48
- tableColumns: {
49
- type: Array,
50
- default: () => [],
51
- },
52
- sortBy: {
53
- type: Array,
54
- default: () => [],
55
- },
56
- disableCheckbox: {
57
- type: Boolean,
58
- default: false,
59
- },
60
- sortable: {
61
- type: Boolean,
62
- default: true,
63
- },
64
- name: {
65
- type: String,
66
- default: '',
67
- },
68
- modelValue: {
69
- type: Object,
70
- default: () => [],
71
- },
72
- instanceName: {
73
- type: String,
74
- required: true,
75
- },
76
- filterRelationsDatasource: {
77
- type: [Object, null],
78
- required: false,
79
- },
80
- filterOperationsDatasource: {
81
- type: [Object, null],
82
- required: false,
83
- },
84
- columnFilterButton: {
85
- type: Boolean,
86
- required: true,
87
- },
88
- columnHasFilter: {
89
- type: Function,
90
- required: true,
91
- },
92
- level: {
93
- type: Number,
94
- default: 0,
95
- },
96
- },
97
- emits: ['selectAllClick', 'resizeMousedown', 'resizeClick', 'update:modelValue'],
98
- setup(props, { emit }) {
99
- const calcWidth = inject('calcWidth');
100
- if (!calcWidth) {
101
- // TODO: use NotProvidedError
102
- throw new Error('calcWidth');
103
- }
104
- const selectAllClick = (event) => {
105
- emit('selectAllClick', event);
106
- };
107
- const resizeMousedown = (column, event) => {
108
- emit('resizeMousedown', { event, column });
109
- };
110
- const resizeClick = (event) => {
111
- emit('resizeClick', { event });
112
- };
113
- const findOrderIndex = (sortBy, column) => {
114
- return sortBy.findIndex((sort) => sort.key === column.name);
115
- };
116
- const updateModelValue = (columnName, value) => {
117
- const modelValue = { ...props.modelValue };
118
- modelValue[columnName] = value;
119
- emit('update:modelValue', modelValue);
120
- };
121
- const showFilterButton = (column) => {
122
- return column.type !== 'action' && props.columnFilterButton && column.filterable;
123
- };
124
- return {
125
- calcWidth,
126
- resizeMousedown,
127
- resizeClick,
128
- findOrderIndex,
129
- updateModelValue,
130
- showFilterButton,
131
- selectAllClick,
132
- };
133
- },
134
- });