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

24
node_modules/rc-tree-select/es/LegacyContext.d.ts generated vendored Normal file
View File

@@ -0,0 +1,24 @@
import * as React from 'react';
import type { DataEntity, IconType } from 'rc-tree/lib/interface';
import type { LegacyDataNode, SafeKey, Key } from './interface';
interface LegacyContextProps {
checkable: boolean | React.ReactNode;
checkedKeys: Key[];
halfCheckedKeys: Key[];
treeExpandedKeys: Key[];
treeDefaultExpandedKeys: Key[];
onTreeExpand: (keys: Key[]) => void;
treeDefaultExpandAll: boolean;
treeIcon: IconType;
showTreeIcon: boolean;
switcherIcon: IconType;
treeLine: boolean;
treeNodeFilterProp: string;
treeLoadedKeys: Key[];
treeMotion: any;
loadData: (treeNode: LegacyDataNode) => Promise<unknown>;
onTreeLoad: (loadedKeys: Key[]) => void;
keyEntities: Record<SafeKey, DataEntity<any>>;
}
declare const LegacySelectContext: React.Context<LegacyContextProps>;
export default LegacySelectContext;

3
node_modules/rc-tree-select/es/LegacyContext.js generated vendored Normal file
View File

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

8
node_modules/rc-tree-select/es/OptionList.d.ts generated vendored Normal file
View File

@@ -0,0 +1,8 @@
import type { RefOptionListProps } from 'rc-select/lib/OptionList';
import type { ScrollTo } from 'rc-tree/lib/interface';
import * as React from 'react';
type ReviseRefOptionListProps = Omit<RefOptionListProps, 'scrollTo'> & {
scrollTo: ScrollTo;
};
declare const RefOptionList: React.ForwardRefExoticComponent<React.RefAttributes<ReviseRefOptionListProps>>;
export default RefOptionList;

386
node_modules/rc-tree-select/es/OptionList.js generated vendored Normal file
View File

@@ -0,0 +1,386 @@
import _extends from "@babel/runtime/helpers/esm/extends";
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
import { useBaseProps } from 'rc-select';
import Tree from 'rc-tree';
import { UnstableContext } from 'rc-tree';
import KeyCode from "rc-util/es/KeyCode";
import useMemo from "rc-util/es/hooks/useMemo";
import * as React from 'react';
import LegacyContext from "./LegacyContext";
import TreeSelectContext from "./TreeSelectContext";
import { getAllKeys, isCheckDisabled } from "./utils/valueUtil";
import { useEvent } from 'rc-util';
var HIDDEN_STYLE = {
width: 0,
height: 0,
display: 'flex',
overflow: 'hidden',
opacity: 0,
border: 0,
padding: 0,
margin: 0
};
var OptionList = function OptionList(_, ref) {
var _useBaseProps = useBaseProps(),
prefixCls = _useBaseProps.prefixCls,
multiple = _useBaseProps.multiple,
searchValue = _useBaseProps.searchValue,
toggleOpen = _useBaseProps.toggleOpen,
open = _useBaseProps.open,
notFoundContent = _useBaseProps.notFoundContent;
var _React$useContext = React.useContext(TreeSelectContext),
virtual = _React$useContext.virtual,
listHeight = _React$useContext.listHeight,
listItemHeight = _React$useContext.listItemHeight,
listItemScrollOffset = _React$useContext.listItemScrollOffset,
treeData = _React$useContext.treeData,
fieldNames = _React$useContext.fieldNames,
onSelect = _React$useContext.onSelect,
dropdownMatchSelectWidth = _React$useContext.dropdownMatchSelectWidth,
treeExpandAction = _React$useContext.treeExpandAction,
treeTitleRender = _React$useContext.treeTitleRender,
onPopupScroll = _React$useContext.onPopupScroll,
leftMaxCount = _React$useContext.leftMaxCount,
leafCountOnly = _React$useContext.leafCountOnly,
valueEntities = _React$useContext.valueEntities;
var _React$useContext2 = React.useContext(LegacyContext),
checkable = _React$useContext2.checkable,
checkedKeys = _React$useContext2.checkedKeys,
halfCheckedKeys = _React$useContext2.halfCheckedKeys,
treeExpandedKeys = _React$useContext2.treeExpandedKeys,
treeDefaultExpandAll = _React$useContext2.treeDefaultExpandAll,
treeDefaultExpandedKeys = _React$useContext2.treeDefaultExpandedKeys,
onTreeExpand = _React$useContext2.onTreeExpand,
treeIcon = _React$useContext2.treeIcon,
showTreeIcon = _React$useContext2.showTreeIcon,
switcherIcon = _React$useContext2.switcherIcon,
treeLine = _React$useContext2.treeLine,
treeNodeFilterProp = _React$useContext2.treeNodeFilterProp,
loadData = _React$useContext2.loadData,
treeLoadedKeys = _React$useContext2.treeLoadedKeys,
treeMotion = _React$useContext2.treeMotion,
onTreeLoad = _React$useContext2.onTreeLoad,
keyEntities = _React$useContext2.keyEntities;
var treeRef = React.useRef();
var memoTreeData = useMemo(function () {
return treeData;
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[open, treeData], function (prev, next) {
return next[0] && prev[1] !== next[1];
});
// ========================== Values ==========================
var mergedCheckedKeys = React.useMemo(function () {
if (!checkable) {
return null;
}
return {
checked: checkedKeys,
halfChecked: halfCheckedKeys
};
}, [checkable, checkedKeys, halfCheckedKeys]);
// ========================== Scroll ==========================
React.useEffect(function () {
// Single mode should scroll to current key
if (open && !multiple && checkedKeys.length) {
var _treeRef$current;
(_treeRef$current = treeRef.current) === null || _treeRef$current === void 0 || _treeRef$current.scrollTo({
key: checkedKeys[0]
});
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [open]);
// ========================== Events ==========================
var onListMouseDown = function onListMouseDown(event) {
event.preventDefault();
};
var onInternalSelect = function onInternalSelect(__, info) {
var node = info.node;
if (checkable && isCheckDisabled(node)) {
return;
}
onSelect(node.key, {
selected: !checkedKeys.includes(node.key)
});
if (!multiple) {
toggleOpen(false);
}
};
// =========================== Keys ===========================
var _React$useState = React.useState(treeDefaultExpandedKeys),
_React$useState2 = _slicedToArray(_React$useState, 2),
expandedKeys = _React$useState2[0],
setExpandedKeys = _React$useState2[1];
var _React$useState3 = React.useState(null),
_React$useState4 = _slicedToArray(_React$useState3, 2),
searchExpandedKeys = _React$useState4[0],
setSearchExpandedKeys = _React$useState4[1];
var mergedExpandedKeys = React.useMemo(function () {
if (treeExpandedKeys) {
return _toConsumableArray(treeExpandedKeys);
}
return searchValue ? searchExpandedKeys : expandedKeys;
}, [expandedKeys, searchExpandedKeys, treeExpandedKeys, searchValue]);
var onInternalExpand = function onInternalExpand(keys) {
setExpandedKeys(keys);
setSearchExpandedKeys(keys);
if (onTreeExpand) {
onTreeExpand(keys);
}
};
// ========================== Search ==========================
var lowerSearchValue = String(searchValue).toLowerCase();
var filterTreeNode = function filterTreeNode(treeNode) {
if (!lowerSearchValue) {
return false;
}
return String(treeNode[treeNodeFilterProp]).toLowerCase().includes(lowerSearchValue);
};
React.useEffect(function () {
if (searchValue) {
setSearchExpandedKeys(getAllKeys(treeData, fieldNames));
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [searchValue]);
// ========================= Disabled =========================
// Cache disabled states in React state to ensure re-render when cache updates
var _React$useState5 = React.useState(function () {
return new Map();
}),
_React$useState6 = _slicedToArray(_React$useState5, 2),
disabledCache = _React$useState6[0],
setDisabledCache = _React$useState6[1];
React.useEffect(function () {
if (leftMaxCount) {
setDisabledCache(new Map());
}
}, [leftMaxCount]);
function getDisabledWithCache(node) {
var value = node[fieldNames.value];
if (!disabledCache.has(value)) {
var entity = valueEntities.get(value);
var isLeaf = (entity.children || []).length === 0;
if (!isLeaf) {
var checkableChildren = entity.children.filter(function (childTreeNode) {
return !childTreeNode.node.disabled && !childTreeNode.node.disableCheckbox && !checkedKeys.includes(childTreeNode.node[fieldNames.value]);
});
var checkableChildrenCount = checkableChildren.length;
disabledCache.set(value, checkableChildrenCount > leftMaxCount);
} else {
disabledCache.set(value, false);
}
}
return disabledCache.get(value);
}
var nodeDisabled = useEvent(function (node) {
var nodeValue = node[fieldNames.value];
if (checkedKeys.includes(nodeValue)) {
return false;
}
if (leftMaxCount === null) {
return false;
}
if (leftMaxCount <= 0) {
return true;
}
// This is a low performance calculation
if (leafCountOnly && leftMaxCount) {
return getDisabledWithCache(node);
}
return false;
});
// ========================== Get First Selectable Node ==========================
var getFirstMatchingNode = function getFirstMatchingNode(nodes) {
var _iterator = _createForOfIteratorHelper(nodes),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var node = _step.value;
if (node.disabled || node.selectable === false) {
continue;
}
if (searchValue) {
if (filterTreeNode(node)) {
return node;
}
} else {
return node;
}
if (node[fieldNames.children]) {
var matchInChildren = getFirstMatchingNode(node[fieldNames.children]);
if (matchInChildren) {
return matchInChildren;
}
}
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
return null;
};
// ========================== Active ==========================
var _React$useState7 = React.useState(null),
_React$useState8 = _slicedToArray(_React$useState7, 2),
activeKey = _React$useState8[0],
setActiveKey = _React$useState8[1];
var activeEntity = keyEntities[activeKey];
React.useEffect(function () {
if (!open) {
return;
}
var nextActiveKey = null;
var getFirstNode = function getFirstNode() {
var firstNode = getFirstMatchingNode(memoTreeData);
return firstNode ? firstNode[fieldNames.value] : null;
};
// single mode active first checked node
if (!multiple && checkedKeys.length && !searchValue) {
nextActiveKey = checkedKeys[0];
} else {
nextActiveKey = getFirstNode();
}
setActiveKey(nextActiveKey);
}, [open, searchValue]);
// ========================= Keyboard =========================
React.useImperativeHandle(ref, function () {
var _treeRef$current2;
return {
scrollTo: (_treeRef$current2 = treeRef.current) === null || _treeRef$current2 === void 0 ? void 0 : _treeRef$current2.scrollTo,
onKeyDown: function onKeyDown(event) {
var _treeRef$current3;
var which = event.which;
switch (which) {
// >>> Arrow keys
case KeyCode.UP:
case KeyCode.DOWN:
case KeyCode.LEFT:
case KeyCode.RIGHT:
(_treeRef$current3 = treeRef.current) === null || _treeRef$current3 === void 0 || _treeRef$current3.onKeyDown(event);
break;
// >>> Select item
case KeyCode.ENTER:
{
if (activeEntity) {
var isNodeDisabled = nodeDisabled(activeEntity.node);
var _ref = (activeEntity === null || activeEntity === void 0 ? void 0 : activeEntity.node) || {},
selectable = _ref.selectable,
value = _ref.value,
disabled = _ref.disabled;
if (selectable !== false && !disabled && !isNodeDisabled) {
onInternalSelect(null, {
node: {
key: activeKey
},
selected: !checkedKeys.includes(value)
});
}
}
break;
}
// >>> Close
case KeyCode.ESC:
{
toggleOpen(false);
}
}
},
onKeyUp: function onKeyUp() {}
};
});
var hasLoadDataFn = useMemo(function () {
return searchValue ? false : true;
}, [searchValue, treeExpandedKeys || expandedKeys], function (_ref2, _ref3) {
var _ref4 = _slicedToArray(_ref2, 1),
preSearchValue = _ref4[0];
var _ref5 = _slicedToArray(_ref3, 2),
nextSearchValue = _ref5[0],
nextExcludeSearchExpandedKeys = _ref5[1];
return preSearchValue !== nextSearchValue && !!(nextSearchValue || nextExcludeSearchExpandedKeys);
});
var syncLoadData = hasLoadDataFn ? loadData : null;
// ========================== Render ==========================
if (memoTreeData.length === 0) {
return /*#__PURE__*/React.createElement("div", {
role: "listbox",
className: "".concat(prefixCls, "-empty"),
onMouseDown: onListMouseDown
}, notFoundContent);
}
var treeProps = {
fieldNames: fieldNames
};
if (treeLoadedKeys) {
treeProps.loadedKeys = treeLoadedKeys;
}
if (mergedExpandedKeys) {
treeProps.expandedKeys = mergedExpandedKeys;
}
return /*#__PURE__*/React.createElement("div", {
onMouseDown: onListMouseDown
}, activeEntity && open && /*#__PURE__*/React.createElement("span", {
style: HIDDEN_STYLE,
"aria-live": "assertive"
}, activeEntity.node.value), /*#__PURE__*/React.createElement(UnstableContext.Provider, {
value: {
nodeDisabled: nodeDisabled
}
}, /*#__PURE__*/React.createElement(Tree, _extends({
ref: treeRef,
focusable: false,
prefixCls: "".concat(prefixCls, "-tree"),
treeData: memoTreeData,
height: listHeight,
itemHeight: listItemHeight,
itemScrollOffset: listItemScrollOffset,
virtual: virtual !== false && dropdownMatchSelectWidth !== false,
multiple: multiple,
icon: treeIcon,
showIcon: showTreeIcon,
switcherIcon: switcherIcon,
showLine: treeLine,
loadData: syncLoadData,
motion: treeMotion,
activeKey: activeKey
// We handle keys by out instead tree self
,
checkable: checkable,
checkStrictly: true,
checkedKeys: mergedCheckedKeys,
selectedKeys: !checkable ? checkedKeys : [],
defaultExpandAll: treeDefaultExpandAll,
titleRender: treeTitleRender
}, treeProps, {
// Proxy event out
onActiveChange: setActiveKey,
onSelect: onInternalSelect,
onCheck: onInternalSelect,
onExpand: onInternalExpand,
onLoad: onTreeLoad,
filterTreeNode: filterTreeNode,
expandAction: treeExpandAction,
onScroll: onPopupScroll
}))));
};
var RefOptionList = /*#__PURE__*/React.forwardRef(OptionList);
if (process.env.NODE_ENV !== 'production') {
RefOptionList.displayName = 'OptionList';
}
export default RefOptionList;

9
node_modules/rc-tree-select/es/TreeNode.d.ts generated vendored Normal file
View File

@@ -0,0 +1,9 @@
import type * as React from 'react';
import type { DataNode, Key } from './interface';
export interface TreeNodeProps extends Omit<DataNode, 'children'> {
value: Key;
children?: React.ReactNode;
}
/** This is a placeholder, not real render in dom */
declare const TreeNode: React.FC<TreeNodeProps>;
export default TreeNode;

7
node_modules/rc-tree-select/es/TreeNode.js generated vendored Normal file
View File

@@ -0,0 +1,7 @@
/* istanbul ignore file */
/** This is a placeholder, not real render in dom */
var TreeNode = function TreeNode() {
return null;
};
export default TreeNode;

65
node_modules/rc-tree-select/es/TreeSelect.d.ts generated vendored Normal file
View File

@@ -0,0 +1,65 @@
import type { BaseSelectPropsWithoutPrivate, BaseSelectRef } from 'rc-select';
import type { IconType } from 'rc-tree/lib/interface';
import type { ExpandAction } from 'rc-tree/lib/Tree';
import * as React from 'react';
import TreeNode from './TreeNode';
import type { CheckedStrategy } from './utils/strategyUtil';
import { SHOW_ALL, SHOW_CHILD, SHOW_PARENT } from './utils/strategyUtil';
import type { SafeKey, DataNode, SimpleModeConfig, ChangeEventExtra, FieldNames, LegacyDataNode } from './interface';
export interface TreeSelectProps<ValueType = any, OptionType extends DataNode = DataNode> extends Omit<BaseSelectPropsWithoutPrivate, 'mode'> {
prefixCls?: string;
id?: string;
children?: React.ReactNode;
value?: ValueType;
defaultValue?: ValueType;
onChange?: (value: ValueType, labelList: React.ReactNode[], extra: ChangeEventExtra) => void;
searchValue?: string;
/** @deprecated Use `searchValue` instead */
inputValue?: string;
onSearch?: (value: string) => void;
autoClearSearchValue?: boolean;
filterTreeNode?: boolean | ((inputValue: string, treeNode: DataNode) => boolean);
treeNodeFilterProp?: string;
onSelect?: (value: ValueType, option: OptionType) => void;
onDeselect?: (value: ValueType, option: OptionType) => void;
showCheckedStrategy?: CheckedStrategy;
treeNodeLabelProp?: string;
fieldNames?: FieldNames;
multiple?: boolean;
treeCheckable?: boolean | React.ReactNode;
treeCheckStrictly?: boolean;
labelInValue?: boolean;
maxCount?: number;
treeData?: OptionType[];
treeDataSimpleMode?: boolean | SimpleModeConfig;
loadData?: (dataNode: LegacyDataNode) => Promise<unknown>;
treeLoadedKeys?: SafeKey[];
onTreeLoad?: (loadedKeys: SafeKey[]) => void;
treeDefaultExpandAll?: boolean;
treeExpandedKeys?: SafeKey[];
treeDefaultExpandedKeys?: SafeKey[];
onTreeExpand?: (expandedKeys: SafeKey[]) => void;
treeExpandAction?: ExpandAction;
virtual?: boolean;
listHeight?: number;
listItemHeight?: number;
listItemScrollOffset?: number;
onDropdownVisibleChange?: (open: boolean) => void;
treeTitleRender?: (node: OptionType) => React.ReactNode;
treeLine?: boolean;
treeIcon?: IconType;
showTreeIcon?: boolean;
switcherIcon?: IconType;
treeMotion?: any;
}
declare const GenericTreeSelect: (<ValueType = any, OptionType extends DataNode = DataNode>(props: TreeSelectProps<ValueType, OptionType> & {
children?: React.ReactNode;
} & {
ref?: React.Ref<BaseSelectRef>;
}) => React.ReactElement) & {
TreeNode: typeof TreeNode;
SHOW_ALL: typeof SHOW_ALL;
SHOW_PARENT: typeof SHOW_PARENT;
SHOW_CHILD: typeof SHOW_CHILD;
};
export default GenericTreeSelect;

556
node_modules/rc-tree-select/es/TreeSelect.js generated vendored Normal file
View File

@@ -0,0 +1,556 @@
import _extends from "@babel/runtime/helpers/esm/extends";
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
import _typeof from "@babel/runtime/helpers/esm/typeof";
var _excluded = ["id", "prefixCls", "value", "defaultValue", "onChange", "onSelect", "onDeselect", "searchValue", "inputValue", "onSearch", "autoClearSearchValue", "filterTreeNode", "treeNodeFilterProp", "showCheckedStrategy", "treeNodeLabelProp", "multiple", "treeCheckable", "treeCheckStrictly", "labelInValue", "maxCount", "fieldNames", "treeDataSimpleMode", "treeData", "children", "loadData", "treeLoadedKeys", "onTreeLoad", "treeDefaultExpandAll", "treeExpandedKeys", "treeDefaultExpandedKeys", "onTreeExpand", "treeExpandAction", "virtual", "listHeight", "listItemHeight", "listItemScrollOffset", "onDropdownVisibleChange", "dropdownMatchSelectWidth", "treeLine", "treeIcon", "showTreeIcon", "switcherIcon", "treeMotion", "treeTitleRender", "onPopupScroll"];
import { BaseSelect } from 'rc-select';
import useId from "rc-select/es/hooks/useId";
import { conductCheck } from "rc-tree/es/utils/conductUtil";
import useMergedState from "rc-util/es/hooks/useMergedState";
import warning from "rc-util/es/warning";
import * as React from 'react';
import useCache from "./hooks/useCache";
import useCheckedKeys from "./hooks/useCheckedKeys";
import useDataEntities from "./hooks/useDataEntities";
import useFilterTreeData from "./hooks/useFilterTreeData";
import useRefFunc from "./hooks/useRefFunc";
import useTreeData from "./hooks/useTreeData";
import LegacyContext from "./LegacyContext";
import OptionList from "./OptionList";
import TreeNode from "./TreeNode";
import TreeSelectContext from "./TreeSelectContext";
import { fillAdditionalInfo, fillLegacyProps } from "./utils/legacyUtil";
import { formatStrategyValues, SHOW_ALL, SHOW_CHILD, SHOW_PARENT } from "./utils/strategyUtil";
import { fillFieldNames, isNil, toArray } from "./utils/valueUtil";
import warningProps from "./utils/warningPropsUtil";
function isRawValue(value) {
return !value || _typeof(value) !== 'object';
}
var TreeSelect = /*#__PURE__*/React.forwardRef(function (props, ref) {
var id = props.id,
_props$prefixCls = props.prefixCls,
prefixCls = _props$prefixCls === void 0 ? 'rc-tree-select' : _props$prefixCls,
value = props.value,
defaultValue = props.defaultValue,
onChange = props.onChange,
onSelect = props.onSelect,
onDeselect = props.onDeselect,
searchValue = props.searchValue,
inputValue = props.inputValue,
onSearch = props.onSearch,
_props$autoClearSearc = props.autoClearSearchValue,
autoClearSearchValue = _props$autoClearSearc === void 0 ? true : _props$autoClearSearc,
filterTreeNode = props.filterTreeNode,
_props$treeNodeFilter = props.treeNodeFilterProp,
treeNodeFilterProp = _props$treeNodeFilter === void 0 ? 'value' : _props$treeNodeFilter,
showCheckedStrategy = props.showCheckedStrategy,
treeNodeLabelProp = props.treeNodeLabelProp,
multiple = props.multiple,
treeCheckable = props.treeCheckable,
treeCheckStrictly = props.treeCheckStrictly,
labelInValue = props.labelInValue,
maxCount = props.maxCount,
fieldNames = props.fieldNames,
treeDataSimpleMode = props.treeDataSimpleMode,
treeData = props.treeData,
children = props.children,
loadData = props.loadData,
treeLoadedKeys = props.treeLoadedKeys,
onTreeLoad = props.onTreeLoad,
treeDefaultExpandAll = props.treeDefaultExpandAll,
treeExpandedKeys = props.treeExpandedKeys,
treeDefaultExpandedKeys = props.treeDefaultExpandedKeys,
onTreeExpand = props.onTreeExpand,
treeExpandAction = props.treeExpandAction,
virtual = props.virtual,
_props$listHeight = props.listHeight,
listHeight = _props$listHeight === void 0 ? 200 : _props$listHeight,
_props$listItemHeight = props.listItemHeight,
listItemHeight = _props$listItemHeight === void 0 ? 20 : _props$listItemHeight,
_props$listItemScroll = props.listItemScrollOffset,
listItemScrollOffset = _props$listItemScroll === void 0 ? 0 : _props$listItemScroll,
onDropdownVisibleChange = props.onDropdownVisibleChange,
_props$dropdownMatchS = props.dropdownMatchSelectWidth,
dropdownMatchSelectWidth = _props$dropdownMatchS === void 0 ? true : _props$dropdownMatchS,
treeLine = props.treeLine,
treeIcon = props.treeIcon,
showTreeIcon = props.showTreeIcon,
switcherIcon = props.switcherIcon,
treeMotion = props.treeMotion,
treeTitleRender = props.treeTitleRender,
onPopupScroll = props.onPopupScroll,
restProps = _objectWithoutProperties(props, _excluded);
var mergedId = useId(id);
var treeConduction = treeCheckable && !treeCheckStrictly;
var mergedCheckable = treeCheckable || treeCheckStrictly;
var mergedLabelInValue = treeCheckStrictly || labelInValue;
var mergedMultiple = mergedCheckable || multiple;
var _useMergedState = useMergedState(defaultValue, {
value: value
}),
_useMergedState2 = _slicedToArray(_useMergedState, 2),
internalValue = _useMergedState2[0],
setInternalValue = _useMergedState2[1];
// `multiple` && `!treeCheckable` should be show all
var mergedShowCheckedStrategy = React.useMemo(function () {
if (!treeCheckable) {
return SHOW_ALL;
}
return showCheckedStrategy || SHOW_CHILD;
}, [showCheckedStrategy, treeCheckable]);
// ========================== Warning ===========================
if (process.env.NODE_ENV !== 'production') {
warningProps(props);
}
// ========================= FieldNames =========================
var mergedFieldNames = React.useMemo(function () {
return fillFieldNames(fieldNames);
}, /* eslint-disable react-hooks/exhaustive-deps */
[JSON.stringify(fieldNames)]
/* eslint-enable react-hooks/exhaustive-deps */);
// =========================== Search ===========================
var _useMergedState3 = useMergedState('', {
value: searchValue !== undefined ? searchValue : inputValue,
postState: function postState(search) {
return search || '';
}
}),
_useMergedState4 = _slicedToArray(_useMergedState3, 2),
mergedSearchValue = _useMergedState4[0],
setSearchValue = _useMergedState4[1];
var onInternalSearch = function onInternalSearch(searchText) {
setSearchValue(searchText);
onSearch === null || onSearch === void 0 || onSearch(searchText);
};
// ============================ Data ============================
// `useTreeData` only do convert of `children` or `simpleMode`.
// Else will return origin `treeData` for perf consideration.
// Do not do anything to loop the data.
var mergedTreeData = useTreeData(treeData, children, treeDataSimpleMode);
var _useDataEntities = useDataEntities(mergedTreeData, mergedFieldNames),
keyEntities = _useDataEntities.keyEntities,
valueEntities = _useDataEntities.valueEntities;
/** Get `missingRawValues` which not exist in the tree yet */
var splitRawValues = React.useCallback(function (newRawValues) {
var missingRawValues = [];
var existRawValues = [];
// Keep missing value in the cache
newRawValues.forEach(function (val) {
if (valueEntities.has(val)) {
existRawValues.push(val);
} else {
missingRawValues.push(val);
}
});
return {
missingRawValues: missingRawValues,
existRawValues: existRawValues
};
}, [valueEntities]);
// Filtered Tree
var filteredTreeData = useFilterTreeData(mergedTreeData, mergedSearchValue, {
fieldNames: mergedFieldNames,
treeNodeFilterProp: treeNodeFilterProp,
filterTreeNode: filterTreeNode
});
// =========================== Label ============================
var getLabel = React.useCallback(function (item) {
if (item) {
if (treeNodeLabelProp) {
return item[treeNodeLabelProp];
}
// Loop from fieldNames
var titleList = mergedFieldNames._title;
for (var i = 0; i < titleList.length; i += 1) {
var title = item[titleList[i]];
if (title !== undefined) {
return title;
}
}
}
}, [mergedFieldNames, treeNodeLabelProp]);
// ========================= Wrap Value =========================
var toLabeledValues = React.useCallback(function (draftValues) {
var values = toArray(draftValues);
return values.map(function (val) {
if (isRawValue(val)) {
return {
value: val
};
}
return val;
});
}, []);
var convert2LabelValues = React.useCallback(function (draftValues) {
var values = toLabeledValues(draftValues);
return values.map(function (item) {
var rawLabel = item.label;
var rawValue = item.value,
rawHalfChecked = item.halfChecked;
var rawDisabled;
var entity = valueEntities.get(rawValue);
// Fill missing label & status
if (entity) {
var _rawLabel;
rawLabel = treeTitleRender ? treeTitleRender(entity.node) : (_rawLabel = rawLabel) !== null && _rawLabel !== void 0 ? _rawLabel : getLabel(entity.node);
rawDisabled = entity.node.disabled;
} else if (rawLabel === undefined) {
// We try to find in current `labelInValue` value
var labelInValueItem = toLabeledValues(internalValue).find(function (labeledItem) {
return labeledItem.value === rawValue;
});
rawLabel = labelInValueItem.label;
}
return {
label: rawLabel,
value: rawValue,
halfChecked: rawHalfChecked,
disabled: rawDisabled
};
});
}, [valueEntities, getLabel, toLabeledValues, internalValue]);
// =========================== Values ===========================
var rawMixedLabeledValues = React.useMemo(function () {
return toLabeledValues(internalValue === null ? [] : internalValue);
}, [toLabeledValues, internalValue]);
// Split value into full check and half check
var _React$useMemo = React.useMemo(function () {
var fullCheckValues = [];
var halfCheckValues = [];
rawMixedLabeledValues.forEach(function (item) {
if (item.halfChecked) {
halfCheckValues.push(item);
} else {
fullCheckValues.push(item);
}
});
return [fullCheckValues, halfCheckValues];
}, [rawMixedLabeledValues]),
_React$useMemo2 = _slicedToArray(_React$useMemo, 2),
rawLabeledValues = _React$useMemo2[0],
rawHalfLabeledValues = _React$useMemo2[1];
// const [mergedValues] = useCache(rawLabeledValues);
var rawValues = React.useMemo(function () {
return rawLabeledValues.map(function (item) {
return item.value;
});
}, [rawLabeledValues]);
// Convert value to key. Will fill missed keys for conduct check.
var _useCheckedKeys = useCheckedKeys(rawLabeledValues, rawHalfLabeledValues, treeConduction, keyEntities),
_useCheckedKeys2 = _slicedToArray(_useCheckedKeys, 2),
rawCheckedValues = _useCheckedKeys2[0],
rawHalfCheckedValues = _useCheckedKeys2[1];
// Convert rawCheckedKeys to check strategy related values
var displayValues = React.useMemo(function () {
// Collect keys which need to show
var displayKeys = formatStrategyValues(rawCheckedValues, mergedShowCheckedStrategy, keyEntities, mergedFieldNames);
// Convert to value and filled with label
var values = displayKeys.map(function (key) {
var _keyEntities$key$node, _keyEntities$key;
return (_keyEntities$key$node = (_keyEntities$key = keyEntities[key]) === null || _keyEntities$key === void 0 || (_keyEntities$key = _keyEntities$key.node) === null || _keyEntities$key === void 0 ? void 0 : _keyEntities$key[mergedFieldNames.value]) !== null && _keyEntities$key$node !== void 0 ? _keyEntities$key$node : key;
});
// Back fill with origin label
var labeledValues = values.map(function (val) {
var targetItem = rawLabeledValues.find(function (item) {
return item.value === val;
});
var label = labelInValue ? targetItem === null || targetItem === void 0 ? void 0 : targetItem.label : treeTitleRender === null || treeTitleRender === void 0 ? void 0 : treeTitleRender(targetItem);
return {
value: val,
label: label
};
});
var rawDisplayValues = convert2LabelValues(labeledValues);
var firstVal = rawDisplayValues[0];
if (!mergedMultiple && firstVal && isNil(firstVal.value) && isNil(firstVal.label)) {
return [];
}
return rawDisplayValues.map(function (item) {
var _item$label;
return _objectSpread(_objectSpread({}, item), {}, {
label: (_item$label = item.label) !== null && _item$label !== void 0 ? _item$label : item.value
});
});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [mergedFieldNames, mergedMultiple, rawCheckedValues, rawLabeledValues, convert2LabelValues, mergedShowCheckedStrategy, keyEntities]);
var _useCache = useCache(displayValues),
_useCache2 = _slicedToArray(_useCache, 1),
cachedDisplayValues = _useCache2[0];
// ========================== MaxCount ==========================
var mergedMaxCount = React.useMemo(function () {
if (mergedMultiple && (mergedShowCheckedStrategy === 'SHOW_CHILD' || treeCheckStrictly || !treeCheckable)) {
return maxCount;
}
return null;
}, [maxCount, mergedMultiple, treeCheckStrictly, mergedShowCheckedStrategy, treeCheckable]);
// =========================== Change ===========================
var triggerChange = useRefFunc(function (newRawValues, extra, source) {
var formattedKeyList = formatStrategyValues(newRawValues, mergedShowCheckedStrategy, keyEntities, mergedFieldNames);
// Not allow pass with `maxCount`
if (mergedMaxCount && formattedKeyList.length > mergedMaxCount) {
return;
}
var labeledValues = convert2LabelValues(newRawValues);
setInternalValue(labeledValues);
// Clean up if needed
if (autoClearSearchValue) {
setSearchValue('');
}
// Generate rest parameters is costly, so only do it when necessary
if (onChange) {
var eventValues = newRawValues;
if (treeConduction) {
eventValues = formattedKeyList.map(function (key) {
var entity = valueEntities.get(key);
return entity ? entity.node[mergedFieldNames.value] : key;
});
}
var _ref = extra || {
triggerValue: undefined,
selected: undefined
},
triggerValue = _ref.triggerValue,
selected = _ref.selected;
var returnRawValues = eventValues;
// We need fill half check back
if (treeCheckStrictly) {
var halfValues = rawHalfLabeledValues.filter(function (item) {
return !eventValues.includes(item.value);
});
returnRawValues = [].concat(_toConsumableArray(returnRawValues), _toConsumableArray(halfValues));
}
var returnLabeledValues = convert2LabelValues(returnRawValues);
var additionalInfo = {
// [Legacy] Always return as array contains label & value
preValue: rawLabeledValues,
triggerValue: triggerValue
};
// [Legacy] Fill legacy data if user query.
// This is expansive that we only fill when user query
// https://github.com/react-component/tree-select/blob/fe33eb7c27830c9ac70cd1fdb1ebbe7bc679c16a/src/Select.jsx
var showPosition = true;
if (treeCheckStrictly || source === 'selection' && !selected) {
showPosition = false;
}
fillAdditionalInfo(additionalInfo, triggerValue, newRawValues, mergedTreeData, showPosition, mergedFieldNames);
if (mergedCheckable) {
additionalInfo.checked = selected;
} else {
additionalInfo.selected = selected;
}
var returnValues = mergedLabelInValue ? returnLabeledValues : returnLabeledValues.map(function (item) {
return item.value;
});
onChange(mergedMultiple ? returnValues : returnValues[0], mergedLabelInValue ? null : returnLabeledValues.map(function (item) {
return item.label;
}), additionalInfo);
}
});
// ========================== Options ===========================
/** Trigger by option list */
var onOptionSelect = React.useCallback(function (selectedKey, _ref2) {
var _node$mergedFieldName;
var selected = _ref2.selected,
source = _ref2.source;
var entity = keyEntities[selectedKey];
var node = entity === null || entity === void 0 ? void 0 : entity.node;
var selectedValue = (_node$mergedFieldName = node === null || node === void 0 ? void 0 : node[mergedFieldNames.value]) !== null && _node$mergedFieldName !== void 0 ? _node$mergedFieldName : selectedKey;
// Never be falsy but keep it safe
if (!mergedMultiple) {
// Single mode always set value
triggerChange([selectedValue], {
selected: true,
triggerValue: selectedValue
}, 'option');
} else {
var newRawValues = selected ? [].concat(_toConsumableArray(rawValues), [selectedValue]) : rawCheckedValues.filter(function (v) {
return v !== selectedValue;
});
// Add keys if tree conduction
if (treeConduction) {
// Should keep missing values
var _splitRawValues = splitRawValues(newRawValues),
missingRawValues = _splitRawValues.missingRawValues,
existRawValues = _splitRawValues.existRawValues;
var keyList = existRawValues.map(function (val) {
return valueEntities.get(val).key;
});
// Conduction by selected or not
var checkedKeys;
if (selected) {
var _conductCheck = conductCheck(keyList, true, keyEntities);
checkedKeys = _conductCheck.checkedKeys;
} else {
var _conductCheck2 = conductCheck(keyList, {
checked: false,
halfCheckedKeys: rawHalfCheckedValues
}, keyEntities);
checkedKeys = _conductCheck2.checkedKeys;
}
// Fill back of keys
newRawValues = [].concat(_toConsumableArray(missingRawValues), _toConsumableArray(checkedKeys.map(function (key) {
return keyEntities[key].node[mergedFieldNames.value];
})));
}
triggerChange(newRawValues, {
selected: selected,
triggerValue: selectedValue
}, source || 'option');
}
// Trigger select event
if (selected || !mergedMultiple) {
onSelect === null || onSelect === void 0 || onSelect(selectedValue, fillLegacyProps(node));
} else {
onDeselect === null || onDeselect === void 0 || onDeselect(selectedValue, fillLegacyProps(node));
}
}, [splitRawValues, valueEntities, keyEntities, mergedFieldNames, mergedMultiple, rawValues, triggerChange, treeConduction, onSelect, onDeselect, rawCheckedValues, rawHalfCheckedValues, maxCount]);
// ========================== Dropdown ==========================
var onInternalDropdownVisibleChange = React.useCallback(function (open) {
if (onDropdownVisibleChange) {
var legacyParam = {};
Object.defineProperty(legacyParam, 'documentClickClose', {
get: function get() {
warning(false, 'Second param of `onDropdownVisibleChange` has been removed.');
return false;
}
});
onDropdownVisibleChange(open, legacyParam);
}
}, [onDropdownVisibleChange]);
// ====================== Display Change ========================
var onDisplayValuesChange = useRefFunc(function (newValues, info) {
var newRawValues = newValues.map(function (item) {
return item.value;
});
if (info.type === 'clear') {
triggerChange(newRawValues, {}, 'selection');
return;
}
// TreeSelect only have multiple mode which means display change only has remove
if (info.values.length) {
onOptionSelect(info.values[0].value, {
selected: false,
source: 'selection'
});
}
});
// ========================== Context ===========================
var treeSelectContext = React.useMemo(function () {
return {
virtual: virtual,
dropdownMatchSelectWidth: dropdownMatchSelectWidth,
listHeight: listHeight,
listItemHeight: listItemHeight,
listItemScrollOffset: listItemScrollOffset,
treeData: filteredTreeData,
fieldNames: mergedFieldNames,
onSelect: onOptionSelect,
treeExpandAction: treeExpandAction,
treeTitleRender: treeTitleRender,
onPopupScroll: onPopupScroll,
leftMaxCount: maxCount === undefined ? null : maxCount - cachedDisplayValues.length,
leafCountOnly: mergedShowCheckedStrategy === 'SHOW_CHILD' && !treeCheckStrictly && !!treeCheckable,
valueEntities: valueEntities
};
}, [virtual, dropdownMatchSelectWidth, listHeight, listItemHeight, listItemScrollOffset, filteredTreeData, mergedFieldNames, onOptionSelect, treeExpandAction, treeTitleRender, onPopupScroll, maxCount, cachedDisplayValues.length, mergedShowCheckedStrategy, treeCheckStrictly, treeCheckable, valueEntities]);
// ======================= Legacy Context =======================
var legacyContext = React.useMemo(function () {
return {
checkable: mergedCheckable,
loadData: loadData,
treeLoadedKeys: treeLoadedKeys,
onTreeLoad: onTreeLoad,
checkedKeys: rawCheckedValues,
halfCheckedKeys: rawHalfCheckedValues,
treeDefaultExpandAll: treeDefaultExpandAll,
treeExpandedKeys: treeExpandedKeys,
treeDefaultExpandedKeys: treeDefaultExpandedKeys,
onTreeExpand: onTreeExpand,
treeIcon: treeIcon,
treeMotion: treeMotion,
showTreeIcon: showTreeIcon,
switcherIcon: switcherIcon,
treeLine: treeLine,
treeNodeFilterProp: treeNodeFilterProp,
keyEntities: keyEntities
};
}, [mergedCheckable, loadData, treeLoadedKeys, onTreeLoad, rawCheckedValues, rawHalfCheckedValues, treeDefaultExpandAll, treeExpandedKeys, treeDefaultExpandedKeys, onTreeExpand, treeIcon, treeMotion, showTreeIcon, switcherIcon, treeLine, treeNodeFilterProp, keyEntities]);
// =========================== Render ===========================
return /*#__PURE__*/React.createElement(TreeSelectContext.Provider, {
value: treeSelectContext
}, /*#__PURE__*/React.createElement(LegacyContext.Provider, {
value: legacyContext
}, /*#__PURE__*/React.createElement(BaseSelect, _extends({
ref: ref
}, restProps, {
// >>> MISC
id: mergedId,
prefixCls: prefixCls,
mode: mergedMultiple ? 'multiple' : undefined
// >>> Display Value
,
displayValues: cachedDisplayValues,
onDisplayValuesChange: onDisplayValuesChange
// >>> Search
,
searchValue: mergedSearchValue,
onSearch: onInternalSearch
// >>> Options
,
OptionList: OptionList,
emptyOptions: !mergedTreeData.length,
onDropdownVisibleChange: onInternalDropdownVisibleChange,
dropdownMatchSelectWidth: dropdownMatchSelectWidth
}))));
});
// Assign name for Debug
if (process.env.NODE_ENV !== 'production') {
TreeSelect.displayName = 'TreeSelect';
}
var GenericTreeSelect = TreeSelect;
GenericTreeSelect.TreeNode = TreeNode;
GenericTreeSelect.SHOW_ALL = SHOW_ALL;
GenericTreeSelect.SHOW_PARENT = SHOW_PARENT;
GenericTreeSelect.SHOW_CHILD = SHOW_CHILD;
export default GenericTreeSelect;

25
node_modules/rc-tree-select/es/TreeSelectContext.d.ts generated vendored Normal file
View File

@@ -0,0 +1,25 @@
import * as React from 'react';
import type { ExpandAction } from 'rc-tree/lib/Tree';
import type { DataNode, FieldNames, Key } from './interface';
import type useDataEntities from './hooks/useDataEntities';
export interface TreeSelectContextProps {
virtual?: boolean;
dropdownMatchSelectWidth?: boolean | number;
listHeight: number;
listItemHeight: number;
listItemScrollOffset?: number;
treeData: DataNode[];
fieldNames: FieldNames;
onSelect: (value: Key, info: {
selected: boolean;
}) => void;
treeExpandAction?: ExpandAction;
treeTitleRender?: (node: any) => React.ReactNode;
onPopupScroll?: React.UIEventHandler<HTMLDivElement>;
leftMaxCount: number | null;
/** When `true`, only take leaf node as count, or take all as count with `maxCount` limitation */
leafCountOnly: boolean;
valueEntities: ReturnType<typeof useDataEntities>['valueEntities'];
}
declare const TreeSelectContext: React.Context<TreeSelectContextProps>;
export default TreeSelectContext;

3
node_modules/rc-tree-select/es/TreeSelectContext.js generated vendored Normal file
View File

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

7
node_modules/rc-tree-select/es/hooks/useCache.d.ts generated vendored Normal file
View File

@@ -0,0 +1,7 @@
import type { LabeledValueType } from '../interface';
/**
* This function will try to call requestIdleCallback if available to save performance.
* No need `getLabel` here since already fetch on `rawLabeledValue`.
*/
declare const _default: (values: LabeledValueType[]) => [LabeledValueType[]];
export default _default;

28
node_modules/rc-tree-select/es/hooks/useCache.js generated vendored Normal file
View File

@@ -0,0 +1,28 @@
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import * as React from 'react';
/**
* This function will try to call requestIdleCallback if available to save performance.
* No need `getLabel` here since already fetch on `rawLabeledValue`.
*/
export default (function (values) {
var cacheRef = React.useRef({
valueLabels: new Map()
});
return React.useMemo(function () {
var valueLabels = cacheRef.current.valueLabels;
var valueLabelsCache = new Map();
var filledValues = values.map(function (item) {
var value = item.value,
label = item.label;
var mergedLabel = label !== null && label !== void 0 ? label : valueLabels.get(value);
// Save in cache
valueLabelsCache.set(value, mergedLabel);
return _objectSpread(_objectSpread({}, item), {}, {
label: mergedLabel
});
});
cacheRef.current.valueLabels = valueLabelsCache;
return [filledValues];
}, [values]);
});

View File

@@ -0,0 +1,5 @@
import * as React from 'react';
import type { DataEntity } from 'rc-tree/lib/interface';
import type { LabeledValueType, SafeKey } from '../interface';
declare const useCheckedKeys: (rawLabeledValues: LabeledValueType[], rawHalfCheckedValues: LabeledValueType[], treeConduction: boolean, keyEntities: Record<SafeKey, DataEntity>) => React.Key[][];
export default useCheckedKeys;

27
node_modules/rc-tree-select/es/hooks/useCheckedKeys.js generated vendored Normal file
View File

@@ -0,0 +1,27 @@
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
import * as React from 'react';
import { conductCheck } from "rc-tree/es/utils/conductUtil";
var useCheckedKeys = function useCheckedKeys(rawLabeledValues, rawHalfCheckedValues, treeConduction, keyEntities) {
return React.useMemo(function () {
var extractValues = function extractValues(values) {
return values.map(function (_ref) {
var value = _ref.value;
return value;
});
};
var checkedKeys = extractValues(rawLabeledValues);
var halfCheckedKeys = extractValues(rawHalfCheckedValues);
var missingValues = checkedKeys.filter(function (key) {
return !keyEntities[key];
});
var finalCheckedKeys = checkedKeys;
var finalHalfCheckedKeys = halfCheckedKeys;
if (treeConduction) {
var conductResult = conductCheck(checkedKeys, true, keyEntities);
finalCheckedKeys = conductResult.checkedKeys;
finalHalfCheckedKeys = conductResult.halfCheckedKeys;
}
return [Array.from(new Set([].concat(_toConsumableArray(missingValues), _toConsumableArray(finalCheckedKeys)))), finalHalfCheckedKeys];
}, [rawLabeledValues, rawHalfCheckedValues, treeConduction, keyEntities]);
};
export default useCheckedKeys;

View File

@@ -0,0 +1,7 @@
import type { DataEntity } from 'rc-tree/lib/interface';
import type { SafeKey, FieldNames } from '../interface';
declare const _default: (treeData: any, fieldNames: FieldNames) => {
valueEntities: Map<SafeKey, DataEntity>;
keyEntities: Record<string, DataEntity>;
};
export default _default;

View File

@@ -0,0 +1,30 @@
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import * as React from 'react';
import { convertDataToEntities } from "rc-tree/es/utils/treeUtil";
import warning from "rc-util/es/warning";
import { isNil } from "../utils/valueUtil";
export default (function (treeData, fieldNames) {
return React.useMemo(function () {
var collection = convertDataToEntities(treeData, {
fieldNames: fieldNames,
initWrapper: function initWrapper(wrapper) {
return _objectSpread(_objectSpread({}, wrapper), {}, {
valueEntities: new Map()
});
},
processEntity: function processEntity(entity, wrapper) {
var val = entity.node[fieldNames.value];
// Check if exist same value
if (process.env.NODE_ENV !== 'production') {
var key = entity.node.key;
warning(!isNil(val), 'TreeNode `value` is invalidate: undefined');
warning(!wrapper.valueEntities.has(val), "Same `value` exist in the tree: ".concat(val));
warning(!key || String(key) === String(val), "`key` or `value` with TreeNode must be the same or you can remove one of them. key: ".concat(key, ", value: ").concat(val, "."));
}
wrapper.valueEntities.set(val, entity);
}
});
return collection;
}, [treeData, fieldNames]);
});

View File

@@ -0,0 +1,8 @@
import type { TreeSelectProps } from '../TreeSelect';
import type { DataNode, FieldNames } from '../interface';
declare const useFilterTreeData: (treeData: DataNode[], searchValue: string, options: {
fieldNames: FieldNames;
treeNodeFilterProp: string;
filterTreeNode: TreeSelectProps['filterTreeNode'];
}) => DataNode[];
export default useFilterTreeData;

View File

@@ -0,0 +1,34 @@
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import * as React from 'react';
import { fillLegacyProps } from "../utils/legacyUtil";
var useFilterTreeData = function useFilterTreeData(treeData, searchValue, options) {
var fieldNames = options.fieldNames,
treeNodeFilterProp = options.treeNodeFilterProp,
filterTreeNode = options.filterTreeNode;
var fieldChildren = fieldNames.children;
return React.useMemo(function () {
if (!searchValue || filterTreeNode === false) {
return treeData;
}
var filterOptionFunc = typeof filterTreeNode === 'function' ? filterTreeNode : function (_, dataNode) {
return String(dataNode[treeNodeFilterProp]).toUpperCase().includes(searchValue.toUpperCase());
};
var filterTreeNodes = function filterTreeNodes(nodes) {
var keepAll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
return nodes.reduce(function (filtered, node) {
var children = node[fieldChildren];
var isMatch = keepAll || filterOptionFunc(searchValue, fillLegacyProps(node));
var filteredChildren = filterTreeNodes(children || [], isMatch);
if (isMatch || filteredChildren.length) {
filtered.push(_objectSpread(_objectSpread({}, node), {}, _defineProperty({
isLeaf: undefined
}, fieldChildren, filteredChildren)));
}
return filtered;
}, []);
};
return filterTreeNodes(treeData);
}, [treeData, searchValue, fieldChildren, treeNodeFilterProp, filterTreeNode]);
};
export default useFilterTreeData;

5
node_modules/rc-tree-select/es/hooks/useRefFunc.d.ts generated vendored Normal file
View File

@@ -0,0 +1,5 @@
/**
* Same as `React.useCallback` but always return a memoized function
* but redirect to real function.
*/
export default function useRefFunc<T extends (...args: any[]) => any>(callback: T): T;

14
node_modules/rc-tree-select/es/hooks/useRefFunc.js generated vendored Normal file
View File

@@ -0,0 +1,14 @@
import * as React from 'react';
/**
* Same as `React.useCallback` but always return a memoized function
* but redirect to real function.
*/
export default function useRefFunc(callback) {
var funcRef = React.useRef();
funcRef.current = callback;
var cacheFn = React.useCallback(function () {
return funcRef.current.apply(funcRef, arguments);
}, []);
return cacheFn;
}

View File

@@ -0,0 +1,7 @@
import * as React from 'react';
import type { DataNode, SimpleModeConfig } from '../interface';
/**
* 将 `treeData` 或 `children` 转换为格式化的 `treeData`。
* 如果 `treeData` 或 `children` 没有变化,则不会重新计算。
*/
export default function useTreeData(treeData: DataNode[], children: React.ReactNode, simpleMode: boolean | SimpleModeConfig): DataNode[];

50
node_modules/rc-tree-select/es/hooks/useTreeData.js generated vendored Normal file
View File

@@ -0,0 +1,50 @@
import _typeof from "@babel/runtime/helpers/esm/typeof";
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import * as React from 'react';
import { convertChildrenToData } from "../utils/legacyUtil";
function buildTreeStructure(nodes, config) {
var id = config.id,
pId = config.pId,
rootPId = config.rootPId;
var nodeMap = new Map();
var rootNodes = [];
nodes.forEach(function (node) {
var nodeKey = node[id];
var clonedNode = _objectSpread(_objectSpread({}, node), {}, {
key: node.key || nodeKey
});
nodeMap.set(nodeKey, clonedNode);
});
nodeMap.forEach(function (node) {
var parentKey = node[pId];
var parent = nodeMap.get(parentKey);
if (parent) {
parent.children = parent.children || [];
parent.children.push(node);
} else if (parentKey === rootPId || rootPId === null) {
rootNodes.push(node);
}
});
return rootNodes;
}
/**
* 将 `treeData` 或 `children` 转换为格式化的 `treeData`。
* 如果 `treeData` 或 `children` 没有变化,则不会重新计算。
*/
export default function useTreeData(treeData, children, simpleMode) {
return React.useMemo(function () {
if (treeData) {
if (simpleMode) {
var config = _objectSpread({
id: 'id',
pId: 'pId',
rootPId: null
}, _typeof(simpleMode) === 'object' ? simpleMode : {});
return buildTreeStructure(treeData, config);
}
return treeData;
}
return convertChildrenToData(children);
}, [children, simpleMode, treeData]);
}

7
node_modules/rc-tree-select/es/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,7 @@
import TreeSelect from './TreeSelect';
import type { TreeSelectProps } from './TreeSelect';
import TreeNode from './TreeNode';
import { SHOW_ALL, SHOW_CHILD, SHOW_PARENT } from './utils/strategyUtil';
export { TreeNode, SHOW_ALL, SHOW_CHILD, SHOW_PARENT };
export type { TreeSelectProps };
export default TreeSelect;

5
node_modules/rc-tree-select/es/index.js generated vendored Normal file
View File

@@ -0,0 +1,5 @@
import TreeSelect from "./TreeSelect";
import TreeNode from "./TreeNode";
import { SHOW_ALL, SHOW_CHILD, SHOW_PARENT } from "./utils/strategyUtil";
export { TreeNode, SHOW_ALL, SHOW_CHILD, SHOW_PARENT };
export default TreeSelect;

57
node_modules/rc-tree-select/es/interface.d.ts generated vendored Normal file
View File

@@ -0,0 +1,57 @@
import type * as React from 'react';
import type { SafeKey, Key, DataNode as TreeDataNode } from 'rc-tree/lib/interface';
export type { SafeKey, Key };
export interface DataNode extends Record<string, any>, Omit<TreeDataNode, 'key' | 'children'> {
key?: Key;
value?: SafeKey;
children?: DataNode[];
}
export type SelectSource = 'option' | 'selection' | 'input' | 'clear';
export interface LabeledValueType {
key?: Key;
value?: SafeKey;
label?: React.ReactNode;
/** Only works on `treeCheckStrictly` */
halfChecked?: boolean;
}
export type DefaultValueType = SafeKey | LabeledValueType | (SafeKey | LabeledValueType)[];
export interface LegacyDataNode extends DataNode {
props: any;
}
export interface FlattenDataNode {
data: DataNode;
key: Key;
value: SafeKey;
level: number;
parent?: FlattenDataNode;
}
export interface SimpleModeConfig {
id?: SafeKey;
pId?: SafeKey;
rootPId?: SafeKey;
}
/** @deprecated This is only used for legacy compatible. Not works on new code. */
export interface LegacyCheckedNode {
pos: string;
node: React.ReactElement;
children?: LegacyCheckedNode[];
}
export interface ChangeEventExtra {
/** @deprecated Please save prev value by control logic instead */
preValue: LabeledValueType[];
triggerValue: SafeKey;
/** @deprecated Use `onSelect` or `onDeselect` instead. */
selected?: boolean;
/** @deprecated Use `onSelect` or `onDeselect` instead. */
checked?: boolean;
/** @deprecated This prop not work as react node anymore. */
triggerNode: React.ReactElement;
/** @deprecated This prop not work as react node anymore. */
allCheckedNodes: LegacyCheckedNode[];
}
export interface FieldNames {
value?: string;
label?: string;
children?: string;
_title?: string[];
}

1
node_modules/rc-tree-select/es/interface.js generated vendored Normal file
View File

@@ -0,0 +1 @@
export {};

5
node_modules/rc-tree-select/es/utils/legacyUtil.d.ts generated vendored Normal file
View File

@@ -0,0 +1,5 @@
import * as React from 'react';
import type { DataNode, ChangeEventExtra, SafeKey, FieldNames } from '../interface';
export declare function convertChildrenToData(nodes: React.ReactNode): DataNode[];
export declare function fillLegacyProps(dataNode: DataNode): DataNode;
export declare function fillAdditionalInfo(extra: ChangeEventExtra, triggerValue: SafeKey, checkedValues: SafeKey[], treeData: DataNode[], showPosition: boolean, fieldNames: FieldNames): void;

117
node_modules/rc-tree-select/es/utils/legacyUtil.js generated vendored Normal file
View File

@@ -0,0 +1,117 @@
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
var _excluded = ["children", "value"];
import * as React from 'react';
import toArray from "rc-util/es/Children/toArray";
import warning from "rc-util/es/warning";
import TreeNode from "../TreeNode";
export function convertChildrenToData(nodes) {
return toArray(nodes).map(function (node) {
if (! /*#__PURE__*/React.isValidElement(node) || !node.type) {
return null;
}
var _ref = node,
key = _ref.key,
_ref$props = _ref.props,
children = _ref$props.children,
value = _ref$props.value,
restProps = _objectWithoutProperties(_ref$props, _excluded);
var data = _objectSpread({
key: key,
value: value
}, restProps);
var childData = convertChildrenToData(children);
if (childData.length) {
data.children = childData;
}
return data;
}).filter(function (data) {
return data;
});
}
export function fillLegacyProps(dataNode) {
if (!dataNode) {
return dataNode;
}
var cloneNode = _objectSpread({}, dataNode);
if (!('props' in cloneNode)) {
Object.defineProperty(cloneNode, 'props', {
get: function get() {
warning(false, 'New `rc-tree-select` not support return node instance as argument anymore. Please consider to remove `props` access.');
return cloneNode;
}
});
}
return cloneNode;
}
export function fillAdditionalInfo(extra, triggerValue, checkedValues, treeData, showPosition, fieldNames) {
var triggerNode = null;
var nodeList = null;
function generateMap() {
function dig(list) {
var level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '0';
var parentIncluded = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
return list.map(function (option, index) {
var pos = "".concat(level, "-").concat(index);
var value = option[fieldNames.value];
var included = checkedValues.includes(value);
var children = dig(option[fieldNames.children] || [], pos, included);
var node = /*#__PURE__*/React.createElement(TreeNode, option, children.map(function (child) {
return child.node;
}));
// Link with trigger node
if (triggerValue === value) {
triggerNode = node;
}
if (included) {
var checkedNode = {
pos: pos,
node: node,
children: children
};
if (!parentIncluded) {
nodeList.push(checkedNode);
}
return checkedNode;
}
return null;
}).filter(function (node) {
return node;
});
}
if (!nodeList) {
nodeList = [];
dig(treeData);
// Sort to keep the checked node length
nodeList.sort(function (_ref2, _ref3) {
var val1 = _ref2.node.props.value;
var val2 = _ref3.node.props.value;
var index1 = checkedValues.indexOf(val1);
var index2 = checkedValues.indexOf(val2);
return index1 - index2;
});
}
}
Object.defineProperty(extra, 'triggerNode', {
get: function get() {
warning(false, '`triggerNode` is deprecated. Please consider decoupling data with node.');
generateMap();
return triggerNode;
}
});
Object.defineProperty(extra, 'allCheckedNodes', {
get: function get() {
warning(false, '`allCheckedNodes` is deprecated. Please consider decoupling data with node.');
generateMap();
if (showPosition) {
return nodeList;
}
return nodeList.map(function (_ref4) {
var node = _ref4.node;
return node;
});
}
});
}

View File

@@ -0,0 +1,7 @@
import type { DataEntity } from 'rc-tree/lib/interface';
import type { SafeKey, FieldNames } from '../interface';
export declare const SHOW_ALL = "SHOW_ALL";
export declare const SHOW_PARENT = "SHOW_PARENT";
export declare const SHOW_CHILD = "SHOW_CHILD";
export type CheckedStrategy = typeof SHOW_ALL | typeof SHOW_PARENT | typeof SHOW_CHILD;
export declare function formatStrategyValues(values: SafeKey[], strategy: CheckedStrategy, keyEntities: Record<SafeKey, DataEntity>, fieldNames: FieldNames): SafeKey[];

27
node_modules/rc-tree-select/es/utils/strategyUtil.js generated vendored Normal file
View File

@@ -0,0 +1,27 @@
import { isCheckDisabled } from "./valueUtil";
export var SHOW_ALL = 'SHOW_ALL';
export var SHOW_PARENT = 'SHOW_PARENT';
export var SHOW_CHILD = 'SHOW_CHILD';
export function formatStrategyValues(values, strategy, keyEntities, fieldNames) {
var valueSet = new Set(values);
if (strategy === SHOW_CHILD) {
return values.filter(function (key) {
var entity = keyEntities[key];
return !entity || !entity.children || !entity.children.some(function (_ref) {
var node = _ref.node;
return valueSet.has(node[fieldNames.value]);
}) || !entity.children.every(function (_ref2) {
var node = _ref2.node;
return isCheckDisabled(node) || valueSet.has(node[fieldNames.value]);
});
});
}
if (strategy === SHOW_PARENT) {
return values.filter(function (key) {
var entity = keyEntities[key];
var parent = entity ? entity.parent : null;
return !parent || isCheckDisabled(parent.node) || !valueSet.has(parent.key);
});
}
return values;
}

11
node_modules/rc-tree-select/es/utils/valueUtil.d.ts generated vendored Normal file
View File

@@ -0,0 +1,11 @@
import type { DataNode, FieldNames, SafeKey } from '../interface';
export declare const toArray: <T>(value: T | T[]) => T[];
export declare const fillFieldNames: (fieldNames?: FieldNames) => {
_title: string[];
value: string;
key: string;
children: string;
};
export declare const isCheckDisabled: (node: DataNode) => boolean;
export declare const getAllKeys: (treeData: DataNode[], fieldNames: FieldNames) => SafeKey[];
export declare const isNil: (val: any) => boolean;

35
node_modules/rc-tree-select/es/utils/valueUtil.js generated vendored Normal file
View File

@@ -0,0 +1,35 @@
export var toArray = function toArray(value) {
return Array.isArray(value) ? value : value !== undefined ? [value] : [];
};
export var fillFieldNames = function fillFieldNames(fieldNames) {
var _ref = fieldNames || {},
label = _ref.label,
value = _ref.value,
children = _ref.children;
return {
_title: label ? [label] : ['title', 'label'],
value: value || 'value',
key: value || 'value',
children: children || 'children'
};
};
export var isCheckDisabled = function isCheckDisabled(node) {
return !node || node.disabled || node.disableCheckbox || node.checkable === false;
};
export var getAllKeys = function getAllKeys(treeData, fieldNames) {
var keys = [];
var dig = function dig(list) {
list.forEach(function (item) {
var children = item[fieldNames.children];
if (children) {
keys.push(item[fieldNames.value]);
dig(children);
}
});
};
dig(treeData);
return keys;
};
export var isNil = function isNil(val) {
return val === null || val === undefined;
};

View File

@@ -0,0 +1,5 @@
import type { TreeSelectProps } from '../TreeSelect';
declare function warningProps(props: TreeSelectProps & {
searchPlaceholder?: string;
}): void;
export default warningProps;

View File

@@ -0,0 +1,31 @@
import _typeof from "@babel/runtime/helpers/esm/typeof";
import warning from "rc-util/es/warning";
import { toArray } from "./valueUtil";
function warningProps(props) {
var searchPlaceholder = props.searchPlaceholder,
treeCheckStrictly = props.treeCheckStrictly,
treeCheckable = props.treeCheckable,
labelInValue = props.labelInValue,
value = props.value,
multiple = props.multiple,
showCheckedStrategy = props.showCheckedStrategy,
maxCount = props.maxCount;
warning(!searchPlaceholder, '`searchPlaceholder` has been removed.');
if (treeCheckStrictly && labelInValue === false) {
warning(false, '`treeCheckStrictly` will force set `labelInValue` to `true`.');
}
if (labelInValue || treeCheckStrictly) {
warning(toArray(value).every(function (val) {
return val && _typeof(val) === 'object' && 'value' in val;
}), 'Invalid prop `value` supplied to `TreeSelect`. You should use { label: string, value: string | number } or [{ label: string, value: string | number }] instead.');
}
if (treeCheckStrictly || multiple || treeCheckable) {
warning(!value || Array.isArray(value), '`value` should be an array when `TreeSelect` is checkable or multiple.');
} else {
warning(!Array.isArray(value), '`value` should not be array when `TreeSelect` is single mode.');
}
if (maxCount && (showCheckedStrategy === 'SHOW_ALL' && !treeCheckStrictly || showCheckedStrategy === 'SHOW_PARENT')) {
warning(false, '`maxCount` not work with `showCheckedStrategy=SHOW_ALL` (when `treeCheckStrictly=false`) or `showCheckedStrategy=SHOW_PARENT`.');
}
}
export default warningProps;