@justeattakeaway/pie-notification 0.4.0 → 0.5.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.
@@ -27,6 +27,46 @@
27
27
  "text": "['h2', 'h3', 'h4', 'h5', 'h6']"
28
28
  },
29
29
  "default": "['h2', 'h3', 'h4', 'h5', 'h6']"
30
+ },
31
+ {
32
+ "kind": "variable",
33
+ "name": "componentSelector",
34
+ "type": {
35
+ "text": "string"
36
+ },
37
+ "default": "'pie-notification'"
38
+ },
39
+ {
40
+ "kind": "variable",
41
+ "name": "componentClass",
42
+ "type": {
43
+ "text": "string"
44
+ },
45
+ "default": "'c-notification'"
46
+ },
47
+ {
48
+ "kind": "variable",
49
+ "name": "ON_NOTIFICATION_CLOSE_EVENT",
50
+ "default": "`${componentSelector}-close`",
51
+ "description": "Event name for when the notification is closed."
52
+ },
53
+ {
54
+ "kind": "variable",
55
+ "name": "ON_NOTIFICATION_OPEN_EVENT",
56
+ "default": "`${componentSelector}-open`",
57
+ "description": "Event name for when the notification is opened."
58
+ },
59
+ {
60
+ "kind": "variable",
61
+ "name": "ON_NOTIFICATION_LEADING_ACTION_CLICK_EVENT",
62
+ "default": "`${componentSelector}-leading-action-click`",
63
+ "description": "Event name for when the notification leading action is clicked."
64
+ },
65
+ {
66
+ "kind": "variable",
67
+ "name": "ON_NOTIFICATION_SUPPORTING_ACTION_CLICK_EVENT",
68
+ "default": "`${componentSelector}-supporting-action-click`",
69
+ "description": "Event name for when the notification supporting action is clicked."
30
70
  }
31
71
  ],
32
72
  "exports": [
@@ -45,6 +85,54 @@
45
85
  "name": "headingLevels",
46
86
  "module": "src/defs.js"
47
87
  }
88
+ },
89
+ {
90
+ "kind": "js",
91
+ "name": "componentSelector",
92
+ "declaration": {
93
+ "name": "componentSelector",
94
+ "module": "src/defs.js"
95
+ }
96
+ },
97
+ {
98
+ "kind": "js",
99
+ "name": "componentClass",
100
+ "declaration": {
101
+ "name": "componentClass",
102
+ "module": "src/defs.js"
103
+ }
104
+ },
105
+ {
106
+ "kind": "js",
107
+ "name": "ON_NOTIFICATION_CLOSE_EVENT",
108
+ "declaration": {
109
+ "name": "ON_NOTIFICATION_CLOSE_EVENT",
110
+ "module": "src/defs.js"
111
+ }
112
+ },
113
+ {
114
+ "kind": "js",
115
+ "name": "ON_NOTIFICATION_OPEN_EVENT",
116
+ "declaration": {
117
+ "name": "ON_NOTIFICATION_OPEN_EVENT",
118
+ "module": "src/defs.js"
119
+ }
120
+ },
121
+ {
122
+ "kind": "js",
123
+ "name": "ON_NOTIFICATION_LEADING_ACTION_CLICK_EVENT",
124
+ "declaration": {
125
+ "name": "ON_NOTIFICATION_LEADING_ACTION_CLICK_EVENT",
126
+ "module": "src/defs.js"
127
+ }
128
+ },
129
+ {
130
+ "kind": "js",
131
+ "name": "ON_NOTIFICATION_SUPPORTING_ACTION_CLICK_EVENT",
132
+ "declaration": {
133
+ "name": "ON_NOTIFICATION_SUPPORTING_ACTION_CLICK_EVENT",
134
+ "module": "src/defs.js"
135
+ }
48
136
  }
49
137
  ]
50
138
  },
@@ -77,6 +165,16 @@
77
165
  "default": "'neutral'",
78
166
  "attribute": "variant"
79
167
  },
168
+ {
169
+ "kind": "field",
170
+ "name": "isDismissible",
171
+ "type": {
172
+ "text": "boolean"
173
+ },
174
+ "privacy": "public",
175
+ "default": "true",
176
+ "attribute": "isDismissible"
177
+ },
80
178
  {
81
179
  "kind": "field",
82
180
  "name": "isCompact",
@@ -126,6 +224,34 @@
126
224
  "default": "false",
127
225
  "attribute": "hideCloseIcon"
128
226
  },
227
+ {
228
+ "kind": "field",
229
+ "name": "leadingAction",
230
+ "type": {
231
+ "text": "NotificationProps['leadingAction']"
232
+ },
233
+ "privacy": "public",
234
+ "attribute": "leadingAction"
235
+ },
236
+ {
237
+ "kind": "field",
238
+ "name": "supportingAction",
239
+ "type": {
240
+ "text": "NotificationProps['supportingAction']"
241
+ },
242
+ "privacy": "public",
243
+ "attribute": "supportingAction"
244
+ },
245
+ {
246
+ "kind": "field",
247
+ "name": "hasStackedActions",
248
+ "type": {
249
+ "text": "boolean"
250
+ },
251
+ "privacy": "public",
252
+ "default": "false",
253
+ "attribute": "hasStackedActions"
254
+ },
129
255
  {
130
256
  "kind": "field",
131
257
  "name": "_iconSlot",
@@ -151,6 +277,15 @@
151
277
  "privacy": "protected",
152
278
  "default": "false"
153
279
  },
280
+ {
281
+ "kind": "field",
282
+ "name": "_hasContentGutter",
283
+ "type": {
284
+ "text": "boolean"
285
+ },
286
+ "privacy": "protected",
287
+ "default": "false"
288
+ },
154
289
  {
155
290
  "kind": "method",
156
291
  "name": "updateIconProperties",
@@ -161,6 +296,21 @@
161
296
  "kind": "method",
162
297
  "name": "renderFooter",
163
298
  "privacy": "private",
299
+ "parameters": [
300
+ {
301
+ "name": "leadingAction",
302
+ "type": {
303
+ "text": "ActionProps"
304
+ }
305
+ },
306
+ {
307
+ "name": "supportingAction",
308
+ "optional": true,
309
+ "type": {
310
+ "text": "ActionProps"
311
+ }
312
+ }
313
+ ],
164
314
  "description": "Template for the footer area\nCalled within the main render function."
165
315
  },
166
316
  {
@@ -271,6 +421,89 @@
271
421
  }
272
422
  },
273
423
  "description": "Template for the close button element. Called within the\nmain render function."
424
+ },
425
+ {
426
+ "kind": "method",
427
+ "name": "handleCloseButton",
428
+ "privacy": "private",
429
+ "description": "It handles the action when user clicks in the close button.\nAlso triggers an event when is executed."
430
+ },
431
+ {
432
+ "kind": "method",
433
+ "name": "closeNotificationComponent",
434
+ "privacy": "private",
435
+ "description": "Util method responsible to close the component."
436
+ },
437
+ {
438
+ "kind": "method",
439
+ "name": "handleActionClick",
440
+ "privacy": "private",
441
+ "parameters": [
442
+ {
443
+ "name": "actionType",
444
+ "type": {
445
+ "text": "'leading' | 'supporting'"
446
+ }
447
+ }
448
+ ],
449
+ "description": "It handle the action button action.\nAlso triggers an event according to its `actionType`."
450
+ },
451
+ {
452
+ "kind": "method",
453
+ "name": "renderActionButton",
454
+ "privacy": "private",
455
+ "return": {
456
+ "type": {
457
+ "text": "TemplateResult | typeof nothing"
458
+ }
459
+ },
460
+ "parameters": [
461
+ {
462
+ "name": "action",
463
+ "type": {
464
+ "text": "ActionProps"
465
+ },
466
+ "description": "The action properties."
467
+ },
468
+ {
469
+ "name": "actionType",
470
+ "type": {
471
+ "text": "'leading' | 'supporting'"
472
+ },
473
+ "description": "The type of the action."
474
+ }
475
+ ],
476
+ "description": "Render the action button depending on action type and its action."
477
+ }
478
+ ],
479
+ "events": [
480
+ {
481
+ "type": {
482
+ "text": "CustomEvent"
483
+ },
484
+ "description": " When the notification leading action is clicked.",
485
+ "name": "pie-notification-leading-action-click"
486
+ },
487
+ {
488
+ "type": {
489
+ "text": "CustomEvent"
490
+ },
491
+ "description": "When the notification supporting action is clicked.",
492
+ "name": "pie-notification-supporting-action-click"
493
+ },
494
+ {
495
+ "type": {
496
+ "text": "CustomEvent"
497
+ },
498
+ "description": "When the notification is closed.",
499
+ "name": "pie-notification-close"
500
+ },
501
+ {
502
+ "type": {
503
+ "text": "CustomEvent"
504
+ },
505
+ "description": "When the notification is opened.",
506
+ "name": "pie-notification-open"
274
507
  }
275
508
  ],
276
509
  "attributes": [
@@ -290,6 +523,14 @@
290
523
  "default": "'neutral'",
291
524
  "fieldName": "variant"
292
525
  },
526
+ {
527
+ "name": "isDismissible",
528
+ "type": {
529
+ "text": "boolean"
530
+ },
531
+ "default": "true",
532
+ "fieldName": "isDismissible"
533
+ },
293
534
  {
294
535
  "name": "isCompact",
295
536
  "type": {
@@ -328,6 +569,28 @@
328
569
  },
329
570
  "default": "false",
330
571
  "fieldName": "hideCloseIcon"
572
+ },
573
+ {
574
+ "name": "leadingAction",
575
+ "type": {
576
+ "text": "NotificationProps['leadingAction']"
577
+ },
578
+ "fieldName": "leadingAction"
579
+ },
580
+ {
581
+ "name": "supportingAction",
582
+ "type": {
583
+ "text": "NotificationProps['supportingAction']"
584
+ },
585
+ "fieldName": "supportingAction"
586
+ },
587
+ {
588
+ "name": "hasStackedActions",
589
+ "type": {
590
+ "text": "boolean"
591
+ },
592
+ "default": "false",
593
+ "fieldName": "hasStackedActions"
331
594
  }
332
595
  ],
333
596
  "superclass": {
package/dist/index.d.ts CHANGED
@@ -1,8 +1,24 @@
1
1
  import type { CSSResult } from 'lit';
2
2
  import type { LitElement } from 'lit';
3
+ import type { nothing } from 'lit';
3
4
  import type { PropertyValues } from 'lit';
4
5
  import type { TemplateResult } from 'lit';
5
6
 
7
+ export declare type ActionProps = {
8
+ /**
9
+ * The text to display inside the button.
10
+ */
11
+ text: string;
12
+ /**
13
+ * The ARIA label for the button.
14
+ */
15
+ ariaLabel?: string;
16
+ };
17
+
18
+ export declare const componentClass = "c-notification";
19
+
20
+ export declare const componentSelector = "pie-notification";
21
+
6
22
  export declare const headingLevels: readonly ["h2", "h3", "h4", "h5", "h6"];
7
23
 
8
24
  export declare interface NotificationProps {
@@ -10,6 +26,10 @@ export declare interface NotificationProps {
10
26
  * Set the variant of the notification.
11
27
  */
12
28
  variant?: typeof variants[number];
29
+ /**
30
+ * When true, allows dismissing the notification by clicking on the close button.
31
+ */
32
+ isDismissible?: boolean;
13
33
  /**
14
34
  * When true, the footer aligns to the header and icons which makes the component compact.
15
35
  */
@@ -30,22 +50,71 @@ export declare interface NotificationProps {
30
50
  * When true, the notification is set to be open and visible.
31
51
  */
32
52
  isOpen?: boolean;
53
+ /**
54
+ * The leading action for the notification.
55
+ */
56
+ leadingAction?: ActionProps;
57
+ /**
58
+ * The supporting action for the notification.
59
+ */
60
+ supportingAction?: ActionProps;
61
+ /**
62
+ * When true, the notification will stack the action buttons on narrow screens.
63
+ */
64
+ hasStackedActions?: boolean;
33
65
  }
34
66
 
67
+ /**
68
+ * Event name for when the notification is closed.
69
+ *
70
+ * @constant
71
+ */
72
+ export declare const ON_NOTIFICATION_CLOSE_EVENT: string;
73
+
74
+ /**
75
+ * Event name for when the notification leading action is clicked.
76
+ *
77
+ * @constant
78
+ */
79
+ export declare const ON_NOTIFICATION_LEADING_ACTION_CLICK_EVENT: string;
80
+
81
+ /**
82
+ * Event name for when the notification is opened.
83
+ *
84
+ * @constant
85
+ */
86
+ export declare const ON_NOTIFICATION_OPEN_EVENT: string;
87
+
88
+ /**
89
+ * Event name for when the notification supporting action is clicked.
90
+ *
91
+ * @constant
92
+ */
93
+ export declare const ON_NOTIFICATION_SUPPORTING_ACTION_CLICK_EVENT: string;
94
+
35
95
  /**
36
96
  * @tagname pie-notification
97
+ * @event {CustomEvent} pie-notification-leading-action-click - When the notification leading action is clicked.
98
+ * @event {CustomEvent} pie-notification-supporting-action-click - When the notification supporting action is clicked.
99
+ * @event {CustomEvent} pie-notification-close - When the notification is closed.
100
+ * @event {CustomEvent} pie-notification-open - When the notification is opened.
37
101
  */
38
102
  export declare class PieNotification extends LitElement implements NotificationProps {
39
103
  isOpen: boolean;
40
104
  variant: NonNullable<NotificationProps['variant']>;
105
+ isDismissible: boolean;
41
106
  isCompact: boolean;
42
107
  heading: string;
43
108
  headingLevel: NonNullable<NotificationProps['headingLevel']>;
44
109
  hideIcon: boolean;
45
110
  hideCloseIcon: boolean;
111
+ leadingAction: NotificationProps['leadingAction'];
112
+ supportingAction: NotificationProps['supportingAction'];
113
+ hasStackedActions: boolean;
46
114
  _iconSlot: Array<HTMLElement>;
47
115
  protected _hasExternalIcon: boolean;
48
116
  protected _hasIconClass: boolean;
117
+ protected _hasContentGutter: boolean;
49
118
  static styles: CSSResult;
50
119
  /**
51
120
  * Lifecycle method executed after component renders.
@@ -56,6 +125,12 @@ export declare class PieNotification extends LitElement implements NotificationP
56
125
  * It update icon properties if variant has changes.
57
126
  */
58
127
  protected willUpdate(_changedProperties: PropertyValues<this>): void;
128
+ /**
129
+ * Lifecycle method executed when component is updated.
130
+ * It dispatches an event if notification is opened.
131
+ * It applies a gutter if there's no heading content in order to avoid the close button overlap the content.
132
+ */
133
+ protected updated(_changedProperties: PropertyValues<this>): void;
59
134
  /**
60
135
  * Method responsible to check if an external icon has been provided.
61
136
  * It reads from icon slot if there is an external icon as well check if variant has default icon.
@@ -123,7 +198,39 @@ export declare class PieNotification extends LitElement implements NotificationP
123
198
  * @private
124
199
  */
125
200
  private renderCloseButton;
126
- render(): TemplateResult;
201
+ /**
202
+ * It handles the action when user clicks in the close button.
203
+ * Also triggers an event when is executed.
204
+ *
205
+ * @private
206
+ */
207
+ private handleCloseButton;
208
+ /**
209
+ * Util method responsible to close the component.
210
+ *
211
+ * @private
212
+ */
213
+ private closeNotificationComponent;
214
+ /**
215
+ * It handle the action button action.
216
+ * Also triggers an event according to its `actionType`.
217
+ *
218
+ * @param {'leading' | 'supporting'} actionType
219
+ *
220
+ * @private
221
+ */
222
+ private handleActionClick;
223
+ /**
224
+ * Render the action button depending on action type and its action.
225
+ *
226
+ * @param {ActionProps} action - The action properties.
227
+ * @param {'leading' | 'supporting'} actionType - The type of the action.
228
+ *
229
+ * @returns {TemplateResult | typeof nothing} - The rendered action button or nothing if the action text is not defined.
230
+ * @private
231
+ */
232
+ private renderActionButton;
233
+ render(): typeof nothing | TemplateResult;
127
234
  }
128
235
 
129
236
  export declare const variants: readonly ["neutral", "neutral-alternative", "info", "success", "warning", "error"];