Latest updates from IceHrmPro
This commit is contained in:
21
web/node_modules/rc-select/es/Selector/Input.d.ts
generated
vendored
Normal file
21
web/node_modules/rc-select/es/Selector/Input.d.ts
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
import React from 'react';
|
||||
declare type InputRef = HTMLInputElement | HTMLTextAreaElement;
|
||||
interface InputProps {
|
||||
prefixCls: string;
|
||||
id: string;
|
||||
inputElement: React.ReactElement;
|
||||
disabled: boolean;
|
||||
autoFocus: boolean;
|
||||
autoComplete: string;
|
||||
editable: boolean;
|
||||
accessibilityIndex: number;
|
||||
value: string;
|
||||
open: boolean;
|
||||
tabIndex: number;
|
||||
onKeyDown: React.KeyboardEventHandler<HTMLInputElement | HTMLTextAreaElement | HTMLElement>;
|
||||
onMouseDown: React.MouseEventHandler<HTMLInputElement | HTMLTextAreaElement | HTMLElement>;
|
||||
onChange: React.ChangeEventHandler<HTMLInputElement | HTMLTextAreaElement | HTMLElement>;
|
||||
onPaste: React.ClipboardEventHandler<HTMLInputElement | HTMLTextAreaElement | HTMLElement>;
|
||||
}
|
||||
declare const RefInput: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<InputRef>>;
|
||||
export default RefInput;
|
||||
82
web/node_modules/rc-select/es/Selector/Input.js
generated
vendored
Normal file
82
web/node_modules/rc-select/es/Selector/Input.js
generated
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
||||
|
||||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
||||
|
||||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
|
||||
import React from 'react';
|
||||
import { composeRef } from "rc-util/es/ref";
|
||||
|
||||
var Input = function Input(_ref, ref) {
|
||||
var prefixCls = _ref.prefixCls,
|
||||
id = _ref.id,
|
||||
inputElement = _ref.inputElement,
|
||||
disabled = _ref.disabled,
|
||||
tabIndex = _ref.tabIndex,
|
||||
autoFocus = _ref.autoFocus,
|
||||
autoComplete = _ref.autoComplete,
|
||||
editable = _ref.editable,
|
||||
accessibilityIndex = _ref.accessibilityIndex,
|
||||
value = _ref.value,
|
||||
_onKeyDown = _ref.onKeyDown,
|
||||
_onMouseDown = _ref.onMouseDown,
|
||||
_onChange = _ref.onChange,
|
||||
onPaste = _ref.onPaste,
|
||||
open = _ref.open;
|
||||
var inputNode = inputElement || React.createElement("input", null);
|
||||
var _inputNode = inputNode,
|
||||
originRef = _inputNode.ref,
|
||||
_inputNode$props = _inputNode.props,
|
||||
onOriginKeyDown = _inputNode$props.onKeyDown,
|
||||
onOriginChange = _inputNode$props.onChange,
|
||||
onOriginMouseDown = _inputNode$props.onMouseDown,
|
||||
style = _inputNode$props.style;
|
||||
inputNode = React.cloneElement(inputNode, {
|
||||
id: id,
|
||||
ref: composeRef(ref, originRef),
|
||||
disabled: disabled,
|
||||
tabIndex: tabIndex,
|
||||
autoComplete: autoComplete || 'off',
|
||||
autoFocus: autoFocus,
|
||||
className: "".concat(prefixCls, "-selection-search-input"),
|
||||
style: _objectSpread({}, style, {
|
||||
opacity: editable ? null : 0
|
||||
}),
|
||||
role: 'combobox',
|
||||
'aria-expanded': open,
|
||||
'aria-haspopup': 'listbox',
|
||||
'aria-owns': "".concat(id, "_list"),
|
||||
'aria-autocomplete': 'list',
|
||||
'aria-controls': "".concat(id, "_list"),
|
||||
'aria-activedescendant': "".concat(id, "_list_").concat(accessibilityIndex),
|
||||
value: editable ? value : '',
|
||||
readOnly: !editable,
|
||||
onKeyDown: function onKeyDown(event) {
|
||||
_onKeyDown(event);
|
||||
|
||||
if (onOriginKeyDown) {
|
||||
onOriginKeyDown(event);
|
||||
}
|
||||
},
|
||||
onMouseDown: function onMouseDown(event) {
|
||||
_onMouseDown(event);
|
||||
|
||||
if (onOriginMouseDown) {
|
||||
onOriginMouseDown(event);
|
||||
}
|
||||
},
|
||||
onChange: function onChange(event) {
|
||||
_onChange(event);
|
||||
|
||||
if (onOriginChange) {
|
||||
onOriginChange(event);
|
||||
}
|
||||
},
|
||||
onPaste: onPaste
|
||||
});
|
||||
return inputNode;
|
||||
};
|
||||
|
||||
var RefInput = React.forwardRef(Input);
|
||||
RefInput.displayName = 'Input';
|
||||
export default RefInput;
|
||||
18
web/node_modules/rc-select/es/Selector/MultipleSelector.d.ts
generated
vendored
Normal file
18
web/node_modules/rc-select/es/Selector/MultipleSelector.d.ts
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
import React from 'react';
|
||||
import { LabelValueType, RawValueType, CustomTagProps } from '../interface/generator';
|
||||
import { RenderNode } from '../interface';
|
||||
import { InnerSelectorProps } from '.';
|
||||
interface SelectorProps extends InnerSelectorProps {
|
||||
removeIcon?: RenderNode;
|
||||
maxTagCount?: number;
|
||||
maxTagTextLength?: number;
|
||||
maxTagPlaceholder?: React.ReactNode | ((omittedValues: LabelValueType[]) => React.ReactNode);
|
||||
tokenSeparators?: string[];
|
||||
tagRender?: (props: CustomTagProps) => React.ReactElement;
|
||||
choiceTransitionName?: string;
|
||||
onSelect: (value: RawValueType, option: {
|
||||
selected: boolean;
|
||||
}) => void;
|
||||
}
|
||||
declare const SelectSelector: React.FC<SelectorProps>;
|
||||
export default SelectSelector;
|
||||
206
web/node_modules/rc-select/es/Selector/MultipleSelector.js
generated
vendored
Normal file
206
web/node_modules/rc-select/es/Selector/MultipleSelector.js
generated
vendored
Normal file
@@ -0,0 +1,206 @@
|
||||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
||||
|
||||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
||||
|
||||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
|
||||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
||||
|
||||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
||||
|
||||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
||||
|
||||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
||||
|
||||
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
||||
|
||||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
||||
|
||||
import React from 'react';
|
||||
import classNames from 'classnames';
|
||||
import CSSMotionList from "rc-animate/es/CSSMotionList";
|
||||
import TransBtn from '../TransBtn';
|
||||
import Input from './Input';
|
||||
import useLayoutEffect from '../hooks/useLayoutEffect';
|
||||
var REST_TAG_KEY = '__RC_SELECT_MAX_REST_COUNT__';
|
||||
|
||||
var SelectSelector = function SelectSelector(_ref) {
|
||||
var id = _ref.id,
|
||||
prefixCls = _ref.prefixCls,
|
||||
values = _ref.values,
|
||||
open = _ref.open,
|
||||
searchValue = _ref.searchValue,
|
||||
inputRef = _ref.inputRef,
|
||||
placeholder = _ref.placeholder,
|
||||
disabled = _ref.disabled,
|
||||
mode = _ref.mode,
|
||||
showSearch = _ref.showSearch,
|
||||
autoFocus = _ref.autoFocus,
|
||||
autoComplete = _ref.autoComplete,
|
||||
accessibilityIndex = _ref.accessibilityIndex,
|
||||
tabIndex = _ref.tabIndex,
|
||||
removeIcon = _ref.removeIcon,
|
||||
choiceTransitionName = _ref.choiceTransitionName,
|
||||
maxTagCount = _ref.maxTagCount,
|
||||
maxTagTextLength = _ref.maxTagTextLength,
|
||||
_ref$maxTagPlaceholde = _ref.maxTagPlaceholder,
|
||||
maxTagPlaceholder = _ref$maxTagPlaceholde === void 0 ? function (omittedValues) {
|
||||
return "+ ".concat(omittedValues.length, " ...");
|
||||
} : _ref$maxTagPlaceholde,
|
||||
tagRender = _ref.tagRender,
|
||||
onSelect = _ref.onSelect,
|
||||
onInputChange = _ref.onInputChange,
|
||||
onInputPaste = _ref.onInputPaste,
|
||||
onInputKeyDown = _ref.onInputKeyDown,
|
||||
onInputMouseDown = _ref.onInputMouseDown;
|
||||
|
||||
var _React$useState = React.useState(false),
|
||||
_React$useState2 = _slicedToArray(_React$useState, 2),
|
||||
motionAppear = _React$useState2[0],
|
||||
setMotionAppear = _React$useState2[1];
|
||||
|
||||
var measureRef = React.useRef(null);
|
||||
|
||||
var _React$useState3 = React.useState(0),
|
||||
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
||||
inputWidth = _React$useState4[0],
|
||||
setInputWidth = _React$useState4[1]; // ===================== Motion ======================
|
||||
|
||||
|
||||
React.useEffect(function () {
|
||||
setMotionAppear(true);
|
||||
}, []); // ===================== Search ======================
|
||||
|
||||
var inputValue = open ? searchValue : '';
|
||||
var inputEditable = mode === 'tags' || open && showSearch; // We measure width and set to the input immediately
|
||||
|
||||
useLayoutEffect(function () {
|
||||
setInputWidth(measureRef.current.scrollWidth);
|
||||
}, [inputValue]); // ==================== Selection ====================
|
||||
|
||||
var displayValues = values; // Cut by `maxTagCount`
|
||||
|
||||
var restCount;
|
||||
|
||||
if (typeof maxTagCount === 'number') {
|
||||
restCount = values.length - maxTagCount;
|
||||
displayValues = values.slice(0, maxTagCount);
|
||||
} // Update by `maxTagTextLength`
|
||||
|
||||
|
||||
if (typeof maxTagTextLength === 'number') {
|
||||
displayValues = displayValues.map(function (_ref2) {
|
||||
var label = _ref2.label,
|
||||
rest = _objectWithoutProperties(_ref2, ["label"]);
|
||||
|
||||
var displayLabel = label;
|
||||
|
||||
if (typeof label === 'string' || typeof label === 'number') {
|
||||
var strLabel = String(displayLabel);
|
||||
|
||||
if (strLabel.length > maxTagTextLength) {
|
||||
displayLabel = "".concat(strLabel.slice(0, maxTagTextLength), "...");
|
||||
}
|
||||
}
|
||||
|
||||
return _objectSpread({}, rest, {
|
||||
label: displayLabel
|
||||
});
|
||||
});
|
||||
} // Fill rest
|
||||
|
||||
|
||||
if (restCount > 0) {
|
||||
displayValues.push({
|
||||
key: REST_TAG_KEY,
|
||||
label: typeof maxTagPlaceholder === 'function' ? maxTagPlaceholder(values.slice(maxTagCount)) : maxTagPlaceholder
|
||||
});
|
||||
}
|
||||
|
||||
var selectionNode = React.createElement(CSSMotionList, {
|
||||
component: false,
|
||||
keys: displayValues,
|
||||
motionName: choiceTransitionName,
|
||||
motionAppear: motionAppear
|
||||
}, function (_ref3) {
|
||||
var key = _ref3.key,
|
||||
label = _ref3.label,
|
||||
value = _ref3.value,
|
||||
itemDisabled = _ref3.disabled,
|
||||
className = _ref3.className,
|
||||
style = _ref3.style;
|
||||
var mergedKey = key || value;
|
||||
var closable = key !== REST_TAG_KEY && !itemDisabled;
|
||||
|
||||
var onMouseDown = function onMouseDown(event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
};
|
||||
|
||||
var onClose = function onClose(event) {
|
||||
if (event) event.stopPropagation();
|
||||
onSelect(value, {
|
||||
selected: false
|
||||
});
|
||||
};
|
||||
|
||||
return typeof tagRender === 'function' ? React.createElement("span", {
|
||||
key: mergedKey,
|
||||
onMouseDown: onMouseDown,
|
||||
className: className,
|
||||
style: style
|
||||
}, tagRender({
|
||||
label: label,
|
||||
value: value,
|
||||
disabled: itemDisabled,
|
||||
closable: closable,
|
||||
onClose: onClose
|
||||
})) : React.createElement("span", {
|
||||
key: mergedKey,
|
||||
className: classNames(className, "".concat(prefixCls, "-selection-item"), _defineProperty({}, "".concat(prefixCls, "-selection-item-disabled"), itemDisabled)),
|
||||
style: style
|
||||
}, React.createElement("span", {
|
||||
className: "".concat(prefixCls, "-selection-item-content")
|
||||
}, label), closable && React.createElement(TransBtn, {
|
||||
className: "".concat(prefixCls, "-selection-item-remove"),
|
||||
onMouseDown: onMouseDown,
|
||||
onClick: onClose,
|
||||
customizeIcon: removeIcon
|
||||
}, "\xD7"));
|
||||
});
|
||||
return React.createElement(React.Fragment, null, selectionNode, React.createElement("span", {
|
||||
className: "".concat(prefixCls, "-selection-search"),
|
||||
style: {
|
||||
width: inputWidth
|
||||
}
|
||||
}, React.createElement(Input, {
|
||||
ref: inputRef,
|
||||
open: open,
|
||||
prefixCls: prefixCls,
|
||||
id: id,
|
||||
inputElement: null,
|
||||
disabled: disabled,
|
||||
autoFocus: autoFocus,
|
||||
autoComplete: autoComplete,
|
||||
editable: inputEditable,
|
||||
accessibilityIndex: accessibilityIndex,
|
||||
value: inputValue,
|
||||
onKeyDown: onInputKeyDown,
|
||||
onMouseDown: onInputMouseDown,
|
||||
onChange: onInputChange,
|
||||
onPaste: onInputPaste,
|
||||
tabIndex: tabIndex
|
||||
}), React.createElement("span", {
|
||||
ref: measureRef,
|
||||
className: "".concat(prefixCls, "-selection-search-mirror"),
|
||||
"aria-hidden": true
|
||||
}, inputValue, "\xA0")), !values.length && !inputValue && React.createElement("span", {
|
||||
className: "".concat(prefixCls, "-selection-placeholder")
|
||||
}, placeholder));
|
||||
};
|
||||
|
||||
export default SelectSelector;
|
||||
9
web/node_modules/rc-select/es/Selector/SingleSelector.d.ts
generated
vendored
Normal file
9
web/node_modules/rc-select/es/Selector/SingleSelector.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import React from 'react';
|
||||
import { InnerSelectorProps } from '.';
|
||||
interface SelectorProps extends InnerSelectorProps {
|
||||
inputElement: React.ReactElement;
|
||||
activeValue: string;
|
||||
backfill?: boolean;
|
||||
}
|
||||
declare const SingleSelector: React.FC<SelectorProps>;
|
||||
export default SingleSelector;
|
||||
67
web/node_modules/rc-select/es/Selector/SingleSelector.js
generated
vendored
Normal file
67
web/node_modules/rc-select/es/Selector/SingleSelector.js
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
import React from 'react';
|
||||
import Input from './Input';
|
||||
|
||||
var SingleSelector = function SingleSelector(_ref) {
|
||||
var inputElement = _ref.inputElement,
|
||||
prefixCls = _ref.prefixCls,
|
||||
id = _ref.id,
|
||||
inputRef = _ref.inputRef,
|
||||
disabled = _ref.disabled,
|
||||
autoFocus = _ref.autoFocus,
|
||||
autoComplete = _ref.autoComplete,
|
||||
accessibilityIndex = _ref.accessibilityIndex,
|
||||
mode = _ref.mode,
|
||||
open = _ref.open,
|
||||
values = _ref.values,
|
||||
placeholder = _ref.placeholder,
|
||||
tabIndex = _ref.tabIndex,
|
||||
showSearch = _ref.showSearch,
|
||||
searchValue = _ref.searchValue,
|
||||
activeValue = _ref.activeValue,
|
||||
onInputKeyDown = _ref.onInputKeyDown,
|
||||
onInputMouseDown = _ref.onInputMouseDown,
|
||||
onInputChange = _ref.onInputChange,
|
||||
onInputPaste = _ref.onInputPaste;
|
||||
var combobox = mode === 'combobox';
|
||||
var inputEditable = combobox || showSearch && open;
|
||||
var item = values[0];
|
||||
|
||||
var getDisplayValue = function getDisplayValue(value) {
|
||||
return value === null ? '' : String(value);
|
||||
};
|
||||
|
||||
var inputValue = searchValue;
|
||||
|
||||
if (combobox) {
|
||||
inputValue = item ? getDisplayValue(item.value) : activeValue || searchValue;
|
||||
} // Not show text when closed expect combobox mode
|
||||
|
||||
|
||||
var hasTextInput = mode !== 'combobox' && !open ? false : !!inputValue;
|
||||
return React.createElement(React.Fragment, null, React.createElement("span", {
|
||||
className: "".concat(prefixCls, "-selection-search")
|
||||
}, React.createElement(Input, {
|
||||
ref: inputRef,
|
||||
prefixCls: prefixCls,
|
||||
id: id,
|
||||
open: open,
|
||||
inputElement: inputElement,
|
||||
disabled: disabled,
|
||||
autoFocus: autoFocus,
|
||||
autoComplete: autoComplete,
|
||||
editable: inputEditable,
|
||||
accessibilityIndex: accessibilityIndex,
|
||||
value: inputValue,
|
||||
onKeyDown: onInputKeyDown,
|
||||
onMouseDown: onInputMouseDown,
|
||||
onChange: onInputChange,
|
||||
onPaste: onInputPaste,
|
||||
tabIndex: tabIndex
|
||||
})), !combobox && item && !hasTextInput && React.createElement("span", {
|
||||
className: "".concat(prefixCls, "-selection-item")
|
||||
}, item.label), !item && !hasTextInput && React.createElement("span", {
|
||||
className: "".concat(prefixCls, "-selection-placeholder")
|
||||
}, placeholder));
|
||||
};
|
||||
|
||||
export default SingleSelector;
|
||||
74
web/node_modules/rc-select/es/Selector/index.d.ts
generated
vendored
Normal file
74
web/node_modules/rc-select/es/Selector/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
/**
|
||||
* 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 * as React from 'react';
|
||||
import { LabelValueType, RawValueType, CustomTagProps } from '../interface/generator';
|
||||
import { RenderNode, Mode } from '../interface';
|
||||
export interface InnerSelectorProps {
|
||||
prefixCls: string;
|
||||
id: string;
|
||||
mode: Mode;
|
||||
inputRef: React.Ref<HTMLInputElement | HTMLTextAreaElement>;
|
||||
placeholder?: React.ReactNode;
|
||||
disabled?: boolean;
|
||||
autoFocus?: boolean;
|
||||
autoComplete?: string;
|
||||
values: LabelValueType[];
|
||||
showSearch?: boolean;
|
||||
searchValue: string;
|
||||
accessibilityIndex: number;
|
||||
open: boolean;
|
||||
tabIndex?: number;
|
||||
onInputKeyDown: React.KeyboardEventHandler<HTMLInputElement | HTMLTextAreaElement>;
|
||||
onInputMouseDown: React.MouseEventHandler<HTMLInputElement | HTMLTextAreaElement>;
|
||||
onInputChange: React.ChangeEventHandler<HTMLInputElement | HTMLTextAreaElement>;
|
||||
onInputPaste: React.ClipboardEventHandler<HTMLInputElement | HTMLTextAreaElement>;
|
||||
}
|
||||
export interface RefSelectorProps {
|
||||
focus: () => void;
|
||||
blur: () => void;
|
||||
}
|
||||
export interface SelectorProps {
|
||||
id: string;
|
||||
prefixCls: string;
|
||||
showSearch?: boolean;
|
||||
open: boolean;
|
||||
/** Display in the Selector value, it's not same as `value` prop */
|
||||
values: LabelValueType[];
|
||||
multiple: boolean;
|
||||
mode: Mode;
|
||||
searchValue: string;
|
||||
activeValue: string;
|
||||
inputElement: JSX.Element;
|
||||
autoFocus?: boolean;
|
||||
accessibilityIndex: number;
|
||||
tabIndex?: number;
|
||||
disabled?: boolean;
|
||||
placeholder?: React.ReactNode;
|
||||
removeIcon?: RenderNode;
|
||||
maxTagCount?: number;
|
||||
maxTagTextLength?: number;
|
||||
maxTagPlaceholder?: React.ReactNode | ((omittedValues: LabelValueType[]) => React.ReactNode);
|
||||
tagRender?: (props: CustomTagProps) => React.ReactElement;
|
||||
choiceTransitionName?: string;
|
||||
onToggleOpen: (open?: boolean) => void;
|
||||
/** `onSearch` returns go next step boolean to check if need do toggle open */
|
||||
onSearch: (searchValue: string) => boolean;
|
||||
onSelect: (value: RawValueType, option: {
|
||||
selected: boolean;
|
||||
}) => void;
|
||||
onInputKeyDown?: React.KeyboardEventHandler<HTMLInputElement | HTMLTextAreaElement>;
|
||||
/**
|
||||
* @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;
|
||||
157
web/node_modules/rc-select/es/Selector/index.js
generated
vendored
Normal file
157
web/node_modules/rc-select/es/Selector/index.js
generated
vendored
Normal file
@@ -0,0 +1,157 @@
|
||||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
||||
|
||||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
||||
|
||||
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
||||
|
||||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
||||
|
||||
/**
|
||||
* 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 * as React from 'react';
|
||||
import KeyCode from "rc-util/es/KeyCode";
|
||||
import MultipleSelector from './MultipleSelector';
|
||||
import SingleSelector from './SingleSelector';
|
||||
import useLock from '../hooks/useLock';
|
||||
|
||||
var Selector = function Selector(props, ref) {
|
||||
var inputRef = React.useRef(null);
|
||||
var prefixCls = props.prefixCls,
|
||||
multiple = props.multiple,
|
||||
open = props.open,
|
||||
mode = props.mode,
|
||||
showSearch = props.showSearch,
|
||||
onSearch = props.onSearch,
|
||||
onToggleOpen = props.onToggleOpen,
|
||||
onInputKeyDown = props.onInputKeyDown,
|
||||
domRef = props.domRef; // ======================= Ref =======================
|
||||
|
||||
React.useImperativeHandle(ref, function () {
|
||||
return {
|
||||
focus: function focus() {
|
||||
inputRef.current.focus();
|
||||
},
|
||||
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;
|
||||
|
||||
if (which === KeyCode.UP || which === KeyCode.DOWN) {
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
if (onInputKeyDown) {
|
||||
onInputKeyDown(event);
|
||||
}
|
||||
|
||||
if (![KeyCode.SHIFT, KeyCode.TAB, KeyCode.BACKSPACE, KeyCode.ESC].includes(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 pasteClearRef = React.useRef(false);
|
||||
|
||||
var triggerOnSearch = function triggerOnSearch(value) {
|
||||
if (onSearch(value) !== false) {
|
||||
onToggleOpen(true);
|
||||
}
|
||||
};
|
||||
|
||||
var onInputChange = function onInputChange(_ref) {
|
||||
var value = _ref.target.value;
|
||||
|
||||
if (pasteClearRef.current) {
|
||||
pasteClearRef.current = false;
|
||||
return;
|
||||
}
|
||||
|
||||
triggerOnSearch(value);
|
||||
};
|
||||
|
||||
var onInputPaste = function onInputPaste(e) {
|
||||
var clipboardData = e.clipboardData;
|
||||
var value = clipboardData.getData('text'); // Block next onChange
|
||||
|
||||
pasteClearRef.current = true;
|
||||
setTimeout(function () {
|
||||
pasteClearRef.current = false;
|
||||
});
|
||||
triggerOnSearch(value);
|
||||
}; // ====================== Focus ======================
|
||||
// Should focus input if click the selector
|
||||
|
||||
|
||||
var onClick = function onClick(_ref2) {
|
||||
var target = _ref2.target;
|
||||
|
||||
if (target !== inputRef.current) {
|
||||
inputRef.current.focus();
|
||||
}
|
||||
};
|
||||
|
||||
var onMouseDown = function onMouseDown(event) {
|
||||
var inputMouseDown = getInputMouseDown();
|
||||
|
||||
if (event.target !== inputRef.current && !inputMouseDown) {
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
if (mode !== 'combobox' && (!showSearch || !inputMouseDown) || !open) {
|
||||
if (open) {
|
||||
onSearch('');
|
||||
}
|
||||
|
||||
onToggleOpen();
|
||||
}
|
||||
}; // ================= Inner Selector ==================
|
||||
|
||||
|
||||
var sharedProps = {
|
||||
inputRef: inputRef,
|
||||
onInputKeyDown: onInternalInputKeyDown,
|
||||
onInputMouseDown: onInternalInputMouseDown,
|
||||
onInputChange: onInputChange,
|
||||
onInputPaste: onInputPaste
|
||||
};
|
||||
var selectNode = multiple ? React.createElement(MultipleSelector, Object.assign({}, props, sharedProps)) : React.createElement(SingleSelector, Object.assign({}, props, sharedProps));
|
||||
return React.createElement("div", {
|
||||
ref: domRef,
|
||||
className: "".concat(prefixCls, "-selector"),
|
||||
onClick: onClick,
|
||||
onMouseDown: onMouseDown
|
||||
}, selectNode);
|
||||
};
|
||||
|
||||
var ForwardSelector = React.forwardRef(Selector);
|
||||
ForwardSelector.displayName = 'Selector';
|
||||
export default ForwardSelector;
|
||||
Reference in New Issue
Block a user