@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,353 @@
|
|
|
1
|
+
var _excluded = ["id", "prefixCls", "fieldNames", "defaultValue", "value", "changeOnSelect", "onChange", "displayRender", "checkable", "searchValue", "onSearch", "showSearch", "expandTrigger", "options", "dropdownPrefixCls", "loadData", "popupVisible", "open", "popupClassName", "dropdownClassName", "dropdownMenuColumnStyle", "popupPlacement", "placement", "onDropdownVisibleChange", "onPopupVisibleChange", "expandIcon", "loadingIcon", "children", "dropdownMatchSelectWidth", "showCheckedStrategy", "onScroll", "onSrollBottom", "showColumnSearch", "onInputChange", "dropdownColumnRender", "labelInValue", "isResetInputValue"];
|
|
2
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
3
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
4
|
+
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."); }
|
|
5
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
6
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
7
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
+
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."); }
|
|
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 _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; }
|
|
11
|
+
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; } }
|
|
12
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
14
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
15
|
+
import { BaseSelect } from "rc-cascader/node_modules/rc-select";
|
|
16
|
+
import useId from "rc-cascader/node_modules/rc-select/lib/hooks/useId";
|
|
17
|
+
import { conductCheck } from "rc-cascader/node_modules/rc-tree/lib/utils/conductUtil";
|
|
18
|
+
import useMergedState from "rc-util/lib/hooks/useMergedState";
|
|
19
|
+
import * as React from "react";
|
|
20
|
+
import CascaderContext from "./context";
|
|
21
|
+
import useDisplayValues from "./hooks/useDisplayValues";
|
|
22
|
+
import useEntities from "./hooks/useEntities";
|
|
23
|
+
import useMissingValues from "./hooks/useMissingValues";
|
|
24
|
+
import useRefFunc from "./hooks/useRefFunc";
|
|
25
|
+
import useSearchConfig from "./hooks/useSearchConfig";
|
|
26
|
+
import useSearchOptions from "./hooks/useSearchOptions";
|
|
27
|
+
import OptionList from "./OptionList";
|
|
28
|
+
import { fillFieldNames, SHOW_CHILD, SHOW_PARENT, toPathKey, toPathKeys } from "./utils/commonUtil";
|
|
29
|
+
import { formatStrategyValues, toPathOptions, toValueAndLabel } from "./utils/treeUtil";
|
|
30
|
+
import warningProps, { warningNullOptions } from "./utils/warningPropsUtil";
|
|
31
|
+
function isMultipleValue(value) {
|
|
32
|
+
return Array.isArray(value) && Array.isArray(value[0]);
|
|
33
|
+
}
|
|
34
|
+
function toRawValues(value) {
|
|
35
|
+
if (!value) {
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
if (isMultipleValue(value)) {
|
|
39
|
+
return value;
|
|
40
|
+
}
|
|
41
|
+
return (value.length === 0 ? [] : [value]).map(function (val) {
|
|
42
|
+
return Array.isArray(val) ? val : [val];
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
var Cascader = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
46
|
+
var id = props.id,
|
|
47
|
+
_props$prefixCls = props.prefixCls,
|
|
48
|
+
prefixCls = _props$prefixCls === void 0 ? "rc-cascader" : _props$prefixCls,
|
|
49
|
+
fieldNames = props.fieldNames,
|
|
50
|
+
defaultValue = props.defaultValue,
|
|
51
|
+
value = props.value,
|
|
52
|
+
changeOnSelect = props.changeOnSelect,
|
|
53
|
+
onChange = props.onChange,
|
|
54
|
+
displayRender = props.displayRender,
|
|
55
|
+
checkable = props.checkable,
|
|
56
|
+
searchValue = props.searchValue,
|
|
57
|
+
onSearch = props.onSearch,
|
|
58
|
+
showSearch = props.showSearch,
|
|
59
|
+
expandTrigger = props.expandTrigger,
|
|
60
|
+
options = props.options,
|
|
61
|
+
dropdownPrefixCls = props.dropdownPrefixCls,
|
|
62
|
+
loadData = props.loadData,
|
|
63
|
+
popupVisible = props.popupVisible,
|
|
64
|
+
open = props.open,
|
|
65
|
+
popupClassName = props.popupClassName,
|
|
66
|
+
dropdownClassName = props.dropdownClassName,
|
|
67
|
+
dropdownMenuColumnStyle = props.dropdownMenuColumnStyle,
|
|
68
|
+
popupPlacement = props.popupPlacement,
|
|
69
|
+
placement = props.placement,
|
|
70
|
+
onDropdownVisibleChange = props.onDropdownVisibleChange,
|
|
71
|
+
onPopupVisibleChange = props.onPopupVisibleChange,
|
|
72
|
+
_props$expandIcon = props.expandIcon,
|
|
73
|
+
expandIcon = _props$expandIcon === void 0 ? ">" : _props$expandIcon,
|
|
74
|
+
loadingIcon = props.loadingIcon,
|
|
75
|
+
children = props.children,
|
|
76
|
+
_props$dropdownMatchS = props.dropdownMatchSelectWidth,
|
|
77
|
+
dropdownMatchSelectWidth = _props$dropdownMatchS === void 0 ? false : _props$dropdownMatchS,
|
|
78
|
+
_props$showCheckedStr = props.showCheckedStrategy,
|
|
79
|
+
showCheckedStrategy = _props$showCheckedStr === void 0 ? SHOW_PARENT : _props$showCheckedStr,
|
|
80
|
+
onScroll = props.onScroll,
|
|
81
|
+
onSrollBottom = props.onSrollBottom,
|
|
82
|
+
showColumnSearch = props.showColumnSearch,
|
|
83
|
+
onInputChange = props.onInputChange,
|
|
84
|
+
dropdownColumnRender = props.dropdownColumnRender,
|
|
85
|
+
labelInValue = props.labelInValue,
|
|
86
|
+
isResetInputValue = props.isResetInputValue,
|
|
87
|
+
restProps = _objectWithoutProperties(props, _excluded);
|
|
88
|
+
var mergedId = useId(id);
|
|
89
|
+
var multiple = !!checkable;
|
|
90
|
+
// =========================== Values ===========================
|
|
91
|
+
var _useMergedState = useMergedState(defaultValue, {
|
|
92
|
+
value: value,
|
|
93
|
+
postState: toRawValues
|
|
94
|
+
}),
|
|
95
|
+
_useMergedState2 = _slicedToArray(_useMergedState, 2),
|
|
96
|
+
rawValues = _useMergedState2[0],
|
|
97
|
+
setRawValues = _useMergedState2[1];
|
|
98
|
+
// ========================= FieldNames =========================
|
|
99
|
+
var mergedFieldNames = React.useMemo(function () {
|
|
100
|
+
return fillFieldNames(fieldNames);
|
|
101
|
+
}, /* eslint-disable react-hooks/exhaustive-deps */
|
|
102
|
+
[JSON.stringify(fieldNames)]);
|
|
103
|
+
// =========================== Option ===========================
|
|
104
|
+
var mergedOptions = React.useMemo(function () {
|
|
105
|
+
return options || [];
|
|
106
|
+
}, [options]);
|
|
107
|
+
// Only used in multiple mode, this fn will not call in single mode
|
|
108
|
+
var getPathKeyEntities = useEntities(mergedOptions, mergedFieldNames);
|
|
109
|
+
/** Convert path key back to value format */
|
|
110
|
+
var getValueByKeyPath = React.useCallback(function (pathKeys) {
|
|
111
|
+
var keyPathEntities = getPathKeyEntities();
|
|
112
|
+
return pathKeys.map(function (pathKey) {
|
|
113
|
+
var nodes = keyPathEntities[pathKey].nodes;
|
|
114
|
+
return nodes.map(function (node) {
|
|
115
|
+
return node[mergedFieldNames.value];
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
}, [getPathKeyEntities, mergedFieldNames]);
|
|
119
|
+
// =========================== Search ===========================
|
|
120
|
+
var _useMergedState3 = useMergedState("", {
|
|
121
|
+
value: searchValue,
|
|
122
|
+
postState: function postState(search) {
|
|
123
|
+
return search || "";
|
|
124
|
+
}
|
|
125
|
+
}),
|
|
126
|
+
_useMergedState4 = _slicedToArray(_useMergedState3, 2),
|
|
127
|
+
mergedSearchValue = _useMergedState4[0],
|
|
128
|
+
setSearchValue = _useMergedState4[1];
|
|
129
|
+
var onInternalSearch = function onInternalSearch(searchText, info) {
|
|
130
|
+
setSearchValue(searchText);
|
|
131
|
+
if (info.source !== "blur" && onSearch) {
|
|
132
|
+
onSearch(searchText);
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
var _useSearchConfig = useSearchConfig(showSearch),
|
|
136
|
+
_useSearchConfig2 = _slicedToArray(_useSearchConfig, 2),
|
|
137
|
+
mergedShowSearch = _useSearchConfig2[0],
|
|
138
|
+
searchConfig = _useSearchConfig2[1];
|
|
139
|
+
var searchOptions = useSearchOptions(mergedSearchValue, mergedOptions, mergedFieldNames, dropdownPrefixCls || prefixCls, searchConfig, changeOnSelect);
|
|
140
|
+
// =========================== Values ===========================
|
|
141
|
+
var getMissingValues = useMissingValues(mergedOptions, mergedFieldNames);
|
|
142
|
+
// Fill `rawValues` with checked conduction values
|
|
143
|
+
var _React$useMemo = React.useMemo(function () {
|
|
144
|
+
var _rawValues = [];
|
|
145
|
+
var labelInValueOption = [];
|
|
146
|
+
if (labelInValue) {
|
|
147
|
+
if (rawValues.length) {
|
|
148
|
+
rawValues[0].forEach(function (item) {
|
|
149
|
+
_rawValues.push(item.value);
|
|
150
|
+
var labelInValueItem = {};
|
|
151
|
+
labelInValueItem.value = item.value;
|
|
152
|
+
labelInValueItem.label = item.label;
|
|
153
|
+
labelInValueOption.push(labelInValueItem);
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
} else {
|
|
157
|
+
_rawValues = rawValues;
|
|
158
|
+
}
|
|
159
|
+
var _getMissingValues = getMissingValues(_rawValues),
|
|
160
|
+
_getMissingValues2 = _slicedToArray(_getMissingValues, 2),
|
|
161
|
+
existValues = _getMissingValues2[0],
|
|
162
|
+
missingValues = _getMissingValues2[1];
|
|
163
|
+
if (!multiple || !_rawValues.length) {
|
|
164
|
+
return [existValues, [], missingValues, labelInValueOption];
|
|
165
|
+
}
|
|
166
|
+
var keyPathValues = toPathKeys(existValues);
|
|
167
|
+
var keyPathEntities = getPathKeyEntities();
|
|
168
|
+
var _conductCheck = conductCheck(keyPathValues, true, keyPathEntities),
|
|
169
|
+
checkedKeys = _conductCheck.checkedKeys,
|
|
170
|
+
halfCheckedKeys = _conductCheck.halfCheckedKeys;
|
|
171
|
+
// Convert key back to value cells
|
|
172
|
+
return [getValueByKeyPath(checkedKeys), getValueByKeyPath(halfCheckedKeys), missingValues, labelInValueOption];
|
|
173
|
+
}, [multiple, rawValues, getPathKeyEntities, getValueByKeyPath, getMissingValues, labelInValue]),
|
|
174
|
+
_React$useMemo2 = _slicedToArray(_React$useMemo, 4),
|
|
175
|
+
checkedValues = _React$useMemo2[0],
|
|
176
|
+
halfCheckedValues = _React$useMemo2[1],
|
|
177
|
+
missingCheckedValues = _React$useMemo2[2],
|
|
178
|
+
labelInValueOption = _React$useMemo2[3];
|
|
179
|
+
var deDuplicatedValues = React.useMemo(function () {
|
|
180
|
+
var checkedKeys = toPathKeys(checkedValues);
|
|
181
|
+
var deduplicateKeys = formatStrategyValues(checkedKeys, getPathKeyEntities, showCheckedStrategy);
|
|
182
|
+
return [].concat(_toConsumableArray(missingCheckedValues), _toConsumableArray(getValueByKeyPath(deduplicateKeys)));
|
|
183
|
+
}, [checkedValues, getPathKeyEntities, getValueByKeyPath, missingCheckedValues, showCheckedStrategy]);
|
|
184
|
+
var displayValues = useDisplayValues(deDuplicatedValues, mergedOptions, mergedFieldNames, multiple, displayRender, labelInValueOption);
|
|
185
|
+
// =========================== Change ===========================
|
|
186
|
+
var triggerChange = useRefFunc(function (nextValues) {
|
|
187
|
+
var _nextValues = nextValues;
|
|
188
|
+
// Save perf if no need trigger event
|
|
189
|
+
var nextRawValues = toRawValues(nextValues);
|
|
190
|
+
var valueOptions = nextRawValues.map(function (valueCells) {
|
|
191
|
+
return toPathOptions(valueCells, mergedOptions, mergedFieldNames, false, labelInValue, labelInValueOption).map(function (valueOpt) {
|
|
192
|
+
return valueOpt.option;
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
if (labelInValue) {
|
|
196
|
+
nextRawValues = toValueAndLabel(valueOptions);
|
|
197
|
+
_nextValues = toValueAndLabel(valueOptions);
|
|
198
|
+
}
|
|
199
|
+
var triggerValues = multiple ? nextRawValues : nextRawValues[0];
|
|
200
|
+
var triggerOptions = multiple ? valueOptions : valueOptions[0];
|
|
201
|
+
if (onChange) {
|
|
202
|
+
onChange(triggerValues, triggerOptions);
|
|
203
|
+
}
|
|
204
|
+
setRawValues(_nextValues);
|
|
205
|
+
});
|
|
206
|
+
// =========================== Select ===========================
|
|
207
|
+
var onInternalSelect = useRefFunc(function (valuePath) {
|
|
208
|
+
setSearchValue("");
|
|
209
|
+
if (!multiple) {
|
|
210
|
+
triggerChange(valuePath);
|
|
211
|
+
} else {
|
|
212
|
+
// Prepare conduct required info
|
|
213
|
+
var pathKey = toPathKey(valuePath);
|
|
214
|
+
var checkedPathKeys = toPathKeys(checkedValues);
|
|
215
|
+
var halfCheckedPathKeys = toPathKeys(halfCheckedValues);
|
|
216
|
+
var existInChecked = checkedPathKeys.includes(pathKey);
|
|
217
|
+
var existInMissing = missingCheckedValues.some(function (valueCells) {
|
|
218
|
+
return toPathKey(valueCells) === pathKey;
|
|
219
|
+
});
|
|
220
|
+
// Do update
|
|
221
|
+
var nextCheckedValues = checkedValues;
|
|
222
|
+
var nextMissingValues = missingCheckedValues;
|
|
223
|
+
if (existInMissing && !existInChecked) {
|
|
224
|
+
// Missing value only do filter
|
|
225
|
+
nextMissingValues = missingCheckedValues.filter(function (valueCells) {
|
|
226
|
+
return toPathKey(valueCells) !== pathKey;
|
|
227
|
+
});
|
|
228
|
+
} else {
|
|
229
|
+
// Update checked key first
|
|
230
|
+
var nextRawCheckedKeys = existInChecked ? checkedPathKeys.filter(function (key) {
|
|
231
|
+
return key !== pathKey;
|
|
232
|
+
}) : [].concat(_toConsumableArray(checkedPathKeys), [pathKey]);
|
|
233
|
+
var pathKeyEntities = getPathKeyEntities();
|
|
234
|
+
// Conduction by selected or not
|
|
235
|
+
var checkedKeys;
|
|
236
|
+
if (existInChecked) {
|
|
237
|
+
var _conductCheck2 = conductCheck(nextRawCheckedKeys, {
|
|
238
|
+
checked: false,
|
|
239
|
+
halfCheckedKeys: halfCheckedPathKeys
|
|
240
|
+
}, pathKeyEntities);
|
|
241
|
+
checkedKeys = _conductCheck2.checkedKeys;
|
|
242
|
+
} else {
|
|
243
|
+
var _conductCheck3 = conductCheck(nextRawCheckedKeys, true, pathKeyEntities);
|
|
244
|
+
checkedKeys = _conductCheck3.checkedKeys;
|
|
245
|
+
}
|
|
246
|
+
// Roll up to parent level keys
|
|
247
|
+
var deDuplicatedKeys = formatStrategyValues(checkedKeys, getPathKeyEntities, showCheckedStrategy);
|
|
248
|
+
nextCheckedValues = getValueByKeyPath(deDuplicatedKeys);
|
|
249
|
+
}
|
|
250
|
+
triggerChange([].concat(_toConsumableArray(nextMissingValues), _toConsumableArray(nextCheckedValues)));
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
// Display Value change logic
|
|
254
|
+
var onDisplayValuesChange = function onDisplayValuesChange(_, info) {
|
|
255
|
+
if (info.type === "clear") {
|
|
256
|
+
triggerChange([]);
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
// Cascader do not support `add` type. Only support `remove`
|
|
260
|
+
var valueCells = info.values[0].valueCells;
|
|
261
|
+
onInternalSelect(valueCells);
|
|
262
|
+
};
|
|
263
|
+
// ============================ Open ============================
|
|
264
|
+
var mergedOpen = open !== undefined ? open : popupVisible;
|
|
265
|
+
var mergedDropdownClassName = dropdownClassName || popupClassName;
|
|
266
|
+
var mergedPlacement = placement || popupPlacement;
|
|
267
|
+
var onInternalDropdownVisibleChange = function onInternalDropdownVisibleChange(nextVisible) {
|
|
268
|
+
onDropdownVisibleChange === null || onDropdownVisibleChange === void 0 ? void 0 : onDropdownVisibleChange(nextVisible);
|
|
269
|
+
onPopupVisibleChange === null || onPopupVisibleChange === void 0 ? void 0 : onPopupVisibleChange(nextVisible);
|
|
270
|
+
};
|
|
271
|
+
// ========================== Warning ===========================
|
|
272
|
+
if (process.env.NODE_ENV !== "production") {
|
|
273
|
+
warningProps(props);
|
|
274
|
+
warningNullOptions(mergedOptions, mergedFieldNames);
|
|
275
|
+
}
|
|
276
|
+
// ========================== Context ===========================
|
|
277
|
+
var cascaderContext = React.useMemo(function () {
|
|
278
|
+
return {
|
|
279
|
+
options: mergedOptions,
|
|
280
|
+
fieldNames: mergedFieldNames,
|
|
281
|
+
values: checkedValues,
|
|
282
|
+
halfValues: halfCheckedValues,
|
|
283
|
+
changeOnSelect: changeOnSelect,
|
|
284
|
+
onSelect: onInternalSelect,
|
|
285
|
+
checkable: checkable,
|
|
286
|
+
searchOptions: searchOptions,
|
|
287
|
+
dropdownPrefixCls: dropdownPrefixCls,
|
|
288
|
+
loadData: loadData,
|
|
289
|
+
expandTrigger: expandTrigger,
|
|
290
|
+
expandIcon: expandIcon,
|
|
291
|
+
loadingIcon: loadingIcon,
|
|
292
|
+
dropdownMenuColumnStyle: dropdownMenuColumnStyle,
|
|
293
|
+
onScroll: onScroll,
|
|
294
|
+
onSrollBottom: onSrollBottom,
|
|
295
|
+
showColumnSearch: showColumnSearch,
|
|
296
|
+
onInputChange: onInputChange,
|
|
297
|
+
dropdownColumnRender: dropdownColumnRender,
|
|
298
|
+
isResetInputValue: isResetInputValue
|
|
299
|
+
};
|
|
300
|
+
}, [mergedOptions, mergedFieldNames, checkedValues, halfCheckedValues, changeOnSelect, onInternalSelect, checkable, searchOptions, dropdownPrefixCls, loadData, expandTrigger, expandIcon, loadingIcon, dropdownMenuColumnStyle, onScroll, onSrollBottom, showColumnSearch, onInputChange, dropdownColumnRender, isResetInputValue]);
|
|
301
|
+
// ==============================================================
|
|
302
|
+
// == Render ==
|
|
303
|
+
// ==============================================================
|
|
304
|
+
var emptyOptions = !(mergedSearchValue ? searchOptions : mergedOptions).length;
|
|
305
|
+
var dropdownStyle =
|
|
306
|
+
// Search to match width
|
|
307
|
+
mergedSearchValue && searchConfig.matchInputWidth ||
|
|
308
|
+
// Empty keep the width
|
|
309
|
+
emptyOptions ? {} : {
|
|
310
|
+
minWidth: "auto"
|
|
311
|
+
};
|
|
312
|
+
return /*#__PURE__*/React.createElement(CascaderContext.Provider, {
|
|
313
|
+
value: cascaderContext
|
|
314
|
+
}, /*#__PURE__*/React.createElement(BaseSelect, _extends({}, restProps, {
|
|
315
|
+
// MISC
|
|
316
|
+
ref: ref,
|
|
317
|
+
id: mergedId,
|
|
318
|
+
prefixCls: prefixCls,
|
|
319
|
+
dropdownMatchSelectWidth: dropdownMatchSelectWidth,
|
|
320
|
+
dropdownStyle: dropdownStyle
|
|
321
|
+
// Value
|
|
322
|
+
,
|
|
323
|
+
displayValues: displayValues,
|
|
324
|
+
onDisplayValuesChange: onDisplayValuesChange,
|
|
325
|
+
mode: multiple ? "multiple" : undefined
|
|
326
|
+
// Search
|
|
327
|
+
,
|
|
328
|
+
searchValue: mergedSearchValue,
|
|
329
|
+
onSearch: onInternalSearch,
|
|
330
|
+
showSearch: showColumnSearch ? false : mergedShowSearch // 列搜索开启时,关闭showSearch
|
|
331
|
+
// Options
|
|
332
|
+
,
|
|
333
|
+
OptionList: OptionList,
|
|
334
|
+
emptyOptions: emptyOptions
|
|
335
|
+
// Open
|
|
336
|
+
,
|
|
337
|
+
open: mergedOpen,
|
|
338
|
+
dropdownClassName: mergedDropdownClassName,
|
|
339
|
+
placement: mergedPlacement,
|
|
340
|
+
onDropdownVisibleChange: onInternalDropdownVisibleChange
|
|
341
|
+
// Children
|
|
342
|
+
,
|
|
343
|
+
getRawInputElement: function getRawInputElement() {
|
|
344
|
+
return children;
|
|
345
|
+
}
|
|
346
|
+
})));
|
|
347
|
+
});
|
|
348
|
+
if (process.env.NODE_ENV !== "production") {
|
|
349
|
+
Cascader.displayName = "Cascader";
|
|
350
|
+
}
|
|
351
|
+
Cascader.SHOW_PARENT = SHOW_PARENT;
|
|
352
|
+
Cascader.SHOW_CHILD = SHOW_CHILD;
|
|
353
|
+
export default Cascader;
|
|
@@ -0,0 +1,22 @@
|
|
|
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 _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; }
|
|
3
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
4
|
+
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); }
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
import classNames from "classnames";
|
|
7
|
+
import CascaderContext from "../context";
|
|
8
|
+
export default function Checkbox(_ref) {
|
|
9
|
+
var _classNames;
|
|
10
|
+
var prefixCls = _ref.prefixCls,
|
|
11
|
+
checked = _ref.checked,
|
|
12
|
+
halfChecked = _ref.halfChecked,
|
|
13
|
+
disabled = _ref.disabled,
|
|
14
|
+
onClick = _ref.onClick;
|
|
15
|
+
var _React$useContext = React.useContext(CascaderContext),
|
|
16
|
+
checkable = _React$useContext.checkable;
|
|
17
|
+
var customCheckbox = typeof checkable !== "boolean" ? checkable : null;
|
|
18
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
19
|
+
className: classNames("".concat(prefixCls), (_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-checked"), checked), _defineProperty(_classNames, "".concat(prefixCls, "-indeterminate"), !checked && halfChecked), _defineProperty(_classNames, "".concat(prefixCls, "-disabled"), disabled), _classNames)),
|
|
20
|
+
onClick: onClick
|
|
21
|
+
}, customCheckbox);
|
|
22
|
+
}
|