@douyinfe/semi-ui 2.2.1 → 2.2.2

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.
@@ -641,3 +641,15 @@ export const FormCustomInput = () => {
641
641
  FormCustomInput.story = {
642
642
  name: 'Form.CustomInput',
643
643
  };
644
+
645
+
646
+ export const FixPrecision = () => {
647
+ const [value, setValue] = useState(5.12);
648
+ const [value2, setValue2] = useState(5.12);
649
+ return (
650
+ <div>
651
+ <InputNumber onChange={v => setValue(v)} value={value} style={{ width: 190 }} precision={2} />
652
+ <InputNumber keepFocus onBlur={() => console.log('blur')} onChange={v => setValue2(v)} value={value2} style={{ width: 190 }} precision={2} />
653
+ </div>
654
+ );
655
+ }
@@ -225,6 +225,7 @@ class InputNumber extends BaseComponent<InputNumberProps, InputNumberState> {
225
225
  currentValue!: number | string;
226
226
  cursorBefore!: string;
227
227
  cursorAfter!: string;
228
+ foundation: InputNumberFoundation;
228
229
  constructor(props: InputNumberProps) {
229
230
  super(props);
230
231
  this.state = {
@@ -291,7 +292,10 @@ class InputNumber extends BaseComponent<InputNumberProps, InputNumberState> {
291
292
  if (focusing) {
292
293
  if (this.foundation.isValidNumber(parsedNum) && parsedNum !== this.state.number) {
293
294
  const obj: { number?: number; value?: string } = { number: parsedNum };
294
- // Updates input when a button is clicked
295
+ /**
296
+ * If you are clicking the button, it will automatically format once
297
+ * We need to set the status to false after trigger focus event
298
+ */
295
299
  if (this.clickUpOrDown) {
296
300
  obj.value = this.foundation.doFormat(valueStr, true);
297
301
  }
@@ -466,7 +466,8 @@ class DatePicker extends _baseComponent.default {
466
466
  density,
467
467
  syncSwitchMonth,
468
468
  onPanelChange,
469
- timeZone
469
+ timeZone,
470
+ triggerRender
470
471
  } = this.props;
471
472
  const {
472
473
  value,
@@ -513,7 +514,8 @@ class DatePicker extends _baseComponent.default {
513
514
  syncSwitchMonth: syncSwitchMonth,
514
515
  onPanelChange: onPanelChange,
515
516
  timeZone: timeZone,
516
- focusRecordsRef: this.focusRecordsRef
517
+ focusRecordsRef: this.focusRecordsRef,
518
+ triggerRender: triggerRender
517
519
  });
518
520
  }
519
521
 
@@ -49,6 +49,7 @@ export default class MonthsGrid extends BaseComponent<MonthsGridProps, MonthsGri
49
49
  syncSwitchMonth: PropTypes.Requireable<boolean>;
50
50
  onPanelChange: PropTypes.Requireable<(...args: any[]) => any>;
51
51
  focusRecordsRef: PropTypes.Requireable<object>;
52
+ triggerRender: PropTypes.Requireable<(...args: any[]) => any>;
52
53
  };
53
54
  static defaultProps: {
54
55
  type: string;
@@ -695,7 +695,8 @@ MonthsGrid.propTypes = {
695
695
  syncSwitchMonth: _propTypes.default.bool,
696
696
  // Callback function for panel date switching
697
697
  onPanelChange: _propTypes.default.func,
698
- focusRecordsRef: _propTypes.default.object
698
+ focusRecordsRef: _propTypes.default.object,
699
+ triggerRender: _propTypes.default.func
699
700
  };
700
701
  MonthsGrid.defaultProps = {
701
702
  type: 'date',
@@ -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 { InputNumberAdapter } from '@douyinfe/semi-foundation/lib/cjs/inputNumber/foundation';
4
+ import InputNumberFoundation, { 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';
@@ -85,20 +85,21 @@ declare class InputNumber extends BaseComponent<InputNumberProps, InputNumberSta
85
85
  currentValue: number | string;
86
86
  cursorBefore: string;
87
87
  cursorAfter: string;
88
+ foundation: InputNumberFoundation;
88
89
  constructor(props: InputNumberProps);
89
90
  componentDidUpdate(prevProps: InputNumberProps): void;
90
91
  setInputRef: (node: HTMLInputElement) => void;
91
- handleInputFocus: (e: React.FocusEvent<HTMLInputElement>) => any;
92
- handleInputChange: (value: string, event: React.ChangeEvent<HTMLInputElement>) => any;
93
- handleInputBlur: (e: React.FocusEvent<HTMLInputElement>) => any;
94
- handleInputKeyDown: (e: React.KeyboardEvent) => any;
95
- handleInputMouseEnter: (e: React.MouseEvent) => any;
96
- handleInputMouseLeave: (e: React.MouseEvent) => any;
97
- handleInputMouseMove: (e: React.MouseEvent) => any;
98
- handleUpClick: (e: React.KeyboardEvent) => any;
99
- handleDownClick: (e: React.KeyboardEvent) => any;
100
- handleMouseUp: (e: React.MouseEvent) => any;
101
- handleMouseLeave: (e: React.MouseEvent) => any;
92
+ handleInputFocus: (e: React.FocusEvent<HTMLInputElement>) => void;
93
+ handleInputChange: (value: string, event: React.ChangeEvent<HTMLInputElement>) => void;
94
+ handleInputBlur: (e: React.FocusEvent<HTMLInputElement>) => void;
95
+ handleInputKeyDown: (e: React.KeyboardEvent) => void;
96
+ handleInputMouseEnter: (e: React.MouseEvent) => void;
97
+ handleInputMouseLeave: (e: React.MouseEvent) => void;
98
+ handleInputMouseMove: (e: React.MouseEvent) => void;
99
+ handleUpClick: (e: React.KeyboardEvent) => void;
100
+ handleDownClick: (e: React.KeyboardEvent) => void;
101
+ handleMouseUp: (e: React.MouseEvent) => void;
102
+ handleMouseLeave: (e: React.MouseEvent) => void;
102
103
  renderButtons: () => JSX.Element;
103
104
  renderSuffix: () => React.ReactNode;
104
105
  render(): JSX.Element;
@@ -363,7 +363,11 @@ class InputNumber extends _baseComponent.default {
363
363
  if (this.foundation.isValidNumber(parsedNum) && parsedNum !== this.state.number) {
364
364
  const obj = {
365
365
  number: parsedNum
366
- }; // Updates input when a button is clicked
366
+ };
367
+ /**
368
+ * If you are clicking the button, it will automatically format once
369
+ * We need to set the status to false after trigger focus event
370
+ */
367
371
 
368
372
  if (this.clickUpOrDown) {
369
373
  obj.value = this.foundation.doFormat(valueStr, true);
@@ -152,7 +152,7 @@ declare class Transfer extends BaseComponent<TransferProps, TransferState> {
152
152
  renderHeader(headerConfig: HeaderConfig): JSX.Element;
153
153
  renderLeftItem(item: ResolvedDataItem, index: number): React.ReactNode;
154
154
  renderLeft(locale: Locale['Transfer']): React.ReactNode;
155
- renderGroupTitle(group: GroupItem): JSX.Element;
155
+ renderGroupTitle(group: GroupItem, index: number): JSX.Element;
156
156
  renderLeftTree(): JSX.Element;
157
157
  renderLeftList(visibileItems: Array<ResolvedDataItem>): JSX.Element;
158
158
  renderRightItem(item: ResolvedDataItem): React.ReactNode;
@@ -373,11 +373,11 @@ class Transfer extends _baseComponent.default {
373
373
  }, inputCom, content);
374
374
  }
375
375
 
376
- renderGroupTitle(group) {
376
+ renderGroupTitle(group, index) {
377
377
  const groupCls = (0, _classnames.default)("".concat(prefixcls, "-group-title"));
378
378
  return /*#__PURE__*/_react.default.createElement("div", {
379
379
  className: groupCls,
380
- key: group.title
380
+ key: "title-".concat(index)
381
381
  }, group.title);
382
382
  }
383
383
 
@@ -432,7 +432,7 @@ class Transfer extends _baseComponent.default {
432
432
  // group content already insert
433
433
  content.push(optionContent);
434
434
  } else if (parentGroup) {
435
- const groupContent = this.renderGroupTitle(parentGroup);
435
+ const groupContent = this.renderGroupTitle(parentGroup, index);
436
436
  groupStatus.set(parentGroup.title, true);
437
437
  content.push(groupContent);
438
438
  content.push(optionContent);
@@ -433,7 +433,8 @@ export default class DatePicker extends BaseComponent {
433
433
  density,
434
434
  syncSwitchMonth,
435
435
  onPanelChange,
436
- timeZone
436
+ timeZone,
437
+ triggerRender
437
438
  } = this.props;
438
439
  const {
439
440
  value,
@@ -480,7 +481,8 @@ export default class DatePicker extends BaseComponent {
480
481
  syncSwitchMonth: syncSwitchMonth,
481
482
  onPanelChange: onPanelChange,
482
483
  timeZone: timeZone,
483
- focusRecordsRef: this.focusRecordsRef
484
+ focusRecordsRef: this.focusRecordsRef,
485
+ triggerRender: triggerRender
484
486
  });
485
487
  }
486
488
 
@@ -49,6 +49,7 @@ export default class MonthsGrid extends BaseComponent<MonthsGridProps, MonthsGri
49
49
  syncSwitchMonth: PropTypes.Requireable<boolean>;
50
50
  onPanelChange: PropTypes.Requireable<(...args: any[]) => any>;
51
51
  focusRecordsRef: PropTypes.Requireable<object>;
52
+ triggerRender: PropTypes.Requireable<(...args: any[]) => any>;
52
53
  };
53
54
  static defaultProps: {
54
55
  type: string;
@@ -664,7 +664,8 @@ MonthsGrid.propTypes = {
664
664
  syncSwitchMonth: PropTypes.bool,
665
665
  // Callback function for panel date switching
666
666
  onPanelChange: PropTypes.func,
667
- focusRecordsRef: PropTypes.object
667
+ focusRecordsRef: PropTypes.object,
668
+ triggerRender: PropTypes.func
668
669
  };
669
670
  MonthsGrid.defaultProps = {
670
671
  type: 'date',
@@ -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 { InputNumberAdapter } from '@douyinfe/semi-foundation/lib/es/inputNumber/foundation';
4
+ import InputNumberFoundation, { 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';
@@ -85,20 +85,21 @@ declare class InputNumber extends BaseComponent<InputNumberProps, InputNumberSta
85
85
  currentValue: number | string;
86
86
  cursorBefore: string;
87
87
  cursorAfter: string;
88
+ foundation: InputNumberFoundation;
88
89
  constructor(props: InputNumberProps);
89
90
  componentDidUpdate(prevProps: InputNumberProps): void;
90
91
  setInputRef: (node: HTMLInputElement) => void;
91
- handleInputFocus: (e: React.FocusEvent<HTMLInputElement>) => any;
92
- handleInputChange: (value: string, event: React.ChangeEvent<HTMLInputElement>) => any;
93
- handleInputBlur: (e: React.FocusEvent<HTMLInputElement>) => any;
94
- handleInputKeyDown: (e: React.KeyboardEvent) => any;
95
- handleInputMouseEnter: (e: React.MouseEvent) => any;
96
- handleInputMouseLeave: (e: React.MouseEvent) => any;
97
- handleInputMouseMove: (e: React.MouseEvent) => any;
98
- handleUpClick: (e: React.KeyboardEvent) => any;
99
- handleDownClick: (e: React.KeyboardEvent) => any;
100
- handleMouseUp: (e: React.MouseEvent) => any;
101
- handleMouseLeave: (e: React.MouseEvent) => any;
92
+ handleInputFocus: (e: React.FocusEvent<HTMLInputElement>) => void;
93
+ handleInputChange: (value: string, event: React.ChangeEvent<HTMLInputElement>) => void;
94
+ handleInputBlur: (e: React.FocusEvent<HTMLInputElement>) => void;
95
+ handleInputKeyDown: (e: React.KeyboardEvent) => void;
96
+ handleInputMouseEnter: (e: React.MouseEvent) => void;
97
+ handleInputMouseLeave: (e: React.MouseEvent) => void;
98
+ handleInputMouseMove: (e: React.MouseEvent) => void;
99
+ handleUpClick: (e: React.KeyboardEvent) => void;
100
+ handleDownClick: (e: React.KeyboardEvent) => void;
101
+ handleMouseUp: (e: React.MouseEvent) => void;
102
+ handleMouseLeave: (e: React.MouseEvent) => void;
102
103
  renderButtons: () => JSX.Element;
103
104
  renderSuffix: () => React.ReactNode;
104
105
  render(): JSX.Element;
@@ -334,7 +334,11 @@ class InputNumber extends BaseComponent {
334
334
  if (this.foundation.isValidNumber(parsedNum) && parsedNum !== this.state.number) {
335
335
  const obj = {
336
336
  number: parsedNum
337
- }; // Updates input when a button is clicked
337
+ };
338
+ /**
339
+ * If you are clicking the button, it will automatically format once
340
+ * We need to set the status to false after trigger focus event
341
+ */
338
342
 
339
343
  if (this.clickUpOrDown) {
340
344
  obj.value = this.foundation.doFormat(valueStr, true);
@@ -152,7 +152,7 @@ declare class Transfer extends BaseComponent<TransferProps, TransferState> {
152
152
  renderHeader(headerConfig: HeaderConfig): JSX.Element;
153
153
  renderLeftItem(item: ResolvedDataItem, index: number): React.ReactNode;
154
154
  renderLeft(locale: Locale['Transfer']): React.ReactNode;
155
- renderGroupTitle(group: GroupItem): JSX.Element;
155
+ renderGroupTitle(group: GroupItem, index: number): JSX.Element;
156
156
  renderLeftTree(): JSX.Element;
157
157
  renderLeftList(visibileItems: Array<ResolvedDataItem>): JSX.Element;
158
158
  renderRightItem(item: ResolvedDataItem): React.ReactNode;
@@ -329,11 +329,11 @@ class Transfer extends BaseComponent {
329
329
  }, inputCom, content);
330
330
  }
331
331
 
332
- renderGroupTitle(group) {
332
+ renderGroupTitle(group, index) {
333
333
  const groupCls = cls("".concat(prefixcls, "-group-title"));
334
334
  return /*#__PURE__*/React.createElement("div", {
335
335
  className: groupCls,
336
- key: group.title
336
+ key: "title-".concat(index)
337
337
  }, group.title);
338
338
  }
339
339
 
@@ -390,7 +390,7 @@ class Transfer extends BaseComponent {
390
390
  // group content already insert
391
391
  content.push(optionContent);
392
392
  } else if (parentGroup) {
393
- const groupContent = this.renderGroupTitle(parentGroup);
393
+ const groupContent = this.renderGroupTitle(parentGroup, index);
394
394
  groupStatus.set(parentGroup.title, true);
395
395
  content.push(groupContent);
396
396
  content.push(optionContent);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-ui",
3
- "version": "2.2.1",
3
+ "version": "2.2.2",
4
4
  "description": "",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/es/index.js",
@@ -14,11 +14,11 @@
14
14
  },
15
15
  "dependencies": {
16
16
  "@babel/runtime-corejs3": "^7.15.4",
17
- "@douyinfe/semi-animation-react": "2.2.1",
18
- "@douyinfe/semi-foundation": "2.2.1",
19
- "@douyinfe/semi-icons": "2.2.1",
20
- "@douyinfe/semi-illustrations": "2.2.1",
21
- "@douyinfe/semi-theme-default": "2.2.1",
17
+ "@douyinfe/semi-animation-react": "2.2.2",
18
+ "@douyinfe/semi-foundation": "2.2.2",
19
+ "@douyinfe/semi-icons": "2.2.2",
20
+ "@douyinfe/semi-illustrations": "2.2.2",
21
+ "@douyinfe/semi-theme-default": "2.2.2",
22
22
  "@types/react-window": "^1.8.2",
23
23
  "async-validator": "^3.5.0",
24
24
  "classnames": "^2.2.6",
@@ -68,13 +68,13 @@
68
68
  ],
69
69
  "author": "",
70
70
  "license": "MIT",
71
- "gitHead": "6d8bb9dd22bf199225fa2a0dda4f8524a4b97f6f",
71
+ "gitHead": "de84e4f81bb443c457c075e808c4bd1fcf9441d7",
72
72
  "devDependencies": {
73
73
  "@babel/plugin-proposal-decorators": "^7.15.8",
74
74
  "@babel/plugin-transform-runtime": "^7.15.8",
75
75
  "@babel/preset-env": "^7.15.8",
76
76
  "@babel/preset-react": "^7.14.5",
77
- "@douyinfe/semi-scss-compile": "2.2.1",
77
+ "@douyinfe/semi-scss-compile": "2.2.2",
78
78
  "@storybook/addon-knobs": "^6.3.1",
79
79
  "@types/lodash": "^4.14.176",
80
80
  "babel-loader": "^8.2.2",
@@ -445,10 +445,10 @@ class Transfer extends BaseComponent<TransferProps, TransferState> {
445
445
  );
446
446
  }
447
447
 
448
- renderGroupTitle(group: GroupItem) {
448
+ renderGroupTitle(group: GroupItem, index: number) {
449
449
  const groupCls = cls(`${prefixcls }-group-title`);
450
450
  return (
451
- <div className={groupCls} key={group.title}>
451
+ <div className={groupCls} key={`title-${index}`}>
452
452
  {group.title}
453
453
  </div>
454
454
  );
@@ -493,7 +493,7 @@ class Transfer extends BaseComponent<TransferProps, TransferState> {
493
493
  // group content already insert
494
494
  content.push(optionContent);
495
495
  } else if (parentGroup) {
496
- const groupContent = this.renderGroupTitle(parentGroup);
496
+ const groupContent = this.renderGroupTitle(parentGroup, index);
497
497
  groupStatus.set(parentGroup.title, true);
498
498
  content.push(groupContent);
499
499
  content.push(optionContent);