@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/checkbox/checkbox.tsx +1 -3
- package/checkbox/checkboxInner.tsx +19 -14
- package/dist/css/semi.css +1 -0
- package/dist/umd/semi-ui.js +381 -349
- package/dist/umd/semi-ui.js.map +1 -1
- package/dist/umd/semi-ui.min.js +1 -1
- package/dist/umd/semi-ui.min.js.map +1 -1
- package/form/baseForm.tsx +0 -1
- package/lib/cjs/checkbox/checkbox.js +1 -2
- package/lib/cjs/checkbox/checkboxInner.js +21 -17
- package/lib/cjs/form/baseForm.d.ts +1 -1
- package/lib/cjs/form/baseForm.js +0 -1
- package/lib/cjs/form/field.d.ts +1 -1
- package/lib/cjs/table/Body/BaseRow.d.ts +1 -0
- package/lib/cjs/table/Body/BaseRow.js +22 -0
- package/lib/cjs/tooltip/index.d.ts +1 -0
- package/lib/cjs/tooltip/index.js +9 -6
- package/lib/cjs/typography/title.d.ts +1 -1
- package/lib/es/checkbox/checkbox.js +1 -2
- package/lib/es/checkbox/checkboxInner.js +20 -17
- package/lib/es/form/baseForm.d.ts +1 -1
- package/lib/es/form/baseForm.js +0 -1
- package/lib/es/form/field.d.ts +1 -1
- package/lib/es/table/Body/BaseRow.d.ts +1 -0
- package/lib/es/table/Body/BaseRow.js +22 -0
- package/lib/es/tooltip/index.d.ts +1 -0
- package/lib/es/tooltip/index.js +9 -6
- package/lib/es/typography/title.d.ts +1 -1
- package/package.json +9 -9
- package/popover/_story/popover.stories.js +38 -2
- package/table/Body/BaseRow.tsx +15 -0
- package/tooltip/index.tsx +9 -2
package/form/baseForm.tsx
CHANGED
|
@@ -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
|
-
|
|
67
|
-
className: wrapper
|
|
68
|
-
}, /*#__PURE__*/_react.default.createElement("input", {
|
|
68
|
+
const inputProps = {
|
|
69
69
|
type: "checkbox",
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
-
|
|
86
|
-
|
|
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, "
|
|
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>;
|
package/lib/cjs/form/baseForm.js
CHANGED
package/lib/cjs/form/field.d.ts
CHANGED
|
@@ -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, "
|
|
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;
|
package/lib/cjs/tooltip/index.js
CHANGED
|
@@ -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
|
-
|
|
502
|
-
capture: true
|
|
503
|
-
});
|
|
508
|
+
window.addEventListener('mousedown', this.clickOutsideHandler);
|
|
504
509
|
},
|
|
505
510
|
unregisterClickOutsideHandler: () => {
|
|
506
511
|
if (this.clickOutsideHandler) {
|
|
507
|
-
|
|
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<
|
|
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
|
-
|
|
42
|
-
className: wrapper
|
|
43
|
-
}, /*#__PURE__*/React.createElement("input", {
|
|
42
|
+
const inputProps = {
|
|
44
43
|
type: "checkbox",
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
|
|
61
|
-
|
|
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, "
|
|
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>;
|
package/lib/es/form/baseForm.js
CHANGED
package/lib/es/form/field.d.ts
CHANGED
|
@@ -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, "
|
|
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;
|
package/lib/es/tooltip/index.js
CHANGED
|
@@ -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
|
-
|
|
461
|
-
capture: true
|
|
462
|
-
});
|
|
467
|
+
window.addEventListener('mousedown', this.clickOutsideHandler);
|
|
463
468
|
},
|
|
464
469
|
unregisterClickOutsideHandler: () => {
|
|
465
470
|
if (this.clickOutsideHandler) {
|
|
466
|
-
|
|
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<
|
|
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.
|
|
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.
|
|
18
|
-
"@douyinfe/semi-animation-react": "2.10.0",
|
|
19
|
-
"@douyinfe/semi-foundation": "2.10.
|
|
20
|
-
"@douyinfe/semi-icons": "2.10.
|
|
21
|
-
"@douyinfe/semi-illustrations": "2.10.
|
|
22
|
-
"@douyinfe/semi-theme-default": "2.10.
|
|
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": "
|
|
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.
|
|
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
|
+
}
|
package/table/Body/BaseRow.tsx
CHANGED
|
@@ -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
|
-
|
|
346
|
+
window.addEventListener('mousedown', this.clickOutsideHandler);
|
|
347
347
|
},
|
|
348
348
|
unregisterClickOutsideHandler: () => {
|
|
349
349
|
if (this.clickOutsideHandler) {
|
|
350
|
-
|
|
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}
|