@justeattakeaway/pie-modal 0.4.0 → 0.5.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 +10 -10
- package/CHANGELOG.md +6 -0
- package/dist/index.js +60 -60
- package/dist/types/packages/components/pie-modal/src/defs.d.ts +4 -8
- 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 +5 -4
- package/dist/types/packages/components/pie-modal/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/defs.ts +5 -8
- package/src/index.ts +5 -5
- package/test/component/pie-modal.spec.ts +5 -5
- package/test/visual/pie-modal.spec.ts +2 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
[
|
|
1
|
+
[3:48:32 PM] @custom-elements-manifest/analyzer: Created new manifest.
|
|
2
2
|
react wrapper has been added!
|
|
3
|
-
|
|
3
|
+
[36mvite v4.2.3 [32mbuilding for production...[36m[39m
|
|
4
4
|
transforming...
|
|
5
|
-
|
|
5
|
+
[32m✓[39m 28 modules transformed.
|
|
6
6
|
rendering chunks...
|
|
7
7
|
computing gzip size...
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
[vite:dts] Start generate declaration files
|
|
12
|
-
|
|
13
|
-
[vite:dts] Declaration files built in
|
|
14
|
-
|
|
8
|
+
[2mdist/[22m[36mindex.js [39m[1m[2m 5.83 kB[22m[1m[22m[2m │ gzip: 2.00 kB[22m
|
|
9
|
+
[2mdist/[22m[36mreact.js [39m[1m[2m59.15 kB[22m[1m[22m[2m │ gzip: 15.94 kB[22m
|
|
10
|
+
[32m
|
|
11
|
+
[36m[vite:dts][32m Start generate declaration files...[39m
|
|
12
|
+
[32m✓[39m built in 30.45s
|
|
13
|
+
[32m[36m[vite:dts][32m Declaration files built in 28192ms.
|
|
14
|
+
[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @justeattakeaway/pie-modal
|
|
2
2
|
|
|
3
|
+
## 0.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [Updated] - enum types to string union types to string union types ([#508](https://github.com/justeattakeaway/pie/pull/508)) by [@FayeCarter](https://github.com/FayeCarter)
|
|
8
|
+
|
|
3
9
|
## 0.4.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { unsafeCSS as
|
|
2
|
-
import { unsafeStatic as
|
|
1
|
+
import { unsafeCSS as h, LitElement as v, html as g } from "lit";
|
|
2
|
+
import { unsafeStatic as u, html as b } from "lit/static-html.js";
|
|
3
3
|
import { property as d } from "lit/decorators.js";
|
|
4
|
-
import { property as
|
|
5
|
-
var
|
|
6
|
-
for (var e = t > 1 ? void 0 : t ?
|
|
7
|
-
(i =
|
|
8
|
-
return t && e &&
|
|
4
|
+
import { property as $ } from "lit/decorators/property.js";
|
|
5
|
+
var y = Object.defineProperty, w = Object.getOwnPropertyDescriptor, P = (s, r, n, t) => {
|
|
6
|
+
for (var e = t > 1 ? void 0 : t ? w(r, n) : r, o = s.length - 1, i; o >= 0; o--)
|
|
7
|
+
(i = s[o]) && (e = (t ? i(r, n, e) : i(e)) || e);
|
|
8
|
+
return t && e && y(r, n, e), e;
|
|
9
9
|
};
|
|
10
|
-
const _ = (
|
|
11
|
-
class r extends
|
|
10
|
+
const _ = (s) => {
|
|
11
|
+
class r extends s {
|
|
12
12
|
constructor() {
|
|
13
13
|
super(...arguments), this.dir = "";
|
|
14
14
|
}
|
|
@@ -26,43 +26,43 @@ const _ = (n) => {
|
|
|
26
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
|
-
|
|
29
|
+
return P([
|
|
30
|
+
$({ type: String })
|
|
31
31
|
], r.prototype, "dir", 2), r;
|
|
32
|
-
},
|
|
33
|
-
const
|
|
32
|
+
}, O = (s, r, n) => function(t, e) {
|
|
33
|
+
const o = `#${e}`;
|
|
34
34
|
Object.defineProperty(t, e, {
|
|
35
35
|
get() {
|
|
36
|
-
return this[
|
|
36
|
+
return this[o];
|
|
37
37
|
},
|
|
38
38
|
set(i) {
|
|
39
|
-
const
|
|
40
|
-
r.includes(i) ? this[
|
|
41
|
-
`<${
|
|
39
|
+
const m = this[o];
|
|
40
|
+
r.includes(i) ? this[o] = i : (console.error(
|
|
41
|
+
`<${s}> Invalid value "${i}" provided for property "${e}".`,
|
|
42
42
|
`Must be one of: ${r.join(" | ")}.`,
|
|
43
|
-
`Falling back to default value: "${
|
|
44
|
-
), this[
|
|
43
|
+
`Falling back to default value: "${n}"`
|
|
44
|
+
), this[o] = n), this.requestUpdate(e, m);
|
|
45
45
|
}
|
|
46
46
|
});
|
|
47
|
-
},
|
|
48
|
-
const t = `#${
|
|
49
|
-
Object.defineProperty(r,
|
|
47
|
+
}, x = (s) => function(r, n) {
|
|
48
|
+
const t = `#${n}`;
|
|
49
|
+
Object.defineProperty(r, n, {
|
|
50
50
|
get() {
|
|
51
51
|
return this[t];
|
|
52
52
|
},
|
|
53
53
|
set(e) {
|
|
54
|
-
const
|
|
55
|
-
(e == null || e === "") && console.error(`<${
|
|
54
|
+
const o = this[t];
|
|
55
|
+
(e == null || e === "") && console.error(`<${s}> Missing required attribute "${n}"`), this[t] = e, this.requestUpdate(n, o);
|
|
56
56
|
}
|
|
57
57
|
});
|
|
58
|
-
},
|
|
58
|
+
}, C = `.c-webComponentTestWrapper{padding-block:var(--dt-spacing-c);padding-inline:var(--dt-spacing-e);font-family:var(--dt-font-interactive-m-family);font-size:calc(var(--dt-font-size-20) * 1px);border:1px solid var(--dt-color-background-dark);display:grid;grid-template-columns:1fr 1fr}.c-webComponentTestWrapper-label{margin-block:var(--dt-spacing-c)}.c-webComponentTestWrapper-slot{padding:var(--dt-spacing-c);border:1px dashed var(--dt-color-background-dark);grid-column:1/3;margin-block-start:var(--dt-spacing-c)}
|
|
59
59
|
`;
|
|
60
|
-
var T = Object.defineProperty, W = Object.getOwnPropertyDescriptor,
|
|
61
|
-
for (var e = t > 1 ? void 0 : t ? W(r,
|
|
62
|
-
(i =
|
|
63
|
-
return t && e && T(r,
|
|
60
|
+
var T = Object.defineProperty, W = Object.getOwnPropertyDescriptor, j = (s, r, n, t) => {
|
|
61
|
+
for (var e = t > 1 ? void 0 : t ? W(r, n) : r, o = s.length - 1, i; o >= 0; o--)
|
|
62
|
+
(i = s[o]) && (e = (t ? i(r, n, e) : i(e)) || e);
|
|
63
|
+
return t && e && T(r, n, e), e;
|
|
64
64
|
};
|
|
65
|
-
class
|
|
65
|
+
class p extends v {
|
|
66
66
|
constructor() {
|
|
67
67
|
super(...arguments), this.propKeyValues = "";
|
|
68
68
|
}
|
|
@@ -72,13 +72,13 @@ class l extends u {
|
|
|
72
72
|
// <p class="c-webComponentTestWrapper-label"><b>isFullWidth</b>: <code>true</code></p>
|
|
73
73
|
_renderPropKeyValues() {
|
|
74
74
|
return this.propKeyValues.split(",").map((r) => {
|
|
75
|
-
const [
|
|
76
|
-
return
|
|
75
|
+
const [n, t] = r.split(":");
|
|
76
|
+
return g`<p class="c-webComponentTestWrapper-label"><b>${n}</b>: <code>${t}</code></p>`;
|
|
77
77
|
});
|
|
78
78
|
}
|
|
79
79
|
// eslint-disable-next-line class-methods-use-this
|
|
80
80
|
render() {
|
|
81
|
-
return
|
|
81
|
+
return g`
|
|
82
82
|
<div class="c-webComponentTestWrapper">
|
|
83
83
|
${this._renderPropKeyValues()}
|
|
84
84
|
<div class="c-webComponentTestWrapper-slot">
|
|
@@ -87,33 +87,33 @@ class l extends u {
|
|
|
87
87
|
</div>`;
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
p.styles = h(C);
|
|
91
|
+
j([
|
|
92
92
|
d({ type: String })
|
|
93
|
-
],
|
|
94
|
-
const
|
|
95
|
-
customElements.get(
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
var
|
|
99
|
-
for (var e = t > 1 ? void 0 : t ?
|
|
100
|
-
(i =
|
|
101
|
-
return t && e &&
|
|
93
|
+
], p.prototype, "propKeyValues", 2);
|
|
94
|
+
const f = "web-component-test-wrapper";
|
|
95
|
+
customElements.get(f) || customElements.define(f, p);
|
|
96
|
+
const S = `.c-modal{border-radius:var(--dt-radius-rounded-d);border:none;font-family:var(--dt-font-interactive-m-family);background-color:var(--dt-color-container-default);padding:0;inline-size:600px;box-shadow:var(--dt-elevation-04)}.c-modal .c-modal-heading{font-size:calc(var(--dt-font-heading-m-size--wide) * 1px);line-height:calc(var(--dt-font-heading-m-line-height--wide) * 1px);font-weight:var(--dt-font-heading-m-weight);margin:0;padding-block:var(--dt-spacing-e) var(--dt-spacing-d);padding-inline:var(--dt-spacing-e)}.c-modal .c-modal-contentWrapper{font-size:calc(var(--dt-font-size-16) * 1px);line-height:calc(var(--dt-font-size-16-line-height) * 1px);font-weight:var(--dt-font-weight-regular);padding-block:var(--dt-spacing-a) var(--dt-spacing-e);padding-inline:var(--dt-spacing-e)}
|
|
97
|
+
`, z = ["h1", "h2", "h3", "h4", "h5", "h6"];
|
|
98
|
+
var L = Object.defineProperty, D = Object.getOwnPropertyDescriptor, l = (s, r, n, t) => {
|
|
99
|
+
for (var e = t > 1 ? void 0 : t ? D(r, n) : r, o = s.length - 1, i; o >= 0; o--)
|
|
100
|
+
(i = s[o]) && (e = (t ? i(r, n, e) : i(e)) || e);
|
|
101
|
+
return t && e && L(r, n, e), e;
|
|
102
102
|
};
|
|
103
|
-
const
|
|
104
|
-
class a extends _(
|
|
103
|
+
const c = "pie-modal";
|
|
104
|
+
class a extends _(v) {
|
|
105
105
|
constructor() {
|
|
106
|
-
super(...arguments), this.isOpen = !1, this.headingLevel =
|
|
106
|
+
super(...arguments), this.isOpen = !1, this.headingLevel = "h2";
|
|
107
107
|
}
|
|
108
108
|
render() {
|
|
109
109
|
const {
|
|
110
110
|
isOpen: r,
|
|
111
|
-
heading:
|
|
111
|
+
heading: n,
|
|
112
112
|
headingLevel: t
|
|
113
|
-
} = this, e =
|
|
114
|
-
return
|
|
113
|
+
} = this, e = u(t);
|
|
114
|
+
return b`
|
|
115
115
|
<dialog class="c-modal" ?open="${r}">
|
|
116
|
-
<${e} class="c-modal-heading">${
|
|
116
|
+
<${e} class="c-modal-heading">${n}</${e}>
|
|
117
117
|
<div class="c-modal-contentWrapper">
|
|
118
118
|
<slot></slot>
|
|
119
119
|
</div>
|
|
@@ -121,20 +121,20 @@ class a extends _(u) {
|
|
|
121
121
|
`;
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
|
-
a.styles =
|
|
125
|
-
|
|
124
|
+
a.styles = h(S);
|
|
125
|
+
l([
|
|
126
126
|
d({ type: Boolean })
|
|
127
127
|
], a.prototype, "isOpen", 2);
|
|
128
|
-
|
|
128
|
+
l([
|
|
129
129
|
d({ type: String }),
|
|
130
|
-
|
|
130
|
+
x(c)
|
|
131
131
|
], a.prototype, "heading", 2);
|
|
132
|
-
|
|
132
|
+
l([
|
|
133
133
|
d(),
|
|
134
|
-
|
|
134
|
+
O(c, z, "h2")
|
|
135
135
|
], a.prototype, "headingLevel", 2);
|
|
136
|
-
customElements.define(
|
|
136
|
+
customElements.define(c, a);
|
|
137
137
|
export {
|
|
138
|
-
|
|
139
|
-
|
|
138
|
+
a as PieModal,
|
|
139
|
+
z as headingLevels
|
|
140
140
|
};
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
+
export interface ModalProps {
|
|
2
|
+
headingLevel: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
3
|
+
}
|
|
1
4
|
/**
|
|
2
5
|
* Modal heading levels/tags
|
|
3
6
|
*/
|
|
4
|
-
export declare
|
|
5
|
-
H1 = "h1",
|
|
6
|
-
H2 = "h2",
|
|
7
|
-
H3 = "h3",
|
|
8
|
-
H4 = "h4",
|
|
9
|
-
H5 = "h5",
|
|
10
|
-
H6 = "h6"
|
|
11
|
-
}
|
|
7
|
+
export declare const headingLevels: ModalProps['headingLevel'][];
|
|
12
8
|
//# sourceMappingURL=defs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defs.d.ts","sourceRoot":"","sources":["../../../src/defs.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"defs.d.ts","sourceRoot":"","sources":["../../../src/defs.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACvB,YAAY,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;CACzD;AAED;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,UAAU,CAAC,cAAc,CAAC,EAAyC,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { LitElement } from 'lit';
|
|
2
|
-
import {
|
|
3
|
-
export {
|
|
2
|
+
import { ModalProps, headingLevels } from './defs';
|
|
3
|
+
export { type ModalProps, headingLevels };
|
|
4
|
+
declare const componentSelector = "pie-modal";
|
|
4
5
|
declare const PieModal_base: (new (...args: any[]) => {
|
|
5
6
|
dir: string;
|
|
6
7
|
isRTL: boolean;
|
|
@@ -8,13 +9,13 @@ declare const PieModal_base: (new (...args: any[]) => {
|
|
|
8
9
|
export declare class PieModal extends PieModal_base {
|
|
9
10
|
isOpen: boolean;
|
|
10
11
|
heading: string;
|
|
11
|
-
headingLevel:
|
|
12
|
+
headingLevel: ModalProps['headingLevel'];
|
|
12
13
|
render(): import("lit-html").TemplateResult<1 | 2>;
|
|
13
14
|
static styles: import("lit").CSSResult;
|
|
14
15
|
}
|
|
15
16
|
declare global {
|
|
16
17
|
interface HTMLElementTagNameMap {
|
|
17
|
-
|
|
18
|
+
[componentSelector]: PieModal;
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAM5C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAM5C,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAGnD,OAAO,EAAE,KAAK,UAAU,EAAE,aAAa,EAAE,CAAC;AAE1C,QAAA,MAAM,iBAAiB,cAAc,CAAC;;;;;AAEtC,qBAAa,QAAS,SAAQ,aAAoB;IAE1C,MAAM,UAAS;IAIf,OAAO,EAAG,MAAM,CAAC;IAIjB,YAAY,EAAE,UAAU,CAAC,cAAc,CAAC,CAAQ;IAEpD,MAAM;IAoBN,MAAM,CAAC,MAAM,0BAAqB;CACrC;AAID,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,qBAAqB;QAC3B,CAAC,iBAAiB,CAAC,EAAE,QAAQ,CAAC;KACjC;CACJ"}
|
package/package.json
CHANGED
package/src/defs.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
+
export interface ModalProps {
|
|
2
|
+
headingLevel: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
3
|
+
}
|
|
4
|
+
|
|
1
5
|
/**
|
|
2
6
|
* Modal heading levels/tags
|
|
3
7
|
*/
|
|
4
|
-
export
|
|
5
|
-
H1 = 'h1',
|
|
6
|
-
H2 = 'h2',
|
|
7
|
-
H3 = 'h3',
|
|
8
|
-
H4 = 'h4',
|
|
9
|
-
H5 = 'h5',
|
|
10
|
-
H6 = 'h6'
|
|
11
|
-
}
|
|
8
|
+
export const headingLevels: ModalProps['headingLevel'][] = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
|
package/src/index.ts
CHANGED
|
@@ -4,10 +4,10 @@ import { property } from 'lit/decorators.js'; // eslint-disable-line import/no-e
|
|
|
4
4
|
import { RtlMixin, validPropertyValues, requiredProperty } from '@justeattakeaway/pie-webc-core';
|
|
5
5
|
|
|
6
6
|
import styles from './modal.scss?inline';
|
|
7
|
-
import {
|
|
7
|
+
import { ModalProps, headingLevels } from './defs';
|
|
8
8
|
|
|
9
9
|
// Valid values available to consumers
|
|
10
|
-
export {
|
|
10
|
+
export { type ModalProps, headingLevels };
|
|
11
11
|
|
|
12
12
|
const componentSelector = 'pie-modal';
|
|
13
13
|
|
|
@@ -20,8 +20,8 @@ export class PieModal extends RtlMixin(LitElement) {
|
|
|
20
20
|
heading!: string;
|
|
21
21
|
|
|
22
22
|
@property()
|
|
23
|
-
@validPropertyValues(componentSelector,
|
|
24
|
-
headingLevel
|
|
23
|
+
@validPropertyValues(componentSelector, headingLevels, 'h2')
|
|
24
|
+
headingLevel: ModalProps['headingLevel'] = 'h2';
|
|
25
25
|
|
|
26
26
|
render () {
|
|
27
27
|
const {
|
|
@@ -50,6 +50,6 @@ customElements.define(componentSelector, PieModal);
|
|
|
50
50
|
|
|
51
51
|
declare global {
|
|
52
52
|
interface HTMLElementTagNameMap {
|
|
53
|
-
|
|
53
|
+
[componentSelector]: PieModal;
|
|
54
54
|
}
|
|
55
55
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { test, expect } from '@sand4rt/experimental-ct-web';
|
|
2
2
|
import { PieModal } from '@/index';
|
|
3
|
-
import {
|
|
3
|
+
import { headingLevels } from '@/defs';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
headingLevels.forEach((headingLevel) => test(`should render the correct heading tag based on the value of headingLevel: ${headingLevel}`, async ({ mount }) => {
|
|
6
6
|
const props = {
|
|
7
7
|
heading: 'Modal Header',
|
|
8
8
|
headingLevel,
|
|
@@ -13,15 +13,15 @@ Object.values(HEADING_LEVELS).forEach((headingLevel) => test(`should render the
|
|
|
13
13
|
await expect(component.locator(`${props.headingLevel}.c-modal-heading`)).toContainText(props.heading);
|
|
14
14
|
}));
|
|
15
15
|
|
|
16
|
-
['span', 'section'].forEach((headingLevel) => test(`should render the fallback heading level
|
|
16
|
+
['span', 'section'].forEach((headingLevel) => test(`should render the fallback heading level 'h2' if invalid headingLevel: ${headingLevel} is passed`, async ({ mount }) => {
|
|
17
17
|
const props = {
|
|
18
18
|
heading: 'Modal Header',
|
|
19
19
|
// assert type checking as we purposely provide incorrect value
|
|
20
|
-
headingLevel
|
|
20
|
+
headingLevel,
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
const component = await mount(PieModal, { props });
|
|
24
24
|
|
|
25
25
|
// h2 is the default / fallback value
|
|
26
|
-
await expect(component.locator(
|
|
26
|
+
await expect(component.locator('h2.c-modal-heading')).toContainText(props.heading);
|
|
27
27
|
}));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { test } from '@sand4rt/experimental-ct-web';
|
|
2
2
|
import percySnapshot from '@percy/playwright';
|
|
3
3
|
import { PieModal } from '@/index';
|
|
4
|
+
import { getLitPercyOptions } from '@justeattakeaway/pie-webc-core/src/test-helpers/percy-lit-options.ts';
|
|
4
5
|
|
|
5
6
|
const propIsOpenValues = [{ heading: 'Modal Heading', isOpen: true }, { isOpen: false }];
|
|
6
7
|
|
|
@@ -15,5 +16,5 @@ propIsOpenValues.forEach((props) => test(`should render Modal correctly when pro
|
|
|
15
16
|
},
|
|
16
17
|
);
|
|
17
18
|
|
|
18
|
-
await percySnapshot(page, `PIE Modal when isOpen is set to ${props.isOpen}
|
|
19
|
+
await percySnapshot(page, `PIE Modal when isOpen is set to ${props.isOpen}`, getLitPercyOptions());
|
|
19
20
|
}));
|