es-grid-template 1.9.94 → 1.9.96
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/type.d.ts +3 -1
- package/es/group-component/TableContainer.js +1 -0
- package/es/group-component/TableContainerEdit.js +1 -0
- package/es/group-component/footer/TableFooter.d.ts +2 -1
- package/es/group-component/footer/TableFooter.js +8 -11
- package/es/group-component/footer/TableFooterCell.d.ts +2 -1
- package/es/group-component/footer/TableFooterCell.js +9 -4
- package/es/group-component/footer/TableFooterRow.d.ts +2 -1
- package/es/group-component/footer/TableFooterRow.js +4 -2
- package/es/group-component/table/TableWrapper.d.ts +1 -0
- package/es/group-component/table/TableWrapper.js +4 -3
- package/es/table-component/TableContainer.js +3 -1
- package/es/table-component/TableContainerEdit.js +3 -1
- package/es/table-component/footer/TableFooter.d.ts +2 -1
- package/es/table-component/footer/TableFooter.js +8 -11
- package/es/table-component/footer/TableFooterCell.d.ts +2 -1
- package/es/table-component/footer/TableFooterCell.js +9 -4
- package/es/table-component/footer/TableFooterRow.d.ts +2 -1
- package/es/table-component/footer/TableFooterRow.js +4 -2
- package/es/table-component/table/TableWrapper.d.ts +1 -0
- package/es/table-component/table/TableWrapper.js +4 -3
- package/es/table-virtuoso/InternalTable.js +54 -11
- package/es/table-virtuoso/footer/TableFooterCell.d.ts +2 -1
- package/es/table-virtuoso/footer/TableFooterCell.js +9 -4
- package/es/table-virtuoso/table/Grid.js +37 -8
- package/es/table-virtuoso/table/TableContainer.js +3 -1
- package/es/table-virtuoso/table/TableWrapper.d.ts +1 -0
- package/es/table-virtuoso/table/TableWrapper.js +7 -7
- package/lib/grid-component/type.d.ts +3 -1
- package/lib/group-component/TableContainer.js +1 -0
- package/lib/group-component/TableContainerEdit.js +1 -0
- package/lib/group-component/footer/TableFooter.d.ts +2 -1
- package/lib/group-component/footer/TableFooter.js +8 -11
- package/lib/group-component/footer/TableFooterCell.d.ts +2 -1
- package/lib/group-component/footer/TableFooterCell.js +9 -4
- package/lib/group-component/footer/TableFooterRow.d.ts +2 -1
- package/lib/group-component/footer/TableFooterRow.js +4 -2
- package/lib/group-component/table/TableWrapper.d.ts +1 -0
- package/lib/group-component/table/TableWrapper.js +4 -3
- package/lib/table-component/TableContainer.js +3 -1
- package/lib/table-component/TableContainerEdit.js +3 -1
- package/lib/table-component/footer/TableFooter.d.ts +2 -1
- package/lib/table-component/footer/TableFooter.js +8 -11
- package/lib/table-component/footer/TableFooterCell.d.ts +2 -1
- package/lib/table-component/footer/TableFooterCell.js +9 -4
- package/lib/table-component/footer/TableFooterRow.d.ts +2 -1
- package/lib/table-component/footer/TableFooterRow.js +4 -2
- package/lib/table-component/table/TableWrapper.d.ts +1 -0
- package/lib/table-component/table/TableWrapper.js +4 -3
- package/lib/table-virtuoso/InternalTable.js +53 -10
- package/lib/table-virtuoso/footer/TableFooterCell.d.ts +2 -1
- package/lib/table-virtuoso/footer/TableFooterCell.js +9 -4
- package/lib/table-virtuoso/table/Grid.js +37 -8
- package/lib/table-virtuoso/table/TableContainer.js +3 -1
- package/lib/table-virtuoso/table/TableWrapper.d.ts +1 -0
- package/lib/table-virtuoso/table/TableWrapper.js +7 -7
- package/package.json +2 -2
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import type { Column } from "@tanstack/react-table";
|
|
3
3
|
interface TableFooterCellProps<T> {
|
|
4
4
|
column: Column<T, any>;
|
|
5
|
+
footerRow?: Record<string, any>;
|
|
5
6
|
}
|
|
6
|
-
declare const TableFooterCell: <RecordType extends object>({ column }: TableFooterCellProps<RecordType>) => JSX.Element;
|
|
7
|
+
declare const TableFooterCell: <RecordType extends object>({ column, footerRow }: TableFooterCellProps<RecordType>) => JSX.Element;
|
|
7
8
|
export default TableFooterCell;
|
|
@@ -14,7 +14,8 @@ var _reactNumericComponent = require("react-numeric-component");
|
|
|
14
14
|
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); }
|
|
15
15
|
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; }
|
|
16
16
|
const TableFooterCell = ({
|
|
17
|
-
column
|
|
17
|
+
column,
|
|
18
|
+
footerRow
|
|
18
19
|
}) => {
|
|
19
20
|
const {
|
|
20
21
|
prefix,
|
|
@@ -22,7 +23,10 @@ const TableFooterCell = ({
|
|
|
22
23
|
dataSource
|
|
23
24
|
} = (0, _react.useContext)(_useContext.TableContext);
|
|
24
25
|
const col = column.columnDef.meta ?? {};
|
|
25
|
-
const
|
|
26
|
+
const isCustomFooter = footerRow !== undefined;
|
|
27
|
+
const field = col.field;
|
|
28
|
+
const hasFooterValue = isCustomFooter && Object.prototype.hasOwnProperty.call(footerRow, field) && footerRow[field] != null;
|
|
29
|
+
const colFormat = typeof col.format === 'function' ? col.format(footerRow ?? {}) : col.format;
|
|
26
30
|
const cellFormat = (0, _utils.getFormat)(colFormat, format);
|
|
27
31
|
const thousandSeparator = cellFormat?.thousandSeparator;
|
|
28
32
|
const decimalSeparator = cellFormat?.decimalSeparator;
|
|
@@ -31,7 +35,7 @@ const TableFooterCell = ({
|
|
|
31
35
|
const dec = cellFormat?.decimalScale;
|
|
32
36
|
|
|
33
37
|
// const sumValue = col.type === 'number' ? sumDataByField(filterDataByColumns4(dataSource, filterStates) as any[], col?.key as string) : 0
|
|
34
|
-
const sumValue = col.type === 'number' ? (0, _hooks.sumByField)(dataSource,
|
|
38
|
+
const sumValue = col.type === 'number' ? isCustomFooter ? hasFooterValue ? Number(footerRow[field]) : 0 : (0, _hooks.sumByField)(dataSource, field) : 0;
|
|
35
39
|
const value = !(0, _utils.isEmpty)(sumValue) ? dec || dec === 0 ? parseFloat(Number(sumValue).toFixed(dec)).toString() : sumValue.toString() : '0';
|
|
36
40
|
const cellValue = col.type === 'number' && col.isSummary !== false ? value : '';
|
|
37
41
|
const numberValue = Number(value);
|
|
@@ -44,6 +48,7 @@ const TableFooterCell = ({
|
|
|
44
48
|
decimalScale: dec,
|
|
45
49
|
fixedDecimalScale: cellFormat?.fixedDecimalScale ?? false
|
|
46
50
|
};
|
|
51
|
+
const content = isCustomFooter && (!hasFooterValue || col.isSummary === false) ? '' : col.summaryTemplate ? col.summaryTemplate(numberValue, field) : isCustomFooter && col.type !== 'number' ? footerRow[field] : (0, _reactNumericComponent.numericFormatter)(cellValue, numericFormatProps);
|
|
47
52
|
return /*#__PURE__*/_react.default.createElement("th", {
|
|
48
53
|
className: (0, _classnames.default)(`${prefix}-grid-cell`, {
|
|
49
54
|
// [`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
|
|
@@ -58,6 +63,6 @@ const TableFooterCell = ({
|
|
|
58
63
|
minWidth: column?.getSize(),
|
|
59
64
|
height: 40
|
|
60
65
|
}
|
|
61
|
-
}, column.id !== "id" && column.id !== "selection_column" ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null,
|
|
66
|
+
}, column.id !== "id" && column.id !== "selection_column" ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, content) : '');
|
|
62
67
|
};
|
|
63
68
|
var _default = exports.default = TableFooterCell;
|
|
@@ -60,16 +60,46 @@ const Grid = props => {
|
|
|
60
60
|
setColumnSizing,
|
|
61
61
|
columnFilters,
|
|
62
62
|
setColumnOrder,
|
|
63
|
-
rowSelection,
|
|
64
63
|
className: tableClassNames,
|
|
65
64
|
...rest
|
|
66
65
|
} = props;
|
|
66
|
+
const selectedRowState = table.getState().rowSelection;
|
|
67
67
|
const [isSelectionChange, setIsSelectionChange] = _react.default.useState({
|
|
68
68
|
isChange: false,
|
|
69
69
|
type: '',
|
|
70
70
|
rowData: {},
|
|
71
71
|
rowsData: []
|
|
72
72
|
});
|
|
73
|
+
const rowSelectedRef = _react.default.useRef(rowSelected);
|
|
74
|
+
_react.default.useEffect(() => {
|
|
75
|
+
rowSelectedRef.current = rowSelected;
|
|
76
|
+
}, [rowSelected]);
|
|
77
|
+
const pruneSelection = selectionSettings?.pruneSelection === true;
|
|
78
|
+
const selectedViewRows = _react.default.useMemo(() => {
|
|
79
|
+
if (!pruneSelection || props.loading) {
|
|
80
|
+
return [];
|
|
81
|
+
}
|
|
82
|
+
return table.getCoreRowModel().flatRows.filter(row => !row.original.isGroupRow && selectedRowState[row.id]).map(row => row.original);
|
|
83
|
+
}, [pruneSelection, props.loading, table, dataSource, selectedRowState]);
|
|
84
|
+
const selectedViewIds = JSON.stringify(selectedViewRows.map(row => String(row.rowId)).sort());
|
|
85
|
+
const lastNotifiedSelection = _react.default.useRef(null);
|
|
86
|
+
|
|
87
|
+
// Keep event handlers in sync with the view without another state/effect.
|
|
88
|
+
const selectionChange = pruneSelection && !props.loading ? {
|
|
89
|
+
...isSelectionChange,
|
|
90
|
+
rowsData: selectedViewRows
|
|
91
|
+
} : isSelectionChange;
|
|
92
|
+
_react.default.useEffect(() => {
|
|
93
|
+
if (!pruneSelection || props.loading || lastNotifiedSelection.current === selectedViewIds) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
lastNotifiedSelection.current = selectedViewIds;
|
|
97
|
+
rowSelected?.({
|
|
98
|
+
type: isSelectionChange.isChange ? isSelectionChange.type : 'selectionPruned',
|
|
99
|
+
rowData: isSelectionChange.rowData,
|
|
100
|
+
selected: selectedViewRows
|
|
101
|
+
});
|
|
102
|
+
}, [pruneSelection, props.loading, selectedViewIds, selectedViewRows, rowSelected, isSelectionChange.isChange, isSelectionChange.type, isSelectionChange.rowData]);
|
|
73
103
|
const [sorterChange, setSorterChange] = _react.default.useState(false);
|
|
74
104
|
const [filterChange, setFilterChange] = _react.default.useState(false);
|
|
75
105
|
const [isFullScreen, setIsFullScreen] = _react.default.useState(false);
|
|
@@ -86,18 +116,17 @@ const Grid = props => {
|
|
|
86
116
|
// }, [mergedSelectedKeys])
|
|
87
117
|
|
|
88
118
|
_react.default.useEffect(() => {
|
|
89
|
-
if (isSelectionChange.isChange) {
|
|
90
|
-
const
|
|
91
|
-
const ids = Object.keys(aa);
|
|
119
|
+
if (!pruneSelection && isSelectionChange.isChange) {
|
|
120
|
+
const ids = Object.keys(selectedRowState);
|
|
92
121
|
const ssss = (0, _utils.filterByIds)(ids, isSelectionChange.rowsData ?? []); // lấy rowsData của trang hiện tại
|
|
93
122
|
|
|
94
|
-
|
|
123
|
+
rowSelectedRef.current?.({
|
|
95
124
|
type: isSelectionChange.type,
|
|
96
125
|
rowData: isSelectionChange.rowData,
|
|
97
126
|
selected: ssss.filter(x => !x.isGroupRow)
|
|
98
127
|
});
|
|
99
128
|
}
|
|
100
|
-
}, [isSelectionChange,
|
|
129
|
+
}, [isSelectionChange, selectedRowState, pruneSelection]);
|
|
101
130
|
_react.default.useEffect(() => {
|
|
102
131
|
if (sorterChange) {
|
|
103
132
|
const aa = table.getState().sorting;
|
|
@@ -188,7 +217,7 @@ const Grid = props => {
|
|
|
188
217
|
originData: originData,
|
|
189
218
|
prefix: prefix,
|
|
190
219
|
selectionSettings: selectionSettings,
|
|
191
|
-
isSelectionChange:
|
|
220
|
+
isSelectionChange: selectionChange,
|
|
192
221
|
setIsSelectionChange: setIsSelectionChange,
|
|
193
222
|
setSorterChange: setSorterChange,
|
|
194
223
|
setFilterChange: setFilterChange,
|
|
@@ -258,7 +287,7 @@ const Grid = props => {
|
|
|
258
287
|
originData: originData,
|
|
259
288
|
prefix: prefix,
|
|
260
289
|
selectionSettings: selectionSettings,
|
|
261
|
-
isSelectionChange:
|
|
290
|
+
isSelectionChange: selectionChange,
|
|
262
291
|
setIsSelectionChange: setIsSelectionChange,
|
|
263
292
|
setSorterChange: setSorterChange,
|
|
264
293
|
setFilterChange: setFilterChange,
|
|
@@ -299,7 +299,9 @@ const TableContainer = props => {
|
|
|
299
299
|
pagination,
|
|
300
300
|
groupSetting
|
|
301
301
|
}
|
|
302
|
-
}, /*#__PURE__*/_react.default.createElement(_TableWrapper.default, (0, _extends2.default)({
|
|
302
|
+
}, /*#__PURE__*/_react.default.createElement(_TableWrapper.default, (0, _extends2.default)({
|
|
303
|
+
footerDataSource: props.footerDataSource
|
|
304
|
+
}, rest, {
|
|
303
305
|
tableContainerRef: tableContainerRef,
|
|
304
306
|
prefix: prefix,
|
|
305
307
|
id: id,
|
|
@@ -258,14 +258,14 @@ const TableWrapper = props => {
|
|
|
258
258
|
},
|
|
259
259
|
fixedFooterContent: summary ? () => {
|
|
260
260
|
const visibleColumns = table.getVisibleLeafColumns();
|
|
261
|
-
return /*#__PURE__*/_react.default.createElement("tr", {
|
|
261
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, (props.footerDataSource ?? [undefined]).map((footerRow, index) => /*#__PURE__*/_react.default.createElement("tr", {
|
|
262
|
+
key: index,
|
|
262
263
|
className: "ui-rc-grid-footer-row"
|
|
263
|
-
}, visibleColumns.map(
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
}));
|
|
264
|
+
}, visibleColumns.map(column => /*#__PURE__*/_react.default.createElement(_TableFooterCell.default, {
|
|
265
|
+
key: column.id,
|
|
266
|
+
column: column,
|
|
267
|
+
footerRow: footerRow
|
|
268
|
+
})))));
|
|
269
269
|
} : undefined
|
|
270
270
|
}))), /*#__PURE__*/_react.default.createElement(_reactTooltip.Tooltip, {
|
|
271
271
|
id: `${id}-tooltip-content`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "es-grid-template",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.96",
|
|
4
4
|
"description": "es-grid-template",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@hookform/resolvers": "5.0.1",
|
|
48
48
|
"@popperjs/core": "2.11.8",
|
|
49
49
|
"@rc-component/color-picker": "2.0.1",
|
|
50
|
-
"@rc-component/father-plugin": "
|
|
50
|
+
"@rc-component/father-plugin": "2.0.1",
|
|
51
51
|
"@rc-component/trigger": "2.0.0",
|
|
52
52
|
"@rc-component/util": "1.0.1",
|
|
53
53
|
"@tanstack/react-table": "8.21.3",
|