@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,309 @@
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.onIndicatorChange(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
+
170
+ if (showArrow && children.length > 1) {
171
+ return /*#__PURE__*/React.createElement(CarouselArrow, {
172
+ type: arrowType,
173
+ theme: theme,
174
+ prev: this.prev,
175
+ next: this.next,
176
+ arrowProps: arrowProps
177
+ });
178
+ }
179
+
180
+ return null;
181
+ };
182
+
183
+ this.foundation = new CarouselFoundation(this.adapter);
184
+ const defaultActiveIndex = this.foundation.getDefaultActiveIndex();
185
+ this.state = {
186
+ activeIndex: defaultActiveIndex,
187
+ children: this.getChildren(),
188
+ preIndex: defaultActiveIndex,
189
+ isReverse: false,
190
+ isInit: true
191
+ };
192
+ }
193
+
194
+ get adapter() {
195
+ return _Object$assign(_Object$assign({}, super.adapter), {
196
+ notifyChange: (activeIndex, preIndex) => {
197
+ this.props.onChange(activeIndex, preIndex);
198
+ },
199
+ setNewActiveIndex: activeIndex => {
200
+ this.setState({
201
+ activeIndex
202
+ });
203
+ },
204
+ setPreActiveIndex: preIndex => {
205
+ this.setState({
206
+ preIndex
207
+ });
208
+ },
209
+ setIsReverse: isReverse => {
210
+ this.setState({
211
+ isReverse
212
+ });
213
+ },
214
+ setIsInit: isInit => {
215
+ this.setState({
216
+ isInit
217
+ });
218
+ }
219
+ });
220
+ }
221
+
222
+ static getDerivedStateFromProps(props, state) {
223
+ const states = {};
224
+
225
+ if (!isNullOrUndefined(props.activeIndex) && props.activeIndex !== state.activeIndex) {
226
+ states.activeIndex = props.activeIndex;
227
+ }
228
+
229
+ return states;
230
+ }
231
+
232
+ componentDidMount() {
233
+ this.handleAutoPlay();
234
+ }
235
+
236
+ componentWillUnmount() {
237
+ this.foundation.destroy();
238
+ }
239
+
240
+ render() {
241
+ var _context2;
242
+
243
+ const {
244
+ animation,
245
+ className,
246
+ style,
247
+ slideDirection
248
+ } = this.props;
249
+ const {
250
+ isReverse
251
+ } = this.state;
252
+ const carouselWrapperCls = cls(className, {
253
+ [cssClasses.CAROUSEL]: true
254
+ });
255
+ return /*#__PURE__*/React.createElement("div", {
256
+ // role='listbox'
257
+ // tabIndex={0}
258
+ className: carouselWrapperCls,
259
+ style: style,
260
+ onMouseEnter: _debounce(this.handleMouseEnter, 400),
261
+ onMouseLeave: _debounce(this.handleMouseLeave, 400)
262
+ }, /*#__PURE__*/React.createElement("div", {
263
+ className: cls([_concatInstanceProperty(_context2 = "".concat(cssClasses.CAROUSEL_CONTENT, "-")).call(_context2, animation)], {
264
+ ["".concat(cssClasses.CAROUSEL_CONTENT)]: true,
265
+ ["".concat(cssClasses.CAROUSEL_CONTENT, "-reverse")]: slideDirection === 'left' ? isReverse : !isReverse
266
+ })
267
+ }, this.renderChildren()), this.renderIndicator(), this.renderArrow());
268
+ }
269
+
270
+ }
271
+
272
+ Carousel.propTypes = {
273
+ activeIndex: PropTypes.number,
274
+ animation: PropTypes.oneOf(strings.ANIMATION_MAP),
275
+ arrowProps: PropTypes.object,
276
+ autoPlay: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]),
277
+ className: PropTypes.string,
278
+ defaultActiveIndex: PropTypes.number,
279
+ indicatorPosition: PropTypes.oneOf(strings.POSITION_MAP),
280
+ indicatorSize: PropTypes.oneOf(strings.SIZE),
281
+ indicatorType: PropTypes.oneOf(strings.TYPE_MAP),
282
+ theme: PropTypes.oneOf(strings.THEME_MAP),
283
+ onChange: PropTypes.func,
284
+ arrowType: PropTypes.oneOf(strings.ARROW_MAP),
285
+ showArrow: PropTypes.bool,
286
+ showIndicator: PropTypes.bool,
287
+ slideDirection: PropTypes.oneOf(strings.DIRECTION),
288
+ speed: PropTypes.number,
289
+ style: PropTypes.object,
290
+ trigger: PropTypes.oneOf(strings.TRIGGER)
291
+ };
292
+ Carousel.defaultProps = {
293
+ children: [],
294
+ animation: 'slide',
295
+ autoPlay: true,
296
+ arrowType: 'always',
297
+ defaultActiveIndex: numbers.DEFAULT_ACTIVE_INDEX,
298
+ indicatorPosition: 'center',
299
+ indicatorSize: 'small',
300
+ indicatorType: 'dot',
301
+ theme: 'light',
302
+ onChange: () => undefined,
303
+ showArrow: true,
304
+ showIndicator: true,
305
+ slideDirection: 'left',
306
+ speed: numbers.DEFAULT_SPEED,
307
+ trigger: 'click'
308
+ };
309
+ export default Carousel;
@@ -0,0 +1,61 @@
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?: (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 @@
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
 
@@ -21,7 +21,7 @@ import PropTypes from 'prop-types';
21
21
  import { format as formatFn, isSameDay } from 'date-fns';
22
22
  import MonthsGridFoundation from '@douyinfe/semi-foundation/lib/es/datePicker/monthsGridFoundation';
23
23
  import { strings, numbers, cssClasses } from '@douyinfe/semi-foundation/lib/es/datePicker/constants';
24
- import { compatiableParse } from '@douyinfe/semi-foundation/lib/es/datePicker/_utils/parser';
24
+ import { compatibleParse } from '@douyinfe/semi-foundation/lib/es/datePicker/_utils/parser';
25
25
  import BaseComponent from '../_base/baseComponent';
26
26
  import Navigation from './navigation';
27
27
  import Month from './month';
@@ -474,7 +474,7 @@ export default class MonthsGrid extends BaseComponent {
474
474
  const dateFormat = this.foundation.getValidDateFormat();
475
475
  let startDate, endDate;
476
476
 
477
- if (type === 'dateTimeRange' && rangeStart && rangeEnd && isSameDay(startDate = compatiableParse(rangeStart, dateFormat, undefined, dateFnsLocale), endDate = compatiableParse(rangeEnd, dateFormat, undefined, dateFnsLocale))) {
477
+ if (type === 'dateTimeRange' && rangeStart && rangeEnd && isSameDay(startDate = compatibleParse(rangeStart, dateFormat, undefined, dateFnsLocale), endDate = compatibleParse(rangeEnd, dateFormat, undefined, dateFnsLocale))) {
478
478
  if (panelType === strings.PANEL_TYPE_RIGHT) {
479
479
  rangeStart && (restProps.startDate = startDate);
480
480
  } else {
@@ -560,10 +560,10 @@ export default class MonthsGrid extends BaseComponent {
560
560
 
561
561
  if (panelType === strings.PANEL_TYPE_LEFT) {
562
562
  panelDetail = monthLeft;
563
- dateText = rangeStart ? formatFn(compatiableParse(rangeStart, dateFormat, undefined, dateFnsLocale), FORMAT_SWITCH_DATE) : '';
563
+ dateText = rangeStart ? formatFn(compatibleParse(rangeStart, dateFormat, undefined, dateFnsLocale), FORMAT_SWITCH_DATE) : '';
564
564
  } else {
565
565
  panelDetail = monthRight;
566
- dateText = rangeEnd ? formatFn(compatiableParse(rangeEnd, dateFormat, undefined, dateFnsLocale), FORMAT_SWITCH_DATE) : '';
566
+ dateText = rangeEnd ? formatFn(compatibleParse(rangeEnd, dateFormat, undefined, dateFnsLocale), FORMAT_SWITCH_DATE) : '';
567
567
  }
568
568
 
569
569
  const {
@@ -573,7 +573,7 @@ export default class MonthsGrid extends BaseComponent {
573
573
  const monthText = showDate ? formatFn(showDate, FORMAT_SWITCH_DATE) : '';
574
574
  const timeText = showDate ? formatFn(showDate, formatTimePicker) : '';
575
575
 
576
- const showSwithIcon = _includesInstanceProperty(_context3 = ['default']).call(_context3, density);
576
+ const showSwitchIcon = _includesInstanceProperty(_context3 = ['default']).call(_context3, density);
577
577
 
578
578
  const switchCls = classnames("".concat(prefixCls, "-switch"));
579
579
  const dateCls = classnames({
@@ -594,7 +594,7 @@ export default class MonthsGrid extends BaseComponent {
594
594
  "aria-label": "Switch to date panel",
595
595
  className: dateCls,
596
596
  onClick: e => this.foundation.showDatePanel(panelType)
597
- }, showSwithIcon && /*#__PURE__*/React.createElement(IconCalendar, {
597
+ }, showSwitchIcon && /*#__PURE__*/React.createElement(IconCalendar, {
598
598
  "aria-hidden": true
599
599
  }), /*#__PURE__*/React.createElement("span", {
600
600
  className: textCls
@@ -603,7 +603,7 @@ export default class MonthsGrid extends BaseComponent {
603
603
  "aria-label": "Switch to time panel",
604
604
  className: timeCls,
605
605
  onClick: e => this.foundation.showTimePicker(panelType, true)
606
- }, showSwithIcon && /*#__PURE__*/React.createElement(IconClock, {
606
+ }, showSwitchIcon && /*#__PURE__*/React.createElement(IconClock, {
607
607
  "aria-hidden": true
608
608
  }), /*#__PURE__*/React.createElement("span", {
609
609
  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;
@@ -47,7 +47,7 @@ class Form extends BaseComponent {
47
47
 
48
48
  super(props);
49
49
  this.state = {
50
- formId: getUuidv4()
50
+ formId: ''
51
51
  };
52
52
  warning(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');
53
53
  warning(props.component && props.children && !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');
@@ -62,6 +62,10 @@ class Form extends BaseComponent {
62
62
  }
63
63
  }
64
64
 
65
+ componentDidMount() {
66
+ this.foundation.init();
67
+ }
68
+
65
69
  componentWillUnmount() {
66
70
  this.foundation.destroy();
67
71
  this.foundation = null;
@@ -89,6 +93,11 @@ class Form extends BaseComponent {
89
93
  notifyReset: () => {
90
94
  this.props.onReset();
91
95
  },
96
+ initFormId: () => {
97
+ this.setState({
98
+ formId: getUuidv4()
99
+ });
100
+ },
92
101
  getInitValues: () => this.props.initValues,
93
102
  getFormProps: keys => {
94
103
  if (typeof keys === 'undefined') {
@@ -380,9 +380,16 @@ function withField(Component, opts) {
380
380
  // eslint-disable-next-line @typescript-eslint/no-empty-function
381
381
  return () => {};
382
382
  } // log('register: ' + field);
383
+ // field value may change after field component mounted, we use ref value here to get changed value
383
384
 
384
385
 
385
- updater.register(field, fieldState, {
386
+ const refValue = getVal();
387
+ updater.register(field, {
388
+ value: refValue,
389
+ error,
390
+ touched,
391
+ status
392
+ }, {
386
393
  field,
387
394
  fieldApi,
388
395
  keepState,
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';
@@ -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/es/inputNumber/foundation';
4
+ import InputNumberFoundation, { BaseInputNumberState, InputNumberAdapter } from '@douyinfe/semi-foundation/lib/es/inputNumber/foundation';
5
5
  import BaseComponent from '../_base/baseComponent';
6
6
  import { strings } from '@douyinfe/semi-foundation/lib/es/inputNumber/constants';
7
7
  import '@douyinfe/semi-foundation/lib/es/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: {
@@ -1,4 +1,5 @@
1
1
  import _noop from "lodash/noop";
2
+ import _isString from "lodash/isString";
2
3
  import _isNaN from "lodash/isNaN";
3
4
  import _indexOfInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/index-of";
4
5
  import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
@@ -271,6 +272,9 @@ class InputNumber extends BaseComponent {
271
272
  },
272
273
  setClickUpOrDown: value => {
273
274
  this.clickUpOrDown = value;
275
+ },
276
+ updateStates: (states, callback) => {
277
+ this.setState(states, callback);
274
278
  }
275
279
  });
276
280
  }
@@ -282,6 +286,7 @@ class InputNumber extends BaseComponent {
282
286
  const {
283
287
  focusing
284
288
  } = this.state;
289
+ let newValue;
285
290
  /**
286
291
  * To determine whether the front and back are equal
287
292
  * NaN need to check whether both are NaN
@@ -289,8 +294,9 @@ class InputNumber extends BaseComponent {
289
294
 
290
295
  if (value !== prevProps.value && !isBothNaN(value, prevProps.value)) {
291
296
  if (isNullOrUndefined(value) || value === '') {
292
- this.setState({
293
- value: '',
297
+ newValue = '';
298
+ this.foundation.updateStates({
299
+ value: newValue,
294
300
  number: null
295
301
  });
296
302
  } else {
@@ -346,33 +352,42 @@ class InputNumber extends BaseComponent {
346
352
 
347
353
  if (this.clickUpOrDown) {
348
354
  obj.value = this.foundation.doFormat(valueStr, true);
355
+ newValue = obj.value;
349
356
  }
350
357
 
351
- this.setState(obj, () => this.adapter.restoreCursor());
358
+ this.foundation.updateStates(obj, () => this.adapter.restoreCursor());
352
359
  } else if (!_isNaN(toNum)) {
353
360
  // Update input content when controlled input is illegal and not NaN
354
- this.setState({
355
- value: this.foundation.doFormat(toNum, false)
361
+ newValue = this.foundation.doFormat(toNum, false);
362
+ this.foundation.updateStates({
363
+ value: newValue
356
364
  });
357
365
  } else {
358
366
  // Update input content when controlled input NaN
359
- this.setState({
360
- value: this.foundation.doFormat(valueStr, false)
367
+ newValue = this.foundation.doFormat(valueStr, false);
368
+ this.foundation.updateStates({
369
+ value: newValue
361
370
  });
362
371
  }
363
372
  } else if (this.foundation.isValidNumber(parsedNum)) {
364
- this.setState({
373
+ newValue = this.foundation.doFormat(parsedNum);
374
+ this.foundation.updateStates({
365
375
  number: parsedNum,
366
- value: this.foundation.doFormat(parsedNum)
376
+ value: newValue
367
377
  });
368
378
  } else {
369
379
  // Invalid digital analog blurring effect instead of controlled failure
370
- this.setState({
380
+ newValue = '';
381
+ this.foundation.updateStates({
371
382
  number: null,
372
- value: ''
383
+ value: newValue
373
384
  });
374
385
  }
375
386
  }
387
+
388
+ if (_isString(newValue) && newValue !== String(this.props.value)) {
389
+ this.foundation.notifyChange(newValue, null);
390
+ }
376
391
  }
377
392
 
378
393
  if (!this.clickUpOrDown) {
@@ -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;