@justeattakeaway/pie-modal 0.44.0 → 0.45.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/custom-elements.json +17 -37
- package/dist/index.d.ts +30 -26
- package/dist/index.js +142 -147
- package/dist/react.d.ts +30 -26
- package/package.json +7 -6
- package/src/defs.ts +23 -20
- package/src/index.ts +28 -33
- package/src/modal.scss +14 -2
package/custom-elements.json
CHANGED
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"type": {
|
|
88
88
|
"text": "DefaultProps"
|
|
89
89
|
},
|
|
90
|
-
"default": "{\n hasBackButton: false,\n hasStackedActions: false,\n headingLevel: 'h2',\n isOpen: false,\n isDismissible: false,\n isFooterPinned: true,\n isFullWidthBelowMid: false,\n isLoading: false,\n
|
|
90
|
+
"default": "{\n hasBackButton: false,\n hasStackedActions: false,\n headingLevel: 'h2',\n isOpen: false,\n isDismissible: false,\n isFooterPinned: true,\n isFullWidthBelowMid: false,\n isLoading: false,\n position: 'center',\n size: 'medium',\n}"
|
|
91
91
|
}
|
|
92
92
|
],
|
|
93
93
|
"exports": [
|
|
@@ -244,18 +244,12 @@
|
|
|
244
244
|
},
|
|
245
245
|
{
|
|
246
246
|
"kind": "field",
|
|
247
|
-
"name": "
|
|
247
|
+
"name": "leadingAction",
|
|
248
248
|
"type": {
|
|
249
|
-
"text": "ModalProps['
|
|
249
|
+
"text": "ModalProps['leadingAction']"
|
|
250
250
|
},
|
|
251
251
|
"privacy": "public",
|
|
252
|
-
"attribute": "
|
|
253
|
-
},
|
|
254
|
-
{
|
|
255
|
-
"kind": "field",
|
|
256
|
-
"name": "leadingActionVariant",
|
|
257
|
-
"privacy": "public",
|
|
258
|
-
"attribute": "leadingActionVariant"
|
|
252
|
+
"attribute": "leadingAction"
|
|
259
253
|
},
|
|
260
254
|
{
|
|
261
255
|
"kind": "field",
|
|
@@ -267,7 +261,7 @@
|
|
|
267
261
|
"kind": "field",
|
|
268
262
|
"name": "returnFocusAfterCloseSelector",
|
|
269
263
|
"type": {
|
|
270
|
-
"text": "ModalProps['returnFocusAfterCloseSelector']
|
|
264
|
+
"text": "ModalProps['returnFocusAfterCloseSelector']"
|
|
271
265
|
},
|
|
272
266
|
"privacy": "public",
|
|
273
267
|
"attribute": "returnFocusAfterCloseSelector"
|
|
@@ -280,18 +274,12 @@
|
|
|
280
274
|
},
|
|
281
275
|
{
|
|
282
276
|
"kind": "field",
|
|
283
|
-
"name": "
|
|
277
|
+
"name": "supportingAction",
|
|
284
278
|
"type": {
|
|
285
|
-
"text": "ModalProps['
|
|
279
|
+
"text": "ModalProps['supportingAction']"
|
|
286
280
|
},
|
|
287
281
|
"privacy": "public",
|
|
288
|
-
"attribute": "
|
|
289
|
-
},
|
|
290
|
-
{
|
|
291
|
-
"kind": "field",
|
|
292
|
-
"name": "supportingActionVariant",
|
|
293
|
-
"privacy": "public",
|
|
294
|
-
"attribute": "supportingActionVariant"
|
|
282
|
+
"attribute": "supportingAction"
|
|
295
283
|
},
|
|
296
284
|
{
|
|
297
285
|
"kind": "field",
|
|
@@ -459,7 +447,7 @@
|
|
|
459
447
|
"text": "TemplateResult | typeof nothing"
|
|
460
448
|
}
|
|
461
449
|
},
|
|
462
|
-
"description": "Renders the \"leadingAction\" button if the text is provided.\n\nIf `
|
|
450
|
+
"description": "Renders the \"leadingAction\" button if the text is provided.\n\nIf `leadingAction.text` is not provided, the button is not rendered.\nIf `leadingAction.variant` is not provided, the default value of \"primary\" is used.\nThe (optional) aria-label is read from `leadingAction.ariaLabel`."
|
|
463
451
|
},
|
|
464
452
|
{
|
|
465
453
|
"kind": "method",
|
|
@@ -470,7 +458,7 @@
|
|
|
470
458
|
"text": "TemplateResult | typeof nothing"
|
|
471
459
|
}
|
|
472
460
|
},
|
|
473
|
-
"description": "Renders the \"supportingAction\" button if the text is provided.\nYou cannot have a supporting action without a leading action.\n\nIf `
|
|
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`."
|
|
474
462
|
},
|
|
475
463
|
{
|
|
476
464
|
"kind": "method",
|
|
@@ -584,15 +572,11 @@
|
|
|
584
572
|
"fieldName": "isOpen"
|
|
585
573
|
},
|
|
586
574
|
{
|
|
587
|
-
"name": "
|
|
575
|
+
"name": "leadingAction",
|
|
588
576
|
"type": {
|
|
589
|
-
"text": "ModalProps['
|
|
577
|
+
"text": "ModalProps['leadingAction']"
|
|
590
578
|
},
|
|
591
|
-
"fieldName": "
|
|
592
|
-
},
|
|
593
|
-
{
|
|
594
|
-
"name": "leadingActionVariant",
|
|
595
|
-
"fieldName": "leadingActionVariant"
|
|
579
|
+
"fieldName": "leadingAction"
|
|
596
580
|
},
|
|
597
581
|
{
|
|
598
582
|
"name": "position",
|
|
@@ -601,7 +585,7 @@
|
|
|
601
585
|
{
|
|
602
586
|
"name": "returnFocusAfterCloseSelector",
|
|
603
587
|
"type": {
|
|
604
|
-
"text": "ModalProps['returnFocusAfterCloseSelector']
|
|
588
|
+
"text": "ModalProps['returnFocusAfterCloseSelector']"
|
|
605
589
|
},
|
|
606
590
|
"fieldName": "returnFocusAfterCloseSelector"
|
|
607
591
|
},
|
|
@@ -610,15 +594,11 @@
|
|
|
610
594
|
"fieldName": "size"
|
|
611
595
|
},
|
|
612
596
|
{
|
|
613
|
-
"name": "
|
|
597
|
+
"name": "supportingAction",
|
|
614
598
|
"type": {
|
|
615
|
-
"text": "ModalProps['
|
|
599
|
+
"text": "ModalProps['supportingAction']"
|
|
616
600
|
},
|
|
617
|
-
"fieldName": "
|
|
618
|
-
},
|
|
619
|
-
{
|
|
620
|
-
"name": "supportingActionVariant",
|
|
621
|
-
"fieldName": "supportingActionVariant"
|
|
601
|
+
"fieldName": "supportingAction"
|
|
622
602
|
}
|
|
623
603
|
],
|
|
624
604
|
"mixins": [
|
package/dist/index.d.ts
CHANGED
|
@@ -7,15 +7,28 @@ import type { RTLInterface } from '@justeattakeaway/pie-webc-core';
|
|
|
7
7
|
import type { TemplateResult } from 'lit';
|
|
8
8
|
import { Variant } from '@justeattakeaway/pie-button/src/defs.ts';
|
|
9
9
|
|
|
10
|
+
declare type ActionProps = {
|
|
11
|
+
/**
|
|
12
|
+
* The text to display inside the button.
|
|
13
|
+
*/
|
|
14
|
+
text: string;
|
|
15
|
+
/**
|
|
16
|
+
* The button variant.
|
|
17
|
+
*/
|
|
18
|
+
variant?: Variant;
|
|
19
|
+
/**
|
|
20
|
+
* The aria label for the button.
|
|
21
|
+
*/
|
|
22
|
+
ariaLabel?: string;
|
|
23
|
+
};
|
|
24
|
+
|
|
10
25
|
export declare type AriaProps = {
|
|
11
26
|
close?: string;
|
|
12
27
|
back?: string;
|
|
13
28
|
loading?: string;
|
|
14
|
-
leadingActionLabel?: string;
|
|
15
|
-
supportingActionLabel?: string;
|
|
16
29
|
};
|
|
17
30
|
|
|
18
|
-
export declare type DefaultProps = ComponentDefaultProps<ModalProps, keyof Omit<ModalProps, 'aria' | 'heading' | '
|
|
31
|
+
export declare type DefaultProps = ComponentDefaultProps<ModalProps, keyof Omit<ModalProps, 'aria' | 'heading' | 'leadingAction' | 'supportingAction' | 'returnFocusAfterCloseSelector'>>;
|
|
19
32
|
|
|
20
33
|
export declare const defaultProps: DefaultProps;
|
|
21
34
|
|
|
@@ -29,7 +42,7 @@ export declare interface ModalEventDetail {
|
|
|
29
42
|
|
|
30
43
|
export declare type ModalProps = {
|
|
31
44
|
/**
|
|
32
|
-
* The ARIA labels used for the modal
|
|
45
|
+
* The ARIA labels used for the modal close and back buttons, as well as for the loading state.
|
|
33
46
|
*/
|
|
34
47
|
aria?: AriaProps;
|
|
35
48
|
/**
|
|
@@ -77,21 +90,13 @@ export declare type ModalProps = {
|
|
|
77
90
|
*/
|
|
78
91
|
isLoading?: boolean;
|
|
79
92
|
/**
|
|
80
|
-
* The
|
|
81
|
-
*/
|
|
82
|
-
leadingActionText?: string;
|
|
83
|
-
/**
|
|
84
|
-
* The button variant for the leading action button.
|
|
85
|
-
*/
|
|
86
|
-
leadingActionVariant?: Variant;
|
|
87
|
-
/**
|
|
88
|
-
* The text to display inside the supporting action button.
|
|
93
|
+
* The leading action configuration for the modal.
|
|
89
94
|
*/
|
|
90
|
-
|
|
95
|
+
leadingAction?: ActionProps;
|
|
91
96
|
/**
|
|
92
|
-
* The
|
|
97
|
+
* The supporting action configuration for the modal.
|
|
93
98
|
*/
|
|
94
|
-
|
|
99
|
+
supportingAction?: ActionProps;
|
|
95
100
|
position?: typeof positions[number];
|
|
96
101
|
/**
|
|
97
102
|
* The selector for the element that you would like focus to be returned to when the modal is closed, e.g., #skipToMain
|
|
@@ -157,13 +162,11 @@ export declare class PieModal extends PieModal_base implements ModalProps {
|
|
|
157
162
|
isFullWidthBelowMid: boolean;
|
|
158
163
|
isLoading: boolean;
|
|
159
164
|
isOpen: boolean;
|
|
160
|
-
|
|
161
|
-
leadingActionVariant: "primary" | "secondary" | "outline" | "outline-inverse" | "ghost" | "inverse" | "ghost-inverse" | "destructive" | "destructive-ghost";
|
|
165
|
+
leadingAction: ModalProps['leadingAction'];
|
|
162
166
|
position: "top" | "center";
|
|
163
|
-
returnFocusAfterCloseSelector
|
|
167
|
+
returnFocusAfterCloseSelector: ModalProps['returnFocusAfterCloseSelector'];
|
|
164
168
|
size: "medium" | "large" | "small";
|
|
165
|
-
|
|
166
|
-
supportingActionVariant: "primary" | "secondary" | "outline" | "outline-inverse" | "ghost" | "inverse" | "ghost-inverse" | "destructive" | "destructive-ghost";
|
|
169
|
+
supportingAction: ModalProps['supportingAction'];
|
|
167
170
|
private _dialog?;
|
|
168
171
|
private _backButtonClicked;
|
|
169
172
|
static styles: CSSResult;
|
|
@@ -211,9 +214,9 @@ export declare class PieModal extends PieModal_base implements ModalProps {
|
|
|
211
214
|
/**
|
|
212
215
|
* Renders the "leadingAction" button if the text is provided.
|
|
213
216
|
*
|
|
214
|
-
* If `
|
|
215
|
-
* If `
|
|
216
|
-
* The (optional) aria-label is read from
|
|
217
|
+
* If `leadingAction.text` is not provided, the button is not rendered.
|
|
218
|
+
* If `leadingAction.variant` is not provided, the default value of "primary" is used.
|
|
219
|
+
* The (optional) aria-label is read from `leadingAction.ariaLabel`.
|
|
217
220
|
*
|
|
218
221
|
* @private
|
|
219
222
|
*/
|
|
@@ -222,8 +225,9 @@ export declare class PieModal extends PieModal_base implements ModalProps {
|
|
|
222
225
|
* Renders the "supportingAction" button if the text is provided.
|
|
223
226
|
* You cannot have a supporting action without a leading action.
|
|
224
227
|
*
|
|
225
|
-
* If `
|
|
226
|
-
* If `
|
|
228
|
+
* If either `supportingAction.text` or `leadingAction.text` are not provided, the button is not rendered.
|
|
229
|
+
* If `supportingAction.variant` is not provided, the default value of "ghost" is used.
|
|
230
|
+
* The (optional) aria-label is read from `supportingAction.ariaLabel`.
|
|
227
231
|
*
|
|
228
232
|
* @private
|
|
229
233
|
*/
|
package/dist/index.js
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import { LitElement as
|
|
2
|
-
import { html as m, unsafeStatic as
|
|
3
|
-
import { property as d, query as
|
|
4
|
-
import { classMap as
|
|
5
|
-
import { ifDefined as
|
|
1
|
+
import { LitElement as I, nothing as g, unsafeCSS as N } from "lit";
|
|
2
|
+
import { html as m, unsafeStatic as R } from "lit/static-html.js";
|
|
3
|
+
import { property as d, query as W } from "lit/decorators.js";
|
|
4
|
+
import { classMap as j } from "lit/directives/class-map.js";
|
|
5
|
+
import { ifDefined as B } from "lit/directives/if-defined.js";
|
|
6
6
|
import "@justeattakeaway/pie-button";
|
|
7
7
|
import "@justeattakeaway/pie-icon-button";
|
|
8
|
-
import { RtlMixin as Y, dispatchCustomEvent as u, requiredProperty as
|
|
8
|
+
import { RtlMixin as Y, dispatchCustomEvent as u, requiredProperty as V, validPropertyValues as S, defineCustomElement as q } 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 H(
|
|
14
|
-
if (Array.isArray(
|
|
15
|
-
for (var e = 0, i = Array(
|
|
16
|
-
i[e] =
|
|
13
|
+
function H(n) {
|
|
14
|
+
if (Array.isArray(n)) {
|
|
15
|
+
for (var e = 0, i = Array(n.length); e < n.length; e++)
|
|
16
|
+
i[e] = n[e];
|
|
17
17
|
return i;
|
|
18
18
|
} else
|
|
19
|
-
return Array.from(
|
|
19
|
+
return Array.from(n);
|
|
20
20
|
}
|
|
21
|
-
var
|
|
21
|
+
var A = !1;
|
|
22
22
|
if (typeof window < "u") {
|
|
23
|
-
var
|
|
23
|
+
var $ = {
|
|
24
24
|
get passive() {
|
|
25
|
-
|
|
25
|
+
A = !0;
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
|
-
window.addEventListener("testPassive", null,
|
|
28
|
+
window.addEventListener("testPassive", null, $), window.removeEventListener("testPassive", null, $);
|
|
29
29
|
}
|
|
30
|
-
var
|
|
30
|
+
var D = typeof window < "u" && window.navigator && window.navigator.platform && (/iP(ad|hone|od)/.test(window.navigator.platform) || window.navigator.platform === "MacIntel" && window.navigator.maxTouchPoints > 1), p = [], y = !1, F = -1, f = void 0, v = void 0, P = function(e) {
|
|
31
31
|
return p.some(function(i) {
|
|
32
32
|
return !!(i.options.allowTouchMove && i.options.allowTouchMove(e));
|
|
33
33
|
});
|
|
34
34
|
}, x = function(e) {
|
|
35
35
|
var i = e || window.event;
|
|
36
|
-
return
|
|
36
|
+
return P(i.target) || i.touches.length > 1 ? !0 : (i.preventDefault && i.preventDefault(), !1);
|
|
37
37
|
}, K = function(e) {
|
|
38
38
|
if (v === void 0) {
|
|
39
|
-
var i = !!e && e.reserveScrollBarGap === !0,
|
|
40
|
-
i &&
|
|
39
|
+
var i = !!e && e.reserveScrollBarGap === !0, o = window.innerWidth - document.documentElement.clientWidth;
|
|
40
|
+
i && o > 0 && (v = document.body.style.paddingRight, document.body.style.paddingRight = o + "px");
|
|
41
41
|
}
|
|
42
42
|
f === void 0 && (f = document.body.style.overflow, document.body.style.overflow = "hidden");
|
|
43
43
|
}, U = function() {
|
|
@@ -45,25 +45,25 @@ var M = typeof window < "u" && window.navigator && window.navigator.platform &&
|
|
|
45
45
|
}, G = function(e) {
|
|
46
46
|
return e ? e.scrollHeight - e.scrollTop <= e.clientHeight : !1;
|
|
47
47
|
}, X = function(e, i) {
|
|
48
|
-
var
|
|
49
|
-
return
|
|
48
|
+
var o = e.targetTouches[0].clientY - F;
|
|
49
|
+
return P(e.target) ? !1 : i && i.scrollTop === 0 && o > 0 || G(i) && o < 0 ? x(e) : (e.stopPropagation(), !0);
|
|
50
50
|
}, J = function(e, i) {
|
|
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 (!p.some(function(
|
|
56
|
-
return
|
|
55
|
+
if (!p.some(function(t) {
|
|
56
|
+
return t.targetElement === e;
|
|
57
57
|
})) {
|
|
58
|
-
var
|
|
58
|
+
var o = {
|
|
59
59
|
targetElement: e,
|
|
60
60
|
options: i || {}
|
|
61
61
|
};
|
|
62
|
-
p = [].concat(H(p), [
|
|
63
|
-
|
|
64
|
-
}, e.ontouchmove = function(
|
|
65
|
-
|
|
66
|
-
}, y || (document.addEventListener("touchmove", x,
|
|
62
|
+
p = [].concat(H(p), [o]), D ? (e.ontouchstart = function(t) {
|
|
63
|
+
t.targetTouches.length === 1 && (F = t.targetTouches[0].clientY);
|
|
64
|
+
}, e.ontouchmove = function(t) {
|
|
65
|
+
t.targetTouches.length === 1 && X(t, e);
|
|
66
|
+
}, y || (document.addEventListener("touchmove", x, A ? { passive: !1 } : void 0), y = !0)) : K(i);
|
|
67
67
|
}
|
|
68
68
|
}, Q = function(e) {
|
|
69
69
|
if (!e) {
|
|
@@ -72,10 +72,10 @@ var M = typeof window < "u" && window.navigator && window.navigator.platform &&
|
|
|
72
72
|
}
|
|
73
73
|
p = p.filter(function(i) {
|
|
74
74
|
return i.targetElement !== e;
|
|
75
|
-
}),
|
|
75
|
+
}), D ? (e.ontouchstart = null, e.ontouchmove = null, y && p.length === 0 && (document.removeEventListener("touchmove", x, A ? { passive: !1 } : void 0), y = !1)) : p.length || U();
|
|
76
76
|
};
|
|
77
|
-
const Z = `*,*: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[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 (width < 768px){.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 (width < 768px){.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 (width < 768px){.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: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[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(--
|
|
78
|
-
`, ee = ["h1", "h2", "h3", "h4", "h5", "h6"], ie = ["small", "medium", "large"],
|
|
77
|
+
const Z = `*,*: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[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 (width < 768px){.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 (width < 768px){.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 (width < 768px){.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: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[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);--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.c-modal-hasFooterActions{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[isfooterpinned] .c-modal-content{overflow-y:auto}.c-modal[isLoading] .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[isLoading] .c-modal-content .c-modal-contentInner{display:none}.c-modal[isLoading] .c-modal-content.c-modal-hasFooterActions pie-spinner{top:50%}@supports not (aspect-ratio: 1/1){.c-modal .c-modal-scrollContainer{background:none}}
|
|
78
|
+
`, ee = ["h1", "h2", "h3", "h4", "h5", "h6"], ie = ["small", "medium", "large"], oe = ["top", "center"], O = "pie-modal-close", w = "pie-modal-open", L = "pie-modal-back", te = "pie-modal-leading-action-click", ae = "pie-modal-supporting-action-click", s = {
|
|
79
79
|
hasBackButton: !1,
|
|
80
80
|
hasStackedActions: !1,
|
|
81
81
|
headingLevel: "h2",
|
|
@@ -84,44 +84,42 @@ const Z = `*,*:after,*:before{box-sizing:inherit}dialog{position:absolute;left:0
|
|
|
84
84
|
isFooterPinned: !0,
|
|
85
85
|
isFullWidthBelowMid: !1,
|
|
86
86
|
isLoading: !1,
|
|
87
|
-
leadingActionVariant: "primary",
|
|
88
87
|
position: "center",
|
|
89
|
-
size: "medium"
|
|
90
|
-
supportingActionVariant: "ghost"
|
|
88
|
+
size: "medium"
|
|
91
89
|
};
|
|
92
|
-
var
|
|
93
|
-
for (var
|
|
94
|
-
(c =
|
|
95
|
-
return
|
|
90
|
+
var ne = Object.defineProperty, le = Object.getOwnPropertyDescriptor, l = (n, e, i, o) => {
|
|
91
|
+
for (var t = o > 1 ? void 0 : o ? le(e, i) : e, r = n.length - 1, c; r >= 0; r--)
|
|
92
|
+
(c = n[r]) && (t = (o ? c(e, i, t) : c(t)) || t);
|
|
93
|
+
return o && t && ne(e, i, t), t;
|
|
96
94
|
};
|
|
97
95
|
const b = "pie-modal";
|
|
98
|
-
class
|
|
96
|
+
class a extends Y(I) {
|
|
99
97
|
constructor() {
|
|
100
|
-
super(...arguments), this.headingLevel =
|
|
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) => {
|
|
101
99
|
this.isDismissible || e.preventDefault();
|
|
102
100
|
}, this._handleDialogLightDismiss = (e) => {
|
|
103
101
|
var k;
|
|
104
102
|
if (!this.isDismissible)
|
|
105
103
|
return;
|
|
106
104
|
const i = (k = this._dialog) == null ? void 0 : k.getBoundingClientRect(), {
|
|
107
|
-
top:
|
|
108
|
-
bottom:
|
|
109
|
-
left:
|
|
105
|
+
top: o = 0,
|
|
106
|
+
bottom: t = 0,
|
|
107
|
+
left: r = 0,
|
|
110
108
|
right: c = 0
|
|
111
109
|
} = i || {};
|
|
112
|
-
if (
|
|
110
|
+
if (o === 0 && t === 0 && r === 0 && c === 0)
|
|
113
111
|
return;
|
|
114
|
-
(e.clientY <
|
|
112
|
+
(e.clientY < o || e.clientY > t || e.clientX < r || e.clientX > c) && (this.isOpen = !1);
|
|
115
113
|
};
|
|
116
114
|
}
|
|
117
115
|
connectedCallback() {
|
|
118
|
-
super.connectedCallback(), this.addEventListener("click", (e) => this._handleDialogLightDismiss(e)), document.addEventListener(w, (e) => this._handleModalOpened(e)), document.addEventListener(
|
|
116
|
+
super.connectedCallback(), this.addEventListener("click", (e) => this._handleDialogLightDismiss(e)), document.addEventListener(w, (e) => this._handleModalOpened(e)), document.addEventListener(O, (e) => this._handleModalClosed(e)), document.addEventListener(L, (e) => this._handleModalClosed(e));
|
|
119
117
|
}
|
|
120
118
|
disconnectedCallback() {
|
|
121
|
-
document.removeEventListener(w, (e) => this._handleModalOpened(e)), document.removeEventListener(
|
|
119
|
+
document.removeEventListener(w, (e) => this._handleModalOpened(e)), document.removeEventListener(O, (e) => this._handleModalClosed(e)), document.removeEventListener(L, (e) => this._handleModalClosed(e)), super.disconnectedCallback();
|
|
122
120
|
}
|
|
123
121
|
async firstUpdated(e) {
|
|
124
|
-
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((o) => o.default)).registerDialog(this._dialog), this._dialog.addEventListener("cancel", (o) => this._handleDialogCancelEvent(o)), this._dialog.addEventListener("close", () => {
|
|
125
123
|
this.isOpen = !1;
|
|
126
124
|
})), this._handleModalOpenStateOnFirstRender(e);
|
|
127
125
|
}
|
|
@@ -132,11 +130,11 @@ class n extends Y(V) {
|
|
|
132
130
|
* Opens the dialog element and disables page scrolling
|
|
133
131
|
*/
|
|
134
132
|
_handleModalOpened(e) {
|
|
135
|
-
var
|
|
133
|
+
var o, t, r, c;
|
|
136
134
|
const { targetModal: i } = e.detail;
|
|
137
135
|
if (i === this) {
|
|
138
|
-
const h = (
|
|
139
|
-
if (h && ("scrollTo" in window && window.scrollTo(0, 0), J(h)), (
|
|
136
|
+
const h = (o = this._dialog) == null ? void 0 : o.querySelector(".c-modal-scrollContainer");
|
|
137
|
+
if (h && ("scrollTo" in window && window.scrollTo(0, 0), J(h)), (t = this._dialog) != null && t.hasAttribute("open") || !((r = this._dialog) != null && r.isConnected))
|
|
140
138
|
return;
|
|
141
139
|
(c = this._dialog) == null || c.showModal();
|
|
142
140
|
}
|
|
@@ -145,11 +143,11 @@ class n extends Y(V) {
|
|
|
145
143
|
* Closes the dialog element and re-enables page scrolling
|
|
146
144
|
*/
|
|
147
145
|
_handleModalClosed(e) {
|
|
148
|
-
var
|
|
146
|
+
var o, t;
|
|
149
147
|
const { targetModal: i } = e.detail;
|
|
150
148
|
if (i === this) {
|
|
151
|
-
const
|
|
152
|
-
|
|
149
|
+
const r = (o = this._dialog) == null ? void 0 : o.querySelector(".c-modal-scrollContainer");
|
|
150
|
+
r && Q(r), (t = this._dialog) == null || t.close(), this._returnFocus();
|
|
153
151
|
}
|
|
154
152
|
}
|
|
155
153
|
// Handles the value of the isOpen property on first render of the component
|
|
@@ -159,20 +157,20 @@ class n extends Y(V) {
|
|
|
159
157
|
// Handles changes to the modal isOpen property by dispatching any appropriate events
|
|
160
158
|
_handleModalOpenStateChanged(e) {
|
|
161
159
|
const i = e.get("isOpen");
|
|
162
|
-
i !== void 0 && (i ? this._backButtonClicked ? (this._backButtonClicked = !1, u(this,
|
|
160
|
+
i !== void 0 && (i ? this._backButtonClicked ? (this._backButtonClicked = !1, u(this, L, { targetModal: this })) : u(this, O, { targetModal: this }) : u(this, w, { targetModal: this }));
|
|
163
161
|
}
|
|
164
162
|
_handleActionClick(e) {
|
|
165
|
-
var i,
|
|
166
|
-
e === "leading" ? ((i = this._dialog) == null || i.close("leading"), u(this,
|
|
163
|
+
var i, o;
|
|
164
|
+
e === "leading" ? ((i = this._dialog) == null || i.close("leading"), u(this, te, { targetModal: this })) : e === "supporting" && ((o = this._dialog) == null || o.close("supporting"), u(this, ae, { targetModal: this }));
|
|
167
165
|
}
|
|
168
166
|
/**
|
|
169
167
|
* Return focus to the specified element, providing the selector is valid
|
|
170
168
|
* and the chosen element can be found.
|
|
171
169
|
*/
|
|
172
170
|
_returnFocus() {
|
|
173
|
-
var i,
|
|
171
|
+
var i, o;
|
|
174
172
|
const e = (i = this.returnFocusAfterCloseSelector) == null ? void 0 : i.trim();
|
|
175
|
-
e && ((
|
|
173
|
+
e && ((o = document.querySelector(e)) == null || o.focus());
|
|
176
174
|
}
|
|
177
175
|
/**
|
|
178
176
|
* Template for the close button element. Called within the
|
|
@@ -209,7 +207,7 @@ class n extends Y(V) {
|
|
|
209
207
|
}}"
|
|
210
208
|
variant="ghost-secondary"
|
|
211
209
|
class="c-modal-backBtn"
|
|
212
|
-
aria-label="${
|
|
210
|
+
aria-label="${B((e = this.aria) == null ? void 0 : e.back)}"
|
|
213
211
|
data-test-id="modal-back-button">
|
|
214
212
|
${this.isRTL ? m`<icon-chevron-right></icon-chevron-right>` : m`<icon-chevron-left></icon-chevron-left>`}
|
|
215
213
|
</pie-icon-button>
|
|
@@ -218,23 +216,23 @@ class n extends Y(V) {
|
|
|
218
216
|
/**
|
|
219
217
|
* Renders the "leadingAction" button if the text is provided.
|
|
220
218
|
*
|
|
221
|
-
* If `
|
|
222
|
-
* If `
|
|
223
|
-
* The (optional) aria-label is read from
|
|
219
|
+
* If `leadingAction.text` is not provided, the button is not rendered.
|
|
220
|
+
* If `leadingAction.variant` is not provided, the default value of "primary" is used.
|
|
221
|
+
* The (optional) aria-label is read from `leadingAction.ariaLabel`.
|
|
224
222
|
*
|
|
225
223
|
* @private
|
|
226
224
|
*/
|
|
227
225
|
renderLeadingAction() {
|
|
228
|
-
|
|
229
|
-
return
|
|
226
|
+
const { ariaLabel: e, text: i, variant: o = "primary" } = this.leadingAction || {};
|
|
227
|
+
return i ? m`
|
|
230
228
|
<pie-button
|
|
231
|
-
variant="${
|
|
232
|
-
aria-label="${
|
|
229
|
+
variant="${o}"
|
|
230
|
+
aria-label="${B(e)}"
|
|
233
231
|
type="submit"
|
|
234
232
|
?isFullWidth="${this.hasStackedActions}"
|
|
235
233
|
@click="${() => this._handleActionClick("leading")}"
|
|
236
234
|
data-test-id="modal-leading-action">
|
|
237
|
-
${
|
|
235
|
+
${i}
|
|
238
236
|
</pie-button>
|
|
239
237
|
` : g;
|
|
240
238
|
}
|
|
@@ -242,22 +240,24 @@ class n extends Y(V) {
|
|
|
242
240
|
* Renders the "supportingAction" button if the text is provided.
|
|
243
241
|
* You cannot have a supporting action without a leading action.
|
|
244
242
|
*
|
|
245
|
-
* If `
|
|
246
|
-
* If `
|
|
243
|
+
* If either `supportingAction.text` or `leadingAction.text` are not provided, the button is not rendered.
|
|
244
|
+
* If `supportingAction.variant` is not provided, the default value of "ghost" is used.
|
|
245
|
+
* The (optional) aria-label is read from `supportingAction.ariaLabel`.
|
|
247
246
|
*
|
|
248
247
|
* @private
|
|
249
248
|
*/
|
|
250
249
|
renderSupportingAction() {
|
|
251
|
-
var
|
|
252
|
-
|
|
250
|
+
var t;
|
|
251
|
+
const { ariaLabel: e, text: i, variant: o = "ghost" } = this.supportingAction || {};
|
|
252
|
+
return i ? (t = this.leadingAction) != null && t.text ? m`
|
|
253
253
|
<pie-button
|
|
254
|
-
variant="${
|
|
255
|
-
aria-label="${
|
|
254
|
+
variant="${o}"
|
|
255
|
+
aria-label="${B(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
|
+
${i}
|
|
261
261
|
</pie-button>
|
|
262
262
|
` : (console.warn("You cannot have a supporting action without a leading action. If you only need one button then use a leading action instead."), g) : g;
|
|
263
263
|
}
|
|
@@ -266,9 +266,10 @@ class n extends Y(V) {
|
|
|
266
266
|
* @private
|
|
267
267
|
*/
|
|
268
268
|
renderModalContentAndFooter() {
|
|
269
|
-
|
|
269
|
+
var o;
|
|
270
|
+
const e = !!((o = this.leadingAction) != null && o.text);
|
|
270
271
|
return m`
|
|
271
|
-
<article class=${
|
|
272
|
+
<article class=${j({
|
|
272
273
|
"c-modal-scrollContainer": !0,
|
|
273
274
|
"c-modal-content": !0,
|
|
274
275
|
"c-modal-content--scrollable": !0,
|
|
@@ -289,27 +290,27 @@ class n extends Y(V) {
|
|
|
289
290
|
const {
|
|
290
291
|
aria: e,
|
|
291
292
|
hasBackButton: i,
|
|
292
|
-
hasStackedActions:
|
|
293
|
-
heading:
|
|
294
|
-
headingLevel:
|
|
293
|
+
hasStackedActions: o,
|
|
294
|
+
heading: t,
|
|
295
|
+
headingLevel: r,
|
|
295
296
|
isDismissible: c,
|
|
296
297
|
isFooterPinned: h,
|
|
297
298
|
isFullWidthBelowMid: k,
|
|
298
299
|
isLoading: z,
|
|
299
|
-
|
|
300
|
-
position:
|
|
301
|
-
size:
|
|
302
|
-
|
|
303
|
-
} = this,
|
|
300
|
+
leadingAction: _,
|
|
301
|
+
position: E,
|
|
302
|
+
size: T,
|
|
303
|
+
supportingAction: C
|
|
304
|
+
} = this, M = R(r);
|
|
304
305
|
return m`
|
|
305
306
|
<dialog
|
|
306
307
|
id="dialog"
|
|
307
308
|
class="c-modal"
|
|
308
|
-
size="${
|
|
309
|
-
position="${
|
|
310
|
-
?hasActions=${
|
|
309
|
+
size="${T}"
|
|
310
|
+
position="${E}"
|
|
311
|
+
?hasActions=${(_ == null ? void 0 : _.text) || (C == null ? void 0 : C.text)}
|
|
311
312
|
?hasBackButton=${i}
|
|
312
|
-
?hasStackedActions=${
|
|
313
|
+
?hasStackedActions=${o}
|
|
313
314
|
?isDismissible=${c}
|
|
314
315
|
?isFooterPinned=${h}
|
|
315
316
|
?isFullWidthBelowMid=${k}
|
|
@@ -320,9 +321,9 @@ class n extends Y(V) {
|
|
|
320
321
|
<header class="c-modal-header"
|
|
321
322
|
data-test-id="modal-header">
|
|
322
323
|
${this.renderBackButton()}
|
|
323
|
-
<${
|
|
324
|
-
${
|
|
325
|
-
</${
|
|
324
|
+
<${M} class="c-modal-heading">
|
|
325
|
+
${t}
|
|
326
|
+
</${M}>
|
|
326
327
|
${this.renderCloseButton()}
|
|
327
328
|
</header>
|
|
328
329
|
${// We need to wrap the remaining content in a shared scrollable container if the footer is not pinned
|
|
@@ -334,75 +335,69 @@ class n extends Y(V) {
|
|
|
334
335
|
</dialog>`;
|
|
335
336
|
}
|
|
336
337
|
}
|
|
337
|
-
|
|
338
|
-
|
|
338
|
+
a.styles = N(Z);
|
|
339
|
+
l([
|
|
339
340
|
d({ type: Object })
|
|
340
|
-
],
|
|
341
|
-
|
|
341
|
+
], a.prototype, "aria", 2);
|
|
342
|
+
l([
|
|
342
343
|
d({ type: String }),
|
|
343
|
-
|
|
344
|
-
],
|
|
345
|
-
|
|
344
|
+
V(b)
|
|
345
|
+
], a.prototype, "heading", 2);
|
|
346
|
+
l([
|
|
346
347
|
d(),
|
|
347
|
-
|
|
348
|
-
],
|
|
349
|
-
|
|
348
|
+
S(b, ee, s.headingLevel)
|
|
349
|
+
], a.prototype, "headingLevel", 2);
|
|
350
|
+
l([
|
|
350
351
|
d({ type: Boolean })
|
|
351
|
-
],
|
|
352
|
-
|
|
352
|
+
], a.prototype, "hasBackButton", 2);
|
|
353
|
+
l([
|
|
353
354
|
d({ type: Boolean })
|
|
354
|
-
],
|
|
355
|
-
|
|
355
|
+
], a.prototype, "hasStackedActions", 2);
|
|
356
|
+
l([
|
|
356
357
|
d({ type: Boolean, reflect: !0 })
|
|
357
|
-
],
|
|
358
|
-
|
|
358
|
+
], a.prototype, "isDismissible", 2);
|
|
359
|
+
l([
|
|
359
360
|
d({ type: Boolean })
|
|
360
|
-
],
|
|
361
|
-
|
|
361
|
+
], a.prototype, "isFooterPinned", 2);
|
|
362
|
+
l([
|
|
362
363
|
d({ type: Boolean })
|
|
363
|
-
],
|
|
364
|
-
|
|
364
|
+
], a.prototype, "isFullWidthBelowMid", 2);
|
|
365
|
+
l([
|
|
365
366
|
d({ type: Boolean, reflect: !0 })
|
|
366
|
-
],
|
|
367
|
-
|
|
367
|
+
], a.prototype, "isLoading", 2);
|
|
368
|
+
l([
|
|
368
369
|
d({ type: Boolean })
|
|
369
|
-
],
|
|
370
|
-
|
|
371
|
-
d({ type:
|
|
372
|
-
],
|
|
373
|
-
|
|
374
|
-
d({ type: String })
|
|
375
|
-
], n.prototype, "leadingActionVariant", 2);
|
|
376
|
-
a([
|
|
370
|
+
], a.prototype, "isOpen", 2);
|
|
371
|
+
l([
|
|
372
|
+
d({ type: Object })
|
|
373
|
+
], a.prototype, "leadingAction", 2);
|
|
374
|
+
l([
|
|
377
375
|
d(),
|
|
378
|
-
|
|
379
|
-
],
|
|
380
|
-
|
|
376
|
+
S(b, oe, s.position)
|
|
377
|
+
], a.prototype, "position", 2);
|
|
378
|
+
l([
|
|
381
379
|
d()
|
|
382
|
-
],
|
|
383
|
-
|
|
380
|
+
], a.prototype, "returnFocusAfterCloseSelector", 2);
|
|
381
|
+
l([
|
|
384
382
|
d(),
|
|
385
|
-
|
|
386
|
-
],
|
|
387
|
-
|
|
388
|
-
d({ type:
|
|
389
|
-
],
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
],
|
|
393
|
-
a
|
|
394
|
-
R("dialog")
|
|
395
|
-
], n.prototype, "_dialog", 2);
|
|
396
|
-
q(b, n);
|
|
383
|
+
S(b, ie, s.size)
|
|
384
|
+
], a.prototype, "size", 2);
|
|
385
|
+
l([
|
|
386
|
+
d({ type: Object })
|
|
387
|
+
], a.prototype, "supportingAction", 2);
|
|
388
|
+
l([
|
|
389
|
+
W("dialog")
|
|
390
|
+
], a.prototype, "_dialog", 2);
|
|
391
|
+
q(b, a);
|
|
397
392
|
export {
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
393
|
+
L as ON_MODAL_BACK_EVENT,
|
|
394
|
+
O as ON_MODAL_CLOSE_EVENT,
|
|
395
|
+
te as ON_MODAL_LEADING_ACTION_CLICK,
|
|
401
396
|
w as ON_MODAL_OPEN_EVENT,
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
397
|
+
ae as ON_MODAL_SUPPORTING_ACTION_CLICK,
|
|
398
|
+
a as PieModal,
|
|
399
|
+
s as defaultProps,
|
|
405
400
|
ee as headingLevels,
|
|
406
|
-
|
|
401
|
+
oe as positions,
|
|
407
402
|
ie as sizes
|
|
408
403
|
};
|
package/dist/react.d.ts
CHANGED
|
@@ -8,15 +8,28 @@ import type { RTLInterface } from '@justeattakeaway/pie-webc-core';
|
|
|
8
8
|
import type { TemplateResult } from 'lit';
|
|
9
9
|
import { Variant } from '@justeattakeaway/pie-button/src/defs.ts';
|
|
10
10
|
|
|
11
|
+
declare type ActionProps = {
|
|
12
|
+
/**
|
|
13
|
+
* The text to display inside the button.
|
|
14
|
+
*/
|
|
15
|
+
text: string;
|
|
16
|
+
/**
|
|
17
|
+
* The button variant.
|
|
18
|
+
*/
|
|
19
|
+
variant?: Variant;
|
|
20
|
+
/**
|
|
21
|
+
* The aria label for the button.
|
|
22
|
+
*/
|
|
23
|
+
ariaLabel?: string;
|
|
24
|
+
};
|
|
25
|
+
|
|
11
26
|
export declare type AriaProps = {
|
|
12
27
|
close?: string;
|
|
13
28
|
back?: string;
|
|
14
29
|
loading?: string;
|
|
15
|
-
leadingActionLabel?: string;
|
|
16
|
-
supportingActionLabel?: string;
|
|
17
30
|
};
|
|
18
31
|
|
|
19
|
-
export declare type DefaultProps = ComponentDefaultProps<ModalProps, keyof Omit<ModalProps, 'aria' | 'heading' | '
|
|
32
|
+
export declare type DefaultProps = ComponentDefaultProps<ModalProps, keyof Omit<ModalProps, 'aria' | 'heading' | 'leadingAction' | 'supportingAction' | 'returnFocusAfterCloseSelector'>>;
|
|
20
33
|
|
|
21
34
|
export declare const defaultProps: DefaultProps;
|
|
22
35
|
|
|
@@ -26,7 +39,7 @@ export declare type ModalActionType = 'leading' | 'supporting';
|
|
|
26
39
|
|
|
27
40
|
export declare type ModalProps = {
|
|
28
41
|
/**
|
|
29
|
-
* The ARIA labels used for the modal
|
|
42
|
+
* The ARIA labels used for the modal close and back buttons, as well as for the loading state.
|
|
30
43
|
*/
|
|
31
44
|
aria?: AriaProps;
|
|
32
45
|
/**
|
|
@@ -74,21 +87,13 @@ export declare type ModalProps = {
|
|
|
74
87
|
*/
|
|
75
88
|
isLoading?: boolean;
|
|
76
89
|
/**
|
|
77
|
-
* The
|
|
78
|
-
*/
|
|
79
|
-
leadingActionText?: string;
|
|
80
|
-
/**
|
|
81
|
-
* The button variant for the leading action button.
|
|
82
|
-
*/
|
|
83
|
-
leadingActionVariant?: Variant;
|
|
84
|
-
/**
|
|
85
|
-
* The text to display inside the supporting action button.
|
|
90
|
+
* The leading action configuration for the modal.
|
|
86
91
|
*/
|
|
87
|
-
|
|
92
|
+
leadingAction?: ActionProps;
|
|
88
93
|
/**
|
|
89
|
-
* The
|
|
94
|
+
* The supporting action configuration for the modal.
|
|
90
95
|
*/
|
|
91
|
-
|
|
96
|
+
supportingAction?: ActionProps;
|
|
92
97
|
position?: typeof positions[number];
|
|
93
98
|
/**
|
|
94
99
|
* The selector for the element that you would like focus to be returned to when the modal is closed, e.g., #skipToMain
|
|
@@ -156,13 +161,11 @@ declare class PieModal_2 extends PieModal_base implements ModalProps {
|
|
|
156
161
|
isFullWidthBelowMid: boolean;
|
|
157
162
|
isLoading: boolean;
|
|
158
163
|
isOpen: boolean;
|
|
159
|
-
|
|
160
|
-
leadingActionVariant: "primary" | "secondary" | "outline" | "outline-inverse" | "ghost" | "inverse" | "ghost-inverse" | "destructive" | "destructive-ghost";
|
|
164
|
+
leadingAction: ModalProps['leadingAction'];
|
|
161
165
|
position: "top" | "center";
|
|
162
|
-
returnFocusAfterCloseSelector
|
|
166
|
+
returnFocusAfterCloseSelector: ModalProps['returnFocusAfterCloseSelector'];
|
|
163
167
|
size: "medium" | "large" | "small";
|
|
164
|
-
|
|
165
|
-
supportingActionVariant: "primary" | "secondary" | "outline" | "outline-inverse" | "ghost" | "inverse" | "ghost-inverse" | "destructive" | "destructive-ghost";
|
|
168
|
+
supportingAction: ModalProps['supportingAction'];
|
|
166
169
|
private _dialog?;
|
|
167
170
|
private _backButtonClicked;
|
|
168
171
|
static styles: CSSResult;
|
|
@@ -210,9 +213,9 @@ declare class PieModal_2 extends PieModal_base implements ModalProps {
|
|
|
210
213
|
/**
|
|
211
214
|
* Renders the "leadingAction" button if the text is provided.
|
|
212
215
|
*
|
|
213
|
-
* If `
|
|
214
|
-
* If `
|
|
215
|
-
* The (optional) aria-label is read from
|
|
216
|
+
* If `leadingAction.text` is not provided, the button is not rendered.
|
|
217
|
+
* If `leadingAction.variant` is not provided, the default value of "primary" is used.
|
|
218
|
+
* The (optional) aria-label is read from `leadingAction.ariaLabel`.
|
|
216
219
|
*
|
|
217
220
|
* @private
|
|
218
221
|
*/
|
|
@@ -221,8 +224,9 @@ declare class PieModal_2 extends PieModal_base implements ModalProps {
|
|
|
221
224
|
* Renders the "supportingAction" button if the text is provided.
|
|
222
225
|
* You cannot have a supporting action without a leading action.
|
|
223
226
|
*
|
|
224
|
-
* If `
|
|
225
|
-
* If `
|
|
227
|
+
* If either `supportingAction.text` or `leadingAction.text` are not provided, the button is not rendered.
|
|
228
|
+
* If `supportingAction.variant` is not provided, the default value of "ghost" is used.
|
|
229
|
+
* The (optional) aria-label is read from `supportingAction.ariaLabel`.
|
|
226
230
|
*
|
|
227
231
|
* @private
|
|
228
232
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justeattakeaway/pie-modal",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.45.0",
|
|
4
4
|
"description": "PIE design system modal built using web components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -37,7 +37,8 @@
|
|
|
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.17.0",
|
|
41
|
+
"@justeattakeaway/pie-css": "0.12.1",
|
|
41
42
|
"@justeattakeaway/pie-wrapper-react": "0.14.1",
|
|
42
43
|
"@types/body-scroll-lock": "3.1.2",
|
|
43
44
|
"cem-plugin-module-file-extensions": "0.0.5"
|
|
@@ -46,10 +47,10 @@
|
|
|
46
47
|
"extends": "../../../package.json"
|
|
47
48
|
},
|
|
48
49
|
"dependencies": {
|
|
49
|
-
"@justeattakeaway/pie-button": "0.48.
|
|
50
|
-
"@justeattakeaway/pie-icon-button": "0.28.
|
|
51
|
-
"@justeattakeaway/pie-icons-webc": "0.
|
|
52
|
-
"@justeattakeaway/pie-spinner": "0.6.
|
|
50
|
+
"@justeattakeaway/pie-button": "0.48.1",
|
|
51
|
+
"@justeattakeaway/pie-icon-button": "0.28.10",
|
|
52
|
+
"@justeattakeaway/pie-icons-webc": "0.25.0",
|
|
53
|
+
"@justeattakeaway/pie-spinner": "0.6.7",
|
|
53
54
|
"@justeattakeaway/pie-webc-core": "0.24.0",
|
|
54
55
|
"body-scroll-lock": "3.1.5",
|
|
55
56
|
"dialog-polyfill": "0.5.6"
|
package/src/defs.ts
CHANGED
|
@@ -10,13 +10,28 @@ export type AriaProps = {
|
|
|
10
10
|
close?: string;
|
|
11
11
|
back?: string;
|
|
12
12
|
loading?: string;
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
type ActionProps = {
|
|
16
|
+
/**
|
|
17
|
+
* The text to display inside the button.
|
|
18
|
+
*/
|
|
19
|
+
text: string;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The button variant.
|
|
23
|
+
*/
|
|
24
|
+
variant?: ButtonVariant;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The aria label for the button.
|
|
28
|
+
*/
|
|
29
|
+
ariaLabel?: string;
|
|
15
30
|
};
|
|
16
31
|
|
|
17
32
|
export type ModalProps = {
|
|
18
33
|
/**
|
|
19
|
-
* The ARIA labels used for the modal
|
|
34
|
+
* The ARIA labels used for the modal close and back buttons, as well as for the loading state.
|
|
20
35
|
*/
|
|
21
36
|
aria?: AriaProps;
|
|
22
37
|
|
|
@@ -74,24 +89,14 @@ export type ModalProps = {
|
|
|
74
89
|
isLoading?: boolean;
|
|
75
90
|
|
|
76
91
|
/**
|
|
77
|
-
* The
|
|
78
|
-
*/
|
|
79
|
-
leadingActionText?: string;
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* The button variant for the leading action button.
|
|
83
|
-
*/
|
|
84
|
-
leadingActionVariant?: ButtonVariant;
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* The text to display inside the supporting action button.
|
|
92
|
+
* The leading action configuration for the modal.
|
|
88
93
|
*/
|
|
89
|
-
|
|
94
|
+
leadingAction?: ActionProps;
|
|
90
95
|
|
|
91
96
|
/**
|
|
92
|
-
* The
|
|
97
|
+
* The supporting action configuration for the modal.
|
|
93
98
|
*/
|
|
94
|
-
|
|
99
|
+
supportingAction?: ActionProps;
|
|
95
100
|
|
|
96
101
|
/*
|
|
97
102
|
* The position of the modal; this controls where it will appear on the page.
|
|
@@ -146,7 +151,7 @@ export const ON_MODAL_SUPPORTING_ACTION_CLICK = 'pie-modal-supporting-action-cli
|
|
|
146
151
|
|
|
147
152
|
export type ModalActionType = 'leading' | 'supporting';
|
|
148
153
|
|
|
149
|
-
export type DefaultProps = ComponentDefaultProps<ModalProps, keyof Omit<ModalProps, 'aria' | 'heading' | '
|
|
154
|
+
export type DefaultProps = ComponentDefaultProps<ModalProps, keyof Omit<ModalProps, 'aria' | 'heading' | 'leadingAction' | 'supportingAction' | 'returnFocusAfterCloseSelector'>>;
|
|
150
155
|
|
|
151
156
|
export const defaultProps: DefaultProps = {
|
|
152
157
|
hasBackButton: false,
|
|
@@ -157,8 +162,6 @@ export const defaultProps: DefaultProps = {
|
|
|
157
162
|
isFooterPinned: true,
|
|
158
163
|
isFullWidthBelowMid: false,
|
|
159
164
|
isLoading: false,
|
|
160
|
-
leadingActionVariant: 'primary',
|
|
161
165
|
position: 'center',
|
|
162
166
|
size: 'medium',
|
|
163
|
-
supportingActionVariant: 'ghost',
|
|
164
167
|
};
|
package/src/index.ts
CHANGED
|
@@ -86,28 +86,22 @@ export class PieModal extends RtlMixin(LitElement) implements ModalProps {
|
|
|
86
86
|
@property({ type: Boolean })
|
|
87
87
|
public isOpen = defaultProps.isOpen;
|
|
88
88
|
|
|
89
|
-
@property({ type:
|
|
90
|
-
public
|
|
91
|
-
|
|
92
|
-
@property({ type: String })
|
|
93
|
-
public leadingActionVariant = defaultProps.leadingActionVariant;
|
|
89
|
+
@property({ type: Object })
|
|
90
|
+
public leadingAction: ModalProps['leadingAction'];
|
|
94
91
|
|
|
95
92
|
@property()
|
|
96
93
|
@validPropertyValues(componentSelector, positions, defaultProps.position)
|
|
97
94
|
public position = defaultProps.position;
|
|
98
95
|
|
|
99
96
|
@property()
|
|
100
|
-
public returnFocusAfterCloseSelector
|
|
97
|
+
public returnFocusAfterCloseSelector: ModalProps['returnFocusAfterCloseSelector'];
|
|
101
98
|
|
|
102
99
|
@property()
|
|
103
100
|
@validPropertyValues(componentSelector, sizes, defaultProps.size)
|
|
104
101
|
public size = defaultProps.size;
|
|
105
102
|
|
|
106
|
-
@property({ type:
|
|
107
|
-
public
|
|
108
|
-
|
|
109
|
-
@property({ type: String })
|
|
110
|
-
public supportingActionVariant = defaultProps.supportingActionVariant;
|
|
103
|
+
@property({ type: Object })
|
|
104
|
+
public supportingAction: ModalProps['supportingAction'];
|
|
111
105
|
|
|
112
106
|
@query('dialog')
|
|
113
107
|
private _dialog?: HTMLDialogElement;
|
|
@@ -307,26 +301,26 @@ export class PieModal extends RtlMixin(LitElement) implements ModalProps {
|
|
|
307
301
|
/**
|
|
308
302
|
* Renders the "leadingAction" button if the text is provided.
|
|
309
303
|
*
|
|
310
|
-
* If `
|
|
311
|
-
* If `
|
|
312
|
-
* The (optional) aria-label is read from
|
|
304
|
+
* If `leadingAction.text` is not provided, the button is not rendered.
|
|
305
|
+
* If `leadingAction.variant` is not provided, the default value of "primary" is used.
|
|
306
|
+
* The (optional) aria-label is read from `leadingAction.ariaLabel`.
|
|
313
307
|
*
|
|
314
308
|
* @private
|
|
315
309
|
*/
|
|
316
310
|
private renderLeadingAction () : TemplateResult | typeof nothing {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
311
|
+
const { ariaLabel, text, variant = 'primary' } = this.leadingAction || {};
|
|
312
|
+
|
|
313
|
+
if (!text) return nothing;
|
|
320
314
|
|
|
321
315
|
return html`
|
|
322
316
|
<pie-button
|
|
323
|
-
variant="${
|
|
324
|
-
aria-label="${ifDefined(
|
|
317
|
+
variant="${variant}"
|
|
318
|
+
aria-label="${ifDefined(ariaLabel)}"
|
|
325
319
|
type="submit"
|
|
326
320
|
?isFullWidth="${this.hasStackedActions}"
|
|
327
321
|
@click="${() => this._handleActionClick('leading')}"
|
|
328
322
|
data-test-id="modal-leading-action">
|
|
329
|
-
${
|
|
323
|
+
${text}
|
|
330
324
|
</pie-button>
|
|
331
325
|
`;
|
|
332
326
|
}
|
|
@@ -335,30 +329,31 @@ export class PieModal extends RtlMixin(LitElement) implements ModalProps {
|
|
|
335
329
|
* Renders the "supportingAction" button if the text is provided.
|
|
336
330
|
* You cannot have a supporting action without a leading action.
|
|
337
331
|
*
|
|
338
|
-
* If `
|
|
339
|
-
* If `
|
|
332
|
+
* If either `supportingAction.text` or `leadingAction.text` are not provided, the button is not rendered.
|
|
333
|
+
* If `supportingAction.variant` is not provided, the default value of "ghost" is used.
|
|
334
|
+
* The (optional) aria-label is read from `supportingAction.ariaLabel`.
|
|
340
335
|
*
|
|
341
336
|
* @private
|
|
342
337
|
*/
|
|
343
338
|
private renderSupportingAction (): TemplateResult | typeof nothing {
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
339
|
+
const { ariaLabel, text, variant = 'ghost' } = this.supportingAction || {};
|
|
340
|
+
|
|
341
|
+
if (!text) return nothing;
|
|
347
342
|
|
|
348
|
-
if (!this.
|
|
343
|
+
if (!this.leadingAction?.text) {
|
|
349
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.');
|
|
350
345
|
return nothing;
|
|
351
346
|
}
|
|
352
347
|
|
|
353
348
|
return html`
|
|
354
349
|
<pie-button
|
|
355
|
-
variant="${
|
|
356
|
-
aria-label="${ifDefined(
|
|
350
|
+
variant="${variant}"
|
|
351
|
+
aria-label="${ifDefined(ariaLabel)}"
|
|
357
352
|
type="reset"
|
|
358
353
|
?isFullWidth="${this.hasStackedActions}"
|
|
359
354
|
@click="${() => this._handleActionClick('supporting')}"
|
|
360
355
|
data-test-id="modal-supporting-action">
|
|
361
|
-
${
|
|
356
|
+
${text}
|
|
362
357
|
</pie-button>
|
|
363
358
|
`;
|
|
364
359
|
}
|
|
@@ -368,7 +363,7 @@ export class PieModal extends RtlMixin(LitElement) implements ModalProps {
|
|
|
368
363
|
* @private
|
|
369
364
|
*/
|
|
370
365
|
private renderModalContentAndFooter (): TemplateResult {
|
|
371
|
-
const hasFooterLeadingAction = Boolean(this.
|
|
366
|
+
const hasFooterLeadingAction = Boolean(this.leadingAction?.text);
|
|
372
367
|
|
|
373
368
|
const scrollContainerClasses = {
|
|
374
369
|
'c-modal-scrollContainer': true,
|
|
@@ -402,10 +397,10 @@ export class PieModal extends RtlMixin(LitElement) implements ModalProps {
|
|
|
402
397
|
isFooterPinned,
|
|
403
398
|
isFullWidthBelowMid,
|
|
404
399
|
isLoading,
|
|
405
|
-
|
|
400
|
+
leadingAction,
|
|
406
401
|
position,
|
|
407
402
|
size,
|
|
408
|
-
|
|
403
|
+
supportingAction,
|
|
409
404
|
} = this;
|
|
410
405
|
|
|
411
406
|
const headingTag = unsafeStatic(headingLevel);
|
|
@@ -416,7 +411,7 @@ export class PieModal extends RtlMixin(LitElement) implements ModalProps {
|
|
|
416
411
|
class="c-modal"
|
|
417
412
|
size="${size}"
|
|
418
413
|
position="${position}"
|
|
419
|
-
?hasActions=${
|
|
414
|
+
?hasActions=${leadingAction?.text || supportingAction?.text}
|
|
420
415
|
?hasBackButton=${hasBackButton}
|
|
421
416
|
?hasStackedActions=${hasStackedActions}
|
|
422
417
|
?isDismissible=${isDismissible}
|
package/src/modal.scss
CHANGED
|
@@ -235,13 +235,16 @@
|
|
|
235
235
|
--modal-content-line-height: calc(var(--dt-font-size-16-line-height) * 1px);
|
|
236
236
|
--modal-content-padding-block: var(--dt-spacing-a);
|
|
237
237
|
--modal-content-padding-inline: var(--dt-spacing-d);
|
|
238
|
+
--modal-content-padding-block-end: var(--dt-spacing-e);
|
|
239
|
+
--modal-content-min-block-size: var(--dt-spacing-j);
|
|
240
|
+
|
|
238
241
|
|
|
239
242
|
@media (min-width: $breakpoint-wide) {
|
|
240
243
|
--modal-content-padding-inline: var(--dt-spacing-e);
|
|
241
244
|
}
|
|
242
245
|
|
|
243
246
|
position: relative;
|
|
244
|
-
min-block-size: var(--
|
|
247
|
+
min-block-size: calc(var(--modal-content-min-block-size) + var(--modal-content-padding-block) + var(--modal-content-padding-block-end)); // The sum of the minimum height and block paddings, when footerActions aren't rendered
|
|
245
248
|
|
|
246
249
|
font-size: var(--modal-content-font-size);
|
|
247
250
|
line-height: var(--modal-content-line-height);
|
|
@@ -255,6 +258,7 @@
|
|
|
255
258
|
|
|
256
259
|
&.c-modal-hasFooterActions {
|
|
257
260
|
padding-block-end: var(--modal-content-padding-block);
|
|
261
|
+
min-block-size: var(--modal-content-min-block-size);
|
|
258
262
|
}
|
|
259
263
|
|
|
260
264
|
&--scrollable {
|
|
@@ -307,13 +311,21 @@
|
|
|
307
311
|
pie-spinner {
|
|
308
312
|
position: absolute;
|
|
309
313
|
left: 50%;
|
|
310
|
-
|
|
314
|
+
|
|
315
|
+
// Compensates different block paddings, when footerActions aren't rendered
|
|
316
|
+
top: calc(50% - (var(--modal-content-padding-block-end) - var(--modal-content-padding-block)) / 2);
|
|
311
317
|
transform: translate(-50%, -50%);
|
|
312
318
|
}
|
|
313
319
|
|
|
314
320
|
& .c-modal-contentInner {
|
|
315
321
|
display: none;
|
|
316
322
|
}
|
|
323
|
+
|
|
324
|
+
&.c-modal-hasFooterActions {
|
|
325
|
+
pie-spinner {
|
|
326
|
+
top: 50%;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
317
329
|
}
|
|
318
330
|
|
|
319
331
|
// removes the scroll shadow effect if "background-attachment" isn't supported.
|