es-grid-template 1.8.71 → 1.8.73
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/TempTable.js +2 -1
- package/es/grid-component/type.d.ts +1 -3
- package/es/group-component/ColumnsChoose.d.ts +13 -0
- package/es/group-component/ColumnsChoose.js +211 -0
- package/es/group-component/ColumnsGroup/ColumnsGroup.d.ts +12 -0
- package/es/group-component/ColumnsGroup/ColumnsGroup.js +230 -0
- package/es/group-component/ColumnsGroup/index.d.ts +1 -0
- package/es/group-component/ColumnsGroup/index.js +1 -0
- package/es/group-component/ContextMenu.d.ts +19 -0
- package/es/group-component/ContextMenu.js +74 -0
- package/es/group-component/InternalTable.d.ts +8 -0
- package/es/group-component/InternalTable.js +224 -0
- package/es/group-component/TableContainer.d.ts +49 -0
- package/es/group-component/TableContainer.js +375 -0
- package/es/group-component/TableContainerEdit.d.ts +48 -0
- package/es/group-component/TableContainerEdit.js +2068 -0
- package/es/group-component/body/EditableCell.d.ts +16 -0
- package/es/group-component/body/EditableCell.js +1066 -0
- package/es/group-component/body/TableBody.d.ts +14 -0
- package/es/group-component/body/TableBody.js +82 -0
- package/es/group-component/body/TableBodyCell.d.ts +12 -0
- package/es/group-component/body/TableBodyCell.js +587 -0
- package/es/group-component/body/TableBodyCellEdit.d.ts +17 -0
- package/es/group-component/body/TableBodyCellEdit.js +1398 -0
- package/es/group-component/body/TableBodyCellEmpty.d.ts +12 -0
- package/es/group-component/body/TableBodyCellEmpty.js +149 -0
- package/es/group-component/body/TableBodyRow.d.ts +21 -0
- package/es/group-component/body/TableBodyRow.js +199 -0
- package/es/group-component/body/TableBodyRowGroupCell.d.ts +12 -0
- package/es/group-component/body/TableBodyRowGroupCell.js +567 -0
- package/es/group-component/components/ControlCheckbox.d.ts +13 -0
- package/es/group-component/components/ControlCheckbox.js +84 -0
- package/es/group-component/components/EditForm/EditForm.d.ts +27 -0
- package/es/group-component/components/EditForm/EditForm.js +394 -0
- package/es/group-component/components/EditForm/index.d.ts +1 -0
- package/es/group-component/components/EditForm/index.js +1 -0
- package/es/group-component/components/InputControl/InputControl.d.ts +27 -0
- package/es/group-component/components/InputControl/InputControl.js +118 -0
- package/es/group-component/components/InputControl/index.d.ts +1 -0
- package/es/group-component/components/InputControl/index.js +1 -0
- package/es/group-component/components/async-select/index.d.ts +11 -0
- package/es/group-component/components/async-select/index.js +38 -0
- package/es/group-component/components/async-table-select/index.d.ts +11 -0
- package/es/group-component/components/async-table-select/index.js +40 -0
- package/es/group-component/components/checkbox-control/index.d.ts +13 -0
- package/es/group-component/components/checkbox-control/index.js +40 -0
- package/es/group-component/components/checkbox-filter/CheckboxFilter.d.ts +18 -0
- package/es/group-component/components/checkbox-filter/CheckboxFilter.js +258 -0
- package/es/group-component/components/checkbox-filter/FilterSearch.d.ts +12 -0
- package/es/group-component/components/checkbox-filter/FilterSearch.js +36 -0
- package/es/group-component/components/command/Command.d.ts +10 -0
- package/es/group-component/components/command/Command.js +35 -0
- package/es/group-component/components/number/index.d.ts +12 -0
- package/es/group-component/components/number/index.js +42 -0
- package/es/group-component/components/number-range/index.d.ts +13 -0
- package/es/group-component/components/number-range/index.js +79 -0
- package/es/group-component/features/operator.d.ts +24 -0
- package/es/group-component/features/operator.js +62 -0
- package/es/group-component/footer/TableFooter.d.ts +7 -0
- package/es/group-component/footer/TableFooter.js +34 -0
- package/es/group-component/footer/TableFooterCell.d.ts +7 -0
- package/es/group-component/footer/TableFooterCell.js +66 -0
- package/es/group-component/footer/TableFooterRow.d.ts +8 -0
- package/es/group-component/footer/TableFooterRow.js +30 -0
- package/es/group-component/header/TableHead.d.ts +15 -0
- package/es/group-component/header/TableHead.js +98 -0
- package/es/group-component/header/TableHeadCell.d.ts +15 -0
- package/es/group-component/header/TableHeadCell.js +310 -0
- package/es/group-component/header/TableHeadCell2.d.ts +17 -0
- package/es/group-component/header/TableHeadCell2.js +321 -0
- package/es/group-component/header/TableHeadGroupCell.d.ts +17 -0
- package/es/group-component/header/TableHeadGroupCell.js +94 -0
- package/es/group-component/header/TableHeadRow.d.ts +15 -0
- package/es/group-component/header/TableHeadRow.js +52 -0
- package/es/group-component/header/renderFilter.d.ts +20 -0
- package/es/group-component/header/renderFilter.js +291 -0
- package/es/group-component/hook/convert.d.ts +1 -0
- package/es/group-component/hook/convert.js +28 -0
- package/es/group-component/hook/useColumns.d.ts +28 -0
- package/es/group-component/hook/useColumns.js +306 -0
- package/es/group-component/hook/useFilterOperator.d.ts +7 -0
- package/es/group-component/hook/useFilterOperator.js +33 -0
- package/es/group-component/hook/utils.d.ts +220 -0
- package/es/group-component/hook/utils.js +2340 -0
- package/es/group-component/index.d.ts +2 -0
- package/es/group-component/index.js +2 -0
- package/es/group-component/style.d.ts +22 -0
- package/es/group-component/style.js +48 -0
- package/es/group-component/style.scss +1438 -0
- package/es/group-component/table/Grid.d.ts +33 -0
- package/es/group-component/table/Grid.js +439 -0
- package/es/group-component/table/TableWrapper.d.ts +33 -0
- package/es/group-component/table/TableWrapper.js +250 -0
- package/es/group-component/useContext.d.ts +100 -0
- package/es/group-component/useContext.js +21 -0
- package/es/table-component/InternalTable.js +9 -2
- package/es/table-component/TableContainer.d.ts +1 -0
- package/es/table-component/TableContainer.js +6 -2
- package/es/table-component/TableContainerEdit.d.ts +1 -0
- package/es/table-component/TableContainerEdit.js +4 -2
- package/es/table-component/body/TableBodyCell.js +49 -40
- package/es/table-component/body/TableBodyCellEdit.js +9 -6
- package/es/table-component/body/TableBodyRow.js +4 -1
- package/es/table-component/header/TableHeadCell2.js +39 -3
- package/es/table-component/hook/utils.d.ts +1 -0
- package/es/table-component/hook/utils.js +15 -7
- package/es/table-component/style.js +1 -1
- package/es/table-component/table/Grid.d.ts +1 -0
- package/es/table-component/table/Grid.js +10 -3
- package/es/table-component/useContext.d.ts +6 -0
- package/es/table-component/useContext.js +2 -1
- package/es/table-virtuoso/InternalTable.js +2 -2
- package/es/table-virtuoso/body/TableBodyCell.js +2 -7
- package/es/table-virtuoso/body/TableBodyCellRowGroup.d.ts +14 -0
- package/es/table-virtuoso/body/TableBodyCellRowGroup.js +196 -0
- package/es/table-virtuoso/body/TableBodyRow.d.ts +1 -1
- package/es/table-virtuoso/body/TableBodyRow.js +43 -1
- package/es/table-virtuoso/hook/utils.d.ts +1 -0
- package/es/table-virtuoso/hook/utils.js +29 -0
- package/es/table-virtuoso/style.js +3 -1
- package/es/table-virtuoso/table/Grid.js +2 -2
- package/es/table-virtuoso/table/TableWrapper.d.ts +7 -1
- package/es/table-virtuoso/table/TableWrapper.js +24 -5
- package/es/table-virtuoso/useContext.d.ts +6 -3
- package/es/table-virtuoso/useContext.js +18 -0
- package/lib/grid-component/TempTable.js +2 -1
- package/lib/grid-component/type.d.ts +1 -3
- package/lib/group-component/ColumnsChoose.d.ts +13 -0
- package/lib/group-component/ColumnsChoose.js +221 -0
- package/lib/group-component/ColumnsGroup/ColumnsGroup.d.ts +12 -0
- package/lib/group-component/ColumnsGroup/ColumnsGroup.js +241 -0
- package/lib/group-component/ColumnsGroup/index.d.ts +1 -0
- package/lib/group-component/ColumnsGroup/index.js +16 -0
- package/lib/group-component/ContextMenu.d.ts +19 -0
- package/lib/group-component/ContextMenu.js +83 -0
- package/lib/group-component/InternalTable.d.ts +8 -0
- package/lib/group-component/InternalTable.js +233 -0
- package/lib/group-component/TableContainer.d.ts +49 -0
- package/lib/group-component/TableContainer.js +382 -0
- package/lib/group-component/TableContainerEdit.d.ts +48 -0
- package/lib/group-component/TableContainerEdit.js +2075 -0
- package/lib/group-component/body/EditableCell.d.ts +16 -0
- package/lib/group-component/body/EditableCell.js +1075 -0
- package/lib/group-component/body/TableBody.d.ts +14 -0
- package/lib/group-component/body/TableBody.js +91 -0
- package/lib/group-component/body/TableBodyCell.d.ts +12 -0
- package/lib/group-component/body/TableBodyCell.js +595 -0
- package/lib/group-component/body/TableBodyCellEdit.d.ts +17 -0
- package/lib/group-component/body/TableBodyCellEdit.js +1405 -0
- package/lib/group-component/body/TableBodyCellEmpty.d.ts +12 -0
- package/lib/group-component/body/TableBodyCellEmpty.js +156 -0
- package/lib/group-component/body/TableBodyRow.d.ts +21 -0
- package/lib/group-component/body/TableBodyRow.js +206 -0
- package/lib/group-component/body/TableBodyRowGroupCell.d.ts +12 -0
- package/lib/group-component/body/TableBodyRowGroupCell.js +575 -0
- package/lib/group-component/components/ControlCheckbox.d.ts +13 -0
- package/lib/group-component/components/ControlCheckbox.js +92 -0
- package/lib/group-component/components/EditForm/EditForm.d.ts +27 -0
- package/lib/group-component/components/EditForm/EditForm.js +404 -0
- package/lib/group-component/components/EditForm/index.d.ts +1 -0
- package/lib/group-component/components/EditForm/index.js +16 -0
- package/lib/group-component/components/InputControl/InputControl.d.ts +27 -0
- package/lib/group-component/components/InputControl/InputControl.js +127 -0
- package/lib/group-component/components/InputControl/index.d.ts +1 -0
- package/lib/group-component/components/InputControl/index.js +16 -0
- package/lib/group-component/components/async-select/index.d.ts +11 -0
- package/lib/group-component/components/async-select/index.js +47 -0
- package/lib/group-component/components/async-table-select/index.d.ts +11 -0
- package/lib/group-component/components/async-table-select/index.js +49 -0
- package/lib/group-component/components/checkbox-control/index.d.ts +13 -0
- package/lib/group-component/components/checkbox-control/index.js +48 -0
- package/lib/group-component/components/checkbox-filter/CheckboxFilter.d.ts +18 -0
- package/lib/group-component/components/checkbox-filter/CheckboxFilter.js +267 -0
- package/lib/group-component/components/checkbox-filter/FilterSearch.d.ts +12 -0
- package/lib/group-component/components/checkbox-filter/FilterSearch.js +44 -0
- package/lib/group-component/components/command/Command.d.ts +10 -0
- package/lib/group-component/components/command/Command.js +44 -0
- package/lib/group-component/components/number/index.d.ts +12 -0
- package/lib/group-component/components/number/index.js +50 -0
- package/lib/group-component/components/number-range/index.d.ts +13 -0
- package/lib/group-component/components/number-range/index.js +87 -0
- package/lib/group-component/features/operator.d.ts +24 -0
- package/lib/group-component/features/operator.js +67 -0
- package/lib/group-component/footer/TableFooter.d.ts +7 -0
- package/lib/group-component/footer/TableFooter.js +44 -0
- package/lib/group-component/footer/TableFooterCell.d.ts +7 -0
- package/lib/group-component/footer/TableFooterCell.js +75 -0
- package/lib/group-component/footer/TableFooterRow.d.ts +8 -0
- package/lib/group-component/footer/TableFooterRow.js +37 -0
- package/lib/group-component/header/TableHead.d.ts +15 -0
- package/lib/group-component/header/TableHead.js +107 -0
- package/lib/group-component/header/TableHeadCell.d.ts +15 -0
- package/lib/group-component/header/TableHeadCell.js +319 -0
- package/lib/group-component/header/TableHeadCell2.d.ts +17 -0
- package/lib/group-component/header/TableHeadCell2.js +330 -0
- package/lib/group-component/header/TableHeadGroupCell.d.ts +17 -0
- package/lib/group-component/header/TableHeadGroupCell.js +103 -0
- package/lib/group-component/header/TableHeadRow.d.ts +15 -0
- package/lib/group-component/header/TableHeadRow.js +59 -0
- package/lib/group-component/header/renderFilter.d.ts +20 -0
- package/lib/group-component/header/renderFilter.js +301 -0
- package/lib/group-component/hook/convert.d.ts +1 -0
- package/lib/group-component/hook/convert.js +34 -0
- package/lib/group-component/hook/useColumns.d.ts +28 -0
- package/lib/group-component/hook/useColumns.js +318 -0
- package/lib/group-component/hook/useFilterOperator.d.ts +7 -0
- package/lib/group-component/hook/useFilterOperator.js +40 -0
- package/lib/group-component/hook/utils.d.ts +220 -0
- package/lib/group-component/hook/utils.js +2468 -0
- package/lib/group-component/index.d.ts +2 -0
- package/lib/group-component/index.js +9 -0
- package/lib/group-component/style.d.ts +22 -0
- package/lib/group-component/style.js +55 -0
- package/lib/group-component/style.scss +1438 -0
- package/lib/group-component/table/Grid.d.ts +33 -0
- package/lib/group-component/table/Grid.js +444 -0
- package/lib/group-component/table/TableWrapper.d.ts +33 -0
- package/lib/group-component/table/TableWrapper.js +259 -0
- package/lib/group-component/useContext.d.ts +100 -0
- package/lib/group-component/useContext.js +27 -0
- package/lib/table-component/InternalTable.js +9 -2
- package/lib/table-component/TableContainer.d.ts +1 -0
- package/lib/table-component/TableContainer.js +6 -2
- package/lib/table-component/TableContainerEdit.d.ts +1 -0
- package/lib/table-component/TableContainerEdit.js +4 -2
- package/lib/table-component/body/TableBodyCell.js +49 -40
- package/lib/table-component/body/TableBodyCellEdit.js +9 -6
- package/lib/table-component/body/TableBodyRow.js +4 -1
- package/lib/table-component/header/TableHeadCell2.js +38 -2
- package/lib/table-component/hook/utils.d.ts +1 -0
- package/lib/table-component/hook/utils.js +16 -7
- package/lib/table-component/style.js +1 -1
- package/lib/table-component/table/Grid.d.ts +1 -0
- package/lib/table-component/table/Grid.js +10 -3
- package/lib/table-component/useContext.d.ts +6 -0
- package/lib/table-component/useContext.js +2 -1
- package/lib/table-virtuoso/InternalTable.js +2 -2
- package/lib/table-virtuoso/body/TableBodyCell.js +2 -7
- package/lib/table-virtuoso/body/TableBodyCellRowGroup.d.ts +14 -0
- package/lib/table-virtuoso/body/TableBodyCellRowGroup.js +203 -0
- package/lib/table-virtuoso/body/TableBodyRow.d.ts +1 -1
- package/lib/table-virtuoso/body/TableBodyRow.js +43 -1
- package/lib/table-virtuoso/hook/utils.d.ts +1 -0
- package/lib/table-virtuoso/hook/utils.js +32 -1
- package/lib/table-virtuoso/style.js +3 -1
- package/lib/table-virtuoso/table/Grid.js +2 -2
- package/lib/table-virtuoso/table/TableWrapper.d.ts +7 -1
- package/lib/table-virtuoso/table/TableWrapper.js +24 -5
- package/lib/table-virtuoso/useContext.d.ts +6 -3
- package/lib/table-virtuoso/useContext.js +18 -0
- package/package.json +1 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ColumnDef, ColumnPinningState, ExpandedState, VisibilityState } from '@tanstack/react-table';
|
|
2
|
+
import type { ColumnsTable, Sorter, TableProps } from '../../grid-component/type';
|
|
3
|
+
import type { Dispatch, Key, SetStateAction } from 'react';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
type Props<T> = Omit<TableProps<T>, 'columns'> & {
|
|
6
|
+
id: string;
|
|
7
|
+
rowKey: string;
|
|
8
|
+
prefix: string;
|
|
9
|
+
columns: ColumnDef<T>[];
|
|
10
|
+
propsColumns: ColumnsTable<T>;
|
|
11
|
+
setColumns: Dispatch<SetStateAction<ColumnsTable<T>>>;
|
|
12
|
+
columnHidden: VisibilityState;
|
|
13
|
+
expanded: ExpandedState;
|
|
14
|
+
setExpanded: any;
|
|
15
|
+
columnPinning: ColumnPinningState;
|
|
16
|
+
setColumnPinning: Dispatch<SetStateAction<ColumnPinningState>>;
|
|
17
|
+
originData: T[];
|
|
18
|
+
mergedFilterKeys: any;
|
|
19
|
+
setMergedFilterKeys: any;
|
|
20
|
+
isFullScreen: boolean;
|
|
21
|
+
setIsFullScreen: Dispatch<SetStateAction<boolean>>;
|
|
22
|
+
triggerFilter: Dispatch<SetStateAction<any>>;
|
|
23
|
+
triggerSorter: Dispatch<SetStateAction<Sorter[]>>;
|
|
24
|
+
onContextMenu?: (data: T) => (event: any) => void;
|
|
25
|
+
triggerChangeColumns?: (args: any, keys: any, type: string) => void;
|
|
26
|
+
windowSize: any;
|
|
27
|
+
isDataTree: boolean;
|
|
28
|
+
mergedSelectedKeys: Key[];
|
|
29
|
+
columnVisibility?: any;
|
|
30
|
+
setColumnVisibility?: Dispatch<SetStateAction<any>>;
|
|
31
|
+
};
|
|
32
|
+
declare const Grid: <RecordType extends object>(props: Props<RecordType>) => React.JSX.Element;
|
|
33
|
+
export default Grid;
|
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var _antd = require("antd");
|
|
10
|
+
var _faker = require("@faker-js/faker");
|
|
11
|
+
var _reactTable = require("@tanstack/react-table");
|
|
12
|
+
var _core = require("@dnd-kit/core");
|
|
13
|
+
var _modifiers = require("@dnd-kit/modifiers");
|
|
14
|
+
var _sortable = require("@dnd-kit/sortable");
|
|
15
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
16
|
+
var _TableContainer = _interopRequireDefault(require("../TableContainer"));
|
|
17
|
+
var _operator = require("../features/operator");
|
|
18
|
+
var _utils = require("../hook/utils");
|
|
19
|
+
var _TableContainerEdit = _interopRequireDefault(require("../TableContainerEdit"));
|
|
20
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
21
|
+
var _style = require("../style");
|
|
22
|
+
var _utils2 = require("../../table-component/hook/utils");
|
|
23
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
24
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
25
|
+
// import { makeData } from "../default/makeData";
|
|
26
|
+
|
|
27
|
+
const Grid = props => {
|
|
28
|
+
const {
|
|
29
|
+
theme,
|
|
30
|
+
t,
|
|
31
|
+
id,
|
|
32
|
+
prefix,
|
|
33
|
+
dataSource,
|
|
34
|
+
originData,
|
|
35
|
+
columns,
|
|
36
|
+
propsColumns,
|
|
37
|
+
setColumns,
|
|
38
|
+
pagination,
|
|
39
|
+
expanded,
|
|
40
|
+
setExpanded,
|
|
41
|
+
columnHidden,
|
|
42
|
+
columnPinning,
|
|
43
|
+
setColumnPinning,
|
|
44
|
+
selectionSettings,
|
|
45
|
+
rowSelected,
|
|
46
|
+
sortMultiple,
|
|
47
|
+
triggerSorter,
|
|
48
|
+
triggerFilter,
|
|
49
|
+
setMergedFilterKeys,
|
|
50
|
+
onSorter,
|
|
51
|
+
onFilter,
|
|
52
|
+
allowFiltering,
|
|
53
|
+
allowSortering,
|
|
54
|
+
groupColumns,
|
|
55
|
+
// height= 700,
|
|
56
|
+
height,
|
|
57
|
+
minHeight,
|
|
58
|
+
editAble,
|
|
59
|
+
triggerChangeColumns,
|
|
60
|
+
infiniteScroll,
|
|
61
|
+
mergedSelectedKeys,
|
|
62
|
+
allowResizing,
|
|
63
|
+
windowSize,
|
|
64
|
+
fullScreenTitle,
|
|
65
|
+
className: tableClassNames,
|
|
66
|
+
groupSetting,
|
|
67
|
+
...rest
|
|
68
|
+
} = props;
|
|
69
|
+
const [columnResizeMode] = _react.default.useState('onChange');
|
|
70
|
+
const [columnResizeDirection] = _react.default.useState('ltr');
|
|
71
|
+
const [paginationState, setPagination] = _react.default.useState({
|
|
72
|
+
pageIndex: pagination && pagination.currentPage ? pagination.currentPage - 1 : 0,
|
|
73
|
+
pageSize: pagination && pagination.pageSize ? pagination.pageSize : 20
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// const [rowSelection, setRowSelection] = React.useState<RowSelectionState>({})
|
|
77
|
+
|
|
78
|
+
// const [rowSelection, setRowSelection] = React.useState<RowSelectionState>(convertToObjTrue(selectionSettings?.selectedRowKeys ?? []))
|
|
79
|
+
const [rowSelection, setRowSelection] = _react.default.useState({});
|
|
80
|
+
// const [rowsSelected, setRowsSelected] = React.useState<RecordType[]>([])
|
|
81
|
+
|
|
82
|
+
const [grouping, setGrouping] = _react.default.useState([]);
|
|
83
|
+
const [columnSizing, setColumnSizing] = _react.default.useState({});
|
|
84
|
+
const [columnSizingInfo, setColumnSizingInfo] = _react.default.useState({});
|
|
85
|
+
// const [manualUpdate, setManualUpdate] = React.useState(false)
|
|
86
|
+
// const [manualResize, setManualResize] = React.useState(false)
|
|
87
|
+
|
|
88
|
+
const [columnFilters, setColumnFilters] = _react.default.useState([]);
|
|
89
|
+
const [operator, setOperator] = _react.default.useState([]);
|
|
90
|
+
const [sorting, setSorting] = _react.default.useState([]);
|
|
91
|
+
const [columnOrder, setColumnOrder] = _react.default.useState(() => columns.map(c => c.id));
|
|
92
|
+
const [isSelectionChange, setIsSelectionChange] = _react.default.useState({
|
|
93
|
+
isChange: false,
|
|
94
|
+
type: '',
|
|
95
|
+
rowData: {},
|
|
96
|
+
rowsData: []
|
|
97
|
+
});
|
|
98
|
+
const [sorterChange, setSorterChange] = _react.default.useState(false);
|
|
99
|
+
const [filterChange, setFilterChange] = _react.default.useState(false);
|
|
100
|
+
const [isFullScreen, setIsFullScreen] = _react.default.useState(false);
|
|
101
|
+
const table = (0, _reactTable.useReactTable)({
|
|
102
|
+
_features: [_operator.OperatorFeature],
|
|
103
|
+
data: dataSource,
|
|
104
|
+
columns: columns,
|
|
105
|
+
state: {
|
|
106
|
+
rowSelection,
|
|
107
|
+
expanded,
|
|
108
|
+
columnPinning,
|
|
109
|
+
columnVisibility: columnHidden,
|
|
110
|
+
pagination: pagination && !infiniteScroll ? paginationState : undefined,
|
|
111
|
+
grouping,
|
|
112
|
+
columnSizing,
|
|
113
|
+
columnOrder,
|
|
114
|
+
columnFilters,
|
|
115
|
+
operator,
|
|
116
|
+
sorting
|
|
117
|
+
},
|
|
118
|
+
getCoreRowModel: (0, _reactTable.getCoreRowModel)(),
|
|
119
|
+
getRowId(originalRow) {
|
|
120
|
+
return originalRow.rowId;
|
|
121
|
+
},
|
|
122
|
+
getSubRows: row => row.children,
|
|
123
|
+
// RowSelection
|
|
124
|
+
enableSubRowSelection: selectionSettings && selectionSettings.mode === 'checkbox' && selectionSettings.type !== 'single',
|
|
125
|
+
enableMultiRowSelection: selectionSettings && (selectionSettings.mode === 'checkbox' || selectionSettings.type !== 'single'),
|
|
126
|
+
// enableRowSelection: true,
|
|
127
|
+
enableRowSelection: row => {
|
|
128
|
+
if (selectionSettings?.getCheckboxProps) {
|
|
129
|
+
return !selectionSettings?.getCheckboxProps(row.original)?.disabled;
|
|
130
|
+
}
|
|
131
|
+
return true;
|
|
132
|
+
},
|
|
133
|
+
initialState: {
|
|
134
|
+
rowSelection: {}
|
|
135
|
+
},
|
|
136
|
+
onRowSelectionChange: setRowSelection,
|
|
137
|
+
// RowSelection
|
|
138
|
+
|
|
139
|
+
// ColumnSizing
|
|
140
|
+
enableColumnResizing: allowResizing !== false,
|
|
141
|
+
columnResizeMode,
|
|
142
|
+
columnResizeDirection,
|
|
143
|
+
onColumnSizingChange: setColumnSizing,
|
|
144
|
+
onColumnSizingInfoChange: setColumnSizingInfo,
|
|
145
|
+
// ColumnSizing
|
|
146
|
+
|
|
147
|
+
// ColumnSorting
|
|
148
|
+
// getSortedRowModel: getSortedRowModel(),
|
|
149
|
+
onSortingChange: setSorting,
|
|
150
|
+
enableMultiSort: sortMultiple !== false,
|
|
151
|
+
isMultiSortEvent: () => sortMultiple === false ? false : true,
|
|
152
|
+
enableSorting: allowSortering !== false,
|
|
153
|
+
// ColumnSorting
|
|
154
|
+
|
|
155
|
+
enableFilters: allowFiltering !== false,
|
|
156
|
+
onColumnFiltersChange: setColumnFilters,
|
|
157
|
+
onColumnOperatorChange: setOperator,
|
|
158
|
+
// getFilteredRowModel: getFilteredRowModel(),
|
|
159
|
+
|
|
160
|
+
onColumnOrderChange: setColumnOrder,
|
|
161
|
+
onGroupingChange: setGrouping,
|
|
162
|
+
getGroupedRowModel: (0, _reactTable.getGroupedRowModel)(),
|
|
163
|
+
// onExpandedChange: setExpanded,
|
|
164
|
+
getExpandedRowModel: (0, _reactTable.getExpandedRowModel)(),
|
|
165
|
+
getPaginationRowModel: pagination && !infiniteScroll ? (0, _reactTable.getPaginationRowModel)() : undefined,
|
|
166
|
+
onPaginationChange: setPagination,
|
|
167
|
+
// onColumnVisibilityChange: setColumnVisibility,
|
|
168
|
+
onColumnPinningChange: setColumnPinning
|
|
169
|
+
|
|
170
|
+
// debugTable: true
|
|
171
|
+
});
|
|
172
|
+
_react.default.useEffect(() => {
|
|
173
|
+
if (columnHidden) {
|
|
174
|
+
const abb = table.getVisibleLeafColumns()?.[0];
|
|
175
|
+
if (abb && Object.keys(columnSizingInfo).length === 0) {
|
|
176
|
+
setColumnSizing({
|
|
177
|
+
[abb.id]: abb.getSize()
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}, [columnHidden, columnSizingInfo]);
|
|
182
|
+
_react.default.useEffect(() => {
|
|
183
|
+
const isEqual = (0, _utils.isObjEqual)((0, _utils.convertToObjTrue)(mergedSelectedKeys), rowSelection);
|
|
184
|
+
if (!isEqual) {
|
|
185
|
+
setRowSelection((0, _utils.convertToObjTrue)(mergedSelectedKeys));
|
|
186
|
+
}
|
|
187
|
+
}, [mergedSelectedKeys]);
|
|
188
|
+
_react.default.useEffect(() => {
|
|
189
|
+
if (isSelectionChange.isChange) {
|
|
190
|
+
const aa = table.getState().rowSelection;
|
|
191
|
+
const ids = Object.keys(aa);
|
|
192
|
+
|
|
193
|
+
// const ssss = dataTable.filter(it => ids.includes(it.id)) // lấy rowsData của trang hiện tại
|
|
194
|
+
const ssss = (0, _utils.filterByIds)(ids, isSelectionChange.rowsData ?? []); // lấy rowsData của trang hiện tại
|
|
195
|
+
|
|
196
|
+
const rs = ssss.map(it => it.original);
|
|
197
|
+
rowSelected?.({
|
|
198
|
+
type: isSelectionChange.type,
|
|
199
|
+
rowData: isSelectionChange.rowData,
|
|
200
|
+
selected: rs
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
}, [isSelectionChange, rowSelection, table.getState().rowSelection]);
|
|
204
|
+
_react.default.useEffect(() => {
|
|
205
|
+
if (sorterChange) {
|
|
206
|
+
const aa = table.getState().sorting;
|
|
207
|
+
const rs = aa.map(it => {
|
|
208
|
+
return {
|
|
209
|
+
columnKey: it.id,
|
|
210
|
+
field: it.id,
|
|
211
|
+
order: it.desc ? 'descend' : 'ascend'
|
|
212
|
+
};
|
|
213
|
+
});
|
|
214
|
+
if (onSorter) {
|
|
215
|
+
onSorter?.(rs);
|
|
216
|
+
} else {
|
|
217
|
+
triggerSorter(rs);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}, [sorterChange, sorting, table]);
|
|
221
|
+
_react.default.useEffect(() => {
|
|
222
|
+
if (filterChange) {
|
|
223
|
+
// const filterState = table.getState().columnFilters
|
|
224
|
+
const operatorState = table.getState().operator;
|
|
225
|
+
const merged = columnFilters.map(filter => {
|
|
226
|
+
const match = operatorState.find(op => op.id === filter.id);
|
|
227
|
+
const col = table.getVisibleFlatColumns().find(it => it.id === filter.id)?.columnDef.meta;
|
|
228
|
+
return {
|
|
229
|
+
field: filter.id,
|
|
230
|
+
key: filter.id,
|
|
231
|
+
column: col,
|
|
232
|
+
filteredKeys: filter.value,
|
|
233
|
+
operator: match ? match.operator : undefined
|
|
234
|
+
// ...(match && { operator: match.operator })
|
|
235
|
+
};
|
|
236
|
+
});
|
|
237
|
+
if (onFilter) {
|
|
238
|
+
onFilter?.((0, _utils.convertFilters)(merged));
|
|
239
|
+
} else {
|
|
240
|
+
triggerFilter((0, _utils.convertFilters)(merged));
|
|
241
|
+
const b = (0, _utils.filterDataByColumns)(originData, (0, _utils.convertFilters)(merged), [], []);
|
|
242
|
+
setMergedFilterKeys((0, _utils.getAllRowKey)(b));
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}, [filterChange, onFilter, originData, setMergedFilterKeys, table, triggerFilter, columnFilters]);
|
|
246
|
+
|
|
247
|
+
// reorder columns after drag & drop
|
|
248
|
+
function handleDragEnd(event) {
|
|
249
|
+
const {
|
|
250
|
+
active,
|
|
251
|
+
over
|
|
252
|
+
} = event;
|
|
253
|
+
if (active && over && active.id !== over.id) {
|
|
254
|
+
setColumnOrder(cols => {
|
|
255
|
+
const oldIndex = cols.indexOf(active.id);
|
|
256
|
+
const newIndex = cols.indexOf(over.id);
|
|
257
|
+
return (0, _sortable.arrayMove)(cols, oldIndex, newIndex); //this is just a splice util
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
const triggerGroupColumns = groupedColumns => {
|
|
262
|
+
// const abcd = updateColumnsByGroup(columns, groupedColumns)
|
|
263
|
+
|
|
264
|
+
const aaa = (0, _utils.fixColumnsLeft)(propsColumns, groupedColumns);
|
|
265
|
+
const abc = (0, _utils.sortColumnsByField)(aaa, groupedColumns);
|
|
266
|
+
|
|
267
|
+
// const bcd = convertToObj(groupedColumns)
|
|
268
|
+
|
|
269
|
+
// const bbb = updateWidthsByOther(propsColumns, abc)
|
|
270
|
+
|
|
271
|
+
setColumns((0, _utils.sortByType)(abc));
|
|
272
|
+
|
|
273
|
+
// const a = getInvisibleColumns(columns)
|
|
274
|
+
|
|
275
|
+
// const prev = groupColumns ?? []
|
|
276
|
+
|
|
277
|
+
// const bbb = prev.filter(item => !groupedColumns.includes(item))
|
|
278
|
+
|
|
279
|
+
// const ccc = removeKeys(columnVisibility, bbb)
|
|
280
|
+
|
|
281
|
+
// const rs = { ...ccc, ...bcd }
|
|
282
|
+
|
|
283
|
+
// setColumnVisibility(rs)
|
|
284
|
+
|
|
285
|
+
// table.setColumnVisibility(rs)
|
|
286
|
+
|
|
287
|
+
if (groupSetting) {
|
|
288
|
+
if (groupSetting.onGroup) {
|
|
289
|
+
groupSetting.onGroup({
|
|
290
|
+
columnGrouped: groupedColumns,
|
|
291
|
+
columns: (0, _utils2.removeColumns)(columns, groupedColumns),
|
|
292
|
+
flattenColumns: (0, _utils2.flatColumns2)((0, _utils2.removeColumns)(columns, groupedColumns))
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
if (groupSetting.client === false) {
|
|
296
|
+
|
|
297
|
+
// group server => không xử lý gì
|
|
298
|
+
} else {
|
|
299
|
+
// group client
|
|
300
|
+
|
|
301
|
+
table.resetRowSelection();
|
|
302
|
+
table.resetExpanded();
|
|
303
|
+
setRowSelection({});
|
|
304
|
+
setExpanded({});
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
const sensors = (0, _core.useSensors)((0, _core.useSensor)(_core.MouseSensor, {}), (0, _core.useSensor)(_core.TouchSensor, {}), (0, _core.useSensor)(_core.KeyboardSensor, {}));
|
|
309
|
+
const ContainerComponent = editAble ? _TableContainerEdit.default : _TableContainer.default;
|
|
310
|
+
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_style.GridStyle, {
|
|
311
|
+
$prefix: prefix,
|
|
312
|
+
$theme: {
|
|
313
|
+
theme: theme?.theme,
|
|
314
|
+
...theme
|
|
315
|
+
},
|
|
316
|
+
className: (0, _classnames.default)(`${prefix}-grid ${tableClassNames}`, {
|
|
317
|
+
[`${prefix}-grid-light`]: !theme || theme.theme === 'light',
|
|
318
|
+
[`${prefix}-grid-dark`]: theme?.theme === 'dark',
|
|
319
|
+
[`${prefix}-grid-editable`]: editAble
|
|
320
|
+
}),
|
|
321
|
+
style: {
|
|
322
|
+
minHeight: minHeight ?? undefined,
|
|
323
|
+
maxHeight: height ?? undefined,
|
|
324
|
+
backgroundColor: theme?.backgroundColor ?? undefined
|
|
325
|
+
}
|
|
326
|
+
}, /*#__PURE__*/_react.default.createElement(_core.DndContext, {
|
|
327
|
+
collisionDetection: _core.closestCenter,
|
|
328
|
+
modifiers: [_modifiers.restrictToHorizontalAxis],
|
|
329
|
+
onDragEnd: handleDragEnd,
|
|
330
|
+
sensors: sensors
|
|
331
|
+
}, /*#__PURE__*/_react.default.createElement(ContainerComponent, (0, _extends2.default)({}, rest, {
|
|
332
|
+
id: id,
|
|
333
|
+
t: t,
|
|
334
|
+
windowSize: windowSize,
|
|
335
|
+
table: table,
|
|
336
|
+
editAble: editAble,
|
|
337
|
+
dataSource: dataSource,
|
|
338
|
+
originData: originData,
|
|
339
|
+
prefix: prefix,
|
|
340
|
+
selectionSettings: selectionSettings,
|
|
341
|
+
isSelectionChange: isSelectionChange,
|
|
342
|
+
setIsSelectionChange: setIsSelectionChange,
|
|
343
|
+
setSorterChange: setSorterChange,
|
|
344
|
+
setFilterChange: setFilterChange,
|
|
345
|
+
height: height ?? minHeight ?? 700,
|
|
346
|
+
minHeight: minHeight,
|
|
347
|
+
pagination: pagination,
|
|
348
|
+
columns: columns,
|
|
349
|
+
groupColumns: groupColumns,
|
|
350
|
+
propsColumns: propsColumns,
|
|
351
|
+
triggerChangeColumns: triggerChangeColumns,
|
|
352
|
+
columnHidden: columnHidden,
|
|
353
|
+
setExpanded: setExpanded,
|
|
354
|
+
expanded: expanded,
|
|
355
|
+
infiniteScroll: infiniteScroll,
|
|
356
|
+
setMergedFilterKeys: setMergedFilterKeys,
|
|
357
|
+
triggerGroupColumns: triggerGroupColumns,
|
|
358
|
+
setColumnSizing: setColumnSizing,
|
|
359
|
+
setColumns: setColumns,
|
|
360
|
+
columnSizing: columnSizing,
|
|
361
|
+
columnSizingInfo: columnSizingInfo,
|
|
362
|
+
isFullScreen: isFullScreen,
|
|
363
|
+
setIsFullScreen: setIsFullScreen
|
|
364
|
+
})))), /*#__PURE__*/_react.default.createElement(_antd.Modal, {
|
|
365
|
+
open: isFullScreen,
|
|
366
|
+
footer: null,
|
|
367
|
+
centered: true,
|
|
368
|
+
closable: true,
|
|
369
|
+
width: '100%',
|
|
370
|
+
style: {
|
|
371
|
+
maxWidth: '100%',
|
|
372
|
+
height: '100%'
|
|
373
|
+
},
|
|
374
|
+
onCancel: () => setIsFullScreen(false)
|
|
375
|
+
|
|
376
|
+
// destroyOnClose
|
|
377
|
+
,
|
|
378
|
+
styles: {
|
|
379
|
+
content: {
|
|
380
|
+
height: '100vh',
|
|
381
|
+
borderRadius: 0,
|
|
382
|
+
padding: '15px 10px'
|
|
383
|
+
},
|
|
384
|
+
wrapper: {
|
|
385
|
+
zIndex: 1050
|
|
386
|
+
}
|
|
387
|
+
},
|
|
388
|
+
title: /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, " ", typeof fullScreenTitle === 'function' ? fullScreenTitle?.() : fullScreenTitle, " "),
|
|
389
|
+
destroyOnClose: true
|
|
390
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
391
|
+
style: {}
|
|
392
|
+
}, /*#__PURE__*/_react.default.createElement(_style.GridStyle, {
|
|
393
|
+
$prefix: prefix,
|
|
394
|
+
$theme: {
|
|
395
|
+
theme: theme?.theme,
|
|
396
|
+
...theme
|
|
397
|
+
},
|
|
398
|
+
className: (0, _classnames.default)(`${prefix}-grid ${tableClassNames}`, {
|
|
399
|
+
[`${prefix}-grid-light`]: !theme || theme.theme === 'light',
|
|
400
|
+
[`${prefix}-grid-dark`]: theme?.theme === 'dark'
|
|
401
|
+
}),
|
|
402
|
+
style: {
|
|
403
|
+
// minHeight: minHeight ?? undefined,
|
|
404
|
+
maxHeight: windowSize.innerHeight - 70
|
|
405
|
+
}
|
|
406
|
+
}, /*#__PURE__*/_react.default.createElement(_core.DndContext, {
|
|
407
|
+
collisionDetection: _core.closestCenter,
|
|
408
|
+
modifiers: [_modifiers.restrictToHorizontalAxis],
|
|
409
|
+
onDragEnd: handleDragEnd,
|
|
410
|
+
sensors: sensors
|
|
411
|
+
}, /*#__PURE__*/_react.default.createElement(ContainerComponent, (0, _extends2.default)({}, rest, {
|
|
412
|
+
id: _faker.faker.string.alpha(20),
|
|
413
|
+
t: t,
|
|
414
|
+
table: table,
|
|
415
|
+
editAble: editAble,
|
|
416
|
+
dataSource: dataSource,
|
|
417
|
+
originData: originData,
|
|
418
|
+
prefix: prefix,
|
|
419
|
+
selectionSettings: selectionSettings,
|
|
420
|
+
isSelectionChange: isSelectionChange,
|
|
421
|
+
setIsSelectionChange: setIsSelectionChange,
|
|
422
|
+
setSorterChange: setSorterChange,
|
|
423
|
+
setFilterChange: setFilterChange,
|
|
424
|
+
height: windowSize.innerHeight - 70,
|
|
425
|
+
minHeight: minHeight,
|
|
426
|
+
pagination: pagination,
|
|
427
|
+
columns: columns,
|
|
428
|
+
windowSize: windowSize,
|
|
429
|
+
propsColumns: propsColumns,
|
|
430
|
+
triggerChangeColumns: triggerChangeColumns,
|
|
431
|
+
columnHidden: columnHidden,
|
|
432
|
+
setExpanded: setExpanded,
|
|
433
|
+
expanded: expanded,
|
|
434
|
+
infiniteScroll: infiniteScroll,
|
|
435
|
+
setMergedFilterKeys: setMergedFilterKeys,
|
|
436
|
+
setColumnSizing: setColumnSizing,
|
|
437
|
+
setColumns: setColumns,
|
|
438
|
+
columnSizing: columnSizing,
|
|
439
|
+
columnSizingInfo: columnSizingInfo,
|
|
440
|
+
isFullScreen: isFullScreen,
|
|
441
|
+
setIsFullScreen: setIsFullScreen
|
|
442
|
+
})))))));
|
|
443
|
+
};
|
|
444
|
+
var _default = exports.default = Grid;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type Table } from "@tanstack/react-table";
|
|
2
|
+
import type { CommandClick, ContextInfo, ContextMenuItem, PaginationConfig } from "../../grid-component/type";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import type { Virtualizer } from "@tanstack/react-virtual";
|
|
5
|
+
import type { Column } from "@tanstack/react-table";
|
|
6
|
+
type Props<T> = {
|
|
7
|
+
prefix: string;
|
|
8
|
+
id: string;
|
|
9
|
+
tableContainerRef: React.RefObject<HTMLDivElement>;
|
|
10
|
+
height: number;
|
|
11
|
+
minHeight?: number;
|
|
12
|
+
table: Table<T>;
|
|
13
|
+
summary?: boolean;
|
|
14
|
+
loading?: boolean;
|
|
15
|
+
commandClick?: (args: Omit<CommandClick<T>, 'rows'>) => void;
|
|
16
|
+
editAble?: boolean;
|
|
17
|
+
contextMenuItems?: ContextMenuItem[];
|
|
18
|
+
showEmptyText?: boolean;
|
|
19
|
+
contextMenuClick?: any;
|
|
20
|
+
contextMenuOpen?: (args: Omit<ContextInfo<T>, 'item'>) => void;
|
|
21
|
+
contextMenuHidden?: string[] | ((args?: Omit<ContextInfo<T>, 'item' | 'event'>) => string[]);
|
|
22
|
+
next?: () => void;
|
|
23
|
+
dataSource: T[];
|
|
24
|
+
pagination?: false | PaginationConfig;
|
|
25
|
+
infiniteScroll?: boolean;
|
|
26
|
+
columnVirtualizer: Virtualizer<HTMLDivElement, HTMLTableCellElement>;
|
|
27
|
+
virtualPaddingLeft: number | undefined;
|
|
28
|
+
virtualPaddingRight: number | undefined;
|
|
29
|
+
fixedLeftColumns: Column<T, unknown>[];
|
|
30
|
+
fixedRightColumns: Column<T, unknown>[];
|
|
31
|
+
};
|
|
32
|
+
declare const TableWrapper: <RecordType extends object>(props: Props<RecordType>) => React.JSX.Element;
|
|
33
|
+
export default TableWrapper;
|