@apdesign/web-react 1.1.3 → 1.3.0

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.
@@ -55,6 +55,12 @@ export interface SelectProps extends SelectViewCommonProps {
55
55
  * @en Whether to embed label in value, turn the format of value from string to `{ value: string, label: ReactNode }`
56
56
  */
57
57
  labelInValue?: boolean;
58
+ /**
59
+ * @zh 是否开启快速单选模式。开启后,由于需要最后点击确定或者取消来选择,单个选项变化的事件 onSelect 和 onDeselect 将无效
60
+ * @en Whether to enable quick single selection mode. When enabled, the onSelect and onDeselect events will be invalid because the selection needs to be confirmed or canceled at the end.
61
+ * @defaultValue true
62
+ */
63
+ isQuickSingleSelectMode?: boolean;
58
64
  /**
59
65
  * @zh 是否根据输入的值筛选数据。如果传入函数的话,接收 `inputValue` 和 `option` 两个参数,当option符合筛选条件时,返回 `true`,反之返回 `false`。
60
66
  * @en If it's true, filter options by input value. If it's a function, filter options base on the function.
@@ -245,6 +251,8 @@ export interface OptionProps extends Omit<HTMLAttributes<HTMLLIElement>, 'classN
245
251
  extra?: any;
246
252
  isSelectOption?: boolean;
247
253
  _isMultipleMode?: boolean;
254
+ _isMultipleQuickSelectMode?: boolean;
255
+ _onSingleQuickSelect?: (value: OptionProps['value']) => void;
248
256
  _isUserCreatedOption?: boolean;
249
257
  _isUserCreatingOption?: boolean;
250
258
  _valueActive?: OptionProps['value'];
@@ -10,6 +10,25 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
16
+ }) : (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ o[k2] = m[k];
19
+ }));
20
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
21
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
22
+ }) : function(o, v) {
23
+ o["default"] = v;
24
+ });
25
+ var __importStar = (this && this.__importStar) || function (mod) {
26
+ if (mod && mod.__esModule) return mod;
27
+ var result = {};
28
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
29
+ __setModuleDefault(result, mod);
30
+ return result;
31
+ };
13
32
  var __rest = (this && this.__rest) || function (s, e) {
14
33
  var t = {};
15
34
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
@@ -21,17 +40,34 @@ var __rest = (this && this.__rest) || function (s, e) {
21
40
  }
22
41
  return t;
23
42
  };
43
+ var __read = (this && this.__read) || function (o, n) {
44
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
45
+ if (!m) return o;
46
+ var i = m.call(o), r, ar = [], e;
47
+ try {
48
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
49
+ }
50
+ catch (error) { e = { error: error }; }
51
+ finally {
52
+ try {
53
+ if (r && !r.done && (m = i["return"])) m.call(i);
54
+ }
55
+ finally { if (e) throw e.error; }
56
+ }
57
+ return ar;
58
+ };
24
59
  var __importDefault = (this && this.__importDefault) || function (mod) {
25
60
  return (mod && mod.__esModule) ? mod : { "default": mod };
26
61
  };
27
62
  Object.defineProperty(exports, "__esModule", { value: true });
28
- var react_1 = __importDefault(require("react"));
63
+ var react_1 = __importStar(require("react"));
29
64
  var classNames_1 = __importDefault(require("../_util/classNames"));
30
65
  var Checkbox_1 = __importDefault(require("../Checkbox"));
31
66
  var omit_1 = __importDefault(require("../_util/omit"));
32
67
  function Option(props, ref) {
33
68
  var _a, _b;
34
- var style = props.style, className = props.className, wrapperClassName = props.wrapperClassName, disabled = props.disabled, prefixCls = props.prefixCls, rtl = props.rtl, propValue = props.value, propChildren = props.children, _isMultipleMode = props._isMultipleMode, _isUserCreatedOption = props._isUserCreatedOption, _isUserCreatingOption = props._isUserCreatingOption, _valueActive = props._valueActive, _valueSelect = props._valueSelect, _onMouseEnter = props._onMouseEnter, _onMouseLeave = props._onMouseLeave, _onClick = props._onClick, rest = __rest(props, ["style", "className", "wrapperClassName", "disabled", "prefixCls", "rtl", "value", "children", "_isMultipleMode", "_isUserCreatedOption", "_isUserCreatingOption", "_valueActive", "_valueSelect", "_onMouseEnter", "_onMouseLeave", "_onClick"]);
69
+ var style = props.style, className = props.className, wrapperClassName = props.wrapperClassName, disabled = props.disabled, prefixCls = props.prefixCls, rtl = props.rtl, propValue = props.value, propChildren = props.children, _isMultipleMode = props._isMultipleMode, _isMultipleQuickSelectMode = props._isMultipleQuickSelectMode, _onSingleQuickSelect = props._onSingleQuickSelect, _isUserCreatedOption = props._isUserCreatedOption, _isUserCreatingOption = props._isUserCreatingOption, _valueActive = props._valueActive, _valueSelect = props._valueSelect, _onMouseEnter = props._onMouseEnter, _onMouseLeave = props._onMouseLeave, _onClick = props._onClick, rest = __rest(props, ["style", "className", "wrapperClassName", "disabled", "prefixCls", "rtl", "value", "children", "_isMultipleMode", "_isMultipleQuickSelectMode", "_onSingleQuickSelect", "_isUserCreatedOption", "_isUserCreatingOption", "_valueActive", "_valueSelect", "_onMouseEnter", "_onMouseLeave", "_onClick"]);
70
+ var _c = __read((0, react_1.useState)(false), 2), isHovering = _c[0], setIsHovering = _c[1];
35
71
  var value = 'value' in props ? propValue : "" + propChildren;
36
72
  var childNode = 'children' in props ? propChildren : "" + propValue;
37
73
  var isChecked = _isMultipleMode
@@ -66,9 +102,34 @@ function Option(props, ref) {
66
102
  return (react_1.default.createElement("li", __assign({}, wrapperProps, { className: (0, classNames_1.default)(prefixCls + "-option-wrapper", (_b = {},
67
103
  _b[prefixCls + "-option-wrapper-selected"] = isChecked,
68
104
  _b[prefixCls + "-option-wrapper-disabled"] = disabled,
69
- _b), wrapperClassName) }),
105
+ _b), wrapperClassName) }, (_isMultipleQuickSelectMode && {
106
+ // TODO: 这个等主题处理好了要改成 css ,包括以下内联样式
107
+ onMouseEnter: function () { return setIsHovering(true); },
108
+ onMouseLeave: function () { return setIsHovering(false); },
109
+ style: {
110
+ position: 'relative',
111
+ },
112
+ })),
70
113
  react_1.default.createElement(Checkbox_1.default, { "aria-hidden": "true", className: prefixCls + "-checkbox", checked: isChecked, disabled: disabled, onChange: optionLabelProps.onClick }),
71
- react_1.default.createElement("span", __assign({}, optionLabelProps), childNode)));
114
+ react_1.default.createElement("div", { style: {
115
+ display: 'flex',
116
+ flex: 1,
117
+ alignItems: 'center',
118
+ overflow: 'hidden',
119
+ } },
120
+ react_1.default.createElement("span", __assign({}, optionLabelProps), childNode),
121
+ _isMultipleQuickSelectMode && !disabled && (react_1.default.createElement("span", { style: {
122
+ display: isHovering ? 'inline' : 'none',
123
+ flex: 0,
124
+ backgroundColor: 'rgb(var(--primary-6))',
125
+ cursor: 'pointer',
126
+ color: 'white',
127
+ padding: '7px',
128
+ paddingLeft: '20px',
129
+ marginLeft: '-20px',
130
+ clipPath: 'polygon(12px 50%, 0% 0%, 100% 0%, 100% 100%, 0% 100%)',
131
+ whiteSpace: 'nowrap',
132
+ }, onClick: function () { return _onSingleQuickSelect === null || _onSingleQuickSelect === void 0 ? void 0 : _onSingleQuickSelect(value); } }, "\u4EC5\u7B5B\u9009\u6B64\u9879")))));
72
133
  }
73
134
  return (react_1.default.createElement("li", __assign({}, wrapperProps, optionLabelProps), childNode));
74
135
  }
@@ -86,6 +86,7 @@ var ConfigProvider_1 = require("../ConfigProvider");
86
86
  var useMergeValue_1 = __importDefault(require("../_util/hooks/useMergeValue"));
87
87
  var omit_1 = __importDefault(require("../_util/omit"));
88
88
  var useMergeProps_1 = __importDefault(require("../_util/hooks/useMergeProps"));
89
+ var index_1 = require("../index");
89
90
  var useId_1 = __importDefault(require("../_util/hooks/useId"));
90
91
  // 用户创建中的option的origin标识
91
92
  var USER_CREATING_OPTION_ORIGIN = 'userCreatingOption';
@@ -94,13 +95,14 @@ var defaultProps = {
94
95
  bordered: true,
95
96
  filterOption: true,
96
97
  unmountOnExit: true,
98
+ isQuickSingleSelectMode: true,
97
99
  defaultActiveFirstOption: true,
98
100
  };
99
101
  var triggerPopupAlign = { bottom: 4 };
100
102
  function Select(baseProps, ref) {
101
103
  var _a = (0, react_1.useContext)(ConfigProvider_1.ConfigContext), getPrefixCls = _a.getPrefixCls, renderEmpty = _a.renderEmpty, componentConfig = _a.componentConfig, rtl = _a.rtl;
102
104
  var props = (0, useMergeProps_1.default)(baseProps, defaultProps, componentConfig === null || componentConfig === void 0 ? void 0 : componentConfig.Select);
103
- var children = props.children, renderFormat = props.renderFormat, defaultActiveFirstOption = props.defaultActiveFirstOption, disabled = props.disabled, unmountOnExit = props.unmountOnExit, notFoundContent = props.notFoundContent, showSearch = props.showSearch, tokenSeparators = props.tokenSeparators, options = props.options, filterOption = props.filterOption, labelInValue = props.labelInValue, getPopupContainer = props.getPopupContainer, trigger = props.trigger, triggerElement = props.triggerElement, triggerProps = props.triggerProps, dropdownRender = props.dropdownRender, dropdownMenuStyle = props.dropdownMenuStyle, dropdownMenuClassName = props.dropdownMenuClassName, virtualListProps = props.virtualListProps,
105
+ var children = props.children, renderFormat = props.renderFormat, defaultActiveFirstOption = props.defaultActiveFirstOption, disabled = props.disabled, unmountOnExit = props.unmountOnExit, notFoundContent = props.notFoundContent, showSearch = props.showSearch, tokenSeparators = props.tokenSeparators, options = props.options, filterOption = props.filterOption, labelInValue = props.labelInValue, getPopupContainer = props.getPopupContainer, isQuickSingleSelectMode = props.isQuickSingleSelectMode, trigger = props.trigger, triggerElement = props.triggerElement, triggerProps = props.triggerProps, dropdownRender = props.dropdownRender, dropdownMenuStyle = props.dropdownMenuStyle, dropdownMenuClassName = props.dropdownMenuClassName, virtualListProps = props.virtualListProps,
104
106
  // events
105
107
  onChange = props.onChange, onSelect = props.onSelect, onDeselect = props.onDeselect, onClear = props.onClear, onSearch = props.onSearch, onFocus = props.onFocus, onBlur = props.onBlur, onPopupScroll = props.onPopupScroll, onVisibleChange = props.onVisibleChange, onInputValueChange = props.onInputValueChange, onPaste = props.onPaste, onKeyDown = props.onKeyDown;
106
108
  // TODO 兼容逻辑,3.0 移除 tags 模式
@@ -112,35 +114,42 @@ function Select(baseProps, ref) {
112
114
  }
113
115
  var prefixCls = getPrefixCls('select');
114
116
  var isMultipleMode = mode === 'multiple';
117
+ var isMultipleQuickSelectMode = isMultipleMode && isQuickSingleSelectMode;
115
118
  // TODO: 统一 useMergeValue 函数的表现
116
119
  var _b = __read((0, react_1.useState)((0, utils_1.getValidValue)(props.defaultValue, isMultipleMode, labelInValue)), 2), stateValue = _b[0], setValue = _b[1];
117
- var value = 'value' in props ? (0, utils_1.getValidValue)(props.value, isMultipleMode, labelInValue) : stateValue;
118
- var _c = __read((0, useMergeValue_1.default)('', {
120
+ var _c = __read((0, react_1.useState)((0, utils_1.getValidValue)(props.defaultValue, isMultipleMode, labelInValue)), 2), stateProxyValue = _c[0], setProxyValue = _c[1];
121
+ var value = 'value' in props
122
+ ? (0, utils_1.getValidValue)(props.value, isMultipleMode, labelInValue)
123
+ : isMultipleQuickSelectMode
124
+ ? stateProxyValue
125
+ : stateValue;
126
+ var valueForInputShow = 'value' in props ? (0, utils_1.getValidValue)(props.value, isMultipleMode, labelInValue) : stateValue;
127
+ var _d = __read((0, useMergeValue_1.default)('', {
119
128
  value: 'inputValue' in props ? props.inputValue || '' : undefined,
120
- }), 3), inputValue = _c[0], setInputValue = _c[1], stateInputValue = _c[2];
121
- var _d = __read((0, useMergeValue_1.default)(false, {
129
+ }), 3), inputValue = _d[0], setInputValue = _d[1], stateInputValue = _d[2];
130
+ var _e = __read((0, useMergeValue_1.default)(false, {
122
131
  defaultValue: props.defaultPopupVisible,
123
132
  value: 'popupVisible' in props
124
133
  ? props.popupVisible
125
134
  : triggerProps && 'popupVisible' in triggerProps
126
135
  ? triggerProps.popupVisible
127
136
  : undefined,
128
- }), 2), popupVisible = _d[0], setPopupVisible = _d[1];
137
+ }), 2), popupVisible = _e[0], setPopupVisible = _e[1];
129
138
  // allowCreate 时,用户正在创建的选项值
130
- var _e = __read((0, react_1.useState)(null), 2), userCreatingOption = _e[0], setUserCreatingOption = _e[1];
139
+ var _f = __read((0, react_1.useState)(null), 2), userCreatingOption = _f[0], setUserCreatingOption = _f[1];
131
140
  // allowCreate 时,由用户输入而扩展到选项中的值
132
- var _f = __read((0, react_1.useState)([]), 2), userCreatedOptions = _f[0], setUserCreatedOptions = _f[1];
141
+ var _g = __read((0, react_1.useState)([]), 2), userCreatedOptions = _g[0], setUserCreatedOptions = _g[1];
133
142
  // 具有选中态或者 hover 态的 option 的 value
134
- var _g = __read((0, react_1.useState)((0, is_1.isArray)(value) ? value[0] : value), 2), valueActive = _g[0], setValueActive = _g[1];
143
+ var _h = __read((0, react_1.useState)((0, is_1.isArray)(value) ? value[0] : value), 2), valueActive = _h[0], setValueActive = _h[1];
135
144
  // 缓存较为耗时的 flatChildren 的结果
136
- var _h = (0, react_1.useMemo)(function () {
145
+ var _j = (0, react_1.useMemo)(function () {
137
146
  return (0, utils_1.flatChildren)({ children: children, options: options, filterOption: filterOption }, {
138
147
  prefixCls: prefixCls,
139
148
  inputValue: inputValue,
140
149
  userCreatedOptions: userCreatedOptions,
141
150
  userCreatingOption: userCreatingOption,
142
151
  });
143
- }, [children, options, filterOption, inputValue, userCreatingOption, userCreatedOptions]), childrenList = _h.childrenList, optionInfoMap = _h.optionInfoMap, optionValueList = _h.optionValueList, optionIndexListForArrowKey = _h.optionIndexListForArrowKey, hasOptGroup = _h.hasOptGroup, hasComplexLabelInOptions = _h.hasComplexLabelInOptions;
152
+ }, [children, options, filterOption, inputValue, userCreatingOption, userCreatedOptions]), childrenList = _j.childrenList, optionInfoMap = _j.optionInfoMap, optionValueList = _j.optionValueList, optionIndexListForArrowKey = _j.optionIndexListForArrowKey, hasOptGroup = _j.hasOptGroup, hasComplexLabelInOptions = _j.hasComplexLabelInOptions;
144
153
  // ref
145
154
  var refWrapper = (0, react_1.useRef)(null);
146
155
  var refTrigger = (0, react_1.useRef)(null);
@@ -218,10 +227,12 @@ function Select(baseProps, ref) {
218
227
  if (isMultipleMode) {
219
228
  if (!Array.isArray(value)) {
220
229
  setValue(value === undefined ? [] : [value]);
230
+ setProxyValue(value === undefined ? [] : [value]);
221
231
  }
222
232
  }
223
233
  else if (Array.isArray(value)) {
224
234
  setValue(value.length === 0 ? undefined : value[0]);
235
+ setProxyValue(value.length === 0 ? undefined : value[0]);
225
236
  }
226
237
  }, [isMultipleMode, value]);
227
238
  // 选项下拉框显示/隐藏时的一些自动行为
@@ -395,21 +406,50 @@ function Select(baseProps, ref) {
395
406
  onChange(paramsForCallback.value, paramsForCallback.option);
396
407
  }
397
408
  };
398
- // 多选时,选择/取消选择一个选项
399
- var checkOption = function (optionValue, operation) {
409
+ var tryUpdateProxySelectValue = function (value) {
410
+ setProxyValue(value);
411
+ };
412
+ // 多选时,选择/取消选择一个选项。 fromTag 为 true 时,表示从input tag标签触发取消选择
413
+ var checkOption = function (optionValue, operation, fromTag) {
414
+ if (fromTag === void 0) { fromTag = false; }
400
415
  // 取消选中时不需要检查option是否存在,因为可能已被外部剔除了此选项
401
416
  if (operation === 'remove' || (operation === 'add' && optionInfoMap.get(optionValue))) {
402
417
  var newValue = operation === 'add'
403
418
  ? value.concat(optionValue)
404
419
  : value.filter(function (v) { return v !== optionValue; });
405
420
  var callbackToTrigger = operation === 'add' ? onSelect : onDeselect;
406
- tryUpdateSelectValue(newValue);
407
421
  if (typeof callbackToTrigger === 'function') {
408
422
  var paramsForCallback = getValueAndOptionForCallback(optionValue, false);
409
423
  callbackToTrigger(paramsForCallback.value, paramsForCallback.option);
410
424
  }
425
+ // 如果是快速单选模式,更新代理值
426
+ if (isMultipleQuickSelectMode) {
427
+ tryUpdateProxySelectValue(newValue);
428
+ if (fromTag) {
429
+ tryUpdateSelectValue(newValue);
430
+ }
431
+ }
432
+ else {
433
+ tryUpdateSelectValue(newValue);
434
+ }
411
435
  }
412
436
  };
437
+ // 多选时,确定
438
+ var confirmCheck = function () {
439
+ tryUpdateSelectValue(stateProxyValue);
440
+ tryUpdatePopupVisible(false);
441
+ };
442
+ // 多选时,取消
443
+ var cancelCheck = function () {
444
+ tryUpdateProxySelectValue(stateValue);
445
+ tryUpdatePopupVisible(false);
446
+ };
447
+ // 多选时候快速只选一个
448
+ var handleSingleQuickSelect = function (optionValue) {
449
+ tryUpdatePopupVisible(false);
450
+ tryUpdateProxySelectValue([optionValue]);
451
+ tryUpdateSelectValue([optionValue]);
452
+ };
413
453
  var handleOptionClick = function (optionValue, disabled) {
414
454
  if (disabled) {
415
455
  return;
@@ -481,41 +521,53 @@ function Select(baseProps, ref) {
481
521
  var needForbidVirtual = needMeasureLongestItem && hasComplexLabelInOptions;
482
522
  var mergedNotFoundContent = 'notFoundContent' in props ? notFoundContent : renderEmpty('Select');
483
523
  // 选项列表元素
484
- var eleOptionList = childrenList.length ? (react_1.default.createElement(VirtualList_1.default, __assign({ id: instancePopupID, role: "listbox", style: dropdownMenuStyle, className: (0, classNames_1.default)(prefixCls + "-popup-inner", dropdownMenuClassName), ref: refWrapper, data: childrenList, height: null, isStaticItemHeight: !hasOptGroup, measureLongestItem: needMeasureLongestItem, itemKey: function (child) { return child.props._key; }, onMouseDown: utils_1.preventDefaultEvent, onMouseMove: function () {
485
- refKeyboardArrowDirection.current = null;
486
- }, onScroll: function (e) { return onPopupScroll && onPopupScroll(e.target); } }, virtualListProps, { threshold: needForbidVirtual ? null : virtualListProps === null || virtualListProps === void 0 ? void 0 : virtualListProps.threshold }), function (child) {
487
- var _a;
488
- if ((0, utils_1.isSelectOptGroup)(child)) {
489
- return react_1.default.createElement(child.type, __assign({}, child.props, { prefixCls: prefixCls }));
490
- }
491
- if ((0, utils_1.isSelectOption)(child)) {
492
- var optionValue = (_a = child.props) === null || _a === void 0 ? void 0 : _a.value;
493
- var userCreatingOptionValue = (0, is_1.isObject)(userCreatingOption)
494
- ? userCreatingOption.value
495
- : userCreatingOption;
496
- var userCreatedOptionValues = userCreatedOptions.map(function (op) {
497
- return (0, is_1.isObject)(op) ? op.value : op;
498
- });
499
- var optionProps = {
500
- prefixCls: prefixCls,
501
- rtl: rtl,
502
- _valueActive: valueActive,
503
- _valueSelect: value,
504
- _isMultipleMode: isMultipleMode,
505
- _isUserCreatingOption: allowCreate && userCreatingOptionValue === optionValue,
506
- _isUserCreatedOption: allowCreate && userCreatedOptionValues.indexOf(optionValue) > -1,
507
- _onClick: handleOptionClick,
508
- _onMouseEnter: function (value) {
509
- refKeyboardArrowDirection.current === null && setValueActive(value);
510
- },
511
- _onMouseLeave: function () {
512
- refKeyboardArrowDirection.current === null && setValueActive(undefined);
513
- },
514
- };
515
- return child && react_1.default.createElement(child.type, __assign({}, child.props, optionProps));
516
- }
517
- return child;
518
- })) : null;
524
+ var eleOptionList = childrenList.length ? (react_1.default.createElement(react_1.default.Fragment, null,
525
+ react_1.default.createElement(VirtualList_1.default, __assign({ id: instancePopupID, role: "listbox", style: dropdownMenuStyle, className: (0, classNames_1.default)(prefixCls + "-popup-inner", dropdownMenuClassName), ref: refWrapper, data: childrenList, height: null, isStaticItemHeight: !hasOptGroup, measureLongestItem: needMeasureLongestItem, itemKey: function (child) { return child.props._key; }, onMouseDown: utils_1.preventDefaultEvent, onMouseMove: function () {
526
+ refKeyboardArrowDirection.current = null;
527
+ }, onScroll: function (e) { return onPopupScroll && onPopupScroll(e.target); } }, virtualListProps, { threshold: needForbidVirtual ? null : virtualListProps === null || virtualListProps === void 0 ? void 0 : virtualListProps.threshold }), function (child) {
528
+ var _a;
529
+ if ((0, utils_1.isSelectOptGroup)(child)) {
530
+ return react_1.default.createElement(child.type, __assign({}, child.props, { prefixCls: prefixCls }));
531
+ }
532
+ if ((0, utils_1.isSelectOption)(child)) {
533
+ var optionValue = (_a = child.props) === null || _a === void 0 ? void 0 : _a.value;
534
+ var userCreatingOptionValue = (0, is_1.isObject)(userCreatingOption)
535
+ ? userCreatingOption.value
536
+ : userCreatingOption;
537
+ var userCreatedOptionValues = userCreatedOptions.map(function (op) {
538
+ return (0, is_1.isObject)(op) ? op.value : op;
539
+ });
540
+ var optionProps = {
541
+ prefixCls: prefixCls,
542
+ rtl: rtl,
543
+ _valueActive: valueActive,
544
+ _valueSelect: value,
545
+ _isMultipleMode: isMultipleMode,
546
+ _isMultipleQuickSelectMode: isMultipleQuickSelectMode,
547
+ _onSingleQuickSelect: handleSingleQuickSelect,
548
+ _isUserCreatingOption: allowCreate && userCreatingOptionValue === optionValue,
549
+ _isUserCreatedOption: allowCreate && userCreatedOptionValues.indexOf(optionValue) > -1,
550
+ _onClick: handleOptionClick,
551
+ _onMouseEnter: function (value) {
552
+ refKeyboardArrowDirection.current === null && setValueActive(value);
553
+ },
554
+ _onMouseLeave: function () {
555
+ refKeyboardArrowDirection.current === null && setValueActive(undefined);
556
+ },
557
+ };
558
+ return child && react_1.default.createElement(child.type, __assign({}, child.props, optionProps));
559
+ }
560
+ return child;
561
+ }),
562
+ isMultipleQuickSelectMode && (react_1.default.createElement("div", { style: {
563
+ display: 'flex',
564
+ justifyContent: 'flex-end',
565
+ gap: 12,
566
+ padding: '8px 16px 4px',
567
+ borderTop: '1px solid var(--color-fill-3)',
568
+ } },
569
+ react_1.default.createElement(index_1.Button, { size: "mini", onClick: cancelCheck }, "\u53D6\u6D88"),
570
+ react_1.default.createElement(index_1.Button, { type: "primary", size: "mini", onClick: confirmCheck }, "\u786E\u5B9A"))))) : null;
519
571
  // Avoid drop-down box jitter when user is creating a selection
520
572
  var isUserCreating = allowCreate && inputValue;
521
573
  // Dropdown-placeholder when there is no options
@@ -603,7 +655,7 @@ function Select(baseProps, ref) {
603
655
  // Option Items
604
656
  onRemoveCheckedItem: function (_, index, event) {
605
657
  event.stopPropagation();
606
- checkOption(value[index], 'remove');
658
+ checkOption(value[index], 'remove', true);
607
659
  },
608
660
  onClear: function (event) {
609
661
  event.stopPropagation();
@@ -641,7 +693,12 @@ function Select(baseProps, ref) {
641
693
  });
642
694
  }, [hotkeyHandler, optionInfoMap, valueActive, getOptionInfoByValue, scrollIntoView]);
643
695
  var renderView = function (eleView) {
644
- return (react_1.default.createElement(Trigger_1.default, __assign({ ref: function (ref) { return (refTrigger.current = ref); }, popup: renderPopup, trigger: trigger, disabled: disabled, getPopupContainer: getPopupContainer, classNames: "slideDynamicOrigin", autoAlignPopupWidth: true, popupAlign: triggerPopupAlign, popupVisible: popupVisible, unmountOnExit: unmountOnExit, onVisibleChange: tryUpdatePopupVisible, __onExit: function () {
696
+ return (react_1.default.createElement(Trigger_1.default, __assign({ ref: function (ref) { return (refTrigger.current = ref); }, popup: renderPopup, trigger: trigger, disabled: disabled, getPopupContainer: getPopupContainer, classNames: "slideDynamicOrigin", autoAlignPopupWidth: true, popupAlign: triggerPopupAlign, popupVisible: popupVisible, unmountOnExit: unmountOnExit, onVisibleChange: function (visible) {
697
+ if (visible === false && isMultipleQuickSelectMode) {
698
+ setProxyValue(stateValue);
699
+ }
700
+ tryUpdatePopupVisible(visible);
701
+ }, __onExit: function () {
645
702
  refPopupExiting.current = true;
646
703
  }, __onExited: function () {
647
704
  refPopupExiting.current = false;
@@ -653,7 +710,7 @@ function Select(baseProps, ref) {
653
710
  : triggerElement;
654
711
  return (react_1.default.createElement(resizeObserver_1.default, { onResize: function () { return refTrigger.current.updatePopupPosition(); } }, usedTriggerElement !== undefined && usedTriggerElement !== null ? (renderView(usedTriggerElement)) : (react_1.default.createElement(select_view_1.default, __assign({}, props, selectViewEventHandlers, { ref: refSelectView,
655
712
  // state
656
- value: value, inputValue: inputValue, popupVisible: popupVisible,
713
+ value: valueForInputShow, inputValue: inputValue, popupVisible: popupVisible,
657
714
  // other
658
715
  rtl: rtl, prefixCls: prefixCls, allowCreate: !!allowCreate, ariaControls: instancePopupID, isEmptyValue: isNoOptionSelected, isMultiple: isMultipleMode, onSort: tryUpdateSelectValue, renderText: function (value) {
659
716
  var option = getOptionInfoByValue(value);
package/lib/index.d.ts CHANGED
@@ -139,4 +139,4 @@ export type { WatermarkProps } from './Watermark/interface';
139
139
  export { default as Watermark } from './Watermark';
140
140
  export type { ImageProps, ImagePreviewProps, ImagePreviewActionProps, ImagePreviewGroupProps } from './Image/interface';
141
141
  export { default as Image } from './Image';
142
- export declare const version = "1.1.3";
142
+ export declare const version = "1.3.0";
package/lib/index.js CHANGED
@@ -147,4 +147,4 @@ var Watermark_1 = require("./Watermark");
147
147
  Object.defineProperty(exports, "Watermark", { enumerable: true, get: function () { return __importDefault(Watermark_1).default; } });
148
148
  var Image_1 = require("./Image");
149
149
  Object.defineProperty(exports, "Image", { enumerable: true, get: function () { return __importDefault(Image_1).default; } });
150
- exports.version = '1.1.3';
150
+ exports.version = '1.3.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apdesign/web-react",
3
- "version": "1.1.3",
3
+ "version": "1.3.0",
4
4
  "description": "AP Design React UI Library.",
5
5
  "module": "./es/index.js",
6
6
  "main": "./lib/index.js",
@@ -126,6 +126,7 @@
126
126
  "dayjs": "^1.10.5",
127
127
  "lodash": "^4.17.21",
128
128
  "number-precision": "^1.3.1",
129
+ "react-draggable": "^4.4.6",
129
130
  "react-focus-lock": "^2.12.1",
130
131
  "react-is": "^18.2.0",
131
132
  "react-transition-group": "^4.3.0",