@douyinfe/semi-ui 2.10.0-beta.0 → 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 (44) hide show
  1. package/button/buttonGroup.tsx +2 -2
  2. package/carousel/CarouselArrow.tsx +4 -4
  3. package/carousel/CarouselIndicator.tsx +0 -1
  4. package/carousel/index.tsx +1 -3
  5. package/carousel/interface.ts +1 -2
  6. package/datePicker/monthsGrid.tsx +8 -8
  7. package/dist/css/semi.css +4 -4
  8. package/dist/css/semi.min.css +1 -1
  9. package/dist/umd/semi-ui.js +365 -211
  10. package/dist/umd/semi-ui.js.map +1 -1
  11. package/dist/umd/semi-ui.min.js +1 -1
  12. package/dist/umd/semi-ui.min.js.map +1 -1
  13. package/form/baseForm.tsx +10 -1
  14. package/form/hoc/withField.tsx +17 -5
  15. package/inputNumber/__test__/inputNumber.test.js +40 -3
  16. package/inputNumber/_story/inputNumber.stories.js +56 -1
  17. package/inputNumber/index.tsx +22 -14
  18. package/lib/cjs/button/buttonGroup.d.ts +1 -1
  19. package/lib/cjs/carousel/CarouselArrow.js +3 -6
  20. package/lib/cjs/carousel/index.js +1 -3
  21. package/lib/cjs/carousel/interface.d.ts +1 -2
  22. package/lib/cjs/datePicker/monthsGrid.js +6 -6
  23. package/lib/cjs/form/baseForm.d.ts +1 -0
  24. package/lib/cjs/form/baseForm.js +10 -1
  25. package/lib/cjs/form/hoc/withField.js +8 -1
  26. package/lib/cjs/inputNumber/index.d.ts +2 -6
  27. package/lib/cjs/inputNumber/index.js +27 -11
  28. package/lib/cjs/transfer/index.js +5 -5
  29. package/lib/cjs/treeSelect/index.js +1 -1
  30. package/lib/es/button/buttonGroup.d.ts +1 -1
  31. package/lib/es/carousel/CarouselArrow.js +3 -5
  32. package/lib/es/carousel/index.js +1 -3
  33. package/lib/es/carousel/interface.d.ts +1 -2
  34. package/lib/es/datePicker/monthsGrid.js +7 -7
  35. package/lib/es/form/baseForm.d.ts +1 -0
  36. package/lib/es/form/baseForm.js +10 -1
  37. package/lib/es/form/hoc/withField.js +8 -1
  38. package/lib/es/inputNumber/index.d.ts +2 -6
  39. package/lib/es/inputNumber/index.js +26 -11
  40. package/lib/es/transfer/index.js +1 -1
  41. package/lib/es/treeSelect/index.js +1 -1
  42. package/package.json +9 -9
  43. package/transfer/index.tsx +1 -1
  44. package/treeSelect/index.tsx +1 -1
@@ -1,4 +1,3 @@
1
- import _throttle from "lodash/throttle";
2
1
  import _get from "lodash/get";
3
2
  import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
4
3
  import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
@@ -37,8 +36,7 @@ class CarouselArrow extends React.PureComponent {
37
36
  type,
38
37
  theme,
39
38
  prev,
40
- next,
41
- timing
39
+ next
42
40
  } = this.props;
43
41
  const classNames = cls({
44
42
  [cssClasses.CAROUSEL_ARROW]: true,
@@ -58,12 +56,12 @@ class CarouselArrow extends React.PureComponent {
58
56
  }, /*#__PURE__*/React.createElement("div", _Object$assign({
59
57
  // role='button'
60
58
  className: leftClassNames,
61
- onClick: _throttle(prev, timing)
59
+ onClick: prev
62
60
  }, _get(this.props, 'arrowProps.leftArrow.props')), this.renderLeftIcon()), /*#__PURE__*/React.createElement("div", _Object$assign({
63
61
  // role='button'
64
62
  // tabIndex={0}
65
63
  className: rightClassNames,
66
- onClick: _throttle(next, timing)
64
+ onClick: next
67
65
  }, _get(this.props, 'arrowProps.rightArrow.props')), this.renderRightIcon()));
68
66
  }
69
67
 
@@ -67,7 +67,7 @@ class Carousel extends BaseComponent {
67
67
  };
68
68
 
69
69
  this.onIndicatorChange = activeIndex => {
70
- return this.foundation.throttleChange(activeIndex);
70
+ return this.foundation.onIndicatorChange(activeIndex);
71
71
  };
72
72
 
73
73
  this.getChildren = () => {
@@ -166,7 +166,6 @@ class Carousel extends BaseComponent {
166
166
  theme,
167
167
  arrowProps
168
168
  } = this.props;
169
- const timing = this.foundation.getSwitchingTime();
170
169
 
171
170
  if (showArrow && children.length > 1) {
172
171
  return /*#__PURE__*/React.createElement(CarouselArrow, {
@@ -174,7 +173,6 @@ class Carousel extends BaseComponent {
174
173
  theme: theme,
175
174
  prev: this.prev,
176
175
  next: this.next,
177
- timing: timing,
178
176
  arrowProps: arrowProps
179
177
  });
180
178
  }
@@ -3,7 +3,7 @@ import { strings } from '@douyinfe/semi-foundation/lib/es/carousel/constants';
3
3
  export interface CarouselMethod {
4
4
  next?: () => void;
5
5
  prev?: () => void;
6
- goTo?: () => void;
6
+ goTo?: (tagetIndex: number) => void;
7
7
  play?: () => void;
8
8
  stop?: () => void;
9
9
  }
@@ -50,7 +50,6 @@ export interface CarouselArrowProps {
50
50
  prev?: () => void;
51
51
  next?: () => void;
52
52
  arrowProps?: ArrowProps;
53
- timing: number;
54
53
  }
55
54
  export interface ArrowButton {
56
55
  props?: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
@@ -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,
@@ -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) {
@@ -19,7 +19,7 @@ import cls from 'classnames';
19
19
  import { SortableContainer, SortableElement, SortableHandle } from 'react-sortable-hoc';
20
20
  import PropTypes from 'prop-types';
21
21
  import TransferFoundation from '@douyinfe/semi-foundation/lib/es/transfer/foundation';
22
- import { _generateDataByType, _generateSelectedItems } from '@douyinfe/semi-foundation/lib/es/transfer/transferUtlls';
22
+ import { _generateDataByType, _generateSelectedItems } from '@douyinfe/semi-foundation/lib/es/transfer/transferUtils';
23
23
  import { cssClasses, strings } from '@douyinfe/semi-foundation/lib/es/transfer/constants';
24
24
  import '@douyinfe/semi-foundation/lib/es/transfer/transfer.css';
25
25
  import BaseComponent from '../_base/baseComponent';
@@ -40,7 +40,7 @@ import TagInput from '../tagInput';
40
40
  import { isSemiIcon } from '../_utils';
41
41
  import { IconChevronDown, IconClear, IconSearch } from '@douyinfe/semi-icons';
42
42
  const prefixcls = cssClasses.PREFIX;
43
- const prefixTree = cssClasses.PREFIXTREE;
43
+ const prefixTree = cssClasses.PREFIX_TREE;
44
44
  const key = 0;
45
45
 
46
46
  class TreeSelect extends BaseComponent {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-ui",
3
- "version": "2.10.0-beta.0",
3
+ "version": "2.10.0",
4
4
  "description": "",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/es/index.js",
@@ -14,12 +14,12 @@
14
14
  },
15
15
  "dependencies": {
16
16
  "@babel/runtime-corejs3": "^7.15.4",
17
- "@douyinfe/semi-animation": "2.10.0-beta.0",
18
- "@douyinfe/semi-animation-react": "2.10.0-beta.0",
19
- "@douyinfe/semi-foundation": "2.10.0-beta.0",
20
- "@douyinfe/semi-icons": "2.10.0-beta.0",
21
- "@douyinfe/semi-illustrations": "2.10.0-beta.0",
22
- "@douyinfe/semi-theme-default": "2.10.0-beta.0",
17
+ "@douyinfe/semi-animation": "2.10.0",
18
+ "@douyinfe/semi-animation-react": "2.10.0",
19
+ "@douyinfe/semi-foundation": "2.10.0",
20
+ "@douyinfe/semi-icons": "2.10.0",
21
+ "@douyinfe/semi-illustrations": "2.10.0",
22
+ "@douyinfe/semi-theme-default": "2.10.0",
23
23
  "@types/react-window": "^1.8.2",
24
24
  "async-validator": "^3.5.0",
25
25
  "classnames": "^2.2.6",
@@ -69,13 +69,13 @@
69
69
  ],
70
70
  "author": "",
71
71
  "license": "MIT",
72
- "gitHead": "10c5eff42fe3144451fd73d9d542a710d165d456",
72
+ "gitHead": "0cbe3b9873aa550afa2eda0997eaa7015983fe0d",
73
73
  "devDependencies": {
74
74
  "@babel/plugin-proposal-decorators": "^7.15.8",
75
75
  "@babel/plugin-transform-runtime": "^7.15.8",
76
76
  "@babel/preset-env": "^7.15.8",
77
77
  "@babel/preset-react": "^7.14.5",
78
- "@douyinfe/semi-scss-compile": "2.10.0-beta.0",
78
+ "@douyinfe/semi-scss-compile": "2.10.0",
79
79
  "@storybook/addon-knobs": "^6.3.1",
80
80
  "@types/lodash": "^4.14.176",
81
81
  "babel-loader": "^8.2.2",
@@ -4,7 +4,7 @@ import { SortableContainer, SortableElement, SortableHandle } from 'react-sortab
4
4
  import PropTypes from 'prop-types';
5
5
  import { isEqual, noop, omit, isEmpty, isArray } from 'lodash';
6
6
  import TransferFoundation, { TransferAdapter, BasicDataItem, OnSortEndProps } from '@douyinfe/semi-foundation/transfer/foundation';
7
- import { _generateDataByType, _generateSelectedItems } from '@douyinfe/semi-foundation/transfer/transferUtlls';
7
+ import { _generateDataByType, _generateSelectedItems } from '@douyinfe/semi-foundation/transfer/transferUtils';
8
8
  import { cssClasses, strings } from '@douyinfe/semi-foundation/transfer/constants';
9
9
  import '@douyinfe/semi-foundation/transfer/transfer.scss';
10
10
  import BaseComponent from '../_base/baseComponent';
@@ -163,7 +163,7 @@ export interface TreeSelectState extends Omit<BasicTreeSelectInnerData, Override
163
163
  }
164
164
 
165
165
  const prefixcls = cssClasses.PREFIX;
166
- const prefixTree = cssClasses.PREFIXTREE;
166
+ const prefixTree = cssClasses.PREFIX_TREE;
167
167
 
168
168
  const key = 0;
169
169