@douyinfe/semi-ui 2.17.0 → 2.19.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 (179) 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 +3 -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/dist/css/semi.css +174 -29
  13. package/dist/css/semi.min.css +1 -1
  14. package/dist/umd/semi-ui.js +4190 -5430
  15. package/dist/umd/semi-ui.js.map +1 -1
  16. package/dist/umd/semi-ui.min.js +1 -1
  17. package/dist/umd/semi-ui.min.js.map +1 -1
  18. package/form/_story/FieldProps/labelOptional.jsx +30 -0
  19. package/form/_story/form.stories.js +7 -0
  20. package/form/hoc/withField.tsx +1 -0
  21. package/form/label.tsx +21 -7
  22. package/gulpfile.js +3 -1
  23. package/lib/cjs/_base/base.css +35 -0
  24. package/lib/cjs/anchor/index.js +2 -1
  25. package/lib/cjs/anchor/link.d.ts +1 -1
  26. package/lib/cjs/anchor/link.js +9 -5
  27. package/lib/cjs/autoComplete/index.d.ts +1 -1
  28. package/lib/cjs/autoComplete/index.js +6 -3
  29. package/lib/cjs/autoComplete/option.d.ts +50 -0
  30. package/lib/cjs/autoComplete/option.js +218 -0
  31. package/lib/cjs/calendar/index.d.ts +2 -0
  32. package/lib/cjs/calendar/index.js +3 -1
  33. package/lib/cjs/calendar/interface.d.ts +2 -1
  34. package/lib/cjs/carousel/index.js +2 -2
  35. package/lib/cjs/checkbox/checkbox.d.ts +4 -0
  36. package/lib/cjs/checkbox/checkbox.js +9 -3
  37. package/lib/cjs/form/hoc/withField.js +2 -1
  38. package/lib/cjs/form/label.d.ts +8 -5
  39. package/lib/cjs/form/label.js +15 -4
  40. package/lib/cjs/locale/interface.d.ts +3 -0
  41. package/lib/cjs/locale/source/ar.js +3 -0
  42. package/lib/cjs/locale/source/de.js +3 -0
  43. package/lib/cjs/locale/source/en_GB.js +3 -0
  44. package/lib/cjs/locale/source/en_US.js +3 -0
  45. package/lib/cjs/locale/source/es.js +3 -0
  46. package/lib/cjs/locale/source/fr.js +3 -0
  47. package/lib/cjs/locale/source/id_ID.js +3 -0
  48. package/lib/cjs/locale/source/it.js +3 -0
  49. package/lib/cjs/locale/source/ja_JP.js +3 -0
  50. package/lib/cjs/locale/source/ko_KR.js +3 -0
  51. package/lib/cjs/locale/source/ms_MY.js +3 -0
  52. package/lib/cjs/locale/source/pt_BR.js +3 -0
  53. package/lib/cjs/locale/source/ru_RU.js +3 -0
  54. package/lib/cjs/locale/source/th_TH.js +3 -0
  55. package/lib/cjs/locale/source/tr_TR.js +3 -0
  56. package/lib/cjs/locale/source/vi_VN.js +3 -0
  57. package/lib/cjs/locale/source/zh_CN.js +3 -0
  58. package/lib/cjs/locale/source/zh_TW.js +3 -0
  59. package/lib/cjs/modal/Modal.js +0 -8
  60. package/lib/cjs/modal/ModalContent.js +4 -1
  61. package/lib/cjs/radio/radio.d.ts +2 -0
  62. package/lib/cjs/radio/radio.js +33 -8
  63. package/lib/cjs/table/ColumnFilter.js +4 -2
  64. package/lib/cjs/table/ColumnSorter.d.ts +1 -0
  65. package/lib/cjs/table/ColumnSorter.js +9 -6
  66. package/lib/cjs/table/Table.js +11 -4
  67. package/lib/cjs/tag/group.d.ts +3 -0
  68. package/lib/cjs/tag/group.js +24 -6
  69. package/lib/cjs/tag/index.d.ts +2 -1
  70. package/lib/cjs/tag/index.js +7 -5
  71. package/lib/cjs/tag/interface.d.ts +2 -1
  72. package/lib/cjs/tree/index.d.ts +3 -1
  73. package/lib/cjs/tree/index.js +23 -0
  74. package/lib/cjs/tree/interface.d.ts +4 -0
  75. package/lib/cjs/tree/treeNode.d.ts +4 -1
  76. package/lib/cjs/tree/treeNode.js +13 -4
  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 +6 -3
  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/form/hoc/withField.js +2 -1
  92. package/lib/es/form/label.d.ts +8 -5
  93. package/lib/es/form/label.js +13 -4
  94. package/lib/es/locale/interface.d.ts +3 -0
  95. package/lib/es/locale/source/ar.js +3 -0
  96. package/lib/es/locale/source/de.js +3 -0
  97. package/lib/es/locale/source/en_GB.js +3 -0
  98. package/lib/es/locale/source/en_US.js +3 -0
  99. package/lib/es/locale/source/es.js +3 -0
  100. package/lib/es/locale/source/fr.js +3 -0
  101. package/lib/es/locale/source/id_ID.js +3 -0
  102. package/lib/es/locale/source/it.js +3 -0
  103. package/lib/es/locale/source/ja_JP.js +3 -0
  104. package/lib/es/locale/source/ko_KR.js +3 -0
  105. package/lib/es/locale/source/ms_MY.js +3 -0
  106. package/lib/es/locale/source/pt_BR.js +3 -0
  107. package/lib/es/locale/source/ru_RU.js +3 -0
  108. package/lib/es/locale/source/th_TH.js +3 -0
  109. package/lib/es/locale/source/tr_TR.js +3 -0
  110. package/lib/es/locale/source/vi_VN.js +3 -0
  111. package/lib/es/locale/source/zh_CN.js +3 -0
  112. package/lib/es/locale/source/zh_TW.js +3 -0
  113. package/lib/es/modal/Modal.js +0 -8
  114. package/lib/es/modal/ModalContent.js +4 -1
  115. package/lib/es/radio/radio.d.ts +2 -0
  116. package/lib/es/radio/radio.js +31 -8
  117. package/lib/es/table/ColumnFilter.js +4 -2
  118. package/lib/es/table/ColumnSorter.d.ts +1 -0
  119. package/lib/es/table/ColumnSorter.js +9 -6
  120. package/lib/es/table/Table.js +10 -4
  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/tree/treeNode.d.ts +4 -1
  130. package/lib/es/tree/treeNode.js +13 -4
  131. package/locale/interface.ts +3 -0
  132. package/locale/source/ar.ts +3 -0
  133. package/locale/source/de.ts +3 -0
  134. package/locale/source/en_GB.ts +3 -0
  135. package/locale/source/en_US.ts +3 -0
  136. package/locale/source/es.ts +3 -0
  137. package/locale/source/fr.ts +3 -0
  138. package/locale/source/id_ID.ts +3 -0
  139. package/locale/source/it.ts +3 -0
  140. package/locale/source/ja_JP.ts +3 -0
  141. package/locale/source/ko_KR.ts +3 -0
  142. package/locale/source/ms_MY.ts +3 -0
  143. package/locale/source/pt_BR.ts +3 -0
  144. package/locale/source/ru_RU.ts +3 -0
  145. package/locale/source/th_TH.ts +3 -0
  146. package/locale/source/tr_TR.ts +4 -1
  147. package/locale/source/vi_VN.ts +3 -0
  148. package/locale/source/zh_CN.ts +3 -0
  149. package/locale/source/zh_TW.ts +3 -0
  150. package/modal/Modal.tsx +0 -6
  151. package/modal/ModalContent.tsx +4 -1
  152. package/modal/__test__/modal.test.js +1 -1
  153. package/modal/_story/__snapshots__/modal.stories.tsx.snap +203 -0
  154. package/package.json +7 -7
  155. package/radio/_story/radio.stories.js +2 -2
  156. package/radio/radio.tsx +27 -5
  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/table/ColumnFilter.tsx +2 -1
  164. package/table/ColumnSorter.tsx +16 -10
  165. package/table/Table.tsx +7 -4
  166. package/table/_story/v2/FixedFilter/index.tsx +106 -0
  167. package/table/_story/v2/FixedSorter/index.tsx +102 -0
  168. package/table/_story/v2/index.js +4 -2
  169. package/tag/_story/tag.stories.js +57 -1
  170. package/tag/group.tsx +20 -3
  171. package/tag/index.tsx +6 -5
  172. package/tag/interface.ts +2 -1
  173. package/transfer/_story/transfer.stories.js +2 -2
  174. package/tree/_story/tree.stories.js +152 -3
  175. package/tree/index.tsx +16 -1
  176. package/tree/interface.ts +6 -0
  177. package/tree/treeNode.tsx +11 -5
  178. package/upload/_story/upload.stories.js +2 -2
  179. package/webpack.config.js +13 -3
@@ -100,9 +100,10 @@ class TagGroup extends _react.PureComponent {
100
100
  tagList,
101
101
  size,
102
102
  mode,
103
- avatarShape
103
+ avatarShape,
104
+ onTagClose
104
105
  } = this.props;
105
- const renderTags = (0, _map.default)(tagList).call(tagList, (tag, index) => {
106
+ const renderTags = (0, _map.default)(tagList).call(tagList, tag => {
106
107
  if (mode === 'custom') {
107
108
  return tag;
108
109
  }
@@ -115,9 +116,24 @@ class TagGroup extends _react.PureComponent {
115
116
  tag.avatarShape = avatarShape;
116
117
  }
117
118
 
118
- return /*#__PURE__*/_react.default.createElement(_index.default, (0, _assign.default)({
119
- key: "".concat(index, "-tag")
120
- }, tag));
119
+ if (!tag.tagKey) {
120
+ if (typeof tag.children === 'string' || typeof tag.children === 'number') {
121
+ tag.tagKey = tag.children;
122
+ } else {
123
+ tag.tagKey = Math.random();
124
+ }
125
+ }
126
+
127
+ return /*#__PURE__*/_react.default.createElement(_index.default, (0, _assign.default)({}, tag, {
128
+ key: tag.tagKey,
129
+ onClose: (tagChildren, e, tagKey) => {
130
+ if (tag.onClose) {
131
+ tag.onClose(tagChildren, e, tagKey);
132
+ }
133
+
134
+ onTagClose && onTagClose(tagChildren, e, tagKey);
135
+ }
136
+ }));
121
137
  });
122
138
  return renderTags;
123
139
  }
@@ -150,7 +166,8 @@ TagGroup.defaultProps = {
150
166
  style: {},
151
167
  className: '',
152
168
  size: tagSize[0],
153
- avatarShape: 'square'
169
+ avatarShape: 'square',
170
+ onTagClose: () => undefined
154
171
  };
155
172
  TagGroup.propTypes = {
156
173
  children: _propTypes.default.node,
@@ -161,6 +178,7 @@ TagGroup.propTypes = {
161
178
  tagList: _propTypes.default.array,
162
179
  size: _propTypes.default.oneOf(tagSize),
163
180
  mode: _propTypes.default.string,
181
+ onTagClose: _propTypes.default.func,
164
182
  showPopover: _propTypes.default.bool,
165
183
  popoverProps: _propTypes.default.object,
166
184
  avatarShape: _propTypes.default.oneOf(avatarShapeSet)
@@ -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;
@@ -118,13 +118,13 @@ class Tag extends _react.Component {
118
118
  }
119
119
  }
120
120
 
121
- close(e, value) {
121
+ close(e, value, tagKey) {
122
122
  const {
123
123
  onClose
124
124
  } = this.props;
125
125
  e.stopPropagation();
126
126
  e.nativeEvent.stopImmediatePropagation();
127
- onClose && onClose(value, e); // when user call e.preventDefault() in onClick callback, tag will not hidden
127
+ onClose && onClose(value, e, tagKey); // when user call e.preventDefault() in onClick callback, tag will not hidden
128
128
 
129
129
  if (e.defaultPrevented) {
130
130
  return;
@@ -143,7 +143,7 @@ class Tag extends _react.Component {
143
143
  switch (event.key) {
144
144
  case "Backspace":
145
145
  case "Delete":
146
- closable && this.close(event, this.props.children);
146
+ closable && this.close(event, this.props.children, this.props.tagKey);
147
147
  (0, _a11y.handlePrevent)(event);
148
148
  break;
149
149
 
@@ -182,6 +182,7 @@ class Tag extends _react.Component {
182
182
 
183
183
  const _a = this.props,
184
184
  {
185
+ tagKey,
185
186
  children,
186
187
  size,
187
188
  color,
@@ -195,7 +196,7 @@ class Tag extends _react.Component {
195
196
  avatarShape,
196
197
  tabIndex
197
198
  } = _a,
198
- attr = __rest(_a, ["children", "size", "color", "closable", "visible", "onClose", "onClick", "className", "type", "avatarSrc", "avatarShape", "tabIndex"]);
199
+ attr = __rest(_a, ["tagKey", "children", "size", "color", "closable", "visible", "onClose", "onClick", "className", "type", "avatarSrc", "avatarShape", "tabIndex"]);
199
200
 
200
201
  const {
201
202
  visible: isVisible
@@ -226,7 +227,7 @@ class Tag extends _react.Component {
226
227
  // eslint-disable-next-line jsx-a11y/click-events-have-key-events
227
228
  _react.default.createElement("div", {
228
229
  className: "".concat(prefixCls, "-close"),
229
- onClick: e => this.close(e, children)
230
+ onClick: e => this.close(e, children, tagKey)
230
231
  }, /*#__PURE__*/_react.default.createElement(_semiIcons.IconClose, {
231
232
  size: "small"
232
233
  })) : null;
@@ -254,6 +255,7 @@ Tag.defaultProps = {
254
255
  };
255
256
  Tag.propTypes = {
256
257
  children: _propTypes.default.node,
258
+ tagKey: _propTypes.default.oneOf([_propTypes.default.string, _propTypes.default.number]),
257
259
  size: _propTypes.default.oneOf(tagSize),
258
260
  color: _propTypes.default.oneOf(tagColors),
259
261
  type: _propTypes.default.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/cjs/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;
@@ -17,6 +17,8 @@ _Object$defineProperty(exports, "__esModule", {
17
17
  var _exportNames = {};
18
18
  exports.default = void 0;
19
19
 
20
+ var _findIndex = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find-index"));
21
+
20
22
  var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
21
23
 
22
24
  var _set = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/set"));
@@ -101,6 +103,25 @@ class Tree extends _baseComponent.default {
101
103
  this.foundation.handleInputChange(value);
102
104
  };
103
105
 
106
+ this.scrollTo = scrollData => {
107
+ var _a;
108
+
109
+ const {
110
+ key,
111
+ align = 'center'
112
+ } = scrollData;
113
+ const {
114
+ flattenNodes
115
+ } = this.state;
116
+
117
+ if (key) {
118
+ const index = flattenNodes === null || flattenNodes === void 0 ? void 0 : (0, _findIndex.default)(flattenNodes).call(flattenNodes, node => {
119
+ return node.key === key;
120
+ });
121
+ index >= 0 && ((_a = this.virtualizedListRef.current) === null || _a === void 0 ? void 0 : _a.scrollToItem(index, align));
122
+ }
123
+ };
124
+
104
125
  this.renderEmpty = () => {
105
126
  const {
106
127
  emptyContent
@@ -262,6 +283,7 @@ class Tree extends _baseComponent.default {
262
283
  this.optionsRef = /*#__PURE__*/_react.default.createRef();
263
284
  this.foundation = new _foundation.default(this.adapter);
264
285
  this.dragNode = null;
286
+ this.virtualizedListRef = /*#__PURE__*/_react.default.createRef();
265
287
  }
266
288
  /**
267
289
  * Process of getDerivedStateFromProps was inspired by rc-tree
@@ -634,6 +656,7 @@ class Tree extends _baseComponent.default {
634
656
  width
635
657
  } = _ref4;
636
658
  return /*#__PURE__*/_react.default.createElement(_reactWindow.FixedSizeList, {
659
+ ref: this.virtualizedListRef,
637
660
  itemCount: flattenNodes.length,
638
661
  itemSize: virtualize.itemSize,
639
662
  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
+ }
@@ -55,7 +55,10 @@ export default class TreeNode extends PureComponent<TreeNodeProps, TreeNodeState
55
55
  isLeaf: () => boolean;
56
56
  isDisabled: () => boolean;
57
57
  renderArrow(): JSX.Element;
58
- renderCheckbox(): JSX.Element;
58
+ renderCheckbox(options: {
59
+ label: React.ReactNode;
60
+ icon: React.ReactNode;
61
+ }): JSX.Element;
59
62
  renderIcon(): any;
60
63
  renderEmptyNode(): JSX.Element;
61
64
  renderRealLabel: () => any;
@@ -339,7 +339,11 @@ class TreeNode extends _react.PureComponent {
339
339
  });
340
340
  }
341
341
 
342
- renderCheckbox() {
342
+ renderCheckbox(options) {
343
+ const {
344
+ label,
345
+ icon
346
+ } = options;
343
347
  const {
344
348
  checked,
345
349
  halfChecked,
@@ -356,7 +360,7 @@ class TreeNode extends _react.PureComponent {
356
360
  indeterminate: halfChecked,
357
361
  checked: checked,
358
362
  disabled: Boolean(disabled)
359
- }));
363
+ }, icon, label));
360
364
  }
361
365
 
362
366
  renderIcon() {
@@ -524,6 +528,8 @@ class TreeNode extends _react.PureComponent {
524
528
  });
525
529
  const setsize = (0, _get2.default)(rest, ['data', 'children', 'length']);
526
530
  const posinset = (0, _isString2.default)(rest.pos) ? Number(rest.pos.split('-')[level + 1]) + 1 : 1;
531
+ const label = this.renderRealLabel();
532
+ const icon = this.renderIcon();
527
533
  return /*#__PURE__*/_react.default.createElement("li", (0, _assign.default)({
528
534
  className: nodeCls,
529
535
  role: "treeitem",
@@ -543,9 +549,12 @@ class TreeNode extends _react.PureComponent {
543
549
  style: style
544
550
  }, dragProps), this.renderArrow(), /*#__PURE__*/_react.default.createElement("span", {
545
551
  className: labelCls
546
- }, multiple ? this.renderCheckbox() : null, this.renderIcon(), /*#__PURE__*/_react.default.createElement("span", {
552
+ }, multiple ? this.renderCheckbox({
553
+ label,
554
+ icon
555
+ }) : null, !multiple && icon, !multiple && /*#__PURE__*/_react.default.createElement("span", {
547
556
  className: "".concat(prefixcls, "-label-text")
548
- }, this.renderRealLabel())));
557
+ }, label)));
549
558
  }
550
559
 
551
560
  }
@@ -1,6 +1,41 @@
1
1
  /* shadow */
2
2
  /* sizing */
3
3
  /* spacing */
4
+ body {
5
+ --semi-transition_duration-slowest:0ms;
6
+ --semi-transition_duration-slower:0ms;
7
+ --semi-transition_duration-slow:0ms;
8
+ --semi-transition_duration-normal:0ms;
9
+ --semi-transition_duration-fast:0ms;
10
+ --semi-transition_duration-faster:0ms;
11
+ --semi-transition_duration-fastest:0ms;
12
+ --semi-transition_function-linear:linear;
13
+ --semi-transition_function-ease:ease;
14
+ --semi-transition_function-easeIn:ease-in;
15
+ --semi-transition_function-easeOut:ease-out;
16
+ --semi-transition_function-easeInIOut:ease-in-out;
17
+ --semi-transition_delay-slowest:0ms;
18
+ --semi-transition_delay-slower:0ms;
19
+ --semi-transition_delay-slow:0ms;
20
+ --semi-transition_delay-normal:0ms;
21
+ --semi-transition_delay-fast:0ms;
22
+ --semi-transition_delay-faster:0ms;
23
+ --semi-transition_delay-fastest:0ms;
24
+ --semi-transform_scale-none:scale(1,1);
25
+ --semi-transform_scale-small:scale(1,1);
26
+ --semi-transform_scale-medium:scale(1,1);
27
+ --semi-transform_scale-large:scale(1,1);
28
+ --semi-transform-rotate-none:rotate(0deg);
29
+ --semi-transform_rotate-clockwise90deg:rotate(90deg);
30
+ --semi-transform_rotate-clockwise180deg:rotate(180deg);
31
+ --semi-transform_rotate-clockwise270deg:rotate(270deg);
32
+ --semi-transform_rotate-clockwise360deg:rotate(360deg);
33
+ --semi-transform_rotate-anticlockwise90deg:rotate(-90deg);
34
+ --semi-transform_rotate-anticlockwise180deg:rotate(-180deg);
35
+ --semi-transform_rotate-anticlockwise270deg:rotate(-270deg);
36
+ --semi-transform_rotate-anticlockwise360deg:rotate(-360deg);
37
+ }
38
+
4
39
  body,
5
40
  body .semi-always-light {
6
41
  --semi-amber-0: 254,251,235;
@@ -273,7 +273,8 @@ class Anchor extends BaseComponent {
273
273
  top: slideBarTop
274
274
  }
275
275
  })), /*#__PURE__*/React.createElement("div", {
276
- className: anchorWrapper
276
+ className: anchorWrapper,
277
+ role: "list"
277
278
  }, children)));
278
279
  }
279
280
 
@@ -36,6 +36,6 @@ export default class Link extends BaseComponent<LinkProps, {}> {
36
36
  componentDidUpdate(prevProps: LinkProps): void;
37
37
  componentWillUnmount(): void;
38
38
  renderTitle: () => string | number | boolean | React.ReactFragment | JSX.Element;
39
- renderChildren: () => React.ReactNode;
39
+ renderChildren: () => JSX.Element;
40
40
  render(): JSX.Element;
41
41
  }
@@ -65,10 +65,14 @@ export default class Link extends BaseComponent {
65
65
  } = this.props;
66
66
 
67
67
  if (!this.context.autoCollapse) {
68
- return this.props.children;
68
+ return /*#__PURE__*/React.createElement("div", {
69
+ role: "list"
70
+ }, children);
69
71
  }
70
72
 
71
- return activeLink === href || childMap[href] && childMap[href].has(activeLink) ? children : null;
73
+ return activeLink === href || childMap[href] && childMap[href].has(activeLink) ? /*#__PURE__*/React.createElement("div", {
74
+ role: "list"
75
+ }, children) : null;
72
76
  };
73
77
 
74
78
  this.foundation = new LinkFoundation(this.adapter);
@@ -144,8 +148,7 @@ export default class Link extends BaseComponent {
144
148
  ["".concat(prefixCls, "-link-title-disabled")]: disabled
145
149
  });
146
150
  const ariaProps = {
147
- 'aria-disabled': disabled,
148
- 'aria-label': href
151
+ 'aria-disabled': disabled
149
152
  };
150
153
 
151
154
  if (active) {
@@ -158,7 +161,8 @@ export default class Link extends BaseComponent {
158
161
 
159
162
  return /*#__PURE__*/React.createElement("div", {
160
163
  className: linkCls,
161
- style: style
164
+ style: style,
165
+ role: "listitem"
162
166
  }, /*#__PURE__*/React.createElement("div", _Object$assign({
163
167
  role: "link",
164
168
  tabIndex: 0
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
3
3
  import { AutoCompleteAdapter, StateOptionItem, DataItem } from '@douyinfe/semi-foundation/lib/es/autoComplete/foundation';
4
4
  import BaseComponent, { ValidateStatus } from '../_base/baseComponent';
5
5
  import { Position } from '../tooltip';
6
- import Option from '../select/option';
6
+ import Option from './option';
7
7
  import '@douyinfe/semi-foundation/lib/es/autoComplete/autoComplete.css';
8
8
  import { Motion } from '../_base/base';
9
9
  /**
@@ -19,7 +19,7 @@ import Spin from '../spin';
19
19
  import Popover from '../popover';
20
20
  import Input from '../input';
21
21
  import Trigger from '../trigger';
22
- import Option from '../select/option';
22
+ import Option from './option';
23
23
  import warning from '@douyinfe/semi-foundation/lib/es/utils/warning';
24
24
  import '@douyinfe/semi-foundation/lib/es/autoComplete/autoComplete.css';
25
25
  const prefixCls = cssClasses.PREFIX;
@@ -195,7 +195,7 @@ class AutoComplete extends BaseComponent {
195
195
  } = this.state;
196
196
  const useCustomTrigger = typeof triggerRender === 'function';
197
197
 
198
- const outerProps = _Object$assign({
198
+ const outerProps = _Object$assign(_Object$assign({
199
199
  style,
200
200
  className: useCustomTrigger ? cls(className) : cls({
201
201
  [prefixCls]: true,
@@ -204,7 +204,10 @@ class AutoComplete extends BaseComponent {
204
204
  onClick: this.handleInputClick,
205
205
  ref: this.triggerRef,
206
206
  id
207
- }, keyboardEventSet);
207
+ }, keyboardEventSet), {
208
+ // tooltip give tabindex 0 to children by default, autoComplete just need the input get focus, so outer div's tabindex set to -1
209
+ tabIndex: -1
210
+ });
208
211
 
209
212
  const innerProps = {
210
213
  disabled,
@@ -0,0 +1,50 @@
1
+ import React, { PureComponent } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { BasicOptionProps } from '@douyinfe/semi-foundation/lib/es/autoComplete/optionFoundation';
4
+ export interface OptionProps extends BasicOptionProps {
5
+ [x: string]: any;
6
+ value?: string | number;
7
+ label?: string | number | React.ReactNode;
8
+ children?: React.ReactNode;
9
+ disabled?: boolean;
10
+ showTick?: boolean;
11
+ className?: string;
12
+ style?: React.CSSProperties;
13
+ }
14
+ interface renderOptionContentArgument {
15
+ config: {
16
+ searchWords: any;
17
+ sourceString: React.ReactNode;
18
+ };
19
+ children: React.ReactNode;
20
+ inputValue: string;
21
+ prefixCls: string;
22
+ }
23
+ declare class Option extends PureComponent<OptionProps> {
24
+ static isSelectOption: boolean;
25
+ static propTypes: {
26
+ children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
27
+ disabled: PropTypes.Requireable<boolean>;
28
+ value: PropTypes.Requireable<string | number>;
29
+ selected: PropTypes.Requireable<boolean>;
30
+ label: PropTypes.Requireable<PropTypes.ReactNodeLike>;
31
+ empty: PropTypes.Requireable<boolean>;
32
+ emptyContent: PropTypes.Requireable<PropTypes.ReactNodeLike>;
33
+ onSelect: PropTypes.Requireable<(...args: any[]) => any>;
34
+ focused: PropTypes.Requireable<boolean>;
35
+ showTick: PropTypes.Requireable<boolean>;
36
+ className: PropTypes.Requireable<string>;
37
+ style: PropTypes.Requireable<object>;
38
+ onMouseEnter: PropTypes.Requireable<(...args: any[]) => any>;
39
+ prefixCls: PropTypes.Requireable<string>;
40
+ renderOptionItem: PropTypes.Requireable<(...args: any[]) => any>;
41
+ inputValue: PropTypes.Requireable<string>;
42
+ };
43
+ static defaultProps: {
44
+ prefixCls: string;
45
+ };
46
+ onClick({ value, label, children, ...rest }: Partial<OptionProps>, event: React.MouseEvent): void;
47
+ renderOptionContent({ config, children, inputValue, prefixCls }: renderOptionContentArgument): React.ReactNode;
48
+ render(): any;
49
+ }
50
+ export default Option;
@@ -0,0 +1,188 @@
1
+ import _isString from "lodash/isString";
2
+ import _indexOfInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/index-of";
3
+ import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
4
+ import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
5
+
6
+ var __rest = this && this.__rest || function (s, e) {
7
+ var t = {};
8
+
9
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && _indexOfInstanceProperty(e).call(e, p) < 0) t[p] = s[p];
10
+
11
+ if (s != null && typeof _Object$getOwnPropertySymbols === "function") for (var i = 0, p = _Object$getOwnPropertySymbols(s); i < p.length; i++) {
12
+ if (_indexOfInstanceProperty(e).call(e, p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
13
+ }
14
+ return t;
15
+ };
16
+ /* eslint-disable max-len */
17
+
18
+
19
+ import React, { PureComponent } from 'react';
20
+ import classNames from 'classnames';
21
+ import PropTypes from 'prop-types';
22
+ import { cssClasses } from '@douyinfe/semi-foundation/lib/es/autoComplete/constants';
23
+ import LocaleConsumer from '../locale/localeConsumer';
24
+ import { IconTick } from '@douyinfe/semi-icons';
25
+ import { getHighLightTextHTML } from '../_utils/index';
26
+
27
+ class Option extends PureComponent {
28
+ onClick(_a, event) {
29
+ var {
30
+ value,
31
+ label,
32
+ children
33
+ } = _a,
34
+ rest = __rest(_a, ["value", "label", "children"]);
35
+
36
+ const {
37
+ props
38
+ } = this;
39
+ const isDisabled = props.disabled;
40
+
41
+ if (!isDisabled) {
42
+ props.onSelect(_Object$assign(_Object$assign({}, rest), {
43
+ value,
44
+ label: label || children
45
+ }), event);
46
+ }
47
+ }
48
+
49
+ renderOptionContent(_ref) {
50
+ let {
51
+ config,
52
+ children,
53
+ inputValue,
54
+ prefixCls
55
+ } = _ref;
56
+
57
+ if (_isString(children) && inputValue) {
58
+ return getHighLightTextHTML(config);
59
+ }
60
+
61
+ return children;
62
+ }
63
+
64
+ render() {
65
+ const _a = this.props,
66
+ {
67
+ children,
68
+ disabled,
69
+ value,
70
+ selected,
71
+ label,
72
+ empty,
73
+ emptyContent,
74
+ onSelect,
75
+ focused,
76
+ showTick,
77
+ className,
78
+ style,
79
+ onMouseEnter,
80
+ prefixCls,
81
+ renderOptionItem,
82
+ inputValue
83
+ } = _a,
84
+ rest = __rest(_a, ["children", "disabled", "value", "selected", "label", "empty", "emptyContent", "onSelect", "focused", "showTick", "className", "style", "onMouseEnter", "prefixCls", "renderOptionItem", "inputValue"]);
85
+
86
+ const optionClassName = classNames(prefixCls, {
87
+ ["".concat(prefixCls, "-disabled")]: disabled,
88
+ ["".concat(prefixCls, "-selected")]: selected,
89
+ ["".concat(prefixCls, "-focused")]: focused,
90
+ ["".concat(prefixCls, "-empty")]: empty,
91
+ [className]: className
92
+ });
93
+ const selectedIconClassName = classNames(["".concat(prefixCls, "-icon")]);
94
+
95
+ if (empty) {
96
+ if (emptyContent === null) {
97
+ return null;
98
+ }
99
+
100
+ return /*#__PURE__*/React.createElement(LocaleConsumer, {
101
+ componentName: "Select"
102
+ }, locale => /*#__PURE__*/React.createElement("div", {
103
+ className: optionClassName,
104
+ "x-semi-prop": "emptyContent"
105
+ }, emptyContent || locale.emptyText));
106
+ } // Since there are empty, locale and other logic, the custom renderOptionItem is directly converged to the internal option instead of being placed in Select/index
107
+
108
+
109
+ if (typeof renderOptionItem === 'function') {
110
+ return renderOptionItem(_Object$assign({
111
+ disabled,
112
+ focused,
113
+ selected,
114
+ style,
115
+ label,
116
+ value,
117
+ inputValue,
118
+ onMouseEnter: e => onMouseEnter(e),
119
+ onClick: e => this.onClick(_Object$assign({
120
+ value,
121
+ label,
122
+ children
123
+ }, rest), e)
124
+ }, rest));
125
+ }
126
+
127
+ const config = {
128
+ searchWords: inputValue,
129
+ sourceString: children,
130
+ option: {
131
+ highlightClassName: "".concat(prefixCls, "-keyword")
132
+ }
133
+ };
134
+ return (
135
+ /*#__PURE__*/
136
+ // eslint-disable-next-line jsx-a11y/interactive-supports-focus,jsx-a11y/click-events-have-key-events
137
+ React.createElement("div", {
138
+ className: optionClassName,
139
+ onClick: e => {
140
+ this.onClick(_Object$assign({
141
+ value,
142
+ label,
143
+ children
144
+ }, rest), e);
145
+ },
146
+ onMouseEnter: e => onMouseEnter && onMouseEnter(e),
147
+ role: "option",
148
+ "aria-selected": selected ? "true" : "false",
149
+ "aria-disabled": disabled ? "true" : "false",
150
+ style: style
151
+ }, showTick ? /*#__PURE__*/React.createElement("div", {
152
+ className: selectedIconClassName
153
+ }, /*#__PURE__*/React.createElement(IconTick, null)) : null, _isString(children) ? /*#__PURE__*/React.createElement("div", {
154
+ className: "".concat(prefixCls, "-text")
155
+ }, this.renderOptionContent({
156
+ children,
157
+ config,
158
+ inputValue,
159
+ prefixCls
160
+ })) : children)
161
+ );
162
+ }
163
+
164
+ }
165
+
166
+ Option.isSelectOption = true;
167
+ Option.propTypes = {
168
+ children: PropTypes.node,
169
+ disabled: PropTypes.bool,
170
+ value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
171
+ selected: PropTypes.bool,
172
+ label: PropTypes.node,
173
+ empty: PropTypes.bool,
174
+ emptyContent: PropTypes.node,
175
+ onSelect: PropTypes.func,
176
+ focused: PropTypes.bool,
177
+ showTick: PropTypes.bool,
178
+ className: PropTypes.string,
179
+ style: PropTypes.object,
180
+ onMouseEnter: PropTypes.func,
181
+ prefixCls: PropTypes.string,
182
+ renderOptionItem: PropTypes.func,
183
+ inputValue: PropTypes.string
184
+ };
185
+ Option.defaultProps = {
186
+ prefixCls: cssClasses.PREFIX_OPTION
187
+ };
188
+ export default Option;