es-grid-template 1.1.5 → 1.1.7
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 -1
- package/es/grid-component/CheckboxFilter.js +2 -2
- package/es/grid-component/ContextMenu.js +1 -3
- package/es/grid-component/FilterSearch.d.ts +1 -1
- package/es/grid-component/FilterSearch.js +1 -1
- package/es/grid-component/InternalTable.js +83 -30
- package/es/grid-component/TableGrid.d.ts +0 -1
- package/es/grid-component/TableGrid.js +104 -65
- package/es/grid-component/hooks/constant.js +14 -14
- package/es/grid-component/hooks/useColumns/index.d.ts +2 -1
- package/es/grid-component/hooks/useColumns/index.js +21 -19
- package/es/grid-component/hooks/utils.d.ts +3 -1
- package/es/grid-component/hooks/utils.js +12 -1
- package/es/grid-component/styles.scss +701 -651
- package/es/grid-component/table/Grid.d.ts +1 -4
- package/es/grid-component/table/Grid.js +6 -70
- package/es/grid-component/table/GridEdit.js +35 -22
- package/es/grid-component/type.d.ts +6 -6
- package/lib/grid-component/CheckboxFilter.d.ts +1 -1
- package/lib/grid-component/CheckboxFilter.js +2 -2
- package/lib/grid-component/ContextMenu.js +1 -3
- package/lib/grid-component/FilterSearch.d.ts +1 -1
- package/lib/grid-component/FilterSearch.js +1 -1
- package/lib/grid-component/InternalTable.js +79 -28
- package/lib/grid-component/TableGrid.d.ts +0 -1
- package/lib/grid-component/TableGrid.js +103 -66
- package/lib/grid-component/hooks/constant.js +14 -14
- package/lib/grid-component/hooks/useColumns/index.d.ts +2 -1
- package/lib/grid-component/hooks/useColumns/index.js +20 -18
- package/lib/grid-component/hooks/utils.d.ts +3 -1
- package/lib/grid-component/hooks/utils.js +15 -2
- package/lib/grid-component/styles.scss +701 -651
- package/lib/grid-component/table/Grid.d.ts +1 -4
- package/lib/grid-component/table/Grid.js +5 -69
- package/lib/grid-component/table/GridEdit.js +35 -22
- package/lib/grid-component/type.d.ts +6 -6
- package/package.json +105 -102
|
@@ -106,7 +106,7 @@ const CheckboxFilter = props => {
|
|
|
106
106
|
});
|
|
107
107
|
const empty = /*#__PURE__*/React.createElement(Empty, {
|
|
108
108
|
image: Empty.PRESENTED_IMAGE_SIMPLE,
|
|
109
|
-
description: locale
|
|
109
|
+
description: locale?.filterEmptyText,
|
|
110
110
|
imageStyle: {
|
|
111
111
|
height: 24
|
|
112
112
|
},
|
|
@@ -193,7 +193,7 @@ const CheckboxFilter = props => {
|
|
|
193
193
|
indeterminate: selectedKeys.length > 0 && selectedKeys.length < flattenKeys(options).length,
|
|
194
194
|
className: `${tablePrefixCls}-filter-dropdown-checkall`,
|
|
195
195
|
onChange: onCheckAll
|
|
196
|
-
}, locale
|
|
196
|
+
}, locale?.filterCheckall) : /*#__PURE__*/React.createElement(Empty, null), /*#__PURE__*/React.createElement(Tree, {
|
|
197
197
|
checkable: true,
|
|
198
198
|
selectable: false,
|
|
199
199
|
blockNode: true,
|
|
@@ -94,9 +94,7 @@ const ContextMenu = props => {
|
|
|
94
94
|
items: contextMenuItems,
|
|
95
95
|
style: {
|
|
96
96
|
minWidth: 200,
|
|
97
|
-
|
|
98
|
-
maxHeight: pos.viewportHeight - 20,
|
|
99
|
-
width: 200
|
|
97
|
+
maxHeight: pos.viewportHeight - 20
|
|
100
98
|
},
|
|
101
99
|
rootClassName: 'popup-context-menu',
|
|
102
100
|
onClick: e => {
|
|
@@ -6,7 +6,7 @@ interface FilterSearchProps<RecordType = AnyObject> {
|
|
|
6
6
|
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
7
7
|
filterSearch: FilterSearchType<RecordType>;
|
|
8
8
|
tablePrefixCls: string;
|
|
9
|
-
locale
|
|
9
|
+
locale?: TableLocale;
|
|
10
10
|
}
|
|
11
11
|
declare const FilterSearch: <RecordType extends AnyObject = AnyObject>(props: FilterSearchProps<RecordType>) => React.JSX.Element;
|
|
12
12
|
export default FilterSearch;
|
|
@@ -20,7 +20,7 @@ const FilterSearch = props => {
|
|
|
20
20
|
}
|
|
21
21
|
}, /*#__PURE__*/React.createElement(Input, {
|
|
22
22
|
suffix: /*#__PURE__*/React.createElement(SearchOutlined, null),
|
|
23
|
-
placeholder: locale
|
|
23
|
+
placeholder: locale?.filterSearchPlaceholder,
|
|
24
24
|
onChange: onChange,
|
|
25
25
|
value: value,
|
|
26
26
|
autoFocus: true
|
|
@@ -5,9 +5,11 @@ 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 {
|
|
8
|
+
import {
|
|
9
|
+
// findAllChildrenKeys,
|
|
10
|
+
numberOperator, translateOption, updateArrayByKey } from "./hooks";
|
|
9
11
|
import { FilterFill } from "becoxy-icons";
|
|
10
|
-
import { renderFilter } from "./hooks/useColumns";
|
|
12
|
+
import { renderContent, renderFilter } from "./hooks/useColumns";
|
|
11
13
|
import dayjs from "dayjs";
|
|
12
14
|
import 'dayjs/locale/es';
|
|
13
15
|
import 'dayjs/locale/vi';
|
|
@@ -16,6 +18,8 @@ import vi from 'rc-master-ui/es/date-picker/locale/vi_VN';
|
|
|
16
18
|
import "./styles.scss";
|
|
17
19
|
import GridEdit from "./table/GridEdit";
|
|
18
20
|
import Grid from "./table/Grid";
|
|
21
|
+
// import useMergedState from "rc-util/lib/hooks/useMergedState";
|
|
22
|
+
|
|
19
23
|
dayjs.extend(customParseFormat);
|
|
20
24
|
const ResizableTitle = props => {
|
|
21
25
|
const {
|
|
@@ -50,30 +54,45 @@ const InternalTable = props => {
|
|
|
50
54
|
t,
|
|
51
55
|
columns: propsColumns,
|
|
52
56
|
lang,
|
|
57
|
+
locale,
|
|
53
58
|
dataSource,
|
|
54
59
|
allowResizing,
|
|
55
60
|
dataSourceFilter: propDataSourceFilter,
|
|
56
61
|
onFilterClick,
|
|
57
62
|
editAble,
|
|
58
63
|
rowKey,
|
|
64
|
+
format,
|
|
59
65
|
onDataChange,
|
|
60
66
|
sortMultiple,
|
|
67
|
+
expandable,
|
|
61
68
|
...rest
|
|
62
69
|
} = props;
|
|
63
|
-
const
|
|
70
|
+
const local = lang && lang === 'en' ? en : vi;
|
|
64
71
|
const buddhistLocale = {
|
|
65
|
-
...
|
|
72
|
+
...local,
|
|
66
73
|
lang: {
|
|
67
|
-
...
|
|
74
|
+
...local.lang
|
|
68
75
|
}
|
|
69
76
|
};
|
|
77
|
+
|
|
78
|
+
// const [mergedColumns, setMergedColumns] = useMergedState(
|
|
79
|
+
// propsColumns,
|
|
80
|
+
// {
|
|
81
|
+
// value: propsColumns,
|
|
82
|
+
// },
|
|
83
|
+
// );
|
|
84
|
+
|
|
85
|
+
// console.log('mergedColumns', mergedColumns)
|
|
86
|
+
|
|
70
87
|
const tableRef = useRef(null);
|
|
71
|
-
const [data, setData] = useState(
|
|
88
|
+
const [data, setData] = useState([]);
|
|
72
89
|
const [columns, setColumns] = useState([]);
|
|
73
90
|
const [isManualUpdate, setIsManualUpdate] = useState(false);
|
|
91
|
+
// const [expandKeys, setExpandKeys] = useState<string[]>([]);
|
|
74
92
|
const [dataSourceFilter, setDataSourceFilter] = useState(propDataSourceFilter ?? []);
|
|
75
93
|
useEffect(() => {
|
|
76
94
|
const rs = propsColumns ? [Table.SELECTION_COLUMN, ...propsColumns] : [];
|
|
95
|
+
// const rs = propsColumns ? [...propsColumns] : []
|
|
77
96
|
setColumns(rs);
|
|
78
97
|
}, [propsColumns]);
|
|
79
98
|
useEffect(() => {
|
|
@@ -81,7 +100,14 @@ const InternalTable = props => {
|
|
|
81
100
|
setData(dataSource || []);
|
|
82
101
|
}
|
|
83
102
|
setIsManualUpdate(false);
|
|
84
|
-
}, [dataSource]);
|
|
103
|
+
}, [dataSource, isManualUpdate]);
|
|
104
|
+
|
|
105
|
+
// const [columns, setColumns] = useMergedState(
|
|
106
|
+
// propsColumns ? [Table.SELECTION_COLUMN, ...propsColumns] : [],
|
|
107
|
+
// {
|
|
108
|
+
// value: propsColumns ? [Table.SELECTION_COLUMN, ...propsColumns] : [],
|
|
109
|
+
// },
|
|
110
|
+
// );
|
|
85
111
|
|
|
86
112
|
// ============================ RowKey ============================
|
|
87
113
|
const getRowKey = React.useMemo(() => {
|
|
@@ -91,6 +117,12 @@ const InternalTable = props => {
|
|
|
91
117
|
// @ts-ignore
|
|
92
118
|
return record => record?.[rowKey];
|
|
93
119
|
}, [rowKey]);
|
|
120
|
+
|
|
121
|
+
// useEffect(() => {
|
|
122
|
+
// const rrr = findAllChildrenKeys<any>(dataSource, getRowKey, 'children');
|
|
123
|
+
// setExpandKeys(rrr as any)
|
|
124
|
+
// }, [dataSource, getRowKey])
|
|
125
|
+
|
|
94
126
|
const handleSearch = (selectedKeys, confirm) => {
|
|
95
127
|
confirm();
|
|
96
128
|
};
|
|
@@ -115,17 +147,13 @@ const InternalTable = props => {
|
|
|
115
147
|
setSelectedKeys,
|
|
116
148
|
selectedKeys,
|
|
117
149
|
confirm,
|
|
118
|
-
|
|
150
|
+
close,
|
|
119
151
|
setOperatorKey,
|
|
120
152
|
operatorKey,
|
|
121
153
|
visible,
|
|
122
154
|
searchValue,
|
|
123
155
|
setSearchValue
|
|
124
156
|
}) => {
|
|
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;
|
|
129
157
|
return /*#__PURE__*/React.createElement("div", {
|
|
130
158
|
style: {
|
|
131
159
|
padding: 8,
|
|
@@ -135,7 +163,7 @@ const InternalTable = props => {
|
|
|
135
163
|
}, column?.showOperator !== false && column?.typeFilter !== 'DateRange' && column?.typeFilter !== 'NumberRange' && /*#__PURE__*/React.createElement("div", {
|
|
136
164
|
className: 'mb-1'
|
|
137
165
|
}, /*#__PURE__*/React.createElement(Select, {
|
|
138
|
-
options: translateOption(
|
|
166
|
+
options: translateOption(numberOperator, t),
|
|
139
167
|
style: {
|
|
140
168
|
width: '100%',
|
|
141
169
|
marginBottom: 8
|
|
@@ -148,7 +176,7 @@ const InternalTable = props => {
|
|
|
148
176
|
style: {
|
|
149
177
|
marginBottom: 8
|
|
150
178
|
}
|
|
151
|
-
}, renderFilter(column, selectedKeys, setSelectedKeys, confirm, visible, searchValue, setSearchValue, dataSourceFilter, buddhistLocale)), /*#__PURE__*/React.createElement(Space, {
|
|
179
|
+
}, renderFilter(column, selectedKeys, setSelectedKeys, confirm, visible, searchValue, setSearchValue, dataSourceFilter, buddhistLocale, locale, t)), /*#__PURE__*/React.createElement(Space, {
|
|
152
180
|
style: {
|
|
153
181
|
justifyContent: 'end',
|
|
154
182
|
width: '100%'
|
|
@@ -166,17 +194,13 @@ const InternalTable = props => {
|
|
|
166
194
|
style: {
|
|
167
195
|
width: 90
|
|
168
196
|
}
|
|
169
|
-
},
|
|
197
|
+
}, "Filter"), /*#__PURE__*/React.createElement(Button, {
|
|
170
198
|
type: "link",
|
|
171
199
|
size: "small",
|
|
172
200
|
onClick: () => {
|
|
173
|
-
|
|
174
|
-
setSelectedKeys([]);
|
|
175
|
-
confirm();
|
|
176
|
-
// handleSearch()
|
|
177
|
-
// close()
|
|
201
|
+
close();
|
|
178
202
|
}
|
|
179
|
-
},
|
|
203
|
+
}, "close")));
|
|
180
204
|
},
|
|
181
205
|
filterIcon: filtered => /*#__PURE__*/React.createElement(FilterFill, {
|
|
182
206
|
fontSize: 12,
|
|
@@ -248,7 +272,7 @@ const InternalTable = props => {
|
|
|
248
272
|
key: col.field ?? col.dataIndex ?? col.key,
|
|
249
273
|
title: t ? t(col.headerText ?? col.title) : col.headerText ?? col.title,
|
|
250
274
|
ellipsis: col.ellipsis !== false,
|
|
251
|
-
align: col.textAlign ?? col.align
|
|
275
|
+
align: col.textAlign ?? col.align,
|
|
252
276
|
fixed: col.frozen ? col.frozen.toLowerCase() : col.fixed
|
|
253
277
|
};
|
|
254
278
|
if (col.children) {
|
|
@@ -257,51 +281,80 @@ const InternalTable = props => {
|
|
|
257
281
|
children: transformColumns(col.children, currentPath)
|
|
258
282
|
};
|
|
259
283
|
}
|
|
260
|
-
|
|
284
|
+
|
|
285
|
+
// @ts-ignore
|
|
286
|
+
if (["index", "#"].includes(transformedColumn.dataIndex)) {
|
|
261
287
|
return {
|
|
262
|
-
...transformedColumn
|
|
288
|
+
...transformedColumn,
|
|
289
|
+
onCell: () => ({
|
|
290
|
+
className: 'cell-number'
|
|
291
|
+
}),
|
|
292
|
+
render: (_, __, rowIndex) => rowIndex + 1
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
if (col.field === 'command') {
|
|
296
|
+
return {
|
|
297
|
+
...transformedColumn,
|
|
298
|
+
onCell: () => ({
|
|
299
|
+
className: col.field === 'command' ? "ui-rc-cell-command" : ''
|
|
300
|
+
}),
|
|
301
|
+
onHeaderCell: () => ({
|
|
302
|
+
width: col.width,
|
|
303
|
+
onResize: handleResize(currentPath)
|
|
304
|
+
})
|
|
263
305
|
};
|
|
264
306
|
}
|
|
265
307
|
return {
|
|
266
|
-
...
|
|
308
|
+
...(col.allowFiltering === false ? {} : {
|
|
309
|
+
...getColumnSearchProps(col)
|
|
310
|
+
}),
|
|
267
311
|
...transformedColumn,
|
|
268
312
|
onFilter: value => {
|
|
269
313
|
return value;
|
|
270
314
|
},
|
|
271
|
-
sorter: {
|
|
315
|
+
sorter: col.sorter === false ? undefined : {
|
|
272
316
|
compare: a => a,
|
|
273
317
|
multiple: sortMultiple ? index : undefined
|
|
274
318
|
},
|
|
275
319
|
onHeaderCell: () => ({
|
|
276
320
|
width: col.width,
|
|
277
321
|
onResize: handleResize(currentPath)
|
|
278
|
-
})
|
|
322
|
+
}),
|
|
323
|
+
render: (value, record, rowIndex) => renderContent(col, value, record, rowIndex, format)
|
|
279
324
|
};
|
|
280
325
|
});
|
|
281
|
-
}, [getColumnSearchProps
|
|
326
|
+
}, [getColumnSearchProps]);
|
|
282
327
|
const mergedColumns = React.useMemo(() => {
|
|
283
328
|
return transformColumns(columns);
|
|
284
329
|
}, [transformColumns, columns]);
|
|
330
|
+
|
|
331
|
+
// console.log('mergedColumns', mergedColumns)
|
|
332
|
+
|
|
285
333
|
const triggerChangeColumns = newColumns => {
|
|
286
334
|
setColumns(newColumns);
|
|
287
335
|
};
|
|
288
336
|
const triggerChangeData = newData => {
|
|
289
337
|
setIsManualUpdate(true);
|
|
290
338
|
setData(newData);
|
|
339
|
+
// setMergedData(newData)
|
|
291
340
|
onDataChange?.(newData);
|
|
292
341
|
};
|
|
293
342
|
const TableComponent = editAble ? GridEdit : Grid;
|
|
294
343
|
return /*#__PURE__*/React.createElement(TableComponent, _extends({}, rest, {
|
|
295
344
|
t: t,
|
|
345
|
+
locale: locale,
|
|
296
346
|
tableRef: tableRef,
|
|
297
|
-
dataSource: data
|
|
347
|
+
dataSource: data
|
|
348
|
+
// mergedData={mergedData}
|
|
349
|
+
,
|
|
298
350
|
components: {
|
|
299
351
|
header: {
|
|
300
352
|
cell: allowResizing ? ResizableTitle : undefined
|
|
301
353
|
}
|
|
302
354
|
},
|
|
355
|
+
format: format,
|
|
303
356
|
columns: mergedColumns
|
|
304
|
-
//
|
|
357
|
+
// defaultColumns={mergedColumns}
|
|
305
358
|
,
|
|
306
359
|
showSorterTooltip: {
|
|
307
360
|
target: 'sorter-icon'
|
|
@@ -6,7 +6,6 @@ type GridProps<T> = GridTableProps<T> & {
|
|
|
6
6
|
triggerChangeColumns?: (columns: ColumnsTable<T>, type: string) => void;
|
|
7
7
|
triggerChangeData?: () => void;
|
|
8
8
|
tableRef: any;
|
|
9
|
-
getRowKey: any;
|
|
10
9
|
};
|
|
11
10
|
declare const TableGrid: <RecordType extends object>(props: GridProps<RecordType>) => React.JSX.Element;
|
|
12
11
|
export default TableGrid;
|
|
@@ -2,12 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import React, { Fragment, useLayoutEffect, useRef } from 'react';
|
|
3
3
|
import { createStyles } from 'antd-style';
|
|
4
4
|
import { numericFormatter } from "react-numeric-component";
|
|
5
|
-
|
|
6
|
-
import { Table, Toolbar } from "rc-master-ui";
|
|
7
|
-
// import { conductCheck } from 'rc-tree/lib/utils/conductUtil';
|
|
8
|
-
// import { devUseWarning } from '../../_util/warning';
|
|
9
|
-
// import { arrAdd, arrDel } from 'rc-tree/lib/util';
|
|
10
|
-
|
|
5
|
+
import { Empty, Table, Toolbar } from "rc-master-ui";
|
|
11
6
|
import 'dayjs/locale/es';
|
|
12
7
|
import 'dayjs/locale/vi';
|
|
13
8
|
import ContextMenu from "./ContextMenu";
|
|
@@ -20,15 +15,7 @@ import { flatColumns } from "./hooks/useColumns";
|
|
|
20
15
|
import Pagination from "rc-master-ui/es/pagination";
|
|
21
16
|
import ComponentSpinner from "./LoadingSpinner";
|
|
22
17
|
import { ColumnsChoose } from "./ColumnsChoose";
|
|
23
|
-
// import {useMergedState} from "rc-util";
|
|
24
18
|
import useMergedState from "rc-util/es/hooks/useMergedState";
|
|
25
|
-
// import {convertDataToEntities} from "rc-tree/lib/utils/treeUtil";
|
|
26
|
-
// import type {DataNode} from "rc-tree/lib/interface";
|
|
27
|
-
// import {devUseWarning} from "antd/es/_util/warning";
|
|
28
|
-
// import type {GetCheckDisabled} from "rc-tree/es/interface";
|
|
29
|
-
// import useLazyKVMap from "antd/es/table/hooks/useLazyKVMap";
|
|
30
|
-
// import useMultipleSelect from "rc-master-ui/es/_util/hooks/useMultipleSelect";
|
|
31
|
-
|
|
32
19
|
const convertFilters = filters => {
|
|
33
20
|
const result = [];
|
|
34
21
|
filters.forEach(({
|
|
@@ -96,26 +83,14 @@ const useStyle = createStyles(({
|
|
|
96
83
|
// type OnChange = NonNullable<TableProps<any>['onChange']>;
|
|
97
84
|
|
|
98
85
|
const EMPTY_LIST = [];
|
|
99
|
-
|
|
100
|
-
// const flattenData = <RecordType extends AnyObject = AnyObject>(
|
|
101
|
-
// childrenColumnName: keyof RecordType,
|
|
102
|
-
// data?: RecordType[],
|
|
103
|
-
// ): RecordType[] => {
|
|
104
|
-
// let list: RecordType[] = [];
|
|
105
|
-
// (data || []).forEach((record) => {
|
|
106
|
-
// list.push(record);
|
|
107
|
-
// if (record && typeof record === 'object' && childrenColumnName in record) {
|
|
108
|
-
// list = [...list, ...flattenData<RecordType>(childrenColumnName, record[childrenColumnName])];
|
|
109
|
-
// }
|
|
110
|
-
// });
|
|
111
|
-
// return list;
|
|
112
|
-
// };
|
|
113
|
-
|
|
114
86
|
const TableGrid = props => {
|
|
115
87
|
const {
|
|
116
88
|
columns,
|
|
117
89
|
tableRef,
|
|
118
90
|
dataSource,
|
|
91
|
+
locale,
|
|
92
|
+
expandable,
|
|
93
|
+
// mergedData,
|
|
119
94
|
title,
|
|
120
95
|
format,
|
|
121
96
|
virtual = true,
|
|
@@ -133,7 +108,7 @@ const TableGrid = props => {
|
|
|
133
108
|
selectionSettings,
|
|
134
109
|
rowSelection,
|
|
135
110
|
rowSelected,
|
|
136
|
-
rowKey,
|
|
111
|
+
rowKey = 'id',
|
|
137
112
|
pagination,
|
|
138
113
|
scroll,
|
|
139
114
|
onFilterClick,
|
|
@@ -141,7 +116,7 @@ const TableGrid = props => {
|
|
|
141
116
|
loading,
|
|
142
117
|
triggerChangeColumns,
|
|
143
118
|
summary,
|
|
144
|
-
|
|
119
|
+
showToolbar,
|
|
145
120
|
onSorter,
|
|
146
121
|
...rest
|
|
147
122
|
} = props;
|
|
@@ -151,18 +126,22 @@ const TableGrid = props => {
|
|
|
151
126
|
const {
|
|
152
127
|
mode,
|
|
153
128
|
type,
|
|
154
|
-
|
|
129
|
+
checkboxOnly,
|
|
155
130
|
hideSelectAll,
|
|
156
131
|
columnWidth,
|
|
157
132
|
selectedRowKeys,
|
|
158
133
|
defaultSelectedRowKeys
|
|
159
|
-
// getCheckboxProps,
|
|
160
|
-
// checkStrictly = true
|
|
161
134
|
} = selectionSettings || {};
|
|
162
135
|
const clickRef = useRef(null);
|
|
163
136
|
const menuRef = useRef(null);
|
|
164
137
|
const viewportWidth = window.innerWidth;
|
|
165
138
|
const viewportHeight = window.innerHeight;
|
|
139
|
+
|
|
140
|
+
// const defaultSelected = useMemo(() => {
|
|
141
|
+
// return defaultSelectedRowKeys ?? []
|
|
142
|
+
//
|
|
143
|
+
// }, [defaultSelectedRowKeys])
|
|
144
|
+
|
|
166
145
|
const [menuVisible, setMenuVisible] = React.useState(false);
|
|
167
146
|
const [selectedRowData, setSelectedRowData] = React.useState(null);
|
|
168
147
|
const [position, setPosition] = React.useState({
|
|
@@ -172,10 +151,15 @@ const TableGrid = props => {
|
|
|
172
151
|
viewportHeight
|
|
173
152
|
});
|
|
174
153
|
|
|
154
|
+
// const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>(defaultSelected);
|
|
155
|
+
|
|
175
156
|
// ========================= Keys =========================
|
|
176
157
|
const [mergedSelectedKeys, setMergedSelectedKeys] = useMergedState(selectedRowKeys || defaultSelectedRowKeys || EMPTY_LIST, {
|
|
177
158
|
value: selectedRowKeys
|
|
178
159
|
});
|
|
160
|
+
|
|
161
|
+
// Reset if rowSelection reset
|
|
162
|
+
|
|
179
163
|
React.useEffect(() => {
|
|
180
164
|
if (!selectionSettings) {
|
|
181
165
|
setMergedSelectedKeys(EMPTY_LIST);
|
|
@@ -248,6 +232,19 @@ const TableGrid = props => {
|
|
|
248
232
|
});
|
|
249
233
|
}
|
|
250
234
|
};
|
|
235
|
+
const handleRowClick = () => () => {
|
|
236
|
+
// const key = getRowKey(record, index);
|
|
237
|
+
|
|
238
|
+
if (checkboxOnly !== true) {
|
|
239
|
+
if (type === 'single') {}
|
|
240
|
+
}
|
|
241
|
+
if (clickRef.current) return;
|
|
242
|
+
|
|
243
|
+
// @ts-ignore
|
|
244
|
+
clickRef.current = setTimeout(() => {
|
|
245
|
+
clickRef.current = null;
|
|
246
|
+
}, 250);
|
|
247
|
+
};
|
|
251
248
|
const handleRowDoubleClick = (record, index) => e => {
|
|
252
249
|
if (clickRef.current) {
|
|
253
250
|
clearTimeout(clickRef.current);
|
|
@@ -279,7 +276,7 @@ const TableGrid = props => {
|
|
|
279
276
|
// @ts-ignore
|
|
280
277
|
setMergedSelectedKeys(keys);
|
|
281
278
|
rowSelected?.({
|
|
282
|
-
selected:
|
|
279
|
+
selected: selectedRows,
|
|
283
280
|
type: 'rowSelected',
|
|
284
281
|
rowData: selectedRow
|
|
285
282
|
});
|
|
@@ -288,8 +285,6 @@ const TableGrid = props => {
|
|
|
288
285
|
};
|
|
289
286
|
const handleChange = sorter => {
|
|
290
287
|
onSorter?.(sorter);
|
|
291
|
-
// setFilteredInfo(filters);
|
|
292
|
-
// setSortedInfo(sorter as Sorts);
|
|
293
288
|
};
|
|
294
289
|
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(ConfigProvider, {
|
|
295
290
|
theme: {
|
|
@@ -310,7 +305,15 @@ const TableGrid = props => {
|
|
|
310
305
|
contextMenuClick: contextMenuClick,
|
|
311
306
|
rowData: selectedRowData
|
|
312
307
|
}), /*#__PURE__*/React.createElement(Table, _extends({
|
|
313
|
-
ref: tableRef
|
|
308
|
+
ref: tableRef
|
|
309
|
+
}, rest, {
|
|
310
|
+
locale: {
|
|
311
|
+
...locale,
|
|
312
|
+
emptyText: /*#__PURE__*/React.createElement(Empty, {
|
|
313
|
+
image: Empty.PRESENTED_IMAGE_SIMPLE,
|
|
314
|
+
description: locale?.emptyText
|
|
315
|
+
})
|
|
316
|
+
},
|
|
314
317
|
loading: {
|
|
315
318
|
spinning: columns && columns.length === 0 || loading === true,
|
|
316
319
|
indicator: /*#__PURE__*/React.createElement(ComponentSpinner, null)
|
|
@@ -319,7 +322,7 @@ const TableGrid = props => {
|
|
|
319
322
|
// className={styles.customTable}
|
|
320
323
|
,
|
|
321
324
|
className: classNames(className, {
|
|
322
|
-
'table-none-column-select': mode === undefined && type !== 'multiple'
|
|
325
|
+
'table-none-column-select': selectionSettings?.mode === undefined && selectionSettings?.type !== 'multiple'
|
|
323
326
|
}, styles.customTable),
|
|
324
327
|
bordered: true,
|
|
325
328
|
virtual: virtual,
|
|
@@ -333,18 +336,17 @@ const TableGrid = props => {
|
|
|
333
336
|
onRow: (data, index) => {
|
|
334
337
|
return {
|
|
335
338
|
onDoubleClick: handleRowDoubleClick(data, index),
|
|
336
|
-
// onClick: handleRowClick
|
|
339
|
+
// onClick: handleRowClick,
|
|
340
|
+
onClick: handleRowClick(),
|
|
337
341
|
onContextMenu: onContextMenu(data)
|
|
338
342
|
};
|
|
339
343
|
},
|
|
340
344
|
rowSelection: {
|
|
341
345
|
...selectionSettings,
|
|
342
|
-
type: mode === 'checkbox' || type === 'multiple' ? 'checkbox' : "radio",
|
|
346
|
+
type: selectionSettings?.mode === 'checkbox' || type === 'multiple' ? 'checkbox' : "radio",
|
|
343
347
|
columnWidth: !mode ? 0.0000001 : columnWidth ?? 50,
|
|
344
348
|
onChange: onSelectChange,
|
|
345
349
|
// selectedRowKeys: mode === 'checkbox' && type === 'single' ? selectedRowKeys : undefined,
|
|
346
|
-
// selectedRowKeys: mode === 'checkbox' && type === 'single' ? mergedSelectedKeys : undefined,
|
|
347
|
-
|
|
348
350
|
selectedRowKeys: mergedSelectedKeys,
|
|
349
351
|
defaultSelectedRowKeys: selectionSettings?.defaultSelectedRowKeys,
|
|
350
352
|
preserveSelectedRowKeys: true,
|
|
@@ -395,43 +397,80 @@ const TableGrid = props => {
|
|
|
395
397
|
onFilter?.(convertFilters(val));
|
|
396
398
|
},
|
|
397
399
|
onChange: (paging, filters, sorter) => handleChange(sorter),
|
|
398
|
-
title: () => {
|
|
399
|
-
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", null, title?.(dataSource)),
|
|
400
|
+
title: showToolbar === false ? undefined : () => {
|
|
401
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", null, title?.(dataSource)), /*#__PURE__*/React.createElement("div", {
|
|
400
402
|
style: {
|
|
401
403
|
display: 'flex',
|
|
402
|
-
justifyContent: 'space-between'
|
|
404
|
+
justifyContent: 'space-between',
|
|
405
|
+
alignItems: 'center'
|
|
403
406
|
}
|
|
404
|
-
}, /*#__PURE__*/React.createElement(Toolbar
|
|
407
|
+
}, toolbarItems && toolbarItems?.length > 0 && /*#__PURE__*/React.createElement(Toolbar
|
|
408
|
+
// @ts-ignore
|
|
409
|
+
, {
|
|
405
410
|
style: {
|
|
406
|
-
width:
|
|
411
|
+
width: `calc(100% - 650px`
|
|
407
412
|
},
|
|
408
413
|
items: toolbarItems ?? [],
|
|
409
|
-
mode: '
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
+
mode: 'scroll'
|
|
415
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
416
|
+
style: {
|
|
417
|
+
display: 'flex',
|
|
418
|
+
justifyContent: 'space-between',
|
|
419
|
+
alignItems: 'center'
|
|
420
|
+
}
|
|
421
|
+
}, pagination && pagination.onChange && pagination?.position && pagination?.position[0] === 'topRight' && /*#__PURE__*/React.createElement(Pagination, _extends({
|
|
422
|
+
showSizeChanger: true,
|
|
423
|
+
responsive: true,
|
|
424
|
+
size: 'small',
|
|
425
|
+
rootClassName: 'top-pagination'
|
|
426
|
+
// @ts-ignore
|
|
427
|
+
,
|
|
428
|
+
showTotal: (total, range) => `${range[0]}-${range[1]} / ${total} ${t ? t(pagination?.locale?.items ?? 'items') : 'items'}`
|
|
429
|
+
}, pagination)), showColumnChoose && /*#__PURE__*/React.createElement(ColumnsChoose, {
|
|
414
430
|
columns: columns,
|
|
415
431
|
t: t,
|
|
416
432
|
triggerChangeColumns: triggerChangeColumns
|
|
417
|
-
})
|
|
418
|
-
}
|
|
433
|
+
}))));
|
|
434
|
+
},
|
|
435
|
+
expandable: {
|
|
436
|
+
expandIconColumnIndex: 3,
|
|
437
|
+
defaultExpandAllRows: true,
|
|
438
|
+
indentSize: 25,
|
|
439
|
+
...expandable,
|
|
440
|
+
expandIcon: args => {
|
|
441
|
+
const {
|
|
442
|
+
record,
|
|
443
|
+
expanded,
|
|
444
|
+
onExpand
|
|
445
|
+
} = args;
|
|
419
446
|
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
447
|
+
// @ts-ignore
|
|
448
|
+
if (record?.children && record?.children?.length > 0 || record?.isChildren) {
|
|
449
|
+
return expanded ? /*#__PURE__*/React.createElement("button", {
|
|
450
|
+
onClick: e => {
|
|
451
|
+
e.preventDefault();
|
|
452
|
+
e.stopPropagation();
|
|
453
|
+
onExpand(record, e);
|
|
454
|
+
},
|
|
455
|
+
className: 'ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded'
|
|
456
|
+
}) : /*#__PURE__*/React.createElement("button", {
|
|
457
|
+
onClick: e => {
|
|
458
|
+
e.preventDefault();
|
|
459
|
+
e.stopPropagation();
|
|
460
|
+
onExpand(record, e);
|
|
461
|
+
},
|
|
462
|
+
className: 'ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed'
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
}
|
|
425
466
|
}
|
|
426
|
-
}
|
|
467
|
+
})), pagination && pagination.onChange && !pagination.position && /*#__PURE__*/React.createElement(Pagination
|
|
427
468
|
// style={{padding: '0.75rem 1rem'}}
|
|
428
469
|
, _extends({
|
|
429
470
|
showSizeChanger: true,
|
|
430
471
|
responsive: true,
|
|
431
|
-
size: 'small'
|
|
432
|
-
|
|
433
|
-
,
|
|
434
|
-
showTotal: (total, range) => `${range[0]}-${range[1]} / ${total} ${t ? t(pagination?.locale?.items ?? 'items') : 'items'}`
|
|
472
|
+
size: 'small',
|
|
473
|
+
showTotal: (total, range) => `${range[0]}-${range[1]} / ${total} items`
|
|
435
474
|
}, pagination))));
|
|
436
475
|
};
|
|
437
476
|
export default TableGrid;
|