@douyinfe/semi-ui 2.9.1 → 2.10.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 (74) hide show
  1. package/banner/_story/banner.stories.js +62 -1
  2. package/banner/index.tsx +5 -5
  3. package/button/buttonGroup.tsx +2 -2
  4. package/carousel/CarouselArrow.tsx +62 -0
  5. package/carousel/CarouselIndicator.tsx +83 -0
  6. package/carousel/__test__/carousel.test.js +159 -0
  7. package/carousel/_story/carousel.stories.js +486 -0
  8. package/carousel/index.tsx +292 -0
  9. package/carousel/interface.ts +63 -0
  10. package/cascader/index.tsx +1 -2
  11. package/datePicker/monthsGrid.tsx +8 -8
  12. package/dist/css/semi.css +342 -0
  13. package/dist/css/semi.min.css +1 -1
  14. package/dist/umd/semi-ui.js +1238 -266
  15. package/dist/umd/semi-ui.js.map +1 -1
  16. package/dist/umd/semi-ui.min.js +1 -1
  17. package/dist/umd/semi-ui.min.js.map +1 -1
  18. package/form/baseForm.tsx +10 -1
  19. package/form/hoc/withField.tsx +17 -5
  20. package/index.ts +2 -0
  21. package/inputNumber/__test__/inputNumber.test.js +40 -3
  22. package/inputNumber/_story/inputNumber.stories.js +56 -1
  23. package/inputNumber/index.tsx +22 -14
  24. package/lib/cjs/banner/index.js +11 -5
  25. package/lib/cjs/button/buttonGroup.d.ts +1 -1
  26. package/lib/cjs/carousel/CarouselArrow.d.ts +8 -0
  27. package/lib/cjs/carousel/CarouselArrow.js +88 -0
  28. package/lib/cjs/carousel/CarouselIndicator.d.ts +23 -0
  29. package/lib/cjs/carousel/CarouselIndicator.js +145 -0
  30. package/lib/cjs/carousel/index.d.ts +58 -0
  31. package/lib/cjs/carousel/index.js +343 -0
  32. package/lib/cjs/carousel/interface.d.ts +61 -0
  33. package/lib/cjs/carousel/interface.js +7 -0
  34. package/lib/cjs/cascader/index.js +1 -1
  35. package/lib/cjs/datePicker/monthsGrid.js +6 -6
  36. package/lib/cjs/form/baseForm.d.ts +1 -0
  37. package/lib/cjs/form/baseForm.js +10 -1
  38. package/lib/cjs/form/hoc/withField.js +8 -1
  39. package/lib/cjs/index.d.ts +1 -0
  40. package/lib/cjs/index.js +9 -0
  41. package/lib/cjs/inputNumber/index.d.ts +2 -6
  42. package/lib/cjs/inputNumber/index.js +27 -11
  43. package/lib/cjs/switch/index.d.ts +3 -0
  44. package/lib/cjs/switch/index.js +26 -6
  45. package/lib/cjs/transfer/index.js +5 -5
  46. package/lib/cjs/treeSelect/index.js +1 -1
  47. package/lib/es/banner/index.js +11 -5
  48. package/lib/es/button/buttonGroup.d.ts +1 -1
  49. package/lib/es/carousel/CarouselArrow.d.ts +8 -0
  50. package/lib/es/carousel/CarouselArrow.js +70 -0
  51. package/lib/es/carousel/CarouselIndicator.d.ts +23 -0
  52. package/lib/es/carousel/CarouselIndicator.js +125 -0
  53. package/lib/es/carousel/index.d.ts +58 -0
  54. package/lib/es/carousel/index.js +309 -0
  55. package/lib/es/carousel/interface.d.ts +61 -0
  56. package/lib/es/carousel/interface.js +1 -0
  57. package/lib/es/cascader/index.js +1 -1
  58. package/lib/es/datePicker/monthsGrid.js +7 -7
  59. package/lib/es/form/baseForm.d.ts +1 -0
  60. package/lib/es/form/baseForm.js +10 -1
  61. package/lib/es/form/hoc/withField.js +8 -1
  62. package/lib/es/index.d.ts +1 -0
  63. package/lib/es/index.js +1 -0
  64. package/lib/es/inputNumber/index.d.ts +2 -6
  65. package/lib/es/inputNumber/index.js +26 -11
  66. package/lib/es/switch/index.d.ts +3 -0
  67. package/lib/es/switch/index.js +26 -6
  68. package/lib/es/transfer/index.js +1 -1
  69. package/lib/es/treeSelect/index.js +1 -1
  70. package/package.json +9 -9
  71. package/switch/index.tsx +20 -3
  72. package/tagInput/__test__/tagInput.test.js +11 -11
  73. package/transfer/index.tsx +1 -1
  74. package/treeSelect/index.tsx +1 -1
@@ -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
 
@@ -505,7 +505,7 @@ class MonthsGrid extends _baseComponent.default {
505
505
  const dateFormat = this.foundation.getValidDateFormat();
506
506
  let startDate, endDate;
507
507
 
508
- if (type === 'dateTimeRange' && rangeStart && rangeEnd && (0, _dateFns.isSameDay)(startDate = (0, _parser.compatiableParse)(rangeStart, dateFormat, undefined, dateFnsLocale), endDate = (0, _parser.compatiableParse)(rangeEnd, dateFormat, undefined, dateFnsLocale))) {
508
+ if (type === 'dateTimeRange' && rangeStart && rangeEnd && (0, _dateFns.isSameDay)(startDate = (0, _parser.compatibleParse)(rangeStart, dateFormat, undefined, dateFnsLocale), endDate = (0, _parser.compatibleParse)(rangeEnd, dateFormat, undefined, dateFnsLocale))) {
509
509
  if (panelType === _constants.strings.PANEL_TYPE_RIGHT) {
510
510
  rangeStart && (restProps.startDate = startDate);
511
511
  } else {
@@ -591,10 +591,10 @@ class MonthsGrid extends _baseComponent.default {
591
591
 
592
592
  if (panelType === _constants.strings.PANEL_TYPE_LEFT) {
593
593
  panelDetail = monthLeft;
594
- dateText = rangeStart ? (0, _dateFns.format)((0, _parser.compatiableParse)(rangeStart, dateFormat, undefined, dateFnsLocale), FORMAT_SWITCH_DATE) : '';
594
+ dateText = rangeStart ? (0, _dateFns.format)((0, _parser.compatibleParse)(rangeStart, dateFormat, undefined, dateFnsLocale), FORMAT_SWITCH_DATE) : '';
595
595
  } else {
596
596
  panelDetail = monthRight;
597
- dateText = rangeEnd ? (0, _dateFns.format)((0, _parser.compatiableParse)(rangeEnd, dateFormat, undefined, dateFnsLocale), FORMAT_SWITCH_DATE) : '';
597
+ dateText = rangeEnd ? (0, _dateFns.format)((0, _parser.compatibleParse)(rangeEnd, dateFormat, undefined, dateFnsLocale), FORMAT_SWITCH_DATE) : '';
598
598
  }
599
599
 
600
600
  const {
@@ -603,7 +603,7 @@ class MonthsGrid extends _baseComponent.default {
603
603
  } = panelDetail;
604
604
  const monthText = showDate ? (0, _dateFns.format)(showDate, FORMAT_SWITCH_DATE) : '';
605
605
  const timeText = showDate ? (0, _dateFns.format)(showDate, formatTimePicker) : '';
606
- const showSwithIcon = (0, _includes.default)(_context3 = ['default']).call(_context3, density);
606
+ const showSwitchIcon = (0, _includes.default)(_context3 = ['default']).call(_context3, density);
607
607
  const switchCls = (0, _classnames.default)("".concat(prefixCls, "-switch"));
608
608
  const dateCls = (0, _classnames.default)({
609
609
  ["".concat(prefixCls, "-switch-date")]: true,
@@ -623,7 +623,7 @@ class MonthsGrid extends _baseComponent.default {
623
623
  "aria-label": "Switch to date panel",
624
624
  className: dateCls,
625
625
  onClick: e => this.foundation.showDatePanel(panelType)
626
- }, showSwithIcon && /*#__PURE__*/_react.default.createElement(_semiIcons.IconCalendar, {
626
+ }, showSwitchIcon && /*#__PURE__*/_react.default.createElement(_semiIcons.IconCalendar, {
627
627
  "aria-hidden": true
628
628
  }), /*#__PURE__*/_react.default.createElement("span", {
629
629
  className: textCls
@@ -632,7 +632,7 @@ class MonthsGrid extends _baseComponent.default {
632
632
  "aria-label": "Switch to time panel",
633
633
  className: timeCls,
634
634
  onClick: e => this.foundation.showTimePicker(panelType, true)
635
- }, showSwithIcon && /*#__PURE__*/_react.default.createElement(_semiIcons.IconClock, {
635
+ }, showSwitchIcon && /*#__PURE__*/_react.default.createElement(_semiIcons.IconClock, {
636
636
  "aria-hidden": true
637
637
  }), /*#__PURE__*/_react.default.createElement("span", {
638
638
  className: textCls
@@ -147,6 +147,7 @@ declare class Form extends BaseComponent<BaseFormProps, BaseFormState> {
147
147
  static Section: typeof Section;
148
148
  formApi: FormApi;
149
149
  constructor(props: BaseFormProps);
150
+ componentDidMount(): void;
150
151
  componentWillUnmount(): void;
151
152
  get adapter(): BaseFormAdapter<BaseFormProps, BaseFormState>;
152
153
  get content(): React.ReactNode;
@@ -85,7 +85,7 @@ class Form extends _baseComponent.default {
85
85
 
86
86
  super(props);
87
87
  this.state = {
88
- formId: (0, _uuid.getUuidv4)()
88
+ formId: ''
89
89
  };
90
90
  (0, _warning.default)(Boolean(props.component && props.render), '[Semi Form] You should not use <Form component> and <Form render> in ths same time; <Form render> will be ignored');
91
91
  (0, _warning.default)(props.component && props.children && !(0, _reactUtils.isEmptyChildren)(props.children), '[Semi Form] You should not use <Form component> and <Form>{children}</Form> in ths same time; <Form>{children}</Form> will be ignored');
@@ -100,6 +100,10 @@ class Form extends _baseComponent.default {
100
100
  }
101
101
  }
102
102
 
103
+ componentDidMount() {
104
+ this.foundation.init();
105
+ }
106
+
103
107
  componentWillUnmount() {
104
108
  this.foundation.destroy();
105
109
  this.foundation = null;
@@ -127,6 +131,11 @@ class Form extends _baseComponent.default {
127
131
  notifyReset: () => {
128
132
  this.props.onReset();
129
133
  },
134
+ initFormId: () => {
135
+ this.setState({
136
+ formId: (0, _uuid.getUuidv4)()
137
+ });
138
+ },
130
139
  getInitValues: () => this.props.initValues,
131
140
  getFormProps: keys => {
132
141
  if (typeof keys === 'undefined') {
@@ -413,9 +413,16 @@ function withField(Component, opts) {
413
413
  // eslint-disable-next-line @typescript-eslint/no-empty-function
414
414
  return () => {};
415
415
  } // log('register: ' + field);
416
+ // field value may change after field component mounted, we use ref value here to get changed value
416
417
 
417
418
 
418
- updater.register(field, fieldState, {
419
+ const refValue = getVal();
420
+ updater.register(field, {
421
+ value: refValue,
422
+ error,
423
+ touched,
424
+ status
425
+ }, {
419
426
  field,
420
427
  fieldApi,
421
428
  keepState,
@@ -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"));
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { InputProps } from '../input';
4
- import InputNumberFoundation, { InputNumberAdapter } from '@douyinfe/semi-foundation/lib/cjs/inputNumber/foundation';
4
+ import InputNumberFoundation, { BaseInputNumberState, InputNumberAdapter } from '@douyinfe/semi-foundation/lib/cjs/inputNumber/foundation';
5
5
  import BaseComponent from '../_base/baseComponent';
6
6
  import { strings } from '@douyinfe/semi-foundation/lib/cjs/inputNumber/constants';
7
7
  import '@douyinfe/semi-foundation/lib/cjs/inputNumber/inputNumber.css';
@@ -40,11 +40,7 @@ export interface InputNumberProps extends InputProps {
40
40
  onNumberChange?: (value: number, e?: React.ChangeEvent) => void;
41
41
  onUpClick?: (value: string, e: React.MouseEvent<HTMLButtonElement>) => void;
42
42
  }
43
- export interface InputNumberState {
44
- value?: number | string;
45
- number?: number | null;
46
- focusing?: boolean;
47
- hovering?: boolean;
43
+ export interface InputNumberState extends BaseInputNumberState {
48
44
  }
49
45
  declare class InputNumber extends BaseComponent<InputNumberProps, InputNumberState> {
50
46
  static propTypes: {
@@ -24,6 +24,8 @@ var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-sta
24
24
 
25
25
  var _noop2 = _interopRequireDefault(require("lodash/noop"));
26
26
 
27
+ var _isString2 = _interopRequireDefault(require("lodash/isString"));
28
+
27
29
  var _isNaN2 = _interopRequireDefault(require("lodash/isNaN"));
28
30
 
29
31
  var _react = _interopRequireDefault(require("react"));
@@ -300,6 +302,9 @@ class InputNumber extends _baseComponent.default {
300
302
  },
301
303
  setClickUpOrDown: value => {
302
304
  this.clickUpOrDown = value;
305
+ },
306
+ updateStates: (states, callback) => {
307
+ this.setState(states, callback);
303
308
  }
304
309
  });
305
310
  }
@@ -311,6 +316,7 @@ class InputNumber extends _baseComponent.default {
311
316
  const {
312
317
  focusing
313
318
  } = this.state;
319
+ let newValue;
314
320
  /**
315
321
  * To determine whether the front and back are equal
316
322
  * NaN need to check whether both are NaN
@@ -318,8 +324,9 @@ class InputNumber extends _baseComponent.default {
318
324
 
319
325
  if (value !== prevProps.value && !(0, _isBothNaN.default)(value, prevProps.value)) {
320
326
  if ((0, _isNullOrUndefined.default)(value) || value === '') {
321
- this.setState({
322
- value: '',
327
+ newValue = '';
328
+ this.foundation.updateStates({
329
+ value: newValue,
323
330
  number: null
324
331
  });
325
332
  } else {
@@ -375,33 +382,42 @@ class InputNumber extends _baseComponent.default {
375
382
 
376
383
  if (this.clickUpOrDown) {
377
384
  obj.value = this.foundation.doFormat(valueStr, true);
385
+ newValue = obj.value;
378
386
  }
379
387
 
380
- this.setState(obj, () => this.adapter.restoreCursor());
388
+ this.foundation.updateStates(obj, () => this.adapter.restoreCursor());
381
389
  } else if (!(0, _isNaN2.default)(toNum)) {
382
390
  // Update input content when controlled input is illegal and not NaN
383
- this.setState({
384
- value: this.foundation.doFormat(toNum, false)
391
+ newValue = this.foundation.doFormat(toNum, false);
392
+ this.foundation.updateStates({
393
+ value: newValue
385
394
  });
386
395
  } else {
387
396
  // Update input content when controlled input NaN
388
- this.setState({
389
- value: this.foundation.doFormat(valueStr, false)
397
+ newValue = this.foundation.doFormat(valueStr, false);
398
+ this.foundation.updateStates({
399
+ value: newValue
390
400
  });
391
401
  }
392
402
  } else if (this.foundation.isValidNumber(parsedNum)) {
393
- this.setState({
403
+ newValue = this.foundation.doFormat(parsedNum);
404
+ this.foundation.updateStates({
394
405
  number: parsedNum,
395
- value: this.foundation.doFormat(parsedNum)
406
+ value: newValue
396
407
  });
397
408
  } else {
398
409
  // Invalid digital analog blurring effect instead of controlled failure
399
- this.setState({
410
+ newValue = '';
411
+ this.foundation.updateStates({
400
412
  number: null,
401
- value: ''
413
+ value: newValue
402
414
  });
403
415
  }
404
416
  }
417
+
418
+ if ((0, _isString2.default)(newValue) && newValue !== String(this.props.value)) {
419
+ this.foundation.notifyChange(newValue, null);
420
+ }
405
421
  }
406
422
 
407
423
  if (!this.clickUpOrDown) {