@justeattakeaway/pie-modal 0.5.0 → 0.6.1
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 +11 -6
- package/CHANGELOG.md +14 -0
- package/README.md +51 -24
- package/dist/index.js +89 -73
- package/dist/react.js +209 -223
- package/dist/types/packages/components/pie-modal/src/defs.d.ts +20 -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 +10 -1
- package/dist/types/packages/components/pie-modal/src/index.d.ts.map +1 -1
- package/package.json +3 -1
- package/src/defs.ts +21 -1
- package/src/index.ts +36 -9
- package/src/modal.scss +60 -49
- package/test/component/pie-modal.spec.ts +26 -0
- package/vite.config.js +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
[
|
|
1
|
+
[2:38:36 PM] @custom-elements-manifest/analyzer: Created new manifest.
|
|
2
2
|
react wrapper has been added!
|
|
3
|
-
[36mvite v4.
|
|
3
|
+
[36mvite v4.3.9 [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
|
-
[2mdist/[22m[36mindex.js [39m[1m[2m
|
|
9
|
-
[2mdist/[22m[36mreact.js [39m[1m[2m59.
|
|
8
|
+
[2mdist/[22m[36mindex.js [39m[1m[2m 7.43 kB[22m[1m[22m[2m │ gzip: 2.38 kB[22m
|
|
9
|
+
[2mdist/[22m[36mreact.js [39m[1m[2m59.04 kB[22m[1m[22m[2m │ gzip: 15.92 kB[22m
|
|
10
10
|
[32m
|
|
11
11
|
[36m[vite:dts][32m Start generate declaration files...[39m
|
|
12
|
-
[
|
|
13
|
-
|
|
12
|
+
[96msrc/index.ts[0m:[93m27[0m:[93m9[0m - [91merror[0m[90m TS2564: [0mProperty '_dialog' has no initializer and is not definitely assigned in the constructor.
|
|
13
|
+
|
|
14
|
+
[7m27[0m _dialog: HTMLDialogElement;
|
|
15
|
+
[7m [0m [91m ~~~~~~~[0m
|
|
16
|
+
|
|
17
|
+
[32m✓ built in 23.71s[39m
|
|
18
|
+
[32m[36m[vite:dts][32m Declaration files built in 21869ms.
|
|
14
19
|
[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @justeattakeaway/pie-modal
|
|
2
2
|
|
|
3
|
+
## 0.6.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [Changed] - Updated defs to use different array type syntax ([#566](https://github.com/justeattakeaway/pie/pull/566)) by [@ashleynolan](https://github.com/ashleynolan)
|
|
8
|
+
|
|
9
|
+
## 0.6.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [Changed] - Updated styles to use custom props ([#551](https://github.com/justeattakeaway/pie/pull/551)) by [@ashleynolan](https://github.com/ashleynolan)
|
|
14
|
+
|
|
15
|
+
- [Added] - close button to modal ([#549](https://github.com/justeattakeaway/pie/pull/549)) by [@kevinrodrigues](https://github.com/kevinrodrigues)
|
|
16
|
+
|
|
3
17
|
## 0.5.0
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -17,65 +17,92 @@
|
|
|
17
17
|
|
|
18
18
|
# pie-modal
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
`pie-modal` is a Web Component built using the Lit library. It offers a simple and accessible modal component for web applications, which uses the native HTML `dialog` element under the hood.
|
|
21
|
+
|
|
22
|
+
This component can be easily integrated into various frontend frameworks and customized through a set of properties.
|
|
21
23
|
|
|
22
24
|
## Local development
|
|
23
25
|
|
|
24
|
-
Install dependencies
|
|
25
|
-
|
|
26
|
+
Install the dependencies. Note that this, and the following commands below, should be run from the **root of the monorepo**:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
26
29
|
yarn
|
|
27
30
|
```
|
|
28
31
|
|
|
29
|
-
|
|
30
|
-
```
|
|
31
|
-
cd packages/components/pie-modal
|
|
32
|
-
yarn build
|
|
33
|
-
```
|
|
32
|
+
To build the `pie-modal` package, run the following command:
|
|
34
33
|
|
|
35
|
-
|
|
34
|
+
```bash
|
|
35
|
+
yarn build --filter=pie-modal
|
|
36
36
|
```
|
|
37
|
-
|
|
37
|
+
|
|
38
|
+
If you'd like to develop using the component storybook, then you should build the component in `watch` mode, and run storybook in a separate terminal tab:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
yarn watch --filter=pie-modal
|
|
42
|
+
|
|
43
|
+
# in a separate terminal tab, run
|
|
44
|
+
yarn dev --filter=pie-storybook
|
|
38
45
|
```
|
|
39
46
|
|
|
40
47
|
### Importing the component
|
|
41
48
|
|
|
42
|
-
```
|
|
49
|
+
```js
|
|
43
50
|
// default
|
|
44
|
-
import { PieModal } from '@justeattakeaway/pie-
|
|
51
|
+
import { PieModal } from '@justeattakeaway/pie-modal';
|
|
45
52
|
|
|
46
53
|
// react
|
|
47
|
-
import { PieModal } from '@justeattakeaway/pie-
|
|
54
|
+
import { PieModal } from '@justeattakeaway/pie-modal/dist/react';
|
|
48
55
|
```
|
|
49
56
|
|
|
50
57
|
## Props
|
|
51
58
|
|
|
52
|
-
| Property
|
|
53
|
-
|
|
54
|
-
| isOpen
|
|
55
|
-
| heading*
|
|
56
|
-
| headingLevel | `String`
|
|
59
|
+
| Property | Type | Default | Description |
|
|
60
|
+
|----------------|-----------|---------|-------------------------------------------------------|
|
|
61
|
+
| isOpen | `Boolean` | `false` | Controls if the modal element is open or closed |
|
|
62
|
+
| heading* | `String` | - | Sets the heading of the modal |
|
|
63
|
+
| headingLevel | `String` | `h2` | Allows you to set the heading tag (from `h1` to `h6`) |
|
|
64
|
+
|
|
57
65
|
|
|
66
|
+
In your markup or JSX, you can then use these to set the properties for the `pie-modal` component:
|
|
67
|
+
|
|
68
|
+
```html
|
|
69
|
+
<!-- Native HTML -->
|
|
70
|
+
<pie-modal heading='My Awesome Heading' headingLevel='h3'>Click me!</pie-modal>
|
|
71
|
+
|
|
72
|
+
<!-- JSX -->
|
|
73
|
+
<PieModal heading='My Awesome Heading' headingLevel='h3'>Click me!</PieModal>
|
|
74
|
+
```
|
|
58
75
|
|
|
59
76
|
## Testing
|
|
60
77
|
|
|
61
|
-
###
|
|
78
|
+
### Browser tests
|
|
79
|
+
|
|
80
|
+
To run the browser tests, run the following command from the root of the monorepo:
|
|
62
81
|
|
|
63
|
-
|
|
82
|
+
```bash
|
|
83
|
+
yarn test:browsers --filter=pie-modal
|
|
64
84
|
```
|
|
85
|
+
|
|
86
|
+
### Visual tests
|
|
87
|
+
|
|
88
|
+
To run the visual regression tests, run the following command from the root of the monorepo:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
65
91
|
yarn test:visual --filter=pie-modal
|
|
66
92
|
```
|
|
67
93
|
|
|
68
94
|
Note: To run these locally, you will need to ensure that any environment variables required are set up on your machine to mirror those on CI (such as Percy tokens). How you achieve this will differ between operating systems.
|
|
69
95
|
|
|
70
|
-
|
|
96
|
+
#### Setup via bash
|
|
71
97
|
|
|
72
|
-
```
|
|
98
|
+
```bash
|
|
73
99
|
export PERCY_TOKEN_PIE_MODAL=abcde
|
|
74
100
|
```
|
|
75
101
|
|
|
76
|
-
|
|
102
|
+
#### Setup via package.json
|
|
77
103
|
|
|
78
104
|
Under scripts `test:visual` replace the environment variable with the below:
|
|
79
105
|
|
|
80
|
-
```
|
|
106
|
+
```bash
|
|
81
107
|
PERCY_TOKEN_PIE_MODAL=abcde
|
|
108
|
+
```
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { unsafeCSS as
|
|
1
|
+
import { unsafeCSS as g, LitElement as v, html as m } from "lit";
|
|
2
2
|
import { unsafeStatic as u, html as b } from "lit/static-html.js";
|
|
3
|
-
import { property as
|
|
4
|
-
import { property as
|
|
5
|
-
var y = Object.defineProperty,
|
|
6
|
-
for (var e =
|
|
7
|
-
(i =
|
|
8
|
-
return
|
|
3
|
+
import { property as s, query as _ } from "lit/decorators.js";
|
|
4
|
+
import { property as w } from "lit/decorators/property.js";
|
|
5
|
+
var y = Object.defineProperty, $ = Object.getOwnPropertyDescriptor, P = (r, t, n, o) => {
|
|
6
|
+
for (var e = o > 1 ? void 0 : o ? $(t, n) : t, a = r.length - 1, i; a >= 0; a--)
|
|
7
|
+
(i = r[a]) && (e = (o ? i(t, n, e) : i(e)) || e);
|
|
8
|
+
return o && e && y(t, n, e), e;
|
|
9
9
|
};
|
|
10
|
-
const
|
|
11
|
-
class
|
|
10
|
+
const O = (r) => {
|
|
11
|
+
class t extends r {
|
|
12
12
|
constructor() {
|
|
13
13
|
super(...arguments), this.dir = "";
|
|
14
14
|
}
|
|
@@ -22,47 +22,47 @@ const _ = (s) => {
|
|
|
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 o;
|
|
26
|
+
return this.dir === "ltr" ? !1 : this.dir === "rtl" || ((o = window == null ? void 0 : window.getComputedStyle(this)) == null ? void 0 : o.direction) === "rtl";
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
return P([
|
|
30
|
-
|
|
31
|
-
],
|
|
32
|
-
},
|
|
33
|
-
const
|
|
34
|
-
Object.defineProperty(
|
|
30
|
+
w({ type: String })
|
|
31
|
+
], t.prototype, "dir", 2), t;
|
|
32
|
+
}, C = (r, t, n) => function(o, e) {
|
|
33
|
+
const a = `#${e}`;
|
|
34
|
+
Object.defineProperty(o, e, {
|
|
35
35
|
get() {
|
|
36
|
-
return this[
|
|
36
|
+
return this[a];
|
|
37
37
|
},
|
|
38
38
|
set(i) {
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
`<${
|
|
42
|
-
`Must be one of: ${
|
|
39
|
+
const f = this[a];
|
|
40
|
+
t.includes(i) ? this[a] = i : (console.error(
|
|
41
|
+
`<${r}> Invalid value "${i}" provided for property "${e}".`,
|
|
42
|
+
`Must be one of: ${t.join(" | ")}.`,
|
|
43
43
|
`Falling back to default value: "${n}"`
|
|
44
|
-
), this[
|
|
44
|
+
), this[a] = n), this.requestUpdate(e, f);
|
|
45
45
|
}
|
|
46
46
|
});
|
|
47
|
-
}, x = (
|
|
48
|
-
const
|
|
49
|
-
Object.defineProperty(
|
|
47
|
+
}, x = (r) => function(t, n) {
|
|
48
|
+
const o = `#${n}`;
|
|
49
|
+
Object.defineProperty(t, n, {
|
|
50
50
|
get() {
|
|
51
|
-
return this[
|
|
51
|
+
return this[o];
|
|
52
52
|
},
|
|
53
53
|
set(e) {
|
|
54
|
-
const
|
|
55
|
-
(e == null || e === "") && console.error(`<${
|
|
54
|
+
const a = this[o];
|
|
55
|
+
(e == null || e === "") && console.error(`<${r}> Missing required attribute "${n}"`), this[o] = e, this.requestUpdate(n, a);
|
|
56
56
|
}
|
|
57
57
|
});
|
|
58
|
-
},
|
|
58
|
+
}, z = `.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
|
|
61
|
-
for (var e =
|
|
62
|
-
(i =
|
|
63
|
-
return
|
|
60
|
+
var D = Object.defineProperty, T = Object.getOwnPropertyDescriptor, E = (r, t, n, o) => {
|
|
61
|
+
for (var e = o > 1 ? void 0 : o ? T(t, n) : t, a = r.length - 1, i; a >= 0; a--)
|
|
62
|
+
(i = r[a]) && (e = (o ? i(t, n, e) : i(e)) || e);
|
|
63
|
+
return o && e && D(t, n, e), e;
|
|
64
64
|
};
|
|
65
|
-
class
|
|
65
|
+
class c extends v {
|
|
66
66
|
constructor() {
|
|
67
67
|
super(...arguments), this.propKeyValues = "";
|
|
68
68
|
}
|
|
@@ -71,14 +71,14 @@ class p extends v {
|
|
|
71
71
|
// <p class="c-webComponentTestWrapper-label"><b>size</b>: <code>small</code></p>
|
|
72
72
|
// <p class="c-webComponentTestWrapper-label"><b>isFullWidth</b>: <code>true</code></p>
|
|
73
73
|
_renderPropKeyValues() {
|
|
74
|
-
return this.propKeyValues.split(",").map((
|
|
75
|
-
const [n,
|
|
76
|
-
return
|
|
74
|
+
return this.propKeyValues.split(",").map((t) => {
|
|
75
|
+
const [n, o] = t.split(":");
|
|
76
|
+
return m`<p class="c-webComponentTestWrapper-label"><b>${n}</b>: <code>${o}</code></p>`;
|
|
77
77
|
});
|
|
78
78
|
}
|
|
79
79
|
// eslint-disable-next-line class-methods-use-this
|
|
80
80
|
render() {
|
|
81
|
-
return
|
|
81
|
+
return m`
|
|
82
82
|
<div class="c-webComponentTestWrapper">
|
|
83
83
|
${this._renderPropKeyValues()}
|
|
84
84
|
<div class="c-webComponentTestWrapper-slot">
|
|
@@ -87,54 +87,70 @@ class p extends v {
|
|
|
87
87
|
</div>`;
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
],
|
|
94
|
-
const
|
|
95
|
-
customElements.get(
|
|
96
|
-
const S = `.c-modal{border-radius:var(--dt-radius-rounded-d)
|
|
97
|
-
`,
|
|
98
|
-
var
|
|
99
|
-
for (var e =
|
|
100
|
-
(i =
|
|
101
|
-
return
|
|
90
|
+
c.styles = g(z);
|
|
91
|
+
E([
|
|
92
|
+
s({ type: String })
|
|
93
|
+
], c.prototype, "propKeyValues", 2);
|
|
94
|
+
const h = "web-component-test-wrapper";
|
|
95
|
+
customElements.get(h) || customElements.define(h, c);
|
|
96
|
+
const S = `.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;font-family:var(--modal-font);background-color:var(--modal-bg-color);padding:0;inline-size:var(--modal-size-m);box-shadow:var(--modal-elevation)}.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);--modal-header-padding: var(--dt-spacing-e);--modal-header-padding-block-end: var(--dt-spacing-d);font-size:var(--modal-header-font-size);line-height:var(--modal-header-font-line-height);font-weight:var(--modal-header-font-weight);margin:0;padding-block:var(--modal-header-padding) var(--modal-header-padding-block-end);padding-inline:var(--modal-header-padding)}.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-start: var(--dt-spacing-a);font-size:var(--modal-content-font-size);line-height:var(--modal-content-line-height);font-weight:var(--modal-content-font-weight);padding-block:var(--modal-content-padding-block-start) var(--modal-content-padding);padding-inline:var(--modal-content-padding)}.c-modal .c-modal-closeBtn{position:absolute;right:var(--dt-spacing-d);top:var(--dt-spacing-d)}
|
|
97
|
+
`, j = ["h1", "h2", "h3", "h4", "h5", "h6"], L = "pie-modal-close";
|
|
98
|
+
var W = Object.defineProperty, V = Object.getOwnPropertyDescriptor, l = (r, t, n, o) => {
|
|
99
|
+
for (var e = o > 1 ? void 0 : o ? V(t, n) : t, a = r.length - 1, i; a >= 0; a--)
|
|
100
|
+
(i = r[a]) && (e = (o ? i(t, n, e) : i(e)) || e);
|
|
101
|
+
return o && e && W(t, n, e), e;
|
|
102
102
|
};
|
|
103
|
-
const
|
|
104
|
-
class
|
|
103
|
+
const p = "pie-modal";
|
|
104
|
+
class d extends O(v) {
|
|
105
105
|
constructor() {
|
|
106
|
-
super(...arguments), this.isOpen = !1, this.headingLevel = "h2"
|
|
106
|
+
super(...arguments), this.isOpen = !1, this.headingLevel = "h2", this._handleCloseDialog = () => {
|
|
107
|
+
this._dialog.close(), this._onDialogClose();
|
|
108
|
+
}, this._onDialogClose = () => {
|
|
109
|
+
const t = new CustomEvent(L);
|
|
110
|
+
this.dispatchEvent(t);
|
|
111
|
+
};
|
|
107
112
|
}
|
|
108
113
|
render() {
|
|
109
114
|
const {
|
|
110
|
-
isOpen:
|
|
115
|
+
isOpen: t,
|
|
111
116
|
heading: n,
|
|
112
|
-
headingLevel:
|
|
113
|
-
} = this, e = u(
|
|
117
|
+
headingLevel: o = "h2"
|
|
118
|
+
} = this, e = u(o);
|
|
114
119
|
return b`
|
|
115
|
-
<dialog class="c-modal" ?open="${
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
<
|
|
119
|
-
|
|
120
|
+
<dialog id="dialog" class="c-modal" ?open="${t}">
|
|
121
|
+
<header>
|
|
122
|
+
<${e} class="c-modal-heading">${n}</${e}>
|
|
123
|
+
<pie-icon-button
|
|
124
|
+
@click="${this._handleCloseDialog}"
|
|
125
|
+
variant="ghost-tertiary"
|
|
126
|
+
class="c-modal-closeBtn"></pie-icon-button>
|
|
127
|
+
</header>
|
|
128
|
+
<article>
|
|
129
|
+
<div class="c-modal-content">
|
|
130
|
+
<slot></slot>
|
|
131
|
+
</div>
|
|
132
|
+
</article>
|
|
120
133
|
</dialog>
|
|
121
134
|
`;
|
|
122
135
|
}
|
|
123
136
|
}
|
|
124
|
-
|
|
137
|
+
d.styles = g(S);
|
|
138
|
+
l([
|
|
139
|
+
s({ type: Boolean })
|
|
140
|
+
], d.prototype, "isOpen", 2);
|
|
125
141
|
l([
|
|
126
|
-
|
|
127
|
-
|
|
142
|
+
s({ type: String }),
|
|
143
|
+
x(p)
|
|
144
|
+
], d.prototype, "heading", 2);
|
|
128
145
|
l([
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
],
|
|
146
|
+
s(),
|
|
147
|
+
C(p, j, "h2")
|
|
148
|
+
], d.prototype, "headingLevel", 2);
|
|
132
149
|
l([
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
customElements.define(c, a);
|
|
150
|
+
_("dialog")
|
|
151
|
+
], d.prototype, "_dialog", 2);
|
|
152
|
+
customElements.define(p, d);
|
|
137
153
|
export {
|
|
138
|
-
|
|
139
|
-
|
|
154
|
+
d as PieModal,
|
|
155
|
+
j as headingLevels
|
|
140
156
|
};
|