@justeattakeaway/pie-modal 0.21.0 → 0.22.0
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/dialog-polyfill.esm-29edb142.js +398 -0
- package/dist/index.d.ts +4 -7
- package/dist/index.js +346 -754
- package/dist/react.d.ts +4 -7
- package/dist/react.js +11 -12
- package/package.json +1 -1
- package/src/defs.ts +1 -2
- package/src/index.ts +11 -14
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
var d = window.CustomEvent;
|
|
2
|
+
(!d || typeof d == "object") && (d = function(t, o) {
|
|
3
|
+
o = o || {};
|
|
4
|
+
var i = document.createEvent("CustomEvent");
|
|
5
|
+
return i.initCustomEvent(t, !!o.bubbles, !!o.cancelable, o.detail || null), i;
|
|
6
|
+
}, d.prototype = window.Event.prototype);
|
|
7
|
+
function g(e, t) {
|
|
8
|
+
var o = "on" + t.type.toLowerCase();
|
|
9
|
+
return typeof e[o] == "function" && e[o](t), e.dispatchEvent(t);
|
|
10
|
+
}
|
|
11
|
+
function E(e) {
|
|
12
|
+
for (; e && e !== document.body; ) {
|
|
13
|
+
var t = window.getComputedStyle(e), o = function(i, a) {
|
|
14
|
+
return !(t[i] === void 0 || t[i] === a);
|
|
15
|
+
};
|
|
16
|
+
if (t.opacity < 1 || o("zIndex", "auto") || o("transform", "none") || o("mixBlendMode", "normal") || o("filter", "none") || o("perspective", "none") || t.isolation === "isolate" || t.position === "fixed" || t.webkitOverflowScrolling === "touch")
|
|
17
|
+
return !0;
|
|
18
|
+
e = e.parentElement;
|
|
19
|
+
}
|
|
20
|
+
return !1;
|
|
21
|
+
}
|
|
22
|
+
function c(e) {
|
|
23
|
+
for (; e; ) {
|
|
24
|
+
if (e.localName === "dialog")
|
|
25
|
+
return (
|
|
26
|
+
/** @type {HTMLDialogElement} */
|
|
27
|
+
e
|
|
28
|
+
);
|
|
29
|
+
e.parentElement ? e = e.parentElement : e.parentNode ? e = e.parentNode.host : e = null;
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
function b(e) {
|
|
34
|
+
for (; e && e.shadowRoot && e.shadowRoot.activeElement; )
|
|
35
|
+
e = e.shadowRoot.activeElement;
|
|
36
|
+
e && e.blur && e !== document.body && e.blur();
|
|
37
|
+
}
|
|
38
|
+
function M(e, t) {
|
|
39
|
+
for (var o = 0; o < e.length; ++o)
|
|
40
|
+
if (e[o] === t)
|
|
41
|
+
return !0;
|
|
42
|
+
return !1;
|
|
43
|
+
}
|
|
44
|
+
function h(e) {
|
|
45
|
+
return !e || !e.hasAttribute("method") ? !1 : e.getAttribute("method").toLowerCase() === "dialog";
|
|
46
|
+
}
|
|
47
|
+
function v(e) {
|
|
48
|
+
var t = ["button", "input", "keygen", "select", "textarea"], o = t.map(function(s) {
|
|
49
|
+
return s + ":not([disabled])";
|
|
50
|
+
});
|
|
51
|
+
o.push('[tabindex]:not([disabled]):not([tabindex=""])');
|
|
52
|
+
var i = e.querySelector(o.join(", "));
|
|
53
|
+
if (!i && "attachShadow" in Element.prototype)
|
|
54
|
+
for (var a = e.querySelectorAll("*"), r = 0; r < a.length && !(a[r].tagName && a[r].shadowRoot && (i = v(a[r].shadowRoot), i)); r++)
|
|
55
|
+
;
|
|
56
|
+
return i;
|
|
57
|
+
}
|
|
58
|
+
function m(e) {
|
|
59
|
+
return e.isConnected || document.body.contains(e);
|
|
60
|
+
}
|
|
61
|
+
function y(e) {
|
|
62
|
+
if (e.submitter)
|
|
63
|
+
return e.submitter;
|
|
64
|
+
var t = e.target;
|
|
65
|
+
if (!(t instanceof HTMLFormElement))
|
|
66
|
+
return null;
|
|
67
|
+
var o = n.formSubmitter;
|
|
68
|
+
if (!o) {
|
|
69
|
+
var i = e.target, a = "getRootNode" in i && i.getRootNode() || document;
|
|
70
|
+
o = a.activeElement;
|
|
71
|
+
}
|
|
72
|
+
return !o || o.form !== t ? null : o;
|
|
73
|
+
}
|
|
74
|
+
function D(e) {
|
|
75
|
+
if (!e.defaultPrevented) {
|
|
76
|
+
var t = (
|
|
77
|
+
/** @type {!HTMLFormElement} */
|
|
78
|
+
e.target
|
|
79
|
+
), o = n.imagemapUseValue, i = y(e);
|
|
80
|
+
o === null && i && (o = i.value);
|
|
81
|
+
var a = c(t);
|
|
82
|
+
if (a) {
|
|
83
|
+
var r = i && i.getAttribute("formmethod") || t.getAttribute("method");
|
|
84
|
+
r === "dialog" && (e.preventDefault(), o != null ? a.close(o) : a.close());
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function _(e) {
|
|
89
|
+
if (this.dialog_ = e, this.replacedStyleTop_ = !1, this.openAsModal_ = !1, e.hasAttribute("role") || e.setAttribute("role", "dialog"), e.show = this.show.bind(this), e.showModal = this.showModal.bind(this), e.close = this.close.bind(this), e.addEventListener("submit", D, !1), "returnValue" in e || (e.returnValue = ""), "MutationObserver" in window) {
|
|
90
|
+
var t = new MutationObserver(this.maybeHideModal.bind(this));
|
|
91
|
+
t.observe(e, { attributes: !0, attributeFilter: ["open"] });
|
|
92
|
+
} else {
|
|
93
|
+
var o = !1, i = function() {
|
|
94
|
+
o ? this.downgradeModal() : this.maybeHideModal(), o = !1;
|
|
95
|
+
}.bind(this), a, r = function(s) {
|
|
96
|
+
if (s.target === e) {
|
|
97
|
+
var u = "DOMNodeRemoved";
|
|
98
|
+
o |= s.type.substr(0, u.length) === u, window.clearTimeout(a), a = window.setTimeout(i, 0);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
["DOMAttrModified", "DOMNodeRemoved", "DOMNodeRemovedFromDocument"].forEach(function(s) {
|
|
102
|
+
e.addEventListener(s, r);
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
Object.defineProperty(e, "open", {
|
|
106
|
+
set: this.setOpen.bind(this),
|
|
107
|
+
get: e.hasAttribute.bind(e, "open")
|
|
108
|
+
}), this.backdrop_ = document.createElement("div"), this.backdrop_.className = "backdrop", this.backdrop_.addEventListener("mouseup", this.backdropMouseEvent_.bind(this)), this.backdrop_.addEventListener("mousedown", this.backdropMouseEvent_.bind(this)), this.backdrop_.addEventListener("click", this.backdropMouseEvent_.bind(this));
|
|
109
|
+
}
|
|
110
|
+
_.prototype = /** @type {HTMLDialogElement.prototype} */
|
|
111
|
+
{
|
|
112
|
+
get dialog() {
|
|
113
|
+
return this.dialog_;
|
|
114
|
+
},
|
|
115
|
+
/**
|
|
116
|
+
* Maybe remove this dialog from the modal top layer. This is called when
|
|
117
|
+
* a modal dialog may no longer be tenable, e.g., when the dialog is no
|
|
118
|
+
* longer open or is no longer part of the DOM.
|
|
119
|
+
*/
|
|
120
|
+
maybeHideModal: function() {
|
|
121
|
+
this.dialog_.hasAttribute("open") && m(this.dialog_) || this.downgradeModal();
|
|
122
|
+
},
|
|
123
|
+
/**
|
|
124
|
+
* Remove this dialog from the modal top layer, leaving it as a non-modal.
|
|
125
|
+
*/
|
|
126
|
+
downgradeModal: function() {
|
|
127
|
+
this.openAsModal_ && (this.openAsModal_ = !1, this.dialog_.style.zIndex = "", this.replacedStyleTop_ && (this.dialog_.style.top = "", this.replacedStyleTop_ = !1), this.backdrop_.parentNode && this.backdrop_.parentNode.removeChild(this.backdrop_), n.dm.removeDialog(this));
|
|
128
|
+
},
|
|
129
|
+
/**
|
|
130
|
+
* @param {boolean} value whether to open or close this dialog
|
|
131
|
+
*/
|
|
132
|
+
setOpen: function(e) {
|
|
133
|
+
e ? this.dialog_.hasAttribute("open") || this.dialog_.setAttribute("open", "") : (this.dialog_.removeAttribute("open"), this.maybeHideModal());
|
|
134
|
+
},
|
|
135
|
+
/**
|
|
136
|
+
* Handles mouse events ('mouseup', 'mousedown', 'click') on the fake .backdrop element, redirecting them as if
|
|
137
|
+
* they were on the dialog itself.
|
|
138
|
+
*
|
|
139
|
+
* @param {!Event} e to redirect
|
|
140
|
+
*/
|
|
141
|
+
backdropMouseEvent_: function(e) {
|
|
142
|
+
if (this.dialog_.hasAttribute("tabindex"))
|
|
143
|
+
this.dialog_.focus();
|
|
144
|
+
else {
|
|
145
|
+
var t = document.createElement("div");
|
|
146
|
+
this.dialog_.insertBefore(t, this.dialog_.firstChild), t.tabIndex = -1, t.focus(), this.dialog_.removeChild(t);
|
|
147
|
+
}
|
|
148
|
+
var o = document.createEvent("MouseEvents");
|
|
149
|
+
o.initMouseEvent(
|
|
150
|
+
e.type,
|
|
151
|
+
e.bubbles,
|
|
152
|
+
e.cancelable,
|
|
153
|
+
window,
|
|
154
|
+
e.detail,
|
|
155
|
+
e.screenX,
|
|
156
|
+
e.screenY,
|
|
157
|
+
e.clientX,
|
|
158
|
+
e.clientY,
|
|
159
|
+
e.ctrlKey,
|
|
160
|
+
e.altKey,
|
|
161
|
+
e.shiftKey,
|
|
162
|
+
e.metaKey,
|
|
163
|
+
e.button,
|
|
164
|
+
e.relatedTarget
|
|
165
|
+
), this.dialog_.dispatchEvent(o), e.stopPropagation();
|
|
166
|
+
},
|
|
167
|
+
/**
|
|
168
|
+
* Focuses on the first focusable element within the dialog. This will always blur the current
|
|
169
|
+
* focus, even if nothing within the dialog is found.
|
|
170
|
+
*/
|
|
171
|
+
focus_: function() {
|
|
172
|
+
var e = this.dialog_.querySelector("[autofocus]:not([disabled])");
|
|
173
|
+
!e && this.dialog_.tabIndex >= 0 && (e = this.dialog_), e || (e = v(this.dialog_)), b(document.activeElement), e && e.focus();
|
|
174
|
+
},
|
|
175
|
+
/**
|
|
176
|
+
* Sets the zIndex for the backdrop and dialog.
|
|
177
|
+
*
|
|
178
|
+
* @param {number} dialogZ
|
|
179
|
+
* @param {number} backdropZ
|
|
180
|
+
*/
|
|
181
|
+
updateZIndex: function(e, t) {
|
|
182
|
+
if (e < t)
|
|
183
|
+
throw new Error("dialogZ should never be < backdropZ");
|
|
184
|
+
this.dialog_.style.zIndex = e, this.backdrop_.style.zIndex = t;
|
|
185
|
+
},
|
|
186
|
+
/**
|
|
187
|
+
* Shows the dialog. If the dialog is already open, this does nothing.
|
|
188
|
+
*/
|
|
189
|
+
show: function() {
|
|
190
|
+
this.dialog_.open || (this.setOpen(!0), this.focus_());
|
|
191
|
+
},
|
|
192
|
+
/**
|
|
193
|
+
* Show this dialog modally.
|
|
194
|
+
*/
|
|
195
|
+
showModal: function() {
|
|
196
|
+
if (this.dialog_.hasAttribute("open"))
|
|
197
|
+
throw new Error("Failed to execute 'showModal' on dialog: The element is already open, and therefore cannot be opened modally.");
|
|
198
|
+
if (!m(this.dialog_))
|
|
199
|
+
throw new Error("Failed to execute 'showModal' on dialog: The element is not in a Document.");
|
|
200
|
+
if (!n.dm.pushDialog(this))
|
|
201
|
+
throw new Error("Failed to execute 'showModal' on dialog: There are too many open modal dialogs.");
|
|
202
|
+
E(this.dialog_.parentElement) && console.warn("A dialog is being shown inside a stacking context. This may cause it to be unusable. For more information, see this link: https://github.com/GoogleChrome/dialog-polyfill/#stacking-context"), this.setOpen(!0), this.openAsModal_ = !0, n.needsCentering(this.dialog_) ? (n.reposition(this.dialog_), this.replacedStyleTop_ = !0) : this.replacedStyleTop_ = !1, this.dialog_.parentNode.insertBefore(this.backdrop_, this.dialog_.nextSibling), this.focus_();
|
|
203
|
+
},
|
|
204
|
+
/**
|
|
205
|
+
* Closes this HTMLDialogElement. This is optional vs clearing the open
|
|
206
|
+
* attribute, however this fires a 'close' event.
|
|
207
|
+
*
|
|
208
|
+
* @param {string=} opt_returnValue to use as the returnValue
|
|
209
|
+
*/
|
|
210
|
+
close: function(e) {
|
|
211
|
+
if (!this.dialog_.hasAttribute("open"))
|
|
212
|
+
throw new Error("Failed to execute 'close' on dialog: The element does not have an 'open' attribute, and therefore cannot be closed.");
|
|
213
|
+
this.setOpen(!1), e !== void 0 && (this.dialog_.returnValue = e);
|
|
214
|
+
var t = new d("close", {
|
|
215
|
+
bubbles: !1,
|
|
216
|
+
cancelable: !1
|
|
217
|
+
});
|
|
218
|
+
g(this.dialog_, t);
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
var n = {};
|
|
222
|
+
n.reposition = function(e) {
|
|
223
|
+
var t = document.body.scrollTop || document.documentElement.scrollTop, o = t + (window.innerHeight - e.offsetHeight) / 2;
|
|
224
|
+
e.style.top = Math.max(t, o) + "px";
|
|
225
|
+
};
|
|
226
|
+
n.isInlinePositionSetByStylesheet = function(e) {
|
|
227
|
+
for (var t = 0; t < document.styleSheets.length; ++t) {
|
|
228
|
+
var o = document.styleSheets[t], i = null;
|
|
229
|
+
try {
|
|
230
|
+
i = o.cssRules;
|
|
231
|
+
} catch {
|
|
232
|
+
}
|
|
233
|
+
if (i)
|
|
234
|
+
for (var a = 0; a < i.length; ++a) {
|
|
235
|
+
var r = i[a], s = null;
|
|
236
|
+
try {
|
|
237
|
+
s = document.querySelectorAll(r.selectorText);
|
|
238
|
+
} catch {
|
|
239
|
+
}
|
|
240
|
+
if (!(!s || !M(s, e))) {
|
|
241
|
+
var u = r.style.getPropertyValue("top"), f = r.style.getPropertyValue("bottom");
|
|
242
|
+
if (u && u !== "auto" || f && f !== "auto")
|
|
243
|
+
return !0;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
return !1;
|
|
248
|
+
};
|
|
249
|
+
n.needsCentering = function(e) {
|
|
250
|
+
var t = window.getComputedStyle(e);
|
|
251
|
+
return t.position !== "absolute" || e.style.top !== "auto" && e.style.top !== "" || e.style.bottom !== "auto" && e.style.bottom !== "" ? !1 : !n.isInlinePositionSetByStylesheet(e);
|
|
252
|
+
};
|
|
253
|
+
n.forceRegisterDialog = function(e) {
|
|
254
|
+
if ((window.HTMLDialogElement || e.showModal) && console.warn("This browser already supports <dialog>, the polyfill may not work correctly", e), e.localName !== "dialog")
|
|
255
|
+
throw new Error("Failed to register dialog: The element is not a dialog.");
|
|
256
|
+
new _(
|
|
257
|
+
/** @type {!HTMLDialogElement} */
|
|
258
|
+
e
|
|
259
|
+
);
|
|
260
|
+
};
|
|
261
|
+
n.registerDialog = function(e) {
|
|
262
|
+
e.showModal || n.forceRegisterDialog(e);
|
|
263
|
+
};
|
|
264
|
+
n.DialogManager = function() {
|
|
265
|
+
this.pendingDialogStack = [];
|
|
266
|
+
var e = this.checkDOM_.bind(this);
|
|
267
|
+
this.overlay = document.createElement("div"), this.overlay.className = "_dialog_overlay", this.overlay.addEventListener("click", function(t) {
|
|
268
|
+
this.forwardTab_ = void 0, t.stopPropagation(), e([]);
|
|
269
|
+
}.bind(this)), this.handleKey_ = this.handleKey_.bind(this), this.handleFocus_ = this.handleFocus_.bind(this), this.zIndexLow_ = 1e5, this.zIndexHigh_ = 1e5 + 150, this.forwardTab_ = void 0, "MutationObserver" in window && (this.mo_ = new MutationObserver(function(t) {
|
|
270
|
+
var o = [];
|
|
271
|
+
t.forEach(function(i) {
|
|
272
|
+
for (var a = 0, r; r = i.removedNodes[a]; ++a) {
|
|
273
|
+
if (r instanceof Element)
|
|
274
|
+
r.localName === "dialog" && o.push(r);
|
|
275
|
+
else
|
|
276
|
+
continue;
|
|
277
|
+
o = o.concat(r.querySelectorAll("dialog"));
|
|
278
|
+
}
|
|
279
|
+
}), o.length && e(o);
|
|
280
|
+
}));
|
|
281
|
+
};
|
|
282
|
+
n.DialogManager.prototype.blockDocument = function() {
|
|
283
|
+
document.documentElement.addEventListener("focus", this.handleFocus_, !0), document.addEventListener("keydown", this.handleKey_), this.mo_ && this.mo_.observe(document, { childList: !0, subtree: !0 });
|
|
284
|
+
};
|
|
285
|
+
n.DialogManager.prototype.unblockDocument = function() {
|
|
286
|
+
document.documentElement.removeEventListener("focus", this.handleFocus_, !0), document.removeEventListener("keydown", this.handleKey_), this.mo_ && this.mo_.disconnect();
|
|
287
|
+
};
|
|
288
|
+
n.DialogManager.prototype.updateStacking = function() {
|
|
289
|
+
for (var e = this.zIndexHigh_, t = 0, o; o = this.pendingDialogStack[t]; ++t)
|
|
290
|
+
o.updateZIndex(--e, --e), t === 0 && (this.overlay.style.zIndex = --e);
|
|
291
|
+
var i = this.pendingDialogStack[0];
|
|
292
|
+
if (i) {
|
|
293
|
+
var a = i.dialog.parentNode || document.body;
|
|
294
|
+
a.appendChild(this.overlay);
|
|
295
|
+
} else
|
|
296
|
+
this.overlay.parentNode && this.overlay.parentNode.removeChild(this.overlay);
|
|
297
|
+
};
|
|
298
|
+
n.DialogManager.prototype.containedByTopDialog_ = function(e) {
|
|
299
|
+
for (; e = c(e); ) {
|
|
300
|
+
for (var t = 0, o; o = this.pendingDialogStack[t]; ++t)
|
|
301
|
+
if (o.dialog === e)
|
|
302
|
+
return t === 0;
|
|
303
|
+
e = e.parentElement;
|
|
304
|
+
}
|
|
305
|
+
return !1;
|
|
306
|
+
};
|
|
307
|
+
n.DialogManager.prototype.handleFocus_ = function(e) {
|
|
308
|
+
var t = e.composedPath ? e.composedPath()[0] : e.target;
|
|
309
|
+
if (!this.containedByTopDialog_(t) && document.activeElement !== document.documentElement && (e.preventDefault(), e.stopPropagation(), b(
|
|
310
|
+
/** @type {Element} */
|
|
311
|
+
t
|
|
312
|
+
), this.forwardTab_ !== void 0)) {
|
|
313
|
+
var o = this.pendingDialogStack[0], i = o.dialog, a = i.compareDocumentPosition(t);
|
|
314
|
+
return a & Node.DOCUMENT_POSITION_PRECEDING && (this.forwardTab_ ? o.focus_() : t !== document.documentElement && document.documentElement.focus()), !1;
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
n.DialogManager.prototype.handleKey_ = function(e) {
|
|
318
|
+
if (this.forwardTab_ = void 0, e.keyCode === 27) {
|
|
319
|
+
e.preventDefault(), e.stopPropagation();
|
|
320
|
+
var t = new d("cancel", {
|
|
321
|
+
bubbles: !1,
|
|
322
|
+
cancelable: !0
|
|
323
|
+
}), o = this.pendingDialogStack[0];
|
|
324
|
+
o && g(o.dialog, t) && o.dialog.close();
|
|
325
|
+
} else
|
|
326
|
+
e.keyCode === 9 && (this.forwardTab_ = !e.shiftKey);
|
|
327
|
+
};
|
|
328
|
+
n.DialogManager.prototype.checkDOM_ = function(e) {
|
|
329
|
+
var t = this.pendingDialogStack.slice();
|
|
330
|
+
t.forEach(function(o) {
|
|
331
|
+
e.indexOf(o.dialog) !== -1 ? o.downgradeModal() : o.maybeHideModal();
|
|
332
|
+
});
|
|
333
|
+
};
|
|
334
|
+
n.DialogManager.prototype.pushDialog = function(e) {
|
|
335
|
+
var t = (this.zIndexHigh_ - this.zIndexLow_) / 2 - 1;
|
|
336
|
+
return this.pendingDialogStack.length >= t ? !1 : (this.pendingDialogStack.unshift(e) === 1 && this.blockDocument(), this.updateStacking(), !0);
|
|
337
|
+
};
|
|
338
|
+
n.DialogManager.prototype.removeDialog = function(e) {
|
|
339
|
+
var t = this.pendingDialogStack.indexOf(e);
|
|
340
|
+
t !== -1 && (this.pendingDialogStack.splice(t, 1), this.pendingDialogStack.length === 0 && this.unblockDocument(), this.updateStacking());
|
|
341
|
+
};
|
|
342
|
+
n.dm = new n.DialogManager();
|
|
343
|
+
n.formSubmitter = null;
|
|
344
|
+
n.imagemapUseValue = null;
|
|
345
|
+
if (window.HTMLDialogElement === void 0) {
|
|
346
|
+
var p = document.createElement("form");
|
|
347
|
+
if (p.setAttribute("method", "dialog"), p.method !== "dialog") {
|
|
348
|
+
var l = Object.getOwnPropertyDescriptor(HTMLFormElement.prototype, "method");
|
|
349
|
+
if (l) {
|
|
350
|
+
var k = l.get;
|
|
351
|
+
l.get = function() {
|
|
352
|
+
return h(this) ? "dialog" : k.call(this);
|
|
353
|
+
};
|
|
354
|
+
var S = l.set;
|
|
355
|
+
l.set = function(e) {
|
|
356
|
+
return typeof e == "string" && e.toLowerCase() === "dialog" ? this.setAttribute("method", e) : S.call(this, e);
|
|
357
|
+
}, Object.defineProperty(HTMLFormElement.prototype, "method", l);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
document.addEventListener("click", function(e) {
|
|
361
|
+
if (n.formSubmitter = null, n.imagemapUseValue = null, !e.defaultPrevented) {
|
|
362
|
+
var t = (
|
|
363
|
+
/** @type {Element} */
|
|
364
|
+
e.target
|
|
365
|
+
);
|
|
366
|
+
if ("composedPath" in e) {
|
|
367
|
+
var o = e.composedPath();
|
|
368
|
+
t = o.shift() || t;
|
|
369
|
+
}
|
|
370
|
+
if (!(!t || !h(t.form))) {
|
|
371
|
+
var i = t.type === "submit" && ["button", "input"].indexOf(t.localName) > -1;
|
|
372
|
+
if (!i) {
|
|
373
|
+
if (!(t.localName === "input" && t.type === "image"))
|
|
374
|
+
return;
|
|
375
|
+
n.imagemapUseValue = e.offsetX + "," + e.offsetY;
|
|
376
|
+
}
|
|
377
|
+
var a = c(t);
|
|
378
|
+
a && (n.formSubmitter = t);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
}, !1), document.addEventListener("submit", function(e) {
|
|
382
|
+
var t = e.target, o = c(t);
|
|
383
|
+
if (!o) {
|
|
384
|
+
var i = y(e), a = i && i.getAttribute("formmethod") || t.getAttribute("method");
|
|
385
|
+
a === "dialog" && e.preventDefault();
|
|
386
|
+
}
|
|
387
|
+
});
|
|
388
|
+
var T = HTMLFormElement.prototype.submit, x = function() {
|
|
389
|
+
if (!h(this))
|
|
390
|
+
return T.call(this);
|
|
391
|
+
var e = c(this);
|
|
392
|
+
e && e.close();
|
|
393
|
+
};
|
|
394
|
+
HTMLFormElement.prototype.submit = x;
|
|
395
|
+
}
|
|
396
|
+
export {
|
|
397
|
+
n as default
|
|
398
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { CSSResult } from 'lit';
|
|
2
|
-
import type { DependentMap } from '@justeattakeaway/pie-webc-core';
|
|
3
2
|
import type { LitElement } from 'lit';
|
|
4
|
-
import {
|
|
3
|
+
import type { PropertyValues } from 'lit';
|
|
5
4
|
import type { TemplateResult } from 'lit';
|
|
6
5
|
import { Variant } from '@justeattakeaway/pie-button/src/defs.ts';
|
|
7
6
|
|
|
@@ -30,7 +29,7 @@ export declare const headingLevels: readonly ["h1", "h2", "h3", "h4", "h5", "h6"
|
|
|
30
29
|
|
|
31
30
|
export declare type ModalActionType = 'leading' | 'supporting';
|
|
32
31
|
|
|
33
|
-
export declare type ModalProps =
|
|
32
|
+
export declare type ModalProps = {
|
|
34
33
|
/**
|
|
35
34
|
* The ARIA labels used for the modal close and back buttons, as well as loading state.
|
|
36
35
|
*/
|
|
@@ -159,11 +158,10 @@ export declare class PieModal extends PieModal_base implements ModalProps {
|
|
|
159
158
|
private _dialog?;
|
|
160
159
|
private _backButtonClicked;
|
|
161
160
|
static styles: CSSResult;
|
|
162
|
-
constructor();
|
|
163
161
|
connectedCallback(): void;
|
|
164
162
|
disconnectedCallback(): void;
|
|
165
|
-
firstUpdated(changedProperties:
|
|
166
|
-
updated(changedProperties:
|
|
163
|
+
firstUpdated(changedProperties: PropertyValues<this>): Promise<void>;
|
|
164
|
+
updated(changedProperties: PropertyValues<this>): void;
|
|
167
165
|
/**
|
|
168
166
|
* Opens the dialog element and disables page scrolling
|
|
169
167
|
*/
|
|
@@ -249,7 +247,6 @@ export declare class PieModal extends PieModal_base implements ModalProps {
|
|
|
249
247
|
}
|
|
250
248
|
|
|
251
249
|
declare const PieModal_base: (new (...args: any[]) => {
|
|
252
|
-
dir: "ltr" | "rtl" | "auto";
|
|
253
250
|
isRTL: boolean;
|
|
254
251
|
}) & typeof LitElement;
|
|
255
252
|
|