@douyinfe/semi-ui 2.10.2 → 2.11.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 (143) hide show
  1. package/anchor/link.tsx +2 -2
  2. package/autoComplete/index.tsx +3 -3
  3. package/avatar/interface.ts +2 -2
  4. package/badge/index.tsx +1 -1
  5. package/banner/index.tsx +4 -4
  6. package/breadcrumb/bread-context.tsx +1 -1
  7. package/card/cardGroup.tsx +1 -1
  8. package/card/index.tsx +1 -1
  9. package/cascader/index.tsx +4 -4
  10. package/checkbox/checkbox.tsx +16 -6
  11. package/collapse/index.tsx +1 -1
  12. package/collapse/item.tsx +1 -1
  13. package/collapsible/index.tsx +1 -1
  14. package/datePicker/_story/datePicker.stories.js +48 -1
  15. package/datePicker/_story/v2/AutoFillTime.jsx +37 -0
  16. package/datePicker/_story/v2/InputFormat.jsx +29 -0
  17. package/datePicker/_story/v2/InputFormatConfirm.jsx +44 -0
  18. package/datePicker/_story/v2/InputFormatDisabled.jsx +27 -0
  19. package/datePicker/_story/v2/index.js +4 -0
  20. package/datePicker/dateInput.tsx +7 -0
  21. package/datePicker/datePicker.tsx +7 -11
  22. package/datePicker/monthsGrid.tsx +2 -1
  23. package/descriptions/item.tsx +1 -1
  24. package/dist/umd/semi-ui.js +521 -197
  25. package/dist/umd/semi-ui.js.map +1 -1
  26. package/dist/umd/semi-ui.min.js +1 -1
  27. package/dist/umd/semi-ui.min.js.map +1 -1
  28. package/empty/index.tsx +1 -1
  29. package/form/errorMessage.tsx +1 -1
  30. package/form/interface.ts +1 -1
  31. package/form/label.tsx +1 -1
  32. package/form/section.tsx +2 -2
  33. package/form/slot.tsx +1 -1
  34. package/layout/Sider.tsx +1 -1
  35. package/lib/cjs/anchor/link.d.ts +2 -2
  36. package/lib/cjs/autoComplete/index.d.ts +1 -1
  37. package/lib/cjs/autoComplete/index.js +1 -1
  38. package/lib/cjs/avatar/interface.d.ts +2 -2
  39. package/lib/cjs/badge/index.d.ts +1 -1
  40. package/lib/cjs/banner/index.d.ts +4 -4
  41. package/lib/cjs/breadcrumb/bread-context.d.ts +1 -1
  42. package/lib/cjs/card/cardGroup.d.ts +1 -1
  43. package/lib/cjs/card/index.d.ts +1 -1
  44. package/lib/cjs/cascader/index.d.ts +1 -1
  45. package/lib/cjs/checkbox/checkbox.d.ts +4 -0
  46. package/lib/cjs/checkbox/checkbox.js +23 -11
  47. package/lib/cjs/collapse/index.d.ts +1 -1
  48. package/lib/cjs/collapse/item.d.ts +1 -1
  49. package/lib/cjs/collapsible/index.d.ts +1 -1
  50. package/lib/cjs/datePicker/dateInput.d.ts +1 -0
  51. package/lib/cjs/datePicker/dateInput.js +5 -3
  52. package/lib/cjs/datePicker/datePicker.js +9 -12
  53. package/lib/cjs/datePicker/monthsGrid.js +2 -1
  54. package/lib/cjs/descriptions/item.d.ts +1 -1
  55. package/lib/cjs/empty/index.d.ts +1 -1
  56. package/lib/cjs/form/errorMessage.d.ts +1 -1
  57. package/lib/cjs/form/interface.d.ts +1 -1
  58. package/lib/cjs/form/label.d.ts +1 -1
  59. package/lib/cjs/form/section.d.ts +2 -2
  60. package/lib/cjs/form/slot.d.ts +1 -1
  61. package/lib/cjs/layout/Sider.d.ts +1 -1
  62. package/lib/cjs/list/index.d.ts +1 -1
  63. package/lib/cjs/list/item.d.ts +1 -1
  64. package/lib/cjs/modal/Modal.d.ts +5 -5
  65. package/lib/cjs/modal/ModalContent.d.ts +1 -1
  66. package/lib/cjs/modal/confirm.d.ts +4 -2
  67. package/lib/cjs/modal/useModal/index.d.ts +16 -23
  68. package/lib/cjs/navigation/Footer.d.ts +1 -1
  69. package/lib/cjs/radio/radio.d.ts +4 -0
  70. package/lib/cjs/radio/radio.js +26 -12
  71. package/lib/cjs/radio/radioGroup.d.ts +1 -1
  72. package/lib/cjs/select/index.d.ts +1 -1
  73. package/lib/cjs/sideSheet/SideSheetContent.d.ts +1 -1
  74. package/lib/cjs/table/interface.d.ts +1 -1
  75. package/lib/cjs/tag/group.d.ts +3 -3
  76. package/lib/cjs/timeline/index.d.ts +1 -1
  77. package/lib/cjs/timeline/item.d.ts +1 -1
  78. package/lib/cjs/tooltip/index.d.ts +1 -0
  79. package/lib/cjs/tooltip/index.js +6 -1
  80. package/lib/es/anchor/link.d.ts +2 -2
  81. package/lib/es/autoComplete/index.d.ts +1 -1
  82. package/lib/es/autoComplete/index.js +1 -1
  83. package/lib/es/avatar/interface.d.ts +2 -2
  84. package/lib/es/badge/index.d.ts +1 -1
  85. package/lib/es/banner/index.d.ts +4 -4
  86. package/lib/es/breadcrumb/bread-context.d.ts +1 -1
  87. package/lib/es/card/cardGroup.d.ts +1 -1
  88. package/lib/es/card/index.d.ts +1 -1
  89. package/lib/es/cascader/index.d.ts +1 -1
  90. package/lib/es/checkbox/checkbox.d.ts +4 -0
  91. package/lib/es/checkbox/checkbox.js +23 -11
  92. package/lib/es/collapse/index.d.ts +1 -1
  93. package/lib/es/collapse/item.d.ts +1 -1
  94. package/lib/es/collapsible/index.d.ts +1 -1
  95. package/lib/es/datePicker/dateInput.d.ts +1 -0
  96. package/lib/es/datePicker/dateInput.js +5 -3
  97. package/lib/es/datePicker/datePicker.js +9 -12
  98. package/lib/es/datePicker/monthsGrid.js +2 -1
  99. package/lib/es/descriptions/item.d.ts +1 -1
  100. package/lib/es/empty/index.d.ts +1 -1
  101. package/lib/es/form/errorMessage.d.ts +1 -1
  102. package/lib/es/form/interface.d.ts +1 -1
  103. package/lib/es/form/label.d.ts +1 -1
  104. package/lib/es/form/section.d.ts +2 -2
  105. package/lib/es/form/slot.d.ts +1 -1
  106. package/lib/es/layout/Sider.d.ts +1 -1
  107. package/lib/es/list/index.d.ts +1 -1
  108. package/lib/es/list/item.d.ts +1 -1
  109. package/lib/es/modal/Modal.d.ts +5 -5
  110. package/lib/es/modal/ModalContent.d.ts +1 -1
  111. package/lib/es/modal/confirm.d.ts +4 -2
  112. package/lib/es/modal/confirm.js +1 -1
  113. package/lib/es/modal/useModal/index.d.ts +16 -23
  114. package/lib/es/navigation/Footer.d.ts +1 -1
  115. package/lib/es/radio/radio.d.ts +4 -0
  116. package/lib/es/radio/radio.js +26 -12
  117. package/lib/es/radio/radioGroup.d.ts +1 -1
  118. package/lib/es/select/index.d.ts +1 -1
  119. package/lib/es/sideSheet/SideSheetContent.d.ts +1 -1
  120. package/lib/es/table/interface.d.ts +1 -1
  121. package/lib/es/tag/group.d.ts +3 -3
  122. package/lib/es/timeline/index.d.ts +1 -1
  123. package/lib/es/timeline/item.d.ts +1 -1
  124. package/lib/es/tooltip/index.d.ts +1 -0
  125. package/lib/es/tooltip/index.js +6 -1
  126. package/list/index.tsx +1 -1
  127. package/list/item.tsx +1 -1
  128. package/modal/Modal.tsx +7 -7
  129. package/modal/ModalContent.tsx +1 -1
  130. package/modal/confirm.tsx +10 -11
  131. package/modal/useModal/index.tsx +9 -1
  132. package/navigation/Footer.tsx +2 -2
  133. package/package.json +9 -9
  134. package/radio/radio.tsx +17 -7
  135. package/radio/radioGroup.tsx +1 -1
  136. package/select/index.tsx +8 -8
  137. package/sideSheet/SideSheetContent.tsx +1 -1
  138. package/table/interface.ts +1 -1
  139. package/tag/group.tsx +4 -4
  140. package/timeline/index.tsx +1 -1
  141. package/timeline/item.tsx +1 -1
  142. package/tooltip/index.tsx +5 -1
  143. package/treeSelect/index.tsx +1 -1
@@ -10,7 +10,7 @@ export declare type ConfirmType = 'leftTop' | 'leftBottom' | 'rightTop' | 'right
10
10
  export declare type Directions = 'ltr' | 'rtl';
11
11
  export interface ModalReactProps extends ModalProps {
12
12
  cancelButtonProps?: ButtonProps;
13
- children?: React.ReactNode | undefined;
13
+ children?: React.ReactNode;
14
14
  okButtonProps?: ButtonProps;
15
15
  bodyStyle?: CSSProperties;
16
16
  maskStyle?: CSSProperties;
@@ -102,19 +102,19 @@ declare class Modal extends BaseComponent<ModalReactProps, ModalState> {
102
102
  static getScrollbarWidth(): number;
103
103
  static info: (props: ModalReactProps) => {
104
104
  destroy: () => void;
105
- update: (newConfig: import("./confirm").ConfirmProps) => void;
105
+ update: (newConfig: ModalReactProps) => void;
106
106
  };
107
107
  static success: (props: ModalReactProps) => {
108
108
  destroy: () => void;
109
- update: (newConfig: import("./confirm").ConfirmProps) => void;
109
+ update: (newConfig: ModalReactProps) => void;
110
110
  };
111
111
  static error: (props: ModalReactProps) => {
112
112
  destroy: () => void;
113
- update: (newConfig: import("./confirm").ConfirmProps) => void;
113
+ update: (newConfig: ModalReactProps) => void;
114
114
  };
115
115
  static warning: (props: ModalReactProps) => {
116
116
  destroy: () => void;
117
- update: (newConfig: import("./confirm").ConfirmProps) => void;
117
+ update: (newConfig: ModalReactProps) => void;
118
118
  };
119
119
  static confirm: (props: ModalReactProps) => {
120
120
  destroy: () => void;
@@ -4,7 +4,7 @@ import { ContextValue } from '../configProvider/context';
4
4
  import BaseComponent from '../_base/baseComponent';
5
5
  import ModalContentFoundation, { ModalContentAdapter, ModalContentProps, ModalContentState } from '@douyinfe/semi-foundation/lib/es/modal/modalContentFoundation';
6
6
  export interface ModalContentReactProps extends ModalContentProps {
7
- children?: React.ReactNode | undefined;
7
+ children?: React.ReactNode;
8
8
  }
9
9
  export default class ModalContent extends BaseComponent<ModalContentReactProps, ModalContentState> {
10
10
  static contextType: React.Context<ContextValue>;
@@ -4,9 +4,11 @@ import '@douyinfe/semi-foundation/lib/es/modal/modal.css';
4
4
  export interface ConfirmProps extends ModalReactProps {
5
5
  type: 'success' | 'info' | 'warning' | 'error' | 'confirm';
6
6
  }
7
- export default function confirm(props: ConfirmProps): {
7
+ export default function confirm<T>(props: ConfirmProps): {
8
8
  destroy: () => void;
9
- update: (newConfig: ConfirmProps) => void;
9
+ update: (newConfig: T extends {
10
+ type: Exclude<ConfirmProps['type'], 'confirm'>;
11
+ } ? ModalReactProps : ConfirmProps) => void;
10
12
  };
11
13
  export declare function withInfo(props: ModalReactProps): {
12
14
  cancelButtonProps?: import("../button").BaseButtonProps;
@@ -6,7 +6,7 @@ import ReactDOM from 'react-dom';
6
6
  import { destroyFns } from './Modal';
7
7
  import ConfirmModal from './ConfirmModal';
8
8
  import '@douyinfe/semi-foundation/lib/es/modal/modal.css';
9
- import { IconAlertTriangle, IconInfoCircle, IconTickCircle, IconHelpCircle, IconAlertCircle } from '@douyinfe/semi-icons';
9
+ import { IconAlertCircle, IconAlertTriangle, IconHelpCircle, IconInfoCircle, IconTickCircle } from '@douyinfe/semi-icons';
10
10
  export default function confirm(props) {
11
11
  // create a dom in adapter?
12
12
  const div = document.createElement('div');
@@ -1,25 +1,18 @@
1
- /// <reference types="react" />
1
+ import { ReactNode } from 'react';
2
2
  import { ConfirmProps } from '../confirm';
3
3
  import { ModalReactProps } from '../Modal';
4
- export default function useModal(): (JSX.Element | {
5
- info: (config: ModalReactProps) => {
6
- destroy: () => void;
7
- update: (newConfig: ConfirmProps) => void;
8
- };
9
- success: (config: ModalReactProps) => {
10
- destroy: () => void;
11
- update: (newConfig: ConfirmProps) => void;
12
- };
13
- error: (config: ModalReactProps) => {
14
- destroy: () => void;
15
- update: (newConfig: ConfirmProps) => void;
16
- };
17
- warning: (config: ModalReactProps) => {
18
- destroy: () => void;
19
- update: (newConfig: ConfirmProps) => void;
20
- };
21
- confirm: (config: ModalReactProps) => {
22
- destroy: () => void;
23
- update: (newConfig: ConfirmProps) => void;
24
- };
25
- })[];
4
+ declare type UseModalReturnHooksType = (config: ModalReactProps) => {
5
+ destroy: () => void;
6
+ update: (newConfig: ConfirmProps) => void;
7
+ };
8
+ export default function useModal(): [
9
+ {
10
+ info: UseModalReturnHooksType;
11
+ success: UseModalReturnHooksType;
12
+ error: UseModalReturnHooksType;
13
+ warning: UseModalReturnHooksType;
14
+ confirm: UseModalReturnHooksType;
15
+ },
16
+ ReactNode
17
+ ];
18
+ export {};
@@ -4,7 +4,7 @@ import '@douyinfe/semi-foundation/lib/es/navigation/navigation.css';
4
4
  import { NavContextType } from './nav-context';
5
5
  import { BaseProps } from '../_base/baseComponent';
6
6
  export interface NavFooterProps extends BaseProps {
7
- collapseButton?: React.ReactNode | boolean;
7
+ collapseButton?: React.ReactNode;
8
8
  collapseText?: (collapsed?: boolean) => React.ReactNode;
9
9
  }
10
10
  export default class NavFooter extends PureComponent<NavFooterProps> {
@@ -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> {
@@ -44,16 +44,12 @@ class Radio extends BaseComponent {
44
44
  };
45
45
 
46
46
  this.state = {
47
- hover: false
47
+ hover: false,
48
+ addonId: props.addonId,
49
+ extraId: props.extraId
48
50
  };
49
51
  this.foundation = new RadioFoundation(this.adapter);
50
52
  this.radioEntity = null;
51
- this.addonId = getUuidShort({
52
- prefix: 'addon'
53
- });
54
- this.extraId = getUuidShort({
55
- prefix: 'extra'
56
- });
57
53
  }
58
54
 
59
55
  get adapter() {
@@ -62,6 +58,20 @@ class Radio extends BaseComponent {
62
58
  this.setState({
63
59
  hover
64
60
  });
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
+ });
65
75
  }
66
76
  });
67
77
  }
@@ -98,7 +108,11 @@ class Radio extends BaseComponent {
98
108
  value: propValue
99
109
  } = this.props;
100
110
  let realChecked, isDisabled, realMode, isButtonRadioGroup, isCardRadioGroup, isPureCardRadioGroup, isButtonRadioComponent, buttonSize, realPrefixCls;
101
- const isHover = this.state.hover;
111
+ const {
112
+ hover: isHover,
113
+ addonId,
114
+ extraId
115
+ } = this.state;
102
116
  let props = {};
103
117
 
104
118
  if (this.isInGroup()) {
@@ -151,10 +165,10 @@ class Radio extends BaseComponent {
151
165
  const renderContent = () => /*#__PURE__*/React.createElement(React.Fragment, null, children ? /*#__PURE__*/React.createElement("span", {
152
166
  className: addonCls,
153
167
  style: addonStyle,
154
- id: this.addonId
168
+ id: addonId
155
169
  }, children) : null, extra && !isButtonRadio ? /*#__PURE__*/React.createElement("div", {
156
170
  className: "".concat(prefix, "-extra"),
157
- id: this.extraId
171
+ id: extraId
158
172
  }, extra) : null);
159
173
 
160
174
  return /*#__PURE__*/React.createElement("label", {
@@ -171,8 +185,8 @@ class Radio extends BaseComponent {
171
185
  ref: ref => {
172
186
  this.radioEntity = ref;
173
187
  },
174
- addonId: children && this.addonId,
175
- extraId: extra && this.extraId
188
+ addonId: children && addonId,
189
+ extraId: extra && extraId
176
190
  })), isCardRadioGroup ? /*#__PURE__*/React.createElement("div", {
177
191
  className: "".concat(prefix, "-isCardRadioGroup_content")
178
192
  }, renderContent()) : renderContent());
@@ -24,7 +24,7 @@ export declare type RadioGroupProps = {
24
24
  value?: string | number;
25
25
  onChange?: (event: RadioChangeEvent) => void;
26
26
  className?: string;
27
- children?: React.ReactNode | undefined;
27
+ children?: React.ReactNode;
28
28
  style?: React.CSSProperties;
29
29
  direction?: ArrayElement<typeof strings.DIRECTION_SET>;
30
30
  mode?: RadioMode;
@@ -19,7 +19,7 @@ declare type ExcludeInputType = {
19
19
  };
20
20
  export interface optionRenderProps {
21
21
  key?: any;
22
- label?: string | React.ReactNode | number;
22
+ label?: React.ReactNode;
23
23
  value?: string | number;
24
24
  style?: React.CSSProperties;
25
25
  className?: string;
@@ -13,7 +13,7 @@ export interface SideSheetContentProps {
13
13
  style: CSSProperties;
14
14
  bodyStyle?: CSSProperties;
15
15
  className: string;
16
- children?: React.ReactNode | undefined;
16
+ children?: React.ReactNode;
17
17
  footer?: React.ReactNode;
18
18
  'aria-label'?: string;
19
19
  }
@@ -211,7 +211,7 @@ export declare type GetCheckboxProps<RecordType> = (record: RecordType) => Check
211
211
  export declare type RowSelectionOnChange<RecordType> = (selectedRowKeys?: (string | number)[], selectedRows?: RecordType[]) => void;
212
212
  export declare type RowSelectionOnSelect<RecordType> = (record?: RecordType, selected?: boolean, selectedRows?: RecordType[], nativeEvent?: React.MouseEvent) => void;
213
213
  export declare type RowSelectionOnSelectAll<RecordType> = (selected?: boolean, selectedRows?: RecordType[], changedRows?: RecordType[]) => void;
214
- export declare type ExpandIcon = ((expanded?: boolean) => React.ReactNode) | React.ReactNode | boolean;
214
+ export declare type ExpandIcon = ((expanded?: boolean) => React.ReactNode) | React.ReactNode;
215
215
  export declare type ExpandedRowRender<RecordType> = (record?: RecordType, index?: number, expanded?: boolean) => React.ReactNode;
216
216
  export declare type Footer<RecordType> = ReactNode | ((pageData?: RecordType[]) => React.ReactNode);
217
217
  export declare type FormatPageText = ((pageInfo?: {
@@ -3,19 +3,19 @@ import PropTypes from 'prop-types';
3
3
  import Tag from './index';
4
4
  import { PopoverProps } from '../popover/index';
5
5
  import { AvatarShape, TagProps } from './interface';
6
- export interface TagGroupProps {
6
+ export interface TagGroupProps<T> {
7
7
  style?: React.CSSProperties;
8
8
  className?: string;
9
9
  maxTagCount?: number;
10
10
  restCount?: number;
11
- tagList?: (TagProps | React.ReactNode)[];
11
+ tagList?: (T extends 'custom' ? React.ReactNode : TagProps)[];
12
12
  size?: 'small' | 'large';
13
13
  showPopover?: boolean;
14
14
  popoverProps?: PopoverProps;
15
15
  avatarShape?: AvatarShape;
16
16
  mode?: string;
17
17
  }
18
- export default class TagGroup extends PureComponent<TagGroupProps> {
18
+ export default class TagGroup<T> extends PureComponent<TagGroupProps<T>> {
19
19
  static defaultProps: {
20
20
  style: {};
21
21
  className: string;
@@ -11,7 +11,7 @@ export interface TimelineProps extends Pick<React.AriaAttributes, 'aria-label'>
11
11
  className?: string;
12
12
  style?: React.CSSProperties;
13
13
  dataSource?: Data[];
14
- children?: React.ReactNode | undefined;
14
+ children?: React.ReactNode;
15
15
  }
16
16
  declare class Timeline extends PureComponent<TimelineProps> {
17
17
  static contextType: React.Context<import("../configProvider/context").ContextValue>;
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
3
3
  import '@douyinfe/semi-foundation/lib/es/timeline/timeline.css';
4
4
  export interface TimelineItemProps {
5
5
  color?: string;
6
- children?: React.ReactNode | undefined;
6
+ children?: React.ReactNode;
7
7
  time?: React.ReactNode;
8
8
  type?: 'default' | 'ongoing' | 'success' | 'warning' | 'error';
9
9
  dot?: React.ReactNode;
@@ -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;
@@ -293,7 +293,7 @@ export default class Tooltip extends BaseComponent {
293
293
  placement: props.position || 'top',
294
294
  transitionStyle: {},
295
295
  isPositionUpdated: false,
296
- id: getUuidShort() // auto generate id, will be used by children.aria-describedby & content.id, improve a11y
296
+ id: props.wrapperId // auto generate id, will be used by children.aria-describedby & content.id, improve a11y
297
297
 
298
298
  };
299
299
  this.foundation = new TooltipFoundation(this.adapter);
@@ -562,6 +562,11 @@ export default class Tooltip extends BaseComponent {
562
562
  },
563
563
  notifyEscKeydown: event => {
564
564
  this.props.onEscKeyDown(event);
565
+ },
566
+ setId: () => {
567
+ this.setState({
568
+ id: getUuidShort()
569
+ });
565
570
  }
566
571
  });
567
572
  }
package/list/index.tsx CHANGED
@@ -17,7 +17,7 @@ export { ListItemProps } from './item';
17
17
  export interface ListProps<T> {
18
18
  style?: React.CSSProperties;
19
19
  className?: string;
20
- children?: React.ReactNode | undefined;
20
+ children?: React.ReactNode;
21
21
  bordered?: boolean;
22
22
  footer?: React.ReactNode;
23
23
  header?: React.ReactNode;
package/list/item.tsx CHANGED
@@ -12,7 +12,7 @@ export interface ListItemProps {
12
12
  main?: React.ReactNode;
13
13
  align?: 'flex-start' | 'flex-end' | 'center' | 'baseline' | 'stretch';
14
14
  className?: string;
15
- children?: React.ReactNode | undefined;
15
+ children?: React.ReactNode;
16
16
  style?: React.CSSProperties;
17
17
  onClick?: React.MouseEventHandler<HTMLLIElement>;
18
18
  onRightClick?: React.MouseEventHandler<HTMLLIElement>;
package/modal/Modal.tsx CHANGED
@@ -23,7 +23,7 @@ export type Directions = 'ltr' | 'rtl';
23
23
 
24
24
  export interface ModalReactProps extends ModalProps {
25
25
  cancelButtonProps?: ButtonProps;
26
- children?: React.ReactNode | undefined;
26
+ children?: React.ReactNode;
27
27
  okButtonProps?: ButtonProps;
28
28
  bodyStyle?: CSSProperties;
29
29
  maskStyle?: CSSProperties;
@@ -50,7 +50,7 @@ class Modal extends BaseComponent<ModalReactProps, ModalState> {
50
50
  centered: PropTypes.bool,
51
51
  visible: PropTypes.bool,
52
52
  width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
53
- height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
53
+ height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
54
54
  confirmLoading: PropTypes.bool,
55
55
  cancelLoading: PropTypes.bool,
56
56
  okText: PropTypes.string,
@@ -193,23 +193,23 @@ class Modal extends BaseComponent<ModalReactProps, ModalState> {
193
193
 
194
194
 
195
195
  static info = function (props: ModalReactProps) {
196
- return confirm(withInfo(props));
196
+ return confirm<ReturnType<typeof withInfo>>(withInfo(props));
197
197
  };
198
198
 
199
199
  static success = function (props: ModalReactProps) {
200
- return confirm(withSuccess(props));
200
+ return confirm<ReturnType<typeof withSuccess>>(withSuccess(props));
201
201
  };
202
202
 
203
203
  static error = function (props: ModalReactProps) {
204
- return confirm(withError(props));
204
+ return confirm<ReturnType<typeof withError>>(withError(props));
205
205
  };
206
206
 
207
207
  static warning = function (props: ModalReactProps) {
208
- return confirm(withWarning(props));
208
+ return confirm<ReturnType<typeof withWarning>>(withWarning(props));
209
209
  };
210
210
 
211
211
  static confirm = function (props: ModalReactProps) {
212
- return confirm(withConfirm(props));
212
+ return confirm<ReturnType<typeof withConfirm>>(withConfirm(props));
213
213
  };
214
214
 
215
215
  static destroyAll = function destroyAllFn() {
@@ -21,7 +21,7 @@ let uuid = 0;
21
21
 
22
22
 
23
23
  export interface ModalContentReactProps extends ModalContentProps {
24
- children?: React.ReactNode | undefined;
24
+ children?: React.ReactNode;
25
25
  }
26
26
  export default class ModalContent extends BaseComponent<ModalContentReactProps, ModalContentState> {
27
27
  static contextType = ConfigContext;
package/modal/confirm.tsx CHANGED
@@ -5,14 +5,14 @@ import ConfirmModal from './ConfirmModal';
5
5
 
6
6
  import '@douyinfe/semi-foundation/modal/modal.scss';
7
7
  import { get } from 'lodash';
8
- import { IconAlertTriangle, IconInfoCircle, IconTickCircle, IconHelpCircle, IconAlertCircle } from '@douyinfe/semi-icons';
8
+ import { IconAlertCircle, IconAlertTriangle, IconHelpCircle, IconInfoCircle, IconTickCircle } from '@douyinfe/semi-icons';
9
9
  import { Motion } from '../_base/base';
10
10
 
11
- export interface ConfirmProps extends ModalReactProps{
11
+ export interface ConfirmProps extends ModalReactProps {
12
12
  type: 'success' | 'info' | 'warning' | 'error' | 'confirm';
13
13
  }
14
14
 
15
- export default function confirm(props: ConfirmProps) {
15
+ export default function confirm<T>(props: ConfirmProps) {
16
16
  // create a dom in adapter?
17
17
  const div = document.createElement('div');
18
18
  document.body.appendChild(div);
@@ -51,7 +51,7 @@ export default function confirm(props: ConfirmProps) {
51
51
  } : false;
52
52
 
53
53
  function render(renderProps: ConfirmProps) {
54
- ReactDOM.render(<ConfirmModal {...renderProps} motion={mergedMotion} />, div);
54
+ ReactDOM.render(<ConfirmModal {...renderProps} motion={mergedMotion}/>, div);
55
55
  }
56
56
 
57
57
  function close() {
@@ -62,7 +62,7 @@ export default function confirm(props: ConfirmProps) {
62
62
  render(currentConfig);
63
63
  }
64
64
 
65
- function update(newConfig: ConfirmProps) {
65
+ function update(newConfig: T extends { type: Exclude<ConfirmProps['type'], 'confirm'> } ? ModalReactProps : ConfirmProps) {
66
66
  currentConfig = {
67
67
  ...currentConfig,
68
68
  ...newConfig,
@@ -79,11 +79,10 @@ export default function confirm(props: ConfirmProps) {
79
79
  }
80
80
 
81
81
 
82
-
83
82
  export function withInfo(props: ModalReactProps) {
84
83
  return {
85
84
  type: 'info' as const,
86
- icon: <IconInfoCircle />,
85
+ icon: <IconInfoCircle/>,
87
86
  ...props
88
87
  };
89
88
  }
@@ -91,7 +90,7 @@ export function withInfo(props: ModalReactProps) {
91
90
  export function withSuccess(props: ModalReactProps) {
92
91
  return {
93
92
  type: 'success' as const,
94
- icon: <IconTickCircle />,
93
+ icon: <IconTickCircle/>,
95
94
  ...props
96
95
  };
97
96
  }
@@ -99,7 +98,7 @@ export function withSuccess(props: ModalReactProps) {
99
98
  export function withWarning(props: ModalReactProps) {
100
99
  return {
101
100
  type: 'warning' as const,
102
- icon: <IconAlertTriangle />,
101
+ icon: <IconAlertTriangle/>,
103
102
  ...props
104
103
  };
105
104
  }
@@ -107,7 +106,7 @@ export function withWarning(props: ModalReactProps) {
107
106
  export function withError(props: ModalReactProps) {
108
107
  return {
109
108
  type: 'error' as const,
110
- icon: <IconAlertCircle />,
109
+ icon: <IconAlertCircle/>,
111
110
  ...props
112
111
  };
113
112
  }
@@ -115,7 +114,7 @@ export function withError(props: ModalReactProps) {
115
114
  export function withConfirm(props: ModalReactProps) {
116
115
  return {
117
116
  type: 'confirm' as const,
118
- icon: <IconHelpCircle />,
117
+ icon: <IconHelpCircle/>,
119
118
  ...props
120
119
  };
121
120
  }
@@ -19,7 +19,15 @@ function usePatchElement(): ([ReactNode[], (element: ReactNode) => () => void])
19
19
  return [elements, patchElement];
20
20
  }
21
21
 
22
- export default function useModal() {
22
+ type UseModalReturnHooksType = (config: ModalReactProps) => { destroy: () => void, update: (newConfig: ConfirmProps) => void };
23
+
24
+ export default function useModal(): [{
25
+ info: UseModalReturnHooksType,
26
+ success: UseModalReturnHooksType,
27
+ error:UseModalReturnHooksType,
28
+ warning: UseModalReturnHooksType,
29
+ confirm: UseModalReturnHooksType
30
+ }, ReactNode] {
23
31
  const [elements, patchElement] = usePatchElement();
24
32
 
25
33
  // eslint-disable-next-line max-len
@@ -10,7 +10,7 @@ import NavContext, { NavContextType } from './nav-context';
10
10
  import { BaseProps } from '../_base/baseComponent';
11
11
 
12
12
  export interface NavFooterProps extends BaseProps {
13
- collapseButton?: React.ReactNode | boolean;
13
+ collapseButton?: React.ReactNode;
14
14
  collapseText?: (collapsed?: boolean) => React.ReactNode;
15
15
  }
16
16
 
@@ -28,7 +28,7 @@ export default class NavFooter extends PureComponent<NavFooterProps> {
28
28
  static defaultProps = {
29
29
  collapseButton: false,
30
30
  };
31
-
31
+
32
32
  context: NavContextType;
33
33
 
34
34
  renderCollapseButton = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-ui",
3
- "version": "2.10.2",
3
+ "version": "2.11.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.2",
18
- "@douyinfe/semi-animation-react": "2.10.2",
19
- "@douyinfe/semi-foundation": "2.10.2",
20
- "@douyinfe/semi-icons": "2.10.2",
21
- "@douyinfe/semi-illustrations": "2.10.2",
22
- "@douyinfe/semi-theme-default": "2.10.2",
17
+ "@douyinfe/semi-animation": "2.11.0",
18
+ "@douyinfe/semi-animation-react": "2.11.0",
19
+ "@douyinfe/semi-foundation": "2.11.0",
20
+ "@douyinfe/semi-icons": "2.11.0",
21
+ "@douyinfe/semi-illustrations": "2.11.0",
22
+ "@douyinfe/semi-theme-default": "2.11.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": "00b27ff43fe6ed5d775d5849bd0adc4c4c5ea231",
72
+ "gitHead": "f7a5cae3d9190faff4a08c5a4da23927a1ab86e5",
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.2",
78
+ "@douyinfe/semi-scss-compile": "2.11.0",
79
79
  "@storybook/addon-knobs": "^6.3.1",
80
80
  "@types/lodash": "^4.14.176",
81
81
  "babel-loader": "^8.2.2",
package/radio/radio.tsx CHANGED
@@ -41,10 +41,14 @@ export type RadioProps = {
41
41
  addonClassName?: string;
42
42
  type?: RadioType;
43
43
  'aria-label'?: React.AriaAttributes['aria-label'];
44
+ addonId?: string;
45
+ extraId?: string;
44
46
  };
45
47
 
46
48
  export interface RadioState {
47
49
  hover?: boolean;
50
+ addonId?: string;
51
+ extraId?: string;
48
52
  }
49
53
 
50
54
  export { RadioChangeEvent };
@@ -94,11 +98,11 @@ class Radio extends BaseComponent<RadioProps, RadioState> {
94
98
  super(props);
95
99
  this.state = {
96
100
  hover: false,
101
+ addonId: props.addonId,
102
+ extraId: props.extraId,
97
103
  };
98
104
  this.foundation = new RadioFoundation(this.adapter);
99
105
  this.radioEntity = null;
100
- this.addonId = getUuidShort({ prefix: 'addon' });
101
- this.extraId = getUuidShort({ prefix: 'extra' });
102
106
  }
103
107
 
104
108
  get adapter(): RadioAdapter {
@@ -106,6 +110,12 @@ class Radio extends BaseComponent<RadioProps, RadioState> {
106
110
  ...super.adapter,
107
111
  setHover: (hover: boolean) => {
108
112
  this.setState({ hover });
113
+ },
114
+ setAddonId: () => {
115
+ this.setState({ addonId: getUuidShort({ prefix: 'addon' }) });
116
+ },
117
+ setExtraId: () => {
118
+ this.setState({ extraId: getUuidShort({ prefix: 'extra' }) });
109
119
  }
110
120
  };
111
121
  }
@@ -168,7 +178,7 @@ class Radio extends BaseComponent<RadioProps, RadioState> {
168
178
  isButtonRadioComponent,
169
179
  buttonSize,
170
180
  realPrefixCls;
171
- const isHover = this.state.hover;
181
+ const { hover: isHover, addonId, extraId } = this.state;
172
182
  let props = {};
173
183
 
174
184
  if (this.isInGroup()) {
@@ -218,8 +228,8 @@ class Radio extends BaseComponent<RadioProps, RadioState> {
218
228
  }, addonClassName);
219
229
  const renderContent = () => (
220
230
  <>
221
- {children ? <span className={addonCls} style={addonStyle} id={this.addonId}>{children}</span> : null}
222
- {extra && !isButtonRadio ? <div className={`${prefix}-extra`} id={this.extraId}>{extra}</div> : null}
231
+ {children ? <span className={addonCls} style={addonStyle} id={addonId}>{children}</span> : null}
232
+ {extra && !isButtonRadio ? <div className={`${prefix}-extra`} id={extraId}>{extra}</div> : null}
223
233
  </>
224
234
  );
225
235
  return (
@@ -240,8 +250,8 @@ class Radio extends BaseComponent<RadioProps, RadioState> {
240
250
  ref={(ref: RadioInner) => {
241
251
  this.radioEntity = ref;
242
252
  }}
243
- addonId={children && this.addonId}
244
- extraId={extra && this.extraId}
253
+ addonId={children && addonId}
254
+ extraId={extra && extraId}
245
255
  />
246
256
  {
247
257
  isCardRadioGroup ?
@@ -30,7 +30,7 @@ export type RadioGroupProps = {
30
30
  value?: string | number;
31
31
  onChange?: (event: RadioChangeEvent) => void;
32
32
  className?: string;
33
- children?: React.ReactNode | undefined;
33
+ children?: React.ReactNode;
34
34
  style?: React.CSSProperties;
35
35
  direction?: ArrayElement<typeof strings.DIRECTION_SET>;
36
36
  mode?: RadioMode;