@kdcloudjs/kdesign 1.6.5 → 1.6.7

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.
Files changed (108) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/dist/kdesign-complete.less +113 -106
  3. package/dist/kdesign.css +108 -84
  4. package/dist/kdesign.css.map +1 -1
  5. package/dist/kdesign.js +758 -513
  6. package/dist/kdesign.js.map +1 -1
  7. package/dist/kdesign.min.css +3 -3
  8. package/dist/kdesign.min.js +8 -8
  9. package/dist/kdesign.min.js.map +1 -1
  10. package/es/_utils/hooks.js +1 -9
  11. package/es/carousel/style/index.css +3 -0
  12. package/es/carousel/style/index.less +4 -0
  13. package/es/cascader/style/index.css +7 -7
  14. package/es/cascader/style/token.less +2 -2
  15. package/es/config-provider/compDefaultProps.d.ts +5 -0
  16. package/es/config-provider/compDefaultProps.js +6 -1
  17. package/es/date-picker/date-picker.js +11 -14
  18. package/es/date-picker/panel/month/month.d.ts +0 -1
  19. package/es/date-picker/panel/month/month.js +6 -4
  20. package/es/date-picker/range/input-range.js +41 -11
  21. package/es/date-picker/range-picker.js +8 -11
  22. package/es/date-picker/single/input-date.js +40 -10
  23. package/es/date-picker/style/index.css +27 -23
  24. package/es/date-picker/style/index.less +16 -33
  25. package/es/date-picker/style/mixin.less +7 -0
  26. package/es/date-picker/style/token.less +2 -1
  27. package/es/form/Field.d.ts +1 -0
  28. package/es/form/Field.js +9 -5
  29. package/es/form/FieldLabel.d.ts +1 -0
  30. package/es/form/FieldLabel.js +4 -2
  31. package/es/input/ClearableLabeledInput.js +23 -5
  32. package/es/input/TextArea.d.ts +1 -0
  33. package/es/input/TextArea.js +8 -6
  34. package/es/input/style/index.css +12 -8
  35. package/es/input/style/index.less +9 -5
  36. package/es/input/style/mixin.less +3 -3
  37. package/es/input/style/token.less +2 -0
  38. package/es/search/style/index.css +3 -1
  39. package/es/search/style/index.less +3 -1
  40. package/es/search/style/token.less +2 -1
  41. package/es/select/interface.d.ts +2 -0
  42. package/es/select/option.js +1 -1
  43. package/es/select/select.js +180 -128
  44. package/es/select/style/index.css +54 -24
  45. package/es/select/style/index.less +60 -43
  46. package/es/select/style/mixin.less +0 -2
  47. package/es/select/style/token.less +2 -0
  48. package/es/split-panel/style/index.css +0 -6
  49. package/es/split-panel/style/index.less +0 -3
  50. package/es/steps/style/index.css +0 -13
  51. package/es/steps/style/index.less +0 -11
  52. package/es/table/feature/mergeCellHover.d.ts +3 -0
  53. package/es/table/feature/mergeCellHover.js +7 -0
  54. package/es/table/interface.d.ts +8 -0
  55. package/es/table/table.d.ts +2 -2
  56. package/es/table/table.js +20 -6
  57. package/es/tooltip/style/index.css +1 -1
  58. package/es/tooltip/style/token.less +1 -1
  59. package/lib/_utils/hooks.js +1 -9
  60. package/lib/carousel/style/index.css +3 -0
  61. package/lib/carousel/style/index.less +4 -0
  62. package/lib/cascader/style/index.css +7 -7
  63. package/lib/cascader/style/token.less +2 -2
  64. package/lib/config-provider/compDefaultProps.d.ts +5 -0
  65. package/lib/config-provider/compDefaultProps.js +6 -1
  66. package/lib/date-picker/date-picker.js +10 -16
  67. package/lib/date-picker/panel/month/month.d.ts +0 -1
  68. package/lib/date-picker/panel/month/month.js +10 -8
  69. package/lib/date-picker/range/input-range.js +40 -11
  70. package/lib/date-picker/range-picker.js +7 -13
  71. package/lib/date-picker/single/input-date.js +37 -9
  72. package/lib/date-picker/style/index.css +27 -23
  73. package/lib/date-picker/style/index.less +16 -33
  74. package/lib/date-picker/style/mixin.less +7 -0
  75. package/lib/date-picker/style/token.less +2 -1
  76. package/lib/form/Field.d.ts +1 -0
  77. package/lib/form/Field.js +10 -6
  78. package/lib/form/FieldLabel.d.ts +1 -0
  79. package/lib/form/FieldLabel.js +4 -2
  80. package/lib/input/ClearableLabeledInput.js +34 -5
  81. package/lib/input/TextArea.d.ts +1 -0
  82. package/lib/input/TextArea.js +9 -7
  83. package/lib/input/style/index.css +12 -8
  84. package/lib/input/style/index.less +9 -5
  85. package/lib/input/style/mixin.less +3 -3
  86. package/lib/input/style/token.less +2 -0
  87. package/lib/search/style/index.css +3 -1
  88. package/lib/search/style/index.less +3 -1
  89. package/lib/search/style/token.less +2 -1
  90. package/lib/select/interface.d.ts +2 -0
  91. package/lib/select/option.js +1 -1
  92. package/lib/select/select.js +179 -126
  93. package/lib/select/style/index.css +54 -24
  94. package/lib/select/style/index.less +60 -43
  95. package/lib/select/style/mixin.less +0 -2
  96. package/lib/select/style/token.less +2 -0
  97. package/lib/split-panel/style/index.css +0 -6
  98. package/lib/split-panel/style/index.less +0 -3
  99. package/lib/steps/style/index.css +0 -13
  100. package/lib/steps/style/index.less +0 -11
  101. package/lib/table/feature/mergeCellHover.d.ts +3 -0
  102. package/lib/table/feature/mergeCellHover.js +15 -0
  103. package/lib/table/interface.d.ts +8 -0
  104. package/lib/table/table.d.ts +2 -2
  105. package/lib/table/table.js +20 -4
  106. package/lib/tooltip/style/index.css +1 -1
  107. package/lib/tooltip/style/token.less +1 -1
  108. package/package.json +1 -1
@@ -35,6 +35,8 @@ var _react = _interopRequireWildcard(require("react"));
35
35
 
36
36
  var _hooks = require("../_utils/hooks");
37
37
 
38
+ var _isBoolean = _interopRequireDefault(require("lodash/isBoolean"));
39
+
38
40
  var _classnames = _interopRequireDefault(require("classnames"));
39
41
 
40
42
  var _ConfigContext = _interopRequireDefault(require("../config-provider/ConfigContext"));
@@ -53,10 +55,10 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "functi
53
55
 
54
56
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
55
57
 
56
- var InternalSelect = function InternalSelect(props, ref) {
57
- var _context, _classNames7, _classNames13, _classNames14;
58
+ var INPUT_MIN_WIDTH = 4; // 输入框最小宽度
58
59
 
59
- var _a;
60
+ var InternalSelect = function InternalSelect(props, ref) {
61
+ var _context, _classNames6, _classNames12;
60
62
 
61
63
  var _useContext = (0, _react.useContext)(_ConfigContext.default),
62
64
  getPrefixCls = _useContext.getPrefixCls,
@@ -92,6 +94,9 @@ var InternalSelect = function InternalSelect(props, ref) {
92
94
  dropdownStyle = selectProps.dropdownStyle,
93
95
  style = selectProps.style,
94
96
  clearIcon = selectProps.clearIcon,
97
+ filterOption = selectProps.filterOption,
98
+ optionFilterProp = selectProps.optionFilterProp,
99
+ optionLabelProp = selectProps.optionLabelProp,
95
100
  _selectProps$popperSt = selectProps.popperStyle,
96
101
  popperStyle = _selectProps$popperSt === void 0 ? {} : _selectProps$popperSt;
97
102
  var isMultiple = mode === 'multiple'; // 是否多选
@@ -118,6 +123,8 @@ var InternalSelect = function InternalSelect(props, ref) {
118
123
  selectMulOpts: []
119
124
  }); // 多选ref已选中项
120
125
 
126
+ var measureRef = _react.default.useRef(null);
127
+
121
128
  var _useState = (0, _react.useState)([]),
122
129
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
123
130
  mulOptions = _useState2[0],
@@ -132,18 +139,19 @@ var InternalSelect = function InternalSelect(props, ref) {
132
139
  _useState6 = (0, _slicedToArray2.default)(_useState5, 2),
133
140
  optionShow = _useState6[0],
134
141
  setOptionShow = _useState6[1]; // 下拉列表是否展示
142
+ // const [searchInput, setSearchInput] = useState<string>('') // 搜索框值
135
143
 
136
144
 
137
145
  var _useState7 = (0, _react.useState)(''),
138
146
  _useState8 = (0, _slicedToArray2.default)(_useState7, 2),
139
- searchInput = _useState8[0],
140
- setSearchInput = _useState8[1]; // 搜索框值
147
+ searchValue = _useState8[0],
148
+ setSearchValue = _useState8[1]; // 搜索框定时器
141
149
 
142
150
 
143
- var _useState9 = (0, _react.useState)(null),
151
+ var _useState9 = (0, _react.useState)(INPUT_MIN_WIDTH),
144
152
  _useState10 = (0, _slicedToArray2.default)(_useState9, 2),
145
- timer = _useState10[0],
146
- setTimer = _useState10[1]; // 搜索框定时器
153
+ inputWidth = _useState10[0],
154
+ setInputWidth = _useState10[1]; // 输入框宽度
147
155
 
148
156
 
149
157
  var selectPrefixCls = getPrefixCls(prefixCls, 'select', customPrefixcls); // 选择器样式
@@ -151,15 +159,13 @@ var InternalSelect = function InternalSelect(props, ref) {
151
159
  var selectCls = (0, _classnames.default)(selectPrefixCls, className, (0, _defineProperty2.default)({}, "".concat(selectPrefixCls, "-visible"), optionShow));
152
160
  var selectionCls = (0, _classnames.default)((0, _defineProperty2.default)({}, "".concat(selectPrefixCls, "-selector"), true)); // 下拉列表框样式
153
161
 
154
- var dropDownCls = (0, _classnames.default)(dropdownClassName, (0, _defineProperty2.default)({}, "".concat(selectPrefixCls, "-dropdown"), true)); // 下拉搜索框样式
155
-
156
- var searchCls = (0, _classnames.default)((0, _defineProperty2.default)({}, "".concat(selectPrefixCls, "-dropdown-search"), true)); // 下拉子项列表样式
162
+ var dropDownCls = (0, _classnames.default)(dropdownClassName, (0, _defineProperty2.default)({}, "".concat(selectPrefixCls, "-dropdown"), true)); // 下拉子项列表样式
157
163
 
158
164
  var dropContentCls = (0, _classnames.default)((0, _defineProperty2.default)({}, "".concat(selectPrefixCls, "-dropdown-scroll"), (isMultiple ? (realChildren === null || realChildren === void 0 ? void 0 : realChildren.length) > 8 : (realChildren === null || realChildren === void 0 ? void 0 : realChildren.length) > 10) || selectProps.dropdownRender)); // 多选底部样式
159
165
 
160
166
  var multipleFooterCls = (0, _classnames.default)((0, _defineProperty2.default)({}, "".concat(selectPrefixCls, "-multiple-footer"), true)); // 多选,单选公共样式
161
167
 
162
- var commCls = (0, _classnames.default)((_classNames7 = {}, (0, _defineProperty2.default)(_classNames7, "".concat(selectPrefixCls, "-bordered"), borderType === 'bordered'), (0, _defineProperty2.default)(_classNames7, "".concat(selectPrefixCls, "-underline"), borderType === 'underline'), (0, _defineProperty2.default)(_classNames7, "".concat(selectPrefixCls, "-borderless"), borderType === 'none'), (0, _defineProperty2.default)(_classNames7, (0, _concat.default)(_context = "".concat(selectPrefixCls, "-size-")).call(_context, size), size), (0, _defineProperty2.default)(_classNames7, "".concat(selectPrefixCls, "-wrapper"), true), _classNames7));
168
+ var commCls = (0, _classnames.default)((_classNames6 = {}, (0, _defineProperty2.default)(_classNames6, "".concat(selectPrefixCls, "-bordered"), borderType === 'bordered'), (0, _defineProperty2.default)(_classNames6, "".concat(selectPrefixCls, "-underline"), borderType === 'underline'), (0, _defineProperty2.default)(_classNames6, "".concat(selectPrefixCls, "-borderless"), borderType === 'none'), (0, _defineProperty2.default)(_classNames6, (0, _concat.default)(_context = "".concat(selectPrefixCls, "-size-")).call(_context, size), size), (0, _defineProperty2.default)(_classNames6, "".concat(selectPrefixCls, "-wrapper"), true), _classNames6));
163
169
 
164
170
  _react.default.useEffect(function () {
165
171
  setOptionShow(!!props.visible);
@@ -209,8 +215,6 @@ var InternalSelect = function InternalSelect(props, ref) {
209
215
  }
210
216
  }, [isMultiple, initValue, children, options]);
211
217
  (0, _react.useEffect)(function () {
212
- var _a;
213
-
214
218
  if (!isMultiple) {
215
219
  multipleRef.current.selectedVal = initValue; // 默认选中值
216
220
 
@@ -226,28 +230,27 @@ var InternalSelect = function InternalSelect(props, ref) {
226
230
  })) || {};
227
231
 
228
232
  if (options && options.length) {
229
- setSingleVal((obj === null || obj === void 0 ? void 0 : obj.label) || (obj === null || obj === void 0 ? void 0 : obj.value));
233
+ setSingleVal(getOptionLabel(obj) || (obj === null || obj === void 0 ? void 0 : obj.value));
230
234
  } else {
231
- setSingleVal((_a = obj.props) === null || _a === void 0 ? void 0 : _a.children);
235
+ // setSingleVal(obj.props?.children)
236
+ setSingleVal(getOptionLabel(obj));
232
237
  }
233
238
  } else {
234
239
  setSingleVal(undefined);
235
240
  }
236
241
  }
237
- }, [initValue, realChildren]); // 更新搜索框的值,判断清除按钮显隐
238
-
242
+ }, [initValue, realChildren]);
239
243
  (0, _react.useEffect)(function () {
240
- var _a;
241
-
242
- setSearchInput((_a = searchRef.current) === null || _a === void 0 ? void 0 : _a.value);
243
- }, [(_a = searchRef.current) === null || _a === void 0 ? void 0 : _a.value]);
244
- (0, _react.useEffect)(function () {
245
- handleClear();
246
- }, [optionShow === false]);
244
+ if (optionShow === false) {
245
+ handleClear();
246
+ }
247
+ }, [optionShow]);
247
248
  var handleFocus = (0, _react.useCallback)(function (e) {
249
+ e.stopPropagation();
248
250
  onFocus && onFocus(e);
249
251
  }, [onFocus]);
250
252
  var handleBlur = (0, _react.useCallback)(function (e) {
253
+ e.stopPropagation();
251
254
  onBlur && onBlur(e);
252
255
  }, [onBlur]); // 点击组件
253
256
 
@@ -257,8 +260,7 @@ var InternalSelect = function InternalSelect(props, ref) {
257
260
  if (!optionShow) {
258
261
  var onDropdownVisibleChange = selectProps.onDropdownVisibleChange;
259
262
  onDropdownVisibleChange && onDropdownVisibleChange(!optionShow);
260
- } // handleClear()
261
-
263
+ }
262
264
  };
263
265
 
264
266
  (0, _react.useEffect)(function () {
@@ -271,11 +273,62 @@ var InternalSelect = function InternalSelect(props, ref) {
271
273
  e.stopPropagation();
272
274
  }
273
275
  });
274
- }, []); // 点击下拉列表中某项回调
276
+ }, []);
277
+ (0, _react.useLayoutEffect)(function () {
278
+ measureRef.current && setInputWidth(measureRef.current.scrollWidth);
279
+ }, [searchValue]);
280
+ var filledOptions = (0, _react.useMemo)(function () {
281
+ if (filterOption === false || !searchValue) {
282
+ return realChildren;
283
+ }
275
284
 
276
- var handleOption = function handleOption(key, label, isSelected) {
277
- var _a, _b, _c;
285
+ var childrenList = [];
286
+
287
+ var handleFilledOption = function handleFilledOption(option) {
288
+ if (filterOption === true) {
289
+ return String(option[optionFilterProp]).toLowerCase().indexOf(searchValue.toLowerCase()) !== -1;
290
+ } else if (typeof filterOption === 'function') {
291
+ return filterOption(searchValue, option);
292
+ }
293
+
294
+ return true;
295
+ };
296
+
297
+ (0, _map.default)(realChildren).call(realChildren, function (item) {
298
+ if (item === null || item === undefined) return;
299
+ var isValidOption = true;
300
+
301
+ if ((item === null || item === void 0 ? void 0 : item.props) && (item.type.displayName === 'Option' || item.type.name === 'Option')) {
302
+ isValidOption = handleFilledOption(item.props);
303
+ } else {
304
+ isValidOption = handleFilledOption(item);
305
+ }
278
306
 
307
+ if (isValidOption) {
308
+ childrenList.push(item);
309
+ }
310
+ });
311
+ return childrenList;
312
+ }, [searchValue, realChildren, filterOption, optionFilterProp]);
313
+ var getOptionLabel = (0, _react.useCallback)(function (obj) {
314
+ var _a;
315
+
316
+ if (obj.props) {
317
+ if (optionLabelProp) {
318
+ return obj === null || obj === void 0 ? void 0 : obj.props[optionLabelProp];
319
+ }
320
+
321
+ return (_a = obj.props) === null || _a === void 0 ? void 0 : _a.children;
322
+ } else {
323
+ if (optionLabelProp) {
324
+ return obj[optionLabelProp];
325
+ }
326
+ }
327
+
328
+ return obj === null || obj === void 0 ? void 0 : obj.label;
329
+ }, [optionLabelProp]); // 点击下拉列表中某项回调
330
+
331
+ var handleOption = function handleOption(key, label, isSelected) {
279
332
  var onSelect = selectProps.onSelect,
280
333
  onDeselect = selectProps.onDeselect,
281
334
  labelInValue = selectProps.labelInValue,
@@ -292,7 +345,6 @@ var InternalSelect = function InternalSelect(props, ref) {
292
345
  var optionsObj = obj.props ? obj.props : obj || {};
293
346
 
294
347
  if (value !== undefined) {
295
- // onChange && onChange(labelInValue ? { value: key, label } : key)
296
348
  if (isMultiple) {
297
349
  var _multipleRef$current = multipleRef.current,
298
350
  selectedVal = _multipleRef$current.selectedVal,
@@ -308,7 +360,8 @@ var InternalSelect = function InternalSelect(props, ref) {
308
360
  valArr.push(key);
309
361
  optsArr.push((0, _extends2.default)((0, _extends2.default)({}, optionsObj), {
310
362
  value: key,
311
- label: obj.props ? (_a = obj.props) === null || _a === void 0 ? void 0 : _a.children : obj.label || key
363
+ // label: obj.props ? obj.props?.children : obj.label || key,
364
+ label: getOptionLabel(obj) || key
312
365
  }));
313
366
  }
314
367
 
@@ -333,11 +386,10 @@ var InternalSelect = function InternalSelect(props, ref) {
333
386
  }
334
387
 
335
388
  if (!isMultiple) {
336
- setSingleVal(obj.props ? (_b = obj.props) === null || _b === void 0 ? void 0 : _b.children : obj.label || key);
389
+ setSingleVal(getOptionLabel(obj) || key);
337
390
  multipleRef.current.selectedVal = key;
338
391
  setInitValue(key);
339
- props.visible === undefined && setOptionShow(false); // handleClear()
340
-
392
+ props.visible === undefined && setOptionShow(false);
341
393
  onChange && onChange(labelInValue ? {
342
394
  value: key,
343
395
  label: label
@@ -360,10 +412,9 @@ var InternalSelect = function InternalSelect(props, ref) {
360
412
 
361
413
  _selectMulOpts.push((0, _extends2.default)((0, _extends2.default)({}, optionsObj), {
362
414
  value: key,
363
- label: obj.props ? (_c = obj.props) === null || _c === void 0 ? void 0 : _c.children : obj.label || key
415
+ label: getOptionLabel(obj) || key
364
416
  }));
365
- } // setInitValue([...selectedVal])
366
-
417
+ }
367
418
 
368
419
  setMulOptions((0, _toConsumableArray2.default)(_selectMulOpts));
369
420
  onChange && onChange(labelInValue ? _selectMulOpts : _selectedVal, _selectMulOpts);
@@ -371,11 +422,9 @@ var InternalSelect = function InternalSelect(props, ref) {
371
422
  if (!isSelected) {
372
423
  onDeselect && onDeselect(key); // 下拉项取消选中时调用,参数为选中项的value,多选模式下生效
373
424
  }
374
- } // if (isSelected) {
375
- // onSelect && onSelect(key) // 下拉项被选中时调用,参数为选中项value或key
376
- // }
377
-
425
+ }
378
426
 
427
+ setSearchValue('');
379
428
  onSelect && onSelect(key); // 下拉项被选中时调用,参数为选中项value或key
380
429
  }; // 多选模式下选中所有 与清除所有 (可以优化)
381
430
 
@@ -388,14 +437,13 @@ var InternalSelect = function InternalSelect(props, ref) {
388
437
  if ((realChildren === null || realChildren === void 0 ? void 0 : realChildren.length) !== selectedVal.length) {
389
438
  (0, _map.default)(realChildren).call(realChildren, function (child) {
390
439
  var _ref = child.props || child,
391
- value = _ref.value,
392
- children = _ref.children;
440
+ value = _ref.value;
393
441
 
394
442
  if (!(0, _includes.default)(selectedVal).call(selectedVal, value)) {
395
443
  selectedVal.push(value);
396
444
  selectMulOpts.push({
397
445
  value: value,
398
- label: children
446
+ label: getOptionLabel(child)
399
447
  });
400
448
  }
401
449
  });
@@ -407,45 +455,31 @@ var InternalSelect = function InternalSelect(props, ref) {
407
455
  }
408
456
 
409
457
  onChange && onChange(labelInValue ? selectMulOpts : selectedVal, selectMulOpts);
410
- }; // 筛选内容 ---可以优化,抽成hook
458
+ }; // 输入框变化搜索内容
411
459
 
412
460
 
413
- var handleSearch = (0, _react.useCallback)(function (event) {
414
- var _a;
415
-
416
- if (event.currentTarget.matches('i')) {
417
- onSearch && onSearch((_a = searchRef.current) === null || _a === void 0 ? void 0 : _a.value);
418
- }
419
- }, [onSearch]); // 输入框变化搜索内容
420
-
421
461
  var handleSearchChange = (0, _react.useCallback)(function (event) {
422
462
  var val = event.currentTarget.value;
423
- clearTimeout(timer);
424
- setTimer(setTimeout(function () {
425
- onSearch && onSearch(val);
426
- }, 500));
427
- }, [onSearch, timer]); // 清除搜索内容
463
+ setSearchValue(val);
464
+ onSearch === null || onSearch === void 0 ? void 0 : onSearch(val);
465
+ }, [onSearch]); // 清除搜索内容
428
466
 
429
467
  var handleClear = (0, _react.useCallback)(function () {
430
468
  if (searchRef.current) {
431
469
  searchRef.current.value = '';
432
- onSearch && onSearch('');
433
- setSearchInput('');
470
+ setSearchValue('');
434
471
  }
435
- }, [onSearch, searchRef]); // 清空选择器内容
472
+ }, [searchRef]); // 清空选择器内容
436
473
 
437
474
  var handleReset = function handleReset(e) {
438
- e.stopPropagation(); // setOptionShow(false)
439
- // e.nativeEvent.stopImmediatePropagation()
475
+ e.stopPropagation();
440
476
 
441
477
  if (isMultiple) {
442
478
  multipleRef.current.selectedVal = [];
443
479
  multipleRef.current.selectMulOpts = [];
444
480
  setMulOptions([]);
445
481
  } else {
446
- // setSingleVal('')
447
- setInitValue(''); // selectionRef.current.value = ''
448
- // multipleRef.current.selectedVal = ''
482
+ setInitValue('');
449
483
  }
450
484
 
451
485
  onClear && onClear('');
@@ -455,8 +489,7 @@ var InternalSelect = function InternalSelect(props, ref) {
455
489
 
456
490
  var handleRemove = function handleRemove(e) {
457
491
  if (disabled) return;
458
- var tag = e.currentTarget.parentNode.getAttribute('data-tag'); // const { tag } = e.currentTarget.dataset
459
-
492
+ var tag = e.currentTarget.parentNode.getAttribute('data-tag');
460
493
  var _multipleRef$current4 = multipleRef.current,
461
494
  selectedVal = _multipleRef$current4.selectedVal,
462
495
  selectMulOpts = _multipleRef$current4.selectMulOpts;
@@ -470,19 +503,19 @@ var InternalSelect = function InternalSelect(props, ref) {
470
503
 
471
504
 
472
505
  var renderSuffix = function renderSuffix() {
473
- var _classNames8;
506
+ var _classNames7;
474
507
 
475
508
  var suffixIcon = selectProps.suffixIcon;
476
509
  var selectedVal = multipleRef.current.selectedVal; // 选择器下拉icon样式
477
510
 
478
- var arrowIconCls = (0, _classnames.default)((_classNames8 = {}, (0, _defineProperty2.default)(_classNames8, "".concat(selectPrefixCls, "-icon-arrow"), true), (0, _defineProperty2.default)(_classNames8, "".concat(selectPrefixCls, "-icon-arrow-up"), optionShow), (0, _defineProperty2.default)(_classNames8, "".concat(selectPrefixCls, "-icon-arrow-down"), !optionShow), (0, _defineProperty2.default)(_classNames8, "".concat(selectPrefixCls, "-icon-arrow-focus"), optionShow), _classNames8));
511
+ var arrowIconCls = (0, _classnames.default)((_classNames7 = {}, (0, _defineProperty2.default)(_classNames7, "".concat(selectPrefixCls, "-icon-arrow"), true), (0, _defineProperty2.default)(_classNames7, "".concat(selectPrefixCls, "-icon-arrow-up"), optionShow), (0, _defineProperty2.default)(_classNames7, "".concat(selectPrefixCls, "-icon-arrow-down"), !optionShow), (0, _defineProperty2.default)(_classNames7, "".concat(selectPrefixCls, "-icon-arrow-focus"), optionShow), _classNames7));
479
512
  var iconShow = allowClear && !disabled && (isMultiple ? mulOptions.length > 0 : (selectedVal !== null && selectedVal !== void 0 ? selectedVal : '') !== '');
480
513
  var clearIconCls = (0, _classnames.default)((0, _defineProperty2.default)({}, "".concat(selectPrefixCls, "-icon-clear"), true));
481
514
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, iconShow && /*#__PURE__*/_react.default.createElement("span", {
482
515
  onClick: handleReset,
483
516
  className: clearIconCls
484
517
  }, /*#__PURE__*/_react.default.createElement(_index.Icon, {
485
- type: "close"
518
+ type: "close-solid"
486
519
  }) || clearIcon), showArrow && /*#__PURE__*/_react.default.createElement("span", {
487
520
  className: arrowIconCls
488
521
  }, suffixIcon || /*#__PURE__*/_react.default.createElement(_index.Icon, {
@@ -525,30 +558,26 @@ var InternalSelect = function InternalSelect(props, ref) {
525
558
  var emptyListCls = (0, _classnames.default)((0, _defineProperty2.default)({}, "".concat(selectPrefixCls, "-dropdown-empty"), true));
526
559
  var notFoundContent = selectProps.notFoundContent;
527
560
  var emptyContent = notFoundContent || '暂无数据';
528
- return (realChildren === null || realChildren === void 0 ? void 0 : realChildren.length) === 0 && /*#__PURE__*/_react.default.createElement("div", {
561
+ return (filledOptions === null || filledOptions === void 0 ? void 0 : filledOptions.length) === 0 && /*#__PURE__*/_react.default.createElement("div", {
529
562
  className: emptyListCls
530
563
  }, emptyContent);
531
- };
564
+ }; // const isShowSearch = useCallback(() => {
565
+ // return !showSearch ? false : !!searchValue
566
+ // }, [showSearch, searchValue])
532
567
 
533
- var isShowSearch = (0, _react.useCallback)(function () {
534
- if (isMultiple) {
535
- return showSearch !== null && showSearch !== void 0 ? showSearch : true;
536
- }
537
568
 
538
- return showSearch !== null && showSearch !== void 0 ? showSearch : false;
539
- }, [showSearch, isMultiple]); // 渲染下拉列表框
569
+ var isShowSearch = (0, _react.useMemo)(function () {
570
+ return (0, _isBoolean.default)(showSearch) ? showSearch : isMultiple;
571
+ }, [isMultiple, showSearch]); // 渲染下拉列表框
540
572
 
541
573
  var renderContent = function renderContent() {
542
- var _a;
543
-
544
- var searchIcon = selectProps.searchIcon,
545
- dropdownRender = selectProps.dropdownRender,
574
+ var dropdownRender = selectProps.dropdownRender,
546
575
  listHeight = selectProps.listHeight;
547
576
  var selectedVal = multipleRef.current.selectedVal;
548
- var childrenToRender = realChildren;
577
+ var childrenToRender = filledOptions;
549
578
 
550
- if (Array.isArray(realChildren) && realChildren.length > 0) {
551
- childrenToRender = (0, _map.default)(realChildren).call(realChildren, function (item, index) {
579
+ if (Array.isArray(childrenToRender) && childrenToRender.length > 0) {
580
+ childrenToRender = (0, _map.default)(childrenToRender).call(childrenToRender, function (item, index) {
552
581
  if (item === null || item === undefined) return;
553
582
  var temp = renderOption(item, index);
554
583
  return temp;
@@ -572,26 +601,7 @@ var InternalSelect = function InternalSelect(props, ref) {
572
601
  className: dropDownCls,
573
602
  style: dropDownStyle,
574
603
  ref: dropDownRef
575
- }, isShowSearch() && /*#__PURE__*/_react.default.createElement("div", {
576
- className: searchCls
577
- }, /*#__PURE__*/_react.default.createElement(_index.Input, {
578
- ref: searchRef,
579
- value: ((_a = searchRef.current) === null || _a === void 0 ? void 0 : _a.value) || '',
580
- borderType: "bordered",
581
- placeholder: "\u8BF7\u8F93\u5165\u9700\u8981\u641C\u7D22\u7684\u5185\u5BB9",
582
- // 搜索图标
583
- prefix: /*#__PURE__*/_react.default.createElement("span", {
584
- onClick: handleSearch
585
- }, /*#__PURE__*/_react.default.createElement(_index.Icon, {
586
- type: "search"
587
- }) || searchIcon),
588
- suffix: searchInput && /*#__PURE__*/_react.default.createElement("span", {
589
- onClick: handleClear
590
- }, /*#__PURE__*/_react.default.createElement(_index.Icon, {
591
- type: "close"
592
- })),
593
- onChange: handleSearchChange
594
- })), !dropdownRender && realChildren.length > 0 && dropRender(childrenToRender, heightStyle), renderNotContent(), /*#__PURE__*/_react.default.createElement("div", null, dropdownRender && dropdownRender(dropRender(childrenToRender, heightStyle))), isMultiple && /*#__PURE__*/_react.default.createElement("div", {
604
+ }, !dropdownRender && childrenToRender.length > 0 && dropRender(childrenToRender, heightStyle), renderNotContent(), /*#__PURE__*/_react.default.createElement("div", null, dropdownRender && dropdownRender(dropRender(childrenToRender, heightStyle))), isMultiple && /*#__PURE__*/_react.default.createElement("div", {
595
605
  className: multipleFooterCls
596
606
  }, /*#__PURE__*/_react.default.createElement(_index.Checkbox, {
597
607
  style: checkboxStyle,
@@ -625,15 +635,43 @@ var InternalSelect = function InternalSelect(props, ref) {
625
635
  disabled: disabled
626
636
  }, maxTagPlaceholder);
627
637
  }
628
- }, [mulOptions]); // 渲染多选选择器 (待优化:多选框下拉按钮样式调整,限制tag数代码优化)
638
+ }, [mulOptions]);
639
+
640
+ var renderSingle = function renderSingle() {
641
+ var hiddenStyle = isShowSearch && !!searchValue || singleVal ? {
642
+ visibility: 'hidden'
643
+ } : undefined;
644
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
645
+ className: singleCls,
646
+ ref: selectionRef
647
+ }, /*#__PURE__*/_react.default.createElement("span", {
648
+ className: "".concat(selectPrefixCls, "-selection-search")
649
+ }, /*#__PURE__*/_react.default.createElement("input", {
650
+ ref: searchRef,
651
+ value: searchValue,
652
+ className: "".concat(selectPrefixCls, "-selection-search-input"),
653
+ onChange: handleSearchChange,
654
+ onFocus: handleFocus,
655
+ onBlur: handleBlur,
656
+ readOnly: !isShowSearch || !!disabled
657
+ })), singleVal && !searchValue && /*#__PURE__*/_react.default.createElement("span", {
658
+ className: "".concat(selectPrefixCls, "-selection-item")
659
+ }, singleVal), /*#__PURE__*/_react.default.createElement("span", {
660
+ className: "".concat(selectPrefixCls, "-placeholder"),
661
+ style: hiddenStyle
662
+ }, placeholder), /*#__PURE__*/_react.default.createElement("span", {
663
+ className: "".concat(selectPrefixCls, "-suffix")
664
+ }, renderSuffix())));
665
+ }; // 渲染多选选择器 (待优化:多选框下拉按钮样式调整,限制tag数代码优化)
666
+
629
667
 
630
668
  var renderMultiple = function renderMultiple() {
631
- var _context3, _classNames11, _context4, _classNames12;
669
+ var _context3, _classNames10, _context4, _classNames11;
632
670
 
633
671
  var maxTagCount = selectProps.maxTagCount,
634
672
  maxTagPlaceholder = selectProps.maxTagPlaceholder;
635
- var multipleCls = (0, _classnames.default)(commCls, (_classNames11 = {}, (0, _defineProperty2.default)(_classNames11, "".concat(selectPrefixCls, "-multiple-disabled"), disabled), (0, _defineProperty2.default)(_classNames11, (0, _concat.default)(_context3 = "".concat(selectPrefixCls, "-")).call(_context3, mode), mode), (0, _defineProperty2.default)(_classNames11, "".concat(selectPrefixCls, "-focused"), autoFocus || optionShow), (0, _defineProperty2.default)(_classNames11, "".concat(selectPrefixCls, "-placeholder"), placeholder && !mulOptions.length), _classNames11));
636
- var itemCls = (0, _classnames.default)((_classNames12 = {}, (0, _defineProperty2.default)(_classNames12, "".concat(selectPrefixCls, "-selection-item"), true), (0, _defineProperty2.default)(_classNames12, (0, _concat.default)(_context4 = "".concat(selectPrefixCls, "-selection-item-")).call(_context4, size), size), _classNames12));
673
+ var multipleCls = (0, _classnames.default)(commCls, (_classNames10 = {}, (0, _defineProperty2.default)(_classNames10, "".concat(selectPrefixCls, "-multiple-disabled"), disabled), (0, _defineProperty2.default)(_classNames10, (0, _concat.default)(_context3 = "".concat(selectPrefixCls, "-")).call(_context3, mode), mode), (0, _defineProperty2.default)(_classNames10, "".concat(selectPrefixCls, "-focused"), autoFocus || optionShow), (0, _defineProperty2.default)(_classNames10, "".concat(selectPrefixCls, "-placeholder"), placeholder && !mulOptions.length), _classNames10));
674
+ var itemCls = (0, _classnames.default)((_classNames11 = {}, (0, _defineProperty2.default)(_classNames11, "".concat(selectPrefixCls, "-selection-item"), true), (0, _defineProperty2.default)(_classNames11, (0, _concat.default)(_context4 = "".concat(selectPrefixCls, "-selection-item-")).call(_context4, size), size), _classNames11));
637
675
  var TagStyle = {
638
676
  margin: '2px 8px 2px 0'
639
677
  };
@@ -659,14 +697,29 @@ var InternalSelect = function InternalSelect(props, ref) {
659
697
  }, /*#__PURE__*/_react.default.createElement("span", {
660
698
  className: "".concat(selectPrefixCls, "-selection-item-content")
661
699
  }, "\u5171", mulOptions.length, "\u9879")) : null), /*#__PURE__*/_react.default.createElement("span", {
700
+ className: "".concat(selectPrefixCls, "-selection-search"),
701
+ style: {
702
+ width: inputWidth
703
+ }
704
+ }, /*#__PURE__*/_react.default.createElement("input", {
705
+ ref: searchRef,
706
+ value: searchValue,
707
+ className: "".concat(selectPrefixCls, "-selection-search-input"),
708
+ onChange: handleSearchChange,
709
+ onFocus: handleFocus,
710
+ onBlur: handleBlur,
711
+ readOnly: !isShowSearch || !!disabled
712
+ }), /*#__PURE__*/_react.default.createElement("span", {
713
+ ref: measureRef,
714
+ className: "".concat(selectPrefixCls, "-selection-search-mirror")
715
+ }, searchValue, "\xA0")), /*#__PURE__*/_react.default.createElement("span", {
662
716
  className: "".concat(selectPrefixCls, "-placeholder")
663
- }, !mulOptions.length && placeholder), /*#__PURE__*/_react.default.createElement("span", {
717
+ }, !mulOptions.length && !searchValue && placeholder), /*#__PURE__*/_react.default.createElement("span", {
664
718
  className: "".concat(selectPrefixCls, "-suffix")
665
719
  }, renderSuffix()));
666
720
  };
667
721
 
668
- var singleCls = (0, _classnames.default)(commCls, (_classNames13 = {}, (0, _defineProperty2.default)(_classNames13, "".concat(selectPrefixCls, "-single"), true), (0, _defineProperty2.default)(_classNames13, "".concat(selectPrefixCls, "-single-disabled"), disabled), (0, _defineProperty2.default)(_classNames13, "".concat(selectPrefixCls, "-single-focused"), autoFocus && !disabled || optionShow), _classNames13));
669
- var singleTextCls = (0, _classnames.default)((_classNames14 = {}, (0, _defineProperty2.default)(_classNames14, "".concat(selectPrefixCls, "-single-text"), true), (0, _defineProperty2.default)(_classNames14, "".concat(selectPrefixCls, "-single-disabled-text"), disabled), _classNames14));
722
+ var singleCls = (0, _classnames.default)(commCls, (_classNames12 = {}, (0, _defineProperty2.default)(_classNames12, "".concat(selectPrefixCls, "-single"), true), (0, _defineProperty2.default)(_classNames12, "".concat(selectPrefixCls, "-single-disabled"), disabled), (0, _defineProperty2.default)(_classNames12, "".concat(selectPrefixCls, "-single-focused"), autoFocus && !disabled || optionShow), _classNames12));
670
723
 
671
724
  var renderSelect = function renderSelect() {
672
725
  return /*#__PURE__*/_react.default.createElement("div", {
@@ -676,18 +729,18 @@ var InternalSelect = function InternalSelect(props, ref) {
676
729
  }, /*#__PURE__*/_react.default.createElement("span", {
677
730
  className: selectionCls,
678
731
  onClick: handleClick,
679
- onFocus: handleFocus,
680
- onBlur: handleBlur
681
- }, !isMultiple ? /*#__PURE__*/_react.default.createElement("div", {
682
- className: singleCls,
683
- ref: selectionRef
684
- }, /*#__PURE__*/_react.default.createElement("span", {
685
- className: singleTextCls
686
- }, singleVal || null), /*#__PURE__*/_react.default.createElement("span", {
687
- className: "".concat(selectPrefixCls, "-placeholder")
688
- }, !singleVal && placeholder), /*#__PURE__*/_react.default.createElement("span", {
689
- className: "".concat(selectPrefixCls, "-suffix")
690
- }, renderSuffix())) : renderMultiple()));
732
+ tabIndex: disabled ? -1 : 0,
733
+ onFocus: function onFocus() {
734
+ var _a;
735
+
736
+ return (_a = searchRef.current) === null || _a === void 0 ? void 0 : _a.focus();
737
+ },
738
+ onBlur: function onBlur() {
739
+ var _a;
740
+
741
+ return (_a = searchRef.current) === null || _a === void 0 ? void 0 : _a.blur();
742
+ }
743
+ }, !isMultiple ? renderSingle() : renderMultiple()));
691
744
  };
692
745
 
693
746
  var catchStyle = function catchStyle() {