@justeattakeaway/pie-notification 0.6.0 → 0.6.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.
- package/custom-elements.json +16 -46
- package/dist/index.d.ts +5 -0
- package/dist/index.js +76 -66
- package/dist/react.d.ts +5 -0
- package/dist/react.js +5 -4
- package/package.json +4 -4
- package/src/defs.ts +15 -0
- package/src/index.ts +16 -15
package/custom-elements.json
CHANGED
|
@@ -75,6 +75,14 @@
|
|
|
75
75
|
"name": "ON_NOTIFICATION_SUPPORTING_ACTION_CLICK_EVENT",
|
|
76
76
|
"default": "`${componentSelector}-supporting-action-click`",
|
|
77
77
|
"description": "Event name for when the notification supporting action is clicked."
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"kind": "variable",
|
|
81
|
+
"name": "defaultProps",
|
|
82
|
+
"type": {
|
|
83
|
+
"text": "DefaultProps"
|
|
84
|
+
},
|
|
85
|
+
"default": "{\n isOpen: true,\n variant: 'neutral',\n position: 'inline-content',\n isDismissible: true,\n isCompact: false,\n headingLevel: 'h2',\n hideIcon: false,\n hasStackedActions: false,\n}"
|
|
78
86
|
}
|
|
79
87
|
],
|
|
80
88
|
"exports": [
|
|
@@ -149,6 +157,14 @@
|
|
|
149
157
|
"name": "ON_NOTIFICATION_SUPPORTING_ACTION_CLICK_EVENT",
|
|
150
158
|
"module": "src/defs.js"
|
|
151
159
|
}
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"kind": "js",
|
|
163
|
+
"name": "defaultProps",
|
|
164
|
+
"declaration": {
|
|
165
|
+
"name": "defaultProps",
|
|
166
|
+
"module": "src/defs.js"
|
|
167
|
+
}
|
|
152
168
|
}
|
|
153
169
|
]
|
|
154
170
|
},
|
|
@@ -164,11 +180,7 @@
|
|
|
164
180
|
{
|
|
165
181
|
"kind": "field",
|
|
166
182
|
"name": "isOpen",
|
|
167
|
-
"type": {
|
|
168
|
-
"text": "boolean"
|
|
169
|
-
},
|
|
170
183
|
"privacy": "public",
|
|
171
|
-
"default": "true",
|
|
172
184
|
"attribute": "isOpen"
|
|
173
185
|
},
|
|
174
186
|
{
|
|
@@ -178,7 +190,6 @@
|
|
|
178
190
|
"text": "NonNullable<NotificationProps['variant']>"
|
|
179
191
|
},
|
|
180
192
|
"privacy": "public",
|
|
181
|
-
"default": "'neutral'",
|
|
182
193
|
"attribute": "variant"
|
|
183
194
|
},
|
|
184
195
|
{
|
|
@@ -188,27 +199,18 @@
|
|
|
188
199
|
"text": "NonNullable<NotificationProps['position']>"
|
|
189
200
|
},
|
|
190
201
|
"privacy": "public",
|
|
191
|
-
"default": "'inline-content'",
|
|
192
202
|
"attribute": "position"
|
|
193
203
|
},
|
|
194
204
|
{
|
|
195
205
|
"kind": "field",
|
|
196
206
|
"name": "isDismissible",
|
|
197
|
-
"type": {
|
|
198
|
-
"text": "boolean"
|
|
199
|
-
},
|
|
200
207
|
"privacy": "public",
|
|
201
|
-
"default": "true",
|
|
202
208
|
"attribute": "isDismissible"
|
|
203
209
|
},
|
|
204
210
|
{
|
|
205
211
|
"kind": "field",
|
|
206
212
|
"name": "isCompact",
|
|
207
|
-
"type": {
|
|
208
|
-
"text": "boolean"
|
|
209
|
-
},
|
|
210
213
|
"privacy": "public",
|
|
211
|
-
"default": "false",
|
|
212
214
|
"attribute": "isCompact"
|
|
213
215
|
},
|
|
214
216
|
{
|
|
@@ -227,17 +229,12 @@
|
|
|
227
229
|
"text": "NonNullable<NotificationProps['headingLevel']>"
|
|
228
230
|
},
|
|
229
231
|
"privacy": "public",
|
|
230
|
-
"default": "'h2'",
|
|
231
232
|
"attribute": "headingLevel"
|
|
232
233
|
},
|
|
233
234
|
{
|
|
234
235
|
"kind": "field",
|
|
235
236
|
"name": "hideIcon",
|
|
236
|
-
"type": {
|
|
237
|
-
"text": "boolean"
|
|
238
|
-
},
|
|
239
237
|
"privacy": "public",
|
|
240
|
-
"default": "false",
|
|
241
238
|
"attribute": "hideIcon"
|
|
242
239
|
},
|
|
243
240
|
{
|
|
@@ -261,11 +258,7 @@
|
|
|
261
258
|
{
|
|
262
259
|
"kind": "field",
|
|
263
260
|
"name": "hasStackedActions",
|
|
264
|
-
"type": {
|
|
265
|
-
"text": "boolean"
|
|
266
|
-
},
|
|
267
261
|
"privacy": "public",
|
|
268
|
-
"default": "false",
|
|
269
262
|
"attribute": "hasStackedActions"
|
|
270
263
|
},
|
|
271
264
|
{
|
|
@@ -516,10 +509,6 @@
|
|
|
516
509
|
"attributes": [
|
|
517
510
|
{
|
|
518
511
|
"name": "isOpen",
|
|
519
|
-
"type": {
|
|
520
|
-
"text": "boolean"
|
|
521
|
-
},
|
|
522
|
-
"default": "true",
|
|
523
512
|
"fieldName": "isOpen"
|
|
524
513
|
},
|
|
525
514
|
{
|
|
@@ -527,7 +516,6 @@
|
|
|
527
516
|
"type": {
|
|
528
517
|
"text": "NonNullable<NotificationProps['variant']>"
|
|
529
518
|
},
|
|
530
|
-
"default": "'neutral'",
|
|
531
519
|
"fieldName": "variant"
|
|
532
520
|
},
|
|
533
521
|
{
|
|
@@ -535,23 +523,14 @@
|
|
|
535
523
|
"type": {
|
|
536
524
|
"text": "NonNullable<NotificationProps['position']>"
|
|
537
525
|
},
|
|
538
|
-
"default": "'inline-content'",
|
|
539
526
|
"fieldName": "position"
|
|
540
527
|
},
|
|
541
528
|
{
|
|
542
529
|
"name": "isDismissible",
|
|
543
|
-
"type": {
|
|
544
|
-
"text": "boolean"
|
|
545
|
-
},
|
|
546
|
-
"default": "true",
|
|
547
530
|
"fieldName": "isDismissible"
|
|
548
531
|
},
|
|
549
532
|
{
|
|
550
533
|
"name": "isCompact",
|
|
551
|
-
"type": {
|
|
552
|
-
"text": "boolean"
|
|
553
|
-
},
|
|
554
|
-
"default": "false",
|
|
555
534
|
"fieldName": "isCompact"
|
|
556
535
|
},
|
|
557
536
|
{
|
|
@@ -566,15 +545,10 @@
|
|
|
566
545
|
"type": {
|
|
567
546
|
"text": "NonNullable<NotificationProps['headingLevel']>"
|
|
568
547
|
},
|
|
569
|
-
"default": "'h2'",
|
|
570
548
|
"fieldName": "headingLevel"
|
|
571
549
|
},
|
|
572
550
|
{
|
|
573
551
|
"name": "hideIcon",
|
|
574
|
-
"type": {
|
|
575
|
-
"text": "boolean"
|
|
576
|
-
},
|
|
577
|
-
"default": "false",
|
|
578
552
|
"fieldName": "hideIcon"
|
|
579
553
|
},
|
|
580
554
|
{
|
|
@@ -593,10 +567,6 @@
|
|
|
593
567
|
},
|
|
594
568
|
{
|
|
595
569
|
"name": "hasStackedActions",
|
|
596
|
-
"type": {
|
|
597
|
-
"text": "boolean"
|
|
598
|
-
},
|
|
599
|
-
"default": "false",
|
|
600
570
|
"fieldName": "hasStackedActions"
|
|
601
571
|
}
|
|
602
572
|
],
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ComponentDefaultPropsGeneric } from '@justeattakeaway/pie-webc-core';
|
|
1
2
|
import type { CSSResult } from 'lit';
|
|
2
3
|
import type { LitElement } from 'lit';
|
|
3
4
|
import type { nothing } from 'lit';
|
|
@@ -19,6 +20,10 @@ export declare const componentClass = "c-notification";
|
|
|
19
20
|
|
|
20
21
|
export declare const componentSelector = "pie-notification";
|
|
21
22
|
|
|
23
|
+
export declare type DefaultProps = ComponentDefaultPropsGeneric<NotificationProps, 'isOpen' | 'variant' | 'position' | 'isDismissible' | 'isCompact' | 'headingLevel' | 'hideIcon' | 'hasStackedActions'>;
|
|
24
|
+
|
|
25
|
+
export declare const defaultProps: DefaultProps;
|
|
26
|
+
|
|
22
27
|
export declare const headingLevels: readonly ["h2", "h3", "h4", "h5", "h6"];
|
|
23
28
|
|
|
24
29
|
export declare interface NotificationProps {
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { unsafeCSS as
|
|
2
|
-
import { html as
|
|
3
|
-
import { validPropertyValues as
|
|
4
|
-
import { property as
|
|
1
|
+
import { unsafeCSS as O, LitElement as x, nothing as c } from "lit";
|
|
2
|
+
import { html as d, unsafeStatic as E } from "lit/static-html.js";
|
|
3
|
+
import { validPropertyValues as v, defineCustomElement as k, dispatchCustomEvent as g } from "@justeattakeaway/pie-webc-core";
|
|
4
|
+
import { property as l, queryAssignedElements as w, state as $ } from "lit/decorators.js";
|
|
5
5
|
import "@justeattakeaway/pie-button";
|
|
6
6
|
import "@justeattakeaway/pie-icon-button";
|
|
7
7
|
import "@justeattakeaway/pie-icons-webc/dist/IconAlertCircle.js";
|
|
@@ -9,16 +9,25 @@ import "@justeattakeaway/pie-icons-webc/dist/IconAlertTriangle.js";
|
|
|
9
9
|
import "@justeattakeaway/pie-icons-webc/dist/IconCheckCircle.js";
|
|
10
10
|
import "@justeattakeaway/pie-icons-webc/dist/IconClose.js";
|
|
11
11
|
import "@justeattakeaway/pie-icons-webc/dist/IconInfoCircle.js";
|
|
12
|
-
const
|
|
12
|
+
const A = ["neutral", "neutral-alternative", "info", "success", "warning", "error"], z = ["h2", "h3", "h4", "h5", "h6"], S = ["inline-content", "full-width"], o = "pie-notification", h = "c-notification", D = `${o}-close`, V = `${o}-open`, T = `${o}-leading-action-click`, B = `${o}-supporting-action-click`, r = {
|
|
13
|
+
isOpen: !0,
|
|
14
|
+
variant: "neutral",
|
|
15
|
+
position: "inline-content",
|
|
16
|
+
isDismissible: !0,
|
|
17
|
+
isCompact: !1,
|
|
18
|
+
headingLevel: "h2",
|
|
19
|
+
hideIcon: !1,
|
|
20
|
+
hasStackedActions: !1
|
|
21
|
+
}, L = `*,*: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-icon-fill: var(--dt-color-content-default);--notification-close-icon-offset: var(--dt-spacing-b);--notification-heading-icon-offset: 2px;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)}.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-red)}.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}.c-notification-content-section .has-icon{display:block ruby;margin-inline-end:var(--dt-spacing-c)}.c-notification-content-section[isDismissible]{max-width:calc(100% - var(--notification-close-icon-offset) - 40px)}.c-notification-heading-icon{padding-block-start:var(--notification-heading-icon-offset);color:var(--notification-icon-fill)}.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}}
|
|
13
22
|
`;
|
|
14
|
-
var P = Object.defineProperty,
|
|
15
|
-
for (var
|
|
16
|
-
(
|
|
17
|
-
return a &&
|
|
23
|
+
var P = Object.defineProperty, F = Object.getOwnPropertyDescriptor, e = (u, i, t, a) => {
|
|
24
|
+
for (var s = a > 1 ? void 0 : a ? F(i, t) : i, f = u.length - 1, p; f >= 0; f--)
|
|
25
|
+
(p = u[f]) && (s = (a ? p(i, t, s) : p(s)) || s);
|
|
26
|
+
return a && s && P(i, t, s), s;
|
|
18
27
|
};
|
|
19
28
|
class n extends x {
|
|
20
29
|
constructor() {
|
|
21
|
-
super(...arguments), this.isOpen =
|
|
30
|
+
super(...arguments), this.isOpen = r.isOpen, this.variant = r.variant, this.position = r.position, this.isDismissible = r.isDismissible, this.isCompact = r.isCompact, this.headingLevel = r.headingLevel, this.hideIcon = r.hideIcon, this.hasStackedActions = r.hasStackedActions, this._hasExternalIcon = !1, this._hasIconClass = !1;
|
|
22
31
|
}
|
|
23
32
|
/**
|
|
24
33
|
* Lifecycle method executed when component is about to update.
|
|
@@ -33,7 +42,7 @@ class n extends x {
|
|
|
33
42
|
* It applies a gutter if there's no heading content in order to avoid the close button overlap the content.
|
|
34
43
|
*/
|
|
35
44
|
updated(i) {
|
|
36
|
-
i.has("isOpen") && this.isOpen &&
|
|
45
|
+
i.has("isOpen") && this.isOpen && g(this, V, { targetNotification: this });
|
|
37
46
|
}
|
|
38
47
|
/**
|
|
39
48
|
* Method responsible to check if an external icon has been provided.
|
|
@@ -51,7 +60,7 @@ class n extends x {
|
|
|
51
60
|
* @private
|
|
52
61
|
*/
|
|
53
62
|
renderFooter(i, t) {
|
|
54
|
-
return
|
|
63
|
+
return d`
|
|
55
64
|
<footer class="${h}-footer" data-test-id="${o}-footer" ?isCompact="${this.isCompact}" ?isStacked="${this.hasStackedActions && !this.isCompact}">
|
|
56
65
|
${t ? this.renderActionButton(t, "supporting") : c}
|
|
57
66
|
${i ? this.renderActionButton(i, "leading") : c}
|
|
@@ -68,7 +77,7 @@ class n extends x {
|
|
|
68
77
|
* @private
|
|
69
78
|
*/
|
|
70
79
|
renderNotificationHeading(i, t) {
|
|
71
|
-
return
|
|
80
|
+
return d`<${t} class="${h}-heading" data-test-id="${o}-heading">${i}</${t}>`;
|
|
72
81
|
}
|
|
73
82
|
/**
|
|
74
83
|
* Util method that returns a boolean if variant has a default icon.
|
|
@@ -90,13 +99,13 @@ class n extends x {
|
|
|
90
99
|
getDefaultVariantIcon(i) {
|
|
91
100
|
switch (i) {
|
|
92
101
|
case "info":
|
|
93
|
-
return
|
|
102
|
+
return d`<icon-info-circle size="m" data-test-id="${o}-heading-icon-info"></icon-info-circle>`;
|
|
94
103
|
case "success":
|
|
95
|
-
return
|
|
104
|
+
return d`<icon-check-circle size="m" data-test-id="${o}-heading-icon-success"></icon-check-circle>`;
|
|
96
105
|
case "warning":
|
|
97
|
-
return
|
|
106
|
+
return d`<icon-alert-triangle size="m" data-test-id="${o}-heading-icon-warning"></icon-alert-triangle>`;
|
|
98
107
|
case "error":
|
|
99
|
-
return
|
|
108
|
+
return d`<icon-alert-circle size="m" data-test-id="${o}-heading-icon-error"></icon-alert-circle>`;
|
|
100
109
|
default:
|
|
101
110
|
return c;
|
|
102
111
|
}
|
|
@@ -123,7 +132,7 @@ class n extends x {
|
|
|
123
132
|
* @private
|
|
124
133
|
*/
|
|
125
134
|
renderIcon(i, t, a) {
|
|
126
|
-
return
|
|
135
|
+
return d`
|
|
127
136
|
<div data-test-id="${o}-icon-area" class="${a ? "has-icon " : ""}${h}-heading-icon">
|
|
128
137
|
${t ? c : this.renderIconVariant(i)}
|
|
129
138
|
<slot name="icon"></slot>
|
|
@@ -137,7 +146,7 @@ class n extends x {
|
|
|
137
146
|
* @private
|
|
138
147
|
*/
|
|
139
148
|
renderCloseButton() {
|
|
140
|
-
return
|
|
149
|
+
return d`
|
|
141
150
|
<pie-icon-button
|
|
142
151
|
variant="ghost-secondary"
|
|
143
152
|
size="small"
|
|
@@ -155,7 +164,7 @@ class n extends x {
|
|
|
155
164
|
* @private
|
|
156
165
|
*/
|
|
157
166
|
handleCloseButton() {
|
|
158
|
-
this.closeNotificationComponent(),
|
|
167
|
+
this.closeNotificationComponent(), g(this, D, { targetNotification: this });
|
|
159
168
|
}
|
|
160
169
|
/**
|
|
161
170
|
* Util method responsible to close the component.
|
|
@@ -174,7 +183,7 @@ class n extends x {
|
|
|
174
183
|
* @private
|
|
175
184
|
*/
|
|
176
185
|
handleActionClick(i) {
|
|
177
|
-
|
|
186
|
+
g(this, i === "leading" ? T : B, { targetNotification: this });
|
|
178
187
|
}
|
|
179
188
|
/**
|
|
180
189
|
* Render the action button depending on action type and its action.
|
|
@@ -186,12 +195,12 @@ class n extends x {
|
|
|
186
195
|
* @private
|
|
187
196
|
*/
|
|
188
197
|
renderActionButton(i, t) {
|
|
189
|
-
const { text: a, ariaLabel:
|
|
190
|
-
return a ?
|
|
198
|
+
const { text: a, ariaLabel: s } = i;
|
|
199
|
+
return a ? d`
|
|
191
200
|
<pie-button
|
|
192
201
|
variant="${t === "leading" ? "primary" : "ghost"}"
|
|
193
202
|
size="small-productive"
|
|
194
|
-
aria-label="${
|
|
203
|
+
aria-label="${s || c}"
|
|
195
204
|
@click="${() => this.handleActionClick(t)}"
|
|
196
205
|
data-test-id="${o}-${t}-action"
|
|
197
206
|
?isFullWidth="${this.hasStackedActions}"
|
|
@@ -205,76 +214,76 @@ class n extends x {
|
|
|
205
214
|
variant: i,
|
|
206
215
|
position: t,
|
|
207
216
|
heading: a,
|
|
208
|
-
headingLevel:
|
|
209
|
-
isDismissible:
|
|
210
|
-
isCompact:
|
|
211
|
-
_hasExternalIcon:
|
|
212
|
-
hideIcon:
|
|
213
|
-
_hasIconClass:
|
|
214
|
-
leadingAction:
|
|
215
|
-
supportingAction:
|
|
216
|
-
isOpen:
|
|
217
|
+
headingLevel: s,
|
|
218
|
+
isDismissible: f,
|
|
219
|
+
isCompact: p,
|
|
220
|
+
_hasExternalIcon: I,
|
|
221
|
+
hideIcon: C,
|
|
222
|
+
_hasIconClass: y,
|
|
223
|
+
leadingAction: m,
|
|
224
|
+
supportingAction: _,
|
|
225
|
+
isOpen: N
|
|
217
226
|
} = this;
|
|
218
|
-
if (!
|
|
227
|
+
if (!N)
|
|
219
228
|
return c;
|
|
220
|
-
const
|
|
221
|
-
return
|
|
222
|
-
<div
|
|
223
|
-
data-test-id="${o}"
|
|
224
|
-
class="${h}"
|
|
225
|
-
variant="${i}"
|
|
229
|
+
const b = f && !p;
|
|
230
|
+
return d`
|
|
231
|
+
<div
|
|
232
|
+
data-test-id="${o}"
|
|
233
|
+
class="${h}"
|
|
234
|
+
variant="${i}"
|
|
226
235
|
position="${t}"
|
|
227
|
-
?isCompact="${
|
|
228
|
-
${
|
|
236
|
+
?isCompact="${p}">
|
|
237
|
+
${b ? this.renderCloseButton() : c}
|
|
229
238
|
|
|
230
|
-
<section class="${h}-content-section" ?isDismissible="${
|
|
231
|
-
${
|
|
239
|
+
<section class="${h}-content-section" ?isDismissible="${b}">
|
|
240
|
+
${C ? c : this.renderIcon(i, I, y)}
|
|
232
241
|
<article>
|
|
233
|
-
${a ? this.renderNotificationHeading(a,
|
|
242
|
+
${a ? this.renderNotificationHeading(a, E(s)) : c}
|
|
234
243
|
<slot></slot>
|
|
235
244
|
</article>
|
|
236
245
|
</section>
|
|
237
246
|
|
|
238
|
-
${
|
|
247
|
+
${m ? this.renderFooter(m, _) : c}
|
|
239
248
|
</div>`;
|
|
240
249
|
}
|
|
241
250
|
}
|
|
242
|
-
n.styles =
|
|
251
|
+
n.styles = O(L);
|
|
243
252
|
e([
|
|
244
|
-
|
|
253
|
+
l({ type: Boolean })
|
|
245
254
|
], n.prototype, "isOpen", 2);
|
|
246
255
|
e([
|
|
247
|
-
|
|
248
|
-
|
|
256
|
+
l(),
|
|
257
|
+
v(o, A, r.variant)
|
|
249
258
|
], n.prototype, "variant", 2);
|
|
250
259
|
e([
|
|
251
|
-
|
|
252
|
-
|
|
260
|
+
l(),
|
|
261
|
+
v(o, S, r.position)
|
|
253
262
|
], n.prototype, "position", 2);
|
|
254
263
|
e([
|
|
255
|
-
|
|
264
|
+
l({ type: Boolean })
|
|
256
265
|
], n.prototype, "isDismissible", 2);
|
|
257
266
|
e([
|
|
258
|
-
|
|
267
|
+
l({ type: Boolean })
|
|
259
268
|
], n.prototype, "isCompact", 2);
|
|
260
269
|
e([
|
|
261
|
-
|
|
270
|
+
l({ type: String })
|
|
262
271
|
], n.prototype, "heading", 2);
|
|
263
272
|
e([
|
|
264
|
-
|
|
265
|
-
|
|
273
|
+
l(),
|
|
274
|
+
v(o, z, r.headingLevel)
|
|
266
275
|
], n.prototype, "headingLevel", 2);
|
|
267
276
|
e([
|
|
268
|
-
|
|
277
|
+
l({ type: Boolean })
|
|
269
278
|
], n.prototype, "hideIcon", 2);
|
|
270
279
|
e([
|
|
271
|
-
|
|
280
|
+
l({ type: Object })
|
|
272
281
|
], n.prototype, "leadingAction", 2);
|
|
273
282
|
e([
|
|
274
|
-
|
|
283
|
+
l({ type: Object })
|
|
275
284
|
], n.prototype, "supportingAction", 2);
|
|
276
285
|
e([
|
|
277
|
-
|
|
286
|
+
l({ type: Boolean })
|
|
278
287
|
], n.prototype, "hasStackedActions", 2);
|
|
279
288
|
e([
|
|
280
289
|
w({ slot: "icon" })
|
|
@@ -285,16 +294,17 @@ e([
|
|
|
285
294
|
e([
|
|
286
295
|
$()
|
|
287
296
|
], n.prototype, "_hasIconClass", 2);
|
|
288
|
-
|
|
297
|
+
k(o, n);
|
|
289
298
|
export {
|
|
290
|
-
|
|
299
|
+
D as ON_NOTIFICATION_CLOSE_EVENT,
|
|
291
300
|
T as ON_NOTIFICATION_LEADING_ACTION_CLICK_EVENT,
|
|
292
301
|
V as ON_NOTIFICATION_OPEN_EVENT,
|
|
293
302
|
B as ON_NOTIFICATION_SUPPORTING_ACTION_CLICK_EVENT,
|
|
294
303
|
n as PieNotification,
|
|
295
304
|
h as componentClass,
|
|
296
305
|
o as componentSelector,
|
|
297
|
-
|
|
298
|
-
z as
|
|
299
|
-
|
|
306
|
+
r as defaultProps,
|
|
307
|
+
z as headingLevels,
|
|
308
|
+
S as positions,
|
|
309
|
+
A as variants
|
|
300
310
|
};
|
package/dist/react.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ComponentDefaultPropsGeneric } from '@justeattakeaway/pie-webc-core';
|
|
1
2
|
import type { CSSResult } from 'lit';
|
|
2
3
|
import type { LitElement } from 'lit';
|
|
3
4
|
import type { nothing } from 'lit';
|
|
@@ -20,6 +21,10 @@ export declare const componentClass = "c-notification";
|
|
|
20
21
|
|
|
21
22
|
export declare const componentSelector = "pie-notification";
|
|
22
23
|
|
|
24
|
+
export declare type DefaultProps = ComponentDefaultPropsGeneric<NotificationProps, 'isOpen' | 'variant' | 'position' | 'isDismissible' | 'isCompact' | 'headingLevel' | 'hideIcon' | 'hasStackedActions'>;
|
|
25
|
+
|
|
26
|
+
export declare const defaultProps: DefaultProps;
|
|
27
|
+
|
|
23
28
|
export declare const headingLevels: readonly ["h2", "h3", "h4", "h5", "h6"];
|
|
24
29
|
|
|
25
30
|
export declare interface NotificationProps {
|
package/dist/react.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as i from "react";
|
|
2
2
|
import { createComponent as o } from "@lit/react";
|
|
3
3
|
import { PieNotification as t } from "./index.js";
|
|
4
|
-
import { ON_NOTIFICATION_CLOSE_EVENT as E, ON_NOTIFICATION_LEADING_ACTION_CLICK_EVENT as A, ON_NOTIFICATION_OPEN_EVENT as g, ON_NOTIFICATION_SUPPORTING_ACTION_CLICK_EVENT as L, componentClass as d, componentSelector as k,
|
|
4
|
+
import { ON_NOTIFICATION_CLOSE_EVENT as E, ON_NOTIFICATION_LEADING_ACTION_CLICK_EVENT as A, ON_NOTIFICATION_OPEN_EVENT as g, ON_NOTIFICATION_SUPPORTING_ACTION_CLICK_EVENT as L, componentClass as d, componentSelector as k, defaultProps as F, headingLevels as S, positions as V, variants as u } from "./index.js";
|
|
5
5
|
import "lit";
|
|
6
6
|
import "lit/static-html.js";
|
|
7
7
|
import "@justeattakeaway/pie-webc-core";
|
|
@@ -37,7 +37,8 @@ export {
|
|
|
37
37
|
T as PieNotification,
|
|
38
38
|
d as componentClass,
|
|
39
39
|
k as componentSelector,
|
|
40
|
-
F as
|
|
41
|
-
S as
|
|
42
|
-
V as
|
|
40
|
+
F as defaultProps,
|
|
41
|
+
S as headingLevels,
|
|
42
|
+
V as positions,
|
|
43
|
+
u as variants
|
|
43
44
|
};
|
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.6.
|
|
4
|
+
"version": "0.6.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
"cem-plugin-module-file-extensions": "0.0.5"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@justeattakeaway/pie-icon-button": "0.28.
|
|
45
|
-
"@justeattakeaway/pie-icons-webc": "0.
|
|
46
|
-
"@justeattakeaway/pie-webc-core": "0.
|
|
44
|
+
"@justeattakeaway/pie-icon-button": "0.28.6",
|
|
45
|
+
"@justeattakeaway/pie-icons-webc": "0.24.0",
|
|
46
|
+
"@justeattakeaway/pie-webc-core": "0.23.0"
|
|
47
47
|
},
|
|
48
48
|
"volta": {
|
|
49
49
|
"extends": "../../../package.json"
|
package/src/defs.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { type ComponentDefaultPropsGeneric } from '@justeattakeaway/pie-webc-core';
|
|
2
|
+
|
|
1
3
|
export const variants = ['neutral', 'neutral-alternative', 'info', 'success', 'warning', 'error'] as const;
|
|
2
4
|
export const headingLevels = ['h2', 'h3', 'h4', 'h5', 'h6'] as const;
|
|
3
5
|
export const positions = ['inline-content', 'full-width'] as const;
|
|
@@ -101,3 +103,16 @@ export const ON_NOTIFICATION_LEADING_ACTION_CLICK_EVENT = `${componentSelector}-
|
|
|
101
103
|
* @constant
|
|
102
104
|
*/
|
|
103
105
|
export const ON_NOTIFICATION_SUPPORTING_ACTION_CLICK_EVENT = `${componentSelector}-supporting-action-click`;
|
|
106
|
+
|
|
107
|
+
export type DefaultProps = ComponentDefaultPropsGeneric<NotificationProps, 'isOpen' | 'variant' | 'position' | 'isDismissible' | 'isCompact' | 'headingLevel' | 'hideIcon' | 'hasStackedActions'>;
|
|
108
|
+
|
|
109
|
+
export const defaultProps: DefaultProps = {
|
|
110
|
+
isOpen: true,
|
|
111
|
+
variant: 'neutral',
|
|
112
|
+
position: 'inline-content',
|
|
113
|
+
isDismissible: true,
|
|
114
|
+
isCompact: false,
|
|
115
|
+
headingLevel: 'h2',
|
|
116
|
+
hideIcon: false,
|
|
117
|
+
hasStackedActions: false,
|
|
118
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
ON_NOTIFICATION_OPEN_EVENT,
|
|
21
21
|
ON_NOTIFICATION_LEADING_ACTION_CLICK_EVENT,
|
|
22
22
|
ON_NOTIFICATION_SUPPORTING_ACTION_CLICK_EVENT,
|
|
23
|
+
defaultProps,
|
|
23
24
|
} from './defs';
|
|
24
25
|
import styles from './notification.scss?inline';
|
|
25
26
|
|
|
@@ -43,31 +44,31 @@ export * from './defs';
|
|
|
43
44
|
*/
|
|
44
45
|
export class PieNotification extends LitElement implements NotificationProps {
|
|
45
46
|
@property({ type: Boolean })
|
|
46
|
-
public isOpen =
|
|
47
|
+
public isOpen = defaultProps.isOpen;
|
|
47
48
|
|
|
48
49
|
@property()
|
|
49
|
-
@validPropertyValues(componentSelector, variants,
|
|
50
|
-
public variant: NonNullable<NotificationProps['variant']> =
|
|
50
|
+
@validPropertyValues(componentSelector, variants, defaultProps.variant)
|
|
51
|
+
public variant: NonNullable<NotificationProps['variant']> = defaultProps.variant;
|
|
51
52
|
|
|
52
53
|
@property()
|
|
53
|
-
@validPropertyValues(componentSelector, positions,
|
|
54
|
-
public position: NonNullable<NotificationProps['position']> =
|
|
54
|
+
@validPropertyValues(componentSelector, positions, defaultProps.position)
|
|
55
|
+
public position: NonNullable<NotificationProps['position']> = defaultProps.position;
|
|
55
56
|
|
|
56
57
|
@property({ type: Boolean })
|
|
57
|
-
public isDismissible =
|
|
58
|
+
public isDismissible = defaultProps.isDismissible;
|
|
58
59
|
|
|
59
60
|
@property({ type: Boolean })
|
|
60
|
-
public isCompact =
|
|
61
|
+
public isCompact = defaultProps.isCompact;
|
|
61
62
|
|
|
62
63
|
@property({ type: String })
|
|
63
64
|
public heading!: string;
|
|
64
65
|
|
|
65
66
|
@property()
|
|
66
|
-
@validPropertyValues(componentSelector, headingLevels,
|
|
67
|
-
public headingLevel: NonNullable<NotificationProps['headingLevel']> =
|
|
67
|
+
@validPropertyValues(componentSelector, headingLevels, defaultProps.headingLevel)
|
|
68
|
+
public headingLevel: NonNullable<NotificationProps['headingLevel']> = defaultProps.headingLevel;
|
|
68
69
|
|
|
69
70
|
@property({ type: Boolean })
|
|
70
|
-
public hideIcon =
|
|
71
|
+
public hideIcon = defaultProps.hideIcon;
|
|
71
72
|
|
|
72
73
|
@property({ type: Object })
|
|
73
74
|
public leadingAction!: NotificationProps['leadingAction'];
|
|
@@ -76,7 +77,7 @@ export class PieNotification extends LitElement implements NotificationProps {
|
|
|
76
77
|
public supportingAction!: NotificationProps['supportingAction'];
|
|
77
78
|
|
|
78
79
|
@property({ type: Boolean })
|
|
79
|
-
public hasStackedActions =
|
|
80
|
+
public hasStackedActions = defaultProps.hasStackedActions;
|
|
80
81
|
|
|
81
82
|
@queryAssignedElements({ slot: 'icon' }) _iconSlot!: Array<HTMLElement>;
|
|
82
83
|
|
|
@@ -327,10 +328,10 @@ export class PieNotification extends LitElement implements NotificationProps {
|
|
|
327
328
|
const showCloseButton = isDismissible && !isCompact;
|
|
328
329
|
|
|
329
330
|
return html`
|
|
330
|
-
<div
|
|
331
|
-
data-test-id="${componentSelector}"
|
|
332
|
-
class="${componentClass}"
|
|
333
|
-
variant="${variant}"
|
|
331
|
+
<div
|
|
332
|
+
data-test-id="${componentSelector}"
|
|
333
|
+
class="${componentClass}"
|
|
334
|
+
variant="${variant}"
|
|
334
335
|
position="${position}"
|
|
335
336
|
?isCompact="${isCompact}">
|
|
336
337
|
${showCloseButton ? this.renderCloseButton() : nothing}
|