@justeattakeaway/pie-modal 0.11.0 → 0.13.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/.turbo/turbo-build.log +6 -6
- package/CHANGELOG.md +27 -0
- package/README.md +2 -0
- package/dist/index.js +221 -164
- package/dist/react.js +131 -124
- package/dist/types/packages/components/pie-modal/src/defs.d.ts +16 -1
- package/dist/types/packages/components/pie-modal/src/defs.d.ts.map +1 -1
- package/dist/types/packages/components/pie-modal/src/index.d.ts +25 -11
- package/dist/types/packages/components/pie-modal/src/index.d.ts.map +1 -1
- package/dist/types/packages/components/pie-modal/src/react.d.ts +6 -1
- package/dist/types/packages/components/pie-modal/src/react.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/defs.ts +20 -1
- package/src/index.ts +110 -41
- package/src/modal.scss +183 -19
- package/test/component/pie-modal.spec.ts +236 -56
- package/test/visual/pie-modal.spec.ts +50 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
[
|
|
1
|
+
[7:14:15 AM] @custom-elements-manifest/analyzer: Created new manifest.
|
|
2
2
|
react wrapper has been added!
|
|
3
3
|
[36mvite v4.3.9 [32mbuilding for production...[36m[39m
|
|
4
4
|
transforming...
|
|
5
|
-
[32m✓[39m
|
|
5
|
+
[32m✓[39m 27 modules transformed.
|
|
6
6
|
rendering chunks...
|
|
7
7
|
computing gzip size...
|
|
8
|
-
[2mdist/[22m[36mindex.js [39m[1m[
|
|
9
|
-
[2mdist/[22m[36mreact.js [39m[1m[2m59.
|
|
8
|
+
[2mdist/[22m[36mindex.js [39m[1m[2m18.85 kB[22m[1m[22m[2m │ gzip: 5.33 kB[22m
|
|
9
|
+
[2mdist/[22m[36mreact.js [39m[1m[2m59.27 kB[22m[1m[22m[2m │ gzip: 15.99 kB[22m
|
|
10
10
|
[32m
|
|
11
11
|
[36m[vite:dts][32m Start generate declaration files...[39m
|
|
12
|
-
[32m✓ built in
|
|
13
|
-
[32m[36m[vite:dts][32m Declaration files built in
|
|
12
|
+
[32m✓ built in 11.11s[39m
|
|
13
|
+
[32m[36m[vite:dts][32m Declaration files built in 9971ms.
|
|
14
14
|
[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# @justeattakeaway/pie-modal
|
|
2
2
|
|
|
3
|
+
## 0.13.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [Added] - Default modal footer ([#619](https://github.com/justeattakeaway/pie/pull/619)) by [@xander-marjoram](https://github.com/xander-marjoram)
|
|
8
|
+
|
|
9
|
+
[Added] - Height styles for the different sizes
|
|
10
|
+
[Removed] - Unnecessary `:focus-visible` outline for the modal
|
|
11
|
+
[Fixed] - Modal width should be able to exceed 600px for `isFullWidthBelowMid`
|
|
12
|
+
|
|
13
|
+
- [Added] - loading spinner to modal ([#628](https://github.com/justeattakeaway/pie/pull/628)) by [@jamieomaguire](https://github.com/jamieomaguire)
|
|
14
|
+
|
|
15
|
+
- [Added] - Scroll shadow for modal contents ([#619](https://github.com/justeattakeaway/pie/pull/619)) by [@xander-marjoram](https://github.com/xander-marjoram)
|
|
16
|
+
|
|
17
|
+
- [Added] - Tests to validate leading/supporting action buttons ([#619](https://github.com/justeattakeaway/pie/pull/619)) by [@xander-marjoram](https://github.com/xander-marjoram)
|
|
18
|
+
|
|
19
|
+
[Added] - Missing tests to check that the modal closes when expected to
|
|
20
|
+
[Changed] - Updated tests to verify that the correct event is being triggered
|
|
21
|
+
|
|
22
|
+
- [Added] - hasBackButton prop to modal ([#623](https://github.com/justeattakeaway/pie/pull/623)) by [@jamieomaguire](https://github.com/jamieomaguire)
|
|
23
|
+
|
|
24
|
+
## 0.12.0
|
|
25
|
+
|
|
26
|
+
### Minor Changes
|
|
27
|
+
|
|
28
|
+
- [Added] - @event jsdoc comments for modal events for react wrapper to analyse ([#612](https://github.com/justeattakeaway/pie/pull/612)) by [@jamieomaguire](https://github.com/jamieomaguire)
|
|
29
|
+
|
|
3
30
|
## 0.11.0
|
|
4
31
|
|
|
5
32
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -66,8 +66,10 @@ import { PieModal } from '@justeattakeaway/pie-modal/dist/react';
|
|
|
66
66
|
| heading | `String` | n/a (Required) | The heading text of the modal |
|
|
67
67
|
| headingLevel | `String` | `h2` | The HTML tag to use for the modal's heading (can be `h1`-`h6`) |
|
|
68
68
|
| isDismissible | `Boolean` | `false` | If true, the modal includes a close button and can be dismissed by clicking on the backdrop or pressing the Esc key |
|
|
69
|
+
| hasBackButton | `Boolean` | `false` | If true, the modal includes a back button which closes the modal when clicked |
|
|
69
70
|
| isFullWidthBelowMid | `Boolean` | `false` | If true and the page is narrower than the mid breakpoint, a **medium-sized** modal will take up the full width of the screen. |
|
|
70
71
|
| isOpen | `Boolean` | `false` | Controls if the modal element is open or closed |
|
|
72
|
+
| isLoading | `Boolean` | `false` | When true, displays a loading spinner in the modal |
|
|
71
73
|
| size | `String` | `medium` | Determines the maximum width of the modal. Large modals will expand to fill the entire page width at narrow viewports. Can be `small`, `medium` or `large`. |
|
|
72
74
|
| returnFocusAfterCloseSelector | `String` | `undefined` | If provided, focus will be sent to the first element that matches this selector when the modal is closed. If not provided, the `dialog` element will return focus to the element that opened the modal. |
|
|
73
75
|
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { nothing as
|
|
2
|
-
import {
|
|
3
|
-
import { property as
|
|
1
|
+
import { nothing as B, unsafeCSS as P, LitElement as E } from "lit";
|
|
2
|
+
import { html as f, unsafeStatic as $ } from "lit/static-html.js";
|
|
3
|
+
import { property as s, query as D } from "lit/decorators.js";
|
|
4
4
|
import { property as T } from "lit/decorators/property.js";
|
|
5
|
-
var
|
|
6
|
-
for (var i =
|
|
7
|
-
(
|
|
8
|
-
return
|
|
5
|
+
var A = Object.defineProperty, F = Object.getOwnPropertyDescriptor, R = (n, e, o, t) => {
|
|
6
|
+
for (var i = t > 1 ? void 0 : t ? F(e, o) : e, a = n.length - 1, r; a >= 0; a--)
|
|
7
|
+
(r = n[a]) && (i = (t ? r(e, o, i) : r(i)) || i);
|
|
8
|
+
return t && i && A(e, o, i), i;
|
|
9
9
|
};
|
|
10
|
-
const
|
|
10
|
+
const I = (n) => {
|
|
11
11
|
class e extends n {
|
|
12
12
|
constructor() {
|
|
13
|
-
super(...arguments), this.dir = "";
|
|
13
|
+
super(...arguments), this.dir = "ltr";
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Returns true if the element is in Right to Left mode.
|
|
@@ -22,171 +22,171 @@ const k = (n) => {
|
|
|
22
22
|
* will not be reactive and is only computed once
|
|
23
23
|
*/
|
|
24
24
|
get isRTL() {
|
|
25
|
-
var
|
|
26
|
-
return this.dir === "ltr" ? !1 : this.dir === "rtl" || ((
|
|
25
|
+
var t;
|
|
26
|
+
return this.dir === "ltr" ? !1 : this.dir === "rtl" || ((t = window == null ? void 0 : window.getComputedStyle(this)) == null ? void 0 : t.direction) === "rtl";
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
return
|
|
30
|
-
T({ type: String })
|
|
29
|
+
return R([
|
|
30
|
+
T({ type: String, reflect: !0 })
|
|
31
31
|
], e.prototype, "dir", 2), e;
|
|
32
|
-
},
|
|
33
|
-
const
|
|
34
|
-
Object.defineProperty(i,
|
|
32
|
+
}, S = (n, e, o) => function(i, a) {
|
|
33
|
+
const r = `#${a}`;
|
|
34
|
+
Object.defineProperty(i, a, {
|
|
35
35
|
get() {
|
|
36
|
-
return this[
|
|
36
|
+
return this[r];
|
|
37
37
|
},
|
|
38
|
-
set(
|
|
39
|
-
const
|
|
40
|
-
e.includes(
|
|
41
|
-
`<${n}> Invalid value "${
|
|
38
|
+
set(p) {
|
|
39
|
+
const c = this[r];
|
|
40
|
+
e.includes(p) ? this[r] = p : (console.error(
|
|
41
|
+
`<${n}> Invalid value "${p}" provided for property "${a}".`,
|
|
42
42
|
`Must be one of: ${e.join(" | ")}.`,
|
|
43
|
-
`Falling back to default value: "${
|
|
44
|
-
), this[
|
|
43
|
+
`Falling back to default value: "${o}"`
|
|
44
|
+
), this[r] = o), this.requestUpdate(a, c);
|
|
45
45
|
}
|
|
46
46
|
});
|
|
47
|
-
},
|
|
48
|
-
const i = `#${
|
|
49
|
-
Object.defineProperty(
|
|
47
|
+
}, j = (n) => function(o, t) {
|
|
48
|
+
const i = `#${t}`;
|
|
49
|
+
Object.defineProperty(o, t, {
|
|
50
50
|
get() {
|
|
51
51
|
return this[i];
|
|
52
52
|
},
|
|
53
|
-
set(
|
|
54
|
-
const
|
|
55
|
-
(
|
|
53
|
+
set(a) {
|
|
54
|
+
const r = this[i];
|
|
55
|
+
(a == null || typeof a == "string" && a.trim() === "") && console.error(`<${n}> Missing required attribute "${t}"`), this[i] = a, this.requestUpdate(t, r);
|
|
56
56
|
}
|
|
57
57
|
});
|
|
58
58
|
};
|
|
59
59
|
function q(n) {
|
|
60
60
|
if (Array.isArray(n)) {
|
|
61
|
-
for (var e = 0,
|
|
62
|
-
|
|
63
|
-
return
|
|
61
|
+
for (var e = 0, o = Array(n.length); e < n.length; e++)
|
|
62
|
+
o[e] = n[e];
|
|
63
|
+
return o;
|
|
64
64
|
} else
|
|
65
65
|
return Array.from(n);
|
|
66
66
|
}
|
|
67
67
|
var O = !1;
|
|
68
68
|
if (typeof window < "u") {
|
|
69
|
-
var
|
|
69
|
+
var C = {
|
|
70
70
|
get passive() {
|
|
71
71
|
O = !0;
|
|
72
72
|
}
|
|
73
73
|
};
|
|
74
|
-
window.addEventListener("testPassive", null,
|
|
74
|
+
window.addEventListener("testPassive", null, C), window.removeEventListener("testPassive", null, C);
|
|
75
75
|
}
|
|
76
|
-
var
|
|
77
|
-
return
|
|
78
|
-
return !!(
|
|
76
|
+
var y = typeof window < "u" && window.navigator && window.navigator.platform && (/iP(ad|hone|od)/.test(window.navigator.platform) || window.navigator.platform === "MacIntel" && window.navigator.maxTouchPoints > 1), u = [], w = !1, L = -1, v = void 0, m = void 0, g = void 0, M = function(e) {
|
|
77
|
+
return u.some(function(o) {
|
|
78
|
+
return !!(o.options.allowTouchMove && o.options.allowTouchMove(e));
|
|
79
79
|
});
|
|
80
|
-
},
|
|
81
|
-
var
|
|
82
|
-
return M(
|
|
83
|
-
},
|
|
84
|
-
if (
|
|
85
|
-
var
|
|
86
|
-
if (
|
|
80
|
+
}, _ = function(e) {
|
|
81
|
+
var o = e || window.event;
|
|
82
|
+
return M(o.target) || o.touches.length > 1 ? !0 : (o.preventDefault && o.preventDefault(), !1);
|
|
83
|
+
}, V = function(e) {
|
|
84
|
+
if (g === void 0) {
|
|
85
|
+
var o = !!e && e.reserveScrollBarGap === !0, t = window.innerWidth - document.documentElement.clientWidth;
|
|
86
|
+
if (o && t > 0) {
|
|
87
87
|
var i = parseInt(window.getComputedStyle(document.body).getPropertyValue("padding-right"), 10);
|
|
88
|
-
|
|
88
|
+
g = document.body.style.paddingRight, document.body.style.paddingRight = i + t + "px";
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
-
|
|
92
|
-
},
|
|
93
|
-
|
|
94
|
-
},
|
|
91
|
+
v === void 0 && (v = document.body.style.overflow, document.body.style.overflow = "hidden");
|
|
92
|
+
}, N = function() {
|
|
93
|
+
g !== void 0 && (document.body.style.paddingRight = g, g = void 0), v !== void 0 && (document.body.style.overflow = v, v = void 0);
|
|
94
|
+
}, H = function() {
|
|
95
95
|
return window.requestAnimationFrame(function() {
|
|
96
|
-
if (
|
|
97
|
-
|
|
96
|
+
if (m === void 0) {
|
|
97
|
+
m = {
|
|
98
98
|
position: document.body.style.position,
|
|
99
99
|
top: document.body.style.top,
|
|
100
100
|
left: document.body.style.left
|
|
101
101
|
};
|
|
102
|
-
var e = window,
|
|
103
|
-
document.body.style.position = "fixed", document.body.style.top = -
|
|
102
|
+
var e = window, o = e.scrollY, t = e.scrollX, i = e.innerHeight;
|
|
103
|
+
document.body.style.position = "fixed", document.body.style.top = -o, document.body.style.left = -t, setTimeout(function() {
|
|
104
104
|
return window.requestAnimationFrame(function() {
|
|
105
|
-
var
|
|
106
|
-
|
|
105
|
+
var a = i - window.innerHeight;
|
|
106
|
+
a && o >= i && (document.body.style.top = -(o + a));
|
|
107
107
|
});
|
|
108
108
|
}, 300);
|
|
109
109
|
}
|
|
110
110
|
});
|
|
111
|
-
},
|
|
112
|
-
if (
|
|
113
|
-
var e = -parseInt(document.body.style.top, 10),
|
|
114
|
-
document.body.style.position =
|
|
111
|
+
}, W = function() {
|
|
112
|
+
if (m !== void 0) {
|
|
113
|
+
var e = -parseInt(document.body.style.top, 10), o = -parseInt(document.body.style.left, 10);
|
|
114
|
+
document.body.style.position = m.position, document.body.style.top = m.top, document.body.style.left = m.left, window.scrollTo(o, e), m = void 0;
|
|
115
115
|
}
|
|
116
|
-
},
|
|
116
|
+
}, Y = function(e) {
|
|
117
117
|
return e ? e.scrollHeight - e.scrollTop <= e.clientHeight : !1;
|
|
118
|
-
},
|
|
119
|
-
var
|
|
120
|
-
return M(e.target) ? !1 :
|
|
121
|
-
},
|
|
118
|
+
}, U = function(e, o) {
|
|
119
|
+
var t = e.targetTouches[0].clientY - L;
|
|
120
|
+
return M(e.target) ? !1 : o && o.scrollTop === 0 && t > 0 || Y(o) && t < 0 ? _(e) : (e.stopPropagation(), !0);
|
|
121
|
+
}, X = function(e, o) {
|
|
122
122
|
if (!e) {
|
|
123
123
|
console.error("disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.");
|
|
124
124
|
return;
|
|
125
125
|
}
|
|
126
|
-
if (!
|
|
126
|
+
if (!u.some(function(i) {
|
|
127
127
|
return i.targetElement === e;
|
|
128
128
|
})) {
|
|
129
|
-
var
|
|
129
|
+
var t = {
|
|
130
130
|
targetElement: e,
|
|
131
|
-
options:
|
|
131
|
+
options: o || {}
|
|
132
132
|
};
|
|
133
|
-
|
|
134
|
-
i.targetTouches.length === 1 && (
|
|
133
|
+
u = [].concat(q(u), [t]), y ? H() : V(o), y && (e.ontouchstart = function(i) {
|
|
134
|
+
i.targetTouches.length === 1 && (L = i.targetTouches[0].clientY);
|
|
135
135
|
}, e.ontouchmove = function(i) {
|
|
136
|
-
i.targetTouches.length === 1 &&
|
|
137
|
-
},
|
|
136
|
+
i.targetTouches.length === 1 && U(i, e);
|
|
137
|
+
}, w || (document.addEventListener("touchmove", _, O ? { passive: !1 } : void 0), w = !0));
|
|
138
138
|
}
|
|
139
|
-
},
|
|
139
|
+
}, G = function(e) {
|
|
140
140
|
if (!e) {
|
|
141
141
|
console.error("enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.");
|
|
142
142
|
return;
|
|
143
143
|
}
|
|
144
|
-
|
|
145
|
-
return
|
|
146
|
-
}),
|
|
144
|
+
u = u.filter(function(o) {
|
|
145
|
+
return o.targetElement !== e;
|
|
146
|
+
}), y && (e.ontouchstart = null, e.ontouchmove = null, w && u.length === 0 && (document.removeEventListener("touchmove", _, O ? { passive: !1 } : void 0), w = !1)), y ? W() : N();
|
|
147
147
|
};
|
|
148
|
-
const
|
|
149
|
-
`,
|
|
150
|
-
var
|
|
151
|
-
for (var i =
|
|
152
|
-
(
|
|
153
|
-
return
|
|
148
|
+
const J = `*,*:before,*:after{box-sizing:border-box}@keyframes rotate360{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.c-modal{--modal-size-s: 450px;--modal-size-m: 600px;--modal-size-l: 1080px;--modal-border-radius: var(--dt-radius-rounded-d);--modal-font: var(--dt-font-interactive-m-family);--modal-bg-color: var(--dt-color-container-default);--modal-elevation: var(--dt-elevation-04);border-radius:var(--modal-border-radius);border:none;box-shadow:var(--modal-elevation);font-family:var(--modal-font);background-color:var(--modal-bg-color);padding:0;--modal-margin-none: var(--dt-spacing-none);--modal-margin-small: var(--dt-spacing-g);--modal-margin-large: var(--dt-spacing-j);--modal-margin-block: var(--modal-margin-small);--modal-block-size: fit-content;--modal-inline-size: 75%;--modal-max-block-size: calc(100vh - calc(var(--modal-margin-block) * 2));--modal-max-inline-size: var(--modal-size-m);block-size:var(--modal-block-size);inline-size:var(--modal-inline-size);max-block-size:var(--modal-max-block-size);max-inline-size:var(--modal-max-inline-size)}.c-modal:focus-visible{outline:none}.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)}}@media (max-width: 767px){.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]{--modal-inline-size: 75%;--modal-max-inline-size: var(--modal-size-l);--modal-margin-block: var(--modal-margin-large)}@media (max-width: 767px){.c-modal[size=large]{--modal-margin-block: var(--modal-margin-none);--modal-border-radius: var(--dt-radius-rounded-none);--modal-block-size: 100%;--modal-inline-size: 100%}}.c-modal::backdrop{background:rgba(0,0,0,.5)}.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)}}.c-modal .c-modal-header{--modal-header-padding: var(--dt-spacing-e);padding-inline:var(--modal-header-padding);padding-block:var(--modal-header-padding);align-items:center;display:flex}.c-modal[hasbackbutton] .c-modal-header{padding-block:var(--dt-spacing-c);padding-inline-start:var(--dt-spacing-c)}.c-modal[isdismissible] .c-modal-header{justify-content:space-between;padding-block:var(--dt-spacing-c);padding-inline-end:var(--dt-spacing-c)}.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);--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}.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-e)}.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: var(--dt-spacing-e);--modal-content-padding-block: var(--dt-spacing-a);--spinner-size: 48px;--spinner-border-width: 6px;--spinner-base-color-h: var(--dt-color-content-interactive-secondary-h);--spinner-base-color-s: var(--dt-color-content-interactive-secondary-s);--spinner-base-color-l: var(--dt-color-content-interactive-secondary-l);--spinner-left-color-opacity: .35;--spinner-left-color: hsl(var(--spinner-base-color-h), var(--spinner-base-color-s), var(--spinner-base-color-l), var(--spinner-left-color-opacity));--spinner-right-color: hsl(var(--spinner-base-color-h), var(--spinner-base-color-s), var(--spinner-base-color-l), 1);--spinner-animation-duration: 1.15s;--spinner-animation-timing-function: linear;--spinner-animation-iteration-count: infinite;position:relative;min-block-size:60px;font-size:var(--modal-content-font-size);line-height:var(--modal-content-line-height);font-weight:var(--modal-content-font-weight);padding-inline:var(--modal-content-padding);padding-block:var(--modal-content-padding-block);overflow-y:auto}.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-content:before{content:"";position:absolute;left:50%;top:50%;translate:-50% -50%;height:var(--spinner-size);width:var(--spinner-size);display:block;background-color:transparent;border-radius:50%;border-color:var(--spinner-left-color) var(--spinner-right-color) var(--spinner-right-color) var(--spinner-left-color);border-width:var(--spinner-border-width);border-style:solid;will-change:transform;opacity:0}.c-modal[isLoading] .c-modal-content:before{animation:rotate360 var(--spinner-animation-duration) var(--spinner-animation-timing-function) var(--spinner-animation-iteration-count);opacity:1}.c-modal[isLoading] .c-modal-content .c-modal-contentInner{opacity:0}.c-modal .c-modal-closeBtn{margin-inline-start:auto}
|
|
149
|
+
`, Q = ["h1", "h2", "h3", "h4", "h5", "h6"], Z = ["small", "medium", "large"], z = "pie-modal-close", b = "pie-modal-open", x = "pie-modal-back";
|
|
150
|
+
var K = Object.defineProperty, ee = Object.getOwnPropertyDescriptor, d = (n, e, o, t) => {
|
|
151
|
+
for (var i = t > 1 ? void 0 : t ? ee(e, o) : e, a = n.length - 1, r; a >= 0; a--)
|
|
152
|
+
(r = n[a]) && (i = (t ? r(e, o, i) : r(i)) || i);
|
|
153
|
+
return t && i && K(e, o, i), i;
|
|
154
154
|
};
|
|
155
|
-
const
|
|
156
|
-
class
|
|
155
|
+
const k = "pie-modal";
|
|
156
|
+
class l extends I(E) {
|
|
157
157
|
constructor() {
|
|
158
|
-
super(), this.headingLevel = "h2", this.isDismissible = !1, this.isFullWidthBelowMid = !1, this.isOpen = !1, this.size = "medium", this._handleDialogCancelEvent = (e) => {
|
|
158
|
+
super(), this.headingLevel = "h2", this.isDismissible = !1, this.hasBackButton = !1, this.isFullWidthBelowMid = !1, this.isOpen = !1, this.isLoading = !1, this.size = "medium", this._backButtonClicked = !1, this._handleDialogCancelEvent = (e) => {
|
|
159
159
|
this.isDismissible || e.preventDefault();
|
|
160
160
|
}, this._handleDialogLightDismiss = (e) => {
|
|
161
|
-
var
|
|
161
|
+
var c;
|
|
162
162
|
if (!this.isDismissible)
|
|
163
163
|
return;
|
|
164
|
-
const
|
|
165
|
-
top:
|
|
164
|
+
const o = (c = this._dialog) == null ? void 0 : c.getBoundingClientRect(), {
|
|
165
|
+
top: t = 0,
|
|
166
166
|
bottom: i = 0,
|
|
167
|
-
left:
|
|
168
|
-
right:
|
|
169
|
-
} =
|
|
170
|
-
if (
|
|
167
|
+
left: a = 0,
|
|
168
|
+
right: r = 0
|
|
169
|
+
} = o || {};
|
|
170
|
+
if (t === 0 && i === 0 && a === 0 && r === 0)
|
|
171
171
|
return;
|
|
172
|
-
(e.clientY <
|
|
172
|
+
(e.clientY < t || e.clientY > i || e.clientX < a || e.clientX > r) && (this.isOpen = !1);
|
|
173
173
|
}, this._dispatchModalCustomEvent = (e) => {
|
|
174
|
-
const
|
|
174
|
+
const o = new CustomEvent(e, {
|
|
175
175
|
bubbles: !0,
|
|
176
176
|
composed: !0
|
|
177
177
|
});
|
|
178
|
-
this.dispatchEvent(
|
|
178
|
+
this.dispatchEvent(o);
|
|
179
179
|
}, this.addEventListener("click", (e) => this._handleDialogLightDismiss(e));
|
|
180
180
|
}
|
|
181
181
|
connectedCallback() {
|
|
182
|
-
super.connectedCallback(), document.addEventListener(
|
|
182
|
+
super.connectedCallback(), document.addEventListener(b, this._handleModalOpened.bind(this)), document.addEventListener(z, this._handleModalClosed.bind(this)), document.addEventListener(x, this._handleModalClosed.bind(this));
|
|
183
183
|
}
|
|
184
184
|
disconnectedCallback() {
|
|
185
|
-
document.removeEventListener(
|
|
185
|
+
document.removeEventListener(b, this._handleModalOpened.bind(this)), document.removeEventListener(z, this._handleModalClosed.bind(this)), document.removeEventListener(x, this._handleModalClosed.bind(this)), super.disconnectedCallback();
|
|
186
186
|
}
|
|
187
187
|
firstUpdated(e) {
|
|
188
|
-
var
|
|
189
|
-
(
|
|
188
|
+
var o, t;
|
|
189
|
+
(o = this._dialog) == null || o.addEventListener("cancel", (i) => this._handleDialogCancelEvent(i)), this._handleModalOpenStateOnFirstRender(e), (t = this._dialog) == null || t.addEventListener("close", () => {
|
|
190
190
|
this.isOpen = !1;
|
|
191
191
|
});
|
|
192
192
|
}
|
|
@@ -197,57 +197,33 @@ class a extends k(B) {
|
|
|
197
197
|
* Opens the dialog element and disables page scrolling
|
|
198
198
|
*/
|
|
199
199
|
_handleModalOpened() {
|
|
200
|
-
var e,
|
|
201
|
-
|
|
200
|
+
var e, o, t;
|
|
201
|
+
X(this), !((e = this._dialog) != null && e.hasAttribute("open") || !((o = this._dialog) != null && o.isConnected)) && ((t = this._dialog) == null || t.showModal());
|
|
202
202
|
}
|
|
203
203
|
/**
|
|
204
204
|
* Closes the dialog element and re-enables page scrolling
|
|
205
205
|
*/
|
|
206
206
|
_handleModalClosed() {
|
|
207
207
|
var e;
|
|
208
|
-
|
|
208
|
+
G(this), (e = this._dialog) == null || e.close(), this._returnFocus();
|
|
209
209
|
}
|
|
210
210
|
// Handles the value of the isOpen property on first render of the component
|
|
211
211
|
_handleModalOpenStateOnFirstRender(e) {
|
|
212
|
-
e.get("isOpen") === void 0 && this.isOpen && this._dispatchModalCustomEvent(
|
|
212
|
+
e.get("isOpen") === void 0 && this.isOpen && this._dispatchModalCustomEvent(b);
|
|
213
213
|
}
|
|
214
214
|
// Handles changes to the modal isOpen property by dispatching any appropriate events
|
|
215
215
|
_handleModalOpenStateChanged(e) {
|
|
216
|
-
const
|
|
217
|
-
|
|
216
|
+
const o = e.get("isOpen");
|
|
217
|
+
o !== void 0 && (o ? this._backButtonClicked ? (this._backButtonClicked = !1, this._dispatchModalCustomEvent(x)) : this._dispatchModalCustomEvent(z) : this._dispatchModalCustomEvent(b));
|
|
218
218
|
}
|
|
219
219
|
/**
|
|
220
220
|
* Return focus to the specified element, providing the selector is valid
|
|
221
221
|
* and the chosen element can be found.
|
|
222
|
-
* Fails silently.
|
|
223
222
|
*/
|
|
224
223
|
_returnFocus() {
|
|
225
|
-
var
|
|
226
|
-
const e = (
|
|
227
|
-
e && ((
|
|
228
|
-
}
|
|
229
|
-
render() {
|
|
230
|
-
const {
|
|
231
|
-
heading: e,
|
|
232
|
-
headingLevel: t = "h2",
|
|
233
|
-
size: o,
|
|
234
|
-
isFullWidthBelowMid: i
|
|
235
|
-
} = this, d = E(t);
|
|
236
|
-
return z`
|
|
237
|
-
<dialog
|
|
238
|
-
id="dialog"
|
|
239
|
-
class="c-modal"
|
|
240
|
-
size="${o}"
|
|
241
|
-
?isFullWidthBelowMid=${i}>
|
|
242
|
-
<header>
|
|
243
|
-
<${d} class="c-modal-heading">${e}</${d}>
|
|
244
|
-
${this.isDismissible ? this.renderCloseButton() : x}
|
|
245
|
-
</header>
|
|
246
|
-
<article class="c-modal-content">
|
|
247
|
-
<slot></slot>
|
|
248
|
-
</article>
|
|
249
|
-
</dialog>
|
|
250
|
-
`;
|
|
224
|
+
var o, t;
|
|
225
|
+
const e = (o = this.returnFocusAfterCloseSelector) == null ? void 0 : o.trim();
|
|
226
|
+
e && ((t = document.querySelector(e)) == null || t.focus());
|
|
251
227
|
}
|
|
252
228
|
/**
|
|
253
229
|
* Template for the close button element. Called within the
|
|
@@ -256,7 +232,7 @@ class a extends k(B) {
|
|
|
256
232
|
* @private
|
|
257
233
|
*/
|
|
258
234
|
renderCloseButton() {
|
|
259
|
-
return
|
|
235
|
+
return f`
|
|
260
236
|
<pie-icon-button
|
|
261
237
|
@click="${() => {
|
|
262
238
|
this.isOpen = !1;
|
|
@@ -266,38 +242,119 @@ class a extends k(B) {
|
|
|
266
242
|
data-test-id="modal-close-button"><icon-close /></pie-icon-button>
|
|
267
243
|
`;
|
|
268
244
|
}
|
|
245
|
+
/**
|
|
246
|
+
* Template for the back button element. Called within the
|
|
247
|
+
* main render function.
|
|
248
|
+
*
|
|
249
|
+
* @private
|
|
250
|
+
*/
|
|
251
|
+
renderBackButton() {
|
|
252
|
+
return f`
|
|
253
|
+
<pie-icon-button
|
|
254
|
+
@click="${() => {
|
|
255
|
+
this._backButtonClicked = !0, this.isOpen = !1;
|
|
256
|
+
}}"
|
|
257
|
+
variant="ghost-secondary"
|
|
258
|
+
class="c-modal-backBtn"
|
|
259
|
+
data-test-id="modal-back-button">
|
|
260
|
+
${this.isRTL ? f`<icon-chevron-right />` : f`<icon-chevron-left />`}
|
|
261
|
+
</pie-icon-button>
|
|
262
|
+
`;
|
|
263
|
+
}
|
|
264
|
+
render() {
|
|
265
|
+
const {
|
|
266
|
+
hasBackButton: e,
|
|
267
|
+
heading: o,
|
|
268
|
+
headingLevel: t = "h2",
|
|
269
|
+
isDismissible: i,
|
|
270
|
+
isFullWidthBelowMid: a,
|
|
271
|
+
isLoading: r,
|
|
272
|
+
size: p
|
|
273
|
+
} = this, c = $(t);
|
|
274
|
+
return f`
|
|
275
|
+
<dialog
|
|
276
|
+
id="dialog"
|
|
277
|
+
class="c-modal"
|
|
278
|
+
size="${p}"
|
|
279
|
+
?hasBackButton=${e}
|
|
280
|
+
?isDismissible=${i}
|
|
281
|
+
?isFullWidthBelowMid=${a}
|
|
282
|
+
?isLoading=${r}
|
|
283
|
+
data-test-id="pie-modal">
|
|
284
|
+
<header class="c-modal-header">
|
|
285
|
+
${e ? this.renderBackButton() : B}
|
|
286
|
+
<${c} class="c-modal-heading">
|
|
287
|
+
${o}
|
|
288
|
+
</${c}>
|
|
289
|
+
${i ? this.renderCloseButton() : B}
|
|
290
|
+
</header>
|
|
291
|
+
<article class="c-modal-content c-modal-content--scrollable">
|
|
292
|
+
<div class="c-modal-contentInner">
|
|
293
|
+
<slot></slot>
|
|
294
|
+
</div>
|
|
295
|
+
</article>
|
|
296
|
+
<footer class="c-modal-footer">
|
|
297
|
+
<pie-button
|
|
298
|
+
variant="primary"
|
|
299
|
+
type="submit"
|
|
300
|
+
@click="${() => {
|
|
301
|
+
var h;
|
|
302
|
+
return (h = this._dialog) == null ? void 0 : h.close("leading");
|
|
303
|
+
}}"
|
|
304
|
+
data-test-id="modal-leading-action">
|
|
305
|
+
Confirm
|
|
306
|
+
</pie-button>
|
|
307
|
+
<pie-button
|
|
308
|
+
variant="ghost"
|
|
309
|
+
type="reset"
|
|
310
|
+
@click="${() => {
|
|
311
|
+
var h;
|
|
312
|
+
return (h = this._dialog) == null ? void 0 : h.close("supporting");
|
|
313
|
+
}}"
|
|
314
|
+
data-test-id="modal-supporting-action">
|
|
315
|
+
Cancel
|
|
316
|
+
</pie-button>
|
|
317
|
+
</footer>
|
|
318
|
+
</dialog>`;
|
|
319
|
+
}
|
|
269
320
|
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
],
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
],
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
],
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
],
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
],
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
],
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
s(
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
321
|
+
l.styles = P(J);
|
|
322
|
+
d([
|
|
323
|
+
s({ type: String }),
|
|
324
|
+
j(k)
|
|
325
|
+
], l.prototype, "heading", 2);
|
|
326
|
+
d([
|
|
327
|
+
s(),
|
|
328
|
+
S(k, Q, "h2")
|
|
329
|
+
], l.prototype, "headingLevel", 2);
|
|
330
|
+
d([
|
|
331
|
+
s({ type: Boolean, reflect: !0 })
|
|
332
|
+
], l.prototype, "isDismissible", 2);
|
|
333
|
+
d([
|
|
334
|
+
s({ type: Boolean })
|
|
335
|
+
], l.prototype, "hasBackButton", 2);
|
|
336
|
+
d([
|
|
337
|
+
s({ type: Boolean })
|
|
338
|
+
], l.prototype, "isFullWidthBelowMid", 2);
|
|
339
|
+
d([
|
|
340
|
+
s({ type: Boolean })
|
|
341
|
+
], l.prototype, "isOpen", 2);
|
|
342
|
+
d([
|
|
343
|
+
s({ type: Boolean, reflect: !0 })
|
|
344
|
+
], l.prototype, "isLoading", 2);
|
|
345
|
+
d([
|
|
346
|
+
s()
|
|
347
|
+
], l.prototype, "returnFocusAfterCloseSelector", 2);
|
|
348
|
+
d([
|
|
349
|
+
s(),
|
|
350
|
+
S(k, Z, "medium")
|
|
351
|
+
], l.prototype, "size", 2);
|
|
352
|
+
d([
|
|
353
|
+
D("dialog")
|
|
354
|
+
], l.prototype, "_dialog", 2);
|
|
355
|
+
customElements.define(k, l);
|
|
299
356
|
export {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
357
|
+
l as PieModal,
|
|
358
|
+
Q as headingLevels,
|
|
359
|
+
Z as sizes
|
|
303
360
|
};
|