@douyinfe/semi-ui 2.17.1 → 2.19.0-alpha.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 (172) hide show
  1. package/anchor/index.tsx +1 -1
  2. package/anchor/link.tsx +3 -4
  3. package/autoComplete/__test__/autoComplete.test.js +6 -6
  4. package/autoComplete/index.tsx +1 -1
  5. package/autoComplete/option.tsx +164 -0
  6. package/calendar/__test__/calendar.test.js +21 -2
  7. package/calendar/_story/calendar.stories.js +31 -0
  8. package/calendar/index.tsx +3 -1
  9. package/calendar/interface.ts +2 -1
  10. package/carousel/index.tsx +5 -5
  11. package/checkbox/checkbox.tsx +10 -2
  12. package/checkbox/checkboxGroup.tsx +2 -0
  13. package/dist/css/semi.css +160 -22
  14. package/dist/css/semi.min.css +1 -1
  15. package/dist/umd/semi-ui.js +15144 -16407
  16. package/dist/umd/semi-ui.js.map +1 -1
  17. package/dist/umd/semi-ui.min.js +1 -1
  18. package/dist/umd/semi-ui.min.js.map +1 -1
  19. package/form/_story/FieldProps/labelOptional.jsx +30 -0
  20. package/form/_story/form.stories.js +7 -0
  21. package/form/hoc/withField.tsx +1 -0
  22. package/form/label.tsx +21 -7
  23. package/gulpfile.js +3 -1
  24. package/lib/cjs/_base/base.css +35 -0
  25. package/lib/cjs/anchor/index.js +2 -1
  26. package/lib/cjs/anchor/link.d.ts +1 -1
  27. package/lib/cjs/anchor/link.js +9 -5
  28. package/lib/cjs/autoComplete/index.d.ts +1 -1
  29. package/lib/cjs/autoComplete/index.js +1 -1
  30. package/lib/cjs/autoComplete/option.d.ts +50 -0
  31. package/lib/cjs/autoComplete/option.js +218 -0
  32. package/lib/cjs/calendar/index.d.ts +2 -0
  33. package/lib/cjs/calendar/index.js +3 -1
  34. package/lib/cjs/calendar/interface.d.ts +2 -1
  35. package/lib/cjs/carousel/index.js +2 -2
  36. package/lib/cjs/checkbox/checkbox.d.ts +4 -0
  37. package/lib/cjs/checkbox/checkbox.js +9 -3
  38. package/lib/cjs/checkbox/checkboxGroup.js +4 -2
  39. package/lib/cjs/form/baseForm.d.ts +1 -1
  40. package/lib/cjs/form/field.d.ts +1 -1
  41. package/lib/cjs/form/hoc/withField.js +2 -1
  42. package/lib/cjs/form/label.d.ts +8 -5
  43. package/lib/cjs/form/label.js +15 -4
  44. package/lib/cjs/locale/interface.d.ts +3 -0
  45. package/lib/cjs/locale/source/ar.js +3 -0
  46. package/lib/cjs/locale/source/de.js +3 -0
  47. package/lib/cjs/locale/source/en_GB.js +3 -0
  48. package/lib/cjs/locale/source/en_US.js +3 -0
  49. package/lib/cjs/locale/source/es.js +3 -0
  50. package/lib/cjs/locale/source/fr.js +3 -0
  51. package/lib/cjs/locale/source/id_ID.js +3 -0
  52. package/lib/cjs/locale/source/it.js +3 -0
  53. package/lib/cjs/locale/source/ja_JP.js +3 -0
  54. package/lib/cjs/locale/source/ko_KR.js +3 -0
  55. package/lib/cjs/locale/source/ms_MY.js +3 -0
  56. package/lib/cjs/locale/source/pt_BR.js +3 -0
  57. package/lib/cjs/locale/source/ru_RU.js +3 -0
  58. package/lib/cjs/locale/source/th_TH.js +3 -0
  59. package/lib/cjs/locale/source/tr_TR.js +3 -0
  60. package/lib/cjs/locale/source/vi_VN.js +3 -0
  61. package/lib/cjs/locale/source/zh_CN.js +3 -0
  62. package/lib/cjs/locale/source/zh_TW.js +3 -0
  63. package/lib/cjs/modal/Modal.js +0 -8
  64. package/lib/cjs/modal/ModalContent.js +4 -1
  65. package/lib/cjs/radio/radio.d.ts +2 -0
  66. package/lib/cjs/radio/radio.js +33 -8
  67. package/lib/cjs/radio/radioGroup.js +4 -2
  68. package/lib/cjs/tag/group.d.ts +3 -0
  69. package/lib/cjs/tag/group.js +24 -6
  70. package/lib/cjs/tag/index.d.ts +2 -1
  71. package/lib/cjs/tag/index.js +7 -5
  72. package/lib/cjs/tag/interface.d.ts +2 -1
  73. package/lib/cjs/tree/index.d.ts +3 -1
  74. package/lib/cjs/tree/index.js +23 -0
  75. package/lib/cjs/tree/interface.d.ts +4 -0
  76. package/lib/cjs/typography/title.d.ts +1 -1
  77. package/lib/es/_base/base.css +35 -0
  78. package/lib/es/anchor/index.js +2 -1
  79. package/lib/es/anchor/link.d.ts +1 -1
  80. package/lib/es/anchor/link.js +9 -5
  81. package/lib/es/autoComplete/index.d.ts +1 -1
  82. package/lib/es/autoComplete/index.js +1 -1
  83. package/lib/es/autoComplete/option.d.ts +50 -0
  84. package/lib/es/autoComplete/option.js +188 -0
  85. package/lib/es/calendar/index.d.ts +2 -0
  86. package/lib/es/calendar/index.js +3 -1
  87. package/lib/es/calendar/interface.d.ts +2 -1
  88. package/lib/es/carousel/index.js +2 -2
  89. package/lib/es/checkbox/checkbox.d.ts +4 -0
  90. package/lib/es/checkbox/checkbox.js +10 -4
  91. package/lib/es/checkbox/checkboxGroup.js +4 -2
  92. package/lib/es/form/baseForm.d.ts +1 -1
  93. package/lib/es/form/field.d.ts +1 -1
  94. package/lib/es/form/hoc/withField.js +2 -1
  95. package/lib/es/form/label.d.ts +8 -5
  96. package/lib/es/form/label.js +13 -4
  97. package/lib/es/locale/interface.d.ts +3 -0
  98. package/lib/es/locale/source/ar.js +3 -0
  99. package/lib/es/locale/source/de.js +3 -0
  100. package/lib/es/locale/source/en_GB.js +3 -0
  101. package/lib/es/locale/source/en_US.js +3 -0
  102. package/lib/es/locale/source/es.js +3 -0
  103. package/lib/es/locale/source/fr.js +3 -0
  104. package/lib/es/locale/source/id_ID.js +3 -0
  105. package/lib/es/locale/source/it.js +3 -0
  106. package/lib/es/locale/source/ja_JP.js +3 -0
  107. package/lib/es/locale/source/ko_KR.js +3 -0
  108. package/lib/es/locale/source/ms_MY.js +3 -0
  109. package/lib/es/locale/source/pt_BR.js +3 -0
  110. package/lib/es/locale/source/ru_RU.js +3 -0
  111. package/lib/es/locale/source/th_TH.js +3 -0
  112. package/lib/es/locale/source/tr_TR.js +3 -0
  113. package/lib/es/locale/source/vi_VN.js +3 -0
  114. package/lib/es/locale/source/zh_CN.js +3 -0
  115. package/lib/es/locale/source/zh_TW.js +3 -0
  116. package/lib/es/modal/Modal.js +0 -8
  117. package/lib/es/modal/ModalContent.js +4 -1
  118. package/lib/es/radio/radio.d.ts +2 -0
  119. package/lib/es/radio/radio.js +31 -8
  120. package/lib/es/radio/radioGroup.js +4 -2
  121. package/lib/es/tag/group.d.ts +3 -0
  122. package/lib/es/tag/group.js +24 -6
  123. package/lib/es/tag/index.d.ts +2 -1
  124. package/lib/es/tag/index.js +7 -5
  125. package/lib/es/tag/interface.d.ts +2 -1
  126. package/lib/es/tree/index.d.ts +3 -1
  127. package/lib/es/tree/index.js +22 -0
  128. package/lib/es/tree/interface.d.ts +4 -0
  129. package/lib/es/typography/title.d.ts +1 -1
  130. package/locale/interface.ts +3 -0
  131. package/locale/source/ar.ts +3 -0
  132. package/locale/source/de.ts +3 -0
  133. package/locale/source/en_GB.ts +3 -0
  134. package/locale/source/en_US.ts +3 -0
  135. package/locale/source/es.ts +3 -0
  136. package/locale/source/fr.ts +3 -0
  137. package/locale/source/id_ID.ts +3 -0
  138. package/locale/source/it.ts +3 -0
  139. package/locale/source/ja_JP.ts +3 -0
  140. package/locale/source/ko_KR.ts +3 -0
  141. package/locale/source/ms_MY.ts +3 -0
  142. package/locale/source/pt_BR.ts +3 -0
  143. package/locale/source/ru_RU.ts +3 -0
  144. package/locale/source/th_TH.ts +3 -0
  145. package/locale/source/tr_TR.ts +4 -1
  146. package/locale/source/vi_VN.ts +3 -0
  147. package/locale/source/zh_CN.ts +3 -0
  148. package/locale/source/zh_TW.ts +3 -0
  149. package/modal/Modal.tsx +0 -6
  150. package/modal/ModalContent.tsx +4 -1
  151. package/modal/__test__/modal.test.js +1 -1
  152. package/modal/_story/__snapshots__/modal.stories.tsx.snap +203 -0
  153. package/package.json +7 -7
  154. package/radio/_story/radio.stories.js +2 -2
  155. package/radio/radio.tsx +27 -5
  156. package/radio/radioGroup.tsx +2 -0
  157. package/rating/__test__/rating.test.js +1 -1
  158. package/select/__test__/select.test.js +11 -17
  159. package/select/_story/select.stories.js +6 -6
  160. package/steps/_story/steps.stories.js +3 -3
  161. package/switch/_story/switch.stories.js +4 -4
  162. package/switch/_story/switch.stories.tsx +4 -4
  163. package/tag/_story/tag.stories.js +57 -1
  164. package/tag/group.tsx +20 -3
  165. package/tag/index.tsx +6 -5
  166. package/tag/interface.ts +2 -1
  167. package/transfer/_story/transfer.stories.js +2 -2
  168. package/tree/_story/tree.stories.js +152 -3
  169. package/tree/index.tsx +16 -1
  170. package/tree/interface.ts +6 -0
  171. package/upload/_story/upload.stories.js +2 -2
  172. package/webpack.config.js +10 -2
@@ -10,6 +10,7 @@ export default class Tag extends Component<TagProps, TagState> {
10
10
  static defaultProps: TagProps;
11
11
  static propTypes: {
12
12
  children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
13
+ tagKey: PropTypes.Requireable<PropTypes.Requireable<string> | PropTypes.Requireable<number>>;
13
14
  size: PropTypes.Requireable<string>;
14
15
  color: PropTypes.Requireable<string>;
15
16
  type: PropTypes.Requireable<string>;
@@ -28,7 +29,7 @@ export default class Tag extends Component<TagProps, TagState> {
28
29
  visible: boolean;
29
30
  };
30
31
  setVisible(visible: boolean): void;
31
- close(e: React.MouseEvent<HTMLElement>, value: React.ReactNode): void;
32
+ close(e: React.MouseEvent<HTMLElement>, value: React.ReactNode, tagKey: string | number): void;
32
33
  handleKeyDown(event: any): void;
33
34
  renderAvatar(): JSX.Element;
34
35
  render(): JSX.Element;
@@ -63,13 +63,13 @@ export default class Tag extends Component {
63
63
  }
64
64
  }
65
65
 
66
- close(e, value) {
66
+ close(e, value, tagKey) {
67
67
  const {
68
68
  onClose
69
69
  } = this.props;
70
70
  e.stopPropagation();
71
71
  e.nativeEvent.stopImmediatePropagation();
72
- onClose && onClose(value, e); // when user call e.preventDefault() in onClick callback, tag will not hidden
72
+ onClose && onClose(value, e, tagKey); // when user call e.preventDefault() in onClick callback, tag will not hidden
73
73
 
74
74
  if (e.defaultPrevented) {
75
75
  return;
@@ -88,7 +88,7 @@ export default class Tag extends Component {
88
88
  switch (event.key) {
89
89
  case "Backspace":
90
90
  case "Delete":
91
- closable && this.close(event, this.props.children);
91
+ closable && this.close(event, this.props.children, this.props.tagKey);
92
92
  handlePrevent(event);
93
93
  break;
94
94
 
@@ -125,6 +125,7 @@ export default class Tag extends Component {
125
125
 
126
126
  const _a = this.props,
127
127
  {
128
+ tagKey,
128
129
  children,
129
130
  size,
130
131
  color,
@@ -138,7 +139,7 @@ export default class Tag extends Component {
138
139
  avatarShape,
139
140
  tabIndex
140
141
  } = _a,
141
- attr = __rest(_a, ["children", "size", "color", "closable", "visible", "onClose", "onClick", "className", "type", "avatarSrc", "avatarShape", "tabIndex"]);
142
+ attr = __rest(_a, ["tagKey", "children", "size", "color", "closable", "visible", "onClose", "onClick", "className", "type", "avatarSrc", "avatarShape", "tabIndex"]);
142
143
 
143
144
  const {
144
145
  visible: isVisible
@@ -171,7 +172,7 @@ export default class Tag extends Component {
171
172
  // eslint-disable-next-line jsx-a11y/click-events-have-key-events
172
173
  React.createElement("div", {
173
174
  className: "".concat(prefixCls, "-close"),
174
- onClick: e => this.close(e, children)
175
+ onClick: e => this.close(e, children, tagKey)
175
176
  }, /*#__PURE__*/React.createElement(IconClose, {
176
177
  size: "small"
177
178
  })) : null;
@@ -197,6 +198,7 @@ Tag.defaultProps = {
197
198
  };
198
199
  Tag.propTypes = {
199
200
  children: PropTypes.node,
201
+ tagKey: PropTypes.oneOf([PropTypes.string, PropTypes.number]),
200
202
  size: PropTypes.oneOf(tagSize),
201
203
  color: PropTypes.oneOf(tagColors),
202
204
  type: PropTypes.oneOf(tagType),
@@ -5,12 +5,13 @@ export declare type TagSize = 'default' | 'small' | 'large';
5
5
  export declare type AvatarShape = 'circle' | 'square';
6
6
  export interface TagProps {
7
7
  children?: React.ReactNode;
8
+ tagKey?: string | number;
8
9
  size?: TagSize;
9
10
  color?: TagColor;
10
11
  type?: TagType;
11
12
  closable?: boolean;
12
13
  visible?: boolean;
13
- onClose?: (tagChildren: React.ReactNode, event: React.MouseEvent<HTMLElement>) => void;
14
+ onClose?: (tagChildren: React.ReactNode, event: React.MouseEvent<HTMLElement>, tagKey: string | number) => void;
14
15
  onClick?: React.MouseEventHandler<HTMLDivElement>;
15
16
  style?: React.CSSProperties;
16
17
  className?: string;
@@ -6,7 +6,7 @@ import BaseComponent from '../_base/baseComponent';
6
6
  import Input from '../input/index';
7
7
  import TreeNode from './treeNode';
8
8
  import '@douyinfe/semi-foundation/lib/es/tree/tree.css';
9
- import { TreeProps, TreeState, TreeNodeProps, TreeNodeData, FlattenNode, KeyEntity } from './interface';
9
+ import { TreeProps, TreeState, TreeNodeProps, TreeNodeData, FlattenNode, KeyEntity, ScrollData } from './interface';
10
10
  export * from './interface';
11
11
  export { AutoSizerProps } from './autoSizer';
12
12
  declare class Tree extends BaseComponent<TreeProps, TreeState> {
@@ -102,6 +102,7 @@ declare class Tree extends BaseComponent<TreeProps, TreeState> {
102
102
  onNodeClick: any;
103
103
  onMotionEnd: any;
104
104
  context: ContextValue;
105
+ virtualizedListRef: React.RefObject<any>;
105
106
  constructor(props: TreeProps);
106
107
  /**
107
108
  * Process of getDerivedStateFromProps was inspired by rc-tree
@@ -110,6 +111,7 @@ declare class Tree extends BaseComponent<TreeProps, TreeState> {
110
111
  static getDerivedStateFromProps(props: TreeProps, prevState: TreeState): Partial<TreeState>;
111
112
  get adapter(): TreeAdapter;
112
113
  search: (value: string) => void;
114
+ scrollTo: (scrollData: ScrollData) => void;
113
115
  renderInput(): JSX.Element;
114
116
  renderEmpty: () => JSX.Element;
115
117
  onNodeSelect: (e: MouseEvent | KeyboardEvent, treeNode: TreeNodeProps) => void;
@@ -2,6 +2,7 @@ import _isFunction from "lodash/isFunction";
2
2
  import _get from "lodash/get";
3
3
  import _isEqual from "lodash/isEqual";
4
4
  import _isEmpty from "lodash/isEmpty";
5
+ import _findIndexInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find-index";
5
6
  import _Promise from "@babel/runtime-corejs3/core-js-stable/promise";
6
7
  import _Set from "@babel/runtime-corejs3/core-js-stable/set";
7
8
  import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
@@ -40,6 +41,25 @@ class Tree extends BaseComponent {
40
41
  this.foundation.handleInputChange(value);
41
42
  };
42
43
 
44
+ this.scrollTo = scrollData => {
45
+ var _a;
46
+
47
+ const {
48
+ key,
49
+ align = 'center'
50
+ } = scrollData;
51
+ const {
52
+ flattenNodes
53
+ } = this.state;
54
+
55
+ if (key) {
56
+ const index = flattenNodes === null || flattenNodes === void 0 ? void 0 : _findIndexInstanceProperty(flattenNodes).call(flattenNodes, node => {
57
+ return node.key === key;
58
+ });
59
+ index >= 0 && ((_a = this.virtualizedListRef.current) === null || _a === void 0 ? void 0 : _a.scrollToItem(index, align));
60
+ }
61
+ };
62
+
43
63
  this.renderEmpty = () => {
44
64
  const {
45
65
  emptyContent
@@ -201,6 +221,7 @@ class Tree extends BaseComponent {
201
221
  this.optionsRef = /*#__PURE__*/React.createRef();
202
222
  this.foundation = new TreeFoundation(this.adapter);
203
223
  this.dragNode = null;
224
+ this.virtualizedListRef = /*#__PURE__*/React.createRef();
204
225
  }
205
226
  /**
206
227
  * Process of getDerivedStateFromProps was inspired by rc-tree
@@ -573,6 +594,7 @@ class Tree extends BaseComponent {
573
594
  width
574
595
  } = _ref4;
575
596
  return /*#__PURE__*/React.createElement(VirtualList, {
597
+ ref: this.virtualizedListRef,
576
598
  itemCount: flattenNodes.length,
577
599
  itemSize: virtualize.itemSize,
578
600
  height: height,
@@ -118,3 +118,7 @@ export interface NodeListState {
118
118
  cachedMotionKeys?: Set<string>;
119
119
  cachedData?: FlattenNode[];
120
120
  }
121
+ export interface ScrollData {
122
+ key: string;
123
+ align?: 'center' | 'start' | 'end' | 'smart' | 'auto';
124
+ }
@@ -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 | 5 | 6>;
41
41
  style: PropTypes.Requireable<object>;
42
42
  className: PropTypes.Requireable<string>;
43
43
  component: PropTypes.Requireable<string>;
@@ -149,4 +149,7 @@ export interface Locale {
149
149
  total: string;
150
150
  selected: string;
151
151
  };
152
+ Form: {
153
+ optional: string;
154
+ }
152
155
  }
@@ -150,6 +150,9 @@ const local: Locale = {
150
150
  total: 'مجموع ${total} العناصر',
151
151
  selected: '${total} العناصر المحدد',
152
152
  },
153
+ Form: {
154
+ optional: '(اختياري)',
155
+ },
153
156
  };
154
157
 
155
158
  // [i18n-Arabic]
@@ -150,6 +150,9 @@ const local: Locale = {
150
150
  total: 'Gesamt ${total} Artikel',
151
151
  selected: '${total} ausgewählte Artikel',
152
152
  },
153
+ Form: {
154
+ optional: '(Optional)',
155
+ },
153
156
  };
154
157
 
155
158
  // [i18n-German]
@@ -150,6 +150,9 @@ const local: Locale = {
150
150
  total: 'Total ${total} items',
151
151
  selected: '${total} items selected',
152
152
  },
153
+ Form: {
154
+ optional: '(optional)',
155
+ },
153
156
  };
154
157
 
155
158
  // [i18n-English(GB)]
@@ -150,6 +150,9 @@ const local: Locale = {
150
150
  total: 'Total ${total} items',
151
151
  selected: '${total} items selected',
152
152
  },
153
+ Form: {
154
+ optional: '(optional)',
155
+ },
153
156
  };
154
157
 
155
158
  // [i18n-English(US)]
@@ -155,6 +155,9 @@ const locale: Locale = {
155
155
  total: 'Total ${total} objetos',
156
156
  selected: '${total} objetos seleccionados',
157
157
  },
158
+ Form: {
159
+ optional: '(opcional)',
160
+ },
158
161
  };
159
162
 
160
163
  export default locale;
@@ -150,6 +150,9 @@ const local: Locale = {
150
150
  total: 'Totale ${total} articles',
151
151
  selected: '${total} articles sélectionnés',
152
152
  },
153
+ Form: {
154
+ optional: '(optionnel)',
155
+ },
153
156
  };
154
157
 
155
158
  // [i18n-French]
@@ -150,6 +150,9 @@ const local: Locale = {
150
150
  total: 'Total ${total} proyek',
151
151
  selected: '${total} item dipilih',
152
152
  },
153
+ Form: {
154
+ optional: '(opsional)',
155
+ },
153
156
  };
154
157
 
155
158
  // [i18n-Indonesia(ID)]
@@ -150,6 +150,9 @@ const local: Locale = {
150
150
  total: 'Totale ${total} elementi',
151
151
  selected: '${total} elementi selezionati',
152
152
  },
153
+ Form: {
154
+ optional: '(opzionale)',
155
+ },
153
156
  };
154
157
 
155
158
  // [i18n-Italian]
@@ -151,6 +151,9 @@ const local: Locale = {
151
151
  total: '合計 ${total} アイテム',
152
152
  selected: '選択済み ${total} アイテム',
153
153
  },
154
+ Form: {
155
+ optional: '(オプション)',
156
+ },
154
157
  };
155
158
 
156
159
  // [i18n-Japan]
@@ -151,6 +151,9 @@ const local: Locale = {
151
151
  total: '총 {total} 개 항목',
152
152
  selected: '선택된 {Total} 개 항목',
153
153
  },
154
+ Form: {
155
+ optional: '(선택 과목)',
156
+ },
154
157
  };
155
158
 
156
159
  // [i18n-Korea]
@@ -150,6 +150,9 @@ const local: Locale = {
150
150
  total: 'Jumlah ${total} item',
151
151
  selected: '${total} projek dipilih',
152
152
  },
153
+ Form: {
154
+ optional: '(pilihan)',
155
+ },
153
156
  };
154
157
 
155
158
  // [i18n-Malaysia(MY)]
@@ -158,6 +158,9 @@ const local: Locale = {
158
158
  total: 'Total de ${total} itens',
159
159
  selected: '${total} itens selecionados',
160
160
  },
161
+ Form: {
162
+ optional: '(opcional)',
163
+ },
161
164
  };
162
165
 
163
166
  // 葡萄牙语
@@ -153,6 +153,9 @@ const local: Locale = {
153
153
  total: 'Всего ${total} элементов',
154
154
  selected: 'Выбрано ${total} элементов',
155
155
  },
156
+ Form: {
157
+ optional: '(по желанию)',
158
+ },
156
159
  };
157
160
 
158
161
  // [i18n-Russia] 俄罗斯语
@@ -154,6 +154,9 @@ const local: Locale = {
154
154
  total: 'รวม ${total} รายการ',
155
155
  selected: 'เลือก ${total} รายการ',
156
156
  },
157
+ Form: {
158
+ optional: '(ไม่จำเป็น)',
159
+ },
157
160
  };
158
161
 
159
162
  // [i18n-Thai]
@@ -149,7 +149,10 @@ const local: Locale = {
149
149
  clearSelectAll: 'Tümünün seçimini kaldır',
150
150
  total: 'Toplam ${total} öğe',
151
151
  selected: '${total} öğe seçildi'
152
- }
152
+ },
153
+ Form: {
154
+ optional: '(isteğe bağlı)',
155
+ },
153
156
  };
154
157
 
155
158
  // [i18n-Turkish]
@@ -153,6 +153,9 @@ const local: Locale = {
153
153
  total: 'Tổng số ${total} mặt hàng',
154
154
  selected: '${total} mục được chọn',
155
155
  },
156
+ Form: {
157
+ optional: '(không bắt buộc)',
158
+ },
156
159
  };
157
160
 
158
161
  // [i18n-Vietnam] 越南语
@@ -151,6 +151,9 @@ const local: Locale = {
151
151
  total: '共 ${total} 项',
152
152
  selected: '已选 ${total} 项',
153
153
  },
154
+ Form: {
155
+ optional: '(可选)',
156
+ },
154
157
  };
155
158
 
156
159
  // 中文
@@ -151,6 +151,9 @@ const local: Locale = {
151
151
  total: '共 ${total} 項',
152
152
  selected: '已選 ${total} 項',
153
153
  },
154
+ Form: {
155
+ optional: '(可選)',
156
+ },
154
157
  };
155
158
 
156
159
  // 中文
package/modal/Modal.tsx CHANGED
@@ -347,12 +347,6 @@ class Modal extends BaseComponent<ModalReactProps, ModalState> {
347
347
  let style = styleFromProps;
348
348
  const maskStyle = maskStyleFromProps;
349
349
  const renderFooter = 'footer' in this.props ? footer : this.renderFooter();
350
- if (this.props.centered) {
351
- style = {
352
- transform: 'translateY(-50%)',
353
- top: '50%', ...style,
354
- };
355
- }
356
350
  let wrapperStyle: {
357
351
  zIndex?: CSSProperties['zIndex'];
358
352
  position?: CSSProperties['position'];
@@ -318,7 +318,10 @@ export default class ModalContent extends BaseComponent<ModalContentReactProps,
318
318
  <div
319
319
  role="none"
320
320
  tabIndex={-1}
321
- className={`${cssClasses.DIALOG}-wrap`}
321
+ className={cls({
322
+ [`${cssClasses.DIALOG}-wrap`]:true,
323
+ [`${cssClasses.DIALOG}-wrap-center`]:this.props.centered
324
+ })}
322
325
  onClick={maskClosable ? this.onMaskClick : null}
323
326
  onMouseUp={maskClosable ? this.onMaskMouseUp : null}
324
327
  >
@@ -287,7 +287,7 @@ describe('modal', () => {
287
287
  it('centered without motion', () => {
288
288
  let com = getModal({ centered: true, visible: true, motion: false });
289
289
  let modal = mount(com, { attachTo: document.getElementById('container') });
290
- expect(modal.find(`div.${BASE_CLASS_PREFIX}-modal`)).toHaveStyle({ transform: 'translateY(-50%)', top: '50%' });
290
+ expect(modal.find(`div.${BASE_CLASS_PREFIX}-modal-wrap`)).toHaveClassName(`${BASE_CLASS_PREFIX}-modal-wrap-center`)
291
291
  });
292
292
 
293
293
  it('keepDOM', () => {
@@ -0,0 +1,203 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`模态框-点击遮罩层不可关闭 1`] = `
4
+ <DialogComponent
5
+ maskClosable={false}
6
+ >
7
+ <Button
8
+ onClick={[Function]}
9
+ >
10
+ <Button
11
+ block={false}
12
+ disabled={false}
13
+ htmlType="button"
14
+ onClick={[Function]}
15
+ onMouseDown={[Function]}
16
+ onMouseEnter={[Function]}
17
+ onMouseLeave={[Function]}
18
+ prefixCls="semi-button"
19
+ size="default"
20
+ theme="light"
21
+ type="primary"
22
+ >
23
+ <button
24
+ aria-disabled={false}
25
+ className="semi-button semi-button-primary semi-button-light"
26
+ disabled={false}
27
+ onClick={[Function]}
28
+ onMouseDown={[Function]}
29
+ onMouseEnter={[Function]}
30
+ onMouseLeave={[Function]}
31
+ type="button"
32
+ >
33
+ <span
34
+ className="semi-button-content"
35
+ onClick={[Function]}
36
+ x-semi-prop="children"
37
+ >
38
+ show dialog
39
+ </span>
40
+ </button>
41
+ </Button>
42
+ </Button>
43
+ <Button
44
+ onClick={[Function]}
45
+ >
46
+ <Button
47
+ block={false}
48
+ disabled={false}
49
+ htmlType="button"
50
+ onClick={[Function]}
51
+ onMouseDown={[Function]}
52
+ onMouseEnter={[Function]}
53
+ onMouseLeave={[Function]}
54
+ prefixCls="semi-button"
55
+ size="default"
56
+ theme="light"
57
+ type="primary"
58
+ >
59
+ <button
60
+ aria-disabled={false}
61
+ className="semi-button semi-button-primary semi-button-light"
62
+ disabled={false}
63
+ onClick={[Function]}
64
+ onMouseDown={[Function]}
65
+ onMouseEnter={[Function]}
66
+ onMouseLeave={[Function]}
67
+ type="button"
68
+ >
69
+ <span
70
+ className="semi-button-content"
71
+ onClick={[Function]}
72
+ x-semi-prop="children"
73
+ >
74
+ 静态调用
75
+ </span>
76
+ </button>
77
+ </Button>
78
+ </Button>
79
+ <Modal
80
+ afterClose={[Function]}
81
+ cancelLoading={false}
82
+ centered={false}
83
+ closable={true}
84
+ closeOnEsc={true}
85
+ confirmLoading={false}
86
+ fullScreen={false}
87
+ hasCancel={true}
88
+ keepDOM={false}
89
+ lazyRender={true}
90
+ mask={true}
91
+ maskClosable={false}
92
+ maskFixed={false}
93
+ motion={true}
94
+ okType="primary"
95
+ onCancel={[Function]}
96
+ onOk={[Function]}
97
+ size="small"
98
+ title="对话框标题"
99
+ visible={false}
100
+ zIndex={1000}
101
+ />
102
+ </DialogComponent>
103
+ `;
104
+
105
+ exports[`模态框默认 1`] = `
106
+ <DialogComponent>
107
+ <Button
108
+ onClick={[Function]}
109
+ >
110
+ <Button
111
+ block={false}
112
+ disabled={false}
113
+ htmlType="button"
114
+ onClick={[Function]}
115
+ onMouseDown={[Function]}
116
+ onMouseEnter={[Function]}
117
+ onMouseLeave={[Function]}
118
+ prefixCls="semi-button"
119
+ size="default"
120
+ theme="light"
121
+ type="primary"
122
+ >
123
+ <button
124
+ aria-disabled={false}
125
+ className="semi-button semi-button-primary semi-button-light"
126
+ disabled={false}
127
+ onClick={[Function]}
128
+ onMouseDown={[Function]}
129
+ onMouseEnter={[Function]}
130
+ onMouseLeave={[Function]}
131
+ type="button"
132
+ >
133
+ <span
134
+ className="semi-button-content"
135
+ onClick={[Function]}
136
+ x-semi-prop="children"
137
+ >
138
+ show dialog
139
+ </span>
140
+ </button>
141
+ </Button>
142
+ </Button>
143
+ <Button
144
+ onClick={[Function]}
145
+ >
146
+ <Button
147
+ block={false}
148
+ disabled={false}
149
+ htmlType="button"
150
+ onClick={[Function]}
151
+ onMouseDown={[Function]}
152
+ onMouseEnter={[Function]}
153
+ onMouseLeave={[Function]}
154
+ prefixCls="semi-button"
155
+ size="default"
156
+ theme="light"
157
+ type="primary"
158
+ >
159
+ <button
160
+ aria-disabled={false}
161
+ className="semi-button semi-button-primary semi-button-light"
162
+ disabled={false}
163
+ onClick={[Function]}
164
+ onMouseDown={[Function]}
165
+ onMouseEnter={[Function]}
166
+ onMouseLeave={[Function]}
167
+ type="button"
168
+ >
169
+ <span
170
+ className="semi-button-content"
171
+ onClick={[Function]}
172
+ x-semi-prop="children"
173
+ >
174
+ 静态调用
175
+ </span>
176
+ </button>
177
+ </Button>
178
+ </Button>
179
+ <Modal
180
+ afterClose={[Function]}
181
+ cancelLoading={false}
182
+ centered={false}
183
+ closable={true}
184
+ closeOnEsc={true}
185
+ confirmLoading={false}
186
+ fullScreen={false}
187
+ hasCancel={true}
188
+ keepDOM={false}
189
+ lazyRender={true}
190
+ mask={true}
191
+ maskClosable={true}
192
+ maskFixed={false}
193
+ motion={true}
194
+ okType="primary"
195
+ onCancel={[Function]}
196
+ onOk={[Function]}
197
+ size="small"
198
+ title="对话框标题"
199
+ visible={false}
200
+ zIndex={1000}
201
+ />
202
+ </DialogComponent>
203
+ `;