@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.
Files changed (47) hide show
  1. package/banner/_story/banner.stories.js +62 -1
  2. package/banner/index.tsx +5 -5
  3. package/carousel/CarouselArrow.tsx +62 -0
  4. package/carousel/CarouselIndicator.tsx +84 -0
  5. package/carousel/__test__/carousel.test.js +159 -0
  6. package/carousel/_story/carousel.stories.js +486 -0
  7. package/carousel/index.tsx +294 -0
  8. package/carousel/interface.ts +64 -0
  9. package/cascader/index.tsx +1 -2
  10. package/dist/css/semi.css +342 -0
  11. package/dist/css/semi.min.css +1 -1
  12. package/dist/umd/semi-ui.js +884 -66
  13. package/dist/umd/semi-ui.js.map +1 -1
  14. package/dist/umd/semi-ui.min.js +1 -1
  15. package/dist/umd/semi-ui.min.js.map +1 -1
  16. package/index.ts +2 -0
  17. package/lib/cjs/banner/index.js +11 -5
  18. package/lib/cjs/carousel/CarouselArrow.d.ts +8 -0
  19. package/lib/cjs/carousel/CarouselArrow.js +91 -0
  20. package/lib/cjs/carousel/CarouselIndicator.d.ts +23 -0
  21. package/lib/cjs/carousel/CarouselIndicator.js +145 -0
  22. package/lib/cjs/carousel/index.d.ts +58 -0
  23. package/lib/cjs/carousel/index.js +345 -0
  24. package/lib/cjs/carousel/interface.d.ts +62 -0
  25. package/lib/cjs/carousel/interface.js +7 -0
  26. package/lib/cjs/cascader/index.js +1 -1
  27. package/lib/cjs/index.d.ts +1 -0
  28. package/lib/cjs/index.js +9 -0
  29. package/lib/cjs/switch/index.d.ts +3 -0
  30. package/lib/cjs/switch/index.js +26 -6
  31. package/lib/es/banner/index.js +11 -5
  32. package/lib/es/carousel/CarouselArrow.d.ts +8 -0
  33. package/lib/es/carousel/CarouselArrow.js +72 -0
  34. package/lib/es/carousel/CarouselIndicator.d.ts +23 -0
  35. package/lib/es/carousel/CarouselIndicator.js +125 -0
  36. package/lib/es/carousel/index.d.ts +58 -0
  37. package/lib/es/carousel/index.js +311 -0
  38. package/lib/es/carousel/interface.d.ts +62 -0
  39. package/lib/es/carousel/interface.js +1 -0
  40. package/lib/es/cascader/index.js +1 -1
  41. package/lib/es/index.d.ts +1 -0
  42. package/lib/es/index.js +1 -0
  43. package/lib/es/switch/index.d.ts +3 -0
  44. package/lib/es/switch/index.js +26 -6
  45. package/package.json +9 -9
  46. package/switch/index.tsx +20 -3
  47. package/tagInput/__test__/tagInput.test.js +11 -11
@@ -0,0 +1,345 @@
1
+ "use strict";
2
+
3
+ var _WeakMap = require("@babel/runtime-corejs3/core-js-stable/weak-map");
4
+
5
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
6
+
7
+ var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
8
+
9
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
10
+
11
+ _Object$defineProperty(exports, "__esModule", {
12
+ value: true
13
+ });
14
+
15
+ exports.default = void 0;
16
+
17
+ var _filter = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/filter"));
18
+
19
+ var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
20
+
21
+ var _assign = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/assign"));
22
+
23
+ var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
24
+
25
+ var _debounce2 = _interopRequireDefault(require("lodash/debounce"));
26
+
27
+ var _react = _interopRequireWildcard(require("react"));
28
+
29
+ var _classnames = _interopRequireDefault(require("classnames"));
30
+
31
+ var _propTypes = _interopRequireDefault(require("prop-types"));
32
+
33
+ var _baseComponent = _interopRequireDefault(require("../_base/baseComponent"));
34
+
35
+ var _constants = require("@douyinfe/semi-foundation/lib/cjs/carousel/constants");
36
+
37
+ var _foundation = _interopRequireDefault(require("@douyinfe/semi-foundation/lib/cjs/carousel/foundation"));
38
+
39
+ var _CarouselIndicator = _interopRequireDefault(require("./CarouselIndicator"));
40
+
41
+ var _CarouselArrow = _interopRequireDefault(require("./CarouselArrow"));
42
+
43
+ require("@douyinfe/semi-foundation/lib/cjs/carousel/carousel.css");
44
+
45
+ var _isNullOrUndefined = _interopRequireDefault(require("@douyinfe/semi-foundation/lib/cjs/utils/isNullOrUndefined"));
46
+
47
+ function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
48
+
49
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
50
+
51
+ /* eslint-disable jsx-a11y/no-static-element-interactions */
52
+ class Carousel extends _baseComponent.default {
53
+ constructor(props) {
54
+ super(props);
55
+
56
+ this.play = () => {
57
+ return this.foundation.handleAutoPlay();
58
+ };
59
+
60
+ this.stop = () => {
61
+ return this.foundation.stop();
62
+ };
63
+
64
+ this.goTo = targetIndex => {
65
+ return this.foundation.goTo(targetIndex);
66
+ };
67
+
68
+ this.prev = () => {
69
+ return this.foundation.prev();
70
+ };
71
+
72
+ this.next = () => {
73
+ return this.foundation.next();
74
+ };
75
+
76
+ this.handleAutoPlay = () => {
77
+ if (!this.foundation.getIsControledComponent()) {
78
+ this.foundation.handleAutoPlay();
79
+ }
80
+ };
81
+
82
+ this.handleMouseEnter = () => {
83
+ const {
84
+ autoPlay
85
+ } = this.props;
86
+
87
+ if (typeof autoPlay !== 'object' || autoPlay.hoverToPause) {
88
+ this.foundation.stop();
89
+ }
90
+ };
91
+
92
+ this.handleMouseLeave = () => {
93
+ const {
94
+ autoPlay
95
+ } = this.props;
96
+
97
+ if ((typeof autoPlay !== 'object' || autoPlay.hoverToPause) && !this.foundation.getIsControledComponent()) {
98
+ this.foundation.handleAutoPlay();
99
+ }
100
+ };
101
+
102
+ this.onIndicatorChange = activeIndex => {
103
+ return this.foundation.throttleChange(activeIndex);
104
+ };
105
+
106
+ this.getChildren = () => {
107
+ var _context;
108
+
109
+ const {
110
+ children: originChildren
111
+ } = this.props;
112
+ return (0, _filter.default)(_context = _react.Children.toArray(originChildren)).call(_context, child => {
113
+ return /*#__PURE__*/_react.default.isValidElement(child);
114
+ });
115
+ };
116
+
117
+ this.getValidIndex = activeIndex => {
118
+ return this.foundation.getValidIndex(activeIndex);
119
+ };
120
+
121
+ this.renderChildren = () => {
122
+ const {
123
+ speed,
124
+ animation
125
+ } = this.props;
126
+ const {
127
+ activeIndex,
128
+ children,
129
+ preIndex,
130
+ isInit
131
+ } = this.state;
132
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, (0, _map.default)(children).call(children, (child, index) => {
133
+ const isCurrent = index === activeIndex;
134
+ const isPrev = index === this.getValidIndex(activeIndex - 1);
135
+ const isNext = index === this.getValidIndex(activeIndex + 1);
136
+ const animateStyle = {
137
+ transitionTimingFunction: 'ease',
138
+ transitionDuration: "".concat(speed, "ms"),
139
+ animationTimingFunction: 'ease',
140
+ animationDuration: "".concat(speed, "ms")
141
+ };
142
+ return /*#__PURE__*/_react.default.cloneElement(child, {
143
+ style: (0, _assign.default)((0, _assign.default)({}, child.props.style), animateStyle),
144
+ className: (0, _classnames.default)(child.props.className, {
145
+ ["".concat(_constants.cssClasses.CAROUSEL_CONTENT, "-item-prev")]: isPrev,
146
+ ["".concat(_constants.cssClasses.CAROUSEL_CONTENT, "-item-next")]: isNext,
147
+ ["".concat(_constants.cssClasses.CAROUSEL_CONTENT, "-item-current")]: isCurrent,
148
+ ["".concat(_constants.cssClasses.CAROUSEL_CONTENT, "-item")]: true,
149
+ ["".concat(_constants.cssClasses.CAROUSEL_CONTENT, "-item-active")]: isCurrent,
150
+ ["".concat(_constants.cssClasses.CAROUSEL_CONTENT, "-item-slide-in")]: animation === 'slide' && !isInit && isCurrent,
151
+ ["".concat(_constants.cssClasses.CAROUSEL_CONTENT, "-item-slide-out")]: animation === 'slide' && !isInit && index === preIndex
152
+ })
153
+ });
154
+ }));
155
+ };
156
+
157
+ this.renderIndicator = () => {
158
+ const {
159
+ children,
160
+ activeIndex
161
+ } = this.state;
162
+ const {
163
+ showIndicator,
164
+ indicatorType,
165
+ theme,
166
+ indicatorPosition,
167
+ indicatorSize,
168
+ trigger
169
+ } = this.props;
170
+ const carouselIndicatorCls = (0, _classnames.default)({
171
+ [_constants.cssClasses.CAROUSEL_INDICATOR]: true
172
+ });
173
+
174
+ if (showIndicator && children.length > 1) {
175
+ return /*#__PURE__*/_react.default.createElement("div", {
176
+ className: carouselIndicatorCls
177
+ }, /*#__PURE__*/_react.default.createElement(_CarouselIndicator.default, {
178
+ type: indicatorType,
179
+ total: children.length,
180
+ activeIndex: activeIndex,
181
+ position: indicatorPosition,
182
+ trigger: trigger,
183
+ size: indicatorSize,
184
+ theme: theme,
185
+ onIndicatorChange: this.onIndicatorChange
186
+ }));
187
+ }
188
+
189
+ return null;
190
+ };
191
+
192
+ this.renderArrow = () => {
193
+ const {
194
+ children
195
+ } = this.state;
196
+ const {
197
+ showArrow,
198
+ arrowType,
199
+ theme,
200
+ arrowProps
201
+ } = this.props;
202
+ const timing = this.foundation.getSwitchingTime();
203
+
204
+ if (showArrow && children.length > 1) {
205
+ return /*#__PURE__*/_react.default.createElement(_CarouselArrow.default, {
206
+ type: arrowType,
207
+ theme: theme,
208
+ prev: this.prev,
209
+ next: this.next,
210
+ timing: timing,
211
+ arrowProps: arrowProps
212
+ });
213
+ }
214
+
215
+ return null;
216
+ };
217
+
218
+ this.foundation = new _foundation.default(this.adapter);
219
+ const defaultActiveIndex = this.foundation.getDefaultActiveIndex();
220
+ this.state = {
221
+ activeIndex: defaultActiveIndex,
222
+ children: this.getChildren(),
223
+ preIndex: defaultActiveIndex,
224
+ isReverse: false,
225
+ isInit: true
226
+ };
227
+ }
228
+
229
+ get adapter() {
230
+ return (0, _assign.default)((0, _assign.default)({}, super.adapter), {
231
+ notifyChange: (activeIndex, preIndex) => {
232
+ this.props.onChange(activeIndex, preIndex);
233
+ },
234
+ setNewActiveIndex: activeIndex => {
235
+ this.setState({
236
+ activeIndex
237
+ });
238
+ },
239
+ setPreActiveIndex: preIndex => {
240
+ this.setState({
241
+ preIndex
242
+ });
243
+ },
244
+ setIsReverse: isReverse => {
245
+ this.setState({
246
+ isReverse
247
+ });
248
+ },
249
+ setIsInit: isInit => {
250
+ this.setState({
251
+ isInit
252
+ });
253
+ }
254
+ });
255
+ }
256
+
257
+ static getDerivedStateFromProps(props, state) {
258
+ const states = {};
259
+
260
+ if (!(0, _isNullOrUndefined.default)(props.activeIndex) && props.activeIndex !== state.activeIndex) {
261
+ states.activeIndex = props.activeIndex;
262
+ }
263
+
264
+ return states;
265
+ }
266
+
267
+ componentDidMount() {
268
+ this.handleAutoPlay();
269
+ }
270
+
271
+ componentWillUnmount() {
272
+ this.foundation.destroy();
273
+ }
274
+
275
+ render() {
276
+ var _context2;
277
+
278
+ const {
279
+ animation,
280
+ className,
281
+ style,
282
+ slideDirection
283
+ } = this.props;
284
+ const {
285
+ isReverse
286
+ } = this.state;
287
+ const carouselWrapperCls = (0, _classnames.default)(className, {
288
+ [_constants.cssClasses.CAROUSEL]: true
289
+ });
290
+ return /*#__PURE__*/_react.default.createElement("div", {
291
+ // role='listbox'
292
+ // tabIndex={0}
293
+ className: carouselWrapperCls,
294
+ style: style,
295
+ onMouseEnter: (0, _debounce2.default)(this.handleMouseEnter, 400),
296
+ onMouseLeave: (0, _debounce2.default)(this.handleMouseLeave, 400)
297
+ }, /*#__PURE__*/_react.default.createElement("div", {
298
+ className: (0, _classnames.default)([(0, _concat.default)(_context2 = "".concat(_constants.cssClasses.CAROUSEL_CONTENT, "-")).call(_context2, animation)], {
299
+ ["".concat(_constants.cssClasses.CAROUSEL_CONTENT)]: true,
300
+ ["".concat(_constants.cssClasses.CAROUSEL_CONTENT, "-reverse")]: slideDirection === 'left' ? isReverse : !isReverse
301
+ })
302
+ }, this.renderChildren()), this.renderIndicator(), this.renderArrow());
303
+ }
304
+
305
+ }
306
+
307
+ Carousel.propTypes = {
308
+ activeIndex: _propTypes.default.number,
309
+ animation: _propTypes.default.oneOf(_constants.strings.ANIMATION_MAP),
310
+ arrowProps: _propTypes.default.object,
311
+ autoPlay: _propTypes.default.oneOfType([_propTypes.default.bool, _propTypes.default.object]),
312
+ className: _propTypes.default.string,
313
+ defaultActiveIndex: _propTypes.default.number,
314
+ indicatorPosition: _propTypes.default.oneOf(_constants.strings.POSITION_MAP),
315
+ indicatorSize: _propTypes.default.oneOf(_constants.strings.SIZE),
316
+ indicatorType: _propTypes.default.oneOf(_constants.strings.TYPE_MAP),
317
+ theme: _propTypes.default.oneOf(_constants.strings.THEME_MAP),
318
+ onChange: _propTypes.default.func,
319
+ arrowType: _propTypes.default.oneOf(_constants.strings.ARROW_MAP),
320
+ showArrow: _propTypes.default.bool,
321
+ showIndicator: _propTypes.default.bool,
322
+ slideDirection: _propTypes.default.oneOf(_constants.strings.DIRECTION),
323
+ speed: _propTypes.default.number,
324
+ style: _propTypes.default.object,
325
+ trigger: _propTypes.default.oneOf(_constants.strings.TRIGGER)
326
+ };
327
+ Carousel.defaultProps = {
328
+ children: [],
329
+ animation: 'slide',
330
+ autoPlay: true,
331
+ arrowType: 'always',
332
+ defaultActiveIndex: _constants.numbers.DEFAULT_ACTIVE_INDEX,
333
+ indicatorPosition: 'center',
334
+ indicatorSize: 'small',
335
+ indicatorType: 'dot',
336
+ theme: 'light',
337
+ onChange: () => undefined,
338
+ showArrow: true,
339
+ showIndicator: true,
340
+ slideDirection: 'left',
341
+ speed: _constants.numbers.DEFAULT_SPEED,
342
+ trigger: 'click'
343
+ };
344
+ var _default = Carousel;
345
+ exports.default = _default;
@@ -0,0 +1,62 @@
1
+ import React, { ReactNode } from "react";
2
+ import { strings } from '@douyinfe/semi-foundation/lib/cjs/carousel/constants';
3
+ export interface CarouselMethod {
4
+ next?: () => void;
5
+ prev?: () => void;
6
+ goTo?: () => void;
7
+ play?: () => void;
8
+ stop?: () => void;
9
+ }
10
+ export interface CarouselProps {
11
+ activeIndex?: number;
12
+ animation?: typeof strings.ANIMATION_MAP[number];
13
+ arrowProps?: ArrowProps;
14
+ autoPlay?: boolean | {
15
+ interval?: number;
16
+ hoverToPause?: boolean;
17
+ };
18
+ arrowType?: typeof strings.ARROW_MAP[number];
19
+ children?: ReactNode | Array<ReactNode>;
20
+ className?: string;
21
+ defaultActiveIndex?: number;
22
+ indicatorPosition?: typeof strings.POSITION_MAP[number];
23
+ indicatorSize?: typeof strings.SIZE[number];
24
+ theme?: typeof strings.THEME_MAP[number];
25
+ indicatorType?: typeof strings.TYPE_MAP[number];
26
+ onChange?: (index: number, preIndex: number) => void;
27
+ showArrow?: boolean;
28
+ showIndicator?: boolean;
29
+ slideDirection?: typeof strings.DIRECTION[number];
30
+ speed?: number;
31
+ style?: React.CSSProperties;
32
+ trigger?: typeof strings.TRIGGER[number];
33
+ }
34
+ export interface CarouselIndicatorProps {
35
+ activeIndex?: number;
36
+ className?: string;
37
+ defaultActiveIndex?: number;
38
+ position?: typeof strings.POSITION_MAP[number];
39
+ size?: typeof strings.SIZE[number];
40
+ total?: number;
41
+ theme?: typeof strings.THEME_MAP[number];
42
+ type?: typeof strings.TYPE_MAP[number];
43
+ onIndicatorChange?: (activeIndex: number) => void;
44
+ style?: React.CSSProperties;
45
+ trigger?: typeof strings.TRIGGER[number];
46
+ }
47
+ export interface CarouselArrowProps {
48
+ type?: typeof strings.ARROW_MAP[number];
49
+ theme?: typeof strings.THEME_MAP[number];
50
+ prev?: () => void;
51
+ next?: () => void;
52
+ arrowProps?: ArrowProps;
53
+ timing: number;
54
+ }
55
+ export interface ArrowButton {
56
+ props?: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
57
+ children?: React.ReactNode;
58
+ }
59
+ export interface ArrowProps {
60
+ leftArrow?: ArrowButton;
61
+ rightArrow?: ArrowButton;
62
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+
3
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
4
+
5
+ _Object$defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
@@ -139,7 +139,7 @@ class Cascader extends _baseComponent.default {
139
139
  e.preventDefault();
140
140
  this.handleTagRemove(e, keyEntities[nodeKey].valuePath);
141
141
  }
142
- }, displayProp === 'label' && keyEntities[nodeKey].data.label, displayProp === 'value' && keyEntities[nodeKey].data.value);
142
+ }, keyEntities[nodeKey].data[displayProp]);
143
143
  }
144
144
  }
145
145
 
@@ -12,6 +12,7 @@ export { default as ButtonGroup } from './button/buttonGroup';
12
12
  export { default as Calendar } from './calendar';
13
13
  export { default as Card } from './card';
14
14
  export { default as CardGroup } from './card/cardGroup';
15
+ export { default as Carousel } from './carousel';
15
16
  export { default as Cascader } from './cascader';
16
17
  export { default as Checkbox } from './checkbox';
17
18
  export { default as CheckboxGroup } from './checkbox/checkboxGroup';
package/lib/cjs/index.js CHANGED
@@ -110,6 +110,13 @@ _Object$defineProperty(exports, "CardGroup", {
110
110
  }
111
111
  });
112
112
 
113
+ _Object$defineProperty(exports, "Carousel", {
114
+ enumerable: true,
115
+ get: function () {
116
+ return _carousel.default;
117
+ }
118
+ });
119
+
113
120
  _Object$defineProperty(exports, "Cascader", {
114
121
  enumerable: true,
115
122
  get: function () {
@@ -656,6 +663,8 @@ var _card = _interopRequireDefault(require("./card"));
656
663
 
657
664
  var _cardGroup = _interopRequireDefault(require("./card/cardGroup"));
658
665
 
666
+ var _carousel = _interopRequireDefault(require("./carousel"));
667
+
659
668
  var _cascader = _interopRequireDefault(require("./cascader"));
660
669
 
661
670
  var _checkbox = _interopRequireDefault(require("./checkbox"));
@@ -26,6 +26,7 @@ export interface SwitchProps {
26
26
  export interface SwitchState {
27
27
  nativeControlChecked: boolean;
28
28
  nativeControlDisabled: boolean;
29
+ focusVisible: boolean;
29
30
  }
30
31
  declare class Switch extends BaseComponent<SwitchProps, SwitchState> {
31
32
  static propTypes: {
@@ -55,6 +56,8 @@ declare class Switch extends BaseComponent<SwitchProps, SwitchState> {
55
56
  componentDidUpdate(prevProps: SwitchProps): void;
56
57
  componentWillUnmount(): void;
57
58
  get adapter(): SwitchAdapter<SwitchProps, SwitchState>;
59
+ handleFocusVisible: (event: React.FocusEvent) => void;
60
+ handleBlur: (event: React.FocusEvent) => void;
58
61
  render(): JSX.Element;
59
62
  }
60
63
  export default Switch;
@@ -30,13 +30,23 @@ require("@douyinfe/semi-foundation/lib/cjs/switch/switch.css");
30
30
 
31
31
  var _spin = _interopRequireDefault(require("../spin"));
32
32
 
33
- /* eslint-disable max-len, jsx-a11y/role-supports-aria-props */
33
+ /* eslint-disable max-len */
34
34
  class Switch extends _baseComponent.default {
35
35
  constructor(props) {
36
36
  super(props);
37
+
38
+ this.handleFocusVisible = event => {
39
+ this.foundation.handleFocusVisible(event);
40
+ };
41
+
42
+ this.handleBlur = event => {
43
+ this.foundation.handleBlur();
44
+ };
45
+
37
46
  this.state = {
38
47
  nativeControlChecked: false,
39
- nativeControlDisabled: false
48
+ nativeControlDisabled: false,
49
+ focusVisible: false
40
50
  };
41
51
  this.switchRef = /*#__PURE__*/_react.default.createRef();
42
52
  this.foundation = new _foundation.default(this.adapter);
@@ -72,6 +82,11 @@ class Switch extends _baseComponent.default {
72
82
  nativeControlDisabled
73
83
  });
74
84
  },
85
+ setFocusVisible: focusVisible => {
86
+ this.setState({
87
+ focusVisible
88
+ });
89
+ },
75
90
  notifyChange: (checked, e) => {
76
91
  this.props.onChange(checked, e);
77
92
  }
@@ -81,7 +96,8 @@ class Switch extends _baseComponent.default {
81
96
  render() {
82
97
  const {
83
98
  nativeControlChecked,
84
- nativeControlDisabled
99
+ nativeControlDisabled,
100
+ focusVisible
85
101
  } = this.state;
86
102
  const {
87
103
  className,
@@ -100,11 +116,11 @@ class Switch extends _baseComponent.default {
100
116
  [_constants.cssClasses.DISABLED]: nativeControlDisabled,
101
117
  [_constants.cssClasses.LARGE]: size === 'large',
102
118
  [_constants.cssClasses.SMALL]: size === 'small',
103
- [_constants.cssClasses.LOADING]: loading
119
+ [_constants.cssClasses.LOADING]: loading,
120
+ [_constants.cssClasses.FOCUS]: focusVisible
104
121
  });
105
122
  const switchProps = {
106
123
  type: 'checkbox',
107
- role: 'switch',
108
124
  className: _constants.cssClasses.NATIVE_CONTROL,
109
125
  disabled: nativeControlDisabled || loading,
110
126
  checked: nativeControlChecked || false
@@ -129,13 +145,17 @@ class Switch extends _baseComponent.default {
129
145
  }, uncheckedText) : null, /*#__PURE__*/_react.default.createElement("input", (0, _assign.default)({}, switchProps, {
130
146
  ref: this.switchRef,
131
147
  id: id,
148
+ role: 'switch',
132
149
  "aria-checked": nativeControlChecked,
133
150
  "aria-invalid": this.props['aria-invalid'],
134
151
  "aria-errormessage": this.props['aria-errormessage'],
135
152
  "aria-label": this.props['aria-label'],
136
153
  "aria-labelledby": this.props['aria-labelledby'],
137
154
  "aria-describedby": this.props["aria-describedby"],
138
- onChange: e => this.foundation.handleChange(e.target.checked, e)
155
+ "aria-disabled": this.props['disabled'],
156
+ onChange: e => this.foundation.handleChange(e.target.checked, e),
157
+ onFocus: e => this.handleFocusVisible(e),
158
+ onBlur: e => this.handleBlur(e)
139
159
  })));
140
160
  }
141
161
 
@@ -67,7 +67,9 @@ export default class Banner extends BaseComponent {
67
67
  const closer = /*#__PURE__*/React.createElement(Button, {
68
68
  className: "".concat(prefixCls, "-close"),
69
69
  onClick: this.remove,
70
- icon: closeIcon || /*#__PURE__*/React.createElement(IconClose, null),
70
+ icon: closeIcon || /*#__PURE__*/React.createElement(IconClose, {
71
+ "aria-hidden": true
72
+ }),
71
73
  theme: "borderless",
72
74
  size: "small",
73
75
  type: "tertiary",
@@ -83,16 +85,20 @@ export default class Banner extends BaseComponent {
83
85
  } = this.props;
84
86
  const iconMap = {
85
87
  warning: /*#__PURE__*/React.createElement(IconAlertTriangle, {
86
- size: "large"
88
+ size: "large",
89
+ "aria-label": 'warning'
87
90
  }),
88
91
  success: /*#__PURE__*/React.createElement(IconTickCircle, {
89
- size: "large"
92
+ size: "large",
93
+ "aria-label": 'success'
90
94
  }),
91
95
  info: /*#__PURE__*/React.createElement(IconInfoCircle, {
92
- size: "large"
96
+ size: "large",
97
+ "aria-label": 'info'
93
98
  }),
94
99
  danger: /*#__PURE__*/React.createElement(IconAlertCircle, {
95
- size: "large"
100
+ size: "large",
101
+ "aria-label": 'danger'
96
102
  })
97
103
  };
98
104
  let iconType = iconMap[type];
@@ -0,0 +1,8 @@
1
+ import React, { ReactNode } from "react";
2
+ import { CarouselArrowProps } from "./interface";
3
+ declare class CarouselArrow extends React.PureComponent<CarouselArrowProps> {
4
+ renderLeftIcon: () => any;
5
+ renderRightIcon: () => any;
6
+ render(): ReactNode;
7
+ }
8
+ export default CarouselArrow;
@@ -0,0 +1,72 @@
1
+ import _throttle from "lodash/throttle";
2
+ import _get from "lodash/get";
3
+ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
4
+ import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
5
+
6
+ /* eslint-disable jsx-a11y/click-events-have-key-events */
7
+
8
+ /* eslint-disable jsx-a11y/no-static-element-interactions */
9
+ import React from "react";
10
+ import cls from 'classnames';
11
+ import { cssClasses } from '@douyinfe/semi-foundation/lib/es/carousel/constants';
12
+ import { IconChevronLeft, IconChevronRight } from "@douyinfe/semi-icons";
13
+
14
+ class CarouselArrow extends React.PureComponent {
15
+ constructor() {
16
+ super(...arguments);
17
+
18
+ this.renderLeftIcon = () => {
19
+ return _get(this.props, 'arrowProps.leftArrow.children', /*#__PURE__*/React.createElement(IconChevronLeft, {
20
+ "aria-label": "Previous index",
21
+ size: "inherit"
22
+ }));
23
+ };
24
+
25
+ this.renderRightIcon = () => {
26
+ return _get(this.props, 'arrowProps.rightArrow.children', /*#__PURE__*/React.createElement(IconChevronRight, {
27
+ "aria-label": "Next index",
28
+ size: "inherit"
29
+ }));
30
+ };
31
+ }
32
+
33
+ render() {
34
+ var _context, _context2, _context3;
35
+
36
+ const {
37
+ type,
38
+ theme,
39
+ prev,
40
+ next,
41
+ timing
42
+ } = this.props;
43
+ const classNames = cls({
44
+ [cssClasses.CAROUSEL_ARROW]: true,
45
+ [_concatInstanceProperty(_context = "".concat(cssClasses.CAROUSEL_ARROW, "-")).call(_context, theme)]: theme,
46
+ ["".concat(cssClasses.CAROUSEL_ARROW, "-hover")]: type === 'hover'
47
+ });
48
+ const leftClassNames = cls({
49
+ ["".concat(cssClasses.CAROUSEL_ARROW, "-prev")]: true,
50
+ [_concatInstanceProperty(_context2 = "".concat(cssClasses.CAROUSEL_ARROW, "-")).call(_context2, theme)]: theme
51
+ });
52
+ const rightClassNames = cls({
53
+ ["".concat(cssClasses.CAROUSEL_ARROW, "-next")]: true,
54
+ [_concatInstanceProperty(_context3 = "".concat(cssClasses.CAROUSEL_ARROW, "-")).call(_context3, theme)]: theme
55
+ });
56
+ return /*#__PURE__*/React.createElement("div", {
57
+ className: classNames
58
+ }, /*#__PURE__*/React.createElement("div", _Object$assign({
59
+ // role='button'
60
+ className: leftClassNames,
61
+ onClick: _throttle(prev, timing)
62
+ }, _get(this.props, 'arrowProps.leftArrow.props')), this.renderLeftIcon()), /*#__PURE__*/React.createElement("div", _Object$assign({
63
+ // role='button'
64
+ // tabIndex={0}
65
+ className: rightClassNames,
66
+ onClick: _throttle(next, timing)
67
+ }, _get(this.props, 'arrowProps.rightArrow.props')), this.renderRightIcon()));
68
+ }
69
+
70
+ }
71
+
72
+ export default CarouselArrow;