@justeattakeaway/pie-toast 0.12.44 → 0.13.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.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { ComponentDefaultProps } from '@justeattakeaway/pie-webc-core';
2
2
  import { CSSResult } from 'lit';
3
+ import { nothing } from 'lit';
3
4
  import { PieElement } from '@justeattakeaway/pie-webc-core/src/internals/PieElement';
4
5
  import { PropertyValues } from 'lit';
5
6
  import { TemplateResult } from 'lit';
@@ -168,7 +169,7 @@ export declare class PieToast extends PieElement implements ToastProps {
168
169
  * @private
169
170
  */
170
171
  private shouldNotUseInverseBtnVariant;
171
- render(): TemplateResult<1>;
172
+ render(): typeof nothing | TemplateResult<1>;
172
173
  }
173
174
 
174
175
  export declare interface ToastProps {
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { LitElement as y, unsafeCSS as $, nothing as d, html as l } from "lit";
1
+ import { LitElement as y, unsafeCSS as $, nothing as l, html as d } from "lit";
2
2
  import { property as u, 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";
@@ -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 = "0.12.44";
17
+ f.v = "0.13.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)}", _ = ["neutral", "info", "warning", "success", "error"], s = "pie-toast", n = "c-toast", O = `${s}-close`, E = `${s}-open`, T = `${s}-leading-action-click`, p = {
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"], s = "pie-toast", n = "c-toast", _ = `${s}-close`, E = `${s}-open`, T = `${s}-leading-action-click`, p = {
20
20
  message: "",
21
21
  isOpen: !0,
22
22
  variant: "neutral",
@@ -108,11 +108,11 @@ let e = class extends m {
108
108
  */
109
109
  renderActionButton(t) {
110
110
  const { text: i, ariaLabel: c } = t;
111
- return l`
111
+ return d`
112
112
  <pie-button
113
113
  variant="${this.shouldNotUseInverseBtnVariant() ? "ghost" : "ghost-inverse"}"
114
114
  size="xsmall"
115
- aria-label="${c || d}"
115
+ aria-label="${c || l}"
116
116
  @click="${() => this.handleActionClick()}"
117
117
  data-test-id="${s}-leading-action"
118
118
  type="button">
@@ -129,9 +129,9 @@ let e = class extends m {
129
129
  */
130
130
  renderFooter() {
131
131
  const { leadingAction: t } = this;
132
- return l`
132
+ return d`
133
133
  <footer class="${n}-footer" data-test-id="${s}-footer" >
134
- ${t ? this.renderActionButton(t) : d}
134
+ ${t ? this.renderActionButton(t) : l}
135
135
  </footer>
136
136
  `;
137
137
  }
@@ -142,7 +142,7 @@ let e = class extends m {
142
142
  * @private
143
143
  */
144
144
  renderCloseButton() {
145
- return l`
145
+ return d`
146
146
  <pie-icon-button
147
147
  variant="${this.shouldNotUseInverseBtnVariant() ? "ghost-secondary" : "ghost-inverse"}"
148
148
  size="xsmall"
@@ -160,7 +160,7 @@ let e = class extends m {
160
160
  * @private
161
161
  */
162
162
  renderMessage(t) {
163
- return l`
163
+ return d`
164
164
  <span data-test-id="${s}-message">
165
165
  ${t}
166
166
  </span>
@@ -173,7 +173,7 @@ let e = class extends m {
173
173
  * @private
174
174
  */
175
175
  closeToastComponent() {
176
- this.isOpen = !1, g(this, O, { targetNotification: this }), this.abortAndCleanEventListeners();
176
+ this.isOpen = !1, g(this, _, { targetNotification: this }), this.abortAndCleanEventListeners();
177
177
  }
178
178
  /**
179
179
  * Util method that returns an icon from a variant that has default icon.
@@ -183,15 +183,15 @@ let e = class extends m {
183
183
  getVariantIcon() {
184
184
  switch (this.variant) {
185
185
  case "info":
186
- return l`<icon-info-circle class="${n}-icon" size="s" data-test-id="${s}-heading-icon-info"></icon-info-circle>`;
186
+ return d`<icon-info-circle class="${n}-icon" size="s" data-test-id="${s}-heading-icon-info"></icon-info-circle>`;
187
187
  case "success":
188
- return l`<icon-check-circle class="${n}-icon" size="s" data-test-id="${s}-heading-icon-success"></icon-check-circle>`;
188
+ return d`<icon-check-circle class="${n}-icon" size="s" data-test-id="${s}-heading-icon-success"></icon-check-circle>`;
189
189
  case "warning":
190
- return l`<icon-alert-triangle class="${n}-icon" size="s" data-test-id="${s}-heading-icon-warning"></icon-alert-triangle>`;
190
+ return d`<icon-alert-triangle class="${n}-icon" size="s" data-test-id="${s}-heading-icon-warning"></icon-alert-triangle>`;
191
191
  case "error":
192
- return l`<icon-alert-circle class="${n}-icon" size="s" data-test-id="${s}-heading-icon-error"></icon-alert-circle>`;
192
+ return d`<icon-alert-circle class="${n}-icon" size="s" data-test-id="${s}-heading-icon-error"></icon-alert-circle>`;
193
193
  default:
194
- return d;
194
+ return l;
195
195
  }
196
196
  }
197
197
  /**
@@ -213,6 +213,8 @@ let e = class extends m {
213
213
  return this.variant === "warning" && this.isStrong;
214
214
  }
215
215
  render() {
216
+ if (!this.isOpen)
217
+ return l;
216
218
  const {
217
219
  variant: t,
218
220
  message: i,
@@ -226,22 +228,22 @@ let e = class extends m {
226
228
  [`${n}--${t}`]: !0,
227
229
  [`${n}--strong`]: h
228
230
  };
229
- return l`
231
+ return d`
230
232
  <div
231
233
  role="${t === "error" ? "alert" : "status"}"
232
234
  data-test-id="${s}"
233
235
  class="${x(v)}">
234
236
  <div class="${n}-contentArea">
235
237
  <div class="${n}-messageArea">
236
- ${this.variantHasIcon(t) ? this.getVariantIcon() : d}
237
- ${i === "" ? d : this.renderMessage(i)}
238
+ ${this.variantHasIcon(t) ? this.getVariantIcon() : l}
239
+ ${i === "" ? l : this.renderMessage(i)}
238
240
  </div>
239
241
  <div class="${n}-actionsArea">
240
- ${!r && (o != null && o.text) ? this.renderActionButton(o) : d}
241
- ${c ? this.renderCloseButton() : d}
242
+ ${!r && (o != null && o.text) ? this.renderActionButton(o) : l}
243
+ ${c ? this.renderCloseButton() : l}
242
244
  </div>
243
245
  </div>
244
- ${r && (o != null && o.text) ? this.renderFooter() : d}
246
+ ${r && (o != null && o.text) ? this.renderFooter() : l}
245
247
  </div>`;
246
248
  }
247
249
  };
@@ -254,7 +256,7 @@ a([
254
256
  ], e.prototype, "isOpen", 2);
255
257
  a([
256
258
  u({ type: String }),
257
- A(s, _, p.variant)
259
+ A(s, O, p.variant)
258
260
  ], e.prototype, "variant", 2);
259
261
  a([
260
262
  u({ type: Boolean })
@@ -281,12 +283,12 @@ e = a([
281
283
  w("pie-toast")
282
284
  ], e);
283
285
  export {
284
- O as ON_TOAST_CLOSE_EVENT,
286
+ _ as ON_TOAST_CLOSE_EVENT,
285
287
  T as ON_TOAST_LEADING_ACTION_CLICK_EVENT,
286
288
  E as ON_TOAST_OPEN_EVENT,
287
289
  e as PieToast,
288
290
  n as componentClass,
289
291
  s as componentSelector,
290
292
  p as defaultProps,
291
- _ as variants
293
+ O as variants
292
294
  };
package/dist/react.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { ComponentDefaultProps } from '@justeattakeaway/pie-webc-core';
2
2
  import { CSSResult } from 'lit';
3
+ import { nothing } from 'lit';
3
4
  import { PieElement } from '@justeattakeaway/pie-webc-core/src/internals/PieElement';
4
5
  import { PropertyValues } from 'lit';
5
6
  import * as React_2 from 'react';
@@ -171,7 +172,7 @@ declare class PieToast_2 extends PieElement implements ToastProps {
171
172
  * @private
172
173
  */
173
174
  private shouldNotUseInverseBtnVariant;
174
- render(): TemplateResult<1>;
175
+ render(): typeof nothing | TemplateResult<1>;
175
176
  }
176
177
 
177
178
  declare type PieToastEvents = {
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.12.44",
4
+ "version": "0.13.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/justeattakeaway/pie",
@@ -28,30 +28,30 @@
28
28
  },
29
29
  "scripts": {
30
30
  "build": "run -T vite build",
31
- "build:react-wrapper": "npx build-react-wrapper",
31
+ "build:react-wrapper": "run -T build-react-wrapper",
32
32
  "create:manifest": "run -T cem analyze --litelement",
33
33
  "lint:scripts": "run -T eslint .",
34
34
  "lint:scripts:fix": "yarn lint:scripts --fix",
35
35
  "lint:style": "run -T stylelint ./src/**/*.{css,scss}",
36
36
  "lint:style:fix": "yarn lint:style --fix",
37
37
  "watch": "run -T vite build --watch",
38
- "test:browsers": "npx playwright test -c ./playwright-lit.config.ts",
38
+ "test:browsers": "run -T playwright test -c ./playwright-lit.config.ts",
39
39
  "test:browsers:ci": "yarn test:browsers",
40
- "test:visual": "run -T cross-env-shell PERCY_TOKEN=${PERCY_TOKEN_PIE_TOAST} percy exec --allowed-hostname cloudfront.net -- npx playwright test -c ./playwright-lit-visual.config.ts",
40
+ "test:visual": "run -T cross-env-shell PERCY_TOKEN=${PERCY_TOKEN_PIE_TOAST} percy exec --allowed-hostname cloudfront.net -- run -T playwright test -c ./playwright-lit-visual.config.ts",
41
41
  "test:visual:ci": "yarn test:visual"
42
42
  },
43
43
  "author": "Just Eat Takeaway.com - Design System Team",
44
44
  "license": "Apache-2.0",
45
45
  "devDependencies": {
46
- "@justeattakeaway/pie-components-config": "0.21.2",
46
+ "@justeattakeaway/pie-components-config": "0.21.3",
47
47
  "@justeattakeaway/pie-css": "1.1.1",
48
- "@justeattakeaway/pie-monorepo-utils": "0.9.1"
48
+ "@justeattakeaway/pie-monorepo-utils": "0.9.2"
49
49
  },
50
50
  "dependencies": {
51
- "@justeattakeaway/pie-button": "1.14.1",
52
- "@justeattakeaway/pie-icon-button": "2.7.14",
53
- "@justeattakeaway/pie-icons-webc": "1.24.1",
54
- "@justeattakeaway/pie-webc-core": "14.0.1"
51
+ "@justeattakeaway/pie-button": "1.14.2",
52
+ "@justeattakeaway/pie-icon-button": "2.7.15",
53
+ "@justeattakeaway/pie-icons-webc": "1.24.2",
54
+ "@justeattakeaway/pie-webc-core": "14.0.2"
55
55
  },
56
56
  "customElements": "custom-elements.json",
57
57
  "sideEffects": [
package/src/index.ts CHANGED
@@ -312,6 +312,10 @@ export class PieToast extends PieElement implements ToastProps {
312
312
  }
313
313
 
314
314
  render () {
315
+ if (!this.isOpen) {
316
+ return nothing;
317
+ }
318
+
315
319
  const {
316
320
  variant,
317
321
  message,