es-grid-template 1.5.16 → 1.6.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/CheckboxFilter2.js +0 -4
- package/es/grid-component/ColumnsChoose.js +9 -4
- package/es/grid-component/ColumnsGroup/ColumnsGroup.js +11 -4
- package/es/grid-component/EditableCell.js +26 -9
- package/es/grid-component/InternalTable.js +82 -28
- package/es/grid-component/TableGrid.js +42 -108
- package/es/grid-component/hooks/columns/index.d.ts +3 -2
- package/es/grid-component/hooks/columns/index.js +84 -8
- package/es/grid-component/hooks/content/ControlCheckbox.d.ts +13 -0
- package/es/grid-component/hooks/content/ControlCheckbox.js +87 -0
- package/es/grid-component/hooks/content/HeaderContent.d.ts +1 -1
- package/es/grid-component/hooks/content/HeaderContent.js +9 -4
- package/es/grid-component/hooks/useColumns.d.ts +3 -1
- package/es/grid-component/hooks/useColumns.js +5 -5
- package/es/grid-component/hooks/utils.d.ts +28 -3
- package/es/grid-component/hooks/utils.js +544 -12
- package/es/grid-component/styles.scss +50 -1
- package/es/grid-component/table/Grid.d.ts +4 -1
- package/es/grid-component/table/GridEdit.d.ts +4 -1
- package/es/grid-component/table/GridEdit.js +353 -336
- package/es/grid-component/table/Group.d.ts +4 -1
- package/es/grid-component/table/InfiniteTable.d.ts +4 -1
- package/es/grid-component/table/InfiniteTable.js +4 -2
- package/es/grid-component/type.d.ts +3 -0
- package/es/index.d.ts +2 -0
- package/es/index.js +1 -0
- package/es/select/index.d.ts +1 -1
- package/lib/grid-component/CheckboxFilter2.js +0 -4
- package/lib/grid-component/ColumnsChoose.js +9 -4
- package/lib/grid-component/ColumnsGroup/ColumnsGroup.js +11 -4
- package/lib/grid-component/EditableCell.js +26 -9
- package/lib/grid-component/InternalTable.js +81 -27
- package/lib/grid-component/TableGrid.js +40 -106
- package/lib/grid-component/hooks/columns/index.d.ts +3 -2
- package/lib/grid-component/hooks/columns/index.js +86 -9
- package/lib/grid-component/hooks/content/ControlCheckbox.d.ts +13 -0
- package/lib/grid-component/hooks/content/ControlCheckbox.js +95 -0
- package/lib/grid-component/hooks/content/HeaderContent.d.ts +1 -1
- package/lib/grid-component/hooks/content/HeaderContent.js +9 -4
- package/lib/grid-component/hooks/useColumns.js +5 -5
- package/lib/grid-component/hooks/utils.d.ts +28 -3
- package/lib/grid-component/hooks/utils.js +565 -19
- package/lib/grid-component/styles.scss +50 -1
- package/lib/grid-component/table/Grid.d.ts +4 -1
- package/lib/grid-component/table/GridEdit.d.ts +4 -1
- package/lib/grid-component/table/GridEdit.js +343 -334
- package/lib/grid-component/table/Group.d.ts +4 -1
- package/lib/grid-component/table/InfiniteTable.d.ts +4 -1
- package/lib/grid-component/table/InfiniteTable.js +4 -2
- package/lib/grid-component/type.d.ts +3 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +7 -0
- package/lib/select/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -79,7 +79,6 @@ const CheckboxFilter = props => {
|
|
|
79
79
|
|
|
80
80
|
// const [searchValue, setSearchValue] = React.useState('');
|
|
81
81
|
|
|
82
|
-
console.log('options', options);
|
|
83
82
|
const [openKeys, setOpenKeys] = React.useState([]);
|
|
84
83
|
|
|
85
84
|
// clear search value after close filter dropdown
|
|
@@ -172,9 +171,6 @@ const CheckboxFilter = props => {
|
|
|
172
171
|
onSelect?.(keys);
|
|
173
172
|
}
|
|
174
173
|
};
|
|
175
|
-
console.log('getTreeData({ filters: options })', getTreeData({
|
|
176
|
-
filters: options
|
|
177
|
-
}));
|
|
178
174
|
if (filterMode === 'tree') {
|
|
179
175
|
return /*#__PURE__*/React.createElement(React.Fragment, null, showFilter && /*#__PURE__*/React.createElement(FilterSearch, {
|
|
180
176
|
filterSearch: filterSearch,
|
|
@@ -378,7 +378,7 @@ export const ColumnsChoose = props => {
|
|
|
378
378
|
const defaultSelectedKeys = useMemo(() => {
|
|
379
379
|
const defaultColumns = propsColumns.filter(it => (it.key || it.dataIndex) && it.showInColumnChoose !== false && !columnsGroup?.includes(it.field));
|
|
380
380
|
return getVisibleColumnKeys(defaultColumns);
|
|
381
|
-
}, [propsColumns]);
|
|
381
|
+
}, [columnsGroup, propsColumns]);
|
|
382
382
|
const [clicked, setClicked] = useState(false);
|
|
383
383
|
const [autoExpandParent, setAutoExpandParent] = useState(true);
|
|
384
384
|
|
|
@@ -473,7 +473,8 @@ export const ColumnsChoose = props => {
|
|
|
473
473
|
placement: 'bottomLeft',
|
|
474
474
|
content: /*#__PURE__*/React.createElement("div", {
|
|
475
475
|
style: {
|
|
476
|
-
minWidth: 250
|
|
476
|
+
minWidth: 250,
|
|
477
|
+
maxWidth: 320
|
|
477
478
|
}
|
|
478
479
|
}, /*#__PURE__*/React.createElement(Input, {
|
|
479
480
|
style: {
|
|
@@ -518,8 +519,12 @@ export const ColumnsChoose = props => {
|
|
|
518
519
|
defaultCheckedKeys: selectedKeys
|
|
519
520
|
// defaultCheckedKeys={defaultSelectedKeys}
|
|
520
521
|
,
|
|
521
|
-
selectedKeys: []
|
|
522
|
-
|
|
522
|
+
selectedKeys: []
|
|
523
|
+
|
|
524
|
+
// height={window.innerHeight - 200}
|
|
525
|
+
,
|
|
526
|
+
height: window.innerHeight / 2 > 450 ? 450 : window.innerHeight / 2 - 110
|
|
527
|
+
// style={{height: 300}}
|
|
523
528
|
}), /*#__PURE__*/React.createElement(BoxAction, {
|
|
524
529
|
className: 'px-1'
|
|
525
530
|
}, /*#__PURE__*/React.createElement(Button
|
|
@@ -10,6 +10,7 @@ import { Button, Popover, Tooltip } from "antd";
|
|
|
10
10
|
// import {SettingOutlined} from "@ant-design/icons";
|
|
11
11
|
import { Select } from "rc-master-ui";
|
|
12
12
|
import styled from "styled-components";
|
|
13
|
+
import { customFilterOption } from "../hooks";
|
|
13
14
|
const BoxAction = styled.div.withConfig({
|
|
14
15
|
displayName: "BoxAction",
|
|
15
16
|
componentId: "es-grid-template__sc-1uj3tyy-0"
|
|
@@ -119,7 +120,8 @@ export const ColumnsGroup = props => {
|
|
|
119
120
|
}, "M\u1EE9c 1"), /*#__PURE__*/React.createElement(Select, {
|
|
120
121
|
style: {
|
|
121
122
|
width: '100%'
|
|
122
|
-
}
|
|
123
|
+
},
|
|
124
|
+
showSearch: true
|
|
123
125
|
// labelInValue={true}
|
|
124
126
|
// options={columns.filter((it: any) => !tempGroup.includes(it.field))}
|
|
125
127
|
// options={columns && columns.length > 0 ? options : []}
|
|
@@ -136,7 +138,8 @@ export const ColumnsGroup = props => {
|
|
|
136
138
|
labelRender: labelProps => {
|
|
137
139
|
const it = columns.find(col => col.field === labelProps.value);
|
|
138
140
|
return t ? t(it?.columnGroupText ?? it?.headerText) : it?.columnGroupText ?? it?.headerText;
|
|
139
|
-
}
|
|
141
|
+
},
|
|
142
|
+
filterOption: customFilterOption
|
|
140
143
|
// hideSelectedOptions
|
|
141
144
|
})), /*#__PURE__*/React.createElement("div", {
|
|
142
145
|
className: 'mb-1',
|
|
@@ -149,6 +152,7 @@ export const ColumnsGroup = props => {
|
|
|
149
152
|
margin: 0
|
|
150
153
|
}
|
|
151
154
|
}, "M\u1EE9c 2"), /*#__PURE__*/React.createElement(Select, {
|
|
155
|
+
showSearch: true,
|
|
152
156
|
style: {
|
|
153
157
|
width: '100%'
|
|
154
158
|
},
|
|
@@ -165,7 +169,8 @@ export const ColumnsGroup = props => {
|
|
|
165
169
|
labelRender: labelProps => {
|
|
166
170
|
const it = columns.find(col => col.field === labelProps.value);
|
|
167
171
|
return t ? t(it?.columnGroupText ?? it?.headerText) : it?.columnGroupText ?? it?.headerText;
|
|
168
|
-
}
|
|
172
|
+
},
|
|
173
|
+
filterOption: customFilterOption
|
|
169
174
|
})), /*#__PURE__*/React.createElement("div", {
|
|
170
175
|
className: 'mb-1',
|
|
171
176
|
style: {
|
|
@@ -181,6 +186,7 @@ export const ColumnsGroup = props => {
|
|
|
181
186
|
width: '100%'
|
|
182
187
|
},
|
|
183
188
|
options: options,
|
|
189
|
+
showSearch: true,
|
|
184
190
|
value: tempGroup?.[2],
|
|
185
191
|
onChange: val => onChangeGroupColumns(val, 2),
|
|
186
192
|
allowClear: !!tempGroup?.[2] && !(unClearableLevel && unClearableLevel - 3 >= 0)
|
|
@@ -192,7 +198,8 @@ export const ColumnsGroup = props => {
|
|
|
192
198
|
labelRender: labelProps => {
|
|
193
199
|
const it = columns.find(col => col.field === labelProps.value);
|
|
194
200
|
return t ? t(it?.columnGroupText ?? it?.headerText) : it?.columnGroupText ?? it?.headerText;
|
|
195
|
-
}
|
|
201
|
+
},
|
|
202
|
+
filterOption: customFilterOption
|
|
196
203
|
}))), /*#__PURE__*/React.createElement(BoxAction, {
|
|
197
204
|
className: 'px-1'
|
|
198
205
|
}, /*#__PURE__*/React.createElement(Button
|
|
@@ -28,6 +28,9 @@ import { cyan, green, red, blue } from '@ant-design/colors';
|
|
|
28
28
|
const {
|
|
29
29
|
SHOW_PARENT
|
|
30
30
|
} = TreeSelect;
|
|
31
|
+
const {
|
|
32
|
+
TextArea
|
|
33
|
+
} = Input;
|
|
31
34
|
const filterTreeNode = (input, treeNode) => {
|
|
32
35
|
const {
|
|
33
36
|
title,
|
|
@@ -114,8 +117,13 @@ const EditableCell = props => {
|
|
|
114
117
|
style: {
|
|
115
118
|
width: '100%',
|
|
116
119
|
height: '100%'
|
|
117
|
-
}
|
|
118
|
-
value
|
|
120
|
+
}
|
|
121
|
+
// value={date}
|
|
122
|
+
,
|
|
123
|
+
defaultValue: date
|
|
124
|
+
// preserveInvalidOnBlur
|
|
125
|
+
,
|
|
126
|
+
|
|
119
127
|
onBlur: () => {
|
|
120
128
|
const formState = getValues();
|
|
121
129
|
const itemState = getValues(dataIndex);
|
|
@@ -178,8 +186,10 @@ const EditableCell = props => {
|
|
|
178
186
|
width: '100%',
|
|
179
187
|
height: '100%'
|
|
180
188
|
},
|
|
181
|
-
showTime: true
|
|
182
|
-
value
|
|
189
|
+
showTime: true
|
|
190
|
+
// value={date}
|
|
191
|
+
,
|
|
192
|
+
defaultValue: date,
|
|
183
193
|
placeholder: t ? t(column.placeholder ?? 'Select') : column.placeholder ?? 'Select',
|
|
184
194
|
disabled: isDisable(column, record) ?? false,
|
|
185
195
|
maxDate: maxDate,
|
|
@@ -708,7 +718,7 @@ const EditableCell = props => {
|
|
|
708
718
|
style: {
|
|
709
719
|
display: 'flex',
|
|
710
720
|
alignItems: 'center',
|
|
711
|
-
justifyContent: column.align ?? '
|
|
721
|
+
justifyContent: column.align ?? 'center',
|
|
712
722
|
paddingInline: 5,
|
|
713
723
|
height: '100%',
|
|
714
724
|
width: '100%'
|
|
@@ -718,7 +728,7 @@ const EditableCell = props => {
|
|
|
718
728
|
// style={{ textAlign: column.align ?? 'left' }}
|
|
719
729
|
,
|
|
720
730
|
onChange: val => {
|
|
721
|
-
const newVal = parseBooleanToValue(val.target.checked, typeof value);
|
|
731
|
+
const newVal = typeof value === "number" ? parseBooleanToValue(val.target.checked, typeof value) : val.target.checked;
|
|
722
732
|
onChange(newVal);
|
|
723
733
|
const key = getRowKey?.(record, index);
|
|
724
734
|
const formState = getValues();
|
|
@@ -929,11 +939,14 @@ const EditableCell = props => {
|
|
|
929
939
|
"data-tooltip-id": `${id}-tooltip-form-error`
|
|
930
940
|
}));
|
|
931
941
|
default:
|
|
932
|
-
return /*#__PURE__*/React.createElement(
|
|
942
|
+
return /*#__PURE__*/React.createElement(TextArea, {
|
|
933
943
|
id: `col${indexCol}-record${indexRow}`,
|
|
934
944
|
style: {
|
|
935
|
-
textAlign: column.align
|
|
945
|
+
textAlign: column.align,
|
|
946
|
+
resize: 'none',
|
|
947
|
+
height: '100%'
|
|
936
948
|
}
|
|
949
|
+
|
|
937
950
|
// @ts-ignore
|
|
938
951
|
// value={!isNullOrUndefined(record[column.dataIndex]) ? record[column.dataIndex] : ''}
|
|
939
952
|
,
|
|
@@ -989,7 +1002,11 @@ const EditableCell = props => {
|
|
|
989
1002
|
onChange: onChange,
|
|
990
1003
|
status: isInvalid ? 'error' : undefined,
|
|
991
1004
|
"data-tooltip-content": message,
|
|
992
|
-
"data-tooltip-id": `${id}-tooltip-form-error
|
|
1005
|
+
"data-tooltip-id": `${id}-tooltip-form-error`,
|
|
1006
|
+
autoSize: {
|
|
1007
|
+
minRows: 1,
|
|
1008
|
+
maxRows: 1
|
|
1009
|
+
}
|
|
993
1010
|
});
|
|
994
1011
|
}
|
|
995
1012
|
};
|
|
@@ -3,7 +3,7 @@ import React, { createContext, Fragment, useCallback, useContext, useState } fro
|
|
|
3
3
|
// import {Resizable} from "react-resizable";
|
|
4
4
|
import 'react-resizable/css/styles.css';
|
|
5
5
|
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
|
6
|
-
import { addRowIdArray, booleanOperator, findItemByKey, findItemPath, getFormat, getTypeFilter, groupArrayByColumns, numberOperator, removeColumns, stringOperator, translateOption, updateArrayByKey, updateColumnsByGroup, updateData } from "./hooks";
|
|
6
|
+
import { addRowIdArray, booleanOperator, convertFilters, convertFlatColumn, filterDataByColumns4, findItemByKey, findItemPath, getAllRowKey, getFormat, getTypeFilter, groupArrayByColumns, numberOperator, removeColumns, removeInvisibleColumns, stringOperator, translateOption, updateArrayByKey, updateColumnsByGroup, updateData } from "./hooks";
|
|
7
7
|
import dayjs from "dayjs";
|
|
8
8
|
import 'dayjs/locale/es';
|
|
9
9
|
import 'dayjs/locale/vi';
|
|
@@ -37,6 +37,7 @@ import { arrayMove, horizontalListSortingStrategy, SortableContext, useSortable
|
|
|
37
37
|
import { Resizable } from "react-resizable";
|
|
38
38
|
import { faker } from "@faker-js/faker";
|
|
39
39
|
import InfiniteTable from "./table/InfiniteTable";
|
|
40
|
+
import useMergedState from "rc-util/es/hooks/useMergedState";
|
|
40
41
|
dayjs.extend(customParseFormat);
|
|
41
42
|
const MySwal = withReactContent(Swal);
|
|
42
43
|
const ASCEND = 'ascend';
|
|
@@ -180,15 +181,19 @@ const InternalTable = props => {
|
|
|
180
181
|
summary,
|
|
181
182
|
infiniteScroll,
|
|
182
183
|
wrapSettings,
|
|
184
|
+
onFilter,
|
|
183
185
|
...rest
|
|
184
186
|
} = props;
|
|
185
187
|
const id = React.useMemo(() => {
|
|
186
188
|
return tableId ?? faker.string.alpha(20);
|
|
187
189
|
// return tableId ?? newGuid()
|
|
188
190
|
}, [tableId]);
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
191
|
+
|
|
192
|
+
// const rowKey = React.useMemo(() => {
|
|
193
|
+
// return propRowKey ?? 'rowId'
|
|
194
|
+
// }, [propRowKey])
|
|
195
|
+
|
|
196
|
+
const rowKey = 'rowId';
|
|
192
197
|
const [scrollHeight, setHeight] = useState(0);
|
|
193
198
|
const local = lang && lang === 'en' ? en : vi;
|
|
194
199
|
const dateRangeLocale = lang && lang === 'en' ? enDr : viDr;
|
|
@@ -208,14 +213,30 @@ const InternalTable = props => {
|
|
|
208
213
|
over: -1
|
|
209
214
|
});
|
|
210
215
|
const [tooltipContent, setTooltipContent] = useState('');
|
|
211
|
-
const
|
|
212
|
-
|
|
216
|
+
const [filterStates, setFilterState] = React.useState(null);
|
|
217
|
+
// const [filterData, setFilterData] = React.useState<any>(null)
|
|
213
218
|
|
|
219
|
+
const mergedData = React.useMemo(() => {
|
|
214
220
|
if (groupAble && groupSetting && groupSetting.client !== false) {
|
|
215
221
|
return groupArrayByColumns(dataSource, groupColumns);
|
|
216
222
|
}
|
|
217
223
|
return addRowIdArray(dataSource);
|
|
218
224
|
}, [dataSource, groupAble, groupColumns, groupSetting]);
|
|
225
|
+
|
|
226
|
+
// ========================= Keys =========================
|
|
227
|
+
const [mergedFilterKeys, setMergedFilterKeys] = useMergedState(getAllRowKey(mergedData), {
|
|
228
|
+
value: undefined
|
|
229
|
+
});
|
|
230
|
+
//
|
|
231
|
+
// const originData = React.useMemo(() => {
|
|
232
|
+
//
|
|
233
|
+
// if (groupAble && groupSetting && groupSetting.client !== false) {
|
|
234
|
+
// return groupArrayByColumns(dataSource, groupColumns)
|
|
235
|
+
// }
|
|
236
|
+
// return addRowIdArray(dataSource)
|
|
237
|
+
//
|
|
238
|
+
// }, [dataSource, groupAble, groupColumns, groupSetting])
|
|
239
|
+
|
|
219
240
|
const [columns, setColumns] = React.useState([]);
|
|
220
241
|
React.useEffect(() => {
|
|
221
242
|
if (propsHeight) {
|
|
@@ -234,6 +255,20 @@ const InternalTable = props => {
|
|
|
234
255
|
React.useEffect(() => {
|
|
235
256
|
setColumns(propsColumns);
|
|
236
257
|
}, [propsColumns]);
|
|
258
|
+
const handleOnFilter = queries => {
|
|
259
|
+
if (onFilter) {
|
|
260
|
+
onFilter?.(convertFilters(queries));
|
|
261
|
+
} else {
|
|
262
|
+
setFilterState(convertFilters(queries));
|
|
263
|
+
const b = filterDataByColumns4(mergedData, convertFilters(queries), []);
|
|
264
|
+
setMergedFilterKeys(getAllRowKey(b));
|
|
265
|
+
if (queries && queries.length > 0) {
|
|
266
|
+
// setIsFilter?.(true)
|
|
267
|
+
} else {
|
|
268
|
+
// setIsFilter?.(false)
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
};
|
|
237
272
|
const handleResize = column => (e, {
|
|
238
273
|
size
|
|
239
274
|
}) => {
|
|
@@ -405,10 +440,11 @@ const InternalTable = props => {
|
|
|
405
440
|
})
|
|
406
441
|
}),
|
|
407
442
|
render: (val, record) => {
|
|
443
|
+
const tmpData = filterDataByColumns4(mergedData, filterStates, mergedFilterKeys);
|
|
408
444
|
if (pagination && pagination.onChange && pagination.currentPage && pagination.pageSize) {
|
|
409
|
-
return findItemPath(
|
|
445
|
+
return findItemPath(tmpData, record, rowKey, pagination.currentPage, pagination.pageSize);
|
|
410
446
|
}
|
|
411
|
-
return findItemPath(
|
|
447
|
+
return findItemPath(tmpData, record, rowKey);
|
|
412
448
|
}
|
|
413
449
|
};
|
|
414
450
|
}
|
|
@@ -504,28 +540,28 @@ const InternalTable = props => {
|
|
|
504
540
|
render: (value, record, rowIndex) => {
|
|
505
541
|
const colFormat = typeof column.format === 'function' ? column.format(record) : column.format;
|
|
506
542
|
const cellFormat = getFormat(colFormat, format);
|
|
507
|
-
if (groupSetting && groupSetting.hiddenColumnGroup === false) {
|
|
543
|
+
if (groupAble && groupSetting && groupSetting.hiddenColumnGroup === false) {
|
|
508
544
|
if (record.children) {
|
|
509
|
-
return renderContent(column, value, record, rowIndex, cellFormat);
|
|
545
|
+
return renderContent(column, value, record, rowIndex, colIndex, false, cellFormat);
|
|
510
546
|
}
|
|
511
547
|
if (groupColumns?.includes(column.field)) {
|
|
512
548
|
return '';
|
|
513
549
|
}
|
|
514
|
-
return renderContent(column, value, record, rowIndex, cellFormat);
|
|
550
|
+
return renderContent(column, value, record, rowIndex, colIndex, false, cellFormat);
|
|
515
551
|
}
|
|
516
|
-
if (column.field === firstNonGroupColumn?.field && record.children) {
|
|
552
|
+
if (groupAble && column.field === firstNonGroupColumn?.field && record.children) {
|
|
517
553
|
const currentGroupColumn = flatColumns2(columns).find(it => it.field === record.field);
|
|
518
554
|
if (currentGroupColumn?.template) {
|
|
519
|
-
return renderContent(currentGroupColumn, record[record.field], record, rowIndex, cellFormat);
|
|
555
|
+
return renderContent(currentGroupColumn, record[record.field], record, rowIndex, colIndex, false, cellFormat);
|
|
520
556
|
}
|
|
521
|
-
return /*#__PURE__*/React.createElement("span", null, currentGroupColumn?.headerText, ": ", renderContent(currentGroupColumn, record[record.field], record, rowIndex, cellFormat));
|
|
557
|
+
return /*#__PURE__*/React.createElement("span", null, currentGroupColumn?.headerText, ": ", renderContent(currentGroupColumn, record[record.field], record, rowIndex, colIndex, false, cellFormat));
|
|
522
558
|
}
|
|
523
|
-
return renderContent(column, value, record, rowIndex, cellFormat);
|
|
559
|
+
return renderContent(column, value, record, rowIndex, colIndex, false, cellFormat);
|
|
524
560
|
},
|
|
525
561
|
hidden: groupSetting && groupSetting.hiddenColumnGroup === false ? transformedColumn.hidden : groupAble && groupColumns && groupColumns.includes(column.field) ? true : transformedColumn.hidden
|
|
526
562
|
};
|
|
527
563
|
});
|
|
528
|
-
}, [columns, t, getColumnSearchProps, sortMultiple, groupSetting, groupAble, groupColumns,
|
|
564
|
+
}, [columns, t, id, wrapSettings, getColumnSearchProps, sortMultiple, groupSetting, groupAble, groupColumns, mergedData, filterStates, mergedFilterKeys, pagination, handleResize, firstNonGroupColumn?.field, nonGroupColumns, format]);
|
|
529
565
|
const transformColumns = React.useCallback(cols => {
|
|
530
566
|
return cols.map(column => {
|
|
531
567
|
const find = convertColumns.find(it => it.field === column.field);
|
|
@@ -573,7 +609,7 @@ const InternalTable = props => {
|
|
|
573
609
|
};
|
|
574
610
|
}
|
|
575
611
|
});
|
|
576
|
-
}, [convertColumns, t]);
|
|
612
|
+
}, [convertColumns, id, t, wrapSettings]);
|
|
577
613
|
const mergedColumns = React.useMemo(() => {
|
|
578
614
|
return transformColumns(columns);
|
|
579
615
|
}, [columns, transformColumns]);
|
|
@@ -591,9 +627,9 @@ const InternalTable = props => {
|
|
|
591
627
|
});
|
|
592
628
|
}
|
|
593
629
|
onChooseColumns?.({
|
|
594
|
-
showColumns: [],
|
|
595
|
-
columns: [],
|
|
596
|
-
flattenColumns: []
|
|
630
|
+
showColumns: removeInvisibleColumns([...newColumns]),
|
|
631
|
+
columns: [...newColumns],
|
|
632
|
+
flattenColumns: convertFlatColumn([...newColumns])
|
|
597
633
|
});
|
|
598
634
|
};
|
|
599
635
|
const onDragEnd = ({
|
|
@@ -672,7 +708,9 @@ const InternalTable = props => {
|
|
|
672
708
|
rowData,
|
|
673
709
|
index
|
|
674
710
|
} = args;
|
|
675
|
-
|
|
711
|
+
|
|
712
|
+
// const tmpData = [...mergedData]
|
|
713
|
+
const tmpData = filterDataByColumns4(mergedData, filterStates, mergedFilterKeys);
|
|
676
714
|
if (idCommand === 'DELETE') {
|
|
677
715
|
// bật modal confirm
|
|
678
716
|
if (commandSettings && commandSettings.confirmDialog) {
|
|
@@ -698,7 +736,7 @@ const InternalTable = props => {
|
|
|
698
736
|
|
|
699
737
|
let newData = [];
|
|
700
738
|
if (rowData?.parentId) {
|
|
701
|
-
const parent = findItemByKey(
|
|
739
|
+
const parent = findItemByKey(tmpData, rowKey, rowData.parentId);
|
|
702
740
|
const childData = parent?.children ? [...parent.children] : [];
|
|
703
741
|
const findIndex = childData.findIndex(obj => obj[rowKey] === rowData[rowKey]);
|
|
704
742
|
childData.splice(Number(findIndex), 1);
|
|
@@ -785,7 +823,7 @@ const InternalTable = props => {
|
|
|
785
823
|
}
|
|
786
824
|
}
|
|
787
825
|
};
|
|
788
|
-
const triggerPaste = (pastedRows, pastedColumnsArray, newData) => {
|
|
826
|
+
const triggerPaste = (pastedRows, pastedColumnsArray, newData, copyRows) => {
|
|
789
827
|
const handlePasteCallback = callbackData => {
|
|
790
828
|
const newDataUpdate = updateData(mergedData, callbackData, rowKey);
|
|
791
829
|
triggerChangeData(newDataUpdate);
|
|
@@ -797,6 +835,7 @@ const InternalTable = props => {
|
|
|
797
835
|
// có callback
|
|
798
836
|
onCellPaste.onPasted({
|
|
799
837
|
pasteData: pastedRows,
|
|
838
|
+
copyRows,
|
|
800
839
|
type: 'onPaste',
|
|
801
840
|
data: mergedData,
|
|
802
841
|
pastedColumns: pastedColumnsArray
|
|
@@ -806,6 +845,7 @@ const InternalTable = props => {
|
|
|
806
845
|
onCellPaste.onPasted({
|
|
807
846
|
pasteData: pastedRows,
|
|
808
847
|
type: 'onPaste',
|
|
848
|
+
copyRows,
|
|
809
849
|
data: mergedData,
|
|
810
850
|
pastedColumns: pastedColumnsArray
|
|
811
851
|
}, handlePasteCallback);
|
|
@@ -833,8 +873,13 @@ const InternalTable = props => {
|
|
|
833
873
|
t: t,
|
|
834
874
|
id: id,
|
|
835
875
|
locale: locale,
|
|
836
|
-
tableRef: tableRef
|
|
837
|
-
dataSource
|
|
876
|
+
tableRef: tableRef
|
|
877
|
+
// dataSource={mergedData}
|
|
878
|
+
,
|
|
879
|
+
originData: mergedData
|
|
880
|
+
// dataSource={filterStates && filterStates.length ? filterData : mergedData}
|
|
881
|
+
,
|
|
882
|
+
dataSource: filterDataByColumns4(mergedData, filterStates, mergedFilterKeys),
|
|
838
883
|
format: format,
|
|
839
884
|
columns: mergedColumns,
|
|
840
885
|
showSorterTooltip: {
|
|
@@ -874,14 +919,23 @@ const InternalTable = props => {
|
|
|
874
919
|
cell: TableBodyCell
|
|
875
920
|
}
|
|
876
921
|
},
|
|
877
|
-
setTooltipContent: setTooltipContent
|
|
922
|
+
setTooltipContent: setTooltipContent,
|
|
923
|
+
onFilter: val => {
|
|
924
|
+
handleOnFilter(val);
|
|
925
|
+
// triggerFilter?.(convertFilters(val))
|
|
926
|
+
// onFilter?.(convertFilters(val))
|
|
927
|
+
},
|
|
928
|
+
setMergedFilterKeys: setMergedFilterKeys,
|
|
929
|
+
mergedFilterKeys: mergedFilterKeys,
|
|
930
|
+
wrapSettings: wrapSettings
|
|
878
931
|
})))), /*#__PURE__*/React.createElement(DragOverlay, {
|
|
879
932
|
style: {
|
|
880
|
-
|
|
933
|
+
minWidth: 100,
|
|
934
|
+
width: columns[columns.findIndex(i => i.field === dragIndex.active)]?.width
|
|
881
935
|
}
|
|
882
936
|
}, /*#__PURE__*/React.createElement("th", {
|
|
883
937
|
style: {
|
|
884
|
-
backgroundColor: '#
|
|
938
|
+
backgroundColor: '#f0f0f0',
|
|
885
939
|
padding: 6,
|
|
886
940
|
borderRadius: 6,
|
|
887
941
|
fontWeight: 500
|