@justeattakeaway/pie-modal 0.45.0 → 0.46.1
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/custom-elements.json +22 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +178 -168
- package/dist/react.d.ts +12 -0
- package/package.json +5 -5
- package/src/index.ts +60 -41
- package/src/modal.scss +17 -20
package/custom-elements.json
CHANGED
|
@@ -460,6 +460,28 @@
|
|
|
460
460
|
},
|
|
461
461
|
"description": "Renders the \"supportingAction\" button if the text is provided.\nYou cannot have a supporting action without a leading action.\n\nIf either `supportingAction.text` or `leadingAction.text` are not provided, the button is not rendered.\nIf `supportingAction.variant` is not provided, the default value of \"ghost\" is used.\nThe (optional) aria-label is read from `supportingAction.ariaLabel`."
|
|
462
462
|
},
|
|
463
|
+
{
|
|
464
|
+
"kind": "method",
|
|
465
|
+
"name": "renderModalFooter",
|
|
466
|
+
"privacy": "private",
|
|
467
|
+
"return": {
|
|
468
|
+
"type": {
|
|
469
|
+
"text": "TemplateResult | typeof nothing"
|
|
470
|
+
}
|
|
471
|
+
},
|
|
472
|
+
"description": "Renders the modal footer if a leading action is provided.\nAdditionally renders the supporting action if it is provided."
|
|
473
|
+
},
|
|
474
|
+
{
|
|
475
|
+
"kind": "method",
|
|
476
|
+
"name": "renderLoadingSpinner",
|
|
477
|
+
"privacy": "private",
|
|
478
|
+
"return": {
|
|
479
|
+
"type": {
|
|
480
|
+
"text": "TemplateResult | typeof nothing"
|
|
481
|
+
}
|
|
482
|
+
},
|
|
483
|
+
"description": "Renders the loading spinner if `isLoading` is true."
|
|
484
|
+
},
|
|
463
485
|
{
|
|
464
486
|
"kind": "method",
|
|
465
487
|
"name": "renderModalContentAndFooter",
|
package/dist/index.d.ts
CHANGED
|
@@ -232,6 +232,18 @@ export declare class PieModal extends PieModal_base implements ModalProps {
|
|
|
232
232
|
* @private
|
|
233
233
|
*/
|
|
234
234
|
private renderSupportingAction;
|
|
235
|
+
/**
|
|
236
|
+
* Renders the modal footer if a leading action is provided.
|
|
237
|
+
* Additionally renders the supporting action if it is provided.
|
|
238
|
+
*
|
|
239
|
+
* @private
|
|
240
|
+
*/
|
|
241
|
+
private renderModalFooter;
|
|
242
|
+
/**
|
|
243
|
+
* Renders the loading spinner if `isLoading` is true.
|
|
244
|
+
* @private
|
|
245
|
+
*/
|
|
246
|
+
private renderLoadingSpinner;
|
|
235
247
|
/**
|
|
236
248
|
* Renders the modal inner content and footer of the modal.
|
|
237
249
|
* @private
|
package/dist/index.js
CHANGED
|
@@ -1,81 +1,81 @@
|
|
|
1
|
-
import { LitElement as
|
|
2
|
-
import { html as m, unsafeStatic as
|
|
3
|
-
import { property as
|
|
4
|
-
import { classMap as
|
|
5
|
-
import { ifDefined as
|
|
1
|
+
import { LitElement as T, nothing as h, unsafeCSS as I } from "lit";
|
|
2
|
+
import { html as m, unsafeStatic as N } from "lit/static-html.js";
|
|
3
|
+
import { property as r, query as W } from "lit/decorators.js";
|
|
4
|
+
import { classMap as L } from "lit/directives/class-map.js";
|
|
5
|
+
import { ifDefined as w } from "lit/directives/if-defined.js";
|
|
6
6
|
import "@justeattakeaway/pie-button";
|
|
7
7
|
import "@justeattakeaway/pie-icon-button";
|
|
8
|
-
import { RtlMixin as
|
|
8
|
+
import { RtlMixin as R, dispatchCustomEvent as u, requiredProperty as j, validPropertyValues as B, defineCustomElement as Y } from "@justeattakeaway/pie-webc-core";
|
|
9
9
|
import "@justeattakeaway/pie-icons-webc/dist/IconClose.js";
|
|
10
10
|
import "@justeattakeaway/pie-icons-webc/dist/IconChevronLeft.js";
|
|
11
11
|
import "@justeattakeaway/pie-icons-webc/dist/IconChevronRight.js";
|
|
12
12
|
import "@justeattakeaway/pie-spinner";
|
|
13
|
-
function
|
|
13
|
+
function V(n) {
|
|
14
14
|
if (Array.isArray(n)) {
|
|
15
|
-
for (var e = 0,
|
|
16
|
-
|
|
17
|
-
return
|
|
15
|
+
for (var e = 0, o = Array(n.length); e < n.length; e++)
|
|
16
|
+
o[e] = n[e];
|
|
17
|
+
return o;
|
|
18
18
|
} else
|
|
19
19
|
return Array.from(n);
|
|
20
20
|
}
|
|
21
|
-
var
|
|
21
|
+
var O = !1;
|
|
22
22
|
if (typeof window < "u") {
|
|
23
|
-
var
|
|
23
|
+
var S = {
|
|
24
24
|
get passive() {
|
|
25
|
-
|
|
25
|
+
O = !0;
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
|
-
window.addEventListener("testPassive", null,
|
|
28
|
+
window.addEventListener("testPassive", null, S), window.removeEventListener("testPassive", null, S);
|
|
29
29
|
}
|
|
30
|
-
var
|
|
31
|
-
return
|
|
32
|
-
return !!(
|
|
30
|
+
var A = 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 = [], x = !1, D = -1, f = void 0, v = void 0, $ = function(e) {
|
|
31
|
+
return g.some(function(o) {
|
|
32
|
+
return !!(o.options.allowTouchMove && o.options.allowTouchMove(e));
|
|
33
33
|
});
|
|
34
|
-
},
|
|
35
|
-
var
|
|
36
|
-
return
|
|
37
|
-
},
|
|
34
|
+
}, _ = function(e) {
|
|
35
|
+
var o = e || window.event;
|
|
36
|
+
return $(o.target) || o.touches.length > 1 ? !0 : (o.preventDefault && o.preventDefault(), !1);
|
|
37
|
+
}, q = function(e) {
|
|
38
38
|
if (v === void 0) {
|
|
39
|
-
var
|
|
40
|
-
|
|
39
|
+
var o = !!e && e.reserveScrollBarGap === !0, t = window.innerWidth - document.documentElement.clientWidth;
|
|
40
|
+
o && t > 0 && (v = document.body.style.paddingRight, document.body.style.paddingRight = t + "px");
|
|
41
41
|
}
|
|
42
42
|
f === void 0 && (f = document.body.style.overflow, document.body.style.overflow = "hidden");
|
|
43
|
-
},
|
|
43
|
+
}, H = function() {
|
|
44
44
|
v !== void 0 && (document.body.style.paddingRight = v, v = void 0), f !== void 0 && (document.body.style.overflow = f, f = void 0);
|
|
45
|
-
},
|
|
45
|
+
}, K = function(e) {
|
|
46
46
|
return e ? e.scrollHeight - e.scrollTop <= e.clientHeight : !1;
|
|
47
|
-
},
|
|
48
|
-
var
|
|
49
|
-
return
|
|
50
|
-
},
|
|
47
|
+
}, U = function(e, o) {
|
|
48
|
+
var t = e.targetTouches[0].clientY - D;
|
|
49
|
+
return $(e.target) ? !1 : o && o.scrollTop === 0 && t > 0 || K(o) && t < 0 ? _(e) : (e.stopPropagation(), !0);
|
|
50
|
+
}, G = function(e, o) {
|
|
51
51
|
if (!e) {
|
|
52
52
|
console.error("disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.");
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
|
-
if (!
|
|
56
|
-
return
|
|
55
|
+
if (!g.some(function(i) {
|
|
56
|
+
return i.targetElement === e;
|
|
57
57
|
})) {
|
|
58
|
-
var
|
|
58
|
+
var t = {
|
|
59
59
|
targetElement: e,
|
|
60
|
-
options:
|
|
60
|
+
options: o || {}
|
|
61
61
|
};
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}, e.ontouchmove = function(
|
|
65
|
-
|
|
66
|
-
},
|
|
62
|
+
g = [].concat(V(g), [t]), A ? (e.ontouchstart = function(i) {
|
|
63
|
+
i.targetTouches.length === 1 && (D = i.targetTouches[0].clientY);
|
|
64
|
+
}, e.ontouchmove = function(i) {
|
|
65
|
+
i.targetTouches.length === 1 && U(i, e);
|
|
66
|
+
}, x || (document.addEventListener("touchmove", _, O ? { passive: !1 } : void 0), x = !0)) : q(o);
|
|
67
67
|
}
|
|
68
|
-
},
|
|
68
|
+
}, X = function(e) {
|
|
69
69
|
if (!e) {
|
|
70
70
|
console.error("enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.");
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
|
-
|
|
74
|
-
return
|
|
75
|
-
}),
|
|
73
|
+
g = g.filter(function(o) {
|
|
74
|
+
return o.targetElement !== e;
|
|
75
|
+
}), A ? (e.ontouchstart = null, e.ontouchmove = null, x && g.length === 0 && (document.removeEventListener("touchmove", _, O ? { passive: !1 } : void 0), x = !1)) : g.length || H();
|
|
76
76
|
};
|
|
77
|
-
const
|
|
78
|
-
`,
|
|
77
|
+
const J = `*,*:after,*:before{box-sizing:inherit}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%)}.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-l-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 (width < 768px){.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.c-modal--small{--modal-max-inline-size: var(--modal-size-s)}@media (min-width: 768px){.c-modal.c-modal--small{--modal-margin-block: var(--modal-margin-large)}}.c-modal.c-modal--large{--modal-inline-size: 75%;--modal-max-inline-size: var(--modal-size-l);--modal-margin-block: var(--modal-margin-large)}@media (width < 768px){.c-modal.c-modal--large,.c-modal.c-modal--medium.c-modal--fullWidthBelowMid{--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.c-modal--large>.c-modal-scrollContainer,.c-modal.c-modal--medium.c-modal--fullWidthBelowMid>.c-modal-scrollContainer{block-size:100%}}.c-modal.c-modal--top{margin-block-start:var(--dt-spacing-j);max-block-size:calc(100% - var(--dt-spacing-j) * 2)}@media (width < 768px){.c-modal.c-modal--top.c-modal--large,.c-modal.c-modal--top.c-modal--fullWidthBelowMid.c-modal--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 (width < 768px){.c-modal .c-modal-footer.c-modal-footer--stackedActions{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: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:20px}}.c-modal .c-modal-backBtn+.c-modal-heading{margin-inline-start:var(--dt-spacing-b)}@media (min-width: 768px){.c-modal .c-modal-backBtn+.c-modal-heading{margin-inline-start:var(--dt-spacing-c)}}.c-modal.c-modal--dismissible .c-modal-heading{margin-inline-end:var(--dt-spacing-d)}@media (min-width: 768px){.c-modal.c-modal--dismissible .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);--modal-content-padding-block-end: var(--dt-spacing-e);--modal-content-min-block-size: var(--dt-spacing-j);position:relative;min-block-size:calc(var(--modal-content-min-block-size) + var(--modal-content-padding-block) + var(--modal-content-padding-block-end));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-end);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:not(:last-child){padding-block-end:var(--modal-content-padding-block);min-block-size:var(--modal-content-min-block-size)}.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.c-modal--pinnedFooter .c-modal-content{overflow-y:auto}.c-modal.c-modal--loading .c-modal-content pie-spinner{position:absolute;left:50%;top:calc(50% - (var(--modal-content-padding-block-end) - var(--modal-content-padding-block)) / 2);transform:translate(-50%,-50%)}.c-modal.c-modal--loading .c-modal-content .c-modal-contentInner{display:none}.c-modal.c-modal--loading .c-modal-content:not(:last-child) pie-spinner{top:50%}@supports not (aspect-ratio: 1/1){.c-modal .c-modal-scrollContainer{background:none}}
|
|
78
|
+
`, Q = ["h1", "h2", "h3", "h4", "h5", "h6"], Z = ["small", "medium", "large"], ee = ["top", "center"], z = "pie-modal-close", y = "pie-modal-open", C = "pie-modal-back", oe = "pie-modal-leading-action-click", te = "pie-modal-supporting-action-click", s = {
|
|
79
79
|
hasBackButton: !1,
|
|
80
80
|
hasStackedActions: !1,
|
|
81
81
|
headingLevel: "h2",
|
|
@@ -87,13 +87,13 @@ const Z = `*,*:after,*:before{box-sizing:inherit}dialog{position:absolute;left:0
|
|
|
87
87
|
position: "center",
|
|
88
88
|
size: "medium"
|
|
89
89
|
};
|
|
90
|
-
var
|
|
91
|
-
for (var
|
|
92
|
-
(c = n[
|
|
93
|
-
return
|
|
90
|
+
var ie = Object.defineProperty, ae = Object.getOwnPropertyDescriptor, l = (n, e, o, t) => {
|
|
91
|
+
for (var i = t > 1 ? void 0 : t ? ae(e, o) : e, d = n.length - 1, c; d >= 0; d--)
|
|
92
|
+
(c = n[d]) && (i = (t ? c(e, o, i) : c(i)) || i);
|
|
93
|
+
return t && i && ie(e, o, i), i;
|
|
94
94
|
};
|
|
95
95
|
const b = "pie-modal";
|
|
96
|
-
class a extends
|
|
96
|
+
class a extends R(T) {
|
|
97
97
|
constructor() {
|
|
98
98
|
super(...arguments), this.headingLevel = s.headingLevel, this.hasBackButton = s.hasBackButton, this.hasStackedActions = s.hasStackedActions, this.isDismissible = s.isDismissible, this.isFooterPinned = s.isFooterPinned, this.isFullWidthBelowMid = s.isFullWidthBelowMid, this.isLoading = s.isLoading, this.isOpen = s.isOpen, this.position = s.position, this.size = s.size, this._backButtonClicked = !1, this._handleDialogCancelEvent = (e) => {
|
|
99
99
|
this.isDismissible || e.preventDefault();
|
|
@@ -101,25 +101,25 @@ class a extends Y(I) {
|
|
|
101
101
|
var k;
|
|
102
102
|
if (!this.isDismissible)
|
|
103
103
|
return;
|
|
104
|
-
const
|
|
105
|
-
top:
|
|
106
|
-
bottom:
|
|
107
|
-
left:
|
|
104
|
+
const o = (k = this._dialog) == null ? void 0 : k.getBoundingClientRect(), {
|
|
105
|
+
top: t = 0,
|
|
106
|
+
bottom: i = 0,
|
|
107
|
+
left: d = 0,
|
|
108
108
|
right: c = 0
|
|
109
|
-
} =
|
|
110
|
-
if (
|
|
109
|
+
} = o || {};
|
|
110
|
+
if (t === 0 && i === 0 && d === 0 && c === 0)
|
|
111
111
|
return;
|
|
112
|
-
(e.clientY <
|
|
112
|
+
(e.clientY < t || e.clientY > i || e.clientX < d || e.clientX > c) && (this.isOpen = !1);
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
115
|
connectedCallback() {
|
|
116
|
-
super.connectedCallback(), this.addEventListener("click", (e) => this._handleDialogLightDismiss(e)), document.addEventListener(
|
|
116
|
+
super.connectedCallback(), this.addEventListener("click", (e) => this._handleDialogLightDismiss(e)), document.addEventListener(y, (e) => this._handleModalOpened(e)), document.addEventListener(z, (e) => this._handleModalClosed(e)), document.addEventListener(C, (e) => this._handleModalClosed(e));
|
|
117
117
|
}
|
|
118
118
|
disconnectedCallback() {
|
|
119
|
-
document.removeEventListener(
|
|
119
|
+
document.removeEventListener(y, (e) => this._handleModalOpened(e)), document.removeEventListener(z, (e) => this._handleModalClosed(e)), document.removeEventListener(C, (e) => this._handleModalClosed(e)), super.disconnectedCallback();
|
|
120
120
|
}
|
|
121
121
|
async firstUpdated(e) {
|
|
122
|
-
super.firstUpdated(e), this._dialog && ((await import("./dialog-polyfill.esm-209f54f8.js").then((
|
|
122
|
+
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", () => {
|
|
123
123
|
this.isOpen = !1;
|
|
124
124
|
})), this._handleModalOpenStateOnFirstRender(e);
|
|
125
125
|
}
|
|
@@ -130,11 +130,11 @@ class a extends Y(I) {
|
|
|
130
130
|
* Opens the dialog element and disables page scrolling
|
|
131
131
|
*/
|
|
132
132
|
_handleModalOpened(e) {
|
|
133
|
-
var
|
|
134
|
-
const { targetModal:
|
|
135
|
-
if (
|
|
136
|
-
const
|
|
137
|
-
if (
|
|
133
|
+
var t, i, d, c;
|
|
134
|
+
const { targetModal: o } = e.detail;
|
|
135
|
+
if (o === this) {
|
|
136
|
+
const p = (t = this._dialog) == null ? void 0 : t.querySelector(".c-modal-scrollContainer");
|
|
137
|
+
if (p && ("scrollTo" in window && window.scrollTo(0, 0), G(p)), (i = this._dialog) != null && i.hasAttribute("open") || !((d = this._dialog) != null && d.isConnected))
|
|
138
138
|
return;
|
|
139
139
|
(c = this._dialog) == null || c.showModal();
|
|
140
140
|
}
|
|
@@ -143,34 +143,34 @@ class a extends Y(I) {
|
|
|
143
143
|
* Closes the dialog element and re-enables page scrolling
|
|
144
144
|
*/
|
|
145
145
|
_handleModalClosed(e) {
|
|
146
|
-
var
|
|
147
|
-
const { targetModal:
|
|
148
|
-
if (
|
|
149
|
-
const
|
|
150
|
-
|
|
146
|
+
var t, i;
|
|
147
|
+
const { targetModal: o } = e.detail;
|
|
148
|
+
if (o === this) {
|
|
149
|
+
const d = (t = this._dialog) == null ? void 0 : t.querySelector(".c-modal-scrollContainer");
|
|
150
|
+
d && X(d), (i = this._dialog) == null || i.close(), this._returnFocus();
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
153
|
// Handles the value of the isOpen property on first render of the component
|
|
154
154
|
_handleModalOpenStateOnFirstRender(e) {
|
|
155
|
-
e.get("isOpen") === void 0 && this.isOpen && u(this,
|
|
155
|
+
e.get("isOpen") === void 0 && this.isOpen && u(this, y, { targetModal: this });
|
|
156
156
|
}
|
|
157
157
|
// Handles changes to the modal isOpen property by dispatching any appropriate events
|
|
158
158
|
_handleModalOpenStateChanged(e) {
|
|
159
|
-
const
|
|
160
|
-
|
|
159
|
+
const o = e.get("isOpen");
|
|
160
|
+
o !== void 0 && (o ? this._backButtonClicked ? (this._backButtonClicked = !1, u(this, C, { targetModal: this })) : u(this, z, { targetModal: this }) : u(this, y, { targetModal: this }));
|
|
161
161
|
}
|
|
162
162
|
_handleActionClick(e) {
|
|
163
|
-
var
|
|
164
|
-
e === "leading" ? ((
|
|
163
|
+
var o, t;
|
|
164
|
+
e === "leading" ? ((o = this._dialog) == null || o.close("leading"), u(this, oe, { targetModal: this })) : e === "supporting" && ((t = this._dialog) == null || t.close("supporting"), u(this, te, { targetModal: this }));
|
|
165
165
|
}
|
|
166
166
|
/**
|
|
167
167
|
* Return focus to the specified element, providing the selector is valid
|
|
168
168
|
* and the chosen element can be found.
|
|
169
169
|
*/
|
|
170
170
|
_returnFocus() {
|
|
171
|
-
var
|
|
172
|
-
const e = (
|
|
173
|
-
e && ((
|
|
171
|
+
var o, t;
|
|
172
|
+
const e = (o = this.returnFocusAfterCloseSelector) == null ? void 0 : o.trim();
|
|
173
|
+
e && ((t = document.querySelector(e)) == null || t.focus());
|
|
174
174
|
}
|
|
175
175
|
/**
|
|
176
176
|
* Template for the close button element. Called within the
|
|
@@ -187,10 +187,10 @@ class a extends Y(I) {
|
|
|
187
187
|
}}"
|
|
188
188
|
variant="ghost-secondary"
|
|
189
189
|
class="c-modal-closeBtn"
|
|
190
|
-
aria-label="${((e = this.aria) == null ? void 0 : e.close) ||
|
|
190
|
+
aria-label="${((e = this.aria) == null ? void 0 : e.close) || h}"
|
|
191
191
|
data-test-id="modal-close-button">
|
|
192
192
|
<icon-close></icon-close>
|
|
193
|
-
</pie-icon-button>` :
|
|
193
|
+
</pie-icon-button>` : h;
|
|
194
194
|
}
|
|
195
195
|
/**
|
|
196
196
|
* Template for the back button element. Called within the
|
|
@@ -207,11 +207,11 @@ class a extends Y(I) {
|
|
|
207
207
|
}}"
|
|
208
208
|
variant="ghost-secondary"
|
|
209
209
|
class="c-modal-backBtn"
|
|
210
|
-
aria-label="${
|
|
210
|
+
aria-label="${w((e = this.aria) == null ? void 0 : e.back)}"
|
|
211
211
|
data-test-id="modal-back-button">
|
|
212
212
|
${this.isRTL ? m`<icon-chevron-right></icon-chevron-right>` : m`<icon-chevron-left></icon-chevron-left>`}
|
|
213
213
|
</pie-icon-button>
|
|
214
|
-
` :
|
|
214
|
+
` : h;
|
|
215
215
|
}
|
|
216
216
|
/**
|
|
217
217
|
* Renders the "leadingAction" button if the text is provided.
|
|
@@ -223,18 +223,18 @@ class a extends Y(I) {
|
|
|
223
223
|
* @private
|
|
224
224
|
*/
|
|
225
225
|
renderLeadingAction() {
|
|
226
|
-
const { ariaLabel: e, text:
|
|
227
|
-
return
|
|
226
|
+
const { ariaLabel: e, text: o, variant: t = "primary" } = this.leadingAction || {};
|
|
227
|
+
return o ? m`
|
|
228
228
|
<pie-button
|
|
229
|
-
variant="${
|
|
230
|
-
aria-label="${
|
|
229
|
+
variant="${t}"
|
|
230
|
+
aria-label="${w(e)}"
|
|
231
231
|
type="submit"
|
|
232
232
|
?isFullWidth="${this.hasStackedActions}"
|
|
233
233
|
@click="${() => this._handleActionClick("leading")}"
|
|
234
234
|
data-test-id="modal-leading-action">
|
|
235
|
-
${
|
|
235
|
+
${o}
|
|
236
236
|
</pie-button>
|
|
237
|
-
` :
|
|
237
|
+
` : h;
|
|
238
238
|
}
|
|
239
239
|
/**
|
|
240
240
|
* Renders the "supportingAction" button if the text is provided.
|
|
@@ -247,157 +247,167 @@ class a extends Y(I) {
|
|
|
247
247
|
* @private
|
|
248
248
|
*/
|
|
249
249
|
renderSupportingAction() {
|
|
250
|
-
var
|
|
251
|
-
const { ariaLabel: e, text:
|
|
252
|
-
return
|
|
250
|
+
var i;
|
|
251
|
+
const { ariaLabel: e, text: o, variant: t = "ghost" } = this.supportingAction || {};
|
|
252
|
+
return !o || !((i = this.leadingAction) != null && i.text) ? h : m`
|
|
253
253
|
<pie-button
|
|
254
|
-
variant="${
|
|
255
|
-
aria-label="${
|
|
254
|
+
variant="${t}"
|
|
255
|
+
aria-label="${w(e)}"
|
|
256
256
|
type="reset"
|
|
257
257
|
?isFullWidth="${this.hasStackedActions}"
|
|
258
258
|
@click="${() => this._handleActionClick("supporting")}"
|
|
259
259
|
data-test-id="modal-supporting-action">
|
|
260
|
-
${
|
|
260
|
+
${o}
|
|
261
261
|
</pie-button>
|
|
262
|
-
|
|
262
|
+
`;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Renders the modal footer if a leading action is provided.
|
|
266
|
+
* Additionally renders the supporting action if it is provided.
|
|
267
|
+
*
|
|
268
|
+
* @private
|
|
269
|
+
*/
|
|
270
|
+
renderModalFooter() {
|
|
271
|
+
var o, t;
|
|
272
|
+
if (!((o = this.leadingAction) != null && o.text))
|
|
273
|
+
return (t = this.supportingAction) != null && t.text && console.warn("You cannot have a supporting action without a leading action. If you only need one button then use a leading action instead."), h;
|
|
274
|
+
const e = {
|
|
275
|
+
"c-modal-footer": !0,
|
|
276
|
+
"c-modal-footer--stackedActions": this.hasStackedActions
|
|
277
|
+
};
|
|
278
|
+
return m`
|
|
279
|
+
<footer class="${L(e)}" data-test-id="pie-modal-footer">
|
|
280
|
+
${this.renderLeadingAction()}
|
|
281
|
+
${this.renderSupportingAction()}
|
|
282
|
+
</footer>`;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Renders the loading spinner if `isLoading` is true.
|
|
286
|
+
* @private
|
|
287
|
+
*/
|
|
288
|
+
renderLoadingSpinner() {
|
|
289
|
+
return this.isLoading ? m`<pie-spinner size="xlarge" variant="secondary"></pie-spinner>` : h;
|
|
263
290
|
}
|
|
264
291
|
/**
|
|
265
292
|
* Renders the modal inner content and footer of the modal.
|
|
266
293
|
* @private
|
|
267
294
|
*/
|
|
268
295
|
renderModalContentAndFooter() {
|
|
269
|
-
var o;
|
|
270
|
-
const e = !!((o = this.leadingAction) != null && o.text);
|
|
271
296
|
return m`
|
|
272
|
-
<article class
|
|
273
|
-
"c-modal-scrollContainer": !0,
|
|
274
|
-
"c-modal-content": !0,
|
|
275
|
-
"c-modal-content--scrollable": !0,
|
|
276
|
-
"c-modal-hasFooterActions": e
|
|
277
|
-
})}>
|
|
297
|
+
<article class="c-modal-scrollContainer c-modal-content c-modal-content--scrollable">
|
|
278
298
|
<div class="c-modal-contentInner" data-test-id="modal-content-inner">
|
|
279
299
|
<slot></slot>
|
|
280
300
|
</div>
|
|
281
|
-
${this.
|
|
301
|
+
${this.renderLoadingSpinner()}
|
|
282
302
|
</article>
|
|
283
|
-
${
|
|
284
|
-
<footer class="c-modal-footer" data-test-id="pie-modal-footer">
|
|
285
|
-
${this.renderLeadingAction()}
|
|
286
|
-
${this.renderSupportingAction()}
|
|
287
|
-
</footer>` : g}`;
|
|
303
|
+
${this.renderModalFooter()}`;
|
|
288
304
|
}
|
|
289
305
|
render() {
|
|
290
306
|
const {
|
|
291
307
|
aria: e,
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
308
|
+
heading: o,
|
|
309
|
+
headingLevel: t,
|
|
310
|
+
isDismissible: i,
|
|
311
|
+
isFooterPinned: d,
|
|
312
|
+
isFullWidthBelowMid: c,
|
|
313
|
+
isLoading: p,
|
|
314
|
+
position: k,
|
|
315
|
+
size: F
|
|
316
|
+
} = this, M = N(t), P = p && (e == null ? void 0 : e.loading) || void 0, E = {
|
|
317
|
+
"c-modal": !0,
|
|
318
|
+
[`c-modal--${F}`]: !0,
|
|
319
|
+
"c-modal--top": k === "top",
|
|
320
|
+
"c-modal--dismissible": i,
|
|
321
|
+
"c-modal--loading": p,
|
|
322
|
+
"c-modal--pinnedFooter": d,
|
|
323
|
+
"c-modal--fullWidthBelowMid": c
|
|
324
|
+
};
|
|
305
325
|
return m`
|
|
306
326
|
<dialog
|
|
307
327
|
id="dialog"
|
|
308
|
-
class="
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
?hasActions=${(_ == null ? void 0 : _.text) || (C == null ? void 0 : C.text)}
|
|
312
|
-
?hasBackButton=${i}
|
|
313
|
-
?hasStackedActions=${o}
|
|
314
|
-
?isDismissible=${c}
|
|
315
|
-
?isFooterPinned=${h}
|
|
316
|
-
?isFullWidthBelowMid=${k}
|
|
317
|
-
?isLoading=${z}
|
|
318
|
-
aria-busy="${z ? "true" : "false"}"
|
|
319
|
-
aria-label="${z && (e == null ? void 0 : e.loading) || g}"
|
|
328
|
+
class="${L(E)}"
|
|
329
|
+
aria-busy="${p ? "true" : "false"}"
|
|
330
|
+
aria-label="${w(P)}"
|
|
320
331
|
data-test-id="pie-modal">
|
|
321
332
|
<header class="c-modal-header"
|
|
322
333
|
data-test-id="modal-header">
|
|
323
334
|
${this.renderBackButton()}
|
|
324
335
|
<${M} class="c-modal-heading">
|
|
325
|
-
${
|
|
336
|
+
${o}
|
|
326
337
|
</${M}>
|
|
327
338
|
${this.renderCloseButton()}
|
|
328
339
|
</header>
|
|
329
340
|
${// We need to wrap the remaining content in a shared scrollable container if the footer is not pinned
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
`}
|
|
341
|
+
d ? this.renderModalContentAndFooter() : m`
|
|
342
|
+
<div class="c-modal-scrollContainer">
|
|
343
|
+
${this.renderModalContentAndFooter()}
|
|
344
|
+
</div>`}
|
|
335
345
|
</dialog>`;
|
|
336
346
|
}
|
|
337
347
|
}
|
|
338
|
-
a.styles =
|
|
348
|
+
a.styles = I(J);
|
|
339
349
|
l([
|
|
340
|
-
|
|
350
|
+
r({ type: Object })
|
|
341
351
|
], a.prototype, "aria", 2);
|
|
342
352
|
l([
|
|
343
|
-
|
|
344
|
-
|
|
353
|
+
r({ type: String }),
|
|
354
|
+
j(b)
|
|
345
355
|
], a.prototype, "heading", 2);
|
|
346
356
|
l([
|
|
347
|
-
|
|
348
|
-
|
|
357
|
+
r(),
|
|
358
|
+
B(b, Q, s.headingLevel)
|
|
349
359
|
], a.prototype, "headingLevel", 2);
|
|
350
360
|
l([
|
|
351
|
-
|
|
361
|
+
r({ type: Boolean })
|
|
352
362
|
], a.prototype, "hasBackButton", 2);
|
|
353
363
|
l([
|
|
354
|
-
|
|
364
|
+
r({ type: Boolean })
|
|
355
365
|
], a.prototype, "hasStackedActions", 2);
|
|
356
366
|
l([
|
|
357
|
-
|
|
367
|
+
r({ type: Boolean, reflect: !0 })
|
|
358
368
|
], a.prototype, "isDismissible", 2);
|
|
359
369
|
l([
|
|
360
|
-
|
|
370
|
+
r({ type: Boolean })
|
|
361
371
|
], a.prototype, "isFooterPinned", 2);
|
|
362
372
|
l([
|
|
363
|
-
|
|
373
|
+
r({ type: Boolean })
|
|
364
374
|
], a.prototype, "isFullWidthBelowMid", 2);
|
|
365
375
|
l([
|
|
366
|
-
|
|
376
|
+
r({ type: Boolean, reflect: !0 })
|
|
367
377
|
], a.prototype, "isLoading", 2);
|
|
368
378
|
l([
|
|
369
|
-
|
|
379
|
+
r({ type: Boolean })
|
|
370
380
|
], a.prototype, "isOpen", 2);
|
|
371
381
|
l([
|
|
372
|
-
|
|
382
|
+
r({ type: Object })
|
|
373
383
|
], a.prototype, "leadingAction", 2);
|
|
374
384
|
l([
|
|
375
|
-
|
|
376
|
-
|
|
385
|
+
r(),
|
|
386
|
+
B(b, ee, s.position)
|
|
377
387
|
], a.prototype, "position", 2);
|
|
378
388
|
l([
|
|
379
|
-
|
|
389
|
+
r()
|
|
380
390
|
], a.prototype, "returnFocusAfterCloseSelector", 2);
|
|
381
391
|
l([
|
|
382
|
-
|
|
383
|
-
|
|
392
|
+
r(),
|
|
393
|
+
B(b, Z, s.size)
|
|
384
394
|
], a.prototype, "size", 2);
|
|
385
395
|
l([
|
|
386
|
-
|
|
396
|
+
r({ type: Object })
|
|
387
397
|
], a.prototype, "supportingAction", 2);
|
|
388
398
|
l([
|
|
389
399
|
W("dialog")
|
|
390
400
|
], a.prototype, "_dialog", 2);
|
|
391
|
-
|
|
401
|
+
Y(b, a);
|
|
392
402
|
export {
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
403
|
+
C as ON_MODAL_BACK_EVENT,
|
|
404
|
+
z as ON_MODAL_CLOSE_EVENT,
|
|
405
|
+
oe as ON_MODAL_LEADING_ACTION_CLICK,
|
|
406
|
+
y as ON_MODAL_OPEN_EVENT,
|
|
407
|
+
te as ON_MODAL_SUPPORTING_ACTION_CLICK,
|
|
398
408
|
a as PieModal,
|
|
399
409
|
s as defaultProps,
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
410
|
+
Q as headingLevels,
|
|
411
|
+
ee as positions,
|
|
412
|
+
Z as sizes
|
|
403
413
|
};
|
package/dist/react.d.ts
CHANGED
|
@@ -231,6 +231,18 @@ declare class PieModal_2 extends PieModal_base implements ModalProps {
|
|
|
231
231
|
* @private
|
|
232
232
|
*/
|
|
233
233
|
private renderSupportingAction;
|
|
234
|
+
/**
|
|
235
|
+
* Renders the modal footer if a leading action is provided.
|
|
236
|
+
* Additionally renders the supporting action if it is provided.
|
|
237
|
+
*
|
|
238
|
+
* @private
|
|
239
|
+
*/
|
|
240
|
+
private renderModalFooter;
|
|
241
|
+
/**
|
|
242
|
+
* Renders the loading spinner if `isLoading` is true.
|
|
243
|
+
* @private
|
|
244
|
+
*/
|
|
245
|
+
private renderLoadingSpinner;
|
|
234
246
|
/**
|
|
235
247
|
* Renders the modal inner content and footer of the modal.
|
|
236
248
|
* @private
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justeattakeaway/pie-modal",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.46.1",
|
|
4
4
|
"description": "PIE design system modal built using web components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@custom-elements-manifest/analyzer": "0.9.0",
|
|
39
39
|
"@justeat/pie-design-tokens": "6.3.1",
|
|
40
|
-
"@justeattakeaway/pie-components-config": "0.
|
|
40
|
+
"@justeattakeaway/pie-components-config": "0.18.0",
|
|
41
41
|
"@justeattakeaway/pie-css": "0.12.1",
|
|
42
42
|
"@justeattakeaway/pie-wrapper-react": "0.14.1",
|
|
43
43
|
"@types/body-scroll-lock": "3.1.2",
|
|
@@ -47,9 +47,9 @@
|
|
|
47
47
|
"extends": "../../../package.json"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@justeattakeaway/pie-button": "0.
|
|
51
|
-
"@justeattakeaway/pie-icon-button": "0.28.
|
|
52
|
-
"@justeattakeaway/pie-icons-webc": "0.25.
|
|
50
|
+
"@justeattakeaway/pie-button": "0.49.0",
|
|
51
|
+
"@justeattakeaway/pie-icon-button": "0.28.11",
|
|
52
|
+
"@justeattakeaway/pie-icons-webc": "0.25.1",
|
|
53
53
|
"@justeattakeaway/pie-spinner": "0.6.7",
|
|
54
54
|
"@justeattakeaway/pie-webc-core": "0.24.0",
|
|
55
55
|
"body-scroll-lock": "3.1.5",
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
LitElement, nothing, TemplateResult, unsafeCSS, PropertyValues,
|
|
2
|
+
LitElement, nothing, type TemplateResult, unsafeCSS, type PropertyValues,
|
|
3
3
|
} from 'lit';
|
|
4
4
|
import { html, unsafeStatic } from 'lit/static-html.js';
|
|
5
5
|
import { property, query } from 'lit/decorators.js';
|
|
@@ -338,10 +338,7 @@ export class PieModal extends RtlMixin(LitElement) implements ModalProps {
|
|
|
338
338
|
private renderSupportingAction (): TemplateResult | typeof nothing {
|
|
339
339
|
const { ariaLabel, text, variant = 'ghost' } = this.supportingAction || {};
|
|
340
340
|
|
|
341
|
-
if (!text)
|
|
342
|
-
|
|
343
|
-
if (!this.leadingAction?.text) {
|
|
344
|
-
console.warn('You cannot have a supporting action without a leading action. If you only need one button then use a leading action instead.');
|
|
341
|
+
if (!text || !this.leadingAction?.text) {
|
|
345
342
|
return nothing;
|
|
346
343
|
}
|
|
347
344
|
|
|
@@ -359,67 +356,90 @@ export class PieModal extends RtlMixin(LitElement) implements ModalProps {
|
|
|
359
356
|
}
|
|
360
357
|
|
|
361
358
|
/**
|
|
362
|
-
* Renders the modal
|
|
359
|
+
* Renders the modal footer if a leading action is provided.
|
|
360
|
+
* Additionally renders the supporting action if it is provided.
|
|
361
|
+
*
|
|
363
362
|
* @private
|
|
364
363
|
*/
|
|
365
|
-
private
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
364
|
+
private renderModalFooter () : TemplateResult | typeof nothing {
|
|
365
|
+
if (!this.leadingAction?.text) {
|
|
366
|
+
if (this.supportingAction?.text) {
|
|
367
|
+
console.warn('You cannot have a supporting action without a leading action. If you only need one button then use a leading action instead.');
|
|
368
|
+
}
|
|
369
|
+
return nothing;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
const footerClasses = {
|
|
373
|
+
'c-modal-footer': true,
|
|
374
|
+
'c-modal-footer--stackedActions': this.hasStackedActions,
|
|
373
375
|
};
|
|
374
376
|
|
|
375
377
|
return html`
|
|
376
|
-
<
|
|
378
|
+
<footer class="${classMap(footerClasses)}" data-test-id="pie-modal-footer">
|
|
379
|
+
${this.renderLeadingAction()}
|
|
380
|
+
${this.renderSupportingAction()}
|
|
381
|
+
</footer>`;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Renders the loading spinner if `isLoading` is true.
|
|
386
|
+
* @private
|
|
387
|
+
*/
|
|
388
|
+
private renderLoadingSpinner () : TemplateResult | typeof nothing {
|
|
389
|
+
if (!this.isLoading) {
|
|
390
|
+
return nothing;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
return html`<pie-spinner size="xlarge" variant="secondary"></pie-spinner>`;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Renders the modal inner content and footer of the modal.
|
|
398
|
+
* @private
|
|
399
|
+
*/
|
|
400
|
+
private renderModalContentAndFooter () : TemplateResult {
|
|
401
|
+
return html`
|
|
402
|
+
<article class="c-modal-scrollContainer c-modal-content c-modal-content--scrollable">
|
|
377
403
|
<div class="c-modal-contentInner" data-test-id="modal-content-inner">
|
|
378
404
|
<slot></slot>
|
|
379
405
|
</div>
|
|
380
|
-
${this.
|
|
406
|
+
${this.renderLoadingSpinner()}
|
|
381
407
|
</article>
|
|
382
|
-
${
|
|
383
|
-
<footer class="c-modal-footer" data-test-id="pie-modal-footer">
|
|
384
|
-
${this.renderLeadingAction()}
|
|
385
|
-
${this.renderSupportingAction()}
|
|
386
|
-
</footer>` : nothing}`;
|
|
408
|
+
${this.renderModalFooter()}`;
|
|
387
409
|
}
|
|
388
410
|
|
|
389
|
-
|
|
411
|
+
render () {
|
|
390
412
|
const {
|
|
391
413
|
aria,
|
|
392
|
-
hasBackButton,
|
|
393
|
-
hasStackedActions,
|
|
394
414
|
heading,
|
|
395
415
|
headingLevel,
|
|
396
416
|
isDismissible,
|
|
397
417
|
isFooterPinned,
|
|
398
418
|
isFullWidthBelowMid,
|
|
399
419
|
isLoading,
|
|
400
|
-
leadingAction,
|
|
401
420
|
position,
|
|
402
421
|
size,
|
|
403
|
-
supportingAction,
|
|
404
422
|
} = this;
|
|
405
423
|
|
|
406
424
|
const headingTag = unsafeStatic(headingLevel);
|
|
425
|
+
const ariaLabel = (isLoading && aria?.loading) || undefined;
|
|
426
|
+
|
|
427
|
+
const modalClasses = {
|
|
428
|
+
'c-modal': true,
|
|
429
|
+
[`c-modal--${size}`]: true,
|
|
430
|
+
'c-modal--top': position === 'top',
|
|
431
|
+
'c-modal--dismissible': isDismissible,
|
|
432
|
+
'c-modal--loading': isLoading,
|
|
433
|
+
'c-modal--pinnedFooter': isFooterPinned,
|
|
434
|
+
'c-modal--fullWidthBelowMid': isFullWidthBelowMid,
|
|
435
|
+
};
|
|
407
436
|
|
|
408
437
|
return html`
|
|
409
438
|
<dialog
|
|
410
439
|
id="dialog"
|
|
411
|
-
class="
|
|
412
|
-
size="${size}"
|
|
413
|
-
position="${position}"
|
|
414
|
-
?hasActions=${leadingAction?.text || supportingAction?.text}
|
|
415
|
-
?hasBackButton=${hasBackButton}
|
|
416
|
-
?hasStackedActions=${hasStackedActions}
|
|
417
|
-
?isDismissible=${isDismissible}
|
|
418
|
-
?isFooterPinned=${isFooterPinned}
|
|
419
|
-
?isFullWidthBelowMid=${isFullWidthBelowMid}
|
|
420
|
-
?isLoading=${isLoading}
|
|
440
|
+
class="${classMap(modalClasses)}"
|
|
421
441
|
aria-busy="${isLoading ? 'true' : 'false'}"
|
|
422
|
-
aria-label="${(
|
|
442
|
+
aria-label="${ifDefined(ariaLabel)}"
|
|
423
443
|
data-test-id="pie-modal">
|
|
424
444
|
<header class="c-modal-header"
|
|
425
445
|
data-test-id="modal-header">
|
|
@@ -434,10 +454,9 @@ export class PieModal extends RtlMixin(LitElement) implements ModalProps {
|
|
|
434
454
|
isFooterPinned
|
|
435
455
|
? this.renderModalContentAndFooter()
|
|
436
456
|
: html`
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
`
|
|
457
|
+
<div class="c-modal-scrollContainer">
|
|
458
|
+
${this.renderModalContentAndFooter()}
|
|
459
|
+
</div>`
|
|
441
460
|
}
|
|
442
461
|
</dialog>`;
|
|
443
462
|
}
|
package/src/modal.scss
CHANGED
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
max-block-size: var(--modal-max-block-size);
|
|
67
67
|
max-inline-size: var(--modal-max-inline-size);
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
&.c-modal--small {
|
|
70
70
|
--modal-max-inline-size: var(--modal-size-s);
|
|
71
71
|
|
|
72
72
|
@media (min-width: $breakpoint-wide) {
|
|
@@ -74,19 +74,19 @@
|
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
&.c-modal--medium {
|
|
78
78
|
/* Same as default styles */
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
&.c-modal--large {
|
|
82
82
|
--modal-inline-size: 75%;
|
|
83
83
|
--modal-max-inline-size: var(--modal-size-l);
|
|
84
84
|
--modal-margin-block: var(--modal-margin-large);
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
// Fullscreen styles
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
&.c-modal--large,
|
|
89
|
+
&.c-modal--medium.c-modal--fullWidthBelowMid {
|
|
90
90
|
@media (width < $breakpoint-wide) {
|
|
91
91
|
--modal-margin-block: var(--modal-margin-none);
|
|
92
92
|
--modal-border-radius: var(--dt-radius-rounded-none);
|
|
@@ -104,12 +104,12 @@
|
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
|
|
107
|
+
&.c-modal--top {
|
|
108
108
|
margin-block-start: var(--dt-spacing-j);
|
|
109
109
|
max-block-size: calc(100% - var(--dt-spacing-j) * 2);
|
|
110
110
|
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
&.c-modal--large,
|
|
112
|
+
&.c-modal--fullWidthBelowMid.c-modal--medium {
|
|
113
113
|
@media (width < $breakpoint-wide) {
|
|
114
114
|
margin-block-start: var(--dt-spacing-none);
|
|
115
115
|
max-block-size: 100%;
|
|
@@ -136,12 +136,8 @@
|
|
|
136
136
|
@media (min-width: $breakpoint-wide) {
|
|
137
137
|
--modal-footer-padding: var(--dt-spacing-e);
|
|
138
138
|
}
|
|
139
|
-
}
|
|
140
139
|
|
|
141
|
-
|
|
142
|
-
// change the direction of the footer flex container so buttons are full width of modal
|
|
143
|
-
&[hasstackedactions] {
|
|
144
|
-
& .c-modal-footer {
|
|
140
|
+
&.c-modal-footer--stackedActions {
|
|
145
141
|
// TODO: Move breakpoint sizes into shared CSS component utilities
|
|
146
142
|
@media (width < $breakpoint-wide) {
|
|
147
143
|
flex-direction: column;
|
|
@@ -181,7 +177,7 @@
|
|
|
181
177
|
}
|
|
182
178
|
|
|
183
179
|
// Ensure correct padding when there is a back button in front of the heading
|
|
184
|
-
|
|
180
|
+
.c-modal-backBtn + .c-modal-heading {
|
|
185
181
|
margin-inline-start: var(--dt-spacing-b);
|
|
186
182
|
|
|
187
183
|
@media (min-width: $breakpoint-wide) {
|
|
@@ -189,8 +185,7 @@
|
|
|
189
185
|
}
|
|
190
186
|
}
|
|
191
187
|
|
|
192
|
-
|
|
193
|
-
&[isdismissible] .c-modal-heading {
|
|
188
|
+
&.c-modal--dismissible .c-modal-heading {
|
|
194
189
|
margin-inline-end: var(--dt-spacing-d);
|
|
195
190
|
|
|
196
191
|
@media (min-width: $breakpoint-wide) {
|
|
@@ -256,7 +251,8 @@
|
|
|
256
251
|
padding-block-end: var(--modal-content-padding-block-end); // We require a larger bottom padding when there's no footer
|
|
257
252
|
flex-grow: 1;
|
|
258
253
|
|
|
259
|
-
|
|
254
|
+
// If the footer is rendered, the modal content is not the last child
|
|
255
|
+
&:not(:last-child) {
|
|
260
256
|
padding-block-end: var(--modal-content-padding-block);
|
|
261
257
|
min-block-size: var(--modal-content-min-block-size);
|
|
262
258
|
}
|
|
@@ -303,11 +299,11 @@
|
|
|
303
299
|
}
|
|
304
300
|
}
|
|
305
301
|
|
|
306
|
-
|
|
302
|
+
&.c-modal--pinnedFooter .c-modal-content {
|
|
307
303
|
overflow-y: auto;
|
|
308
304
|
}
|
|
309
305
|
|
|
310
|
-
|
|
306
|
+
&.c-modal--loading .c-modal-content {
|
|
311
307
|
pie-spinner {
|
|
312
308
|
position: absolute;
|
|
313
309
|
left: 50%;
|
|
@@ -321,7 +317,8 @@
|
|
|
321
317
|
display: none;
|
|
322
318
|
}
|
|
323
319
|
|
|
324
|
-
|
|
320
|
+
// If the footer is rendered, the modal content is not the last child
|
|
321
|
+
&:not(:last-child) {
|
|
325
322
|
pie-spinner {
|
|
326
323
|
top: 50%;
|
|
327
324
|
}
|