@justeattakeaway/pie-toast 0.4.2 → 0.4.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/custom-elements.json +5 -11
- package/dist/index.d.ts +4 -4
- package/dist/index.js +23 -22
- package/dist/react.d.ts +4 -4
- package/package.json +3 -3
- package/src/defs.ts +2 -1
- package/src/index.ts +10 -8
package/custom-elements.json
CHANGED
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"type": {
|
|
61
61
|
"text": "DefaultProps"
|
|
62
62
|
},
|
|
63
|
-
"default": "{\n isOpen: true,\n variant: 'neutral',\n isStrong: false,\n isDismissible: true,\n isMultiline: false,\n duration: 5000,\n}"
|
|
63
|
+
"default": "{\n message: '',\n isOpen: true,\n variant: 'neutral',\n isStrong: false,\n isDismissible: true,\n isMultiline: false,\n duration: 5000,\n}"
|
|
64
64
|
}
|
|
65
65
|
],
|
|
66
66
|
"exports": [
|
|
@@ -134,11 +134,7 @@
|
|
|
134
134
|
{
|
|
135
135
|
"kind": "field",
|
|
136
136
|
"name": "message",
|
|
137
|
-
"type": {
|
|
138
|
-
"text": "ToastProps['message']"
|
|
139
|
-
},
|
|
140
137
|
"privacy": "public",
|
|
141
|
-
"default": "''",
|
|
142
138
|
"attribute": "message"
|
|
143
139
|
},
|
|
144
140
|
{
|
|
@@ -191,14 +187,16 @@
|
|
|
191
187
|
"name": "actionButton",
|
|
192
188
|
"type": {
|
|
193
189
|
"text": "HTMLElement | undefined"
|
|
194
|
-
}
|
|
190
|
+
},
|
|
191
|
+
"privacy": "private"
|
|
195
192
|
},
|
|
196
193
|
{
|
|
197
194
|
"kind": "field",
|
|
198
195
|
"name": "closeButton",
|
|
199
196
|
"type": {
|
|
200
197
|
"text": "HTMLElement | undefined"
|
|
201
|
-
}
|
|
198
|
+
},
|
|
199
|
+
"privacy": "private"
|
|
202
200
|
},
|
|
203
201
|
{
|
|
204
202
|
"kind": "field",
|
|
@@ -438,10 +436,6 @@
|
|
|
438
436
|
"attributes": [
|
|
439
437
|
{
|
|
440
438
|
"name": "message",
|
|
441
|
-
"type": {
|
|
442
|
-
"text": "ToastProps['message']"
|
|
443
|
-
},
|
|
444
|
-
"default": "''",
|
|
445
439
|
"fieldName": "message"
|
|
446
440
|
},
|
|
447
441
|
{
|
package/dist/index.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export declare const componentClass = "c-toast";
|
|
|
21
21
|
|
|
22
22
|
export declare const componentSelector = "pie-toast";
|
|
23
23
|
|
|
24
|
-
export declare type DefaultProps = ComponentDefaultProps<ToastProps, keyof Omit<ToastProps, '
|
|
24
|
+
export declare type DefaultProps = ComponentDefaultProps<ToastProps, keyof Omit<ToastProps, 'leadingAction'>>;
|
|
25
25
|
|
|
26
26
|
export declare const defaultProps: DefaultProps;
|
|
27
27
|
|
|
@@ -50,7 +50,7 @@ export declare const ON_TOAST_OPEN_EVENT: string;
|
|
|
50
50
|
* @tagname pie-toast
|
|
51
51
|
*/
|
|
52
52
|
export declare class PieToast extends PieToast_base implements ToastProps {
|
|
53
|
-
message:
|
|
53
|
+
message: string;
|
|
54
54
|
isOpen: boolean;
|
|
55
55
|
variant: "neutral" | "info" | "warning" | "success" | "error";
|
|
56
56
|
isStrong: boolean;
|
|
@@ -58,8 +58,8 @@ export declare class PieToast extends PieToast_base implements ToastProps {
|
|
|
58
58
|
isMultiline: boolean;
|
|
59
59
|
leadingAction: ToastProps['leadingAction'];
|
|
60
60
|
duration: number | null;
|
|
61
|
-
actionButton
|
|
62
|
-
closeButton
|
|
61
|
+
private actionButton?;
|
|
62
|
+
private closeButton?;
|
|
63
63
|
private _actionButtonOffset;
|
|
64
64
|
private _messageAreaMaxWidth;
|
|
65
65
|
private _timeoutId;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LitElement as C, unsafeCSS as w, html as l, nothing as d } from "lit";
|
|
2
|
-
import { property as
|
|
2
|
+
import { property as p, query as y } from "lit/decorators.js";
|
|
3
3
|
import { classMap as $ } from "lit/directives/class-map.js";
|
|
4
4
|
import { RtlMixin as O, dispatchCustomEvent as f, validPropertyValues as E, defineCustomElement as _ } from "@justeattakeaway/pie-webc-core";
|
|
5
5
|
import "@justeattakeaway/pie-icon-button";
|
|
@@ -9,7 +9,8 @@ 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 k = "*,*: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);transition-property:all;transition-duration:var(--dt-motion-timing-100);transition-timing-function:var(--dt-motion-easing-in)}.c-toast--animate-in{animation-duration:var(--dt-motion-timing-200);animation-name:animate-in;animation-timing-function:var(--dt-motion-easing-in);transform:translate(0)}.c-toast--animate-out{animation-duration:var(--dt-motion-timing-100);animation-name:animate-out;animation-timing-function:var(--dt-motion-easing-out);transform:translate(100%);opacity:0}.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)}@keyframes animate-in{0%{transform:translate(100%)}to{transform:translate(0)}}@keyframes animate-out{0%{transform:translate(0)}to{transform:translate(100%)}}", B = ["neutral", "info", "warning", "success", "error"], o = "pie-toast", s = "c-toast", M = `${o}-close`, I = `${o}-open`, T = `${o}-leading-action-click`,
|
|
12
|
+
const k = "*,*: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);transition-property:all;transition-duration:var(--dt-motion-timing-100);transition-timing-function:var(--dt-motion-easing-in)}.c-toast--animate-in{animation-duration:var(--dt-motion-timing-200);animation-name:animate-in;animation-timing-function:var(--dt-motion-easing-in);transform:translate(0)}.c-toast--animate-out{animation-duration:var(--dt-motion-timing-100);animation-name:animate-out;animation-timing-function:var(--dt-motion-easing-out);transform:translate(100%);opacity:0}.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)}@keyframes animate-in{0%{transform:translate(100%)}to{transform:translate(0)}}@keyframes animate-out{0%{transform:translate(0)}to{transform:translate(100%)}}", B = ["neutral", "info", "warning", "success", "error"], o = "pie-toast", s = "c-toast", M = `${o}-close`, I = `${o}-open`, T = `${o}-leading-action-click`, u = {
|
|
13
|
+
message: "",
|
|
13
14
|
isOpen: !0,
|
|
14
15
|
variant: "neutral",
|
|
15
16
|
isStrong: !1,
|
|
@@ -18,13 +19,13 @@ const k = "*,*:after,*:before{box-sizing:inherit}.c-toast{--toast-border-radius:
|
|
|
18
19
|
duration: 5e3
|
|
19
20
|
};
|
|
20
21
|
var L = Object.defineProperty, c = (v, t, i, n) => {
|
|
21
|
-
for (var e = void 0, r = v.length - 1,
|
|
22
|
-
(
|
|
22
|
+
for (var e = void 0, r = v.length - 1, h; r >= 0; r--)
|
|
23
|
+
(h = v[r]) && (e = h(t, i, e) || e);
|
|
23
24
|
return e && L(t, i, e), e;
|
|
24
25
|
};
|
|
25
26
|
const g = class g extends O(C) {
|
|
26
27
|
constructor() {
|
|
27
|
-
super(...arguments), this.message =
|
|
28
|
+
super(...arguments), this.message = u.message, this.isOpen = u.isOpen, this.variant = u.variant, this.isStrong = u.isStrong, this.isDismissible = u.isDismissible, this.isMultiline = u.isMultiline, this.duration = u.duration, this._actionButtonOffset = 0, this._messageAreaMaxWidth = 0, this._timeoutId = null, this._abortController = null;
|
|
28
29
|
}
|
|
29
30
|
/**
|
|
30
31
|
* Create a timeout function and set its id into a private attribute.
|
|
@@ -230,7 +231,7 @@ const g = class g extends O(C) {
|
|
|
230
231
|
message: n,
|
|
231
232
|
isDismissible: e,
|
|
232
233
|
leadingAction: r,
|
|
233
|
-
isMultiline:
|
|
234
|
+
isMultiline: h,
|
|
234
235
|
isStrong: b,
|
|
235
236
|
_messageAreaMaxWidth: x
|
|
236
237
|
} = this, m = {
|
|
@@ -241,12 +242,12 @@ const g = class g extends O(C) {
|
|
|
241
242
|
[`${s}--animate-out`]: !t
|
|
242
243
|
}, A = {
|
|
243
244
|
[`${s}-messageArea`]: !0,
|
|
244
|
-
[`${s}--multiline`]:
|
|
245
|
+
[`${s}--multiline`]: h
|
|
245
246
|
};
|
|
246
247
|
return l`
|
|
247
|
-
<div
|
|
248
|
-
data-test-id="${o}"
|
|
249
|
-
class="${$(m)}"
|
|
248
|
+
<div
|
|
249
|
+
data-test-id="${o}"
|
|
250
|
+
class="${$(m)}"
|
|
250
251
|
aria-live="${i === "error" ? "assertive" : "polite"}"
|
|
251
252
|
>
|
|
252
253
|
<div class="${s}-contentArea">
|
|
@@ -255,40 +256,40 @@ const g = class g extends O(C) {
|
|
|
255
256
|
${n === "" ? d : this.renderMessage(n, x)}
|
|
256
257
|
</div>
|
|
257
258
|
<div class="${s}-actionsArea">
|
|
258
|
-
${!
|
|
259
|
+
${!h && (r != null && r.text) ? this.renderActionButton(r) : d}
|
|
259
260
|
${e ? this.renderCloseButton() : d}
|
|
260
261
|
</div>
|
|
261
262
|
</div>
|
|
262
|
-
${
|
|
263
|
+
${h && (r != null && r.text) ? this.renderFooter() : d}
|
|
263
264
|
</div>`;
|
|
264
265
|
}
|
|
265
266
|
};
|
|
266
267
|
g.styles = w(k);
|
|
267
268
|
let a = g;
|
|
268
269
|
c([
|
|
269
|
-
|
|
270
|
+
p({ type: String })
|
|
270
271
|
], a.prototype, "message");
|
|
271
272
|
c([
|
|
272
|
-
|
|
273
|
+
p({ type: Boolean })
|
|
273
274
|
], a.prototype, "isOpen");
|
|
274
275
|
c([
|
|
275
|
-
|
|
276
|
-
E(o, B,
|
|
276
|
+
p({ type: String }),
|
|
277
|
+
E(o, B, u.variant)
|
|
277
278
|
], a.prototype, "variant");
|
|
278
279
|
c([
|
|
279
|
-
|
|
280
|
+
p({ type: Boolean })
|
|
280
281
|
], a.prototype, "isStrong");
|
|
281
282
|
c([
|
|
282
|
-
|
|
283
|
+
p({ type: Boolean })
|
|
283
284
|
], a.prototype, "isDismissible");
|
|
284
285
|
c([
|
|
285
|
-
|
|
286
|
+
p({ type: Boolean })
|
|
286
287
|
], a.prototype, "isMultiline");
|
|
287
288
|
c([
|
|
288
|
-
|
|
289
|
+
p({ type: Object })
|
|
289
290
|
], a.prototype, "leadingAction");
|
|
290
291
|
c([
|
|
291
|
-
|
|
292
|
+
p({ type: Number })
|
|
292
293
|
], a.prototype, "duration");
|
|
293
294
|
c([
|
|
294
295
|
y("pie-button")
|
|
@@ -304,6 +305,6 @@ export {
|
|
|
304
305
|
a as PieToast,
|
|
305
306
|
s as componentClass,
|
|
306
307
|
o as componentSelector,
|
|
307
|
-
|
|
308
|
+
u as defaultProps,
|
|
308
309
|
B as variants
|
|
309
310
|
};
|
package/dist/react.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export declare const componentClass = "c-toast";
|
|
|
22
22
|
|
|
23
23
|
export declare const componentSelector = "pie-toast";
|
|
24
24
|
|
|
25
|
-
export declare type DefaultProps = ComponentDefaultProps<ToastProps, keyof Omit<ToastProps, '
|
|
25
|
+
export declare type DefaultProps = ComponentDefaultProps<ToastProps, keyof Omit<ToastProps, 'leadingAction'>>;
|
|
26
26
|
|
|
27
27
|
export declare const defaultProps: DefaultProps;
|
|
28
28
|
|
|
@@ -53,7 +53,7 @@ export declare const PieToast: React_2.ForwardRefExoticComponent<ToastProps & Re
|
|
|
53
53
|
* @tagname pie-toast
|
|
54
54
|
*/
|
|
55
55
|
declare class PieToast_2 extends PieToast_base implements ToastProps {
|
|
56
|
-
message:
|
|
56
|
+
message: string;
|
|
57
57
|
isOpen: boolean;
|
|
58
58
|
variant: "neutral" | "info" | "warning" | "success" | "error";
|
|
59
59
|
isStrong: boolean;
|
|
@@ -61,8 +61,8 @@ declare class PieToast_2 extends PieToast_base implements ToastProps {
|
|
|
61
61
|
isMultiline: boolean;
|
|
62
62
|
leadingAction: ToastProps['leadingAction'];
|
|
63
63
|
duration: number | null;
|
|
64
|
-
actionButton
|
|
65
|
-
closeButton
|
|
64
|
+
private actionButton?;
|
|
65
|
+
private closeButton?;
|
|
66
66
|
private _actionButtonOffset;
|
|
67
67
|
private _messageAreaMaxWidth;
|
|
68
68
|
private _timeoutId;
|
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.4.
|
|
4
|
+
"version": "0.4.4",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"cem-plugin-module-file-extensions": "0.0.5"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@justeattakeaway/pie-button": "0.
|
|
45
|
-
"@justeattakeaway/pie-icon-button": "0.
|
|
44
|
+
"@justeattakeaway/pie-button": "1.0.0",
|
|
45
|
+
"@justeattakeaway/pie-icon-button": "1.0.0",
|
|
46
46
|
"@justeattakeaway/pie-icons-webc": "1.1.0",
|
|
47
47
|
"@justeattakeaway/pie-webc-core": "0.24.2"
|
|
48
48
|
},
|
package/src/defs.ts
CHANGED
|
@@ -77,9 +77,10 @@ export const ON_TOAST_OPEN_EVENT = `${componentSelector}-open`;
|
|
|
77
77
|
*/
|
|
78
78
|
export const ON_TOAST_LEADING_ACTION_CLICK_EVENT = `${componentSelector}-leading-action-click`;
|
|
79
79
|
|
|
80
|
-
export type DefaultProps = ComponentDefaultProps<ToastProps, keyof Omit<ToastProps, '
|
|
80
|
+
export type DefaultProps = ComponentDefaultProps<ToastProps, keyof Omit<ToastProps, 'leadingAction'>>;
|
|
81
81
|
|
|
82
82
|
export const defaultProps: DefaultProps = {
|
|
83
|
+
message: '',
|
|
83
84
|
isOpen: true,
|
|
84
85
|
variant: 'neutral',
|
|
85
86
|
isStrong: false,
|
package/src/index.ts
CHANGED
|
@@ -42,13 +42,13 @@ export * from './defs';
|
|
|
42
42
|
* @tagname pie-toast
|
|
43
43
|
*/
|
|
44
44
|
export class PieToast extends RtlMixin(LitElement) implements ToastProps {
|
|
45
|
-
@property()
|
|
46
|
-
public message
|
|
45
|
+
@property({ type: String })
|
|
46
|
+
public message = defaultProps.message;
|
|
47
47
|
|
|
48
48
|
@property({ type: Boolean })
|
|
49
49
|
public isOpen = defaultProps.isOpen;
|
|
50
50
|
|
|
51
|
-
@property()
|
|
51
|
+
@property({ type: String })
|
|
52
52
|
@validPropertyValues(componentSelector, variants, defaultProps.variant)
|
|
53
53
|
public variant = defaultProps.variant;
|
|
54
54
|
|
|
@@ -67,9 +67,11 @@ export class PieToast extends RtlMixin(LitElement) implements ToastProps {
|
|
|
67
67
|
@property({ type: Number })
|
|
68
68
|
public duration = defaultProps.duration;
|
|
69
69
|
|
|
70
|
-
@query('pie-button')
|
|
70
|
+
@query('pie-button')
|
|
71
|
+
private actionButton?: HTMLElement;
|
|
71
72
|
|
|
72
|
-
@query('pie-icon-button')
|
|
73
|
+
@query('pie-icon-button')
|
|
74
|
+
private closeButton?: HTMLElement;
|
|
73
75
|
|
|
74
76
|
private _actionButtonOffset = 0;
|
|
75
77
|
|
|
@@ -406,9 +408,9 @@ export class PieToast extends RtlMixin(LitElement) implements ToastProps {
|
|
|
406
408
|
};
|
|
407
409
|
|
|
408
410
|
return html`
|
|
409
|
-
<div
|
|
410
|
-
data-test-id="${componentSelector}"
|
|
411
|
-
class="${classMap(componentWrapperClasses)}"
|
|
411
|
+
<div
|
|
412
|
+
data-test-id="${componentSelector}"
|
|
413
|
+
class="${classMap(componentWrapperClasses)}"
|
|
412
414
|
aria-live="${variant === 'error' ? 'assertive' : 'polite'}"
|
|
413
415
|
>
|
|
414
416
|
<div class="${componentClass}-contentArea">
|