@douyinfe/semi-ui 2.9.1 → 2.10.0-alpha.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 (67) hide show
  1. package/badge/_story/badge.stories.js +2 -34
  2. package/checkbox/checkbox.tsx +18 -8
  3. package/dist/css/semi.css +0 -1
  4. package/dist/css/semi.min.css +1 -1
  5. package/dist/umd/semi-ui.js +23030 -22978
  6. package/dist/umd/semi-ui.js.map +1 -1
  7. package/dist/umd/semi-ui.min.js +1 -1
  8. package/dist/umd/semi-ui.min.js.map +1 -1
  9. package/form/hoc/withField.tsx +5 -8
  10. package/lib/cjs/_portal/index.d.ts +1 -1
  11. package/lib/cjs/checkbox/checkbox.d.ts +4 -0
  12. package/lib/cjs/checkbox/checkbox.js +25 -13
  13. package/lib/cjs/datePicker/dateInput.d.ts +1 -1
  14. package/lib/cjs/datePicker/datePicker.d.ts +1 -1
  15. package/lib/cjs/datePicker/insetInput.d.ts +0 -1
  16. package/lib/cjs/datePicker/monthsGrid.d.ts +1 -1
  17. package/lib/cjs/dropdown/dropdownMenu.d.ts +0 -1
  18. package/lib/cjs/form/baseForm.d.ts +1 -1
  19. package/lib/cjs/form/field.d.ts +1 -1
  20. package/lib/cjs/form/hoc/withField.js +4 -6
  21. package/lib/cjs/modal/useModal/index.d.ts +0 -1
  22. package/lib/cjs/notification/useNotification/index.d.ts +0 -1
  23. package/lib/cjs/radio/radio.d.ts +5 -1
  24. package/lib/cjs/radio/radio.js +26 -12
  25. package/lib/cjs/radio/radioGroup.d.ts +1 -1
  26. package/lib/cjs/scrollList/scrollItem.js +1 -1
  27. package/lib/cjs/timePicker/Combobox.d.ts +0 -1
  28. package/lib/cjs/timePicker/TimePicker.d.ts +2 -2
  29. package/lib/cjs/timePicker/TimeShape.d.ts +1 -1
  30. package/lib/cjs/timePicker/index.d.ts +2 -2
  31. package/lib/cjs/toast/useToast/index.d.ts +0 -1
  32. package/lib/cjs/tooltip/index.d.ts +1 -0
  33. package/lib/cjs/tooltip/index.js +7 -2
  34. package/lib/cjs/typography/title.d.ts +1 -1
  35. package/lib/cjs/upload/index.d.ts +1 -1
  36. package/lib/es/_portal/index.d.ts +1 -1
  37. package/lib/es/checkbox/checkbox.d.ts +4 -0
  38. package/lib/es/checkbox/checkbox.js +25 -13
  39. package/lib/es/datePicker/dateInput.d.ts +1 -1
  40. package/lib/es/datePicker/datePicker.d.ts +1 -1
  41. package/lib/es/datePicker/insetInput.d.ts +0 -1
  42. package/lib/es/datePicker/monthsGrid.d.ts +1 -1
  43. package/lib/es/dropdown/dropdownMenu.d.ts +0 -1
  44. package/lib/es/form/baseForm.d.ts +1 -1
  45. package/lib/es/form/field.d.ts +1 -1
  46. package/lib/es/form/hoc/withField.js +4 -6
  47. package/lib/es/modal/useModal/index.d.ts +0 -1
  48. package/lib/es/notification/useNotification/index.d.ts +0 -1
  49. package/lib/es/radio/radio.d.ts +5 -1
  50. package/lib/es/radio/radio.js +26 -12
  51. package/lib/es/radio/radioGroup.d.ts +1 -1
  52. package/lib/es/scrollList/scrollItem.js +1 -1
  53. package/lib/es/timePicker/Combobox.d.ts +0 -1
  54. package/lib/es/timePicker/TimePicker.d.ts +2 -2
  55. package/lib/es/timePicker/TimeShape.d.ts +1 -1
  56. package/lib/es/timePicker/index.d.ts +2 -2
  57. package/lib/es/toast/useToast/index.d.ts +0 -1
  58. package/lib/es/tooltip/index.d.ts +1 -0
  59. package/lib/es/tooltip/index.js +7 -2
  60. package/lib/es/typography/title.d.ts +1 -1
  61. package/lib/es/upload/index.d.ts +1 -1
  62. package/package.json +9 -9
  63. package/radio/radio.tsx +17 -7
  64. package/scrollList/scrollItem.tsx +1 -1
  65. package/timePicker/TimePicker.tsx +1 -1
  66. package/timePicker/_story/timepicker.stories.js +1 -20
  67. package/tooltip/index.tsx +6 -2
@@ -15,7 +15,6 @@ import { Col } from '../../grid';
15
15
  import { CallOpts, WithFieldOption } from '@douyinfe/semi-foundation/form/interface';
16
16
  import { CommonFieldProps, CommonexcludeType } from '../interface';
17
17
  import { Subtract } from 'utility-types';
18
- import { noop } from "lodash";
19
18
 
20
19
  const prefix = cssClasses.PREFIX;
21
20
 
@@ -122,7 +121,6 @@ function withField<
122
121
  const [status, setStatus] = useState(validateStatus); // use props.validateStatus to init
123
122
 
124
123
  const rulesRef = useRef(rules);
125
- const validateRef = useRef(validate);
126
124
 
127
125
  // notNotify is true means that the onChange of the Form does not need to be triggered
128
126
  // notUpdate is true means that this operation does not need to trigger the forceUpdate
@@ -223,7 +221,7 @@ function withField<
223
221
  let maybePromisedErrors;
224
222
  // let errorThrowSync;
225
223
  try {
226
- maybePromisedErrors = validateRef.current(val, values);
224
+ maybePromisedErrors = validate(val, values);
227
225
  } catch (err) {
228
226
  // error throw by syncValidate
229
227
  maybePromisedErrors = err;
@@ -260,7 +258,7 @@ function withField<
260
258
  if (transform) {
261
259
  finalVal = transform(val);
262
260
  }
263
- if (validateRef.current) {
261
+ if (validate) {
264
262
  return _validate(finalVal, updater.getValue(), callOpts);
265
263
  } else if (latestRules) {
266
264
  return _validateInternal(finalVal, callOpts);
@@ -359,8 +357,7 @@ function withField<
359
357
  // avoid hooks capture value, fixed issue 346
360
358
  useLayoutEffect(() => {
361
359
  rulesRef.current = rules;
362
- validateRef.current = validate;
363
- }, [rules, validate]);
360
+ }, [rules]);
364
361
 
365
362
  // exec validate once when trigger inlcude 'mount'
366
363
  useLayoutEffect(() => {
@@ -445,11 +442,11 @@ function withField<
445
442
  if (helpText) {
446
443
  newProps['aria-describedby'] = extraText ? `${helpTextId} ${extraTextId}` : helpTextId;
447
444
  }
448
-
445
+
449
446
  if (extraText) {
450
447
  newProps['aria-describedby'] = helpText ? `${helpTextId} ${extraTextId}` : extraTextId;
451
448
  }
452
-
449
+
453
450
  if (status === 'error') {
454
451
  newProps['aria-errormessage'] = errorMessageId;
455
452
  newProps['aria-invalid'] = true;
@@ -33,6 +33,6 @@ declare class Portal extends PureComponent<PortalProps, PortalState> {
33
33
  componentWillUnmount(): void;
34
34
  addStyle: (style?: {}) => void;
35
35
  addClass: (prefixCls: string, ...classNames: string[]) => void;
36
- render(): React.ReactPortal;
36
+ render(): import("react").ReactPortal;
37
37
  }
38
38
  export default Portal;
@@ -22,9 +22,13 @@ export interface CheckboxProps extends BaseCheckboxProps {
22
22
  'aria-label'?: React.AriaAttributes['aria-label'];
23
23
  role?: React.HTMLAttributes<HTMLSpanElement>['role'];
24
24
  tabIndex?: number;
25
+ addonId?: string;
26
+ extraId?: string;
25
27
  }
26
28
  interface CheckboxState {
27
29
  checked: boolean;
30
+ addonId?: string;
31
+ extraId?: string;
28
32
  }
29
33
  declare class Checkbox extends BaseComponent<CheckboxProps, CheckboxState> {
30
34
  static contextType: React.Context<CheckboxContextType>;
@@ -51,15 +51,11 @@ class Checkbox extends _baseComponent.default {
51
51
 
52
52
  const checked = false;
53
53
  this.state = {
54
- checked: props.checked || props.defaultChecked || checked
54
+ checked: props.checked || props.defaultChecked || checked,
55
+ addonId: props.addonId,
56
+ extraId: props.extraId
55
57
  };
56
58
  this.checkboxEntity = null;
57
- this.addonId = (0, _uuid.getUuidShort)({
58
- prefix: 'addon'
59
- });
60
- this.extraId = (0, _uuid.getUuidShort)({
61
- prefix: 'extra'
62
- });
63
59
  this.foundation = new _checkboxFoundation.default(this.adapter);
64
60
  }
65
61
 
@@ -81,7 +77,21 @@ class Checkbox extends _baseComponent.default {
81
77
  notifyGroupChange: cbContent => {
82
78
  this.context.checkboxGroup.onChange(cbContent);
83
79
  },
84
- getGroupDisabled: () => this.context && this.context.checkboxGroup.disabled
80
+ getGroupDisabled: () => this.context && this.context.checkboxGroup.disabled,
81
+ setAddonId: () => {
82
+ this.setState({
83
+ addonId: (0, _uuid.getUuidShort)({
84
+ prefix: 'addon'
85
+ })
86
+ });
87
+ },
88
+ setExtraId: () => {
89
+ this.setState({
90
+ extraId: (0, _uuid.getUuidShort)({
91
+ prefix: 'extra'
92
+ })
93
+ });
94
+ }
85
95
  });
86
96
  }
87
97
 
@@ -124,7 +134,9 @@ class Checkbox extends _baseComponent.default {
124
134
  id
125
135
  } = this.props;
126
136
  const {
127
- checked
137
+ checked,
138
+ addonId,
139
+ extraId
128
140
  } = this.state;
129
141
  const props = {
130
142
  checked,
@@ -171,10 +183,10 @@ class Checkbox extends _baseComponent.default {
171
183
  const name = inGroup && this.context.checkboxGroup.name;
172
184
 
173
185
  const renderContent = () => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children ? /*#__PURE__*/_react.default.createElement("span", {
174
- id: this.addonId,
186
+ id: addonId,
175
187
  className: "".concat(prefix, "-addon")
176
188
  }, children) : null, extra ? /*#__PURE__*/_react.default.createElement("div", {
177
- id: this.extraId,
189
+ id: extraId,
178
190
  className: extraCls
179
191
  }, extra) : null);
180
192
 
@@ -194,8 +206,8 @@ class Checkbox extends _baseComponent.default {
194
206
  onKeyPress: this.handleEnterPress,
195
207
  "aria-labelledby": this.props['aria-labelledby']
196
208
  }, /*#__PURE__*/_react.default.createElement(_checkboxInner.default, (0, _assign.default)({}, this.props, props, {
197
- addonId: children && this.addonId,
198
- extraId: extra && this.extraId,
209
+ addonId: children && addonId,
210
+ extraId: extra && extraId,
199
211
  name: name,
200
212
  isPureCardType: props.isPureCardType,
201
213
  ref: ref => {
@@ -26,7 +26,7 @@ export default class DateInput extends BaseComponent<DateInputProps, {}> {
26
26
  onFocus: PropTypes.Requireable<(...args: any[]) => any>;
27
27
  value: PropTypes.Requireable<any[]>;
28
28
  disabled: PropTypes.Requireable<boolean>;
29
- type: PropTypes.Requireable<"dateTime" | "date" | "month" | "dateRange" | "year" | "dateTimeRange">;
29
+ type: PropTypes.Requireable<"date" | "month" | "dateTime" | "dateRange" | "year" | "dateTimeRange">;
30
30
  showClear: PropTypes.Requireable<boolean>;
31
31
  format: PropTypes.Requireable<string>;
32
32
  inputStyle: PropTypes.Requireable<object>;
@@ -41,7 +41,7 @@ export default class DatePicker extends BaseComponent<DatePickerProps, DatePicke
41
41
  'aria-invalid': PropTypes.Requireable<boolean>;
42
42
  'aria-labelledby': PropTypes.Requireable<string>;
43
43
  'aria-required': PropTypes.Requireable<boolean>;
44
- type: PropTypes.Requireable<"dateTime" | "date" | "month" | "dateRange" | "year" | "dateTimeRange">;
44
+ type: PropTypes.Requireable<"date" | "month" | "dateTime" | "dateRange" | "year" | "dateTimeRange">;
45
45
  size: PropTypes.Requireable<"default" | "small" | "large">;
46
46
  density: PropTypes.Requireable<"default" | "compact">;
47
47
  defaultValue: PropTypes.Requireable<string | number | object>;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { InsetInputValue, Type, InsetInputChangeFoundationProps } from '@douyinfe/semi-foundation/lib/cjs/datePicker/inputFoundation';
3
2
  import { InputProps } from '../input';
4
3
  export interface InsetDateInputProps {
@@ -17,7 +17,7 @@ export interface MonthsGridProps extends MonthsGridFoundationProps, BaseProps {
17
17
  export declare type MonthsGridState = MonthsGridFoundationState;
18
18
  export default class MonthsGrid extends BaseComponent<MonthsGridProps, MonthsGridState> {
19
19
  static propTypes: {
20
- type: PropTypes.Requireable<"dateTime" | "date" | "month" | "dateRange" | "year" | "dateTimeRange">;
20
+ type: PropTypes.Requireable<"date" | "month" | "dateTime" | "dateRange" | "year" | "dateTimeRange">;
21
21
  defaultValue: PropTypes.Requireable<string | number | object>;
22
22
  defaultPickerValue: PropTypes.Requireable<string | number | object>;
23
23
  multiple: PropTypes.Requireable<boolean>;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import PropTypes from 'prop-types';
3
2
  import BaseComponent, { BaseProps } from '../_base/baseComponent';
4
3
  export declare type DropdownMenuProps = BaseProps;
@@ -125,7 +125,7 @@ declare class Form extends BaseComponent<BaseFormProps, BaseFormState> {
125
125
  onBlur?: (e: React.FocusEvent<Element, Element>) => void;
126
126
  onListScroll?: (e: React.UIEvent<HTMLDivElement, UIEvent>) => void;
127
127
  children?: React.ReactNode;
128
- } & Pick<import("../tooltip").TooltipProps, "stopPropagation" | "getPopupContainer" | "spacing" | "mouseEnterDelay" | "autoAdjustOverflow" | "mouseLeaveDelay" | "motion"> & React.RefAttributes<any> & import("./interface").CommonFieldProps, import("./interface").CommonexcludeType>> & import("./interface").SelectStatic;
128
+ } & Pick<import("../tooltip").TooltipProps, "getPopupContainer" | "stopPropagation" | "spacing" | "mouseEnterDelay" | "autoAdjustOverflow" | "mouseLeaveDelay" | "motion"> & React.RefAttributes<any> & import("./interface").CommonFieldProps, import("./interface").CommonexcludeType>> & import("./interface").SelectStatic;
129
129
  static Checkbox: React.ComponentType<import("utility-types").Subtract<import("./interface").CommonFieldProps, import("./interface").RadioCheckboxExcludeProps> & import("../checkbox").CheckboxProps & import("./interface").RCIncludeType>;
130
130
  static CheckboxGroup: React.ComponentType<import("utility-types").Subtract<import("../checkbox").CheckboxGroupProps, import("./interface").CommonexcludeType> & import("./interface").CommonFieldProps>;
131
131
  static Radio: React.ComponentType<import("utility-types").Subtract<import("./interface").CommonFieldProps, import("./interface").RadioCheckboxExcludeProps> & import("../radio").RadioProps & import("./interface").RCIncludeType>;
@@ -73,7 +73,7 @@ declare const FormSelect: import("react").ComponentType<import("utility-types").
73
73
  onBlur?: (e: import("react").FocusEvent<Element, Element>) => void;
74
74
  onListScroll?: (e: import("react").UIEvent<HTMLDivElement, UIEvent>) => void;
75
75
  children?: import("react").ReactNode;
76
- } & Pick<import("../tooltip").TooltipProps, "stopPropagation" | "getPopupContainer" | "spacing" | "mouseEnterDelay" | "autoAdjustOverflow" | "mouseLeaveDelay" | "motion"> & import("react").RefAttributes<any> & import("./interface").CommonFieldProps, import("./interface").CommonexcludeType>> & import("./interface").SelectStatic;
76
+ } & Pick<import("../tooltip").TooltipProps, "getPopupContainer" | "stopPropagation" | "spacing" | "mouseEnterDelay" | "autoAdjustOverflow" | "mouseLeaveDelay" | "motion"> & import("react").RefAttributes<any> & import("./interface").CommonFieldProps, import("./interface").CommonexcludeType>> & import("./interface").SelectStatic;
77
77
  declare const FormCheckboxGroup: import("react").ComponentType<import("utility-types").Subtract<import("../checkbox/checkboxGroup").CheckboxGroupProps, import("./interface").CommonexcludeType> & import("./interface").CommonFieldProps>;
78
78
  declare const FormCheckbox: import("react").ComponentType<import("utility-types").Subtract<import("./interface").CommonFieldProps, import("./interface").RadioCheckboxExcludeProps> & import("../checkbox/checkbox").CheckboxProps & import("./interface").RCIncludeType>;
79
79
  declare const FormRadioGroup: import("react").ComponentType<import("utility-types").Subtract<import("../radio/radioGroup").RadioGroupProps, import("./interface").CommonexcludeType> & import("./interface").CommonFieldProps>;
@@ -147,8 +147,7 @@ function withField(Component, opts) {
147
147
  const [cursor, setCursor, getCursor] = (0, _index.useStateWithGetter)(0);
148
148
  const [status, setStatus] = (0, _react.useState)(validateStatus); // use props.validateStatus to init
149
149
 
150
- const rulesRef = (0, _react.useRef)(rules);
151
- const validateRef = (0, _react.useRef)(validate); // notNotify is true means that the onChange of the Form does not need to be triggered
150
+ const rulesRef = (0, _react.useRef)(rules); // notNotify is true means that the onChange of the Form does not need to be triggered
152
151
  // notUpdate is true means that this operation does not need to trigger the forceUpdate
153
152
 
154
153
  const updateTouched = (isTouched, callOpts) => {
@@ -247,7 +246,7 @@ function withField(Component, opts) {
247
246
  let maybePromisedErrors; // let errorThrowSync;
248
247
 
249
248
  try {
250
- maybePromisedErrors = validateRef.current(val, values);
249
+ maybePromisedErrors = validate(val, values);
251
250
  } catch (err) {
252
251
  // error throw by syncValidate
253
252
  maybePromisedErrors = err;
@@ -287,7 +286,7 @@ function withField(Component, opts) {
287
286
  finalVal = transform(val);
288
287
  }
289
288
 
290
- if (validateRef.current) {
289
+ if (validate) {
291
290
  return _validate(finalVal, updater.getValue(), callOpts);
292
291
  } else if (latestRules) {
293
292
  return _validateInternal(finalVal, callOpts);
@@ -396,8 +395,7 @@ function withField(Component, opts) {
396
395
 
397
396
  (0, _react.useLayoutEffect)(() => {
398
397
  rulesRef.current = rules;
399
- validateRef.current = validate;
400
- }, [rules, validate]); // exec validate once when trigger inlcude 'mount'
398
+ }, [rules]); // exec validate once when trigger inlcude 'mount'
401
399
 
402
400
  (0, _react.useLayoutEffect)(() => {
403
401
  if (validateOnMount) {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ConfirmProps } from '../confirm';
3
2
  import { ModalReactProps } from '../Modal';
4
3
  export default function useModal(): (JSX.Element | {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import '@douyinfe/semi-foundation/lib/cjs/notification/notification.css';
3
2
  import { NoticeProps } from '@douyinfe/semi-foundation/lib/cjs/notification/notificationFoundation';
4
3
  export default function useNotification(): (JSX.Element | {
@@ -29,9 +29,13 @@ 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;
32
34
  };
33
35
  export interface RadioState {
34
36
  hover?: boolean;
37
+ addonId?: string;
38
+ extraId?: string;
35
39
  }
36
40
  export { RadioChangeEvent };
37
41
  declare class Radio extends BaseComponent<RadioProps, RadioState> {
@@ -71,7 +75,7 @@ declare class Radio extends BaseComponent<RadioProps, RadioState> {
71
75
  prefixCls?: string;
72
76
  name?: string;
73
77
  onChange?: (e: RadioChangeEvent) => void;
74
- buttonSize?: "small" | "middle" | "large";
78
+ buttonSize?: "small" | "large" | "middle";
75
79
  isCardRadio?: boolean;
76
80
  isPureCardRadio?: boolean;
77
81
  };
@@ -67,16 +67,12 @@ class Radio extends _baseComponent.default {
67
67
  };
68
68
 
69
69
  this.state = {
70
- hover: false
70
+ hover: false,
71
+ addonId: props.addonId,
72
+ extraId: props.extraId
71
73
  };
72
74
  this.foundation = new _radioFoundation.default(this.adapter);
73
75
  this.radioEntity = null;
74
- this.addonId = (0, _uuid.getUuidShort)({
75
- prefix: 'addon'
76
- });
77
- this.extraId = (0, _uuid.getUuidShort)({
78
- prefix: 'extra'
79
- });
80
76
  }
81
77
 
82
78
  get adapter() {
@@ -85,6 +81,20 @@ class Radio extends _baseComponent.default {
85
81
  this.setState({
86
82
  hover
87
83
  });
84
+ },
85
+ setAddonId: () => {
86
+ this.setState({
87
+ addonId: (0, _uuid.getUuidShort)({
88
+ prefix: 'addon'
89
+ })
90
+ });
91
+ },
92
+ setExtraId: () => {
93
+ this.setState({
94
+ extraId: (0, _uuid.getUuidShort)({
95
+ prefix: 'extra'
96
+ })
97
+ });
88
98
  }
89
99
  });
90
100
  }
@@ -121,7 +131,11 @@ class Radio extends _baseComponent.default {
121
131
  value: propValue
122
132
  } = this.props;
123
133
  let realChecked, isDisabled, realMode, isButtonRadioGroup, isCardRadioGroup, isPureCardRadioGroup, isButtonRadioComponent, buttonSize, realPrefixCls;
124
- const isHover = this.state.hover;
134
+ const {
135
+ hover: isHover,
136
+ addonId,
137
+ extraId
138
+ } = this.state;
125
139
  let props = {};
126
140
 
127
141
  if (this.isInGroup()) {
@@ -174,10 +188,10 @@ class Radio extends _baseComponent.default {
174
188
  const renderContent = () => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children ? /*#__PURE__*/_react.default.createElement("span", {
175
189
  className: addonCls,
176
190
  style: addonStyle,
177
- id: this.addonId
191
+ id: addonId
178
192
  }, children) : null, extra && !isButtonRadio ? /*#__PURE__*/_react.default.createElement("div", {
179
193
  className: "".concat(prefix, "-extra"),
180
- id: this.extraId
194
+ id: extraId
181
195
  }, extra) : null);
182
196
 
183
197
  return /*#__PURE__*/_react.default.createElement("label", {
@@ -194,8 +208,8 @@ class Radio extends _baseComponent.default {
194
208
  ref: ref => {
195
209
  this.radioEntity = ref;
196
210
  },
197
- addonId: children && this.addonId,
198
- extraId: extra && this.extraId
211
+ addonId: children && addonId,
212
+ extraId: extra && extraId
199
213
  })), isCardRadioGroup ? /*#__PURE__*/_react.default.createElement("div", {
200
214
  className: "".concat(prefix, "-isCardRadioGroup_content")
201
215
  }, 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" | "middle" | "large">;
51
+ buttonSize: PropTypes.Requireable<"small" | "large" | "middle">;
52
52
  type: PropTypes.Requireable<"default" | "button" | "card" | "pureCard">;
53
53
  value: PropTypes.Requireable<any>;
54
54
  onChange: PropTypes.Requireable<(...args: any[]) => any>;
@@ -201,7 +201,7 @@ class ScrollItem extends _baseComponent.default {
201
201
  } = this;
202
202
  const wrapperHeight = wrapper.offsetHeight;
203
203
  const itemHeight = this.getItmHeight(node);
204
- const targetTop = (node.offsetTop || this.list.children.length * itemHeight / 2) - (wrapperHeight - itemHeight) / 2;
204
+ const targetTop = node.offsetTop - (wrapperHeight - itemHeight) / 2;
205
205
  this.scrollToPos(targetTop, duration);
206
206
  };
207
207
 
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import PropTypes from 'prop-types';
3
2
  import BaseComponent, { BaseProps } from '../_base/baseComponent';
4
3
  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[] | number[] | Date | Date[]>;
100
+ value: PropTypes.Requireable<string | number | string[] | Date | number[] | 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[] | number[] | Date | Date[]>;
104
+ defaultValue: PropTypes.Requireable<string | number | string[] | Date | number[] | 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[] | number[] | Date | Date[]>;
9
+ declare const TimeShape: PropTypes.Requireable<string | number | string[] | Date | number[] | 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[] | number[] | Date | Date[]>;
21
+ value: import("prop-types").Requireable<string | number | string[] | Date | number[] | 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[] | number[] | Date | Date[]>;
25
+ defaultValue: import("prop-types").Requireable<string | number | string[] | Date | number[] | 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,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ToastProps } from '@douyinfe/semi-foundation/lib/cjs/toast/toastFoundation';
3
2
  export default function useToast(): (JSX.Element | {
4
3
  success: (config: ToastProps) => string;
@@ -53,6 +53,7 @@ export interface TooltipProps extends BaseProps {
53
53
  guardFocus?: boolean;
54
54
  returnFocusOnClose?: boolean;
55
55
  onEscKeyDown?: (e: React.KeyboardEvent) => void;
56
+ wrapperId?: string;
56
57
  }
57
58
  interface TooltipState {
58
59
  visible: boolean;
@@ -258,7 +258,7 @@ class Tooltip extends _baseComponent.default {
258
258
  }, portalEventSet, {
259
259
  "x-placement": placement,
260
260
  style: (0, _assign.default)({
261
- visibility: motion ? 'hidden' : 'visible'
261
+ visibility: motion ? undefined : 'visible'
262
262
  }, style)
263
263
  }), contentNode, icon);
264
264
  return /*#__PURE__*/_react.default.createElement(_index.default, {
@@ -327,7 +327,7 @@ class Tooltip extends _baseComponent.default {
327
327
  placement: props.position || 'top',
328
328
  transitionStyle: {},
329
329
  isPositionUpdated: false,
330
- id: (0, _uuid.getUuidShort)() // auto generate id, will be used by children.aria-describedby & content.id, improve a11y
330
+ id: props.wrapperId // auto generate id, will be used by children.aria-describedby & content.id, improve a11y
331
331
 
332
332
  };
333
333
  this.foundation = new _foundation.default(this.adapter);
@@ -600,6 +600,11 @@ class Tooltip extends _baseComponent.default {
600
600
  },
601
601
  notifyEscKeydown: event => {
602
602
  this.props.onEscKeyDown(event);
603
+ },
604
+ setId: () => {
605
+ this.setState({
606
+ id: (0, _uuid.getUuidShort)()
607
+ });
603
608
  }
604
609
  });
605
610
  }
@@ -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<1 | 2 | 3 | 4 | 5 | 6>;
40
+ heading: PropTypes.Requireable<4 | 2 | 1 | 3 | 6 | 5>;
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<"auto" | "custom">;
143
+ uploadTrigger: PropTypes.Requireable<"custom" | "auto">;
144
144
  validateMessage: PropTypes.Requireable<PropTypes.ReactNodeLike>;
145
145
  validateStatus: PropTypes.Requireable<"default" | "error" | "warning" | "success">;
146
146
  withCredentials: PropTypes.Requireable<boolean>;
@@ -33,6 +33,6 @@ declare class Portal extends PureComponent<PortalProps, PortalState> {
33
33
  componentWillUnmount(): void;
34
34
  addStyle: (style?: {}) => void;
35
35
  addClass: (prefixCls: string, ...classNames: string[]) => void;
36
- render(): React.ReactPortal;
36
+ render(): import("react").ReactPortal;
37
37
  }
38
38
  export default Portal;
@@ -22,9 +22,13 @@ export interface CheckboxProps extends BaseCheckboxProps {
22
22
  'aria-label'?: React.AriaAttributes['aria-label'];
23
23
  role?: React.HTMLAttributes<HTMLSpanElement>['role'];
24
24
  tabIndex?: number;
25
+ addonId?: string;
26
+ extraId?: string;
25
27
  }
26
28
  interface CheckboxState {
27
29
  checked: boolean;
30
+ addonId?: string;
31
+ extraId?: string;
28
32
  }
29
33
  declare class Checkbox extends BaseComponent<CheckboxProps, CheckboxState> {
30
34
  static contextType: React.Context<CheckboxContextType>;
@@ -26,15 +26,11 @@ class Checkbox extends BaseComponent {
26
26
 
27
27
  const checked = false;
28
28
  this.state = {
29
- checked: props.checked || props.defaultChecked || checked
29
+ checked: props.checked || props.defaultChecked || checked,
30
+ addonId: props.addonId,
31
+ extraId: props.extraId
30
32
  };
31
33
  this.checkboxEntity = null;
32
- this.addonId = getUuidShort({
33
- prefix: 'addon'
34
- });
35
- this.extraId = getUuidShort({
36
- prefix: 'extra'
37
- });
38
34
  this.foundation = new CheckboxFoundation(this.adapter);
39
35
  }
40
36
 
@@ -56,7 +52,21 @@ class Checkbox extends BaseComponent {
56
52
  notifyGroupChange: cbContent => {
57
53
  this.context.checkboxGroup.onChange(cbContent);
58
54
  },
59
- getGroupDisabled: () => this.context && this.context.checkboxGroup.disabled
55
+ getGroupDisabled: () => this.context && this.context.checkboxGroup.disabled,
56
+ setAddonId: () => {
57
+ this.setState({
58
+ addonId: getUuidShort({
59
+ prefix: 'addon'
60
+ })
61
+ });
62
+ },
63
+ setExtraId: () => {
64
+ this.setState({
65
+ extraId: getUuidShort({
66
+ prefix: 'extra'
67
+ })
68
+ });
69
+ }
60
70
  });
61
71
  }
62
72
 
@@ -99,7 +109,9 @@ class Checkbox extends BaseComponent {
99
109
  id
100
110
  } = this.props;
101
111
  const {
102
- checked
112
+ checked,
113
+ addonId,
114
+ extraId
103
115
  } = this.state;
104
116
  const props = {
105
117
  checked,
@@ -147,10 +159,10 @@ class Checkbox extends BaseComponent {
147
159
  const name = inGroup && this.context.checkboxGroup.name;
148
160
 
149
161
  const renderContent = () => /*#__PURE__*/React.createElement(React.Fragment, null, children ? /*#__PURE__*/React.createElement("span", {
150
- id: this.addonId,
162
+ id: addonId,
151
163
  className: "".concat(prefix, "-addon")
152
164
  }, children) : null, extra ? /*#__PURE__*/React.createElement("div", {
153
- id: this.extraId,
165
+ id: extraId,
154
166
  className: extraCls
155
167
  }, extra) : null);
156
168
 
@@ -170,8 +182,8 @@ class Checkbox extends BaseComponent {
170
182
  onKeyPress: this.handleEnterPress,
171
183
  "aria-labelledby": this.props['aria-labelledby']
172
184
  }, /*#__PURE__*/React.createElement(CheckboxInner, _Object$assign({}, this.props, props, {
173
- addonId: children && this.addonId,
174
- extraId: extra && this.extraId,
185
+ addonId: children && addonId,
186
+ extraId: extra && extraId,
175
187
  name: name,
176
188
  isPureCardType: props.isPureCardType,
177
189
  ref: ref => {
@@ -26,7 +26,7 @@ export default class DateInput extends BaseComponent<DateInputProps, {}> {
26
26
  onFocus: PropTypes.Requireable<(...args: any[]) => any>;
27
27
  value: PropTypes.Requireable<any[]>;
28
28
  disabled: PropTypes.Requireable<boolean>;
29
- type: PropTypes.Requireable<"dateTime" | "date" | "month" | "dateRange" | "year" | "dateTimeRange">;
29
+ type: PropTypes.Requireable<"date" | "month" | "dateTime" | "dateRange" | "year" | "dateTimeRange">;
30
30
  showClear: PropTypes.Requireable<boolean>;
31
31
  format: PropTypes.Requireable<string>;
32
32
  inputStyle: PropTypes.Requireable<object>;
@@ -41,7 +41,7 @@ export default class DatePicker extends BaseComponent<DatePickerProps, DatePicke
41
41
  'aria-invalid': PropTypes.Requireable<boolean>;
42
42
  'aria-labelledby': PropTypes.Requireable<string>;
43
43
  'aria-required': PropTypes.Requireable<boolean>;
44
- type: PropTypes.Requireable<"dateTime" | "date" | "month" | "dateRange" | "year" | "dateTimeRange">;
44
+ type: PropTypes.Requireable<"date" | "month" | "dateTime" | "dateRange" | "year" | "dateTimeRange">;
45
45
  size: PropTypes.Requireable<"default" | "small" | "large">;
46
46
  density: PropTypes.Requireable<"default" | "compact">;
47
47
  defaultValue: PropTypes.Requireable<string | number | object>;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { InsetInputValue, Type, InsetInputChangeFoundationProps } from '@douyinfe/semi-foundation/lib/es/datePicker/inputFoundation';
3
2
  import { InputProps } from '../input';
4
3
  export interface InsetDateInputProps {