es-grid-template 1.8.59 → 1.8.61
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/ColumnsChoose.js +4 -321
- package/es/grid-component/InternalTable.js +61 -68
- package/es/grid-component/TableGrid.js +18 -14
- package/es/grid-component/TempTable.js +0 -4
- package/es/grid-component/hooks/utils.d.ts +1 -0
- package/es/grid-component/hooks/utils.js +25 -1
- package/es/grid-component/table/GridEdit.js +8 -4
- package/es/grid-component/table/Group.js +22 -6
- package/es/grid-component/table/InfiniteTable.js +1 -1
- package/es/grid-component/type.d.ts +8 -2
- package/es/table-component/hook/useColumns.js +1 -0
- package/lib/grid-component/ColumnsChoose.js +4 -321
- package/lib/grid-component/InternalTable.js +61 -67
- package/lib/grid-component/TableGrid.js +18 -14
- package/lib/grid-component/TempTable.js +0 -4
- package/lib/grid-component/hooks/utils.d.ts +1 -0
- package/lib/grid-component/hooks/utils.js +28 -3
- package/lib/grid-component/table/GridEdit.js +8 -4
- package/lib/grid-component/table/Group.js +22 -6
- package/lib/grid-component/table/InfiniteTable.js +1 -1
- package/lib/grid-component/type.d.ts +8 -2
- package/lib/table-component/hook/useColumns.js +1 -0
- package/package.json +1 -1
|
@@ -1,326 +1,7 @@
|
|
|
1
|
-
// import React, {Fragment, useMemo, useState} from "react"
|
|
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
|
-
//
|
|
223
|
-
// // const rs1 = updateColumns(propsColumns, selectedKeys)
|
|
224
|
-
// const rs1 = updateColumns(propsColumns, mergedSelectedKeys)
|
|
225
|
-
//
|
|
226
|
-
//
|
|
227
|
-
// triggerChangeColumns?.(rs1, 'columnChoose')
|
|
228
|
-
//
|
|
229
|
-
// hide()
|
|
230
|
-
//
|
|
231
|
-
// }
|
|
232
|
-
//
|
|
233
|
-
// const handleCancel = () => {
|
|
234
|
-
// // setSelectedKeys(defaultSelectedKeys)
|
|
235
|
-
// hide()
|
|
236
|
-
// }
|
|
237
|
-
//
|
|
238
|
-
//
|
|
239
|
-
// return (
|
|
240
|
-
// <Fragment>
|
|
241
|
-
// <Popover
|
|
242
|
-
// placement={'bottomLeft'}
|
|
243
|
-
// content={
|
|
244
|
-
// <div style={{minWidth: 250}}>
|
|
245
|
-
// <Input style={{ marginBottom: 8 }} placeholder={t ? t("Search") : 'Search'} prefix={<SearchOutlined />} onChange={onChange} />
|
|
246
|
-
//
|
|
247
|
-
// <Tree
|
|
248
|
-
// onExpand={onExpand}
|
|
249
|
-
// // expandedKeys={expandedKeys}
|
|
250
|
-
// autoExpandParent={autoExpandParent}
|
|
251
|
-
// // treeData={treeData}
|
|
252
|
-
// treeData={columns}
|
|
253
|
-
// defaultExpandAll={true}
|
|
254
|
-
// checkable={true}
|
|
255
|
-
// // onSelect={(keys, info) => {
|
|
256
|
-
// // const key = info.node.key
|
|
257
|
-
// //
|
|
258
|
-
// // const find = findItemByKey(columns, 'key', key)
|
|
259
|
-
// //
|
|
260
|
-
// // // const tmpColumn
|
|
261
|
-
// //
|
|
262
|
-
// // // if (selectedKeys.includes(key as string)) {
|
|
263
|
-
// // // const rssss = findKeyPath(columns, key as string)
|
|
264
|
-
// // // const rs = selectedKeys.filter(item => !rssss.includes(item));
|
|
265
|
-
// // //
|
|
266
|
-
// // // setSelectedKeys(rs)
|
|
267
|
-
// // // } else {
|
|
268
|
-
// //
|
|
269
|
-
// // // const rs = [...selectedKeys, keys[0]]
|
|
270
|
-
// //
|
|
271
|
-
// // // setSelectedKeys(keys)
|
|
272
|
-
// // // }
|
|
273
|
-
// // }}
|
|
274
|
-
// onCheck={(keys) => onCheck(keys as string[])}
|
|
275
|
-
//
|
|
276
|
-
//
|
|
277
|
-
// multiple={true}
|
|
278
|
-
// // checkedKeys={selectedKeys}
|
|
279
|
-
//
|
|
280
|
-
// defaultCheckedKeys={mergedSelectedKeys}
|
|
281
|
-
// // defaultCheckedKeys={defaultSelectedKeys}
|
|
282
|
-
// // selectedKeys={[]}
|
|
283
|
-
//
|
|
284
|
-
// height={window.innerHeight - 200}
|
|
285
|
-
//
|
|
286
|
-
// />
|
|
287
|
-
//
|
|
288
|
-
//
|
|
289
|
-
// <BoxAction className={'px-1'}>
|
|
290
|
-
// <Button
|
|
291
|
-
// // className={classnames('btn-action btn-action-submit', {
|
|
292
|
-
// // // disable: !columns.find((item) => item.visible !== false || item.visible)
|
|
293
|
-
// // })}
|
|
294
|
-
// onClick={handleAccept}
|
|
295
|
-
// // disabled={!columns.find((item) => item.visible !== false || item.visible)}
|
|
296
|
-
// >
|
|
297
|
-
// {t ? t('OK') : 'OK'}
|
|
298
|
-
// {/*{'OK'}*/}
|
|
299
|
-
// </Button>
|
|
300
|
-
//
|
|
301
|
-
// {/*<Button className={'btn-action btn-action-cancel'} onClick={hide} >{('Cancel') }</Button>*/}
|
|
302
|
-
// <Button className={'btn-action btn-action-cancel'} onClick={handleCancel} >{t ? t('Cancel') : 'Cancel' }</Button>
|
|
303
|
-
// </BoxAction>
|
|
304
|
-
// </div>
|
|
305
|
-
// }
|
|
306
|
-
// trigger="click"
|
|
307
|
-
// open={clicked}
|
|
308
|
-
// onOpenChange={handleClickChange}
|
|
309
|
-
// arrow={false}
|
|
310
|
-
// >
|
|
311
|
-
// <Tooltip arrow={false} title={'Cài đặt'} >
|
|
312
|
-
// <SettingOutlined size={16} color={'#555555'} style={{fontSize: 16, color: '#555555'}} />
|
|
313
|
-
// </Tooltip>
|
|
314
|
-
//
|
|
315
|
-
// </Popover>
|
|
316
|
-
// </Fragment>
|
|
317
|
-
// )
|
|
318
|
-
// }
|
|
319
|
-
|
|
320
1
|
import React, { Fragment, useEffect, useMemo, useState } from "react";
|
|
321
2
|
import styled from "styled-components";
|
|
322
3
|
import { Button, Input, Popover, Tooltip } from "antd";
|
|
323
|
-
import {
|
|
4
|
+
import { Settings } from "becoxy-icons";
|
|
324
5
|
import { getVisibleColumnKeys, updateColumns } from "./hooks";
|
|
325
6
|
|
|
326
7
|
// import type {TableColumnsType} from "rc-master-ui";
|
|
@@ -543,5 +224,7 @@ export const ColumnsChoose = props => {
|
|
|
543
224
|
}, /*#__PURE__*/React.createElement(Tooltip, {
|
|
544
225
|
arrow: false,
|
|
545
226
|
title: 'Cài đặt'
|
|
546
|
-
}, /*#__PURE__*/React.createElement(
|
|
227
|
+
}, /*#__PURE__*/React.createElement(Settings, {
|
|
228
|
+
fontSize: 16
|
|
229
|
+
}))));
|
|
547
230
|
};
|
|
@@ -2,9 +2,10 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import React, { createContext, Fragment, useCallback, useContext, useState } from 'react';
|
|
3
3
|
import 'react-resizable/css/styles.css';
|
|
4
4
|
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
|
5
|
-
import { addRowIdArray, booleanOperator, convertFilters, convertFlatColumn, filterDataByColumns4, findItemByKey, findItemPath, flattenArray, getAllRowKey, getFormat, getTypeFilter, groupArrayByColumns, isNullOrUndefined, numberOperator, removeColumns, removeInvisibleColumns, stringOperator, translateOption, unFlattenData, updateArrayByKey, updateColumnsByGroup,
|
|
5
|
+
import { addRowIdArray, booleanOperator, convertFilters, convertFlatColumn, filterDataByColumns4, findItemByKey, findItemPath, flattenArray, getAllRowKey, getFormat, getTypeFilter, groupArrayByColumns, isNullOrUndefined, numberOperator, removeColumns, removeInvisibleColumns, stringOperator, sumByField, translateOption, unFlattenData, updateArrayByKey, updateColumnsByGroup,
|
|
6
6
|
// updateData,
|
|
7
7
|
updateOrInsert } from "./hooks";
|
|
8
|
+
import ReactDOMServer from 'react-dom/server';
|
|
8
9
|
import dayjs from "dayjs";
|
|
9
10
|
import 'dayjs/locale/es';
|
|
10
11
|
import 'dayjs/locale/vi';
|
|
@@ -12,7 +13,7 @@ import 'dayjs/locale/vi';
|
|
|
12
13
|
// import GridEdit from "./table/GridEdit"
|
|
13
14
|
// import InfiniteTable from "./table/InfiniteTable";
|
|
14
15
|
|
|
15
|
-
import Grid from "./table/Grid"
|
|
16
|
+
// import Grid from "./table/Grid"
|
|
16
17
|
import en from "rc-master-ui/es/date-picker/locale/en_US";
|
|
17
18
|
import vi from "rc-master-ui/es/date-picker/locale/vi_VN";
|
|
18
19
|
import enDr from "rc-master-ui/es/locales/en_US";
|
|
@@ -115,15 +116,12 @@ const ResizableTitle = props => {
|
|
|
115
116
|
})))
|
|
116
117
|
);
|
|
117
118
|
};
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
}));
|
|
126
|
-
};
|
|
119
|
+
|
|
120
|
+
// const TableBodyCell = (props: any) => {
|
|
121
|
+
// const dragState = useContext<DragIndexState>(DragIndexContext)
|
|
122
|
+
// return <div {...props} style={{ ...props.style, ...dragActiveStyle(dragState, props.id) }} />
|
|
123
|
+
// }
|
|
124
|
+
|
|
127
125
|
const SortableHeaderCell = ({
|
|
128
126
|
children,
|
|
129
127
|
columnKey
|
|
@@ -189,6 +187,8 @@ const InternalTable = props => {
|
|
|
189
187
|
onSorter,
|
|
190
188
|
defaultSorter,
|
|
191
189
|
toolbarItems,
|
|
190
|
+
allowSortering,
|
|
191
|
+
allowFiltering,
|
|
192
192
|
...rest
|
|
193
193
|
} = props;
|
|
194
194
|
const id = React.useMemo(() => {
|
|
@@ -243,30 +243,22 @@ const InternalTable = props => {
|
|
|
243
243
|
active: -1,
|
|
244
244
|
over: -1
|
|
245
245
|
});
|
|
246
|
-
const [tooltipContent, setTooltipContent] = useState('')
|
|
246
|
+
// const [tooltipContent, setTooltipContent] = useState<any>('')
|
|
247
|
+
|
|
247
248
|
const [filterStates, setFilterState] = React.useState(null);
|
|
248
249
|
const [isFullScreen, setIsFullScreen] = React.useState(false);
|
|
250
|
+
const [isOpenTooltip, setIsOpenTooltip] = React.useState(false);
|
|
249
251
|
const mergedData = React.useMemo(() => {
|
|
250
|
-
if (
|
|
252
|
+
if (groupSetting && groupSetting.client !== false) {
|
|
251
253
|
return groupArrayByColumns(dataSource, groupColumns);
|
|
252
254
|
}
|
|
253
255
|
return addRowIdArray(dataSource);
|
|
254
|
-
}, [dataSource,
|
|
256
|
+
}, [dataSource, groupColumns, groupSetting?.client]);
|
|
255
257
|
|
|
256
258
|
// ========================= Keys =========================
|
|
257
259
|
const [mergedFilterKeys, setMergedFilterKeys] = useMergedState(getAllRowKey(mergedData), {
|
|
258
260
|
value: undefined
|
|
259
261
|
});
|
|
260
|
-
//
|
|
261
|
-
// const originData = React.useMemo(() => {
|
|
262
|
-
//
|
|
263
|
-
// if (groupAble && groupSetting && groupSetting.client !== false) {
|
|
264
|
-
// return groupArrayByColumns(dataSource, groupColumns)
|
|
265
|
-
// }
|
|
266
|
-
// return addRowIdArray(dataSource)
|
|
267
|
-
//
|
|
268
|
-
// }, [dataSource, groupAble, groupColumns, groupSetting])
|
|
269
|
-
|
|
270
262
|
const [columns, setColumns] = React.useState([]);
|
|
271
263
|
React.useEffect(() => {
|
|
272
264
|
const totalHeight = propsHeight;
|
|
@@ -445,7 +437,7 @@ const InternalTable = props => {
|
|
|
445
437
|
wrapSettings: wrapSettings
|
|
446
438
|
})),
|
|
447
439
|
// ellipsis: editAble || column.ellipsis !== false && wrapSettings && wrapSettings.wrapMode !== 'Content' && wrapSettings.wrapMode !== 'Both',
|
|
448
|
-
ellipsis: column.ellipsis !== false
|
|
440
|
+
ellipsis: column.ellipsis !== false || wrapSettings && wrapSettings.wrapMode !== 'Content' && wrapSettings.wrapMode !== 'Both',
|
|
449
441
|
// ellipsis: false,
|
|
450
442
|
// ellipsis: column.ellipsis !== false,
|
|
451
443
|
|
|
@@ -504,17 +496,17 @@ const InternalTable = props => {
|
|
|
504
496
|
}
|
|
505
497
|
return {
|
|
506
498
|
...transformedColumn,
|
|
507
|
-
...(transformedColumn.allowFiltering === false ? {} : {
|
|
499
|
+
...(transformedColumn.allowFiltering === false || allowFiltering === false ? {} : {
|
|
508
500
|
...getColumnSearchProps(column)
|
|
509
501
|
}),
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
// }),
|
|
502
|
+
sorter: column.sorter === false || allowSortering === false ? undefined : {
|
|
503
|
+
// @ts-ignore
|
|
504
|
+
compare: (a, b) => onSorter ? a : a[column.field] - b[column.field],
|
|
505
|
+
multiple: sortMultiple ? colIndex : undefined
|
|
506
|
+
},
|
|
516
507
|
// @ts-ignore
|
|
517
|
-
sorter: (a, b) => a[column.field] - b[column.field],
|
|
508
|
+
// sorter: (a, b) => a[column.field] - b[column.field],
|
|
509
|
+
|
|
518
510
|
sortIcon: args => {
|
|
519
511
|
const {
|
|
520
512
|
sortOrder
|
|
@@ -561,6 +553,10 @@ const InternalTable = props => {
|
|
|
561
553
|
${wrapSettings && wrapSettings.wrapMode === 'Content' ? 'ui-rc-table-cell-ellipsis' : ''}`
|
|
562
554
|
}),
|
|
563
555
|
onCell: (data, index) => {
|
|
556
|
+
const tooltipContent = isOpenTooltip === false ? '' : column?.tooltipDescription ? typeof column.tooltipDescription === 'function' ? column.tooltipDescription({
|
|
557
|
+
value: data[column.field ?? ''],
|
|
558
|
+
record: data
|
|
559
|
+
}) : column.tooltipDescription : column.template && typeof column.template !== 'function' ? column.template : data[column.field ?? ''];
|
|
564
560
|
return {
|
|
565
561
|
id: `${column.field}`,
|
|
566
562
|
colSpan: groupColumns && data.children && column.field === firstNonGroupColumn?.field ? 2 : groupColumns && data.children && nonGroupColumns[1].field === column.field ? 0 : 1,
|
|
@@ -571,7 +567,23 @@ const InternalTable = props => {
|
|
|
571
567
|
'cell-group-fixed': groupColumns && data.children && column.field === firstNonGroupColumn?.field
|
|
572
568
|
}),
|
|
573
569
|
// 'data-tooltip-id': "tooltip-cell-content"
|
|
574
|
-
'data-tooltip-id': `${id}-tooltip-cell-content
|
|
570
|
+
'data-tooltip-id': `${id}-tooltip-cell-content`,
|
|
571
|
+
"data-tooltip-html": ReactDOMServer.renderToStaticMarkup( /*#__PURE__*/React.createElement(React.Fragment, null, tooltipContent)),
|
|
572
|
+
onMouseEnter: e => {
|
|
573
|
+
if (e.target.firstChild?.clientWidth <= e.target.firstChild?.scrollWidth) {
|
|
574
|
+
if (e.target.firstChild?.clientWidth < e.target.firstChild?.scrollWidth) {
|
|
575
|
+
setIsOpenTooltip(true);
|
|
576
|
+
} else {
|
|
577
|
+
setIsOpenTooltip(false);
|
|
578
|
+
}
|
|
579
|
+
} else {
|
|
580
|
+
if (e.target.clientWidth < e.target.scrollWidth) {
|
|
581
|
+
setIsOpenTooltip(true);
|
|
582
|
+
} else {
|
|
583
|
+
setIsOpenTooltip(false);
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
}
|
|
575
587
|
};
|
|
576
588
|
},
|
|
577
589
|
render: (value, record, rowIndex) => {
|
|
@@ -593,6 +605,10 @@ const InternalTable = props => {
|
|
|
593
605
|
}
|
|
594
606
|
return /*#__PURE__*/React.createElement("span", null, currentGroupColumn?.headerText, ": ", renderContent(currentGroupColumn, record[record.field], record, rowIndex, colIndex, false, cellFormat));
|
|
595
607
|
}
|
|
608
|
+
if (groupAble && record.children && column.sumGroup === true && column.type === 'number') {
|
|
609
|
+
const sumValue = sumByField(filterDataByColumns4(record.children, [], []), column?.field);
|
|
610
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, sumValue);
|
|
611
|
+
}
|
|
596
612
|
return renderContent(column, value, record, rowIndex, colIndex, false, cellFormat);
|
|
597
613
|
},
|
|
598
614
|
// defaultSortOrder: 'ascend',
|
|
@@ -914,10 +930,7 @@ const InternalTable = props => {
|
|
|
914
930
|
const handleFullScreen = () => {
|
|
915
931
|
setIsFullScreen(!isFullScreen);
|
|
916
932
|
};
|
|
917
|
-
|
|
918
|
-
// const TableComponent = infiniteScroll ? InfiniteTable : (groupAble ? Group : editAble ? GridEdit : Grid)
|
|
919
|
-
const TableComponent = groupAble ? Group : Grid;
|
|
920
|
-
return /*#__PURE__*/React.createElement(Fragment, null, true && /*#__PURE__*/React.createElement(DndContext, {
|
|
933
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(DndContext, {
|
|
921
934
|
sensors: sensors,
|
|
922
935
|
modifiers: [restrictToHorizontalAxis],
|
|
923
936
|
onDragEnd: onDragEnd,
|
|
@@ -928,7 +941,7 @@ const InternalTable = props => {
|
|
|
928
941
|
strategy: horizontalListSortingStrategy
|
|
929
942
|
}, /*#__PURE__*/React.createElement(DragIndexContext.Provider, {
|
|
930
943
|
value: dragIndex
|
|
931
|
-
}, /*#__PURE__*/React.createElement(
|
|
944
|
+
}, /*#__PURE__*/React.createElement(Group, _extends({}, rest, {
|
|
932
945
|
t: t,
|
|
933
946
|
id: id,
|
|
934
947
|
locale: locale,
|
|
@@ -956,34 +969,24 @@ const InternalTable = props => {
|
|
|
956
969
|
groupColumns: groupColumns,
|
|
957
970
|
commandClick: triggerCommandClick,
|
|
958
971
|
summary: summary,
|
|
959
|
-
pagination: pagination
|
|
960
|
-
// scroll={{ y: 300 - 41 - 7 }} // scroll height auto, không quá 600
|
|
961
|
-
// scroll={{ y: scrollHeight - (summary ? 0 : 7) }} // scroll height auto, không quá 600
|
|
962
|
-
,
|
|
963
|
-
|
|
972
|
+
pagination: pagination,
|
|
964
973
|
scroll: scrollHeight - (summary ? 1 : 1) < 0 ? {
|
|
965
974
|
y: 500
|
|
966
975
|
} : {
|
|
967
976
|
y: scrollHeight - (summary ? 1 : 1)
|
|
968
977
|
} // scroll height auto, không quá 600
|
|
969
|
-
|
|
970
|
-
// height={isFullScreen ? windowSize.innerHeight - 100 : propsHeight}
|
|
971
978
|
,
|
|
972
979
|
height: propsHeight,
|
|
973
980
|
scrollHeight: scrollHeight,
|
|
981
|
+
toolbarItems: toolbarItems,
|
|
974
982
|
components: {
|
|
975
983
|
header: {
|
|
976
984
|
cell: ResizableTitle
|
|
977
|
-
},
|
|
978
|
-
body: {
|
|
979
|
-
cell: TableBodyCell
|
|
980
985
|
}
|
|
986
|
+
// body: { cell: TableBodyCell }
|
|
981
987
|
},
|
|
982
|
-
setTooltipContent: setTooltipContent,
|
|
983
988
|
onFilter: val => {
|
|
984
989
|
handleOnFilter(val);
|
|
985
|
-
// triggerFilter?.(convertFilters(val))
|
|
986
|
-
// onFilter?.(convertFilters(val))
|
|
987
990
|
},
|
|
988
991
|
setMergedFilterKeys: setMergedFilterKeys,
|
|
989
992
|
mergedFilterKeys: mergedFilterKeys,
|
|
@@ -991,10 +994,6 @@ const InternalTable = props => {
|
|
|
991
994
|
onChange: handleChange,
|
|
992
995
|
handleFullScreen: handleFullScreen,
|
|
993
996
|
isFullScreen: isFullScreen
|
|
994
|
-
|
|
995
|
-
// onChange={(paging, filters, sorter) => {
|
|
996
|
-
// handleChange(sorter)
|
|
997
|
-
// }}
|
|
998
997
|
})))), /*#__PURE__*/React.createElement(DragOverlay, {
|
|
999
998
|
style: {
|
|
1000
999
|
minWidth: 100,
|
|
@@ -1046,7 +1045,7 @@ const InternalTable = props => {
|
|
|
1046
1045
|
strategy: horizontalListSortingStrategy
|
|
1047
1046
|
}, /*#__PURE__*/React.createElement(DragIndexContext.Provider, {
|
|
1048
1047
|
value: dragIndex
|
|
1049
|
-
}, /*#__PURE__*/React.createElement(
|
|
1048
|
+
}, /*#__PURE__*/React.createElement(Group, _extends({}, rest, {
|
|
1050
1049
|
t: t,
|
|
1051
1050
|
id: faker.string.alpha(20),
|
|
1052
1051
|
locale: locale,
|
|
@@ -1088,12 +1087,12 @@ const InternalTable = props => {
|
|
|
1088
1087
|
components: {
|
|
1089
1088
|
header: {
|
|
1090
1089
|
cell: ResizableTitle
|
|
1091
|
-
},
|
|
1092
|
-
body: {
|
|
1093
|
-
cell: TableBodyCell
|
|
1094
1090
|
}
|
|
1095
|
-
|
|
1096
|
-
|
|
1091
|
+
// body: { cell: TableBodyCell }
|
|
1092
|
+
}
|
|
1093
|
+
// setTooltipContent={setTooltipContent}
|
|
1094
|
+
,
|
|
1095
|
+
|
|
1097
1096
|
onFilter: val => {
|
|
1098
1097
|
handleOnFilter(val);
|
|
1099
1098
|
// triggerFilter?.(convertFilters(val))
|
|
@@ -1130,12 +1129,6 @@ const InternalTable = props => {
|
|
|
1130
1129
|
id: `${id}-tooltip-cell-content`,
|
|
1131
1130
|
style: {
|
|
1132
1131
|
zIndex: 1999
|
|
1133
|
-
},
|
|
1134
|
-
render: () => {
|
|
1135
|
-
if (tooltipContent) {
|
|
1136
|
-
return /*#__PURE__*/React.createElement("span", null, typeof tooltipContent === 'function' ? tooltipContent() : tooltipContent);
|
|
1137
|
-
}
|
|
1138
|
-
return undefined;
|
|
1139
1132
|
}
|
|
1140
1133
|
}));
|
|
1141
1134
|
};
|
|
@@ -62,7 +62,7 @@ const TableGrid = props => {
|
|
|
62
62
|
rowHoverable,
|
|
63
63
|
title,
|
|
64
64
|
format,
|
|
65
|
-
|
|
65
|
+
virtualRow = true,
|
|
66
66
|
t,
|
|
67
67
|
lang,
|
|
68
68
|
contextMenuOpen,
|
|
@@ -322,14 +322,18 @@ const TableGrid = props => {
|
|
|
322
322
|
'table-none-column-select': selectionSettings?.mode === undefined && selectionSettings?.type !== 'multiple'
|
|
323
323
|
}, styles.customTable),
|
|
324
324
|
bordered: true,
|
|
325
|
-
virtual:
|
|
325
|
+
virtual: virtualRow,
|
|
326
326
|
columns: columns,
|
|
327
327
|
rowKey: rowKey,
|
|
328
328
|
rowHoverable: rowHoverable,
|
|
329
329
|
size: "small",
|
|
330
330
|
scroll: scroll ? scroll : {
|
|
331
331
|
y: 500
|
|
332
|
-
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// scroll={{ x: 'max-content', y: 700 }}
|
|
335
|
+
,
|
|
336
|
+
|
|
333
337
|
onRow: (data, index) => {
|
|
334
338
|
return {
|
|
335
339
|
onDoubleClick: handleRowDoubleClick(data, index),
|
|
@@ -380,16 +384,6 @@ const TableGrid = props => {
|
|
|
380
384
|
, {
|
|
381
385
|
items: (toolbarItems ?? []).filter(it => it.position !== 'Bottom'),
|
|
382
386
|
mode: 'scroll'
|
|
383
|
-
})), fullScreen !== false && (isFullScreen ? /*#__PURE__*/React.createElement(Minimize, {
|
|
384
|
-
fontSize: 16,
|
|
385
|
-
onClick: () => handleFullScreen?.(),
|
|
386
|
-
"data-tooltip-id": "tooltip-icon",
|
|
387
|
-
"data-tooltip-content": t ? t('Minimized') : 'Minimized'
|
|
388
|
-
}) : /*#__PURE__*/React.createElement(Maximize, {
|
|
389
|
-
fontSize: 16,
|
|
390
|
-
onClick: () => handleFullScreen?.(),
|
|
391
|
-
"data-tooltip-id": "tooltip-icon",
|
|
392
|
-
"data-tooltip-content": t ? t('Full screen') : 'Full screen'
|
|
393
387
|
})), /*#__PURE__*/React.createElement("div", {
|
|
394
388
|
style: {
|
|
395
389
|
display: 'flex',
|
|
@@ -405,7 +399,17 @@ const TableGrid = props => {
|
|
|
405
399
|
// @ts-ignore
|
|
406
400
|
,
|
|
407
401
|
showTotal: (total, range) => `${range[0]}-${range[1]} / ${total} ${t ? t(pagination?.locale?.items ?? 'items') : 'items'}`
|
|
408
|
-
}, pagination)), typeof actionTemplate === 'function' ? actionTemplate() : actionTemplate,
|
|
402
|
+
}, pagination)), typeof actionTemplate === 'function' ? actionTemplate() : actionTemplate, fullScreen !== false && (isFullScreen ? /*#__PURE__*/React.createElement(Minimize, {
|
|
403
|
+
fontSize: 16,
|
|
404
|
+
onClick: () => handleFullScreen?.(),
|
|
405
|
+
"data-tooltip-id": "tooltip-icon",
|
|
406
|
+
"data-tooltip-content": t ? t('Minimized') : 'Minimized'
|
|
407
|
+
}) : /*#__PURE__*/React.createElement(Maximize, {
|
|
408
|
+
fontSize: 16,
|
|
409
|
+
onClick: () => handleFullScreen?.(),
|
|
410
|
+
"data-tooltip-id": "tooltip-icon",
|
|
411
|
+
"data-tooltip-content": t ? t('Full screen') : 'Full screen'
|
|
412
|
+
})), showColumnChoose && /*#__PURE__*/React.createElement(ColumnsChoose, {
|
|
409
413
|
columns: columns,
|
|
410
414
|
t: t,
|
|
411
415
|
columnsGroup: groupColumns,
|