You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
NewEduCoderBuild/42167.async.js

8172 lines
298 KiB

"use strict";
(self["webpackChunk"] = self["webpackChunk"] || []).push([[42167],{
/***/ 42167:
/*!****************************************************************!*\
!*** ./node_modules/antd/es/tree-select/index.js + 67 modules ***!
\****************************************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
// EXPORTS
__webpack_require__.d(__webpack_exports__, {
"Z": function() { return /* binding */ tree_select; }
});
// UNUSED EXPORTS: TreeNode
// EXTERNAL MODULE: ./node_modules/classnames/index.js
var classnames = __webpack_require__(94184);
var classnames_default = /*#__PURE__*/__webpack_require__.n(classnames);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js
var esm_extends = __webpack_require__(87462);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js + 2 modules
var toConsumableArray = __webpack_require__(74902);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/objectSpread2.js
var objectSpread2 = __webpack_require__(1413);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js + 1 modules
var slicedToArray = __webpack_require__(97685);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js
var objectWithoutProperties = __webpack_require__(45987);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/typeof.js
var esm_typeof = __webpack_require__(71002);
// EXTERNAL MODULE: ./node_modules/react/index.js
var react = __webpack_require__(67294);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js
var defineProperty = __webpack_require__(4942);
// EXTERNAL MODULE: ./node_modules/rc-util/es/hooks/useMergedState.js
var useMergedState = __webpack_require__(21770);
// EXTERNAL MODULE: ./node_modules/rc-util/es/warning.js
var es_warning = __webpack_require__(80334);
// EXTERNAL MODULE: ./node_modules/rc-util/es/hooks/useLayoutEffect.js
var useLayoutEffect = __webpack_require__(8410);
// EXTERNAL MODULE: ./node_modules/rc-util/es/isMobile.js
var isMobile = __webpack_require__(31131);
// EXTERNAL MODULE: ./node_modules/rc-util/es/KeyCode.js
var KeyCode = __webpack_require__(15105);
// EXTERNAL MODULE: ./node_modules/rc-util/es/ref.js
var es_ref = __webpack_require__(42550);
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/node_modules/rc-select/es/hooks/useBaseProps.js
/**
* BaseSelect provide some parsed data into context.
* You can use this hooks to get them.
*/
var BaseSelectContext = /*#__PURE__*/react.createContext(null);
function useBaseProps() {
return react.useContext(BaseSelectContext);
}
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/node_modules/rc-select/es/hooks/useDelayReset.js
/**
* Similar with `useLock`, but this hook will always execute last value.
* When set to `true`, it will keep `true` for a short time even if `false` is set.
*/
function useDelayReset() {
var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10;
var _React$useState = react.useState(false),
_React$useState2 = (0,slicedToArray/* default */.Z)(_React$useState, 2),
bool = _React$useState2[0],
setBool = _React$useState2[1];
var delayRef = react.useRef(null);
var cancelLatest = function cancelLatest() {
window.clearTimeout(delayRef.current);
};
react.useEffect(function () {
return cancelLatest;
}, []);
var delaySetBool = function delaySetBool(value, callback) {
cancelLatest();
delayRef.current = window.setTimeout(function () {
setBool(value);
if (callback) {
callback();
}
}, timeout);
};
return [bool, delaySetBool, cancelLatest];
}
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/node_modules/rc-select/es/hooks/useLock.js
/**
* Locker return cached mark.
* If set to `true`, will return `true` in a short time even if set `false`.
* If set to `false` and then set to `true`, will change to `true`.
* And after time duration, it will back to `null` automatically.
*/
function useLock() {
var duration = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 250;
var lockRef = react.useRef(null);
var timeoutRef = react.useRef(null);
// Clean up
react.useEffect(function () {
return function () {
window.clearTimeout(timeoutRef.current);
};
}, []);
function doLock(locked) {
if (locked || lockRef.current === null) {
lockRef.current = locked;
}
window.clearTimeout(timeoutRef.current);
timeoutRef.current = window.setTimeout(function () {
lockRef.current = null;
}, duration);
}
return [function () {
return lockRef.current;
}, doLock];
}
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/node_modules/rc-select/es/hooks/useSelectTriggerControl.js
function useSelectTriggerControl(elements, open, triggerOpen, customizedTrigger) {
var propsRef = react.useRef(null);
propsRef.current = {
open: open,
triggerOpen: triggerOpen,
customizedTrigger: customizedTrigger
};
react.useEffect(function () {
function onGlobalMouseDown(event) {
var _propsRef$current;
// If trigger is customized, Trigger will take control of popupVisible
if ((_propsRef$current = propsRef.current) !== null && _propsRef$current !== void 0 && _propsRef$current.customizedTrigger) {
return;
}
var target = event.target;
if (target.shadowRoot && event.composed) {
target = event.composedPath()[0] || target;
}
if (propsRef.current.open && elements().filter(function (element) {
return element;
}).every(function (element) {
return !element.contains(target) && element !== target;
})) {
// Should trigger close
propsRef.current.triggerOpen(false);
}
}
window.addEventListener('mousedown', onGlobalMouseDown);
return function () {
return window.removeEventListener('mousedown', onGlobalMouseDown);
};
}, []);
}
// EXTERNAL MODULE: ./node_modules/rc-util/es/pickAttrs.js
var pickAttrs = __webpack_require__(64217);
// EXTERNAL MODULE: ./node_modules/rc-overflow/es/index.js + 4 modules
var es = __webpack_require__(34243);
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/node_modules/rc-select/es/TransBtn.js
var TransBtn = function TransBtn(_ref) {
var className = _ref.className,
customizeIcon = _ref.customizeIcon,
customizeIconProps = _ref.customizeIconProps,
_onMouseDown = _ref.onMouseDown,
onClick = _ref.onClick,
children = _ref.children;
var icon;
if (typeof customizeIcon === 'function') {
icon = customizeIcon(customizeIconProps);
} else {
icon = customizeIcon;
}
return /*#__PURE__*/react.createElement("span", {
className: className,
onMouseDown: function onMouseDown(event) {
event.preventDefault();
if (_onMouseDown) {
_onMouseDown(event);
}
},
style: {
userSelect: 'none',
WebkitUserSelect: 'none'
},
unselectable: "on",
onClick: onClick,
"aria-hidden": true
}, icon !== undefined ? icon : /*#__PURE__*/react.createElement("span", {
className: classnames_default()(className.split(/\s+/).map(function (cls) {
return "".concat(cls, "-icon");
}))
}, children));
};
/* harmony default export */ var es_TransBtn = (TransBtn);
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/node_modules/rc-select/es/Selector/Input.js
var Input = function Input(_ref, ref) {
var _inputNode2, _inputNode2$props;
var prefixCls = _ref.prefixCls,
id = _ref.id,
inputElement = _ref.inputElement,
disabled = _ref.disabled,
tabIndex = _ref.tabIndex,
autoFocus = _ref.autoFocus,
autoComplete = _ref.autoComplete,
editable = _ref.editable,
activeDescendantId = _ref.activeDescendantId,
value = _ref.value,
maxLength = _ref.maxLength,
_onKeyDown = _ref.onKeyDown,
_onMouseDown = _ref.onMouseDown,
_onChange = _ref.onChange,
onPaste = _ref.onPaste,
_onCompositionStart = _ref.onCompositionStart,
_onCompositionEnd = _ref.onCompositionEnd,
open = _ref.open,
attrs = _ref.attrs;
var inputNode = inputElement || /*#__PURE__*/react.createElement("input", null);
var _inputNode = inputNode,
originRef = _inputNode.ref,
originProps = _inputNode.props;
var onOriginKeyDown = originProps.onKeyDown,
onOriginChange = originProps.onChange,
onOriginMouseDown = originProps.onMouseDown,
onOriginCompositionStart = originProps.onCompositionStart,
onOriginCompositionEnd = originProps.onCompositionEnd,
style = originProps.style;
(0,es_warning/* warning */.Kp)(!('maxLength' in inputNode.props), "Passing 'maxLength' to input element directly may not work because input in BaseSelect is controlled.");
inputNode = /*#__PURE__*/react.cloneElement(inputNode, (0,objectSpread2/* default */.Z)((0,objectSpread2/* default */.Z)((0,objectSpread2/* default */.Z)({
type: 'search'
}, originProps), {}, {
// Override over origin props
id: id,
ref: (0,es_ref/* composeRef */.sQ)(ref, originRef),
disabled: disabled,
tabIndex: tabIndex,
autoComplete: autoComplete || 'off',
autoFocus: autoFocus,
className: classnames_default()("".concat(prefixCls, "-selection-search-input"), (_inputNode2 = inputNode) === null || _inputNode2 === void 0 ? void 0 : (_inputNode2$props = _inputNode2.props) === null || _inputNode2$props === void 0 ? void 0 : _inputNode2$props.className),
role: 'combobox',
'aria-expanded': open,
'aria-haspopup': 'listbox',
'aria-owns': "".concat(id, "_list"),
'aria-autocomplete': 'list',
'aria-controls': "".concat(id, "_list"),
'aria-activedescendant': activeDescendantId
}, attrs), {}, {
value: editable ? value : '',
maxLength: maxLength,
readOnly: !editable,
unselectable: !editable ? 'on' : null,
style: (0,objectSpread2/* default */.Z)((0,objectSpread2/* default */.Z)({}, style), {}, {
opacity: editable ? null : 0
}),
onKeyDown: function onKeyDown(event) {
_onKeyDown(event);
if (onOriginKeyDown) {
onOriginKeyDown(event);
}
},
onMouseDown: function onMouseDown(event) {
_onMouseDown(event);
if (onOriginMouseDown) {
onOriginMouseDown(event);
}
},
onChange: function onChange(event) {
_onChange(event);
if (onOriginChange) {
onOriginChange(event);
}
},
onCompositionStart: function onCompositionStart(event) {
_onCompositionStart(event);
if (onOriginCompositionStart) {
onOriginCompositionStart(event);
}
},
onCompositionEnd: function onCompositionEnd(event) {
_onCompositionEnd(event);
if (onOriginCompositionEnd) {
onOriginCompositionEnd(event);
}
},
onPaste: onPaste
}));
return inputNode;
};
var RefInput = /*#__PURE__*/react.forwardRef(Input);
RefInput.displayName = 'Input';
/* harmony default export */ var Selector_Input = (RefInput);
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/node_modules/rc-select/es/utils/commonUtil.js
function commonUtil_toArray(value) {
if (Array.isArray(value)) {
return value;
}
return value !== undefined ? [value] : [];
}
var isClient = typeof window !== 'undefined' && window.document && window.document.documentElement;
/** Is client side and not jsdom */
var isBrowserClient = true && isClient;
function hasValue(value) {
return value !== undefined && value !== null;
}
function isTitleType(title) {
return ['string', 'number'].includes((0,esm_typeof/* default */.Z)(title));
}
function getTitle(item) {
var title = undefined;
if (item) {
if (isTitleType(item.title)) {
title = item.title.toString();
} else if (isTitleType(item.label)) {
title = item.label.toString();
}
}
return title;
}
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/node_modules/rc-select/es/hooks/useLayoutEffect.js
/* eslint-disable react-hooks/rules-of-hooks */
/**
* Wrap `React.useLayoutEffect` which will not throw warning message in test env
*/
function useLayoutEffect_useLayoutEffect(effect, deps) {
// Never happen in test env
if (isBrowserClient) {
/* istanbul ignore next */
react.useLayoutEffect(effect, deps);
} else {
react.useEffect(effect, deps);
}
}
/* eslint-enable */
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/node_modules/rc-select/es/Selector/MultipleSelector.js
function itemKey(value) {
var _value$key;
return (_value$key = value.key) !== null && _value$key !== void 0 ? _value$key : value.value;
}
var onPreventMouseDown = function onPreventMouseDown(event) {
event.preventDefault();
event.stopPropagation();
};
var SelectSelector = function SelectSelector(props) {
var id = props.id,
prefixCls = props.prefixCls,
values = props.values,
open = props.open,
searchValue = props.searchValue,
autoClearSearchValue = props.autoClearSearchValue,
inputRef = props.inputRef,
placeholder = props.placeholder,
disabled = props.disabled,
mode = props.mode,
showSearch = props.showSearch,
autoFocus = props.autoFocus,
autoComplete = props.autoComplete,
activeDescendantId = props.activeDescendantId,
tabIndex = props.tabIndex,
removeIcon = props.removeIcon,
maxTagCount = props.maxTagCount,
maxTagTextLength = props.maxTagTextLength,
_props$maxTagPlacehol = props.maxTagPlaceholder,
maxTagPlaceholder = _props$maxTagPlacehol === void 0 ? function (omittedValues) {
return "+ ".concat(omittedValues.length, " ...");
} : _props$maxTagPlacehol,
tagRender = props.tagRender,
onToggleOpen = props.onToggleOpen,
onRemove = props.onRemove,
onInputChange = props.onInputChange,
onInputPaste = props.onInputPaste,
onInputKeyDown = props.onInputKeyDown,
onInputMouseDown = props.onInputMouseDown,
onInputCompositionStart = props.onInputCompositionStart,
onInputCompositionEnd = props.onInputCompositionEnd;
var measureRef = react.useRef(null);
var _useState = (0,react.useState)(0),
_useState2 = (0,slicedToArray/* default */.Z)(_useState, 2),
inputWidth = _useState2[0],
setInputWidth = _useState2[1];
var _useState3 = (0,react.useState)(false),
_useState4 = (0,slicedToArray/* default */.Z)(_useState3, 2),
focused = _useState4[0],
setFocused = _useState4[1];
var selectionPrefixCls = "".concat(prefixCls, "-selection");
// ===================== Search ======================
var inputValue = open || mode === "multiple" && autoClearSearchValue === false || mode === 'tags' ? searchValue : '';
var inputEditable = mode === 'tags' || mode === "multiple" && autoClearSearchValue === false || showSearch && (open || focused);
// We measure width and set to the input immediately
useLayoutEffect_useLayoutEffect(function () {
setInputWidth(measureRef.current.scrollWidth);
}, [inputValue]);
// ===================== Render ======================
// >>> Render Selector Node. Includes Item & Rest
function defaultRenderSelector(item, content, itemDisabled, closable, onClose) {
return /*#__PURE__*/react.createElement("span", {
className: classnames_default()("".concat(selectionPrefixCls, "-item"), (0,defineProperty/* default */.Z)({}, "".concat(selectionPrefixCls, "-item-disabled"), itemDisabled)),
title: getTitle(item)
}, /*#__PURE__*/react.createElement("span", {
className: "".concat(selectionPrefixCls, "-item-content")
}, content), closable && /*#__PURE__*/react.createElement(es_TransBtn, {
className: "".concat(selectionPrefixCls, "-item-remove"),
onMouseDown: onPreventMouseDown,
onClick: onClose,
customizeIcon: removeIcon
}, "\xD7"));
}
function customizeRenderSelector(value, content, itemDisabled, closable, onClose) {
var onMouseDown = function onMouseDown(e) {
onPreventMouseDown(e);
onToggleOpen(!open);
};
return /*#__PURE__*/react.createElement("span", {
onMouseDown: onMouseDown
}, tagRender({
label: content,
value: value,
disabled: itemDisabled,
closable: closable,
onClose: onClose
}));
}
function renderItem(valueItem) {
var itemDisabled = valueItem.disabled,
label = valueItem.label,
value = valueItem.value;
var closable = !disabled && !itemDisabled;
var displayLabel = label;
if (typeof maxTagTextLength === 'number') {
if (typeof label === 'string' || typeof label === 'number') {
var strLabel = String(displayLabel);
if (strLabel.length > maxTagTextLength) {
displayLabel = "".concat(strLabel.slice(0, maxTagTextLength), "...");
}
}
}
var onClose = function onClose(event) {
if (event) event.stopPropagation();
onRemove(valueItem);
};
return typeof tagRender === 'function' ? customizeRenderSelector(value, displayLabel, itemDisabled, closable, onClose) : defaultRenderSelector(valueItem, displayLabel, itemDisabled, closable, onClose);
}
function renderRest(omittedValues) {
var content = typeof maxTagPlaceholder === 'function' ? maxTagPlaceholder(omittedValues) : maxTagPlaceholder;
return defaultRenderSelector({
title: content
}, content, false);
}
// >>> Input Node
var inputNode = /*#__PURE__*/react.createElement("div", {
className: "".concat(selectionPrefixCls, "-search"),
style: {
width: inputWidth
},
onFocus: function onFocus() {
setFocused(true);
},
onBlur: function onBlur() {
setFocused(false);
}
}, /*#__PURE__*/react.createElement(Selector_Input, {
ref: inputRef,
open: open,
prefixCls: prefixCls,
id: id,
inputElement: null,
disabled: disabled,
autoFocus: autoFocus,
autoComplete: autoComplete,
editable: inputEditable,
activeDescendantId: activeDescendantId,
value: inputValue,
onKeyDown: onInputKeyDown,
onMouseDown: onInputMouseDown,
onChange: onInputChange,
onPaste: onInputPaste,
onCompositionStart: onInputCompositionStart,
onCompositionEnd: onInputCompositionEnd,
tabIndex: tabIndex,
attrs: (0,pickAttrs/* default */.Z)(props, true)
}), /*#__PURE__*/react.createElement("span", {
ref: measureRef,
className: "".concat(selectionPrefixCls, "-search-mirror"),
"aria-hidden": true
}, inputValue, "\xA0"));
// >>> Selections
var selectionNode = /*#__PURE__*/react.createElement(es/* default */.Z, {
prefixCls: "".concat(selectionPrefixCls, "-overflow"),
data: values,
renderItem: renderItem,
renderRest: renderRest,
suffix: inputNode,
itemKey: itemKey,
maxCount: maxTagCount
});
return /*#__PURE__*/react.createElement(react.Fragment, null, selectionNode, !values.length && !inputValue && /*#__PURE__*/react.createElement("span", {
className: "".concat(selectionPrefixCls, "-placeholder")
}, placeholder));
};
/* harmony default export */ var MultipleSelector = (SelectSelector);
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/node_modules/rc-select/es/Selector/SingleSelector.js
var SingleSelector = function SingleSelector(props) {
var inputElement = props.inputElement,
prefixCls = props.prefixCls,
id = props.id,
inputRef = props.inputRef,
disabled = props.disabled,
autoFocus = props.autoFocus,
autoComplete = props.autoComplete,
activeDescendantId = props.activeDescendantId,
mode = props.mode,
open = props.open,
values = props.values,
placeholder = props.placeholder,
tabIndex = props.tabIndex,
showSearch = props.showSearch,
searchValue = props.searchValue,
activeValue = props.activeValue,
maxLength = props.maxLength,
onInputKeyDown = props.onInputKeyDown,
onInputMouseDown = props.onInputMouseDown,
onInputChange = props.onInputChange,
onInputPaste = props.onInputPaste,
onInputCompositionStart = props.onInputCompositionStart,
onInputCompositionEnd = props.onInputCompositionEnd,
title = props.title;
var _React$useState = react.useState(false),
_React$useState2 = (0,slicedToArray/* default */.Z)(_React$useState, 2),
inputChanged = _React$useState2[0],
setInputChanged = _React$useState2[1];
var combobox = mode === 'combobox';
var inputEditable = combobox || showSearch;
var item = values[0];
var inputValue = searchValue || '';
if (combobox && activeValue && !inputChanged) {
inputValue = activeValue;
}
react.useEffect(function () {
if (combobox) {
setInputChanged(false);
}
}, [combobox, activeValue]);
// Not show text when closed expect combobox mode
var hasTextInput = mode !== 'combobox' && !open && !showSearch ? false : !!inputValue;
// Get title of selection item
var selectionTitle = title === undefined ? getTitle(item) : title;
var renderPlaceholder = function renderPlaceholder() {
if (item) {
return null;
}
var hiddenStyle = hasTextInput ? {
visibility: 'hidden'
} : undefined;
return /*#__PURE__*/react.createElement("span", {
className: "".concat(prefixCls, "-selection-placeholder"),
style: hiddenStyle
}, placeholder);
};
return /*#__PURE__*/react.createElement(react.Fragment, null, /*#__PURE__*/react.createElement("span", {
className: "".concat(prefixCls, "-selection-search")
}, /*#__PURE__*/react.createElement(Selector_Input, {
ref: inputRef,
prefixCls: prefixCls,
id: id,
open: open,
inputElement: inputElement,
disabled: disabled,
autoFocus: autoFocus,
autoComplete: autoComplete,
editable: inputEditable,
activeDescendantId: activeDescendantId,
value: inputValue,
onKeyDown: onInputKeyDown,
onMouseDown: onInputMouseDown,
onChange: function onChange(e) {
setInputChanged(true);
onInputChange(e);
},
onPaste: onInputPaste,
onCompositionStart: onInputCompositionStart,
onCompositionEnd: onInputCompositionEnd,
tabIndex: tabIndex,
attrs: (0,pickAttrs/* default */.Z)(props, true),
maxLength: combobox ? maxLength : undefined
})), !combobox && item ? /*#__PURE__*/react.createElement("span", {
className: "".concat(prefixCls, "-selection-item"),
title: selectionTitle
// 当 Select 已经选中选项时,还需 selection 隐藏但留在原地占位
// https://github.com/ant-design/ant-design/issues/27688
// https://github.com/ant-design/ant-design/issues/41530
,
style: hasTextInput ? {
visibility: 'hidden'
} : undefined
}, item.label) : null, renderPlaceholder());
};
/* harmony default export */ var Selector_SingleSelector = (SingleSelector);
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/node_modules/rc-select/es/utils/keyUtil.js
/** keyCode Judgment function */
function isValidateOpenKey(currentKeyCode) {
return ![
// System function button
KeyCode/* default.ESC */.Z.ESC, KeyCode/* default.SHIFT */.Z.SHIFT, KeyCode/* default.BACKSPACE */.Z.BACKSPACE, KeyCode/* default.TAB */.Z.TAB, KeyCode/* default.WIN_KEY */.Z.WIN_KEY, KeyCode/* default.ALT */.Z.ALT, KeyCode/* default.META */.Z.META, KeyCode/* default.WIN_KEY_RIGHT */.Z.WIN_KEY_RIGHT, KeyCode/* default.CTRL */.Z.CTRL, KeyCode/* default.SEMICOLON */.Z.SEMICOLON, KeyCode/* default.EQUALS */.Z.EQUALS, KeyCode/* default.CAPS_LOCK */.Z.CAPS_LOCK, KeyCode/* default.CONTEXT_MENU */.Z.CONTEXT_MENU,
// F1-F12
KeyCode/* default.F1 */.Z.F1, KeyCode/* default.F2 */.Z.F2, KeyCode/* default.F3 */.Z.F3, KeyCode/* default.F4 */.Z.F4, KeyCode/* default.F5 */.Z.F5, KeyCode/* default.F6 */.Z.F6, KeyCode/* default.F7 */.Z.F7, KeyCode/* default.F8 */.Z.F8, KeyCode/* default.F9 */.Z.F9, KeyCode/* default.F10 */.Z.F10, KeyCode/* default.F11 */.Z.F11, KeyCode/* default.F12 */.Z.F12].includes(currentKeyCode);
}
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/node_modules/rc-select/es/Selector/index.js
/**
* Cursor rule:
* 1. Only `showSearch` enabled
* 2. Only `open` is `true`
* 3. When typing, set `open` to `true` which hit rule of 2
*
* Accessibility:
* - https://www.w3.org/TR/wai-aria-practices/examples/combobox/aria1.1pattern/listbox-combo.html
*/
var Selector = function Selector(props, ref) {
var inputRef = (0,react.useRef)(null);
var compositionStatusRef = (0,react.useRef)(false);
var prefixCls = props.prefixCls,
open = props.open,
mode = props.mode,
showSearch = props.showSearch,
tokenWithEnter = props.tokenWithEnter,
autoClearSearchValue = props.autoClearSearchValue,
onSearch = props.onSearch,
onSearchSubmit = props.onSearchSubmit,
onToggleOpen = props.onToggleOpen,
onInputKeyDown = props.onInputKeyDown,
domRef = props.domRef;
// ======================= Ref =======================
react.useImperativeHandle(ref, function () {
return {
focus: function focus() {
inputRef.current.focus();
},
blur: function blur() {
inputRef.current.blur();
}
};
});
// ====================== Input ======================
var _useLock = useLock(0),
_useLock2 = (0,slicedToArray/* default */.Z)(_useLock, 2),
getInputMouseDown = _useLock2[0],
setInputMouseDown = _useLock2[1];
var onInternalInputKeyDown = function onInternalInputKeyDown(event) {
var which = event.which;
if (which === KeyCode/* default.UP */.Z.UP || which === KeyCode/* default.DOWN */.Z.DOWN) {
event.preventDefault();
}
if (onInputKeyDown) {
onInputKeyDown(event);
}
if (which === KeyCode/* default.ENTER */.Z.ENTER && mode === 'tags' && !compositionStatusRef.current && !open) {
// When menu isn't open, OptionList won't trigger a value change
// So when enter is pressed, the tag's input value should be emitted here to let selector know
onSearchSubmit === null || onSearchSubmit === void 0 ? void 0 : onSearchSubmit(event.target.value);
}
if (isValidateOpenKey(which)) {
onToggleOpen(true);
}
};
/**
* We can not use `findDOMNode` sine it will get warning,
* have to use timer to check if is input element.
*/
var onInternalInputMouseDown = function onInternalInputMouseDown() {
setInputMouseDown(true);
};
// When paste come, ignore next onChange
var pastedTextRef = (0,react.useRef)(null);
var triggerOnSearch = function triggerOnSearch(value) {
if (onSearch(value, true, compositionStatusRef.current) !== false) {
onToggleOpen(true);
}
};
var onInputCompositionStart = function onInputCompositionStart() {
compositionStatusRef.current = true;
};
var onInputCompositionEnd = function onInputCompositionEnd(e) {
compositionStatusRef.current = false;
// Trigger search again to support `tokenSeparators` with typewriting
if (mode !== 'combobox') {
triggerOnSearch(e.target.value);
}
};
var onInputChange = function onInputChange(event) {
var value = event.target.value;
// Pasted text should replace back to origin content
if (tokenWithEnter && pastedTextRef.current && /[\r\n]/.test(pastedTextRef.current)) {
// CRLF will be treated as a single space for input element
var replacedText = pastedTextRef.current.replace(/[\r\n]+$/, '').replace(/\r\n/g, ' ').replace(/[\r\n]/g, ' ');
value = value.replace(replacedText, pastedTextRef.current);
}
pastedTextRef.current = null;
triggerOnSearch(value);
};
var onInputPaste = function onInputPaste(e) {
var clipboardData = e.clipboardData;
var value = clipboardData.getData('text');
pastedTextRef.current = value;
};
var onClick = function onClick(_ref) {
var target = _ref.target;
if (target !== inputRef.current) {
// Should focus input if click the selector
var isIE = document.body.style.msTouchAction !== undefined;
if (isIE) {
setTimeout(function () {
inputRef.current.focus();
});
} else {
inputRef.current.focus();
}
}
};
var onMouseDown = function onMouseDown(event) {
var inputMouseDown = getInputMouseDown();
// when mode is combobox, don't prevent default behavior
// https://github.com/ant-design/ant-design/issues/37320
if (event.target !== inputRef.current && !inputMouseDown && mode !== 'combobox') {
event.preventDefault();
}
if (mode !== 'combobox' && (!showSearch || !inputMouseDown) || !open) {
if (open && autoClearSearchValue !== false) {
onSearch('', true, false);
}
onToggleOpen();
}
};
// ================= Inner Selector ==================
var sharedProps = {
inputRef: inputRef,
onInputKeyDown: onInternalInputKeyDown,
onInputMouseDown: onInternalInputMouseDown,
onInputChange: onInputChange,
onInputPaste: onInputPaste,
onInputCompositionStart: onInputCompositionStart,
onInputCompositionEnd: onInputCompositionEnd
};
var selectNode = mode === 'multiple' || mode === 'tags' ? /*#__PURE__*/react.createElement(MultipleSelector, (0,esm_extends/* default */.Z)({}, props, sharedProps)) : /*#__PURE__*/react.createElement(Selector_SingleSelector, (0,esm_extends/* default */.Z)({}, props, sharedProps));
return /*#__PURE__*/react.createElement("div", {
ref: domRef,
className: "".concat(prefixCls, "-selector"),
onClick: onClick,
onMouseDown: onMouseDown
}, selectNode);
};
var ForwardSelector = /*#__PURE__*/react.forwardRef(Selector);
ForwardSelector.displayName = 'Selector';
/* harmony default export */ var es_Selector = (ForwardSelector);
// EXTERNAL MODULE: ./node_modules/@rc-component/trigger/es/index.js + 42 modules
var trigger_es = __webpack_require__(62709);
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/node_modules/rc-select/es/SelectTrigger.js
var _excluded = ["prefixCls", "disabled", "visible", "children", "popupElement", "containerWidth", "animation", "transitionName", "dropdownStyle", "dropdownClassName", "direction", "placement", "builtinPlacements", "dropdownMatchSelectWidth", "dropdownRender", "dropdownAlign", "getPopupContainer", "empty", "getTriggerDOMNode", "onPopupVisibleChange", "onPopupMouseEnter"];
var getBuiltInPlacements = function getBuiltInPlacements(dropdownMatchSelectWidth) {
// Enable horizontal overflow auto-adjustment when a custom dropdown width is provided
var adjustX = dropdownMatchSelectWidth === true ? 0 : 1;
return {
bottomLeft: {
points: ['tl', 'bl'],
offset: [0, 4],
overflow: {
adjustX: adjustX,
adjustY: 1
},
htmlRegion: 'scroll'
},
bottomRight: {
points: ['tr', 'br'],
offset: [0, 4],
overflow: {
adjustX: adjustX,
adjustY: 1
},
htmlRegion: 'scroll'
},
topLeft: {
points: ['bl', 'tl'],
offset: [0, -4],
overflow: {
adjustX: adjustX,
adjustY: 1
},
htmlRegion: 'scroll'
},
topRight: {
points: ['br', 'tr'],
offset: [0, -4],
overflow: {
adjustX: adjustX,
adjustY: 1
},
htmlRegion: 'scroll'
}
};
};
var SelectTrigger = function SelectTrigger(props, ref) {
var prefixCls = props.prefixCls,
disabled = props.disabled,
visible = props.visible,
children = props.children,
popupElement = props.popupElement,
containerWidth = props.containerWidth,
animation = props.animation,
transitionName = props.transitionName,
dropdownStyle = props.dropdownStyle,
dropdownClassName = props.dropdownClassName,
_props$direction = props.direction,
direction = _props$direction === void 0 ? 'ltr' : _props$direction,
placement = props.placement,
builtinPlacements = props.builtinPlacements,
dropdownMatchSelectWidth = props.dropdownMatchSelectWidth,
dropdownRender = props.dropdownRender,
dropdownAlign = props.dropdownAlign,
getPopupContainer = props.getPopupContainer,
empty = props.empty,
getTriggerDOMNode = props.getTriggerDOMNode,
onPopupVisibleChange = props.onPopupVisibleChange,
onPopupMouseEnter = props.onPopupMouseEnter,
restProps = (0,objectWithoutProperties/* default */.Z)(props, _excluded);
var dropdownPrefixCls = "".concat(prefixCls, "-dropdown");
var popupNode = popupElement;
if (dropdownRender) {
popupNode = dropdownRender(popupElement);
}
var mergedBuiltinPlacements = react.useMemo(function () {
return builtinPlacements || getBuiltInPlacements(dropdownMatchSelectWidth);
}, [builtinPlacements, dropdownMatchSelectWidth]);
// ===================== Motion ======================
var mergedTransitionName = animation ? "".concat(dropdownPrefixCls, "-").concat(animation) : transitionName;
// ======================= Ref =======================
var popupRef = react.useRef(null);
react.useImperativeHandle(ref, function () {
return {
getPopupElement: function getPopupElement() {
return popupRef.current;
}
};
});
var popupStyle = (0,objectSpread2/* default */.Z)({
minWidth: containerWidth
}, dropdownStyle);
if (typeof dropdownMatchSelectWidth === 'number') {
popupStyle.width = dropdownMatchSelectWidth;
} else if (dropdownMatchSelectWidth) {
popupStyle.width = containerWidth;
}
return /*#__PURE__*/react.createElement(trigger_es/* default */.Z, (0,esm_extends/* default */.Z)({}, restProps, {
showAction: onPopupVisibleChange ? ['click'] : [],
hideAction: onPopupVisibleChange ? ['click'] : [],
popupPlacement: placement || (direction === 'rtl' ? 'bottomRight' : 'bottomLeft'),
builtinPlacements: mergedBuiltinPlacements,
prefixCls: dropdownPrefixCls,
popupTransitionName: mergedTransitionName,
popup: /*#__PURE__*/react.createElement("div", {
ref: popupRef,
onMouseEnter: onPopupMouseEnter
}, popupNode),
popupAlign: dropdownAlign,
popupVisible: visible,
getPopupContainer: getPopupContainer,
popupClassName: classnames_default()(dropdownClassName, (0,defineProperty/* default */.Z)({}, "".concat(dropdownPrefixCls, "-empty"), empty)),
popupStyle: popupStyle,
getTriggerDOMNode: getTriggerDOMNode,
onPopupVisibleChange: onPopupVisibleChange
}), children);
};
var RefSelectTrigger = /*#__PURE__*/react.forwardRef(SelectTrigger);
RefSelectTrigger.displayName = 'SelectTrigger';
/* harmony default export */ var es_SelectTrigger = (RefSelectTrigger);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/toArray.js
var esm_toArray = __webpack_require__(84506);
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/node_modules/rc-select/es/utils/valueUtil.js
function getKey(data, index) {
var key = data.key;
var value;
if ('value' in data) {
value = data.value;
}
if (key !== null && key !== undefined) {
return key;
}
if (value !== undefined) {
return value;
}
return "rc-index-key-".concat(index);
}
function fillFieldNames(fieldNames, childrenAsData) {
var _ref = fieldNames || {},
label = _ref.label,
value = _ref.value,
options = _ref.options,
groupLabel = _ref.groupLabel;
var mergedLabel = label || (childrenAsData ? 'children' : 'label');
return {
label: mergedLabel,
value: value || 'value',
options: options || 'options',
groupLabel: groupLabel || mergedLabel
};
}
/**
* Flat options into flatten list.
* We use `optionOnly` here is aim to avoid user use nested option group.
* Here is simply set `key` to the index if not provided.
*/
function flattenOptions(options) {
var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
fieldNames = _ref2.fieldNames,
childrenAsData = _ref2.childrenAsData;
var flattenList = [];
var _fillFieldNames = fillFieldNames(fieldNames, false),
fieldLabel = _fillFieldNames.label,
fieldValue = _fillFieldNames.value,
fieldOptions = _fillFieldNames.options,
groupLabel = _fillFieldNames.groupLabel;
function dig(list, isGroupOption) {
list.forEach(function (data) {
if (isGroupOption || !(fieldOptions in data)) {
var value = data[fieldValue];
// Option
flattenList.push({
key: getKey(data, flattenList.length),
groupOption: isGroupOption,
data: data,
label: data[fieldLabel],
value: value
});
} else {
var grpLabel = data[groupLabel];
if (grpLabel === undefined && childrenAsData) {
grpLabel = data.label;
}
// Option Group
flattenList.push({
key: getKey(data, flattenList.length),
group: true,
data: data,
label: grpLabel
});
dig(data[fieldOptions], true);
}
});
}
dig(options, false);
return flattenList;
}
/**
* Inject `props` into `option` for legacy usage
*/
function injectPropsWithOption(option) {
var newOption = (0,objectSpread2/* default */.Z)({}, option);
if (!('props' in newOption)) {
Object.defineProperty(newOption, 'props', {
get: function get() {
(0,es_warning/* default */.ZP)(false, 'Return type is option instead of Option instance. Please read value directly instead of reading from `props`.');
return newOption;
}
});
}
return newOption;
}
function getSeparatedContent(text, tokens) {
if (!tokens || !tokens.length) {
return null;
}
var match = false;
function separate(str, _ref3) {
var _ref4 = (0,esm_toArray/* default */.Z)(_ref3),
token = _ref4[0],
restTokens = _ref4.slice(1);
if (!token) {
return [str];
}
var list = str.split(token);
match = match || list.length > 1;
return list.reduce(function (prevList, unitStr) {
return [].concat((0,toConsumableArray/* default */.Z)(prevList), (0,toConsumableArray/* default */.Z)(separate(unitStr, restTokens)));
}, []).filter(function (unit) {
return unit;
});
}
var list = separate(text, tokens);
return match ? list : null;
}
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/node_modules/rc-select/es/BaseSelect.js
var BaseSelect_excluded = ["id", "prefixCls", "className", "showSearch", "tagRender", "direction", "omitDomProps", "displayValues", "onDisplayValuesChange", "emptyOptions", "notFoundContent", "onClear", "mode", "disabled", "loading", "getInputElement", "getRawInputElement", "open", "defaultOpen", "onDropdownVisibleChange", "activeValue", "onActiveValueChange", "activeDescendantId", "searchValue", "autoClearSearchValue", "onSearch", "onSearchSplit", "tokenSeparators", "allowClear", "showArrow", "inputIcon", "clearIcon", "OptionList", "animation", "transitionName", "dropdownStyle", "dropdownClassName", "dropdownMatchSelectWidth", "dropdownRender", "dropdownAlign", "placement", "builtinPlacements", "getPopupContainer", "showAction", "onFocus", "onBlur", "onKeyUp", "onKeyDown", "onMouseDown"];
var DEFAULT_OMIT_PROPS = ['value', 'onChange', 'removeIcon', 'placeholder', 'autoFocus', 'maxTagCount', 'maxTagTextLength', 'maxTagPlaceholder', 'choiceTransitionName', 'onInputKeyDown', 'onPopupScroll', 'tabIndex'];
function BaseSelect_isMultiple(mode) {
return mode === 'tags' || mode === 'multiple';
}
var BaseSelect = /*#__PURE__*/react.forwardRef(function (props, ref) {
var _customizeRawInputEle, _classNames2;
var id = props.id,
prefixCls = props.prefixCls,
className = props.className,
showSearch = props.showSearch,
tagRender = props.tagRender,
direction = props.direction,
omitDomProps = props.omitDomProps,
displayValues = props.displayValues,
onDisplayValuesChange = props.onDisplayValuesChange,
emptyOptions = props.emptyOptions,
_props$notFoundConten = props.notFoundContent,
notFoundContent = _props$notFoundConten === void 0 ? 'Not Found' : _props$notFoundConten,
onClear = props.onClear,
mode = props.mode,
disabled = props.disabled,
loading = props.loading,
getInputElement = props.getInputElement,
getRawInputElement = props.getRawInputElement,
open = props.open,
defaultOpen = props.defaultOpen,
onDropdownVisibleChange = props.onDropdownVisibleChange,
activeValue = props.activeValue,
onActiveValueChange = props.onActiveValueChange,
activeDescendantId = props.activeDescendantId,
searchValue = props.searchValue,
autoClearSearchValue = props.autoClearSearchValue,
onSearch = props.onSearch,
onSearchSplit = props.onSearchSplit,
tokenSeparators = props.tokenSeparators,
allowClear = props.allowClear,
showArrow = props.showArrow,
inputIcon = props.inputIcon,
clearIcon = props.clearIcon,
OptionList = props.OptionList,
animation = props.animation,
transitionName = props.transitionName,
dropdownStyle = props.dropdownStyle,
dropdownClassName = props.dropdownClassName,
dropdownMatchSelectWidth = props.dropdownMatchSelectWidth,
dropdownRender = props.dropdownRender,
dropdownAlign = props.dropdownAlign,
placement = props.placement,
builtinPlacements = props.builtinPlacements,
getPopupContainer = props.getPopupContainer,
_props$showAction = props.showAction,
showAction = _props$showAction === void 0 ? [] : _props$showAction,
onFocus = props.onFocus,
onBlur = props.onBlur,
onKeyUp = props.onKeyUp,
onKeyDown = props.onKeyDown,
onMouseDown = props.onMouseDown,
restProps = (0,objectWithoutProperties/* default */.Z)(props, BaseSelect_excluded);
// ============================== MISC ==============================
var multiple = BaseSelect_isMultiple(mode);
var mergedShowSearch = (showSearch !== undefined ? showSearch : multiple) || mode === 'combobox';
var domProps = (0,objectSpread2/* default */.Z)({}, restProps);
DEFAULT_OMIT_PROPS.forEach(function (propName) {
delete domProps[propName];
});
omitDomProps === null || omitDomProps === void 0 ? void 0 : omitDomProps.forEach(function (propName) {
delete domProps[propName];
});
// ============================= Mobile =============================
var _React$useState = react.useState(false),
_React$useState2 = (0,slicedToArray/* default */.Z)(_React$useState, 2),
mobile = _React$useState2[0],
setMobile = _React$useState2[1];
react.useEffect(function () {
// Only update on the client side
setMobile((0,isMobile/* default */.Z)());
}, []);
// ============================== Refs ==============================
var containerRef = react.useRef(null);
var selectorDomRef = react.useRef(null);
var triggerRef = react.useRef(null);
var selectorRef = react.useRef(null);
var listRef = react.useRef(null);
/** Used for component focused management */
var _useDelayReset = useDelayReset(),
_useDelayReset2 = (0,slicedToArray/* default */.Z)(_useDelayReset, 3),
mockFocused = _useDelayReset2[0],
setMockFocused = _useDelayReset2[1],
cancelSetMockFocused = _useDelayReset2[2];
// =========================== Imperative ===========================
react.useImperativeHandle(ref, function () {
var _selectorRef$current, _selectorRef$current2;
return {
focus: (_selectorRef$current = selectorRef.current) === null || _selectorRef$current === void 0 ? void 0 : _selectorRef$current.focus,
blur: (_selectorRef$current2 = selectorRef.current) === null || _selectorRef$current2 === void 0 ? void 0 : _selectorRef$current2.blur,
scrollTo: function scrollTo(arg) {
var _listRef$current;
return (_listRef$current = listRef.current) === null || _listRef$current === void 0 ? void 0 : _listRef$current.scrollTo(arg);
}
};
});
// ========================== Search Value ==========================
var mergedSearchValue = react.useMemo(function () {
var _displayValues$;
if (mode !== 'combobox') {
return searchValue;
}
var val = (_displayValues$ = displayValues[0]) === null || _displayValues$ === void 0 ? void 0 : _displayValues$.value;
return typeof val === 'string' || typeof val === 'number' ? String(val) : '';
}, [searchValue, mode, displayValues]);
// ========================== Custom Input ==========================
// Only works in `combobox`
var customizeInputElement = mode === 'combobox' && typeof getInputElement === 'function' && getInputElement() || null;
// Used for customize replacement for `rc-cascader`
var customizeRawInputElement = typeof getRawInputElement === 'function' && getRawInputElement();
var customizeRawInputRef = (0,es_ref/* useComposeRef */.x1)(selectorDomRef, customizeRawInputElement === null || customizeRawInputElement === void 0 ? void 0 : (_customizeRawInputEle = customizeRawInputElement.props) === null || _customizeRawInputEle === void 0 ? void 0 : _customizeRawInputEle.ref);
// ============================== Open ==============================
// SSR not support Portal which means we need delay `open` for the first time render
var _React$useState3 = react.useState(false),
_React$useState4 = (0,slicedToArray/* default */.Z)(_React$useState3, 2),
rendered = _React$useState4[0],
setRendered = _React$useState4[1];
(0,useLayoutEffect/* default */.Z)(function () {
setRendered(true);
}, []);
var _useMergedState = (0,useMergedState/* default */.Z)(false, {
defaultValue: defaultOpen,
value: open
}),
_useMergedState2 = (0,slicedToArray/* default */.Z)(_useMergedState, 2),
innerOpen = _useMergedState2[0],
setInnerOpen = _useMergedState2[1];
var mergedOpen = rendered ? innerOpen : false;
// Not trigger `open` in `combobox` when `notFoundContent` is empty
var emptyListContent = !notFoundContent && emptyOptions;
if (disabled || emptyListContent && mergedOpen && mode === 'combobox') {
mergedOpen = false;
}
var triggerOpen = emptyListContent ? false : mergedOpen;
var onToggleOpen = react.useCallback(function (newOpen) {
var nextOpen = newOpen !== undefined ? newOpen : !mergedOpen;
if (!disabled) {
setInnerOpen(nextOpen);
if (mergedOpen !== nextOpen) {
onDropdownVisibleChange === null || onDropdownVisibleChange === void 0 ? void 0 : onDropdownVisibleChange(nextOpen);
}
}
}, [disabled, mergedOpen, setInnerOpen, onDropdownVisibleChange]);
// ============================= Search =============================
var tokenWithEnter = react.useMemo(function () {
return (tokenSeparators || []).some(function (tokenSeparator) {
return ['\n', '\r\n'].includes(tokenSeparator);
});
}, [tokenSeparators]);
var onInternalSearch = function onInternalSearch(searchText, fromTyping, isCompositing) {
var ret = true;
var newSearchText = searchText;
onActiveValueChange === null || onActiveValueChange === void 0 ? void 0 : onActiveValueChange(null);
// Check if match the `tokenSeparators`
var patchLabels = isCompositing ? null : getSeparatedContent(searchText, tokenSeparators);
// Ignore combobox since it's not split-able
if (mode !== 'combobox' && patchLabels) {
newSearchText = '';
onSearchSplit === null || onSearchSplit === void 0 ? void 0 : onSearchSplit(patchLabels);
// Should close when paste finish
onToggleOpen(false);
// Tell Selector that break next actions
ret = false;
}
if (onSearch && mergedSearchValue !== newSearchText) {
onSearch(newSearchText, {
source: fromTyping ? 'typing' : 'effect'
});
}
return ret;
};
// Only triggered when menu is closed & mode is tags
// If menu is open, OptionList will take charge
// If mode isn't tags, press enter is not meaningful when you can't see any option
var onInternalSearchSubmit = function onInternalSearchSubmit(searchText) {
// prevent empty tags from appearing when you click the Enter button
if (!searchText || !searchText.trim()) {
return;
}
onSearch(searchText, {
source: 'submit'
});
};
// Close will clean up single mode search text
react.useEffect(function () {
if (!mergedOpen && !multiple && mode !== 'combobox') {
onInternalSearch('', false, false);
}
}, [mergedOpen]);
// ============================ Disabled ============================
// Close dropdown & remove focus state when disabled change
react.useEffect(function () {
if (innerOpen && disabled) {
setInnerOpen(false);
}
if (disabled) {
setMockFocused(false);
}
}, [disabled]);
// ============================ Keyboard ============================
/**
* We record input value here to check if can press to clean up by backspace
* - null: Key is not down, this is reset by key up
* - true: Search text is empty when first time backspace down
* - false: Search text is not empty when first time backspace down
*/
var _useLock = useLock(),
_useLock2 = (0,slicedToArray/* default */.Z)(_useLock, 2),
getClearLock = _useLock2[0],
setClearLock = _useLock2[1];
// KeyDown
var onInternalKeyDown = function onInternalKeyDown(event) {
var clearLock = getClearLock();
var which = event.which;
if (which === KeyCode/* default.ENTER */.Z.ENTER) {
// Do not submit form when type in the input
if (mode !== 'combobox') {
event.preventDefault();
}
// We only manage open state here, close logic should handle by list component
if (!mergedOpen) {
onToggleOpen(true);
}
}
setClearLock(!!mergedSearchValue);
// Remove value by `backspace`
if (which === KeyCode/* default.BACKSPACE */.Z.BACKSPACE && !clearLock && multiple && !mergedSearchValue && displayValues.length) {
var cloneDisplayValues = (0,toConsumableArray/* default */.Z)(displayValues);
var removedDisplayValue = null;
for (var i = cloneDisplayValues.length - 1; i >= 0; i -= 1) {
var current = cloneDisplayValues[i];
if (!current.disabled) {
cloneDisplayValues.splice(i, 1);
removedDisplayValue = current;
break;
}
}
if (removedDisplayValue) {
onDisplayValuesChange(cloneDisplayValues, {
type: 'remove',
values: [removedDisplayValue]
});
}
}
for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
rest[_key - 1] = arguments[_key];
}
if (mergedOpen && listRef.current) {
var _listRef$current2;
(_listRef$current2 = listRef.current).onKeyDown.apply(_listRef$current2, [event].concat(rest));
}
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown.apply(void 0, [event].concat(rest));
};
// KeyUp
var onInternalKeyUp = function onInternalKeyUp(event) {
for (var _len2 = arguments.length, rest = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
rest[_key2 - 1] = arguments[_key2];
}
if (mergedOpen && listRef.current) {
var _listRef$current3;
(_listRef$current3 = listRef.current).onKeyUp.apply(_listRef$current3, [event].concat(rest));
}
onKeyUp === null || onKeyUp === void 0 ? void 0 : onKeyUp.apply(void 0, [event].concat(rest));
};
// ============================ Selector ============================
var onSelectorRemove = function onSelectorRemove(val) {
var newValues = displayValues.filter(function (i) {
return i !== val;
});
onDisplayValuesChange(newValues, {
type: 'remove',
values: [val]
});
};
// ========================== Focus / Blur ==========================
/** Record real focus status */
var focusRef = react.useRef(false);
var onContainerFocus = function onContainerFocus() {
setMockFocused(true);
if (!disabled) {
if (onFocus && !focusRef.current) {
onFocus.apply(void 0, arguments);
}
// `showAction` should handle `focus` if set
if (showAction.includes('focus')) {
onToggleOpen(true);
}
}
focusRef.current = true;
};
var onContainerBlur = function onContainerBlur() {
setMockFocused(false, function () {
focusRef.current = false;
onToggleOpen(false);
});
if (disabled) {
return;
}
if (mergedSearchValue) {
// `tags` mode should move `searchValue` into values
if (mode === 'tags') {
onSearch(mergedSearchValue, {
source: 'submit'
});
} else if (mode === 'multiple') {
// `multiple` mode only clean the search value but not trigger event
onSearch('', {
source: 'blur'
});
}
}
if (onBlur) {
onBlur.apply(void 0, arguments);
}
};
// Give focus back of Select
var activeTimeoutIds = [];
react.useEffect(function () {
return function () {
activeTimeoutIds.forEach(function (timeoutId) {
return clearTimeout(timeoutId);
});
activeTimeoutIds.splice(0, activeTimeoutIds.length);
};
}, []);
var onInternalMouseDown = function onInternalMouseDown(event) {
var _triggerRef$current;
var target = event.target;
var popupElement = (_triggerRef$current = triggerRef.current) === null || _triggerRef$current === void 0 ? void 0 : _triggerRef$current.getPopupElement();
// We should give focus back to selector if clicked item is not focusable
if (popupElement && popupElement.contains(target)) {
var timeoutId = setTimeout(function () {
var index = activeTimeoutIds.indexOf(timeoutId);
if (index !== -1) {
activeTimeoutIds.splice(index, 1);
}
cancelSetMockFocused();
if (!mobile && !popupElement.contains(document.activeElement)) {
var _selectorRef$current3;
(_selectorRef$current3 = selectorRef.current) === null || _selectorRef$current3 === void 0 ? void 0 : _selectorRef$current3.focus();
}
});
activeTimeoutIds.push(timeoutId);
}
for (var _len3 = arguments.length, restArgs = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
restArgs[_key3 - 1] = arguments[_key3];
}
onMouseDown === null || onMouseDown === void 0 ? void 0 : onMouseDown.apply(void 0, [event].concat(restArgs));
};
// ============================ Dropdown ============================
var _React$useState5 = react.useState(null),
_React$useState6 = (0,slicedToArray/* default */.Z)(_React$useState5, 2),
containerWidth = _React$useState6[0],
setContainerWidth = _React$useState6[1];
var _React$useState7 = react.useState({}),
_React$useState8 = (0,slicedToArray/* default */.Z)(_React$useState7, 2),
forceUpdate = _React$useState8[1];
// We need force update here since popup dom is render async
function onPopupMouseEnter() {
forceUpdate({});
}
(0,useLayoutEffect/* default */.Z)(function () {
if (triggerOpen) {
var _containerRef$current;
var newWidth = Math.ceil((_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.offsetWidth);
if (containerWidth !== newWidth && !Number.isNaN(newWidth)) {
setContainerWidth(newWidth);
}
}
}, [triggerOpen]);
// Used for raw custom input trigger
var onTriggerVisibleChange;
if (customizeRawInputElement) {
onTriggerVisibleChange = function onTriggerVisibleChange(newOpen) {
onToggleOpen(newOpen);
};
}
// Close when click on non-select element
useSelectTriggerControl(function () {
var _triggerRef$current2;
return [containerRef.current, (_triggerRef$current2 = triggerRef.current) === null || _triggerRef$current2 === void 0 ? void 0 : _triggerRef$current2.getPopupElement()];
}, triggerOpen, onToggleOpen, !!customizeRawInputElement);
// ============================ Context =============================
var baseSelectContext = react.useMemo(function () {
return (0,objectSpread2/* default */.Z)((0,objectSpread2/* default */.Z)({}, props), {}, {
notFoundContent: notFoundContent,
open: mergedOpen,
triggerOpen: triggerOpen,
id: id,
showSearch: mergedShowSearch,
multiple: multiple,
toggleOpen: onToggleOpen
});
}, [props, notFoundContent, triggerOpen, mergedOpen, id, mergedShowSearch, multiple, onToggleOpen]);
// ==================================================================
// == Render ==
// ==================================================================
// ============================= Arrow ==============================
var mergedShowArrow = showArrow !== undefined ? showArrow : loading || !multiple && mode !== 'combobox';
var arrowNode;
if (mergedShowArrow) {
arrowNode = /*#__PURE__*/react.createElement(es_TransBtn, {
className: classnames_default()("".concat(prefixCls, "-arrow"), (0,defineProperty/* default */.Z)({}, "".concat(prefixCls, "-arrow-loading"), loading)),
customizeIcon: inputIcon,
customizeIconProps: {
loading: loading,
searchValue: mergedSearchValue,
open: mergedOpen,
focused: mockFocused,
showSearch: mergedShowSearch
}
});
}
// ============================= Clear ==============================
var clearNode;
var onClearMouseDown = function onClearMouseDown() {
var _selectorRef$current4;
onClear === null || onClear === void 0 ? void 0 : onClear();
(_selectorRef$current4 = selectorRef.current) === null || _selectorRef$current4 === void 0 ? void 0 : _selectorRef$current4.focus();
onDisplayValuesChange([], {
type: 'clear',
values: displayValues
});
onInternalSearch('', false, false);
};
if (!disabled && allowClear && (displayValues.length || mergedSearchValue) && !(mode === 'combobox' && mergedSearchValue === '')) {
clearNode = /*#__PURE__*/react.createElement(es_TransBtn, {
className: "".concat(prefixCls, "-clear"),
onMouseDown: onClearMouseDown,
customizeIcon: clearIcon
}, "\xD7");
}
// =========================== OptionList ===========================
var optionList = /*#__PURE__*/react.createElement(OptionList, {
ref: listRef
});
// ============================= Select =============================
var mergedClassName = classnames_default()(prefixCls, className, (_classNames2 = {}, (0,defineProperty/* default */.Z)(_classNames2, "".concat(prefixCls, "-focused"), mockFocused), (0,defineProperty/* default */.Z)(_classNames2, "".concat(prefixCls, "-multiple"), multiple), (0,defineProperty/* default */.Z)(_classNames2, "".concat(prefixCls, "-single"), !multiple), (0,defineProperty/* default */.Z)(_classNames2, "".concat(prefixCls, "-allow-clear"), allowClear), (0,defineProperty/* default */.Z)(_classNames2, "".concat(prefixCls, "-show-arrow"), mergedShowArrow), (0,defineProperty/* default */.Z)(_classNames2, "".concat(prefixCls, "-disabled"), disabled), (0,defineProperty/* default */.Z)(_classNames2, "".concat(prefixCls, "-loading"), loading), (0,defineProperty/* default */.Z)(_classNames2, "".concat(prefixCls, "-open"), mergedOpen), (0,defineProperty/* default */.Z)(_classNames2, "".concat(prefixCls, "-customize-input"), customizeInputElement), (0,defineProperty/* default */.Z)(_classNames2, "".concat(prefixCls, "-show-search"), mergedShowSearch), _classNames2));
// >>> Selector
var selectorNode = /*#__PURE__*/react.createElement(es_SelectTrigger, {
ref: triggerRef,
disabled: disabled,
prefixCls: prefixCls,
visible: triggerOpen,
popupElement: optionList,
containerWidth: containerWidth,
animation: animation,
transitionName: transitionName,
dropdownStyle: dropdownStyle,
dropdownClassName: dropdownClassName,
direction: direction,
dropdownMatchSelectWidth: dropdownMatchSelectWidth,
dropdownRender: dropdownRender,
dropdownAlign: dropdownAlign,
placement: placement,
builtinPlacements: builtinPlacements,
getPopupContainer: getPopupContainer,
empty: emptyOptions,
getTriggerDOMNode: function getTriggerDOMNode() {
return selectorDomRef.current;
},
onPopupVisibleChange: onTriggerVisibleChange,
onPopupMouseEnter: onPopupMouseEnter
}, customizeRawInputElement ? /*#__PURE__*/react.cloneElement(customizeRawInputElement, {
ref: customizeRawInputRef
}) : /*#__PURE__*/react.createElement(es_Selector, (0,esm_extends/* default */.Z)({}, props, {
domRef: selectorDomRef,
prefixCls: prefixCls,
inputElement: customizeInputElement,
ref: selectorRef,
id: id,
showSearch: mergedShowSearch,
autoClearSearchValue: autoClearSearchValue,
mode: mode,
activeDescendantId: activeDescendantId,
tagRender: tagRender,
values: displayValues,
open: mergedOpen,
onToggleOpen: onToggleOpen,
activeValue: activeValue,
searchValue: mergedSearchValue,
onSearch: onInternalSearch,
onSearchSubmit: onInternalSearchSubmit,
onRemove: onSelectorRemove,
tokenWithEnter: tokenWithEnter
})));
// >>> Render
var renderNode;
// Render raw
if (customizeRawInputElement) {
renderNode = selectorNode;
} else {
renderNode = /*#__PURE__*/react.createElement("div", (0,esm_extends/* default */.Z)({
className: mergedClassName
}, domProps, {
ref: containerRef,
onMouseDown: onInternalMouseDown,
onKeyDown: onInternalKeyDown,
onKeyUp: onInternalKeyUp,
onFocus: onContainerFocus,
onBlur: onContainerBlur
}), mockFocused && !mergedOpen && /*#__PURE__*/react.createElement("span", {
style: {
width: 0,
height: 0,
position: 'absolute',
overflow: 'hidden',
opacity: 0
},
"aria-live": "polite"
}, "".concat(displayValues.map(function (_ref) {
var label = _ref.label,
value = _ref.value;
return ['number', 'string'].includes((0,esm_typeof/* default */.Z)(label)) ? label : value;
}).join(', '))), selectorNode, arrowNode, clearNode);
}
return /*#__PURE__*/react.createElement(BaseSelectContext.Provider, {
value: baseSelectContext
}, renderNode);
});
// Set display name for dev
if (false) {}
/* harmony default export */ var es_BaseSelect = (BaseSelect);
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/node_modules/rc-select/es/hooks/useCache.js
/**
* Cache `value` related LabeledValue & options.
*/
/* harmony default export */ var useCache = (function (labeledValues, valueOptions) {
var cacheRef = react.useRef({
values: new Map(),
options: new Map()
});
var filledLabeledValues = react.useMemo(function () {
var _cacheRef$current = cacheRef.current,
prevValueCache = _cacheRef$current.values,
prevOptionCache = _cacheRef$current.options;
// Fill label by cache
var patchedValues = labeledValues.map(function (item) {
if (item.label === undefined) {
var _prevValueCache$get;
return (0,objectSpread2/* default */.Z)((0,objectSpread2/* default */.Z)({}, item), {}, {
label: (_prevValueCache$get = prevValueCache.get(item.value)) === null || _prevValueCache$get === void 0 ? void 0 : _prevValueCache$get.label
});
}
return item;
});
// Refresh cache
var valueCache = new Map();
var optionCache = new Map();
patchedValues.forEach(function (item) {
valueCache.set(item.value, item);
optionCache.set(item.value, valueOptions.get(item.value) || prevOptionCache.get(item.value));
});
cacheRef.current.values = valueCache;
cacheRef.current.options = optionCache;
return patchedValues;
}, [labeledValues, valueOptions]);
var getOption = react.useCallback(function (val) {
return valueOptions.get(val) || cacheRef.current.options.get(val);
}, [valueOptions]);
return [filledLabeledValues, getOption];
});
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/node_modules/rc-select/es/hooks/useFilterOptions.js
function includes(test, search) {
return commonUtil_toArray(test).join('').toUpperCase().includes(search);
}
/* harmony default export */ var useFilterOptions = (function (options, fieldNames, searchValue, filterOption, optionFilterProp) {
return react.useMemo(function () {
if (!searchValue || filterOption === false) {
return options;
}
var fieldOptions = fieldNames.options,
fieldLabel = fieldNames.label,
fieldValue = fieldNames.value;
var filteredOptions = [];
var customizeFilter = typeof filterOption === 'function';
var upperSearch = searchValue.toUpperCase();
var filterFunc = customizeFilter ? filterOption : function (_, option) {
// Use provided `optionFilterProp`
if (optionFilterProp) {
return includes(option[optionFilterProp], upperSearch);
}
// Auto select `label` or `value` by option type
if (option[fieldOptions]) {
// hack `fieldLabel` since `OptionGroup` children is not `label`
return includes(option[fieldLabel !== 'children' ? fieldLabel : 'label'], upperSearch);
}
return includes(option[fieldValue], upperSearch);
};
var wrapOption = customizeFilter ? function (opt) {
return injectPropsWithOption(opt);
} : function (opt) {
return opt;
};
options.forEach(function (item) {
// Group should check child options
if (item[fieldOptions]) {
// Check group first
var matchGroup = filterFunc(searchValue, wrapOption(item));
if (matchGroup) {
filteredOptions.push(item);
} else {
// Check option
var subOptions = item[fieldOptions].filter(function (subItem) {
return filterFunc(searchValue, wrapOption(subItem));
});
if (subOptions.length) {
filteredOptions.push((0,objectSpread2/* default */.Z)((0,objectSpread2/* default */.Z)({}, item), {}, (0,defineProperty/* default */.Z)({}, fieldOptions, subOptions)));
}
}
return;
}
if (filterFunc(searchValue, wrapOption(item))) {
filteredOptions.push(item);
}
});
return filteredOptions;
}, [options, filterOption, optionFilterProp, searchValue, fieldNames]);
});
// EXTERNAL MODULE: ./node_modules/rc-util/es/Dom/canUseDom.js
var canUseDom = __webpack_require__(98924);
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/node_modules/rc-select/es/hooks/useId.js
var uuid = 0;
/** Is client side and not jsdom */
var useId_isBrowserClient = true && (0,canUseDom/* default */.Z)();
/** Get unique id for accessibility usage */
function getUUID() {
var retId;
// Test never reach
/* istanbul ignore if */
if (useId_isBrowserClient) {
retId = uuid;
uuid += 1;
} else {
retId = 'TEST_OR_SSR';
}
return retId;
}
function useId(id) {
// Inner id for accessibility usage. Only work in client side
var _React$useState = react.useState(),
_React$useState2 = (0,slicedToArray/* default */.Z)(_React$useState, 2),
innerId = _React$useState2[0],
setInnerId = _React$useState2[1];
react.useEffect(function () {
setInnerId("rc_select_".concat(getUUID()));
}, []);
return id || innerId;
}
// EXTERNAL MODULE: ./node_modules/rc-util/es/Children/toArray.js
var Children_toArray = __webpack_require__(50344);
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/node_modules/rc-select/es/utils/legacyUtil.js
var legacyUtil_excluded = ["children", "value"],
_excluded2 = ["children"];
function convertNodeToOption(node) {
var _ref = node,
key = _ref.key,
_ref$props = _ref.props,
children = _ref$props.children,
value = _ref$props.value,
restProps = (0,objectWithoutProperties/* default */.Z)(_ref$props, legacyUtil_excluded);
return (0,objectSpread2/* default */.Z)({
key: key,
value: value !== undefined ? value : key,
children: children
}, restProps);
}
function legacyUtil_convertChildrenToData(nodes) {
var optionOnly = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
return (0,Children_toArray/* default */.Z)(nodes).map(function (node, index) {
if (! /*#__PURE__*/react.isValidElement(node) || !node.type) {
return null;
}
var _ref2 = node,
isSelectOptGroup = _ref2.type.isSelectOptGroup,
key = _ref2.key,
_ref2$props = _ref2.props,
children = _ref2$props.children,
restProps = (0,objectWithoutProperties/* default */.Z)(_ref2$props, _excluded2);
if (optionOnly || !isSelectOptGroup) {
return convertNodeToOption(node);
}
return (0,objectSpread2/* default */.Z)((0,objectSpread2/* default */.Z)({
key: "__RC_SELECT_GRP__".concat(key === null ? index : key, "__"),
label: key
}, restProps), {}, {
options: legacyUtil_convertChildrenToData(children)
});
}).filter(function (data) {
return data;
});
}
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/node_modules/rc-select/es/hooks/useOptions.js
/**
* Parse `children` to `options` if `options` is not provided.
* Then flatten the `options`.
*/
function useOptions(options, children, fieldNames, optionFilterProp, optionLabelProp) {
return react.useMemo(function () {
var mergedOptions = options;
var childrenAsData = !options;
if (childrenAsData) {
mergedOptions = legacyUtil_convertChildrenToData(children);
}
var valueOptions = new Map();
var labelOptions = new Map();
var setLabelOptions = function setLabelOptions(labelOptionsMap, option, key) {
if (key && typeof key === 'string') {
labelOptionsMap.set(option[key], option);
}
};
function dig(optionList) {
var isChildren = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
// for loop to speed up collection speed
for (var i = 0; i < optionList.length; i += 1) {
var option = optionList[i];
if (!option[fieldNames.options] || isChildren) {
valueOptions.set(option[fieldNames.value], option);
setLabelOptions(labelOptions, option, fieldNames.label);
// https://github.com/ant-design/ant-design/issues/35304
setLabelOptions(labelOptions, option, optionFilterProp);
setLabelOptions(labelOptions, option, optionLabelProp);
} else {
dig(option[fieldNames.options], true);
}
}
}
dig(mergedOptions);
return {
options: mergedOptions,
valueOptions: valueOptions,
labelOptions: labelOptions
};
}, [options, children, fieldNames, optionFilterProp, optionLabelProp]);
}
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/node_modules/rc-select/es/hooks/useRefFunc.js
/**
* Same as `React.useCallback` but always return a memoized function
* but redirect to real function.
*/
function useRefFunc(callback) {
var funcRef = react.useRef();
funcRef.current = callback;
var cacheFn = react.useCallback(function () {
return funcRef.current.apply(funcRef, arguments);
}, []);
return cacheFn;
}
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/node_modules/rc-select/es/OptGroup.js
/* istanbul ignore file */
/** This is a placeholder, not real render in dom */
var OptGroup = function OptGroup() {
return null;
};
OptGroup.isSelectOptGroup = true;
/* harmony default export */ var es_OptGroup = (OptGroup);
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/node_modules/rc-select/es/Option.js
/* istanbul ignore file */
/** This is a placeholder, not real render in dom */
var Option = function Option() {
return null;
};
Option.isSelectOption = true;
/* harmony default export */ var es_Option = (Option);
// EXTERNAL MODULE: ./node_modules/rc-util/es/hooks/useMemo.js
var useMemo = __webpack_require__(56982);
// EXTERNAL MODULE: ./node_modules/rc-util/es/omit.js
var omit = __webpack_require__(98423);
// EXTERNAL MODULE: ./node_modules/rc-resize-observer/es/index.js + 4 modules
var rc_resize_observer_es = __webpack_require__(48555);
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/node_modules/rc-virtual-list/es/Filler.js
/**
* Fill component to provided the scroll content real height.
*/
var Filler = /*#__PURE__*/react.forwardRef(function (_ref, ref) {
var height = _ref.height,
offset = _ref.offset,
children = _ref.children,
prefixCls = _ref.prefixCls,
onInnerResize = _ref.onInnerResize,
innerProps = _ref.innerProps;
var outerStyle = {};
var innerStyle = {
display: 'flex',
flexDirection: 'column'
};
if (offset !== undefined) {
outerStyle = {
height: height,
position: 'relative',
overflow: 'hidden'
};
innerStyle = (0,objectSpread2/* default */.Z)((0,objectSpread2/* default */.Z)({}, innerStyle), {}, {
transform: "translateY(".concat(offset, "px)"),
position: 'absolute',
left: 0,
right: 0,
top: 0
});
}
return /*#__PURE__*/react.createElement("div", {
style: outerStyle
}, /*#__PURE__*/react.createElement(rc_resize_observer_es/* default */.Z, {
onResize: function onResize(_ref2) {
var offsetHeight = _ref2.offsetHeight;
if (offsetHeight && onInnerResize) {
onInnerResize();
}
}
}, /*#__PURE__*/react.createElement("div", (0,esm_extends/* default */.Z)({
style: innerStyle,
className: classnames_default()((0,defineProperty/* default */.Z)({}, "".concat(prefixCls, "-holder-inner"), prefixCls)),
ref: ref
}, innerProps), children)));
});
Filler.displayName = 'Filler';
/* harmony default export */ var es_Filler = (Filler);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/classCallCheck.js
var classCallCheck = __webpack_require__(15671);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/createClass.js
var createClass = __webpack_require__(43144);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/inherits.js
var inherits = __webpack_require__(60136);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/createSuper.js + 1 modules
var createSuper = __webpack_require__(51630);
// EXTERNAL MODULE: ./node_modules/rc-util/es/raf.js
var raf = __webpack_require__(75164);
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/node_modules/rc-virtual-list/es/ScrollBar.js
var MIN_SIZE = 20;
function getPageY(e) {
return 'touches' in e ? e.touches[0].pageY : e.pageY;
}
var ScrollBar = /*#__PURE__*/function (_React$Component) {
(0,inherits/* default */.Z)(ScrollBar, _React$Component);
var _super = (0,createSuper/* default */.Z)(ScrollBar);
function ScrollBar() {
var _this;
(0,classCallCheck/* default */.Z)(this, ScrollBar);
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
_this = _super.call.apply(_super, [this].concat(args));
_this.moveRaf = null;
_this.scrollbarRef = /*#__PURE__*/react.createRef();
_this.thumbRef = /*#__PURE__*/react.createRef();
_this.visibleTimeout = null;
_this.state = {
dragging: false,
pageY: null,
startTop: null,
visible: false
};
_this.delayHidden = function () {
clearTimeout(_this.visibleTimeout);
_this.setState({
visible: true
});
_this.visibleTimeout = setTimeout(function () {
_this.setState({
visible: false
});
}, 2000);
};
_this.onScrollbarTouchStart = function (e) {
e.preventDefault();
};
_this.onContainerMouseDown = function (e) {
e.stopPropagation();
e.preventDefault();
};
// ======================= Clean =======================
_this.patchEvents = function () {
window.addEventListener('mousemove', _this.onMouseMove);
window.addEventListener('mouseup', _this.onMouseUp);
_this.thumbRef.current.addEventListener('touchmove', _this.onMouseMove);
_this.thumbRef.current.addEventListener('touchend', _this.onMouseUp);
};
_this.removeEvents = function () {
window.removeEventListener('mousemove', _this.onMouseMove);
window.removeEventListener('mouseup', _this.onMouseUp);
if (_this.thumbRef.current) {
_this.thumbRef.current.removeEventListener('touchmove', _this.onMouseMove);
_this.thumbRef.current.removeEventListener('touchend', _this.onMouseUp);
}
raf/* default.cancel */.Z.cancel(_this.moveRaf);
};
// ======================= Thumb =======================
_this.onMouseDown = function (e) {
var onStartMove = _this.props.onStartMove;
_this.setState({
dragging: true,
pageY: getPageY(e),
startTop: _this.getTop()
});
onStartMove();
_this.patchEvents();
e.stopPropagation();
e.preventDefault();
};
_this.onMouseMove = function (e) {
var _this$state = _this.state,
dragging = _this$state.dragging,
pageY = _this$state.pageY,
startTop = _this$state.startTop;
var onScroll = _this.props.onScroll;
raf/* default.cancel */.Z.cancel(_this.moveRaf);
if (dragging) {
var offsetY = getPageY(e) - pageY;
var newTop = startTop + offsetY;
var enableScrollRange = _this.getEnableScrollRange();
var enableHeightRange = _this.getEnableHeightRange();
var ptg = enableHeightRange ? newTop / enableHeightRange : 0;
var newScrollTop = Math.ceil(ptg * enableScrollRange);
_this.moveRaf = (0,raf/* default */.Z)(function () {
onScroll(newScrollTop);
});
}
};
_this.onMouseUp = function () {
var onStopMove = _this.props.onStopMove;
_this.setState({
dragging: false
});
onStopMove();
_this.removeEvents();
};
// ===================== Calculate =====================
_this.getSpinHeight = function () {
var _this$props = _this.props,
height = _this$props.height,
count = _this$props.count;
var baseHeight = height / count * 10;
baseHeight = Math.max(baseHeight, MIN_SIZE);
baseHeight = Math.min(baseHeight, height / 2);
return Math.floor(baseHeight);
};
_this.getEnableScrollRange = function () {
var _this$props2 = _this.props,
scrollHeight = _this$props2.scrollHeight,
height = _this$props2.height;
return scrollHeight - height || 0;
};
_this.getEnableHeightRange = function () {
var height = _this.props.height;
var spinHeight = _this.getSpinHeight();
return height - spinHeight || 0;
};
_this.getTop = function () {
var scrollTop = _this.props.scrollTop;
var enableScrollRange = _this.getEnableScrollRange();
var enableHeightRange = _this.getEnableHeightRange();
if (scrollTop === 0 || enableScrollRange === 0) {
return 0;
}
var ptg = scrollTop / enableScrollRange;
return ptg * enableHeightRange;
};
// Not show scrollbar when height is large than scrollHeight
_this.showScroll = function () {
var _this$props3 = _this.props,
height = _this$props3.height,
scrollHeight = _this$props3.scrollHeight;
return scrollHeight > height;
};
return _this;
}
(0,createClass/* default */.Z)(ScrollBar, [{
key: "componentDidMount",
value: function componentDidMount() {
this.scrollbarRef.current.addEventListener('touchstart', this.onScrollbarTouchStart);
this.thumbRef.current.addEventListener('touchstart', this.onMouseDown);
}
}, {
key: "componentDidUpdate",
value: function componentDidUpdate(prevProps) {
if (prevProps.scrollTop !== this.props.scrollTop) {
this.delayHidden();
}
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
var _this$scrollbarRef$cu, _this$thumbRef$curren;
this.removeEvents();
(_this$scrollbarRef$cu = this.scrollbarRef.current) === null || _this$scrollbarRef$cu === void 0 ? void 0 : _this$scrollbarRef$cu.removeEventListener('touchstart', this.onScrollbarTouchStart);
(_this$thumbRef$curren = this.thumbRef.current) === null || _this$thumbRef$curren === void 0 ? void 0 : _this$thumbRef$curren.removeEventListener('touchstart', this.onMouseDown);
clearTimeout(this.visibleTimeout);
}
}, {
key: "render",
value:
// ====================== Render =======================
function render() {
var _this$state2 = this.state,
dragging = _this$state2.dragging,
visible = _this$state2.visible;
var _this$props4 = this.props,
prefixCls = _this$props4.prefixCls,
direction = _this$props4.direction;
var spinHeight = this.getSpinHeight();
var top = this.getTop();
var canScroll = this.showScroll();
var mergedVisible = canScroll && visible;
var scrollBarDirection = direction === 'rtl' ? {
left: 0
} : {
right: 0
};
return /*#__PURE__*/react.createElement("div", {
ref: this.scrollbarRef,
className: classnames_default()("".concat(prefixCls, "-scrollbar"), (0,defineProperty/* default */.Z)({}, "".concat(prefixCls, "-scrollbar-show"), canScroll)),
style: (0,objectSpread2/* default */.Z)((0,objectSpread2/* default */.Z)({
width: 8,
top: 0,
bottom: 0
}, scrollBarDirection), {}, {
position: 'absolute',
display: mergedVisible ? null : 'none'
}),
onMouseDown: this.onContainerMouseDown,
onMouseMove: this.delayHidden
}, /*#__PURE__*/react.createElement("div", {
ref: this.thumbRef,
className: classnames_default()("".concat(prefixCls, "-scrollbar-thumb"), (0,defineProperty/* default */.Z)({}, "".concat(prefixCls, "-scrollbar-thumb-moving"), dragging)),
style: {
width: '100%',
height: spinHeight,
top: top,
left: 0,
position: 'absolute',
background: 'rgba(0, 0, 0, 0.5)',
borderRadius: 99,
cursor: 'pointer',
userSelect: 'none'
},
onMouseDown: this.onMouseDown
}));
}
}]);
return ScrollBar;
}(react.Component);
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/node_modules/rc-virtual-list/es/Item.js
function Item(_ref) {
var children = _ref.children,
setRef = _ref.setRef;
var refFunc = react.useCallback(function (node) {
setRef(node);
}, []);
return /*#__PURE__*/react.cloneElement(children, {
ref: refFunc
});
}
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/node_modules/rc-virtual-list/es/hooks/useChildren.js
function useChildren(list, startIndex, endIndex, setNodeRef, renderFunc, _ref) {
var getKey = _ref.getKey;
return list.slice(startIndex, endIndex + 1).map(function (item, index) {
var eleIndex = startIndex + index;
var node = renderFunc(item, eleIndex, {
// style: status === 'MEASURE_START' ? { visibility: 'hidden' } : {},
});
var key = getKey(item);
return /*#__PURE__*/react.createElement(Item, {
key: key,
setRef: function setRef(ele) {
return setNodeRef(item, ele);
}
}, node);
});
}
// EXTERNAL MODULE: ./node_modules/rc-util/es/Dom/findDOMNode.js
var findDOMNode = __webpack_require__(34203);
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/node_modules/rc-virtual-list/es/utils/CacheMap.js
// Firefox has low performance of map.
var CacheMap = /*#__PURE__*/function () {
function CacheMap() {
(0,classCallCheck/* default */.Z)(this, CacheMap);
this.maps = void 0;
this.maps = Object.create(null);
}
(0,createClass/* default */.Z)(CacheMap, [{
key: "set",
value: function set(key, value) {
this.maps[key] = value;
}
}, {
key: "get",
value: function get(key) {
return this.maps[key];
}
}]);
return CacheMap;
}();
/* harmony default export */ var utils_CacheMap = (CacheMap);
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/node_modules/rc-virtual-list/es/hooks/useHeights.js
function useHeights(getKey, onItemAdd, onItemRemove) {
var _React$useState = react.useState(0),
_React$useState2 = (0,slicedToArray/* default */.Z)(_React$useState, 2),
updatedMark = _React$useState2[0],
setUpdatedMark = _React$useState2[1];
var instanceRef = (0,react.useRef)(new Map());
var heightsRef = (0,react.useRef)(new utils_CacheMap());
var collectRafRef = (0,react.useRef)();
function cancelRaf() {
raf/* default.cancel */.Z.cancel(collectRafRef.current);
}
function collectHeight() {
cancelRaf();
collectRafRef.current = (0,raf/* default */.Z)(function () {
instanceRef.current.forEach(function (element, key) {
if (element && element.offsetParent) {
var htmlElement = (0,findDOMNode/* default */.Z)(element);
var offsetHeight = htmlElement.offsetHeight;
if (heightsRef.current.get(key) !== offsetHeight) {
heightsRef.current.set(key, htmlElement.offsetHeight);
}
}
});
// Always trigger update mark to tell parent that should re-calculate heights when resized
setUpdatedMark(function (c) {
return c + 1;
});
});
}
function setInstanceRef(item, instance) {
var key = getKey(item);
var origin = instanceRef.current.get(key);
if (instance) {
instanceRef.current.set(key, instance);
collectHeight();
} else {
instanceRef.current.delete(key);
}
// Instance changed
if (!origin !== !instance) {
if (instance) {
onItemAdd === null || onItemAdd === void 0 ? void 0 : onItemAdd(item);
} else {
onItemRemove === null || onItemRemove === void 0 ? void 0 : onItemRemove(item);
}
}
}
(0,react.useEffect)(function () {
return cancelRaf;
}, []);
return [setInstanceRef, collectHeight, heightsRef.current, updatedMark];
}
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/node_modules/rc-virtual-list/es/hooks/useScrollTo.js
/* eslint-disable no-param-reassign */
function useScrollTo(containerRef, data, heights, itemHeight, getKey, collectHeight, syncScrollTop, triggerFlash) {
var scrollRef = react.useRef();
return function (arg) {
// When not argument provided, we think dev may want to show the scrollbar
if (arg === null || arg === undefined) {
triggerFlash();
return;
}
// Normal scroll logic
raf/* default.cancel */.Z.cancel(scrollRef.current);
if (typeof arg === 'number') {
syncScrollTop(arg);
} else if (arg && (0,esm_typeof/* default */.Z)(arg) === 'object') {
var index;
var align = arg.align;
if ('index' in arg) {
index = arg.index;
} else {
index = data.findIndex(function (item) {
return getKey(item) === arg.key;
});
}
var _arg$offset = arg.offset,
offset = _arg$offset === void 0 ? 0 : _arg$offset;
// We will retry 3 times in case dynamic height shaking
var syncScroll = function syncScroll(times, targetAlign) {
if (times < 0 || !containerRef.current) return;
var height = containerRef.current.clientHeight;
var needCollectHeight = false;
var newTargetAlign = targetAlign;
// Go to next frame if height not exist
if (height) {
var mergedAlign = targetAlign || align;
// Get top & bottom
var stackTop = 0;
var itemTop = 0;
var itemBottom = 0;
var maxLen = Math.min(data.length, index);
for (var i = 0; i <= maxLen; i += 1) {
var key = getKey(data[i]);
itemTop = stackTop;
var cacheHeight = heights.get(key);
itemBottom = itemTop + (cacheHeight === undefined ? itemHeight : cacheHeight);
stackTop = itemBottom;
if (i === index && cacheHeight === undefined) {
needCollectHeight = true;
}
}
// Scroll to
var targetTop = null;
switch (mergedAlign) {
case 'top':
targetTop = itemTop - offset;
break;
case 'bottom':
targetTop = itemBottom - height + offset;
break;
default:
{
var scrollTop = containerRef.current.scrollTop;
var scrollBottom = scrollTop + height;
if (itemTop < scrollTop) {
newTargetAlign = 'top';
} else if (itemBottom > scrollBottom) {
newTargetAlign = 'bottom';
}
}
}
if (targetTop !== null && targetTop !== containerRef.current.scrollTop) {
syncScrollTop(targetTop);
}
}
// We will retry since element may not sync height as it described
scrollRef.current = (0,raf/* default */.Z)(function () {
if (needCollectHeight) {
collectHeight();
}
syncScroll(times - 1, newTargetAlign);
}, 2); // Delay 2 to wait for List collect heights
};
syncScroll(3);
}
};
}
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/node_modules/rc-virtual-list/es/utils/algorithmUtil.js
/**
* Get index with specific start index one by one. e.g.
* min: 3, max: 9, start: 6
*
* Return index is:
* [0]: 6
* [1]: 7
* [2]: 5
* [3]: 8
* [4]: 4
* [5]: 9
* [6]: 3
*/
function getIndexByStartLoc(min, max, start, index) {
var beforeCount = start - min;
var afterCount = max - start;
var balanceCount = Math.min(beforeCount, afterCount) * 2;
// Balance
if (index <= balanceCount) {
var stepIndex = Math.floor(index / 2);
if (index % 2) {
return start + stepIndex + 1;
}
return start - stepIndex;
}
// One is out of range
if (beforeCount > afterCount) {
return start - (index - afterCount);
}
return start + (index - beforeCount);
}
/**
* We assume that 2 list has only 1 item diff and others keeping the order.
* So we can use dichotomy algorithm to find changed one.
*/
function findListDiffIndex(originList, targetList, getKey) {
var originLen = originList.length;
var targetLen = targetList.length;
var shortList;
var longList;
if (originLen === 0 && targetLen === 0) {
return null;
}
if (originLen < targetLen) {
shortList = originList;
longList = targetList;
} else {
shortList = targetList;
longList = originList;
}
var notExistKey = {
__EMPTY_ITEM__: true
};
function getItemKey(item) {
if (item !== undefined) {
return getKey(item);
}
return notExistKey;
}
// Loop to find diff one
var diffIndex = null;
var multiple = Math.abs(originLen - targetLen) !== 1;
for (var i = 0; i < longList.length; i += 1) {
var shortKey = getItemKey(shortList[i]);
var longKey = getItemKey(longList[i]);
if (shortKey !== longKey) {
diffIndex = i;
multiple = multiple || shortKey !== getItemKey(longList[i + 1]);
break;
}
}
return diffIndex === null ? null : {
index: diffIndex,
multiple: multiple
};
}
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/node_modules/rc-virtual-list/es/hooks/useDiffItem.js
function useDiffItem(data, getKey, onDiff) {
var _React$useState = react.useState(data),
_React$useState2 = (0,slicedToArray/* default */.Z)(_React$useState, 2),
prevData = _React$useState2[0],
setPrevData = _React$useState2[1];
var _React$useState3 = react.useState(null),
_React$useState4 = (0,slicedToArray/* default */.Z)(_React$useState3, 2),
diffItem = _React$useState4[0],
setDiffItem = _React$useState4[1];
react.useEffect(function () {
var diff = findListDiffIndex(prevData || [], data || [], getKey);
if ((diff === null || diff === void 0 ? void 0 : diff.index) !== undefined) {
onDiff === null || onDiff === void 0 ? void 0 : onDiff(diff.index);
setDiffItem(data[diff.index]);
}
setPrevData(data);
}, [data]);
return [diffItem];
}
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/node_modules/rc-virtual-list/es/utils/isFirefox.js
var isFF = (typeof navigator === "undefined" ? "undefined" : (0,esm_typeof/* default */.Z)(navigator)) === 'object' && /Firefox/i.test(navigator.userAgent);
/* harmony default export */ var isFirefox = (isFF);
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/node_modules/rc-virtual-list/es/hooks/useOriginScroll.js
/* harmony default export */ var useOriginScroll = (function (isScrollAtTop, isScrollAtBottom) {
// Do lock for a wheel when scrolling
var lockRef = (0,react.useRef)(false);
var lockTimeoutRef = (0,react.useRef)(null);
function lockScroll() {
clearTimeout(lockTimeoutRef.current);
lockRef.current = true;
lockTimeoutRef.current = setTimeout(function () {
lockRef.current = false;
}, 50);
}
// Pass to ref since global add is in closure
var scrollPingRef = (0,react.useRef)({
top: isScrollAtTop,
bottom: isScrollAtBottom
});
scrollPingRef.current.top = isScrollAtTop;
scrollPingRef.current.bottom = isScrollAtBottom;
return function (deltaY) {
var smoothOffset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var originScroll =
// Pass origin wheel when on the top
deltaY < 0 && scrollPingRef.current.top ||
// Pass origin wheel when on the bottom
deltaY > 0 && scrollPingRef.current.bottom;
if (smoothOffset && originScroll) {
// No need lock anymore when it's smooth offset from touchMove interval
clearTimeout(lockTimeoutRef.current);
lockRef.current = false;
} else if (!originScroll || lockRef.current) {
lockScroll();
}
return !lockRef.current && originScroll;
};
});
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/node_modules/rc-virtual-list/es/hooks/useFrameWheel.js
function useFrameWheel(inVirtual, isScrollAtTop, isScrollAtBottom, onWheelDelta) {
var offsetRef = (0,react.useRef)(0);
var nextFrameRef = (0,react.useRef)(null);
// Firefox patch
var wheelValueRef = (0,react.useRef)(null);
var isMouseScrollRef = (0,react.useRef)(false);
// Scroll status sync
var originScroll = useOriginScroll(isScrollAtTop, isScrollAtBottom);
function onWheel(event) {
if (!inVirtual) return;
raf/* default.cancel */.Z.cancel(nextFrameRef.current);
var deltaY = event.deltaY;
offsetRef.current += deltaY;
wheelValueRef.current = deltaY;
// Do nothing when scroll at the edge, Skip check when is in scroll
if (originScroll(deltaY)) return;
// Proxy of scroll events
if (!isFirefox) {
event.preventDefault();
}
nextFrameRef.current = (0,raf/* default */.Z)(function () {
// Patch a multiple for Firefox to fix wheel number too small
// ref: https://github.com/ant-design/ant-design/issues/26372#issuecomment-679460266
var patchMultiple = isMouseScrollRef.current ? 10 : 1;
onWheelDelta(offsetRef.current * patchMultiple);
offsetRef.current = 0;
});
}
// A patch for firefox
function onFireFoxScroll(event) {
if (!inVirtual) return;
isMouseScrollRef.current = event.detail === wheelValueRef.current;
}
return [onWheel, onFireFoxScroll];
}
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/node_modules/rc-virtual-list/es/hooks/useMobileTouchMove.js
var SMOOTH_PTG = 14 / 15;
function useMobileTouchMove(inVirtual, listRef, callback) {
var touchedRef = (0,react.useRef)(false);
var touchYRef = (0,react.useRef)(0);
var elementRef = (0,react.useRef)(null);
// Smooth scroll
var intervalRef = (0,react.useRef)(null);
/* eslint-disable prefer-const */
var cleanUpEvents;
var onTouchMove = function onTouchMove(e) {
if (touchedRef.current) {
var currentY = Math.ceil(e.touches[0].pageY);
var offsetY = touchYRef.current - currentY;
touchYRef.current = currentY;
if (callback(offsetY)) {
e.preventDefault();
}
// Smooth interval
clearInterval(intervalRef.current);
intervalRef.current = setInterval(function () {
offsetY *= SMOOTH_PTG;
if (!callback(offsetY, true) || Math.abs(offsetY) <= 0.1) {
clearInterval(intervalRef.current);
}
}, 16);
}
};
var onTouchEnd = function onTouchEnd() {
touchedRef.current = false;
cleanUpEvents();
};
var onTouchStart = function onTouchStart(e) {
cleanUpEvents();
if (e.touches.length === 1 && !touchedRef.current) {
touchedRef.current = true;
touchYRef.current = Math.ceil(e.touches[0].pageY);
elementRef.current = e.target;
elementRef.current.addEventListener('touchmove', onTouchMove);
elementRef.current.addEventListener('touchend', onTouchEnd);
}
};
cleanUpEvents = function cleanUpEvents() {
if (elementRef.current) {
elementRef.current.removeEventListener('touchmove', onTouchMove);
elementRef.current.removeEventListener('touchend', onTouchEnd);
}
};
(0,useLayoutEffect/* default */.Z)(function () {
if (inVirtual) {
listRef.current.addEventListener('touchstart', onTouchStart);
}
return function () {
var _listRef$current;
(_listRef$current = listRef.current) === null || _listRef$current === void 0 ? void 0 : _listRef$current.removeEventListener('touchstart', onTouchStart);
cleanUpEvents();
clearInterval(intervalRef.current);
};
}, [inVirtual]);
}
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/node_modules/rc-virtual-list/es/List.js
var List_excluded = ["prefixCls", "className", "height", "itemHeight", "fullHeight", "style", "data", "children", "itemKey", "virtual", "direction", "component", "onScroll", "onVisibleChange", "innerProps"];
var EMPTY_DATA = [];
var ScrollStyle = {
overflowY: 'auto',
overflowAnchor: 'none'
};
function RawList(props, ref) {
var _props$prefixCls = props.prefixCls,
prefixCls = _props$prefixCls === void 0 ? 'rc-virtual-list' : _props$prefixCls,
className = props.className,
height = props.height,
itemHeight = props.itemHeight,
_props$fullHeight = props.fullHeight,
fullHeight = _props$fullHeight === void 0 ? true : _props$fullHeight,
style = props.style,
data = props.data,
children = props.children,
itemKey = props.itemKey,
virtual = props.virtual,
direction = props.direction,
_props$component = props.component,
Component = _props$component === void 0 ? 'div' : _props$component,
onScroll = props.onScroll,
onVisibleChange = props.onVisibleChange,
innerProps = props.innerProps,
restProps = (0,objectWithoutProperties/* default */.Z)(props, List_excluded);
// ================================= MISC =================================
var useVirtual = !!(virtual !== false && height && itemHeight);
var inVirtual = useVirtual && data && itemHeight * data.length > height;
var _useState = (0,react.useState)(0),
_useState2 = (0,slicedToArray/* default */.Z)(_useState, 2),
scrollTop = _useState2[0],
setScrollTop = _useState2[1];
var _useState3 = (0,react.useState)(false),
_useState4 = (0,slicedToArray/* default */.Z)(_useState3, 2),
scrollMoving = _useState4[0],
setScrollMoving = _useState4[1];
var mergedClassName = classnames_default()(prefixCls, (0,defineProperty/* default */.Z)({}, "".concat(prefixCls, "-rtl"), direction === 'rtl'), className);
var mergedData = data || EMPTY_DATA;
var componentRef = (0,react.useRef)();
var fillerInnerRef = (0,react.useRef)();
var scrollBarRef = (0,react.useRef)(); // Hack on scrollbar to enable flash call
// =============================== Item Key ===============================
var getKey = react.useCallback(function (item) {
if (typeof itemKey === 'function') {
return itemKey(item);
}
return item === null || item === void 0 ? void 0 : item[itemKey];
}, [itemKey]);
var sharedConfig = {
getKey: getKey
};
// ================================ Scroll ================================
function syncScrollTop(newTop) {
setScrollTop(function (origin) {
var value;
if (typeof newTop === 'function') {
value = newTop(origin);
} else {
value = newTop;
}
var alignedTop = keepInRange(value);
componentRef.current.scrollTop = alignedTop;
return alignedTop;
});
}
// ================================ Legacy ================================
// Put ref here since the range is generate by follow
var rangeRef = (0,react.useRef)({
start: 0,
end: mergedData.length
});
var diffItemRef = (0,react.useRef)();
var _useDiffItem = useDiffItem(mergedData, getKey),
_useDiffItem2 = (0,slicedToArray/* default */.Z)(_useDiffItem, 1),
diffItem = _useDiffItem2[0];
diffItemRef.current = diffItem;
// ================================ Height ================================
var _useHeights = useHeights(getKey, null, null),
_useHeights2 = (0,slicedToArray/* default */.Z)(_useHeights, 4),
setInstanceRef = _useHeights2[0],
collectHeight = _useHeights2[1],
heights = _useHeights2[2],
heightUpdatedMark = _useHeights2[3];
// ========================== Visible Calculation =========================
var _React$useMemo = react.useMemo(function () {
if (!useVirtual) {
return {
scrollHeight: undefined,
start: 0,
end: mergedData.length - 1,
offset: undefined
};
}
// Always use virtual scroll bar in avoid shaking
if (!inVirtual) {
var _fillerInnerRef$curre;
return {
scrollHeight: ((_fillerInnerRef$curre = fillerInnerRef.current) === null || _fillerInnerRef$curre === void 0 ? void 0 : _fillerInnerRef$curre.offsetHeight) || 0,
start: 0,
end: mergedData.length - 1,
offset: undefined
};
}
var itemTop = 0;
var startIndex;
var startOffset;
var endIndex;
var dataLen = mergedData.length;
for (var i = 0; i < dataLen; i += 1) {
var item = mergedData[i];
var key = getKey(item);
var cacheHeight = heights.get(key);
var currentItemBottom = itemTop + (cacheHeight === undefined ? itemHeight : cacheHeight);
// Check item top in the range
if (currentItemBottom >= scrollTop && startIndex === undefined) {
startIndex = i;
startOffset = itemTop;
}
// Check item bottom in the range. We will render additional one item for motion usage
if (currentItemBottom > scrollTop + height && endIndex === undefined) {
endIndex = i;
}
itemTop = currentItemBottom;
}
// When scrollTop at the end but data cut to small count will reach this
if (startIndex === undefined) {
startIndex = 0;
startOffset = 0;
endIndex = Math.ceil(height / itemHeight);
}
if (endIndex === undefined) {
endIndex = mergedData.length - 1;
}
// Give cache to improve scroll experience
endIndex = Math.min(endIndex + 1, mergedData.length);
return {
scrollHeight: itemTop,
start: startIndex,
end: endIndex,
offset: startOffset
};
}, [inVirtual, useVirtual, scrollTop, mergedData, heightUpdatedMark, height]),
scrollHeight = _React$useMemo.scrollHeight,
start = _React$useMemo.start,
end = _React$useMemo.end,
offset = _React$useMemo.offset;
rangeRef.current.start = start;
rangeRef.current.end = end;
// =============================== In Range ===============================
var maxScrollHeight = scrollHeight - height;
var maxScrollHeightRef = (0,react.useRef)(maxScrollHeight);
maxScrollHeightRef.current = maxScrollHeight;
function keepInRange(newScrollTop) {
var newTop = newScrollTop;
if (!Number.isNaN(maxScrollHeightRef.current)) {
newTop = Math.min(newTop, maxScrollHeightRef.current);
}
newTop = Math.max(newTop, 0);
return newTop;
}
var isScrollAtTop = scrollTop <= 0;
var isScrollAtBottom = scrollTop >= maxScrollHeight;
var originScroll = useOriginScroll(isScrollAtTop, isScrollAtBottom);
// ================================ Scroll ================================
function onScrollBar(newScrollTop) {
var newTop = newScrollTop;
syncScrollTop(newTop);
}
// When data size reduce. It may trigger native scroll event back to fit scroll position
function onFallbackScroll(e) {
var newScrollTop = e.currentTarget.scrollTop;
if (newScrollTop !== scrollTop) {
syncScrollTop(newScrollTop);
}
// Trigger origin onScroll
onScroll === null || onScroll === void 0 ? void 0 : onScroll(e);
}
// Since this added in global,should use ref to keep update
var _useFrameWheel = useFrameWheel(useVirtual, isScrollAtTop, isScrollAtBottom, function (offsetY) {
syncScrollTop(function (top) {
var newTop = top + offsetY;
return newTop;
});
}),
_useFrameWheel2 = (0,slicedToArray/* default */.Z)(_useFrameWheel, 2),
onRawWheel = _useFrameWheel2[0],
onFireFoxScroll = _useFrameWheel2[1];
// Mobile touch move
useMobileTouchMove(useVirtual, componentRef, function (deltaY, smoothOffset) {
if (originScroll(deltaY, smoothOffset)) {
return false;
}
onRawWheel({
preventDefault: function preventDefault() {},
deltaY: deltaY
});
return true;
});
(0,useLayoutEffect/* default */.Z)(function () {
// Firefox only
function onMozMousePixelScroll(e) {
if (useVirtual) {
e.preventDefault();
}
}
componentRef.current.addEventListener('wheel', onRawWheel);
componentRef.current.addEventListener('DOMMouseScroll', onFireFoxScroll);
componentRef.current.addEventListener('MozMousePixelScroll', onMozMousePixelScroll);
return function () {
if (componentRef.current) {
componentRef.current.removeEventListener('wheel', onRawWheel);
componentRef.current.removeEventListener('DOMMouseScroll', onFireFoxScroll);
componentRef.current.removeEventListener('MozMousePixelScroll', onMozMousePixelScroll);
}
};
}, [useVirtual]);
// ================================= Ref ==================================
var scrollTo = useScrollTo(componentRef, mergedData, heights, itemHeight, getKey, collectHeight, syncScrollTop, function () {
var _scrollBarRef$current;
(_scrollBarRef$current = scrollBarRef.current) === null || _scrollBarRef$current === void 0 ? void 0 : _scrollBarRef$current.delayHidden();
});
react.useImperativeHandle(ref, function () {
return {
scrollTo: scrollTo
};
});
// ================================ Effect ================================
/** We need told outside that some list not rendered */
(0,useLayoutEffect/* default */.Z)(function () {
if (onVisibleChange) {
var renderList = mergedData.slice(start, end + 1);
onVisibleChange(renderList, mergedData);
}
}, [start, end, mergedData]);
// ================================ Render ================================
var listChildren = useChildren(mergedData, start, end, setInstanceRef, children, sharedConfig);
var componentStyle = null;
if (height) {
componentStyle = (0,objectSpread2/* default */.Z)((0,defineProperty/* default */.Z)({}, fullHeight ? 'height' : 'maxHeight', height), ScrollStyle);
if (useVirtual) {
componentStyle.overflowY = 'hidden';
if (scrollMoving) {
componentStyle.pointerEvents = 'none';
}
}
}
return /*#__PURE__*/react.createElement("div", (0,esm_extends/* default */.Z)({
style: (0,objectSpread2/* default */.Z)((0,objectSpread2/* default */.Z)({}, style), {}, {
position: 'relative'
}),
className: mergedClassName
}, restProps), /*#__PURE__*/react.createElement(Component, {
className: "".concat(prefixCls, "-holder"),
style: componentStyle,
ref: componentRef,
onScroll: onFallbackScroll
}, /*#__PURE__*/react.createElement(es_Filler, {
prefixCls: prefixCls,
height: scrollHeight,
offset: offset,
onInnerResize: collectHeight,
ref: fillerInnerRef,
innerProps: innerProps
}, listChildren)), useVirtual && /*#__PURE__*/react.createElement(ScrollBar, {
ref: scrollBarRef,
prefixCls: prefixCls,
scrollTop: scrollTop,
height: height,
scrollHeight: scrollHeight,
count: mergedData.length,
direction: direction,
onScroll: onScrollBar,
onStartMove: function onStartMove() {
setScrollMoving(true);
},
onStopMove: function onStopMove() {
setScrollMoving(false);
}
}));
}
var List = /*#__PURE__*/react.forwardRef(RawList);
List.displayName = 'List';
/* harmony default export */ var es_List = (List);
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/node_modules/rc-virtual-list/es/index.js
/* harmony default export */ var rc_virtual_list_es = (es_List);
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/node_modules/rc-select/es/SelectContext.js
var SelectContext = /*#__PURE__*/react.createContext(null);
/* harmony default export */ var es_SelectContext = (SelectContext);
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/node_modules/rc-select/es/utils/platformUtil.js
/* istanbul ignore file */
function isPlatformMac() {
return /(mac\sos|macintosh)/i.test(navigator.appVersion);
}
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/node_modules/rc-select/es/OptionList.js
var OptionList_excluded = ["disabled", "title", "children", "style", "className"];
// export interface OptionListProps<OptionsType extends object[]> {
function OptionList_isTitleType(content) {
return typeof content === 'string' || typeof content === 'number';
}
/**
* Using virtual list of option display.
* Will fallback to dom if use customize render.
*/
var OptionList = function OptionList(_, ref) {
var _useBaseProps = useBaseProps(),
prefixCls = _useBaseProps.prefixCls,
id = _useBaseProps.id,
open = _useBaseProps.open,
multiple = _useBaseProps.multiple,
mode = _useBaseProps.mode,
searchValue = _useBaseProps.searchValue,
toggleOpen = _useBaseProps.toggleOpen,
notFoundContent = _useBaseProps.notFoundContent,
onPopupScroll = _useBaseProps.onPopupScroll;
var _React$useContext = react.useContext(es_SelectContext),
flattenOptions = _React$useContext.flattenOptions,
onActiveValue = _React$useContext.onActiveValue,
defaultActiveFirstOption = _React$useContext.defaultActiveFirstOption,
onSelect = _React$useContext.onSelect,
menuItemSelectedIcon = _React$useContext.menuItemSelectedIcon,
rawValues = _React$useContext.rawValues,
fieldNames = _React$useContext.fieldNames,
virtual = _React$useContext.virtual,
direction = _React$useContext.direction,
listHeight = _React$useContext.listHeight,
listItemHeight = _React$useContext.listItemHeight;
var itemPrefixCls = "".concat(prefixCls, "-item");
var memoFlattenOptions = (0,useMemo/* default */.Z)(function () {
return flattenOptions;
}, [open, flattenOptions], function (prev, next) {
return next[0] && prev[1] !== next[1];
});
// =========================== List ===========================
var listRef = react.useRef(null);
var onListMouseDown = function onListMouseDown(event) {
event.preventDefault();
};
var scrollIntoView = function scrollIntoView(args) {
if (listRef.current) {
listRef.current.scrollTo(typeof args === 'number' ? {
index: args
} : args);
}
};
// ========================== Active ==========================
var getEnabledActiveIndex = function getEnabledActiveIndex(index) {
var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
var len = memoFlattenOptions.length;
for (var i = 0; i < len; i += 1) {
var current = (index + i * offset + len) % len;
var _memoFlattenOptions$c = memoFlattenOptions[current],
group = _memoFlattenOptions$c.group,
data = _memoFlattenOptions$c.data;
if (!group && !data.disabled) {
return current;
}
}
return -1;
};
var _React$useState = react.useState(function () {
return getEnabledActiveIndex(0);
}),
_React$useState2 = (0,slicedToArray/* default */.Z)(_React$useState, 2),
activeIndex = _React$useState2[0],
setActiveIndex = _React$useState2[1];
var setActive = function setActive(index) {
var fromKeyboard = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
setActiveIndex(index);
var info = {
source: fromKeyboard ? 'keyboard' : 'mouse'
};
// Trigger active event
var flattenItem = memoFlattenOptions[index];
if (!flattenItem) {
onActiveValue(null, -1, info);
return;
}
onActiveValue(flattenItem.value, index, info);
};
// Auto active first item when list length or searchValue changed
(0,react.useEffect)(function () {
setActive(defaultActiveFirstOption !== false ? getEnabledActiveIndex(0) : -1);
}, [memoFlattenOptions.length, searchValue]);
// https://github.com/ant-design/ant-design/issues/34975
var isSelected = react.useCallback(function (value) {
return rawValues.has(value) && mode !== 'combobox';
}, [mode, (0,toConsumableArray/* default */.Z)(rawValues).toString(), rawValues.size]);
// Auto scroll to item position in single mode
(0,react.useEffect)(function () {
/**
* React will skip `onChange` when component update.
* `setActive` function will call root accessibility state update which makes re-render.
* So we need to delay to let Input component trigger onChange first.
*/
var timeoutId = setTimeout(function () {
if (!multiple && open && rawValues.size === 1) {
var value = Array.from(rawValues)[0];
var index = memoFlattenOptions.findIndex(function (_ref) {
var data = _ref.data;
return data.value === value;
});
if (index !== -1) {
setActive(index);
scrollIntoView(index);
}
}
});
// Force trigger scrollbar visible when open
if (open) {
var _listRef$current;
(_listRef$current = listRef.current) === null || _listRef$current === void 0 ? void 0 : _listRef$current.scrollTo(undefined);
}
return function () {
return clearTimeout(timeoutId);
};
}, [open, searchValue, flattenOptions.length]);
// ========================== Values ==========================
var onSelectValue = function onSelectValue(value) {
if (value !== undefined) {
onSelect(value, {
selected: !rawValues.has(value)
});
}
// Single mode should always close by select
if (!multiple) {
toggleOpen(false);
}
};
// ========================= Keyboard =========================
react.useImperativeHandle(ref, function () {
return {
onKeyDown: function onKeyDown(event) {
var which = event.which,
ctrlKey = event.ctrlKey;
switch (which) {
// >>> Arrow keys & ctrl + n/p on Mac
case KeyCode/* default.N */.Z.N:
case KeyCode/* default.P */.Z.P:
case KeyCode/* default.UP */.Z.UP:
case KeyCode/* default.DOWN */.Z.DOWN:
{
var offset = 0;
if (which === KeyCode/* default.UP */.Z.UP) {
offset = -1;
} else if (which === KeyCode/* default.DOWN */.Z.DOWN) {
offset = 1;
} else if (isPlatformMac() && ctrlKey) {
if (which === KeyCode/* default.N */.Z.N) {
offset = 1;
} else if (which === KeyCode/* default.P */.Z.P) {
offset = -1;
}
}
if (offset !== 0) {
var nextActiveIndex = getEnabledActiveIndex(activeIndex + offset, offset);
scrollIntoView(nextActiveIndex);
setActive(nextActiveIndex, true);
}
break;
}
// >>> Select
case KeyCode/* default.ENTER */.Z.ENTER:
{
// value
var item = memoFlattenOptions[activeIndex];
if (item && !item.data.disabled) {
onSelectValue(item.value);
} else {
onSelectValue(undefined);
}
if (open) {
event.preventDefault();
}
break;
}
// >>> Close
case KeyCode/* default.ESC */.Z.ESC:
{
toggleOpen(false);
if (open) {
event.stopPropagation();
}
}
}
},
onKeyUp: function onKeyUp() {},
scrollTo: function scrollTo(index) {
scrollIntoView(index);
}
};
});
// ========================== Render ==========================
if (memoFlattenOptions.length === 0) {
return /*#__PURE__*/react.createElement("div", {
role: "listbox",
id: "".concat(id, "_list"),
className: "".concat(itemPrefixCls, "-empty"),
onMouseDown: onListMouseDown
}, notFoundContent);
}
var omitFieldNameList = Object.keys(fieldNames).map(function (key) {
return fieldNames[key];
});
var getLabel = function getLabel(item) {
return item.label;
};
function getItemAriaProps(item, index) {
var group = item.group;
return {
role: group ? 'presentation' : 'option',
id: "".concat(id, "_list_").concat(index)
};
}
var renderItem = function renderItem(index) {
var item = memoFlattenOptions[index];
if (!item) return null;
var itemData = item.data || {};
var value = itemData.value;
var group = item.group;
var attrs = (0,pickAttrs/* default */.Z)(itemData, true);
var mergedLabel = getLabel(item);
return item ? /*#__PURE__*/react.createElement("div", (0,esm_extends/* default */.Z)({
"aria-label": typeof mergedLabel === 'string' && !group ? mergedLabel : null
}, attrs, {
key: index
}, getItemAriaProps(item, index), {
"aria-selected": isSelected(value)
}), value) : null;
};
var a11yProps = {
role: 'listbox',
id: "".concat(id, "_list")
};
return /*#__PURE__*/react.createElement(react.Fragment, null, virtual && /*#__PURE__*/react.createElement("div", (0,esm_extends/* default */.Z)({}, a11yProps, {
style: {
height: 0,
width: 0,
overflow: 'hidden'
}
}), renderItem(activeIndex - 1), renderItem(activeIndex), renderItem(activeIndex + 1)), /*#__PURE__*/react.createElement(rc_virtual_list_es, {
itemKey: "key",
ref: listRef,
data: memoFlattenOptions,
height: listHeight,
itemHeight: listItemHeight,
fullHeight: false,
onMouseDown: onListMouseDown,
onScroll: onPopupScroll,
virtual: virtual,
direction: direction,
innerProps: virtual ? null : a11yProps
}, function (item, itemIndex) {
var _classNames;
var group = item.group,
groupOption = item.groupOption,
data = item.data,
label = item.label,
value = item.value;
var key = data.key;
// Group
if (group) {
var _data$title;
var groupTitle = (_data$title = data.title) !== null && _data$title !== void 0 ? _data$title : OptionList_isTitleType(label) ? label.toString() : undefined;
return /*#__PURE__*/react.createElement("div", {
className: classnames_default()(itemPrefixCls, "".concat(itemPrefixCls, "-group")),
title: groupTitle
}, label !== undefined ? label : key);
}
var disabled = data.disabled,
title = data.title,
children = data.children,
style = data.style,
className = data.className,
otherProps = (0,objectWithoutProperties/* default */.Z)(data, OptionList_excluded);
var passedProps = (0,omit/* default */.Z)(otherProps, omitFieldNameList);
// Option
var selected = isSelected(value);
var optionPrefixCls = "".concat(itemPrefixCls, "-option");
var optionClassName = classnames_default()(itemPrefixCls, optionPrefixCls, className, (_classNames = {}, (0,defineProperty/* default */.Z)(_classNames, "".concat(optionPrefixCls, "-grouped"), groupOption), (0,defineProperty/* default */.Z)(_classNames, "".concat(optionPrefixCls, "-active"), activeIndex === itemIndex && !disabled), (0,defineProperty/* default */.Z)(_classNames, "".concat(optionPrefixCls, "-disabled"), disabled), (0,defineProperty/* default */.Z)(_classNames, "".concat(optionPrefixCls, "-selected"), selected), _classNames));
var mergedLabel = getLabel(item);
var iconVisible = !menuItemSelectedIcon || typeof menuItemSelectedIcon === 'function' || selected;
// https://github.com/ant-design/ant-design/issues/34145
var content = typeof mergedLabel === 'number' ? mergedLabel : mergedLabel || value;
// https://github.com/ant-design/ant-design/issues/26717
var optionTitle = OptionList_isTitleType(content) ? content.toString() : undefined;
if (title !== undefined) {
optionTitle = title;
}
return /*#__PURE__*/react.createElement("div", (0,esm_extends/* default */.Z)({}, (0,pickAttrs/* default */.Z)(passedProps), !virtual ? getItemAriaProps(item, itemIndex) : {}, {
"aria-selected": selected,
className: optionClassName,
title: optionTitle,
onMouseMove: function onMouseMove() {
if (activeIndex === itemIndex || disabled) {
return;
}
setActive(itemIndex);
},
onClick: function onClick() {
if (!disabled) {
onSelectValue(value);
}
},
style: style
}), /*#__PURE__*/react.createElement("div", {
className: "".concat(optionPrefixCls, "-content")
}, content), /*#__PURE__*/react.isValidElement(menuItemSelectedIcon) || selected, iconVisible && /*#__PURE__*/react.createElement(es_TransBtn, {
className: "".concat(itemPrefixCls, "-option-state"),
customizeIcon: menuItemSelectedIcon,
customizeIconProps: {
isSelected: selected
}
}, selected ? '✓' : null));
}));
};
var RefOptionList = /*#__PURE__*/react.forwardRef(OptionList);
RefOptionList.displayName = 'OptionList';
/* harmony default export */ var es_OptionList = (RefOptionList);
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/node_modules/rc-select/es/utils/warningPropsUtil.js
function warningProps(props) {
var mode = props.mode,
options = props.options,
children = props.children,
backfill = props.backfill,
allowClear = props.allowClear,
placeholder = props.placeholder,
getInputElement = props.getInputElement,
showSearch = props.showSearch,
onSearch = props.onSearch,
defaultOpen = props.defaultOpen,
autoFocus = props.autoFocus,
labelInValue = props.labelInValue,
value = props.value,
inputValue = props.inputValue,
optionLabelProp = props.optionLabelProp;
var multiple = isMultiple(mode);
var mergedShowSearch = showSearch !== undefined ? showSearch : multiple || mode === 'combobox';
var mergedOptions = options || convertChildrenToData(children);
// `tags` should not set option as disabled
warning(mode !== 'tags' || mergedOptions.every(function (opt) {
return !opt.disabled;
}), 'Please avoid setting option to disabled in tags mode since user can always type text as tag.');
// `combobox` & `tags` should option be `string` type
if (mode === 'tags' || mode === 'combobox') {
var hasNumberValue = mergedOptions.some(function (item) {
if (item.options) {
return item.options.some(function (opt) {
return typeof ('value' in opt ? opt.value : opt.key) === 'number';
});
}
return typeof ('value' in item ? item.value : item.key) === 'number';
});
warning(!hasNumberValue, '`value` of Option should not use number type when `mode` is `tags` or `combobox`.');
}
// `combobox` should not use `optionLabelProp`
warning(mode !== 'combobox' || !optionLabelProp, '`combobox` mode not support `optionLabelProp`. Please set `value` on Option directly.');
// Only `combobox` support `backfill`
warning(mode === 'combobox' || !backfill, '`backfill` only works with `combobox` mode.');
// Only `combobox` support `getInputElement`
warning(mode === 'combobox' || !getInputElement, '`getInputElement` only work with `combobox` mode.');
// Customize `getInputElement` should not use `allowClear` & `placeholder`
noteOnce(mode !== 'combobox' || !getInputElement || !allowClear || !placeholder, 'Customize `getInputElement` should customize clear and placeholder logic instead of configuring `allowClear` and `placeholder`.');
// `onSearch` should use in `combobox` or `showSearch`
if (onSearch && !mergedShowSearch && mode !== 'combobox' && mode !== 'tags') {
warning(false, '`onSearch` should work with `showSearch` instead of use alone.');
}
noteOnce(!defaultOpen || autoFocus, '`defaultOpen` makes Select open without focus which means it will not close by click outside. You can set `autoFocus` if needed.');
if (value !== undefined && value !== null) {
var values = toArray(value);
warning(!labelInValue || values.every(function (val) {
return _typeof(val) === 'object' && ('key' in val || 'value' in val);
}), '`value` should in shape of `{ value: string | number, label?: ReactNode }` when you set `labelInValue` to `true`');
warning(!multiple || Array.isArray(value), '`value` should be array when `mode` is `multiple` or `tags`');
}
// Syntactic sugar should use correct children type
if (children) {
var invalidateChildType = null;
toNodeArray(children).some(function (node) {
if (! /*#__PURE__*/React.isValidElement(node) || !node.type) {
return false;
}
var _ref = node,
type = _ref.type;
if (type.isSelectOption) {
return false;
}
if (type.isSelectOptGroup) {
var allChildrenValid = toNodeArray(node.props.children).every(function (subNode) {
if (! /*#__PURE__*/React.isValidElement(subNode) || !node.type || subNode.type.isSelectOption) {
return true;
}
invalidateChildType = subNode.type;
return false;
});
if (allChildrenValid) {
return false;
}
return true;
}
invalidateChildType = type;
return true;
});
if (invalidateChildType) {
warning(false, "`children` should be `Select.Option` or `Select.OptGroup` instead of `".concat(invalidateChildType.displayName || invalidateChildType.name || invalidateChildType, "`."));
}
warning(inputValue === undefined, '`inputValue` is deprecated, please use `searchValue` instead.');
}
}
// value in Select option should not be null
// note: OptGroup has options too
function warningNullOptions(options, fieldNames) {
if (options) {
var recursiveOptions = function recursiveOptions(optionsList) {
var inGroup = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
for (var i = 0; i < optionsList.length; i++) {
var option = optionsList[i];
if (option[fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.value] === null) {
warning(false, '`value` in Select options should not be `null`.');
return true;
}
if (!inGroup && Array.isArray(option[fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.options]) && recursiveOptions(option[fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.options], true)) {
break;
}
}
};
recursiveOptions(options);
}
}
/* harmony default export */ var warningPropsUtil = ((/* unused pure expression or super */ null && (warningProps)));
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/node_modules/rc-select/es/Select.js
var Select_excluded = ["id", "mode", "prefixCls", "backfill", "fieldNames", "inputValue", "searchValue", "onSearch", "autoClearSearchValue", "onSelect", "onDeselect", "dropdownMatchSelectWidth", "filterOption", "filterSort", "optionFilterProp", "optionLabelProp", "options", "children", "defaultActiveFirstOption", "menuItemSelectedIcon", "virtual", "direction", "listHeight", "listItemHeight", "value", "defaultValue", "labelInValue", "onChange"];
/**
* To match accessibility requirement, we always provide an input in the component.
* Other element will not set `tabIndex` to avoid `onBlur` sequence problem.
* For focused select, we set `aria-live="polite"` to update the accessibility content.
*
* ref:
* - keyboard: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/listbox_role#Keyboard_interactions
*
* New api:
* - listHeight
* - listItemHeight
* - component
*
* Remove deprecated api:
* - multiple
* - tags
* - combobox
* - firstActiveValue
* - dropdownMenuStyle
* - openClassName (Not list in api)
*
* Update:
* - `backfill` only support `combobox` mode
* - `combobox` mode not support `labelInValue` since it's meaningless
* - `getInputElement` only support `combobox` mode
* - `onChange` return OptionData instead of ReactNode
* - `filterOption` `onChange` `onSelect` accept OptionData instead of ReactNode
* - `combobox` mode trigger `onChange` will get `undefined` if no `value` match in Option
* - `combobox` mode not support `optionLabelProp`
*/
var OMIT_DOM_PROPS = ['inputValue'];
function isRawValue(value) {
return !value || (0,esm_typeof/* default */.Z)(value) !== 'object';
}
var Select_Select = /*#__PURE__*/react.forwardRef(function (props, ref) {
var id = props.id,
mode = props.mode,
_props$prefixCls = props.prefixCls,
prefixCls = _props$prefixCls === void 0 ? 'rc-select' : _props$prefixCls,
backfill = props.backfill,
fieldNames = props.fieldNames,
inputValue = props.inputValue,
searchValue = props.searchValue,
onSearch = props.onSearch,
_props$autoClearSearc = props.autoClearSearchValue,
autoClearSearchValue = _props$autoClearSearc === void 0 ? true : _props$autoClearSearc,
onSelect = props.onSelect,
onDeselect = props.onDeselect,
_props$dropdownMatchS = props.dropdownMatchSelectWidth,
dropdownMatchSelectWidth = _props$dropdownMatchS === void 0 ? true : _props$dropdownMatchS,
filterOption = props.filterOption,
filterSort = props.filterSort,
optionFilterProp = props.optionFilterProp,
optionLabelProp = props.optionLabelProp,
options = props.options,
children = props.children,
defaultActiveFirstOption = props.defaultActiveFirstOption,
menuItemSelectedIcon = props.menuItemSelectedIcon,
virtual = props.virtual,
direction = props.direction,
_props$listHeight = props.listHeight,
listHeight = _props$listHeight === void 0 ? 200 : _props$listHeight,
_props$listItemHeight = props.listItemHeight,
listItemHeight = _props$listItemHeight === void 0 ? 20 : _props$listItemHeight,
value = props.value,
defaultValue = props.defaultValue,
labelInValue = props.labelInValue,
onChange = props.onChange,
restProps = (0,objectWithoutProperties/* default */.Z)(props, Select_excluded);
var mergedId = useId(id);
var multiple = BaseSelect_isMultiple(mode);
var childrenAsData = !!(!options && children);
var mergedFilterOption = react.useMemo(function () {
if (filterOption === undefined && mode === 'combobox') {
return false;
}
return filterOption;
}, [filterOption, mode]);
// ========================= FieldNames =========================
var mergedFieldNames = react.useMemo(function () {
return fillFieldNames(fieldNames, childrenAsData);
}, /* eslint-disable react-hooks/exhaustive-deps */
[
// We stringify fieldNames to avoid unnecessary re-renders.
JSON.stringify(fieldNames), childrenAsData]
/* eslint-enable react-hooks/exhaustive-deps */);
// =========================== Search ===========================
var _useMergedState = (0,useMergedState/* default */.Z)('', {
value: searchValue !== undefined ? searchValue : inputValue,
postState: function postState(search) {
return search || '';
}
}),
_useMergedState2 = (0,slicedToArray/* default */.Z)(_useMergedState, 2),
mergedSearchValue = _useMergedState2[0],
setSearchValue = _useMergedState2[1];
// =========================== Option ===========================
var parsedOptions = useOptions(options, children, mergedFieldNames, optionFilterProp, optionLabelProp);
var valueOptions = parsedOptions.valueOptions,
labelOptions = parsedOptions.labelOptions,
mergedOptions = parsedOptions.options;
// ========================= Wrap Value =========================
var convert2LabelValues = react.useCallback(function (draftValues) {
// Convert to array
var valueList = commonUtil_toArray(draftValues);
// Convert to labelInValue type
return valueList.map(function (val) {
var rawValue;
var rawLabel;
var rawKey;
var rawDisabled;
var rawTitle;
// Fill label & value
if (isRawValue(val)) {
rawValue = val;
} else {
var _val$value;
rawKey = val.key;
rawLabel = val.label;
rawValue = (_val$value = val.value) !== null && _val$value !== void 0 ? _val$value : rawKey;
}
var option = valueOptions.get(rawValue);
if (option) {
var _option$key;
// Fill missing props
if (rawLabel === undefined) rawLabel = option === null || option === void 0 ? void 0 : option[optionLabelProp || mergedFieldNames.label];
if (rawKey === undefined) rawKey = (_option$key = option === null || option === void 0 ? void 0 : option.key) !== null && _option$key !== void 0 ? _option$key : rawValue;
rawDisabled = option === null || option === void 0 ? void 0 : option.disabled;
rawTitle = option === null || option === void 0 ? void 0 : option.title;
// Warning if label not same as provided
if (false) { var optionLabel; }
}
return {
label: rawLabel,
value: rawValue,
key: rawKey,
disabled: rawDisabled,
title: rawTitle
};
});
}, [mergedFieldNames, optionLabelProp, valueOptions]);
// =========================== Values ===========================
var _useMergedState3 = (0,useMergedState/* default */.Z)(defaultValue, {
value: value
}),
_useMergedState4 = (0,slicedToArray/* default */.Z)(_useMergedState3, 2),
internalValue = _useMergedState4[0],
setInternalValue = _useMergedState4[1];
// Merged value with LabelValueType
var rawLabeledValues = react.useMemo(function () {
var _values$;
var values = convert2LabelValues(internalValue);
// combobox no need save value when it's no value
if (mode === 'combobox' && !((_values$ = values[0]) !== null && _values$ !== void 0 && _values$.value)) {
return [];
}
return values;
}, [internalValue, convert2LabelValues, mode]);
// Fill label with cache to avoid option remove
var _useCache = useCache(rawLabeledValues, valueOptions),
_useCache2 = (0,slicedToArray/* default */.Z)(_useCache, 2),
mergedValues = _useCache2[0],
getMixedOption = _useCache2[1];
var displayValues = react.useMemo(function () {
// `null` need show as placeholder instead
// https://github.com/ant-design/ant-design/issues/25057
if (!mode && mergedValues.length === 1) {
var firstValue = mergedValues[0];
if (firstValue.value === null && (firstValue.label === null || firstValue.label === undefined)) {
return [];
}
}
return mergedValues.map(function (item) {
var _item$label;
return (0,objectSpread2/* default */.Z)((0,objectSpread2/* default */.Z)({}, item), {}, {
label: (_item$label = item.label) !== null && _item$label !== void 0 ? _item$label : item.value
});
});
}, [mode, mergedValues]);
/** Convert `displayValues` to raw value type set */
var rawValues = react.useMemo(function () {
return new Set(mergedValues.map(function (val) {
return val.value;
}));
}, [mergedValues]);
react.useEffect(function () {
if (mode === 'combobox') {
var _mergedValues$;
var strValue = (_mergedValues$ = mergedValues[0]) === null || _mergedValues$ === void 0 ? void 0 : _mergedValues$.value;
setSearchValue(hasValue(strValue) ? String(strValue) : '');
}
}, [mergedValues]);
// ======================= Display Option =======================
// Create a placeholder item if not exist in `options`
var createTagOption = useRefFunc(function (val, label) {
var _ref;
var mergedLabel = label !== null && label !== void 0 ? label : val;
return _ref = {}, (0,defineProperty/* default */.Z)(_ref, mergedFieldNames.value, val), (0,defineProperty/* default */.Z)(_ref, mergedFieldNames.label, mergedLabel), _ref;
});
// Fill tag as option if mode is `tags`
var filledTagOptions = react.useMemo(function () {
if (mode !== 'tags') {
return mergedOptions;
}
// >>> Tag mode
var cloneOptions = (0,toConsumableArray/* default */.Z)(mergedOptions);
// Check if value exist in options (include new patch item)
var existOptions = function existOptions(val) {
return valueOptions.has(val);
};
// Fill current value as option
(0,toConsumableArray/* default */.Z)(mergedValues).sort(function (a, b) {
return a.value < b.value ? -1 : 1;
}).forEach(function (item) {
var val = item.value;
if (!existOptions(val)) {
cloneOptions.push(createTagOption(val, item.label));
}
});
return cloneOptions;
}, [createTagOption, mergedOptions, valueOptions, mergedValues, mode]);
var filteredOptions = useFilterOptions(filledTagOptions, mergedFieldNames, mergedSearchValue, mergedFilterOption, optionFilterProp);
// Fill options with search value if needed
var filledSearchOptions = react.useMemo(function () {
if (mode !== 'tags' || !mergedSearchValue || filteredOptions.some(function (item) {
return item[optionFilterProp || 'value'] === mergedSearchValue;
})) {
return filteredOptions;
}
// Fill search value as option
return [createTagOption(mergedSearchValue)].concat((0,toConsumableArray/* default */.Z)(filteredOptions));
}, [createTagOption, optionFilterProp, mode, filteredOptions, mergedSearchValue]);
var orderedFilteredOptions = react.useMemo(function () {
if (!filterSort) {
return filledSearchOptions;
}
return (0,toConsumableArray/* default */.Z)(filledSearchOptions).sort(function (a, b) {
return filterSort(a, b);
});
}, [filledSearchOptions, filterSort]);
var displayOptions = react.useMemo(function () {
return flattenOptions(orderedFilteredOptions, {
fieldNames: mergedFieldNames,
childrenAsData: childrenAsData
});
}, [orderedFilteredOptions, mergedFieldNames, childrenAsData]);
// =========================== Change ===========================
var triggerChange = function triggerChange(values) {
var labeledValues = convert2LabelValues(values);
setInternalValue(labeledValues);
if (onChange && (
// Trigger event only when value changed
labeledValues.length !== mergedValues.length || labeledValues.some(function (newVal, index) {
var _mergedValues$index;
return ((_mergedValues$index = mergedValues[index]) === null || _mergedValues$index === void 0 ? void 0 : _mergedValues$index.value) !== (newVal === null || newVal === void 0 ? void 0 : newVal.value);
}))) {
var returnValues = labelInValue ? labeledValues : labeledValues.map(function (v) {
return v.value;
});
var returnOptions = labeledValues.map(function (v) {
return injectPropsWithOption(getMixedOption(v.value));
});
onChange(
// Value
multiple ? returnValues : returnValues[0],
// Option
multiple ? returnOptions : returnOptions[0]);
}
};
// ======================= Accessibility ========================
var _React$useState = react.useState(null),
_React$useState2 = (0,slicedToArray/* default */.Z)(_React$useState, 2),
activeValue = _React$useState2[0],
setActiveValue = _React$useState2[1];
var _React$useState3 = react.useState(0),
_React$useState4 = (0,slicedToArray/* default */.Z)(_React$useState3, 2),
accessibilityIndex = _React$useState4[0],
setAccessibilityIndex = _React$useState4[1];
var mergedDefaultActiveFirstOption = defaultActiveFirstOption !== undefined ? defaultActiveFirstOption : mode !== 'combobox';
var onActiveValue = react.useCallback(function (active, index) {
var _ref2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
_ref2$source = _ref2.source,
source = _ref2$source === void 0 ? 'keyboard' : _ref2$source;
setAccessibilityIndex(index);
if (backfill && mode === 'combobox' && active !== null && source === 'keyboard') {
setActiveValue(String(active));
}
}, [backfill, mode]);
// ========================= OptionList =========================
var triggerSelect = function triggerSelect(val, selected, type) {
var getSelectEnt = function getSelectEnt() {
var _option$key2;
var option = getMixedOption(val);
return [labelInValue ? {
label: option === null || option === void 0 ? void 0 : option[mergedFieldNames.label],
value: val,
key: (_option$key2 = option === null || option === void 0 ? void 0 : option.key) !== null && _option$key2 !== void 0 ? _option$key2 : val
} : val, injectPropsWithOption(option)];
};
if (selected && onSelect) {
var _getSelectEnt = getSelectEnt(),
_getSelectEnt2 = (0,slicedToArray/* default */.Z)(_getSelectEnt, 2),
wrappedValue = _getSelectEnt2[0],
_option = _getSelectEnt2[1];
onSelect(wrappedValue, _option);
} else if (!selected && onDeselect && type !== 'clear') {
var _getSelectEnt3 = getSelectEnt(),
_getSelectEnt4 = (0,slicedToArray/* default */.Z)(_getSelectEnt3, 2),
_wrappedValue = _getSelectEnt4[0],
_option2 = _getSelectEnt4[1];
onDeselect(_wrappedValue, _option2);
}
};
// Used for OptionList selection
var onInternalSelect = useRefFunc(function (val, info) {
var cloneValues;
// Single mode always trigger select only with option list
var mergedSelect = multiple ? info.selected : true;
if (mergedSelect) {
cloneValues = multiple ? [].concat((0,toConsumableArray/* default */.Z)(mergedValues), [val]) : [val];
} else {
cloneValues = mergedValues.filter(function (v) {
return v.value !== val;
});
}
triggerChange(cloneValues);
triggerSelect(val, mergedSelect);
// Clean search value if single or configured
if (mode === 'combobox') {
// setSearchValue(String(val));
setActiveValue('');
} else if (!BaseSelect_isMultiple || autoClearSearchValue) {
setSearchValue('');
setActiveValue('');
}
});
// ======================= Display Change =======================
// BaseSelect display values change
var onDisplayValuesChange = function onDisplayValuesChange(nextValues, info) {
triggerChange(nextValues);
var type = info.type,
values = info.values;
if (type === 'remove' || type === 'clear') {
values.forEach(function (item) {
triggerSelect(item.value, false, type);
});
}
};
// =========================== Search ===========================
var onInternalSearch = function onInternalSearch(searchText, info) {
setSearchValue(searchText);
setActiveValue(null);
// [Submit] Tag mode should flush input
if (info.source === 'submit') {
var formatted = (searchText || '').trim();
// prevent empty tags from appearing when you click the Enter button
if (formatted) {
var newRawValues = Array.from(new Set([].concat((0,toConsumableArray/* default */.Z)(rawValues), [formatted])));
triggerChange(newRawValues);
triggerSelect(formatted, true);
setSearchValue('');
}
return;
}
if (info.source !== 'blur') {
if (mode === 'combobox') {
triggerChange(searchText);
}
onSearch === null || onSearch === void 0 ? void 0 : onSearch(searchText);
}
};
var onInternalSearchSplit = function onInternalSearchSplit(words) {
var patchValues = words;
if (mode !== 'tags') {
patchValues = words.map(function (word) {
var opt = labelOptions.get(word);
return opt === null || opt === void 0 ? void 0 : opt.value;
}).filter(function (val) {
return val !== undefined;
});
}
var newRawValues = Array.from(new Set([].concat((0,toConsumableArray/* default */.Z)(rawValues), (0,toConsumableArray/* default */.Z)(patchValues))));
triggerChange(newRawValues);
newRawValues.forEach(function (newRawValue) {
triggerSelect(newRawValue, true);
});
};
// ========================== Context ===========================
var selectContext = react.useMemo(function () {
var realVirtual = virtual !== false && dropdownMatchSelectWidth !== false;
return (0,objectSpread2/* default */.Z)((0,objectSpread2/* default */.Z)({}, parsedOptions), {}, {
flattenOptions: displayOptions,
onActiveValue: onActiveValue,
defaultActiveFirstOption: mergedDefaultActiveFirstOption,
onSelect: onInternalSelect,
menuItemSelectedIcon: menuItemSelectedIcon,
rawValues: rawValues,
fieldNames: mergedFieldNames,
virtual: realVirtual,
direction: direction,
listHeight: listHeight,
listItemHeight: listItemHeight,
childrenAsData: childrenAsData
});
}, [parsedOptions, displayOptions, onActiveValue, mergedDefaultActiveFirstOption, onInternalSelect, menuItemSelectedIcon, rawValues, mergedFieldNames, virtual, dropdownMatchSelectWidth, listHeight, listItemHeight, childrenAsData]);
// ========================== Warning ===========================
if (false) {}
// ==============================================================
// == Render ==
// ==============================================================
return /*#__PURE__*/react.createElement(es_SelectContext.Provider, {
value: selectContext
}, /*#__PURE__*/react.createElement(es_BaseSelect, (0,esm_extends/* default */.Z)({}, restProps, {
// >>> MISC
id: mergedId,
prefixCls: prefixCls,
ref: ref,
omitDomProps: OMIT_DOM_PROPS,
mode: mode
// >>> Values
,
displayValues: displayValues,
onDisplayValuesChange: onDisplayValuesChange
// >>> Trigger
,
direction: direction
// >>> Search
,
searchValue: mergedSearchValue,
onSearch: onInternalSearch,
autoClearSearchValue: autoClearSearchValue,
onSearchSplit: onInternalSearchSplit,
dropdownMatchSelectWidth: dropdownMatchSelectWidth
// >>> OptionList
,
OptionList: es_OptionList,
emptyOptions: !displayOptions.length
// >>> Accessibility
,
activeValue: activeValue,
activeDescendantId: "".concat(mergedId, "_list_").concat(accessibilityIndex)
})));
});
if (false) {}
var TypedSelect = Select_Select;
TypedSelect.Option = es_Option;
TypedSelect.OptGroup = es_OptGroup;
/* harmony default export */ var es_Select = ((/* unused pure expression or super */ null && (TypedSelect)));
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/node_modules/rc-select/es/index.js
/* harmony default export */ var rc_select_es = ((/* unused pure expression or super */ null && (Select)));
// EXTERNAL MODULE: ./node_modules/rc-tree/es/utils/conductUtil.js
var conductUtil = __webpack_require__(17341);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js
var assertThisInitialized = __webpack_require__(97326);
// EXTERNAL MODULE: ./node_modules/rc-tree/es/contextTypes.js
var contextTypes = __webpack_require__(27822);
// EXTERNAL MODULE: ./node_modules/rc-tree/es/util.js
var util = __webpack_require__(10225);
// EXTERNAL MODULE: ./node_modules/rc-tree/es/utils/treeUtil.js
var treeUtil = __webpack_require__(1089);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/objectDestructuringEmpty.js
var objectDestructuringEmpty = __webpack_require__(36459);
// EXTERNAL MODULE: ./node_modules/rc-virtual-list/es/index.js + 14 modules
var node_modules_rc_virtual_list_es = __webpack_require__(73453);
// EXTERNAL MODULE: ./node_modules/rc-motion/es/index.js + 11 modules
var rc_motion_es = __webpack_require__(62874);
// EXTERNAL MODULE: ./node_modules/rc-tree/es/TreeNode.js + 1 modules
var TreeNode = __webpack_require__(86128);
;// CONCATENATED MODULE: ./node_modules/rc-tree/es/MotionTreeNode.js
var MotionTreeNode_excluded = ["className", "style", "motion", "motionNodes", "motionType", "onMotionStart", "onMotionEnd", "active", "treeNodeRequiredProps"];
var MotionTreeNode = function MotionTreeNode(_ref, ref) {
var className = _ref.className,
style = _ref.style,
motion = _ref.motion,
motionNodes = _ref.motionNodes,
motionType = _ref.motionType,
onOriginMotionStart = _ref.onMotionStart,
onOriginMotionEnd = _ref.onMotionEnd,
active = _ref.active,
treeNodeRequiredProps = _ref.treeNodeRequiredProps,
props = (0,objectWithoutProperties/* default */.Z)(_ref, MotionTreeNode_excluded);
var _React$useState = react.useState(true),
_React$useState2 = (0,slicedToArray/* default */.Z)(_React$useState, 2),
visible = _React$useState2[0],
setVisible = _React$useState2[1];
var _React$useContext = react.useContext(contextTypes/* TreeContext */.k),
prefixCls = _React$useContext.prefixCls;
var motionedRef = react.useRef(false);
var onMotionEnd = function onMotionEnd() {
if (!motionedRef.current) {
onOriginMotionEnd();
}
motionedRef.current = true;
};
(0,react.useEffect)(function () {
if (motionNodes && motionType === 'hide' && visible) {
setVisible(false);
}
}, [motionNodes]);
(0,react.useEffect)(function () {
// Trigger motion only when patched
if (motionNodes) {
onOriginMotionStart();
}
return function () {
if (motionNodes) {
onMotionEnd();
}
};
}, []);
if (motionNodes) {
return /*#__PURE__*/react.createElement(rc_motion_es/* default */.Z, (0,esm_extends/* default */.Z)({
ref: ref,
visible: visible
}, motion, {
motionAppear: motionType === 'show',
onAppearEnd: onMotionEnd,
onLeaveEnd: onMotionEnd
}), function (_ref2, motionRef) {
var motionClassName = _ref2.className,
motionStyle = _ref2.style;
return /*#__PURE__*/react.createElement("div", {
ref: motionRef,
className: classnames_default()("".concat(prefixCls, "-treenode-motion"), motionClassName),
style: motionStyle
}, motionNodes.map(function (treeNode) {
var restProps = (0,esm_extends/* default */.Z)({}, ((0,objectDestructuringEmpty/* default */.Z)(treeNode.data), treeNode.data)),
title = treeNode.title,
key = treeNode.key,
isStart = treeNode.isStart,
isEnd = treeNode.isEnd;
delete restProps.children;
var treeNodeProps = (0,treeUtil/* getTreeNodeProps */.H8)(key, treeNodeRequiredProps);
return /*#__PURE__*/react.createElement(TreeNode/* default */.Z, (0,esm_extends/* default */.Z)({}, restProps, treeNodeProps, {
title: title,
active: active,
data: treeNode.data,
key: key,
isStart: isStart,
isEnd: isEnd
}));
}));
});
}
return /*#__PURE__*/react.createElement(TreeNode/* default */.Z, (0,esm_extends/* default */.Z)({
domRef: ref,
className: className,
style: style
}, props, {
active: active
}));
};
MotionTreeNode.displayName = 'MotionTreeNode';
var RefMotionTreeNode = /*#__PURE__*/react.forwardRef(MotionTreeNode);
/* harmony default export */ var es_MotionTreeNode = (RefMotionTreeNode);
;// CONCATENATED MODULE: ./node_modules/rc-tree/es/utils/diffUtil.js
function findExpandedKeys() {
var prev = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
var next = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
var prevLen = prev.length;
var nextLen = next.length;
if (Math.abs(prevLen - nextLen) !== 1) {
return {
add: false,
key: null
};
}
function find(shorter, longer) {
var cache = new Map();
shorter.forEach(function (key) {
cache.set(key, true);
});
var keys = longer.filter(function (key) {
return !cache.has(key);
});
return keys.length === 1 ? keys[0] : null;
}
if (prevLen < nextLen) {
return {
add: true,
key: find(prev, next)
};
}
return {
add: false,
key: find(next, prev)
};
}
function getExpandRange(shorter, longer, key) {
var shorterStartIndex = shorter.findIndex(function (data) {
return data.key === key;
});
var shorterEndNode = shorter[shorterStartIndex + 1];
var longerStartIndex = longer.findIndex(function (data) {
return data.key === key;
});
if (shorterEndNode) {
var longerEndIndex = longer.findIndex(function (data) {
return data.key === shorterEndNode.key;
});
return longer.slice(longerStartIndex + 1, longerEndIndex);
}
return longer.slice(longerStartIndex + 1);
}
;// CONCATENATED MODULE: ./node_modules/rc-tree/es/NodeList.js
var NodeList_excluded = ["prefixCls", "data", "selectable", "checkable", "expandedKeys", "selectedKeys", "checkedKeys", "loadedKeys", "loadingKeys", "halfCheckedKeys", "keyEntities", "disabled", "dragging", "dragOverNodeKey", "dropPosition", "motion", "height", "itemHeight", "virtual", "focusable", "activeItem", "focused", "tabIndex", "onKeyDown", "onFocus", "onBlur", "onActiveChange", "onListChangeStart", "onListChangeEnd"];
/**
* Handle virtual list of the TreeNodes.
*/
var HIDDEN_STYLE = {
width: 0,
height: 0,
display: 'flex',
overflow: 'hidden',
opacity: 0,
border: 0,
padding: 0,
margin: 0
};
var noop = function noop() {};
var MOTION_KEY = "RC_TREE_MOTION_".concat(Math.random());
var MotionNode = {
key: MOTION_KEY
};
var MotionEntity = {
key: MOTION_KEY,
level: 0,
index: 0,
pos: '0',
node: MotionNode,
nodes: [MotionNode]
};
var MotionFlattenData = {
parent: null,
children: [],
pos: MotionEntity.pos,
data: MotionNode,
title: null,
key: MOTION_KEY,
/** Hold empty list here since we do not use it */
isStart: [],
isEnd: []
};
/**
* We only need get visible content items to play the animation.
*/
function getMinimumRangeTransitionRange(list, virtual, height, itemHeight) {
if (virtual === false || !height) {
return list;
}
return list.slice(0, Math.ceil(height / itemHeight) + 1);
}
function NodeList_itemKey(item) {
var key = item.key,
pos = item.pos;
return (0,treeUtil/* getKey */.km)(key, pos);
}
function getAccessibilityPath(item) {
var path = String(item.data.key);
var current = item;
while (current.parent) {
current = current.parent;
path = "".concat(current.data.key, " > ").concat(path);
}
return path;
}
var NodeList = /*#__PURE__*/react.forwardRef(function (props, ref) {
var prefixCls = props.prefixCls,
data = props.data,
selectable = props.selectable,
checkable = props.checkable,
expandedKeys = props.expandedKeys,
selectedKeys = props.selectedKeys,
checkedKeys = props.checkedKeys,
loadedKeys = props.loadedKeys,
loadingKeys = props.loadingKeys,
halfCheckedKeys = props.halfCheckedKeys,
keyEntities = props.keyEntities,
disabled = props.disabled,
dragging = props.dragging,
dragOverNodeKey = props.dragOverNodeKey,
dropPosition = props.dropPosition,
motion = props.motion,
height = props.height,
itemHeight = props.itemHeight,
virtual = props.virtual,
focusable = props.focusable,
activeItem = props.activeItem,
focused = props.focused,
tabIndex = props.tabIndex,
onKeyDown = props.onKeyDown,
onFocus = props.onFocus,
onBlur = props.onBlur,
onActiveChange = props.onActiveChange,
onListChangeStart = props.onListChangeStart,
onListChangeEnd = props.onListChangeEnd,
domProps = (0,objectWithoutProperties/* default */.Z)(props, NodeList_excluded);
// =============================== Ref ================================
var listRef = react.useRef(null);
var indentMeasurerRef = react.useRef(null);
react.useImperativeHandle(ref, function () {
return {
scrollTo: function scrollTo(scroll) {
listRef.current.scrollTo(scroll);
},
getIndentWidth: function getIndentWidth() {
return indentMeasurerRef.current.offsetWidth;
}
};
});
// ============================== Motion ==============================
var _React$useState = react.useState(expandedKeys),
_React$useState2 = (0,slicedToArray/* default */.Z)(_React$useState, 2),
prevExpandedKeys = _React$useState2[0],
setPrevExpandedKeys = _React$useState2[1];
var _React$useState3 = react.useState(data),
_React$useState4 = (0,slicedToArray/* default */.Z)(_React$useState3, 2),
prevData = _React$useState4[0],
setPrevData = _React$useState4[1];
var _React$useState5 = react.useState(data),
_React$useState6 = (0,slicedToArray/* default */.Z)(_React$useState5, 2),
transitionData = _React$useState6[0],
setTransitionData = _React$useState6[1];
var _React$useState7 = react.useState([]),
_React$useState8 = (0,slicedToArray/* default */.Z)(_React$useState7, 2),
transitionRange = _React$useState8[0],
setTransitionRange = _React$useState8[1];
var _React$useState9 = react.useState(null),
_React$useState10 = (0,slicedToArray/* default */.Z)(_React$useState9, 2),
motionType = _React$useState10[0],
setMotionType = _React$useState10[1];
// When motion end but data change, this will makes data back to previous one
var dataRef = react.useRef(data);
dataRef.current = data;
function onMotionEnd() {
var latestData = dataRef.current;
setPrevData(latestData);
setTransitionData(latestData);
setTransitionRange([]);
setMotionType(null);
onListChangeEnd();
}
// Do animation if expanded keys changed
react.useEffect(function () {
setPrevExpandedKeys(expandedKeys);
var diffExpanded = findExpandedKeys(prevExpandedKeys, expandedKeys);
if (diffExpanded.key !== null) {
if (diffExpanded.add) {
var keyIndex = prevData.findIndex(function (_ref) {
var key = _ref.key;
return key === diffExpanded.key;
});
var rangeNodes = getMinimumRangeTransitionRange(getExpandRange(prevData, data, diffExpanded.key), virtual, height, itemHeight);
var newTransitionData = prevData.slice();
newTransitionData.splice(keyIndex + 1, 0, MotionFlattenData);
setTransitionData(newTransitionData);
setTransitionRange(rangeNodes);
setMotionType('show');
} else {
var _keyIndex = data.findIndex(function (_ref2) {
var key = _ref2.key;
return key === diffExpanded.key;
});
var _rangeNodes = getMinimumRangeTransitionRange(getExpandRange(data, prevData, diffExpanded.key), virtual, height, itemHeight);
var _newTransitionData = data.slice();
_newTransitionData.splice(_keyIndex + 1, 0, MotionFlattenData);
setTransitionData(_newTransitionData);
setTransitionRange(_rangeNodes);
setMotionType('hide');
}
} else if (prevData !== data) {
// If whole data changed, we just refresh the list
setPrevData(data);
setTransitionData(data);
}
}, [expandedKeys, data]);
// We should clean up motion if is changed by dragging
react.useEffect(function () {
if (!dragging) {
onMotionEnd();
}
}, [dragging]);
var mergedData = motion ? transitionData : data;
var treeNodeRequiredProps = {
expandedKeys: expandedKeys,
selectedKeys: selectedKeys,
loadedKeys: loadedKeys,
loadingKeys: loadingKeys,
checkedKeys: checkedKeys,
halfCheckedKeys: halfCheckedKeys,
dragOverNodeKey: dragOverNodeKey,
dropPosition: dropPosition,
keyEntities: keyEntities
};
return /*#__PURE__*/react.createElement(react.Fragment, null, focused && activeItem && /*#__PURE__*/react.createElement("span", {
style: HIDDEN_STYLE,
"aria-live": "assertive"
}, getAccessibilityPath(activeItem)), /*#__PURE__*/react.createElement("div", null, /*#__PURE__*/react.createElement("input", {
style: HIDDEN_STYLE,
disabled: focusable === false || disabled,
tabIndex: focusable !== false ? tabIndex : null,
onKeyDown: onKeyDown,
onFocus: onFocus,
onBlur: onBlur,
value: "",
onChange: noop,
"aria-label": "for screen reader"
})), /*#__PURE__*/react.createElement("div", {
className: "".concat(prefixCls, "-treenode"),
"aria-hidden": true,
style: {
position: 'absolute',
pointerEvents: 'none',
visibility: 'hidden',
height: 0,
overflow: 'hidden',
border: 0,
padding: 0
}
}, /*#__PURE__*/react.createElement("div", {
className: "".concat(prefixCls, "-indent")
}, /*#__PURE__*/react.createElement("div", {
ref: indentMeasurerRef,
className: "".concat(prefixCls, "-indent-unit")
}))), /*#__PURE__*/react.createElement(node_modules_rc_virtual_list_es/* default */.Z, (0,esm_extends/* default */.Z)({}, domProps, {
data: mergedData,
itemKey: NodeList_itemKey,
height: height,
fullHeight: false,
virtual: virtual,
itemHeight: itemHeight,
prefixCls: "".concat(prefixCls, "-list"),
ref: listRef,
onVisibleChange: function onVisibleChange(originList, fullList) {
var originSet = new Set(originList);
var restList = fullList.filter(function (item) {
return !originSet.has(item);
});
// Motion node is not render. Skip motion
if (restList.some(function (item) {
return NodeList_itemKey(item) === MOTION_KEY;
})) {
onMotionEnd();
}
}
}), function (treeNode) {
var pos = treeNode.pos,
restProps = (0,esm_extends/* default */.Z)({}, ((0,objectDestructuringEmpty/* default */.Z)(treeNode.data), treeNode.data)),
title = treeNode.title,
key = treeNode.key,
isStart = treeNode.isStart,
isEnd = treeNode.isEnd;
var mergedKey = (0,treeUtil/* getKey */.km)(key, pos);
delete restProps.key;
delete restProps.children;
var treeNodeProps = (0,treeUtil/* getTreeNodeProps */.H8)(mergedKey, treeNodeRequiredProps);
return /*#__PURE__*/react.createElement(es_MotionTreeNode, (0,esm_extends/* default */.Z)({}, restProps, treeNodeProps, {
title: title,
active: !!activeItem && key === activeItem.key,
pos: pos,
data: treeNode.data,
isStart: isStart,
isEnd: isEnd,
motion: motion,
motionNodes: key === MOTION_KEY ? transitionRange : null,
motionType: motionType,
onMotionStart: onListChangeStart,
onMotionEnd: onMotionEnd,
treeNodeRequiredProps: treeNodeRequiredProps,
onMouseMove: function onMouseMove() {
onActiveChange(null);
}
}));
}));
});
NodeList.displayName = 'NodeList';
/* harmony default export */ var es_NodeList = (NodeList);
;// CONCATENATED MODULE: ./node_modules/rc-tree/es/DropIndicator.js
function DropIndicator(_ref) {
var dropPosition = _ref.dropPosition,
dropLevelOffset = _ref.dropLevelOffset,
indent = _ref.indent;
var style = {
pointerEvents: 'none',
position: 'absolute',
right: 0,
backgroundColor: 'red',
height: 2
};
switch (dropPosition) {
case -1:
style.top = 0;
style.left = -dropLevelOffset * indent;
break;
case 1:
style.bottom = 0;
style.left = -dropLevelOffset * indent;
break;
case 0:
style.bottom = 0;
style.left = indent;
break;
}
return /*#__PURE__*/react.createElement("div", {
style: style
});
}
;// CONCATENATED MODULE: ./node_modules/rc-tree/es/Tree.js
// TODO: https://www.w3.org/TR/2017/NOTE-wai-aria-practices-1.1-20171214/examples/treeview/treeview-2/treeview-2a.html
// Fully accessibility support
var MAX_RETRY_TIMES = 10;
var Tree = /*#__PURE__*/function (_React$Component) {
(0,inherits/* default */.Z)(Tree, _React$Component);
var _super = (0,createSuper/* default */.Z)(Tree);
function Tree() {
var _this;
(0,classCallCheck/* default */.Z)(this, Tree);
for (var _len = arguments.length, _args = new Array(_len), _key = 0; _key < _len; _key++) {
_args[_key] = arguments[_key];
}
_this = _super.call.apply(_super, [this].concat(_args));
_this.destroyed = false;
_this.delayedDragEnterLogic = void 0;
_this.loadingRetryTimes = {};
_this.state = {
keyEntities: {},
indent: null,
selectedKeys: [],
checkedKeys: [],
halfCheckedKeys: [],
loadedKeys: [],
loadingKeys: [],
expandedKeys: [],
draggingNodeKey: null,
dragChildrenKeys: [],
// dropTargetKey is the key of abstract-drop-node
// the abstract-drop-node is the real drop node when drag and drop
// not the DOM drag over node
dropTargetKey: null,
dropPosition: null,
dropContainerKey: null,
dropLevelOffset: null,
dropTargetPos: null,
dropAllowed: true,
// the abstract-drag-over-node
// if mouse is on the bottom of top dom node or no the top of the bottom dom node
// abstract-drag-over-node is the top node
dragOverNodeKey: null,
treeData: [],
flattenNodes: [],
focused: false,
activeKey: null,
listChanging: false,
prevProps: null,
fieldNames: (0,treeUtil/* fillFieldNames */.w$)()
};
_this.dragStartMousePosition = null;
_this.dragNode = void 0;
_this.currentMouseOverDroppableNodeKey = null;
_this.listRef = /*#__PURE__*/react.createRef();
_this.onNodeDragStart = function (event, node) {
var _this$state = _this.state,
expandedKeys = _this$state.expandedKeys,
keyEntities = _this$state.keyEntities;
var onDragStart = _this.props.onDragStart;
var eventKey = node.props.eventKey;
_this.dragNode = node;
_this.dragStartMousePosition = {
x: event.clientX,
y: event.clientY
};
var newExpandedKeys = (0,util/* arrDel */._5)(expandedKeys, eventKey);
_this.setState({
draggingNodeKey: eventKey,
dragChildrenKeys: (0,util/* getDragChildrenKeys */.wA)(eventKey, keyEntities),
indent: _this.listRef.current.getIndentWidth()
});
_this.setExpandedKeys(newExpandedKeys);
window.addEventListener('dragend', _this.onWindowDragEnd);
onDragStart === null || onDragStart === void 0 ? void 0 : onDragStart({
event: event,
node: (0,treeUtil/* convertNodePropsToEventData */.F)(node.props)
});
};
/**
* [Legacy] Select handler is smaller than node,
* so that this will trigger when drag enter node or select handler.
* This is a little tricky if customize css without padding.
* Better for use mouse move event to refresh drag state.
* But let's just keep it to avoid event trigger logic change.
*/
_this.onNodeDragEnter = function (event, node) {
var _this$state2 = _this.state,
expandedKeys = _this$state2.expandedKeys,
keyEntities = _this$state2.keyEntities,
dragChildrenKeys = _this$state2.dragChildrenKeys,
flattenNodes = _this$state2.flattenNodes,
indent = _this$state2.indent;
var _this$props = _this.props,
onDragEnter = _this$props.onDragEnter,
onExpand = _this$props.onExpand,
allowDrop = _this$props.allowDrop,
direction = _this$props.direction;
var _node$props = node.props,
pos = _node$props.pos,
eventKey = _node$props.eventKey;
var _assertThisInitialize = (0,assertThisInitialized/* default */.Z)(_this),
dragNode = _assertThisInitialize.dragNode;
// record the key of node which is latest entered, used in dragleave event.
if (_this.currentMouseOverDroppableNodeKey !== eventKey) {
_this.currentMouseOverDroppableNodeKey = eventKey;
}
if (!dragNode) {
_this.resetDragState();
return;
}
var _calcDropPosition = (0,util/* calcDropPosition */.OM)(event, dragNode, node, indent, _this.dragStartMousePosition, allowDrop, flattenNodes, keyEntities, expandedKeys, direction),
dropPosition = _calcDropPosition.dropPosition,
dropLevelOffset = _calcDropPosition.dropLevelOffset,
dropTargetKey = _calcDropPosition.dropTargetKey,
dropContainerKey = _calcDropPosition.dropContainerKey,
dropTargetPos = _calcDropPosition.dropTargetPos,
dropAllowed = _calcDropPosition.dropAllowed,
dragOverNodeKey = _calcDropPosition.dragOverNodeKey;
if (
// don't allow drop inside its children
dragChildrenKeys.indexOf(dropTargetKey) !== -1 ||
// don't allow drop when drop is not allowed caculated by calcDropPosition
!dropAllowed) {
_this.resetDragState();
return;
}
// Side effect for delay drag
if (!_this.delayedDragEnterLogic) {
_this.delayedDragEnterLogic = {};
}
Object.keys(_this.delayedDragEnterLogic).forEach(function (key) {
clearTimeout(_this.delayedDragEnterLogic[key]);
});
if (dragNode.props.eventKey !== node.props.eventKey) {
// hoist expand logic here
// since if logic is on the bottom
// it will be blocked by abstract dragover node check
// => if you dragenter from top, you mouse will still be consider as in the top node
event.persist();
_this.delayedDragEnterLogic[pos] = window.setTimeout(function () {
if (_this.state.draggingNodeKey === null) return;
var newExpandedKeys = (0,toConsumableArray/* default */.Z)(expandedKeys);
var entity = keyEntities[node.props.eventKey];
if (entity && (entity.children || []).length) {
newExpandedKeys = (0,util/* arrAdd */.L0)(expandedKeys, node.props.eventKey);
}
if (!('expandedKeys' in _this.props)) {
_this.setExpandedKeys(newExpandedKeys);
}
onExpand === null || onExpand === void 0 ? void 0 : onExpand(newExpandedKeys, {
node: (0,treeUtil/* convertNodePropsToEventData */.F)(node.props),
expanded: true,
nativeEvent: event.nativeEvent
});
}, 800);
}
// Skip if drag node is self
if (dragNode.props.eventKey === dropTargetKey && dropLevelOffset === 0) {
_this.resetDragState();
return;
}
// Update drag over node and drag state
_this.setState({
dragOverNodeKey: dragOverNodeKey,
dropPosition: dropPosition,
dropLevelOffset: dropLevelOffset,
dropTargetKey: dropTargetKey,
dropContainerKey: dropContainerKey,
dropTargetPos: dropTargetPos,
dropAllowed: dropAllowed
});
onDragEnter === null || onDragEnter === void 0 ? void 0 : onDragEnter({
event: event,
node: (0,treeUtil/* convertNodePropsToEventData */.F)(node.props),
expandedKeys: expandedKeys
});
};
_this.onNodeDragOver = function (event, node) {
var _this$state3 = _this.state,
dragChildrenKeys = _this$state3.dragChildrenKeys,
flattenNodes = _this$state3.flattenNodes,
keyEntities = _this$state3.keyEntities,
expandedKeys = _this$state3.expandedKeys,
indent = _this$state3.indent;
var _this$props2 = _this.props,
onDragOver = _this$props2.onDragOver,
allowDrop = _this$props2.allowDrop,
direction = _this$props2.direction;
var _assertThisInitialize2 = (0,assertThisInitialized/* default */.Z)(_this),
dragNode = _assertThisInitialize2.dragNode;
if (!dragNode) {
return;
}
var _calcDropPosition2 = (0,util/* calcDropPosition */.OM)(event, dragNode, node, indent, _this.dragStartMousePosition, allowDrop, flattenNodes, keyEntities, expandedKeys, direction),
dropPosition = _calcDropPosition2.dropPosition,
dropLevelOffset = _calcDropPosition2.dropLevelOffset,
dropTargetKey = _calcDropPosition2.dropTargetKey,
dropContainerKey = _calcDropPosition2.dropContainerKey,
dropAllowed = _calcDropPosition2.dropAllowed,
dropTargetPos = _calcDropPosition2.dropTargetPos,
dragOverNodeKey = _calcDropPosition2.dragOverNodeKey;
if (dragChildrenKeys.indexOf(dropTargetKey) !== -1 || !dropAllowed) {
// don't allow drop inside its children
// don't allow drop when drop is not allowed caculated by calcDropPosition
return;
}
// Update drag position
if (dragNode.props.eventKey === dropTargetKey && dropLevelOffset === 0) {
if (!(_this.state.dropPosition === null && _this.state.dropLevelOffset === null && _this.state.dropTargetKey === null && _this.state.dropContainerKey === null && _this.state.dropTargetPos === null && _this.state.dropAllowed === false && _this.state.dragOverNodeKey === null)) {
_this.resetDragState();
}
} else if (!(dropPosition === _this.state.dropPosition && dropLevelOffset === _this.state.dropLevelOffset && dropTargetKey === _this.state.dropTargetKey && dropContainerKey === _this.state.dropContainerKey && dropTargetPos === _this.state.dropTargetPos && dropAllowed === _this.state.dropAllowed && dragOverNodeKey === _this.state.dragOverNodeKey)) {
_this.setState({
dropPosition: dropPosition,
dropLevelOffset: dropLevelOffset,
dropTargetKey: dropTargetKey,
dropContainerKey: dropContainerKey,
dropTargetPos: dropTargetPos,
dropAllowed: dropAllowed,
dragOverNodeKey: dragOverNodeKey
});
}
onDragOver === null || onDragOver === void 0 ? void 0 : onDragOver({
event: event,
node: (0,treeUtil/* convertNodePropsToEventData */.F)(node.props)
});
};
_this.onNodeDragLeave = function (event, node) {
// if it is outside the droppable area
// currentMouseOverDroppableNodeKey will be updated in dragenter event when into another droppable receiver.
if (_this.currentMouseOverDroppableNodeKey === node.props.eventKey && !event.currentTarget.contains(event.relatedTarget)) {
_this.resetDragState();
_this.currentMouseOverDroppableNodeKey = null;
}
var onDragLeave = _this.props.onDragLeave;
onDragLeave === null || onDragLeave === void 0 ? void 0 : onDragLeave({
event: event,
node: (0,treeUtil/* convertNodePropsToEventData */.F)(node.props)
});
};
// since stopPropagation() is called in treeNode
// if onWindowDrag is called, whice means state is keeped, drag state should be cleared
_this.onWindowDragEnd = function (event) {
_this.onNodeDragEnd(event, null, true);
window.removeEventListener('dragend', _this.onWindowDragEnd);
};
// if onNodeDragEnd is called, onWindowDragEnd won't be called since stopPropagation() is called
_this.onNodeDragEnd = function (event, node) {
var onDragEnd = _this.props.onDragEnd;
_this.setState({
dragOverNodeKey: null
});
_this.cleanDragState();
onDragEnd === null || onDragEnd === void 0 ? void 0 : onDragEnd({
event: event,
node: (0,treeUtil/* convertNodePropsToEventData */.F)(node.props)
});
_this.dragNode = null;
window.removeEventListener('dragend', _this.onWindowDragEnd);
};
_this.onNodeDrop = function (event, node) {
var _this$getActiveItem;
var outsideTree = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
var _this$state4 = _this.state,
dragChildrenKeys = _this$state4.dragChildrenKeys,
dropPosition = _this$state4.dropPosition,
dropTargetKey = _this$state4.dropTargetKey,
dropTargetPos = _this$state4.dropTargetPos,
dropAllowed = _this$state4.dropAllowed;
if (!dropAllowed) return;
var onDrop = _this.props.onDrop;
_this.setState({
dragOverNodeKey: null
});
_this.cleanDragState();
if (dropTargetKey === null) return;
var abstractDropNodeProps = (0,objectSpread2/* default */.Z)((0,objectSpread2/* default */.Z)({}, (0,treeUtil/* getTreeNodeProps */.H8)(dropTargetKey, _this.getTreeNodeRequiredProps())), {}, {
active: ((_this$getActiveItem = _this.getActiveItem()) === null || _this$getActiveItem === void 0 ? void 0 : _this$getActiveItem.key) === dropTargetKey,
data: _this.state.keyEntities[dropTargetKey].node
});
var dropToChild = dragChildrenKeys.indexOf(dropTargetKey) !== -1;
(0,es_warning/* default */.ZP)(!dropToChild, "Can not drop to dragNode's children node. This is a bug of rc-tree. Please report an issue.");
var posArr = (0,util/* posToArr */.yx)(dropTargetPos);
var dropResult = {
event: event,
node: (0,treeUtil/* convertNodePropsToEventData */.F)(abstractDropNodeProps),
dragNode: _this.dragNode ? (0,treeUtil/* convertNodePropsToEventData */.F)(_this.dragNode.props) : null,
dragNodesKeys: [_this.dragNode.props.eventKey].concat(dragChildrenKeys),
dropToGap: dropPosition !== 0,
dropPosition: dropPosition + Number(posArr[posArr.length - 1])
};
if (!outsideTree) {
onDrop === null || onDrop === void 0 ? void 0 : onDrop(dropResult);
}
_this.dragNode = null;
};
_this.cleanDragState = function () {
var draggingNodeKey = _this.state.draggingNodeKey;
if (draggingNodeKey !== null) {
_this.setState({
draggingNodeKey: null,
dropPosition: null,
dropContainerKey: null,
dropTargetKey: null,
dropLevelOffset: null,
dropAllowed: true,
dragOverNodeKey: null
});
}
_this.dragStartMousePosition = null;
_this.currentMouseOverDroppableNodeKey = null;
};
_this.triggerExpandActionExpand = function (e, treeNode) {
var _this$state5 = _this.state,
expandedKeys = _this$state5.expandedKeys,
flattenNodes = _this$state5.flattenNodes;
var expanded = treeNode.expanded,
key = treeNode.key,
isLeaf = treeNode.isLeaf;
if (isLeaf || e.shiftKey || e.metaKey || e.ctrlKey) {
return;
}
var node = flattenNodes.filter(function (nodeItem) {
return nodeItem.key === key;
})[0];
var eventNode = (0,treeUtil/* convertNodePropsToEventData */.F)((0,objectSpread2/* default */.Z)((0,objectSpread2/* default */.Z)({}, (0,treeUtil/* getTreeNodeProps */.H8)(key, _this.getTreeNodeRequiredProps())), {}, {
data: node.data
}));
_this.setExpandedKeys(expanded ? (0,util/* arrDel */._5)(expandedKeys, key) : (0,util/* arrAdd */.L0)(expandedKeys, key));
_this.onNodeExpand(e, eventNode);
};
_this.onNodeClick = function (e, treeNode) {
var _this$props3 = _this.props,
onClick = _this$props3.onClick,
expandAction = _this$props3.expandAction;
if (expandAction === 'click') {
_this.triggerExpandActionExpand(e, treeNode);
}
onClick === null || onClick === void 0 ? void 0 : onClick(e, treeNode);
};
_this.onNodeDoubleClick = function (e, treeNode) {
var _this$props4 = _this.props,
onDoubleClick = _this$props4.onDoubleClick,
expandAction = _this$props4.expandAction;
if (expandAction === 'doubleClick') {
_this.triggerExpandActionExpand(e, treeNode);
}
onDoubleClick === null || onDoubleClick === void 0 ? void 0 : onDoubleClick(e, treeNode);
};
_this.onNodeSelect = function (e, treeNode) {
var selectedKeys = _this.state.selectedKeys;
var _this$state6 = _this.state,
keyEntities = _this$state6.keyEntities,
fieldNames = _this$state6.fieldNames;
var _this$props5 = _this.props,
onSelect = _this$props5.onSelect,
multiple = _this$props5.multiple;
var selected = treeNode.selected;
var key = treeNode[fieldNames.key];
var targetSelected = !selected;
// Update selected keys
if (!targetSelected) {
selectedKeys = (0,util/* arrDel */._5)(selectedKeys, key);
} else if (!multiple) {
selectedKeys = [key];
} else {
selectedKeys = (0,util/* arrAdd */.L0)(selectedKeys, key);
}
// [Legacy] Not found related usage in doc or upper libs
var selectedNodes = selectedKeys.map(function (selectedKey) {
var entity = keyEntities[selectedKey];
if (!entity) return null;
return entity.node;
}).filter(function (node) {
return node;
});
_this.setUncontrolledState({
selectedKeys: selectedKeys
});
onSelect === null || onSelect === void 0 ? void 0 : onSelect(selectedKeys, {
event: 'select',
selected: targetSelected,
node: treeNode,
selectedNodes: selectedNodes,
nativeEvent: e.nativeEvent
});
};
_this.onNodeCheck = function (e, treeNode, checked) {
var _this$state7 = _this.state,
keyEntities = _this$state7.keyEntities,
oriCheckedKeys = _this$state7.checkedKeys,
oriHalfCheckedKeys = _this$state7.halfCheckedKeys;
var _this$props6 = _this.props,
checkStrictly = _this$props6.checkStrictly,
onCheck = _this$props6.onCheck;
var key = treeNode.key;
// Prepare trigger arguments
var checkedObj;
var eventObj = {
event: 'check',
node: treeNode,
checked: checked,
nativeEvent: e.nativeEvent
};
if (checkStrictly) {
var checkedKeys = checked ? (0,util/* arrAdd */.L0)(oriCheckedKeys, key) : (0,util/* arrDel */._5)(oriCheckedKeys, key);
var halfCheckedKeys = (0,util/* arrDel */._5)(oriHalfCheckedKeys, key);
checkedObj = {
checked: checkedKeys,
halfChecked: halfCheckedKeys
};
eventObj.checkedNodes = checkedKeys.map(function (checkedKey) {
return keyEntities[checkedKey];
}).filter(function (entity) {
return entity;
}).map(function (entity) {
return entity.node;
});
_this.setUncontrolledState({
checkedKeys: checkedKeys
});
} else {
// Always fill first
var _conductCheck = (0,conductUtil/* conductCheck */.S)([].concat((0,toConsumableArray/* default */.Z)(oriCheckedKeys), [key]), true, keyEntities),
_checkedKeys = _conductCheck.checkedKeys,
_halfCheckedKeys = _conductCheck.halfCheckedKeys;
// If remove, we do it again to correction
if (!checked) {
var keySet = new Set(_checkedKeys);
keySet.delete(key);
var _conductCheck2 = (0,conductUtil/* conductCheck */.S)(Array.from(keySet), {
checked: false,
halfCheckedKeys: _halfCheckedKeys
}, keyEntities);
_checkedKeys = _conductCheck2.checkedKeys;
_halfCheckedKeys = _conductCheck2.halfCheckedKeys;
}
checkedObj = _checkedKeys;
// [Legacy] This is used for `rc-tree-select`
eventObj.checkedNodes = [];
eventObj.checkedNodesPositions = [];
eventObj.halfCheckedKeys = _halfCheckedKeys;
_checkedKeys.forEach(function (checkedKey) {
var entity = keyEntities[checkedKey];
if (!entity) return;
var node = entity.node,
pos = entity.pos;
eventObj.checkedNodes.push(node);
eventObj.checkedNodesPositions.push({
node: node,
pos: pos
});
});
_this.setUncontrolledState({
checkedKeys: _checkedKeys
}, false, {
halfCheckedKeys: _halfCheckedKeys
});
}
onCheck === null || onCheck === void 0 ? void 0 : onCheck(checkedObj, eventObj);
};
_this.onNodeLoad = function (treeNode) {
var key = treeNode.key;
var loadPromise = new Promise(function (resolve, reject) {
// We need to get the latest state of loading/loaded keys
_this.setState(function (_ref) {
var _ref$loadedKeys = _ref.loadedKeys,
loadedKeys = _ref$loadedKeys === void 0 ? [] : _ref$loadedKeys,
_ref$loadingKeys = _ref.loadingKeys,
loadingKeys = _ref$loadingKeys === void 0 ? [] : _ref$loadingKeys;
var _this$props7 = _this.props,
loadData = _this$props7.loadData,
onLoad = _this$props7.onLoad;
if (!loadData || loadedKeys.indexOf(key) !== -1 || loadingKeys.indexOf(key) !== -1) {
return null;
}
// Process load data
var promise = loadData(treeNode);
promise.then(function () {
var currentLoadedKeys = _this.state.loadedKeys;
var newLoadedKeys = (0,util/* arrAdd */.L0)(currentLoadedKeys, key);
// onLoad should trigger before internal setState to avoid `loadData` trigger twice.
// https://github.com/ant-design/ant-design/issues/12464
onLoad === null || onLoad === void 0 ? void 0 : onLoad(newLoadedKeys, {
event: 'load',
node: treeNode
});
_this.setUncontrolledState({
loadedKeys: newLoadedKeys
});
_this.setState(function (prevState) {
return {
loadingKeys: (0,util/* arrDel */._5)(prevState.loadingKeys, key)
};
});
resolve();
}).catch(function (e) {
_this.setState(function (prevState) {
return {
loadingKeys: (0,util/* arrDel */._5)(prevState.loadingKeys, key)
};
});
// If exceed max retry times, we give up retry
_this.loadingRetryTimes[key] = (_this.loadingRetryTimes[key] || 0) + 1;
if (_this.loadingRetryTimes[key] >= MAX_RETRY_TIMES) {
var currentLoadedKeys = _this.state.loadedKeys;
(0,es_warning/* default */.ZP)(false, 'Retry for `loadData` many times but still failed. No more retry.');
_this.setUncontrolledState({
loadedKeys: (0,util/* arrAdd */.L0)(currentLoadedKeys, key)
});
resolve();
}
reject(e);
});
return {
loadingKeys: (0,util/* arrAdd */.L0)(loadingKeys, key)
};
});
});
// Not care warning if we ignore this
loadPromise.catch(function () {});
return loadPromise;
};
_this.onNodeMouseEnter = function (event, node) {
var onMouseEnter = _this.props.onMouseEnter;
onMouseEnter === null || onMouseEnter === void 0 ? void 0 : onMouseEnter({
event: event,
node: node
});
};
_this.onNodeMouseLeave = function (event, node) {
var onMouseLeave = _this.props.onMouseLeave;
onMouseLeave === null || onMouseLeave === void 0 ? void 0 : onMouseLeave({
event: event,
node: node
});
};
_this.onNodeContextMenu = function (event, node) {
var onRightClick = _this.props.onRightClick;
if (onRightClick) {
event.preventDefault();
onRightClick({
event: event,
node: node
});
}
};
_this.onFocus = function () {
var onFocus = _this.props.onFocus;
_this.setState({
focused: true
});
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
onFocus === null || onFocus === void 0 ? void 0 : onFocus.apply(void 0, args);
};
_this.onBlur = function () {
var onBlur = _this.props.onBlur;
_this.setState({
focused: false
});
_this.onActiveChange(null);
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
args[_key3] = arguments[_key3];
}
onBlur === null || onBlur === void 0 ? void 0 : onBlur.apply(void 0, args);
};
_this.getTreeNodeRequiredProps = function () {
var _this$state8 = _this.state,
expandedKeys = _this$state8.expandedKeys,
selectedKeys = _this$state8.selectedKeys,
loadedKeys = _this$state8.loadedKeys,
loadingKeys = _this$state8.loadingKeys,
checkedKeys = _this$state8.checkedKeys,
halfCheckedKeys = _this$state8.halfCheckedKeys,
dragOverNodeKey = _this$state8.dragOverNodeKey,
dropPosition = _this$state8.dropPosition,
keyEntities = _this$state8.keyEntities;
return {
expandedKeys: expandedKeys || [],
selectedKeys: selectedKeys || [],
loadedKeys: loadedKeys || [],
loadingKeys: loadingKeys || [],
checkedKeys: checkedKeys || [],
halfCheckedKeys: halfCheckedKeys || [],
dragOverNodeKey: dragOverNodeKey,
dropPosition: dropPosition,
keyEntities: keyEntities
};
};
// =========================== Expanded ===========================
/** Set uncontrolled `expandedKeys`. This will also auto update `flattenNodes`. */
_this.setExpandedKeys = function (expandedKeys) {
var _this$state9 = _this.state,
treeData = _this$state9.treeData,
fieldNames = _this$state9.fieldNames;
var flattenNodes = (0,treeUtil/* flattenTreeData */.oH)(treeData, expandedKeys, fieldNames);
_this.setUncontrolledState({
expandedKeys: expandedKeys,
flattenNodes: flattenNodes
}, true);
};
_this.onNodeExpand = function (e, treeNode) {
var expandedKeys = _this.state.expandedKeys;
var _this$state10 = _this.state,
listChanging = _this$state10.listChanging,
fieldNames = _this$state10.fieldNames;
var _this$props8 = _this.props,
onExpand = _this$props8.onExpand,
loadData = _this$props8.loadData;
var expanded = treeNode.expanded;
var key = treeNode[fieldNames.key];
// Do nothing when motion is in progress
if (listChanging) {
return;
}
// Update selected keys
var index = expandedKeys.indexOf(key);
var targetExpanded = !expanded;
(0,es_warning/* default */.ZP)(expanded && index !== -1 || !expanded && index === -1, 'Expand state not sync with index check');
if (targetExpanded) {
expandedKeys = (0,util/* arrAdd */.L0)(expandedKeys, key);
} else {
expandedKeys = (0,util/* arrDel */._5)(expandedKeys, key);
}
_this.setExpandedKeys(expandedKeys);
onExpand === null || onExpand === void 0 ? void 0 : onExpand(expandedKeys, {
node: treeNode,
expanded: targetExpanded,
nativeEvent: e.nativeEvent
});
// Async Load data
if (targetExpanded && loadData) {
var loadPromise = _this.onNodeLoad(treeNode);
if (loadPromise) {
loadPromise.then(function () {
// [Legacy] Refresh logic
var newFlattenTreeData = (0,treeUtil/* flattenTreeData */.oH)(_this.state.treeData, expandedKeys, fieldNames);
_this.setUncontrolledState({
flattenNodes: newFlattenTreeData
});
}).catch(function () {
var currentExpandedKeys = _this.state.expandedKeys;
var expandedKeysToRestore = (0,util/* arrDel */._5)(currentExpandedKeys, key);
_this.setExpandedKeys(expandedKeysToRestore);
});
}
}
};
_this.onListChangeStart = function () {
_this.setUncontrolledState({
listChanging: true
});
};
_this.onListChangeEnd = function () {
setTimeout(function () {
_this.setUncontrolledState({
listChanging: false
});
});
};
// =========================== Keyboard ===========================
_this.onActiveChange = function (newActiveKey) {
var activeKey = _this.state.activeKey;
var onActiveChange = _this.props.onActiveChange;
if (activeKey === newActiveKey) {
return;
}
_this.setState({
activeKey: newActiveKey
});
if (newActiveKey !== null) {
_this.scrollTo({
key: newActiveKey
});
}
onActiveChange === null || onActiveChange === void 0 ? void 0 : onActiveChange(newActiveKey);
};
_this.getActiveItem = function () {
var _this$state11 = _this.state,
activeKey = _this$state11.activeKey,
flattenNodes = _this$state11.flattenNodes;
if (activeKey === null) {
return null;
}
return flattenNodes.find(function (_ref2) {
var key = _ref2.key;
return key === activeKey;
}) || null;
};
_this.offsetActiveKey = function (offset) {
var _this$state12 = _this.state,
flattenNodes = _this$state12.flattenNodes,
activeKey = _this$state12.activeKey;
var index = flattenNodes.findIndex(function (_ref3) {
var key = _ref3.key;
return key === activeKey;
});
// Align with index
if (index === -1 && offset < 0) {
index = flattenNodes.length;
}
index = (index + offset + flattenNodes.length) % flattenNodes.length;
var item = flattenNodes[index];
if (item) {
var key = item.key;
_this.onActiveChange(key);
} else {
_this.onActiveChange(null);
}
};
_this.onKeyDown = function (event) {
var _this$state13 = _this.state,
activeKey = _this$state13.activeKey,
expandedKeys = _this$state13.expandedKeys,
checkedKeys = _this$state13.checkedKeys,
fieldNames = _this$state13.fieldNames;
var _this$props9 = _this.props,
onKeyDown = _this$props9.onKeyDown,
checkable = _this$props9.checkable,
selectable = _this$props9.selectable;
// >>>>>>>>>> Direction
switch (event.which) {
case KeyCode/* default.UP */.Z.UP:
{
_this.offsetActiveKey(-1);
event.preventDefault();
break;
}
case KeyCode/* default.DOWN */.Z.DOWN:
{
_this.offsetActiveKey(1);
event.preventDefault();
break;
}
}
// >>>>>>>>>> Expand & Selection
var activeItem = _this.getActiveItem();
if (activeItem && activeItem.data) {
var treeNodeRequiredProps = _this.getTreeNodeRequiredProps();
var expandable = activeItem.data.isLeaf === false || !!(activeItem.data[fieldNames.children] || []).length;
var eventNode = (0,treeUtil/* convertNodePropsToEventData */.F)((0,objectSpread2/* default */.Z)((0,objectSpread2/* default */.Z)({}, (0,treeUtil/* getTreeNodeProps */.H8)(activeKey, treeNodeRequiredProps)), {}, {
data: activeItem.data,
active: true
}));
switch (event.which) {
// >>> Expand
case KeyCode/* default.LEFT */.Z.LEFT:
{
// Collapse if possible
if (expandable && expandedKeys.includes(activeKey)) {
_this.onNodeExpand({}, eventNode);
} else if (activeItem.parent) {
_this.onActiveChange(activeItem.parent.key);
}
event.preventDefault();
break;
}
case KeyCode/* default.RIGHT */.Z.RIGHT:
{
// Expand if possible
if (expandable && !expandedKeys.includes(activeKey)) {
_this.onNodeExpand({}, eventNode);
} else if (activeItem.children && activeItem.children.length) {
_this.onActiveChange(activeItem.children[0].key);
}
event.preventDefault();
break;
}
// Selection
case KeyCode/* default.ENTER */.Z.ENTER:
case KeyCode/* default.SPACE */.Z.SPACE:
{
if (checkable && !eventNode.disabled && eventNode.checkable !== false && !eventNode.disableCheckbox) {
_this.onNodeCheck({}, eventNode, !checkedKeys.includes(activeKey));
} else if (!checkable && selectable && !eventNode.disabled && eventNode.selectable !== false) {
_this.onNodeSelect({}, eventNode);
}
break;
}
}
}
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
};
/**
* Only update the value which is not in props
*/
_this.setUncontrolledState = function (state) {
var atomic = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var forceState = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
if (!_this.destroyed) {
var needSync = false;
var allPassed = true;
var newState = {};
Object.keys(state).forEach(function (name) {
if (name in _this.props) {
allPassed = false;
return;
}
needSync = true;
newState[name] = state[name];
});
if (needSync && (!atomic || allPassed)) {
_this.setState((0,objectSpread2/* default */.Z)((0,objectSpread2/* default */.Z)({}, newState), forceState));
}
}
};
_this.scrollTo = function (scroll) {
_this.listRef.current.scrollTo(scroll);
};
return _this;
}
(0,createClass/* default */.Z)(Tree, [{
key: "componentDidMount",
value: function componentDidMount() {
this.destroyed = false;
this.onUpdated();
}
}, {
key: "componentDidUpdate",
value: function componentDidUpdate() {
this.onUpdated();
}
}, {
key: "onUpdated",
value: function onUpdated() {
var activeKey = this.props.activeKey;
if (activeKey !== undefined && activeKey !== this.state.activeKey) {
this.setState({
activeKey: activeKey
});
if (activeKey !== null) {
this.scrollTo({
key: activeKey
});
}
}
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
window.removeEventListener('dragend', this.onWindowDragEnd);
this.destroyed = true;
}
}, {
key: "resetDragState",
value: function resetDragState() {
this.setState({
dragOverNodeKey: null,
dropPosition: null,
dropLevelOffset: null,
dropTargetKey: null,
dropContainerKey: null,
dropTargetPos: null,
dropAllowed: false
});
}
}, {
key: "render",
value: function render() {
var _classNames;
var _this$state14 = this.state,
focused = _this$state14.focused,
flattenNodes = _this$state14.flattenNodes,
keyEntities = _this$state14.keyEntities,
draggingNodeKey = _this$state14.draggingNodeKey,
activeKey = _this$state14.activeKey,
dropLevelOffset = _this$state14.dropLevelOffset,
dropContainerKey = _this$state14.dropContainerKey,
dropTargetKey = _this$state14.dropTargetKey,
dropPosition = _this$state14.dropPosition,
dragOverNodeKey = _this$state14.dragOverNodeKey,
indent = _this$state14.indent;
var _this$props10 = this.props,
prefixCls = _this$props10.prefixCls,
className = _this$props10.className,
style = _this$props10.style,
showLine = _this$props10.showLine,
focusable = _this$props10.focusable,
_this$props10$tabInde = _this$props10.tabIndex,
tabIndex = _this$props10$tabInde === void 0 ? 0 : _this$props10$tabInde,
selectable = _this$props10.selectable,
showIcon = _this$props10.showIcon,
icon = _this$props10.icon,
switcherIcon = _this$props10.switcherIcon,
draggable = _this$props10.draggable,
checkable = _this$props10.checkable,
checkStrictly = _this$props10.checkStrictly,
disabled = _this$props10.disabled,
motion = _this$props10.motion,
loadData = _this$props10.loadData,
filterTreeNode = _this$props10.filterTreeNode,
height = _this$props10.height,
itemHeight = _this$props10.itemHeight,
virtual = _this$props10.virtual,
titleRender = _this$props10.titleRender,
dropIndicatorRender = _this$props10.dropIndicatorRender,
onContextMenu = _this$props10.onContextMenu,
onScroll = _this$props10.onScroll,
direction = _this$props10.direction,
rootClassName = _this$props10.rootClassName,
rootStyle = _this$props10.rootStyle;
var domProps = (0,pickAttrs/* default */.Z)(this.props, {
aria: true,
data: true
});
// It's better move to hooks but we just simply keep here
var draggableConfig;
if (draggable) {
if ((0,esm_typeof/* default */.Z)(draggable) === 'object') {
draggableConfig = draggable;
} else if (typeof draggable === 'function') {
draggableConfig = {
nodeDraggable: draggable
};
} else {
draggableConfig = {};
}
}
return /*#__PURE__*/react.createElement(contextTypes/* TreeContext.Provider */.k.Provider, {
value: {
prefixCls: prefixCls,
selectable: selectable,
showIcon: showIcon,
icon: icon,
switcherIcon: switcherIcon,
draggable: draggableConfig,
draggingNodeKey: draggingNodeKey,
checkable: checkable,
checkStrictly: checkStrictly,
disabled: disabled,
keyEntities: keyEntities,
dropLevelOffset: dropLevelOffset,
dropContainerKey: dropContainerKey,
dropTargetKey: dropTargetKey,
dropPosition: dropPosition,
dragOverNodeKey: dragOverNodeKey,
indent: indent,
direction: direction,
dropIndicatorRender: dropIndicatorRender,
loadData: loadData,
filterTreeNode: filterTreeNode,
titleRender: titleRender,
onNodeClick: this.onNodeClick,
onNodeDoubleClick: this.onNodeDoubleClick,
onNodeExpand: this.onNodeExpand,
onNodeSelect: this.onNodeSelect,
onNodeCheck: this.onNodeCheck,
onNodeLoad: this.onNodeLoad,
onNodeMouseEnter: this.onNodeMouseEnter,
onNodeMouseLeave: this.onNodeMouseLeave,
onNodeContextMenu: this.onNodeContextMenu,
onNodeDragStart: this.onNodeDragStart,
onNodeDragEnter: this.onNodeDragEnter,
onNodeDragOver: this.onNodeDragOver,
onNodeDragLeave: this.onNodeDragLeave,
onNodeDragEnd: this.onNodeDragEnd,
onNodeDrop: this.onNodeDrop
}
}, /*#__PURE__*/react.createElement("div", {
role: "tree",
className: classnames_default()(prefixCls, className, rootClassName, (_classNames = {}, (0,defineProperty/* default */.Z)(_classNames, "".concat(prefixCls, "-show-line"), showLine), (0,defineProperty/* default */.Z)(_classNames, "".concat(prefixCls, "-focused"), focused), (0,defineProperty/* default */.Z)(_classNames, "".concat(prefixCls, "-active-focused"), activeKey !== null), _classNames)),
style: rootStyle
}, /*#__PURE__*/react.createElement(es_NodeList, (0,esm_extends/* default */.Z)({
ref: this.listRef,
prefixCls: prefixCls,
style: style,
data: flattenNodes,
disabled: disabled,
selectable: selectable,
checkable: !!checkable,
motion: motion,
dragging: draggingNodeKey !== null,
height: height,
itemHeight: itemHeight,
virtual: virtual,
focusable: focusable,
focused: focused,
tabIndex: tabIndex,
activeItem: this.getActiveItem(),
onFocus: this.onFocus,
onBlur: this.onBlur,
onKeyDown: this.onKeyDown,
onActiveChange: this.onActiveChange,
onListChangeStart: this.onListChangeStart,
onListChangeEnd: this.onListChangeEnd,
onContextMenu: onContextMenu,
onScroll: onScroll
}, this.getTreeNodeRequiredProps(), domProps))));
}
}], [{
key: "getDerivedStateFromProps",
value: function getDerivedStateFromProps(props, prevState) {
var prevProps = prevState.prevProps;
var newState = {
prevProps: props
};
function needSync(name) {
return !prevProps && name in props || prevProps && prevProps[name] !== props[name];
}
// ================== Tree Node ==================
var treeData;
// fieldNames
var fieldNames = prevState.fieldNames;
if (needSync('fieldNames')) {
fieldNames = (0,treeUtil/* fillFieldNames */.w$)(props.fieldNames);
newState.fieldNames = fieldNames;
}
// Check if `treeData` or `children` changed and save into the state.
if (needSync('treeData')) {
treeData = props.treeData;
} else if (needSync('children')) {
(0,es_warning/* default */.ZP)(false, '`children` of Tree is deprecated. Please use `treeData` instead.');
treeData = (0,treeUtil/* convertTreeToData */.zn)(props.children);
}
// Save flatten nodes info and convert `treeData` into keyEntities
if (treeData) {
newState.treeData = treeData;
var entitiesMap = (0,treeUtil/* convertDataToEntities */.I8)(treeData, {
fieldNames: fieldNames
});
newState.keyEntities = (0,objectSpread2/* default */.Z)((0,defineProperty/* default */.Z)({}, MOTION_KEY, MotionEntity), entitiesMap.keyEntities);
// Warning if treeNode not provide key
if (false) {}
}
var keyEntities = newState.keyEntities || prevState.keyEntities;
// ================ expandedKeys =================
if (needSync('expandedKeys') || prevProps && needSync('autoExpandParent')) {
newState.expandedKeys = props.autoExpandParent || !prevProps && props.defaultExpandParent ? (0,util/* conductExpandParent */.r7)(props.expandedKeys, keyEntities) : props.expandedKeys;
} else if (!prevProps && props.defaultExpandAll) {
var cloneKeyEntities = (0,objectSpread2/* default */.Z)({}, keyEntities);
delete cloneKeyEntities[MOTION_KEY];
newState.expandedKeys = Object.keys(cloneKeyEntities).map(function (key) {
return cloneKeyEntities[key].key;
});
} else if (!prevProps && props.defaultExpandedKeys) {
newState.expandedKeys = props.autoExpandParent || props.defaultExpandParent ? (0,util/* conductExpandParent */.r7)(props.defaultExpandedKeys, keyEntities) : props.defaultExpandedKeys;
}
if (!newState.expandedKeys) {
delete newState.expandedKeys;
}
// ================ flattenNodes =================
if (treeData || newState.expandedKeys) {
var flattenNodes = (0,treeUtil/* flattenTreeData */.oH)(treeData || prevState.treeData, newState.expandedKeys || prevState.expandedKeys, fieldNames);
newState.flattenNodes = flattenNodes;
}
// ================ selectedKeys =================
if (props.selectable) {
if (needSync('selectedKeys')) {
newState.selectedKeys = (0,util/* calcSelectedKeys */.BT)(props.selectedKeys, props);
} else if (!prevProps && props.defaultSelectedKeys) {
newState.selectedKeys = (0,util/* calcSelectedKeys */.BT)(props.defaultSelectedKeys, props);
}
}
// ================= checkedKeys =================
if (props.checkable) {
var checkedKeyEntity;
if (needSync('checkedKeys')) {
checkedKeyEntity = (0,util/* parseCheckedKeys */.E6)(props.checkedKeys) || {};
} else if (!prevProps && props.defaultCheckedKeys) {
checkedKeyEntity = (0,util/* parseCheckedKeys */.E6)(props.defaultCheckedKeys) || {};
} else if (treeData) {
// If `treeData` changed, we also need check it
checkedKeyEntity = (0,util/* parseCheckedKeys */.E6)(props.checkedKeys) || {
checkedKeys: prevState.checkedKeys,
halfCheckedKeys: prevState.halfCheckedKeys
};
}
if (checkedKeyEntity) {
var _checkedKeyEntity = checkedKeyEntity,
_checkedKeyEntity$che = _checkedKeyEntity.checkedKeys,
checkedKeys = _checkedKeyEntity$che === void 0 ? [] : _checkedKeyEntity$che,
_checkedKeyEntity$hal = _checkedKeyEntity.halfCheckedKeys,
halfCheckedKeys = _checkedKeyEntity$hal === void 0 ? [] : _checkedKeyEntity$hal;
if (!props.checkStrictly) {
var conductKeys = (0,conductUtil/* conductCheck */.S)(checkedKeys, true, keyEntities);
checkedKeys = conductKeys.checkedKeys;
halfCheckedKeys = conductKeys.halfCheckedKeys;
}
newState.checkedKeys = checkedKeys;
newState.halfCheckedKeys = halfCheckedKeys;
}
}
// ================= loadedKeys ==================
if (needSync('loadedKeys')) {
newState.loadedKeys = props.loadedKeys;
}
return newState;
}
}]);
return Tree;
}(react.Component);
Tree.defaultProps = {
prefixCls: 'rc-tree',
showLine: false,
showIcon: true,
selectable: true,
multiple: false,
checkable: false,
disabled: false,
checkStrictly: false,
draggable: false,
defaultExpandParent: true,
autoExpandParent: false,
defaultExpandAll: false,
defaultExpandedKeys: [],
defaultCheckedKeys: [],
defaultSelectedKeys: [],
dropIndicatorRender: DropIndicator,
allowDrop: function allowDrop() {
return true;
},
expandAction: false
};
Tree.TreeNode = TreeNode/* default */.Z;
/* harmony default export */ var es_Tree = (Tree);
;// CONCATENATED MODULE: ./node_modules/rc-tree/es/index.js
/* harmony default export */ var rc_tree_es = (es_Tree);
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/es/LegacyContext.js
var LegacySelectContext = /*#__PURE__*/react.createContext(null);
/* harmony default export */ var LegacyContext = (LegacySelectContext);
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/es/TreeSelectContext.js
var TreeSelectContext = /*#__PURE__*/react.createContext(null);
/* harmony default export */ var es_TreeSelectContext = (TreeSelectContext);
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/es/utils/valueUtil.js
function valueUtil_toArray(value) {
if (Array.isArray(value)) {
return value;
}
return value !== undefined ? [value] : [];
}
function valueUtil_fillFieldNames(fieldNames) {
var _ref = fieldNames || {},
label = _ref.label,
value = _ref.value,
children = _ref.children;
var mergedValue = value || 'value';
return {
_title: label ? [label] : ['title', 'label'],
value: mergedValue,
key: mergedValue,
children: children || 'children'
};
}
function isCheckDisabled(node) {
return !node || node.disabled || node.disableCheckbox || node.checkable === false;
}
/** Loop fetch all the keys exist in the tree */
function getAllKeys(treeData, fieldNames) {
var keys = [];
function dig(list) {
list.forEach(function (item) {
var children = item[fieldNames.children];
if (children) {
keys.push(item[fieldNames.value]);
dig(children);
}
});
}
dig(treeData);
return keys;
}
function isNil(val) {
return val === null || val === undefined;
}
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/es/OptionList.js
var OptionList_HIDDEN_STYLE = {
width: 0,
height: 0,
display: 'flex',
overflow: 'hidden',
opacity: 0,
border: 0,
padding: 0,
margin: 0
};
var OptionList_OptionList = function OptionList(_, ref) {
var _useBaseProps = useBaseProps(),
prefixCls = _useBaseProps.prefixCls,
multiple = _useBaseProps.multiple,
searchValue = _useBaseProps.searchValue,
toggleOpen = _useBaseProps.toggleOpen,
open = _useBaseProps.open,
notFoundContent = _useBaseProps.notFoundContent;
var _React$useContext = react.useContext(es_TreeSelectContext),
virtual = _React$useContext.virtual,
listHeight = _React$useContext.listHeight,
listItemHeight = _React$useContext.listItemHeight,
treeData = _React$useContext.treeData,
fieldNames = _React$useContext.fieldNames,
onSelect = _React$useContext.onSelect,
dropdownMatchSelectWidth = _React$useContext.dropdownMatchSelectWidth,
treeExpandAction = _React$useContext.treeExpandAction;
var _React$useContext2 = react.useContext(LegacyContext),
checkable = _React$useContext2.checkable,
checkedKeys = _React$useContext2.checkedKeys,
halfCheckedKeys = _React$useContext2.halfCheckedKeys,
treeExpandedKeys = _React$useContext2.treeExpandedKeys,
treeDefaultExpandAll = _React$useContext2.treeDefaultExpandAll,
treeDefaultExpandedKeys = _React$useContext2.treeDefaultExpandedKeys,
onTreeExpand = _React$useContext2.onTreeExpand,
treeIcon = _React$useContext2.treeIcon,
showTreeIcon = _React$useContext2.showTreeIcon,
switcherIcon = _React$useContext2.switcherIcon,
treeLine = _React$useContext2.treeLine,
treeNodeFilterProp = _React$useContext2.treeNodeFilterProp,
loadData = _React$useContext2.loadData,
treeLoadedKeys = _React$useContext2.treeLoadedKeys,
treeMotion = _React$useContext2.treeMotion,
onTreeLoad = _React$useContext2.onTreeLoad,
keyEntities = _React$useContext2.keyEntities;
var treeRef = react.useRef();
var memoTreeData = (0,useMemo/* default */.Z)(function () {
return treeData;
}, [open, treeData], function (prev, next) {
return next[0] && prev[1] !== next[1];
});
// ========================== Values ==========================
var mergedCheckedKeys = react.useMemo(function () {
if (!checkable) {
return null;
}
return {
checked: checkedKeys,
halfChecked: halfCheckedKeys
};
}, [checkable, checkedKeys, halfCheckedKeys]);
// ========================== Scroll ==========================
react.useEffect(function () {
// Single mode should scroll to current key
if (open && !multiple && checkedKeys.length) {
var _treeRef$current;
(_treeRef$current = treeRef.current) === null || _treeRef$current === void 0 ? void 0 : _treeRef$current.scrollTo({
key: checkedKeys[0]
});
}
}, [open]);
// ========================== Search ==========================
var lowerSearchValue = String(searchValue).toLowerCase();
var filterTreeNode = function filterTreeNode(treeNode) {
if (!lowerSearchValue) {
return false;
}
return String(treeNode[treeNodeFilterProp]).toLowerCase().includes(lowerSearchValue);
};
// =========================== Keys ===========================
var _React$useState = react.useState(treeDefaultExpandedKeys),
_React$useState2 = (0,slicedToArray/* default */.Z)(_React$useState, 2),
expandedKeys = _React$useState2[0],
setExpandedKeys = _React$useState2[1];
var _React$useState3 = react.useState(null),
_React$useState4 = (0,slicedToArray/* default */.Z)(_React$useState3, 2),
searchExpandedKeys = _React$useState4[0],
setSearchExpandedKeys = _React$useState4[1];
var mergedExpandedKeys = react.useMemo(function () {
if (treeExpandedKeys) {
return (0,toConsumableArray/* default */.Z)(treeExpandedKeys);
}
return searchValue ? searchExpandedKeys : expandedKeys;
}, [expandedKeys, searchExpandedKeys, treeExpandedKeys, searchValue]);
react.useEffect(function () {
if (searchValue) {
setSearchExpandedKeys(getAllKeys(treeData, fieldNames));
}
}, [searchValue]);
var onInternalExpand = function onInternalExpand(keys) {
setExpandedKeys(keys);
setSearchExpandedKeys(keys);
if (onTreeExpand) {
onTreeExpand(keys);
}
};
// ========================== Events ==========================
var onListMouseDown = function onListMouseDown(event) {
event.preventDefault();
};
var onInternalSelect = function onInternalSelect(__, info) {
var node = info.node;
if (checkable && isCheckDisabled(node)) {
return;
}
onSelect(node.key, {
selected: !checkedKeys.includes(node.key)
});
if (!multiple) {
toggleOpen(false);
}
};
// ========================= Keyboard =========================
var _React$useState5 = react.useState(null),
_React$useState6 = (0,slicedToArray/* default */.Z)(_React$useState5, 2),
activeKey = _React$useState6[0],
setActiveKey = _React$useState6[1];
var activeEntity = keyEntities[activeKey];
react.useImperativeHandle(ref, function () {
var _treeRef$current2;
return {
scrollTo: (_treeRef$current2 = treeRef.current) === null || _treeRef$current2 === void 0 ? void 0 : _treeRef$current2.scrollTo,
onKeyDown: function onKeyDown(event) {
var _treeRef$current3;
var which = event.which;
switch (which) {
// >>> Arrow keys
case KeyCode/* default.UP */.Z.UP:
case KeyCode/* default.DOWN */.Z.DOWN:
case KeyCode/* default.LEFT */.Z.LEFT:
case KeyCode/* default.RIGHT */.Z.RIGHT:
(_treeRef$current3 = treeRef.current) === null || _treeRef$current3 === void 0 ? void 0 : _treeRef$current3.onKeyDown(event);
break;
// >>> Select item
case KeyCode/* default.ENTER */.Z.ENTER:
{
if (activeEntity) {
var _ref = (activeEntity === null || activeEntity === void 0 ? void 0 : activeEntity.node) || {},
selectable = _ref.selectable,
value = _ref.value;
if (selectable !== false) {
onInternalSelect(null, {
node: {
key: activeKey
},
selected: !checkedKeys.includes(value)
});
}
}
break;
}
// >>> Close
case KeyCode/* default.ESC */.Z.ESC:
{
toggleOpen(false);
}
}
},
onKeyUp: function onKeyUp() {}
};
});
// ========================== Render ==========================
if (memoTreeData.length === 0) {
return /*#__PURE__*/react.createElement("div", {
role: "listbox",
className: "".concat(prefixCls, "-empty"),
onMouseDown: onListMouseDown
}, notFoundContent);
}
var treeProps = {
fieldNames: fieldNames
};
if (treeLoadedKeys) {
treeProps.loadedKeys = treeLoadedKeys;
}
if (mergedExpandedKeys) {
treeProps.expandedKeys = mergedExpandedKeys;
}
return /*#__PURE__*/react.createElement("div", {
onMouseDown: onListMouseDown
}, activeEntity && open && /*#__PURE__*/react.createElement("span", {
style: OptionList_HIDDEN_STYLE,
"aria-live": "assertive"
}, activeEntity.node.value), /*#__PURE__*/react.createElement(rc_tree_es, (0,esm_extends/* default */.Z)({
ref: treeRef,
focusable: false,
prefixCls: "".concat(prefixCls, "-tree"),
treeData: memoTreeData,
height: listHeight,
itemHeight: listItemHeight,
virtual: virtual !== false && dropdownMatchSelectWidth !== false,
multiple: multiple,
icon: treeIcon,
showIcon: showTreeIcon,
switcherIcon: switcherIcon,
showLine: treeLine,
loadData: searchValue ? null : loadData,
motion: treeMotion,
activeKey: activeKey
// We handle keys by out instead tree self
,
checkable: checkable,
checkStrictly: true,
checkedKeys: mergedCheckedKeys,
selectedKeys: !checkable ? checkedKeys : [],
defaultExpandAll: treeDefaultExpandAll
}, treeProps, {
// Proxy event out
onActiveChange: setActiveKey,
onSelect: onInternalSelect,
onCheck: onInternalSelect,
onExpand: onInternalExpand,
onLoad: onTreeLoad,
filterTreeNode: filterTreeNode,
expandAction: treeExpandAction
})));
};
var OptionList_RefOptionList = /*#__PURE__*/react.forwardRef(OptionList_OptionList);
OptionList_RefOptionList.displayName = 'OptionList';
/* harmony default export */ var rc_tree_select_es_OptionList = (OptionList_RefOptionList);
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/es/TreeNode.js
/* istanbul ignore file */
/** This is a placeholder, not real render in dom */
var TreeNode_TreeNode = function TreeNode() {
return null;
};
/* harmony default export */ var es_TreeNode = (TreeNode_TreeNode);
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/es/utils/strategyUtil.js
var SHOW_ALL = 'SHOW_ALL';
var SHOW_PARENT = 'SHOW_PARENT';
var SHOW_CHILD = 'SHOW_CHILD';
function formatStrategyValues(values, strategy, keyEntities, fieldNames) {
var valueSet = new Set(values);
if (strategy === SHOW_CHILD) {
return values.filter(function (key) {
var entity = keyEntities[key];
if (entity && entity.children && entity.children.some(function (_ref) {
var node = _ref.node;
return valueSet.has(node[fieldNames.value]);
}) && entity.children.every(function (_ref2) {
var node = _ref2.node;
return isCheckDisabled(node) || valueSet.has(node[fieldNames.value]);
})) {
return false;
}
return true;
});
}
if (strategy === SHOW_PARENT) {
return values.filter(function (key) {
var entity = keyEntities[key];
var parent = entity ? entity.parent : null;
if (parent && !isCheckDisabled(parent.node) && valueSet.has(parent.key)) {
return false;
}
return true;
});
}
return values;
}
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/es/utils/legacyUtil.js
var utils_legacyUtil_excluded = ["children", "value"];
function utils_legacyUtil_convertChildrenToData(nodes) {
return (0,Children_toArray/* default */.Z)(nodes).map(function (node) {
if (! /*#__PURE__*/react.isValidElement(node) || !node.type) {
return null;
}
var _ref = node,
key = _ref.key,
_ref$props = _ref.props,
children = _ref$props.children,
value = _ref$props.value,
restProps = (0,objectWithoutProperties/* default */.Z)(_ref$props, utils_legacyUtil_excluded);
var data = (0,objectSpread2/* default */.Z)({
key: key,
value: value
}, restProps);
var childData = utils_legacyUtil_convertChildrenToData(children);
if (childData.length) {
data.children = childData;
}
return data;
}).filter(function (data) {
return data;
});
}
function fillLegacyProps(dataNode) {
if (!dataNode) {
return dataNode;
}
var cloneNode = (0,objectSpread2/* default */.Z)({}, dataNode);
if (!('props' in cloneNode)) {
Object.defineProperty(cloneNode, 'props', {
get: function get() {
(0,es_warning/* default */.ZP)(false, 'New `rc-tree-select` not support return node instance as argument anymore. Please consider to remove `props` access.');
return cloneNode;
}
});
}
return cloneNode;
}
function fillAdditionalInfo(extra, triggerValue, checkedValues, treeData, showPosition, fieldNames) {
var triggerNode = null;
var nodeList = null;
function generateMap() {
function dig(list) {
var level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '0';
var parentIncluded = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
return list.map(function (option, index) {
var pos = "".concat(level, "-").concat(index);
var value = option[fieldNames.value];
var included = checkedValues.includes(value);
var children = dig(option[fieldNames.children] || [], pos, included);
var node = /*#__PURE__*/react.createElement(es_TreeNode, option, children.map(function (child) {
return child.node;
}));
// Link with trigger node
if (triggerValue === value) {
triggerNode = node;
}
if (included) {
var checkedNode = {
pos: pos,
node: node,
children: children
};
if (!parentIncluded) {
nodeList.push(checkedNode);
}
return checkedNode;
}
return null;
}).filter(function (node) {
return node;
});
}
if (!nodeList) {
nodeList = [];
dig(treeData);
// Sort to keep the checked node length
nodeList.sort(function (_ref2, _ref3) {
var val1 = _ref2.node.props.value;
var val2 = _ref3.node.props.value;
var index1 = checkedValues.indexOf(val1);
var index2 = checkedValues.indexOf(val2);
return index1 - index2;
});
}
}
Object.defineProperty(extra, 'triggerNode', {
get: function get() {
(0,es_warning/* default */.ZP)(false, '`triggerNode` is deprecated. Please consider decoupling data with node.');
generateMap();
return triggerNode;
}
});
Object.defineProperty(extra, 'allCheckedNodes', {
get: function get() {
(0,es_warning/* default */.ZP)(false, '`allCheckedNodes` is deprecated. Please consider decoupling data with node.');
generateMap();
if (showPosition) {
return nodeList;
}
return nodeList.map(function (_ref4) {
var node = _ref4.node;
return node;
});
}
});
}
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/es/hooks/useTreeData.js
function parseSimpleTreeData(treeData, _ref) {
var id = _ref.id,
pId = _ref.pId,
rootPId = _ref.rootPId;
var keyNodes = {};
var rootNodeList = [];
// Fill in the map
var nodeList = treeData.map(function (node) {
var clone = (0,objectSpread2/* default */.Z)({}, node);
var key = clone[id];
keyNodes[key] = clone;
clone.key = clone.key || key;
return clone;
});
// Connect tree
nodeList.forEach(function (node) {
var parentKey = node[pId];
var parent = keyNodes[parentKey];
// Fill parent
if (parent) {
parent.children = parent.children || [];
parent.children.push(node);
}
// Fill root tree node
if (parentKey === rootPId || !parent && rootPId === null) {
rootNodeList.push(node);
}
});
return rootNodeList;
}
/**
* Convert `treeData` or `children` into formatted `treeData`.
* Will not re-calculate if `treeData` or `children` not change.
*/
function useTreeData(treeData, children, simpleMode) {
return react.useMemo(function () {
if (treeData) {
return simpleMode ? parseSimpleTreeData(treeData, (0,objectSpread2/* default */.Z)({
id: 'id',
pId: 'pId',
rootPId: null
}, simpleMode !== true ? simpleMode : {})) : treeData;
}
return utils_legacyUtil_convertChildrenToData(children);
}, [children, simpleMode, treeData]);
}
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/es/hooks/useCache.js
/**
* This function will try to call requestIdleCallback if available to save performance.
* No need `getLabel` here since already fetch on `rawLabeledValue`.
*/
/* harmony default export */ var hooks_useCache = (function (values) {
var cacheRef = react.useRef({
valueLabels: new Map()
});
return react.useMemo(function () {
var valueLabels = cacheRef.current.valueLabels;
var valueLabelsCache = new Map();
var filledValues = values.map(function (item) {
var _item$label;
var value = item.value;
var mergedLabel = (_item$label = item.label) !== null && _item$label !== void 0 ? _item$label : valueLabels.get(value);
// Save in cache
valueLabelsCache.set(value, mergedLabel);
return (0,objectSpread2/* default */.Z)((0,objectSpread2/* default */.Z)({}, item), {}, {
label: mergedLabel
});
});
cacheRef.current.valueLabels = valueLabelsCache;
return [filledValues];
}, [values]);
});
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/es/hooks/useRefFunc.js
/**
* Same as `React.useCallback` but always return a memoized function
* but redirect to real function.
*/
function useRefFunc_useRefFunc(callback) {
var funcRef = react.useRef();
funcRef.current = callback;
var cacheFn = react.useCallback(function () {
return funcRef.current.apply(funcRef, arguments);
}, []);
return cacheFn;
}
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/es/hooks/useDataEntities.js
/* harmony default export */ var useDataEntities = (function (treeData, fieldNames) {
return react.useMemo(function () {
var collection = (0,treeUtil/* convertDataToEntities */.I8)(treeData, {
fieldNames: fieldNames,
initWrapper: function initWrapper(wrapper) {
return (0,objectSpread2/* default */.Z)((0,objectSpread2/* default */.Z)({}, wrapper), {}, {
valueEntities: new Map()
});
},
processEntity: function processEntity(entity, wrapper) {
var val = entity.node[fieldNames.value];
// Check if exist same value
if (false) { var key; }
wrapper.valueEntities.set(val, entity);
}
});
return collection;
}, [treeData, fieldNames]);
});
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/es/hooks/useCheckedKeys.js
/* harmony default export */ var useCheckedKeys = (function (rawLabeledValues, rawHalfCheckedValues, treeConduction, keyEntities) {
return react.useMemo(function () {
var checkedKeys = rawLabeledValues.map(function (_ref) {
var value = _ref.value;
return value;
});
var halfCheckedKeys = rawHalfCheckedValues.map(function (_ref2) {
var value = _ref2.value;
return value;
});
var missingValues = checkedKeys.filter(function (key) {
return !keyEntities[key];
});
if (treeConduction) {
var _conductCheck = (0,conductUtil/* conductCheck */.S)(checkedKeys, true, keyEntities);
checkedKeys = _conductCheck.checkedKeys;
halfCheckedKeys = _conductCheck.halfCheckedKeys;
}
return [
// Checked keys should fill with missing keys which should de-duplicated
Array.from(new Set([].concat((0,toConsumableArray/* default */.Z)(missingValues), (0,toConsumableArray/* default */.Z)(checkedKeys)))),
// Half checked keys
halfCheckedKeys];
}, [rawLabeledValues, rawHalfCheckedValues, treeConduction, keyEntities]);
});
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/es/hooks/useFilterTreeData.js
/* harmony default export */ var useFilterTreeData = (function (treeData, searchValue, _ref) {
var treeNodeFilterProp = _ref.treeNodeFilterProp,
filterTreeNode = _ref.filterTreeNode,
fieldNames = _ref.fieldNames;
var fieldChildren = fieldNames.children;
return react.useMemo(function () {
if (!searchValue || filterTreeNode === false) {
return treeData;
}
var filterOptionFunc;
if (typeof filterTreeNode === 'function') {
filterOptionFunc = filterTreeNode;
} else {
var upperStr = searchValue.toUpperCase();
filterOptionFunc = function filterOptionFunc(_, dataNode) {
var value = dataNode[treeNodeFilterProp];
return String(value).toUpperCase().includes(upperStr);
};
}
function dig(list) {
var keepAll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
return list.map(function (dataNode) {
var children = dataNode[fieldChildren];
var match = keepAll || filterOptionFunc(searchValue, fillLegacyProps(dataNode));
var childList = dig(children || [], match);
if (match || childList.length) {
return (0,objectSpread2/* default */.Z)((0,objectSpread2/* default */.Z)({}, dataNode), {}, (0,defineProperty/* default */.Z)({
isLeaf: undefined
}, fieldChildren, childList));
}
return null;
}).filter(function (node) {
return node;
});
}
return dig(treeData);
}, [treeData, searchValue, fieldChildren, treeNodeFilterProp, filterTreeNode]);
});
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/es/utils/warningPropsUtil.js
function warningPropsUtil_warningProps(props) {
var searchPlaceholder = props.searchPlaceholder,
treeCheckStrictly = props.treeCheckStrictly,
treeCheckable = props.treeCheckable,
labelInValue = props.labelInValue,
value = props.value,
multiple = props.multiple;
warning(!searchPlaceholder, '`searchPlaceholder` has been removed.');
if (treeCheckStrictly && labelInValue === false) {
warning(false, '`treeCheckStrictly` will force set `labelInValue` to `true`.');
}
if (labelInValue || treeCheckStrictly) {
warning(toArray(value).every(function (val) {
return val && _typeof(val) === 'object' && 'value' in val;
}), 'Invalid prop `value` supplied to `TreeSelect`. You should use { label: string, value: string | number } or [{ label: string, value: string | number }] instead.');
}
if (treeCheckStrictly || multiple || treeCheckable) {
warning(!value || Array.isArray(value), '`value` should be an array when `TreeSelect` is checkable or multiple.');
} else {
warning(!Array.isArray(value), '`value` should not be array when `TreeSelect` is single mode.');
}
}
/* harmony default export */ var utils_warningPropsUtil = ((/* unused pure expression or super */ null && (warningPropsUtil_warningProps)));
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/es/TreeSelect.js
var TreeSelect_excluded = ["id", "prefixCls", "value", "defaultValue", "onChange", "onSelect", "onDeselect", "searchValue", "inputValue", "onSearch", "autoClearSearchValue", "filterTreeNode", "treeNodeFilterProp", "showCheckedStrategy", "treeNodeLabelProp", "multiple", "treeCheckable", "treeCheckStrictly", "labelInValue", "fieldNames", "treeDataSimpleMode", "treeData", "children", "loadData", "treeLoadedKeys", "onTreeLoad", "treeDefaultExpandAll", "treeExpandedKeys", "treeDefaultExpandedKeys", "onTreeExpand", "treeExpandAction", "virtual", "listHeight", "listItemHeight", "onDropdownVisibleChange", "dropdownMatchSelectWidth", "treeLine", "treeIcon", "showTreeIcon", "switcherIcon", "treeMotion"];
function TreeSelect_isRawValue(value) {
return !value || (0,esm_typeof/* default */.Z)(value) !== 'object';
}
var TreeSelect = /*#__PURE__*/react.forwardRef(function (props, ref) {
var id = props.id,
_props$prefixCls = props.prefixCls,
prefixCls = _props$prefixCls === void 0 ? 'rc-tree-select' : _props$prefixCls,
value = props.value,
defaultValue = props.defaultValue,
onChange = props.onChange,
onSelect = props.onSelect,
onDeselect = props.onDeselect,
searchValue = props.searchValue,
inputValue = props.inputValue,
onSearch = props.onSearch,
_props$autoClearSearc = props.autoClearSearchValue,
autoClearSearchValue = _props$autoClearSearc === void 0 ? true : _props$autoClearSearc,
filterTreeNode = props.filterTreeNode,
_props$treeNodeFilter = props.treeNodeFilterProp,
treeNodeFilterProp = _props$treeNodeFilter === void 0 ? 'value' : _props$treeNodeFilter,
_props$showCheckedStr = props.showCheckedStrategy,
showCheckedStrategy = _props$showCheckedStr === void 0 ? SHOW_CHILD : _props$showCheckedStr,
treeNodeLabelProp = props.treeNodeLabelProp,
multiple = props.multiple,
treeCheckable = props.treeCheckable,
treeCheckStrictly = props.treeCheckStrictly,
labelInValue = props.labelInValue,
fieldNames = props.fieldNames,
treeDataSimpleMode = props.treeDataSimpleMode,
treeData = props.treeData,
children = props.children,
loadData = props.loadData,
treeLoadedKeys = props.treeLoadedKeys,
onTreeLoad = props.onTreeLoad,
treeDefaultExpandAll = props.treeDefaultExpandAll,
treeExpandedKeys = props.treeExpandedKeys,
treeDefaultExpandedKeys = props.treeDefaultExpandedKeys,
onTreeExpand = props.onTreeExpand,
treeExpandAction = props.treeExpandAction,
virtual = props.virtual,
_props$listHeight = props.listHeight,
listHeight = _props$listHeight === void 0 ? 200 : _props$listHeight,
_props$listItemHeight = props.listItemHeight,
listItemHeight = _props$listItemHeight === void 0 ? 20 : _props$listItemHeight,
onDropdownVisibleChange = props.onDropdownVisibleChange,
_props$dropdownMatchS = props.dropdownMatchSelectWidth,
dropdownMatchSelectWidth = _props$dropdownMatchS === void 0 ? true : _props$dropdownMatchS,
treeLine = props.treeLine,
treeIcon = props.treeIcon,
showTreeIcon = props.showTreeIcon,
switcherIcon = props.switcherIcon,
treeMotion = props.treeMotion,
restProps = (0,objectWithoutProperties/* default */.Z)(props, TreeSelect_excluded);
var mergedId = useId(id);
var treeConduction = treeCheckable && !treeCheckStrictly;
var mergedCheckable = treeCheckable || treeCheckStrictly;
var mergedLabelInValue = treeCheckStrictly || labelInValue;
var mergedMultiple = mergedCheckable || multiple;
var _useMergedState = (0,useMergedState/* default */.Z)(defaultValue, {
value: value
}),
_useMergedState2 = (0,slicedToArray/* default */.Z)(_useMergedState, 2),
internalValue = _useMergedState2[0],
setInternalValue = _useMergedState2[1];
// ========================== Warning ===========================
if (false) {}
// ========================= FieldNames =========================
var mergedFieldNames = react.useMemo(function () {
return valueUtil_fillFieldNames(fieldNames);
}, /* eslint-disable react-hooks/exhaustive-deps */
[JSON.stringify(fieldNames)]
/* eslint-enable react-hooks/exhaustive-deps */);
// =========================== Search ===========================
var _useMergedState3 = (0,useMergedState/* default */.Z)('', {
value: searchValue !== undefined ? searchValue : inputValue,
postState: function postState(search) {
return search || '';
}
}),
_useMergedState4 = (0,slicedToArray/* default */.Z)(_useMergedState3, 2),
mergedSearchValue = _useMergedState4[0],
setSearchValue = _useMergedState4[1];
var onInternalSearch = function onInternalSearch(searchText) {
setSearchValue(searchText);
onSearch === null || onSearch === void 0 ? void 0 : onSearch(searchText);
};
// ============================ Data ============================
// `useTreeData` only do convert of `children` or `simpleMode`.
// Else will return origin `treeData` for perf consideration.
// Do not do anything to loop the data.
var mergedTreeData = useTreeData(treeData, children, treeDataSimpleMode);
var _useDataEntities = useDataEntities(mergedTreeData, mergedFieldNames),
keyEntities = _useDataEntities.keyEntities,
valueEntities = _useDataEntities.valueEntities;
/** Get `missingRawValues` which not exist in the tree yet */
var splitRawValues = react.useCallback(function (newRawValues) {
var missingRawValues = [];
var existRawValues = [];
// Keep missing value in the cache
newRawValues.forEach(function (val) {
if (valueEntities.has(val)) {
existRawValues.push(val);
} else {
missingRawValues.push(val);
}
});
return {
missingRawValues: missingRawValues,
existRawValues: existRawValues
};
}, [valueEntities]);
// Filtered Tree
var filteredTreeData = useFilterTreeData(mergedTreeData, mergedSearchValue, {
fieldNames: mergedFieldNames,
treeNodeFilterProp: treeNodeFilterProp,
filterTreeNode: filterTreeNode
});
// =========================== Label ============================
var getLabel = react.useCallback(function (item) {
if (item) {
if (treeNodeLabelProp) {
return item[treeNodeLabelProp];
}
// Loop from fieldNames
var titleList = mergedFieldNames._title;
for (var i = 0; i < titleList.length; i += 1) {
var title = item[titleList[i]];
if (title !== undefined) {
return title;
}
}
}
}, [mergedFieldNames, treeNodeLabelProp]);
// ========================= Wrap Value =========================
var toLabeledValues = react.useCallback(function (draftValues) {
var values = valueUtil_toArray(draftValues);
return values.map(function (val) {
if (TreeSelect_isRawValue(val)) {
return {
value: val
};
}
return val;
});
}, []);
var convert2LabelValues = react.useCallback(function (draftValues) {
var values = toLabeledValues(draftValues);
return values.map(function (item) {
var rawLabel = item.label;
var rawValue = item.value,
rawHalfChecked = item.halfChecked;
var rawDisabled;
var entity = valueEntities.get(rawValue);
// Fill missing label & status
if (entity) {
var _rawLabel;
rawLabel = (_rawLabel = rawLabel) !== null && _rawLabel !== void 0 ? _rawLabel : getLabel(entity.node);
rawDisabled = entity.node.disabled;
} else if (rawLabel === undefined) {
// We try to find in current `labelInValue` value
var labelInValueItem = toLabeledValues(internalValue).find(function (labeledItem) {
return labeledItem.value === rawValue;
});
rawLabel = labelInValueItem.label;
}
return {
label: rawLabel,
value: rawValue,
halfChecked: rawHalfChecked,
disabled: rawDisabled
};
});
}, [valueEntities, getLabel, toLabeledValues, internalValue]);
// =========================== Values ===========================
var rawMixedLabeledValues = react.useMemo(function () {
return toLabeledValues(internalValue);
}, [toLabeledValues, internalValue]);
// Split value into full check and half check
var _React$useMemo = react.useMemo(function () {
var fullCheckValues = [];
var halfCheckValues = [];
rawMixedLabeledValues.forEach(function (item) {
if (item.halfChecked) {
halfCheckValues.push(item);
} else {
fullCheckValues.push(item);
}
});
return [fullCheckValues, halfCheckValues];
}, [rawMixedLabeledValues]),
_React$useMemo2 = (0,slicedToArray/* default */.Z)(_React$useMemo, 2),
rawLabeledValues = _React$useMemo2[0],
rawHalfLabeledValues = _React$useMemo2[1];
// const [mergedValues] = useCache(rawLabeledValues);
var rawValues = react.useMemo(function () {
return rawLabeledValues.map(function (item) {
return item.value;
});
}, [rawLabeledValues]);
// Convert value to key. Will fill missed keys for conduct check.
var _useCheckedKeys = useCheckedKeys(rawLabeledValues, rawHalfLabeledValues, treeConduction, keyEntities),
_useCheckedKeys2 = (0,slicedToArray/* default */.Z)(_useCheckedKeys, 2),
rawCheckedValues = _useCheckedKeys2[0],
rawHalfCheckedValues = _useCheckedKeys2[1];
// Convert rawCheckedKeys to check strategy related values
var displayValues = react.useMemo(function () {
// Collect keys which need to show
var displayKeys = formatStrategyValues(rawCheckedValues, showCheckedStrategy, keyEntities, mergedFieldNames);
// Convert to value and filled with label
var values = displayKeys.map(function (key) {
var _keyEntities$key$node, _keyEntities$key, _keyEntities$key$node2;
return (_keyEntities$key$node = (_keyEntities$key = keyEntities[key]) === null || _keyEntities$key === void 0 ? void 0 : (_keyEntities$key$node2 = _keyEntities$key.node) === null || _keyEntities$key$node2 === void 0 ? void 0 : _keyEntities$key$node2[mergedFieldNames.value]) !== null && _keyEntities$key$node !== void 0 ? _keyEntities$key$node : key;
});
// Back fill with origin label
var labeledValues = values.map(function (val) {
var targetItem = rawLabeledValues.find(function (item) {
return item.value === val;
});
return {
value: val,
label: targetItem === null || targetItem === void 0 ? void 0 : targetItem.label
};
});
var rawDisplayValues = convert2LabelValues(labeledValues);
var firstVal = rawDisplayValues[0];
if (!mergedMultiple && firstVal && isNil(firstVal.value) && isNil(firstVal.label)) {
return [];
}
return rawDisplayValues.map(function (item) {
var _item$label;
return (0,objectSpread2/* default */.Z)((0,objectSpread2/* default */.Z)({}, item), {}, {
label: (_item$label = item.label) !== null && _item$label !== void 0 ? _item$label : item.value
});
});
}, [mergedFieldNames, mergedMultiple, rawCheckedValues, rawLabeledValues, convert2LabelValues, showCheckedStrategy, keyEntities]);
var _useCache = hooks_useCache(displayValues),
_useCache2 = (0,slicedToArray/* default */.Z)(_useCache, 1),
cachedDisplayValues = _useCache2[0];
// =========================== Change ===========================
var triggerChange = useRefFunc_useRefFunc(function (newRawValues, extra, source) {
var labeledValues = convert2LabelValues(newRawValues);
setInternalValue(labeledValues);
// Clean up if needed
if (autoClearSearchValue) {
setSearchValue('');
}
// Generate rest parameters is costly, so only do it when necessary
if (onChange) {
var eventValues = newRawValues;
if (treeConduction) {
var formattedKeyList = formatStrategyValues(newRawValues, showCheckedStrategy, keyEntities, mergedFieldNames);
eventValues = formattedKeyList.map(function (key) {
var entity = valueEntities.get(key);
return entity ? entity.node[mergedFieldNames.value] : key;
});
}
var _ref = extra || {
triggerValue: undefined,
selected: undefined
},
triggerValue = _ref.triggerValue,
selected = _ref.selected;
var returnRawValues = eventValues;
// We need fill half check back
if (treeCheckStrictly) {
var halfValues = rawHalfLabeledValues.filter(function (item) {
return !eventValues.includes(item.value);
});
returnRawValues = [].concat((0,toConsumableArray/* default */.Z)(returnRawValues), (0,toConsumableArray/* default */.Z)(halfValues));
}
var returnLabeledValues = convert2LabelValues(returnRawValues);
var additionalInfo = {
// [Legacy] Always return as array contains label & value
preValue: rawLabeledValues,
triggerValue: triggerValue
};
// [Legacy] Fill legacy data if user query.
// This is expansive that we only fill when user query
// https://github.com/react-component/tree-select/blob/fe33eb7c27830c9ac70cd1fdb1ebbe7bc679c16a/src/Select.jsx
var showPosition = true;
if (treeCheckStrictly || source === 'selection' && !selected) {
showPosition = false;
}
fillAdditionalInfo(additionalInfo, triggerValue, newRawValues, mergedTreeData, showPosition, mergedFieldNames);
if (mergedCheckable) {
additionalInfo.checked = selected;
} else {
additionalInfo.selected = selected;
}
var returnValues = mergedLabelInValue ? returnLabeledValues : returnLabeledValues.map(function (item) {
return item.value;
});
onChange(mergedMultiple ? returnValues : returnValues[0], mergedLabelInValue ? null : returnLabeledValues.map(function (item) {
return item.label;
}), additionalInfo);
}
});
// ========================== Options ===========================
/** Trigger by option list */
var onOptionSelect = react.useCallback(function (selectedKey, _ref2) {
var _node$mergedFieldName;
var selected = _ref2.selected,
source = _ref2.source;
var entity = keyEntities[selectedKey];
var node = entity === null || entity === void 0 ? void 0 : entity.node;
var selectedValue = (_node$mergedFieldName = node === null || node === void 0 ? void 0 : node[mergedFieldNames.value]) !== null && _node$mergedFieldName !== void 0 ? _node$mergedFieldName : selectedKey;
// Never be falsy but keep it safe
if (!mergedMultiple) {
// Single mode always set value
triggerChange([selectedValue], {
selected: true,
triggerValue: selectedValue
}, 'option');
} else {
var newRawValues = selected ? [].concat((0,toConsumableArray/* default */.Z)(rawValues), [selectedValue]) : rawCheckedValues.filter(function (v) {
return v !== selectedValue;
});
// Add keys if tree conduction
if (treeConduction) {
// Should keep missing values
var _splitRawValues = splitRawValues(newRawValues),
missingRawValues = _splitRawValues.missingRawValues,
existRawValues = _splitRawValues.existRawValues;
var keyList = existRawValues.map(function (val) {
return valueEntities.get(val).key;
});
// Conduction by selected or not
var checkedKeys;
if (selected) {
var _conductCheck = (0,conductUtil/* conductCheck */.S)(keyList, true, keyEntities);
checkedKeys = _conductCheck.checkedKeys;
} else {
var _conductCheck2 = (0,conductUtil/* conductCheck */.S)(keyList, {
checked: false,
halfCheckedKeys: rawHalfCheckedValues
}, keyEntities);
checkedKeys = _conductCheck2.checkedKeys;
}
// Fill back of keys
newRawValues = [].concat((0,toConsumableArray/* default */.Z)(missingRawValues), (0,toConsumableArray/* default */.Z)(checkedKeys.map(function (key) {
return keyEntities[key].node[mergedFieldNames.value];
})));
}
triggerChange(newRawValues, {
selected: selected,
triggerValue: selectedValue
}, source || 'option');
}
// Trigger select event
if (selected || !mergedMultiple) {
onSelect === null || onSelect === void 0 ? void 0 : onSelect(selectedValue, fillLegacyProps(node));
} else {
onDeselect === null || onDeselect === void 0 ? void 0 : onDeselect(selectedValue, fillLegacyProps(node));
}
}, [splitRawValues, valueEntities, keyEntities, mergedFieldNames, mergedMultiple, rawValues, triggerChange, treeConduction, onSelect, onDeselect, rawCheckedValues, rawHalfCheckedValues]);
// ========================== Dropdown ==========================
var onInternalDropdownVisibleChange = react.useCallback(function (open) {
if (onDropdownVisibleChange) {
var legacyParam = {};
Object.defineProperty(legacyParam, 'documentClickClose', {
get: function get() {
(0,es_warning/* default */.ZP)(false, 'Second param of `onDropdownVisibleChange` has been removed.');
return false;
}
});
onDropdownVisibleChange(open, legacyParam);
}
}, [onDropdownVisibleChange]);
// ====================== Display Change ========================
var onDisplayValuesChange = useRefFunc_useRefFunc(function (newValues, info) {
var newRawValues = newValues.map(function (item) {
return item.value;
});
if (info.type === 'clear') {
triggerChange(newRawValues, {}, 'selection');
return;
}
// TreeSelect only have multiple mode which means display change only has remove
if (info.values.length) {
onOptionSelect(info.values[0].value, {
selected: false,
source: 'selection'
});
}
});
// ========================== Context ===========================
var treeSelectContext = react.useMemo(function () {
return {
virtual: virtual,
dropdownMatchSelectWidth: dropdownMatchSelectWidth,
listHeight: listHeight,
listItemHeight: listItemHeight,
treeData: filteredTreeData,
fieldNames: mergedFieldNames,
onSelect: onOptionSelect,
treeExpandAction: treeExpandAction
};
}, [virtual, dropdownMatchSelectWidth, listHeight, listItemHeight, filteredTreeData, mergedFieldNames, onOptionSelect, treeExpandAction]);
// ======================= Legacy Context =======================
var legacyContext = react.useMemo(function () {
return {
checkable: mergedCheckable,
loadData: loadData,
treeLoadedKeys: treeLoadedKeys,
onTreeLoad: onTreeLoad,
checkedKeys: rawCheckedValues,
halfCheckedKeys: rawHalfCheckedValues,
treeDefaultExpandAll: treeDefaultExpandAll,
treeExpandedKeys: treeExpandedKeys,
treeDefaultExpandedKeys: treeDefaultExpandedKeys,
onTreeExpand: onTreeExpand,
treeIcon: treeIcon,
treeMotion: treeMotion,
showTreeIcon: showTreeIcon,
switcherIcon: switcherIcon,
treeLine: treeLine,
treeNodeFilterProp: treeNodeFilterProp,
keyEntities: keyEntities
};
}, [mergedCheckable, loadData, treeLoadedKeys, onTreeLoad, rawCheckedValues, rawHalfCheckedValues, treeDefaultExpandAll, treeExpandedKeys, treeDefaultExpandedKeys, onTreeExpand, treeIcon, treeMotion, showTreeIcon, switcherIcon, treeLine, treeNodeFilterProp, keyEntities]);
// =========================== Render ===========================
return /*#__PURE__*/react.createElement(es_TreeSelectContext.Provider, {
value: treeSelectContext
}, /*#__PURE__*/react.createElement(LegacyContext.Provider, {
value: legacyContext
}, /*#__PURE__*/react.createElement(es_BaseSelect, (0,esm_extends/* default */.Z)({
ref: ref
}, restProps, {
// >>> MISC
id: mergedId,
prefixCls: prefixCls,
mode: mergedMultiple ? 'multiple' : undefined
// >>> Display Value
,
displayValues: cachedDisplayValues,
onDisplayValuesChange: onDisplayValuesChange
// >>> Search
,
searchValue: mergedSearchValue,
onSearch: onInternalSearch
// >>> Options
,
OptionList: rc_tree_select_es_OptionList,
emptyOptions: !mergedTreeData.length,
onDropdownVisibleChange: onInternalDropdownVisibleChange,
dropdownMatchSelectWidth: dropdownMatchSelectWidth
}))));
});
// Assign name for Debug
if (false) {}
var GenericTreeSelect = TreeSelect;
GenericTreeSelect.TreeNode = es_TreeNode;
GenericTreeSelect.SHOW_ALL = SHOW_ALL;
GenericTreeSelect.SHOW_PARENT = SHOW_PARENT;
GenericTreeSelect.SHOW_CHILD = SHOW_CHILD;
/* harmony default export */ var es_TreeSelect = (GenericTreeSelect);
;// CONCATENATED MODULE: ./node_modules/rc-tree-select/es/index.js
/* harmony default export */ var rc_tree_select_es = (es_TreeSelect);
// EXTERNAL MODULE: ./node_modules/antd/node_modules/rc-util/es/omit.js
var es_omit = __webpack_require__(10366);
// EXTERNAL MODULE: ./node_modules/antd/es/_util/PurePanel.js
var PurePanel = __webpack_require__(8745);
// EXTERNAL MODULE: ./node_modules/antd/es/_util/motion.js
var motion = __webpack_require__(33603);
// EXTERNAL MODULE: ./node_modules/antd/es/_util/statusUtils.js
var statusUtils = __webpack_require__(9708);
// EXTERNAL MODULE: ./node_modules/antd/es/config-provider/context.js
var context = __webpack_require__(53124);
// EXTERNAL MODULE: ./node_modules/antd/es/config-provider/DisabledContext.js
var DisabledContext = __webpack_require__(98866);
// EXTERNAL MODULE: ./node_modules/antd/es/config-provider/defaultRenderEmpty.js
var defaultRenderEmpty = __webpack_require__(88258);
// EXTERNAL MODULE: ./node_modules/antd/es/config-provider/hooks/useSize.js
var useSize = __webpack_require__(98675);
// EXTERNAL MODULE: ./node_modules/antd/es/form/context.js
var form_context = __webpack_require__(65223);
// EXTERNAL MODULE: ./node_modules/antd/es/select/style/index.js + 3 modules
var style = __webpack_require__(87244);
// EXTERNAL MODULE: ./node_modules/antd/es/select/useBuiltinPlacements.js
var useBuiltinPlacements = __webpack_require__(13458);
// EXTERNAL MODULE: ./node_modules/antd/es/select/useShowArrow.js
var useShowArrow = __webpack_require__(78642);
// EXTERNAL MODULE: ./node_modules/antd/es/select/utils/iconUtil.js
var iconUtil = __webpack_require__(46163);
// EXTERNAL MODULE: ./node_modules/antd/es/space/Compact.js
var Compact = __webpack_require__(4173);
// EXTERNAL MODULE: ./node_modules/antd/es/tree/utils/iconUtil.js + 2 modules
var utils_iconUtil = __webpack_require__(79337);
// EXTERNAL MODULE: ./node_modules/antd/es/checkbox/style/index.js
var checkbox_style = __webpack_require__(63185);
// EXTERNAL MODULE: ./node_modules/antd/es/theme/util/statistic.js
var statistic = __webpack_require__(45503);
// EXTERNAL MODULE: ./node_modules/antd/es/theme/util/genComponentStyleHook.js
var genComponentStyleHook = __webpack_require__(67968);
// EXTERNAL MODULE: ./node_modules/antd/es/tree/style/index.js
var tree_style = __webpack_require__(32157);
;// CONCATENATED MODULE: ./node_modules/antd/es/tree-select/style/index.js
// =============================== Base ===============================
const genBaseStyle = token => {
const {
componentCls,
treePrefixCls,
colorBgElevated
} = token;
const treeCls = `.${treePrefixCls}`;
return [
// ======================================================
// == Dropdown ==
// ======================================================
{
[`${componentCls}-dropdown`]: [{
padding: `${token.paddingXS}px ${token.paddingXS / 2}px`
},
// ====================== Tree ======================
(0,tree_style/* genTreeStyle */.Yk)(treePrefixCls, (0,statistic/* merge */.TS)(token, {
colorBgContainer: colorBgElevated
})), {
[treeCls]: {
borderRadius: 0,
[`${treeCls}-list-holder-inner`]: {
alignItems: 'stretch',
[`${treeCls}-treenode`]: {
[`${treeCls}-node-content-wrapper`]: {
flex: 'auto'
}
}
}
}
},
// ==================== Checkbox ====================
(0,checkbox_style/* getStyle */.C2)(`${treePrefixCls}-checkbox`, token),
// ====================== RTL =======================
{
'&-rtl': {
direction: 'rtl',
[`${treeCls}-switcher${treeCls}-switcher_close`]: {
[`${treeCls}-switcher-icon svg`]: {
transform: 'rotate(90deg)'
}
}
}
}]
}];
};
// ============================== Export ==============================
function useTreeSelectStyle(prefixCls, treePrefixCls) {
return (0,genComponentStyleHook/* default */.Z)('TreeSelect', token => {
const treeSelectToken = (0,statistic/* merge */.TS)(token, {
treePrefixCls
});
return [genBaseStyle(treeSelectToken)];
})(prefixCls);
}
;// CONCATENATED MODULE: ./node_modules/antd/es/tree-select/index.js
'use client';
var __rest = undefined && undefined.__rest || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
}
return t;
};
const InternalTreeSelect = (_a, ref) => {
var _b;
var {
prefixCls: customizePrefixCls,
size: customizeSize,
disabled: customDisabled,
bordered = true,
className,
rootClassName,
treeCheckable,
multiple,
listHeight = 256,
listItemHeight = 26,
placement,
notFoundContent,
switcherIcon,
treeLine,
getPopupContainer,
popupClassName,
dropdownClassName,
treeIcon = false,
transitionName,
choiceTransitionName = '',
status: customStatus,
showArrow,
treeExpandAction,
builtinPlacements,
dropdownMatchSelectWidth,
popupMatchSelectWidth
} = _a,
props = __rest(_a, ["prefixCls", "size", "disabled", "bordered", "className", "rootClassName", "treeCheckable", "multiple", "listHeight", "listItemHeight", "placement", "notFoundContent", "switcherIcon", "treeLine", "getPopupContainer", "popupClassName", "dropdownClassName", "treeIcon", "transitionName", "choiceTransitionName", "status", "showArrow", "treeExpandAction", "builtinPlacements", "dropdownMatchSelectWidth", "popupMatchSelectWidth"]);
const {
getPopupContainer: getContextPopupContainer,
getPrefixCls,
renderEmpty,
direction,
virtual,
popupMatchSelectWidth: contextPopupMatchSelectWidth,
popupOverflow
} = react.useContext(context/* ConfigContext */.E_);
if (false) {}
const rootPrefixCls = getPrefixCls();
const prefixCls = getPrefixCls('select', customizePrefixCls);
const treePrefixCls = getPrefixCls('select-tree', customizePrefixCls);
const treeSelectPrefixCls = getPrefixCls('tree-select', customizePrefixCls);
const {
compactSize,
compactItemClassnames
} = (0,Compact/* useCompactItemContext */.ri)(prefixCls, direction);
const [wrapSelectSSR, hashId] = (0,style/* default */.Z)(prefixCls);
const [wrapTreeSelectSSR] = useTreeSelectStyle(treeSelectPrefixCls, treePrefixCls);
const mergedDropdownClassName = classnames_default()(popupClassName || dropdownClassName, `${treeSelectPrefixCls}-dropdown`, {
[`${treeSelectPrefixCls}-dropdown-rtl`]: direction === 'rtl'
}, rootClassName, hashId);
const isMultiple = !!(treeCheckable || multiple);
const mergedShowArrow = (0,useShowArrow/* default */.Z)(showArrow);
const mergedPopupMatchSelectWidth = (_b = popupMatchSelectWidth !== null && popupMatchSelectWidth !== void 0 ? popupMatchSelectWidth : dropdownMatchSelectWidth) !== null && _b !== void 0 ? _b : contextPopupMatchSelectWidth;
// ===================== Form =====================
const {
status: contextStatus,
hasFeedback,
isFormItemInput,
feedbackIcon
} = react.useContext(form_context/* FormItemInputContext */.aM);
const mergedStatus = (0,statusUtils/* getMergedStatus */.F)(contextStatus, customStatus);
// ===================== Icons =====================
const {
suffixIcon,
removeIcon,
clearIcon
} = (0,iconUtil/* default */.Z)(Object.assign(Object.assign({}, props), {
multiple: isMultiple,
showArrow: mergedShowArrow,
hasFeedback,
feedbackIcon,
prefixCls
}));
// ===================== Empty =====================
let mergedNotFound;
if (notFoundContent !== undefined) {
mergedNotFound = notFoundContent;
} else {
mergedNotFound = (renderEmpty === null || renderEmpty === void 0 ? void 0 : renderEmpty('Select')) || /*#__PURE__*/react.createElement(defaultRenderEmpty/* default */.Z, {
componentName: "Select"
});
}
// ==================== Render =====================
const selectProps = (0,es_omit/* default */.Z)(props, ['suffixIcon', 'itemIcon', 'removeIcon', 'clearIcon', 'switcherIcon']);
// ===================== Placement =====================
const memoizedPlacement = react.useMemo(() => {
if (placement !== undefined) {
return placement;
}
return direction === 'rtl' ? 'bottomRight' : 'bottomLeft';
}, [placement, direction]);
const mergedBuiltinPlacements = (0,useBuiltinPlacements/* default */.Z)(builtinPlacements, popupOverflow);
const mergedSize = (0,useSize/* default */.Z)(ctx => {
var _a;
return (_a = customizeSize !== null && customizeSize !== void 0 ? customizeSize : compactSize) !== null && _a !== void 0 ? _a : ctx;
});
// ===================== Disabled =====================
const disabled = react.useContext(DisabledContext/* default */.Z);
const mergedDisabled = customDisabled !== null && customDisabled !== void 0 ? customDisabled : disabled;
const mergedClassName = classnames_default()(!customizePrefixCls && treeSelectPrefixCls, {
[`${prefixCls}-lg`]: mergedSize === 'large',
[`${prefixCls}-sm`]: mergedSize === 'small',
[`${prefixCls}-rtl`]: direction === 'rtl',
[`${prefixCls}-borderless`]: !bordered,
[`${prefixCls}-in-form-item`]: isFormItemInput
}, (0,statusUtils/* getStatusClassNames */.Z)(prefixCls, mergedStatus, hasFeedback), compactItemClassnames, className, rootClassName, hashId);
const renderSwitcherIcon = nodeProps => /*#__PURE__*/react.createElement(utils_iconUtil/* default */.Z, {
prefixCls: treePrefixCls,
switcherIcon: switcherIcon,
treeNodeProps: nodeProps,
showLine: treeLine
});
const returnNode = /*#__PURE__*/react.createElement(rc_tree_select_es, Object.assign({
virtual: virtual,
disabled: mergedDisabled
}, selectProps, {
dropdownMatchSelectWidth: mergedPopupMatchSelectWidth,
builtinPlacements: mergedBuiltinPlacements,
ref: ref,
prefixCls: prefixCls,
className: mergedClassName,
listHeight: listHeight,
listItemHeight: listItemHeight,
treeCheckable: treeCheckable ? /*#__PURE__*/react.createElement("span", {
className: `${prefixCls}-tree-checkbox-inner`
}) : treeCheckable,
treeLine: !!treeLine,
inputIcon: suffixIcon,
multiple: isMultiple,
placement: memoizedPlacement,
removeIcon: removeIcon,
clearIcon: clearIcon,
switcherIcon: renderSwitcherIcon,
showTreeIcon: treeIcon,
notFoundContent: mergedNotFound,
getPopupContainer: getPopupContainer || getContextPopupContainer,
treeMotion: null,
dropdownClassName: mergedDropdownClassName,
choiceTransitionName: (0,motion/* getTransitionName */.mL)(rootPrefixCls, '', choiceTransitionName),
transitionName: (0,motion/* getTransitionName */.mL)(rootPrefixCls, (0,motion/* getTransitionDirection */.q0)(placement), transitionName),
showArrow: hasFeedback || mergedShowArrow,
treeExpandAction: treeExpandAction
}));
return wrapSelectSSR(wrapTreeSelectSSR(returnNode));
};
const TreeSelectRef = /*#__PURE__*/react.forwardRef(InternalTreeSelect);
const tree_select_TreeSelect = TreeSelectRef;
// We don't care debug panel
/* istanbul ignore next */
const tree_select_PurePanel = (0,PurePanel/* default */.Z)(tree_select_TreeSelect);
tree_select_TreeSelect.TreeNode = es_TreeNode;
tree_select_TreeSelect.SHOW_ALL = SHOW_ALL;
tree_select_TreeSelect.SHOW_PARENT = SHOW_PARENT;
tree_select_TreeSelect.SHOW_CHILD = SHOW_CHILD;
tree_select_TreeSelect._InternalPanelDoNotUseOrYouWillBeFired = tree_select_PurePanel;
if (false) {}
/* harmony default export */ var tree_select = (tree_select_TreeSelect);
/***/ }),
/***/ 73453:
/*!***************************************************************!*\
!*** ./node_modules/rc-virtual-list/es/index.js + 14 modules ***!
\***************************************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
// EXPORTS
__webpack_require__.d(__webpack_exports__, {
"Z": function() { return /* binding */ rc_virtual_list_es; }
});
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js
var esm_extends = __webpack_require__(87462);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js
var defineProperty = __webpack_require__(4942);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/objectSpread2.js
var objectSpread2 = __webpack_require__(1413);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js + 1 modules
var slicedToArray = __webpack_require__(97685);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js
var objectWithoutProperties = __webpack_require__(45987);
// EXTERNAL MODULE: ./node_modules/react/index.js
var react = __webpack_require__(67294);
// EXTERNAL MODULE: ./node_modules/classnames/index.js
var classnames = __webpack_require__(94184);
var classnames_default = /*#__PURE__*/__webpack_require__.n(classnames);
// EXTERNAL MODULE: ./node_modules/rc-resize-observer/es/index.js + 4 modules
var es = __webpack_require__(48555);
;// CONCATENATED MODULE: ./node_modules/rc-virtual-list/es/Filler.js
/**
* Fill component to provided the scroll content real height.
*/
var Filler = /*#__PURE__*/react.forwardRef(function (_ref, ref) {
var height = _ref.height,
offset = _ref.offset,
children = _ref.children,
prefixCls = _ref.prefixCls,
onInnerResize = _ref.onInnerResize,
innerProps = _ref.innerProps;
var outerStyle = {};
var innerStyle = {
display: 'flex',
flexDirection: 'column'
};
if (offset !== undefined) {
outerStyle = {
height: height,
position: 'relative',
overflow: 'hidden'
};
innerStyle = (0,objectSpread2/* default */.Z)((0,objectSpread2/* default */.Z)({}, innerStyle), {}, {
transform: "translateY(".concat(offset, "px)"),
position: 'absolute',
left: 0,
right: 0,
top: 0
});
}
return /*#__PURE__*/react.createElement("div", {
style: outerStyle
}, /*#__PURE__*/react.createElement(es/* default */.Z, {
onResize: function onResize(_ref2) {
var offsetHeight = _ref2.offsetHeight;
if (offsetHeight && onInnerResize) {
onInnerResize();
}
}
}, /*#__PURE__*/react.createElement("div", (0,esm_extends/* default */.Z)({
style: innerStyle,
className: classnames_default()((0,defineProperty/* default */.Z)({}, "".concat(prefixCls, "-holder-inner"), prefixCls)),
ref: ref
}, innerProps), children)));
});
Filler.displayName = 'Filler';
/* harmony default export */ var es_Filler = (Filler);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/classCallCheck.js
var classCallCheck = __webpack_require__(15671);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/createClass.js
var createClass = __webpack_require__(43144);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/inherits.js
var inherits = __webpack_require__(60136);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/createSuper.js + 1 modules
var createSuper = __webpack_require__(51630);
// EXTERNAL MODULE: ./node_modules/rc-util/es/raf.js
var raf = __webpack_require__(75164);
;// CONCATENATED MODULE: ./node_modules/rc-virtual-list/es/ScrollBar.js
var MIN_SIZE = 20;
function getPageY(e) {
return 'touches' in e ? e.touches[0].pageY : e.pageY;
}
var ScrollBar = /*#__PURE__*/function (_React$Component) {
(0,inherits/* default */.Z)(ScrollBar, _React$Component);
var _super = (0,createSuper/* default */.Z)(ScrollBar);
function ScrollBar() {
var _this;
(0,classCallCheck/* default */.Z)(this, ScrollBar);
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
_this = _super.call.apply(_super, [this].concat(args));
_this.moveRaf = null;
_this.scrollbarRef = /*#__PURE__*/react.createRef();
_this.thumbRef = /*#__PURE__*/react.createRef();
_this.visibleTimeout = null;
_this.state = {
dragging: false,
pageY: null,
startTop: null,
visible: false
};
_this.delayHidden = function () {
clearTimeout(_this.visibleTimeout);
_this.setState({
visible: true
});
_this.visibleTimeout = setTimeout(function () {
_this.setState({
visible: false
});
}, 2000);
};
_this.onScrollbarTouchStart = function (e) {
e.preventDefault();
};
_this.onContainerMouseDown = function (e) {
e.stopPropagation();
e.preventDefault();
};
_this.patchEvents = function () {
window.addEventListener('mousemove', _this.onMouseMove);
window.addEventListener('mouseup', _this.onMouseUp);
_this.thumbRef.current.addEventListener('touchmove', _this.onMouseMove);
_this.thumbRef.current.addEventListener('touchend', _this.onMouseUp);
};
_this.removeEvents = function () {
var _this$scrollbarRef$cu;
window.removeEventListener('mousemove', _this.onMouseMove);
window.removeEventListener('mouseup', _this.onMouseUp);
(_this$scrollbarRef$cu = _this.scrollbarRef.current) === null || _this$scrollbarRef$cu === void 0 ? void 0 : _this$scrollbarRef$cu.removeEventListener('touchstart', _this.onScrollbarTouchStart);
if (_this.thumbRef.current) {
_this.thumbRef.current.removeEventListener('touchstart', _this.onMouseDown);
_this.thumbRef.current.removeEventListener('touchmove', _this.onMouseMove);
_this.thumbRef.current.removeEventListener('touchend', _this.onMouseUp);
}
raf/* default.cancel */.Z.cancel(_this.moveRaf);
};
_this.onMouseDown = function (e) {
var onStartMove = _this.props.onStartMove;
_this.setState({
dragging: true,
pageY: getPageY(e),
startTop: _this.getTop()
});
onStartMove();
_this.patchEvents();
e.stopPropagation();
e.preventDefault();
};
_this.onMouseMove = function (e) {
var _this$state = _this.state,
dragging = _this$state.dragging,
pageY = _this$state.pageY,
startTop = _this$state.startTop;
var onScroll = _this.props.onScroll;
raf/* default.cancel */.Z.cancel(_this.moveRaf);
if (dragging) {
var offsetY = getPageY(e) - pageY;
var newTop = startTop + offsetY;
var enableScrollRange = _this.getEnableScrollRange();
var enableHeightRange = _this.getEnableHeightRange();
var ptg = enableHeightRange ? newTop / enableHeightRange : 0;
var newScrollTop = Math.ceil(ptg * enableScrollRange);
_this.moveRaf = (0,raf/* default */.Z)(function () {
onScroll(newScrollTop);
});
}
};
_this.onMouseUp = function () {
var onStopMove = _this.props.onStopMove;
_this.setState({
dragging: false
});
onStopMove();
_this.removeEvents();
};
_this.getSpinHeight = function () {
var _this$props = _this.props,
height = _this$props.height,
count = _this$props.count;
var baseHeight = height / count * 10;
baseHeight = Math.max(baseHeight, MIN_SIZE);
baseHeight = Math.min(baseHeight, height / 2);
return Math.floor(baseHeight);
};
_this.getEnableScrollRange = function () {
var _this$props2 = _this.props,
scrollHeight = _this$props2.scrollHeight,
height = _this$props2.height;
return scrollHeight - height || 0;
};
_this.getEnableHeightRange = function () {
var height = _this.props.height;
var spinHeight = _this.getSpinHeight();
return height - spinHeight || 0;
};
_this.getTop = function () {
var scrollTop = _this.props.scrollTop;
var enableScrollRange = _this.getEnableScrollRange();
var enableHeightRange = _this.getEnableHeightRange();
if (scrollTop === 0 || enableScrollRange === 0) {
return 0;
}
var ptg = scrollTop / enableScrollRange;
return ptg * enableHeightRange;
};
_this.showScroll = function () {
var _this$props3 = _this.props,
height = _this$props3.height,
scrollHeight = _this$props3.scrollHeight;
return scrollHeight > height;
};
return _this;
}
(0,createClass/* default */.Z)(ScrollBar, [{
key: "componentDidMount",
value: function componentDidMount() {
this.scrollbarRef.current.addEventListener('touchstart', this.onScrollbarTouchStart);
this.thumbRef.current.addEventListener('touchstart', this.onMouseDown);
}
}, {
key: "componentDidUpdate",
value: function componentDidUpdate(prevProps) {
if (prevProps.scrollTop !== this.props.scrollTop) {
this.delayHidden();
}
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
this.removeEvents();
clearTimeout(this.visibleTimeout);
}
}, {
key: "render",
value:
// ====================== Render =======================
function render() {
var _this$state2 = this.state,
dragging = _this$state2.dragging,
visible = _this$state2.visible;
var prefixCls = this.props.prefixCls;
var spinHeight = this.getSpinHeight();
var top = this.getTop();
var canScroll = this.showScroll();
var mergedVisible = canScroll && visible;
return /*#__PURE__*/react.createElement("div", {
ref: this.scrollbarRef,
className: classnames_default()("".concat(prefixCls, "-scrollbar"), (0,defineProperty/* default */.Z)({}, "".concat(prefixCls, "-scrollbar-show"), canScroll)),
style: {
width: 8,
top: 0,
bottom: 0,
right: 0,
position: 'absolute',
display: mergedVisible ? null : 'none'
},
onMouseDown: this.onContainerMouseDown,
onMouseMove: this.delayHidden
}, /*#__PURE__*/react.createElement("div", {
ref: this.thumbRef,
className: classnames_default()("".concat(prefixCls, "-scrollbar-thumb"), (0,defineProperty/* default */.Z)({}, "".concat(prefixCls, "-scrollbar-thumb-moving"), dragging)),
style: {
width: '100%',
height: spinHeight,
top: top,
left: 0,
position: 'absolute',
background: 'rgba(0, 0, 0, 0.5)',
borderRadius: 99,
cursor: 'pointer',
userSelect: 'none'
},
onMouseDown: this.onMouseDown
}));
}
}]);
return ScrollBar;
}(react.Component);
;// CONCATENATED MODULE: ./node_modules/rc-virtual-list/es/Item.js
function Item(_ref) {
var children = _ref.children,
setRef = _ref.setRef;
var refFunc = react.useCallback(function (node) {
setRef(node);
}, []);
return /*#__PURE__*/react.cloneElement(children, {
ref: refFunc
});
}
;// CONCATENATED MODULE: ./node_modules/rc-virtual-list/es/hooks/useChildren.js
function useChildren(list, startIndex, endIndex, setNodeRef, renderFunc, _ref) {
var getKey = _ref.getKey;
return list.slice(startIndex, endIndex + 1).map(function (item, index) {
var eleIndex = startIndex + index;
var node = renderFunc(item, eleIndex, {
// style: status === 'MEASURE_START' ? { visibility: 'hidden' } : {},
});
var key = getKey(item);
return /*#__PURE__*/react.createElement(Item, {
key: key,
setRef: function setRef(ele) {
return setNodeRef(item, ele);
}
}, node);
});
}
// EXTERNAL MODULE: ./node_modules/rc-util/es/Dom/findDOMNode.js
var findDOMNode = __webpack_require__(34203);
;// CONCATENATED MODULE: ./node_modules/rc-virtual-list/es/utils/CacheMap.js
// Firefox has low performance of map.
var CacheMap = /*#__PURE__*/function () {
function CacheMap() {
(0,classCallCheck/* default */.Z)(this, CacheMap);
this.maps = void 0;
this.maps = Object.create(null);
}
(0,createClass/* default */.Z)(CacheMap, [{
key: "set",
value: function set(key, value) {
this.maps[key] = value;
}
}, {
key: "get",
value: function get(key) {
return this.maps[key];
}
}]);
return CacheMap;
}();
/* harmony default export */ var utils_CacheMap = (CacheMap);
;// CONCATENATED MODULE: ./node_modules/rc-virtual-list/es/hooks/useHeights.js
function useHeights(getKey, onItemAdd, onItemRemove) {
var _React$useState = react.useState(0),
_React$useState2 = (0,slicedToArray/* default */.Z)(_React$useState, 2),
updatedMark = _React$useState2[0],
setUpdatedMark = _React$useState2[1];
var instanceRef = (0,react.useRef)(new Map());
var heightsRef = (0,react.useRef)(new utils_CacheMap());
var collectRafRef = (0,react.useRef)();
function cancelRaf() {
raf/* default.cancel */.Z.cancel(collectRafRef.current);
}
function collectHeight() {
cancelRaf();
collectRafRef.current = (0,raf/* default */.Z)(function () {
instanceRef.current.forEach(function (element, key) {
if (element && element.offsetParent) {
var htmlElement = (0,findDOMNode/* default */.Z)(element);
var offsetHeight = htmlElement.offsetHeight;
if (heightsRef.current.get(key) !== offsetHeight) {
heightsRef.current.set(key, htmlElement.offsetHeight);
}
}
});
// Always trigger update mark to tell parent that should re-calculate heights when resized
setUpdatedMark(function (c) {
return c + 1;
});
});
}
function setInstanceRef(item, instance) {
var key = getKey(item);
var origin = instanceRef.current.get(key);
if (instance) {
instanceRef.current.set(key, instance);
collectHeight();
} else {
instanceRef.current.delete(key);
}
// Instance changed
if (!origin !== !instance) {
if (instance) {
onItemAdd === null || onItemAdd === void 0 ? void 0 : onItemAdd(item);
} else {
onItemRemove === null || onItemRemove === void 0 ? void 0 : onItemRemove(item);
}
}
}
(0,react.useEffect)(function () {
return cancelRaf;
}, []);
return [setInstanceRef, collectHeight, heightsRef.current, updatedMark];
}
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/typeof.js
var esm_typeof = __webpack_require__(71002);
;// CONCATENATED MODULE: ./node_modules/rc-virtual-list/es/hooks/useScrollTo.js
/* eslint-disable no-param-reassign */
function useScrollTo(containerRef, data, heights, itemHeight, getKey, collectHeight, syncScrollTop, triggerFlash) {
var scrollRef = react.useRef();
return function (arg) {
// When not argument provided, we think dev may want to show the scrollbar
if (arg === null || arg === undefined) {
triggerFlash();
return;
}
// Normal scroll logic
raf/* default.cancel */.Z.cancel(scrollRef.current);
if (typeof arg === 'number') {
syncScrollTop(arg);
} else if (arg && (0,esm_typeof/* default */.Z)(arg) === 'object') {
var index;
var align = arg.align;
if ('index' in arg) {
index = arg.index;
} else {
index = data.findIndex(function (item) {
return getKey(item) === arg.key;
});
}
var _arg$offset = arg.offset,
offset = _arg$offset === void 0 ? 0 : _arg$offset;
// We will retry 3 times in case dynamic height shaking
var syncScroll = function syncScroll(times, targetAlign) {
if (times < 0 || !containerRef.current) return;
var height = containerRef.current.clientHeight;
var needCollectHeight = false;
var newTargetAlign = targetAlign;
// Go to next frame if height not exist
if (height) {
var mergedAlign = targetAlign || align;
// Get top & bottom
var stackTop = 0;
var itemTop = 0;
var itemBottom = 0;
var maxLen = Math.min(data.length, index);
for (var i = 0; i <= maxLen; i += 1) {
var key = getKey(data[i]);
itemTop = stackTop;
var cacheHeight = heights.get(key);
itemBottom = itemTop + (cacheHeight === undefined ? itemHeight : cacheHeight);
stackTop = itemBottom;
if (i === index && cacheHeight === undefined) {
needCollectHeight = true;
}
}
// Scroll to
var targetTop = null;
switch (mergedAlign) {
case 'top':
targetTop = itemTop - offset;
break;
case 'bottom':
targetTop = itemBottom - height + offset;
break;
default:
{
var scrollTop = containerRef.current.scrollTop;
var scrollBottom = scrollTop + height;
if (itemTop < scrollTop) {
newTargetAlign = 'top';
} else if (itemBottom > scrollBottom) {
newTargetAlign = 'bottom';
}
}
}
if (targetTop !== null && targetTop !== containerRef.current.scrollTop) {
syncScrollTop(targetTop);
}
}
// We will retry since element may not sync height as it described
scrollRef.current = (0,raf/* default */.Z)(function () {
if (needCollectHeight) {
collectHeight();
}
syncScroll(times - 1, newTargetAlign);
}, 2); // Delay 2 to wait for List collect heights
};
syncScroll(3);
}
};
}
;// CONCATENATED MODULE: ./node_modules/rc-virtual-list/es/utils/algorithmUtil.js
/**
* Get index with specific start index one by one. e.g.
* min: 3, max: 9, start: 6
*
* Return index is:
* [0]: 6
* [1]: 7
* [2]: 5
* [3]: 8
* [4]: 4
* [5]: 9
* [6]: 3
*/
function getIndexByStartLoc(min, max, start, index) {
var beforeCount = start - min;
var afterCount = max - start;
var balanceCount = Math.min(beforeCount, afterCount) * 2;
// Balance
if (index <= balanceCount) {
var stepIndex = Math.floor(index / 2);
if (index % 2) {
return start + stepIndex + 1;
}
return start - stepIndex;
}
// One is out of range
if (beforeCount > afterCount) {
return start - (index - afterCount);
}
return start + (index - beforeCount);
}
/**
* We assume that 2 list has only 1 item diff and others keeping the order.
* So we can use dichotomy algorithm to find changed one.
*/
function findListDiffIndex(originList, targetList, getKey) {
var originLen = originList.length;
var targetLen = targetList.length;
var shortList;
var longList;
if (originLen === 0 && targetLen === 0) {
return null;
}
if (originLen < targetLen) {
shortList = originList;
longList = targetList;
} else {
shortList = targetList;
longList = originList;
}
var notExistKey = {
__EMPTY_ITEM__: true
};
function getItemKey(item) {
if (item !== undefined) {
return getKey(item);
}
return notExistKey;
}
// Loop to find diff one
var diffIndex = null;
var multiple = Math.abs(originLen - targetLen) !== 1;
for (var i = 0; i < longList.length; i += 1) {
var shortKey = getItemKey(shortList[i]);
var longKey = getItemKey(longList[i]);
if (shortKey !== longKey) {
diffIndex = i;
multiple = multiple || shortKey !== getItemKey(longList[i + 1]);
break;
}
}
return diffIndex === null ? null : {
index: diffIndex,
multiple: multiple
};
}
;// CONCATENATED MODULE: ./node_modules/rc-virtual-list/es/hooks/useDiffItem.js
function useDiffItem(data, getKey, onDiff) {
var _React$useState = react.useState(data),
_React$useState2 = (0,slicedToArray/* default */.Z)(_React$useState, 2),
prevData = _React$useState2[0],
setPrevData = _React$useState2[1];
var _React$useState3 = react.useState(null),
_React$useState4 = (0,slicedToArray/* default */.Z)(_React$useState3, 2),
diffItem = _React$useState4[0],
setDiffItem = _React$useState4[1];
react.useEffect(function () {
var diff = findListDiffIndex(prevData || [], data || [], getKey);
if ((diff === null || diff === void 0 ? void 0 : diff.index) !== undefined) {
onDiff === null || onDiff === void 0 ? void 0 : onDiff(diff.index);
setDiffItem(data[diff.index]);
}
setPrevData(data);
}, [data]);
return [diffItem];
}
;// CONCATENATED MODULE: ./node_modules/rc-virtual-list/es/utils/isFirefox.js
var isFF = (typeof navigator === "undefined" ? "undefined" : (0,esm_typeof/* default */.Z)(navigator)) === 'object' && /Firefox/i.test(navigator.userAgent);
/* harmony default export */ var isFirefox = (isFF);
;// CONCATENATED MODULE: ./node_modules/rc-virtual-list/es/hooks/useOriginScroll.js
/* harmony default export */ var useOriginScroll = (function (isScrollAtTop, isScrollAtBottom) {
// Do lock for a wheel when scrolling
var lockRef = (0,react.useRef)(false);
var lockTimeoutRef = (0,react.useRef)(null);
function lockScroll() {
clearTimeout(lockTimeoutRef.current);
lockRef.current = true;
lockTimeoutRef.current = setTimeout(function () {
lockRef.current = false;
}, 50);
}
// Pass to ref since global add is in closure
var scrollPingRef = (0,react.useRef)({
top: isScrollAtTop,
bottom: isScrollAtBottom
});
scrollPingRef.current.top = isScrollAtTop;
scrollPingRef.current.bottom = isScrollAtBottom;
return function (deltaY) {
var smoothOffset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var originScroll =
// Pass origin wheel when on the top
deltaY < 0 && scrollPingRef.current.top ||
// Pass origin wheel when on the bottom
deltaY > 0 && scrollPingRef.current.bottom;
if (smoothOffset && originScroll) {
// No need lock anymore when it's smooth offset from touchMove interval
clearTimeout(lockTimeoutRef.current);
lockRef.current = false;
} else if (!originScroll || lockRef.current) {
lockScroll();
}
return !lockRef.current && originScroll;
};
});
;// CONCATENATED MODULE: ./node_modules/rc-virtual-list/es/hooks/useFrameWheel.js
function useFrameWheel(inVirtual, isScrollAtTop, isScrollAtBottom, onWheelDelta) {
var offsetRef = (0,react.useRef)(0);
var nextFrameRef = (0,react.useRef)(null);
// Firefox patch
var wheelValueRef = (0,react.useRef)(null);
var isMouseScrollRef = (0,react.useRef)(false);
// Scroll status sync
var originScroll = useOriginScroll(isScrollAtTop, isScrollAtBottom);
function onWheel(event) {
if (!inVirtual) return;
raf/* default.cancel */.Z.cancel(nextFrameRef.current);
var deltaY = event.deltaY;
offsetRef.current += deltaY;
wheelValueRef.current = deltaY;
// Do nothing when scroll at the edge, Skip check when is in scroll
if (originScroll(deltaY)) return;
// Proxy of scroll events
if (!isFirefox) {
event.preventDefault();
}
nextFrameRef.current = (0,raf/* default */.Z)(function () {
// Patch a multiple for Firefox to fix wheel number too small
// ref: https://github.com/ant-design/ant-design/issues/26372#issuecomment-679460266
var patchMultiple = isMouseScrollRef.current ? 10 : 1;
onWheelDelta(offsetRef.current * patchMultiple);
offsetRef.current = 0;
});
}
// A patch for firefox
function onFireFoxScroll(event) {
if (!inVirtual) return;
isMouseScrollRef.current = event.detail === wheelValueRef.current;
}
return [onWheel, onFireFoxScroll];
}
// EXTERNAL MODULE: ./node_modules/rc-util/es/hooks/useLayoutEffect.js
var useLayoutEffect = __webpack_require__(8410);
;// CONCATENATED MODULE: ./node_modules/rc-virtual-list/es/hooks/useMobileTouchMove.js
var SMOOTH_PTG = 14 / 15;
function useMobileTouchMove(inVirtual, listRef, callback) {
var touchedRef = (0,react.useRef)(false);
var touchYRef = (0,react.useRef)(0);
var elementRef = (0,react.useRef)(null);
// Smooth scroll
var intervalRef = (0,react.useRef)(null);
/* eslint-disable prefer-const */
var cleanUpEvents;
var onTouchMove = function onTouchMove(e) {
if (touchedRef.current) {
var currentY = Math.ceil(e.touches[0].pageY);
var offsetY = touchYRef.current - currentY;
touchYRef.current = currentY;
if (callback(offsetY)) {
e.preventDefault();
}
// Smooth interval
clearInterval(intervalRef.current);
intervalRef.current = setInterval(function () {
offsetY *= SMOOTH_PTG;
if (!callback(offsetY, true) || Math.abs(offsetY) <= 0.1) {
clearInterval(intervalRef.current);
}
}, 16);
}
};
var onTouchEnd = function onTouchEnd() {
touchedRef.current = false;
cleanUpEvents();
};
var onTouchStart = function onTouchStart(e) {
cleanUpEvents();
if (e.touches.length === 1 && !touchedRef.current) {
touchedRef.current = true;
touchYRef.current = Math.ceil(e.touches[0].pageY);
elementRef.current = e.target;
elementRef.current.addEventListener('touchmove', onTouchMove);
elementRef.current.addEventListener('touchend', onTouchEnd);
}
};
cleanUpEvents = function cleanUpEvents() {
if (elementRef.current) {
elementRef.current.removeEventListener('touchmove', onTouchMove);
elementRef.current.removeEventListener('touchend', onTouchEnd);
}
};
(0,useLayoutEffect/* default */.Z)(function () {
if (inVirtual) {
listRef.current.addEventListener('touchstart', onTouchStart);
}
return function () {
var _listRef$current;
(_listRef$current = listRef.current) === null || _listRef$current === void 0 ? void 0 : _listRef$current.removeEventListener('touchstart', onTouchStart);
cleanUpEvents();
clearInterval(intervalRef.current);
};
}, [inVirtual]);
}
;// CONCATENATED MODULE: ./node_modules/rc-virtual-list/es/List.js
var _excluded = ["prefixCls", "className", "height", "itemHeight", "fullHeight", "style", "data", "children", "itemKey", "virtual", "component", "onScroll", "onVisibleChange", "innerProps"];
var EMPTY_DATA = [];
var ScrollStyle = {
overflowY: 'auto',
overflowAnchor: 'none'
};
function RawList(props, ref) {
var _props$prefixCls = props.prefixCls,
prefixCls = _props$prefixCls === void 0 ? 'rc-virtual-list' : _props$prefixCls,
className = props.className,
height = props.height,
itemHeight = props.itemHeight,
_props$fullHeight = props.fullHeight,
fullHeight = _props$fullHeight === void 0 ? true : _props$fullHeight,
style = props.style,
data = props.data,
children = props.children,
itemKey = props.itemKey,
virtual = props.virtual,
_props$component = props.component,
Component = _props$component === void 0 ? 'div' : _props$component,
onScroll = props.onScroll,
onVisibleChange = props.onVisibleChange,
innerProps = props.innerProps,
restProps = (0,objectWithoutProperties/* default */.Z)(props, _excluded);
// ================================= MISC =================================
var useVirtual = !!(virtual !== false && height && itemHeight);
var inVirtual = useVirtual && data && itemHeight * data.length > height;
var _useState = (0,react.useState)(0),
_useState2 = (0,slicedToArray/* default */.Z)(_useState, 2),
scrollTop = _useState2[0],
setScrollTop = _useState2[1];
var _useState3 = (0,react.useState)(false),
_useState4 = (0,slicedToArray/* default */.Z)(_useState3, 2),
scrollMoving = _useState4[0],
setScrollMoving = _useState4[1];
var mergedClassName = classnames_default()(prefixCls, className);
var mergedData = data || EMPTY_DATA;
var componentRef = (0,react.useRef)();
var fillerInnerRef = (0,react.useRef)();
var scrollBarRef = (0,react.useRef)(); // Hack on scrollbar to enable flash call
// =============================== Item Key ===============================
var getKey = react.useCallback(function (item) {
if (typeof itemKey === 'function') {
return itemKey(item);
}
return item === null || item === void 0 ? void 0 : item[itemKey];
}, [itemKey]);
var sharedConfig = {
getKey: getKey
};
// ================================ Scroll ================================
function syncScrollTop(newTop) {
setScrollTop(function (origin) {
var value;
if (typeof newTop === 'function') {
value = newTop(origin);
} else {
value = newTop;
}
var alignedTop = keepInRange(value);
componentRef.current.scrollTop = alignedTop;
return alignedTop;
});
}
// ================================ Legacy ================================
// Put ref here since the range is generate by follow
var rangeRef = (0,react.useRef)({
start: 0,
end: mergedData.length
});
var diffItemRef = (0,react.useRef)();
var _useDiffItem = useDiffItem(mergedData, getKey),
_useDiffItem2 = (0,slicedToArray/* default */.Z)(_useDiffItem, 1),
diffItem = _useDiffItem2[0];
diffItemRef.current = diffItem;
// ================================ Height ================================
var _useHeights = useHeights(getKey, null, null),
_useHeights2 = (0,slicedToArray/* default */.Z)(_useHeights, 4),
setInstanceRef = _useHeights2[0],
collectHeight = _useHeights2[1],
heights = _useHeights2[2],
heightUpdatedMark = _useHeights2[3];
// ========================== Visible Calculation =========================
var _React$useMemo = react.useMemo(function () {
if (!useVirtual) {
return {
scrollHeight: undefined,
start: 0,
end: mergedData.length - 1,
offset: undefined
};
}
// Always use virtual scroll bar in avoid shaking
if (!inVirtual) {
var _fillerInnerRef$curre;
return {
scrollHeight: ((_fillerInnerRef$curre = fillerInnerRef.current) === null || _fillerInnerRef$curre === void 0 ? void 0 : _fillerInnerRef$curre.offsetHeight) || 0,
start: 0,
end: mergedData.length - 1,
offset: undefined
};
}
var itemTop = 0;
var startIndex;
var startOffset;
var endIndex;
var dataLen = mergedData.length;
for (var i = 0; i < dataLen; i += 1) {
var item = mergedData[i];
var key = getKey(item);
var cacheHeight = heights.get(key);
var currentItemBottom = itemTop + (cacheHeight === undefined ? itemHeight : cacheHeight);
// Check item top in the range
if (currentItemBottom >= scrollTop && startIndex === undefined) {
startIndex = i;
startOffset = itemTop;
}
// Check item bottom in the range. We will render additional one item for motion usage
if (currentItemBottom > scrollTop + height && endIndex === undefined) {
endIndex = i;
}
itemTop = currentItemBottom;
}
// When scrollTop at the end but data cut to small count will reach this
if (startIndex === undefined) {
startIndex = 0;
startOffset = 0;
endIndex = Math.ceil(height / itemHeight);
}
if (endIndex === undefined) {
endIndex = mergedData.length - 1;
}
// Give cache to improve scroll experience
endIndex = Math.min(endIndex + 1, mergedData.length);
return {
scrollHeight: itemTop,
start: startIndex,
end: endIndex,
offset: startOffset
};
}, [inVirtual, useVirtual, scrollTop, mergedData, heightUpdatedMark, height]),
scrollHeight = _React$useMemo.scrollHeight,
start = _React$useMemo.start,
end = _React$useMemo.end,
offset = _React$useMemo.offset;
rangeRef.current.start = start;
rangeRef.current.end = end;
// =============================== In Range ===============================
var maxScrollHeight = scrollHeight - height;
var maxScrollHeightRef = (0,react.useRef)(maxScrollHeight);
maxScrollHeightRef.current = maxScrollHeight;
function keepInRange(newScrollTop) {
var newTop = newScrollTop;
if (!Number.isNaN(maxScrollHeightRef.current)) {
newTop = Math.min(newTop, maxScrollHeightRef.current);
}
newTop = Math.max(newTop, 0);
return newTop;
}
var isScrollAtTop = scrollTop <= 0;
var isScrollAtBottom = scrollTop >= maxScrollHeight;
var originScroll = useOriginScroll(isScrollAtTop, isScrollAtBottom);
// ================================ Scroll ================================
function onScrollBar(newScrollTop) {
var newTop = newScrollTop;
syncScrollTop(newTop);
}
// When data size reduce. It may trigger native scroll event back to fit scroll position
function onFallbackScroll(e) {
var newScrollTop = e.currentTarget.scrollTop;
if (newScrollTop !== scrollTop) {
syncScrollTop(newScrollTop);
}
// Trigger origin onScroll
onScroll === null || onScroll === void 0 ? void 0 : onScroll(e);
}
// Since this added in global,should use ref to keep update
var _useFrameWheel = useFrameWheel(useVirtual, isScrollAtTop, isScrollAtBottom, function (offsetY) {
syncScrollTop(function (top) {
var newTop = top + offsetY;
return newTop;
});
}),
_useFrameWheel2 = (0,slicedToArray/* default */.Z)(_useFrameWheel, 2),
onRawWheel = _useFrameWheel2[0],
onFireFoxScroll = _useFrameWheel2[1];
// Mobile touch move
useMobileTouchMove(useVirtual, componentRef, function (deltaY, smoothOffset) {
if (originScroll(deltaY, smoothOffset)) {
return false;
}
onRawWheel({
preventDefault: function preventDefault() {},
deltaY: deltaY
});
return true;
});
(0,useLayoutEffect/* default */.Z)(function () {
// Firefox only
function onMozMousePixelScroll(e) {
if (useVirtual) {
e.preventDefault();
}
}
componentRef.current.addEventListener('wheel', onRawWheel);
componentRef.current.addEventListener('DOMMouseScroll', onFireFoxScroll);
componentRef.current.addEventListener('MozMousePixelScroll', onMozMousePixelScroll);
return function () {
if (componentRef.current) {
componentRef.current.removeEventListener('wheel', onRawWheel);
componentRef.current.removeEventListener('DOMMouseScroll', onFireFoxScroll);
componentRef.current.removeEventListener('MozMousePixelScroll', onMozMousePixelScroll);
}
};
}, [useVirtual]);
// ================================= Ref ==================================
var scrollTo = useScrollTo(componentRef, mergedData, heights, itemHeight, getKey, collectHeight, syncScrollTop, function () {
var _scrollBarRef$current;
(_scrollBarRef$current = scrollBarRef.current) === null || _scrollBarRef$current === void 0 ? void 0 : _scrollBarRef$current.delayHidden();
});
react.useImperativeHandle(ref, function () {
return {
scrollTo: scrollTo
};
});
// ================================ Effect ================================
/** We need told outside that some list not rendered */
(0,useLayoutEffect/* default */.Z)(function () {
if (onVisibleChange) {
var renderList = mergedData.slice(start, end + 1);
onVisibleChange(renderList, mergedData);
}
}, [start, end, mergedData]);
// ================================ Render ================================
var listChildren = useChildren(mergedData, start, end, setInstanceRef, children, sharedConfig);
var componentStyle = null;
if (height) {
componentStyle = (0,objectSpread2/* default */.Z)((0,defineProperty/* default */.Z)({}, fullHeight ? 'height' : 'maxHeight', height), ScrollStyle);
if (useVirtual) {
componentStyle.overflowY = 'hidden';
if (scrollMoving) {
componentStyle.pointerEvents = 'none';
}
}
}
return /*#__PURE__*/react.createElement("div", (0,esm_extends/* default */.Z)({
style: (0,objectSpread2/* default */.Z)((0,objectSpread2/* default */.Z)({}, style), {}, {
position: 'relative'
}),
className: mergedClassName
}, restProps), /*#__PURE__*/react.createElement(Component, {
className: "".concat(prefixCls, "-holder"),
style: componentStyle,
ref: componentRef,
onScroll: onFallbackScroll
}, /*#__PURE__*/react.createElement(es_Filler, {
prefixCls: prefixCls,
height: scrollHeight,
offset: offset,
onInnerResize: collectHeight,
ref: fillerInnerRef,
innerProps: innerProps
}, listChildren)), useVirtual && /*#__PURE__*/react.createElement(ScrollBar, {
ref: scrollBarRef,
prefixCls: prefixCls,
scrollTop: scrollTop,
height: height,
scrollHeight: scrollHeight,
count: mergedData.length,
onScroll: onScrollBar,
onStartMove: function onStartMove() {
setScrollMoving(true);
},
onStopMove: function onStopMove() {
setScrollMoving(false);
}
}));
}
var List = /*#__PURE__*/react.forwardRef(RawList);
List.displayName = 'List';
/* harmony default export */ var es_List = (List);
;// CONCATENATED MODULE: ./node_modules/rc-virtual-list/es/index.js
/* harmony default export */ var rc_virtual_list_es = (es_List);
/***/ })
}]);