es-grid-template 1.7.24 → 1.7.26
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/table-component/ColumnsChoose.d.ts +6 -3
- package/es/table-component/ColumnsChoose.js +31 -382
- package/es/table-component/InternalTable.js +32 -19
- package/es/table-component/TableContainer.d.ts +11 -2
- package/es/table-component/TableContainer.js +134 -14
- package/es/table-component/TableContainerEdit.d.ts +10 -7
- package/es/table-component/TableContainerEdit.js +158 -65
- package/es/table-component/body/EditableCell.js +14 -11
- package/es/table-component/body/TableBody.d.ts +2 -1
- package/es/table-component/body/TableBody.js +25 -6
- package/es/table-component/body/TableBodyCell.d.ts +2 -0
- package/es/table-component/body/TableBodyCell.js +13 -3
- package/es/table-component/body/TableBodyCellEdit.d.ts +2 -1
- package/es/table-component/body/TableBodyCellEdit.js +159 -34
- package/es/table-component/body/TableBodyRow.js +9 -4
- package/es/table-component/components/ControlCheckbox.js +0 -3
- package/es/table-component/components/async-table-select/index.d.ts +1 -1
- package/es/table-component/components/async-table-select/index.js +1 -0
- package/es/table-component/components/command/Command.d.ts +1 -0
- package/es/table-component/components/command/Command.js +6 -1
- package/es/table-component/footer/TableFooterCell.js +45 -3
- package/es/table-component/footer/TableFooterRow.js +3 -1
- package/es/table-component/header/TableHeadCell.js +31 -12
- package/es/table-component/header/TableHeadRow.js +5 -1
- package/es/table-component/hook/useColumns.d.ts +5 -7
- package/es/table-component/hook/useColumns.js +18 -58
- package/es/table-component/hook/utils.d.ts +12 -0
- package/es/table-component/hook/utils.js +140 -2
- package/es/table-component/style.scss +72 -7
- package/es/table-component/table/Grid.d.ts +3 -2
- package/es/table-component/table/Grid.js +25 -100
- package/es/table-component/type.d.ts +34 -3
- package/es/table-component/useContext.d.ts +5 -50
- package/es/table-component/useContext.js +3 -49
- package/lib/table-component/ColumnsChoose.d.ts +6 -3
- package/lib/table-component/ColumnsChoose.js +29 -381
- package/lib/table-component/InternalTable.js +30 -16
- package/lib/table-component/TableContainer.d.ts +11 -2
- package/lib/table-component/TableContainer.js +135 -14
- package/lib/table-component/TableContainerEdit.d.ts +10 -7
- package/lib/table-component/TableContainerEdit.js +157 -64
- package/lib/table-component/body/EditableCell.js +14 -11
- package/lib/table-component/body/TableBody.d.ts +2 -1
- package/lib/table-component/body/TableBody.js +27 -6
- package/lib/table-component/body/TableBodyCell.d.ts +2 -0
- package/lib/table-component/body/TableBodyCell.js +13 -3
- package/lib/table-component/body/TableBodyCellEdit.d.ts +2 -1
- package/lib/table-component/body/TableBodyCellEdit.js +159 -34
- package/lib/table-component/body/TableBodyRow.js +9 -4
- package/lib/table-component/components/ControlCheckbox.js +0 -3
- package/lib/table-component/components/async-table-select/index.d.ts +1 -1
- package/lib/table-component/components/async-table-select/index.js +2 -0
- package/lib/table-component/components/command/Command.d.ts +1 -0
- package/lib/table-component/components/command/Command.js +6 -1
- package/lib/table-component/footer/TableFooterCell.js +46 -2
- package/lib/table-component/footer/TableFooterRow.js +3 -1
- package/lib/table-component/header/TableHeadCell.js +31 -12
- package/lib/table-component/header/TableHeadRow.js +5 -1
- package/lib/table-component/hook/useColumns.d.ts +5 -7
- package/lib/table-component/hook/useColumns.js +17 -57
- package/lib/table-component/hook/utils.d.ts +12 -0
- package/lib/table-component/hook/utils.js +156 -9
- package/lib/table-component/style.scss +72 -7
- package/lib/table-component/table/Grid.d.ts +3 -2
- package/lib/table-component/table/Grid.js +24 -100
- package/lib/table-component/type.d.ts +34 -3
- package/lib/table-component/useContext.d.ts +5 -50
- package/lib/table-component/useContext.js +4 -50
- package/package.json +2 -2
- package/es/table-component/table/GridEdit.d.ts +0 -23
- package/es/table-component/table/GridEdit.js +0 -282
- package/lib/table-component/table/GridEdit.d.ts +0 -23
- package/lib/table-component/table/GridEdit.js +0 -284
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type { ColumnsTable } from "./type";
|
|
2
|
+
import type { ColumnsTable, ColumnTable } from "./type";
|
|
3
|
+
import type { ColumnDef } from "@tanstack/react-table";
|
|
3
4
|
export type IColumnsChoose<RecordType> = {
|
|
4
|
-
columns:
|
|
5
|
+
columns: ColumnDef<RecordType>[];
|
|
6
|
+
originColumns: ColumnTable[];
|
|
5
7
|
columnsGroup?: string[];
|
|
6
|
-
triggerChangeColumns?: (columns: ColumnsTable<RecordType>, type: string) => void;
|
|
8
|
+
triggerChangeColumns?: (columns: ColumnsTable<RecordType>, keys: string[], type: string) => void;
|
|
7
9
|
t?: any;
|
|
8
10
|
triggerChangeKeys?: any;
|
|
11
|
+
columnHidden: any;
|
|
9
12
|
};
|
|
10
13
|
export declare const ColumnsChoose: <RecordType extends object>(props: IColumnsChoose<RecordType>) => React.JSX.Element;
|
|
@@ -1,336 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
// import styled from "styled-components"
|
|
4
|
-
// import {Button, Input, Popover, Tooltip} from "antd";
|
|
5
|
-
// import {SettingOutlined} from "@ant-design/icons";
|
|
6
|
-
// import {
|
|
7
|
-
// getVisibleColumnKeys,
|
|
8
|
-
// updateColumns
|
|
9
|
-
// } from "./hooks";
|
|
10
|
-
//
|
|
11
|
-
// // import type {TableColumnsType} from "rc-master-ui";
|
|
12
|
-
// import Tree from "rc-master-ui/es/tree";
|
|
13
|
-
// import SearchOutlined from "@ant-design/icons/SearchOutlined";
|
|
14
|
-
// import type {ColumnsTable} from "./type";
|
|
15
|
-
// import useMergedState from "rc-util/lib/hooks/useMergedState";
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
// const BoxAction = styled.div`
|
|
19
|
-
// border-top: 1px solid #c4c4c4;
|
|
20
|
-
// padding-top: .75rem;
|
|
21
|
-
// display: flex;
|
|
22
|
-
// justify-content: end;
|
|
23
|
-
// gap: 10px;
|
|
24
|
-
//
|
|
25
|
-
// .btn-action {
|
|
26
|
-
// background: none !important;
|
|
27
|
-
// border: none !important;
|
|
28
|
-
// &.btn-action-submit {
|
|
29
|
-
// color: #df4318;
|
|
30
|
-
// &:disabled {
|
|
31
|
-
// background-color: #f0f0f0 !important;
|
|
32
|
-
// }
|
|
33
|
-
// &:hover {
|
|
34
|
-
// color: #df4318 !important;
|
|
35
|
-
// }
|
|
36
|
-
// }
|
|
37
|
-
//
|
|
38
|
-
// &:hover {
|
|
39
|
-
// background-color: #f0f0f0 !important;
|
|
40
|
-
// }
|
|
41
|
-
// }
|
|
42
|
-
// `
|
|
43
|
-
//
|
|
44
|
-
// export type IColumnsChoose<RecordType> = {
|
|
45
|
-
// columns: ColumnsTable<RecordType>
|
|
46
|
-
// columnsGroup?: string[]
|
|
47
|
-
// triggerChangeColumns?: (columns: ColumnsTable<RecordType>, type: string) => void
|
|
48
|
-
// t?: any
|
|
49
|
-
//
|
|
50
|
-
// }
|
|
51
|
-
//
|
|
52
|
-
//
|
|
53
|
-
// export const ColumnsChoose = <RecordType extends object>(props: IColumnsChoose<RecordType>) => {
|
|
54
|
-
// const {
|
|
55
|
-
// columns: propsColumns,
|
|
56
|
-
// triggerChangeColumns,
|
|
57
|
-
// t,
|
|
58
|
-
// columnsGroup,
|
|
59
|
-
// } = props
|
|
60
|
-
//
|
|
61
|
-
// // const dataList: { key: React.Key; title: string }[] = [];
|
|
62
|
-
//
|
|
63
|
-
// // const defaultColumns = useMemo(() => {
|
|
64
|
-
// // return propsColumns.filter((it) => it.key || it.dataIndex && it.showColumnChoose !== false)
|
|
65
|
-
// // }, [propsColumns])
|
|
66
|
-
//
|
|
67
|
-
//
|
|
68
|
-
// // const columnsChooseRef: any = useRef()
|
|
69
|
-
// // const searchRef: any = useRef()
|
|
70
|
-
//
|
|
71
|
-
//
|
|
72
|
-
//
|
|
73
|
-
// // const [columns, setColumns] = useState<TableColumnsType>([])
|
|
74
|
-
//
|
|
75
|
-
// // const [selectedKeys, setSelectedKeys] = useState<string[]>([]);
|
|
76
|
-
//
|
|
77
|
-
// // const [isManualUpdate, setIsManualUpdate] = useState(false);
|
|
78
|
-
//
|
|
79
|
-
//
|
|
80
|
-
// // useEffect(() => {
|
|
81
|
-
// //
|
|
82
|
-
// // const defaultColumns = propsColumns.filter((it) => it.key || it.dataIndex && it.showInColumnChoose !== false)
|
|
83
|
-
// // setColumns(defaultColumns as TableColumnsType)
|
|
84
|
-
// //
|
|
85
|
-
// // }, [propsColumns])
|
|
86
|
-
//
|
|
87
|
-
// const columns = useMemo(() => {
|
|
88
|
-
//
|
|
89
|
-
// // return propsColumns.filter((it) => (it.key || it.dataIndex) && it.showInColumnChoose !== false && !columnsGroup?.includes(it.field as string))
|
|
90
|
-
// return propsColumns.filter((it) => (it.key || it.dataIndex) && it.showInColumnChoose !== false)
|
|
91
|
-
// // setColumns(defaultColumns as TableColumnsType)
|
|
92
|
-
// }, [columnsGroup, propsColumns])
|
|
93
|
-
//
|
|
94
|
-
//
|
|
95
|
-
// // useEffect(() => {
|
|
96
|
-
// //
|
|
97
|
-
// // const defaultColumns = propsColumns.filter((it) => it.key || it.dataIndex && it.showInColumnChoose !== false)
|
|
98
|
-
// //
|
|
99
|
-
// // const defaultSelectedKeys = getVisibleColumnKeys(defaultColumns)
|
|
100
|
-
// //
|
|
101
|
-
// // if (!isManualUpdate) {
|
|
102
|
-
// // setSelectedKeys(defaultSelectedKeys)
|
|
103
|
-
// // }
|
|
104
|
-
// // setIsManualUpdate(false);
|
|
105
|
-
// //
|
|
106
|
-
// //
|
|
107
|
-
// // }, [isManualUpdate, propsColumns])
|
|
108
|
-
//
|
|
109
|
-
// const defaultSelectedKeys = React.useMemo(() => {
|
|
110
|
-
//
|
|
111
|
-
// const rs = propsColumns.filter((it) => (it.key || it.dataIndex) && it.showInColumnChoose !== false && !columnsGroup?.includes(it.field as string))
|
|
112
|
-
// return getVisibleColumnKeys(rs)
|
|
113
|
-
//
|
|
114
|
-
// }, [columnsGroup, propsColumns])
|
|
115
|
-
//
|
|
116
|
-
// const [mergedSelectedKeys, setMergedSelectedKeys] = useMergedState(
|
|
117
|
-
// defaultSelectedKeys || [],
|
|
118
|
-
// {
|
|
119
|
-
// value: defaultSelectedKeys,
|
|
120
|
-
// },
|
|
121
|
-
// );
|
|
122
|
-
//
|
|
123
|
-
// //
|
|
124
|
-
// // const defaultSelectedKeys = useMemo(() => {
|
|
125
|
-
// //
|
|
126
|
-
// // return getVisibleColumnKeys(propsColumns)
|
|
127
|
-
// //
|
|
128
|
-
// // }, [propsColumns])
|
|
129
|
-
//
|
|
130
|
-
//
|
|
131
|
-
// const [clicked, setClicked] = useState(false);
|
|
132
|
-
// const [autoExpandParent, setAutoExpandParent] = useState(true);
|
|
133
|
-
//
|
|
134
|
-
//
|
|
135
|
-
// // const treeData = useMemo(() => {
|
|
136
|
-
// // const loop = (data: TreeDataNode[]): TreeDataNode[] =>
|
|
137
|
-
// // data.map((item) => {
|
|
138
|
-
// // const strTitle = item.title as string;
|
|
139
|
-
// // const index = strTitle.indexOf(searchValue);
|
|
140
|
-
// // const beforeStr = strTitle.substring(0, index);
|
|
141
|
-
// // const afterStr = strTitle.slice(index + searchValue.length);
|
|
142
|
-
// // const title =
|
|
143
|
-
// // index > -1 ? (
|
|
144
|
-
// // <span key={item.key}>
|
|
145
|
-
// // {beforeStr}
|
|
146
|
-
// // <span className="site-tree-search-value">{searchValue}</span>
|
|
147
|
-
// // {afterStr}
|
|
148
|
-
// // </span>
|
|
149
|
-
// // ) : (
|
|
150
|
-
// // <span key={item.key}>{strTitle}</span>
|
|
151
|
-
// // );
|
|
152
|
-
// // if (item.children) {
|
|
153
|
-
// // return { title, key: item.key, children: loop(item.children) };
|
|
154
|
-
// // }
|
|
155
|
-
// //
|
|
156
|
-
// // return {
|
|
157
|
-
// // title,
|
|
158
|
-
// // key: item.key,
|
|
159
|
-
// // };
|
|
160
|
-
// // });
|
|
161
|
-
// //
|
|
162
|
-
// // // return loop(defaultData);
|
|
163
|
-
// // return loop(columns as any);
|
|
164
|
-
// // }, [searchValue, columns]);
|
|
165
|
-
//
|
|
166
|
-
//
|
|
167
|
-
// const hide = () => {
|
|
168
|
-
// setClicked(false)
|
|
169
|
-
// }
|
|
170
|
-
//
|
|
171
|
-
// const handleClickChange = (open: boolean) => {
|
|
172
|
-
// setClicked(open)
|
|
173
|
-
// }
|
|
174
|
-
//
|
|
175
|
-
// const onExpand = () => {
|
|
176
|
-
// // setExpandedKeys(newExpandedKeys)
|
|
177
|
-
// setAutoExpandParent(false)
|
|
178
|
-
// }
|
|
179
|
-
//
|
|
180
|
-
// // const getParentKey = (key: React.Key, tree: TreeDataNode[]): React.Key => {
|
|
181
|
-
// // let parentKey: React.Key
|
|
182
|
-
// // for (let i = 0; i < tree.length; i++) {
|
|
183
|
-
// // const node = tree[i]
|
|
184
|
-
// // if (node.children) {
|
|
185
|
-
// // if (node.children.some((item) => item.key === key)) {
|
|
186
|
-
// // parentKey = node.key
|
|
187
|
-
// // } else if (getParentKey(key, node.children)) {
|
|
188
|
-
// // parentKey = getParentKey(key, node.children)
|
|
189
|
-
// // }
|
|
190
|
-
// // }
|
|
191
|
-
// // }
|
|
192
|
-
// // return parentKey!
|
|
193
|
-
// // }
|
|
194
|
-
//
|
|
195
|
-
// // const onChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
196
|
-
// const onChange = () => {
|
|
197
|
-
// // const { value } = e.target
|
|
198
|
-
// // const newExpandedKeys = dataList
|
|
199
|
-
// // .map((item) => {
|
|
200
|
-
// // if (item.title.indexOf(value) > -1) {
|
|
201
|
-
// // return getParentKey(item.key, defaultData)
|
|
202
|
-
// // }
|
|
203
|
-
// // return null
|
|
204
|
-
// // })
|
|
205
|
-
// // .filter((item, i, self): item is React.Key => !!(item && self.indexOf(item) === i))
|
|
206
|
-
// // setExpandedKeys(newExpandedKeys)
|
|
207
|
-
//
|
|
208
|
-
// // setSearchValue(value)
|
|
209
|
-
// setAutoExpandParent(true)
|
|
210
|
-
// };
|
|
211
|
-
//
|
|
212
|
-
// const onCheck = (keys: string[]) => {
|
|
213
|
-
//
|
|
214
|
-
// // setSelectedKeys(keys)
|
|
215
|
-
// setMergedSelectedKeys(keys)
|
|
216
|
-
// // setIsManualUpdate(true)
|
|
217
|
-
//
|
|
218
|
-
// }
|
|
219
|
-
//
|
|
220
|
-
// const handleAccept = () => {
|
|
221
|
-
//
|
|
222
|
-
// console.log('mergedSelectedKeys', mergedSelectedKeys)
|
|
223
|
-
//
|
|
224
|
-
// // const rs1 = updateColumns(propsColumns, selectedKeys)
|
|
225
|
-
// const rs1 = updateColumns(propsColumns, mergedSelectedKeys)
|
|
226
|
-
//
|
|
227
|
-
//
|
|
228
|
-
// triggerChangeColumns?.(rs1, 'columnChoose')
|
|
229
|
-
//
|
|
230
|
-
// hide()
|
|
231
|
-
//
|
|
232
|
-
// }
|
|
233
|
-
//
|
|
234
|
-
// const handleCancel = () => {
|
|
235
|
-
// // setSelectedKeys(defaultSelectedKeys)
|
|
236
|
-
// hide()
|
|
237
|
-
// }
|
|
238
|
-
//
|
|
239
|
-
//
|
|
240
|
-
// return (
|
|
241
|
-
// <Fragment>
|
|
242
|
-
// <Popover
|
|
243
|
-
// placement={'bottomLeft'}
|
|
244
|
-
// content={
|
|
245
|
-
// <div style={{minWidth: 250}}>
|
|
246
|
-
// <Input style={{ marginBottom: 8 }} placeholder={t ? t("Search") : 'Search'} prefix={<SearchOutlined />} onChange={onChange} />
|
|
247
|
-
//
|
|
248
|
-
// <Tree
|
|
249
|
-
// onExpand={onExpand}
|
|
250
|
-
// // expandedKeys={expandedKeys}
|
|
251
|
-
// autoExpandParent={autoExpandParent}
|
|
252
|
-
// // treeData={treeData}
|
|
253
|
-
// treeData={columns}
|
|
254
|
-
// defaultExpandAll={true}
|
|
255
|
-
// checkable={true}
|
|
256
|
-
// // onSelect={(keys, info) => {
|
|
257
|
-
// // const key = info.node.key
|
|
258
|
-
// //
|
|
259
|
-
// // const find = findItemByKey(columns, 'key', key)
|
|
260
|
-
// //
|
|
261
|
-
// // // const tmpColumn
|
|
262
|
-
// //
|
|
263
|
-
// // // if (selectedKeys.includes(key as string)) {
|
|
264
|
-
// // // const rssss = findKeyPath(columns, key as string)
|
|
265
|
-
// // // const rs = selectedKeys.filter(item => !rssss.includes(item));
|
|
266
|
-
// // //
|
|
267
|
-
// // // setSelectedKeys(rs)
|
|
268
|
-
// // // } else {
|
|
269
|
-
// //
|
|
270
|
-
// // // const rs = [...selectedKeys, keys[0]]
|
|
271
|
-
// //
|
|
272
|
-
// // // setSelectedKeys(keys)
|
|
273
|
-
// // // }
|
|
274
|
-
// // }}
|
|
275
|
-
// onCheck={(keys) => onCheck(keys as string[])}
|
|
276
|
-
//
|
|
277
|
-
//
|
|
278
|
-
// multiple={true}
|
|
279
|
-
// // checkedKeys={selectedKeys}
|
|
280
|
-
//
|
|
281
|
-
// defaultCheckedKeys={mergedSelectedKeys}
|
|
282
|
-
// // defaultCheckedKeys={defaultSelectedKeys}
|
|
283
|
-
// // selectedKeys={[]}
|
|
284
|
-
//
|
|
285
|
-
// height={window.innerHeight - 200}
|
|
286
|
-
//
|
|
287
|
-
// />
|
|
288
|
-
//
|
|
289
|
-
//
|
|
290
|
-
// <BoxAction className={'px-1'}>
|
|
291
|
-
// <Button
|
|
292
|
-
// // className={classnames('btn-action btn-action-submit', {
|
|
293
|
-
// // // disable: !columns.find((item) => item.visible !== false || item.visible)
|
|
294
|
-
// // })}
|
|
295
|
-
// onClick={handleAccept}
|
|
296
|
-
// // disabled={!columns.find((item) => item.visible !== false || item.visible)}
|
|
297
|
-
// >
|
|
298
|
-
// {t ? t('OK') : 'OK'}
|
|
299
|
-
// {/*{'OK'}*/}
|
|
300
|
-
// </Button>
|
|
301
|
-
//
|
|
302
|
-
// {/*<Button className={'btn-action btn-action-cancel'} onClick={hide} >{('Cancel') }</Button>*/}
|
|
303
|
-
// <Button className={'btn-action btn-action-cancel'} onClick={handleCancel} >{t ? t('Cancel') : 'Cancel' }</Button>
|
|
304
|
-
// </BoxAction>
|
|
305
|
-
// </div>
|
|
306
|
-
// }
|
|
307
|
-
// trigger="click"
|
|
308
|
-
// open={clicked}
|
|
309
|
-
// onOpenChange={handleClickChange}
|
|
310
|
-
// arrow={false}
|
|
311
|
-
// >
|
|
312
|
-
// <Tooltip arrow={false} title={'Cài đặt'} >
|
|
313
|
-
// <SettingOutlined size={16} color={'#555555'} style={{fontSize: 16, color: '#555555'}} />
|
|
314
|
-
// </Tooltip>
|
|
315
|
-
//
|
|
316
|
-
// </Popover>
|
|
317
|
-
// </Fragment>
|
|
318
|
-
// )
|
|
319
|
-
// }
|
|
320
|
-
|
|
321
|
-
import React, { Fragment, useEffect, useMemo, useState } from "react";
|
|
1
|
+
import useMergedState from "rc-util/es/hooks/useMergedState";
|
|
2
|
+
import React, { Fragment, useState } from "react";
|
|
322
3
|
import styled from "styled-components";
|
|
323
4
|
import { Button, Input, Popover, Tooltip } from "antd";
|
|
324
5
|
import { SettingOutlined } from "@ant-design/icons";
|
|
325
|
-
// import {
|
|
326
|
-
// getVisibleColumnKeys,
|
|
327
|
-
// updateColumns
|
|
328
|
-
// } from "./hooks"
|
|
329
|
-
|
|
330
|
-
// import type {TableColumnsType} from "rc-master-ui";
|
|
331
6
|
import Tree from "rc-master-ui/es/tree";
|
|
332
7
|
import SearchOutlined from "@ant-design/icons/SearchOutlined";
|
|
333
|
-
import {
|
|
8
|
+
import { convertColumnsToTreeData, getVisibleColumnKeys1, updateColumns1 } from "./hook/utils";
|
|
334
9
|
const BoxAction = styled.div.withConfig({
|
|
335
10
|
displayName: "BoxAction",
|
|
336
11
|
componentId: "es-grid-template__sc-jfujqh-0"
|
|
@@ -338,50 +13,24 @@ const BoxAction = styled.div.withConfig({
|
|
|
338
13
|
export const ColumnsChoose = props => {
|
|
339
14
|
const {
|
|
340
15
|
columns: propsColumns,
|
|
341
|
-
|
|
16
|
+
originColumns,
|
|
17
|
+
columnHidden,
|
|
18
|
+
triggerChangeColumns,
|
|
342
19
|
// triggerChangeKeys,
|
|
343
20
|
t,
|
|
344
21
|
columnsGroup
|
|
345
22
|
} = props;
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
const [selectedKeys, setSelectedKeys] = useState([]);
|
|
358
|
-
const [isManualUpdate, setIsManualUpdate] = useState(false);
|
|
359
|
-
|
|
360
|
-
// useEffect(() => {
|
|
361
|
-
//
|
|
362
|
-
// const defaultColumns = propsColumns.filter((it) => it.key || it.dataIndex && it.showInColumnChoose !== false)
|
|
363
|
-
// setColumns(defaultColumns as TableColumnsType)
|
|
364
|
-
//
|
|
365
|
-
// }, [propsColumns])
|
|
366
|
-
|
|
367
|
-
const columns = useMemo(() => {
|
|
368
|
-
return propsColumns.filter(it => it.field && it.showInColumnChoose !== false);
|
|
369
|
-
// setColumns(defaultColumns as TableColumnsType)
|
|
370
|
-
}, [propsColumns]);
|
|
371
|
-
console.log('columns', columns);
|
|
372
|
-
useEffect(() => {
|
|
373
|
-
// const defaultColumns = propsColumns.filter((it) => it.key || it.dataIndex && it.showInColumnChoose !== false)
|
|
374
|
-
const defaultColumns = propsColumns.filter(it => it.field && it.showInColumnChoose !== false && !columnsGroup?.includes(it.field));
|
|
375
|
-
const defaultSelectedKeys = getVisibleColumnKeys(defaultColumns);
|
|
376
|
-
if (!isManualUpdate) {
|
|
377
|
-
setSelectedKeys(defaultSelectedKeys);
|
|
378
|
-
}
|
|
379
|
-
setIsManualUpdate(false);
|
|
380
|
-
}, [propsColumns]);
|
|
381
|
-
const defaultSelectedKeys = useMemo(() => {
|
|
382
|
-
const defaultColumns = propsColumns.filter(it => it.field && it.showInColumnChoose !== false && !columnsGroup?.includes(it.field));
|
|
383
|
-
return getVisibleColumnKeys(defaultColumns);
|
|
384
|
-
}, [columnsGroup, propsColumns]);
|
|
23
|
+
const treeColumns = React.useMemo(() => {
|
|
24
|
+
return convertColumnsToTreeData(propsColumns, columnsGroup);
|
|
25
|
+
}, [propsColumns, columnsGroup]);
|
|
26
|
+
const defaultSelectedKeys = React.useMemo(() => {
|
|
27
|
+
const defaultColumns = originColumns.filter(it => it.field && it.showInColumnChoose !== false && !columnsGroup?.includes(it.field));
|
|
28
|
+
const aa = Object.keys(columnHidden);
|
|
29
|
+
return getVisibleColumnKeys1(defaultColumns).filter(it => !aa.includes(it));
|
|
30
|
+
}, [columnHidden, columnsGroup, originColumns]);
|
|
31
|
+
const [mergedSelectedKeys, setMergedSelectedKeys] = useMergedState(defaultSelectedKeys && defaultSelectedKeys.length ? defaultSelectedKeys : undefined, {
|
|
32
|
+
value: undefined
|
|
33
|
+
});
|
|
385
34
|
const [clicked, setClicked] = useState(false);
|
|
386
35
|
const [autoExpandParent, setAutoExpandParent] = useState(true);
|
|
387
36
|
|
|
@@ -459,20 +108,17 @@ export const ColumnsChoose = props => {
|
|
|
459
108
|
setAutoExpandParent(true);
|
|
460
109
|
};
|
|
461
110
|
const onCheck = keys => {
|
|
462
|
-
setSelectedKeys(keys)
|
|
463
|
-
setIsManualUpdate(true)
|
|
111
|
+
// setSelectedKeys(keys)
|
|
112
|
+
// setIsManualUpdate(true)
|
|
113
|
+
setMergedSelectedKeys(keys);
|
|
464
114
|
};
|
|
465
115
|
const handleAccept = () => {
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
// triggerChangeKeys?.(selectedKeys)
|
|
469
|
-
|
|
470
|
-
// triggerChangeColumns?.(rs1, 'columnChoose')
|
|
471
|
-
|
|
116
|
+
const rs1 = updateColumns1(originColumns, mergedSelectedKeys ?? []);
|
|
117
|
+
triggerChangeColumns?.(rs1, mergedSelectedKeys ?? [], 'columnChoose');
|
|
472
118
|
hide();
|
|
473
119
|
};
|
|
474
120
|
const handleCancel = () => {
|
|
475
|
-
|
|
121
|
+
setMergedSelectedKeys(defaultSelectedKeys);
|
|
476
122
|
hide();
|
|
477
123
|
};
|
|
478
124
|
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(Popover, {
|
|
@@ -497,7 +143,7 @@ export const ColumnsChoose = props => {
|
|
|
497
143
|
// treeData={treeData}
|
|
498
144
|
// treeData={columns.filter((it) => !columnsGroup?.includes(it.field as string))}
|
|
499
145
|
,
|
|
500
|
-
treeData:
|
|
146
|
+
treeData: treeColumns,
|
|
501
147
|
defaultExpandAll: true,
|
|
502
148
|
checkable: true
|
|
503
149
|
// onSelect={(keys, info) => {
|
|
@@ -521,11 +167,14 @@ export const ColumnsChoose = props => {
|
|
|
521
167
|
// }}
|
|
522
168
|
,
|
|
523
169
|
onCheck: keys => onCheck(keys),
|
|
524
|
-
multiple: true
|
|
525
|
-
checkedKeys
|
|
526
|
-
|
|
527
|
-
|
|
170
|
+
multiple: true
|
|
171
|
+
// checkedKeys={selectedKeys}
|
|
172
|
+
,
|
|
173
|
+
checkedKeys: mergedSelectedKeys || defaultSelectedKeys
|
|
174
|
+
|
|
175
|
+
// defaultCheckedKeys={selectedKeys}
|
|
528
176
|
,
|
|
177
|
+
defaultCheckedKeys: defaultSelectedKeys,
|
|
529
178
|
selectedKeys: []
|
|
530
179
|
|
|
531
180
|
// height={window.innerHeight - 200}
|
|
@@ -29,13 +29,15 @@ import Grid from "./table/Grid";
|
|
|
29
29
|
|
|
30
30
|
import { Tooltip } from 'react-tooltip';
|
|
31
31
|
import ContextMenu from "./ContextMenu";
|
|
32
|
-
import { addRowIdArray,
|
|
32
|
+
import { addRowIdArray, convertToObj,
|
|
33
33
|
// convertFilters,
|
|
34
|
-
filterDataByColumns,
|
|
34
|
+
filterDataByColumns, flatColumns2,
|
|
35
35
|
// filterDataByColumns,
|
|
36
|
-
getAllRowKey, getFixedFields, getInvisibleColumns, groupArrayByColumns } from "./hook/utils";
|
|
37
|
-
import GridEdit from
|
|
36
|
+
getAllRowKey, getDiffent2Array, getFixedFields, getInvisibleColumns, groupArrayByColumns } from "./hook/utils";
|
|
37
|
+
// import GridEdit from './table/GridEdit'
|
|
38
38
|
import { convertToTanStackColumns } from "./hook/useColumns";
|
|
39
|
+
// import { columns111 } from '../test-2/columns'
|
|
40
|
+
|
|
39
41
|
dayjs.extend(customParseFormat);
|
|
40
42
|
|
|
41
43
|
// const MySwal = withReactContent(Swal)
|
|
@@ -60,7 +62,7 @@ const InternalTable = props => {
|
|
|
60
62
|
infiniteScroll,
|
|
61
63
|
// wrapSettings,
|
|
62
64
|
// onFilter,
|
|
63
|
-
expandable,
|
|
65
|
+
// expandable,
|
|
64
66
|
contextMenuItems: propContextMenuItems,
|
|
65
67
|
contextMenuHidden,
|
|
66
68
|
contextMenuClick,
|
|
@@ -119,9 +121,6 @@ const InternalTable = props => {
|
|
|
119
121
|
|
|
120
122
|
const [filterStates, setFilterState] = React.useState(null);
|
|
121
123
|
const [sorterStates, setSorterStates] = React.useState([]);
|
|
122
|
-
|
|
123
|
-
// const [isFullScreen, setIsFullScreen] = React.useState<boolean>(false)
|
|
124
|
-
|
|
125
124
|
const [expanded, setExpanded] = React.useState({});
|
|
126
125
|
const convertData = React.useMemo(() => {
|
|
127
126
|
if (groupAble && groupSetting && groupSetting.client !== false) {
|
|
@@ -131,16 +130,18 @@ const InternalTable = props => {
|
|
|
131
130
|
}, [dataSource, groupAble, groupColumns, groupSetting]);
|
|
132
131
|
const mergedColumns = React.useMemo(() => {
|
|
133
132
|
return convertToTanStackColumns({
|
|
133
|
+
t,
|
|
134
134
|
columns,
|
|
135
|
-
expanded,
|
|
136
|
-
setExpanded,
|
|
137
|
-
expandable,
|
|
135
|
+
// expanded,
|
|
136
|
+
// setExpanded,
|
|
137
|
+
// expandable,
|
|
138
138
|
format,
|
|
139
139
|
editAble
|
|
140
140
|
});
|
|
141
141
|
|
|
142
142
|
// return convertToTanStackColumns<RecordType>(columns, expanded, setExpanded, expandable)
|
|
143
|
-
}, [
|
|
143
|
+
}, [t, columns, format, editAble]);
|
|
144
|
+
console.log('mergedColumns', mergedColumns);
|
|
144
145
|
const columnPinning = React.useMemo(() => {
|
|
145
146
|
return {
|
|
146
147
|
left: getFixedFields(columns, 'left'),
|
|
@@ -158,6 +159,14 @@ const InternalTable = props => {
|
|
|
158
159
|
const columnVisibility = React.useMemo(() => {
|
|
159
160
|
return getInvisibleColumns(columns);
|
|
160
161
|
}, [columns]);
|
|
162
|
+
const [columnsHiddenKeys, setColumnsHiddenKeys] = useMergedState(undefined, {
|
|
163
|
+
value: undefined
|
|
164
|
+
});
|
|
165
|
+
const triggerChangeColumns = (cols, keys) => {
|
|
166
|
+
const aa = flatColumns2(columns).map(it => it.field);
|
|
167
|
+
const rsss = getDiffent2Array(aa, keys);
|
|
168
|
+
setColumnsHiddenKeys(rsss);
|
|
169
|
+
};
|
|
161
170
|
const contextMenuItems = React.useMemo(() => {
|
|
162
171
|
if (typeof contextMenuHidden === 'function' && propContextMenuItems && selectedRowData) {
|
|
163
172
|
const hiddenItems = contextMenuHidden({
|
|
@@ -251,24 +260,26 @@ const InternalTable = props => {
|
|
|
251
260
|
};
|
|
252
261
|
|
|
253
262
|
// const TableComponent = infiniteScroll ? InfiniteTable : (groupAble ? Group : editAble ? GridEdit : Grid)
|
|
254
|
-
const TableComponent =
|
|
255
|
-
|
|
263
|
+
// const TableComponent = Grid
|
|
264
|
+
|
|
265
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(Grid, _extends({}, rest, {
|
|
256
266
|
t: t,
|
|
257
267
|
id: id,
|
|
258
268
|
prefix: prefix,
|
|
259
269
|
originData: convertData,
|
|
260
270
|
dataSource: mergedData,
|
|
261
271
|
locale: locale,
|
|
262
|
-
format: format
|
|
272
|
+
format: format
|
|
273
|
+
// columns={columns111 as any}
|
|
274
|
+
,
|
|
263
275
|
columns: mergedColumns,
|
|
264
276
|
propsColumns: columns,
|
|
265
277
|
rowKey: rowKey,
|
|
266
278
|
groupSetting: groupSetting,
|
|
267
279
|
groupAble: groupAble,
|
|
268
280
|
groupColumns: groupColumns,
|
|
269
|
-
isFullScreen: false,
|
|
270
281
|
columnPinning: columnPinning,
|
|
271
|
-
|
|
282
|
+
columnHidden: columnsHiddenKeys ? convertToObj(columnsHiddenKeys) : columnVisibility,
|
|
272
283
|
triggerFilter: setFilterState,
|
|
273
284
|
triggerSorter: setSorterStates,
|
|
274
285
|
setMergedFilterKeys: setMergedFilterKeys,
|
|
@@ -276,7 +287,9 @@ const InternalTable = props => {
|
|
|
276
287
|
expanded: expanded,
|
|
277
288
|
onContextMenu: onContextMenu,
|
|
278
289
|
contextMenuItems: contextMenuItems,
|
|
279
|
-
editAble: editAble
|
|
290
|
+
editAble: editAble,
|
|
291
|
+
triggerChangeColumns: triggerChangeColumns,
|
|
292
|
+
setExpanded: setExpanded
|
|
280
293
|
})), menuVisible && /*#__PURE__*/React.createElement(ContextMenu, {
|
|
281
294
|
open: menuVisible,
|
|
282
295
|
pos: position,
|
|
@@ -286,7 +299,7 @@ const InternalTable = props => {
|
|
|
286
299
|
contextMenuClick: contextMenuClick,
|
|
287
300
|
rowData: selectedRowData
|
|
288
301
|
}), /*#__PURE__*/React.createElement(Tooltip, {
|
|
289
|
-
id: `${id}-tooltip-
|
|
302
|
+
id: `${id}-tooltip-content`,
|
|
290
303
|
style: {
|
|
291
304
|
zIndex: 1999
|
|
292
305
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Dispatch, SetStateAction } from 'react';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import type { Table } from '@tanstack/react-table';
|
|
4
|
-
import type { TableProps } from './type';
|
|
3
|
+
import type { ColumnDef, Table } from '@tanstack/react-table';
|
|
4
|
+
import type { ColumnsTable, TableProps } from './type';
|
|
5
5
|
type TableContainerProps<T> = Omit<TableProps<T>, 'columns'> & {
|
|
6
6
|
table: Table<T>;
|
|
7
7
|
prefix: string;
|
|
@@ -17,6 +17,15 @@ type TableContainerProps<T> = Omit<TableProps<T>, 'columns'> & {
|
|
|
17
17
|
setFilterChange: Dispatch<SetStateAction<boolean>>;
|
|
18
18
|
onContextMenu?: (data: T) => (event: any) => void;
|
|
19
19
|
tableHeight?: number;
|
|
20
|
+
triggerPaste?: (pastedRows: T[], pastedColumnsArray: string[], newData: T[], copyRows: T[]) => void;
|
|
21
|
+
mergedFilterKeys?: any;
|
|
22
|
+
setMergedFilterKeys?: any;
|
|
23
|
+
setExpanded?: any;
|
|
24
|
+
expanded?: any;
|
|
25
|
+
columns: ColumnDef<T>[];
|
|
26
|
+
propsColumns: ColumnsTable;
|
|
27
|
+
triggerChangeColumns: any;
|
|
28
|
+
columnHidden: any;
|
|
20
29
|
};
|
|
21
30
|
declare const TableContainer: <RecordType extends object>(props: TableContainerProps<RecordType>) => React.JSX.Element;
|
|
22
31
|
export default TableContainer;
|