@justeattakeaway/pie-toast 1.0.6 → 1.1.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/README.md +1 -0
- package/custom-elements.json +16 -0
- package/dist/index.d.ts +10 -1
- package/dist/index.js +75 -70
- package/dist/react.d.ts +10 -1
- package/package.json +4 -4
- package/src/defs.ts +10 -1
- package/src/index.ts +4 -0
package/README.md
CHANGED
|
@@ -42,6 +42,7 @@ Ideally, you should install the component using the **`@justeattakeaway/pie-webc
|
|
|
42
42
|
| `isMultiline` | `true`, `false` | Allows the message content to be displayed as multiline, limited to three rows. | `false` |
|
|
43
43
|
| `leadingAction` | `{ text: string, ariaLabel?: string }` | The leading action for the toast. | `undefined` |
|
|
44
44
|
| `duration` | `number`, `null` | Sets the duration of the toast in milliseconds before it auto-dismisses. `null` disables auto-dismiss. Defaults to 5 seconds if not specified. | `5000` |
|
|
45
|
+
| `aria` | `{ close?: string }` | The ARIA labels used for various parts of the toast. `close` sets the `aria-label` on the close button. | `undefined` |
|
|
45
46
|
|
|
46
47
|
### Slots
|
|
47
48
|
This component does not have any slots. All content is controlled through properties.
|
package/custom-elements.json
CHANGED
|
@@ -182,6 +182,15 @@
|
|
|
182
182
|
"privacy": "public",
|
|
183
183
|
"attribute": "duration"
|
|
184
184
|
},
|
|
185
|
+
{
|
|
186
|
+
"kind": "field",
|
|
187
|
+
"name": "aria",
|
|
188
|
+
"type": {
|
|
189
|
+
"text": "ToastProps['aria']"
|
|
190
|
+
},
|
|
191
|
+
"privacy": "public",
|
|
192
|
+
"attribute": "aria"
|
|
193
|
+
},
|
|
185
194
|
{
|
|
186
195
|
"kind": "field",
|
|
187
196
|
"name": "actionButton",
|
|
@@ -425,6 +434,13 @@
|
|
|
425
434
|
{
|
|
426
435
|
"name": "duration",
|
|
427
436
|
"fieldName": "duration"
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
"name": "aria",
|
|
440
|
+
"type": {
|
|
441
|
+
"text": "ToastProps['aria']"
|
|
442
|
+
},
|
|
443
|
+
"fieldName": "aria"
|
|
428
444
|
}
|
|
429
445
|
],
|
|
430
446
|
"superclass": {
|
package/dist/index.d.ts
CHANGED
|
@@ -16,11 +16,15 @@ export declare type ActionProps = {
|
|
|
16
16
|
ariaLabel?: string;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
+
declare type AriaProps = {
|
|
20
|
+
close?: string;
|
|
21
|
+
};
|
|
22
|
+
|
|
19
23
|
export declare const componentClass = "c-toast";
|
|
20
24
|
|
|
21
25
|
export declare const componentSelector = "pie-toast";
|
|
22
26
|
|
|
23
|
-
export declare type DefaultProps = ComponentDefaultProps<ToastProps, keyof Omit<ToastProps, 'leadingAction'>>;
|
|
27
|
+
export declare type DefaultProps = ComponentDefaultProps<ToastProps, keyof Omit<ToastProps, 'leadingAction' | 'aria'>>;
|
|
24
28
|
|
|
25
29
|
export declare const defaultProps: DefaultProps;
|
|
26
30
|
|
|
@@ -60,6 +64,7 @@ export declare class PieToast extends PieElement implements ToastProps {
|
|
|
60
64
|
isMultiline: boolean;
|
|
61
65
|
leadingAction: ToastProps['leadingAction'];
|
|
62
66
|
duration: number | null;
|
|
67
|
+
aria: ToastProps['aria'];
|
|
63
68
|
private actionButton?;
|
|
64
69
|
private closeButton?;
|
|
65
70
|
private _timeoutId;
|
|
@@ -207,6 +212,10 @@ export declare interface ToastProps {
|
|
|
207
212
|
* If the value is not provided it auto-dismisses after 5 seconds
|
|
208
213
|
*/
|
|
209
214
|
duration?: number | null;
|
|
215
|
+
/**
|
|
216
|
+
* The ARIA labels used for various parts of the toast.
|
|
217
|
+
*/
|
|
218
|
+
aria?: AriaProps;
|
|
210
219
|
}
|
|
211
220
|
|
|
212
221
|
export declare const variants: readonly ["neutral", "info", "warning", "success", "error"];
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LitElement as y, unsafeCSS as $, nothing as l, html as d } from "lit";
|
|
2
|
-
import { property as
|
|
2
|
+
import { property as p, query as b } from "lit/decorators.js";
|
|
3
3
|
import { classMap as x } from "lit/directives/class-map.js";
|
|
4
4
|
import { validPropertyValues as A, safeCustomElement as w, dispatchCustomEvent as g } from "@justeattakeaway/pie-webc-core";
|
|
5
5
|
import "@justeattakeaway/pie-icon-button";
|
|
@@ -14,9 +14,9 @@ const f = class f extends y {
|
|
|
14
14
|
this.getAttribute("v") || this.setAttribute("v", f.v);
|
|
15
15
|
}
|
|
16
16
|
};
|
|
17
|
-
f.v = "1.0
|
|
17
|
+
f.v = "1.1.0";
|
|
18
18
|
let m = f;
|
|
19
|
-
const C = "*,*:after,*:before{box-sizing:inherit}:host{display:block}.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-family: var(--dt-font-body-s-family);--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);display:flex;flex-direction:column;justify-content:center;min-height:48px;max-height:122px;min-width:300px;max-width:420px;padding:var(--dt-spacing-b) var(--dt-spacing-c) var(--dt-spacing-b) var(--dt-spacing-d);border-radius:var(--toast-border-radius);background-color:var(--toast-background-color);box-shadow:var(--dt-elevation-below-20);color:var(--toast-font-color);font-family:var(--toast-font-family);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-light);--toast-font-color: var(--dt-color-content-light)}.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:6px var(--dt-spacing-a) 6px 0;overflow:hidden}.c-toast-messageArea span{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.c-toast-actionsArea{display:flex;gap:var(--dt-spacing-b);flex-shrink:0}.is-multiline .c-toast-contentArea{align-items:flex-start;gap:0}.is-multiline .c-toast-messageArea{align-items:flex-start;padding-block-end:var(--dt-spacing-b)}.is-multiline .c-toast-messageArea span{max-height:60px;white-space:inherit;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical}.c-toast-footer{display:flex;justify-content:flex-end}.c-toast-icon{color:var(--toast-icon-fill)}", O = ["neutral", "info", "warning", "success", "error"],
|
|
19
|
+
const C = "*,*:after,*:before{box-sizing:inherit}:host{display:block}.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-family: var(--dt-font-body-s-family);--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);display:flex;flex-direction:column;justify-content:center;min-height:48px;max-height:122px;min-width:300px;max-width:420px;padding:var(--dt-spacing-b) var(--dt-spacing-c) var(--dt-spacing-b) var(--dt-spacing-d);border-radius:var(--toast-border-radius);background-color:var(--toast-background-color);box-shadow:var(--dt-elevation-below-20);color:var(--toast-font-color);font-family:var(--toast-font-family);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-light);--toast-font-color: var(--dt-color-content-light)}.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:6px var(--dt-spacing-a) 6px 0;overflow:hidden}.c-toast-messageArea span{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.c-toast-actionsArea{display:flex;gap:var(--dt-spacing-b);flex-shrink:0}.is-multiline .c-toast-contentArea{align-items:flex-start;gap:0}.is-multiline .c-toast-messageArea{align-items:flex-start;padding-block-end:var(--dt-spacing-b)}.is-multiline .c-toast-messageArea span{max-height:60px;white-space:inherit;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical}.c-toast-footer{display:flex;justify-content:flex-end}.c-toast-icon{color:var(--toast-icon-fill)}", O = ["neutral", "info", "warning", "success", "error"], e = "pie-toast", a = "c-toast", _ = `${e}-close`, E = `${e}-open`, T = `${e}-leading-action-click`, u = {
|
|
20
20
|
message: "",
|
|
21
21
|
isOpen: !0,
|
|
22
22
|
variant: "neutral",
|
|
@@ -25,14 +25,14 @@ const C = "*,*:after,*:before{box-sizing:inherit}:host{display:block}.c-toast{--
|
|
|
25
25
|
isMultiline: !1,
|
|
26
26
|
duration: 5e3
|
|
27
27
|
};
|
|
28
|
-
var k = Object.defineProperty, B = Object.getOwnPropertyDescriptor,
|
|
29
|
-
for (var
|
|
30
|
-
(v = t[h]) && (
|
|
31
|
-
return o &&
|
|
28
|
+
var k = Object.defineProperty, B = Object.getOwnPropertyDescriptor, i = (t, r, c, o) => {
|
|
29
|
+
for (var n = o > 1 ? void 0 : o ? B(r, c) : r, h = t.length - 1, v; h >= 0; h--)
|
|
30
|
+
(v = t[h]) && (n = (o ? v(r, c, n) : v(n)) || n);
|
|
31
|
+
return o && n && k(r, c, n), n;
|
|
32
32
|
};
|
|
33
|
-
let
|
|
33
|
+
let s = class extends m {
|
|
34
34
|
constructor() {
|
|
35
|
-
super(...arguments), this.message =
|
|
35
|
+
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._timeoutId = null, this._abortController = null;
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
38
|
* Create a timeout function and set its id into a private attribute.
|
|
@@ -63,8 +63,8 @@ let e = class extends m {
|
|
|
63
63
|
*
|
|
64
64
|
* @private
|
|
65
65
|
*/
|
|
66
|
-
addListenersToElement(t,
|
|
67
|
-
t && (t.addEventListener(
|
|
66
|
+
addListenersToElement(t, r, c, o) {
|
|
67
|
+
t && (t.addEventListener(r, () => {
|
|
68
68
|
this._timeoutId && clearTimeout(this._timeoutId);
|
|
69
69
|
}, { signal: o }), t.addEventListener(c, () => {
|
|
70
70
|
this.setAutoDismiss();
|
|
@@ -107,16 +107,16 @@ let e = class extends m {
|
|
|
107
107
|
* @private
|
|
108
108
|
*/
|
|
109
109
|
renderActionButton(t) {
|
|
110
|
-
const { text:
|
|
110
|
+
const { text: r, ariaLabel: c } = t;
|
|
111
111
|
return d`
|
|
112
112
|
<pie-button
|
|
113
113
|
variant="${this.shouldNotUseInverseBtnVariant() ? "ghost" : "ghost-inverse"}"
|
|
114
114
|
size="xsmall"
|
|
115
115
|
aria-label="${c || l}"
|
|
116
116
|
@click="${() => this.handleActionClick()}"
|
|
117
|
-
data-test-id="${
|
|
117
|
+
data-test-id="${e}-leading-action"
|
|
118
118
|
type="button">
|
|
119
|
-
${
|
|
119
|
+
${r}
|
|
120
120
|
</pie-button>
|
|
121
121
|
`;
|
|
122
122
|
}
|
|
@@ -130,7 +130,7 @@ let e = class extends m {
|
|
|
130
130
|
renderFooter() {
|
|
131
131
|
const { leadingAction: t } = this;
|
|
132
132
|
return d`
|
|
133
|
-
<footer class="${
|
|
133
|
+
<footer class="${a}-footer" data-test-id="${e}-footer" >
|
|
134
134
|
${t ? this.renderActionButton(t) : l}
|
|
135
135
|
</footer>
|
|
136
136
|
`;
|
|
@@ -142,11 +142,13 @@ let e = class extends m {
|
|
|
142
142
|
* @private
|
|
143
143
|
*/
|
|
144
144
|
renderCloseButton() {
|
|
145
|
+
var t;
|
|
145
146
|
return d`
|
|
146
147
|
<pie-icon-button
|
|
147
148
|
variant="${this.shouldNotUseInverseBtnVariant() ? "ghost-secondary" : "ghost-inverse"}"
|
|
148
149
|
size="xsmall"
|
|
149
|
-
data-test-id="${
|
|
150
|
+
data-test-id="${e}-close"
|
|
151
|
+
.aria="${{ label: (t = this.aria) == null ? void 0 : t.close }}"
|
|
150
152
|
@click="${this.closeToastComponent}">
|
|
151
153
|
<icon-close></icon-close>
|
|
152
154
|
</pie-icon-button>`;
|
|
@@ -161,7 +163,7 @@ let e = class extends m {
|
|
|
161
163
|
*/
|
|
162
164
|
renderMessage(t) {
|
|
163
165
|
return d`
|
|
164
|
-
<span data-test-id="${
|
|
166
|
+
<span data-test-id="${e}-message">
|
|
165
167
|
${t}
|
|
166
168
|
</span>
|
|
167
169
|
`;
|
|
@@ -183,13 +185,13 @@ let e = class extends m {
|
|
|
183
185
|
getVariantIcon() {
|
|
184
186
|
switch (this.variant) {
|
|
185
187
|
case "info":
|
|
186
|
-
return d`<icon-info-circle class="${
|
|
188
|
+
return d`<icon-info-circle class="${a}-icon" size="s" data-test-id="${e}-heading-icon-info"></icon-info-circle>`;
|
|
187
189
|
case "success":
|
|
188
|
-
return d`<icon-check-circle class="${
|
|
190
|
+
return d`<icon-check-circle class="${a}-icon" size="s" data-test-id="${e}-heading-icon-success"></icon-check-circle>`;
|
|
189
191
|
case "warning":
|
|
190
|
-
return d`<icon-alert-triangle class="${
|
|
192
|
+
return d`<icon-alert-triangle class="${a}-icon" size="s" data-test-id="${e}-heading-icon-warning"></icon-alert-triangle>`;
|
|
191
193
|
case "error":
|
|
192
|
-
return d`<icon-alert-circle class="${
|
|
194
|
+
return d`<icon-alert-circle class="${a}-icon" size="s" data-test-id="${e}-heading-icon-error"></icon-alert-circle>`;
|
|
193
195
|
default:
|
|
194
196
|
return l;
|
|
195
197
|
}
|
|
@@ -217,78 +219,81 @@ let e = class extends m {
|
|
|
217
219
|
return l;
|
|
218
220
|
const {
|
|
219
221
|
variant: t,
|
|
220
|
-
message:
|
|
222
|
+
message: r,
|
|
221
223
|
isDismissible: c,
|
|
222
224
|
leadingAction: o,
|
|
223
|
-
isMultiline:
|
|
225
|
+
isMultiline: n,
|
|
224
226
|
isStrong: h
|
|
225
227
|
} = this, v = {
|
|
226
|
-
[
|
|
227
|
-
"is-multiline":
|
|
228
|
-
[`${
|
|
229
|
-
[`${
|
|
228
|
+
[a]: !0,
|
|
229
|
+
"is-multiline": n,
|
|
230
|
+
[`${a}--${t}`]: !0,
|
|
231
|
+
[`${a}--strong`]: h
|
|
230
232
|
};
|
|
231
233
|
return d`
|
|
232
234
|
<div
|
|
233
235
|
role="${t === "error" ? "alert" : "status"}"
|
|
234
|
-
data-test-id="${
|
|
236
|
+
data-test-id="${e}"
|
|
235
237
|
class="${x(v)}">
|
|
236
|
-
<div class="${
|
|
237
|
-
<div class="${
|
|
238
|
+
<div class="${a}-contentArea">
|
|
239
|
+
<div class="${a}-messageArea">
|
|
238
240
|
${this.variantHasIcon(t) ? this.getVariantIcon() : l}
|
|
239
|
-
${
|
|
241
|
+
${r === "" ? l : this.renderMessage(r)}
|
|
240
242
|
</div>
|
|
241
|
-
<div class="${
|
|
242
|
-
${!
|
|
243
|
+
<div class="${a}-actionsArea">
|
|
244
|
+
${!n && (o != null && o.text) ? this.renderActionButton(o) : l}
|
|
243
245
|
${c ? this.renderCloseButton() : l}
|
|
244
246
|
</div>
|
|
245
247
|
</div>
|
|
246
|
-
${
|
|
248
|
+
${n && (o != null && o.text) ? this.renderFooter() : l}
|
|
247
249
|
</div>`;
|
|
248
250
|
}
|
|
249
251
|
};
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
],
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
],
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
A(
|
|
260
|
-
],
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
],
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
],
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
],
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
],
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
],
|
|
276
|
-
|
|
252
|
+
s.styles = $(C);
|
|
253
|
+
i([
|
|
254
|
+
p({ type: String })
|
|
255
|
+
], s.prototype, "message", 2);
|
|
256
|
+
i([
|
|
257
|
+
p({ type: Boolean })
|
|
258
|
+
], s.prototype, "isOpen", 2);
|
|
259
|
+
i([
|
|
260
|
+
p({ type: String }),
|
|
261
|
+
A(e, O, u.variant)
|
|
262
|
+
], s.prototype, "variant", 2);
|
|
263
|
+
i([
|
|
264
|
+
p({ type: Boolean })
|
|
265
|
+
], s.prototype, "isStrong", 2);
|
|
266
|
+
i([
|
|
267
|
+
p({ type: Boolean })
|
|
268
|
+
], s.prototype, "isDismissible", 2);
|
|
269
|
+
i([
|
|
270
|
+
p({ type: Boolean })
|
|
271
|
+
], s.prototype, "isMultiline", 2);
|
|
272
|
+
i([
|
|
273
|
+
p({ type: Object })
|
|
274
|
+
], s.prototype, "leadingAction", 2);
|
|
275
|
+
i([
|
|
276
|
+
p({ type: Number })
|
|
277
|
+
], s.prototype, "duration", 2);
|
|
278
|
+
i([
|
|
279
|
+
p({ type: Object })
|
|
280
|
+
], s.prototype, "aria", 2);
|
|
281
|
+
i([
|
|
277
282
|
b("pie-button")
|
|
278
|
-
],
|
|
279
|
-
|
|
283
|
+
], s.prototype, "actionButton", 2);
|
|
284
|
+
i([
|
|
280
285
|
b("pie-icon-button")
|
|
281
|
-
],
|
|
282
|
-
|
|
286
|
+
], s.prototype, "closeButton", 2);
|
|
287
|
+
s = i([
|
|
283
288
|
w("pie-toast")
|
|
284
|
-
],
|
|
289
|
+
], s);
|
|
285
290
|
export {
|
|
286
291
|
_ as ON_TOAST_CLOSE_EVENT,
|
|
287
292
|
T as ON_TOAST_LEADING_ACTION_CLICK_EVENT,
|
|
288
293
|
E as ON_TOAST_OPEN_EVENT,
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
294
|
+
s as PieToast,
|
|
295
|
+
a as componentClass,
|
|
296
|
+
e as componentSelector,
|
|
297
|
+
u as defaultProps,
|
|
293
298
|
O as variants
|
|
294
299
|
};
|
package/dist/react.d.ts
CHANGED
|
@@ -17,11 +17,15 @@ export declare type ActionProps = {
|
|
|
17
17
|
ariaLabel?: string;
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
+
declare type AriaProps = {
|
|
21
|
+
close?: string;
|
|
22
|
+
};
|
|
23
|
+
|
|
20
24
|
export declare const componentClass = "c-toast";
|
|
21
25
|
|
|
22
26
|
export declare const componentSelector = "pie-toast";
|
|
23
27
|
|
|
24
|
-
export declare type DefaultProps = ComponentDefaultProps<ToastProps, keyof Omit<ToastProps, 'leadingAction'>>;
|
|
28
|
+
export declare type DefaultProps = ComponentDefaultProps<ToastProps, keyof Omit<ToastProps, 'leadingAction' | 'aria'>>;
|
|
25
29
|
|
|
26
30
|
export declare const defaultProps: DefaultProps;
|
|
27
31
|
|
|
@@ -63,6 +67,7 @@ declare class PieToast_2 extends PieElement implements ToastProps {
|
|
|
63
67
|
isMultiline: boolean;
|
|
64
68
|
leadingAction: ToastProps['leadingAction'];
|
|
65
69
|
duration: number | null;
|
|
70
|
+
aria: ToastProps['aria'];
|
|
66
71
|
private actionButton?;
|
|
67
72
|
private closeButton?;
|
|
68
73
|
private _timeoutId;
|
|
@@ -218,6 +223,10 @@ export declare interface ToastProps {
|
|
|
218
223
|
* If the value is not provided it auto-dismisses after 5 seconds
|
|
219
224
|
*/
|
|
220
225
|
duration?: number | null;
|
|
226
|
+
/**
|
|
227
|
+
* The ARIA labels used for various parts of the toast.
|
|
228
|
+
*/
|
|
229
|
+
aria?: AriaProps;
|
|
221
230
|
}
|
|
222
231
|
|
|
223
232
|
export declare const variants: readonly ["neutral", "info", "warning", "success", "error"];
|
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": "1.0
|
|
4
|
+
"version": "1.1.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/justeattakeaway/pie",
|
|
@@ -45,12 +45,12 @@
|
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@justeattakeaway/pie-components-config": "0.21.3",
|
|
47
47
|
"@justeattakeaway/pie-css": "1.3.0",
|
|
48
|
-
"@justeattakeaway/pie-monorepo-utils": "0.9.
|
|
48
|
+
"@justeattakeaway/pie-monorepo-utils": "0.9.7"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@justeattakeaway/pie-button": "1.14.8",
|
|
52
|
-
"@justeattakeaway/pie-icon-button": "2.7.
|
|
53
|
-
"@justeattakeaway/pie-icons-webc": "1.
|
|
52
|
+
"@justeattakeaway/pie-icon-button": "2.7.24",
|
|
53
|
+
"@justeattakeaway/pie-icons-webc": "1.26.0",
|
|
54
54
|
"@justeattakeaway/pie-webc-core": "16.0.0"
|
|
55
55
|
},
|
|
56
56
|
"customElements": "custom-elements.json",
|
package/src/defs.ts
CHANGED
|
@@ -2,6 +2,10 @@ import { type ComponentDefaultProps } from '@justeattakeaway/pie-webc-core';
|
|
|
2
2
|
|
|
3
3
|
export const variants = ['neutral', 'info', 'warning', 'success', 'error'] as const;
|
|
4
4
|
|
|
5
|
+
type AriaProps = {
|
|
6
|
+
close?: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
5
9
|
export type ActionProps = {
|
|
6
10
|
/**
|
|
7
11
|
* The text to display inside the button.
|
|
@@ -51,6 +55,11 @@ export interface ToastProps {
|
|
|
51
55
|
* If the value is not provided it auto-dismisses after 5 seconds
|
|
52
56
|
*/
|
|
53
57
|
duration?: number | null;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The ARIA labels used for various parts of the toast.
|
|
61
|
+
*/
|
|
62
|
+
aria?: AriaProps;
|
|
54
63
|
}
|
|
55
64
|
|
|
56
65
|
export const componentSelector = 'pie-toast';
|
|
@@ -77,7 +86,7 @@ export const ON_TOAST_OPEN_EVENT = `${componentSelector}-open`;
|
|
|
77
86
|
*/
|
|
78
87
|
export const ON_TOAST_LEADING_ACTION_CLICK_EVENT = `${componentSelector}-leading-action-click`;
|
|
79
88
|
|
|
80
|
-
export type DefaultProps = ComponentDefaultProps<ToastProps, keyof Omit<ToastProps, 'leadingAction'>>;
|
|
89
|
+
export type DefaultProps = ComponentDefaultProps<ToastProps, keyof Omit<ToastProps, 'leadingAction' | 'aria'>>;
|
|
81
90
|
|
|
82
91
|
export const defaultProps: DefaultProps = {
|
|
83
92
|
message: '',
|
package/src/index.ts
CHANGED
|
@@ -70,6 +70,9 @@ export class PieToast extends PieElement implements ToastProps {
|
|
|
70
70
|
@property({ type: Number })
|
|
71
71
|
public duration = defaultProps.duration;
|
|
72
72
|
|
|
73
|
+
@property({ type: Object })
|
|
74
|
+
public aria: ToastProps['aria'];
|
|
75
|
+
|
|
73
76
|
@query('pie-button')
|
|
74
77
|
private actionButton?: HTMLElement;
|
|
75
78
|
|
|
@@ -238,6 +241,7 @@ export class PieToast extends PieElement implements ToastProps {
|
|
|
238
241
|
variant="${this.shouldNotUseInverseBtnVariant() ? 'ghost-secondary' : 'ghost-inverse'}"
|
|
239
242
|
size="xsmall"
|
|
240
243
|
data-test-id="${componentSelector}-close"
|
|
244
|
+
.aria="${{ label: this.aria?.close }}"
|
|
241
245
|
@click="${this.closeToastComponent}">
|
|
242
246
|
<icon-close></icon-close>
|
|
243
247
|
</pie-icon-button>`;
|