@chaoswise/ui 2.2.9 → 2.3.1
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/lib/AbreastLayout/index.js +5 -1
- package/lib/BasicLayout/Sider.js +8 -3
- package/lib/BasicLayout/index.js +10 -2
- package/lib/Button/index.js +0 -8
- package/lib/CWCascader/Cascader/index.js +207 -0
- package/lib/CWCascader/index.js +60 -0
- package/lib/CWCascader/index.less +31 -0
- package/lib/CWCascader/rc-cascader/Cascader.js +353 -0
- package/lib/CWCascader/rc-cascader/OptionList/Checkbox.js +22 -0
- package/lib/CWCascader/rc-cascader/OptionList/Column.js +276 -0
- package/lib/CWCascader/rc-cascader/OptionList/index.js +221 -0
- package/lib/CWCascader/rc-cascader/OptionList/useActive.js +33 -0
- package/lib/CWCascader/rc-cascader/OptionList/useKeyboard.js +173 -0
- package/lib/CWCascader/rc-cascader/context.js +3 -0
- package/lib/CWCascader/rc-cascader/hooks/useDisplayValues.js +85 -0
- package/lib/CWCascader/rc-cascader/hooks/useEntities.js +40 -0
- package/lib/CWCascader/rc-cascader/hooks/useMissingValues.js +19 -0
- package/lib/CWCascader/rc-cascader/hooks/useRefFunc.js +13 -0
- package/lib/CWCascader/rc-cascader/hooks/useSearchConfig.js +30 -0
- package/lib/CWCascader/rc-cascader/hooks/useSearchOptions.js +74 -0
- package/lib/CWCascader/rc-cascader/index.js +2 -0
- package/lib/CWCascader/rc-cascader/utils/commonUtil.js +54 -0
- package/lib/CWCascader/rc-cascader/utils/treeUtil.js +81 -0
- package/lib/CWCascader/rc-cascader/utils/warningPropsUtil.js +30 -0
- package/lib/CWRangePicker/DropdownMenu/index.js +1 -1
- package/lib/CWRangePicker/DropdownMenu/index.less +11 -7
- package/lib/CWRangePicker/index.js +30 -29
- package/lib/CWSelect/index.js +9 -1
- package/lib/CWSelect/index.less +11 -1
- package/lib/Cascader/index.js +0 -8
- package/lib/Cascader/index.less +23 -0
- package/lib/Cascaders/Cascader/index.js +208 -0
- package/lib/Cascaders/index.js +17 -0
- package/lib/Cascaders/index.less +1 -0
- package/lib/Cascaders/rc-cascader/Cascader.js +326 -0
- package/lib/Cascaders/rc-cascader/OptionList/Checkbox.js +22 -0
- package/lib/Cascaders/rc-cascader/OptionList/Column.js +203 -0
- package/lib/Cascaders/rc-cascader/OptionList/index.js +213 -0
- package/lib/Cascaders/rc-cascader/OptionList/useActive.js +33 -0
- package/lib/Cascaders/rc-cascader/OptionList/useKeyboard.js +171 -0
- package/lib/Cascaders/rc-cascader/context.js +3 -0
- package/lib/Cascaders/rc-cascader/hooks/useDisplayValues.js +56 -0
- package/lib/Cascaders/rc-cascader/hooks/useEntities.js +34 -0
- package/lib/Cascaders/rc-cascader/hooks/useMissingValues.js +19 -0
- package/lib/Cascaders/rc-cascader/hooks/useRefFunc.js +13 -0
- package/lib/Cascaders/rc-cascader/hooks/useSearchConfig.js +25 -0
- package/lib/Cascaders/rc-cascader/hooks/useSearchOptions.js +72 -0
- package/lib/Cascaders/rc-cascader/index.js +2 -0
- package/lib/Cascaders/rc-cascader/utils/commonUtil.js +54 -0
- package/lib/Cascaders/rc-cascader/utils/treeUtil.js +37 -0
- package/lib/Cascaders/rc-cascader/utils/warningPropsUtil.js +30 -0
- package/lib/CitySelect/index.js +2 -2
- package/lib/DropdownDatePicker/DropdownMenu/MoreTimeList/index.js +46 -0
- package/lib/DropdownDatePicker/DropdownMenu/MoreTimeList/index.less +14 -0
- package/lib/DropdownDatePicker/DropdownMenu/index.js +126 -0
- package/lib/DropdownDatePicker/DropdownMenu/index.less +68 -0
- package/lib/DropdownDatePicker/assets/Calendar2.js +15 -0
- package/lib/DropdownDatePicker/assets/live.js +19 -0
- package/lib/DropdownDatePicker/assets/more.js +23 -0
- package/lib/DropdownDatePicker/index.js +281 -0
- package/lib/DropdownDatePicker/index.less +34 -0
- package/lib/DropdownDatePicker/locale/en_US.js +20 -0
- package/lib/DropdownDatePicker/locale/index.js +12 -0
- package/lib/DropdownDatePicker/locale/zh_CN.js +20 -0
- package/lib/DropdownDatePicker/utils/index.js +247 -0
- package/lib/InputNumber/index.js +15 -11
- package/lib/ModuleFederation/ErrorBoundary/index.js +54 -0
- package/lib/ModuleFederation/index.js +10 -0
- package/lib/ModuleFederation/react-dynamic-remote-component/RemoteComponent.js +185 -0
- package/lib/ModuleFederation/react-dynamic-remote-component/attach-script.js +42 -0
- package/lib/ModuleFederation/react-dynamic-remote-component/index.js +1 -0
- package/lib/ModuleFederation/react-dynamic-remote-component/load-module.js +44 -0
- package/lib/ModuleFederation/react-dynamic-remote-component/loading-script.js +35 -0
- package/lib/ModuleFederation/react-dynamic-remote-component/suspend.js +28 -0
- package/lib/ModuleFederation/react-dynamic-remote-component/utils.js +7 -0
- package/lib/QuickTransfer/locale/index.js +1 -4
- package/lib/QuickTransfer/locale/zh_CN.js +0 -8
- package/package.json +4 -3
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
4
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
5
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
6
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
7
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
8
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
9
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
10
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
11
|
+
import { useBaseProps } from 'rc-cascader/node_modules/rc-select';
|
|
12
|
+
import KeyCode from 'rc-util/lib/KeyCode';
|
|
13
|
+
import * as React from 'react';
|
|
14
|
+
import { SEARCH_MARK } from '../hooks/useSearchOptions';
|
|
15
|
+
import { getFullPathKeys, toPathKey } from '../utils/commonUtil';
|
|
16
|
+
export default (function (ref, options, fieldNames, activeValueCells, setActiveValueCells, onKeyBoardSelect) {
|
|
17
|
+
var _useBaseProps = useBaseProps(),
|
|
18
|
+
direction = _useBaseProps.direction,
|
|
19
|
+
searchValue = _useBaseProps.searchValue,
|
|
20
|
+
toggleOpen = _useBaseProps.toggleOpen,
|
|
21
|
+
open = _useBaseProps.open;
|
|
22
|
+
var rtl = direction === 'rtl';
|
|
23
|
+
var _React$useMemo = React.useMemo(function () {
|
|
24
|
+
var activeIndex = -1;
|
|
25
|
+
var currentOptions = options;
|
|
26
|
+
var mergedActiveIndexes = [];
|
|
27
|
+
var mergedActiveValueCells = [];
|
|
28
|
+
var len = activeValueCells.length;
|
|
29
|
+
var pathKeys = getFullPathKeys(options, fieldNames);
|
|
30
|
+
// Fill validate active value cells and index
|
|
31
|
+
var _loop = function _loop(i) {
|
|
32
|
+
// Mark the active index for current options
|
|
33
|
+
var nextActiveIndex = currentOptions.findIndex(function (option, index) {
|
|
34
|
+
return (pathKeys[index] ? toPathKey(pathKeys[index]) : option[fieldNames.value]) === activeValueCells[i];
|
|
35
|
+
});
|
|
36
|
+
if (nextActiveIndex === -1) {
|
|
37
|
+
return "break";
|
|
38
|
+
}
|
|
39
|
+
activeIndex = nextActiveIndex;
|
|
40
|
+
mergedActiveIndexes.push(activeIndex);
|
|
41
|
+
mergedActiveValueCells.push(activeValueCells[i]);
|
|
42
|
+
currentOptions = currentOptions[activeIndex][fieldNames.children];
|
|
43
|
+
};
|
|
44
|
+
for (var i = 0; i < len && currentOptions; i += 1) {
|
|
45
|
+
var _ret = _loop(i);
|
|
46
|
+
if (_ret === "break") break;
|
|
47
|
+
}
|
|
48
|
+
// Fill last active options
|
|
49
|
+
var activeOptions = options;
|
|
50
|
+
for (var _i2 = 0; _i2 < mergedActiveIndexes.length - 1; _i2 += 1) {
|
|
51
|
+
activeOptions = activeOptions[mergedActiveIndexes[_i2]][fieldNames.children];
|
|
52
|
+
}
|
|
53
|
+
return [mergedActiveValueCells, activeIndex, activeOptions, pathKeys];
|
|
54
|
+
}, [activeValueCells, fieldNames, options]),
|
|
55
|
+
_React$useMemo2 = _slicedToArray(_React$useMemo, 4),
|
|
56
|
+
validActiveValueCells = _React$useMemo2[0],
|
|
57
|
+
lastActiveIndex = _React$useMemo2[1],
|
|
58
|
+
lastActiveOptions = _React$useMemo2[2],
|
|
59
|
+
fullPathKeys = _React$useMemo2[3];
|
|
60
|
+
// Update active value cells and scroll to target element
|
|
61
|
+
var internalSetActiveValueCells = function internalSetActiveValueCells(next) {
|
|
62
|
+
setActiveValueCells(next);
|
|
63
|
+
};
|
|
64
|
+
// Same options offset
|
|
65
|
+
var offsetActiveOption = function offsetActiveOption(offset) {
|
|
66
|
+
var len = lastActiveOptions.length;
|
|
67
|
+
var currentIndex = lastActiveIndex;
|
|
68
|
+
if (currentIndex === -1 && offset < 0) {
|
|
69
|
+
currentIndex = len;
|
|
70
|
+
}
|
|
71
|
+
for (var i = 0; i < len; i += 1) {
|
|
72
|
+
currentIndex = (currentIndex + offset + len) % len;
|
|
73
|
+
var option = lastActiveOptions[currentIndex];
|
|
74
|
+
if (option && !option.disabled) {
|
|
75
|
+
var nextActiveCells = validActiveValueCells.slice(0, -1).concat(fullPathKeys[currentIndex] ? toPathKey(fullPathKeys[currentIndex]) : option[fieldNames.value]);
|
|
76
|
+
internalSetActiveValueCells(nextActiveCells);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
// Different options offset
|
|
82
|
+
var prevColumn = function prevColumn() {
|
|
83
|
+
if (validActiveValueCells.length > 1) {
|
|
84
|
+
var nextActiveCells = validActiveValueCells.slice(0, -1);
|
|
85
|
+
internalSetActiveValueCells(nextActiveCells);
|
|
86
|
+
} else {
|
|
87
|
+
toggleOpen(false);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
var nextColumn = function nextColumn() {
|
|
91
|
+
var _lastActiveOptions$la;
|
|
92
|
+
var nextOptions = ((_lastActiveOptions$la = lastActiveOptions[lastActiveIndex]) === null || _lastActiveOptions$la === void 0 ? void 0 : _lastActiveOptions$la[fieldNames.children]) || [];
|
|
93
|
+
var nextOption = nextOptions.find(function (option) {
|
|
94
|
+
return !option.disabled;
|
|
95
|
+
});
|
|
96
|
+
if (nextOption) {
|
|
97
|
+
var nextActiveCells = [].concat(_toConsumableArray(validActiveValueCells), [nextOption[fieldNames.value]]);
|
|
98
|
+
internalSetActiveValueCells(nextActiveCells);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
React.useImperativeHandle(ref, function () {
|
|
102
|
+
return {
|
|
103
|
+
// scrollTo: treeRef.current?.scrollTo,
|
|
104
|
+
onKeyDown: function onKeyDown(event) {
|
|
105
|
+
// const { which } = event;
|
|
106
|
+
// switch (which) {
|
|
107
|
+
// // >>> Arrow keys
|
|
108
|
+
// case KeyCode.UP:
|
|
109
|
+
// case KeyCode.DOWN: {
|
|
110
|
+
// let offset = 0;
|
|
111
|
+
// if (which === KeyCode.UP) {
|
|
112
|
+
// offset = -1;
|
|
113
|
+
// }
|
|
114
|
+
// else if (which === KeyCode.DOWN) {
|
|
115
|
+
// offset = 1;
|
|
116
|
+
// }
|
|
117
|
+
// if (offset !== 0) {
|
|
118
|
+
// offsetActiveOption(offset);
|
|
119
|
+
// }
|
|
120
|
+
// break;
|
|
121
|
+
// }
|
|
122
|
+
// case KeyCode.LEFT: {
|
|
123
|
+
// if (rtl) {
|
|
124
|
+
// nextColumn();
|
|
125
|
+
// }
|
|
126
|
+
// else {
|
|
127
|
+
// prevColumn();
|
|
128
|
+
// }
|
|
129
|
+
// break;
|
|
130
|
+
// }
|
|
131
|
+
// case KeyCode.RIGHT: {
|
|
132
|
+
// if (rtl) {
|
|
133
|
+
// prevColumn();
|
|
134
|
+
// }
|
|
135
|
+
// else {
|
|
136
|
+
// nextColumn();
|
|
137
|
+
// }
|
|
138
|
+
// break;
|
|
139
|
+
// }
|
|
140
|
+
// case KeyCode.BACKSPACE: {
|
|
141
|
+
// if (!searchValue) {
|
|
142
|
+
// prevColumn();
|
|
143
|
+
// }
|
|
144
|
+
// break;
|
|
145
|
+
// }
|
|
146
|
+
// // >>> Select
|
|
147
|
+
// case KeyCode.ENTER: {
|
|
148
|
+
// if (validActiveValueCells.length) {
|
|
149
|
+
// const option = lastActiveOptions[lastActiveIndex];
|
|
150
|
+
// // Search option should revert back of origin options
|
|
151
|
+
// const originOptions = option?.[SEARCH_MARK] || [];
|
|
152
|
+
// if (originOptions.length) {
|
|
153
|
+
// onKeyBoardSelect(originOptions.map(opt => opt[fieldNames.value]), originOptions[originOptions.length - 1]);
|
|
154
|
+
// }
|
|
155
|
+
// else {
|
|
156
|
+
// onKeyBoardSelect(validActiveValueCells, lastActiveOptions[lastActiveIndex]);
|
|
157
|
+
// }
|
|
158
|
+
// }
|
|
159
|
+
// break;
|
|
160
|
+
// }
|
|
161
|
+
// // >>> Close
|
|
162
|
+
// case KeyCode.ESC: {
|
|
163
|
+
// toggleOpen(false);
|
|
164
|
+
// if (open) {
|
|
165
|
+
// event.stopPropagation();
|
|
166
|
+
// }
|
|
167
|
+
// }
|
|
168
|
+
// }
|
|
169
|
+
},
|
|
170
|
+
onKeyUp: function onKeyUp() {}
|
|
171
|
+
};
|
|
172
|
+
});
|
|
173
|
+
});
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
5
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
6
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
7
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
8
|
+
import { toPathOptions } from "../utils/treeUtil";
|
|
9
|
+
import * as React from "react";
|
|
10
|
+
import { toPathKey } from "../utils/commonUtil";
|
|
11
|
+
export default (function (rawValues, options, fieldNames, multiple, displayRender, labelInValueOption) {
|
|
12
|
+
return React.useMemo(function () {
|
|
13
|
+
var mergedDisplayRender = displayRender ||
|
|
14
|
+
// Default displayRender
|
|
15
|
+
function (labels) {
|
|
16
|
+
var mergedLabels = multiple ? labels.slice(-1) : labels;
|
|
17
|
+
var SPLIT = " / ";
|
|
18
|
+
if (mergedLabels.every(function (label) {
|
|
19
|
+
return ["string", "number"].includes(_typeof(label));
|
|
20
|
+
})) {
|
|
21
|
+
return mergedLabels.join(SPLIT);
|
|
22
|
+
}
|
|
23
|
+
// If exist non-string value, use ReactNode instead
|
|
24
|
+
return mergedLabels.reduce(function (list, label, index) {
|
|
25
|
+
var keyedLabel = /*#__PURE__*/React.isValidElement(label) ? /*#__PURE__*/React.cloneElement(label, {
|
|
26
|
+
key: index
|
|
27
|
+
}) : label;
|
|
28
|
+
if (index === 0) {
|
|
29
|
+
return [keyedLabel];
|
|
30
|
+
}
|
|
31
|
+
return [].concat(_toConsumableArray(list), [SPLIT, keyedLabel]);
|
|
32
|
+
}, []);
|
|
33
|
+
};
|
|
34
|
+
return rawValues.map(function (valueCells) {
|
|
35
|
+
var _valueOptions, _valueOptions$option;
|
|
36
|
+
var valueOptions = toPathOptions(valueCells, options, fieldNames);
|
|
37
|
+
var isBackEndQuery = false;
|
|
38
|
+
if (valueOptions.length && (valueOptions[valueOptions.length - 1].index === -1 || valueOptions[valueOptions.length - 1].index === undefined)) {
|
|
39
|
+
var findItem = labelInValueOption.find(function (item) {
|
|
40
|
+
return item.value == valueCells;
|
|
41
|
+
});
|
|
42
|
+
if (findItem) {
|
|
43
|
+
isBackEndQuery = true;
|
|
44
|
+
valueOptions[valueOptions.length - 1].option = {
|
|
45
|
+
value: valueOptions[valueOptions.length - 1].value,
|
|
46
|
+
label: findItem.label
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
var label;
|
|
51
|
+
if (isBackEndQuery) {
|
|
52
|
+
label = mergedDisplayRender(valueOptions.map(function (_ref) {
|
|
53
|
+
var option = _ref.option,
|
|
54
|
+
value = _ref.value;
|
|
55
|
+
return option === null || option === void 0 ? void 0 : option[fieldNames.label];
|
|
56
|
+
}).filter(Boolean), valueOptions.map(function (_ref2) {
|
|
57
|
+
var option = _ref2.option,
|
|
58
|
+
value = _ref2.value;
|
|
59
|
+
return option !== null && option !== void 0 ? option : {
|
|
60
|
+
label: undefined,
|
|
61
|
+
value: value
|
|
62
|
+
};
|
|
63
|
+
}));
|
|
64
|
+
} else {
|
|
65
|
+
label = mergedDisplayRender(valueOptions.map(function (_ref3) {
|
|
66
|
+
var _option$fieldNames$la;
|
|
67
|
+
var option = _ref3.option,
|
|
68
|
+
value = _ref3.value;
|
|
69
|
+
return (_option$fieldNames$la = option === null || option === void 0 ? void 0 : option[fieldNames.label]) !== null && _option$fieldNames$la !== void 0 ? _option$fieldNames$la : value;
|
|
70
|
+
}), valueOptions.map(function (_ref4) {
|
|
71
|
+
var option = _ref4.option;
|
|
72
|
+
return option;
|
|
73
|
+
}));
|
|
74
|
+
}
|
|
75
|
+
var value = toPathKey(valueCells);
|
|
76
|
+
return {
|
|
77
|
+
label: label,
|
|
78
|
+
value: value,
|
|
79
|
+
key: value,
|
|
80
|
+
valueCells: valueCells,
|
|
81
|
+
disabled: (_valueOptions = valueOptions[valueOptions.length - 1]) === null || _valueOptions === void 0 ? void 0 : (_valueOptions$option = _valueOptions.option) === null || _valueOptions$option === void 0 ? void 0 : _valueOptions$option.disabled
|
|
82
|
+
};
|
|
83
|
+
});
|
|
84
|
+
}, [rawValues, options, fieldNames, displayRender, multiple, labelInValueOption]);
|
|
85
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
|
+
import * as React from 'react';
|
|
8
|
+
import { convertDataToEntities } from 'rc-cascader/node_modules/rc-tree/lib/utils/treeUtil';
|
|
9
|
+
import { VALUE_SPLIT } from '../utils/commonUtil';
|
|
10
|
+
/** Lazy parse options data into conduct-able info to avoid perf issue in single mode */
|
|
11
|
+
export default (function (options, fieldNames) {
|
|
12
|
+
var cacheRef = React.useRef({
|
|
13
|
+
options: null,
|
|
14
|
+
info: null
|
|
15
|
+
});
|
|
16
|
+
var getEntities = React.useCallback(function () {
|
|
17
|
+
if (cacheRef.current.options !== options) {
|
|
18
|
+
cacheRef.current.options = options;
|
|
19
|
+
cacheRef.current.info = convertDataToEntities(options, {
|
|
20
|
+
fieldNames: fieldNames,
|
|
21
|
+
initWrapper: function initWrapper(wrapper) {
|
|
22
|
+
return _objectSpread(_objectSpread({}, wrapper), {}, {
|
|
23
|
+
pathKeyEntities: {}
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
processEntity: function processEntity(entity, wrapper) {
|
|
27
|
+
var pathKey = entity.nodes.map(function (node) {
|
|
28
|
+
return node[fieldNames.value];
|
|
29
|
+
}).join(VALUE_SPLIT);
|
|
30
|
+
wrapper.pathKeyEntities[pathKey] = entity;
|
|
31
|
+
// Overwrite origin key.
|
|
32
|
+
// this is very hack but we need let conduct logic work with connect path
|
|
33
|
+
entity.key = pathKey;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return cacheRef.current.info.pathKeyEntities;
|
|
38
|
+
}, [fieldNames, options]);
|
|
39
|
+
return getEntities;
|
|
40
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { toPathOptions } from '../utils/treeUtil';
|
|
3
|
+
export default (function (options, fieldNames) {
|
|
4
|
+
return React.useCallback(function (rawValues) {
|
|
5
|
+
var missingValues = [];
|
|
6
|
+
var existsValues = [];
|
|
7
|
+
rawValues.forEach(function (valueCell) {
|
|
8
|
+
var pathOptions = toPathOptions(valueCell, options, fieldNames);
|
|
9
|
+
if (pathOptions.every(function (opt) {
|
|
10
|
+
return opt.option;
|
|
11
|
+
})) {
|
|
12
|
+
existsValues.push(valueCell);
|
|
13
|
+
} else {
|
|
14
|
+
missingValues.push(valueCell);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return [existsValues, missingValues];
|
|
18
|
+
}, [options, fieldNames]);
|
|
19
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Same as `React.useCallback` but always return a memoized function
|
|
4
|
+
* but redirect to real function.
|
|
5
|
+
*/
|
|
6
|
+
export default function useRefFunc(callback) {
|
|
7
|
+
var funcRef = React.useRef();
|
|
8
|
+
funcRef.current = callback;
|
|
9
|
+
var cacheFn = React.useCallback(function () {
|
|
10
|
+
return funcRef.current.apply(funcRef, arguments);
|
|
11
|
+
}, []);
|
|
12
|
+
return cacheFn;
|
|
13
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
3
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
4
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
5
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
6
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
7
|
+
import * as React from 'react';
|
|
8
|
+
import warning from 'rc-util/lib/warning';
|
|
9
|
+
// Convert `showSearch` to unique config
|
|
10
|
+
export default function useSearchConfig(showSearch) {
|
|
11
|
+
return React.useMemo(function () {
|
|
12
|
+
if (!showSearch) {
|
|
13
|
+
return [false, {}];
|
|
14
|
+
}
|
|
15
|
+
var searchConfig = {
|
|
16
|
+
matchInputWidth: true,
|
|
17
|
+
limit: 50
|
|
18
|
+
};
|
|
19
|
+
if (showSearch && _typeof(showSearch) === 'object') {
|
|
20
|
+
searchConfig = _objectSpread(_objectSpread({}, searchConfig), showSearch);
|
|
21
|
+
}
|
|
22
|
+
if (searchConfig.limit <= 0) {
|
|
23
|
+
delete searchConfig.limit;
|
|
24
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
25
|
+
warning(false, "'limit' of showSearch should be positive number or false.");
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return [true, searchConfig];
|
|
29
|
+
}, [showSearch]);
|
|
30
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
8
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
11
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
12
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
13
|
+
import * as React from 'react';
|
|
14
|
+
export var SEARCH_MARK = '__rc_cascader_search_mark__';
|
|
15
|
+
var defaultFilter = function defaultFilter(search, options, _ref) {
|
|
16
|
+
var label = _ref.label;
|
|
17
|
+
return options.some(function (opt) {
|
|
18
|
+
return String(opt[label]).toLowerCase().includes(search.toLowerCase());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var defaultRender = function defaultRender(inputValue, path, prefixCls, fieldNames) {
|
|
22
|
+
return path.map(function (opt) {
|
|
23
|
+
return opt[fieldNames.label];
|
|
24
|
+
}).join(' / ');
|
|
25
|
+
};
|
|
26
|
+
export default (function (search, options, fieldNames, prefixCls, config, changeOnSelect) {
|
|
27
|
+
var _config$filter = config.filter,
|
|
28
|
+
filter = _config$filter === void 0 ? defaultFilter : _config$filter,
|
|
29
|
+
_config$render = config.render,
|
|
30
|
+
render = _config$render === void 0 ? defaultRender : _config$render,
|
|
31
|
+
_config$limit = config.limit,
|
|
32
|
+
limit = _config$limit === void 0 ? 50 : _config$limit,
|
|
33
|
+
sort = config.sort;
|
|
34
|
+
return React.useMemo(function () {
|
|
35
|
+
var filteredOptions = [];
|
|
36
|
+
if (!search) {
|
|
37
|
+
return [];
|
|
38
|
+
}
|
|
39
|
+
function dig(list, pathOptions) {
|
|
40
|
+
list.forEach(function (option) {
|
|
41
|
+
// Perf saving when `sort` is disabled and `limit` is provided
|
|
42
|
+
if (!sort && limit > 0 && filteredOptions.length >= limit) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
var connectedPathOptions = [].concat(_toConsumableArray(pathOptions), [option]);
|
|
46
|
+
var children = option[fieldNames.children];
|
|
47
|
+
// If current option is filterable
|
|
48
|
+
if (
|
|
49
|
+
// If is leaf option
|
|
50
|
+
!children || children.length === 0 ||
|
|
51
|
+
// If is changeOnSelect
|
|
52
|
+
changeOnSelect) {
|
|
53
|
+
if (filter(search, connectedPathOptions, {
|
|
54
|
+
label: fieldNames.label
|
|
55
|
+
})) {
|
|
56
|
+
var _objectSpread2;
|
|
57
|
+
filteredOptions.push(_objectSpread(_objectSpread({}, option), {}, (_objectSpread2 = {}, _defineProperty(_objectSpread2, fieldNames.label, render(search, connectedPathOptions, prefixCls, fieldNames)), _defineProperty(_objectSpread2, SEARCH_MARK, connectedPathOptions), _objectSpread2)));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (children) {
|
|
61
|
+
dig(option[fieldNames.children], connectedPathOptions);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
dig(options, []);
|
|
66
|
+
// Do sort
|
|
67
|
+
if (sort) {
|
|
68
|
+
filteredOptions.sort(function (a, b) {
|
|
69
|
+
return sort(a[SEARCH_MARK], b[SEARCH_MARK], search, fieldNames);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return limit > 0 ? filteredOptions.slice(0, limit) : filteredOptions;
|
|
73
|
+
}, [search, options, fieldNames, prefixCls, render, changeOnSelect, filter, sort, limit]);
|
|
74
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { SEARCH_MARK } from '../hooks/useSearchOptions';
|
|
2
|
+
export var VALUE_SPLIT = '__RC_CASCADER_SPLIT__';
|
|
3
|
+
export var SHOW_PARENT = 'SHOW_PARENT';
|
|
4
|
+
export var SHOW_CHILD = 'SHOW_CHILD';
|
|
5
|
+
export function toPathKey(value) {
|
|
6
|
+
return value.join(VALUE_SPLIT);
|
|
7
|
+
}
|
|
8
|
+
export function toPathKeys(value) {
|
|
9
|
+
return value.map(toPathKey);
|
|
10
|
+
}
|
|
11
|
+
export function toPathValueStr(pathKey) {
|
|
12
|
+
return pathKey.split(VALUE_SPLIT);
|
|
13
|
+
}
|
|
14
|
+
export function fillFieldNames(fieldNames) {
|
|
15
|
+
var _ref = fieldNames || {},
|
|
16
|
+
label = _ref.label,
|
|
17
|
+
value = _ref.value,
|
|
18
|
+
children = _ref.children;
|
|
19
|
+
var val = value || 'value';
|
|
20
|
+
return {
|
|
21
|
+
label: label || 'label',
|
|
22
|
+
value: val,
|
|
23
|
+
key: val,
|
|
24
|
+
children: children || 'children'
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export function isLeaf(option, fieldNames) {
|
|
28
|
+
var _option$isLeaf, _option$fieldNames$ch;
|
|
29
|
+
return (_option$isLeaf = option.isLeaf) !== null && _option$isLeaf !== void 0 ? _option$isLeaf : !((_option$fieldNames$ch = option[fieldNames.children]) !== null && _option$fieldNames$ch !== void 0 && _option$fieldNames$ch.length);
|
|
30
|
+
}
|
|
31
|
+
export function scrollIntoParentView(element) {
|
|
32
|
+
var parent = element.parentElement;
|
|
33
|
+
if (!parent) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
var elementToParent = element.offsetTop - parent.offsetTop; // offsetParent may not be parent.
|
|
37
|
+
if (elementToParent - parent.scrollTop < 0) {
|
|
38
|
+
parent.scrollTo({
|
|
39
|
+
top: elementToParent
|
|
40
|
+
});
|
|
41
|
+
} else if (elementToParent + element.offsetHeight - parent.scrollTop > parent.offsetHeight) {
|
|
42
|
+
parent.scrollTo({
|
|
43
|
+
top: elementToParent + element.offsetHeight - parent.offsetHeight
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export function getFullPathKeys(options, fieldNames) {
|
|
48
|
+
return options.map(function (item) {
|
|
49
|
+
var _item$SEARCH_MARK;
|
|
50
|
+
return (_item$SEARCH_MARK = item[SEARCH_MARK]) === null || _item$SEARCH_MARK === void 0 ? void 0 : _item$SEARCH_MARK.map(function (opt) {
|
|
51
|
+
return opt[fieldNames.value];
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { SHOW_CHILD } from "./commonUtil";
|
|
2
|
+
export function formatStrategyValues(pathKeys, getKeyPathEntities, showCheckedStrategy) {
|
|
3
|
+
var valueSet = new Set(pathKeys);
|
|
4
|
+
var keyPathEntities = getKeyPathEntities();
|
|
5
|
+
return pathKeys.filter(function (key) {
|
|
6
|
+
var entity = keyPathEntities[key];
|
|
7
|
+
var parent = entity ? entity.parent : null;
|
|
8
|
+
var children = entity ? entity.children : null;
|
|
9
|
+
return showCheckedStrategy === SHOW_CHILD ? !(children && children.some(function (child) {
|
|
10
|
+
return child.key && valueSet.has(child.key);
|
|
11
|
+
})) : !(parent && !parent.node.disabled && valueSet.has(parent.key));
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
export function toPathOptions(valueCells, options, fieldNames) {
|
|
15
|
+
var stringMode = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
16
|
+
var labelInValue = arguments.length > 4 ? arguments[4] : undefined;
|
|
17
|
+
var labelInValueOption = arguments.length > 5 ? arguments[5] : undefined;
|
|
18
|
+
var currentList = options;
|
|
19
|
+
var valueOptions = [];
|
|
20
|
+
var isHit = true;
|
|
21
|
+
var _loop = function _loop() {
|
|
22
|
+
var _currentList, _currentList2, _foundOption$fieldNam;
|
|
23
|
+
var valueCell = valueCells[i];
|
|
24
|
+
var foundIndex = (_currentList = currentList) === null || _currentList === void 0 ? void 0 : _currentList.findIndex(function (option) {
|
|
25
|
+
var val = option[fieldNames.value];
|
|
26
|
+
return stringMode ? String(val) === String(valueCell) : val === valueCell;
|
|
27
|
+
});
|
|
28
|
+
var foundOption = foundIndex !== -1 ? (_currentList2 = currentList) === null || _currentList2 === void 0 ? void 0 : _currentList2[foundIndex] : null;
|
|
29
|
+
if (foundIndex === -1) {
|
|
30
|
+
isHit = false;
|
|
31
|
+
}
|
|
32
|
+
valueOptions.push({
|
|
33
|
+
value: (_foundOption$fieldNam = foundOption === null || foundOption === void 0 ? void 0 : foundOption[fieldNames.value]) !== null && _foundOption$fieldNam !== void 0 ? _foundOption$fieldNam : valueCell,
|
|
34
|
+
index: foundIndex,
|
|
35
|
+
option: foundOption
|
|
36
|
+
});
|
|
37
|
+
currentList = foundOption === null || foundOption === void 0 ? void 0 : foundOption[fieldNames.children];
|
|
38
|
+
};
|
|
39
|
+
for (var i = 0; i < valueCells.length; i += 1) {
|
|
40
|
+
_loop();
|
|
41
|
+
}
|
|
42
|
+
if (!isHit && labelInValue) {
|
|
43
|
+
var findOption = labelInValueOption.find(function (item) {
|
|
44
|
+
return item.value === valueCells;
|
|
45
|
+
});
|
|
46
|
+
if (findOption) {
|
|
47
|
+
valueOptions = [{
|
|
48
|
+
option: {
|
|
49
|
+
value: findOption.value,
|
|
50
|
+
label: findOption.label,
|
|
51
|
+
backEndQuery: true
|
|
52
|
+
}
|
|
53
|
+
}];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return valueOptions;
|
|
57
|
+
}
|
|
58
|
+
export function toValueAndLabel(valueOptions) {
|
|
59
|
+
var triggerValues = [];
|
|
60
|
+
valueOptions.forEach(function (item) {
|
|
61
|
+
var isBackEndQuery = item.some(function (i) {
|
|
62
|
+
return i.backEndQuery;
|
|
63
|
+
});
|
|
64
|
+
if (isBackEndQuery) {
|
|
65
|
+
triggerValues.push({
|
|
66
|
+
label: item[0].label,
|
|
67
|
+
value: item[0].value
|
|
68
|
+
});
|
|
69
|
+
} else {
|
|
70
|
+
var value = [];
|
|
71
|
+
item.forEach(function (i) {
|
|
72
|
+
value.push(i.value);
|
|
73
|
+
});
|
|
74
|
+
triggerValues.push({
|
|
75
|
+
label: item[item.length - 1].label,
|
|
76
|
+
value: value
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
return triggerValues;
|
|
81
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import warning from 'rc-util/lib/warning';
|
|
2
|
+
function warningProps(props) {
|
|
3
|
+
var onPopupVisibleChange = props.onPopupVisibleChange,
|
|
4
|
+
popupVisible = props.popupVisible,
|
|
5
|
+
popupClassName = props.popupClassName,
|
|
6
|
+
popupPlacement = props.popupPlacement;
|
|
7
|
+
warning(!onPopupVisibleChange, '`onPopupVisibleChange` is deprecated. Please use `onDropdownVisibleChange` instead.');
|
|
8
|
+
warning(popupVisible === undefined, '`popupVisible` is deprecated. Please use `open` instead.');
|
|
9
|
+
warning(popupClassName === undefined, '`popupClassName` is deprecated. Please use `dropdownClassName` instead.');
|
|
10
|
+
warning(popupPlacement === undefined, '`popupPlacement` is deprecated. Please use `placement` instead.');
|
|
11
|
+
}
|
|
12
|
+
// value in Cascader options should not be null
|
|
13
|
+
export function warningNullOptions(options, fieldNames) {
|
|
14
|
+
if (options) {
|
|
15
|
+
var recursiveOptions = function recursiveOptions(optionsList) {
|
|
16
|
+
for (var i = 0; i < optionsList.length; i++) {
|
|
17
|
+
var option = optionsList[i];
|
|
18
|
+
if (option[fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.value] === null) {
|
|
19
|
+
warning(false, '`value` in Cascader options should not be `null`.');
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
if (Array.isArray(option[fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.children]) && recursiveOptions(option[fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.children])) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
recursiveOptions(options);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export default warningProps;
|
|
@@ -190,7 +190,7 @@ var DropdownMenu = function DropdownMenu(props) {
|
|
|
190
190
|
"cw-dropdown-menu-more-wrapper-left": moreItemDropdownPosition === "left"
|
|
191
191
|
}),
|
|
192
192
|
getPopupContainer: function getPopupContainer(triggerNode) {
|
|
193
|
-
return triggerNode
|
|
193
|
+
return triggerNode;
|
|
194
194
|
}
|
|
195
195
|
}, /*#__PURE__*/React.createElement("div", {
|
|
196
196
|
className: classnames("cw-dropdown-menu-_item", "cw-dropdown-menu-item-more")
|