@nectary/components 5.37.8 → 5.38.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/bundle.js +40 -10
- package/field/index.d.ts +3 -0
- package/field/index.js +15 -1
- package/field/types.d.ts +2 -0
- package/package.json +1 -1
- package/toast/index.js +4 -2
- package/toast/types.d.ts +1 -1
- package/toast-manager/index.js +22 -7
package/bundle.js
CHANGED
|
@@ -8028,13 +8028,14 @@ class EmojiPicker extends NectaryElement {
|
|
|
8028
8028
|
}
|
|
8029
8029
|
}
|
|
8030
8030
|
defineCustomElement("sinch-emoji-picker", EmojiPicker);
|
|
8031
|
-
const templateHTML$M = '<style>:host{display:block}#wrapper{display:flex;flex-direction:column;width:100%}#bottom,#top{display:flex;align-items:baseline}#top{height:24px;margin-bottom:2px}#top.empty{display:none}#additional,#invalid,#label,#optional{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#label{font:var(--sinch-comp-field-font-label);color:var(--sinch-comp-field-color-default-label-initial)}#optional{flex:1;font:var(--sinch-comp-field-font-optional);color:var(--sinch-comp-field-color-default-optional-initial);text-align:right}#additional{flex:1;text-align:right;font:var(--sinch-comp-field-font-additional);color:var(--sinch-comp-field-color-default-additional-initial);line-height:20px;margin-top:2px}#additional:empty{display:none}#invalid{font:var(--sinch-comp-field-font-invalid);color:var(--sinch-comp-field-color-invalid-text-initial);line-height:20px;margin-top:2px}#invalid:empty{display:none}#tooltip{align-self:center;margin:0 8px;display:flex}#tooltip.empty{display:none}:host([disabled]) #label{color:var(--sinch-comp-field-color-disabled-label-initial)}:host([disabled]) #additional{color:var(--sinch-comp-field-color-disabled-additional-initial)}:host([disabled]) #optional{color:var(--sinch-comp-field-color-disabled-optional-initial)}</style><div id="wrapper"><div id="top"><label id="label" for="input"></label><div id="tooltip"><slot name="tooltip"></slot></div><span id="optional"></span></div><slot name="input"></slot><div id="bottom"><div id="invalid"></div><div id="additional"></div></div></div>';
|
|
8031
|
+
const templateHTML$M = '<style>:host{display:block}#wrapper{display:flex;flex-direction:column;width:100%}#bottom,#top{display:flex;align-items:baseline}#top{height:24px;margin-bottom:2px}#top.empty{display:none}#additional,#invalid,#label,#optional{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#label{font:var(--sinch-comp-field-font-label);color:var(--sinch-comp-field-color-default-label-initial)}#optional{flex:1;font:var(--sinch-comp-field-font-optional);color:var(--sinch-comp-field-color-default-optional-initial);text-align:right;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#optional:empty{display:none}#additional{flex:1;text-align:right;font:var(--sinch-comp-field-font-additional);color:var(--sinch-comp-field-color-default-additional-initial);line-height:20px;margin-top:2px}#additional:empty{display:none}#invalid{font:var(--sinch-comp-field-font-invalid);color:var(--sinch-comp-field-color-invalid-text-initial);line-height:20px;margin-top:2px}#invalid:empty{display:none}#tooltip{align-self:center;margin:0 8px;display:flex}#tooltip.empty{display:none}:host([disabled]) #label{color:var(--sinch-comp-field-color-disabled-label-initial)}:host([disabled]) #additional{color:var(--sinch-comp-field-color-disabled-additional-initial)}:host([disabled]) #optional{color:var(--sinch-comp-field-color-disabled-optional-initial)}</style><div id="wrapper"><div id="top"><label id="label" for="input"></label><div id="tooltip"><slot name="tooltip"></slot></div><sinch-tooltip id="optional-tooltip" allow-scroll><span id="optional"></span></sinch-tooltip></div><slot name="input"></slot><div id="bottom"><div id="invalid"></div><div id="additional"></div></div></div>';
|
|
8032
8032
|
const template$M = document.createElement("template");
|
|
8033
8033
|
template$M.innerHTML = templateHTML$M;
|
|
8034
8034
|
class Field extends NectaryElement {
|
|
8035
8035
|
topSection;
|
|
8036
8036
|
#$label;
|
|
8037
8037
|
#$optionalText;
|
|
8038
|
+
#$optionalTooltip;
|
|
8038
8039
|
#$additionalText;
|
|
8039
8040
|
#$invalidText;
|
|
8040
8041
|
#$inputSlot;
|
|
@@ -8048,6 +8049,7 @@ class Field extends NectaryElement {
|
|
|
8048
8049
|
this.topSection = shadowRoot.querySelector("#top");
|
|
8049
8050
|
this.#$label = shadowRoot.querySelector("#label");
|
|
8050
8051
|
this.#$optionalText = shadowRoot.querySelector("#optional");
|
|
8052
|
+
this.#$optionalTooltip = shadowRoot.querySelector("#optional-tooltip");
|
|
8051
8053
|
this.#$additionalText = shadowRoot.querySelector("#additional");
|
|
8052
8054
|
this.#$invalidText = shadowRoot.querySelector("#invalid");
|
|
8053
8055
|
this.#$inputSlot = shadowRoot.querySelector('slot[name="input"]');
|
|
@@ -8071,6 +8073,7 @@ class Field extends NectaryElement {
|
|
|
8071
8073
|
return [
|
|
8072
8074
|
"label",
|
|
8073
8075
|
"optionaltext",
|
|
8076
|
+
"optionaltooltip",
|
|
8074
8077
|
"additionaltext",
|
|
8075
8078
|
"invalidtext",
|
|
8076
8079
|
"disabled"
|
|
@@ -8091,6 +8094,10 @@ class Field extends NectaryElement {
|
|
|
8091
8094
|
this.#$optionalText.textContent = newVal;
|
|
8092
8095
|
break;
|
|
8093
8096
|
}
|
|
8097
|
+
case "optionaltooltip": {
|
|
8098
|
+
updateAttribute(this.#$optionalTooltip, "text", newVal);
|
|
8099
|
+
break;
|
|
8100
|
+
}
|
|
8094
8101
|
case "additionaltext": {
|
|
8095
8102
|
this.#$additionalText.textContent = newVal;
|
|
8096
8103
|
break;
|
|
@@ -8121,6 +8128,12 @@ class Field extends NectaryElement {
|
|
|
8121
8128
|
get optionalText() {
|
|
8122
8129
|
return getAttribute(this, "optionaltext");
|
|
8123
8130
|
}
|
|
8131
|
+
set optionalTooltip(value) {
|
|
8132
|
+
updateAttribute(this, "optionaltooltip", value);
|
|
8133
|
+
}
|
|
8134
|
+
get optionalTooltip() {
|
|
8135
|
+
return getAttribute(this, "optionaltooltip");
|
|
8136
|
+
}
|
|
8124
8137
|
set additionalText(value) {
|
|
8125
8138
|
updateAttribute(this, "additionaltext", value);
|
|
8126
8139
|
}
|
|
@@ -15880,7 +15893,7 @@ class Toast extends NectaryElement {
|
|
|
15880
15893
|
this.#clearTimeout();
|
|
15881
15894
|
}
|
|
15882
15895
|
static get observedAttributes() {
|
|
15883
|
-
return ["text", "persistent"];
|
|
15896
|
+
return ["text", "type", "persistent"];
|
|
15884
15897
|
}
|
|
15885
15898
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
15886
15899
|
switch (name) {
|
|
@@ -15888,6 +15901,7 @@ class Toast extends NectaryElement {
|
|
|
15888
15901
|
updateAttribute(this.#$text, name, newVal);
|
|
15889
15902
|
break;
|
|
15890
15903
|
}
|
|
15904
|
+
case "type":
|
|
15891
15905
|
case "persistent": {
|
|
15892
15906
|
this.#updateTimeout();
|
|
15893
15907
|
break;
|
|
@@ -15913,7 +15927,8 @@ class Toast extends NectaryElement {
|
|
|
15913
15927
|
updateBooleanAttribute(this, "persistent", isPersistent);
|
|
15914
15928
|
}
|
|
15915
15929
|
#updateTimeout() {
|
|
15916
|
-
|
|
15930
|
+
const type = getAttribute(this, "type");
|
|
15931
|
+
if (this.persistent || type === "error" || type === "warn") {
|
|
15917
15932
|
this.#clearTimeout();
|
|
15918
15933
|
return;
|
|
15919
15934
|
}
|
|
@@ -15937,7 +15952,7 @@ class Toast extends NectaryElement {
|
|
|
15937
15952
|
}
|
|
15938
15953
|
defineCustomElement("sinch-toast", Toast);
|
|
15939
15954
|
const originValues = ["bottom-right", "top-right"];
|
|
15940
|
-
const templateHTML$1 = '<style>:host{display:block}#items{display:block;width:0;height:0;visibility:hidden;overflow:hidden}#list{display:flex;flex-direction:column;position:fixed;z-index:1;bottom:0;right:16px}:host([origin=top-right]) #list{flex-direction:column-reverse;bottom:unset;top:16px}.item-wrapper{height:0;opacity:0;position:relative}.item-wrapper[data-deleting]::after{content:"";position:absolute;top:0;left:0;bottom:0;right:0}</style><slot id="items"></slot><div id="list" aria-live="polite"></div>';
|
|
15955
|
+
const templateHTML$1 = '<style>:host{display:block}#items{display:block;width:0;height:0;visibility:hidden;overflow:hidden}#list{display:flex;flex-direction:column;position:fixed;z-index:1;bottom:0;right:16px}:host([origin=top-right]) #list{flex-direction:column-reverse;bottom:unset;top:16px}.item-wrapper{height:0;opacity:0;position:relative}.item-wrapper[data-deleting]::after{content:"";position:absolute;top:0;left:0;bottom:0;right:0}</style><slot id="items"></slot><div id="list" role="status" aria-live="polite" aria-atomic="false"></div>';
|
|
15941
15956
|
const DURATION_ADD = 250;
|
|
15942
15957
|
const DURATION_REMOVE = 250;
|
|
15943
15958
|
const ITEMS_GAP = 16;
|
|
@@ -16048,6 +16063,27 @@ class ToastManager extends NectaryElement {
|
|
|
16048
16063
|
this.#onAnimateRemove(item, removeIndex);
|
|
16049
16064
|
++removeIndex;
|
|
16050
16065
|
}
|
|
16066
|
+
let hasNewItems = false;
|
|
16067
|
+
let isAssertive = false;
|
|
16068
|
+
for (const item of slotItems) {
|
|
16069
|
+
if (this.#map.has(item)) {
|
|
16070
|
+
continue;
|
|
16071
|
+
}
|
|
16072
|
+
hasNewItems = true;
|
|
16073
|
+
if (item instanceof Toast) {
|
|
16074
|
+
const type = item.type;
|
|
16075
|
+
if (type === "error" || type === "warn") {
|
|
16076
|
+
isAssertive = true;
|
|
16077
|
+
}
|
|
16078
|
+
}
|
|
16079
|
+
}
|
|
16080
|
+
if (slotItems.length === 0) {
|
|
16081
|
+
this.#$list.setAttribute("role", "status");
|
|
16082
|
+
this.#$list.setAttribute("aria-live", "polite");
|
|
16083
|
+
} else if (hasNewItems) {
|
|
16084
|
+
this.#$list.setAttribute("role", isAssertive ? "alert" : "status");
|
|
16085
|
+
this.#$list.setAttribute("aria-live", isAssertive ? "assertive" : "polite");
|
|
16086
|
+
}
|
|
16051
16087
|
let addIndex = 0;
|
|
16052
16088
|
for (const item of slotItems) {
|
|
16053
16089
|
if (this.#map.has(item)) {
|
|
@@ -16056,12 +16092,6 @@ class ToastManager extends NectaryElement {
|
|
|
16056
16092
|
const cloned = cloneNode(item, true);
|
|
16057
16093
|
const rect = item.getBoundingClientRect();
|
|
16058
16094
|
const wrapper = document.createElement("div");
|
|
16059
|
-
if (item instanceof Toast) {
|
|
16060
|
-
if (item.hasAttribute("type")) {
|
|
16061
|
-
const type = item.type;
|
|
16062
|
-
this.#$list.setAttribute("aria-live", type === "error" || type === "warn" ? "assertive" : "polite");
|
|
16063
|
-
}
|
|
16064
|
-
}
|
|
16065
16095
|
wrapper.className = "item-wrapper";
|
|
16066
16096
|
wrapper.appendChild(cloned);
|
|
16067
16097
|
this.#$list.appendChild(wrapper);
|
package/field/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import '../tooltip';
|
|
1
2
|
import { NectaryElement } from '../utils';
|
|
2
3
|
export * from './types';
|
|
3
4
|
export declare class Field extends NectaryElement {
|
|
@@ -13,6 +14,8 @@ export declare class Field extends NectaryElement {
|
|
|
13
14
|
get label(): string | null;
|
|
14
15
|
set optionalText(value: string | null);
|
|
15
16
|
get optionalText(): string | null;
|
|
17
|
+
set optionalTooltip(value: string | null);
|
|
18
|
+
get optionalTooltip(): string | null;
|
|
16
19
|
set additionalText(value: string | null);
|
|
17
20
|
get additionalText(): string | null;
|
|
18
21
|
set invalidText(value: string | null);
|
package/field/index.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
import "../tooltip/index.js";
|
|
1
2
|
import { getAttribute, setClass, isAttrEqual, updateBooleanAttribute, isAttrTrue, updateAttribute, getBooleanAttribute } from "../utils/dom.js";
|
|
2
3
|
import { defineCustomElement, NectaryElement } from "../utils/element.js";
|
|
3
4
|
import { getFirstSlotElement } from "../utils/slot.js";
|
|
4
|
-
const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:column;width:100%}#bottom,#top{display:flex;align-items:baseline}#top{height:24px;margin-bottom:2px}#top.empty{display:none}#additional,#invalid,#label,#optional{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#label{font:var(--sinch-comp-field-font-label);color:var(--sinch-comp-field-color-default-label-initial)}#optional{flex:1;font:var(--sinch-comp-field-font-optional);color:var(--sinch-comp-field-color-default-optional-initial);text-align:right}#additional{flex:1;text-align:right;font:var(--sinch-comp-field-font-additional);color:var(--sinch-comp-field-color-default-additional-initial);line-height:20px;margin-top:2px}#additional:empty{display:none}#invalid{font:var(--sinch-comp-field-font-invalid);color:var(--sinch-comp-field-color-invalid-text-initial);line-height:20px;margin-top:2px}#invalid:empty{display:none}#tooltip{align-self:center;margin:0 8px;display:flex}#tooltip.empty{display:none}:host([disabled]) #label{color:var(--sinch-comp-field-color-disabled-label-initial)}:host([disabled]) #additional{color:var(--sinch-comp-field-color-disabled-additional-initial)}:host([disabled]) #optional{color:var(--sinch-comp-field-color-disabled-optional-initial)}</style><div id="wrapper"><div id="top"><label id="label" for="input"></label><div id="tooltip"><slot name="tooltip"></slot></div><span id="optional"></span></div><slot name="input"></slot><div id="bottom"><div id="invalid"></div><div id="additional"></div></div></div>';
|
|
5
|
+
const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:column;width:100%}#bottom,#top{display:flex;align-items:baseline}#top{height:24px;margin-bottom:2px}#top.empty{display:none}#additional,#invalid,#label,#optional{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#label{font:var(--sinch-comp-field-font-label);color:var(--sinch-comp-field-color-default-label-initial)}#optional{flex:1;font:var(--sinch-comp-field-font-optional);color:var(--sinch-comp-field-color-default-optional-initial);text-align:right;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#optional:empty{display:none}#additional{flex:1;text-align:right;font:var(--sinch-comp-field-font-additional);color:var(--sinch-comp-field-color-default-additional-initial);line-height:20px;margin-top:2px}#additional:empty{display:none}#invalid{font:var(--sinch-comp-field-font-invalid);color:var(--sinch-comp-field-color-invalid-text-initial);line-height:20px;margin-top:2px}#invalid:empty{display:none}#tooltip{align-self:center;margin:0 8px;display:flex}#tooltip.empty{display:none}:host([disabled]) #label{color:var(--sinch-comp-field-color-disabled-label-initial)}:host([disabled]) #additional{color:var(--sinch-comp-field-color-disabled-additional-initial)}:host([disabled]) #optional{color:var(--sinch-comp-field-color-disabled-optional-initial)}</style><div id="wrapper"><div id="top"><label id="label" for="input"></label><div id="tooltip"><slot name="tooltip"></slot></div><sinch-tooltip id="optional-tooltip" allow-scroll><span id="optional"></span></sinch-tooltip></div><slot name="input"></slot><div id="bottom"><div id="invalid"></div><div id="additional"></div></div></div>';
|
|
5
6
|
const template = document.createElement("template");
|
|
6
7
|
template.innerHTML = templateHTML;
|
|
7
8
|
class Field extends NectaryElement {
|
|
8
9
|
topSection;
|
|
9
10
|
#$label;
|
|
10
11
|
#$optionalText;
|
|
12
|
+
#$optionalTooltip;
|
|
11
13
|
#$additionalText;
|
|
12
14
|
#$invalidText;
|
|
13
15
|
#$inputSlot;
|
|
@@ -21,6 +23,7 @@ class Field extends NectaryElement {
|
|
|
21
23
|
this.topSection = shadowRoot.querySelector("#top");
|
|
22
24
|
this.#$label = shadowRoot.querySelector("#label");
|
|
23
25
|
this.#$optionalText = shadowRoot.querySelector("#optional");
|
|
26
|
+
this.#$optionalTooltip = shadowRoot.querySelector("#optional-tooltip");
|
|
24
27
|
this.#$additionalText = shadowRoot.querySelector("#additional");
|
|
25
28
|
this.#$invalidText = shadowRoot.querySelector("#invalid");
|
|
26
29
|
this.#$inputSlot = shadowRoot.querySelector('slot[name="input"]');
|
|
@@ -44,6 +47,7 @@ class Field extends NectaryElement {
|
|
|
44
47
|
return [
|
|
45
48
|
"label",
|
|
46
49
|
"optionaltext",
|
|
50
|
+
"optionaltooltip",
|
|
47
51
|
"additionaltext",
|
|
48
52
|
"invalidtext",
|
|
49
53
|
"disabled"
|
|
@@ -64,6 +68,10 @@ class Field extends NectaryElement {
|
|
|
64
68
|
this.#$optionalText.textContent = newVal;
|
|
65
69
|
break;
|
|
66
70
|
}
|
|
71
|
+
case "optionaltooltip": {
|
|
72
|
+
updateAttribute(this.#$optionalTooltip, "text", newVal);
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
67
75
|
case "additionaltext": {
|
|
68
76
|
this.#$additionalText.textContent = newVal;
|
|
69
77
|
break;
|
|
@@ -94,6 +102,12 @@ class Field extends NectaryElement {
|
|
|
94
102
|
get optionalText() {
|
|
95
103
|
return getAttribute(this, "optionaltext");
|
|
96
104
|
}
|
|
105
|
+
set optionalTooltip(value) {
|
|
106
|
+
updateAttribute(this, "optionaltooltip", value);
|
|
107
|
+
}
|
|
108
|
+
get optionalTooltip() {
|
|
109
|
+
return getAttribute(this, "optionaltooltip");
|
|
110
|
+
}
|
|
97
111
|
set additionalText(value) {
|
|
98
112
|
updateAttribute(this, "additionaltext", value);
|
|
99
113
|
}
|
package/field/types.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ export type TSinchFieldProps = {
|
|
|
4
4
|
label?: string;
|
|
5
5
|
/** Optional text */
|
|
6
6
|
optionalText?: string;
|
|
7
|
+
/** Tooltip text for optional text */
|
|
8
|
+
optionalTooltip?: string;
|
|
7
9
|
/** Additional text */
|
|
8
10
|
additionalText?: string;
|
|
9
11
|
/** Invalid text, controls the overall invalid state of the text field */
|
package/package.json
CHANGED
package/toast/index.js
CHANGED
|
@@ -29,7 +29,7 @@ class Toast extends NectaryElement {
|
|
|
29
29
|
this.#clearTimeout();
|
|
30
30
|
}
|
|
31
31
|
static get observedAttributes() {
|
|
32
|
-
return ["text", "persistent"];
|
|
32
|
+
return ["text", "type", "persistent"];
|
|
33
33
|
}
|
|
34
34
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
35
35
|
switch (name) {
|
|
@@ -37,6 +37,7 @@ class Toast extends NectaryElement {
|
|
|
37
37
|
updateAttribute(this.#$text, name, newVal);
|
|
38
38
|
break;
|
|
39
39
|
}
|
|
40
|
+
case "type":
|
|
40
41
|
case "persistent": {
|
|
41
42
|
this.#updateTimeout();
|
|
42
43
|
break;
|
|
@@ -62,7 +63,8 @@ class Toast extends NectaryElement {
|
|
|
62
63
|
updateBooleanAttribute(this, "persistent", isPersistent);
|
|
63
64
|
}
|
|
64
65
|
#updateTimeout() {
|
|
65
|
-
|
|
66
|
+
const type = getAttribute(this, "type");
|
|
67
|
+
if (this.persistent || type === "error" || type === "warn") {
|
|
66
68
|
this.#clearTimeout();
|
|
67
69
|
return;
|
|
68
70
|
}
|
package/toast/types.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export type TSinchToastProps = {
|
|
|
5
5
|
type: TSinchToastType;
|
|
6
6
|
/** Text */
|
|
7
7
|
text: string;
|
|
8
|
-
/** Persistent, i.e. doesn't automatically
|
|
8
|
+
/** Persistent, i.e. doesn't automatically disappear after 5s. Error and warn toasts are always persistent. */
|
|
9
9
|
persistent?: boolean;
|
|
10
10
|
};
|
|
11
11
|
export type TSinchToastEvents = {
|
package/toast-manager/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { shouldReduceMotion, getLiteralAttribute, updateLiteralAttribute, cloneN
|
|
|
5
5
|
import { defineCustomElement, NectaryElement } from "../utils/element.js";
|
|
6
6
|
import { getRect } from "../utils/rect.js";
|
|
7
7
|
import { originValues } from "./utils.js";
|
|
8
|
-
const templateHTML = '<style>:host{display:block}#items{display:block;width:0;height:0;visibility:hidden;overflow:hidden}#list{display:flex;flex-direction:column;position:fixed;z-index:1;bottom:0;right:16px}:host([origin=top-right]) #list{flex-direction:column-reverse;bottom:unset;top:16px}.item-wrapper{height:0;opacity:0;position:relative}.item-wrapper[data-deleting]::after{content:"";position:absolute;top:0;left:0;bottom:0;right:0}</style><slot id="items"></slot><div id="list" aria-live="polite"></div>';
|
|
8
|
+
const templateHTML = '<style>:host{display:block}#items{display:block;width:0;height:0;visibility:hidden;overflow:hidden}#list{display:flex;flex-direction:column;position:fixed;z-index:1;bottom:0;right:16px}:host([origin=top-right]) #list{flex-direction:column-reverse;bottom:unset;top:16px}.item-wrapper{height:0;opacity:0;position:relative}.item-wrapper[data-deleting]::after{content:"";position:absolute;top:0;left:0;bottom:0;right:0}</style><slot id="items"></slot><div id="list" role="status" aria-live="polite" aria-atomic="false"></div>';
|
|
9
9
|
const DURATION_ADD = 250;
|
|
10
10
|
const DURATION_REMOVE = 250;
|
|
11
11
|
const ITEMS_GAP = 16;
|
|
@@ -116,6 +116,27 @@ class ToastManager extends NectaryElement {
|
|
|
116
116
|
this.#onAnimateRemove(item, removeIndex);
|
|
117
117
|
++removeIndex;
|
|
118
118
|
}
|
|
119
|
+
let hasNewItems = false;
|
|
120
|
+
let isAssertive = false;
|
|
121
|
+
for (const item of slotItems) {
|
|
122
|
+
if (this.#map.has(item)) {
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
hasNewItems = true;
|
|
126
|
+
if (item instanceof Toast) {
|
|
127
|
+
const type = item.type;
|
|
128
|
+
if (type === "error" || type === "warn") {
|
|
129
|
+
isAssertive = true;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
if (slotItems.length === 0) {
|
|
134
|
+
this.#$list.setAttribute("role", "status");
|
|
135
|
+
this.#$list.setAttribute("aria-live", "polite");
|
|
136
|
+
} else if (hasNewItems) {
|
|
137
|
+
this.#$list.setAttribute("role", isAssertive ? "alert" : "status");
|
|
138
|
+
this.#$list.setAttribute("aria-live", isAssertive ? "assertive" : "polite");
|
|
139
|
+
}
|
|
119
140
|
let addIndex = 0;
|
|
120
141
|
for (const item of slotItems) {
|
|
121
142
|
if (this.#map.has(item)) {
|
|
@@ -124,12 +145,6 @@ class ToastManager extends NectaryElement {
|
|
|
124
145
|
const cloned = cloneNode(item, true);
|
|
125
146
|
const rect = item.getBoundingClientRect();
|
|
126
147
|
const wrapper = document.createElement("div");
|
|
127
|
-
if (item instanceof Toast) {
|
|
128
|
-
if (item.hasAttribute("type")) {
|
|
129
|
-
const type = item.type;
|
|
130
|
-
this.#$list.setAttribute("aria-live", type === "error" || type === "warn" ? "assertive" : "polite");
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
148
|
wrapper.className = "item-wrapper";
|
|
134
149
|
wrapper.appendChild(cloned);
|
|
135
150
|
this.#$list.appendChild(wrapper);
|