@chaoswise/ui 2.3.0 → 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.
Files changed (41) hide show
  1. package/lib/Button/index.js +0 -8
  2. package/lib/CWCascader/index.js +56 -1
  3. package/lib/CWCascader/index.less +22 -0
  4. package/lib/CWCascader/rc-cascader/Cascader.js +45 -21
  5. package/lib/CWCascader/rc-cascader/OptionList/Column.js +115 -48
  6. package/lib/CWCascader/rc-cascader/OptionList/index.js +11 -5
  7. package/lib/CWCascader/rc-cascader/OptionList/useKeyboard.js +64 -68
  8. package/lib/CWCascader/rc-cascader/hooks/useDisplayValues.js +45 -16
  9. package/lib/CWCascader/rc-cascader/hooks/useEntities.js +0 -8
  10. package/lib/CWCascader/rc-cascader/utils/treeUtil.js +45 -1
  11. package/lib/CWRangePicker/DropdownMenu/index.js +1 -1
  12. package/lib/CWRangePicker/DropdownMenu/index.less +11 -7
  13. package/lib/CWRangePicker/index.js +24 -28
  14. package/lib/CWSelect/index.less +1 -1
  15. package/lib/Cascader/index.less +20 -2
  16. package/lib/DropdownDatePicker/DropdownMenu/MoreTimeList/index.js +46 -0
  17. package/lib/DropdownDatePicker/DropdownMenu/MoreTimeList/index.less +14 -0
  18. package/lib/DropdownDatePicker/DropdownMenu/index.js +126 -0
  19. package/lib/DropdownDatePicker/DropdownMenu/index.less +68 -0
  20. package/lib/DropdownDatePicker/assets/Calendar2.js +15 -0
  21. package/lib/DropdownDatePicker/assets/live.js +19 -0
  22. package/lib/DropdownDatePicker/assets/more.js +23 -0
  23. package/lib/DropdownDatePicker/index.js +281 -0
  24. package/lib/DropdownDatePicker/index.less +34 -0
  25. package/lib/DropdownDatePicker/locale/en_US.js +20 -0
  26. package/lib/DropdownDatePicker/locale/index.js +12 -0
  27. package/lib/DropdownDatePicker/locale/zh_CN.js +20 -0
  28. package/lib/DropdownDatePicker/utils/index.js +247 -0
  29. package/lib/InputNumber/index.js +15 -11
  30. package/lib/ModuleFederation/ErrorBoundary/index.js +54 -0
  31. package/lib/ModuleFederation/index.js +10 -0
  32. package/lib/ModuleFederation/react-dynamic-remote-component/RemoteComponent.js +185 -0
  33. package/lib/ModuleFederation/react-dynamic-remote-component/attach-script.js +42 -0
  34. package/lib/ModuleFederation/react-dynamic-remote-component/index.js +1 -0
  35. package/lib/ModuleFederation/react-dynamic-remote-component/load-module.js +44 -0
  36. package/lib/ModuleFederation/react-dynamic-remote-component/loading-script.js +35 -0
  37. package/lib/ModuleFederation/react-dynamic-remote-component/suspend.js +28 -0
  38. package/lib/ModuleFederation/react-dynamic-remote-component/utils.js +7 -0
  39. package/lib/QuickTransfer/locale/index.js +1 -4
  40. package/lib/QuickTransfer/locale/zh_CN.js +0 -8
  41. package/package.json +3 -2
@@ -4,14 +4,6 @@ var _excluded = ["mainType", "className"];
4
4
  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); }
5
5
  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; }
6
6
  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; }
7
- /*
8
- * @Author: andrew.qiao andrew.qiao@cloudwise.com
9
- * @Date: 2022-12-27 17:34:03
10
- * @LastEditors: andrew.qiao andrew.qiao@cloudwise.com
11
- * @LastEditTime: 2023-01-10 16:22:47
12
- * @FilePath: /change_01/aops_web_commons/packages/ui/components/Button/index.js
13
- * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
14
- */
15
7
  import React, { forwardRef } from "react";
16
8
  import PropTypes from "prop-types";
17
9
  import classnames from "classnames";
@@ -1,5 +1,60 @@
1
+ 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); }
2
+ import React, { forwardRef } from "react";
1
3
  import Cascader from "./Cascader";
4
+ import PropTypes from "prop-types";
2
5
  import "antd/es/cascader/style/index.less";
3
6
  import "../Antd4/cascader/style/index.less";
4
7
  import "./index.less";
5
- export default Cascader;
8
+ var CWCascader = /*#__PURE__*/forwardRef(function (props, ref) {
9
+ return /*#__PURE__*/React.createElement(Cascader, _extends({}, props, {
10
+ ref: ref
11
+ }));
12
+ });
13
+ CWCascader.SHOW_CHILD = Cascader.SHOW_CHILD;
14
+ CWCascader.SHOW_PARENT = Cascader.SHOW_PARENT;
15
+ CWCascader.defaultProps = {
16
+ showColumnSearch: false,
17
+ labelInValue: false,
18
+ showCheckedStrategy: CWCascader.SHOW_PARENT
19
+ };
20
+ CWCascader.propTypes = {
21
+ /**
22
+ * 级联选择器是否每列都可搜索(需要后端搜索时使用),默认为false
23
+ */
24
+ showColumnSearch: PropTypes.bool,
25
+ /**
26
+ * 是否把每个选项的 label 包装到 value 中,从 array 变为 { value: array, label: string } 的格式,默认为false
27
+ */
28
+ labelInValue: PropTypes.bool,
29
+ /**
30
+ * 是否重置第一列value
31
+ */
32
+ isResetInputValue: PropTypes.bool,
33
+ // todo: 后面要完善成为所有value受控状态
34
+ /**
35
+ * 下拉列表中各列项滚动到底部时的回调,onSrollBottom = (e,scrollColumnId) => {}。
36
+ * scrollColumnId第一列为undefined,从第二列开始为前一列的父级id值。
37
+ */
38
+ onSrollBottom: PropTypes.func,
39
+ /**
40
+ * 下拉列表中各列项文本框值变化的回调,onInputChange = (e,searchColumnId) => {}。
41
+ * searchColumnId第一列为undefined,从第二列开始为前一列的父级id值。
42
+ * --异步加载数据--
43
+ */
44
+ onInputChange: PropTypes.func,
45
+ /**
46
+ * 下拉列表中各列项自定义下拉框内容,dropdownColumnRender = (columnMenu,columnId,columnLoading) => {}。
47
+ * columnMenu为原始菜单dom。
48
+ * columnId第一列为undefined,从第二列开始为前一列的父级id值。
49
+ * columnLoading是否处于loading状态中。
50
+ * --异步加载数据--
51
+ */
52
+ dropdownColumnRender: PropTypes.func,
53
+ /**
54
+ * 定义选中项回填的方式。
55
+ * CWCascader.SHOW_CHILD: 只显示选中的子节点。
56
+ * CWCascader.SHOW_PARENT: 只显示父节点(当父节点下所有子节点都选中时)。
57
+ */
58
+ showCheckedStrategy: PropTypes.oneOf([CWCascader.SHOW_PARENT, CWCascader.SHOW_CHILD])
59
+ };
60
+ export default CWCascader;
@@ -3,7 +3,29 @@
3
3
  .cw-cascader-custom-dropdown.@{ant-prefix}-select-dropdown {
4
4
  overflow: visible !important;
5
5
  padding: 0 !important;
6
+
6
7
  // .@{ant-prefix}-cascader-menu {
7
8
  // max-height: 200px !important;
8
9
  // }
10
+ .cw-cascader-column-wrapper {
11
+ display: flex;
12
+ flex-direction: column;
13
+ flex: 1;
14
+ align-self: stretch;
15
+ .cw-cascader-column-input{
16
+ width: 100%;
17
+ min-width: 100px;
18
+ }
19
+ .cw-cascader-column-search-loading-wrapper{
20
+ display: flex;
21
+ justify-content: center;
22
+ align-items: center;
23
+ flex: 1;
24
+ }
25
+ .cw-cascader-column-scroll-loading-wrapper{
26
+ display: flex;
27
+ justify-content: center;
28
+ align-items: center;
29
+ }
30
+ }
9
31
  }
@@ -1,4 +1,4 @@
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"];
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
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
3
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
4
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."); }
@@ -26,7 +26,7 @@ import useSearchConfig from "./hooks/useSearchConfig";
26
26
  import useSearchOptions from "./hooks/useSearchOptions";
27
27
  import OptionList from "./OptionList";
28
28
  import { fillFieldNames, SHOW_CHILD, SHOW_PARENT, toPathKey, toPathKeys } from "./utils/commonUtil";
29
- import { formatStrategyValues, toPathOptions } from "./utils/treeUtil";
29
+ import { formatStrategyValues, toPathOptions, toValueAndLabel } from "./utils/treeUtil";
30
30
  import warningProps, { warningNullOptions } from "./utils/warningPropsUtil";
31
31
  function isMultipleValue(value) {
32
32
  return Array.isArray(value) && Array.isArray(value[0]);
@@ -82,6 +82,8 @@ var Cascader = /*#__PURE__*/React.forwardRef(function (props, ref) {
82
82
  showColumnSearch = props.showColumnSearch,
83
83
  onInputChange = props.onInputChange,
84
84
  dropdownColumnRender = props.dropdownColumnRender,
85
+ labelInValue = props.labelInValue,
86
+ isResetInputValue = props.isResetInputValue,
85
87
  restProps = _objectWithoutProperties(props, _excluded);
86
88
  var mergedId = useId(id);
87
89
  var multiple = !!checkable;
@@ -139,12 +141,27 @@ var Cascader = /*#__PURE__*/React.forwardRef(function (props, ref) {
139
141
  var getMissingValues = useMissingValues(mergedOptions, mergedFieldNames);
140
142
  // Fill `rawValues` with checked conduction values
141
143
  var _React$useMemo = React.useMemo(function () {
142
- var _getMissingValues = getMissingValues(rawValues),
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),
143
160
  _getMissingValues2 = _slicedToArray(_getMissingValues, 2),
144
161
  existValues = _getMissingValues2[0],
145
162
  missingValues = _getMissingValues2[1];
146
- if (!multiple || !rawValues.length) {
147
- return [existValues, [], missingValues];
163
+ if (!multiple || !_rawValues.length) {
164
+ return [existValues, [], missingValues, labelInValueOption];
148
165
  }
149
166
  var keyPathValues = toPathKeys(existValues);
150
167
  var keyPathEntities = getPathKeyEntities();
@@ -152,33 +169,39 @@ var Cascader = /*#__PURE__*/React.forwardRef(function (props, ref) {
152
169
  checkedKeys = _conductCheck.checkedKeys,
153
170
  halfCheckedKeys = _conductCheck.halfCheckedKeys;
154
171
  // Convert key back to value cells
155
- return [getValueByKeyPath(checkedKeys), getValueByKeyPath(halfCheckedKeys), missingValues];
156
- }, [multiple, rawValues, getPathKeyEntities, getValueByKeyPath, getMissingValues]),
157
- _React$useMemo2 = _slicedToArray(_React$useMemo, 3),
172
+ return [getValueByKeyPath(checkedKeys), getValueByKeyPath(halfCheckedKeys), missingValues, labelInValueOption];
173
+ }, [multiple, rawValues, getPathKeyEntities, getValueByKeyPath, getMissingValues, labelInValue]),
174
+ _React$useMemo2 = _slicedToArray(_React$useMemo, 4),
158
175
  checkedValues = _React$useMemo2[0],
159
176
  halfCheckedValues = _React$useMemo2[1],
160
- missingCheckedValues = _React$useMemo2[2];
177
+ missingCheckedValues = _React$useMemo2[2],
178
+ labelInValueOption = _React$useMemo2[3];
161
179
  var deDuplicatedValues = React.useMemo(function () {
162
180
  var checkedKeys = toPathKeys(checkedValues);
163
181
  var deduplicateKeys = formatStrategyValues(checkedKeys, getPathKeyEntities, showCheckedStrategy);
164
182
  return [].concat(_toConsumableArray(missingCheckedValues), _toConsumableArray(getValueByKeyPath(deduplicateKeys)));
165
183
  }, [checkedValues, getPathKeyEntities, getValueByKeyPath, missingCheckedValues, showCheckedStrategy]);
166
- var displayValues = useDisplayValues(deDuplicatedValues, mergedOptions, mergedFieldNames, multiple, displayRender);
184
+ var displayValues = useDisplayValues(deDuplicatedValues, mergedOptions, mergedFieldNames, multiple, displayRender, labelInValueOption);
167
185
  // =========================== Change ===========================
168
186
  var triggerChange = useRefFunc(function (nextValues) {
169
- setRawValues(nextValues);
187
+ var _nextValues = nextValues;
170
188
  // Save perf if no need trigger event
171
- if (onChange) {
172
- var nextRawValues = toRawValues(nextValues);
173
- var valueOptions = nextRawValues.map(function (valueCells) {
174
- return toPathOptions(valueCells, mergedOptions, mergedFieldNames).map(function (valueOpt) {
175
- return valueOpt.option;
176
- });
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;
177
193
  });
178
- var triggerValues = multiple ? nextRawValues : nextRawValues[0];
179
- var triggerOptions = multiple ? valueOptions : valueOptions[0];
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) {
180
202
  onChange(triggerValues, triggerOptions);
181
203
  }
204
+ setRawValues(_nextValues);
182
205
  });
183
206
  // =========================== Select ===========================
184
207
  var onInternalSelect = useRefFunc(function (valuePath) {
@@ -271,9 +294,10 @@ var Cascader = /*#__PURE__*/React.forwardRef(function (props, ref) {
271
294
  onSrollBottom: onSrollBottom,
272
295
  showColumnSearch: showColumnSearch,
273
296
  onInputChange: onInputChange,
274
- dropdownColumnRender: dropdownColumnRender
297
+ dropdownColumnRender: dropdownColumnRender,
298
+ isResetInputValue: isResetInputValue
275
299
  };
276
- }, [mergedOptions, mergedFieldNames, checkedValues, halfCheckedValues, changeOnSelect, onInternalSelect, checkable, searchOptions, dropdownPrefixCls, loadData, expandTrigger, expandIcon, loadingIcon, dropdownMenuColumnStyle, onScroll, onSrollBottom, showColumnSearch, onInputChange, dropdownColumnRender]);
300
+ }, [mergedOptions, mergedFieldNames, checkedValues, halfCheckedValues, changeOnSelect, onInternalSelect, checkable, searchOptions, dropdownPrefixCls, loadData, expandTrigger, expandIcon, loadingIcon, dropdownMenuColumnStyle, onScroll, onSrollBottom, showColumnSearch, onInputChange, dropdownColumnRender, isResetInputValue]);
277
301
  // ==============================================================
278
302
  // == Render ==
279
303
  // ==============================================================
@@ -1,9 +1,13 @@
1
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
2
  import "@chaoswise/ui/lib/Input/index.less";
3
3
  import _Input from "@chaoswise/ui/lib/Input";
4
+ import _Spin from "@chaoswise/ui/lib/Antd/Spin";
4
5
  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
6
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
7
  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); }
8
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
9
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
10
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
7
11
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
8
12
  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
13
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
@@ -33,9 +37,20 @@ export default function Column(_ref) {
33
37
  checkedSet = _ref.checkedSet,
34
38
  halfCheckedSet = _ref.halfCheckedSet,
35
39
  loadingKeys = _ref.loadingKeys,
36
- isSelectable = _ref.isSelectable;
40
+ isSelectable = _ref.isSelectable,
41
+ columnId = _ref.columnId,
42
+ setColumnId = _ref.setColumnId;
37
43
  var menuPrefixCls = "".concat(prefixCls, "-menu");
38
44
  var menuItemPrefixCls = "".concat(prefixCls, "-menu-item");
45
+ var scrollColumnId = prevValuePath.length ? prevValuePath[prevValuePath.length - 1] : undefined;
46
+ var _React$useState = React.useState(false),
47
+ _React$useState2 = _slicedToArray(_React$useState, 2),
48
+ columnLoading = _React$useState2[0],
49
+ setColumnLoading = _React$useState2[1];
50
+ var _React$useState3 = React.useState("scroll"),
51
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
52
+ loadingType = _React$useState4[0],
53
+ setLoadingType = _React$useState4[1];
39
54
  var _React$useContext = React.useContext(CascaderContext),
40
55
  fieldNames = _React$useContext.fieldNames,
41
56
  changeOnSelect = _React$useContext.changeOnSelect,
@@ -44,18 +59,27 @@ export default function Column(_ref) {
44
59
  loadingIcon = _React$useContext.loadingIcon,
45
60
  dropdownMenuColumnStyle = _React$useContext.dropdownMenuColumnStyle,
46
61
  _React$useContext$onS = _React$useContext.onScroll,
47
- _onScroll = _React$useContext$onS === void 0 ? function () {} : _React$useContext$onS,
62
+ onScroll = _React$useContext$onS === void 0 ? function () {} : _React$useContext$onS,
48
63
  _React$useContext$onS2 = _React$useContext.onSrollBottom,
49
64
  onSrollBottom = _React$useContext$onS2 === void 0 ? function () {} : _React$useContext$onS2,
50
65
  _React$useContext$onI = _React$useContext.onInputChange,
51
66
  onInputChange = _React$useContext$onI === void 0 ? function () {} : _React$useContext$onI,
52
67
  showColumnSearch = _React$useContext.showColumnSearch,
53
- dropdownColumnRender = _React$useContext.dropdownColumnRender;
68
+ dropdownColumnRender = _React$useContext.dropdownColumnRender,
69
+ isResetInputValue = _React$useContext.isResetInputValue;
54
70
  var hoverOpen = expandTrigger === "hover";
55
- var _React$useState = React.useState(""),
56
- _React$useState2 = _slicedToArray(_React$useState, 2),
57
- inputValue = _React$useState2[0],
58
- setInputValue = _React$useState2[1];
71
+ var _React$useState5 = React.useState(""),
72
+ _React$useState6 = _slicedToArray(_React$useState5, 2),
73
+ inputValue = _React$useState6[0],
74
+ setInputValue = _React$useState6[1];
75
+ React.useEffect(function () {
76
+ if (scrollColumnId == undefined && isResetInputValue) {
77
+ setInputValue("");
78
+ }
79
+ }, [scrollColumnId, isResetInputValue]);
80
+ React.useEffect(function () {
81
+ setInputValue("");
82
+ }, [scrollColumnId]);
59
83
  // ============================ Option ============================
60
84
  var optionInfoList = React.useMemo(function () {
61
85
  return options.map(function (option) {
@@ -89,41 +113,81 @@ export default function Column(_ref) {
89
113
  };
90
114
  });
91
115
  }, [options, checkedSet, fieldNames, halfCheckedSet, loadingKeys, prevValuePath]);
92
- var scrollColumnId = prevValuePath.length ? prevValuePath[prevValuePath.length - 1] : undefined;
93
- var onChange = function onChange(e) {
94
- setInputValue(e.target.value);
95
- onInputChange(e, scrollColumnId);
96
- };
116
+ var onChange = /*#__PURE__*/function () {
117
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(e) {
118
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
119
+ while (1) switch (_context.prev = _context.next) {
120
+ case 0:
121
+ setInputValue(e.target.value);
122
+ setColumnId(scrollColumnId);
123
+ setColumnLoading(true);
124
+ setLoadingType("search");
125
+ _context.next = 6;
126
+ return onInputChange(e, scrollColumnId);
127
+ case 6:
128
+ setColumnLoading(false);
129
+ case 7:
130
+ case "end":
131
+ return _context.stop();
132
+ }
133
+ }, _callee);
134
+ }));
135
+ return function onChange(_x2) {
136
+ return _ref2.apply(this, arguments);
137
+ };
138
+ }();
97
139
  // ============================ Render ============================
98
- var renderColumnDom = /*#__PURE__*/React.createElement("ul", {
140
+ var renderColumnDom = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("ul", {
99
141
  className: menuPrefixCls,
100
142
  role: "menu",
101
143
  style: {
102
144
  flex: 1
103
145
  },
104
- onScroll: function onScroll(e) {
105
- // scrollColumnId,一级为undefind,非一级为上一次的value
106
- _onScroll(e, scrollColumnId);
107
- function isScrollBottom() {
108
- var element = e.target;
109
- return element.scrollHeight - element.scrollTop <= element.clientHeight;
110
- }
111
- if (isScrollBottom()) {
112
- onSrollBottom(e, scrollColumnId);
113
- }
114
- }
115
- }, optionInfoList.map(function (_ref2) {
146
+ onScroll: /*#__PURE__*/function () {
147
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(e) {
148
+ var isScrollBottom;
149
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
150
+ while (1) switch (_context2.prev = _context2.next) {
151
+ case 0:
152
+ isScrollBottom = function _isScrollBottom() {
153
+ var element = e.target;
154
+ return element.scrollHeight - element.scrollTop - 5 <= element.clientHeight;
155
+ };
156
+ // scrollColumnId,一级为undefind,非一级为上一次的value
157
+ setColumnId(scrollColumnId);
158
+ onScroll(e, scrollColumnId);
159
+ if (!isScrollBottom()) {
160
+ _context2.next = 9;
161
+ break;
162
+ }
163
+ setColumnLoading(true);
164
+ setLoadingType("scroll");
165
+ _context2.next = 8;
166
+ return onSrollBottom(e, scrollColumnId);
167
+ case 8:
168
+ setColumnLoading(false);
169
+ case 9:
170
+ case "end":
171
+ return _context2.stop();
172
+ }
173
+ }, _callee2);
174
+ }));
175
+ return function (_x3) {
176
+ return _ref3.apply(this, arguments);
177
+ };
178
+ }()
179
+ }, optionInfoList.map(function (_ref4) {
116
180
  var _classNames;
117
- var disabled = _ref2.disabled,
118
- label = _ref2.label,
119
- value = _ref2.value,
120
- isMergedLeaf = _ref2.isLeaf,
121
- isLoading = _ref2.isLoading,
122
- checked = _ref2.checked,
123
- halfChecked = _ref2.halfChecked,
124
- option = _ref2.option,
125
- fullPath = _ref2.fullPath,
126
- fullPathKey = _ref2.fullPathKey;
181
+ var disabled = _ref4.disabled,
182
+ label = _ref4.label,
183
+ value = _ref4.value,
184
+ isMergedLeaf = _ref4.isLeaf,
185
+ isLoading = _ref4.isLoading,
186
+ checked = _ref4.checked,
187
+ halfChecked = _ref4.halfChecked,
188
+ option = _ref4.option,
189
+ fullPath = _ref4.fullPath,
190
+ fullPathKey = _ref4.fullPathKey;
127
191
  // >>>>> Open
128
192
  var triggerOpenPath = function triggerOpenPath() {
129
193
  if (!disabled && (!hoverOpen || !isMergedLeaf)) {
@@ -145,7 +209,6 @@ export default function Column(_ref) {
145
209
  } else if (typeof label === "string") {
146
210
  title = label;
147
211
  }
148
-
149
212
  // >>>>> Render
150
213
  return /*#__PURE__*/React.createElement("li", {
151
214
  key: fullPathKey,
@@ -173,7 +236,7 @@ export default function Column(_ref) {
173
236
  },
174
237
  onMouseDown: function onMouseDown(e) {
175
238
  // Prevent selector from blurring
176
- // e.preventDefault();
239
+ e.preventDefault();
177
240
  }
178
241
  }, multiple && /*#__PURE__*/React.createElement(Checkbox, {
179
242
  prefixCls: "".concat(prefixCls, "-checkbox"),
@@ -191,19 +254,23 @@ export default function Column(_ref) {
191
254
  }, expandIcon), isLoading && loadingIcon && /*#__PURE__*/React.createElement("div", {
192
255
  className: "".concat(menuItemPrefixCls, "-loading-icon")
193
256
  }, loadingIcon));
194
- }));
257
+ })), columnLoading && columnId === scrollColumnId && loadingType === "scroll" && /*#__PURE__*/React.createElement("div", {
258
+ className: "cw-cascader-column-scroll-loading-wrapper"
259
+ }, /*#__PURE__*/React.createElement(_Spin, {
260
+ size: "small"
261
+ })));
262
+ var _renderColumnDom = columnLoading && columnId === scrollColumnId && loadingType === "search" ? /*#__PURE__*/React.createElement("div", {
263
+ className: "cw-cascader-column-search-loading-wrapper"
264
+ }, /*#__PURE__*/React.createElement(_Spin, null)) : renderColumnDom;
195
265
  // ============================ Render ============================
196
266
  return /*#__PURE__*/React.createElement("div", {
197
- style: {
198
- display: "flex",
199
- flexDirection: "column",
200
- flex: 1
201
- }
267
+ className: "cw-cascader-column-wrapper"
202
268
  }, showColumnSearch && /*#__PURE__*/React.createElement(_Input, {
203
- style: {
204
- width: "100%"
205
- },
269
+ className: "cw-cascader-column-input",
206
270
  value: inputValue,
207
- onChange: onChange
208
- }), dropdownColumnRender ? dropdownColumnRender(renderColumnDom, scrollColumnId) : renderColumnDom);
271
+ onChange: onChange,
272
+ onKeyDown: function onKeyDown(e) {
273
+ e.stopPropagation();
274
+ }
275
+ }), dropdownColumnRender ? dropdownColumnRender(_renderColumnDom, scrollColumnId, columnLoading) : _renderColumnDom);
209
276
  }
@@ -48,11 +48,15 @@ var RefOptionList = /*#__PURE__*/React.forwardRef(function (props, ref) {
48
48
  loadData = _React$useContext.loadData,
49
49
  expandTrigger = _React$useContext.expandTrigger;
50
50
  var mergedPrefixCls = dropdownPrefixCls || prefixCls;
51
- // ========================= loadData =========================
52
- var _React$useState = React.useState([]),
51
+ var _React$useState = React.useState(''),
53
52
  _React$useState2 = _slicedToArray(_React$useState, 2),
54
- loadingKeys = _React$useState2[0],
55
- setLoadingKeys = _React$useState2[1];
53
+ columnId = _React$useState2[0],
54
+ setColumnId = _React$useState2[1];
55
+ // ========================= loadData =========================
56
+ var _React$useState3 = React.useState([]),
57
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
58
+ loadingKeys = _React$useState4[0],
59
+ setLoadingKeys = _React$useState4[1];
56
60
  var internalLoadData = function internalLoadData(valueCells) {
57
61
  // Do not load when search
58
62
  if (!loadData || searchValue) {
@@ -202,7 +206,9 @@ var RefOptionList = /*#__PURE__*/React.forwardRef(function (props, ref) {
202
206
  prefixCls: mergedPrefixCls,
203
207
  options: col.options,
204
208
  prevValuePath: prevValuePath,
205
- activeValue: activeValue
209
+ activeValue: activeValue,
210
+ columnId: columnId,
211
+ setColumnId: setColumnId
206
212
  }));
207
213
  });
208
214