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

9
node_modules/rc-cascader/LICENSE.md generated vendored Normal file
View File

@@ -0,0 +1,9 @@
The MIT License (MIT)
Copyright (c) 2014-present alipay.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

300
node_modules/rc-cascader/README.md generated vendored Normal file
View File

@@ -0,0 +1,300 @@
# rc-cascader
React Cascader Component.
[![NPM version][npm-image]][npm-url]
[![npm download][download-image]][download-url]
[![build status][github-actions-image]][github-actions-url]
[![Codecov][codecov-image]][codecov-url]
[![bundle size][bundlephobia-image]][bundlephobia-url]
[![dumi][dumi-image]][dumi-url]
[npm-image]: http://img.shields.io/npm/v/rc-cascader.svg?style=flat-square
[npm-url]: http://npmjs.org/package/rc-cascader
[travis-image]: https://img.shields.io/travis/react-component/cascader/master?style=flat-square
[travis-url]: https://travis-ci.com/react-component/cascader
[github-actions-image]: https://github.com/react-component/cascader/workflows/CI/badge.svg
[github-actions-url]: https://github.com/react-component/cascader/actions
[codecov-image]: https://img.shields.io/codecov/c/github/react-component/cascader/master.svg?style=flat-square
[codecov-url]: https://app.codecov.io/gh/react-component/cascader
[david-url]: https://david-dm.org/react-component/cascader
[david-image]: https://david-dm.org/react-component/cascader/status.svg?style=flat-square
[david-dev-url]: https://david-dm.org/react-component/cascader?type=dev
[david-dev-image]: https://david-dm.org/react-component/cascader/dev-status.svg?style=flat-square
[download-image]: https://img.shields.io/npm/dm/rc-cascader.svg?style=flat-square
[download-url]: https://npmjs.org/package/rc-cascader
[bundlephobia-url]: https://bundlephobia.com/package/rc-cascader
[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/rc-cascader
[dumi-url]: https://github.com/umijs/dumi
[dumi-image]: https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square
## Browser Support
| [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="IE / Edge" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>IE / Edge | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Safari | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/electron/electron_48x48.png" alt="Electron" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Electron |
| --- | --- | --- | --- | --- |
| IE11, Edge | last 2 versions | last 2 versions | last 2 versions | last 2 versions |
## Screenshots
<img src="https://os.alipayobjects.com/rmsportal/TYFXEbuQXIaMqQF.png" width="288"/>
## Example
https://cascader-react-component.vercel.app
## Install
[![rc-cascader](https://nodei.co/npm/rc-cascader.png)](https://npmjs.org/package/rc-cascader)
```bash
$ npm install rc-cascader --save
```
## Usage
```js
import React from 'react';
import Cascader from 'rc-cascader';
const options = [{
'label': '福建',
'value': 'fj',
'children': [{
'label': '福州',
'value': 'fuzhou',
'children': [{
'label': '马尾',
'value': 'mawei',
}],
}, {
'label': '泉州',
'value': 'quanzhou',
}],
}, {
'label': '浙江',
'value': 'zj',
'children': [{
'label': '杭州',
'value': 'hangzhou',
'children': [{
'label': '余杭',
'value': 'yuhang',
}],
}],
}, {
'label': '北京',
'value': 'bj',
'children': [{
'label': '朝阳区',
'value': 'chaoyang',
}, {
'label': '海淀区',
'value': 'haidian',
}],
}];
React.render(
<Cascader options={options}>
...
</Cascader>
, container);
```
## API
### props
<table class="table table-bordered table-striped">
<thead>
<tr>
<th style="width: 100px;">name</th>
<th style="width: 50px;">type</th>
<th style="width: 50px;">default</th>
<th>description</th>
</tr>
</thead>
<tbody>
<tr>
<td>autoClearSearchValue</td>
<td>boolean</td>
<td>true</td>
<td>Whether the current search will be cleared on selecting an item. Only applies when checkable</td>
</tr>
<tr>
<td>options</td>
<td>Object</td>
<td></td>
<td>The data options of cascade</td>
</tr>
<tr>
<td>value</td>
<td>Array</td>
<td></td>
<td>selected value</td>
</tr>
<tr>
<td>defaultValue</td>
<td>Array</td>
<td></td>
<td>initial selected value</td>
</tr>
<tr>
<td>onChange</td>
<td>Function(value, selectedOptions)</td>
<td></td>
<td>callback when finishing cascader select</td>
</tr>
<tr>
<td>changeOnSelect</td>
<td>Boolean</td>
<td>false</td>
<td>change value on each selection</td>
</tr>
<tr>
<td>loadData</td>
<td>Function(selectedOptions)</td>
<td></td>
<td>callback when click any option, use for loading more options</td>
</tr>
<tr>
<td>expandTrigger</td>
<td>String</td>
<td>'click'</td>
<td>expand current item when click or hover</td>
</tr>
<tr>
<td>open</td>
<td>Boolean</td>
<td></td>
<td>visibility of popup overlay</td>
</tr>
<tr>
<td>onDropdownVisibleChange</td>
<td>Function(visible)</td>
<td></td>
<td>callback when popup overlay's visibility changed</td>
</tr>
<tr>
<td>transitionName</td>
<td>String</td>
<td></td>
<td>transition className like "slide-up"</td>
</tr>
<tr>
<td>prefixCls</td>
<td>String</td>
<td>rc-cascader</td>
<td>prefix className of popup overlay</td>
</tr>
<tr>
<td>dropdownClassName</td>
<td>String</td>
<td></td>
<td>additional className of popup overlay</td>
</tr>
<tr>
<td>popupPlacement</td>
<td>String</td>
<td>bottomLeft</td>
<td>use preset popup align config from builtinPlacementsbottomRight topRight bottomLeft topLeft</td>
</tr>
<tr>
<td>getPopupContainer</td>
<td>function(trigger:Node):Node</td>
<td>() => document.body</td>
<td>container which popup select menu rendered into</td>
</tr>
<tr>
<td>dropdownMenuColumnStyle</td>
<td>Object</td>
<td></td>
<td>style object for each cascader pop menu</td>
</tr>
<tr>
<td>fieldNames</td>
<td>Object</td>
<td>{ label: 'label', value: 'value', children: 'children' }</td>
<td>custom field name for label and value and children</td>
</tr>
<tr>
<td>expandIcon</td>
<td>ReactNode</td>
<td>></td>
<td>specific the default expand icon</td>
</tr>
<tr>
<td>loadingIcon</td>
<td>ReactNode</td>
<td>></td>
<td>specific the default loading icon</td>
</tr>
<tr>
<td>hidePopupOnSelect</td>
<td>Boolean</td>
<td>>true</td>
<td>hide popup on select</td>
</tr>
</tbody>
</table>
### option
<table class="table table-bordered table-striped">
<thead>
<tr>
<th style="width: 100px;">name</th>
<th style="width: 50px;">type</th>
<th style="width: 50px;">default</th>
<th>description</th>
</tr>
</thead>
<tbody>
<tr>
<td>label</td>
<td>String</td>
<td></td>
<td>option text to display</td>
</tr>
<tr>
<td>value</td>
<td>String</td>
<td></td>
<td>option value as react key</td>
</tr>
<tr>
<td>disabled</td>
<td>Boolean</td>
<td></td>
<td>disabled option</td>
</tr>
<tr>
<td>children</td>
<td>Array</td>
<td></td>
<td>children options</td>
</tr>
</tbody>
</table>
## Development
```bash
$ npm install
$ npm start
```
## Test Case
```bash
$ npm test
```
## Coverage
```bash
$ npm run coverage
```
## License
rc-cascader is released under the MIT license.

3
node_modules/rc-cascader/assets/index.less generated vendored Normal file
View File

@@ -0,0 +1,3 @@
@import "./select.less";
@import "./list.less";
@import "./panel.less";

106
node_modules/rc-cascader/assets/list.less generated vendored Normal file
View File

@@ -0,0 +1,106 @@
@select-prefix: ~'rc-cascader';
.@{select-prefix} {
&-dropdown {
min-height: auto;
}
&-menus {
display: flex;
flex-wrap: nowrap;
}
&-menu {
flex: none;
margin: 0;
padding: 0;
list-style: none;
border-left: 1px solid blue;
height: 180px;
min-width: 100px;
overflow: auto;
&:first-child {
border-left: 0;
}
&-item {
display: flex;
flex-wrap: nowrap;
padding-right: 20px;
position: relative;
&:hover {
background: rgba(0, 0, 255, 0.1);
}
&-selected {
background: rgba(0, 0, 255, 0.05);
}
&-active {
background: rgba(0, 255, 0, 0.1);
}
&-disabled {
opacity: 0.5;
}
&-content {
flex: auto;
}
&-expand-icon {
position: absolute;
right: 4px;
top: 50%;
transform: translateY(-50%);
}
}
}
&-checkbox {
position: relative;
display: block;
flex: none;
width: 20px;
height: 20px;
border: 1px solid blue;
&::after {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
content: '';
}
&-checked::after {
content: '✔️';
}
&-indeterminate::after {
content: '';
}
}
// ====================== RTL ======================
&-rtl {
direction: rtl;
.@{select-prefix}-menu {
flex: none;
margin: 0;
padding: 0;
list-style: none;
border-left: none;
border-right: 1px solid blue;
&:first-child {
border-right: 0;
}
}
}
}

7
node_modules/rc-cascader/assets/panel.less generated vendored Normal file
View File

@@ -0,0 +1,7 @@
@import (reference) './index.less';
.@{select-prefix} {
&-panel {
border: 1px solid green;
}
}

3
node_modules/rc-cascader/assets/select.less generated vendored Normal file
View File

@@ -0,0 +1,3 @@
@import '~rc-select/assets/index';
@select-prefix: ~'rc-cascader';

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;

95
node_modules/rc-cascader/lib/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;

269
node_modules/rc-cascader/lib/Cascader.js generated vendored Normal file
View File

@@ -0,0 +1,269 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
var _rcSelect = require("rc-select");
var _useId = _interopRequireDefault(require("rc-select/lib/hooks/useId"));
var _useEvent = _interopRequireDefault(require("rc-util/lib/hooks/useEvent"));
var _useMergedState5 = _interopRequireDefault(require("rc-util/lib/hooks/useMergedState"));
var React = _interopRequireWildcard(require("react"));
var _context = _interopRequireDefault(require("./context"));
var _useDisplayValues = _interopRequireDefault(require("./hooks/useDisplayValues"));
var _useMissingValues = _interopRequireDefault(require("./hooks/useMissingValues"));
var _useOptions3 = _interopRequireDefault(require("./hooks/useOptions"));
var _useSearchConfig3 = _interopRequireDefault(require("./hooks/useSearchConfig"));
var _useSearchOptions = _interopRequireDefault(require("./hooks/useSearchOptions"));
var _useSelect = _interopRequireDefault(require("./hooks/useSelect"));
var _useValues3 = _interopRequireDefault(require("./hooks/useValues"));
var _OptionList = _interopRequireDefault(require("./OptionList"));
var _Panel = _interopRequireDefault(require("./Panel"));
var _commonUtil = require("./utils/commonUtil");
var _treeUtil = require("./utils/treeUtil");
var _warningPropsUtil = _interopRequireWildcard(require("./utils/warningPropsUtil"));
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"];
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 ? _commonUtil.SHOW_PARENT : _props$showCheckedStr,
optionRender = props.optionRender,
restProps = (0, _objectWithoutProperties2.default)(props, _excluded);
var mergedId = (0, _useId.default)(id);
var multiple = !!checkable;
// =========================== Values ===========================
var _useMergedState = (0, _useMergedState5.default)(defaultValue, {
value: value,
postState: _commonUtil.toRawValues
}),
_useMergedState2 = (0, _slicedToArray2.default)(_useMergedState, 2),
rawValues = _useMergedState2[0],
setRawValues = _useMergedState2[1];
// ========================= FieldNames =========================
var mergedFieldNames = React.useMemo(function () {
return (0, _commonUtil.fillFieldNames)(fieldNames);
}, /* eslint-disable react-hooks/exhaustive-deps */
[JSON.stringify(fieldNames)]
/* eslint-enable react-hooks/exhaustive-deps */);
// =========================== Option ===========================
var _useOptions = (0, _useOptions3.default)(mergedFieldNames, options),
_useOptions2 = (0, _slicedToArray2.default)(_useOptions, 3),
mergedOptions = _useOptions2[0],
getPathKeyEntities = _useOptions2[1],
getValueByKeyPath = _useOptions2[2];
// =========================== Search ===========================
var _useMergedState3 = (0, _useMergedState5.default)('', {
value: searchValue,
postState: function postState(search) {
return search || '';
}
}),
_useMergedState4 = (0, _slicedToArray2.default)(_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 = (0, _useSearchConfig3.default)(showSearch),
_useSearchConfig2 = (0, _slicedToArray2.default)(_useSearchConfig, 2),
mergedShowSearch = _useSearchConfig2[0],
searchConfig = _useSearchConfig2[1];
var searchOptions = (0, _useSearchOptions.default)(mergedSearchValue, mergedOptions, mergedFieldNames, dropdownPrefixCls || prefixCls, searchConfig, changeOnSelect || multiple);
// =========================== Values ===========================
var getMissingValues = (0, _useMissingValues.default)(mergedOptions, mergedFieldNames);
// Fill `rawValues` with checked conduction values
var _useValues = (0, _useValues3.default)(multiple, rawValues, getPathKeyEntities, getValueByKeyPath, getMissingValues),
_useValues2 = (0, _slicedToArray2.default)(_useValues, 3),
checkedValues = _useValues2[0],
halfCheckedValues = _useValues2[1],
missingCheckedValues = _useValues2[2];
var deDuplicatedValues = React.useMemo(function () {
var checkedKeys = (0, _commonUtil.toPathKeys)(checkedValues);
var deduplicateKeys = (0, _treeUtil.formatStrategyValues)(checkedKeys, getPathKeyEntities, showCheckedStrategy);
return [].concat((0, _toConsumableArray2.default)(missingCheckedValues), (0, _toConsumableArray2.default)(getValueByKeyPath(deduplicateKeys)));
}, [checkedValues, getPathKeyEntities, getValueByKeyPath, missingCheckedValues, showCheckedStrategy]);
var displayValues = (0, _useDisplayValues.default)(deDuplicatedValues, mergedOptions, mergedFieldNames, multiple, displayRender);
// =========================== Change ===========================
var triggerChange = (0, _useEvent.default)(function (nextValues) {
setRawValues(nextValues);
// Save perf if no need trigger event
if (onChange) {
var nextRawValues = (0, _commonUtil.toRawValues)(nextValues);
var valueOptions = nextRawValues.map(function (valueCells) {
return (0, _treeUtil.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 = (0, _useSelect.default)(multiple, triggerChange, checkedValues, halfCheckedValues, missingCheckedValues, getPathKeyEntities, getValueByKeyPath, showCheckedStrategy);
var onInternalSelect = (0, _useEvent.default)(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') {
(0, _warningPropsUtil.default)(props);
(0, _warningPropsUtil.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(_context.default.Provider, {
value: cascaderContext
}, /*#__PURE__*/React.createElement(_rcSelect.BaseSelect, (0, _extends2.default)({}, restProps, {
// MISC
ref: ref,
id: mergedId,
prefixCls: prefixCls,
autoClearSearchValue: autoClearSearchValue,
dropdownMatchSelectWidth: dropdownMatchSelectWidth,
dropdownStyle: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, dropdownStyle), customDropdownStyle)
// Value
,
displayValues: displayValues,
onDisplayValuesChange: onDisplayValuesChange,
mode: multiple ? 'multiple' : undefined
// Search
,
searchValue: mergedSearchValue,
onSearch: onInternalSearch,
showSearch: mergedShowSearch
// Options
,
OptionList: _OptionList.default,
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 = _commonUtil.SHOW_PARENT;
Cascader.SHOW_CHILD = _commonUtil.SHOW_CHILD;
Cascader.Panel = _Panel.default;
var _default = exports.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;

View File

@@ -0,0 +1,18 @@
"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var React = _interopRequireWildcard(require("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';
}
var _default = exports.default = CacheContent;

10
node_modules/rc-cascader/lib/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;

28
node_modules/rc-cascader/lib/OptionList/Checkbox.js generated vendored Normal file
View File

@@ -0,0 +1,28 @@
"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = Checkbox;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var React = _interopRequireWildcard(require("react"));
var _classnames = _interopRequireDefault(require("classnames"));
var _context = _interopRequireDefault(require("../context"));
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(_context.default),
checkable = _React$useContext.checkable;
var customCheckbox = typeof checkable !== 'boolean' ? checkable : null;
return /*#__PURE__*/React.createElement("span", {
className: (0, _classnames.default)("".concat(prefixCls), (_classNames = {}, (0, _defineProperty2.default)(_classNames, "".concat(prefixCls, "-checked"), checked), (0, _defineProperty2.default)(_classNames, "".concat(prefixCls, "-indeterminate"), !checked && halfChecked), (0, _defineProperty2.default)(_classNames, "".concat(prefixCls, "-disabled"), disabled || disableCheckbox), _classNames)),
onClick: onClick
}, customCheckbox);
}

21
node_modules/rc-cascader/lib/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;

184
node_modules/rc-cascader/lib/OptionList/Column.js generated vendored Normal file
View File

@@ -0,0 +1,184 @@
"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.FIX_LABEL = void 0;
exports.default = Column;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
var _classnames = _interopRequireDefault(require("classnames"));
var React = _interopRequireWildcard(require("react"));
var _context = _interopRequireDefault(require("../context"));
var _useSearchOptions = require("../hooks/useSearchOptions");
var _commonUtil = require("../utils/commonUtil");
var _Checkbox = _interopRequireDefault(require("./Checkbox"));
var FIX_LABEL = exports.FIX_LABEL = '__cascader_fix_label__';
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(_context.default),
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[_useSearchOptions.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 = (0, _commonUtil.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((0, _toConsumableArray2.default)(prevValuePath), [value]);
var fullPathKey = (0, _commonUtil.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 = (0, _toConsumableArray2.default)(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: (0, _classnames.default)(menuItemPrefixCls, (_classNames = {}, (0, _defineProperty2.default)(_classNames, "".concat(menuItemPrefixCls, "-expand"), !isMergedLeaf), (0, _defineProperty2.default)(_classNames, "".concat(menuItemPrefixCls, "-active"), activeValue === value || activeValue === fullPathKey), (0, _defineProperty2.default)(_classNames, "".concat(menuItemPrefixCls, "-disabled"), isOptionDisabled(disabled)), (0, _defineProperty2.default)(_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.default, {
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/lib/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;

241
node_modules/rc-cascader/lib/OptionList/List.js generated vendored Normal file
View File

@@ -0,0 +1,241 @@
"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var _classnames = _interopRequireDefault(require("classnames"));
var React = _interopRequireWildcard(require("react"));
var _context = _interopRequireDefault(require("../context"));
var _commonUtil = require("../utils/commonUtil");
var _treeUtil = require("../utils/treeUtil");
var _CacheContent = _interopRequireDefault(require("./CacheContent"));
var _Column = _interopRequireWildcard(require("./Column"));
var _useActive3 = _interopRequireDefault(require("./useActive"));
var _useKeyboard = _interopRequireDefault(require("./useKeyboard"));
/* eslint-disable default-case */
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(_context.default),
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 = (0, _slicedToArray2.default)(_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 = (0, _treeUtil.toPathOptions)(valueCells, options, fieldNames);
var rawOptions = optionList.map(function (_ref) {
var option = _ref.option;
return option;
});
var lastOption = rawOptions[rawOptions.length - 1];
if (lastOption && !(0, _commonUtil.isLeaf)(lastOption, fieldNames)) {
var pathKey = (0, _commonUtil.toPathKey)(valueCells);
setLoadingKeys(function (keys) {
return [].concat((0, _toConsumableArray2.default)(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 = (0, _commonUtil.toPathValueStr)(loadingKey);
var optionList = (0, _treeUtil.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] || (0, _commonUtil.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((0, _commonUtil.toPathKeys)(values));
}, [values]);
var halfCheckedSet = React.useMemo(function () {
return new Set((0, _commonUtil.toPathKeys)(halfValues));
}, [halfValues]);
// ====================== Accessibility =======================
var _useActive = (0, _useActive3.default)(multiple, open),
_useActive2 = (0, _slicedToArray2.default)(_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 = (0, _commonUtil.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 = (0, _commonUtil.getFullPathKeys)(currentList, fieldNames);
var _loop = function _loop() {
var activeValueCell = activeValueCells[i];
var currentOption = currentList.find(function (option, index) {
return (fullPathKeys[index] ? (0, _commonUtil.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, (0, _commonUtil.isLeaf)(option, fieldNames), true);
}
};
(0, _useKeyboard.default)(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 = (0, _commonUtil.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) {
(0, _commonUtil.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 = {}, (0, _defineProperty2.default)(_ref3, fieldNames.value, '__EMPTY__'), (0, _defineProperty2.default)(_ref3, _Column.FIX_LABEL, notFoundContent), (0, _defineProperty2.default)(_ref3, "disabled", true), _ref3)];
var columnProps = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, 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.default, (0, _extends2.default)({
key: index
}, columnProps, {
prefixCls: mergedPrefixCls,
options: col.options,
prevValuePath: prevValuePath,
activeValue: activeValue
}));
});
// >>>>> Render
return /*#__PURE__*/React.createElement(_CacheContent.default, {
open: open
}, /*#__PURE__*/React.createElement("div", {
className: (0, _classnames.default)("".concat(mergedPrefixCls, "-menus"), (_classNames = {}, (0, _defineProperty2.default)(_classNames, "".concat(mergedPrefixCls, "-menu-empty"), isEmpty), (0, _defineProperty2.default)(_classNames, "".concat(mergedPrefixCls, "-rtl"), rtl), _classNames)),
ref: containerRef
}, columnNodes));
});
if (process.env.NODE_ENV !== 'production') {
RawOptionList.displayName = 'RawOptionList';
}
var _default = exports.default = RawOptionList;

4
node_modules/rc-cascader/lib/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;

21
node_modules/rc-cascader/lib/OptionList/index.js generated vendored Normal file
View File

@@ -0,0 +1,21 @@
"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _rcSelect = require("rc-select");
var React = _interopRequireWildcard(require("react"));
var _List = _interopRequireDefault(require("./List"));
var RefOptionList = /*#__PURE__*/React.forwardRef(function (props, ref) {
var baseProps = (0, _rcSelect.useBaseProps)();
// >>>>> Render
return /*#__PURE__*/React.createElement(_List.default, (0, _extends2.default)({}, props, baseProps, {
ref: ref
}));
});
var _default = exports.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;

36
node_modules/rc-cascader/lib/OptionList/useActive.js generated vendored Normal file
View File

@@ -0,0 +1,36 @@
"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var React = _interopRequireWildcard(require("react"));
var _context = _interopRequireDefault(require("../context"));
/**
* Control the active open options path.
*/
var useActive = function useActive(multiple, open) {
var _React$useContext = React.useContext(_context.default),
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 = (0, _slicedToArray2.default)(_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];
};
var _default = exports.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;

188
node_modules/rc-cascader/lib/OptionList/useKeyboard.js generated vendored Normal file
View File

@@ -0,0 +1,188 @@
"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var _KeyCode = _interopRequireDefault(require("rc-util/lib/KeyCode"));
var React = _interopRequireWildcard(require("react"));
var _useSearchOptions = require("../hooks/useSearchOptions");
var _commonUtil = require("../utils/commonUtil");
var _default = exports.default = function _default(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 = (0, _commonUtil.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] ? (0, _commonUtil.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 = (0, _slicedToArray2.default)(_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] ? (0, _commonUtil.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((0, _toConsumableArray2.default)(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.default.UP:
case _KeyCode.default.DOWN:
{
var offset = 0;
if (which === _KeyCode.default.UP) {
offset = -1;
} else if (which === _KeyCode.default.DOWN) {
offset = 1;
}
if (offset !== 0) {
offsetActiveOption(offset);
}
break;
}
case _KeyCode.default.LEFT:
{
if (searchValue) {
break;
}
if (rtl) {
nextColumn();
} else {
prevColumn();
}
break;
}
case _KeyCode.default.RIGHT:
{
if (searchValue) {
break;
}
if (rtl) {
prevColumn();
} else {
nextColumn();
}
break;
}
case _KeyCode.default.BACKSPACE:
{
if (!searchValue) {
prevColumn();
}
break;
}
// >>> Select
case _KeyCode.default.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[_useSearchOptions.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.default.ESC:
{
toggleOpen(false);
if (open) {
event.stopPropagation();
}
}
}
},
onKeyUp: function onKeyUp() {}
};
});
};

5
node_modules/rc-cascader/lib/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;

145
node_modules/rc-cascader/lib/Panel.js generated vendored Normal file
View File

@@ -0,0 +1,145 @@
"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = Panel;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var _classnames = _interopRequireDefault(require("classnames"));
var _rcUtil = require("rc-util");
var React = _interopRequireWildcard(require("react"));
var _context = _interopRequireDefault(require("./context"));
var _useMissingValues = _interopRequireDefault(require("./hooks/useMissingValues"));
var _useOptions3 = _interopRequireDefault(require("./hooks/useOptions"));
var _useSelect = _interopRequireDefault(require("./hooks/useSelect"));
var _useValues3 = _interopRequireDefault(require("./hooks/useValues"));
var _List = _interopRequireDefault(require("./OptionList/List"));
var _commonUtil = require("./utils/commonUtil");
var _treeUtil = require("./utils/treeUtil");
function noop() {}
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 = (0, _rcUtil.useMergedState)(defaultValue, {
value: value,
postState: _commonUtil.toRawValues
}),
_useMergedState2 = (0, _slicedToArray2.default)(_useMergedState, 2),
rawValues = _useMergedState2[0],
setRawValues = _useMergedState2[1];
// ========================= FieldNames =========================
var mergedFieldNames = React.useMemo(function () {
return (0, _commonUtil.fillFieldNames)(fieldNames);
}, /* eslint-disable react-hooks/exhaustive-deps */
[JSON.stringify(fieldNames)]
/* eslint-enable react-hooks/exhaustive-deps */);
// =========================== Option ===========================
var _useOptions = (0, _useOptions3.default)(mergedFieldNames, options),
_useOptions2 = (0, _slicedToArray2.default)(_useOptions, 3),
mergedOptions = _useOptions2[0],
getPathKeyEntities = _useOptions2[1],
getValueByKeyPath = _useOptions2[2];
// ========================= Values =========================
var getMissingValues = (0, _useMissingValues.default)(mergedOptions, mergedFieldNames);
// Fill `rawValues` with checked conduction values
var _useValues = (0, _useValues3.default)(multiple, rawValues, getPathKeyEntities, getValueByKeyPath, getMissingValues),
_useValues2 = (0, _slicedToArray2.default)(_useValues, 3),
checkedValues = _useValues2[0],
halfCheckedValues = _useValues2[1],
missingCheckedValues = _useValues2[2];
// =========================== Change ===========================
var triggerChange = (0, _rcUtil.useEvent)(function (nextValues) {
setRawValues(nextValues);
// Save perf if no need trigger event
if (onChange) {
var nextRawValues = (0, _commonUtil.toRawValues)(nextValues);
var valueOptions = nextRawValues.map(function (valueCells) {
return (0, _treeUtil.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 = (0, _useSelect.default)(multiple, triggerChange, checkedValues, halfCheckedValues, missingCheckedValues, getPathKeyEntities, getValueByKeyPath, showCheckedStrategy);
var onInternalSelect = (0, _rcUtil.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(_context.default.Provider, {
value: cascaderContext
}, /*#__PURE__*/React.createElement("div", {
className: (0, _classnames.default)(panelPrefixCls, (_classNames = {}, (0, _defineProperty2.default)(_classNames, "".concat(panelPrefixCls, "-rtl"), direction === 'rtl'), (0, _defineProperty2.default)(_classNames, "".concat(panelPrefixCls, "-empty"), isEmpty), _classNames), className),
style: style
}, isEmpty ? notFoundContent : /*#__PURE__*/React.createElement(_List.default, {
prefixCls: prefixCls,
searchValue: "",
multiple: multiple,
toggleOpen: noop,
open: true,
direction: direction,
disabled: disabled
})));
}

21
node_modules/rc-cascader/lib/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;

10
node_modules/rc-cascader/lib/context.js generated vendored Normal file
View File

@@ -0,0 +1,10 @@
"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var React = _interopRequireWildcard(require("react"));
var CascaderContext = /*#__PURE__*/React.createContext({});
var _default = exports.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;

60
node_modules/rc-cascader/lib/hooks/useDisplayValues.js generated vendored Normal file
View File

@@ -0,0 +1,60 @@
"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
var _treeUtil = require("../utils/treeUtil");
var React = _interopRequireWildcard(require("react"));
var _commonUtil = require("../utils/commonUtil");
var _default = exports.default = function _default(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((0, _typeof2.default)(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((0, _toConsumableArray2.default)(list), [SPLIT, keyedLabel]);
}, []);
};
return rawValues.map(function (valueCells) {
var _valueOptions;
var valueOptions = (0, _treeUtil.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 = (0, _commonUtil.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/lib/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;

47
node_modules/rc-cascader/lib/hooks/useEntities.js generated vendored Normal file
View File

@@ -0,0 +1,47 @@
"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
var React = _interopRequireWildcard(require("react"));
var _treeUtil = require("rc-tree/lib/utils/treeUtil");
var _commonUtil = require("../utils/commonUtil");
/** Lazy parse options data into conduct-able info to avoid perf issue in single mode */
var _default = exports.default = function _default(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 = (0, _treeUtil.convertDataToEntities)(options, {
fieldNames: fieldNames,
initWrapper: function initWrapper(wrapper) {
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, wrapper), {}, {
pathKeyEntities: {}
});
},
processEntity: function processEntity(entity, wrapper) {
var pathKey = entity.nodes.map(function (node) {
return node[fieldNames.value];
}).join(_commonUtil.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[]];

26
node_modules/rc-cascader/lib/hooks/useMissingValues.js generated vendored Normal file
View File

@@ -0,0 +1,26 @@
"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = useMissingValues;
var React = _interopRequireWildcard(require("react"));
var _treeUtil = require("../utils/treeUtil");
function useMissingValues(options, fieldNames) {
return React.useCallback(function (rawValues) {
var missingValues = [];
var existsValues = [];
rawValues.forEach(function (valueCell) {
var pathOptions = (0, _treeUtil.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/lib/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[]
];

30
node_modules/rc-cascader/lib/hooks/useOptions.js generated vendored Normal file
View File

@@ -0,0 +1,30 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = useOptions;
var React = _interopRequireWildcard(require("react"));
var _useEntities = _interopRequireDefault(require("./useEntities"));
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 = (0, _useEntities.default)(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>];

34
node_modules/rc-cascader/lib/hooks/useSearchConfig.js generated vendored Normal file
View File

@@ -0,0 +1,34 @@
"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = useSearchConfig;
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
var _warning = _interopRequireDefault(require("rc-util/lib/warning"));
var React = _interopRequireWildcard(require("react"));
// Convert `showSearch` to unique config
function useSearchConfig(showSearch) {
return React.useMemo(function () {
if (!showSearch) {
return [false, {}];
}
var searchConfig = {
matchInputWidth: true,
limit: 50
};
if (showSearch && (0, _typeof2.default)(showSearch) === 'object') {
searchConfig = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, searchConfig), showSearch);
}
if (searchConfig.limit <= 0) {
searchConfig.limit = false;
if (process.env.NODE_ENV !== 'production') {
(0, _warning.default)(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;

81
node_modules/rc-cascader/lib/hooks/useSearchOptions.js generated vendored Normal file
View File

@@ -0,0 +1,81 @@
"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.SEARCH_MARK = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _objectSpread3 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
var React = _interopRequireWildcard(require("react"));
var SEARCH_MARK = exports.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((0, _toConsumableArray2.default)(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((0, _objectSpread3.default)((0, _objectSpread3.default)({}, option), {}, (_objectSpread2 = {
disabled: mergedDisabled
}, (0, _defineProperty2.default)(_objectSpread2, fieldNames.label, render(search, connectedPathOptions, prefixCls, fieldNames)), (0, _defineProperty2.default)(_objectSpread2, SEARCH_MARK, connectedPathOptions), (0, _defineProperty2.default)(_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]);
};
var _default = exports.default = useSearchOptions;

4
node_modules/rc-cascader/lib/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;

61
node_modules/rc-cascader/lib/hooks/useSelect.js generated vendored Normal file
View File

@@ -0,0 +1,61 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = useSelect;
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
var _conductUtil = require("rc-tree/lib/utils/conductUtil");
var _commonUtil = require("../utils/commonUtil");
var _treeUtil = require("../utils/treeUtil");
function useSelect(multiple, triggerChange, checkedValues, halfCheckedValues, missingCheckedValues, getPathKeyEntities, getValueByKeyPath, showCheckedStrategy) {
return function (valuePath) {
if (!multiple) {
triggerChange(valuePath);
} else {
// Prepare conduct required info
var pathKey = (0, _commonUtil.toPathKey)(valuePath);
var checkedPathKeys = (0, _commonUtil.toPathKeys)(checkedValues);
var halfCheckedPathKeys = (0, _commonUtil.toPathKeys)(halfCheckedValues);
var existInChecked = checkedPathKeys.includes(pathKey);
var existInMissing = missingCheckedValues.some(function (valueCells) {
return (0, _commonUtil.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 (0, _commonUtil.toPathKey)(valueCells) !== pathKey;
});
} else {
// Update checked key first
var nextRawCheckedKeys = existInChecked ? checkedPathKeys.filter(function (key) {
return key !== pathKey;
}) : [].concat((0, _toConsumableArray2.default)(checkedPathKeys), [pathKey]);
var pathKeyEntities = getPathKeyEntities();
// Conduction by selected or not
var checkedKeys;
if (existInChecked) {
var _conductCheck = (0, _conductUtil.conductCheck)(nextRawCheckedKeys, {
checked: false,
halfCheckedKeys: halfCheckedPathKeys
}, pathKeyEntities);
checkedKeys = _conductCheck.checkedKeys;
} else {
var _conductCheck2 = (0, _conductUtil.conductCheck)(nextRawCheckedKeys, true, pathKeyEntities);
checkedKeys = _conductCheck2.checkedKeys;
}
// Roll up to parent level keys
var deDuplicatedKeys = (0, _treeUtil.formatStrategyValues)(checkedKeys, getPathKeyEntities, showCheckedStrategy);
nextCheckedValues = getValueByKeyPath(deDuplicatedKeys);
}
triggerChange([].concat((0, _toConsumableArray2.default)(nextMissingValues), (0, _toConsumableArray2.default)(nextCheckedValues)));
}
};
}

9
node_modules/rc-cascader/lib/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[]
];

32
node_modules/rc-cascader/lib/hooks/useValues.js generated vendored Normal file
View File

@@ -0,0 +1,32 @@
"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = useValues;
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var _conductUtil = require("rc-tree/lib/utils/conductUtil");
var React = _interopRequireWildcard(require("react"));
var _commonUtil = require("../utils/commonUtil");
function useValues(multiple, rawValues, getPathKeyEntities, getValueByKeyPath, getMissingValues) {
// Fill `rawValues` with checked conduction values
return React.useMemo(function () {
var _getMissingValues = getMissingValues(rawValues),
_getMissingValues2 = (0, _slicedToArray2.default)(_getMissingValues, 2),
existValues = _getMissingValues2[0],
missingValues = _getMissingValues2[1];
if (!multiple || !rawValues.length) {
return [existValues, [], missingValues];
}
var keyPathValues = (0, _commonUtil.toPathKeys)(existValues);
var keyPathEntities = getPathKeyEntities();
var _conductCheck = (0, _conductUtil.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/lib/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;

16
node_modules/rc-cascader/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,16 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "Panel", {
enumerable: true,
get: function get() {
return _Panel.default;
}
});
exports.default = void 0;
var _Cascader = _interopRequireDefault(require("./Cascader"));
var _Panel = _interopRequireDefault(require("./Panel"));
var _default = exports.default = _Cascader.default;

18
node_modules/rc-cascader/lib/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[];

90
node_modules/rc-cascader/lib/utils/commonUtil.js generated vendored Normal file
View File

@@ -0,0 +1,90 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.VALUE_SPLIT = exports.SHOW_PARENT = exports.SHOW_CHILD = void 0;
exports.fillFieldNames = fillFieldNames;
exports.getFullPathKeys = getFullPathKeys;
exports.isLeaf = isLeaf;
exports.scrollIntoParentView = scrollIntoParentView;
exports.toPathKey = toPathKey;
exports.toPathKeys = toPathKeys;
exports.toPathValueStr = toPathValueStr;
exports.toRawValues = toRawValues;
var _useSearchOptions = require("../hooks/useSearchOptions");
var VALUE_SPLIT = exports.VALUE_SPLIT = '__RC_CASCADER_SPLIT__';
var SHOW_PARENT = exports.SHOW_PARENT = 'SHOW_PARENT';
var SHOW_CHILD = exports.SHOW_CHILD = 'SHOW_CHILD';
/**
* Will convert value to string, and join with `VALUE_SPLIT`
*/
function toPathKey(value) {
return value.join(VALUE_SPLIT);
}
/**
* Batch convert value to string, and join with `VALUE_SPLIT`
*/
function toPathKeys(value) {
return value.map(toPathKey);
}
function toPathValueStr(pathKey) {
return pathKey.split(VALUE_SPLIT);
}
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'
};
}
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);
}
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
});
}
}
function getFullPathKeys(options, fieldNames) {
return options.map(function (item) {
var _item$SEARCH_MARK;
return (_item$SEARCH_MARK = item[_useSearchOptions.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]);
}
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/lib/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;
}[];

47
node_modules/rc-cascader/lib/utils/treeUtil.js generated vendored Normal file
View File

@@ -0,0 +1,47 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.formatStrategyValues = formatStrategyValues;
exports.toPathOptions = toPathOptions;
var _commonUtil = require("./commonUtil");
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 === _commonUtil.SHOW_CHILD ? !(children && children.some(function (child) {
return child.key && valueSet.has(child.key);
})) : !(parent && !parent.node.disabled && valueSet.has(parent.key));
});
}
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;

41
node_modules/rc-cascader/lib/utils/warningPropsUtil.js generated vendored Normal file
View File

@@ -0,0 +1,41 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
exports.warningNullOptions = warningNullOptions;
var _warning = _interopRequireDefault(require("rc-util/lib/warning"));
function warningProps(props) {
var onPopupVisibleChange = props.onPopupVisibleChange,
popupVisible = props.popupVisible,
popupClassName = props.popupClassName,
popupPlacement = props.popupPlacement,
onDropdownVisibleChange = props.onDropdownVisibleChange;
(0, _warning.default)(!onPopupVisibleChange, '`onPopupVisibleChange` is deprecated. Please use `onOpenChange` instead.');
(0, _warning.default)(!onDropdownVisibleChange, '`onDropdownVisibleChange` is deprecated. Please use `onOpenChange` instead.');
(0, _warning.default)(popupVisible === undefined, '`popupVisible` is deprecated. Please use `open` instead.');
(0, _warning.default)(popupClassName === undefined, '`popupClassName` is deprecated. Please use `dropdownClassName` instead.');
(0, _warning.default)(popupPlacement === undefined, '`popupPlacement` is deprecated. Please use `placement` instead.');
}
// value in Cascader options should not be null
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) {
(0, _warning.default)(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);
}
}
var _default = exports.default = warningProps;

88
node_modules/rc-cascader/package.json generated vendored Normal file
View File

@@ -0,0 +1,88 @@
{
"name": "rc-cascader",
"version": "3.34.0",
"description": "cascade select ui component for react",
"keywords": [
"react",
"react-component",
"react-cascader",
"react-select",
"select",
"cascade",
"cascader"
],
"homepage": "https://github.com/react-component/cascader",
"bugs": {
"url": "https://github.com/react-component/cascader/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/react-component/cascader.git"
},
"license": "MIT",
"author": "afc163@gmail.com",
"main": "./lib/index",
"module": "./es/index",
"files": [
"lib",
"es",
"assets/*.css",
"assets/*.less"
],
"scripts": {
"build": "dumi build",
"compile": "father build",
"coverage": "father test --coverage",
"deploy": "UMI_ENV=gh npm run build && gh-pages -d dist",
"lint": "eslint src/ examples/ --ext .tsx,.ts,.jsx,.jsx",
"now-build": "npm run build",
"prepublishOnly": "npm run compile && np --no-cleanup --yolo --no-publish --any-branch",
"lint:tsc": "tsc -p tsconfig.json --noEmit",
"start": "dumi dev",
"test": "rc-test"
},
"dependencies": {
"@babel/runtime": "^7.25.7",
"classnames": "^2.3.1",
"rc-select": "~14.16.2",
"rc-tree": "~5.13.0",
"rc-util": "^5.43.0"
},
"devDependencies": {
"@rc-component/father-plugin": "^1.0.0",
"@rc-component/trigger": "^1.5.0",
"@testing-library/react": "^12.1.5",
"@types/classnames": "^2.2.6",
"@types/enzyme": "^3.1.15",
"@types/jest": "^29.4.0",
"@types/react": "^17.0.38",
"@types/react-dom": "^18.0.11",
"@types/warning": "^3.0.0",
"@umijs/fabric": "^4.0.0",
"array-tree-filter": "^3.0.2",
"cheerio": "1.0.0-rc.12",
"cross-env": "^7.0.0",
"dumi": "^2.1.10",
"enzyme": "^3.3.0",
"enzyme-adapter-react-16": "^1.15.6",
"enzyme-to-json": "^3.2.1",
"eslint": "^8.54.0",
"eslint-plugin-jest": "^28.8.3",
"eslint-plugin-unicorn": "^52.0.0",
"father": "^4.0.0",
"gh-pages": "^6.1.1",
"glob": "^7.1.6",
"less": "^4.2.0",
"np": "^10.0.2",
"prettier": "^3.1.0",
"rc-field-form": "^1.44.0",
"rc-test": "^7.0.14",
"react": "^16.0.0",
"react-dom": "^16.0.0",
"typescript": "^5.3.2"
},
"peerDependencies": {
"react": ">=16.9.0",
"react-dom": ">=16.9.0"
}
}