@douyinfe/semi-foundation 2.2.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/breadcrumb/foundation.ts +10 -1
  2. package/checkbox/checkboxFoundation.ts +9 -0
  3. package/datePicker/datePicker.scss +11 -0
  4. package/datePicker/foundation.ts +33 -15
  5. package/datePicker/inputFoundation.ts +2 -0
  6. package/datePicker/monthsGridFoundation.ts +10 -3
  7. package/datePicker/rtl.scss +15 -1
  8. package/datePicker/variables.scss +2 -0
  9. package/form/foundation.ts +20 -8
  10. package/form/utils.ts +2 -0
  11. package/input/foundation.ts +21 -2
  12. package/input/textareaFoundation.ts +11 -1
  13. package/inputNumber/foundation.ts +3 -2
  14. package/lib/cjs/breadcrumb/foundation.d.ts +4 -0
  15. package/lib/cjs/breadcrumb/foundation.js +12 -0
  16. package/lib/cjs/checkbox/checkboxFoundation.d.ts +3 -0
  17. package/lib/cjs/checkbox/checkboxFoundation.js +8 -0
  18. package/lib/cjs/datePicker/datePicker.css +26 -2
  19. package/lib/cjs/datePicker/datePicker.scss +11 -0
  20. package/lib/cjs/datePicker/foundation.d.ts +6 -3
  21. package/lib/cjs/datePicker/foundation.js +42 -18
  22. package/lib/cjs/datePicker/inputFoundation.js +3 -0
  23. package/lib/cjs/datePicker/monthsGridFoundation.d.ts +2 -1
  24. package/lib/cjs/datePicker/monthsGridFoundation.js +16 -3
  25. package/lib/cjs/datePicker/rtl.scss +15 -1
  26. package/lib/cjs/datePicker/variables.scss +2 -0
  27. package/lib/cjs/form/foundation.d.ts +13 -0
  28. package/lib/cjs/form/foundation.js +32 -8
  29. package/lib/cjs/form/utils.d.ts +1 -0
  30. package/lib/cjs/form/utils.js +5 -3
  31. package/lib/cjs/input/foundation.d.ts +8 -0
  32. package/lib/cjs/input/foundation.js +24 -2
  33. package/lib/cjs/input/textareaFoundation.d.ts +5 -1
  34. package/lib/cjs/input/textareaFoundation.js +12 -0
  35. package/lib/cjs/inputNumber/foundation.d.ts +2 -2
  36. package/lib/cjs/inputNumber/foundation.js +3 -1
  37. package/lib/cjs/modal/modalContentFoundation.d.ts +7 -0
  38. package/lib/cjs/modal/modalContentFoundation.js +14 -0
  39. package/lib/cjs/navigation/itemFoundation.d.ts +5 -0
  40. package/lib/cjs/navigation/itemFoundation.js +12 -0
  41. package/lib/cjs/navigation/subNavFoundation.d.ts +6 -0
  42. package/lib/cjs/navigation/subNavFoundation.js +14 -0
  43. package/lib/cjs/notification/notificationListFoundation.js +1 -1
  44. package/lib/cjs/radio/radio.css +7 -1
  45. package/lib/cjs/radio/radio.scss +8 -1
  46. package/lib/cjs/select/foundation.d.ts +2 -0
  47. package/lib/cjs/select/foundation.js +40 -6
  48. package/lib/cjs/sideSheet/sideSheetFoundation.d.ts +1 -0
  49. package/lib/cjs/slider/foundation.d.ts +6 -1
  50. package/lib/cjs/slider/foundation.js +6 -12
  51. package/lib/cjs/slider/slider.css +1 -0
  52. package/lib/cjs/slider/slider.scss +1 -0
  53. package/lib/cjs/table/table.css +0 -2
  54. package/lib/cjs/table/table.scss +0 -2
  55. package/lib/cjs/table/utils.d.ts +7 -0
  56. package/lib/cjs/table/utils.js +26 -0
  57. package/lib/cjs/tagInput/foundation.d.ts +4 -0
  58. package/lib/cjs/tagInput/foundation.js +12 -0
  59. package/lib/cjs/tooltip/foundation.js +7 -6
  60. package/lib/cjs/transfer/transfer.css +0 -2
  61. package/lib/cjs/transfer/transfer.scss +0 -2
  62. package/lib/cjs/tree/foundation.d.ts +1 -0
  63. package/lib/cjs/tree/foundation.js +1 -1
  64. package/lib/cjs/treeSelect/foundation.d.ts +9 -1
  65. package/lib/cjs/treeSelect/foundation.js +22 -0
  66. package/lib/cjs/utils/isEnterPress.d.ts +4 -0
  67. package/lib/cjs/utils/isEnterPress.js +22 -0
  68. package/lib/cjs/utils/keyCode.d.ts +2 -0
  69. package/lib/cjs/utils/keyCode.js +5 -1
  70. package/lib/cjs/utils/uuid.d.ts +16 -1
  71. package/lib/cjs/utils/uuid.js +32 -0
  72. package/lib/es/breadcrumb/foundation.d.ts +4 -0
  73. package/lib/es/breadcrumb/foundation.js +11 -0
  74. package/lib/es/checkbox/checkboxFoundation.d.ts +3 -0
  75. package/lib/es/checkbox/checkboxFoundation.js +7 -0
  76. package/lib/es/datePicker/datePicker.css +26 -2
  77. package/lib/es/datePicker/datePicker.scss +11 -0
  78. package/lib/es/datePicker/foundation.d.ts +6 -3
  79. package/lib/es/datePicker/foundation.js +42 -18
  80. package/lib/es/datePicker/inputFoundation.js +3 -0
  81. package/lib/es/datePicker/monthsGridFoundation.d.ts +2 -1
  82. package/lib/es/datePicker/monthsGridFoundation.js +15 -3
  83. package/lib/es/datePicker/rtl.scss +15 -1
  84. package/lib/es/datePicker/variables.scss +2 -0
  85. package/lib/es/form/foundation.d.ts +13 -0
  86. package/lib/es/form/foundation.js +31 -8
  87. package/lib/es/form/utils.d.ts +1 -0
  88. package/lib/es/form/utils.js +5 -3
  89. package/lib/es/input/foundation.d.ts +8 -0
  90. package/lib/es/input/foundation.js +23 -2
  91. package/lib/es/input/textareaFoundation.d.ts +5 -1
  92. package/lib/es/input/textareaFoundation.js +11 -0
  93. package/lib/es/inputNumber/foundation.d.ts +2 -2
  94. package/lib/es/inputNumber/foundation.js +3 -1
  95. package/lib/es/modal/modalContentFoundation.d.ts +7 -0
  96. package/lib/es/modal/modalContentFoundation.js +14 -0
  97. package/lib/es/navigation/itemFoundation.d.ts +5 -0
  98. package/lib/es/navigation/itemFoundation.js +11 -0
  99. package/lib/es/navigation/subNavFoundation.d.ts +6 -0
  100. package/lib/es/navigation/subNavFoundation.js +13 -0
  101. package/lib/es/notification/notificationListFoundation.js +1 -1
  102. package/lib/es/radio/radio.css +7 -1
  103. package/lib/es/radio/radio.scss +8 -1
  104. package/lib/es/select/foundation.d.ts +2 -0
  105. package/lib/es/select/foundation.js +31 -6
  106. package/lib/es/sideSheet/sideSheetFoundation.d.ts +1 -0
  107. package/lib/es/slider/foundation.d.ts +6 -1
  108. package/lib/es/slider/foundation.js +6 -12
  109. package/lib/es/slider/slider.css +1 -0
  110. package/lib/es/slider/slider.scss +1 -0
  111. package/lib/es/table/table.css +0 -2
  112. package/lib/es/table/table.scss +0 -2
  113. package/lib/es/table/utils.d.ts +7 -0
  114. package/lib/es/table/utils.js +24 -0
  115. package/lib/es/tagInput/foundation.d.ts +4 -0
  116. package/lib/es/tagInput/foundation.js +11 -0
  117. package/lib/es/tooltip/foundation.js +7 -6
  118. package/lib/es/transfer/transfer.css +0 -2
  119. package/lib/es/transfer/transfer.scss +0 -2
  120. package/lib/es/tree/foundation.d.ts +1 -0
  121. package/lib/es/tree/foundation.js +1 -1
  122. package/lib/es/treeSelect/foundation.d.ts +9 -1
  123. package/lib/es/treeSelect/foundation.js +22 -1
  124. package/lib/es/utils/isEnterPress.d.ts +4 -0
  125. package/lib/es/utils/isEnterPress.js +8 -0
  126. package/lib/es/utils/keyCode.d.ts +2 -0
  127. package/lib/es/utils/keyCode.js +2 -0
  128. package/lib/es/utils/uuid.d.ts +16 -1
  129. package/lib/es/utils/uuid.js +32 -1
  130. package/modal/modalContentFoundation.ts +18 -0
  131. package/navigation/itemFoundation.ts +11 -0
  132. package/navigation/subNavFoundation.ts +12 -0
  133. package/notification/notificationListFoundation.ts +4 -8
  134. package/package.json +3 -3
  135. package/radio/radio.scss +8 -1
  136. package/select/foundation.ts +26 -7
  137. package/sideSheet/sideSheetFoundation.ts +3 -5
  138. package/slider/foundation.ts +10 -13
  139. package/slider/slider.scss +1 -0
  140. package/table/table.scss +0 -2
  141. package/table/utils.ts +16 -0
  142. package/tagInput/foundation.ts +10 -0
  143. package/tooltip/foundation.ts +5 -5
  144. package/transfer/transfer.scss +0 -2
  145. package/tree/foundation.ts +2 -1
  146. package/treeSelect/foundation.ts +20 -0
  147. package/utils/isEnterPress.ts +8 -0
  148. package/utils/keyCode.ts +3 -0
  149. package/utils/uuid.ts +29 -1
@@ -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
  }
@@ -1,5 +1,6 @@
1
1
  /* argus-disable unPkgSensitiveInfo */
2
2
  import BaseFoundation, { DefaultAdapter } from '../base/foundation';
3
+ import isEnterPress from '../utils/isEnterPress';
3
4
 
4
5
  export interface ItemProps {
5
6
  text?: any;
@@ -37,6 +38,7 @@ export interface ItemAdapter<P = Record<string, any>, S = Record<string, any>> e
37
38
  notifyMouseLeave(e: any): void;
38
39
  getIsCollapsed(): boolean;
39
40
  getSelected(): boolean;
41
+ getIsOpen(): boolean;
40
42
  }
41
43
 
42
44
  export default class ItemFoundation<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<ItemAdapter<P, S>, P, S> {
@@ -91,4 +93,13 @@ export default class ItemFoundation<P = Record<string, any>, S = Record<string,
91
93
  }
92
94
  this._adapter.notifyClick({ itemKey, text, domEvent: e });
93
95
  }
96
+
97
+ /**
98
+ * A11y: simulate item click
99
+ */
100
+ handleKeyPress(e: any) {
101
+ if (isEnterPress(e)) {
102
+ this.handleClick(e);
103
+ }
104
+ }
94
105
  }
@@ -1,4 +1,5 @@
1
1
  import BaseFoundation, { DefaultAdapter } from '../base/foundation';
2
+ import isEnterPress from '../utils/isEnterPress';
2
3
 
3
4
  const addKeys = function addKeys(originKeys: (string | number)[] = [], ...willAddKeys: (string | number)[]) {
4
5
  const keySet = new Set(originKeys);
@@ -120,4 +121,15 @@ export default class SubNavFoundation<P = Record<string, any>, S = Record<string
120
121
  this._adapter.notifyGlobalOpenChange(cbVal);
121
122
  this._adapter.notifyGlobalOnClick(cbVal);
122
123
  }
124
+
125
+ /**
126
+ * A11y: simulate sub nav click
127
+ * @param e
128
+ * @param titleRef
129
+ */
130
+ handleKeyPress(e: any, titleRef: any) {
131
+ if (isEnterPress(e)) {
132
+ this.handleClick(e, titleRef);
133
+ }
134
+ }
123
135
  }
@@ -4,24 +4,22 @@ import { NoticeInstance, NoticePosition, NoticeProps } from '../notification/not
4
4
  import { strings } from './constants';
5
5
 
6
6
 
7
-
8
7
  // eslint-disable-next-line @typescript-eslint/no-empty-interface
9
- export interface NotificationListProps{
8
+ export interface NotificationListProps {
10
9
 
11
10
  }
12
11
 
13
- export interface NotificationListState{
12
+ export interface NotificationListState {
14
13
  notices: NoticeInstance[];
15
14
  removedItems: NoticeInstance[];
16
15
  }
17
16
 
18
- export interface NotificationListAdapter extends DefaultAdapter<NotificationListProps, NotificationListState>{
17
+ export interface NotificationListAdapter extends DefaultAdapter<NotificationListProps, NotificationListState> {
19
18
  updateNotices: (notices: NoticeInstance[], removedItems?: NoticeInstance[]) => void;
20
19
  getNotices: () => NoticeInstance[];
21
20
  }
22
21
 
23
22
 
24
-
25
23
  export interface ConfigProps {
26
24
  top?: number | string;
27
25
  bottom?: number | string;
@@ -34,8 +32,6 @@ export interface ConfigProps {
34
32
  }
35
33
 
36
34
 
37
-
38
-
39
35
  export default class NotificationListFoundation extends BaseFoundation<NotificationListAdapter> {
40
36
 
41
37
  addNotice(opts: NoticeProps) {
@@ -48,7 +44,7 @@ export default class NotificationListFoundation extends BaseFoundation<Notificat
48
44
  // this.removeNotice(opts.id);
49
45
  // }, opts.duration * 1000);
50
46
  // }
51
- this._adapter.updateNotices([...notices, opts]);
47
+ this._adapter.updateNotices([opts, ...notices]);
52
48
  // return id;
53
49
  }
54
50
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-foundation",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build:lib": "node ./scripts/compileLib.js",
@@ -8,7 +8,7 @@
8
8
  },
9
9
  "dependencies": {
10
10
  "@babel/runtime-corejs3": "^7.15.4",
11
- "@douyinfe/semi-animation": "2.2.0",
11
+ "@douyinfe/semi-animation": "2.3.0",
12
12
  "async-validator": "^3.5.0",
13
13
  "classnames": "^2.2.6",
14
14
  "date-fns": "^2.9.0",
@@ -24,7 +24,7 @@
24
24
  "*.scss",
25
25
  "*.css"
26
26
  ],
27
- "gitHead": "f47324c727f9ca85ceb44649c4227b75876c4596",
27
+ "gitHead": "456b90e3f3501dd92e9d0b55bb9c8c86312837aa",
28
28
  "devDependencies": {
29
29
  "@babel/plugin-proposal-decorators": "^7.15.8",
30
30
  "@babel/plugin-transform-runtime": "^7.15.8",
package/radio/radio.scss CHANGED
@@ -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 {
@@ -1,11 +1,12 @@
1
1
  /* argus-disable unPkgSensitiveInfo */
2
2
  /* eslint-disable max-len */
3
3
  import BaseFoundation, { DefaultAdapter } from '../base/foundation';
4
- import KeyCode from '../utils/keyCode';
5
4
  import { isNumber, isString, isEqual, omit } from 'lodash';
5
+ import KeyCode, { ENTER_KEY } from '../utils/keyCode';
6
6
  import warning from '../utils/warning';
7
7
  import isNullOrUndefined from '../utils/isNullOrUndefined';
8
8
  import { BasicOptionProps } from './optionFoundation';
9
+ import isEnterPress from '../utils/isEnterPress';
9
10
 
10
11
  export interface SelectAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
11
12
  getTriggerWidth(): number;
@@ -405,7 +406,7 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
405
406
  _handleMultipleSelect({ value, label, ...rest }: BasicOptionProps, event: MouseEvent | KeyboardEvent) {
406
407
  const maxLimit = this._adapter.getMaxLimit();
407
408
  const selections = this._adapter.getSelections();
408
-
409
+ const { autoClearSearchValue } = this.getProps();
409
410
  if (selections.has(label)) {
410
411
  this._notifyDeselect(value, { value, label, ...rest });
411
412
  selections.delete(label);
@@ -420,7 +421,9 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
420
421
  // Controlled components, directly notified
421
422
  this._notifyChange(selections);
422
423
  if (this._isFilterable()) {
423
- this.clearInput();
424
+ if (autoClearSearchValue) {
425
+ this.clearInput();
426
+ }
424
427
  this.focusInput();
425
428
  }
426
429
  } else {
@@ -431,11 +434,14 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
431
434
  let { options } = this.getStates();
432
435
  // Searchable filtering, when selected, resets Input
433
436
  if (this._isFilterable()) {
434
- this.clearInput();
437
+ // When filter active,if autoClearSearchValue is true,reset input after select
438
+ if (autoClearSearchValue) {
439
+ this.clearInput();
440
+ // At the same time, the filtering of options is also cleared, in order to show all candidates
441
+ const sugInput = '';
442
+ options = this._filterOption(options, sugInput);
443
+ }
435
444
  this.focusInput();
436
- // At the same time, the filtering of options is also cleared, in order to show all candidates
437
- const sugInput = '';
438
- options = this._filterOption(options, sugInput);
439
445
  }
440
446
  this.updateOptionsActiveStatus(selections, options);
441
447
  this._notifyChange(selections);
@@ -650,6 +656,7 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
650
656
  this._handleEnterKeyDown(event);
651
657
  break;
652
658
  case KeyCode.ESC:
659
+ case KeyCode.TAB:
653
660
  this.close(event);
654
661
  break;
655
662
  default:
@@ -871,6 +878,18 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
871
878
  e.stopPropagation();
872
879
  }
873
880
 
881
+ handleKeyPress(e: KeyboardEvent) {
882
+ if (e && e.key === ENTER_KEY) {
883
+ this.handleClick(e);
884
+ }
885
+ }
886
+
887
+ handleClearBtnEnterPress(e: KeyboardEvent) {
888
+ if (isEnterPress(e)) {
889
+ this.handleClearClick(e as any);
890
+ }
891
+ }
892
+
874
893
  handleOptionMouseEnter(optionIndex: number) {
875
894
  this._adapter.updateFocusIndex(optionIndex);
876
895
  }
@@ -29,13 +29,14 @@ export interface SideSheetProps {
29
29
  width?: number | string;
30
30
  zIndex?: number;
31
31
  children?: any;
32
+ 'aria-label'?: string;
32
33
  }
33
34
 
34
- export interface SideSheetState{
35
+ export interface SideSheetState {
35
36
  hidden: boolean;
36
37
  }
37
38
 
38
- export interface SideSheetAdapter extends DefaultAdapter<SideSheetProps, SideSheetState>{
39
+ export interface SideSheetAdapter extends DefaultAdapter<SideSheetProps, SideSheetState> {
39
40
  disabledBodyScroll: () => void;
40
41
  enabledBodyScroll: () => void;
41
42
  notifyCancel: (e: any) => void;
@@ -46,9 +47,6 @@ export interface SideSheetAdapter extends DefaultAdapter<SideSheetProps, SideShe
46
47
  }
47
48
 
48
49
 
49
-
50
-
51
-
52
50
  export default class SideSheetFoundation extends BaseFoundation<SideSheetAdapter> {
53
51
  constructor(adapter: SideSheetAdapter) {
54
52
  super({ ...SideSheetFoundation.defaultAdapter, ...adapter });
@@ -31,6 +31,10 @@ export interface SliderProps{
31
31
  showBoundary?: boolean;
32
32
  railStyle?: Record<string, any>;
33
33
  verticalReverse?: boolean;
34
+ 'aria-label'?: string;
35
+ 'aria-labelledby'?: string;
36
+ 'aria-valuetext'?: string;
37
+ getAriaValueText?: (value: number) => string;
34
38
  }
35
39
 
36
40
  export interface SliderState {
@@ -235,7 +239,7 @@ export default class SliderFoundation extends BaseFoundation<SliderAdapter> {
235
239
 
236
240
  const scroll = (node: Element) => regex.test(style(node, 'overflow') + style(node, 'overflow-y') + style(node, 'overflow-x'));
237
241
 
238
- const scrollParent = (node: Element): Element | boolean => (
242
+ const scrollParent = (node: Element): Element => (
239
243
  !node || node === document.body ? document.body : scroll(node) ? node : scrollParent(node.parentNode as Element)
240
244
  );
241
245
 
@@ -316,18 +320,8 @@ export default class SliderFoundation extends BaseFoundation<SliderAdapter> {
316
320
  } else {
317
321
  compareValue = currentValue;
318
322
  }
319
- if (step !== 1) {
320
- // Existence step
321
- if (stepValue > compareValue && Math.round(stepValue / step) * step >= stepValue) {
322
- // Move right
323
- stepValue = Math.round(stepValue / step) * step;
324
- } else if (stepValue < compareValue && Math.round(stepValue / step) * step <= stepValue) {
325
- // Move left
326
- stepValue = Math.round(stepValue / step) * step;
327
- } else {
328
- // Other moves are invalid, click valid
329
- stepValue = compareValue;
330
- }
323
+ if (step !== 1) { // Find nearest step point
324
+ stepValue = Math.round(stepValue / step) * step;
331
325
  }
332
326
  if (range && stepValue !== compareValue) {
333
327
  if (vertical && verticalReverse) {
@@ -559,6 +553,9 @@ export default class SliderFoundation extends BaseFoundation<SliderAdapter> {
559
553
  return true;
560
554
  };
561
555
 
556
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
557
+ onFocus = (e:any, handler: 'min'| 'max') => {}
558
+
562
559
  handleWrapClick = (e: any) => {
563
560
  const { disabled, isDrag } = this._adapter.getStates();
564
561
  if (isDrag || disabled || this._adapter.isEventFromHandle(e)) {
@@ -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 {
package/table/table.scss CHANGED
@@ -25,7 +25,6 @@ $module: #{$prefix}-table;
25
25
  }
26
26
 
27
27
  &-middle {
28
- .#{$module}-thead > .#{$module}-row > .#{$module}-row-head,
29
28
  .#{$module}-tbody > .#{$module}-row > .#{$module}-row-cell {
30
29
  padding-top: $spacing-table_middle-paddingY;
31
30
  padding-bottom: $spacing-table_middle-paddingY;
@@ -33,7 +32,6 @@ $module: #{$prefix}-table;
33
32
  }
34
33
 
35
34
  &-small {
36
- .#{$module}-thead > .#{$module}-row > .#{$module}-row-head,
37
35
  .#{$module}-tbody > .#{$module}-row > .#{$module}-row-cell {
38
36
  padding-top: $spacing-table_small-paddingY;
39
37
  padding-bottom: $spacing-table_small-paddingY;
package/table/utils.ts CHANGED
@@ -484,4 +484,20 @@ export function warnIfNoDataIndex(column: Record<string, any>) {
484
484
  logger.warn(`The column with sorter or filter must pass the 'dataIndex' prop`);
485
485
  }
486
486
  }
487
+ }
488
+ /**
489
+ * Whether is tree table
490
+ */
491
+ export function isTreeTable({ dataSource, childrenRecordName = 'children' }: { dataSource: Record<string, any>; childrenRecordName?: string; }) {
492
+ let flag = false;
493
+ if (Array.isArray(dataSource)) {
494
+ for (const data of dataSource) {
495
+ const children = get(data, childrenRecordName);
496
+ if (Array.isArray(children) && children.length) {
497
+ flag = true;
498
+ break;
499
+ }
500
+ }
501
+ }
502
+ return flag;
487
503
  }
@@ -7,6 +7,7 @@ import {
7
7
  isUndefined
8
8
  } from 'lodash';
9
9
  import getSplitedArray from './utils/getSplitedArray';
10
+ import isEnterPress from '../utils/isEnterPress';
10
11
 
11
12
  export type TagInputChangeEvent = any;
12
13
  export type TagInputCursorEvent = any;
@@ -143,6 +144,15 @@ class TagInputFoundation extends BaseFoundation<TagInputAdapter> {
143
144
  this._adapter.notifyFocus(e);
144
145
  }
145
146
 
147
+ /**
148
+ * A11y: simulate clear button click
149
+ */
150
+ handleClearEnterPress(e: TagInputKeyboardEvent) {
151
+ if (isEnterPress(e)) {
152
+ this.handleClearBtn(e);
153
+ }
154
+ }
155
+
146
156
  handleClearBtn(e: TagInputMouseEvent) {
147
157
  const { inputValue, tagsArray } = this._adapter.getStates();
148
158
  if (tagsArray.length > 0) {
@@ -270,7 +270,6 @@ export default class Tooltip<P = Record<string, any>, S = Record<string, any>> e
270
270
  if (trigger === 'custom') {
271
271
  // eslint-disable-next-line
272
272
  this._adapter.registerClickOutsideHandler(() => {});
273
- this._togglePortalVisible(true);
274
273
  }
275
274
 
276
275
  /**
@@ -571,6 +570,7 @@ export default class Tooltip<P = Record<string, any>, S = Record<string, any>> e
571
570
  // place the dom correctly
572
571
  adjustPosIfNeed(position: Position | string, style: Record<string, any>, triggerRect: DOMRect, wrapperRect: DOMRect, containerRect: PopupContainerDOMRect) {
573
572
  const { innerWidth, innerHeight } = window;
573
+ const { spacing } = this.getProps();
574
574
 
575
575
  if (wrapperRect.width > 0 && wrapperRect.height > 0) {
576
576
  // let clientLeft = left + translateX * wrapperRect.width - containerRect.scrollLeft;
@@ -600,10 +600,10 @@ export default class Tooltip<P = Record<string, any>, S = Record<string, any>> e
600
600
 
601
601
  // The wrapperR ect.top|bottom equivalent cannot be directly used here for comparison, which is easy to cause jitter
602
602
 
603
- const shouldReverseTop = clientTop < wrapperRect.height && restClientBottom > wrapperRect.height;
604
- const shouldReverseLeft = clientLeft < wrapperRect.width && restClientRight > wrapperRect.width;
605
- const sholdReverseBottom = restClientBottom < wrapperRect.height && clientTop > wrapperRect.height;
606
- const shouldReverseRight = restClientRight < wrapperRect.width && clientLeft > wrapperRect.width;
603
+ const shouldReverseTop = clientTop < wrapperRect.height + spacing && restClientBottom > wrapperRect.height + spacing;
604
+ const shouldReverseLeft = clientLeft < wrapperRect.width + spacing && restClientRight > wrapperRect.width + spacing;
605
+ const sholdReverseBottom = restClientBottom < wrapperRect.height + spacing && clientTop > wrapperRect.height + spacing;
606
+ const shouldReverseRight = restClientRight < wrapperRect.width + spacing && clientLeft > wrapperRect.width + spacing;
607
607
 
608
608
  const shouldReverseTopSide = restClientTop < wrapperRect.height && clientBottom > wrapperRect.height;
609
609
  const shouldReverseBottomSide = clientBottom < wrapperRect.height && restClientTop > wrapperRect.height;
@@ -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;
@@ -233,6 +233,7 @@ export interface BasicTreeProps {
233
233
  value?: BasicValue;
234
234
  virtualize?: Virtualize;
235
235
  icon?: any;
236
+ 'aria-label'?: string;
236
237
  }
237
238
 
238
239
  /* Data maintained internally. At the React framework level, corresponding to state */
@@ -783,7 +784,7 @@ export default class TreeFoundation extends BaseFoundation<TreeAdapter, BasicTre
783
784
 
784
785
  // Update the drag position
785
786
  if (dragNode && eventKey === dragOverNodeKey) {
786
- const newPos = calcDropRelativePosition(event, treeNode);
787
+ const newPos = calcDropRelativePosition(e, treeNode);
787
788
  if (dropPosition === newPos) {
788
789
  return;
789
790
  }
@@ -23,6 +23,7 @@ import {
23
23
  BasicExpandedOtherProps
24
24
  } from '../tree/foundation';
25
25
  import { Motion } from '../utils/type';
26
+ import isEnterPress from '../utils/isEnterPress';
26
27
 
27
28
  /* Here ValidateStatus is the same as ValidateStatus in baseComponent */
28
29
  export type ValidateStatus = 'error' | 'warning' | 'default';
@@ -93,6 +94,7 @@ export interface BasicTreeSelectProps extends Pick<BasicTreeProps,
93
94
  | 'onSearch'
94
95
  | 'expandAll'
95
96
  | 'disableStrictly'
97
+ | 'aria-label'
96
98
  > {
97
99
  motion?: Motion;
98
100
  mouseEnterDelay?: number;
@@ -417,6 +419,15 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
417
419
  }
418
420
  }
419
421
 
422
+ /**
423
+ * A11y: simulate selection click
424
+ */
425
+ handleSelectionEnterPress(e: any) {
426
+ if (isEnterPress(e)) {
427
+ this.handleClick(e);
428
+ }
429
+ }
430
+
420
431
  handleClear(e: any) {
421
432
  const { searchPosition, filterTreeNode } = this.getProps();
422
433
  const { inputValue, selectedKeys } = this.getStates();
@@ -445,6 +456,15 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
445
456
  }
446
457
  }
447
458
 
459
+ /**
460
+ * A11y: simulate clear button click
461
+ */
462
+ handleClearEnterPress(e: any) {
463
+ if (isEnterPress(e)) {
464
+ this.handleClear(e);
465
+ }
466
+ }
467
+
448
468
  removeTag(eventKey: BasicTreeNodeData['key']) {
449
469
  const { disableStrictly } = this.getProps();
450
470
  const { keyEntities, disabledKeys } = this.getStates();
@@ -0,0 +1,8 @@
1
+ import { get } from 'lodash';
2
+ import { ENTER_KEY } from './keyCode';
3
+
4
+ function isEnterPress<T extends { key: string }>(e: T) {
5
+ return get(e, 'key') === ENTER_KEY ? true : false;
6
+ }
7
+
8
+ export default isEnterPress;
package/utils/keyCode.ts CHANGED
@@ -426,4 +426,7 @@ const keyCode = {
426
426
  WIN_IME: 229,
427
427
  };
428
428
 
429
+ export const ENTER_KEY = 'Enter';
430
+ export const TAB_KEY = 'Tab';
431
+
429
432
  export default keyCode;
package/utils/uuid.ts CHANGED
@@ -13,4 +13,32 @@ function getUuidv4() {
13
13
  }
14
14
  }
15
15
 
16
- export { getUuid, getUuidv4 };
16
+ /**
17
+ * Get a random id with prefix, it not strictly guarantee id uniqueness
18
+ *
19
+ * Note: the return value of getUuid is too long, we need a short one
20
+ *
21
+ * @example
22
+ * getUuidShort({ prefix: 'semi' }) => 'semi-46dinzc'
23
+ * getUuidShort({ prefix: '' }) => '0eer2i0'
24
+ * getUuidShort({ prefix: 'semi', length: 4 }) => 'semi-8jts'
25
+ */
26
+ function getUuidShort(options: GetUuidShortOptions = {}) {
27
+ const { prefix = '', length = 7 } = options;
28
+ const characters = '0123456789abcdefghijklmnopqrstuvwxyz';
29
+ const total = characters.length;
30
+ let randomId = '';
31
+ for (let i = 0; i < length; i++) {
32
+ const random = Math.floor(Math.random() * total);
33
+ randomId += characters.charAt(random);
34
+ }
35
+
36
+ return prefix ? `${prefix}-${randomId}` : randomId;
37
+ }
38
+
39
+ interface GetUuidShortOptions {
40
+ prefix?: string;
41
+ length?: number;
42
+ }
43
+
44
+ export { getUuid, getUuidv4, getUuidShort };