@justeattakeaway/pie-toast-provider 0.3.2 → 0.4.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/dist/index.js CHANGED
@@ -1,22 +1,22 @@
1
1
  import { LitElement as m, nothing as T, html as u, unsafeCSS as g } from "lit";
2
2
  import { property as f, state as v } from "lit/decorators.js";
3
3
  import { ifDefined as y } from "lit/directives/if-defined.js";
4
- import { RtlMixin as P, dispatchCustomEvent as $, defineCustomElement as b } from "@justeattakeaway/pie-webc-core";
4
+ import { RtlMixin as P, dispatchCustomEvent as x, defineCustomElement as $ } from "@justeattakeaway/pie-webc-core";
5
5
  import { defaultProps as h } from "@justeattakeaway/pie-toast";
6
- var E = Object.defineProperty, x = (o, t, e, r) => {
6
+ var b = Object.defineProperty, E = (o, t, e, r) => {
7
7
  for (var s = void 0, i = o.length - 1, n; i >= 0; i--)
8
8
  (n = o[i]) && (s = n(t, e, s) || s);
9
- return s && E(t, e, s), s;
9
+ return s && b(t, e, s), s;
10
10
  };
11
11
  class _ extends m {
12
12
  constructor() {
13
- super(...arguments), this.v = "0.3.2";
13
+ super(...arguments), this.v = "0.4.0";
14
14
  }
15
15
  }
16
- x([
16
+ E([
17
17
  f({ type: String, reflect: !0 })
18
18
  ], _.prototype, "v");
19
- const A = "*,*:after,*:before{box-sizing:inherit}.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)}@media (min-width: 769px){.c-toast-provider{--toast-offset: var(--dt-spacing-e)}}", O = {
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 = {
20
20
  "error-actionable": 1,
21
21
  error: 2,
22
22
  "warning-actionable": 3,
@@ -29,7 +29,7 @@ const A = "*,*:after,*:before{box-sizing:inherit}.c-toast-provider{--toast-provi
29
29
  neutral: 10
30
30
  }, D = {
31
31
  options: {}
32
- }, S = "pie-toast-provider-queue-update", q = {
32
+ }, S = "pie-toast-provider-queue-update", k = {
33
33
  _getToastProvider() {
34
34
  const o = document.querySelectorAll("pie-toast-provider");
35
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];
@@ -56,7 +56,7 @@ const C = "pie-toast-provider", l = class l extends P(_) {
56
56
  t.has("_toasts") && this._dispatchQueueUpdateEvent();
57
57
  }
58
58
  _dispatchQueueUpdateEvent() {
59
- $(
59
+ x(
60
60
  this,
61
61
  S,
62
62
  this._toasts
@@ -113,23 +113,25 @@ const C = "pie-toast-provider", l = class l extends P(_) {
113
113
  render() {
114
114
  const { _currentToast: t, _dismissToast: e } = this;
115
115
  return u`
116
- <div class="c-toast-provider" data-test-id="pie-toast-provider">
117
- ${t && u`
118
- <pie-toast
119
- message="${t.message}"
120
- variant="${y(t.variant)}"
121
- ?isStrong="${t.isStrong}"
122
- ?isDismissible="${t.isDismissible}"
123
- ?isMultiline="${t.isMultiline}"
124
- .leadingAction="${t.leadingAction}"
125
- .duration="${typeof t.duration > "u" ? T : t.duration}"
126
- @pie-toast-close="${e}"
127
- @pie-toast-open="${t.onPieToastOpen}"
128
- @pie-toast-leading-action-click="${t.onPieToastLeadingActionClick}">
129
- </pie-toast>
116
+ <div
117
+ class="c-toast-provider"
118
+ data-test-id="pie-toast-provider">
119
+ ${t && u`
120
+ <pie-toast
121
+ message="${t.message}"
122
+ variant="${y(t.variant)}"
123
+ ?isStrong="${t.isStrong}"
124
+ ?isDismissible="${t.isDismissible}"
125
+ ?isMultiline="${t.isMultiline}"
126
+ .leadingAction="${t.leadingAction}"
127
+ .duration="${typeof t.duration > "u" ? T : t.duration}"
128
+ @pie-toast-close="${e}"
129
+ @pie-toast-open="${t.onPieToastOpen}"
130
+ @pie-toast-leading-action-click="${t.onPieToastLeadingActionClick}">
131
+ </pie-toast>
130
132
  `}
131
- </div>
132
- `;
133
+ </div>
134
+ `;
133
135
  }
134
136
  };
135
137
  l.styles = g(A);
@@ -143,11 +145,11 @@ p([
143
145
  p([
144
146
  f({ type: Object })
145
147
  ], a.prototype, "options");
146
- b(C, a);
148
+ $(C, a);
147
149
  export {
148
150
  S as ON_TOAST_PROVIDER_QUEUE_UPDATE_EVENT,
149
151
  O as PRIORITY_ORDER,
150
152
  a as PieToastProvider,
151
153
  D as defaultProps,
152
- q as toaster
154
+ k as toaster
153
155
  };
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.3.2",
4
+ "version": "0.4.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/justeattakeaway/pie",
package/src/defs-react.ts CHANGED
@@ -1,8 +1,3 @@
1
1
  import type React from 'react';
2
- /**
3
- * TODO: Verify if ReactBaseType can be set as a more specific React interface
4
- * Use the React IntrinsicElements interface to find how to map standard HTML elements to existing React Interfaces
5
- * Example: an HTML button maps to `React.ButtonHTMLAttributes<HTMLButtonElement>`
6
- * https://github.com/DefinitelyTyped/DefinitelyTyped/blob/0bb210867d16170c4a08d9ce5d132817651a0f80/types/react/index.d.ts#L2829
7
- */
2
+
8
3
  export type ReactBaseType = React.HTMLAttributes<HTMLElement>
package/src/index.ts CHANGED
@@ -121,24 +121,26 @@ export class PieToastProvider extends RtlMixin(PieElement) implements ToastProvi
121
121
  const { _currentToast, _dismissToast } = this;
122
122
 
123
123
  return html`
124
- <div class="c-toast-provider" data-test-id="pie-toast-provider">
125
- ${_currentToast &&
126
- html`
127
- <pie-toast
128
- message="${_currentToast.message}"
129
- variant="${ifDefined(_currentToast.variant)}"
130
- ?isStrong="${_currentToast.isStrong}"
131
- ?isDismissible="${_currentToast.isDismissible}"
132
- ?isMultiline="${_currentToast.isMultiline}"
133
- .leadingAction="${_currentToast.leadingAction}"
134
- .duration="${typeof _currentToast.duration === 'undefined' ? nothing : _currentToast.duration}"
135
- @pie-toast-close="${_dismissToast}"
136
- @pie-toast-open="${_currentToast.onPieToastOpen}"
137
- @pie-toast-leading-action-click="${_currentToast.onPieToastLeadingActionClick}">
138
- </pie-toast>
124
+ <div
125
+ class="c-toast-provider"
126
+ data-test-id="pie-toast-provider">
127
+ ${_currentToast &&
128
+ html`
129
+ <pie-toast
130
+ message="${_currentToast.message}"
131
+ variant="${ifDefined(_currentToast.variant)}"
132
+ ?isStrong="${_currentToast.isStrong}"
133
+ ?isDismissible="${_currentToast.isDismissible}"
134
+ ?isMultiline="${_currentToast.isMultiline}"
135
+ .leadingAction="${_currentToast.leadingAction}"
136
+ .duration="${typeof _currentToast.duration === 'undefined' ? nothing : _currentToast.duration}"
137
+ @pie-toast-close="${_dismissToast}"
138
+ @pie-toast-open="${_currentToast.onPieToastOpen}"
139
+ @pie-toast-leading-action-click="${_currentToast.onPieToastLeadingActionClick}">
140
+ </pie-toast>
139
141
  `}
140
- </div>
141
- `;
142
+ </div>
143
+ `;
142
144
  }
143
145
 
144
146
  // Renders a `CSSResult` generated from SCSS by Vite
@@ -152,4 +154,3 @@ declare global {
152
154
  [componentSelector]: PieToastProvider;
153
155
  }
154
156
  }
155
-
@@ -1,6 +1,9 @@
1
1
  @use '@justeattakeaway/pie-css/scss' as p;
2
2
  @use '@justeattakeaway/pie-css/scss/settings' as *;
3
3
 
4
+ :host {
5
+ --toast-provider-z-index: var(--dt-z-index-toast);
6
+ }
4
7
 
5
8
  .c-toast-provider {
6
9
  --toast-provider-offset: var(--dt-spacing-d);
@@ -8,6 +11,7 @@
8
11
  position: absolute;
9
12
  inset-inline-start: var(--toast-provider-offset);
10
13
  inset-block-end: var(--toast-provider-offset);
14
+ z-index: var(--toast-provider-z-index);
11
15
 
12
16
  @include media('>md') {
13
17
  --toast-offset: var(--dt-spacing-e);