es-grid-template 1.8.61 → 1.8.63
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.
|
@@ -2,7 +2,7 @@ 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, sumByField, translateOption, unFlattenData, updateArrayByKey, updateColumnsByGroup,
|
|
5
|
+
import { addRowIdArray, booleanOperator, checkDecimalSeparator, checkThousandSeparator, 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
8
|
import ReactDOMServer from 'react-dom/server';
|
|
@@ -33,7 +33,7 @@ import classNames from "classnames";
|
|
|
33
33
|
import HeaderContent from "./hooks/content/HeaderContent";
|
|
34
34
|
import { ArrowDown, ArrowUp, FilterFill, SortCancel } from "becoxy-icons";
|
|
35
35
|
import { Select } from "rc-master-ui";
|
|
36
|
-
import { Button, Space } from "antd";
|
|
36
|
+
import { Button, Modal, Space } from "antd";
|
|
37
37
|
import { SearchOutlined } from "@ant-design/icons";
|
|
38
38
|
import { restrictToHorizontalAxis } from "@dnd-kit/modifiers";
|
|
39
39
|
import { closestCenter, DndContext, DragOverlay, PointerSensor, useSensor, useSensors } from "@dnd-kit/core";
|
|
@@ -42,7 +42,9 @@ import { arrayMove, horizontalListSortingStrategy, SortableContext, useSortable
|
|
|
42
42
|
import { Resizable } from "react-resizable";
|
|
43
43
|
import { faker } from "@faker-js/faker";
|
|
44
44
|
import useMergedState from "rc-util/es/hooks/useMergedState";
|
|
45
|
-
import
|
|
45
|
+
import { numericFormatter } from 'react-numeric-component';
|
|
46
|
+
// import Modal from 'antd/es/modal/Modal'
|
|
47
|
+
|
|
46
48
|
dayjs.extend(customParseFormat);
|
|
47
49
|
const MySwal = withReactContent(Swal);
|
|
48
50
|
const ASCEND = 'ascend';
|
|
@@ -61,9 +63,7 @@ const dragActiveStyle = (dragState, id) => {
|
|
|
61
63
|
backgroundColor: '#c0c0c0',
|
|
62
64
|
opacity: 0.3
|
|
63
65
|
};
|
|
64
|
-
}
|
|
65
|
-
// dragover dashed style
|
|
66
|
-
else if (over && id === over && active !== over) {
|
|
66
|
+
} else if (over && id === over && active !== over) {
|
|
67
67
|
style = direction === 'right' ? {
|
|
68
68
|
borderRight: '1px dashed gray'
|
|
69
69
|
} : {
|
|
@@ -83,11 +83,9 @@ const ResizableTitle = props => {
|
|
|
83
83
|
...restProps
|
|
84
84
|
} = props;
|
|
85
85
|
const dragState = useContext(DragIndexContext);
|
|
86
|
-
|
|
87
|
-
// const { attributes, listeners, setNodeRef, isDragging } = useSortable({ id: props.id });
|
|
88
|
-
|
|
89
86
|
const style = {
|
|
90
87
|
...props.style,
|
|
88
|
+
borderBottom: '1px solid #e0e0e0',
|
|
91
89
|
// cursor: 'move',
|
|
92
90
|
// ...(isDragging ? { position: 'relative', zIndex: 9999, userSelect: 'none' } : {}),
|
|
93
91
|
...dragActiveStyle(dragState, props.id)
|
|
@@ -158,12 +156,11 @@ const InternalTable = props => {
|
|
|
158
156
|
lang,
|
|
159
157
|
locale,
|
|
160
158
|
dataSource,
|
|
161
|
-
allowResizing,
|
|
162
159
|
dataSourceFilter: propDataSourceFilter,
|
|
163
160
|
// onFilterClick,
|
|
164
161
|
// onFilter,
|
|
165
162
|
editAble,
|
|
166
|
-
rowKey: propRowKey,
|
|
163
|
+
// rowKey: propRowKey,
|
|
167
164
|
format,
|
|
168
165
|
onDataChange,
|
|
169
166
|
sortMultiple,
|
|
@@ -171,7 +168,7 @@ const InternalTable = props => {
|
|
|
171
168
|
// @ts-ignore
|
|
172
169
|
onCellPaste,
|
|
173
170
|
clickHeaderToSort = true,
|
|
174
|
-
components,
|
|
171
|
+
// components,
|
|
175
172
|
onChooseColumns,
|
|
176
173
|
groupAble,
|
|
177
174
|
groupSetting,
|
|
@@ -181,16 +178,17 @@ const InternalTable = props => {
|
|
|
181
178
|
pagination,
|
|
182
179
|
height: propsHeight,
|
|
183
180
|
summary,
|
|
184
|
-
infiniteScroll,
|
|
181
|
+
// infiniteScroll,
|
|
185
182
|
wrapSettings,
|
|
186
183
|
onFilter,
|
|
187
184
|
onSorter,
|
|
188
|
-
defaultSorter,
|
|
185
|
+
// defaultSorter,
|
|
189
186
|
toolbarItems,
|
|
190
187
|
allowSortering,
|
|
191
188
|
allowFiltering,
|
|
192
189
|
...rest
|
|
193
190
|
} = props;
|
|
191
|
+
const theadRef = React.useRef(null);
|
|
194
192
|
const id = React.useMemo(() => {
|
|
195
193
|
return tableId ?? faker.string.alpha(20);
|
|
196
194
|
// return tableId ?? newGuid()
|
|
@@ -265,15 +263,14 @@ const InternalTable = props => {
|
|
|
265
263
|
if (totalHeight) {
|
|
266
264
|
const table = document.querySelector(`#${id}`);
|
|
267
265
|
const title = table?.querySelector(`.ui-rc-table-title`);
|
|
268
|
-
const
|
|
266
|
+
const tableScrollRight = table?.querySelector(`.ui-rc-table-ping-right`);
|
|
269
267
|
const paginationE = table?.querySelector(`.ui-rc-pagination`);
|
|
270
268
|
const toolbar = table?.querySelector(`.ui-rc-toolbar-bottom`);
|
|
271
269
|
const summaryE = table?.querySelector(`.ui-rc-table-summary`);
|
|
272
|
-
const
|
|
273
|
-
const hhh = (totalHeight ?? 0) - (title ? title.offsetHeight : 0) - (header ? header.offsetHeight : 0) - (paginationE ? paginationE.offsetHeight : 0) - (toolbar ? toolbar.offsetHeight : 0) - (summaryE ? summaryE.offsetHeight : 0) - (scrollbar ? scrollbar.offsetHeight : 0);
|
|
270
|
+
const hhh = (totalHeight ?? 0) - (title ? title.offsetHeight : 0) - (theadRef ? theadRef.current.clientHeight : 0) - (paginationE ? paginationE.offsetHeight : 0) - (toolbar ? toolbar.offsetHeight : 0) - (summaryE ? 40 : 0) - (tableScrollRight ? 10 : 0);
|
|
274
271
|
setHeight(hhh > 0 ? hhh : 0);
|
|
275
272
|
}
|
|
276
|
-
}, [id, propsHeight,
|
|
273
|
+
}, [id, propsHeight, summary, theadRef, columns]);
|
|
277
274
|
React.useEffect(() => {
|
|
278
275
|
// const totalHeight = isFullScreen ? windowSize.innerHeight - 50 : propsHeight
|
|
279
276
|
const totalHeight = windowSize.innerHeight - 60;
|
|
@@ -426,26 +423,28 @@ const InternalTable = props => {
|
|
|
426
423
|
dataIndex: column.field ?? column.dataIndex,
|
|
427
424
|
key: column.field ?? column.key,
|
|
428
425
|
// title: () => (<HeaderContent column={{...column} as any} t={t}/>),
|
|
429
|
-
title:
|
|
430
|
-
|
|
431
|
-
|
|
426
|
+
title:
|
|
427
|
+
/*#__PURE__*/
|
|
428
|
+
// <SortableHeaderCell columnKey={column.field}>
|
|
429
|
+
React.createElement(HeaderContent, {
|
|
432
430
|
column: {
|
|
433
431
|
...column
|
|
434
432
|
},
|
|
435
433
|
t: t,
|
|
436
434
|
id: id,
|
|
437
435
|
wrapSettings: wrapSettings
|
|
438
|
-
})
|
|
436
|
+
})
|
|
437
|
+
// </SortableHeaderCell>
|
|
438
|
+
,
|
|
439
439
|
// ellipsis: editAble || column.ellipsis !== false && wrapSettings && wrapSettings.wrapMode !== 'Content' && wrapSettings.wrapMode !== 'Both',
|
|
440
|
-
ellipsis: column.ellipsis !== false || wrapSettings && wrapSettings.wrapMode !== 'Content' && wrapSettings.wrapMode !== 'Both',
|
|
441
|
-
|
|
442
|
-
// ellipsis: column.ellipsis !== false,
|
|
443
|
-
|
|
440
|
+
// ellipsis: column.ellipsis !== false || (wrapSettings && wrapSettings.wrapMode !== 'Content' && wrapSettings.wrapMode !== 'Both'),
|
|
441
|
+
ellipsis: false,
|
|
444
442
|
align: column.textAlign ?? column.align,
|
|
445
443
|
fixed: column.fixedType ?? column.fixed,
|
|
446
444
|
isSummary: column.isSummary ?? column.haveSum,
|
|
447
445
|
hidden: column.hidden ?? column.visible === false
|
|
448
446
|
};
|
|
447
|
+
const headerTooltip = t ? t?.(column.headerTooltip ?? column.columnGroupText ?? column.headerText) : column.headerTooltip ?? column.columnGroupText ?? column.headerText;
|
|
449
448
|
if (transformedColumn.field === '#') {
|
|
450
449
|
return {
|
|
451
450
|
...transformedColumn,
|
|
@@ -547,10 +546,18 @@ const InternalTable = props => {
|
|
|
547
546
|
},
|
|
548
547
|
onHeaderCell: () => ({
|
|
549
548
|
id: `${column.field}`,
|
|
550
|
-
width: column.width,
|
|
549
|
+
// width: column.width,
|
|
550
|
+
|
|
551
|
+
'data-tooltip-id': `${id}-tooltip-header`,
|
|
552
|
+
'data-tooltip-content': headerTooltip,
|
|
551
553
|
onResize: handleResize?.(column),
|
|
552
|
-
className:
|
|
553
|
-
|
|
554
|
+
className: classNames('', {
|
|
555
|
+
'head-align-center': column.headerTextAlign === 'center',
|
|
556
|
+
'head-align-right': column.headerTextAlign === 'right',
|
|
557
|
+
'ui-rc-table-cell-ellipsis': !wrapSettings || !!(wrapSettings && wrapSettings.wrapMode === 'Content'),
|
|
558
|
+
// mặc định = true
|
|
559
|
+
'ui-rc-table-cell-wrap': wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Header')
|
|
560
|
+
})
|
|
554
561
|
}),
|
|
555
562
|
onCell: (data, index) => {
|
|
556
563
|
const tooltipContent = isOpenTooltip === false ? '' : column?.tooltipDescription ? typeof column.tooltipDescription === 'function' ? column.tooltipDescription({
|
|
@@ -559,14 +566,16 @@ const InternalTable = props => {
|
|
|
559
566
|
}) : column.tooltipDescription : column.template && typeof column.template !== 'function' ? column.template : data[column.field ?? ''];
|
|
560
567
|
return {
|
|
561
568
|
id: `${column.field}`,
|
|
562
|
-
colSpan: groupColumns && data.children && column.field === firstNonGroupColumn?.field ? 2 : groupColumns && data.children && nonGroupColumns[1].field === column.field ? 0 : 1,
|
|
569
|
+
colSpan: groupColumns && data.children && column.field === firstNonGroupColumn?.field ? groupSetting?.groupColumnSpan ?? 2 : groupColumns && data.children && nonGroupColumns[1].field === column.field ? 0 : 1,
|
|
563
570
|
// 'z-index': data?.children && column.field === firstNonGroupColumn?.field ? 11 : undefined,
|
|
564
571
|
...transformedColumn?.onCell?.(data, index),
|
|
565
572
|
className: classNames(transformedColumn?.onCell?.(data, index).className ?? '', {
|
|
566
573
|
'cell-group': groupColumns && data.children,
|
|
567
|
-
'cell-group-fixed': groupColumns && data.children && column.field === firstNonGroupColumn?.field
|
|
574
|
+
'cell-group-fixed': groupColumns && data.children && column.field === firstNonGroupColumn?.field,
|
|
575
|
+
'ui-rc-table-cell-ellipsis': !wrapSettings || wrapSettings && (wrapSettings.wrapMode === 'Header' || wrapSettings.wrapMode !== 'Both'),
|
|
576
|
+
// mặc định = true
|
|
577
|
+
'ui-rc-table-cell-wrap': wrapSettings && (wrapSettings.wrapMode === 'Content' || wrapSettings.wrapMode === 'Both')
|
|
568
578
|
}),
|
|
569
|
-
// 'data-tooltip-id': "tooltip-cell-content"
|
|
570
579
|
'data-tooltip-id': `${id}-tooltip-cell-content`,
|
|
571
580
|
"data-tooltip-html": ReactDOMServer.renderToStaticMarkup( /*#__PURE__*/React.createElement(React.Fragment, null, tooltipContent)),
|
|
572
581
|
onMouseEnter: e => {
|
|
@@ -606,8 +615,20 @@ const InternalTable = props => {
|
|
|
606
615
|
return /*#__PURE__*/React.createElement("span", null, currentGroupColumn?.headerText, ": ", renderContent(currentGroupColumn, record[record.field], record, rowIndex, colIndex, false, cellFormat));
|
|
607
616
|
}
|
|
608
617
|
if (groupAble && record.children && column.sumGroup === true && column.type === 'number') {
|
|
618
|
+
const thousandSeparator = cellFormat?.thousandSeparator;
|
|
619
|
+
const decimalSeparator = cellFormat?.decimalSeparator;
|
|
620
|
+
const dec = cellFormat?.decimalScale;
|
|
621
|
+
const numericFormatProps = {
|
|
622
|
+
thousandSeparator: checkThousandSeparator(thousandSeparator, decimalSeparator),
|
|
623
|
+
decimalSeparator: checkDecimalSeparator(thousandSeparator, decimalSeparator),
|
|
624
|
+
allowNegative: cellFormat?.allowNegative ?? true,
|
|
625
|
+
prefix: cellFormat?.prefix,
|
|
626
|
+
suffix: cellFormat?.suffix,
|
|
627
|
+
decimalScale: dec,
|
|
628
|
+
fixedDecimalScale: cellFormat?.fixedDecimalScale ?? false
|
|
629
|
+
};
|
|
609
630
|
const sumValue = sumByField(filterDataByColumns4(record.children, [], []), column?.field);
|
|
610
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, sumValue);
|
|
631
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, numericFormatter(sumValue.toString(), numericFormatProps));
|
|
611
632
|
}
|
|
612
633
|
return renderContent(column, value, record, rowIndex, colIndex, false, cellFormat);
|
|
613
634
|
},
|
|
@@ -637,13 +658,14 @@ const InternalTable = props => {
|
|
|
637
658
|
id: id,
|
|
638
659
|
wrapSettings: wrapSettings
|
|
639
660
|
})),
|
|
640
|
-
|
|
641
|
-
ellipsis: editAble || column.ellipsis !== false && wrapSettings && wrapSettings.wrapMode !== 'Content' && wrapSettings.wrapMode !== 'Both',
|
|
661
|
+
ellipsis: false,
|
|
662
|
+
// ellipsis: editAble || column.ellipsis !== false && wrapSettings && wrapSettings.wrapMode !== 'Content' && wrapSettings.wrapMode !== 'Both',
|
|
663
|
+
|
|
642
664
|
align: column.textAlign ?? column.align,
|
|
643
665
|
fixed: column.fixedType ?? column.fixed,
|
|
644
666
|
isSummary: column.isSummary ?? column.haveSum,
|
|
645
|
-
hidden: column.hidden ?? column.visible === false
|
|
646
|
-
defaultSortOrder: 'ascend'
|
|
667
|
+
hidden: column.hidden ?? column.visible === false
|
|
668
|
+
// defaultSortOrder: 'ascend'
|
|
647
669
|
};
|
|
648
670
|
|
|
649
671
|
// Xử lý đệ quy cho children
|
|
@@ -930,6 +952,16 @@ const InternalTable = props => {
|
|
|
930
952
|
const handleFullScreen = () => {
|
|
931
953
|
setIsFullScreen(!isFullScreen);
|
|
932
954
|
};
|
|
955
|
+
const CustomThead = headerProps => {
|
|
956
|
+
const {
|
|
957
|
+
children,
|
|
958
|
+
className
|
|
959
|
+
} = headerProps;
|
|
960
|
+
return /*#__PURE__*/React.createElement("thead", {
|
|
961
|
+
ref: theadRef,
|
|
962
|
+
className: className
|
|
963
|
+
}, children);
|
|
964
|
+
};
|
|
933
965
|
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(DndContext, {
|
|
934
966
|
sensors: sensors,
|
|
935
967
|
modifiers: [restrictToHorizontalAxis],
|
|
@@ -953,7 +985,10 @@ const InternalTable = props => {
|
|
|
953
985
|
,
|
|
954
986
|
dataSource: filterDataByColumns4(mergedData, filterStates, mergedFilterKeys),
|
|
955
987
|
format: format,
|
|
956
|
-
columns: mergedColumns
|
|
988
|
+
columns: mergedColumns
|
|
989
|
+
|
|
990
|
+
// showSorterTooltip={false}
|
|
991
|
+
,
|
|
957
992
|
showSorterTooltip: {
|
|
958
993
|
target: 'sorter-icon'
|
|
959
994
|
},
|
|
@@ -981,9 +1016,9 @@ const InternalTable = props => {
|
|
|
981
1016
|
toolbarItems: toolbarItems,
|
|
982
1017
|
components: {
|
|
983
1018
|
header: {
|
|
984
|
-
cell: ResizableTitle
|
|
1019
|
+
cell: ResizableTitle,
|
|
1020
|
+
wrapper: CustomThead
|
|
985
1021
|
}
|
|
986
|
-
// body: { cell: TableBodyCell }
|
|
987
1022
|
},
|
|
988
1023
|
onFilter: val => {
|
|
989
1024
|
handleOnFilter(val);
|
|
@@ -314,6 +314,7 @@ export interface CommandItem {
|
|
|
314
314
|
export type IGroupSetting = {
|
|
315
315
|
client?: boolean;
|
|
316
316
|
onGroup?: (props: IOnGroup) => void;
|
|
317
|
+
groupColumnSpan?: number;
|
|
317
318
|
hiddenColumnGroup?: boolean;
|
|
318
319
|
showGroupIcon?: boolean;
|
|
319
320
|
unClearableLevel?: 1 | 2 | 3 | undefined;
|
|
@@ -36,7 +36,7 @@ var _sortable = require("@dnd-kit/sortable");
|
|
|
36
36
|
var _reactResizable = require("react-resizable");
|
|
37
37
|
var _faker = require("@faker-js/faker");
|
|
38
38
|
var _useMergedState = _interopRequireDefault(require("rc-util/lib/hooks/useMergedState"));
|
|
39
|
-
var
|
|
39
|
+
var _reactNumericComponent = require("react-numeric-component");
|
|
40
40
|
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); }
|
|
41
41
|
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; }
|
|
42
42
|
// import GridEdit from "./table/GridEdit"
|
|
@@ -51,6 +51,8 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
51
51
|
|
|
52
52
|
// import {CSS} from "@dnd-kit/utilities";
|
|
53
53
|
|
|
54
|
+
// import Modal from 'antd/es/modal/Modal'
|
|
55
|
+
|
|
54
56
|
_dayjs.default.extend(_customParseFormat.default);
|
|
55
57
|
const MySwal = (0, _sweetalert2ReactContent.default)(_sweetalert.default);
|
|
56
58
|
const ASCEND = 'ascend';
|
|
@@ -69,9 +71,7 @@ const dragActiveStyle = (dragState, id) => {
|
|
|
69
71
|
backgroundColor: '#c0c0c0',
|
|
70
72
|
opacity: 0.3
|
|
71
73
|
};
|
|
72
|
-
}
|
|
73
|
-
// dragover dashed style
|
|
74
|
-
else if (over && id === over && active !== over) {
|
|
74
|
+
} else if (over && id === over && active !== over) {
|
|
75
75
|
style = direction === 'right' ? {
|
|
76
76
|
borderRight: '1px dashed gray'
|
|
77
77
|
} : {
|
|
@@ -91,11 +91,9 @@ const ResizableTitle = props => {
|
|
|
91
91
|
...restProps
|
|
92
92
|
} = props;
|
|
93
93
|
const dragState = (0, _react.useContext)(DragIndexContext);
|
|
94
|
-
|
|
95
|
-
// const { attributes, listeners, setNodeRef, isDragging } = useSortable({ id: props.id });
|
|
96
|
-
|
|
97
94
|
const style = {
|
|
98
95
|
...props.style,
|
|
96
|
+
borderBottom: '1px solid #e0e0e0',
|
|
99
97
|
// cursor: 'move',
|
|
100
98
|
// ...(isDragging ? { position: 'relative', zIndex: 9999, userSelect: 'none' } : {}),
|
|
101
99
|
...dragActiveStyle(dragState, props.id)
|
|
@@ -166,12 +164,11 @@ const InternalTable = props => {
|
|
|
166
164
|
lang,
|
|
167
165
|
locale,
|
|
168
166
|
dataSource,
|
|
169
|
-
allowResizing,
|
|
170
167
|
dataSourceFilter: propDataSourceFilter,
|
|
171
168
|
// onFilterClick,
|
|
172
169
|
// onFilter,
|
|
173
170
|
editAble,
|
|
174
|
-
rowKey: propRowKey,
|
|
171
|
+
// rowKey: propRowKey,
|
|
175
172
|
format,
|
|
176
173
|
onDataChange,
|
|
177
174
|
sortMultiple,
|
|
@@ -179,7 +176,7 @@ const InternalTable = props => {
|
|
|
179
176
|
// @ts-ignore
|
|
180
177
|
onCellPaste,
|
|
181
178
|
clickHeaderToSort = true,
|
|
182
|
-
components,
|
|
179
|
+
// components,
|
|
183
180
|
onChooseColumns,
|
|
184
181
|
groupAble,
|
|
185
182
|
groupSetting,
|
|
@@ -189,16 +186,17 @@ const InternalTable = props => {
|
|
|
189
186
|
pagination,
|
|
190
187
|
height: propsHeight,
|
|
191
188
|
summary,
|
|
192
|
-
infiniteScroll,
|
|
189
|
+
// infiniteScroll,
|
|
193
190
|
wrapSettings,
|
|
194
191
|
onFilter,
|
|
195
192
|
onSorter,
|
|
196
|
-
defaultSorter,
|
|
193
|
+
// defaultSorter,
|
|
197
194
|
toolbarItems,
|
|
198
195
|
allowSortering,
|
|
199
196
|
allowFiltering,
|
|
200
197
|
...rest
|
|
201
198
|
} = props;
|
|
199
|
+
const theadRef = _react.default.useRef(null);
|
|
202
200
|
const id = _react.default.useMemo(() => {
|
|
203
201
|
return tableId ?? _faker.faker.string.alpha(20);
|
|
204
202
|
// return tableId ?? newGuid()
|
|
@@ -273,15 +271,14 @@ const InternalTable = props => {
|
|
|
273
271
|
if (totalHeight) {
|
|
274
272
|
const table = document.querySelector(`#${id}`);
|
|
275
273
|
const title = table?.querySelector(`.ui-rc-table-title`);
|
|
276
|
-
const
|
|
274
|
+
const tableScrollRight = table?.querySelector(`.ui-rc-table-ping-right`);
|
|
277
275
|
const paginationE = table?.querySelector(`.ui-rc-pagination`);
|
|
278
276
|
const toolbar = table?.querySelector(`.ui-rc-toolbar-bottom`);
|
|
279
277
|
const summaryE = table?.querySelector(`.ui-rc-table-summary`);
|
|
280
|
-
const
|
|
281
|
-
const hhh = (totalHeight ?? 0) - (title ? title.offsetHeight : 0) - (header ? header.offsetHeight : 0) - (paginationE ? paginationE.offsetHeight : 0) - (toolbar ? toolbar.offsetHeight : 0) - (summaryE ? summaryE.offsetHeight : 0) - (scrollbar ? scrollbar.offsetHeight : 0);
|
|
278
|
+
const hhh = (totalHeight ?? 0) - (title ? title.offsetHeight : 0) - (theadRef ? theadRef.current.clientHeight : 0) - (paginationE ? paginationE.offsetHeight : 0) - (toolbar ? toolbar.offsetHeight : 0) - (summaryE ? 40 : 0) - (tableScrollRight ? 10 : 0);
|
|
282
279
|
setHeight(hhh > 0 ? hhh : 0);
|
|
283
280
|
}
|
|
284
|
-
}, [id, propsHeight,
|
|
281
|
+
}, [id, propsHeight, summary, theadRef, columns]);
|
|
285
282
|
_react.default.useEffect(() => {
|
|
286
283
|
// const totalHeight = isFullScreen ? windowSize.innerHeight - 50 : propsHeight
|
|
287
284
|
const totalHeight = windowSize.innerHeight - 60;
|
|
@@ -434,26 +431,28 @@ const InternalTable = props => {
|
|
|
434
431
|
dataIndex: column.field ?? column.dataIndex,
|
|
435
432
|
key: column.field ?? column.key,
|
|
436
433
|
// title: () => (<HeaderContent column={{...column} as any} t={t}/>),
|
|
437
|
-
title:
|
|
438
|
-
|
|
439
|
-
|
|
434
|
+
title:
|
|
435
|
+
/*#__PURE__*/
|
|
436
|
+
// <SortableHeaderCell columnKey={column.field}>
|
|
437
|
+
_react.default.createElement(_HeaderContent.default, {
|
|
440
438
|
column: {
|
|
441
439
|
...column
|
|
442
440
|
},
|
|
443
441
|
t: t,
|
|
444
442
|
id: id,
|
|
445
443
|
wrapSettings: wrapSettings
|
|
446
|
-
})
|
|
444
|
+
})
|
|
445
|
+
// </SortableHeaderCell>
|
|
446
|
+
,
|
|
447
447
|
// ellipsis: editAble || column.ellipsis !== false && wrapSettings && wrapSettings.wrapMode !== 'Content' && wrapSettings.wrapMode !== 'Both',
|
|
448
|
-
ellipsis: column.ellipsis !== false || wrapSettings && wrapSettings.wrapMode !== 'Content' && wrapSettings.wrapMode !== 'Both',
|
|
449
|
-
|
|
450
|
-
// ellipsis: column.ellipsis !== false,
|
|
451
|
-
|
|
448
|
+
// ellipsis: column.ellipsis !== false || (wrapSettings && wrapSettings.wrapMode !== 'Content' && wrapSettings.wrapMode !== 'Both'),
|
|
449
|
+
ellipsis: false,
|
|
452
450
|
align: column.textAlign ?? column.align,
|
|
453
451
|
fixed: column.fixedType ?? column.fixed,
|
|
454
452
|
isSummary: column.isSummary ?? column.haveSum,
|
|
455
453
|
hidden: column.hidden ?? column.visible === false
|
|
456
454
|
};
|
|
455
|
+
const headerTooltip = t ? t?.(column.headerTooltip ?? column.columnGroupText ?? column.headerText) : column.headerTooltip ?? column.columnGroupText ?? column.headerText;
|
|
457
456
|
if (transformedColumn.field === '#') {
|
|
458
457
|
return {
|
|
459
458
|
...transformedColumn,
|
|
@@ -555,10 +554,18 @@ const InternalTable = props => {
|
|
|
555
554
|
},
|
|
556
555
|
onHeaderCell: () => ({
|
|
557
556
|
id: `${column.field}`,
|
|
558
|
-
width: column.width,
|
|
557
|
+
// width: column.width,
|
|
558
|
+
|
|
559
|
+
'data-tooltip-id': `${id}-tooltip-header`,
|
|
560
|
+
'data-tooltip-content': headerTooltip,
|
|
559
561
|
onResize: handleResize?.(column),
|
|
560
|
-
className:
|
|
561
|
-
|
|
562
|
+
className: (0, _classnames.default)('', {
|
|
563
|
+
'head-align-center': column.headerTextAlign === 'center',
|
|
564
|
+
'head-align-right': column.headerTextAlign === 'right',
|
|
565
|
+
'ui-rc-table-cell-ellipsis': !wrapSettings || !!(wrapSettings && wrapSettings.wrapMode === 'Content'),
|
|
566
|
+
// mặc định = true
|
|
567
|
+
'ui-rc-table-cell-wrap': wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Header')
|
|
568
|
+
})
|
|
562
569
|
}),
|
|
563
570
|
onCell: (data, index) => {
|
|
564
571
|
const tooltipContent = isOpenTooltip === false ? '' : column?.tooltipDescription ? typeof column.tooltipDescription === 'function' ? column.tooltipDescription({
|
|
@@ -567,14 +574,16 @@ const InternalTable = props => {
|
|
|
567
574
|
}) : column.tooltipDescription : column.template && typeof column.template !== 'function' ? column.template : data[column.field ?? ''];
|
|
568
575
|
return {
|
|
569
576
|
id: `${column.field}`,
|
|
570
|
-
colSpan: groupColumns && data.children && column.field === firstNonGroupColumn?.field ? 2 : groupColumns && data.children && nonGroupColumns[1].field === column.field ? 0 : 1,
|
|
577
|
+
colSpan: groupColumns && data.children && column.field === firstNonGroupColumn?.field ? groupSetting?.groupColumnSpan ?? 2 : groupColumns && data.children && nonGroupColumns[1].field === column.field ? 0 : 1,
|
|
571
578
|
// 'z-index': data?.children && column.field === firstNonGroupColumn?.field ? 11 : undefined,
|
|
572
579
|
...transformedColumn?.onCell?.(data, index),
|
|
573
580
|
className: (0, _classnames.default)(transformedColumn?.onCell?.(data, index).className ?? '', {
|
|
574
581
|
'cell-group': groupColumns && data.children,
|
|
575
|
-
'cell-group-fixed': groupColumns && data.children && column.field === firstNonGroupColumn?.field
|
|
582
|
+
'cell-group-fixed': groupColumns && data.children && column.field === firstNonGroupColumn?.field,
|
|
583
|
+
'ui-rc-table-cell-ellipsis': !wrapSettings || wrapSettings && (wrapSettings.wrapMode === 'Header' || wrapSettings.wrapMode !== 'Both'),
|
|
584
|
+
// mặc định = true
|
|
585
|
+
'ui-rc-table-cell-wrap': wrapSettings && (wrapSettings.wrapMode === 'Content' || wrapSettings.wrapMode === 'Both')
|
|
576
586
|
}),
|
|
577
|
-
// 'data-tooltip-id': "tooltip-cell-content"
|
|
578
587
|
'data-tooltip-id': `${id}-tooltip-cell-content`,
|
|
579
588
|
"data-tooltip-html": _server.default.renderToStaticMarkup( /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, tooltipContent)),
|
|
580
589
|
onMouseEnter: e => {
|
|
@@ -614,8 +623,20 @@ const InternalTable = props => {
|
|
|
614
623
|
return /*#__PURE__*/_react.default.createElement("span", null, currentGroupColumn?.headerText, ": ", (0, _columns.renderContent)(currentGroupColumn, record[record.field], record, rowIndex, colIndex, false, cellFormat));
|
|
615
624
|
}
|
|
616
625
|
if (groupAble && record.children && column.sumGroup === true && column.type === 'number') {
|
|
626
|
+
const thousandSeparator = cellFormat?.thousandSeparator;
|
|
627
|
+
const decimalSeparator = cellFormat?.decimalSeparator;
|
|
628
|
+
const dec = cellFormat?.decimalScale;
|
|
629
|
+
const numericFormatProps = {
|
|
630
|
+
thousandSeparator: (0, _hooks.checkThousandSeparator)(thousandSeparator, decimalSeparator),
|
|
631
|
+
decimalSeparator: (0, _hooks.checkDecimalSeparator)(thousandSeparator, decimalSeparator),
|
|
632
|
+
allowNegative: cellFormat?.allowNegative ?? true,
|
|
633
|
+
prefix: cellFormat?.prefix,
|
|
634
|
+
suffix: cellFormat?.suffix,
|
|
635
|
+
decimalScale: dec,
|
|
636
|
+
fixedDecimalScale: cellFormat?.fixedDecimalScale ?? false
|
|
637
|
+
};
|
|
617
638
|
const sumValue = (0, _hooks.sumByField)((0, _hooks.filterDataByColumns4)(record.children, [], []), column?.field);
|
|
618
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, sumValue);
|
|
639
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, (0, _reactNumericComponent.numericFormatter)(sumValue.toString(), numericFormatProps));
|
|
619
640
|
}
|
|
620
641
|
return (0, _columns.renderContent)(column, value, record, rowIndex, colIndex, false, cellFormat);
|
|
621
642
|
},
|
|
@@ -645,13 +666,14 @@ const InternalTable = props => {
|
|
|
645
666
|
id: id,
|
|
646
667
|
wrapSettings: wrapSettings
|
|
647
668
|
})),
|
|
648
|
-
|
|
649
|
-
ellipsis: editAble || column.ellipsis !== false && wrapSettings && wrapSettings.wrapMode !== 'Content' && wrapSettings.wrapMode !== 'Both',
|
|
669
|
+
ellipsis: false,
|
|
670
|
+
// ellipsis: editAble || column.ellipsis !== false && wrapSettings && wrapSettings.wrapMode !== 'Content' && wrapSettings.wrapMode !== 'Both',
|
|
671
|
+
|
|
650
672
|
align: column.textAlign ?? column.align,
|
|
651
673
|
fixed: column.fixedType ?? column.fixed,
|
|
652
674
|
isSummary: column.isSummary ?? column.haveSum,
|
|
653
|
-
hidden: column.hidden ?? column.visible === false
|
|
654
|
-
defaultSortOrder: 'ascend'
|
|
675
|
+
hidden: column.hidden ?? column.visible === false
|
|
676
|
+
// defaultSortOrder: 'ascend'
|
|
655
677
|
};
|
|
656
678
|
|
|
657
679
|
// Xử lý đệ quy cho children
|
|
@@ -938,6 +960,16 @@ const InternalTable = props => {
|
|
|
938
960
|
const handleFullScreen = () => {
|
|
939
961
|
setIsFullScreen(!isFullScreen);
|
|
940
962
|
};
|
|
963
|
+
const CustomThead = headerProps => {
|
|
964
|
+
const {
|
|
965
|
+
children,
|
|
966
|
+
className
|
|
967
|
+
} = headerProps;
|
|
968
|
+
return /*#__PURE__*/_react.default.createElement("thead", {
|
|
969
|
+
ref: theadRef,
|
|
970
|
+
className: className
|
|
971
|
+
}, children);
|
|
972
|
+
};
|
|
941
973
|
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_core.DndContext, {
|
|
942
974
|
sensors: sensors,
|
|
943
975
|
modifiers: [_modifiers.restrictToHorizontalAxis],
|
|
@@ -961,7 +993,10 @@ const InternalTable = props => {
|
|
|
961
993
|
,
|
|
962
994
|
dataSource: (0, _hooks.filterDataByColumns4)(mergedData, filterStates, mergedFilterKeys),
|
|
963
995
|
format: format,
|
|
964
|
-
columns: mergedColumns
|
|
996
|
+
columns: mergedColumns
|
|
997
|
+
|
|
998
|
+
// showSorterTooltip={false}
|
|
999
|
+
,
|
|
965
1000
|
showSorterTooltip: {
|
|
966
1001
|
target: 'sorter-icon'
|
|
967
1002
|
},
|
|
@@ -989,9 +1024,9 @@ const InternalTable = props => {
|
|
|
989
1024
|
toolbarItems: toolbarItems,
|
|
990
1025
|
components: {
|
|
991
1026
|
header: {
|
|
992
|
-
cell: ResizableTitle
|
|
1027
|
+
cell: ResizableTitle,
|
|
1028
|
+
wrapper: CustomThead
|
|
993
1029
|
}
|
|
994
|
-
// body: { cell: TableBodyCell }
|
|
995
1030
|
},
|
|
996
1031
|
onFilter: val => {
|
|
997
1032
|
handleOnFilter(val);
|
|
@@ -1014,7 +1049,7 @@ const InternalTable = props => {
|
|
|
1014
1049
|
borderRadius: 6,
|
|
1015
1050
|
fontWeight: 500
|
|
1016
1051
|
}
|
|
1017
|
-
}, columns[columns.findIndex(i => i.field === dragIndex.active)]?.headerText))), /*#__PURE__*/_react.default.createElement(
|
|
1052
|
+
}, columns[columns.findIndex(i => i.field === dragIndex.active)]?.headerText))), /*#__PURE__*/_react.default.createElement(_antd.Modal, {
|
|
1018
1053
|
open: isFullScreen,
|
|
1019
1054
|
footer: null,
|
|
1020
1055
|
centered: true,
|
|
@@ -314,6 +314,7 @@ export interface CommandItem {
|
|
|
314
314
|
export type IGroupSetting = {
|
|
315
315
|
client?: boolean;
|
|
316
316
|
onGroup?: (props: IOnGroup) => void;
|
|
317
|
+
groupColumnSpan?: number;
|
|
317
318
|
hiddenColumnGroup?: boolean;
|
|
318
319
|
showGroupIcon?: boolean;
|
|
319
320
|
unClearableLevel?: 1 | 2 | 3 | undefined;
|