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