@justeattakeaway/pie-notification 0.9.3 → 0.10.1

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.
@@ -82,7 +82,7 @@
82
82
  "type": {
83
83
  "text": "DefaultProps"
84
84
  },
85
- "default": "{\n variant: 'neutral',\n position: 'inline-content',\n isDismissible: true,\n isCompact: false,\n headingLevel: 'h2',\n hideIcon: false,\n isOpen: true,\n hasStackedActions: false,\n}"
85
+ "default": "{\n variant: 'neutral',\n position: 'inline-content',\n isDismissible: false,\n isCompact: false,\n headingLevel: 'h2',\n hideIcon: false,\n isOpen: true,\n hasStackedActions: false,\n}"
86
86
  }
87
87
  ],
88
88
  "exports": [
@@ -176,6 +176,16 @@
176
176
  "kind": "class",
177
177
  "description": "",
178
178
  "name": "PieNotification",
179
+ "slots": [
180
+ {
181
+ "description": "Default slot",
182
+ "name": ""
183
+ },
184
+ {
185
+ "description": "The icon slot",
186
+ "name": "icon"
187
+ }
188
+ ],
179
189
  "members": [
180
190
  {
181
191
  "kind": "field",
@@ -328,12 +338,6 @@
328
338
  "privacy": "private",
329
339
  "description": "It handles the action when user clicks in the close button.\nAlso triggers an event when is executed."
330
340
  },
331
- {
332
- "kind": "method",
333
- "name": "closeNotificationComponent",
334
- "privacy": "private",
335
- "description": "Util method responsible to close the component."
336
- },
337
341
  {
338
342
  "kind": "method",
339
343
  "name": "handleActionClick",
@@ -346,7 +350,7 @@
346
350
  }
347
351
  }
348
352
  ],
349
- "description": "It handle the action button action.\nAlso triggers an event according to its `actionType`."
353
+ "description": "It handles the action button action.\nAlso triggers an event according to its `actionType`."
350
354
  },
351
355
  {
352
356
  "kind": "method",
package/dist/index.d.ts CHANGED
@@ -118,6 +118,8 @@ export declare const ON_NOTIFICATION_SUPPORTING_ACTION_CLICK_EVENT: string;
118
118
  * @event {CustomEvent} pie-notification-supporting-action-click - When the notification supporting action is clicked.
119
119
  * @event {CustomEvent} pie-notification-close - When the notification is closed.
120
120
  * @event {CustomEvent} pie-notification-open - When the notification is opened.
121
+ * @slot - Default slot
122
+ * @slot icon - The icon slot
121
123
  */
122
124
  export declare class PieNotification extends LitElement implements NotificationProps {
123
125
  isOpen: boolean;
@@ -182,13 +184,7 @@ export declare class PieNotification extends LitElement implements NotificationP
182
184
  */
183
185
  private handleCloseButton;
184
186
  /**
185
- * Util method responsible to close the component.
186
- *
187
- * @private
188
- */
189
- private closeNotificationComponent;
190
- /**
191
- * It handle the action button action.
187
+ * It handles the action button action.
192
188
  * Also triggers an event according to its `actionType`.
193
189
  *
194
190
  * @param {'leading' | 'supporting'} actionType
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { unsafeCSS as O, LitElement as x, nothing as c } from "lit";
1
+ import { unsafeCSS as O, LitElement as x, nothing as s } from "lit";
2
2
  import { html as d, unsafeStatic as N } from "lit/static-html.js";
3
3
  import { validPropertyValues as b, defineCustomElement as I, dispatchCustomEvent as m } from "@justeattakeaway/pie-webc-core";
4
- import { property as r, queryAssignedElements as _ } from "lit/decorators.js";
4
+ import { property as c, queryAssignedElements as k } from "lit/decorators.js";
5
5
  import { ifDefined as y } from "lit/directives/if-defined.js";
6
6
  import "@justeattakeaway/pie-button";
7
7
  import "@justeattakeaway/pie-icon-button";
@@ -10,10 +10,10 @@ import "@justeattakeaway/pie-icons-webc/dist/IconAlertTriangle.js";
10
10
  import "@justeattakeaway/pie-icons-webc/dist/IconCheckCircle.js";
11
11
  import "@justeattakeaway/pie-icons-webc/dist/IconClose.js";
12
12
  import "@justeattakeaway/pie-icons-webc/dist/IconInfoCircle.js";
13
- const k = ["neutral", "neutral-alternative", "info", "success", "warning", "error"], w = ["h2", "h3", "h4", "h5", "h6"], A = ["inline-content", "full-width"], t = "pie-notification", h = "c-notification", E = `${t}-close`, z = `${t}-open`, S = `${t}-leading-action-click`, T = `${t}-supporting-action-click`, l = {
13
+ const _ = ["neutral", "neutral-alternative", "info", "success", "warning", "error"], w = ["h2", "h3", "h4", "h5", "h6"], A = ["inline-content", "full-width"], t = "pie-notification", h = "c-notification", E = `${t}-close`, z = `${t}-open`, S = `${t}-leading-action-click`, T = `${t}-supporting-action-click`, l = {
14
14
  variant: "neutral",
15
15
  position: "inline-content",
16
- isDismissible: !0,
16
+ isDismissible: !1,
17
17
  isCompact: !1,
18
18
  headingLevel: "h2",
19
19
  hideIcon: !1,
@@ -22,9 +22,9 @@ const k = ["neutral", "neutral-alternative", "info", "success", "warning", "erro
22
22
  }, B = `*,*:after,*:before{box-sizing:inherit}.c-notification{--notification-border-radius: var(--dt-radius-rounded-c);--notification-background-color: var(--dt-color-container-subtle);--notification-direction: column;--notification-heading-font-size: calc(var(--dt-font-heading-s-size--narrow) * 1px);--notification-heading-line-height: calc(var(--dt-font-heading-s-line-height--narrow) * 1px);--notification-font-size: calc(var(--dt-font-body-l-size) * 1px);--notification-line-height: calc(var(--dt-font-body-l-line-height) * 1px);--notification-close-icon-offset: var(--dt-spacing-b);--notification-icon-fill: var(--dt-color-content-default);--notification-icon-offset: 2px;--icon-size-override: 24px;padding:var(--dt-spacing-d);border-radius:var(--notification-border-radius);background-color:var(--notification-background-color);position:relative;display:flex;flex-direction:var(--notification-direction);gap:var(--dt-spacing-d);font-size:var(--notification-font-size);line-height:var(--notification-line-height)}.c-notification[isCompact]{--notification-direction: row}.c-notification[position=full-width]{--notification-border-radius: var(--dt-radius-rounded-none)}.c-notification[variant=neutral-alternative]{--notification-background-color: var(--dt-color-container-default)}.c-notification[variant=info]{--notification-background-color: var(--dt-color-support-info-02);--notification-icon-fill: var(--dt-color-blue)}.c-notification[variant=success]{--notification-background-color: var(--dt-color-support-positive-02);--notification-icon-fill: var(--dt-color-content-positive)}.c-notification[variant=warning]{--notification-background-color: var(--dt-color-support-warning-02)}.c-notification[variant=error]{--notification-background-color: var(--dt-color-support-error-02);--notification-icon-fill: var(--dt-color-support-error)}.c-notification-heading{margin:0;margin-block-end:var(--dt-spacing-a);font-size:var(--notification-heading-font-size);line-height:var(--notification-heading-line-height)}@media (min-width: 768px){.c-notification-heading{--notification-heading-font-size: calc(var(--dt-font-heading-s-size--wide) * 1px);--notification-heading-line-height: calc(var(--dt-font-heading-s-line-height--wide) * 1px)}}.c-notification-content-section{display:flex;flex-direction:row;gap:var(--dt-spacing-c)}.c-notification-content-section[isDismissible]{max-width:calc(100% - var(--notification-close-icon-offset) - 40px)}.c-notification-icon-close{position:absolute;inset-block-start:var(--notification-close-icon-offset);inset-inline-end:var(--notification-close-icon-offset)}.c-notification-footer{display:flex;flex-direction:row;justify-content:flex-end;gap:var(--dt-spacing-d)}.c-notification-footer[isCompact]{align-self:flex-end}@media (max-width: 768px){.c-notification-footer[isStacked]{flex-direction:column-reverse}}.icon,::slotted([slot=icon]){display:inline-flex;color:var(--notification-icon-fill);margin-block-start:var(--notification-icon-offset)}@media (max-width: 768px){.icon,::slotted([slot=icon]){margin-block-start:0}}
23
23
  `;
24
24
  var D = Object.defineProperty, L = Object.getOwnPropertyDescriptor, a = (g, i, o, e) => {
25
- for (var s = e > 1 ? void 0 : e ? L(i, o) : i, f = g.length - 1, p; f >= 0; f--)
26
- (p = g[f]) && (s = (e ? p(i, o, s) : p(s)) || s);
27
- return e && s && D(i, o, s), s;
25
+ for (var r = e > 1 ? void 0 : e ? L(i, o) : i, f = g.length - 1, p; f >= 0; f--)
26
+ (p = g[f]) && (r = (e ? p(i, o, r) : p(r)) || r);
27
+ return e && r && D(i, o, r), r;
28
28
  };
29
29
  class n extends x {
30
30
  constructor() {
@@ -46,9 +46,13 @@ class n extends x {
46
46
  renderFooter() {
47
47
  const { leadingAction: i, supportingAction: o } = this;
48
48
  return d`
49
- <footer class="${h}-footer" data-test-id="${t}-footer" ?isCompact="${this.isCompact}" ?isStacked="${this.hasStackedActions && !this.isCompact}">
50
- ${o ? this.renderActionButton(o, "supporting") : c}
51
- ${i ? this.renderActionButton(i, "leading") : c}
49
+ <footer
50
+ class="${h}-footer"
51
+ data-test-id="${t}-footer"
52
+ ?isCompact="${this.isCompact}"
53
+ ?isStacked="${this.hasStackedActions && !this.isCompact}">
54
+ ${o ? this.renderActionButton(o, "supporting") : s}
55
+ ${i ? this.renderActionButton(i, "leading") : s}
52
56
  </footer>
53
57
  `;
54
58
  }
@@ -83,7 +87,7 @@ class n extends x {
83
87
  case "error":
84
88
  return d`<icon-alert-circle class="icon" size="m" data-test-id="${t}-heading-icon-error"></icon-alert-circle>`;
85
89
  default:
86
- return c;
90
+ return s;
87
91
  }
88
92
  }
89
93
  /**
@@ -94,11 +98,7 @@ class n extends x {
94
98
  * @private
95
99
  */
96
100
  renderIcon() {
97
- const i = this._iconSlot.length > 0;
98
- return d`
99
- ${i ? c : this.getDefaultVariantIcon()}
100
- <slot name="icon"></slot>
101
- `;
101
+ return d`<slot name="icon">${this.getDefaultVariantIcon()}</slot>`;
102
102
  }
103
103
  /**
104
104
  * Template for the close button element. Called within the
@@ -126,18 +126,10 @@ class n extends x {
126
126
  * @private
127
127
  */
128
128
  handleCloseButton() {
129
- this.closeNotificationComponent(), m(this, E, { targetNotification: this });
130
- }
131
- /**
132
- * Util method responsible to close the component.
133
- *
134
- * @private
135
- */
136
- closeNotificationComponent() {
137
- this.isOpen = !1;
129
+ this.isOpen = !1, m(this, E, { targetNotification: this });
138
130
  }
139
131
  /**
140
- * It handle the action button action.
132
+ * It handles the action button action.
141
133
  * Also triggers an event according to its `actionType`.
142
134
  *
143
135
  * @param {'leading' | 'supporting'} actionType
@@ -157,26 +149,26 @@ class n extends x {
157
149
  * @private
158
150
  */
159
151
  renderActionButton(i, o) {
160
- const { text: e, ariaLabel: s } = i;
152
+ const { text: e, ariaLabel: r } = i;
161
153
  return e ? d`
162
154
  <pie-button
163
155
  variant="${o === "leading" ? "primary" : "ghost"}"
164
156
  size="small-productive"
165
- aria-label="${s || c}"
157
+ aria-label="${r || s}"
166
158
  @click="${() => this.handleActionClick(o)}"
167
159
  data-test-id="${t}-${o}-action"
168
160
  ?isFullWidth="${this.hasStackedActions}"
169
161
  type="button">
170
162
  ${e}
171
163
  </pie-button>
172
- ` : c;
164
+ ` : s;
173
165
  }
174
166
  render() {
175
167
  const {
176
168
  variant: i,
177
169
  position: o,
178
170
  heading: e,
179
- isDismissible: s,
171
+ isDismissible: r,
180
172
  isCompact: f,
181
173
  hideIcon: p,
182
174
  leadingAction: u,
@@ -184,8 +176,8 @@ class n extends x {
184
176
  aria: v
185
177
  } = this;
186
178
  if (!C)
187
- return c;
188
- const $ = s && !f;
179
+ return s;
180
+ const $ = r && !f;
189
181
  return d`
190
182
  <div
191
183
  data-test-id="${t}"
@@ -195,64 +187,64 @@ class n extends x {
195
187
  ?isCompact="${f}"
196
188
  role="region"
197
189
  aria-live="${i === "error" ? "assertive" : "polite"}"
198
- aria-labelledby="${e ? `${t}-heading` : c}"
190
+ aria-labelledby="${e ? `${t}-heading` : s}"
199
191
  aria-label="${!e && y(v == null ? void 0 : v.label)}">
200
- ${$ ? this.renderCloseButton() : c}
192
+ ${$ ? this.renderCloseButton() : s}
201
193
 
202
194
  <section class="${h}-content-section" ?isDismissible="${$}">
203
- ${p ? c : this.renderIcon()}
195
+ ${p ? s : this.renderIcon()}
204
196
  <article>
205
- ${e ? this.renderNotificationHeading() : c}
197
+ ${e ? this.renderNotificationHeading() : s}
206
198
  <slot></slot>
207
199
  </article>
208
200
  </section>
209
201
 
210
- ${u != null && u.text ? this.renderFooter() : c}
202
+ ${u != null && u.text ? this.renderFooter() : s}
211
203
  </div>`;
212
204
  }
213
205
  }
214
206
  n.styles = O(B);
215
207
  a([
216
- r({ type: Boolean })
208
+ c({ type: Boolean })
217
209
  ], n.prototype, "isOpen", 2);
218
210
  a([
219
- r(),
220
- b(t, k, l.variant)
211
+ c(),
212
+ b(t, _, l.variant)
221
213
  ], n.prototype, "variant", 2);
222
214
  a([
223
- r(),
215
+ c(),
224
216
  b(t, A, l.position)
225
217
  ], n.prototype, "position", 2);
226
218
  a([
227
- r({ type: Boolean })
219
+ c({ type: Boolean })
228
220
  ], n.prototype, "isDismissible", 2);
229
221
  a([
230
- r({ type: Boolean })
222
+ c({ type: Boolean })
231
223
  ], n.prototype, "isCompact", 2);
232
224
  a([
233
- r({ type: String })
225
+ c({ type: String })
234
226
  ], n.prototype, "heading", 2);
235
227
  a([
236
- r(),
228
+ c(),
237
229
  b(t, w, l.headingLevel)
238
230
  ], n.prototype, "headingLevel", 2);
239
231
  a([
240
- r({ type: Boolean })
232
+ c({ type: Boolean })
241
233
  ], n.prototype, "hideIcon", 2);
242
234
  a([
243
- r({ type: Object })
235
+ c({ type: Object })
244
236
  ], n.prototype, "leadingAction", 2);
245
237
  a([
246
- r({ type: Object })
238
+ c({ type: Object })
247
239
  ], n.prototype, "supportingAction", 2);
248
240
  a([
249
- r({ type: Boolean })
241
+ c({ type: Boolean })
250
242
  ], n.prototype, "hasStackedActions", 2);
251
243
  a([
252
- r({ type: Object })
244
+ c({ type: Object })
253
245
  ], n.prototype, "aria", 2);
254
246
  a([
255
- _({ slot: "icon" })
247
+ k({ slot: "icon" })
256
248
  ], n.prototype, "_iconSlot", 2);
257
249
  I(t, n);
258
250
  export {
@@ -266,5 +258,5 @@ export {
266
258
  l as defaultProps,
267
259
  w as headingLevels,
268
260
  A as positions,
269
- k as variants
261
+ _ as variants
270
262
  };
package/dist/react.d.ts CHANGED
@@ -121,6 +121,8 @@ export declare const PieNotification: React_2.ForwardRefExoticComponent<Notifica
121
121
  * @event {CustomEvent} pie-notification-supporting-action-click - When the notification supporting action is clicked.
122
122
  * @event {CustomEvent} pie-notification-close - When the notification is closed.
123
123
  * @event {CustomEvent} pie-notification-open - When the notification is opened.
124
+ * @slot - Default slot
125
+ * @slot icon - The icon slot
124
126
  */
125
127
  declare class PieNotification_2 extends LitElement implements NotificationProps {
126
128
  isOpen: boolean;
@@ -185,13 +187,7 @@ declare class PieNotification_2 extends LitElement implements NotificationProps
185
187
  */
186
188
  private handleCloseButton;
187
189
  /**
188
- * Util method responsible to close the component.
189
- *
190
- * @private
191
- */
192
- private closeNotificationComponent;
193
- /**
194
- * It handle the action button action.
190
+ * It handles the action button action.
195
191
  * Also triggers an event according to its `actionType`.
196
192
  *
197
193
  * @param {'leading' | 'supporting'} actionType
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@justeattakeaway/pie-notification",
3
3
  "description": "PIE Design System Notification built using Web Components",
4
- "version": "0.9.3",
4
+ "version": "0.10.1",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -36,13 +36,14 @@
36
36
  "license": "Apache-2.0",
37
37
  "devDependencies": {
38
38
  "@custom-elements-manifest/analyzer": "0.9.0",
39
- "@justeattakeaway/pie-components-config": "0.16.0",
39
+ "@justeattakeaway/pie-components-config": "0.18.0",
40
+ "@justeattakeaway/pie-css": "0.12.1",
40
41
  "@justeattakeaway/pie-wrapper-react": "0.14.1",
41
42
  "cem-plugin-module-file-extensions": "0.0.5"
42
43
  },
43
44
  "dependencies": {
44
- "@justeattakeaway/pie-icon-button": "0.28.9",
45
- "@justeattakeaway/pie-icons-webc": "0.24.2",
45
+ "@justeattakeaway/pie-icon-button": "0.28.11",
46
+ "@justeattakeaway/pie-icons-webc": "0.25.1",
46
47
  "@justeattakeaway/pie-webc-core": "0.24.0"
47
48
  },
48
49
  "volta": {
package/src/defs.ts CHANGED
@@ -121,7 +121,7 @@ export type DefaultProps = ComponentDefaultProps<NotificationProps, keyof Omit<N
121
121
  export const defaultProps: DefaultProps = {
122
122
  variant: 'neutral',
123
123
  position: 'inline-content',
124
- isDismissible: true,
124
+ isDismissible: false,
125
125
  isCompact: false,
126
126
  headingLevel: 'h2',
127
127
  hideIcon: false,
package/src/index.ts CHANGED
@@ -42,6 +42,8 @@ export * from './defs';
42
42
  * @event {CustomEvent} pie-notification-supporting-action-click - When the notification supporting action is clicked.
43
43
  * @event {CustomEvent} pie-notification-close - When the notification is closed.
44
44
  * @event {CustomEvent} pie-notification-open - When the notification is opened.
45
+ * @slot - Default slot
46
+ * @slot icon - The icon slot
45
47
  */
46
48
  export class PieNotification extends LitElement implements NotificationProps {
47
49
  @property({ type: Boolean })
@@ -107,9 +109,13 @@ export class PieNotification extends LitElement implements NotificationProps {
107
109
  private renderFooter () {
108
110
  const { leadingAction, supportingAction } = this;
109
111
  return html`
110
- <footer class="${componentClass}-footer" data-test-id="${componentSelector}-footer" ?isCompact="${this.isCompact}" ?isStacked="${this.hasStackedActions && !this.isCompact}">
111
- ${supportingAction ? this.renderActionButton(supportingAction, 'supporting') : nothing}
112
- ${leadingAction ? this.renderActionButton(leadingAction, 'leading') : nothing}
112
+ <footer
113
+ class="${componentClass}-footer"
114
+ data-test-id="${componentSelector}-footer"
115
+ ?isCompact="${this.isCompact}"
116
+ ?isStacked="${this.hasStackedActions && !this.isCompact}">
117
+ ${supportingAction ? this.renderActionButton(supportingAction, 'supporting') : nothing}
118
+ ${leadingAction ? this.renderActionButton(leadingAction, 'leading') : nothing}
113
119
  </footer>
114
120
  `;
115
121
  }
@@ -160,12 +166,7 @@ export class PieNotification extends LitElement implements NotificationProps {
160
166
  * @private
161
167
  */
162
168
  private renderIcon (): TemplateResult | typeof nothing {
163
- const hasExternalIcon = this._iconSlot.length > 0;
164
-
165
- return html`
166
- ${!hasExternalIcon ? this.getDefaultVariantIcon() : nothing}
167
- <slot name="icon"></slot>
168
- `;
169
+ return html`<slot name="icon">${this.getDefaultVariantIcon()}</slot>`;
169
170
  }
170
171
 
171
172
  /**
@@ -194,21 +195,12 @@ export class PieNotification extends LitElement implements NotificationProps {
194
195
  * @private
195
196
  */
196
197
  private handleCloseButton () {
197
- this.closeNotificationComponent();
198
- dispatchCustomEvent(this, ON_NOTIFICATION_CLOSE_EVENT, { targetNotification: this });
199
- }
200
-
201
- /**
202
- * Util method responsible to close the component.
203
- *
204
- * @private
205
- */
206
- private closeNotificationComponent () {
207
198
  this.isOpen = false;
199
+ dispatchCustomEvent(this, ON_NOTIFICATION_CLOSE_EVENT, { targetNotification: this });
208
200
  }
209
201
 
210
202
  /**
211
- * It handle the action button action.
203
+ * It handles the action button action.
212
204
  * Also triggers an event according to its `actionType`.
213
205
  *
214
206
  * @param {'leading' | 'supporting'} actionType