@justeattakeaway/pie-toast-provider 0.6.3 → 0.7.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/custom-elements.json +0 -6
- package/dist/index.d.ts +1 -5
- package/dist/index.js +57 -59
- package/dist/react.d.ts +1 -5
- package/package.json +5 -5
- package/src/index.ts +1 -4
- package/src/toast-provider.scss +1 -1
package/custom-elements.json
CHANGED
|
@@ -200,12 +200,6 @@
|
|
|
200
200
|
"name": "pie-toast-provider-queue-update"
|
|
201
201
|
}
|
|
202
202
|
],
|
|
203
|
-
"mixins": [
|
|
204
|
-
{
|
|
205
|
-
"name": "RtlMixin",
|
|
206
|
-
"package": "@justeattakeaway/pie-webc-core"
|
|
207
|
-
}
|
|
208
|
-
],
|
|
209
203
|
"superclass": {
|
|
210
204
|
"name": "PieElement",
|
|
211
205
|
"package": "@justeattakeaway/pie-webc-core/src/internals/PieElement"
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { ComponentDefaultProps } from '@justeattakeaway/pie-webc-core';
|
|
2
2
|
import { CSSResult } from 'lit';
|
|
3
|
-
import { GenericConstructor } from '@justeattakeaway/pie-webc-core';
|
|
4
3
|
import { PieElement } from '@justeattakeaway/pie-webc-core/src/internals/PieElement';
|
|
5
4
|
import { PropertyValues } from 'lit';
|
|
6
|
-
import { RTLInterface } from '@justeattakeaway/pie-webc-core';
|
|
7
5
|
import { TemplateResult } from 'lit-html';
|
|
8
6
|
import { ToastProps } from '@justeattakeaway/pie-toast';
|
|
9
7
|
|
|
@@ -37,7 +35,7 @@ export declare const ON_TOAST_PROVIDER_QUEUE_UPDATE_EVENT = "pie-toast-provider-
|
|
|
37
35
|
* @tagname pie-toast-provider
|
|
38
36
|
* @event {CustomEvent} pie-toast-provider-queue-update - when a toast is added or removed from the queue.
|
|
39
37
|
*/
|
|
40
|
-
export declare class PieToastProvider extends
|
|
38
|
+
export declare class PieToastProvider extends PieElement implements ToastProviderProps {
|
|
41
39
|
options: Partial<ExtendedToastProps>;
|
|
42
40
|
position: "default" | "bottom-left" | "bottom-right" | "bottom-center";
|
|
43
41
|
private _toasts;
|
|
@@ -73,8 +71,6 @@ export declare class PieToastProvider extends PieToastProvider_base implements T
|
|
|
73
71
|
static styles: CSSResult;
|
|
74
72
|
}
|
|
75
73
|
|
|
76
|
-
declare const PieToastProvider_base: GenericConstructor<RTLInterface> & typeof PieElement;
|
|
77
|
-
|
|
78
74
|
export declare const positions: readonly ["default", "bottom-left", "bottom-right", "bottom-center"];
|
|
79
75
|
|
|
80
76
|
export declare type Priority = keyof typeof PRIORITY_ORDER;
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { LitElement as g,
|
|
1
|
+
import { LitElement as g, unsafeCSS as T, nothing as b, html as u } from "lit";
|
|
2
2
|
import { property as h, state as _ } from "lit/decorators.js";
|
|
3
3
|
import { ifDefined as y } from "lit/directives/if-defined.js";
|
|
4
4
|
import { classMap as m } from "lit/directives/class-map.js";
|
|
5
|
-
import {
|
|
5
|
+
import { validPropertyValues as P, safeCustomElement as $, dispatchCustomEvent as x } from "@justeattakeaway/pie-webc-core";
|
|
6
6
|
import { defaultProps as f } from "@justeattakeaway/pie-toast";
|
|
7
7
|
const l = class l extends g {
|
|
8
8
|
willUpdate() {
|
|
9
9
|
this.getAttribute("v") || this.setAttribute("v", l.v);
|
|
10
10
|
}
|
|
11
11
|
};
|
|
12
|
-
l.v = "0.
|
|
12
|
+
l.v = "0.7.0";
|
|
13
13
|
let d = l;
|
|
14
|
-
const
|
|
14
|
+
const A = "*,*:after,*:before{box-sizing:inherit}:root{--pie-animation-slide-translate-start: -100%}.pie-animation--slide-in{animation:pie-animation-slide-in var(--dt-motion-timing-200) var(--dt-motion-easing-out)}.pie-animation--slide-out{animation:pie-animation-slide-out var(--dt-motion-timing-100) var(--dt-motion-easing-in)}@keyframes pie-animation-slide-in{0%{transform:translate(var(--pie-animation-slide-translate-start))}to{transform:translate(0)}}@keyframes pie-animation-slide-out{0%{transform:translate(0)}to{transform:translate(var(--pie-animation-slide-translate-start))}}:host{--toast-provider-z-index: var(--dt-z-index-toast);--toast-provider-offset: var(--dt-spacing-d)}@media (min-width: 769px){:host{--toast-provider-offset: var(--dt-spacing-e)}}.c-toast-provider{position:fixed;z-index:var(--toast-provider-z-index)}.c-toast-provider.c-toast-provider--default{inset-inline-start:var(--toast-provider-offset);inset-block-end:var(--toast-provider-offset)}.c-toast-provider.c-toast-provider--default:dir(rtl){--pie-animation-slide-translate-start: 100%}.c-toast-provider.c-toast-provider--bottom-left{--pie-animation-slide-translate-start: -100%;left:var(--toast-provider-offset);bottom:var(--toast-provider-offset)}.c-toast-provider.c-toast-provider--bottom-right{--pie-animation-slide-translate-start: 100%;right:var(--toast-provider-offset);bottom:var(--toast-provider-offset)}.c-toast-provider.c-toast-provider--bottom-center{--pie-animation-slide-translate-start: 0, 100%;left:50%;bottom:var(--toast-provider-offset);transform:translate(-50%)}", O = {
|
|
15
15
|
"error-actionable": 1,
|
|
16
16
|
error: 2,
|
|
17
17
|
"warning-actionable": 3,
|
|
@@ -22,40 +22,40 @@ const O = "*,*:after,*:before{box-sizing:inherit}:root{--pie-animation-slide-tra
|
|
|
22
22
|
success: 8,
|
|
23
23
|
info: 9,
|
|
24
24
|
neutral: 10
|
|
25
|
-
},
|
|
25
|
+
}, w = ["default", "bottom-left", "bottom-right", "bottom-center"], c = {
|
|
26
26
|
options: {},
|
|
27
27
|
position: "default"
|
|
28
|
-
},
|
|
28
|
+
}, D = "pie-toast-provider-queue-update", j = {
|
|
29
29
|
_getToastProvider() {
|
|
30
|
-
const
|
|
31
|
-
return
|
|
30
|
+
const o = document.querySelectorAll("pie-toast-provider");
|
|
31
|
+
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];
|
|
32
32
|
},
|
|
33
|
-
create(
|
|
34
|
-
const
|
|
35
|
-
|
|
33
|
+
create(o) {
|
|
34
|
+
const t = this._getToastProvider();
|
|
35
|
+
t && t.createToast(o);
|
|
36
36
|
},
|
|
37
37
|
clearAll() {
|
|
38
|
-
const
|
|
39
|
-
|
|
38
|
+
const o = this._getToastProvider();
|
|
39
|
+
o && o.clearToasts();
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
|
-
var
|
|
43
|
-
for (var
|
|
44
|
-
(a =
|
|
45
|
-
return
|
|
42
|
+
var E = Object.defineProperty, S = Object.getOwnPropertyDescriptor, n = (o, t, e, i) => {
|
|
43
|
+
for (var s = i > 1 ? void 0 : i ? S(t, e) : t, p = o.length - 1, a; p >= 0; p--)
|
|
44
|
+
(a = o[p]) && (s = (i ? a(t, e, s) : a(s)) || s);
|
|
45
|
+
return i && s && E(t, e, s), s;
|
|
46
46
|
};
|
|
47
47
|
const C = "pie-toast-provider";
|
|
48
|
-
let r = class extends
|
|
48
|
+
let r = class extends d {
|
|
49
49
|
constructor() {
|
|
50
50
|
super(...arguments), this.options = c.options, this.position = c.position, this._toasts = [], this._currentToast = null;
|
|
51
51
|
}
|
|
52
|
-
updated(
|
|
53
|
-
|
|
52
|
+
updated(o) {
|
|
53
|
+
o.has("_toasts") && this._dispatchQueueUpdateEvent();
|
|
54
54
|
}
|
|
55
55
|
_dispatchQueueUpdateEvent() {
|
|
56
56
|
x(
|
|
57
57
|
this,
|
|
58
|
-
|
|
58
|
+
D,
|
|
59
59
|
this._toasts
|
|
60
60
|
);
|
|
61
61
|
}
|
|
@@ -65,16 +65,16 @@ let r = class extends P(d) {
|
|
|
65
65
|
* @param {boolean} hasAction - Whether the toast has an action.
|
|
66
66
|
* @returns {number} - The priority based on the variant and action.
|
|
67
67
|
*/
|
|
68
|
-
getPriority(
|
|
69
|
-
const
|
|
70
|
-
return
|
|
68
|
+
getPriority(o = f.variant, t = !1) {
|
|
69
|
+
const e = `${o}${t ? "-actionable" : ""}`;
|
|
70
|
+
return O[e];
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
73
73
|
* Handles the dismissal of the current toast and displays the next one in the queue (if any).
|
|
74
74
|
*/
|
|
75
75
|
_dismissToast() {
|
|
76
|
-
var
|
|
77
|
-
(
|
|
76
|
+
var o, t;
|
|
77
|
+
(t = (o = this._currentToast) == null ? void 0 : o.onPieToastClose) == null || t.call(o), this._currentToast = null, requestAnimationFrame(() => {
|
|
78
78
|
this._showNextToast();
|
|
79
79
|
});
|
|
80
80
|
}
|
|
@@ -83,8 +83,8 @@ let r = class extends P(d) {
|
|
|
83
83
|
*/
|
|
84
84
|
_showNextToast() {
|
|
85
85
|
if (this._toasts.length > 0) {
|
|
86
|
-
const [
|
|
87
|
-
this._currentToast =
|
|
86
|
+
const [o, ...t] = this._toasts;
|
|
87
|
+
this._currentToast = o, this._toasts = t;
|
|
88
88
|
} else
|
|
89
89
|
this._currentToast = null;
|
|
90
90
|
}
|
|
@@ -92,12 +92,12 @@ let r = class extends P(d) {
|
|
|
92
92
|
* Adds a new toast to the queue and triggers its display if no toast is currently active.
|
|
93
93
|
* @param {ToastProps} toast - The toast props to display.
|
|
94
94
|
*/
|
|
95
|
-
createToast(
|
|
96
|
-
const
|
|
97
|
-
this._toasts = [...this._toasts,
|
|
95
|
+
createToast(o) {
|
|
96
|
+
const t = { ...f, ...this.options, ...o };
|
|
97
|
+
this._toasts = [...this._toasts, t].sort((e, i) => {
|
|
98
98
|
var a, v;
|
|
99
|
-
const
|
|
100
|
-
return this.getPriority(
|
|
99
|
+
const s = this.getPriority(i.variant, !!((a = i.leadingAction) != null && a.text));
|
|
100
|
+
return this.getPriority(e.variant, !!((v = e.leadingAction) != null && v.text)) - s;
|
|
101
101
|
}), this._currentToast || this._showNextToast();
|
|
102
102
|
}
|
|
103
103
|
/**
|
|
@@ -109,47 +109,45 @@ let r = class extends P(d) {
|
|
|
109
109
|
}
|
|
110
110
|
render() {
|
|
111
111
|
const {
|
|
112
|
-
position:
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
} = this, s = {
|
|
112
|
+
position: o,
|
|
113
|
+
_currentToast: t
|
|
114
|
+
} = this, e = {
|
|
116
115
|
"c-toast-provider": !0,
|
|
117
|
-
[`c-toast-provider--${
|
|
118
|
-
"c-toast-provider--rtl": e
|
|
116
|
+
[`c-toast-provider--${o}`]: !0
|
|
119
117
|
}, i = {
|
|
120
|
-
"pie-animation--slide-in": !!
|
|
121
|
-
"pie-animation--slide-out":
|
|
118
|
+
"pie-animation--slide-in": !!t,
|
|
119
|
+
"pie-animation--slide-out": t === null
|
|
122
120
|
};
|
|
123
121
|
return u`
|
|
124
122
|
<div
|
|
125
|
-
class=${m(
|
|
123
|
+
class=${m(e)}
|
|
126
124
|
data-test-id="pie-toast-provider">
|
|
127
|
-
${
|
|
125
|
+
${t && u`
|
|
128
126
|
<pie-toast
|
|
129
127
|
class=${m(i)}
|
|
130
|
-
message="${
|
|
131
|
-
variant="${y(
|
|
132
|
-
?isStrong="${
|
|
133
|
-
?isDismissible="${
|
|
134
|
-
?isMultiline="${
|
|
135
|
-
.leadingAction="${
|
|
136
|
-
.duration="${typeof
|
|
128
|
+
message="${t.message}"
|
|
129
|
+
variant="${y(t.variant)}"
|
|
130
|
+
?isStrong="${t.isStrong}"
|
|
131
|
+
?isDismissible="${t.isDismissible}"
|
|
132
|
+
?isMultiline="${t.isMultiline}"
|
|
133
|
+
.leadingAction="${t.leadingAction}"
|
|
134
|
+
.duration="${typeof t.duration > "u" ? b : t.duration}"
|
|
137
135
|
@pie-toast-close="${this._dismissToast}"
|
|
138
|
-
@pie-toast-open="${
|
|
139
|
-
@pie-toast-leading-action-click="${
|
|
136
|
+
@pie-toast-open="${t.onPieToastOpen}"
|
|
137
|
+
@pie-toast-leading-action-click="${t.onPieToastLeadingActionClick}">
|
|
140
138
|
</pie-toast>
|
|
141
139
|
`}
|
|
142
140
|
</div>
|
|
143
141
|
`;
|
|
144
142
|
}
|
|
145
143
|
};
|
|
146
|
-
r.styles =
|
|
144
|
+
r.styles = T(A);
|
|
147
145
|
n([
|
|
148
146
|
h({ type: Object })
|
|
149
147
|
], r.prototype, "options", 2);
|
|
150
148
|
n([
|
|
151
149
|
h({ type: String }),
|
|
152
|
-
|
|
150
|
+
P(C, w, c.position)
|
|
153
151
|
], r.prototype, "position", 2);
|
|
154
152
|
n([
|
|
155
153
|
_()
|
|
@@ -158,13 +156,13 @@ n([
|
|
|
158
156
|
_()
|
|
159
157
|
], r.prototype, "_currentToast", 2);
|
|
160
158
|
r = n([
|
|
161
|
-
|
|
159
|
+
$("pie-toast-provider")
|
|
162
160
|
], r);
|
|
163
161
|
export {
|
|
164
|
-
|
|
165
|
-
|
|
162
|
+
D as ON_TOAST_PROVIDER_QUEUE_UPDATE_EVENT,
|
|
163
|
+
O as PRIORITY_ORDER,
|
|
166
164
|
r as PieToastProvider,
|
|
167
165
|
c as defaultProps,
|
|
168
|
-
|
|
169
|
-
|
|
166
|
+
w as positions,
|
|
167
|
+
j as toaster
|
|
170
168
|
};
|
package/dist/react.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { ComponentDefaultProps } from '@justeattakeaway/pie-webc-core';
|
|
2
2
|
import { CSSResult } from 'lit';
|
|
3
|
-
import { GenericConstructor } from '@justeattakeaway/pie-webc-core';
|
|
4
3
|
import { PieElement } from '@justeattakeaway/pie-webc-core/src/internals/PieElement';
|
|
5
4
|
import { PropertyValues } from 'lit';
|
|
6
5
|
import * as React_2 from 'react';
|
|
7
|
-
import { RTLInterface } from '@justeattakeaway/pie-webc-core';
|
|
8
6
|
import { TemplateResult } from 'lit-html';
|
|
9
7
|
import { ToastProps } from '@justeattakeaway/pie-toast';
|
|
10
8
|
|
|
@@ -40,7 +38,7 @@ export declare const PieToastProvider: React_2.ForwardRefExoticComponent<React_2
|
|
|
40
38
|
* @tagname pie-toast-provider
|
|
41
39
|
* @event {CustomEvent} pie-toast-provider-queue-update - when a toast is added or removed from the queue.
|
|
42
40
|
*/
|
|
43
|
-
declare class PieToastProvider_2 extends
|
|
41
|
+
declare class PieToastProvider_2 extends PieElement implements ToastProviderProps {
|
|
44
42
|
options: Partial<ExtendedToastProps>;
|
|
45
43
|
position: "default" | "bottom-left" | "bottom-right" | "bottom-center";
|
|
46
44
|
private _toasts;
|
|
@@ -76,8 +74,6 @@ declare class PieToastProvider_2 extends PieToastProvider_base implements ToastP
|
|
|
76
74
|
static styles: CSSResult;
|
|
77
75
|
}
|
|
78
76
|
|
|
79
|
-
declare const PieToastProvider_base: GenericConstructor<RTLInterface> & typeof PieElement;
|
|
80
|
-
|
|
81
77
|
declare type PieToastProviderEvents = {
|
|
82
78
|
onPieToastProviderQueueUpdate?: (event: CustomEvent) => void;
|
|
83
79
|
};
|
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
|
+
"version": "0.7.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/justeattakeaway/pie",
|
|
@@ -40,13 +40,13 @@
|
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@custom-elements-manifest/analyzer": "0.9.0",
|
|
42
42
|
"@justeattakeaway/pie-components-config": "0.21.0",
|
|
43
|
-
"@justeattakeaway/pie-css": "0.
|
|
44
|
-
"@justeattakeaway/pie-monorepo-utils": "0.
|
|
43
|
+
"@justeattakeaway/pie-css": "0.19.0",
|
|
44
|
+
"@justeattakeaway/pie-monorepo-utils": "0.7.0",
|
|
45
45
|
"cem-plugin-module-file-extensions": "0.0.5"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@justeattakeaway/pie-toast": "0.
|
|
49
|
-
"@justeattakeaway/pie-webc-core": "1.
|
|
48
|
+
"@justeattakeaway/pie-toast": "0.11.1",
|
|
49
|
+
"@justeattakeaway/pie-webc-core": "1.1.0"
|
|
50
50
|
},
|
|
51
51
|
"volta": {
|
|
52
52
|
"extends": "../../../package.json"
|
package/src/index.ts
CHANGED
|
@@ -9,7 +9,6 @@ import { state, property } from 'lit/decorators.js';
|
|
|
9
9
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
10
10
|
import { classMap } from 'lit/directives/class-map.js';
|
|
11
11
|
import {
|
|
12
|
-
RtlMixin,
|
|
13
12
|
dispatchCustomEvent,
|
|
14
13
|
safeCustomElement,
|
|
15
14
|
validPropertyValues,
|
|
@@ -37,7 +36,7 @@ const componentSelector = 'pie-toast-provider';
|
|
|
37
36
|
* @event {CustomEvent} pie-toast-provider-queue-update - when a toast is added or removed from the queue.
|
|
38
37
|
*/
|
|
39
38
|
@safeCustomElement('pie-toast-provider')
|
|
40
|
-
export class PieToastProvider extends
|
|
39
|
+
export class PieToastProvider extends PieElement implements ToastProviderProps {
|
|
41
40
|
@property({ type: Object })
|
|
42
41
|
public options = defaultProps.options;
|
|
43
42
|
|
|
@@ -128,14 +127,12 @@ export class PieToastProvider extends RtlMixin(PieElement) implements ToastProvi
|
|
|
128
127
|
render () {
|
|
129
128
|
const {
|
|
130
129
|
position,
|
|
131
|
-
isRTL,
|
|
132
130
|
_currentToast,
|
|
133
131
|
} = this;
|
|
134
132
|
|
|
135
133
|
const classes = {
|
|
136
134
|
'c-toast-provider': true,
|
|
137
135
|
[`c-toast-provider--${position}`]: true,
|
|
138
|
-
'c-toast-provider--rtl': isRTL,
|
|
139
136
|
};
|
|
140
137
|
|
|
141
138
|
const toastClasses = {
|