@justeattakeaway/pie-modal 0.42.5 → 0.42.7
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 +16 -62
- package/dist/index.d.ts +5 -0
- package/dist/index.js +154 -142
- package/dist/react.d.ts +5 -0
- package/dist/react.js +5 -4
- package/package.json +6 -6
- package/src/defs.ts +17 -0
- package/src/index.ts +16 -15
package/custom-elements.json
CHANGED
|
@@ -80,6 +80,14 @@
|
|
|
80
80
|
},
|
|
81
81
|
"default": "'pie-modal-supporting-action-click'",
|
|
82
82
|
"description": "Event name for when the modal supporting action is clicked."
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"kind": "variable",
|
|
86
|
+
"name": "defaultProps",
|
|
87
|
+
"type": {
|
|
88
|
+
"text": "DefaultProps"
|
|
89
|
+
},
|
|
90
|
+
"default": "{\n headingLevel: 'h2',\n hasBackButton: false,\n hasStackedActions: false,\n isDismissible: false,\n isFooterPinned: true,\n isFullWidthBelowMid: false,\n isLoading: false,\n isOpen: false,\n position: 'center',\n size: 'medium',\n}"
|
|
83
91
|
}
|
|
84
92
|
],
|
|
85
93
|
"exports": [
|
|
@@ -146,6 +154,14 @@
|
|
|
146
154
|
"name": "ON_MODAL_SUPPORTING_ACTION_CLICK",
|
|
147
155
|
"module": "src/defs.js"
|
|
148
156
|
}
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
"kind": "js",
|
|
160
|
+
"name": "defaultProps",
|
|
161
|
+
"declaration": {
|
|
162
|
+
"name": "defaultProps",
|
|
163
|
+
"module": "src/defs.js"
|
|
164
|
+
}
|
|
149
165
|
}
|
|
150
166
|
]
|
|
151
167
|
},
|
|
@@ -183,79 +199,50 @@
|
|
|
183
199
|
"text": "ModalProps['headingLevel']"
|
|
184
200
|
},
|
|
185
201
|
"privacy": "public",
|
|
186
|
-
"default": "'h2'",
|
|
187
202
|
"attribute": "headingLevel"
|
|
188
203
|
},
|
|
189
204
|
{
|
|
190
205
|
"kind": "field",
|
|
191
206
|
"name": "hasBackButton",
|
|
192
|
-
"type": {
|
|
193
|
-
"text": "boolean"
|
|
194
|
-
},
|
|
195
207
|
"privacy": "public",
|
|
196
|
-
"default": "false",
|
|
197
208
|
"attribute": "hasBackButton"
|
|
198
209
|
},
|
|
199
210
|
{
|
|
200
211
|
"kind": "field",
|
|
201
212
|
"name": "hasStackedActions",
|
|
202
|
-
"type": {
|
|
203
|
-
"text": "boolean"
|
|
204
|
-
},
|
|
205
213
|
"privacy": "public",
|
|
206
|
-
"default": "false",
|
|
207
214
|
"attribute": "hasStackedActions"
|
|
208
215
|
},
|
|
209
216
|
{
|
|
210
217
|
"kind": "field",
|
|
211
218
|
"name": "isDismissible",
|
|
212
|
-
"type": {
|
|
213
|
-
"text": "boolean"
|
|
214
|
-
},
|
|
215
219
|
"privacy": "public",
|
|
216
|
-
"default": "false",
|
|
217
220
|
"attribute": "isDismissible",
|
|
218
221
|
"reflects": true
|
|
219
222
|
},
|
|
220
223
|
{
|
|
221
224
|
"kind": "field",
|
|
222
225
|
"name": "isFooterPinned",
|
|
223
|
-
"type": {
|
|
224
|
-
"text": "boolean"
|
|
225
|
-
},
|
|
226
226
|
"privacy": "public",
|
|
227
|
-
"default": "true",
|
|
228
227
|
"attribute": "isFooterPinned"
|
|
229
228
|
},
|
|
230
229
|
{
|
|
231
230
|
"kind": "field",
|
|
232
231
|
"name": "isFullWidthBelowMid",
|
|
233
|
-
"type": {
|
|
234
|
-
"text": "boolean"
|
|
235
|
-
},
|
|
236
232
|
"privacy": "public",
|
|
237
|
-
"default": "false",
|
|
238
233
|
"attribute": "isFullWidthBelowMid"
|
|
239
234
|
},
|
|
240
235
|
{
|
|
241
236
|
"kind": "field",
|
|
242
237
|
"name": "isLoading",
|
|
243
|
-
"type": {
|
|
244
|
-
"text": "boolean"
|
|
245
|
-
},
|
|
246
238
|
"privacy": "public",
|
|
247
|
-
"default": "false",
|
|
248
239
|
"attribute": "isLoading",
|
|
249
240
|
"reflects": true
|
|
250
241
|
},
|
|
251
242
|
{
|
|
252
243
|
"kind": "field",
|
|
253
244
|
"name": "isOpen",
|
|
254
|
-
"type": {
|
|
255
|
-
"text": "boolean"
|
|
256
|
-
},
|
|
257
245
|
"privacy": "public",
|
|
258
|
-
"default": "false",
|
|
259
246
|
"attribute": "isOpen"
|
|
260
247
|
},
|
|
261
248
|
{
|
|
@@ -274,7 +261,6 @@
|
|
|
274
261
|
"text": "ModalProps['position']"
|
|
275
262
|
},
|
|
276
263
|
"privacy": "public",
|
|
277
|
-
"default": "'center'",
|
|
278
264
|
"attribute": "position"
|
|
279
265
|
},
|
|
280
266
|
{
|
|
@@ -293,7 +279,6 @@
|
|
|
293
279
|
"text": "ModalProps['size']"
|
|
294
280
|
},
|
|
295
281
|
"privacy": "public",
|
|
296
|
-
"default": "'medium'",
|
|
297
282
|
"attribute": "size"
|
|
298
283
|
},
|
|
299
284
|
{
|
|
@@ -568,63 +553,34 @@
|
|
|
568
553
|
"type": {
|
|
569
554
|
"text": "ModalProps['headingLevel']"
|
|
570
555
|
},
|
|
571
|
-
"default": "'h2'",
|
|
572
556
|
"fieldName": "headingLevel"
|
|
573
557
|
},
|
|
574
558
|
{
|
|
575
559
|
"name": "hasBackButton",
|
|
576
|
-
"type": {
|
|
577
|
-
"text": "boolean"
|
|
578
|
-
},
|
|
579
|
-
"default": "false",
|
|
580
560
|
"fieldName": "hasBackButton"
|
|
581
561
|
},
|
|
582
562
|
{
|
|
583
563
|
"name": "hasStackedActions",
|
|
584
|
-
"type": {
|
|
585
|
-
"text": "boolean"
|
|
586
|
-
},
|
|
587
|
-
"default": "false",
|
|
588
564
|
"fieldName": "hasStackedActions"
|
|
589
565
|
},
|
|
590
566
|
{
|
|
591
567
|
"name": "isDismissible",
|
|
592
|
-
"type": {
|
|
593
|
-
"text": "boolean"
|
|
594
|
-
},
|
|
595
|
-
"default": "false",
|
|
596
568
|
"fieldName": "isDismissible"
|
|
597
569
|
},
|
|
598
570
|
{
|
|
599
571
|
"name": "isFooterPinned",
|
|
600
|
-
"type": {
|
|
601
|
-
"text": "boolean"
|
|
602
|
-
},
|
|
603
|
-
"default": "true",
|
|
604
572
|
"fieldName": "isFooterPinned"
|
|
605
573
|
},
|
|
606
574
|
{
|
|
607
575
|
"name": "isFullWidthBelowMid",
|
|
608
|
-
"type": {
|
|
609
|
-
"text": "boolean"
|
|
610
|
-
},
|
|
611
|
-
"default": "false",
|
|
612
576
|
"fieldName": "isFullWidthBelowMid"
|
|
613
577
|
},
|
|
614
578
|
{
|
|
615
579
|
"name": "isLoading",
|
|
616
|
-
"type": {
|
|
617
|
-
"text": "boolean"
|
|
618
|
-
},
|
|
619
|
-
"default": "false",
|
|
620
580
|
"fieldName": "isLoading"
|
|
621
581
|
},
|
|
622
582
|
{
|
|
623
583
|
"name": "isOpen",
|
|
624
|
-
"type": {
|
|
625
|
-
"text": "boolean"
|
|
626
|
-
},
|
|
627
|
-
"default": "false",
|
|
628
584
|
"fieldName": "isOpen"
|
|
629
585
|
},
|
|
630
586
|
{
|
|
@@ -639,7 +595,6 @@
|
|
|
639
595
|
"type": {
|
|
640
596
|
"text": "ModalProps['position']"
|
|
641
597
|
},
|
|
642
|
-
"default": "'center'",
|
|
643
598
|
"fieldName": "position"
|
|
644
599
|
},
|
|
645
600
|
{
|
|
@@ -654,7 +609,6 @@
|
|
|
654
609
|
"type": {
|
|
655
610
|
"text": "ModalProps['size']"
|
|
656
611
|
},
|
|
657
|
-
"default": "'medium'",
|
|
658
612
|
"fieldName": "size"
|
|
659
613
|
},
|
|
660
614
|
{
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ComponentDefaultPropsGeneric } from '@justeattakeaway/pie-webc-core';
|
|
1
2
|
import type { CSSResult } from 'lit';
|
|
2
3
|
import type { GenericConstructor } from '@justeattakeaway/pie-webc-core';
|
|
3
4
|
import type { LitElement } from 'lit';
|
|
@@ -27,6 +28,10 @@ export declare type AriaProps = {
|
|
|
27
28
|
loading?: string;
|
|
28
29
|
};
|
|
29
30
|
|
|
31
|
+
export declare type DefaultProps = ComponentDefaultPropsGeneric<ModalProps, 'headingLevel' | 'hasBackButton' | 'hasStackedActions' | 'isDismissible' | 'isFooterPinned' | 'isFullWidthBelowMid' | 'isLoading' | 'isOpen' | 'position' | 'size'>;
|
|
32
|
+
|
|
33
|
+
export declare const defaultProps: DefaultProps;
|
|
34
|
+
|
|
30
35
|
export declare const headingLevels: readonly ["h1", "h2", "h3", "h4", "h5", "h6"];
|
|
31
36
|
|
|
32
37
|
export declare type ModalActionType = 'leading' | 'supporting';
|
package/dist/index.js
CHANGED
|
@@ -1,109 +1,120 @@
|
|
|
1
|
-
import { LitElement as
|
|
2
|
-
import { html as
|
|
3
|
-
import { property as
|
|
1
|
+
import { LitElement as T, nothing as c, unsafeCSS as N } from "lit";
|
|
2
|
+
import { html as g, unsafeStatic as I } from "lit/static-html.js";
|
|
3
|
+
import { property as r, query as R } from "lit/decorators.js";
|
|
4
4
|
import "@justeattakeaway/pie-button";
|
|
5
5
|
import "@justeattakeaway/pie-icon-button";
|
|
6
|
-
import { RtlMixin as
|
|
6
|
+
import { RtlMixin as W, dispatchCustomEvent as u, requiredProperty as j, validPropertyValues as B, defineCustomElement as Y } from "@justeattakeaway/pie-webc-core";
|
|
7
7
|
import "@justeattakeaway/pie-icons-webc/dist/IconClose.js";
|
|
8
8
|
import "@justeattakeaway/pie-icons-webc/dist/IconChevronLeft.js";
|
|
9
9
|
import "@justeattakeaway/pie-icons-webc/dist/IconChevronRight.js";
|
|
10
10
|
import "@justeattakeaway/pie-spinner";
|
|
11
|
-
function
|
|
12
|
-
if (Array.isArray(
|
|
13
|
-
for (var e = 0, i = Array(
|
|
14
|
-
i[e] =
|
|
11
|
+
function V(a) {
|
|
12
|
+
if (Array.isArray(a)) {
|
|
13
|
+
for (var e = 0, i = Array(a.length); e < a.length; e++)
|
|
14
|
+
i[e] = a[e];
|
|
15
15
|
return i;
|
|
16
16
|
} else
|
|
17
|
-
return Array.from(
|
|
17
|
+
return Array.from(a);
|
|
18
18
|
}
|
|
19
19
|
var O = !1;
|
|
20
20
|
if (typeof window < "u") {
|
|
21
|
-
var
|
|
21
|
+
var L = {
|
|
22
22
|
get passive() {
|
|
23
23
|
O = !0;
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
|
-
window.addEventListener("testPassive", null,
|
|
26
|
+
window.addEventListener("testPassive", null, L), window.removeEventListener("testPassive", null, L);
|
|
27
27
|
}
|
|
28
|
-
var S = typeof window < "u" && window.navigator && window.navigator.platform && (/iP(ad|hone|od)/.test(window.navigator.platform) || window.navigator.platform === "MacIntel" && window.navigator.maxTouchPoints > 1),
|
|
29
|
-
return
|
|
28
|
+
var S = 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, M = -1, f = void 0, v = void 0, $ = function(e) {
|
|
29
|
+
return p.some(function(i) {
|
|
30
30
|
return !!(i.options.allowTouchMove && i.options.allowTouchMove(e));
|
|
31
31
|
});
|
|
32
|
-
},
|
|
32
|
+
}, x = function(e) {
|
|
33
33
|
var i = e || window.event;
|
|
34
|
-
return
|
|
35
|
-
},
|
|
36
|
-
if (
|
|
34
|
+
return $(i.target) || i.touches.length > 1 ? !0 : (i.preventDefault && i.preventDefault(), !1);
|
|
35
|
+
}, q = function(e) {
|
|
36
|
+
if (v === void 0) {
|
|
37
37
|
var i = !!e && e.reserveScrollBarGap === !0, t = window.innerWidth - document.documentElement.clientWidth;
|
|
38
|
-
i && t > 0 && (
|
|
38
|
+
i && t > 0 && (v = document.body.style.paddingRight, document.body.style.paddingRight = t + "px");
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
},
|
|
40
|
+
f === void 0 && (f = document.body.style.overflow, document.body.style.overflow = "hidden");
|
|
41
|
+
}, H = function() {
|
|
42
|
+
v !== void 0 && (document.body.style.paddingRight = v, v = void 0), f !== void 0 && (document.body.style.overflow = f, f = void 0);
|
|
43
|
+
}, U = function(e) {
|
|
44
44
|
return e ? e.scrollHeight - e.scrollTop <= e.clientHeight : !1;
|
|
45
|
-
}, U = function(e, i) {
|
|
46
|
-
var t = e.targetTouches[0].clientY - L;
|
|
47
|
-
return M(e.target) ? !1 : i && i.scrollTop === 0 && t > 0 || H(i) && t < 0 ? y(e) : (e.stopPropagation(), !0);
|
|
48
45
|
}, K = function(e, i) {
|
|
46
|
+
var t = e.targetTouches[0].clientY - M;
|
|
47
|
+
return $(e.target) ? !1 : i && i.scrollTop === 0 && t > 0 || U(i) && t < 0 ? x(e) : (e.stopPropagation(), !0);
|
|
48
|
+
}, G = function(e, i) {
|
|
49
49
|
if (!e) {
|
|
50
50
|
console.error("disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.");
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
53
|
-
if (!
|
|
53
|
+
if (!p.some(function(o) {
|
|
54
54
|
return o.targetElement === e;
|
|
55
55
|
})) {
|
|
56
56
|
var t = {
|
|
57
57
|
targetElement: e,
|
|
58
58
|
options: i || {}
|
|
59
59
|
};
|
|
60
|
-
|
|
61
|
-
o.targetTouches.length === 1 && (
|
|
60
|
+
p = [].concat(V(p), [t]), S ? (e.ontouchstart = function(o) {
|
|
61
|
+
o.targetTouches.length === 1 && (M = o.targetTouches[0].clientY);
|
|
62
62
|
}, e.ontouchmove = function(o) {
|
|
63
|
-
o.targetTouches.length === 1 &&
|
|
64
|
-
},
|
|
63
|
+
o.targetTouches.length === 1 && K(o, e);
|
|
64
|
+
}, y || (document.addEventListener("touchmove", x, O ? { passive: !1 } : void 0), y = !0)) : q(i);
|
|
65
65
|
}
|
|
66
|
-
},
|
|
66
|
+
}, X = function(e) {
|
|
67
67
|
if (!e) {
|
|
68
68
|
console.error("enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.");
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
|
-
|
|
71
|
+
p = p.filter(function(i) {
|
|
72
72
|
return i.targetElement !== e;
|
|
73
|
-
}), S ? (e.ontouchstart = null, e.ontouchmove = null,
|
|
73
|
+
}), S ? (e.ontouchstart = null, e.ontouchmove = null, y && p.length === 0 && (document.removeEventListener("touchmove", x, O ? { passive: !1 } : void 0), y = !1)) : p.length || H();
|
|
74
74
|
};
|
|
75
|
-
const
|
|
76
|
-
`,
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
75
|
+
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[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(--dt-spacing-j);font-size:var(--modal-content-font-size);line-height:var(--modal-content-line-height);font-weight:var(--modal-content-font-weight);padding-inline-start:var(--modal-content-padding-inline);padding-inline-end:var(--modal-content-padding-inline);padding-block-start:var(--modal-content-padding-block);padding-block-end:var(--modal-content-padding-block);flex-grow:1}@media (min-width: 768px){.c-modal .c-modal-content{--modal-content-padding-inline: var(--dt-spacing-e)}}.c-modal .c-modal-content--scrollable{background:linear-gradient(to bottom,transparent,var(--dt-color-container-default) 75%) center bottom,linear-gradient(transparent,var(--dt-color-border-strong)) center bottom;background-repeat:no-repeat;background-size:100% 48px,100% 12px;background-attachment:local,scroll}.c-modal>.c-modal-scrollContainer{display:flex;flex-direction:column;overflow-y:auto;--bg-scroll-end: linear-gradient(rgba(255, 255, 255, 0), var(--dt-color-container-default) 70%) 0 100%;--bg-scroll-bottom: radial-gradient(farthest-corner at 50% 100%, rgba(0, 0, 0, .3), rgba(0, 0, 0, 0)) 0 100%;--bg-size-scroll-end: 100% 40px;--bg-size-scroll-bottom: 100% 8px;background:var(--bg-scroll-end),var(--bg-scroll-bottom);background-repeat:no-repeat;background-size:var(--bg-size-scroll-end),var(--bg-size-scroll-bottom);background-attachment:local,scroll}.c-modal>.c-modal-scrollContainer .c-modal-content{flex-shrink:0}.c-modal[isfooterpinned] .c-modal-content{overflow-y:auto}.c-modal[isLoading] .c-modal-content pie-spinner{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%)}.c-modal[isLoading] .c-modal-content .c-modal-contentInner{display:none}@supports not (aspect-ratio: 1/1){.c-modal .c-modal-scrollContainer{background:none}}
|
|
76
|
+
`, Q = ["h1", "h2", "h3", "h4", "h5", "h6"], Z = ["small", "medium", "large"], ee = ["top", "center"], _ = "pie-modal-close", w = "pie-modal-open", C = "pie-modal-back", ie = "pie-modal-leading-action-click", te = "pie-modal-supporting-action-click", d = {
|
|
77
|
+
headingLevel: "h2",
|
|
78
|
+
hasBackButton: !1,
|
|
79
|
+
hasStackedActions: !1,
|
|
80
|
+
isDismissible: !1,
|
|
81
|
+
isFooterPinned: !0,
|
|
82
|
+
isFullWidthBelowMid: !1,
|
|
83
|
+
isLoading: !1,
|
|
84
|
+
isOpen: !1,
|
|
85
|
+
position: "center",
|
|
86
|
+
size: "medium"
|
|
81
87
|
};
|
|
82
|
-
|
|
83
|
-
|
|
88
|
+
var oe = Object.defineProperty, ne = Object.getOwnPropertyDescriptor, l = (a, e, i, t) => {
|
|
89
|
+
for (var o = t > 1 ? void 0 : t ? ne(e, i) : e, s = a.length - 1, m; s >= 0; s--)
|
|
90
|
+
(m = a[s]) && (o = (t ? m(e, i, o) : m(o)) || o);
|
|
91
|
+
return t && o && oe(e, i, o), o;
|
|
92
|
+
};
|
|
93
|
+
const b = "pie-modal";
|
|
94
|
+
class n extends W(T) {
|
|
84
95
|
constructor() {
|
|
85
|
-
super(...arguments), this.headingLevel =
|
|
96
|
+
super(...arguments), this.headingLevel = d.headingLevel, this.hasBackButton = d.hasBackButton, this.hasStackedActions = d.hasStackedActions, this.isDismissible = d.isDismissible, this.isFooterPinned = d.isFooterPinned, this.isFullWidthBelowMid = d.isFullWidthBelowMid, this.isLoading = d.isLoading, this.isOpen = d.isOpen, this.position = d.position, this.size = d.size, this._backButtonClicked = !1, this._handleDialogCancelEvent = (e) => {
|
|
86
97
|
this.isDismissible || e.preventDefault();
|
|
87
98
|
}, this._handleDialogLightDismiss = (e) => {
|
|
88
|
-
var
|
|
99
|
+
var k;
|
|
89
100
|
if (!this.isDismissible)
|
|
90
101
|
return;
|
|
91
|
-
const i = (
|
|
102
|
+
const i = (k = this._dialog) == null ? void 0 : k.getBoundingClientRect(), {
|
|
92
103
|
top: t = 0,
|
|
93
104
|
bottom: o = 0,
|
|
94
|
-
left:
|
|
95
|
-
right:
|
|
105
|
+
left: s = 0,
|
|
106
|
+
right: m = 0
|
|
96
107
|
} = i || {};
|
|
97
|
-
if (t === 0 && o === 0 &&
|
|
108
|
+
if (t === 0 && o === 0 && s === 0 && m === 0)
|
|
98
109
|
return;
|
|
99
|
-
(e.clientY < t || e.clientY > o || e.clientX <
|
|
110
|
+
(e.clientY < t || e.clientY > o || e.clientX < s || e.clientX > m) && (this.isOpen = !1);
|
|
100
111
|
};
|
|
101
112
|
}
|
|
102
113
|
connectedCallback() {
|
|
103
|
-
super.connectedCallback(), this.addEventListener("click", (e) => this._handleDialogLightDismiss(e)), document.addEventListener(
|
|
114
|
+
super.connectedCallback(), this.addEventListener("click", (e) => this._handleDialogLightDismiss(e)), document.addEventListener(w, (e) => this._handleModalOpened(e)), document.addEventListener(_, (e) => this._handleModalClosed(e)), document.addEventListener(C, (e) => this._handleModalClosed(e));
|
|
104
115
|
}
|
|
105
116
|
disconnectedCallback() {
|
|
106
|
-
document.removeEventListener(
|
|
117
|
+
document.removeEventListener(w, (e) => this._handleModalOpened(e)), document.removeEventListener(_, (e) => this._handleModalClosed(e)), document.removeEventListener(C, (e) => this._handleModalClosed(e)), super.disconnectedCallback();
|
|
107
118
|
}
|
|
108
119
|
async firstUpdated(e) {
|
|
109
120
|
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", () => {
|
|
@@ -117,13 +128,13 @@ class a extends R(P) {
|
|
|
117
128
|
* Opens the dialog element and disables page scrolling
|
|
118
129
|
*/
|
|
119
130
|
_handleModalOpened(e) {
|
|
120
|
-
var t, o,
|
|
131
|
+
var t, o, s, m;
|
|
121
132
|
const { targetModal: i } = e.detail;
|
|
122
133
|
if (i === this) {
|
|
123
|
-
const
|
|
124
|
-
if (
|
|
134
|
+
const h = (t = this._dialog) == null ? void 0 : t.querySelector(".c-modal-scrollContainer");
|
|
135
|
+
if (h && ("scrollTo" in window && window.scrollTo(0, 0), G(h)), (o = this._dialog) != null && o.hasAttribute("open") || !((s = this._dialog) != null && s.isConnected))
|
|
125
136
|
return;
|
|
126
|
-
(
|
|
137
|
+
(m = this._dialog) == null || m.showModal();
|
|
127
138
|
}
|
|
128
139
|
}
|
|
129
140
|
/**
|
|
@@ -133,22 +144,22 @@ class a extends R(P) {
|
|
|
133
144
|
var t, o;
|
|
134
145
|
const { targetModal: i } = e.detail;
|
|
135
146
|
if (i === this) {
|
|
136
|
-
const
|
|
137
|
-
|
|
147
|
+
const s = (t = this._dialog) == null ? void 0 : t.querySelector(".c-modal-scrollContainer");
|
|
148
|
+
s && X(s), (o = this._dialog) == null || o.close(), this._returnFocus();
|
|
138
149
|
}
|
|
139
150
|
}
|
|
140
151
|
// Handles the value of the isOpen property on first render of the component
|
|
141
152
|
_handleModalOpenStateOnFirstRender(e) {
|
|
142
|
-
e.get("isOpen") === void 0 && this.isOpen &&
|
|
153
|
+
e.get("isOpen") === void 0 && this.isOpen && u(this, w, { targetModal: this });
|
|
143
154
|
}
|
|
144
155
|
// Handles changes to the modal isOpen property by dispatching any appropriate events
|
|
145
156
|
_handleModalOpenStateChanged(e) {
|
|
146
157
|
const i = e.get("isOpen");
|
|
147
|
-
i !== void 0 && (i ? this._backButtonClicked ? (this._backButtonClicked = !1,
|
|
158
|
+
i !== void 0 && (i ? this._backButtonClicked ? (this._backButtonClicked = !1, u(this, C, { targetModal: this })) : u(this, _, { targetModal: this }) : u(this, w, { targetModal: this }));
|
|
148
159
|
}
|
|
149
160
|
_handleActionClick(e) {
|
|
150
161
|
var i, t;
|
|
151
|
-
e === "leading" ? ((i = this._dialog) == null || i.close("leading"),
|
|
162
|
+
e === "leading" ? ((i = this._dialog) == null || i.close("leading"), u(this, ie, { targetModal: this })) : e === "supporting" && ((t = this._dialog) == null || t.close("supporting"), u(this, te, { targetModal: this }));
|
|
152
163
|
}
|
|
153
164
|
/**
|
|
154
165
|
* Return focus to the specified element, providing the selector is valid
|
|
@@ -167,14 +178,14 @@ class a extends R(P) {
|
|
|
167
178
|
*/
|
|
168
179
|
renderCloseButton() {
|
|
169
180
|
var e;
|
|
170
|
-
return
|
|
181
|
+
return g`
|
|
171
182
|
<pie-icon-button
|
|
172
183
|
@click="${() => {
|
|
173
184
|
this.isOpen = !1;
|
|
174
185
|
}}"
|
|
175
186
|
variant="ghost-secondary"
|
|
176
187
|
class="c-modal-closeBtn"
|
|
177
|
-
aria-label="${((e = this.aria) == null ? void 0 : e.close) ||
|
|
188
|
+
aria-label="${((e = this.aria) == null ? void 0 : e.close) || c}"
|
|
178
189
|
data-test-id="modal-close-button">
|
|
179
190
|
<icon-close></icon-close>
|
|
180
191
|
</pie-icon-button>`;
|
|
@@ -187,16 +198,16 @@ class a extends R(P) {
|
|
|
187
198
|
*/
|
|
188
199
|
renderBackButton() {
|
|
189
200
|
var e;
|
|
190
|
-
return
|
|
201
|
+
return g`
|
|
191
202
|
<pie-icon-button
|
|
192
203
|
@click="${() => {
|
|
193
204
|
this._backButtonClicked = !0, this.isOpen = !1;
|
|
194
205
|
}}"
|
|
195
206
|
variant="ghost-secondary"
|
|
196
207
|
class="c-modal-backBtn"
|
|
197
|
-
aria-label="${((e = this.aria) == null ? void 0 : e.back) ||
|
|
208
|
+
aria-label="${((e = this.aria) == null ? void 0 : e.back) || c}"
|
|
198
209
|
data-test-id="modal-back-button">
|
|
199
|
-
${this.isRTL ?
|
|
210
|
+
${this.isRTL ? g`<icon-chevron-right></icon-chevron-right>` : g`<icon-chevron-left></icon-chevron-left>`}
|
|
200
211
|
</pie-icon-button>
|
|
201
212
|
`;
|
|
202
213
|
}
|
|
@@ -211,17 +222,17 @@ class a extends R(P) {
|
|
|
211
222
|
*/
|
|
212
223
|
renderLeadingAction() {
|
|
213
224
|
const { text: e, variant: i = "primary", ariaLabel: t } = this.leadingAction;
|
|
214
|
-
return e ?
|
|
225
|
+
return e ? g`
|
|
215
226
|
<pie-button
|
|
216
227
|
variant="${i}"
|
|
217
|
-
aria-label="${t ||
|
|
228
|
+
aria-label="${t || c}"
|
|
218
229
|
type="submit"
|
|
219
230
|
?isFullWidth="${this.hasStackedActions}"
|
|
220
231
|
@click="${() => this._handleActionClick("leading")}"
|
|
221
232
|
data-test-id="modal-leading-action">
|
|
222
233
|
${e}
|
|
223
234
|
</pie-button>
|
|
224
|
-
` :
|
|
235
|
+
` : c;
|
|
225
236
|
}
|
|
226
237
|
/**
|
|
227
238
|
* Render supportingAction button depending on prop availability.
|
|
@@ -236,34 +247,34 @@ class a extends R(P) {
|
|
|
236
247
|
*/
|
|
237
248
|
renderSupportingAction() {
|
|
238
249
|
const { text: e, variant: i = "ghost", ariaLabel: t } = this.supportingAction;
|
|
239
|
-
return e ? this.leadingAction ?
|
|
250
|
+
return e ? this.leadingAction ? g`
|
|
240
251
|
<pie-button
|
|
241
252
|
variant="${i}"
|
|
242
|
-
aria-label="${t ||
|
|
253
|
+
aria-label="${t || c}"
|
|
243
254
|
type="reset"
|
|
244
255
|
?isFullWidth="${this.hasStackedActions}"
|
|
245
256
|
@click="${() => this._handleActionClick("supporting")}"
|
|
246
257
|
data-test-id="modal-supporting-action">
|
|
247
258
|
${e}
|
|
248
259
|
</pie-button>
|
|
249
|
-
` : (console.warn("Use `leadingAction` instead of `supportingAction`. `supportingAction` is being ignored."),
|
|
260
|
+
` : (console.warn("Use `leadingAction` instead of `supportingAction`. `supportingAction` is being ignored."), c) : c;
|
|
250
261
|
}
|
|
251
262
|
/**
|
|
252
263
|
* Renders the modal inner content and footer of the modal.
|
|
253
264
|
* @private
|
|
254
265
|
*/
|
|
255
266
|
renderModalContentAndFooter() {
|
|
256
|
-
return
|
|
267
|
+
return g`
|
|
257
268
|
<article class="c-modal-scrollContainer c-modal-content c-modal-content--scrollable">
|
|
258
269
|
<div class="c-modal-contentInner"
|
|
259
270
|
data-test-id="modal-content-inner">
|
|
260
271
|
<slot></slot>
|
|
261
272
|
</div>
|
|
262
|
-
${this.isLoading ?
|
|
273
|
+
${this.isLoading ? g`<pie-spinner size="xlarge" variant="secondary"></pie-spinner>` : c}
|
|
263
274
|
</article>
|
|
264
275
|
<footer class="c-modal-footer">
|
|
265
|
-
${this.leadingAction ? this.renderLeadingAction() :
|
|
266
|
-
${this.supportingAction ? this.renderSupportingAction() :
|
|
276
|
+
${this.leadingAction ? this.renderLeadingAction() : c}
|
|
277
|
+
${this.supportingAction ? this.renderSupportingAction() : c}
|
|
267
278
|
</footer>`;
|
|
268
279
|
}
|
|
269
280
|
render() {
|
|
@@ -272,42 +283,42 @@ class a extends R(P) {
|
|
|
272
283
|
hasBackButton: i,
|
|
273
284
|
hasStackedActions: t,
|
|
274
285
|
heading: o,
|
|
275
|
-
headingLevel:
|
|
276
|
-
isDismissible:
|
|
277
|
-
isFooterPinned:
|
|
278
|
-
isFullWidthBelowMid:
|
|
279
|
-
isLoading:
|
|
280
|
-
leadingAction:
|
|
281
|
-
position:
|
|
286
|
+
headingLevel: s = "h2",
|
|
287
|
+
isDismissible: m,
|
|
288
|
+
isFooterPinned: h,
|
|
289
|
+
isFullWidthBelowMid: k,
|
|
290
|
+
isLoading: z,
|
|
291
|
+
leadingAction: D,
|
|
292
|
+
position: P,
|
|
282
293
|
size: E,
|
|
283
|
-
supportingAction:
|
|
284
|
-
} = this, A =
|
|
285
|
-
return
|
|
294
|
+
supportingAction: F
|
|
295
|
+
} = this, A = I(s);
|
|
296
|
+
return g`
|
|
286
297
|
<dialog
|
|
287
298
|
id="dialog"
|
|
288
299
|
class="c-modal"
|
|
289
|
-
size="${E ||
|
|
290
|
-
position="${
|
|
291
|
-
?hasActions=${
|
|
300
|
+
size="${E || d.size}"
|
|
301
|
+
position="${P || d.position}"
|
|
302
|
+
?hasActions=${D || F}
|
|
292
303
|
?hasBackButton=${i}
|
|
293
304
|
?hasStackedActions=${t}
|
|
294
|
-
?isDismissible=${
|
|
295
|
-
?isFooterPinned=${
|
|
296
|
-
?isFullWidthBelowMid=${
|
|
297
|
-
?isLoading=${
|
|
298
|
-
aria-busy="${
|
|
299
|
-
aria-label="${
|
|
305
|
+
?isDismissible=${m}
|
|
306
|
+
?isFooterPinned=${h}
|
|
307
|
+
?isFullWidthBelowMid=${k}
|
|
308
|
+
?isLoading=${z}
|
|
309
|
+
aria-busy="${z ? "true" : "false"}"
|
|
310
|
+
aria-label="${z && (e == null ? void 0 : e.loading) || c}"
|
|
300
311
|
data-test-id="pie-modal">
|
|
301
312
|
<header class="c-modal-header"
|
|
302
313
|
data-test-id="modal-header">
|
|
303
|
-
${i ? this.renderBackButton() :
|
|
314
|
+
${i ? this.renderBackButton() : c}
|
|
304
315
|
<${A} class="c-modal-heading">
|
|
305
316
|
${o}
|
|
306
317
|
</${A}>
|
|
307
|
-
${
|
|
318
|
+
${m ? this.renderCloseButton() : c}
|
|
308
319
|
</header>
|
|
309
320
|
${// We need to wrap the remaining content in a shared scrollable container if the footer is not pinned
|
|
310
|
-
|
|
321
|
+
h ? this.renderModalContentAndFooter() : g`
|
|
311
322
|
<div class="c-modal-scrollContainer">
|
|
312
323
|
${this.renderModalContentAndFooter()}
|
|
313
324
|
</div>
|
|
@@ -315,68 +326,69 @@ class a extends R(P) {
|
|
|
315
326
|
</dialog>`;
|
|
316
327
|
}
|
|
317
328
|
}
|
|
318
|
-
|
|
329
|
+
n.styles = N(J);
|
|
319
330
|
l([
|
|
320
|
-
|
|
321
|
-
],
|
|
331
|
+
r({ type: Object })
|
|
332
|
+
], n.prototype, "aria", 2);
|
|
322
333
|
l([
|
|
323
|
-
|
|
324
|
-
j(
|
|
325
|
-
],
|
|
334
|
+
r({ type: String }),
|
|
335
|
+
j(b)
|
|
336
|
+
], n.prototype, "heading", 2);
|
|
326
337
|
l([
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
],
|
|
338
|
+
r(),
|
|
339
|
+
B(b, Q, d.headingLevel)
|
|
340
|
+
], n.prototype, "headingLevel", 2);
|
|
330
341
|
l([
|
|
331
|
-
|
|
332
|
-
],
|
|
342
|
+
r({ type: Boolean })
|
|
343
|
+
], n.prototype, "hasBackButton", 2);
|
|
333
344
|
l([
|
|
334
|
-
|
|
335
|
-
],
|
|
345
|
+
r({ type: Boolean })
|
|
346
|
+
], n.prototype, "hasStackedActions", 2);
|
|
336
347
|
l([
|
|
337
|
-
|
|
338
|
-
],
|
|
348
|
+
r({ type: Boolean, reflect: !0 })
|
|
349
|
+
], n.prototype, "isDismissible", 2);
|
|
339
350
|
l([
|
|
340
|
-
|
|
341
|
-
],
|
|
351
|
+
r({ type: Boolean })
|
|
352
|
+
], n.prototype, "isFooterPinned", 2);
|
|
342
353
|
l([
|
|
343
|
-
|
|
344
|
-
],
|
|
354
|
+
r({ type: Boolean })
|
|
355
|
+
], n.prototype, "isFullWidthBelowMid", 2);
|
|
345
356
|
l([
|
|
346
|
-
|
|
347
|
-
],
|
|
357
|
+
r({ type: Boolean, reflect: !0 })
|
|
358
|
+
], n.prototype, "isLoading", 2);
|
|
348
359
|
l([
|
|
349
|
-
|
|
350
|
-
],
|
|
360
|
+
r({ type: Boolean })
|
|
361
|
+
], n.prototype, "isOpen", 2);
|
|
351
362
|
l([
|
|
352
|
-
|
|
353
|
-
],
|
|
363
|
+
r({ type: Object })
|
|
364
|
+
], n.prototype, "leadingAction", 2);
|
|
354
365
|
l([
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
],
|
|
366
|
+
r(),
|
|
367
|
+
B(b, ee, d.position)
|
|
368
|
+
], n.prototype, "position", 2);
|
|
358
369
|
l([
|
|
359
|
-
|
|
360
|
-
],
|
|
370
|
+
r()
|
|
371
|
+
], n.prototype, "returnFocusAfterCloseSelector", 2);
|
|
361
372
|
l([
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
],
|
|
373
|
+
r(),
|
|
374
|
+
B(b, Z, d.size)
|
|
375
|
+
], n.prototype, "size", 2);
|
|
365
376
|
l([
|
|
366
|
-
|
|
367
|
-
],
|
|
377
|
+
r({ type: Object })
|
|
378
|
+
], n.prototype, "supportingAction", 2);
|
|
368
379
|
l([
|
|
369
|
-
|
|
370
|
-
],
|
|
371
|
-
|
|
380
|
+
R("dialog")
|
|
381
|
+
], n.prototype, "_dialog", 2);
|
|
382
|
+
Y(b, n);
|
|
372
383
|
export {
|
|
373
|
-
|
|
384
|
+
C as ON_MODAL_BACK_EVENT,
|
|
374
385
|
_ as ON_MODAL_CLOSE_EVENT,
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
386
|
+
ie as ON_MODAL_LEADING_ACTION_CLICK,
|
|
387
|
+
w as ON_MODAL_OPEN_EVENT,
|
|
388
|
+
te as ON_MODAL_SUPPORTING_ACTION_CLICK,
|
|
389
|
+
n as PieModal,
|
|
390
|
+
d as defaultProps,
|
|
391
|
+
Q as headingLevels,
|
|
392
|
+
ee as positions,
|
|
393
|
+
Z as sizes
|
|
382
394
|
};
|
package/dist/react.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ComponentDefaultPropsGeneric } from '@justeattakeaway/pie-webc-core';
|
|
1
2
|
import type { CSSResult } from 'lit';
|
|
2
3
|
import type { GenericConstructor } from '@justeattakeaway/pie-webc-core';
|
|
3
4
|
import type { LitElement } from 'lit';
|
|
@@ -28,6 +29,10 @@ export declare type AriaProps = {
|
|
|
28
29
|
loading?: string;
|
|
29
30
|
};
|
|
30
31
|
|
|
32
|
+
export declare type DefaultProps = ComponentDefaultPropsGeneric<ModalProps, 'headingLevel' | 'hasBackButton' | 'hasStackedActions' | 'isDismissible' | 'isFooterPinned' | 'isFullWidthBelowMid' | 'isLoading' | 'isOpen' | 'position' | 'size'>;
|
|
33
|
+
|
|
34
|
+
export declare const defaultProps: DefaultProps;
|
|
35
|
+
|
|
31
36
|
export declare const headingLevels: readonly ["h1", "h2", "h3", "h4", "h5", "h6"];
|
|
32
37
|
|
|
33
38
|
export declare type ModalActionType = 'leading' | 'supporting';
|
package/dist/react.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as o from "react";
|
|
2
2
|
import { createComponent as i } from "@lit/react";
|
|
3
3
|
import { PieModal as e } from "./index.js";
|
|
4
|
-
import { ON_MODAL_BACK_EVENT as A, ON_MODAL_CLOSE_EVENT as L, ON_MODAL_LEADING_ACTION_CLICK as E, ON_MODAL_OPEN_EVENT as g, ON_MODAL_SUPPORTING_ACTION_CLICK as k,
|
|
4
|
+
import { ON_MODAL_BACK_EVENT as A, ON_MODAL_CLOSE_EVENT as L, ON_MODAL_LEADING_ACTION_CLICK as E, ON_MODAL_OPEN_EVENT as g, ON_MODAL_SUPPORTING_ACTION_CLICK as k, defaultProps as D, headingLevels as I, positions as T, sizes as f } from "./index.js";
|
|
5
5
|
import "lit";
|
|
6
6
|
import "lit/static-html.js";
|
|
7
7
|
import "lit/decorators.js";
|
|
@@ -37,7 +37,8 @@ export {
|
|
|
37
37
|
g as ON_MODAL_OPEN_EVENT,
|
|
38
38
|
k as ON_MODAL_SUPPORTING_ACTION_CLICK,
|
|
39
39
|
N as PieModal,
|
|
40
|
-
D as
|
|
41
|
-
I as
|
|
42
|
-
T as
|
|
40
|
+
D as defaultProps,
|
|
41
|
+
I as headingLevels,
|
|
42
|
+
T as positions,
|
|
43
|
+
f as sizes
|
|
43
44
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justeattakeaway/pie-modal",
|
|
3
|
-
"version": "0.42.
|
|
3
|
+
"version": "0.42.7",
|
|
4
4
|
"description": "PIE design system modal built using web components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -46,11 +46,11 @@
|
|
|
46
46
|
"extends": "../../../package.json"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@justeattakeaway/pie-button": "0.47.
|
|
50
|
-
"@justeattakeaway/pie-icon-button": "0.28.
|
|
51
|
-
"@justeattakeaway/pie-icons-webc": "0.
|
|
52
|
-
"@justeattakeaway/pie-spinner": "0.6.
|
|
53
|
-
"@justeattakeaway/pie-webc-core": "0.
|
|
49
|
+
"@justeattakeaway/pie-button": "0.47.6",
|
|
50
|
+
"@justeattakeaway/pie-icon-button": "0.28.6",
|
|
51
|
+
"@justeattakeaway/pie-icons-webc": "0.24.0",
|
|
52
|
+
"@justeattakeaway/pie-spinner": "0.6.5",
|
|
53
|
+
"@justeattakeaway/pie-webc-core": "0.23.0",
|
|
54
54
|
"body-scroll-lock": "3.1.5",
|
|
55
55
|
"dialog-polyfill": "0.5.6"
|
|
56
56
|
},
|
package/src/defs.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { type ComponentDefaultPropsGeneric } from '@justeattakeaway/pie-webc-core';
|
|
2
|
+
|
|
1
3
|
import { Variant } from '@justeattakeaway/pie-button/src/defs.ts';
|
|
2
4
|
|
|
3
5
|
export const headingLevels = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'] as const;
|
|
@@ -148,3 +150,18 @@ export const ON_MODAL_LEADING_ACTION_CLICK = 'pie-modal-leading-action-click';
|
|
|
148
150
|
export const ON_MODAL_SUPPORTING_ACTION_CLICK = 'pie-modal-supporting-action-click';
|
|
149
151
|
|
|
150
152
|
export type ModalActionType = 'leading' | 'supporting';
|
|
153
|
+
|
|
154
|
+
export type DefaultProps = ComponentDefaultPropsGeneric<ModalProps, 'headingLevel'|'hasBackButton'|'hasStackedActions'|'isDismissible'|'isFooterPinned'|'isFullWidthBelowMid'|'isLoading'|'isOpen'|'position'|'size'>;
|
|
155
|
+
|
|
156
|
+
export const defaultProps: DefaultProps = {
|
|
157
|
+
headingLevel: 'h2',
|
|
158
|
+
hasBackButton: false,
|
|
159
|
+
hasStackedActions: false,
|
|
160
|
+
isDismissible: false,
|
|
161
|
+
isFooterPinned: true,
|
|
162
|
+
isFullWidthBelowMid: false,
|
|
163
|
+
isLoading: false,
|
|
164
|
+
isOpen: false,
|
|
165
|
+
position: 'center',
|
|
166
|
+
size: 'medium',
|
|
167
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
headingLevels,
|
|
29
29
|
positions,
|
|
30
30
|
sizes,
|
|
31
|
+
defaultProps,
|
|
31
32
|
ON_MODAL_BACK_EVENT,
|
|
32
33
|
ON_MODAL_CLOSE_EVENT,
|
|
33
34
|
ON_MODAL_OPEN_EVENT,
|
|
@@ -61,43 +62,43 @@ export class PieModal extends RtlMixin(LitElement) implements ModalProps {
|
|
|
61
62
|
public heading!: string;
|
|
62
63
|
|
|
63
64
|
@property()
|
|
64
|
-
@validPropertyValues(componentSelector, headingLevels,
|
|
65
|
-
public headingLevel: ModalProps['headingLevel'] =
|
|
65
|
+
@validPropertyValues(componentSelector, headingLevels, defaultProps.headingLevel)
|
|
66
|
+
public headingLevel: ModalProps['headingLevel'] = defaultProps.headingLevel;
|
|
66
67
|
|
|
67
68
|
@property({ type: Boolean })
|
|
68
|
-
public hasBackButton =
|
|
69
|
+
public hasBackButton = defaultProps.hasBackButton;
|
|
69
70
|
|
|
70
71
|
@property({ type: Boolean })
|
|
71
|
-
public hasStackedActions =
|
|
72
|
+
public hasStackedActions = defaultProps.hasStackedActions;
|
|
72
73
|
|
|
73
74
|
@property({ type: Boolean, reflect: true })
|
|
74
|
-
public isDismissible =
|
|
75
|
+
public isDismissible = defaultProps.isDismissible;
|
|
75
76
|
|
|
76
77
|
@property({ type: Boolean })
|
|
77
|
-
public isFooterPinned =
|
|
78
|
+
public isFooterPinned = defaultProps.isFooterPinned;
|
|
78
79
|
|
|
79
80
|
@property({ type: Boolean })
|
|
80
|
-
public isFullWidthBelowMid =
|
|
81
|
+
public isFullWidthBelowMid = defaultProps.isFullWidthBelowMid;
|
|
81
82
|
|
|
82
83
|
@property({ type: Boolean, reflect: true })
|
|
83
|
-
public isLoading =
|
|
84
|
+
public isLoading = defaultProps.isLoading;
|
|
84
85
|
|
|
85
86
|
@property({ type: Boolean })
|
|
86
|
-
public isOpen =
|
|
87
|
+
public isOpen = defaultProps.isOpen;
|
|
87
88
|
|
|
88
89
|
@property({ type: Object })
|
|
89
90
|
public leadingAction!: ActionProps;
|
|
90
91
|
|
|
91
92
|
@property()
|
|
92
|
-
@validPropertyValues(componentSelector, positions,
|
|
93
|
-
public position: ModalProps['position'] =
|
|
93
|
+
@validPropertyValues(componentSelector, positions, defaultProps.position)
|
|
94
|
+
public position: ModalProps['position'] = defaultProps.position;
|
|
94
95
|
|
|
95
96
|
@property()
|
|
96
97
|
public returnFocusAfterCloseSelector?: string;
|
|
97
98
|
|
|
98
99
|
@property()
|
|
99
|
-
@validPropertyValues(componentSelector, sizes,
|
|
100
|
-
public size: ModalProps['size'] =
|
|
100
|
+
@validPropertyValues(componentSelector, sizes, defaultProps.size)
|
|
101
|
+
public size: ModalProps['size'] = defaultProps.size;
|
|
101
102
|
|
|
102
103
|
@property({ type: Object })
|
|
103
104
|
public supportingAction!: ActionProps;
|
|
@@ -396,8 +397,8 @@ export class PieModal extends RtlMixin(LitElement) implements ModalProps {
|
|
|
396
397
|
<dialog
|
|
397
398
|
id="dialog"
|
|
398
399
|
class="c-modal"
|
|
399
|
-
size="${size ||
|
|
400
|
-
position="${position ||
|
|
400
|
+
size="${size || defaultProps.size}"
|
|
401
|
+
position="${position || defaultProps.position}"
|
|
401
402
|
?hasActions=${leadingAction || supportingAction}
|
|
402
403
|
?hasBackButton=${hasBackButton}
|
|
403
404
|
?hasStackedActions=${hasStackedActions}
|