@aurodesignsystem-dev/auro-toast 0.0.0-pr147.9 → 0.0.0-pr149.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/README.md +35 -23
- package/demo/api.md +7 -8
- package/demo/api.min.js +22 -98
- package/demo/index.min.js +21 -97
- package/dist/{auro-toaster-BKYDCLaO.js → auro-toaster-BVtBRPDA.js} +6 -6
- package/dist/index.d.ts +6 -15
- package/dist/index.js +1 -1
- package/dist/registered.js +1 -1
- package/package.json +2 -3
- package/custom-elements.json +0 -458
package/README.md
CHANGED
|
@@ -49,7 +49,9 @@ The `<auro-toast>` use cases include:
|
|
|
49
49
|
[](https://www.apache.org/licenses/LICENSE-2.0)
|
|
50
50
|

|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
```shell
|
|
53
|
+
$ npm i @aurodesignsystem/auro-toast
|
|
54
|
+
```
|
|
53
55
|
|
|
54
56
|
<!-- AURO-GENERATED-CONTENT:END -->
|
|
55
57
|
|
|
@@ -61,7 +63,9 @@ Defining the dependency within each project that is using the `<auro-toast>` com
|
|
|
61
63
|
<!-- AURO-GENERATED-CONTENT:END -->
|
|
62
64
|
<!-- AURO-GENERATED-CONTENT:START (REMOTE:url=https://raw.githubusercontent.com/AlaskaAirlines/auro-templates/main/templates/default/partials/usage/componentImport.md) -->
|
|
63
65
|
|
|
64
|
-
|
|
66
|
+
```js
|
|
67
|
+
import "@aurodesignsystem/auro-toast";
|
|
68
|
+
```
|
|
65
69
|
|
|
66
70
|
<!-- AURO-GENERATED-CONTENT:END -->
|
|
67
71
|
|
|
@@ -70,7 +74,9 @@ Defining the dependency within each project that is using the `<auro-toast>` com
|
|
|
70
74
|
<!-- AURO-GENERATED-CONTENT:START (REMOTE:url=https://raw.githubusercontent.com/AlaskaAirlines/auro-templates/main/templates/default/partials/usage/bundleInstallDescription.md) -->
|
|
71
75
|
In cases where the project is not able to process JS assets, there are pre-processed assets available for use. Legacy browsers such as IE11 are no longer supported.
|
|
72
76
|
|
|
73
|
-
|
|
77
|
+
```html
|
|
78
|
+
<script type="module" src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-toast@latest/+esm"></script>
|
|
79
|
+
```
|
|
74
80
|
|
|
75
81
|
<!-- AURO-GENERATED-CONTENT:END -->
|
|
76
82
|
|
|
@@ -79,16 +85,18 @@ In cases where the project is not able to process JS assets, there are pre-proce
|
|
|
79
85
|
<!-- AURO-GENERATED-CONTENT:START (CODE:src=./apiExamples/basic.html) -->
|
|
80
86
|
<!-- The below code snippet is automatically added from ./apiExamples/basic.html -->
|
|
81
87
|
|
|
82
|
-
|
|
88
|
+
```html
|
|
89
|
+
<auro-button id="basicToastBtn">
|
|
83
90
|
Show default notification
|
|
84
|
-
|
|
85
|
-
|
|
91
|
+
</auro-button>
|
|
92
|
+
<!--
|
|
86
93
|
NOTE: The manually added style is NOT necessary for use,
|
|
87
94
|
Demo purposes ONLY!
|
|
88
|
-
|
|
89
|
-
|
|
95
|
+
-->
|
|
96
|
+
<auro-toast style="display: block; margin: 0.5rem 0;" id="basicToast">
|
|
90
97
|
Default notification with no error type.
|
|
91
|
-
|
|
98
|
+
</auro-toast>
|
|
99
|
+
```
|
|
92
100
|
<!-- AURO-GENERATED-CONTENT:END -->
|
|
93
101
|
|
|
94
102
|
## Custom Component Registration for Version Management
|
|
@@ -105,35 +113,39 @@ You can do this by importing only the component class and using the `register(na
|
|
|
105
113
|
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./docs/partials/customRegistration.md) -->
|
|
106
114
|
<!-- The below content is automatically added from ./docs/partials/customRegistration.md -->
|
|
107
115
|
|
|
108
|
-
|
|
116
|
+
```js
|
|
117
|
+
// Import the class only
|
|
109
118
|
import { AuroToast } from '@aurodesignsystem/auro-toast/class';
|
|
110
119
|
|
|
111
120
|
// Register with a custom name if desired
|
|
112
|
-
AuroToast.register('custom-toast')
|
|
121
|
+
AuroToast.register('custom-toast');
|
|
122
|
+
```
|
|
113
123
|
|
|
114
124
|
This will create a new custom element `<custom-toast>` that behaves exactly like `<auro-toast>`, allowing both to coexist on the same page without interfering with each other.
|
|
115
125
|
<!-- AURO-GENERATED-CONTENT:END -->
|
|
116
126
|
<div class="exampleWrapper exampleWrapper--flex">
|
|
117
|
-
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./apiExamples/custom.html) -->
|
|
118
|
-
<!-- The below content is automatically added from ./apiExamples/custom.html -->
|
|
119
|
-
<auro-button id="customToastBtn">
|
|
127
|
+
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./apiExamples/custom.html) -->
|
|
128
|
+
<!-- The below content is automatically added from ./apiExamples/custom.html -->
|
|
129
|
+
<auro-button id="customToastBtn">
|
|
120
130
|
Show default notification
|
|
121
|
-
</auro-button>
|
|
122
|
-
<custom-toast style="display: block; margin: 0.5rem 0;" id="customToast">
|
|
131
|
+
</auro-button>
|
|
132
|
+
<custom-toast style="display: block; margin: 0.5rem 0;" id="customToast">
|
|
123
133
|
Default notification with no error type.
|
|
124
|
-
</custom-toast>
|
|
125
|
-
<!-- AURO-GENERATED-CONTENT:END -->
|
|
134
|
+
</custom-toast>
|
|
135
|
+
<!-- AURO-GENERATED-CONTENT:END -->
|
|
126
136
|
</div>
|
|
127
137
|
<auro-accordion alignRight>
|
|
128
|
-
<span slot="trigger">See code</span>
|
|
138
|
+
<span slot="trigger">See code</span>
|
|
129
139
|
<!-- AURO-GENERATED-CONTENT:START (CODE:src=./apiExamples/custom.html) -->
|
|
130
140
|
<!-- The below code snippet is automatically added from ./apiExamples/custom.html -->
|
|
131
141
|
|
|
132
|
-
|
|
142
|
+
```html
|
|
143
|
+
<auro-button id="customToastBtn">
|
|
133
144
|
Show default notification
|
|
134
|
-
|
|
135
|
-
|
|
145
|
+
</auro-button>
|
|
146
|
+
<custom-toast style="display: block; margin: 0.5rem 0;" id="customToast">
|
|
136
147
|
Default notification with no error type.
|
|
137
|
-
|
|
148
|
+
</custom-toast>
|
|
149
|
+
```
|
|
138
150
|
<!-- AURO-GENERATED-CONTENT:END -->
|
|
139
151
|
</auro-accordion>
|
package/demo/api.md
CHANGED
|
@@ -9,9 +9,9 @@ The `auro-toast` element provides users a way to display short, temporary messag
|
|
|
9
9
|
|
|
10
10
|
| Properties | Attributes | Modifiers | Type | Default | Description |
|
|
11
11
|
| --------------- | --------------- | --------- | -------------------------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
12
|
-
| disableAutoHide |
|
|
13
|
-
| noIcon |
|
|
14
|
-
| timeTilHide |
|
|
12
|
+
| disableAutoHide | disableAutoHide | | boolean | | Prevents the toast from auto-hiding on the default time. |
|
|
13
|
+
| noIcon | noIcon | | boolean | | Removes icon from the toast UI. |
|
|
14
|
+
| timeTilHide | timeTilHide | | number | | Sets the time in milliseconds until the toast hides. |
|
|
15
15
|
| trigger | trigger | | string | | The id of the element that triggered the toast.<br>When the toast is manually closed, focus will return to this element.<br>Takes precedence over the triggerElement property if both are set. |
|
|
16
16
|
| triggerElement | | | HTMLElement | | A direct reference to the element that triggered the toast.<br>When the toast is manually closed, focus will return to this element.<br>Use the trigger attribute instead if you prefer a declarative approach. |
|
|
17
17
|
| variant | variant | | `error` \| `success` \| `custom` | | Component will render visually based on which variant value is set. |
|
|
@@ -25,10 +25,9 @@ The `auro-toast` element provides users a way to display short, temporary messag
|
|
|
25
25
|
|
|
26
26
|
### Events
|
|
27
27
|
|
|
28
|
-
| Name | Description
|
|
29
|
-
| ------------ |
|
|
30
|
-
|
|
|
31
|
-
| onToastClose | **Deprecated**, use `toast-close` event instead. Note: `detail` is the toast element, not `{ visible }` — the two events do not share a payload shape. |
|
|
28
|
+
| Name | Description |
|
|
29
|
+
| ------------ | --------------------------------------- |
|
|
30
|
+
| onToastClose | Notifies that the toast has been closed |
|
|
32
31
|
|
|
33
32
|
### CSS Shadow Parts
|
|
34
33
|
|
|
@@ -514,7 +513,7 @@ export function initDynamicToastsExample() {
|
|
|
514
513
|
console.log("Toast added:", toastId);
|
|
515
514
|
|
|
516
515
|
// optional cleanup if your component doesn't auto-remove itself
|
|
517
|
-
toast.addEventListener("
|
|
516
|
+
toast.addEventListener("onToastClose", () => {
|
|
518
517
|
activeToasts.delete(toastId);
|
|
519
518
|
});
|
|
520
519
|
});
|
package/demo/api.min.js
CHANGED
|
@@ -182,7 +182,7 @@ function initDynamicToastsExample() {
|
|
|
182
182
|
console.log("Toast added:", toastId);
|
|
183
183
|
|
|
184
184
|
// optional cleanup if your component doesn't auto-remove itself
|
|
185
|
-
toast.addEventListener("
|
|
185
|
+
toast.addEventListener("onToastClose", () => {
|
|
186
186
|
activeToasts.delete(toastId);
|
|
187
187
|
});
|
|
188
188
|
});
|
|
@@ -538,8 +538,7 @@ const FADE_OUT_DURATION = 300;
|
|
|
538
538
|
*
|
|
539
539
|
* @csspart type-icon - Apply css to the toast type icon
|
|
540
540
|
* @csspart close-button - Apply css to the toast close button
|
|
541
|
-
* @fires onToastClose -
|
|
542
|
-
* @event toast-close - Notifies that the toast has been closed. `detail` is `{ visible: false }`.
|
|
541
|
+
* @fires onToastClose - Notifies that the toast has been closed
|
|
543
542
|
*/
|
|
544
543
|
|
|
545
544
|
// build the component class
|
|
@@ -625,11 +624,6 @@ class AuroToast extends i$2 {
|
|
|
625
624
|
*/
|
|
626
625
|
this.fadeOutTimer = undefined;
|
|
627
626
|
|
|
628
|
-
/**
|
|
629
|
-
* @private
|
|
630
|
-
*/
|
|
631
|
-
this.fadeOutCompleteTimer = undefined;
|
|
632
|
-
|
|
633
627
|
/**
|
|
634
628
|
* True when the toast is not inside an auro-toaster and must manage its
|
|
635
629
|
* own live region announcement. Set once in connectedCallback.
|
|
@@ -652,7 +646,6 @@ class AuroToast extends i$2 {
|
|
|
652
646
|
disableAutoHide: {
|
|
653
647
|
type: Boolean,
|
|
654
648
|
reflect: true,
|
|
655
|
-
attribute: "disableautohide",
|
|
656
649
|
},
|
|
657
650
|
|
|
658
651
|
/**
|
|
@@ -661,7 +654,6 @@ class AuroToast extends i$2 {
|
|
|
661
654
|
noIcon: {
|
|
662
655
|
type: Boolean,
|
|
663
656
|
reflect: true,
|
|
664
|
-
attribute: "noicon",
|
|
665
657
|
},
|
|
666
658
|
|
|
667
659
|
/**
|
|
@@ -670,7 +662,6 @@ class AuroToast extends i$2 {
|
|
|
670
662
|
timeTilHide: {
|
|
671
663
|
type: Number,
|
|
672
664
|
reflect: true,
|
|
673
|
-
attribute: "timetilhide",
|
|
674
665
|
},
|
|
675
666
|
|
|
676
667
|
/**
|
|
@@ -757,6 +748,7 @@ class AuroToast extends i$2 {
|
|
|
757
748
|
clickToClose() {
|
|
758
749
|
this._returnFocus();
|
|
759
750
|
this.closeToast();
|
|
751
|
+
clearTimeout(this.fadeOutTimer);
|
|
760
752
|
}
|
|
761
753
|
|
|
762
754
|
/**
|
|
@@ -764,37 +756,16 @@ class AuroToast extends i$2 {
|
|
|
764
756
|
* @returns {void}
|
|
765
757
|
*/
|
|
766
758
|
fadeOutToast() {
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
return;
|
|
773
|
-
}
|
|
759
|
+
if (!this.disableAutoHide) {
|
|
760
|
+
const toastContainer = this.shadowRoot.querySelector(".toastContainer");
|
|
761
|
+
if (toastContainer) {
|
|
762
|
+
toastContainer.classList.add("hidden");
|
|
763
|
+
}
|
|
774
764
|
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
765
|
+
setTimeout(() => {
|
|
766
|
+
this.closeToast();
|
|
767
|
+
}, FADE_OUT_DURATION);
|
|
778
768
|
}
|
|
779
|
-
|
|
780
|
-
clearTimeout(this.fadeOutCompleteTimer);
|
|
781
|
-
this.fadeOutCompleteTimer = setTimeout(() => {
|
|
782
|
-
this.closeToast();
|
|
783
|
-
}, FADE_OUT_DURATION);
|
|
784
|
-
}
|
|
785
|
-
|
|
786
|
-
/**
|
|
787
|
-
* Cancels an in-progress fade-out, if any, and restores the toast's
|
|
788
|
-
* visibility. Without this, interrupting a fade (e.g. escalating to
|
|
789
|
-
* variant="error" mid-fade) would clear the pending close but leave the
|
|
790
|
-
* "hidden" CSS class in place, permanently hiding a toast that remains
|
|
791
|
-
* open.
|
|
792
|
-
* @private
|
|
793
|
-
* @returns {void}
|
|
794
|
-
*/
|
|
795
|
-
_cancelFadeOut() {
|
|
796
|
-
clearTimeout(this.fadeOutCompleteTimer);
|
|
797
|
-
this.shadowRoot?.querySelector(".toastContainer")?.classList.remove("hidden");
|
|
798
769
|
}
|
|
799
770
|
|
|
800
771
|
/**
|
|
@@ -803,42 +774,20 @@ class AuroToast extends i$2 {
|
|
|
803
774
|
*/
|
|
804
775
|
closeToast() {
|
|
805
776
|
clearTimeout(this.fadeOutTimer);
|
|
806
|
-
clearTimeout(this.fadeOutCompleteTimer);
|
|
807
|
-
|
|
808
|
-
// Idempotent: a close already in flight (e.g. the close button clicked
|
|
809
|
-
// while the auto-hide fade-out is in progress) must not dispatch twice.
|
|
810
|
-
if (!this.visible) {
|
|
811
|
-
return;
|
|
812
|
-
}
|
|
813
|
-
|
|
814
777
|
this.visible = false;
|
|
815
778
|
|
|
816
779
|
/**
|
|
817
780
|
* Emits closed toast event.
|
|
818
781
|
*
|
|
819
|
-
* @deprecated Use `toast-close` event instead.
|
|
820
782
|
* @event onToastClose
|
|
821
|
-
* @type {
|
|
783
|
+
* @type {object}
|
|
784
|
+
* @property {boolean} false - Sets visibility value for the toast element.
|
|
822
785
|
*/
|
|
823
786
|
this.dispatchEvent(
|
|
824
787
|
new CustomEvent("onToastClose", {
|
|
825
788
|
bubbles: true,
|
|
826
789
|
composed: true,
|
|
827
|
-
detail: this,
|
|
828
|
-
}),
|
|
829
|
-
);
|
|
830
|
-
|
|
831
|
-
/**
|
|
832
|
-
* Emits closed toast event.
|
|
833
|
-
*
|
|
834
|
-
* @event toast-close
|
|
835
|
-
* @type {{ visible: boolean }}
|
|
836
|
-
*/
|
|
837
|
-
this.dispatchEvent(
|
|
838
|
-
new CustomEvent("toast-close", {
|
|
839
|
-
bubbles: true,
|
|
840
|
-
composed: true,
|
|
841
|
-
detail: { visible: false },
|
|
790
|
+
detail: this,
|
|
842
791
|
}),
|
|
843
792
|
);
|
|
844
793
|
}
|
|
@@ -876,14 +825,6 @@ class AuroToast extends i$2 {
|
|
|
876
825
|
super.connectedCallback();
|
|
877
826
|
this.setOnClick();
|
|
878
827
|
|
|
879
|
-
// On a reconnect (hasUpdated is false on the initial connection, which
|
|
880
|
-
// Lit's own first-update cycle already handles), force updated() to
|
|
881
|
-
// re-run so a visible toast's auto-hide timer — cleared by
|
|
882
|
-
// disconnectedCallback() — gets re-armed instead of being lost forever.
|
|
883
|
-
if (this.hasUpdated && this.visible) {
|
|
884
|
-
this.requestUpdate();
|
|
885
|
-
}
|
|
886
|
-
|
|
887
828
|
// Dispatch a cancelable event so auro-toaster can signal it will handle
|
|
888
829
|
// announcements. If nothing cancels the event the toast is standalone and
|
|
889
830
|
// must register its own live region on the host element — before
|
|
@@ -912,12 +853,6 @@ class AuroToast extends i$2 {
|
|
|
912
853
|
this._syncStandaloneRole();
|
|
913
854
|
}
|
|
914
855
|
|
|
915
|
-
disconnectedCallback() {
|
|
916
|
-
super.disconnectedCallback();
|
|
917
|
-
clearTimeout(this.fadeOutTimer);
|
|
918
|
-
clearTimeout(this.fadeOutCompleteTimer);
|
|
919
|
-
}
|
|
920
|
-
|
|
921
856
|
/**
|
|
922
857
|
* Sets or removes the live-region role on the host depending on whether
|
|
923
858
|
* the toast is standalone. Extracted so connectedCallback and updated()
|
|
@@ -967,20 +902,7 @@ class AuroToast extends i$2 {
|
|
|
967
902
|
this._syncStandaloneRole();
|
|
968
903
|
}
|
|
969
904
|
|
|
970
|
-
// Cancel an in-flight fade-out when the toast becomes ineligible for
|
|
971
|
-
// auto-dismiss (escalated to variant="error", or disableAutoHide set) —
|
|
972
|
-
// a stale completion timer must not auto-close a now-persistent toast.
|
|
973
|
-
if (
|
|
974
|
-
(changedProperties.has("variant") || changedProperties.has("disableAutoHide")) &&
|
|
975
|
-
(this.variant === "error" || this.disableAutoHide)
|
|
976
|
-
) {
|
|
977
|
-
this._cancelFadeOut();
|
|
978
|
-
}
|
|
979
|
-
|
|
980
905
|
// do not auto dismiss for error toasts or if disableAutoHide is set
|
|
981
|
-
// Note: intentionally does not clear fadeOutCompleteTimer — this block
|
|
982
|
-
// re-runs on every update while visible, and clearing it here would
|
|
983
|
-
// cancel an in-flight fade-out on any unrelated property change.
|
|
984
906
|
if (this.visible && !this.disableAutoHide && this.variant !== "error") {
|
|
985
907
|
clearTimeout(this.fadeOutTimer);
|
|
986
908
|
this.fadeOutTimer = setTimeout(() => {
|
|
@@ -1014,12 +936,14 @@ class AuroToast extends i$2 {
|
|
|
1014
936
|
|
|
1015
937
|
render() {
|
|
1016
938
|
return u$2`
|
|
1017
|
-
${
|
|
1018
|
-
|
|
939
|
+
${
|
|
940
|
+
this.visible
|
|
941
|
+
? u$2`
|
|
1019
942
|
<div class="toastContainer">
|
|
1020
|
-
${
|
|
1021
|
-
|
|
1022
|
-
|
|
943
|
+
${
|
|
944
|
+
this.noIcon
|
|
945
|
+
? undefined
|
|
946
|
+
: u$2`
|
|
1023
947
|
<${this.iconTag} customColor customSvg class="typeIcon body-default" part="type-icon">
|
|
1024
948
|
${this.variant === "custom" ? undefined : u$2`${this.getVariantIcon()}`}
|
|
1025
949
|
</${this.iconTag}>
|
|
@@ -1041,7 +965,7 @@ class AuroToast extends i$2 {
|
|
|
1041
965
|
</${this.buttonTag}>
|
|
1042
966
|
</div>
|
|
1043
967
|
`
|
|
1044
|
-
|
|
968
|
+
: undefined
|
|
1045
969
|
}
|
|
1046
970
|
`;
|
|
1047
971
|
}
|
package/demo/index.min.js
CHANGED
|
@@ -289,8 +289,7 @@ const FADE_OUT_DURATION = 300;
|
|
|
289
289
|
*
|
|
290
290
|
* @csspart type-icon - Apply css to the toast type icon
|
|
291
291
|
* @csspart close-button - Apply css to the toast close button
|
|
292
|
-
* @fires onToastClose -
|
|
293
|
-
* @event toast-close - Notifies that the toast has been closed. `detail` is `{ visible: false }`.
|
|
292
|
+
* @fires onToastClose - Notifies that the toast has been closed
|
|
294
293
|
*/
|
|
295
294
|
|
|
296
295
|
// build the component class
|
|
@@ -376,11 +375,6 @@ class AuroToast extends i$2 {
|
|
|
376
375
|
*/
|
|
377
376
|
this.fadeOutTimer = undefined;
|
|
378
377
|
|
|
379
|
-
/**
|
|
380
|
-
* @private
|
|
381
|
-
*/
|
|
382
|
-
this.fadeOutCompleteTimer = undefined;
|
|
383
|
-
|
|
384
378
|
/**
|
|
385
379
|
* True when the toast is not inside an auro-toaster and must manage its
|
|
386
380
|
* own live region announcement. Set once in connectedCallback.
|
|
@@ -403,7 +397,6 @@ class AuroToast extends i$2 {
|
|
|
403
397
|
disableAutoHide: {
|
|
404
398
|
type: Boolean,
|
|
405
399
|
reflect: true,
|
|
406
|
-
attribute: "disableautohide",
|
|
407
400
|
},
|
|
408
401
|
|
|
409
402
|
/**
|
|
@@ -412,7 +405,6 @@ class AuroToast extends i$2 {
|
|
|
412
405
|
noIcon: {
|
|
413
406
|
type: Boolean,
|
|
414
407
|
reflect: true,
|
|
415
|
-
attribute: "noicon",
|
|
416
408
|
},
|
|
417
409
|
|
|
418
410
|
/**
|
|
@@ -421,7 +413,6 @@ class AuroToast extends i$2 {
|
|
|
421
413
|
timeTilHide: {
|
|
422
414
|
type: Number,
|
|
423
415
|
reflect: true,
|
|
424
|
-
attribute: "timetilhide",
|
|
425
416
|
},
|
|
426
417
|
|
|
427
418
|
/**
|
|
@@ -508,6 +499,7 @@ class AuroToast extends i$2 {
|
|
|
508
499
|
clickToClose() {
|
|
509
500
|
this._returnFocus();
|
|
510
501
|
this.closeToast();
|
|
502
|
+
clearTimeout(this.fadeOutTimer);
|
|
511
503
|
}
|
|
512
504
|
|
|
513
505
|
/**
|
|
@@ -515,37 +507,16 @@ class AuroToast extends i$2 {
|
|
|
515
507
|
* @returns {void}
|
|
516
508
|
*/
|
|
517
509
|
fadeOutToast() {
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
return;
|
|
524
|
-
}
|
|
510
|
+
if (!this.disableAutoHide) {
|
|
511
|
+
const toastContainer = this.shadowRoot.querySelector(".toastContainer");
|
|
512
|
+
if (toastContainer) {
|
|
513
|
+
toastContainer.classList.add("hidden");
|
|
514
|
+
}
|
|
525
515
|
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
516
|
+
setTimeout(() => {
|
|
517
|
+
this.closeToast();
|
|
518
|
+
}, FADE_OUT_DURATION);
|
|
529
519
|
}
|
|
530
|
-
|
|
531
|
-
clearTimeout(this.fadeOutCompleteTimer);
|
|
532
|
-
this.fadeOutCompleteTimer = setTimeout(() => {
|
|
533
|
-
this.closeToast();
|
|
534
|
-
}, FADE_OUT_DURATION);
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
/**
|
|
538
|
-
* Cancels an in-progress fade-out, if any, and restores the toast's
|
|
539
|
-
* visibility. Without this, interrupting a fade (e.g. escalating to
|
|
540
|
-
* variant="error" mid-fade) would clear the pending close but leave the
|
|
541
|
-
* "hidden" CSS class in place, permanently hiding a toast that remains
|
|
542
|
-
* open.
|
|
543
|
-
* @private
|
|
544
|
-
* @returns {void}
|
|
545
|
-
*/
|
|
546
|
-
_cancelFadeOut() {
|
|
547
|
-
clearTimeout(this.fadeOutCompleteTimer);
|
|
548
|
-
this.shadowRoot?.querySelector(".toastContainer")?.classList.remove("hidden");
|
|
549
520
|
}
|
|
550
521
|
|
|
551
522
|
/**
|
|
@@ -554,42 +525,20 @@ class AuroToast extends i$2 {
|
|
|
554
525
|
*/
|
|
555
526
|
closeToast() {
|
|
556
527
|
clearTimeout(this.fadeOutTimer);
|
|
557
|
-
clearTimeout(this.fadeOutCompleteTimer);
|
|
558
|
-
|
|
559
|
-
// Idempotent: a close already in flight (e.g. the close button clicked
|
|
560
|
-
// while the auto-hide fade-out is in progress) must not dispatch twice.
|
|
561
|
-
if (!this.visible) {
|
|
562
|
-
return;
|
|
563
|
-
}
|
|
564
|
-
|
|
565
528
|
this.visible = false;
|
|
566
529
|
|
|
567
530
|
/**
|
|
568
531
|
* Emits closed toast event.
|
|
569
532
|
*
|
|
570
|
-
* @deprecated Use `toast-close` event instead.
|
|
571
533
|
* @event onToastClose
|
|
572
|
-
* @type {
|
|
534
|
+
* @type {object}
|
|
535
|
+
* @property {boolean} false - Sets visibility value for the toast element.
|
|
573
536
|
*/
|
|
574
537
|
this.dispatchEvent(
|
|
575
538
|
new CustomEvent("onToastClose", {
|
|
576
539
|
bubbles: true,
|
|
577
540
|
composed: true,
|
|
578
|
-
detail: this,
|
|
579
|
-
}),
|
|
580
|
-
);
|
|
581
|
-
|
|
582
|
-
/**
|
|
583
|
-
* Emits closed toast event.
|
|
584
|
-
*
|
|
585
|
-
* @event toast-close
|
|
586
|
-
* @type {{ visible: boolean }}
|
|
587
|
-
*/
|
|
588
|
-
this.dispatchEvent(
|
|
589
|
-
new CustomEvent("toast-close", {
|
|
590
|
-
bubbles: true,
|
|
591
|
-
composed: true,
|
|
592
|
-
detail: { visible: false },
|
|
541
|
+
detail: this,
|
|
593
542
|
}),
|
|
594
543
|
);
|
|
595
544
|
}
|
|
@@ -627,14 +576,6 @@ class AuroToast extends i$2 {
|
|
|
627
576
|
super.connectedCallback();
|
|
628
577
|
this.setOnClick();
|
|
629
578
|
|
|
630
|
-
// On a reconnect (hasUpdated is false on the initial connection, which
|
|
631
|
-
// Lit's own first-update cycle already handles), force updated() to
|
|
632
|
-
// re-run so a visible toast's auto-hide timer — cleared by
|
|
633
|
-
// disconnectedCallback() — gets re-armed instead of being lost forever.
|
|
634
|
-
if (this.hasUpdated && this.visible) {
|
|
635
|
-
this.requestUpdate();
|
|
636
|
-
}
|
|
637
|
-
|
|
638
579
|
// Dispatch a cancelable event so auro-toaster can signal it will handle
|
|
639
580
|
// announcements. If nothing cancels the event the toast is standalone and
|
|
640
581
|
// must register its own live region on the host element — before
|
|
@@ -663,12 +604,6 @@ class AuroToast extends i$2 {
|
|
|
663
604
|
this._syncStandaloneRole();
|
|
664
605
|
}
|
|
665
606
|
|
|
666
|
-
disconnectedCallback() {
|
|
667
|
-
super.disconnectedCallback();
|
|
668
|
-
clearTimeout(this.fadeOutTimer);
|
|
669
|
-
clearTimeout(this.fadeOutCompleteTimer);
|
|
670
|
-
}
|
|
671
|
-
|
|
672
607
|
/**
|
|
673
608
|
* Sets or removes the live-region role on the host depending on whether
|
|
674
609
|
* the toast is standalone. Extracted so connectedCallback and updated()
|
|
@@ -718,20 +653,7 @@ class AuroToast extends i$2 {
|
|
|
718
653
|
this._syncStandaloneRole();
|
|
719
654
|
}
|
|
720
655
|
|
|
721
|
-
// Cancel an in-flight fade-out when the toast becomes ineligible for
|
|
722
|
-
// auto-dismiss (escalated to variant="error", or disableAutoHide set) —
|
|
723
|
-
// a stale completion timer must not auto-close a now-persistent toast.
|
|
724
|
-
if (
|
|
725
|
-
(changedProperties.has("variant") || changedProperties.has("disableAutoHide")) &&
|
|
726
|
-
(this.variant === "error" || this.disableAutoHide)
|
|
727
|
-
) {
|
|
728
|
-
this._cancelFadeOut();
|
|
729
|
-
}
|
|
730
|
-
|
|
731
656
|
// do not auto dismiss for error toasts or if disableAutoHide is set
|
|
732
|
-
// Note: intentionally does not clear fadeOutCompleteTimer — this block
|
|
733
|
-
// re-runs on every update while visible, and clearing it here would
|
|
734
|
-
// cancel an in-flight fade-out on any unrelated property change.
|
|
735
657
|
if (this.visible && !this.disableAutoHide && this.variant !== "error") {
|
|
736
658
|
clearTimeout(this.fadeOutTimer);
|
|
737
659
|
this.fadeOutTimer = setTimeout(() => {
|
|
@@ -765,12 +687,14 @@ class AuroToast extends i$2 {
|
|
|
765
687
|
|
|
766
688
|
render() {
|
|
767
689
|
return u$2`
|
|
768
|
-
${
|
|
769
|
-
|
|
690
|
+
${
|
|
691
|
+
this.visible
|
|
692
|
+
? u$2`
|
|
770
693
|
<div class="toastContainer">
|
|
771
|
-
${
|
|
772
|
-
|
|
773
|
-
|
|
694
|
+
${
|
|
695
|
+
this.noIcon
|
|
696
|
+
? undefined
|
|
697
|
+
: u$2`
|
|
774
698
|
<${this.iconTag} customColor customSvg class="typeIcon body-default" part="type-icon">
|
|
775
699
|
${this.variant === "custom" ? undefined : u$2`${this.getVariantIcon()}`}
|
|
776
700
|
</${this.iconTag}>
|
|
@@ -792,7 +716,7 @@ class AuroToast extends i$2 {
|
|
|
792
716
|
</${this.buttonTag}>
|
|
793
717
|
</div>
|
|
794
718
|
`
|
|
795
|
-
|
|
719
|
+
: undefined
|
|
796
720
|
}
|
|
797
721
|
`;
|
|
798
722
|
}
|