one-design-next 0.0.64 → 0.0.66

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.
@@ -1,27 +1,27 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
- import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
4
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
5
- import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
6
- var _excluded = ["id", "prefixCls", "fieldNames", "defaultValue", "value", "changeOnSelect", "onChange", "displayRender", "checkable", "autoClearSearchValue", "searchValue", "onSearch", "showSearch", "expandTrigger", "options", "dropdownPrefixCls", "loadData", "popupVisible", "open", "popupClassName", "dropdownClassName", "dropdownMenuColumnStyle", "dropdownStyle", "popupPlacement", "placement", "onDropdownVisibleChange", "onPopupVisibleChange", "onOpenChange", "expandIcon", "loadingIcon", "children", "dropdownMatchSelectWidth", "showCheckedStrategy", "optionRender", "checkStrictly"];
7
- import { BaseSelect } from 'rc-select';
8
- import useId from "rc-select/es/hooks/useId";
9
- import useEvent from "rc-util/es/hooks/useEvent";
10
- import useMergedState from "rc-util/es/hooks/useMergedState";
11
- import * as React from 'react';
1
+ import _extends from '@babel/runtime/helpers/esm/extends';
2
+ import _objectSpread from '@babel/runtime/helpers/esm/objectSpread2';
3
+ import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
4
+ import _slicedToArray from '@babel/runtime/helpers/esm/slicedToArray';
5
+ import _toConsumableArray from '@babel/runtime/helpers/esm/toConsumableArray';
12
6
  import CascaderContext from 'rc-cascader/es/context';
13
7
  import useDisplayValues from 'rc-cascader/es/hooks/useDisplayValues';
14
8
  import useMissingValues from 'rc-cascader/es/hooks/useMissingValues';
15
9
  import useOptions from 'rc-cascader/es/hooks/useOptions';
16
10
  import useSearchConfig from 'rc-cascader/es/hooks/useSearchConfig';
17
11
  import useSearchOptions from 'rc-cascader/es/hooks/useSearchOptions';
12
+ import { fillFieldNames, SHOW_CHILD, SHOW_PARENT, toPathKeys, toRawValues } from 'rc-cascader/es/utils/commonUtil';
13
+ import { formatStrategyValues, toPathOptions } from 'rc-cascader/es/utils/treeUtil';
14
+ import warningProps, { warningNullOptions } from 'rc-cascader/es/utils/warningPropsUtil';
15
+ import { BaseSelect } from 'rc-select';
16
+ import useId from 'rc-select/es/hooks/useId';
17
+ import useEvent from 'rc-util/es/hooks/useEvent';
18
+ import useMergedState from 'rc-util/es/hooks/useMergedState';
19
+ import * as React from 'react';
18
20
  import useSelect from "./hooks/useSelect";
19
21
  import useValues from "./hooks/useValues";
20
22
  import OptionList from "./OptionList";
21
23
  import Panel from "./Panel";
22
- import { fillFieldNames, SHOW_CHILD, SHOW_PARENT, toPathKeys, toRawValues } from 'rc-cascader/es/utils/commonUtil';
23
- import { formatStrategyValues, toPathOptions } from 'rc-cascader/es/utils/treeUtil';
24
- import warningProps, { warningNullOptions } from 'rc-cascader/es/utils/warningPropsUtil';
24
+ var _excluded = ['id', 'prefixCls', 'fieldNames', 'defaultValue', 'value', 'changeOnSelect', 'onChange', 'displayRender', 'checkable', 'autoClearSearchValue', 'searchValue', 'onSearch', 'showSearch', 'showInnerSearch', 'expandTrigger', 'options', 'dropdownPrefixCls', 'loadData', 'popupVisible', 'open', 'popupClassName', 'dropdownClassName', 'dropdownMenuColumnStyle', 'dropdownStyle', 'popupPlacement', 'placement', 'onDropdownVisibleChange', 'onPopupVisibleChange', 'onOpenChange', 'expandIcon', 'loadingIcon', 'children', 'dropdownMatchSelectWidth', 'showCheckedStrategy', 'optionRender', 'checkStrictly'];
25
25
  var Cascader = /*#__PURE__*/React.forwardRef(function (props, ref) {
26
26
  var id = props.id,
27
27
  _props$prefixCls = props.prefixCls,
@@ -38,6 +38,7 @@ var Cascader = /*#__PURE__*/React.forwardRef(function (props, ref) {
38
38
  searchValue = props.searchValue,
39
39
  onSearch = props.onSearch,
40
40
  showSearch = props.showSearch,
41
+ showInnerSearch = props.showInnerSearch,
41
42
  expandTrigger = props.expandTrigger,
42
43
  options = props.options,
43
44
  dropdownPrefixCls = props.dropdownPrefixCls,
@@ -81,8 +82,7 @@ var Cascader = /*#__PURE__*/React.forwardRef(function (props, ref) {
81
82
  // ========================= FieldNames =========================
82
83
  var mergedFieldNames = React.useMemo(function () {
83
84
  return fillFieldNames(fieldNames);
84
- }, /* eslint-disable react-hooks/exhaustive-deps */
85
- [JSON.stringify(fieldNames)]
85
+ } /* eslint-disable react-hooks/exhaustive-deps */, [JSON.stringify(fieldNames)]
86
86
  /* eslint-enable react-hooks/exhaustive-deps */);
87
87
 
88
88
  // =========================== Option ===========================
@@ -231,34 +231,24 @@ var Cascader = /*#__PURE__*/React.forwardRef(function (props, ref) {
231
231
  prefixCls: prefixCls,
232
232
  autoClearSearchValue: autoClearSearchValue,
233
233
  dropdownMatchSelectWidth: dropdownMatchSelectWidth,
234
- dropdownStyle: _objectSpread(_objectSpread({}, dropdownStyle), customDropdownStyle)
234
+ dropdownStyle: _objectSpread(_objectSpread({}, dropdownStyle), customDropdownStyle),
235
235
  // Value
236
- ,
237
-
238
236
  displayValues: displayValues,
239
237
  onDisplayValuesChange: onDisplayValuesChange,
240
- mode: multiple ? 'multiple' : undefined
238
+ mode: multiple ? 'multiple' : undefined,
241
239
  // Search
242
- ,
243
-
244
240
  searchValue: mergedSearchValue,
245
241
  onSearch: onInternalSearch,
246
- showSearch: mergedShowSearch
242
+ showSearch: showInnerSearch ? false : mergedShowSearch,
247
243
  // Options
248
- ,
249
-
250
244
  OptionList: OptionList,
251
- emptyOptions: emptyOptions
245
+ emptyOptions: emptyOptions,
252
246
  // Open
253
- ,
254
-
255
247
  open: mergedOpen,
256
248
  dropdownClassName: mergedDropdownClassName,
257
249
  placement: mergedPlacement,
258
- onDropdownVisibleChange: onInternalDropdownVisibleChange
250
+ onDropdownVisibleChange: onInternalDropdownVisibleChange,
259
251
  // Children
260
- ,
261
-
262
252
  getRawInputElement: function getRawInputElement() {
263
253
  return children;
264
254
  }
@@ -15,6 +15,5 @@ export interface ColumnProps {
15
15
  loadingKeys: string[];
16
16
  isSelectable: (option: DefaultOptionType) => boolean;
17
17
  disabled?: boolean;
18
- motionEnter?: boolean;
19
18
  }
20
- export default function Column({ prefixCls, multiple, options, activeValue, prevValuePath, onToggleOpen, onSelect, onActive, checkedSet, halfCheckedSet, loadingKeys, isSelectable, disabled: propsDisabled, motionEnter, }: ColumnProps): React.JSX.Element;
19
+ export default function Column({ prefixCls, multiple, options, activeValue, prevValuePath, onToggleOpen, onSelect, onActive, checkedSet, halfCheckedSet, loadingKeys, isSelectable, disabled: propsDisabled, }: ColumnProps): React.JSX.Element;
@@ -20,8 +20,7 @@ export default function Column(_ref) {
20
20
  halfCheckedSet = _ref.halfCheckedSet,
21
21
  loadingKeys = _ref.loadingKeys,
22
22
  isSelectable = _ref.isSelectable,
23
- propsDisabled = _ref.disabled,
24
- motionEnter = _ref.motionEnter;
23
+ propsDisabled = _ref.disabled;
25
24
  var menuPrefixCls = "".concat(prefixCls, "-menu");
26
25
  var menuItemPrefixCls = "".concat(prefixCls, "-menu-item");
27
26
  var _ref2 = React.useContext(CascaderContext),
@@ -72,7 +71,7 @@ export default function Column(_ref) {
72
71
  });
73
72
  }, [options, checkedSet, fieldNames, halfCheckedSet, loadingKeys, prevValuePath]);
74
73
  return /*#__PURE__*/React.createElement("ul", {
75
- className: clsx(menuPrefixCls, _defineProperty({}, "".concat(menuPrefixCls, "-enter"), motionEnter)),
74
+ className: menuPrefixCls,
76
75
  role: "menu"
77
76
  }, optionInfoList.map(function (_ref3) {
78
77
  var disabled = _ref3.disabled,
@@ -1,18 +1,18 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
- import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
5
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
1
+ import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
2
+ import _extends from '@babel/runtime/helpers/esm/extends';
3
+ import _objectSpread from '@babel/runtime/helpers/esm/objectSpread2';
4
+ import _slicedToArray from '@babel/runtime/helpers/esm/slicedToArray';
5
+ import _toConsumableArray from '@babel/runtime/helpers/esm/toConsumableArray';
6
6
  /* eslint-disable default-case */
7
7
  import classNames from 'classnames';
8
- import * as React from 'react';
9
8
  import CascaderContext from 'rc-cascader/es/context';
9
+ import CacheContent from 'rc-cascader/es/OptionList/CacheContent';
10
+ import useKeyboard from 'rc-cascader/es/OptionList/useKeyboard';
10
11
  import { getFullPathKeys, isLeaf, scrollIntoParentView, toPathKey, toPathKeys, toPathValueStr } from 'rc-cascader/es/utils/commonUtil';
11
12
  import { toPathOptions } from 'rc-cascader/es/utils/treeUtil';
12
- import CacheContent from 'rc-cascader/es/OptionList/CacheContent';
13
+ import * as React from 'react';
13
14
  import Column, { FIX_LABEL } from "./Column";
14
15
  import useActive from "./useActive";
15
- import useKeyboard from 'rc-cascader/es/OptionList/useKeyboard';
16
16
  var RawOptionList = /*#__PURE__*/React.forwardRef(function (props, ref) {
17
17
  var _optionColumns$, _ref3, _classNames;
18
18
  var prefixCls = props.prefixCls,
@@ -180,7 +180,7 @@ var RawOptionList = /*#__PURE__*/React.forwardRef(function (props, ref) {
180
180
  var _containerRef$current;
181
181
  var cellPath = activeValueCells.slice(0, i + 1);
182
182
  var cellKeyPath = toPathKey(cellPath);
183
- var ele = (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.querySelector("li[data-path-key=\"".concat(cellKeyPath.replace(/\\{0,2}"/g, '\\"'), "\"]") // matches unescaped double quotes
183
+ var ele = (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.querySelector('li[data-path-key="'.concat(cellKeyPath.replace(/\\{0,2}"/g, '\\"'), '"]') // matches unescaped double quotes
184
184
  );
185
185
  if (ele) {
186
186
  scrollIntoParentView(ele);
@@ -191,7 +191,7 @@ var RawOptionList = /*#__PURE__*/React.forwardRef(function (props, ref) {
191
191
  // ========================== Render ==========================
192
192
  // >>>>> Empty
193
193
  var isEmpty = !((_optionColumns$ = optionColumns[0]) !== null && _optionColumns$ !== void 0 && (_optionColumns$ = _optionColumns$.options) !== null && _optionColumns$ !== void 0 && _optionColumns$.length);
194
- var emptyList = [(_ref3 = {}, _defineProperty(_ref3, fieldNames.value, '__EMPTY__'), _defineProperty(_ref3, FIX_LABEL, notFoundContent), _defineProperty(_ref3, "disabled", true), _ref3)];
194
+ var emptyList = [(_ref3 = {}, _defineProperty(_ref3, fieldNames.value, '__EMPTY__'), _defineProperty(_ref3, FIX_LABEL, notFoundContent), _defineProperty(_ref3, 'disabled', true), _ref3)];
195
195
  var columnProps = _objectSpread(_objectSpread({}, props), {}, {
196
196
  multiple: !isEmpty && multiple,
197
197
  onSelect: onPathSelect,
@@ -207,88 +207,6 @@ var RawOptionList = /*#__PURE__*/React.forwardRef(function (props, ref) {
207
207
  var mergedOptionColumns = isEmpty ? [{
208
208
  options: emptyList
209
209
  }] : optionColumns;
210
-
211
- // 面板已展开时,列数变化驱动宽度过渡;仅新增的那一列做进入动效
212
- var prevOpenRef = React.useRef(false);
213
- var prevColCountRef = React.useRef(0);
214
- var prevWidthRef = React.useRef(null);
215
- var widthMotionEndRef = React.useRef(null);
216
- var colCount = mergedOptionColumns.length;
217
- var _React$useStateEnter = React.useState(-1),
218
- _React$useStateEnter2 = _slicedToArray(_React$useStateEnter, 2),
219
- enterColumnIndex = _React$useStateEnter2[0],
220
- setEnterColumnIndex = _React$useStateEnter2[1];
221
- React.useLayoutEffect(function () {
222
- var el = containerRef.current;
223
- var wasOpen = prevOpenRef.current;
224
- var prevColCount = prevColCountRef.current;
225
- prevOpenRef.current = !!open;
226
- prevColCountRef.current = open ? colCount : 0;
227
- if (!el) {
228
- return undefined;
229
- }
230
- if (!open) {
231
- prevWidthRef.current = null;
232
- el.style.width = '';
233
- el.style.transition = '';
234
- el.style.overflow = '';
235
- setEnterColumnIndex(-1);
236
- return undefined;
237
- }
238
- var nextWidth = el.offsetWidth;
239
- var prevWidth = prevWidthRef.current;
240
- prevWidthRef.current = nextWidth;
241
- var reduceMotion = typeof window !== 'undefined' && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
242
- var timers = [];
243
- // 已展开时新增列:给新列进入动效
244
- if (wasOpen && !reduceMotion && colCount > prevColCount) {
245
- setEnterColumnIndex(colCount - 1);
246
- timers.push(window.setTimeout(function () {
247
- setEnterColumnIndex(-1);
248
- }, 220));
249
- }
250
- // 首次打开不动画,避免整板滑入;仅在已展开时宽度变化过渡
251
- if (!wasOpen || reduceMotion || prevWidth == null || prevWidth === nextWidth) {
252
- return function () {
253
- timers.forEach(function (id) {
254
- return window.clearTimeout(id);
255
- });
256
- };
257
- }
258
- if (widthMotionEndRef.current) {
259
- el.removeEventListener('transitionend', widthMotionEndRef.current);
260
- widthMotionEndRef.current = null;
261
- }
262
- el.style.transition = 'none';
263
- el.style.overflow = 'hidden';
264
- el.style.width = "".concat(prevWidth, "px");
265
- // force reflow
266
- el.offsetWidth;
267
- el.style.transition = "width var(--odn-cascader-panel-motion-duration, 0.22s) var(--odn-cascader-panel-motion-ease, cubic-bezier(0.32, 0.72, 0, 1))";
268
- el.style.width = "".concat(nextWidth, "px");
269
- var onEnd = function onEnd(event) {
270
- if (event.target !== el || event.propertyName !== 'width') {
271
- return;
272
- }
273
- el.style.width = '';
274
- el.style.transition = '';
275
- el.style.overflow = '';
276
- el.removeEventListener('transitionend', onEnd);
277
- widthMotionEndRef.current = null;
278
- prevWidthRef.current = el.offsetWidth;
279
- };
280
- widthMotionEndRef.current = onEnd;
281
- el.addEventListener('transitionend', onEnd);
282
- return function () {
283
- timers.forEach(function (id) {
284
- return window.clearTimeout(id);
285
- });
286
- el.removeEventListener('transitionend', onEnd);
287
- if (widthMotionEndRef.current === onEnd) {
288
- widthMotionEndRef.current = null;
289
- }
290
- };
291
- }, [colCount, searchValue, open, isEmpty]);
292
210
  var columnNodes = mergedOptionColumns.map(function (col, index) {
293
211
  var prevValuePath = activeValueCells.slice(0, index);
294
212
  var activeValue = activeValueCells[index];
@@ -298,16 +216,15 @@ var RawOptionList = /*#__PURE__*/React.forwardRef(function (props, ref) {
298
216
  prefixCls: mergedPrefixCls,
299
217
  options: col.options,
300
218
  prevValuePath: prevValuePath,
301
- activeValue: activeValue,
302
- motionEnter: index === enterColumnIndex
219
+ activeValue: activeValue
303
220
  }));
304
221
  });
305
222
 
306
223
  // >>>>> Render
307
224
  return /*#__PURE__*/React.createElement(CacheContent, {
308
225
  open: open
309
- }, /*#__PURE__*/React.createElement("div", {
310
- className: classNames("".concat(mergedPrefixCls, "-menus"), (_classNames = {}, _defineProperty(_classNames, "".concat(mergedPrefixCls, "-menu-empty"), isEmpty), _defineProperty(_classNames, "".concat(mergedPrefixCls, "-rtl"), rtl), _classNames)),
226
+ }, /*#__PURE__*/React.createElement('div', {
227
+ className: classNames(''.concat(mergedPrefixCls, '-menus'), (_classNames = {}, _defineProperty(_classNames, ''.concat(mergedPrefixCls, '-menu-empty'), isEmpty), _defineProperty(_classNames, ''.concat(mergedPrefixCls, '-rtl'), rtl), _classNames)),
311
228
  ref: containerRef
312
229
  }, columnNodes));
313
230
  });
@@ -1,4 +1,4 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
1
+ import _extends from '@babel/runtime/helpers/esm/extends';
2
2
  import { useBaseProps } from 'rc-select';
3
3
  import * as React from 'react';
4
4
  import RawOptionList from "./List";
@@ -1,6 +1,12 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
- import * as React from 'react';
3
2
  import CascaderContext from 'rc-cascader/es/context';
3
+ import * as React from 'react';
4
+ var getStrictActivePath = function getStrictActivePath(path) {
5
+ if (!(path !== null && path !== void 0 && path.length)) {
6
+ return [];
7
+ }
8
+ return path.slice(0, -1);
9
+ };
4
10
 
5
11
  /**
6
12
  * Control the active open options path.
@@ -17,31 +23,51 @@ var useActive = function useActive(multiple, open) {
17
23
  activeValueCells = _React$useState2[0],
18
24
  setActiveValueCells = _React$useState2[1];
19
25
  var prevOpenRef = React.useRef(open);
20
- React.useEffect(function () {
21
- var justOpened = open && !prevOpenRef.current;
22
- prevOpenRef.current = open;
26
+ var justOpened = open && !prevOpenRef.current;
27
+ prevOpenRef.current = open;
28
+ React.useLayoutEffect(function () {
23
29
  if (checkStrictly) {
24
30
  if (multiple) {
25
- // 多选:仅在打开面板时定位到选中值所在层级,勾选不重置展开路径
26
31
  if (justOpened) {
27
- var path = firstValueCells || [];
28
- setActiveValueCells(path.slice(0, -1));
32
+ setActiveValueCells(getStrictActivePath(firstValueCells));
29
33
  }
30
34
  return;
31
35
  }
32
- // 单选:打开或值变化时定位(选中后会收起面板)
33
36
  if (open) {
34
- var _path = firstValueCells || [];
35
- setActiveValueCells(_path.slice(0, -1));
37
+ setActiveValueCells(getStrictActivePath(firstValueCells));
36
38
  }
37
39
  return;
38
40
  }
39
- if (!multiple) {
41
+ if (!multiple && (justOpened || open)) {
40
42
  setActiveValueCells(firstValueCells || []);
41
43
  }
42
- },
43
- // eslint-disable-next-line react-hooks/exhaustive-deps
44
- [open, firstValueCells, checkStrictly, multiple]);
45
- return [activeValueCells, setActiveValueCells];
44
+ }, [open, firstValueCells, checkStrictly, multiple, justOpened]);
45
+
46
+ // 打开首帧即用目标路径渲染列,避免弹层先窄后宽导致定位跳动
47
+ var mergedActiveValueCells = React.useMemo(function () {
48
+ if (!open) {
49
+ return activeValueCells;
50
+ }
51
+ if (checkStrictly) {
52
+ if (justOpened) {
53
+ return getStrictActivePath(firstValueCells);
54
+ }
55
+ if (activeValueCells.length > 0) {
56
+ return activeValueCells;
57
+ }
58
+ return getStrictActivePath(firstValueCells);
59
+ }
60
+ if (multiple) {
61
+ return activeValueCells;
62
+ }
63
+ if (justOpened) {
64
+ return firstValueCells || [];
65
+ }
66
+ if (activeValueCells.length > 0) {
67
+ return activeValueCells;
68
+ }
69
+ return firstValueCells || [];
70
+ }, [activeValueCells, checkStrictly, firstValueCells, justOpened, multiple, open]);
71
+ return [mergedActiveValueCells, setActiveValueCells];
46
72
  };
47
73
  export default useActive;
@@ -1,16 +1,16 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
1
+ import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
2
+ import _slicedToArray from '@babel/runtime/helpers/esm/slicedToArray';
3
3
  import classNames from 'classnames';
4
- import { useEvent, useMergedState } from 'rc-util';
5
- import * as React from 'react';
6
4
  import CascaderContext from 'rc-cascader/es/context';
7
5
  import useMissingValues from 'rc-cascader/es/hooks/useMissingValues';
8
6
  import useOptions from 'rc-cascader/es/hooks/useOptions';
7
+ import { fillFieldNames, toRawValues } from 'rc-cascader/es/utils/commonUtil';
8
+ import { toPathOptions } from 'rc-cascader/es/utils/treeUtil';
9
+ import { useEvent, useMergedState } from 'rc-util';
10
+ import * as React from 'react';
9
11
  import useSelect from "./hooks/useSelect";
10
12
  import useValues from "./hooks/useValues";
11
13
  import RawOptionList from "./OptionList/List";
12
- import { fillFieldNames, toRawValues } from 'rc-cascader/es/utils/commonUtil';
13
- import { toPathOptions } from 'rc-cascader/es/utils/treeUtil';
14
14
  function noop() {}
15
15
  export default function Panel(props) {
16
16
  var _classNames;
@@ -54,8 +54,7 @@ export default function Panel(props) {
54
54
  // ========================= FieldNames =========================
55
55
  var mergedFieldNames = React.useMemo(function () {
56
56
  return fillFieldNames(fieldNames);
57
- }, /* eslint-disable react-hooks/exhaustive-deps */
58
- [JSON.stringify(fieldNames)]
57
+ } /* eslint-disable react-hooks/exhaustive-deps */, [JSON.stringify(fieldNames)]
59
58
  /* eslint-enable react-hooks/exhaustive-deps */);
60
59
 
61
60
  // =========================== Option ===========================
@@ -121,16 +120,16 @@ export default function Panel(props) {
121
120
  }, [mergedOptions, mergedFieldNames, checkedValues, halfCheckedValues, mergedChangeOnSelect, onInternalSelect, checkable, checkStrictly, loadData, expandTrigger, expandIcon, loadingIcon]);
122
121
 
123
122
  // ========================= Render =========================
124
- var panelPrefixCls = "".concat(prefixCls, "-panel");
123
+ var panelPrefixCls = ''.concat(prefixCls, '-panel');
125
124
  var isEmpty = !mergedOptions.length;
126
125
  return /*#__PURE__*/React.createElement(CascaderContext.Provider, {
127
126
  value: cascaderContext
128
- }, /*#__PURE__*/React.createElement("div", {
129
- className: classNames(panelPrefixCls, (_classNames = {}, _defineProperty(_classNames, "".concat(panelPrefixCls, "-rtl"), direction === 'rtl'), _defineProperty(_classNames, "".concat(panelPrefixCls, "-empty"), isEmpty), _classNames), className),
127
+ }, /*#__PURE__*/React.createElement('div', {
128
+ className: classNames(panelPrefixCls, (_classNames = {}, _defineProperty(_classNames, ''.concat(panelPrefixCls, '-rtl'), direction === 'rtl'), _defineProperty(_classNames, ''.concat(panelPrefixCls, '-empty'), isEmpty), _classNames), className),
130
129
  style: style
131
130
  }, isEmpty ? notFoundContent : /*#__PURE__*/React.createElement(RawOptionList, {
132
131
  prefixCls: prefixCls,
133
- searchValue: "",
132
+ searchValue: '',
134
133
  multiple: multiple,
135
134
  toggleOpen: noop,
136
135
  open: true,
@@ -1,7 +1,4 @@
1
- import type {
2
- CascaderProps,
3
- DefaultOptionType,
4
- } from 'rc-cascader';
1
+ import type { CascaderProps, DefaultOptionType } from 'rc-cascader';
5
2
  import type * as React from 'react';
6
3
 
7
4
  export { SHOW_CHILD, SHOW_PARENT } from 'rc-cascader';
@@ -12,6 +9,8 @@ export type ForkCascaderProps<
12
9
  Multiple extends boolean | React.ReactNode = false,
13
10
  > = CascaderProps<OptionType, ValueField, Multiple> & {
14
11
  checkStrictly?: boolean;
12
+ /** 下拉内搜索:为 true 时不占用 selector 内的搜索后缀宽度 */
13
+ showInnerSearch?: boolean;
15
14
  };
16
15
 
17
16
  type CascaderComponent = (<
@@ -3,7 +3,6 @@ import React from 'react';
3
3
  import '../select/style';
4
4
  import CascaderPanel from './Panel';
5
5
  import './style';
6
- import { type ExpandDirection } from './utils';
7
6
  export interface BaseCascaderProps extends Omit<RcCascaderProps<DefaultOptionType, 'value', false>, 'prefixCls' | 'onChange' | 'value' | 'defaultValue' | 'showCheckedStrategy' | 'changeOnSelect'> {
8
7
  /** 组件尺寸 */
9
8
  size?: 'small' | 'medium' | 'large';
@@ -52,14 +51,6 @@ export interface BaseCascaderProps extends Omit<RcCascaderProps<DefaultOptionTyp
52
51
  * 点击选项或勾选控件选中,仅点击展开图标展开下一级;多选时父子节点选择互不影响(无半选)。
53
52
  */
54
53
  crossLevelSelect?: boolean;
55
- /**
56
- * 弹层生长方向(不影响列阅读顺序,层级始终从左到右加深,展开 Icon 不翻转):
57
- * - `ltr` 左对齐,整体向右生长
58
- * - `rtl` 右对齐,整体向左生长(避免靠右时超出屏幕)
59
- * - `auto` 根据 selector 相对视口位置自动选择
60
- * `crossLevelSelect` 时默认 `auto`,否则默认 `ltr`。
61
- */
62
- expandDirection?: ExpandDirection;
63
54
  }
64
55
  export type CascaderProps<V = (string | number)[] | null> = BaseCascaderProps & {
65
56
  mode?: 'single' | 'multiple';
@@ -1,13 +1,12 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _typeof from "@babel/runtime/helpers/esm/typeof";
3
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
4
3
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
5
5
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
6
6
  import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
7
- var _excluded = ["size", "disabled", "placeholder", "allowClear", "showSearch", "className", "style", "light", "visible", "onVisibleChange", "onChange", "value", "defaultValue", "suffixIcon", "mode", "options", "optionPopoverProps", "showInnerSearch", "searchValue", "onSearch", "autoClearSearchValue", "searchFilter", "searchRender", "searchLimit", "notFoundContent", "showCheckedStrategy", "displayRender", "dropdownClassName", "dropdownMatchSelectWidth", "separator", "optionRender", "changeOnSelect", "crossLevelSelect", "expandDirection", "maxTagCount", "maxTagPlaceholder", "direction", "placement", "getPopupContainer"];
7
+ var _excluded = ["size", "disabled", "placeholder", "allowClear", "showSearch", "className", "style", "light", "visible", "onVisibleChange", "onChange", "value", "defaultValue", "suffixIcon", "mode", "options", "optionPopoverProps", "showInnerSearch", "searchValue", "onSearch", "autoClearSearchValue", "searchFilter", "searchRender", "searchLimit", "notFoundContent", "showCheckedStrategy", "displayRender", "dropdownClassName", "dropdownMatchSelectWidth", "separator", "optionRender", "changeOnSelect", "crossLevelSelect", "maxTagCount", "maxTagPlaceholder", "direction", "placement", "getPopupContainer"];
8
8
  import clsx from 'clsx';
9
9
  import React, { useEffect, useMemo, useRef, useState } from 'react';
10
- import { flushSync } from 'react-dom';
11
10
  import Icon from "../icon";
12
11
  import "../select/style";
13
12
  import useIcons from "../select/useIcons";
@@ -16,7 +15,7 @@ import RcCascader, { SHOW_CHILD, SHOW_PARENT } from "./fork";
16
15
  import CascaderPanel from "./Panel";
17
16
  import SelectedSummary from "./SelectedSummary";
18
17
  import "./style";
19
- import { calculateOptionsDepth, DEFAULT_FIELD_NAMES, getExpandBuiltinPlacements, processOptions, resolveExpandDirection } from "./utils";
18
+ import { DEFAULT_FIELD_NAMES, processOptions } from "./utils";
20
19
  function getPathLeafLabel(path, optionList, valueField, childrenField) {
21
20
  var current = optionList;
22
21
  var leaf;
@@ -104,7 +103,6 @@ function CascaderInner(_ref) {
104
103
  changeOnSelectProp = _ref.changeOnSelect,
105
104
  _ref$crossLevelSelect = _ref.crossLevelSelect,
106
105
  crossLevelSelect = _ref$crossLevelSelect === void 0 ? false : _ref$crossLevelSelect,
107
- expandDirectionProp = _ref.expandDirection,
108
106
  maxTagCountProp = _ref.maxTagCount,
109
107
  maxTagPlaceholderProp = _ref.maxTagPlaceholder,
110
108
  directionProp = _ref.direction,
@@ -115,13 +113,6 @@ function CascaderInner(_ref) {
115
113
  var showInnerSearch = showInnerSearchProp !== null && showInnerSearchProp !== void 0 ? showInnerSearchProp : crossLevelSelect;
116
114
  // 跨层级多选:勾选后不自动清空搜索,避免搜索结果被收起
117
115
  var autoClearSearchValue = autoClearSearchValueProp !== null && autoClearSearchValueProp !== void 0 ? autoClearSearchValueProp : !(crossLevelSelect && mode === 'multiple');
118
- // 跨层级默认按位置自动适配展开方向
119
- var expandDirection = expandDirectionProp !== null && expandDirectionProp !== void 0 ? expandDirectionProp : crossLevelSelect ? 'auto' : 'ltr';
120
- var instanceId = React.useId().replace(/:/g, '');
121
- var _useState = useState(expandDirection === 'rtl' ? 'rtl' : 'ltr'),
122
- _useState2 = _slicedToArray(_useState, 2),
123
- resolvedDirection = _useState2[0],
124
- setResolvedDirection = _useState2[1];
125
116
 
126
117
  // 默认 fieldNames.label 为 labelWithPopover,下拉展示带 Popover 的节点,用户传入的 label 保留
127
118
  var mergedFieldNames = React.useMemo(function () {
@@ -149,37 +140,6 @@ function CascaderInner(_ref) {
149
140
  var processedOptions = React.useMemo(function () {
150
141
  return processOptions(options, mergedFieldNames, optionPopoverProps);
151
142
  }, [options, mergedFieldNames, optionPopoverProps]);
152
- var optionsDepth = useMemo(function () {
153
- return calculateOptionsDepth(processedOptions, mergedFieldNames);
154
- }, [processedOptions, mergedFieldNames]);
155
-
156
- // expandDirection 只控制弹层锚点(靠右时向左生长),列阅读顺序始终从左到右、层级加深向右
157
- var panelExpandSide = expandDirection === 'auto' ? resolvedDirection : expandDirection;
158
- var mergedDirection = directionProp !== null && directionProp !== void 0 ? directionProp : 'ltr';
159
-
160
- /**
161
- * rtl:弹层右对齐 trigger、向左生长。打开前(pointerdown / onOpenChange)
162
- * 已算好方向,配合 bottomRight + adjustX:0 避免首帧横向跳动。
163
- * 弹层默认仍挂 document.body(不传 getPopupContainer 时)。
164
- */
165
- var mergedPlacement = placementProp !== null && placementProp !== void 0 ? placementProp : panelExpandSide === 'rtl' ? 'bottomRight' : 'bottomLeft';
166
- var builtinPlacements = useMemo(function () {
167
- return getExpandBuiltinPlacements();
168
- }, []);
169
- var syncAutoExpandDirection = function syncAutoExpandDirection() {
170
- var _ref2, _root$querySelector;
171
- if (expandDirection !== 'auto') {
172
- return;
173
- }
174
- var root = document.querySelector(".odn-cascader-uid-".concat(instanceId));
175
- var selector = (_ref2 = (_root$querySelector = root === null || root === void 0 ? void 0 : root.querySelector('.odn-select-selector')) !== null && _root$querySelector !== void 0 ? _root$querySelector : root) !== null && _ref2 !== void 0 ? _ref2 : null;
176
- var nextDirection = resolveExpandDirection(selector, optionsDepth);
177
- flushSync(function () {
178
- setResolvedDirection(function (prev) {
179
- return prev === nextDirection ? prev : nextDirection;
180
- });
181
- });
182
- };
183
143
  var prefixCls = 'odn-select';
184
144
  var _useIcons = useIcons(_objectSpread(_objectSpread({}, restProps), {}, {
185
145
  hasFeedback: false,
@@ -191,44 +151,17 @@ function CascaderInner(_ref) {
191
151
  suffixIcon = _useIcons.suffixIcon,
192
152
  removeIcon = _useIcons.removeIcon,
193
153
  clearIcon = _useIcons.clearIcon;
194
- var cascaderClassName = [prefixCls, "".concat(prefixCls, "-").concat(size), disabled && "".concat(prefixCls, "-disabled"), light && "".concat(prefixCls, "-light"), !light && "".concat(prefixCls, "-outlined"), "".concat(prefixCls, "-show-arrow"), showInnerSearch && "".concat(prefixCls, "-show-inner-search"), 'odn-cascader', crossLevelSelect && 'odn-cascader-cross-level', "odn-cascader-uid-".concat(instanceId), panelExpandSide === 'rtl' && 'odn-cascader-expand-rtl', className].filter(Boolean).join(' ');
195
- var _useState3 = useState(visibleProp),
154
+ var cascaderClassName = [prefixCls, "".concat(prefixCls, "-").concat(size), disabled && "".concat(prefixCls, "-disabled"), light && "".concat(prefixCls, "-light"), !light && "".concat(prefixCls, "-outlined"), "".concat(prefixCls, "-show-arrow"), showInnerSearch && "".concat(prefixCls, "-show-inner-search"), 'odn-cascader', crossLevelSelect && 'odn-cascader-cross-level', className].filter(Boolean).join(' ');
155
+ var _useState = useState(visibleProp),
156
+ _useState2 = _slicedToArray(_useState, 2),
157
+ visible = _useState2[0],
158
+ setVisible = _useState2[1];
159
+ var _useState3 = useState(searchValueProp || ''),
196
160
  _useState4 = _slicedToArray(_useState3, 2),
197
- visible = _useState4[0],
198
- setVisible = _useState4[1];
199
- var _useState5 = useState(searchValueProp || ''),
200
- _useState6 = _slicedToArray(_useState5, 2),
201
- searchValue = _useState6[0],
202
- setSearchValue = _useState6[1];
161
+ searchValue = _useState4[0],
162
+ setSearchValue = _useState4[1];
203
163
  var dropdownSearchInputRef = useRef(null);
204
- useEffect(function () {
205
- if (expandDirection === 'ltr' || expandDirection === 'rtl') {
206
- setResolvedDirection(expandDirection);
207
- }
208
- }, [expandDirection]);
209
-
210
- // 在打开前(pointerdown)就算好 auto 方向,避免打开后再切换 rtl class / placement
211
- useEffect(function () {
212
- if (expandDirection !== 'auto') {
213
- return undefined;
214
- }
215
- var root = document.querySelector(".odn-cascader-uid-".concat(instanceId));
216
- if (!root) {
217
- return undefined;
218
- }
219
- var onPointerDown = function onPointerDown() {
220
- syncAutoExpandDirection();
221
- };
222
- root.addEventListener('pointerdown', onPointerDown, true);
223
- return function () {
224
- root.removeEventListener('pointerdown', onPointerDown, true);
225
- };
226
- // eslint-disable-next-line react-hooks/exhaustive-deps -- 仅在关键参数变化时重绑
227
- }, [expandDirection, instanceId, optionsDepth]);
228
164
  var handleVisibleChange = function handleVisibleChange(bool) {
229
- if (bool && expandDirection === 'auto') {
230
- syncAutoExpandDirection();
231
- }
232
165
  if (visibleProp === undefined) {
233
166
  setVisible(bool);
234
167
  }
@@ -315,8 +248,11 @@ function CascaderInner(_ref) {
315
248
  return optionList;
316
249
  };
317
250
  var mergedShowSearch = React.useMemo(function () {
251
+ if (!showInnerSearch && !showSearch) {
252
+ return false;
253
+ }
318
254
  if (!showInnerSearch) {
319
- return showInnerSearch;
255
+ return showSearch;
320
256
  }
321
257
  var searchConfig = {
322
258
  filter: searchFilter || function (inputValue, path) {
@@ -328,8 +264,8 @@ function CascaderInner(_ref) {
328
264
  limit: searchLimit
329
265
  };
330
266
  return searchConfig;
331
- }, [showInnerSearch, searchFilter, searchRender, searchLimit]);
332
- var commonProps = _objectSpread(_objectSpread(_objectSpread({}, restProps), {}, {
267
+ }, [showInnerSearch, showSearch, searchFilter, searchRender, searchLimit]);
268
+ var commonProps = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, restProps), {}, {
333
269
  fieldNames: mergedFieldNames,
334
270
  prefixCls: prefixCls,
335
271
  disabled: disabled,
@@ -394,14 +330,15 @@ function CascaderInner(_ref) {
394
330
  optionRender: optionRenderProp,
395
331
  changeOnSelect: !!changeOnSelectProp || crossLevelSelect,
396
332
  checkStrictly: crossLevelSelect,
333
+ showInnerSearch: showInnerSearch,
397
334
  maxTagCount: mergedMaxTagCount,
398
- maxTagPlaceholder: mergedMaxTagPlaceholder,
399
- direction: mergedDirection,
400
- placement: mergedPlacement
401
- }, getPopupContainerProp ? {
335
+ maxTagPlaceholder: mergedMaxTagPlaceholder
336
+ }, directionProp ? {
337
+ direction: directionProp
338
+ } : {}), placementProp ? {
339
+ placement: placementProp
340
+ } : {}), getPopupContainerProp ? {
402
341
  getPopupContainer: getPopupContainerProp
403
- } : {}), panelExpandSide === 'rtl' ? {
404
- builtinPlacements: builtinPlacements
405
342
  } : {});
406
343
  var dropdownRender = showInnerSearch ? function (menu) {
407
344
  var searchNode = /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
@@ -3,8 +3,6 @@ html {
3
3
  --odn-cascader-control-width: 184px;
4
4
  --odn-cascader-control-item-width: 200px;
5
5
  --odn-cascader-dropdown-height: 232px;
6
- --odn-cascader-panel-motion-duration: 0.22s;
7
- --odn-cascader-panel-motion-ease: cubic-bezier(0.32, 0.72, 0, 1);
8
6
  --odn-cascader-option-selected-bg: var(--odn-color-blue-1);
9
7
  --odn-cascader-option-selected-font-weight: 400;
10
8
  --odn-cascader-option-padding-block: 7px;
@@ -15,6 +13,7 @@ html {
15
13
  --odn-cascader-panel-border-radius: 6px;
16
14
  }
17
15
 
16
+ /* stylelint-disable no-descending-specificity, no-duplicate-selectors */
18
17
  .odn-cascader {
19
18
  width: var(--odn-cascader-control-width);
20
19
  }
@@ -12,51 +12,3 @@ export declare const DEFAULT_FIELD_NAMES: FieldNames;
12
12
  export declare const processOptions: (options: DefaultOptionType[] | undefined, fieldNames?: FieldNames, optionPopoverProps?: Record<string, unknown>) => DefaultOptionType[] | undefined;
13
13
  export declare const calculateOptionsDepth: (options: DefaultOptionType[] | undefined, fieldNames?: FieldNames) => number;
14
14
  export declare const generateCommonStyle: (depth: number, autoMaxWidth: boolean, customStyle?: React.CSSProperties) => React.CSSProperties;
15
- export type ExpandDirection = 'ltr' | 'rtl' | 'auto';
16
- /**
17
- * Cascader 自管水平锚点(expandDirection),关闭 adjustX,
18
- * 避免 Trigger 首帧按溢出翻转后再纠正造成「先错后对」。
19
- */
20
- export declare const getExpandBuiltinPlacements: () => {
21
- bottomLeft: {
22
- points: [string, string];
23
- offset: number[];
24
- overflow: {
25
- adjustX: number;
26
- adjustY: number;
27
- };
28
- htmlRegion: "scroll";
29
- };
30
- bottomRight: {
31
- points: [string, string];
32
- offset: number[];
33
- overflow: {
34
- adjustX: number;
35
- adjustY: number;
36
- };
37
- htmlRegion: "scroll";
38
- };
39
- topLeft: {
40
- points: [string, string];
41
- offset: number[];
42
- overflow: {
43
- adjustX: number;
44
- adjustY: number;
45
- };
46
- htmlRegion: "scroll";
47
- };
48
- topRight: {
49
- points: [string, string];
50
- offset: number[];
51
- overflow: {
52
- adjustX: number;
53
- adjustY: number;
54
- };
55
- htmlRegion: "scroll";
56
- };
57
- };
58
- /**
59
- * 根据 selector 相对视口的位置,决定弹层左对齐向右生长(ltr)
60
- * 还是右对齐向左生长(rtl)。列阅读顺序始终从左到右。
61
- */
62
- export declare const resolveExpandDirection: (triggerEl: Element | null | undefined, depth: number, columnMinWidth?: number) => 'ltr' | 'rtl';
@@ -47,7 +47,7 @@ export var processOptions = function processOptions(options, fieldNames, optionP
47
47
  });
48
48
 
49
49
  // 记录一个自定义的固定的属性,用以处理 search 逻辑
50
- processedOption['labelForSearch'] = displayContent != null && (typeof displayContent === 'string' || typeof displayContent === 'number') ? String(displayContent) : '';
50
+ processedOption['labelForSearch'] = displayContent !== null && displayContent !== undefined && (typeof displayContent === 'string' || typeof displayContent === 'number') ? String(displayContent) : '';
51
51
 
52
52
  // 递归处理 children
53
53
  var childrenField = (fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.children) || 'children';
@@ -96,75 +96,4 @@ export var generateCommonStyle = function generateCommonStyle(depth, autoMaxWidt
96
96
  return _objectSpread({
97
97
  '--odn-cascader-panel-column-flex': autoMaxWidth ? "0 0 ".concat(100 / depth, "%") : '1 1 0%'
98
98
  }, customStyle);
99
- };
100
- var DEFAULT_COLUMN_MIN_WIDTH = 200;
101
-
102
- /**
103
- * Cascader 自管水平锚点(expandDirection),关闭 adjustX,
104
- * 避免 Trigger 首帧按溢出翻转后再纠正造成「先错后对」。
105
- */
106
- export var getExpandBuiltinPlacements = function getExpandBuiltinPlacements() {
107
- var adjustX = 0;
108
- var adjustY = 1;
109
- return {
110
- bottomLeft: {
111
- points: ['tl', 'bl'],
112
- offset: [0, 4],
113
- overflow: {
114
- adjustX: adjustX,
115
- adjustY: adjustY
116
- },
117
- htmlRegion: 'scroll'
118
- },
119
- bottomRight: {
120
- points: ['tr', 'br'],
121
- offset: [0, 4],
122
- overflow: {
123
- adjustX: adjustX,
124
- adjustY: adjustY
125
- },
126
- htmlRegion: 'scroll'
127
- },
128
- topLeft: {
129
- points: ['bl', 'tl'],
130
- offset: [0, -4],
131
- overflow: {
132
- adjustX: adjustX,
133
- adjustY: adjustY
134
- },
135
- htmlRegion: 'scroll'
136
- },
137
- topRight: {
138
- points: ['br', 'tr'],
139
- offset: [0, -4],
140
- overflow: {
141
- adjustX: adjustX,
142
- adjustY: adjustY
143
- },
144
- htmlRegion: 'scroll'
145
- }
146
- };
147
- };
148
-
149
- /**
150
- * 根据 selector 相对视口的位置,决定弹层左对齐向右生长(ltr)
151
- * 还是右对齐向左生长(rtl)。列阅读顺序始终从左到右。
152
- */
153
- export var resolveExpandDirection = function resolveExpandDirection(triggerEl, depth) {
154
- var columnMinWidth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DEFAULT_COLUMN_MIN_WIDTH;
155
- if (!triggerEl || typeof window === 'undefined') {
156
- return 'ltr';
157
- }
158
- var rect = triggerEl.getBoundingClientRect();
159
- var columns = Math.max(1, Math.min(depth, 4));
160
- var neededWidth = columns * columnMinWidth;
161
- var spaceRight = window.innerWidth - rect.left;
162
- var spaceLeft = rect.right;
163
- if (spaceRight >= neededWidth) {
164
- return 'ltr';
165
- }
166
- if (spaceLeft > spaceRight) {
167
- return 'rtl';
168
- }
169
- return 'ltr';
170
99
  };
@@ -14,7 +14,7 @@ import Icon from "../icon";
14
14
  import Popover from "../popover";
15
15
  import SelectFeedback from "./SelectFeedback";
16
16
  import "./style";
17
- import { formatTokenPasteFeedback, readClipboardText, resolveTokenPaste, splitByTokenSeparators, toRawValueList } from "./tokenUtils";
17
+ import { countValidValues, formatTokenPasteFeedback, readClipboardText, resolveTokenPaste, splitByTokenSeparators, toRawValueList } from "./tokenUtils";
18
18
  import useIcons from "./useIcons";
19
19
  var InternalSelect = function InternalSelect(props, ref) {
20
20
  var className = props.className,
@@ -332,7 +332,7 @@ var InternalSelect = function InternalSelect(props, ref) {
332
332
  var suffixIconFinal = typeof _suffixIcon === 'function' ? _suffixIcon(suffixIconProps) : _suffixIcon;
333
333
  return /*#__PURE__*/React.createElement(React.Fragment, null, !!maxCount && mode === 'multiple' && Array.isArray(value) && /*#__PURE__*/React.createElement("span", {
334
334
  className: "odn-select-max-count"
335
- }, value.length, " / ", maxCount), suffixIconFinal);
335
+ }, countValidValues(toRawValueList(value), invalidValues), " /", ' ', maxCount), suffixIconFinal);
336
336
  },
337
337
  menuItemSelectedIcon: mode === 'multiple' ? function (iconProps) {
338
338
  var optionDisabled = iconProps.disabled,
@@ -5,6 +5,13 @@ html {
5
5
  --odn-select-border-radius-sm: 4px;
6
6
  --odn-select-internal_fixed_item_margin: 2px;
7
7
  --odn-select-multiple-item-height: 22px;
8
+ --odn-select-multiple-selector-max-height: calc(
9
+ 8px + 5 *
10
+ (
11
+ var(--odn-select-multiple-item-height) +
12
+ var(--odn-select-internal_fixed_item_margin) * 4
13
+ )
14
+ );
8
15
  --odn-select-multiple-item-bg: var(--odn-color-black-1);
9
16
  --odn-select-multiple-item-border-color: var(--odn-color-border);
10
17
  --odn-select-popup-padding-block: 8px;
@@ -567,6 +574,11 @@ html {
567
574
  display: inline-flex;
568
575
  }
569
576
 
577
+ .odn-select-multiple .odn-select-selection-overflow-item > span {
578
+ max-width: 100%;
579
+ min-width: 0;
580
+ }
581
+
570
582
  .odn-select-multiple .odn-select-selection-overflow .odn-select-selection-item {
571
583
  display: flex;
572
584
  align-self: center;
@@ -625,12 +637,35 @@ html {
625
637
 
626
638
  .odn-select-multiple .odn-select-selector {
627
639
  display: flex;
628
- align-items: center;
640
+ align-items: flex-start;
629
641
  width: 100%;
630
- height: 100%;
631
642
  padding-inline: 12px;
632
643
  padding-block: 4px;
633
644
  border-radius: var(--odn-select-border-radius);
645
+ max-height: var(--odn-select-multiple-selector-max-height);
646
+ overflow-x: hidden;
647
+ overflow-y: auto;
648
+ }
649
+ .odn-select-multiple .odn-select-selector::-webkit-scrollbar {
650
+ width: 14px;
651
+ height: 14px;
652
+ }
653
+ .odn-select-multiple .odn-select-selector::-webkit-scrollbar-thumb {
654
+ min-width: 14px;
655
+ min-height: 14px;
656
+ background-color: rgba(0, 0, 0, 0.1);
657
+ background-clip: content-box;
658
+ border: 4px solid transparent;
659
+ border-radius: 14px;
660
+ }
661
+ .odn-select-multiple .odn-select-selector::-webkit-scrollbar-track {
662
+ background-color: rgba(0, 0, 0, 0);
663
+ }
664
+ .odn-select-multiple .odn-select-selector::-webkit-scrollbar-thumb:hover {
665
+ background-color: rgba(0, 0, 0, 0.2);
666
+ }
667
+ .odn-select-multiple .odn-select-selector::-webkit-scrollbar-thumb:active {
668
+ background-color: rgba(0, 0, 0, 0.3);
634
669
  }
635
670
 
636
671
  .odn-select-disabled.odn-select-multiple .odn-select-selector {
@@ -801,12 +836,35 @@ html {
801
836
 
802
837
  .odn-select-multiple.odn-select-sm .odn-select-selector {
803
838
  display: flex;
804
- align-items: center;
839
+ align-items: flex-start;
805
840
  width: 100%;
806
- height: 100%;
807
841
  padding-inline: 12px;
808
842
  padding-block: max(max(var(--odn-padding-xxs) - 1px, 0px) - var(--odn-select-internal_fixed_item_margin), 0px);
809
843
  border-radius: var(--odn-select-border-radius-sm);
844
+ max-height: var(--odn-select-multiple-selector-max-height);
845
+ overflow-x: hidden;
846
+ overflow-y: auto;
847
+ }
848
+ .odn-select-multiple.odn-select-sm .odn-select-selector::-webkit-scrollbar {
849
+ width: 14px;
850
+ height: 14px;
851
+ }
852
+ .odn-select-multiple.odn-select-sm .odn-select-selector::-webkit-scrollbar-thumb {
853
+ min-width: 14px;
854
+ min-height: 14px;
855
+ background-color: rgba(0, 0, 0, 0.1);
856
+ background-clip: content-box;
857
+ border: 4px solid transparent;
858
+ border-radius: 14px;
859
+ }
860
+ .odn-select-multiple.odn-select-sm .odn-select-selector::-webkit-scrollbar-track {
861
+ background-color: rgba(0, 0, 0, 0);
862
+ }
863
+ .odn-select-multiple.odn-select-sm .odn-select-selector::-webkit-scrollbar-thumb:hover {
864
+ background-color: rgba(0, 0, 0, 0.2);
865
+ }
866
+ .odn-select-multiple.odn-select-sm .odn-select-selector::-webkit-scrollbar-thumb:active {
867
+ background-color: rgba(0, 0, 0, 0.3);
810
868
  }
811
869
 
812
870
  .odn-select-disabled.odn-select-multiple.odn-select-sm .odn-select-selector {
@@ -983,12 +1041,35 @@ html {
983
1041
 
984
1042
  .odn-select-multiple.odn-select-lg .odn-select-selector {
985
1043
  display: flex;
986
- align-items: center;
1044
+ align-items: flex-start;
987
1045
  width: 100%;
988
- height: 100%;
989
1046
  padding-inline: 12px;
990
1047
  padding-block: max(max(var(--odn-padding-xxs) - 1px, 0px) - var(--odn-select-internal_fixed_item_margin), 0px);
991
1048
  border-radius: var(--odn-select-border-radius-lg);
1049
+ max-height: var(--odn-select-multiple-selector-max-height);
1050
+ overflow-x: hidden;
1051
+ overflow-y: auto;
1052
+ }
1053
+ .odn-select-multiple.odn-select-lg .odn-select-selector::-webkit-scrollbar {
1054
+ width: 14px;
1055
+ height: 14px;
1056
+ }
1057
+ .odn-select-multiple.odn-select-lg .odn-select-selector::-webkit-scrollbar-thumb {
1058
+ min-width: 14px;
1059
+ min-height: 14px;
1060
+ background-color: rgba(0, 0, 0, 0.1);
1061
+ background-clip: content-box;
1062
+ border: 4px solid transparent;
1063
+ border-radius: 14px;
1064
+ }
1065
+ .odn-select-multiple.odn-select-lg .odn-select-selector::-webkit-scrollbar-track {
1066
+ background-color: rgba(0, 0, 0, 0);
1067
+ }
1068
+ .odn-select-multiple.odn-select-lg .odn-select-selector::-webkit-scrollbar-thumb:hover {
1069
+ background-color: rgba(0, 0, 0, 0.2);
1070
+ }
1071
+ .odn-select-multiple.odn-select-lg .odn-select-selector::-webkit-scrollbar-thumb:active {
1072
+ background-color: rgba(0, 0, 0, 0.3);
992
1073
  }
993
1074
 
994
1075
  .odn-select-disabled.odn-select-multiple.odn-select-lg .odn-select-selector {
@@ -1795,6 +1876,7 @@ html {
1795
1876
  }
1796
1877
 
1797
1878
  .odn-select-selection-overflow-item-rest > span {
1879
+ max-width: 100%;
1798
1880
  min-width: 0;
1799
1881
  }
1800
1882
 
@@ -23,6 +23,8 @@ export declare function readClipboardText(clipboardData: DataTransfer | null): s
23
23
  export declare function splitByTokenSeparators(text: string, separators: string[]): string[] | null;
24
24
  export declare function flattenSelectOptions(options?: DefaultOptionType[]): DefaultOptionType[];
25
25
  export declare function matchOptionByToken(token: string, options: DefaultOptionType[]): DefaultOptionType | null;
26
+ /** 有效选中数:不含 invalid chip(未匹配保留项) */
27
+ export declare function countValidValues(values: RawValue[], invalid: RawValue[]): number;
26
28
  export declare function toRawValueList(value: unknown): RawValue[];
27
29
  export declare function resolveTokenPaste(params: {
28
30
  tokens: string[];
@@ -63,6 +63,17 @@ export function matchOptionByToken(token, options) {
63
63
  return String(value).toLowerCase() === normalized || String(label !== null && label !== void 0 ? label : '').toLowerCase() === normalized;
64
64
  })) !== null && _flat$find !== void 0 ? _flat$find : null;
65
65
  }
66
+
67
+ /** 有效选中数:不含 invalid chip(未匹配保留项) */
68
+ export function countValidValues(values, invalid) {
69
+ if (!invalid.length) {
70
+ return values.length;
71
+ }
72
+ var invalidSet = new Set(invalid.map(String));
73
+ return values.filter(function (v) {
74
+ return !invalidSet.has(String(v));
75
+ }).length;
76
+ }
66
77
  export function toRawValueList(value) {
67
78
  if (value === undefined || value === null || value === '') {
68
79
  return [];
@@ -136,23 +147,23 @@ function _resolveTokenPaste() {
136
147
  while (1) switch (_context.prev = _context.next) {
137
148
  case 0:
138
149
  item = _step.value;
139
- if (!(typeof maxCount === 'number' && nextValue.length >= maxCount)) {
140
- _context.next = 3;
141
- break;
142
- }
143
- return _context.abrupt("return", 0);
144
- case 3:
145
150
  if (!item.valid) {
146
151
  _context.next = 13;
147
152
  break;
148
153
  }
154
+ if (!(typeof maxCount === 'number' && countValidValues(nextValue, nextInvalid) >= maxCount)) {
155
+ _context.next = 4;
156
+ break;
157
+ }
158
+ return _context.abrupt("return", 0);
159
+ case 4:
149
160
  _value = (_item$value = item.value) !== null && _item$value !== void 0 ? _item$value : item.token;
150
161
  if (!hasValue(_value)) {
151
162
  _context.next = 8;
152
163
  break;
153
164
  }
154
165
  duplicated.push(item.token);
155
- return _context.abrupt("return", 1);
166
+ return _context.abrupt("return", 0);
156
167
  case 8:
157
168
  nextValue.push(_value);
158
169
  added.push(_value);
@@ -163,7 +174,7 @@ function _resolveTokenPaste() {
163
174
  if (idx >= 0) {
164
175
  nextInvalid.splice(idx, 1);
165
176
  }
166
- return _context.abrupt("return", 1);
177
+ return _context.abrupt("return", 0);
167
178
  case 13:
168
179
  // 未匹配
169
180
  invalid.push(item.token);
@@ -171,7 +182,7 @@ function _resolveTokenPaste() {
171
182
  _context.next = 16;
172
183
  break;
173
184
  }
174
- return _context.abrupt("return", 1);
185
+ return _context.abrupt("return", 0);
175
186
  case 16:
176
187
  value = (_item$value2 = item.value) !== null && _item$value2 !== void 0 ? _item$value2 : item.token;
177
188
  if (!hasValue(value)) {
@@ -179,7 +190,7 @@ function _resolveTokenPaste() {
179
190
  break;
180
191
  }
181
192
  duplicated.push(item.token);
182
- return _context.abrupt("return", 1);
193
+ return _context.abrupt("return", 0);
183
194
  case 20:
184
195
  nextValue.push(value);
185
196
  added.push(value);
@@ -197,7 +208,7 @@ function _resolveTokenPaste() {
197
208
  _iterator.s();
198
209
  case 19:
199
210
  if ((_step = _iterator.n()).done) {
200
- _context2.next = 28;
211
+ _context2.next = 26;
201
212
  break;
202
213
  }
203
214
  return _context2.delegateYield(_loop(), "t1", 21);
@@ -207,28 +218,22 @@ function _resolveTokenPaste() {
207
218
  _context2.next = 24;
208
219
  break;
209
220
  }
210
- return _context2.abrupt("break", 28);
221
+ return _context2.abrupt("continue", 24);
211
222
  case 24:
212
- if (!(_ret === 1)) {
213
- _context2.next = 26;
214
- break;
215
- }
216
- return _context2.abrupt("continue", 26);
217
- case 26:
218
223
  _context2.next = 19;
219
224
  break;
220
- case 28:
221
- _context2.next = 33;
225
+ case 26:
226
+ _context2.next = 31;
222
227
  break;
223
- case 30:
224
- _context2.prev = 30;
228
+ case 28:
229
+ _context2.prev = 28;
225
230
  _context2.t2 = _context2["catch"](16);
226
231
  _iterator.e(_context2.t2);
227
- case 33:
228
- _context2.prev = 33;
232
+ case 31:
233
+ _context2.prev = 31;
229
234
  _iterator.f();
230
- return _context2.finish(33);
231
- case 36:
235
+ return _context2.finish(31);
236
+ case 34:
232
237
  return _context2.abrupt("return", {
233
238
  added: added,
234
239
  duplicated: duplicated,
@@ -236,11 +241,11 @@ function _resolveTokenPaste() {
236
241
  nextValue: nextValue,
237
242
  nextInvalid: nextInvalid
238
243
  });
239
- case 37:
244
+ case 35:
240
245
  case "end":
241
246
  return _context2.stop();
242
247
  }
243
- }, _callee, null, [[16, 30, 33, 36]]);
248
+ }, _callee, null, [[16, 28, 31, 34]]);
244
249
  }));
245
250
  return _resolveTokenPaste.apply(this, arguments);
246
251
  }
@@ -243,12 +243,14 @@ a[disabled] {
243
243
  pointer-events: none;
244
244
  }
245
245
 
246
- [data-scrollbar-custom]::-webkit-scrollbar {
246
+ [data-scrollbar-custom]::-webkit-scrollbar,
247
+ .scrollbar-custom::-webkit-scrollbar {
247
248
  width: 14px;
248
249
  height: 14px;
249
250
  }
250
251
 
251
- [data-scrollbar-custom]::-webkit-scrollbar-thumb {
252
+ [data-scrollbar-custom]::-webkit-scrollbar-thumb,
253
+ .scrollbar-custom::-webkit-scrollbar-thumb {
252
254
  min-width: 14px;
253
255
  min-height: 14px;
254
256
  background-color: rgba(0, 0, 0, 10%);
@@ -257,15 +259,18 @@ a[disabled] {
257
259
  border-radius: 14px;
258
260
  }
259
261
 
260
- [data-scrollbar-custom]::-webkit-scrollbar-track {
262
+ [data-scrollbar-custom]::-webkit-scrollbar-track,
263
+ .scrollbar-custom::-webkit-scrollbar-track {
261
264
  background-color: rgba(0, 0, 0, 0%);
262
265
  }
263
266
 
264
- [data-scrollbar-custom]::-webkit-scrollbar-thumb:hover {
267
+ [data-scrollbar-custom]::-webkit-scrollbar-thumb:hover,
268
+ .scrollbar-custom::-webkit-scrollbar-thumb:hover {
265
269
  background-color: rgba(0, 0, 0, 20%);
266
270
  }
267
271
 
268
- [data-scrollbar-custom]::-webkit-scrollbar-thumb:active {
272
+ [data-scrollbar-custom]::-webkit-scrollbar-thumb:active,
273
+ .scrollbar-custom::-webkit-scrollbar-thumb:active {
269
274
  background-color: rgba(0, 0, 0, 30%);
270
275
  }
271
276
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "one-design-next",
3
- "version": "0.0.64",
3
+ "version": "0.0.66",
4
4
  "description": "One Design Next from TAD@tencent.com",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -56,10 +56,6 @@
56
56
  "*.{md,json}": [
57
57
  "prettier --write --no-error-on-unmatched-pattern"
58
58
  ],
59
- "{components,test}/**/*.{css,scss}": [
60
- "stylelint --fix",
61
- "prettier --write"
62
- ],
63
59
  "{components,test}/**/*.{js,jsx}": [
64
60
  "eslint --fix",
65
61
  "prettier --write"