Socket
Socket
Sign inDemoInstall

rc-select

Package Overview
Dependencies
Maintainers
9
Versions
465
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rc-select - npm Package Compare versions

Comparing version 14.1.16 to 14.1.17-0

344

es/BaseSelect.js

@@ -30,61 +30,58 @@ import _typeof from "@babel/runtime/helpers/esm/typeof";

var _customizeRawInputEle, _classNames2;
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,
showArrow = props.showArrow,
inputIcon = props.inputIcon,
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,
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 ==============================
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,
showArrow = props.showArrow,
inputIcon = props.inputIcon,
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,
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) {

@@ -95,14 +92,15 @@ delete domProps[propName];

delete domProps[propName];
}); // ============================= Mobile =============================
});
// ============================= Mobile =============================
var _React$useState = React.useState(false),
_React$useState2 = _slicedToArray(_React$useState, 2),
mobile = _React$useState2[0],
setMobile = _React$useState2[1];
_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 ==============================
}, []);
// ============================== Refs ==============================
var containerRef = React.useRef(null);

@@ -113,14 +111,13 @@ var selectorDomRef = React.useRef(null);

var listRef = React.useRef(null);
/** Used for component focused management */
var _useDelayReset = useDelayReset(),
_useDelayReset2 = _slicedToArray(_useDelayReset, 3),
mockFocused = _useDelayReset2[0],
setMockFocused = _useDelayReset2[1],
cancelSetMockFocused = _useDelayReset2[2]; // =========================== Imperative ===========================
_useDelayReset2 = _slicedToArray(_useDelayReset, 3),
mockFocused = _useDelayReset2[0],
setMockFocused = _useDelayReset2[1],
cancelSetMockFocused = _useDelayReset2[2];
// =========================== Imperative ===========================
React.useImperativeHandle(ref, function () {
var _selectorRef$current, _selectorRef$current2;
return {

@@ -131,48 +128,45 @@ focus: (_selectorRef$current = selectorRef.current) === null || _selectorRef$current === void 0 ? void 0 : _selectorRef$current.focus,

var _listRef$current;
return (_listRef$current = listRef.current) === null || _listRef$current === void 0 ? void 0 : _listRef$current.scrollTo(arg);
}
};
}); // ========================== Search Value ==========================
});
// ========================== 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 ==========================
}, [searchValue, mode, displayValues]);
// ========================== Custom Input ==========================
// Only works in `combobox`
var customizeInputElement = mode === 'combobox' && typeof getInputElement === 'function' && getInputElement() || null;
var customizeInputElement = mode === 'combobox' && typeof getInputElement === 'function' && getInputElement() || null; // Used for customize replacement for `rc-cascader`
// Used for customize replacement for `rc-cascader`
var customizeRawInputElement = typeof getRawInputElement === 'function' && getRawInputElement();
var customizeRawInputRef = useComposeRef(selectorDomRef, customizeRawInputElement === null || customizeRawInputElement === void 0 ? void 0 : (_customizeRawInputEle = customizeRawInputElement.props) === null || _customizeRawInputEle === void 0 ? void 0 : _customizeRawInputEle.ref); // ============================== Open ==============================
var customizeRawInputRef = useComposeRef(selectorDomRef, customizeRawInputElement === null || customizeRawInputElement === void 0 ? void 0 : (_customizeRawInputEle = customizeRawInputElement.props) === null || _customizeRawInputEle === void 0 ? void 0 : _customizeRawInputEle.ref);
// ============================== Open ==============================
var _useMergedState = useMergedState(undefined, {
defaultValue: defaultOpen,
value: open
}),
_useMergedState2 = _slicedToArray(_useMergedState, 2),
innerOpen = _useMergedState2[0],
setInnerOpen = _useMergedState2[1];
defaultValue: defaultOpen,
value: open
}),
_useMergedState2 = _slicedToArray(_useMergedState, 2),
innerOpen = _useMergedState2[0],
setInnerOpen = _useMergedState2[1];
var mergedOpen = innerOpen;
var mergedOpen = innerOpen; // Not trigger `open` in `combobox` when `notFoundContent` is empty
// 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) {

@@ -182,4 +176,5 @@ onDropdownVisibleChange === null || onDropdownVisibleChange === void 0 ? void 0 : onDropdownVisibleChange(nextOpen);

}
}, [disabled, mergedOpen, setInnerOpen, onDropdownVisibleChange]); // ============================= Search =============================
}, [disabled, mergedOpen, setInnerOpen, onDropdownVisibleChange]);
// ============================= Search =============================
var tokenWithEnter = React.useMemo(function () {

@@ -190,19 +185,21 @@ return (tokenSeparators || []).some(function (tokenSeparator) {

}, [tokenSeparators]);
var onInternalSearch = function onInternalSearch(searchText, fromTyping, isCompositing) {
var ret = true;
var newSearchText = searchText;
onActiveValueChange === null || onActiveValueChange === void 0 ? void 0 : onActiveValueChange(null); // Check if match the `tokenSeparators`
onActiveValueChange === null || onActiveValueChange === void 0 ? void 0 : onActiveValueChange(null);
var patchLabels = isCompositing ? null : getSeparatedContent(searchText, tokenSeparators); // Ignore combobox since it's not split-able
// Check if match the `tokenSeparators`
var patchLabels = isCompositing ? null : getSeparatedContent(searchText, tokenSeparators);
// Ignore combobox since it's not split-able
if (mode !== 'combobox' && patchLabels) {
newSearchText = '';
onSearchSplit === null || onSearchSplit === void 0 ? void 0 : onSearchSplit(patchLabels); // Should close when paste finish
onSearchSplit === null || onSearchSplit === void 0 ? void 0 : onSearchSplit(patchLabels);
onToggleOpen(false); // Tell Selector that break next actions
// Should close when paste finish
onToggleOpen(false);
// Tell Selector that break next actions
ret = false;
}
if (onSearch && mergedSearchValue !== newSearchText) {

@@ -213,9 +210,8 @@ onSearch(newSearchText, {

}
return ret;
};
return ret;
}; // Only triggered when menu is closed & mode is tags
// 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) {

@@ -226,9 +222,8 @@ // prevent empty tags from appearing when you click the Enter button

}
onSearch(searchText, {
source: 'submit'
});
}; // Close will clean up single mode search text
};
// Close will clean up single mode search text
React.useEffect(function () {

@@ -238,5 +233,6 @@ if (!mergedOpen && !multiple && mode !== 'combobox') {

}
}, [mergedOpen]); // ============================ Disabled ============================
}, [mergedOpen]);
// ============================ Disabled ============================
// Close dropdown & remove focus state when disabled change
React.useEffect(function () {

@@ -246,8 +242,8 @@ if (innerOpen && disabled) {

}
if (disabled) {
setMockFocused(false);
}
}, [disabled]); // ============================ Keyboard ============================
}, [disabled]);
// ============================ Keyboard ============================
/**

@@ -259,13 +255,11 @@ * We record input value here to check if can press to clean up by backspace

*/
var _useLock = useLock(),
_useLock2 = _slicedToArray(_useLock, 2),
getClearLock = _useLock2[0],
setClearLock = _useLock2[1]; // KeyDown
_useLock2 = _slicedToArray(_useLock, 2),
getClearLock = _useLock2[0],
setClearLock = _useLock2[1];
// KeyDown
var onInternalKeyDown = function onInternalKeyDown(event) {
var clearLock = getClearLock();
var which = event.which;
if (which === KeyCode.ENTER) {

@@ -275,5 +269,5 @@ // Do not submit form when type in the input

event.preventDefault();
} // We only manage open state here, close logic should handle by list component
}
// We only manage open state here, close logic should handle by list component
if (!mergedOpen) {

@@ -283,13 +277,10 @@ onToggleOpen(true);

}
setClearLock(!!mergedSearchValue);
setClearLock(!!mergedSearchValue); // Remove value by `backspace`
// Remove value by `backspace`
if (which === KeyCode.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) {

@@ -301,3 +292,2 @@ cloneDisplayValues.splice(i, 1);

}
if (removedDisplayValue) {

@@ -310,17 +300,13 @@ onDisplayValuesChange(cloneDisplayValues, {

}
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 && listRef.current) {
var _listRef$current2;
(_listRef$current2 = listRef.current).onKeyDown.apply(_listRef$current2, [event].concat(rest));
}
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown.apply(void 0, [event].concat(rest));
}; // KeyUp
};
// KeyUp
var onInternalKeyUp = function onInternalKeyUp(event) {

@@ -330,13 +316,10 @@ for (var _len2 = arguments.length, rest = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {

}
if (mergedOpen && listRef.current) {
var _listRef$current3;
(_listRef$current3 = listRef.current).onKeyUp.apply(_listRef$current3, [event].concat(rest));
}
onKeyUp === null || onKeyUp === void 0 ? void 0 : onKeyUp.apply(void 0, [event].concat(rest));
}; // ============================ Selector ============================
};
// ============================ Selector ============================
var onSelectorRemove = function onSelectorRemove(val) {

@@ -350,18 +333,15 @@ var newValues = displayValues.filter(function (i) {

});
}; // ========================== Focus / Blur ==========================
};
// ========================== 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
}
// `showAction` should handle `focus` if set
if (showAction.includes('focus')) {

@@ -371,6 +351,4 @@ onToggleOpen(true);

}
focusRef.current = true;
};
var onContainerBlur = function onContainerBlur() {

@@ -381,7 +359,5 @@ setMockFocused(false, function () {

});
if (disabled) {
return;
}
if (mergedSearchValue) {

@@ -400,9 +376,8 @@ // `tags` mode should move `searchValue` into values

}
if (onBlur) {
onBlur.apply(void 0, arguments);
}
}; // Give focus back of Select
};
// Give focus back of Select
var activeTimeoutIds = [];

@@ -417,22 +392,17 @@ React.useEffect(function () {

}, []);
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
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 ? void 0 : _selectorRef$current3.focus();

@@ -443,31 +413,24 @@ }

}
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 ? void 0 : onMouseDown.apply(void 0, [event].concat(restArgs));
}; // ============================ Dropdown ============================
};
// ============================ Dropdown ============================
var _React$useState3 = React.useState(null),
_React$useState4 = _slicedToArray(_React$useState3, 2),
containerWidth = _React$useState4[0],
setContainerWidth = _React$useState4[1];
_React$useState4 = _slicedToArray(_React$useState3, 2),
containerWidth = _React$useState4[0],
setContainerWidth = _React$useState4[1];
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
_React$useState6 = _slicedToArray(_React$useState5, 2),
forceUpdate = _React$useState6[1];
// We need force update here since popup dom is render async
function onPopupMouseEnter() {
forceUpdate({});
}
useLayoutEffect(function () {
if (triggerOpen) {
var _containerRef$current;
var newWidth = Math.ceil((_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.offsetWidth);
if (containerWidth !== newWidth && !Number.isNaN(newWidth)) {

@@ -477,6 +440,6 @@ setContainerWidth(newWidth);

}
}, [triggerOpen]); // Used for raw custom input trigger
}, [triggerOpen]);
// Used for raw custom input trigger
var onTriggerVisibleChange;
if (customizeRawInputElement) {

@@ -486,11 +449,11 @@ onTriggerVisibleChange = function onTriggerVisibleChange(newOpen) {

};
} // Close when click on non-select element
}
// 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 =============================
}, triggerOpen, onToggleOpen, !!customizeRawInputElement);
// ============================ Context =============================
var baseSelectContext = React.useMemo(function () {

@@ -506,10 +469,11 @@ return _objectSpread(_objectSpread({}, props), {}, {

});
}, [props, notFoundContent, triggerOpen, mergedOpen, id, mergedShowSearch, multiple, onToggleOpen]); // ==================================================================
}, [props, notFoundContent, triggerOpen, mergedOpen, id, mergedShowSearch, multiple, onToggleOpen]);
// ==================================================================
// == Render ==
// ==================================================================
// ============================= Arrow ==============================
var mergedShowArrow = showArrow !== undefined ? showArrow : loading || !multiple && mode !== 'combobox';
var arrowNode;
if (mergedShowArrow) {

@@ -527,10 +491,8 @@ arrowNode = /*#__PURE__*/React.createElement(TransBtn, {

});
} // ============================= Clear ==============================
}
// ============================= Clear ==============================
var clearNode;
var onClearMouseDown = function onClearMouseDown() {
var _selectorRef$current4;
onClear === null || onClear === void 0 ? void 0 : onClear();

@@ -544,3 +506,2 @@ (_selectorRef$current4 = selectorRef.current) === null || _selectorRef$current4 === void 0 ? void 0 : _selectorRef$current4.focus();

};
if (!disabled && allowClear && (displayValues.length || mergedSearchValue) && !(mode === 'combobox' && mergedSearchValue === '')) {

@@ -552,11 +513,13 @@ clearNode = /*#__PURE__*/React.createElement(TransBtn, {

}, "\xD7");
} // =========================== OptionList ===========================
}
// =========================== OptionList ===========================
var optionList = /*#__PURE__*/React.createElement(OptionList, {
ref: listRef
}); // ============================= Select =============================
});
var mergedClassName = classNames(prefixCls, className, (_classNames2 = {}, _defineProperty(_classNames2, "".concat(prefixCls, "-focused"), mockFocused), _defineProperty(_classNames2, "".concat(prefixCls, "-multiple"), multiple), _defineProperty(_classNames2, "".concat(prefixCls, "-single"), !multiple), _defineProperty(_classNames2, "".concat(prefixCls, "-allow-clear"), allowClear), _defineProperty(_classNames2, "".concat(prefixCls, "-show-arrow"), mergedShowArrow), _defineProperty(_classNames2, "".concat(prefixCls, "-disabled"), disabled), _defineProperty(_classNames2, "".concat(prefixCls, "-loading"), loading), _defineProperty(_classNames2, "".concat(prefixCls, "-open"), mergedOpen), _defineProperty(_classNames2, "".concat(prefixCls, "-customize-input"), customizeInputElement), _defineProperty(_classNames2, "".concat(prefixCls, "-show-search"), mergedShowSearch), _classNames2)); // >>> Selector
// ============================= Select =============================
var mergedClassName = classNames(prefixCls, className, (_classNames2 = {}, _defineProperty(_classNames2, "".concat(prefixCls, "-focused"), mockFocused), _defineProperty(_classNames2, "".concat(prefixCls, "-multiple"), multiple), _defineProperty(_classNames2, "".concat(prefixCls, "-single"), !multiple), _defineProperty(_classNames2, "".concat(prefixCls, "-allow-clear"), allowClear), _defineProperty(_classNames2, "".concat(prefixCls, "-show-arrow"), mergedShowArrow), _defineProperty(_classNames2, "".concat(prefixCls, "-disabled"), disabled), _defineProperty(_classNames2, "".concat(prefixCls, "-loading"), loading), _defineProperty(_classNames2, "".concat(prefixCls, "-open"), mergedOpen), _defineProperty(_classNames2, "".concat(prefixCls, "-customize-input"), customizeInputElement), _defineProperty(_classNames2, "".concat(prefixCls, "-show-search"), mergedShowSearch), _classNames2));
// >>> Selector
var selectorNode = /*#__PURE__*/React.createElement(SelectTrigger, {

@@ -607,6 +570,8 @@ ref: triggerRef,

tokenWithEnter: tokenWithEnter
}))); // >>> Render
})));
var renderNode; // Render raw
// >>> Render
var renderNode;
// Render raw
if (customizeRawInputElement) {

@@ -635,16 +600,15 @@ renderNode = selectorNode;

var label = _ref.label,
value = _ref.value;
value = _ref.value;
return ['number', 'string'].includes(_typeof(label)) ? label : value;
}).join(', '))), selectorNode, arrowNode, clearNode);
}
return /*#__PURE__*/React.createElement(BaseSelectContext.Provider, {
value: baseSelectContext
}, renderNode);
}); // Set display name for dev
});
// Set display name for dev
if (process.env.NODE_ENV !== 'production') {
BaseSelect.displayName = 'BaseSelect';
}
export default BaseSelect;

@@ -5,2 +5,3 @@ /**

*/
import * as React from 'react';

@@ -7,0 +8,0 @@ export var BaseSelectContext = /*#__PURE__*/React.createContext(null);

import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import * as React from 'react';
/**

@@ -14,9 +13,9 @@ * Cache `value` related LabeledValue & options.

var _cacheRef$current = cacheRef.current,
prevValueCache = _cacheRef$current.values,
prevOptionCache = _cacheRef$current.options; // Fill label by cache
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), {}, {

@@ -26,6 +25,6 @@ label: (_prevValueCache$get = prevValueCache.get(item.value)) === null || _prevValueCache$get === void 0 ? void 0 : _prevValueCache$get.label

}
return item;
}); // Refresh cache
});
// Refresh cache
var valueCache = new Map();

@@ -32,0 +31,0 @@ var optionCache = new Map();

import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
import * as React from 'react';
/**

@@ -7,21 +8,15 @@ * Similar with `useLock`, but this hook will always execute last value.

*/
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];
_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) {

@@ -31,3 +26,2 @@ cancelLatest();

setBool(value);
if (callback) {

@@ -38,4 +32,3 @@ callback();

};
return [bool, delaySetBool, cancelLatest];
}

@@ -6,7 +6,5 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";

import { injectPropsWithOption } from "../utils/valueUtil";
function includes(test, search) {
return toArray(test).join('').toUpperCase().includes(search);
}
export default (function (options, fieldNames, searchValue, filterOption, optionFilterProp) {

@@ -17,6 +15,5 @@ return React.useMemo(function () {

}
var fieldOptions = fieldNames.options,
fieldLabel = fieldNames.label,
fieldValue = fieldNames.value;
fieldLabel = fieldNames.label,
fieldValue = fieldNames.value;
var filteredOptions = [];

@@ -29,5 +26,5 @@ var customizeFilter = typeof filterOption === 'function';

return includes(option[optionFilterProp], upperSearch);
} // Auto select `label` or `value` by option type
}
// Auto select `label` or `value` by option type
if (option[fieldOptions]) {

@@ -37,3 +34,2 @@ // hack `fieldLabel` since `OptionGroup` children is not `label`

}
return includes(option[fieldValue], upperSearch);

@@ -51,3 +47,2 @@ };

var matchGroup = filterFunc(searchValue, wrapOption(item));
if (matchGroup) {

@@ -60,3 +55,2 @@ filteredOptions.push(item);

});
if (subOptions.length) {

@@ -66,6 +60,4 @@ filteredOptions.push(_objectSpread(_objectSpread({}, item), {}, _defineProperty({}, fieldOptions, subOptions)));

}
return;
}
if (filterFunc(searchValue, wrapOption(item))) {

@@ -72,0 +64,0 @@ filteredOptions.push(item);

@@ -5,12 +5,12 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";

var uuid = 0;
/** Is client side and not jsdom */
export var isBrowserClient = process.env.NODE_ENV !== 'test' && canUseDom();
export var isBrowserClient = process.env.NODE_ENV !== 'test' && canUseDom();
/** Get unique id for accessibility usage */
export function getUUID() {
var retId; // Test never reach
var retId;
// Test never reach
/* istanbul ignore if */
if (isBrowserClient) {

@@ -22,3 +22,2 @@ retId = uuid;

}
return retId;

@@ -29,6 +28,5 @@ }

var _React$useState = React.useState(),
_React$useState2 = _slicedToArray(_React$useState, 2),
innerId = _React$useState2[0],
setInnerId = _React$useState2[1];
_React$useState2 = _slicedToArray(_React$useState, 2),
innerId = _React$useState2[0],
setInnerId = _React$useState2[1];
React.useEffect(function () {

@@ -35,0 +33,0 @@ setInnerId("rc_select_".concat(getUUID()));

/* 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) {

@@ -9,0 +9,0 @@ // Never happen in test env

import * as React from 'react';
/**

@@ -8,8 +9,8 @@ * Locker return cached mark.

*/
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
var timeoutRef = React.useRef(null);
// Clean up
React.useEffect(function () {

@@ -20,3 +21,2 @@ return function () {

}, []);
function doLock(locked) {

@@ -26,3 +26,2 @@ if (locked || lockRef.current === null) {

}
window.clearTimeout(timeoutRef.current);

@@ -33,3 +32,2 @@ timeoutRef.current = window.setTimeout(function () {

}
return [function () {

@@ -36,0 +34,0 @@ return lockRef.current;

import * as React from 'react';
import { convertChildrenToData } from "../utils/legacyUtil";
/**

@@ -7,3 +8,2 @@ * Parse `children` to `options` if `options` is not provided.

*/
export default function useOptions(options, children, fieldNames, optionFilterProp, optionLabelProp) {

@@ -13,10 +13,7 @@ return React.useMemo(function () {

var childrenAsData = !options;
if (childrenAsData) {
mergedOptions = convertChildrenToData(children);
}
var valueOptions = new Map();
var labelOptions = new Map();
var setLabelOptions = function setLabelOptions(labelOptionsMap, option, key) {

@@ -27,14 +24,11 @@ if (key && typeof key === 'string') {

};
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, fieldNames.label);
// https://github.com/ant-design/ant-design/issues/35304
setLabelOptions(labelOptions, option, optionFilterProp);

@@ -47,3 +41,2 @@ setLabelOptions(labelOptions, option, optionLabelProp);

}
dig(mergedOptions);

@@ -50,0 +43,0 @@ return {

import * as React from 'react';
/**

@@ -6,3 +7,2 @@ * Same as `React.useCallback` but always return a memoized function

*/
export default function useRefFunc(callback) {

@@ -9,0 +9,0 @@ var funcRef = React.useRef();

@@ -12,3 +12,2 @@ import * as React from 'react';

var _propsRef$current;
// If trigger is customized, Trigger will take control of popupVisible

@@ -18,9 +17,6 @@ if ((_propsRef$current = propsRef.current) !== null && _propsRef$current !== void 0 && _propsRef$current.customizedTrigger) {

}
var target = event.target;
if (target.shadowRoot && event.composed) {
target = event.composedPath()[0] || target;
}
if (propsRef.current.open && elements().filter(function (element) {

@@ -35,3 +31,2 @@ return element;

}
window.addEventListener('mousedown', onGlobalMouseDown);

@@ -38,0 +33,0 @@ return function () {

@@ -7,4 +7,3 @@ /* istanbul ignore file */

};
OptGroup.isSelectOptGroup = true;
export default OptGroup;

@@ -7,4 +7,3 @@ /* istanbul ignore file */

};
Option.isSelectOption = true;
export default Option;

@@ -19,6 +19,6 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";

import SelectContext from "./SelectContext";
function isTitleType(content) {
return typeof content === 'string' || typeof content === 'number';
}
/**

@@ -28,28 +28,24 @@ * Using virtual list of option display.

*/
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;
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),
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,
listHeight = _React$useContext.listHeight,
listItemHeight = _React$useContext.listItemHeight;
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,
listHeight = _React$useContext.listHeight,
listItemHeight = _React$useContext.listItemHeight;
var itemPrefixCls = "".concat(prefixCls, "-item");

@@ -60,10 +56,9 @@ var memoFlattenOptions = useMemo(function () {

return next[0] && prev[1] !== next[1];
}); // =========================== List ===========================
});
// =========================== List ===========================
var listRef = React.useRef(null);
var onListMouseDown = function onListMouseDown(event) {
event.preventDefault();
};
var scrollIntoView = function scrollIntoView(args) {

@@ -75,15 +70,13 @@ if (listRef.current) {

}
}; // ========================== Active ==========================
};
// ========================== 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 _memoFlattenOptions$c = memoFlattenOptions[current],
group = _memoFlattenOptions$c.group,
data = _memoFlattenOptions$c.data;
group = _memoFlattenOptions$c.group,
data = _memoFlattenOptions$c.data;
if (!group && !data.disabled) {

@@ -93,13 +86,10 @@ 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];
return getEnabledActiveIndex(0);
}),
_React$useState2 = _slicedToArray(_React$useState, 2),
activeIndex = _React$useState2[0],
setActiveIndex = _React$useState2[1];
var setActive = function setActive(index) {

@@ -110,6 +100,6 @@ var fromKeyboard = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;

source: fromKeyboard ? 'keyboard' : 'mouse'
}; // Trigger active event
};
// Trigger active event
var flattenItem = memoFlattenOptions[index];
if (!flattenItem) {

@@ -119,15 +109,16 @@ onActiveValue(null, -1, info);

}
onActiveValue(flattenItem.value, index, info);
}; // Auto active first item when list length or searchValue changed
};
// 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/34975
}, [memoFlattenOptions.length, searchValue]);
// https://github.com/ant-design/ant-design/issues/34975
var isSelected = React.useCallback(function (value) {
return rawValues.has(value) && mode !== 'combobox';
}, [mode, _toConsumableArray(rawValues).toString(), rawValues.size]); // Auto scroll to item position in single mode
}, [mode, _toConsumableArray(rawValues).toString(), rawValues.size]);
// Auto scroll to item position in single mode
useEffect(function () {

@@ -146,3 +137,2 @@ /**

});
if (index !== -1) {

@@ -153,15 +143,15 @@ setActive(index);

}
}); // Force trigger scrollbar visible when open
});
// Force trigger scrollbar visible when open
if (open) {
var _listRef$current;
(_listRef$current = listRef.current) === null || _listRef$current === void 0 ? void 0 : _listRef$current.scrollTo(undefined);
}
return function () {
return clearTimeout(timeoutId);
};
}, [open, searchValue]); // ========================== Values ==========================
}, [open, searchValue]);
// ========================== Values ==========================
var onSelectValue = function onSelectValue(value) {

@@ -172,11 +162,11 @@ if (value !== undefined) {

});
} // Single mode should always close by select
}
// Single mode should always close by select
if (!multiple) {
toggleOpen(false);
}
}; // ========================= Keyboard =========================
};
// ========================= Keyboard =========================
React.useImperativeHandle(ref, function () {

@@ -186,4 +176,3 @@ return {

var which = event.which,
ctrlKey = event.ctrlKey;
ctrlKey = event.ctrlKey;
switch (which) {

@@ -197,3 +186,2 @@ // >>> Arrow keys & ctrl + n/p on Mac

var offset = 0;
if (which === KeyCode.UP) {

@@ -210,3 +198,2 @@ offset = -1;

}
if (offset !== 0) {

@@ -217,7 +204,6 @@ var nextActiveIndex = getEnabledActiveIndex(activeIndex + offset, offset);

}
break;
}
// >>> Select
case KeyCode.ENTER:

@@ -227,3 +213,2 @@ {

var item = memoFlattenOptions[activeIndex];
if (item && !item.data.disabled) {

@@ -234,15 +219,12 @@ onSelectValue(item.value);

}
if (open) {
event.preventDefault();
}
break;
}
// >>> Close
case KeyCode.ESC:
{
toggleOpen(false);
if (open) {

@@ -259,4 +241,5 @@ event.stopPropagation();

};
}); // ========================== Render ==========================
});
// ========================== Render ==========================
if (memoFlattenOptions.length === 0) {

@@ -270,11 +253,8 @@ return /*#__PURE__*/React.createElement("div", {

}
var omitFieldNameList = Object.keys(fieldNames).map(function (key) {
return fieldNames[key];
});
var getLabel = function getLabel(item) {
return item.label;
};
var renderItem = function renderItem(index) {

@@ -297,3 +277,2 @@ var item = memoFlattenOptions[index];

};
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {

@@ -319,13 +298,12 @@ role: "listbox",

var _classNames;
var group = item.group,
groupOption = item.groupOption,
data = item.data,
label = item.label,
value = item.value;
var key = data.key; // 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;

@@ -337,12 +315,11 @@ return /*#__PURE__*/React.createElement("div", {

}
var disabled = data.disabled,
title = data.title,
children = data.children,
style = data.style,
className = data.className,
otherProps = _objectWithoutProperties(data, _excluded);
title = data.title,
children = data.children,
style = data.style,
className = data.className,
otherProps = _objectWithoutProperties(data, _excluded);
var passedProps = omit(otherProps, omitFieldNameList);
var passedProps = omit(otherProps, omitFieldNameList); // Option
// Option
var selected = isSelected(value);

@@ -352,12 +329,11 @@ var optionPrefixCls = "".concat(itemPrefixCls, "-option");

var mergedLabel = getLabel(item);
var iconVisible = !menuItemSelectedIcon || typeof menuItemSelectedIcon === 'function' || selected; // https://github.com/ant-design/ant-design/issues/34145
var iconVisible = !menuItemSelectedIcon || typeof menuItemSelectedIcon === 'function' || selected;
var content = typeof mergedLabel === 'number' ? mergedLabel : mergedLabel || value; // https://github.com/ant-design/ant-design/issues/26717
// 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), {

@@ -371,3 +347,2 @@ "aria-selected": selected,

}
setActive(itemIndex);

@@ -392,5 +367,4 @@ },

};
var RefOptionList = /*#__PURE__*/React.forwardRef(OptionList);
RefOptionList.displayName = 'OptionList';
export default RefOptionList;

@@ -9,3 +9,2 @@ import _extends from "@babel/runtime/helpers/esm/extends";

var _excluded = ["id", "mode", "prefixCls", "backfill", "fieldNames", "inputValue", "searchValue", "onSearch", "autoClearSearchValue", "onSelect", "onDeselect", "dropdownMatchSelectWidth", "filterOption", "filterSort", "optionFilterProp", "optionLabelProp", "options", "children", "defaultActiveFirstOption", "menuItemSelectedIcon", "virtual", "listHeight", "listItemHeight", "value", "defaultValue", "labelInValue", "onChange"];
/**

@@ -41,2 +40,3 @@ * To match accessibility requirement, we always provide an input in the component.

*/
import useMergedState from "rc-util/es/hooks/useMergedState";

@@ -59,42 +59,39 @@ import warning from "rc-util/es/warning";

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,
children = props.children,
defaultActiveFirstOption = props.defaultActiveFirstOption,
menuItemSelectedIcon = props.menuItemSelectedIcon,
virtual = props.virtual,
_props$listHeight = props.listHeight,
listHeight = _props$listHeight === void 0 ? 200 : _props$listHeight,
_props$listItemHeight = props.listItemHeight,
listItemHeight = _props$listItemHeight === void 0 ? 20 : _props$listItemHeight,
value = props.value,
defaultValue = props.defaultValue,
labelInValue = props.labelInValue,
onChange = props.onChange,
restProps = _objectWithoutProperties(props, _excluded);
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,
children = props.children,
defaultActiveFirstOption = props.defaultActiveFirstOption,
menuItemSelectedIcon = props.menuItemSelectedIcon,
virtual = props.virtual,
_props$listHeight = props.listHeight,
listHeight = _props$listHeight === void 0 ? 200 : _props$listHeight,
_props$listItemHeight = props.listItemHeight,
listItemHeight = _props$listItemHeight === void 0 ? 20 : _props$listItemHeight,
value = props.value,
defaultValue = props.defaultValue,
labelInValue = props.labelInValue,
onChange = props.onChange,
restProps = _objectWithoutProperties(props, _excluded);
var mergedId = useId(id);

@@ -107,35 +104,37 @@ var multiple = isMultiple(mode);

}
return filterOption;
}, [filterOption, mode]); // ========================= FieldNames =========================
}, [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.
}, /* 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 ===========================
/* 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 ===========================
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 =========================
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
var valueList = toArray(draftValues);
// Convert to labelInValue type
return valueList.map(function (val) {

@@ -146,4 +145,5 @@ var rawValue;

var rawDisabled;
var rawTitle; // Fill label & value
var rawTitle;
// Fill label & value
if (isRawValue(val)) {

@@ -153,3 +153,2 @@ rawValue = val;

var _val$value;
rawKey = val.key;

@@ -159,8 +158,5 @@ rawLabel = val.label;

}
var option = valueOptions.get(rawValue);
if (option) {
var _option$key;
// Fill missing props

@@ -170,7 +166,7 @@ if (rawLabel === undefined) rawLabel = option === null || option === void 0 ? void 0 : option[optionLabelProp || mergedFieldNames.label];

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
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 && optionLabel !== rawLabel) {

@@ -181,3 +177,2 @@ warning(false, '`label` of `value` is not same as `label` in Select options.');

}
return {

@@ -191,29 +186,29 @@ label: rawLabel,

});
}, [mergedFieldNames, optionLabelProp, valueOptions]); // =========================== Values ===========================
}, [mergedFieldNames, optionLabelProp, valueOptions]);
// =========================== Values ===========================
var _useMergedState3 = useMergedState(defaultValue, {
value: value
}),
_useMergedState4 = _slicedToArray(_useMergedState3, 2),
internalValue = _useMergedState4[0],
setInternalValue = _useMergedState4[1]; // Merged value with LabelValueType
value: value
}),
_useMergedState4 = _slicedToArray(_useMergedState3, 2),
internalValue = _useMergedState4[0],
setInternalValue = _useMergedState4[1];
// Merged value with LabelValueType
var rawLabeledValues = React.useMemo(function () {
var _values$;
var values = convert2LabelValues(internalValue);
var values = convert2LabelValues(internalValue); // combobox no need save value when it's no value
// combobox no need save value when it's no value
if (mode === 'combobox' && !((_values$ = values[0]) !== null && _values$ !== void 0 && _values$.value)) {
return [];
}
return values;
}, [internalValue, convert2LabelValues, mode]); // Fill label with cache to avoid option remove
}, [internalValue, convert2LabelValues, mode]);
// Fill label with cache to avoid option remove
var _useCache = useCache(rawLabeledValues, valueOptions),
_useCache2 = _slicedToArray(_useCache, 2),
mergedValues = _useCache2[0],
getMixedOption = _useCache2[1];
_useCache2 = _slicedToArray(_useCache, 2),
mergedValues = _useCache2[0],
getMixedOption = _useCache2[1];
var displayValues = React.useMemo(function () {

@@ -224,3 +219,2 @@ // `null` need show as placeholder instead

var firstValue = mergedValues[0];
if (firstValue.value === null && (firstValue.label === null || firstValue.label === undefined)) {

@@ -230,6 +224,4 @@ return [];

}
return mergedValues.map(function (item) {
var _item$label;
return _objectSpread(_objectSpread({}, item), {}, {

@@ -240,4 +232,4 @@ label: (_item$label = item.label) !== null && _item$label !== void 0 ? _item$label : item.value

}, [mode, mergedValues]);
/** Convert `displayValues` to raw value type set */
var rawValues = React.useMemo(function () {

@@ -251,30 +243,30 @@ return new Set(mergedValues.map(function (val) {

var _mergedValues$;
var strValue = (_mergedValues$ = mergedValues[0]) === null || _mergedValues$ === void 0 ? void 0 : _mergedValues$.value;
setSearchValue(hasValue(strValue) ? String(strValue) : '');
}
}, [mergedValues]); // ======================= Display Option =======================
}, [mergedValues]);
// ======================= Display Option =======================
// Create a placeholder item if not exist in `options`
var createTagOption = useRefFunc(function (val, label) {
var _ref;
var mergedLabel = label !== null && label !== void 0 ? label : val;
return _ref = {}, _defineProperty(_ref, mergedFieldNames.value, val), _defineProperty(_ref, mergedFieldNames.label, mergedLabel), _ref;
}); // Fill tag as option if mode is `tags`
});
// Fill tag as option if mode is `tags`
var filledTagOptions = React.useMemo(function () {
if (mode !== 'tags') {
return mergedOptions;
} // >>> Tag mode
}
// >>> Tag mode
var cloneOptions = _toConsumableArray(mergedOptions);
var cloneOptions = _toConsumableArray(mergedOptions); // Check if value exist in options (include new patch item)
// Check if value exist in options (include new patch item)
var existOptions = function existOptions(val) {
return valueOptions.has(val);
}; // Fill current value as option
};
// Fill current value as option
_toConsumableArray(mergedValues).sort(function (a, b) {

@@ -284,3 +276,2 @@ return a.value < b.value ? -1 : 1;

var val = item.value;
if (!existOptions(val)) {

@@ -290,7 +281,7 @@ 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 filteredOptions = useFilterOptions(filledTagOptions, mergedFieldNames, mergedSearchValue, mergedFilterOption, optionFilterProp);
// Fill options with search value if needed
var filledSearchOptions = React.useMemo(function () {

@@ -301,5 +292,5 @@ if (mode !== 'tags' || !mergedSearchValue || filteredOptions.some(function (item) {

return filteredOptions;
} // Fill search value as option
}
// Fill search value as option
return [createTagOption(mergedSearchValue)].concat(_toConsumableArray(filteredOptions));

@@ -311,3 +302,2 @@ }, [createTagOption, optionFilterProp, mode, filteredOptions, mergedSearchValue]);

}
return _toConsumableArray(filledSearchOptions).sort(function (a, b) {

@@ -322,12 +312,12 @@ return filterSort(a, b);

});
}, [orderedFilteredOptions, mergedFieldNames, childrenAsData]); // =========================== Change ===========================
}, [orderedFilteredOptions, mergedFieldNames, childrenAsData]);
// =========================== Change ===========================
var triggerChange = function triggerChange(values) {
var labeledValues = convert2LabelValues(values);
setInternalValue(labeledValues);
if (onChange && ( // Trigger event only when value changed
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);

@@ -341,36 +331,34 @@ }))) {

});
onChange( // Value
multiple ? returnValues : returnValues[0], // Option
onChange(
// Value
multiple ? returnValues : returnValues[0],
// Option
multiple ? returnOptions : returnOptions[0]);
}
}; // ======================= Accessibility ========================
};
// ======================= Accessibility ========================
var _React$useState = React.useState(null),
_React$useState2 = _slicedToArray(_React$useState, 2),
activeValue = _React$useState2[0],
setActiveValue = _React$useState2[1];
_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];
_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 _ref2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
_ref2$source = _ref2.source,
source = _ref2$source === void 0 ? 'keyboard' : _ref2$source;
_ref2$source = _ref2.source,
source = _ref2$source === void 0 ? 'keyboard' : _ref2$source;
setAccessibilityIndex(index);
if (backfill && mode === 'combobox' && active !== null && source === 'keyboard') {
setActiveValue(String(active));
}
}, [backfill, mode]); // ========================= OptionList =========================
}, [backfill, mode]);
// ========================= OptionList =========================
var triggerSelect = function triggerSelect(val, selected, type) {
var getSelectEnt = function getSelectEnt() {
var _option$key2;
var option = getMixedOption(val);

@@ -383,26 +371,23 @@ return [labelInValue ? {

};
if (selected && onSelect) {
var _getSelectEnt = getSelectEnt(),
_getSelectEnt2 = _slicedToArray(_getSelectEnt, 2),
wrappedValue = _getSelectEnt2[0],
_option = _getSelectEnt2[1];
_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];
_getSelectEnt4 = _slicedToArray(_getSelectEnt3, 2),
_wrappedValue = _getSelectEnt4[0],
_option2 = _getSelectEnt4[1];
onDeselect(_wrappedValue, _option2);
}
}; // Used for OptionList selection
};
// Used for OptionList selection
var onInternalSelect = useRefFunc(function (val, info) {
var cloneValues; // Single mode always trigger select only with option list
var cloneValues;
// Single mode always trigger select only with option list
var mergedSelect = multiple ? info.selected : true;
if (mergedSelect) {

@@ -415,6 +400,6 @@ cloneValues = multiple ? [].concat(_toConsumableArray(mergedValues), [val]) : [val];

}
triggerChange(cloneValues);
triggerSelect(val, mergedSelect); // Clean search value if single or configured
triggerSelect(val, mergedSelect);
// Clean search value if single or configured
if (mode === 'combobox') {

@@ -427,10 +412,10 @@ // setSearchValue(String(val));

}
}); // ======================= Display Change =======================
});
// ======================= Display Change =======================
// BaseSelect display values change
var onDisplayValuesChange = function onDisplayValuesChange(nextValues, info) {
triggerChange(nextValues);
var type = info.type,
values = info.values;
values = info.values;
if (type === 'remove' || type === 'clear') {

@@ -441,12 +426,13 @@ values.forEach(function (item) {

}
}; // =========================== Search ===========================
};
// =========================== Search ===========================
var onInternalSearch = function onInternalSearch(searchText, info) {
setSearchValue(searchText);
setActiveValue(null); // [Submit] Tag mode should flush input
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
var formatted = (searchText || '').trim();
// prevent empty tags from appearing when you click the Enter button
if (formatted) {

@@ -458,6 +444,4 @@ var newRawValues = Array.from(new Set([].concat(_toConsumableArray(rawValues), [formatted])));

}
return;
}
if (info.source !== 'blur') {

@@ -467,10 +451,7 @@ if (mode === 'combobox') {

}
onSearch === null || onSearch === void 0 ? void 0 : onSearch(searchText);
}
};
var onInternalSearchSplit = function onInternalSearchSplit(words) {
var patchValues = words;
if (mode !== 'tags') {

@@ -484,3 +465,2 @@ patchValues = words.map(function (word) {

}
var newRawValues = Array.from(new Set([].concat(_toConsumableArray(rawValues), _toConsumableArray(patchValues))));

@@ -491,5 +471,5 @@ triggerChange(newRawValues);

});
}; // ========================== Context ===========================
};
// ========================== Context ===========================
var selectContext = React.useMemo(function () {

@@ -510,12 +490,13 @@ var realVirtual = virtual !== false && dropdownMatchSelectWidth !== false;

});
}, [parsedOptions, displayOptions, onActiveValue, mergedDefaultActiveFirstOption, onInternalSelect, menuItemSelectedIcon, rawValues, mergedFieldNames, virtual, dropdownMatchSelectWidth, listHeight, listItemHeight, childrenAsData]); // ========================== Warning ===========================
}, [parsedOptions, displayOptions, onActiveValue, mergedDefaultActiveFirstOption, onInternalSelect, menuItemSelectedIcon, rawValues, mergedFieldNames, virtual, dropdownMatchSelectWidth, listHeight, listItemHeight, childrenAsData]);
// ========================== Warning ===========================
if (process.env.NODE_ENV !== 'production') {
warningProps(props);
warningNullOptions(mergedOptions, mergedFieldNames);
} // ==============================================================
}
// ==============================================================
// == Render ==
// ==============================================================
return /*#__PURE__*/React.createElement(SelectContext.Provider, {

@@ -529,6 +510,8 @@ value: selectContext

omitDomProps: OMIT_DOM_PROPS,
mode: mode // >>> Values
mode: mode
// >>> Values
,
displayValues: displayValues,
onDisplayValuesChange: onDisplayValuesChange // >>> Search
onDisplayValuesChange: onDisplayValuesChange
// >>> Search
,

@@ -539,6 +522,8 @@ searchValue: mergedSearchValue,

onSearchSplit: onInternalSearchSplit,
dropdownMatchSelectWidth: dropdownMatchSelectWidth // >>> OptionList
dropdownMatchSelectWidth: dropdownMatchSelectWidth
// >>> OptionList
,
OptionList: OptionList,
emptyOptions: !displayOptions.length // >>> Accessibility
emptyOptions: !displayOptions.length
// >>> Accessibility
,

@@ -549,7 +534,5 @@ activeValue: activeValue,

});
if (process.env.NODE_ENV !== 'production') {
Select.displayName = 'Select';
}
var TypedSelect = Select;

@@ -556,0 +539,0 @@ TypedSelect.Option = Option;

import _extends from "@babel/runtime/helpers/esm/extends";
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
/**

@@ -13,2 +12,3 @@ * Cursor rule:

*/
import * as React from 'react';

@@ -21,3 +21,2 @@ import { useRef } from 'react';

import { isValidateOpenKey } from "../utils/keyUtil";
var Selector = function Selector(props, ref) {

@@ -27,13 +26,14 @@ var inputRef = useRef(null);

var prefixCls = props.prefixCls,
open = props.open,
mode = props.mode,
showSearch = props.showSearch,
tokenWithEnter = props.tokenWithEnter,
autoClearSearchValue = props.autoClearSearchValue,
onSearch = props.onSearch,
onSearchSubmit = props.onSearchSubmit,
onToggleOpen = props.onToggleOpen,
onInputKeyDown = props.onInputKeyDown,
domRef = props.domRef; // ======================= Ref =======================
open = props.open,
mode = props.mode,
showSearch = props.showSearch,
tokenWithEnter = props.tokenWithEnter,
autoClearSearchValue = props.autoClearSearchValue,
onSearch = props.onSearch,
onSearchSubmit = props.onSearchSubmit,
onToggleOpen = props.onToggleOpen,
onInputKeyDown = props.onInputKeyDown,
domRef = props.domRef;
// ======================= Ref =======================
React.useImperativeHandle(ref, function () {

@@ -48,20 +48,17 @@ return {

};
}); // ====================== Input ======================
});
// ====================== Input ======================
var _useLock = useLock(0),
_useLock2 = _slicedToArray(_useLock, 2),
getInputMouseDown = _useLock2[0],
setInputMouseDown = _useLock2[1];
_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 (which === KeyCode.ENTER && mode === 'tags' && !compositionStatusRef.current && !open) {

@@ -72,3 +69,2 @@ // When menu isn't open, OptionList won't trigger a value change

}
if (isValidateOpenKey(which)) {

@@ -78,2 +74,3 @@ onToggleOpen(true);

};
/**

@@ -83,11 +80,8 @@ * We can not use `findDOMNode` sine it will get warning,

*/
var onInternalInputMouseDown = function onInternalInputMouseDown() {
setInputMouseDown(true);
}; // When paste come, ignore next onChange
};
// When paste come, ignore next onChange
var pastedTextRef = useRef(null);
var triggerOnSearch = function triggerOnSearch(value) {

@@ -98,10 +92,9 @@ if (onSearch(value, true, compositionStatusRef.current) !== false) {

};
var onInputCompositionStart = function onInputCompositionStart() {
compositionStatusRef.current = true;
};
var onInputCompositionEnd = function onInputCompositionEnd(e) {
compositionStatusRef.current = false; // Trigger search again to support `tokenSeparators` with typewriting
compositionStatusRef.current = false;
// Trigger search again to support `tokenSeparators` with typewriting
if (mode !== 'combobox') {

@@ -111,6 +104,6 @@ triggerOnSearch(e.target.value);

};
var onInputChange = function onInputChange(event) {
var value = event.target.value; // Pasted text should replace back to origin content
var value = event.target.value;
// Pasted text should replace back to origin content
if (tokenWithEnter && pastedTextRef.current && /[\r\n]/.test(pastedTextRef.current)) {

@@ -121,7 +114,5 @@ // CRLF will be treated as a single space for input element

}
pastedTextRef.current = null;
triggerOnSearch(value);
};
var onInputPaste = function onInputPaste(e) {

@@ -132,10 +123,7 @@ var clipboardData = e.clipboardData;

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

@@ -150,11 +138,10 @@ setTimeout(function () {

};
var onMouseDown = function onMouseDown(event) {
var inputMouseDown = getInputMouseDown();
var onMouseDown = function onMouseDown(event) {
var inputMouseDown = getInputMouseDown(); // when mode is combobox, don't prevent default behavior
// when mode is combobox, don't prevent default behavior
// https://github.com/ant-design/ant-design/issues/37320
if (event.target !== inputRef.current && !inputMouseDown && mode !== 'combobox') {
event.preventDefault();
}
if (mode !== 'combobox' && (!showSearch || !inputMouseDown) || !open) {

@@ -164,8 +151,7 @@ if (open && autoClearSearchValue !== false) {

}
onToggleOpen();
}
}; // ================= Inner Selector ==================
};
// ================= Inner Selector ==================
var sharedProps = {

@@ -188,5 +174,4 @@ inputRef: inputRef,

};
var ForwardSelector = /*#__PURE__*/React.forwardRef(Selector);
ForwardSelector.displayName = 'Selector';
export default ForwardSelector;

@@ -6,35 +6,33 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";

import { warning } from "rc-util/es/warning";
var Input = function Input(_ref, ref) {
var _inputNode2, _inputNode2$props;
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,
activeDescendantId = _ref.activeDescendantId,
value = _ref.value,
maxLength = _ref.maxLength,
_onKeyDown = _ref.onKeyDown,
_onMouseDown = _ref.onMouseDown,
_onChange = _ref.onChange,
onPaste = _ref.onPaste,
_onCompositionStart = _ref.onCompositionStart,
_onCompositionEnd = _ref.onCompositionEnd,
open = _ref.open,
attrs = _ref.attrs;
id = _ref.id,
inputElement = _ref.inputElement,
disabled = _ref.disabled,
tabIndex = _ref.tabIndex,
autoFocus = _ref.autoFocus,
autoComplete = _ref.autoComplete,
editable = _ref.editable,
activeDescendantId = _ref.activeDescendantId,
value = _ref.value,
maxLength = _ref.maxLength,
_onKeyDown = _ref.onKeyDown,
_onMouseDown = _ref.onMouseDown,
_onChange = _ref.onChange,
onPaste = _ref.onPaste,
_onCompositionStart = _ref.onCompositionStart,
_onCompositionEnd = _ref.onCompositionEnd,
open = _ref.open,
attrs = _ref.attrs;
var inputNode = inputElement || /*#__PURE__*/React.createElement("input", null);
var _inputNode = inputNode,
originRef = _inputNode.ref,
originProps = _inputNode.props;
originRef = _inputNode.ref,
originProps = _inputNode.props;
var onOriginKeyDown = originProps.onKeyDown,
onOriginChange = originProps.onChange,
onOriginMouseDown = originProps.onMouseDown,
onOriginCompositionStart = originProps.onCompositionStart,
onOriginCompositionEnd = originProps.onCompositionEnd,
style = originProps.style;
onOriginChange = originProps.onChange,
onOriginMouseDown = originProps.onMouseDown,
onOriginCompositionStart = originProps.onCompositionStart,
onOriginCompositionEnd = originProps.onCompositionEnd,
style = originProps.style;
warning(!('maxLength' in inputNode.props), "Passing 'maxLength' to input element directly may not work because input in BaseSelect is controlled.");

@@ -69,3 +67,2 @@ inputNode = /*#__PURE__*/React.cloneElement(inputNode, _objectSpread(_objectSpread(_objectSpread({

_onKeyDown(event);
if (onOriginKeyDown) {

@@ -77,3 +74,2 @@ onOriginKeyDown(event);

_onMouseDown(event);
if (onOriginMouseDown) {

@@ -85,3 +81,2 @@ onOriginMouseDown(event);

_onChange(event);
if (onOriginChange) {

@@ -93,3 +88,2 @@ onOriginChange(event);

_onCompositionStart(event);
if (onOriginCompositionStart) {

@@ -101,3 +95,2 @@ onOriginCompositionStart(event);

_onCompositionEnd(event);
if (onOriginCompositionEnd) {

@@ -111,5 +104,4 @@ onOriginCompositionEnd(event);

};
var RefInput = /*#__PURE__*/React.forwardRef(Input);
RefInput.displayName = 'Input';
export default RefInput;

@@ -12,9 +12,6 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";

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) {

@@ -24,57 +21,56 @@ event.preventDefault();

};
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;
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;
var measureRef = React.useRef(null);
var _useState = useState(0),
_useState2 = _slicedToArray(_useState, 2),
inputWidth = _useState2[0],
setInputWidth = _useState2[1];
_useState2 = _slicedToArray(_useState, 2),
inputWidth = _useState2[0],
setInputWidth = _useState2[1];
var _useState3 = useState(false),
_useState4 = _slicedToArray(_useState3, 2),
focused = _useState4[0],
setFocused = _useState4[1];
_useState4 = _slicedToArray(_useState3, 2),
focused = _useState4[0],
setFocused = _useState4[1];
var selectionPrefixCls = "".concat(prefixCls, "-selection");
var selectionPrefixCls = "".concat(prefixCls, "-selection"); // ===================== Search ======================
// ===================== 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
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 ======================
}, [inputValue]);
// ===================== Render ======================
// >>> Render Selector Node. Includes Item & Rest
function defaultRenderSelector(item, content, itemDisabled, closable, onClose) {

@@ -93,3 +89,2 @@ return /*#__PURE__*/React.createElement("span", {

}
function customizeRenderSelector(value, content, itemDisabled, closable, onClose) {

@@ -100,3 +95,2 @@ var onMouseDown = function onMouseDown(e) {

};
return /*#__PURE__*/React.createElement("span", {

@@ -112,14 +106,11 @@ onMouseDown: onMouseDown

}
function renderItem(valueItem) {
var itemDisabled = valueItem.disabled,
label = valueItem.label,
value = valueItem.value;
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) {

@@ -130,3 +121,2 @@ displayLabel = "".concat(strLabel.slice(0, maxTagTextLength), "...");

}
var onClose = function onClose(event) {

@@ -136,6 +126,4 @@ if (event) event.stopPropagation();

};
return typeof tagRender === 'function' ? customizeRenderSelector(value, displayLabel, itemDisabled, closable, onClose) : defaultRenderSelector(valueItem, displayLabel, itemDisabled, closable, onClose);
}
function renderRest(omittedValues) {

@@ -146,5 +134,5 @@ var content = typeof maxTagPlaceholder === 'function' ? maxTagPlaceholder(omittedValues) : maxTagPlaceholder;

}, content, false);
} // >>> Input Node
}
// >>> Input Node
var inputNode = /*#__PURE__*/React.createElement("div", {

@@ -185,4 +173,5 @@ className: "".concat(selectionPrefixCls, "-search"),

"aria-hidden": true
}, inputValue, "\xA0")); // >>> Selections
}, inputValue, "\xA0"));
// >>> Selections
var selectionNode = /*#__PURE__*/React.createElement(Overflow, {

@@ -201,3 +190,2 @@ prefixCls: "".concat(selectionPrefixCls, "-overflow"),

};
export default SelectSelector;

@@ -6,33 +6,30 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";

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;
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;
var _React$useState = React.useState(false),
_React$useState2 = _slicedToArray(_React$useState, 2),
inputChanged = _React$useState2[0],
setInputChanged = _React$useState2[1];
_React$useState2 = _slicedToArray(_React$useState, 2),
inputChanged = _React$useState2[0],
setInputChanged = _React$useState2[1];
var combobox = mode === 'combobox';

@@ -42,7 +39,5 @@ var inputEditable = combobox || showSearch;

var inputValue = searchValue || '';
if (combobox && activeValue && !inputChanged) {
inputValue = activeValue;
}
React.useEffect(function () {

@@ -52,14 +47,15 @@ if (combobox) {

}
}, [combobox, activeValue]); // Not show text when closed expect combobox mode
}, [combobox, activeValue]);
var hasTextInput = mode !== 'combobox' && !open && !showSearch ? false : !!inputValue; // Get title
// Not show text when closed expect combobox mode
var hasTextInput = mode !== 'combobox' && !open && !showSearch ? false : !!inputValue;
// Get title
var title = getTitle(item);
// 当 Select 已经选中了选型时,placeholder 隐藏,但留在原地占位,内容是选中项文本,这样宽度不会缩减为 0px
// https://github.com/ant-design/ant-design/issues/27688
// https://github.com/ant-design/ant-design/issues/41530
var renderPlaceholder = function renderPlaceholder() {
if (item) {
return null;
}
var hiddenStyle = hasTextInput ? {
var hiddenStyle = hasTextInput || item ? {
visibility: 'hidden'

@@ -70,5 +66,4 @@ } : undefined;

style: hiddenStyle
}, placeholder);
}, item ? item.label : placeholder);
};
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {

@@ -105,3 +100,2 @@ className: "".concat(prefixCls, "-selection-search")

};
export default SingleSelector;

@@ -9,3 +9,2 @@ import _extends from "@babel/runtime/helpers/esm/extends";

import classNames from 'classnames';
var getBuiltInPlacements = function getBuiltInPlacements(dropdownMatchSelectWidth) {

@@ -49,40 +48,38 @@ // Enable horizontal overflow auto-adjustment when a custom dropdown width is provided

};
var SelectTrigger = function SelectTrigger(props, ref) {
var prefixCls = props.prefixCls,
disabled = props.disabled,
visible = props.visible,
children = props.children,
popupElement = props.popupElement,
containerWidth = props.containerWidth,
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,
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);
disabled = props.disabled,
visible = props.visible,
children = props.children,
popupElement = props.popupElement,
containerWidth = props.containerWidth,
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,
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 builtInPlacements = React.useMemo(function () {
return getBuiltInPlacements(dropdownMatchSelectWidth);
}, [dropdownMatchSelectWidth]); // ===================== Motion ======================
}, [dropdownMatchSelectWidth]);
var mergedTransitionName = animation ? "".concat(dropdownPrefixCls, "-").concat(animation) : transitionName; // ======================= Ref =======================
// ===================== Motion ======================
var mergedTransitionName = animation ? "".concat(dropdownPrefixCls, "-").concat(animation) : transitionName;
// ======================= Ref =======================
var popupRef = React.useRef(null);

@@ -96,7 +93,5 @@ React.useImperativeHandle(ref, function () {

});
var popupStyle = _objectSpread({
minWidth: containerWidth
}, dropdownStyle);
if (typeof dropdownMatchSelectWidth === 'number') {

@@ -107,3 +102,2 @@ popupStyle.width = dropdownMatchSelectWidth;

}
return /*#__PURE__*/React.createElement(Trigger, _extends({}, restProps, {

@@ -129,5 +123,4 @@ showAction: onPopupVisibleChange ? ['click'] : [],

};
var RefSelectTrigger = /*#__PURE__*/React.forwardRef(SelectTrigger);
RefSelectTrigger.displayName = 'SelectTrigger';
export default RefSelectTrigger;
import * as React from 'react';
import classNames from 'classnames';
var TransBtn = function TransBtn(_ref) {
var className = _ref.className,
customizeIcon = _ref.customizeIcon,
customizeIconProps = _ref.customizeIconProps,
_onMouseDown = _ref.onMouseDown,
onClick = _ref.onClick,
children = _ref.children;
customizeIcon = _ref.customizeIcon,
customizeIconProps = _ref.customizeIconProps,
_onMouseDown = _ref.onMouseDown,
onClick = _ref.onClick,
children = _ref.children;
var icon;
if (typeof customizeIcon === 'function') {

@@ -18,3 +16,2 @@ icon = customizeIcon(customizeIconProps);

}
return /*#__PURE__*/React.createElement("span", {

@@ -24,3 +21,2 @@ className: className,

event.preventDefault();
if (_onMouseDown) {

@@ -43,3 +39,2 @@ _onMouseDown(event);

};
export default TransBtn;

@@ -6,8 +6,7 @@ import _typeof from "@babel/runtime/helpers/esm/typeof";

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

@@ -17,10 +16,7 @@ export function hasValue(value) {

}
function isTitleType(title) {
return ['string', 'number'].includes(_typeof(title));
}
export function getTitle(item) {
var title = undefined;
if (item) {

@@ -33,4 +29,3 @@ if (isTitleType(item.title)) {

}
return title;
}
import KeyCode from "rc-util/es/KeyCode";
/** keyCode Judgment function */
export function isValidateOpenKey(currentKeyCode) {
return ![// 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
return ![
// 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);
}
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
var _excluded = ["children", "value"],
_excluded2 = ["children"];
_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);
key = _ref.key,
_ref$props = _ref.props,
children = _ref$props.children,
value = _ref$props.value,
restProps = _objectWithoutProperties(_ref$props, _excluded);
return _objectSpread({

@@ -22,3 +20,2 @@ key: key,

}
export function convertChildrenToData(nodes) {

@@ -30,14 +27,11 @@ var optionOnly = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;

}
var _ref2 = node,
isSelectOptGroup = _ref2.type.isSelectOptGroup,
key = _ref2.key,
_ref2$props = _ref2.props,
children = _ref2$props.children,
restProps = _objectWithoutProperties(_ref2$props, _excluded2);
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({

@@ -44,0 +38,0 @@ key: "__RC_SELECT_GRP__".concat(key === null ? index : key, "__"),

@@ -5,28 +5,21 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";

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 fillFieldNames(fieldNames, childrenAsData) {
var _ref = fieldNames || {},
label = _ref.label,
value = _ref.value,
options = _ref.options;
label = _ref.label,
value = _ref.value,
options = _ref.options;
return {

@@ -38,2 +31,3 @@ label: label || (childrenAsData ? 'children' : 'label'),

}
/**

@@ -44,22 +38,18 @@ * Flat options into flatten list.

*/
export function flattenOptions(options) {
var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
fieldNames = _ref2.fieldNames,
childrenAsData = _ref2.childrenAsData;
fieldNames = _ref2.fieldNames,
childrenAsData = _ref2.childrenAsData;
var flattenList = [];
var _fillFieldNames = fillFieldNames(fieldNames, false),
fieldLabel = _fillFieldNames.label,
fieldValue = _fillFieldNames.value,
fieldOptions = _fillFieldNames.options;
fieldLabel = _fillFieldNames.label,
fieldValue = _fillFieldNames.value,
fieldOptions = _fillFieldNames.options;
function dig(list, isGroupOption) {
list.forEach(function (data) {
var label = data[fieldLabel];
if (isGroupOption || !(fieldOptions in data)) {
var value = data[fieldValue]; // Option
var value = data[fieldValue];
// Option
flattenList.push({

@@ -74,8 +64,7 @@ key: getKey(data, flattenList.length),

var grpLabel = label;
if (grpLabel === undefined && childrenAsData) {
grpLabel = data.label;
} // Option Group
}
// Option Group
flattenList.push({

@@ -91,13 +80,11 @@ key: getKey(data, flattenList.length),

}
dig(options, false);
return flattenList;
}
/**
* Inject `props` into `option` for legacy usage
*/
export function injectPropsWithOption(option) {
var newOption = _objectSpread({}, option);
if (!('props' in newOption)) {

@@ -111,3 +98,2 @@ Object.defineProperty(newOption, 'props', {

}
return newOption;

@@ -119,14 +105,10 @@ }

}
var match = false;
function separate(str, _ref3) {
var _ref4 = _toArray(_ref3),
token = _ref4[0],
restTokens = _ref4.slice(1);
token = _ref4[0],
restTokens = _ref4.slice(1);
if (!token) {
return [str];
}
var list = str.split(token);

@@ -140,5 +122,4 @@ match = match || list.length > 1;

}
var list = separate(text, tokens);
return match ? list : null;
}

@@ -8,27 +8,28 @@ import _typeof from "@babel/runtime/helpers/esm/typeof";

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;
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
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
}), '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') {

@@ -41,23 +42,24 @@ var hasNumberValue = mergedOptions.some(function (item) {

}
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`
}
// `combobox` should not use `optionLabelProp`
warning(mode !== 'combobox' || !optionLabelProp, '`combobox` mode not support `optionLabelProp`. Please set `value` on Option directly.');
warning(mode !== 'combobox' || !optionLabelProp, '`combobox` mode not support `optionLabelProp`. Please set `value` on Option directly.'); // Only `combobox` support `backfill`
// Only `combobox` support `backfill`
warning(mode === 'combobox' || !backfill, '`backfill` only works with `combobox` mode.');
warning(mode === 'combobox' || !backfill, '`backfill` only works with `combobox` mode.'); // Only `combobox` support `getInputElement`
// Only `combobox` support `getInputElement`
warning(mode === 'combobox' || !getInputElement, '`getInputElement` only work with `combobox` mode.');
warning(mode === 'combobox' || !getInputElement, '`getInputElement` only work with `combobox` mode.'); // Customize `getInputElement` should not use `allowClear` & `placeholder`
// 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`.');
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`
// `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) {

@@ -69,5 +71,5 @@ var values = toArray(value);

warning(!multiple || Array.isArray(value), '`value` should be array when `mode` is `multiple` or `tags`');
} // Syntactic sugar should use correct children type
}
// Syntactic sugar should use correct children type
if (children) {

@@ -79,10 +81,7 @@ var invalidateChildType = null;

}
var _ref = node,
type = _ref.type;
type = _ref.type;
if (type.isSelectOption) {
return false;
}
if (type.isSelectOptGroup) {

@@ -93,28 +92,22 @@ var allChildrenValid = toNodeArray(node.props.children).every(function (subNode) {

}
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
}
// value in Select option should not be null
// note: OptGroup has options too
export function warningNullOptions(options, fieldNames) {

@@ -124,6 +117,4 @@ if (options) {

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) {

@@ -133,3 +124,2 @@ warning(false, '`value` in Select options should not be `null`.');

}
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)) {

@@ -140,3 +130,2 @@ break;

};
recursiveOptions(options);

@@ -143,0 +132,0 @@ }

"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof3 = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {

@@ -12,114 +10,86 @@ value: true

exports.isMultiple = isMultiple;
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
var _classnames = _interopRequireDefault(require("classnames"));
var _useLayoutEffect = _interopRequireDefault(require("rc-util/lib/hooks/useLayoutEffect"));
var _useMergedState3 = _interopRequireDefault(require("rc-util/lib/hooks/useMergedState"));
var _isMobile = _interopRequireDefault(require("rc-util/lib/isMobile"));
var _KeyCode = _interopRequireDefault(require("rc-util/lib/KeyCode"));
var _ref2 = require("rc-util/lib/ref");
var React = _interopRequireWildcard(require("react"));
var _useBaseProps = require("./hooks/useBaseProps");
var _useDelayReset3 = _interopRequireDefault(require("./hooks/useDelayReset"));
var _useLock3 = _interopRequireDefault(require("./hooks/useLock"));
var _useSelectTriggerControl = _interopRequireDefault(require("./hooks/useSelectTriggerControl"));
var _Selector = _interopRequireDefault(require("./Selector"));
var _SelectTrigger = _interopRequireDefault(require("./SelectTrigger"));
var _TransBtn = _interopRequireDefault(require("./TransBtn"));
var _valueUtil = require("./utils/valueUtil");
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", "showArrow", "inputIcon", "clearIcon", "OptionList", "animation", "transitionName", "dropdownStyle", "dropdownClassName", "dropdownMatchSelectWidth", "dropdownRender", "dropdownAlign", "placement", "getPopupContainer", "showAction", "onFocus", "onBlur", "onKeyUp", "onKeyDown", "onMouseDown"];
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var DEFAULT_OMIT_PROPS = ['value', 'onChange', 'removeIcon', 'placeholder', 'autoFocus', 'maxTagCount', 'maxTagTextLength', 'maxTagPlaceholder', 'choiceTransitionName', 'onInputKeyDown', 'onPopupScroll', 'tabIndex'];
function isMultiple(mode) {
return mode === 'tags' || mode === 'multiple';
}
var BaseSelect = /*#__PURE__*/React.forwardRef(function (props, ref) {
var _customizeRawInputEle, _classNames2;
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,
showArrow = props.showArrow,
inputIcon = props.inputIcon,
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,
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 = (0, _objectWithoutProperties2.default)(props, _excluded); // ============================== MISC ==============================
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,
showArrow = props.showArrow,
inputIcon = props.inputIcon,
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,
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 = (0, _objectWithoutProperties2.default)(props, _excluded);
// ============================== MISC ==============================
var multiple = isMultiple(mode);

@@ -133,14 +103,15 @@ var mergedShowSearch = (showSearch !== undefined ? showSearch : multiple) || mode === 'combobox';

delete domProps[propName];
}); // ============================= Mobile =============================
});
// ============================= Mobile =============================
var _React$useState = React.useState(false),
_React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
mobile = _React$useState2[0],
setMobile = _React$useState2[1];
_React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
mobile = _React$useState2[0],
setMobile = _React$useState2[1];
React.useEffect(function () {
// Only update on the client side
setMobile((0, _isMobile.default)());
}, []); // ============================== Refs ==============================
}, []);
// ============================== Refs ==============================
var containerRef = React.useRef(null);

@@ -151,14 +122,13 @@ var selectorDomRef = React.useRef(null);

var listRef = React.useRef(null);
/** Used for component focused management */
var _useDelayReset = (0, _useDelayReset3.default)(),
_useDelayReset2 = (0, _slicedToArray2.default)(_useDelayReset, 3),
mockFocused = _useDelayReset2[0],
setMockFocused = _useDelayReset2[1],
cancelSetMockFocused = _useDelayReset2[2]; // =========================== Imperative ===========================
_useDelayReset2 = (0, _slicedToArray2.default)(_useDelayReset, 3),
mockFocused = _useDelayReset2[0],
setMockFocused = _useDelayReset2[1],
cancelSetMockFocused = _useDelayReset2[2];
// =========================== Imperative ===========================
React.useImperativeHandle(ref, function () {
var _selectorRef$current, _selectorRef$current2;
return {

@@ -169,48 +139,45 @@ focus: (_selectorRef$current = selectorRef.current) === null || _selectorRef$current === void 0 ? void 0 : _selectorRef$current.focus,

var _listRef$current;
return (_listRef$current = listRef.current) === null || _listRef$current === void 0 ? void 0 : _listRef$current.scrollTo(arg);
}
};
}); // ========================== Search Value ==========================
});
// ========================== 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 ==========================
}, [searchValue, mode, displayValues]);
// ========================== Custom Input ==========================
// Only works in `combobox`
var customizeInputElement = mode === 'combobox' && typeof getInputElement === 'function' && getInputElement() || null;
var customizeInputElement = mode === 'combobox' && typeof getInputElement === 'function' && getInputElement() || null; // Used for customize replacement for `rc-cascader`
// Used for customize replacement for `rc-cascader`
var customizeRawInputElement = typeof getRawInputElement === 'function' && getRawInputElement();
var customizeRawInputRef = (0, _ref2.useComposeRef)(selectorDomRef, customizeRawInputElement === null || customizeRawInputElement === void 0 ? void 0 : (_customizeRawInputEle = customizeRawInputElement.props) === null || _customizeRawInputEle === void 0 ? void 0 : _customizeRawInputEle.ref); // ============================== Open ==============================
var customizeRawInputRef = (0, _ref2.useComposeRef)(selectorDomRef, customizeRawInputElement === null || customizeRawInputElement === void 0 ? void 0 : (_customizeRawInputEle = customizeRawInputElement.props) === null || _customizeRawInputEle === void 0 ? void 0 : _customizeRawInputEle.ref);
// ============================== Open ==============================
var _useMergedState = (0, _useMergedState3.default)(undefined, {
defaultValue: defaultOpen,
value: open
}),
_useMergedState2 = (0, _slicedToArray2.default)(_useMergedState, 2),
innerOpen = _useMergedState2[0],
setInnerOpen = _useMergedState2[1];
defaultValue: defaultOpen,
value: open
}),
_useMergedState2 = (0, _slicedToArray2.default)(_useMergedState, 2),
innerOpen = _useMergedState2[0],
setInnerOpen = _useMergedState2[1];
var mergedOpen = innerOpen;
var mergedOpen = innerOpen; // Not trigger `open` in `combobox` when `notFoundContent` is empty
// 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) {

@@ -220,4 +187,5 @@ onDropdownVisibleChange === null || onDropdownVisibleChange === void 0 ? void 0 : onDropdownVisibleChange(nextOpen);

}
}, [disabled, mergedOpen, setInnerOpen, onDropdownVisibleChange]); // ============================= Search =============================
}, [disabled, mergedOpen, setInnerOpen, onDropdownVisibleChange]);
// ============================= Search =============================
var tokenWithEnter = React.useMemo(function () {

@@ -228,19 +196,21 @@ return (tokenSeparators || []).some(function (tokenSeparator) {

}, [tokenSeparators]);
var onInternalSearch = function onInternalSearch(searchText, fromTyping, isCompositing) {
var ret = true;
var newSearchText = searchText;
onActiveValueChange === null || onActiveValueChange === void 0 ? void 0 : onActiveValueChange(null); // Check if match the `tokenSeparators`
onActiveValueChange === null || onActiveValueChange === void 0 ? void 0 : onActiveValueChange(null);
var patchLabels = isCompositing ? null : (0, _valueUtil.getSeparatedContent)(searchText, tokenSeparators); // Ignore combobox since it's not split-able
// Check if match the `tokenSeparators`
var patchLabels = isCompositing ? null : (0, _valueUtil.getSeparatedContent)(searchText, tokenSeparators);
// Ignore combobox since it's not split-able
if (mode !== 'combobox' && patchLabels) {
newSearchText = '';
onSearchSplit === null || onSearchSplit === void 0 ? void 0 : onSearchSplit(patchLabels); // Should close when paste finish
onSearchSplit === null || onSearchSplit === void 0 ? void 0 : onSearchSplit(patchLabels);
onToggleOpen(false); // Tell Selector that break next actions
// Should close when paste finish
onToggleOpen(false);
// Tell Selector that break next actions
ret = false;
}
if (onSearch && mergedSearchValue !== newSearchText) {

@@ -251,9 +221,8 @@ onSearch(newSearchText, {

}
return ret;
};
return ret;
}; // Only triggered when menu is closed & mode is tags
// 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) {

@@ -264,9 +233,8 @@ // prevent empty tags from appearing when you click the Enter button

}
onSearch(searchText, {
source: 'submit'
});
}; // Close will clean up single mode search text
};
// Close will clean up single mode search text
React.useEffect(function () {

@@ -276,5 +244,6 @@ if (!mergedOpen && !multiple && mode !== 'combobox') {

}
}, [mergedOpen]); // ============================ Disabled ============================
}, [mergedOpen]);
// ============================ Disabled ============================
// Close dropdown & remove focus state when disabled change
React.useEffect(function () {

@@ -284,8 +253,8 @@ if (innerOpen && disabled) {

}
if (disabled) {
setMockFocused(false);
}
}, [disabled]); // ============================ Keyboard ============================
}, [disabled]);
// ============================ Keyboard ============================
/**

@@ -297,13 +266,11 @@ * We record input value here to check if can press to clean up by backspace

*/
var _useLock = (0, _useLock3.default)(),
_useLock2 = (0, _slicedToArray2.default)(_useLock, 2),
getClearLock = _useLock2[0],
setClearLock = _useLock2[1]; // KeyDown
_useLock2 = (0, _slicedToArray2.default)(_useLock, 2),
getClearLock = _useLock2[0],
setClearLock = _useLock2[1];
// KeyDown
var onInternalKeyDown = function onInternalKeyDown(event) {
var clearLock = getClearLock();
var which = event.which;
if (which === _KeyCode.default.ENTER) {

@@ -313,5 +280,5 @@ // Do not submit form when type in the input

event.preventDefault();
} // We only manage open state here, close logic should handle by list component
}
// We only manage open state here, close logic should handle by list component
if (!mergedOpen) {

@@ -321,12 +288,10 @@ onToggleOpen(true);

}
setClearLock(!!mergedSearchValue);
setClearLock(!!mergedSearchValue); // Remove value by `backspace`
// Remove value by `backspace`
if (which === _KeyCode.default.BACKSPACE && !clearLock && multiple && !mergedSearchValue && displayValues.length) {
var cloneDisplayValues = (0, _toConsumableArray2.default)(displayValues);
var removedDisplayValue = null;
for (var i = cloneDisplayValues.length - 1; i >= 0; i -= 1) {
var current = cloneDisplayValues[i];
if (!current.disabled) {

@@ -338,3 +303,2 @@ cloneDisplayValues.splice(i, 1);

}
if (removedDisplayValue) {

@@ -347,17 +311,13 @@ onDisplayValuesChange(cloneDisplayValues, {

}
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 && listRef.current) {
var _listRef$current2;
(_listRef$current2 = listRef.current).onKeyDown.apply(_listRef$current2, [event].concat(rest));
}
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown.apply(void 0, [event].concat(rest));
}; // KeyUp
};
// KeyUp
var onInternalKeyUp = function onInternalKeyUp(event) {

@@ -367,13 +327,10 @@ for (var _len2 = arguments.length, rest = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {

}
if (mergedOpen && listRef.current) {
var _listRef$current3;
(_listRef$current3 = listRef.current).onKeyUp.apply(_listRef$current3, [event].concat(rest));
}
onKeyUp === null || onKeyUp === void 0 ? void 0 : onKeyUp.apply(void 0, [event].concat(rest));
}; // ============================ Selector ============================
};
// ============================ Selector ============================
var onSelectorRemove = function onSelectorRemove(val) {

@@ -387,18 +344,15 @@ var newValues = displayValues.filter(function (i) {

});
}; // ========================== Focus / Blur ==========================
};
// ========================== 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
}
// `showAction` should handle `focus` if set
if (showAction.includes('focus')) {

@@ -408,6 +362,4 @@ onToggleOpen(true);

}
focusRef.current = true;
};
var onContainerBlur = function onContainerBlur() {

@@ -418,7 +370,5 @@ setMockFocused(false, function () {

});
if (disabled) {
return;
}
if (mergedSearchValue) {

@@ -437,9 +387,8 @@ // `tags` mode should move `searchValue` into values

}
if (onBlur) {
onBlur.apply(void 0, arguments);
}
}; // Give focus back of Select
};
// Give focus back of Select
var activeTimeoutIds = [];

@@ -454,22 +403,17 @@ React.useEffect(function () {

}, []);
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
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 ? void 0 : _selectorRef$current3.focus();

@@ -480,31 +424,24 @@ }

}
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 ? void 0 : onMouseDown.apply(void 0, [event].concat(restArgs));
}; // ============================ Dropdown ============================
};
// ============================ Dropdown ============================
var _React$useState3 = React.useState(null),
_React$useState4 = (0, _slicedToArray2.default)(_React$useState3, 2),
containerWidth = _React$useState4[0],
setContainerWidth = _React$useState4[1];
_React$useState4 = (0, _slicedToArray2.default)(_React$useState3, 2),
containerWidth = _React$useState4[0],
setContainerWidth = _React$useState4[1];
var _React$useState5 = React.useState({}),
_React$useState6 = (0, _slicedToArray2.default)(_React$useState5, 2),
forceUpdate = _React$useState6[1]; // We need force update here since popup dom is render async
_React$useState6 = (0, _slicedToArray2.default)(_React$useState5, 2),
forceUpdate = _React$useState6[1];
// We need force update here since popup dom is render async
function onPopupMouseEnter() {
forceUpdate({});
}
(0, _useLayoutEffect.default)(function () {
if (triggerOpen) {
var _containerRef$current;
var newWidth = Math.ceil((_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.offsetWidth);
if (containerWidth !== newWidth && !Number.isNaN(newWidth)) {

@@ -514,6 +451,6 @@ setContainerWidth(newWidth);

}
}, [triggerOpen]); // Used for raw custom input trigger
}, [triggerOpen]);
// Used for raw custom input trigger
var onTriggerVisibleChange;
if (customizeRawInputElement) {

@@ -523,11 +460,11 @@ onTriggerVisibleChange = function onTriggerVisibleChange(newOpen) {

};
} // Close when click on non-select element
}
// Close when click on non-select element
(0, _useSelectTriggerControl.default)(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 =============================
}, triggerOpen, onToggleOpen, !!customizeRawInputElement);
// ============================ Context =============================
var baseSelectContext = React.useMemo(function () {

@@ -543,10 +480,11 @@ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, props), {}, {

});
}, [props, notFoundContent, triggerOpen, mergedOpen, id, mergedShowSearch, multiple, onToggleOpen]); // ==================================================================
}, [props, notFoundContent, triggerOpen, mergedOpen, id, mergedShowSearch, multiple, onToggleOpen]);
// ==================================================================
// == Render ==
// ==================================================================
// ============================= Arrow ==============================
var mergedShowArrow = showArrow !== undefined ? showArrow : loading || !multiple && mode !== 'combobox';
var arrowNode;
if (mergedShowArrow) {

@@ -564,10 +502,8 @@ arrowNode = /*#__PURE__*/React.createElement(_TransBtn.default, {

});
} // ============================= Clear ==============================
}
// ============================= Clear ==============================
var clearNode;
var onClearMouseDown = function onClearMouseDown() {
var _selectorRef$current4;
onClear === null || onClear === void 0 ? void 0 : onClear();

@@ -581,3 +517,2 @@ (_selectorRef$current4 = selectorRef.current) === null || _selectorRef$current4 === void 0 ? void 0 : _selectorRef$current4.focus();

};
if (!disabled && allowClear && (displayValues.length || mergedSearchValue) && !(mode === 'combobox' && mergedSearchValue === '')) {

@@ -589,11 +524,13 @@ clearNode = /*#__PURE__*/React.createElement(_TransBtn.default, {

}, "\xD7");
} // =========================== OptionList ===========================
}
// =========================== OptionList ===========================
var optionList = /*#__PURE__*/React.createElement(OptionList, {
ref: listRef
}); // ============================= Select =============================
});
var mergedClassName = (0, _classnames.default)(prefixCls, className, (_classNames2 = {}, (0, _defineProperty2.default)(_classNames2, "".concat(prefixCls, "-focused"), mockFocused), (0, _defineProperty2.default)(_classNames2, "".concat(prefixCls, "-multiple"), multiple), (0, _defineProperty2.default)(_classNames2, "".concat(prefixCls, "-single"), !multiple), (0, _defineProperty2.default)(_classNames2, "".concat(prefixCls, "-allow-clear"), allowClear), (0, _defineProperty2.default)(_classNames2, "".concat(prefixCls, "-show-arrow"), mergedShowArrow), (0, _defineProperty2.default)(_classNames2, "".concat(prefixCls, "-disabled"), disabled), (0, _defineProperty2.default)(_classNames2, "".concat(prefixCls, "-loading"), loading), (0, _defineProperty2.default)(_classNames2, "".concat(prefixCls, "-open"), mergedOpen), (0, _defineProperty2.default)(_classNames2, "".concat(prefixCls, "-customize-input"), customizeInputElement), (0, _defineProperty2.default)(_classNames2, "".concat(prefixCls, "-show-search"), mergedShowSearch), _classNames2)); // >>> Selector
// ============================= Select =============================
var mergedClassName = (0, _classnames.default)(prefixCls, className, (_classNames2 = {}, (0, _defineProperty2.default)(_classNames2, "".concat(prefixCls, "-focused"), mockFocused), (0, _defineProperty2.default)(_classNames2, "".concat(prefixCls, "-multiple"), multiple), (0, _defineProperty2.default)(_classNames2, "".concat(prefixCls, "-single"), !multiple), (0, _defineProperty2.default)(_classNames2, "".concat(prefixCls, "-allow-clear"), allowClear), (0, _defineProperty2.default)(_classNames2, "".concat(prefixCls, "-show-arrow"), mergedShowArrow), (0, _defineProperty2.default)(_classNames2, "".concat(prefixCls, "-disabled"), disabled), (0, _defineProperty2.default)(_classNames2, "".concat(prefixCls, "-loading"), loading), (0, _defineProperty2.default)(_classNames2, "".concat(prefixCls, "-open"), mergedOpen), (0, _defineProperty2.default)(_classNames2, "".concat(prefixCls, "-customize-input"), customizeInputElement), (0, _defineProperty2.default)(_classNames2, "".concat(prefixCls, "-show-search"), mergedShowSearch), _classNames2));
// >>> Selector
var selectorNode = /*#__PURE__*/React.createElement(_SelectTrigger.default, {

@@ -644,6 +581,8 @@ ref: triggerRef,

tokenWithEnter: tokenWithEnter
}))); // >>> Render
})));
var renderNode; // Render raw
// >>> Render
var renderNode;
// Render raw
if (customizeRawInputElement) {

@@ -672,17 +611,16 @@ renderNode = selectorNode;

var label = _ref.label,
value = _ref.value;
value = _ref.value;
return ['number', 'string'].includes((0, _typeof2.default)(label)) ? label : value;
}).join(', '))), selectorNode, arrowNode, clearNode);
}
return /*#__PURE__*/React.createElement(_useBaseProps.BaseSelectContext.Provider, {
value: baseSelectContext
}, renderNode);
}); // Set display name for dev
});
// Set display name for dev
if (process.env.NODE_ENV !== 'production') {
BaseSelect.displayName = 'BaseSelect';
}
var _default = BaseSelect;
exports.default = _default;
"use strict";
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {

@@ -10,9 +9,5 @@ value: true

exports.default = useBaseProps;
var React = _interopRequireWildcard(require("react"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
/**

@@ -22,7 +17,7 @@ * BaseSelect provide some parsed data into context.

*/
var BaseSelectContext = /*#__PURE__*/React.createContext(null);
exports.BaseSelectContext = BaseSelectContext;
function useBaseProps() {
return React.useContext(BaseSelectContext);
}
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {

@@ -11,11 +9,6 @@ value: true

exports.default = void 0;
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
var React = _interopRequireWildcard(require("react"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
/**

@@ -31,9 +24,9 @@ * Cache `value` related LabeledValue & options.

var _cacheRef$current = cacheRef.current,
prevValueCache = _cacheRef$current.values,
prevOptionCache = _cacheRef$current.options; // Fill label by cache
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 (0, _objectSpread2.default)((0, _objectSpread2.default)({}, item), {}, {

@@ -43,6 +36,6 @@ label: (_prevValueCache$get = prevValueCache.get(item.value)) === null || _prevValueCache$get === void 0 ? void 0 : _prevValueCache$get.label

}
return item;
}); // Refresh cache
});
// Refresh cache
var valueCache = new Map();

@@ -63,3 +56,2 @@ var optionCache = new Map();

};
exports.default = _default;
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {

@@ -11,11 +9,6 @@ value: true

exports.default = useDelayReset;
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var React = _interopRequireWildcard(require("react"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
/**

@@ -27,18 +20,13 @@ * Similar with `useLock`, but this hook will always execute last value.

var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10;
var _React$useState = React.useState(false),
_React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
bool = _React$useState2[0],
setBool = _React$useState2[1];
_React$useState2 = (0, _slicedToArray2.default)(_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) {

@@ -48,3 +36,2 @@ cancelLatest();

setBool(value);
if (callback) {

@@ -55,4 +42,3 @@ callback();

};
return [bool, delaySetBool, cancelLatest];
}
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {

@@ -11,21 +9,12 @@ value: true

exports.default = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _objectSpread3 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
var React = _interopRequireWildcard(require("react"));
var _commonUtil = require("../utils/commonUtil");
var _valueUtil = require("../utils/valueUtil");
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function includes(test, search) {
return (0, _commonUtil.toArray)(test).join('').toUpperCase().includes(search);
}
var _default = function _default(options, fieldNames, searchValue, filterOption, optionFilterProp) {

@@ -36,6 +25,5 @@ return React.useMemo(function () {

}
var fieldOptions = fieldNames.options,
fieldLabel = fieldNames.label,
fieldValue = fieldNames.value;
fieldLabel = fieldNames.label,
fieldValue = fieldNames.value;
var filteredOptions = [];

@@ -48,5 +36,5 @@ var customizeFilter = typeof filterOption === 'function';

return includes(option[optionFilterProp], upperSearch);
} // Auto select `label` or `value` by option type
}
// Auto select `label` or `value` by option type
if (option[fieldOptions]) {

@@ -56,3 +44,2 @@ // hack `fieldLabel` since `OptionGroup` children is not `label`

}
return includes(option[fieldValue], upperSearch);

@@ -70,3 +57,2 @@ };

var matchGroup = filterFunc(searchValue, wrapOption(item));
if (matchGroup) {

@@ -79,3 +65,2 @@ filteredOptions.push(item);

});
if (subOptions.length) {

@@ -85,6 +70,4 @@ filteredOptions.push((0, _objectSpread3.default)((0, _objectSpread3.default)({}, item), {}, (0, _defineProperty2.default)({}, fieldOptions, subOptions)));

}
return;
}
if (filterFunc(searchValue, wrapOption(item))) {

@@ -97,3 +80,2 @@ filteredOptions.push(item);

};
exports.default = _default;
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {

@@ -13,26 +11,19 @@ value: true

exports.isBrowserClient = void 0;
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var React = _interopRequireWildcard(require("react"));
var _canUseDom = _interopRequireDefault(require("rc-util/lib/Dom/canUseDom"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var uuid = 0;
var uuid = 0;
/** Is client side and not jsdom */
var isBrowserClient = process.env.NODE_ENV !== 'test' && (0, _canUseDom.default)();
var isBrowserClient = process.env.NODE_ENV !== 'test' && (0, _canUseDom.default)();
/** Get unique id for accessibility usage */
exports.isBrowserClient = isBrowserClient;
function getUUID() {
var retId; // Test never reach
var retId;
// Test never reach
/* istanbul ignore if */
if (isBrowserClient) {

@@ -44,13 +35,10 @@ retId = uuid;

}
return retId;
}
function useId(id) {
// Inner id for accessibility usage. Only work in client side
var _React$useState = React.useState(),
_React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
innerId = _React$useState2[0],
setInnerId = _React$useState2[1];
_React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
innerId = _React$useState2[0],
setInnerId = _React$useState2[1];
React.useEffect(function () {

@@ -57,0 +45,0 @@ setInnerId("rc_select_".concat(getUUID()));

"use strict";
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {

@@ -9,11 +8,6 @@ value: true

exports.default = useLayoutEffect;
var React = _interopRequireWildcard(require("react"));
var _commonUtil = require("../utils/commonUtil");
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
/* eslint-disable react-hooks/rules-of-hooks */

@@ -20,0 +14,0 @@

"use strict";
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {

@@ -9,9 +8,5 @@ value: true

exports.default = useLock;
var React = _interopRequireWildcard(require("react"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
/**

@@ -26,4 +21,5 @@ * Locker return cached mark.

var lockRef = React.useRef(null);
var timeoutRef = React.useRef(null); // Clean up
var timeoutRef = React.useRef(null);
// Clean up
React.useEffect(function () {

@@ -34,3 +30,2 @@ return function () {

}, []);
function doLock(locked) {

@@ -40,3 +35,2 @@ if (locked || lockRef.current === null) {

}
window.clearTimeout(timeoutRef.current);

@@ -47,3 +41,2 @@ timeoutRef.current = window.setTimeout(function () {

}
return [function () {

@@ -50,0 +43,0 @@ return lockRef.current;

"use strict";
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {

@@ -9,11 +8,6 @@ value: true

exports.default = useOptions;
var React = _interopRequireWildcard(require("react"));
var _legacyUtil = require("../utils/legacyUtil");
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
/**

@@ -27,10 +21,7 @@ * Parse `children` to `options` if `options` is not provided.

var childrenAsData = !options;
if (childrenAsData) {
mergedOptions = (0, _legacyUtil.convertChildrenToData)(children);
}
var valueOptions = new Map();
var labelOptions = new Map();
var setLabelOptions = function setLabelOptions(labelOptionsMap, option, key) {

@@ -41,14 +32,11 @@ if (key && typeof key === 'string') {

};
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, fieldNames.label);
// https://github.com/ant-design/ant-design/issues/35304
setLabelOptions(labelOptions, option, optionFilterProp);

@@ -61,3 +49,2 @@ setLabelOptions(labelOptions, option, optionLabelProp);

}
dig(mergedOptions);

@@ -64,0 +51,0 @@ return {

"use strict";
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {

@@ -9,9 +8,5 @@ value: true

exports.default = useRefFunc;
var React = _interopRequireWildcard(require("react"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
/**

@@ -18,0 +13,0 @@ * Same as `React.useCallback` but always return a memoized function

"use strict";
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {

@@ -9,9 +8,5 @@ value: true

exports.default = useSelectTriggerControl;
var React = _interopRequireWildcard(require("react"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function useSelectTriggerControl(elements, open, triggerOpen, customizedTrigger) {

@@ -27,3 +22,2 @@ var propsRef = React.useRef(null);

var _propsRef$current;
// If trigger is customized, Trigger will take control of popupVisible

@@ -33,9 +27,6 @@ if ((_propsRef$current = propsRef.current) !== null && _propsRef$current !== void 0 && _propsRef$current.customizedTrigger) {

}
var target = event.target;
if (target.shadowRoot && event.composed) {
target = event.composedPath()[0] || target;
}
if (propsRef.current.open && elements().filter(function (element) {

@@ -50,3 +41,2 @@ return element;

}
window.addEventListener('mousedown', onGlobalMouseDown);

@@ -53,0 +43,0 @@ return function () {

"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {

@@ -33,14 +32,8 @@ value: true

});
var _Select = _interopRequireDefault(require("./Select"));
var _Option = _interopRequireDefault(require("./Option"));
var _OptGroup = _interopRequireDefault(require("./OptGroup"));
var _BaseSelect = _interopRequireDefault(require("./BaseSelect"));
var _useBaseProps = _interopRequireDefault(require("./hooks/useBaseProps"));
var _default = _Select.default;
exports.default = _default;

@@ -7,3 +7,2 @@ "use strict";

exports.default = void 0;
/* istanbul ignore file */

@@ -15,5 +14,4 @@

};
OptGroup.isSelectOptGroup = true;
var _default = OptGroup;
exports.default = _default;

@@ -7,3 +7,2 @@ "use strict";

exports.default = void 0;
/* istanbul ignore file */

@@ -15,5 +14,4 @@

};
Option.isSelectOption = true;
var _default = Option;
exports.default = _default;
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {

@@ -11,44 +9,25 @@ value: true

exports.default = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var React = _interopRequireWildcard(require("react"));
var _KeyCode = _interopRequireDefault(require("rc-util/lib/KeyCode"));
var _omit = _interopRequireDefault(require("rc-util/lib/omit"));
var _pickAttrs = _interopRequireDefault(require("rc-util/lib/pickAttrs"));
var _useMemo = _interopRequireDefault(require("rc-util/lib/hooks/useMemo"));
var _classnames = _interopRequireDefault(require("classnames"));
var _rcVirtualList = _interopRequireDefault(require("rc-virtual-list"));
var _TransBtn = _interopRequireDefault(require("./TransBtn"));
var _platformUtil = require("./utils/platformUtil");
var _useBaseProps2 = _interopRequireDefault(require("./hooks/useBaseProps"));
var _SelectContext = _interopRequireDefault(require("./SelectContext"));
var _excluded = ["disabled", "title", "children", "style", "className"];
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function isTitleType(content) {
return typeof content === 'string' || typeof content === 'number';
}
/**

@@ -58,28 +37,24 @@ * Using virtual list of option display.

*/
var OptionList = function OptionList(_, ref) {
var _useBaseProps = (0, _useBaseProps2.default)(),
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;
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.default),
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,
listHeight = _React$useContext.listHeight,
listItemHeight = _React$useContext.listItemHeight;
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,
listHeight = _React$useContext.listHeight,
listItemHeight = _React$useContext.listItemHeight;
var itemPrefixCls = "".concat(prefixCls, "-item");

@@ -90,10 +65,9 @@ var memoFlattenOptions = (0, _useMemo.default)(function () {

return next[0] && prev[1] !== next[1];
}); // =========================== List ===========================
});
// =========================== List ===========================
var listRef = React.useRef(null);
var onListMouseDown = function onListMouseDown(event) {
event.preventDefault();
};
var scrollIntoView = function scrollIntoView(args) {

@@ -105,15 +79,13 @@ if (listRef.current) {

}
}; // ========================== Active ==========================
};
// ========================== 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 _memoFlattenOptions$c = memoFlattenOptions[current],
group = _memoFlattenOptions$c.group,
data = _memoFlattenOptions$c.data;
group = _memoFlattenOptions$c.group,
data = _memoFlattenOptions$c.data;
if (!group && !data.disabled) {

@@ -123,13 +95,10 @@ return current;

}
return -1;
};
var _React$useState = React.useState(function () {
return getEnabledActiveIndex(0);
}),
_React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
activeIndex = _React$useState2[0],
setActiveIndex = _React$useState2[1];
return getEnabledActiveIndex(0);
}),
_React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
activeIndex = _React$useState2[0],
setActiveIndex = _React$useState2[1];
var setActive = function setActive(index) {

@@ -140,6 +109,6 @@ var fromKeyboard = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;

source: fromKeyboard ? 'keyboard' : 'mouse'
}; // Trigger active event
};
// Trigger active event
var flattenItem = memoFlattenOptions[index];
if (!flattenItem) {

@@ -149,15 +118,16 @@ onActiveValue(null, -1, info);

}
onActiveValue(flattenItem.value, index, info);
}; // Auto active first item when list length or searchValue changed
};
// Auto active first item when list length or searchValue changed
(0, React.useEffect)(function () {
setActive(defaultActiveFirstOption !== false ? getEnabledActiveIndex(0) : -1);
}, [memoFlattenOptions.length, searchValue]); // https://github.com/ant-design/ant-design/issues/34975
}, [memoFlattenOptions.length, searchValue]);
// https://github.com/ant-design/ant-design/issues/34975
var isSelected = React.useCallback(function (value) {
return rawValues.has(value) && mode !== 'combobox';
}, [mode, (0, _toConsumableArray2.default)(rawValues).toString(), rawValues.size]); // Auto scroll to item position in single mode
}, [mode, (0, _toConsumableArray2.default)(rawValues).toString(), rawValues.size]);
// Auto scroll to item position in single mode
(0, React.useEffect)(function () {

@@ -176,3 +146,2 @@ /**

});
if (index !== -1) {

@@ -183,15 +152,15 @@ setActive(index);

}
}); // Force trigger scrollbar visible when open
});
// Force trigger scrollbar visible when open
if (open) {
var _listRef$current;
(_listRef$current = listRef.current) === null || _listRef$current === void 0 ? void 0 : _listRef$current.scrollTo(undefined);
}
return function () {
return clearTimeout(timeoutId);
};
}, [open, searchValue]); // ========================== Values ==========================
}, [open, searchValue]);
// ========================== Values ==========================
var onSelectValue = function onSelectValue(value) {

@@ -202,11 +171,11 @@ if (value !== undefined) {

});
} // Single mode should always close by select
}
// Single mode should always close by select
if (!multiple) {
toggleOpen(false);
}
}; // ========================= Keyboard =========================
};
// ========================= Keyboard =========================
React.useImperativeHandle(ref, function () {

@@ -216,4 +185,3 @@ return {

var which = event.which,
ctrlKey = event.ctrlKey;
ctrlKey = event.ctrlKey;
switch (which) {

@@ -227,3 +195,2 @@ // >>> Arrow keys & ctrl + n/p on Mac

var offset = 0;
if (which === _KeyCode.default.UP) {

@@ -240,3 +207,2 @@ offset = -1;

}
if (offset !== 0) {

@@ -247,7 +213,6 @@ var nextActiveIndex = getEnabledActiveIndex(activeIndex + offset, offset);

}
break;
}
// >>> Select
case _KeyCode.default.ENTER:

@@ -257,3 +222,2 @@ {

var item = memoFlattenOptions[activeIndex];
if (item && !item.data.disabled) {

@@ -264,15 +228,12 @@ onSelectValue(item.value);

}
if (open) {
event.preventDefault();
}
break;
}
// >>> Close
case _KeyCode.default.ESC:
{
toggleOpen(false);
if (open) {

@@ -289,4 +250,5 @@ event.stopPropagation();

};
}); // ========================== Render ==========================
});
// ========================== Render ==========================
if (memoFlattenOptions.length === 0) {

@@ -300,11 +262,8 @@ return /*#__PURE__*/React.createElement("div", {

}
var omitFieldNameList = Object.keys(fieldNames).map(function (key) {
return fieldNames[key];
});
var getLabel = function getLabel(item) {
return item.label;
};
var renderItem = function renderItem(index) {

@@ -327,3 +286,2 @@ var item = memoFlattenOptions[index];

};
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {

@@ -349,13 +307,12 @@ role: "listbox",

var _classNames;
var group = item.group,
groupOption = item.groupOption,
data = item.data,
label = item.label,
value = item.value;
var key = data.key; // 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;

@@ -367,11 +324,11 @@ return /*#__PURE__*/React.createElement("div", {

}
var disabled = data.disabled,
title = data.title,
children = data.children,
style = data.style,
className = data.className,
otherProps = (0, _objectWithoutProperties2.default)(data, _excluded);
var passedProps = (0, _omit.default)(otherProps, omitFieldNameList); // Option
title = data.title,
children = data.children,
style = data.style,
className = data.className,
otherProps = (0, _objectWithoutProperties2.default)(data, _excluded);
var passedProps = (0, _omit.default)(otherProps, omitFieldNameList);
// Option
var selected = isSelected(value);

@@ -381,12 +338,11 @@ var optionPrefixCls = "".concat(itemPrefixCls, "-option");

var mergedLabel = getLabel(item);
var iconVisible = !menuItemSelectedIcon || typeof menuItemSelectedIcon === 'function' || selected; // https://github.com/ant-design/ant-design/issues/34145
var iconVisible = !menuItemSelectedIcon || typeof menuItemSelectedIcon === 'function' || selected;
var content = typeof mergedLabel === 'number' ? mergedLabel : mergedLabel || value; // https://github.com/ant-design/ant-design/issues/26717
// 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", (0, _extends2.default)({}, (0, _pickAttrs.default)(passedProps), {

@@ -400,3 +356,2 @@ "aria-selected": selected,

}
setActive(itemIndex);

@@ -421,3 +376,2 @@ },

};
var RefOptionList = /*#__PURE__*/React.forwardRef(OptionList);

@@ -424,0 +378,0 @@ RefOptionList.displayName = 'OptionList';

"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof3 = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {

@@ -11,95 +9,66 @@ value: true

exports.default = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
var _useMergedState5 = _interopRequireDefault(require("rc-util/lib/hooks/useMergedState"));
var _warning = _interopRequireDefault(require("rc-util/lib/warning"));
var React = _interopRequireWildcard(require("react"));
var _BaseSelect = _interopRequireWildcard(require("./BaseSelect"));
var _useCache3 = _interopRequireDefault(require("./hooks/useCache"));
var _useFilterOptions = _interopRequireDefault(require("./hooks/useFilterOptions"));
var _useId = _interopRequireDefault(require("./hooks/useId"));
var _useOptions = _interopRequireDefault(require("./hooks/useOptions"));
var _useRefFunc = _interopRequireDefault(require("./hooks/useRefFunc"));
var _OptGroup = _interopRequireDefault(require("./OptGroup"));
var _Option = _interopRequireDefault(require("./Option"));
var _OptionList = _interopRequireDefault(require("./OptionList"));
var _SelectContext = _interopRequireDefault(require("./SelectContext"));
var _commonUtil = require("./utils/commonUtil");
var _valueUtil = require("./utils/valueUtil");
var _warningPropsUtil = _interopRequireWildcard(require("./utils/warningPropsUtil"));
var _excluded = ["id", "mode", "prefixCls", "backfill", "fieldNames", "inputValue", "searchValue", "onSearch", "autoClearSearchValue", "onSelect", "onDeselect", "dropdownMatchSelectWidth", "filterOption", "filterSort", "optionFilterProp", "optionLabelProp", "options", "children", "defaultActiveFirstOption", "menuItemSelectedIcon", "virtual", "listHeight", "listItemHeight", "value", "defaultValue", "labelInValue", "onChange"];
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var OMIT_DOM_PROPS = ['inputValue'];
function isRawValue(value) {
return !value || (0, _typeof2.default)(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,
children = props.children,
defaultActiveFirstOption = props.defaultActiveFirstOption,
menuItemSelectedIcon = props.menuItemSelectedIcon,
virtual = props.virtual,
_props$listHeight = props.listHeight,
listHeight = _props$listHeight === void 0 ? 200 : _props$listHeight,
_props$listItemHeight = props.listItemHeight,
listItemHeight = _props$listItemHeight === void 0 ? 20 : _props$listItemHeight,
value = props.value,
defaultValue = props.defaultValue,
labelInValue = props.labelInValue,
onChange = props.onChange,
restProps = (0, _objectWithoutProperties2.default)(props, _excluded);
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,
children = props.children,
defaultActiveFirstOption = props.defaultActiveFirstOption,
menuItemSelectedIcon = props.menuItemSelectedIcon,
virtual = props.virtual,
_props$listHeight = props.listHeight,
listHeight = _props$listHeight === void 0 ? 200 : _props$listHeight,
_props$listItemHeight = props.listItemHeight,
listItemHeight = _props$listItemHeight === void 0 ? 20 : _props$listItemHeight,
value = props.value,
defaultValue = props.defaultValue,
labelInValue = props.labelInValue,
onChange = props.onChange,
restProps = (0, _objectWithoutProperties2.default)(props, _excluded);
var mergedId = (0, _useId.default)(id);

@@ -112,35 +81,37 @@ var multiple = (0, _BaseSelect.isMultiple)(mode);

}
return filterOption;
}, [filterOption, mode]); // ========================= FieldNames =========================
}, [filterOption, mode]);
// ========================= FieldNames =========================
var mergedFieldNames = React.useMemo(function () {
return (0, _valueUtil.fillFieldNames)(fieldNames, childrenAsData);
},
/* eslint-disable react-hooks/exhaustive-deps */
[// We stringify fieldNames to avoid unnecessary re-renders.
}, /* 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 ===========================
/* eslint-enable react-hooks/exhaustive-deps */);
// =========================== Search ===========================
var _useMergedState = (0, _useMergedState5.default)('', {
value: searchValue !== undefined ? searchValue : inputValue,
postState: function postState(search) {
return search || '';
}
}),
_useMergedState2 = (0, _slicedToArray2.default)(_useMergedState, 2),
mergedSearchValue = _useMergedState2[0],
setSearchValue = _useMergedState2[1]; // =========================== Option ===========================
value: searchValue !== undefined ? searchValue : inputValue,
postState: function postState(search) {
return search || '';
}
}),
_useMergedState2 = (0, _slicedToArray2.default)(_useMergedState, 2),
mergedSearchValue = _useMergedState2[0],
setSearchValue = _useMergedState2[1];
// =========================== Option ===========================
var parsedOptions = (0, _useOptions.default)(options, children, mergedFieldNames, optionFilterProp, optionLabelProp);
var valueOptions = parsedOptions.valueOptions,
labelOptions = parsedOptions.labelOptions,
mergedOptions = parsedOptions.options; // ========================= Wrap Value =========================
labelOptions = parsedOptions.labelOptions,
mergedOptions = parsedOptions.options;
// ========================= Wrap Value =========================
var convert2LabelValues = React.useCallback(function (draftValues) {
// Convert to array
var valueList = (0, _commonUtil.toArray)(draftValues); // Convert to labelInValue type
var valueList = (0, _commonUtil.toArray)(draftValues);
// Convert to labelInValue type
return valueList.map(function (val) {

@@ -151,4 +122,5 @@ var rawValue;

var rawDisabled;
var rawTitle; // Fill label & value
var rawTitle;
// Fill label & value
if (isRawValue(val)) {

@@ -158,3 +130,2 @@ rawValue = val;

var _val$value;
rawKey = val.key;

@@ -164,8 +135,5 @@ rawLabel = val.label;

}
var option = valueOptions.get(rawValue);
if (option) {
var _option$key;
// Fill missing props

@@ -175,7 +143,7 @@ if (rawLabel === undefined) rawLabel = option === null || option === void 0 ? void 0 : option[optionLabelProp || mergedFieldNames.label];

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
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 && optionLabel !== rawLabel) {

@@ -186,3 +154,2 @@ (0, _warning.default)(false, '`label` of `value` is not same as `label` in Select options.');

}
return {

@@ -196,29 +163,29 @@ label: rawLabel,

});
}, [mergedFieldNames, optionLabelProp, valueOptions]); // =========================== Values ===========================
}, [mergedFieldNames, optionLabelProp, valueOptions]);
// =========================== Values ===========================
var _useMergedState3 = (0, _useMergedState5.default)(defaultValue, {
value: value
}),
_useMergedState4 = (0, _slicedToArray2.default)(_useMergedState3, 2),
internalValue = _useMergedState4[0],
setInternalValue = _useMergedState4[1]; // Merged value with LabelValueType
value: value
}),
_useMergedState4 = (0, _slicedToArray2.default)(_useMergedState3, 2),
internalValue = _useMergedState4[0],
setInternalValue = _useMergedState4[1];
// Merged value with LabelValueType
var rawLabeledValues = React.useMemo(function () {
var _values$;
var values = convert2LabelValues(internalValue);
var values = convert2LabelValues(internalValue); // combobox no need save value when it's no value
// combobox no need save value when it's no value
if (mode === 'combobox' && !((_values$ = values[0]) !== null && _values$ !== void 0 && _values$.value)) {
return [];
}
return values;
}, [internalValue, convert2LabelValues, mode]); // Fill label with cache to avoid option remove
}, [internalValue, convert2LabelValues, mode]);
// Fill label with cache to avoid option remove
var _useCache = (0, _useCache3.default)(rawLabeledValues, valueOptions),
_useCache2 = (0, _slicedToArray2.default)(_useCache, 2),
mergedValues = _useCache2[0],
getMixedOption = _useCache2[1];
_useCache2 = (0, _slicedToArray2.default)(_useCache, 2),
mergedValues = _useCache2[0],
getMixedOption = _useCache2[1];
var displayValues = React.useMemo(function () {

@@ -229,3 +196,2 @@ // `null` need show as placeholder instead

var firstValue = mergedValues[0];
if (firstValue.value === null && (firstValue.label === null || firstValue.label === undefined)) {

@@ -235,6 +201,4 @@ return [];

}
return mergedValues.map(function (item) {
var _item$label;
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, item), {}, {

@@ -245,4 +209,4 @@ label: (_item$label = item.label) !== null && _item$label !== void 0 ? _item$label : item.value

}, [mode, mergedValues]);
/** Convert `displayValues` to raw value type set */
var rawValues = React.useMemo(function () {

@@ -256,29 +220,30 @@ return new Set(mergedValues.map(function (val) {

var _mergedValues$;
var strValue = (_mergedValues$ = mergedValues[0]) === null || _mergedValues$ === void 0 ? void 0 : _mergedValues$.value;
setSearchValue((0, _commonUtil.hasValue)(strValue) ? String(strValue) : '');
}
}, [mergedValues]); // ======================= Display Option =======================
}, [mergedValues]);
// ======================= Display Option =======================
// Create a placeholder item if not exist in `options`
var createTagOption = (0, _useRefFunc.default)(function (val, label) {
var _ref;
var mergedLabel = label !== null && label !== void 0 ? label : val;
return _ref = {}, (0, _defineProperty2.default)(_ref, mergedFieldNames.value, val), (0, _defineProperty2.default)(_ref, mergedFieldNames.label, mergedLabel), _ref;
}); // Fill tag as option if mode is `tags`
});
// Fill tag as option if mode is `tags`
var filledTagOptions = React.useMemo(function () {
if (mode !== 'tags') {
return mergedOptions;
} // >>> Tag mode
}
// >>> Tag mode
var cloneOptions = (0, _toConsumableArray2.default)(mergedOptions);
var cloneOptions = (0, _toConsumableArray2.default)(mergedOptions); // Check if value exist in options (include new patch item)
// Check if value exist in options (include new patch item)
var existOptions = function existOptions(val) {
return valueOptions.has(val);
}; // Fill current value as option
};
// Fill current value as option
(0, _toConsumableArray2.default)(mergedValues).sort(function (a, b) {

@@ -288,3 +253,2 @@ return a.value < b.value ? -1 : 1;

var val = item.value;
if (!existOptions(val)) {

@@ -296,4 +260,5 @@ cloneOptions.push(createTagOption(val, item.label));

}, [createTagOption, mergedOptions, valueOptions, mergedValues, mode]);
var filteredOptions = (0, _useFilterOptions.default)(filledTagOptions, mergedFieldNames, mergedSearchValue, mergedFilterOption, optionFilterProp); // Fill options with search value if needed
var filteredOptions = (0, _useFilterOptions.default)(filledTagOptions, mergedFieldNames, mergedSearchValue, mergedFilterOption, optionFilterProp);
// Fill options with search value if needed
var filledSearchOptions = React.useMemo(function () {

@@ -304,5 +269,5 @@ if (mode !== 'tags' || !mergedSearchValue || filteredOptions.some(function (item) {

return filteredOptions;
} // Fill search value as option
}
// Fill search value as option
return [createTagOption(mergedSearchValue)].concat((0, _toConsumableArray2.default)(filteredOptions));

@@ -314,3 +279,2 @@ }, [createTagOption, optionFilterProp, mode, filteredOptions, mergedSearchValue]);

}
return (0, _toConsumableArray2.default)(filledSearchOptions).sort(function (a, b) {

@@ -325,12 +289,12 @@ return filterSort(a, b);

});
}, [orderedFilteredOptions, mergedFieldNames, childrenAsData]); // =========================== Change ===========================
}, [orderedFilteredOptions, mergedFieldNames, childrenAsData]);
// =========================== Change ===========================
var triggerChange = function triggerChange(values) {
var labeledValues = convert2LabelValues(values);
setInternalValue(labeledValues);
if (onChange && ( // Trigger event only when value changed
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);

@@ -344,36 +308,34 @@ }))) {

});
onChange( // Value
multiple ? returnValues : returnValues[0], // Option
onChange(
// Value
multiple ? returnValues : returnValues[0],
// Option
multiple ? returnOptions : returnOptions[0]);
}
}; // ======================= Accessibility ========================
};
// ======================= Accessibility ========================
var _React$useState = React.useState(null),
_React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
activeValue = _React$useState2[0],
setActiveValue = _React$useState2[1];
_React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
activeValue = _React$useState2[0],
setActiveValue = _React$useState2[1];
var _React$useState3 = React.useState(0),
_React$useState4 = (0, _slicedToArray2.default)(_React$useState3, 2),
accessibilityIndex = _React$useState4[0],
setAccessibilityIndex = _React$useState4[1];
_React$useState4 = (0, _slicedToArray2.default)(_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 _ref2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
_ref2$source = _ref2.source,
source = _ref2$source === void 0 ? 'keyboard' : _ref2$source;
_ref2$source = _ref2.source,
source = _ref2$source === void 0 ? 'keyboard' : _ref2$source;
setAccessibilityIndex(index);
if (backfill && mode === 'combobox' && active !== null && source === 'keyboard') {
setActiveValue(String(active));
}
}, [backfill, mode]); // ========================= OptionList =========================
}, [backfill, mode]);
// ========================= OptionList =========================
var triggerSelect = function triggerSelect(val, selected, type) {
var getSelectEnt = function getSelectEnt() {
var _option$key2;
var option = getMixedOption(val);

@@ -386,26 +348,23 @@ return [labelInValue ? {

};
if (selected && onSelect) {
var _getSelectEnt = getSelectEnt(),
_getSelectEnt2 = (0, _slicedToArray2.default)(_getSelectEnt, 2),
wrappedValue = _getSelectEnt2[0],
_option = _getSelectEnt2[1];
_getSelectEnt2 = (0, _slicedToArray2.default)(_getSelectEnt, 2),
wrappedValue = _getSelectEnt2[0],
_option = _getSelectEnt2[1];
onSelect(wrappedValue, _option);
} else if (!selected && onDeselect && type !== 'clear') {
var _getSelectEnt3 = getSelectEnt(),
_getSelectEnt4 = (0, _slicedToArray2.default)(_getSelectEnt3, 2),
_wrappedValue = _getSelectEnt4[0],
_option2 = _getSelectEnt4[1];
_getSelectEnt4 = (0, _slicedToArray2.default)(_getSelectEnt3, 2),
_wrappedValue = _getSelectEnt4[0],
_option2 = _getSelectEnt4[1];
onDeselect(_wrappedValue, _option2);
}
}; // Used for OptionList selection
};
// Used for OptionList selection
var onInternalSelect = (0, _useRefFunc.default)(function (val, info) {
var cloneValues; // Single mode always trigger select only with option list
var cloneValues;
// Single mode always trigger select only with option list
var mergedSelect = multiple ? info.selected : true;
if (mergedSelect) {

@@ -418,6 +377,6 @@ cloneValues = multiple ? [].concat((0, _toConsumableArray2.default)(mergedValues), [val]) : [val];

}
triggerChange(cloneValues);
triggerSelect(val, mergedSelect); // Clean search value if single or configured
triggerSelect(val, mergedSelect);
// Clean search value if single or configured
if (mode === 'combobox') {

@@ -430,10 +389,10 @@ // setSearchValue(String(val));

}
}); // ======================= Display Change =======================
});
// ======================= Display Change =======================
// BaseSelect display values change
var onDisplayValuesChange = function onDisplayValuesChange(nextValues, info) {
triggerChange(nextValues);
var type = info.type,
values = info.values;
values = info.values;
if (type === 'remove' || type === 'clear') {

@@ -444,12 +403,13 @@ values.forEach(function (item) {

}
}; // =========================== Search ===========================
};
// =========================== Search ===========================
var onInternalSearch = function onInternalSearch(searchText, info) {
setSearchValue(searchText);
setActiveValue(null); // [Submit] Tag mode should flush input
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
var formatted = (searchText || '').trim();
// prevent empty tags from appearing when you click the Enter button
if (formatted) {

@@ -461,6 +421,4 @@ var newRawValues = Array.from(new Set([].concat((0, _toConsumableArray2.default)(rawValues), [formatted])));

}
return;
}
if (info.source !== 'blur') {

@@ -470,10 +428,7 @@ if (mode === 'combobox') {

}
onSearch === null || onSearch === void 0 ? void 0 : onSearch(searchText);
}
};
var onInternalSearchSplit = function onInternalSearchSplit(words) {
var patchValues = words;
if (mode !== 'tags') {

@@ -487,3 +442,2 @@ patchValues = words.map(function (word) {

}
var newRawValues = Array.from(new Set([].concat((0, _toConsumableArray2.default)(rawValues), (0, _toConsumableArray2.default)(patchValues))));

@@ -494,5 +448,5 @@ triggerChange(newRawValues);

});
}; // ========================== Context ===========================
};
// ========================== Context ===========================
var selectContext = React.useMemo(function () {

@@ -513,12 +467,13 @@ var realVirtual = virtual !== false && dropdownMatchSelectWidth !== false;

});
}, [parsedOptions, displayOptions, onActiveValue, mergedDefaultActiveFirstOption, onInternalSelect, menuItemSelectedIcon, rawValues, mergedFieldNames, virtual, dropdownMatchSelectWidth, listHeight, listItemHeight, childrenAsData]); // ========================== Warning ===========================
}, [parsedOptions, displayOptions, onActiveValue, mergedDefaultActiveFirstOption, onInternalSelect, menuItemSelectedIcon, rawValues, mergedFieldNames, virtual, dropdownMatchSelectWidth, listHeight, listItemHeight, childrenAsData]);
// ========================== Warning ===========================
if (process.env.NODE_ENV !== 'production') {
(0, _warningPropsUtil.default)(props);
(0, _warningPropsUtil.warningNullOptions)(mergedOptions, mergedFieldNames);
} // ==============================================================
}
// ==============================================================
// == Render ==
// ==============================================================
return /*#__PURE__*/React.createElement(_SelectContext.default.Provider, {

@@ -532,6 +487,8 @@ value: selectContext

omitDomProps: OMIT_DOM_PROPS,
mode: mode // >>> Values
mode: mode
// >>> Values
,
displayValues: displayValues,
onDisplayValuesChange: onDisplayValuesChange // >>> Search
onDisplayValuesChange: onDisplayValuesChange
// >>> Search
,

@@ -542,6 +499,8 @@ searchValue: mergedSearchValue,

onSearchSplit: onInternalSearchSplit,
dropdownMatchSelectWidth: dropdownMatchSelectWidth // >>> OptionList
dropdownMatchSelectWidth: dropdownMatchSelectWidth
// >>> OptionList
,
OptionList: _OptionList.default,
emptyOptions: !displayOptions.length // >>> Accessibility
emptyOptions: !displayOptions.length
// >>> Accessibility
,

@@ -552,7 +511,5 @@ activeValue: activeValue,

});
if (process.env.NODE_ENV !== 'production') {
Select.displayName = 'Select';
}
var TypedSelect = Select;

@@ -559,0 +516,0 @@ TypedSelect.Option = _Option.default;

"use strict";
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {

@@ -9,11 +8,7 @@ value: true

exports.default = void 0;
var React = _interopRequireWildcard(require("react"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var SelectContext = /*#__PURE__*/React.createContext(null);
var _default = SelectContext;
exports.default = _default;
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {

@@ -11,23 +9,12 @@ value: true

exports.default = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var React = _interopRequireWildcard(require("react"));
var _KeyCode = _interopRequireDefault(require("rc-util/lib/KeyCode"));
var _MultipleSelector = _interopRequireDefault(require("./MultipleSelector"));
var _SingleSelector = _interopRequireDefault(require("./SingleSelector"));
var _useLock3 = _interopRequireDefault(require("../hooks/useLock"));
var _keyUtil = require("../utils/keyUtil");
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
/**

@@ -42,2 +29,3 @@ * Cursor rule:

*/
var Selector = function Selector(props, ref) {

@@ -47,13 +35,14 @@ var inputRef = (0, React.useRef)(null);

var prefixCls = props.prefixCls,
open = props.open,
mode = props.mode,
showSearch = props.showSearch,
tokenWithEnter = props.tokenWithEnter,
autoClearSearchValue = props.autoClearSearchValue,
onSearch = props.onSearch,
onSearchSubmit = props.onSearchSubmit,
onToggleOpen = props.onToggleOpen,
onInputKeyDown = props.onInputKeyDown,
domRef = props.domRef; // ======================= Ref =======================
open = props.open,
mode = props.mode,
showSearch = props.showSearch,
tokenWithEnter = props.tokenWithEnter,
autoClearSearchValue = props.autoClearSearchValue,
onSearch = props.onSearch,
onSearchSubmit = props.onSearchSubmit,
onToggleOpen = props.onToggleOpen,
onInputKeyDown = props.onInputKeyDown,
domRef = props.domRef;
// ======================= Ref =======================
React.useImperativeHandle(ref, function () {

@@ -68,20 +57,17 @@ return {

};
}); // ====================== Input ======================
});
// ====================== Input ======================
var _useLock = (0, _useLock3.default)(0),
_useLock2 = (0, _slicedToArray2.default)(_useLock, 2),
getInputMouseDown = _useLock2[0],
setInputMouseDown = _useLock2[1];
_useLock2 = (0, _slicedToArray2.default)(_useLock, 2),
getInputMouseDown = _useLock2[0],
setInputMouseDown = _useLock2[1];
var onInternalInputKeyDown = function onInternalInputKeyDown(event) {
var which = event.which;
if (which === _KeyCode.default.UP || which === _KeyCode.default.DOWN) {
event.preventDefault();
}
if (onInputKeyDown) {
onInputKeyDown(event);
}
if (which === _KeyCode.default.ENTER && mode === 'tags' && !compositionStatusRef.current && !open) {

@@ -92,3 +78,2 @@ // When menu isn't open, OptionList won't trigger a value change

}
if ((0, _keyUtil.isValidateOpenKey)(which)) {

@@ -98,2 +83,3 @@ onToggleOpen(true);

};
/**

@@ -103,11 +89,8 @@ * We can not use `findDOMNode` sine it will get warning,

*/
var onInternalInputMouseDown = function onInternalInputMouseDown() {
setInputMouseDown(true);
}; // When paste come, ignore next onChange
};
// When paste come, ignore next onChange
var pastedTextRef = (0, React.useRef)(null);
var triggerOnSearch = function triggerOnSearch(value) {

@@ -118,10 +101,9 @@ if (onSearch(value, true, compositionStatusRef.current) !== false) {

};
var onInputCompositionStart = function onInputCompositionStart() {
compositionStatusRef.current = true;
};
var onInputCompositionEnd = function onInputCompositionEnd(e) {
compositionStatusRef.current = false; // Trigger search again to support `tokenSeparators` with typewriting
compositionStatusRef.current = false;
// Trigger search again to support `tokenSeparators` with typewriting
if (mode !== 'combobox') {

@@ -131,6 +113,6 @@ triggerOnSearch(e.target.value);

};
var onInputChange = function onInputChange(event) {
var value = event.target.value; // Pasted text should replace back to origin content
var value = event.target.value;
// Pasted text should replace back to origin content
if (tokenWithEnter && pastedTextRef.current && /[\r\n]/.test(pastedTextRef.current)) {

@@ -141,7 +123,5 @@ // CRLF will be treated as a single space for input element

}
pastedTextRef.current = null;
triggerOnSearch(value);
};
var onInputPaste = function onInputPaste(e) {

@@ -152,10 +132,7 @@ var clipboardData = e.clipboardData;

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

@@ -170,11 +147,10 @@ setTimeout(function () {

};
var onMouseDown = function onMouseDown(event) {
var inputMouseDown = getInputMouseDown();
var onMouseDown = function onMouseDown(event) {
var inputMouseDown = getInputMouseDown(); // when mode is combobox, don't prevent default behavior
// when mode is combobox, don't prevent default behavior
// https://github.com/ant-design/ant-design/issues/37320
if (event.target !== inputRef.current && !inputMouseDown && mode !== 'combobox') {
event.preventDefault();
}
if (mode !== 'combobox' && (!showSearch || !inputMouseDown) || !open) {

@@ -184,8 +160,7 @@ if (open && autoClearSearchValue !== false) {

}
onToggleOpen();
}
}; // ================= Inner Selector ==================
};
// ================= Inner Selector ==================
var sharedProps = {

@@ -208,3 +183,2 @@ inputRef: inputRef,

};
var ForwardSelector = /*#__PURE__*/React.forwardRef(Selector);

@@ -211,0 +185,0 @@ ForwardSelector.displayName = 'Selector';

"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {

@@ -11,49 +9,40 @@ value: true

exports.default = void 0;
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
var React = _interopRequireWildcard(require("react"));
var _classnames = _interopRequireDefault(require("classnames"));
var _ref2 = require("rc-util/lib/ref");
var _warning = require("rc-util/lib/warning");
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var Input = function Input(_ref, ref) {
var _inputNode2, _inputNode2$props;
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,
activeDescendantId = _ref.activeDescendantId,
value = _ref.value,
maxLength = _ref.maxLength,
_onKeyDown = _ref.onKeyDown,
_onMouseDown = _ref.onMouseDown,
_onChange = _ref.onChange,
onPaste = _ref.onPaste,
_onCompositionStart = _ref.onCompositionStart,
_onCompositionEnd = _ref.onCompositionEnd,
open = _ref.open,
attrs = _ref.attrs;
id = _ref.id,
inputElement = _ref.inputElement,
disabled = _ref.disabled,
tabIndex = _ref.tabIndex,
autoFocus = _ref.autoFocus,
autoComplete = _ref.autoComplete,
editable = _ref.editable,
activeDescendantId = _ref.activeDescendantId,
value = _ref.value,
maxLength = _ref.maxLength,
_onKeyDown = _ref.onKeyDown,
_onMouseDown = _ref.onMouseDown,
_onChange = _ref.onChange,
onPaste = _ref.onPaste,
_onCompositionStart = _ref.onCompositionStart,
_onCompositionEnd = _ref.onCompositionEnd,
open = _ref.open,
attrs = _ref.attrs;
var inputNode = inputElement || /*#__PURE__*/React.createElement("input", null);
var _inputNode = inputNode,
originRef = _inputNode.ref,
originProps = _inputNode.props;
originRef = _inputNode.ref,
originProps = _inputNode.props;
var onOriginKeyDown = originProps.onKeyDown,
onOriginChange = originProps.onChange,
onOriginMouseDown = originProps.onMouseDown,
onOriginCompositionStart = originProps.onCompositionStart,
onOriginCompositionEnd = originProps.onCompositionEnd,
style = originProps.style;
onOriginChange = originProps.onChange,
onOriginMouseDown = originProps.onMouseDown,
onOriginCompositionStart = originProps.onCompositionStart,
onOriginCompositionEnd = originProps.onCompositionEnd,
style = originProps.style;
(0, _warning.warning)(!('maxLength' in inputNode.props), "Passing 'maxLength' to input element directly may not work because input in BaseSelect is controlled.");

@@ -88,3 +77,2 @@ inputNode = /*#__PURE__*/React.cloneElement(inputNode, (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({

_onKeyDown(event);
if (onOriginKeyDown) {

@@ -96,3 +84,2 @@ onOriginKeyDown(event);

_onMouseDown(event);
if (onOriginMouseDown) {

@@ -104,3 +91,2 @@ onOriginMouseDown(event);

_onChange(event);
if (onOriginChange) {

@@ -112,3 +98,2 @@ onOriginChange(event);

_onCompositionStart(event);
if (onOriginCompositionStart) {

@@ -120,3 +105,2 @@ onOriginCompositionStart(event);

_onCompositionEnd(event);
if (onOriginCompositionEnd) {

@@ -130,3 +114,2 @@ onOriginCompositionEnd(event);

};
var RefInput = /*#__PURE__*/React.forwardRef(Input);

@@ -133,0 +116,0 @@ RefInput.displayName = 'Input';

"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {

@@ -11,33 +9,18 @@ value: true

exports.default = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var React = _interopRequireWildcard(require("react"));
var _classnames = _interopRequireDefault(require("classnames"));
var _pickAttrs = _interopRequireDefault(require("rc-util/lib/pickAttrs"));
var _rcOverflow = _interopRequireDefault(require("rc-overflow"));
var _TransBtn = _interopRequireDefault(require("../TransBtn"));
var _Input = _interopRequireDefault(require("./Input"));
var _useLayoutEffect = _interopRequireDefault(require("../hooks/useLayoutEffect"));
var _commonUtil = require("../utils/commonUtil");
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
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) {

@@ -47,57 +30,56 @@ event.preventDefault();

};
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;
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;
var measureRef = React.useRef(null);
var _useState = (0, React.useState)(0),
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
inputWidth = _useState2[0],
setInputWidth = _useState2[1];
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
inputWidth = _useState2[0],
setInputWidth = _useState2[1];
var _useState3 = (0, React.useState)(false),
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
focused = _useState4[0],
setFocused = _useState4[1];
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
focused = _useState4[0],
setFocused = _useState4[1];
var selectionPrefixCls = "".concat(prefixCls, "-selection");
var selectionPrefixCls = "".concat(prefixCls, "-selection"); // ===================== Search ======================
// ===================== 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
var inputEditable = mode === 'tags' || mode === "multiple" && autoClearSearchValue === false || showSearch && (open || focused);
// We measure width and set to the input immediately
(0, _useLayoutEffect.default)(function () {
setInputWidth(measureRef.current.scrollWidth);
}, [inputValue]); // ===================== Render ======================
}, [inputValue]);
// ===================== Render ======================
// >>> Render Selector Node. Includes Item & Rest
function defaultRenderSelector(item, content, itemDisabled, closable, onClose) {

@@ -116,3 +98,2 @@ return /*#__PURE__*/React.createElement("span", {

}
function customizeRenderSelector(value, content, itemDisabled, closable, onClose) {

@@ -123,3 +104,2 @@ var onMouseDown = function onMouseDown(e) {

};
return /*#__PURE__*/React.createElement("span", {

@@ -135,14 +115,11 @@ onMouseDown: onMouseDown

}
function renderItem(valueItem) {
var itemDisabled = valueItem.disabled,
label = valueItem.label,
value = valueItem.value;
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) {

@@ -153,3 +130,2 @@ displayLabel = "".concat(strLabel.slice(0, maxTagTextLength), "...");

}
var onClose = function onClose(event) {

@@ -159,6 +135,4 @@ if (event) event.stopPropagation();

};
return typeof tagRender === 'function' ? customizeRenderSelector(value, displayLabel, itemDisabled, closable, onClose) : defaultRenderSelector(valueItem, displayLabel, itemDisabled, closable, onClose);
}
function renderRest(omittedValues) {

@@ -169,5 +143,5 @@ var content = typeof maxTagPlaceholder === 'function' ? maxTagPlaceholder(omittedValues) : maxTagPlaceholder;

}, content, false);
} // >>> Input Node
}
// >>> Input Node
var inputNode = /*#__PURE__*/React.createElement("div", {

@@ -208,4 +182,5 @@ className: "".concat(selectionPrefixCls, "-search"),

"aria-hidden": true
}, inputValue, "\xA0")); // >>> Selections
}, inputValue, "\xA0"));
// >>> Selections
var selectionNode = /*#__PURE__*/React.createElement(_rcOverflow.default, {

@@ -224,4 +199,3 @@ prefixCls: "".concat(selectionPrefixCls, "-overflow"),

};
var _default = SelectSelector;
exports.default = _default;
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {

@@ -11,47 +9,37 @@ value: true

exports.default = void 0;
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var React = _interopRequireWildcard(require("react"));
var _pickAttrs = _interopRequireDefault(require("rc-util/lib/pickAttrs"));
var _Input = _interopRequireDefault(require("./Input"));
var _commonUtil = require("../utils/commonUtil");
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
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;
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;
var _React$useState = React.useState(false),
_React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
inputChanged = _React$useState2[0],
setInputChanged = _React$useState2[1];
_React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
inputChanged = _React$useState2[0],
setInputChanged = _React$useState2[1];
var combobox = mode === 'combobox';

@@ -61,7 +49,5 @@ var inputEditable = combobox || showSearch;

var inputValue = searchValue || '';
if (combobox && activeValue && !inputChanged) {
inputValue = activeValue;
}
React.useEffect(function () {

@@ -71,14 +57,15 @@ if (combobox) {

}
}, [combobox, activeValue]); // Not show text when closed expect combobox mode
}, [combobox, activeValue]);
var hasTextInput = mode !== 'combobox' && !open && !showSearch ? false : !!inputValue; // Get title
// Not show text when closed expect combobox mode
var hasTextInput = mode !== 'combobox' && !open && !showSearch ? false : !!inputValue;
// Get title
var title = (0, _commonUtil.getTitle)(item);
// 当 Select 已经选中了选型时,placeholder 隐藏,但留在原地占位,内容是选中项文本,这样宽度不会缩减为 0px
// https://github.com/ant-design/ant-design/issues/27688
// https://github.com/ant-design/ant-design/issues/41530
var renderPlaceholder = function renderPlaceholder() {
if (item) {
return null;
}
var hiddenStyle = hasTextInput ? {
var hiddenStyle = hasTextInput || item ? {
visibility: 'hidden'

@@ -89,5 +76,4 @@ } : undefined;

style: hiddenStyle
}, placeholder);
}, item ? item.label : placeholder);
};
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {

@@ -124,4 +110,3 @@ className: "".concat(prefixCls, "-selection-search")

};
var _default = SingleSelector;
exports.default = _default;
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {

@@ -11,23 +9,12 @@ value: true

exports.default = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
var React = _interopRequireWildcard(require("react"));
var _rcTrigger = _interopRequireDefault(require("rc-trigger"));
var _classnames = _interopRequireDefault(require("classnames"));
var _excluded = ["prefixCls", "disabled", "visible", "children", "popupElement", "containerWidth", "animation", "transitionName", "dropdownStyle", "dropdownClassName", "direction", "placement", "dropdownMatchSelectWidth", "dropdownRender", "dropdownAlign", "getPopupContainer", "empty", "getTriggerDOMNode", "onPopupVisibleChange", "onPopupMouseEnter"];
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var getBuiltInPlacements = function getBuiltInPlacements(dropdownMatchSelectWidth) {

@@ -71,39 +58,38 @@ // Enable horizontal overflow auto-adjustment when a custom dropdown width is provided

};
var SelectTrigger = function SelectTrigger(props, ref) {
var prefixCls = props.prefixCls,
disabled = props.disabled,
visible = props.visible,
children = props.children,
popupElement = props.popupElement,
containerWidth = props.containerWidth,
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,
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 = (0, _objectWithoutProperties2.default)(props, _excluded);
disabled = props.disabled,
visible = props.visible,
children = props.children,
popupElement = props.popupElement,
containerWidth = props.containerWidth,
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,
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 = (0, _objectWithoutProperties2.default)(props, _excluded);
var dropdownPrefixCls = "".concat(prefixCls, "-dropdown");
var popupNode = popupElement;
if (dropdownRender) {
popupNode = dropdownRender(popupElement);
}
var builtInPlacements = React.useMemo(function () {
return getBuiltInPlacements(dropdownMatchSelectWidth);
}, [dropdownMatchSelectWidth]); // ===================== Motion ======================
}, [dropdownMatchSelectWidth]);
var mergedTransitionName = animation ? "".concat(dropdownPrefixCls, "-").concat(animation) : transitionName; // ======================= Ref =======================
// ===================== Motion ======================
var mergedTransitionName = animation ? "".concat(dropdownPrefixCls, "-").concat(animation) : transitionName;
// ======================= Ref =======================
var popupRef = React.useRef(null);

@@ -120,3 +106,2 @@ React.useImperativeHandle(ref, function () {

}, dropdownStyle);
if (typeof dropdownMatchSelectWidth === 'number') {

@@ -127,3 +112,2 @@ popupStyle.width = dropdownMatchSelectWidth;

}
return /*#__PURE__*/React.createElement(_rcTrigger.default, (0, _extends2.default)({}, restProps, {

@@ -149,3 +133,2 @@ showAction: onPopupVisibleChange ? ['click'] : [],

};
var RefSelectTrigger = /*#__PURE__*/React.forwardRef(SelectTrigger);

@@ -152,0 +135,0 @@ RefSelectTrigger.displayName = 'SelectTrigger';

"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {

@@ -11,20 +9,14 @@ value: true

exports.default = void 0;
var React = _interopRequireWildcard(require("react"));
var _classnames = _interopRequireDefault(require("classnames"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var TransBtn = function TransBtn(_ref) {
var className = _ref.className,
customizeIcon = _ref.customizeIcon,
customizeIconProps = _ref.customizeIconProps,
_onMouseDown = _ref.onMouseDown,
onClick = _ref.onClick,
children = _ref.children;
customizeIcon = _ref.customizeIcon,
customizeIconProps = _ref.customizeIconProps,
_onMouseDown = _ref.onMouseDown,
onClick = _ref.onClick,
children = _ref.children;
var icon;
if (typeof customizeIcon === 'function') {

@@ -35,3 +27,2 @@ icon = customizeIcon(customizeIconProps);

}
return /*#__PURE__*/React.createElement("span", {

@@ -41,3 +32,2 @@ className: className,

event.preventDefault();
if (_onMouseDown) {

@@ -60,4 +50,3 @@ _onMouseDown(event);

};
var _default = TransBtn;
exports.default = _default;

@@ -7,5 +7,4 @@ "use strict";

exports.isPlatformMac = isPlatformMac;
function isPlatformMac() {
return true;
}
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {

@@ -12,5 +11,3 @@ value: true

exports.toArray = toArray;
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
function toArray(value) {

@@ -20,24 +17,18 @@ if (Array.isArray(value)) {

}
return value !== undefined ? [value] : [];
}
var isClient = typeof window !== 'undefined' && window.document && window.document.documentElement;
var isClient = typeof window !== 'undefined' && window.document && window.document.documentElement;
/** Is client side and not jsdom */
exports.isClient = isClient;
var isBrowserClient = process.env.NODE_ENV !== 'test' && isClient;
exports.isBrowserClient = isBrowserClient;
function hasValue(value) {
return value !== undefined && value !== null;
}
function isTitleType(title) {
return ['string', 'number'].includes((0, _typeof2.default)(title));
}
function getTitle(item) {
var title = undefined;
if (item) {

@@ -50,4 +41,3 @@ if (isTitleType(item.title)) {

}
return title;
}
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {

@@ -9,10 +8,10 @@ value: true

exports.isValidateOpenKey = isValidateOpenKey;
var _KeyCode = _interopRequireDefault(require("rc-util/lib/KeyCode"));
/** keyCode Judgment function */
function isValidateOpenKey(currentKeyCode) {
return ![// System function button
_KeyCode.default.ESC, _KeyCode.default.SHIFT, _KeyCode.default.BACKSPACE, _KeyCode.default.TAB, _KeyCode.default.WIN_KEY, _KeyCode.default.ALT, _KeyCode.default.META, _KeyCode.default.WIN_KEY_RIGHT, _KeyCode.default.CTRL, _KeyCode.default.SEMICOLON, _KeyCode.default.EQUALS, _KeyCode.default.CAPS_LOCK, _KeyCode.default.CONTEXT_MENU, // F1-F12
return ![
// System function button
_KeyCode.default.ESC, _KeyCode.default.SHIFT, _KeyCode.default.BACKSPACE, _KeyCode.default.TAB, _KeyCode.default.WIN_KEY, _KeyCode.default.ALT, _KeyCode.default.META, _KeyCode.default.WIN_KEY_RIGHT, _KeyCode.default.CTRL, _KeyCode.default.SEMICOLON, _KeyCode.default.EQUALS, _KeyCode.default.CAPS_LOCK, _KeyCode.default.CONTEXT_MENU,
// F1-F12
_KeyCode.default.F1, _KeyCode.default.F2, _KeyCode.default.F3, _KeyCode.default.F4, _KeyCode.default.F5, _KeyCode.default.F6, _KeyCode.default.F7, _KeyCode.default.F8, _KeyCode.default.F9, _KeyCode.default.F10, _KeyCode.default.F11, _KeyCode.default.F12].includes(currentKeyCode);
}
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {

@@ -11,25 +9,17 @@ value: true

exports.convertChildrenToData = convertChildrenToData;
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
var React = _interopRequireWildcard(require("react"));
var _toArray = _interopRequireDefault(require("rc-util/lib/Children/toArray"));
var _excluded = ["children", "value"],
_excluded2 = ["children"];
_excluded2 = ["children"];
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function convertNodeToOption(node) {
var _ref = node,
key = _ref.key,
_ref$props = _ref.props,
children = _ref$props.children,
value = _ref$props.value,
restProps = (0, _objectWithoutProperties2.default)(_ref$props, _excluded);
key = _ref.key,
_ref$props = _ref.props,
children = _ref$props.children,
value = _ref$props.value,
restProps = (0, _objectWithoutProperties2.default)(_ref$props, _excluded);
return (0, _objectSpread2.default)({

@@ -41,3 +31,2 @@ key: key,

}
function convertChildrenToData(nodes) {

@@ -49,14 +38,11 @@ var optionOnly = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;

}
var _ref2 = node,
isSelectOptGroup = _ref2.type.isSelectOptGroup,
key = _ref2.key,
_ref2$props = _ref2.props,
children = _ref2$props.children,
restProps = (0, _objectWithoutProperties2.default)(_ref2$props, _excluded2);
isSelectOptGroup = _ref2.type.isSelectOptGroup,
key = _ref2.key,
_ref2$props = _ref2.props,
children = _ref2$props.children,
restProps = (0, _objectWithoutProperties2.default)(_ref2$props, _excluded2);
if (optionOnly || !isSelectOptGroup) {
return convertNodeToOption(node);
}
return (0, _objectSpread2.default)((0, _objectSpread2.default)({

@@ -63,0 +49,0 @@ key: "__RC_SELECT_GRP__".concat(key === null ? index : key, "__"),

@@ -7,3 +7,2 @@ "use strict";

exports.isPlatformMac = isPlatformMac;
/* istanbul ignore file */

@@ -10,0 +9,0 @@ function isPlatformMac() {

"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {

@@ -12,36 +11,25 @@ value: true

exports.injectPropsWithOption = injectPropsWithOption;
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
var _toArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toArray"));
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
var _warning = _interopRequireDefault(require("rc-util/lib/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);
}
function fillFieldNames(fieldNames, childrenAsData) {
var _ref = fieldNames || {},
label = _ref.label,
value = _ref.value,
options = _ref.options;
label = _ref.label,
value = _ref.value,
options = _ref.options;
return {

@@ -53,2 +41,3 @@ label: label || (childrenAsData ? 'children' : 'label'),

}
/**

@@ -59,23 +48,18 @@ * Flat options into flatten list.

*/
function flattenOptions(options) {
var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
fieldNames = _ref2.fieldNames,
childrenAsData = _ref2.childrenAsData;
fieldNames = _ref2.fieldNames,
childrenAsData = _ref2.childrenAsData;
var flattenList = [];
var _fillFieldNames = fillFieldNames(fieldNames, false),
fieldLabel = _fillFieldNames.label,
fieldValue = _fillFieldNames.value,
fieldOptions = _fillFieldNames.options;
fieldLabel = _fillFieldNames.label,
fieldValue = _fillFieldNames.value,
fieldOptions = _fillFieldNames.options;
function dig(list, isGroupOption) {
list.forEach(function (data) {
var label = data[fieldLabel];
if (isGroupOption || !(fieldOptions in data)) {
var value = data[fieldValue]; // Option
var value = data[fieldValue];
// Option
flattenList.push({

@@ -90,8 +74,7 @@ key: getKey(data, flattenList.length),

var grpLabel = label;
if (grpLabel === undefined && childrenAsData) {
grpLabel = data.label;
} // Option Group
}
// Option Group
flattenList.push({

@@ -107,14 +90,11 @@ key: getKey(data, flattenList.length),

}
dig(options, false);
return flattenList;
}
/**
* Inject `props` into `option` for legacy usage
*/
function injectPropsWithOption(option) {
var newOption = (0, _objectSpread2.default)({}, option);
if (!('props' in newOption)) {

@@ -128,6 +108,4 @@ Object.defineProperty(newOption, 'props', {

}
return newOption;
}
function getSeparatedContent(text, tokens) {

@@ -137,14 +115,10 @@ if (!tokens || !tokens.length) {

}
var match = false;
function separate(str, _ref3) {
var _ref4 = (0, _toArray2.default)(_ref3),
token = _ref4[0],
restTokens = _ref4.slice(1);
token = _ref4[0],
restTokens = _ref4.slice(1);
if (!token) {
return [str];
}
var list = str.split(token);

@@ -158,5 +132,4 @@ match = match || list.length > 1;

}
var list = separate(text, tokens);
return match ? list : null;
}
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof3 = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {

@@ -12,45 +10,37 @@ value: true

exports.warningNullOptions = warningNullOptions;
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
var _toArray = _interopRequireDefault(require("rc-util/lib/Children/toArray"));
var _warning = _interopRequireWildcard(require("rc-util/lib/warning"));
var React = _interopRequireWildcard(require("react"));
var _BaseSelect = require("../BaseSelect");
var _commonUtil = require("./commonUtil");
var _legacyUtil = require("./legacyUtil");
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
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;
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 = (0, _BaseSelect.isMultiple)(mode);
var mergedShowSearch = showSearch !== undefined ? showSearch : multiple || mode === 'combobox';
var mergedOptions = options || (0, _legacyUtil.convertChildrenToData)(children); // `tags` should not set option as disabled
var mergedOptions = options || (0, _legacyUtil.convertChildrenToData)(children);
// `tags` should not set option as disabled
(0, _warning.default)(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
}), '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') {

@@ -63,23 +53,24 @@ var hasNumberValue = mergedOptions.some(function (item) {

}
return typeof ('value' in item ? item.value : item.key) === 'number';
});
(0, _warning.default)(!hasNumberValue, '`value` of Option should not use number type when `mode` is `tags` or `combobox`.');
} // `combobox` should not use `optionLabelProp`
}
// `combobox` should not use `optionLabelProp`
(0, _warning.default)(mode !== 'combobox' || !optionLabelProp, '`combobox` mode not support `optionLabelProp`. Please set `value` on Option directly.');
(0, _warning.default)(mode !== 'combobox' || !optionLabelProp, '`combobox` mode not support `optionLabelProp`. Please set `value` on Option directly.'); // Only `combobox` support `backfill`
// Only `combobox` support `backfill`
(0, _warning.default)(mode === 'combobox' || !backfill, '`backfill` only works with `combobox` mode.');
(0, _warning.default)(mode === 'combobox' || !backfill, '`backfill` only works with `combobox` mode.'); // Only `combobox` support `getInputElement`
// Only `combobox` support `getInputElement`
(0, _warning.default)(mode === 'combobox' || !getInputElement, '`getInputElement` only work with `combobox` mode.');
(0, _warning.default)(mode === 'combobox' || !getInputElement, '`getInputElement` only work with `combobox` mode.'); // Customize `getInputElement` should not use `allowClear` & `placeholder`
// Customize `getInputElement` should not use `allowClear` & `placeholder`
(0, _warning.noteOnce)(mode !== 'combobox' || !getInputElement || !allowClear || !placeholder, 'Customize `getInputElement` should customize clear and placeholder logic instead of configuring `allowClear` and `placeholder`.');
(0, _warning.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`
// `onSearch` should use in `combobox` or `showSearch`
if (onSearch && !mergedShowSearch && mode !== 'combobox' && mode !== 'tags') {
(0, _warning.default)(false, '`onSearch` should work with `showSearch` instead of use alone.');
}
(0, _warning.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) {

@@ -91,5 +82,5 @@ var values = (0, _commonUtil.toArray)(value);

(0, _warning.default)(!multiple || Array.isArray(value), '`value` should be array when `mode` is `multiple` or `tags`');
} // Syntactic sugar should use correct children type
}
// Syntactic sugar should use correct children type
if (children) {

@@ -101,10 +92,7 @@ var invalidateChildType = null;

}
var _ref = node,
type = _ref.type;
type = _ref.type;
if (type.isSelectOption) {
return false;
}
if (type.isSelectOptGroup) {

@@ -115,28 +103,22 @@ var allChildrenValid = (0, _toArray.default)(node.props.children).every(function (subNode) {

}
invalidateChildType = subNode.type;
return false;
});
if (allChildrenValid) {
return false;
}
return true;
}
invalidateChildType = type;
return true;
});
if (invalidateChildType) {
(0, _warning.default)(false, "`children` should be `Select.Option` or `Select.OptGroup` instead of `".concat(invalidateChildType.displayName || invalidateChildType.name || invalidateChildType, "`."));
}
(0, _warning.default)(inputValue === undefined, '`inputValue` is deprecated, please use `searchValue` instead.');
}
} // value in Select option should not be null
}
// value in Select option should not be null
// note: OptGroup has options too
function warningNullOptions(options, fieldNames) {

@@ -146,6 +128,4 @@ if (options) {

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) {

@@ -155,3 +135,2 @@ (0, _warning.default)(false, '`value` in Select options should not be `null`.');

}
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)) {

@@ -162,8 +141,6 @@ break;

};
recursiveOptions(options);
}
}
var _default = warningProps;
exports.default = _default;
{
"name": "rc-select",
"version": "14.1.16",
"version": "14.1.17-0",
"description": "React Select",

@@ -36,3 +36,3 @@ "engines": {

"compile": "father build",
"prepublishOnly": "npm run compile && np --yolo --no-publish",
"prepublishOnly": "npm run compile && np --yolo --no-publish --branch 14.1.x",
"lint": "eslint src/ docs/examples/ --ext .tsx,.ts,.jsx,.js",

@@ -39,0 +39,0 @@ "test": "rc-test",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc