@douyinfe/semi-ui 2.10.0-alpha.0 → 2.10.1

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 (130) hide show
  1. package/badge/_story/badge.stories.js +34 -2
  2. package/banner/_story/banner.stories.js +62 -1
  3. package/banner/index.tsx +5 -5
  4. package/button/buttonGroup.tsx +2 -2
  5. package/carousel/CarouselArrow.tsx +62 -0
  6. package/carousel/CarouselIndicator.tsx +83 -0
  7. package/carousel/__test__/carousel.test.js +159 -0
  8. package/carousel/_story/carousel.stories.js +486 -0
  9. package/carousel/index.tsx +292 -0
  10. package/carousel/interface.ts +63 -0
  11. package/cascader/index.tsx +1 -2
  12. package/checkbox/checkbox.tsx +8 -18
  13. package/datePicker/monthsGrid.tsx +8 -8
  14. package/dist/css/semi.css +343 -0
  15. package/dist/css/semi.min.css +1 -1
  16. package/dist/umd/semi-ui.js +23525 -22602
  17. package/dist/umd/semi-ui.js.map +1 -1
  18. package/dist/umd/semi-ui.min.js +1 -1
  19. package/dist/umd/semi-ui.min.js.map +1 -1
  20. package/form/baseForm.tsx +10 -1
  21. package/form/hoc/withField.tsx +25 -10
  22. package/index.ts +2 -0
  23. package/inputNumber/__test__/inputNumber.test.js +40 -3
  24. package/inputNumber/_story/inputNumber.stories.js +56 -1
  25. package/inputNumber/index.tsx +22 -14
  26. package/lib/cjs/_portal/index.d.ts +1 -1
  27. package/lib/cjs/banner/index.js +11 -5
  28. package/lib/cjs/button/buttonGroup.d.ts +1 -1
  29. package/lib/cjs/carousel/CarouselArrow.d.ts +8 -0
  30. package/lib/cjs/carousel/CarouselArrow.js +88 -0
  31. package/lib/cjs/carousel/CarouselIndicator.d.ts +23 -0
  32. package/lib/cjs/carousel/CarouselIndicator.js +145 -0
  33. package/lib/cjs/carousel/index.d.ts +58 -0
  34. package/lib/cjs/carousel/index.js +343 -0
  35. package/lib/cjs/carousel/interface.d.ts +61 -0
  36. package/lib/cjs/carousel/interface.js +7 -0
  37. package/lib/cjs/cascader/index.js +1 -1
  38. package/lib/cjs/checkbox/checkbox.d.ts +0 -4
  39. package/lib/cjs/checkbox/checkbox.js +13 -25
  40. package/lib/cjs/datePicker/dateInput.d.ts +1 -1
  41. package/lib/cjs/datePicker/datePicker.d.ts +1 -1
  42. package/lib/cjs/datePicker/insetInput.d.ts +1 -0
  43. package/lib/cjs/datePicker/monthsGrid.d.ts +1 -1
  44. package/lib/cjs/datePicker/monthsGrid.js +6 -6
  45. package/lib/cjs/dropdown/dropdownMenu.d.ts +1 -0
  46. package/lib/cjs/form/baseForm.d.ts +2 -1
  47. package/lib/cjs/form/baseForm.js +10 -1
  48. package/lib/cjs/form/field.d.ts +1 -1
  49. package/lib/cjs/form/hoc/withField.js +14 -5
  50. package/lib/cjs/index.d.ts +1 -0
  51. package/lib/cjs/index.js +9 -0
  52. package/lib/cjs/inputNumber/index.d.ts +2 -6
  53. package/lib/cjs/inputNumber/index.js +27 -11
  54. package/lib/cjs/modal/useModal/index.d.ts +1 -0
  55. package/lib/cjs/notification/useNotification/index.d.ts +1 -0
  56. package/lib/cjs/radio/radio.d.ts +1 -5
  57. package/lib/cjs/radio/radio.js +12 -26
  58. package/lib/cjs/radio/radioGroup.d.ts +1 -1
  59. package/lib/cjs/scrollList/scrollItem.js +1 -1
  60. package/lib/cjs/switch/index.d.ts +3 -0
  61. package/lib/cjs/switch/index.js +26 -6
  62. package/lib/cjs/timePicker/Combobox.d.ts +1 -0
  63. package/lib/cjs/timePicker/TimePicker.d.ts +2 -2
  64. package/lib/cjs/timePicker/TimeShape.d.ts +1 -1
  65. package/lib/cjs/timePicker/index.d.ts +2 -2
  66. package/lib/cjs/toast/useToast/index.d.ts +1 -0
  67. package/lib/cjs/tooltip/index.d.ts +1 -1
  68. package/lib/cjs/tooltip/index.js +11 -13
  69. package/lib/cjs/transfer/index.js +5 -5
  70. package/lib/cjs/treeSelect/index.js +1 -1
  71. package/lib/cjs/typography/title.d.ts +1 -1
  72. package/lib/cjs/upload/index.d.ts +1 -1
  73. package/lib/es/_portal/index.d.ts +1 -1
  74. package/lib/es/banner/index.js +11 -5
  75. package/lib/es/button/buttonGroup.d.ts +1 -1
  76. package/lib/es/carousel/CarouselArrow.d.ts +8 -0
  77. package/lib/es/carousel/CarouselArrow.js +70 -0
  78. package/lib/es/carousel/CarouselIndicator.d.ts +23 -0
  79. package/lib/es/carousel/CarouselIndicator.js +125 -0
  80. package/lib/es/carousel/index.d.ts +58 -0
  81. package/lib/es/carousel/index.js +309 -0
  82. package/lib/es/carousel/interface.d.ts +61 -0
  83. package/lib/es/carousel/interface.js +1 -0
  84. package/lib/es/cascader/index.js +1 -1
  85. package/lib/es/checkbox/checkbox.d.ts +0 -4
  86. package/lib/es/checkbox/checkbox.js +13 -25
  87. package/lib/es/datePicker/dateInput.d.ts +1 -1
  88. package/lib/es/datePicker/datePicker.d.ts +1 -1
  89. package/lib/es/datePicker/insetInput.d.ts +1 -0
  90. package/lib/es/datePicker/monthsGrid.d.ts +1 -1
  91. package/lib/es/datePicker/monthsGrid.js +7 -7
  92. package/lib/es/dropdown/dropdownMenu.d.ts +1 -0
  93. package/lib/es/form/baseForm.d.ts +2 -1
  94. package/lib/es/form/baseForm.js +10 -1
  95. package/lib/es/form/field.d.ts +1 -1
  96. package/lib/es/form/hoc/withField.js +14 -5
  97. package/lib/es/index.d.ts +1 -0
  98. package/lib/es/index.js +1 -0
  99. package/lib/es/inputNumber/index.d.ts +2 -6
  100. package/lib/es/inputNumber/index.js +26 -11
  101. package/lib/es/modal/useModal/index.d.ts +1 -0
  102. package/lib/es/notification/useNotification/index.d.ts +1 -0
  103. package/lib/es/radio/radio.d.ts +1 -5
  104. package/lib/es/radio/radio.js +12 -26
  105. package/lib/es/radio/radioGroup.d.ts +1 -1
  106. package/lib/es/scrollList/scrollItem.js +1 -1
  107. package/lib/es/switch/index.d.ts +3 -0
  108. package/lib/es/switch/index.js +26 -6
  109. package/lib/es/timePicker/Combobox.d.ts +1 -0
  110. package/lib/es/timePicker/TimePicker.d.ts +2 -2
  111. package/lib/es/timePicker/TimeShape.d.ts +1 -1
  112. package/lib/es/timePicker/index.d.ts +2 -2
  113. package/lib/es/toast/useToast/index.d.ts +1 -0
  114. package/lib/es/tooltip/index.d.ts +1 -1
  115. package/lib/es/tooltip/index.js +11 -13
  116. package/lib/es/transfer/index.js +1 -1
  117. package/lib/es/treeSelect/index.js +1 -1
  118. package/lib/es/typography/title.d.ts +1 -1
  119. package/lib/es/upload/index.d.ts +1 -1
  120. package/package.json +9 -9
  121. package/popover/_story/popover.stories.js +38 -2
  122. package/radio/radio.tsx +7 -17
  123. package/scrollList/scrollItem.tsx +1 -1
  124. package/switch/index.tsx +20 -3
  125. package/tagInput/__test__/tagInput.test.js +11 -11
  126. package/timePicker/TimePicker.tsx +1 -1
  127. package/timePicker/_story/timepicker.stories.js +20 -1
  128. package/tooltip/index.tsx +11 -8
  129. package/transfer/index.tsx +1 -1
  130. package/treeSelect/index.tsx +1 -1
@@ -0,0 +1,145 @@
1
+ "use strict";
2
+
3
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
4
+
5
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
6
+
7
+ _Object$defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+
11
+ exports.default = void 0;
12
+
13
+ var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
14
+
15
+ var _getOwnPropertySymbols = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols"));
16
+
17
+ var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
18
+
19
+ var _assign = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/assign"));
20
+
21
+ var _react = _interopRequireDefault(require("react"));
22
+
23
+ var _classnames = _interopRequireDefault(require("classnames"));
24
+
25
+ var _propTypes = _interopRequireDefault(require("prop-types"));
26
+
27
+ var _constants = require("@douyinfe/semi-foundation/lib/cjs/carousel/constants");
28
+
29
+ var _getDataAttr = _interopRequireDefault(require("@douyinfe/semi-foundation/lib/cjs/utils/getDataAttr"));
30
+
31
+ var __rest = void 0 && (void 0).__rest || function (s, e) {
32
+ var t = {};
33
+
34
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && (0, _indexOf.default)(e).call(e, p) < 0) t[p] = s[p];
35
+
36
+ if (s != null && typeof _getOwnPropertySymbols.default === "function") for (var i = 0, p = (0, _getOwnPropertySymbols.default)(s); i < p.length; i++) {
37
+ if ((0, _indexOf.default)(e).call(e, p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
38
+ }
39
+ return t;
40
+ };
41
+ /* eslint-disable jsx-a11y/no-static-element-interactions */
42
+
43
+ /* eslint-disable jsx-a11y/click-events-have-key-events */
44
+
45
+
46
+ class CarouselIndicator extends _react.default.PureComponent {
47
+ constructor() {
48
+ super(...arguments);
49
+
50
+ this.onIndicatorChange = activeIndex => {
51
+ this.props.onIndicatorChange(activeIndex);
52
+ };
53
+
54
+ this.handleIndicatorClick = activeIndex => {
55
+ const {
56
+ trigger
57
+ } = this.props;
58
+
59
+ if (trigger === 'click') {
60
+ this.onIndicatorChange(activeIndex);
61
+ }
62
+ };
63
+
64
+ this.handleIndicatorHover = activeIndex => {
65
+ const {
66
+ trigger
67
+ } = this.props;
68
+
69
+ if (trigger === 'hover') {
70
+ this.onIndicatorChange(activeIndex);
71
+ }
72
+ };
73
+ }
74
+
75
+ renderIndicatorContent() {
76
+ const {
77
+ total,
78
+ theme,
79
+ size,
80
+ activeIndex
81
+ } = this.props;
82
+ const indicatorContent = [];
83
+
84
+ for (let i = 0; i < total; i++) {
85
+ var _context, _context2;
86
+
87
+ indicatorContent.push( /*#__PURE__*/_react.default.createElement("span", {
88
+ // role='none'
89
+ key: i,
90
+ "data-index": i,
91
+ className: (0, _classnames.default)(["".concat(_constants.cssClasses.CAROUSEL_INDICATOR, "-item")], {
92
+ ["".concat(_constants.cssClasses.CAROUSEL_INDICATOR, "-item-active")]: i === activeIndex,
93
+ [(0, _concat.default)(_context = "".concat(_constants.cssClasses.CAROUSEL_INDICATOR, "-item-")).call(_context, theme)]: theme,
94
+ [(0, _concat.default)(_context2 = "".concat(_constants.cssClasses.CAROUSEL_INDICATOR, "-item-")).call(_context2, size)]: size
95
+ }),
96
+ onClick: () => this.handleIndicatorClick(i),
97
+ onMouseEnter: () => this.handleIndicatorHover(i)
98
+ }));
99
+ }
100
+
101
+ return indicatorContent;
102
+ }
103
+
104
+ render() {
105
+ var _context3, _context4;
106
+
107
+ const _a = this.props,
108
+ {
109
+ type,
110
+ size,
111
+ theme,
112
+ style,
113
+ className,
114
+ position
115
+ } = _a,
116
+ restProps = __rest(_a, ["type", "size", "theme", "style", "className", "position"]);
117
+
118
+ const classNames = (0, _classnames.default)(className, {
119
+ [_constants.cssClasses.CAROUSEL_INDICATOR]: true,
120
+ [(0, _concat.default)(_context3 = "".concat(_constants.cssClasses.CAROUSEL_INDICATOR, "-")).call(_context3, type)]: type,
121
+ [(0, _concat.default)(_context4 = "".concat(_constants.cssClasses.CAROUSEL_INDICATOR, "-")).call(_context4, position)]: position
122
+ });
123
+ const indicatorContent = this.renderIndicatorContent();
124
+ return /*#__PURE__*/_react.default.createElement("div", (0, _assign.default)({
125
+ className: classNames,
126
+ style: style
127
+ }, (0, _getDataAttr.default)(restProps)), indicatorContent);
128
+ }
129
+
130
+ }
131
+
132
+ CarouselIndicator.propTypes = {
133
+ activeKey: _propTypes.default.number,
134
+ className: _propTypes.default.string,
135
+ position: _propTypes.default.oneOf(_constants.strings.POSITION_MAP),
136
+ size: _propTypes.default.oneOf(_constants.strings.SIZE),
137
+ style: _propTypes.default.object,
138
+ theme: _propTypes.default.oneOf(_constants.strings.THEME_MAP),
139
+ total: _propTypes.default.number,
140
+ onIndicatorChange: _propTypes.default.func,
141
+ type: _propTypes.default.oneOf(_constants.strings.TYPE_MAP),
142
+ trigger: _propTypes.default.oneOf(_constants.strings.TRIGGER)
143
+ };
144
+ var _default = CarouselIndicator;
145
+ exports.default = _default;
@@ -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/cjs/carousel/foundation';
6
+ import '@douyinfe/semi-foundation/lib/cjs/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,343 @@
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.onIndicatorChange(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
+
203
+ if (showArrow && children.length > 1) {
204
+ return /*#__PURE__*/_react.default.createElement(_CarouselArrow.default, {
205
+ type: arrowType,
206
+ theme: theme,
207
+ prev: this.prev,
208
+ next: this.next,
209
+ arrowProps: arrowProps
210
+ });
211
+ }
212
+
213
+ return null;
214
+ };
215
+
216
+ this.foundation = new _foundation.default(this.adapter);
217
+ const defaultActiveIndex = this.foundation.getDefaultActiveIndex();
218
+ this.state = {
219
+ activeIndex: defaultActiveIndex,
220
+ children: this.getChildren(),
221
+ preIndex: defaultActiveIndex,
222
+ isReverse: false,
223
+ isInit: true
224
+ };
225
+ }
226
+
227
+ get adapter() {
228
+ return (0, _assign.default)((0, _assign.default)({}, super.adapter), {
229
+ notifyChange: (activeIndex, preIndex) => {
230
+ this.props.onChange(activeIndex, preIndex);
231
+ },
232
+ setNewActiveIndex: activeIndex => {
233
+ this.setState({
234
+ activeIndex
235
+ });
236
+ },
237
+ setPreActiveIndex: preIndex => {
238
+ this.setState({
239
+ preIndex
240
+ });
241
+ },
242
+ setIsReverse: isReverse => {
243
+ this.setState({
244
+ isReverse
245
+ });
246
+ },
247
+ setIsInit: isInit => {
248
+ this.setState({
249
+ isInit
250
+ });
251
+ }
252
+ });
253
+ }
254
+
255
+ static getDerivedStateFromProps(props, state) {
256
+ const states = {};
257
+
258
+ if (!(0, _isNullOrUndefined.default)(props.activeIndex) && props.activeIndex !== state.activeIndex) {
259
+ states.activeIndex = props.activeIndex;
260
+ }
261
+
262
+ return states;
263
+ }
264
+
265
+ componentDidMount() {
266
+ this.handleAutoPlay();
267
+ }
268
+
269
+ componentWillUnmount() {
270
+ this.foundation.destroy();
271
+ }
272
+
273
+ render() {
274
+ var _context2;
275
+
276
+ const {
277
+ animation,
278
+ className,
279
+ style,
280
+ slideDirection
281
+ } = this.props;
282
+ const {
283
+ isReverse
284
+ } = this.state;
285
+ const carouselWrapperCls = (0, _classnames.default)(className, {
286
+ [_constants.cssClasses.CAROUSEL]: true
287
+ });
288
+ return /*#__PURE__*/_react.default.createElement("div", {
289
+ // role='listbox'
290
+ // tabIndex={0}
291
+ className: carouselWrapperCls,
292
+ style: style,
293
+ onMouseEnter: (0, _debounce2.default)(this.handleMouseEnter, 400),
294
+ onMouseLeave: (0, _debounce2.default)(this.handleMouseLeave, 400)
295
+ }, /*#__PURE__*/_react.default.createElement("div", {
296
+ className: (0, _classnames.default)([(0, _concat.default)(_context2 = "".concat(_constants.cssClasses.CAROUSEL_CONTENT, "-")).call(_context2, animation)], {
297
+ ["".concat(_constants.cssClasses.CAROUSEL_CONTENT)]: true,
298
+ ["".concat(_constants.cssClasses.CAROUSEL_CONTENT, "-reverse")]: slideDirection === 'left' ? isReverse : !isReverse
299
+ })
300
+ }, this.renderChildren()), this.renderIndicator(), this.renderArrow());
301
+ }
302
+
303
+ }
304
+
305
+ Carousel.propTypes = {
306
+ activeIndex: _propTypes.default.number,
307
+ animation: _propTypes.default.oneOf(_constants.strings.ANIMATION_MAP),
308
+ arrowProps: _propTypes.default.object,
309
+ autoPlay: _propTypes.default.oneOfType([_propTypes.default.bool, _propTypes.default.object]),
310
+ className: _propTypes.default.string,
311
+ defaultActiveIndex: _propTypes.default.number,
312
+ indicatorPosition: _propTypes.default.oneOf(_constants.strings.POSITION_MAP),
313
+ indicatorSize: _propTypes.default.oneOf(_constants.strings.SIZE),
314
+ indicatorType: _propTypes.default.oneOf(_constants.strings.TYPE_MAP),
315
+ theme: _propTypes.default.oneOf(_constants.strings.THEME_MAP),
316
+ onChange: _propTypes.default.func,
317
+ arrowType: _propTypes.default.oneOf(_constants.strings.ARROW_MAP),
318
+ showArrow: _propTypes.default.bool,
319
+ showIndicator: _propTypes.default.bool,
320
+ slideDirection: _propTypes.default.oneOf(_constants.strings.DIRECTION),
321
+ speed: _propTypes.default.number,
322
+ style: _propTypes.default.object,
323
+ trigger: _propTypes.default.oneOf(_constants.strings.TRIGGER)
324
+ };
325
+ Carousel.defaultProps = {
326
+ children: [],
327
+ animation: 'slide',
328
+ autoPlay: true,
329
+ arrowType: 'always',
330
+ defaultActiveIndex: _constants.numbers.DEFAULT_ACTIVE_INDEX,
331
+ indicatorPosition: 'center',
332
+ indicatorSize: 'small',
333
+ indicatorType: 'dot',
334
+ theme: 'light',
335
+ onChange: () => undefined,
336
+ showArrow: true,
337
+ showIndicator: true,
338
+ slideDirection: 'left',
339
+ speed: _constants.numbers.DEFAULT_SPEED,
340
+ trigger: 'click'
341
+ };
342
+ var _default = Carousel;
343
+ exports.default = _default;
@@ -0,0 +1,61 @@
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?: (tagetIndex: number) => 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
+ }
54
+ export interface ArrowButton {
55
+ props?: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
56
+ children?: React.ReactNode;
57
+ }
58
+ export interface ArrowProps {
59
+ leftArrow?: ArrowButton;
60
+ rightArrow?: ArrowButton;
61
+ }
@@ -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
 
@@ -22,13 +22,9 @@ export interface CheckboxProps extends BaseCheckboxProps {
22
22
  'aria-label'?: React.AriaAttributes['aria-label'];
23
23
  role?: React.HTMLAttributes<HTMLSpanElement>['role'];
24
24
  tabIndex?: number;
25
- addonId?: string;
26
- extraId?: string;
27
25
  }
28
26
  interface CheckboxState {
29
27
  checked: boolean;
30
- addonId?: string;
31
- extraId?: string;
32
28
  }
33
29
  declare class Checkbox extends BaseComponent<CheckboxProps, CheckboxState> {
34
30
  static contextType: React.Context<CheckboxContextType>;