@4i/modal-manager 1.1.34 → 1.1.40
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
@@ -70,6 +70,17 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
70
70
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
71
71
|
}
|
72
72
|
};
|
73
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
74
|
+
var t = {};
|
75
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
76
|
+
t[p] = s[p];
|
77
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
78
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
79
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
80
|
+
t[p[i]] = s[p[i]];
|
81
|
+
}
|
82
|
+
return t;
|
83
|
+
};
|
73
84
|
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
74
85
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
75
86
|
if (ar || !(i in from)) {
|
@@ -187,14 +198,19 @@ var ModalProvider = function (_a) {
|
|
187
198
|
e.stopPropagation();
|
188
199
|
};
|
189
200
|
return (react_1.default.createElement(react_1.default.Fragment, null, modals.map(function (modalItem, index) {
|
190
|
-
var name = modalItem.name, payload = modalItem.payload, options = modalItem.options, id = modalItem.id;
|
201
|
+
var name = modalItem.name, payload = modalItem.payload, options = modalItem.options, id = modalItem.id, props = __rest(modalItem, ["name", "payload", "options", "id"]);
|
191
202
|
var Modal = modalList[name] || (function () { return react_1.default.createElement("div", null,
|
192
203
|
"Modal not found: ",
|
193
204
|
name); });
|
194
205
|
var hideBackdrop = (options === null || options === void 0 ? void 0 : options.hideBackdrop) || false;
|
195
206
|
var extraClass = (options === null || options === void 0 ? void 0 : options.extraClass) || "";
|
196
207
|
return (react_1.default.createElement("div", { key: id, "data-modal-id": id, "data-modal-index": index, className: "modal_container ".concat(extraClass) },
|
197
|
-
!hideBackdrop && (react_1.default.createElement("div", { onClick: function () {
|
208
|
+
!hideBackdrop && (react_1.default.createElement("div", { onClick: function () {
|
209
|
+
var _a;
|
210
|
+
(options === null || options === void 0 ? void 0 : options.onClickBackdrop)
|
211
|
+
? (_a = options === null || options === void 0 ? void 0 : options.onClickBackdrop) === null || _a === void 0 ? void 0 : _a.call(options, function () { return handleCloseModal(index); })
|
212
|
+
: handleCloseModal(index);
|
213
|
+
}, className: "modal_backdrop" })),
|
198
214
|
react_1.default.createElement("div", { className: "".concat(className, " modal_paper"), onClick: stopPropagation, ref: function (ref) { return saveModalRef(id, ref); } },
|
199
215
|
react_1.default.createElement(Modal, __assign({}, (payload.data || {}), { modalIndex: index })))));
|
200
216
|
})));
|
@@ -10,6 +10,7 @@ interface ModalProviderProps {
|
|
10
10
|
isOverflow?: boolean;
|
11
11
|
className?: string;
|
12
12
|
backdropClassName?: string;
|
13
|
+
onClickBackdrop?: (cb: any) => void;
|
13
14
|
onModalStateChange?: (
|
14
15
|
modalState: boolean,
|
15
16
|
data: ModalData[],
|
@@ -142,7 +143,7 @@ const ModalProvider: React.FC<ModalProviderProps> = ({
|
|
142
143
|
return (
|
143
144
|
<>
|
144
145
|
{modals.map((modalItem, index) => {
|
145
|
-
const { name, payload, options, id } = modalItem;
|
146
|
+
const { name, payload, options, id, ...props } = modalItem;
|
146
147
|
const Modal =
|
147
148
|
modalList[name] || (() => <div>Modal not found: {name}</div>);
|
148
149
|
const hideBackdrop = options?.hideBackdrop || false;
|
@@ -157,7 +158,11 @@ const ModalProvider: React.FC<ModalProviderProps> = ({
|
|
157
158
|
>
|
158
159
|
{!hideBackdrop && (
|
159
160
|
<div
|
160
|
-
onClick={() =>
|
161
|
+
onClick={() => {
|
162
|
+
options?.onClickBackdrop
|
163
|
+
? options?.onClickBackdrop?.(() => handleCloseModal(index))
|
164
|
+
: handleCloseModal(index);
|
165
|
+
}}
|
161
166
|
className="modal_backdrop"
|
162
167
|
/>
|
163
168
|
)}
|
@@ -32,7 +32,7 @@ var ModalManager = /** @class */ (function (_super) {
|
|
32
32
|
function ModalManager() {
|
33
33
|
var _this = _super.call(this) || this;
|
34
34
|
_this.queue = [];
|
35
|
-
_this.modalData = new Map();
|
35
|
+
_this.modalData = new Map();
|
36
36
|
_this.call = function (name, data, options) {
|
37
37
|
var modalId = uniqueID();
|
38
38
|
var id = _this.create(name, { modalId: modalId, data: data }, options);
|
@@ -26,11 +26,12 @@ export interface Options {
|
|
26
26
|
hideBackdrop?: boolean;
|
27
27
|
extraClass?: string;
|
28
28
|
openMinimized?: boolean;
|
29
|
+
onClickBackdrop?: (cb: () => void) => void;
|
29
30
|
}
|
30
31
|
|
31
32
|
export class ModalManager extends Manager {
|
32
33
|
queue: string[] = [];
|
33
|
-
modalData: Map<string, any> = new Map();
|
34
|
+
modalData: Map<string, any> = new Map();
|
34
35
|
_openModalStateCallback: null | ((props: ModalState) => void);
|
35
36
|
|
36
37
|
constructor() {
|