@douyinfe/semi-ui 2.10.0 → 2.10.2-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.
package/form/baseForm.tsx CHANGED
@@ -151,7 +151,6 @@ class Form extends BaseComponent<BaseFormProps, BaseFormState> {
151
151
 
152
152
  componentWillUnmount() {
153
153
  this.foundation.destroy();
154
- this.foundation = null;
155
154
  this.formApi = null;
156
155
  }
157
156
 
@@ -150,6 +150,7 @@ class Checkbox extends _baseComponent.default {
150
150
  } = this.context.checkboxGroup;
151
151
  props.isCardType = isCardType;
152
152
  props.isPureCardType = isPureCardType;
153
+ props['name'] = this.context.checkboxGroup.name;
153
154
  }
154
155
 
155
156
  const prefix = prefixCls || _constants.checkboxClasses.PREFIX;
@@ -168,7 +169,6 @@ class Checkbox extends _baseComponent.default {
168
169
  const extraCls = (0, _classnames.default)("".concat(prefix, "-extra"), {
169
170
  ["".concat(prefix, "-cardType_extra_noChildren")]: props.isCardType && !children
170
171
  });
171
- const name = inGroup && this.context.checkboxGroup.name;
172
172
 
173
173
  const renderContent = () => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children ? /*#__PURE__*/_react.default.createElement("span", {
174
174
  id: this.addonId,
@@ -196,7 +196,6 @@ class Checkbox extends _baseComponent.default {
196
196
  }, /*#__PURE__*/_react.default.createElement(_checkboxInner.default, (0, _assign.default)({}, this.props, props, {
197
197
  addonId: children && this.addonId,
198
198
  extraId: extra && this.extraId,
199
- name: name,
200
199
  isPureCardType: props.isPureCardType,
201
200
  ref: ref => {
202
201
  this.checkboxEntity = ref;
@@ -14,6 +14,8 @@ _Object$defineProperty(exports, "__esModule", {
14
14
 
15
15
  exports.default = void 0;
16
16
 
17
+ var _assign = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/assign"));
18
+
17
19
  var _noop2 = _interopRequireDefault(require("lodash/noop"));
18
20
 
19
21
  var _react = _interopRequireWildcard(require("react"));
@@ -63,27 +65,29 @@ class CheckboxInner extends _react.PureComponent {
63
65
  ["".concat(prefix, "-inner-display")]: true
64
66
  });
65
67
  const icon = checked ? /*#__PURE__*/_react.default.createElement(_semiIcons.IconCheckboxTick, null) : indeterminate ? /*#__PURE__*/_react.default.createElement(_semiIcons.IconCheckboxIndeterminate, null) : null;
66
- return /*#__PURE__*/_react.default.createElement("span", {
67
- className: wrapper
68
- }, /*#__PURE__*/_react.default.createElement("input", {
68
+ const inputProps = {
69
69
  type: "checkbox",
70
- "aria-label": this.props['aria-label'],
71
- "aria-disabled": disabled,
72
- "aria-checked": checked,
73
- "aria-labelledby": addonId,
74
- "aria-describedby": extraId || this.props['aria-describedby'],
75
- "aria-invalid": this.props['aria-invalid'],
76
- "aria-errormessage": this.props['aria-errormessage'],
77
- "aria-required": this.props['aria-required'],
78
- ref: ref => {
79
- this.inputEntity = ref;
80
- },
70
+ 'aria-label': this.props['aria-label'],
71
+ 'aria-disabled': disabled,
72
+ 'aria-checked': checked,
73
+ 'aria-labelledby': addonId,
74
+ 'aria-describedby': extraId || this.props['aria-describedby'],
75
+ 'aria-invalid': this.props['aria-invalid'],
76
+ 'aria-errormessage': this.props['aria-errormessage'],
77
+ 'aria-required': this.props['aria-required'],
81
78
  className: _constants.checkboxClasses.INPUT,
82
79
  onChange: _noop2.default,
83
80
  checked: checked,
84
- disabled: disabled,
85
- name: name
86
- }), /*#__PURE__*/_react.default.createElement("span", {
81
+ disabled: disabled
82
+ };
83
+ name && (inputProps['name'] = name);
84
+ return /*#__PURE__*/_react.default.createElement("span", {
85
+ className: wrapper
86
+ }, /*#__PURE__*/_react.default.createElement("input", (0, _assign.default)({}, inputProps, {
87
+ ref: ref => {
88
+ this.inputEntity = ref;
89
+ }
90
+ })), /*#__PURE__*/_react.default.createElement("span", {
87
91
  className: inner
88
92
  }, icon));
89
93
  }
@@ -125,7 +125,7 @@ declare class Form extends BaseComponent<BaseFormProps, BaseFormState> {
125
125
  onBlur?: (e: React.FocusEvent<Element, Element>) => void;
126
126
  onListScroll?: (e: React.UIEvent<HTMLDivElement, UIEvent>) => void;
127
127
  children?: React.ReactNode;
128
- } & Pick<import("../tooltip").TooltipProps, "stopPropagation" | "getPopupContainer" | "spacing" | "mouseEnterDelay" | "autoAdjustOverflow" | "mouseLeaveDelay" | "motion"> & React.RefAttributes<any> & import("./interface").CommonFieldProps, import("./interface").CommonexcludeType>> & import("./interface").SelectStatic;
128
+ } & Pick<import("../tooltip").TooltipProps, "getPopupContainer" | "stopPropagation" | "spacing" | "mouseEnterDelay" | "autoAdjustOverflow" | "mouseLeaveDelay" | "motion"> & React.RefAttributes<any> & import("./interface").CommonFieldProps, import("./interface").CommonexcludeType>> & import("./interface").SelectStatic;
129
129
  static Checkbox: React.ComponentType<import("utility-types").Subtract<import("./interface").CommonFieldProps, import("./interface").RadioCheckboxExcludeProps> & import("../checkbox").CheckboxProps & import("./interface").RCIncludeType>;
130
130
  static CheckboxGroup: React.ComponentType<import("utility-types").Subtract<import("../checkbox").CheckboxGroupProps, import("./interface").CommonexcludeType> & import("./interface").CommonFieldProps>;
131
131
  static Radio: React.ComponentType<import("utility-types").Subtract<import("./interface").CommonFieldProps, import("./interface").RadioCheckboxExcludeProps> & import("../radio").RadioProps & import("./interface").RCIncludeType>;
@@ -106,7 +106,6 @@ class Form extends _baseComponent.default {
106
106
 
107
107
  componentWillUnmount() {
108
108
  this.foundation.destroy();
109
- this.foundation = null;
110
109
  this.formApi = null;
111
110
  }
112
111
 
@@ -73,7 +73,7 @@ declare const FormSelect: import("react").ComponentType<import("utility-types").
73
73
  onBlur?: (e: import("react").FocusEvent<Element, Element>) => void;
74
74
  onListScroll?: (e: import("react").UIEvent<HTMLDivElement, UIEvent>) => void;
75
75
  children?: import("react").ReactNode;
76
- } & Pick<import("../tooltip").TooltipProps, "stopPropagation" | "getPopupContainer" | "spacing" | "mouseEnterDelay" | "autoAdjustOverflow" | "mouseLeaveDelay" | "motion"> & import("react").RefAttributes<any> & import("./interface").CommonFieldProps, import("./interface").CommonexcludeType>> & import("./interface").SelectStatic;
76
+ } & Pick<import("../tooltip").TooltipProps, "getPopupContainer" | "stopPropagation" | "spacing" | "mouseEnterDelay" | "autoAdjustOverflow" | "mouseLeaveDelay" | "motion"> & import("react").RefAttributes<any> & import("./interface").CommonFieldProps, import("./interface").CommonexcludeType>> & import("./interface").SelectStatic;
77
77
  declare const FormCheckboxGroup: import("react").ComponentType<import("utility-types").Subtract<import("../checkbox/checkboxGroup").CheckboxGroupProps, import("./interface").CommonexcludeType> & import("./interface").CommonFieldProps>;
78
78
  declare const FormCheckbox: import("react").ComponentType<import("utility-types").Subtract<import("./interface").CommonFieldProps, import("./interface").RadioCheckboxExcludeProps> & import("../checkbox/checkbox").CheckboxProps & import("./interface").RCIncludeType>;
79
79
  declare const FormRadioGroup: import("react").ComponentType<import("utility-types").Subtract<import("../radio/radioGroup").RadioGroupProps, import("./interface").CommonexcludeType> & import("./interface").CommonFieldProps>;
@@ -113,6 +113,7 @@ export default class TableRow extends BaseComponent<BaseRowProps, Record<string,
113
113
  get adapter(): TableRowAdapter<BaseRowProps>;
114
114
  ref: React.MutableRefObject<any>;
115
115
  constructor(props: BaseRowProps);
116
+ componentDidMount(): void;
116
117
  shouldComponentUpdate(nextProps: BaseRowProps): boolean;
117
118
  _cacheNode: (node: any) => void;
118
119
  renderExpandIcon: (record: Record<string, any>) => React.ReactNode;
@@ -141,6 +141,28 @@ class TableRow extends _baseComponent.default {
141
141
  });
142
142
  }
143
143
 
144
+ componentDidMount() {
145
+ // fix #745
146
+ // didmount/willUnmount may be called twice when React.StrictMode is true in React 18, we need to ensure that this.cache.customRowProps is correct
147
+ const {
148
+ onRow,
149
+ index,
150
+ record
151
+ } = this.props;
152
+ const customRowProps = this.adapter.getCache('customRowProps');
153
+
154
+ if (typeof customRowProps === 'undefined') {
155
+ const _a = onRow(record, index) || {},
156
+ {
157
+ className: customClassName,
158
+ style: customStyle
159
+ } = _a,
160
+ rowProps = __rest(_a, ["className", "style"]);
161
+
162
+ this.adapter.setCache('customRowProps', (0, _assign.default)({}, rowProps));
163
+ }
164
+ }
165
+
144
166
  shouldComponentUpdate(nextProps) {
145
167
  /**
146
168
  * Shallow comparison of incoming props to simulate PureComponent
@@ -164,6 +164,7 @@ export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
164
164
  componentDidUpdate(prevProps: TooltipProps, prevState: TooltipState): void;
165
165
  renderIcon: () => any;
166
166
  handlePortalInnerClick: (e: React.MouseEvent) => void;
167
+ handlePortalMouseDown: (e: React.MouseEvent) => void;
167
168
  handlePortalInnerKeyDown: (e: React.KeyboardEvent) => void;
168
169
  renderContentNode: (content: TooltipProps['content']) => React.ReactNode;
169
170
  renderPortal: () => JSX.Element;
@@ -187,6 +187,12 @@ class Tooltip extends _baseComponent.default {
187
187
  }
188
188
  };
189
189
 
190
+ this.handlePortalMouseDown = e => {
191
+ if (this.props.stopPropagation) {
192
+ (0, _utils.stopPropagation)(e);
193
+ }
194
+ };
195
+
190
196
  this.handlePortalInnerKeyDown = e => {
191
197
  this.foundation.handleContainerKeydown(e);
192
198
  };
@@ -271,6 +277,7 @@ class Tooltip extends _baseComponent.default {
271
277
  style: portalInnerStyle,
272
278
  ref: this.setContainerEl,
273
279
  onClick: this.handlePortalInnerClick,
280
+ onMouseDown: this.handlePortalMouseDown,
274
281
  onKeyDown: this.handlePortalInnerKeyDown
275
282
  }, inner));
276
283
  };
@@ -498,15 +505,11 @@ class Tooltip extends _baseComponent.default {
498
505
  }
499
506
  };
500
507
 
501
- document.addEventListener('mousedown', this.clickOutsideHandler, {
502
- capture: true
503
- });
508
+ window.addEventListener('mousedown', this.clickOutsideHandler);
504
509
  },
505
510
  unregisterClickOutsideHandler: () => {
506
511
  if (this.clickOutsideHandler) {
507
- document.removeEventListener('mousedown', this.clickOutsideHandler, {
508
- capture: true
509
- });
512
+ window.removeEventListener('mousedown', this.clickOutsideHandler);
510
513
  this.clickOutsideHandler = null;
511
514
  }
512
515
  },
@@ -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>;
@@ -126,6 +126,7 @@ class Checkbox extends BaseComponent {
126
126
  } = this.context.checkboxGroup;
127
127
  props.isCardType = isCardType;
128
128
  props.isPureCardType = isPureCardType;
129
+ props['name'] = this.context.checkboxGroup.name;
129
130
  }
130
131
 
131
132
  const prefix = prefixCls || css.PREFIX;
@@ -144,7 +145,6 @@ class Checkbox extends BaseComponent {
144
145
  const extraCls = classnames("".concat(prefix, "-extra"), {
145
146
  ["".concat(prefix, "-cardType_extra_noChildren")]: props.isCardType && !children
146
147
  });
147
- const name = inGroup && this.context.checkboxGroup.name;
148
148
 
149
149
  const renderContent = () => /*#__PURE__*/React.createElement(React.Fragment, null, children ? /*#__PURE__*/React.createElement("span", {
150
150
  id: this.addonId,
@@ -172,7 +172,6 @@ class Checkbox extends BaseComponent {
172
172
  }, /*#__PURE__*/React.createElement(CheckboxInner, _Object$assign({}, this.props, props, {
173
173
  addonId: children && this.addonId,
174
174
  extraId: extra && this.extraId,
175
- name: name,
176
175
  isPureCardType: props.isPureCardType,
177
176
  ref: ref => {
178
177
  this.checkboxEntity = ref;
@@ -1,4 +1,5 @@
1
1
  import _noop from "lodash/noop";
2
+ import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
2
3
 
3
4
  /* eslint-disable no-nested-ternary */
4
5
  import React, { PureComponent } from 'react';
@@ -38,27 +39,29 @@ class CheckboxInner extends PureComponent {
38
39
  ["".concat(prefix, "-inner-display")]: true
39
40
  });
40
41
  const icon = checked ? /*#__PURE__*/React.createElement(IconCheckboxTick, null) : indeterminate ? /*#__PURE__*/React.createElement(IconCheckboxIndeterminate, null) : null;
41
- return /*#__PURE__*/React.createElement("span", {
42
- className: wrapper
43
- }, /*#__PURE__*/React.createElement("input", {
42
+ const inputProps = {
44
43
  type: "checkbox",
45
- "aria-label": this.props['aria-label'],
46
- "aria-disabled": disabled,
47
- "aria-checked": checked,
48
- "aria-labelledby": addonId,
49
- "aria-describedby": extraId || this.props['aria-describedby'],
50
- "aria-invalid": this.props['aria-invalid'],
51
- "aria-errormessage": this.props['aria-errormessage'],
52
- "aria-required": this.props['aria-required'],
53
- ref: ref => {
54
- this.inputEntity = ref;
55
- },
44
+ 'aria-label': this.props['aria-label'],
45
+ 'aria-disabled': disabled,
46
+ 'aria-checked': checked,
47
+ 'aria-labelledby': addonId,
48
+ 'aria-describedby': extraId || this.props['aria-describedby'],
49
+ 'aria-invalid': this.props['aria-invalid'],
50
+ 'aria-errormessage': this.props['aria-errormessage'],
51
+ 'aria-required': this.props['aria-required'],
56
52
  className: css.INPUT,
57
53
  onChange: _noop,
58
54
  checked: checked,
59
- disabled: disabled,
60
- name: name
61
- }), /*#__PURE__*/React.createElement("span", {
55
+ disabled: disabled
56
+ };
57
+ name && (inputProps['name'] = name);
58
+ return /*#__PURE__*/React.createElement("span", {
59
+ className: wrapper
60
+ }, /*#__PURE__*/React.createElement("input", _Object$assign({}, inputProps, {
61
+ ref: ref => {
62
+ this.inputEntity = ref;
63
+ }
64
+ })), /*#__PURE__*/React.createElement("span", {
62
65
  className: inner
63
66
  }, icon));
64
67
  }
@@ -125,7 +125,7 @@ declare class Form extends BaseComponent<BaseFormProps, BaseFormState> {
125
125
  onBlur?: (e: React.FocusEvent<Element, Element>) => void;
126
126
  onListScroll?: (e: React.UIEvent<HTMLDivElement, UIEvent>) => void;
127
127
  children?: React.ReactNode;
128
- } & Pick<import("../tooltip").TooltipProps, "stopPropagation" | "getPopupContainer" | "spacing" | "mouseEnterDelay" | "autoAdjustOverflow" | "mouseLeaveDelay" | "motion"> & React.RefAttributes<any> & import("./interface").CommonFieldProps, import("./interface").CommonexcludeType>> & import("./interface").SelectStatic;
128
+ } & Pick<import("../tooltip").TooltipProps, "getPopupContainer" | "stopPropagation" | "spacing" | "mouseEnterDelay" | "autoAdjustOverflow" | "mouseLeaveDelay" | "motion"> & React.RefAttributes<any> & import("./interface").CommonFieldProps, import("./interface").CommonexcludeType>> & import("./interface").SelectStatic;
129
129
  static Checkbox: React.ComponentType<import("utility-types").Subtract<import("./interface").CommonFieldProps, import("./interface").RadioCheckboxExcludeProps> & import("../checkbox").CheckboxProps & import("./interface").RCIncludeType>;
130
130
  static CheckboxGroup: React.ComponentType<import("utility-types").Subtract<import("../checkbox").CheckboxGroupProps, import("./interface").CommonexcludeType> & import("./interface").CommonFieldProps>;
131
131
  static Radio: React.ComponentType<import("utility-types").Subtract<import("./interface").CommonFieldProps, import("./interface").RadioCheckboxExcludeProps> & import("../radio").RadioProps & import("./interface").RCIncludeType>;
@@ -68,7 +68,6 @@ class Form extends BaseComponent {
68
68
 
69
69
  componentWillUnmount() {
70
70
  this.foundation.destroy();
71
- this.foundation = null;
72
71
  this.formApi = null;
73
72
  }
74
73
 
@@ -73,7 +73,7 @@ declare const FormSelect: import("react").ComponentType<import("utility-types").
73
73
  onBlur?: (e: import("react").FocusEvent<Element, Element>) => void;
74
74
  onListScroll?: (e: import("react").UIEvent<HTMLDivElement, UIEvent>) => void;
75
75
  children?: import("react").ReactNode;
76
- } & Pick<import("../tooltip").TooltipProps, "stopPropagation" | "getPopupContainer" | "spacing" | "mouseEnterDelay" | "autoAdjustOverflow" | "mouseLeaveDelay" | "motion"> & import("react").RefAttributes<any> & import("./interface").CommonFieldProps, import("./interface").CommonexcludeType>> & import("./interface").SelectStatic;
76
+ } & Pick<import("../tooltip").TooltipProps, "getPopupContainer" | "stopPropagation" | "spacing" | "mouseEnterDelay" | "autoAdjustOverflow" | "mouseLeaveDelay" | "motion"> & import("react").RefAttributes<any> & import("./interface").CommonFieldProps, import("./interface").CommonexcludeType>> & import("./interface").SelectStatic;
77
77
  declare const FormCheckboxGroup: import("react").ComponentType<import("utility-types").Subtract<import("../checkbox/checkboxGroup").CheckboxGroupProps, import("./interface").CommonexcludeType> & import("./interface").CommonFieldProps>;
78
78
  declare const FormCheckbox: import("react").ComponentType<import("utility-types").Subtract<import("./interface").CommonFieldProps, import("./interface").RadioCheckboxExcludeProps> & import("../checkbox/checkbox").CheckboxProps & import("./interface").RCIncludeType>;
79
79
  declare const FormRadioGroup: import("react").ComponentType<import("utility-types").Subtract<import("../radio/radioGroup").RadioGroupProps, import("./interface").CommonexcludeType> & import("./interface").CommonFieldProps>;
@@ -113,6 +113,7 @@ export default class TableRow extends BaseComponent<BaseRowProps, Record<string,
113
113
  get adapter(): TableRowAdapter<BaseRowProps>;
114
114
  ref: React.MutableRefObject<any>;
115
115
  constructor(props: BaseRowProps);
116
+ componentDidMount(): void;
116
117
  shouldComponentUpdate(nextProps: BaseRowProps): boolean;
117
118
  _cacheNode: (node: any) => void;
118
119
  renderExpandIcon: (record: Record<string, any>) => React.ReactNode;
@@ -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
@@ -164,6 +164,7 @@ export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
164
164
  componentDidUpdate(prevProps: TooltipProps, prevState: TooltipState): void;
165
165
  renderIcon: () => any;
166
166
  handlePortalInnerClick: (e: React.MouseEvent) => void;
167
+ handlePortalMouseDown: (e: React.MouseEvent) => void;
167
168
  handlePortalInnerKeyDown: (e: React.KeyboardEvent) => void;
168
169
  renderContentNode: (content: TooltipProps['content']) => React.ReactNode;
169
170
  renderPortal: () => JSX.Element;
@@ -138,6 +138,12 @@ export default class Tooltip extends BaseComponent {
138
138
  }
139
139
  };
140
140
 
141
+ this.handlePortalMouseDown = e => {
142
+ if (this.props.stopPropagation) {
143
+ stopPropagation(e);
144
+ }
145
+ };
146
+
141
147
  this.handlePortalInnerKeyDown = e => {
142
148
  this.foundation.handleContainerKeydown(e);
143
149
  };
@@ -225,6 +231,7 @@ export default class Tooltip extends BaseComponent {
225
231
  style: portalInnerStyle,
226
232
  ref: this.setContainerEl,
227
233
  onClick: this.handlePortalInnerClick,
234
+ onMouseDown: this.handlePortalMouseDown,
228
235
  onKeyDown: this.handlePortalInnerKeyDown
229
236
  }, inner));
230
237
  };
@@ -457,15 +464,11 @@ export default class Tooltip extends BaseComponent {
457
464
  }
458
465
  };
459
466
 
460
- document.addEventListener('mousedown', this.clickOutsideHandler, {
461
- capture: true
462
- });
467
+ window.addEventListener('mousedown', this.clickOutsideHandler);
463
468
  },
464
469
  unregisterClickOutsideHandler: () => {
465
470
  if (this.clickOutsideHandler) {
466
- document.removeEventListener('mousedown', this.clickOutsideHandler, {
467
- capture: true
468
- });
471
+ window.removeEventListener('mousedown', this.clickOutsideHandler);
469
472
  this.clickOutsideHandler = null;
470
473
  }
471
474
  },
@@ -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>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-ui",
3
- "version": "2.10.0",
3
+ "version": "2.10.2-alpha.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.0",
18
- "@douyinfe/semi-animation-react": "2.10.0",
19
- "@douyinfe/semi-foundation": "2.10.0",
20
- "@douyinfe/semi-icons": "2.10.0",
21
- "@douyinfe/semi-illustrations": "2.10.0",
22
- "@douyinfe/semi-theme-default": "2.10.0",
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",
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": "0cbe3b9873aa550afa2eda0997eaa7015983fe0d",
72
+ "gitHead": "f3c92123d53b7b67e6d89b8c858793c2b5c30256",
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.0",
78
+ "@douyinfe/semi-scss-compile": "2.10.1",
79
79
  "@storybook/addon-knobs": "^6.3.1",
80
80
  "@types/lodash": "^4.14.176",
81
81
  "babel-loader": "^8.2.2",
@@ -2,7 +2,7 @@ import React, { useState } from 'react';
2
2
 
3
3
  import Popover from '../index';
4
4
  import { strings } from '@douyinfe/semi-foundation/tooltip/constants';
5
- import { Button, Input, Table, IconButton, Modal, Tag, Space } from '@douyinfe/semi-ui';
5
+ import { Button, Input, Table, IconButton, Modal, Tag, Space, Select } from '@douyinfe/semi-ui';
6
6
  import SelectInPopover from './SelectInPopover';
7
7
  import BtnClose from './BtnClose';
8
8
  import PopRight from './PopRight';
@@ -10,6 +10,8 @@ import NestedPopover from './NestedPopover';
10
10
  import ArrowPointAtCenter from './ArrowPointAtCenter';
11
11
  import { IconDelete } from '@douyinfe/semi-icons';
12
12
 
13
+ const Option = Select.Option;
14
+
13
15
  export default {
14
16
  title: 'Popover',
15
17
  parameters: {
@@ -645,4 +647,38 @@ export const A11yKeyboard = () => {
645
647
  </div>
646
648
  );
647
649
  };
648
- A11yKeyboard.storyName = "a11y keyboard and focus";
650
+ A11yKeyboard.storyName = "a11y keyboard and focus";
651
+
652
+ /**
653
+ * fix 嵌套 popover 的弹出层会导致外部 popover 关闭问题
654
+ *
655
+ * @see https://github.com/DouyinFE/semi-design/issues/818
656
+ * @see https://github.com/facebook/react/issues/4335#issuecomment-421705171
657
+ */
658
+ export const FixNestedPopover = () => {
659
+ return (
660
+ <div data-cy="fix-nested-popover" style={{ paddingLeft: 100 }}>
661
+ <Popover
662
+ content={(
663
+ <div data-cy="select-in-popover" style={{ padding: 20 }}>
664
+ <Select
665
+ defaultValue="abc"
666
+ style={{ width: 120 }}
667
+ >
668
+ <Option value="abc">抖音</Option>
669
+ <Option value="hotsoon">火山</Option>
670
+ <Option value="pipixia" disabled>
671
+ 皮皮虾
672
+ </Option>
673
+ <Option value="xigua">西瓜视频</Option>
674
+ </Select>
675
+ </div>
676
+ )}
677
+ trigger="click"
678
+ showArrow
679
+ >
680
+ <Tag>点击此处</Tag>
681
+ </Popover>
682
+ </div>
683
+ );
684
+ }
@@ -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/tooltip/index.tsx CHANGED
@@ -343,11 +343,11 @@ export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
343
343
  cb();
344
344
  }
345
345
  };
346
- document.addEventListener('mousedown', this.clickOutsideHandler, { capture: true });
346
+ window.addEventListener('mousedown', this.clickOutsideHandler);
347
347
  },
348
348
  unregisterClickOutsideHandler: () => {
349
349
  if (this.clickOutsideHandler) {
350
- document.removeEventListener('mousedown', this.clickOutsideHandler, { capture: true });
350
+ window.removeEventListener('mousedown', this.clickOutsideHandler);
351
351
  this.clickOutsideHandler = null;
352
352
  }
353
353
  },
@@ -528,6 +528,12 @@ export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
528
528
  }
529
529
  };
530
530
 
531
+ handlePortalMouseDown = (e: React.MouseEvent) => {
532
+ if (this.props.stopPropagation) {
533
+ stopPropagation(e);
534
+ }
535
+ }
536
+
531
537
  handlePortalInnerKeyDown = (e: React.KeyboardEvent) => {
532
538
  this.foundation.handleContainerKeydown(e);
533
539
  }
@@ -595,6 +601,7 @@ export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
595
601
  style={portalInnerStyle}
596
602
  ref={this.setContainerEl}
597
603
  onClick={this.handlePortalInnerClick}
604
+ onMouseDown={this.handlePortalMouseDown}
598
605
  onKeyDown={this.handlePortalInnerKeyDown}
599
606
  >
600
607
  {inner}