@chaoswise/ui 2.3.14 → 2.3.16
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 +6 -6
- package/lib/Ace/ace.js +1 -1
- package/lib/Ace/diff.js +1 -1
- package/lib/Ace/split.js +1 -1
- package/lib/AdaptiveLayout/index.js +4 -4
- package/lib/Antd/Drawer.js +4 -4
- package/lib/Antd4Form/FieldList.js +3 -3
- package/lib/Antd4Form/Form.js +1 -1
- package/lib/Antd4Form/FormItem.js +3 -3
- package/lib/Antd4Form/FormItemChildren.js +1 -1
- package/lib/Antd4Form/useForm.js +4 -4
- package/lib/BasicLayout/Breadcrumb.js +3 -3
- package/lib/BasicLayout/Sider.js +3 -3
- package/lib/BasicLayout/index.js +1 -1
- package/lib/CWCascader/Cascader/index.js +3 -3
- package/lib/CWCascader/rc-cascader/Cascader.js +3 -3
- package/lib/CWCascader/rc-cascader/OptionList/Checkbox.js +1 -1
- package/lib/CWCascader/rc-cascader/OptionList/Column.js +5 -5
- package/lib/CWCascader/rc-cascader/OptionList/index.js +6 -7
- package/lib/CWCascader/rc-cascader/OptionList/useActive.js +1 -1
- package/lib/CWCascader/rc-cascader/OptionList/useKeyboard.js +5 -6
- package/lib/CWCascader/rc-cascader/hooks/useDisplayValues.js +1 -1
- package/lib/CWCascader/rc-cascader/hooks/useEntities.js +3 -3
- package/lib/CWCascader/rc-cascader/hooks/useSearchConfig.js +3 -3
- package/lib/CWCascader/rc-cascader/hooks/useSearchOptions.js +3 -3
- package/lib/CWMessage/MessageContent/TabList/index.js +4 -4
- package/lib/CWMessage/MessageContent/index.js +6 -6
- package/lib/CWMessage/index.js +8 -8
- package/lib/CWRadioTabs/index.js +1 -1
- package/lib/CWRangePicker/DropdownMenu/index.js +4 -4
- package/lib/CWRangePicker/Refresh/index.js +4 -4
- package/lib/CWRangePicker/index.js +4 -4
- package/lib/CWRangePicker/utils/index.js +4 -4
- package/lib/CWSelect/DragTag/index.js +1 -1
- package/lib/CWSelect/antd-select.js +1 -1
- package/lib/CWSelect/index.js +4 -4
- package/lib/CWTable/CWTable.js +12 -12
- package/lib/CWTable/EditLine.js +4 -4
- package/lib/CWTable/Filter.js +1 -1
- package/lib/CWTable/FormTable.js +3 -3
- package/lib/CWTable/header.js +1 -1
- package/lib/CWTree/index.js +4 -4
- package/lib/CWTree/index.less +6 -0
- package/lib/CWTree/utils/index.js +3 -3
- package/lib/CWUpload/upload/DragList.js +2 -2
- package/lib/CWUpload/upload/Upload.js +2 -2
- package/lib/CWUpload/upload/UploadList.js +1 -1
- package/lib/CardSelect/index.js +1 -1
- package/lib/ChangeIcon/index.js +1 -1
- package/lib/Checkbox/Checkbox.js +3 -3
- package/lib/Checkbox/Group.js +1 -1
- package/lib/ColorPicker/index.js +4 -4
- package/lib/ConfigProvider/ConfigProvider.js +4 -4
- package/lib/CustomScrollBar/index.js +3 -3
- package/lib/DateRangePicker/RangeDatePicker.js +1 -1
- package/lib/DateRangePicker/RangeDateTimePicker.js +1 -1
- package/lib/DateRangePicker/components/ExtraTimeFooter.js +3 -3
- package/lib/DateRangePicker/utils/index.js +1 -1
- package/lib/Documentation/Tocify.js +1 -1
- package/lib/Documentation/index.js +4 -4
- package/lib/DropdownDatePicker/DropdownMenu/index.js +3 -3
- package/lib/DropdownDatePicker/index.js +4 -4
- package/lib/DropdownDatePicker/utils/index.js +4 -4
- package/lib/EchartsArea/index.js +3 -3
- package/lib/EchartsBar/index.js +3 -3
- package/lib/EchartsBase/index.js +3 -3
- package/lib/EchartsLine/index.js +3 -3
- package/lib/EditableText/index.js +1 -1
- package/lib/ErrorBoundary/history.js +1 -1
- package/lib/ErrorBoundary/index.js +1 -1
- package/lib/FilterDropDown/DragList.js +1 -1
- package/lib/FilterDropDown/index.js +1 -1
- package/lib/Flow/Flow.js +1 -1
- package/lib/Flow/components/PluginWrapper.js +1 -1
- package/lib/Flow/layouts/callChain.js +1 -1
- package/lib/Flow/plugins/CommandLifeCycle.js +1 -1
- package/lib/Flow/plugins/InitSideBarPlugin.js +1 -1
- package/lib/Flow/plugins/InitToolBarPlugin.js +1 -1
- package/lib/Form/FormItem.js +6 -5
- package/lib/FormItemWrapper/index.js +3 -3
- package/lib/Formily/FieldList/index.js +3 -3
- package/lib/Formily/FormItem/index.js +3 -3
- package/lib/Formily/FormItem/items/Upload.js +1 -1
- package/lib/Formily/FormItem/items/shared.js +1 -1
- package/lib/Formily/MegaLayout/index.js +3 -3
- package/lib/Formily/formily/index.js +1 -1
- package/lib/Formily/subscribeFields/index.js +4 -4
- package/lib/GlobalTabs/index.js +3 -3
- package/lib/Header/CommonDropMenu.js +1 -1
- package/lib/Header/CommonIcon.js +3 -3
- package/lib/Header/UserSetting/index.js +1 -1
- package/lib/Header/UserSetting/utils.js +3 -3
- package/lib/Header/index.js +3 -2
- package/lib/IconSelect/components/SearchIcon/index.js +1 -1
- package/lib/IconSelect/index.js +1 -1
- package/lib/Input/InputComponent.js +4 -7
- package/lib/IntersectionInput/index.js +4 -4
- package/lib/Joyride/index.js +4 -4
- package/lib/LayoutBreadcrumb/index.js +3 -3
- package/lib/LayoutWrapper/index.js +1 -1
- package/lib/LazyLoadingTreeSelect/index.js +4 -4
- package/lib/Menu/menu/MenuItem.js +1 -1
- package/lib/Menu/menu/SubMenu.js +1 -1
- package/lib/Menu/menu/index.js +1 -1
- package/lib/Modal/Modal.js +1 -1
- package/lib/Modal/custom-backup/entiretyDrag.js +3 -3
- package/lib/Modal/index.js +3 -3
- package/lib/ModuleFederation/ErrorBoundary/index.js +1 -1
- package/lib/ModuleFederation/react-dynamic-remote-component/RemoteComponent.js +6 -6
- package/lib/ModuleFederation/react-dynamic-remote-component/load-module.js +2 -2
- package/lib/Pagination/index.js +4 -4
- package/lib/PolymerizationSearch/index.js +1 -1
- package/lib/QuickRangePicker/index.js +2 -2
- package/lib/QuickTransfer/DragList.js +1 -1
- package/lib/QuickTransfer/TopicList.js +1 -1
- package/lib/QuickTransfer/index.js +4 -4
- package/lib/QuickTransfer/utils.js +23 -23
- package/lib/Radio/Group.js +1 -1
- package/lib/Radio/Radio.js +3 -3
- package/lib/RangePicker/components/ExtraTimeFooter.js +3 -3
- package/lib/RangePicker/index.js +2 -2
- package/lib/RangePicker/utils/index.js +1 -1
- package/lib/ReactSelect/customStyles.js +3 -3
- package/lib/ReactSelect/index.js +4 -4
- package/lib/ScrollLoad/index.js +1 -1
- package/lib/SearchBar/OutSearch.js +2 -1
- package/lib/SearchBar/index.js +4 -4
- package/lib/SelectBackup/index.js +4 -4
- package/lib/SiderMenu/Item.js +1 -1
- package/lib/SiderMenu/index.js +3 -3
- package/lib/SimplePagination/index.js +4 -4
- package/lib/SingleSpa/import-html/process-tpl.js +1 -1
- package/lib/SingleSpa/import-html/utils.js +2 -2
- package/lib/SingleSpa/index.js +5 -5
- package/lib/SingleSpa/singleSpa/single-spa.dev.js +1 -1
- package/lib/SingleSpa/system/amd.js +1 -1
- package/lib/SingleSpa/system/system.js +1 -1
- package/lib/Tabs/index.js +3 -3
- package/lib/ThemeProvider/main.js +4 -4
- package/lib/ThemeProvider/utils.js +2 -2
- package/lib/TooltipText/index.js +4 -4
- package/lib/TreeList/index.js +2 -2
- package/lib/TreeSelect111/index.js +4 -4
- package/lib/TreeSelect111/utils/index.js +3 -3
- package/lib/Upload-back/index.js +1 -1
- package/lib/WangEditor/release/wangEditor.js +1 -1
- package/lib/WangEditor/usePreview.js +1 -1
- package/lib/WangEditor/wangEditor.js +1 -1
- package/lib/message/index.js +3 -3
- package/lib/noticeManager/globalState.js +1 -1
- package/lib/portalNoticeManager/usePortalDispatchNotice.js +4 -4
- package/lib/useLocale/index.js +3 -3
- package/lib/usePreview/index.js +1 -1
- package/package.json +4 -4
- package/lib/Antd4/notification/index.copy.js +0 -302
- package/lib/Cascaders/Cascader/index.js +0 -208
- package/lib/Cascaders/index.js +0 -17
- package/lib/Cascaders/index.less +0 -1
- package/lib/Cascaders/rc-cascader/Cascader.js +0 -326
- package/lib/Cascaders/rc-cascader/OptionList/Checkbox.js +0 -22
- package/lib/Cascaders/rc-cascader/OptionList/Column.js +0 -203
- package/lib/Cascaders/rc-cascader/OptionList/index.js +0 -213
- package/lib/Cascaders/rc-cascader/OptionList/useActive.js +0 -33
- package/lib/Cascaders/rc-cascader/OptionList/useKeyboard.js +0 -171
- package/lib/Cascaders/rc-cascader/context.js +0 -3
- package/lib/Cascaders/rc-cascader/hooks/useDisplayValues.js +0 -56
- package/lib/Cascaders/rc-cascader/hooks/useEntities.js +0 -34
- package/lib/Cascaders/rc-cascader/hooks/useMissingValues.js +0 -19
- package/lib/Cascaders/rc-cascader/hooks/useRefFunc.js +0 -13
- package/lib/Cascaders/rc-cascader/hooks/useSearchConfig.js +0 -25
- package/lib/Cascaders/rc-cascader/hooks/useSearchOptions.js +0 -72
- package/lib/Cascaders/rc-cascader/index.js +0 -2
- package/lib/Cascaders/rc-cascader/utils/commonUtil.js +0 -54
- package/lib/Cascaders/rc-cascader/utils/treeUtil.js +0 -37
- package/lib/Cascaders/rc-cascader/utils/warningPropsUtil.js +0 -30
- package/lib/Empty/assets/emptyState.png +0 -0
- package/lib/Header/assets/icon2.png +0 -0
- package/lib/Menu/assets/arrow.png +0 -0
- package/lib/Menu/index.less +0 -81
- package/lib/SiderMenu/assets/arrow.png +0 -0
- package/lib/SiderMenu/assets/logo.svg +0 -58
- package/lib/SiderMenu/assets/rect-logo.png +0 -0
- package/lib/SiderMenu/utils.js +0 -29
|
@@ -1,213 +0,0 @@
|
|
|
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
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
6
|
-
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."); }
|
|
7
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
8
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
9
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
10
|
-
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."); }
|
|
11
|
-
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); }
|
|
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
|
-
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; } }
|
|
14
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
15
|
-
// @ts-nocheck
|
|
16
|
-
/* eslint-disable default-case */
|
|
17
|
-
import classNames from 'classnames';
|
|
18
|
-
import { useBaseProps } from 'rc-cascader/node_modules/rc-select';
|
|
19
|
-
import * as React from 'react';
|
|
20
|
-
import CascaderContext from '../context';
|
|
21
|
-
import { getFullPathKeys, isLeaf, scrollIntoParentView, toPathKey, toPathKeys, toPathValueStr } from '../utils/commonUtil';
|
|
22
|
-
import { toPathOptions } from '../utils/treeUtil';
|
|
23
|
-
import Column, { FIX_LABEL } from './Column';
|
|
24
|
-
import useActive from './useActive';
|
|
25
|
-
import useKeyboard from './useKeyboard';
|
|
26
|
-
var RefOptionList = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
27
|
-
var _ref3, _classNames;
|
|
28
|
-
var _a, _b;
|
|
29
|
-
var _useBaseProps = useBaseProps(),
|
|
30
|
-
prefixCls = _useBaseProps.prefixCls,
|
|
31
|
-
multiple = _useBaseProps.multiple,
|
|
32
|
-
searchValue = _useBaseProps.searchValue,
|
|
33
|
-
toggleOpen = _useBaseProps.toggleOpen,
|
|
34
|
-
notFoundContent = _useBaseProps.notFoundContent,
|
|
35
|
-
direction = _useBaseProps.direction;
|
|
36
|
-
var containerRef = React.useRef();
|
|
37
|
-
var rtl = direction === 'rtl';
|
|
38
|
-
var _React$useContext = React.useContext(CascaderContext),
|
|
39
|
-
options = _React$useContext.options,
|
|
40
|
-
values = _React$useContext.values,
|
|
41
|
-
halfValues = _React$useContext.halfValues,
|
|
42
|
-
fieldNames = _React$useContext.fieldNames,
|
|
43
|
-
changeOnSelect = _React$useContext.changeOnSelect,
|
|
44
|
-
onSelect = _React$useContext.onSelect,
|
|
45
|
-
searchOptions = _React$useContext.searchOptions,
|
|
46
|
-
dropdownPrefixCls = _React$useContext.dropdownPrefixCls,
|
|
47
|
-
loadData = _React$useContext.loadData,
|
|
48
|
-
expandTrigger = _React$useContext.expandTrigger;
|
|
49
|
-
var mergedPrefixCls = dropdownPrefixCls || prefixCls;
|
|
50
|
-
// ========================= loadData =========================
|
|
51
|
-
var _React$useState = React.useState([]),
|
|
52
|
-
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
53
|
-
loadingKeys = _React$useState2[0],
|
|
54
|
-
setLoadingKeys = _React$useState2[1];
|
|
55
|
-
var internalLoadData = function internalLoadData(valueCells) {
|
|
56
|
-
// Do not load when search
|
|
57
|
-
if (!loadData || searchValue) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
var optionList = toPathOptions(valueCells, options, fieldNames);
|
|
61
|
-
var rawOptions = optionList.map(function (_ref) {
|
|
62
|
-
var option = _ref.option;
|
|
63
|
-
return option;
|
|
64
|
-
});
|
|
65
|
-
var lastOption = rawOptions[rawOptions.length - 1];
|
|
66
|
-
if (lastOption && !isLeaf(lastOption, fieldNames)) {
|
|
67
|
-
var pathKey = toPathKey(valueCells);
|
|
68
|
-
setLoadingKeys(function (keys) {
|
|
69
|
-
return [].concat(_toConsumableArray(keys), [pathKey]);
|
|
70
|
-
});
|
|
71
|
-
loadData(rawOptions);
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
// zombieJ: This is bad. We should make this same as `rc-tree` to use Promise instead.
|
|
75
|
-
React.useEffect(function () {
|
|
76
|
-
if (loadingKeys.length) {
|
|
77
|
-
loadingKeys.forEach(function (loadingKey) {
|
|
78
|
-
var valueStrCells = toPathValueStr(loadingKey);
|
|
79
|
-
var optionList = toPathOptions(valueStrCells, options, fieldNames, true).map(function (_ref2) {
|
|
80
|
-
var option = _ref2.option;
|
|
81
|
-
return option;
|
|
82
|
-
});
|
|
83
|
-
var lastOption = optionList[optionList.length - 1];
|
|
84
|
-
if (!lastOption || lastOption[fieldNames.children] || isLeaf(lastOption, fieldNames)) {
|
|
85
|
-
setLoadingKeys(function (keys) {
|
|
86
|
-
return keys.filter(function (key) {
|
|
87
|
-
return key !== loadingKey;
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
}, [options, loadingKeys, fieldNames]);
|
|
94
|
-
// ========================== Values ==========================
|
|
95
|
-
var checkedSet = React.useMemo(function () {
|
|
96
|
-
return new Set(toPathKeys(values));
|
|
97
|
-
}, [values]);
|
|
98
|
-
var halfCheckedSet = React.useMemo(function () {
|
|
99
|
-
return new Set(toPathKeys(halfValues));
|
|
100
|
-
}, [halfValues]);
|
|
101
|
-
// ====================== Accessibility =======================
|
|
102
|
-
var _useActive = useActive(),
|
|
103
|
-
_useActive2 = _slicedToArray(_useActive, 2),
|
|
104
|
-
activeValueCells = _useActive2[0],
|
|
105
|
-
setActiveValueCells = _useActive2[1];
|
|
106
|
-
// =========================== Path ===========================
|
|
107
|
-
var onPathOpen = function onPathOpen(nextValueCells) {
|
|
108
|
-
setActiveValueCells(nextValueCells);
|
|
109
|
-
// Trigger loadData
|
|
110
|
-
internalLoadData(nextValueCells);
|
|
111
|
-
};
|
|
112
|
-
var isSelectable = function isSelectable(option) {
|
|
113
|
-
var disabled = option.disabled;
|
|
114
|
-
var isMergedLeaf = isLeaf(option, fieldNames);
|
|
115
|
-
return !disabled && (isMergedLeaf || changeOnSelect || multiple);
|
|
116
|
-
};
|
|
117
|
-
var onPathSelect = function onPathSelect(valuePath, leaf) {
|
|
118
|
-
var fromKeyboard = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
119
|
-
onSelect(valuePath);
|
|
120
|
-
if (!multiple && (leaf || changeOnSelect && (expandTrigger === 'hover' || fromKeyboard))) {
|
|
121
|
-
toggleOpen(false);
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
// ========================== Option ==========================
|
|
125
|
-
var mergedOptions = React.useMemo(function () {
|
|
126
|
-
if (searchValue) {
|
|
127
|
-
return searchOptions;
|
|
128
|
-
}
|
|
129
|
-
return options;
|
|
130
|
-
}, [searchValue, searchOptions, options]);
|
|
131
|
-
// ========================== Column ==========================
|
|
132
|
-
var optionColumns = React.useMemo(function () {
|
|
133
|
-
var optionList = [{
|
|
134
|
-
options: mergedOptions
|
|
135
|
-
}];
|
|
136
|
-
var currentList = mergedOptions;
|
|
137
|
-
var fullPathKeys = getFullPathKeys(currentList, fieldNames);
|
|
138
|
-
var _loop = function _loop() {
|
|
139
|
-
var activeValueCell = activeValueCells[i];
|
|
140
|
-
var currentOption = currentList.find(function (option, index) {
|
|
141
|
-
return (fullPathKeys[index] ? toPathKey(fullPathKeys[index]) : option[fieldNames.value]) === activeValueCell;
|
|
142
|
-
});
|
|
143
|
-
var subOptions = currentOption === null || currentOption === void 0 ? void 0 : currentOption[fieldNames.children];
|
|
144
|
-
if (!(subOptions === null || subOptions === void 0 ? void 0 : subOptions.length)) {
|
|
145
|
-
return "break";
|
|
146
|
-
}
|
|
147
|
-
currentList = subOptions;
|
|
148
|
-
optionList.push({
|
|
149
|
-
options: subOptions
|
|
150
|
-
});
|
|
151
|
-
};
|
|
152
|
-
for (var i = 0; i < activeValueCells.length; i += 1) {
|
|
153
|
-
var _ret = _loop();
|
|
154
|
-
if (_ret === "break") break;
|
|
155
|
-
}
|
|
156
|
-
return optionList;
|
|
157
|
-
}, [mergedOptions, activeValueCells, fieldNames]);
|
|
158
|
-
// ========================= Keyboard =========================
|
|
159
|
-
var onKeyboardSelect = function onKeyboardSelect(selectValueCells, option) {
|
|
160
|
-
if (isSelectable(option)) {
|
|
161
|
-
onPathSelect(selectValueCells, isLeaf(option, fieldNames), true);
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
useKeyboard(ref, mergedOptions, fieldNames, activeValueCells, onPathOpen, onKeyboardSelect);
|
|
165
|
-
// >>>>> Active Scroll
|
|
166
|
-
React.useEffect(function () {
|
|
167
|
-
var _a;
|
|
168
|
-
for (var i = 0; i < activeValueCells.length; i += 1) {
|
|
169
|
-
var cellPath = activeValueCells.slice(0, i + 1);
|
|
170
|
-
var cellKeyPath = toPathKey(cellPath);
|
|
171
|
-
var ele = (_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.querySelector("li[data-path-key=\"".concat(cellKeyPath.replace(/\\{0,2}"/g, '\\"'), "\"]"));
|
|
172
|
-
if (ele) {
|
|
173
|
-
scrollIntoParentView(ele);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}, [activeValueCells]);
|
|
177
|
-
// ========================== Render ==========================
|
|
178
|
-
// >>>>> Empty
|
|
179
|
-
var isEmpty = !((_b = (_a = optionColumns[0]) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.length);
|
|
180
|
-
var emptyList = [(_ref3 = {}, _defineProperty(_ref3, fieldNames.value, '__EMPTY__'), _defineProperty(_ref3, FIX_LABEL, notFoundContent), _defineProperty(_ref3, "disabled", true), _ref3)];
|
|
181
|
-
var columnProps = Object.assign(Object.assign({}, props), {
|
|
182
|
-
multiple: !isEmpty && multiple,
|
|
183
|
-
onSelect: onPathSelect,
|
|
184
|
-
onActive: onPathOpen,
|
|
185
|
-
onToggleOpen: toggleOpen,
|
|
186
|
-
checkedSet: checkedSet,
|
|
187
|
-
halfCheckedSet: halfCheckedSet,
|
|
188
|
-
loadingKeys: loadingKeys,
|
|
189
|
-
isSelectable: isSelectable
|
|
190
|
-
});
|
|
191
|
-
// >>>>> Columns
|
|
192
|
-
var mergedOptionColumns = isEmpty ? [{
|
|
193
|
-
options: emptyList
|
|
194
|
-
}] : optionColumns;
|
|
195
|
-
var columnNodes = mergedOptionColumns.map(function (col, index) {
|
|
196
|
-
var prevValuePath = activeValueCells.slice(0, index);
|
|
197
|
-
var activeValue = activeValueCells[index];
|
|
198
|
-
return /*#__PURE__*/React.createElement(Column, Object.assign({
|
|
199
|
-
key: index
|
|
200
|
-
}, columnProps, {
|
|
201
|
-
prefixCls: mergedPrefixCls,
|
|
202
|
-
options: col.options,
|
|
203
|
-
prevValuePath: prevValuePath,
|
|
204
|
-
activeValue: activeValue
|
|
205
|
-
}));
|
|
206
|
-
});
|
|
207
|
-
// >>>>> Render
|
|
208
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
209
|
-
className: classNames("".concat(mergedPrefixCls, "-menus"), (_classNames = {}, _defineProperty(_classNames, "".concat(mergedPrefixCls, "-menu-empty"), isEmpty), _defineProperty(_classNames, "".concat(mergedPrefixCls, "-rtl"), rtl), _classNames)),
|
|
210
|
-
ref: containerRef
|
|
211
|
-
}, columnNodes);
|
|
212
|
-
});
|
|
213
|
-
export default RefOptionList;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
-
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."); }
|
|
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 _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; }
|
|
5
|
-
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; } }
|
|
6
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
-
import * as React from 'react';
|
|
8
|
-
import CascaderContext from '../context';
|
|
9
|
-
import { useBaseProps } from 'rc-cascader/node_modules/rc-select';
|
|
10
|
-
/**
|
|
11
|
-
* Control the active open options path.
|
|
12
|
-
*/
|
|
13
|
-
export default (function () {
|
|
14
|
-
var _useBaseProps = useBaseProps(),
|
|
15
|
-
multiple = _useBaseProps.multiple,
|
|
16
|
-
open = _useBaseProps.open;
|
|
17
|
-
var _React$useContext = React.useContext(CascaderContext),
|
|
18
|
-
values = _React$useContext.values;
|
|
19
|
-
// Record current dropdown active options
|
|
20
|
-
// This also control the open status
|
|
21
|
-
var _React$useState = React.useState([]),
|
|
22
|
-
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
23
|
-
activeValueCells = _React$useState2[0],
|
|
24
|
-
setActiveValueCells = _React$useState2[1];
|
|
25
|
-
React.useEffect(function () {
|
|
26
|
-
if (open && !multiple) {
|
|
27
|
-
var firstValueCells = values[0];
|
|
28
|
-
setActiveValueCells(firstValueCells || []);
|
|
29
|
-
}
|
|
30
|
-
}, /* eslint-disable react-hooks/exhaustive-deps */
|
|
31
|
-
[open]);
|
|
32
|
-
return [activeValueCells, setActiveValueCells];
|
|
33
|
-
});
|
|
@@ -1,171 +0,0 @@
|
|
|
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 * as React from 'react';
|
|
13
|
-
import { getFullPathKeys, toPathKey } from '../utils/commonUtil';
|
|
14
|
-
export default (function (ref, options, fieldNames, activeValueCells, setActiveValueCells, onKeyBoardSelect) {
|
|
15
|
-
var _useBaseProps = useBaseProps(),
|
|
16
|
-
direction = _useBaseProps.direction,
|
|
17
|
-
searchValue = _useBaseProps.searchValue,
|
|
18
|
-
toggleOpen = _useBaseProps.toggleOpen,
|
|
19
|
-
open = _useBaseProps.open;
|
|
20
|
-
var rtl = direction === 'rtl';
|
|
21
|
-
var _React$useMemo = React.useMemo(function () {
|
|
22
|
-
var activeIndex = -1;
|
|
23
|
-
var currentOptions = options;
|
|
24
|
-
var mergedActiveIndexes = [];
|
|
25
|
-
var mergedActiveValueCells = [];
|
|
26
|
-
var len = activeValueCells.length;
|
|
27
|
-
var pathKeys = getFullPathKeys(options, fieldNames);
|
|
28
|
-
// Fill validate active value cells and index
|
|
29
|
-
var _loop = function _loop(i) {
|
|
30
|
-
// Mark the active index for current options
|
|
31
|
-
var nextActiveIndex = currentOptions.findIndex(function (option, index) {
|
|
32
|
-
return (pathKeys[index] ? toPathKey(pathKeys[index]) : option[fieldNames.value]) === activeValueCells[i];
|
|
33
|
-
});
|
|
34
|
-
if (nextActiveIndex === -1) {
|
|
35
|
-
return "break";
|
|
36
|
-
}
|
|
37
|
-
activeIndex = nextActiveIndex;
|
|
38
|
-
mergedActiveIndexes.push(activeIndex);
|
|
39
|
-
mergedActiveValueCells.push(activeValueCells[i]);
|
|
40
|
-
currentOptions = currentOptions[activeIndex][fieldNames.children];
|
|
41
|
-
};
|
|
42
|
-
for (var i = 0; i < len && currentOptions; i += 1) {
|
|
43
|
-
var _ret = _loop(i);
|
|
44
|
-
if (_ret === "break") break;
|
|
45
|
-
}
|
|
46
|
-
// Fill last active options
|
|
47
|
-
var activeOptions = options;
|
|
48
|
-
for (var _i2 = 0; _i2 < mergedActiveIndexes.length - 1; _i2 += 1) {
|
|
49
|
-
activeOptions = activeOptions[mergedActiveIndexes[_i2]][fieldNames.children];
|
|
50
|
-
}
|
|
51
|
-
return [mergedActiveValueCells, activeIndex, activeOptions, pathKeys];
|
|
52
|
-
}, [activeValueCells, fieldNames, options]),
|
|
53
|
-
_React$useMemo2 = _slicedToArray(_React$useMemo, 4),
|
|
54
|
-
validActiveValueCells = _React$useMemo2[0],
|
|
55
|
-
lastActiveIndex = _React$useMemo2[1],
|
|
56
|
-
lastActiveOptions = _React$useMemo2[2],
|
|
57
|
-
fullPathKeys = _React$useMemo2[3];
|
|
58
|
-
// Update active value cells and scroll to target element
|
|
59
|
-
var internalSetActiveValueCells = function internalSetActiveValueCells(next) {
|
|
60
|
-
setActiveValueCells(next);
|
|
61
|
-
};
|
|
62
|
-
// Same options offset
|
|
63
|
-
var offsetActiveOption = function offsetActiveOption(offset) {
|
|
64
|
-
var len = lastActiveOptions.length;
|
|
65
|
-
var currentIndex = lastActiveIndex;
|
|
66
|
-
if (currentIndex === -1 && offset < 0) {
|
|
67
|
-
currentIndex = len;
|
|
68
|
-
}
|
|
69
|
-
for (var i = 0; i < len; i += 1) {
|
|
70
|
-
currentIndex = (currentIndex + offset + len) % len;
|
|
71
|
-
var option = lastActiveOptions[currentIndex];
|
|
72
|
-
if (option && !option.disabled) {
|
|
73
|
-
var nextActiveCells = validActiveValueCells.slice(0, -1).concat(fullPathKeys[currentIndex] ? toPathKey(fullPathKeys[currentIndex]) : option[fieldNames.value]);
|
|
74
|
-
internalSetActiveValueCells(nextActiveCells);
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
// Different options offset
|
|
80
|
-
var prevColumn = function prevColumn() {
|
|
81
|
-
if (validActiveValueCells.length > 1) {
|
|
82
|
-
var nextActiveCells = validActiveValueCells.slice(0, -1);
|
|
83
|
-
internalSetActiveValueCells(nextActiveCells);
|
|
84
|
-
} else {
|
|
85
|
-
toggleOpen(false);
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
var nextColumn = function nextColumn() {
|
|
89
|
-
var _a;
|
|
90
|
-
var nextOptions = ((_a = lastActiveOptions[lastActiveIndex]) === null || _a === void 0 ? void 0 : _a[fieldNames.children]) || [];
|
|
91
|
-
var nextOption = nextOptions.find(function (option) {
|
|
92
|
-
return !option.disabled;
|
|
93
|
-
});
|
|
94
|
-
if (nextOption) {
|
|
95
|
-
var nextActiveCells = [].concat(_toConsumableArray(validActiveValueCells), [nextOption[fieldNames.value]]);
|
|
96
|
-
internalSetActiveValueCells(nextActiveCells);
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
React.useImperativeHandle(ref, function () {
|
|
100
|
-
return {
|
|
101
|
-
// scrollTo: treeRef.current?.scrollTo,
|
|
102
|
-
onKeyDown: function onKeyDown(event) {
|
|
103
|
-
var which = event.which;
|
|
104
|
-
// switch (which) {
|
|
105
|
-
// // >>> Arrow keys
|
|
106
|
-
// case KeyCode.UP:
|
|
107
|
-
// case KeyCode.DOWN: {
|
|
108
|
-
// let offset = 0;
|
|
109
|
-
// if (which === KeyCode.UP) {
|
|
110
|
-
// offset = -1;
|
|
111
|
-
// } else if (which === KeyCode.DOWN) {
|
|
112
|
-
// offset = 1;
|
|
113
|
-
// }
|
|
114
|
-
// if (offset !== 0) {
|
|
115
|
-
// offsetActiveOption(offset);
|
|
116
|
-
// }
|
|
117
|
-
// break;
|
|
118
|
-
// }
|
|
119
|
-
// case KeyCode.LEFT: {
|
|
120
|
-
// if (rtl) {
|
|
121
|
-
// nextColumn();
|
|
122
|
-
// } else {
|
|
123
|
-
// prevColumn();
|
|
124
|
-
// }
|
|
125
|
-
// break;
|
|
126
|
-
// }
|
|
127
|
-
// case KeyCode.RIGHT: {
|
|
128
|
-
// if (rtl) {
|
|
129
|
-
// prevColumn();
|
|
130
|
-
// } else {
|
|
131
|
-
// nextColumn();
|
|
132
|
-
// }
|
|
133
|
-
// break;
|
|
134
|
-
// }
|
|
135
|
-
// case KeyCode.BACKSPACE: {
|
|
136
|
-
// if (!searchValue && !showColumnSearch) {
|
|
137
|
-
// prevColumn();
|
|
138
|
-
// }
|
|
139
|
-
// break;
|
|
140
|
-
// }
|
|
141
|
-
// // >>> Select
|
|
142
|
-
// case KeyCode.ENTER: {
|
|
143
|
-
// if (validActiveValueCells.length) {
|
|
144
|
-
// const option = lastActiveOptions[lastActiveIndex];
|
|
145
|
-
// // Search option should revert back of origin options
|
|
146
|
-
// const originOptions: DefaultOptionType[] = option?.[SEARCH_MARK] || [];
|
|
147
|
-
// if (originOptions.length) {
|
|
148
|
-
// onKeyBoardSelect(
|
|
149
|
-
// originOptions.map(opt => opt[fieldNames.value]),
|
|
150
|
-
// originOptions[originOptions.length - 1],
|
|
151
|
-
// );
|
|
152
|
-
// } else {
|
|
153
|
-
// onKeyBoardSelect(validActiveValueCells, lastActiveOptions[lastActiveIndex]);
|
|
154
|
-
// }
|
|
155
|
-
// }
|
|
156
|
-
// break;
|
|
157
|
-
// }
|
|
158
|
-
// // >>> Close
|
|
159
|
-
// case KeyCode.ESC: {
|
|
160
|
-
// toggleOpen(false);
|
|
161
|
-
// if (open) {
|
|
162
|
-
// event.stopPropagation();
|
|
163
|
-
// }
|
|
164
|
-
// }
|
|
165
|
-
// }
|
|
166
|
-
},
|
|
167
|
-
|
|
168
|
-
onKeyUp: function onKeyUp() {}
|
|
169
|
-
};
|
|
170
|
-
});
|
|
171
|
-
});
|
|
@@ -1,56 +0,0 @@
|
|
|
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) {
|
|
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 _a, _b;
|
|
36
|
-
var valueOptions = toPathOptions(valueCells, options, fieldNames);
|
|
37
|
-
var label = mergedDisplayRender(valueOptions.map(function (_ref) {
|
|
38
|
-
var option = _ref.option,
|
|
39
|
-
value = _ref.value;
|
|
40
|
-
var _a;
|
|
41
|
-
return (_a = option === null || option === void 0 ? void 0 : option[fieldNames.label]) !== null && _a !== void 0 ? _a : value;
|
|
42
|
-
}), valueOptions.map(function (_ref2) {
|
|
43
|
-
var option = _ref2.option;
|
|
44
|
-
return option;
|
|
45
|
-
}));
|
|
46
|
-
var value = toPathKey(valueCells);
|
|
47
|
-
return {
|
|
48
|
-
label: label,
|
|
49
|
-
value: value,
|
|
50
|
-
key: value,
|
|
51
|
-
valueCells: valueCells,
|
|
52
|
-
disabled: (_b = (_a = valueOptions[valueOptions.length - 1]) === null || _a === void 0 ? void 0 : _a.option) === null || _b === void 0 ? void 0 : _b.disabled
|
|
53
|
-
};
|
|
54
|
-
});
|
|
55
|
-
}, [rawValues, options, fieldNames, displayRender, multiple]);
|
|
56
|
-
});
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { convertDataToEntities } from 'rc-cascader/node_modules/rc-tree/lib/utils/treeUtil';
|
|
3
|
-
import { VALUE_SPLIT } from '../utils/commonUtil';
|
|
4
|
-
/** Lazy parse options data into conduct-able info to avoid perf issue in single mode */
|
|
5
|
-
export default (function (options, fieldNames) {
|
|
6
|
-
var cacheRef = React.useRef({
|
|
7
|
-
options: null,
|
|
8
|
-
info: null
|
|
9
|
-
});
|
|
10
|
-
var getEntities = React.useCallback(function () {
|
|
11
|
-
if (cacheRef.current.options !== options) {
|
|
12
|
-
cacheRef.current.options = options;
|
|
13
|
-
cacheRef.current.info = convertDataToEntities(options, {
|
|
14
|
-
fieldNames: fieldNames,
|
|
15
|
-
initWrapper: function initWrapper(wrapper) {
|
|
16
|
-
return Object.assign(Object.assign({}, wrapper), {
|
|
17
|
-
pathKeyEntities: {}
|
|
18
|
-
});
|
|
19
|
-
},
|
|
20
|
-
processEntity: function processEntity(entity, wrapper) {
|
|
21
|
-
var pathKey = entity.nodes.map(function (node) {
|
|
22
|
-
return node[fieldNames.value];
|
|
23
|
-
}).join(VALUE_SPLIT);
|
|
24
|
-
wrapper.pathKeyEntities[pathKey] = entity;
|
|
25
|
-
// Overwrite origin key.
|
|
26
|
-
// this is very hack but we need let conduct logic work with connect path
|
|
27
|
-
entity.key = pathKey;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
return cacheRef.current.info.pathKeyEntities;
|
|
32
|
-
}, [fieldNames, options]);
|
|
33
|
-
return getEntities;
|
|
34
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,13 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
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
|
-
import * as React from 'react';
|
|
3
|
-
import warning from 'rc-util/lib/warning';
|
|
4
|
-
// Convert `showSearch` to unique config
|
|
5
|
-
export default function useSearchConfig(showSearch) {
|
|
6
|
-
return React.useMemo(function () {
|
|
7
|
-
if (!showSearch) {
|
|
8
|
-
return [false, {}];
|
|
9
|
-
}
|
|
10
|
-
var searchConfig = {
|
|
11
|
-
matchInputWidth: true,
|
|
12
|
-
limit: 50
|
|
13
|
-
};
|
|
14
|
-
if (showSearch && _typeof(showSearch) === 'object') {
|
|
15
|
-
searchConfig = Object.assign(Object.assign({}, searchConfig), showSearch);
|
|
16
|
-
}
|
|
17
|
-
if (searchConfig.limit <= 0) {
|
|
18
|
-
delete searchConfig.limit;
|
|
19
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
20
|
-
warning(false, "'limit' of showSearch should be positive number or false.");
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return [true, searchConfig];
|
|
24
|
-
}, [showSearch]);
|
|
25
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
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
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
6
|
-
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."); }
|
|
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 _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
9
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
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
|
-
import * as React from 'react';
|
|
12
|
-
export var SEARCH_MARK = '__rc_cascader_search_mark__';
|
|
13
|
-
var defaultFilter = function defaultFilter(search, options, _ref) {
|
|
14
|
-
var label = _ref.label;
|
|
15
|
-
return options.some(function (opt) {
|
|
16
|
-
return String(opt[label]).toLowerCase().includes(search.toLowerCase());
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
var defaultRender = function defaultRender(inputValue, path, prefixCls, fieldNames) {
|
|
20
|
-
return path.map(function (opt) {
|
|
21
|
-
return opt[fieldNames.label];
|
|
22
|
-
}).join(' / ');
|
|
23
|
-
};
|
|
24
|
-
export default (function (search, options, fieldNames, prefixCls, config, changeOnSelect) {
|
|
25
|
-
var _config$filter = config.filter,
|
|
26
|
-
filter = _config$filter === void 0 ? defaultFilter : _config$filter,
|
|
27
|
-
_config$render = config.render,
|
|
28
|
-
render = _config$render === void 0 ? defaultRender : _config$render,
|
|
29
|
-
_config$limit = config.limit,
|
|
30
|
-
limit = _config$limit === void 0 ? 50 : _config$limit,
|
|
31
|
-
sort = config.sort;
|
|
32
|
-
return React.useMemo(function () {
|
|
33
|
-
var filteredOptions = [];
|
|
34
|
-
if (!search) {
|
|
35
|
-
return [];
|
|
36
|
-
}
|
|
37
|
-
function dig(list, pathOptions) {
|
|
38
|
-
list.forEach(function (option) {
|
|
39
|
-
// Perf saving when `sort` is disabled and `limit` is provided
|
|
40
|
-
if (!sort && limit > 0 && filteredOptions.length >= limit) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
var connectedPathOptions = [].concat(_toConsumableArray(pathOptions), [option]);
|
|
44
|
-
var children = option[fieldNames.children];
|
|
45
|
-
// If current option is filterable
|
|
46
|
-
if (
|
|
47
|
-
// If is leaf option
|
|
48
|
-
!children || children.length === 0 ||
|
|
49
|
-
// If is changeOnSelect
|
|
50
|
-
changeOnSelect) {
|
|
51
|
-
if (filter(search, connectedPathOptions, {
|
|
52
|
-
label: fieldNames.label
|
|
53
|
-
})) {
|
|
54
|
-
var _Object$assign;
|
|
55
|
-
filteredOptions.push(Object.assign(Object.assign({}, option), (_Object$assign = {}, _defineProperty(_Object$assign, fieldNames.label, render(search, connectedPathOptions, prefixCls, fieldNames)), _defineProperty(_Object$assign, SEARCH_MARK, connectedPathOptions), _Object$assign)));
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
if (children) {
|
|
59
|
-
dig(option[fieldNames.children], connectedPathOptions);
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
dig(options, []);
|
|
64
|
-
// Do sort
|
|
65
|
-
if (sort) {
|
|
66
|
-
filteredOptions.sort(function (a, b) {
|
|
67
|
-
return sort(a[SEARCH_MARK], b[SEARCH_MARK], search, fieldNames);
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
return limit > 0 ? filteredOptions.slice(0, limit) : filteredOptions;
|
|
71
|
-
}, [search, options, fieldNames, prefixCls, render, changeOnSelect, filter, sort, limit]);
|
|
72
|
-
});
|