@justeattakeaway/pie-modal 0.30.0 → 0.32.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/README.md +16 -2
- package/dist/index.js +195 -408
- package/dist/react.js +53 -45
- package/package.json +7 -6
- package/src/index.ts +6 -1
- package/src/modal.scss +6 -53
package/README.md
CHANGED
|
@@ -43,14 +43,28 @@ For full information on using PIE components as part of an application, check ou
|
|
|
43
43
|
|
|
44
44
|
### Importing the component
|
|
45
45
|
|
|
46
|
+
#### JavaScript
|
|
46
47
|
```js
|
|
47
|
-
//
|
|
48
|
+
// Default – for Native JS Applications, Vue, Angular, Svelte, etc.
|
|
48
49
|
import { PieModal } from '@justeattakeaway/pie-modal';
|
|
49
50
|
|
|
50
|
-
//
|
|
51
|
+
// If you don't need to reference the imported object, you can simply
|
|
52
|
+
// import the module which registers the component as a custom element.
|
|
53
|
+
import '@justeattakeaway/pie-modal';
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
#### React
|
|
57
|
+
```js
|
|
58
|
+
// React
|
|
59
|
+
// For React, you will need to import our React-specific component build
|
|
60
|
+
// which wraps the web component using @lit-labs/react
|
|
51
61
|
import { PieModal } from '@justeattakeaway/pie-modal/dist/react';
|
|
52
62
|
```
|
|
53
63
|
|
|
64
|
+
> [!NOTE]
|
|
65
|
+
> When using the React version of the component, please make sure to also
|
|
66
|
+
> include React as a [peer dependency](#peer-dependencies) in your project.
|
|
67
|
+
|
|
54
68
|
|
|
55
69
|
## Peer Dependencies
|
|
56
70
|
|
package/dist/index.js
CHANGED
|
@@ -1,329 +1,115 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { html as
|
|
3
|
-
import { property as
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return this.dir ? this.dir === "rtl" : !K && !this.dir ? document.documentElement.getAttribute("dir") === "rtl" : !1;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return e;
|
|
20
|
-
}, E = (n, e, t) => function(o, a) {
|
|
21
|
-
const r = `#${a}`;
|
|
22
|
-
Object.defineProperty(o, a, {
|
|
23
|
-
get() {
|
|
24
|
-
return this[r];
|
|
25
|
-
},
|
|
26
|
-
set(h) {
|
|
27
|
-
const g = this[r];
|
|
28
|
-
e.includes(h) ? this[r] = h : (console.error(
|
|
29
|
-
`<${n}> Invalid value "${h}" provided for property "${a}".`,
|
|
30
|
-
`Must be one of: ${e.join(" | ")}.`,
|
|
31
|
-
`Falling back to default value: "${t}"`
|
|
32
|
-
), this[r] = t), this.requestUpdate(a, g);
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
}, oe = (n) => function(t, i) {
|
|
36
|
-
const o = `#${i}`;
|
|
37
|
-
Object.defineProperty(t, i, {
|
|
38
|
-
get() {
|
|
39
|
-
return this[o];
|
|
40
|
-
},
|
|
41
|
-
set(a) {
|
|
42
|
-
const r = this[o];
|
|
43
|
-
(a == null || typeof a == "string" && a.trim() === "") && console.error(`<${n}> Missing required attribute "${i}"`), this[o] = a, this.requestUpdate(i, r);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
};
|
|
47
|
-
function ne(n, e) {
|
|
48
|
-
customElements.get(n) ? console.warn(`PIE Web Component: "${n}" has already been defined. Please ensure the component is only being defined once in your application.`) : customElements.define(n, e);
|
|
49
|
-
}
|
|
50
|
-
function P(n, e) {
|
|
51
|
-
customElements.get(n) ? console.warn(`PIE Web Component: "${n}" has already been defined. Please ensure the component is only being defined once in your application.`) : customElements.define(n, e);
|
|
52
|
-
}
|
|
53
|
-
const _ = {
|
|
54
|
-
xs: 16,
|
|
55
|
-
s: 20,
|
|
56
|
-
m: 24,
|
|
57
|
-
l: 28,
|
|
58
|
-
xl: 32,
|
|
59
|
-
xxl: 40
|
|
60
|
-
}, W = Object.keys(_), q = "xs", V = 8, z = 32;
|
|
61
|
-
function ae(n, e, t) {
|
|
62
|
-
const i = parseInt(n, 10), o = i % t === 0;
|
|
63
|
-
return i >= e && o;
|
|
64
|
-
}
|
|
65
|
-
const Y = {
|
|
66
|
-
large: (n) => ae(n, z, V),
|
|
67
|
-
regular: (n) => W.includes(n)
|
|
68
|
-
};
|
|
69
|
-
function re(n) {
|
|
70
|
-
const e = Y.large(n);
|
|
71
|
-
return { isValid: e, size: e ? n : z };
|
|
72
|
-
}
|
|
73
|
-
function le(n) {
|
|
74
|
-
const e = Y.regular(n), t = e ? _[n] : _[q];
|
|
75
|
-
return { isValid: e, size: t };
|
|
76
|
-
}
|
|
77
|
-
const u = (n, e, t, i) => {
|
|
78
|
-
const o = n.endsWith("Large") || n.endsWith("-large");
|
|
79
|
-
let a, r;
|
|
80
|
-
if (t) {
|
|
81
|
-
if ({ isValid: a, size: r } = o ? re(t) : le(t), !a) {
|
|
82
|
-
const h = o ? `Invalid prop "size" value supplied to "${i}". The prop value should be a number equal or greater than ${z} and multiple of ${V}.` : `Invalid prop "size" value supplied to "${i}". The prop value should be one of the following values: ${W.join(", ")}.`;
|
|
83
|
-
console.error(h);
|
|
84
|
-
}
|
|
1
|
+
import { LitElement as P, nothing as r, unsafeCSS as T } from "lit";
|
|
2
|
+
import { html as c, unsafeStatic as F } from "lit/static-html.js";
|
|
3
|
+
import { property as d, query as N } from "lit/decorators.js";
|
|
4
|
+
import "@justeattakeaway/pie-button";
|
|
5
|
+
import "@justeattakeaway/pie-icon-button";
|
|
6
|
+
import { RtlMixin as I, requiredProperty as R, validPropertyValues as z, defineCustomElement as j } from "@justeattakeaway/pie-webc-core";
|
|
7
|
+
import "@justeattakeaway/pie-icons-webc/IconClose";
|
|
8
|
+
import "@justeattakeaway/pie-icons-webc/IconChevronLeft";
|
|
9
|
+
import "@justeattakeaway/pie-icons-webc/IconChevronRight";
|
|
10
|
+
import "@justeattakeaway/pie-spinner";
|
|
11
|
+
function W(a) {
|
|
12
|
+
if (Array.isArray(a)) {
|
|
13
|
+
for (var e = 0, o = Array(a.length); e < a.length; e++)
|
|
14
|
+
o[e] = a[e];
|
|
15
|
+
return o;
|
|
85
16
|
} else
|
|
86
|
-
|
|
87
|
-
return {
|
|
88
|
-
class: [n, e].filter(Boolean).join(" "),
|
|
89
|
-
width: r,
|
|
90
|
-
height: r
|
|
91
|
-
};
|
|
92
|
-
};
|
|
93
|
-
var se = Object.defineProperty, de = Object.getOwnPropertyDescriptor, D = (n, e, t, i) => {
|
|
94
|
-
for (var o = i > 1 ? void 0 : i ? de(e, t) : e, a = n.length - 1, r; a >= 0; a--)
|
|
95
|
-
(r = n[a]) && (o = (i ? r(e, t, o) : r(o)) || o);
|
|
96
|
-
return i && o && se(e, t, o), o;
|
|
97
|
-
};
|
|
98
|
-
const ce = "icon-close";
|
|
99
|
-
class b extends $ {
|
|
100
|
-
constructor() {
|
|
101
|
-
super(...arguments), this.size = "xs", this.class = "c-pieIcon c-pieIcon--close";
|
|
102
|
-
}
|
|
103
|
-
connectedCallback() {
|
|
104
|
-
var e, t, i;
|
|
105
|
-
if (super.connectedCallback(), ((e = this._svg) == null ? void 0 : e.getAttribute("width")) === null) {
|
|
106
|
-
const o = u("c-pieIcon c-pieIcon--close", "", null, "IconClose");
|
|
107
|
-
(t = this._svg) == null || t.setAttribute("width", o.width), (i = this._svg) == null || i.setAttribute("height", o.height);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
updated(e) {
|
|
111
|
-
var t, i;
|
|
112
|
-
let o;
|
|
113
|
-
e.has("size") && (o = u("c-pieIcon c-pieIcon--close", "", this.size, "IconClose"), (t = this._svg) == null || t.setAttribute("width", o.width), (i = this._svg) == null || i.setAttribute("height", o.height));
|
|
114
|
-
}
|
|
115
|
-
render() {
|
|
116
|
-
return M`<svg xmlns="http://www.w3.org/2000/svg" role="presentation" focusable="false" fill="currentColor" viewBox="0 0 16 16" class="c-pieIcon c-pieIcon--close"><path d="M11.868 3.205 8 7.072 4.133 3.205l-.928.927L7.073 8l-3.868 3.867.928.928L8 8.927l3.868 3.868.927-.928L8.928 8l3.867-3.868-.927-.927Z"></path></svg>`;
|
|
117
|
-
}
|
|
17
|
+
return Array.from(a);
|
|
118
18
|
}
|
|
119
|
-
|
|
120
|
-
:host-context(pie-icon-button) svg,
|
|
121
|
-
:host-context(pie-button) svg {
|
|
122
|
-
display: block;
|
|
123
|
-
width: var(--btn-icon-size);
|
|
124
|
-
height: var(--btn-icon-size);
|
|
125
|
-
}
|
|
126
|
-
`;
|
|
127
|
-
D([
|
|
128
|
-
l({ type: String, reflect: !0 })
|
|
129
|
-
], b.prototype, "size", 2);
|
|
130
|
-
D([
|
|
131
|
-
l({ type: String, reflect: !0 })
|
|
132
|
-
], b.prototype, "class", 2);
|
|
133
|
-
D([
|
|
134
|
-
O("svg")
|
|
135
|
-
], b.prototype, "_svg", 2);
|
|
136
|
-
P(ce, b);
|
|
137
|
-
var he = Object.defineProperty, pe = Object.getOwnPropertyDescriptor, T = (n, e, t, i) => {
|
|
138
|
-
for (var o = i > 1 ? void 0 : i ? pe(e, t) : e, a = n.length - 1, r; a >= 0; a--)
|
|
139
|
-
(r = n[a]) && (o = (i ? r(e, t, o) : r(o)) || o);
|
|
140
|
-
return i && o && he(e, t, o), o;
|
|
141
|
-
};
|
|
142
|
-
const me = "icon-chevron-left";
|
|
143
|
-
class w extends $ {
|
|
144
|
-
constructor() {
|
|
145
|
-
super(...arguments), this.size = "xs", this.class = "c-pieIcon c-pieIcon--chevronLeft";
|
|
146
|
-
}
|
|
147
|
-
connectedCallback() {
|
|
148
|
-
var e, t, i;
|
|
149
|
-
if (super.connectedCallback(), ((e = this._svg) == null ? void 0 : e.getAttribute("width")) === null) {
|
|
150
|
-
const o = u("c-pieIcon c-pieIcon--chevronLeft", "", null, "IconChevronLeft");
|
|
151
|
-
(t = this._svg) == null || t.setAttribute("width", o.width), (i = this._svg) == null || i.setAttribute("height", o.height);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
updated(e) {
|
|
155
|
-
var t, i;
|
|
156
|
-
let o;
|
|
157
|
-
e.has("size") && (o = u("c-pieIcon c-pieIcon--chevronLeft", "", this.size, "IconChevronLeft"), (t = this._svg) == null || t.setAttribute("width", o.width), (i = this._svg) == null || i.setAttribute("height", o.height));
|
|
158
|
-
}
|
|
159
|
-
render() {
|
|
160
|
-
return M`<svg xmlns="http://www.w3.org/2000/svg" role="presentation" focusable="false" fill="currentColor" viewBox="0 0 16 16" class="c-pieIcon c-pieIcon--chevronLeft"><path d="M10.96 2.82 5.605 8l5.399 5.197-.875.963-5.565-5.364a1.164 1.164 0 0 1 0-1.671l5.495-5.25.901.945Z"></path></svg>`;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
w.styles = I`
|
|
164
|
-
:host-context(pie-icon-button) svg,
|
|
165
|
-
:host-context(pie-button) svg {
|
|
166
|
-
display: block;
|
|
167
|
-
width: var(--btn-icon-size);
|
|
168
|
-
height: var(--btn-icon-size);
|
|
169
|
-
}
|
|
170
|
-
`;
|
|
171
|
-
T([
|
|
172
|
-
l({ type: String, reflect: !0 })
|
|
173
|
-
], w.prototype, "size", 2);
|
|
174
|
-
T([
|
|
175
|
-
l({ type: String, reflect: !0 })
|
|
176
|
-
], w.prototype, "class", 2);
|
|
177
|
-
T([
|
|
178
|
-
O("svg")
|
|
179
|
-
], w.prototype, "_svg", 2);
|
|
180
|
-
P(me, w);
|
|
181
|
-
var ge = Object.defineProperty, ue = Object.getOwnPropertyDescriptor, j = (n, e, t, i) => {
|
|
182
|
-
for (var o = i > 1 ? void 0 : i ? ue(e, t) : e, a = n.length - 1, r; a >= 0; a--)
|
|
183
|
-
(r = n[a]) && (o = (i ? r(e, t, o) : r(o)) || o);
|
|
184
|
-
return i && o && ge(e, t, o), o;
|
|
185
|
-
};
|
|
186
|
-
const ve = "icon-chevron-right";
|
|
187
|
-
class y extends $ {
|
|
188
|
-
constructor() {
|
|
189
|
-
super(...arguments), this.size = "xs", this.class = "c-pieIcon c-pieIcon--chevronRight";
|
|
190
|
-
}
|
|
191
|
-
connectedCallback() {
|
|
192
|
-
var e, t, i;
|
|
193
|
-
if (super.connectedCallback(), ((e = this._svg) == null ? void 0 : e.getAttribute("width")) === null) {
|
|
194
|
-
const o = u("c-pieIcon c-pieIcon--chevronRight", "", null, "IconChevronRight");
|
|
195
|
-
(t = this._svg) == null || t.setAttribute("width", o.width), (i = this._svg) == null || i.setAttribute("height", o.height);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
updated(e) {
|
|
199
|
-
var t, i;
|
|
200
|
-
let o;
|
|
201
|
-
e.has("size") && (o = u("c-pieIcon c-pieIcon--chevronRight", "", this.size, "IconChevronRight"), (t = this._svg) == null || t.setAttribute("width", o.width), (i = this._svg) == null || i.setAttribute("height", o.height));
|
|
202
|
-
}
|
|
203
|
-
render() {
|
|
204
|
-
return M`<svg xmlns="http://www.w3.org/2000/svg" role="presentation" focusable="false" fill="currentColor" viewBox="0 0 16 16" class="c-pieIcon c-pieIcon--chevronRight"><path d="M5.044 13.18 10.399 8 5 2.82l.875-.962 5.539 5.346a1.164 1.164 0 0 1 0 1.636l-5.469 5.285-.901-.945Z"></path></svg>`;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
y.styles = I`
|
|
208
|
-
:host-context(pie-icon-button) svg,
|
|
209
|
-
:host-context(pie-button) svg {
|
|
210
|
-
display: block;
|
|
211
|
-
width: var(--btn-icon-size);
|
|
212
|
-
height: var(--btn-icon-size);
|
|
213
|
-
}
|
|
214
|
-
`;
|
|
215
|
-
j([
|
|
216
|
-
l({ type: String, reflect: !0 })
|
|
217
|
-
], y.prototype, "size", 2);
|
|
218
|
-
j([
|
|
219
|
-
l({ type: String, reflect: !0 })
|
|
220
|
-
], y.prototype, "class", 2);
|
|
221
|
-
j([
|
|
222
|
-
O("svg")
|
|
223
|
-
], y.prototype, "_svg", 2);
|
|
224
|
-
P(ve, y);
|
|
225
|
-
function fe(n) {
|
|
226
|
-
if (Array.isArray(n)) {
|
|
227
|
-
for (var e = 0, t = Array(n.length); e < n.length; e++)
|
|
228
|
-
t[e] = n[e];
|
|
229
|
-
return t;
|
|
230
|
-
} else
|
|
231
|
-
return Array.from(n);
|
|
232
|
-
}
|
|
233
|
-
var F = !1;
|
|
19
|
+
var C = !1;
|
|
234
20
|
if (typeof window < "u") {
|
|
235
|
-
var
|
|
21
|
+
var A = {
|
|
236
22
|
get passive() {
|
|
237
|
-
|
|
23
|
+
C = !0;
|
|
238
24
|
}
|
|
239
25
|
};
|
|
240
|
-
window.addEventListener("testPassive", null,
|
|
26
|
+
window.addEventListener("testPassive", null, A), window.removeEventListener("testPassive", null, A);
|
|
241
27
|
}
|
|
242
|
-
var
|
|
243
|
-
return
|
|
244
|
-
return !!(
|
|
28
|
+
var B = typeof window < "u" && window.navigator && window.navigator.platform && (/iP(ad|hone|od)/.test(window.navigator.platform) || window.navigator.platform === "MacIntel" && window.navigator.maxTouchPoints > 1), p = [], b = !1, S = -1, g = void 0, h = void 0, L = function(e) {
|
|
29
|
+
return p.some(function(o) {
|
|
30
|
+
return !!(o.options.allowTouchMove && o.options.allowTouchMove(e));
|
|
245
31
|
});
|
|
246
|
-
},
|
|
247
|
-
var
|
|
248
|
-
return
|
|
249
|
-
},
|
|
250
|
-
if (
|
|
251
|
-
var
|
|
252
|
-
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
},
|
|
256
|
-
|
|
257
|
-
},
|
|
32
|
+
}, k = function(e) {
|
|
33
|
+
var o = e || window.event;
|
|
34
|
+
return L(o.target) || o.touches.length > 1 ? !0 : (o.preventDefault && o.preventDefault(), !1);
|
|
35
|
+
}, Y = function(e) {
|
|
36
|
+
if (h === void 0) {
|
|
37
|
+
var o = !!e && e.reserveScrollBarGap === !0, i = window.innerWidth - document.documentElement.clientWidth;
|
|
38
|
+
o && i > 0 && (h = document.body.style.paddingRight, document.body.style.paddingRight = i + "px");
|
|
39
|
+
}
|
|
40
|
+
g === void 0 && (g = document.body.style.overflow, document.body.style.overflow = "hidden");
|
|
41
|
+
}, V = function() {
|
|
42
|
+
h !== void 0 && (document.body.style.paddingRight = h, h = void 0), g !== void 0 && (document.body.style.overflow = g, g = void 0);
|
|
43
|
+
}, q = function(e) {
|
|
258
44
|
return e ? e.scrollHeight - e.scrollTop <= e.clientHeight : !1;
|
|
259
|
-
},
|
|
260
|
-
var i = e.targetTouches[0].clientY -
|
|
261
|
-
return
|
|
262
|
-
},
|
|
45
|
+
}, H = function(e, o) {
|
|
46
|
+
var i = e.targetTouches[0].clientY - S;
|
|
47
|
+
return L(e.target) ? !1 : o && o.scrollTop === 0 && i > 0 || q(o) && i < 0 ? k(e) : (e.stopPropagation(), !0);
|
|
48
|
+
}, U = function(e, o) {
|
|
263
49
|
if (!e) {
|
|
264
50
|
console.error("disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.");
|
|
265
51
|
return;
|
|
266
52
|
}
|
|
267
|
-
if (!
|
|
268
|
-
return
|
|
53
|
+
if (!p.some(function(t) {
|
|
54
|
+
return t.targetElement === e;
|
|
269
55
|
})) {
|
|
270
56
|
var i = {
|
|
271
57
|
targetElement: e,
|
|
272
|
-
options:
|
|
58
|
+
options: o || {}
|
|
273
59
|
};
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
}, e.ontouchmove = function(
|
|
277
|
-
|
|
278
|
-
},
|
|
60
|
+
p = [].concat(W(p), [i]), B ? (e.ontouchstart = function(t) {
|
|
61
|
+
t.targetTouches.length === 1 && (S = t.targetTouches[0].clientY);
|
|
62
|
+
}, e.ontouchmove = function(t) {
|
|
63
|
+
t.targetTouches.length === 1 && H(t, e);
|
|
64
|
+
}, b || (document.addEventListener("touchmove", k, C ? { passive: !1 } : void 0), b = !0)) : Y(o);
|
|
279
65
|
}
|
|
280
|
-
},
|
|
66
|
+
}, K = function(e) {
|
|
281
67
|
if (!e) {
|
|
282
68
|
console.error("enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.");
|
|
283
69
|
return;
|
|
284
70
|
}
|
|
285
|
-
|
|
286
|
-
return
|
|
287
|
-
}),
|
|
71
|
+
p = p.filter(function(o) {
|
|
72
|
+
return o.targetElement !== e;
|
|
73
|
+
}), B ? (e.ontouchstart = null, e.ontouchmove = null, b && p.length === 0 && (document.removeEventListener("touchmove", k, C ? { passive: !1 } : void 0), b = !1)) : p.length || V();
|
|
288
74
|
};
|
|
289
|
-
const
|
|
290
|
-
`,
|
|
291
|
-
var
|
|
292
|
-
for (var
|
|
293
|
-
(
|
|
294
|
-
return i &&
|
|
75
|
+
const G = `dialog{position:absolute;left:0;right:0;width:-moz-fit-content;width:-webkit-fit-content;width:fit-content;height:-moz-fit-content;height:-webkit-fit-content;height:fit-content;margin:auto;border:solid;padding:1em;background:white;color:#000;display:block}dialog:not([open]){display:none}dialog+.backdrop{position:fixed;top:0;right:0;bottom:0;left:0;background:rgba(0,0,0,.1)}._dialog_overlay{position:fixed;top:0;right:0;bottom:0;left:0}dialog.fixed{position:fixed;top:50%;transform:translateY(-50%)}*,*:before,*:after{box-sizing:border-box}.c-modal{--modal-size-s: 450px;--modal-size-m: 600px;--modal-size-l: 1080px;--modal-border-radius: var(--dt-radius-rounded-d);--modal-font: var(--dt-font-interactive-m-family);--modal-bg-color: var(--dt-color-container-default);--modal-elevation: var(--dt-elevation-04);border-radius:var(--modal-border-radius);border:none;box-shadow:var(--modal-elevation);font-family:var(--modal-font);background-color:var(--modal-bg-color);padding:0;--modal-margin-none: var(--dt-spacing-none);--modal-margin-small: var(--dt-spacing-g);--modal-margin-large: var(--dt-spacing-j);--modal-margin-block: var(--modal-margin-small);--modal-block-size: fit-content;--modal-inline-size: 75%;--modal-max-block-size: calc(100vh - calc(var(--modal-margin-block) * 2));--modal-max-inline-size: var(--modal-size-m);block-size:var(--modal-block-size);inline-size:var(--modal-inline-size);max-block-size:var(--modal-max-block-size);max-inline-size:var(--modal-max-inline-size)}.c-modal:focus-visible{outline:none}@media (max-width: 767px){.c-modal pie-icon-button{--btn-dimension: 40px}}.c-modal[open]{display:flex;flex-direction:column}@media (min-width: 768px){.c-modal{--modal-margin-block: var(--modal-margin-large)}}.c-modal[size=small]{--modal-max-inline-size: var(--modal-size-s)}@media (min-width: 768px){.c-modal[size=small]{--modal-margin-block: var(--modal-margin-large)}}@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[position=top]{margin-block-start:var(--dt-spacing-j);max-block-size:calc(100% - var(--dt-spacing-j) * 2)}@media (max-width: 767px){.c-modal[position=top][size=large],.c-modal[position=top][isfullwidthbelowmid][size=medium]{margin-block-start:var(--dt-spacing-none);max-block-size:100%}}.c-modal::backdrop{background:rgba(0,0,0,.55)}.c-modal .c-modal-footer{--modal-button-spacing: var(--dt-spacing-d);--modal-footer-padding: var(--dt-spacing-d);display:flex;flex-flow:row-reverse;flex-wrap:wrap;gap:var(--modal-button-spacing);padding:var(--modal-footer-padding)}@media (min-width: 768px){.c-modal .c-modal-footer{--modal-footer-padding: var(--dt-spacing-e)}}@media (max-width: 767px){.c-modal[hasstackedactions] .c-modal-footer{flex-direction:column}}.c-modal .c-modal-header{display:grid;grid-template-areas:"back heading close";grid-template-columns:minmax(0,max-content) minmax(0,1fr) minmax(0,max-content);align-items:start}.c-modal .c-modal-heading{--modal-header-font-size: calc(var(--dt-font-heading-m-size--narrow) * 1px);--modal-header-font-line-height: calc(var(--dt-font-heading-m-line-height--narrow) * 1px);--modal-header-font-weight: var(--dt-font-heading-m-weight);font-size:var(--modal-header-font-size);line-height:var(--modal-header-font-line-height);font-weight:var(--modal-header-font-weight);margin:0;grid-area:heading;margin-inline:var(--dt-spacing-d);margin-block:14px}@media (min-width: 768px){.c-modal .c-modal-heading{--modal-header-font-size: calc(var(--dt-font-heading-m-size--wide) * 1px);--modal-header-font-line-height: calc(var(--dt-font-heading-m-line-height--wide) * 1px);margin-inline:var(--dt-spacing-e);margin-block:20px}}.c-modal[hasbackbutton] .c-modal-heading{margin-inline-start:var(--dt-spacing-b)}@media (min-width: 768px){.c-modal[hasbackbutton] .c-modal-heading{margin-inline-start:var(--dt-spacing-c)}}.c-modal[isdismissible] .c-modal-heading{margin-inline-end:var(--dt-spacing-d)}@media (min-width: 768px){.c-modal[isdismissible] .c-modal-heading{margin-inline-end:var(--dt-spacing-e)}}.c-modal .c-modal-backBtn{grid-area:back;margin-block:var(--dt-spacing-b);margin-inline:var(--dt-spacing-b) var(--dt-spacing-none)}@media (min-width: 768px){.c-modal .c-modal-backBtn{margin-block:var(--dt-spacing-c);margin-inline:var(--dt-spacing-c) var(--dt-spacing-none)}}.c-modal .c-modal-closeBtn{grid-area:close;margin-block:var(--dt-spacing-b);margin-inline:var(--dt-spacing-none) var(--dt-spacing-b)}@media (min-width: 768px){.c-modal .c-modal-closeBtn{margin-block:var(--dt-spacing-c);margin-inline:var(--dt-spacing-none) 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:var(--modal-content-padding-inline);padding-block: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;height:100%;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
|
+
`, X = ["h1", "h2", "h3", "h4", "h5", "h6"], J = ["small", "medium", "large"], Q = ["top", "center"], x = "pie-modal-close", v = "pie-modal-open", _ = "pie-modal-back", Z = "pie-modal-leading-action-click", ee = "pie-modal-supporting-action-click";
|
|
77
|
+
var oe = Object.defineProperty, ie = Object.getOwnPropertyDescriptor, l = (a, e, o, i) => {
|
|
78
|
+
for (var t = i > 1 ? void 0 : i ? ie(e, o) : e, s = a.length - 1, m; s >= 0; s--)
|
|
79
|
+
(m = a[s]) && (t = (i ? m(e, o, t) : m(t)) || t);
|
|
80
|
+
return i && t && oe(e, o, t), t;
|
|
295
81
|
};
|
|
296
|
-
const
|
|
297
|
-
class
|
|
82
|
+
const u = "pie-modal";
|
|
83
|
+
class n extends I(P) {
|
|
298
84
|
constructor() {
|
|
299
85
|
super(...arguments), this.headingLevel = "h2", this.hasBackButton = !1, this.hasStackedActions = !1, this.isDismissible = !1, this.isFooterPinned = !0, this.isFullWidthBelowMid = !1, this.isLoading = !1, this.isOpen = !1, this.position = "center", this.size = "medium", this._backButtonClicked = !1, this._handleDialogCancelEvent = (e) => {
|
|
300
86
|
this.isDismissible || e.preventDefault();
|
|
301
87
|
}, this._handleDialogLightDismiss = (e) => {
|
|
302
|
-
var
|
|
88
|
+
var f;
|
|
303
89
|
if (!this.isDismissible)
|
|
304
90
|
return;
|
|
305
|
-
const
|
|
91
|
+
const o = (f = this._dialog) == null ? void 0 : f.getBoundingClientRect(), {
|
|
306
92
|
top: i = 0,
|
|
307
|
-
bottom:
|
|
308
|
-
left:
|
|
309
|
-
right:
|
|
310
|
-
} =
|
|
311
|
-
if (i === 0 &&
|
|
93
|
+
bottom: t = 0,
|
|
94
|
+
left: s = 0,
|
|
95
|
+
right: m = 0
|
|
96
|
+
} = o || {};
|
|
97
|
+
if (i === 0 && t === 0 && s === 0 && m === 0)
|
|
312
98
|
return;
|
|
313
|
-
(e.clientY < i || e.clientY >
|
|
99
|
+
(e.clientY < i || e.clientY > t || e.clientX < s || e.clientX > m) && (this.isOpen = !1);
|
|
314
100
|
}, this._dispatchModalCustomEvent = (e) => {
|
|
315
|
-
const
|
|
101
|
+
const o = new CustomEvent(e, {
|
|
316
102
|
bubbles: !0,
|
|
317
103
|
composed: !0
|
|
318
104
|
});
|
|
319
|
-
this.dispatchEvent(
|
|
105
|
+
this.dispatchEvent(o);
|
|
320
106
|
};
|
|
321
107
|
}
|
|
322
108
|
connectedCallback() {
|
|
323
|
-
super.connectedCallback(), this.addEventListener("click", (e) => this._handleDialogLightDismiss(e)), document.addEventListener(
|
|
109
|
+
super.connectedCallback(), this.addEventListener("click", (e) => this._handleDialogLightDismiss(e)), document.addEventListener(v, this._handleModalOpened.bind(this)), document.addEventListener(x, this._handleModalClosed.bind(this)), document.addEventListener(_, this._handleModalClosed.bind(this));
|
|
324
110
|
}
|
|
325
111
|
disconnectedCallback() {
|
|
326
|
-
document.removeEventListener(
|
|
112
|
+
document.removeEventListener(v, this._handleModalOpened.bind(this)), document.removeEventListener(x, this._handleModalClosed.bind(this)), document.removeEventListener(_, this._handleModalClosed.bind(this)), super.disconnectedCallback();
|
|
327
113
|
}
|
|
328
114
|
async firstUpdated(e) {
|
|
329
115
|
super.firstUpdated(e), this._dialog && ((await import("./dialog-polyfill.esm-29edb142.js").then((i) => i.default)).registerDialog(this._dialog), this._dialog.addEventListener("cancel", (i) => this._handleDialogCancelEvent(i)), this._dialog.addEventListener("close", () => {
|
|
@@ -337,38 +123,38 @@ class s extends ie($) {
|
|
|
337
123
|
* Opens the dialog element and disables page scrolling
|
|
338
124
|
*/
|
|
339
125
|
_handleModalOpened() {
|
|
340
|
-
var
|
|
341
|
-
const e = (
|
|
342
|
-
e &&
|
|
126
|
+
var o, i, t, s;
|
|
127
|
+
const e = (o = this._dialog) == null ? void 0 : o.querySelector(".c-modal-scrollContainer");
|
|
128
|
+
e && U(e), !((i = this._dialog) != null && i.hasAttribute("open") || !((t = this._dialog) != null && t.isConnected)) && ((s = this._dialog) == null || s.showModal());
|
|
343
129
|
}
|
|
344
130
|
/**
|
|
345
131
|
* Closes the dialog element and re-enables page scrolling
|
|
346
132
|
*/
|
|
347
133
|
_handleModalClosed() {
|
|
348
|
-
var
|
|
349
|
-
const e = (
|
|
350
|
-
e &&
|
|
134
|
+
var o, i;
|
|
135
|
+
const e = (o = this._dialog) == null ? void 0 : o.querySelector(".c-modal-scrollContainer");
|
|
136
|
+
e && K(e), (i = this._dialog) == null || i.close(), this._returnFocus();
|
|
351
137
|
}
|
|
352
138
|
// Handles the value of the isOpen property on first render of the component
|
|
353
139
|
_handleModalOpenStateOnFirstRender(e) {
|
|
354
|
-
e.get("isOpen") === void 0 && this.isOpen && this._dispatchModalCustomEvent(
|
|
140
|
+
e.get("isOpen") === void 0 && this.isOpen && this._dispatchModalCustomEvent(v);
|
|
355
141
|
}
|
|
356
142
|
// Handles changes to the modal isOpen property by dispatching any appropriate events
|
|
357
143
|
_handleModalOpenStateChanged(e) {
|
|
358
|
-
const
|
|
359
|
-
|
|
144
|
+
const o = e.get("isOpen");
|
|
145
|
+
o !== void 0 && (o ? this._backButtonClicked ? (this._backButtonClicked = !1, this._dispatchModalCustomEvent(_)) : this._dispatchModalCustomEvent(x) : this._dispatchModalCustomEvent(v));
|
|
360
146
|
}
|
|
361
147
|
_handleActionClick(e) {
|
|
362
|
-
var
|
|
363
|
-
e === "leading" ? ((
|
|
148
|
+
var o, i;
|
|
149
|
+
e === "leading" ? ((o = this._dialog) == null || o.close("leading"), this._dispatchModalCustomEvent(Z)) : e === "supporting" && ((i = this._dialog) == null || i.close("supporting"), this._dispatchModalCustomEvent(ee));
|
|
364
150
|
}
|
|
365
151
|
/**
|
|
366
152
|
* Return focus to the specified element, providing the selector is valid
|
|
367
153
|
* and the chosen element can be found.
|
|
368
154
|
*/
|
|
369
155
|
_returnFocus() {
|
|
370
|
-
var
|
|
371
|
-
const e = (
|
|
156
|
+
var o, i;
|
|
157
|
+
const e = (o = this.returnFocusAfterCloseSelector) == null ? void 0 : o.trim();
|
|
372
158
|
e && ((i = document.querySelector(e)) == null || i.focus());
|
|
373
159
|
}
|
|
374
160
|
/**
|
|
@@ -379,14 +165,14 @@ class s extends ie($) {
|
|
|
379
165
|
*/
|
|
380
166
|
renderCloseButton() {
|
|
381
167
|
var e;
|
|
382
|
-
return
|
|
168
|
+
return c`
|
|
383
169
|
<pie-icon-button
|
|
384
170
|
@click="${() => {
|
|
385
171
|
this.isOpen = !1;
|
|
386
172
|
}}"
|
|
387
173
|
variant="ghost-secondary"
|
|
388
174
|
class="c-modal-closeBtn"
|
|
389
|
-
aria-label="${((e = this.aria) == null ? void 0 : e.close) ||
|
|
175
|
+
aria-label="${((e = this.aria) == null ? void 0 : e.close) || r}"
|
|
390
176
|
data-test-id="modal-close-button">
|
|
391
177
|
<icon-close></icon-close>
|
|
392
178
|
</pie-icon-button>`;
|
|
@@ -399,16 +185,16 @@ class s extends ie($) {
|
|
|
399
185
|
*/
|
|
400
186
|
renderBackButton() {
|
|
401
187
|
var e;
|
|
402
|
-
return
|
|
188
|
+
return c`
|
|
403
189
|
<pie-icon-button
|
|
404
190
|
@click="${() => {
|
|
405
191
|
this._backButtonClicked = !0, this.isOpen = !1;
|
|
406
192
|
}}"
|
|
407
193
|
variant="ghost-secondary"
|
|
408
194
|
class="c-modal-backBtn"
|
|
409
|
-
aria-label="${((e = this.aria) == null ? void 0 : e.back) ||
|
|
195
|
+
aria-label="${((e = this.aria) == null ? void 0 : e.back) || r}"
|
|
410
196
|
data-test-id="modal-back-button">
|
|
411
|
-
${this.isRTL ?
|
|
197
|
+
${this.isRTL ? c`<icon-chevron-right></icon-chevron-right>` : c`<icon-chevron-left></icon-chevron-left>`}
|
|
412
198
|
</pie-icon-button>
|
|
413
199
|
`;
|
|
414
200
|
}
|
|
@@ -422,18 +208,18 @@ class s extends ie($) {
|
|
|
422
208
|
* @private
|
|
423
209
|
*/
|
|
424
210
|
renderLeadingAction() {
|
|
425
|
-
const { text: e, variant:
|
|
426
|
-
return e ?
|
|
211
|
+
const { text: e, variant: o = "primary", ariaLabel: i } = this.leadingAction;
|
|
212
|
+
return e ? c`
|
|
427
213
|
<pie-button
|
|
428
|
-
variant="${
|
|
429
|
-
aria-label="${i ||
|
|
214
|
+
variant="${o}"
|
|
215
|
+
aria-label="${i || r}"
|
|
430
216
|
type="submit"
|
|
431
217
|
?isFullWidth="${this.hasStackedActions}"
|
|
432
218
|
@click="${() => this._handleActionClick("leading")}"
|
|
433
219
|
data-test-id="modal-leading-action">
|
|
434
220
|
${e}
|
|
435
221
|
</pie-button>
|
|
436
|
-
` :
|
|
222
|
+
` : r;
|
|
437
223
|
}
|
|
438
224
|
/**
|
|
439
225
|
* Render supportingAction button depending on prop availability.
|
|
@@ -447,76 +233,77 @@ class s extends ie($) {
|
|
|
447
233
|
* @private
|
|
448
234
|
*/
|
|
449
235
|
renderSupportingAction() {
|
|
450
|
-
const { text: e, variant:
|
|
451
|
-
return e ? this.leadingAction ?
|
|
236
|
+
const { text: e, variant: o = "ghost", ariaLabel: i } = this.supportingAction;
|
|
237
|
+
return e ? this.leadingAction ? c`
|
|
452
238
|
<pie-button
|
|
453
|
-
variant="${
|
|
454
|
-
aria-label="${i ||
|
|
239
|
+
variant="${o}"
|
|
240
|
+
aria-label="${i || r}"
|
|
455
241
|
type="reset"
|
|
456
242
|
?isFullWidth="${this.hasStackedActions}"
|
|
457
243
|
@click="${() => this._handleActionClick("supporting")}"
|
|
458
244
|
data-test-id="modal-supporting-action">
|
|
459
245
|
${e}
|
|
460
246
|
</pie-button>
|
|
461
|
-
` : (console.warn("Use `leadingAction` instead of `supportingAction`. `supportingAction` is being ignored."),
|
|
247
|
+
` : (console.warn("Use `leadingAction` instead of `supportingAction`. `supportingAction` is being ignored."), r) : r;
|
|
462
248
|
}
|
|
463
249
|
/**
|
|
464
250
|
* Renders the modal inner content and footer of the modal.
|
|
465
251
|
* @private
|
|
466
252
|
*/
|
|
467
253
|
renderModalContentAndFooter() {
|
|
468
|
-
return
|
|
254
|
+
return c`
|
|
469
255
|
<article class="c-modal-scrollContainer c-modal-content c-modal-content--scrollable">
|
|
470
256
|
<div class="c-modal-contentInner">
|
|
471
257
|
<slot></slot>
|
|
472
258
|
</div>
|
|
259
|
+
${this.isLoading ? c`<pie-spinner size="xl" variant="secondary"></pie-spinner>` : r}
|
|
473
260
|
</article>
|
|
474
261
|
<footer class="c-modal-footer">
|
|
475
|
-
${this.leadingAction ? this.renderLeadingAction() :
|
|
476
|
-
${this.supportingAction ? this.renderSupportingAction() :
|
|
262
|
+
${this.leadingAction ? this.renderLeadingAction() : r}
|
|
263
|
+
${this.supportingAction ? this.renderSupportingAction() : r}
|
|
477
264
|
</footer>`;
|
|
478
265
|
}
|
|
479
266
|
render() {
|
|
480
267
|
const {
|
|
481
268
|
aria: e,
|
|
482
|
-
hasBackButton:
|
|
269
|
+
hasBackButton: o,
|
|
483
270
|
hasStackedActions: i,
|
|
484
|
-
heading:
|
|
485
|
-
headingLevel:
|
|
486
|
-
isDismissible:
|
|
487
|
-
isFooterPinned:
|
|
488
|
-
isFullWidthBelowMid:
|
|
489
|
-
isLoading:
|
|
490
|
-
leadingAction:
|
|
491
|
-
position:
|
|
492
|
-
size:
|
|
493
|
-
supportingAction:
|
|
494
|
-
} = this,
|
|
495
|
-
return
|
|
271
|
+
heading: t,
|
|
272
|
+
headingLevel: s = "h2",
|
|
273
|
+
isDismissible: m,
|
|
274
|
+
isFooterPinned: w,
|
|
275
|
+
isFullWidthBelowMid: f,
|
|
276
|
+
isLoading: y,
|
|
277
|
+
leadingAction: M,
|
|
278
|
+
position: $,
|
|
279
|
+
size: E,
|
|
280
|
+
supportingAction: D
|
|
281
|
+
} = this, O = F(s);
|
|
282
|
+
return c`
|
|
496
283
|
<dialog
|
|
497
284
|
id="dialog"
|
|
498
285
|
class="c-modal"
|
|
499
|
-
size="${
|
|
500
|
-
position="${
|
|
501
|
-
?hasActions=${
|
|
502
|
-
?hasBackButton=${
|
|
286
|
+
size="${E}"
|
|
287
|
+
position="${$}"
|
|
288
|
+
?hasActions=${M || D}
|
|
289
|
+
?hasBackButton=${o}
|
|
503
290
|
?hasStackedActions=${i}
|
|
504
|
-
?isDismissible=${
|
|
505
|
-
?isFooterPinned=${
|
|
506
|
-
?isFullWidthBelowMid=${
|
|
507
|
-
?isLoading=${
|
|
508
|
-
aria-busy="${
|
|
509
|
-
aria-label="${
|
|
291
|
+
?isDismissible=${m}
|
|
292
|
+
?isFooterPinned=${w}
|
|
293
|
+
?isFullWidthBelowMid=${f}
|
|
294
|
+
?isLoading=${y}
|
|
295
|
+
aria-busy="${y ? "true" : "false"}"
|
|
296
|
+
aria-label="${y && (e == null ? void 0 : e.loading) || r}"
|
|
510
297
|
data-test-id="pie-modal">
|
|
511
298
|
<header class="c-modal-header">
|
|
512
|
-
${
|
|
513
|
-
<${
|
|
514
|
-
${
|
|
515
|
-
</${
|
|
516
|
-
${
|
|
299
|
+
${o ? this.renderBackButton() : r}
|
|
300
|
+
<${O} class="c-modal-heading">
|
|
301
|
+
${t}
|
|
302
|
+
</${O}>
|
|
303
|
+
${m ? this.renderCloseButton() : r}
|
|
517
304
|
</header>
|
|
518
305
|
${// We need to wrap the remaining content in a shared scrollable container if the footer is not pinned
|
|
519
|
-
|
|
306
|
+
w ? this.renderModalContentAndFooter() : c`
|
|
520
307
|
<div class="c-modal-scrollContainer">
|
|
521
308
|
${this.renderModalContentAndFooter()}
|
|
522
309
|
</div>
|
|
@@ -524,68 +311,68 @@ class s extends ie($) {
|
|
|
524
311
|
</dialog>`;
|
|
525
312
|
}
|
|
526
313
|
}
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
],
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
],
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
],
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
],
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
],
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
],
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
],
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
],
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
],
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
],
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
],
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
],
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
],
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
],
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
],
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
],
|
|
580
|
-
|
|
314
|
+
n.styles = T(G);
|
|
315
|
+
l([
|
|
316
|
+
d({ type: Object })
|
|
317
|
+
], n.prototype, "aria", 2);
|
|
318
|
+
l([
|
|
319
|
+
d({ type: String }),
|
|
320
|
+
R(u)
|
|
321
|
+
], n.prototype, "heading", 2);
|
|
322
|
+
l([
|
|
323
|
+
d(),
|
|
324
|
+
z(u, X, "h2")
|
|
325
|
+
], n.prototype, "headingLevel", 2);
|
|
326
|
+
l([
|
|
327
|
+
d({ type: Boolean })
|
|
328
|
+
], n.prototype, "hasBackButton", 2);
|
|
329
|
+
l([
|
|
330
|
+
d({ type: Boolean })
|
|
331
|
+
], n.prototype, "hasStackedActions", 2);
|
|
332
|
+
l([
|
|
333
|
+
d({ type: Boolean, reflect: !0 })
|
|
334
|
+
], n.prototype, "isDismissible", 2);
|
|
335
|
+
l([
|
|
336
|
+
d({ type: Boolean })
|
|
337
|
+
], n.prototype, "isFooterPinned", 2);
|
|
338
|
+
l([
|
|
339
|
+
d({ type: Boolean })
|
|
340
|
+
], n.prototype, "isFullWidthBelowMid", 2);
|
|
341
|
+
l([
|
|
342
|
+
d({ type: Boolean, reflect: !0 })
|
|
343
|
+
], n.prototype, "isLoading", 2);
|
|
344
|
+
l([
|
|
345
|
+
d({ type: Boolean })
|
|
346
|
+
], n.prototype, "isOpen", 2);
|
|
347
|
+
l([
|
|
348
|
+
d({ type: Object })
|
|
349
|
+
], n.prototype, "leadingAction", 2);
|
|
350
|
+
l([
|
|
351
|
+
d(),
|
|
352
|
+
z(u, Q, "center")
|
|
353
|
+
], n.prototype, "position", 2);
|
|
354
|
+
l([
|
|
355
|
+
d()
|
|
356
|
+
], n.prototype, "returnFocusAfterCloseSelector", 2);
|
|
357
|
+
l([
|
|
358
|
+
d(),
|
|
359
|
+
z(u, J, "medium")
|
|
360
|
+
], n.prototype, "size", 2);
|
|
361
|
+
l([
|
|
362
|
+
d({ type: Object })
|
|
363
|
+
], n.prototype, "supportingAction", 2);
|
|
364
|
+
l([
|
|
365
|
+
N("dialog")
|
|
366
|
+
], n.prototype, "_dialog", 2);
|
|
367
|
+
j(u, n);
|
|
581
368
|
export {
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
369
|
+
_ as ON_MODAL_BACK_EVENT,
|
|
370
|
+
x as ON_MODAL_CLOSE_EVENT,
|
|
371
|
+
Z as ON_MODAL_LEADING_ACTION_CLICK,
|
|
372
|
+
v as ON_MODAL_OPEN_EVENT,
|
|
373
|
+
ee as ON_MODAL_SUPPORTING_ACTION_CLICK,
|
|
374
|
+
n as PieModal,
|
|
375
|
+
X as headingLevels,
|
|
376
|
+
Q as positions,
|
|
377
|
+
J as sizes
|
|
591
378
|
};
|
package/dist/react.js
CHANGED
|
@@ -1,67 +1,75 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { PieModal as
|
|
3
|
-
import { ON_MODAL_BACK_EVENT as
|
|
1
|
+
import * as f from "react";
|
|
2
|
+
import { PieModal as E } from "./index.js";
|
|
3
|
+
import { ON_MODAL_BACK_EVENT as $, ON_MODAL_CLOSE_EVENT as j, ON_MODAL_LEADING_ACTION_CLICK as B, ON_MODAL_OPEN_EVENT as H, ON_MODAL_SUPPORTING_ACTION_CLICK as U, headingLevels as W, positions as z, sizes as q } from "./index.js";
|
|
4
4
|
import "lit";
|
|
5
5
|
import "lit/static-html.js";
|
|
6
6
|
import "lit/decorators.js";
|
|
7
|
+
import "@justeattakeaway/pie-button";
|
|
8
|
+
import "@justeattakeaway/pie-icon-button";
|
|
9
|
+
import "@justeattakeaway/pie-webc-core";
|
|
10
|
+
import "@justeattakeaway/pie-icons-webc/IconClose";
|
|
11
|
+
import "@justeattakeaway/pie-icons-webc/IconChevronLeft";
|
|
12
|
+
import "@justeattakeaway/pie-icons-webc/IconChevronRight";
|
|
13
|
+
import "@justeattakeaway/pie-spinner";
|
|
7
14
|
/**
|
|
8
15
|
* @license
|
|
9
16
|
* Copyright 2018 Google LLC
|
|
10
17
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
11
18
|
*/
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
let l =
|
|
16
|
-
l === void 0 &&
|
|
17
|
-
let
|
|
18
|
-
|
|
19
|
-
})(
|
|
19
|
+
const C = /* @__PURE__ */ new Set(["children", "localName", "ref", "style", "className"]), O = /* @__PURE__ */ new WeakMap(), L = (o, t, d, c, m) => {
|
|
20
|
+
const s = m == null ? void 0 : m[t];
|
|
21
|
+
s === void 0 || d === c ? d == null && t in HTMLElement.prototype ? o.removeAttribute(t) : o[t] = d : ((a, i, h) => {
|
|
22
|
+
let l = O.get(a);
|
|
23
|
+
l === void 0 && O.set(a, l = /* @__PURE__ */ new Map());
|
|
24
|
+
let r = l.get(i);
|
|
25
|
+
h !== void 0 ? r === void 0 ? (l.set(i, r = { handleEvent: h }), a.addEventListener(i, r)) : r.handleEvent = h : r !== void 0 && (l.delete(i), a.removeEventListener(i, r));
|
|
26
|
+
})(o, s, d);
|
|
27
|
+
}, A = (o, t) => {
|
|
28
|
+
typeof o == "function" ? o(t) : o.current = t;
|
|
20
29
|
};
|
|
21
|
-
function
|
|
22
|
-
let
|
|
23
|
-
if (
|
|
24
|
-
const
|
|
25
|
-
({ tagName:
|
|
30
|
+
function y(o = window.React, t, d, c, m) {
|
|
31
|
+
let s, a, i;
|
|
32
|
+
if (t === void 0) {
|
|
33
|
+
const p = o;
|
|
34
|
+
({ tagName: a, elementClass: i, events: c, displayName: m } = p), s = p.react;
|
|
26
35
|
} else
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
class v extends
|
|
36
|
+
s = o, i = d, a = t;
|
|
37
|
+
const h = s.Component, l = s.createElement, r = new Set(Object.keys(c ?? {}));
|
|
38
|
+
class v extends h {
|
|
30
39
|
constructor() {
|
|
31
40
|
super(...arguments), this.o = null;
|
|
32
41
|
}
|
|
33
42
|
t(e) {
|
|
34
43
|
if (this.o !== null)
|
|
35
|
-
for (const
|
|
36
|
-
|
|
44
|
+
for (const u in this.i)
|
|
45
|
+
L(this.o, u, this.props[u], e ? e[u] : void 0, c);
|
|
37
46
|
}
|
|
38
47
|
componentDidMount() {
|
|
39
|
-
|
|
48
|
+
var e;
|
|
49
|
+
this.t(), (e = this.o) === null || e === void 0 || e.removeAttribute("defer-hydration");
|
|
40
50
|
}
|
|
41
51
|
componentDidUpdate(e) {
|
|
42
52
|
this.t(e);
|
|
43
53
|
}
|
|
44
54
|
render() {
|
|
45
|
-
const { _$Gl: e, ...
|
|
46
|
-
this.h !== e && (this.u = (
|
|
47
|
-
e !== null && (
|
|
48
|
-
typeof r == "function" ? r(O) : r.current = O;
|
|
49
|
-
})(e, o), this.o = o, this.h = e;
|
|
55
|
+
const { _$Gl: e, ...u } = this.props;
|
|
56
|
+
this.h !== e && (this.u = (n) => {
|
|
57
|
+
e !== null && A(e, n), this.o = n, this.h = e;
|
|
50
58
|
}), this.i = {};
|
|
51
|
-
const
|
|
52
|
-
for (const [
|
|
53
|
-
|
|
54
|
-
return l(
|
|
59
|
+
const N = { ref: this.u };
|
|
60
|
+
for (const [n, _] of Object.entries(u))
|
|
61
|
+
C.has(n) ? N[n === "className" ? "class" : n] = _ : r.has(n) || n in i.prototype ? this.i[n] = _ : N[n] = _;
|
|
62
|
+
return N.suppressHydrationWarning = !0, l(a, N);
|
|
55
63
|
}
|
|
56
64
|
}
|
|
57
|
-
v.displayName =
|
|
58
|
-
const M =
|
|
65
|
+
v.displayName = m ?? i.name;
|
|
66
|
+
const M = s.forwardRef((p, e) => l(v, { ...p, _$Gl: e }, p == null ? void 0 : p.children));
|
|
59
67
|
return M.displayName = v.displayName, M;
|
|
60
68
|
}
|
|
61
|
-
const
|
|
69
|
+
const x = y({
|
|
62
70
|
displayName: "PieModal",
|
|
63
|
-
elementClass:
|
|
64
|
-
react:
|
|
71
|
+
elementClass: E,
|
|
72
|
+
react: f,
|
|
65
73
|
tagName: "pie-modal",
|
|
66
74
|
events: {
|
|
67
75
|
onPieModalOpen: "pie-modal-open",
|
|
@@ -77,13 +85,13 @@ const w = P({
|
|
|
77
85
|
}
|
|
78
86
|
});
|
|
79
87
|
export {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
88
|
+
$ as ON_MODAL_BACK_EVENT,
|
|
89
|
+
j as ON_MODAL_CLOSE_EVENT,
|
|
90
|
+
B as ON_MODAL_LEADING_ACTION_CLICK,
|
|
91
|
+
H as ON_MODAL_OPEN_EVENT,
|
|
92
|
+
U as ON_MODAL_SUPPORTING_ACTION_CLICK,
|
|
93
|
+
x as PieModal,
|
|
94
|
+
W as headingLevels,
|
|
95
|
+
z as positions,
|
|
96
|
+
q as sizes
|
|
89
97
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justeattakeaway/pie-modal",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.32.0",
|
|
4
4
|
"description": "PIE design system modal built using web components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -28,12 +28,8 @@
|
|
|
28
28
|
"author": "Just Eat Takeaway.com - Design System Team",
|
|
29
29
|
"license": "Apache-2.0",
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@justeat/pie-design-tokens": "5.
|
|
32
|
-
"@justeattakeaway/pie-button": "0.35.0",
|
|
31
|
+
"@justeat/pie-design-tokens": "5.9.0",
|
|
33
32
|
"@justeattakeaway/pie-components-config": "0.4.0",
|
|
34
|
-
"@justeattakeaway/pie-icon-button": "0.19.0",
|
|
35
|
-
"@justeattakeaway/pie-icons-webc": "0.11.1",
|
|
36
|
-
"@justeattakeaway/pie-webc-core": "0.11.0",
|
|
37
33
|
"@types/body-scroll-lock": "3.1.1"
|
|
38
34
|
},
|
|
39
35
|
"peerDependencies": {
|
|
@@ -43,6 +39,11 @@
|
|
|
43
39
|
"extends": "../../../package.json"
|
|
44
40
|
},
|
|
45
41
|
"dependencies": {
|
|
42
|
+
"@justeattakeaway/pie-button": "0.37.0",
|
|
43
|
+
"@justeattakeaway/pie-icon-button": "0.21.1",
|
|
44
|
+
"@justeattakeaway/pie-icons-webc": "0.11.1",
|
|
45
|
+
"@justeattakeaway/pie-spinner": "0.2.1",
|
|
46
|
+
"@justeattakeaway/pie-webc-core": "0.11.0",
|
|
46
47
|
"dialog-polyfill": "0.5.6"
|
|
47
48
|
},
|
|
48
49
|
"sideEffects": [
|
package/src/index.ts
CHANGED
|
@@ -3,13 +3,17 @@ import {
|
|
|
3
3
|
} from 'lit';
|
|
4
4
|
import { html, unsafeStatic } from 'lit/static-html.js';
|
|
5
5
|
import { property, query } from 'lit/decorators.js';
|
|
6
|
+
import { disableBodyScroll, enableBodyScroll } from 'body-scroll-lock';
|
|
7
|
+
|
|
8
|
+
import '@justeattakeaway/pie-button';
|
|
9
|
+
import '@justeattakeaway/pie-icon-button';
|
|
6
10
|
import {
|
|
7
11
|
requiredProperty, RtlMixin, validPropertyValues, defineCustomElement,
|
|
8
12
|
} from '@justeattakeaway/pie-webc-core';
|
|
9
13
|
import '@justeattakeaway/pie-icons-webc/IconClose';
|
|
10
14
|
import '@justeattakeaway/pie-icons-webc/IconChevronLeft';
|
|
11
15
|
import '@justeattakeaway/pie-icons-webc/IconChevronRight';
|
|
12
|
-
import
|
|
16
|
+
import '@justeattakeaway/pie-spinner';
|
|
13
17
|
|
|
14
18
|
import styles from './modal.scss?inline';
|
|
15
19
|
import {
|
|
@@ -339,6 +343,7 @@ export class PieModal extends RtlMixin(LitElement) implements ModalProps {
|
|
|
339
343
|
<div class="c-modal-contentInner">
|
|
340
344
|
<slot></slot>
|
|
341
345
|
</div>
|
|
346
|
+
${this.isLoading ? html`<pie-spinner size="xl" variant="secondary"></pie-spinner>` : nothing}
|
|
342
347
|
</article>
|
|
343
348
|
<footer class="c-modal-footer">
|
|
344
349
|
${this.leadingAction ? this.renderLeadingAction() : nothing}
|
package/src/modal.scss
CHANGED
|
@@ -8,17 +8,6 @@
|
|
|
8
8
|
box-sizing: border-box;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
// Spin animation for loading state
|
|
12
|
-
@keyframes rotate360 {
|
|
13
|
-
from {
|
|
14
|
-
transform: rotate(0deg);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
to {
|
|
18
|
-
transform: rotate(360deg);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
11
|
.c-modal {
|
|
23
12
|
// Custom Property Declarations
|
|
24
13
|
// These are defined here instead of :host to encapsulate them inside Shadow DOM
|
|
@@ -245,23 +234,6 @@
|
|
|
245
234
|
--modal-content-padding-inline: var(--dt-spacing-e);
|
|
246
235
|
}
|
|
247
236
|
|
|
248
|
-
// Spinner sizes defaults
|
|
249
|
-
--spinner-size: 48px;
|
|
250
|
-
--spinner-border-width: 6px;
|
|
251
|
-
|
|
252
|
-
// Spinner colors - currently set for the primary button styles
|
|
253
|
-
--spinner-base-color-h: var(--dt-color-content-interactive-secondary-h);
|
|
254
|
-
--spinner-base-color-s: var(--dt-color-content-interactive-secondary-s);
|
|
255
|
-
--spinner-base-color-l: var(--dt-color-content-interactive-secondary-l);
|
|
256
|
-
--spinner-left-color-opacity: 0.35;
|
|
257
|
-
--spinner-left-color: hsl(var(--spinner-base-color-h), var(--spinner-base-color-s), var(--spinner-base-color-l), var(--spinner-left-color-opacity));
|
|
258
|
-
--spinner-right-color: hsl(var(--spinner-base-color-h), var(--spinner-base-color-s), var(--spinner-base-color-l), 1);
|
|
259
|
-
|
|
260
|
-
// Spinner animations
|
|
261
|
-
--spinner-animation-duration: 1.15s;
|
|
262
|
-
--spinner-animation-timing-function: linear;
|
|
263
|
-
--spinner-animation-iteration-count: infinite;
|
|
264
|
-
|
|
265
237
|
position: relative;
|
|
266
238
|
min-block-size: var(--dt-spacing-j);
|
|
267
239
|
|
|
@@ -289,27 +261,6 @@
|
|
|
289
261
|
// The shadow itself does not move as you scroll.
|
|
290
262
|
background-attachment: local, scroll;
|
|
291
263
|
}
|
|
292
|
-
|
|
293
|
-
&:before {
|
|
294
|
-
content: '';
|
|
295
|
-
|
|
296
|
-
// Centre the spinner over the top of the button text
|
|
297
|
-
position: absolute;
|
|
298
|
-
left: 50%;
|
|
299
|
-
top: 50%;
|
|
300
|
-
translate: -50% -50%;
|
|
301
|
-
|
|
302
|
-
height: var(--spinner-size);
|
|
303
|
-
width: var(--spinner-size);
|
|
304
|
-
display: block;
|
|
305
|
-
background-color: transparent;
|
|
306
|
-
border-radius: 50%;
|
|
307
|
-
border-color: var(--spinner-left-color) var(--spinner-right-color) var(--spinner-right-color) var(--spinner-left-color);
|
|
308
|
-
border-width: var(--spinner-border-width);
|
|
309
|
-
border-style: solid;
|
|
310
|
-
will-change: transform;
|
|
311
|
-
opacity: 0;
|
|
312
|
-
}
|
|
313
264
|
}
|
|
314
265
|
|
|
315
266
|
& > .c-modal-scrollContainer {
|
|
@@ -342,13 +293,15 @@
|
|
|
342
293
|
}
|
|
343
294
|
|
|
344
295
|
&[isLoading] .c-modal-content {
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
296
|
+
pie-spinner {
|
|
297
|
+
position: absolute;
|
|
298
|
+
left: 50%;
|
|
299
|
+
top: 50%;
|
|
300
|
+
transform: translate(-50%, -50%);
|
|
348
301
|
}
|
|
349
302
|
|
|
350
303
|
& .c-modal-contentInner {
|
|
351
|
-
|
|
304
|
+
display: none;
|
|
352
305
|
}
|
|
353
306
|
}
|
|
354
307
|
|