@justeattakeaway/pie-modal 0.38.2 → 0.38.3
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.
|
@@ -90,9 +90,9 @@ function _(e) {
|
|
|
90
90
|
var t = new MutationObserver(this.maybeHideModal.bind(this));
|
|
91
91
|
t.observe(e, { attributes: !0, attributeFilter: ["open"] });
|
|
92
92
|
} else {
|
|
93
|
-
var o = !1, i = function() {
|
|
93
|
+
var o = !1, i = (function() {
|
|
94
94
|
o ? this.downgradeModal() : this.maybeHideModal(), o = !1;
|
|
95
|
-
}.bind(this), a, r = function(s) {
|
|
95
|
+
}).bind(this), a, r = function(s) {
|
|
96
96
|
if (s.target === e) {
|
|
97
97
|
var u = "DOMNodeRemoved";
|
|
98
98
|
o |= s.type.substr(0, u.length) === u, window.clearTimeout(a), a = window.setTimeout(i, 0);
|
|
@@ -264,9 +264,9 @@ n.registerDialog = function(e) {
|
|
|
264
264
|
n.DialogManager = function() {
|
|
265
265
|
this.pendingDialogStack = [];
|
|
266
266
|
var e = this.checkDOM_.bind(this);
|
|
267
|
-
this.overlay = document.createElement("div"), this.overlay.className = "_dialog_overlay", this.overlay.addEventListener("click", function(t) {
|
|
267
|
+
this.overlay = document.createElement("div"), this.overlay.className = "_dialog_overlay", this.overlay.addEventListener("click", (function(t) {
|
|
268
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) {
|
|
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
270
|
var o = [];
|
|
271
271
|
t.forEach(function(i) {
|
|
272
272
|
for (var a = 0, r; r = i.removedNodes[a]; ++a) {
|
package/dist/index.js
CHANGED
|
@@ -10,9 +10,9 @@ import "@justeattakeaway/pie-icons-webc/IconChevronRight";
|
|
|
10
10
|
import "@justeattakeaway/pie-spinner";
|
|
11
11
|
function W(n) {
|
|
12
12
|
if (Array.isArray(n)) {
|
|
13
|
-
for (var e = 0,
|
|
14
|
-
|
|
15
|
-
return
|
|
13
|
+
for (var e = 0, i = Array(n.length); e < n.length; e++)
|
|
14
|
+
i[e] = n[e];
|
|
15
|
+
return i;
|
|
16
16
|
} else
|
|
17
17
|
return Array.from(n);
|
|
18
18
|
}
|
|
@@ -25,59 +25,59 @@ if (typeof window < "u") {
|
|
|
25
25
|
};
|
|
26
26
|
window.addEventListener("testPassive", null, A), window.removeEventListener("testPassive", null, A);
|
|
27
27
|
}
|
|
28
|
-
var B = typeof window < "u" && window.navigator && window.navigator.platform && (/iP(ad|hone|od)/.test(window.navigator.platform) || window.navigator.platform === "MacIntel" && window.navigator.maxTouchPoints > 1),
|
|
29
|
-
return
|
|
30
|
-
return !!(
|
|
28
|
+
var B = typeof window < "u" && window.navigator && window.navigator.platform && (/iP(ad|hone|od)/.test(window.navigator.platform) || window.navigator.platform === "MacIntel" && window.navigator.maxTouchPoints > 1), g = [], k = !1, S = -1, h = void 0, u = void 0, L = function(e) {
|
|
29
|
+
return g.some(function(i) {
|
|
30
|
+
return !!(i.options.allowTouchMove && i.options.allowTouchMove(e));
|
|
31
31
|
});
|
|
32
|
-
},
|
|
33
|
-
var
|
|
34
|
-
return L(
|
|
32
|
+
}, w = function(e) {
|
|
33
|
+
var i = e || window.event;
|
|
34
|
+
return L(i.target) || i.touches.length > 1 ? !0 : (i.preventDefault && i.preventDefault(), !1);
|
|
35
35
|
}, Y = function(e) {
|
|
36
36
|
if (u === void 0) {
|
|
37
|
-
var
|
|
38
|
-
|
|
37
|
+
var i = !!e && e.reserveScrollBarGap === !0, t = window.innerWidth - document.documentElement.clientWidth;
|
|
38
|
+
i && t > 0 && (u = document.body.style.paddingRight, document.body.style.paddingRight = t + "px");
|
|
39
39
|
}
|
|
40
40
|
h === void 0 && (h = document.body.style.overflow, document.body.style.overflow = "hidden");
|
|
41
41
|
}, V = function() {
|
|
42
42
|
u !== void 0 && (document.body.style.paddingRight = u, u = void 0), h !== void 0 && (document.body.style.overflow = h, h = void 0);
|
|
43
43
|
}, q = function(e) {
|
|
44
44
|
return e ? e.scrollHeight - e.scrollTop <= e.clientHeight : !1;
|
|
45
|
-
}, H = function(e,
|
|
46
|
-
var
|
|
47
|
-
return L(e.target) ? !1 :
|
|
48
|
-
}, U = function(e,
|
|
45
|
+
}, H = function(e, i) {
|
|
46
|
+
var t = e.targetTouches[0].clientY - S;
|
|
47
|
+
return L(e.target) ? !1 : i && i.scrollTop === 0 && t > 0 || q(i) && t < 0 ? w(e) : (e.stopPropagation(), !0);
|
|
48
|
+
}, U = function(e, i) {
|
|
49
49
|
if (!e) {
|
|
50
50
|
console.error("disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.");
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
53
|
-
if (!
|
|
54
|
-
return
|
|
53
|
+
if (!g.some(function(o) {
|
|
54
|
+
return o.targetElement === e;
|
|
55
55
|
})) {
|
|
56
|
-
var
|
|
56
|
+
var t = {
|
|
57
57
|
targetElement: e,
|
|
58
|
-
options:
|
|
58
|
+
options: i || {}
|
|
59
59
|
};
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}, e.ontouchmove = function(
|
|
63
|
-
|
|
64
|
-
},
|
|
60
|
+
g = [].concat(W(g), [t]), B ? (e.ontouchstart = function(o) {
|
|
61
|
+
o.targetTouches.length === 1 && (S = o.targetTouches[0].clientY);
|
|
62
|
+
}, e.ontouchmove = function(o) {
|
|
63
|
+
o.targetTouches.length === 1 && H(o, e);
|
|
64
|
+
}, k || (document.addEventListener("touchmove", w, C ? { passive: !1 } : void 0), k = !0)) : Y(i);
|
|
65
65
|
}
|
|
66
66
|
}, K = function(e) {
|
|
67
67
|
if (!e) {
|
|
68
68
|
console.error("enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.");
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
|
-
|
|
72
|
-
return
|
|
73
|
-
}), B ? (e.ontouchstart = null, e.ontouchmove = null,
|
|
71
|
+
g = g.filter(function(i) {
|
|
72
|
+
return i.targetElement !== e;
|
|
73
|
+
}), B ? (e.ontouchstart = null, e.ontouchmove = null, k && g.length === 0 && (document.removeEventListener("touchmove", w, C ? { passive: !1 } : void 0), k = !1)) : g.length || V();
|
|
74
74
|
};
|
|
75
|
-
const G = `dialog{position:absolute;left:0;right:0;width:-moz-fit-content;width:-webkit-fit-content;width:fit-content;height:-moz-fit-content;height:-webkit-fit-content;height:fit-content;margin:auto;border:solid;padding:1em;background:white;color:#000;display:block}dialog:not([open]){display:none}dialog+.backdrop{position:fixed;top:0;right:0;bottom:0;left:0;background:rgba(0,0,0,.1)}._dialog_overlay{position:fixed;top:0;right:0;bottom:0;left:0}dialog.fixed{position:fixed;top:50%;transform:translateY(-50%)}*,*:before,*:after{box-sizing:border-box}.c-modal{--modal-size-s: 450px;--modal-size-m: 600px;--modal-size-l: 1080px;--modal-border-radius: var(--dt-radius-rounded-d);--modal-font: var(--dt-font-interactive-m-family);--modal-bg-color: var(--dt-color-container-default);--modal-elevation: var(--dt-elevation-04);border-radius:var(--modal-border-radius);border:none;box-shadow:var(--modal-elevation);font-family:var(--modal-font);background-color:var(--modal-bg-color);padding:0;--modal-margin-none: var(--dt-spacing-none);--modal-margin-small: var(--dt-spacing-g);--modal-margin-large: var(--dt-spacing-j);--modal-margin-block: var(--modal-margin-small);--modal-block-size: fit-content;--modal-inline-size: 75%;--modal-max-block-size: calc(100vh - calc(var(--modal-margin-block) * 2));--modal-max-inline-size: var(--modal-size-m);block-size:var(--modal-block-size);inline-size:var(--modal-inline-size);max-block-size:var(--modal-max-block-size);max-inline-size:var(--modal-max-inline-size)}.c-modal:focus-visible{outline:none}@media (max-width: 767px){.c-modal pie-icon-button{--btn-dimension: 40px}}.c-modal[open]{display:flex;flex-direction:column}@media (min-width: 768px){.c-modal{--modal-margin-block: var(--modal-margin-large)}}.c-modal[size=small]{--modal-max-inline-size: var(--modal-size-s)}@media (min-width: 768px){.c-modal[size=small]{--modal-margin-block: var(--modal-margin-large)}}.c-modal[size=large]{--modal-inline-size: 75%;--modal-max-inline-size: var(--modal-size-l);--modal-margin-block: var(--modal-margin-large)}@media (max-width: 767px){.c-modal[size=large],.c-modal[size=medium][isfullwidthbelowmid]{--modal-margin-block: var(--modal-margin-none);--modal-border-radius: var(--dt-radius-rounded-none);--modal-block-size: 100%;--modal-inline-size: 100%;--modal-max-inline-size: 100%}.c-modal[size=large]>.c-modal-scrollContainer,.c-modal[size=medium][isfullwidthbelowmid]>.c-modal-scrollContainer{block-size:100%}}.c-modal[position=top]{margin-block-start:var(--dt-spacing-j);max-block-size:calc(100% - var(--dt-spacing-j) * 2)}@media (max-width: 767px){.c-modal[position=top][size=large],.c-modal[position=top][isfullwidthbelowmid][size=medium]{margin-block-start:var(--dt-spacing-none);max-block-size:100%}}.c-modal::backdrop{background:rgba(0,0,0,.55)}.c-modal .c-modal-footer{--modal-button-spacing: var(--dt-spacing-d);--modal-footer-padding: var(--dt-spacing-d);display:flex;flex-flow:row-reverse;flex-wrap:wrap;gap:var(--modal-button-spacing);padding:var(--modal-footer-padding)}@media (min-width: 768px){.c-modal .c-modal-footer{--modal-footer-padding: var(--dt-spacing-e)}}@media (max-width: 767px){.c-modal[hasstackedactions] .c-modal-footer{flex-direction:column}}.c-modal .c-modal-header{display:grid;grid-template-areas:"back heading close";grid-template-columns:minmax(0,max-content) minmax(0,1fr) minmax(0,max-content);align-items:start}.c-modal .c-modal-heading{--modal-header-font-size: calc(var(--dt-font-heading-m-size--narrow) * 1px);--modal-header-font-line-height: calc(var(--dt-font-heading-m-line-height--narrow) * 1px);--modal-header-font-weight: var(--dt-font-heading-m-weight);font-size:var(--modal-header-font-size);line-height:var(--modal-header-font-line-height);font-weight:var(--modal-header-font-weight);margin:0;grid-area:heading;margin-inline:var(--dt-spacing-d);margin-block:14px}@media (min-width: 768px){.c-modal .c-modal-heading{--modal-header-font-size: calc(var(--dt-font-heading-m-size--wide) * 1px);--modal-header-font-line-height: calc(var(--dt-font-heading-m-line-height--wide) * 1px);margin-inline:var(--dt-spacing-e);margin-block:20px}}.c-modal[hasbackbutton] .c-modal-heading{margin-inline-start:var(--dt-spacing-b)}@media (min-width: 768px){.c-modal[hasbackbutton] .c-modal-heading{margin-inline-start:var(--dt-spacing-c)}}.c-modal[isdismissible] .c-modal-heading{margin-inline-end:var(--dt-spacing-d)}@media (min-width: 768px){.c-modal[isdismissible] .c-modal-heading{margin-inline-end:var(--dt-spacing-e)}}.c-modal .c-modal-backBtn{grid-area:back;margin-block:var(--dt-spacing-b);margin-inline:var(--dt-spacing-b)
|
|
75
|
+
const G = `dialog{position:absolute;left:0;right:0;width:-moz-fit-content;width:-webkit-fit-content;width:fit-content;height:-moz-fit-content;height:-webkit-fit-content;height:fit-content;margin:auto;border:solid;padding:1em;background:white;color:#000;display:block}dialog:not([open]){display:none}dialog+.backdrop{position:fixed;top:0;right:0;bottom:0;left:0;background:rgba(0,0,0,.1)}._dialog_overlay{position:fixed;top:0;right:0;bottom:0;left:0}dialog.fixed{position:fixed;top:50%;transform:translateY(-50%)}*,*:before,*:after{box-sizing:border-box}.c-modal{--modal-size-s: 450px;--modal-size-m: 600px;--modal-size-l: 1080px;--modal-border-radius: var(--dt-radius-rounded-d);--modal-font: var(--dt-font-interactive-m-family);--modal-bg-color: var(--dt-color-container-default);--modal-elevation: var(--dt-elevation-04);border-radius:var(--modal-border-radius);border:none;box-shadow:var(--modal-elevation);font-family:var(--modal-font);background-color:var(--modal-bg-color);padding:0;--modal-margin-none: var(--dt-spacing-none);--modal-margin-small: var(--dt-spacing-g);--modal-margin-large: var(--dt-spacing-j);--modal-margin-block: var(--modal-margin-small);--modal-block-size: fit-content;--modal-inline-size: 75%;--modal-max-block-size: calc(100vh - calc(var(--modal-margin-block) * 2));--modal-max-inline-size: var(--modal-size-m);block-size:var(--modal-block-size);inline-size:var(--modal-inline-size);max-block-size:var(--modal-max-block-size);max-inline-size:var(--modal-max-inline-size)}.c-modal:focus-visible{outline:none}@media (max-width: 767px){.c-modal pie-icon-button{--btn-dimension: 40px}}.c-modal[open]{display:flex;flex-direction:column}@media (min-width: 768px){.c-modal{--modal-margin-block: var(--modal-margin-large)}}.c-modal[size=small]{--modal-max-inline-size: var(--modal-size-s)}@media (min-width: 768px){.c-modal[size=small]{--modal-margin-block: var(--modal-margin-large)}}.c-modal[size=large]{--modal-inline-size: 75%;--modal-max-inline-size: var(--modal-size-l);--modal-margin-block: var(--modal-margin-large)}@media (max-width: 767px){.c-modal[size=large],.c-modal[size=medium][isfullwidthbelowmid]{--modal-margin-block: var(--modal-margin-none);--modal-border-radius: var(--dt-radius-rounded-none);--modal-block-size: 100%;--modal-inline-size: 100%;--modal-max-inline-size: 100%}.c-modal[size=large]>.c-modal-scrollContainer,.c-modal[size=medium][isfullwidthbelowmid]>.c-modal-scrollContainer{block-size:100%}}.c-modal[position=top]{margin-block-start:var(--dt-spacing-j);max-block-size:calc(100% - var(--dt-spacing-j) * 2)}@media (max-width: 767px){.c-modal[position=top][size=large],.c-modal[position=top][isfullwidthbelowmid][size=medium]{margin-block-start:var(--dt-spacing-none);max-block-size:100%}}.c-modal::backdrop{background:rgba(0,0,0,.55)}.c-modal .c-modal-footer{--modal-button-spacing: var(--dt-spacing-d);--modal-footer-padding: var(--dt-spacing-d);display:flex;flex-flow:row-reverse;flex-wrap:wrap;gap:var(--modal-button-spacing);padding:var(--modal-footer-padding)}@media (min-width: 768px){.c-modal .c-modal-footer{--modal-footer-padding: var(--dt-spacing-e)}}@media (max-width: 767px){.c-modal[hasstackedactions] .c-modal-footer{flex-direction:column}}.c-modal .c-modal-header{display:grid;grid-template-areas:"back heading close";grid-template-columns:minmax(0,max-content) minmax(0,1fr) minmax(0,max-content);align-items:start}.c-modal .c-modal-heading{--modal-header-font-size: calc(var(--dt-font-heading-m-size--narrow) * 1px);--modal-header-font-line-height: calc(var(--dt-font-heading-m-line-height--narrow) * 1px);--modal-header-font-weight: var(--dt-font-heading-m-weight);font-size:var(--modal-header-font-size);line-height:var(--modal-header-font-line-height);font-weight:var(--modal-header-font-weight);margin:0;grid-area:heading;margin-inline-start:var(--dt-spacing-d);margin-inline-end:var(--dt-spacing-d);margin-block-start:14px;margin-block-end:14px}@media (min-width: 768px){.c-modal .c-modal-heading{--modal-header-font-size: calc(var(--dt-font-heading-m-size--wide) * 1px);--modal-header-font-line-height: calc(var(--dt-font-heading-m-line-height--wide) * 1px);margin-inline-start:var(--dt-spacing-e);margin-inline-end:var(--dt-spacing-e);margin-block-start:20px;margin-block-end:20px}}.c-modal[hasbackbutton] .c-modal-heading{margin-inline-start:var(--dt-spacing-b)}@media (min-width: 768px){.c-modal[hasbackbutton] .c-modal-heading{margin-inline-start:var(--dt-spacing-c)}}.c-modal[isdismissible] .c-modal-heading{margin-inline-end:var(--dt-spacing-d)}@media (min-width: 768px){.c-modal[isdismissible] .c-modal-heading{margin-inline-end:var(--dt-spacing-e)}}.c-modal .c-modal-backBtn{grid-area:back;margin-block-start:var(--dt-spacing-b);margin-block-end:var(--dt-spacing-b);margin-inline-start:var(--dt-spacing-b);margin-inline-end:var(--dt-spacing-none)}@media (min-width: 768px){.c-modal .c-modal-backBtn{margin-block-start:var(--dt-spacing-c);margin-block-end:var(--dt-spacing-c);margin-inline-start:var(--dt-spacing-c);margin-inline-end:var(--dt-spacing-none)}}.c-modal .c-modal-closeBtn{grid-area:close;margin-block-start:var(--dt-spacing-b);margin-block-end:var(--dt-spacing-b);margin-inline-start:var(--dt-spacing-none);margin-inline-end:var(--dt-spacing-b)}@media (min-width: 768px){.c-modal .c-modal-closeBtn{margin-block-start:var(--dt-spacing-c);margin-block-end:var(--dt-spacing-c);margin-inline-start:var(--dt-spacing-none);margin-inline-end:var(--dt-spacing-c)}}.c-modal .c-modal-content{--modal-content-font-size: calc(var(--dt-font-size-16) * 1px);--modal-content-font-weight: var(--dt-font-weight-regular);--modal-content-line-height: calc(var(--dt-font-size-16-line-height) * 1px);--modal-content-padding-block: var(--dt-spacing-a);--modal-content-padding-inline: var(--dt-spacing-d);position:relative;min-block-size:var(--dt-spacing-j);font-size:var(--modal-content-font-size);line-height:var(--modal-content-line-height);font-weight:var(--modal-content-font-weight);padding-inline-start:var(--modal-content-padding-inline);padding-inline-end:var(--modal-content-padding-inline);padding-block-start:var(--modal-content-padding-block);padding-block-end:var(--modal-content-padding-block);flex-grow:1}@media (min-width: 768px){.c-modal .c-modal-content{--modal-content-padding-inline: var(--dt-spacing-e)}}.c-modal .c-modal-content--scrollable{background:linear-gradient(to bottom,transparent,var(--dt-color-container-default) 75%) center bottom,linear-gradient(transparent,var(--dt-color-border-strong)) center bottom;background-repeat:no-repeat;background-size:100% 48px,100% 12px;background-attachment:local,scroll}.c-modal>.c-modal-scrollContainer{display:flex;flex-direction:column;overflow-y:auto;--bg-scroll-end: linear-gradient(rgba(255, 255, 255, 0), var(--dt-color-container-default) 70%) 0 100%;--bg-scroll-bottom: radial-gradient(farthest-corner at 50% 100%, rgba(0, 0, 0, .3), rgba(0, 0, 0, 0)) 0 100%;--bg-size-scroll-end: 100% 40px;--bg-size-scroll-bottom: 100% 8px;background:var(--bg-scroll-end),var(--bg-scroll-bottom);background-repeat:no-repeat;background-size:var(--bg-size-scroll-end),var(--bg-size-scroll-bottom);background-attachment:local,scroll}.c-modal>.c-modal-scrollContainer .c-modal-content{flex-shrink:0}.c-modal[isfooterpinned] .c-modal-content{overflow-y:auto}.c-modal[isLoading] .c-modal-content pie-spinner{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%)}.c-modal[isLoading] .c-modal-content .c-modal-contentInner{display:none}@supports not (aspect-ratio: 1/1){.c-modal .c-modal-scrollContainer{background:none}}
|
|
76
76
|
`, X = ["h1", "h2", "h3", "h4", "h5", "h6"], J = ["small", "medium", "large"], Q = ["top", "center"], x = "pie-modal-close", b = "pie-modal-open", _ = "pie-modal-back", Z = "pie-modal-leading-action-click", ee = "pie-modal-supporting-action-click";
|
|
77
|
-
var
|
|
78
|
-
for (var
|
|
79
|
-
(c = n[r]) && (
|
|
80
|
-
return
|
|
77
|
+
var ie = Object.defineProperty, te = Object.getOwnPropertyDescriptor, l = (n, e, i, t) => {
|
|
78
|
+
for (var o = t > 1 ? void 0 : t ? te(e, i) : e, r = n.length - 1, c; r >= 0; r--)
|
|
79
|
+
(c = n[r]) && (o = (t ? c(e, i, o) : c(o)) || o);
|
|
80
|
+
return t && o && ie(e, i, o), o;
|
|
81
81
|
};
|
|
82
82
|
const f = "pie-modal";
|
|
83
83
|
class a extends I(P) {
|
|
@@ -88,15 +88,15 @@ class a extends I(P) {
|
|
|
88
88
|
var v;
|
|
89
89
|
if (!this.isDismissible)
|
|
90
90
|
return;
|
|
91
|
-
const
|
|
92
|
-
top:
|
|
93
|
-
bottom:
|
|
91
|
+
const i = (v = this._dialog) == null ? void 0 : v.getBoundingClientRect(), {
|
|
92
|
+
top: t = 0,
|
|
93
|
+
bottom: o = 0,
|
|
94
94
|
left: r = 0,
|
|
95
95
|
right: c = 0
|
|
96
|
-
} =
|
|
97
|
-
if (
|
|
96
|
+
} = i || {};
|
|
97
|
+
if (t === 0 && o === 0 && r === 0 && c === 0)
|
|
98
98
|
return;
|
|
99
|
-
(e.clientY <
|
|
99
|
+
(e.clientY < t || e.clientY > o || e.clientX < r || e.clientX > c) && (this.isOpen = !1);
|
|
100
100
|
};
|
|
101
101
|
}
|
|
102
102
|
connectedCallback() {
|
|
@@ -106,7 +106,7 @@ class a extends I(P) {
|
|
|
106
106
|
document.removeEventListener(b, (e) => this._handleModalOpened(e)), document.removeEventListener(x, (e) => this._handleModalClosed(e)), document.removeEventListener(_, (e) => this._handleModalClosed(e)), super.disconnectedCallback();
|
|
107
107
|
}
|
|
108
108
|
async firstUpdated(e) {
|
|
109
|
-
super.firstUpdated(e), this._dialog && ((await import("./dialog-polyfill.esm-
|
|
109
|
+
super.firstUpdated(e), this._dialog && ((await import("./dialog-polyfill.esm-209f54f8.js").then((t) => t.default)).registerDialog(this._dialog), this._dialog.addEventListener("cancel", (t) => this._handleDialogCancelEvent(t)), this._dialog.addEventListener("close", () => {
|
|
110
110
|
this.isOpen = !1;
|
|
111
111
|
})), this._handleModalOpenStateOnFirstRender(e);
|
|
112
112
|
}
|
|
@@ -117,11 +117,11 @@ class a extends I(P) {
|
|
|
117
117
|
* Opens the dialog element and disables page scrolling
|
|
118
118
|
*/
|
|
119
119
|
_handleModalOpened(e) {
|
|
120
|
-
var
|
|
121
|
-
const { targetModal:
|
|
122
|
-
if (
|
|
123
|
-
const
|
|
124
|
-
if (
|
|
120
|
+
var t, o, r, c;
|
|
121
|
+
const { targetModal: i } = e.detail;
|
|
122
|
+
if (i === this) {
|
|
123
|
+
const p = (t = this._dialog) == null ? void 0 : t.querySelector(".c-modal-scrollContainer");
|
|
124
|
+
if (p && U(p), (o = this._dialog) != null && o.hasAttribute("open") || !((r = this._dialog) != null && r.isConnected))
|
|
125
125
|
return;
|
|
126
126
|
(c = this._dialog) == null || c.showModal();
|
|
127
127
|
}
|
|
@@ -130,11 +130,11 @@ class a extends I(P) {
|
|
|
130
130
|
* Closes the dialog element and re-enables page scrolling
|
|
131
131
|
*/
|
|
132
132
|
_handleModalClosed(e) {
|
|
133
|
-
var
|
|
134
|
-
const { targetModal:
|
|
135
|
-
if (
|
|
136
|
-
const r = (
|
|
137
|
-
r && K(r), (
|
|
133
|
+
var t, o;
|
|
134
|
+
const { targetModal: i } = e.detail;
|
|
135
|
+
if (i === this) {
|
|
136
|
+
const r = (t = this._dialog) == null ? void 0 : t.querySelector(".c-modal-scrollContainer");
|
|
137
|
+
r && K(r), (o = this._dialog) == null || o.close(), this._returnFocus();
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
// Handles the value of the isOpen property on first render of the component
|
|
@@ -143,21 +143,21 @@ class a extends I(P) {
|
|
|
143
143
|
}
|
|
144
144
|
// Handles changes to the modal isOpen property by dispatching any appropriate events
|
|
145
145
|
_handleModalOpenStateChanged(e) {
|
|
146
|
-
const
|
|
147
|
-
|
|
146
|
+
const i = e.get("isOpen");
|
|
147
|
+
i !== void 0 && (i ? this._backButtonClicked ? (this._backButtonClicked = !1, this._dispatchModalCustomEvent(_)) : this._dispatchModalCustomEvent(x) : this._dispatchModalCustomEvent(b));
|
|
148
148
|
}
|
|
149
149
|
_handleActionClick(e) {
|
|
150
|
-
var
|
|
151
|
-
e === "leading" ? ((
|
|
150
|
+
var i, t;
|
|
151
|
+
e === "leading" ? ((i = this._dialog) == null || i.close("leading"), this._dispatchModalCustomEvent(Z)) : e === "supporting" && ((t = this._dialog) == null || t.close("supporting"), this._dispatchModalCustomEvent(ee));
|
|
152
152
|
}
|
|
153
153
|
/**
|
|
154
154
|
* Return focus to the specified element, providing the selector is valid
|
|
155
155
|
* and the chosen element can be found.
|
|
156
156
|
*/
|
|
157
157
|
_returnFocus() {
|
|
158
|
-
var
|
|
159
|
-
const e = (
|
|
160
|
-
e && ((
|
|
158
|
+
var i, t;
|
|
159
|
+
const e = (i = this.returnFocusAfterCloseSelector) == null ? void 0 : i.trim();
|
|
160
|
+
e && ((t = document.querySelector(e)) == null || t.focus());
|
|
161
161
|
}
|
|
162
162
|
/**
|
|
163
163
|
* Template for the close button element. Called within the
|
|
@@ -210,11 +210,11 @@ class a extends I(P) {
|
|
|
210
210
|
* @private
|
|
211
211
|
*/
|
|
212
212
|
renderLeadingAction() {
|
|
213
|
-
const { text: e, variant:
|
|
213
|
+
const { text: e, variant: i = "primary", ariaLabel: t } = this.leadingAction;
|
|
214
214
|
return e ? m`
|
|
215
215
|
<pie-button
|
|
216
|
-
variant="${
|
|
217
|
-
aria-label="${
|
|
216
|
+
variant="${i}"
|
|
217
|
+
aria-label="${t || s}"
|
|
218
218
|
type="submit"
|
|
219
219
|
?isFullWidth="${this.hasStackedActions}"
|
|
220
220
|
@click="${() => this._handleActionClick("leading")}"
|
|
@@ -235,11 +235,11 @@ class a extends I(P) {
|
|
|
235
235
|
* @private
|
|
236
236
|
*/
|
|
237
237
|
renderSupportingAction() {
|
|
238
|
-
const { text: e, variant:
|
|
238
|
+
const { text: e, variant: i = "ghost", ariaLabel: t } = this.supportingAction;
|
|
239
239
|
return e ? this.leadingAction ? m`
|
|
240
240
|
<pie-button
|
|
241
|
-
variant="${
|
|
242
|
-
aria-label="${
|
|
241
|
+
variant="${i}"
|
|
242
|
+
aria-label="${t || s}"
|
|
243
243
|
type="reset"
|
|
244
244
|
?isFullWidth="${this.hasStackedActions}"
|
|
245
245
|
@click="${() => this._handleActionClick("supporting")}"
|
|
@@ -268,12 +268,12 @@ class a extends I(P) {
|
|
|
268
268
|
render() {
|
|
269
269
|
const {
|
|
270
270
|
aria: e,
|
|
271
|
-
hasBackButton:
|
|
272
|
-
hasStackedActions:
|
|
273
|
-
heading:
|
|
271
|
+
hasBackButton: i,
|
|
272
|
+
hasStackedActions: t,
|
|
273
|
+
heading: o,
|
|
274
274
|
headingLevel: r = "h2",
|
|
275
275
|
isDismissible: c,
|
|
276
|
-
isFooterPinned:
|
|
276
|
+
isFooterPinned: p,
|
|
277
277
|
isFullWidthBelowMid: v,
|
|
278
278
|
isLoading: y,
|
|
279
279
|
leadingAction: M,
|
|
@@ -288,24 +288,24 @@ class a extends I(P) {
|
|
|
288
288
|
size="${E || "medium"}"
|
|
289
289
|
position="${$ || "center"}"
|
|
290
290
|
?hasActions=${M || D}
|
|
291
|
-
?hasBackButton=${
|
|
292
|
-
?hasStackedActions=${
|
|
291
|
+
?hasBackButton=${i}
|
|
292
|
+
?hasStackedActions=${t}
|
|
293
293
|
?isDismissible=${c}
|
|
294
|
-
?isFooterPinned=${
|
|
294
|
+
?isFooterPinned=${p}
|
|
295
295
|
?isFullWidthBelowMid=${v}
|
|
296
296
|
?isLoading=${y}
|
|
297
297
|
aria-busy="${y ? "true" : "false"}"
|
|
298
298
|
aria-label="${y && (e == null ? void 0 : e.loading) || s}"
|
|
299
299
|
data-test-id="pie-modal">
|
|
300
300
|
<header class="c-modal-header">
|
|
301
|
-
${
|
|
301
|
+
${i ? this.renderBackButton() : s}
|
|
302
302
|
<${O} class="c-modal-heading">
|
|
303
|
-
${
|
|
303
|
+
${o}
|
|
304
304
|
</${O}>
|
|
305
305
|
${c ? this.renderCloseButton() : s}
|
|
306
306
|
</header>
|
|
307
307
|
${// We need to wrap the remaining content in a shared scrollable container if the footer is not pinned
|
|
308
|
-
|
|
308
|
+
p ? this.renderModalContentAndFooter() : m`
|
|
309
309
|
<div class="c-modal-scrollContainer">
|
|
310
310
|
${this.renderModalContentAndFooter()}
|
|
311
311
|
</div>
|
|
@@ -324,12 +324,12 @@ class a extends I(P) {
|
|
|
324
324
|
* @param {string} eventType
|
|
325
325
|
*/
|
|
326
326
|
_dispatchModalCustomEvent(e) {
|
|
327
|
-
const
|
|
327
|
+
const i = new CustomEvent(e, {
|
|
328
328
|
bubbles: !0,
|
|
329
329
|
composed: !0,
|
|
330
330
|
detail: { targetModal: this }
|
|
331
331
|
});
|
|
332
|
-
this.dispatchEvent(
|
|
332
|
+
this.dispatchEvent(i);
|
|
333
333
|
}
|
|
334
334
|
}
|
|
335
335
|
a.styles = T(G);
|
package/package.json
CHANGED
package/src/modal.scss
CHANGED
|
@@ -173,14 +173,18 @@
|
|
|
173
173
|
margin: 0;
|
|
174
174
|
grid-area: heading;
|
|
175
175
|
|
|
176
|
-
margin-inline: var(--dt-spacing-d);
|
|
177
|
-
margin-
|
|
176
|
+
margin-inline-start: var(--dt-spacing-d);
|
|
177
|
+
margin-inline-end: var(--dt-spacing-d);
|
|
178
|
+
margin-block-start: 14px;
|
|
179
|
+
margin-block-end: 14px; // This is deliberately not a custom property
|
|
178
180
|
|
|
179
181
|
@media (min-width: $breakpoint-wide) {
|
|
180
182
|
--modal-header-font-size: calc(var(--dt-font-heading-m-size--wide) * 1px);
|
|
181
183
|
--modal-header-font-line-height: calc(var(--dt-font-heading-m-line-height--wide) * 1px);
|
|
182
|
-
margin-inline: var(--dt-spacing-e);
|
|
183
|
-
margin-
|
|
184
|
+
margin-inline-start: var(--dt-spacing-e);
|
|
185
|
+
margin-inline-end: var(--dt-spacing-e);
|
|
186
|
+
margin-block-start: 20px;
|
|
187
|
+
margin-block-end: 20px; // This is deliberately not a custom property
|
|
184
188
|
}
|
|
185
189
|
}
|
|
186
190
|
|
|
@@ -204,23 +208,31 @@
|
|
|
204
208
|
|
|
205
209
|
& .c-modal-backBtn {
|
|
206
210
|
grid-area: back;
|
|
207
|
-
margin-block: var(--dt-spacing-b);
|
|
208
|
-
margin-
|
|
211
|
+
margin-block-start: var(--dt-spacing-b);
|
|
212
|
+
margin-block-end: var(--dt-spacing-b);
|
|
213
|
+
margin-inline-start: var(--dt-spacing-b);
|
|
214
|
+
margin-inline-end: var(--dt-spacing-none);
|
|
209
215
|
|
|
210
216
|
@media (min-width: $breakpoint-wide) {
|
|
211
|
-
margin-block: var(--dt-spacing-c);
|
|
212
|
-
margin-
|
|
217
|
+
margin-block-start: var(--dt-spacing-c);
|
|
218
|
+
margin-block-end: var(--dt-spacing-c);
|
|
219
|
+
margin-inline-start: var(--dt-spacing-c);
|
|
220
|
+
margin-inline-end: var(--dt-spacing-none);
|
|
213
221
|
}
|
|
214
222
|
}
|
|
215
223
|
|
|
216
224
|
& .c-modal-closeBtn {
|
|
217
225
|
grid-area: close;
|
|
218
|
-
margin-block: var(--dt-spacing-b);
|
|
219
|
-
margin-
|
|
226
|
+
margin-block-start: var(--dt-spacing-b);
|
|
227
|
+
margin-block-end: var(--dt-spacing-b);
|
|
228
|
+
margin-inline-start: var(--dt-spacing-none);
|
|
229
|
+
margin-inline-end: var(--dt-spacing-b);
|
|
220
230
|
|
|
221
231
|
@media (min-width: $breakpoint-wide) {
|
|
222
|
-
margin-block: var(--dt-spacing-c);
|
|
223
|
-
margin-
|
|
232
|
+
margin-block-start: var(--dt-spacing-c);
|
|
233
|
+
margin-block-end: var(--dt-spacing-c);
|
|
234
|
+
margin-inline-start: var(--dt-spacing-none);
|
|
235
|
+
margin-inline-end: var(--dt-spacing-c);
|
|
224
236
|
}
|
|
225
237
|
}
|
|
226
238
|
|
|
@@ -243,8 +255,10 @@
|
|
|
243
255
|
line-height: var(--modal-content-line-height);
|
|
244
256
|
font-weight: var(--modal-content-font-weight);
|
|
245
257
|
|
|
246
|
-
padding-inline: var(--modal-content-padding-inline);
|
|
247
|
-
padding-
|
|
258
|
+
padding-inline-start: var(--modal-content-padding-inline);
|
|
259
|
+
padding-inline-end: var(--modal-content-padding-inline);
|
|
260
|
+
padding-block-start: var(--modal-content-padding-block);
|
|
261
|
+
padding-block-end: var(--modal-content-padding-block);
|
|
248
262
|
flex-grow: 1;
|
|
249
263
|
|
|
250
264
|
&--scrollable {
|