@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.
@@ -1,14 +1,14 @@
1
- [11:48:53] @custom-elements-manifest/analyzer: Created new manifest.
1
+ [3:48:32 PM] @custom-elements-manifest/analyzer: Created new manifest.
2
2
  react wrapper has been added!
3
- vite v4.2.3 building for production...
3
+ vite v4.2.3 building for production...
4
4
  transforming...
5
- 27 modules transformed.
5
+ ✓ 28 modules transformed.
6
6
  rendering chunks...
7
7
  computing gzip size...
8
- dist/index.js 5.93 kB │ gzip: 2.06 kB
9
- dist/react.js 59.15 kB │ gzip: 15.95 kB
10
-
11
- [vite:dts] Start generate declaration files...
12
- built in 5.82s
13
- [vite:dts] Declaration files built in 5339ms.
14
-
8
+ dist/index.js  5.83 kB │ gzip: 2.00 kB
9
+ dist/react.js 59.15 kB │ gzip: 15.94 kB
10
+ 
11
+ [vite:dts] Start generate declaration files...
12
+ ✓ built in 30.45s
13
+ [vite:dts] Declaration files built in 28192ms.
14
+ 
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 m, LitElement as u, html as f } from "lit";
2
- import { unsafeStatic as b, html as $ } from "lit/static-html.js";
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 y } from "lit/decorators/property.js";
5
- var w = Object.defineProperty, P = Object.getOwnPropertyDescriptor, O = (n, r, o, t) => {
6
- for (var e = t > 1 ? void 0 : t ? P(r, o) : r, s = n.length - 1, i; s >= 0; s--)
7
- (i = n[s]) && (e = (t ? i(r, o, e) : i(e)) || e);
8
- return t && e && w(r, o, e), 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 _ = (n) => {
11
- class r extends n {
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 O([
30
- y({ type: String })
29
+ return P([
30
+ $({ type: String })
31
31
  ], r.prototype, "dir", 2), r;
32
- }, x = (n, r, o) => function(t, e) {
33
- const s = `#${e}`;
32
+ }, O = (s, r, n) => function(t, e) {
33
+ const o = `#${e}`;
34
34
  Object.defineProperty(t, e, {
35
35
  get() {
36
- return this[s];
36
+ return this[o];
37
37
  },
38
38
  set(i) {
39
- const h = this[s];
40
- r.includes(i) ? this[s] = i : (console.error(
41
- `<${n}> Invalid value "${i}" provided for property "${e}".`,
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: "${o}"`
44
- ), this[s] = o), this.requestUpdate(e, h);
43
+ `Falling back to default value: "${n}"`
44
+ ), this[o] = n), this.requestUpdate(e, m);
45
45
  }
46
46
  });
47
- }, C = (n) => function(r, o) {
48
- const t = `#${o}`;
49
- Object.defineProperty(r, o, {
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 s = this[t];
55
- (e == null || e === "") && console.error(`<${n}> Missing required attribute "${o}"`), this[t] = e, this.requestUpdate(o, s);
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
- }, j = `.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)}
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, z = (n, r, o, t) => {
61
- for (var e = t > 1 ? void 0 : t ? W(r, o) : r, s = n.length - 1, i; s >= 0; s--)
62
- (i = n[s]) && (e = (t ? i(r, o, e) : i(e)) || e);
63
- return t && e && T(r, o, e), e;
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 l extends u {
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 [o, t] = r.split(":");
76
- return f`<p class="c-webComponentTestWrapper-label"><b>${o}</b>: <code>${t}</code></p>`;
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 f`
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
- l.styles = m(j);
91
- z([
90
+ p.styles = h(C);
91
+ j([
92
92
  d({ type: String })
93
- ], l.prototype, "propKeyValues", 2);
94
- const v = "web-component-test-wrapper";
95
- customElements.get(v) || customElements.define(v, l);
96
- const q = `.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
- `;
98
- var p = /* @__PURE__ */ ((n) => (n.H1 = "h1", n.H2 = "h2", n.H3 = "h3", n.H4 = "h4", n.H5 = "h5", n.H6 = "h6", n))(p || {}), M = Object.defineProperty, S = Object.getOwnPropertyDescriptor, c = (n, r, o, t) => {
99
- for (var e = t > 1 ? void 0 : t ? S(r, o) : r, s = n.length - 1, i; s >= 0; s--)
100
- (i = n[s]) && (e = (t ? i(r, o, e) : i(e)) || e);
101
- return t && e && M(r, o, e), 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 g = "pie-modal";
104
- class a extends _(u) {
103
+ const c = "pie-modal";
104
+ class a extends _(v) {
105
105
  constructor() {
106
- super(...arguments), this.isOpen = !1, this.headingLevel = p.H2;
106
+ super(...arguments), this.isOpen = !1, this.headingLevel = "h2";
107
107
  }
108
108
  render() {
109
109
  const {
110
110
  isOpen: r,
111
- heading: o,
111
+ heading: n,
112
112
  headingLevel: t
113
- } = this, e = b(t);
114
- return $`
113
+ } = this, e = u(t);
114
+ return b`
115
115
  <dialog class="c-modal" ?open="${r}">
116
- <${e} class="c-modal-heading">${o}</${e}>
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 = m(q);
125
- c([
124
+ a.styles = h(S);
125
+ l([
126
126
  d({ type: Boolean })
127
127
  ], a.prototype, "isOpen", 2);
128
- c([
128
+ l([
129
129
  d({ type: String }),
130
- C(g)
130
+ x(c)
131
131
  ], a.prototype, "heading", 2);
132
- c([
132
+ l([
133
133
  d(),
134
- x(g, Object.values(p), p.H2)
134
+ O(c, z, "h2")
135
135
  ], a.prototype, "headingLevel", 2);
136
- customElements.define(g, a);
136
+ customElements.define(c, a);
137
137
  export {
138
- p as HEADING_LEVELS,
139
- a as PieModal
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 enum HEADING_LEVELS {
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;;GAEG;AACH,oBAAY,cAAc;IACxB,EAAE,OAAO;IACT,EAAE,OAAO;IACT,EAAE,OAAO;IACT,EAAE,OAAO;IACT,EAAE,OAAO;IACT,EAAE,OAAO;CACV"}
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 { HEADING_LEVELS } from './defs';
3
- export { HEADING_LEVELS };
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: HEADING_LEVELS;
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
- 'pie-modal': PieModal;
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,cAAc,EAAE,MAAM,QAAQ,CAAC;AAGxC,OAAO,EAAE,cAAc,EAAE,CAAC;;;;;AAI1B,qBAAa,QAAS,SAAQ,aAAoB;IAE1C,MAAM,UAAS;IAIf,OAAO,EAAG,MAAM,CAAC;IAIjB,YAAY,EAAG,cAAc,CAAqB;IAEtD,MAAM;IAoBN,MAAM,CAAC,MAAM,0BAAqB;CACrC;AAID,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,qBAAqB;QAC3B,WAAW,EAAE,QAAQ,CAAC;KACzB;CACJ"}
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@justeattakeaway/pie-modal",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "PIE design system modal built using web components",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
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 enum HEADING_LEVELS {
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 { HEADING_LEVELS } from './defs';
7
+ import { ModalProps, headingLevels } from './defs';
8
8
 
9
9
  // Valid values available to consumers
10
- export { HEADING_LEVELS };
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, Object.values(HEADING_LEVELS), HEADING_LEVELS.H2)
24
- headingLevel : HEADING_LEVELS = HEADING_LEVELS.H2;
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
- 'pie-modal': PieModal;
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 { HEADING_LEVELS } from '@/defs';
3
+ import { headingLevels } from '@/defs';
4
4
 
5
- Object.values(HEADING_LEVELS).forEach((headingLevel) => test(`should render the correct heading tag based on the value of headingLevel: ${headingLevel}`, async ({ mount }) => {
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 ${HEADING_LEVELS.H2} if invalid headingLevel: ${headingLevel} is passed`, async ({ mount }) => {
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: headingLevel as HEADING_LEVELS,
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(`${HEADING_LEVELS.H2}.c-modal-heading`)).toContainText(props.heading);
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
  }));