@justeattakeaway/pie-toast-provider 0.4.2 → 0.5.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.
@@ -16,9 +16,9 @@
16
16
  "kind": "variable",
17
17
  "name": "PRIORITY_ORDER",
18
18
  "type": {
19
- "text": "{\n 'error-actionable': 1,\n error: 2,\n 'warning-actionable': 3,\n 'success-actionable': 4,\n 'info-actionable': 5,\n 'neutral-actionable': 6,\n warning: 7,\n success: 8,\n info: 9,\n neutral: 10,\n}"
19
+ "text": "{\r\n 'error-actionable': 1,\r\n error: 2,\r\n 'warning-actionable': 3,\r\n 'success-actionable': 4,\r\n 'info-actionable': 5,\r\n 'neutral-actionable': 6,\r\n warning: 7,\r\n success: 8,\r\n info: 9,\r\n neutral: 10,\r\n}"
20
20
  },
21
- "default": "{\n 'error-actionable': 1,\n error: 2,\n 'warning-actionable': 3,\n 'success-actionable': 4,\n 'info-actionable': 5,\n 'neutral-actionable': 6,\n warning: 7,\n success: 8,\n info: 9,\n neutral: 10,\n}"
21
+ "default": "{\r\n 'error-actionable': 1,\r\n error: 2,\r\n 'warning-actionable': 3,\r\n 'success-actionable': 4,\r\n 'info-actionable': 5,\r\n 'neutral-actionable': 6,\r\n warning: 7,\r\n success: 8,\r\n info: 9,\r\n neutral: 10,\r\n}"
22
22
  },
23
23
  {
24
24
  "kind": "variable",
@@ -26,7 +26,7 @@
26
26
  "type": {
27
27
  "text": "DefaultProps"
28
28
  },
29
- "default": "{\n options: {},\n}"
29
+ "default": "{\r\n options: {},\r\n}"
30
30
  },
31
31
  {
32
32
  "kind": "variable",
@@ -168,7 +168,7 @@
168
168
  "kind": "method",
169
169
  "name": "clearToasts",
170
170
  "privacy": "public",
171
- "description": "\nClears all toasts from the queue and dismisses the currently visible toast."
171
+ "description": "\r\nClears all toasts from the queue and dismisses the currently visible toast."
172
172
  }
173
173
  ],
174
174
  "events": [
@@ -237,7 +237,7 @@
237
237
  "type": {
238
238
  "text": "object"
239
239
  },
240
- "default": "{\n _getToastProvider (): PieToastProvider | null {\n const toastProviders = document.querySelectorAll('pie-toast-provider');\n\n if (toastProviders.length === 0) {\n console.error('The pie-toast component requires a pie-toast-provider element present in the DOM.');\n return null;\n }\n\n if (toastProviders.length > 1) {\n console.error('Multiple pie-toast-provider are found in the DOM. Only one provider is supported currently and should be registered at the root of the app.');\n return null;\n }\n\n return toastProviders[0];\n },\n create (toast: ExtendedToastProps) {\n const toastProvider = this._getToastProvider();\n if (!toastProvider) return;\n\n toastProvider.createToast(toast);\n },\n clearAll () {\n const toastProvider = this._getToastProvider();\n if (!toastProvider) return;\n\n toastProvider.clearToasts();\n },\n}",
240
+ "default": "{\r\n _getToastProvider (): PieToastProvider | null {\r\n const toastProviders = document.querySelectorAll('pie-toast-provider');\r\n\r\n if (toastProviders.length === 0) {\r\n console.error('The pie-toast component requires a pie-toast-provider element present in the DOM.');\r\n return null;\r\n }\r\n\r\n if (toastProviders.length > 1) {\r\n console.error('Multiple pie-toast-provider are found in the DOM. Only one provider is supported currently and should be registered at the root of the app.');\r\n return null;\r\n }\r\n\r\n return toastProviders[0];\r\n },\r\n create (toast: ExtendedToastProps) {\r\n const toastProvider = this._getToastProvider();\r\n if (!toastProvider) return;\r\n\r\n toastProvider.createToast(toast);\r\n },\r\n clearAll () {\r\n const toastProvider = this._getToastProvider();\r\n if (!toastProvider) return;\r\n\r\n toastProvider.clearToasts();\r\n },\r\n}",
241
241
  "description": "Singleton toaster interface for global access."
242
242
  }
243
243
  ],
package/dist/index.js CHANGED
@@ -1,22 +1,16 @@
1
- import { LitElement as m, nothing as T, html as u, unsafeCSS as g } from "lit";
2
- import { property as f, state as v } from "lit/decorators.js";
3
- import { ifDefined as y } from "lit/directives/if-defined.js";
4
- import { RtlMixin as P, dispatchCustomEvent as x, defineCustomElement as $ } from "@justeattakeaway/pie-webc-core";
1
+ import { LitElement as f, nothing as _, html as u, unsafeCSS as T } from "lit";
2
+ import { state as v, property as g } from "lit/decorators.js";
3
+ import { ifDefined as m } from "lit/directives/if-defined.js";
4
+ import { RtlMixin as P, dispatchCustomEvent as y, safeCustomElement as b } from "@justeattakeaway/pie-webc-core";
5
5
  import { defaultProps as h } from "@justeattakeaway/pie-toast";
6
- var b = Object.defineProperty, E = (o, t, e, r) => {
7
- for (var s = void 0, i = o.length - 1, n; i >= 0; i--)
8
- (n = o[i]) && (s = n(t, e, s) || s);
9
- return s && b(t, e, s), s;
10
- };
11
- class _ extends m {
12
- constructor() {
13
- super(...arguments), this.v = "0.4.2";
6
+ const p = class p extends f {
7
+ willUpdate() {
8
+ this.getAttribute("v") || this.setAttribute("v", p.v);
14
9
  }
15
- }
16
- E([
17
- f({ type: String, reflect: !0 })
18
- ], _.prototype, "v");
19
- const A = "*,*:after,*:before{box-sizing:inherit}:host{--toast-provider-z-index: var(--dt-z-index-toast)}.c-toast-provider{--toast-provider-offset: var(--dt-spacing-d);position:absolute;inset-inline-start:var(--toast-provider-offset);inset-block-end:var(--toast-provider-offset);z-index:var(--toast-provider-z-index)}@media (min-width: 769px){.c-toast-provider{--toast-offset: var(--dt-spacing-e)}}", O = {
10
+ };
11
+ p.v = "0.5.1";
12
+ let c = p;
13
+ const x = "*,*:after,*:before{box-sizing:inherit}:host{--toast-provider-z-index: var(--dt-z-index-toast)}.c-toast-provider{--toast-provider-offset: var(--dt-spacing-d);position:absolute;inset-inline-start:var(--toast-provider-offset);inset-block-end:var(--toast-provider-offset);z-index:var(--toast-provider-z-index)}@media (min-width: 769px){.c-toast-provider{--toast-offset: var(--dt-spacing-e)}}", A = {
20
14
  "error-actionable": 1,
21
15
  error: 2,
22
16
  "warning-actionable": 3,
@@ -27,38 +21,38 @@ const A = "*,*:after,*:before{box-sizing:inherit}:host{--toast-provider-z-index:
27
21
  success: 8,
28
22
  info: 9,
29
23
  neutral: 10
30
- }, D = {
24
+ }, O = {
31
25
  options: {}
32
- }, S = "pie-toast-provider-queue-update", k = {
26
+ }, $ = "pie-toast-provider-queue-update", U = {
33
27
  _getToastProvider() {
34
- const o = document.querySelectorAll("pie-toast-provider");
35
- return o.length === 0 ? (console.error("The pie-toast component requires a pie-toast-provider element present in the DOM."), null) : o.length > 1 ? (console.error("Multiple pie-toast-provider are found in the DOM. Only one provider is supported currently and should be registered at the root of the app."), null) : o[0];
28
+ const t = document.querySelectorAll("pie-toast-provider");
29
+ return t.length === 0 ? (console.error("The pie-toast component requires a pie-toast-provider element present in the DOM."), null) : t.length > 1 ? (console.error("Multiple pie-toast-provider are found in the DOM. Only one provider is supported currently and should be registered at the root of the app."), null) : t[0];
36
30
  },
37
- create(o) {
38
- const t = this._getToastProvider();
39
- t && t.createToast(o);
31
+ create(t) {
32
+ const e = this._getToastProvider();
33
+ e && e.createToast(t);
40
34
  },
41
35
  clearAll() {
42
- const o = this._getToastProvider();
43
- o && o.clearToasts();
36
+ const t = this._getToastProvider();
37
+ t && t.clearToasts();
44
38
  }
45
39
  };
46
- var w = Object.defineProperty, p = (o, t, e, r) => {
47
- for (var s = void 0, i = o.length - 1, n; i >= 0; i--)
48
- (n = o[i]) && (s = n(t, e, s) || s);
49
- return s && w(t, e, s), s;
40
+ var w = Object.defineProperty, D = Object.getOwnPropertyDescriptor, l = (t, e, o, i) => {
41
+ for (var s = i > 1 ? void 0 : i ? D(e, o) : e, n = t.length - 1, r; n >= 0; n--)
42
+ (r = t[n]) && (s = (i ? r(e, o, s) : r(s)) || s);
43
+ return i && s && w(e, o, s), s;
50
44
  };
51
- const C = "pie-toast-provider", l = class l extends P(_) {
45
+ let a = class extends P(c) {
52
46
  constructor() {
53
- super(...arguments), this._toasts = [], this._currentToast = null, this.options = D.options;
47
+ super(...arguments), this._toasts = [], this._currentToast = null, this.options = O.options;
54
48
  }
55
49
  updated(t) {
56
50
  t.has("_toasts") && this._dispatchQueueUpdateEvent();
57
51
  }
58
52
  _dispatchQueueUpdateEvent() {
59
- x(
53
+ y(
60
54
  this,
61
- S,
55
+ $,
62
56
  this._toasts
63
57
  );
64
58
  }
@@ -69,8 +63,8 @@ const C = "pie-toast-provider", l = class l extends P(_) {
69
63
  * @returns {number} - The priority based on the variant and action.
70
64
  */
71
65
  getPriority(t = h.variant, e = !1) {
72
- const r = `${t}${e ? "-actionable" : ""}`;
73
- return O[r];
66
+ const o = `${t}${e ? "-actionable" : ""}`;
67
+ return A[o];
74
68
  }
75
69
  /**
76
70
  * Handles the dismissal of the current toast and displays the next one in the queue (if any).
@@ -97,10 +91,10 @@ const C = "pie-toast-provider", l = class l extends P(_) {
97
91
  */
98
92
  createToast(t) {
99
93
  const e = { ...h, ...this.options, ...t };
100
- this._toasts = [...this._toasts, e].sort((r, s) => {
101
- var c, d;
102
- const i = this.getPriority(s.variant, !!((c = s.leadingAction) != null && c.text));
103
- return this.getPriority(r.variant, !!((d = r.leadingAction) != null && d.text)) - i;
94
+ this._toasts = [...this._toasts, e].sort((o, i) => {
95
+ var r, d;
96
+ const s = this.getPriority(i.variant, !!((r = i.leadingAction) != null && r.text));
97
+ return this.getPriority(o.variant, !!((d = o.leadingAction) != null && d.text)) - s;
104
98
  }), this._currentToast || this._showNextToast();
105
99
  }
106
100
  /**
@@ -119,12 +113,12 @@ const C = "pie-toast-provider", l = class l extends P(_) {
119
113
  ${t && u`
120
114
  <pie-toast
121
115
  message="${t.message}"
122
- variant="${y(t.variant)}"
116
+ variant="${m(t.variant)}"
123
117
  ?isStrong="${t.isStrong}"
124
118
  ?isDismissible="${t.isDismissible}"
125
119
  ?isMultiline="${t.isMultiline}"
126
120
  .leadingAction="${t.leadingAction}"
127
- .duration="${typeof t.duration > "u" ? T : t.duration}"
121
+ .duration="${typeof t.duration > "u" ? _ : t.duration}"
128
122
  @pie-toast-close="${e}"
129
123
  @pie-toast-open="${t.onPieToastOpen}"
130
124
  @pie-toast-leading-action-click="${t.onPieToastLeadingActionClick}">
@@ -134,22 +128,23 @@ const C = "pie-toast-provider", l = class l extends P(_) {
134
128
  `;
135
129
  }
136
130
  };
137
- l.styles = g(A);
138
- let a = l;
139
- p([
131
+ a.styles = T(x);
132
+ l([
140
133
  v()
141
- ], a.prototype, "_toasts");
142
- p([
134
+ ], a.prototype, "_toasts", 2);
135
+ l([
143
136
  v()
144
- ], a.prototype, "_currentToast");
145
- p([
146
- f({ type: Object })
147
- ], a.prototype, "options");
148
- $(C, a);
137
+ ], a.prototype, "_currentToast", 2);
138
+ l([
139
+ g({ type: Object })
140
+ ], a.prototype, "options", 2);
141
+ a = l([
142
+ b("pie-toast-provider")
143
+ ], a);
149
144
  export {
150
- S as ON_TOAST_PROVIDER_QUEUE_UPDATE_EVENT,
151
- O as PRIORITY_ORDER,
145
+ $ as ON_TOAST_PROVIDER_QUEUE_UPDATE_EVENT,
146
+ A as PRIORITY_ORDER,
152
147
  a as PieToastProvider,
153
- D as defaultProps,
154
- k as toaster
148
+ O as defaultProps,
149
+ U as toaster
155
150
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@justeattakeaway/pie-toast-provider",
3
3
  "description": "PIE Design System Toast Provider built using Web Components",
4
- "version": "0.4.2",
4
+ "version": "0.5.1",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/justeattakeaway/pie",
@@ -45,8 +45,8 @@
45
45
  "cem-plugin-module-file-extensions": "0.0.5"
46
46
  },
47
47
  "dependencies": {
48
- "@justeattakeaway/pie-toast": "0.8.4",
49
- "@justeattakeaway/pie-webc-core": "0.25.1"
48
+ "@justeattakeaway/pie-toast": "0.9.1",
49
+ "@justeattakeaway/pie-webc-core": "0.26.0"
50
50
  },
51
51
  "volta": {
52
52
  "extends": "../../../package.json"
package/src/index.ts CHANGED
@@ -9,8 +9,8 @@ import { state, property } from 'lit/decorators.js';
9
9
  import { ifDefined } from 'lit/directives/if-defined.js';
10
10
  import {
11
11
  RtlMixin,
12
- defineCustomElement,
13
12
  dispatchCustomEvent,
13
+ safeCustomElement,
14
14
  } from '@justeattakeaway/pie-webc-core';
15
15
  import { defaultProps as toastDefaultProps } from '@justeattakeaway/pie-toast';
16
16
  import styles from './toast-provider.scss?inline';
@@ -33,6 +33,7 @@ const componentSelector = 'pie-toast-provider';
33
33
  * @tagname pie-toast-provider
34
34
  * @event {CustomEvent} pie-toast-provider-queue-update - when a toast is added or removed from the queue.
35
35
  */
36
+ @safeCustomElement('pie-toast-provider')
36
37
  export class PieToastProvider extends RtlMixin(PieElement) implements ToastProviderProps {
37
38
  @state()
38
39
  private _toasts: ExtendedToastProps[] = [];
@@ -147,8 +148,6 @@ export class PieToastProvider extends RtlMixin(PieElement) implements ToastProvi
147
148
  static styles = unsafeCSS(styles);
148
149
  }
149
150
 
150
- defineCustomElement(componentSelector, PieToastProvider);
151
-
152
151
  declare global {
153
152
  interface HTMLElementTagNameMap {
154
153
  [componentSelector]: PieToastProvider;