@douyinfe/semi-ui 2.9.0-beta.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 (96) hide show
  1. package/anchor/__test__/anchor.test.js +1 -0
  2. package/anchor/_story/anchor.stories.js +23 -1
  3. package/badge/_story/badge.stories.js +34 -2
  4. package/banner/_story/banner.stories.js +62 -1
  5. package/banner/index.tsx +5 -5
  6. package/carousel/CarouselArrow.tsx +62 -0
  7. package/carousel/CarouselIndicator.tsx +84 -0
  8. package/carousel/__test__/carousel.test.js +159 -0
  9. package/carousel/_story/carousel.stories.js +486 -0
  10. package/carousel/index.tsx +294 -0
  11. package/carousel/interface.ts +64 -0
  12. package/cascader/_story/cascader.stories.js +17 -2
  13. package/cascader/index.tsx +2 -3
  14. package/checkbox/_story/checkbox.stories.js +1 -1
  15. package/collapse/item.tsx +2 -0
  16. package/datePicker/_story/datePicker.stories.js +37 -0
  17. package/dist/css/semi.css +344 -2
  18. package/dist/css/semi.min.css +1 -1
  19. package/dist/umd/semi-ui.js +1068 -330
  20. package/dist/umd/semi-ui.js.map +1 -1
  21. package/dist/umd/semi-ui.min.js +1 -1
  22. package/dist/umd/semi-ui.min.js.map +1 -1
  23. package/form/hoc/withField.tsx +8 -5
  24. package/index.ts +2 -0
  25. package/input/__test__/input.test.js +12 -3
  26. package/input/__test__/textArea.test.js +53 -0
  27. package/lib/cjs/banner/index.js +11 -5
  28. package/lib/cjs/carousel/CarouselArrow.d.ts +8 -0
  29. package/lib/cjs/carousel/CarouselArrow.js +91 -0
  30. package/lib/cjs/carousel/CarouselIndicator.d.ts +23 -0
  31. package/lib/cjs/carousel/CarouselIndicator.js +145 -0
  32. package/lib/cjs/carousel/index.d.ts +58 -0
  33. package/lib/cjs/carousel/index.js +345 -0
  34. package/lib/cjs/carousel/interface.d.ts +62 -0
  35. package/lib/cjs/carousel/interface.js +7 -0
  36. package/lib/cjs/cascader/index.js +2 -2
  37. package/lib/cjs/collapse/item.js +4 -2
  38. package/lib/cjs/form/hoc/withField.js +6 -4
  39. package/lib/cjs/index.d.ts +1 -0
  40. package/lib/cjs/index.js +9 -0
  41. package/lib/cjs/modal/Modal.js +3 -0
  42. package/lib/cjs/scrollList/scrollItem.js +5 -1
  43. package/lib/cjs/switch/index.d.ts +3 -0
  44. package/lib/cjs/switch/index.js +26 -6
  45. package/lib/cjs/tabs/TabPane.js +4 -0
  46. package/lib/cjs/tabs/index.js +2 -0
  47. package/lib/cjs/toast/toast.d.ts +1 -1
  48. package/lib/cjs/tooltip/index.js +1 -1
  49. package/lib/cjs/transfer/index.d.ts +1 -0
  50. package/lib/cjs/transfer/index.js +3 -1
  51. package/lib/es/banner/index.js +11 -5
  52. package/lib/es/carousel/CarouselArrow.d.ts +8 -0
  53. package/lib/es/carousel/CarouselArrow.js +72 -0
  54. package/lib/es/carousel/CarouselIndicator.d.ts +23 -0
  55. package/lib/es/carousel/CarouselIndicator.js +125 -0
  56. package/lib/es/carousel/index.d.ts +58 -0
  57. package/lib/es/carousel/index.js +311 -0
  58. package/lib/es/carousel/interface.d.ts +62 -0
  59. package/lib/es/carousel/interface.js +1 -0
  60. package/lib/es/cascader/index.js +2 -2
  61. package/lib/es/collapse/item.js +4 -2
  62. package/lib/es/form/hoc/withField.js +6 -4
  63. package/lib/es/index.d.ts +1 -0
  64. package/lib/es/index.js +1 -0
  65. package/lib/es/modal/Modal.js +3 -0
  66. package/lib/es/scrollList/scrollItem.js +5 -1
  67. package/lib/es/switch/index.d.ts +3 -0
  68. package/lib/es/switch/index.js +26 -6
  69. package/lib/es/tabs/TabPane.js +4 -0
  70. package/lib/es/tabs/index.js +2 -0
  71. package/lib/es/toast/toast.d.ts +1 -1
  72. package/lib/es/tooltip/index.js +1 -1
  73. package/lib/es/transfer/index.d.ts +1 -0
  74. package/lib/es/transfer/index.js +3 -1
  75. package/modal/Modal.tsx +2 -0
  76. package/modal/confirm.tsx +1 -1
  77. package/overflowList/_story/overflowList.stories.js +44 -0
  78. package/package.json +9 -9
  79. package/scrollList/_story/SingleWheelList/index.js +72 -0
  80. package/scrollList/_story/scrolllist.stories.js +7 -0
  81. package/scrollList/scrollItem.tsx +4 -1
  82. package/switch/index.tsx +20 -3
  83. package/table/__test__/table.test.js +1 -0
  84. package/tabs/TabPane.tsx +2 -0
  85. package/tabs/_story/tabs.stories.js +72 -0
  86. package/tabs/index.tsx +1 -0
  87. package/tagInput/__test__/tagInput.test.js +11 -11
  88. package/tagInput/_story/tagInput.stories.js +14 -1
  89. package/timePicker/TimePicker.tsx +1 -1
  90. package/timePicker/_story/timepicker.stories.js +20 -1
  91. package/tooltip/_story/tooltip.stories.js +127 -15
  92. package/tooltip/index.tsx +1 -1
  93. package/transfer/index.tsx +4 -1
  94. package/typography/__test__/typography.test.js +1 -0
  95. package/upload/__test__/upload.test.js +2 -0
  96. package/upload/_story/upload.stories.js +2 -2
@@ -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
 
@@ -423,7 +423,7 @@ class Cascader extends _baseComponent.default {
423
423
 
424
424
  this.handleClearEnterPress = e => {
425
425
  e && e.stopPropagation();
426
- this.foundation.handleClearEnterPress();
426
+ this.foundation.handleClearEnterPress(e);
427
427
  };
428
428
 
429
429
  this.showClearBtn = () => {
@@ -103,9 +103,11 @@ class CollapsePanel extends _react.PureComponent {
103
103
  className,
104
104
  children,
105
105
  itemKey,
106
- reCalcKey
106
+ reCalcKey,
107
+ header,
108
+ extra
107
109
  } = _a,
108
- restProps = __rest(_a, ["className", "children", "itemKey", "reCalcKey"]);
110
+ restProps = __rest(_a, ["className", "children", "itemKey", "reCalcKey", "header", "extra"]);
109
111
 
110
112
  const {
111
113
  keepDOM,
@@ -147,7 +147,8 @@ function withField(Component, opts) {
147
147
  const [cursor, setCursor, getCursor] = (0, _index.useStateWithGetter)(0);
148
148
  const [status, setStatus] = (0, _react.useState)(validateStatus); // use props.validateStatus to init
149
149
 
150
- const rulesRef = (0, _react.useRef)(rules); // notNotify is true means that the onChange of the Form does not need to be triggered
150
+ const rulesRef = (0, _react.useRef)(rules);
151
+ const validateRef = (0, _react.useRef)(validate); // notNotify is true means that the onChange of the Form does not need to be triggered
151
152
  // notUpdate is true means that this operation does not need to trigger the forceUpdate
152
153
 
153
154
  const updateTouched = (isTouched, callOpts) => {
@@ -246,7 +247,7 @@ function withField(Component, opts) {
246
247
  let maybePromisedErrors; // let errorThrowSync;
247
248
 
248
249
  try {
249
- maybePromisedErrors = validate(val, values);
250
+ maybePromisedErrors = validateRef.current(val, values);
250
251
  } catch (err) {
251
252
  // error throw by syncValidate
252
253
  maybePromisedErrors = err;
@@ -286,7 +287,7 @@ function withField(Component, opts) {
286
287
  finalVal = transform(val);
287
288
  }
288
289
 
289
- if (validate) {
290
+ if (validateRef.current) {
290
291
  return _validate(finalVal, updater.getValue(), callOpts);
291
292
  } else if (latestRules) {
292
293
  return _validateInternal(finalVal, callOpts);
@@ -395,7 +396,8 @@ function withField(Component, opts) {
395
396
 
396
397
  (0, _react.useLayoutEffect)(() => {
397
398
  rulesRef.current = rules;
398
- }, [rules]); // exec validate once when trigger inlcude 'mount'
399
+ validateRef.current = validate;
400
+ }, [rules, validate]); // exec validate once when trigger inlcude 'mount'
399
401
 
400
402
  (0, _react.useLayoutEffect)(() => {
401
403
  if (validateOnMount) {
@@ -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"));
@@ -253,6 +253,9 @@ class Modal extends _baseComponent.default {
253
253
  this.props.onOk(e);
254
254
  },
255
255
  notifyClose: () => {
256
+ var _a, _b;
257
+
258
+ (_b = (_a = this.props.motion) === null || _a === void 0 ? void 0 : _a.didLeave) === null || _b === void 0 ? void 0 : _b.call(_a);
256
259
  this.props.afterClose();
257
260
  },
258
261
  toggleHidden: (hidden, callback) => {
@@ -71,6 +71,8 @@ class ScrollItem extends _baseComponent.default {
71
71
  this._cacheSelectorNode = selector => this._cacheNode('selector', selector);
72
72
 
73
73
  this._cacheWrapperNode = wrapper => this._cacheNode('wrapper', wrapper);
74
+ /* istanbul ignore next */
75
+
74
76
 
75
77
  this._isFirst = node => {
76
78
  const {
@@ -85,6 +87,8 @@ class ScrollItem extends _baseComponent.default {
85
87
 
86
88
  return false;
87
89
  };
90
+ /* istanbul ignore next */
91
+
88
92
 
89
93
  this._isLast = node => {
90
94
  const {
@@ -197,7 +201,7 @@ class ScrollItem extends _baseComponent.default {
197
201
  } = this;
198
202
  const wrapperHeight = wrapper.offsetHeight;
199
203
  const itemHeight = this.getItmHeight(node);
200
- const targetTop = node.offsetTop - (wrapperHeight - itemHeight) / 2;
204
+ const targetTop = (node.offsetTop || this.list.children.length * itemHeight / 2) - (wrapperHeight - itemHeight) / 2;
201
205
  this.scrollToPos(targetTop, duration);
202
206
  };
203
207
 
@@ -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
 
@@ -75,6 +75,8 @@ class TabPane extends _react.PureComponent {
75
75
 
76
76
  return false;
77
77
  };
78
+ /* istanbul ignore next */
79
+
78
80
 
79
81
  this.hideScroll = () => {
80
82
  if (this.ref && this.ref.current) {
@@ -82,6 +84,8 @@ class TabPane extends _react.PureComponent {
82
84
  this.isAnimating = true;
83
85
  }
84
86
  };
87
+ /* istanbul ignore next */
88
+
85
89
 
86
90
  this.autoScroll = () => {
87
91
  if (this.ref && this.ref.current) {
@@ -112,6 +112,8 @@ class Tabs extends _baseComponent.default {
112
112
  this.onTabClick = (activeKey, event) => {
113
113
  this.foundation.handleTabClick(activeKey, event);
114
114
  };
115
+ /* istanbul ignore next */
116
+
115
117
 
116
118
  this.rePosChildren = (children, activeKey) => {
117
119
  const newChildren = [];