@nectary/components 5.0.0 → 5.0.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 +37 -1
- package/checkbox/index.js +2 -0
- package/chip/index.js +3 -1
- package/package.json +2 -2
- package/popover/index.js +30 -0
- package/progress/index.js +1 -0
- package/select-menu-option/index.js +1 -0
- package/utils/element.js +1 -1
package/bundle.js
CHANGED
|
@@ -141,7 +141,7 @@ class NectaryElementBase extends HTMLElement {
|
|
|
141
141
|
this._isGlobal = value;
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
|
-
const version = "5.0.
|
|
144
|
+
const version = "5.0.1";
|
|
145
145
|
const pkg = {
|
|
146
146
|
version
|
|
147
147
|
};
|
|
@@ -2476,6 +2476,8 @@ class Checkbox extends NectaryElement {
|
|
|
2476
2476
|
switch (name) {
|
|
2477
2477
|
case "text": {
|
|
2478
2478
|
updateAttribute(this.#$label, "text", newVal);
|
|
2479
|
+
updateAttribute(this.#$label, "aria-label", newVal);
|
|
2480
|
+
updateAttribute(this, "aria-label", newVal);
|
|
2479
2481
|
break;
|
|
2480
2482
|
}
|
|
2481
2483
|
case "checked": {
|
|
@@ -2628,6 +2630,8 @@ class Chip extends NectaryElement {
|
|
|
2628
2630
|
}
|
|
2629
2631
|
case "text": {
|
|
2630
2632
|
this.#$text.textContent = newVal;
|
|
2633
|
+
updateAttribute(this, "aria-label", newVal);
|
|
2634
|
+
updateAttribute(this.#$button, "aria-label", `Delete ${newVal}`);
|
|
2631
2635
|
break;
|
|
2632
2636
|
}
|
|
2633
2637
|
case "small": {
|
|
@@ -5726,6 +5730,8 @@ class Popover extends NectaryElement {
|
|
|
5726
5730
|
#$tip;
|
|
5727
5731
|
#controller = null;
|
|
5728
5732
|
#resizeObserver = null;
|
|
5733
|
+
#$targetSlot;
|
|
5734
|
+
#$contentSlot;
|
|
5729
5735
|
constructor() {
|
|
5730
5736
|
super();
|
|
5731
5737
|
const shadowRoot = this.attachShadow();
|
|
@@ -5733,6 +5739,8 @@ class Popover extends NectaryElement {
|
|
|
5733
5739
|
this.#$pop = shadowRoot.querySelector("#pop");
|
|
5734
5740
|
this.#$content = shadowRoot.querySelector("#content");
|
|
5735
5741
|
this.#$tip = shadowRoot.querySelector("#tip");
|
|
5742
|
+
this.#$targetSlot = shadowRoot.querySelector('slot[name="target"]');
|
|
5743
|
+
this.#$contentSlot = shadowRoot.querySelector('slot[name="content"]');
|
|
5736
5744
|
}
|
|
5737
5745
|
connectedCallback() {
|
|
5738
5746
|
this.#controller = new AbortController();
|
|
@@ -5741,6 +5749,18 @@ class Popover extends NectaryElement {
|
|
|
5741
5749
|
this.#$pop.addEventListener("-close", this.#onPopClose, { signal });
|
|
5742
5750
|
subscribeContext(this.#$content, "visibility", this.#onContextVisibility, signal);
|
|
5743
5751
|
updateAttribute(this.#$pop, "orientation", getPopOrientation(this.orientation));
|
|
5752
|
+
const slottedTarget = this.#getFirstAssignedElementInSlot(this.#$targetSlot);
|
|
5753
|
+
const slottedContent = this.#getFirstAssignedElementInSlot(this.#$contentSlot);
|
|
5754
|
+
const popoverIdReference = `popover-${(/* @__PURE__ */ new Date()).getMilliseconds()}-${Math.round(100 * Math.random())}`;
|
|
5755
|
+
if (slottedContent != null && slottedTarget != null) {
|
|
5756
|
+
updateAttribute(slottedContent, "aria-lablledby", popoverIdReference);
|
|
5757
|
+
}
|
|
5758
|
+
if (slottedTarget != null) {
|
|
5759
|
+
updateAttribute(slottedTarget, "aria-controls", popoverIdReference);
|
|
5760
|
+
updateAttribute(slottedTarget, "aria-haspopup", true);
|
|
5761
|
+
const isOpen = this.getAttribute("open") ?? false;
|
|
5762
|
+
updateAttribute(slottedTarget, "aria-expanded", isOpen);
|
|
5763
|
+
}
|
|
5744
5764
|
this.#resizeObserver = new ResizeObserver(() => {
|
|
5745
5765
|
if (this.#$pop.open) {
|
|
5746
5766
|
this.#updateContentMaxWidth();
|
|
@@ -5788,6 +5808,10 @@ class Popover extends NectaryElement {
|
|
|
5788
5808
|
case "open": {
|
|
5789
5809
|
updateAttribute(this.#$pop, name, newVal);
|
|
5790
5810
|
updateBooleanAttribute(this, name, isAttrTrue(newVal));
|
|
5811
|
+
const slottedContent = this.#getFirstAssignedElementInSlot(this.#$targetSlot);
|
|
5812
|
+
if (slottedContent != null) {
|
|
5813
|
+
updateAttribute(slottedContent, "aria-expanded", isAttrTrue(newVal));
|
|
5814
|
+
}
|
|
5791
5815
|
break;
|
|
5792
5816
|
}
|
|
5793
5817
|
case "aria-label":
|
|
@@ -5827,6 +5851,16 @@ class Popover extends NectaryElement {
|
|
|
5827
5851
|
get popoverRect() {
|
|
5828
5852
|
return this.#$pop.popoverRect;
|
|
5829
5853
|
}
|
|
5854
|
+
#getFirstAssignedElementInSlot(slot) {
|
|
5855
|
+
if (slot === null) {
|
|
5856
|
+
return null;
|
|
5857
|
+
}
|
|
5858
|
+
const elements = slot != null ? slot.assignedElements() : null;
|
|
5859
|
+
if (elements === null) {
|
|
5860
|
+
return null;
|
|
5861
|
+
}
|
|
5862
|
+
return elements[0];
|
|
5863
|
+
}
|
|
5830
5864
|
#onPopClose = () => {
|
|
5831
5865
|
this.#dispatchCloseEvent();
|
|
5832
5866
|
};
|
|
@@ -7821,6 +7855,7 @@ class Progress extends NectaryElement {
|
|
|
7821
7855
|
this.#$bar.style.width = `${int}%`;
|
|
7822
7856
|
this.#$text.textContent = Intl.NumberFormat(navigator.language, { style: "percent" }).format(int / 100);
|
|
7823
7857
|
this.setAttribute("valuenow", int !== null ? String(int) : "0");
|
|
7858
|
+
this.setAttribute("aria-valuenow", int !== null ? String(int) : "0");
|
|
7824
7859
|
break;
|
|
7825
7860
|
}
|
|
7826
7861
|
case "detailed": {
|
|
@@ -10884,6 +10919,7 @@ class SelectMenuOption extends NectaryElement {
|
|
|
10884
10919
|
}
|
|
10885
10920
|
case "disabled": {
|
|
10886
10921
|
updateBooleanAttribute(this, "disabled", isAttrTrue(newVal));
|
|
10922
|
+
updateExplicitBooleanAttribute(this, "aria-disabled", isAttrTrue(newVal));
|
|
10887
10923
|
break;
|
|
10888
10924
|
}
|
|
10889
10925
|
}
|
package/checkbox/index.js
CHANGED
|
@@ -72,6 +72,8 @@ class Checkbox extends NectaryElement {
|
|
|
72
72
|
switch (name) {
|
|
73
73
|
case "text": {
|
|
74
74
|
updateAttribute(this.#$label, "text", newVal);
|
|
75
|
+
updateAttribute(this.#$label, "aria-label", newVal);
|
|
76
|
+
updateAttribute(this, "aria-label", newVal);
|
|
75
77
|
break;
|
|
76
78
|
}
|
|
77
79
|
case "checked": {
|
package/chip/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "../text/index.js";
|
|
2
2
|
import "../icon/index.js";
|
|
3
|
-
import { isAttrEqual, updateBooleanAttribute, isAttrTrue,
|
|
3
|
+
import { isAttrEqual, updateBooleanAttribute, isAttrTrue, updateAttribute, getAttribute, getBooleanAttribute } from "../utils/dom.js";
|
|
4
4
|
import { defineCustomElement, NectaryElement } from "../utils/element.js";
|
|
5
5
|
import { getReactEventHandler } from "../utils/get-react-event-handler.js";
|
|
6
6
|
import { getChipColorBg, getChipColorFg } from "./utils.js";
|
|
@@ -52,6 +52,8 @@ class Chip extends NectaryElement {
|
|
|
52
52
|
}
|
|
53
53
|
case "text": {
|
|
54
54
|
this.#$text.textContent = newVal;
|
|
55
|
+
updateAttribute(this, "aria-label", newVal);
|
|
56
|
+
updateAttribute(this.#$button, "aria-label", `Delete ${newVal}`);
|
|
55
57
|
break;
|
|
56
58
|
}
|
|
57
59
|
case "small": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nectary/components",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"files": [
|
|
5
5
|
"**/*/*.css",
|
|
6
6
|
"**/*/*.json",
|
|
@@ -40,6 +40,6 @@
|
|
|
40
40
|
"vite": "^7.0.6"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@nectary/theme-base": "
|
|
43
|
+
"@nectary/theme-base": "1.5.0"
|
|
44
44
|
}
|
|
45
45
|
}
|
package/popover/index.js
CHANGED
|
@@ -15,6 +15,8 @@ class Popover extends NectaryElement {
|
|
|
15
15
|
#$tip;
|
|
16
16
|
#controller = null;
|
|
17
17
|
#resizeObserver = null;
|
|
18
|
+
#$targetSlot;
|
|
19
|
+
#$contentSlot;
|
|
18
20
|
constructor() {
|
|
19
21
|
super();
|
|
20
22
|
const shadowRoot = this.attachShadow();
|
|
@@ -22,6 +24,8 @@ class Popover extends NectaryElement {
|
|
|
22
24
|
this.#$pop = shadowRoot.querySelector("#pop");
|
|
23
25
|
this.#$content = shadowRoot.querySelector("#content");
|
|
24
26
|
this.#$tip = shadowRoot.querySelector("#tip");
|
|
27
|
+
this.#$targetSlot = shadowRoot.querySelector('slot[name="target"]');
|
|
28
|
+
this.#$contentSlot = shadowRoot.querySelector('slot[name="content"]');
|
|
25
29
|
}
|
|
26
30
|
connectedCallback() {
|
|
27
31
|
this.#controller = new AbortController();
|
|
@@ -30,6 +34,18 @@ class Popover extends NectaryElement {
|
|
|
30
34
|
this.#$pop.addEventListener("-close", this.#onPopClose, { signal });
|
|
31
35
|
subscribeContext(this.#$content, "visibility", this.#onContextVisibility, signal);
|
|
32
36
|
updateAttribute(this.#$pop, "orientation", getPopOrientation(this.orientation));
|
|
37
|
+
const slottedTarget = this.#getFirstAssignedElementInSlot(this.#$targetSlot);
|
|
38
|
+
const slottedContent = this.#getFirstAssignedElementInSlot(this.#$contentSlot);
|
|
39
|
+
const popoverIdReference = `popover-${(/* @__PURE__ */ new Date()).getMilliseconds()}-${Math.round(100 * Math.random())}`;
|
|
40
|
+
if (slottedContent != null && slottedTarget != null) {
|
|
41
|
+
updateAttribute(slottedContent, "aria-lablledby", popoverIdReference);
|
|
42
|
+
}
|
|
43
|
+
if (slottedTarget != null) {
|
|
44
|
+
updateAttribute(slottedTarget, "aria-controls", popoverIdReference);
|
|
45
|
+
updateAttribute(slottedTarget, "aria-haspopup", true);
|
|
46
|
+
const isOpen = this.getAttribute("open") ?? false;
|
|
47
|
+
updateAttribute(slottedTarget, "aria-expanded", isOpen);
|
|
48
|
+
}
|
|
33
49
|
this.#resizeObserver = new ResizeObserver(() => {
|
|
34
50
|
if (this.#$pop.open) {
|
|
35
51
|
this.#updateContentMaxWidth();
|
|
@@ -77,6 +93,10 @@ class Popover extends NectaryElement {
|
|
|
77
93
|
case "open": {
|
|
78
94
|
updateAttribute(this.#$pop, name, newVal);
|
|
79
95
|
updateBooleanAttribute(this, name, isAttrTrue(newVal));
|
|
96
|
+
const slottedContent = this.#getFirstAssignedElementInSlot(this.#$targetSlot);
|
|
97
|
+
if (slottedContent != null) {
|
|
98
|
+
updateAttribute(slottedContent, "aria-expanded", isAttrTrue(newVal));
|
|
99
|
+
}
|
|
80
100
|
break;
|
|
81
101
|
}
|
|
82
102
|
case "aria-label":
|
|
@@ -116,6 +136,16 @@ class Popover extends NectaryElement {
|
|
|
116
136
|
get popoverRect() {
|
|
117
137
|
return this.#$pop.popoverRect;
|
|
118
138
|
}
|
|
139
|
+
#getFirstAssignedElementInSlot(slot) {
|
|
140
|
+
if (slot === null) {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
const elements = slot != null ? slot.assignedElements() : null;
|
|
144
|
+
if (elements === null) {
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
return elements[0];
|
|
148
|
+
}
|
|
119
149
|
#onPopClose = () => {
|
|
120
150
|
this.#dispatchCloseEvent();
|
|
121
151
|
};
|
package/progress/index.js
CHANGED
|
@@ -27,6 +27,7 @@ class Progress extends NectaryElement {
|
|
|
27
27
|
this.#$bar.style.width = `${int}%`;
|
|
28
28
|
this.#$text.textContent = Intl.NumberFormat(navigator.language, { style: "percent" }).format(int / 100);
|
|
29
29
|
this.setAttribute("valuenow", int !== null ? String(int) : "0");
|
|
30
|
+
this.setAttribute("aria-valuenow", int !== null ? String(int) : "0");
|
|
30
31
|
break;
|
|
31
32
|
}
|
|
32
33
|
case "detailed": {
|
package/utils/element.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NectaryElementBase, sinchElementNameToBase } from "./shared/nectary-element-base.js";
|
|
2
2
|
import { getConstructor } from "./shared/global-elements-store.js";
|
|
3
3
|
import { COMPONENTS_STORE_KEY } from "./global-components-constants.js";
|
|
4
|
-
const version = "5.0.
|
|
4
|
+
const version = "5.0.1";
|
|
5
5
|
const pkg = {
|
|
6
6
|
version
|
|
7
7
|
};
|