@4i/modal-manager 1.0.70 → 1.0.73
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/package.json
CHANGED
@@ -12,9 +12,10 @@ interface ModalProviderProps {
|
|
12
12
|
onModalClose?: (modalName: string | string[]) => void;
|
13
13
|
onModalOpen?: (modalName: string) => void;
|
14
14
|
onModalStateChange?: (modalState: boolean, data: TData[], names: string[]) => void;
|
15
|
+
ignoreClickClassName?: string;
|
15
16
|
}
|
16
17
|
type TData = {
|
17
18
|
[key: string]: any;
|
18
19
|
};
|
19
|
-
declare const ModalProvider: ({ modalList, isOverflow, className, onModalStateChange, onModalClose, onModalOpen, isHaveBackdrop, isCloseOnBackdropClick, zIndex, }: ModalProviderProps) => false | React.JSX.Element[];
|
20
|
+
declare const ModalProvider: ({ modalList, isOverflow, className, onModalStateChange, onModalClose, onModalOpen, isHaveBackdrop, isCloseOnBackdropClick, zIndex, ignoreClickClassName, }: ModalProviderProps) => false | React.JSX.Element[];
|
20
21
|
export default ModalProvider;
|
@@ -50,7 +50,7 @@ var react_1 = __importStar(require("react"));
|
|
50
50
|
var ModalManager_1 = __importDefault(require("../utils/ModalManager"));
|
51
51
|
var ModalManager_2 = __importDefault(require("../utils/ModalManager"));
|
52
52
|
var ModalProvider = function (_a) {
|
53
|
-
var modalList = _a.modalList, isOverflow = _a.isOverflow, className = _a.className, onModalStateChange = _a.onModalStateChange, onModalClose = _a.onModalClose, onModalOpen = _a.onModalOpen, _b = _a.isHaveBackdrop, isHaveBackdrop = _b === void 0 ? true : _b, _c = _a.isCloseOnBackdropClick, isCloseOnBackdropClick = _c === void 0 ? true : _c, zIndex = _a.zIndex;
|
53
|
+
var modalList = _a.modalList, isOverflow = _a.isOverflow, className = _a.className, onModalStateChange = _a.onModalStateChange, onModalClose = _a.onModalClose, onModalOpen = _a.onModalOpen, _b = _a.isHaveBackdrop, isHaveBackdrop = _b === void 0 ? true : _b, _c = _a.isCloseOnBackdropClick, isCloseOnBackdropClick = _c === void 0 ? true : _c, zIndex = _a.zIndex, ignoreClickClassName = _a.ignoreClickClassName;
|
54
54
|
var _d = (0, react_1.useState)([]), data = _d[0], setData = _d[1];
|
55
55
|
var _e = (0, react_1.useState)([]), names = _e[0], setNames = _e[1];
|
56
56
|
var modalRef = (0, react_1.useRef)([]);
|
@@ -129,8 +129,12 @@ var ModalProvider = function (_a) {
|
|
129
129
|
return Component;
|
130
130
|
});
|
131
131
|
var handleCloseModal = function (index, e) {
|
132
|
+
e.stopPropagation();
|
132
133
|
if (!isCloseOnBackdropClick)
|
133
134
|
return;
|
135
|
+
var element = document.querySelector(".".concat(ignoreClickClassName));
|
136
|
+
if (element && element.contains(e.target))
|
137
|
+
return;
|
134
138
|
if (modalRef.current[index] &&
|
135
139
|
!modalRef.current[index].contains(e.target)) {
|
136
140
|
ModalManager_2.default.close(index);
|
@@ -18,7 +18,7 @@ interface ModalProviderProps {
|
|
18
18
|
data: TData[],
|
19
19
|
names: string[]
|
20
20
|
) => void;
|
21
|
-
|
21
|
+
ignoreClickClassName?: string;
|
22
22
|
}
|
23
23
|
|
24
24
|
type TData = { [key: string]: any };
|
@@ -33,7 +33,7 @@ const ModalProvider = ({
|
|
33
33
|
isHaveBackdrop = true,
|
34
34
|
isCloseOnBackdropClick = true,
|
35
35
|
zIndex,
|
36
|
-
|
36
|
+
ignoreClickClassName,
|
37
37
|
}: ModalProviderProps) => {
|
38
38
|
const [data, setData] = useState<TData[]>([]);
|
39
39
|
const [names, setNames] = useState<string[]>([]);
|
@@ -122,8 +122,12 @@ const ModalProvider = ({
|
|
122
122
|
});
|
123
123
|
|
124
124
|
const handleCloseModal = (index: number, e: any) => {
|
125
|
+
e.stopPropagation();
|
125
126
|
if (!isCloseOnBackdropClick) return;
|
126
|
-
|
127
|
+
|
128
|
+
const element = document.querySelector(`.${ignoreClickClassName}`);
|
129
|
+
if (element && element.contains(e.target)) return;
|
130
|
+
|
127
131
|
if (
|
128
132
|
modalRef.current[index] &&
|
129
133
|
!modalRef.current[index].contains(e.target)
|