rc-select
Advanced tools
Comparing version 14.11.0-0 to 14.11.0
@@ -111,4 +111,4 @@ import type { AlignType, BuildInPlacements } from '@rc-component/trigger/lib/interface'; | ||
} | ||
export declare function isMultiple(mode: Mode): boolean; | ||
export declare const isMultiple: (mode: Mode) => boolean; | ||
declare const BaseSelect: React.ForwardRefExoticComponent<BaseSelectProps & React.RefAttributes<BaseSelectRef>>; | ||
export default BaseSelect; |
@@ -25,6 +25,7 @@ import _typeof from "@babel/runtime/helpers/esm/typeof"; | ||
import { getSeparatedContent } from "./utils/valueUtil"; | ||
import SelectContext from "./SelectContext"; | ||
var DEFAULT_OMIT_PROPS = ['value', 'onChange', 'removeIcon', 'placeholder', 'autoFocus', 'maxTagCount', 'maxTagTextLength', 'maxTagPlaceholder', 'choiceTransitionName', 'onInputKeyDown', 'onPopupScroll', 'tabIndex']; | ||
export function isMultiple(mode) { | ||
export var isMultiple = function isMultiple(mode) { | ||
return mode === 'tags' || mode === 'multiple'; | ||
} | ||
}; | ||
var BaseSelect = /*#__PURE__*/React.forwardRef(function (props, ref) { | ||
@@ -191,9 +192,16 @@ var _customizeRawInputEle, _classNames2; | ||
}, [tokenSeparators]); | ||
var _ref = React.useContext(SelectContext) || {}, | ||
maxCount = _ref.maxCount, | ||
rawValues = _ref.rawValues; | ||
var onInternalSearch = function onInternalSearch(searchText, fromTyping, isCompositing) { | ||
if ((rawValues === null || rawValues === void 0 ? void 0 : rawValues.size) >= maxCount) { | ||
return; | ||
} | ||
var ret = true; | ||
var newSearchText = searchText; | ||
onActiveValueChange === null || onActiveValueChange === void 0 || onActiveValueChange(null); | ||
var separatedList = getSeparatedContent(searchText, tokenSeparators, maxCount && maxCount - rawValues.size); | ||
// Check if match the `tokenSeparators` | ||
var patchLabels = isCompositing ? null : getSeparatedContent(searchText, tokenSeparators); | ||
var patchLabels = isCompositing ? null : separatedList; | ||
@@ -303,5 +311,5 @@ // Ignore combobox since it's not split-able | ||
} | ||
if (mergedOpen && listRef.current) { | ||
if (mergedOpen) { | ||
var _listRef$current2; | ||
(_listRef$current2 = listRef.current).onKeyDown.apply(_listRef$current2, [event].concat(rest)); | ||
(_listRef$current2 = listRef.current) === null || _listRef$current2 === void 0 || _listRef$current2.onKeyDown.apply(_listRef$current2, [event].concat(rest)); | ||
} | ||
@@ -316,5 +324,5 @@ onKeyDown === null || onKeyDown === void 0 || onKeyDown.apply(void 0, [event].concat(rest)); | ||
} | ||
if (mergedOpen && listRef.current) { | ||
if (mergedOpen) { | ||
var _listRef$current3; | ||
(_listRef$current3 = listRef.current).onKeyUp.apply(_listRef$current3, [event].concat(rest)); | ||
(_listRef$current3 = listRef.current) === null || _listRef$current3 === void 0 || _listRef$current3.onKeyUp.apply(_listRef$current3, [event].concat(rest)); | ||
} | ||
@@ -569,5 +577,5 @@ onKeyUp === null || onKeyUp === void 0 || onKeyUp.apply(void 0, [event].concat(rest)); | ||
} | ||
}, "".concat(displayValues.map(function (_ref) { | ||
var label = _ref.label, | ||
value = _ref.value; | ||
}, "".concat(displayValues.map(function (_ref2) { | ||
var label = _ref2.label, | ||
value = _ref2.value; | ||
return ['number', 'string'].includes(_typeof(label)) ? label : value; | ||
@@ -574,0 +582,0 @@ }).join(', '))), selectorNode, arrowNode, mergedAllowClear && clearNode); |
@@ -65,4 +65,4 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; | ||
var overMaxCount = React.useMemo(function () { | ||
return multiple && typeof maxCount !== 'undefined' && rawValues.size >= maxCount; | ||
}, [multiple, maxCount, rawValues.size]); | ||
return multiple && typeof maxCount !== 'undefined' && (rawValues === null || rawValues === void 0 ? void 0 : rawValues.size) >= maxCount; | ||
}, [multiple, maxCount, rawValues === null || rawValues === void 0 ? void 0 : rawValues.size]); | ||
var onListMouseDown = function onListMouseDown(event) { | ||
@@ -72,7 +72,6 @@ event.preventDefault(); | ||
var scrollIntoView = function scrollIntoView(args) { | ||
if (listRef.current) { | ||
listRef.current.scrollTo(typeof args === 'number' ? { | ||
index: args | ||
} : args); | ||
} | ||
var _listRef$current; | ||
(_listRef$current = listRef.current) === null || _listRef$current === void 0 || _listRef$current.scrollTo(typeof args === 'number' ? { | ||
index: args | ||
} : args); | ||
}; | ||
@@ -150,4 +149,4 @@ | ||
if (open) { | ||
var _listRef$current; | ||
(_listRef$current = listRef.current) === null || _listRef$current === void 0 || _listRef$current.scrollTo(undefined); | ||
var _listRef$current2; | ||
(_listRef$current2 = listRef.current) === null || _listRef$current2 === void 0 || _listRef$current2.scrollTo(undefined); | ||
} | ||
@@ -154,0 +153,0 @@ return function () { |
@@ -110,4 +110,4 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
var clipboardData = e.clipboardData; | ||
var value = clipboardData.getData('text'); | ||
pastedTextRef.current = value; | ||
var value = clipboardData === null || clipboardData === void 0 ? void 0 : clipboardData.getData('text'); | ||
pastedTextRef.current = value || ''; | ||
}; | ||
@@ -114,0 +114,0 @@ var onClick = function onClick(_ref) { |
@@ -23,2 +23,2 @@ import type { BaseOptionType, DefaultOptionType } from '../Select'; | ||
export declare function injectPropsWithOption<T extends object>(option: T): T; | ||
export declare function getSeparatedContent(text: string, tokens: string[]): string[]; | ||
export declare const getSeparatedContent: (text: string, tokens: string[], end?: number) => string[]; |
@@ -101,3 +101,3 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray"; | ||
} | ||
export function getSeparatedContent(text, tokens) { | ||
export var getSeparatedContent = function getSeparatedContent(text, tokens, end) { | ||
if (!tokens || !tokens.length) { | ||
@@ -107,3 +107,3 @@ return null; | ||
var match = false; | ||
function separate(str, _ref3) { | ||
var separate = function separate(str, _ref3) { | ||
var _ref4 = _toArray(_ref3), | ||
@@ -119,8 +119,10 @@ token = _ref4[0], | ||
return [].concat(_toConsumableArray(prevList), _toConsumableArray(separate(unitStr, restTokens))); | ||
}, []).filter(function (unit) { | ||
return unit; | ||
}); | ||
}, []).filter(Boolean); | ||
}; | ||
var list = separate(text, tokens); | ||
if (match) { | ||
return typeof end !== 'undefined' ? list.slice(0, end) : list; | ||
} else { | ||
return null; | ||
} | ||
var list = separate(text, tokens); | ||
return match ? list : null; | ||
} | ||
}; |
@@ -111,4 +111,4 @@ import type { AlignType, BuildInPlacements } from '@rc-component/trigger/lib/interface'; | ||
} | ||
export declare function isMultiple(mode: Mode): boolean; | ||
export declare const isMultiple: (mode: Mode) => boolean; | ||
declare const BaseSelect: React.ForwardRefExoticComponent<BaseSelectProps & React.RefAttributes<BaseSelectRef>>; | ||
export default BaseSelect; |
@@ -8,4 +8,3 @@ "use strict"; | ||
}); | ||
exports.default = void 0; | ||
exports.isMultiple = isMultiple; | ||
exports.isMultiple = exports.default = void 0; | ||
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")); | ||
@@ -23,3 +22,3 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); | ||
var _KeyCode = _interopRequireDefault(require("rc-util/lib/KeyCode")); | ||
var _ref2 = require("rc-util/lib/ref"); | ||
var _ref3 = require("rc-util/lib/ref"); | ||
var React = _interopRequireWildcard(require("react")); | ||
@@ -35,2 +34,3 @@ var _useAllowClear2 = require("./hooks/useAllowClear"); | ||
var _valueUtil = require("./utils/valueUtil"); | ||
var _SelectContext = _interopRequireDefault(require("./SelectContext")); | ||
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", "suffixIcon", "clearIcon", "OptionList", "animation", "transitionName", "dropdownStyle", "dropdownClassName", "dropdownMatchSelectWidth", "dropdownRender", "dropdownAlign", "placement", "builtinPlacements", "getPopupContainer", "showAction", "onFocus", "onBlur", "onKeyUp", "onKeyDown", "onMouseDown"]; | ||
@@ -40,5 +40,5 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); } | ||
var DEFAULT_OMIT_PROPS = ['value', 'onChange', 'removeIcon', 'placeholder', 'autoFocus', 'maxTagCount', 'maxTagTextLength', 'maxTagPlaceholder', 'choiceTransitionName', 'onInputKeyDown', 'onPopupScroll', 'tabIndex']; | ||
function isMultiple(mode) { | ||
var isMultiple = exports.isMultiple = function isMultiple(mode) { | ||
return mode === 'tags' || mode === 'multiple'; | ||
} | ||
}; | ||
var BaseSelect = /*#__PURE__*/React.forwardRef(function (props, ref) { | ||
@@ -163,3 +163,3 @@ var _customizeRawInputEle, _classNames2; | ||
var customizeRawInputElement = typeof getRawInputElement === 'function' && getRawInputElement(); | ||
var customizeRawInputRef = (0, _ref2.useComposeRef)(selectorDomRef, customizeRawInputElement === null || customizeRawInputElement === void 0 || (_customizeRawInputEle = customizeRawInputElement.props) === null || _customizeRawInputEle === void 0 ? void 0 : _customizeRawInputEle.ref); | ||
var customizeRawInputRef = (0, _ref3.useComposeRef)(selectorDomRef, customizeRawInputElement === null || customizeRawInputElement === void 0 || (_customizeRawInputEle = customizeRawInputElement.props) === null || _customizeRawInputEle === void 0 ? void 0 : _customizeRawInputEle.ref); | ||
@@ -206,9 +206,16 @@ // ============================== Open ============================== | ||
}, [tokenSeparators]); | ||
var _ref = React.useContext(_SelectContext.default) || {}, | ||
maxCount = _ref.maxCount, | ||
rawValues = _ref.rawValues; | ||
var onInternalSearch = function onInternalSearch(searchText, fromTyping, isCompositing) { | ||
if ((rawValues === null || rawValues === void 0 ? void 0 : rawValues.size) >= maxCount) { | ||
return; | ||
} | ||
var ret = true; | ||
var newSearchText = searchText; | ||
onActiveValueChange === null || onActiveValueChange === void 0 || onActiveValueChange(null); | ||
var separatedList = (0, _valueUtil.getSeparatedContent)(searchText, tokenSeparators, maxCount && maxCount - rawValues.size); | ||
// Check if match the `tokenSeparators` | ||
var patchLabels = isCompositing ? null : (0, _valueUtil.getSeparatedContent)(searchText, tokenSeparators); | ||
var patchLabels = isCompositing ? null : separatedList; | ||
@@ -318,5 +325,5 @@ // Ignore combobox since it's not split-able | ||
} | ||
if (mergedOpen && listRef.current) { | ||
if (mergedOpen) { | ||
var _listRef$current2; | ||
(_listRef$current2 = listRef.current).onKeyDown.apply(_listRef$current2, [event].concat(rest)); | ||
(_listRef$current2 = listRef.current) === null || _listRef$current2 === void 0 || _listRef$current2.onKeyDown.apply(_listRef$current2, [event].concat(rest)); | ||
} | ||
@@ -331,5 +338,5 @@ onKeyDown === null || onKeyDown === void 0 || onKeyDown.apply(void 0, [event].concat(rest)); | ||
} | ||
if (mergedOpen && listRef.current) { | ||
if (mergedOpen) { | ||
var _listRef$current3; | ||
(_listRef$current3 = listRef.current).onKeyUp.apply(_listRef$current3, [event].concat(rest)); | ||
(_listRef$current3 = listRef.current) === null || _listRef$current3 === void 0 || _listRef$current3.onKeyUp.apply(_listRef$current3, [event].concat(rest)); | ||
} | ||
@@ -584,5 +591,5 @@ onKeyUp === null || onKeyUp === void 0 || onKeyUp.apply(void 0, [event].concat(rest)); | ||
} | ||
}, "".concat(displayValues.map(function (_ref) { | ||
var label = _ref.label, | ||
value = _ref.value; | ||
}, "".concat(displayValues.map(function (_ref2) { | ||
var label = _ref2.label, | ||
value = _ref2.value; | ||
return ['number', 'string'].includes((0, _typeof2.default)(label)) ? label : value; | ||
@@ -589,0 +596,0 @@ }).join(', '))), selectorNode, arrowNode, mergedAllowClear && clearNode); |
@@ -74,4 +74,4 @@ "use strict"; | ||
var overMaxCount = React.useMemo(function () { | ||
return multiple && typeof maxCount !== 'undefined' && rawValues.size >= maxCount; | ||
}, [multiple, maxCount, rawValues.size]); | ||
return multiple && typeof maxCount !== 'undefined' && (rawValues === null || rawValues === void 0 ? void 0 : rawValues.size) >= maxCount; | ||
}, [multiple, maxCount, rawValues === null || rawValues === void 0 ? void 0 : rawValues.size]); | ||
var onListMouseDown = function onListMouseDown(event) { | ||
@@ -81,7 +81,6 @@ event.preventDefault(); | ||
var scrollIntoView = function scrollIntoView(args) { | ||
if (listRef.current) { | ||
listRef.current.scrollTo(typeof args === 'number' ? { | ||
index: args | ||
} : args); | ||
} | ||
var _listRef$current; | ||
(_listRef$current = listRef.current) === null || _listRef$current === void 0 || _listRef$current.scrollTo(typeof args === 'number' ? { | ||
index: args | ||
} : args); | ||
}; | ||
@@ -159,4 +158,4 @@ | ||
if (open) { | ||
var _listRef$current; | ||
(_listRef$current = listRef.current) === null || _listRef$current === void 0 || _listRef$current.scrollTo(undefined); | ||
var _listRef$current2; | ||
(_listRef$current2 = listRef.current) === null || _listRef$current2 === void 0 || _listRef$current2.scrollTo(undefined); | ||
} | ||
@@ -163,0 +162,0 @@ return function () { |
@@ -120,4 +120,4 @@ "use strict"; | ||
var clipboardData = e.clipboardData; | ||
var value = clipboardData.getData('text'); | ||
pastedTextRef.current = value; | ||
var value = clipboardData === null || clipboardData === void 0 ? void 0 : clipboardData.getData('text'); | ||
pastedTextRef.current = value || ''; | ||
}; | ||
@@ -124,0 +124,0 @@ var onClick = function onClick(_ref) { |
@@ -23,2 +23,2 @@ import type { BaseOptionType, DefaultOptionType } from '../Select'; | ||
export declare function injectPropsWithOption<T extends object>(option: T): T; | ||
export declare function getSeparatedContent(text: string, tokens: string[]): string[]; | ||
export declare const getSeparatedContent: (text: string, tokens: string[], end?: number) => string[]; |
@@ -9,3 +9,3 @@ "use strict"; | ||
exports.flattenOptions = flattenOptions; | ||
exports.getSeparatedContent = getSeparatedContent; | ||
exports.getSeparatedContent = void 0; | ||
exports.injectPropsWithOption = injectPropsWithOption; | ||
@@ -112,3 +112,3 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray")); | ||
} | ||
function getSeparatedContent(text, tokens) { | ||
var getSeparatedContent = exports.getSeparatedContent = function getSeparatedContent(text, tokens, end) { | ||
if (!tokens || !tokens.length) { | ||
@@ -118,3 +118,3 @@ return null; | ||
var match = false; | ||
function separate(str, _ref3) { | ||
var separate = function separate(str, _ref3) { | ||
var _ref4 = (0, _toArray2.default)(_ref3), | ||
@@ -130,8 +130,10 @@ token = _ref4[0], | ||
return [].concat((0, _toConsumableArray2.default)(prevList), (0, _toConsumableArray2.default)(separate(unitStr, restTokens))); | ||
}, []).filter(function (unit) { | ||
return unit; | ||
}); | ||
}, []).filter(Boolean); | ||
}; | ||
var list = separate(text, tokens); | ||
if (match) { | ||
return typeof end !== 'undefined' ? list.slice(0, end) : list; | ||
} else { | ||
return null; | ||
} | ||
var list = separate(text, tokens); | ||
return match ? list : null; | ||
} | ||
}; |
{ | ||
"name": "rc-select", | ||
"version": "14.11.0-0", | ||
"version": "14.11.0", | ||
"description": "React Select", | ||
@@ -5,0 +5,0 @@ "engines": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
336143
7336
0