@sheinx/base 3.8.4-beta.9 → 3.8.5-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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal-content.d.ts","sourceRoot":"","sources":["modal-content.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"modal-content.d.ts","sourceRoot":"","sources":["modal-content.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AA2D9D,QAAA,MAAM,KAAK,UAAW,iBAAiB,mDAyYtC,CAAC;AAEF,eAAe,KAAK,CAAC"}
|
|
@@ -29,7 +29,8 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
29
29
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
30
30
|
var hasMask = false;
|
|
31
31
|
var config = {
|
|
32
|
-
instanceIds: []
|
|
32
|
+
instanceIds: [],
|
|
33
|
+
originDocumentStyle: null
|
|
33
34
|
};
|
|
34
35
|
var state = (0, _reactive.create)(config);
|
|
35
36
|
var useModalConfig = function useModalConfig() {
|
|
@@ -46,6 +47,12 @@ var removeModalInstance = function removeModalInstance(instanceId) {
|
|
|
46
47
|
var getInstanceIds = function getInstanceIds() {
|
|
47
48
|
return state.mutate.instanceIds;
|
|
48
49
|
};
|
|
50
|
+
var setOriginDocumentStyle = function setOriginDocumentStyle(style) {
|
|
51
|
+
state.mutate.originDocumentStyle = style;
|
|
52
|
+
};
|
|
53
|
+
var getOriginDocumentStyle = function getOriginDocumentStyle() {
|
|
54
|
+
return state.mutate.originDocumentStyle;
|
|
55
|
+
};
|
|
49
56
|
var mousePosition = null;
|
|
50
57
|
var getClickPosition = function getClickPosition(e) {
|
|
51
58
|
mousePosition = {
|
|
@@ -88,7 +95,6 @@ var Modal = function Modal(props) {
|
|
|
88
95
|
mouseDownTarget: null,
|
|
89
96
|
mouseUpTarget: null,
|
|
90
97
|
content: null,
|
|
91
|
-
originDocumentStyle: null,
|
|
92
98
|
instanceId: _hooks.util.generateUUID()
|
|
93
99
|
}),
|
|
94
100
|
context = _useRef.current;
|
|
@@ -203,15 +209,16 @@ var Modal = function Modal(props) {
|
|
|
203
209
|
setAnimation(true);
|
|
204
210
|
}
|
|
205
211
|
}, [props.visible]);
|
|
212
|
+
var originDocumentStyle = getOriginDocumentStyle();
|
|
206
213
|
|
|
207
214
|
// 设置 document.body.style.overflow 和 document.body.style.paddingRight,并记录原始值到 context 中
|
|
208
215
|
var setDocumentOverflow = (0, _hooks.usePersistFn)(function () {
|
|
209
216
|
var doc = document.body.parentNode;
|
|
210
|
-
if (context.isMask && !
|
|
211
|
-
|
|
217
|
+
if (context.isMask && !originDocumentStyle) {
|
|
218
|
+
setOriginDocumentStyle({
|
|
212
219
|
overflow: doc.style.overflow,
|
|
213
220
|
paddingRight: doc.style.paddingRight
|
|
214
|
-
};
|
|
221
|
+
});
|
|
215
222
|
}
|
|
216
223
|
doc.style.overflow = 'hidden';
|
|
217
224
|
if (!doc.style.paddingRight) {
|
|
@@ -222,9 +229,10 @@ var Modal = function Modal(props) {
|
|
|
222
229
|
// 还原 document.body.style.overflow 和 document.body.style.paddingRight
|
|
223
230
|
var resetDocumentOverflow = (0, _hooks.usePersistFn)(function () {
|
|
224
231
|
var doc = document.body.parentNode;
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
doc.style.
|
|
232
|
+
// 把originDocumentStyle放到全局管理后,多个modal连续打开关闭场景下,可以正确还原
|
|
233
|
+
if (originDocumentStyle) {
|
|
234
|
+
doc.style.overflow = originDocumentStyle.overflow;
|
|
235
|
+
doc.style.paddingRight = originDocumentStyle.paddingRight;
|
|
228
236
|
}
|
|
229
237
|
});
|
|
230
238
|
(0, _react.useEffect)(function () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal-content.d.ts","sourceRoot":"","sources":["modal-content.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"modal-content.d.ts","sourceRoot":"","sources":["modal-content.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AA2D9D,QAAA,MAAM,KAAK,UAAW,iBAAiB,mDAyYtC,CAAC;AAEF,eAAe,KAAK,CAAC"}
|
|
@@ -23,7 +23,8 @@ import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
|
23
23
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
24
|
var hasMask = false;
|
|
25
25
|
var config = {
|
|
26
|
-
instanceIds: []
|
|
26
|
+
instanceIds: [],
|
|
27
|
+
originDocumentStyle: null
|
|
27
28
|
};
|
|
28
29
|
var state = create(config);
|
|
29
30
|
var useModalConfig = function useModalConfig() {
|
|
@@ -40,6 +41,12 @@ var removeModalInstance = function removeModalInstance(instanceId) {
|
|
|
40
41
|
var getInstanceIds = function getInstanceIds() {
|
|
41
42
|
return state.mutate.instanceIds;
|
|
42
43
|
};
|
|
44
|
+
var setOriginDocumentStyle = function setOriginDocumentStyle(style) {
|
|
45
|
+
state.mutate.originDocumentStyle = style;
|
|
46
|
+
};
|
|
47
|
+
var getOriginDocumentStyle = function getOriginDocumentStyle() {
|
|
48
|
+
return state.mutate.originDocumentStyle;
|
|
49
|
+
};
|
|
43
50
|
var mousePosition = null;
|
|
44
51
|
var getClickPosition = function getClickPosition(e) {
|
|
45
52
|
mousePosition = {
|
|
@@ -82,7 +89,6 @@ var Modal = function Modal(props) {
|
|
|
82
89
|
mouseDownTarget: null,
|
|
83
90
|
mouseUpTarget: null,
|
|
84
91
|
content: null,
|
|
85
|
-
originDocumentStyle: null,
|
|
86
92
|
instanceId: util.generateUUID()
|
|
87
93
|
}),
|
|
88
94
|
context = _useRef.current;
|
|
@@ -197,15 +203,16 @@ var Modal = function Modal(props) {
|
|
|
197
203
|
setAnimation(true);
|
|
198
204
|
}
|
|
199
205
|
}, [props.visible]);
|
|
206
|
+
var originDocumentStyle = getOriginDocumentStyle();
|
|
200
207
|
|
|
201
208
|
// 设置 document.body.style.overflow 和 document.body.style.paddingRight,并记录原始值到 context 中
|
|
202
209
|
var setDocumentOverflow = usePersistFn(function () {
|
|
203
210
|
var doc = document.body.parentNode;
|
|
204
|
-
if (context.isMask && !
|
|
205
|
-
|
|
211
|
+
if (context.isMask && !originDocumentStyle) {
|
|
212
|
+
setOriginDocumentStyle({
|
|
206
213
|
overflow: doc.style.overflow,
|
|
207
214
|
paddingRight: doc.style.paddingRight
|
|
208
|
-
};
|
|
215
|
+
});
|
|
209
216
|
}
|
|
210
217
|
doc.style.overflow = 'hidden';
|
|
211
218
|
if (!doc.style.paddingRight) {
|
|
@@ -216,9 +223,10 @@ var Modal = function Modal(props) {
|
|
|
216
223
|
// 还原 document.body.style.overflow 和 document.body.style.paddingRight
|
|
217
224
|
var resetDocumentOverflow = usePersistFn(function () {
|
|
218
225
|
var doc = document.body.parentNode;
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
doc.style.
|
|
226
|
+
// 把originDocumentStyle放到全局管理后,多个modal连续打开关闭场景下,可以正确还原
|
|
227
|
+
if (originDocumentStyle) {
|
|
228
|
+
doc.style.overflow = originDocumentStyle.overflow;
|
|
229
|
+
doc.style.paddingRight = originDocumentStyle.paddingRight;
|
|
222
230
|
}
|
|
223
231
|
});
|
|
224
232
|
useEffect(function () {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sheinx/base",
|
|
3
|
-
"version": "3.8.
|
|
3
|
+
"version": "3.8.5-beta.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"module": "./esm/index.js",
|
|
11
11
|
"typings": "./cjs/index.d.ts",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@sheinx/hooks": "3.8.
|
|
13
|
+
"@sheinx/hooks": "3.8.5-beta.1",
|
|
14
14
|
"immer": "^10.0.0",
|
|
15
15
|
"classnames": "^2.0.0",
|
|
16
16
|
"@shined/reactive": "^0.1.3-alpha.0"
|