es-grid-template 0.0.7 → 0.0.8
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/CheckboxFilter.d.ts +1 -1
- package/es/CheckboxFilter.js +7 -10
- package/es/ColumnsChoose.d.ts +2 -3
- package/es/ColumnsChoose.js +65 -69
- package/es/FilterSearch.js +1 -1
- package/es/{GridTable.d.ts → InternalTable.d.ts} +2 -2
- package/es/InternalTable.js +185 -0
- package/es/LoadingSpinner.d.ts +3 -0
- package/es/LoadingSpinner.js +20 -0
- package/es/TableGrid.d.ts +10 -0
- package/es/{GridTable.js → TableGrid.js} +395 -267
- package/es/hooks/constant.js +1 -1
- package/es/hooks/utils.d.ts +2 -1
- package/es/hooks/utils.js +23 -3
- package/es/index.d.ts +2 -2
- package/es/index.js +2 -2
- package/es/styles.scss +287 -21
- package/es/type.d.ts +17 -5
- package/lib/CheckboxFilter.d.ts +1 -1
- package/lib/CheckboxFilter.js +11 -13
- package/lib/ColumnsChoose.d.ts +2 -3
- package/lib/ColumnsChoose.js +65 -69
- package/lib/FilterSearch.js +2 -2
- package/lib/{GridTable.d.ts → InternalTable.d.ts} +2 -2
- package/lib/InternalTable.js +194 -0
- package/lib/LoadingSpinner.d.ts +3 -0
- package/lib/LoadingSpinner.js +29 -0
- package/lib/TableGrid.d.ts +10 -0
- package/lib/{GridTable.js → TableGrid.js} +401 -274
- package/lib/hooks/constant.js +1 -1
- package/lib/hooks/utils.d.ts +2 -1
- package/lib/hooks/utils.js +26 -5
- package/lib/index.d.ts +2 -2
- package/lib/index.js +2 -2
- package/lib/styles.scss +287 -21
- package/lib/type.d.ts +17 -5
- package/package.json +6 -4
|
@@ -1,49 +1,33 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import React, { Fragment, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
3
|
-
import { Table } from "ui-rc";
|
|
4
3
|
import { Resizable } from 'react-resizable';
|
|
5
4
|
import { createStyles } from 'antd-style';
|
|
6
5
|
import { NumericFormat, numericFormatter } from "react-numeric-component";
|
|
7
|
-
// import {Button, DatePicker, Input, Space} from "antd"
|
|
8
6
|
import { SearchOutlined } from '@ant-design/icons';
|
|
9
|
-
import { Select,
|
|
10
|
-
// import {flatColumns} from "../../hooks/useColumns";
|
|
11
|
-
// import {
|
|
12
|
-
// checkDecimalSeparator,
|
|
13
|
-
// checkThousandSeparator,
|
|
14
|
-
// convertDateToDayjs,
|
|
15
|
-
// convertDayjsToDate,
|
|
16
|
-
// getTypeFilter,
|
|
17
|
-
// getDatepickerFormat,
|
|
18
|
-
// isColor,
|
|
19
|
-
// isEmpty,
|
|
20
|
-
// numberOperator,
|
|
21
|
-
// sumDataByField,
|
|
22
|
-
// translateOption
|
|
23
|
-
// } from "../hooks";
|
|
24
|
-
|
|
25
|
-
// import type {ColumnsType, ColumnType, GridTableProps} from "../../type";
|
|
7
|
+
import { Select, DatePicker, Input, Table, Toolbar } from "rc-master-ui";
|
|
26
8
|
import dayjs from "dayjs";
|
|
27
9
|
import 'dayjs/locale/es';
|
|
28
10
|
import 'dayjs/locale/vi';
|
|
29
11
|
import "./styles.scss";
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
// import vi from 'antd/es/date-picker/locale/vi_VN'
|
|
34
|
-
|
|
12
|
+
import en from 'rc-master-ui/es/date-picker/locale/en_US';
|
|
13
|
+
import vi from 'rc-master-ui/es/date-picker/locale/vi_VN';
|
|
35
14
|
import moment from "moment";
|
|
36
15
|
import CheckboxFilter from "./CheckboxFilter";
|
|
37
16
|
import ContextMenu from "./ContextMenu";
|
|
38
|
-
import { ColumnsChoose } from "./ColumnsChoose";
|
|
39
17
|
import classNames from "classnames";
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
import { Button } from "antd";
|
|
18
|
+
import { checkDecimalSeparator, checkThousandSeparator, convertDateToDayjs, convertDayjsToDate, getTypeFilter, getDatepickerFormat, isColor, isEmpty, numberOperator, sumDataByField, translateOption, updateArrayByKey
|
|
19
|
+
// updateArrayByKey
|
|
20
|
+
} from "./hooks";
|
|
21
|
+
import { Button, ConfigProvider } from "antd";
|
|
46
22
|
import { flatColumns } from "./hooks/useColumns";
|
|
23
|
+
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
|
24
|
+
import Pagination from "rc-master-ui/es/pagination";
|
|
25
|
+
// import styled from "styled-components";
|
|
26
|
+
import Space from "rc-master-ui/es/space";
|
|
27
|
+
import { FilterFill } from "becoxy-icons";
|
|
28
|
+
import ComponentSpinner from "./LoadingSpinner";
|
|
29
|
+
import { ColumnsChoose } from "./ColumnsChoose";
|
|
30
|
+
dayjs.extend(customParseFormat);
|
|
47
31
|
const {
|
|
48
32
|
RangePicker
|
|
49
33
|
} = DatePicker;
|
|
@@ -56,25 +40,25 @@ const convertFilters = filters => {
|
|
|
56
40
|
operator
|
|
57
41
|
}) => {
|
|
58
42
|
if (!filteredKeys || filteredKeys.length === 0) return;
|
|
59
|
-
if (column
|
|
43
|
+
if (column?.typeFilter === "DateRange" && filteredKeys.length === 2) {
|
|
60
44
|
result.push({
|
|
61
45
|
key,
|
|
62
|
-
field: column
|
|
46
|
+
field: column?.dataIndex,
|
|
63
47
|
value: filteredKeys[0],
|
|
64
48
|
predicate: "and",
|
|
65
49
|
operator: "greaterthanorequal"
|
|
66
50
|
}, {
|
|
67
51
|
key,
|
|
68
|
-
field: column
|
|
52
|
+
field: column?.dataIndex,
|
|
69
53
|
value: filteredKeys[1],
|
|
70
54
|
predicate: "and",
|
|
71
55
|
operator: "lessthanorequal"
|
|
72
56
|
});
|
|
73
|
-
} else if (column
|
|
57
|
+
} else if (column?.typeFilter === 'Checkbox') {
|
|
74
58
|
filteredKeys.forEach(value => {
|
|
75
59
|
result.push({
|
|
76
60
|
key,
|
|
77
|
-
field: column
|
|
61
|
+
field: column?.dataIndex,
|
|
78
62
|
value,
|
|
79
63
|
predicate: "or",
|
|
80
64
|
operator
|
|
@@ -83,7 +67,7 @@ const convertFilters = filters => {
|
|
|
83
67
|
} else {
|
|
84
68
|
result.push({
|
|
85
69
|
key,
|
|
86
|
-
field: column
|
|
70
|
+
field: column?.dataIndex,
|
|
87
71
|
value: filteredKeys[0],
|
|
88
72
|
predicate: 'and',
|
|
89
73
|
operator
|
|
@@ -140,10 +124,13 @@ const useStyle = createStyles(({
|
|
|
140
124
|
`
|
|
141
125
|
};
|
|
142
126
|
});
|
|
143
|
-
|
|
127
|
+
// type OnChange = NonNullable<TableProps<any>['onChange']>;
|
|
128
|
+
|
|
129
|
+
const TableGrid = props => {
|
|
144
130
|
const {
|
|
145
131
|
columns: defaultColumns,
|
|
146
132
|
dataSource,
|
|
133
|
+
title,
|
|
147
134
|
format,
|
|
148
135
|
virtual = true,
|
|
149
136
|
t,
|
|
@@ -160,23 +147,27 @@ const GridTable = props => {
|
|
|
160
147
|
rowSelection,
|
|
161
148
|
rowSelected,
|
|
162
149
|
rowKey = 'id',
|
|
150
|
+
pagination,
|
|
151
|
+
scroll,
|
|
152
|
+
onFilterClick,
|
|
153
|
+
dataSourceFilter: propDataSourceFilter,
|
|
154
|
+
loading,
|
|
155
|
+
setColumns,
|
|
156
|
+
// dataSourceFilter,
|
|
163
157
|
...rest
|
|
164
158
|
} = props;
|
|
165
159
|
const {
|
|
166
160
|
styles
|
|
167
161
|
} = useStyle();
|
|
162
|
+
const locale = lang && lang === 'en' ? en : vi;
|
|
163
|
+
// const locale = vi
|
|
168
164
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
//
|
|
176
|
-
// }
|
|
177
|
-
// }
|
|
178
|
-
|
|
179
|
-
// console.log('buddhistLocale', buddhistLocale)
|
|
165
|
+
const buddhistLocale = {
|
|
166
|
+
...locale,
|
|
167
|
+
lang: {
|
|
168
|
+
...locale.lang
|
|
169
|
+
}
|
|
170
|
+
};
|
|
180
171
|
const clickRef = useRef(null);
|
|
181
172
|
const searchInput = useRef(null);
|
|
182
173
|
const menuRef = useRef(null);
|
|
@@ -193,9 +184,11 @@ const GridTable = props => {
|
|
|
193
184
|
viewportWidth,
|
|
194
185
|
viewportHeight
|
|
195
186
|
});
|
|
196
|
-
// const [filters, setFilters] = React.useState<any[]>([])
|
|
197
|
-
|
|
198
187
|
const [selectedRowKeys, setSelectedRowKeys] = useState(defaultSelected);
|
|
188
|
+
const [dataSourceFilter, setDataSourceFilter] = useState(propDataSourceFilter ?? []);
|
|
189
|
+
React.useEffect(() => {
|
|
190
|
+
setDataSourceFilter(propDataSourceFilter ?? []);
|
|
191
|
+
}, [propDataSourceFilter]);
|
|
199
192
|
const contextMenuItems = React.useMemo(() => {
|
|
200
193
|
if (typeof contextMenuHidden === "function" && propContextMenuItems && selectedRowData) {
|
|
201
194
|
const hiddenItems = contextMenuHidden({
|
|
@@ -213,15 +206,15 @@ const GridTable = props => {
|
|
|
213
206
|
useLayoutEffect(() => {
|
|
214
207
|
setMenuVisible(false);
|
|
215
208
|
}, []);
|
|
216
|
-
const handleSearch = (selectedKeys, confirm
|
|
217
|
-
// dataIndex: any
|
|
218
|
-
) => {
|
|
209
|
+
const handleSearch = (selectedKeys, confirm) => {
|
|
219
210
|
confirm();
|
|
220
211
|
};
|
|
221
212
|
const renderFilter = (column, selectedKeys, setSelectedKeys, confirm, visible, searchValue, setSearchValue) => {
|
|
222
213
|
const type = getTypeFilter(column);
|
|
223
|
-
const dateFormat = getDatepickerFormat(column
|
|
224
|
-
const dateRangeFormat = getDatepickerFormat(column
|
|
214
|
+
const dateFormat = getDatepickerFormat(column?.typeFilter ?? column?.type, column) ?? 'DD/MM/YYYY';
|
|
215
|
+
const dateRangeFormat = getDatepickerFormat(column?.type, column) ?? 'DD/MM/YYYY';
|
|
216
|
+
const find = dataSourceFilter?.find(it => it.key === column?.key);
|
|
217
|
+
const options = find ? find.data : [];
|
|
225
218
|
switch (type) {
|
|
226
219
|
case 'Number':
|
|
227
220
|
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
@@ -282,17 +275,16 @@ const GridTable = props => {
|
|
|
282
275
|
format: {
|
|
283
276
|
format: dateFormat,
|
|
284
277
|
type: 'mask'
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
,
|
|
278
|
+
},
|
|
279
|
+
locale: buddhistLocale,
|
|
288
280
|
style: {
|
|
289
281
|
width: '100%',
|
|
290
282
|
height: '100%'
|
|
291
283
|
},
|
|
292
284
|
value: dateValue,
|
|
293
285
|
defaultValue: dateValue,
|
|
294
|
-
placeholder: column
|
|
295
|
-
onChange: (
|
|
286
|
+
placeholder: column?.placeholder,
|
|
287
|
+
onChange: (date, dateString) => {
|
|
296
288
|
const newDateValue = dateString ? moment(convertDayjsToDate(dateString, dateFormat)).format() : null;
|
|
297
289
|
setSelectedKeys(newDateValue ? [newDateValue] : []);
|
|
298
290
|
}
|
|
@@ -325,11 +317,136 @@ const GridTable = props => {
|
|
|
325
317
|
// popupClassName={'adv-popup-container'}
|
|
326
318
|
// getPopupContainer={() => menuRef.current}
|
|
327
319
|
}))));
|
|
320
|
+
case 'Week':
|
|
321
|
+
const weekValue = !isEmpty(selectedKeys[0]) ? dayjs(selectedKeys[0], dateFormat) : null;
|
|
322
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
323
|
+
className: 'mb-1'
|
|
324
|
+
}, /*#__PURE__*/React.createElement(DatePicker, {
|
|
325
|
+
format: {
|
|
326
|
+
format: dateFormat,
|
|
327
|
+
type: 'mask'
|
|
328
|
+
},
|
|
329
|
+
picker: 'week',
|
|
330
|
+
locale: buddhistLocale,
|
|
331
|
+
style: {
|
|
332
|
+
width: '100%',
|
|
333
|
+
height: '100%'
|
|
334
|
+
},
|
|
335
|
+
value: weekValue,
|
|
336
|
+
defaultValue: weekValue,
|
|
337
|
+
placeholder: column?.placeholder,
|
|
338
|
+
onChange: (date, dateString) => {
|
|
339
|
+
const newDateValue = dateString ?? null;
|
|
340
|
+
setSelectedKeys(newDateValue ? [newDateValue] : []);
|
|
341
|
+
}
|
|
342
|
+
}))));
|
|
343
|
+
case 'Month':
|
|
344
|
+
const monthValue = !isEmpty(selectedKeys[0]) ? dayjs(selectedKeys[0], dateFormat) : null;
|
|
345
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
346
|
+
className: 'mb-1'
|
|
347
|
+
}, /*#__PURE__*/React.createElement(DatePicker, {
|
|
348
|
+
format: {
|
|
349
|
+
format: dateFormat,
|
|
350
|
+
type: 'mask'
|
|
351
|
+
},
|
|
352
|
+
picker: 'month',
|
|
353
|
+
locale: buddhistLocale,
|
|
354
|
+
style: {
|
|
355
|
+
width: '100%',
|
|
356
|
+
height: '100%'
|
|
357
|
+
},
|
|
358
|
+
value: monthValue,
|
|
359
|
+
defaultValue: monthValue,
|
|
360
|
+
placeholder: column?.placeholder,
|
|
361
|
+
onChange: (date, dateString) => {
|
|
362
|
+
const newDateValue = dateString ?? null;
|
|
363
|
+
setSelectedKeys(newDateValue ? [newDateValue] : []);
|
|
364
|
+
}
|
|
365
|
+
})));
|
|
366
|
+
|
|
367
|
+
// case 'Quarter':
|
|
368
|
+
//
|
|
369
|
+
// // const monthValue = selectedKeys[0] ? convertDateToDayjs(new Date(selectedKeys[0]), dateFormat) : null
|
|
370
|
+
//
|
|
371
|
+
// const pickerFormat = getDatepickerFormat(getEditType(col) as IEditType, col)
|
|
372
|
+
// const pickerValue = !isEmpty(selectedKeys[0]) ? dayjs(selectedKeys[0], pickerFormat) : null
|
|
373
|
+
//
|
|
374
|
+
// return (
|
|
375
|
+
// <Fragment>
|
|
376
|
+
// <div>
|
|
377
|
+
//
|
|
378
|
+
//
|
|
379
|
+
// <div className={'mb-1'}>
|
|
380
|
+
//
|
|
381
|
+
// <DatePicker
|
|
382
|
+
// format={{
|
|
383
|
+
// format: dateFormat,
|
|
384
|
+
// type: 'mask'
|
|
385
|
+
// }}
|
|
386
|
+
// locale={buddhistLocale}
|
|
387
|
+
// style={{width: '100%', height: '100%'}}
|
|
388
|
+
// value={pickerValue}
|
|
389
|
+
// defaultValue={pickerValue}
|
|
390
|
+
// placeholder={column.placeholder}
|
|
391
|
+
// onChange={(date, dateString) => {
|
|
392
|
+
// const newDateValue = dateString ? moment(convertDayjsToDate(dateString as string, dateFormat)).format() : null
|
|
393
|
+
// setSelectedKeys(newDateValue ? [newDateValue] : [])
|
|
394
|
+
//
|
|
395
|
+
// }}
|
|
396
|
+
//
|
|
397
|
+
// />
|
|
398
|
+
// </div>
|
|
399
|
+
//
|
|
400
|
+
//
|
|
401
|
+
// </div>
|
|
402
|
+
// </Fragment>
|
|
403
|
+
// )
|
|
404
|
+
//
|
|
405
|
+
// case 'Year':
|
|
406
|
+
//
|
|
407
|
+
// // const monthValue = selectedKeys[0] ? convertDateToDayjs(new Date(selectedKeys[0]), dateFormat) : null
|
|
408
|
+
//
|
|
409
|
+
// const pickerFormat = getDatepickerFormat(getEditType(col) as IEditType, col)
|
|
410
|
+
// const pickerValue = !isEmpty(selectedKeys[0]) ? dayjs(selectedKeys[0], pickerFormat) : null
|
|
411
|
+
//
|
|
412
|
+
// return (
|
|
413
|
+
// <Fragment>
|
|
414
|
+
// <div>
|
|
415
|
+
//
|
|
416
|
+
//
|
|
417
|
+
// <div className={'mb-1'}>
|
|
418
|
+
//
|
|
419
|
+
// <DatePicker
|
|
420
|
+
// format={{
|
|
421
|
+
// format: dateFormat,
|
|
422
|
+
// type: 'mask'
|
|
423
|
+
// }}
|
|
424
|
+
// locale={buddhistLocale}
|
|
425
|
+
// style={{width: '100%', height: '100%'}}
|
|
426
|
+
// value={pickerValue}
|
|
427
|
+
// defaultValue={pickerValue}
|
|
428
|
+
// placeholder={column.placeholder}
|
|
429
|
+
// onChange={(date, dateString) => {
|
|
430
|
+
// const newDateValue = dateString ? moment(convertDayjsToDate(dateString as string, dateFormat)).format() : null
|
|
431
|
+
// setSelectedKeys(newDateValue ? [newDateValue] : [])
|
|
432
|
+
//
|
|
433
|
+
// }}
|
|
434
|
+
//
|
|
435
|
+
// />
|
|
436
|
+
// </div>
|
|
437
|
+
//
|
|
438
|
+
//
|
|
439
|
+
// </div>
|
|
440
|
+
// </Fragment>
|
|
441
|
+
// )
|
|
442
|
+
|
|
328
443
|
case 'Dropdown':
|
|
329
444
|
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
330
445
|
className: 'mb-1'
|
|
331
|
-
}, /*#__PURE__*/React.createElement(Select
|
|
332
|
-
|
|
446
|
+
}, /*#__PURE__*/React.createElement(Select
|
|
447
|
+
// options={translateOption(numberOperator, t)}
|
|
448
|
+
, {
|
|
449
|
+
options: options,
|
|
333
450
|
style: {
|
|
334
451
|
width: '100%',
|
|
335
452
|
marginBottom: 8
|
|
@@ -400,54 +517,17 @@ const GridTable = props => {
|
|
|
400
517
|
filterCheckall: 'Chọn tất cả'
|
|
401
518
|
},
|
|
402
519
|
selectedKeys: selectedKeys,
|
|
403
|
-
onSelect: setSelectedKeys
|
|
404
|
-
options
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
},
|
|
414
|
-
text: 'Black',
|
|
415
|
-
value: 'Black'
|
|
416
|
-
}, {
|
|
417
|
-
text: 'Category 1',
|
|
418
|
-
value: 'Category 1'
|
|
419
|
-
}, {
|
|
420
|
-
text: 'Yellow',
|
|
421
|
-
value: 'Yellow'
|
|
422
|
-
}, {
|
|
423
|
-
text: 'Pink',
|
|
424
|
-
value: 'Pink'
|
|
425
|
-
}, {
|
|
426
|
-
text: 'Category 2',
|
|
427
|
-
value: 'Category 666'
|
|
428
|
-
}, {
|
|
429
|
-
text: 'Category 2',
|
|
430
|
-
value: 'Category 555'
|
|
431
|
-
}, {
|
|
432
|
-
text: 'Category 2',
|
|
433
|
-
value: 'Category 55'
|
|
434
|
-
}, {
|
|
435
|
-
text: 'Category 2',
|
|
436
|
-
value: 'Category 44'
|
|
437
|
-
}, {
|
|
438
|
-
text: 'Category 2',
|
|
439
|
-
value: 'Category 33'
|
|
440
|
-
}, {
|
|
441
|
-
text: 'Category 2',
|
|
442
|
-
value: 'Category 22'
|
|
443
|
-
}, {
|
|
444
|
-
text: 'Category 2',
|
|
445
|
-
value: 'Category 11'
|
|
446
|
-
}
|
|
447
|
-
// {
|
|
448
|
-
// text: 'Submenu',
|
|
449
|
-
// value: 'Submenu',
|
|
450
|
-
// children: [
|
|
520
|
+
onSelect: setSelectedKeys
|
|
521
|
+
// options={
|
|
522
|
+
// [
|
|
523
|
+
// {
|
|
524
|
+
// text: 'Joe',
|
|
525
|
+
// value: 'Joe',
|
|
526
|
+
// },
|
|
527
|
+
// {
|
|
528
|
+
// text: 'Jim',
|
|
529
|
+
// value: 'Jim',
|
|
530
|
+
// },
|
|
451
531
|
// {
|
|
452
532
|
// text: 'Green',
|
|
453
533
|
// value: 'Green',
|
|
@@ -456,9 +536,65 @@ const GridTable = props => {
|
|
|
456
536
|
// text: 'Black',
|
|
457
537
|
// value: 'Black',
|
|
458
538
|
// },
|
|
459
|
-
//
|
|
460
|
-
//
|
|
461
|
-
|
|
539
|
+
// {
|
|
540
|
+
// text: 'Category 1',
|
|
541
|
+
// value: 'Category 1'
|
|
542
|
+
// },
|
|
543
|
+
// {
|
|
544
|
+
// text: 'Yellow',
|
|
545
|
+
// value: 'Yellow',
|
|
546
|
+
// },
|
|
547
|
+
// {
|
|
548
|
+
// text: 'Pink',
|
|
549
|
+
// value: 'Pink',
|
|
550
|
+
// },
|
|
551
|
+
// {
|
|
552
|
+
// text: 'Category 2',
|
|
553
|
+
// value: 'Category 666'
|
|
554
|
+
// },
|
|
555
|
+
// {
|
|
556
|
+
// text: 'Category 2',
|
|
557
|
+
// value: 'Category 555'
|
|
558
|
+
// },
|
|
559
|
+
// {
|
|
560
|
+
// text: 'Category 2',
|
|
561
|
+
// value: 'Category 55'
|
|
562
|
+
// },
|
|
563
|
+
// {
|
|
564
|
+
// text: 'Category 2',
|
|
565
|
+
// value: 'Category 44'
|
|
566
|
+
// },
|
|
567
|
+
// {
|
|
568
|
+
// text: 'Category 2',
|
|
569
|
+
// value: 'Category 33'
|
|
570
|
+
// },
|
|
571
|
+
// {
|
|
572
|
+
// text: 'Category 2',
|
|
573
|
+
// value: 'Category 22'
|
|
574
|
+
// },
|
|
575
|
+
// {
|
|
576
|
+
// text: 'Category 2',
|
|
577
|
+
// value: 'Category 11'
|
|
578
|
+
// }
|
|
579
|
+
// // {
|
|
580
|
+
// // text: 'Submenu',
|
|
581
|
+
// // value: 'Submenu',
|
|
582
|
+
// // children: [
|
|
583
|
+
// // {
|
|
584
|
+
// // text: 'Green',
|
|
585
|
+
// // value: 'Green',
|
|
586
|
+
// // },
|
|
587
|
+
// // {
|
|
588
|
+
// // text: 'Black',
|
|
589
|
+
// // value: 'Black',
|
|
590
|
+
// // },
|
|
591
|
+
// // ],
|
|
592
|
+
// // },
|
|
593
|
+
// ]
|
|
594
|
+
// }
|
|
595
|
+
,
|
|
596
|
+
|
|
597
|
+
options: options,
|
|
462
598
|
filterMultiple: true,
|
|
463
599
|
open: visible,
|
|
464
600
|
searchValue: searchValue,
|
|
@@ -470,7 +606,7 @@ const GridTable = props => {
|
|
|
470
606
|
className: 'mb-1'
|
|
471
607
|
}, /*#__PURE__*/React.createElement(Input, {
|
|
472
608
|
ref: searchInput,
|
|
473
|
-
placeholder: `Search ${column
|
|
609
|
+
placeholder: `Search ${column?.dataIndex}`,
|
|
474
610
|
value: selectedKeys[0],
|
|
475
611
|
onChange: e => setSelectedKeys(e.target.value ? [e.target.value] : []),
|
|
476
612
|
onPressEnter: () => handleSearch(selectedKeys, confirm),
|
|
@@ -478,12 +614,33 @@ const GridTable = props => {
|
|
|
478
614
|
}))));
|
|
479
615
|
}
|
|
480
616
|
};
|
|
617
|
+
const onFilterCallback = (key, data) => {
|
|
618
|
+
// console.log(key, data)
|
|
619
|
+
|
|
620
|
+
const find = dataSourceFilter.find(it => it.key === key);
|
|
621
|
+
if (find) {
|
|
622
|
+
const newData = updateArrayByKey(dataSourceFilter, {
|
|
623
|
+
key,
|
|
624
|
+
data
|
|
625
|
+
}, 'key');
|
|
626
|
+
setDataSourceFilter(newData);
|
|
627
|
+
} else {
|
|
628
|
+
const newData = [...dataSourceFilter, {
|
|
629
|
+
key,
|
|
630
|
+
data
|
|
631
|
+
}];
|
|
632
|
+
setDataSourceFilter(newData);
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
// setDataSourceFilter([{key, data}])
|
|
636
|
+
};
|
|
637
|
+
|
|
638
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
481
639
|
const getColumnSearchProps = column => ({
|
|
482
640
|
filterDropdown: ({
|
|
483
641
|
setSelectedKeys,
|
|
484
642
|
selectedKeys,
|
|
485
643
|
confirm,
|
|
486
|
-
// clearFilters,
|
|
487
644
|
close,
|
|
488
645
|
setOperatorKey,
|
|
489
646
|
operatorKey,
|
|
@@ -491,14 +648,13 @@ const GridTable = props => {
|
|
|
491
648
|
searchValue,
|
|
492
649
|
setSearchValue
|
|
493
650
|
}) => {
|
|
494
|
-
// const typeFilter = getTypeFilter(columns as RcColumnType)
|
|
495
651
|
return /*#__PURE__*/React.createElement("div", {
|
|
496
652
|
style: {
|
|
497
653
|
padding: 8,
|
|
498
654
|
minWidth: 275
|
|
499
655
|
},
|
|
500
656
|
onKeyDown: e => e.stopPropagation()
|
|
501
|
-
}, (column
|
|
657
|
+
}, (column?.showOperator !== false || column?.typeFilter !== 'DateRange' && column?.typeFilter !== 'NumberRange') && /*#__PURE__*/React.createElement("div", {
|
|
502
658
|
className: 'mb-1'
|
|
503
659
|
}, /*#__PURE__*/React.createElement(Select, {
|
|
504
660
|
options: translateOption(numberOperator, t),
|
|
@@ -514,7 +670,7 @@ const GridTable = props => {
|
|
|
514
670
|
style: {
|
|
515
671
|
marginBottom: 8
|
|
516
672
|
}
|
|
517
|
-
}, renderFilter(column, selectedKeys, setSelectedKeys, confirm, visible, searchValue, setSearchValue)), /*#__PURE__*/React.createElement(
|
|
673
|
+
}, renderFilter(column, selectedKeys, setSelectedKeys, confirm, visible, searchValue, setSearchValue)), /*#__PURE__*/React.createElement(Space, {
|
|
518
674
|
style: {
|
|
519
675
|
justifyContent: 'end',
|
|
520
676
|
width: '100%'
|
|
@@ -540,50 +696,52 @@ const GridTable = props => {
|
|
|
540
696
|
}
|
|
541
697
|
}, "close")));
|
|
542
698
|
},
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
699
|
+
filterIcon: filtered => /*#__PURE__*/React.createElement(FilterFill, {
|
|
700
|
+
fontSize: 12,
|
|
701
|
+
onClick: () => {
|
|
702
|
+
console.log('onFilterClick', column);
|
|
703
|
+
onFilterClick?.(column, onFilterCallback);
|
|
704
|
+
},
|
|
705
|
+
style: {
|
|
706
|
+
color: filtered ? '#283046' : undefined
|
|
707
|
+
}
|
|
708
|
+
}),
|
|
551
709
|
filterDropdownProps: {
|
|
552
710
|
onOpenChange(open) {
|
|
553
711
|
if (open) {
|
|
554
712
|
setTimeout(() => searchInput.current?.select(), 100);
|
|
555
713
|
}
|
|
556
714
|
}
|
|
557
|
-
|
|
558
|
-
// trigger: ['hover']
|
|
559
715
|
}
|
|
560
716
|
});
|
|
717
|
+
|
|
718
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
561
719
|
const renderContent = column => value => {
|
|
562
720
|
switch (column?.type) {
|
|
563
721
|
case 'number':
|
|
564
|
-
const thousandSeparator = column
|
|
565
|
-
const decimalSeparator = column
|
|
566
|
-
const dec = column
|
|
722
|
+
const thousandSeparator = column?.format?.thousandSeparator ? column?.format?.thousandSeparator : format?.thousandSeparator;
|
|
723
|
+
const decimalSeparator = column?.format?.decimalSeparator ? column?.format?.decimalSeparator : format?.decimalSeparator;
|
|
724
|
+
const dec = column?.format?.decimalScale || column?.format?.decimalScale === 0 ? column?.format?.decimalScale : format?.decimalScale;
|
|
567
725
|
const content = !isEmpty(value) ? dec || dec === 0 ? parseFloat(Number(value).toFixed(dec)).toString() : value.toString() : '0';
|
|
568
726
|
const numericFormatProps = {
|
|
569
727
|
thousandSeparator: checkThousandSeparator(thousandSeparator, decimalSeparator),
|
|
570
728
|
decimalSeparator: checkDecimalSeparator(thousandSeparator, decimalSeparator),
|
|
571
|
-
allowNegative: (column
|
|
572
|
-
prefix: column
|
|
573
|
-
suffix: column
|
|
574
|
-
decimalScale: column
|
|
575
|
-
fixedDecimalScale: (column
|
|
729
|
+
allowNegative: (column?.format?.allowNegative ? column?.format?.allowNegative : format?.allowNegative) ?? true,
|
|
730
|
+
prefix: column?.format?.prefix ? column?.format?.prefix : format?.prefix,
|
|
731
|
+
suffix: column?.format?.suffix ? column?.format?.suffix : format?.suffix,
|
|
732
|
+
decimalScale: column?.format?.decimalScale || column?.format?.decimalScale === 0 ? column?.format?.decimalScale : format?.decimalScale,
|
|
733
|
+
fixedDecimalScale: (column?.format?.fixedDecimalScale ? column?.format?.fixedDecimalScale : format?.fixedDecimalScale) ?? false
|
|
576
734
|
};
|
|
577
735
|
return !isEmpty(content) ? numericFormatter(content, numericFormatProps) : '';
|
|
578
736
|
case 'date':
|
|
579
|
-
return value ? dayjs(value).format(column
|
|
737
|
+
return value ? dayjs(value).format(column?.format?.dateFormat ?? format?.dateFormat ?? 'DD/MM/YYYY') : '';
|
|
580
738
|
case 'time':
|
|
581
739
|
return value ? value : '';
|
|
582
740
|
case 'year':
|
|
583
741
|
const year = value ? moment(value).format('yyyy') : '';
|
|
584
742
|
return /*#__PURE__*/React.createElement(Fragment, null, year);
|
|
585
743
|
case 'datetime':
|
|
586
|
-
return value ? moment(value).format(column
|
|
744
|
+
return value ? moment(value).format(column?.format?.datetimeFormat ?? format?.datetimeFormat ?? 'DD/MM/YYYY HH:mm') : '';
|
|
587
745
|
case 'boolean':
|
|
588
746
|
return value ? 'true' : 'false';
|
|
589
747
|
case 'color':
|
|
@@ -610,117 +768,45 @@ const GridTable = props => {
|
|
|
610
768
|
return value;
|
|
611
769
|
}
|
|
612
770
|
};
|
|
613
|
-
const
|
|
614
|
-
return
|
|
771
|
+
const addFilter = React.useCallback(cols => {
|
|
772
|
+
return cols.map(column => {
|
|
615
773
|
// @ts-ignore
|
|
616
|
-
if (!column?.dataIndex && !column
|
|
774
|
+
if (!column?.dataIndex && !column?.key) {
|
|
617
775
|
return column;
|
|
618
776
|
}
|
|
619
777
|
// @ts-ignore
|
|
620
|
-
if (column?.children && column
|
|
778
|
+
if (column?.children && column?.children.length > 0) {
|
|
621
779
|
return {
|
|
622
780
|
...column,
|
|
623
781
|
// @ts-ignore
|
|
624
|
-
children:
|
|
782
|
+
children: addFilter(column?.children) // Xử lý đệ quy cho cấp con
|
|
625
783
|
};
|
|
626
784
|
}
|
|
627
785
|
// @ts-ignore
|
|
628
|
-
if (column?.dataIndex === 'index' || column
|
|
786
|
+
if (column?.dataIndex === 'index' || column?.allowFiltering === false) {
|
|
629
787
|
return {
|
|
630
788
|
...column
|
|
631
789
|
};
|
|
632
790
|
}
|
|
633
791
|
return {
|
|
634
792
|
...getColumnSearchProps(column),
|
|
793
|
+
onFilter: (value, record) => {
|
|
794
|
+
// @ts-ignore
|
|
795
|
+
return record[column?.dataIndex];
|
|
796
|
+
},
|
|
635
797
|
render: renderContent(column),
|
|
636
|
-
...column
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
const tmpColumns = useMemo(() => {
|
|
641
|
-
// return addIsFilter(defaultColumns ?? [])
|
|
642
|
-
return addIsFilter(defaultColumns ? [Table.SELECTION_COLUMN, ...defaultColumns] : []);
|
|
643
|
-
}, [defaultColumns]);
|
|
644
|
-
const [columns, setColumns] = useState(tmpColumns ?? []);
|
|
645
|
-
const handleResize = indexPath => (e, {
|
|
646
|
-
size
|
|
647
|
-
}) => {
|
|
648
|
-
const updateColumns = (cols, path) => {
|
|
649
|
-
const [currentIndex, ...restPath] = path;
|
|
650
|
-
return cols.map((col, idx) => {
|
|
651
|
-
if (idx === currentIndex) {
|
|
652
|
-
if (restPath.length === 0) {
|
|
653
|
-
// Cập nhật width của cột cuối cùng trong path
|
|
654
|
-
// return { ...col, width: size.width }
|
|
655
|
-
|
|
656
|
-
// Kiểm tra minWidth trước khi cập nhật width
|
|
657
|
-
if (col.minWidth && size.width < col.minWidth) {
|
|
658
|
-
e.preventDefault();
|
|
659
|
-
return col; // Không cập nhật nếu nhỏ hơn minWidth
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
// Kiểm tra minWidth trước khi cập nhật width
|
|
663
|
-
if (col.maxWidth && size.width > col.maxWidth) {
|
|
664
|
-
e.preventDefault();
|
|
665
|
-
return col; // Không cập nhật nếu nhỏ hơn minWidth
|
|
666
|
-
}
|
|
667
|
-
return {
|
|
668
|
-
...col,
|
|
669
|
-
width: size.width
|
|
670
|
-
};
|
|
671
|
-
} else if (col.children) {
|
|
672
|
-
// Tiếp tục cập nhật các cấp con
|
|
673
|
-
return {
|
|
674
|
-
...col,
|
|
675
|
-
children: updateColumns(col.children, restPath)
|
|
676
|
-
};
|
|
677
|
-
}
|
|
798
|
+
...column,
|
|
799
|
+
ellipsis: column?.ellipsis !== false,
|
|
800
|
+
sorter: () => {
|
|
801
|
+
// console.log('a, b, sortOrder', a, b, sortOrder)
|
|
678
802
|
}
|
|
679
|
-
// e.preventDefault()
|
|
680
|
-
return col;
|
|
681
|
-
});
|
|
682
|
-
};
|
|
683
|
-
setColumns(prevColumns => updateColumns(prevColumns, indexPath));
|
|
684
|
-
};
|
|
685
|
-
const addResizeHandlers = (cols, parentPath = []) => {
|
|
686
|
-
return cols.map((col, index) => {
|
|
687
|
-
const currentPath = [...parentPath, index];
|
|
688
|
-
if (!col?.dataIndex && !col.key) {
|
|
689
|
-
return col;
|
|
690
|
-
}
|
|
691
|
-
if (col.children) {
|
|
692
|
-
return {
|
|
693
|
-
...col,
|
|
694
|
-
ellipsis: col.ellipsis !== true,
|
|
695
|
-
children: addResizeHandlers(col.children, currentPath)
|
|
696
|
-
};
|
|
697
|
-
}
|
|
698
|
-
return {
|
|
699
|
-
...col,
|
|
700
|
-
ellipsis: col.ellipsis !== true,
|
|
701
|
-
onHeaderCell: () => ({
|
|
702
|
-
width: col.width,
|
|
703
|
-
onResize: handleResize(currentPath)
|
|
704
|
-
})
|
|
705
803
|
};
|
|
706
804
|
});
|
|
707
|
-
};
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
const resizableColumns = useMemo(() => {
|
|
713
|
-
return addResizeHandlers(columns);
|
|
714
|
-
}, [columns]);
|
|
715
|
-
|
|
716
|
-
// const handleReset = (clearFilters: () => void) => {
|
|
717
|
-
// clearFilters()
|
|
718
|
-
// }
|
|
719
|
-
|
|
720
|
-
// const handleChangeOperator = (val: IFilterOperator) => {
|
|
721
|
-
// setOperator(val)
|
|
722
|
-
// }
|
|
723
|
-
|
|
805
|
+
}, [getColumnSearchProps, renderContent]);
|
|
806
|
+
const tmpColumns = useMemo(() => {
|
|
807
|
+
// @ts-ignore
|
|
808
|
+
return addFilter(defaultColumns ?? []);
|
|
809
|
+
}, [addFilter, defaultColumns]);
|
|
724
810
|
const onContextMenu = data => event => {
|
|
725
811
|
event.preventDefault(); // Ngăn chặn menu mặc định của trình duyệt
|
|
726
812
|
|
|
@@ -818,7 +904,22 @@ const GridTable = props => {
|
|
|
818
904
|
}
|
|
819
905
|
}
|
|
820
906
|
};
|
|
821
|
-
|
|
907
|
+
const handleChange = sorter => {
|
|
908
|
+
console.log('Various parameters', sorter);
|
|
909
|
+
// setFilteredInfo(filters);
|
|
910
|
+
// setSortedInfo(sorter as Sorts);
|
|
911
|
+
};
|
|
912
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(ConfigProvider, {
|
|
913
|
+
theme: {
|
|
914
|
+
components: {
|
|
915
|
+
Table: {
|
|
916
|
+
rowHoverBg: '#eb461912',
|
|
917
|
+
rowSelectedBg: '#eb4619',
|
|
918
|
+
rowSelectedHoverBg: '#eb4619'
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
}, /*#__PURE__*/React.createElement(ContextMenu, {
|
|
822
923
|
open: menuVisible,
|
|
823
924
|
pos: position,
|
|
824
925
|
setOpen: setMenuVisible,
|
|
@@ -826,7 +927,14 @@ const GridTable = props => {
|
|
|
826
927
|
contextMenuItems: contextMenuItems,
|
|
827
928
|
contextMenuClick: contextMenuClick,
|
|
828
929
|
rowData: selectedRowData
|
|
829
|
-
}), /*#__PURE__*/React.createElement(Table
|
|
930
|
+
}), /*#__PURE__*/React.createElement(Table
|
|
931
|
+
// loading={defaultColumns && defaultColumns.length === 0}
|
|
932
|
+
// loading={true}
|
|
933
|
+
, _extends({
|
|
934
|
+
loading: {
|
|
935
|
+
spinning: defaultColumns && defaultColumns.length === 0 || loading === true,
|
|
936
|
+
indicator: /*#__PURE__*/React.createElement(ComponentSpinner, null)
|
|
937
|
+
},
|
|
830
938
|
dataSource: dataSource
|
|
831
939
|
// className={styles.customTable}
|
|
832
940
|
,
|
|
@@ -834,19 +942,28 @@ const GridTable = props => {
|
|
|
834
942
|
'table-none-column-select': selectionSettings?.mode === undefined && selectionSettings?.type !== 'multiple'
|
|
835
943
|
}, styles.customTable),
|
|
836
944
|
bordered: true,
|
|
837
|
-
virtual: virtual
|
|
838
|
-
columns
|
|
945
|
+
virtual: virtual
|
|
946
|
+
// columns={resizableColumns as any}
|
|
947
|
+
,
|
|
948
|
+
columns: tmpColumns
|
|
949
|
+
// scroll={{ y: 550 }}
|
|
950
|
+
,
|
|
839
951
|
rowKey: rowKey,
|
|
840
952
|
rowHoverable: true,
|
|
841
953
|
components: {
|
|
842
954
|
header: {
|
|
843
955
|
cell: ResizableTitle
|
|
844
956
|
}
|
|
957
|
+
}
|
|
958
|
+
// scroll={scroll}
|
|
959
|
+
,
|
|
960
|
+
size: "small",
|
|
961
|
+
scroll: scroll ? scroll : {
|
|
962
|
+
y: 500
|
|
845
963
|
},
|
|
846
964
|
onRow: (data, index) => {
|
|
847
965
|
return {
|
|
848
966
|
onDoubleClick: handleRowDoubleClick(data, index),
|
|
849
|
-
// onClick: handleRowClick(data),
|
|
850
967
|
onClick: handleRowClick,
|
|
851
968
|
onContextMenu: onContextMenu(data)
|
|
852
969
|
};
|
|
@@ -856,6 +973,9 @@ const GridTable = props => {
|
|
|
856
973
|
// columnWidth: selectionSettings?.mode === 'checkbox' || selectionSettings?.mode === 'radio' || selectionSettings?.type === 'multiple' ? 50 : 0.000001,
|
|
857
974
|
columnWidth: !selectionSettings?.mode ? 0.0000001 : selectionSettings?.columnWidth ?? 50,
|
|
858
975
|
onChange: onSelectChange,
|
|
976
|
+
// onChange: (selectedRowKeys, selectedRows, info, selectedRow) => {
|
|
977
|
+
//
|
|
978
|
+
// },
|
|
859
979
|
// onSelect: (record, selected, selectedRows, nativeEvent)=> {
|
|
860
980
|
// // console.log(record, selected, selectedRows, nativeEvent)
|
|
861
981
|
// },
|
|
@@ -870,28 +990,6 @@ const GridTable = props => {
|
|
|
870
990
|
onScroll: () => {
|
|
871
991
|
setMenuVisible(false);
|
|
872
992
|
},
|
|
873
|
-
title: () => {
|
|
874
|
-
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", null, "Header"), toolbarItems && /*#__PURE__*/React.createElement("div", {
|
|
875
|
-
style: {
|
|
876
|
-
display: 'flex',
|
|
877
|
-
justifyContent: 'space-between'
|
|
878
|
-
}
|
|
879
|
-
}, /*#__PURE__*/React.createElement(Toolbar, {
|
|
880
|
-
style: {
|
|
881
|
-
width: '100%'
|
|
882
|
-
},
|
|
883
|
-
items: toolbarItems,
|
|
884
|
-
mode: 'responsive'
|
|
885
|
-
// mode={'scroll'}
|
|
886
|
-
,
|
|
887
|
-
onClick: val => {
|
|
888
|
-
console.log(val);
|
|
889
|
-
}
|
|
890
|
-
}), showColumnChoose && /*#__PURE__*/React.createElement(ColumnsChoose, {
|
|
891
|
-
columns: columns,
|
|
892
|
-
setColumns: setColumns
|
|
893
|
-
}), /*#__PURE__*/React.createElement("div", null)));
|
|
894
|
-
},
|
|
895
993
|
summary: () => /*#__PURE__*/React.createElement(Table.Summary, {
|
|
896
994
|
fixed: true
|
|
897
995
|
}, /*#__PURE__*/React.createElement(Table.Summary.Row, null, flatColumns(tmpColumns).filter(col => col.hidden !== true).map((col, index) => {
|
|
@@ -910,18 +1008,48 @@ const GridTable = props => {
|
|
|
910
1008
|
decimalScale: dec,
|
|
911
1009
|
fixedDecimalScale: (col.format?.fixedDecimalScale ? col.format?.fixedDecimalScale : format?.fixedDecimalScale) ?? false
|
|
912
1010
|
};
|
|
913
|
-
return (
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
key: index,
|
|
918
|
-
index: index
|
|
919
|
-
}, col.summaryTemplate ? col.summaryTemplate(cellValue, col.key) : numericFormatter(cellValue, numericFormatProps))
|
|
920
|
-
);
|
|
1011
|
+
return /*#__PURE__*/React.createElement(Table.Summary.Cell, {
|
|
1012
|
+
key: col.key,
|
|
1013
|
+
index: index
|
|
1014
|
+
}, col.summaryTemplate ? col.summaryTemplate(cellValue, col.key) : numericFormatter(cellValue, numericFormatProps));
|
|
921
1015
|
}))),
|
|
1016
|
+
pagination: pagination && pagination.onChange ? false : {
|
|
1017
|
+
showTotal: (total, range) => `${range[0]}-${range[1]} / ${total} items`,
|
|
1018
|
+
...pagination
|
|
1019
|
+
},
|
|
922
1020
|
onFilter: val => {
|
|
923
1021
|
onFilter?.(convertFilters(val));
|
|
1022
|
+
},
|
|
1023
|
+
onChange: (paging, filters, sorter) => handleChange(sorter),
|
|
1024
|
+
title: () => {
|
|
1025
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", null, title?.(dataSource)), (toolbarItems || showColumnChoose !== false) && /*#__PURE__*/React.createElement("div", {
|
|
1026
|
+
style: {
|
|
1027
|
+
display: 'flex',
|
|
1028
|
+
justifyContent: 'space-between'
|
|
1029
|
+
}
|
|
1030
|
+
}, /*#__PURE__*/React.createElement(Toolbar, {
|
|
1031
|
+
style: {
|
|
1032
|
+
width: '100%'
|
|
1033
|
+
},
|
|
1034
|
+
items: toolbarItems ?? [],
|
|
1035
|
+
mode: 'responsive'
|
|
1036
|
+
// mode={'scroll'}
|
|
1037
|
+
,
|
|
1038
|
+
onClick: val => {
|
|
1039
|
+
console.log(val);
|
|
1040
|
+
}
|
|
1041
|
+
}), showColumnChoose && /*#__PURE__*/React.createElement(ColumnsChoose, {
|
|
1042
|
+
columns: tmpColumns,
|
|
1043
|
+
setColumns: setColumns
|
|
1044
|
+
}), /*#__PURE__*/React.createElement("div", null)));
|
|
924
1045
|
}
|
|
925
|
-
}))
|
|
1046
|
+
}, rest)), pagination && pagination.onChange && /*#__PURE__*/React.createElement(Pagination
|
|
1047
|
+
// style={{padding: '0.75rem 1rem'}}
|
|
1048
|
+
, _extends({
|
|
1049
|
+
showSizeChanger: true,
|
|
1050
|
+
responsive: true,
|
|
1051
|
+
size: 'small',
|
|
1052
|
+
showTotal: (total, range) => `${range[0]}-${range[1]} / ${total} items`
|
|
1053
|
+
}, pagination))));
|
|
926
1054
|
};
|
|
927
|
-
export default
|
|
1055
|
+
export default TableGrid;
|