@justeattakeaway/pie-toast 0.3.2 → 0.3.4
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 +81 -81
- package/dist/react.js +14 -25
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { LitElement as
|
|
2
|
-
import { property as h, query as
|
|
3
|
-
import { classMap as
|
|
4
|
-
import { RtlMixin as
|
|
1
|
+
import { LitElement as w, unsafeCSS as O, html as c, nothing as l } from "lit";
|
|
2
|
+
import { property as h, query as A } from "lit/decorators.js";
|
|
3
|
+
import { classMap as $ } from "lit/directives/class-map.js";
|
|
4
|
+
import { RtlMixin as M, dispatchCustomEvent as f, validPropertyValues as k, defineCustomElement as B } from "@justeattakeaway/pie-webc-core";
|
|
5
5
|
import "@justeattakeaway/pie-icon-button";
|
|
6
6
|
import "@justeattakeaway/pie-icons-webc/dist/IconClose.js";
|
|
7
7
|
import "@justeattakeaway/pie-icons-webc/dist/IconInfoCircle.js";
|
|
@@ -9,20 +9,19 @@ import "@justeattakeaway/pie-icons-webc/dist/IconAlertCircle.js";
|
|
|
9
9
|
import "@justeattakeaway/pie-icons-webc/dist/IconAlertTriangle.js";
|
|
10
10
|
import "@justeattakeaway/pie-icons-webc/dist/IconCheckCircle.js";
|
|
11
11
|
import "@justeattakeaway/pie-button";
|
|
12
|
-
const C =
|
|
13
|
-
`, _ = ["neutral", "info", "warning", "success", "error"], i = "pie-toast", a = "c-toast", N = `${i}-close`, k = `${i}-open`, I = `${i}-leading-action-click`, g = {
|
|
12
|
+
const C = "*,*:after,*:before{box-sizing:inherit}.c-toast{--toast-border-radius: var(--dt-radius-rounded-b);--toast-background-color: var(--dt-color-container-inverse);--toast-font-color: var(--dt-color-content-inverse);--toast-font-size: calc(var(--dt-font-body-s-size) * 1px);--toast-line-height: calc(var(--dt-font-body-s-line-height) * 1px);--toast-icon-fill: var(--dt-color-content-default);--toast-message-max-width: 100%;display:flex;flex-direction:column;justify-content:center;min-height:48px;max-height:122px;min-width:300px;max-width:420px;padding:var(--dt-spacing-a) var(--dt-spacing-c) var(--dt-spacing-a) var(--dt-spacing-d);border-radius:var(--toast-border-radius);gap:var(--dt-spacing-a);background-color:var(--toast-background-color);box-shadow:var(--dt-elevation-03);color:var(--toast-font-color);font-size:var(--toast-font-size);line-height:var(--toast-line-height)}.c-toast--info{--toast-icon-fill: var(--dt-color-support-info-inverse)}.c-toast--info.c-toast--strong{--toast-background-color: var(--dt-color-support-info);--toast-icon-fill: var(--dt-color-content-inverse)}.c-toast--warning{--toast-icon-fill: var(--dt-color-support-warning-inverse)}.c-toast--warning.c-toast--strong{--toast-background-color: var(--dt-color-support-warning);--toast-icon-fill: var(--dt-color-content-dark);--toast-font-color: var(--dt-color-content-dark)}.c-toast--success{--toast-icon-fill: var(--dt-color-support-positive-inverse)}.c-toast--success.c-toast--strong{--toast-background-color: var(--dt-color-support-positive);--toast-icon-fill: var(--dt-color-content-inverse)}.c-toast--error{--toast-icon-fill: var(--dt-color-support-error-inverse)}.c-toast--error.c-toast--strong{--toast-background-color: var(--dt-color-support-error);--toast-icon-fill: var(--dt-color-content-inverse)}.c-toast-contentArea{display:flex;gap:var(--dt-spacing-b);justify-content:space-between}.c-toast-messageArea{display:flex;align-items:center;gap:var(--dt-spacing-b);padding:calc(var(--dt-spacing-03) / 2) 0}.c-toast-messageArea span{text-overflow:ellipsis;white-space:nowrap;overflow:hidden;max-width:var(--toast-message-max-width)}.c-toast-messageArea.c-toast--multiline{align-items:flex-start}.c-toast-messageArea.c-toast--multiline span{max-height:60px;white-space:inherit;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical}.c-toast-actionsArea{display:flex;gap:var(--dt-spacing-b)}.c-toast-footer{display:flex;justify-content:flex-end}.c-toast-icon{color:var(--toast-icon-fill)}", N = ["neutral", "info", "warning", "success", "error"], s = "pie-toast", e = "c-toast", I = `${s}-close`, S = `${s}-open`, _ = `${s}-leading-action-click`, g = {
|
|
14
13
|
isOpen: !0,
|
|
15
14
|
variant: "neutral",
|
|
16
15
|
isStrong: !1,
|
|
17
16
|
isDismissible: !0,
|
|
18
17
|
isMultiline: !1
|
|
19
18
|
};
|
|
20
|
-
var
|
|
21
|
-
for (var
|
|
22
|
-
(
|
|
23
|
-
return
|
|
19
|
+
var E = Object.defineProperty, d = (m, t, i, n) => {
|
|
20
|
+
for (var r = void 0, o = m.length - 1, p; o >= 0; o--)
|
|
21
|
+
(p = m[o]) && (r = p(t, i, r) || r);
|
|
22
|
+
return r && E(t, i, r), r;
|
|
24
23
|
};
|
|
25
|
-
class
|
|
24
|
+
const v = class v extends M(w) {
|
|
26
25
|
constructor() {
|
|
27
26
|
super(...arguments), this.message = "", this.isOpen = g.isOpen, this.variant = g.variant, this.isStrong = g.isStrong, this.isDismissible = g.isDismissible, this.isMultiline = g.isMultiline, this._actionButtonOffset = 0, this._messageAreaMaxWidth = 0;
|
|
28
27
|
}
|
|
@@ -36,9 +35,9 @@ class r extends A(y) {
|
|
|
36
35
|
*
|
|
37
36
|
* @returns {number} - The width of the message in pixels.
|
|
38
37
|
*/
|
|
39
|
-
getMessageMaxWidth(t,
|
|
38
|
+
getMessageMaxWidth(t, i, n, r) {
|
|
40
39
|
let u = 0;
|
|
41
|
-
return t && (u +=
|
|
40
|
+
return t && (u += 28), !i && n && (u += this._actionButtonOffset + 8), r && (u += 40), 392 - u;
|
|
42
41
|
}
|
|
43
42
|
/**
|
|
44
43
|
* Lifecycle method executed when component is updated.
|
|
@@ -46,10 +45,10 @@ class r extends A(y) {
|
|
|
46
45
|
* It calculates _messageAreaMaxWidth
|
|
47
46
|
*/
|
|
48
47
|
async updated(t) {
|
|
49
|
-
var
|
|
50
|
-
t.has("isOpen") && this.isOpen &&
|
|
51
|
-
const
|
|
52
|
-
this._messageAreaMaxWidth = this.getMessageMaxWidth(
|
|
48
|
+
var n;
|
|
49
|
+
t.has("isOpen") && this.isOpen && f(this, S, { targetNotification: this }), await this.updateComplete, this.actionButton && (this._actionButtonOffset = this.actionButton.offsetWidth);
|
|
50
|
+
const i = this.variantHasIcon(this.variant);
|
|
51
|
+
this._messageAreaMaxWidth = this.getMessageMaxWidth(i, this.isMultiline, !!((n = this.leadingAction) != null && n.text), this.isDismissible), (t.has("variant") || t.has("isStrong") || t.has("message") || t.has("isDismissible") || t.has("isMultiline") || t.has("leadingAction")) && this.requestUpdate();
|
|
53
52
|
}
|
|
54
53
|
/**
|
|
55
54
|
* It handle the action button action.
|
|
@@ -57,7 +56,7 @@ class r extends A(y) {
|
|
|
57
56
|
* @private
|
|
58
57
|
*/
|
|
59
58
|
handleActionClick() {
|
|
60
|
-
|
|
59
|
+
f(this, _, { targetNotification: this });
|
|
61
60
|
}
|
|
62
61
|
/**
|
|
63
62
|
* Render the action button depending on action type and its action.
|
|
@@ -68,16 +67,16 @@ class r extends A(y) {
|
|
|
68
67
|
* @private
|
|
69
68
|
*/
|
|
70
69
|
renderActionButton(t) {
|
|
71
|
-
const { text:
|
|
70
|
+
const { text: i, ariaLabel: n } = t;
|
|
72
71
|
return c`
|
|
73
72
|
<pie-button
|
|
74
73
|
variant="${this.shouldNotUseInverseBtnVariant() ? "ghost" : "ghost-inverse"}"
|
|
75
74
|
size="xsmall"
|
|
76
|
-
aria-label="${
|
|
75
|
+
aria-label="${n || l}"
|
|
77
76
|
@click="${() => this.handleActionClick()}"
|
|
78
|
-
data-test-id="${
|
|
77
|
+
data-test-id="${s}-leading-action"
|
|
79
78
|
type="button">
|
|
80
|
-
${
|
|
79
|
+
${i}
|
|
81
80
|
</pie-button>
|
|
82
81
|
`;
|
|
83
82
|
}
|
|
@@ -91,7 +90,7 @@ class r extends A(y) {
|
|
|
91
90
|
renderFooter() {
|
|
92
91
|
const { leadingAction: t } = this;
|
|
93
92
|
return c`
|
|
94
|
-
<footer class="${
|
|
93
|
+
<footer class="${e}-footer" data-test-id="${s}-footer" >
|
|
95
94
|
${t ? this.renderActionButton(t) : l}
|
|
96
95
|
</footer>
|
|
97
96
|
`;
|
|
@@ -107,7 +106,7 @@ class r extends A(y) {
|
|
|
107
106
|
<pie-icon-button
|
|
108
107
|
variant="${this.shouldNotUseInverseBtnVariant() ? "ghost-secondary" : "ghost-inverse"}"
|
|
109
108
|
size="xsmall"
|
|
110
|
-
data-test-id="${
|
|
109
|
+
data-test-id="${s}-close"
|
|
111
110
|
@click="${this.closeToastComponent}">
|
|
112
111
|
<icon-close></icon-close>
|
|
113
112
|
</pie-icon-button>`;
|
|
@@ -121,9 +120,9 @@ class r extends A(y) {
|
|
|
121
120
|
*
|
|
122
121
|
* @private
|
|
123
122
|
*/
|
|
124
|
-
renderMessage(t,
|
|
123
|
+
renderMessage(t, i) {
|
|
125
124
|
return c`
|
|
126
|
-
<span style="--toast-message-max-width: ${
|
|
125
|
+
<span style="--toast-message-max-width: ${i}px" data-test-id="${s}-message">
|
|
127
126
|
${t}
|
|
128
127
|
</span>
|
|
129
128
|
`;
|
|
@@ -135,7 +134,7 @@ class r extends A(y) {
|
|
|
135
134
|
* @private
|
|
136
135
|
*/
|
|
137
136
|
closeToastComponent() {
|
|
138
|
-
this.isOpen = !1,
|
|
137
|
+
this.isOpen = !1, f(this, I, { targetNotification: this });
|
|
139
138
|
}
|
|
140
139
|
/**
|
|
141
140
|
* Util method that returns an icon from a variant that has default icon.
|
|
@@ -145,13 +144,13 @@ class r extends A(y) {
|
|
|
145
144
|
getVariantIcon() {
|
|
146
145
|
switch (this.variant) {
|
|
147
146
|
case "info":
|
|
148
|
-
return c`<icon-info-circle class="${
|
|
147
|
+
return c`<icon-info-circle class="${e}-icon" size="s" data-test-id="${s}-heading-icon-info"></icon-info-circle>`;
|
|
149
148
|
case "success":
|
|
150
|
-
return c`<icon-check-circle class="${
|
|
149
|
+
return c`<icon-check-circle class="${e}-icon" size="s" data-test-id="${s}-heading-icon-success"></icon-check-circle>`;
|
|
151
150
|
case "warning":
|
|
152
|
-
return c`<icon-alert-triangle class="${
|
|
151
|
+
return c`<icon-alert-triangle class="${e}-icon" size="s" data-test-id="${s}-heading-icon-warning"></icon-alert-triangle>`;
|
|
153
152
|
case "error":
|
|
154
|
-
return c`<icon-alert-circle class="${
|
|
153
|
+
return c`<icon-alert-circle class="${e}-icon" size="s" data-test-id="${s}-heading-icon-error"></icon-alert-circle>`;
|
|
155
154
|
default:
|
|
156
155
|
return l;
|
|
157
156
|
}
|
|
@@ -177,74 +176,75 @@ class r extends A(y) {
|
|
|
177
176
|
render() {
|
|
178
177
|
const {
|
|
179
178
|
isOpen: t,
|
|
180
|
-
variant:
|
|
181
|
-
message:
|
|
182
|
-
isDismissible:
|
|
183
|
-
leadingAction:
|
|
184
|
-
isMultiline:
|
|
185
|
-
isStrong:
|
|
186
|
-
_messageAreaMaxWidth:
|
|
179
|
+
variant: i,
|
|
180
|
+
message: n,
|
|
181
|
+
isDismissible: r,
|
|
182
|
+
leadingAction: o,
|
|
183
|
+
isMultiline: p,
|
|
184
|
+
isStrong: x,
|
|
185
|
+
_messageAreaMaxWidth: b
|
|
187
186
|
} = this;
|
|
188
187
|
if (!t)
|
|
189
188
|
return l;
|
|
190
189
|
const u = {
|
|
191
|
-
[
|
|
192
|
-
[`${
|
|
193
|
-
[`${
|
|
194
|
-
},
|
|
195
|
-
[`${
|
|
196
|
-
[`${
|
|
190
|
+
[e]: !0,
|
|
191
|
+
[`${e}--${i}`]: !0,
|
|
192
|
+
[`${e}--strong`]: x
|
|
193
|
+
}, y = {
|
|
194
|
+
[`${e}-messageArea`]: !0,
|
|
195
|
+
[`${e}--multiline`]: p
|
|
197
196
|
};
|
|
198
197
|
return c`
|
|
199
|
-
<div data-test-id="${
|
|
200
|
-
<div class="${
|
|
201
|
-
<div class="${
|
|
202
|
-
${this.variantHasIcon(
|
|
203
|
-
${
|
|
198
|
+
<div data-test-id="${s}" class="${$(u)}">
|
|
199
|
+
<div class="${e}-contentArea">
|
|
200
|
+
<div class="${$(y)}">
|
|
201
|
+
${this.variantHasIcon(i) ? this.getVariantIcon() : l}
|
|
202
|
+
${n === "" ? l : this.renderMessage(n, b)}
|
|
204
203
|
</div>
|
|
205
|
-
<div class="${
|
|
206
|
-
${!
|
|
207
|
-
${
|
|
204
|
+
<div class="${e}-actionsArea">
|
|
205
|
+
${!p && (o != null && o.text) ? this.renderActionButton(o) : l}
|
|
206
|
+
${r ? this.renderCloseButton() : l}
|
|
208
207
|
</div>
|
|
209
208
|
</div>
|
|
210
|
-
${
|
|
209
|
+
${p && (o != null && o.text) ? this.renderFooter() : l}
|
|
211
210
|
</div>`;
|
|
212
211
|
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
|
|
212
|
+
};
|
|
213
|
+
v.styles = O(C);
|
|
214
|
+
let a = v;
|
|
215
|
+
d([
|
|
216
216
|
h()
|
|
217
|
-
],
|
|
218
|
-
|
|
217
|
+
], a.prototype, "message");
|
|
218
|
+
d([
|
|
219
219
|
h({ type: Boolean })
|
|
220
|
-
],
|
|
221
|
-
|
|
220
|
+
], a.prototype, "isOpen");
|
|
221
|
+
d([
|
|
222
222
|
h(),
|
|
223
|
-
|
|
224
|
-
],
|
|
225
|
-
|
|
223
|
+
k(s, N, g.variant)
|
|
224
|
+
], a.prototype, "variant");
|
|
225
|
+
d([
|
|
226
226
|
h({ type: Boolean })
|
|
227
|
-
],
|
|
228
|
-
|
|
227
|
+
], a.prototype, "isStrong");
|
|
228
|
+
d([
|
|
229
229
|
h({ type: Boolean })
|
|
230
|
-
],
|
|
231
|
-
|
|
230
|
+
], a.prototype, "isDismissible");
|
|
231
|
+
d([
|
|
232
232
|
h({ type: Boolean })
|
|
233
|
-
],
|
|
234
|
-
|
|
233
|
+
], a.prototype, "isMultiline");
|
|
234
|
+
d([
|
|
235
235
|
h({ type: Object })
|
|
236
|
-
],
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
],
|
|
240
|
-
B(
|
|
236
|
+
], a.prototype, "leadingAction");
|
|
237
|
+
d([
|
|
238
|
+
A("pie-button")
|
|
239
|
+
], a.prototype, "actionButton");
|
|
240
|
+
B(s, a);
|
|
241
241
|
export {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
242
|
+
I as ON_TOAST_CLOSE_EVENT,
|
|
243
|
+
_ as ON_TOAST_LEADING_ACTION_CLICK_EVENT,
|
|
244
|
+
S as ON_TOAST_OPEN_EVENT,
|
|
245
|
+
a as PieToast,
|
|
246
|
+
e as componentClass,
|
|
247
|
+
s as componentSelector,
|
|
248
248
|
g as defaultProps,
|
|
249
|
-
|
|
249
|
+
N as variants
|
|
250
250
|
};
|
package/dist/react.js
CHANGED
|
@@ -1,32 +1,21 @@
|
|
|
1
1
|
import * as t from "react";
|
|
2
|
-
import { createComponent as
|
|
3
|
-
import { PieToast as
|
|
4
|
-
import { ON_TOAST_CLOSE_EVENT as
|
|
5
|
-
|
|
6
|
-
import "lit/decorators.js";
|
|
7
|
-
import "lit/directives/class-map.js";
|
|
8
|
-
import "@justeattakeaway/pie-webc-core";
|
|
9
|
-
import "@justeattakeaway/pie-icon-button";
|
|
10
|
-
import "@justeattakeaway/pie-icons-webc/dist/IconClose.js";
|
|
11
|
-
import "@justeattakeaway/pie-icons-webc/dist/IconInfoCircle.js";
|
|
12
|
-
import "@justeattakeaway/pie-icons-webc/dist/IconAlertCircle.js";
|
|
13
|
-
import "@justeattakeaway/pie-icons-webc/dist/IconAlertTriangle.js";
|
|
14
|
-
import "@justeattakeaway/pie-icons-webc/dist/IconCheckCircle.js";
|
|
15
|
-
import "@justeattakeaway/pie-button";
|
|
16
|
-
const r = o({
|
|
2
|
+
import { createComponent as e } from "@lit/react";
|
|
3
|
+
import { PieToast as o } from "./index.js";
|
|
4
|
+
import { ON_TOAST_CLOSE_EVENT as n, ON_TOAST_LEADING_ACTION_CLICK_EVENT as p, ON_TOAST_OPEN_EVENT as N, componentClass as _, componentSelector as c, defaultProps as E, variants as O } from "./index.js";
|
|
5
|
+
const a = e({
|
|
17
6
|
displayName: "PieToast",
|
|
18
|
-
elementClass:
|
|
7
|
+
elementClass: o,
|
|
19
8
|
react: t,
|
|
20
9
|
tagName: "pie-toast",
|
|
21
10
|
events: {}
|
|
22
|
-
}),
|
|
11
|
+
}), r = a;
|
|
23
12
|
export {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
13
|
+
n as ON_TOAST_CLOSE_EVENT,
|
|
14
|
+
p as ON_TOAST_LEADING_ACTION_CLICK_EVENT,
|
|
15
|
+
N as ON_TOAST_OPEN_EVENT,
|
|
16
|
+
r as PieToast,
|
|
17
|
+
_ as componentClass,
|
|
18
|
+
c as componentSelector,
|
|
19
|
+
E as defaultProps,
|
|
20
|
+
O as variants
|
|
32
21
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justeattakeaway/pie-toast",
|
|
3
3
|
"description": "PIE Design System Toast built using Web Components",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.4",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -37,14 +37,14 @@
|
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@custom-elements-manifest/analyzer": "0.9.0",
|
|
39
39
|
"@justeattakeaway/pie-components-config": "0.18.0",
|
|
40
|
-
"@justeattakeaway/pie-css": "0.
|
|
40
|
+
"@justeattakeaway/pie-css": "0.13.0",
|
|
41
41
|
"cem-plugin-module-file-extensions": "0.0.5"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@justeattakeaway/pie-button": "0.49.
|
|
45
|
-
"@justeattakeaway/pie-icon-button": "0.28.
|
|
46
|
-
"@justeattakeaway/pie-icons-webc": "0.25.
|
|
47
|
-
"@justeattakeaway/pie-webc-core": "0.24.
|
|
44
|
+
"@justeattakeaway/pie-button": "0.49.2",
|
|
45
|
+
"@justeattakeaway/pie-icon-button": "0.28.13",
|
|
46
|
+
"@justeattakeaway/pie-icons-webc": "0.25.2",
|
|
47
|
+
"@justeattakeaway/pie-webc-core": "0.24.1"
|
|
48
48
|
},
|
|
49
49
|
"volta": {
|
|
50
50
|
"extends": "../../../package.json"
|