es-grid-template 0.1.2-2 → 0.1.3-0
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/CheckboxFilter.d.ts +1 -0
- package/es/grid-component/CheckboxFilter.js +4 -3
- package/es/grid-component/ColumnsChoose.js +4 -4
- package/es/grid-component/InternalTable.js +27 -19
- package/es/grid-component/TableGrid.d.ts +1 -0
- package/es/grid-component/TableGrid.js +48 -40
- package/es/grid-component/hooks/constant.js +14 -14
- package/es/grid-component/hooks/useColumns/index.js +8 -4
- package/es/grid-component/styles.scss +11 -0
- package/es/grid-component/table/Grid.d.ts +1 -0
- package/es/grid-component/table/Grid.js +7 -3
- package/es/grid-component/table/GridEdit.js +2 -1
- package/es/grid-component/type.d.ts +5 -2
- package/lib/grid-component/CheckboxFilter.d.ts +1 -0
- package/lib/grid-component/CheckboxFilter.js +4 -3
- package/lib/grid-component/ColumnsChoose.js +4 -4
- package/lib/grid-component/InternalTable.js +26 -18
- package/lib/grid-component/TableGrid.d.ts +1 -0
- package/lib/grid-component/TableGrid.js +48 -40
- package/lib/grid-component/hooks/constant.js +14 -14
- package/lib/grid-component/hooks/useColumns/index.js +8 -4
- package/lib/grid-component/styles.scss +11 -0
- package/lib/grid-component/table/Grid.d.ts +1 -0
- package/lib/grid-component/table/Grid.js +7 -3
- package/lib/grid-component/table/GridEdit.js +2 -1
- package/lib/grid-component/type.d.ts +5 -2
- package/package.json +2 -2
|
@@ -72,6 +72,7 @@ const CheckboxFilter = props => {
|
|
|
72
72
|
filterMode = 'tree',
|
|
73
73
|
// open,
|
|
74
74
|
searchValue,
|
|
75
|
+
showFilter,
|
|
75
76
|
setSearchValue,
|
|
76
77
|
onSelect
|
|
77
78
|
} = props;
|
|
@@ -173,7 +174,7 @@ const CheckboxFilter = props => {
|
|
|
173
174
|
}
|
|
174
175
|
};
|
|
175
176
|
if (filterMode === 'tree') {
|
|
176
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FilterSearch, {
|
|
177
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, showFilter && /*#__PURE__*/React.createElement(FilterSearch, {
|
|
177
178
|
filterSearch: filterSearch,
|
|
178
179
|
value: searchValue,
|
|
179
180
|
onChange: onSearch,
|
|
@@ -181,7 +182,7 @@ const CheckboxFilter = props => {
|
|
|
181
182
|
locale: locale
|
|
182
183
|
}), /*#__PURE__*/React.createElement("div", {
|
|
183
184
|
className: `${tablePrefixCls}-filter-dropdown-tree`
|
|
184
|
-
}, filterMultiple ? /*#__PURE__*/React.createElement(Checkbox
|
|
185
|
+
}, filterMultiple && options.length > 0 ? /*#__PURE__*/React.createElement(Checkbox
|
|
185
186
|
// checked={selectedKeys.length === flattenKeys(column.filters).length}
|
|
186
187
|
, {
|
|
187
188
|
checked: selectedKeys.length === flattenKeys(options).length
|
|
@@ -194,7 +195,7 @@ const CheckboxFilter = props => {
|
|
|
194
195
|
indeterminate: selectedKeys.length > 0 && selectedKeys.length < flattenKeys(options).length,
|
|
195
196
|
className: `${tablePrefixCls}-filter-dropdown-checkall`,
|
|
196
197
|
onChange: onCheckAll
|
|
197
|
-
}, locale.filterCheckall) : null, /*#__PURE__*/React.createElement(Tree, {
|
|
198
|
+
}, locale.filterCheckall) : /*#__PURE__*/React.createElement(Empty, null), /*#__PURE__*/React.createElement(Tree, {
|
|
198
199
|
checkable: true,
|
|
199
200
|
selectable: false,
|
|
200
201
|
blockNode: true,
|
|
@@ -14,8 +14,8 @@ const BoxAction = styled.div.withConfig({
|
|
|
14
14
|
export const ColumnsChoose = props => {
|
|
15
15
|
const {
|
|
16
16
|
columns: propsColumns,
|
|
17
|
-
triggerChangeColumns
|
|
18
|
-
|
|
17
|
+
triggerChangeColumns,
|
|
18
|
+
t
|
|
19
19
|
} = props;
|
|
20
20
|
|
|
21
21
|
// const dataList: { key: React.Key; title: string }[] = [];
|
|
@@ -207,10 +207,10 @@ export const ColumnsChoose = props => {
|
|
|
207
207
|
, {
|
|
208
208
|
onClick: handleAccept
|
|
209
209
|
// disabled={!columns.find((item) => item.visible !== false || item.visible)}
|
|
210
|
-
}, 'OK'), /*#__PURE__*/React.createElement(Button, {
|
|
210
|
+
}, t ? t('OK') : 'OK'), /*#__PURE__*/React.createElement(Button, {
|
|
211
211
|
className: 'btn-action btn-action-cancel',
|
|
212
212
|
onClick: handleCancel
|
|
213
|
-
}, 'Cancel'))),
|
|
213
|
+
}, t ? t('Cancel') : 'Cancel'))),
|
|
214
214
|
trigger: "click",
|
|
215
215
|
open: clicked,
|
|
216
216
|
onOpenChange: handleClickChange,
|
|
@@ -5,7 +5,7 @@ import { Button, Space } from "antd";
|
|
|
5
5
|
import { SearchOutlined } from "@ant-design/icons";
|
|
6
6
|
import { Resizable } from "react-resizable";
|
|
7
7
|
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
|
8
|
-
import { numberOperator, translateOption, updateArrayByKey } from "./hooks";
|
|
8
|
+
import { booleanOperator, getTypeFilter, numberOperator, stringOperator, translateOption, updateArrayByKey } from "./hooks";
|
|
9
9
|
import { FilterFill } from "becoxy-icons";
|
|
10
10
|
import { renderFilter } from "./hooks/useColumns";
|
|
11
11
|
import dayjs from "dayjs";
|
|
@@ -57,6 +57,7 @@ const InternalTable = props => {
|
|
|
57
57
|
editAble,
|
|
58
58
|
rowKey,
|
|
59
59
|
onDataChange,
|
|
60
|
+
sortMultiple,
|
|
60
61
|
...rest
|
|
61
62
|
} = props;
|
|
62
63
|
const locale = lang && lang === 'en' ? en : vi;
|
|
@@ -114,23 +115,27 @@ const InternalTable = props => {
|
|
|
114
115
|
setSelectedKeys,
|
|
115
116
|
selectedKeys,
|
|
116
117
|
confirm,
|
|
117
|
-
close,
|
|
118
|
+
// close,
|
|
118
119
|
setOperatorKey,
|
|
119
120
|
operatorKey,
|
|
120
121
|
visible,
|
|
121
122
|
searchValue,
|
|
122
123
|
setSearchValue
|
|
123
124
|
}) => {
|
|
125
|
+
const type = getTypeFilter(column);
|
|
126
|
+
// const operatorOptions = !type || type === 'Text' ? stringOperator : numberOperator
|
|
127
|
+
// const operatorOptions = type === 'Checkbox' || type === 'Dropdown' || type === 'DropTree' || ty
|
|
128
|
+
const operatorOptions = type === ('Checkbox' || 'Dropdown' || 'DropTree' || 'CheckboxDropdown') ? booleanOperator : !type || type === 'Text' ? stringOperator : numberOperator;
|
|
124
129
|
return /*#__PURE__*/React.createElement("div", {
|
|
125
130
|
style: {
|
|
126
131
|
padding: 8,
|
|
127
132
|
minWidth: 275
|
|
128
133
|
},
|
|
129
134
|
onKeyDown: e => e.stopPropagation()
|
|
130
|
-
},
|
|
135
|
+
}, column?.showOperator !== false && column?.typeFilter !== 'DateRange' && column?.typeFilter !== 'NumberRange' && /*#__PURE__*/React.createElement("div", {
|
|
131
136
|
className: 'mb-1'
|
|
132
137
|
}, /*#__PURE__*/React.createElement(Select, {
|
|
133
|
-
options: translateOption(
|
|
138
|
+
options: translateOption(operatorOptions, t),
|
|
134
139
|
style: {
|
|
135
140
|
width: '100%',
|
|
136
141
|
marginBottom: 8
|
|
@@ -161,13 +166,17 @@ const InternalTable = props => {
|
|
|
161
166
|
style: {
|
|
162
167
|
width: 90
|
|
163
168
|
}
|
|
164
|
-
},
|
|
169
|
+
}, t ? t('Filter') : 'Filter'), /*#__PURE__*/React.createElement(Button, {
|
|
165
170
|
type: "link",
|
|
166
171
|
size: "small",
|
|
167
172
|
onClick: () => {
|
|
168
|
-
|
|
173
|
+
// setSearchValue('')
|
|
174
|
+
setSelectedKeys([]);
|
|
175
|
+
confirm();
|
|
176
|
+
// handleSearch()
|
|
177
|
+
// close()
|
|
169
178
|
}
|
|
170
|
-
}, "
|
|
179
|
+
}, t ? t("Clear") : 'Clear')));
|
|
171
180
|
},
|
|
172
181
|
filterIcon: filtered => /*#__PURE__*/React.createElement(FilterFill, {
|
|
173
182
|
fontSize: 12,
|
|
@@ -185,7 +194,7 @@ const InternalTable = props => {
|
|
|
185
194
|
}
|
|
186
195
|
}
|
|
187
196
|
}
|
|
188
|
-
}), [onFilterCallback, onFilterClick,
|
|
197
|
+
}), [buddhistLocale, dataSourceFilter, onFilterCallback, onFilterClick, t]);
|
|
189
198
|
const handleResize = indexPath => (e, {
|
|
190
199
|
size
|
|
191
200
|
}) => {
|
|
@@ -236,6 +245,7 @@ const InternalTable = props => {
|
|
|
236
245
|
const transformedColumn = {
|
|
237
246
|
...col,
|
|
238
247
|
dataIndex: col.field ?? col.dataIndex,
|
|
248
|
+
key: col.field ?? col.dataIndex ?? col.key,
|
|
239
249
|
title: t ? t(col.headerText ?? col.title) : col.headerText ?? col.title,
|
|
240
250
|
ellipsis: col.ellipsis !== false,
|
|
241
251
|
align: col.textAlign ?? col.align,
|
|
@@ -247,7 +257,7 @@ const InternalTable = props => {
|
|
|
247
257
|
children: transformColumns(col.children, currentPath)
|
|
248
258
|
};
|
|
249
259
|
}
|
|
250
|
-
if (col.dataIndex === 'index' || col.field === 'index' || col.dataIndex === '#' || col.
|
|
260
|
+
if (col.dataIndex === 'index' || col.field === 'index' || col.dataIndex === '#' || col.field === '#' || col.allowFiltering === false || col.field === 'command') {
|
|
251
261
|
return {
|
|
252
262
|
...transformedColumn
|
|
253
263
|
};
|
|
@@ -255,15 +265,12 @@ const InternalTable = props => {
|
|
|
255
265
|
return {
|
|
256
266
|
...getColumnSearchProps(col),
|
|
257
267
|
...transformedColumn,
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
onFilter: (value, record) => {
|
|
265
|
-
// @ts-ignore
|
|
266
|
-
return record[col.field ?? col.dataIndex];
|
|
268
|
+
onFilter: value => {
|
|
269
|
+
return value;
|
|
270
|
+
},
|
|
271
|
+
sorter: {
|
|
272
|
+
compare: a => a,
|
|
273
|
+
multiple: sortMultiple ? index : undefined
|
|
267
274
|
},
|
|
268
275
|
onHeaderCell: () => ({
|
|
269
276
|
width: col.width,
|
|
@@ -271,7 +278,7 @@ const InternalTable = props => {
|
|
|
271
278
|
})
|
|
272
279
|
};
|
|
273
280
|
});
|
|
274
|
-
}, [getColumnSearchProps]);
|
|
281
|
+
}, [getColumnSearchProps, sortMultiple, t]);
|
|
275
282
|
const mergedColumns = React.useMemo(() => {
|
|
276
283
|
return transformColumns(columns);
|
|
277
284
|
}, [transformColumns, columns]);
|
|
@@ -286,6 +293,7 @@ const InternalTable = props => {
|
|
|
286
293
|
};
|
|
287
294
|
const TableComponent = editAble ? GridEdit : Grid;
|
|
288
295
|
return /*#__PURE__*/React.createElement(TableComponent, _extends({}, rest, {
|
|
296
|
+
t: t,
|
|
289
297
|
tableRef: tableRef,
|
|
290
298
|
dataSource: data,
|
|
291
299
|
components: {
|
|
@@ -6,6 +6,7 @@ type GridProps<T> = GridTableProps<T> & {
|
|
|
6
6
|
triggerChangeColumns?: () => void;
|
|
7
7
|
triggerChangeData?: () => void;
|
|
8
8
|
tableRef: any;
|
|
9
|
+
getRowKey: any;
|
|
9
10
|
};
|
|
10
11
|
declare const TableGrid: <RecordType extends object>(props: GridProps<RecordType>) => React.JSX.Element;
|
|
11
12
|
export default TableGrid;
|
|
@@ -108,13 +108,16 @@ const TableGrid = props => {
|
|
|
108
108
|
selectionSettings,
|
|
109
109
|
rowSelection,
|
|
110
110
|
rowSelected,
|
|
111
|
-
rowKey
|
|
111
|
+
rowKey,
|
|
112
112
|
pagination,
|
|
113
113
|
scroll,
|
|
114
114
|
onFilterClick,
|
|
115
115
|
dataSourceFilter: propDataSourceFilter,
|
|
116
116
|
loading,
|
|
117
117
|
triggerChangeColumns,
|
|
118
|
+
summary,
|
|
119
|
+
getRowKey,
|
|
120
|
+
onSorter,
|
|
118
121
|
...rest
|
|
119
122
|
} = props;
|
|
120
123
|
const {
|
|
@@ -133,12 +136,6 @@ const TableGrid = props => {
|
|
|
133
136
|
const menuRef = useRef(null);
|
|
134
137
|
const viewportWidth = window.innerWidth;
|
|
135
138
|
const viewportHeight = window.innerHeight;
|
|
136
|
-
|
|
137
|
-
// const defaultSelected = useMemo(() => {
|
|
138
|
-
// return defaultSelectedRowKeys ?? []
|
|
139
|
-
//
|
|
140
|
-
// }, [defaultSelectedRowKeys])
|
|
141
|
-
|
|
142
139
|
const [menuVisible, setMenuVisible] = React.useState(false);
|
|
143
140
|
const [selectedRowData, setSelectedRowData] = React.useState(null);
|
|
144
141
|
const [position, setPosition] = React.useState({
|
|
@@ -158,6 +155,8 @@ const TableGrid = props => {
|
|
|
158
155
|
// },
|
|
159
156
|
// );
|
|
160
157
|
|
|
158
|
+
// console.log('mergedSelectedKeys', mergedSelectedKeys)
|
|
159
|
+
|
|
161
160
|
// Reset if rowSelection reset
|
|
162
161
|
|
|
163
162
|
// React.useEffect(() => {
|
|
@@ -234,11 +233,10 @@ const TableGrid = props => {
|
|
|
234
233
|
}
|
|
235
234
|
};
|
|
236
235
|
const handleRowClick = () => () => {
|
|
237
|
-
// console.log(data)
|
|
238
|
-
// console.log(index)
|
|
239
|
-
|
|
240
236
|
// const key = getRowKey(record, index);
|
|
241
237
|
|
|
238
|
+
// const keySet = new Set(derivedSelectedKeySet);
|
|
239
|
+
|
|
242
240
|
// console.log('key', key)
|
|
243
241
|
|
|
244
242
|
if (checkboxOnly !== true) {
|
|
@@ -292,7 +290,7 @@ const TableGrid = props => {
|
|
|
292
290
|
}
|
|
293
291
|
};
|
|
294
292
|
const handleChange = sorter => {
|
|
295
|
-
|
|
293
|
+
onSorter?.(sorter);
|
|
296
294
|
// setFilteredInfo(filters);
|
|
297
295
|
// setSortedInfo(sorter as Sorts);
|
|
298
296
|
};
|
|
@@ -357,29 +355,37 @@ const TableGrid = props => {
|
|
|
357
355
|
onScroll: () => {
|
|
358
356
|
setMenuVisible(false);
|
|
359
357
|
},
|
|
360
|
-
summary: () =>
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
thousandSeparator:
|
|
371
|
-
decimalSeparator
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
358
|
+
summary: () => {
|
|
359
|
+
if (typeof summary === 'function') {
|
|
360
|
+
return summary(dataSource);
|
|
361
|
+
}
|
|
362
|
+
if (!summary) {
|
|
363
|
+
return undefined;
|
|
364
|
+
}
|
|
365
|
+
return /*#__PURE__*/React.createElement(Table.Summary, {
|
|
366
|
+
fixed: true
|
|
367
|
+
}, /*#__PURE__*/React.createElement(Table.Summary.Row, null, flatColumns(columns).filter(col => col.hidden !== true).map((col, index) => {
|
|
368
|
+
const thousandSeparator = col.format?.thousandSeparator ? col.format?.thousandSeparator : format?.thousandSeparator;
|
|
369
|
+
const decimalSeparator = col.format?.decimalSeparator ? col.format?.decimalSeparator : format?.decimalSeparator;
|
|
370
|
+
const dec = col.format?.decimalScale || col.format?.decimalScale === 0 ? col.format?.decimalScale : format?.decimalScale;
|
|
371
|
+
const sumValue = col.type === 'number' ? sumDataByField(dataSource, col?.key) : 0;
|
|
372
|
+
const value = !isEmpty(sumValue) ? dec || dec === 0 ? parseFloat(Number(sumValue).toFixed(dec)).toString() : sumValue.toString() : '0';
|
|
373
|
+
const cellValue = col.type === 'number' && col.isSummary !== false ? value : '';
|
|
374
|
+
const numericFormatProps = {
|
|
375
|
+
thousandSeparator: checkThousandSeparator(thousandSeparator, decimalSeparator),
|
|
376
|
+
decimalSeparator: checkDecimalSeparator(thousandSeparator, decimalSeparator),
|
|
377
|
+
allowNegative: (col.format?.allowNegative ? col.format?.allowNegative : format?.allowNegative) ?? false,
|
|
378
|
+
prefix: col.format?.prefix ? col.format?.prefix : format?.prefix,
|
|
379
|
+
suffix: col.format?.suffix ? col.format?.suffix : format?.suffix,
|
|
380
|
+
decimalScale: dec,
|
|
381
|
+
fixedDecimalScale: (col.format?.fixedDecimalScale ? col.format?.fixedDecimalScale : format?.fixedDecimalScale) ?? false
|
|
382
|
+
};
|
|
383
|
+
return /*#__PURE__*/React.createElement(Table.Summary.Cell, {
|
|
384
|
+
key: col.key,
|
|
385
|
+
index: index
|
|
386
|
+
}, col.summaryTemplate ? col.summaryTemplate(cellValue, col.key) : numericFormatter(cellValue, numericFormatProps));
|
|
387
|
+
})));
|
|
388
|
+
},
|
|
383
389
|
pagination: pagination && pagination.onChange ? false : {
|
|
384
390
|
showTotal: (total, range) => `${range[0]}-${range[1]} / ${total} items`,
|
|
385
391
|
...pagination
|
|
@@ -401,12 +407,12 @@ const TableGrid = props => {
|
|
|
401
407
|
items: toolbarItems ?? [],
|
|
402
408
|
mode: 'responsive'
|
|
403
409
|
// mode={'scroll'}
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
}
|
|
410
|
+
// onClick={(val: any) => {
|
|
411
|
+
// console.log(val)
|
|
412
|
+
// }}
|
|
408
413
|
}), showColumnChoose && /*#__PURE__*/React.createElement(ColumnsChoose, {
|
|
409
414
|
columns: columns,
|
|
415
|
+
t: t,
|
|
410
416
|
triggerChangeColumns: triggerChangeColumns
|
|
411
417
|
}), /*#__PURE__*/React.createElement("div", null)));
|
|
412
418
|
}
|
|
@@ -415,8 +421,10 @@ const TableGrid = props => {
|
|
|
415
421
|
, _extends({
|
|
416
422
|
showSizeChanger: true,
|
|
417
423
|
responsive: true,
|
|
418
|
-
size: 'small'
|
|
419
|
-
|
|
424
|
+
size: 'small'
|
|
425
|
+
// @ts-ignore
|
|
426
|
+
,
|
|
427
|
+
showTotal: (total, range) => `${range[0]}-${range[1]} / ${total} ${t ? t(pagination?.locale?.items ?? 'items') : 'items'}`
|
|
420
428
|
}, pagination))));
|
|
421
429
|
};
|
|
422
430
|
export default TableGrid;
|
|
@@ -10,29 +10,29 @@ export const numberOperator = [{
|
|
|
10
10
|
key: '>'
|
|
11
11
|
}, {
|
|
12
12
|
value: 'greaterthanorequal',
|
|
13
|
-
label: 'Greater
|
|
13
|
+
label: 'Greater than or equal',
|
|
14
14
|
key: '>='
|
|
15
15
|
}, {
|
|
16
16
|
value: 'lessthan',
|
|
17
|
-
label: 'Less
|
|
17
|
+
label: 'Less than',
|
|
18
18
|
key: '<'
|
|
19
19
|
}, {
|
|
20
20
|
value: 'lessthanorequal',
|
|
21
|
-
label: 'Less
|
|
21
|
+
label: 'Less than or equal',
|
|
22
22
|
key: '<='
|
|
23
23
|
}, {
|
|
24
24
|
value: 'notequal',
|
|
25
|
-
label: 'Not
|
|
25
|
+
label: 'Not equal',
|
|
26
26
|
key: '!='
|
|
27
27
|
}];
|
|
28
28
|
export const stringOperator = [{
|
|
29
29
|
value: 'startswith',
|
|
30
30
|
key: '_=',
|
|
31
|
-
label: 'Starts
|
|
31
|
+
label: 'Starts with'
|
|
32
32
|
}, {
|
|
33
33
|
value: 'endswith',
|
|
34
34
|
key: '|=',
|
|
35
|
-
label: 'Ends
|
|
35
|
+
label: 'Ends with'
|
|
36
36
|
}, {
|
|
37
37
|
value: 'contains',
|
|
38
38
|
key: '~=',
|
|
@@ -44,7 +44,7 @@ export const stringOperator = [{
|
|
|
44
44
|
}, {
|
|
45
45
|
value: 'notequal',
|
|
46
46
|
key: '!=',
|
|
47
|
-
label: 'Not
|
|
47
|
+
label: 'Not equal'
|
|
48
48
|
}];
|
|
49
49
|
export const dateOperator = [{
|
|
50
50
|
value: 'equal',
|
|
@@ -53,15 +53,15 @@ export const dateOperator = [{
|
|
|
53
53
|
}, {
|
|
54
54
|
value: 'notequal',
|
|
55
55
|
key: '!=',
|
|
56
|
-
label: 'Not
|
|
56
|
+
label: 'Not equal'
|
|
57
57
|
}, {
|
|
58
58
|
value: 'greaterthan',
|
|
59
59
|
key: '>',
|
|
60
|
-
label: 'Greater
|
|
60
|
+
label: 'Greater than'
|
|
61
61
|
}, {
|
|
62
62
|
value: 'lessthan',
|
|
63
63
|
key: '<',
|
|
64
|
-
label: 'Less
|
|
64
|
+
label: 'Less than'
|
|
65
65
|
}];
|
|
66
66
|
export const dateTimeOperator = [{
|
|
67
67
|
value: 'equal',
|
|
@@ -70,15 +70,15 @@ export const dateTimeOperator = [{
|
|
|
70
70
|
}, {
|
|
71
71
|
value: 'notequal',
|
|
72
72
|
key: '!=',
|
|
73
|
-
label: 'Not
|
|
73
|
+
label: 'Not equal'
|
|
74
74
|
}, {
|
|
75
75
|
value: 'greaterthan',
|
|
76
76
|
key: '>',
|
|
77
|
-
label: 'Greater
|
|
77
|
+
label: 'Greater than'
|
|
78
78
|
}, {
|
|
79
79
|
value: 'lessthan',
|
|
80
80
|
key: '<',
|
|
81
|
-
label: 'Less
|
|
81
|
+
label: 'Less than'
|
|
82
82
|
}];
|
|
83
83
|
export const booleanOperator = [{
|
|
84
84
|
value: 'equal',
|
|
@@ -87,7 +87,7 @@ export const booleanOperator = [{
|
|
|
87
87
|
}, {
|
|
88
88
|
value: 'notequal',
|
|
89
89
|
key: '!=',
|
|
90
|
-
label: 'Not
|
|
90
|
+
label: 'Not equal'
|
|
91
91
|
}];
|
|
92
92
|
export const translateOption = (options, t) => {
|
|
93
93
|
if (!t) {
|
|
@@ -96,8 +96,8 @@ export const renderContent = (column, value, record, index, format) => {
|
|
|
96
96
|
export const renderFilter = (column, selectedKeys, setSelectedKeys, confirm, visible, searchValue, setSearchValue, dataSourceFilter, buddhistLocale) => {
|
|
97
97
|
const type = getTypeFilter(column);
|
|
98
98
|
const dateFormat = getDatepickerFormat(column?.typeFilter ?? column?.type, column) ?? 'DD/MM/YYYY';
|
|
99
|
-
const dateRangeFormat =
|
|
100
|
-
const find = dataSourceFilter?.find(it => it.key === column?.
|
|
99
|
+
const dateRangeFormat = 'DD/MM/YYYY';
|
|
100
|
+
const find = dataSourceFilter?.find(it => it.key === (column?.field || column.dataIndex));
|
|
101
101
|
const options = find ? find.data : [];
|
|
102
102
|
switch (type) {
|
|
103
103
|
case 'Number':
|
|
@@ -182,7 +182,8 @@ export const renderFilter = (column, selectedKeys, setSelectedKeys, confirm, vis
|
|
|
182
182
|
format: {
|
|
183
183
|
format: dateRangeFormat,
|
|
184
184
|
type: 'mask'
|
|
185
|
-
}
|
|
185
|
+
},
|
|
186
|
+
locale: buddhistLocale
|
|
186
187
|
// defaultValue={dateRangeValue}
|
|
187
188
|
,
|
|
188
189
|
value: dateRangeValue,
|
|
@@ -401,9 +402,12 @@ export const renderFilter = (column, selectedKeys, setSelectedKeys, confirm, vis
|
|
|
401
402
|
filterTitle: 'Chọn tất cả',
|
|
402
403
|
filterCheckall: 'Chọn tất cả'
|
|
403
404
|
},
|
|
405
|
+
showFilter: column.showFilterSearch,
|
|
404
406
|
selectedKeys: selectedKeys,
|
|
405
407
|
onSelect: setSelectedKeys,
|
|
406
|
-
options: options
|
|
408
|
+
options: options
|
|
409
|
+
// options={[]}
|
|
410
|
+
,
|
|
407
411
|
filterMultiple: true,
|
|
408
412
|
open: visible,
|
|
409
413
|
searchValue: searchValue,
|
|
@@ -83,6 +83,16 @@ $rowSelectedHoverBg: 'ui-rc' !default;
|
|
|
83
83
|
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
|
+
.ui-rc-table-placeholder {
|
|
87
|
+
.ui-rc-table-cell {
|
|
88
|
+
padding-top: 0 !important;
|
|
89
|
+
padding-bottom: 0 !important;
|
|
90
|
+
.ui-rc-table-expanded-row-fixed {
|
|
91
|
+
margin-top: 0 !important;
|
|
92
|
+
margin-bottom: 0 !important;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
86
96
|
}
|
|
87
97
|
|
|
88
98
|
.#{$prefix}-table-thead {
|
|
@@ -106,6 +116,7 @@ $rowSelectedHoverBg: 'ui-rc' !default;
|
|
|
106
116
|
.#{$prefix}-table-summary {
|
|
107
117
|
.#{$prefix}-table-cell {
|
|
108
118
|
background-color: #fafafa;
|
|
119
|
+
height: 32px;
|
|
109
120
|
}
|
|
110
121
|
|
|
111
122
|
> tr > td {
|
|
@@ -6,12 +6,14 @@ import Command from "../Command";
|
|
|
6
6
|
import { renderContent } from "../hooks/useColumns";
|
|
7
7
|
const Grid = props => {
|
|
8
8
|
const {
|
|
9
|
+
t,
|
|
9
10
|
columns,
|
|
10
11
|
height,
|
|
11
12
|
tableRef,
|
|
12
13
|
components,
|
|
13
14
|
style,
|
|
14
15
|
format,
|
|
16
|
+
getRowKey,
|
|
15
17
|
...rest
|
|
16
18
|
} = props;
|
|
17
19
|
const transformColumns = React.useCallback(cols => {
|
|
@@ -31,7 +33,7 @@ const Grid = props => {
|
|
|
31
33
|
const transformedColumn = {
|
|
32
34
|
...column,
|
|
33
35
|
dataIndex: column.field ?? column.dataIndex,
|
|
34
|
-
title: column.headerText ?? column.title,
|
|
36
|
+
title: t ? t(column.headerText ?? column.title) : column.headerText ?? column.title,
|
|
35
37
|
ellipsis: column.ellipsis !== false,
|
|
36
38
|
align: column.textAlign ?? column.align,
|
|
37
39
|
fixed: column.frozen ? column.frozen.toLowerCase() : column.fixed
|
|
@@ -63,7 +65,7 @@ const Grid = props => {
|
|
|
63
65
|
render: (value, record, rowIndex) => renderContent(column, value, record, rowIndex, format)
|
|
64
66
|
};
|
|
65
67
|
});
|
|
66
|
-
}, []);
|
|
68
|
+
}, [format, t]);
|
|
67
69
|
const mergedColumns = useMemo(() => transformColumns(columns ?? []), [transformColumns, columns]);
|
|
68
70
|
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(GridStyle, {
|
|
69
71
|
heightTable: height,
|
|
@@ -71,6 +73,7 @@ const Grid = props => {
|
|
|
71
73
|
position: 'relative'
|
|
72
74
|
}
|
|
73
75
|
}, /*#__PURE__*/React.createElement(TableGrid, _extends({}, rest, {
|
|
76
|
+
t: t,
|
|
74
77
|
tableRef: tableRef,
|
|
75
78
|
components: {
|
|
76
79
|
...components
|
|
@@ -79,7 +82,8 @@ const Grid = props => {
|
|
|
79
82
|
style: {
|
|
80
83
|
...style,
|
|
81
84
|
minHeight: height
|
|
82
|
-
}
|
|
85
|
+
},
|
|
86
|
+
getRowKey: getRowKey
|
|
83
87
|
}))));
|
|
84
88
|
};
|
|
85
89
|
export default Grid;
|
|
@@ -91,6 +91,7 @@ export type ColumnType<RecordType> = Omit<RcColumnType<RecordType>, 'headerTempl
|
|
|
91
91
|
placeholder?: string;
|
|
92
92
|
showInColumnChoose?: boolean;
|
|
93
93
|
typeFilter?: TypeFilter;
|
|
94
|
+
showFilterSearch?: boolean;
|
|
94
95
|
headerText?: string;
|
|
95
96
|
textAlign?: ITextAlign;
|
|
96
97
|
frozen?: Frozen;
|
|
@@ -118,8 +119,9 @@ export type ColumnsType<RecordType = AnyObject> = ColumnType<RecordType>[];
|
|
|
118
119
|
export type ColumnsEditType<RecordType = AnyObject> = ColumnEditType<RecordType>[];
|
|
119
120
|
export type ColumnTable<RecordType = AnyObject> = ColumnEditType<RecordType> | ColumnType<RecordType>;
|
|
120
121
|
export type ColumnsTable<RecordType = AnyObject> = (ColumnType<RecordType> | ColumnEditType<RecordType>)[];
|
|
121
|
-
export interface TableProps<RecordType> extends Omit<RcTableProps<RecordType>, 'columns' | 'rowSelection' | 'loading' | 'dataSource'> {
|
|
122
|
+
export interface TableProps<RecordType> extends Omit<RcTableProps<RecordType>, 'columns' | 'rowSelection' | 'loading' | 'dataSource' | 'summary'> {
|
|
122
123
|
editAble?: boolean;
|
|
124
|
+
sortMultiple?: boolean;
|
|
123
125
|
dataSource: RecordType[];
|
|
124
126
|
columns: ColumnsTable<RecordType>;
|
|
125
127
|
height?: number;
|
|
@@ -159,6 +161,7 @@ export interface TableProps<RecordType> extends Omit<RcTableProps<RecordType>, '
|
|
|
159
161
|
loading?: boolean;
|
|
160
162
|
allowResizing?: boolean;
|
|
161
163
|
onDataChange?: (data: RecordType[]) => void;
|
|
164
|
+
summary?: boolean | ((data: readonly RecordType[]) => React.ReactNode);
|
|
162
165
|
}
|
|
163
166
|
export interface TableEditProps<RecordType = AnyObject> extends Omit<TableProps<RecordType>, 'columns'> {
|
|
164
167
|
columns: ColumnsTable<RecordType>;
|
|
@@ -173,7 +176,7 @@ export interface CommandItem {
|
|
|
173
176
|
title: string;
|
|
174
177
|
color?: 'blue' | 'purple' | 'cyan' | 'green' | 'magenta' | 'pink' | 'red' | 'orange' | 'yellow' | 'volcano' | 'geekblue' | 'lime' | 'gold';
|
|
175
178
|
tooltip?: string;
|
|
176
|
-
icon?:
|
|
179
|
+
icon?: any;
|
|
177
180
|
template?: ReactNode | ReactElement | (() => ReactNode | ReactElement);
|
|
178
181
|
client?: boolean;
|
|
179
182
|
confirmDialog?: boolean;
|
|
@@ -81,6 +81,7 @@ const CheckboxFilter = props => {
|
|
|
81
81
|
filterMode = 'tree',
|
|
82
82
|
// open,
|
|
83
83
|
searchValue,
|
|
84
|
+
showFilter,
|
|
84
85
|
setSearchValue,
|
|
85
86
|
onSelect
|
|
86
87
|
} = props;
|
|
@@ -182,7 +183,7 @@ const CheckboxFilter = props => {
|
|
|
182
183
|
}
|
|
183
184
|
};
|
|
184
185
|
if (filterMode === 'tree') {
|
|
185
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_FilterSearch.default, {
|
|
186
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, showFilter && /*#__PURE__*/React.createElement(_FilterSearch.default, {
|
|
186
187
|
filterSearch: filterSearch,
|
|
187
188
|
value: searchValue,
|
|
188
189
|
onChange: onSearch,
|
|
@@ -190,7 +191,7 @@ const CheckboxFilter = props => {
|
|
|
190
191
|
locale: locale
|
|
191
192
|
}), /*#__PURE__*/React.createElement("div", {
|
|
192
193
|
className: `${tablePrefixCls}-filter-dropdown-tree`
|
|
193
|
-
}, filterMultiple ? /*#__PURE__*/React.createElement(_rcMasterUi.Checkbox
|
|
194
|
+
}, filterMultiple && options.length > 0 ? /*#__PURE__*/React.createElement(_rcMasterUi.Checkbox
|
|
194
195
|
// checked={selectedKeys.length === flattenKeys(column.filters).length}
|
|
195
196
|
, {
|
|
196
197
|
checked: selectedKeys.length === (0, _useFilter.flattenKeys)(options).length
|
|
@@ -203,7 +204,7 @@ const CheckboxFilter = props => {
|
|
|
203
204
|
indeterminate: selectedKeys.length > 0 && selectedKeys.length < (0, _useFilter.flattenKeys)(options).length,
|
|
204
205
|
className: `${tablePrefixCls}-filter-dropdown-checkall`,
|
|
205
206
|
onChange: onCheckAll
|
|
206
|
-
}, locale.filterCheckall) : null, /*#__PURE__*/React.createElement(_antd.Tree, {
|
|
207
|
+
}, locale.filterCheckall) : /*#__PURE__*/React.createElement(_rcMasterUi.Empty, null), /*#__PURE__*/React.createElement(_antd.Tree, {
|
|
207
208
|
checkable: true,
|
|
208
209
|
selectable: false,
|
|
209
210
|
blockNode: true,
|
|
@@ -23,8 +23,8 @@ const BoxAction = _styledComponents.default.div.withConfig({
|
|
|
23
23
|
const ColumnsChoose = props => {
|
|
24
24
|
const {
|
|
25
25
|
columns: propsColumns,
|
|
26
|
-
triggerChangeColumns
|
|
27
|
-
|
|
26
|
+
triggerChangeColumns,
|
|
27
|
+
t
|
|
28
28
|
} = props;
|
|
29
29
|
|
|
30
30
|
// const dataList: { key: React.Key; title: string }[] = [];
|
|
@@ -216,10 +216,10 @@ const ColumnsChoose = props => {
|
|
|
216
216
|
, {
|
|
217
217
|
onClick: handleAccept
|
|
218
218
|
// disabled={!columns.find((item) => item.visible !== false || item.visible)}
|
|
219
|
-
}, 'OK'), /*#__PURE__*/_react.default.createElement(_antd.Button, {
|
|
219
|
+
}, t ? t('OK') : 'OK'), /*#__PURE__*/_react.default.createElement(_antd.Button, {
|
|
220
220
|
className: 'btn-action btn-action-cancel',
|
|
221
221
|
onClick: handleCancel
|
|
222
|
-
}, 'Cancel'))),
|
|
222
|
+
}, t ? t('Cancel') : 'Cancel'))),
|
|
223
223
|
trigger: "click",
|
|
224
224
|
open: clicked,
|
|
225
225
|
onOpenChange: handleClickChange,
|
|
@@ -66,6 +66,7 @@ const InternalTable = props => {
|
|
|
66
66
|
editAble,
|
|
67
67
|
rowKey,
|
|
68
68
|
onDataChange,
|
|
69
|
+
sortMultiple,
|
|
69
70
|
...rest
|
|
70
71
|
} = props;
|
|
71
72
|
const locale = lang && lang === 'en' ? _en_US.default : _vi_VN.default;
|
|
@@ -123,23 +124,27 @@ const InternalTable = props => {
|
|
|
123
124
|
setSelectedKeys,
|
|
124
125
|
selectedKeys,
|
|
125
126
|
confirm,
|
|
126
|
-
close,
|
|
127
|
+
// close,
|
|
127
128
|
setOperatorKey,
|
|
128
129
|
operatorKey,
|
|
129
130
|
visible,
|
|
130
131
|
searchValue,
|
|
131
132
|
setSearchValue
|
|
132
133
|
}) => {
|
|
134
|
+
const type = (0, _hooks.getTypeFilter)(column);
|
|
135
|
+
// const operatorOptions = !type || type === 'Text' ? stringOperator : numberOperator
|
|
136
|
+
// const operatorOptions = type === 'Checkbox' || type === 'Dropdown' || type === 'DropTree' || ty
|
|
137
|
+
const operatorOptions = type === ('Checkbox' || 'Dropdown' || 'DropTree' || 'CheckboxDropdown') ? _hooks.booleanOperator : !type || type === 'Text' ? _hooks.stringOperator : _hooks.numberOperator;
|
|
133
138
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
134
139
|
style: {
|
|
135
140
|
padding: 8,
|
|
136
141
|
minWidth: 275
|
|
137
142
|
},
|
|
138
143
|
onKeyDown: e => e.stopPropagation()
|
|
139
|
-
},
|
|
144
|
+
}, column?.showOperator !== false && column?.typeFilter !== 'DateRange' && column?.typeFilter !== 'NumberRange' && /*#__PURE__*/_react.default.createElement("div", {
|
|
140
145
|
className: 'mb-1'
|
|
141
146
|
}, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Select, {
|
|
142
|
-
options: (0, _hooks.translateOption)(
|
|
147
|
+
options: (0, _hooks.translateOption)(operatorOptions, t),
|
|
143
148
|
style: {
|
|
144
149
|
width: '100%',
|
|
145
150
|
marginBottom: 8
|
|
@@ -170,13 +175,17 @@ const InternalTable = props => {
|
|
|
170
175
|
style: {
|
|
171
176
|
width: 90
|
|
172
177
|
}
|
|
173
|
-
},
|
|
178
|
+
}, t ? t('Filter') : 'Filter'), /*#__PURE__*/_react.default.createElement(_antd.Button, {
|
|
174
179
|
type: "link",
|
|
175
180
|
size: "small",
|
|
176
181
|
onClick: () => {
|
|
177
|
-
|
|
182
|
+
// setSearchValue('')
|
|
183
|
+
setSelectedKeys([]);
|
|
184
|
+
confirm();
|
|
185
|
+
// handleSearch()
|
|
186
|
+
// close()
|
|
178
187
|
}
|
|
179
|
-
}, "
|
|
188
|
+
}, t ? t("Clear") : 'Clear')));
|
|
180
189
|
},
|
|
181
190
|
filterIcon: filtered => /*#__PURE__*/_react.default.createElement(_becoxyIcons.FilterFill, {
|
|
182
191
|
fontSize: 12,
|
|
@@ -194,7 +203,7 @@ const InternalTable = props => {
|
|
|
194
203
|
}
|
|
195
204
|
}
|
|
196
205
|
}
|
|
197
|
-
}), [onFilterCallback, onFilterClick,
|
|
206
|
+
}), [buddhistLocale, dataSourceFilter, onFilterCallback, onFilterClick, t]);
|
|
198
207
|
const handleResize = indexPath => (e, {
|
|
199
208
|
size
|
|
200
209
|
}) => {
|
|
@@ -245,6 +254,7 @@ const InternalTable = props => {
|
|
|
245
254
|
const transformedColumn = {
|
|
246
255
|
...col,
|
|
247
256
|
dataIndex: col.field ?? col.dataIndex,
|
|
257
|
+
key: col.field ?? col.dataIndex ?? col.key,
|
|
248
258
|
title: t ? t(col.headerText ?? col.title) : col.headerText ?? col.title,
|
|
249
259
|
ellipsis: col.ellipsis !== false,
|
|
250
260
|
align: col.textAlign ?? col.align,
|
|
@@ -256,7 +266,7 @@ const InternalTable = props => {
|
|
|
256
266
|
children: transformColumns(col.children, currentPath)
|
|
257
267
|
};
|
|
258
268
|
}
|
|
259
|
-
if (col.dataIndex === 'index' || col.field === 'index' || col.dataIndex === '#' || col.
|
|
269
|
+
if (col.dataIndex === 'index' || col.field === 'index' || col.dataIndex === '#' || col.field === '#' || col.allowFiltering === false || col.field === 'command') {
|
|
260
270
|
return {
|
|
261
271
|
...transformedColumn
|
|
262
272
|
};
|
|
@@ -264,15 +274,12 @@ const InternalTable = props => {
|
|
|
264
274
|
return {
|
|
265
275
|
...getColumnSearchProps(col),
|
|
266
276
|
...transformedColumn,
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
onFilter: (value, record) => {
|
|
274
|
-
// @ts-ignore
|
|
275
|
-
return record[col.field ?? col.dataIndex];
|
|
277
|
+
onFilter: value => {
|
|
278
|
+
return value;
|
|
279
|
+
},
|
|
280
|
+
sorter: {
|
|
281
|
+
compare: a => a,
|
|
282
|
+
multiple: sortMultiple ? index : undefined
|
|
276
283
|
},
|
|
277
284
|
onHeaderCell: () => ({
|
|
278
285
|
width: col.width,
|
|
@@ -280,7 +287,7 @@ const InternalTable = props => {
|
|
|
280
287
|
})
|
|
281
288
|
};
|
|
282
289
|
});
|
|
283
|
-
}, [getColumnSearchProps]);
|
|
290
|
+
}, [getColumnSearchProps, sortMultiple, t]);
|
|
284
291
|
const mergedColumns = _react.default.useMemo(() => {
|
|
285
292
|
return transformColumns(columns);
|
|
286
293
|
}, [transformColumns, columns]);
|
|
@@ -295,6 +302,7 @@ const InternalTable = props => {
|
|
|
295
302
|
};
|
|
296
303
|
const TableComponent = editAble ? _GridEdit.default : _Grid.default;
|
|
297
304
|
return /*#__PURE__*/_react.default.createElement(TableComponent, (0, _extends2.default)({}, rest, {
|
|
305
|
+
t: t,
|
|
298
306
|
tableRef: tableRef,
|
|
299
307
|
dataSource: data,
|
|
300
308
|
components: {
|
|
@@ -6,6 +6,7 @@ type GridProps<T> = GridTableProps<T> & {
|
|
|
6
6
|
triggerChangeColumns?: () => void;
|
|
7
7
|
triggerChangeData?: () => void;
|
|
8
8
|
tableRef: any;
|
|
9
|
+
getRowKey: any;
|
|
9
10
|
};
|
|
10
11
|
declare const TableGrid: <RecordType extends object>(props: GridProps<RecordType>) => React.JSX.Element;
|
|
11
12
|
export default TableGrid;
|
|
@@ -115,13 +115,16 @@ const TableGrid = props => {
|
|
|
115
115
|
selectionSettings,
|
|
116
116
|
rowSelection,
|
|
117
117
|
rowSelected,
|
|
118
|
-
rowKey
|
|
118
|
+
rowKey,
|
|
119
119
|
pagination,
|
|
120
120
|
scroll,
|
|
121
121
|
onFilterClick,
|
|
122
122
|
dataSourceFilter: propDataSourceFilter,
|
|
123
123
|
loading,
|
|
124
124
|
triggerChangeColumns,
|
|
125
|
+
summary,
|
|
126
|
+
getRowKey,
|
|
127
|
+
onSorter,
|
|
125
128
|
...rest
|
|
126
129
|
} = props;
|
|
127
130
|
const {
|
|
@@ -140,12 +143,6 @@ const TableGrid = props => {
|
|
|
140
143
|
const menuRef = (0, _react.useRef)(null);
|
|
141
144
|
const viewportWidth = window.innerWidth;
|
|
142
145
|
const viewportHeight = window.innerHeight;
|
|
143
|
-
|
|
144
|
-
// const defaultSelected = useMemo(() => {
|
|
145
|
-
// return defaultSelectedRowKeys ?? []
|
|
146
|
-
//
|
|
147
|
-
// }, [defaultSelectedRowKeys])
|
|
148
|
-
|
|
149
146
|
const [menuVisible, setMenuVisible] = _react.default.useState(false);
|
|
150
147
|
const [selectedRowData, setSelectedRowData] = _react.default.useState(null);
|
|
151
148
|
const [position, setPosition] = _react.default.useState({
|
|
@@ -165,6 +162,8 @@ const TableGrid = props => {
|
|
|
165
162
|
// },
|
|
166
163
|
// );
|
|
167
164
|
|
|
165
|
+
// console.log('mergedSelectedKeys', mergedSelectedKeys)
|
|
166
|
+
|
|
168
167
|
// Reset if rowSelection reset
|
|
169
168
|
|
|
170
169
|
// React.useEffect(() => {
|
|
@@ -241,11 +240,10 @@ const TableGrid = props => {
|
|
|
241
240
|
}
|
|
242
241
|
};
|
|
243
242
|
const handleRowClick = () => () => {
|
|
244
|
-
// console.log(data)
|
|
245
|
-
// console.log(index)
|
|
246
|
-
|
|
247
243
|
// const key = getRowKey(record, index);
|
|
248
244
|
|
|
245
|
+
// const keySet = new Set(derivedSelectedKeySet);
|
|
246
|
+
|
|
249
247
|
// console.log('key', key)
|
|
250
248
|
|
|
251
249
|
if (checkboxOnly !== true) {
|
|
@@ -299,7 +297,7 @@ const TableGrid = props => {
|
|
|
299
297
|
}
|
|
300
298
|
};
|
|
301
299
|
const handleChange = sorter => {
|
|
302
|
-
|
|
300
|
+
onSorter?.(sorter);
|
|
303
301
|
// setFilteredInfo(filters);
|
|
304
302
|
// setSortedInfo(sorter as Sorts);
|
|
305
303
|
};
|
|
@@ -364,29 +362,37 @@ const TableGrid = props => {
|
|
|
364
362
|
onScroll: () => {
|
|
365
363
|
setMenuVisible(false);
|
|
366
364
|
},
|
|
367
|
-
summary: () =>
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
thousandSeparator
|
|
378
|
-
decimalSeparator
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
365
|
+
summary: () => {
|
|
366
|
+
if (typeof summary === 'function') {
|
|
367
|
+
return summary(dataSource);
|
|
368
|
+
}
|
|
369
|
+
if (!summary) {
|
|
370
|
+
return undefined;
|
|
371
|
+
}
|
|
372
|
+
return /*#__PURE__*/_react.default.createElement(_rcMasterUi.Table.Summary, {
|
|
373
|
+
fixed: true
|
|
374
|
+
}, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Table.Summary.Row, null, (0, _useColumns.flatColumns)(columns).filter(col => col.hidden !== true).map((col, index) => {
|
|
375
|
+
const thousandSeparator = col.format?.thousandSeparator ? col.format?.thousandSeparator : format?.thousandSeparator;
|
|
376
|
+
const decimalSeparator = col.format?.decimalSeparator ? col.format?.decimalSeparator : format?.decimalSeparator;
|
|
377
|
+
const dec = col.format?.decimalScale || col.format?.decimalScale === 0 ? col.format?.decimalScale : format?.decimalScale;
|
|
378
|
+
const sumValue = col.type === 'number' ? (0, _hooks.sumDataByField)(dataSource, col?.key) : 0;
|
|
379
|
+
const value = !(0, _hooks.isEmpty)(sumValue) ? dec || dec === 0 ? parseFloat(Number(sumValue).toFixed(dec)).toString() : sumValue.toString() : '0';
|
|
380
|
+
const cellValue = col.type === 'number' && col.isSummary !== false ? value : '';
|
|
381
|
+
const numericFormatProps = {
|
|
382
|
+
thousandSeparator: (0, _hooks.checkThousandSeparator)(thousandSeparator, decimalSeparator),
|
|
383
|
+
decimalSeparator: (0, _hooks.checkDecimalSeparator)(thousandSeparator, decimalSeparator),
|
|
384
|
+
allowNegative: (col.format?.allowNegative ? col.format?.allowNegative : format?.allowNegative) ?? false,
|
|
385
|
+
prefix: col.format?.prefix ? col.format?.prefix : format?.prefix,
|
|
386
|
+
suffix: col.format?.suffix ? col.format?.suffix : format?.suffix,
|
|
387
|
+
decimalScale: dec,
|
|
388
|
+
fixedDecimalScale: (col.format?.fixedDecimalScale ? col.format?.fixedDecimalScale : format?.fixedDecimalScale) ?? false
|
|
389
|
+
};
|
|
390
|
+
return /*#__PURE__*/_react.default.createElement(_rcMasterUi.Table.Summary.Cell, {
|
|
391
|
+
key: col.key,
|
|
392
|
+
index: index
|
|
393
|
+
}, col.summaryTemplate ? col.summaryTemplate(cellValue, col.key) : (0, _reactNumericComponent.numericFormatter)(cellValue, numericFormatProps));
|
|
394
|
+
})));
|
|
395
|
+
},
|
|
390
396
|
pagination: pagination && pagination.onChange ? false : {
|
|
391
397
|
showTotal: (total, range) => `${range[0]}-${range[1]} / ${total} items`,
|
|
392
398
|
...pagination
|
|
@@ -408,12 +414,12 @@ const TableGrid = props => {
|
|
|
408
414
|
items: toolbarItems ?? [],
|
|
409
415
|
mode: 'responsive'
|
|
410
416
|
// mode={'scroll'}
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
}
|
|
417
|
+
// onClick={(val: any) => {
|
|
418
|
+
// console.log(val)
|
|
419
|
+
// }}
|
|
415
420
|
}), showColumnChoose && /*#__PURE__*/_react.default.createElement(_ColumnsChoose.ColumnsChoose, {
|
|
416
421
|
columns: columns,
|
|
422
|
+
t: t,
|
|
417
423
|
triggerChangeColumns: triggerChangeColumns
|
|
418
424
|
}), /*#__PURE__*/_react.default.createElement("div", null)));
|
|
419
425
|
}
|
|
@@ -422,8 +428,10 @@ const TableGrid = props => {
|
|
|
422
428
|
, (0, _extends2.default)({
|
|
423
429
|
showSizeChanger: true,
|
|
424
430
|
responsive: true,
|
|
425
|
-
size: 'small'
|
|
426
|
-
|
|
431
|
+
size: 'small'
|
|
432
|
+
// @ts-ignore
|
|
433
|
+
,
|
|
434
|
+
showTotal: (total, range) => `${range[0]}-${range[1]} / ${total} ${t ? t(pagination?.locale?.items ?? 'items') : 'items'}`
|
|
427
435
|
}, pagination))));
|
|
428
436
|
};
|
|
429
437
|
var _default = exports.default = TableGrid;
|
|
@@ -16,29 +16,29 @@ const numberOperator = exports.numberOperator = [{
|
|
|
16
16
|
key: '>'
|
|
17
17
|
}, {
|
|
18
18
|
value: 'greaterthanorequal',
|
|
19
|
-
label: 'Greater
|
|
19
|
+
label: 'Greater than or equal',
|
|
20
20
|
key: '>='
|
|
21
21
|
}, {
|
|
22
22
|
value: 'lessthan',
|
|
23
|
-
label: 'Less
|
|
23
|
+
label: 'Less than',
|
|
24
24
|
key: '<'
|
|
25
25
|
}, {
|
|
26
26
|
value: 'lessthanorequal',
|
|
27
|
-
label: 'Less
|
|
27
|
+
label: 'Less than or equal',
|
|
28
28
|
key: '<='
|
|
29
29
|
}, {
|
|
30
30
|
value: 'notequal',
|
|
31
|
-
label: 'Not
|
|
31
|
+
label: 'Not equal',
|
|
32
32
|
key: '!='
|
|
33
33
|
}];
|
|
34
34
|
const stringOperator = exports.stringOperator = [{
|
|
35
35
|
value: 'startswith',
|
|
36
36
|
key: '_=',
|
|
37
|
-
label: 'Starts
|
|
37
|
+
label: 'Starts with'
|
|
38
38
|
}, {
|
|
39
39
|
value: 'endswith',
|
|
40
40
|
key: '|=',
|
|
41
|
-
label: 'Ends
|
|
41
|
+
label: 'Ends with'
|
|
42
42
|
}, {
|
|
43
43
|
value: 'contains',
|
|
44
44
|
key: '~=',
|
|
@@ -50,7 +50,7 @@ const stringOperator = exports.stringOperator = [{
|
|
|
50
50
|
}, {
|
|
51
51
|
value: 'notequal',
|
|
52
52
|
key: '!=',
|
|
53
|
-
label: 'Not
|
|
53
|
+
label: 'Not equal'
|
|
54
54
|
}];
|
|
55
55
|
const dateOperator = exports.dateOperator = [{
|
|
56
56
|
value: 'equal',
|
|
@@ -59,15 +59,15 @@ const dateOperator = exports.dateOperator = [{
|
|
|
59
59
|
}, {
|
|
60
60
|
value: 'notequal',
|
|
61
61
|
key: '!=',
|
|
62
|
-
label: 'Not
|
|
62
|
+
label: 'Not equal'
|
|
63
63
|
}, {
|
|
64
64
|
value: 'greaterthan',
|
|
65
65
|
key: '>',
|
|
66
|
-
label: 'Greater
|
|
66
|
+
label: 'Greater than'
|
|
67
67
|
}, {
|
|
68
68
|
value: 'lessthan',
|
|
69
69
|
key: '<',
|
|
70
|
-
label: 'Less
|
|
70
|
+
label: 'Less than'
|
|
71
71
|
}];
|
|
72
72
|
const dateTimeOperator = exports.dateTimeOperator = [{
|
|
73
73
|
value: 'equal',
|
|
@@ -76,15 +76,15 @@ const dateTimeOperator = exports.dateTimeOperator = [{
|
|
|
76
76
|
}, {
|
|
77
77
|
value: 'notequal',
|
|
78
78
|
key: '!=',
|
|
79
|
-
label: 'Not
|
|
79
|
+
label: 'Not equal'
|
|
80
80
|
}, {
|
|
81
81
|
value: 'greaterthan',
|
|
82
82
|
key: '>',
|
|
83
|
-
label: 'Greater
|
|
83
|
+
label: 'Greater than'
|
|
84
84
|
}, {
|
|
85
85
|
value: 'lessthan',
|
|
86
86
|
key: '<',
|
|
87
|
-
label: 'Less
|
|
87
|
+
label: 'Less than'
|
|
88
88
|
}];
|
|
89
89
|
const booleanOperator = exports.booleanOperator = [{
|
|
90
90
|
value: 'equal',
|
|
@@ -93,7 +93,7 @@ const booleanOperator = exports.booleanOperator = [{
|
|
|
93
93
|
}, {
|
|
94
94
|
value: 'notequal',
|
|
95
95
|
key: '!=',
|
|
96
|
-
label: 'Not
|
|
96
|
+
label: 'Not equal'
|
|
97
97
|
}];
|
|
98
98
|
const translateOption = (options, t) => {
|
|
99
99
|
if (!t) {
|
|
@@ -108,8 +108,8 @@ exports.renderContent = renderContent;
|
|
|
108
108
|
const renderFilter = (column, selectedKeys, setSelectedKeys, confirm, visible, searchValue, setSearchValue, dataSourceFilter, buddhistLocale) => {
|
|
109
109
|
const type = (0, _utils.getTypeFilter)(column);
|
|
110
110
|
const dateFormat = (0, _utils.getDatepickerFormat)(column?.typeFilter ?? column?.type, column) ?? 'DD/MM/YYYY';
|
|
111
|
-
const dateRangeFormat =
|
|
112
|
-
const find = dataSourceFilter?.find(it => it.key === column?.
|
|
111
|
+
const dateRangeFormat = 'DD/MM/YYYY';
|
|
112
|
+
const find = dataSourceFilter?.find(it => it.key === (column?.field || column.dataIndex));
|
|
113
113
|
const options = find ? find.data : [];
|
|
114
114
|
switch (type) {
|
|
115
115
|
case 'Number':
|
|
@@ -194,7 +194,8 @@ const renderFilter = (column, selectedKeys, setSelectedKeys, confirm, visible, s
|
|
|
194
194
|
format: {
|
|
195
195
|
format: dateRangeFormat,
|
|
196
196
|
type: 'mask'
|
|
197
|
-
}
|
|
197
|
+
},
|
|
198
|
+
locale: buddhistLocale
|
|
198
199
|
// defaultValue={dateRangeValue}
|
|
199
200
|
,
|
|
200
201
|
value: dateRangeValue,
|
|
@@ -413,9 +414,12 @@ const renderFilter = (column, selectedKeys, setSelectedKeys, confirm, visible, s
|
|
|
413
414
|
filterTitle: 'Chọn tất cả',
|
|
414
415
|
filterCheckall: 'Chọn tất cả'
|
|
415
416
|
},
|
|
417
|
+
showFilter: column.showFilterSearch,
|
|
416
418
|
selectedKeys: selectedKeys,
|
|
417
419
|
onSelect: setSelectedKeys,
|
|
418
|
-
options: options
|
|
420
|
+
options: options
|
|
421
|
+
// options={[]}
|
|
422
|
+
,
|
|
419
423
|
filterMultiple: true,
|
|
420
424
|
open: visible,
|
|
421
425
|
searchValue: searchValue,
|
|
@@ -83,6 +83,16 @@ $rowSelectedHoverBg: 'ui-rc' !default;
|
|
|
83
83
|
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
|
+
.ui-rc-table-placeholder {
|
|
87
|
+
.ui-rc-table-cell {
|
|
88
|
+
padding-top: 0 !important;
|
|
89
|
+
padding-bottom: 0 !important;
|
|
90
|
+
.ui-rc-table-expanded-row-fixed {
|
|
91
|
+
margin-top: 0 !important;
|
|
92
|
+
margin-bottom: 0 !important;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
86
96
|
}
|
|
87
97
|
|
|
88
98
|
.#{$prefix}-table-thead {
|
|
@@ -106,6 +116,7 @@ $rowSelectedHoverBg: 'ui-rc' !default;
|
|
|
106
116
|
.#{$prefix}-table-summary {
|
|
107
117
|
.#{$prefix}-table-cell {
|
|
108
118
|
background-color: #fafafa;
|
|
119
|
+
height: 32px;
|
|
109
120
|
}
|
|
110
121
|
|
|
111
122
|
> tr > td {
|
|
@@ -15,12 +15,14 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
|
|
|
15
15
|
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; }
|
|
16
16
|
const Grid = props => {
|
|
17
17
|
const {
|
|
18
|
+
t,
|
|
18
19
|
columns,
|
|
19
20
|
height,
|
|
20
21
|
tableRef,
|
|
21
22
|
components,
|
|
22
23
|
style,
|
|
23
24
|
format,
|
|
25
|
+
getRowKey,
|
|
24
26
|
...rest
|
|
25
27
|
} = props;
|
|
26
28
|
const transformColumns = _react.default.useCallback(cols => {
|
|
@@ -40,7 +42,7 @@ const Grid = props => {
|
|
|
40
42
|
const transformedColumn = {
|
|
41
43
|
...column,
|
|
42
44
|
dataIndex: column.field ?? column.dataIndex,
|
|
43
|
-
title: column.headerText ?? column.title,
|
|
45
|
+
title: t ? t(column.headerText ?? column.title) : column.headerText ?? column.title,
|
|
44
46
|
ellipsis: column.ellipsis !== false,
|
|
45
47
|
align: column.textAlign ?? column.align,
|
|
46
48
|
fixed: column.frozen ? column.frozen.toLowerCase() : column.fixed
|
|
@@ -72,7 +74,7 @@ const Grid = props => {
|
|
|
72
74
|
render: (value, record, rowIndex) => (0, _useColumns.renderContent)(column, value, record, rowIndex, format)
|
|
73
75
|
};
|
|
74
76
|
});
|
|
75
|
-
}, []);
|
|
77
|
+
}, [format, t]);
|
|
76
78
|
const mergedColumns = (0, _react.useMemo)(() => transformColumns(columns ?? []), [transformColumns, columns]);
|
|
77
79
|
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_GridStyle.GridStyle, {
|
|
78
80
|
heightTable: height,
|
|
@@ -80,6 +82,7 @@ const Grid = props => {
|
|
|
80
82
|
position: 'relative'
|
|
81
83
|
}
|
|
82
84
|
}, /*#__PURE__*/_react.default.createElement(_TableGrid.default, (0, _extends2.default)({}, rest, {
|
|
85
|
+
t: t,
|
|
83
86
|
tableRef: tableRef,
|
|
84
87
|
components: {
|
|
85
88
|
...components
|
|
@@ -88,7 +91,8 @@ const Grid = props => {
|
|
|
88
91
|
style: {
|
|
89
92
|
...style,
|
|
90
93
|
minHeight: height
|
|
91
|
-
}
|
|
94
|
+
},
|
|
95
|
+
getRowKey: getRowKey
|
|
92
96
|
}))));
|
|
93
97
|
};
|
|
94
98
|
var _default = exports.default = Grid;
|
|
@@ -792,7 +792,8 @@ const GridEdit = props => {
|
|
|
792
792
|
...style,
|
|
793
793
|
minHeight: height
|
|
794
794
|
},
|
|
795
|
-
rowHoverable: false
|
|
795
|
+
rowHoverable: false,
|
|
796
|
+
getRowKey: getRowKey
|
|
796
797
|
}))))), /*#__PURE__*/_react.default.createElement(_reactHotToast.Toaster, {
|
|
797
798
|
position: toast,
|
|
798
799
|
toastOptions: {
|
|
@@ -91,6 +91,7 @@ export type ColumnType<RecordType> = Omit<RcColumnType<RecordType>, 'headerTempl
|
|
|
91
91
|
placeholder?: string;
|
|
92
92
|
showInColumnChoose?: boolean;
|
|
93
93
|
typeFilter?: TypeFilter;
|
|
94
|
+
showFilterSearch?: boolean;
|
|
94
95
|
headerText?: string;
|
|
95
96
|
textAlign?: ITextAlign;
|
|
96
97
|
frozen?: Frozen;
|
|
@@ -118,8 +119,9 @@ export type ColumnsType<RecordType = AnyObject> = ColumnType<RecordType>[];
|
|
|
118
119
|
export type ColumnsEditType<RecordType = AnyObject> = ColumnEditType<RecordType>[];
|
|
119
120
|
export type ColumnTable<RecordType = AnyObject> = ColumnEditType<RecordType> | ColumnType<RecordType>;
|
|
120
121
|
export type ColumnsTable<RecordType = AnyObject> = (ColumnType<RecordType> | ColumnEditType<RecordType>)[];
|
|
121
|
-
export interface TableProps<RecordType> extends Omit<RcTableProps<RecordType>, 'columns' | 'rowSelection' | 'loading' | 'dataSource'> {
|
|
122
|
+
export interface TableProps<RecordType> extends Omit<RcTableProps<RecordType>, 'columns' | 'rowSelection' | 'loading' | 'dataSource' | 'summary'> {
|
|
122
123
|
editAble?: boolean;
|
|
124
|
+
sortMultiple?: boolean;
|
|
123
125
|
dataSource: RecordType[];
|
|
124
126
|
columns: ColumnsTable<RecordType>;
|
|
125
127
|
height?: number;
|
|
@@ -159,6 +161,7 @@ export interface TableProps<RecordType> extends Omit<RcTableProps<RecordType>, '
|
|
|
159
161
|
loading?: boolean;
|
|
160
162
|
allowResizing?: boolean;
|
|
161
163
|
onDataChange?: (data: RecordType[]) => void;
|
|
164
|
+
summary?: boolean | ((data: readonly RecordType[]) => React.ReactNode);
|
|
162
165
|
}
|
|
163
166
|
export interface TableEditProps<RecordType = AnyObject> extends Omit<TableProps<RecordType>, 'columns'> {
|
|
164
167
|
columns: ColumnsTable<RecordType>;
|
|
@@ -173,7 +176,7 @@ export interface CommandItem {
|
|
|
173
176
|
title: string;
|
|
174
177
|
color?: 'blue' | 'purple' | 'cyan' | 'green' | 'magenta' | 'pink' | 'red' | 'orange' | 'yellow' | 'volcano' | 'geekblue' | 'lime' | 'gold';
|
|
175
178
|
tooltip?: string;
|
|
176
|
-
icon?:
|
|
179
|
+
icon?: any;
|
|
177
180
|
template?: ReactNode | ReactElement | (() => ReactNode | ReactElement);
|
|
178
181
|
client?: boolean;
|
|
179
182
|
confirmDialog?: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "es-grid-template",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3-0",
|
|
4
4
|
"description": "es-grid-template",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"rc-checkbox": "^3.5.0",
|
|
60
60
|
"rc-dropdown": "^4.2.1",
|
|
61
61
|
"rc-field-form": "^2.6.0",
|
|
62
|
-
"rc-master-ui": "^1.1.
|
|
62
|
+
"rc-master-ui": "^1.1.10-0",
|
|
63
63
|
"rc-select": "^14.16.3",
|
|
64
64
|
"rc-tooltip": "^6.3.0",
|
|
65
65
|
"rc-tree": "^5.10.1",
|