@rc-component/select 1.6.15 → 1.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -83,7 +83,7 @@ export default () => (
83
83
  | dropdownAlign | additional align applied to dropdown | [AlignType](https://github.com/react-component/trigger/blob/728d7e92394aa4b3214650f743fc47e1382dfa68/src/interface.ts#L25-L80) | {} |
84
84
  | dropdownMenuStyle | additional style applied to dropdown menu | Object | React.CSSProperties |
85
85
  | notFoundContent | specify content to show when no result matches. | ReactNode | 'Not Found' |
86
- | tokenSeparators | separator used to tokenize on tag/multiple mode | string[]? | |
86
+ | tokenSeparators | separator used to tokenize on tag/multiple mode | `string[] \| ((input: string) => string[])` | |
87
87
  | open | control select open | boolean | |
88
88
  | defaultOpen | control select default open | boolean | |
89
89
  | placeholder | select placeholder | React Node | |
@@ -1,5 +1,5 @@
1
- import type { AlignType, BuildInPlacements } from '@rc-component/trigger/lib/interface';
2
- import type { ScrollConfig, ScrollTo } from '@rc-component/virtual-list/lib/List';
1
+ import type { AlignType, BuildInPlacements } from '@rc-component/trigger';
2
+ import type { ScrollConfig, ScrollTo } from '@rc-component/virtual-list';
3
3
  import * as React from 'react';
4
4
  import type { DisplayInfoType, DisplayValueType, Mode, Placement, RawValueType, RenderDOMFunc, RenderNode } from '../interface';
5
5
  import type { ComponentsConfig } from '../hooks/useComponents';
@@ -90,7 +90,7 @@ export interface BaseSelectProps extends BaseSelectPrivateProps, React.AriaAttri
90
90
  maxTagTextLength?: number;
91
91
  maxTagCount?: number | 'responsive';
92
92
  maxTagPlaceholder?: React.ReactNode | ((omittedValues: DisplayValueType[]) => React.ReactNode);
93
- tokenSeparators?: string[];
93
+ tokenSeparators?: string[] | ((input: string) => string[]);
94
94
  allowClear?: boolean | {
95
95
  clearIcon?: React.ReactNode;
96
96
  };
@@ -1,6 +1,6 @@
1
1
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
2
  import { clsx } from 'clsx';
3
- import { getDOM } from "@rc-component/util/es/Dom/findDOMNode";
3
+ import { getDOM, useEvent } from '@rc-component/util';
4
4
  import * as React from 'react';
5
5
  import { useAllowClear } from "../hooks/useAllowClear";
6
6
  import { BaseSelectContext } from "../hooks/useBaseProps";
@@ -10,7 +10,6 @@ import SelectTrigger from "../SelectTrigger";
10
10
  import { getSeparatedContent, isValidCount } from "../utils/valueUtil";
11
11
  import Polite from "./Polite";
12
12
  import useOpen, { macroTask } from "../hooks/useOpen";
13
- import { useEvent } from '@rc-component/util';
14
13
  import SelectInput from "../SelectInput";
15
14
  import useComponents from "../hooks/useComponents";
16
15
 
@@ -138,7 +137,20 @@ const BaseSelect = /*#__PURE__*/React.forwardRef((props, ref) => {
138
137
  const [rawOpen, mergedOpen, triggerOpen, lockOptions] = useOpen(defaultOpen || false, open, onPopupVisibleChange, nextOpen => disabled || emptyListContent ? false : nextOpen);
139
138
 
140
139
  // ============================= Search =============================
141
- const tokenWithEnter = React.useMemo(() => (tokenSeparators || []).some(tokenSeparator => ['\n', '\r\n'].includes(tokenSeparator)), [tokenSeparators]);
140
+ const tokenWithEnter = React.useMemo(() => typeof tokenSeparators === 'function' || (tokenSeparators || []).some(tokenSeparator => ['\n', '\r\n'].includes(tokenSeparator)), [tokenSeparators]);
141
+ const splitByTokenSeparators = React.useMemo(() => {
142
+ if (typeof tokenSeparators === 'function') {
143
+ return (input, end) => {
144
+ const tokens = tokenSeparators(input);
145
+ const isUnchanged = Array.isArray(tokens) && tokens.length === 1 && tokens[0] === input;
146
+ if (!Array.isArray(tokens) || !tokens.length || isUnchanged) {
147
+ return null;
148
+ }
149
+ return typeof end !== 'undefined' ? tokens.slice(0, end) : tokens;
150
+ };
151
+ }
152
+ return (input, end) => getSeparatedContent(input, tokenSeparators, end);
153
+ }, [tokenSeparators]);
142
154
  const onInternalSearch = (searchText, fromTyping, isCompositing) => {
143
155
  if (multiple && isValidCount(maxCount) && displayValues.length >= maxCount) {
144
156
  return;
@@ -146,10 +158,8 @@ const BaseSelect = /*#__PURE__*/React.forwardRef((props, ref) => {
146
158
  let ret = true;
147
159
  let newSearchText = searchText;
148
160
  onActiveValueChange?.(null);
149
- const separatedList = getSeparatedContent(searchText, tokenSeparators, isValidCount(maxCount) ? maxCount - displayValues.length : undefined);
150
-
151
- // Check if match the `tokenSeparators`
152
- const patchLabels = isCompositing ? null : separatedList;
161
+ const cap = isValidCount(maxCount) ? maxCount - displayValues.length : undefined;
162
+ const patchLabels = isCompositing ? null : splitByTokenSeparators(searchText, cap);
153
163
 
154
164
  // Ignore combobox since it's not split-able
155
165
  if (mode !== 'combobox' && patchLabels) {
@@ -1,4 +1,4 @@
1
- import type { ScrollConfig } from '@rc-component/virtual-list/lib/List';
1
+ import { type ScrollConfig } from '@rc-component/virtual-list';
2
2
  import * as React from 'react';
3
3
  export type OptionListProps = Record<string, never>;
4
4
  export interface RefOptionListProps {
package/es/OptionList.js CHANGED
@@ -1,9 +1,6 @@
1
1
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
2
  import { clsx } from 'clsx';
3
- import KeyCode from "@rc-component/util/es/KeyCode";
4
- import useMemo from "@rc-component/util/es/hooks/useMemo";
5
- import omit from "@rc-component/util/es/omit";
6
- import pickAttrs from "@rc-component/util/es/pickAttrs";
3
+ import { KeyCode, omit, pickAttrs, useMemo } from '@rc-component/util';
7
4
  import List from '@rc-component/virtual-list';
8
5
  import * as React from 'react';
9
6
  import { useEffect } from 'react';
package/es/Select.js CHANGED
@@ -30,8 +30,7 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
30
30
  * - `combobox` mode not support `optionLabelProp`
31
31
  */
32
32
 
33
- import useControlledState from "@rc-component/util/es/hooks/useControlledState";
34
- import warning from "@rc-component/util/es/warning";
33
+ import { useControlledState, useId, warning } from '@rc-component/util';
35
34
  import * as React from 'react';
36
35
  import BaseSelect, { isMultiple } from "./BaseSelect";
37
36
  import OptGroup from "./OptGroup";
@@ -40,7 +39,6 @@ import OptionList from "./OptionList";
40
39
  import SelectContext from "./SelectContext";
41
40
  import useCache from "./hooks/useCache";
42
41
  import useFilterOptions from "./hooks/useFilterOptions";
43
- import useId from "@rc-component/util/es/hooks/useId";
44
42
  import useOptions from "./hooks/useOptions";
45
43
  import useRefFunc from "./hooks/useRefFunc";
46
44
  import { hasValue, isComboNoValue, toArray } from "./utils/commonUtil";
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import pickAttrs from "@rc-component/util/es/pickAttrs";
2
+ import { pickAttrs } from '@rc-component/util';
3
3
  import SingleContent from "./SingleContent";
4
4
  import MultipleContent from "./MultipleContent";
5
5
  import { useSelectInputContext } from "../context";
@@ -1,9 +1,8 @@
1
1
  import * as React from 'react';
2
2
  import { clsx } from 'clsx';
3
3
  import { useSelectInputContext } from "./context";
4
- import useLayoutEffect from "@rc-component/util/es/hooks/useLayoutEffect";
4
+ import { composeRef, useLayoutEffect } from '@rc-component/util';
5
5
  import useBaseProps from "../hooks/useBaseProps";
6
- import { composeRef } from "@rc-component/util/es/ref";
7
6
  const Input = /*#__PURE__*/React.forwardRef((props, ref) => {
8
7
  const {
9
8
  onChange,
@@ -27,7 +27,7 @@ export interface SelectInputProps extends Omit<React.HTMLAttributes<HTMLDivEleme
27
27
  onSelectorRemove?: (value: DisplayValueType) => void;
28
28
  maxLength?: number;
29
29
  autoFocus?: boolean;
30
- /** Check if `tokenSeparators` contains `\n` or `\r\n` */
30
+ /** Check if tokenization should treat pasted line breaks as separators */
31
31
  tokenWithEnter?: boolean;
32
32
  className?: string;
33
33
  style?: React.CSSProperties;
@@ -4,13 +4,9 @@ import Affix from "./Affix";
4
4
  import SelectContent from "./Content";
5
5
  import SelectInputContext from "./context";
6
6
  import useBaseProps from "../hooks/useBaseProps";
7
- import { omit, useEvent } from '@rc-component/util';
8
- import KeyCode from "@rc-component/util/es/KeyCode";
7
+ import { composeRef, getDOM, KeyCode, omit, pickAttrs, useEvent } from '@rc-component/util';
9
8
  import { isValidateOpenKey } from "../utils/keyUtil";
10
9
  import { clsx } from 'clsx';
11
- import { getDOM } from "@rc-component/util/es/Dom/findDOMNode";
12
- import { composeRef } from "@rc-component/util/es/ref";
13
- import pickAttrs from "@rc-component/util/es/pickAttrs";
14
10
  const DEFAULT_OMIT_PROPS = ['value', 'onChange', 'removeIcon', 'placeholder', 'maxTagCount', 'maxTagTextLength', 'maxTagPlaceholder', 'choiceTransitionName', 'onInputKeyDown', 'onPopupScroll', 'tabIndex', 'activeValue', 'onSelectorRemove', 'focused'];
15
11
  export default /*#__PURE__*/React.forwardRef(function SelectInput(props, ref) {
16
12
  const {
@@ -1,4 +1,4 @@
1
- import type { AlignType, BuildInPlacements } from '@rc-component/trigger/lib/interface';
1
+ import { type AlignType, type BuildInPlacements } from '@rc-component/trigger';
2
2
  import * as React from 'react';
3
3
  import type { Placement, RenderDOMFunc } from './BaseSelect';
4
4
  export interface RefTriggerProps {
package/es/index.d.ts CHANGED
@@ -1,10 +1,12 @@
1
1
  import Select from './Select';
2
2
  import Option from './Option';
3
3
  import OptGroup from './OptGroup';
4
- import type { SelectProps } from './Select';
4
+ import type { BaseOptionType, DefaultOptionType, SearchConfig, SelectProps } from './Select';
5
5
  import BaseSelect from './BaseSelect';
6
6
  import type { BaseSelectProps, BaseSelectRef, BaseSelectPropsWithoutPrivate } from './BaseSelect';
7
7
  import useBaseProps from './hooks/useBaseProps';
8
+ import type { OptionProps } from './Option';
8
9
  export { Option, OptGroup, BaseSelect, useBaseProps };
10
+ export type { BaseOptionType, DefaultOptionType, OptionProps, SearchConfig };
9
11
  export type { SelectProps, BaseSelectProps, BaseSelectRef, BaseSelectPropsWithoutPrivate };
10
12
  export default Select;
@@ -1,4 +1,4 @@
1
- import KeyCode from "@rc-component/util/es/KeyCode";
1
+ import { KeyCode } from '@rc-component/util';
2
2
 
3
3
  /** keyCode Judgment function */
4
4
  export function isValidateOpenKey(currentKeyCode) {
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import toArray from "@rc-component/util/es/Children/toArray";
2
+ import { toArray } from '@rc-component/util';
3
3
  function convertNodeToOption(node) {
4
4
  const {
5
5
  key,
@@ -1,4 +1,4 @@
1
- import warning from "@rc-component/util/es/warning";
1
+ import { warning } from '@rc-component/util';
2
2
  function getKey(data, index) {
3
3
  const {
4
4
  key
@@ -1,5 +1,4 @@
1
- import toNodeArray from "@rc-component/util/es/Children/toArray";
2
- import warning, { noteOnce } from "@rc-component/util/es/warning";
1
+ import { noteOnce, toArray as toNodeArray, warning } from '@rc-component/util';
3
2
  import * as React from 'react';
4
3
  import { isMultiple } from "../BaseSelect";
5
4
  import { toArray } from "./commonUtil";
@@ -1,5 +1,5 @@
1
- import type { AlignType, BuildInPlacements } from '@rc-component/trigger/lib/interface';
2
- import type { ScrollConfig, ScrollTo } from '@rc-component/virtual-list/lib/List';
1
+ import type { AlignType, BuildInPlacements } from '@rc-component/trigger';
2
+ import type { ScrollConfig, ScrollTo } from '@rc-component/virtual-list';
3
3
  import * as React from 'react';
4
4
  import type { DisplayInfoType, DisplayValueType, Mode, Placement, RawValueType, RenderDOMFunc, RenderNode } from '../interface';
5
5
  import type { ComponentsConfig } from '../hooks/useComponents';
@@ -90,7 +90,7 @@ export interface BaseSelectProps extends BaseSelectPrivateProps, React.AriaAttri
90
90
  maxTagTextLength?: number;
91
91
  maxTagCount?: number | 'responsive';
92
92
  maxTagPlaceholder?: React.ReactNode | ((omittedValues: DisplayValueType[]) => React.ReactNode);
93
- tokenSeparators?: string[];
93
+ tokenSeparators?: string[] | ((input: string) => string[]);
94
94
  allowClear?: boolean | {
95
95
  clearIcon?: React.ReactNode;
96
96
  };
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.isMultiple = exports.default = void 0;
7
7
  var _clsx = require("clsx");
8
- var _findDOMNode = require("@rc-component/util/lib/Dom/findDOMNode");
8
+ var _util = require("@rc-component/util");
9
9
  var React = _interopRequireWildcard(require("react"));
10
10
  var _useAllowClear = require("../hooks/useAllowClear");
11
11
  var _useBaseProps = require("../hooks/useBaseProps");
@@ -15,7 +15,6 @@ var _SelectTrigger = _interopRequireDefault(require("../SelectTrigger"));
15
15
  var _valueUtil = require("../utils/valueUtil");
16
16
  var _Polite = _interopRequireDefault(require("./Polite"));
17
17
  var _useOpen = _interopRequireWildcard(require("../hooks/useOpen"));
18
- var _util = require("@rc-component/util");
19
18
  var _SelectInput = _interopRequireDefault(require("../SelectInput"));
20
19
  var _useComponents = _interopRequireDefault(require("../hooks/useComponents"));
21
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -122,7 +121,7 @@ const BaseSelect = /*#__PURE__*/React.forwardRef((props, ref) => {
122
121
  focus: containerRef.current?.focus,
123
122
  blur: containerRef.current?.blur,
124
123
  scrollTo: arg => listRef.current?.scrollTo(arg),
125
- nativeElement: (0, _findDOMNode.getDOM)(containerRef.current)
124
+ nativeElement: (0, _util.getDOM)(containerRef.current)
126
125
  }));
127
126
 
128
127
  // =========================== Components ===========================
@@ -147,7 +146,20 @@ const BaseSelect = /*#__PURE__*/React.forwardRef((props, ref) => {
147
146
  const [rawOpen, mergedOpen, triggerOpen, lockOptions] = (0, _useOpen.default)(defaultOpen || false, open, onPopupVisibleChange, nextOpen => disabled || emptyListContent ? false : nextOpen);
148
147
 
149
148
  // ============================= Search =============================
150
- const tokenWithEnter = React.useMemo(() => (tokenSeparators || []).some(tokenSeparator => ['\n', '\r\n'].includes(tokenSeparator)), [tokenSeparators]);
149
+ const tokenWithEnter = React.useMemo(() => typeof tokenSeparators === 'function' || (tokenSeparators || []).some(tokenSeparator => ['\n', '\r\n'].includes(tokenSeparator)), [tokenSeparators]);
150
+ const splitByTokenSeparators = React.useMemo(() => {
151
+ if (typeof tokenSeparators === 'function') {
152
+ return (input, end) => {
153
+ const tokens = tokenSeparators(input);
154
+ const isUnchanged = Array.isArray(tokens) && tokens.length === 1 && tokens[0] === input;
155
+ if (!Array.isArray(tokens) || !tokens.length || isUnchanged) {
156
+ return null;
157
+ }
158
+ return typeof end !== 'undefined' ? tokens.slice(0, end) : tokens;
159
+ };
160
+ }
161
+ return (input, end) => (0, _valueUtil.getSeparatedContent)(input, tokenSeparators, end);
162
+ }, [tokenSeparators]);
151
163
  const onInternalSearch = (searchText, fromTyping, isCompositing) => {
152
164
  if (multiple && (0, _valueUtil.isValidCount)(maxCount) && displayValues.length >= maxCount) {
153
165
  return;
@@ -155,10 +167,8 @@ const BaseSelect = /*#__PURE__*/React.forwardRef((props, ref) => {
155
167
  let ret = true;
156
168
  let newSearchText = searchText;
157
169
  onActiveValueChange?.(null);
158
- const separatedList = (0, _valueUtil.getSeparatedContent)(searchText, tokenSeparators, (0, _valueUtil.isValidCount)(maxCount) ? maxCount - displayValues.length : undefined);
159
-
160
- // Check if match the `tokenSeparators`
161
- const patchLabels = isCompositing ? null : separatedList;
170
+ const cap = (0, _valueUtil.isValidCount)(maxCount) ? maxCount - displayValues.length : undefined;
171
+ const patchLabels = isCompositing ? null : splitByTokenSeparators(searchText, cap);
162
172
 
163
173
  // Ignore combobox since it's not split-able
164
174
  if (mode !== 'combobox' && patchLabels) {
@@ -306,7 +316,7 @@ const BaseSelect = /*#__PURE__*/React.forwardRef((props, ref) => {
306
316
  };
307
317
 
308
318
  // ========================== Focus / Blur ==========================
309
- const getSelectElements = () => [(0, _findDOMNode.getDOM)(containerRef.current), triggerRef.current?.getPopupElement()];
319
+ const getSelectElements = () => [(0, _util.getDOM)(containerRef.current), triggerRef.current?.getPopupElement()];
310
320
 
311
321
  // Close when click on non-select element
312
322
  (0, _useSelectTriggerControl.default)(getSelectElements, mergedOpen, triggerOpen, !!mergedComponents.root);
@@ -1,4 +1,4 @@
1
- import type { ScrollConfig } from '@rc-component/virtual-list/lib/List';
1
+ import { type ScrollConfig } from '@rc-component/virtual-list';
2
2
  import * as React from 'react';
3
3
  export type OptionListProps = Record<string, never>;
4
4
  export interface RefOptionListProps {
package/lib/OptionList.js CHANGED
@@ -5,10 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _clsx = require("clsx");
8
- var _KeyCode = _interopRequireDefault(require("@rc-component/util/lib/KeyCode"));
9
- var _useMemo = _interopRequireDefault(require("@rc-component/util/lib/hooks/useMemo"));
10
- var _omit = _interopRequireDefault(require("@rc-component/util/lib/omit"));
11
- var _pickAttrs = _interopRequireDefault(require("@rc-component/util/lib/pickAttrs"));
8
+ var _util = require("@rc-component/util");
12
9
  var _virtualList = _interopRequireDefault(require("@rc-component/virtual-list"));
13
10
  var _react = _interopRequireWildcard(require("react"));
14
11
  var React = _react;
@@ -63,7 +60,7 @@ const OptionList = (_, ref) => {
63
60
  styles: contextStyles
64
61
  } = React.useContext(_SelectContext.default);
65
62
  const itemPrefixCls = `${prefixCls}-item`;
66
- const memoFlattenOptions = (0, _useMemo.default)(() => flattenOptions, [open, lockOptions], (prev, next) => next[0] && !next[1]);
63
+ const memoFlattenOptions = (0, _util.useMemo)(() => flattenOptions, [open, lockOptions], (prev, next) => next[0] && !next[1]);
67
64
 
68
65
  // =========================== List ===========================
69
66
  const listRef = React.useRef(null);
@@ -181,20 +178,20 @@ const OptionList = (_, ref) => {
181
178
  } = event;
182
179
  switch (which) {
183
180
  // >>> Arrow keys & ctrl + n/p on Mac
184
- case _KeyCode.default.N:
185
- case _KeyCode.default.P:
186
- case _KeyCode.default.UP:
187
- case _KeyCode.default.DOWN:
181
+ case _util.KeyCode.N:
182
+ case _util.KeyCode.P:
183
+ case _util.KeyCode.UP:
184
+ case _util.KeyCode.DOWN:
188
185
  {
189
186
  let offset = 0;
190
- if (which === _KeyCode.default.UP) {
187
+ if (which === _util.KeyCode.UP) {
191
188
  offset = -1;
192
- } else if (which === _KeyCode.default.DOWN) {
189
+ } else if (which === _util.KeyCode.DOWN) {
193
190
  offset = 1;
194
191
  } else if ((0, _platformUtil.isPlatformMac)() && ctrlKey) {
195
- if (which === _KeyCode.default.N) {
192
+ if (which === _util.KeyCode.N) {
196
193
  offset = 1;
197
- } else if (which === _KeyCode.default.P) {
194
+ } else if (which === _util.KeyCode.P) {
198
195
  offset = -1;
199
196
  }
200
197
  }
@@ -207,8 +204,8 @@ const OptionList = (_, ref) => {
207
204
  }
208
205
 
209
206
  // >>> Select (Tab / Enter)
210
- case _KeyCode.default.TAB:
211
- case _KeyCode.default.ENTER:
207
+ case _util.KeyCode.TAB:
208
+ case _util.KeyCode.ENTER:
212
209
  {
213
210
  // value
214
211
  const item = memoFlattenOptions[activeIndex];
@@ -227,7 +224,7 @@ const OptionList = (_, ref) => {
227
224
  }
228
225
 
229
226
  // >>> Close
230
- case _KeyCode.default.ESC:
227
+ case _util.KeyCode.ESC:
231
228
  {
232
229
  toggleOpen(false);
233
230
  if (open) {
@@ -275,7 +272,7 @@ const OptionList = (_, ref) => {
275
272
  const {
276
273
  group
277
274
  } = item;
278
- const attrs = (0, _pickAttrs.default)(itemData, true);
275
+ const attrs = (0, _util.pickAttrs)(itemData, true);
279
276
  const mergedLabel = getLabel(item);
280
277
  return item ? /*#__PURE__*/React.createElement("div", _extends({
281
278
  "aria-label": typeof mergedLabel === 'string' && !group ? mergedLabel : null
@@ -339,7 +336,7 @@ const OptionList = (_, ref) => {
339
336
  className,
340
337
  ...otherProps
341
338
  } = data;
342
- const passedProps = (0, _omit.default)(otherProps, omitFieldNameList);
339
+ const passedProps = (0, _util.omit)(otherProps, omitFieldNameList);
343
340
 
344
341
  // Option
345
342
  const selected = isSelected(value);
@@ -361,7 +358,7 @@ const OptionList = (_, ref) => {
361
358
  if (title !== undefined) {
362
359
  optionTitle = title;
363
360
  }
364
- return /*#__PURE__*/React.createElement("div", _extends({}, (0, _pickAttrs.default)(passedProps), !virtual ? getItemAriaProps(item, itemIndex) : {}, {
361
+ return /*#__PURE__*/React.createElement("div", _extends({}, (0, _util.pickAttrs)(passedProps), !virtual ? getItemAriaProps(item, itemIndex) : {}, {
365
362
  "aria-selected": virtual ? undefined : isAriaSelected(value),
366
363
  "aria-disabled": mergedDisabled,
367
364
  className: optionClassName,
package/lib/Select.js CHANGED
@@ -4,8 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _useControlledState = _interopRequireDefault(require("@rc-component/util/lib/hooks/useControlledState"));
8
- var _warning = _interopRequireDefault(require("@rc-component/util/lib/warning"));
7
+ var _util = require("@rc-component/util");
9
8
  var React = _interopRequireWildcard(require("react"));
10
9
  var _BaseSelect = _interopRequireWildcard(require("./BaseSelect"));
11
10
  var _OptGroup = _interopRequireDefault(require("./OptGroup"));
@@ -14,16 +13,15 @@ var _OptionList = _interopRequireDefault(require("./OptionList"));
14
13
  var _SelectContext = _interopRequireDefault(require("./SelectContext"));
15
14
  var _useCache = _interopRequireDefault(require("./hooks/useCache"));
16
15
  var _useFilterOptions = _interopRequireDefault(require("./hooks/useFilterOptions"));
17
- var _useId = _interopRequireDefault(require("@rc-component/util/lib/hooks/useId"));
18
16
  var _useOptions = _interopRequireDefault(require("./hooks/useOptions"));
19
17
  var _useRefFunc = _interopRequireDefault(require("./hooks/useRefFunc"));
20
18
  var _commonUtil = require("./utils/commonUtil");
21
19
  var _valueUtil = require("./utils/valueUtil");
22
20
  var _warningPropsUtil = _interopRequireWildcard(require("./utils/warningPropsUtil"));
23
21
  var _useSearchConfig = _interopRequireDefault(require("./hooks/useSearchConfig"));
22
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24
23
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
25
24
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
26
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
25
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } /**
28
26
  * To match accessibility requirement, we always provide an input in the component.
29
27
  * Other element will not set `tabIndex` to avoid `onBlur` sequence problem.
@@ -120,7 +118,7 @@ const Select = /*#__PURE__*/React.forwardRef((props, ref) => {
120
118
  if (!optionFilterProp) return [];
121
119
  return Array.isArray(optionFilterProp) ? optionFilterProp : [optionFilterProp];
122
120
  }, [optionFilterProp]);
123
- const mergedId = (0, _useId.default)(id);
121
+ const mergedId = (0, _util.useId)(id);
124
122
  const multiple = (0, _BaseSelect.isMultiple)(mode);
125
123
  const childrenAsData = !!(!options && children);
126
124
  const mergedFilterOption = React.useMemo(() => {
@@ -138,7 +136,7 @@ const Select = /*#__PURE__*/React.forwardRef((props, ref) => {
138
136
  /* eslint-enable react-hooks/exhaustive-deps */);
139
137
 
140
138
  // =========================== Search ===========================
141
- const [internalSearchValue, setSearchValue] = (0, _useControlledState.default)('', searchValue);
139
+ const [internalSearchValue, setSearchValue] = (0, _util.useControlledState)('', searchValue);
142
140
  const mergedSearchValue = internalSearchValue || '';
143
141
 
144
142
  // =========================== Option ===========================
@@ -179,7 +177,7 @@ const Select = /*#__PURE__*/React.forwardRef((props, ref) => {
179
177
  if (process.env.NODE_ENV !== 'production' && !optionLabelProp) {
180
178
  const optionLabel = option?.[mergedFieldNames.label];
181
179
  if (optionLabel !== undefined && ! /*#__PURE__*/React.isValidElement(optionLabel) && ! /*#__PURE__*/React.isValidElement(rawLabel) && optionLabel !== rawLabel) {
182
- (0, _warning.default)(false, '`label` of `value` is not same as `label` in Select options.');
180
+ (0, _util.warning)(false, '`label` of `value` is not same as `label` in Select options.');
183
181
  }
184
182
  }
185
183
  }
@@ -194,7 +192,7 @@ const Select = /*#__PURE__*/React.forwardRef((props, ref) => {
194
192
  }, [mergedFieldNames, optionLabelProp, valueOptions]);
195
193
 
196
194
  // =========================== Values ===========================
197
- const [internalValue, setInternalValue] = (0, _useControlledState.default)(defaultValue, value);
195
+ const [internalValue, setInternalValue] = (0, _util.useControlledState)(defaultValue, value);
198
196
 
199
197
  // Merged value with LabelValueType
200
198
  const rawLabeledValues = React.useMemo(() => {
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var React = _interopRequireWildcard(require("react"));
8
- var _pickAttrs = _interopRequireDefault(require("@rc-component/util/lib/pickAttrs"));
8
+ var _util = require("@rc-component/util");
9
9
  var _SingleContent = _interopRequireDefault(require("./SingleContent"));
10
10
  var _MultipleContent = _interopRequireDefault(require("./MultipleContent"));
11
11
  var _context = require("../context");
@@ -23,7 +23,7 @@ const SelectContent = /*#__PURE__*/React.forwardRef(function SelectContent(_, re
23
23
  const {
24
24
  showSearch
25
25
  } = baseProps;
26
- const ariaProps = (0, _pickAttrs.default)(baseProps, {
26
+ const ariaProps = (0, _util.pickAttrs)(baseProps, {
27
27
  aria: true
28
28
  });
29
29
  const sharedInputProps = {
@@ -7,9 +7,8 @@ exports.default = void 0;
7
7
  var React = _interopRequireWildcard(require("react"));
8
8
  var _clsx = require("clsx");
9
9
  var _context = require("./context");
10
- var _useLayoutEffect = _interopRequireDefault(require("@rc-component/util/lib/hooks/useLayoutEffect"));
10
+ var _util = require("@rc-component/util");
11
11
  var _useBaseProps = _interopRequireDefault(require("../hooks/useBaseProps"));
12
- var _ref = require("@rc-component/util/lib/ref");
13
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
13
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
15
14
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -144,7 +143,7 @@ const Input = /*#__PURE__*/React.forwardRef((props, ref) => {
144
143
  const [widthCssVar, setWidthCssVar] = React.useState(undefined);
145
144
 
146
145
  // When syncWidth is enabled, adjust input width based on content
147
- (0, _useLayoutEffect.default)(() => {
146
+ (0, _util.useLayoutEffect)(() => {
148
147
  const input = inputRef.current;
149
148
  if (syncWidth && input) {
150
149
  input.style.width = '0px';
@@ -214,7 +213,7 @@ const Input = /*#__PURE__*/React.forwardRef((props, ref) => {
214
213
  });
215
214
 
216
215
  // Update ref
217
- mergedProps.ref = (0, _ref.composeRef)(InputComponent.ref, sharedInputProps.ref);
216
+ mergedProps.ref = (0, _util.composeRef)(InputComponent.ref, sharedInputProps.ref);
218
217
  return /*#__PURE__*/React.cloneElement(InputComponent, mergedProps);
219
218
  }
220
219
 
@@ -27,7 +27,7 @@ export interface SelectInputProps extends Omit<React.HTMLAttributes<HTMLDivEleme
27
27
  onSelectorRemove?: (value: DisplayValueType) => void;
28
28
  maxLength?: number;
29
29
  autoFocus?: boolean;
30
- /** Check if `tokenSeparators` contains `\n` or `\r\n` */
30
+ /** Check if tokenization should treat pasted line breaks as separators */
31
31
  tokenWithEnter?: boolean;
32
32
  className?: string;
33
33
  style?: React.CSSProperties;
@@ -10,12 +10,8 @@ var _Content = _interopRequireDefault(require("./Content"));
10
10
  var _context = _interopRequireDefault(require("./context"));
11
11
  var _useBaseProps = _interopRequireDefault(require("../hooks/useBaseProps"));
12
12
  var _util = require("@rc-component/util");
13
- var _KeyCode = _interopRequireDefault(require("@rc-component/util/lib/KeyCode"));
14
13
  var _keyUtil = require("../utils/keyUtil");
15
14
  var _clsx = require("clsx");
16
- var _findDOMNode = require("@rc-component/util/lib/Dom/findDOMNode");
17
- var _ref = require("@rc-component/util/lib/ref");
18
- var _pickAttrs = _interopRequireDefault(require("@rc-component/util/lib/pickAttrs"));
19
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
16
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
21
17
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -78,7 +74,7 @@ var _default = exports.default = /*#__PURE__*/React.forwardRef(function SelectIn
78
74
  const isTextAreaElement = inputRef.current instanceof HTMLTextAreaElement;
79
75
 
80
76
  // Prevent default behavior for up/down arrows when dropdown is open
81
- if (!isTextAreaElement && triggerOpen && (which === _KeyCode.default.UP || which === _KeyCode.default.DOWN)) {
77
+ if (!isTextAreaElement && triggerOpen && (which === _util.KeyCode.UP || which === _util.KeyCode.DOWN)) {
82
78
  event.preventDefault();
83
79
  }
84
80
 
@@ -88,7 +84,7 @@ var _default = exports.default = /*#__PURE__*/React.forwardRef(function SelectIn
88
84
  }
89
85
 
90
86
  // Move within the text box for TextArea
91
- if (isTextAreaElement && !triggerOpen && ~[_KeyCode.default.UP, _KeyCode.default.DOWN, _KeyCode.default.LEFT, _KeyCode.default.RIGHT].indexOf(which)) {
87
+ if (isTextAreaElement && !triggerOpen && ~[_util.KeyCode.UP, _util.KeyCode.DOWN, _util.KeyCode.LEFT, _util.KeyCode.RIGHT].indexOf(which)) {
92
88
  return;
93
89
  }
94
90
 
@@ -110,14 +106,14 @@ var _default = exports.default = /*#__PURE__*/React.forwardRef(function SelectIn
110
106
  (inputRef.current || rootRef.current).blur?.();
111
107
  },
112
108
  // Use getDOM to handle nested nativeElement structure (e.g., when RootComponent is antd Input)
113
- nativeElement: (0, _findDOMNode.getDOM)(rootRef.current)
109
+ nativeElement: (0, _util.getDOM)(rootRef.current)
114
110
  };
115
111
  });
116
112
 
117
113
  // ====================== Open ======================
118
114
  const onInternalMouseDown = (0, _util.useEvent)(event => {
119
115
  if (!disabled) {
120
- const inputDOM = (0, _findDOMNode.getDOM)(inputRef.current);
116
+ const inputDOM = (0, _util.getDOM)(inputRef.current);
121
117
 
122
118
  // https://github.com/ant-design/ant-design/issues/56002
123
119
  // Tell `useSelectTriggerControl` to ignore this event
@@ -158,7 +154,7 @@ var _default = exports.default = /*#__PURE__*/React.forwardRef(function SelectIn
158
154
 
159
155
  // ===================== Render =====================
160
156
  const domProps = (0, _util.omit)(restProps, DEFAULT_OMIT_PROPS);
161
- const ariaProps = (0, _pickAttrs.default)(domProps, {
157
+ const ariaProps = (0, _util.pickAttrs)(domProps, {
162
158
  aria: true
163
159
  });
164
160
  const ariaKeys = Object.keys(ariaProps);
@@ -187,7 +183,7 @@ var _default = exports.default = /*#__PURE__*/React.forwardRef(function SelectIn
187
183
  if ( /*#__PURE__*/React.isValidElement(RootComponent)) {
188
184
  return /*#__PURE__*/React.cloneElement(RootComponent, {
189
185
  ...mergedProps,
190
- ref: (0, _ref.composeRef)(RootComponent.ref, rootRef)
186
+ ref: (0, _util.composeRef)(RootComponent.ref, rootRef)
191
187
  });
192
188
  }
193
189
  return /*#__PURE__*/React.createElement(RootComponent, _extends({}, mergedProps, {
@@ -1,4 +1,4 @@
1
- import type { AlignType, BuildInPlacements } from '@rc-component/trigger/lib/interface';
1
+ import { type AlignType, type BuildInPlacements } from '@rc-component/trigger';
2
2
  import * as React from 'react';
3
3
  import type { Placement, RenderDOMFunc } from './BaseSelect';
4
4
  export interface RefTriggerProps {
package/lib/index.d.ts CHANGED
@@ -1,10 +1,12 @@
1
1
  import Select from './Select';
2
2
  import Option from './Option';
3
3
  import OptGroup from './OptGroup';
4
- import type { SelectProps } from './Select';
4
+ import type { BaseOptionType, DefaultOptionType, SearchConfig, SelectProps } from './Select';
5
5
  import BaseSelect from './BaseSelect';
6
6
  import type { BaseSelectProps, BaseSelectRef, BaseSelectPropsWithoutPrivate } from './BaseSelect';
7
7
  import useBaseProps from './hooks/useBaseProps';
8
+ import type { OptionProps } from './Option';
8
9
  export { Option, OptGroup, BaseSelect, useBaseProps };
10
+ export type { BaseOptionType, DefaultOptionType, OptionProps, SearchConfig };
9
11
  export type { SelectProps, BaseSelectProps, BaseSelectRef, BaseSelectPropsWithoutPrivate };
10
12
  export default Select;
@@ -4,8 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.isValidateOpenKey = isValidateOpenKey;
7
- var _KeyCode = _interopRequireDefault(require("@rc-component/util/lib/KeyCode"));
8
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
7
+ var _util = require("@rc-component/util");
9
8
  /** keyCode Judgment function */
10
9
  function isValidateOpenKey(currentKeyCode) {
11
10
  return (
@@ -15,12 +14,12 @@ function isValidateOpenKey(currentKeyCode) {
15
14
  // Other keys
16
15
  ![
17
16
  // System function button
18
- _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,
17
+ _util.KeyCode.ESC, _util.KeyCode.SHIFT, _util.KeyCode.BACKSPACE, _util.KeyCode.TAB, _util.KeyCode.WIN_KEY, _util.KeyCode.ALT, _util.KeyCode.META, _util.KeyCode.WIN_KEY_RIGHT, _util.KeyCode.CTRL, _util.KeyCode.SEMICOLON, _util.KeyCode.EQUALS, _util.KeyCode.CAPS_LOCK, _util.KeyCode.CONTEXT_MENU,
19
18
  // Arrow keys - should not trigger open when navigating in input
20
- _KeyCode.default.UP,
19
+ _util.KeyCode.UP,
21
20
  // KeyCode.DOWN,
22
- _KeyCode.default.LEFT, _KeyCode.default.RIGHT,
21
+ _util.KeyCode.LEFT, _util.KeyCode.RIGHT,
23
22
  // F1-F12
24
- _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)
23
+ _util.KeyCode.F1, _util.KeyCode.F2, _util.KeyCode.F3, _util.KeyCode.F4, _util.KeyCode.F5, _util.KeyCode.F6, _util.KeyCode.F7, _util.KeyCode.F8, _util.KeyCode.F9, _util.KeyCode.F10, _util.KeyCode.F11, _util.KeyCode.F12].includes(currentKeyCode)
25
24
  );
26
25
  }
@@ -5,8 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.convertChildrenToData = convertChildrenToData;
7
7
  var React = _interopRequireWildcard(require("react"));
8
- var _toArray = _interopRequireDefault(require("@rc-component/util/lib/Children/toArray"));
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
+ var _util = require("@rc-component/util");
10
9
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
11
10
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
12
11
  function convertNodeToOption(node) {
@@ -26,7 +25,7 @@ function convertNodeToOption(node) {
26
25
  };
27
26
  }
28
27
  function convertChildrenToData(nodes, optionOnly = false) {
29
- return (0, _toArray.default)(nodes).map((node, index) => {
28
+ return (0, _util.toArray)(nodes).map((node, index) => {
30
29
  if (! /*#__PURE__*/React.isValidElement(node) || !node.type) {
31
30
  return null;
32
31
  }
@@ -8,8 +8,7 @@ exports.flattenOptions = flattenOptions;
8
8
  exports.getSeparatedContent = void 0;
9
9
  exports.injectPropsWithOption = injectPropsWithOption;
10
10
  exports.isValidCount = isValidCount;
11
- var _warning = _interopRequireDefault(require("@rc-component/util/lib/warning"));
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+ var _util = require("@rc-component/util");
13
12
  function getKey(data, index) {
14
13
  const {
15
14
  key
@@ -110,7 +109,7 @@ function injectPropsWithOption(option) {
110
109
  if (!('props' in newOption)) {
111
110
  Object.defineProperty(newOption, 'props', {
112
111
  get() {
113
- (0, _warning.default)(false, 'Return type is option instead of Option instance. Please read value directly instead of reading from `props`.');
112
+ (0, _util.warning)(false, 'Return type is option instead of Option instance. Please read value directly instead of reading from `props`.');
114
113
  return newOption;
115
114
  }
116
115
  });
@@ -5,15 +5,13 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  exports.warningNullOptions = warningNullOptions;
8
- var _toArray = _interopRequireDefault(require("@rc-component/util/lib/Children/toArray"));
9
- var _warning = _interopRequireWildcard(require("@rc-component/util/lib/warning"));
8
+ var _util = require("@rc-component/util");
10
9
  var React = _interopRequireWildcard(require("react"));
11
10
  var _BaseSelect = require("../BaseSelect");
12
11
  var _commonUtil = require("./commonUtil");
13
12
  var _legacyUtil = require("./legacyUtil");
14
13
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
15
14
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
15
  function warningProps(props) {
18
16
  const {
19
17
  mode,
@@ -36,7 +34,7 @@ function warningProps(props) {
36
34
  const mergedOptions = options || (0, _legacyUtil.convertChildrenToData)(children);
37
35
 
38
36
  // `tags` should not set option as disabled
39
- (0, _warning.default)(mode !== 'tags' || mergedOptions.every(opt => !opt.disabled), 'Please avoid setting option to disabled in tags mode since user can always type text as tag.');
37
+ (0, _util.warning)(mode !== 'tags' || mergedOptions.every(opt => !opt.disabled), 'Please avoid setting option to disabled in tags mode since user can always type text as tag.');
40
38
 
41
39
  // `combobox` & `tags` should option be `string` type
42
40
  if (mode === 'tags' || mode === 'combobox') {
@@ -46,36 +44,36 @@ function warningProps(props) {
46
44
  }
47
45
  return typeof ('value' in item ? item.value : item.key) === 'number';
48
46
  });
49
- (0, _warning.default)(!hasNumberValue, '`value` of Option should not use number type when `mode` is `tags` or `combobox`.');
47
+ (0, _util.warning)(!hasNumberValue, '`value` of Option should not use number type when `mode` is `tags` or `combobox`.');
50
48
  }
51
49
 
52
50
  // `combobox` should not use `optionLabelProp`
53
- (0, _warning.default)(mode !== 'combobox' || !optionLabelProp, '`combobox` mode not support `optionLabelProp`. Please set `value` on Option directly.');
51
+ (0, _util.warning)(mode !== 'combobox' || !optionLabelProp, '`combobox` mode not support `optionLabelProp`. Please set `value` on Option directly.');
54
52
 
55
53
  // Only `combobox` support `backfill`
56
- (0, _warning.default)(mode === 'combobox' || !backfill, '`backfill` only works with `combobox` mode.');
54
+ (0, _util.warning)(mode === 'combobox' || !backfill, '`backfill` only works with `combobox` mode.');
57
55
 
58
56
  // Only `combobox` support `getInputElement`
59
- (0, _warning.default)(mode === 'combobox' || !getInputElement, '`getInputElement` only work with `combobox` mode.');
57
+ (0, _util.warning)(mode === 'combobox' || !getInputElement, '`getInputElement` only work with `combobox` mode.');
60
58
 
61
59
  // Customize `getInputElement` should not use `allowClear` & `placeholder`
62
- (0, _warning.noteOnce)(mode !== 'combobox' || !getInputElement || !allowClear || !placeholder, 'Customize `getInputElement` should customize clear and placeholder logic instead of configuring `allowClear` and `placeholder`.');
60
+ (0, _util.noteOnce)(mode !== 'combobox' || !getInputElement || !allowClear || !placeholder, 'Customize `getInputElement` should customize clear and placeholder logic instead of configuring `allowClear` and `placeholder`.');
63
61
 
64
62
  // `onSearch` should use in `combobox` or `showSearch`
65
63
  if (onSearch && !mergedShowSearch && mode !== 'combobox' && mode !== 'tags') {
66
- (0, _warning.default)(false, '`onSearch` should work with `showSearch` instead of use alone.');
64
+ (0, _util.warning)(false, '`onSearch` should work with `showSearch` instead of use alone.');
67
65
  }
68
- (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.');
66
+ (0, _util.noteOnce)(!defaultOpen || autoFocus, '`defaultOpen` makes Select open without focus which means it will not close by click outside. You can set `autoFocus` if needed.');
69
67
  if (value !== undefined && value !== null) {
70
68
  const values = (0, _commonUtil.toArray)(value);
71
- (0, _warning.default)(!labelInValue || values.every(val => typeof val === 'object' && ('key' in val || 'value' in val)), '`value` should in shape of `{ value: string | number, label?: ReactNode }` when you set `labelInValue` to `true`');
72
- (0, _warning.default)(!multiple || Array.isArray(value), '`value` should be array when `mode` is `multiple` or `tags`');
69
+ (0, _util.warning)(!labelInValue || values.every(val => typeof val === 'object' && ('key' in val || 'value' in val)), '`value` should in shape of `{ value: string | number, label?: ReactNode }` when you set `labelInValue` to `true`');
70
+ (0, _util.warning)(!multiple || Array.isArray(value), '`value` should be array when `mode` is `multiple` or `tags`');
73
71
  }
74
72
 
75
73
  // Syntactic sugar should use correct children type
76
74
  if (children) {
77
75
  let invalidateChildType = null;
78
- (0, _toArray.default)(children).some(node => {
76
+ (0, _util.toArray)(children).some(node => {
79
77
  if (! /*#__PURE__*/React.isValidElement(node) || !node.type) {
80
78
  return false;
81
79
  }
@@ -86,7 +84,7 @@ function warningProps(props) {
86
84
  return false;
87
85
  }
88
86
  if (type.isSelectOptGroup) {
89
- const allChildrenValid = (0, _toArray.default)(node.props.children).every(subNode => {
87
+ const allChildrenValid = (0, _util.toArray)(node.props.children).every(subNode => {
90
88
  if (! /*#__PURE__*/React.isValidElement(subNode) || !node.type || subNode.type.isSelectOption) {
91
89
  return true;
92
90
  }
@@ -102,7 +100,7 @@ function warningProps(props) {
102
100
  return true;
103
101
  });
104
102
  if (invalidateChildType) {
105
- (0, _warning.default)(false, `\`children\` should be \`Select.Option\` or \`Select.OptGroup\` instead of \`${invalidateChildType.displayName || invalidateChildType.name || invalidateChildType}\`.`);
103
+ (0, _util.warning)(false, `\`children\` should be \`Select.Option\` or \`Select.OptGroup\` instead of \`${invalidateChildType.displayName || invalidateChildType.name || invalidateChildType}\`.`);
106
104
  }
107
105
  }
108
106
  }
@@ -115,7 +113,7 @@ function warningNullOptions(options, fieldNames) {
115
113
  for (let i = 0; i < optionsList.length; i++) {
116
114
  const option = optionsList[i];
117
115
  if (option[fieldNames?.value] === null) {
118
- (0, _warning.default)(false, '`value` in Select options should not be `null`.');
116
+ (0, _util.warning)(false, '`value` in Select options should not be `null`.');
119
117
  return true;
120
118
  }
121
119
  if (!inGroup && Array.isArray(option[fieldNames?.options]) && recursiveOptions(option[fieldNames?.options], true)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rc-component/select",
3
- "version": "1.6.15",
3
+ "version": "1.7.1",
4
4
  "description": "React Select",
5
5
  "engines": {
6
6
  "node": ">=8.x"
@@ -51,12 +51,12 @@
51
51
  "dependencies": {
52
52
  "@rc-component/overflow": "^1.0.0",
53
53
  "@rc-component/trigger": "^3.0.0",
54
- "@rc-component/util": "^1.3.0",
55
- "@rc-component/virtual-list": "^1.0.1",
54
+ "@rc-component/util": "^1.11.1",
55
+ "@rc-component/virtual-list": "^1.2.0",
56
56
  "clsx": "^2.1.1"
57
57
  },
58
58
  "devDependencies": {
59
- "@rc-component/father-plugin": "^2.0.2",
59
+ "@rc-component/father-plugin": "^2.2.0",
60
60
  "@rc-component/np": "^1.0.0",
61
61
  "@testing-library/jest-dom": "^6.4.5",
62
62
  "@testing-library/react": "^15.0.6",