@douyinfe/semi-foundation 2.13.0 → 2.14.0-beta.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/anchor/foundation.ts +1 -2
- package/autoComplete/foundation.ts +29 -18
- package/avatar/avatar.scss +14 -0
- package/avatar/foundation.ts +17 -0
- package/avatar/variables.scss +3 -0
- package/base/foundation.ts +6 -0
- package/calendar/foundation.ts +2 -1
- package/cascader/cascader.scss +3 -0
- package/cascader/foundation.ts +3 -0
- package/checkbox/checkboxFoundation.ts +2 -1
- package/datePicker/foundation.ts +3 -3
- package/datePicker/inputFoundation.ts +1 -1
- package/datePicker/monthsGridFoundation.ts +8 -4
- package/form/utils.ts +5 -1
- package/input/foundation.ts +3 -11
- package/input/input.scss +6 -0
- package/input/textareaFoundation.ts +0 -9
- package/input/variables.scss +3 -0
- package/lib/cjs/anchor/foundation.d.ts +1 -2
- package/lib/cjs/autoComplete/foundation.d.ts +0 -1
- package/lib/cjs/autoComplete/foundation.js +35 -23
- package/lib/cjs/avatar/avatar.css +9 -0
- package/lib/cjs/avatar/avatar.scss +14 -0
- package/lib/cjs/avatar/foundation.d.ts +3 -0
- package/lib/cjs/avatar/foundation.js +20 -0
- package/lib/cjs/avatar/variables.scss +3 -0
- package/lib/cjs/base/foundation.js +12 -0
- package/lib/cjs/calendar/eventUtil.d.ts +1 -1
- package/lib/cjs/calendar/foundation.d.ts +1 -2
- package/lib/cjs/cascader/cascader.css +5 -0
- package/lib/cjs/cascader/cascader.scss +3 -0
- package/lib/cjs/cascader/foundation.d.ts +0 -11
- package/lib/cjs/cascader/foundation.js +5 -0
- package/lib/cjs/checkbox/checkboxFoundation.js +3 -1
- package/lib/cjs/datePicker/foundation.d.ts +3 -4
- package/lib/cjs/datePicker/inputFoundation.d.ts +1 -2
- package/lib/cjs/datePicker/monthsGridFoundation.d.ts +4 -5
- package/lib/cjs/form/utils.d.ts +5 -2
- package/lib/cjs/form/utils.js +4 -0
- package/lib/cjs/input/foundation.d.ts +0 -4
- package/lib/cjs/input/foundation.js +7 -13
- package/lib/cjs/input/input.css +6 -0
- package/lib/cjs/input/input.scss +6 -0
- package/lib/cjs/input/textareaFoundation.d.ts +0 -4
- package/lib/cjs/input/textareaFoundation.js +0 -12
- package/lib/cjs/input/variables.scss +3 -0
- package/lib/cjs/overflowList/foundation.d.ts +1 -0
- package/lib/cjs/overflowList/foundation.js +25 -0
- package/lib/cjs/radio/radio.css +6 -0
- package/lib/cjs/radio/radio.scss +8 -0
- package/lib/cjs/radio/radioFoundation.d.ts +3 -0
- package/lib/cjs/radio/radioFoundation.js +24 -0
- package/lib/cjs/radio/variables.scss +4 -0
- package/lib/cjs/select/foundation.js +2 -0
- package/lib/cjs/select/select.css +5 -0
- package/lib/cjs/select/select.scss +3 -0
- package/lib/cjs/switch/foundation.js +3 -1
- package/lib/cjs/tagInput/foundation.js +2 -0
- package/lib/cjs/tagInput/tagInput.css +1 -1
- package/lib/cjs/tagInput/variables.scss +1 -1
- package/lib/cjs/timePicker/foundation.js +4 -0
- package/lib/cjs/timePicker/utils/localeDate.js +5 -0
- package/lib/cjs/tree/tree.css +0 -20
- package/lib/cjs/tree/tree.scss +0 -20
- package/lib/cjs/tree/treeUtil.js +2 -0
- package/lib/cjs/tree/variables.scss +0 -18
- package/lib/cjs/treeSelect/foundation.js +10 -1
- package/lib/cjs/treeSelect/treeSelect.css +5 -0
- package/lib/cjs/treeSelect/treeSelect.scss +3 -0
- package/lib/cjs/utils/Logger.js +8 -0
- package/lib/cjs/utils/Store.js +1 -0
- package/lib/cjs/utils/date-fns-extra.js +4 -0
- package/lib/cjs/utils/isElement.js +1 -0
- package/lib/cjs/utils/isEscPress.js +1 -0
- package/lib/cjs/utils/set.js +1 -0
- package/lib/es/anchor/foundation.d.ts +1 -2
- package/lib/es/autoComplete/foundation.d.ts +0 -1
- package/lib/es/autoComplete/foundation.js +35 -23
- package/lib/es/avatar/avatar.css +9 -0
- package/lib/es/avatar/avatar.scss +14 -0
- package/lib/es/avatar/foundation.d.ts +3 -0
- package/lib/es/avatar/foundation.js +19 -0
- package/lib/es/avatar/variables.scss +3 -0
- package/lib/es/base/foundation.js +12 -0
- package/lib/es/calendar/eventUtil.d.ts +1 -1
- package/lib/es/calendar/foundation.d.ts +1 -2
- package/lib/es/cascader/cascader.css +5 -0
- package/lib/es/cascader/cascader.scss +3 -0
- package/lib/es/cascader/foundation.d.ts +0 -11
- package/lib/es/cascader/foundation.js +5 -0
- package/lib/es/checkbox/checkboxFoundation.js +2 -1
- package/lib/es/datePicker/foundation.d.ts +3 -4
- package/lib/es/datePicker/inputFoundation.d.ts +1 -2
- package/lib/es/datePicker/monthsGridFoundation.d.ts +4 -5
- package/lib/es/form/utils.d.ts +5 -2
- package/lib/es/form/utils.js +5 -0
- package/lib/es/input/foundation.d.ts +0 -4
- package/lib/es/input/foundation.js +6 -12
- package/lib/es/input/input.css +6 -0
- package/lib/es/input/input.scss +6 -0
- package/lib/es/input/textareaFoundation.d.ts +0 -4
- package/lib/es/input/textareaFoundation.js +0 -11
- package/lib/es/input/variables.scss +3 -0
- package/lib/es/overflowList/foundation.d.ts +1 -0
- package/lib/es/overflowList/foundation.js +25 -0
- package/lib/es/radio/radio.css +6 -0
- package/lib/es/radio/radio.scss +8 -0
- package/lib/es/radio/radioFoundation.d.ts +3 -0
- package/lib/es/radio/radioFoundation.js +23 -0
- package/lib/es/radio/variables.scss +4 -0
- package/lib/es/select/foundation.js +2 -0
- package/lib/es/select/select.css +5 -0
- package/lib/es/select/select.scss +3 -0
- package/lib/es/switch/foundation.js +2 -1
- package/lib/es/tagInput/foundation.js +2 -0
- package/lib/es/tagInput/tagInput.css +1 -1
- package/lib/es/tagInput/variables.scss +1 -1
- package/lib/es/timePicker/foundation.js +4 -0
- package/lib/es/timePicker/utils/localeDate.js +5 -0
- package/lib/es/tree/tree.css +0 -20
- package/lib/es/tree/tree.scss +0 -20
- package/lib/es/tree/treeUtil.js +2 -0
- package/lib/es/tree/variables.scss +0 -18
- package/lib/es/treeSelect/foundation.js +10 -1
- package/lib/es/treeSelect/treeSelect.css +5 -0
- package/lib/es/treeSelect/treeSelect.scss +3 -0
- package/lib/es/utils/Logger.js +8 -0
- package/lib/es/utils/Store.js +1 -0
- package/lib/es/utils/date-fns-extra.js +4 -0
- package/lib/es/utils/isElement.js +1 -0
- package/lib/es/utils/isEscPress.js +1 -0
- package/lib/es/utils/set.js +2 -0
- package/overflowList/foundation.ts +20 -0
- package/package.json +2 -2
- package/radio/radio.scss +8 -0
- package/radio/radioFoundation.ts +17 -0
- package/radio/variables.scss +4 -0
- package/select/foundation.ts +1 -0
- package/select/select.scss +3 -0
- package/switch/foundation.ts +2 -1
- package/tagInput/foundation.ts +1 -0
- package/tagInput/variables.scss +1 -1
- package/timePicker/foundation.ts +2 -1
- package/timePicker/utils/localeDate.ts +3 -0
- package/tree/tree.scss +0 -20
- package/tree/treeUtil.ts +1 -0
- package/tree/variables.scss +0 -18
- package/treeSelect/foundation.ts +7 -0
- package/treeSelect/treeSelect.scss +3 -0
- package/utils/Logger.ts +4 -0
- package/utils/Store.ts +1 -0
- package/utils/date-fns-extra.ts +2 -0
- package/utils/isElement.ts +1 -0
- package/utils/isEscPress.ts +1 -0
- package/utils/set.ts +1 -0
package/anchor/foundation.ts
CHANGED
|
@@ -2,7 +2,6 @@ import BaseFoundation, { DefaultAdapter } from '../base/foundation';
|
|
|
2
2
|
import { isArray, get } from 'lodash';
|
|
3
3
|
import scrollIntoView, { CustomBehaviorOptions } from 'scroll-into-view-if-needed';
|
|
4
4
|
import { cssClasses } from './constants';
|
|
5
|
-
import React from 'react';
|
|
6
5
|
|
|
7
6
|
const prefixCls = cssClasses.PREFIX;
|
|
8
7
|
|
|
@@ -21,7 +20,7 @@ export interface AnchorAdapter<P = Record<string, any>, S = Record<string, any>>
|
|
|
21
20
|
getAnchorNode: (selector: string) => HTMLElement;
|
|
22
21
|
getContentNode: (selector: string) => HTMLElement;
|
|
23
22
|
notifyChange: (currentLink: string, previousLink: string) => void;
|
|
24
|
-
notifyClick: (e:
|
|
23
|
+
notifyClick: (e: any, link: string) => void;
|
|
25
24
|
canSmoothScroll: () => boolean;
|
|
26
25
|
}
|
|
27
26
|
|
|
@@ -78,7 +78,7 @@ class AutoCompleteFoundation<P = Record<string, any>, S = Record<string, any>> e
|
|
|
78
78
|
|
|
79
79
|
destroy(): void {
|
|
80
80
|
// this._adapter.unregisterClickOutsideHandler();
|
|
81
|
-
this.unBindKeyBoardEvent();
|
|
81
|
+
// this.unBindKeyBoardEvent();
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
_setDropdownWidth(): void {
|
|
@@ -114,7 +114,6 @@ class AutoCompleteFoundation<P = Record<string, any>, S = Record<string, any>> e
|
|
|
114
114
|
this._setDropdownWidth();
|
|
115
115
|
// this._adapter.registerClickOutsideHandler(e => this.closeDropdown(e));
|
|
116
116
|
this._adapter.notifyDropdownVisibleChange(true);
|
|
117
|
-
this.bindKeyBoardEvent();
|
|
118
117
|
this._modifyFocusIndexOnPanelOpen();
|
|
119
118
|
}
|
|
120
119
|
|
|
@@ -123,7 +122,8 @@ class AutoCompleteFoundation<P = Record<string, any>, S = Record<string, any>> e
|
|
|
123
122
|
this._adapter.toggleListVisible(false);
|
|
124
123
|
// this._adapter.unregisterClickOutsideHandler();
|
|
125
124
|
this._adapter.notifyDropdownVisibleChange(false);
|
|
126
|
-
|
|
125
|
+
// After closing the panel, you can still open the panel by pressing the enter key
|
|
126
|
+
// this.unBindKeyBoardEvent();
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
// props.data => optionList
|
|
@@ -301,19 +301,16 @@ class AutoCompleteFoundation<P = Record<string, any>, S = Record<string, any>> e
|
|
|
301
301
|
this._adapter.registerKeyDown(this._keydownHandler);
|
|
302
302
|
}
|
|
303
303
|
|
|
304
|
-
unBindKeyBoardEvent() {
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
}
|
|
304
|
+
// unBindKeyBoardEvent() {
|
|
305
|
+
// if (this._keydownHandler) {
|
|
306
|
+
// this._adapter.unregisterKeyDown(this._keydownHandler);
|
|
307
|
+
// }
|
|
308
|
+
// }
|
|
309
309
|
|
|
310
310
|
_handleKeyDown(event: KeyboardEvent) {
|
|
311
311
|
const key = event.keyCode;
|
|
312
312
|
const { visible } = this.getStates();
|
|
313
313
|
|
|
314
|
-
if (!visible) {
|
|
315
|
-
return;
|
|
316
|
-
}
|
|
317
314
|
switch (key) {
|
|
318
315
|
case KeyCode.UP:
|
|
319
316
|
// Prevent Input's cursor from following the movement
|
|
@@ -326,6 +323,8 @@ class AutoCompleteFoundation<P = Record<string, any>, S = Record<string, any>> e
|
|
|
326
323
|
this._handleArrowKeyDown(1);
|
|
327
324
|
break;
|
|
328
325
|
case KeyCode.ENTER:
|
|
326
|
+
// when custom trigger, prevent outer open panel again
|
|
327
|
+
event.preventDefault();
|
|
329
328
|
this._handleEnterKeyDown();
|
|
330
329
|
break;
|
|
331
330
|
case KeyCode.ESC:
|
|
@@ -377,17 +376,26 @@ class AutoCompleteFoundation<P = Record<string, any>, S = Record<string, any>> e
|
|
|
377
376
|
}
|
|
378
377
|
|
|
379
378
|
_handleArrowKeyDown(offset: number): void {
|
|
380
|
-
this.
|
|
379
|
+
const { visible } = this.getStates();
|
|
380
|
+
if (!visible){
|
|
381
|
+
this.openDropdown();
|
|
382
|
+
} else {
|
|
383
|
+
this._getEnableFocusIndex(offset);
|
|
384
|
+
}
|
|
381
385
|
}
|
|
382
386
|
|
|
383
387
|
_handleEnterKeyDown() {
|
|
384
388
|
const { visible, options, focusIndex } = this.getStates();
|
|
385
|
-
if (
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
389
|
+
if (!visible){
|
|
390
|
+
this.openDropdown();
|
|
391
|
+
} else {
|
|
392
|
+
if (focusIndex !== undefined && focusIndex !== -1 && options.length !== 0) {
|
|
393
|
+
const visibleOptions = options.filter((item: StateOptionItem) => item.show);
|
|
394
|
+
const selectedOption = visibleOptions[focusIndex];
|
|
395
|
+
this.handleSelect(selectedOption, focusIndex);
|
|
396
|
+
} else {
|
|
397
|
+
this.closeDropdown();
|
|
398
|
+
}
|
|
391
399
|
}
|
|
392
400
|
}
|
|
393
401
|
|
|
@@ -396,6 +404,9 @@ class AutoCompleteFoundation<P = Record<string, any>, S = Record<string, any>> e
|
|
|
396
404
|
}
|
|
397
405
|
|
|
398
406
|
handleFocus(e: FocusEvent) {
|
|
407
|
+
// If you get the focus through the tab key, you need to manually bind keyboard events
|
|
408
|
+
// Then you can open the panel by pressing the enter key
|
|
409
|
+
this.bindKeyBoardEvent();
|
|
399
410
|
this._adapter.notifyFocus(e);
|
|
400
411
|
}
|
|
401
412
|
|
package/avatar/avatar.scss
CHANGED
|
@@ -16,6 +16,20 @@ $colors: "amber", "blue", "cyan", "green", "grey", "indigo", "light-blue", "ligh
|
|
|
16
16
|
text-align: center;
|
|
17
17
|
vertical-align: middle;
|
|
18
18
|
|
|
19
|
+
&:focus-visible {
|
|
20
|
+
outline: $width-avatar-outline solid $color-avatar-outline-focus;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&-focus {
|
|
24
|
+
outline: $width-avatar-outline solid $color-avatar-outline-focus;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&-no-focus-visible {
|
|
28
|
+
&:focus-visible {
|
|
29
|
+
outline: none;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
19
33
|
.#{$module}-label {
|
|
20
34
|
display: flex;
|
|
21
35
|
align-items: center;
|
package/avatar/foundation.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import BaseFoundation, { DefaultAdapter } from '../base/foundation';
|
|
2
|
+
import warning from '../utils/warning';
|
|
2
3
|
|
|
3
4
|
export interface AvatarAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
|
|
4
5
|
notifyImgState(isImgExist: boolean): void;
|
|
5
6
|
notifyLeave(event: any): void;
|
|
6
7
|
notifyEnter(event: any): void;
|
|
8
|
+
setFocusVisible: (focusVisible: boolean) => void;
|
|
7
9
|
}
|
|
8
10
|
|
|
9
11
|
export default class AvatarFoundation<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<AvatarAdapter<P, S>, P, S> {
|
|
@@ -32,4 +34,19 @@ export default class AvatarFoundation<P = Record<string, any>, S = Record<string
|
|
|
32
34
|
this._adapter.notifyLeave(e);
|
|
33
35
|
}
|
|
34
36
|
|
|
37
|
+
handleFocusVisible = (event: any) => {
|
|
38
|
+
const { target } = event;
|
|
39
|
+
try {
|
|
40
|
+
if (target.matches(':focus-visible')) {
|
|
41
|
+
this._adapter.setFocusVisible(true);
|
|
42
|
+
}
|
|
43
|
+
} catch (error){
|
|
44
|
+
warning(true, 'Warning: [Semi Avatar] The current browser does not support the focus-visible');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
handleBlur = () => {
|
|
49
|
+
this._adapter.setFocusVisible(false);
|
|
50
|
+
}
|
|
51
|
+
|
|
35
52
|
}
|
package/avatar/variables.scss
CHANGED
|
@@ -2,6 +2,7 @@ $z-avatar-default: 100; // 头像 z-index
|
|
|
2
2
|
// color
|
|
3
3
|
$color-avatar_default-border-default: var(--semi-color-bg-1); // 头像描边颜色
|
|
4
4
|
$color-avatar_more_default-bg-default: rgba(var(--semi-grey-5), 1); // 「更多」描边颜色
|
|
5
|
+
$color-avatar-outline-focus: var(--semi-color-primary-light-active); // 头像聚焦轮廓颜色
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
$width-avatar_extra_extra_small: 20px; // 头像尺寸 - 极小
|
|
@@ -43,3 +44,5 @@ $spacing-avatar_extra_small-marginLeft: -10px; // 头像左侧外边距 - 超小
|
|
|
43
44
|
|
|
44
45
|
$width-avatar_extra_extra_small-border: 1px; // 头像描边尺寸 - 极小
|
|
45
46
|
$spacing-avatar_extra_extra_small-marginLeft: -4px; // 头像左侧外边距 - 极小
|
|
47
|
+
|
|
48
|
+
$width-avatar-outline: 2px; //头像聚焦轮廓宽度
|
package/base/foundation.ts
CHANGED
|
@@ -25,6 +25,7 @@ export interface DefaultAdapter<P = Record<string, any>, S = Record<string, any>
|
|
|
25
25
|
|
|
26
26
|
class BaseFoundation<T extends Partial<DefaultAdapter<P, S>>, P = Record<string, any>, S = Record<string, any>> {
|
|
27
27
|
/** @return enum{css className} */
|
|
28
|
+
/* istanbul ignore next */
|
|
28
29
|
static get cssClasses() {
|
|
29
30
|
// Classes extending Foundation should implement this method to return an object which exports every
|
|
30
31
|
// CSS class the foundation class needs as a property. e.g. {ACTIVE: 'component--active'}
|
|
@@ -32,6 +33,7 @@ class BaseFoundation<T extends Partial<DefaultAdapter<P, S>>, P = Record<string,
|
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
/** @return enum{strings} */
|
|
36
|
+
/* istanbul ignore next */
|
|
35
37
|
static get strings() {
|
|
36
38
|
// Classes extending Foundation should implement this method to return an object which exports all
|
|
37
39
|
// semantic strings as constants. e.g. {ARIA_ROLE: 'tablist'}
|
|
@@ -39,6 +41,7 @@ class BaseFoundation<T extends Partial<DefaultAdapter<P, S>>, P = Record<string,
|
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
/** @return enum{numbers} */
|
|
44
|
+
/* istanbul ignore next */
|
|
42
45
|
static get numbers() {
|
|
43
46
|
// Classes extending Foundation should implement this method to return an object which exports all
|
|
44
47
|
// of its semantic numbers as constants. e.g. {ANIMATION_DELAY_MS: 350}
|
|
@@ -91,10 +94,12 @@ class BaseFoundation<T extends Partial<DefaultAdapter<P, S>>, P = Record<string,
|
|
|
91
94
|
return this._adapter.getContext(key);
|
|
92
95
|
}
|
|
93
96
|
|
|
97
|
+
/* istanbul ignore next */
|
|
94
98
|
getContexts() {
|
|
95
99
|
return this._adapter.getContexts();
|
|
96
100
|
}
|
|
97
101
|
|
|
102
|
+
/* istanbul ignore next */
|
|
98
103
|
getCaches() {
|
|
99
104
|
return this._adapter.getCaches();
|
|
100
105
|
}
|
|
@@ -132,6 +137,7 @@ class BaseFoundation<T extends Partial<DefaultAdapter<P, S>>, P = Record<string,
|
|
|
132
137
|
// Subclasses should override this method to perform de-initialization routines (de-registering events, etc.)
|
|
133
138
|
}
|
|
134
139
|
|
|
140
|
+
/* istanbul ignore next */
|
|
135
141
|
log(text: string, ...rest: any) {
|
|
136
142
|
log(text, ...rest);
|
|
137
143
|
}
|
package/calendar/foundation.ts
CHANGED
package/cascader/cascader.scss
CHANGED
package/cascader/foundation.ts
CHANGED
|
@@ -606,6 +606,7 @@ export default class CascaderFoundation extends BaseFoundation<CascaderAdapter,
|
|
|
606
606
|
/**
|
|
607
607
|
* A11y: simulate selection click
|
|
608
608
|
*/
|
|
609
|
+
/* istanbul ignore next */
|
|
609
610
|
handleSelectionEnterPress(keyboardEvent: any) {
|
|
610
611
|
if (isEnterPress(keyboardEvent)) {
|
|
611
612
|
this.handleClick(keyboardEvent);
|
|
@@ -924,6 +925,7 @@ export default class CascaderFoundation extends BaseFoundation<CascaderAdapter,
|
|
|
924
925
|
/**
|
|
925
926
|
* A11y: simulate clear button click
|
|
926
927
|
*/
|
|
928
|
+
/* istanbul ignore next */
|
|
927
929
|
handleClearEnterPress(keyboardEvent: any) {
|
|
928
930
|
if (isEnterPress(keyboardEvent)) {
|
|
929
931
|
this.handleClear();
|
|
@@ -976,6 +978,7 @@ export default class CascaderFoundation extends BaseFoundation<CascaderAdapter,
|
|
|
976
978
|
const { keyEntities } = this.getStates();
|
|
977
979
|
const { disabled } = this.getProps();
|
|
978
980
|
if (disabled) {
|
|
981
|
+
/* istanbul ignore next */
|
|
979
982
|
return;
|
|
980
983
|
}
|
|
981
984
|
const removedItem = (Object.values(keyEntities) as BasicEntity[])
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import BaseFoundation, { DefaultAdapter, noopFunction } from '../base/foundation';
|
|
2
2
|
import isEnterPress from '../utils/isEnterPress';
|
|
3
|
+
import warning from '../utils/warning';
|
|
3
4
|
|
|
4
5
|
export interface BasicTargetObject {
|
|
5
6
|
[x: string]: any;
|
|
@@ -139,7 +140,7 @@ class CheckboxFoundation<P = Record<string, any>, S = Record<string, any>> exten
|
|
|
139
140
|
this._adapter.setFocusVisible(true);
|
|
140
141
|
}
|
|
141
142
|
} catch (error){
|
|
142
|
-
|
|
143
|
+
warning(true, 'Warning: [Semi Checkbox] The current browser does not support the focus-visible');
|
|
143
144
|
}
|
|
144
145
|
}
|
|
145
146
|
|
package/datePicker/foundation.ts
CHANGED
|
@@ -125,12 +125,12 @@ export interface DatePickerFoundationProps extends ElementProps, RenderProps, Ev
|
|
|
125
125
|
disabledDate?: DisabledDateType;
|
|
126
126
|
disabledTime?: DisabledTimeType;
|
|
127
127
|
dropdownClassName?: string;
|
|
128
|
-
dropdownStyle?:
|
|
128
|
+
dropdownStyle?: Record<string, any>;
|
|
129
129
|
endDateOffset?: DateOffsetType;
|
|
130
130
|
format?: string;
|
|
131
131
|
getPopupContainer?: () => HTMLElement;
|
|
132
132
|
inputReadOnly?: boolean;
|
|
133
|
-
inputStyle?:
|
|
133
|
+
inputStyle?: Record<string, any>;
|
|
134
134
|
max?: number;
|
|
135
135
|
motion?: Motion;
|
|
136
136
|
multiple?: boolean;
|
|
@@ -146,7 +146,7 @@ export interface DatePickerFoundationProps extends ElementProps, RenderProps, Ev
|
|
|
146
146
|
spacing?: number;
|
|
147
147
|
startDateOffset?: DateOffsetType;
|
|
148
148
|
stopPropagation?: boolean | string;
|
|
149
|
-
style?:
|
|
149
|
+
style?: Record<string, any>;
|
|
150
150
|
timePickerOpts?: any; // TODO import timePicker props
|
|
151
151
|
timeZone?: string | number;
|
|
152
152
|
type?: Type;
|
|
@@ -45,7 +45,7 @@ export interface DateInputFoundationProps extends DateInputElementProps, DateInp
|
|
|
45
45
|
type?: Type;
|
|
46
46
|
showClear?: boolean;
|
|
47
47
|
format?: string;
|
|
48
|
-
inputStyle?:
|
|
48
|
+
inputStyle?: Record<string, any>;
|
|
49
49
|
inputReadOnly?: boolean;
|
|
50
50
|
validateStatus?: ValidateStatus;
|
|
51
51
|
prefixCls?: string;
|
|
@@ -40,10 +40,14 @@ const dateCalcFns = {
|
|
|
40
40
|
type Type = ArrayElement<typeof strings.TYPE_SET>;
|
|
41
41
|
|
|
42
42
|
interface MonthsGridElementProps {
|
|
43
|
-
navPrev?: React.ReactNode;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
// navPrev?: React.ReactNode;
|
|
44
|
+
navPrev?: any;
|
|
45
|
+
// navNext?: React.ReactNode;
|
|
46
|
+
navNext?: any;
|
|
47
|
+
// renderDate?: () => React.ReactNode;
|
|
48
|
+
renderDate?: () => any;
|
|
49
|
+
// renderFullDate?: () => React.ReactNode;
|
|
50
|
+
renderFullDate?: () => any;
|
|
47
51
|
}
|
|
48
52
|
|
|
49
53
|
export type PanelType = 'left' | 'right';
|
package/form/utils.ts
CHANGED
|
@@ -5,7 +5,11 @@ import AsyncValidator from 'async-validator';
|
|
|
5
5
|
import { cloneDeep, toPath } from 'lodash';
|
|
6
6
|
import { FieldValidateTriggerType, BasicTriggerType, ComponentProps, WithFieldOption } from './interface';
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @param WrappedComponent React.ComponentType | any
|
|
11
|
+
*/
|
|
12
|
+
export function getDisplayName(WrappedComponent: any) {
|
|
9
13
|
const originName = WrappedComponent.displayName || WrappedComponent.name;
|
|
10
14
|
return originName ? `SemiField${originName}` : 'SemiField';
|
|
11
15
|
}
|
package/input/foundation.ts
CHANGED
|
@@ -2,7 +2,6 @@ import BaseFoundation, { DefaultAdapter, noopFunction } from '../base/foundation
|
|
|
2
2
|
import { strings } from './constants';
|
|
3
3
|
import { noop, set, isNumber, isString, isFunction } from 'lodash';
|
|
4
4
|
|
|
5
|
-
import isEnterPress from '../utils/isEnterPress';
|
|
6
5
|
import { ENTER_KEY } from './../utils/keyCode';
|
|
7
6
|
|
|
8
7
|
export interface InputDefaultAdapter {
|
|
@@ -296,20 +295,13 @@ class InputFoundation extends BaseFoundation<InputAdapter> {
|
|
|
296
295
|
}
|
|
297
296
|
}
|
|
298
297
|
|
|
299
|
-
/**
|
|
300
|
-
* A11y: simulate clear button click
|
|
301
|
-
*/
|
|
302
|
-
handleClearEnterPress(e: any) {
|
|
303
|
-
if (isEnterPress(e)) {
|
|
304
|
-
this.handleClear(e);
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
|
|
308
298
|
/**
|
|
309
299
|
* A11y: simulate password button click
|
|
310
300
|
*/
|
|
311
301
|
handleModeEnterPress(e: any) {
|
|
312
|
-
|
|
302
|
+
// trigger by Enter or Space key
|
|
303
|
+
if (['Enter', ' '].includes(e?.key)) {
|
|
304
|
+
this.handlePreventMouseDown(e);
|
|
313
305
|
this.handleClickEye(e);
|
|
314
306
|
}
|
|
315
307
|
}
|
package/input/input.scss
CHANGED
|
@@ -173,6 +173,12 @@ $module: #{$prefix}-input;
|
|
|
173
173
|
color: $color-input-icon-hover;
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
|
+
|
|
177
|
+
&:focus-visible {
|
|
178
|
+
border-radius: $radius-input_wrapper;
|
|
179
|
+
outline: $width-input_icon-outline solid $color-input_icon-outline;
|
|
180
|
+
outline-offset: $width-input_icon-outlineOffset;
|
|
181
|
+
}
|
|
176
182
|
}
|
|
177
183
|
|
|
178
184
|
&__with-suffix-icon.#{$module}-wrapper-clearable:not(.#{$module}-wrapper__with-suffix-hidden) {
|
|
@@ -233,13 +233,4 @@ export default class TextAreaFoundation extends BaseFoundation<TextAreaAdapter>
|
|
|
233
233
|
this._adapter.notifyClear(e);
|
|
234
234
|
this.stopPropagation(e);
|
|
235
235
|
}
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* A11y: simulate clear button click
|
|
239
|
-
*/
|
|
240
|
-
handleClearEnterPress(e: any) {
|
|
241
|
-
if (isEnterPress(e)) {
|
|
242
|
-
this.handleClear(e);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
236
|
}
|
package/input/variables.scss
CHANGED
|
@@ -11,6 +11,7 @@ $color-input_default-border-active: $color-input_default-bg-active; // 输入框
|
|
|
11
11
|
|
|
12
12
|
$color-input_default-bg-focus: var(--semi-color-fill-0); // 输入框背景颜色 - 选中
|
|
13
13
|
$color-input_default-border-focus: var(--semi-color-focus-border); // 输入框描边颜色 - 选中
|
|
14
|
+
$color-input_icon-outline: var(--semi-color-primary-light-active); // 输入框 icon outline 颜色
|
|
14
15
|
|
|
15
16
|
// error
|
|
16
17
|
$color-input_danger-bg-default: var(--semi-color-danger-light-default); // 错误输入框背景颜色 - 默认
|
|
@@ -75,6 +76,8 @@ $width-input_prepend-border: $border-thickness-control; // 前置标签描边宽
|
|
|
75
76
|
$width-input_group_pseudo-border: $border-thickness-control;
|
|
76
77
|
$width-input_wrapper-border: $border-thickness-control-focus; // 输入框描边宽度
|
|
77
78
|
$width-input_wrapper_focus-border: $border-thickness-control-focus; // 输入框描边宽度 - 选中态
|
|
79
|
+
$width-input_icon-outline: 2px; // 输入框 icon outline 宽度
|
|
80
|
+
$width-input_icon-outlineOffset: -1px; // 输入框 icon outline-offset 宽度
|
|
78
81
|
|
|
79
82
|
$radius-input_wrapper: var(--semi-border-radius-small); // 输入框圆角大小
|
|
80
83
|
$spacing-input_icon-marginLeft: -$spacing-base-tight; // 输入框图标左侧内边距
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import BaseFoundation, { DefaultAdapter } from '../base/foundation';
|
|
2
|
-
import React from 'react';
|
|
3
2
|
export interface AnchorAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
|
|
4
3
|
addLink: (link: string) => void;
|
|
5
4
|
removeLink: (link: string) => void;
|
|
@@ -15,7 +14,7 @@ export interface AnchorAdapter<P = Record<string, any>, S = Record<string, any>>
|
|
|
15
14
|
getAnchorNode: (selector: string) => HTMLElement;
|
|
16
15
|
getContentNode: (selector: string) => HTMLElement;
|
|
17
16
|
notifyChange: (currentLink: string, previousLink: string) => void;
|
|
18
|
-
notifyClick: (e:
|
|
17
|
+
notifyClick: (e: any, link: string) => void;
|
|
19
18
|
canSmoothScroll: () => boolean;
|
|
20
19
|
}
|
|
21
20
|
export default class AnchorFoundation<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<AnchorAdapter<P, S>, P, S> {
|
|
@@ -53,7 +53,6 @@ declare class AutoCompleteFoundation<P = Record<string, any>, S = Record<string,
|
|
|
53
53
|
_getRenderSelectedItem(): any;
|
|
54
54
|
handleClear(): void;
|
|
55
55
|
bindKeyBoardEvent(): void;
|
|
56
|
-
unBindKeyBoardEvent(): void;
|
|
57
56
|
_handleKeyDown(event: KeyboardEvent): void;
|
|
58
57
|
_getEnableFocusIndex(offset: number): void;
|
|
59
58
|
_handleArrowKeyDown(offset: number): void;
|
|
@@ -81,9 +81,8 @@ class AutoCompleteFoundation extends _foundation.default {
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
destroy() {
|
|
85
|
-
// this.
|
|
86
|
-
this.unBindKeyBoardEvent();
|
|
84
|
+
destroy() {// this._adapter.unregisterClickOutsideHandler();
|
|
85
|
+
// this.unBindKeyBoardEvent();
|
|
87
86
|
}
|
|
88
87
|
|
|
89
88
|
_setDropdownWidth() {
|
|
@@ -135,8 +134,6 @@ class AutoCompleteFoundation extends _foundation.default {
|
|
|
135
134
|
|
|
136
135
|
this._adapter.notifyDropdownVisibleChange(true);
|
|
137
136
|
|
|
138
|
-
this.bindKeyBoardEvent();
|
|
139
|
-
|
|
140
137
|
this._modifyFocusIndexOnPanelOpen();
|
|
141
138
|
}
|
|
142
139
|
|
|
@@ -146,9 +143,9 @@ class AutoCompleteFoundation extends _foundation.default {
|
|
|
146
143
|
this._adapter.toggleListVisible(false); // this._adapter.unregisterClickOutsideHandler();
|
|
147
144
|
|
|
148
145
|
|
|
149
|
-
this._adapter.notifyDropdownVisibleChange(false);
|
|
146
|
+
this._adapter.notifyDropdownVisibleChange(false); // After closing the panel, you can still open the panel by pressing the enter key
|
|
147
|
+
// this.unBindKeyBoardEvent();
|
|
150
148
|
|
|
151
|
-
this.unBindKeyBoardEvent();
|
|
152
149
|
} // props.data => optionList
|
|
153
150
|
|
|
154
151
|
|
|
@@ -368,13 +365,12 @@ class AutoCompleteFoundation extends _foundation.default {
|
|
|
368
365
|
};
|
|
369
366
|
|
|
370
367
|
this._adapter.registerKeyDown(this._keydownHandler);
|
|
371
|
-
}
|
|
368
|
+
} // unBindKeyBoardEvent() {
|
|
369
|
+
// if (this._keydownHandler) {
|
|
370
|
+
// this._adapter.unregisterKeyDown(this._keydownHandler);
|
|
371
|
+
// }
|
|
372
|
+
// }
|
|
372
373
|
|
|
373
|
-
unBindKeyBoardEvent() {
|
|
374
|
-
if (this._keydownHandler) {
|
|
375
|
-
this._adapter.unregisterKeyDown(this._keydownHandler);
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
374
|
|
|
379
375
|
_handleKeyDown(event) {
|
|
380
376
|
const key = event.keyCode;
|
|
@@ -382,10 +378,6 @@ class AutoCompleteFoundation extends _foundation.default {
|
|
|
382
378
|
visible
|
|
383
379
|
} = this.getStates();
|
|
384
380
|
|
|
385
|
-
if (!visible) {
|
|
386
|
-
return;
|
|
387
|
-
}
|
|
388
|
-
|
|
389
381
|
switch (key) {
|
|
390
382
|
case _keyCode.default.UP:
|
|
391
383
|
// Prevent Input's cursor from following the movement
|
|
@@ -404,6 +396,9 @@ class AutoCompleteFoundation extends _foundation.default {
|
|
|
404
396
|
break;
|
|
405
397
|
|
|
406
398
|
case _keyCode.default.ENTER:
|
|
399
|
+
// when custom trigger, prevent outer open panel again
|
|
400
|
+
event.preventDefault();
|
|
401
|
+
|
|
407
402
|
this._handleEnterKeyDown();
|
|
408
403
|
|
|
409
404
|
break;
|
|
@@ -473,7 +468,15 @@ class AutoCompleteFoundation extends _foundation.default {
|
|
|
473
468
|
}
|
|
474
469
|
|
|
475
470
|
_handleArrowKeyDown(offset) {
|
|
476
|
-
|
|
471
|
+
const {
|
|
472
|
+
visible
|
|
473
|
+
} = this.getStates();
|
|
474
|
+
|
|
475
|
+
if (!visible) {
|
|
476
|
+
this.openDropdown();
|
|
477
|
+
} else {
|
|
478
|
+
this._getEnableFocusIndex(offset);
|
|
479
|
+
}
|
|
477
480
|
}
|
|
478
481
|
|
|
479
482
|
_handleEnterKeyDown() {
|
|
@@ -483,11 +486,16 @@ class AutoCompleteFoundation extends _foundation.default {
|
|
|
483
486
|
focusIndex
|
|
484
487
|
} = this.getStates();
|
|
485
488
|
|
|
486
|
-
if (
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
489
|
+
if (!visible) {
|
|
490
|
+
this.openDropdown();
|
|
491
|
+
} else {
|
|
492
|
+
if (focusIndex !== undefined && focusIndex !== -1 && options.length !== 0) {
|
|
493
|
+
const visibleOptions = (0, _filter.default)(options).call(options, item => item.show);
|
|
494
|
+
const selectedOption = visibleOptions[focusIndex];
|
|
495
|
+
this.handleSelect(selectedOption, focusIndex);
|
|
496
|
+
} else {
|
|
497
|
+
this.closeDropdown();
|
|
498
|
+
}
|
|
491
499
|
}
|
|
492
500
|
}
|
|
493
501
|
|
|
@@ -496,6 +504,10 @@ class AutoCompleteFoundation extends _foundation.default {
|
|
|
496
504
|
}
|
|
497
505
|
|
|
498
506
|
handleFocus(e) {
|
|
507
|
+
// If you get the focus through the tab key, you need to manually bind keyboard events
|
|
508
|
+
// Then you can open the panel by pressing the enter key
|
|
509
|
+
this.bindKeyBoardEvent();
|
|
510
|
+
|
|
499
511
|
this._adapter.notifyFocus(e);
|
|
500
512
|
}
|
|
501
513
|
|
|
@@ -11,6 +11,15 @@
|
|
|
11
11
|
text-align: center;
|
|
12
12
|
vertical-align: middle;
|
|
13
13
|
}
|
|
14
|
+
.semi-avatar:focus-visible {
|
|
15
|
+
outline: 2px solid var(--semi-color-primary-light-active);
|
|
16
|
+
}
|
|
17
|
+
.semi-avatar-focus {
|
|
18
|
+
outline: 2px solid var(--semi-color-primary-light-active);
|
|
19
|
+
}
|
|
20
|
+
.semi-avatar-no-focus-visible:focus-visible {
|
|
21
|
+
outline: none;
|
|
22
|
+
}
|
|
14
23
|
.semi-avatar .semi-avatar-label {
|
|
15
24
|
display: flex;
|
|
16
25
|
align-items: center;
|
|
@@ -16,6 +16,20 @@ $colors: "amber", "blue", "cyan", "green", "grey", "indigo", "light-blue", "ligh
|
|
|
16
16
|
text-align: center;
|
|
17
17
|
vertical-align: middle;
|
|
18
18
|
|
|
19
|
+
&:focus-visible {
|
|
20
|
+
outline: $width-avatar-outline solid $color-avatar-outline-focus;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&-focus {
|
|
24
|
+
outline: $width-avatar-outline solid $color-avatar-outline-focus;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&-no-focus-visible {
|
|
28
|
+
&:focus-visible {
|
|
29
|
+
outline: none;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
19
33
|
.#{$module}-label {
|
|
20
34
|
display: flex;
|
|
21
35
|
align-items: center;
|
|
@@ -3,6 +3,7 @@ export interface AvatarAdapter<P = Record<string, any>, S = Record<string, any>>
|
|
|
3
3
|
notifyImgState(isImgExist: boolean): void;
|
|
4
4
|
notifyLeave(event: any): void;
|
|
5
5
|
notifyEnter(event: any): void;
|
|
6
|
+
setFocusVisible: (focusVisible: boolean) => void;
|
|
6
7
|
}
|
|
7
8
|
export default class AvatarFoundation<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<AvatarAdapter<P, S>, P, S> {
|
|
8
9
|
constructor(adapter: AvatarAdapter<P, S>);
|
|
@@ -11,4 +12,6 @@ export default class AvatarFoundation<P = Record<string, any>, S = Record<string
|
|
|
11
12
|
handleImgLoadError(): void;
|
|
12
13
|
handleEnter(e: any): void;
|
|
13
14
|
handleLeave(e: any): void;
|
|
15
|
+
handleFocusVisible: (event: any) => void;
|
|
16
|
+
handleBlur: () => void;
|
|
14
17
|
}
|