@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,23 @@
1
+ import React, { ReactNode } from "react";
2
+ import PropTypes from 'prop-types';
3
+ import { CarouselIndicatorProps } from "./interface";
4
+ declare class CarouselIndicator extends React.PureComponent<CarouselIndicatorProps> {
5
+ static propTypes: {
6
+ activeKey: PropTypes.Requireable<number>;
7
+ className: PropTypes.Requireable<string>;
8
+ position: PropTypes.Requireable<"left" | "right" | "center">;
9
+ size: PropTypes.Requireable<"small" | "medium">;
10
+ style: PropTypes.Requireable<object>;
11
+ theme: PropTypes.Requireable<"primary" | "dark" | "light">;
12
+ total: PropTypes.Requireable<number>;
13
+ onIndicatorChange: PropTypes.Requireable<(...args: any[]) => any>;
14
+ type: PropTypes.Requireable<"line" | "dot" | "columnar">;
15
+ trigger: PropTypes.Requireable<"hover" | "click">;
16
+ };
17
+ onIndicatorChange: (activeIndex: number) => void;
18
+ handleIndicatorClick: (activeIndex: number) => void;
19
+ handleIndicatorHover: (activeIndex: number) => void;
20
+ renderIndicatorContent(): ReactNode;
21
+ render(): ReactNode;
22
+ }
23
+ export default CarouselIndicator;
@@ -0,0 +1,125 @@
1
+ import _indexOfInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/index-of";
2
+ import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
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
+ var __rest = this && this.__rest || function (s, e) {
7
+ var t = {};
8
+
9
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && _indexOfInstanceProperty(e).call(e, p) < 0) t[p] = s[p];
10
+
11
+ if (s != null && typeof _Object$getOwnPropertySymbols === "function") for (var i = 0, p = _Object$getOwnPropertySymbols(s); i < p.length; i++) {
12
+ if (_indexOfInstanceProperty(e).call(e, p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
13
+ }
14
+ return t;
15
+ };
16
+ /* eslint-disable jsx-a11y/no-static-element-interactions */
17
+
18
+ /* eslint-disable jsx-a11y/click-events-have-key-events */
19
+
20
+
21
+ import React from "react";
22
+ import cls from 'classnames';
23
+ import PropTypes from 'prop-types';
24
+ import { cssClasses, strings } from '@douyinfe/semi-foundation/lib/es/carousel/constants';
25
+ import getDataAttr from '@douyinfe/semi-foundation/lib/es/utils/getDataAttr';
26
+
27
+ class CarouselIndicator extends React.PureComponent {
28
+ constructor() {
29
+ super(...arguments);
30
+
31
+ this.onIndicatorChange = activeIndex => {
32
+ this.props.onIndicatorChange(activeIndex);
33
+ };
34
+
35
+ this.handleIndicatorClick = activeIndex => {
36
+ const {
37
+ trigger
38
+ } = this.props;
39
+
40
+ if (trigger === 'click') {
41
+ this.onIndicatorChange(activeIndex);
42
+ }
43
+ };
44
+
45
+ this.handleIndicatorHover = activeIndex => {
46
+ const {
47
+ trigger
48
+ } = this.props;
49
+
50
+ if (trigger === 'hover') {
51
+ this.onIndicatorChange(activeIndex);
52
+ }
53
+ };
54
+ }
55
+
56
+ renderIndicatorContent() {
57
+ const {
58
+ total,
59
+ theme,
60
+ size,
61
+ activeIndex
62
+ } = this.props;
63
+ const indicatorContent = [];
64
+
65
+ for (let i = 0; i < total; i++) {
66
+ var _context, _context2;
67
+
68
+ indicatorContent.push( /*#__PURE__*/React.createElement("span", {
69
+ // role='none'
70
+ key: i,
71
+ "data-index": i,
72
+ className: cls(["".concat(cssClasses.CAROUSEL_INDICATOR, "-item")], {
73
+ ["".concat(cssClasses.CAROUSEL_INDICATOR, "-item-active")]: i === activeIndex,
74
+ [_concatInstanceProperty(_context = "".concat(cssClasses.CAROUSEL_INDICATOR, "-item-")).call(_context, theme)]: theme,
75
+ [_concatInstanceProperty(_context2 = "".concat(cssClasses.CAROUSEL_INDICATOR, "-item-")).call(_context2, size)]: size
76
+ }),
77
+ onClick: () => this.handleIndicatorClick(i),
78
+ onMouseEnter: () => this.handleIndicatorHover(i)
79
+ }));
80
+ }
81
+
82
+ return indicatorContent;
83
+ }
84
+
85
+ render() {
86
+ var _context3, _context4;
87
+
88
+ const _a = this.props,
89
+ {
90
+ type,
91
+ size,
92
+ theme,
93
+ style,
94
+ className,
95
+ position
96
+ } = _a,
97
+ restProps = __rest(_a, ["type", "size", "theme", "style", "className", "position"]);
98
+
99
+ const classNames = cls(className, {
100
+ [cssClasses.CAROUSEL_INDICATOR]: true,
101
+ [_concatInstanceProperty(_context3 = "".concat(cssClasses.CAROUSEL_INDICATOR, "-")).call(_context3, type)]: type,
102
+ [_concatInstanceProperty(_context4 = "".concat(cssClasses.CAROUSEL_INDICATOR, "-")).call(_context4, position)]: position
103
+ });
104
+ const indicatorContent = this.renderIndicatorContent();
105
+ return /*#__PURE__*/React.createElement("div", _Object$assign({
106
+ className: classNames,
107
+ style: style
108
+ }, getDataAttr(restProps)), indicatorContent);
109
+ }
110
+
111
+ }
112
+
113
+ CarouselIndicator.propTypes = {
114
+ activeKey: PropTypes.number,
115
+ className: PropTypes.string,
116
+ position: PropTypes.oneOf(strings.POSITION_MAP),
117
+ size: PropTypes.oneOf(strings.SIZE),
118
+ style: PropTypes.object,
119
+ theme: PropTypes.oneOf(strings.THEME_MAP),
120
+ total: PropTypes.number,
121
+ onIndicatorChange: PropTypes.func,
122
+ type: PropTypes.oneOf(strings.TYPE_MAP),
123
+ trigger: PropTypes.oneOf(strings.TRIGGER)
124
+ };
125
+ export default CarouselIndicator;
@@ -0,0 +1,58 @@
1
+ import { ReactNode, ReactChild, ReactFragment, ReactPortal } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import BaseComponent from "../_base/baseComponent";
4
+ import { CarouselProps } from './interface';
5
+ import CarouselFoundation, { CarouselAdapter } from '@douyinfe/semi-foundation/lib/es/carousel/foundation';
6
+ import '@douyinfe/semi-foundation/lib/es/carousel/carousel.css';
7
+ export interface CarouselState {
8
+ activeIndex: number;
9
+ children: (ReactChild | ReactFragment | ReactPortal)[];
10
+ preIndex: number;
11
+ isReverse: boolean;
12
+ isInit: boolean;
13
+ }
14
+ declare class Carousel extends BaseComponent<CarouselProps, CarouselState> {
15
+ static propTypes: {
16
+ activeIndex: PropTypes.Requireable<number>;
17
+ animation: PropTypes.Requireable<"slide" | "fade">;
18
+ arrowProps: PropTypes.Requireable<object>;
19
+ autoPlay: PropTypes.Requireable<boolean | object>;
20
+ className: PropTypes.Requireable<string>;
21
+ defaultActiveIndex: PropTypes.Requireable<number>;
22
+ indicatorPosition: PropTypes.Requireable<"left" | "right" | "center">;
23
+ indicatorSize: PropTypes.Requireable<"small" | "medium">;
24
+ indicatorType: PropTypes.Requireable<"line" | "dot" | "columnar">;
25
+ theme: PropTypes.Requireable<"primary" | "dark" | "light">;
26
+ onChange: PropTypes.Requireable<(...args: any[]) => any>;
27
+ arrowType: PropTypes.Requireable<"hover" | "always">;
28
+ showArrow: PropTypes.Requireable<boolean>;
29
+ showIndicator: PropTypes.Requireable<boolean>;
30
+ slideDirection: PropTypes.Requireable<"left" | "right">;
31
+ speed: PropTypes.Requireable<number>;
32
+ style: PropTypes.Requireable<object>;
33
+ trigger: PropTypes.Requireable<"hover" | "click">;
34
+ };
35
+ static defaultProps: CarouselProps;
36
+ foundation: CarouselFoundation;
37
+ constructor(props: CarouselProps);
38
+ get adapter(): CarouselAdapter<CarouselProps, CarouselState>;
39
+ static getDerivedStateFromProps(props: CarouselProps, state: CarouselState): Partial<CarouselState>;
40
+ componentDidMount(): void;
41
+ componentWillUnmount(): void;
42
+ play: () => void;
43
+ stop: () => void;
44
+ goTo: (targetIndex: number) => void;
45
+ prev: () => void;
46
+ next: () => void;
47
+ handleAutoPlay: () => void;
48
+ handleMouseEnter: () => void;
49
+ handleMouseLeave: () => void;
50
+ onIndicatorChange: (activeIndex: number) => void;
51
+ getChildren: () => (ReactChild | ReactFragment | ReactPortal)[];
52
+ getValidIndex: (activeIndex: number) => number;
53
+ renderChildren: () => JSX.Element;
54
+ renderIndicator: () => JSX.Element;
55
+ renderArrow: () => JSX.Element;
56
+ render(): ReactNode;
57
+ }
58
+ export default Carousel;
@@ -0,0 +1,311 @@
1
+ import _debounce from "lodash/debounce";
2
+ import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
3
+ import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
4
+ import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
5
+ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
6
+
7
+ /* eslint-disable jsx-a11y/no-static-element-interactions */
8
+ import React, { Children } from 'react';
9
+ import cls from 'classnames';
10
+ import PropTypes from 'prop-types';
11
+ import BaseComponent from "../_base/baseComponent";
12
+ import { cssClasses, numbers, strings } from '@douyinfe/semi-foundation/lib/es/carousel/constants';
13
+ import CarouselFoundation from '@douyinfe/semi-foundation/lib/es/carousel/foundation';
14
+ import CarouselIndicator from './CarouselIndicator';
15
+ import CarouselArrow from './CarouselArrow';
16
+ import '@douyinfe/semi-foundation/lib/es/carousel/carousel.css';
17
+ import isNullOrUndefined from '@douyinfe/semi-foundation/lib/es/utils/isNullOrUndefined';
18
+
19
+ class Carousel extends BaseComponent {
20
+ constructor(props) {
21
+ super(props);
22
+
23
+ this.play = () => {
24
+ return this.foundation.handleAutoPlay();
25
+ };
26
+
27
+ this.stop = () => {
28
+ return this.foundation.stop();
29
+ };
30
+
31
+ this.goTo = targetIndex => {
32
+ return this.foundation.goTo(targetIndex);
33
+ };
34
+
35
+ this.prev = () => {
36
+ return this.foundation.prev();
37
+ };
38
+
39
+ this.next = () => {
40
+ return this.foundation.next();
41
+ };
42
+
43
+ this.handleAutoPlay = () => {
44
+ if (!this.foundation.getIsControledComponent()) {
45
+ this.foundation.handleAutoPlay();
46
+ }
47
+ };
48
+
49
+ this.handleMouseEnter = () => {
50
+ const {
51
+ autoPlay
52
+ } = this.props;
53
+
54
+ if (typeof autoPlay !== 'object' || autoPlay.hoverToPause) {
55
+ this.foundation.stop();
56
+ }
57
+ };
58
+
59
+ this.handleMouseLeave = () => {
60
+ const {
61
+ autoPlay
62
+ } = this.props;
63
+
64
+ if ((typeof autoPlay !== 'object' || autoPlay.hoverToPause) && !this.foundation.getIsControledComponent()) {
65
+ this.foundation.handleAutoPlay();
66
+ }
67
+ };
68
+
69
+ this.onIndicatorChange = activeIndex => {
70
+ return this.foundation.throttleChange(activeIndex);
71
+ };
72
+
73
+ this.getChildren = () => {
74
+ var _context;
75
+
76
+ const {
77
+ children: originChildren
78
+ } = this.props;
79
+ return _filterInstanceProperty(_context = Children.toArray(originChildren)).call(_context, child => {
80
+ return /*#__PURE__*/React.isValidElement(child);
81
+ });
82
+ };
83
+
84
+ this.getValidIndex = activeIndex => {
85
+ return this.foundation.getValidIndex(activeIndex);
86
+ };
87
+
88
+ this.renderChildren = () => {
89
+ const {
90
+ speed,
91
+ animation
92
+ } = this.props;
93
+ const {
94
+ activeIndex,
95
+ children,
96
+ preIndex,
97
+ isInit
98
+ } = this.state;
99
+ return /*#__PURE__*/React.createElement(React.Fragment, null, _mapInstanceProperty(children).call(children, (child, index) => {
100
+ const isCurrent = index === activeIndex;
101
+ const isPrev = index === this.getValidIndex(activeIndex - 1);
102
+ const isNext = index === this.getValidIndex(activeIndex + 1);
103
+ const animateStyle = {
104
+ transitionTimingFunction: 'ease',
105
+ transitionDuration: "".concat(speed, "ms"),
106
+ animationTimingFunction: 'ease',
107
+ animationDuration: "".concat(speed, "ms")
108
+ };
109
+ return /*#__PURE__*/React.cloneElement(child, {
110
+ style: _Object$assign(_Object$assign({}, child.props.style), animateStyle),
111
+ className: cls(child.props.className, {
112
+ ["".concat(cssClasses.CAROUSEL_CONTENT, "-item-prev")]: isPrev,
113
+ ["".concat(cssClasses.CAROUSEL_CONTENT, "-item-next")]: isNext,
114
+ ["".concat(cssClasses.CAROUSEL_CONTENT, "-item-current")]: isCurrent,
115
+ ["".concat(cssClasses.CAROUSEL_CONTENT, "-item")]: true,
116
+ ["".concat(cssClasses.CAROUSEL_CONTENT, "-item-active")]: isCurrent,
117
+ ["".concat(cssClasses.CAROUSEL_CONTENT, "-item-slide-in")]: animation === 'slide' && !isInit && isCurrent,
118
+ ["".concat(cssClasses.CAROUSEL_CONTENT, "-item-slide-out")]: animation === 'slide' && !isInit && index === preIndex
119
+ })
120
+ });
121
+ }));
122
+ };
123
+
124
+ this.renderIndicator = () => {
125
+ const {
126
+ children,
127
+ activeIndex
128
+ } = this.state;
129
+ const {
130
+ showIndicator,
131
+ indicatorType,
132
+ theme,
133
+ indicatorPosition,
134
+ indicatorSize,
135
+ trigger
136
+ } = this.props;
137
+ const carouselIndicatorCls = cls({
138
+ [cssClasses.CAROUSEL_INDICATOR]: true
139
+ });
140
+
141
+ if (showIndicator && children.length > 1) {
142
+ return /*#__PURE__*/React.createElement("div", {
143
+ className: carouselIndicatorCls
144
+ }, /*#__PURE__*/React.createElement(CarouselIndicator, {
145
+ type: indicatorType,
146
+ total: children.length,
147
+ activeIndex: activeIndex,
148
+ position: indicatorPosition,
149
+ trigger: trigger,
150
+ size: indicatorSize,
151
+ theme: theme,
152
+ onIndicatorChange: this.onIndicatorChange
153
+ }));
154
+ }
155
+
156
+ return null;
157
+ };
158
+
159
+ this.renderArrow = () => {
160
+ const {
161
+ children
162
+ } = this.state;
163
+ const {
164
+ showArrow,
165
+ arrowType,
166
+ theme,
167
+ arrowProps
168
+ } = this.props;
169
+ const timing = this.foundation.getSwitchingTime();
170
+
171
+ if (showArrow && children.length > 1) {
172
+ return /*#__PURE__*/React.createElement(CarouselArrow, {
173
+ type: arrowType,
174
+ theme: theme,
175
+ prev: this.prev,
176
+ next: this.next,
177
+ timing: timing,
178
+ arrowProps: arrowProps
179
+ });
180
+ }
181
+
182
+ return null;
183
+ };
184
+
185
+ this.foundation = new CarouselFoundation(this.adapter);
186
+ const defaultActiveIndex = this.foundation.getDefaultActiveIndex();
187
+ this.state = {
188
+ activeIndex: defaultActiveIndex,
189
+ children: this.getChildren(),
190
+ preIndex: defaultActiveIndex,
191
+ isReverse: false,
192
+ isInit: true
193
+ };
194
+ }
195
+
196
+ get adapter() {
197
+ return _Object$assign(_Object$assign({}, super.adapter), {
198
+ notifyChange: (activeIndex, preIndex) => {
199
+ this.props.onChange(activeIndex, preIndex);
200
+ },
201
+ setNewActiveIndex: activeIndex => {
202
+ this.setState({
203
+ activeIndex
204
+ });
205
+ },
206
+ setPreActiveIndex: preIndex => {
207
+ this.setState({
208
+ preIndex
209
+ });
210
+ },
211
+ setIsReverse: isReverse => {
212
+ this.setState({
213
+ isReverse
214
+ });
215
+ },
216
+ setIsInit: isInit => {
217
+ this.setState({
218
+ isInit
219
+ });
220
+ }
221
+ });
222
+ }
223
+
224
+ static getDerivedStateFromProps(props, state) {
225
+ const states = {};
226
+
227
+ if (!isNullOrUndefined(props.activeIndex) && props.activeIndex !== state.activeIndex) {
228
+ states.activeIndex = props.activeIndex;
229
+ }
230
+
231
+ return states;
232
+ }
233
+
234
+ componentDidMount() {
235
+ this.handleAutoPlay();
236
+ }
237
+
238
+ componentWillUnmount() {
239
+ this.foundation.destroy();
240
+ }
241
+
242
+ render() {
243
+ var _context2;
244
+
245
+ const {
246
+ animation,
247
+ className,
248
+ style,
249
+ slideDirection
250
+ } = this.props;
251
+ const {
252
+ isReverse
253
+ } = this.state;
254
+ const carouselWrapperCls = cls(className, {
255
+ [cssClasses.CAROUSEL]: true
256
+ });
257
+ return /*#__PURE__*/React.createElement("div", {
258
+ // role='listbox'
259
+ // tabIndex={0}
260
+ className: carouselWrapperCls,
261
+ style: style,
262
+ onMouseEnter: _debounce(this.handleMouseEnter, 400),
263
+ onMouseLeave: _debounce(this.handleMouseLeave, 400)
264
+ }, /*#__PURE__*/React.createElement("div", {
265
+ className: cls([_concatInstanceProperty(_context2 = "".concat(cssClasses.CAROUSEL_CONTENT, "-")).call(_context2, animation)], {
266
+ ["".concat(cssClasses.CAROUSEL_CONTENT)]: true,
267
+ ["".concat(cssClasses.CAROUSEL_CONTENT, "-reverse")]: slideDirection === 'left' ? isReverse : !isReverse
268
+ })
269
+ }, this.renderChildren()), this.renderIndicator(), this.renderArrow());
270
+ }
271
+
272
+ }
273
+
274
+ Carousel.propTypes = {
275
+ activeIndex: PropTypes.number,
276
+ animation: PropTypes.oneOf(strings.ANIMATION_MAP),
277
+ arrowProps: PropTypes.object,
278
+ autoPlay: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]),
279
+ className: PropTypes.string,
280
+ defaultActiveIndex: PropTypes.number,
281
+ indicatorPosition: PropTypes.oneOf(strings.POSITION_MAP),
282
+ indicatorSize: PropTypes.oneOf(strings.SIZE),
283
+ indicatorType: PropTypes.oneOf(strings.TYPE_MAP),
284
+ theme: PropTypes.oneOf(strings.THEME_MAP),
285
+ onChange: PropTypes.func,
286
+ arrowType: PropTypes.oneOf(strings.ARROW_MAP),
287
+ showArrow: PropTypes.bool,
288
+ showIndicator: PropTypes.bool,
289
+ slideDirection: PropTypes.oneOf(strings.DIRECTION),
290
+ speed: PropTypes.number,
291
+ style: PropTypes.object,
292
+ trigger: PropTypes.oneOf(strings.TRIGGER)
293
+ };
294
+ Carousel.defaultProps = {
295
+ children: [],
296
+ animation: 'slide',
297
+ autoPlay: true,
298
+ arrowType: 'always',
299
+ defaultActiveIndex: numbers.DEFAULT_ACTIVE_INDEX,
300
+ indicatorPosition: 'center',
301
+ indicatorSize: 'small',
302
+ indicatorType: 'dot',
303
+ theme: 'light',
304
+ onChange: () => undefined,
305
+ showArrow: true,
306
+ showIndicator: true,
307
+ slideDirection: 'left',
308
+ speed: numbers.DEFAULT_SPEED,
309
+ trigger: 'click'
310
+ };
311
+ export default Carousel;
@@ -0,0 +1,62 @@
1
+ import React, { ReactNode } from "react";
2
+ import { strings } from '@douyinfe/semi-foundation/lib/es/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 @@
1
+ export {};
@@ -84,7 +84,7 @@ class Cascader extends BaseComponent {
84
84
  e.preventDefault();
85
85
  this.handleTagRemove(e, keyEntities[nodeKey].valuePath);
86
86
  }
87
- }, displayProp === 'label' && keyEntities[nodeKey].data.label, displayProp === 'value' && keyEntities[nodeKey].data.value);
87
+ }, keyEntities[nodeKey].data[displayProp]);
88
88
  }
89
89
  }
90
90
 
package/lib/es/index.d.ts CHANGED
@@ -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/es/index.js CHANGED
@@ -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';
@@ -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;