@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,276 @@
|
|
|
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 "@chaoswise/ui/lib/Input/index.less";
|
|
3
|
+
import _Input from "@chaoswise/ui/lib/Input";
|
|
4
|
+
import _Spin from "@chaoswise/ui/lib/Antd/Spin";
|
|
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; }
|
|
6
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
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); }); }; }
|
|
11
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
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."); }
|
|
13
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
14
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
15
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
16
|
+
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."); }
|
|
17
|
+
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); }
|
|
18
|
+
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; }
|
|
19
|
+
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; } }
|
|
20
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
21
|
+
import * as React from "react";
|
|
22
|
+
import classNames from "classnames";
|
|
23
|
+
import { isLeaf, toPathKey } from "../utils/commonUtil";
|
|
24
|
+
import CascaderContext from "../context";
|
|
25
|
+
import Checkbox from "./Checkbox";
|
|
26
|
+
import { SEARCH_MARK } from "../hooks/useSearchOptions";
|
|
27
|
+
export var FIX_LABEL = "__cascader_fix_label__";
|
|
28
|
+
export default function Column(_ref) {
|
|
29
|
+
var prefixCls = _ref.prefixCls,
|
|
30
|
+
multiple = _ref.multiple,
|
|
31
|
+
options = _ref.options,
|
|
32
|
+
activeValue = _ref.activeValue,
|
|
33
|
+
prevValuePath = _ref.prevValuePath,
|
|
34
|
+
onToggleOpen = _ref.onToggleOpen,
|
|
35
|
+
onSelect = _ref.onSelect,
|
|
36
|
+
onActive = _ref.onActive,
|
|
37
|
+
checkedSet = _ref.checkedSet,
|
|
38
|
+
halfCheckedSet = _ref.halfCheckedSet,
|
|
39
|
+
loadingKeys = _ref.loadingKeys,
|
|
40
|
+
isSelectable = _ref.isSelectable,
|
|
41
|
+
columnId = _ref.columnId,
|
|
42
|
+
setColumnId = _ref.setColumnId;
|
|
43
|
+
var menuPrefixCls = "".concat(prefixCls, "-menu");
|
|
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];
|
|
54
|
+
var _React$useContext = React.useContext(CascaderContext),
|
|
55
|
+
fieldNames = _React$useContext.fieldNames,
|
|
56
|
+
changeOnSelect = _React$useContext.changeOnSelect,
|
|
57
|
+
expandTrigger = _React$useContext.expandTrigger,
|
|
58
|
+
expandIcon = _React$useContext.expandIcon,
|
|
59
|
+
loadingIcon = _React$useContext.loadingIcon,
|
|
60
|
+
dropdownMenuColumnStyle = _React$useContext.dropdownMenuColumnStyle,
|
|
61
|
+
_React$useContext$onS = _React$useContext.onScroll,
|
|
62
|
+
onScroll = _React$useContext$onS === void 0 ? function () {} : _React$useContext$onS,
|
|
63
|
+
_React$useContext$onS2 = _React$useContext.onSrollBottom,
|
|
64
|
+
onSrollBottom = _React$useContext$onS2 === void 0 ? function () {} : _React$useContext$onS2,
|
|
65
|
+
_React$useContext$onI = _React$useContext.onInputChange,
|
|
66
|
+
onInputChange = _React$useContext$onI === void 0 ? function () {} : _React$useContext$onI,
|
|
67
|
+
showColumnSearch = _React$useContext.showColumnSearch,
|
|
68
|
+
dropdownColumnRender = _React$useContext.dropdownColumnRender,
|
|
69
|
+
isResetInputValue = _React$useContext.isResetInputValue;
|
|
70
|
+
var hoverOpen = expandTrigger === "hover";
|
|
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]);
|
|
83
|
+
// ============================ Option ============================
|
|
84
|
+
var optionInfoList = React.useMemo(function () {
|
|
85
|
+
return options.map(function (option) {
|
|
86
|
+
var _option$FIX_LABEL;
|
|
87
|
+
var disabled = option.disabled;
|
|
88
|
+
var searchOptions = option[SEARCH_MARK];
|
|
89
|
+
var label = (_option$FIX_LABEL = option[FIX_LABEL]) !== null && _option$FIX_LABEL !== void 0 ? _option$FIX_LABEL : option[fieldNames.label];
|
|
90
|
+
var value = option[fieldNames.value];
|
|
91
|
+
var isMergedLeaf = isLeaf(option, fieldNames);
|
|
92
|
+
// Get real value of option. Search option is different way.
|
|
93
|
+
var fullPath = searchOptions ? searchOptions.map(function (opt) {
|
|
94
|
+
return opt[fieldNames.value];
|
|
95
|
+
}) : [].concat(_toConsumableArray(prevValuePath), [value]);
|
|
96
|
+
var fullPathKey = toPathKey(fullPath);
|
|
97
|
+
var isLoading = loadingKeys.includes(fullPathKey);
|
|
98
|
+
// >>>>> checked
|
|
99
|
+
var checked = checkedSet.has(fullPathKey);
|
|
100
|
+
// >>>>> halfChecked
|
|
101
|
+
var halfChecked = halfCheckedSet.has(fullPathKey);
|
|
102
|
+
return {
|
|
103
|
+
disabled: disabled,
|
|
104
|
+
label: label,
|
|
105
|
+
value: value,
|
|
106
|
+
isLeaf: isMergedLeaf,
|
|
107
|
+
isLoading: isLoading,
|
|
108
|
+
checked: checked,
|
|
109
|
+
halfChecked: halfChecked,
|
|
110
|
+
option: option,
|
|
111
|
+
fullPath: fullPath,
|
|
112
|
+
fullPathKey: fullPathKey
|
|
113
|
+
};
|
|
114
|
+
});
|
|
115
|
+
}, [options, checkedSet, fieldNames, halfCheckedSet, loadingKeys, prevValuePath]);
|
|
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
|
+
}();
|
|
139
|
+
// ============================ Render ============================
|
|
140
|
+
var renderColumnDom = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("ul", {
|
|
141
|
+
className: menuPrefixCls,
|
|
142
|
+
role: "menu",
|
|
143
|
+
style: {
|
|
144
|
+
flex: 1
|
|
145
|
+
},
|
|
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) {
|
|
180
|
+
var _classNames;
|
|
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;
|
|
191
|
+
// >>>>> Open
|
|
192
|
+
var triggerOpenPath = function triggerOpenPath() {
|
|
193
|
+
if (!disabled && (!hoverOpen || !isMergedLeaf)) {
|
|
194
|
+
onActive(fullPath);
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
// >>>>> Selection
|
|
199
|
+
var triggerSelect = function triggerSelect() {
|
|
200
|
+
if (isSelectable(option)) {
|
|
201
|
+
onSelect(fullPath, isMergedLeaf);
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
// >>>>> Title
|
|
206
|
+
var title;
|
|
207
|
+
if (typeof option.title === "string") {
|
|
208
|
+
title = option.title;
|
|
209
|
+
} else if (typeof label === "string") {
|
|
210
|
+
title = label;
|
|
211
|
+
}
|
|
212
|
+
// >>>>> Render
|
|
213
|
+
return /*#__PURE__*/React.createElement("li", {
|
|
214
|
+
key: fullPathKey,
|
|
215
|
+
className: classNames(menuItemPrefixCls, (_classNames = {}, _defineProperty(_classNames, "".concat(menuItemPrefixCls, "-expand"), !isMergedLeaf), _defineProperty(_classNames, "".concat(menuItemPrefixCls, "-active"), activeValue === value), _defineProperty(_classNames, "".concat(menuItemPrefixCls, "-disabled"), disabled), _defineProperty(_classNames, "".concat(menuItemPrefixCls, "-loading"), isLoading), _classNames)),
|
|
216
|
+
style: dropdownMenuColumnStyle,
|
|
217
|
+
role: "menuitemcheckbox",
|
|
218
|
+
title: title,
|
|
219
|
+
"aria-checked": checked,
|
|
220
|
+
"data-path-key": fullPathKey,
|
|
221
|
+
onClick: function onClick() {
|
|
222
|
+
triggerOpenPath();
|
|
223
|
+
if (!multiple || isMergedLeaf) {
|
|
224
|
+
triggerSelect();
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
onDoubleClick: function onDoubleClick() {
|
|
228
|
+
if (changeOnSelect) {
|
|
229
|
+
onToggleOpen(false);
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
onMouseEnter: function onMouseEnter() {
|
|
233
|
+
if (hoverOpen) {
|
|
234
|
+
triggerOpenPath();
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
onMouseDown: function onMouseDown(e) {
|
|
238
|
+
// Prevent selector from blurring
|
|
239
|
+
e.preventDefault();
|
|
240
|
+
}
|
|
241
|
+
}, multiple && /*#__PURE__*/React.createElement(Checkbox, {
|
|
242
|
+
prefixCls: "".concat(prefixCls, "-checkbox"),
|
|
243
|
+
checked: checked,
|
|
244
|
+
halfChecked: halfChecked,
|
|
245
|
+
disabled: disabled,
|
|
246
|
+
onClick: function onClick(e) {
|
|
247
|
+
e.stopPropagation();
|
|
248
|
+
triggerSelect();
|
|
249
|
+
}
|
|
250
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
251
|
+
className: "".concat(menuItemPrefixCls, "-content")
|
|
252
|
+
}, label), !isLoading && expandIcon && !isMergedLeaf && /*#__PURE__*/React.createElement("div", {
|
|
253
|
+
className: "".concat(menuItemPrefixCls, "-expand-icon")
|
|
254
|
+
}, expandIcon), isLoading && loadingIcon && /*#__PURE__*/React.createElement("div", {
|
|
255
|
+
className: "".concat(menuItemPrefixCls, "-loading-icon")
|
|
256
|
+
}, loadingIcon));
|
|
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;
|
|
265
|
+
// ============================ Render ============================
|
|
266
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
267
|
+
className: "cw-cascader-column-wrapper"
|
|
268
|
+
}, showColumnSearch && /*#__PURE__*/React.createElement(_Input, {
|
|
269
|
+
className: "cw-cascader-column-input",
|
|
270
|
+
value: inputValue,
|
|
271
|
+
onChange: onChange,
|
|
272
|
+
onKeyDown: function onKeyDown(e) {
|
|
273
|
+
e.stopPropagation();
|
|
274
|
+
}
|
|
275
|
+
}), dropdownColumnRender ? dropdownColumnRender(_renderColumnDom, scrollColumnId, columnLoading) : _renderColumnDom);
|
|
276
|
+
}
|
|
@@ -0,0 +1,221 @@
|
|
|
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 _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 ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
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; }
|
|
6
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
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 _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
9
|
+
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."); }
|
|
10
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
11
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
12
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
13
|
+
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."); }
|
|
14
|
+
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); }
|
|
15
|
+
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; }
|
|
16
|
+
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; } }
|
|
17
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
18
|
+
/* eslint-disable default-case */
|
|
19
|
+
import classNames from 'classnames';
|
|
20
|
+
import { useBaseProps } from 'rc-cascader/node_modules/rc-select';
|
|
21
|
+
import * as React from 'react';
|
|
22
|
+
import CascaderContext from '../context';
|
|
23
|
+
import { getFullPathKeys, isLeaf, scrollIntoParentView, toPathKey, toPathKeys, toPathValueStr } from '../utils/commonUtil';
|
|
24
|
+
import { toPathOptions } from '../utils/treeUtil';
|
|
25
|
+
import Column, { FIX_LABEL } from './Column';
|
|
26
|
+
import useActive from './useActive';
|
|
27
|
+
import useKeyboard from './useKeyboard';
|
|
28
|
+
var RefOptionList = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
29
|
+
var _optionColumns$, _optionColumns$$optio, _ref3, _classNames;
|
|
30
|
+
var _useBaseProps = useBaseProps(),
|
|
31
|
+
prefixCls = _useBaseProps.prefixCls,
|
|
32
|
+
multiple = _useBaseProps.multiple,
|
|
33
|
+
searchValue = _useBaseProps.searchValue,
|
|
34
|
+
toggleOpen = _useBaseProps.toggleOpen,
|
|
35
|
+
notFoundContent = _useBaseProps.notFoundContent,
|
|
36
|
+
direction = _useBaseProps.direction;
|
|
37
|
+
var containerRef = React.useRef();
|
|
38
|
+
var rtl = direction === 'rtl';
|
|
39
|
+
var _React$useContext = React.useContext(CascaderContext),
|
|
40
|
+
options = _React$useContext.options,
|
|
41
|
+
values = _React$useContext.values,
|
|
42
|
+
halfValues = _React$useContext.halfValues,
|
|
43
|
+
fieldNames = _React$useContext.fieldNames,
|
|
44
|
+
changeOnSelect = _React$useContext.changeOnSelect,
|
|
45
|
+
onSelect = _React$useContext.onSelect,
|
|
46
|
+
searchOptions = _React$useContext.searchOptions,
|
|
47
|
+
dropdownPrefixCls = _React$useContext.dropdownPrefixCls,
|
|
48
|
+
loadData = _React$useContext.loadData,
|
|
49
|
+
expandTrigger = _React$useContext.expandTrigger;
|
|
50
|
+
var mergedPrefixCls = dropdownPrefixCls || prefixCls;
|
|
51
|
+
var _React$useState = React.useState(''),
|
|
52
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
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];
|
|
60
|
+
var internalLoadData = function internalLoadData(valueCells) {
|
|
61
|
+
// Do not load when search
|
|
62
|
+
if (!loadData || searchValue) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
var optionList = toPathOptions(valueCells, options, fieldNames);
|
|
66
|
+
var rawOptions = optionList.map(function (_ref) {
|
|
67
|
+
var option = _ref.option;
|
|
68
|
+
return option;
|
|
69
|
+
});
|
|
70
|
+
var lastOption = rawOptions[rawOptions.length - 1];
|
|
71
|
+
if (lastOption && !isLeaf(lastOption, fieldNames)) {
|
|
72
|
+
var pathKey = toPathKey(valueCells);
|
|
73
|
+
setLoadingKeys(function (keys) {
|
|
74
|
+
return [].concat(_toConsumableArray(keys), [pathKey]);
|
|
75
|
+
});
|
|
76
|
+
loadData(rawOptions);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
// zombieJ: This is bad. We should make this same as `rc-tree` to use Promise instead.
|
|
80
|
+
React.useEffect(function () {
|
|
81
|
+
if (loadingKeys.length) {
|
|
82
|
+
loadingKeys.forEach(function (loadingKey) {
|
|
83
|
+
var valueStrCells = toPathValueStr(loadingKey);
|
|
84
|
+
var optionList = toPathOptions(valueStrCells, options, fieldNames, true).map(function (_ref2) {
|
|
85
|
+
var option = _ref2.option;
|
|
86
|
+
return option;
|
|
87
|
+
});
|
|
88
|
+
var lastOption = optionList[optionList.length - 1];
|
|
89
|
+
if (!lastOption || lastOption[fieldNames.children] || isLeaf(lastOption, fieldNames)) {
|
|
90
|
+
setLoadingKeys(function (keys) {
|
|
91
|
+
return keys.filter(function (key) {
|
|
92
|
+
return key !== loadingKey;
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}, [options, loadingKeys, fieldNames]);
|
|
99
|
+
// ========================== Values ==========================
|
|
100
|
+
var checkedSet = React.useMemo(function () {
|
|
101
|
+
return new Set(toPathKeys(values));
|
|
102
|
+
}, [values]);
|
|
103
|
+
var halfCheckedSet = React.useMemo(function () {
|
|
104
|
+
return new Set(toPathKeys(halfValues));
|
|
105
|
+
}, [halfValues]);
|
|
106
|
+
// ====================== Accessibility =======================
|
|
107
|
+
var _useActive = useActive(),
|
|
108
|
+
_useActive2 = _slicedToArray(_useActive, 2),
|
|
109
|
+
activeValueCells = _useActive2[0],
|
|
110
|
+
setActiveValueCells = _useActive2[1];
|
|
111
|
+
// =========================== Path ===========================
|
|
112
|
+
var onPathOpen = function onPathOpen(nextValueCells) {
|
|
113
|
+
setActiveValueCells(nextValueCells);
|
|
114
|
+
// Trigger loadData
|
|
115
|
+
internalLoadData(nextValueCells);
|
|
116
|
+
};
|
|
117
|
+
var isSelectable = function isSelectable(option) {
|
|
118
|
+
var disabled = option.disabled;
|
|
119
|
+
var isMergedLeaf = isLeaf(option, fieldNames);
|
|
120
|
+
return !disabled && (isMergedLeaf || changeOnSelect || multiple);
|
|
121
|
+
};
|
|
122
|
+
var onPathSelect = function onPathSelect(valuePath, leaf) {
|
|
123
|
+
var fromKeyboard = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
124
|
+
onSelect(valuePath);
|
|
125
|
+
if (!multiple && (leaf || changeOnSelect && (expandTrigger === 'hover' || fromKeyboard))) {
|
|
126
|
+
toggleOpen(false);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
// ========================== Option ==========================
|
|
130
|
+
var mergedOptions = React.useMemo(function () {
|
|
131
|
+
if (searchValue) {
|
|
132
|
+
return searchOptions;
|
|
133
|
+
}
|
|
134
|
+
return options;
|
|
135
|
+
}, [searchValue, searchOptions, options]);
|
|
136
|
+
// ========================== Column ==========================
|
|
137
|
+
var optionColumns = React.useMemo(function () {
|
|
138
|
+
var optionList = [{
|
|
139
|
+
options: mergedOptions
|
|
140
|
+
}];
|
|
141
|
+
var currentList = mergedOptions;
|
|
142
|
+
var fullPathKeys = getFullPathKeys(currentList, fieldNames);
|
|
143
|
+
var _loop = function _loop() {
|
|
144
|
+
var activeValueCell = activeValueCells[i];
|
|
145
|
+
var currentOption = currentList.find(function (option, index) {
|
|
146
|
+
return (fullPathKeys[index] ? toPathKey(fullPathKeys[index]) : option[fieldNames.value]) === activeValueCell;
|
|
147
|
+
});
|
|
148
|
+
var subOptions = currentOption === null || currentOption === void 0 ? void 0 : currentOption[fieldNames.children];
|
|
149
|
+
if (!(subOptions !== null && subOptions !== void 0 && subOptions.length)) {
|
|
150
|
+
return "break";
|
|
151
|
+
}
|
|
152
|
+
currentList = subOptions;
|
|
153
|
+
optionList.push({
|
|
154
|
+
options: subOptions
|
|
155
|
+
});
|
|
156
|
+
};
|
|
157
|
+
for (var i = 0; i < activeValueCells.length; i += 1) {
|
|
158
|
+
var _ret = _loop();
|
|
159
|
+
if (_ret === "break") break;
|
|
160
|
+
}
|
|
161
|
+
return optionList;
|
|
162
|
+
}, [mergedOptions, activeValueCells, fieldNames]);
|
|
163
|
+
// ========================= Keyboard =========================
|
|
164
|
+
var onKeyboardSelect = function onKeyboardSelect(selectValueCells, option) {
|
|
165
|
+
if (isSelectable(option)) {
|
|
166
|
+
onPathSelect(selectValueCells, isLeaf(option, fieldNames), true);
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
useKeyboard(ref, mergedOptions, fieldNames, activeValueCells, onPathOpen, onKeyboardSelect);
|
|
170
|
+
// >>>>> Active Scroll
|
|
171
|
+
React.useEffect(function () {
|
|
172
|
+
for (var i = 0; i < activeValueCells.length; i += 1) {
|
|
173
|
+
var _containerRef$current;
|
|
174
|
+
var cellPath = activeValueCells.slice(0, i + 1);
|
|
175
|
+
var cellKeyPath = toPathKey(cellPath);
|
|
176
|
+
var ele = (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.querySelector("li[data-path-key=\"".concat(cellKeyPath.replace(/\\{0,2}"/g, '\\"'), "\"]"));
|
|
177
|
+
if (ele) {
|
|
178
|
+
scrollIntoParentView(ele);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}, [activeValueCells]);
|
|
182
|
+
// ========================== Render ==========================
|
|
183
|
+
// >>>>> Empty
|
|
184
|
+
var isEmpty = !((_optionColumns$ = optionColumns[0]) !== null && _optionColumns$ !== void 0 && (_optionColumns$$optio = _optionColumns$.options) !== null && _optionColumns$$optio !== void 0 && _optionColumns$$optio.length);
|
|
185
|
+
var emptyList = [(_ref3 = {}, _defineProperty(_ref3, fieldNames.value, '__EMPTY__'), _defineProperty(_ref3, FIX_LABEL, notFoundContent), _defineProperty(_ref3, "disabled", true), _ref3)];
|
|
186
|
+
var columnProps = _objectSpread(_objectSpread({}, props), {}, {
|
|
187
|
+
multiple: !isEmpty && multiple,
|
|
188
|
+
onSelect: onPathSelect,
|
|
189
|
+
onActive: onPathOpen,
|
|
190
|
+
onToggleOpen: toggleOpen,
|
|
191
|
+
checkedSet: checkedSet,
|
|
192
|
+
halfCheckedSet: halfCheckedSet,
|
|
193
|
+
loadingKeys: loadingKeys,
|
|
194
|
+
isSelectable: isSelectable
|
|
195
|
+
});
|
|
196
|
+
// >>>>> Columns
|
|
197
|
+
var mergedOptionColumns = isEmpty ? [{
|
|
198
|
+
options: emptyList
|
|
199
|
+
}] : optionColumns;
|
|
200
|
+
var columnNodes = mergedOptionColumns.map(function (col, index) {
|
|
201
|
+
var prevValuePath = activeValueCells.slice(0, index);
|
|
202
|
+
var activeValue = activeValueCells[index];
|
|
203
|
+
return /*#__PURE__*/React.createElement(Column, _extends({
|
|
204
|
+
key: index
|
|
205
|
+
}, columnProps, {
|
|
206
|
+
prefixCls: mergedPrefixCls,
|
|
207
|
+
options: col.options,
|
|
208
|
+
prevValuePath: prevValuePath,
|
|
209
|
+
activeValue: activeValue,
|
|
210
|
+
columnId: columnId,
|
|
211
|
+
setColumnId: setColumnId
|
|
212
|
+
}));
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
// >>>>> Render
|
|
216
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
217
|
+
className: classNames("".concat(mergedPrefixCls, "-menus"), (_classNames = {}, _defineProperty(_classNames, "".concat(mergedPrefixCls, "-menu-empty"), isEmpty), _defineProperty(_classNames, "".concat(mergedPrefixCls, "-rtl"), rtl), _classNames)),
|
|
218
|
+
ref: containerRef
|
|
219
|
+
}, columnNodes);
|
|
220
|
+
});
|
|
221
|
+
export default RefOptionList;
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
});
|