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
|
@@ -7,10 +7,13 @@ type Props<T> = GridTableProps<T> & {
|
|
|
7
7
|
triggerChangeData?: (newData: T[], type: string) => void;
|
|
8
8
|
getRowKey: GetRowKey<T>;
|
|
9
9
|
triggerGroupColumns?: (groupedColumns: string[]) => void;
|
|
10
|
-
triggerPaste?: (pastedRows: T[], pastedColumnsArray: string[], newData: T[]) => void;
|
|
10
|
+
triggerPaste?: (pastedRows: T[], pastedColumnsArray: string[], newData: T[], copyRows: T[]) => void;
|
|
11
11
|
triggerFilter?: (queries: any) => void;
|
|
12
12
|
setTooltipContent?: any;
|
|
13
13
|
scrollHeight?: number;
|
|
14
|
+
originData: T[];
|
|
15
|
+
mergedFilterKeys?: any;
|
|
16
|
+
setMergedFilterKeys?: any;
|
|
14
17
|
};
|
|
15
18
|
declare const Group: <RecordType extends object>(props: Props<RecordType>) => React.JSX.Element;
|
|
16
19
|
export default Group;
|
|
@@ -10,9 +10,12 @@ type Props<T> = TableProps<T> & {
|
|
|
10
10
|
getRowKey: GetRowKey<T>;
|
|
11
11
|
triggerGroupColumns?: (groupedColumns: string[]) => void;
|
|
12
12
|
setTooltipContent?: any;
|
|
13
|
-
triggerPaste?: (pastedRows: T[], pastedColumnsArray: string[], newData: T[]) => void;
|
|
13
|
+
triggerPaste?: (pastedRows: T[], pastedColumnsArray: string[], newData: T[], copyRows: T[]) => void;
|
|
14
14
|
isFilter?: boolean;
|
|
15
15
|
setIsFilter?: React.Dispatch<React.SetStateAction<boolean>>;
|
|
16
|
+
originData: T[];
|
|
17
|
+
mergedFilterKeys?: any;
|
|
18
|
+
setMergedFilterKeys?: any;
|
|
16
19
|
};
|
|
17
20
|
declare const InfiniteTable: <RecordType extends object>(props: Props<RecordType>) => React.JSX.Element;
|
|
18
21
|
export default InfiniteTable;
|
|
@@ -25,6 +25,7 @@ const InfiniteTable = props => {
|
|
|
25
25
|
scrollHeight,
|
|
26
26
|
rowHoverable,
|
|
27
27
|
pagination,
|
|
28
|
+
dataSource,
|
|
28
29
|
...rest
|
|
29
30
|
} = props;
|
|
30
31
|
const {
|
|
@@ -49,7 +50,7 @@ const InfiniteTable = props => {
|
|
|
49
50
|
loadData(currentPage + 1);
|
|
50
51
|
};
|
|
51
52
|
const handleScroll = e => {
|
|
52
|
-
if (loadingRef.current || loading) {
|
|
53
|
+
if (loadingRef.current || loading || dataSource?.length === 0) {
|
|
53
54
|
e.stopPropagation();
|
|
54
55
|
e.preventDefault();
|
|
55
56
|
return;
|
|
@@ -60,7 +61,7 @@ const InfiniteTable = props => {
|
|
|
60
61
|
clientHeight
|
|
61
62
|
} = e.currentTarget;
|
|
62
63
|
const isEnd = scrollTop + clientHeight >= tbScrollHeight - 50;
|
|
63
|
-
if (isEnd && !loadingRef.current && hasMoreRef.current) {
|
|
64
|
+
if (isEnd && !loadingRef.current && hasMoreRef.current && dataSource?.length > 0) {
|
|
64
65
|
handleNext();
|
|
65
66
|
}
|
|
66
67
|
};
|
|
@@ -87,6 +88,7 @@ const InfiniteTable = props => {
|
|
|
87
88
|
}
|
|
88
89
|
}, /*#__PURE__*/React.createElement(TableGrid, _extends({}, rest, {
|
|
89
90
|
id: id,
|
|
91
|
+
dataSource: dataSource,
|
|
90
92
|
pagination: false,
|
|
91
93
|
virtual: true,
|
|
92
94
|
onScroll: handleScroll,
|
|
@@ -227,6 +227,7 @@ export interface TableProps<RecordType = AnyObject> extends Omit<RcTableProps<Re
|
|
|
227
227
|
rowData: any;
|
|
228
228
|
}) => void;
|
|
229
229
|
wrapSettings?: IWrapSettings;
|
|
230
|
+
actionTemplate?: ReactNode | ReactElement | (() => ReactNode | ReactElement);
|
|
230
231
|
}
|
|
231
232
|
export type PaginationConfig = TablePaginationConfig & {
|
|
232
233
|
currentPage?: number;
|
|
@@ -259,6 +260,7 @@ export type IGroupSetting = {
|
|
|
259
260
|
hiddenColumnGroup?: boolean;
|
|
260
261
|
showGroupIcon?: boolean;
|
|
261
262
|
unClearableLevel?: 1 | 2 | 3 | undefined;
|
|
263
|
+
sumGroup?: boolean;
|
|
262
264
|
};
|
|
263
265
|
type IOnGroup = {
|
|
264
266
|
columnGrouped: string[];
|
|
@@ -284,6 +286,7 @@ export type CellChangeArgs<T> = {
|
|
|
284
286
|
};
|
|
285
287
|
export type IOnPastedProps = {
|
|
286
288
|
data: any[];
|
|
289
|
+
copyRows: any[];
|
|
287
290
|
pastedColumns: string[];
|
|
288
291
|
pasteData: any[];
|
|
289
292
|
type: 'onPaste' | 'onChange' | 'onCellPaste';
|
package/es/index.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ export { default as Tabs } from './tabs';
|
|
|
6
6
|
export type { TabPaneProps, TabsProps } from './tabs';
|
|
7
7
|
export { default as SelectTable } from './select-table';
|
|
8
8
|
export type { TableSelectProps as SelectTableProps } from './select-table';
|
|
9
|
+
export { default as Select } from './select';
|
|
10
|
+
export type { SelectProps } from './select';
|
|
9
11
|
export { default as DateRangePicker } from './date-range-picker';
|
|
10
12
|
export type { DateRangePickerProps } from './date-range-picker';
|
|
11
13
|
export { default as DatePicker } from './datepicker';
|
package/es/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export { default as Dropdown } from "./dropdown";
|
|
|
2
2
|
export { default as GridComponent } from "./grid-component";
|
|
3
3
|
export { default as Tabs } from "./tabs";
|
|
4
4
|
export { default as SelectTable } from "./select-table";
|
|
5
|
+
export { default as Select } from "./select";
|
|
5
6
|
export { default as DateRangePicker } from "./date-range-picker";
|
|
6
7
|
export { default as DatePicker } from "./datepicker";
|
|
7
8
|
export { default as Splitter } from "./splitter";
|
package/es/select/index.d.ts
CHANGED
|
@@ -88,7 +88,6 @@ const CheckboxFilter = props => {
|
|
|
88
88
|
|
|
89
89
|
// const [searchValue, setSearchValue] = React.useState('');
|
|
90
90
|
|
|
91
|
-
console.log('options', options);
|
|
92
91
|
const [openKeys, setOpenKeys] = React.useState([]);
|
|
93
92
|
|
|
94
93
|
// clear search value after close filter dropdown
|
|
@@ -181,9 +180,6 @@ const CheckboxFilter = props => {
|
|
|
181
180
|
onSelect?.(keys);
|
|
182
181
|
}
|
|
183
182
|
};
|
|
184
|
-
console.log('getTreeData({ filters: options })', getTreeData({
|
|
185
|
-
filters: options
|
|
186
|
-
}));
|
|
187
183
|
if (filterMode === 'tree') {
|
|
188
184
|
return /*#__PURE__*/React.createElement(React.Fragment, null, showFilter && /*#__PURE__*/React.createElement(_FilterSearch.default, {
|
|
189
185
|
filterSearch: filterSearch,
|
|
@@ -387,7 +387,7 @@ const ColumnsChoose = props => {
|
|
|
387
387
|
const defaultSelectedKeys = (0, _react.useMemo)(() => {
|
|
388
388
|
const defaultColumns = propsColumns.filter(it => (it.key || it.dataIndex) && it.showInColumnChoose !== false && !columnsGroup?.includes(it.field));
|
|
389
389
|
return (0, _hooks.getVisibleColumnKeys)(defaultColumns);
|
|
390
|
-
}, [propsColumns]);
|
|
390
|
+
}, [columnsGroup, propsColumns]);
|
|
391
391
|
const [clicked, setClicked] = (0, _react.useState)(false);
|
|
392
392
|
const [autoExpandParent, setAutoExpandParent] = (0, _react.useState)(true);
|
|
393
393
|
|
|
@@ -482,7 +482,8 @@ const ColumnsChoose = props => {
|
|
|
482
482
|
placement: 'bottomLeft',
|
|
483
483
|
content: /*#__PURE__*/_react.default.createElement("div", {
|
|
484
484
|
style: {
|
|
485
|
-
minWidth: 250
|
|
485
|
+
minWidth: 250,
|
|
486
|
+
maxWidth: 320
|
|
486
487
|
}
|
|
487
488
|
}, /*#__PURE__*/_react.default.createElement(_antd.Input, {
|
|
488
489
|
style: {
|
|
@@ -527,8 +528,12 @@ const ColumnsChoose = props => {
|
|
|
527
528
|
defaultCheckedKeys: selectedKeys
|
|
528
529
|
// defaultCheckedKeys={defaultSelectedKeys}
|
|
529
530
|
,
|
|
530
|
-
selectedKeys: []
|
|
531
|
-
|
|
531
|
+
selectedKeys: []
|
|
532
|
+
|
|
533
|
+
// height={window.innerHeight - 200}
|
|
534
|
+
,
|
|
535
|
+
height: window.innerHeight / 2 > 450 ? 450 : window.innerHeight / 2 - 110
|
|
536
|
+
// style={{height: 300}}
|
|
532
537
|
}), /*#__PURE__*/_react.default.createElement(BoxAction, {
|
|
533
538
|
className: 'px-1'
|
|
534
539
|
}, /*#__PURE__*/_react.default.createElement(_antd.Button
|
|
@@ -10,6 +10,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
10
10
|
var _antd = require("antd");
|
|
11
11
|
var _rcMasterUi = require("rc-master-ui");
|
|
12
12
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
13
|
+
var _hooks = require("../hooks");
|
|
13
14
|
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); }
|
|
14
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; }
|
|
15
16
|
// import {
|
|
@@ -129,7 +130,8 @@ const ColumnsGroup = props => {
|
|
|
129
130
|
}, "M\u1EE9c 1"), /*#__PURE__*/_react.default.createElement(_rcMasterUi.Select, {
|
|
130
131
|
style: {
|
|
131
132
|
width: '100%'
|
|
132
|
-
}
|
|
133
|
+
},
|
|
134
|
+
showSearch: true
|
|
133
135
|
// labelInValue={true}
|
|
134
136
|
// options={columns.filter((it: any) => !tempGroup.includes(it.field))}
|
|
135
137
|
// options={columns && columns.length > 0 ? options : []}
|
|
@@ -146,7 +148,8 @@ const ColumnsGroup = props => {
|
|
|
146
148
|
labelRender: labelProps => {
|
|
147
149
|
const it = columns.find(col => col.field === labelProps.value);
|
|
148
150
|
return t ? t(it?.columnGroupText ?? it?.headerText) : it?.columnGroupText ?? it?.headerText;
|
|
149
|
-
}
|
|
151
|
+
},
|
|
152
|
+
filterOption: _hooks.customFilterOption
|
|
150
153
|
// hideSelectedOptions
|
|
151
154
|
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
152
155
|
className: 'mb-1',
|
|
@@ -159,6 +162,7 @@ const ColumnsGroup = props => {
|
|
|
159
162
|
margin: 0
|
|
160
163
|
}
|
|
161
164
|
}, "M\u1EE9c 2"), /*#__PURE__*/_react.default.createElement(_rcMasterUi.Select, {
|
|
165
|
+
showSearch: true,
|
|
162
166
|
style: {
|
|
163
167
|
width: '100%'
|
|
164
168
|
},
|
|
@@ -175,7 +179,8 @@ const ColumnsGroup = props => {
|
|
|
175
179
|
labelRender: labelProps => {
|
|
176
180
|
const it = columns.find(col => col.field === labelProps.value);
|
|
177
181
|
return t ? t(it?.columnGroupText ?? it?.headerText) : it?.columnGroupText ?? it?.headerText;
|
|
178
|
-
}
|
|
182
|
+
},
|
|
183
|
+
filterOption: _hooks.customFilterOption
|
|
179
184
|
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
180
185
|
className: 'mb-1',
|
|
181
186
|
style: {
|
|
@@ -191,6 +196,7 @@ const ColumnsGroup = props => {
|
|
|
191
196
|
width: '100%'
|
|
192
197
|
},
|
|
193
198
|
options: options,
|
|
199
|
+
showSearch: true,
|
|
194
200
|
value: tempGroup?.[2],
|
|
195
201
|
onChange: val => onChangeGroupColumns(val, 2),
|
|
196
202
|
allowClear: !!tempGroup?.[2] && !(unClearableLevel && unClearableLevel - 3 >= 0)
|
|
@@ -202,7 +208,8 @@ const ColumnsGroup = props => {
|
|
|
202
208
|
labelRender: labelProps => {
|
|
203
209
|
const it = columns.find(col => col.field === labelProps.value);
|
|
204
210
|
return t ? t(it?.columnGroupText ?? it?.headerText) : it?.columnGroupText ?? it?.headerText;
|
|
205
|
-
}
|
|
211
|
+
},
|
|
212
|
+
filterOption: _hooks.customFilterOption
|
|
206
213
|
}))), /*#__PURE__*/_react.default.createElement(BoxAction, {
|
|
207
214
|
className: 'px-1'
|
|
208
215
|
}, /*#__PURE__*/_react.default.createElement(_antd.Button
|
|
@@ -30,6 +30,9 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
30
30
|
const {
|
|
31
31
|
SHOW_PARENT
|
|
32
32
|
} = _rcMasterUi.TreeSelect;
|
|
33
|
+
const {
|
|
34
|
+
TextArea
|
|
35
|
+
} = _antd.Input;
|
|
33
36
|
const filterTreeNode = (input, treeNode) => {
|
|
34
37
|
const {
|
|
35
38
|
title,
|
|
@@ -116,8 +119,13 @@ const EditableCell = props => {
|
|
|
116
119
|
style: {
|
|
117
120
|
width: '100%',
|
|
118
121
|
height: '100%'
|
|
119
|
-
}
|
|
120
|
-
value
|
|
122
|
+
}
|
|
123
|
+
// value={date}
|
|
124
|
+
,
|
|
125
|
+
defaultValue: date
|
|
126
|
+
// preserveInvalidOnBlur
|
|
127
|
+
,
|
|
128
|
+
|
|
121
129
|
onBlur: () => {
|
|
122
130
|
const formState = getValues();
|
|
123
131
|
const itemState = getValues(dataIndex);
|
|
@@ -180,8 +188,10 @@ const EditableCell = props => {
|
|
|
180
188
|
width: '100%',
|
|
181
189
|
height: '100%'
|
|
182
190
|
},
|
|
183
|
-
showTime: true
|
|
184
|
-
value
|
|
191
|
+
showTime: true
|
|
192
|
+
// value={date}
|
|
193
|
+
,
|
|
194
|
+
defaultValue: date,
|
|
185
195
|
placeholder: t ? t(column.placeholder ?? 'Select') : column.placeholder ?? 'Select',
|
|
186
196
|
disabled: (0, _hooks.isDisable)(column, record) ?? false,
|
|
187
197
|
maxDate: maxDate,
|
|
@@ -710,7 +720,7 @@ const EditableCell = props => {
|
|
|
710
720
|
style: {
|
|
711
721
|
display: 'flex',
|
|
712
722
|
alignItems: 'center',
|
|
713
|
-
justifyContent: column.align ?? '
|
|
723
|
+
justifyContent: column.align ?? 'center',
|
|
714
724
|
paddingInline: 5,
|
|
715
725
|
height: '100%',
|
|
716
726
|
width: '100%'
|
|
@@ -720,7 +730,7 @@ const EditableCell = props => {
|
|
|
720
730
|
// style={{ textAlign: column.align ?? 'left' }}
|
|
721
731
|
,
|
|
722
732
|
onChange: val => {
|
|
723
|
-
const newVal = (0, _hooks.parseBooleanToValue)(val.target.checked, typeof value);
|
|
733
|
+
const newVal = typeof value === "number" ? (0, _hooks.parseBooleanToValue)(val.target.checked, typeof value) : val.target.checked;
|
|
724
734
|
onChange(newVal);
|
|
725
735
|
const key = getRowKey?.(record, index);
|
|
726
736
|
const formState = getValues();
|
|
@@ -931,11 +941,14 @@ const EditableCell = props => {
|
|
|
931
941
|
"data-tooltip-id": `${id}-tooltip-form-error`
|
|
932
942
|
}));
|
|
933
943
|
default:
|
|
934
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
944
|
+
return /*#__PURE__*/_react.default.createElement(TextArea, {
|
|
935
945
|
id: `col${indexCol}-record${indexRow}`,
|
|
936
946
|
style: {
|
|
937
|
-
textAlign: column.align
|
|
947
|
+
textAlign: column.align,
|
|
948
|
+
resize: 'none',
|
|
949
|
+
height: '100%'
|
|
938
950
|
}
|
|
951
|
+
|
|
939
952
|
// @ts-ignore
|
|
940
953
|
// value={!isNullOrUndefined(record[column.dataIndex]) ? record[column.dataIndex] : ''}
|
|
941
954
|
,
|
|
@@ -991,7 +1004,11 @@ const EditableCell = props => {
|
|
|
991
1004
|
onChange: onChange,
|
|
992
1005
|
status: isInvalid ? 'error' : undefined,
|
|
993
1006
|
"data-tooltip-content": message,
|
|
994
|
-
"data-tooltip-id": `${id}-tooltip-form-error
|
|
1007
|
+
"data-tooltip-id": `${id}-tooltip-form-error`,
|
|
1008
|
+
autoSize: {
|
|
1009
|
+
minRows: 1,
|
|
1010
|
+
maxRows: 1
|
|
1011
|
+
}
|
|
995
1012
|
});
|
|
996
1013
|
}
|
|
997
1014
|
};
|
|
@@ -37,6 +37,7 @@ var _sortable = require("@dnd-kit/sortable");
|
|
|
37
37
|
var _reactResizable = require("react-resizable");
|
|
38
38
|
var _faker = require("@faker-js/faker");
|
|
39
39
|
var _InfiniteTable = _interopRequireDefault(require("./table/InfiniteTable"));
|
|
40
|
+
var _useMergedState = _interopRequireDefault(require("rc-util/lib/hooks/useMergedState"));
|
|
40
41
|
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); }
|
|
41
42
|
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; }
|
|
42
43
|
// import {Resizable} from "react-resizable";
|
|
@@ -191,15 +192,19 @@ const InternalTable = props => {
|
|
|
191
192
|
summary,
|
|
192
193
|
infiniteScroll,
|
|
193
194
|
wrapSettings,
|
|
195
|
+
onFilter,
|
|
194
196
|
...rest
|
|
195
197
|
} = props;
|
|
196
198
|
const id = _react.default.useMemo(() => {
|
|
197
199
|
return tableId ?? _faker.faker.string.alpha(20);
|
|
198
200
|
// return tableId ?? newGuid()
|
|
199
201
|
}, [tableId]);
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
202
|
+
|
|
203
|
+
// const rowKey = React.useMemo(() => {
|
|
204
|
+
// return propRowKey ?? 'rowId'
|
|
205
|
+
// }, [propRowKey])
|
|
206
|
+
|
|
207
|
+
const rowKey = 'rowId';
|
|
203
208
|
const [scrollHeight, setHeight] = (0, _react.useState)(0);
|
|
204
209
|
const local = lang && lang === 'en' ? _en_US.default : _vi_VN.default;
|
|
205
210
|
const dateRangeLocale = lang && lang === 'en' ? _en_US2.default : _vi_VN2.default;
|
|
@@ -219,14 +224,30 @@ const InternalTable = props => {
|
|
|
219
224
|
over: -1
|
|
220
225
|
});
|
|
221
226
|
const [tooltipContent, setTooltipContent] = (0, _react.useState)('');
|
|
222
|
-
const
|
|
223
|
-
|
|
227
|
+
const [filterStates, setFilterState] = _react.default.useState(null);
|
|
228
|
+
// const [filterData, setFilterData] = React.useState<any>(null)
|
|
224
229
|
|
|
230
|
+
const mergedData = _react.default.useMemo(() => {
|
|
225
231
|
if (groupAble && groupSetting && groupSetting.client !== false) {
|
|
226
232
|
return (0, _hooks.groupArrayByColumns)(dataSource, groupColumns);
|
|
227
233
|
}
|
|
228
234
|
return (0, _hooks.addRowIdArray)(dataSource);
|
|
229
235
|
}, [dataSource, groupAble, groupColumns, groupSetting]);
|
|
236
|
+
|
|
237
|
+
// ========================= Keys =========================
|
|
238
|
+
const [mergedFilterKeys, setMergedFilterKeys] = (0, _useMergedState.default)((0, _hooks.getAllRowKey)(mergedData), {
|
|
239
|
+
value: undefined
|
|
240
|
+
});
|
|
241
|
+
//
|
|
242
|
+
// const originData = React.useMemo(() => {
|
|
243
|
+
//
|
|
244
|
+
// if (groupAble && groupSetting && groupSetting.client !== false) {
|
|
245
|
+
// return groupArrayByColumns(dataSource, groupColumns)
|
|
246
|
+
// }
|
|
247
|
+
// return addRowIdArray(dataSource)
|
|
248
|
+
//
|
|
249
|
+
// }, [dataSource, groupAble, groupColumns, groupSetting])
|
|
250
|
+
|
|
230
251
|
const [columns, setColumns] = _react.default.useState([]);
|
|
231
252
|
_react.default.useEffect(() => {
|
|
232
253
|
if (propsHeight) {
|
|
@@ -245,6 +266,20 @@ const InternalTable = props => {
|
|
|
245
266
|
_react.default.useEffect(() => {
|
|
246
267
|
setColumns(propsColumns);
|
|
247
268
|
}, [propsColumns]);
|
|
269
|
+
const handleOnFilter = queries => {
|
|
270
|
+
if (onFilter) {
|
|
271
|
+
onFilter?.((0, _hooks.convertFilters)(queries));
|
|
272
|
+
} else {
|
|
273
|
+
setFilterState((0, _hooks.convertFilters)(queries));
|
|
274
|
+
const b = (0, _hooks.filterDataByColumns4)(mergedData, (0, _hooks.convertFilters)(queries), []);
|
|
275
|
+
setMergedFilterKeys((0, _hooks.getAllRowKey)(b));
|
|
276
|
+
if (queries && queries.length > 0) {
|
|
277
|
+
// setIsFilter?.(true)
|
|
278
|
+
} else {
|
|
279
|
+
// setIsFilter?.(false)
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
};
|
|
248
283
|
const handleResize = column => (e, {
|
|
249
284
|
size
|
|
250
285
|
}) => {
|
|
@@ -416,10 +451,11 @@ const InternalTable = props => {
|
|
|
416
451
|
})
|
|
417
452
|
}),
|
|
418
453
|
render: (val, record) => {
|
|
454
|
+
const tmpData = (0, _hooks.filterDataByColumns4)(mergedData, filterStates, mergedFilterKeys);
|
|
419
455
|
if (pagination && pagination.onChange && pagination.currentPage && pagination.pageSize) {
|
|
420
|
-
return (0, _hooks.findItemPath)(
|
|
456
|
+
return (0, _hooks.findItemPath)(tmpData, record, rowKey, pagination.currentPage, pagination.pageSize);
|
|
421
457
|
}
|
|
422
|
-
return (0, _hooks.findItemPath)(
|
|
458
|
+
return (0, _hooks.findItemPath)(tmpData, record, rowKey);
|
|
423
459
|
}
|
|
424
460
|
};
|
|
425
461
|
}
|
|
@@ -515,28 +551,28 @@ const InternalTable = props => {
|
|
|
515
551
|
render: (value, record, rowIndex) => {
|
|
516
552
|
const colFormat = typeof column.format === 'function' ? column.format(record) : column.format;
|
|
517
553
|
const cellFormat = (0, _hooks.getFormat)(colFormat, format);
|
|
518
|
-
if (groupSetting && groupSetting.hiddenColumnGroup === false) {
|
|
554
|
+
if (groupAble && groupSetting && groupSetting.hiddenColumnGroup === false) {
|
|
519
555
|
if (record.children) {
|
|
520
|
-
return (0, _columns.renderContent)(column, value, record, rowIndex, cellFormat);
|
|
556
|
+
return (0, _columns.renderContent)(column, value, record, rowIndex, colIndex, false, cellFormat);
|
|
521
557
|
}
|
|
522
558
|
if (groupColumns?.includes(column.field)) {
|
|
523
559
|
return '';
|
|
524
560
|
}
|
|
525
|
-
return (0, _columns.renderContent)(column, value, record, rowIndex, cellFormat);
|
|
561
|
+
return (0, _columns.renderContent)(column, value, record, rowIndex, colIndex, false, cellFormat);
|
|
526
562
|
}
|
|
527
|
-
if (column.field === firstNonGroupColumn?.field && record.children) {
|
|
563
|
+
if (groupAble && column.field === firstNonGroupColumn?.field && record.children) {
|
|
528
564
|
const currentGroupColumn = (0, _columns.flatColumns2)(columns).find(it => it.field === record.field);
|
|
529
565
|
if (currentGroupColumn?.template) {
|
|
530
|
-
return (0, _columns.renderContent)(currentGroupColumn, record[record.field], record, rowIndex, cellFormat);
|
|
566
|
+
return (0, _columns.renderContent)(currentGroupColumn, record[record.field], record, rowIndex, colIndex, false, cellFormat);
|
|
531
567
|
}
|
|
532
|
-
return /*#__PURE__*/_react.default.createElement("span", null, currentGroupColumn?.headerText, ": ", (0, _columns.renderContent)(currentGroupColumn, record[record.field], record, rowIndex, cellFormat));
|
|
568
|
+
return /*#__PURE__*/_react.default.createElement("span", null, currentGroupColumn?.headerText, ": ", (0, _columns.renderContent)(currentGroupColumn, record[record.field], record, rowIndex, colIndex, false, cellFormat));
|
|
533
569
|
}
|
|
534
|
-
return (0, _columns.renderContent)(column, value, record, rowIndex, cellFormat);
|
|
570
|
+
return (0, _columns.renderContent)(column, value, record, rowIndex, colIndex, false, cellFormat);
|
|
535
571
|
},
|
|
536
572
|
hidden: groupSetting && groupSetting.hiddenColumnGroup === false ? transformedColumn.hidden : groupAble && groupColumns && groupColumns.includes(column.field) ? true : transformedColumn.hidden
|
|
537
573
|
};
|
|
538
574
|
});
|
|
539
|
-
}, [columns, t, getColumnSearchProps, sortMultiple, groupSetting, groupAble, groupColumns,
|
|
575
|
+
}, [columns, t, id, wrapSettings, getColumnSearchProps, sortMultiple, groupSetting, groupAble, groupColumns, mergedData, filterStates, mergedFilterKeys, pagination, handleResize, firstNonGroupColumn?.field, nonGroupColumns, format]);
|
|
540
576
|
const transformColumns = _react.default.useCallback(cols => {
|
|
541
577
|
return cols.map(column => {
|
|
542
578
|
const find = convertColumns.find(it => it.field === column.field);
|
|
@@ -584,7 +620,7 @@ const InternalTable = props => {
|
|
|
584
620
|
};
|
|
585
621
|
}
|
|
586
622
|
});
|
|
587
|
-
}, [convertColumns, t]);
|
|
623
|
+
}, [convertColumns, id, t, wrapSettings]);
|
|
588
624
|
const mergedColumns = _react.default.useMemo(() => {
|
|
589
625
|
return transformColumns(columns);
|
|
590
626
|
}, [columns, transformColumns]);
|
|
@@ -602,9 +638,9 @@ const InternalTable = props => {
|
|
|
602
638
|
});
|
|
603
639
|
}
|
|
604
640
|
onChooseColumns?.({
|
|
605
|
-
showColumns: [],
|
|
606
|
-
columns: [],
|
|
607
|
-
flattenColumns: []
|
|
641
|
+
showColumns: (0, _hooks.removeInvisibleColumns)([...newColumns]),
|
|
642
|
+
columns: [...newColumns],
|
|
643
|
+
flattenColumns: (0, _hooks.convertFlatColumn)([...newColumns])
|
|
608
644
|
});
|
|
609
645
|
};
|
|
610
646
|
const onDragEnd = ({
|
|
@@ -683,7 +719,9 @@ const InternalTable = props => {
|
|
|
683
719
|
rowData,
|
|
684
720
|
index
|
|
685
721
|
} = args;
|
|
686
|
-
|
|
722
|
+
|
|
723
|
+
// const tmpData = [...mergedData]
|
|
724
|
+
const tmpData = (0, _hooks.filterDataByColumns4)(mergedData, filterStates, mergedFilterKeys);
|
|
687
725
|
if (idCommand === 'DELETE') {
|
|
688
726
|
// bật modal confirm
|
|
689
727
|
if (commandSettings && commandSettings.confirmDialog) {
|
|
@@ -709,7 +747,7 @@ const InternalTable = props => {
|
|
|
709
747
|
|
|
710
748
|
let newData = [];
|
|
711
749
|
if (rowData?.parentId) {
|
|
712
|
-
const parent = (0, _hooks.findItemByKey)(
|
|
750
|
+
const parent = (0, _hooks.findItemByKey)(tmpData, rowKey, rowData.parentId);
|
|
713
751
|
const childData = parent?.children ? [...parent.children] : [];
|
|
714
752
|
const findIndex = childData.findIndex(obj => obj[rowKey] === rowData[rowKey]);
|
|
715
753
|
childData.splice(Number(findIndex), 1);
|
|
@@ -796,7 +834,7 @@ const InternalTable = props => {
|
|
|
796
834
|
}
|
|
797
835
|
}
|
|
798
836
|
};
|
|
799
|
-
const triggerPaste = (pastedRows, pastedColumnsArray, newData) => {
|
|
837
|
+
const triggerPaste = (pastedRows, pastedColumnsArray, newData, copyRows) => {
|
|
800
838
|
const handlePasteCallback = callbackData => {
|
|
801
839
|
const newDataUpdate = (0, _hooks.updateData)(mergedData, callbackData, rowKey);
|
|
802
840
|
triggerChangeData(newDataUpdate);
|
|
@@ -808,6 +846,7 @@ const InternalTable = props => {
|
|
|
808
846
|
// có callback
|
|
809
847
|
onCellPaste.onPasted({
|
|
810
848
|
pasteData: pastedRows,
|
|
849
|
+
copyRows,
|
|
811
850
|
type: 'onPaste',
|
|
812
851
|
data: mergedData,
|
|
813
852
|
pastedColumns: pastedColumnsArray
|
|
@@ -817,6 +856,7 @@ const InternalTable = props => {
|
|
|
817
856
|
onCellPaste.onPasted({
|
|
818
857
|
pasteData: pastedRows,
|
|
819
858
|
type: 'onPaste',
|
|
859
|
+
copyRows,
|
|
820
860
|
data: mergedData,
|
|
821
861
|
pastedColumns: pastedColumnsArray
|
|
822
862
|
}, handlePasteCallback);
|
|
@@ -844,8 +884,13 @@ const InternalTable = props => {
|
|
|
844
884
|
t: t,
|
|
845
885
|
id: id,
|
|
846
886
|
locale: locale,
|
|
847
|
-
tableRef: tableRef
|
|
848
|
-
dataSource
|
|
887
|
+
tableRef: tableRef
|
|
888
|
+
// dataSource={mergedData}
|
|
889
|
+
,
|
|
890
|
+
originData: mergedData
|
|
891
|
+
// dataSource={filterStates && filterStates.length ? filterData : mergedData}
|
|
892
|
+
,
|
|
893
|
+
dataSource: (0, _hooks.filterDataByColumns4)(mergedData, filterStates, mergedFilterKeys),
|
|
849
894
|
format: format,
|
|
850
895
|
columns: mergedColumns,
|
|
851
896
|
showSorterTooltip: {
|
|
@@ -885,14 +930,23 @@ const InternalTable = props => {
|
|
|
885
930
|
cell: TableBodyCell
|
|
886
931
|
}
|
|
887
932
|
},
|
|
888
|
-
setTooltipContent: setTooltipContent
|
|
933
|
+
setTooltipContent: setTooltipContent,
|
|
934
|
+
onFilter: val => {
|
|
935
|
+
handleOnFilter(val);
|
|
936
|
+
// triggerFilter?.(convertFilters(val))
|
|
937
|
+
// onFilter?.(convertFilters(val))
|
|
938
|
+
},
|
|
939
|
+
setMergedFilterKeys: setMergedFilterKeys,
|
|
940
|
+
mergedFilterKeys: mergedFilterKeys,
|
|
941
|
+
wrapSettings: wrapSettings
|
|
889
942
|
})))), /*#__PURE__*/_react.default.createElement(_core.DragOverlay, {
|
|
890
943
|
style: {
|
|
891
|
-
|
|
944
|
+
minWidth: 100,
|
|
945
|
+
width: columns[columns.findIndex(i => i.field === dragIndex.active)]?.width
|
|
892
946
|
}
|
|
893
947
|
}, /*#__PURE__*/_react.default.createElement("th", {
|
|
894
948
|
style: {
|
|
895
|
-
backgroundColor: '#
|
|
949
|
+
backgroundColor: '#f0f0f0',
|
|
896
950
|
padding: 6,
|
|
897
951
|
borderRadius: 6,
|
|
898
952
|
fontWeight: 500
|