@douyinfe/semi-ui 2.27.1 → 2.27.2
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/dist/umd/semi-ui.js +238 -224
- 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/lib/cjs/_portal/index.d.ts +3 -2
- package/lib/cjs/_portal/index.js +42 -28
- package/lib/es/_portal/index.d.ts +3 -2
- package/lib/es/_portal/index.js +42 -28
- package/package.json +8 -8
|
@@ -27,12 +27,13 @@ declare class Portal extends PureComponent<PortalProps, PortalState> {
|
|
|
27
27
|
};
|
|
28
28
|
el: HTMLElement;
|
|
29
29
|
context: ContextValue;
|
|
30
|
-
constructor(props: PortalProps);
|
|
30
|
+
constructor(props: PortalProps, context: ContextValue);
|
|
31
31
|
componentDidMount(): void;
|
|
32
|
+
initContainer: (context: ContextValue, catchError?: boolean) => HTMLElement;
|
|
32
33
|
componentDidUpdate(prevProps: PortalProps): void;
|
|
33
34
|
componentWillUnmount(): void;
|
|
34
35
|
addStyle: (style?: {}) => void;
|
|
35
|
-
addClass: (prefixCls: string, ...classNames: string[]) => void;
|
|
36
|
+
addClass: (prefixCls: string, context?: ContextValue, ...classNames: string[]) => void;
|
|
36
37
|
render(): React.ReactPortal;
|
|
37
38
|
}
|
|
38
39
|
export default Portal;
|
package/lib/cjs/_portal/index.js
CHANGED
|
@@ -24,12 +24,46 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
24
24
|
const defaultGetContainer = () => document.body;
|
|
25
25
|
|
|
26
26
|
class Portal extends _react.PureComponent {
|
|
27
|
-
constructor(props) {
|
|
27
|
+
constructor(props, context) {
|
|
28
28
|
var _this;
|
|
29
29
|
|
|
30
30
|
super(props);
|
|
31
31
|
_this = this;
|
|
32
32
|
|
|
33
|
+
this.initContainer = function (context) {
|
|
34
|
+
let catchError = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
35
|
+
|
|
36
|
+
var _a, _b;
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
let container = undefined;
|
|
40
|
+
|
|
41
|
+
if (!_this.el) {
|
|
42
|
+
_this.el = document.createElement('div');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (!((_a = _this.state) === null || _a === void 0 ? void 0 : _a.container)) {
|
|
46
|
+
_this.el = document.createElement('div');
|
|
47
|
+
const getContainer = _this.props.getPopupContainer || context.getPopupContainer || defaultGetContainer;
|
|
48
|
+
const portalContainer = getContainer();
|
|
49
|
+
portalContainer.appendChild(_this.el);
|
|
50
|
+
|
|
51
|
+
_this.addStyle(_this.props.style);
|
|
52
|
+
|
|
53
|
+
_this.addClass(_this.props.prefixCls, context, _this.props.className);
|
|
54
|
+
|
|
55
|
+
container = portalContainer;
|
|
56
|
+
return container;
|
|
57
|
+
}
|
|
58
|
+
} catch (e) {
|
|
59
|
+
if (!catchError) {
|
|
60
|
+
throw e;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return (_b = _this.state) === null || _b === void 0 ? void 0 : _b.container;
|
|
65
|
+
};
|
|
66
|
+
|
|
33
67
|
this.addStyle = function () {
|
|
34
68
|
let style = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
35
69
|
|
|
@@ -41,12 +75,13 @@ class Portal extends _react.PureComponent {
|
|
|
41
75
|
};
|
|
42
76
|
|
|
43
77
|
this.addClass = function (prefixCls) {
|
|
78
|
+
let context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _this.context;
|
|
44
79
|
const {
|
|
45
80
|
direction
|
|
46
|
-
} =
|
|
81
|
+
} = context;
|
|
47
82
|
|
|
48
|
-
for (var _len = arguments.length, classNames = new Array(_len >
|
|
49
|
-
classNames[_key -
|
|
83
|
+
for (var _len = arguments.length, classNames = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
84
|
+
classNames[_key - 2] = arguments[_key];
|
|
50
85
|
}
|
|
51
86
|
|
|
52
87
|
const cls = (0, _classnames.default)(prefixCls, ...classNames, {
|
|
@@ -58,36 +93,15 @@ class Portal extends _react.PureComponent {
|
|
|
58
93
|
}
|
|
59
94
|
};
|
|
60
95
|
|
|
61
|
-
try {
|
|
62
|
-
this.el = document.createElement('div');
|
|
63
|
-
} catch (e) {}
|
|
64
|
-
|
|
65
96
|
this.state = {
|
|
66
|
-
container:
|
|
97
|
+
container: this.initContainer(context, true)
|
|
67
98
|
};
|
|
68
99
|
}
|
|
69
100
|
|
|
70
101
|
componentDidMount() {
|
|
71
|
-
|
|
72
|
-
this.el = document.createElement('div');
|
|
73
|
-
}
|
|
102
|
+
const container = this.initContainer(this.context);
|
|
74
103
|
|
|
75
|
-
|
|
76
|
-
state,
|
|
77
|
-
props,
|
|
78
|
-
context
|
|
79
|
-
} = this;
|
|
80
|
-
const getContainer = props.getPopupContainer || context.getPopupContainer || defaultGetContainer;
|
|
81
|
-
const container = getContainer();
|
|
82
|
-
|
|
83
|
-
if (container !== state.container) {
|
|
84
|
-
// const computedStyle = window.getComputedStyle(container);
|
|
85
|
-
// if (computedStyle.position !== 'relative') {
|
|
86
|
-
// container.style.position = 'relative';
|
|
87
|
-
// }
|
|
88
|
-
container.appendChild(this.el);
|
|
89
|
-
this.addStyle(props.style);
|
|
90
|
-
this.addClass(props.prefixCls, props.className);
|
|
104
|
+
if (container !== this.state.container) {
|
|
91
105
|
this.setState({
|
|
92
106
|
container
|
|
93
107
|
});
|
|
@@ -27,12 +27,13 @@ declare class Portal extends PureComponent<PortalProps, PortalState> {
|
|
|
27
27
|
};
|
|
28
28
|
el: HTMLElement;
|
|
29
29
|
context: ContextValue;
|
|
30
|
-
constructor(props: PortalProps);
|
|
30
|
+
constructor(props: PortalProps, context: ContextValue);
|
|
31
31
|
componentDidMount(): void;
|
|
32
|
+
initContainer: (context: ContextValue, catchError?: boolean) => HTMLElement;
|
|
32
33
|
componentDidUpdate(prevProps: PortalProps): void;
|
|
33
34
|
componentWillUnmount(): void;
|
|
34
35
|
addStyle: (style?: {}) => void;
|
|
35
|
-
addClass: (prefixCls: string, ...classNames: string[]) => void;
|
|
36
|
+
addClass: (prefixCls: string, context?: ContextValue, ...classNames: string[]) => void;
|
|
36
37
|
render(): React.ReactPortal;
|
|
37
38
|
}
|
|
38
39
|
export default Portal;
|
package/lib/es/_portal/index.js
CHANGED
|
@@ -9,12 +9,46 @@ import '@douyinfe/semi-foundation/lib/es/_portal/portal.css';
|
|
|
9
9
|
const defaultGetContainer = () => document.body;
|
|
10
10
|
|
|
11
11
|
class Portal extends PureComponent {
|
|
12
|
-
constructor(props) {
|
|
12
|
+
constructor(props, context) {
|
|
13
13
|
var _this;
|
|
14
14
|
|
|
15
15
|
super(props);
|
|
16
16
|
_this = this;
|
|
17
17
|
|
|
18
|
+
this.initContainer = function (context) {
|
|
19
|
+
let catchError = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
20
|
+
|
|
21
|
+
var _a, _b;
|
|
22
|
+
|
|
23
|
+
try {
|
|
24
|
+
let container = undefined;
|
|
25
|
+
|
|
26
|
+
if (!_this.el) {
|
|
27
|
+
_this.el = document.createElement('div');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (!((_a = _this.state) === null || _a === void 0 ? void 0 : _a.container)) {
|
|
31
|
+
_this.el = document.createElement('div');
|
|
32
|
+
const getContainer = _this.props.getPopupContainer || context.getPopupContainer || defaultGetContainer;
|
|
33
|
+
const portalContainer = getContainer();
|
|
34
|
+
portalContainer.appendChild(_this.el);
|
|
35
|
+
|
|
36
|
+
_this.addStyle(_this.props.style);
|
|
37
|
+
|
|
38
|
+
_this.addClass(_this.props.prefixCls, context, _this.props.className);
|
|
39
|
+
|
|
40
|
+
container = portalContainer;
|
|
41
|
+
return container;
|
|
42
|
+
}
|
|
43
|
+
} catch (e) {
|
|
44
|
+
if (!catchError) {
|
|
45
|
+
throw e;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return (_b = _this.state) === null || _b === void 0 ? void 0 : _b.container;
|
|
50
|
+
};
|
|
51
|
+
|
|
18
52
|
this.addStyle = function () {
|
|
19
53
|
let style = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
20
54
|
|
|
@@ -26,12 +60,13 @@ class Portal extends PureComponent {
|
|
|
26
60
|
};
|
|
27
61
|
|
|
28
62
|
this.addClass = function (prefixCls) {
|
|
63
|
+
let context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _this.context;
|
|
29
64
|
const {
|
|
30
65
|
direction
|
|
31
|
-
} =
|
|
66
|
+
} = context;
|
|
32
67
|
|
|
33
|
-
for (var _len = arguments.length, classNames = new Array(_len >
|
|
34
|
-
classNames[_key -
|
|
68
|
+
for (var _len = arguments.length, classNames = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
69
|
+
classNames[_key - 2] = arguments[_key];
|
|
35
70
|
}
|
|
36
71
|
|
|
37
72
|
const cls = classnames(prefixCls, ...classNames, {
|
|
@@ -43,36 +78,15 @@ class Portal extends PureComponent {
|
|
|
43
78
|
}
|
|
44
79
|
};
|
|
45
80
|
|
|
46
|
-
try {
|
|
47
|
-
this.el = document.createElement('div');
|
|
48
|
-
} catch (e) {}
|
|
49
|
-
|
|
50
81
|
this.state = {
|
|
51
|
-
container:
|
|
82
|
+
container: this.initContainer(context, true)
|
|
52
83
|
};
|
|
53
84
|
}
|
|
54
85
|
|
|
55
86
|
componentDidMount() {
|
|
56
|
-
|
|
57
|
-
this.el = document.createElement('div');
|
|
58
|
-
}
|
|
87
|
+
const container = this.initContainer(this.context);
|
|
59
88
|
|
|
60
|
-
|
|
61
|
-
state,
|
|
62
|
-
props,
|
|
63
|
-
context
|
|
64
|
-
} = this;
|
|
65
|
-
const getContainer = props.getPopupContainer || context.getPopupContainer || defaultGetContainer;
|
|
66
|
-
const container = getContainer();
|
|
67
|
-
|
|
68
|
-
if (container !== state.container) {
|
|
69
|
-
// const computedStyle = window.getComputedStyle(container);
|
|
70
|
-
// if (computedStyle.position !== 'relative') {
|
|
71
|
-
// container.style.position = 'relative';
|
|
72
|
-
// }
|
|
73
|
-
container.appendChild(this.el);
|
|
74
|
-
this.addStyle(props.style);
|
|
75
|
-
this.addClass(props.prefixCls, props.className);
|
|
89
|
+
if (container !== this.state.container) {
|
|
76
90
|
this.setState({
|
|
77
91
|
container
|
|
78
92
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-ui",
|
|
3
|
-
"version": "2.27.
|
|
3
|
+
"version": "2.27.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/es/index.js",
|
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
"lib/*"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@douyinfe/semi-animation": "2.27.
|
|
21
|
-
"@douyinfe/semi-animation-react": "2.27.
|
|
22
|
-
"@douyinfe/semi-foundation": "2.27.
|
|
23
|
-
"@douyinfe/semi-icons": "2.27.
|
|
24
|
-
"@douyinfe/semi-illustrations": "2.27.
|
|
25
|
-
"@douyinfe/semi-theme-default": "2.27.
|
|
20
|
+
"@douyinfe/semi-animation": "2.27.2",
|
|
21
|
+
"@douyinfe/semi-animation-react": "2.27.2",
|
|
22
|
+
"@douyinfe/semi-foundation": "2.27.2",
|
|
23
|
+
"@douyinfe/semi-icons": "2.27.2",
|
|
24
|
+
"@douyinfe/semi-illustrations": "2.27.2",
|
|
25
|
+
"@douyinfe/semi-theme-default": "2.27.2",
|
|
26
26
|
"async-validator": "^3.5.0",
|
|
27
27
|
"classnames": "^2.2.6",
|
|
28
28
|
"copy-text-to-clipboard": "^2.1.1",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
],
|
|
70
70
|
"author": "",
|
|
71
71
|
"license": "MIT",
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "6efa0e3f18bac28642eadca29f6d3fa27e5d6ba4",
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@babel/plugin-proposal-decorators": "^7.15.8",
|
|
75
75
|
"@babel/plugin-transform-runtime": "^7.15.8",
|