first commit
This commit is contained in:
7
frontend/node_modules/rc-cascader/es/OptionList/CacheContent.d.ts
generated
vendored
Normal file
7
frontend/node_modules/rc-cascader/es/OptionList/CacheContent.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import * as React from 'react';
|
||||
export interface CacheContentProps {
|
||||
children?: React.ReactNode;
|
||||
open?: boolean;
|
||||
}
|
||||
declare const CacheContent: React.MemoExoticComponent<({ children }: CacheContentProps) => React.ReactElement<any, string | React.JSXElementConstructor<any>>>;
|
||||
export default CacheContent;
|
||||
11
frontend/node_modules/rc-cascader/es/OptionList/CacheContent.js
generated
vendored
Normal file
11
frontend/node_modules/rc-cascader/es/OptionList/CacheContent.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import * as React from 'react';
|
||||
var CacheContent = /*#__PURE__*/React.memo(function (_ref) {
|
||||
var children = _ref.children;
|
||||
return children;
|
||||
}, function (_, next) {
|
||||
return !next.open;
|
||||
});
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
CacheContent.displayName = 'CacheContent';
|
||||
}
|
||||
export default CacheContent;
|
||||
10
frontend/node_modules/rc-cascader/es/OptionList/Checkbox.d.ts
generated
vendored
Normal file
10
frontend/node_modules/rc-cascader/es/OptionList/Checkbox.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import * as React from 'react';
|
||||
export interface CheckboxProps {
|
||||
prefixCls: string;
|
||||
checked?: boolean;
|
||||
halfChecked?: boolean;
|
||||
disabled?: boolean;
|
||||
onClick?: React.MouseEventHandler;
|
||||
disableCheckbox?: boolean;
|
||||
}
|
||||
export default function Checkbox({ prefixCls, checked, halfChecked, disabled, onClick, disableCheckbox, }: CheckboxProps): React.JSX.Element;
|
||||
20
frontend/node_modules/rc-cascader/es/OptionList/Checkbox.js
generated
vendored
Normal file
20
frontend/node_modules/rc-cascader/es/OptionList/Checkbox.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
||||
import * as React from 'react';
|
||||
import classNames from 'classnames';
|
||||
import CascaderContext from "../context";
|
||||
export default function Checkbox(_ref) {
|
||||
var _classNames;
|
||||
var prefixCls = _ref.prefixCls,
|
||||
checked = _ref.checked,
|
||||
halfChecked = _ref.halfChecked,
|
||||
disabled = _ref.disabled,
|
||||
onClick = _ref.onClick,
|
||||
disableCheckbox = _ref.disableCheckbox;
|
||||
var _React$useContext = React.useContext(CascaderContext),
|
||||
checkable = _React$useContext.checkable;
|
||||
var customCheckbox = typeof checkable !== 'boolean' ? checkable : null;
|
||||
return /*#__PURE__*/React.createElement("span", {
|
||||
className: classNames("".concat(prefixCls), (_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-checked"), checked), _defineProperty(_classNames, "".concat(prefixCls, "-indeterminate"), !checked && halfChecked), _defineProperty(_classNames, "".concat(prefixCls, "-disabled"), disabled || disableCheckbox), _classNames)),
|
||||
onClick: onClick
|
||||
}, customCheckbox);
|
||||
}
|
||||
21
frontend/node_modules/rc-cascader/es/OptionList/Column.d.ts
generated
vendored
Normal file
21
frontend/node_modules/rc-cascader/es/OptionList/Column.d.ts
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
import * as React from 'react';
|
||||
import type { DefaultOptionType, SingleValueType } from '../Cascader';
|
||||
export declare const FIX_LABEL = "__cascader_fix_label__";
|
||||
export interface ColumnProps<OptionType extends DefaultOptionType = DefaultOptionType> {
|
||||
prefixCls: string;
|
||||
multiple?: boolean;
|
||||
options: OptionType[];
|
||||
/** Current Column opened item key */
|
||||
activeValue?: React.Key;
|
||||
/** The value path before current column */
|
||||
prevValuePath: React.Key[];
|
||||
onToggleOpen: (open: boolean) => void;
|
||||
onSelect: (valuePath: SingleValueType, leaf: boolean) => void;
|
||||
onActive: (valuePath: SingleValueType) => void;
|
||||
checkedSet: Set<React.Key>;
|
||||
halfCheckedSet: Set<React.Key>;
|
||||
loadingKeys: React.Key[];
|
||||
isSelectable: (option: DefaultOptionType) => boolean;
|
||||
disabled?: boolean;
|
||||
}
|
||||
export default function Column<OptionType extends DefaultOptionType = DefaultOptionType>({ prefixCls, multiple, options, activeValue, prevValuePath, onToggleOpen, onSelect, onActive, checkedSet, halfCheckedSet, loadingKeys, isSelectable, disabled: propsDisabled, }: ColumnProps<OptionType>): React.JSX.Element;
|
||||
175
frontend/node_modules/rc-cascader/es/OptionList/Column.js
generated
vendored
Normal file
175
frontend/node_modules/rc-cascader/es/OptionList/Column.js
generated
vendored
Normal file
@@ -0,0 +1,175 @@
|
||||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
||||
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
||||
import classNames from 'classnames';
|
||||
import * as React from 'react';
|
||||
import CascaderContext from "../context";
|
||||
import { SEARCH_MARK } from "../hooks/useSearchOptions";
|
||||
import { isLeaf, toPathKey } from "../utils/commonUtil";
|
||||
import Checkbox from "./Checkbox";
|
||||
export var FIX_LABEL = '__cascader_fix_label__';
|
||||
export default function Column(_ref) {
|
||||
var prefixCls = _ref.prefixCls,
|
||||
multiple = _ref.multiple,
|
||||
options = _ref.options,
|
||||
activeValue = _ref.activeValue,
|
||||
prevValuePath = _ref.prevValuePath,
|
||||
onToggleOpen = _ref.onToggleOpen,
|
||||
onSelect = _ref.onSelect,
|
||||
onActive = _ref.onActive,
|
||||
checkedSet = _ref.checkedSet,
|
||||
halfCheckedSet = _ref.halfCheckedSet,
|
||||
loadingKeys = _ref.loadingKeys,
|
||||
isSelectable = _ref.isSelectable,
|
||||
propsDisabled = _ref.disabled;
|
||||
var menuPrefixCls = "".concat(prefixCls, "-menu");
|
||||
var menuItemPrefixCls = "".concat(prefixCls, "-menu-item");
|
||||
var _React$useContext = React.useContext(CascaderContext),
|
||||
fieldNames = _React$useContext.fieldNames,
|
||||
changeOnSelect = _React$useContext.changeOnSelect,
|
||||
expandTrigger = _React$useContext.expandTrigger,
|
||||
expandIcon = _React$useContext.expandIcon,
|
||||
loadingIcon = _React$useContext.loadingIcon,
|
||||
dropdownMenuColumnStyle = _React$useContext.dropdownMenuColumnStyle,
|
||||
optionRender = _React$useContext.optionRender;
|
||||
var hoverOpen = expandTrigger === 'hover';
|
||||
var isOptionDisabled = function isOptionDisabled(disabled) {
|
||||
return propsDisabled || disabled;
|
||||
};
|
||||
|
||||
// ============================ Option ============================
|
||||
var optionInfoList = React.useMemo(function () {
|
||||
return options.map(function (option) {
|
||||
var _option$FIX_LABEL;
|
||||
var disabled = option.disabled,
|
||||
disableCheckbox = option.disableCheckbox;
|
||||
var searchOptions = option[SEARCH_MARK];
|
||||
var label = (_option$FIX_LABEL = option[FIX_LABEL]) !== null && _option$FIX_LABEL !== void 0 ? _option$FIX_LABEL : option[fieldNames.label];
|
||||
var value = option[fieldNames.value];
|
||||
var isMergedLeaf = isLeaf(option, fieldNames);
|
||||
|
||||
// Get real value of option. Search option is different way.
|
||||
var fullPath = searchOptions ? searchOptions.map(function (opt) {
|
||||
return opt[fieldNames.value];
|
||||
}) : [].concat(_toConsumableArray(prevValuePath), [value]);
|
||||
var fullPathKey = toPathKey(fullPath);
|
||||
var isLoading = loadingKeys.includes(fullPathKey);
|
||||
|
||||
// >>>>> checked
|
||||
var checked = checkedSet.has(fullPathKey);
|
||||
|
||||
// >>>>> halfChecked
|
||||
var halfChecked = halfCheckedSet.has(fullPathKey);
|
||||
return {
|
||||
disabled: disabled,
|
||||
label: label,
|
||||
value: value,
|
||||
isLeaf: isMergedLeaf,
|
||||
isLoading: isLoading,
|
||||
checked: checked,
|
||||
halfChecked: halfChecked,
|
||||
option: option,
|
||||
disableCheckbox: disableCheckbox,
|
||||
fullPath: fullPath,
|
||||
fullPathKey: fullPathKey
|
||||
};
|
||||
});
|
||||
}, [options, checkedSet, fieldNames, halfCheckedSet, loadingKeys, prevValuePath]);
|
||||
|
||||
// ============================ Render ============================
|
||||
return /*#__PURE__*/React.createElement("ul", {
|
||||
className: menuPrefixCls,
|
||||
role: "menu"
|
||||
}, optionInfoList.map(function (_ref2) {
|
||||
var _classNames;
|
||||
var disabled = _ref2.disabled,
|
||||
label = _ref2.label,
|
||||
value = _ref2.value,
|
||||
isMergedLeaf = _ref2.isLeaf,
|
||||
isLoading = _ref2.isLoading,
|
||||
checked = _ref2.checked,
|
||||
halfChecked = _ref2.halfChecked,
|
||||
option = _ref2.option,
|
||||
fullPath = _ref2.fullPath,
|
||||
fullPathKey = _ref2.fullPathKey,
|
||||
disableCheckbox = _ref2.disableCheckbox;
|
||||
// >>>>> Open
|
||||
var triggerOpenPath = function triggerOpenPath() {
|
||||
if (isOptionDisabled(disabled)) {
|
||||
return;
|
||||
}
|
||||
var nextValueCells = _toConsumableArray(fullPath);
|
||||
if (hoverOpen && isMergedLeaf) {
|
||||
nextValueCells.pop();
|
||||
}
|
||||
onActive(nextValueCells);
|
||||
};
|
||||
|
||||
// >>>>> Selection
|
||||
var triggerSelect = function triggerSelect() {
|
||||
if (isSelectable(option) && !isOptionDisabled(disabled)) {
|
||||
onSelect(fullPath, isMergedLeaf);
|
||||
}
|
||||
};
|
||||
|
||||
// >>>>> Title
|
||||
var title;
|
||||
if (typeof option.title === 'string') {
|
||||
title = option.title;
|
||||
} else if (typeof label === 'string') {
|
||||
title = label;
|
||||
}
|
||||
|
||||
// >>>>> Render
|
||||
return /*#__PURE__*/React.createElement("li", {
|
||||
key: fullPathKey,
|
||||
className: classNames(menuItemPrefixCls, (_classNames = {}, _defineProperty(_classNames, "".concat(menuItemPrefixCls, "-expand"), !isMergedLeaf), _defineProperty(_classNames, "".concat(menuItemPrefixCls, "-active"), activeValue === value || activeValue === fullPathKey), _defineProperty(_classNames, "".concat(menuItemPrefixCls, "-disabled"), isOptionDisabled(disabled)), _defineProperty(_classNames, "".concat(menuItemPrefixCls, "-loading"), isLoading), _classNames)),
|
||||
style: dropdownMenuColumnStyle,
|
||||
role: "menuitemcheckbox",
|
||||
title: title,
|
||||
"aria-checked": checked,
|
||||
"data-path-key": fullPathKey,
|
||||
onClick: function onClick() {
|
||||
triggerOpenPath();
|
||||
if (disableCheckbox) {
|
||||
return;
|
||||
}
|
||||
if (!multiple || isMergedLeaf) {
|
||||
triggerSelect();
|
||||
}
|
||||
},
|
||||
onDoubleClick: function onDoubleClick() {
|
||||
if (changeOnSelect) {
|
||||
onToggleOpen(false);
|
||||
}
|
||||
},
|
||||
onMouseEnter: function onMouseEnter() {
|
||||
if (hoverOpen) {
|
||||
triggerOpenPath();
|
||||
}
|
||||
},
|
||||
onMouseDown: function onMouseDown(e) {
|
||||
// Prevent selector from blurring
|
||||
e.preventDefault();
|
||||
}
|
||||
}, multiple && /*#__PURE__*/React.createElement(Checkbox, {
|
||||
prefixCls: "".concat(prefixCls, "-checkbox"),
|
||||
checked: checked,
|
||||
halfChecked: halfChecked,
|
||||
disabled: isOptionDisabled(disabled) || disableCheckbox,
|
||||
disableCheckbox: disableCheckbox,
|
||||
onClick: function onClick(e) {
|
||||
if (disableCheckbox) {
|
||||
return;
|
||||
}
|
||||
e.stopPropagation();
|
||||
triggerSelect();
|
||||
}
|
||||
}), /*#__PURE__*/React.createElement("div", {
|
||||
className: "".concat(menuItemPrefixCls, "-content")
|
||||
}, optionRender ? optionRender(option) : label), !isLoading && expandIcon && !isMergedLeaf && /*#__PURE__*/React.createElement("div", {
|
||||
className: "".concat(menuItemPrefixCls, "-expand-icon")
|
||||
}, expandIcon), isLoading && loadingIcon && /*#__PURE__*/React.createElement("div", {
|
||||
className: "".concat(menuItemPrefixCls, "-loading-icon")
|
||||
}, loadingIcon));
|
||||
}));
|
||||
}
|
||||
6
frontend/node_modules/rc-cascader/es/OptionList/List.d.ts
generated
vendored
Normal file
6
frontend/node_modules/rc-cascader/es/OptionList/List.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import type { useBaseProps } from 'rc-select';
|
||||
import type { RefOptionListProps } from 'rc-select/lib/OptionList';
|
||||
import * as React from 'react';
|
||||
export type RawOptionListProps = Pick<ReturnType<typeof useBaseProps>, 'prefixCls' | 'multiple' | 'searchValue' | 'toggleOpen' | 'notFoundContent' | 'direction' | 'open' | 'disabled'>;
|
||||
declare const RawOptionList: React.ForwardRefExoticComponent<RawOptionListProps & React.RefAttributes<RefOptionListProps>>;
|
||||
export default RawOptionList;
|
||||
232
frontend/node_modules/rc-cascader/es/OptionList/List.js
generated
vendored
Normal file
232
frontend/node_modules/rc-cascader/es/OptionList/List.js
generated
vendored
Normal file
@@ -0,0 +1,232 @@
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
||||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
||||
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
||||
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
||||
/* eslint-disable default-case */
|
||||
import classNames from 'classnames';
|
||||
import * as React from 'react';
|
||||
import CascaderContext from "../context";
|
||||
import { getFullPathKeys, isLeaf, scrollIntoParentView, toPathKey, toPathKeys, toPathValueStr } from "../utils/commonUtil";
|
||||
import { toPathOptions } from "../utils/treeUtil";
|
||||
import CacheContent from "./CacheContent";
|
||||
import Column, { FIX_LABEL } from "./Column";
|
||||
import useActive from "./useActive";
|
||||
import useKeyboard from "./useKeyboard";
|
||||
var RawOptionList = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
||||
var _optionColumns$, _ref3, _classNames;
|
||||
var prefixCls = props.prefixCls,
|
||||
multiple = props.multiple,
|
||||
searchValue = props.searchValue,
|
||||
toggleOpen = props.toggleOpen,
|
||||
notFoundContent = props.notFoundContent,
|
||||
direction = props.direction,
|
||||
open = props.open,
|
||||
disabled = props.disabled;
|
||||
var containerRef = React.useRef(null);
|
||||
var rtl = direction === 'rtl';
|
||||
var _React$useContext = React.useContext(CascaderContext),
|
||||
options = _React$useContext.options,
|
||||
values = _React$useContext.values,
|
||||
halfValues = _React$useContext.halfValues,
|
||||
fieldNames = _React$useContext.fieldNames,
|
||||
changeOnSelect = _React$useContext.changeOnSelect,
|
||||
onSelect = _React$useContext.onSelect,
|
||||
searchOptions = _React$useContext.searchOptions,
|
||||
dropdownPrefixCls = _React$useContext.dropdownPrefixCls,
|
||||
loadData = _React$useContext.loadData,
|
||||
expandTrigger = _React$useContext.expandTrigger;
|
||||
var mergedPrefixCls = dropdownPrefixCls || prefixCls;
|
||||
|
||||
// ========================= loadData =========================
|
||||
var _React$useState = React.useState([]),
|
||||
_React$useState2 = _slicedToArray(_React$useState, 2),
|
||||
loadingKeys = _React$useState2[0],
|
||||
setLoadingKeys = _React$useState2[1];
|
||||
var internalLoadData = function internalLoadData(valueCells) {
|
||||
// Do not load when search
|
||||
if (!loadData || searchValue) {
|
||||
return;
|
||||
}
|
||||
var optionList = toPathOptions(valueCells, options, fieldNames);
|
||||
var rawOptions = optionList.map(function (_ref) {
|
||||
var option = _ref.option;
|
||||
return option;
|
||||
});
|
||||
var lastOption = rawOptions[rawOptions.length - 1];
|
||||
if (lastOption && !isLeaf(lastOption, fieldNames)) {
|
||||
var pathKey = toPathKey(valueCells);
|
||||
setLoadingKeys(function (keys) {
|
||||
return [].concat(_toConsumableArray(keys), [pathKey]);
|
||||
});
|
||||
loadData(rawOptions);
|
||||
}
|
||||
};
|
||||
|
||||
// zombieJ: This is bad. We should make this same as `rc-tree` to use Promise instead.
|
||||
React.useEffect(function () {
|
||||
if (loadingKeys.length) {
|
||||
loadingKeys.forEach(function (loadingKey) {
|
||||
var valueStrCells = toPathValueStr(loadingKey);
|
||||
var optionList = toPathOptions(valueStrCells, options, fieldNames, true).map(function (_ref2) {
|
||||
var option = _ref2.option;
|
||||
return option;
|
||||
});
|
||||
var lastOption = optionList[optionList.length - 1];
|
||||
if (!lastOption || lastOption[fieldNames.children] || isLeaf(lastOption, fieldNames)) {
|
||||
setLoadingKeys(function (keys) {
|
||||
return keys.filter(function (key) {
|
||||
return key !== loadingKey;
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}, [options, loadingKeys, fieldNames]);
|
||||
|
||||
// ========================== Values ==========================
|
||||
var checkedSet = React.useMemo(function () {
|
||||
return new Set(toPathKeys(values));
|
||||
}, [values]);
|
||||
var halfCheckedSet = React.useMemo(function () {
|
||||
return new Set(toPathKeys(halfValues));
|
||||
}, [halfValues]);
|
||||
|
||||
// ====================== Accessibility =======================
|
||||
var _useActive = useActive(multiple, open),
|
||||
_useActive2 = _slicedToArray(_useActive, 2),
|
||||
activeValueCells = _useActive2[0],
|
||||
setActiveValueCells = _useActive2[1];
|
||||
|
||||
// =========================== Path ===========================
|
||||
var onPathOpen = function onPathOpen(nextValueCells) {
|
||||
setActiveValueCells(nextValueCells);
|
||||
|
||||
// Trigger loadData
|
||||
internalLoadData(nextValueCells);
|
||||
};
|
||||
var isSelectable = function isSelectable(option) {
|
||||
if (disabled) {
|
||||
return false;
|
||||
}
|
||||
var optionDisabled = option.disabled;
|
||||
var isMergedLeaf = isLeaf(option, fieldNames);
|
||||
return !optionDisabled && (isMergedLeaf || changeOnSelect || multiple);
|
||||
};
|
||||
var onPathSelect = function onPathSelect(valuePath, leaf) {
|
||||
var fromKeyboard = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
||||
onSelect(valuePath);
|
||||
if (!multiple && (leaf || changeOnSelect && (expandTrigger === 'hover' || fromKeyboard))) {
|
||||
toggleOpen(false);
|
||||
}
|
||||
};
|
||||
|
||||
// ========================== Option ==========================
|
||||
var mergedOptions = React.useMemo(function () {
|
||||
if (searchValue) {
|
||||
return searchOptions;
|
||||
}
|
||||
return options;
|
||||
}, [searchValue, searchOptions, options]);
|
||||
|
||||
// ========================== Column ==========================
|
||||
var optionColumns = React.useMemo(function () {
|
||||
var optionList = [{
|
||||
options: mergedOptions
|
||||
}];
|
||||
var currentList = mergedOptions;
|
||||
var fullPathKeys = getFullPathKeys(currentList, fieldNames);
|
||||
var _loop = function _loop() {
|
||||
var activeValueCell = activeValueCells[i];
|
||||
var currentOption = currentList.find(function (option, index) {
|
||||
return (fullPathKeys[index] ? toPathKey(fullPathKeys[index]) : option[fieldNames.value]) === activeValueCell;
|
||||
});
|
||||
var subOptions = currentOption === null || currentOption === void 0 ? void 0 : currentOption[fieldNames.children];
|
||||
if (!(subOptions !== null && subOptions !== void 0 && subOptions.length)) {
|
||||
return 1; // break
|
||||
}
|
||||
currentList = subOptions;
|
||||
optionList.push({
|
||||
options: subOptions
|
||||
});
|
||||
};
|
||||
for (var i = 0; i < activeValueCells.length; i += 1) {
|
||||
if (_loop()) break;
|
||||
}
|
||||
return optionList;
|
||||
}, [mergedOptions, activeValueCells, fieldNames]);
|
||||
|
||||
// ========================= Keyboard =========================
|
||||
var onKeyboardSelect = function onKeyboardSelect(selectValueCells, option) {
|
||||
if (isSelectable(option)) {
|
||||
onPathSelect(selectValueCells, isLeaf(option, fieldNames), true);
|
||||
}
|
||||
};
|
||||
useKeyboard(ref, mergedOptions, fieldNames, activeValueCells, onPathOpen, onKeyboardSelect, {
|
||||
direction: direction,
|
||||
searchValue: searchValue,
|
||||
toggleOpen: toggleOpen,
|
||||
open: open
|
||||
});
|
||||
|
||||
// >>>>> Active Scroll
|
||||
React.useEffect(function () {
|
||||
if (searchValue) {
|
||||
return;
|
||||
}
|
||||
for (var i = 0; i < activeValueCells.length; i += 1) {
|
||||
var _containerRef$current;
|
||||
var cellPath = activeValueCells.slice(0, i + 1);
|
||||
var cellKeyPath = toPathKey(cellPath);
|
||||
var ele = (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.querySelector("li[data-path-key=\"".concat(cellKeyPath.replace(/\\{0,2}"/g, '\\"'), "\"]") // matches unescaped double quotes
|
||||
);
|
||||
if (ele) {
|
||||
scrollIntoParentView(ele);
|
||||
}
|
||||
}
|
||||
}, [activeValueCells, searchValue]);
|
||||
|
||||
// ========================== Render ==========================
|
||||
// >>>>> Empty
|
||||
var isEmpty = !((_optionColumns$ = optionColumns[0]) !== null && _optionColumns$ !== void 0 && (_optionColumns$ = _optionColumns$.options) !== null && _optionColumns$ !== void 0 && _optionColumns$.length);
|
||||
var emptyList = [(_ref3 = {}, _defineProperty(_ref3, fieldNames.value, '__EMPTY__'), _defineProperty(_ref3, FIX_LABEL, notFoundContent), _defineProperty(_ref3, "disabled", true), _ref3)];
|
||||
var columnProps = _objectSpread(_objectSpread({}, props), {}, {
|
||||
multiple: !isEmpty && multiple,
|
||||
onSelect: onPathSelect,
|
||||
onActive: onPathOpen,
|
||||
onToggleOpen: toggleOpen,
|
||||
checkedSet: checkedSet,
|
||||
halfCheckedSet: halfCheckedSet,
|
||||
loadingKeys: loadingKeys,
|
||||
isSelectable: isSelectable
|
||||
});
|
||||
|
||||
// >>>>> Columns
|
||||
var mergedOptionColumns = isEmpty ? [{
|
||||
options: emptyList
|
||||
}] : optionColumns;
|
||||
var columnNodes = mergedOptionColumns.map(function (col, index) {
|
||||
var prevValuePath = activeValueCells.slice(0, index);
|
||||
var activeValue = activeValueCells[index];
|
||||
return /*#__PURE__*/React.createElement(Column, _extends({
|
||||
key: index
|
||||
}, columnProps, {
|
||||
prefixCls: mergedPrefixCls,
|
||||
options: col.options,
|
||||
prevValuePath: prevValuePath,
|
||||
activeValue: activeValue
|
||||
}));
|
||||
});
|
||||
|
||||
// >>>>> Render
|
||||
return /*#__PURE__*/React.createElement(CacheContent, {
|
||||
open: open
|
||||
}, /*#__PURE__*/React.createElement("div", {
|
||||
className: classNames("".concat(mergedPrefixCls, "-menus"), (_classNames = {}, _defineProperty(_classNames, "".concat(mergedPrefixCls, "-menu-empty"), isEmpty), _defineProperty(_classNames, "".concat(mergedPrefixCls, "-rtl"), rtl), _classNames)),
|
||||
ref: containerRef
|
||||
}, columnNodes));
|
||||
});
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
RawOptionList.displayName = 'RawOptionList';
|
||||
}
|
||||
export default RawOptionList;
|
||||
4
frontend/node_modules/rc-cascader/es/OptionList/index.d.ts
generated
vendored
Normal file
4
frontend/node_modules/rc-cascader/es/OptionList/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import type { RefOptionListProps } from 'rc-select/lib/OptionList';
|
||||
import * as React from 'react';
|
||||
declare const RefOptionList: React.ForwardRefExoticComponent<React.RefAttributes<RefOptionListProps>>;
|
||||
export default RefOptionList;
|
||||
13
frontend/node_modules/rc-cascader/es/OptionList/index.js
generated
vendored
Normal file
13
frontend/node_modules/rc-cascader/es/OptionList/index.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import { useBaseProps } from 'rc-select';
|
||||
import * as React from 'react';
|
||||
import RawOptionList from "./List";
|
||||
var RefOptionList = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
||||
var baseProps = useBaseProps();
|
||||
|
||||
// >>>>> Render
|
||||
return /*#__PURE__*/React.createElement(RawOptionList, _extends({}, props, baseProps, {
|
||||
ref: ref
|
||||
}));
|
||||
});
|
||||
export default RefOptionList;
|
||||
6
frontend/node_modules/rc-cascader/es/OptionList/useActive.d.ts
generated
vendored
Normal file
6
frontend/node_modules/rc-cascader/es/OptionList/useActive.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import * as React from 'react';
|
||||
/**
|
||||
* Control the active open options path.
|
||||
*/
|
||||
declare const useActive: (multiple?: boolean, open?: boolean) => [React.Key[], (activeValueCells: React.Key[]) => void];
|
||||
export default useActive;
|
||||
29
frontend/node_modules/rc-cascader/es/OptionList/useActive.js
generated
vendored
Normal file
29
frontend/node_modules/rc-cascader/es/OptionList/useActive.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
||||
import * as React from 'react';
|
||||
import CascaderContext from "../context";
|
||||
|
||||
/**
|
||||
* Control the active open options path.
|
||||
*/
|
||||
var useActive = function useActive(multiple, open) {
|
||||
var _React$useContext = React.useContext(CascaderContext),
|
||||
values = _React$useContext.values;
|
||||
var firstValueCells = values[0];
|
||||
|
||||
// Record current dropdown active options
|
||||
// This also control the open status
|
||||
var _React$useState = React.useState([]),
|
||||
_React$useState2 = _slicedToArray(_React$useState, 2),
|
||||
activeValueCells = _React$useState2[0],
|
||||
setActiveValueCells = _React$useState2[1];
|
||||
React.useEffect(function () {
|
||||
if (!multiple) {
|
||||
setActiveValueCells(firstValueCells || []);
|
||||
}
|
||||
}, /* eslint-disable react-hooks/exhaustive-deps */
|
||||
[open, firstValueCells]
|
||||
/* eslint-enable react-hooks/exhaustive-deps */);
|
||||
|
||||
return [activeValueCells, setActiveValueCells];
|
||||
};
|
||||
export default useActive;
|
||||
10
frontend/node_modules/rc-cascader/es/OptionList/useKeyboard.d.ts
generated
vendored
Normal file
10
frontend/node_modules/rc-cascader/es/OptionList/useKeyboard.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import type { RefOptionListProps } from 'rc-select/lib/OptionList';
|
||||
import * as React from 'react';
|
||||
import type { DefaultOptionType, InternalFieldNames, SingleValueType } from '../Cascader';
|
||||
declare const _default: (ref: React.Ref<RefOptionListProps>, options: DefaultOptionType[], fieldNames: InternalFieldNames, activeValueCells: React.Key[], setActiveValueCells: (activeValueCells: React.Key[]) => void, onKeyBoardSelect: (valueCells: SingleValueType, option: DefaultOptionType) => void, contextProps: {
|
||||
direction?: "ltr" | "rtl" | undefined;
|
||||
searchValue: string;
|
||||
toggleOpen: (open?: boolean) => void;
|
||||
open?: boolean | undefined;
|
||||
}) => void;
|
||||
export default _default;
|
||||
180
frontend/node_modules/rc-cascader/es/OptionList/useKeyboard.js
generated
vendored
Normal file
180
frontend/node_modules/rc-cascader/es/OptionList/useKeyboard.js
generated
vendored
Normal file
@@ -0,0 +1,180 @@
|
||||
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
||||
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
||||
import KeyCode from "rc-util/es/KeyCode";
|
||||
import * as React from 'react';
|
||||
import { SEARCH_MARK } from "../hooks/useSearchOptions";
|
||||
import { getFullPathKeys, toPathKey } from "../utils/commonUtil";
|
||||
export default (function (ref, options, fieldNames, activeValueCells, setActiveValueCells, onKeyBoardSelect, contextProps) {
|
||||
var direction = contextProps.direction,
|
||||
searchValue = contextProps.searchValue,
|
||||
toggleOpen = contextProps.toggleOpen,
|
||||
open = contextProps.open;
|
||||
var rtl = direction === 'rtl';
|
||||
var _React$useMemo = React.useMemo(function () {
|
||||
var activeIndex = -1;
|
||||
var currentOptions = options;
|
||||
var mergedActiveIndexes = [];
|
||||
var mergedActiveValueCells = [];
|
||||
var len = activeValueCells.length;
|
||||
var pathKeys = getFullPathKeys(options, fieldNames);
|
||||
|
||||
// Fill validate active value cells and index
|
||||
var _loop = function _loop(i) {
|
||||
// Mark the active index for current options
|
||||
var nextActiveIndex = currentOptions.findIndex(function (option, index) {
|
||||
return (pathKeys[index] ? toPathKey(pathKeys[index]) : option[fieldNames.value]) === activeValueCells[i];
|
||||
});
|
||||
if (nextActiveIndex === -1) {
|
||||
return 1; // break
|
||||
}
|
||||
activeIndex = nextActiveIndex;
|
||||
mergedActiveIndexes.push(activeIndex);
|
||||
mergedActiveValueCells.push(activeValueCells[i]);
|
||||
currentOptions = currentOptions[activeIndex][fieldNames.children];
|
||||
};
|
||||
for (var i = 0; i < len && currentOptions; i += 1) {
|
||||
if (_loop(i)) break;
|
||||
}
|
||||
|
||||
// Fill last active options
|
||||
var activeOptions = options;
|
||||
for (var _i = 0; _i < mergedActiveIndexes.length - 1; _i += 1) {
|
||||
activeOptions = activeOptions[mergedActiveIndexes[_i]][fieldNames.children];
|
||||
}
|
||||
return [mergedActiveValueCells, activeIndex, activeOptions, pathKeys];
|
||||
}, [activeValueCells, fieldNames, options]),
|
||||
_React$useMemo2 = _slicedToArray(_React$useMemo, 4),
|
||||
validActiveValueCells = _React$useMemo2[0],
|
||||
lastActiveIndex = _React$useMemo2[1],
|
||||
lastActiveOptions = _React$useMemo2[2],
|
||||
fullPathKeys = _React$useMemo2[3];
|
||||
|
||||
// Update active value cells and scroll to target element
|
||||
var internalSetActiveValueCells = function internalSetActiveValueCells(next) {
|
||||
setActiveValueCells(next);
|
||||
};
|
||||
|
||||
// Same options offset
|
||||
var offsetActiveOption = function offsetActiveOption(offset) {
|
||||
var len = lastActiveOptions.length;
|
||||
var currentIndex = lastActiveIndex;
|
||||
if (currentIndex === -1 && offset < 0) {
|
||||
currentIndex = len;
|
||||
}
|
||||
for (var i = 0; i < len; i += 1) {
|
||||
currentIndex = (currentIndex + offset + len) % len;
|
||||
var _option = lastActiveOptions[currentIndex];
|
||||
if (_option && !_option.disabled) {
|
||||
var nextActiveCells = validActiveValueCells.slice(0, -1).concat(fullPathKeys[currentIndex] ? toPathKey(fullPathKeys[currentIndex]) : _option[fieldNames.value]);
|
||||
internalSetActiveValueCells(nextActiveCells);
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Different options offset
|
||||
var prevColumn = function prevColumn() {
|
||||
if (validActiveValueCells.length > 1) {
|
||||
var nextActiveCells = validActiveValueCells.slice(0, -1);
|
||||
internalSetActiveValueCells(nextActiveCells);
|
||||
} else {
|
||||
toggleOpen(false);
|
||||
}
|
||||
};
|
||||
var nextColumn = function nextColumn() {
|
||||
var _lastActiveOptions$la;
|
||||
var nextOptions = ((_lastActiveOptions$la = lastActiveOptions[lastActiveIndex]) === null || _lastActiveOptions$la === void 0 ? void 0 : _lastActiveOptions$la[fieldNames.children]) || [];
|
||||
var nextOption = nextOptions.find(function (option) {
|
||||
return !option.disabled;
|
||||
});
|
||||
if (nextOption) {
|
||||
var nextActiveCells = [].concat(_toConsumableArray(validActiveValueCells), [nextOption[fieldNames.value]]);
|
||||
internalSetActiveValueCells(nextActiveCells);
|
||||
}
|
||||
};
|
||||
React.useImperativeHandle(ref, function () {
|
||||
return {
|
||||
// scrollTo: treeRef.current?.scrollTo,
|
||||
onKeyDown: function onKeyDown(event) {
|
||||
var which = event.which;
|
||||
switch (which) {
|
||||
// >>> Arrow keys
|
||||
case KeyCode.UP:
|
||||
case KeyCode.DOWN:
|
||||
{
|
||||
var offset = 0;
|
||||
if (which === KeyCode.UP) {
|
||||
offset = -1;
|
||||
} else if (which === KeyCode.DOWN) {
|
||||
offset = 1;
|
||||
}
|
||||
if (offset !== 0) {
|
||||
offsetActiveOption(offset);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case KeyCode.LEFT:
|
||||
{
|
||||
if (searchValue) {
|
||||
break;
|
||||
}
|
||||
if (rtl) {
|
||||
nextColumn();
|
||||
} else {
|
||||
prevColumn();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case KeyCode.RIGHT:
|
||||
{
|
||||
if (searchValue) {
|
||||
break;
|
||||
}
|
||||
if (rtl) {
|
||||
prevColumn();
|
||||
} else {
|
||||
nextColumn();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case KeyCode.BACKSPACE:
|
||||
{
|
||||
if (!searchValue) {
|
||||
prevColumn();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// >>> Select
|
||||
case KeyCode.ENTER:
|
||||
{
|
||||
if (validActiveValueCells.length) {
|
||||
var _option2 = lastActiveOptions[lastActiveIndex];
|
||||
|
||||
// Search option should revert back of origin options
|
||||
var originOptions = (_option2 === null || _option2 === void 0 ? void 0 : _option2[SEARCH_MARK]) || [];
|
||||
if (originOptions.length) {
|
||||
onKeyBoardSelect(originOptions.map(function (opt) {
|
||||
return opt[fieldNames.value];
|
||||
}), originOptions[originOptions.length - 1]);
|
||||
} else {
|
||||
onKeyBoardSelect(validActiveValueCells, lastActiveOptions[lastActiveIndex]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// >>> Close
|
||||
case KeyCode.ESC:
|
||||
{
|
||||
toggleOpen(false);
|
||||
if (open) {
|
||||
event.stopPropagation();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
onKeyUp: function onKeyUp() {}
|
||||
};
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user