@hi-ui/table 4.3.0 → 4.3.2-alpha.0
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/CHANGELOG.md +11 -0
- package/lib/cjs/BaseTable.js +136 -189
- package/lib/cjs/ColGroupContent.js +5 -28
- package/lib/cjs/SettingDrawer.js +76 -127
- package/lib/cjs/Table.js +107 -171
- package/lib/cjs/TableAdvancedFilter.js +49 -85
- package/lib/cjs/TableBody.js +42 -73
- package/lib/cjs/TableCell.js +56 -102
- package/lib/cjs/TableColumnMenu.js +39 -77
- package/lib/cjs/TableEmbedRow.js +11 -38
- package/lib/cjs/TableHeader.js +8 -33
- package/lib/cjs/TableRow.js +48 -88
- package/lib/cjs/TableSettingMenu.js +48 -94
- package/lib/cjs/TbodyContent.js +28 -56
- package/lib/cjs/TheadContent.js +20 -49
- package/lib/cjs/_virtual/index.js +0 -3
- package/lib/cjs/_virtual/index2.js +0 -3
- package/lib/cjs/_virtual/react-is.development.js +0 -3
- package/lib/cjs/_virtual/react-is.production.min.js +0 -3
- package/lib/cjs/context.js +0 -9
- package/lib/cjs/hooks/use-async-switch.js +13 -51
- package/lib/cjs/hooks/use-check.js +47 -77
- package/lib/cjs/hooks/use-col-hidden.js +16 -28
- package/lib/cjs/hooks/use-col-set.js +5 -18
- package/lib/cjs/hooks/use-col-sorter.js +18 -32
- package/lib/cjs/hooks/use-col-width.js +21 -57
- package/lib/cjs/hooks/use-colgroup.js +63 -85
- package/lib/cjs/hooks/use-drag.js +10 -31
- package/lib/cjs/hooks/use-embed-expand.js +23 -68
- package/lib/cjs/hooks/use-expand.js +32 -64
- package/lib/cjs/hooks/use-pagination.js +19 -50
- package/lib/cjs/hooks/use-queue.js +2 -14
- package/lib/cjs/icons/index.js +4 -21
- package/lib/cjs/index.js +0 -4
- package/lib/cjs/node_modules/classnames/index.js +2 -11
- package/lib/cjs/node_modules/perfect-scrollbar/dist/perfect-scrollbar.esm.js +1090 -0
- package/lib/cjs/node_modules/rc-resize-observer/es/index.js +10 -68
- package/lib/cjs/node_modules/rc-resize-observer/node_modules/rc-util/es/Children/toArray.js +1 -17
- package/lib/cjs/node_modules/rc-resize-observer/node_modules/rc-util/es/Dom/findDOMNode.js +1 -14
- package/lib/cjs/node_modules/rc-resize-observer/node_modules/rc-util/es/ref.js +1 -25
- package/lib/cjs/node_modules/rc-resize-observer/node_modules/rc-util/es/warning.js +1 -5
- package/lib/cjs/node_modules/rc-util/es/Dom/canUseDom.js +0 -2
- package/lib/cjs/node_modules/rc-util/es/Dom/findDOMNode.js +1 -14
- package/lib/cjs/node_modules/rc-util/es/hooks/useLayoutEffect.js +2 -9
- package/lib/cjs/node_modules/rc-util/es/raf.js +0 -11
- package/lib/cjs/node_modules/rc-virtual-list/es/Filler.js +6 -25
- package/lib/cjs/node_modules/rc-virtual-list/es/Item.js +3 -14
- package/lib/cjs/node_modules/rc-virtual-list/es/List.js +103 -194
- package/lib/cjs/node_modules/rc-virtual-list/es/ScrollBar.js +16 -96
- package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useChildren.js +2 -11
- package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useDiffItem.js +8 -34
- package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useFrameWheel.js +0 -10
- package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useHeights.js +6 -39
- package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useMobileTouchMove.js +0 -16
- package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useOriginScroll.js +4 -9
- package/lib/cjs/node_modules/rc-virtual-list/es/hooks/useScrollTo.js +3 -28
- package/lib/cjs/node_modules/rc-virtual-list/es/index.js +0 -2
- package/lib/cjs/node_modules/rc-virtual-list/es/utils/CacheMap.js +2 -9
- package/lib/cjs/node_modules/rc-virtual-list/es/utils/algorithmUtil.js +0 -15
- package/lib/cjs/node_modules/rc-virtual-list/es/utils/isFirefox.js +0 -2
- package/lib/cjs/node_modules/react-is/cjs/react-is.development.js +3 -29
- package/lib/cjs/node_modules/react-is/cjs/react-is.production.min.js +19 -45
- package/lib/cjs/node_modules/react-is/index.js +0 -5
- package/lib/cjs/node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js +83 -248
- package/lib/cjs/packages/hooks/use-merge-refs/lib/esm/index.js +65 -0
- package/lib/cjs/packages/ui/scrollbar/lib/esm/Scrollbar.js +147 -0
- package/lib/cjs/packages/ui/scrollbar/lib/esm/styles/index.scss.js +28 -0
- package/lib/cjs/packages/ui/scrollbar/lib/esm/utils/index.js +68 -0
- package/lib/cjs/styles/index.scss.js +1 -4
- package/lib/cjs/use-table.js +276 -361
- package/lib/cjs/utils/index.js +11 -45
- package/lib/esm/BaseTable.js +117 -138
- package/lib/esm/ColGroupContent.js +3 -9
- package/lib/esm/SettingDrawer.js +64 -83
- package/lib/esm/Table.js +97 -124
- package/lib/esm/TableAdvancedFilter.js +37 -47
- package/lib/esm/TableBody.js +37 -44
- package/lib/esm/TableCell.js +48 -72
- package/lib/esm/TableColumnMenu.js +24 -38
- package/lib/esm/TableEmbedRow.js +8 -15
- package/lib/esm/TableHeader.js +5 -11
- package/lib/esm/TableRow.js +36 -51
- package/lib/esm/TableSettingMenu.js +33 -49
- package/lib/esm/TbodyContent.js +20 -27
- package/lib/esm/TheadContent.js +14 -21
- package/lib/esm/context.js +0 -4
- package/lib/esm/hooks/use-async-switch.js +9 -28
- package/lib/esm/hooks/use-check.js +42 -55
- package/lib/esm/hooks/use-col-hidden.js +16 -21
- package/lib/esm/hooks/use-col-set.js +5 -13
- package/lib/esm/hooks/use-col-sorter.js +18 -23
- package/lib/esm/hooks/use-col-width.js +14 -34
- package/lib/esm/hooks/use-colgroup.js +60 -66
- package/lib/esm/hooks/use-drag.js +9 -13
- package/lib/esm/hooks/use-embed-expand.js +20 -42
- package/lib/esm/hooks/use-expand.js +32 -56
- package/lib/esm/hooks/use-pagination.js +13 -25
- package/lib/esm/hooks/use-queue.js +2 -10
- package/lib/esm/node_modules/classnames/index.js +2 -9
- package/lib/esm/node_modules/perfect-scrollbar/dist/perfect-scrollbar.esm.js +1084 -0
- package/lib/esm/node_modules/rc-resize-observer/es/index.js +3 -26
- package/lib/esm/node_modules/rc-resize-observer/node_modules/rc-util/es/Children/toArray.js +0 -3
- package/lib/esm/node_modules/rc-resize-observer/node_modules/rc-util/es/Dom/findDOMNode.js +1 -2
- package/lib/esm/node_modules/rc-resize-observer/node_modules/rc-util/es/ref.js +0 -8
- package/lib/esm/node_modules/rc-resize-observer/node_modules/rc-util/es/warning.js +0 -5
- package/lib/esm/node_modules/rc-util/es/Dom/canUseDom.js +0 -1
- package/lib/esm/node_modules/rc-util/es/Dom/findDOMNode.js +1 -2
- package/lib/esm/node_modules/rc-util/es/hooks/useLayoutEffect.js +1 -0
- package/lib/esm/node_modules/rc-util/es/raf.js +0 -10
- package/lib/esm/node_modules/rc-virtual-list/es/Filler.js +4 -15
- package/lib/esm/node_modules/rc-virtual-list/es/Item.js +1 -3
- package/lib/esm/node_modules/rc-virtual-list/es/List.js +101 -174
- package/lib/esm/node_modules/rc-virtual-list/es/ScrollBar.js +14 -86
- package/lib/esm/node_modules/rc-virtual-list/es/hooks/useChildren.js +0 -2
- package/lib/esm/node_modules/rc-virtual-list/es/hooks/useDiffItem.js +6 -25
- package/lib/esm/node_modules/rc-virtual-list/es/hooks/useFrameWheel.js +0 -6
- package/lib/esm/node_modules/rc-virtual-list/es/hooks/useHeights.js +4 -28
- package/lib/esm/node_modules/rc-virtual-list/es/hooks/useMobileTouchMove.js +0 -13
- package/lib/esm/node_modules/rc-virtual-list/es/hooks/useOriginScroll.js +4 -8
- package/lib/esm/node_modules/rc-virtual-list/es/hooks/useScrollTo.js +1 -19
- package/lib/esm/node_modules/rc-virtual-list/es/index.js +1 -1
- package/lib/esm/node_modules/rc-virtual-list/es/utils/CacheMap.js +2 -8
- package/lib/esm/node_modules/rc-virtual-list/es/utils/algorithmUtil.js +1 -12
- package/lib/esm/node_modules/rc-virtual-list/es/utils/isFirefox.js +0 -1
- package/lib/esm/node_modules/react-is/cjs/react-is.development.js +4 -27
- package/lib/esm/node_modules/react-is/cjs/react-is.production.min.js +20 -44
- package/lib/esm/node_modules/react-is/index.js +0 -1
- package/lib/esm/node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js +82 -248
- package/lib/esm/packages/hooks/use-merge-refs/lib/esm/index.js +62 -0
- package/lib/esm/packages/ui/scrollbar/lib/esm/Scrollbar.js +145 -0
- package/lib/esm/packages/ui/scrollbar/lib/esm/styles/index.scss.js +23 -0
- package/lib/esm/packages/ui/scrollbar/lib/esm/utils/index.js +66 -0
- package/lib/esm/styles/index.scss.js +1 -3
- package/lib/esm/use-table.js +268 -323
- package/lib/esm/utils/index.js +11 -41
- package/lib/types/context.d.ts +2 -0
- package/lib/types/use-table.d.ts +8 -2
- package/package.json +5 -5
|
@@ -9,53 +9,31 @@
|
|
|
9
9
|
*/
|
|
10
10
|
'use strict';
|
|
11
11
|
|
|
12
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
13
|
-
|
|
14
|
-
Object.defineProperty(exports, '__esModule', {
|
|
15
|
-
value: true
|
|
16
|
-
});
|
|
17
|
-
|
|
18
12
|
var _regeneratorRuntime = require('@babel/runtime/regenerator');
|
|
19
|
-
|
|
20
13
|
var tslib = require('tslib');
|
|
21
|
-
|
|
22
14
|
var React = require('react');
|
|
23
|
-
|
|
24
15
|
var useLatest = require('@hi-ui/use-latest');
|
|
25
|
-
|
|
26
16
|
var treeUtils = require('@hi-ui/tree-utils');
|
|
27
|
-
|
|
28
17
|
var useCheckState = require('@hi-ui/use-check-state');
|
|
29
|
-
|
|
30
|
-
function _interopDefaultLegacy(e) {
|
|
31
|
-
return e && _typeof(e) === 'object' && 'default' in e ? e : {
|
|
32
|
-
'default': e
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
var _regeneratorRuntime__default = /*#__PURE__*/_interopDefaultLegacy(_regeneratorRuntime);
|
|
37
|
-
|
|
38
18
|
var useAsyncSwitch = function useAsyncSwitch(_ref) {
|
|
39
19
|
var setCascaderData = _ref.setCascaderData,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
var onLoadChildrenLatest = useLatest.useLatestCallback(onLoadChildren);
|
|
45
|
-
|
|
20
|
+
onExpand = _ref.onExpand,
|
|
21
|
+
onLoadChildren = _ref.onLoadChildren,
|
|
22
|
+
_ref$fieldKey = _ref.fieldKey,
|
|
23
|
+
fieldKey = _ref$fieldKey === void 0 ? 'key' : _ref$fieldKey;
|
|
24
|
+
var onLoadChildrenLatest = useLatest.useLatestCallback(onLoadChildren);
|
|
25
|
+
// 加载节点
|
|
46
26
|
var loadChildren = React.useCallback(function (node) {
|
|
47
|
-
return tslib.__awaiter(void 0, void 0, void 0, /*#__PURE__*/
|
|
27
|
+
return tslib.__awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
48
28
|
var childrenNodes;
|
|
49
|
-
return
|
|
29
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
50
30
|
while (1) {
|
|
51
31
|
switch (_context.prev = _context.next) {
|
|
52
32
|
case 0:
|
|
53
33
|
_context.next = 2;
|
|
54
34
|
return onLoadChildrenLatest(node);
|
|
55
|
-
|
|
56
35
|
case 2:
|
|
57
36
|
childrenNodes = _context.sent;
|
|
58
|
-
|
|
59
37
|
if (Array.isArray(childrenNodes)) {
|
|
60
38
|
setCascaderData(function (prev) {
|
|
61
39
|
var nextTreeData = treeUtils.cloneTree(prev);
|
|
@@ -63,7 +41,6 @@ var useAsyncSwitch = function useAsyncSwitch(_ref) {
|
|
|
63
41
|
return nextTreeData;
|
|
64
42
|
});
|
|
65
43
|
}
|
|
66
|
-
|
|
67
44
|
case 4:
|
|
68
45
|
case "end":
|
|
69
46
|
return _context.stop();
|
|
@@ -72,64 +49,52 @@ var useAsyncSwitch = function useAsyncSwitch(_ref) {
|
|
|
72
49
|
}, _callee);
|
|
73
50
|
}));
|
|
74
51
|
}, [fieldKey, onLoadChildrenLatest, setCascaderData]);
|
|
75
|
-
|
|
76
52
|
var _useCheckState = useCheckState.useCheckState(),
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
53
|
+
loadingIds = _useCheckState.state,
|
|
54
|
+
addLoadingIds = _useCheckState.add,
|
|
55
|
+
removeLoadingIds = _useCheckState.remove;
|
|
81
56
|
var onExpandLatest = useLatest.useLatestCallback(onExpand);
|
|
82
57
|
var onNodeSwitch = React.useCallback(function (node, onlyExpand) {
|
|
83
58
|
if (onlyExpand === void 0) {
|
|
84
59
|
onlyExpand = false;
|
|
85
60
|
}
|
|
86
|
-
|
|
87
|
-
return tslib.__awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2() {
|
|
61
|
+
return tslib.__awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
88
62
|
var id, children, isLeaf;
|
|
89
|
-
return
|
|
63
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
90
64
|
while (1) {
|
|
91
65
|
switch (_context2.prev = _context2.next) {
|
|
92
66
|
case 0:
|
|
93
67
|
// 直接触发选中该节点
|
|
94
68
|
onExpandLatest(node, onlyExpand);
|
|
95
69
|
id = node.id, children = node.children, isLeaf = node.isLeaf;
|
|
96
|
-
|
|
97
70
|
if (!children) {
|
|
98
71
|
_context2.next = 4;
|
|
99
72
|
break;
|
|
100
73
|
}
|
|
101
|
-
|
|
102
74
|
return _context2.abrupt("return");
|
|
103
|
-
|
|
104
75
|
case 4:
|
|
105
76
|
if (!isLeaf) {
|
|
106
77
|
_context2.next = 6;
|
|
107
78
|
break;
|
|
108
79
|
}
|
|
109
|
-
|
|
110
80
|
return _context2.abrupt("return");
|
|
111
|
-
|
|
112
81
|
case 6:
|
|
113
82
|
if (!onLoadChildren) {
|
|
114
83
|
_context2.next = 17;
|
|
115
84
|
break;
|
|
116
85
|
}
|
|
117
|
-
|
|
118
86
|
addLoadingIds(id);
|
|
119
87
|
_context2.prev = 8;
|
|
120
88
|
_context2.next = 11;
|
|
121
89
|
return loadChildren(node);
|
|
122
|
-
|
|
123
90
|
case 11:
|
|
124
91
|
removeLoadingIds(id);
|
|
125
92
|
_context2.next = 17;
|
|
126
93
|
break;
|
|
127
|
-
|
|
128
94
|
case 14:
|
|
129
95
|
_context2.prev = 14;
|
|
130
96
|
_context2.t0 = _context2["catch"](8);
|
|
131
97
|
removeLoadingIds(id);
|
|
132
|
-
|
|
133
98
|
case 17:
|
|
134
99
|
case "end":
|
|
135
100
|
return _context2.stop();
|
|
@@ -138,12 +103,9 @@ var useAsyncSwitch = function useAsyncSwitch(_ref) {
|
|
|
138
103
|
}, _callee2, null, [[8, 14]]);
|
|
139
104
|
}));
|
|
140
105
|
}, [loadChildren, onLoadChildren, onExpandLatest, addLoadingIds, removeLoadingIds]);
|
|
141
|
-
|
|
142
106
|
var isLoadingId = function isLoadingId(id) {
|
|
143
107
|
return loadingIds.indexOf(id) !== -1;
|
|
144
108
|
};
|
|
145
|
-
|
|
146
109
|
return [isLoadingId, onNodeSwitch];
|
|
147
110
|
};
|
|
148
|
-
|
|
149
111
|
exports.useAsyncSwitch = useAsyncSwitch;
|
|
@@ -9,60 +9,38 @@
|
|
|
9
9
|
*/
|
|
10
10
|
'use strict';
|
|
11
11
|
|
|
12
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
13
|
-
|
|
14
|
-
Object.defineProperty(exports, '__esModule', {
|
|
15
|
-
value: true
|
|
16
|
-
});
|
|
17
|
-
|
|
18
12
|
var useCheck = require('@hi-ui/use-check');
|
|
19
|
-
|
|
20
13
|
var React = require('react');
|
|
21
|
-
|
|
22
14
|
var useUncontrolledState = require('@hi-ui/use-uncontrolled-state');
|
|
23
|
-
|
|
24
|
-
function _interopDefaultLegacy(e) {
|
|
25
|
-
return e && _typeof(e) === 'object' && 'default' in e ? e : {
|
|
26
|
-
'default': e
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
31
|
-
|
|
32
15
|
var DEFAULT_CHECKED_ROW_KEYS = [];
|
|
33
|
-
|
|
34
16
|
var useTableCheck = function useTableCheck(_ref) {
|
|
35
17
|
var rowSelection = _ref.rowSelection,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
var checkRowIsDisabledCheckbox =
|
|
18
|
+
flattedData = _ref.flattedData,
|
|
19
|
+
fieldKey = _ref.fieldKey;
|
|
20
|
+
var checkRowIsDisabledCheckbox = React.useCallback(function (rowItem) {
|
|
39
21
|
var checkboxConfig = rowSelection && rowSelection.getCheckboxConfig && rowSelection.getCheckboxConfig(rowItem);
|
|
40
22
|
return checkboxConfig && checkboxConfig.disabled || false;
|
|
41
23
|
}, [rowSelection]);
|
|
42
|
-
|
|
43
24
|
var _useUncontrolledState = useUncontrolledState.useUncontrolledState(DEFAULT_CHECKED_ROW_KEYS, rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.selectedRowKeys, rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.onChange),
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
var
|
|
49
|
-
|
|
50
|
-
|
|
25
|
+
checkedRowKeys = _useUncontrolledState[0],
|
|
26
|
+
trySetCheckedRowKeys = _useUncontrolledState[1];
|
|
27
|
+
// 已选中的行数据集合
|
|
28
|
+
var checkedRowDataItemsRef = React.useRef([]);
|
|
29
|
+
var checkedRowDataItems = checkedRowDataItemsRef.current;
|
|
30
|
+
// TODO: 暂时不支持正反选
|
|
51
31
|
var _useCheck = useCheck.useCheck({
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
var onCheckedRowKeysChange = React__default["default"].useCallback(function (rowItem, checked) {
|
|
32
|
+
checkedIds: checkedRowKeys,
|
|
33
|
+
onCheck: function onCheck(checkedRowKeys, rowItem, checked) {
|
|
34
|
+
trySetCheckedRowKeys(checkedRowKeys, rowItem, checked, checkedRowDataItemsRef.current);
|
|
35
|
+
},
|
|
36
|
+
idFieldName: fieldKey
|
|
37
|
+
}),
|
|
38
|
+
handleCheckedRowKeysChange = _useCheck[0],
|
|
39
|
+
isCheckedRowKey = _useCheck[1];
|
|
40
|
+
// 选中项变化会触发该函数
|
|
41
|
+
var onCheckedRowKeysChange = React.useCallback(function (rowItem, checked) {
|
|
63
42
|
// 记录选中的行数据集合
|
|
64
43
|
var nextCheckedDataItems = checkedRowDataItems;
|
|
65
|
-
|
|
66
44
|
if (checked) {
|
|
67
45
|
if (!nextCheckedDataItems.find(function (item) {
|
|
68
46
|
return item[fieldKey] === rowItem[fieldKey];
|
|
@@ -74,40 +52,34 @@ var useTableCheck = function useTableCheck(_ref) {
|
|
|
74
52
|
return item[fieldKey] !== rowItem[fieldKey];
|
|
75
53
|
});
|
|
76
54
|
}
|
|
77
|
-
|
|
78
55
|
handleCheckedRowKeysChange(rowItem, checked);
|
|
79
|
-
}, [checkedRowDataItems, fieldKey, handleCheckedRowKeysChange]);
|
|
80
|
-
|
|
81
|
-
var _React$useMemo =
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
56
|
+
}, [checkedRowDataItems, fieldKey, handleCheckedRowKeysChange]);
|
|
57
|
+
// 判断是否全选
|
|
58
|
+
var _React$useMemo = React.useMemo(function () {
|
|
59
|
+
if (rowSelection) {
|
|
60
|
+
if (flattedData.length === 0 || checkedRowKeys.length === 0) {
|
|
61
|
+
return [false, false];
|
|
62
|
+
}
|
|
63
|
+
var idsCanBeChecked = flattedData.filter(function (item) {
|
|
64
|
+
return !checkRowIsDisabledCheckbox(item.raw);
|
|
65
|
+
}).map(function (item) {
|
|
66
|
+
return item.id;
|
|
67
|
+
});
|
|
68
|
+
// TODO: 数组项完全匹配工具函数
|
|
69
|
+
// TODO: 数组项完全匹配工具函数
|
|
70
|
+
var _checkedAll = idsCanBeChecked.every(function (id) {
|
|
71
|
+
return isCheckedRowKey(id);
|
|
72
|
+
});
|
|
73
|
+
var _semiChecked = _checkedAll ? false : checkedRowKeys.length > 0 && idsCanBeChecked.some(function (id) {
|
|
74
|
+
return isCheckedRowKey(id);
|
|
75
|
+
});
|
|
76
|
+
return [_checkedAll, _semiChecked];
|
|
85
77
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}); // TODO: 数组项完全匹配工具函数
|
|
92
|
-
// TODO: 数组项完全匹配工具函数
|
|
93
|
-
|
|
94
|
-
var _checkedAll = idsCanBeChecked.every(function (id) {
|
|
95
|
-
return isCheckedRowKey(id);
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
var _semiChecked = _checkedAll ? false : checkedRowKeys.length > 0 && idsCanBeChecked.some(function (id) {
|
|
99
|
-
return isCheckedRowKey(id);
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
return [_checkedAll, _semiChecked];
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
return [false, false];
|
|
106
|
-
}, [flattedData, rowSelection, isCheckedRowKey, checkedRowKeys.length, checkRowIsDisabledCheckbox]),
|
|
107
|
-
checkedAll = _React$useMemo[0],
|
|
108
|
-
semiChecked = _React$useMemo[1];
|
|
109
|
-
|
|
110
|
-
var tryCheckAllRow = React__default["default"].useCallback(function () {
|
|
78
|
+
return [false, false];
|
|
79
|
+
}, [flattedData, rowSelection, isCheckedRowKey, checkedRowKeys.length, checkRowIsDisabledCheckbox]),
|
|
80
|
+
checkedAll = _React$useMemo[0],
|
|
81
|
+
semiChecked = _React$useMemo[1];
|
|
82
|
+
var tryCheckAllRow = React.useCallback(function () {
|
|
111
83
|
var targetItems = flattedData.filter(function (item) {
|
|
112
84
|
return !checkRowIsDisabledCheckbox(item.raw);
|
|
113
85
|
});
|
|
@@ -118,7 +90,6 @@ var useTableCheck = function useTableCheck(_ref) {
|
|
|
118
90
|
return item.raw;
|
|
119
91
|
});
|
|
120
92
|
var checkedRowKeysSet = new Set(checkedRowKeys);
|
|
121
|
-
|
|
122
93
|
if (checkedAll) {
|
|
123
94
|
// 移除当前页所有行 ids
|
|
124
95
|
trySetCheckedRowKeys(function (prev) {
|
|
@@ -128,8 +99,8 @@ var useTableCheck = function useTableCheck(_ref) {
|
|
|
128
99
|
}, targetRowItems, false);
|
|
129
100
|
return;
|
|
130
101
|
}
|
|
131
|
-
|
|
132
|
-
|
|
102
|
+
trySetCheckedRowKeys(
|
|
103
|
+
// 添加当前页所有行 ids
|
|
133
104
|
function (prev) {
|
|
134
105
|
prev.forEach(function (id) {
|
|
135
106
|
return checkedRowKeysSet.add(id);
|
|
@@ -148,5 +119,4 @@ var useTableCheck = function useTableCheck(_ref) {
|
|
|
148
119
|
checkRowIsDisabledCheckbox: checkRowIsDisabledCheckbox
|
|
149
120
|
};
|
|
150
121
|
};
|
|
151
|
-
|
|
152
122
|
exports.useTableCheck = useTableCheck;
|
|
@@ -9,39 +9,29 @@
|
|
|
9
9
|
*/
|
|
10
10
|
'use strict';
|
|
11
11
|
|
|
12
|
-
Object.defineProperty(exports, '__esModule', {
|
|
13
|
-
value: true
|
|
14
|
-
});
|
|
15
|
-
|
|
16
12
|
var React = require('react');
|
|
17
|
-
|
|
18
13
|
var useUncontrolledState = require('@hi-ui/use-uncontrolled-state');
|
|
19
|
-
|
|
20
14
|
var index = require('../utils/index.js');
|
|
21
|
-
|
|
22
15
|
var DEFAULT_COLUMNS = [];
|
|
23
16
|
/**
|
|
24
17
|
* 列操作逻辑
|
|
25
18
|
*/
|
|
26
|
-
|
|
27
19
|
var useColHidden = function useColHidden(_ref) {
|
|
28
20
|
var uniqueId = _ref.uniqueId,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
21
|
+
_ref$columns = _ref.columns,
|
|
22
|
+
columns = _ref$columns === void 0 ? DEFAULT_COLUMNS : _ref$columns,
|
|
23
|
+
hiddenColKeysProp = _ref.hiddenColKeys,
|
|
24
|
+
onHiddenColKeysChange = _ref.onHiddenColKeysChange;
|
|
33
25
|
var cacheKey = uniqueId ? uniqueId + "_hiddenColKeys" : '';
|
|
34
|
-
|
|
35
26
|
var _useUncontrolledState = useUncontrolledState.useUncontrolledState(function () {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
27
|
+
return index.parseLocalArray({
|
|
28
|
+
key: cacheKey,
|
|
29
|
+
defaultValue: []
|
|
30
|
+
});
|
|
31
|
+
}, hiddenColKeysProp, onHiddenColKeysChange),
|
|
32
|
+
_hiddenColKeys = _useUncontrolledState[0],
|
|
33
|
+
setHiddenColKeys = _useUncontrolledState[1];
|
|
34
|
+
// 保证 includes 匹配 column,是有效的可展示的列
|
|
45
35
|
var hiddenColKeys = React.useMemo(function () {
|
|
46
36
|
return _hiddenColKeys.filter(function (dataKey) {
|
|
47
37
|
return typeof dataKey === 'string' && dataKey !== '';
|
|
@@ -50,12 +40,11 @@ var useColHidden = function useColHidden(_ref) {
|
|
|
50
40
|
React.useEffect(function () {
|
|
51
41
|
if (!cacheKey) return;
|
|
52
42
|
window.localStorage.setItem(cacheKey, JSON.stringify(hiddenColKeys));
|
|
53
|
-
}, [cacheKey, hiddenColKeys]);
|
|
54
|
-
|
|
43
|
+
}, [cacheKey, hiddenColKeys]);
|
|
44
|
+
// 用于维护列操作时显隐临时状态
|
|
55
45
|
var _useState = React.useState(hiddenColKeys),
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
46
|
+
cacheHiddenColKeys = _useState[0],
|
|
47
|
+
setCacheHiddenColKeys = _useState[1];
|
|
59
48
|
var visibleCols = React.useMemo(function () {
|
|
60
49
|
// TODO: 支持隐藏叶子结点,而不是根节点
|
|
61
50
|
// @ts-ignore
|
|
@@ -71,5 +60,4 @@ var useColHidden = function useColHidden(_ref) {
|
|
|
71
60
|
setCacheHiddenColKeys: setCacheHiddenColKeys
|
|
72
61
|
};
|
|
73
62
|
};
|
|
74
|
-
|
|
75
63
|
exports.useColHidden = useColHidden;
|
|
@@ -9,50 +9,38 @@
|
|
|
9
9
|
*/
|
|
10
10
|
'use strict';
|
|
11
11
|
|
|
12
|
-
Object.defineProperty(exports, '__esModule', {
|
|
13
|
-
value: true
|
|
14
|
-
});
|
|
15
|
-
|
|
16
12
|
var React = require('react');
|
|
17
|
-
|
|
18
13
|
var DEFAULT_COLUMNS = [];
|
|
19
14
|
/**
|
|
20
15
|
* 列设置
|
|
21
16
|
*/
|
|
22
|
-
|
|
23
17
|
var useColSet = function useColSet(_ref) {
|
|
24
18
|
var _ref$columns = _ref.columns,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
columns = _ref$columns === void 0 ? DEFAULT_COLUMNS : _ref$columns,
|
|
20
|
+
sortedColKeysProp = _ref.sortedColKeys,
|
|
21
|
+
hiddenColKeysProp = _ref.hiddenColKeys;
|
|
28
22
|
var isColumnsEqual = React.useMemo(function () {
|
|
29
|
-
var _a;
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
var _a;
|
|
24
|
+
// 判断columns和之前的是不是一样的,如果之前columns对不上,那么认为设置数据无效。
|
|
32
25
|
if (!sortedColKeysProp) {
|
|
33
26
|
return true;
|
|
34
27
|
}
|
|
35
|
-
|
|
36
28
|
if (columns.length !== sortedColKeysProp.length) {
|
|
37
29
|
return false;
|
|
38
30
|
}
|
|
39
|
-
|
|
40
31
|
for (var cIndex = 0; cIndex < columns.length; cIndex++) {
|
|
41
32
|
var exist = false;
|
|
42
33
|
var dataKey = (_a = columns[cIndex]) === null || _a === void 0 ? void 0 : _a.dataKey;
|
|
43
|
-
|
|
44
34
|
for (var sIndex = 0; sIndex < sortedColKeysProp.length; sIndex++) {
|
|
45
35
|
if (dataKey === sortedColKeysProp[sIndex]) {
|
|
46
36
|
exist = true;
|
|
47
37
|
break;
|
|
48
38
|
}
|
|
49
39
|
}
|
|
50
|
-
|
|
51
40
|
if (!exist) {
|
|
52
41
|
return false;
|
|
53
42
|
}
|
|
54
43
|
}
|
|
55
|
-
|
|
56
44
|
return true;
|
|
57
45
|
}, [columns, sortedColKeysProp]);
|
|
58
46
|
return {
|
|
@@ -60,5 +48,4 @@ var useColSet = function useColSet(_ref) {
|
|
|
60
48
|
hiddenColKeys: isColumnsEqual ? hiddenColKeysProp : undefined
|
|
61
49
|
};
|
|
62
50
|
};
|
|
63
|
-
|
|
64
51
|
exports.useColSet = useColSet;
|
|
@@ -9,44 +9,32 @@
|
|
|
9
9
|
*/
|
|
10
10
|
'use strict';
|
|
11
11
|
|
|
12
|
-
Object.defineProperty(exports, '__esModule', {
|
|
13
|
-
value: true
|
|
14
|
-
});
|
|
15
|
-
|
|
16
12
|
var React = require('react');
|
|
17
|
-
|
|
18
13
|
var useUpdateEffect = require('@hi-ui/use-update-effect');
|
|
19
|
-
|
|
20
14
|
var useUncontrolledState = require('@hi-ui/use-uncontrolled-state');
|
|
21
|
-
|
|
22
15
|
var useLatest = require('@hi-ui/use-latest');
|
|
23
|
-
|
|
24
16
|
var index = require('../utils/index.js');
|
|
25
|
-
|
|
26
17
|
var DEFAULT_COLUMNS = [];
|
|
27
18
|
/**
|
|
28
19
|
* 列排序
|
|
29
20
|
*/
|
|
30
|
-
|
|
31
21
|
var useColSorter = function useColSorter(_ref) {
|
|
32
22
|
var uniqueId = _ref.uniqueId,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
23
|
+
_ref$columns = _ref.columns,
|
|
24
|
+
columns = _ref$columns === void 0 ? DEFAULT_COLUMNS : _ref$columns,
|
|
25
|
+
sortedColKeysProp = _ref.sortedColKeys,
|
|
26
|
+
onSortedColKeysChange = _ref.onSortedColKeysChange;
|
|
37
27
|
var cacheKey = uniqueId ? uniqueId + "_sortCols" : '';
|
|
38
|
-
|
|
39
28
|
var _useUncontrolledState = useUncontrolledState.useUncontrolledState(function () {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
29
|
+
return index.parseLocalArray({
|
|
30
|
+
key: cacheKey,
|
|
31
|
+
defaultValue: columns.map(function (column) {
|
|
32
|
+
return column.dataKey;
|
|
33
|
+
})
|
|
34
|
+
});
|
|
35
|
+
}, sortedColKeysProp, onSortedColKeysChange),
|
|
36
|
+
sortedColKeys = _useUncontrolledState[0],
|
|
37
|
+
setSortColKeys = _useUncontrolledState[1];
|
|
50
38
|
useUpdateEffect.useUpdateEffect(function () {
|
|
51
39
|
// 当column发生改变的时候,同步 setting 的 sortedCols 设置
|
|
52
40
|
setSortColKeys(columns.map(function (column) {
|
|
@@ -66,13 +54,12 @@ var useColSorter = function useColSorter(_ref) {
|
|
|
66
54
|
React.useEffect(function () {
|
|
67
55
|
if (!cacheKey) return;
|
|
68
56
|
window.localStorage.setItem(cacheKey, JSON.stringify(sortedColKeys));
|
|
69
|
-
}, [cacheKey, sortedColKeys]);
|
|
70
|
-
|
|
57
|
+
}, [cacheKey, sortedColKeys]);
|
|
58
|
+
// 用于维护列操作时排序临时状态((未确认保存时))
|
|
71
59
|
var _useState = React.useState(sortedCols),
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
60
|
+
_cacheSortedCols = _useState[0],
|
|
61
|
+
setCacheSortedCols = _useState[1];
|
|
62
|
+
// 保证排序的 column,是有效的可展示的列
|
|
76
63
|
var cacheSortedCols = React.useMemo(function () {
|
|
77
64
|
return _cacheSortedCols.filter(function (col) {
|
|
78
65
|
return col && typeof col.dataKey === 'string' && col.dataKey !== '';
|
|
@@ -85,5 +72,4 @@ var useColSorter = function useColSorter(_ref) {
|
|
|
85
72
|
setCacheSortedCols: setCacheSortedCols
|
|
86
73
|
};
|
|
87
74
|
};
|
|
88
|
-
|
|
89
75
|
exports.useColSorter = useColSorter;
|