@sheinx/base 3.9.8-beta.10 → 3.9.8-beta.11
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":"AAUA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAkF9D,QAAA,MAAM,KAAK,UAAW,iBAAiB,mDAsbtC,CAAC;AAEF,eAAe,KAAK,CAAC"}
|
|
@@ -85,6 +85,8 @@ var Modal = function Modal(props) {
|
|
|
85
85
|
var _props$jssStyle, _props$jssStyle$modal;
|
|
86
86
|
var modalClasses = (_props$jssStyle = props.jssStyle) === null || _props$jssStyle === void 0 || (_props$jssStyle$modal = _props$jssStyle.modal) === null || _props$jssStyle$modal === void 0 ? void 0 : _props$jssStyle$modal.call(_props$jssStyle);
|
|
87
87
|
var panelRef = (0, _react.useRef)(null);
|
|
88
|
+
var wrapperRef = (0, _react.useRef)(null);
|
|
89
|
+
var popupCtx = (0, _react.useContext)(_hooks.popupContext);
|
|
88
90
|
var isPositionX = ['left', 'right'].includes(props.position || '');
|
|
89
91
|
var isPositionY = ['top', 'bottom'].includes(props.position || '');
|
|
90
92
|
var defaultWidth = isPositionX ? 'auto' : 500;
|
|
@@ -298,6 +300,22 @@ var Modal = function Modal(props) {
|
|
|
298
300
|
}
|
|
299
301
|
}, [props.setInnerClose]);
|
|
300
302
|
|
|
303
|
+
// 将 Modal 的 ref 注册到父 Popover 的 chain 中,防止点击 Modal 时关闭 Popover
|
|
304
|
+
(0, _react.useLayoutEffect)(function () {
|
|
305
|
+
// Modal 显示或关闭动画播放期间,都需要在 chain 中
|
|
306
|
+
if (wrapperRef.current) {
|
|
307
|
+
if (visible) {
|
|
308
|
+
popupCtx.bindChild(wrapperRef);
|
|
309
|
+
} else {
|
|
310
|
+
popupCtx.removeChild(wrapperRef);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
return function () {
|
|
314
|
+
// 确保清理时移除
|
|
315
|
+
popupCtx.removeChild(wrapperRef);
|
|
316
|
+
};
|
|
317
|
+
}, [visible]);
|
|
318
|
+
|
|
301
319
|
// render
|
|
302
320
|
var renderIcon = function renderIcon(isEmptyTitle) {
|
|
303
321
|
var iconRoot = (0, _classnames.default)(modalClasses === null || modalClasses === void 0 ? void 0 : modalClasses.headerIcon, isEmptyTitle && (modalClasses === null || modalClasses === void 0 ? void 0 : modalClasses.emptyIcon));
|
|
@@ -426,6 +444,7 @@ var Modal = function Modal(props) {
|
|
|
426
444
|
context.content = content;
|
|
427
445
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_formFooterContext.FormFooterProvider, {
|
|
428
446
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
447
|
+
ref: wrapperRef,
|
|
429
448
|
onClick: function onClick(e) {
|
|
430
449
|
e.stopPropagation();
|
|
431
450
|
},
|
|
@@ -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":"AAUA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAkF9D,QAAA,MAAM,KAAK,UAAW,iBAAiB,mDAsbtC,CAAC;AAEF,eAAe,KAAK,CAAC"}
|
|
@@ -11,13 +11,14 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
11
11
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
12
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
13
|
import classNames from 'classnames';
|
|
14
|
-
import React, { useRef, useEffect, useState, useMemo } from 'react';
|
|
14
|
+
import React, { useRef, useEffect, useState, useMemo, useContext, useLayoutEffect } from 'react';
|
|
15
15
|
import AlertIcon, { AlertIconMap } from "../alert/alert-icon";
|
|
16
16
|
import Icons from "../icons";
|
|
17
17
|
import { util } from '@sheinx/hooks';
|
|
18
18
|
import { create } from '@shined/reactive';
|
|
19
19
|
import { useDragMove, useDragResize, usePersistFn, useRender } from '@sheinx/hooks';
|
|
20
20
|
import { FormFooterProvider } from "../form/form-footer-context";
|
|
21
|
+
import { popupContext } from '@sheinx/hooks';
|
|
21
22
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
22
23
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
23
24
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -79,6 +80,8 @@ var Modal = function Modal(props) {
|
|
|
79
80
|
var _props$jssStyle, _props$jssStyle$modal;
|
|
80
81
|
var modalClasses = (_props$jssStyle = props.jssStyle) === null || _props$jssStyle === void 0 || (_props$jssStyle$modal = _props$jssStyle.modal) === null || _props$jssStyle$modal === void 0 ? void 0 : _props$jssStyle$modal.call(_props$jssStyle);
|
|
81
82
|
var panelRef = useRef(null);
|
|
83
|
+
var wrapperRef = useRef(null);
|
|
84
|
+
var popupCtx = useContext(popupContext);
|
|
82
85
|
var isPositionX = ['left', 'right'].includes(props.position || '');
|
|
83
86
|
var isPositionY = ['top', 'bottom'].includes(props.position || '');
|
|
84
87
|
var defaultWidth = isPositionX ? 'auto' : 500;
|
|
@@ -292,6 +295,22 @@ var Modal = function Modal(props) {
|
|
|
292
295
|
}
|
|
293
296
|
}, [props.setInnerClose]);
|
|
294
297
|
|
|
298
|
+
// 将 Modal 的 ref 注册到父 Popover 的 chain 中,防止点击 Modal 时关闭 Popover
|
|
299
|
+
useLayoutEffect(function () {
|
|
300
|
+
// Modal 显示或关闭动画播放期间,都需要在 chain 中
|
|
301
|
+
if (wrapperRef.current) {
|
|
302
|
+
if (visible) {
|
|
303
|
+
popupCtx.bindChild(wrapperRef);
|
|
304
|
+
} else {
|
|
305
|
+
popupCtx.removeChild(wrapperRef);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
return function () {
|
|
309
|
+
// 确保清理时移除
|
|
310
|
+
popupCtx.removeChild(wrapperRef);
|
|
311
|
+
};
|
|
312
|
+
}, [visible]);
|
|
313
|
+
|
|
295
314
|
// render
|
|
296
315
|
var renderIcon = function renderIcon(isEmptyTitle) {
|
|
297
316
|
var iconRoot = classNames(modalClasses === null || modalClasses === void 0 ? void 0 : modalClasses.headerIcon, isEmptyTitle && (modalClasses === null || modalClasses === void 0 ? void 0 : modalClasses.emptyIcon));
|
|
@@ -420,6 +439,7 @@ var Modal = function Modal(props) {
|
|
|
420
439
|
context.content = content;
|
|
421
440
|
return /*#__PURE__*/_jsx(FormFooterProvider, {
|
|
422
441
|
children: /*#__PURE__*/_jsx("div", {
|
|
442
|
+
ref: wrapperRef,
|
|
423
443
|
onClick: function onClick(e) {
|
|
424
444
|
e.stopPropagation();
|
|
425
445
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sheinx/base",
|
|
3
|
-
"version": "3.9.8-beta.
|
|
3
|
+
"version": "3.9.8-beta.11",
|
|
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.9.8-beta.
|
|
13
|
+
"@sheinx/hooks": "3.9.8-beta.11",
|
|
14
14
|
"immer": "^10.0.0",
|
|
15
15
|
"classnames": "^2.0.0",
|
|
16
16
|
"@shined/reactive": "^0.3.3"
|