@douyinfe/semi-foundation 2.2.2 → 2.3.0-beta.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.
Files changed (112) hide show
  1. package/breadcrumb/foundation.ts +10 -1
  2. package/checkbox/checkboxFoundation.ts +9 -0
  3. package/form/foundation.ts +20 -8
  4. package/form/utils.ts +2 -0
  5. package/input/foundation.ts +21 -2
  6. package/input/textareaFoundation.ts +11 -1
  7. package/lib/cjs/breadcrumb/foundation.d.ts +4 -0
  8. package/lib/cjs/breadcrumb/foundation.js +12 -0
  9. package/lib/cjs/checkbox/checkboxFoundation.d.ts +3 -0
  10. package/lib/cjs/checkbox/checkboxFoundation.js +8 -0
  11. package/lib/cjs/form/foundation.d.ts +13 -0
  12. package/lib/cjs/form/foundation.js +32 -8
  13. package/lib/cjs/form/utils.d.ts +1 -0
  14. package/lib/cjs/form/utils.js +5 -3
  15. package/lib/cjs/input/foundation.d.ts +8 -0
  16. package/lib/cjs/input/foundation.js +24 -2
  17. package/lib/cjs/input/textareaFoundation.d.ts +5 -1
  18. package/lib/cjs/input/textareaFoundation.js +12 -0
  19. package/lib/cjs/modal/modalContentFoundation.d.ts +7 -0
  20. package/lib/cjs/modal/modalContentFoundation.js +14 -0
  21. package/lib/cjs/navigation/itemFoundation.d.ts +5 -0
  22. package/lib/cjs/navigation/itemFoundation.js +12 -0
  23. package/lib/cjs/navigation/subNavFoundation.d.ts +6 -0
  24. package/lib/cjs/navigation/subNavFoundation.js +14 -0
  25. package/lib/cjs/radio/radio.css +7 -1
  26. package/lib/cjs/radio/radio.scss +8 -1
  27. package/lib/cjs/select/foundation.d.ts +2 -0
  28. package/lib/cjs/select/foundation.js +40 -6
  29. package/lib/cjs/sideSheet/sideSheetFoundation.d.ts +1 -0
  30. package/lib/cjs/slider/foundation.d.ts +6 -1
  31. package/lib/cjs/slider/foundation.js +6 -12
  32. package/lib/cjs/slider/slider.css +1 -0
  33. package/lib/cjs/slider/slider.scss +1 -0
  34. package/lib/cjs/table/utils.d.ts +7 -0
  35. package/lib/cjs/table/utils.js +26 -0
  36. package/lib/cjs/tagInput/foundation.d.ts +4 -0
  37. package/lib/cjs/tagInput/foundation.js +12 -0
  38. package/lib/cjs/tooltip/foundation.js +7 -6
  39. package/lib/cjs/transfer/transfer.css +0 -2
  40. package/lib/cjs/transfer/transfer.scss +0 -2
  41. package/lib/cjs/tree/foundation.d.ts +1 -0
  42. package/lib/cjs/tree/foundation.js +1 -1
  43. package/lib/cjs/treeSelect/foundation.d.ts +9 -1
  44. package/lib/cjs/treeSelect/foundation.js +22 -0
  45. package/lib/cjs/utils/isEnterPress.d.ts +4 -0
  46. package/lib/cjs/utils/isEnterPress.js +22 -0
  47. package/lib/cjs/utils/keyCode.d.ts +2 -0
  48. package/lib/cjs/utils/keyCode.js +5 -1
  49. package/lib/cjs/utils/uuid.d.ts +15 -1
  50. package/lib/cjs/utils/uuid.js +31 -0
  51. package/lib/es/breadcrumb/foundation.d.ts +4 -0
  52. package/lib/es/breadcrumb/foundation.js +11 -0
  53. package/lib/es/checkbox/checkboxFoundation.d.ts +3 -0
  54. package/lib/es/checkbox/checkboxFoundation.js +7 -0
  55. package/lib/es/form/foundation.d.ts +13 -0
  56. package/lib/es/form/foundation.js +31 -8
  57. package/lib/es/form/utils.d.ts +1 -0
  58. package/lib/es/form/utils.js +5 -3
  59. package/lib/es/input/foundation.d.ts +8 -0
  60. package/lib/es/input/foundation.js +23 -2
  61. package/lib/es/input/textareaFoundation.d.ts +5 -1
  62. package/lib/es/input/textareaFoundation.js +11 -0
  63. package/lib/es/modal/modalContentFoundation.d.ts +7 -0
  64. package/lib/es/modal/modalContentFoundation.js +14 -0
  65. package/lib/es/navigation/itemFoundation.d.ts +5 -0
  66. package/lib/es/navigation/itemFoundation.js +11 -0
  67. package/lib/es/navigation/subNavFoundation.d.ts +6 -0
  68. package/lib/es/navigation/subNavFoundation.js +13 -0
  69. package/lib/es/radio/radio.css +7 -1
  70. package/lib/es/radio/radio.scss +8 -1
  71. package/lib/es/select/foundation.d.ts +2 -0
  72. package/lib/es/select/foundation.js +31 -6
  73. package/lib/es/sideSheet/sideSheetFoundation.d.ts +1 -0
  74. package/lib/es/slider/foundation.d.ts +6 -1
  75. package/lib/es/slider/foundation.js +6 -12
  76. package/lib/es/slider/slider.css +1 -0
  77. package/lib/es/slider/slider.scss +1 -0
  78. package/lib/es/table/utils.d.ts +7 -0
  79. package/lib/es/table/utils.js +24 -0
  80. package/lib/es/tagInput/foundation.d.ts +4 -0
  81. package/lib/es/tagInput/foundation.js +11 -0
  82. package/lib/es/tooltip/foundation.js +7 -6
  83. package/lib/es/transfer/transfer.css +0 -2
  84. package/lib/es/transfer/transfer.scss +0 -2
  85. package/lib/es/tree/foundation.d.ts +1 -0
  86. package/lib/es/tree/foundation.js +1 -1
  87. package/lib/es/treeSelect/foundation.d.ts +9 -1
  88. package/lib/es/treeSelect/foundation.js +22 -1
  89. package/lib/es/utils/isEnterPress.d.ts +4 -0
  90. package/lib/es/utils/isEnterPress.js +8 -0
  91. package/lib/es/utils/keyCode.d.ts +2 -0
  92. package/lib/es/utils/keyCode.js +2 -0
  93. package/lib/es/utils/uuid.d.ts +15 -1
  94. package/lib/es/utils/uuid.js +31 -1
  95. package/modal/modalContentFoundation.ts +18 -0
  96. package/navigation/itemFoundation.ts +11 -0
  97. package/navigation/subNavFoundation.ts +12 -0
  98. package/package.json +3 -3
  99. package/radio/radio.scss +8 -1
  100. package/select/foundation.ts +26 -7
  101. package/sideSheet/sideSheetFoundation.ts +3 -5
  102. package/slider/foundation.ts +10 -13
  103. package/slider/slider.scss +1 -0
  104. package/table/utils.ts +16 -0
  105. package/tagInput/foundation.ts +10 -0
  106. package/tooltip/foundation.ts +5 -5
  107. package/transfer/transfer.scss +0 -2
  108. package/tree/foundation.ts +2 -1
  109. package/treeSelect/foundation.ts +20 -0
  110. package/utils/isEnterPress.ts +8 -0
  111. package/utils/keyCode.ts +3 -0
  112. package/utils/uuid.ts +23 -1
@@ -236,7 +236,13 @@
236
236
  }
237
237
  .semi-radio .semi-radio-inner-buttonRadio,
238
238
  .semi-radio .semi-radio-inner-pureCardRadio {
239
- display: none;
239
+ position: absolute;
240
+ top: 0;
241
+ left: 0;
242
+ width: 100%;
243
+ height: 100%;
244
+ z-index: -1;
245
+ opacity: 0;
240
246
  }
241
247
  .semi-radio-disabled, .semi-radio-disabled:hover {
242
248
  cursor: not-allowed;
@@ -317,9 +317,16 @@ $inner-width: $width-icon-medium;
317
317
  }
318
318
  }
319
319
 
320
+ // A11y: arrow keyboard control
320
321
  .#{$module}-inner-buttonRadio,
321
322
  .#{$module}-inner-pureCardRadio {
322
- display: none;
323
+ position: absolute;
324
+ top: 0;
325
+ left: 0;
326
+ width: 100%;
327
+ height: 100%;
328
+ z-index: -1;
329
+ opacity: 0;
323
330
  }
324
331
 
325
332
  &-disabled {
@@ -101,6 +101,8 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
101
101
  handleMouseEnter(e: MouseEvent): void;
102
102
  handleMouseLeave(e: MouseEvent): void;
103
103
  handleClearClick(e: MouseEvent): void;
104
+ handleKeyPress(e: KeyboardEvent): void;
105
+ handleClearBtnEnterPress(e: KeyboardEvent): void;
104
106
  handleOptionMouseEnter(optionIndex: number): void;
105
107
  handleListScroll(e: any): void;
106
108
  handleTriggerBlur(e: FocusEvent): void;
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
 
3
+ var _WeakMap = require("@babel/runtime-corejs3/core-js-stable/weak-map");
4
+
3
5
  var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
4
6
 
7
+ var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
8
+
5
9
  var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
6
10
 
7
11
  _Object$defineProperty(exports, "__esModule", {
@@ -46,12 +50,18 @@ var _isNumber2 = _interopRequireDefault(require("lodash/isNumber"));
46
50
 
47
51
  var _foundation = _interopRequireDefault(require("../base/foundation"));
48
52
 
49
- var _keyCode = _interopRequireDefault(require("../utils/keyCode"));
53
+ var _keyCode = _interopRequireWildcard(require("../utils/keyCode"));
50
54
 
51
55
  var _warning = _interopRequireDefault(require("../utils/warning"));
52
56
 
53
57
  var _isNullOrUndefined = _interopRequireDefault(require("../utils/isNullOrUndefined"));
54
58
 
59
+ var _isEnterPress = _interopRequireDefault(require("../utils/isEnterPress"));
60
+
61
+ function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
62
+
63
+ 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; }
64
+
55
65
  var __rest = void 0 && (void 0).__rest || function (s, e) {
56
66
  var t = {};
57
67
 
@@ -536,6 +546,10 @@ class SelectFoundation extends _foundation.default {
536
546
 
537
547
  const selections = this._adapter.getSelections();
538
548
 
549
+ const {
550
+ autoClearSearchValue
551
+ } = this.getProps();
552
+
539
553
  if (selections.has(label)) {
540
554
  this._notifyDeselect(value, (0, _assign.default)({
541
555
  value,
@@ -567,7 +581,10 @@ class SelectFoundation extends _foundation.default {
567
581
  this._notifyChange(selections);
568
582
 
569
583
  if (this._isFilterable()) {
570
- this.clearInput();
584
+ if (autoClearSearchValue) {
585
+ this.clearInput();
586
+ }
587
+
571
588
  this.focusInput();
572
589
  }
573
590
  } else {
@@ -582,11 +599,15 @@ class SelectFoundation extends _foundation.default {
582
599
  } = this.getStates(); // Searchable filtering, when selected, resets Input
583
600
 
584
601
  if (this._isFilterable()) {
585
- this.clearInput();
586
- this.focusInput(); // At the same time, the filtering of options is also cleared, in order to show all candidates
602
+ // When filter active,if autoClearSearchValue is true,reset input after select
603
+ if (autoClearSearchValue) {
604
+ this.clearInput(); // At the same time, the filtering of options is also cleared, in order to show all candidates
587
605
 
588
- const sugInput = '';
589
- options = this._filterOption(options, sugInput);
606
+ const sugInput = '';
607
+ options = this._filterOption(options, sugInput);
608
+ }
609
+
610
+ this.focusInput();
590
611
  }
591
612
 
592
613
  this.updateOptionsActiveStatus(selections, options);
@@ -860,6 +881,7 @@ class SelectFoundation extends _foundation.default {
860
881
  break;
861
882
 
862
883
  case _keyCode.default.ESC:
884
+ case _keyCode.default.TAB:
863
885
  this.close(event);
864
886
  break;
865
887
 
@@ -1134,6 +1156,18 @@ class SelectFoundation extends _foundation.default {
1134
1156
  e.stopPropagation();
1135
1157
  }
1136
1158
 
1159
+ handleKeyPress(e) {
1160
+ if (e && e.key === _keyCode.ENTER_KEY) {
1161
+ this.handleClick(e);
1162
+ }
1163
+ }
1164
+
1165
+ handleClearBtnEnterPress(e) {
1166
+ if ((0, _isEnterPress.default)(e)) {
1167
+ this.handleClearClick(e);
1168
+ }
1169
+ }
1170
+
1137
1171
  handleOptionMouseEnter(optionIndex) {
1138
1172
  this._adapter.updateFocusIndex(optionIndex);
1139
1173
  }
@@ -25,6 +25,7 @@ export interface SideSheetProps {
25
25
  width?: number | string;
26
26
  zIndex?: number;
27
27
  children?: any;
28
+ 'aria-label'?: string;
28
29
  }
29
30
  export interface SideSheetState {
30
31
  hidden: boolean;
@@ -23,6 +23,10 @@ export interface SliderProps {
23
23
  showBoundary?: boolean;
24
24
  railStyle?: Record<string, any>;
25
25
  verticalReverse?: boolean;
26
+ 'aria-label'?: string;
27
+ 'aria-labelledby'?: string;
28
+ 'aria-valuetext'?: string;
29
+ getAriaValueText?: (value: number) => string;
26
30
  }
27
31
  export interface SliderState {
28
32
  currentValue: number | number[];
@@ -138,7 +142,7 @@ export default class SliderFoundation extends BaseFoundation<SliderAdapter> {
138
142
  *
139
143
  * @memberof SliderFoundation
140
144
  */
141
- getScrollParent: (element: HTMLElement) => boolean | Element;
145
+ getScrollParent: (element: HTMLElement) => Element;
142
146
  /**
143
147
  * Fixed the event location, beyond the maximum, minimum, left and right, etc. directly modified to the effective location
144
148
  *
@@ -184,6 +188,7 @@ export default class SliderFoundation extends BaseFoundation<SliderAdapter> {
184
188
  onHandleEnter: (pos: SliderState['focusPos']) => void;
185
189
  onHandleLeave: () => void;
186
190
  onHandleUp: (e: any) => boolean;
191
+ onFocus: (e: any, handler: 'min' | 'max') => void;
187
192
  handleWrapClick: (e: any) => void;
188
193
  /**
189
194
  * Move the slider to the current click position
@@ -286,17 +286,8 @@ class SliderFoundation extends _foundation.default {
286
286
  }
287
287
 
288
288
  if (step !== 1) {
289
- // Existence step
290
- if (stepValue > compareValue && Math.round(stepValue / step) * step >= stepValue) {
291
- // Move right
292
- stepValue = Math.round(stepValue / step) * step;
293
- } else if (stepValue < compareValue && Math.round(stepValue / step) * step <= stepValue) {
294
- // Move left
295
- stepValue = Math.round(stepValue / step) * step;
296
- } else {
297
- // Other moves are invalid, click valid
298
- stepValue = compareValue;
299
- }
289
+ // Find nearest step point
290
+ stepValue = Math.round(stepValue / step) * step;
300
291
  }
301
292
 
302
293
  if (range && stepValue !== compareValue) {
@@ -610,7 +601,10 @@ class SliderFoundation extends _foundation.default {
610
601
  this._adapter.onHandleUpAfter();
611
602
 
612
603
  return true;
613
- };
604
+ }; // eslint-disable-next-line @typescript-eslint/no-empty-function
605
+
606
+
607
+ this.onFocus = (e, handler) => {};
614
608
 
615
609
  this.handleWrapClick = e => {
616
610
  const {
@@ -51,6 +51,7 @@
51
51
  }
52
52
  .semi-slider-handle-clicked {
53
53
  border: solid 1px var(--semi-color-focus-border);
54
+ cursor: grabbing;
54
55
  }
55
56
  .semi-slider-track {
56
57
  height: 4px;
@@ -63,6 +63,7 @@ $module: #{$prefix}-slider;
63
63
 
64
64
  &-handle-clicked {
65
65
  border: solid $width-slider_handle_clicked $color-slider_handle-border-focus;
66
+ cursor: grabbing;
66
67
  }
67
68
 
68
69
  &-track {
@@ -93,3 +93,10 @@ export interface GetAllDisabledRowKeysProps {
93
93
  rowKey?: string | number | ((record: Record<string, any>) => string | number);
94
94
  }
95
95
  export declare function warnIfNoDataIndex(column: Record<string, any>): void;
96
+ /**
97
+ * Whether is tree table
98
+ */
99
+ export declare function isTreeTable({ dataSource, childrenRecordName }: {
100
+ dataSource: Record<string, any>;
101
+ childrenRecordName?: string;
102
+ }): boolean;
@@ -41,6 +41,7 @@ exports.isLastLeftFixed = isLastLeftFixed;
41
41
  exports.isScrollbarColumn = isScrollbarColumn;
42
42
  exports.isSelected = isSelected;
43
43
  exports.isSelectionColumn = isSelectionColumn;
44
+ exports.isTreeTable = isTreeTable;
44
45
  exports.mergeColumns = mergeColumns;
45
46
  exports.mergeQueries = mergeQueries;
46
47
  exports.sliceColumnsByLevel = sliceColumnsByLevel;
@@ -614,4 +615,29 @@ function warnIfNoDataIndex(column) {
614
615
  logger.warn("The column with sorter or filter must pass the 'dataIndex' prop");
615
616
  }
616
617
  }
618
+ }
619
+ /**
620
+ * Whether is tree table
621
+ */
622
+
623
+
624
+ function isTreeTable(_ref2) {
625
+ let {
626
+ dataSource,
627
+ childrenRecordName = 'children'
628
+ } = _ref2;
629
+ let flag = false;
630
+
631
+ if ((0, _isArray.default)(dataSource)) {
632
+ for (const data of dataSource) {
633
+ const children = (0, _get2.default)(data, childrenRecordName);
634
+
635
+ if ((0, _isArray.default)(children) && children.length) {
636
+ flag = true;
637
+ break;
638
+ }
639
+ }
640
+ }
641
+
642
+ return flag;
617
643
  }
@@ -33,6 +33,10 @@ declare class TagInputFoundation extends BaseFoundation<TagInputAdapter> {
33
33
  _handleAddTags(e: TagInputChangeEvent): void;
34
34
  handleInputBlur(e: TagInputCursorEvent): void;
35
35
  handleInputFocus(e: TagInputCursorEvent): void;
36
+ /**
37
+ * A11y: simulate clear button click
38
+ */
39
+ handleClearEnterPress(e: TagInputKeyboardEvent): void;
36
40
  handleClearBtn(e: TagInputMouseEvent): void;
37
41
  handleTagClose(index: number): void;
38
42
  handleInputMouseEnter(): void;
@@ -40,6 +40,8 @@ var _keyCode = _interopRequireDefault(require("../utils/keyCode"));
40
40
 
41
41
  var _getSplitedArray = _interopRequireDefault(require("./utils/getSplitedArray"));
42
42
 
43
+ var _isEnterPress = _interopRequireDefault(require("../utils/isEnterPress"));
44
+
43
45
  class TagInputFoundation extends _foundation.default {
44
46
  constructor(adapter) {
45
47
  super((0, _assign.default)({}, adapter));
@@ -185,6 +187,16 @@ class TagInputFoundation extends _foundation.default {
185
187
 
186
188
  this._adapter.notifyFocus(e);
187
189
  }
190
+ /**
191
+ * A11y: simulate clear button click
192
+ */
193
+
194
+
195
+ handleClearEnterPress(e) {
196
+ if ((0, _isEnterPress.default)(e)) {
197
+ this.handleClearBtn(e);
198
+ }
199
+ }
188
200
 
189
201
  handleClearBtn(e) {
190
202
  const {
@@ -96,8 +96,6 @@ class Tooltip extends _foundation.default {
96
96
  if (trigger === 'custom') {
97
97
  // eslint-disable-next-line
98
98
  this._adapter.registerClickOutsideHandler(() => {});
99
-
100
- this._togglePortalVisible(true);
101
99
  }
102
100
  /**
103
101
  * trigger类型是click时,仅当portal被插入显示后,才绑定clickOutsideHandler
@@ -643,6 +641,9 @@ class Tooltip extends _foundation.default {
643
641
  innerWidth,
644
642
  innerHeight
645
643
  } = window;
644
+ const {
645
+ spacing
646
+ } = this.getProps();
646
647
 
647
648
  if (wrapperRect.width > 0 && wrapperRect.height > 0) {
648
649
  // let clientLeft = left + translateX * wrapperRect.width - containerRect.scrollLeft;
@@ -666,10 +667,10 @@ class Tooltip extends _foundation.default {
666
667
  const widthIsBigger = wrapperRect.width > triggerRect.width;
667
668
  const heightIsBigger = wrapperRect.height > triggerRect.height; // The wrapperR ect.top|bottom equivalent cannot be directly used here for comparison, which is easy to cause jitter
668
669
 
669
- const shouldReverseTop = clientTop < wrapperRect.height && restClientBottom > wrapperRect.height;
670
- const shouldReverseLeft = clientLeft < wrapperRect.width && restClientRight > wrapperRect.width;
671
- const sholdReverseBottom = restClientBottom < wrapperRect.height && clientTop > wrapperRect.height;
672
- const shouldReverseRight = restClientRight < wrapperRect.width && clientLeft > wrapperRect.width;
670
+ const shouldReverseTop = clientTop < wrapperRect.height + spacing && restClientBottom > wrapperRect.height + spacing;
671
+ const shouldReverseLeft = clientLeft < wrapperRect.width + spacing && restClientRight > wrapperRect.width + spacing;
672
+ const sholdReverseBottom = restClientBottom < wrapperRect.height + spacing && clientTop > wrapperRect.height + spacing;
673
+ const shouldReverseRight = restClientRight < wrapperRect.width + spacing && clientLeft > wrapperRect.width + spacing;
673
674
  const shouldReverseTopSide = restClientTop < wrapperRect.height && clientBottom > wrapperRect.height;
674
675
  const shouldReverseBottomSide = clientBottom < wrapperRect.height && restClientTop > wrapperRect.height;
675
676
  const shouldReverseLeftSide = restClientLeft < wrapperRect.width && clientRight > wrapperRect.width;
@@ -85,8 +85,6 @@
85
85
  background-color: inherit;
86
86
  }
87
87
  .semi-transfer-item .semi-transfer-item-close-icon {
88
- width: 12px;
89
- height: 12px;
90
88
  font-size: 12px;
91
89
  cursor: pointer;
92
90
  visibility: hidden;
@@ -93,8 +93,6 @@ $module: #{$prefix}-transfer;
93
93
  }
94
94
 
95
95
  .#{$module}-item-close-icon {
96
- width: $width-transfer_item_close-icon;
97
- height: $width-transfer_item_close-icon;
98
96
  font-size: $width-transfer_item_close-icon;
99
97
  cursor: pointer;
100
98
  visibility: hidden;
@@ -183,6 +183,7 @@ export interface BasicTreeProps {
183
183
  value?: BasicValue;
184
184
  virtualize?: Virtualize;
185
185
  icon?: any;
186
+ 'aria-label'?: string;
186
187
  }
187
188
  export interface BasicTreeInnerData {
188
189
  inputValue: string;
@@ -651,7 +651,7 @@ class TreeFoundation extends _foundation.default {
651
651
 
652
652
 
653
653
  if (dragNode && eventKey === dragOverNodeKey) {
654
- const newPos = (0, _treeUtil.calcDropRelativePosition)(event, treeNode);
654
+ const newPos = (0, _treeUtil.calcDropRelativePosition)(e, treeNode);
655
655
 
656
656
  if (dropPosition === newPos) {
657
657
  return;
@@ -27,7 +27,7 @@ export interface BasicOnChange {
27
27
  (node: BasicTreeNodeData[] | BasicTreeNodeData, e: any): void;
28
28
  (value: BasicTreeNodeData['value'] | Array<BasicTreeNodeData['value']>, node: BasicTreeNodeData[] | BasicTreeNodeData, e: any): void;
29
29
  }
30
- export interface BasicTreeSelectProps extends Pick<BasicTreeProps, 'virtualize' | 'renderFullLabel' | 'renderLabel' | 'autoExpandParent' | 'className' | 'defaultExpandAll' | 'defaultExpandedKeys' | 'defaultValue' | 'disabled' | 'emptyContent' | 'expandAction' | 'expandedKeys' | 'filterTreeNode' | 'labelEllipsis' | 'leafOnly' | 'multiple' | 'onChangeWithObject' | 'showClear' | 'showFilteredOnly' | 'style' | 'treeData' | 'treeNodeFilterProp' | 'value' | 'onExpand' | 'onSearch' | 'expandAll' | 'disableStrictly'> {
30
+ export interface BasicTreeSelectProps extends Pick<BasicTreeProps, 'virtualize' | 'renderFullLabel' | 'renderLabel' | 'autoExpandParent' | 'className' | 'defaultExpandAll' | 'defaultExpandedKeys' | 'defaultValue' | 'disabled' | 'emptyContent' | 'expandAction' | 'expandedKeys' | 'filterTreeNode' | 'labelEllipsis' | 'leafOnly' | 'multiple' | 'onChangeWithObject' | 'showClear' | 'showFilteredOnly' | 'style' | 'treeData' | 'treeNodeFilterProp' | 'value' | 'onExpand' | 'onSearch' | 'expandAll' | 'disableStrictly' | 'aria-label'> {
31
31
  motion?: Motion;
32
32
  mouseEnterDelay?: number;
33
33
  mouseLeaveDelay?: number;
@@ -128,7 +128,15 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
128
128
  open(): void;
129
129
  close(e: any): void;
130
130
  handleClick(e: any): void;
131
+ /**
132
+ * A11y: simulate selection click
133
+ */
134
+ handleSelectionEnterPress(e: any): void;
131
135
  handleClear(e: any): void;
136
+ /**
137
+ * A11y: simulate clear button click
138
+ */
139
+ handleClearEnterPress(e: any): void;
132
140
  removeTag(eventKey: BasicTreeNodeData['key']): void;
133
141
  clearInput(): void;
134
142
  handleInputChange(sugInput: string): void;
@@ -54,6 +54,8 @@ var _foundation = _interopRequireDefault(require("../base/foundation"));
54
54
 
55
55
  var _treeUtil = require("../tree/treeUtil");
56
56
 
57
+ var _isEnterPress = _interopRequireDefault(require("../utils/isEnterPress"));
58
+
57
59
  // eslint-disable-next-line max-len
58
60
  class TreeSelectFoundation extends _foundation.default {
59
61
  constructor(adapter) {
@@ -338,6 +340,16 @@ class TreeSelectFoundation extends _foundation.default {
338
340
  this.close(e);
339
341
  }
340
342
  }
343
+ /**
344
+ * A11y: simulate selection click
345
+ */
346
+
347
+
348
+ handleSelectionEnterPress(e) {
349
+ if ((0, _isEnterPress.default)(e)) {
350
+ this.handleClick(e);
351
+ }
352
+ }
341
353
 
342
354
  handleClear(e) {
343
355
  const {
@@ -379,6 +391,16 @@ class TreeSelectFoundation extends _foundation.default {
379
391
  }
380
392
  }
381
393
  }
394
+ /**
395
+ * A11y: simulate clear button click
396
+ */
397
+
398
+
399
+ handleClearEnterPress(e) {
400
+ if ((0, _isEnterPress.default)(e)) {
401
+ this.handleClear(e);
402
+ }
403
+ }
382
404
 
383
405
  removeTag(eventKey) {
384
406
  const {
@@ -0,0 +1,4 @@
1
+ declare function isEnterPress<T extends {
2
+ key: string;
3
+ }>(e: T): boolean;
4
+ export default isEnterPress;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
4
+
5
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
6
+
7
+ _Object$defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+
11
+ exports.default = void 0;
12
+
13
+ var _get2 = _interopRequireDefault(require("lodash/get"));
14
+
15
+ var _keyCode = require("./keyCode");
16
+
17
+ function isEnterPress(e) {
18
+ return (0, _get2.default)(e, 'key') === _keyCode.ENTER_KEY ? true : false;
19
+ }
20
+
21
+ var _default = isEnterPress;
22
+ exports.default = _default;
@@ -424,4 +424,6 @@ declare const keyCode: {
424
424
  */
425
425
  WIN_IME: number;
426
426
  };
427
+ export declare const ENTER_KEY = "Enter";
428
+ export declare const TAB_KEY = "Tab";
427
429
  export default keyCode;
@@ -6,7 +6,7 @@ _Object$defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
 
9
- exports.default = void 0;
9
+ exports.default = exports.TAB_KEY = exports.ENTER_KEY = void 0;
10
10
 
11
11
  /**
12
12
  * @ignore
@@ -538,5 +538,9 @@ const keyCode = {
538
538
  */
539
539
  WIN_IME: 229
540
540
  };
541
+ const ENTER_KEY = 'Enter';
542
+ exports.ENTER_KEY = ENTER_KEY;
543
+ const TAB_KEY = 'Tab';
544
+ exports.TAB_KEY = TAB_KEY;
541
545
  var _default = keyCode;
542
546
  exports.default = _default;
@@ -1,3 +1,17 @@
1
1
  export default function getUuid(prefix: string): string;
2
2
  declare function getUuidv4(): string;
3
- export { getUuid, getUuidv4 };
3
+ /**
4
+ * Get a random id with prefix, it not strictly guarantee id uniqueness
5
+ *
6
+ * Note: the return value of getUuid is too long, we need a short one
7
+ *
8
+ * @example
9
+ * getUuidShort({ prefix: 'semi' }) => 'semi-46dinzc'
10
+ * getUuidShort({ prefix: '' }) => '0eer2i0'
11
+ * getUuidShort({ prefix: 'semi', length: 4 }) => 'semi-8jts'
12
+ */
13
+ declare function getUuidShort({ prefix, length }: {
14
+ prefix?: string;
15
+ length?: number;
16
+ }): string;
17
+ export { getUuid, getUuidv4, getUuidShort };
@@ -9,6 +9,7 @@ _Object$defineProperty(exports, "__esModule", {
9
9
  });
10
10
 
11
11
  exports.getUuid = exports.default = getUuid;
12
+ exports.getUuidShort = getUuidShort;
12
13
  exports.getUuidv4 = getUuidv4;
13
14
 
14
15
  var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
@@ -26,4 +27,34 @@ function getUuidv4() {
26
27
  } catch (err) {
27
28
  return getUuid('semi');
28
29
  }
30
+ }
31
+ /**
32
+ * Get a random id with prefix, it not strictly guarantee id uniqueness
33
+ *
34
+ * Note: the return value of getUuid is too long, we need a short one
35
+ *
36
+ * @example
37
+ * getUuidShort({ prefix: 'semi' }) => 'semi-46dinzc'
38
+ * getUuidShort({ prefix: '' }) => '0eer2i0'
39
+ * getUuidShort({ prefix: 'semi', length: 4 }) => 'semi-8jts'
40
+ */
41
+
42
+
43
+ function getUuidShort(_ref) {
44
+ var _context3;
45
+
46
+ let {
47
+ prefix = '',
48
+ length = 7
49
+ } = _ref;
50
+ const characters = '0123456789abcdefghijklmnopqrstuvwxyz';
51
+ const total = characters.length;
52
+ let randomId = '';
53
+
54
+ for (let i = 0; i < length; i++) {
55
+ const random = Math.floor(Math.random() * total);
56
+ randomId += characters.charAt(random);
57
+ }
58
+
59
+ return prefix ? (0, _concat.default)(_context3 = "".concat(prefix, "-")).call(_context3, randomId) : randomId;
29
60
  }
@@ -8,6 +8,10 @@ export default class BreadcrumbFoundation<P = Record<string, any>, S = Record<st
8
8
  constructor(adapter: BreadcrumbAdapter<P, S>);
9
9
  handleClick(info: BreadcrumbItemInfo, event: any): void;
10
10
  handleExpand(clickEvent: any): void;
11
+ /**
12
+ * A11y: simulate clear button click
13
+ */
14
+ handleExpandEnterPress(keyboardEvent: any): void;
11
15
  genRoutes(routes: Array<Route>): ({
12
16
  name: never;
13
17
  _origin: {
@@ -3,6 +3,7 @@ import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance
3
3
 
4
4
  /* eslint-disable prefer-const */
5
5
  import BaseFoundation from '../base/foundation';
6
+ import isEnterPress from '../utils/isEnterPress';
6
7
  export default class BreadcrumbFoundation extends BaseFoundation {
7
8
  constructor(adapter) {
8
9
  super(_Object$assign({}, adapter));
@@ -15,6 +16,16 @@ export default class BreadcrumbFoundation extends BaseFoundation {
15
16
  handleExpand(clickEvent) {
16
17
  this._adapter.expandCollapsed(clickEvent);
17
18
  }
19
+ /**
20
+ * A11y: simulate clear button click
21
+ */
22
+
23
+
24
+ handleExpandEnterPress(keyboardEvent) {
25
+ if (isEnterPress(keyboardEvent)) {
26
+ this.handleExpand(keyboardEvent);
27
+ }
28
+ }
18
29
 
19
30
  genRoutes(routes) {
20
31
  return _mapInstanceProperty(routes).call(routes, route => {
@@ -34,6 +34,7 @@ declare class CheckboxFoundation<P = Record<string, any>, S = Record<string, any
34
34
  notifyChange(checked: boolean, e: any): void;
35
35
  handleChange(e: any): void;
36
36
  handleChangeInGroup(e: any): void;
37
+ handleEnterPress(e: any): void;
37
38
  setChecked(checked: boolean): void;
38
39
  destroy(): void;
39
40
  }
@@ -52,5 +53,7 @@ export interface BaseCheckboxProps {
52
53
  onMouseEnter?: (e: any) => void;
53
54
  onMouseLeave?: (e: any) => void;
54
55
  extra?: any;
56
+ addonId?: string;
57
+ extraId?: string;
55
58
  }
56
59
  export default CheckboxFoundation;
@@ -1,6 +1,7 @@
1
1
  import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
2
2
  import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
3
3
  import BaseFoundation from '../base/foundation';
4
+ import isEnterPress from '../utils/isEnterPress';
4
5
 
5
6
  class CheckboxFoundation extends BaseFoundation {
6
7
  constructor(adapter) {
@@ -86,6 +87,12 @@ class CheckboxFoundation extends BaseFoundation {
86
87
  this._adapter.notifyGroupChange(event);
87
88
  }
88
89
 
90
+ handleEnterPress(e) {
91
+ if (isEnterPress(e)) {
92
+ this.handleChange(e);
93
+ }
94
+ }
95
+
89
96
  setChecked(checked) {
90
97
  this._adapter.setNativeControlChecked(checked);
91
98
  } // eslint-disable-next-line @typescript-eslint/no-empty-function