@kdcloudjs/kdesign 1.7.25 → 1.7.27

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 (70) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/dist/kdesign-complete.less +109 -45
  3. package/dist/kdesign.css +85 -40
  4. package/dist/kdesign.css.map +1 -1
  5. package/dist/kdesign.js +266 -106
  6. package/dist/kdesign.js.map +1 -1
  7. package/dist/kdesign.min.css +3 -3
  8. package/dist/kdesign.min.js +6 -6
  9. package/dist/kdesign.min.js.map +1 -1
  10. package/es/anchor/style/index.css +1 -1
  11. package/es/anchor/style/index.less +1 -1
  12. package/es/anchor/style/token.less +1 -0
  13. package/es/cascader/cascader.js +64 -32
  14. package/es/cascader/style/index.css +42 -26
  15. package/es/cascader/style/index.less +51 -29
  16. package/es/cascader/style/token.less +5 -3
  17. package/es/city-picker/city-picker.js +104 -13
  18. package/es/city-picker/interface.d.ts +3 -0
  19. package/es/city-picker/option.js +15 -3
  20. package/es/city-picker/style/index.css +22 -10
  21. package/es/city-picker/style/index.less +24 -10
  22. package/es/collapse/panel.js +31 -18
  23. package/es/collapse/style/index.css +4 -1
  24. package/es/collapse/style/index.less +4 -1
  25. package/es/form/Field.d.ts +1 -0
  26. package/es/form/Field.js +5 -3
  27. package/es/form/FieldWrapper.d.ts +1 -0
  28. package/es/form/FieldWrapper.js +13 -5
  29. package/es/form/style/index.css +11 -1
  30. package/es/form/style/index.less +16 -1
  31. package/es/form/style/token.less +1 -0
  32. package/es/select/style/index.css +1 -0
  33. package/es/select/style/index.less +1 -0
  34. package/es/select/style/token.less +1 -0
  35. package/es/tabs/style/index.css +3 -0
  36. package/es/tabs/style/index.less +3 -0
  37. package/es/tabs/style/token.less +1 -0
  38. package/es/tag/tag.d.ts +1 -0
  39. package/es/tree-select/tree-select.js +2 -1
  40. package/lib/anchor/style/index.css +1 -1
  41. package/lib/anchor/style/index.less +1 -1
  42. package/lib/anchor/style/token.less +1 -0
  43. package/lib/cascader/cascader.js +63 -31
  44. package/lib/cascader/style/index.css +42 -26
  45. package/lib/cascader/style/index.less +51 -29
  46. package/lib/cascader/style/token.less +5 -3
  47. package/lib/city-picker/city-picker.js +103 -12
  48. package/lib/city-picker/interface.d.ts +3 -0
  49. package/lib/city-picker/option.js +15 -3
  50. package/lib/city-picker/style/index.css +22 -10
  51. package/lib/city-picker/style/index.less +24 -10
  52. package/lib/collapse/panel.js +32 -19
  53. package/lib/collapse/style/index.css +4 -1
  54. package/lib/collapse/style/index.less +4 -1
  55. package/lib/form/Field.d.ts +1 -0
  56. package/lib/form/Field.js +5 -3
  57. package/lib/form/FieldWrapper.d.ts +1 -0
  58. package/lib/form/FieldWrapper.js +13 -5
  59. package/lib/form/style/index.css +11 -1
  60. package/lib/form/style/index.less +16 -1
  61. package/lib/form/style/token.less +1 -0
  62. package/lib/select/style/index.css +1 -0
  63. package/lib/select/style/index.less +1 -0
  64. package/lib/select/style/token.less +1 -0
  65. package/lib/tabs/style/index.css +3 -0
  66. package/lib/tabs/style/index.less +3 -0
  67. package/lib/tabs/style/token.less +1 -0
  68. package/lib/tag/tag.d.ts +1 -0
  69. package/lib/tree-select/tree-select.js +2 -1
  70. package/package.json +1 -1
@@ -5,7 +5,7 @@ import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
5
5
  import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
6
6
  import _findInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find";
7
7
  import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
8
- import React, { useContext, useRef, useEffect, useState, useCallback } from 'react';
8
+ import React, { useContext, useRef, useEffect, useState, useCallback, useMemo } from 'react';
9
9
  import { useMergedState } from '../_utils/hooks';
10
10
  import classNames from 'classnames';
11
11
  import ConfigContext from '../config-provider/ConfigContext';
@@ -14,6 +14,7 @@ import { Icon, Tabs, Spin } from '../index';
14
14
  import usePopper from '../_utils/usePopper';
15
15
  import Option from './option';
16
16
  import escapeRegExp from 'lodash/escapeRegExp';
17
+ import KeyCode from '../_utils/KeyCode';
17
18
  var InternalSelect = function InternalSelect(props, ref) {
18
19
  var _context, _classNames3, _classNames5;
19
20
  var _useContext = useContext(ConfigContext),
@@ -81,6 +82,7 @@ var InternalSelect = function InternalSelect(props, ref) {
81
82
  var searchRef = useRef(null); // 搜索框ref
82
83
  var selectionRef = useRef(null);
83
84
  var clearRef = useRef(null);
85
+ var optionsListRef = useRef(null);
84
86
  var _useState = useState(typeof props.visible === 'undefined' ? !!defaultOpen : !!props.visible),
85
87
  _useState2 = _slicedToArray(_useState, 2),
86
88
  optionShow = _useState2[0],
@@ -116,9 +118,7 @@ var InternalSelect = function InternalSelect(props, ref) {
116
118
  var city = _findInstanceProperty(cityList).call(cityList, function (city) {
117
119
  return city.id === value;
118
120
  });
119
- if (city) {
120
- setSeletedCity(city);
121
- }
121
+ setSeletedCity(city);
122
122
  }, [commonList, domesticList, foreignList, value]);
123
123
  useEffect(function () {
124
124
  if (typeof props.visible !== 'undefined') {
@@ -226,17 +226,24 @@ var InternalSelect = function InternalSelect(props, ref) {
226
226
  return renderNotContent(notContent);
227
227
  }
228
228
  return /*#__PURE__*/React.createElement("div", {
229
- className: "".concat(selectPrefixCls, "-list")
230
- }, _mapInstanceProperty(data).call(data, function (item) {
229
+ className: "".concat(selectPrefixCls, "-list"),
230
+ ref: optionsListRef
231
+ }, _mapInstanceProperty(data).call(data, function (item, index) {
231
232
  return /*#__PURE__*/React.createElement(Option, {
232
233
  key: item.id,
233
234
  value: initValue,
234
235
  city: item,
236
+ className: searchValue ? "".concat(selectPrefixCls, "-list-item-match") : undefined,
235
237
  renderCityInfo: function renderCityInfo(data, flag) {
236
238
  return _renderCityInfo(data, isCommon, flag);
237
239
  },
238
240
  onChangeSelect: handleOption,
239
- itemRender: itemRender
241
+ itemRender: itemRender,
242
+ activeIndex: activeIndex,
243
+ index: index,
244
+ onChangeActiveIndex: function onChangeActiveIndex(i) {
245
+ setActiveIndex(i);
246
+ }
240
247
  }, searchValue ? getHighlightText(item === null || item === void 0 ? void 0 : item.name, (item === null || item === void 0 ? void 0 : item[optionHighlightProps]) || searchValue) : item === null || item === void 0 ? void 0 : item.name);
241
248
  }));
242
249
  };
@@ -272,12 +279,17 @@ var InternalSelect = function InternalSelect(props, ref) {
272
279
  var symbol = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : ', ';
273
280
  if (!data) return null;
274
281
  if (isDomestic(type)) {
275
- var _context3;
276
- var curVal = tabsValue === 'domestic' || isCommon ? data === null || data === void 0 ? void 0 : data.province : data === null || data === void 0 ? void 0 : data.country;
277
- return _concatInstanceProperty(_context3 = "".concat(flag && curVal ? symbol : '')).call(_context3, curVal);
282
+ var _context4;
283
+ if (isCommon) {
284
+ var _context3;
285
+ var _curVal = (data === null || data === void 0 ? void 0 : data.province) ? data === null || data === void 0 ? void 0 : data.province : data === null || data === void 0 ? void 0 : data.country;
286
+ return _concatInstanceProperty(_context3 = "".concat(flag && _curVal ? symbol : '')).call(_context3, _curVal);
287
+ }
288
+ var curVal = tabsValue === 'domestic' ? data === null || data === void 0 ? void 0 : data.province : data === null || data === void 0 ? void 0 : data.country;
289
+ return _concatInstanceProperty(_context4 = "".concat(flag && curVal ? symbol : '')).call(_context4, curVal);
278
290
  } else {
279
- var _context4, _context5, _context6;
280
- return _concatInstanceProperty(_context4 = _concatInstanceProperty(_context5 = _concatInstanceProperty(_context6 = "".concat(flag && (data === null || data === void 0 ? void 0 : data.province) ? symbol : '')).call(_context6, data === null || data === void 0 ? void 0 : data.province)).call(_context5, (data === null || data === void 0 ? void 0 : data.country) && (data === null || data === void 0 ? void 0 : data.province) ? symbol : '')).call(_context4, data === null || data === void 0 ? void 0 : data.country);
291
+ var _context5, _context6, _context7;
292
+ return _concatInstanceProperty(_context5 = _concatInstanceProperty(_context6 = _concatInstanceProperty(_context7 = "".concat(flag && ((data === null || data === void 0 ? void 0 : data.province) || (data === null || data === void 0 ? void 0 : data.country)) ? symbol : '')).call(_context7, data === null || data === void 0 ? void 0 : data.province)).call(_context6, (data === null || data === void 0 ? void 0 : data.country) && (data === null || data === void 0 ? void 0 : data.province) ? symbol : '')).call(_context5, data === null || data === void 0 ? void 0 : data.country);
281
293
  }
282
294
  }, [type, tabsValue]);
283
295
  var renderSingle = function renderSingle() {
@@ -329,6 +341,81 @@ var InternalSelect = function InternalSelect(props, ref) {
329
341
  (_a = clearRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener('mouseup', fn);
330
342
  };
331
343
  }, [initValue]);
344
+ // keyboard
345
+ var curkeyboardList = useMemo(function () {
346
+ if (!searchValue) {
347
+ return commonList;
348
+ } else if (tabsValue === 'domestic') {
349
+ return domesticList;
350
+ } else {
351
+ return foreignList;
352
+ }
353
+ }, [commonList, domesticList, foreignList, searchValue, tabsValue]);
354
+ var getActiveIndex = function getActiveIndex(index) {
355
+ var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
356
+ var len = curkeyboardList.length;
357
+ for (var i = 0; i < len; i += 1) {
358
+ var current = (index + i * offset + len) % len;
359
+ return current;
360
+ }
361
+ return -1;
362
+ };
363
+ var _useState11 = useState(getActiveIndex(0)),
364
+ _useState12 = _slicedToArray(_useState11, 2),
365
+ activeIndex = _useState12[0],
366
+ setActiveIndex = _useState12[1];
367
+ var initActiveIndex = function initActiveIndex() {
368
+ setActiveIndex(getActiveIndex(0));
369
+ };
370
+ useEffect(function () {
371
+ initActiveIndex();
372
+ }, [searchValue, tabsValue]);
373
+ var onInternalKeyDown = function onInternalKeyDown(e) {
374
+ var _a, _b, _c;
375
+ var which = e.which;
376
+ // open
377
+ if (which === KeyCode.ENTER || which === KeyCode.UP || which === KeyCode.DOWN) {
378
+ e.preventDefault();
379
+ setOptionShow(true);
380
+ }
381
+ // up、down、enter、esc
382
+ if (optionShow) {
383
+ var offset = 0;
384
+ switch (which) {
385
+ case KeyCode.UP:
386
+ offset = -1;
387
+ break;
388
+ case KeyCode.DOWN:
389
+ offset = 1;
390
+ break;
391
+ case KeyCode.ENTER:
392
+ {
393
+ var item = curkeyboardList[activeIndex];
394
+ if (!item) return;
395
+ handleOption(item);
396
+ setOptionShow(false);
397
+ break;
398
+ }
399
+ case KeyCode.ESC:
400
+ setOptionShow(false);
401
+ break;
402
+ default:
403
+ break;
404
+ }
405
+ if (offset !== 0) {
406
+ var nextActiveIndex = getActiveIndex(activeIndex + offset, offset);
407
+ var curDom = (_b = (_a = optionsListRef.current) === null || _a === void 0 ? void 0 : _a.children) === null || _b === void 0 ? void 0 : _b[nextActiveIndex];
408
+ if (curDom) {
409
+ (_c = optionsListRef.current) === null || _c === void 0 ? void 0 : _c.children[nextActiveIndex].scrollIntoView({
410
+ behavior: 'auto',
411
+ block: 'nearest'
412
+ });
413
+ }
414
+ setActiveIndex(nextActiveIndex);
415
+ e.preventDefault();
416
+ }
417
+ }
418
+ };
332
419
  var renderCityPicker = function renderCityPicker() {
333
420
  return /*#__PURE__*/React.createElement("div", {
334
421
  className: cityPickerCls,
@@ -346,7 +433,8 @@ var InternalSelect = function InternalSelect(props, ref) {
346
433
  onBlur: function onBlur() {
347
434
  var _a;
348
435
  return (_a = searchRef.current) === null || _a === void 0 ? void 0 : _a.blur();
349
- }
436
+ },
437
+ onKeyDown: onInternalKeyDown
350
438
  }, renderSingle()));
351
439
  };
352
440
  var catchStyle = function catchStyle() {
@@ -364,6 +452,9 @@ var InternalSelect = function InternalSelect(props, ref) {
364
452
  }
365
453
  };
366
454
  var handleVisibleChange = function handleVisibleChange(visible) {
455
+ if (!visible) {
456
+ initActiveIndex();
457
+ }
367
458
  if (visible !== optionShow) {
368
459
  props.visible === undefined && setOptionShow(visible);
369
460
  onVisibleChange && onVisibleChange(visible);
@@ -52,7 +52,10 @@ export interface ICityPickerOptionProps {
52
52
  children?: React.ReactNode;
53
53
  className?: string;
54
54
  style?: React.CSSProperties;
55
+ activeIndex?: number;
56
+ index: number;
55
57
  onChangeSelect?: (city: City | null) => void;
56
58
  renderCityInfo?: (city: City, flag?: boolean, symbol?: string) => React.ReactNode;
57
59
  itemRender?: (city: City) => React.ReactNode;
60
+ onChangeActiveIndex?: (index: number) => void;
58
61
  }
@@ -8,11 +8,15 @@ var InternalOption = function InternalOption(props, ref) {
8
8
  var children = props.children,
9
9
  value = props.value,
10
10
  disabled = props.disabled,
11
+ className = props.className,
12
+ activeIndex = props.activeIndex,
13
+ index = props.index,
11
14
  onChangeSelect = props.onChangeSelect,
12
15
  _props$city = props.city,
13
16
  city = _props$city === void 0 ? {} : _props$city,
14
17
  renderCityInfo = props.renderCityInfo,
15
- itemRender = props.itemRender;
18
+ itemRender = props.itemRender,
19
+ onChangeActiveIndex = props.onChangeActiveIndex;
16
20
  var id = city.id,
17
21
  name = city.name;
18
22
  var _useContext = useContext(ConfigContext),
@@ -20,17 +24,25 @@ var InternalOption = function InternalOption(props, ref) {
20
24
  prefixCls = _useContext.prefixCls;
21
25
  var selectOptionPrefixCls = getPrefixCls(prefixCls, 'city-picker-list-item');
22
26
  var isSelected = id !== undefined ? id === value : false;
23
- var optionCls = classNames(selectOptionPrefixCls, (_classNames = {}, _defineProperty(_classNames, "".concat(selectOptionPrefixCls, "-selected"), isSelected), _defineProperty(_classNames, "".concat(selectOptionPrefixCls, "-disabled"), disabled), _classNames));
27
+ var optionCls = classNames(selectOptionPrefixCls, className, (_classNames = {}, _defineProperty(_classNames, "".concat(selectOptionPrefixCls, "-selected"), isSelected), _defineProperty(_classNames, "".concat(selectOptionPrefixCls, "-disabled"), disabled), _defineProperty(_classNames, "".concat(selectOptionPrefixCls, "-active"), activeIndex === index), _classNames));
24
28
  var handleClick = function handleClick(e) {
25
29
  e.preventDefault();
26
30
  if (disabled || id === undefined) return;
27
31
  onChangeSelect === null || onChangeSelect === void 0 ? void 0 : onChangeSelect(city);
28
32
  };
33
+ var handleOnMouseEnter = function handleOnMouseEnter() {
34
+ onChangeActiveIndex && onChangeActiveIndex(index);
35
+ };
36
+ var handleOnMouseLeave = function handleOnMouseLeave() {
37
+ onChangeActiveIndex && onChangeActiveIndex(-1);
38
+ };
29
39
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
30
40
  ref: optionRef,
31
41
  className: optionCls,
32
42
  title: name,
33
- onClick: handleClick
43
+ onClick: handleClick,
44
+ onMouseEnter: handleOnMouseEnter,
45
+ onMouseLeave: handleOnMouseLeave
34
46
  }, typeof itemRender === 'function' ? itemRender(city) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
35
47
  className: "".concat(selectOptionPrefixCls, "-content")
36
48
  }, children), /*#__PURE__*/React.createElement("span", {
@@ -121,6 +121,9 @@
121
121
  -ms-flex-direction: column;
122
122
  flex-direction: column;
123
123
  }
124
+ .kd-city-picker-selector {
125
+ width: 100%;
126
+ }
124
127
  .kd-city-picker-selector:hover .kd-city-picker-icon-active {
125
128
  color: #3761ca;
126
129
  }
@@ -309,6 +312,15 @@
309
312
  -ms-flex-pack: center;
310
313
  justify-content: center;
311
314
  }
315
+ .kd-city-picker-dropdown.topLeft.hidden,
316
+ .kd-city-picker-dropdown.bottomLeft.hidden,
317
+ .kd-city-picker-dropdown.topRight.hidden,
318
+ .kd-city-picker-dropdown.bottomRight.hidden {
319
+ opacity: 0;
320
+ visibility: hidden;
321
+ -webkit-transition: all calc(0.3s - 0.1s) cubic-bezier(0.4, 0, 0.6, 1);
322
+ transition: all calc(0.3s - 0.1s) cubic-bezier(0.4, 0, 0.6, 1);
323
+ }
312
324
  .kd-city-picker-list {
313
325
  padding: 8px 0;
314
326
  max-height: 320px;
@@ -334,18 +346,27 @@
334
346
  color: var(--kd-c-city-picker-placeholder-color-text, #b2b2b2);
335
347
  white-space: nowrap;
336
348
  }
337
- .kd-city-picker-list-item:hover {
349
+ .kd-city-picker-list-item-active:not(.kd-city-picker-list-item-disabled) {
338
350
  background-color: var(--kd-c-city-picker-color-background, #f5f5f5);
339
351
  }
340
352
  .kd-city-picker-list-item-selected:not(.kd-city-picker-list-item-disabled) {
341
353
  background-color: var(--kd-c-city-picker-color-background-selected, var(--kd-g-color-theme-3, #e3eeff));
342
354
  color: var(--kd-c-city-picker-list-item-color-text-selected, var(--kd-g-color-theme, #5582f3));
343
355
  }
356
+ .kd-city-picker-list-item-selected:not(.kd-city-picker-list-item-disabled) .kd-city-picker-list-item-info {
357
+ color: var(--kd-c-city-picker-list-item-color-text-selected, var(--kd-g-color-theme, #5582f3));
358
+ }
344
359
  .kd-city-picker-list-item-disabled {
345
360
  color: var(--kd-c-city-picker-item-color-text-disabled, var(--kd-g-color-disabled, #b2b2b2));
346
361
  cursor: not-allowed;
347
362
  background-color: var(--kd-c-city-picker-item-color-background-disabled, #fff);
348
363
  }
364
+ .kd-city-picker-list > .kd-city-picker-list-item-match {
365
+ color: var(--kd-c-city-picker-footer-color-text, var(--kd-g-color-text-primary, #212121));
366
+ }
367
+ .kd-city-picker-list > .kd-city-picker-list-item-match .kd-city-picker-list-item-info {
368
+ color: var(--kd-c-city-picker-placeholder-color-text, #b2b2b2);
369
+ }
349
370
  .kd-city-picker-highlight {
350
371
  color: var(--kd-c-city-picker-highlight-color-text, var(--kd-g-color-theme, #5582f3));
351
372
  }
@@ -446,12 +467,3 @@
446
467
  white-space: nowrap;
447
468
  text-overflow: ellipsis;
448
469
  }
449
- .kd-city-picker.topLeft.hidden,
450
- .kd-city-picker.bottomLeft.hidden,
451
- .kd-city-picker.topRight.hidden,
452
- .kd-city-picker.bottomRight.hidden {
453
- opacity: 0;
454
- visibility: hidden;
455
- -webkit-transition: all calc(0.3s - 0.1s) cubic-bezier(0.4, 0, 0.6, 1);
456
- transition: all calc(0.3s - 0.1s) cubic-bezier(0.4, 0, 0.6, 1);
457
- }
@@ -14,6 +14,9 @@
14
14
  display: flex;
15
15
  flex-direction: column;
16
16
 
17
+ &-selector {
18
+ width: 100%;
19
+ }
17
20
  &-selector:hover {
18
21
  .@{city-picker-prefix-cls}-icon-active {
19
22
  color: #3761ca;
@@ -199,6 +202,15 @@
199
202
  align-items: center;
200
203
  justify-content: center;
201
204
  }
205
+
206
+ &.topLeft.hidden,
207
+ &.bottomLeft.hidden,
208
+ &.topRight.hidden,
209
+ &.bottomRight.hidden {
210
+ opacity: 0;
211
+ visibility: hidden;
212
+ transition: all calc(@transition-duration - 0.1s) @ease;
213
+ }
202
214
  }
203
215
 
204
216
  &-list {
@@ -218,13 +230,17 @@
218
230
  white-space: nowrap;
219
231
  }
220
232
 
221
- &:hover {
233
+ &-active:not(&-disabled) {
222
234
  background-color: @city-picker-item-active-bg;
223
235
  }
224
236
 
225
237
  &-selected:not(&-disabled) {
226
238
  background-color: @city-picker-item-selected-bg;
227
239
  color: @city-picker-list-item-color-selected;
240
+
241
+ .@{city-picker-prefix-cls}-list-item-info {
242
+ color: @city-picker-list-item-color-selected;
243
+ }
228
244
  }
229
245
 
230
246
  &-disabled {
@@ -233,6 +249,13 @@
233
249
  background-color: @city-picker-disabled-option-bg;
234
250
  }
235
251
  }
252
+
253
+ & > .@{city-picker-prefix-cls}-list-item-match {
254
+ color: @city-picker-font-color;
255
+ .@{city-picker-prefix-cls}-list-item-info {
256
+ color: @city-picker-placeholder-color;
257
+ }
258
+ }
236
259
  }
237
260
 
238
261
  &-highlight {
@@ -323,13 +346,4 @@
323
346
  .over();
324
347
  }
325
348
  }
326
-
327
- &.topLeft.hidden,
328
- &.bottomLeft.hidden,
329
- &.topRight.hidden,
330
- &.bottomRight.hidden {
331
- opacity: 0;
332
- visibility: hidden;
333
- transition: all calc(@transition-duration - 0.1s) @ease;
334
- }
335
349
  }
@@ -1,6 +1,16 @@
1
+ import _extends from "@babel/runtime-corejs3/helpers/extends";
1
2
  import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
2
3
  import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
4
+ import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
3
5
  import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
6
+ var __rest = this && this.__rest || function (s, e) {
7
+ var t = {};
8
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
9
+ if (s != null && typeof _Object$getOwnPropertySymbols === "function") for (var i = 0, p = _Object$getOwnPropertySymbols(s); i < p.length; i++) {
10
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
11
+ }
12
+ return t;
13
+ };
4
14
  import React, { useEffect, useRef, useState } from 'react';
5
15
  import classNames from 'classnames';
6
16
  import ConfigContext from '../config-provider/ConfigContext';
@@ -12,21 +22,23 @@ var Panel = /*#__PURE__*/React.forwardRef(function (props, ref) {
12
22
  getPrefixCls = _React$useContext.getPrefixCls,
13
23
  prefixCls = _React$useContext.prefixCls,
14
24
  userDefaultProps = _React$useContext.compDefaultProps;
15
- var _getCompProps = getCompProps('CollapsePanel', userDefaultProps, props),
16
- disabled = _getCompProps.disabled,
17
- extra = _getCompProps.extra,
18
- assist = _getCompProps.assist,
19
- header = _getCompProps.header,
20
- onChange = _getCompProps.onChange,
21
- panelKey = _getCompProps.panelKey,
22
- innerKey = _getCompProps.innerKey,
23
- bordered = _getCompProps.bordered,
24
- expandIcon = _getCompProps.expandIcon,
25
- expandIconPosition = _getCompProps.expandIconPosition,
26
- style = _getCompProps.style,
27
- className = _getCompProps.className,
28
- children = _getCompProps.children,
29
- customPrefixcls = _getCompProps.prefixCls;
25
+ var _a = getCompProps('CollapsePanel', userDefaultProps, props),
26
+ disabled = _a.disabled,
27
+ extra = _a.extra,
28
+ assist = _a.assist,
29
+ header = _a.header,
30
+ onChange = _a.onChange,
31
+ panelKey = _a.panelKey,
32
+ innerKey = _a.innerKey,
33
+ bordered = _a.bordered,
34
+ expandIcon = _a.expandIcon,
35
+ expandIconPosition = _a.expandIconPosition,
36
+ style = _a.style,
37
+ title = _a.title,
38
+ className = _a.className,
39
+ children = _a.children,
40
+ customPrefixcls = _a.prefixCls,
41
+ others = __rest(_a, ["disabled", "extra", "assist", "header", "onChange", "panelKey", "innerKey", "bordered", "expandIcon", "expandIconPosition", "style", "title", "className", "children", "prefixCls"]);
30
42
  var panelPrefixCls = getPrefixCls(prefixCls, 'collapse-panel', customPrefixcls); // 样式前缀
31
43
  var childrenRef = useRef();
32
44
  var setHeightTimerRef = useRef(null);
@@ -68,7 +80,8 @@ var Panel = /*#__PURE__*/React.forwardRef(function (props, ref) {
68
80
  className: className,
69
81
  onClick: handleClick
70
82
  }, expandIconPosition === 'left' ? renderIcon() : null, header && /*#__PURE__*/React.createElement("span", {
71
- className: headerClassName
83
+ className: headerClassName,
84
+ title: title
72
85
  }, renderReactNode(header)));
73
86
  };
74
87
  var renderRight = function renderRight() {
@@ -135,11 +148,11 @@ var Panel = /*#__PURE__*/React.forwardRef(function (props, ref) {
135
148
  expand ? expandWidthoutAnimation(childrenRef.current) : runCollapseAnimation(childrenRef.current);
136
149
  }
137
150
  }, [childrenRef.current, expandAnimation, expand]);
138
- return /*#__PURE__*/React.createElement("div", {
151
+ return /*#__PURE__*/React.createElement("div", _extends({
139
152
  className: rootClassName,
140
153
  style: style,
141
154
  ref: panelPrefixClsRef
142
- }, /*#__PURE__*/React.createElement("span", {
155
+ }, others), /*#__PURE__*/React.createElement("span", {
143
156
  className: topClassName
144
157
  }, renderLeft(), renderMiddle(), renderRight()), /*#__PURE__*/React.createElement("div", {
145
158
  className: childrenClassName,
@@ -116,9 +116,12 @@
116
116
  .kd-collapse-panel:last-child {
117
117
  border-top: none;
118
118
  }
119
- .kd-collapse-panel:first-child {
119
+ .kd-collapse-panel-border.kd-collapse-panel:first-child {
120
120
  border-top: var(--kd-c-collapse-border-width, 1px) solid var(--kd-c-collapse-color-border-strong-2, var(--kd-g-color-border-strong-2, #d9d9d9));
121
121
  }
122
+ .kd-collapse-panel-border.kd-collapse-panel:not(:nth-child(1)) {
123
+ border-top: none;
124
+ }
122
125
  .kd-collapse-panel {
123
126
  display: -webkit-inline-box;
124
127
  display: -ms-inline-flexbox;
@@ -9,9 +9,12 @@
9
9
  &-panel:last-child {
10
10
  border-top: none;
11
11
  }
12
- &-panel:first-child {
12
+ &-panel-border&-panel:first-child {
13
13
  border-top: @collapse-border-width solid @collapse-border-color;
14
14
  }
15
+ &-panel-border&-panel:not(:nth-child(1)) {
16
+ border-top: none;
17
+ }
15
18
  &-panel {
16
19
  display: inline-flex;
17
20
  flex-direction: column;
@@ -17,6 +17,7 @@ export interface FormItemProps {
17
17
  validateTrigger?: string | string[];
18
18
  wrapperWidth?: string | number;
19
19
  valuePropName?: string;
20
+ extra?: React.ReactNode;
20
21
  }
21
22
  export declare const INNER_VALUE_PROPS_LIST: {
22
23
  name: string;
package/es/form/Field.js CHANGED
@@ -101,7 +101,8 @@ var Field = function Field(props) {
101
101
  wrapperWidth = props.wrapperWidth,
102
102
  validateTrigger = props.validateTrigger,
103
103
  defaultValue = props.defaultValue,
104
- valuePropName = props.valuePropName;
104
+ valuePropName = props.valuePropName,
105
+ extra = props.extra;
105
106
  var htmlFor = customizeHtmlFor || (name ? _concatInstanceProperty(_context = "form_".concat(name, "_")).call(_context, (Math.random() * 100).toFixed(0)) : undefined);
106
107
  var childrenNode = null;
107
108
  var innerValuePropName = 'value';
@@ -187,7 +188,7 @@ var Field = function Field(props) {
187
188
  };
188
189
  }, []);
189
190
  var formPrefixCls = getPrefixCls === null || getPrefixCls === void 0 ? void 0 : getPrefixCls(prefixCls, 'form', customizePrefixcls);
190
- var formItemClassName = classnames((_classnames = {}, _defineProperty(_classnames, "".concat(formPrefixCls), true), _defineProperty(_classnames, "".concat(formPrefixCls, "-field"), true), _defineProperty(_classnames, "".concat(formPrefixCls, "-field-hidden"), hidden), _defineProperty(_classnames, "".concat(formPrefixCls, "-field-vertical"), vertical), _classnames), className);
191
+ var formItemClassName = classnames((_classnames = {}, _defineProperty(_classnames, "".concat(formPrefixCls), true), _defineProperty(_classnames, "".concat(formPrefixCls, "-field"), true), _defineProperty(_classnames, "".concat(formPrefixCls, "-field-hidden"), hidden), _defineProperty(_classnames, "".concat(formPrefixCls, "-field-vertical"), vertical), _defineProperty(_classnames, "".concat(formPrefixCls, "-field-extra"), extra), _classnames), className);
191
192
  var value = getFieldValue(name);
192
193
  var validateMessage = getFieldError(name);
193
194
  var getInputValueFormProp = function getInputValueFormProp(evt) {
@@ -282,7 +283,8 @@ var Field = function Field(props) {
282
283
  requiredMark: mergedRequired
283
284
  }), /*#__PURE__*/React.createElement(FieldWrapper, {
284
285
  width: wrapperWidth,
285
- validateMessage: validateMessage
286
+ validateMessage: validateMessage,
287
+ extra: extra
286
288
  }, _mapInstanceProperty(childrenArray).call(childrenArray, function (child, index) {
287
289
  var keys = mergeProps(_extends(_extends({}, generateEventHandler(handleValueValidate, validateTrigger)), {
288
290
  key: index,
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  export interface FieldWrapperProps {
3
+ extra?: React.ReactNode;
3
4
  children?: React.ReactNode;
4
5
  width?: string | number;
5
6
  validateMessage?: string;
@@ -11,18 +11,26 @@ var FieldWrapper = function FieldWrapper(props) {
11
11
  var children = wrapperProps.children,
12
12
  customizePrefixCls = wrapperProps.prefixCls,
13
13
  width = wrapperProps.width,
14
- validateMessage = wrapperProps.validateMessage;
14
+ validateMessage = wrapperProps.validateMessage,
15
+ extra = wrapperProps.extra;
15
16
  var wrapperPrefixCls = getPrefixCls === null || getPrefixCls === void 0 ? void 0 : getPrefixCls(prefixCls, 'form-field-wrapper', customizePrefixCls);
16
17
  var wrapperClassName = classnames(["".concat(wrapperPrefixCls)]);
17
18
  var messageClassName = classnames(["".concat(wrapperPrefixCls, "-message")]);
19
+ var validate = validateMessage ? /*#__PURE__*/React.createElement("p", {
20
+ className: messageClassName,
21
+ title: validateMessage
22
+ }, validateMessage) : null;
18
23
  return /*#__PURE__*/React.createElement("div", {
19
24
  className: wrapperClassName,
20
25
  style: {
21
26
  width: width
22
27
  }
23
- }, children, validateMessage && /*#__PURE__*/React.createElement("p", {
24
- className: messageClassName,
25
- title: validateMessage
26
- }, validateMessage));
28
+ }, children, extra ? /*#__PURE__*/React.createElement("div", {
29
+ className: "".concat(wrapperPrefixCls, "-extra")
30
+ }, /*#__PURE__*/React.createElement("div", {
31
+ className: "".concat(wrapperPrefixCls, "-extra-message")
32
+ }, validateMessage), /*#__PURE__*/React.createElement("div", {
33
+ className: "".concat(wrapperPrefixCls, "-extra-text")
34
+ }, extra)) : /*#__PURE__*/React.createElement(React.Fragment, null, validate));
27
35
  };
28
36
  export default FieldWrapper;
@@ -152,6 +152,9 @@
152
152
  .kd-form-field-hidden {
153
153
  display: none !important;
154
154
  }
155
+ .kd-form-field-extra {
156
+ margin-bottom: calc(var(--kd-c-form-field-spacing-margin-bottom, 22px) * 2);
157
+ }
155
158
  .kd-form-field-label {
156
159
  font-size: var(--kd-c-form-field-label-font-size, 12px);
157
160
  line-height: var(--kd-c-form-field-label-line-height, 18px);
@@ -178,7 +181,8 @@
178
181
  .kd-form-field-wrapper {
179
182
  position: relative;
180
183
  }
181
- .kd-form-field-wrapper-message {
184
+ .kd-form-field-wrapper-message,
185
+ .kd-form-field-wrapper-extra {
182
186
  position: absolute;
183
187
  left: -7px;
184
188
  right: 0;
@@ -191,3 +195,9 @@
191
195
  white-space: nowrap;
192
196
  text-overflow: ellipsis;
193
197
  }
198
+ .kd-form-field-wrapper-extra-message {
199
+ color: var(--kd-c-form-error-color, var(--kd-g-color-error, #fb2323));
200
+ }
201
+ .kd-form-field-wrapper-extra-text {
202
+ color: var(--kd-c-form-extra-color, var(--kd-g-color-text-third, #999));
203
+ }
@@ -46,6 +46,10 @@
46
46
  &-hidden {
47
47
  display: none !important;
48
48
  }
49
+
50
+ &-extra {
51
+ margin-bottom: calc(@form-field-spacing-margin-bottom * 2);
52
+ }
49
53
  }
50
54
 
51
55
  .@{field-label-cls} {
@@ -76,7 +80,8 @@
76
80
 
77
81
  .@{field-wrapper-cls} {
78
82
  position: relative;
79
- &-message {
83
+
84
+ &-message, &-extra {
80
85
  position: absolute;
81
86
  left: -7px;
82
87
  right: 0;
@@ -89,4 +94,14 @@
89
94
  white-space: nowrap;
90
95
  text-overflow: ellipsis;
91
96
  }
97
+
98
+ &-extra {
99
+ &-message {
100
+ color: @form-error-color;
101
+ }
102
+
103
+ &-text {
104
+ color: @form-extra-color;
105
+ }
106
+ }
92
107
  }
@@ -5,6 +5,7 @@
5
5
  // color
6
6
  @form-field-color: var(~'@{form-prefix}-field-color', @color-text-secondary);
7
7
  @form-error-color: var(~'@{form-prefix}-error-color', @color-error);
8
+ @form-extra-color: var(~'@{form-prefix}-extra-color', @color-text-third);
8
9
 
9
10
  // font
10
11
  @form-field-label-font-size: var(~'@{form-prefix}-field-label-font-size',12px);
@@ -405,6 +405,7 @@
405
405
  min-width: 75px;
406
406
  }
407
407
  .kd-select-item-option-content {
408
+ max-width: var(--kd-c-select-item-sizing-max-width);
408
409
  overflow: hidden;
409
410
  white-space: nowrap;
410
411
  text-overflow: ellipsis;
@@ -176,6 +176,7 @@
176
176
  min-width: 75px;
177
177
 
178
178
  &-content {
179
+ max-width: @select-item-max-width;
179
180
  .over();
180
181
 
181
182
  .@{kd-prefix}-checkbox {