@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.
- package/breadcrumb/foundation.ts +10 -1
- package/checkbox/checkboxFoundation.ts +9 -0
- package/datePicker/foundation.ts +2 -4
- package/datePicker/monthsGridFoundation.ts +10 -3
- package/form/foundation.ts +20 -8
- package/form/utils.ts +2 -0
- package/input/foundation.ts +21 -2
- package/input/textareaFoundation.ts +11 -1
- package/inputNumber/foundation.ts +3 -2
- package/lib/cjs/breadcrumb/foundation.d.ts +4 -0
- package/lib/cjs/breadcrumb/foundation.js +12 -0
- package/lib/cjs/checkbox/checkboxFoundation.d.ts +3 -0
- package/lib/cjs/checkbox/checkboxFoundation.js +8 -0
- package/lib/cjs/datePicker/foundation.js +2 -4
- package/lib/cjs/datePicker/monthsGridFoundation.d.ts +1 -0
- package/lib/cjs/datePicker/monthsGridFoundation.js +16 -3
- package/lib/cjs/form/foundation.d.ts +13 -0
- package/lib/cjs/form/foundation.js +32 -8
- package/lib/cjs/form/utils.d.ts +1 -0
- package/lib/cjs/form/utils.js +5 -3
- package/lib/cjs/input/foundation.d.ts +8 -0
- package/lib/cjs/input/foundation.js +24 -2
- package/lib/cjs/input/textareaFoundation.d.ts +5 -1
- package/lib/cjs/input/textareaFoundation.js +12 -0
- package/lib/cjs/inputNumber/foundation.d.ts +2 -2
- package/lib/cjs/inputNumber/foundation.js +3 -1
- package/lib/cjs/modal/modalContentFoundation.d.ts +7 -0
- package/lib/cjs/modal/modalContentFoundation.js +14 -0
- package/lib/cjs/navigation/itemFoundation.d.ts +5 -0
- package/lib/cjs/navigation/itemFoundation.js +12 -0
- package/lib/cjs/navigation/subNavFoundation.d.ts +6 -0
- package/lib/cjs/navigation/subNavFoundation.js +14 -0
- package/lib/cjs/notification/notificationListFoundation.js +1 -1
- package/lib/cjs/radio/radio.css +7 -1
- package/lib/cjs/radio/radio.scss +8 -1
- package/lib/cjs/select/foundation.d.ts +2 -0
- package/lib/cjs/select/foundation.js +40 -6
- package/lib/cjs/sideSheet/sideSheetFoundation.d.ts +1 -0
- package/lib/cjs/slider/foundation.d.ts +6 -1
- package/lib/cjs/slider/foundation.js +6 -12
- package/lib/cjs/slider/slider.css +1 -0
- package/lib/cjs/slider/slider.scss +1 -0
- package/lib/cjs/table/utils.d.ts +7 -0
- package/lib/cjs/table/utils.js +26 -0
- package/lib/cjs/tagInput/foundation.d.ts +4 -0
- package/lib/cjs/tagInput/foundation.js +12 -0
- package/lib/cjs/tooltip/foundation.js +7 -6
- package/lib/cjs/transfer/transfer.css +0 -2
- package/lib/cjs/transfer/transfer.scss +0 -2
- package/lib/cjs/tree/foundation.d.ts +1 -0
- package/lib/cjs/tree/foundation.js +1 -1
- package/lib/cjs/treeSelect/foundation.d.ts +9 -1
- package/lib/cjs/treeSelect/foundation.js +22 -0
- package/lib/cjs/utils/isEnterPress.d.ts +4 -0
- package/lib/cjs/utils/isEnterPress.js +22 -0
- package/lib/cjs/utils/keyCode.d.ts +2 -0
- package/lib/cjs/utils/keyCode.js +5 -1
- package/lib/cjs/utils/uuid.d.ts +16 -1
- package/lib/cjs/utils/uuid.js +32 -0
- package/lib/es/breadcrumb/foundation.d.ts +4 -0
- package/lib/es/breadcrumb/foundation.js +11 -0
- package/lib/es/checkbox/checkboxFoundation.d.ts +3 -0
- package/lib/es/checkbox/checkboxFoundation.js +7 -0
- package/lib/es/datePicker/foundation.js +2 -4
- package/lib/es/datePicker/monthsGridFoundation.d.ts +1 -0
- package/lib/es/datePicker/monthsGridFoundation.js +15 -3
- package/lib/es/form/foundation.d.ts +13 -0
- package/lib/es/form/foundation.js +31 -8
- package/lib/es/form/utils.d.ts +1 -0
- package/lib/es/form/utils.js +5 -3
- package/lib/es/input/foundation.d.ts +8 -0
- package/lib/es/input/foundation.js +23 -2
- package/lib/es/input/textareaFoundation.d.ts +5 -1
- package/lib/es/input/textareaFoundation.js +11 -0
- package/lib/es/inputNumber/foundation.d.ts +2 -2
- package/lib/es/inputNumber/foundation.js +3 -1
- package/lib/es/modal/modalContentFoundation.d.ts +7 -0
- package/lib/es/modal/modalContentFoundation.js +14 -0
- package/lib/es/navigation/itemFoundation.d.ts +5 -0
- package/lib/es/navigation/itemFoundation.js +11 -0
- package/lib/es/navigation/subNavFoundation.d.ts +6 -0
- package/lib/es/navigation/subNavFoundation.js +13 -0
- package/lib/es/notification/notificationListFoundation.js +1 -1
- package/lib/es/radio/radio.css +7 -1
- package/lib/es/radio/radio.scss +8 -1
- package/lib/es/select/foundation.d.ts +2 -0
- package/lib/es/select/foundation.js +31 -6
- package/lib/es/sideSheet/sideSheetFoundation.d.ts +1 -0
- package/lib/es/slider/foundation.d.ts +6 -1
- package/lib/es/slider/foundation.js +6 -12
- package/lib/es/slider/slider.css +1 -0
- package/lib/es/slider/slider.scss +1 -0
- package/lib/es/table/utils.d.ts +7 -0
- package/lib/es/table/utils.js +24 -0
- package/lib/es/tagInput/foundation.d.ts +4 -0
- package/lib/es/tagInput/foundation.js +11 -0
- package/lib/es/tooltip/foundation.js +7 -6
- package/lib/es/transfer/transfer.css +0 -2
- package/lib/es/transfer/transfer.scss +0 -2
- package/lib/es/tree/foundation.d.ts +1 -0
- package/lib/es/tree/foundation.js +1 -1
- package/lib/es/treeSelect/foundation.d.ts +9 -1
- package/lib/es/treeSelect/foundation.js +22 -1
- package/lib/es/utils/isEnterPress.d.ts +4 -0
- package/lib/es/utils/isEnterPress.js +8 -0
- package/lib/es/utils/keyCode.d.ts +2 -0
- package/lib/es/utils/keyCode.js +2 -0
- package/lib/es/utils/uuid.d.ts +16 -1
- package/lib/es/utils/uuid.js +32 -1
- package/modal/modalContentFoundation.ts +18 -0
- package/navigation/itemFoundation.ts +11 -0
- package/navigation/subNavFoundation.ts +12 -0
- package/notification/notificationListFoundation.ts +4 -8
- package/package.json +3 -3
- package/radio/radio.scss +8 -1
- package/select/foundation.ts +26 -7
- package/sideSheet/sideSheetFoundation.ts +3 -5
- package/slider/foundation.ts +10 -13
- package/slider/slider.scss +1 -0
- package/table/utils.ts +16 -0
- package/tagInput/foundation.ts +10 -0
- package/tooltip/foundation.ts +5 -5
- package/transfer/transfer.scss +0 -2
- package/tree/foundation.ts +2 -1
- package/treeSelect/foundation.ts +20 -0
- package/utils/isEnterPress.ts +8 -0
- package/utils/keyCode.ts +3 -0
- package/utils/uuid.ts +29 -1
|
@@ -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
|
|
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.
|
|
3
|
+
"version": "2.3.1",
|
|
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.
|
|
11
|
+
"@douyinfe/semi-animation": "2.3.1",
|
|
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": "
|
|
27
|
+
"gitHead": "c77d5f7c20ea94158c0c79458879c7d884d99c21",
|
|
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
|
-
|
|
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 {
|
package/select/foundation.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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 });
|
package/slider/foundation.ts
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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)) {
|
package/slider/slider.scss
CHANGED
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
|
}
|
package/tagInput/foundation.ts
CHANGED
|
@@ -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) {
|
package/tooltip/foundation.ts
CHANGED
|
@@ -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;
|
package/transfer/transfer.scss
CHANGED
package/tree/foundation.ts
CHANGED
|
@@ -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(
|
|
787
|
+
const newPos = calcDropRelativePosition(e, treeNode);
|
|
787
788
|
if (dropPosition === newPos) {
|
|
788
789
|
return;
|
|
789
790
|
}
|
package/treeSelect/foundation.ts
CHANGED
|
@@ -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();
|
package/utils/keyCode.ts
CHANGED
package/utils/uuid.ts
CHANGED
|
@@ -13,4 +13,32 @@ function getUuidv4() {
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
|
|
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 };
|