@sula-tech/webcomponents 0.19.2 → 0.20.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/cjs/{index-i5WGQEGK.js → index-BjAGuSPl.js} +30 -5
- package/dist/cjs/index-BjAGuSPl.js.map +1 -0
- package/dist/cjs/index.cjs.js +17 -11
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/sula-avatar_31.cjs.entry.js +121 -66
- package/dist/cjs/sula-avatar_31.cjs.entry.js.map +1 -1
- package/dist/cjs/sula-menu.model-BDxbWyPG.js +16 -0
- package/dist/cjs/sula-menu.model-BDxbWyPG.js.map +1 -0
- package/dist/cjs/sula-toast-stack.cjs.entry.js +314 -0
- package/dist/cjs/sula-toast-stack.cjs.entry.js.map +1 -0
- package/dist/cjs/sula-toast-stack.entry.cjs.js.map +1 -0
- package/dist/cjs/sula-toast.cjs.entry.js +195 -0
- package/dist/cjs/sula-toast.cjs.entry.js.map +1 -0
- package/dist/cjs/sula-toast.entry.cjs.js.map +1 -0
- package/dist/cjs/sula-toast.model-frnF9yhp.js +14 -0
- package/dist/cjs/sula-toast.model-frnF9yhp.js.map +1 -0
- package/dist/cjs/webcomponents.cjs.js +2 -2
- package/dist/collection/collection-manifest.json +2 -0
- package/dist/collection/components/sula-avatar/sula-avatar.css +1 -1
- package/dist/collection/components/sula-badge/sula-badge.css +1 -1
- package/dist/collection/components/sula-breadcrumb/sula-breadcrumb.css +1 -1
- package/dist/collection/components/sula-button/sula-button.css +1 -1
- package/dist/collection/components/sula-checkbox/sula-checkbox.css +1 -1
- package/dist/collection/components/sula-chip/sula-chip.css +1 -1
- package/dist/collection/components/sula-dropdown/sula-dropdown.css +1 -1
- package/dist/collection/components/sula-icon/sula-icon.css +1 -1
- package/dist/collection/components/sula-icon-picker/sula-icon-picker.css +1 -1
- package/dist/collection/components/sula-loader/sula-loader.css +1 -1
- package/dist/collection/components/sula-menu/model/sula-menu.model.js.map +1 -1
- package/dist/collection/components/sula-menu/sula-menu.css +1 -1
- package/dist/collection/components/sula-menu/sula-menu.js +80 -25
- package/dist/collection/components/sula-menu/sula-menu.js.map +1 -1
- package/dist/collection/components/sula-menu/sula-menu.stories.js +79 -2
- package/dist/collection/components/sula-menu/sula-menu.stories.js.map +1 -1
- package/dist/collection/components/sula-menu-select-list/sula-menu-select-list.css +1 -1
- package/dist/collection/components/sula-modal/sula-modal.css +1 -1
- package/dist/collection/components/sula-progress-bar/sula-progress-bar.css +1 -1
- package/dist/collection/components/sula-radio-button/sula-radio-button.css +1 -1
- package/dist/collection/components/sula-search-bar/sula-search-bar.css +1 -1
- package/dist/collection/components/sula-segmented-control/sula-segmented-control.css +1 -1
- package/dist/collection/components/sula-switch/sula-switch.css +1 -1
- package/dist/collection/components/sula-table/sula-table.css +1 -1
- package/dist/collection/components/sula-table-body/sula-table-body.css +1 -1
- package/dist/collection/components/sula-table-cell/sula-table-cell.css +1 -1
- package/dist/collection/components/sula-table-head-cell/sula-table-head-cell.css +1 -1
- package/dist/collection/components/sula-table-header/sula-table-header.css +1 -1
- package/dist/collection/components/sula-table-row/sula-table-row.css +1 -1
- package/dist/collection/components/sula-tag/sula-tag.css +1 -1
- package/dist/collection/components/sula-textarea/sula-textarea.css +1 -1
- package/dist/collection/components/sula-textfield/sula-textfield.css +1 -1
- package/dist/collection/components/sula-tiles/sula-tiles.css +1 -1
- package/dist/collection/components/sula-timeline-list/sula-timeline-list.css +1 -1
- package/dist/collection/components/sula-toast/model/sula-toast.model.js +10 -0
- package/dist/collection/components/sula-toast/model/sula-toast.model.js.map +1 -0
- package/dist/collection/components/sula-toast/sula-toast.css +1 -0
- package/dist/collection/components/sula-toast/sula-toast.js +501 -0
- package/dist/collection/components/sula-toast/sula-toast.js.map +1 -0
- package/dist/collection/components/sula-toast/sula-toast.stories.js +101 -0
- package/dist/collection/components/sula-toast/sula-toast.stories.js.map +1 -0
- package/dist/collection/components/sula-toast-stack/model/sula-toast-stack.model.js +2 -0
- package/dist/collection/components/sula-toast-stack/model/sula-toast-stack.model.js.map +1 -0
- package/dist/collection/components/sula-toast-stack/sula-toast-stack.css +1 -0
- package/dist/collection/components/sula-toast-stack/sula-toast-stack.js +333 -0
- package/dist/collection/components/sula-toast-stack/sula-toast-stack.js.map +1 -0
- package/dist/collection/components/sula-toast-stack/sula-toast-stack.motion.js +67 -0
- package/dist/collection/components/sula-toast-stack/sula-toast-stack.motion.js.map +1 -0
- package/dist/collection/components/sula-toast-stack/sula-toast-stack.stories.js +87 -0
- package/dist/collection/components/sula-toast-stack/sula-toast-stack.stories.js.map +1 -0
- package/dist/collection/components/sula-toggle/sula-toggle.css +1 -1
- package/dist/collection/components/sula-toggle/sula-toggle.js +1 -1
- package/dist/collection/components/sula-tooltip/sula-tooltip.css +1 -1
- package/dist/collection/components/sula-tooltip/sula-tooltip.js +1 -1
- package/dist/collection/index.js +1 -0
- package/dist/collection/index.js.map +1 -1
- package/dist/components/index.js +3 -15
- package/dist/components/index.js.map +1 -1
- package/dist/components/{p-CelSwSJG.js → p-CJ2i2jVV.js} +5 -5
- package/dist/components/{p-CelSwSJG.js.map → p-CJ2i2jVV.js.map} +1 -1
- package/dist/components/p-Cs9RR1ZV.js +16 -0
- package/dist/components/p-Cs9RR1ZV.js.map +1 -0
- package/dist/components/{p-Bqd5Y-Ir.js → p-D0ZAC0yK.js} +6 -6
- package/dist/components/p-D0ZAC0yK.js.map +1 -0
- package/dist/components/{p-BJQZqrGi.js → p-DGfvh6dZ.js} +5 -5
- package/dist/components/{p-BJQZqrGi.js.map → p-DGfvh6dZ.js.map} +1 -1
- package/dist/components/{p-Cy4ZswbA.js → p-DYfmicjp.js} +31 -6
- package/dist/components/p-DYfmicjp.js.map +1 -0
- package/dist/components/{p-f7rEWsEo.js → p-DmCNhtp_.js} +4 -4
- package/dist/components/{p-f7rEWsEo.js.map → p-DmCNhtp_.js.map} +1 -1
- package/dist/components/p-DmQoJS86.js +235 -0
- package/dist/components/p-DmQoJS86.js.map +1 -0
- package/dist/components/{p-bHiC51v2.js → p-DqRqPukj.js} +4 -4
- package/dist/components/{p-bHiC51v2.js.map → p-DqRqPukj.js.map} +1 -1
- package/dist/components/{p-D1tWu3qb.js → p-b7t6bSNa.js} +6 -6
- package/dist/components/{p-D1tWu3qb.js.map → p-b7t6bSNa.js.map} +1 -1
- package/dist/components/p-t0X4JATS.js +14 -0
- package/dist/components/p-t0X4JATS.js.map +1 -0
- package/dist/components/sula-avatar.js +3 -3
- package/dist/components/sula-avatar.js.map +1 -1
- package/dist/components/sula-badge.js +3 -3
- package/dist/components/sula-badge.js.map +1 -1
- package/dist/components/sula-breadcrumb.js +3 -3
- package/dist/components/sula-breadcrumb.js.map +1 -1
- package/dist/components/sula-button.js +1 -1
- package/dist/components/sula-checkbox.js +3 -3
- package/dist/components/sula-checkbox.js.map +1 -1
- package/dist/components/sula-chip.js +4 -4
- package/dist/components/sula-chip.js.map +1 -1
- package/dist/components/sula-dropdown.js +1 -1
- package/dist/components/sula-icon-picker.js +6 -6
- package/dist/components/sula-icon-picker.js.map +1 -1
- package/dist/components/sula-icon.js +1 -1
- package/dist/components/sula-loader.js +1 -1
- package/dist/components/sula-menu-select-list.js +1 -1
- package/dist/components/sula-menu.js +84 -29
- package/dist/components/sula-menu.js.map +1 -1
- package/dist/components/sula-modal.js +5 -5
- package/dist/components/sula-modal.js.map +1 -1
- package/dist/components/sula-progress-bar.js +3 -3
- package/dist/components/sula-progress-bar.js.map +1 -1
- package/dist/components/sula-radio-button.js +2 -2
- package/dist/components/sula-radio-button.js.map +1 -1
- package/dist/components/sula-search-bar.js +1 -1
- package/dist/components/sula-segmented-control.js +3 -3
- package/dist/components/sula-segmented-control.js.map +1 -1
- package/dist/components/sula-switch.js +2 -2
- package/dist/components/sula-switch.js.map +1 -1
- package/dist/components/sula-table-body.js +2 -2
- package/dist/components/sula-table-body.js.map +1 -1
- package/dist/components/sula-table-cell.js +2 -2
- package/dist/components/sula-table-cell.js.map +1 -1
- package/dist/components/sula-table-head-cell.js +2 -2
- package/dist/components/sula-table-head-cell.js.map +1 -1
- package/dist/components/sula-table-header.js +2 -2
- package/dist/components/sula-table-header.js.map +1 -1
- package/dist/components/sula-table-row.js +2 -2
- package/dist/components/sula-table-row.js.map +1 -1
- package/dist/components/sula-table.js +2 -2
- package/dist/components/sula-table.js.map +1 -1
- package/dist/components/sula-tag.js +3 -3
- package/dist/components/sula-tag.js.map +1 -1
- package/dist/components/sula-textarea.js +2 -2
- package/dist/components/sula-textarea.js.map +1 -1
- package/dist/components/sula-textfield.js +3 -3
- package/dist/components/sula-textfield.js.map +1 -1
- package/dist/components/sula-tiles.js +3 -3
- package/dist/components/sula-tiles.js.map +1 -1
- package/dist/components/sula-timeline-list.js +3 -3
- package/dist/components/sula-timeline-list.js.map +1 -1
- package/dist/components/sula-toast-stack.d.ts +11 -0
- package/dist/components/sula-toast-stack.js +352 -0
- package/dist/components/sula-toast-stack.js.map +1 -0
- package/dist/components/sula-toast.d.ts +11 -0
- package/dist/components/sula-toast.js +9 -0
- package/dist/components/sula-toast.js.map +1 -0
- package/dist/components/sula-toggle.js +4 -4
- package/dist/components/sula-toggle.js.map +1 -1
- package/dist/components/sula-tooltip.js +4 -4
- package/dist/components/sula-tooltip.js.map +1 -1
- package/dist/esm/{index-lrQT_q8m.js → index-BL15Tt3m.js} +30 -5
- package/dist/esm/index-BL15Tt3m.js.map +1 -0
- package/dist/esm/index.js +2 -13
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/loader.js +3 -3
- package/dist/esm/sula-avatar_31.entry.js +115 -60
- package/dist/esm/sula-avatar_31.entry.js.map +1 -1
- package/dist/esm/sula-menu.model-Cs9RR1ZV.js +16 -0
- package/dist/esm/sula-menu.model-Cs9RR1ZV.js.map +1 -0
- package/dist/esm/sula-toast-stack.entry.js +312 -0
- package/dist/esm/sula-toast-stack.entry.js.map +1 -0
- package/dist/esm/sula-toast.entry.js +193 -0
- package/dist/esm/sula-toast.entry.js.map +1 -0
- package/dist/esm/sula-toast.model-t0X4JATS.js +14 -0
- package/dist/esm/sula-toast.model-t0X4JATS.js.map +1 -0
- package/dist/esm/webcomponents.js +3 -3
- package/dist/types/components/sula-menu/model/sula-menu.model.d.ts +1 -0
- package/dist/types/components/sula-menu/sula-menu.d.ts +5 -4
- package/dist/types/components/sula-menu/sula-menu.stories.d.ts +1 -0
- package/dist/types/components/sula-toast/model/sula-toast.model.d.ts +31 -0
- package/dist/types/components/sula-toast/sula-toast.d.ts +64 -0
- package/dist/types/components/sula-toast/sula-toast.stories.d.ts +188 -0
- package/dist/types/components/sula-toast-stack/model/sula-toast-stack.model.d.ts +8 -0
- package/dist/types/components/sula-toast-stack/sula-toast-stack.d.ts +51 -0
- package/dist/types/components/sula-toast-stack/sula-toast-stack.motion.d.ts +9 -0
- package/dist/types/components/sula-toast-stack/sula-toast-stack.stories.d.ts +64 -0
- package/dist/types/components.d.ts +204 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/webcomponents/index.esm.js +2 -15
- package/dist/webcomponents/index.esm.js.map +1 -1
- package/dist/webcomponents/p-170854a5.entry.js +270 -0
- package/dist/webcomponents/p-170854a5.entry.js.map +1 -0
- package/dist/webcomponents/{p-lrQT_q8m.js → p-BL15Tt3m.js} +240 -215
- package/dist/webcomponents/p-BL15Tt3m.js.map +1 -0
- package/dist/webcomponents/p-Cs9RR1ZV.js +18 -0
- package/dist/webcomponents/p-Cs9RR1ZV.js.map +1 -0
- package/dist/webcomponents/p-c58125e1.entry.js +376 -0
- package/dist/webcomponents/p-c58125e1.entry.js.map +1 -0
- package/dist/webcomponents/{p-c2f9f164.entry.js → p-fcc1a28c.entry.js} +139 -83
- package/dist/webcomponents/p-fcc1a28c.entry.js.map +1 -0
- package/dist/webcomponents/p-t0X4JATS.js +14 -0
- package/dist/webcomponents/p-t0X4JATS.js.map +1 -0
- package/dist/webcomponents/sula-toast-stack.entry.esm.js.map +1 -0
- package/dist/webcomponents/sula-toast.entry.esm.js.map +1 -0
- package/dist/webcomponents/webcomponents.esm.js +35 -6
- package/package.json +2 -2
- package/dist/cjs/index-i5WGQEGK.js.map +0 -1
- package/dist/components/p-Bqd5Y-Ir.js.map +0 -1
- package/dist/components/p-Cy4ZswbA.js.map +0 -1
- package/dist/esm/index-lrQT_q8m.js.map +0 -1
- package/dist/webcomponents/p-c2f9f164.entry.js.map +0 -1
- package/dist/webcomponents/p-lrQT_q8m.js.map +0 -1
|
@@ -0,0 +1,501 @@
|
|
|
1
|
+
import { Host, h } from "@stencil/core";
|
|
2
|
+
import { SulaToastType } from "./model/sula-toast.model";
|
|
3
|
+
const DEFAULT_DURATION = 5000;
|
|
4
|
+
const FOCUS_RING_CLASSES = 'focus-visible:outline focus-visible:outline-2 focus-visible:outline-feedback-informational focus-visible:outline-offset-2';
|
|
5
|
+
const TOAST_INTENTS = {
|
|
6
|
+
[SulaToastType.Neutral]: {
|
|
7
|
+
border: 'border-line-general',
|
|
8
|
+
borderColor: 'var(--color-line-general)',
|
|
9
|
+
color: 'text-icon-primary',
|
|
10
|
+
background: 'bg-surface-on-body',
|
|
11
|
+
},
|
|
12
|
+
[SulaToastType.Brand]: {
|
|
13
|
+
border: 'border-brand-primary',
|
|
14
|
+
borderColor: 'var(--color-brand-primary)',
|
|
15
|
+
color: 'text-brand-primary',
|
|
16
|
+
background: 'bg-surface-on-body-brand',
|
|
17
|
+
},
|
|
18
|
+
[SulaToastType.Info]: {
|
|
19
|
+
border: 'border-feedback-informational',
|
|
20
|
+
borderColor: 'var(--color-feedback-informational)',
|
|
21
|
+
color: 'text-feedback-informational',
|
|
22
|
+
background: 'bg-surface-on-body-feedback-info',
|
|
23
|
+
},
|
|
24
|
+
[SulaToastType.Success]: {
|
|
25
|
+
border: 'border-feedback-success',
|
|
26
|
+
borderColor: 'var(--color-feedback-success)',
|
|
27
|
+
color: 'text-feedback-success',
|
|
28
|
+
background: 'bg-surface-on-body-feedback-success',
|
|
29
|
+
},
|
|
30
|
+
[SulaToastType.Warning]: {
|
|
31
|
+
border: 'border-feedback-alert',
|
|
32
|
+
borderColor: 'var(--color-feedback-alert)',
|
|
33
|
+
color: 'text-feedback-alert',
|
|
34
|
+
background: 'bg-surface-on-body-feedback-alert',
|
|
35
|
+
},
|
|
36
|
+
[SulaToastType.Danger]: {
|
|
37
|
+
border: 'border-feedback-error',
|
|
38
|
+
borderColor: 'var(--color-feedback-error)',
|
|
39
|
+
color: 'text-feedback-error',
|
|
40
|
+
background: 'bg-surface-on-body-feedback-error',
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* A controlled notification. The consumer removes it after toastDismissRequested.
|
|
45
|
+
* @part container - Notification surface.
|
|
46
|
+
* @part icon - Decorative intent icon.
|
|
47
|
+
* @part content - Title, description and action.
|
|
48
|
+
* @part close-button - Dismiss button.
|
|
49
|
+
*/
|
|
50
|
+
export class SulaToast {
|
|
51
|
+
constructor() {
|
|
52
|
+
/** Notification title. */
|
|
53
|
+
this.toastTitle = '';
|
|
54
|
+
/** Optional notification description, displayed on up to four lines. */
|
|
55
|
+
this.message = '';
|
|
56
|
+
/** Visual intent, independent of announcement urgency. */
|
|
57
|
+
this.type = SulaToastType.Neutral;
|
|
58
|
+
/** Optional single-line action label. The consumer implements the action. */
|
|
59
|
+
this.actionText = '';
|
|
60
|
+
/** Whether to display the dismiss button. */
|
|
61
|
+
this.closable = true;
|
|
62
|
+
/** Externally pause the remaining timeout, for example while covered by a stack. */
|
|
63
|
+
this.paused = false;
|
|
64
|
+
/** Whether to play the entrance animations (fade-in and border trace). Disable when a parent already controls the animation, for example toasts covered in a stack. */
|
|
65
|
+
this.animated = true;
|
|
66
|
+
/** Screen reader announcement priority. Use off when a parent owns announcements. */
|
|
67
|
+
this.announcement = 'polite';
|
|
68
|
+
/** Accessible dismiss button label. */
|
|
69
|
+
this.closeLabel = 'Fechar notificação';
|
|
70
|
+
this.announcedText = '';
|
|
71
|
+
this.remaining = 0;
|
|
72
|
+
this.startedAt = 0;
|
|
73
|
+
this.timedOut = false;
|
|
74
|
+
this.timeoutEnabled = false;
|
|
75
|
+
this.hovering = false;
|
|
76
|
+
this.focused = false;
|
|
77
|
+
this.visible = false;
|
|
78
|
+
this.ready = false;
|
|
79
|
+
this.connected = false;
|
|
80
|
+
this.handleFocusOut = (event) => {
|
|
81
|
+
const target = event.relatedTarget;
|
|
82
|
+
this.focused = !!target && (this.hostElement.contains(target) || this.hostElement.shadowRoot.contains(target));
|
|
83
|
+
this.updateTimeout();
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
connectedCallback() {
|
|
87
|
+
this.connected = true;
|
|
88
|
+
if (this.ready)
|
|
89
|
+
this.observeVisibility();
|
|
90
|
+
}
|
|
91
|
+
componentDidLoad() {
|
|
92
|
+
this.ready = true;
|
|
93
|
+
this.resetTimeout();
|
|
94
|
+
Promise.resolve().then(() => {
|
|
95
|
+
if (this.connected)
|
|
96
|
+
this.updateAnnouncement();
|
|
97
|
+
});
|
|
98
|
+
this.observeVisibility();
|
|
99
|
+
}
|
|
100
|
+
disconnectedCallback() {
|
|
101
|
+
var _a;
|
|
102
|
+
this.connected = false;
|
|
103
|
+
this.stopTimeout();
|
|
104
|
+
(_a = this.observer) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
105
|
+
this.hovering = false;
|
|
106
|
+
this.focused = false;
|
|
107
|
+
}
|
|
108
|
+
handleContentChange() {
|
|
109
|
+
this.resetTimeout();
|
|
110
|
+
this.updateAnnouncement();
|
|
111
|
+
}
|
|
112
|
+
updateAnnouncement() {
|
|
113
|
+
this.announcedText = this.announcement === 'off' ? '' : [this.toastTitle, this.message].filter(Boolean).join('. ');
|
|
114
|
+
}
|
|
115
|
+
updateTimeout() {
|
|
116
|
+
const blocked = !this.connected || !this.ready || !this.visible || this.paused || this.hovering || this.focused || document.visibilityState === 'hidden';
|
|
117
|
+
if (blocked) {
|
|
118
|
+
this.stopTimeout();
|
|
119
|
+
}
|
|
120
|
+
else if (this.timer === undefined && this.timeoutEnabled && !this.timedOut) {
|
|
121
|
+
this.startedAt = Date.now();
|
|
122
|
+
this.timer = setTimeout(() => {
|
|
123
|
+
this.timer = undefined;
|
|
124
|
+
this.remaining = 0;
|
|
125
|
+
this.timedOut = true;
|
|
126
|
+
this.toastDismissRequested.emit({ reason: 'timeout' });
|
|
127
|
+
}, this.remaining);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
resetTimeout() {
|
|
131
|
+
this.stopTimeout();
|
|
132
|
+
this.remaining = this.resolveDuration();
|
|
133
|
+
this.timeoutEnabled = this.remaining > 0;
|
|
134
|
+
this.timedOut = false;
|
|
135
|
+
this.updateTimeout();
|
|
136
|
+
}
|
|
137
|
+
resolveDuration() {
|
|
138
|
+
if (typeof this.duration === 'number' && Number.isFinite(this.duration) && this.duration >= 0)
|
|
139
|
+
return this.duration;
|
|
140
|
+
return this.actionText ? 0 : DEFAULT_DURATION;
|
|
141
|
+
}
|
|
142
|
+
stopTimeout() {
|
|
143
|
+
if (this.timer !== undefined) {
|
|
144
|
+
clearTimeout(this.timer);
|
|
145
|
+
this.timer = undefined;
|
|
146
|
+
this.remaining = Math.max(0, this.remaining - (Date.now() - this.startedAt));
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
observeVisibility() {
|
|
150
|
+
var _a;
|
|
151
|
+
(_a = this.observer) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
152
|
+
if (typeof IntersectionObserver === 'undefined') {
|
|
153
|
+
this.visible = true;
|
|
154
|
+
this.updateTimeout();
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
this.visible = false;
|
|
158
|
+
this.observer = new IntersectionObserver(entries => {
|
|
159
|
+
this.visible = entries.some(entry => entry.isIntersecting && entry.intersectionRatio > 0);
|
|
160
|
+
this.updateTimeout();
|
|
161
|
+
});
|
|
162
|
+
this.observer.observe(this.hostElement);
|
|
163
|
+
}
|
|
164
|
+
setHover(value) {
|
|
165
|
+
var _a, _b;
|
|
166
|
+
this.hovering = value && !((_b = (_a = window.matchMedia) === null || _a === void 0 ? void 0 : _a.call(window, '(hover: none)').matches) !== null && _b !== void 0 ? _b : false);
|
|
167
|
+
this.updateTimeout();
|
|
168
|
+
}
|
|
169
|
+
get intent() {
|
|
170
|
+
return TOAST_INTENTS[this.type] || TOAST_INTENTS[SulaToastType.Neutral];
|
|
171
|
+
}
|
|
172
|
+
render() {
|
|
173
|
+
const intent = this.intent;
|
|
174
|
+
return (h(Host, { key: 'af689f4f1497431d4a9664ddb5452079f09ef03f', onMouseEnter: () => this.setHover(true), onMouseLeave: () => this.setHover(false), onFocusin: () => {
|
|
175
|
+
this.focused = true;
|
|
176
|
+
this.updateTimeout();
|
|
177
|
+
}, onFocusout: this.handleFocusOut }, h("div", { key: '51d418a2bcd9610ec55551828cff4aab8c085a62', part: "container", class: `toast-surface relative isolate box-border flex items-center w-full p-16 gap-12 rounded-sm border bg-opacity-toast ${intent.border} ${this.animated ? 'toast-surface--animated' : ''}`, style: { '--toast-border-color': intent.borderColor } }, this.icon && (h("div", { key: '383e8204c8f6cbfd13270a1543baea5273149bca', part: "icon", "aria-hidden": "true", class: `flex shrink-0 items-center justify-center w-44 h-44 rounded-xxl ${intent.background}` }, h("sula-icon", { key: 'b2a17f14dbfbd6975b29ccb63ee7a76705e20e12', icon: this.icon, customClass: `text-2xl ${intent.color}`, class: "flex leading-none" }))), h("div", { key: '8bd8d7c43b25d9c408b5e0e107fc3d5f78d92c4a', part: "content", class: `flex min-w-0 flex-1 flex-col gap-8 ${this.closable ? 'pr-48' : ''}` }, h("div", { key: 'fe41d0b855c17fb145c760815abc5fdd64e1dbc4', class: "flex flex-col gap-4" }, this.toastTitle && (h("p", { key: '0403d060fe5d28161bbf29cb937b8a0d90daf17d', class: "toast-copy toast-title text-label-medium-bold text-text-primary", title: this.toastTitle }, this.toastTitle)), this.message && (h("p", { key: 'b163c773c6a82f5dbb455770708ac9690efbffbe', class: "toast-copy toast-message text-label-medium-regular text-text-secondary", title: this.message }, this.message))), this.actionText && (h("button", { key: '07890efac226f3d8ad4dfa71422781ad94ab9be8', type: "button", class: `toast-copy toast-action self-start text-left text-label-medium-bold text-text-link underline rounded ${FOCUS_RING_CLASSES}`, title: this.actionText, onClick: () => this.toastAction.emit() }, this.actionText))), this.closable && (h("button", { key: 'da40e440a9b8efb785bb808718ae51d72c4550bc', part: "close-button", type: "button", "aria-label": this.closeLabel, class: `absolute top-16 right-16 flex items-center justify-center w-24 h-24 rounded ${intent.color} ${FOCUS_RING_CLASSES}`, onClick: () => this.toastDismissRequested.emit({ reason: 'close' }) }, h("sula-icon", { key: 'a326223db3ae4de7e0c2139b7b1b5f2ce3bf79ba', "aria-hidden": "true", icon: "ph ph-x", customClass: "text-2xl", class: "flex leading-none" }))), h("svg", { key: '6f0c0004ff519d857abcbed244215c9f2b9b7598', class: "toast-border", "aria-hidden": "true", focusable: "false" }, h("rect", { key: 'a2fec270e4bfc1afe1567e492c915304d6bd4f85', class: "toast-border__path", pathLength: "1" }))), h("div", { key: 'be19cd8661299b03aebc46d9eb94c53f948924f4', class: "sr-only", role: "status", "aria-live": "polite", "aria-atomic": "true" }, this.announcement === 'polite' ? this.announcedText : ''), h("div", { key: '2582e166e21d087d1e3f2b66d39b2a05d4d8bbb2', class: "sr-only", role: "alert", "aria-live": "assertive", "aria-atomic": "true" }, this.announcement === 'assertive' ? this.announcedText : '')));
|
|
178
|
+
}
|
|
179
|
+
static get is() { return "sula-toast"; }
|
|
180
|
+
static get encapsulation() { return "shadow"; }
|
|
181
|
+
static get originalStyleUrls() {
|
|
182
|
+
return {
|
|
183
|
+
"$": ["sula-toast.scss"]
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
static get styleUrls() {
|
|
187
|
+
return {
|
|
188
|
+
"$": ["sula-toast.css"]
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
static get properties() {
|
|
192
|
+
return {
|
|
193
|
+
"toastTitle": {
|
|
194
|
+
"type": "string",
|
|
195
|
+
"attribute": "toast-title",
|
|
196
|
+
"mutable": false,
|
|
197
|
+
"complexType": {
|
|
198
|
+
"original": "string",
|
|
199
|
+
"resolved": "string",
|
|
200
|
+
"references": {}
|
|
201
|
+
},
|
|
202
|
+
"required": false,
|
|
203
|
+
"optional": false,
|
|
204
|
+
"docs": {
|
|
205
|
+
"tags": [],
|
|
206
|
+
"text": "Notification title."
|
|
207
|
+
},
|
|
208
|
+
"getter": false,
|
|
209
|
+
"setter": false,
|
|
210
|
+
"reflect": false,
|
|
211
|
+
"defaultValue": "''"
|
|
212
|
+
},
|
|
213
|
+
"message": {
|
|
214
|
+
"type": "string",
|
|
215
|
+
"attribute": "message",
|
|
216
|
+
"mutable": false,
|
|
217
|
+
"complexType": {
|
|
218
|
+
"original": "string",
|
|
219
|
+
"resolved": "string",
|
|
220
|
+
"references": {}
|
|
221
|
+
},
|
|
222
|
+
"required": false,
|
|
223
|
+
"optional": false,
|
|
224
|
+
"docs": {
|
|
225
|
+
"tags": [],
|
|
226
|
+
"text": "Optional notification description, displayed on up to four lines."
|
|
227
|
+
},
|
|
228
|
+
"getter": false,
|
|
229
|
+
"setter": false,
|
|
230
|
+
"reflect": false,
|
|
231
|
+
"defaultValue": "''"
|
|
232
|
+
},
|
|
233
|
+
"type": {
|
|
234
|
+
"type": "string",
|
|
235
|
+
"attribute": "type",
|
|
236
|
+
"mutable": false,
|
|
237
|
+
"complexType": {
|
|
238
|
+
"original": "SulaToastType",
|
|
239
|
+
"resolved": "SulaToastType.Brand | SulaToastType.Danger | SulaToastType.Info | SulaToastType.Neutral | SulaToastType.Success | SulaToastType.Warning",
|
|
240
|
+
"references": {
|
|
241
|
+
"SulaToastType": {
|
|
242
|
+
"location": "import",
|
|
243
|
+
"path": "./model/sula-toast.model",
|
|
244
|
+
"id": "src/components/sula-toast/model/sula-toast.model.ts::SulaToastType"
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
},
|
|
248
|
+
"required": false,
|
|
249
|
+
"optional": false,
|
|
250
|
+
"docs": {
|
|
251
|
+
"tags": [],
|
|
252
|
+
"text": "Visual intent, independent of announcement urgency."
|
|
253
|
+
},
|
|
254
|
+
"getter": false,
|
|
255
|
+
"setter": false,
|
|
256
|
+
"reflect": false,
|
|
257
|
+
"defaultValue": "SulaToastType.Neutral"
|
|
258
|
+
},
|
|
259
|
+
"icon": {
|
|
260
|
+
"type": "string",
|
|
261
|
+
"attribute": "icon",
|
|
262
|
+
"mutable": false,
|
|
263
|
+
"complexType": {
|
|
264
|
+
"original": "string",
|
|
265
|
+
"resolved": "string",
|
|
266
|
+
"references": {}
|
|
267
|
+
},
|
|
268
|
+
"required": false,
|
|
269
|
+
"optional": true,
|
|
270
|
+
"docs": {
|
|
271
|
+
"tags": [],
|
|
272
|
+
"text": "Optional full Phosphor class name. No icon is displayed when omitted or empty."
|
|
273
|
+
},
|
|
274
|
+
"getter": false,
|
|
275
|
+
"setter": false,
|
|
276
|
+
"reflect": false
|
|
277
|
+
},
|
|
278
|
+
"actionText": {
|
|
279
|
+
"type": "string",
|
|
280
|
+
"attribute": "action-text",
|
|
281
|
+
"mutable": false,
|
|
282
|
+
"complexType": {
|
|
283
|
+
"original": "string",
|
|
284
|
+
"resolved": "string",
|
|
285
|
+
"references": {}
|
|
286
|
+
},
|
|
287
|
+
"required": false,
|
|
288
|
+
"optional": false,
|
|
289
|
+
"docs": {
|
|
290
|
+
"tags": [],
|
|
291
|
+
"text": "Optional single-line action label. The consumer implements the action."
|
|
292
|
+
},
|
|
293
|
+
"getter": false,
|
|
294
|
+
"setter": false,
|
|
295
|
+
"reflect": false,
|
|
296
|
+
"defaultValue": "''"
|
|
297
|
+
},
|
|
298
|
+
"closable": {
|
|
299
|
+
"type": "boolean",
|
|
300
|
+
"attribute": "closable",
|
|
301
|
+
"mutable": false,
|
|
302
|
+
"complexType": {
|
|
303
|
+
"original": "boolean",
|
|
304
|
+
"resolved": "boolean",
|
|
305
|
+
"references": {}
|
|
306
|
+
},
|
|
307
|
+
"required": false,
|
|
308
|
+
"optional": false,
|
|
309
|
+
"docs": {
|
|
310
|
+
"tags": [],
|
|
311
|
+
"text": "Whether to display the dismiss button."
|
|
312
|
+
},
|
|
313
|
+
"getter": false,
|
|
314
|
+
"setter": false,
|
|
315
|
+
"reflect": false,
|
|
316
|
+
"defaultValue": "true"
|
|
317
|
+
},
|
|
318
|
+
"duration": {
|
|
319
|
+
"type": "number",
|
|
320
|
+
"attribute": "duration",
|
|
321
|
+
"mutable": false,
|
|
322
|
+
"complexType": {
|
|
323
|
+
"original": "number",
|
|
324
|
+
"resolved": "number",
|
|
325
|
+
"references": {}
|
|
326
|
+
},
|
|
327
|
+
"required": false,
|
|
328
|
+
"optional": true,
|
|
329
|
+
"docs": {
|
|
330
|
+
"tags": [],
|
|
331
|
+
"text": "Milliseconds before requesting dismissal. Zero persists; omitted means 5000 without an action and persistent with an action."
|
|
332
|
+
},
|
|
333
|
+
"getter": false,
|
|
334
|
+
"setter": false,
|
|
335
|
+
"reflect": false
|
|
336
|
+
},
|
|
337
|
+
"paused": {
|
|
338
|
+
"type": "boolean",
|
|
339
|
+
"attribute": "paused",
|
|
340
|
+
"mutable": false,
|
|
341
|
+
"complexType": {
|
|
342
|
+
"original": "boolean",
|
|
343
|
+
"resolved": "boolean",
|
|
344
|
+
"references": {}
|
|
345
|
+
},
|
|
346
|
+
"required": false,
|
|
347
|
+
"optional": false,
|
|
348
|
+
"docs": {
|
|
349
|
+
"tags": [],
|
|
350
|
+
"text": "Externally pause the remaining timeout, for example while covered by a stack."
|
|
351
|
+
},
|
|
352
|
+
"getter": false,
|
|
353
|
+
"setter": false,
|
|
354
|
+
"reflect": false,
|
|
355
|
+
"defaultValue": "false"
|
|
356
|
+
},
|
|
357
|
+
"animated": {
|
|
358
|
+
"type": "boolean",
|
|
359
|
+
"attribute": "animated",
|
|
360
|
+
"mutable": false,
|
|
361
|
+
"complexType": {
|
|
362
|
+
"original": "boolean",
|
|
363
|
+
"resolved": "boolean",
|
|
364
|
+
"references": {}
|
|
365
|
+
},
|
|
366
|
+
"required": false,
|
|
367
|
+
"optional": false,
|
|
368
|
+
"docs": {
|
|
369
|
+
"tags": [],
|
|
370
|
+
"text": "Whether to play the entrance animations (fade-in and border trace). Disable when a parent already controls the animation, for example toasts covered in a stack."
|
|
371
|
+
},
|
|
372
|
+
"getter": false,
|
|
373
|
+
"setter": false,
|
|
374
|
+
"reflect": false,
|
|
375
|
+
"defaultValue": "true"
|
|
376
|
+
},
|
|
377
|
+
"announcement": {
|
|
378
|
+
"type": "string",
|
|
379
|
+
"attribute": "announcement",
|
|
380
|
+
"mutable": false,
|
|
381
|
+
"complexType": {
|
|
382
|
+
"original": "SulaToastAnnouncement",
|
|
383
|
+
"resolved": "\"assertive\" | \"off\" | \"polite\"",
|
|
384
|
+
"references": {
|
|
385
|
+
"SulaToastAnnouncement": {
|
|
386
|
+
"location": "import",
|
|
387
|
+
"path": "./model/sula-toast.model",
|
|
388
|
+
"id": "src/components/sula-toast/model/sula-toast.model.ts::SulaToastAnnouncement"
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
},
|
|
392
|
+
"required": false,
|
|
393
|
+
"optional": false,
|
|
394
|
+
"docs": {
|
|
395
|
+
"tags": [],
|
|
396
|
+
"text": "Screen reader announcement priority. Use off when a parent owns announcements."
|
|
397
|
+
},
|
|
398
|
+
"getter": false,
|
|
399
|
+
"setter": false,
|
|
400
|
+
"reflect": false,
|
|
401
|
+
"defaultValue": "'polite'"
|
|
402
|
+
},
|
|
403
|
+
"closeLabel": {
|
|
404
|
+
"type": "string",
|
|
405
|
+
"attribute": "close-label",
|
|
406
|
+
"mutable": false,
|
|
407
|
+
"complexType": {
|
|
408
|
+
"original": "string",
|
|
409
|
+
"resolved": "string",
|
|
410
|
+
"references": {}
|
|
411
|
+
},
|
|
412
|
+
"required": false,
|
|
413
|
+
"optional": false,
|
|
414
|
+
"docs": {
|
|
415
|
+
"tags": [],
|
|
416
|
+
"text": "Accessible dismiss button label."
|
|
417
|
+
},
|
|
418
|
+
"getter": false,
|
|
419
|
+
"setter": false,
|
|
420
|
+
"reflect": false,
|
|
421
|
+
"defaultValue": "'Fechar notifica\u00E7\u00E3o'"
|
|
422
|
+
}
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
static get states() {
|
|
426
|
+
return {
|
|
427
|
+
"announcedText": {}
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
static get events() {
|
|
431
|
+
return [{
|
|
432
|
+
"method": "toastDismissRequested",
|
|
433
|
+
"name": "toastDismissRequested",
|
|
434
|
+
"bubbles": true,
|
|
435
|
+
"cancelable": true,
|
|
436
|
+
"composed": true,
|
|
437
|
+
"docs": {
|
|
438
|
+
"tags": [],
|
|
439
|
+
"text": "Requests removal by the consumer. Does not remove or hide the element."
|
|
440
|
+
},
|
|
441
|
+
"complexType": {
|
|
442
|
+
"original": "SulaToastDismissEvent",
|
|
443
|
+
"resolved": "SulaToastDismissEvent",
|
|
444
|
+
"references": {
|
|
445
|
+
"SulaToastDismissEvent": {
|
|
446
|
+
"location": "import",
|
|
447
|
+
"path": "./model/sula-toast.model",
|
|
448
|
+
"id": "src/components/sula-toast/model/sula-toast.model.ts::SulaToastDismissEvent"
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
}, {
|
|
453
|
+
"method": "toastAction",
|
|
454
|
+
"name": "toastAction",
|
|
455
|
+
"bubbles": true,
|
|
456
|
+
"cancelable": true,
|
|
457
|
+
"composed": true,
|
|
458
|
+
"docs": {
|
|
459
|
+
"tags": [],
|
|
460
|
+
"text": "Requests the configured action without dismissing the notification."
|
|
461
|
+
},
|
|
462
|
+
"complexType": {
|
|
463
|
+
"original": "void",
|
|
464
|
+
"resolved": "void",
|
|
465
|
+
"references": {}
|
|
466
|
+
}
|
|
467
|
+
}];
|
|
468
|
+
}
|
|
469
|
+
static get elementRef() { return "hostElement"; }
|
|
470
|
+
static get watchers() {
|
|
471
|
+
return [{
|
|
472
|
+
"propName": "toastTitle",
|
|
473
|
+
"methodName": "handleContentChange"
|
|
474
|
+
}, {
|
|
475
|
+
"propName": "message",
|
|
476
|
+
"methodName": "handleContentChange"
|
|
477
|
+
}, {
|
|
478
|
+
"propName": "actionText",
|
|
479
|
+
"methodName": "handleContentChange"
|
|
480
|
+
}, {
|
|
481
|
+
"propName": "duration",
|
|
482
|
+
"methodName": "handleContentChange"
|
|
483
|
+
}, {
|
|
484
|
+
"propName": "announcement",
|
|
485
|
+
"methodName": "updateAnnouncement"
|
|
486
|
+
}, {
|
|
487
|
+
"propName": "paused",
|
|
488
|
+
"methodName": "updateTimeout"
|
|
489
|
+
}];
|
|
490
|
+
}
|
|
491
|
+
static get listeners() {
|
|
492
|
+
return [{
|
|
493
|
+
"name": "visibilitychange",
|
|
494
|
+
"method": "updateTimeout",
|
|
495
|
+
"target": "document",
|
|
496
|
+
"capture": false,
|
|
497
|
+
"passive": false
|
|
498
|
+
}];
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
//# sourceMappingURL=sula-toast.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sula-toast.js","sourceRoot":"","sources":["../../../src/components/sula-toast/sula-toast.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAC7G,OAAO,EAAgD,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEvG,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAC9B,MAAM,kBAAkB,GAAG,2HAA2H,CAAC;AAEvJ,MAAM,aAAa,GAAsG;IACvH,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE;QACvB,MAAM,EAAE,qBAAqB;QAC7B,WAAW,EAAE,2BAA2B;QACxC,KAAK,EAAE,mBAAmB;QAC1B,U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} from '@stencil/core';\nimport { SulaToastAnnouncement, SulaToastDismissEvent, SulaToastType } from './model/sula-toast.model';\n\nconst DEFAULT_DURATION = 5000;\nconst FOCUS_RING_CLASSES = 'focus-visible:outline focus-visible:outline-2 focus-visible:outline-feedback-informational focus-visible:outline-offset-2';\n\nconst TOAST_INTENTS: Record<SulaToastType, { border: string; borderColor: string; color: string; background: string }> = {\n [SulaToastType.Neutral]: {\n border: 'border-line-general',\n borderColor: 'var(--color-line-general)',\n color: 'text-icon-primary',\n background: 'bg-surface-on-body',\n },\n [SulaToastType.Brand]: {\n border: 'border-brand-primary',\n borderColor: 'var(--color-brand-primary)',\n color: 'text-brand-primary',\n background: 'bg-surface-on-body-brand',\n },\n [SulaToastType.Info]: {\n border: 'border-feedback-informational',\n borderColor: 'var(--color-feedback-informational)',\n color: 'text-feedback-informational',\n background: 'bg-surface-on-body-feedback-info',\n },\n [SulaToastType.Success]: {\n border: 'border-feedback-success',\n borderColor: 'var(--color-feedback-success)',\n color: 'text-feedback-success',\n background: 'bg-surface-on-body-feedback-success',\n },\n [SulaToastType.Warning]: {\n border: 'border-feedback-alert',\n borderColor: 'var(--color-feedback-alert)',\n color: 'text-feedback-alert',\n background: 'bg-surface-on-body-feedback-alert',\n },\n [SulaToastType.Danger]: {\n border: 'border-feedback-error',\n borderColor: 'var(--color-feedback-error)',\n color: 'text-feedback-error',\n background: 'bg-surface-on-body-feedback-error',\n },\n};\n\n/**\n * A controlled notification. The consumer removes it after toastDismissRequested.\n * @part container - Notification surface.\n * @part icon - Decorative intent icon.\n * @part content - Title, description and action.\n * @part close-button - Dismiss button.\n */\n@Component({ tag: 'sula-toast', styleUrl: 'sula-toast.scss', shadow: true })\nexport class SulaToast {\n @Element() hostElement: HTMLElement;\n\n /** Notification title. */\n @Prop() toastTitle = '';\n\n /** Optional notification description, displayed on up to four lines. */\n @Prop() message = '';\n\n /** Visual intent, independent of announcement urgency. */\n @Prop() type: SulaToastType = SulaToastType.Neutral;\n\n /** Optional full Phosphor class name. No icon is displayed when omitted or empty. */\n @Prop() icon?: string;\n\n /** Optional single-line action label. The consumer implements the action. */\n @Prop() actionText = '';\n\n /** Whether to display the dismiss button. */\n @Prop() closable = true;\n\n /** Milliseconds before requesting dismissal. Zero persists; omitted means 5000 without an action and persistent with an action. */\n @Prop() duration?: number;\n\n /** Externally pause the remaining timeout, for example while covered by a stack. */\n @Prop() paused = false;\n\n /** Whether to play the entrance animations (fade-in and border trace). Disable when a parent already controls the animation, for example toasts covered in a stack. */\n @Prop() animated = true;\n\n /** Screen reader announcement priority. Use off when a parent owns announcements. */\n @Prop() announcement: SulaToastAnnouncement = 'polite';\n\n /** Accessible dismiss button label. */\n @Prop() closeLabel = 'Fechar notificação';\n\n /** Requests removal by the consumer. Does not remove or hide the element. */\n @Event() toastDismissRequested: EventEmitter<SulaToastDismissEvent>;\n /** Requests the configured action without dismissing the notification. */\n @Event() toastAction: EventEmitter<void>;\n\n @State() announcedText = '';\n private timer?: ReturnType<typeof setTimeout>;\n private observer?: IntersectionObserver;\n private remaining = 0;\n private startedAt = 0;\n private timedOut = false;\n private timeoutEnabled = false;\n private hovering = false;\n private focused = false;\n private visible = false;\n private ready = false;\n private connected = false;\n\n connectedCallback() {\n this.connected = true;\n if (this.ready) this.observeVisibility();\n }\n\n componentDidLoad() {\n this.ready = true;\n this.resetTimeout();\n Promise.resolve().then(() => {\n if (this.connected) this.updateAnnouncement();\n });\n this.observeVisibility();\n }\n\n disconnectedCallback() {\n this.connected = false;\n this.stopTimeout();\n this.observer?.disconnect();\n this.hovering = false;\n this.focused = false;\n }\n\n @Watch('toastTitle')\n @Watch('message')\n @Watch('actionText')\n @Watch('duration')\n handleContentChange() {\n this.resetTimeout();\n this.updateAnnouncement();\n }\n\n @Watch('announcement')\n updateAnnouncement() {\n this.announcedText = this.announcement === 'off' ? '' : [this.toastTitle, this.message].filter(Boolean).join('. ');\n }\n\n @Watch('paused')\n @Listen('visibilitychange', { target: 'document' })\n updateTimeout() {\n const blocked = !this.connected || !this.ready || !this.visible || this.paused || this.hovering || this.focused || document.visibilityState === 'hidden';\n if (blocked) {\n this.stopTimeout();\n } else if (this.timer === undefined && this.timeoutEnabled && !this.timedOut) {\n this.startedAt = Date.now();\n this.timer = setTimeout(() => {\n this.timer = undefined;\n this.remaining = 0;\n this.timedOut = true;\n this.toastDismissRequested.emit({ reason: 'timeout' });\n }, this.remaining);\n }\n }\n\n private resetTimeout() {\n this.stopTimeout();\n this.remaining = this.resolveDuration();\n this.timeoutEnabled = this.remaining > 0;\n this.timedOut = false;\n this.updateTimeout();\n }\n\n private resolveDuration() {\n if (typeof this.duration === 'number' && Number.isFinite(this.duration) && this.duration >= 0) return this.duration;\n return this.actionText ? 0 : DEFAULT_DURATION;\n }\n\n private stopTimeout() {\n if (this.timer !== undefined) {\n clearTimeout(this.timer);\n this.timer = undefined;\n this.remaining = Math.max(0, this.remaining - (Date.now() - this.startedAt));\n }\n }\n\n private observeVisibility() {\n this.observer?.disconnect();\n if (typeof IntersectionObserver === 'undefined') {\n this.visible = true;\n this.updateTimeout();\n return;\n }\n this.visible = false;\n this.observer = new IntersectionObserver(entries => {\n this.visible = entries.some(entry => entry.isIntersecting && entry.intersectionRatio > 0);\n this.updateTimeout();\n });\n this.observer.observe(this.hostElement);\n }\n\n private setHover(value: boolean) {\n this.hovering = value && !(window.matchMedia?.('(hover: none)').matches ?? false);\n this.updateTimeout();\n }\n\n private handleFocusOut = (event: FocusEvent) => {\n const target = event.relatedTarget as Node | null;\n this.focused = !!target && (this.hostElement.contains(target) || this.hostElement.shadowRoot.contains(target));\n this.updateTimeout();\n };\n\n private get intent() {\n return TOAST_INTENTS[this.type] || TOAST_INTENTS[SulaToastType.Neutral];\n }\n\n render() {\n const intent = this.intent;\n return (\n <Host\n onMouseEnter={() => this.setHover(true)}\n onMouseLeave={() => this.setHover(false)}\n onFocusin={() => {\n this.focused = true;\n this.updateTimeout();\n }}\n onFocusout={this.handleFocusOut}\n >\n <div\n part=\"container\"\n class={`toast-surface relative isolate box-border flex items-center w-full p-16 gap-12 rounded-sm border bg-opacity-toast ${intent.border} ${this.animated ? 'toast-surface--animated' : ''}`}\n style={{ '--toast-border-color': intent.borderColor }}\n >\n {this.icon && (\n <div part=\"icon\" aria-hidden=\"true\" class={`flex shrink-0 items-center justify-center w-44 h-44 rounded-xxl ${intent.background}`}>\n <sula-icon icon={this.icon} customClass={`text-2xl ${intent.color}`} class=\"flex leading-none\" />\n </div>\n )}\n <div part=\"content\" class={`flex min-w-0 flex-1 flex-col gap-8 ${this.closable ? 'pr-48' : ''}`}>\n <div class=\"flex flex-col gap-4\">\n {this.toastTitle && (\n <p class=\"toast-copy toast-title text-label-medium-bold text-text-primary\" title={this.toastTitle}>\n {this.toastTitle}\n </p>\n )}\n {this.message && (\n <p class=\"toast-copy toast-message text-label-medium-regular text-text-secondary\" title={this.message}>\n {this.message}\n </p>\n )}\n </div>\n {this.actionText && (\n <button\n type=\"button\"\n class={`toast-copy toast-action self-start text-left text-label-medium-bold text-text-link underline rounded ${FOCUS_RING_CLASSES}`}\n title={this.actionText}\n onClick={() => this.toastAction.emit()}\n >\n {this.actionText}\n </button>\n )}\n </div>\n {this.closable && (\n <button\n part=\"close-button\"\n type=\"button\"\n aria-label={this.closeLabel}\n class={`absolute top-16 right-16 flex items-center justify-center w-24 h-24 rounded ${intent.color} ${FOCUS_RING_CLASSES}`}\n onClick={() => this.toastDismissRequested.emit({ reason: 'close' })}\n >\n <sula-icon aria-hidden=\"true\" icon=\"ph ph-x\" customClass=\"text-2xl\" class=\"flex leading-none\" />\n </button>\n )}\n <svg class=\"toast-border\" aria-hidden=\"true\" focusable=\"false\">\n <rect class=\"toast-border__path\" pathLength=\"1\" />\n </svg>\n </div>\n <div class=\"sr-only\" role=\"status\" aria-live=\"polite\" aria-atomic=\"true\">\n {this.announcement === 'polite' ? this.announcedText : ''}\n </div>\n <div class=\"sr-only\" role=\"alert\" aria-live=\"assertive\" aria-atomic=\"true\">\n {this.announcement === 'assertive' ? this.announcedText : ''}\n </div>\n </Host>\n );\n }\n}\n"]}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s)
|
|
4
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
import { SulaToastType } from "./model/sula-toast.model";
|
|
14
|
+
export default {
|
|
15
|
+
title: 'Components/sula-toast',
|
|
16
|
+
tags: ['autodocs'],
|
|
17
|
+
parameters: {
|
|
18
|
+
docs: {
|
|
19
|
+
description: {
|
|
20
|
+
component: 'Notificação controlada com seis intenções. Ao entrar, surge suavemente enquanto a borda percorre o perímetro. A aplicação remove o elemento ao receber toastDismissRequested e implementa a ação em toastAction. Sem duração explícita, mensagens sem ação duram 5 segundos; com ação permanecem. As demonstrações visuais usam duration=0.',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
argTypes: {
|
|
25
|
+
toastTitle: { control: 'text', description: 'Título da notificação.' },
|
|
26
|
+
message: { control: 'text', description: 'Descrição opcional, limitada visualmente a quatro linhas.' },
|
|
27
|
+
type: { control: 'select', options: Object.values(SulaToastType) },
|
|
28
|
+
icon: { control: 'text', description: 'Classe Phosphor completa; omitida ou vazia não exibe ícone.' },
|
|
29
|
+
actionText: { control: 'text', description: 'Ação opcional de uma linha, com reticências quando necessário.' },
|
|
30
|
+
closable: { control: 'boolean' },
|
|
31
|
+
duration: { control: 'number', description: 'Milissegundos; 0 mantém a mensagem visível.' },
|
|
32
|
+
paused: { control: 'boolean' },
|
|
33
|
+
animated: { control: 'boolean', description: 'Controla a animação de entrada (fade e traçado da borda).' },
|
|
34
|
+
announcement: { control: 'select', options: ['polite', 'assertive', 'off'] },
|
|
35
|
+
closeLabel: { control: 'text' },
|
|
36
|
+
toastAction: { action: 'toastAction' },
|
|
37
|
+
toastDismissRequested: { action: 'toastDismissRequested' },
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
const Template = args => {
|
|
41
|
+
const surface = document.createElement('div');
|
|
42
|
+
surface.className = 'bg-surface-on-body rounded-sm p-32';
|
|
43
|
+
const toast = document.createElement('sula-toast');
|
|
44
|
+
const { toastAction, toastDismissRequested } = args, props = __rest(args, ["toastAction", "toastDismissRequested"]);
|
|
45
|
+
Object.assign(toast, props);
|
|
46
|
+
toast.addEventListener('toastAction', event => toastAction === null || toastAction === void 0 ? void 0 : toastAction(event));
|
|
47
|
+
toast.addEventListener('toastDismissRequested', event => toastDismissRequested === null || toastDismissRequested === void 0 ? void 0 : toastDismissRequested(event));
|
|
48
|
+
surface.append(toast);
|
|
49
|
+
return surface;
|
|
50
|
+
};
|
|
51
|
+
const defaults = {
|
|
52
|
+
toastTitle: 'Toast title',
|
|
53
|
+
message: 'This is a description with supporting details.',
|
|
54
|
+
actionText: 'Desfazer',
|
|
55
|
+
duration: 0,
|
|
56
|
+
icon: 'ph ph-circle-dashed',
|
|
57
|
+
closable: true,
|
|
58
|
+
announcement: 'polite',
|
|
59
|
+
closeLabel: 'Fechar notificação',
|
|
60
|
+
};
|
|
61
|
+
export const Neutral = { render: Template, args: Object.assign(Object.assign({}, defaults), { type: SulaToastType.Neutral }) };
|
|
62
|
+
export const Brand = { render: Template, args: Object.assign(Object.assign({}, defaults), { type: SulaToastType.Brand }) };
|
|
63
|
+
export const Info = { render: Template, args: Object.assign(Object.assign({}, defaults), { type: SulaToastType.Info, icon: 'ph ph-info' }) };
|
|
64
|
+
export const Success = { render: Template, args: Object.assign(Object.assign({}, defaults), { type: SulaToastType.Success, icon: 'ph ph-check-circle' }) };
|
|
65
|
+
export const Warning = { render: Template, args: Object.assign(Object.assign({}, defaults), { type: SulaToastType.Warning, icon: 'ph ph-warning' }) };
|
|
66
|
+
export const Danger = { render: Template, args: Object.assign(Object.assign({}, defaults), { type: SulaToastType.Danger, icon: 'ph ph-warning-circle' }) };
|
|
67
|
+
export const WithoutAction = { render: Template, args: Object.assign(Object.assign({}, defaults), { actionText: '' }) };
|
|
68
|
+
export const WithoutIconOrClose = { render: Template, args: Object.assign(Object.assign({}, defaults), { icon: '', closable: false }) };
|
|
69
|
+
export const LongContent = {
|
|
70
|
+
render: Template,
|
|
71
|
+
args: Object.assign(Object.assign({}, defaults), { toastTitle: 'Um título que pode ocupar mais de uma linha', message: 'A descrição ocupa até quatro linhas e termina com reticências quando o conteúdo ultrapassa o espaço disponível: abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz.', actionText: 'Uma ação extensa também permanece em uma única linha' }),
|
|
72
|
+
};
|
|
73
|
+
export const ControlledDismissal = {
|
|
74
|
+
render: () => {
|
|
75
|
+
const container = document.createElement('div');
|
|
76
|
+
const show = document.createElement('button');
|
|
77
|
+
show.type = 'button';
|
|
78
|
+
show.textContent = 'Mostrar notificação novamente';
|
|
79
|
+
show.className = 'text-text-link underline mb-24';
|
|
80
|
+
const output = document.createElement('div');
|
|
81
|
+
const showToast = () => {
|
|
82
|
+
const toast = document.createElement('sula-toast');
|
|
83
|
+
toast.toastTitle = 'Alterações salvas';
|
|
84
|
+
toast.message = 'Passe o mouse ou use Tab para pausar o tempo.';
|
|
85
|
+
toast.addEventListener('toastDismissRequested', () => {
|
|
86
|
+
const wasFocused = toast.matches(':focus-within');
|
|
87
|
+
toast.remove();
|
|
88
|
+
show.hidden = false;
|
|
89
|
+
if (wasFocused)
|
|
90
|
+
show.focus();
|
|
91
|
+
});
|
|
92
|
+
show.hidden = true;
|
|
93
|
+
output.replaceChildren(toast);
|
|
94
|
+
};
|
|
95
|
+
show.addEventListener('click', showToast);
|
|
96
|
+
container.append(show, output);
|
|
97
|
+
showToast();
|
|
98
|
+
return container;
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
//# sourceMappingURL=sula-toast.stories.js.map
|