es-grid-template 1.8.64 → 1.8.66
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.d.ts +2 -2
- package/es/grid-component/TempTable.js +5 -5
- package/es/grid-component/hooks/index.js +0 -1
- package/es/grid-component/hooks/useLazyKVMap.d.ts +1 -1
- package/es/grid-component/hooks/useLazyKVMap.js +0 -4
- package/es/grid-component/hooks/utils.d.ts +1 -8
- package/es/grid-component/hooks/utils.js +176 -144
- package/es/grid-component/index.d.ts +1 -1
- package/es/grid-component/index.js +0 -4
- package/es/grid-component/styles.scss +1394 -1394
- package/es/grid-component/type.d.ts +0 -407
- package/es/grid-component/type.js +490 -1
- package/es/table-component/type.d.ts +10 -0
- package/es/{grid-component → table-virtuoso}/ColumnsGroup/ColumnsGroup.js +4 -3
- package/es/{grid-component → table-virtuoso}/InternalTable.d.ts +2 -3
- package/es/table-virtuoso/InternalTable.js +391 -0
- package/es/table-virtuoso/body/TableBodyCell.d.ts +14 -0
- package/es/table-virtuoso/body/TableBodyCell.js +457 -0
- package/es/table-virtuoso/body/TableBodyRow.d.ts +13 -0
- package/es/table-virtuoso/body/TableBodyRow.js +112 -0
- package/es/table-virtuoso/footer/TableFooterCell.d.ts +7 -0
- package/es/table-virtuoso/footer/TableFooterCell.js +54 -0
- package/es/table-virtuoso/header/TableHeadCell.d.ts +14 -0
- package/es/table-virtuoso/header/TableHeadCell.js +265 -0
- package/es/table-virtuoso/header/renderFilter.d.ts +20 -0
- package/es/table-virtuoso/header/renderFilter.js +289 -0
- package/es/table-virtuoso/hook/constant.d.ts +73 -0
- package/es/table-virtuoso/hook/constant.js +240 -0
- package/es/table-virtuoso/hook/convert.d.ts +1 -0
- package/es/table-virtuoso/hook/convert.js +28 -0
- package/es/table-virtuoso/hook/useColumns.d.ts +28 -0
- package/es/table-virtuoso/hook/useColumns.js +302 -0
- package/es/table-virtuoso/hook/useFilterOperator.d.ts +7 -0
- package/es/table-virtuoso/hook/useFilterOperator.js +33 -0
- package/es/table-virtuoso/hook/utils.d.ts +159 -0
- package/es/table-virtuoso/hook/utils.js +2263 -0
- package/es/table-virtuoso/index.d.ts +2 -0
- package/es/table-virtuoso/index.js +2 -0
- package/es/table-virtuoso/style.d.ts +22 -0
- package/es/table-virtuoso/style.js +12 -0
- package/es/table-virtuoso/style.scss +1441 -0
- package/es/table-virtuoso/table/Grid.d.ts +37 -0
- package/es/table-virtuoso/table/Grid.js +298 -0
- package/es/table-virtuoso/table/TableContainer.d.ts +49 -0
- package/es/table-virtuoso/table/TableContainer.js +292 -0
- package/es/table-virtuoso/table/TableWrapper.d.ts +22 -0
- package/es/table-virtuoso/table/TableWrapper.js +161 -0
- package/es/table-virtuoso/type.d.ts +0 -0
- package/es/table-virtuoso/type.js +785 -0
- package/es/table-virtuoso/useContext.d.ts +97 -0
- package/es/table-virtuoso/useContext.js +21 -0
- package/lib/grid-component/TempTable.d.ts +2 -2
- package/lib/grid-component/TempTable.js +5 -7
- package/lib/grid-component/hooks/useLazyKVMap.d.ts +1 -1
- package/lib/grid-component/hooks/useLazyKVMap.js +0 -3
- package/lib/grid-component/hooks/utils.d.ts +1 -8
- package/lib/grid-component/hooks/utils.js +179 -152
- package/lib/grid-component/index.d.ts +1 -1
- package/lib/grid-component/index.js +0 -3
- package/lib/grid-component/styles.scss +1394 -1394
- package/lib/grid-component/type.d.ts +0 -407
- package/lib/grid-component/type.js +490 -4
- package/lib/table-component/type.d.ts +10 -0
- package/lib/{grid-component → table-virtuoso}/ColumnsGroup/ColumnsGroup.js +4 -3
- package/lib/{grid-component → table-virtuoso}/InternalTable.d.ts +2 -3
- package/lib/table-virtuoso/InternalTable.js +400 -0
- package/lib/table-virtuoso/body/TableBodyCell.d.ts +14 -0
- package/lib/table-virtuoso/body/TableBodyCell.js +464 -0
- package/lib/table-virtuoso/body/TableBodyRow.d.ts +13 -0
- package/lib/table-virtuoso/body/TableBodyRow.js +119 -0
- package/lib/table-virtuoso/footer/TableFooterCell.d.ts +7 -0
- package/lib/table-virtuoso/footer/TableFooterCell.js +63 -0
- package/lib/table-virtuoso/header/TableHeadCell.d.ts +14 -0
- package/lib/table-virtuoso/header/TableHeadCell.js +274 -0
- package/lib/table-virtuoso/header/renderFilter.d.ts +20 -0
- package/lib/table-virtuoso/header/renderFilter.js +299 -0
- package/lib/table-virtuoso/hook/constant.d.ts +73 -0
- package/lib/table-virtuoso/hook/constant.js +247 -0
- package/lib/table-virtuoso/hook/convert.d.ts +1 -0
- package/lib/table-virtuoso/hook/convert.js +34 -0
- package/lib/table-virtuoso/hook/useColumns.d.ts +28 -0
- package/lib/table-virtuoso/hook/useColumns.js +315 -0
- package/lib/table-virtuoso/hook/useFilterOperator.d.ts +7 -0
- package/lib/table-virtuoso/hook/useFilterOperator.js +40 -0
- package/lib/table-virtuoso/hook/utils.d.ts +159 -0
- package/lib/table-virtuoso/hook/utils.js +2389 -0
- package/lib/table-virtuoso/index.d.ts +2 -0
- package/lib/table-virtuoso/index.js +9 -0
- package/lib/table-virtuoso/style.d.ts +22 -0
- package/lib/table-virtuoso/style.js +19 -0
- package/lib/table-virtuoso/style.scss +1441 -0
- package/lib/table-virtuoso/table/Grid.d.ts +37 -0
- package/lib/table-virtuoso/table/Grid.js +307 -0
- package/lib/table-virtuoso/table/TableContainer.d.ts +49 -0
- package/lib/table-virtuoso/table/TableContainer.js +300 -0
- package/lib/table-virtuoso/table/TableWrapper.d.ts +22 -0
- package/lib/table-virtuoso/table/TableWrapper.js +166 -0
- package/lib/table-virtuoso/type.d.ts +0 -0
- package/lib/table-virtuoso/type.js +786 -0
- package/lib/table-virtuoso/useContext.d.ts +97 -0
- package/lib/table-virtuoso/useContext.js +27 -0
- package/package.json +2 -1
- package/es/grid-component/AdvanceFilter.d.ts +0 -14
- package/es/grid-component/AdvanceFilter.js +0 -454
- package/es/grid-component/CheckboxFilter.d.ts +0 -20
- package/es/grid-component/CheckboxFilter.js +0 -244
- package/es/grid-component/CheckboxFilter2.d.ts +0 -20
- package/es/grid-component/CheckboxFilter2.js +0 -244
- package/es/grid-component/ColumnsChoose.d.ts +0 -10
- package/es/grid-component/ColumnsChoose.js +0 -230
- package/es/grid-component/Command.d.ts +0 -8
- package/es/grid-component/Command.js +0 -80
- package/es/grid-component/ContextMenu.d.ts +0 -20
- package/es/grid-component/ContextMenu.js +0 -130
- package/es/grid-component/ConvertColumnTable.d.ts +0 -7
- package/es/grid-component/ConvertColumnTable.js +0 -144
- package/es/grid-component/EditForm/EditForm.d.ts +0 -27
- package/es/grid-component/EditForm/EditForm.js +0 -394
- package/es/grid-component/EditForm/index.d.ts +0 -1
- package/es/grid-component/EditForm/index.js +0 -1
- package/es/grid-component/EditableCell.d.ts +0 -20
- package/es/grid-component/EditableCell.js +0 -1030
- package/es/grid-component/FilterSearch.d.ts +0 -12
- package/es/grid-component/FilterSearch.js +0 -33
- package/es/grid-component/GridStyle.d.ts +0 -8
- package/es/grid-component/GridStyle.js +0 -5
- package/es/grid-component/InternalTable.js +0 -1170
- package/es/grid-component/TableGrid.d.ts +0 -21
- package/es/grid-component/TableGrid.js +0 -493
- package/es/grid-component/async-select/index.d.ts +0 -11
- package/es/grid-component/async-select/index.js +0 -38
- package/es/grid-component/async-table-select/index.d.ts +0 -11
- package/es/grid-component/async-table-select/index.js +0 -40
- package/es/grid-component/checkbox-control/index.d.ts +0 -13
- package/es/grid-component/checkbox-control/index.js +0 -40
- package/es/grid-component/hooks/columns/index.d.ts +0 -10
- package/es/grid-component/hooks/columns/index.js +0 -503
- package/es/grid-component/hooks/content/ControlCheckbox.d.ts +0 -13
- package/es/grid-component/hooks/content/ControlCheckbox.js +0 -87
- package/es/grid-component/hooks/content/HeaderContent.d.ts +0 -14
- package/es/grid-component/hooks/content/HeaderContent.js +0 -44
- package/es/grid-component/hooks/content/TooltipContent.d.ts +0 -13
- package/es/grid-component/hooks/content/TooltipContent.js +0 -74
- package/es/grid-component/hooks/useColumns.d.ts +0 -19
- package/es/grid-component/hooks/useColumns.js +0 -317
- package/es/grid-component/number/index.d.ts +0 -10
- package/es/grid-component/number/index.js +0 -39
- package/es/grid-component/number-range/index.d.ts +0 -11
- package/es/grid-component/number-range/index.js +0 -63
- package/es/grid-component/table/Grid.d.ts +0 -23
- package/es/grid-component/table/Grid.js +0 -49
- package/es/grid-component/table/GridEdit.d.ts +0 -23
- package/es/grid-component/table/GridEdit.js +0 -2726
- package/es/grid-component/table/Group.d.ts +0 -21
- package/es/grid-component/table/Group.js +0 -195
- package/es/grid-component/table/InfiniteTable.d.ts +0 -23
- package/es/grid-component/table/InfiniteTable.js +0 -101
- package/es/grid-component/useContext.d.ts +0 -34
- package/es/grid-component/useContext.js +0 -8
- package/lib/grid-component/AdvanceFilter.d.ts +0 -14
- package/lib/grid-component/AdvanceFilter.js +0 -463
- package/lib/grid-component/CheckboxFilter.d.ts +0 -20
- package/lib/grid-component/CheckboxFilter.js +0 -253
- package/lib/grid-component/CheckboxFilter2.d.ts +0 -20
- package/lib/grid-component/CheckboxFilter2.js +0 -253
- package/lib/grid-component/ColumnsChoose.d.ts +0 -10
- package/lib/grid-component/ColumnsChoose.js +0 -240
- package/lib/grid-component/Command.d.ts +0 -8
- package/lib/grid-component/Command.js +0 -88
- package/lib/grid-component/ContextMenu.d.ts +0 -20
- package/lib/grid-component/ContextMenu.js +0 -140
- package/lib/grid-component/ConvertColumnTable.d.ts +0 -7
- package/lib/grid-component/ConvertColumnTable.js +0 -153
- package/lib/grid-component/EditForm/EditForm.d.ts +0 -27
- package/lib/grid-component/EditForm/EditForm.js +0 -404
- package/lib/grid-component/EditForm/index.d.ts +0 -1
- package/lib/grid-component/EditForm/index.js +0 -16
- package/lib/grid-component/EditableCell.d.ts +0 -20
- package/lib/grid-component/EditableCell.js +0 -1032
- package/lib/grid-component/FilterSearch.d.ts +0 -12
- package/lib/grid-component/FilterSearch.js +0 -42
- package/lib/grid-component/GridStyle.d.ts +0 -8
- package/lib/grid-component/GridStyle.js +0 -12
- package/lib/grid-component/InternalTable.js +0 -1178
- package/lib/grid-component/TableGrid.d.ts +0 -21
- package/lib/grid-component/TableGrid.js +0 -493
- package/lib/grid-component/async-select/index.d.ts +0 -11
- package/lib/grid-component/async-select/index.js +0 -47
- package/lib/grid-component/async-table-select/index.d.ts +0 -11
- package/lib/grid-component/async-table-select/index.js +0 -49
- package/lib/grid-component/checkbox-control/index.d.ts +0 -13
- package/lib/grid-component/checkbox-control/index.js +0 -48
- package/lib/grid-component/hooks/columns/index.d.ts +0 -10
- package/lib/grid-component/hooks/columns/index.js +0 -518
- package/lib/grid-component/hooks/content/ControlCheckbox.d.ts +0 -13
- package/lib/grid-component/hooks/content/ControlCheckbox.js +0 -95
- package/lib/grid-component/hooks/content/HeaderContent.d.ts +0 -14
- package/lib/grid-component/hooks/content/HeaderContent.js +0 -53
- package/lib/grid-component/hooks/content/TooltipContent.d.ts +0 -13
- package/lib/grid-component/hooks/content/TooltipContent.js +0 -81
- package/lib/grid-component/hooks/useColumns.d.ts +0 -19
- package/lib/grid-component/hooks/useColumns.js +0 -328
- package/lib/grid-component/number/index.d.ts +0 -10
- package/lib/grid-component/number/index.js +0 -47
- package/lib/grid-component/number-range/index.d.ts +0 -11
- package/lib/grid-component/number-range/index.js +0 -71
- package/lib/grid-component/table/Grid.d.ts +0 -23
- package/lib/grid-component/table/Grid.js +0 -58
- package/lib/grid-component/table/GridEdit.d.ts +0 -23
- package/lib/grid-component/table/GridEdit.js +0 -2723
- package/lib/grid-component/table/Group.d.ts +0 -21
- package/lib/grid-component/table/Group.js +0 -204
- package/lib/grid-component/table/InfiniteTable.d.ts +0 -23
- package/lib/grid-component/table/InfiniteTable.js +0 -109
- package/lib/grid-component/useContext.d.ts +0 -34
- package/lib/grid-component/useContext.js +0 -13
- /package/es/{grid-component → table-virtuoso}/ColumnsGroup/ColumnsGroup.d.ts +0 -0
- /package/es/{grid-component → table-virtuoso}/ColumnsGroup/index.d.ts +0 -0
- /package/es/{grid-component → table-virtuoso}/ColumnsGroup/index.js +0 -0
- /package/lib/{grid-component → table-virtuoso}/ColumnsGroup/ColumnsGroup.d.ts +0 -0
- /package/lib/{grid-component → table-virtuoso}/ColumnsGroup/index.d.ts +0 -0
- /package/lib/{grid-component → table-virtuoso}/ColumnsGroup/index.js +0 -0
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import 'dayjs/locale/es';
|
|
3
|
-
import 'dayjs/locale/vi';
|
|
4
|
-
import type { ColumnsTable, GetRowKey, GridTableProps } from "./type";
|
|
5
|
-
type GridProps<T> = GridTableProps<T> & {
|
|
6
|
-
triggerChangeColumns?: (columns: ColumnsTable<T>, type: string) => void;
|
|
7
|
-
triggerChangeData?: (newData: T[], type: string) => void;
|
|
8
|
-
triggerFilter?: (queries: any) => void;
|
|
9
|
-
triggerGroupColumns?: (groupedColumns: string[]) => void;
|
|
10
|
-
tableRef: any;
|
|
11
|
-
bottomToolbar?: () => React.ReactElement;
|
|
12
|
-
getRowKey: GetRowKey<T>;
|
|
13
|
-
rowSelection?: any;
|
|
14
|
-
groupToolbar?: () => React.ReactNode;
|
|
15
|
-
isFilter?: boolean;
|
|
16
|
-
setIsFilter?: React.Dispatch<React.SetStateAction<boolean>>;
|
|
17
|
-
handleFullScreen?: any;
|
|
18
|
-
isFullScreen?: boolean;
|
|
19
|
-
};
|
|
20
|
-
declare const TableGrid: <RecordType extends object>(props: GridProps<RecordType>) => React.JSX.Element;
|
|
21
|
-
export default TableGrid;
|
|
@@ -1,493 +0,0 @@
|
|
|
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 _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
var _antdStyle = require("antd-style");
|
|
11
|
-
var _reactNumericComponent = require("react-numeric-component");
|
|
12
|
-
var _rcMasterUi = require("rc-master-ui");
|
|
13
|
-
require("dayjs/locale/es");
|
|
14
|
-
require("dayjs/locale/vi");
|
|
15
|
-
var _ContextMenu = _interopRequireDefault(require("./ContextMenu"));
|
|
16
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
17
|
-
var _hooks = require("./hooks");
|
|
18
|
-
var _columns = require("./hooks/columns");
|
|
19
|
-
var _pagination = _interopRequireDefault(require("rc-master-ui/es/pagination"));
|
|
20
|
-
var _LoadingSpinner = _interopRequireDefault(require("./LoadingSpinner"));
|
|
21
|
-
var _ColumnsChoose = require("./ColumnsChoose");
|
|
22
|
-
var _useMergedState = _interopRequireDefault(require("rc-util/lib/hooks/useMergedState"));
|
|
23
|
-
var _AdvanceFilter = _interopRequireDefault(require("./AdvanceFilter"));
|
|
24
|
-
var _reactTooltip = require("react-tooltip");
|
|
25
|
-
var _becoxyIcons = require("becoxy-icons");
|
|
26
|
-
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); }
|
|
27
|
-
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; }
|
|
28
|
-
// import Table from "../../core/table"
|
|
29
|
-
|
|
30
|
-
// import {ConfigProvider} from "antd";
|
|
31
|
-
|
|
32
|
-
const useStyle = (0, _antdStyle.createStyles)(({
|
|
33
|
-
css
|
|
34
|
-
}) => {
|
|
35
|
-
const antCls = 'ui-rc';
|
|
36
|
-
return {
|
|
37
|
-
customTable: css`
|
|
38
|
-
${antCls}-table {
|
|
39
|
-
${antCls}-table-container {
|
|
40
|
-
${antCls}-table-body,
|
|
41
|
-
${antCls}-table-content {
|
|
42
|
-
scrollbar-width: thin;
|
|
43
|
-
scrollbar-color: #eaeaea transparent;
|
|
44
|
-
scrollbar-gutter: stable;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
`
|
|
49
|
-
};
|
|
50
|
-
});
|
|
51
|
-
// type OnChange = NonNullable<TableProps<any>['onChange']>;
|
|
52
|
-
|
|
53
|
-
const EMPTY_LIST = [];
|
|
54
|
-
const TableGrid = props => {
|
|
55
|
-
const {
|
|
56
|
-
id,
|
|
57
|
-
columns,
|
|
58
|
-
tableRef,
|
|
59
|
-
dataSource,
|
|
60
|
-
locale,
|
|
61
|
-
expandable,
|
|
62
|
-
rowHoverable,
|
|
63
|
-
title,
|
|
64
|
-
format,
|
|
65
|
-
virtualRow = true,
|
|
66
|
-
t,
|
|
67
|
-
lang,
|
|
68
|
-
contextMenuOpen,
|
|
69
|
-
className,
|
|
70
|
-
contextMenuItems: propContextMenuItems,
|
|
71
|
-
contextMenuHidden,
|
|
72
|
-
contextMenuClick,
|
|
73
|
-
recordDoubleClick,
|
|
74
|
-
toolbarItems,
|
|
75
|
-
showColumnChoose,
|
|
76
|
-
showAdvanceFilter,
|
|
77
|
-
// onFilter,
|
|
78
|
-
triggerFilter,
|
|
79
|
-
selectionSettings,
|
|
80
|
-
rowSelection,
|
|
81
|
-
rowSelected,
|
|
82
|
-
rowKey = 'id',
|
|
83
|
-
pagination,
|
|
84
|
-
scroll,
|
|
85
|
-
onFilterClick,
|
|
86
|
-
dataSourceFilter: propDataSourceFilter,
|
|
87
|
-
loading,
|
|
88
|
-
triggerChangeColumns,
|
|
89
|
-
triggerGroupColumns,
|
|
90
|
-
summary,
|
|
91
|
-
showToolbar,
|
|
92
|
-
// onSorter,
|
|
93
|
-
bottomToolbar,
|
|
94
|
-
groupSetting,
|
|
95
|
-
groupAble,
|
|
96
|
-
getRowKey,
|
|
97
|
-
groupColumns,
|
|
98
|
-
groupToolbar,
|
|
99
|
-
showEmptyText,
|
|
100
|
-
// setIsFilter,
|
|
101
|
-
actionTemplate,
|
|
102
|
-
handleFullScreen,
|
|
103
|
-
fullScreen,
|
|
104
|
-
isFullScreen,
|
|
105
|
-
...rest
|
|
106
|
-
} = props;
|
|
107
|
-
const {
|
|
108
|
-
styles
|
|
109
|
-
} = useStyle();
|
|
110
|
-
const {
|
|
111
|
-
mode,
|
|
112
|
-
type,
|
|
113
|
-
checkboxOnly,
|
|
114
|
-
hideSelectAll,
|
|
115
|
-
columnWidth,
|
|
116
|
-
selectedRowKeys,
|
|
117
|
-
defaultSelectedRowKeys
|
|
118
|
-
} = selectionSettings || {};
|
|
119
|
-
const clickRef = _react.default.useRef(null);
|
|
120
|
-
const menuRef = _react.default.useRef(null);
|
|
121
|
-
const viewportWidth = window.innerWidth;
|
|
122
|
-
const viewportHeight = window.innerHeight;
|
|
123
|
-
const [menuVisible, setMenuVisible] = _react.default.useState(false);
|
|
124
|
-
const [selectedRowData, setSelectedRowData] = _react.default.useState(null);
|
|
125
|
-
const [position, setPosition] = _react.default.useState({
|
|
126
|
-
x: 0,
|
|
127
|
-
y: 0,
|
|
128
|
-
viewportWidth,
|
|
129
|
-
viewportHeight
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
// const [filterStates, setFilterState] = React.useState<any>(null)
|
|
133
|
-
|
|
134
|
-
// const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>(defaultSelected);
|
|
135
|
-
|
|
136
|
-
// ========================= Keys =========================
|
|
137
|
-
const [mergedSelectedKeys, setMergedSelectedKeys] = (0, _useMergedState.default)(selectedRowKeys || defaultSelectedRowKeys || EMPTY_LIST, {
|
|
138
|
-
value: selectedRowKeys
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
// Reset if rowSelection reset
|
|
142
|
-
|
|
143
|
-
_react.default.useEffect(() => {
|
|
144
|
-
if (!selectionSettings) {
|
|
145
|
-
setMergedSelectedKeys(EMPTY_LIST);
|
|
146
|
-
}
|
|
147
|
-
}, [!!selectionSettings]);
|
|
148
|
-
const contextMenuItems = _react.default.useMemo(() => {
|
|
149
|
-
if (typeof contextMenuHidden === "function" && propContextMenuItems && selectedRowData) {
|
|
150
|
-
const hiddenItems = contextMenuHidden({
|
|
151
|
-
rowInfo: {
|
|
152
|
-
rowData: selectedRowData
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
return propContextMenuItems.filter(item => !hiddenItems.includes(item?.key));
|
|
156
|
-
}
|
|
157
|
-
if (contextMenuHidden && typeof contextMenuHidden !== 'function' && propContextMenuItems) {
|
|
158
|
-
return propContextMenuItems.filter(item => !contextMenuHidden.includes(item?.key));
|
|
159
|
-
}
|
|
160
|
-
return propContextMenuItems;
|
|
161
|
-
}, [propContextMenuItems, contextMenuHidden, selectedRowData]);
|
|
162
|
-
_react.default.useLayoutEffect(() => {
|
|
163
|
-
setMenuVisible(false);
|
|
164
|
-
}, []);
|
|
165
|
-
const onContextMenu = data => event => {
|
|
166
|
-
event.preventDefault(); // Ngăn chặn menu mặc định của trình duyệt
|
|
167
|
-
|
|
168
|
-
setSelectedRowData(data);
|
|
169
|
-
contextMenuOpen?.({
|
|
170
|
-
rowInfo: {
|
|
171
|
-
rowData: data
|
|
172
|
-
},
|
|
173
|
-
event
|
|
174
|
-
});
|
|
175
|
-
setMenuVisible(true);
|
|
176
|
-
|
|
177
|
-
// Đợi DOM cập nhật và lấy kích thước menu
|
|
178
|
-
setTimeout(() => {
|
|
179
|
-
const menuElement = menuRef.current; // Lấy menu từ DOM
|
|
180
|
-
const menuWidth = menuElement?.offsetWidth || 200; // Mặc định 200px nếu chưa render
|
|
181
|
-
const menuHeight = menuElement?.offsetHeight; // Mặc định 450px nếu chưa render
|
|
182
|
-
|
|
183
|
-
// Điều chỉnh vị trí menu
|
|
184
|
-
let x = event.clientX;
|
|
185
|
-
let y = event.clientY;
|
|
186
|
-
if (x + menuWidth > viewportWidth) {
|
|
187
|
-
x = x - menuWidth - 10; // Cách cạnh phải 10px
|
|
188
|
-
}
|
|
189
|
-
if (y + menuHeight > viewportHeight) {
|
|
190
|
-
if (y < menuHeight) {
|
|
191
|
-
y = 10;
|
|
192
|
-
} else {
|
|
193
|
-
y = y - 10 - menuHeight; // Cách cạnh dưới 10px
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
setPosition(prevState => ({
|
|
197
|
-
...prevState,
|
|
198
|
-
x,
|
|
199
|
-
y
|
|
200
|
-
}));
|
|
201
|
-
}, 100);
|
|
202
|
-
if (!menuVisible) {
|
|
203
|
-
document.addEventListener(`click`, function onClickOutside(e) {
|
|
204
|
-
const element = e.target;
|
|
205
|
-
const menuContainer = document.querySelector(".popup-context-menu");
|
|
206
|
-
const isInsideContainer = element.closest(".popup-context-menu") && menuContainer;
|
|
207
|
-
if (isInsideContainer) {
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
setMenuVisible(false);
|
|
211
|
-
document.removeEventListener(`click`, onClickOutside);
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
};
|
|
215
|
-
const handleRowClick = () => () => {
|
|
216
|
-
// const key = getRowKey(record, index);
|
|
217
|
-
|
|
218
|
-
if (checkboxOnly !== true) {
|
|
219
|
-
if (type === 'single') {}
|
|
220
|
-
}
|
|
221
|
-
};
|
|
222
|
-
const handleRowDoubleClick = (record, index) => e => {
|
|
223
|
-
if (clickRef.current) {
|
|
224
|
-
clearTimeout(clickRef.current);
|
|
225
|
-
clickRef.current = null;
|
|
226
|
-
}
|
|
227
|
-
recordDoubleClick?.({
|
|
228
|
-
e,
|
|
229
|
-
rowIndex: index,
|
|
230
|
-
rowData: record
|
|
231
|
-
});
|
|
232
|
-
};
|
|
233
|
-
const onSelectChange = (keys, selectedRows, info, selectedRow) => {
|
|
234
|
-
if (info.type === 'all') {
|
|
235
|
-
setMergedSelectedKeys(keys);
|
|
236
|
-
rowSelected?.({
|
|
237
|
-
selected: selectedRows,
|
|
238
|
-
type: 'rowSelected',
|
|
239
|
-
rowData: {}
|
|
240
|
-
});
|
|
241
|
-
} else {
|
|
242
|
-
if (selectionSettings?.type === 'multiple') {
|
|
243
|
-
setMergedSelectedKeys(keys);
|
|
244
|
-
rowSelected?.({
|
|
245
|
-
selected: selectedRows,
|
|
246
|
-
type: 'rowSelected',
|
|
247
|
-
rowData: selectedRow
|
|
248
|
-
});
|
|
249
|
-
} else {
|
|
250
|
-
const keySet = new Set(keys);
|
|
251
|
-
|
|
252
|
-
// @ts-ignore
|
|
253
|
-
if (!keySet.has(selectedRow[rowKey])) {
|
|
254
|
-
setMergedSelectedKeys([]);
|
|
255
|
-
rowSelected?.({
|
|
256
|
-
selected: [],
|
|
257
|
-
type: 'rowSelected',
|
|
258
|
-
rowData: selectedRow
|
|
259
|
-
});
|
|
260
|
-
} else {
|
|
261
|
-
// @ts-ignore
|
|
262
|
-
setMergedSelectedKeys([selectedRow[rowKey]]);
|
|
263
|
-
rowSelected?.({
|
|
264
|
-
// @ts-ignore
|
|
265
|
-
selected: [selectedRow],
|
|
266
|
-
type: 'rowSelected',
|
|
267
|
-
rowData: selectedRow
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
};
|
|
273
|
-
|
|
274
|
-
// const handleChange = (sorter: any) => {
|
|
275
|
-
// onSorter?.(sorter)
|
|
276
|
-
// }
|
|
277
|
-
|
|
278
|
-
// const handleOnFilter = (queries: any) => {
|
|
279
|
-
//
|
|
280
|
-
// if (onFilter) {
|
|
281
|
-
// onFilter?.(convertFilters(queries))
|
|
282
|
-
// } else {
|
|
283
|
-
// setFilterState(convertFilters(queries))
|
|
284
|
-
// if (queries && queries.length > 0) {
|
|
285
|
-
// // setIsFilter?.(true)
|
|
286
|
-
// } else {
|
|
287
|
-
// // setIsFilter?.(false)
|
|
288
|
-
// }
|
|
289
|
-
// }
|
|
290
|
-
//
|
|
291
|
-
// }
|
|
292
|
-
|
|
293
|
-
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_ContextMenu.default, {
|
|
294
|
-
open: menuVisible,
|
|
295
|
-
pos: position,
|
|
296
|
-
setOpen: setMenuVisible,
|
|
297
|
-
menuRef: menuRef,
|
|
298
|
-
contextMenuItems: contextMenuItems,
|
|
299
|
-
contextMenuClick: contextMenuClick,
|
|
300
|
-
rowData: selectedRowData
|
|
301
|
-
}), /*#__PURE__*/_react.default.createElement(_rcMasterUi.Table, (0, _extends2.default)({
|
|
302
|
-
ref: tableRef
|
|
303
|
-
}, rest, {
|
|
304
|
-
tableLayout: 'fixed',
|
|
305
|
-
locale: {
|
|
306
|
-
...locale,
|
|
307
|
-
emptyText: showEmptyText !== false ? /*#__PURE__*/_react.default.createElement(_rcMasterUi.Empty, {
|
|
308
|
-
image: _rcMasterUi.Empty.PRESENTED_IMAGE_SIMPLE,
|
|
309
|
-
description: locale?.emptyText
|
|
310
|
-
}) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null)
|
|
311
|
-
},
|
|
312
|
-
loading: {
|
|
313
|
-
spinning: columns && columns.length === 0 || loading === true,
|
|
314
|
-
indicator: /*#__PURE__*/_react.default.createElement(_LoadingSpinner.default, null)
|
|
315
|
-
}
|
|
316
|
-
// dataSource={columns && columns.length > 0 ? filterDataByColumns3(dataSource, filterStates) : []}
|
|
317
|
-
|
|
318
|
-
// dataSource={columns && columns.length > 0 ? filterDataByColumns4(dataSource, filterStates) : []}
|
|
319
|
-
,
|
|
320
|
-
dataSource: dataSource,
|
|
321
|
-
className: (0, _classnames.default)(className, {
|
|
322
|
-
'table-none-column-select': selectionSettings?.mode === undefined && selectionSettings?.type !== 'multiple'
|
|
323
|
-
}, styles.customTable),
|
|
324
|
-
bordered: true,
|
|
325
|
-
virtual: virtualRow,
|
|
326
|
-
columns: columns,
|
|
327
|
-
rowKey: rowKey,
|
|
328
|
-
rowHoverable: rowHoverable,
|
|
329
|
-
size: "small",
|
|
330
|
-
scroll: scroll ? scroll : {
|
|
331
|
-
y: 500
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
// scroll={{ x: 'max-content', y: 700 }}
|
|
335
|
-
,
|
|
336
|
-
|
|
337
|
-
onRow: (data, index) => {
|
|
338
|
-
return {
|
|
339
|
-
onDoubleClick: handleRowDoubleClick(data, index),
|
|
340
|
-
onClick: handleRowClick(),
|
|
341
|
-
onContextMenu: onContextMenu(data)
|
|
342
|
-
};
|
|
343
|
-
},
|
|
344
|
-
rowSelection: columns && columns.length === 0 ? undefined : {
|
|
345
|
-
...selectionSettings,
|
|
346
|
-
// type: selectionSettings?.mode,
|
|
347
|
-
type: mode,
|
|
348
|
-
columnWidth: columnWidth ?? 50,
|
|
349
|
-
onChange: onSelectChange,
|
|
350
|
-
// selectedRowKeys: mode === 'checkbox' && type === 'single' ? selectedRowKeys : undefined,
|
|
351
|
-
selectedRowKeys: mergedSelectedKeys,
|
|
352
|
-
// defaultSelectedRowKeys: selectionSettings?.defaultSelectedRowKeys,
|
|
353
|
-
defaultSelectedRowKeys,
|
|
354
|
-
preserveSelectedRowKeys: true,
|
|
355
|
-
hideSelectAll: !type || type === 'single' || mode === 'radio' ? true : hideSelectAll ?? type !== 'multiple'
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
// onFilter={(val: any) => {
|
|
359
|
-
// handleOnFilter(val)
|
|
360
|
-
// // triggerFilter?.(convertFilters(val))
|
|
361
|
-
// // onFilter?.(convertFilters(val))
|
|
362
|
-
//
|
|
363
|
-
// }}
|
|
364
|
-
|
|
365
|
-
// onChange={(paging, filters, sorter) => handleChange(sorter)}
|
|
366
|
-
,
|
|
367
|
-
|
|
368
|
-
title: showToolbar !== false || fullScreen !== false ? () => {
|
|
369
|
-
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("div", null, title?.(dataSource)), /*#__PURE__*/_react.default.createElement("div", {
|
|
370
|
-
style: {
|
|
371
|
-
display: 'flex',
|
|
372
|
-
justifyContent: 'space-between',
|
|
373
|
-
alignItems: 'center',
|
|
374
|
-
gap: '.75rem'
|
|
375
|
-
}
|
|
376
|
-
}, groupAble && groupToolbar?.(), toolbarItems && toolbarItems?.length > 0 && /*#__PURE__*/_react.default.createElement("div", {
|
|
377
|
-
style: {
|
|
378
|
-
flex: 1,
|
|
379
|
-
overflow: 'hidden'
|
|
380
|
-
}
|
|
381
|
-
}, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Toolbar
|
|
382
|
-
// @ts-ignore
|
|
383
|
-
// style={{width: pagination && pagination.onChange && pagination?.position && pagination?.position[0] === 'topRight' ? `calc(100% - 650px - ${groupAble ? 50 : 0}px` : `calc(100% - 25px - ${groupAble ? 50 : 0}px`}}
|
|
384
|
-
, {
|
|
385
|
-
items: (toolbarItems ?? []).filter(it => it.position !== 'Bottom'),
|
|
386
|
-
mode: 'scroll'
|
|
387
|
-
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
388
|
-
style: {
|
|
389
|
-
display: 'flex',
|
|
390
|
-
justifyContent: 'space-between',
|
|
391
|
-
alignItems: 'center',
|
|
392
|
-
gap: '.75rem'
|
|
393
|
-
}
|
|
394
|
-
}, pagination && pagination.onChange && pagination?.position && pagination?.position[0] === 'topRight' && /*#__PURE__*/_react.default.createElement(_pagination.default, (0, _extends2.default)({
|
|
395
|
-
showSizeChanger: true,
|
|
396
|
-
responsive: true,
|
|
397
|
-
size: 'small',
|
|
398
|
-
rootClassName: 'top-pagination'
|
|
399
|
-
// @ts-ignore
|
|
400
|
-
,
|
|
401
|
-
showTotal: (total, range) => `${range[0]}-${range[1]} / ${total} ${t ? t(pagination?.locale?.items ?? 'items') : 'items'}`
|
|
402
|
-
}, pagination)), typeof actionTemplate === 'function' ? actionTemplate() : actionTemplate, fullScreen !== false && (isFullScreen ? /*#__PURE__*/_react.default.createElement(_becoxyIcons.Minimize, {
|
|
403
|
-
fontSize: 16,
|
|
404
|
-
onClick: () => handleFullScreen?.(),
|
|
405
|
-
"data-tooltip-id": "tooltip-icon",
|
|
406
|
-
"data-tooltip-content": t ? t('Minimized') : 'Minimized'
|
|
407
|
-
}) : /*#__PURE__*/_react.default.createElement(_becoxyIcons.Maximize, {
|
|
408
|
-
fontSize: 16,
|
|
409
|
-
onClick: () => handleFullScreen?.(),
|
|
410
|
-
"data-tooltip-id": "tooltip-icon",
|
|
411
|
-
"data-tooltip-content": t ? t('Full screen') : 'Full screen'
|
|
412
|
-
})), showColumnChoose && /*#__PURE__*/_react.default.createElement(_ColumnsChoose.ColumnsChoose, {
|
|
413
|
-
columns: columns,
|
|
414
|
-
t: t,
|
|
415
|
-
columnsGroup: groupColumns,
|
|
416
|
-
triggerChangeColumns: triggerChangeColumns
|
|
417
|
-
}), showAdvanceFilter && /*#__PURE__*/_react.default.createElement(_AdvanceFilter.default, {
|
|
418
|
-
columns: columns,
|
|
419
|
-
t: t
|
|
420
|
-
// columnsGroup={groupColumns}
|
|
421
|
-
// triggerChangeColumns={triggerChangeColumns}
|
|
422
|
-
}))));
|
|
423
|
-
} : undefined,
|
|
424
|
-
expandable: {
|
|
425
|
-
...expandable
|
|
426
|
-
},
|
|
427
|
-
summary: () => {
|
|
428
|
-
if (typeof summary === 'function') {
|
|
429
|
-
return summary(dataSource);
|
|
430
|
-
}
|
|
431
|
-
if (!summary) {
|
|
432
|
-
return undefined;
|
|
433
|
-
}
|
|
434
|
-
return /*#__PURE__*/_react.default.createElement(_rcMasterUi.Table.Summary, {
|
|
435
|
-
fixed: true
|
|
436
|
-
}, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Table.Summary.Row, null, (0, _columns.flatColumns)(!!mode ? [_rcMasterUi.Table.SELECTION_COLUMN, ...columns] : [...columns]).filter(col => col.hidden !== true).map((col, index) => {
|
|
437
|
-
// const cellFormat: IFormat | undefined = col.format ? typeof col.format === 'function' ? col.format({}) : col.format : format
|
|
438
|
-
|
|
439
|
-
const colFormat = typeof col.format === 'function' ? col.format({}) : col.format;
|
|
440
|
-
const cellFormat = (0, _hooks.getFormat)(colFormat, format);
|
|
441
|
-
const thousandSeparator = cellFormat?.thousandSeparator;
|
|
442
|
-
const decimalSeparator = cellFormat?.decimalSeparator;
|
|
443
|
-
|
|
444
|
-
// const dec = (col.format?.decimalScale || col.format?.decimalScale === 0) ? col.format?.decimalScale : format?.decimalScale
|
|
445
|
-
const dec = cellFormat?.decimalScale;
|
|
446
|
-
|
|
447
|
-
// const sumValue = col.type === 'number' ? sumDataByField(filterDataByColumns4(dataSource, filterStates) as any[], col?.key as string) : 0
|
|
448
|
-
const sumValue = col.type === 'number' ? (0, _hooks.sumByField)((0, _hooks.filterDataByColumns4)(dataSource, [], []), col?.field) : 0;
|
|
449
|
-
const value = !(0, _hooks.isEmpty)(sumValue) ? dec || dec === 0 ? parseFloat(Number(sumValue).toFixed(dec)).toString() : sumValue.toString() : '0';
|
|
450
|
-
const cellValue = col.type === 'number' && col.isSummary !== false ? value : '';
|
|
451
|
-
const numberValue = Number(value);
|
|
452
|
-
const numericFormatProps = {
|
|
453
|
-
thousandSeparator: (0, _hooks.checkThousandSeparator)(thousandSeparator, decimalSeparator),
|
|
454
|
-
decimalSeparator: (0, _hooks.checkDecimalSeparator)(thousandSeparator, decimalSeparator),
|
|
455
|
-
allowNegative: cellFormat?.allowNegative ?? false,
|
|
456
|
-
prefix: cellFormat?.prefix,
|
|
457
|
-
suffix: cellFormat?.suffix,
|
|
458
|
-
decimalScale: dec,
|
|
459
|
-
fixedDecimalScale: cellFormat?.fixedDecimalScale ?? false
|
|
460
|
-
};
|
|
461
|
-
return /*#__PURE__*/_react.default.createElement(_rcMasterUi.Table.Summary.Cell, {
|
|
462
|
-
key: col.key,
|
|
463
|
-
index: index,
|
|
464
|
-
align: col.align ?? 'right',
|
|
465
|
-
className: 'ui-rc-table-cell-ellipsis'
|
|
466
|
-
}, col.summaryTemplate ? col.summaryTemplate(numberValue, col.key) : (0, _reactNumericComponent.numericFormatter)(cellValue, numericFormatProps));
|
|
467
|
-
})));
|
|
468
|
-
},
|
|
469
|
-
pagination: !pagination || pagination && pagination?.onChange ? false : {
|
|
470
|
-
showTotal: (total, range) => `${range[0]}-${range[1]} / ${total} items`,
|
|
471
|
-
...pagination
|
|
472
|
-
}
|
|
473
|
-
})), /*#__PURE__*/_react.default.createElement("div", null), pagination && pagination.onChange && !pagination.position && /*#__PURE__*/_react.default.createElement(_pagination.default
|
|
474
|
-
// style={{padding: '0.75rem 1rem'}}
|
|
475
|
-
, (0, _extends2.default)({
|
|
476
|
-
rootClassName: 'pagination-template',
|
|
477
|
-
showSizeChanger: true,
|
|
478
|
-
responsive: true,
|
|
479
|
-
size: 'small'
|
|
480
|
-
// @ts-ignore
|
|
481
|
-
,
|
|
482
|
-
showTotal: (total, range) => `${range[0]}-${range[1]} / ${total} ${t ? t(pagination?.locale?.items ?? 'items') : 'items'}`
|
|
483
|
-
}, pagination)), bottomToolbar?.(), /*#__PURE__*/_react.default.createElement(_reactTooltip.Tooltip, {
|
|
484
|
-
id: `${id}-tooltip-header`,
|
|
485
|
-
style: {
|
|
486
|
-
zIndex: 1999,
|
|
487
|
-
maxWidth: 350
|
|
488
|
-
}
|
|
489
|
-
}), /*#__PURE__*/_react.default.createElement(_reactTooltip.Tooltip, {
|
|
490
|
-
id: "tooltip-icon"
|
|
491
|
-
}));
|
|
492
|
-
};
|
|
493
|
-
var _default = exports.default = TableGrid;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { BaseOptionType, DefaultOptionType } from "rc-select/lib/Select";
|
|
3
|
-
import type { SelectProps } from "rc-master-ui/es/select";
|
|
4
|
-
import type { LoadOptionsArgs } from "../type";
|
|
5
|
-
export interface DebounceSelectProps<OptionType extends BaseOptionType = DefaultOptionType> extends SelectProps {
|
|
6
|
-
loadOptions?: (search: string, callback: (newOptions: OptionType[]) => void, args?: LoadOptionsArgs) => void;
|
|
7
|
-
debounceTimeout?: number;
|
|
8
|
-
defaultOptions?: OptionType[];
|
|
9
|
-
rowData?: any;
|
|
10
|
-
}
|
|
11
|
-
export declare function AsyncSelect<OptionType extends BaseOptionType>({ loadOptions, debounceTimeout, defaultOptions, rowData, ...props }: DebounceSelectProps<OptionType>): React.JSX.Element;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.AsyncSelect = AsyncSelect;
|
|
8
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
var _debounce = _interopRequireDefault(require("lodash/debounce"));
|
|
11
|
-
var _rcMasterUi = require("rc-master-ui");
|
|
12
|
-
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); }
|
|
13
|
-
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; }
|
|
14
|
-
function AsyncSelect({
|
|
15
|
-
loadOptions,
|
|
16
|
-
debounceTimeout = 500,
|
|
17
|
-
defaultOptions,
|
|
18
|
-
rowData,
|
|
19
|
-
...props
|
|
20
|
-
}) {
|
|
21
|
-
const [options, setOptions] = (0, _react.useState)(defaultOptions ?? []);
|
|
22
|
-
const debounceFetcher = (0, _react.useMemo)(() => {
|
|
23
|
-
const fetchOptions = value => {
|
|
24
|
-
if (value.trim().length === 0) {
|
|
25
|
-
setOptions(defaultOptions ?? []);
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
if (loadOptions) {
|
|
29
|
-
loadOptions(value, newOptions => {
|
|
30
|
-
setOptions(newOptions);
|
|
31
|
-
}, {
|
|
32
|
-
rowData
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
return (0, _debounce.default)(fetchOptions, debounceTimeout);
|
|
37
|
-
}, [loadOptions, debounceTimeout]);
|
|
38
|
-
(0, _react.useEffect)(() => {
|
|
39
|
-
setOptions(defaultOptions ?? []);
|
|
40
|
-
}, [defaultOptions]);
|
|
41
|
-
return /*#__PURE__*/_react.default.createElement(_rcMasterUi.Select, (0, _extends2.default)({}, props, {
|
|
42
|
-
filterOption: loadOptions ? false : props?.filterOption,
|
|
43
|
-
onSearch: debounceFetcher,
|
|
44
|
-
onSelect: () => setOptions(defaultOptions ?? []),
|
|
45
|
-
options: options
|
|
46
|
-
}));
|
|
47
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { BaseOptionType, DefaultOptionType } from "rc-select/lib/Select";
|
|
3
|
-
import type { TableSelectProps } from "rc-master-ui/es/table-select";
|
|
4
|
-
import type { LoadOptionsArgs } from "../type";
|
|
5
|
-
export interface DebounceSelectProps<OptionType extends BaseOptionType = DefaultOptionType> extends TableSelectProps {
|
|
6
|
-
loadOptions?: (search: string, callback: (newOptions: OptionType[]) => void, args?: LoadOptionsArgs) => void;
|
|
7
|
-
debounceTimeout?: number;
|
|
8
|
-
defaultOptions?: OptionType[];
|
|
9
|
-
rowData?: any;
|
|
10
|
-
}
|
|
11
|
-
export declare function AsyncTableSelect<OptionType extends BaseOptionType>({ loadOptions, debounceTimeout, defaultOptions, columns, rowData, ...props }: DebounceSelectProps<OptionType>): React.JSX.Element;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.AsyncTableSelect = AsyncTableSelect;
|
|
8
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
var _debounce = _interopRequireDefault(require("lodash/debounce"));
|
|
11
|
-
var _rcMasterUi = require("rc-master-ui");
|
|
12
|
-
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); }
|
|
13
|
-
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; }
|
|
14
|
-
function AsyncTableSelect({
|
|
15
|
-
loadOptions,
|
|
16
|
-
debounceTimeout = 500,
|
|
17
|
-
defaultOptions,
|
|
18
|
-
columns,
|
|
19
|
-
rowData,
|
|
20
|
-
...props
|
|
21
|
-
}) {
|
|
22
|
-
const [options, setOptions] = (0, _react.useState)(defaultOptions ?? []);
|
|
23
|
-
const debounceFetcher = (0, _react.useMemo)(() => {
|
|
24
|
-
const fetchOptions = value => {
|
|
25
|
-
if (value.trim().length === 0) {
|
|
26
|
-
setOptions(defaultOptions ?? []);
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
if (loadOptions) {
|
|
30
|
-
loadOptions(value, newOptions => {
|
|
31
|
-
setOptions(newOptions);
|
|
32
|
-
}, {
|
|
33
|
-
rowData
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
return (0, _debounce.default)(fetchOptions, debounceTimeout);
|
|
38
|
-
}, [debounceTimeout, loadOptions, defaultOptions, rowData]);
|
|
39
|
-
(0, _react.useEffect)(() => {
|
|
40
|
-
setOptions(defaultOptions ?? []);
|
|
41
|
-
}, [defaultOptions]);
|
|
42
|
-
return /*#__PURE__*/_react.default.createElement(_rcMasterUi.TableSelect, (0, _extends2.default)({}, props, {
|
|
43
|
-
filterOption: loadOptions ? false : props?.filterOption,
|
|
44
|
-
onSearch: debounceFetcher,
|
|
45
|
-
onSelect: () => setOptions(defaultOptions ?? []),
|
|
46
|
-
options: options,
|
|
47
|
-
columns: columns
|
|
48
|
-
}));
|
|
49
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
type OptionType = {
|
|
3
|
-
value: any;
|
|
4
|
-
label: string;
|
|
5
|
-
[key: string]: any;
|
|
6
|
-
};
|
|
7
|
-
type Props<T> = {
|
|
8
|
-
options: T[];
|
|
9
|
-
value: any[];
|
|
10
|
-
onChange?: (value: any[]) => void;
|
|
11
|
-
};
|
|
12
|
-
declare const CheckboxControl: <T extends OptionType>(props: Props<T>) => React.JSX.Element;
|
|
13
|
-
export default CheckboxControl;
|