@hi-ui/check-tree-select 4.6.1-alpha.0 → 4.6.2
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 +22 -0
- package/lib/cjs/CheckTreeSelect.js +2 -2
- package/lib/cjs/hooks/use-check.js +9 -5
- package/lib/cjs/utils/index.js +5 -2
- package/lib/esm/CheckTreeSelect.js +2 -2
- package/lib/esm/hooks/use-check.js +9 -5
- package/lib/esm/utils/index.js +6 -3
- package/lib/types/CheckTreeSelect.d.ts +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,27 @@
|
|
1
1
|
# @hi-ui/check-tree-select
|
2
2
|
|
3
|
+
## 4.6.2
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- [#3096](https://github.com/XiaoMi/hiui/pull/3096) [`3aff5eee7`](https://github.com/XiaoMi/hiui/commit/3aff5eee7ab4e1734fa2800d5154e8ebe24bbe00) Thanks [@zyprepare](https://github.com/zyprepare)! - perf(tag-input): 优化 wrap 模式下设置 displayRender 卡顿问题 (#3094)
|
8
|
+
|
9
|
+
- Updated dependencies [[`3aff5eee7`](https://github.com/XiaoMi/hiui/commit/3aff5eee7ab4e1734fa2800d5154e8ebe24bbe00), [`414c96a86`](https://github.com/XiaoMi/hiui/commit/414c96a86c6311c5b103733749092108cad03760), [`13b169670`](https://github.com/XiaoMi/hiui/commit/13b16967026f8389cc66315d376ef77029f4ba2b)]:
|
10
|
+
- @hi-ui/tag-input@4.1.3
|
11
|
+
- @hi-ui/highlighter@4.1.0
|
12
|
+
|
13
|
+
## 4.6.1
|
14
|
+
|
15
|
+
### Patch Changes
|
16
|
+
|
17
|
+
- [#3000](https://github.com/XiaoMi/hiui/pull/3000) [`908d6cd96`](https://github.com/XiaoMi/hiui/commit/908d6cd9657551203917230d9a91de45e65354c2) Thanks [@zyprepare](https://github.com/zyprepare)! - perf: 优化大数据下勾选卡顿
|
18
|
+
|
19
|
+
- [#2994](https://github.com/XiaoMi/hiui/pull/2994) [`4d6b26507`](https://github.com/XiaoMi/hiui/commit/4d6b26507479030686d5da65e1bec8b353b80bfa) Thanks [@zyprepare](https://github.com/zyprepare)! - fix: 修复 keyword 设置后数据没有过滤的问题
|
20
|
+
|
21
|
+
- Updated dependencies [[`908d6cd96`](https://github.com/XiaoMi/hiui/commit/908d6cd9657551203917230d9a91de45e65354c2)]:
|
22
|
+
- @hi-ui/tag-input@4.1.2
|
23
|
+
- @hi-ui/tree@4.6.1
|
24
|
+
|
3
25
|
## 4.6.0
|
4
26
|
|
5
27
|
### Minor Changes
|
@@ -79,6 +79,7 @@ var CheckTreeSelect = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
79
79
|
onLoadChildren = _a.onLoadChildren,
|
80
80
|
titleRender = _a.render,
|
81
81
|
filterOption = _a.filterOption,
|
82
|
+
keywordProp = _a.keyword,
|
82
83
|
onSearchProp = _a.onSearch,
|
83
84
|
clearable = _a.clearable,
|
84
85
|
invalid = _a.invalid,
|
@@ -97,8 +98,7 @@ var CheckTreeSelect = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
97
98
|
customRender = _a.customRender,
|
98
99
|
prefix = _a.prefix,
|
99
100
|
suffix = _a.suffix,
|
100
|
-
|
101
|
-
rest = tslib.__rest(_a, ["prefixCls", "role", "className", "data", "dataSource", "disabled", "visible", "onOpen", "onClose", "fieldNames", "checkedMode", "defaultExpandAll", "expandedIds", "defaultExpandedIds", "onExpand", "defaultValue", "value", "onChange", "searchable", "searchMode", "onLoadChildren", "render", "filterOption", "onSearch", "clearable", "invalid", "displayRender", "placeholder", "appearance", "virtual", "itemHeight", "height", "showCheckAll", "showOnlyShowChecked", "tagInputProps", "size", "customRender", "prefix", "suffix", "keyword"]);
|
101
|
+
rest = tslib.__rest(_a, ["prefixCls", "role", "className", "data", "dataSource", "disabled", "visible", "onOpen", "onClose", "fieldNames", "checkedMode", "defaultExpandAll", "expandedIds", "defaultExpandedIds", "onExpand", "defaultValue", "value", "onChange", "searchable", "searchMode", "onLoadChildren", "render", "filterOption", "keyword", "onSearch", "clearable", "invalid", "displayRender", "placeholder", "appearance", "virtual", "itemHeight", "height", "showCheckAll", "showOnlyShowChecked", "tagInputProps", "size", "customRender", "prefix", "suffix"]);
|
102
102
|
var i18n = core.useLocaleContext();
|
103
103
|
var placeholder = typeAssertion.isUndef(placeholderProp) ? i18n.get('checkTreeSelect.placeholder') : placeholderProp;
|
104
104
|
var _useUncontrolledToggl = useToggle.useUncontrolledToggle({
|
@@ -25,9 +25,15 @@ var useCheck = function useCheck(checkedMode, disabled, flattedData, defaultChec
|
|
25
25
|
var _useState = React.useState([]),
|
26
26
|
checkedNodes = _useState[0],
|
27
27
|
setCheckedNodes = _useState[1];
|
28
|
+
var flattedDataMap = React.useMemo(function () {
|
29
|
+
return new Map(flattedData.map(function (item) {
|
30
|
+
return [item.id, item];
|
31
|
+
}));
|
32
|
+
}, [flattedData]);
|
28
33
|
var _useUncontrolledState = useUncontrolledState.useUncontrolledState(defaultCheckedIds, checkedIdsProp, function (checkedIds, checkedNode, checked, semiCheckedIds) {
|
34
|
+
var checkedIdsSet = new Set(checkedIds);
|
29
35
|
var nextCheckedNodes = flattedData.filter(function (item) {
|
30
|
-
return
|
36
|
+
return checkedIdsSet.has(item.id);
|
31
37
|
});
|
32
38
|
setCheckedNodes(nextCheckedNodes);
|
33
39
|
onCheck === null || onCheck === void 0 ? void 0 : onCheck(checkedIds, {
|
@@ -61,13 +67,11 @@ var useCheck = function useCheck(checkedMode, disabled, flattedData, defaultChec
|
|
61
67
|
onNodeCheck = _useCascadeCheck[0];
|
62
68
|
var proxyOnNodeCheck = React.useCallback(function (target, shouldChecked) {
|
63
69
|
// 保证 target 来源于原数据自身,而不是tree内部
|
64
|
-
var targetNode =
|
65
|
-
return item.id === target.id;
|
66
|
-
});
|
70
|
+
var targetNode = flattedDataMap.get(target.id);
|
67
71
|
if (targetNode) {
|
68
72
|
onNodeCheck(targetNode, shouldChecked);
|
69
73
|
}
|
70
|
-
}, [
|
74
|
+
}, [flattedDataMap, onNodeCheck]);
|
71
75
|
return [checkedIds, trySetCheckedIds, proxyOnNodeCheck, checkedNodes, parsedCheckedIds];
|
72
76
|
};
|
73
77
|
var allowCheck = function allowCheck(targetItem) {
|
package/lib/cjs/utils/index.js
CHANGED
@@ -24,10 +24,13 @@ var typeAssertion = require('@hi-ui/type-assertion');
|
|
24
24
|
*/
|
25
25
|
var processCheckedIds = function processCheckedIds(type, checkedIds, flattenData, allowCheck) {
|
26
26
|
var keySet = new Set(checkedIds);
|
27
|
+
var flattedDataMap = new Map(flattenData.map(function (item) {
|
28
|
+
return [item.id, item];
|
29
|
+
}));
|
27
30
|
switch (type) {
|
28
31
|
case 'CHILD':
|
29
32
|
return checkedIds.filter(function (id) {
|
30
|
-
var node =
|
33
|
+
var node = flattedDataMap.get(id);
|
31
34
|
if (node) {
|
32
35
|
var children = node.children;
|
33
36
|
if (typeAssertion.isArrayNonEmpty(children)) {
|
@@ -43,7 +46,7 @@ var processCheckedIds = function processCheckedIds(type, checkedIds, flattenData
|
|
43
46
|
});
|
44
47
|
case 'PARENT':
|
45
48
|
return checkedIds.filter(function (id) {
|
46
|
-
var node =
|
49
|
+
var node = flattedDataMap.get(id);
|
47
50
|
if (node) {
|
48
51
|
// 向上递归遍历是否被勾选
|
49
52
|
var ancestors = treeUtils.getNodeAncestors(node);
|
@@ -66,6 +66,7 @@ var CheckTreeSelect = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
66
66
|
onLoadChildren = _a.onLoadChildren,
|
67
67
|
titleRender = _a.render,
|
68
68
|
filterOption = _a.filterOption,
|
69
|
+
keywordProp = _a.keyword,
|
69
70
|
onSearchProp = _a.onSearch,
|
70
71
|
clearable = _a.clearable,
|
71
72
|
invalid = _a.invalid,
|
@@ -84,8 +85,7 @@ var CheckTreeSelect = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
84
85
|
customRender = _a.customRender,
|
85
86
|
prefix = _a.prefix,
|
86
87
|
suffix = _a.suffix,
|
87
|
-
|
88
|
-
rest = __rest(_a, ["prefixCls", "role", "className", "data", "dataSource", "disabled", "visible", "onOpen", "onClose", "fieldNames", "checkedMode", "defaultExpandAll", "expandedIds", "defaultExpandedIds", "onExpand", "defaultValue", "value", "onChange", "searchable", "searchMode", "onLoadChildren", "render", "filterOption", "onSearch", "clearable", "invalid", "displayRender", "placeholder", "appearance", "virtual", "itemHeight", "height", "showCheckAll", "showOnlyShowChecked", "tagInputProps", "size", "customRender", "prefix", "suffix", "keyword"]);
|
88
|
+
rest = __rest(_a, ["prefixCls", "role", "className", "data", "dataSource", "disabled", "visible", "onOpen", "onClose", "fieldNames", "checkedMode", "defaultExpandAll", "expandedIds", "defaultExpandedIds", "onExpand", "defaultValue", "value", "onChange", "searchable", "searchMode", "onLoadChildren", "render", "filterOption", "keyword", "onSearch", "clearable", "invalid", "displayRender", "placeholder", "appearance", "virtual", "itemHeight", "height", "showCheckAll", "showOnlyShowChecked", "tagInputProps", "size", "customRender", "prefix", "suffix"]);
|
89
89
|
var i18n = useLocaleContext();
|
90
90
|
var placeholder = isUndef(placeholderProp) ? i18n.get('checkTreeSelect.placeholder') : placeholderProp;
|
91
91
|
var _useUncontrolledToggl = useUncontrolledToggle({
|
@@ -20,9 +20,15 @@ var useCheck = function useCheck(checkedMode, disabled, flattedData, defaultChec
|
|
20
20
|
var _useState = useState([]),
|
21
21
|
checkedNodes = _useState[0],
|
22
22
|
setCheckedNodes = _useState[1];
|
23
|
+
var flattedDataMap = useMemo(function () {
|
24
|
+
return new Map(flattedData.map(function (item) {
|
25
|
+
return [item.id, item];
|
26
|
+
}));
|
27
|
+
}, [flattedData]);
|
23
28
|
var _useUncontrolledState = useUncontrolledState(defaultCheckedIds, checkedIdsProp, function (checkedIds, checkedNode, checked, semiCheckedIds) {
|
29
|
+
var checkedIdsSet = new Set(checkedIds);
|
24
30
|
var nextCheckedNodes = flattedData.filter(function (item) {
|
25
|
-
return
|
31
|
+
return checkedIdsSet.has(item.id);
|
26
32
|
});
|
27
33
|
setCheckedNodes(nextCheckedNodes);
|
28
34
|
onCheck === null || onCheck === void 0 ? void 0 : onCheck(checkedIds, {
|
@@ -56,13 +62,11 @@ var useCheck = function useCheck(checkedMode, disabled, flattedData, defaultChec
|
|
56
62
|
onNodeCheck = _useCascadeCheck[0];
|
57
63
|
var proxyOnNodeCheck = useCallback(function (target, shouldChecked) {
|
58
64
|
// 保证 target 来源于原数据自身,而不是tree内部
|
59
|
-
var targetNode =
|
60
|
-
return item.id === target.id;
|
61
|
-
});
|
65
|
+
var targetNode = flattedDataMap.get(target.id);
|
62
66
|
if (targetNode) {
|
63
67
|
onNodeCheck(targetNode, shouldChecked);
|
64
68
|
}
|
65
|
-
}, [
|
69
|
+
}, [flattedDataMap, onNodeCheck]);
|
66
70
|
return [checkedIds, trySetCheckedIds, proxyOnNodeCheck, checkedNodes, parsedCheckedIds];
|
67
71
|
};
|
68
72
|
var allowCheck = function allowCheck(targetItem) {
|
package/lib/esm/utils/index.js
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
9
9
|
*/
|
10
|
-
import {
|
10
|
+
import { getNodeAncestors, findNestedChildren } from '@hi-ui/tree-utils';
|
11
11
|
import { isArrayNonEmpty } from '@hi-ui/type-assertion';
|
12
12
|
|
13
13
|
/**
|
@@ -19,10 +19,13 @@ import { isArrayNonEmpty } from '@hi-ui/type-assertion';
|
|
19
19
|
*/
|
20
20
|
var processCheckedIds = function processCheckedIds(type, checkedIds, flattenData, allowCheck) {
|
21
21
|
var keySet = new Set(checkedIds);
|
22
|
+
var flattedDataMap = new Map(flattenData.map(function (item) {
|
23
|
+
return [item.id, item];
|
24
|
+
}));
|
22
25
|
switch (type) {
|
23
26
|
case 'CHILD':
|
24
27
|
return checkedIds.filter(function (id) {
|
25
|
-
var node =
|
28
|
+
var node = flattedDataMap.get(id);
|
26
29
|
if (node) {
|
27
30
|
var children = node.children;
|
28
31
|
if (isArrayNonEmpty(children)) {
|
@@ -38,7 +41,7 @@ var processCheckedIds = function processCheckedIds(type, checkedIds, flattenData
|
|
38
41
|
});
|
39
42
|
case 'PARENT':
|
40
43
|
return checkedIds.filter(function (id) {
|
41
|
-
var node =
|
44
|
+
var node = flattedDataMap.get(id);
|
42
45
|
if (node) {
|
43
46
|
// 向上递归遍历是否被勾选
|
44
47
|
var ancestors = getNodeAncestors(node);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@hi-ui/check-tree-select",
|
3
|
-
"version": "4.6.
|
3
|
+
"version": "4.6.2",
|
4
4
|
"description": "A sub-package for @hi-ui/hiui.",
|
5
5
|
"keywords": [],
|
6
6
|
"author": "HiUI <mi-hiui@xiaomi.com>",
|
@@ -48,12 +48,12 @@
|
|
48
48
|
"@hi-ui/classname": "^4.0.5",
|
49
49
|
"@hi-ui/env": "^4.0.5",
|
50
50
|
"@hi-ui/func-utils": "^4.0.4",
|
51
|
-
"@hi-ui/highlighter": "^4.0
|
51
|
+
"@hi-ui/highlighter": "^4.1.0",
|
52
52
|
"@hi-ui/icons": "^4.0.19",
|
53
53
|
"@hi-ui/picker": "^4.1.6",
|
54
54
|
"@hi-ui/popper": "^4.1.5",
|
55
|
-
"@hi-ui/tag-input": "^4.1.
|
56
|
-
"@hi-ui/tree": "^4.6.
|
55
|
+
"@hi-ui/tag-input": "^4.1.3",
|
56
|
+
"@hi-ui/tree": "^4.6.1",
|
57
57
|
"@hi-ui/tree-utils": "^4.1.6",
|
58
58
|
"@hi-ui/type-assertion": "^4.0.4",
|
59
59
|
"@hi-ui/use-check": "^4.0.5",
|