@douyinfe/semi-foundation 2.41.0 → 2.41.2
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/carousel/foundation.ts +6 -7
- package/dropdown/menuFoundation.ts +3 -3
- package/image/previewFoundation.ts +1 -1
- package/lib/cjs/slider/foundation.d.ts +1 -0
- package/lib/es/slider/foundation.d.ts +1 -0
- package/modal/modalContentFoundation.ts +3 -3
- package/package.json +3 -3
- package/sideSheet/sideSheetFoundation.ts +2 -2
- package/slider/foundation.ts +1 -0
- package/tabs/foundation.ts +2 -2
- package/utils/a11y.ts +6 -6
package/carousel/foundation.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { isObject, get } from 'lodash';
|
|
2
2
|
import BaseFoundation, { DefaultAdapter } from '../base/foundation';
|
|
3
3
|
import { numbers } from './constants';
|
|
4
|
-
import { throttle } from 'lodash';
|
|
5
4
|
|
|
6
5
|
export interface CarouselAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
|
|
7
6
|
notifyChange: (activeIndex: number, preIndex: number) => void;
|
|
@@ -34,7 +33,7 @@ class CarouselFoundation<P = Record<string, any>, S = Record<string, any>> exten
|
|
|
34
33
|
}
|
|
35
34
|
|
|
36
35
|
stop(): void {
|
|
37
|
-
if (this._interval){
|
|
36
|
+
if (this._interval) {
|
|
38
37
|
clearInterval(this._interval);
|
|
39
38
|
}
|
|
40
39
|
}
|
|
@@ -93,7 +92,7 @@ class CarouselFoundation<P = Record<string, any>, S = Record<string, any>> exten
|
|
|
93
92
|
|
|
94
93
|
_notifyChange(activeIndex: number): void {
|
|
95
94
|
const { activeIndex: stateActiveIndex, isInit } = this.getStates();
|
|
96
|
-
if (isInit){
|
|
95
|
+
if (isInit) {
|
|
97
96
|
this._adapter.setIsInit(false);
|
|
98
97
|
}
|
|
99
98
|
if (stateActiveIndex !== activeIndex) {
|
|
@@ -110,10 +109,10 @@ class CarouselFoundation<P = Record<string, any>, S = Record<string, any>> exten
|
|
|
110
109
|
getSwitchingTime(): number {
|
|
111
110
|
const { autoPlay, speed } = this.getProps();
|
|
112
111
|
const autoPlayType = typeof autoPlay;
|
|
113
|
-
if (autoPlayType === 'boolean'){
|
|
112
|
+
if (autoPlayType === 'boolean') {
|
|
114
113
|
return numbers.DEFAULT_INTERVAL + speed;
|
|
115
114
|
}
|
|
116
|
-
if (isObject(autoPlay)){
|
|
115
|
+
if (isObject(autoPlay)) {
|
|
117
116
|
return get(autoPlay, 'interval', numbers.DEFAULT_INTERVAL) + speed;
|
|
118
117
|
}
|
|
119
118
|
return speed;
|
|
@@ -127,12 +126,12 @@ class CarouselFoundation<P = Record<string, any>, S = Record<string, any>> exten
|
|
|
127
126
|
const { autoPlay } = this.getProps();
|
|
128
127
|
const autoPlayType = typeof autoPlay;
|
|
129
128
|
// when user manually call the play function, force play
|
|
130
|
-
if ((autoPlayType === 'boolean' && autoPlay) || isObject(autoPlay) || this._forcePlay){
|
|
129
|
+
if ((autoPlayType === 'boolean' && autoPlay) || isObject(autoPlay) || this._forcePlay) {
|
|
131
130
|
this.play(this.getSwitchingTime());
|
|
132
131
|
}
|
|
133
132
|
}
|
|
134
133
|
|
|
135
|
-
handleKeyDown(event: any): void{
|
|
134
|
+
handleKeyDown(event: any): void {
|
|
136
135
|
if (event.key === 'ArrowLeft') {
|
|
137
136
|
this.prev();
|
|
138
137
|
}
|
|
@@ -8,7 +8,7 @@ export default class DropdownMenuFoundation extends BaseFoundation<Partial<Defau
|
|
|
8
8
|
|
|
9
9
|
handleEscape(menu: Element): void {
|
|
10
10
|
const trigger = this._adapter.getContext('trigger');
|
|
11
|
-
if (trigger === 'custom'){
|
|
11
|
+
if (trigger === 'custom') {
|
|
12
12
|
const menuButton = menu && getMenuButton(document.querySelectorAll(`[data-popupid]`), menu.id);
|
|
13
13
|
menuButton.focus();
|
|
14
14
|
}
|
|
@@ -25,11 +25,11 @@ export default class DropdownMenuFoundation extends BaseFoundation<Partial<Defau
|
|
|
25
25
|
onMenuKeydown(event: any): void {
|
|
26
26
|
const menu = getAncestorNodeByRole(event.target, 'tooltip');
|
|
27
27
|
|
|
28
|
-
if (!this.menuItemNodes){
|
|
28
|
+
if (!this.menuItemNodes) {
|
|
29
29
|
this.menuItemNodes = [...(event.target.parentNode).getElementsByTagName('li')].filter(item => item.ariaDisabled !== "true");
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
if (this.firstChars.length === 0){
|
|
32
|
+
if (this.firstChars.length === 0) {
|
|
33
33
|
this.menuItemNodes.forEach((item: Element) => {
|
|
34
34
|
// the menuItemNodes can be an component and not exit textContent
|
|
35
35
|
this.firstChars.push(item.textContent.trim()[0]?.toLowerCase());
|
|
@@ -2,7 +2,7 @@ import BaseFoundation, { DefaultAdapter } from "../base/foundation";
|
|
|
2
2
|
|
|
3
3
|
export default class PreviewFoundation<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<Partial<DefaultAdapter>> {
|
|
4
4
|
|
|
5
|
-
handleVisibleChange = (newVisible
|
|
5
|
+
handleVisibleChange = (newVisible: boolean) => {
|
|
6
6
|
const { visible, onVisibleChange } = this.getProps();
|
|
7
7
|
if (!(visible in this.getProps())) {
|
|
8
8
|
this.setState({
|
|
@@ -17,6 +17,7 @@ export interface SliderProps {
|
|
|
17
17
|
vertical?: boolean;
|
|
18
18
|
onAfterChange?: (value: SliderProps['value']) => void;
|
|
19
19
|
onChange?: (value: SliderProps['value']) => void;
|
|
20
|
+
onMouseUp?: (e: any) => void;
|
|
20
21
|
tooltipVisible?: boolean;
|
|
21
22
|
style?: Record<string, any>;
|
|
22
23
|
className?: string;
|
|
@@ -17,6 +17,7 @@ export interface SliderProps {
|
|
|
17
17
|
vertical?: boolean;
|
|
18
18
|
onAfterChange?: (value: SliderProps['value']) => void;
|
|
19
19
|
onChange?: (value: SliderProps['value']) => void;
|
|
20
|
+
onMouseUp?: (e: any) => void;
|
|
20
21
|
tooltipVisible?: boolean;
|
|
21
22
|
style?: Record<string, any>;
|
|
22
23
|
className?: string;
|
|
@@ -8,9 +8,9 @@ export interface ModalContentProps extends ModalProps {
|
|
|
8
8
|
isFullScreen?: boolean;
|
|
9
9
|
contentClassName?: string;
|
|
10
10
|
maskClassName?: string;
|
|
11
|
-
onAnimationEnd?: (e:any) => void;
|
|
12
|
-
maskExtraProps?:Record<string, any>;
|
|
13
|
-
contentExtraProps?:Record<string, any>
|
|
11
|
+
onAnimationEnd?: (e: any) => void;
|
|
12
|
+
maskExtraProps?: Record<string, any>;
|
|
13
|
+
contentExtraProps?: Record<string, any>
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export interface ModalContentState {
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-foundation",
|
|
3
|
-
"version": "2.41.
|
|
3
|
+
"version": "2.41.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build:lib": "node ./scripts/compileLib.js",
|
|
7
7
|
"prepublishOnly": "npm run build:lib"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@douyinfe/semi-animation": "2.41.
|
|
10
|
+
"@douyinfe/semi-animation": "2.41.2",
|
|
11
11
|
"async-validator": "^3.5.0",
|
|
12
12
|
"classnames": "^2.2.6",
|
|
13
13
|
"date-fns": "^2.29.3",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"*.scss",
|
|
24
24
|
"*.css"
|
|
25
25
|
],
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "63e24c001dfdb899bd705e60e56f08e1cb66929b",
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@babel/plugin-transform-runtime": "^7.15.8",
|
|
29
29
|
"@babel/preset-env": "^7.15.8",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import BaseFoundation, { DefaultAdapter } from '../base/foundation';
|
|
2
|
-
import {
|
|
2
|
+
import { noop } from 'lodash';
|
|
3
3
|
import KeyCode from '../utils/keyCode';
|
|
4
4
|
|
|
5
5
|
|
|
@@ -95,7 +95,7 @@ export default class SideSheetFoundation extends BaseFoundation<SideSheetAdapter
|
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
|
|
98
|
-
toggleDisplayNone = (displayNone:boolean)=>{
|
|
98
|
+
toggleDisplayNone = (displayNone: boolean)=>{
|
|
99
99
|
this._adapter.toggleDisplayNone(displayNone);
|
|
100
100
|
}
|
|
101
101
|
|
package/slider/foundation.ts
CHANGED
|
@@ -23,6 +23,7 @@ export interface SliderProps{
|
|
|
23
23
|
vertical?: boolean;
|
|
24
24
|
onAfterChange?: (value: SliderProps['value']) => void; // triggered when mouse up and clicked
|
|
25
25
|
onChange?: (value: SliderProps['value']) => void;
|
|
26
|
+
onMouseUp?: (e: any) => void;
|
|
26
27
|
tooltipVisible?: boolean;
|
|
27
28
|
style?: Record<string, any>;
|
|
28
29
|
className?: string;
|
package/tabs/foundation.ts
CHANGED
|
@@ -128,14 +128,14 @@ class TabsFoundation<P = Record<string, any>, S = Record<string, any>> extends B
|
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
handleDeleteKeyDown(event:any, tabs: HTMLElement[], itemKey: string, closable: boolean): void {
|
|
131
|
+
handleDeleteKeyDown(event: any, tabs: HTMLElement[], itemKey: string, closable: boolean): void {
|
|
132
132
|
const { preventScroll } = this.getProps();
|
|
133
133
|
if (closable) {
|
|
134
134
|
this.handleTabDelete(itemKey);
|
|
135
135
|
const index = tabs.indexOf(event.target);
|
|
136
136
|
// Move focus to next element after deletion
|
|
137
137
|
// If the element is the last removable tab, focus to its previous tab
|
|
138
|
-
if (tabs.length !== 1 ){
|
|
138
|
+
if (tabs.length !== 1 ) {
|
|
139
139
|
tabs[index + 1 >= tabs.length ? index - 1 : index + 1].focus({ preventScroll });
|
|
140
140
|
}
|
|
141
141
|
}
|
package/utils/a11y.ts
CHANGED
|
@@ -35,7 +35,7 @@ export function setFocusToLastItem(itemNodes: HTMLElement[]): void {
|
|
|
35
35
|
export function setFocusToPreviousMenuItem (itemNodes: HTMLElement[], currentItem: HTMLElement): void {
|
|
36
36
|
let newMenuItem: HTMLElement, index: number;
|
|
37
37
|
|
|
38
|
-
if (itemNodes.length > 0){
|
|
38
|
+
if (itemNodes.length > 0) {
|
|
39
39
|
if (currentItem === itemNodes[0]) {
|
|
40
40
|
newMenuItem = itemNodes[itemNodes.length-1];
|
|
41
41
|
} else {
|
|
@@ -50,7 +50,7 @@ export function setFocusToPreviousMenuItem (itemNodes: HTMLElement[], currentIte
|
|
|
50
50
|
export function setFocusToNextMenuitem (itemNodes: HTMLElement[], currentItem: HTMLElement): void {
|
|
51
51
|
let newMenuItem: HTMLElement, index: number;
|
|
52
52
|
|
|
53
|
-
if (itemNodes.length > 0){
|
|
53
|
+
if (itemNodes.length > 0) {
|
|
54
54
|
if (currentItem === itemNodes[itemNodes.length-1]) {
|
|
55
55
|
newMenuItem = itemNodes[0];
|
|
56
56
|
} else {
|
|
@@ -91,17 +91,17 @@ export function getAncestorNodeByRole(curElement: Element, role: string): Elemen
|
|
|
91
91
|
if (!curElement) {
|
|
92
92
|
return null;
|
|
93
93
|
}
|
|
94
|
-
while (curElement.parentElement && get(curElement.parentElement, 'attributes.role.value', '') !== role){
|
|
94
|
+
while (curElement.parentElement && get(curElement.parentElement, 'attributes.role.value', '') !== role) {
|
|
95
95
|
curElement = curElement.parentElement;
|
|
96
96
|
}
|
|
97
97
|
return curElement.parentElement;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
// According to the Id, find the corresponding data-popupid element
|
|
101
|
-
export function getMenuButton(focusableEle: NodeListOf<HTMLElement>, Id: string): HTMLElement{
|
|
102
|
-
for (let i = 0; i < focusableEle.length; i++){
|
|
101
|
+
export function getMenuButton(focusableEle: NodeListOf<HTMLElement>, Id: string): HTMLElement {
|
|
102
|
+
for (let i = 0; i < focusableEle.length; i++) {
|
|
103
103
|
const curAriDescribedby = focusableEle[i].attributes['data-popupid'];
|
|
104
|
-
if (curAriDescribedby && curAriDescribedby.value === Id){
|
|
104
|
+
if (curAriDescribedby && curAriDescribedby.value === Id) {
|
|
105
105
|
return focusableEle[i];
|
|
106
106
|
}
|
|
107
107
|
}
|