@douyinfe/semi-ui 2.10.2-alpha.0 → 2.11.0-beta.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 (50) hide show
  1. package/checkbox/checkbox.tsx +16 -6
  2. package/datePicker/_story/datePicker.stories.js +48 -1
  3. package/datePicker/_story/v2/AutoFillTime.jsx +37 -0
  4. package/datePicker/_story/v2/InputFormat.jsx +29 -0
  5. package/datePicker/_story/v2/InputFormatConfirm.jsx +44 -0
  6. package/datePicker/_story/v2/InputFormatDisabled.jsx +27 -0
  7. package/datePicker/_story/v2/index.js +4 -0
  8. package/datePicker/dateInput.tsx +7 -0
  9. package/datePicker/datePicker.tsx +7 -11
  10. package/datePicker/monthsGrid.tsx +2 -1
  11. package/dist/css/semi.css +0 -1
  12. package/dist/umd/semi-ui.js +865 -518
  13. package/dist/umd/semi-ui.js.map +1 -1
  14. package/dist/umd/semi-ui.min.js +1 -1
  15. package/dist/umd/semi-ui.min.js.map +1 -1
  16. package/lib/cjs/checkbox/checkbox.d.ts +4 -0
  17. package/lib/cjs/checkbox/checkbox.js +23 -11
  18. package/lib/cjs/datePicker/dateInput.d.ts +1 -0
  19. package/lib/cjs/datePicker/dateInput.js +5 -3
  20. package/lib/cjs/datePicker/datePicker.js +9 -12
  21. package/lib/cjs/datePicker/monthsGrid.js +2 -1
  22. package/lib/cjs/radio/radio.d.ts +4 -0
  23. package/lib/cjs/radio/radio.js +26 -12
  24. package/lib/cjs/table/Body/BaseRow.d.ts +1 -0
  25. package/lib/cjs/table/Body/BaseRow.js +22 -0
  26. package/lib/cjs/tag/group.d.ts +3 -3
  27. package/lib/cjs/tooltip/index.d.ts +1 -0
  28. package/lib/cjs/tooltip/index.js +6 -1
  29. package/lib/es/checkbox/checkbox.d.ts +4 -0
  30. package/lib/es/checkbox/checkbox.js +23 -11
  31. package/lib/es/datePicker/dateInput.d.ts +1 -0
  32. package/lib/es/datePicker/dateInput.js +5 -3
  33. package/lib/es/datePicker/datePicker.js +9 -12
  34. package/lib/es/datePicker/monthsGrid.js +2 -1
  35. package/lib/es/radio/radio.d.ts +4 -0
  36. package/lib/es/radio/radio.js +26 -12
  37. package/lib/es/table/Body/BaseRow.d.ts +1 -0
  38. package/lib/es/table/Body/BaseRow.js +22 -0
  39. package/lib/es/tag/group.d.ts +3 -3
  40. package/lib/es/tooltip/index.d.ts +1 -0
  41. package/lib/es/tooltip/index.js +6 -1
  42. package/package.json +9 -9
  43. package/radio/radio.tsx +17 -7
  44. package/scrollList/_story/ScrollList/index.js +1 -1
  45. package/select/index.tsx +7 -7
  46. package/table/Body/BaseRow.tsx +15 -0
  47. package/tag/group.tsx +4 -4
  48. package/tooltip/index.tsx +5 -1
  49. package/treeSelect/index.tsx +1 -1
  50. package/upload/_story/upload.stories.js +1 -0
@@ -103,6 +103,28 @@ export default class TableRow extends BaseComponent {
103
103
  });
104
104
  }
105
105
 
106
+ componentDidMount() {
107
+ // fix #745
108
+ // didmount/willUnmount may be called twice when React.StrictMode is true in React 18, we need to ensure that this.cache.customRowProps is correct
109
+ const {
110
+ onRow,
111
+ index,
112
+ record
113
+ } = this.props;
114
+ const customRowProps = this.adapter.getCache('customRowProps');
115
+
116
+ if (typeof customRowProps === 'undefined') {
117
+ const _a = onRow(record, index) || {},
118
+ {
119
+ className: customClassName,
120
+ style: customStyle
121
+ } = _a,
122
+ rowProps = __rest(_a, ["className", "style"]);
123
+
124
+ this.adapter.setCache('customRowProps', _Object$assign({}, rowProps));
125
+ }
126
+ }
127
+
106
128
  shouldComponentUpdate(nextProps) {
107
129
  /**
108
130
  * Shallow comparison of incoming props to simulate PureComponent
@@ -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;
@@ -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-ui",
3
- "version": "2.10.2-alpha.0",
3
+ "version": "2.11.0-beta.1",
4
4
  "description": "",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/es/index.js",
@@ -14,12 +14,12 @@
14
14
  },
15
15
  "dependencies": {
16
16
  "@babel/runtime-corejs3": "^7.15.4",
17
- "@douyinfe/semi-animation": "2.10.1",
18
- "@douyinfe/semi-animation-react": "2.10.2-alpha.0",
19
- "@douyinfe/semi-foundation": "2.10.1",
20
- "@douyinfe/semi-icons": "2.10.1",
21
- "@douyinfe/semi-illustrations": "2.10.1",
22
- "@douyinfe/semi-theme-default": "2.10.1",
17
+ "@douyinfe/semi-animation": "2.11.0-beta.1",
18
+ "@douyinfe/semi-animation-react": "2.11.0-beta.1",
19
+ "@douyinfe/semi-foundation": "2.11.0-beta.1",
20
+ "@douyinfe/semi-icons": "2.11.0-beta.1",
21
+ "@douyinfe/semi-illustrations": "2.11.0-beta.1",
22
+ "@douyinfe/semi-theme-default": "2.11.0-beta.1",
23
23
  "@types/react-window": "^1.8.2",
24
24
  "async-validator": "^3.5.0",
25
25
  "classnames": "^2.2.6",
@@ -69,13 +69,13 @@
69
69
  ],
70
70
  "author": "",
71
71
  "license": "MIT",
72
- "gitHead": "0af26368c88d1654b57ca177c18ed1d92b1b8b61",
72
+ "gitHead": "23088cd48e6c894f541e4358d495001e923321fd",
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.1",
78
+ "@douyinfe/semi-scss-compile": "2.11.0-beta.1",
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 ?
@@ -11,7 +11,7 @@ class ScrollListDemo extends React.Component {
11
11
  };
12
12
 
13
13
  this.list = new Array(20).fill(0).map((itm, index) => {
14
- return { value: index, disabled: Math.random() + 0.2 > 1 };
14
+ return { value: index };
15
15
  });
16
16
  }
17
17
 
package/select/index.tsx CHANGED
@@ -446,11 +446,11 @@ class Select extends BaseComponent<SelectProps, SelectState> {
446
446
  let options = [];
447
447
  const { optionList } = this.props;
448
448
  if (optionList && optionList.length) {
449
- options = optionList.map((itemOpt, index) => ({
450
- _show: true,
451
- _selected: false,
449
+ options = optionList.map((itemOpt, index) => ({
450
+ _show: true,
451
+ _selected: false,
452
452
  _scrollIndex: index,
453
- ...itemOpt
453
+ ...itemOpt
454
454
  }));
455
455
  optionGroups[0] = { children: options, label: '' };
456
456
  } else {
@@ -771,7 +771,7 @@ class Select extends BaseComponent<SelectProps, SelectState> {
771
771
  const groupContent = <OptionGroup {...parentGroup} key={parentGroup.label} />;
772
772
  groupStatus.set(parentGroup.label, true);
773
773
  content.push(groupContent);
774
- }
774
+ }
775
775
  content.push(optionContent);
776
776
  });
777
777
 
@@ -899,7 +899,7 @@ class Select extends BaseComponent<SelectProps, SelectState> {
899
899
  content: optionNode.label,
900
900
  });
901
901
  }
902
-
902
+
903
903
  const mapItems = maxTagCount ? selectedItems.slice(0, maxTagCount) : selectedItems; // no need to render rest tag when maxTagCount is setting
904
904
 
905
905
  const tags = mapItems.map((item, i) => {
@@ -946,7 +946,7 @@ class Select extends BaseComponent<SelectProps, SelectState> {
946
946
 
947
947
  const NotOneLine = !maxTagCount; // Multiple lines (that is, do not set maxTagCount), do not use TagGroup, directly traverse with Tag, otherwise Input cannot follow the correct position
948
948
 
949
- const tagContent = NotOneLine ? tags : <TagGroup tagList={tags} maxTagCount={n} restCount={maxTagCount ? selectedItems.length - maxTagCount : undefined} size="large" mode="custom" />;
949
+ const tagContent = NotOneLine ? tags : <TagGroup<"custom"> tagList={tags} maxTagCount={n} restCount={maxTagCount ? selectedItems.length - maxTagCount : undefined} size="large" mode="custom" />;
950
950
 
951
951
  return (
952
952
  <>
@@ -153,6 +153,21 @@ export default class TableRow extends BaseComponent<BaseRowProps, Record<string,
153
153
  this.foundation = new TableRowFoundation(this.adapter);
154
154
  }
155
155
 
156
+ componentDidMount() {
157
+ // fix #745
158
+ // didmount/willUnmount may be called twice when React.StrictMode is true in React 18, we need to ensure that this.cache.customRowProps is correct
159
+ const {
160
+ onRow,
161
+ index,
162
+ record,
163
+ } = this.props;
164
+ const customRowProps = this.adapter.getCache('customRowProps');
165
+ if (typeof customRowProps === 'undefined') {
166
+ const { className: customClassName, style: customStyle, ...rowProps } = onRow(record, index) || {};
167
+ this.adapter.setCache('customRowProps', { ...rowProps });
168
+ }
169
+ }
170
+
156
171
  shouldComponentUpdate(nextProps: BaseRowProps) {
157
172
  /**
158
173
  * Shallow comparison of incoming props to simulate PureComponent
package/tag/group.tsx CHANGED
@@ -10,12 +10,12 @@ const prefixCls = cssClasses.PREFIX;
10
10
  const tagSize = strings.TAG_SIZE;
11
11
  const avatarShapeSet = strings.AVATAR_SHAPE;
12
12
 
13
- export interface TagGroupProps {
13
+ export interface TagGroupProps<T> {
14
14
  style?: React.CSSProperties;
15
15
  className?: string;
16
16
  maxTagCount?: number;
17
17
  restCount?: number;
18
- tagList?: (TagProps | React.ReactNode)[];
18
+ tagList?: (T extends 'custom' ? React.ReactNode : TagProps)[];
19
19
  size?: 'small' | 'large';
20
20
  showPopover?: boolean;
21
21
  popoverProps?: PopoverProps;
@@ -23,7 +23,7 @@ export interface TagGroupProps {
23
23
  mode?: string;
24
24
  }
25
25
 
26
- export default class TagGroup extends PureComponent<TagGroupProps> {
26
+ export default class TagGroup<T> extends PureComponent<TagGroupProps<T>> {
27
27
  static defaultProps = {
28
28
  style: {},
29
29
  className: '',
@@ -84,7 +84,7 @@ export default class TagGroup extends PureComponent<TagGroupProps> {
84
84
  let renderTags: (Tag | React.ReactNode)[] = tags;
85
85
 
86
86
  const normalTags: (Tag | React.ReactNode)[] = tags.slice(0, maxTagCount);
87
- const restTags = tags.slice(maxTagCount) as React.ReactNode;
87
+ const restTags = tags.slice(maxTagCount) as React.ReactNode;
88
88
  let nTag = null;
89
89
  if (n > 0) {
90
90
  nTag = this.renderNTag(n, restTags);
package/tooltip/index.tsx CHANGED
@@ -75,6 +75,7 @@ export interface TooltipProps extends BaseProps {
75
75
  guardFocus?: boolean;
76
76
  returnFocusOnClose?: boolean;
77
77
  onEscKeyDown?: (e: React.KeyboardEvent) => void;
78
+ wrapperId?: string;
78
79
  }
79
80
  interface TooltipState {
80
81
  visible: boolean;
@@ -193,7 +194,7 @@ export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
193
194
  placement: props.position || 'top',
194
195
  transitionStyle: {},
195
196
  isPositionUpdated: false,
196
- id: getUuidShort(), // auto generate id, will be used by children.aria-describedby & content.id, improve a11y
197
+ id: props.wrapperId, // auto generate id, will be used by children.aria-describedby & content.id, improve a11y
197
198
  };
198
199
  this.foundation = new TooltipFoundation(this.adapter);
199
200
  this.eventManager = new Event();
@@ -428,6 +429,9 @@ export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
428
429
  },
429
430
  notifyEscKeydown: (event: React.KeyboardEvent) => {
430
431
  this.props.onEscKeyDown(event);
432
+ },
433
+ setId: () => {
434
+ this.setState({ id: getUuidShort() });
431
435
  }
432
436
  };
433
437
  }
@@ -826,7 +826,7 @@ class TreeSelect extends BaseComponent<TreeSelectProps, TreeSelectState> {
826
826
  const tagList = this.renderTagList();
827
827
  // mode=custom to return tagList directly
828
828
  return (
829
- <TagGroup
829
+ <TagGroup<'custom'>
830
830
  maxTagCount={maxTagCount}
831
831
  tagList={tagList}
832
832
  size="large"
@@ -581,6 +581,7 @@ export const Draggable = () => (
581
581
  <Upload
582
582
  {...commonProps}
583
583
  style={{ marginTop: 10, height: 300 }}
584
+ // directory
584
585
  draggable={true}
585
586
  dragMainText={'点击上传文件或拖拽文件到这里'}
586
587
  ></Upload>