@douyinfe/semi-ui 2.9.1 → 2.10.0-beta.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.
- package/banner/_story/banner.stories.js +62 -1
- package/banner/index.tsx +5 -5
- package/carousel/CarouselArrow.tsx +62 -0
- package/carousel/CarouselIndicator.tsx +84 -0
- package/carousel/__test__/carousel.test.js +159 -0
- package/carousel/_story/carousel.stories.js +486 -0
- package/carousel/index.tsx +294 -0
- package/carousel/interface.ts +64 -0
- package/cascader/index.tsx +1 -2
- package/dist/css/semi.css +342 -0
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +884 -66
- package/dist/umd/semi-ui.js.map +1 -1
- package/dist/umd/semi-ui.min.js +1 -1
- package/dist/umd/semi-ui.min.js.map +1 -1
- package/index.ts +2 -0
- package/lib/cjs/banner/index.js +11 -5
- package/lib/cjs/carousel/CarouselArrow.d.ts +8 -0
- package/lib/cjs/carousel/CarouselArrow.js +91 -0
- package/lib/cjs/carousel/CarouselIndicator.d.ts +23 -0
- package/lib/cjs/carousel/CarouselIndicator.js +145 -0
- package/lib/cjs/carousel/index.d.ts +58 -0
- package/lib/cjs/carousel/index.js +345 -0
- package/lib/cjs/carousel/interface.d.ts +62 -0
- package/lib/cjs/carousel/interface.js +7 -0
- package/lib/cjs/cascader/index.js +1 -1
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.js +9 -0
- package/lib/cjs/switch/index.d.ts +3 -0
- package/lib/cjs/switch/index.js +26 -6
- package/lib/es/banner/index.js +11 -5
- package/lib/es/carousel/CarouselArrow.d.ts +8 -0
- package/lib/es/carousel/CarouselArrow.js +72 -0
- package/lib/es/carousel/CarouselIndicator.d.ts +23 -0
- package/lib/es/carousel/CarouselIndicator.js +125 -0
- package/lib/es/carousel/index.d.ts +58 -0
- package/lib/es/carousel/index.js +311 -0
- package/lib/es/carousel/interface.d.ts +62 -0
- package/lib/es/carousel/interface.js +1 -0
- package/lib/es/cascader/index.js +1 -1
- package/lib/es/index.d.ts +1 -0
- package/lib/es/index.js +1 -0
- package/lib/es/switch/index.d.ts +3 -0
- package/lib/es/switch/index.js +26 -6
- package/package.json +9 -9
- package/switch/index.tsx +20 -3
- package/tagInput/__test__/tagInput.test.js +11 -11
package/lib/es/switch/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _noop from "lodash/noop";
|
|
2
2
|
import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
|
|
3
3
|
|
|
4
|
-
/* eslint-disable max-len
|
|
4
|
+
/* eslint-disable max-len */
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import cls from 'classnames';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
@@ -14,9 +14,19 @@ import Spin from '../spin';
|
|
|
14
14
|
class Switch extends BaseComponent {
|
|
15
15
|
constructor(props) {
|
|
16
16
|
super(props);
|
|
17
|
+
|
|
18
|
+
this.handleFocusVisible = event => {
|
|
19
|
+
this.foundation.handleFocusVisible(event);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
this.handleBlur = event => {
|
|
23
|
+
this.foundation.handleBlur();
|
|
24
|
+
};
|
|
25
|
+
|
|
17
26
|
this.state = {
|
|
18
27
|
nativeControlChecked: false,
|
|
19
|
-
nativeControlDisabled: false
|
|
28
|
+
nativeControlDisabled: false,
|
|
29
|
+
focusVisible: false
|
|
20
30
|
};
|
|
21
31
|
this.switchRef = /*#__PURE__*/React.createRef();
|
|
22
32
|
this.foundation = new SwitchFoudation(this.adapter);
|
|
@@ -52,6 +62,11 @@ class Switch extends BaseComponent {
|
|
|
52
62
|
nativeControlDisabled
|
|
53
63
|
});
|
|
54
64
|
},
|
|
65
|
+
setFocusVisible: focusVisible => {
|
|
66
|
+
this.setState({
|
|
67
|
+
focusVisible
|
|
68
|
+
});
|
|
69
|
+
},
|
|
55
70
|
notifyChange: (checked, e) => {
|
|
56
71
|
this.props.onChange(checked, e);
|
|
57
72
|
}
|
|
@@ -61,7 +76,8 @@ class Switch extends BaseComponent {
|
|
|
61
76
|
render() {
|
|
62
77
|
const {
|
|
63
78
|
nativeControlChecked,
|
|
64
|
-
nativeControlDisabled
|
|
79
|
+
nativeControlDisabled,
|
|
80
|
+
focusVisible
|
|
65
81
|
} = this.state;
|
|
66
82
|
const {
|
|
67
83
|
className,
|
|
@@ -80,11 +96,11 @@ class Switch extends BaseComponent {
|
|
|
80
96
|
[cssClasses.DISABLED]: nativeControlDisabled,
|
|
81
97
|
[cssClasses.LARGE]: size === 'large',
|
|
82
98
|
[cssClasses.SMALL]: size === 'small',
|
|
83
|
-
[cssClasses.LOADING]: loading
|
|
99
|
+
[cssClasses.LOADING]: loading,
|
|
100
|
+
[cssClasses.FOCUS]: focusVisible
|
|
84
101
|
});
|
|
85
102
|
const switchProps = {
|
|
86
103
|
type: 'checkbox',
|
|
87
|
-
role: 'switch',
|
|
88
104
|
className: cssClasses.NATIVE_CONTROL,
|
|
89
105
|
disabled: nativeControlDisabled || loading,
|
|
90
106
|
checked: nativeControlChecked || false
|
|
@@ -109,13 +125,17 @@ class Switch extends BaseComponent {
|
|
|
109
125
|
}, uncheckedText) : null, /*#__PURE__*/React.createElement("input", _Object$assign({}, switchProps, {
|
|
110
126
|
ref: this.switchRef,
|
|
111
127
|
id: id,
|
|
128
|
+
role: 'switch',
|
|
112
129
|
"aria-checked": nativeControlChecked,
|
|
113
130
|
"aria-invalid": this.props['aria-invalid'],
|
|
114
131
|
"aria-errormessage": this.props['aria-errormessage'],
|
|
115
132
|
"aria-label": this.props['aria-label'],
|
|
116
133
|
"aria-labelledby": this.props['aria-labelledby'],
|
|
117
134
|
"aria-describedby": this.props["aria-describedby"],
|
|
118
|
-
|
|
135
|
+
"aria-disabled": this.props['disabled'],
|
|
136
|
+
onChange: e => this.foundation.handleChange(e.target.checked, e),
|
|
137
|
+
onFocus: e => this.handleFocusVisible(e),
|
|
138
|
+
onBlur: e => this.handleBlur(e)
|
|
119
139
|
})));
|
|
120
140
|
}
|
|
121
141
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-ui",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.10.0-beta.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/es/index.js",
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@babel/runtime-corejs3": "^7.15.4",
|
|
17
|
-
"@douyinfe/semi-animation": "2.
|
|
18
|
-
"@douyinfe/semi-animation-react": "2.
|
|
19
|
-
"@douyinfe/semi-foundation": "2.
|
|
20
|
-
"@douyinfe/semi-icons": "2.
|
|
21
|
-
"@douyinfe/semi-illustrations": "2.
|
|
22
|
-
"@douyinfe/semi-theme-default": "2.
|
|
17
|
+
"@douyinfe/semi-animation": "2.10.0-beta.0",
|
|
18
|
+
"@douyinfe/semi-animation-react": "2.10.0-beta.0",
|
|
19
|
+
"@douyinfe/semi-foundation": "2.10.0-beta.0",
|
|
20
|
+
"@douyinfe/semi-icons": "2.10.0-beta.0",
|
|
21
|
+
"@douyinfe/semi-illustrations": "2.10.0-beta.0",
|
|
22
|
+
"@douyinfe/semi-theme-default": "2.10.0-beta.0",
|
|
23
23
|
"@types/react-window": "^1.8.2",
|
|
24
24
|
"async-validator": "^3.5.0",
|
|
25
25
|
"classnames": "^2.2.6",
|
|
@@ -69,13 +69,13 @@
|
|
|
69
69
|
],
|
|
70
70
|
"author": "",
|
|
71
71
|
"license": "MIT",
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "10c5eff42fe3144451fd73d9d542a710d165d456",
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@babel/plugin-proposal-decorators": "^7.15.8",
|
|
75
75
|
"@babel/plugin-transform-runtime": "^7.15.8",
|
|
76
76
|
"@babel/preset-env": "^7.15.8",
|
|
77
77
|
"@babel/preset-react": "^7.14.5",
|
|
78
|
-
"@douyinfe/semi-scss-compile": "2.
|
|
78
|
+
"@douyinfe/semi-scss-compile": "2.10.0-beta.0",
|
|
79
79
|
"@storybook/addon-knobs": "^6.3.1",
|
|
80
80
|
"@types/lodash": "^4.14.176",
|
|
81
81
|
"babel-loader": "^8.2.2",
|
package/switch/index.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* eslint-disable max-len
|
|
1
|
+
/* eslint-disable max-len */
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import cls from 'classnames';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
@@ -33,6 +33,7 @@ export interface SwitchProps {
|
|
|
33
33
|
export interface SwitchState {
|
|
34
34
|
nativeControlChecked: boolean;
|
|
35
35
|
nativeControlDisabled: boolean;
|
|
36
|
+
focusVisible: boolean;
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
class Switch extends BaseComponent<SwitchProps, SwitchState> {
|
|
@@ -74,6 +75,7 @@ class Switch extends BaseComponent<SwitchProps, SwitchState> {
|
|
|
74
75
|
this.state = {
|
|
75
76
|
nativeControlChecked: false,
|
|
76
77
|
nativeControlDisabled: false,
|
|
78
|
+
focusVisible: false
|
|
77
79
|
};
|
|
78
80
|
this.switchRef = React.createRef();
|
|
79
81
|
this.foundation = new SwitchFoudation(this.adapter);
|
|
@@ -105,14 +107,25 @@ class Switch extends BaseComponent<SwitchProps, SwitchState> {
|
|
|
105
107
|
setNativeControlDisabled: (nativeControlDisabled: boolean): void => {
|
|
106
108
|
this.setState({ nativeControlDisabled });
|
|
107
109
|
},
|
|
110
|
+
setFocusVisible: (focusVisible: boolean): void => {
|
|
111
|
+
this.setState({ focusVisible });
|
|
112
|
+
},
|
|
108
113
|
notifyChange: (checked: boolean, e: React.ChangeEvent<HTMLInputElement>): void => {
|
|
109
114
|
this.props.onChange(checked, e);
|
|
110
115
|
},
|
|
111
116
|
};
|
|
112
117
|
}
|
|
113
118
|
|
|
119
|
+
handleFocusVisible = (event: React.FocusEvent) => {
|
|
120
|
+
this.foundation.handleFocusVisible(event);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
handleBlur = (event: React.FocusEvent) => {
|
|
124
|
+
this.foundation.handleBlur();
|
|
125
|
+
}
|
|
126
|
+
|
|
114
127
|
render() {
|
|
115
|
-
const { nativeControlChecked, nativeControlDisabled } = this.state;
|
|
128
|
+
const { nativeControlChecked, nativeControlDisabled, focusVisible } = this.state;
|
|
116
129
|
const { className, style, onMouseEnter, onMouseLeave, size, checkedText, uncheckedText, loading, id } = this.props;
|
|
117
130
|
const wrapperCls = cls(className, {
|
|
118
131
|
[cssClasses.PREFIX]: true,
|
|
@@ -121,10 +134,10 @@ class Switch extends BaseComponent<SwitchProps, SwitchState> {
|
|
|
121
134
|
[cssClasses.LARGE]: size === 'large',
|
|
122
135
|
[cssClasses.SMALL]: size === 'small',
|
|
123
136
|
[cssClasses.LOADING]: loading,
|
|
137
|
+
[cssClasses.FOCUS]: focusVisible,
|
|
124
138
|
});
|
|
125
139
|
const switchProps = {
|
|
126
140
|
type: 'checkbox',
|
|
127
|
-
role: 'switch',
|
|
128
141
|
className: cssClasses.NATIVE_CONTROL,
|
|
129
142
|
disabled: nativeControlDisabled || loading,
|
|
130
143
|
checked: nativeControlChecked || false,
|
|
@@ -157,13 +170,17 @@ class Switch extends BaseComponent<SwitchProps, SwitchState> {
|
|
|
157
170
|
{...switchProps}
|
|
158
171
|
ref={this.switchRef}
|
|
159
172
|
id={id}
|
|
173
|
+
role='switch'
|
|
160
174
|
aria-checked={nativeControlChecked}
|
|
161
175
|
aria-invalid={this.props['aria-invalid']}
|
|
162
176
|
aria-errormessage={this.props['aria-errormessage']}
|
|
163
177
|
aria-label={this.props['aria-label']}
|
|
164
178
|
aria-labelledby={this.props['aria-labelledby']}
|
|
165
179
|
aria-describedby={this.props["aria-describedby"]}
|
|
180
|
+
aria-disabled={this.props['disabled']}
|
|
166
181
|
onChange={e => this.foundation.handleChange(e.target.checked, e)}
|
|
182
|
+
onFocus={e => this.handleFocusVisible(e)}
|
|
183
|
+
onBlur={e => this.handleBlur(e)}
|
|
167
184
|
/>
|
|
168
185
|
</div>
|
|
169
186
|
);
|
|
@@ -78,7 +78,7 @@ describe('TagInput', () => {
|
|
|
78
78
|
|
|
79
79
|
it('TagInput with defaultValue and value is undefined', () => {
|
|
80
80
|
const props = {
|
|
81
|
-
defaultValue: ['
|
|
81
|
+
defaultValue: ['semi', 'hotsoon'],
|
|
82
82
|
value: undefined,
|
|
83
83
|
};
|
|
84
84
|
const tagInput = getTagInput(props);
|
|
@@ -89,7 +89,7 @@ describe('TagInput', () => {
|
|
|
89
89
|
|
|
90
90
|
it('TagInput with defaultValue and value is null', () => {
|
|
91
91
|
const props = {
|
|
92
|
-
defaultValue: ['
|
|
92
|
+
defaultValue: ['semi', 'hotsoon'],
|
|
93
93
|
value: null,
|
|
94
94
|
};
|
|
95
95
|
const tagInput = getTagInput(props);
|
|
@@ -123,26 +123,26 @@ describe('TagInput', () => {
|
|
|
123
123
|
/* when separator is null */
|
|
124
124
|
const props2 = {
|
|
125
125
|
separator: null,
|
|
126
|
-
inputValue: '
|
|
126
|
+
inputValue: 'semi-hotsoon'
|
|
127
127
|
}
|
|
128
128
|
const tagInput2 = getTagInput(props2);
|
|
129
129
|
tagInput2.find('input').simulate('keyDown', { keyCode: 13 });
|
|
130
130
|
const tags2 = tagInput2.find(`.${BASE_CLASS_PREFIX}-tagInput-wrapper .${BASE_CLASS_PREFIX}-tag-content`);
|
|
131
131
|
expect(tags2.length).toEqual(1);
|
|
132
|
-
expect(tags2.at(0).getDOMNode().textContent).toEqual('
|
|
132
|
+
expect(tags2.at(0).getDOMNode().textContent).toEqual('semi-hotsoon');
|
|
133
133
|
tagInput2.unmount();
|
|
134
134
|
|
|
135
135
|
/* when separator is number */
|
|
136
136
|
const props3 = {
|
|
137
137
|
separator: 1,
|
|
138
|
-
inputValue: '
|
|
138
|
+
inputValue: 'semi1design'
|
|
139
139
|
}
|
|
140
140
|
const tagInput3 = getTagInput(props3);
|
|
141
141
|
tagInput3.find('input').simulate('keyDown', { keyCode: 13 });
|
|
142
142
|
const tags3 = tagInput3.find(`.${BASE_CLASS_PREFIX}-tagInput-wrapper .${BASE_CLASS_PREFIX}-tag-content`);
|
|
143
143
|
expect(tags3.length).toEqual(2);
|
|
144
|
-
expect(tags3.at(0).getDOMNode().textContent).toEqual('
|
|
145
|
-
expect(tags3.at(1).getDOMNode().textContent).toEqual('
|
|
144
|
+
expect(tags3.at(0).getDOMNode().textContent).toEqual('semi');
|
|
145
|
+
expect(tags3.at(1).getDOMNode().textContent).toEqual('design');
|
|
146
146
|
tagInput3.unmount();
|
|
147
147
|
});
|
|
148
148
|
|
|
@@ -352,10 +352,10 @@ describe('TagInput', () => {
|
|
|
352
352
|
|
|
353
353
|
it('tagInput with set value to null ', () => {
|
|
354
354
|
const props = {
|
|
355
|
-
value: ['
|
|
355
|
+
value: ['semi']
|
|
356
356
|
};
|
|
357
357
|
const tagInput = getTagInput(props);
|
|
358
|
-
expect(tagInput.find(`.${BASE_CLASS_PREFIX}-tagInput-wrapper .${BASE_CLASS_PREFIX}-tag-content`).getDOMNode().textContent).toEqual('
|
|
358
|
+
expect(tagInput.find(`.${BASE_CLASS_PREFIX}-tagInput-wrapper .${BASE_CLASS_PREFIX}-tag-content`).getDOMNode().textContent).toEqual('semi');
|
|
359
359
|
tagInput.setProps({ value: null });
|
|
360
360
|
tagInput.update();
|
|
361
361
|
const tags = tagInput.find(`.${BASE_CLASS_PREFIX}-tagInput-wrapper .${BASE_CLASS_PREFIX}-tag-content`);
|
|
@@ -364,10 +364,10 @@ describe('TagInput', () => {
|
|
|
364
364
|
|
|
365
365
|
it('tagInput with set value to null ', () => {
|
|
366
366
|
const props = {
|
|
367
|
-
value: ['
|
|
367
|
+
value: ['semi']
|
|
368
368
|
};
|
|
369
369
|
const tagInput = getTagInput(props);
|
|
370
|
-
expect(tagInput.find(`.${BASE_CLASS_PREFIX}-tagInput-wrapper .${BASE_CLASS_PREFIX}-tag-content`).getDOMNode().textContent).toEqual('
|
|
370
|
+
expect(tagInput.find(`.${BASE_CLASS_PREFIX}-tagInput-wrapper .${BASE_CLASS_PREFIX}-tag-content`).getDOMNode().textContent).toEqual('semi');
|
|
371
371
|
tagInput.setProps({ value: undefined });
|
|
372
372
|
tagInput.update();
|
|
373
373
|
const tags = tagInput.find(`.${BASE_CLASS_PREFIX}-tagInput-wrapper .${BASE_CLASS_PREFIX}-tag-content`);
|