first commit
This commit is contained in:
7
frontend/node_modules/rc-select/es/BaseSelect/Polite.d.ts
generated
vendored
Normal file
7
frontend/node_modules/rc-select/es/BaseSelect/Polite.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import * as React from 'react';
|
||||
import type { DisplayValueType } from '.';
|
||||
export interface PoliteProps {
|
||||
visible: boolean;
|
||||
values: DisplayValueType[];
|
||||
}
|
||||
export default function Polite(props: PoliteProps): React.JSX.Element;
|
||||
26
frontend/node_modules/rc-select/es/BaseSelect/Polite.js
generated
vendored
Normal file
26
frontend/node_modules/rc-select/es/BaseSelect/Polite.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
||||
import * as React from 'react';
|
||||
export default function Polite(props) {
|
||||
var visible = props.visible,
|
||||
values = props.values;
|
||||
if (!visible) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Only cut part of values since it's a screen reader
|
||||
var MAX_COUNT = 50;
|
||||
return /*#__PURE__*/React.createElement("span", {
|
||||
"aria-live": "polite",
|
||||
style: {
|
||||
width: 0,
|
||||
height: 0,
|
||||
position: 'absolute',
|
||||
overflow: 'hidden',
|
||||
opacity: 0
|
||||
}
|
||||
}, "".concat(values.slice(0, MAX_COUNT).map(function (_ref) {
|
||||
var label = _ref.label,
|
||||
value = _ref.value;
|
||||
return ['number', 'string'].includes(_typeof(label)) ? label : value;
|
||||
}).join(', ')), values.length > MAX_COUNT ? ', ...' : null);
|
||||
}
|
||||
116
frontend/node_modules/rc-select/es/BaseSelect/index.d.ts
generated
vendored
Normal file
116
frontend/node_modules/rc-select/es/BaseSelect/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
import type { AlignType, BuildInPlacements } from '@rc-component/trigger/lib/interface';
|
||||
import type { ScrollConfig, ScrollTo } from 'rc-virtual-list/lib/List';
|
||||
import * as React from 'react';
|
||||
import type { DisplayInfoType, DisplayValueType, Mode, Placement, RawValueType, RenderDOMFunc, RenderNode } from '../interface';
|
||||
export type { DisplayInfoType, DisplayValueType, Mode, Placement, RenderDOMFunc, RenderNode, RawValueType, };
|
||||
export interface RefOptionListProps {
|
||||
onKeyDown: React.KeyboardEventHandler;
|
||||
onKeyUp: React.KeyboardEventHandler;
|
||||
scrollTo?: (args: number | ScrollConfig) => void;
|
||||
}
|
||||
export type CustomTagProps = {
|
||||
label: React.ReactNode;
|
||||
value: any;
|
||||
disabled: boolean;
|
||||
onClose: (event?: React.MouseEvent<HTMLElement, MouseEvent>) => void;
|
||||
closable: boolean;
|
||||
isMaxTag: boolean;
|
||||
};
|
||||
export interface BaseSelectRef {
|
||||
focus: (options?: FocusOptions) => void;
|
||||
blur: () => void;
|
||||
scrollTo: ScrollTo;
|
||||
nativeElement: HTMLElement;
|
||||
}
|
||||
export interface BaseSelectPrivateProps {
|
||||
id: string;
|
||||
prefixCls: string;
|
||||
omitDomProps?: string[];
|
||||
displayValues: DisplayValueType[];
|
||||
onDisplayValuesChange: (values: DisplayValueType[], info: {
|
||||
type: DisplayInfoType;
|
||||
values: DisplayValueType[];
|
||||
}) => void;
|
||||
/** Current dropdown list active item string value */
|
||||
activeValue?: string;
|
||||
/** Link search input with target element */
|
||||
activeDescendantId?: string;
|
||||
onActiveValueChange?: (value: string | null) => void;
|
||||
searchValue: string;
|
||||
autoClearSearchValue?: boolean;
|
||||
/** Trigger onSearch, return false to prevent trigger open event */
|
||||
onSearch: (searchValue: string, info: {
|
||||
source: 'typing' | 'effect' | 'submit' | 'blur';
|
||||
}) => void;
|
||||
/** Trigger when search text match the `tokenSeparators`. Will provide split content */
|
||||
onSearchSplit?: (words: string[]) => void;
|
||||
OptionList: React.ForwardRefExoticComponent<React.PropsWithoutRef<any> & React.RefAttributes<RefOptionListProps>>;
|
||||
/** Tell if provided `options` is empty */
|
||||
emptyOptions: boolean;
|
||||
}
|
||||
export type BaseSelectPropsWithoutPrivate = Omit<BaseSelectProps, keyof BaseSelectPrivateProps>;
|
||||
export interface BaseSelectProps extends BaseSelectPrivateProps, React.AriaAttributes {
|
||||
className?: string;
|
||||
style?: React.CSSProperties;
|
||||
title?: string;
|
||||
showSearch?: boolean;
|
||||
tagRender?: (props: CustomTagProps) => React.ReactElement;
|
||||
direction?: 'ltr' | 'rtl';
|
||||
maxLength?: number;
|
||||
tabIndex?: number;
|
||||
autoFocus?: boolean;
|
||||
notFoundContent?: React.ReactNode;
|
||||
placeholder?: React.ReactNode;
|
||||
onClear?: () => void;
|
||||
choiceTransitionName?: string;
|
||||
mode?: Mode;
|
||||
disabled?: boolean;
|
||||
loading?: boolean;
|
||||
open?: boolean;
|
||||
defaultOpen?: boolean;
|
||||
onDropdownVisibleChange?: (open: boolean) => void;
|
||||
/** @private Internal usage. Do not use in your production. */
|
||||
getInputElement?: () => JSX.Element;
|
||||
/** @private Internal usage. Do not use in your production. */
|
||||
getRawInputElement?: () => JSX.Element;
|
||||
maxTagTextLength?: number;
|
||||
maxTagCount?: number | 'responsive';
|
||||
maxTagPlaceholder?: React.ReactNode | ((omittedValues: DisplayValueType[]) => React.ReactNode);
|
||||
tokenSeparators?: string[];
|
||||
allowClear?: boolean | {
|
||||
clearIcon?: RenderNode;
|
||||
};
|
||||
prefix?: React.ReactNode;
|
||||
suffixIcon?: RenderNode;
|
||||
/**
|
||||
* Clear all icon
|
||||
* @deprecated Please use `allowClear` instead
|
||||
**/
|
||||
clearIcon?: RenderNode;
|
||||
/** Selector remove icon */
|
||||
removeIcon?: RenderNode;
|
||||
animation?: string;
|
||||
transitionName?: string;
|
||||
dropdownStyle?: React.CSSProperties;
|
||||
dropdownClassName?: string;
|
||||
dropdownMatchSelectWidth?: boolean | number;
|
||||
dropdownRender?: (menu: React.ReactElement) => React.ReactElement;
|
||||
dropdownAlign?: AlignType;
|
||||
placement?: Placement;
|
||||
builtinPlacements?: BuildInPlacements;
|
||||
getPopupContainer?: RenderDOMFunc;
|
||||
showAction?: ('focus' | 'click')[];
|
||||
onBlur?: React.FocusEventHandler<HTMLElement>;
|
||||
onFocus?: React.FocusEventHandler<HTMLElement>;
|
||||
onKeyUp?: React.KeyboardEventHandler<HTMLDivElement>;
|
||||
onKeyDown?: React.KeyboardEventHandler<HTMLDivElement>;
|
||||
onMouseDown?: React.MouseEventHandler<HTMLDivElement>;
|
||||
onPopupScroll?: React.UIEventHandler<HTMLDivElement>;
|
||||
onInputKeyDown?: React.KeyboardEventHandler<HTMLInputElement | HTMLTextAreaElement>;
|
||||
onMouseEnter?: React.MouseEventHandler<HTMLDivElement>;
|
||||
onMouseLeave?: React.MouseEventHandler<HTMLDivElement>;
|
||||
onClick?: React.MouseEventHandler<HTMLDivElement>;
|
||||
}
|
||||
export declare const isMultiple: (mode: Mode) => boolean;
|
||||
declare const BaseSelect: React.ForwardRefExoticComponent<BaseSelectProps & React.RefAttributes<BaseSelectRef>>;
|
||||
export default BaseSelect;
|
||||
599
frontend/node_modules/rc-select/es/BaseSelect/index.js
generated
vendored
Normal file
599
frontend/node_modules/rc-select/es/BaseSelect/index.js
generated
vendored
Normal file
@@ -0,0 +1,599 @@
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
||||
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
||||
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
||||
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
||||
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
||||
var _excluded = ["id", "prefixCls", "className", "showSearch", "tagRender", "direction", "omitDomProps", "displayValues", "onDisplayValuesChange", "emptyOptions", "notFoundContent", "onClear", "mode", "disabled", "loading", "getInputElement", "getRawInputElement", "open", "defaultOpen", "onDropdownVisibleChange", "activeValue", "onActiveValueChange", "activeDescendantId", "searchValue", "autoClearSearchValue", "onSearch", "onSearchSplit", "tokenSeparators", "allowClear", "prefix", "suffixIcon", "clearIcon", "OptionList", "animation", "transitionName", "dropdownStyle", "dropdownClassName", "dropdownMatchSelectWidth", "dropdownRender", "dropdownAlign", "placement", "builtinPlacements", "getPopupContainer", "showAction", "onFocus", "onBlur", "onKeyUp", "onKeyDown", "onMouseDown"];
|
||||
import classNames from 'classnames';
|
||||
import useLayoutEffect from "rc-util/es/hooks/useLayoutEffect";
|
||||
import useMergedState from "rc-util/es/hooks/useMergedState";
|
||||
import isMobile from "rc-util/es/isMobile";
|
||||
import { useComposeRef } from "rc-util/es/ref";
|
||||
import * as React from 'react';
|
||||
import { useAllowClear } from "../hooks/useAllowClear";
|
||||
import { BaseSelectContext } from "../hooks/useBaseProps";
|
||||
import useDelayReset from "../hooks/useDelayReset";
|
||||
import useLock from "../hooks/useLock";
|
||||
import useSelectTriggerControl from "../hooks/useSelectTriggerControl";
|
||||
import Selector from "../Selector";
|
||||
import SelectTrigger from "../SelectTrigger";
|
||||
import TransBtn from "../TransBtn";
|
||||
import { getSeparatedContent, isValidCount } from "../utils/valueUtil";
|
||||
import SelectContext from "../SelectContext";
|
||||
import Polite from "./Polite";
|
||||
var DEFAULT_OMIT_PROPS = ['value', 'onChange', 'removeIcon', 'placeholder', 'autoFocus', 'maxTagCount', 'maxTagTextLength', 'maxTagPlaceholder', 'choiceTransitionName', 'onInputKeyDown', 'onPopupScroll', 'tabIndex'];
|
||||
export var isMultiple = function isMultiple(mode) {
|
||||
return mode === 'tags' || mode === 'multiple';
|
||||
};
|
||||
var BaseSelect = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
||||
var _customizeRawInputEle;
|
||||
var id = props.id,
|
||||
prefixCls = props.prefixCls,
|
||||
className = props.className,
|
||||
showSearch = props.showSearch,
|
||||
tagRender = props.tagRender,
|
||||
direction = props.direction,
|
||||
omitDomProps = props.omitDomProps,
|
||||
displayValues = props.displayValues,
|
||||
onDisplayValuesChange = props.onDisplayValuesChange,
|
||||
emptyOptions = props.emptyOptions,
|
||||
_props$notFoundConten = props.notFoundContent,
|
||||
notFoundContent = _props$notFoundConten === void 0 ? 'Not Found' : _props$notFoundConten,
|
||||
onClear = props.onClear,
|
||||
mode = props.mode,
|
||||
disabled = props.disabled,
|
||||
loading = props.loading,
|
||||
getInputElement = props.getInputElement,
|
||||
getRawInputElement = props.getRawInputElement,
|
||||
open = props.open,
|
||||
defaultOpen = props.defaultOpen,
|
||||
onDropdownVisibleChange = props.onDropdownVisibleChange,
|
||||
activeValue = props.activeValue,
|
||||
onActiveValueChange = props.onActiveValueChange,
|
||||
activeDescendantId = props.activeDescendantId,
|
||||
searchValue = props.searchValue,
|
||||
autoClearSearchValue = props.autoClearSearchValue,
|
||||
onSearch = props.onSearch,
|
||||
onSearchSplit = props.onSearchSplit,
|
||||
tokenSeparators = props.tokenSeparators,
|
||||
allowClear = props.allowClear,
|
||||
prefix = props.prefix,
|
||||
suffixIcon = props.suffixIcon,
|
||||
clearIcon = props.clearIcon,
|
||||
OptionList = props.OptionList,
|
||||
animation = props.animation,
|
||||
transitionName = props.transitionName,
|
||||
dropdownStyle = props.dropdownStyle,
|
||||
dropdownClassName = props.dropdownClassName,
|
||||
dropdownMatchSelectWidth = props.dropdownMatchSelectWidth,
|
||||
dropdownRender = props.dropdownRender,
|
||||
dropdownAlign = props.dropdownAlign,
|
||||
placement = props.placement,
|
||||
builtinPlacements = props.builtinPlacements,
|
||||
getPopupContainer = props.getPopupContainer,
|
||||
_props$showAction = props.showAction,
|
||||
showAction = _props$showAction === void 0 ? [] : _props$showAction,
|
||||
onFocus = props.onFocus,
|
||||
onBlur = props.onBlur,
|
||||
onKeyUp = props.onKeyUp,
|
||||
onKeyDown = props.onKeyDown,
|
||||
onMouseDown = props.onMouseDown,
|
||||
restProps = _objectWithoutProperties(props, _excluded);
|
||||
|
||||
// ============================== MISC ==============================
|
||||
var multiple = isMultiple(mode);
|
||||
var mergedShowSearch = (showSearch !== undefined ? showSearch : multiple) || mode === 'combobox';
|
||||
var domProps = _objectSpread({}, restProps);
|
||||
DEFAULT_OMIT_PROPS.forEach(function (propName) {
|
||||
delete domProps[propName];
|
||||
});
|
||||
omitDomProps === null || omitDomProps === void 0 || omitDomProps.forEach(function (propName) {
|
||||
delete domProps[propName];
|
||||
});
|
||||
|
||||
// ============================= Mobile =============================
|
||||
var _React$useState = React.useState(false),
|
||||
_React$useState2 = _slicedToArray(_React$useState, 2),
|
||||
mobile = _React$useState2[0],
|
||||
setMobile = _React$useState2[1];
|
||||
React.useEffect(function () {
|
||||
// Only update on the client side
|
||||
setMobile(isMobile());
|
||||
}, []);
|
||||
|
||||
// ============================== Refs ==============================
|
||||
var containerRef = React.useRef(null);
|
||||
var selectorDomRef = React.useRef(null);
|
||||
var triggerRef = React.useRef(null);
|
||||
var selectorRef = React.useRef(null);
|
||||
var listRef = React.useRef(null);
|
||||
var blurRef = React.useRef(false);
|
||||
|
||||
/** Used for component focused management */
|
||||
var _useDelayReset = useDelayReset(),
|
||||
_useDelayReset2 = _slicedToArray(_useDelayReset, 3),
|
||||
mockFocused = _useDelayReset2[0],
|
||||
setMockFocused = _useDelayReset2[1],
|
||||
cancelSetMockFocused = _useDelayReset2[2];
|
||||
|
||||
// =========================== Imperative ===========================
|
||||
React.useImperativeHandle(ref, function () {
|
||||
var _selectorRef$current, _selectorRef$current2;
|
||||
return {
|
||||
focus: (_selectorRef$current = selectorRef.current) === null || _selectorRef$current === void 0 ? void 0 : _selectorRef$current.focus,
|
||||
blur: (_selectorRef$current2 = selectorRef.current) === null || _selectorRef$current2 === void 0 ? void 0 : _selectorRef$current2.blur,
|
||||
scrollTo: function scrollTo(arg) {
|
||||
var _listRef$current;
|
||||
return (_listRef$current = listRef.current) === null || _listRef$current === void 0 ? void 0 : _listRef$current.scrollTo(arg);
|
||||
},
|
||||
nativeElement: containerRef.current || selectorDomRef.current
|
||||
};
|
||||
});
|
||||
|
||||
// ========================== Search Value ==========================
|
||||
var mergedSearchValue = React.useMemo(function () {
|
||||
var _displayValues$;
|
||||
if (mode !== 'combobox') {
|
||||
return searchValue;
|
||||
}
|
||||
var val = (_displayValues$ = displayValues[0]) === null || _displayValues$ === void 0 ? void 0 : _displayValues$.value;
|
||||
return typeof val === 'string' || typeof val === 'number' ? String(val) : '';
|
||||
}, [searchValue, mode, displayValues]);
|
||||
|
||||
// ========================== Custom Input ==========================
|
||||
// Only works in `combobox`
|
||||
var customizeInputElement = mode === 'combobox' && typeof getInputElement === 'function' && getInputElement() || null;
|
||||
|
||||
// Used for customize replacement for `rc-cascader`
|
||||
var customizeRawInputElement = typeof getRawInputElement === 'function' && getRawInputElement();
|
||||
var customizeRawInputRef = useComposeRef(selectorDomRef, customizeRawInputElement === null || customizeRawInputElement === void 0 || (_customizeRawInputEle = customizeRawInputElement.props) === null || _customizeRawInputEle === void 0 ? void 0 : _customizeRawInputEle.ref);
|
||||
|
||||
// ============================== Open ==============================
|
||||
// SSR not support Portal which means we need delay `open` for the first time render
|
||||
var _React$useState3 = React.useState(false),
|
||||
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
||||
rendered = _React$useState4[0],
|
||||
setRendered = _React$useState4[1];
|
||||
useLayoutEffect(function () {
|
||||
setRendered(true);
|
||||
}, []);
|
||||
var _useMergedState = useMergedState(false, {
|
||||
defaultValue: defaultOpen,
|
||||
value: open
|
||||
}),
|
||||
_useMergedState2 = _slicedToArray(_useMergedState, 2),
|
||||
innerOpen = _useMergedState2[0],
|
||||
setInnerOpen = _useMergedState2[1];
|
||||
var mergedOpen = rendered ? innerOpen : false;
|
||||
|
||||
// Not trigger `open` in `combobox` when `notFoundContent` is empty
|
||||
var emptyListContent = !notFoundContent && emptyOptions;
|
||||
if (disabled || emptyListContent && mergedOpen && mode === 'combobox') {
|
||||
mergedOpen = false;
|
||||
}
|
||||
var triggerOpen = emptyListContent ? false : mergedOpen;
|
||||
var onToggleOpen = React.useCallback(function (newOpen) {
|
||||
var nextOpen = newOpen !== undefined ? newOpen : !mergedOpen;
|
||||
if (!disabled) {
|
||||
setInnerOpen(nextOpen);
|
||||
if (mergedOpen !== nextOpen) {
|
||||
onDropdownVisibleChange === null || onDropdownVisibleChange === void 0 || onDropdownVisibleChange(nextOpen);
|
||||
}
|
||||
}
|
||||
}, [disabled, mergedOpen, setInnerOpen, onDropdownVisibleChange]);
|
||||
|
||||
// ============================= Search =============================
|
||||
var tokenWithEnter = React.useMemo(function () {
|
||||
return (tokenSeparators || []).some(function (tokenSeparator) {
|
||||
return ['\n', '\r\n'].includes(tokenSeparator);
|
||||
});
|
||||
}, [tokenSeparators]);
|
||||
var _ref = React.useContext(SelectContext) || {},
|
||||
maxCount = _ref.maxCount,
|
||||
rawValues = _ref.rawValues;
|
||||
var onInternalSearch = function onInternalSearch(searchText, fromTyping, isCompositing) {
|
||||
if (multiple && isValidCount(maxCount) && (rawValues === null || rawValues === void 0 ? void 0 : rawValues.size) >= maxCount) {
|
||||
return;
|
||||
}
|
||||
var ret = true;
|
||||
var newSearchText = searchText;
|
||||
onActiveValueChange === null || onActiveValueChange === void 0 || onActiveValueChange(null);
|
||||
var separatedList = getSeparatedContent(searchText, tokenSeparators, isValidCount(maxCount) ? maxCount - rawValues.size : undefined);
|
||||
|
||||
// Check if match the `tokenSeparators`
|
||||
var patchLabels = isCompositing ? null : separatedList;
|
||||
|
||||
// Ignore combobox since it's not split-able
|
||||
if (mode !== 'combobox' && patchLabels) {
|
||||
newSearchText = '';
|
||||
onSearchSplit === null || onSearchSplit === void 0 || onSearchSplit(patchLabels);
|
||||
|
||||
// Should close when paste finish
|
||||
onToggleOpen(false);
|
||||
|
||||
// Tell Selector that break next actions
|
||||
ret = false;
|
||||
}
|
||||
if (onSearch && mergedSearchValue !== newSearchText) {
|
||||
onSearch(newSearchText, {
|
||||
source: fromTyping ? 'typing' : 'effect'
|
||||
});
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
// Only triggered when menu is closed & mode is tags
|
||||
// If menu is open, OptionList will take charge
|
||||
// If mode isn't tags, press enter is not meaningful when you can't see any option
|
||||
var onInternalSearchSubmit = function onInternalSearchSubmit(searchText) {
|
||||
// prevent empty tags from appearing when you click the Enter button
|
||||
if (!searchText || !searchText.trim()) {
|
||||
return;
|
||||
}
|
||||
onSearch(searchText, {
|
||||
source: 'submit'
|
||||
});
|
||||
};
|
||||
|
||||
// Close will clean up single mode search text
|
||||
React.useEffect(function () {
|
||||
if (!mergedOpen && !multiple && mode !== 'combobox') {
|
||||
onInternalSearch('', false, false);
|
||||
}
|
||||
}, [mergedOpen]);
|
||||
|
||||
// ============================ Disabled ============================
|
||||
// Close dropdown & remove focus state when disabled change
|
||||
React.useEffect(function () {
|
||||
if (innerOpen && disabled) {
|
||||
setInnerOpen(false);
|
||||
}
|
||||
|
||||
// After onBlur is triggered, the focused does not need to be reset
|
||||
if (disabled && !blurRef.current) {
|
||||
setMockFocused(false);
|
||||
}
|
||||
}, [disabled]);
|
||||
|
||||
// ============================ Keyboard ============================
|
||||
/**
|
||||
* We record input value here to check if can press to clean up by backspace
|
||||
* - null: Key is not down, this is reset by key up
|
||||
* - true: Search text is empty when first time backspace down
|
||||
* - false: Search text is not empty when first time backspace down
|
||||
*/
|
||||
var _useLock = useLock(),
|
||||
_useLock2 = _slicedToArray(_useLock, 2),
|
||||
getClearLock = _useLock2[0],
|
||||
setClearLock = _useLock2[1];
|
||||
var keyLockRef = React.useRef(false);
|
||||
|
||||
// KeyDown
|
||||
var onInternalKeyDown = function onInternalKeyDown(event) {
|
||||
var clearLock = getClearLock();
|
||||
var key = event.key;
|
||||
var isEnterKey = key === 'Enter';
|
||||
if (isEnterKey) {
|
||||
// Do not submit form when type in the input
|
||||
if (mode !== 'combobox') {
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
// We only manage open state here, close logic should handle by list component
|
||||
if (!mergedOpen) {
|
||||
onToggleOpen(true);
|
||||
}
|
||||
}
|
||||
setClearLock(!!mergedSearchValue);
|
||||
|
||||
// Remove value by `backspace`
|
||||
if (key === 'Backspace' && !clearLock && multiple && !mergedSearchValue && displayValues.length) {
|
||||
var cloneDisplayValues = _toConsumableArray(displayValues);
|
||||
var removedDisplayValue = null;
|
||||
for (var i = cloneDisplayValues.length - 1; i >= 0; i -= 1) {
|
||||
var current = cloneDisplayValues[i];
|
||||
if (!current.disabled) {
|
||||
cloneDisplayValues.splice(i, 1);
|
||||
removedDisplayValue = current;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (removedDisplayValue) {
|
||||
onDisplayValuesChange(cloneDisplayValues, {
|
||||
type: 'remove',
|
||||
values: [removedDisplayValue]
|
||||
});
|
||||
}
|
||||
}
|
||||
for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
||||
rest[_key - 1] = arguments[_key];
|
||||
}
|
||||
if (mergedOpen && (!isEnterKey || !keyLockRef.current)) {
|
||||
var _listRef$current2;
|
||||
// Lock the Enter key after it is pressed to avoid repeated triggering of the onChange event.
|
||||
if (isEnterKey) {
|
||||
keyLockRef.current = true;
|
||||
}
|
||||
(_listRef$current2 = listRef.current) === null || _listRef$current2 === void 0 || _listRef$current2.onKeyDown.apply(_listRef$current2, [event].concat(rest));
|
||||
}
|
||||
onKeyDown === null || onKeyDown === void 0 || onKeyDown.apply(void 0, [event].concat(rest));
|
||||
};
|
||||
|
||||
// KeyUp
|
||||
var onInternalKeyUp = function onInternalKeyUp(event) {
|
||||
for (var _len2 = arguments.length, rest = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
||||
rest[_key2 - 1] = arguments[_key2];
|
||||
}
|
||||
if (mergedOpen) {
|
||||
var _listRef$current3;
|
||||
(_listRef$current3 = listRef.current) === null || _listRef$current3 === void 0 || _listRef$current3.onKeyUp.apply(_listRef$current3, [event].concat(rest));
|
||||
}
|
||||
if (event.key === 'Enter') {
|
||||
keyLockRef.current = false;
|
||||
}
|
||||
onKeyUp === null || onKeyUp === void 0 || onKeyUp.apply(void 0, [event].concat(rest));
|
||||
};
|
||||
|
||||
// ============================ Selector ============================
|
||||
var onSelectorRemove = function onSelectorRemove(val) {
|
||||
var newValues = displayValues.filter(function (i) {
|
||||
return i !== val;
|
||||
});
|
||||
onDisplayValuesChange(newValues, {
|
||||
type: 'remove',
|
||||
values: [val]
|
||||
});
|
||||
};
|
||||
var onInputBlur = function onInputBlur() {
|
||||
// Unlock the Enter key after the input blur; otherwise, the Enter key needs to be pressed twice to trigger the correct effect.
|
||||
keyLockRef.current = false;
|
||||
};
|
||||
|
||||
// ========================== Focus / Blur ==========================
|
||||
/** Record real focus status */
|
||||
var focusRef = React.useRef(false);
|
||||
var onContainerFocus = function onContainerFocus() {
|
||||
setMockFocused(true);
|
||||
if (!disabled) {
|
||||
if (onFocus && !focusRef.current) {
|
||||
onFocus.apply(void 0, arguments);
|
||||
}
|
||||
|
||||
// `showAction` should handle `focus` if set
|
||||
if (showAction.includes('focus')) {
|
||||
onToggleOpen(true);
|
||||
}
|
||||
}
|
||||
focusRef.current = true;
|
||||
};
|
||||
var onContainerBlur = function onContainerBlur() {
|
||||
blurRef.current = true;
|
||||
setMockFocused(false, function () {
|
||||
focusRef.current = false;
|
||||
blurRef.current = false;
|
||||
onToggleOpen(false);
|
||||
});
|
||||
if (disabled) {
|
||||
return;
|
||||
}
|
||||
if (mergedSearchValue) {
|
||||
// `tags` mode should move `searchValue` into values
|
||||
if (mode === 'tags') {
|
||||
onSearch(mergedSearchValue, {
|
||||
source: 'submit'
|
||||
});
|
||||
} else if (mode === 'multiple') {
|
||||
// `multiple` mode only clean the search value but not trigger event
|
||||
onSearch('', {
|
||||
source: 'blur'
|
||||
});
|
||||
}
|
||||
}
|
||||
if (onBlur) {
|
||||
onBlur.apply(void 0, arguments);
|
||||
}
|
||||
};
|
||||
|
||||
// Give focus back of Select
|
||||
var activeTimeoutIds = [];
|
||||
React.useEffect(function () {
|
||||
return function () {
|
||||
activeTimeoutIds.forEach(function (timeoutId) {
|
||||
return clearTimeout(timeoutId);
|
||||
});
|
||||
activeTimeoutIds.splice(0, activeTimeoutIds.length);
|
||||
};
|
||||
}, []);
|
||||
var onInternalMouseDown = function onInternalMouseDown(event) {
|
||||
var _triggerRef$current;
|
||||
var target = event.target;
|
||||
var popupElement = (_triggerRef$current = triggerRef.current) === null || _triggerRef$current === void 0 ? void 0 : _triggerRef$current.getPopupElement();
|
||||
|
||||
// We should give focus back to selector if clicked item is not focusable
|
||||
if (popupElement && popupElement.contains(target)) {
|
||||
var timeoutId = setTimeout(function () {
|
||||
var index = activeTimeoutIds.indexOf(timeoutId);
|
||||
if (index !== -1) {
|
||||
activeTimeoutIds.splice(index, 1);
|
||||
}
|
||||
cancelSetMockFocused();
|
||||
if (!mobile && !popupElement.contains(document.activeElement)) {
|
||||
var _selectorRef$current3;
|
||||
(_selectorRef$current3 = selectorRef.current) === null || _selectorRef$current3 === void 0 || _selectorRef$current3.focus();
|
||||
}
|
||||
});
|
||||
activeTimeoutIds.push(timeoutId);
|
||||
}
|
||||
for (var _len3 = arguments.length, restArgs = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
|
||||
restArgs[_key3 - 1] = arguments[_key3];
|
||||
}
|
||||
onMouseDown === null || onMouseDown === void 0 || onMouseDown.apply(void 0, [event].concat(restArgs));
|
||||
};
|
||||
|
||||
// ============================ Dropdown ============================
|
||||
var _React$useState5 = React.useState({}),
|
||||
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
||||
forceUpdate = _React$useState6[1];
|
||||
// We need force update here since popup dom is render async
|
||||
function onPopupMouseEnter() {
|
||||
forceUpdate({});
|
||||
}
|
||||
|
||||
// Used for raw custom input trigger
|
||||
var onTriggerVisibleChange;
|
||||
if (customizeRawInputElement) {
|
||||
onTriggerVisibleChange = function onTriggerVisibleChange(newOpen) {
|
||||
onToggleOpen(newOpen);
|
||||
};
|
||||
}
|
||||
|
||||
// Close when click on non-select element
|
||||
useSelectTriggerControl(function () {
|
||||
var _triggerRef$current2;
|
||||
return [containerRef.current, (_triggerRef$current2 = triggerRef.current) === null || _triggerRef$current2 === void 0 ? void 0 : _triggerRef$current2.getPopupElement()];
|
||||
}, triggerOpen, onToggleOpen, !!customizeRawInputElement);
|
||||
|
||||
// ============================ Context =============================
|
||||
var baseSelectContext = React.useMemo(function () {
|
||||
return _objectSpread(_objectSpread({}, props), {}, {
|
||||
notFoundContent: notFoundContent,
|
||||
open: mergedOpen,
|
||||
triggerOpen: triggerOpen,
|
||||
id: id,
|
||||
showSearch: mergedShowSearch,
|
||||
multiple: multiple,
|
||||
toggleOpen: onToggleOpen
|
||||
});
|
||||
}, [props, notFoundContent, triggerOpen, mergedOpen, id, mergedShowSearch, multiple, onToggleOpen]);
|
||||
|
||||
// ==================================================================
|
||||
// == Render ==
|
||||
// ==================================================================
|
||||
|
||||
// ============================= Arrow ==============================
|
||||
var showSuffixIcon = !!suffixIcon || loading;
|
||||
var arrowNode;
|
||||
if (showSuffixIcon) {
|
||||
arrowNode = /*#__PURE__*/React.createElement(TransBtn, {
|
||||
className: classNames("".concat(prefixCls, "-arrow"), _defineProperty({}, "".concat(prefixCls, "-arrow-loading"), loading)),
|
||||
customizeIcon: suffixIcon,
|
||||
customizeIconProps: {
|
||||
loading: loading,
|
||||
searchValue: mergedSearchValue,
|
||||
open: mergedOpen,
|
||||
focused: mockFocused,
|
||||
showSearch: mergedShowSearch
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// ============================= Clear ==============================
|
||||
var onClearMouseDown = function onClearMouseDown() {
|
||||
var _selectorRef$current4;
|
||||
onClear === null || onClear === void 0 || onClear();
|
||||
(_selectorRef$current4 = selectorRef.current) === null || _selectorRef$current4 === void 0 || _selectorRef$current4.focus();
|
||||
onDisplayValuesChange([], {
|
||||
type: 'clear',
|
||||
values: displayValues
|
||||
});
|
||||
onInternalSearch('', false, false);
|
||||
};
|
||||
var _useAllowClear = useAllowClear(prefixCls, onClearMouseDown, displayValues, allowClear, clearIcon, disabled, mergedSearchValue, mode),
|
||||
mergedAllowClear = _useAllowClear.allowClear,
|
||||
clearNode = _useAllowClear.clearIcon;
|
||||
|
||||
// =========================== OptionList ===========================
|
||||
var optionList = /*#__PURE__*/React.createElement(OptionList, {
|
||||
ref: listRef
|
||||
});
|
||||
|
||||
// ============================= Select =============================
|
||||
var mergedClassName = classNames(prefixCls, className, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(prefixCls, "-focused"), mockFocused), "".concat(prefixCls, "-multiple"), multiple), "".concat(prefixCls, "-single"), !multiple), "".concat(prefixCls, "-allow-clear"), allowClear), "".concat(prefixCls, "-show-arrow"), showSuffixIcon), "".concat(prefixCls, "-disabled"), disabled), "".concat(prefixCls, "-loading"), loading), "".concat(prefixCls, "-open"), mergedOpen), "".concat(prefixCls, "-customize-input"), customizeInputElement), "".concat(prefixCls, "-show-search"), mergedShowSearch));
|
||||
|
||||
// >>> Selector
|
||||
var selectorNode = /*#__PURE__*/React.createElement(SelectTrigger, {
|
||||
ref: triggerRef,
|
||||
disabled: disabled,
|
||||
prefixCls: prefixCls,
|
||||
visible: triggerOpen,
|
||||
popupElement: optionList,
|
||||
animation: animation,
|
||||
transitionName: transitionName,
|
||||
dropdownStyle: dropdownStyle,
|
||||
dropdownClassName: dropdownClassName,
|
||||
direction: direction,
|
||||
dropdownMatchSelectWidth: dropdownMatchSelectWidth,
|
||||
dropdownRender: dropdownRender,
|
||||
dropdownAlign: dropdownAlign,
|
||||
placement: placement,
|
||||
builtinPlacements: builtinPlacements,
|
||||
getPopupContainer: getPopupContainer,
|
||||
empty: emptyOptions,
|
||||
getTriggerDOMNode: function getTriggerDOMNode(node) {
|
||||
return (
|
||||
// TODO: This is workaround and should be removed in `rc-select`
|
||||
// And use new standard `nativeElement` for ref.
|
||||
// But we should update `rc-resize-observer` first.
|
||||
selectorDomRef.current || node
|
||||
);
|
||||
},
|
||||
onPopupVisibleChange: onTriggerVisibleChange,
|
||||
onPopupMouseEnter: onPopupMouseEnter
|
||||
}, customizeRawInputElement ? ( /*#__PURE__*/React.cloneElement(customizeRawInputElement, {
|
||||
ref: customizeRawInputRef
|
||||
})) : /*#__PURE__*/React.createElement(Selector, _extends({}, props, {
|
||||
domRef: selectorDomRef,
|
||||
prefixCls: prefixCls,
|
||||
inputElement: customizeInputElement,
|
||||
ref: selectorRef,
|
||||
id: id,
|
||||
prefix: prefix,
|
||||
showSearch: mergedShowSearch,
|
||||
autoClearSearchValue: autoClearSearchValue,
|
||||
mode: mode,
|
||||
activeDescendantId: activeDescendantId,
|
||||
tagRender: tagRender,
|
||||
values: displayValues,
|
||||
open: mergedOpen,
|
||||
onToggleOpen: onToggleOpen,
|
||||
activeValue: activeValue,
|
||||
searchValue: mergedSearchValue,
|
||||
onSearch: onInternalSearch,
|
||||
onSearchSubmit: onInternalSearchSubmit,
|
||||
onRemove: onSelectorRemove,
|
||||
tokenWithEnter: tokenWithEnter,
|
||||
onInputBlur: onInputBlur
|
||||
})));
|
||||
|
||||
// >>> Render
|
||||
var renderNode;
|
||||
|
||||
// Render raw
|
||||
if (customizeRawInputElement) {
|
||||
renderNode = selectorNode;
|
||||
} else {
|
||||
renderNode = /*#__PURE__*/React.createElement("div", _extends({
|
||||
className: mergedClassName
|
||||
}, domProps, {
|
||||
ref: containerRef,
|
||||
onMouseDown: onInternalMouseDown,
|
||||
onKeyDown: onInternalKeyDown,
|
||||
onKeyUp: onInternalKeyUp,
|
||||
onFocus: onContainerFocus,
|
||||
onBlur: onContainerBlur
|
||||
}), /*#__PURE__*/React.createElement(Polite, {
|
||||
visible: mockFocused && !mergedOpen,
|
||||
values: displayValues
|
||||
}), selectorNode, arrowNode, mergedAllowClear && clearNode);
|
||||
}
|
||||
return /*#__PURE__*/React.createElement(BaseSelectContext.Provider, {
|
||||
value: baseSelectContext
|
||||
}, renderNode);
|
||||
});
|
||||
|
||||
// Set display name for dev
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
BaseSelect.displayName = 'BaseSelect';
|
||||
}
|
||||
export default BaseSelect;
|
||||
12
frontend/node_modules/rc-select/es/OptGroup.d.ts
generated
vendored
Normal file
12
frontend/node_modules/rc-select/es/OptGroup.d.ts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import type * as React from 'react';
|
||||
import type { DefaultOptionType } from './Select';
|
||||
export interface OptGroupProps extends Omit<DefaultOptionType, 'options'> {
|
||||
children?: React.ReactNode;
|
||||
}
|
||||
export interface OptionGroupFC extends React.FC<OptGroupProps> {
|
||||
/** Legacy for check if is a Option Group */
|
||||
isSelectOptGroup: boolean;
|
||||
}
|
||||
/** This is a placeholder, not real render in dom */
|
||||
declare const OptGroup: OptionGroupFC;
|
||||
export default OptGroup;
|
||||
8
frontend/node_modules/rc-select/es/OptGroup.js
generated
vendored
Normal file
8
frontend/node_modules/rc-select/es/OptGroup.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/* istanbul ignore file */
|
||||
|
||||
/** This is a placeholder, not real render in dom */
|
||||
var OptGroup = function OptGroup() {
|
||||
return null;
|
||||
};
|
||||
OptGroup.isSelectOptGroup = true;
|
||||
export default OptGroup;
|
||||
14
frontend/node_modules/rc-select/es/Option.d.ts
generated
vendored
Normal file
14
frontend/node_modules/rc-select/es/Option.d.ts
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import type * as React from 'react';
|
||||
import type { DefaultOptionType } from './Select';
|
||||
export interface OptionProps extends Omit<DefaultOptionType, 'label'> {
|
||||
children: React.ReactNode;
|
||||
/** Save for customize data */
|
||||
[prop: string]: any;
|
||||
}
|
||||
export interface OptionFC extends React.FC<OptionProps> {
|
||||
/** Legacy for check if is a Option Group */
|
||||
isSelectOption: boolean;
|
||||
}
|
||||
/** This is a placeholder, not real render in dom */
|
||||
declare const Option: OptionFC;
|
||||
export default Option;
|
||||
8
frontend/node_modules/rc-select/es/Option.js
generated
vendored
Normal file
8
frontend/node_modules/rc-select/es/Option.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/* istanbul ignore file */
|
||||
|
||||
/** This is a placeholder, not real render in dom */
|
||||
var Option = function Option() {
|
||||
return null;
|
||||
};
|
||||
Option.isSelectOption = true;
|
||||
export default Option;
|
||||
10
frontend/node_modules/rc-select/es/OptionList.d.ts
generated
vendored
Normal file
10
frontend/node_modules/rc-select/es/OptionList.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import type { ScrollConfig } from 'rc-virtual-list/lib/List';
|
||||
import * as React from 'react';
|
||||
export type OptionListProps = Record<string, never>;
|
||||
export interface RefOptionListProps {
|
||||
onKeyDown: React.KeyboardEventHandler;
|
||||
onKeyUp: React.KeyboardEventHandler;
|
||||
scrollTo?: (args: number | ScrollConfig) => void;
|
||||
}
|
||||
declare const RefOptionList: React.ForwardRefExoticComponent<React.RefAttributes<RefOptionListProps>>;
|
||||
export default RefOptionList;
|
||||
387
frontend/node_modules/rc-select/es/OptionList.js
generated
vendored
Normal file
387
frontend/node_modules/rc-select/es/OptionList.js
generated
vendored
Normal file
@@ -0,0 +1,387 @@
|
||||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
||||
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
||||
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
||||
var _excluded = ["disabled", "title", "children", "style", "className"];
|
||||
import classNames from 'classnames';
|
||||
import KeyCode from "rc-util/es/KeyCode";
|
||||
import useMemo from "rc-util/es/hooks/useMemo";
|
||||
import omit from "rc-util/es/omit";
|
||||
import pickAttrs from "rc-util/es/pickAttrs";
|
||||
import List from 'rc-virtual-list';
|
||||
import * as React from 'react';
|
||||
import { useEffect } from 'react';
|
||||
import SelectContext from "./SelectContext";
|
||||
import TransBtn from "./TransBtn";
|
||||
import useBaseProps from "./hooks/useBaseProps";
|
||||
import { isPlatformMac } from "./utils/platformUtil";
|
||||
import { isValidCount } from "./utils/valueUtil";
|
||||
|
||||
// export interface OptionListProps<OptionsType extends object[]> {
|
||||
|
||||
function isTitleType(content) {
|
||||
return typeof content === 'string' || typeof content === 'number';
|
||||
}
|
||||
|
||||
/**
|
||||
* Using virtual list of option display.
|
||||
* Will fallback to dom if use customize render.
|
||||
*/
|
||||
var OptionList = function OptionList(_, ref) {
|
||||
var _useBaseProps = useBaseProps(),
|
||||
prefixCls = _useBaseProps.prefixCls,
|
||||
id = _useBaseProps.id,
|
||||
open = _useBaseProps.open,
|
||||
multiple = _useBaseProps.multiple,
|
||||
mode = _useBaseProps.mode,
|
||||
searchValue = _useBaseProps.searchValue,
|
||||
toggleOpen = _useBaseProps.toggleOpen,
|
||||
notFoundContent = _useBaseProps.notFoundContent,
|
||||
onPopupScroll = _useBaseProps.onPopupScroll;
|
||||
var _React$useContext = React.useContext(SelectContext),
|
||||
maxCount = _React$useContext.maxCount,
|
||||
flattenOptions = _React$useContext.flattenOptions,
|
||||
onActiveValue = _React$useContext.onActiveValue,
|
||||
defaultActiveFirstOption = _React$useContext.defaultActiveFirstOption,
|
||||
onSelect = _React$useContext.onSelect,
|
||||
menuItemSelectedIcon = _React$useContext.menuItemSelectedIcon,
|
||||
rawValues = _React$useContext.rawValues,
|
||||
fieldNames = _React$useContext.fieldNames,
|
||||
virtual = _React$useContext.virtual,
|
||||
direction = _React$useContext.direction,
|
||||
listHeight = _React$useContext.listHeight,
|
||||
listItemHeight = _React$useContext.listItemHeight,
|
||||
optionRender = _React$useContext.optionRender;
|
||||
var itemPrefixCls = "".concat(prefixCls, "-item");
|
||||
var memoFlattenOptions = useMemo(function () {
|
||||
return flattenOptions;
|
||||
}, [open, flattenOptions], function (prev, next) {
|
||||
return next[0] && prev[1] !== next[1];
|
||||
});
|
||||
|
||||
// =========================== List ===========================
|
||||
var listRef = React.useRef(null);
|
||||
var overMaxCount = React.useMemo(function () {
|
||||
return multiple && isValidCount(maxCount) && (rawValues === null || rawValues === void 0 ? void 0 : rawValues.size) >= maxCount;
|
||||
}, [multiple, maxCount, rawValues === null || rawValues === void 0 ? void 0 : rawValues.size]);
|
||||
var onListMouseDown = function onListMouseDown(event) {
|
||||
event.preventDefault();
|
||||
};
|
||||
var scrollIntoView = function scrollIntoView(args) {
|
||||
var _listRef$current;
|
||||
(_listRef$current = listRef.current) === null || _listRef$current === void 0 || _listRef$current.scrollTo(typeof args === 'number' ? {
|
||||
index: args
|
||||
} : args);
|
||||
};
|
||||
|
||||
// https://github.com/ant-design/ant-design/issues/34975
|
||||
var isSelected = React.useCallback(function (value) {
|
||||
if (mode === 'combobox') {
|
||||
return false;
|
||||
}
|
||||
return rawValues.has(value);
|
||||
}, [mode, _toConsumableArray(rawValues).toString(), rawValues.size]);
|
||||
|
||||
// ========================== Active ==========================
|
||||
var getEnabledActiveIndex = function getEnabledActiveIndex(index) {
|
||||
var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
||||
var len = memoFlattenOptions.length;
|
||||
for (var i = 0; i < len; i += 1) {
|
||||
var current = (index + i * offset + len) % len;
|
||||
var _ref = memoFlattenOptions[current] || {},
|
||||
group = _ref.group,
|
||||
data = _ref.data;
|
||||
if (!group && !(data !== null && data !== void 0 && data.disabled) && (isSelected(data.value) || !overMaxCount)) {
|
||||
return current;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
};
|
||||
var _React$useState = React.useState(function () {
|
||||
return getEnabledActiveIndex(0);
|
||||
}),
|
||||
_React$useState2 = _slicedToArray(_React$useState, 2),
|
||||
activeIndex = _React$useState2[0],
|
||||
setActiveIndex = _React$useState2[1];
|
||||
var setActive = function setActive(index) {
|
||||
var fromKeyboard = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
||||
setActiveIndex(index);
|
||||
var info = {
|
||||
source: fromKeyboard ? 'keyboard' : 'mouse'
|
||||
};
|
||||
|
||||
// Trigger active event
|
||||
var flattenItem = memoFlattenOptions[index];
|
||||
if (!flattenItem) {
|
||||
onActiveValue(null, -1, info);
|
||||
return;
|
||||
}
|
||||
onActiveValue(flattenItem.value, index, info);
|
||||
};
|
||||
|
||||
// Auto active first item when list length or searchValue changed
|
||||
useEffect(function () {
|
||||
setActive(defaultActiveFirstOption !== false ? getEnabledActiveIndex(0) : -1);
|
||||
}, [memoFlattenOptions.length, searchValue]);
|
||||
|
||||
// https://github.com/ant-design/ant-design/issues/48036
|
||||
var isAriaSelected = React.useCallback(function (value) {
|
||||
if (mode === 'combobox') {
|
||||
return String(value).toLowerCase() === searchValue.toLowerCase();
|
||||
}
|
||||
return rawValues.has(value);
|
||||
}, [mode, searchValue, _toConsumableArray(rawValues).toString(), rawValues.size]);
|
||||
|
||||
// Auto scroll to item position in single mode
|
||||
useEffect(function () {
|
||||
/**
|
||||
* React will skip `onChange` when component update.
|
||||
* `setActive` function will call root accessibility state update which makes re-render.
|
||||
* So we need to delay to let Input component trigger onChange first.
|
||||
*/
|
||||
var timeoutId = setTimeout(function () {
|
||||
if (!multiple && open && rawValues.size === 1) {
|
||||
var value = Array.from(rawValues)[0];
|
||||
// Scroll to the option closest to the searchValue if searching.
|
||||
var index = memoFlattenOptions.findIndex(function (_ref2) {
|
||||
var data = _ref2.data;
|
||||
return searchValue ? String(data.value).startsWith(searchValue) : data.value === value;
|
||||
});
|
||||
if (index !== -1) {
|
||||
setActive(index);
|
||||
scrollIntoView(index);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Force trigger scrollbar visible when open
|
||||
if (open) {
|
||||
var _listRef$current2;
|
||||
(_listRef$current2 = listRef.current) === null || _listRef$current2 === void 0 || _listRef$current2.scrollTo(undefined);
|
||||
}
|
||||
return function () {
|
||||
return clearTimeout(timeoutId);
|
||||
};
|
||||
}, [open, searchValue]);
|
||||
|
||||
// ========================== Values ==========================
|
||||
var onSelectValue = function onSelectValue(value) {
|
||||
if (value !== undefined) {
|
||||
onSelect(value, {
|
||||
selected: !rawValues.has(value)
|
||||
});
|
||||
}
|
||||
|
||||
// Single mode should always close by select
|
||||
if (!multiple) {
|
||||
toggleOpen(false);
|
||||
}
|
||||
};
|
||||
|
||||
// ========================= Keyboard =========================
|
||||
React.useImperativeHandle(ref, function () {
|
||||
return {
|
||||
onKeyDown: function onKeyDown(event) {
|
||||
var which = event.which,
|
||||
ctrlKey = event.ctrlKey;
|
||||
switch (which) {
|
||||
// >>> Arrow keys & ctrl + n/p on Mac
|
||||
case KeyCode.N:
|
||||
case KeyCode.P:
|
||||
case KeyCode.UP:
|
||||
case KeyCode.DOWN:
|
||||
{
|
||||
var offset = 0;
|
||||
if (which === KeyCode.UP) {
|
||||
offset = -1;
|
||||
} else if (which === KeyCode.DOWN) {
|
||||
offset = 1;
|
||||
} else if (isPlatformMac() && ctrlKey) {
|
||||
if (which === KeyCode.N) {
|
||||
offset = 1;
|
||||
} else if (which === KeyCode.P) {
|
||||
offset = -1;
|
||||
}
|
||||
}
|
||||
if (offset !== 0) {
|
||||
var nextActiveIndex = getEnabledActiveIndex(activeIndex + offset, offset);
|
||||
scrollIntoView(nextActiveIndex);
|
||||
setActive(nextActiveIndex, true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// >>> Select (Tab / Enter)
|
||||
case KeyCode.TAB:
|
||||
case KeyCode.ENTER:
|
||||
{
|
||||
var _item$data;
|
||||
// value
|
||||
var item = memoFlattenOptions[activeIndex];
|
||||
if (item && !(item !== null && item !== void 0 && (_item$data = item.data) !== null && _item$data !== void 0 && _item$data.disabled) && !overMaxCount) {
|
||||
onSelectValue(item.value);
|
||||
} else {
|
||||
onSelectValue(undefined);
|
||||
}
|
||||
if (open) {
|
||||
event.preventDefault();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// >>> Close
|
||||
case KeyCode.ESC:
|
||||
{
|
||||
toggleOpen(false);
|
||||
if (open) {
|
||||
event.stopPropagation();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
onKeyUp: function onKeyUp() {},
|
||||
scrollTo: function scrollTo(index) {
|
||||
scrollIntoView(index);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
// ========================== Render ==========================
|
||||
if (memoFlattenOptions.length === 0) {
|
||||
return /*#__PURE__*/React.createElement("div", {
|
||||
role: "listbox",
|
||||
id: "".concat(id, "_list"),
|
||||
className: "".concat(itemPrefixCls, "-empty"),
|
||||
onMouseDown: onListMouseDown
|
||||
}, notFoundContent);
|
||||
}
|
||||
var omitFieldNameList = Object.keys(fieldNames).map(function (key) {
|
||||
return fieldNames[key];
|
||||
});
|
||||
var getLabel = function getLabel(item) {
|
||||
return item.label;
|
||||
};
|
||||
function getItemAriaProps(item, index) {
|
||||
var group = item.group;
|
||||
return {
|
||||
role: group ? 'presentation' : 'option',
|
||||
id: "".concat(id, "_list_").concat(index)
|
||||
};
|
||||
}
|
||||
var renderItem = function renderItem(index) {
|
||||
var item = memoFlattenOptions[index];
|
||||
if (!item) {
|
||||
return null;
|
||||
}
|
||||
var itemData = item.data || {};
|
||||
var value = itemData.value;
|
||||
var group = item.group;
|
||||
var attrs = pickAttrs(itemData, true);
|
||||
var mergedLabel = getLabel(item);
|
||||
return item ? /*#__PURE__*/React.createElement("div", _extends({
|
||||
"aria-label": typeof mergedLabel === 'string' && !group ? mergedLabel : null
|
||||
}, attrs, {
|
||||
key: index
|
||||
}, getItemAriaProps(item, index), {
|
||||
"aria-selected": isAriaSelected(value)
|
||||
}), value) : null;
|
||||
};
|
||||
var a11yProps = {
|
||||
role: 'listbox',
|
||||
id: "".concat(id, "_list")
|
||||
};
|
||||
return /*#__PURE__*/React.createElement(React.Fragment, null, virtual && /*#__PURE__*/React.createElement("div", _extends({}, a11yProps, {
|
||||
style: {
|
||||
height: 0,
|
||||
width: 0,
|
||||
overflow: 'hidden'
|
||||
}
|
||||
}), renderItem(activeIndex - 1), renderItem(activeIndex), renderItem(activeIndex + 1)), /*#__PURE__*/React.createElement(List, {
|
||||
itemKey: "key",
|
||||
ref: listRef,
|
||||
data: memoFlattenOptions,
|
||||
height: listHeight,
|
||||
itemHeight: listItemHeight,
|
||||
fullHeight: false,
|
||||
onMouseDown: onListMouseDown,
|
||||
onScroll: onPopupScroll,
|
||||
virtual: virtual,
|
||||
direction: direction,
|
||||
innerProps: virtual ? null : a11yProps
|
||||
}, function (item, itemIndex) {
|
||||
var group = item.group,
|
||||
groupOption = item.groupOption,
|
||||
data = item.data,
|
||||
label = item.label,
|
||||
value = item.value;
|
||||
var key = data.key;
|
||||
|
||||
// Group
|
||||
if (group) {
|
||||
var _data$title;
|
||||
var groupTitle = (_data$title = data.title) !== null && _data$title !== void 0 ? _data$title : isTitleType(label) ? label.toString() : undefined;
|
||||
return /*#__PURE__*/React.createElement("div", {
|
||||
className: classNames(itemPrefixCls, "".concat(itemPrefixCls, "-group"), data.className),
|
||||
title: groupTitle
|
||||
}, label !== undefined ? label : key);
|
||||
}
|
||||
var disabled = data.disabled,
|
||||
title = data.title,
|
||||
children = data.children,
|
||||
style = data.style,
|
||||
className = data.className,
|
||||
otherProps = _objectWithoutProperties(data, _excluded);
|
||||
var passedProps = omit(otherProps, omitFieldNameList);
|
||||
|
||||
// Option
|
||||
var selected = isSelected(value);
|
||||
var mergedDisabled = disabled || !selected && overMaxCount;
|
||||
var optionPrefixCls = "".concat(itemPrefixCls, "-option");
|
||||
var optionClassName = classNames(itemPrefixCls, optionPrefixCls, className, _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(optionPrefixCls, "-grouped"), groupOption), "".concat(optionPrefixCls, "-active"), activeIndex === itemIndex && !mergedDisabled), "".concat(optionPrefixCls, "-disabled"), mergedDisabled), "".concat(optionPrefixCls, "-selected"), selected));
|
||||
var mergedLabel = getLabel(item);
|
||||
var iconVisible = !menuItemSelectedIcon || typeof menuItemSelectedIcon === 'function' || selected;
|
||||
|
||||
// https://github.com/ant-design/ant-design/issues/34145
|
||||
var content = typeof mergedLabel === 'number' ? mergedLabel : mergedLabel || value;
|
||||
// https://github.com/ant-design/ant-design/issues/26717
|
||||
var optionTitle = isTitleType(content) ? content.toString() : undefined;
|
||||
if (title !== undefined) {
|
||||
optionTitle = title;
|
||||
}
|
||||
return /*#__PURE__*/React.createElement("div", _extends({}, pickAttrs(passedProps), !virtual ? getItemAriaProps(item, itemIndex) : {}, {
|
||||
"aria-selected": isAriaSelected(value),
|
||||
className: optionClassName,
|
||||
title: optionTitle,
|
||||
onMouseMove: function onMouseMove() {
|
||||
if (activeIndex === itemIndex || mergedDisabled) {
|
||||
return;
|
||||
}
|
||||
setActive(itemIndex);
|
||||
},
|
||||
onClick: function onClick() {
|
||||
if (!mergedDisabled) {
|
||||
onSelectValue(value);
|
||||
}
|
||||
},
|
||||
style: style
|
||||
}), /*#__PURE__*/React.createElement("div", {
|
||||
className: "".concat(optionPrefixCls, "-content")
|
||||
}, typeof optionRender === 'function' ? optionRender(item, {
|
||||
index: itemIndex
|
||||
}) : content), /*#__PURE__*/React.isValidElement(menuItemSelectedIcon) || selected, iconVisible && /*#__PURE__*/React.createElement(TransBtn, {
|
||||
className: "".concat(itemPrefixCls, "-option-state"),
|
||||
customizeIcon: menuItemSelectedIcon,
|
||||
customizeIconProps: {
|
||||
value: value,
|
||||
disabled: mergedDisabled,
|
||||
isSelected: selected
|
||||
}
|
||||
}, selected ? '✓' : null));
|
||||
}));
|
||||
};
|
||||
var RefOptionList = /*#__PURE__*/React.forwardRef(OptionList);
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
RefOptionList.displayName = 'OptionList';
|
||||
}
|
||||
export default RefOptionList;
|
||||
118
frontend/node_modules/rc-select/es/Select.d.ts
generated
vendored
Normal file
118
frontend/node_modules/rc-select/es/Select.d.ts
generated
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
/**
|
||||
* To match accessibility requirement, we always provide an input in the component.
|
||||
* Other element will not set `tabIndex` to avoid `onBlur` sequence problem.
|
||||
* For focused select, we set `aria-live="polite"` to update the accessibility content.
|
||||
*
|
||||
* ref:
|
||||
* - keyboard: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/listbox_role#Keyboard_interactions
|
||||
*
|
||||
* New api:
|
||||
* - listHeight
|
||||
* - listItemHeight
|
||||
* - component
|
||||
*
|
||||
* Remove deprecated api:
|
||||
* - multiple
|
||||
* - tags
|
||||
* - combobox
|
||||
* - firstActiveValue
|
||||
* - dropdownMenuStyle
|
||||
* - openClassName (Not list in api)
|
||||
*
|
||||
* Update:
|
||||
* - `backfill` only support `combobox` mode
|
||||
* - `combobox` mode not support `labelInValue` since it's meaningless
|
||||
* - `getInputElement` only support `combobox` mode
|
||||
* - `onChange` return OptionData instead of ReactNode
|
||||
* - `filterOption` `onChange` `onSelect` accept OptionData instead of ReactNode
|
||||
* - `combobox` mode trigger `onChange` will get `undefined` if no `value` match in Option
|
||||
* - `combobox` mode not support `optionLabelProp`
|
||||
*/
|
||||
import * as React from 'react';
|
||||
import type { BaseSelectPropsWithoutPrivate, BaseSelectRef, DisplayValueType, RenderNode } from './BaseSelect';
|
||||
import OptGroup from './OptGroup';
|
||||
import Option from './Option';
|
||||
import type { FlattenOptionData } from './interface';
|
||||
export type OnActiveValue = (active: RawValueType, index: number, info?: {
|
||||
source?: 'keyboard' | 'mouse';
|
||||
}) => void;
|
||||
export type OnInternalSelect = (value: RawValueType, info: {
|
||||
selected: boolean;
|
||||
}) => void;
|
||||
export type RawValueType = string | number;
|
||||
export interface LabelInValueType {
|
||||
label: React.ReactNode;
|
||||
value: RawValueType;
|
||||
/** @deprecated `key` is useless since it should always same as `value` */
|
||||
key?: React.Key;
|
||||
}
|
||||
export type DraftValueType = RawValueType | LabelInValueType | DisplayValueType | (RawValueType | LabelInValueType | DisplayValueType)[];
|
||||
export type FilterFunc<OptionType> = (inputValue: string, option?: OptionType) => boolean;
|
||||
export interface FieldNames {
|
||||
value?: string;
|
||||
label?: string;
|
||||
groupLabel?: string;
|
||||
options?: string;
|
||||
}
|
||||
export interface BaseOptionType {
|
||||
disabled?: boolean;
|
||||
className?: string;
|
||||
title?: string;
|
||||
[name: string]: any;
|
||||
}
|
||||
export interface DefaultOptionType extends BaseOptionType {
|
||||
label?: React.ReactNode;
|
||||
value?: string | number | null;
|
||||
children?: Omit<DefaultOptionType, 'children'>[];
|
||||
}
|
||||
export type SelectHandler<ValueType, OptionType extends BaseOptionType = DefaultOptionType> = (value: ValueType, option: OptionType) => void;
|
||||
type ArrayElementType<T> = T extends (infer E)[] ? E : T;
|
||||
export interface SelectProps<ValueType = any, OptionType extends BaseOptionType = DefaultOptionType> extends BaseSelectPropsWithoutPrivate {
|
||||
prefixCls?: string;
|
||||
id?: string;
|
||||
backfill?: boolean;
|
||||
fieldNames?: FieldNames;
|
||||
/** @deprecated Use `searchValue` instead */
|
||||
inputValue?: string;
|
||||
searchValue?: string;
|
||||
onSearch?: (value: string) => void;
|
||||
autoClearSearchValue?: boolean;
|
||||
onSelect?: SelectHandler<ArrayElementType<ValueType>, OptionType>;
|
||||
onDeselect?: SelectHandler<ArrayElementType<ValueType>, OptionType>;
|
||||
/**
|
||||
* In Select, `false` means do nothing.
|
||||
* In TreeSelect, `false` will highlight match item.
|
||||
* It's by design.
|
||||
*/
|
||||
filterOption?: boolean | FilterFunc<OptionType>;
|
||||
filterSort?: (optionA: OptionType, optionB: OptionType, info: {
|
||||
searchValue: string;
|
||||
}) => number;
|
||||
optionFilterProp?: string;
|
||||
optionLabelProp?: string;
|
||||
children?: React.ReactNode;
|
||||
options?: OptionType[];
|
||||
optionRender?: (oriOption: FlattenOptionData<OptionType>, info: {
|
||||
index: number;
|
||||
}) => React.ReactNode;
|
||||
defaultActiveFirstOption?: boolean;
|
||||
virtual?: boolean;
|
||||
direction?: 'ltr' | 'rtl';
|
||||
listHeight?: number;
|
||||
listItemHeight?: number;
|
||||
labelRender?: (props: LabelInValueType) => React.ReactNode;
|
||||
menuItemSelectedIcon?: RenderNode;
|
||||
mode?: 'combobox' | 'multiple' | 'tags';
|
||||
labelInValue?: boolean;
|
||||
value?: ValueType | null;
|
||||
defaultValue?: ValueType | null;
|
||||
maxCount?: number;
|
||||
onChange?: (value: ValueType, option?: OptionType | OptionType[]) => void;
|
||||
}
|
||||
declare const TypedSelect: (<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType>(props: SelectProps<ValueType, OptionType> & {
|
||||
children?: React.ReactNode;
|
||||
} & React.RefAttributes<BaseSelectRef>) => React.ReactElement) & {
|
||||
Option: typeof Option;
|
||||
OptGroup: typeof OptGroup;
|
||||
};
|
||||
export default TypedSelect;
|
||||
537
frontend/node_modules/rc-select/es/Select.js
generated
vendored
Normal file
537
frontend/node_modules/rc-select/es/Select.js
generated
vendored
Normal file
@@ -0,0 +1,537 @@
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
||||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
||||
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
||||
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
||||
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
||||
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
||||
var _excluded = ["id", "mode", "prefixCls", "backfill", "fieldNames", "inputValue", "searchValue", "onSearch", "autoClearSearchValue", "onSelect", "onDeselect", "dropdownMatchSelectWidth", "filterOption", "filterSort", "optionFilterProp", "optionLabelProp", "options", "optionRender", "children", "defaultActiveFirstOption", "menuItemSelectedIcon", "virtual", "direction", "listHeight", "listItemHeight", "labelRender", "value", "defaultValue", "labelInValue", "onChange", "maxCount"];
|
||||
/**
|
||||
* To match accessibility requirement, we always provide an input in the component.
|
||||
* Other element will not set `tabIndex` to avoid `onBlur` sequence problem.
|
||||
* For focused select, we set `aria-live="polite"` to update the accessibility content.
|
||||
*
|
||||
* ref:
|
||||
* - keyboard: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/listbox_role#Keyboard_interactions
|
||||
*
|
||||
* New api:
|
||||
* - listHeight
|
||||
* - listItemHeight
|
||||
* - component
|
||||
*
|
||||
* Remove deprecated api:
|
||||
* - multiple
|
||||
* - tags
|
||||
* - combobox
|
||||
* - firstActiveValue
|
||||
* - dropdownMenuStyle
|
||||
* - openClassName (Not list in api)
|
||||
*
|
||||
* Update:
|
||||
* - `backfill` only support `combobox` mode
|
||||
* - `combobox` mode not support `labelInValue` since it's meaningless
|
||||
* - `getInputElement` only support `combobox` mode
|
||||
* - `onChange` return OptionData instead of ReactNode
|
||||
* - `filterOption` `onChange` `onSelect` accept OptionData instead of ReactNode
|
||||
* - `combobox` mode trigger `onChange` will get `undefined` if no `value` match in Option
|
||||
* - `combobox` mode not support `optionLabelProp`
|
||||
*/
|
||||
|
||||
import useMergedState from "rc-util/es/hooks/useMergedState";
|
||||
import warning from "rc-util/es/warning";
|
||||
import * as React from 'react';
|
||||
import BaseSelect, { isMultiple } from "./BaseSelect";
|
||||
import OptGroup from "./OptGroup";
|
||||
import Option from "./Option";
|
||||
import OptionList from "./OptionList";
|
||||
import SelectContext from "./SelectContext";
|
||||
import useCache from "./hooks/useCache";
|
||||
import useFilterOptions from "./hooks/useFilterOptions";
|
||||
import useId from "./hooks/useId";
|
||||
import useOptions from "./hooks/useOptions";
|
||||
import useRefFunc from "./hooks/useRefFunc";
|
||||
import { hasValue, isComboNoValue, toArray } from "./utils/commonUtil";
|
||||
import { fillFieldNames, flattenOptions, injectPropsWithOption } from "./utils/valueUtil";
|
||||
import warningProps, { warningNullOptions } from "./utils/warningPropsUtil";
|
||||
var OMIT_DOM_PROPS = ['inputValue'];
|
||||
function isRawValue(value) {
|
||||
return !value || _typeof(value) !== 'object';
|
||||
}
|
||||
var Select = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
||||
var id = props.id,
|
||||
mode = props.mode,
|
||||
_props$prefixCls = props.prefixCls,
|
||||
prefixCls = _props$prefixCls === void 0 ? 'rc-select' : _props$prefixCls,
|
||||
backfill = props.backfill,
|
||||
fieldNames = props.fieldNames,
|
||||
inputValue = props.inputValue,
|
||||
searchValue = props.searchValue,
|
||||
onSearch = props.onSearch,
|
||||
_props$autoClearSearc = props.autoClearSearchValue,
|
||||
autoClearSearchValue = _props$autoClearSearc === void 0 ? true : _props$autoClearSearc,
|
||||
onSelect = props.onSelect,
|
||||
onDeselect = props.onDeselect,
|
||||
_props$dropdownMatchS = props.dropdownMatchSelectWidth,
|
||||
dropdownMatchSelectWidth = _props$dropdownMatchS === void 0 ? true : _props$dropdownMatchS,
|
||||
filterOption = props.filterOption,
|
||||
filterSort = props.filterSort,
|
||||
optionFilterProp = props.optionFilterProp,
|
||||
optionLabelProp = props.optionLabelProp,
|
||||
options = props.options,
|
||||
optionRender = props.optionRender,
|
||||
children = props.children,
|
||||
defaultActiveFirstOption = props.defaultActiveFirstOption,
|
||||
menuItemSelectedIcon = props.menuItemSelectedIcon,
|
||||
virtual = props.virtual,
|
||||
direction = props.direction,
|
||||
_props$listHeight = props.listHeight,
|
||||
listHeight = _props$listHeight === void 0 ? 200 : _props$listHeight,
|
||||
_props$listItemHeight = props.listItemHeight,
|
||||
listItemHeight = _props$listItemHeight === void 0 ? 20 : _props$listItemHeight,
|
||||
labelRender = props.labelRender,
|
||||
value = props.value,
|
||||
defaultValue = props.defaultValue,
|
||||
labelInValue = props.labelInValue,
|
||||
onChange = props.onChange,
|
||||
maxCount = props.maxCount,
|
||||
restProps = _objectWithoutProperties(props, _excluded);
|
||||
var mergedId = useId(id);
|
||||
var multiple = isMultiple(mode);
|
||||
var childrenAsData = !!(!options && children);
|
||||
var mergedFilterOption = React.useMemo(function () {
|
||||
if (filterOption === undefined && mode === 'combobox') {
|
||||
return false;
|
||||
}
|
||||
return filterOption;
|
||||
}, [filterOption, mode]);
|
||||
|
||||
// ========================= FieldNames =========================
|
||||
var mergedFieldNames = React.useMemo(function () {
|
||||
return fillFieldNames(fieldNames, childrenAsData);
|
||||
}, /* eslint-disable react-hooks/exhaustive-deps */
|
||||
[
|
||||
// We stringify fieldNames to avoid unnecessary re-renders.
|
||||
JSON.stringify(fieldNames), childrenAsData]
|
||||
/* eslint-enable react-hooks/exhaustive-deps */);
|
||||
|
||||
// =========================== Search ===========================
|
||||
var _useMergedState = useMergedState('', {
|
||||
value: searchValue !== undefined ? searchValue : inputValue,
|
||||
postState: function postState(search) {
|
||||
return search || '';
|
||||
}
|
||||
}),
|
||||
_useMergedState2 = _slicedToArray(_useMergedState, 2),
|
||||
mergedSearchValue = _useMergedState2[0],
|
||||
setSearchValue = _useMergedState2[1];
|
||||
|
||||
// =========================== Option ===========================
|
||||
var parsedOptions = useOptions(options, children, mergedFieldNames, optionFilterProp, optionLabelProp);
|
||||
var valueOptions = parsedOptions.valueOptions,
|
||||
labelOptions = parsedOptions.labelOptions,
|
||||
mergedOptions = parsedOptions.options;
|
||||
|
||||
// ========================= Wrap Value =========================
|
||||
var convert2LabelValues = React.useCallback(function (draftValues) {
|
||||
// Convert to array
|
||||
var valueList = toArray(draftValues);
|
||||
|
||||
// Convert to labelInValue type
|
||||
return valueList.map(function (val) {
|
||||
var rawValue;
|
||||
var rawLabel;
|
||||
var rawKey;
|
||||
var rawDisabled;
|
||||
var rawTitle;
|
||||
|
||||
// Fill label & value
|
||||
if (isRawValue(val)) {
|
||||
rawValue = val;
|
||||
} else {
|
||||
var _val$value;
|
||||
rawKey = val.key;
|
||||
rawLabel = val.label;
|
||||
rawValue = (_val$value = val.value) !== null && _val$value !== void 0 ? _val$value : rawKey;
|
||||
}
|
||||
var option = valueOptions.get(rawValue);
|
||||
if (option) {
|
||||
var _option$key;
|
||||
// Fill missing props
|
||||
if (rawLabel === undefined) rawLabel = option === null || option === void 0 ? void 0 : option[optionLabelProp || mergedFieldNames.label];
|
||||
if (rawKey === undefined) rawKey = (_option$key = option === null || option === void 0 ? void 0 : option.key) !== null && _option$key !== void 0 ? _option$key : rawValue;
|
||||
rawDisabled = option === null || option === void 0 ? void 0 : option.disabled;
|
||||
rawTitle = option === null || option === void 0 ? void 0 : option.title;
|
||||
|
||||
// Warning if label not same as provided
|
||||
if (process.env.NODE_ENV !== 'production' && !optionLabelProp) {
|
||||
var optionLabel = option === null || option === void 0 ? void 0 : option[mergedFieldNames.label];
|
||||
if (optionLabel !== undefined && ! /*#__PURE__*/React.isValidElement(optionLabel) && ! /*#__PURE__*/React.isValidElement(rawLabel) && optionLabel !== rawLabel) {
|
||||
warning(false, '`label` of `value` is not same as `label` in Select options.');
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
label: rawLabel,
|
||||
value: rawValue,
|
||||
key: rawKey,
|
||||
disabled: rawDisabled,
|
||||
title: rawTitle
|
||||
};
|
||||
});
|
||||
}, [mergedFieldNames, optionLabelProp, valueOptions]);
|
||||
|
||||
// =========================== Values ===========================
|
||||
var _useMergedState3 = useMergedState(defaultValue, {
|
||||
value: value
|
||||
}),
|
||||
_useMergedState4 = _slicedToArray(_useMergedState3, 2),
|
||||
internalValue = _useMergedState4[0],
|
||||
setInternalValue = _useMergedState4[1];
|
||||
|
||||
// Merged value with LabelValueType
|
||||
var rawLabeledValues = React.useMemo(function () {
|
||||
var _values$;
|
||||
var newInternalValue = multiple && internalValue === null ? [] : internalValue;
|
||||
var values = convert2LabelValues(newInternalValue);
|
||||
|
||||
// combobox no need save value when it's no value (exclude value equal 0)
|
||||
if (mode === 'combobox' && isComboNoValue((_values$ = values[0]) === null || _values$ === void 0 ? void 0 : _values$.value)) {
|
||||
return [];
|
||||
}
|
||||
return values;
|
||||
}, [internalValue, convert2LabelValues, mode, multiple]);
|
||||
|
||||
// Fill label with cache to avoid option remove
|
||||
var _useCache = useCache(rawLabeledValues, valueOptions),
|
||||
_useCache2 = _slicedToArray(_useCache, 2),
|
||||
mergedValues = _useCache2[0],
|
||||
getMixedOption = _useCache2[1];
|
||||
var displayValues = React.useMemo(function () {
|
||||
// `null` need show as placeholder instead
|
||||
// https://github.com/ant-design/ant-design/issues/25057
|
||||
if (!mode && mergedValues.length === 1) {
|
||||
var firstValue = mergedValues[0];
|
||||
if (firstValue.value === null && (firstValue.label === null || firstValue.label === undefined)) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
return mergedValues.map(function (item) {
|
||||
var _ref;
|
||||
return _objectSpread(_objectSpread({}, item), {}, {
|
||||
label: (_ref = typeof labelRender === 'function' ? labelRender(item) : item.label) !== null && _ref !== void 0 ? _ref : item.value
|
||||
});
|
||||
});
|
||||
}, [mode, mergedValues, labelRender]);
|
||||
|
||||
/** Convert `displayValues` to raw value type set */
|
||||
var rawValues = React.useMemo(function () {
|
||||
return new Set(mergedValues.map(function (val) {
|
||||
return val.value;
|
||||
}));
|
||||
}, [mergedValues]);
|
||||
React.useEffect(function () {
|
||||
if (mode === 'combobox') {
|
||||
var _mergedValues$;
|
||||
var strValue = (_mergedValues$ = mergedValues[0]) === null || _mergedValues$ === void 0 ? void 0 : _mergedValues$.value;
|
||||
setSearchValue(hasValue(strValue) ? String(strValue) : '');
|
||||
}
|
||||
}, [mergedValues]);
|
||||
|
||||
// ======================= Display Option =======================
|
||||
// Create a placeholder item if not exist in `options`
|
||||
var createTagOption = useRefFunc(function (val, label) {
|
||||
var mergedLabel = label !== null && label !== void 0 ? label : val;
|
||||
return _defineProperty(_defineProperty({}, mergedFieldNames.value, val), mergedFieldNames.label, mergedLabel);
|
||||
});
|
||||
|
||||
// Fill tag as option if mode is `tags`
|
||||
var filledTagOptions = React.useMemo(function () {
|
||||
if (mode !== 'tags') {
|
||||
return mergedOptions;
|
||||
}
|
||||
|
||||
// >>> Tag mode
|
||||
var cloneOptions = _toConsumableArray(mergedOptions);
|
||||
|
||||
// Check if value exist in options (include new patch item)
|
||||
var existOptions = function existOptions(val) {
|
||||
return valueOptions.has(val);
|
||||
};
|
||||
|
||||
// Fill current value as option
|
||||
_toConsumableArray(mergedValues).sort(function (a, b) {
|
||||
return a.value < b.value ? -1 : 1;
|
||||
}).forEach(function (item) {
|
||||
var val = item.value;
|
||||
if (!existOptions(val)) {
|
||||
cloneOptions.push(createTagOption(val, item.label));
|
||||
}
|
||||
});
|
||||
return cloneOptions;
|
||||
}, [createTagOption, mergedOptions, valueOptions, mergedValues, mode]);
|
||||
var filteredOptions = useFilterOptions(filledTagOptions, mergedFieldNames, mergedSearchValue, mergedFilterOption, optionFilterProp);
|
||||
|
||||
// Fill options with search value if needed
|
||||
var filledSearchOptions = React.useMemo(function () {
|
||||
if (mode !== 'tags' || !mergedSearchValue || filteredOptions.some(function (item) {
|
||||
return item[optionFilterProp || 'value'] === mergedSearchValue;
|
||||
})) {
|
||||
return filteredOptions;
|
||||
}
|
||||
// ignore when search value equal select input value
|
||||
if (filteredOptions.some(function (item) {
|
||||
return item[mergedFieldNames.value] === mergedSearchValue;
|
||||
})) {
|
||||
return filteredOptions;
|
||||
}
|
||||
// Fill search value as option
|
||||
return [createTagOption(mergedSearchValue)].concat(_toConsumableArray(filteredOptions));
|
||||
}, [createTagOption, optionFilterProp, mode, filteredOptions, mergedSearchValue, mergedFieldNames]);
|
||||
var sorter = function sorter(inputOptions) {
|
||||
var sortedOptions = _toConsumableArray(inputOptions).sort(function (a, b) {
|
||||
return filterSort(a, b, {
|
||||
searchValue: mergedSearchValue
|
||||
});
|
||||
});
|
||||
return sortedOptions.map(function (item) {
|
||||
if (Array.isArray(item.options)) {
|
||||
return _objectSpread(_objectSpread({}, item), {}, {
|
||||
options: item.options.length > 0 ? sorter(item.options) : item.options
|
||||
});
|
||||
}
|
||||
return item;
|
||||
});
|
||||
};
|
||||
var orderedFilteredOptions = React.useMemo(function () {
|
||||
if (!filterSort) {
|
||||
return filledSearchOptions;
|
||||
}
|
||||
return sorter(filledSearchOptions);
|
||||
}, [filledSearchOptions, filterSort, mergedSearchValue]);
|
||||
var displayOptions = React.useMemo(function () {
|
||||
return flattenOptions(orderedFilteredOptions, {
|
||||
fieldNames: mergedFieldNames,
|
||||
childrenAsData: childrenAsData
|
||||
});
|
||||
}, [orderedFilteredOptions, mergedFieldNames, childrenAsData]);
|
||||
|
||||
// =========================== Change ===========================
|
||||
var triggerChange = function triggerChange(values) {
|
||||
var labeledValues = convert2LabelValues(values);
|
||||
setInternalValue(labeledValues);
|
||||
if (onChange && (
|
||||
// Trigger event only when value changed
|
||||
labeledValues.length !== mergedValues.length || labeledValues.some(function (newVal, index) {
|
||||
var _mergedValues$index;
|
||||
return ((_mergedValues$index = mergedValues[index]) === null || _mergedValues$index === void 0 ? void 0 : _mergedValues$index.value) !== (newVal === null || newVal === void 0 ? void 0 : newVal.value);
|
||||
}))) {
|
||||
var returnValues = labelInValue ? labeledValues : labeledValues.map(function (v) {
|
||||
return v.value;
|
||||
});
|
||||
var returnOptions = labeledValues.map(function (v) {
|
||||
return injectPropsWithOption(getMixedOption(v.value));
|
||||
});
|
||||
onChange(
|
||||
// Value
|
||||
multiple ? returnValues : returnValues[0],
|
||||
// Option
|
||||
multiple ? returnOptions : returnOptions[0]);
|
||||
}
|
||||
};
|
||||
|
||||
// ======================= Accessibility ========================
|
||||
var _React$useState = React.useState(null),
|
||||
_React$useState2 = _slicedToArray(_React$useState, 2),
|
||||
activeValue = _React$useState2[0],
|
||||
setActiveValue = _React$useState2[1];
|
||||
var _React$useState3 = React.useState(0),
|
||||
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
||||
accessibilityIndex = _React$useState4[0],
|
||||
setAccessibilityIndex = _React$useState4[1];
|
||||
var mergedDefaultActiveFirstOption = defaultActiveFirstOption !== undefined ? defaultActiveFirstOption : mode !== 'combobox';
|
||||
var onActiveValue = React.useCallback(function (active, index) {
|
||||
var _ref3 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
||||
_ref3$source = _ref3.source,
|
||||
source = _ref3$source === void 0 ? 'keyboard' : _ref3$source;
|
||||
setAccessibilityIndex(index);
|
||||
if (backfill && mode === 'combobox' && active !== null && source === 'keyboard') {
|
||||
setActiveValue(String(active));
|
||||
}
|
||||
}, [backfill, mode]);
|
||||
|
||||
// ========================= OptionList =========================
|
||||
var triggerSelect = function triggerSelect(val, selected, type) {
|
||||
var getSelectEnt = function getSelectEnt() {
|
||||
var _option$key2;
|
||||
var option = getMixedOption(val);
|
||||
return [labelInValue ? {
|
||||
label: option === null || option === void 0 ? void 0 : option[mergedFieldNames.label],
|
||||
value: val,
|
||||
key: (_option$key2 = option === null || option === void 0 ? void 0 : option.key) !== null && _option$key2 !== void 0 ? _option$key2 : val
|
||||
} : val, injectPropsWithOption(option)];
|
||||
};
|
||||
if (selected && onSelect) {
|
||||
var _getSelectEnt = getSelectEnt(),
|
||||
_getSelectEnt2 = _slicedToArray(_getSelectEnt, 2),
|
||||
wrappedValue = _getSelectEnt2[0],
|
||||
_option = _getSelectEnt2[1];
|
||||
onSelect(wrappedValue, _option);
|
||||
} else if (!selected && onDeselect && type !== 'clear') {
|
||||
var _getSelectEnt3 = getSelectEnt(),
|
||||
_getSelectEnt4 = _slicedToArray(_getSelectEnt3, 2),
|
||||
_wrappedValue = _getSelectEnt4[0],
|
||||
_option2 = _getSelectEnt4[1];
|
||||
onDeselect(_wrappedValue, _option2);
|
||||
}
|
||||
};
|
||||
|
||||
// Used for OptionList selection
|
||||
var onInternalSelect = useRefFunc(function (val, info) {
|
||||
var cloneValues;
|
||||
|
||||
// Single mode always trigger select only with option list
|
||||
var mergedSelect = multiple ? info.selected : true;
|
||||
if (mergedSelect) {
|
||||
cloneValues = multiple ? [].concat(_toConsumableArray(mergedValues), [val]) : [val];
|
||||
} else {
|
||||
cloneValues = mergedValues.filter(function (v) {
|
||||
return v.value !== val;
|
||||
});
|
||||
}
|
||||
triggerChange(cloneValues);
|
||||
triggerSelect(val, mergedSelect);
|
||||
|
||||
// Clean search value if single or configured
|
||||
if (mode === 'combobox') {
|
||||
// setSearchValue(String(val));
|
||||
setActiveValue('');
|
||||
} else if (!isMultiple || autoClearSearchValue) {
|
||||
setSearchValue('');
|
||||
setActiveValue('');
|
||||
}
|
||||
});
|
||||
|
||||
// ======================= Display Change =======================
|
||||
// BaseSelect display values change
|
||||
var onDisplayValuesChange = function onDisplayValuesChange(nextValues, info) {
|
||||
triggerChange(nextValues);
|
||||
var type = info.type,
|
||||
values = info.values;
|
||||
if (type === 'remove' || type === 'clear') {
|
||||
values.forEach(function (item) {
|
||||
triggerSelect(item.value, false, type);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// =========================== Search ===========================
|
||||
var onInternalSearch = function onInternalSearch(searchText, info) {
|
||||
setSearchValue(searchText);
|
||||
setActiveValue(null);
|
||||
|
||||
// [Submit] Tag mode should flush input
|
||||
if (info.source === 'submit') {
|
||||
var formatted = (searchText || '').trim();
|
||||
// prevent empty tags from appearing when you click the Enter button
|
||||
if (formatted) {
|
||||
var newRawValues = Array.from(new Set([].concat(_toConsumableArray(rawValues), [formatted])));
|
||||
triggerChange(newRawValues);
|
||||
triggerSelect(formatted, true);
|
||||
setSearchValue('');
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (info.source !== 'blur') {
|
||||
if (mode === 'combobox') {
|
||||
triggerChange(searchText);
|
||||
}
|
||||
onSearch === null || onSearch === void 0 || onSearch(searchText);
|
||||
}
|
||||
};
|
||||
var onInternalSearchSplit = function onInternalSearchSplit(words) {
|
||||
var patchValues = words;
|
||||
if (mode !== 'tags') {
|
||||
patchValues = words.map(function (word) {
|
||||
var opt = labelOptions.get(word);
|
||||
return opt === null || opt === void 0 ? void 0 : opt.value;
|
||||
}).filter(function (val) {
|
||||
return val !== undefined;
|
||||
});
|
||||
}
|
||||
var newRawValues = Array.from(new Set([].concat(_toConsumableArray(rawValues), _toConsumableArray(patchValues))));
|
||||
triggerChange(newRawValues);
|
||||
newRawValues.forEach(function (newRawValue) {
|
||||
triggerSelect(newRawValue, true);
|
||||
});
|
||||
};
|
||||
|
||||
// ========================== Context ===========================
|
||||
var selectContext = React.useMemo(function () {
|
||||
var realVirtual = virtual !== false && dropdownMatchSelectWidth !== false;
|
||||
return _objectSpread(_objectSpread({}, parsedOptions), {}, {
|
||||
flattenOptions: displayOptions,
|
||||
onActiveValue: onActiveValue,
|
||||
defaultActiveFirstOption: mergedDefaultActiveFirstOption,
|
||||
onSelect: onInternalSelect,
|
||||
menuItemSelectedIcon: menuItemSelectedIcon,
|
||||
rawValues: rawValues,
|
||||
fieldNames: mergedFieldNames,
|
||||
virtual: realVirtual,
|
||||
direction: direction,
|
||||
listHeight: listHeight,
|
||||
listItemHeight: listItemHeight,
|
||||
childrenAsData: childrenAsData,
|
||||
maxCount: maxCount,
|
||||
optionRender: optionRender
|
||||
});
|
||||
}, [maxCount, parsedOptions, displayOptions, onActiveValue, mergedDefaultActiveFirstOption, onInternalSelect, menuItemSelectedIcon, rawValues, mergedFieldNames, virtual, dropdownMatchSelectWidth, direction, listHeight, listItemHeight, childrenAsData, optionRender]);
|
||||
|
||||
// ========================== Warning ===========================
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
warningProps(props);
|
||||
warningNullOptions(mergedOptions, mergedFieldNames);
|
||||
}
|
||||
|
||||
// ==============================================================
|
||||
// == Render ==
|
||||
// ==============================================================
|
||||
return /*#__PURE__*/React.createElement(SelectContext.Provider, {
|
||||
value: selectContext
|
||||
}, /*#__PURE__*/React.createElement(BaseSelect, _extends({}, restProps, {
|
||||
// >>> MISC
|
||||
id: mergedId,
|
||||
prefixCls: prefixCls,
|
||||
ref: ref,
|
||||
omitDomProps: OMIT_DOM_PROPS,
|
||||
mode: mode
|
||||
// >>> Values
|
||||
,
|
||||
displayValues: displayValues,
|
||||
onDisplayValuesChange: onDisplayValuesChange
|
||||
// >>> Trigger
|
||||
,
|
||||
direction: direction
|
||||
// >>> Search
|
||||
,
|
||||
searchValue: mergedSearchValue,
|
||||
onSearch: onInternalSearch,
|
||||
autoClearSearchValue: autoClearSearchValue,
|
||||
onSearchSplit: onInternalSearchSplit,
|
||||
dropdownMatchSelectWidth: dropdownMatchSelectWidth
|
||||
// >>> OptionList
|
||||
,
|
||||
OptionList: OptionList,
|
||||
emptyOptions: !displayOptions.length
|
||||
// >>> Accessibility
|
||||
,
|
||||
activeValue: activeValue,
|
||||
activeDescendantId: "".concat(mergedId, "_list_").concat(accessibilityIndex)
|
||||
})));
|
||||
});
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
Select.displayName = 'Select';
|
||||
}
|
||||
var TypedSelect = Select;
|
||||
TypedSelect.Option = Option;
|
||||
TypedSelect.OptGroup = OptGroup;
|
||||
export default TypedSelect;
|
||||
23
frontend/node_modules/rc-select/es/SelectContext.d.ts
generated
vendored
Normal file
23
frontend/node_modules/rc-select/es/SelectContext.d.ts
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
import * as React from 'react';
|
||||
import type { RawValueType, RenderNode } from './BaseSelect';
|
||||
import type { BaseOptionType, FieldNames, OnActiveValue, OnInternalSelect, SelectProps } from './Select';
|
||||
import type { FlattenOptionData } from './interface';
|
||||
export interface SelectContextProps {
|
||||
options: BaseOptionType[];
|
||||
optionRender?: SelectProps['optionRender'];
|
||||
flattenOptions: FlattenOptionData<BaseOptionType>[];
|
||||
onActiveValue: OnActiveValue;
|
||||
defaultActiveFirstOption?: boolean;
|
||||
onSelect: OnInternalSelect;
|
||||
menuItemSelectedIcon?: RenderNode;
|
||||
rawValues: Set<RawValueType>;
|
||||
fieldNames?: FieldNames;
|
||||
virtual?: boolean;
|
||||
direction?: 'ltr' | 'rtl';
|
||||
listHeight?: number;
|
||||
listItemHeight?: number;
|
||||
childrenAsData?: boolean;
|
||||
maxCount?: number;
|
||||
}
|
||||
declare const SelectContext: React.Context<SelectContextProps>;
|
||||
export default SelectContext;
|
||||
6
frontend/node_modules/rc-select/es/SelectContext.js
generated
vendored
Normal file
6
frontend/node_modules/rc-select/es/SelectContext.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import * as React from 'react';
|
||||
|
||||
// Use any here since we do not get the type during compilation
|
||||
|
||||
var SelectContext = /*#__PURE__*/React.createContext(null);
|
||||
export default SelectContext;
|
||||
30
frontend/node_modules/rc-select/es/SelectTrigger.d.ts
generated
vendored
Normal file
30
frontend/node_modules/rc-select/es/SelectTrigger.d.ts
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
import type { AlignType, BuildInPlacements } from '@rc-component/trigger/lib/interface';
|
||||
import * as React from 'react';
|
||||
import type { Placement, RenderDOMFunc } from './BaseSelect';
|
||||
export interface RefTriggerProps {
|
||||
getPopupElement: () => HTMLDivElement;
|
||||
}
|
||||
export interface SelectTriggerProps {
|
||||
prefixCls: string;
|
||||
children: React.ReactElement;
|
||||
disabled: boolean;
|
||||
visible: boolean;
|
||||
popupElement: React.ReactElement;
|
||||
animation?: string;
|
||||
transitionName?: string;
|
||||
placement?: Placement;
|
||||
builtinPlacements?: BuildInPlacements;
|
||||
dropdownStyle: React.CSSProperties;
|
||||
dropdownClassName: string;
|
||||
direction: string;
|
||||
dropdownMatchSelectWidth?: boolean | number;
|
||||
dropdownRender?: (menu: React.ReactElement) => React.ReactElement;
|
||||
getPopupContainer?: RenderDOMFunc;
|
||||
dropdownAlign: AlignType;
|
||||
empty: boolean;
|
||||
getTriggerDOMNode: (node: HTMLElement) => HTMLElement;
|
||||
onPopupVisibleChange?: (visible: boolean) => void;
|
||||
onPopupMouseEnter: () => void;
|
||||
}
|
||||
declare const RefSelectTrigger: React.ForwardRefExoticComponent<SelectTriggerProps & React.RefAttributes<RefTriggerProps>>;
|
||||
export default RefSelectTrigger;
|
||||
136
frontend/node_modules/rc-select/es/SelectTrigger.js
generated
vendored
Normal file
136
frontend/node_modules/rc-select/es/SelectTrigger.js
generated
vendored
Normal file
@@ -0,0 +1,136 @@
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
||||
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
||||
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
||||
var _excluded = ["prefixCls", "disabled", "visible", "children", "popupElement", "animation", "transitionName", "dropdownStyle", "dropdownClassName", "direction", "placement", "builtinPlacements", "dropdownMatchSelectWidth", "dropdownRender", "dropdownAlign", "getPopupContainer", "empty", "getTriggerDOMNode", "onPopupVisibleChange", "onPopupMouseEnter"];
|
||||
import Trigger from '@rc-component/trigger';
|
||||
import classNames from 'classnames';
|
||||
import * as React from 'react';
|
||||
var getBuiltInPlacements = function getBuiltInPlacements(dropdownMatchSelectWidth) {
|
||||
// Enable horizontal overflow auto-adjustment when a custom dropdown width is provided
|
||||
var adjustX = dropdownMatchSelectWidth === true ? 0 : 1;
|
||||
return {
|
||||
bottomLeft: {
|
||||
points: ['tl', 'bl'],
|
||||
offset: [0, 4],
|
||||
overflow: {
|
||||
adjustX: adjustX,
|
||||
adjustY: 1
|
||||
},
|
||||
htmlRegion: 'scroll'
|
||||
},
|
||||
bottomRight: {
|
||||
points: ['tr', 'br'],
|
||||
offset: [0, 4],
|
||||
overflow: {
|
||||
adjustX: adjustX,
|
||||
adjustY: 1
|
||||
},
|
||||
htmlRegion: 'scroll'
|
||||
},
|
||||
topLeft: {
|
||||
points: ['bl', 'tl'],
|
||||
offset: [0, -4],
|
||||
overflow: {
|
||||
adjustX: adjustX,
|
||||
adjustY: 1
|
||||
},
|
||||
htmlRegion: 'scroll'
|
||||
},
|
||||
topRight: {
|
||||
points: ['br', 'tr'],
|
||||
offset: [0, -4],
|
||||
overflow: {
|
||||
adjustX: adjustX,
|
||||
adjustY: 1
|
||||
},
|
||||
htmlRegion: 'scroll'
|
||||
}
|
||||
};
|
||||
};
|
||||
var SelectTrigger = function SelectTrigger(props, ref) {
|
||||
var prefixCls = props.prefixCls,
|
||||
disabled = props.disabled,
|
||||
visible = props.visible,
|
||||
children = props.children,
|
||||
popupElement = props.popupElement,
|
||||
animation = props.animation,
|
||||
transitionName = props.transitionName,
|
||||
dropdownStyle = props.dropdownStyle,
|
||||
dropdownClassName = props.dropdownClassName,
|
||||
_props$direction = props.direction,
|
||||
direction = _props$direction === void 0 ? 'ltr' : _props$direction,
|
||||
placement = props.placement,
|
||||
builtinPlacements = props.builtinPlacements,
|
||||
dropdownMatchSelectWidth = props.dropdownMatchSelectWidth,
|
||||
dropdownRender = props.dropdownRender,
|
||||
dropdownAlign = props.dropdownAlign,
|
||||
getPopupContainer = props.getPopupContainer,
|
||||
empty = props.empty,
|
||||
getTriggerDOMNode = props.getTriggerDOMNode,
|
||||
onPopupVisibleChange = props.onPopupVisibleChange,
|
||||
onPopupMouseEnter = props.onPopupMouseEnter,
|
||||
restProps = _objectWithoutProperties(props, _excluded);
|
||||
var dropdownPrefixCls = "".concat(prefixCls, "-dropdown");
|
||||
var popupNode = popupElement;
|
||||
if (dropdownRender) {
|
||||
popupNode = dropdownRender(popupElement);
|
||||
}
|
||||
var mergedBuiltinPlacements = React.useMemo(function () {
|
||||
return builtinPlacements || getBuiltInPlacements(dropdownMatchSelectWidth);
|
||||
}, [builtinPlacements, dropdownMatchSelectWidth]);
|
||||
|
||||
// ===================== Motion ======================
|
||||
var mergedTransitionName = animation ? "".concat(dropdownPrefixCls, "-").concat(animation) : transitionName;
|
||||
|
||||
// =================== Popup Width ===================
|
||||
var isNumberPopupWidth = typeof dropdownMatchSelectWidth === 'number';
|
||||
var stretch = React.useMemo(function () {
|
||||
if (isNumberPopupWidth) {
|
||||
return null;
|
||||
}
|
||||
return dropdownMatchSelectWidth === false ? 'minWidth' : 'width';
|
||||
}, [dropdownMatchSelectWidth, isNumberPopupWidth]);
|
||||
var popupStyle = dropdownStyle;
|
||||
if (isNumberPopupWidth) {
|
||||
popupStyle = _objectSpread(_objectSpread({}, popupStyle), {}, {
|
||||
width: dropdownMatchSelectWidth
|
||||
});
|
||||
}
|
||||
|
||||
// ======================= Ref =======================
|
||||
var triggerPopupRef = React.useRef(null);
|
||||
React.useImperativeHandle(ref, function () {
|
||||
return {
|
||||
getPopupElement: function getPopupElement() {
|
||||
var _triggerPopupRef$curr;
|
||||
return (_triggerPopupRef$curr = triggerPopupRef.current) === null || _triggerPopupRef$curr === void 0 ? void 0 : _triggerPopupRef$curr.popupElement;
|
||||
}
|
||||
};
|
||||
});
|
||||
return /*#__PURE__*/React.createElement(Trigger, _extends({}, restProps, {
|
||||
showAction: onPopupVisibleChange ? ['click'] : [],
|
||||
hideAction: onPopupVisibleChange ? ['click'] : [],
|
||||
popupPlacement: placement || (direction === 'rtl' ? 'bottomRight' : 'bottomLeft'),
|
||||
builtinPlacements: mergedBuiltinPlacements,
|
||||
prefixCls: dropdownPrefixCls,
|
||||
popupTransitionName: mergedTransitionName,
|
||||
popup: /*#__PURE__*/React.createElement("div", {
|
||||
onMouseEnter: onPopupMouseEnter
|
||||
}, popupNode),
|
||||
ref: triggerPopupRef,
|
||||
stretch: stretch,
|
||||
popupAlign: dropdownAlign,
|
||||
popupVisible: visible,
|
||||
getPopupContainer: getPopupContainer,
|
||||
popupClassName: classNames(dropdownClassName, _defineProperty({}, "".concat(dropdownPrefixCls, "-empty"), empty)),
|
||||
popupStyle: popupStyle,
|
||||
getTriggerDOMNode: getTriggerDOMNode,
|
||||
onPopupVisibleChange: onPopupVisibleChange
|
||||
}), children);
|
||||
};
|
||||
var RefSelectTrigger = /*#__PURE__*/React.forwardRef(SelectTrigger);
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
RefSelectTrigger.displayName = 'SelectTrigger';
|
||||
}
|
||||
export default RefSelectTrigger;
|
||||
27
frontend/node_modules/rc-select/es/Selector/Input.d.ts
generated
vendored
Normal file
27
frontend/node_modules/rc-select/es/Selector/Input.d.ts
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
import * as React from 'react';
|
||||
type InputRef = HTMLInputElement | HTMLTextAreaElement;
|
||||
interface InputProps {
|
||||
prefixCls: string;
|
||||
id: string;
|
||||
inputElement: React.ReactElement;
|
||||
disabled: boolean;
|
||||
autoFocus: boolean;
|
||||
autoComplete: string;
|
||||
editable: boolean;
|
||||
activeDescendantId?: string;
|
||||
value: string;
|
||||
maxLength?: number;
|
||||
open: boolean;
|
||||
tabIndex: number;
|
||||
/** Pass accessibility props to input */
|
||||
attrs: Record<string, unknown>;
|
||||
onKeyDown: React.KeyboardEventHandler<HTMLInputElement | HTMLTextAreaElement | HTMLElement>;
|
||||
onMouseDown: React.MouseEventHandler<HTMLInputElement | HTMLTextAreaElement | HTMLElement>;
|
||||
onChange: React.ChangeEventHandler<HTMLInputElement | HTMLTextAreaElement | HTMLElement>;
|
||||
onPaste: React.ClipboardEventHandler<HTMLInputElement | HTMLTextAreaElement | HTMLElement>;
|
||||
onBlur: React.FocusEventHandler<HTMLInputElement | HTMLTextAreaElement | HTMLElement>;
|
||||
onCompositionStart: React.CompositionEventHandler<HTMLInputElement | HTMLTextAreaElement | HTMLElement>;
|
||||
onCompositionEnd: React.CompositionEventHandler<HTMLInputElement | HTMLTextAreaElement | HTMLElement>;
|
||||
}
|
||||
declare const RefInput: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<InputRef>>;
|
||||
export default RefInput;
|
||||
56
frontend/node_modules/rc-select/es/Selector/Input.js
generated
vendored
Normal file
56
frontend/node_modules/rc-select/es/Selector/Input.js
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
||||
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
||||
var _excluded = ["prefixCls", "id", "inputElement", "autoFocus", "autoComplete", "editable", "activeDescendantId", "value", "open", "attrs"];
|
||||
import * as React from 'react';
|
||||
import classNames from 'classnames';
|
||||
import { composeRef } from "rc-util/es/ref";
|
||||
import { warning } from "rc-util/es/warning";
|
||||
import composeProps from "rc-util/es/composeProps";
|
||||
var Input = function Input(props, ref) {
|
||||
var prefixCls = props.prefixCls,
|
||||
id = props.id,
|
||||
inputElement = props.inputElement,
|
||||
autoFocus = props.autoFocus,
|
||||
autoComplete = props.autoComplete,
|
||||
editable = props.editable,
|
||||
activeDescendantId = props.activeDescendantId,
|
||||
value = props.value,
|
||||
open = props.open,
|
||||
attrs = props.attrs,
|
||||
restProps = _objectWithoutProperties(props, _excluded);
|
||||
var inputNode = inputElement || /*#__PURE__*/React.createElement("input", null);
|
||||
var _inputNode = inputNode,
|
||||
originRef = _inputNode.ref,
|
||||
originProps = _inputNode.props;
|
||||
warning(!('maxLength' in inputNode.props), "Passing 'maxLength' to input element directly may not work because input in BaseSelect is controlled.");
|
||||
inputNode = /*#__PURE__*/React.cloneElement(inputNode, _objectSpread(_objectSpread(_objectSpread({
|
||||
type: 'search'
|
||||
}, composeProps(restProps, originProps, true)), {}, {
|
||||
// Override over origin props
|
||||
id: id,
|
||||
ref: composeRef(ref, originRef),
|
||||
autoComplete: autoComplete || 'off',
|
||||
autoFocus: autoFocus,
|
||||
className: classNames("".concat(prefixCls, "-selection-search-input"), originProps === null || originProps === void 0 ? void 0 : originProps.className),
|
||||
role: 'combobox',
|
||||
'aria-expanded': open || false,
|
||||
'aria-haspopup': 'listbox',
|
||||
'aria-owns': "".concat(id, "_list"),
|
||||
'aria-autocomplete': 'list',
|
||||
'aria-controls': "".concat(id, "_list"),
|
||||
'aria-activedescendant': open ? activeDescendantId : undefined
|
||||
}, attrs), {}, {
|
||||
value: editable ? value : '',
|
||||
readOnly: !editable,
|
||||
unselectable: !editable ? 'on' : null,
|
||||
style: _objectSpread(_objectSpread({}, originProps.style), {}, {
|
||||
opacity: editable ? null : 0
|
||||
})
|
||||
}));
|
||||
return inputNode;
|
||||
};
|
||||
var RefInput = /*#__PURE__*/React.forwardRef(Input);
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
RefInput.displayName = 'Input';
|
||||
}
|
||||
export default RefInput;
|
||||
16
frontend/node_modules/rc-select/es/Selector/MultipleSelector.d.ts
generated
vendored
Normal file
16
frontend/node_modules/rc-select/es/Selector/MultipleSelector.d.ts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
import * as React from 'react';
|
||||
import type { InnerSelectorProps } from '.';
|
||||
import type { DisplayValueType, RenderNode, CustomTagProps } from '../BaseSelect';
|
||||
interface SelectorProps extends InnerSelectorProps {
|
||||
removeIcon?: RenderNode;
|
||||
maxTagCount?: number | 'responsive';
|
||||
maxTagTextLength?: number;
|
||||
maxTagPlaceholder?: React.ReactNode | ((omittedValues: DisplayValueType[]) => React.ReactNode);
|
||||
tokenSeparators?: string[];
|
||||
tagRender?: (props: CustomTagProps) => React.ReactElement;
|
||||
onToggleOpen: (open?: boolean) => void;
|
||||
choiceTransitionName?: string;
|
||||
onRemove: (value: DisplayValueType) => void;
|
||||
}
|
||||
declare const SelectSelector: React.FC<SelectorProps>;
|
||||
export default SelectSelector;
|
||||
192
frontend/node_modules/rc-select/es/Selector/MultipleSelector.js
generated
vendored
Normal file
192
frontend/node_modules/rc-select/es/Selector/MultipleSelector.js
generated
vendored
Normal file
@@ -0,0 +1,192 @@
|
||||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
||||
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
||||
import * as React from 'react';
|
||||
import { useState } from 'react';
|
||||
import classNames from 'classnames';
|
||||
import pickAttrs from "rc-util/es/pickAttrs";
|
||||
import Overflow from 'rc-overflow';
|
||||
import TransBtn from "../TransBtn";
|
||||
import Input from "./Input";
|
||||
import useLayoutEffect from "../hooks/useLayoutEffect";
|
||||
import { getTitle } from "../utils/commonUtil";
|
||||
function itemKey(value) {
|
||||
var _value$key;
|
||||
return (_value$key = value.key) !== null && _value$key !== void 0 ? _value$key : value.value;
|
||||
}
|
||||
var onPreventMouseDown = function onPreventMouseDown(event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
};
|
||||
var SelectSelector = function SelectSelector(props) {
|
||||
var id = props.id,
|
||||
prefixCls = props.prefixCls,
|
||||
values = props.values,
|
||||
open = props.open,
|
||||
searchValue = props.searchValue,
|
||||
autoClearSearchValue = props.autoClearSearchValue,
|
||||
inputRef = props.inputRef,
|
||||
placeholder = props.placeholder,
|
||||
disabled = props.disabled,
|
||||
mode = props.mode,
|
||||
showSearch = props.showSearch,
|
||||
autoFocus = props.autoFocus,
|
||||
autoComplete = props.autoComplete,
|
||||
activeDescendantId = props.activeDescendantId,
|
||||
tabIndex = props.tabIndex,
|
||||
removeIcon = props.removeIcon,
|
||||
maxTagCount = props.maxTagCount,
|
||||
maxTagTextLength = props.maxTagTextLength,
|
||||
_props$maxTagPlacehol = props.maxTagPlaceholder,
|
||||
maxTagPlaceholder = _props$maxTagPlacehol === void 0 ? function (omittedValues) {
|
||||
return "+ ".concat(omittedValues.length, " ...");
|
||||
} : _props$maxTagPlacehol,
|
||||
tagRender = props.tagRender,
|
||||
onToggleOpen = props.onToggleOpen,
|
||||
onRemove = props.onRemove,
|
||||
onInputChange = props.onInputChange,
|
||||
onInputPaste = props.onInputPaste,
|
||||
onInputKeyDown = props.onInputKeyDown,
|
||||
onInputMouseDown = props.onInputMouseDown,
|
||||
onInputCompositionStart = props.onInputCompositionStart,
|
||||
onInputCompositionEnd = props.onInputCompositionEnd,
|
||||
onInputBlur = props.onInputBlur;
|
||||
var measureRef = React.useRef(null);
|
||||
var _useState = useState(0),
|
||||
_useState2 = _slicedToArray(_useState, 2),
|
||||
inputWidth = _useState2[0],
|
||||
setInputWidth = _useState2[1];
|
||||
var _useState3 = useState(false),
|
||||
_useState4 = _slicedToArray(_useState3, 2),
|
||||
focused = _useState4[0],
|
||||
setFocused = _useState4[1];
|
||||
var selectionPrefixCls = "".concat(prefixCls, "-selection");
|
||||
|
||||
// ===================== Search ======================
|
||||
var inputValue = open || mode === 'multiple' && autoClearSearchValue === false || mode === 'tags' ? searchValue : '';
|
||||
var inputEditable = mode === 'tags' || mode === 'multiple' && autoClearSearchValue === false || showSearch && (open || focused);
|
||||
|
||||
// We measure width and set to the input immediately
|
||||
useLayoutEffect(function () {
|
||||
setInputWidth(measureRef.current.scrollWidth);
|
||||
}, [inputValue]);
|
||||
|
||||
// ===================== Render ======================
|
||||
// >>> Render Selector Node. Includes Item & Rest
|
||||
var defaultRenderSelector = function defaultRenderSelector(item, content, itemDisabled, closable, onClose) {
|
||||
return /*#__PURE__*/React.createElement("span", {
|
||||
title: getTitle(item),
|
||||
className: classNames("".concat(selectionPrefixCls, "-item"), _defineProperty({}, "".concat(selectionPrefixCls, "-item-disabled"), itemDisabled))
|
||||
}, /*#__PURE__*/React.createElement("span", {
|
||||
className: "".concat(selectionPrefixCls, "-item-content")
|
||||
}, content), closable && /*#__PURE__*/React.createElement(TransBtn, {
|
||||
className: "".concat(selectionPrefixCls, "-item-remove"),
|
||||
onMouseDown: onPreventMouseDown,
|
||||
onClick: onClose,
|
||||
customizeIcon: removeIcon
|
||||
}, "\xD7"));
|
||||
};
|
||||
var customizeRenderSelector = function customizeRenderSelector(value, content, itemDisabled, closable, onClose, isMaxTag) {
|
||||
var onMouseDown = function onMouseDown(e) {
|
||||
onPreventMouseDown(e);
|
||||
onToggleOpen(!open);
|
||||
};
|
||||
return /*#__PURE__*/React.createElement("span", {
|
||||
onMouseDown: onMouseDown
|
||||
}, tagRender({
|
||||
label: content,
|
||||
value: value,
|
||||
disabled: itemDisabled,
|
||||
closable: closable,
|
||||
onClose: onClose,
|
||||
isMaxTag: !!isMaxTag
|
||||
}));
|
||||
};
|
||||
var renderItem = function renderItem(valueItem) {
|
||||
var itemDisabled = valueItem.disabled,
|
||||
label = valueItem.label,
|
||||
value = valueItem.value;
|
||||
var closable = !disabled && !itemDisabled;
|
||||
var displayLabel = label;
|
||||
if (typeof maxTagTextLength === 'number') {
|
||||
if (typeof label === 'string' || typeof label === 'number') {
|
||||
var strLabel = String(displayLabel);
|
||||
if (strLabel.length > maxTagTextLength) {
|
||||
displayLabel = "".concat(strLabel.slice(0, maxTagTextLength), "...");
|
||||
}
|
||||
}
|
||||
}
|
||||
var onClose = function onClose(event) {
|
||||
if (event) {
|
||||
event.stopPropagation();
|
||||
}
|
||||
onRemove(valueItem);
|
||||
};
|
||||
return typeof tagRender === 'function' ? customizeRenderSelector(value, displayLabel, itemDisabled, closable, onClose) : defaultRenderSelector(valueItem, displayLabel, itemDisabled, closable, onClose);
|
||||
};
|
||||
var renderRest = function renderRest(omittedValues) {
|
||||
// https://github.com/ant-design/ant-design/issues/48930
|
||||
if (!values.length) {
|
||||
return null;
|
||||
}
|
||||
var content = typeof maxTagPlaceholder === 'function' ? maxTagPlaceholder(omittedValues) : maxTagPlaceholder;
|
||||
return typeof tagRender === 'function' ? customizeRenderSelector(undefined, content, false, false, undefined, true) : defaultRenderSelector({
|
||||
title: content
|
||||
}, content, false);
|
||||
};
|
||||
|
||||
// >>> Input Node
|
||||
var inputNode = /*#__PURE__*/React.createElement("div", {
|
||||
className: "".concat(selectionPrefixCls, "-search"),
|
||||
style: {
|
||||
width: inputWidth
|
||||
},
|
||||
onFocus: function onFocus() {
|
||||
setFocused(true);
|
||||
},
|
||||
onBlur: function onBlur() {
|
||||
setFocused(false);
|
||||
}
|
||||
}, /*#__PURE__*/React.createElement(Input, {
|
||||
ref: inputRef,
|
||||
open: open,
|
||||
prefixCls: prefixCls,
|
||||
id: id,
|
||||
inputElement: null,
|
||||
disabled: disabled,
|
||||
autoFocus: autoFocus,
|
||||
autoComplete: autoComplete,
|
||||
editable: inputEditable,
|
||||
activeDescendantId: activeDescendantId,
|
||||
value: inputValue,
|
||||
onKeyDown: onInputKeyDown,
|
||||
onMouseDown: onInputMouseDown,
|
||||
onChange: onInputChange,
|
||||
onPaste: onInputPaste,
|
||||
onCompositionStart: onInputCompositionStart,
|
||||
onCompositionEnd: onInputCompositionEnd,
|
||||
onBlur: onInputBlur,
|
||||
tabIndex: tabIndex,
|
||||
attrs: pickAttrs(props, true)
|
||||
}), /*#__PURE__*/React.createElement("span", {
|
||||
ref: measureRef,
|
||||
className: "".concat(selectionPrefixCls, "-search-mirror"),
|
||||
"aria-hidden": true
|
||||
}, inputValue, "\xA0"));
|
||||
|
||||
// >>> Selections
|
||||
var selectionNode = /*#__PURE__*/React.createElement(Overflow, {
|
||||
prefixCls: "".concat(selectionPrefixCls, "-overflow"),
|
||||
data: values,
|
||||
renderItem: renderItem,
|
||||
renderRest: renderRest,
|
||||
suffix: inputNode,
|
||||
itemKey: itemKey,
|
||||
maxCount: maxTagCount
|
||||
});
|
||||
return /*#__PURE__*/React.createElement("span", {
|
||||
className: "".concat(selectionPrefixCls, "-wrap")
|
||||
}, selectionNode, !values.length && !inputValue && /*#__PURE__*/React.createElement("span", {
|
||||
className: "".concat(selectionPrefixCls, "-placeholder")
|
||||
}, placeholder));
|
||||
};
|
||||
export default SelectSelector;
|
||||
8
frontend/node_modules/rc-select/es/Selector/SingleSelector.d.ts
generated
vendored
Normal file
8
frontend/node_modules/rc-select/es/Selector/SingleSelector.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import * as React from 'react';
|
||||
import type { InnerSelectorProps } from '.';
|
||||
interface SelectorProps extends InnerSelectorProps {
|
||||
inputElement: React.ReactElement;
|
||||
activeValue: string;
|
||||
}
|
||||
declare const SingleSelector: React.FC<SelectorProps>;
|
||||
export default SingleSelector;
|
||||
106
frontend/node_modules/rc-select/es/Selector/SingleSelector.js
generated
vendored
Normal file
106
frontend/node_modules/rc-select/es/Selector/SingleSelector.js
generated
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
||||
import * as React from 'react';
|
||||
import pickAttrs from "rc-util/es/pickAttrs";
|
||||
import Input from "./Input";
|
||||
import { getTitle } from "../utils/commonUtil";
|
||||
var SingleSelector = function SingleSelector(props) {
|
||||
var inputElement = props.inputElement,
|
||||
prefixCls = props.prefixCls,
|
||||
id = props.id,
|
||||
inputRef = props.inputRef,
|
||||
disabled = props.disabled,
|
||||
autoFocus = props.autoFocus,
|
||||
autoComplete = props.autoComplete,
|
||||
activeDescendantId = props.activeDescendantId,
|
||||
mode = props.mode,
|
||||
open = props.open,
|
||||
values = props.values,
|
||||
placeholder = props.placeholder,
|
||||
tabIndex = props.tabIndex,
|
||||
showSearch = props.showSearch,
|
||||
searchValue = props.searchValue,
|
||||
activeValue = props.activeValue,
|
||||
maxLength = props.maxLength,
|
||||
onInputKeyDown = props.onInputKeyDown,
|
||||
onInputMouseDown = props.onInputMouseDown,
|
||||
onInputChange = props.onInputChange,
|
||||
onInputPaste = props.onInputPaste,
|
||||
onInputCompositionStart = props.onInputCompositionStart,
|
||||
onInputCompositionEnd = props.onInputCompositionEnd,
|
||||
onInputBlur = props.onInputBlur,
|
||||
title = props.title;
|
||||
var _React$useState = React.useState(false),
|
||||
_React$useState2 = _slicedToArray(_React$useState, 2),
|
||||
inputChanged = _React$useState2[0],
|
||||
setInputChanged = _React$useState2[1];
|
||||
var combobox = mode === 'combobox';
|
||||
var inputEditable = combobox || showSearch;
|
||||
var item = values[0];
|
||||
var inputValue = searchValue || '';
|
||||
if (combobox && activeValue && !inputChanged) {
|
||||
inputValue = activeValue;
|
||||
}
|
||||
React.useEffect(function () {
|
||||
if (combobox) {
|
||||
setInputChanged(false);
|
||||
}
|
||||
}, [combobox, activeValue]);
|
||||
|
||||
// Not show text when closed expect combobox mode
|
||||
var hasTextInput = mode !== 'combobox' && !open && !showSearch ? false : !!inputValue;
|
||||
|
||||
// Get title of selection item
|
||||
var selectionTitle = title === undefined ? getTitle(item) : title;
|
||||
var placeholderNode = React.useMemo(function () {
|
||||
if (item) {
|
||||
return null;
|
||||
}
|
||||
return /*#__PURE__*/React.createElement("span", {
|
||||
className: "".concat(prefixCls, "-selection-placeholder"),
|
||||
style: hasTextInput ? {
|
||||
visibility: 'hidden'
|
||||
} : undefined
|
||||
}, placeholder);
|
||||
}, [item, hasTextInput, placeholder, prefixCls]);
|
||||
return /*#__PURE__*/React.createElement("span", {
|
||||
className: "".concat(prefixCls, "-selection-wrap")
|
||||
}, /*#__PURE__*/React.createElement("span", {
|
||||
className: "".concat(prefixCls, "-selection-search")
|
||||
}, /*#__PURE__*/React.createElement(Input, {
|
||||
ref: inputRef,
|
||||
prefixCls: prefixCls,
|
||||
id: id,
|
||||
open: open,
|
||||
inputElement: inputElement,
|
||||
disabled: disabled,
|
||||
autoFocus: autoFocus,
|
||||
autoComplete: autoComplete,
|
||||
editable: inputEditable,
|
||||
activeDescendantId: activeDescendantId,
|
||||
value: inputValue,
|
||||
onKeyDown: onInputKeyDown,
|
||||
onMouseDown: onInputMouseDown,
|
||||
onChange: function onChange(e) {
|
||||
setInputChanged(true);
|
||||
onInputChange(e);
|
||||
},
|
||||
onPaste: onInputPaste,
|
||||
onCompositionStart: onInputCompositionStart,
|
||||
onCompositionEnd: onInputCompositionEnd,
|
||||
onBlur: onInputBlur,
|
||||
tabIndex: tabIndex,
|
||||
attrs: pickAttrs(props, true),
|
||||
maxLength: combobox ? maxLength : undefined
|
||||
})), !combobox && item ? /*#__PURE__*/React.createElement("span", {
|
||||
className: "".concat(prefixCls, "-selection-item"),
|
||||
title: selectionTitle
|
||||
// 当 Select 已经选中选项时,还需 selection 隐藏但留在原地占位
|
||||
// https://github.com/ant-design/ant-design/issues/27688
|
||||
// https://github.com/ant-design/ant-design/issues/41530
|
||||
,
|
||||
style: hasTextInput ? {
|
||||
visibility: 'hidden'
|
||||
} : undefined
|
||||
}, item.label) : null, placeholderNode);
|
||||
};
|
||||
export default SingleSelector;
|
||||
85
frontend/node_modules/rc-select/es/Selector/index.d.ts
generated
vendored
Normal file
85
frontend/node_modules/rc-select/es/Selector/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
/**
|
||||
* Cursor rule:
|
||||
* 1. Only `showSearch` enabled
|
||||
* 2. Only `open` is `true`
|
||||
* 3. When typing, set `open` to `true` which hit rule of 2
|
||||
*
|
||||
* Accessibility:
|
||||
* - https://www.w3.org/TR/wai-aria-practices/examples/combobox/aria1.1pattern/listbox-combo.html
|
||||
*/
|
||||
import type { ScrollTo } from 'rc-virtual-list/lib/List';
|
||||
import * as React from 'react';
|
||||
import type { CustomTagProps, DisplayValueType, Mode, RenderNode } from '../BaseSelect';
|
||||
export interface InnerSelectorProps {
|
||||
prefixCls: string;
|
||||
id: string;
|
||||
mode: Mode;
|
||||
title?: string;
|
||||
inputRef: React.Ref<HTMLInputElement | HTMLTextAreaElement>;
|
||||
placeholder?: React.ReactNode;
|
||||
disabled?: boolean;
|
||||
autoFocus?: boolean;
|
||||
autoComplete?: string;
|
||||
values: DisplayValueType[];
|
||||
showSearch?: boolean;
|
||||
searchValue: string;
|
||||
autoClearSearchValue?: boolean;
|
||||
activeDescendantId?: string;
|
||||
open: boolean;
|
||||
tabIndex?: number;
|
||||
maxLength?: number;
|
||||
onInputKeyDown: React.KeyboardEventHandler<HTMLInputElement | HTMLTextAreaElement>;
|
||||
onInputMouseDown: React.MouseEventHandler<HTMLInputElement | HTMLTextAreaElement>;
|
||||
onInputChange: React.ChangeEventHandler<HTMLInputElement | HTMLTextAreaElement>;
|
||||
onInputPaste: React.ClipboardEventHandler<HTMLInputElement | HTMLTextAreaElement>;
|
||||
onInputCompositionStart: React.CompositionEventHandler<HTMLInputElement | HTMLTextAreaElement>;
|
||||
onInputCompositionEnd: React.CompositionEventHandler<HTMLInputElement | HTMLTextAreaElement>;
|
||||
onInputBlur: React.FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;
|
||||
}
|
||||
export interface RefSelectorProps {
|
||||
focus: (options?: FocusOptions) => void;
|
||||
blur: () => void;
|
||||
scrollTo?: ScrollTo;
|
||||
}
|
||||
export interface SelectorProps {
|
||||
id: string;
|
||||
prefixCls: string;
|
||||
showSearch?: boolean;
|
||||
open: boolean;
|
||||
/** Display in the Selector value, it's not same as `value` prop */
|
||||
values: DisplayValueType[];
|
||||
mode: Mode;
|
||||
searchValue: string;
|
||||
activeValue: string;
|
||||
autoClearSearchValue: boolean;
|
||||
inputElement: JSX.Element;
|
||||
maxLength?: number;
|
||||
autoFocus?: boolean;
|
||||
activeDescendantId?: string;
|
||||
tabIndex?: number;
|
||||
disabled?: boolean;
|
||||
placeholder?: React.ReactNode;
|
||||
removeIcon?: RenderNode;
|
||||
prefix?: React.ReactNode;
|
||||
maxTagCount?: number | 'responsive';
|
||||
maxTagTextLength?: number;
|
||||
maxTagPlaceholder?: React.ReactNode | ((omittedValues: DisplayValueType[]) => React.ReactNode);
|
||||
tagRender?: (props: CustomTagProps) => React.ReactElement;
|
||||
/** Check if `tokenSeparators` contains `\n` or `\r\n` */
|
||||
tokenWithEnter?: boolean;
|
||||
choiceTransitionName?: string;
|
||||
onToggleOpen: (open?: boolean) => void;
|
||||
/** `onSearch` returns go next step boolean to check if need do toggle open */
|
||||
onSearch: (searchText: string, fromTyping: boolean, isCompositing: boolean) => boolean;
|
||||
onSearchSubmit?: (searchText: string) => void;
|
||||
onRemove: (value: DisplayValueType) => void;
|
||||
onInputKeyDown?: React.KeyboardEventHandler<HTMLInputElement | HTMLTextAreaElement>;
|
||||
onInputBlur?: () => void;
|
||||
/**
|
||||
* @private get real dom for trigger align.
|
||||
* This may be removed after React provides replacement of `findDOMNode`
|
||||
*/
|
||||
domRef: React.Ref<HTMLDivElement>;
|
||||
}
|
||||
declare const ForwardSelector: React.ForwardRefExoticComponent<SelectorProps & React.RefAttributes<RefSelectorProps>>;
|
||||
export default ForwardSelector;
|
||||
179
frontend/node_modules/rc-select/es/Selector/index.js
generated
vendored
Normal file
179
frontend/node_modules/rc-select/es/Selector/index.js
generated
vendored
Normal file
@@ -0,0 +1,179 @@
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
||||
/**
|
||||
* Cursor rule:
|
||||
* 1. Only `showSearch` enabled
|
||||
* 2. Only `open` is `true`
|
||||
* 3. When typing, set `open` to `true` which hit rule of 2
|
||||
*
|
||||
* Accessibility:
|
||||
* - https://www.w3.org/TR/wai-aria-practices/examples/combobox/aria1.1pattern/listbox-combo.html
|
||||
*/
|
||||
|
||||
import KeyCode from "rc-util/es/KeyCode";
|
||||
import * as React from 'react';
|
||||
import { useRef } from 'react';
|
||||
import useLock from "../hooks/useLock";
|
||||
import { isValidateOpenKey } from "../utils/keyUtil";
|
||||
import MultipleSelector from "./MultipleSelector";
|
||||
import SingleSelector from "./SingleSelector";
|
||||
var Selector = function Selector(props, ref) {
|
||||
var inputRef = useRef(null);
|
||||
var compositionStatusRef = useRef(false);
|
||||
var prefixCls = props.prefixCls,
|
||||
open = props.open,
|
||||
mode = props.mode,
|
||||
showSearch = props.showSearch,
|
||||
tokenWithEnter = props.tokenWithEnter,
|
||||
disabled = props.disabled,
|
||||
prefix = props.prefix,
|
||||
autoClearSearchValue = props.autoClearSearchValue,
|
||||
onSearch = props.onSearch,
|
||||
onSearchSubmit = props.onSearchSubmit,
|
||||
onToggleOpen = props.onToggleOpen,
|
||||
onInputKeyDown = props.onInputKeyDown,
|
||||
onInputBlur = props.onInputBlur,
|
||||
domRef = props.domRef;
|
||||
|
||||
// ======================= Ref =======================
|
||||
React.useImperativeHandle(ref, function () {
|
||||
return {
|
||||
focus: function focus(options) {
|
||||
inputRef.current.focus(options);
|
||||
},
|
||||
blur: function blur() {
|
||||
inputRef.current.blur();
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
// ====================== Input ======================
|
||||
var _useLock = useLock(0),
|
||||
_useLock2 = _slicedToArray(_useLock, 2),
|
||||
getInputMouseDown = _useLock2[0],
|
||||
setInputMouseDown = _useLock2[1];
|
||||
var onInternalInputKeyDown = function onInternalInputKeyDown(event) {
|
||||
var which = event.which;
|
||||
|
||||
// Compatible with multiple lines in TextArea
|
||||
var isTextAreaElement = inputRef.current instanceof HTMLTextAreaElement;
|
||||
if (!isTextAreaElement && open && (which === KeyCode.UP || which === KeyCode.DOWN)) {
|
||||
event.preventDefault();
|
||||
}
|
||||
if (onInputKeyDown) {
|
||||
onInputKeyDown(event);
|
||||
}
|
||||
if (which === KeyCode.ENTER && mode === 'tags' && !compositionStatusRef.current && !open) {
|
||||
// When menu isn't open, OptionList won't trigger a value change
|
||||
// So when enter is pressed, the tag's input value should be emitted here to let selector know
|
||||
onSearchSubmit === null || onSearchSubmit === void 0 || onSearchSubmit(event.target.value);
|
||||
}
|
||||
// Move within the text box
|
||||
if (isTextAreaElement && !open && ~[KeyCode.UP, KeyCode.DOWN, KeyCode.LEFT, KeyCode.RIGHT].indexOf(which)) {
|
||||
return;
|
||||
}
|
||||
if (isValidateOpenKey(which)) {
|
||||
onToggleOpen(true);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* We can not use `findDOMNode` sine it will get warning,
|
||||
* have to use timer to check if is input element.
|
||||
*/
|
||||
var onInternalInputMouseDown = function onInternalInputMouseDown() {
|
||||
setInputMouseDown(true);
|
||||
};
|
||||
|
||||
// When paste come, ignore next onChange
|
||||
var pastedTextRef = useRef(null);
|
||||
var triggerOnSearch = function triggerOnSearch(value) {
|
||||
if (onSearch(value, true, compositionStatusRef.current) !== false) {
|
||||
onToggleOpen(true);
|
||||
}
|
||||
};
|
||||
var onInputCompositionStart = function onInputCompositionStart() {
|
||||
compositionStatusRef.current = true;
|
||||
};
|
||||
var onInputCompositionEnd = function onInputCompositionEnd(e) {
|
||||
compositionStatusRef.current = false;
|
||||
|
||||
// Trigger search again to support `tokenSeparators` with typewriting
|
||||
if (mode !== 'combobox') {
|
||||
triggerOnSearch(e.target.value);
|
||||
}
|
||||
};
|
||||
var onInputChange = function onInputChange(event) {
|
||||
var value = event.target.value;
|
||||
|
||||
// Pasted text should replace back to origin content
|
||||
if (tokenWithEnter && pastedTextRef.current && /[\r\n]/.test(pastedTextRef.current)) {
|
||||
// CRLF will be treated as a single space for input element
|
||||
var replacedText = pastedTextRef.current.replace(/[\r\n]+$/, '').replace(/\r\n/g, ' ').replace(/[\r\n]/g, ' ');
|
||||
value = value.replace(replacedText, pastedTextRef.current);
|
||||
}
|
||||
pastedTextRef.current = null;
|
||||
triggerOnSearch(value);
|
||||
};
|
||||
var onInputPaste = function onInputPaste(e) {
|
||||
var clipboardData = e.clipboardData;
|
||||
var value = clipboardData === null || clipboardData === void 0 ? void 0 : clipboardData.getData('text');
|
||||
pastedTextRef.current = value || '';
|
||||
};
|
||||
var onClick = function onClick(_ref) {
|
||||
var target = _ref.target;
|
||||
if (target !== inputRef.current) {
|
||||
// Should focus input if click the selector
|
||||
var isIE = document.body.style.msTouchAction !== undefined;
|
||||
if (isIE) {
|
||||
setTimeout(function () {
|
||||
inputRef.current.focus();
|
||||
});
|
||||
} else {
|
||||
inputRef.current.focus();
|
||||
}
|
||||
}
|
||||
};
|
||||
var onMouseDown = function onMouseDown(event) {
|
||||
var inputMouseDown = getInputMouseDown();
|
||||
|
||||
// when mode is combobox and it is disabled, don't prevent default behavior
|
||||
// https://github.com/ant-design/ant-design/issues/37320
|
||||
// https://github.com/ant-design/ant-design/issues/48281
|
||||
if (event.target !== inputRef.current && !inputMouseDown && !(mode === 'combobox' && disabled)) {
|
||||
event.preventDefault();
|
||||
}
|
||||
if (mode !== 'combobox' && (!showSearch || !inputMouseDown) || !open) {
|
||||
if (open && autoClearSearchValue !== false) {
|
||||
onSearch('', true, false);
|
||||
}
|
||||
onToggleOpen();
|
||||
}
|
||||
};
|
||||
|
||||
// ================= Inner Selector ==================
|
||||
var sharedProps = {
|
||||
inputRef: inputRef,
|
||||
onInputKeyDown: onInternalInputKeyDown,
|
||||
onInputMouseDown: onInternalInputMouseDown,
|
||||
onInputChange: onInputChange,
|
||||
onInputPaste: onInputPaste,
|
||||
onInputCompositionStart: onInputCompositionStart,
|
||||
onInputCompositionEnd: onInputCompositionEnd,
|
||||
onInputBlur: onInputBlur
|
||||
};
|
||||
var selectNode = mode === 'multiple' || mode === 'tags' ? /*#__PURE__*/React.createElement(MultipleSelector, _extends({}, props, sharedProps)) : /*#__PURE__*/React.createElement(SingleSelector, _extends({}, props, sharedProps));
|
||||
return /*#__PURE__*/React.createElement("div", {
|
||||
ref: domRef,
|
||||
className: "".concat(prefixCls, "-selector"),
|
||||
onClick: onClick,
|
||||
onMouseDown: onMouseDown
|
||||
}, prefix && /*#__PURE__*/React.createElement("div", {
|
||||
className: "".concat(prefixCls, "-prefix")
|
||||
}, prefix), selectNode);
|
||||
};
|
||||
var ForwardSelector = /*#__PURE__*/React.forwardRef(Selector);
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
ForwardSelector.displayName = 'Selector';
|
||||
}
|
||||
export default ForwardSelector;
|
||||
12
frontend/node_modules/rc-select/es/TransBtn.d.ts
generated
vendored
Normal file
12
frontend/node_modules/rc-select/es/TransBtn.d.ts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import * as React from 'react';
|
||||
import type { RenderNode } from './BaseSelect';
|
||||
export interface TransBtnProps {
|
||||
className: string;
|
||||
customizeIcon: RenderNode;
|
||||
customizeIconProps?: any;
|
||||
onMouseDown?: React.MouseEventHandler<HTMLSpanElement>;
|
||||
onClick?: React.MouseEventHandler<HTMLSpanElement>;
|
||||
children?: React.ReactNode;
|
||||
}
|
||||
declare const TransBtn: React.FC<TransBtnProps>;
|
||||
export default TransBtn;
|
||||
30
frontend/node_modules/rc-select/es/TransBtn.js
generated
vendored
Normal file
30
frontend/node_modules/rc-select/es/TransBtn.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
import * as React from 'react';
|
||||
import classNames from 'classnames';
|
||||
var TransBtn = function TransBtn(props) {
|
||||
var className = props.className,
|
||||
customizeIcon = props.customizeIcon,
|
||||
customizeIconProps = props.customizeIconProps,
|
||||
children = props.children,
|
||||
_onMouseDown = props.onMouseDown,
|
||||
onClick = props.onClick;
|
||||
var icon = typeof customizeIcon === 'function' ? customizeIcon(customizeIconProps) : customizeIcon;
|
||||
return /*#__PURE__*/React.createElement("span", {
|
||||
className: className,
|
||||
onMouseDown: function onMouseDown(event) {
|
||||
event.preventDefault();
|
||||
_onMouseDown === null || _onMouseDown === void 0 || _onMouseDown(event);
|
||||
},
|
||||
style: {
|
||||
userSelect: 'none',
|
||||
WebkitUserSelect: 'none'
|
||||
},
|
||||
unselectable: "on",
|
||||
onClick: onClick,
|
||||
"aria-hidden": true
|
||||
}, icon !== undefined ? icon : /*#__PURE__*/React.createElement("span", {
|
||||
className: classNames(className.split(/\s+/).map(function (cls) {
|
||||
return "".concat(cls, "-icon");
|
||||
}))
|
||||
}, children));
|
||||
};
|
||||
export default TransBtn;
|
||||
8
frontend/node_modules/rc-select/es/hooks/useAllowClear.d.ts
generated
vendored
Normal file
8
frontend/node_modules/rc-select/es/hooks/useAllowClear.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import type { DisplayValueType, Mode, RenderNode } from '../interface';
|
||||
import React from 'react';
|
||||
export declare const useAllowClear: (prefixCls: string, onClearMouseDown: React.MouseEventHandler<HTMLSpanElement>, displayValues: DisplayValueType[], allowClear?: boolean | {
|
||||
clearIcon?: RenderNode;
|
||||
}, clearIcon?: RenderNode, disabled?: boolean, mergedSearchValue?: string, mode?: Mode) => {
|
||||
allowClear: boolean;
|
||||
clearIcon: React.JSX.Element;
|
||||
};
|
||||
30
frontend/node_modules/rc-select/es/hooks/useAllowClear.js
generated
vendored
Normal file
30
frontend/node_modules/rc-select/es/hooks/useAllowClear.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
||||
import TransBtn from "../TransBtn";
|
||||
import React from 'react';
|
||||
export var useAllowClear = function useAllowClear(prefixCls, onClearMouseDown, displayValues, allowClear, clearIcon) {
|
||||
var disabled = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
||||
var mergedSearchValue = arguments.length > 6 ? arguments[6] : undefined;
|
||||
var mode = arguments.length > 7 ? arguments[7] : undefined;
|
||||
var mergedClearIcon = React.useMemo(function () {
|
||||
if (_typeof(allowClear) === 'object') {
|
||||
return allowClear.clearIcon;
|
||||
}
|
||||
if (clearIcon) {
|
||||
return clearIcon;
|
||||
}
|
||||
}, [allowClear, clearIcon]);
|
||||
var mergedAllowClear = React.useMemo(function () {
|
||||
if (!disabled && !!allowClear && (displayValues.length || mergedSearchValue) && !(mode === 'combobox' && mergedSearchValue === '')) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}, [allowClear, disabled, displayValues.length, mergedSearchValue, mode]);
|
||||
return {
|
||||
allowClear: mergedAllowClear,
|
||||
clearIcon: /*#__PURE__*/React.createElement(TransBtn, {
|
||||
className: "".concat(prefixCls, "-clear"),
|
||||
onMouseDown: onClearMouseDown,
|
||||
customizeIcon: mergedClearIcon
|
||||
}, "\xD7")
|
||||
};
|
||||
};
|
||||
13
frontend/node_modules/rc-select/es/hooks/useBaseProps.d.ts
generated
vendored
Normal file
13
frontend/node_modules/rc-select/es/hooks/useBaseProps.d.ts
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* BaseSelect provide some parsed data into context.
|
||||
* You can use this hooks to get them.
|
||||
*/
|
||||
import * as React from 'react';
|
||||
import type { BaseSelectProps } from '../BaseSelect';
|
||||
export interface BaseSelectContextProps extends BaseSelectProps {
|
||||
triggerOpen: boolean;
|
||||
multiple: boolean;
|
||||
toggleOpen: (open?: boolean) => void;
|
||||
}
|
||||
export declare const BaseSelectContext: React.Context<BaseSelectContextProps>;
|
||||
export default function useBaseProps(): BaseSelectContextProps;
|
||||
10
frontend/node_modules/rc-select/es/hooks/useBaseProps.js
generated
vendored
Normal file
10
frontend/node_modules/rc-select/es/hooks/useBaseProps.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* BaseSelect provide some parsed data into context.
|
||||
* You can use this hooks to get them.
|
||||
*/
|
||||
|
||||
import * as React from 'react';
|
||||
export var BaseSelectContext = /*#__PURE__*/React.createContext(null);
|
||||
export default function useBaseProps() {
|
||||
return React.useContext(BaseSelectContext);
|
||||
}
|
||||
7
frontend/node_modules/rc-select/es/hooks/useCache.d.ts
generated
vendored
Normal file
7
frontend/node_modules/rc-select/es/hooks/useCache.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import type { RawValueType } from '../BaseSelect';
|
||||
import type { DefaultOptionType, LabelInValueType } from '../Select';
|
||||
/**
|
||||
* Cache `value` related LabeledValue & options.
|
||||
*/
|
||||
declare const _default: (labeledValues: LabelInValueType[], valueOptions: Map<RawValueType, DefaultOptionType>) => [LabelInValueType[], (val: RawValueType) => DefaultOptionType];
|
||||
export default _default;
|
||||
42
frontend/node_modules/rc-select/es/hooks/useCache.js
generated
vendored
Normal file
42
frontend/node_modules/rc-select/es/hooks/useCache.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
||||
import * as React from 'react';
|
||||
/**
|
||||
* Cache `value` related LabeledValue & options.
|
||||
*/
|
||||
export default (function (labeledValues, valueOptions) {
|
||||
var cacheRef = React.useRef({
|
||||
values: new Map(),
|
||||
options: new Map()
|
||||
});
|
||||
var filledLabeledValues = React.useMemo(function () {
|
||||
var _cacheRef$current = cacheRef.current,
|
||||
prevValueCache = _cacheRef$current.values,
|
||||
prevOptionCache = _cacheRef$current.options;
|
||||
|
||||
// Fill label by cache
|
||||
var patchedValues = labeledValues.map(function (item) {
|
||||
if (item.label === undefined) {
|
||||
var _prevValueCache$get;
|
||||
return _objectSpread(_objectSpread({}, item), {}, {
|
||||
label: (_prevValueCache$get = prevValueCache.get(item.value)) === null || _prevValueCache$get === void 0 ? void 0 : _prevValueCache$get.label
|
||||
});
|
||||
}
|
||||
return item;
|
||||
});
|
||||
|
||||
// Refresh cache
|
||||
var valueCache = new Map();
|
||||
var optionCache = new Map();
|
||||
patchedValues.forEach(function (item) {
|
||||
valueCache.set(item.value, item);
|
||||
optionCache.set(item.value, valueOptions.get(item.value) || prevOptionCache.get(item.value));
|
||||
});
|
||||
cacheRef.current.values = valueCache;
|
||||
cacheRef.current.options = optionCache;
|
||||
return patchedValues;
|
||||
}, [labeledValues, valueOptions]);
|
||||
var getOption = React.useCallback(function (val) {
|
||||
return valueOptions.get(val) || cacheRef.current.options.get(val);
|
||||
}, [valueOptions]);
|
||||
return [filledLabeledValues, getOption];
|
||||
});
|
||||
5
frontend/node_modules/rc-select/es/hooks/useDelayReset.d.ts
generated
vendored
Normal file
5
frontend/node_modules/rc-select/es/hooks/useDelayReset.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* Similar with `useLock`, but this hook will always execute last value.
|
||||
* When set to `true`, it will keep `true` for a short time even if `false` is set.
|
||||
*/
|
||||
export default function useDelayReset(timeout?: number): [boolean, (val: boolean, callback?: () => void) => void, () => void];
|
||||
31
frontend/node_modules/rc-select/es/hooks/useDelayReset.js
generated
vendored
Normal file
31
frontend/node_modules/rc-select/es/hooks/useDelayReset.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
||||
import * as React from 'react';
|
||||
|
||||
/**
|
||||
* Similar with `useLock`, but this hook will always execute last value.
|
||||
* When set to `true`, it will keep `true` for a short time even if `false` is set.
|
||||
*/
|
||||
export default function useDelayReset() {
|
||||
var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10;
|
||||
var _React$useState = React.useState(false),
|
||||
_React$useState2 = _slicedToArray(_React$useState, 2),
|
||||
bool = _React$useState2[0],
|
||||
setBool = _React$useState2[1];
|
||||
var delayRef = React.useRef(null);
|
||||
var cancelLatest = function cancelLatest() {
|
||||
window.clearTimeout(delayRef.current);
|
||||
};
|
||||
React.useEffect(function () {
|
||||
return cancelLatest;
|
||||
}, []);
|
||||
var delaySetBool = function delaySetBool(value, callback) {
|
||||
cancelLatest();
|
||||
delayRef.current = window.setTimeout(function () {
|
||||
setBool(value);
|
||||
if (callback) {
|
||||
callback();
|
||||
}
|
||||
}, timeout);
|
||||
};
|
||||
return [bool, delaySetBool, cancelLatest];
|
||||
}
|
||||
3
frontend/node_modules/rc-select/es/hooks/useFilterOptions.d.ts
generated
vendored
Normal file
3
frontend/node_modules/rc-select/es/hooks/useFilterOptions.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import type { FieldNames, DefaultOptionType, SelectProps } from '../Select';
|
||||
declare const _default: (options: DefaultOptionType[], fieldNames: FieldNames, searchValue?: string, filterOption?: SelectProps['filterOption'], optionFilterProp?: string) => DefaultOptionType[];
|
||||
export default _default;
|
||||
62
frontend/node_modules/rc-select/es/hooks/useFilterOptions.js
generated
vendored
Normal file
62
frontend/node_modules/rc-select/es/hooks/useFilterOptions.js
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
||||
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
||||
import * as React from 'react';
|
||||
import { toArray } from "../utils/commonUtil";
|
||||
import { injectPropsWithOption } from "../utils/valueUtil";
|
||||
function includes(test, search) {
|
||||
return toArray(test).join('').toUpperCase().includes(search);
|
||||
}
|
||||
export default (function (options, fieldNames, searchValue, filterOption, optionFilterProp) {
|
||||
return React.useMemo(function () {
|
||||
if (!searchValue || filterOption === false) {
|
||||
return options;
|
||||
}
|
||||
var fieldOptions = fieldNames.options,
|
||||
fieldLabel = fieldNames.label,
|
||||
fieldValue = fieldNames.value;
|
||||
var filteredOptions = [];
|
||||
var customizeFilter = typeof filterOption === 'function';
|
||||
var upperSearch = searchValue.toUpperCase();
|
||||
var filterFunc = customizeFilter ? filterOption : function (_, option) {
|
||||
// Use provided `optionFilterProp`
|
||||
if (optionFilterProp) {
|
||||
return includes(option[optionFilterProp], upperSearch);
|
||||
}
|
||||
|
||||
// Auto select `label` or `value` by option type
|
||||
if (option[fieldOptions]) {
|
||||
// hack `fieldLabel` since `OptionGroup` children is not `label`
|
||||
return includes(option[fieldLabel !== 'children' ? fieldLabel : 'label'], upperSearch);
|
||||
}
|
||||
return includes(option[fieldValue], upperSearch);
|
||||
};
|
||||
var wrapOption = customizeFilter ? function (opt) {
|
||||
return injectPropsWithOption(opt);
|
||||
} : function (opt) {
|
||||
return opt;
|
||||
};
|
||||
options.forEach(function (item) {
|
||||
// Group should check child options
|
||||
if (item[fieldOptions]) {
|
||||
// Check group first
|
||||
var matchGroup = filterFunc(searchValue, wrapOption(item));
|
||||
if (matchGroup) {
|
||||
filteredOptions.push(item);
|
||||
} else {
|
||||
// Check option
|
||||
var subOptions = item[fieldOptions].filter(function (subItem) {
|
||||
return filterFunc(searchValue, wrapOption(subItem));
|
||||
});
|
||||
if (subOptions.length) {
|
||||
filteredOptions.push(_objectSpread(_objectSpread({}, item), {}, _defineProperty({}, fieldOptions, subOptions)));
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (filterFunc(searchValue, wrapOption(item))) {
|
||||
filteredOptions.push(item);
|
||||
}
|
||||
});
|
||||
return filteredOptions;
|
||||
}, [options, filterOption, optionFilterProp, searchValue, fieldNames]);
|
||||
});
|
||||
5
frontend/node_modules/rc-select/es/hooks/useId.d.ts
generated
vendored
Normal file
5
frontend/node_modules/rc-select/es/hooks/useId.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
/** Is client side and not jsdom */
|
||||
export declare const isBrowserClient: boolean;
|
||||
/** Get unique id for accessibility usage */
|
||||
export declare function getUUID(): number | string;
|
||||
export default function useId(id?: string): string;
|
||||
33
frontend/node_modules/rc-select/es/hooks/useId.js
generated
vendored
Normal file
33
frontend/node_modules/rc-select/es/hooks/useId.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
||||
import * as React from 'react';
|
||||
import canUseDom from "rc-util/es/Dom/canUseDom";
|
||||
var uuid = 0;
|
||||
|
||||
/** Is client side and not jsdom */
|
||||
export var isBrowserClient = process.env.NODE_ENV !== 'test' && canUseDom();
|
||||
|
||||
/** Get unique id for accessibility usage */
|
||||
export function getUUID() {
|
||||
var retId;
|
||||
|
||||
// Test never reach
|
||||
/* istanbul ignore if */
|
||||
if (isBrowserClient) {
|
||||
retId = uuid;
|
||||
uuid += 1;
|
||||
} else {
|
||||
retId = 'TEST_OR_SSR';
|
||||
}
|
||||
return retId;
|
||||
}
|
||||
export default function useId(id) {
|
||||
// Inner id for accessibility usage. Only work in client side
|
||||
var _React$useState = React.useState(),
|
||||
_React$useState2 = _slicedToArray(_React$useState, 2),
|
||||
innerId = _React$useState2[0],
|
||||
setInnerId = _React$useState2[1];
|
||||
React.useEffect(function () {
|
||||
setInnerId("rc_select_".concat(getUUID()));
|
||||
}, []);
|
||||
return id || innerId;
|
||||
}
|
||||
5
frontend/node_modules/rc-select/es/hooks/useLayoutEffect.d.ts
generated
vendored
Normal file
5
frontend/node_modules/rc-select/es/hooks/useLayoutEffect.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import * as React from 'react';
|
||||
/**
|
||||
* Wrap `React.useLayoutEffect` which will not throw warning message in test env
|
||||
*/
|
||||
export default function useLayoutEffect(effect: React.EffectCallback, deps?: React.DependencyList): void;
|
||||
17
frontend/node_modules/rc-select/es/hooks/useLayoutEffect.js
generated
vendored
Normal file
17
frontend/node_modules/rc-select/es/hooks/useLayoutEffect.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/* eslint-disable react-hooks/rules-of-hooks */
|
||||
import * as React from 'react';
|
||||
import { isBrowserClient } from "../utils/commonUtil";
|
||||
|
||||
/**
|
||||
* Wrap `React.useLayoutEffect` which will not throw warning message in test env
|
||||
*/
|
||||
export default function useLayoutEffect(effect, deps) {
|
||||
// Never happen in test env
|
||||
if (isBrowserClient) {
|
||||
/* istanbul ignore next */
|
||||
React.useLayoutEffect(effect, deps);
|
||||
} else {
|
||||
React.useEffect(effect, deps);
|
||||
}
|
||||
}
|
||||
/* eslint-enable */
|
||||
7
frontend/node_modules/rc-select/es/hooks/useLock.d.ts
generated
vendored
Normal file
7
frontend/node_modules/rc-select/es/hooks/useLock.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* Locker return cached mark.
|
||||
* If set to `true`, will return `true` in a short time even if set `false`.
|
||||
* If set to `false` and then set to `true`, will change to `true`.
|
||||
* And after time duration, it will back to `null` automatically.
|
||||
*/
|
||||
export default function useLock(duration?: number): [() => boolean, (lock: boolean) => void];
|
||||
32
frontend/node_modules/rc-select/es/hooks/useLock.js
generated
vendored
Normal file
32
frontend/node_modules/rc-select/es/hooks/useLock.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
import * as React from 'react';
|
||||
|
||||
/**
|
||||
* Locker return cached mark.
|
||||
* If set to `true`, will return `true` in a short time even if set `false`.
|
||||
* If set to `false` and then set to `true`, will change to `true`.
|
||||
* And after time duration, it will back to `null` automatically.
|
||||
*/
|
||||
export default function useLock() {
|
||||
var duration = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 250;
|
||||
var lockRef = React.useRef(null);
|
||||
var timeoutRef = React.useRef(null);
|
||||
|
||||
// Clean up
|
||||
React.useEffect(function () {
|
||||
return function () {
|
||||
window.clearTimeout(timeoutRef.current);
|
||||
};
|
||||
}, []);
|
||||
function doLock(locked) {
|
||||
if (locked || lockRef.current === null) {
|
||||
lockRef.current = locked;
|
||||
}
|
||||
window.clearTimeout(timeoutRef.current);
|
||||
timeoutRef.current = window.setTimeout(function () {
|
||||
lockRef.current = null;
|
||||
}, duration);
|
||||
}
|
||||
return [function () {
|
||||
return lockRef.current;
|
||||
}, doLock];
|
||||
}
|
||||
12
frontend/node_modules/rc-select/es/hooks/useOptions.d.ts
generated
vendored
Normal file
12
frontend/node_modules/rc-select/es/hooks/useOptions.d.ts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import * as React from 'react';
|
||||
import type { FieldNames, RawValueType } from '../Select';
|
||||
/**
|
||||
* Parse `children` to `options` if `options` is not provided.
|
||||
* Then flatten the `options`.
|
||||
*/
|
||||
declare const useOptions: <OptionType>(options: OptionType[], children: React.ReactNode, fieldNames: FieldNames, optionFilterProp: string, optionLabelProp: string) => {
|
||||
options: OptionType[];
|
||||
valueOptions: Map<RawValueType, OptionType>;
|
||||
labelOptions: Map<React.ReactNode, OptionType>;
|
||||
};
|
||||
export default useOptions;
|
||||
46
frontend/node_modules/rc-select/es/hooks/useOptions.js
generated
vendored
Normal file
46
frontend/node_modules/rc-select/es/hooks/useOptions.js
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
import * as React from 'react';
|
||||
import { convertChildrenToData } from "../utils/legacyUtil";
|
||||
|
||||
/**
|
||||
* Parse `children` to `options` if `options` is not provided.
|
||||
* Then flatten the `options`.
|
||||
*/
|
||||
var useOptions = function useOptions(options, children, fieldNames, optionFilterProp, optionLabelProp) {
|
||||
return React.useMemo(function () {
|
||||
var mergedOptions = options;
|
||||
var childrenAsData = !options;
|
||||
if (childrenAsData) {
|
||||
mergedOptions = convertChildrenToData(children);
|
||||
}
|
||||
var valueOptions = new Map();
|
||||
var labelOptions = new Map();
|
||||
var setLabelOptions = function setLabelOptions(labelOptionsMap, option, key) {
|
||||
if (key && typeof key === 'string') {
|
||||
labelOptionsMap.set(option[key], option);
|
||||
}
|
||||
};
|
||||
var dig = function dig(optionList) {
|
||||
var isChildren = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
||||
// for loop to speed up collection speed
|
||||
for (var i = 0; i < optionList.length; i += 1) {
|
||||
var option = optionList[i];
|
||||
if (!option[fieldNames.options] || isChildren) {
|
||||
valueOptions.set(option[fieldNames.value], option);
|
||||
setLabelOptions(labelOptions, option, fieldNames.label);
|
||||
// https://github.com/ant-design/ant-design/issues/35304
|
||||
setLabelOptions(labelOptions, option, optionFilterProp);
|
||||
setLabelOptions(labelOptions, option, optionLabelProp);
|
||||
} else {
|
||||
dig(option[fieldNames.options], true);
|
||||
}
|
||||
}
|
||||
};
|
||||
dig(mergedOptions);
|
||||
return {
|
||||
options: mergedOptions,
|
||||
valueOptions: valueOptions,
|
||||
labelOptions: labelOptions
|
||||
};
|
||||
}, [options, children, fieldNames, optionFilterProp, optionLabelProp]);
|
||||
};
|
||||
export default useOptions;
|
||||
5
frontend/node_modules/rc-select/es/hooks/useRefFunc.d.ts
generated
vendored
Normal file
5
frontend/node_modules/rc-select/es/hooks/useRefFunc.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* Same as `React.useCallback` but always return a memoized function
|
||||
* but redirect to real function.
|
||||
*/
|
||||
export default function useRefFunc<T extends (...args: any[]) => any>(callback: T): T;
|
||||
14
frontend/node_modules/rc-select/es/hooks/useRefFunc.js
generated
vendored
Normal file
14
frontend/node_modules/rc-select/es/hooks/useRefFunc.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import * as React from 'react';
|
||||
|
||||
/**
|
||||
* Same as `React.useCallback` but always return a memoized function
|
||||
* but redirect to real function.
|
||||
*/
|
||||
export default function useRefFunc(callback) {
|
||||
var funcRef = React.useRef();
|
||||
funcRef.current = callback;
|
||||
var cacheFn = React.useCallback(function () {
|
||||
return funcRef.current.apply(funcRef, arguments);
|
||||
}, []);
|
||||
return cacheFn;
|
||||
}
|
||||
1
frontend/node_modules/rc-select/es/hooks/useSelectTriggerControl.d.ts
generated
vendored
Normal file
1
frontend/node_modules/rc-select/es/hooks/useSelectTriggerControl.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export default function useSelectTriggerControl(elements: () => (HTMLElement | undefined)[], open: boolean, triggerOpen: (open: boolean) => void, customizedTrigger: boolean): void;
|
||||
34
frontend/node_modules/rc-select/es/hooks/useSelectTriggerControl.js
generated
vendored
Normal file
34
frontend/node_modules/rc-select/es/hooks/useSelectTriggerControl.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
import * as React from 'react';
|
||||
export default function useSelectTriggerControl(elements, open, triggerOpen, customizedTrigger) {
|
||||
var propsRef = React.useRef(null);
|
||||
propsRef.current = {
|
||||
open: open,
|
||||
triggerOpen: triggerOpen,
|
||||
customizedTrigger: customizedTrigger
|
||||
};
|
||||
React.useEffect(function () {
|
||||
function onGlobalMouseDown(event) {
|
||||
var _propsRef$current;
|
||||
// If trigger is customized, Trigger will take control of popupVisible
|
||||
if ((_propsRef$current = propsRef.current) !== null && _propsRef$current !== void 0 && _propsRef$current.customizedTrigger) {
|
||||
return;
|
||||
}
|
||||
var target = event.target;
|
||||
if (target.shadowRoot && event.composed) {
|
||||
target = event.composedPath()[0] || target;
|
||||
}
|
||||
if (propsRef.current.open && elements().filter(function (element) {
|
||||
return element;
|
||||
}).every(function (element) {
|
||||
return !element.contains(target) && element !== target;
|
||||
})) {
|
||||
// Should trigger close
|
||||
propsRef.current.triggerOpen(false);
|
||||
}
|
||||
}
|
||||
window.addEventListener('mousedown', onGlobalMouseDown);
|
||||
return function () {
|
||||
return window.removeEventListener('mousedown', onGlobalMouseDown);
|
||||
};
|
||||
}, []);
|
||||
}
|
||||
10
frontend/node_modules/rc-select/es/index.d.ts
generated
vendored
Normal file
10
frontend/node_modules/rc-select/es/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import Select from './Select';
|
||||
import Option from './Option';
|
||||
import OptGroup from './OptGroup';
|
||||
import type { SelectProps } from './Select';
|
||||
import BaseSelect from './BaseSelect';
|
||||
import type { BaseSelectProps, BaseSelectRef, BaseSelectPropsWithoutPrivate } from './BaseSelect';
|
||||
import useBaseProps from './hooks/useBaseProps';
|
||||
export { Option, OptGroup, BaseSelect, useBaseProps };
|
||||
export type { SelectProps, BaseSelectProps, BaseSelectRef, BaseSelectPropsWithoutPrivate };
|
||||
export default Select;
|
||||
7
frontend/node_modules/rc-select/es/index.js
generated
vendored
Normal file
7
frontend/node_modules/rc-select/es/index.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import Select from "./Select";
|
||||
import Option from "./Option";
|
||||
import OptGroup from "./OptGroup";
|
||||
import BaseSelect from "./BaseSelect";
|
||||
import useBaseProps from "./hooks/useBaseProps";
|
||||
export { Option, OptGroup, BaseSelect, useBaseProps };
|
||||
export default Select;
|
||||
22
frontend/node_modules/rc-select/es/interface.d.ts
generated
vendored
Normal file
22
frontend/node_modules/rc-select/es/interface.d.ts
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
import type * as React from 'react';
|
||||
export type RawValueType = string | number;
|
||||
export interface FlattenOptionData<OptionType> {
|
||||
label?: React.ReactNode;
|
||||
data: OptionType;
|
||||
key: React.Key;
|
||||
value?: RawValueType;
|
||||
groupOption?: boolean;
|
||||
group?: boolean;
|
||||
}
|
||||
export interface DisplayValueType {
|
||||
key?: React.Key;
|
||||
value?: RawValueType;
|
||||
label?: React.ReactNode;
|
||||
title?: React.ReactNode;
|
||||
disabled?: boolean;
|
||||
}
|
||||
export type RenderNode = React.ReactNode | ((props: any) => React.ReactNode);
|
||||
export type RenderDOMFunc = (props: any) => HTMLElement;
|
||||
export type Mode = 'multiple' | 'tags' | 'combobox';
|
||||
export type Placement = 'bottomLeft' | 'bottomRight' | 'topLeft' | 'topRight';
|
||||
export type DisplayInfoType = 'add' | 'remove' | 'clear';
|
||||
1
frontend/node_modules/rc-select/es/interface.js
generated
vendored
Normal file
1
frontend/node_modules/rc-select/es/interface.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
1
frontend/node_modules/rc-select/es/utils/__mocks__/platformUtil.d.ts
generated
vendored
Normal file
1
frontend/node_modules/rc-select/es/utils/__mocks__/platformUtil.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare function isPlatformMac(): boolean;
|
||||
3
frontend/node_modules/rc-select/es/utils/__mocks__/platformUtil.js
generated
vendored
Normal file
3
frontend/node_modules/rc-select/es/utils/__mocks__/platformUtil.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export function isPlatformMac() {
|
||||
return true;
|
||||
}
|
||||
9
frontend/node_modules/rc-select/es/utils/commonUtil.d.ts
generated
vendored
Normal file
9
frontend/node_modules/rc-select/es/utils/commonUtil.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import type { DisplayValueType } from '../BaseSelect';
|
||||
export declare function toArray<T>(value: T | T[]): T[];
|
||||
export declare const isClient: HTMLElement;
|
||||
/** Is client side and not jsdom */
|
||||
export declare const isBrowserClient: HTMLElement;
|
||||
export declare function hasValue(value: any): boolean;
|
||||
/** combo mode no value judgment function */
|
||||
export declare function isComboNoValue(value: any): boolean;
|
||||
export declare function getTitle(item: DisplayValueType): string;
|
||||
33
frontend/node_modules/rc-select/es/utils/commonUtil.js
generated
vendored
Normal file
33
frontend/node_modules/rc-select/es/utils/commonUtil.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
||||
export function toArray(value) {
|
||||
if (Array.isArray(value)) {
|
||||
return value;
|
||||
}
|
||||
return value !== undefined ? [value] : [];
|
||||
}
|
||||
export var isClient = typeof window !== 'undefined' && window.document && window.document.documentElement;
|
||||
|
||||
/** Is client side and not jsdom */
|
||||
export var isBrowserClient = process.env.NODE_ENV !== 'test' && isClient;
|
||||
export function hasValue(value) {
|
||||
return value !== undefined && value !== null;
|
||||
}
|
||||
|
||||
/** combo mode no value judgment function */
|
||||
export function isComboNoValue(value) {
|
||||
return !value && value !== 0;
|
||||
}
|
||||
function isTitleType(title) {
|
||||
return ['string', 'number'].includes(_typeof(title));
|
||||
}
|
||||
export function getTitle(item) {
|
||||
var title = undefined;
|
||||
if (item) {
|
||||
if (isTitleType(item.title)) {
|
||||
title = item.title.toString();
|
||||
} else if (isTitleType(item.label)) {
|
||||
title = item.label.toString();
|
||||
}
|
||||
}
|
||||
return title;
|
||||
}
|
||||
2
frontend/node_modules/rc-select/es/utils/keyUtil.d.ts
generated
vendored
Normal file
2
frontend/node_modules/rc-select/es/utils/keyUtil.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/** keyCode Judgment function */
|
||||
export declare function isValidateOpenKey(currentKeyCode: number): boolean;
|
||||
16
frontend/node_modules/rc-select/es/utils/keyUtil.js
generated
vendored
Normal file
16
frontend/node_modules/rc-select/es/utils/keyUtil.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
import KeyCode from "rc-util/es/KeyCode";
|
||||
|
||||
/** keyCode Judgment function */
|
||||
export function isValidateOpenKey(currentKeyCode) {
|
||||
return (
|
||||
// Undefined for Edge bug:
|
||||
// https://github.com/ant-design/ant-design/issues/51292
|
||||
currentKeyCode &&
|
||||
// Other keys
|
||||
![
|
||||
// System function button
|
||||
KeyCode.ESC, KeyCode.SHIFT, KeyCode.BACKSPACE, KeyCode.TAB, KeyCode.WIN_KEY, KeyCode.ALT, KeyCode.META, KeyCode.WIN_KEY_RIGHT, KeyCode.CTRL, KeyCode.SEMICOLON, KeyCode.EQUALS, KeyCode.CAPS_LOCK, KeyCode.CONTEXT_MENU,
|
||||
// F1-F12
|
||||
KeyCode.F1, KeyCode.F2, KeyCode.F3, KeyCode.F4, KeyCode.F5, KeyCode.F6, KeyCode.F7, KeyCode.F8, KeyCode.F9, KeyCode.F10, KeyCode.F11, KeyCode.F12].includes(currentKeyCode)
|
||||
);
|
||||
}
|
||||
3
frontend/node_modules/rc-select/es/utils/legacyUtil.d.ts
generated
vendored
Normal file
3
frontend/node_modules/rc-select/es/utils/legacyUtil.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import * as React from 'react';
|
||||
import type { BaseOptionType, DefaultOptionType } from '../Select';
|
||||
export declare function convertChildrenToData<OptionType extends BaseOptionType = DefaultOptionType>(nodes: React.ReactNode, optionOnly?: boolean): OptionType[];
|
||||
44
frontend/node_modules/rc-select/es/utils/legacyUtil.js
generated
vendored
Normal file
44
frontend/node_modules/rc-select/es/utils/legacyUtil.js
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
||||
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
||||
var _excluded = ["children", "value"],
|
||||
_excluded2 = ["children"];
|
||||
import * as React from 'react';
|
||||
import toArray from "rc-util/es/Children/toArray";
|
||||
function convertNodeToOption(node) {
|
||||
var _ref = node,
|
||||
key = _ref.key,
|
||||
_ref$props = _ref.props,
|
||||
children = _ref$props.children,
|
||||
value = _ref$props.value,
|
||||
restProps = _objectWithoutProperties(_ref$props, _excluded);
|
||||
return _objectSpread({
|
||||
key: key,
|
||||
value: value !== undefined ? value : key,
|
||||
children: children
|
||||
}, restProps);
|
||||
}
|
||||
export function convertChildrenToData(nodes) {
|
||||
var optionOnly = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
||||
return toArray(nodes).map(function (node, index) {
|
||||
if (! /*#__PURE__*/React.isValidElement(node) || !node.type) {
|
||||
return null;
|
||||
}
|
||||
var _ref2 = node,
|
||||
isSelectOptGroup = _ref2.type.isSelectOptGroup,
|
||||
key = _ref2.key,
|
||||
_ref2$props = _ref2.props,
|
||||
children = _ref2$props.children,
|
||||
restProps = _objectWithoutProperties(_ref2$props, _excluded2);
|
||||
if (optionOnly || !isSelectOptGroup) {
|
||||
return convertNodeToOption(node);
|
||||
}
|
||||
return _objectSpread(_objectSpread({
|
||||
key: "__RC_SELECT_GRP__".concat(key === null ? index : key, "__"),
|
||||
label: key
|
||||
}, restProps), {}, {
|
||||
options: convertChildrenToData(children)
|
||||
});
|
||||
}).filter(function (data) {
|
||||
return data;
|
||||
});
|
||||
}
|
||||
1
frontend/node_modules/rc-select/es/utils/platformUtil.d.ts
generated
vendored
Normal file
1
frontend/node_modules/rc-select/es/utils/platformUtil.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare function isPlatformMac(): boolean;
|
||||
4
frontend/node_modules/rc-select/es/utils/platformUtil.js
generated
vendored
Normal file
4
frontend/node_modules/rc-select/es/utils/platformUtil.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
/* istanbul ignore file */
|
||||
export function isPlatformMac() {
|
||||
return /(mac\sos|macintosh)/i.test(navigator.appVersion);
|
||||
}
|
||||
24
frontend/node_modules/rc-select/es/utils/valueUtil.d.ts
generated
vendored
Normal file
24
frontend/node_modules/rc-select/es/utils/valueUtil.d.ts
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
import type { BaseOptionType, DefaultOptionType } from '../Select';
|
||||
import type { FieldNames } from '../Select';
|
||||
import type { FlattenOptionData } from '../interface';
|
||||
export declare function isValidCount(value?: number): boolean;
|
||||
export declare function fillFieldNames(fieldNames: FieldNames | undefined, childrenAsData: boolean): {
|
||||
label: string;
|
||||
value: string;
|
||||
options: string;
|
||||
groupLabel: string;
|
||||
};
|
||||
/**
|
||||
* Flat options into flatten list.
|
||||
* We use `optionOnly` here is aim to avoid user use nested option group.
|
||||
* Here is simply set `key` to the index if not provided.
|
||||
*/
|
||||
export declare function flattenOptions<OptionType extends BaseOptionType = DefaultOptionType>(options: OptionType[], { fieldNames, childrenAsData }?: {
|
||||
fieldNames?: FieldNames;
|
||||
childrenAsData?: boolean;
|
||||
}): FlattenOptionData<OptionType>[];
|
||||
/**
|
||||
* Inject `props` into `option` for legacy usage
|
||||
*/
|
||||
export declare function injectPropsWithOption<T extends object>(option: T): T;
|
||||
export declare const getSeparatedContent: (text: string, tokens: string[], end?: number) => string[];
|
||||
128
frontend/node_modules/rc-select/es/utils/valueUtil.js
generated
vendored
Normal file
128
frontend/node_modules/rc-select/es/utils/valueUtil.js
generated
vendored
Normal file
@@ -0,0 +1,128 @@
|
||||
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
||||
import _toArray from "@babel/runtime/helpers/esm/toArray";
|
||||
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
||||
import warning from "rc-util/es/warning";
|
||||
function getKey(data, index) {
|
||||
var key = data.key;
|
||||
var value;
|
||||
if ('value' in data) {
|
||||
value = data.value;
|
||||
}
|
||||
if (key !== null && key !== undefined) {
|
||||
return key;
|
||||
}
|
||||
if (value !== undefined) {
|
||||
return value;
|
||||
}
|
||||
return "rc-index-key-".concat(index);
|
||||
}
|
||||
export function isValidCount(value) {
|
||||
return typeof value !== 'undefined' && !Number.isNaN(value);
|
||||
}
|
||||
export function fillFieldNames(fieldNames, childrenAsData) {
|
||||
var _ref = fieldNames || {},
|
||||
label = _ref.label,
|
||||
value = _ref.value,
|
||||
options = _ref.options,
|
||||
groupLabel = _ref.groupLabel;
|
||||
var mergedLabel = label || (childrenAsData ? 'children' : 'label');
|
||||
return {
|
||||
label: mergedLabel,
|
||||
value: value || 'value',
|
||||
options: options || 'options',
|
||||
groupLabel: groupLabel || mergedLabel
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Flat options into flatten list.
|
||||
* We use `optionOnly` here is aim to avoid user use nested option group.
|
||||
* Here is simply set `key` to the index if not provided.
|
||||
*/
|
||||
export function flattenOptions(options) {
|
||||
var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
||||
fieldNames = _ref2.fieldNames,
|
||||
childrenAsData = _ref2.childrenAsData;
|
||||
var flattenList = [];
|
||||
var _fillFieldNames = fillFieldNames(fieldNames, false),
|
||||
fieldLabel = _fillFieldNames.label,
|
||||
fieldValue = _fillFieldNames.value,
|
||||
fieldOptions = _fillFieldNames.options,
|
||||
groupLabel = _fillFieldNames.groupLabel;
|
||||
function dig(list, isGroupOption) {
|
||||
if (!Array.isArray(list)) {
|
||||
return;
|
||||
}
|
||||
list.forEach(function (data) {
|
||||
if (isGroupOption || !(fieldOptions in data)) {
|
||||
var value = data[fieldValue];
|
||||
|
||||
// Option
|
||||
flattenList.push({
|
||||
key: getKey(data, flattenList.length),
|
||||
groupOption: isGroupOption,
|
||||
data: data,
|
||||
label: data[fieldLabel],
|
||||
value: value
|
||||
});
|
||||
} else {
|
||||
var grpLabel = data[groupLabel];
|
||||
if (grpLabel === undefined && childrenAsData) {
|
||||
grpLabel = data.label;
|
||||
}
|
||||
|
||||
// Option Group
|
||||
flattenList.push({
|
||||
key: getKey(data, flattenList.length),
|
||||
group: true,
|
||||
data: data,
|
||||
label: grpLabel
|
||||
});
|
||||
dig(data[fieldOptions], true);
|
||||
}
|
||||
});
|
||||
}
|
||||
dig(options, false);
|
||||
return flattenList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inject `props` into `option` for legacy usage
|
||||
*/
|
||||
export function injectPropsWithOption(option) {
|
||||
var newOption = _objectSpread({}, option);
|
||||
if (!('props' in newOption)) {
|
||||
Object.defineProperty(newOption, 'props', {
|
||||
get: function get() {
|
||||
warning(false, 'Return type is option instead of Option instance. Please read value directly instead of reading from `props`.');
|
||||
return newOption;
|
||||
}
|
||||
});
|
||||
}
|
||||
return newOption;
|
||||
}
|
||||
export var getSeparatedContent = function getSeparatedContent(text, tokens, end) {
|
||||
if (!tokens || !tokens.length) {
|
||||
return null;
|
||||
}
|
||||
var match = false;
|
||||
var separate = function separate(str, _ref3) {
|
||||
var _ref4 = _toArray(_ref3),
|
||||
token = _ref4[0],
|
||||
restTokens = _ref4.slice(1);
|
||||
if (!token) {
|
||||
return [str];
|
||||
}
|
||||
var list = str.split(token);
|
||||
match = match || list.length > 1;
|
||||
return list.reduce(function (prevList, unitStr) {
|
||||
return [].concat(_toConsumableArray(prevList), _toConsumableArray(separate(unitStr, restTokens)));
|
||||
}, []).filter(Boolean);
|
||||
};
|
||||
var list = separate(text, tokens);
|
||||
if (match) {
|
||||
return typeof end !== 'undefined' ? list.slice(0, end) : list;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
4
frontend/node_modules/rc-select/es/utils/warningPropsUtil.d.ts
generated
vendored
Normal file
4
frontend/node_modules/rc-select/es/utils/warningPropsUtil.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import type { DefaultOptionType, FieldNames, SelectProps } from '../Select';
|
||||
declare function warningProps(props: SelectProps): void;
|
||||
export declare function warningNullOptions(options: DefaultOptionType[], fieldNames: FieldNames): void;
|
||||
export default warningProps;
|
||||
126
frontend/node_modules/rc-select/es/utils/warningPropsUtil.js
generated
vendored
Normal file
126
frontend/node_modules/rc-select/es/utils/warningPropsUtil.js
generated
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
||||
import toNodeArray from "rc-util/es/Children/toArray";
|
||||
import warning, { noteOnce } from "rc-util/es/warning";
|
||||
import * as React from 'react';
|
||||
import { isMultiple } from "../BaseSelect";
|
||||
import { toArray } from "./commonUtil";
|
||||
import { convertChildrenToData } from "./legacyUtil";
|
||||
function warningProps(props) {
|
||||
var mode = props.mode,
|
||||
options = props.options,
|
||||
children = props.children,
|
||||
backfill = props.backfill,
|
||||
allowClear = props.allowClear,
|
||||
placeholder = props.placeholder,
|
||||
getInputElement = props.getInputElement,
|
||||
showSearch = props.showSearch,
|
||||
onSearch = props.onSearch,
|
||||
defaultOpen = props.defaultOpen,
|
||||
autoFocus = props.autoFocus,
|
||||
labelInValue = props.labelInValue,
|
||||
value = props.value,
|
||||
inputValue = props.inputValue,
|
||||
optionLabelProp = props.optionLabelProp;
|
||||
var multiple = isMultiple(mode);
|
||||
var mergedShowSearch = showSearch !== undefined ? showSearch : multiple || mode === 'combobox';
|
||||
var mergedOptions = options || convertChildrenToData(children);
|
||||
|
||||
// `tags` should not set option as disabled
|
||||
warning(mode !== 'tags' || mergedOptions.every(function (opt) {
|
||||
return !opt.disabled;
|
||||
}), 'Please avoid setting option to disabled in tags mode since user can always type text as tag.');
|
||||
|
||||
// `combobox` & `tags` should option be `string` type
|
||||
if (mode === 'tags' || mode === 'combobox') {
|
||||
var hasNumberValue = mergedOptions.some(function (item) {
|
||||
if (item.options) {
|
||||
return item.options.some(function (opt) {
|
||||
return typeof ('value' in opt ? opt.value : opt.key) === 'number';
|
||||
});
|
||||
}
|
||||
return typeof ('value' in item ? item.value : item.key) === 'number';
|
||||
});
|
||||
warning(!hasNumberValue, '`value` of Option should not use number type when `mode` is `tags` or `combobox`.');
|
||||
}
|
||||
|
||||
// `combobox` should not use `optionLabelProp`
|
||||
warning(mode !== 'combobox' || !optionLabelProp, '`combobox` mode not support `optionLabelProp`. Please set `value` on Option directly.');
|
||||
|
||||
// Only `combobox` support `backfill`
|
||||
warning(mode === 'combobox' || !backfill, '`backfill` only works with `combobox` mode.');
|
||||
|
||||
// Only `combobox` support `getInputElement`
|
||||
warning(mode === 'combobox' || !getInputElement, '`getInputElement` only work with `combobox` mode.');
|
||||
|
||||
// Customize `getInputElement` should not use `allowClear` & `placeholder`
|
||||
noteOnce(mode !== 'combobox' || !getInputElement || !allowClear || !placeholder, 'Customize `getInputElement` should customize clear and placeholder logic instead of configuring `allowClear` and `placeholder`.');
|
||||
|
||||
// `onSearch` should use in `combobox` or `showSearch`
|
||||
if (onSearch && !mergedShowSearch && mode !== 'combobox' && mode !== 'tags') {
|
||||
warning(false, '`onSearch` should work with `showSearch` instead of use alone.');
|
||||
}
|
||||
noteOnce(!defaultOpen || autoFocus, '`defaultOpen` makes Select open without focus which means it will not close by click outside. You can set `autoFocus` if needed.');
|
||||
if (value !== undefined && value !== null) {
|
||||
var values = toArray(value);
|
||||
warning(!labelInValue || values.every(function (val) {
|
||||
return _typeof(val) === 'object' && ('key' in val || 'value' in val);
|
||||
}), '`value` should in shape of `{ value: string | number, label?: ReactNode }` when you set `labelInValue` to `true`');
|
||||
warning(!multiple || Array.isArray(value), '`value` should be array when `mode` is `multiple` or `tags`');
|
||||
}
|
||||
|
||||
// Syntactic sugar should use correct children type
|
||||
if (children) {
|
||||
var invalidateChildType = null;
|
||||
toNodeArray(children).some(function (node) {
|
||||
if (! /*#__PURE__*/React.isValidElement(node) || !node.type) {
|
||||
return false;
|
||||
}
|
||||
var _ref = node,
|
||||
type = _ref.type;
|
||||
if (type.isSelectOption) {
|
||||
return false;
|
||||
}
|
||||
if (type.isSelectOptGroup) {
|
||||
var allChildrenValid = toNodeArray(node.props.children).every(function (subNode) {
|
||||
if (! /*#__PURE__*/React.isValidElement(subNode) || !node.type || subNode.type.isSelectOption) {
|
||||
return true;
|
||||
}
|
||||
invalidateChildType = subNode.type;
|
||||
return false;
|
||||
});
|
||||
if (allChildrenValid) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
invalidateChildType = type;
|
||||
return true;
|
||||
});
|
||||
if (invalidateChildType) {
|
||||
warning(false, "`children` should be `Select.Option` or `Select.OptGroup` instead of `".concat(invalidateChildType.displayName || invalidateChildType.name || invalidateChildType, "`."));
|
||||
}
|
||||
warning(inputValue === undefined, '`inputValue` is deprecated, please use `searchValue` instead.');
|
||||
}
|
||||
}
|
||||
|
||||
// value in Select option should not be null
|
||||
// note: OptGroup has options too
|
||||
export function warningNullOptions(options, fieldNames) {
|
||||
if (options) {
|
||||
var recursiveOptions = function recursiveOptions(optionsList) {
|
||||
var inGroup = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
||||
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 Select options should not be `null`.');
|
||||
return true;
|
||||
}
|
||||
if (!inGroup && Array.isArray(option[fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.options]) && recursiveOptions(option[fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.options], true)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
recursiveOptions(options);
|
||||
}
|
||||
}
|
||||
export default warningProps;
|
||||
Reference in New Issue
Block a user