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

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]);
}