@hi-ui/check-cascader 4.2.1 → 4.2.3

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.
@@ -20,72 +20,65 @@ import { useSelect } from './hooks/use-select.js';
20
20
  import { useAsyncSwitch } from './hooks/use-async-switch.js';
21
21
  import { isFunction } from '@hi-ui/type-assertion';
22
22
  var _role = 'check-cascader-menus';
23
-
24
23
  var _prefix = getPrefixCls(_role);
25
-
26
24
  var NOOP_ARRAY = [];
27
25
  var CheckCascaderMenuList = /*#__PURE__*/forwardRef(function (_a, ref) {
28
26
  var _a$prefixCls = _a.prefixCls,
29
- prefixCls = _a$prefixCls === void 0 ? _prefix : _a$prefixCls,
30
- _a$role = _a.role,
31
- role = _a$role === void 0 ? _role : _a$role,
32
- className = _a.className,
33
- flattedData = _a.flattedData,
34
- onChangeData = _a.onChangeData,
35
- valueProp = _a.value,
36
- _a$defaultValue = _a.defaultValue,
37
- defaultValue = _a$defaultValue === void 0 ? NOOP_ARRAY : _a$defaultValue,
38
- _a$disabled = _a.disabled,
39
- disabled = _a$disabled === void 0 ? false : _a$disabled,
40
- _a$expandTrigger = _a.expandTrigger,
41
- expandTrigger = _a$expandTrigger === void 0 ? 'click' : _a$expandTrigger,
42
- _a$changeOnSelect = _a.changeOnSelect,
43
- changeOnSelect = _a$changeOnSelect === void 0 ? false : _a$changeOnSelect,
44
- _a$checkCascaded = _a.checkCascaded,
45
- checkCascaded = _a$checkCascaded === void 0 ? true : _a$checkCascaded,
46
- onLoadChildren = _a.onLoadChildren,
47
- onChange = _a.onChange,
48
- titleRender = _a.titleRender,
49
- dropdownColumnRender = _a.dropdownColumnRender,
50
- flatted = _a.flatted,
51
- _a$checkedMode = _a.checkedMode,
52
- checkedMode = _a$checkedMode === void 0 ? 'ALL' : _a$checkedMode,
53
- rest = __rest(_a, ["prefixCls", "role", "className", "children", "data", "flattedData", "onChangeData", "value", "defaultValue", "disabled", "expandTrigger", "changeOnSelect", "checkCascaded", "onLoadChildren", "onChange", "onSelect", "titleRender", "dropdownColumnRender", "flatted", "checkedMode"]);
54
-
27
+ prefixCls = _a$prefixCls === void 0 ? _prefix : _a$prefixCls,
28
+ _a$role = _a.role,
29
+ role = _a$role === void 0 ? _role : _a$role,
30
+ className = _a.className,
31
+ flattedData = _a.flattedData,
32
+ onChangeData = _a.onChangeData,
33
+ valueProp = _a.value,
34
+ _a$defaultValue = _a.defaultValue,
35
+ defaultValue = _a$defaultValue === void 0 ? NOOP_ARRAY : _a$defaultValue,
36
+ _a$disabled = _a.disabled,
37
+ disabled = _a$disabled === void 0 ? false : _a$disabled,
38
+ _a$expandTrigger = _a.expandTrigger,
39
+ expandTrigger = _a$expandTrigger === void 0 ? 'click' : _a$expandTrigger,
40
+ _a$changeOnSelect = _a.changeOnSelect,
41
+ changeOnSelect = _a$changeOnSelect === void 0 ? false : _a$changeOnSelect,
42
+ _a$checkCascaded = _a.checkCascaded,
43
+ checkCascaded = _a$checkCascaded === void 0 ? true : _a$checkCascaded,
44
+ onLoadChildren = _a.onLoadChildren,
45
+ onChange = _a.onChange,
46
+ titleRender = _a.titleRender,
47
+ dropdownColumnRender = _a.dropdownColumnRender,
48
+ flatted = _a.flatted,
49
+ _a$checkedMode = _a.checkedMode,
50
+ checkedMode = _a$checkedMode === void 0 ? 'ALL' : _a$checkedMode,
51
+ rest = __rest(_a, ["prefixCls", "role", "className", "children", "data", "flattedData", "onChangeData", "value", "defaultValue", "disabled", "expandTrigger", "changeOnSelect", "checkCascaded", "onLoadChildren", "onChange", "onSelect", "titleRender", "dropdownColumnRender", "flatted", "checkedMode"]);
55
52
  if (checkCascaded === false) {
56
53
  checkedMode = 'SEPARATE';
57
54
  }
58
-
59
55
  var _useSelect = useSelect(disabled),
60
- selectedId = _useSelect[0],
61
- onOptionSelect = _useSelect[1];
62
-
56
+ selectedId = _useSelect[0],
57
+ onOptionSelect = _useSelect[1];
63
58
  var selectedIds = getActiveMenuIds(flattedData, selectedId);
64
-
65
59
  var _useAsyncSwitch = useAsyncSwitch(onChangeData, onOptionSelect, onLoadChildren),
66
- isLoadingId = _useAsyncSwitch[0],
67
- onItemExpand = _useAsyncSwitch[1];
68
-
60
+ isLoadingId = _useAsyncSwitch[0],
61
+ onItemExpand = _useAsyncSwitch[1];
69
62
  var _useCheck = useCheck(checkedMode, disabled, flattedData, defaultValue, valueProp, function (_ref, target, shouldChecked) {
70
- var checkedIds = _ref.checkedIds; // @ts-ignore
71
-
72
- onChange === null || onChange === void 0 ? void 0 : onChange(checkedIds, target, shouldChecked);
73
- }),
74
- onOptionCheck = _useCheck[0],
75
- isCheckedId = _useCheck[1],
76
- isSemiCheckedId = _useCheck[2];
77
-
63
+ var checkedIds = _ref.checkedIds;
64
+ // @ts-ignore
65
+ onChange === null || onChange === void 0 ? void 0 : onChange(checkedIds, target, shouldChecked);
66
+ }),
67
+ onOptionCheck = _useCheck[0],
68
+ isCheckedId = _useCheck[1],
69
+ isSemiCheckedId = _useCheck[2];
78
70
  var getCascaderItemRequiredProps = useLatestCallback(function (_ref2) {
79
71
  var id = _ref2.id,
80
- depth = _ref2.depth;
72
+ depth = _ref2.depth;
81
73
  return {
82
74
  selected: flatted ? selectedId === id : selectedIds[depth] === id,
83
75
  checked: isCheckedId(id),
84
76
  loading: isLoadingId(id),
85
- semiChecked: isSemiCheckedId(id) // focused: false,
86
-
77
+ semiChecked: isSemiCheckedId(id)
78
+ // focused: false,
87
79
  };
88
80
  });
81
+
89
82
  var providedValue = useMemo(function () {
90
83
  return {
91
84
  expandTrigger: expandTrigger,
@@ -115,9 +108,7 @@ var CheckCascaderMenuList = /*#__PURE__*/forwardRef(function (_a, ref) {
115
108
  return menu.length > 0 ? isFunction(dropdownColumnRender) ? dropdownColumnRender(menuContent, menuIndex) : menuContent : null;
116
109
  })));
117
110
  });
118
-
119
111
  if (__DEV__) {
120
112
  CheckCascaderMenuList.displayName = 'CheckCascaderMenuList';
121
113
  }
122
-
123
114
  export { CheckCascaderMenuList };
@@ -10,15 +10,11 @@
10
10
  import { createContext, useContext } from 'react';
11
11
  var checkCascaderContext = /*#__PURE__*/createContext({});
12
12
  var CheckCascaderProvider = checkCascaderContext.Provider;
13
-
14
13
  var useCheckCascaderContext = function useCheckCascaderContext() {
15
14
  var context = useContext(checkCascaderContext);
16
-
17
15
  if (!context) {
18
16
  throw new Error('The checkCascaderContext context should using in CheckCascader.');
19
17
  }
20
-
21
18
  return context;
22
19
  };
23
-
24
20
  export { CheckCascaderProvider, useCheckCascaderContext };
@@ -12,14 +12,12 @@ import { __awaiter } from 'tslib';
12
12
  import { useCallback, useState } from 'react';
13
13
  import { useLatestCallback } from '@hi-ui/use-latest';
14
14
  import { cloneTree, addChildrenById, getTopDownAncestors } from '@hi-ui/tree-utils';
15
-
16
15
  var useAsyncSwitch = function useAsyncSwitch(setCascaderData, onExpand, onLoadChildren) {
17
16
  var _useList = useList(),
18
- loadingIds = _useList[0],
19
- addLoadingIds = _useList[1],
20
- removeLoadingIds = _useList[2]; // 加载节点
21
-
22
-
17
+ loadingIds = _useList[0],
18
+ addLoadingIds = _useList[1],
19
+ removeLoadingIds = _useList[2];
20
+ // 加载节点
23
21
  var loadChildren = useCallback(function (node) {
24
22
  return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
25
23
  var childrenNodes;
@@ -31,19 +29,15 @@ var useAsyncSwitch = function useAsyncSwitch(setCascaderData, onExpand, onLoadCh
31
29
  _context.next = 2;
32
30
  break;
33
31
  }
34
-
35
32
  return _context.abrupt("return");
36
-
37
33
  case 2:
38
34
  _context.next = 4;
39
35
  return onLoadChildren(node, getTopDownAncestors(node).map(function (_ref) {
40
36
  var id = _ref.id;
41
37
  return id;
42
38
  }));
43
-
44
39
  case 4:
45
40
  childrenNodes = _context.sent;
46
-
47
41
  if (Array.isArray(childrenNodes)) {
48
42
  setCascaderData(function (prev) {
49
43
  var nextTreeData = cloneTree(prev);
@@ -51,7 +45,6 @@ var useAsyncSwitch = function useAsyncSwitch(setCascaderData, onExpand, onLoadCh
51
45
  return nextTreeData;
52
46
  });
53
47
  }
54
-
55
48
  case 6:
56
49
  case "end":
57
50
  return _context.stop();
@@ -70,43 +63,34 @@ var useAsyncSwitch = function useAsyncSwitch(setCascaderData, onExpand, onLoadCh
70
63
  case 0:
71
64
  id = node.id, children = node.children, isLeaf = node.isLeaf;
72
65
  onExpandLatest(node);
73
-
74
66
  if (!children) {
75
67
  _context2.next = 4;
76
68
  break;
77
69
  }
78
-
79
70
  return _context2.abrupt("return");
80
-
81
71
  case 4:
82
72
  if (!isLeaf) {
83
73
  _context2.next = 6;
84
74
  break;
85
75
  }
86
-
87
76
  return _context2.abrupt("return");
88
-
89
77
  case 6:
90
78
  if (!onLoadChildren) {
91
79
  _context2.next = 17;
92
80
  break;
93
81
  }
94
-
95
82
  addLoadingIds(id);
96
83
  _context2.prev = 8;
97
84
  _context2.next = 11;
98
85
  return loadChildren(node);
99
-
100
86
  case 11:
101
87
  removeLoadingIds(id);
102
88
  _context2.next = 17;
103
89
  break;
104
-
105
90
  case 14:
106
91
  _context2.prev = 14;
107
92
  _context2.t0 = _context2["catch"](8);
108
93
  removeLoadingIds(id);
109
-
110
94
  case 17:
111
95
  case "end":
112
96
  return _context2.stop();
@@ -115,23 +99,18 @@ var useAsyncSwitch = function useAsyncSwitch(setCascaderData, onExpand, onLoadCh
115
99
  }, _callee2, null, [[8, 14]]);
116
100
  }));
117
101
  }, [loadChildren, onLoadChildren, onExpandLatest, addLoadingIds, removeLoadingIds]);
118
-
119
102
  var isLoadingId = function isLoadingId(id) {
120
103
  return loadingIds.indexOf(id) !== -1;
121
104
  };
122
-
123
105
  return [isLoadingId, onNodeSwitch];
124
106
  };
125
-
126
107
  var useList = function useList(initialValue) {
127
108
  if (initialValue === void 0) {
128
109
  initialValue = [];
129
110
  }
130
-
131
111
  var _useState = useState(initialValue),
132
- keyList = _useState[0],
133
- setKeyList = _useState[1];
134
-
112
+ keyList = _useState[0],
113
+ setKeyList = _useState[1];
135
114
  var remove = useCallback(function (targetKey) {
136
115
  setKeyList(function (prev) {
137
116
  return prev.filter(function (key) {
@@ -146,5 +125,4 @@ var useList = function useList(initialValue) {
146
125
  }, []);
147
126
  return [keyList, add, remove];
148
127
  };
149
-
150
128
  export { useAsyncSwitch };
@@ -8,6 +8,7 @@
8
8
  * LICENSE file in the root directory of this source tree.
9
9
  */
10
10
  import { useState, useEffect } from 'react';
11
+
11
12
  /** @LICENSE
12
13
  * @hi-ui/use-cache
13
14
  * https://github.com/XiaoMi/hiui/tree/master/packages/hooks/use-cache#readme
@@ -21,16 +22,13 @@ import { useState, useEffect } from 'react';
21
22
  /**
22
23
  * A hook using for data cache that compatible with the controlled and uncontrolled modes coexist.
23
24
  */
24
-
25
25
  var useCache = function useCache(data) {
26
26
  var _useState = useState(data),
27
- internalData = _useState[0],
28
- setInternalData = _useState[1];
29
-
27
+ internalData = _useState[0],
28
+ setInternalData = _useState[1];
30
29
  useEffect(function () {
31
30
  setInternalData(data);
32
31
  }, [data]);
33
32
  return [internalData, setInternalData];
34
33
  };
35
-
36
34
  export { useCache };
@@ -9,25 +9,22 @@
9
9
  */
10
10
  import { useUncontrolledState } from '@hi-ui/use-uncontrolled-state';
11
11
  import { useCascadeCheck } from '@hi-ui/use-check';
12
- import { processCheckedIds, parseCheckDataDirty } from '../utils/index.js';
12
+ import { parseCheckDataDirty, processCheckedIds } from '../utils/index.js';
13
13
  var NOOP_ARRAY = [];
14
-
15
14
  var useCheck = function useCheck(checkedMode, disabled, flattedData, defaultCheckedIds, checkedIdsProp, onCheck) {
16
15
  if (defaultCheckedIds === void 0) {
17
16
  defaultCheckedIds = NOOP_ARRAY;
18
17
  }
19
-
20
18
  var _useUncontrolledState = useUncontrolledState(defaultCheckedIds, checkedIdsProp, function (checkedIds, checkedNode, shouldChecked, semiCheckedIds) {
21
- // 出口数据处理
22
- onCheck === null || onCheck === void 0 ? void 0 : onCheck({
23
- checkedIds: checkedIds,
24
- semiCheckedIds: semiCheckedIds
25
- }, checkedNode, shouldChecked);
26
- }),
27
- checkedIds = _useUncontrolledState[0],
28
- trySetCheckedIds = _useUncontrolledState[1]; // 入口数据处理
29
-
30
-
19
+ // 出口数据处理
20
+ onCheck === null || onCheck === void 0 ? void 0 : onCheck({
21
+ checkedIds: checkedIds,
22
+ semiCheckedIds: semiCheckedIds
23
+ }, checkedNode, shouldChecked);
24
+ }),
25
+ checkedIds = _useUncontrolledState[0],
26
+ trySetCheckedIds = _useUncontrolledState[1];
27
+ // 入口数据处理
31
28
  var parsedCheckedIds = parseCheckDataDirty(checkedMode, checkedIds, flattedData, allowCheck);
32
29
  var cascaded = checkedMode !== 'SEPARATE';
33
30
  return useCascadeCheck({
@@ -43,13 +40,10 @@ var useCheck = function useCheck(checkedMode, disabled, flattedData, defaultChec
43
40
  allowCheck: allowCheck
44
41
  });
45
42
  };
46
-
47
43
  var allowCheck = function allowCheck(targetItem) {
48
44
  if (targetItem.disabled || targetItem.disabledCheckbox || targetItem.checkable === false) {
49
45
  return false;
50
46
  }
51
-
52
47
  return true;
53
48
  };
54
-
55
49
  export { useCheck };
@@ -8,23 +8,21 @@
8
8
  * LICENSE file in the root directory of this source tree.
9
9
  */
10
10
  import { useState, useCallback } from 'react';
11
+
11
12
  /**
12
13
  * 用于选中的 hook
13
14
  *
14
15
  * @param disabled
15
16
  * @returns
16
17
  */
17
-
18
18
  var useSelect = function useSelect(disabled) {
19
19
  var _useState = useState(),
20
- selectedId = _useState[0],
21
- setSelectedId = _useState[1];
22
-
20
+ selectedId = _useState[0],
21
+ setSelectedId = _useState[1];
23
22
  var onOptionSelect = useCallback(function (selectedOption) {
24
23
  if (disabled || selectedOption.disabled) return;
25
24
  setSelectedId(selectedOption.id);
26
25
  }, [disabled]);
27
26
  return [selectedId, onOptionSelect];
28
27
  };
29
-
30
28
  export { useSelect };
@@ -8,8 +8,6 @@
8
8
  * LICENSE file in the root directory of this source tree.
9
9
  */
10
10
  import __styleInject__ from 'style-inject';
11
- var css_248z = "@charset \"UTF-8\";.hi-v4-check-cascader__popper .hi-v4-picker__body {padding-left: 0;padding-right: 0;overflow-y: hidden;}.hi-v4-check-cascader__popper .hi-v4-picker__loading, .hi-v4-check-cascader__popper .hi-v4-picker__empty {padding: var(--hi-v4-spacing-5, 10px) var(--hi-v4-spacing-8, 16px);}.hi-v4-check-cascader-panel {white-space: nowrap;-webkit-box-sizing: border-box;box-sizing: border-box;}.hi-v4-check-cascader-panel-search {-webkit-box-sizing: border-box;box-sizing: border-box;padding: 0 10px 10px;position: relative;}.hi-v4-check-cascader-panel-search .hi-v4-input__prefix {font-size: 16px;padding-left: 0;}.hi-v4-check-cascader-panel-search__empty {display: inline-block;margin-top: 20px;font-size: 14px;font-weight: 400;color: #999;line-height: 20px;}.hi-v4-check-cascader-menus {display: -webkit-box;display: -ms-flexbox;display: flex;-webkit-box-sizing: border-box;box-sizing: border-box;overflow-x: auto;}.hi-v4-check-cascader-menus--flatted .hi-v4-check-cascader-menu {-ms-flex-preferred-size: 100%;flex-basis: 100%;}.hi-v4-check-cascader-menu {-webkit-box-sizing: border-box;box-sizing: border-box;margin: 0;padding: 0;border: none;outline: none;font-size: var(--hi-v4-text-size-md, 0.875rem);vertical-align: middle;list-style: none;width: auto;box-sizing: border-box;-ms-flex-negative: 0;flex-shrink: 0;display: inline-block;min-width: 140px;max-height: 256px;overflow: auto;padding: 0 var(--hi-v4-spacing-4, 8px);border-right: var(--hi-v4-border-size-normal, 1px solid) var(--hi-v4-color-gray-200, #ebedf0);}.hi-v4-check-cascader-menu:last-of-type {border: none;}.hi-v4-check-cascader-menu--checkable .hi-v4-check-cascader-menu-checkbox + .title__text {padding-left: 8px;}.hi-v4-check-cascader-menu-item {width: 100%;position: relative;cursor: pointer;display: -webkit-box;display: -ms-flexbox;display: flex;}.hi-v4-check-cascader-menu-checkbox {position: relative;}.hi-v4-check-cascader-menu-checkbox::after {right: 0;top: -8px;bottom: -8px;left: -8px;content: \"\";position: absolute;display: block;}.hi-v4-check-cascader-menu-option {padding: var(--hi-v4-spacing-1, 2px) var(--hi-v4-spacing-3, 6px);-webkit-box-sizing: border-box;box-sizing: border-box;height: var(--hi-v4-height-8, 32px);width: 100%;display: -webkit-box;display: -ms-flexbox;display: flex;-webkit-box-align: center;-ms-flex-align: center;align-items: center;position: relative;-webkit-box-pack: justify;-ms-flex-pack: justify;justify-content: space-between;border-radius: var(--hi-v4-border-radius-md, 4px);}.hi-v4-check-cascader-menu-option:hover {background-color: var(--hi-v4-color-gray-100, #f2f4f7);}.hi-v4-check-cascader-menus--selectchange .hi-v4-check-cascader-menu-option:hover .hi-v4-checkbox__icon {border-color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));}.hi-v4-check-cascader-menu-option.hi-v4-check-cascader-menu-option--selected {background: var(--hi-v4-color-primary-50, var(--hi-v4-color-brandblue-50, #e2f3fe));color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));}.hi-v4-check-cascader-menu-option.hi-v4-check-cascader-menu-option--selected .hi-v4-check-cascader-menu-switcher {color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));}.hi-v4-check-cascader-menu-option--focused {background-color: var(--hi-v4-color-primary-50, var(--hi-v4-color-brandblue-50, #e2f3fe));}.hi-v4-check-cascader-menu-option--disabled {cursor: not-allowed;color: var(--hi-v4-color-gray-500, #929aa6);background: transparent;}.hi-v4-check-cascader-menu-option--disabled .hi-v4-check-cascader-menu-switcher {color: var(--hi-v4-color-gray-400, #c9ced6);}.hi-v4-check-cascader-menu .title__text {-webkit-box-flex: 1;-ms-flex: 1 1;flex: 1 1;}.hi-v4-check-cascader-menu .title__text--cols {display: block;width: 100%;-webkit-box-sizing: border-box;box-sizing: border-box;margin: 0;padding: 0;border: none;outline: none;font-size: var(--hi-v4-text-size-md, 0.875rem);vertical-align: middle;list-style: none;}.hi-v4-check-cascader-menu .title__text--col {display: inline-block;}.hi-v4-check-cascader-menu .title__text--col::after {content: \" / \";}.hi-v4-check-cascader-menu .title__text--col:last-child::after {content: none;}.hi-v4-check-cascader-menu .title__text--matched {color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));}.hi-v4-check-cascader-menu-switcher {-ms-flex-negative: 0;flex-shrink: 0;font-size: 16px;color: var(--hi-v4-color-gray-500, #929aa6);}.hi-v4-check-cascader-menu-switcher--loading {color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));}.hi-v4-tree--icon-loading {-webkit-animation-name: hi-rotate;animation-name: hi-rotate;-webkit-animation-duration: 2s;animation-duration: 2s;-webkit-animation-iteration-count: infinite;animation-iteration-count: infinite;}@-webkit-keyframes hi-rotate {from {-webkit-transform: rotate(0);transform: rotate(0);}to {-webkit-transform: rotate(360deg);transform: rotate(360deg);}}@keyframes hi-rotate {from {-webkit-transform: rotate(0);transform: rotate(0);}to {-webkit-transform: rotate(360deg);transform: rotate(360deg);}}";
12
-
11
+ var css_248z = "@charset \"UTF-8\";.hi-v4-check-cascader__popper .hi-v4-picker__body {padding-left: 0;padding-right: 0;overflow-y: hidden;}.hi-v4-check-cascader__popper .hi-v4-picker__loading, .hi-v4-check-cascader__popper .hi-v4-picker__empty {padding: var(--hi-v4-spacing-5, 10px) var(--hi-v4-spacing-8, 16px);}.hi-v4-check-cascader-panel {white-space: nowrap;-webkit-box-sizing: border-box;box-sizing: border-box;}.hi-v4-check-cascader-panel-search {-webkit-box-sizing: border-box;box-sizing: border-box;padding: 0 10px 10px;position: relative;}.hi-v4-check-cascader-panel-search .hi-v4-input__prefix {font-size: 16px;padding-left: 0;}.hi-v4-check-cascader-panel-search__empty {display: inline-block;margin-top: 20px;font-size: 14px;font-weight: 400;color: #999;line-height: 20px;}.hi-v4-check-cascader-menus {display: -webkit-box;display: -ms-flexbox;display: flex;-webkit-box-sizing: border-box;box-sizing: border-box;overflow-x: auto;}.hi-v4-check-cascader-menus--flatted .hi-v4-check-cascader-menu {-ms-flex-preferred-size: 100%;flex-basis: 100%;}.hi-v4-check-cascader-menu {-webkit-box-sizing: border-box;box-sizing: border-box;margin: 0;padding: 0;border: none;outline: none;font-size: var(--hi-v4-text-size-md, 0.875rem);vertical-align: middle;list-style: none;width: auto;box-sizing: border-box;-ms-flex-negative: 0;flex-shrink: 0;display: inline-block;min-width: 140px;max-height: 256px;overflow: auto;padding: 0 var(--hi-v4-spacing-4, 8px);border-right: var(--hi-v4-border-size-normal, 1px solid) var(--hi-v4-color-gray-200, #ebedf0);}.hi-v4-check-cascader-menu:last-of-type {border: none;}.hi-v4-check-cascader-menu--checkable .hi-v4-check-cascader-menu-checkbox + .title__text {padding-left: 8px;}.hi-v4-check-cascader-menu-item {width: 100%;position: relative;cursor: pointer;display: -webkit-box;display: -ms-flexbox;display: flex;}.hi-v4-check-cascader-menu-checkbox {position: relative;}.hi-v4-check-cascader-menu-checkbox::after {right: 0;top: -8px;bottom: -8px;left: -8px;content: \"\";position: absolute;display: block;}.hi-v4-check-cascader-menu-option {padding: var(--hi-v4-spacing-1, 2px) var(--hi-v4-spacing-3, 6px);-webkit-box-sizing: border-box;box-sizing: border-box;height: var(--hi-v4-height-8, 32px);width: 100%;display: -webkit-box;display: -ms-flexbox;display: flex;-webkit-box-align: center;-ms-flex-align: center;align-items: center;position: relative;-webkit-box-pack: justify;-ms-flex-pack: justify;justify-content: space-between;border-radius: var(--hi-v4-border-radius-md, 4px);}.hi-v4-check-cascader-menu-option:hover {background-color: var(--hi-v4-color-gray-100, #f2f4f7);}.hi-v4-check-cascader-menus--selectchange .hi-v4-check-cascader-menu-option:hover .hi-v4-checkbox__icon {border-color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));}.hi-v4-check-cascader-menu-option.hi-v4-check-cascader-menu-option--selected {background: var(--hi-v4-color-primary-50, var(--hi-v4-color-brandblue-50, #e2f3fe));color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));}.hi-v4-check-cascader-menu-option.hi-v4-check-cascader-menu-option--selected .hi-v4-check-cascader-menu-switcher {color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));}.hi-v4-check-cascader-menu-option--focused {background-color: var(--hi-v4-color-primary-50, var(--hi-v4-color-brandblue-50, #e2f3fe));}.hi-v4-check-cascader-menu-option--disabled {cursor: not-allowed;color: var(--hi-v4-color-gray-500, #929aa6);background: transparent;}.hi-v4-check-cascader-menu-option--disabled .hi-v4-check-cascader-menu-switcher {color: var(--hi-v4-color-gray-400, #b5bcc7);}.hi-v4-check-cascader-menu .title__text {-webkit-box-flex: 1;-ms-flex: 1 1;flex: 1 1;}.hi-v4-check-cascader-menu .title__text--cols {display: block;width: 100%;-webkit-box-sizing: border-box;box-sizing: border-box;margin: 0;padding: 0;border: none;outline: none;font-size: var(--hi-v4-text-size-md, 0.875rem);vertical-align: middle;list-style: none;}.hi-v4-check-cascader-menu .title__text--col {display: inline-block;}.hi-v4-check-cascader-menu .title__text--col::after {content: \" / \";}.hi-v4-check-cascader-menu .title__text--col:last-child::after {content: none;}.hi-v4-check-cascader-menu .title__text--matched {color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));}.hi-v4-check-cascader-menu-switcher {-ms-flex-negative: 0;flex-shrink: 0;font-size: 16px;color: var(--hi-v4-color-gray-500, #929aa6);}.hi-v4-check-cascader-menu-switcher--loading {color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));}.hi-v4-tree--icon-loading {-webkit-animation-name: hi-rotate;animation-name: hi-rotate;-webkit-animation-duration: 2s;animation-duration: 2s;-webkit-animation-iteration-count: infinite;animation-iteration-count: infinite;}@-webkit-keyframes hi-rotate {from {-webkit-transform: rotate(0);transform: rotate(0);}to {-webkit-transform: rotate(360deg);transform: rotate(360deg);}}@keyframes hi-rotate {from {-webkit-transform: rotate(0);transform: rotate(0);}to {-webkit-transform: rotate(360deg);transform: rotate(360deg);}}";
13
12
  __styleInject__(css_248z);
14
-
15
13
  export { css_248z as default };
@@ -9,13 +9,13 @@
9
9
  */
10
10
  import { baseFlattenTree, getTopDownAncestors, fFindNodeById, getNodeAncestors, findNestedChildren } from '@hi-ui/tree-utils';
11
11
  import { isArrayNonEmpty } from '@hi-ui/type-assertion';
12
+
12
13
  /**
13
14
  * 扁平化树数据结构,基于前序遍历
14
15
  *
15
16
  * @param treeData
16
17
  * @returns
17
18
  */
18
-
19
19
  var flattenTreeData = function flattenTreeData(treeData, fieldNames) {
20
20
  /**
21
21
  * 转换对象
@@ -24,10 +24,8 @@ var flattenTreeData = function flattenTreeData(treeData, fieldNames) {
24
24
  if (fieldNames) {
25
25
  return node[fieldNames[key] || key];
26
26
  }
27
-
28
27
  return node[key];
29
28
  };
30
-
31
29
  return baseFlattenTree({
32
30
  tree: treeData,
33
31
  childrenFieldName: function childrenFieldName(node) {
@@ -35,7 +33,6 @@ var flattenTreeData = function flattenTreeData(treeData, fieldNames) {
35
33
  },
36
34
  transform: function transform(node) {
37
35
  var _a, _b, _c, _d;
38
-
39
36
  var flattedNode = node;
40
37
  var raw = node.raw;
41
38
  flattedNode.id = getKeyFields(raw, 'id');
@@ -48,7 +45,6 @@ var flattenTreeData = function flattenTreeData(treeData, fieldNames) {
48
45
  }
49
46
  });
50
47
  };
51
-
52
48
  var getActiveMenus = function getActiveMenus(data, selectedIds) {
53
49
  if (data.length === 0) return [];
54
50
  var root = data[0].parent;
@@ -59,28 +55,23 @@ var getActiveMenus = function getActiveMenus(data, selectedIds) {
59
55
  return selectedIds === id;
60
56
  });
61
57
  if (!selectedOption) return menu;
62
-
63
58
  if (selectedOption.children) {
64
59
  menu = [selectedOption.children];
65
60
  } else {
66
61
  menu = [];
67
62
  }
68
-
69
63
  while (selectedOption.parent) {
70
64
  menu.push(selectedOption.parent.children);
71
65
  selectedOption = selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.parent;
72
66
  }
73
-
74
67
  return menu.reverse();
75
68
  };
76
-
77
69
  var getFlattedMenus = function getFlattedMenus(data) {
78
70
  return [data.filter(function (_ref2) {
79
71
  var checkable = _ref2.checkable;
80
72
  return checkable;
81
73
  })];
82
74
  };
83
-
84
75
  var getActiveMenuIds = function getActiveMenuIds(data, selectedIds) {
85
76
  if (data.length === 0) return [];
86
77
  var selectedOption = data.find(function (_ref3) {
@@ -93,7 +84,6 @@ var getActiveMenuIds = function getActiveMenuIds(data, selectedIds) {
93
84
  return id;
94
85
  });
95
86
  };
96
-
97
87
  function getCascaderItemEventData(node, requiredProps) {
98
88
  return Object.assign(Object.assign({}, node), requiredProps);
99
89
  }
@@ -104,19 +94,14 @@ function getCascaderItemEventData(node, requiredProps) {
104
94
  * @param nodeEntries 所有数据的Map 集合
105
95
  * @param type 数据回显方式
106
96
  */
107
-
108
-
109
97
  var processCheckedIds = function processCheckedIds(type, checkedIds, flattenData, allowCheck) {
110
98
  var keySet = new Set(checkedIds);
111
-
112
99
  switch (type) {
113
100
  case 'CHILD':
114
101
  return checkedIds.filter(function (id) {
115
102
  var node = fFindNodeById(flattenData, id);
116
-
117
103
  if (node) {
118
104
  var children = node.children;
119
-
120
105
  if (isArrayNonEmpty(children)) {
121
106
  if (children.filter(allowCheck).every(function (node) {
122
107
  return keySet.has(node.id);
@@ -124,48 +109,38 @@ var processCheckedIds = function processCheckedIds(type, checkedIds, flattenData
124
109
  return false;
125
110
  }
126
111
  }
127
- } // 没有孩子节点,保留
128
-
129
-
112
+ }
113
+ // 没有孩子节点,保留
130
114
  return true;
131
115
  });
132
-
133
116
  case 'PARENT':
134
117
  return checkedIds.filter(function (id) {
135
118
  var node = fFindNodeById(flattenData, id);
136
-
137
119
  if (node) {
138
120
  // 向上递归遍历是否被勾选
139
121
  var ancestors = getNodeAncestors(node);
140
-
141
122
  if (ancestors.some(function (parent) {
142
123
  return keySet.has(parent.id);
143
124
  })) {
144
125
  return false;
145
126
  }
146
127
  }
147
-
148
128
  return true;
149
129
  });
150
130
  }
151
-
152
131
  return checkedIds;
153
132
  };
154
133
  /**
155
134
  * 根据传入的 checkedIds 解析全选/半选数据
156
135
  */
157
-
158
-
159
136
  var parseCheckDataDirty = function parseCheckDataDirty(type, checkedIds, flattenData, allowCheck) {
160
137
  switch (type) {
161
138
  case 'CHILD':
162
139
  case 'PARENT':
163
140
  return dirtyCheck(checkedIds, flattenData, allowCheck);
164
141
  }
165
-
166
142
  return checkedIds;
167
143
  };
168
-
169
144
  function dirtyCheck(checkedIds, flattenData, allowCheck) {
170
145
  var nodeEntities = flattenData.reduce(function (prev, cur) {
171
146
  prev[cur.id] = cur;
@@ -175,18 +150,16 @@ function dirtyCheck(checkedIds, flattenData, allowCheck) {
175
150
  return !!nodeEntities[id];
176
151
  }));
177
152
  var depthEntities = new Map();
178
- var maxDepth = 0; // Convert entities by depth for calculation
179
-
153
+ var maxDepth = 0;
154
+ // Convert entities by depth for calculation
180
155
  Object.keys(nodeEntities).forEach(function (id) {
181
156
  var entity = nodeEntities[id];
182
157
  var depth = entity.depth;
183
158
  var depthSet = depthEntities.get(depth);
184
-
185
159
  if (!depthSet) {
186
160
  depthSet = new Set();
187
161
  depthEntities.set(depth, depthSet);
188
162
  }
189
-
190
163
  depthSet.add(entity);
191
164
  maxDepth = Math.max(maxDepth, depth);
192
165
  });
@@ -198,8 +171,6 @@ function dirtyCheck(checkedIds, flattenData, allowCheck) {
198
171
  * 1. 把所有嵌套孩子节点 allowCheck 的都标记为 checked
199
172
  * 2. 祖先节点从下至上维护 checked 状态
200
173
  */
201
-
202
-
203
174
  function fillCheck(checkedIds, depthEntities, nodeEntities, maxDepth, allowCheck) {
204
175
  var checkedIdsSet = new Set(checkedIds);
205
176
  checkedIdsSet.forEach(function (id) {
@@ -208,35 +179,29 @@ function fillCheck(checkedIds, depthEntities, nodeEntities, maxDepth, allowCheck
208
179
  nestedChildren.forEach(function (child) {
209
180
  checkedIdsSet.add(child.id);
210
181
  });
211
- }); // 缓存中间结果,优化查询
212
-
182
+ });
183
+ // 缓存中间结果,优化查询
213
184
  var visitedIds = new Map();
214
-
215
185
  for (var depth = maxDepth - 1; depth >= 0; --depth) {
216
186
  var entities = depthEntities.get(depth);
217
187
  entities === null || entities === void 0 ? void 0 : entities.forEach(function (entity) {
218
188
  var id = entity.id,
219
- children = entity.children;
189
+ children = entity.children;
220
190
  if (visitedIds.has(id)) return;
221
-
222
191
  if (isArrayNonEmpty(children)) {
223
192
  var shouldChecked = !children.some(function (child) {
224
193
  if (visitedIds.has(child.id)) {
225
194
  return !visitedIds.get(child.id);
226
195
  }
227
-
228
196
  return !checkedIdsSet.has(child.id);
229
197
  });
230
198
  visitedIds.set(id, shouldChecked);
231
-
232
199
  if (shouldChecked && allowCheck(entity)) {
233
200
  checkedIdsSet.add(id);
234
201
  }
235
202
  }
236
203
  });
237
204
  }
238
-
239
205
  return Array.from(checkedIdsSet);
240
206
  }
241
-
242
207
  export { flattenTreeData, getActiveMenuIds, getActiveMenus, getCascaderItemEventData, getFlattedMenus, parseCheckDataDirty, processCheckedIds };