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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/badge/_story/badge.stories.js +34 -2
  2. package/banner/_story/banner.stories.js +62 -1
  3. package/banner/index.tsx +5 -5
  4. package/button/buttonGroup.tsx +2 -2
  5. package/carousel/CarouselArrow.tsx +62 -0
  6. package/carousel/CarouselIndicator.tsx +83 -0
  7. package/carousel/__test__/carousel.test.js +159 -0
  8. package/carousel/_story/carousel.stories.js +486 -0
  9. package/carousel/index.tsx +292 -0
  10. package/carousel/interface.ts +63 -0
  11. package/cascader/index.tsx +1 -2
  12. package/checkbox/checkbox.tsx +8 -18
  13. package/datePicker/monthsGrid.tsx +8 -8
  14. package/dist/css/semi.css +343 -0
  15. package/dist/css/semi.min.css +1 -1
  16. package/dist/umd/semi-ui.js +23525 -22602
  17. package/dist/umd/semi-ui.js.map +1 -1
  18. package/dist/umd/semi-ui.min.js +1 -1
  19. package/dist/umd/semi-ui.min.js.map +1 -1
  20. package/form/baseForm.tsx +10 -1
  21. package/form/hoc/withField.tsx +25 -10
  22. package/index.ts +2 -0
  23. package/inputNumber/__test__/inputNumber.test.js +40 -3
  24. package/inputNumber/_story/inputNumber.stories.js +56 -1
  25. package/inputNumber/index.tsx +22 -14
  26. package/lib/cjs/_portal/index.d.ts +1 -1
  27. package/lib/cjs/banner/index.js +11 -5
  28. package/lib/cjs/button/buttonGroup.d.ts +1 -1
  29. package/lib/cjs/carousel/CarouselArrow.d.ts +8 -0
  30. package/lib/cjs/carousel/CarouselArrow.js +88 -0
  31. package/lib/cjs/carousel/CarouselIndicator.d.ts +23 -0
  32. package/lib/cjs/carousel/CarouselIndicator.js +145 -0
  33. package/lib/cjs/carousel/index.d.ts +58 -0
  34. package/lib/cjs/carousel/index.js +343 -0
  35. package/lib/cjs/carousel/interface.d.ts +61 -0
  36. package/lib/cjs/carousel/interface.js +7 -0
  37. package/lib/cjs/cascader/index.js +1 -1
  38. package/lib/cjs/checkbox/checkbox.d.ts +0 -4
  39. package/lib/cjs/checkbox/checkbox.js +13 -25
  40. package/lib/cjs/datePicker/dateInput.d.ts +1 -1
  41. package/lib/cjs/datePicker/datePicker.d.ts +1 -1
  42. package/lib/cjs/datePicker/insetInput.d.ts +1 -0
  43. package/lib/cjs/datePicker/monthsGrid.d.ts +1 -1
  44. package/lib/cjs/datePicker/monthsGrid.js +6 -6
  45. package/lib/cjs/dropdown/dropdownMenu.d.ts +1 -0
  46. package/lib/cjs/form/baseForm.d.ts +2 -1
  47. package/lib/cjs/form/baseForm.js +10 -1
  48. package/lib/cjs/form/field.d.ts +1 -1
  49. package/lib/cjs/form/hoc/withField.js +14 -5
  50. package/lib/cjs/index.d.ts +1 -0
  51. package/lib/cjs/index.js +9 -0
  52. package/lib/cjs/inputNumber/index.d.ts +2 -6
  53. package/lib/cjs/inputNumber/index.js +27 -11
  54. package/lib/cjs/modal/useModal/index.d.ts +1 -0
  55. package/lib/cjs/notification/useNotification/index.d.ts +1 -0
  56. package/lib/cjs/radio/radio.d.ts +1 -5
  57. package/lib/cjs/radio/radio.js +12 -26
  58. package/lib/cjs/radio/radioGroup.d.ts +1 -1
  59. package/lib/cjs/scrollList/scrollItem.js +1 -1
  60. package/lib/cjs/switch/index.d.ts +3 -0
  61. package/lib/cjs/switch/index.js +26 -6
  62. package/lib/cjs/timePicker/Combobox.d.ts +1 -0
  63. package/lib/cjs/timePicker/TimePicker.d.ts +2 -2
  64. package/lib/cjs/timePicker/TimeShape.d.ts +1 -1
  65. package/lib/cjs/timePicker/index.d.ts +2 -2
  66. package/lib/cjs/toast/useToast/index.d.ts +1 -0
  67. package/lib/cjs/tooltip/index.d.ts +1 -1
  68. package/lib/cjs/tooltip/index.js +11 -13
  69. package/lib/cjs/transfer/index.js +5 -5
  70. package/lib/cjs/treeSelect/index.js +1 -1
  71. package/lib/cjs/typography/title.d.ts +1 -1
  72. package/lib/cjs/upload/index.d.ts +1 -1
  73. package/lib/es/_portal/index.d.ts +1 -1
  74. package/lib/es/banner/index.js +11 -5
  75. package/lib/es/button/buttonGroup.d.ts +1 -1
  76. package/lib/es/carousel/CarouselArrow.d.ts +8 -0
  77. package/lib/es/carousel/CarouselArrow.js +70 -0
  78. package/lib/es/carousel/CarouselIndicator.d.ts +23 -0
  79. package/lib/es/carousel/CarouselIndicator.js +125 -0
  80. package/lib/es/carousel/index.d.ts +58 -0
  81. package/lib/es/carousel/index.js +309 -0
  82. package/lib/es/carousel/interface.d.ts +61 -0
  83. package/lib/es/carousel/interface.js +1 -0
  84. package/lib/es/cascader/index.js +1 -1
  85. package/lib/es/checkbox/checkbox.d.ts +0 -4
  86. package/lib/es/checkbox/checkbox.js +13 -25
  87. package/lib/es/datePicker/dateInput.d.ts +1 -1
  88. package/lib/es/datePicker/datePicker.d.ts +1 -1
  89. package/lib/es/datePicker/insetInput.d.ts +1 -0
  90. package/lib/es/datePicker/monthsGrid.d.ts +1 -1
  91. package/lib/es/datePicker/monthsGrid.js +7 -7
  92. package/lib/es/dropdown/dropdownMenu.d.ts +1 -0
  93. package/lib/es/form/baseForm.d.ts +2 -1
  94. package/lib/es/form/baseForm.js +10 -1
  95. package/lib/es/form/field.d.ts +1 -1
  96. package/lib/es/form/hoc/withField.js +14 -5
  97. package/lib/es/index.d.ts +1 -0
  98. package/lib/es/index.js +1 -0
  99. package/lib/es/inputNumber/index.d.ts +2 -6
  100. package/lib/es/inputNumber/index.js +26 -11
  101. package/lib/es/modal/useModal/index.d.ts +1 -0
  102. package/lib/es/notification/useNotification/index.d.ts +1 -0
  103. package/lib/es/radio/radio.d.ts +1 -5
  104. package/lib/es/radio/radio.js +12 -26
  105. package/lib/es/radio/radioGroup.d.ts +1 -1
  106. package/lib/es/scrollList/scrollItem.js +1 -1
  107. package/lib/es/switch/index.d.ts +3 -0
  108. package/lib/es/switch/index.js +26 -6
  109. package/lib/es/timePicker/Combobox.d.ts +1 -0
  110. package/lib/es/timePicker/TimePicker.d.ts +2 -2
  111. package/lib/es/timePicker/TimeShape.d.ts +1 -1
  112. package/lib/es/timePicker/index.d.ts +2 -2
  113. package/lib/es/toast/useToast/index.d.ts +1 -0
  114. package/lib/es/tooltip/index.d.ts +1 -1
  115. package/lib/es/tooltip/index.js +11 -13
  116. package/lib/es/transfer/index.js +1 -1
  117. package/lib/es/treeSelect/index.js +1 -1
  118. package/lib/es/typography/title.d.ts +1 -1
  119. package/lib/es/upload/index.d.ts +1 -1
  120. package/package.json +9 -9
  121. package/popover/_story/popover.stories.js +38 -2
  122. package/radio/radio.tsx +7 -17
  123. package/scrollList/scrollItem.tsx +1 -1
  124. package/switch/index.tsx +20 -3
  125. package/tagInput/__test__/tagInput.test.js +11 -11
  126. package/timePicker/TimePicker.tsx +1 -1
  127. package/timePicker/_story/timepicker.stories.js +20 -1
  128. package/tooltip/index.tsx +11 -8
  129. package/transfer/index.tsx +1 -1
  130. package/treeSelect/index.tsx +1 -1
@@ -112,7 +112,8 @@ function withField(Component, opts) {
112
112
  const [cursor, setCursor, getCursor] = useStateWithGetter(0);
113
113
  const [status, setStatus] = useState(validateStatus); // use props.validateStatus to init
114
114
 
115
- const rulesRef = useRef(rules); // notNotify is true means that the onChange of the Form does not need to be triggered
115
+ const rulesRef = useRef(rules);
116
+ const validateRef = useRef(validate); // notNotify is true means that the onChange of the Form does not need to be triggered
116
117
  // notUpdate is true means that this operation does not need to trigger the forceUpdate
117
118
 
118
119
  const updateTouched = (isTouched, callOpts) => {
@@ -213,7 +214,7 @@ function withField(Component, opts) {
213
214
  let maybePromisedErrors; // let errorThrowSync;
214
215
 
215
216
  try {
216
- maybePromisedErrors = validate(val, values);
217
+ maybePromisedErrors = validateRef.current(val, values);
217
218
  } catch (err) {
218
219
  // error throw by syncValidate
219
220
  maybePromisedErrors = err;
@@ -253,7 +254,7 @@ function withField(Component, opts) {
253
254
  finalVal = transform(val);
254
255
  }
255
256
 
256
- if (validate) {
257
+ if (validateRef.current) {
257
258
  return _validate(finalVal, updater.getValue(), callOpts);
258
259
  } else if (latestRules) {
259
260
  return _validateInternal(finalVal, callOpts);
@@ -362,7 +363,8 @@ function withField(Component, opts) {
362
363
 
363
364
  useLayoutEffect(() => {
364
365
  rulesRef.current = rules;
365
- }, [rules]); // exec validate once when trigger inlcude 'mount'
366
+ validateRef.current = validate;
367
+ }, [rules, validate]); // exec validate once when trigger inlcude 'mount'
366
368
 
367
369
  useLayoutEffect(() => {
368
370
  if (validateOnMount) {
@@ -378,9 +380,16 @@ function withField(Component, opts) {
378
380
  // eslint-disable-next-line @typescript-eslint/no-empty-function
379
381
  return () => {};
380
382
  } // log('register: ' + field);
383
+ // field value may change after field component mounted, we use ref value here to get changed value
381
384
 
382
385
 
383
- updater.register(field, fieldState, {
386
+ const refValue = getVal();
387
+ updater.register(field, {
388
+ value: refValue,
389
+ error,
390
+ touched,
391
+ status
392
+ }, {
384
393
  field,
385
394
  fieldApi,
386
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) {
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { ConfirmProps } from '../confirm';
2
3
  import { ModalReactProps } from '../Modal';
3
4
  export default function useModal(): (JSX.Element | {
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import '@douyinfe/semi-foundation/lib/es/notification/notification.css';
2
3
  import { NoticeProps } from '@douyinfe/semi-foundation/lib/es/notification/notificationFoundation';
3
4
  export default function useNotification(): (JSX.Element | {
@@ -29,13 +29,9 @@ export declare type RadioProps = {
29
29
  addonClassName?: string;
30
30
  type?: RadioType;
31
31
  'aria-label'?: React.AriaAttributes['aria-label'];
32
- addonId?: string;
33
- extraId?: string;
34
32
  };
35
33
  export interface RadioState {
36
34
  hover?: boolean;
37
- addonId?: string;
38
- extraId?: string;
39
35
  }
40
36
  export { RadioChangeEvent };
41
37
  declare class Radio extends BaseComponent<RadioProps, RadioState> {
@@ -75,7 +71,7 @@ declare class Radio extends BaseComponent<RadioProps, RadioState> {
75
71
  prefixCls?: string;
76
72
  name?: string;
77
73
  onChange?: (e: RadioChangeEvent) => void;
78
- buttonSize?: "small" | "large" | "middle";
74
+ buttonSize?: "small" | "middle" | "large";
79
75
  isCardRadio?: boolean;
80
76
  isPureCardRadio?: boolean;
81
77
  };
@@ -44,12 +44,16 @@ class Radio extends BaseComponent {
44
44
  };
45
45
 
46
46
  this.state = {
47
- hover: false,
48
- addonId: props.addonId,
49
- extraId: props.extraId
47
+ hover: false
50
48
  };
51
49
  this.foundation = new RadioFoundation(this.adapter);
52
50
  this.radioEntity = null;
51
+ this.addonId = getUuidShort({
52
+ prefix: 'addon'
53
+ });
54
+ this.extraId = getUuidShort({
55
+ prefix: 'extra'
56
+ });
53
57
  }
54
58
 
55
59
  get adapter() {
@@ -58,20 +62,6 @@ class Radio extends BaseComponent {
58
62
  this.setState({
59
63
  hover
60
64
  });
61
- },
62
- setAddonId: () => {
63
- this.setState({
64
- addonId: getUuidShort({
65
- prefix: 'addon'
66
- })
67
- });
68
- },
69
- setExtraId: () => {
70
- this.setState({
71
- extraId: getUuidShort({
72
- prefix: 'extra'
73
- })
74
- });
75
65
  }
76
66
  });
77
67
  }
@@ -108,11 +98,7 @@ class Radio extends BaseComponent {
108
98
  value: propValue
109
99
  } = this.props;
110
100
  let realChecked, isDisabled, realMode, isButtonRadioGroup, isCardRadioGroup, isPureCardRadioGroup, isButtonRadioComponent, buttonSize, realPrefixCls;
111
- const {
112
- hover: isHover,
113
- addonId,
114
- extraId
115
- } = this.state;
101
+ const isHover = this.state.hover;
116
102
  let props = {};
117
103
 
118
104
  if (this.isInGroup()) {
@@ -165,10 +151,10 @@ class Radio extends BaseComponent {
165
151
  const renderContent = () => /*#__PURE__*/React.createElement(React.Fragment, null, children ? /*#__PURE__*/React.createElement("span", {
166
152
  className: addonCls,
167
153
  style: addonStyle,
168
- id: addonId
154
+ id: this.addonId
169
155
  }, children) : null, extra && !isButtonRadio ? /*#__PURE__*/React.createElement("div", {
170
156
  className: "".concat(prefix, "-extra"),
171
- id: extraId
157
+ id: this.extraId
172
158
  }, extra) : null);
173
159
 
174
160
  return /*#__PURE__*/React.createElement("label", {
@@ -185,8 +171,8 @@ class Radio extends BaseComponent {
185
171
  ref: ref => {
186
172
  this.radioEntity = ref;
187
173
  },
188
- addonId: children && addonId,
189
- extraId: extra && extraId
174
+ addonId: children && this.addonId,
175
+ extraId: extra && this.extraId
190
176
  })), isCardRadioGroup ? /*#__PURE__*/React.createElement("div", {
191
177
  className: "".concat(prefix, "-isCardRadioGroup_content")
192
178
  }, renderContent()) : renderContent());
@@ -48,7 +48,7 @@ declare class RadioGroup extends BaseComponent<RadioGroupProps, RadioGroupState>
48
48
  disabled: PropTypes.Requireable<boolean>;
49
49
  name: PropTypes.Requireable<string>;
50
50
  options: PropTypes.Requireable<any[]>;
51
- buttonSize: PropTypes.Requireable<"small" | "large" | "middle">;
51
+ buttonSize: PropTypes.Requireable<"small" | "middle" | "large">;
52
52
  type: PropTypes.Requireable<"default" | "button" | "card" | "pureCard">;
53
53
  value: PropTypes.Requireable<any>;
54
54
  onChange: PropTypes.Requireable<(...args: any[]) => any>;
@@ -176,7 +176,7 @@ export default class ScrollItem extends BaseComponent {
176
176
  } = this;
177
177
  const wrapperHeight = wrapper.offsetHeight;
178
178
  const itemHeight = this.getItmHeight(node);
179
- const targetTop = node.offsetTop - (wrapperHeight - itemHeight) / 2;
179
+ const targetTop = (node.offsetTop || this.list.children.length * itemHeight / 2) - (wrapperHeight - itemHeight) / 2;
180
180
  this.scrollToPos(targetTop, duration);
181
181
  };
182
182
 
@@ -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;
@@ -1,7 +1,7 @@
1
1
  import _noop from "lodash/noop";
2
2
  import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
3
3
 
4
- /* eslint-disable max-len, jsx-a11y/role-supports-aria-props */
4
+ /* eslint-disable max-len */
5
5
  import React from 'react';
6
6
  import cls from 'classnames';
7
7
  import PropTypes from 'prop-types';
@@ -14,9 +14,19 @@ import Spin from '../spin';
14
14
  class Switch extends BaseComponent {
15
15
  constructor(props) {
16
16
  super(props);
17
+
18
+ this.handleFocusVisible = event => {
19
+ this.foundation.handleFocusVisible(event);
20
+ };
21
+
22
+ this.handleBlur = event => {
23
+ this.foundation.handleBlur();
24
+ };
25
+
17
26
  this.state = {
18
27
  nativeControlChecked: false,
19
- nativeControlDisabled: false
28
+ nativeControlDisabled: false,
29
+ focusVisible: false
20
30
  };
21
31
  this.switchRef = /*#__PURE__*/React.createRef();
22
32
  this.foundation = new SwitchFoudation(this.adapter);
@@ -52,6 +62,11 @@ class Switch extends BaseComponent {
52
62
  nativeControlDisabled
53
63
  });
54
64
  },
65
+ setFocusVisible: focusVisible => {
66
+ this.setState({
67
+ focusVisible
68
+ });
69
+ },
55
70
  notifyChange: (checked, e) => {
56
71
  this.props.onChange(checked, e);
57
72
  }
@@ -61,7 +76,8 @@ class Switch extends BaseComponent {
61
76
  render() {
62
77
  const {
63
78
  nativeControlChecked,
64
- nativeControlDisabled
79
+ nativeControlDisabled,
80
+ focusVisible
65
81
  } = this.state;
66
82
  const {
67
83
  className,
@@ -80,11 +96,11 @@ class Switch extends BaseComponent {
80
96
  [cssClasses.DISABLED]: nativeControlDisabled,
81
97
  [cssClasses.LARGE]: size === 'large',
82
98
  [cssClasses.SMALL]: size === 'small',
83
- [cssClasses.LOADING]: loading
99
+ [cssClasses.LOADING]: loading,
100
+ [cssClasses.FOCUS]: focusVisible
84
101
  });
85
102
  const switchProps = {
86
103
  type: 'checkbox',
87
- role: 'switch',
88
104
  className: cssClasses.NATIVE_CONTROL,
89
105
  disabled: nativeControlDisabled || loading,
90
106
  checked: nativeControlChecked || false
@@ -109,13 +125,17 @@ class Switch extends BaseComponent {
109
125
  }, uncheckedText) : null, /*#__PURE__*/React.createElement("input", _Object$assign({}, switchProps, {
110
126
  ref: this.switchRef,
111
127
  id: id,
128
+ role: 'switch',
112
129
  "aria-checked": nativeControlChecked,
113
130
  "aria-invalid": this.props['aria-invalid'],
114
131
  "aria-errormessage": this.props['aria-errormessage'],
115
132
  "aria-label": this.props['aria-label'],
116
133
  "aria-labelledby": this.props['aria-labelledby'],
117
134
  "aria-describedby": this.props["aria-describedby"],
118
- onChange: e => this.foundation.handleChange(e.target.checked, e)
135
+ "aria-disabled": this.props['disabled'],
136
+ onChange: e => this.foundation.handleChange(e.target.checked, e),
137
+ onFocus: e => this.handleFocusVisible(e),
138
+ onBlur: e => this.handleBlur(e)
119
139
  })));
120
140
  }
121
141
 
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import PropTypes from 'prop-types';
2
3
  import BaseComponent, { BaseProps } from '../_base/baseComponent';
3
4
  import ScrollItem from '../scrollList/scrollItem';
@@ -97,11 +97,11 @@ export default class TimePicker extends BaseComponent<TimePickerProps, TimePicke
97
97
  'aria-required': PropTypes.Requireable<boolean>;
98
98
  prefixCls: PropTypes.Requireable<string>;
99
99
  clearText: PropTypes.Requireable<string>;
100
- value: PropTypes.Requireable<string | number | string[] | Date | number[] | Date[]>;
100
+ value: PropTypes.Requireable<string | number | string[] | number[] | Date | Date[]>;
101
101
  inputReadOnly: PropTypes.Requireable<boolean>;
102
102
  disabled: PropTypes.Requireable<boolean>;
103
103
  showClear: PropTypes.Requireable<boolean>;
104
- defaultValue: PropTypes.Requireable<string | number | string[] | Date | number[] | Date[]>;
104
+ defaultValue: PropTypes.Requireable<string | number | string[] | number[] | Date | Date[]>;
105
105
  open: PropTypes.Requireable<boolean>;
106
106
  defaultOpen: PropTypes.Requireable<boolean>;
107
107
  onOpenChange: PropTypes.Requireable<(...args: any[]) => any>;
@@ -6,5 +6,5 @@ import PropTypes from 'prop-types';
6
6
  * - \[12:00:12, 12:21:12]
7
7
  * - \[[12:00:12, 12:21:12], [12:11:12, 12:32:12]]
8
8
  */
9
- declare const TimeShape: PropTypes.Requireable<string | number | string[] | Date | number[] | Date[]>;
9
+ declare const TimeShape: PropTypes.Requireable<string | number | string[] | number[] | Date | Date[]>;
10
10
  export { TimeShape };
@@ -18,11 +18,11 @@ export default class LocaleTimePicker extends React.PureComponent<LocalePickerPr
18
18
  'aria-required': import("prop-types").Requireable<boolean>;
19
19
  prefixCls: import("prop-types").Requireable<string>;
20
20
  clearText: import("prop-types").Requireable<string>;
21
- value: import("prop-types").Requireable<string | number | string[] | Date | number[] | Date[]>;
21
+ value: import("prop-types").Requireable<string | number | string[] | number[] | Date | Date[]>;
22
22
  inputReadOnly: import("prop-types").Requireable<boolean>;
23
23
  disabled: import("prop-types").Requireable<boolean>;
24
24
  showClear: import("prop-types").Requireable<boolean>;
25
- defaultValue: import("prop-types").Requireable<string | number | string[] | Date | number[] | Date[]>;
25
+ defaultValue: import("prop-types").Requireable<string | number | string[] | number[] | Date | Date[]>;
26
26
  open: import("prop-types").Requireable<boolean>;
27
27
  defaultOpen: import("prop-types").Requireable<boolean>;
28
28
  onOpenChange: import("prop-types").Requireable<(...args: any[]) => any>;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { ToastProps } from '@douyinfe/semi-foundation/lib/es/toast/toastFoundation';
2
3
  export default function useToast(): (JSX.Element | {
3
4
  success: (config: ToastProps) => string;
@@ -53,7 +53,6 @@ export interface TooltipProps extends BaseProps {
53
53
  guardFocus?: boolean;
54
54
  returnFocusOnClose?: boolean;
55
55
  onEscKeyDown?: (e: React.KeyboardEvent) => void;
56
- wrapperId?: string;
57
56
  }
58
57
  interface TooltipState {
59
58
  visible: boolean;
@@ -165,6 +164,7 @@ export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
165
164
  componentDidUpdate(prevProps: TooltipProps, prevState: TooltipState): void;
166
165
  renderIcon: () => any;
167
166
  handlePortalInnerClick: (e: React.MouseEvent) => void;
167
+ handlePortalMouseDown: (e: React.MouseEvent) => void;
168
168
  handlePortalInnerKeyDown: (e: React.KeyboardEvent) => void;
169
169
  renderContentNode: (content: TooltipProps['content']) => React.ReactNode;
170
170
  renderPortal: () => JSX.Element;
@@ -138,6 +138,12 @@ export default class Tooltip extends BaseComponent {
138
138
  }
139
139
  };
140
140
 
141
+ this.handlePortalMouseDown = e => {
142
+ if (this.props.stopPropagation) {
143
+ stopPropagation(e);
144
+ }
145
+ };
146
+
141
147
  this.handlePortalInnerKeyDown = e => {
142
148
  this.foundation.handleContainerKeydown(e);
143
149
  };
@@ -212,7 +218,7 @@ export default class Tooltip extends BaseComponent {
212
218
  }, portalEventSet, {
213
219
  "x-placement": placement,
214
220
  style: _Object$assign({
215
- visibility: motion ? undefined : 'visible'
221
+ visibility: motion ? 'hidden' : 'visible'
216
222
  }, style)
217
223
  }), contentNode, icon);
218
224
  return /*#__PURE__*/React.createElement(Portal, {
@@ -225,6 +231,7 @@ export default class Tooltip extends BaseComponent {
225
231
  style: portalInnerStyle,
226
232
  ref: this.setContainerEl,
227
233
  onClick: this.handlePortalInnerClick,
234
+ onMouseDown: this.handlePortalMouseDown,
228
235
  onKeyDown: this.handlePortalInnerKeyDown
229
236
  }, inner));
230
237
  };
@@ -286,7 +293,7 @@ export default class Tooltip extends BaseComponent {
286
293
  placement: props.position || 'top',
287
294
  transitionStyle: {},
288
295
  isPositionUpdated: false,
289
- id: props.wrapperId // auto generate id, will be used by children.aria-describedby & content.id, improve a11y
296
+ id: getUuidShort() // auto generate id, will be used by children.aria-describedby & content.id, improve a11y
290
297
 
291
298
  };
292
299
  this.foundation = new TooltipFoundation(this.adapter);
@@ -457,15 +464,11 @@ export default class Tooltip extends BaseComponent {
457
464
  }
458
465
  };
459
466
 
460
- document.addEventListener('mousedown', this.clickOutsideHandler, {
461
- capture: true
462
- });
467
+ window.addEventListener('mousedown', this.clickOutsideHandler);
463
468
  },
464
469
  unregisterClickOutsideHandler: () => {
465
470
  if (this.clickOutsideHandler) {
466
- document.removeEventListener('mousedown', this.clickOutsideHandler, {
467
- capture: true
468
- });
471
+ window.removeEventListener('mousedown', this.clickOutsideHandler);
469
472
  this.clickOutsideHandler = null;
470
473
  }
471
474
  },
@@ -559,11 +562,6 @@ export default class Tooltip extends BaseComponent {
559
562
  },
560
563
  notifyEscKeydown: event => {
561
564
  this.props.onEscKeyDown(event);
562
- },
563
- setId: () => {
564
- this.setState({
565
- id: getUuidShort()
566
- });
567
565
  }
568
566
  });
569
567
  }
@@ -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 {
@@ -37,7 +37,7 @@ export default class Title extends PureComponent<TitleProps> {
37
37
  underline: PropTypes.Requireable<boolean>;
38
38
  strong: PropTypes.Requireable<boolean>;
39
39
  type: PropTypes.Requireable<"warning" | "success" | "primary" | "tertiary" | "secondary" | "danger" | "quaternary">;
40
- heading: PropTypes.Requireable<4 | 2 | 1 | 3 | 6 | 5>;
40
+ heading: PropTypes.Requireable<1 | 2 | 3 | 4 | 5 | 6>;
41
41
  style: PropTypes.Requireable<object>;
42
42
  className: PropTypes.Requireable<string>;
43
43
  component: PropTypes.Requireable<string>;
@@ -140,7 +140,7 @@ declare class Upload extends BaseComponent<UploadProps, UploadState> {
140
140
  style: PropTypes.Requireable<object>;
141
141
  timeout: PropTypes.Requireable<number>;
142
142
  transformFile: PropTypes.Requireable<(...args: any[]) => any>;
143
- uploadTrigger: PropTypes.Requireable<"custom" | "auto">;
143
+ uploadTrigger: PropTypes.Requireable<"auto" | "custom">;
144
144
  validateMessage: PropTypes.Requireable<PropTypes.ReactNodeLike>;
145
145
  validateStatus: PropTypes.Requireable<"default" | "error" | "warning" | "success">;
146
146
  withCredentials: PropTypes.Requireable<boolean>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-ui",
3
- "version": "2.10.0-alpha.0",
3
+ "version": "2.10.1",
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.9.0",
18
- "@douyinfe/semi-animation-react": "2.9.0",
19
- "@douyinfe/semi-foundation": "^2.10.0-alpha.0",
20
- "@douyinfe/semi-icons": "2.9.0",
21
- "@douyinfe/semi-illustrations": "2.9.0",
22
- "@douyinfe/semi-theme-default": "2.9.0",
17
+ "@douyinfe/semi-animation": "2.10.1",
18
+ "@douyinfe/semi-animation-react": "2.10.1",
19
+ "@douyinfe/semi-foundation": "2.10.1",
20
+ "@douyinfe/semi-icons": "2.10.1",
21
+ "@douyinfe/semi-illustrations": "2.10.1",
22
+ "@douyinfe/semi-theme-default": "2.10.1",
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": "5d1bb1d031052d7584ecd5d1bc444cd13f861337",
72
+ "gitHead": "1c84b585ff43db35b286e8c24f8333e4170d015c",
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.9.0",
78
+ "@douyinfe/semi-scss-compile": "2.10.1",
79
79
  "@storybook/addon-knobs": "^6.3.1",
80
80
  "@types/lodash": "^4.14.176",
81
81
  "babel-loader": "^8.2.2",