@douyinfe/semi-foundation 2.2.1 → 2.3.1

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 (128) hide show
  1. package/breadcrumb/foundation.ts +10 -1
  2. package/checkbox/checkboxFoundation.ts +9 -0
  3. package/datePicker/foundation.ts +2 -4
  4. package/datePicker/monthsGridFoundation.ts +10 -3
  5. package/form/foundation.ts +20 -8
  6. package/form/utils.ts +2 -0
  7. package/input/foundation.ts +21 -2
  8. package/input/textareaFoundation.ts +11 -1
  9. package/inputNumber/foundation.ts +3 -2
  10. package/lib/cjs/breadcrumb/foundation.d.ts +4 -0
  11. package/lib/cjs/breadcrumb/foundation.js +12 -0
  12. package/lib/cjs/checkbox/checkboxFoundation.d.ts +3 -0
  13. package/lib/cjs/checkbox/checkboxFoundation.js +8 -0
  14. package/lib/cjs/datePicker/foundation.js +2 -4
  15. package/lib/cjs/datePicker/monthsGridFoundation.d.ts +1 -0
  16. package/lib/cjs/datePicker/monthsGridFoundation.js +16 -3
  17. package/lib/cjs/form/foundation.d.ts +13 -0
  18. package/lib/cjs/form/foundation.js +32 -8
  19. package/lib/cjs/form/utils.d.ts +1 -0
  20. package/lib/cjs/form/utils.js +5 -3
  21. package/lib/cjs/input/foundation.d.ts +8 -0
  22. package/lib/cjs/input/foundation.js +24 -2
  23. package/lib/cjs/input/textareaFoundation.d.ts +5 -1
  24. package/lib/cjs/input/textareaFoundation.js +12 -0
  25. package/lib/cjs/inputNumber/foundation.d.ts +2 -2
  26. package/lib/cjs/inputNumber/foundation.js +3 -1
  27. package/lib/cjs/modal/modalContentFoundation.d.ts +7 -0
  28. package/lib/cjs/modal/modalContentFoundation.js +14 -0
  29. package/lib/cjs/navigation/itemFoundation.d.ts +5 -0
  30. package/lib/cjs/navigation/itemFoundation.js +12 -0
  31. package/lib/cjs/navigation/subNavFoundation.d.ts +6 -0
  32. package/lib/cjs/navigation/subNavFoundation.js +14 -0
  33. package/lib/cjs/notification/notificationListFoundation.js +1 -1
  34. package/lib/cjs/radio/radio.css +7 -1
  35. package/lib/cjs/radio/radio.scss +8 -1
  36. package/lib/cjs/select/foundation.d.ts +2 -0
  37. package/lib/cjs/select/foundation.js +40 -6
  38. package/lib/cjs/sideSheet/sideSheetFoundation.d.ts +1 -0
  39. package/lib/cjs/slider/foundation.d.ts +6 -1
  40. package/lib/cjs/slider/foundation.js +6 -12
  41. package/lib/cjs/slider/slider.css +1 -0
  42. package/lib/cjs/slider/slider.scss +1 -0
  43. package/lib/cjs/table/utils.d.ts +7 -0
  44. package/lib/cjs/table/utils.js +26 -0
  45. package/lib/cjs/tagInput/foundation.d.ts +4 -0
  46. package/lib/cjs/tagInput/foundation.js +12 -0
  47. package/lib/cjs/tooltip/foundation.js +7 -6
  48. package/lib/cjs/transfer/transfer.css +0 -2
  49. package/lib/cjs/transfer/transfer.scss +0 -2
  50. package/lib/cjs/tree/foundation.d.ts +1 -0
  51. package/lib/cjs/tree/foundation.js +1 -1
  52. package/lib/cjs/treeSelect/foundation.d.ts +9 -1
  53. package/lib/cjs/treeSelect/foundation.js +22 -0
  54. package/lib/cjs/utils/isEnterPress.d.ts +4 -0
  55. package/lib/cjs/utils/isEnterPress.js +22 -0
  56. package/lib/cjs/utils/keyCode.d.ts +2 -0
  57. package/lib/cjs/utils/keyCode.js +5 -1
  58. package/lib/cjs/utils/uuid.d.ts +16 -1
  59. package/lib/cjs/utils/uuid.js +32 -0
  60. package/lib/es/breadcrumb/foundation.d.ts +4 -0
  61. package/lib/es/breadcrumb/foundation.js +11 -0
  62. package/lib/es/checkbox/checkboxFoundation.d.ts +3 -0
  63. package/lib/es/checkbox/checkboxFoundation.js +7 -0
  64. package/lib/es/datePicker/foundation.js +2 -4
  65. package/lib/es/datePicker/monthsGridFoundation.d.ts +1 -0
  66. package/lib/es/datePicker/monthsGridFoundation.js +15 -3
  67. package/lib/es/form/foundation.d.ts +13 -0
  68. package/lib/es/form/foundation.js +31 -8
  69. package/lib/es/form/utils.d.ts +1 -0
  70. package/lib/es/form/utils.js +5 -3
  71. package/lib/es/input/foundation.d.ts +8 -0
  72. package/lib/es/input/foundation.js +23 -2
  73. package/lib/es/input/textareaFoundation.d.ts +5 -1
  74. package/lib/es/input/textareaFoundation.js +11 -0
  75. package/lib/es/inputNumber/foundation.d.ts +2 -2
  76. package/lib/es/inputNumber/foundation.js +3 -1
  77. package/lib/es/modal/modalContentFoundation.d.ts +7 -0
  78. package/lib/es/modal/modalContentFoundation.js +14 -0
  79. package/lib/es/navigation/itemFoundation.d.ts +5 -0
  80. package/lib/es/navigation/itemFoundation.js +11 -0
  81. package/lib/es/navigation/subNavFoundation.d.ts +6 -0
  82. package/lib/es/navigation/subNavFoundation.js +13 -0
  83. package/lib/es/notification/notificationListFoundation.js +1 -1
  84. package/lib/es/radio/radio.css +7 -1
  85. package/lib/es/radio/radio.scss +8 -1
  86. package/lib/es/select/foundation.d.ts +2 -0
  87. package/lib/es/select/foundation.js +31 -6
  88. package/lib/es/sideSheet/sideSheetFoundation.d.ts +1 -0
  89. package/lib/es/slider/foundation.d.ts +6 -1
  90. package/lib/es/slider/foundation.js +6 -12
  91. package/lib/es/slider/slider.css +1 -0
  92. package/lib/es/slider/slider.scss +1 -0
  93. package/lib/es/table/utils.d.ts +7 -0
  94. package/lib/es/table/utils.js +24 -0
  95. package/lib/es/tagInput/foundation.d.ts +4 -0
  96. package/lib/es/tagInput/foundation.js +11 -0
  97. package/lib/es/tooltip/foundation.js +7 -6
  98. package/lib/es/transfer/transfer.css +0 -2
  99. package/lib/es/transfer/transfer.scss +0 -2
  100. package/lib/es/tree/foundation.d.ts +1 -0
  101. package/lib/es/tree/foundation.js +1 -1
  102. package/lib/es/treeSelect/foundation.d.ts +9 -1
  103. package/lib/es/treeSelect/foundation.js +22 -1
  104. package/lib/es/utils/isEnterPress.d.ts +4 -0
  105. package/lib/es/utils/isEnterPress.js +8 -0
  106. package/lib/es/utils/keyCode.d.ts +2 -0
  107. package/lib/es/utils/keyCode.js +2 -0
  108. package/lib/es/utils/uuid.d.ts +16 -1
  109. package/lib/es/utils/uuid.js +32 -1
  110. package/modal/modalContentFoundation.ts +18 -0
  111. package/navigation/itemFoundation.ts +11 -0
  112. package/navigation/subNavFoundation.ts +12 -0
  113. package/notification/notificationListFoundation.ts +4 -8
  114. package/package.json +3 -3
  115. package/radio/radio.scss +8 -1
  116. package/select/foundation.ts +26 -7
  117. package/sideSheet/sideSheetFoundation.ts +3 -5
  118. package/slider/foundation.ts +10 -13
  119. package/slider/slider.scss +1 -0
  120. package/table/utils.ts +16 -0
  121. package/tagInput/foundation.ts +10 -0
  122. package/tooltip/foundation.ts +5 -5
  123. package/transfer/transfer.scss +0 -2
  124. package/tree/foundation.ts +2 -1
  125. package/treeSelect/foundation.ts +20 -0
  126. package/utils/isEnterPress.ts +8 -0
  127. package/utils/keyCode.ts +3 -0
  128. package/utils/uuid.ts +29 -1
@@ -2,6 +2,7 @@ import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign"
2
2
 
3
3
  /* argus-disable unPkgSensitiveInfo */
4
4
  import BaseFoundation from '../base/foundation';
5
+ import isEnterPress from '../utils/isEnterPress';
5
6
  export default class ItemFoundation extends BaseFoundation {
6
7
  constructor(adapter) {
7
8
  super(_Object$assign({}, adapter));
@@ -65,5 +66,15 @@ export default class ItemFoundation extends BaseFoundation {
65
66
  domEvent: e
66
67
  });
67
68
  }
69
+ /**
70
+ * A11y: simulate item click
71
+ */
72
+
73
+
74
+ handleKeyPress(e) {
75
+ if (isEnterPress(e)) {
76
+ this.handleClick(e);
77
+ }
78
+ }
68
79
 
69
80
  }
@@ -36,4 +36,10 @@ export default class SubNavFoundation<P = Record<string, any>, S = Record<string
36
36
  * @param {HTMLElement} titleRef
37
37
  */
38
38
  handleClick(e: any, titleRef: any): void;
39
+ /**
40
+ * A11y: simulate sub nav click
41
+ * @param e
42
+ * @param titleRef
43
+ */
44
+ handleKeyPress(e: any, titleRef: any): void;
39
45
  }
@@ -3,6 +3,7 @@ import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/inst
3
3
  import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
4
4
  import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
5
5
  import BaseFoundation from '../base/foundation';
6
+ import isEnterPress from '../utils/isEnterPress';
6
7
 
7
8
  const addKeys = function addKeys() {
8
9
  let originKeys = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
@@ -127,5 +128,17 @@ export default class SubNavFoundation extends BaseFoundation {
127
128
 
128
129
  this._adapter.notifyGlobalOnClick(cbVal);
129
130
  }
131
+ /**
132
+ * A11y: simulate sub nav click
133
+ * @param e
134
+ * @param titleRef
135
+ */
136
+
137
+
138
+ handleKeyPress(e, titleRef) {
139
+ if (isEnterPress(e)) {
140
+ this.handleClick(e, titleRef);
141
+ }
142
+ }
130
143
 
131
144
  }
@@ -13,7 +13,7 @@ export default class NotificationListFoundation extends BaseFoundation {
13
13
  // }
14
14
 
15
15
 
16
- this._adapter.updateNotices([...notices, opts]); // return id;
16
+ this._adapter.updateNotices([opts, ...notices]); // return id;
17
17
 
18
18
  }
19
19
 
@@ -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;
@@ -32,9 +32,10 @@ var __rest = this && this.__rest || function (s, e) {
32
32
 
33
33
 
34
34
  import BaseFoundation from '../base/foundation';
35
- import KeyCode from '../utils/keyCode';
35
+ import KeyCode, { ENTER_KEY } from '../utils/keyCode';
36
36
  import warning from '../utils/warning';
37
37
  import isNullOrUndefined from '../utils/isNullOrUndefined';
38
+ import isEnterPress from '../utils/isEnterPress';
38
39
  export default class SelectFoundation extends BaseFoundation {
39
40
  constructor(adapter) {
40
41
  super(_Object$assign({}, adapter)); // keyboard event listner
@@ -511,6 +512,10 @@ export default class SelectFoundation extends BaseFoundation {
511
512
 
512
513
  const selections = this._adapter.getSelections();
513
514
 
515
+ const {
516
+ autoClearSearchValue
517
+ } = this.getProps();
518
+
514
519
  if (selections.has(label)) {
515
520
  this._notifyDeselect(value, _Object$assign({
516
521
  value,
@@ -542,7 +547,10 @@ export default class SelectFoundation extends BaseFoundation {
542
547
  this._notifyChange(selections);
543
548
 
544
549
  if (this._isFilterable()) {
545
- this.clearInput();
550
+ if (autoClearSearchValue) {
551
+ this.clearInput();
552
+ }
553
+
546
554
  this.focusInput();
547
555
  }
548
556
  } else {
@@ -557,11 +565,15 @@ export default class SelectFoundation extends BaseFoundation {
557
565
  } = this.getStates(); // Searchable filtering, when selected, resets Input
558
566
 
559
567
  if (this._isFilterable()) {
560
- this.clearInput();
561
- this.focusInput(); // At the same time, the filtering of options is also cleared, in order to show all candidates
568
+ // When filter active,if autoClearSearchValue is true,reset input after select
569
+ if (autoClearSearchValue) {
570
+ this.clearInput(); // At the same time, the filtering of options is also cleared, in order to show all candidates
571
+
572
+ const sugInput = '';
573
+ options = this._filterOption(options, sugInput);
574
+ }
562
575
 
563
- const sugInput = '';
564
- options = this._filterOption(options, sugInput);
576
+ this.focusInput();
565
577
  }
566
578
 
567
579
  this.updateOptionsActiveStatus(selections, options);
@@ -839,6 +851,7 @@ export default class SelectFoundation extends BaseFoundation {
839
851
  break;
840
852
 
841
853
  case KeyCode.ESC:
854
+ case KeyCode.TAB:
842
855
  this.close(event);
843
856
  break;
844
857
 
@@ -1118,6 +1131,18 @@ export default class SelectFoundation extends BaseFoundation {
1118
1131
  e.stopPropagation();
1119
1132
  }
1120
1133
 
1134
+ handleKeyPress(e) {
1135
+ if (e && e.key === ENTER_KEY) {
1136
+ this.handleClick(e);
1137
+ }
1138
+ }
1139
+
1140
+ handleClearBtnEnterPress(e) {
1141
+ if (isEnterPress(e)) {
1142
+ this.handleClearClick(e);
1143
+ }
1144
+ }
1145
+
1121
1146
  handleOptionMouseEnter(optionIndex) {
1122
1147
  this._adapter.updateFocusIndex(optionIndex);
1123
1148
  }
@@ -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
@@ -271,17 +271,8 @@ export default class SliderFoundation extends BaseFoundation {
271
271
  }
272
272
 
273
273
  if (step !== 1) {
274
- // Existence step
275
- if (stepValue > compareValue && Math.round(stepValue / step) * step >= stepValue) {
276
- // Move right
277
- stepValue = Math.round(stepValue / step) * step;
278
- } else if (stepValue < compareValue && Math.round(stepValue / step) * step <= stepValue) {
279
- // Move left
280
- stepValue = Math.round(stepValue / step) * step;
281
- } else {
282
- // Other moves are invalid, click valid
283
- stepValue = compareValue;
284
- }
274
+ // Find nearest step point
275
+ stepValue = Math.round(stepValue / step) * step;
285
276
  }
286
277
 
287
278
  if (range && stepValue !== compareValue) {
@@ -595,7 +586,10 @@ export default class SliderFoundation extends BaseFoundation {
595
586
  this._adapter.onHandleUpAfter();
596
587
 
597
588
  return true;
598
- };
589
+ }; // eslint-disable-next-line @typescript-eslint/no-empty-function
590
+
591
+
592
+ this.onFocus = (e, handler) => {};
599
593
 
600
594
  this.handleWrapClick = e => {
601
595
  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;
@@ -521,4 +521,28 @@ export function warnIfNoDataIndex(column) {
521
521
  logger.warn("The column with sorter or filter must pass the 'dataIndex' prop");
522
522
  }
523
523
  }
524
+ }
525
+ /**
526
+ * Whether is tree table
527
+ */
528
+
529
+ export function isTreeTable(_ref2) {
530
+ let {
531
+ dataSource,
532
+ childrenRecordName = 'children'
533
+ } = _ref2;
534
+ let flag = false;
535
+
536
+ if (_Array$isArray(dataSource)) {
537
+ for (const data of dataSource) {
538
+ const children = _get(data, childrenRecordName);
539
+
540
+ if (_Array$isArray(children) && children.length) {
541
+ flag = true;
542
+ break;
543
+ }
544
+ }
545
+ }
546
+
547
+ return flag;
524
548
  }
@@ -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;
@@ -13,6 +13,7 @@ import _spliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/insta
13
13
  import BaseFoundation from '../base/foundation';
14
14
  import keyCode from '../utils/keyCode';
15
15
  import getSplitedArray from './utils/getSplitedArray';
16
+ import isEnterPress from '../utils/isEnterPress';
16
17
 
17
18
  class TagInputFoundation extends BaseFoundation {
18
19
  constructor(adapter) {
@@ -161,6 +162,16 @@ class TagInputFoundation extends BaseFoundation {
161
162
 
162
163
  this._adapter.notifyFocus(e);
163
164
  }
165
+ /**
166
+ * A11y: simulate clear button click
167
+ */
168
+
169
+
170
+ handleClearEnterPress(e) {
171
+ if (isEnterPress(e)) {
172
+ this.handleClearBtn(e);
173
+ }
174
+ }
164
175
 
165
176
  handleClearBtn(e) {
166
177
  const {
@@ -74,8 +74,6 @@ export default class Tooltip extends BaseFoundation {
74
74
  if (trigger === 'custom') {
75
75
  // eslint-disable-next-line
76
76
  this._adapter.registerClickOutsideHandler(() => {});
77
-
78
- this._togglePortalVisible(true);
79
77
  }
80
78
  /**
81
79
  * trigger类型是click时,仅当portal被插入显示后,才绑定clickOutsideHandler
@@ -627,6 +625,9 @@ export default class Tooltip extends BaseFoundation {
627
625
  innerWidth,
628
626
  innerHeight
629
627
  } = window;
628
+ const {
629
+ spacing
630
+ } = this.getProps();
630
631
 
631
632
  if (wrapperRect.width > 0 && wrapperRect.height > 0) {
632
633
  // let clientLeft = left + translateX * wrapperRect.width - containerRect.scrollLeft;
@@ -650,10 +651,10 @@ export default class Tooltip extends BaseFoundation {
650
651
  const widthIsBigger = wrapperRect.width > triggerRect.width;
651
652
  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
652
653
 
653
- const shouldReverseTop = clientTop < wrapperRect.height && restClientBottom > wrapperRect.height;
654
- const shouldReverseLeft = clientLeft < wrapperRect.width && restClientRight > wrapperRect.width;
655
- const sholdReverseBottom = restClientBottom < wrapperRect.height && clientTop > wrapperRect.height;
656
- const shouldReverseRight = restClientRight < wrapperRect.width && clientLeft > wrapperRect.width;
654
+ const shouldReverseTop = clientTop < wrapperRect.height + spacing && restClientBottom > wrapperRect.height + spacing;
655
+ const shouldReverseLeft = clientLeft < wrapperRect.width + spacing && restClientRight > wrapperRect.width + spacing;
656
+ const sholdReverseBottom = restClientBottom < wrapperRect.height + spacing && clientTop > wrapperRect.height + spacing;
657
+ const shouldReverseRight = restClientRight < wrapperRect.width + spacing && clientLeft > wrapperRect.width + spacing;
657
658
  const shouldReverseTopSide = restClientTop < wrapperRect.height && clientBottom > wrapperRect.height;
658
659
  const shouldReverseBottomSide = clientBottom < wrapperRect.height && restClientTop > wrapperRect.height;
659
660
  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;
@@ -634,7 +634,7 @@ export default class TreeFoundation extends BaseFoundation {
634
634
 
635
635
 
636
636
  if (dragNode && eventKey === dragOverNodeKey) {
637
- const newPos = calcDropRelativePosition(event, treeNode);
637
+ const newPos = calcDropRelativePosition(e, treeNode);
638
638
 
639
639
  if (dropPosition === newPos) {
640
640
  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;
@@ -18,7 +18,8 @@ import _someInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instanc
18
18
  import _everyInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/every";
19
19
  import { strings } from '../treeSelect/constants';
20
20
  import BaseFoundation from '../base/foundation';
21
- import { flattenTreeData, findDescendantKeys, findAncestorKeys, filter, normalizedArr, normalizeKeyList, getMotionKeys, calcCheckedKeysForChecked, calcCheckedKeys, calcCheckedKeysForUnchecked, getValueOrKey } from '../tree/treeUtil'; // eslint-disable-next-line max-len
21
+ import { flattenTreeData, findDescendantKeys, findAncestorKeys, filter, normalizedArr, normalizeKeyList, getMotionKeys, calcCheckedKeysForChecked, calcCheckedKeys, calcCheckedKeysForUnchecked, getValueOrKey } from '../tree/treeUtil';
22
+ import isEnterPress from '../utils/isEnterPress'; // eslint-disable-next-line max-len
22
23
 
23
24
  export default class TreeSelectFoundation extends BaseFoundation {
24
25
  constructor(adapter) {
@@ -306,6 +307,16 @@ export default class TreeSelectFoundation extends BaseFoundation {
306
307
  this.close(e);
307
308
  }
308
309
  }
310
+ /**
311
+ * A11y: simulate selection click
312
+ */
313
+
314
+
315
+ handleSelectionEnterPress(e) {
316
+ if (isEnterPress(e)) {
317
+ this.handleClick(e);
318
+ }
319
+ }
309
320
 
310
321
  handleClear(e) {
311
322
  const {
@@ -347,6 +358,16 @@ export default class TreeSelectFoundation extends BaseFoundation {
347
358
  }
348
359
  }
349
360
  }
361
+ /**
362
+ * A11y: simulate clear button click
363
+ */
364
+
365
+
366
+ handleClearEnterPress(e) {
367
+ if (isEnterPress(e)) {
368
+ this.handleClear(e);
369
+ }
370
+ }
350
371
 
351
372
  removeTag(eventKey) {
352
373
  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,8 @@
1
+ import _get from "lodash/get";
2
+ import { ENTER_KEY } from './keyCode';
3
+
4
+ function isEnterPress(e) {
5
+ return _get(e, 'key') === ENTER_KEY ? true : false;
6
+ }
7
+
8
+ export default isEnterPress;
@@ -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;
@@ -528,4 +528,6 @@ const keyCode = {
528
528
  */
529
529
  WIN_IME: 229
530
530
  };
531
+ export const ENTER_KEY = 'Enter';
532
+ export const TAB_KEY = 'Tab';
531
533
  export default keyCode;
@@ -1,3 +1,18 @@
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(options?: GetUuidShortOptions): string;
14
+ interface GetUuidShortOptions {
15
+ prefix?: string;
16
+ length?: number;
17
+ }
18
+ export { getUuid, getUuidv4, getUuidShort };
@@ -12,5 +12,36 @@ function getUuidv4() {
12
12
  return getUuid('semi');
13
13
  }
14
14
  }
15
+ /**
16
+ * Get a random id with prefix, it not strictly guarantee id uniqueness
17
+ *
18
+ * Note: the return value of getUuid is too long, we need a short one
19
+ *
20
+ * @example
21
+ * getUuidShort({ prefix: 'semi' }) => 'semi-46dinzc'
22
+ * getUuidShort({ prefix: '' }) => '0eer2i0'
23
+ * getUuidShort({ prefix: 'semi', length: 4 }) => 'semi-8jts'
24
+ */
15
25
 
16
- export { getUuid, getUuidv4 };
26
+
27
+ function getUuidShort() {
28
+ var _context3;
29
+
30
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
31
+ const {
32
+ prefix = '',
33
+ length = 7
34
+ } = options;
35
+ const characters = '0123456789abcdefghijklmnopqrstuvwxyz';
36
+ const total = characters.length;
37
+ let randomId = '';
38
+
39
+ for (let i = 0; i < length; i++) {
40
+ const random = Math.floor(Math.random() * total);
41
+ randomId += characters.charAt(random);
42
+ }
43
+
44
+ return prefix ? _concatInstanceProperty(_context3 = "".concat(prefix, "-")).call(_context3, randomId) : randomId;
45
+ }
46
+
47
+ export { getUuid, getUuidv4, getUuidShort };
@@ -13,6 +13,7 @@ export interface ModalContentProps extends ModalProps {
13
13
 
14
14
  export interface ModalContentState {
15
15
  dialogMouseDown: boolean;
16
+ prevFocusElement: HTMLElement;
16
17
  }
17
18
 
18
19
  export interface ModalContentAdapter extends DefaultAdapter<ModalContentProps, ModalContentState> {
@@ -22,6 +23,9 @@ export interface ModalContentAdapter extends DefaultAdapter<ModalContentProps, M
22
23
  addKeyDownEventListener: () => void;
23
24
  removeKeyDownEventListener: () => void;
24
25
  getMouseState: () => boolean;
26
+ modalDialogFocus: () => void;
27
+ modalDialogBlur: () => void;
28
+ prevFocusElementReFocus: () => void;
25
29
  }
26
30
 
27
31
  export default class ModalContentFoundation extends BaseFoundation<ModalContentAdapter> {
@@ -32,6 +36,8 @@ export default class ModalContentFoundation extends BaseFoundation<ModalContentA
32
36
 
33
37
  destroy() {
34
38
  this.handleKeyDownEventListenerUnmount();
39
+ this.modalDialogBlur();
40
+ this.prevFocusElementReFocus();
35
41
  }
36
42
 
37
43
  handleDialogMouseDown() {
@@ -73,4 +79,16 @@ export default class ModalContentFoundation extends BaseFoundation<ModalContentA
73
79
  close(e: any) {
74
80
  this._adapter.notifyClose(e);
75
81
  }
82
+
83
+ modalDialogFocus() {
84
+ this._adapter.modalDialogFocus();
85
+ }
86
+
87
+ modalDialogBlur() {
88
+ this._adapter.modalDialogBlur();
89
+ }
90
+
91
+ prevFocusElementReFocus() {
92
+ this._adapter.prevFocusElementReFocus();
93
+ }
76
94
  }