add all frontend files

This commit is contained in:
2026-01-17 15:16:36 -05:00
parent ff16ae7858
commit e40287e4aa
25704 changed files with 1935289 additions and 0 deletions

95
node_modules/rc-cascader/es/Cascader.d.ts generated vendored Normal file
View File

@@ -0,0 +1,95 @@
import type { BuildInPlacements } from '@rc-component/trigger/lib/interface';
import type { BaseSelectPropsWithoutPrivate, BaseSelectRef } from 'rc-select';
import type { Placement } from 'rc-select/lib/BaseSelect';
import * as React from 'react';
import Panel from './Panel';
import { SHOW_CHILD, SHOW_PARENT } from './utils/commonUtil';
export interface BaseOptionType {
disabled?: boolean;
disableCheckbox?: boolean;
label?: React.ReactNode;
value?: string | number | null;
children?: DefaultOptionType[];
}
export type DefaultOptionType = BaseOptionType & Record<string, any>;
export interface ShowSearchType<OptionType extends DefaultOptionType = DefaultOptionType, ValueField extends keyof OptionType = keyof OptionType> {
filter?: (inputValue: string, options: OptionType[], fieldNames: FieldNames<OptionType, ValueField>) => boolean;
render?: (inputValue: string, path: OptionType[], prefixCls: string, fieldNames: FieldNames<OptionType, ValueField>) => React.ReactNode;
sort?: (a: OptionType[], b: OptionType[], inputValue: string, fieldNames: FieldNames<OptionType, ValueField>) => number;
matchInputWidth?: boolean;
limit?: number | false;
}
export type ShowCheckedStrategy = typeof SHOW_PARENT | typeof SHOW_CHILD;
interface BaseCascaderProps<OptionType extends DefaultOptionType = DefaultOptionType, ValueField extends keyof OptionType = keyof OptionType> extends Omit<BaseSelectPropsWithoutPrivate, 'tokenSeparators' | 'labelInValue' | 'mode' | 'showSearch'> {
id?: string;
prefixCls?: string;
fieldNames?: FieldNames<OptionType, ValueField>;
optionRender?: (option: OptionType) => React.ReactNode;
children?: React.ReactElement;
changeOnSelect?: boolean;
displayRender?: (label: string[], selectedOptions?: OptionType[]) => React.ReactNode;
checkable?: boolean | React.ReactNode;
showCheckedStrategy?: ShowCheckedStrategy;
autoClearSearchValue?: boolean;
showSearch?: boolean | ShowSearchType<OptionType>;
searchValue?: string;
onSearch?: (value: string) => void;
expandTrigger?: 'hover' | 'click';
options?: OptionType[];
/** @private Internal usage. Do not use in your production. */
dropdownPrefixCls?: string;
loadData?: (selectOptions: OptionType[]) => void;
/** @deprecated Use `open` instead */
popupVisible?: boolean;
/** @deprecated Use `dropdownClassName` instead */
popupClassName?: string;
dropdownClassName?: string;
dropdownMenuColumnStyle?: React.CSSProperties;
/** @deprecated Use `placement` instead */
popupPlacement?: Placement;
placement?: Placement;
builtinPlacements?: BuildInPlacements;
/** @deprecated Use `onOpenChange` instead */
onPopupVisibleChange?: (open: boolean) => void;
/** @deprecated Use `onOpenChange` instead */
onDropdownVisibleChange?: (open: boolean) => void;
onOpenChange?: (open: boolean) => void;
expandIcon?: React.ReactNode;
loadingIcon?: React.ReactNode;
}
export interface FieldNames<OptionType extends DefaultOptionType = DefaultOptionType, ValueField extends keyof OptionType = keyof OptionType> {
label?: keyof OptionType;
value?: keyof OptionType | ValueField;
children?: keyof OptionType;
}
export type ValueType<OptionType extends DefaultOptionType = DefaultOptionType, ValueField extends keyof OptionType = keyof OptionType> = keyof OptionType extends ValueField ? unknown extends OptionType['value'] ? OptionType[ValueField] : OptionType['value'] : OptionType[ValueField];
export type GetValueType<OptionType extends DefaultOptionType = DefaultOptionType, ValueField extends keyof OptionType = keyof OptionType, Multiple extends boolean | React.ReactNode = false> = false extends Multiple ? ValueType<Required<OptionType>, ValueField>[] : ValueType<Required<OptionType>, ValueField>[][];
export type GetOptionType<OptionType extends DefaultOptionType = DefaultOptionType, Multiple extends boolean | React.ReactNode = false> = false extends Multiple ? OptionType[] : OptionType[][];
export interface CascaderProps<OptionType extends DefaultOptionType = DefaultOptionType, ValueField extends keyof OptionType = keyof OptionType, Multiple extends boolean | React.ReactNode = false> extends BaseCascaderProps<OptionType, ValueField> {
checkable?: Multiple;
value?: GetValueType<OptionType, ValueField, Multiple>;
defaultValue?: GetValueType<OptionType, ValueField, Multiple>;
onChange?: (value: GetValueType<OptionType, ValueField, Multiple>, selectOptions: GetOptionType<OptionType, Multiple>) => void;
}
export type SingleValueType = (string | number)[];
export type InternalValueType = SingleValueType | SingleValueType[];
export interface InternalFieldNames extends Required<FieldNames> {
key: string;
}
export type InternalCascaderProps = Omit<CascaderProps, 'onChange' | 'value' | 'defaultValue'> & {
value?: InternalValueType;
defaultValue?: InternalValueType;
onChange?: (value: InternalValueType, selectOptions: BaseOptionType[] | BaseOptionType[][]) => void;
};
export type CascaderRef = Omit<BaseSelectRef, 'scrollTo'>;
declare const Cascader: (<OptionType extends DefaultOptionType = DefaultOptionType, ValueField extends keyof OptionType = keyof OptionType, Multiple extends React.ReactNode = false>(props: CascaderProps<OptionType, ValueField, Multiple> & {
children?: React.ReactNode;
} & {
ref?: React.Ref<CascaderRef> | undefined;
}) => React.ReactElement) & {
displayName?: string | undefined;
SHOW_PARENT: typeof SHOW_PARENT;
SHOW_CHILD: typeof SHOW_CHILD;
Panel: typeof Panel;
};
export default Cascader;

261
node_modules/rc-cascader/es/Cascader.js generated vendored Normal file
View File

@@ -0,0 +1,261 @@
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
var _excluded = ["id", "prefixCls", "fieldNames", "defaultValue", "value", "changeOnSelect", "onChange", "displayRender", "checkable", "autoClearSearchValue", "searchValue", "onSearch", "showSearch", "expandTrigger", "options", "dropdownPrefixCls", "loadData", "popupVisible", "open", "popupClassName", "dropdownClassName", "dropdownMenuColumnStyle", "dropdownStyle", "popupPlacement", "placement", "onDropdownVisibleChange", "onPopupVisibleChange", "onOpenChange", "expandIcon", "loadingIcon", "children", "dropdownMatchSelectWidth", "showCheckedStrategy", "optionRender"];
import { BaseSelect } from 'rc-select';
import useId from "rc-select/es/hooks/useId";
import useEvent from "rc-util/es/hooks/useEvent";
import useMergedState from "rc-util/es/hooks/useMergedState";
import * as React from 'react';
import CascaderContext from "./context";
import useDisplayValues from "./hooks/useDisplayValues";
import useMissingValues from "./hooks/useMissingValues";
import useOptions from "./hooks/useOptions";
import useSearchConfig from "./hooks/useSearchConfig";
import useSearchOptions from "./hooks/useSearchOptions";
import useSelect from "./hooks/useSelect";
import useValues from "./hooks/useValues";
import OptionList from "./OptionList";
import Panel from "./Panel";
import { fillFieldNames, SHOW_CHILD, SHOW_PARENT, toPathKeys, toRawValues } from "./utils/commonUtil";
import { formatStrategyValues, toPathOptions } from "./utils/treeUtil";
import warningProps, { warningNullOptions } from "./utils/warningPropsUtil";
var Cascader = /*#__PURE__*/React.forwardRef(function (props, ref) {
var id = props.id,
_props$prefixCls = props.prefixCls,
prefixCls = _props$prefixCls === void 0 ? 'rc-cascader' : _props$prefixCls,
fieldNames = props.fieldNames,
defaultValue = props.defaultValue,
value = props.value,
changeOnSelect = props.changeOnSelect,
onChange = props.onChange,
displayRender = props.displayRender,
checkable = props.checkable,
_props$autoClearSearc = props.autoClearSearchValue,
autoClearSearchValue = _props$autoClearSearc === void 0 ? true : _props$autoClearSearc,
searchValue = props.searchValue,
onSearch = props.onSearch,
showSearch = props.showSearch,
expandTrigger = props.expandTrigger,
options = props.options,
dropdownPrefixCls = props.dropdownPrefixCls,
loadData = props.loadData,
popupVisible = props.popupVisible,
open = props.open,
popupClassName = props.popupClassName,
dropdownClassName = props.dropdownClassName,
dropdownMenuColumnStyle = props.dropdownMenuColumnStyle,
customDropdownStyle = props.dropdownStyle,
popupPlacement = props.popupPlacement,
placement = props.placement,
onDropdownVisibleChange = props.onDropdownVisibleChange,
onPopupVisibleChange = props.onPopupVisibleChange,
onOpenChange = props.onOpenChange,
_props$expandIcon = props.expandIcon,
expandIcon = _props$expandIcon === void 0 ? '>' : _props$expandIcon,
loadingIcon = props.loadingIcon,
children = props.children,
_props$dropdownMatchS = props.dropdownMatchSelectWidth,
dropdownMatchSelectWidth = _props$dropdownMatchS === void 0 ? false : _props$dropdownMatchS,
_props$showCheckedStr = props.showCheckedStrategy,
showCheckedStrategy = _props$showCheckedStr === void 0 ? SHOW_PARENT : _props$showCheckedStr,
optionRender = props.optionRender,
restProps = _objectWithoutProperties(props, _excluded);
var mergedId = useId(id);
var multiple = !!checkable;
// =========================== Values ===========================
var _useMergedState = useMergedState(defaultValue, {
value: value,
postState: toRawValues
}),
_useMergedState2 = _slicedToArray(_useMergedState, 2),
rawValues = _useMergedState2[0],
setRawValues = _useMergedState2[1];
// ========================= FieldNames =========================
var mergedFieldNames = React.useMemo(function () {
return fillFieldNames(fieldNames);
}, /* eslint-disable react-hooks/exhaustive-deps */
[JSON.stringify(fieldNames)]
/* eslint-enable react-hooks/exhaustive-deps */);
// =========================== Option ===========================
var _useOptions = useOptions(mergedFieldNames, options),
_useOptions2 = _slicedToArray(_useOptions, 3),
mergedOptions = _useOptions2[0],
getPathKeyEntities = _useOptions2[1],
getValueByKeyPath = _useOptions2[2];
// =========================== Search ===========================
var _useMergedState3 = useMergedState('', {
value: searchValue,
postState: function postState(search) {
return search || '';
}
}),
_useMergedState4 = _slicedToArray(_useMergedState3, 2),
mergedSearchValue = _useMergedState4[0],
setSearchValue = _useMergedState4[1];
var onInternalSearch = function onInternalSearch(searchText, info) {
setSearchValue(searchText);
if (info.source !== 'blur' && onSearch) {
onSearch(searchText);
}
};
var _useSearchConfig = useSearchConfig(showSearch),
_useSearchConfig2 = _slicedToArray(_useSearchConfig, 2),
mergedShowSearch = _useSearchConfig2[0],
searchConfig = _useSearchConfig2[1];
var searchOptions = useSearchOptions(mergedSearchValue, mergedOptions, mergedFieldNames, dropdownPrefixCls || prefixCls, searchConfig, changeOnSelect || multiple);
// =========================== Values ===========================
var getMissingValues = useMissingValues(mergedOptions, mergedFieldNames);
// Fill `rawValues` with checked conduction values
var _useValues = useValues(multiple, rawValues, getPathKeyEntities, getValueByKeyPath, getMissingValues),
_useValues2 = _slicedToArray(_useValues, 3),
checkedValues = _useValues2[0],
halfCheckedValues = _useValues2[1],
missingCheckedValues = _useValues2[2];
var deDuplicatedValues = React.useMemo(function () {
var checkedKeys = toPathKeys(checkedValues);
var deduplicateKeys = formatStrategyValues(checkedKeys, getPathKeyEntities, showCheckedStrategy);
return [].concat(_toConsumableArray(missingCheckedValues), _toConsumableArray(getValueByKeyPath(deduplicateKeys)));
}, [checkedValues, getPathKeyEntities, getValueByKeyPath, missingCheckedValues, showCheckedStrategy]);
var displayValues = useDisplayValues(deDuplicatedValues, mergedOptions, mergedFieldNames, multiple, displayRender);
// =========================== Change ===========================
var triggerChange = useEvent(function (nextValues) {
setRawValues(nextValues);
// Save perf if no need trigger event
if (onChange) {
var nextRawValues = toRawValues(nextValues);
var valueOptions = nextRawValues.map(function (valueCells) {
return toPathOptions(valueCells, mergedOptions, mergedFieldNames).map(function (valueOpt) {
return valueOpt.option;
});
});
var triggerValues = multiple ? nextRawValues : nextRawValues[0];
var triggerOptions = multiple ? valueOptions : valueOptions[0];
onChange(triggerValues, triggerOptions);
}
});
// =========================== Select ===========================
var handleSelection = useSelect(multiple, triggerChange, checkedValues, halfCheckedValues, missingCheckedValues, getPathKeyEntities, getValueByKeyPath, showCheckedStrategy);
var onInternalSelect = useEvent(function (valuePath) {
if (!multiple || autoClearSearchValue) {
setSearchValue('');
}
handleSelection(valuePath);
});
// Display Value change logic
var onDisplayValuesChange = function onDisplayValuesChange(_, info) {
if (info.type === 'clear') {
triggerChange([]);
return;
}
// Cascader do not support `add` type. Only support `remove`
var _ref = info.values[0],
valueCells = _ref.valueCells;
onInternalSelect(valueCells);
};
// ============================ Open ============================
var mergedOpen = open !== undefined ? open : popupVisible;
var mergedDropdownClassName = dropdownClassName || popupClassName;
var mergedPlacement = placement || popupPlacement;
var onInternalDropdownVisibleChange = function onInternalDropdownVisibleChange(nextVisible) {
onOpenChange === null || onOpenChange === void 0 || onOpenChange(nextVisible);
onDropdownVisibleChange === null || onDropdownVisibleChange === void 0 || onDropdownVisibleChange(nextVisible);
onPopupVisibleChange === null || onPopupVisibleChange === void 0 || onPopupVisibleChange(nextVisible);
};
// ========================== Warning ===========================
if (process.env.NODE_ENV !== 'production') {
warningProps(props);
warningNullOptions(mergedOptions, mergedFieldNames);
}
// ========================== Context ===========================
var cascaderContext = React.useMemo(function () {
return {
options: mergedOptions,
fieldNames: mergedFieldNames,
values: checkedValues,
halfValues: halfCheckedValues,
changeOnSelect: changeOnSelect,
onSelect: onInternalSelect,
checkable: checkable,
searchOptions: searchOptions,
dropdownPrefixCls: dropdownPrefixCls,
loadData: loadData,
expandTrigger: expandTrigger,
expandIcon: expandIcon,
loadingIcon: loadingIcon,
dropdownMenuColumnStyle: dropdownMenuColumnStyle,
optionRender: optionRender
};
}, [mergedOptions, mergedFieldNames, checkedValues, halfCheckedValues, changeOnSelect, onInternalSelect, checkable, searchOptions, dropdownPrefixCls, loadData, expandTrigger, expandIcon, loadingIcon, dropdownMenuColumnStyle, optionRender]);
// ==============================================================
// == Render ==
// ==============================================================
var emptyOptions = !(mergedSearchValue ? searchOptions : mergedOptions).length;
var dropdownStyle =
// Search to match width
mergedSearchValue && searchConfig.matchInputWidth ||
// Empty keep the width
emptyOptions ? {} : {
minWidth: 'auto'
};
return /*#__PURE__*/React.createElement(CascaderContext.Provider, {
value: cascaderContext
}, /*#__PURE__*/React.createElement(BaseSelect, _extends({}, restProps, {
// MISC
ref: ref,
id: mergedId,
prefixCls: prefixCls,
autoClearSearchValue: autoClearSearchValue,
dropdownMatchSelectWidth: dropdownMatchSelectWidth,
dropdownStyle: _objectSpread(_objectSpread({}, dropdownStyle), customDropdownStyle)
// Value
,
displayValues: displayValues,
onDisplayValuesChange: onDisplayValuesChange,
mode: multiple ? 'multiple' : undefined
// Search
,
searchValue: mergedSearchValue,
onSearch: onInternalSearch,
showSearch: mergedShowSearch
// Options
,
OptionList: OptionList,
emptyOptions: emptyOptions
// Open
,
open: mergedOpen,
dropdownClassName: mergedDropdownClassName,
placement: mergedPlacement,
onDropdownVisibleChange: onInternalDropdownVisibleChange
// Children
,
getRawInputElement: function getRawInputElement() {
return children;
}
})));
});
if (process.env.NODE_ENV !== 'production') {
Cascader.displayName = 'Cascader';
}
Cascader.SHOW_PARENT = SHOW_PARENT;
Cascader.SHOW_CHILD = SHOW_CHILD;
Cascader.Panel = Panel;
export default Cascader;

View 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
node_modules/rc-cascader/es/OptionList/CacheContent.js generated vendored Normal file
View 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
node_modules/rc-cascader/es/OptionList/Checkbox.d.ts generated vendored Normal file
View 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
node_modules/rc-cascader/es/OptionList/Checkbox.js generated vendored Normal file
View 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
node_modules/rc-cascader/es/OptionList/Column.d.ts generated vendored Normal file
View 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
node_modules/rc-cascader/es/OptionList/Column.js generated vendored Normal file
View 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
node_modules/rc-cascader/es/OptionList/List.d.ts generated vendored Normal file
View 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
node_modules/rc-cascader/es/OptionList/List.js generated vendored Normal file
View 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
node_modules/rc-cascader/es/OptionList/index.d.ts generated vendored Normal file
View 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
node_modules/rc-cascader/es/OptionList/index.js generated vendored Normal file
View 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;

View 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
node_modules/rc-cascader/es/OptionList/useActive.js generated vendored Normal file
View 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;

View 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
node_modules/rc-cascader/es/OptionList/useKeyboard.js generated vendored Normal file
View 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() {}
};
});
});

5
node_modules/rc-cascader/es/Panel.d.ts generated vendored Normal file
View File

@@ -0,0 +1,5 @@
import * as React from 'react';
import type { CascaderProps, DefaultOptionType } from './Cascader';
export type PickType = 'value' | 'defaultValue' | 'changeOnSelect' | 'onChange' | 'options' | 'prefixCls' | 'checkable' | 'fieldNames' | 'showCheckedStrategy' | 'loadData' | 'expandTrigger' | 'expandIcon' | 'loadingIcon' | 'className' | 'style' | 'direction' | 'notFoundContent' | 'disabled';
export type PanelProps<OptionType extends DefaultOptionType = DefaultOptionType, ValueField extends keyof OptionType = keyof OptionType, Multiple extends boolean | React.ReactNode = false> = Pick<CascaderProps<OptionType, ValueField, Multiple>, PickType>;
export default function Panel<OptionType extends DefaultOptionType = DefaultOptionType, ValueField extends keyof OptionType = keyof OptionType, Multiple extends boolean | React.ReactNode = false>(props: PanelProps<OptionType, ValueField, Multiple>): React.JSX.Element;

137
node_modules/rc-cascader/es/Panel.js generated vendored Normal file
View File

@@ -0,0 +1,137 @@
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
import classNames from 'classnames';
import { useEvent, useMergedState } from 'rc-util';
import * as React from 'react';
import CascaderContext from "./context";
import useMissingValues from "./hooks/useMissingValues";
import useOptions from "./hooks/useOptions";
import useSelect from "./hooks/useSelect";
import useValues from "./hooks/useValues";
import RawOptionList from "./OptionList/List";
import { fillFieldNames, toRawValues } from "./utils/commonUtil";
import { toPathOptions } from "./utils/treeUtil";
function noop() {}
export default function Panel(props) {
var _classNames;
var _ref = props,
_ref$prefixCls = _ref.prefixCls,
prefixCls = _ref$prefixCls === void 0 ? 'rc-cascader' : _ref$prefixCls,
style = _ref.style,
className = _ref.className,
options = _ref.options,
checkable = _ref.checkable,
defaultValue = _ref.defaultValue,
value = _ref.value,
fieldNames = _ref.fieldNames,
changeOnSelect = _ref.changeOnSelect,
onChange = _ref.onChange,
showCheckedStrategy = _ref.showCheckedStrategy,
loadData = _ref.loadData,
expandTrigger = _ref.expandTrigger,
_ref$expandIcon = _ref.expandIcon,
expandIcon = _ref$expandIcon === void 0 ? '>' : _ref$expandIcon,
loadingIcon = _ref.loadingIcon,
direction = _ref.direction,
_ref$notFoundContent = _ref.notFoundContent,
notFoundContent = _ref$notFoundContent === void 0 ? 'Not Found' : _ref$notFoundContent,
disabled = _ref.disabled;
// ======================== Multiple ========================
var multiple = !!checkable;
// ========================= Values =========================
var _useMergedState = useMergedState(defaultValue, {
value: value,
postState: toRawValues
}),
_useMergedState2 = _slicedToArray(_useMergedState, 2),
rawValues = _useMergedState2[0],
setRawValues = _useMergedState2[1];
// ========================= FieldNames =========================
var mergedFieldNames = React.useMemo(function () {
return fillFieldNames(fieldNames);
}, /* eslint-disable react-hooks/exhaustive-deps */
[JSON.stringify(fieldNames)]
/* eslint-enable react-hooks/exhaustive-deps */);
// =========================== Option ===========================
var _useOptions = useOptions(mergedFieldNames, options),
_useOptions2 = _slicedToArray(_useOptions, 3),
mergedOptions = _useOptions2[0],
getPathKeyEntities = _useOptions2[1],
getValueByKeyPath = _useOptions2[2];
// ========================= Values =========================
var getMissingValues = useMissingValues(mergedOptions, mergedFieldNames);
// Fill `rawValues` with checked conduction values
var _useValues = useValues(multiple, rawValues, getPathKeyEntities, getValueByKeyPath, getMissingValues),
_useValues2 = _slicedToArray(_useValues, 3),
checkedValues = _useValues2[0],
halfCheckedValues = _useValues2[1],
missingCheckedValues = _useValues2[2];
// =========================== Change ===========================
var triggerChange = useEvent(function (nextValues) {
setRawValues(nextValues);
// Save perf if no need trigger event
if (onChange) {
var nextRawValues = toRawValues(nextValues);
var valueOptions = nextRawValues.map(function (valueCells) {
return toPathOptions(valueCells, mergedOptions, mergedFieldNames).map(function (valueOpt) {
return valueOpt.option;
});
});
var triggerValues = multiple ? nextRawValues : nextRawValues[0];
var triggerOptions = multiple ? valueOptions : valueOptions[0];
onChange(triggerValues, triggerOptions);
}
});
// =========================== Select ===========================
var handleSelection = useSelect(multiple, triggerChange, checkedValues, halfCheckedValues, missingCheckedValues, getPathKeyEntities, getValueByKeyPath, showCheckedStrategy);
var onInternalSelect = useEvent(function (valuePath) {
handleSelection(valuePath);
});
// ======================== Context =========================
var cascaderContext = React.useMemo(function () {
return {
options: mergedOptions,
fieldNames: mergedFieldNames,
values: checkedValues,
halfValues: halfCheckedValues,
changeOnSelect: changeOnSelect,
onSelect: onInternalSelect,
checkable: checkable,
searchOptions: [],
dropdownPrefixCls: undefined,
loadData: loadData,
expandTrigger: expandTrigger,
expandIcon: expandIcon,
loadingIcon: loadingIcon,
dropdownMenuColumnStyle: undefined
};
}, [mergedOptions, mergedFieldNames, checkedValues, halfCheckedValues, changeOnSelect, onInternalSelect, checkable, loadData, expandTrigger, expandIcon, loadingIcon]);
// ========================= Render =========================
var panelPrefixCls = "".concat(prefixCls, "-panel");
var isEmpty = !mergedOptions.length;
return /*#__PURE__*/React.createElement(CascaderContext.Provider, {
value: cascaderContext
}, /*#__PURE__*/React.createElement("div", {
className: classNames(panelPrefixCls, (_classNames = {}, _defineProperty(_classNames, "".concat(panelPrefixCls, "-rtl"), direction === 'rtl'), _defineProperty(_classNames, "".concat(panelPrefixCls, "-empty"), isEmpty), _classNames), className),
style: style
}, isEmpty ? notFoundContent : /*#__PURE__*/React.createElement(RawOptionList, {
prefixCls: prefixCls,
searchValue: "",
multiple: multiple,
toggleOpen: noop,
open: true,
direction: direction,
disabled: disabled
})));
}

21
node_modules/rc-cascader/es/context.d.ts generated vendored Normal file
View File

@@ -0,0 +1,21 @@
import * as React from 'react';
import type { CascaderProps, InternalFieldNames, DefaultOptionType, SingleValueType } from './Cascader';
export interface CascaderContextProps {
options: NonNullable<CascaderProps['options']>;
fieldNames: InternalFieldNames;
values: SingleValueType[];
halfValues: SingleValueType[];
changeOnSelect?: boolean;
onSelect: (valuePath: SingleValueType) => void;
checkable?: boolean | React.ReactNode;
searchOptions: DefaultOptionType[];
dropdownPrefixCls?: string;
loadData?: (selectOptions: DefaultOptionType[]) => void;
expandTrigger?: 'hover' | 'click';
expandIcon?: React.ReactNode;
loadingIcon?: React.ReactNode;
dropdownMenuColumnStyle?: React.CSSProperties;
optionRender?: CascaderProps['optionRender'];
}
declare const CascaderContext: React.Context<CascaderContextProps>;
export default CascaderContext;

3
node_modules/rc-cascader/es/context.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
import * as React from 'react';
var CascaderContext = /*#__PURE__*/React.createContext({});
export default CascaderContext;

View File

@@ -0,0 +1,10 @@
import * as React from 'react';
import type { DefaultOptionType, SingleValueType, CascaderProps, InternalFieldNames } from '../Cascader';
declare const _default: (rawValues: SingleValueType[], options: DefaultOptionType[], fieldNames: InternalFieldNames, multiple: boolean, displayRender: CascaderProps['displayRender']) => {
label: React.ReactNode;
value: string;
key: string;
valueCells: SingleValueType;
disabled: boolean | undefined;
}[];
export default _default;

52
node_modules/rc-cascader/es/hooks/useDisplayValues.js generated vendored Normal file
View File

@@ -0,0 +1,52 @@
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
import _typeof from "@babel/runtime/helpers/esm/typeof";
import { toPathOptions } from "../utils/treeUtil";
import * as React from 'react';
import { toPathKey } from "../utils/commonUtil";
export default (function (rawValues, options, fieldNames, multiple, displayRender) {
return React.useMemo(function () {
var mergedDisplayRender = displayRender ||
// Default displayRender
function (labels) {
var mergedLabels = multiple ? labels.slice(-1) : labels;
var SPLIT = ' / ';
if (mergedLabels.every(function (label) {
return ['string', 'number'].includes(_typeof(label));
})) {
return mergedLabels.join(SPLIT);
}
// If exist non-string value, use ReactNode instead
return mergedLabels.reduce(function (list, label, index) {
var keyedLabel = /*#__PURE__*/React.isValidElement(label) ? /*#__PURE__*/React.cloneElement(label, {
key: index
}) : label;
if (index === 0) {
return [keyedLabel];
}
return [].concat(_toConsumableArray(list), [SPLIT, keyedLabel]);
}, []);
};
return rawValues.map(function (valueCells) {
var _valueOptions;
var valueOptions = toPathOptions(valueCells, options, fieldNames);
var label = mergedDisplayRender(valueOptions.map(function (_ref) {
var _option$fieldNames$la;
var option = _ref.option,
value = _ref.value;
return (_option$fieldNames$la = option === null || option === void 0 ? void 0 : option[fieldNames.label]) !== null && _option$fieldNames$la !== void 0 ? _option$fieldNames$la : value;
}), valueOptions.map(function (_ref2) {
var option = _ref2.option;
return option;
}));
var value = toPathKey(valueCells);
return {
label: label,
value: value,
key: value,
valueCells: valueCells,
disabled: (_valueOptions = valueOptions[valueOptions.length - 1]) === null || _valueOptions === void 0 || (_valueOptions = _valueOptions.option) === null || _valueOptions === void 0 ? void 0 : _valueOptions.disabled
};
});
}, [rawValues, options, fieldNames, displayRender, multiple]);
});

10
node_modules/rc-cascader/es/hooks/useEntities.d.ts generated vendored Normal file
View File

@@ -0,0 +1,10 @@
import type { DefaultOptionType, InternalFieldNames } from '../Cascader';
import type { DataEntity } from 'rc-tree/lib/interface';
export interface OptionsInfo {
keyEntities: Record<string, DataEntity>;
pathKeyEntities: Record<string, DataEntity>;
}
export type GetEntities = () => OptionsInfo['pathKeyEntities'];
/** Lazy parse options data into conduct-able info to avoid perf issue in single mode */
declare const _default: (options: DefaultOptionType[], fieldNames: InternalFieldNames) => GetEntities;
export default _default;

39
node_modules/rc-cascader/es/hooks/useEntities.js generated vendored Normal file
View File

@@ -0,0 +1,39 @@
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import * as React from 'react';
import { convertDataToEntities } from "rc-tree/es/utils/treeUtil";
import { VALUE_SPLIT } from "../utils/commonUtil";
/** Lazy parse options data into conduct-able info to avoid perf issue in single mode */
export default (function (options, fieldNames) {
var cacheRef = React.useRef({
options: [],
info: {
keyEntities: {},
pathKeyEntities: {}
}
});
var getEntities = React.useCallback(function () {
if (cacheRef.current.options !== options) {
cacheRef.current.options = options;
cacheRef.current.info = convertDataToEntities(options, {
fieldNames: fieldNames,
initWrapper: function initWrapper(wrapper) {
return _objectSpread(_objectSpread({}, wrapper), {}, {
pathKeyEntities: {}
});
},
processEntity: function processEntity(entity, wrapper) {
var pathKey = entity.nodes.map(function (node) {
return node[fieldNames.value];
}).join(VALUE_SPLIT);
wrapper.pathKeyEntities[pathKey] = entity;
// Overwrite origin key.
// this is very hack but we need let conduct logic work with connect path
entity.key = pathKey;
}
});
}
return cacheRef.current.info.pathKeyEntities;
}, [fieldNames, options]);
return getEntities;
});

View File

@@ -0,0 +1,3 @@
import type { DefaultOptionType, InternalFieldNames, SingleValueType } from '../Cascader';
export type GetMissValues = ReturnType<typeof useMissingValues>;
export default function useMissingValues(options: DefaultOptionType[], fieldNames: InternalFieldNames): (rawValues: SingleValueType[]) => [SingleValueType[], SingleValueType[]];

19
node_modules/rc-cascader/es/hooks/useMissingValues.js generated vendored Normal file
View File

@@ -0,0 +1,19 @@
import * as React from 'react';
import { toPathOptions } from "../utils/treeUtil";
export default function useMissingValues(options, fieldNames) {
return React.useCallback(function (rawValues) {
var missingValues = [];
var existsValues = [];
rawValues.forEach(function (valueCell) {
var pathOptions = toPathOptions(valueCell, options, fieldNames);
if (pathOptions.every(function (opt) {
return opt.option;
})) {
existsValues.push(valueCell);
} else {
missingValues.push(valueCell);
}
});
return [existsValues, missingValues];
}, [options, fieldNames]);
}

9
node_modules/rc-cascader/es/hooks/useOptions.d.ts generated vendored Normal file
View File

@@ -0,0 +1,9 @@
import * as React from 'react';
import type { DefaultOptionType } from '..';
import type { InternalFieldNames, SingleValueType } from '../Cascader';
import { type GetEntities } from './useEntities';
export default function useOptions(mergedFieldNames: InternalFieldNames, options?: DefaultOptionType[]): [
mergedOptions: DefaultOptionType[],
getPathKeyEntities: GetEntities,
getValueByKeyPath: (pathKeys: React.Key[]) => SingleValueType[]
];

22
node_modules/rc-cascader/es/hooks/useOptions.js generated vendored Normal file
View File

@@ -0,0 +1,22 @@
import * as React from 'react';
import useEntities from "./useEntities";
export default function useOptions(mergedFieldNames, options) {
var mergedOptions = React.useMemo(function () {
return options || [];
}, [options]);
// Only used in multiple mode, this fn will not call in single mode
var getPathKeyEntities = useEntities(mergedOptions, mergedFieldNames);
/** Convert path key back to value format */
var getValueByKeyPath = React.useCallback(function (pathKeys) {
var keyPathEntities = getPathKeyEntities();
return pathKeys.map(function (pathKey) {
var nodes = keyPathEntities[pathKey].nodes;
return nodes.map(function (node) {
return node[mergedFieldNames.value];
});
});
}, [getPathKeyEntities, mergedFieldNames]);
return [mergedOptions, getPathKeyEntities, getValueByKeyPath];
}

View File

@@ -0,0 +1,2 @@
import type { CascaderProps, ShowSearchType } from '../Cascader';
export default function useSearchConfig(showSearch?: CascaderProps['showSearch']): [boolean, ShowSearchType<import("../Cascader").DefaultOptionType, string>];

26
node_modules/rc-cascader/es/hooks/useSearchConfig.js generated vendored Normal file
View File

@@ -0,0 +1,26 @@
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _typeof from "@babel/runtime/helpers/esm/typeof";
import warning from "rc-util/es/warning";
import * as React from 'react';
// Convert `showSearch` to unique config
export default function useSearchConfig(showSearch) {
return React.useMemo(function () {
if (!showSearch) {
return [false, {}];
}
var searchConfig = {
matchInputWidth: true,
limit: 50
};
if (showSearch && _typeof(showSearch) === 'object') {
searchConfig = _objectSpread(_objectSpread({}, searchConfig), showSearch);
}
if (searchConfig.limit <= 0) {
searchConfig.limit = false;
if (process.env.NODE_ENV !== 'production') {
warning(false, "'limit' of showSearch should be positive number or false.");
}
}
return [true, searchConfig];
}, [showSearch]);
}

View File

@@ -0,0 +1,4 @@
import type { DefaultOptionType, InternalFieldNames, ShowSearchType } from '../Cascader';
export declare const SEARCH_MARK = "__rc_cascader_search_mark__";
declare const useSearchOptions: (search: string, options: DefaultOptionType[], fieldNames: InternalFieldNames, prefixCls: string, config: ShowSearchType, enableHalfPath?: boolean) => DefaultOptionType[];
export default useSearchOptions;

73
node_modules/rc-cascader/es/hooks/useSearchOptions.js generated vendored Normal file
View File

@@ -0,0 +1,73 @@
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
import * as React from 'react';
export var SEARCH_MARK = '__rc_cascader_search_mark__';
var defaultFilter = function defaultFilter(search, options, _ref) {
var _ref$label = _ref.label,
label = _ref$label === void 0 ? '' : _ref$label;
return options.some(function (opt) {
return String(opt[label]).toLowerCase().includes(search.toLowerCase());
});
};
var defaultRender = function defaultRender(inputValue, path, prefixCls, fieldNames) {
return path.map(function (opt) {
return opt[fieldNames.label];
}).join(' / ');
};
var useSearchOptions = function useSearchOptions(search, options, fieldNames, prefixCls, config, enableHalfPath) {
var _config$filter = config.filter,
filter = _config$filter === void 0 ? defaultFilter : _config$filter,
_config$render = config.render,
render = _config$render === void 0 ? defaultRender : _config$render,
_config$limit = config.limit,
limit = _config$limit === void 0 ? 50 : _config$limit,
sort = config.sort;
return React.useMemo(function () {
var filteredOptions = [];
if (!search) {
return [];
}
function dig(list, pathOptions) {
var parentDisabled = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
list.forEach(function (option) {
// Perf saving when `sort` is disabled and `limit` is provided
if (!sort && limit !== false && limit > 0 && filteredOptions.length >= limit) {
return;
}
var connectedPathOptions = [].concat(_toConsumableArray(pathOptions), [option]);
var children = option[fieldNames.children];
var mergedDisabled = parentDisabled || option.disabled;
// If current option is filterable
if (
// If is leaf option
!children || children.length === 0 ||
// If is changeOnSelect or multiple
enableHalfPath) {
if (filter(search, connectedPathOptions, {
label: fieldNames.label
})) {
var _objectSpread2;
filteredOptions.push(_objectSpread(_objectSpread({}, option), {}, (_objectSpread2 = {
disabled: mergedDisabled
}, _defineProperty(_objectSpread2, fieldNames.label, render(search, connectedPathOptions, prefixCls, fieldNames)), _defineProperty(_objectSpread2, SEARCH_MARK, connectedPathOptions), _defineProperty(_objectSpread2, fieldNames.children, undefined), _objectSpread2)));
}
}
if (children) {
dig(option[fieldNames.children], connectedPathOptions, mergedDisabled);
}
});
}
dig(options, []);
// Do sort
if (sort) {
filteredOptions.sort(function (a, b) {
return sort(a[SEARCH_MARK], b[SEARCH_MARK], search, fieldNames);
});
}
return limit !== false && limit > 0 ? filteredOptions.slice(0, limit) : filteredOptions;
}, [search, options, fieldNames, prefixCls, render, enableHalfPath, filter, sort, limit]);
};
export default useSearchOptions;

4
node_modules/rc-cascader/es/hooks/useSelect.d.ts generated vendored Normal file
View File

@@ -0,0 +1,4 @@
/// <reference types="react" />
import type { InternalValueType, ShowCheckedStrategy, SingleValueType } from '../Cascader';
import type { GetEntities } from './useEntities';
export default function useSelect(multiple: boolean, triggerChange: (nextValues: InternalValueType) => void, checkedValues: SingleValueType[], halfCheckedValues: SingleValueType[], missingCheckedValues: SingleValueType[], getPathKeyEntities: GetEntities, getValueByKeyPath: (pathKeys: React.Key[]) => SingleValueType[], showCheckedStrategy?: ShowCheckedStrategy): (valuePath: SingleValueType) => void;

54
node_modules/rc-cascader/es/hooks/useSelect.js generated vendored Normal file
View File

@@ -0,0 +1,54 @@
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
import { conductCheck } from "rc-tree/es/utils/conductUtil";
import { toPathKey, toPathKeys } from "../utils/commonUtil";
import { formatStrategyValues } from "../utils/treeUtil";
export default function useSelect(multiple, triggerChange, checkedValues, halfCheckedValues, missingCheckedValues, getPathKeyEntities, getValueByKeyPath, showCheckedStrategy) {
return function (valuePath) {
if (!multiple) {
triggerChange(valuePath);
} else {
// Prepare conduct required info
var pathKey = toPathKey(valuePath);
var checkedPathKeys = toPathKeys(checkedValues);
var halfCheckedPathKeys = toPathKeys(halfCheckedValues);
var existInChecked = checkedPathKeys.includes(pathKey);
var existInMissing = missingCheckedValues.some(function (valueCells) {
return toPathKey(valueCells) === pathKey;
});
// Do update
var nextCheckedValues = checkedValues;
var nextMissingValues = missingCheckedValues;
if (existInMissing && !existInChecked) {
// Missing value only do filter
nextMissingValues = missingCheckedValues.filter(function (valueCells) {
return toPathKey(valueCells) !== pathKey;
});
} else {
// Update checked key first
var nextRawCheckedKeys = existInChecked ? checkedPathKeys.filter(function (key) {
return key !== pathKey;
}) : [].concat(_toConsumableArray(checkedPathKeys), [pathKey]);
var pathKeyEntities = getPathKeyEntities();
// Conduction by selected or not
var checkedKeys;
if (existInChecked) {
var _conductCheck = conductCheck(nextRawCheckedKeys, {
checked: false,
halfCheckedKeys: halfCheckedPathKeys
}, pathKeyEntities);
checkedKeys = _conductCheck.checkedKeys;
} else {
var _conductCheck2 = conductCheck(nextRawCheckedKeys, true, pathKeyEntities);
checkedKeys = _conductCheck2.checkedKeys;
}
// Roll up to parent level keys
var deDuplicatedKeys = formatStrategyValues(checkedKeys, getPathKeyEntities, showCheckedStrategy);
nextCheckedValues = getValueByKeyPath(deDuplicatedKeys);
}
triggerChange([].concat(_toConsumableArray(nextMissingValues), _toConsumableArray(nextCheckedValues)));
}
};
}

9
node_modules/rc-cascader/es/hooks/useValues.d.ts generated vendored Normal file
View File

@@ -0,0 +1,9 @@
import type { DataEntity } from 'rc-tree/lib/interface';
import * as React from 'react';
import type { SingleValueType } from '../Cascader';
import type { GetMissValues } from './useMissingValues';
export default function useValues(multiple: boolean, rawValues: SingleValueType[], getPathKeyEntities: () => Record<string, DataEntity>, getValueByKeyPath: (pathKeys: React.Key[]) => SingleValueType[], getMissingValues: GetMissValues): [
checkedValues: SingleValueType[],
halfCheckedValues: SingleValueType[],
missingCheckedValues: SingleValueType[]
];

24
node_modules/rc-cascader/es/hooks/useValues.js generated vendored Normal file
View File

@@ -0,0 +1,24 @@
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
import { conductCheck } from "rc-tree/es/utils/conductUtil";
import * as React from 'react';
import { toPathKeys } from "../utils/commonUtil";
export default function useValues(multiple, rawValues, getPathKeyEntities, getValueByKeyPath, getMissingValues) {
// Fill `rawValues` with checked conduction values
return React.useMemo(function () {
var _getMissingValues = getMissingValues(rawValues),
_getMissingValues2 = _slicedToArray(_getMissingValues, 2),
existValues = _getMissingValues2[0],
missingValues = _getMissingValues2[1];
if (!multiple || !rawValues.length) {
return [existValues, [], missingValues];
}
var keyPathValues = toPathKeys(existValues);
var keyPathEntities = getPathKeyEntities();
var _conductCheck = conductCheck(keyPathValues, true, keyPathEntities),
checkedKeys = _conductCheck.checkedKeys,
halfCheckedKeys = _conductCheck.halfCheckedKeys;
// Convert key back to value cells
return [getValueByKeyPath(checkedKeys), getValueByKeyPath(halfCheckedKeys), missingValues];
}, [multiple, rawValues, getPathKeyEntities, getValueByKeyPath, getMissingValues]);
}

5
node_modules/rc-cascader/es/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,5 @@
import Cascader from './Cascader';
import Panel from './Panel';
export type { BaseOptionType, DefaultOptionType, CascaderProps, FieldNames, ShowSearchType, CascaderRef, } from './Cascader';
export { Panel };
export default Cascader;

4
node_modules/rc-cascader/es/index.js generated vendored Normal file
View File

@@ -0,0 +1,4 @@
import Cascader from "./Cascader";
import Panel from "./Panel";
export { Panel };
export default Cascader;

18
node_modules/rc-cascader/es/utils/commonUtil.d.ts generated vendored Normal file
View File

@@ -0,0 +1,18 @@
import type { DefaultOptionType, FieldNames, InternalFieldNames, InternalValueType, SingleValueType } from '../Cascader';
export declare const VALUE_SPLIT = "__RC_CASCADER_SPLIT__";
export declare const SHOW_PARENT = "SHOW_PARENT";
export declare const SHOW_CHILD = "SHOW_CHILD";
/**
* Will convert value to string, and join with `VALUE_SPLIT`
*/
export declare function toPathKey(value: SingleValueType): string;
/**
* Batch convert value to string, and join with `VALUE_SPLIT`
*/
export declare function toPathKeys(value: SingleValueType[]): string[];
export declare function toPathValueStr(pathKey: string): string[];
export declare function fillFieldNames(fieldNames?: FieldNames): InternalFieldNames;
export declare function isLeaf(option: DefaultOptionType, fieldNames: FieldNames): any;
export declare function scrollIntoParentView(element: HTMLElement): void;
export declare function getFullPathKeys(options: DefaultOptionType[], fieldNames: FieldNames): any[];
export declare function toRawValues(value?: InternalValueType): SingleValueType[];

76
node_modules/rc-cascader/es/utils/commonUtil.js generated vendored Normal file
View File

@@ -0,0 +1,76 @@
import { SEARCH_MARK } from "../hooks/useSearchOptions";
export var VALUE_SPLIT = '__RC_CASCADER_SPLIT__';
export var SHOW_PARENT = 'SHOW_PARENT';
export var SHOW_CHILD = 'SHOW_CHILD';
/**
* Will convert value to string, and join with `VALUE_SPLIT`
*/
export function toPathKey(value) {
return value.join(VALUE_SPLIT);
}
/**
* Batch convert value to string, and join with `VALUE_SPLIT`
*/
export function toPathKeys(value) {
return value.map(toPathKey);
}
export function toPathValueStr(pathKey) {
return pathKey.split(VALUE_SPLIT);
}
export function fillFieldNames(fieldNames) {
var _ref = fieldNames || {},
label = _ref.label,
value = _ref.value,
children = _ref.children;
var val = value || 'value';
return {
label: label || 'label',
value: val,
key: val,
children: children || 'children'
};
}
export function isLeaf(option, fieldNames) {
var _option$isLeaf, _option;
return (_option$isLeaf = option.isLeaf) !== null && _option$isLeaf !== void 0 ? _option$isLeaf : !((_option = option[fieldNames.children]) !== null && _option !== void 0 && _option.length);
}
export function scrollIntoParentView(element) {
var parent = element.parentElement;
if (!parent) {
return;
}
var elementToParent = element.offsetTop - parent.offsetTop; // offsetParent may not be parent.
if (elementToParent - parent.scrollTop < 0) {
parent.scrollTo({
top: elementToParent
});
} else if (elementToParent + element.offsetHeight - parent.scrollTop > parent.offsetHeight) {
parent.scrollTo({
top: elementToParent + element.offsetHeight - parent.offsetHeight
});
}
}
export function getFullPathKeys(options, fieldNames) {
return options.map(function (item) {
var _item$SEARCH_MARK;
return (_item$SEARCH_MARK = item[SEARCH_MARK]) === null || _item$SEARCH_MARK === void 0 ? void 0 : _item$SEARCH_MARK.map(function (opt) {
return opt[fieldNames.value];
});
});
}
function isMultipleValue(value) {
return Array.isArray(value) && Array.isArray(value[0]);
}
export function toRawValues(value) {
if (!value) {
return [];
}
if (isMultipleValue(value)) {
return value;
}
return (value.length === 0 ? [] : [value]).map(function (val) {
return Array.isArray(val) ? val : [val];
});
}

9
node_modules/rc-cascader/es/utils/treeUtil.d.ts generated vendored Normal file
View File

@@ -0,0 +1,9 @@
/// <reference types="react" />
import type { SingleValueType, DefaultOptionType, InternalFieldNames, ShowCheckedStrategy } from '../Cascader';
import type { GetEntities } from '../hooks/useEntities';
export declare function formatStrategyValues(pathKeys: React.Key[], getKeyPathEntities: GetEntities, showCheckedStrategy?: ShowCheckedStrategy): import("react").Key[];
export declare function toPathOptions(valueCells: SingleValueType, options: DefaultOptionType[], fieldNames: InternalFieldNames, stringMode?: boolean): {
value: SingleValueType[number];
index: number;
option: DefaultOptionType;
}[];

40
node_modules/rc-cascader/es/utils/treeUtil.js generated vendored Normal file
View File

@@ -0,0 +1,40 @@
import { SHOW_CHILD } from "./commonUtil";
export function formatStrategyValues(pathKeys, getKeyPathEntities, showCheckedStrategy) {
var valueSet = new Set(pathKeys);
var keyPathEntities = getKeyPathEntities();
return pathKeys.filter(function (key) {
var entity = keyPathEntities[key];
var parent = entity ? entity.parent : null;
var children = entity ? entity.children : null;
if (entity && entity.node.disabled) {
return true;
}
return showCheckedStrategy === SHOW_CHILD ? !(children && children.some(function (child) {
return child.key && valueSet.has(child.key);
})) : !(parent && !parent.node.disabled && valueSet.has(parent.key));
});
}
export function toPathOptions(valueCells, options, fieldNames) {
var stringMode = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
var currentList = options;
var valueOptions = [];
var _loop = function _loop() {
var _currentList, _currentList2, _foundOption$fieldNam;
var valueCell = valueCells[i];
var foundIndex = (_currentList = currentList) === null || _currentList === void 0 ? void 0 : _currentList.findIndex(function (option) {
var val = option[fieldNames.value];
return stringMode ? String(val) === String(valueCell) : val === valueCell;
});
var foundOption = foundIndex !== -1 ? (_currentList2 = currentList) === null || _currentList2 === void 0 ? void 0 : _currentList2[foundIndex] : null;
valueOptions.push({
value: (_foundOption$fieldNam = foundOption === null || foundOption === void 0 ? void 0 : foundOption[fieldNames.value]) !== null && _foundOption$fieldNam !== void 0 ? _foundOption$fieldNam : valueCell,
index: foundIndex,
option: foundOption
});
currentList = foundOption === null || foundOption === void 0 ? void 0 : foundOption[fieldNames.children];
};
for (var i = 0; i < valueCells.length; i += 1) {
_loop();
}
return valueOptions;
}

View File

@@ -0,0 +1,4 @@
import type { DefaultOptionType, FieldNames, InternalCascaderProps } from '../Cascader';
declare function warningProps(props: InternalCascaderProps): void;
export declare function warningNullOptions(options: DefaultOptionType[], fieldNames: FieldNames): void;
export default warningProps;

33
node_modules/rc-cascader/es/utils/warningPropsUtil.js generated vendored Normal file
View File

@@ -0,0 +1,33 @@
import warning from "rc-util/es/warning";
function warningProps(props) {
var onPopupVisibleChange = props.onPopupVisibleChange,
popupVisible = props.popupVisible,
popupClassName = props.popupClassName,
popupPlacement = props.popupPlacement,
onDropdownVisibleChange = props.onDropdownVisibleChange;
warning(!onPopupVisibleChange, '`onPopupVisibleChange` is deprecated. Please use `onOpenChange` instead.');
warning(!onDropdownVisibleChange, '`onDropdownVisibleChange` is deprecated. Please use `onOpenChange` instead.');
warning(popupVisible === undefined, '`popupVisible` is deprecated. Please use `open` instead.');
warning(popupClassName === undefined, '`popupClassName` is deprecated. Please use `dropdownClassName` instead.');
warning(popupPlacement === undefined, '`popupPlacement` is deprecated. Please use `placement` instead.');
}
// value in Cascader options should not be null
export function warningNullOptions(options, fieldNames) {
if (options) {
var recursiveOptions = function recursiveOptions(optionsList) {
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 Cascader options should not be `null`.');
return true;
}
if (Array.isArray(option[fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.children]) && recursiveOptions(option[fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.children])) {
return true;
}
}
};
recursiveOptions(options);
}
}
export default warningProps;