es-grid-template 1.8.64 → 1.8.66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/grid-component/TempTable.d.ts +2 -2
- package/es/grid-component/TempTable.js +5 -5
- package/es/grid-component/hooks/index.js +0 -1
- package/es/grid-component/hooks/useLazyKVMap.d.ts +1 -1
- package/es/grid-component/hooks/useLazyKVMap.js +0 -4
- package/es/grid-component/hooks/utils.d.ts +1 -8
- package/es/grid-component/hooks/utils.js +176 -144
- package/es/grid-component/index.d.ts +1 -1
- package/es/grid-component/index.js +0 -4
- package/es/grid-component/styles.scss +1394 -1394
- package/es/grid-component/type.d.ts +0 -407
- package/es/grid-component/type.js +490 -1
- package/es/table-component/type.d.ts +10 -0
- package/es/{grid-component → table-virtuoso}/ColumnsGroup/ColumnsGroup.js +4 -3
- package/es/{grid-component → table-virtuoso}/InternalTable.d.ts +2 -3
- package/es/table-virtuoso/InternalTable.js +391 -0
- package/es/table-virtuoso/body/TableBodyCell.d.ts +14 -0
- package/es/table-virtuoso/body/TableBodyCell.js +457 -0
- package/es/table-virtuoso/body/TableBodyRow.d.ts +13 -0
- package/es/table-virtuoso/body/TableBodyRow.js +112 -0
- package/es/table-virtuoso/footer/TableFooterCell.d.ts +7 -0
- package/es/table-virtuoso/footer/TableFooterCell.js +54 -0
- package/es/table-virtuoso/header/TableHeadCell.d.ts +14 -0
- package/es/table-virtuoso/header/TableHeadCell.js +265 -0
- package/es/table-virtuoso/header/renderFilter.d.ts +20 -0
- package/es/table-virtuoso/header/renderFilter.js +289 -0
- package/es/table-virtuoso/hook/constant.d.ts +73 -0
- package/es/table-virtuoso/hook/constant.js +240 -0
- package/es/table-virtuoso/hook/convert.d.ts +1 -0
- package/es/table-virtuoso/hook/convert.js +28 -0
- package/es/table-virtuoso/hook/useColumns.d.ts +28 -0
- package/es/table-virtuoso/hook/useColumns.js +302 -0
- package/es/table-virtuoso/hook/useFilterOperator.d.ts +7 -0
- package/es/table-virtuoso/hook/useFilterOperator.js +33 -0
- package/es/table-virtuoso/hook/utils.d.ts +159 -0
- package/es/table-virtuoso/hook/utils.js +2263 -0
- package/es/table-virtuoso/index.d.ts +2 -0
- package/es/table-virtuoso/index.js +2 -0
- package/es/table-virtuoso/style.d.ts +22 -0
- package/es/table-virtuoso/style.js +12 -0
- package/es/table-virtuoso/style.scss +1441 -0
- package/es/table-virtuoso/table/Grid.d.ts +37 -0
- package/es/table-virtuoso/table/Grid.js +298 -0
- package/es/table-virtuoso/table/TableContainer.d.ts +49 -0
- package/es/table-virtuoso/table/TableContainer.js +292 -0
- package/es/table-virtuoso/table/TableWrapper.d.ts +22 -0
- package/es/table-virtuoso/table/TableWrapper.js +161 -0
- package/es/table-virtuoso/type.d.ts +0 -0
- package/es/table-virtuoso/type.js +785 -0
- package/es/table-virtuoso/useContext.d.ts +97 -0
- package/es/table-virtuoso/useContext.js +21 -0
- package/lib/grid-component/TempTable.d.ts +2 -2
- package/lib/grid-component/TempTable.js +5 -7
- package/lib/grid-component/hooks/useLazyKVMap.d.ts +1 -1
- package/lib/grid-component/hooks/useLazyKVMap.js +0 -3
- package/lib/grid-component/hooks/utils.d.ts +1 -8
- package/lib/grid-component/hooks/utils.js +179 -152
- package/lib/grid-component/index.d.ts +1 -1
- package/lib/grid-component/index.js +0 -3
- package/lib/grid-component/styles.scss +1394 -1394
- package/lib/grid-component/type.d.ts +0 -407
- package/lib/grid-component/type.js +490 -4
- package/lib/table-component/type.d.ts +10 -0
- package/lib/{grid-component → table-virtuoso}/ColumnsGroup/ColumnsGroup.js +4 -3
- package/lib/{grid-component → table-virtuoso}/InternalTable.d.ts +2 -3
- package/lib/table-virtuoso/InternalTable.js +400 -0
- package/lib/table-virtuoso/body/TableBodyCell.d.ts +14 -0
- package/lib/table-virtuoso/body/TableBodyCell.js +464 -0
- package/lib/table-virtuoso/body/TableBodyRow.d.ts +13 -0
- package/lib/table-virtuoso/body/TableBodyRow.js +119 -0
- package/lib/table-virtuoso/footer/TableFooterCell.d.ts +7 -0
- package/lib/table-virtuoso/footer/TableFooterCell.js +63 -0
- package/lib/table-virtuoso/header/TableHeadCell.d.ts +14 -0
- package/lib/table-virtuoso/header/TableHeadCell.js +274 -0
- package/lib/table-virtuoso/header/renderFilter.d.ts +20 -0
- package/lib/table-virtuoso/header/renderFilter.js +299 -0
- package/lib/table-virtuoso/hook/constant.d.ts +73 -0
- package/lib/table-virtuoso/hook/constant.js +247 -0
- package/lib/table-virtuoso/hook/convert.d.ts +1 -0
- package/lib/table-virtuoso/hook/convert.js +34 -0
- package/lib/table-virtuoso/hook/useColumns.d.ts +28 -0
- package/lib/table-virtuoso/hook/useColumns.js +315 -0
- package/lib/table-virtuoso/hook/useFilterOperator.d.ts +7 -0
- package/lib/table-virtuoso/hook/useFilterOperator.js +40 -0
- package/lib/table-virtuoso/hook/utils.d.ts +159 -0
- package/lib/table-virtuoso/hook/utils.js +2389 -0
- package/lib/table-virtuoso/index.d.ts +2 -0
- package/lib/table-virtuoso/index.js +9 -0
- package/lib/table-virtuoso/style.d.ts +22 -0
- package/lib/table-virtuoso/style.js +19 -0
- package/lib/table-virtuoso/style.scss +1441 -0
- package/lib/table-virtuoso/table/Grid.d.ts +37 -0
- package/lib/table-virtuoso/table/Grid.js +307 -0
- package/lib/table-virtuoso/table/TableContainer.d.ts +49 -0
- package/lib/table-virtuoso/table/TableContainer.js +300 -0
- package/lib/table-virtuoso/table/TableWrapper.d.ts +22 -0
- package/lib/table-virtuoso/table/TableWrapper.js +166 -0
- package/lib/table-virtuoso/type.d.ts +0 -0
- package/lib/table-virtuoso/type.js +786 -0
- package/lib/table-virtuoso/useContext.d.ts +97 -0
- package/lib/table-virtuoso/useContext.js +27 -0
- package/package.json +2 -1
- package/es/grid-component/AdvanceFilter.d.ts +0 -14
- package/es/grid-component/AdvanceFilter.js +0 -454
- package/es/grid-component/CheckboxFilter.d.ts +0 -20
- package/es/grid-component/CheckboxFilter.js +0 -244
- package/es/grid-component/CheckboxFilter2.d.ts +0 -20
- package/es/grid-component/CheckboxFilter2.js +0 -244
- package/es/grid-component/ColumnsChoose.d.ts +0 -10
- package/es/grid-component/ColumnsChoose.js +0 -230
- package/es/grid-component/Command.d.ts +0 -8
- package/es/grid-component/Command.js +0 -80
- package/es/grid-component/ContextMenu.d.ts +0 -20
- package/es/grid-component/ContextMenu.js +0 -130
- package/es/grid-component/ConvertColumnTable.d.ts +0 -7
- package/es/grid-component/ConvertColumnTable.js +0 -144
- package/es/grid-component/EditForm/EditForm.d.ts +0 -27
- package/es/grid-component/EditForm/EditForm.js +0 -394
- package/es/grid-component/EditForm/index.d.ts +0 -1
- package/es/grid-component/EditForm/index.js +0 -1
- package/es/grid-component/EditableCell.d.ts +0 -20
- package/es/grid-component/EditableCell.js +0 -1030
- package/es/grid-component/FilterSearch.d.ts +0 -12
- package/es/grid-component/FilterSearch.js +0 -33
- package/es/grid-component/GridStyle.d.ts +0 -8
- package/es/grid-component/GridStyle.js +0 -5
- package/es/grid-component/InternalTable.js +0 -1170
- package/es/grid-component/TableGrid.d.ts +0 -21
- package/es/grid-component/TableGrid.js +0 -493
- package/es/grid-component/async-select/index.d.ts +0 -11
- package/es/grid-component/async-select/index.js +0 -38
- package/es/grid-component/async-table-select/index.d.ts +0 -11
- package/es/grid-component/async-table-select/index.js +0 -40
- package/es/grid-component/checkbox-control/index.d.ts +0 -13
- package/es/grid-component/checkbox-control/index.js +0 -40
- package/es/grid-component/hooks/columns/index.d.ts +0 -10
- package/es/grid-component/hooks/columns/index.js +0 -503
- package/es/grid-component/hooks/content/ControlCheckbox.d.ts +0 -13
- package/es/grid-component/hooks/content/ControlCheckbox.js +0 -87
- package/es/grid-component/hooks/content/HeaderContent.d.ts +0 -14
- package/es/grid-component/hooks/content/HeaderContent.js +0 -44
- package/es/grid-component/hooks/content/TooltipContent.d.ts +0 -13
- package/es/grid-component/hooks/content/TooltipContent.js +0 -74
- package/es/grid-component/hooks/useColumns.d.ts +0 -19
- package/es/grid-component/hooks/useColumns.js +0 -317
- package/es/grid-component/number/index.d.ts +0 -10
- package/es/grid-component/number/index.js +0 -39
- package/es/grid-component/number-range/index.d.ts +0 -11
- package/es/grid-component/number-range/index.js +0 -63
- package/es/grid-component/table/Grid.d.ts +0 -23
- package/es/grid-component/table/Grid.js +0 -49
- package/es/grid-component/table/GridEdit.d.ts +0 -23
- package/es/grid-component/table/GridEdit.js +0 -2726
- package/es/grid-component/table/Group.d.ts +0 -21
- package/es/grid-component/table/Group.js +0 -195
- package/es/grid-component/table/InfiniteTable.d.ts +0 -23
- package/es/grid-component/table/InfiniteTable.js +0 -101
- package/es/grid-component/useContext.d.ts +0 -34
- package/es/grid-component/useContext.js +0 -8
- package/lib/grid-component/AdvanceFilter.d.ts +0 -14
- package/lib/grid-component/AdvanceFilter.js +0 -463
- package/lib/grid-component/CheckboxFilter.d.ts +0 -20
- package/lib/grid-component/CheckboxFilter.js +0 -253
- package/lib/grid-component/CheckboxFilter2.d.ts +0 -20
- package/lib/grid-component/CheckboxFilter2.js +0 -253
- package/lib/grid-component/ColumnsChoose.d.ts +0 -10
- package/lib/grid-component/ColumnsChoose.js +0 -240
- package/lib/grid-component/Command.d.ts +0 -8
- package/lib/grid-component/Command.js +0 -88
- package/lib/grid-component/ContextMenu.d.ts +0 -20
- package/lib/grid-component/ContextMenu.js +0 -140
- package/lib/grid-component/ConvertColumnTable.d.ts +0 -7
- package/lib/grid-component/ConvertColumnTable.js +0 -153
- package/lib/grid-component/EditForm/EditForm.d.ts +0 -27
- package/lib/grid-component/EditForm/EditForm.js +0 -404
- package/lib/grid-component/EditForm/index.d.ts +0 -1
- package/lib/grid-component/EditForm/index.js +0 -16
- package/lib/grid-component/EditableCell.d.ts +0 -20
- package/lib/grid-component/EditableCell.js +0 -1032
- package/lib/grid-component/FilterSearch.d.ts +0 -12
- package/lib/grid-component/FilterSearch.js +0 -42
- package/lib/grid-component/GridStyle.d.ts +0 -8
- package/lib/grid-component/GridStyle.js +0 -12
- package/lib/grid-component/InternalTable.js +0 -1178
- package/lib/grid-component/TableGrid.d.ts +0 -21
- package/lib/grid-component/TableGrid.js +0 -493
- package/lib/grid-component/async-select/index.d.ts +0 -11
- package/lib/grid-component/async-select/index.js +0 -47
- package/lib/grid-component/async-table-select/index.d.ts +0 -11
- package/lib/grid-component/async-table-select/index.js +0 -49
- package/lib/grid-component/checkbox-control/index.d.ts +0 -13
- package/lib/grid-component/checkbox-control/index.js +0 -48
- package/lib/grid-component/hooks/columns/index.d.ts +0 -10
- package/lib/grid-component/hooks/columns/index.js +0 -518
- package/lib/grid-component/hooks/content/ControlCheckbox.d.ts +0 -13
- package/lib/grid-component/hooks/content/ControlCheckbox.js +0 -95
- package/lib/grid-component/hooks/content/HeaderContent.d.ts +0 -14
- package/lib/grid-component/hooks/content/HeaderContent.js +0 -53
- package/lib/grid-component/hooks/content/TooltipContent.d.ts +0 -13
- package/lib/grid-component/hooks/content/TooltipContent.js +0 -81
- package/lib/grid-component/hooks/useColumns.d.ts +0 -19
- package/lib/grid-component/hooks/useColumns.js +0 -328
- package/lib/grid-component/number/index.d.ts +0 -10
- package/lib/grid-component/number/index.js +0 -47
- package/lib/grid-component/number-range/index.d.ts +0 -11
- package/lib/grid-component/number-range/index.js +0 -71
- package/lib/grid-component/table/Grid.d.ts +0 -23
- package/lib/grid-component/table/Grid.js +0 -58
- package/lib/grid-component/table/GridEdit.d.ts +0 -23
- package/lib/grid-component/table/GridEdit.js +0 -2723
- package/lib/grid-component/table/Group.d.ts +0 -21
- package/lib/grid-component/table/Group.js +0 -204
- package/lib/grid-component/table/InfiniteTable.d.ts +0 -23
- package/lib/grid-component/table/InfiniteTable.js +0 -109
- package/lib/grid-component/useContext.d.ts +0 -34
- package/lib/grid-component/useContext.js +0 -13
- /package/es/{grid-component → table-virtuoso}/ColumnsGroup/ColumnsGroup.d.ts +0 -0
- /package/es/{grid-component → table-virtuoso}/ColumnsGroup/index.d.ts +0 -0
- /package/es/{grid-component → table-virtuoso}/ColumnsGroup/index.js +0 -0
- /package/lib/{grid-component → table-virtuoso}/ColumnsGroup/ColumnsGroup.d.ts +0 -0
- /package/lib/{grid-component → table-virtuoso}/ColumnsGroup/index.d.ts +0 -0
- /package/lib/{grid-component → table-virtuoso}/ColumnsGroup/index.js +0 -0
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.valueToBoolean = exports.translateOption = exports.transferFontSize = exports.stringOperator = exports.paperSize = exports.optionsSize = exports.optionsPaperOrientation = exports.optionFontSize = exports.optionFont = exports.numberOperator = exports.nonActionColumn = exports.defaultWidth = exports.defaultTimeFormat = exports.defaultRowHeight = exports.defaultPageSizes = exports.defaultDateTimeFormat = exports.defaultDateFormat = exports.default = exports.dateTimeOperator = exports.dateOperator = exports.booleanToValue = exports.booleanOperator = exports.alignToFlex = void 0;
|
|
7
|
+
const defaultWidth = exports.defaultWidth = 100;
|
|
8
|
+
const defaultRowHeight = exports.defaultRowHeight = 35;
|
|
9
|
+
const numberOperator = exports.numberOperator = [{
|
|
10
|
+
value: 'equal',
|
|
11
|
+
label: 'Equal',
|
|
12
|
+
key: '=='
|
|
13
|
+
}, {
|
|
14
|
+
value: 'greaterthan',
|
|
15
|
+
label: 'Greater than',
|
|
16
|
+
key: '>'
|
|
17
|
+
}, {
|
|
18
|
+
value: 'greaterthanorequal',
|
|
19
|
+
label: 'Greater than or equal',
|
|
20
|
+
key: '>='
|
|
21
|
+
}, {
|
|
22
|
+
value: 'lessthan',
|
|
23
|
+
label: 'Less than',
|
|
24
|
+
key: '<'
|
|
25
|
+
}, {
|
|
26
|
+
value: 'lessthanorequal',
|
|
27
|
+
label: 'Less than or equal',
|
|
28
|
+
key: '<='
|
|
29
|
+
}, {
|
|
30
|
+
value: 'notequal',
|
|
31
|
+
label: 'Not equal',
|
|
32
|
+
key: '!='
|
|
33
|
+
}];
|
|
34
|
+
const stringOperator = exports.stringOperator = [{
|
|
35
|
+
value: 'startswith',
|
|
36
|
+
key: '_=',
|
|
37
|
+
label: 'Starts with'
|
|
38
|
+
}, {
|
|
39
|
+
value: 'endswith',
|
|
40
|
+
key: '|=',
|
|
41
|
+
label: 'Ends with'
|
|
42
|
+
}, {
|
|
43
|
+
value: 'contains',
|
|
44
|
+
key: '~=',
|
|
45
|
+
label: 'Contains'
|
|
46
|
+
}, {
|
|
47
|
+
value: 'equal',
|
|
48
|
+
key: '==',
|
|
49
|
+
label: 'Equal'
|
|
50
|
+
}, {
|
|
51
|
+
value: 'notequal',
|
|
52
|
+
key: '!=',
|
|
53
|
+
label: 'Not equal'
|
|
54
|
+
}];
|
|
55
|
+
const dateOperator = exports.dateOperator = [{
|
|
56
|
+
value: 'equal',
|
|
57
|
+
key: '==',
|
|
58
|
+
label: 'Equal'
|
|
59
|
+
}, {
|
|
60
|
+
value: 'notequal',
|
|
61
|
+
key: '!=',
|
|
62
|
+
label: 'Not equal'
|
|
63
|
+
}, {
|
|
64
|
+
value: 'greaterthan',
|
|
65
|
+
key: '>',
|
|
66
|
+
label: 'Greater than'
|
|
67
|
+
}, {
|
|
68
|
+
value: 'lessthan',
|
|
69
|
+
key: '<',
|
|
70
|
+
label: 'Less than'
|
|
71
|
+
}];
|
|
72
|
+
const dateTimeOperator = exports.dateTimeOperator = [{
|
|
73
|
+
value: 'equal',
|
|
74
|
+
key: '==',
|
|
75
|
+
label: 'Equal'
|
|
76
|
+
}, {
|
|
77
|
+
value: 'notequal',
|
|
78
|
+
key: '!=',
|
|
79
|
+
label: 'Not equal'
|
|
80
|
+
}, {
|
|
81
|
+
value: 'greaterthan',
|
|
82
|
+
key: '>',
|
|
83
|
+
label: 'Greater than'
|
|
84
|
+
}, {
|
|
85
|
+
value: 'lessthan',
|
|
86
|
+
key: '<',
|
|
87
|
+
label: 'Less than'
|
|
88
|
+
}];
|
|
89
|
+
const booleanOperator = exports.booleanOperator = [{
|
|
90
|
+
value: 'equal',
|
|
91
|
+
key: '==',
|
|
92
|
+
label: 'Equal'
|
|
93
|
+
}, {
|
|
94
|
+
value: 'notequal',
|
|
95
|
+
key: '!=',
|
|
96
|
+
label: 'Not equal'
|
|
97
|
+
}];
|
|
98
|
+
const translateOption = (options, t) => {
|
|
99
|
+
if (!t) {
|
|
100
|
+
return options;
|
|
101
|
+
}
|
|
102
|
+
return options.map(it => ({
|
|
103
|
+
...it,
|
|
104
|
+
label: t(it.label)
|
|
105
|
+
}));
|
|
106
|
+
};
|
|
107
|
+
exports.translateOption = translateOption;
|
|
108
|
+
const transferFontSize = exports.transferFontSize = {
|
|
109
|
+
6: 8,
|
|
110
|
+
7: 9,
|
|
111
|
+
8: 11,
|
|
112
|
+
9: 12,
|
|
113
|
+
10: 13,
|
|
114
|
+
11: 15,
|
|
115
|
+
12: 16,
|
|
116
|
+
13: 17,
|
|
117
|
+
14: 19,
|
|
118
|
+
15: 20,
|
|
119
|
+
16: 21,
|
|
120
|
+
17: 23,
|
|
121
|
+
18: 24,
|
|
122
|
+
19: 25,
|
|
123
|
+
20: 27,
|
|
124
|
+
21: 28,
|
|
125
|
+
22: 29,
|
|
126
|
+
24: 32,
|
|
127
|
+
26: 35,
|
|
128
|
+
27: 36,
|
|
129
|
+
28: 37
|
|
130
|
+
};
|
|
131
|
+
const defaultDateFormat = exports.defaultDateFormat = 'd/m/Y';
|
|
132
|
+
const defaultDateTimeFormat = exports.defaultDateTimeFormat = 'd/m/Y H:i';
|
|
133
|
+
const defaultTimeFormat = exports.defaultTimeFormat = 'H:i';
|
|
134
|
+
const defaultPageSizes = exports.defaultPageSizes = [20, 30, 50, 100];
|
|
135
|
+
const alignToFlex = exports.alignToFlex = {
|
|
136
|
+
center: 'center',
|
|
137
|
+
left: 'start',
|
|
138
|
+
right: 'end'
|
|
139
|
+
};
|
|
140
|
+
const optionsSize = exports.optionsSize = [{
|
|
141
|
+
label: 'letter',
|
|
142
|
+
value: 'letter',
|
|
143
|
+
width: 21.59,
|
|
144
|
+
height: 27.94
|
|
145
|
+
}, {
|
|
146
|
+
label: 'A3',
|
|
147
|
+
value: 'a3',
|
|
148
|
+
width: 27.94,
|
|
149
|
+
height: 42
|
|
150
|
+
}, {
|
|
151
|
+
label: 'A4',
|
|
152
|
+
value: 'a4',
|
|
153
|
+
width: 21,
|
|
154
|
+
height: 29.7
|
|
155
|
+
}];
|
|
156
|
+
const paperSize = exports.paperSize = {
|
|
157
|
+
a4: {
|
|
158
|
+
width: 21,
|
|
159
|
+
height: 29.7
|
|
160
|
+
},
|
|
161
|
+
a3: {
|
|
162
|
+
width: 27.94,
|
|
163
|
+
height: 42
|
|
164
|
+
},
|
|
165
|
+
letter: {
|
|
166
|
+
width: 21.59,
|
|
167
|
+
height: 27.94
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
const optionFont = exports.optionFont = [{
|
|
171
|
+
value: 'Times New Roman',
|
|
172
|
+
label: 'Times New Roman'
|
|
173
|
+
}, {
|
|
174
|
+
value: 'Calibri',
|
|
175
|
+
label: 'Calibri (Body)'
|
|
176
|
+
}];
|
|
177
|
+
// portrait' | 'landscape'
|
|
178
|
+
const optionsPaperOrientation = exports.optionsPaperOrientation = [{
|
|
179
|
+
value: 'portrait',
|
|
180
|
+
label: 'portrait'
|
|
181
|
+
}, {
|
|
182
|
+
value: 'landscape',
|
|
183
|
+
label: 'landscape'
|
|
184
|
+
}];
|
|
185
|
+
const optionFontSize = exports.optionFontSize = [{
|
|
186
|
+
value: 8,
|
|
187
|
+
label: '8'
|
|
188
|
+
}, {
|
|
189
|
+
value: 9,
|
|
190
|
+
label: '9'
|
|
191
|
+
}, {
|
|
192
|
+
value: 10,
|
|
193
|
+
label: '10'
|
|
194
|
+
}, {
|
|
195
|
+
value: 11,
|
|
196
|
+
label: '11'
|
|
197
|
+
}, {
|
|
198
|
+
value: 12,
|
|
199
|
+
label: '12'
|
|
200
|
+
}, {
|
|
201
|
+
value: 13,
|
|
202
|
+
label: '13'
|
|
203
|
+
}, {
|
|
204
|
+
value: 14,
|
|
205
|
+
label: '14'
|
|
206
|
+
}, {
|
|
207
|
+
value: 16,
|
|
208
|
+
label: '16'
|
|
209
|
+
}, {
|
|
210
|
+
value: 18,
|
|
211
|
+
label: '18'
|
|
212
|
+
}, {
|
|
213
|
+
value: 24,
|
|
214
|
+
label: '24'
|
|
215
|
+
}, {
|
|
216
|
+
value: 36,
|
|
217
|
+
label: '36'
|
|
218
|
+
}, {
|
|
219
|
+
value: 48,
|
|
220
|
+
label: '48'
|
|
221
|
+
}];
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Sort order for BaseTable
|
|
225
|
+
*/
|
|
226
|
+
const SortOrder = {
|
|
227
|
+
/**
|
|
228
|
+
* Sort data in ascending order
|
|
229
|
+
*/
|
|
230
|
+
ascend: 'Ascending',
|
|
231
|
+
/**
|
|
232
|
+
* Sort data in descending order
|
|
233
|
+
*/
|
|
234
|
+
descend: 'Descending'
|
|
235
|
+
};
|
|
236
|
+
var _default = exports.default = SortOrder;
|
|
237
|
+
const valueToBoolean = exports.valueToBoolean = {
|
|
238
|
+
true: true,
|
|
239
|
+
false: false,
|
|
240
|
+
1: true,
|
|
241
|
+
0: false
|
|
242
|
+
};
|
|
243
|
+
const booleanToValue = exports.booleanToValue = {
|
|
244
|
+
true: 1,
|
|
245
|
+
false: 0
|
|
246
|
+
};
|
|
247
|
+
const nonActionColumn = exports.nonActionColumn = ['#', 'command', 'selection_column'];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function convertColumns(columns: any[]): any[];
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.convertColumns = convertColumns;
|
|
7
|
+
var _reactTable = require("@tanstack/react-table");
|
|
8
|
+
const columnHelper = (0, _reactTable.createColumnHelper)();
|
|
9
|
+
function convertColumns(columns) {
|
|
10
|
+
return columns.map(col => {
|
|
11
|
+
if (col.columns) {
|
|
12
|
+
// Group column
|
|
13
|
+
return columnHelper.group({
|
|
14
|
+
...col,
|
|
15
|
+
columns: convertColumns(col.columns) // đệ quy
|
|
16
|
+
});
|
|
17
|
+
} else {
|
|
18
|
+
// Accessor column
|
|
19
|
+
let accessor;
|
|
20
|
+
|
|
21
|
+
// Ưu tiên accessorKey nếu có, nếu không thì dùng hàm row => row[col.id]
|
|
22
|
+
if (col.accessorKey) {
|
|
23
|
+
accessor = col.accessorKey;
|
|
24
|
+
} else if (col.id) {
|
|
25
|
+
accessor = row => row[col.id];
|
|
26
|
+
} else {
|
|
27
|
+
throw new Error('Column không có accessorKey hoặc id');
|
|
28
|
+
}
|
|
29
|
+
return columnHelper.accessor(accessor, {
|
|
30
|
+
...col
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Dispatch, SetStateAction } from "react";
|
|
2
|
+
import type { ColumnsTable, ColumnTable, IFormat, SelectionSettings } from '../../table-component/type';
|
|
3
|
+
import type { Cell, ColumnDef } from '@tanstack/react-table';
|
|
4
|
+
export declare const renderValueCell: <T>(column: ColumnTable<T>, value: any, record: T, rowIndex: number, colIndex: number, format?: IFormat, editAble?: boolean) => any;
|
|
5
|
+
export declare function convertToTanStackColumns<T>({ t, columns, format, editAble }: {
|
|
6
|
+
t?: any;
|
|
7
|
+
columns: ColumnsTable<T>;
|
|
8
|
+
format?: IFormat;
|
|
9
|
+
editAble?: boolean;
|
|
10
|
+
}): ColumnDef<T, any>[];
|
|
11
|
+
export type ToggleRow<T> = {
|
|
12
|
+
e: any;
|
|
13
|
+
cell: Cell<T, unknown>;
|
|
14
|
+
selectionSettings?: SelectionSettings;
|
|
15
|
+
isSelectionChange?: {
|
|
16
|
+
isChange: boolean;
|
|
17
|
+
type: string;
|
|
18
|
+
rowData: T;
|
|
19
|
+
rowsData: T[];
|
|
20
|
+
};
|
|
21
|
+
setIsSelectionChange: Dispatch<SetStateAction<{
|
|
22
|
+
isChange: boolean;
|
|
23
|
+
type: string;
|
|
24
|
+
rowData: T;
|
|
25
|
+
rowsData: T[];
|
|
26
|
+
}>>;
|
|
27
|
+
};
|
|
28
|
+
export declare const toggleRowSelection: <T>(props: ToggleRow<T>) => void;
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.convertToTanStackColumns = convertToTanStackColumns;
|
|
8
|
+
exports.toggleRowSelection = exports.renderValueCell = void 0;
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _utils = require("./utils");
|
|
11
|
+
var _reactNumericComponent = require("react-numeric-component");
|
|
12
|
+
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
13
|
+
var _moment = _interopRequireDefault(require("moment"));
|
|
14
|
+
var _ControlCheckbox = _interopRequireDefault(require("../../table-component/components/ControlCheckbox"));
|
|
15
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
16
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
17
|
+
// import ControlCheckbox from '../components/ControlCheckbox'
|
|
18
|
+
|
|
19
|
+
const renderValueCell = (column, value, record, rowIndex, colIndex, format, editAble) => {
|
|
20
|
+
switch (column?.type) {
|
|
21
|
+
case 'number':
|
|
22
|
+
const colFormat = typeof column.format === 'function' ? column.format(record) : column.format;
|
|
23
|
+
const cellFormat = (0, _utils.getFormat)(colFormat, format);
|
|
24
|
+
const thousandSeparator = cellFormat?.thousandSeparator;
|
|
25
|
+
const decimalSeparator = cellFormat?.decimalSeparator;
|
|
26
|
+
const dec = cellFormat?.decimalScale;
|
|
27
|
+
|
|
28
|
+
// const contentNumber = !isEmpty(value) ? ((dec || dec === 0) ? parseFloat(Number(value).toFixed(dec)).toString() : value.toString()) : '0'
|
|
29
|
+
|
|
30
|
+
const tmpval = typeof value === 'string' ? Number(value) : value;
|
|
31
|
+
const numericFormatProps = {
|
|
32
|
+
thousandSeparator: (0, _utils.checkThousandSeparator)(thousandSeparator, decimalSeparator),
|
|
33
|
+
decimalSeparator: (0, _utils.checkDecimalSeparator)(thousandSeparator, decimalSeparator),
|
|
34
|
+
allowNegative: cellFormat?.allowNegative ?? true,
|
|
35
|
+
prefix: cellFormat?.prefix,
|
|
36
|
+
suffix: cellFormat?.suffix,
|
|
37
|
+
decimalScale: dec,
|
|
38
|
+
fixedDecimalScale: cellFormat?.fixedDecimalScale ?? false
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// if ( typeof value === "string") {
|
|
42
|
+
// const ttt = removeNumericFormat(value, undefined, numericFormatProps )
|
|
43
|
+
//
|
|
44
|
+
// }
|
|
45
|
+
|
|
46
|
+
const contentNumber = !(0, _utils.isEmpty)(value) ? dec || dec === 0 ? parseFloat(tmpval.toFixed(dec)).toString() : tmpval.toString() : '0';
|
|
47
|
+
// const contentNumber = !isEmpty(value) ? ((dec || dec === 0) ? tmpval.toString() : tmpval.toString()) : '0'
|
|
48
|
+
|
|
49
|
+
return !(0, _utils.isEmpty)(contentNumber) ? (0, _reactNumericComponent.numericFormatter)(contentNumber, numericFormatProps) : '';
|
|
50
|
+
case 'date':
|
|
51
|
+
return value ? (0, _dayjs.default)(value).format(format?.dateFormat ?? 'DD/MM/YYYY') : '';
|
|
52
|
+
case 'time':
|
|
53
|
+
return value ? value : '';
|
|
54
|
+
case 'year':
|
|
55
|
+
const year = value ? (0, _moment.default)(value).format('yyyy') : '';
|
|
56
|
+
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, year);
|
|
57
|
+
case 'datetime':
|
|
58
|
+
return value ? (0, _moment.default)(value).format(format?.datetimeFormat ?? 'DD/MM/YYYY HH:mm') : '';
|
|
59
|
+
case 'boolean':
|
|
60
|
+
return value ? 'true' : 'false';
|
|
61
|
+
case 'color':
|
|
62
|
+
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
63
|
+
className: 'w-100 h-100',
|
|
64
|
+
style: {
|
|
65
|
+
backgroundColor: (0, _utils.isColor)(value) ? value : '#fff',
|
|
66
|
+
border: '1px solid #f0f0f0',
|
|
67
|
+
height: '100%',
|
|
68
|
+
minHeight: 20
|
|
69
|
+
}
|
|
70
|
+
}));
|
|
71
|
+
case 'checkbox':
|
|
72
|
+
return /*#__PURE__*/_react.default.createElement(_ControlCheckbox.default, {
|
|
73
|
+
column: column,
|
|
74
|
+
record: record,
|
|
75
|
+
rowIndex: rowIndex,
|
|
76
|
+
colIndex: colIndex,
|
|
77
|
+
checked: !!value,
|
|
78
|
+
checkValue: value,
|
|
79
|
+
editAble: editAble
|
|
80
|
+
});
|
|
81
|
+
case 'file':
|
|
82
|
+
const nameFile = typeof value === 'object' && !Array.isArray(value) ? value.name : Array.isArray(value) ? value.map(it => typeof it === 'object' ? it.name : it).filter(Boolean).join(", ") : '';
|
|
83
|
+
return value ? nameFile : '';
|
|
84
|
+
default:
|
|
85
|
+
if (Array.isArray(value)) {
|
|
86
|
+
return value.join(', ');
|
|
87
|
+
}
|
|
88
|
+
return value;
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
exports.renderValueCell = renderValueCell;
|
|
92
|
+
function convertToTanStackColumns({
|
|
93
|
+
t,
|
|
94
|
+
columns,
|
|
95
|
+
format,
|
|
96
|
+
editAble
|
|
97
|
+
}) {
|
|
98
|
+
return (0, _utils.sortByType)(columns).map(col => {
|
|
99
|
+
const {
|
|
100
|
+
headerText,
|
|
101
|
+
headerTemplate,
|
|
102
|
+
field,
|
|
103
|
+
width,
|
|
104
|
+
allowResizing,
|
|
105
|
+
minWidth,
|
|
106
|
+
template,
|
|
107
|
+
allowSortering,
|
|
108
|
+
allowFiltering
|
|
109
|
+
} = col;
|
|
110
|
+
const {
|
|
111
|
+
children,
|
|
112
|
+
...restProps
|
|
113
|
+
} = col;
|
|
114
|
+
const newCol = {
|
|
115
|
+
header: () => {
|
|
116
|
+
if (headerTemplate) {
|
|
117
|
+
if (typeof headerTemplate === 'function') {
|
|
118
|
+
return headerTemplate(col);
|
|
119
|
+
} else {
|
|
120
|
+
return headerTemplate;
|
|
121
|
+
}
|
|
122
|
+
} else {
|
|
123
|
+
return t ? t(headerText) : headerText;
|
|
124
|
+
// return field
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
cell: props => {
|
|
128
|
+
const {
|
|
129
|
+
getValue,
|
|
130
|
+
cell
|
|
131
|
+
} = props;
|
|
132
|
+
const cellValue = props.renderValue() ?? null;
|
|
133
|
+
const record = cell.row.original;
|
|
134
|
+
const colIndex = cell.column.getIndex();
|
|
135
|
+
const rowIndex = cell.row.index;
|
|
136
|
+
if (template) {
|
|
137
|
+
if (typeof template === 'function') {
|
|
138
|
+
return template({
|
|
139
|
+
field: field ?? '',
|
|
140
|
+
index: cell.row.index,
|
|
141
|
+
rowData: cell.row.original,
|
|
142
|
+
value: getValue()
|
|
143
|
+
});
|
|
144
|
+
} else {
|
|
145
|
+
return template;
|
|
146
|
+
}
|
|
147
|
+
} else {
|
|
148
|
+
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, renderValueCell(col, cellValue, record, rowIndex, colIndex, format, editAble));
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
enableResizing: allowResizing !== false,
|
|
152
|
+
// enableHiding: false,
|
|
153
|
+
// enableResizing: true,
|
|
154
|
+
id: field,
|
|
155
|
+
size: width,
|
|
156
|
+
accessorKey: field,
|
|
157
|
+
sortDescFirst: false,
|
|
158
|
+
minSize: minWidth,
|
|
159
|
+
// maxSize: maxWidth,
|
|
160
|
+
enableSorting: allowSortering !== false,
|
|
161
|
+
// enableSorting: false,
|
|
162
|
+
// enableColumnFilter: allowFiltering !== false && !nonActionColumn.includes(field)
|
|
163
|
+
enableColumnFilter: allowFiltering !== false
|
|
164
|
+
};
|
|
165
|
+
if (children) {
|
|
166
|
+
newCol.size = undefined;
|
|
167
|
+
// @ts-ignore
|
|
168
|
+
newCol.columns = convertToTanStackColumns({
|
|
169
|
+
columns: children,
|
|
170
|
+
editAble,
|
|
171
|
+
format,
|
|
172
|
+
t
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
const meta = {
|
|
176
|
+
...restProps
|
|
177
|
+
};
|
|
178
|
+
if (Object.keys(meta).length > 0) {
|
|
179
|
+
newCol.meta = meta;
|
|
180
|
+
}
|
|
181
|
+
return newCol;
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
const toggleRowSelection = props => {
|
|
185
|
+
const {
|
|
186
|
+
selectionSettings,
|
|
187
|
+
cell,
|
|
188
|
+
isSelectionChange,
|
|
189
|
+
e,
|
|
190
|
+
setIsSelectionChange
|
|
191
|
+
} = props;
|
|
192
|
+
const {
|
|
193
|
+
row
|
|
194
|
+
} = cell;
|
|
195
|
+
const {
|
|
196
|
+
rowsData
|
|
197
|
+
} = isSelectionChange ?? {};
|
|
198
|
+
const prevSelected = rowsData && rowsData.length > 0 ? [...rowsData] : [];
|
|
199
|
+
if (selectionSettings?.checkStrictly || selectionSettings?.type === 'single') {
|
|
200
|
+
row.getToggleSelectedHandler()(e);
|
|
201
|
+
if (row.getIsSelected()) {
|
|
202
|
+
// đã chọn
|
|
203
|
+
|
|
204
|
+
// xóa row ra list selected
|
|
205
|
+
const newRowsSelected = prevSelected.filter(it => it.id !== row.id);
|
|
206
|
+
setIsSelectionChange({
|
|
207
|
+
isChange: true,
|
|
208
|
+
type: 'rowSelected',
|
|
209
|
+
rowData: row.original,
|
|
210
|
+
rowsData: newRowsSelected ?? []
|
|
211
|
+
});
|
|
212
|
+
} else {
|
|
213
|
+
// chưa selected
|
|
214
|
+
|
|
215
|
+
const checkedRows = [...prevSelected, row];
|
|
216
|
+
setIsSelectionChange({
|
|
217
|
+
isChange: true,
|
|
218
|
+
type: 'rowSelected',
|
|
219
|
+
rowData: row.original,
|
|
220
|
+
rowsData: selectionSettings?.type === 'single' ? [row] : checkedRows
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
if (row.subRows && row.subRows.length > 0) {
|
|
226
|
+
// click vào row cha
|
|
227
|
+
|
|
228
|
+
const allChild = (0, _utils.getAllChildren)(row);
|
|
229
|
+
(0, _utils.toggleRowAndChildren)(row, !row.getIsSelected());
|
|
230
|
+
if (row.getIsSelected()) {
|
|
231
|
+
// đã chọn
|
|
232
|
+
|
|
233
|
+
// const aaa = isSelectionChange?.rowsData.filter((it) => it.id !== row.id)
|
|
234
|
+
|
|
235
|
+
const newRowsSelected = (0, _utils.excludeItems)(prevSelected, [...allChild, row]);
|
|
236
|
+
setIsSelectionChange({
|
|
237
|
+
isChange: true,
|
|
238
|
+
type: 'rowSelected',
|
|
239
|
+
rowData: row.original,
|
|
240
|
+
rowsData: newRowsSelected ?? []
|
|
241
|
+
});
|
|
242
|
+
} else {
|
|
243
|
+
// chưa selected
|
|
244
|
+
|
|
245
|
+
let checkedRows = [];
|
|
246
|
+
if (row.subRows && row.subRows.length > 0) {
|
|
247
|
+
checkedRows = [...prevSelected, row, ...allChild];
|
|
248
|
+
} else {
|
|
249
|
+
checkedRows = [...prevSelected, row];
|
|
250
|
+
}
|
|
251
|
+
setIsSelectionChange({
|
|
252
|
+
isChange: true,
|
|
253
|
+
type: 'rowSelected',
|
|
254
|
+
rowData: row.original,
|
|
255
|
+
rowsData: checkedRows
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
} else {
|
|
259
|
+
// click vào row không có cha
|
|
260
|
+
|
|
261
|
+
row.getToggleSelectedHandler()(e);
|
|
262
|
+
if (row.getIsSelected()) {
|
|
263
|
+
// đã chọn
|
|
264
|
+
|
|
265
|
+
const rowParent = row.getParentRow();
|
|
266
|
+
// const rowParent1 = row.getParentRows()
|
|
267
|
+
|
|
268
|
+
let newCheckedRows = [];
|
|
269
|
+
if (rowParent) {}
|
|
270
|
+
if (rowParent && (0, _utils.countUnselectedChildren)(row) === 1) {
|
|
271
|
+
newCheckedRows = prevSelected.filter(it => it.id !== row.id && it.id !== rowParent.id);
|
|
272
|
+
} else {
|
|
273
|
+
// xóa row ra list selected
|
|
274
|
+
// const newRowsSelected = prevSelected.filter((it) => it.id !== row.id)
|
|
275
|
+
newCheckedRows = prevSelected.filter(it => it.id !== row.id);
|
|
276
|
+
}
|
|
277
|
+
setIsSelectionChange({
|
|
278
|
+
isChange: true,
|
|
279
|
+
type: 'rowSelected',
|
|
280
|
+
rowData: row.original,
|
|
281
|
+
rowsData: newCheckedRows ?? []
|
|
282
|
+
});
|
|
283
|
+
} else {
|
|
284
|
+
// chưa selected
|
|
285
|
+
|
|
286
|
+
let checkedRows = [];
|
|
287
|
+
const rowParent = row.getParentRow();
|
|
288
|
+
|
|
289
|
+
// nếu có cha và cha chưa được chọn và tất cả con đã chọn => thêm row cha vào
|
|
290
|
+
if (rowParent && !rowParent.getIsSelected() && (0, _utils.countUnselectedChildren)(row) === 1) {
|
|
291
|
+
rowParent.toggleSelected(!rowParent.getIsSelected());
|
|
292
|
+
checkedRows = [...prevSelected, row, rowParent];
|
|
293
|
+
} else {
|
|
294
|
+
// chỉ thêm vào row hiện tại
|
|
295
|
+
|
|
296
|
+
const isInclude = prevSelected.findIndex(it => it.id === cell.row.id);
|
|
297
|
+
if (isInclude > -1) {
|
|
298
|
+
// cập nhật data row hiện tại
|
|
299
|
+
|
|
300
|
+
prevSelected[isInclude] = row;
|
|
301
|
+
checkedRows = [...prevSelected];
|
|
302
|
+
} else {
|
|
303
|
+
checkedRows = [...prevSelected, row];
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
setIsSelectionChange({
|
|
307
|
+
isChange: true,
|
|
308
|
+
type: 'rowSelected',
|
|
309
|
+
rowData: row.original,
|
|
310
|
+
rowsData: checkedRows
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
exports.toggleRowSelection = toggleRowSelection;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Table } from '@tanstack/react-table';
|
|
2
|
+
import type { FilterOperator } from '../../table-component/type';
|
|
3
|
+
export declare function useFilterOperator(table: Table<any>): {
|
|
4
|
+
setFilterOperator: (columnId: string, operator: FilterOperator) => void;
|
|
5
|
+
getFilterOperator: (columnId: string) => FilterOperator;
|
|
6
|
+
};
|
|
7
|
+
export declare function customStringFilterFn(row: any, columnId: any, filterValue: any): boolean;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.customStringFilterFn = customStringFilterFn;
|
|
7
|
+
exports.useFilterOperator = useFilterOperator;
|
|
8
|
+
function useFilterOperator(table) {
|
|
9
|
+
const setFilterOperator = (columnId, operator) => {
|
|
10
|
+
const filters = table.getState().columnFilters;
|
|
11
|
+
const next = filters.map(f => f.id === columnId ? {
|
|
12
|
+
...f,
|
|
13
|
+
operator
|
|
14
|
+
} : f);
|
|
15
|
+
table.setColumnFilters(next);
|
|
16
|
+
};
|
|
17
|
+
const getFilterOperator = columnId => {
|
|
18
|
+
const filters = table.getState().columnFilters;
|
|
19
|
+
return filters.find(f => f.id === columnId)?.operator ?? 'contains';
|
|
20
|
+
};
|
|
21
|
+
return {
|
|
22
|
+
setFilterOperator,
|
|
23
|
+
getFilterOperator
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function customStringFilterFn(row, columnId, filterValue) {
|
|
27
|
+
const filters = row.table.getState().columnFilters;
|
|
28
|
+
const operator = filters.find(f => f.id === columnId)?.operator ?? 'contains';
|
|
29
|
+
const cellValue = String(row.getValue(columnId) ?? '');
|
|
30
|
+
switch (operator) {
|
|
31
|
+
case 'equal':
|
|
32
|
+
return cellValue === filterValue;
|
|
33
|
+
case 'startsWith':
|
|
34
|
+
return cellValue.toLowerCase().startsWith(filterValue.toLowerCase());
|
|
35
|
+
case 'endsWith':
|
|
36
|
+
return cellValue.toLowerCase().endsWith(filterValue.toLowerCase());
|
|
37
|
+
default:
|
|
38
|
+
return cellValue.toLowerCase().includes(filterValue.toLowerCase());
|
|
39
|
+
}
|
|
40
|
+
}
|