@nectary/components 5.20.9 → 5.20.10
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 +16 -1
- package/package.json +1 -1
- package/radio-option/index.js +17 -2
package/bundle.js
CHANGED
|
@@ -8573,6 +8573,15 @@ class RadioOption extends NectaryElement {
|
|
|
8573
8573
|
}
|
|
8574
8574
|
connectedCallback() {
|
|
8575
8575
|
this.setAttribute("role", "radio");
|
|
8576
|
+
this.#$input.setAttribute("role", "radio");
|
|
8577
|
+
this.#$input.setAttribute("aria-labelledby", "label");
|
|
8578
|
+
const isChecked = getBooleanAttribute(this, "checked");
|
|
8579
|
+
const isDisabled = getBooleanAttribute(this, "disabled");
|
|
8580
|
+
this.#$input.setAttribute("aria-checked", isChecked ? "true" : "false");
|
|
8581
|
+
this.setAttribute("aria-checked", isChecked ? "true" : "false");
|
|
8582
|
+
this.#$input.setAttribute("aria-disabled", isDisabled ? "true" : "false");
|
|
8583
|
+
this.setAttribute("aria-disabled", isDisabled ? "true" : "false");
|
|
8584
|
+
this.#$label.setAttribute("aria-label", this.getAttribute("aria-label") ?? "radio-option");
|
|
8576
8585
|
this.tabIndex = 0;
|
|
8577
8586
|
}
|
|
8578
8587
|
disconnectedCallback() {
|
|
@@ -8582,7 +8591,8 @@ class RadioOption extends NectaryElement {
|
|
|
8582
8591
|
"checked",
|
|
8583
8592
|
"disabled",
|
|
8584
8593
|
"text",
|
|
8585
|
-
"data-invalid"
|
|
8594
|
+
"data-invalid",
|
|
8595
|
+
"aria-label"
|
|
8586
8596
|
];
|
|
8587
8597
|
}
|
|
8588
8598
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
@@ -8590,6 +8600,10 @@ class RadioOption extends NectaryElement {
|
|
|
8590
8600
|
return;
|
|
8591
8601
|
}
|
|
8592
8602
|
switch (name) {
|
|
8603
|
+
case "aria-label": {
|
|
8604
|
+
this.#$label.setAttribute("aria-label", newVal ?? "");
|
|
8605
|
+
break;
|
|
8606
|
+
}
|
|
8593
8607
|
case "text": {
|
|
8594
8608
|
this.#$label.textContent = newVal;
|
|
8595
8609
|
break;
|
|
@@ -8604,6 +8618,7 @@ class RadioOption extends NectaryElement {
|
|
|
8604
8618
|
case "disabled": {
|
|
8605
8619
|
const isDisabled = isAttrTrue(newVal);
|
|
8606
8620
|
updateExplicitBooleanAttribute(this, "aria-disabled", isDisabled);
|
|
8621
|
+
updateExplicitBooleanAttribute(this.#$input, "aria-disabled", isDisabled);
|
|
8607
8622
|
updateBooleanAttribute(this, "disabled", isDisabled);
|
|
8608
8623
|
break;
|
|
8609
8624
|
}
|
package/package.json
CHANGED
package/radio-option/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isAttrEqual, updateBooleanAttribute, isAttrTrue, updateExplicitBooleanAttribute,
|
|
1
|
+
import { getBooleanAttribute, isAttrEqual, updateBooleanAttribute, isAttrTrue, updateExplicitBooleanAttribute, updateAttribute, getAttribute } from "../utils/dom.js";
|
|
2
2
|
import { defineCustomElement, NectaryElement } from "../utils/element.js";
|
|
3
3
|
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{display:flex;flex-direction:row;box-sizing:border-box;width:100%;min-height:24px;--sinch-local-color-background:var(--sinch-comp-radio-color-default-background-initial);--sinch-local-color-background-hover:var(--sinch-comp-radio-color-default-background-hover);--sinch-local-color-background-active:var(--sinch-comp-radio-color-default-background-active);--sinch-local-color-border:var(--sinch-comp-radio-color-default-border-initial);--sinch-local-color-border-hover:var(--sinch-comp-radio-color-default-border-hover);--sinch-local-color-border-active:var(--sinch-comp-radio-color-default-border-active);--sinch-local-color-knob:var(--sinch-comp-radio-color-checked-knob-initial);--sinch-local-color-knob-hover:var(--sinch-comp-radio-color-checked-knob-hover);--sinch-local-color-knob-active:var(--sinch-comp-radio-color-checked-knob-active);--sinch-local-color-text:var(--sinch-comp-radio-color-default-label-initial)}:host([data-invalid])>#wrapper{--sinch-local-color-border:var(--sinch-comp-radio-color-invalid-border-initial);--sinch-local-color-border-hover:var(--sinch-comp-radio-color-invalid-border-hover);--sinch-local-color-border-active:var(--sinch-comp-radio-color-invalid-border-active);--sinch-local-color-text:var(--sinch-comp-radio-color-invalid-label-initial)}:host([checked])>#wrapper{--sinch-local-color-border:var(--sinch-comp-radio-color-checked-border-initial);--sinch-local-color-border-hover:var(--sinch-comp-radio-color-checked-border-hover);--sinch-local-color-border-active:var(--sinch-comp-radio-color-checked-border-active)}:host([disabled])>#wrapper{--sinch-local-color-background:var(--sinch-comp-radio-color-disabled-background-initial);--sinch-local-color-border:var(--sinch-comp-radio-color-disabled-border-initial);--sinch-local-color-text:var(--sinch-comp-radio-color-disabled-label-initial)}:host([disabled][checked])>#wrapper{--sinch-local-color-border:var(--sinch-comp-radio-color-checked-disabled-border-initial);--sinch-local-color-knob:var(--sinch-comp-radio-color-checked-disabled-knob-initial);--sinch-local-color-text:var(--sinch-comp-radio-color-checked-disabled-label-initial)}#input{all:initial;display:block;width:18px;height:18px;cursor:pointer}:host([disabled]) #input{cursor:initial}#input-wrapper{position:relative;width:18px;height:18px;align-self:flex-start;margin-top:3px}#input::before{content:"";position:absolute;inset:-3px;border:2px solid var(--sinch-comp-radio-color-default-outline-focus);border-radius:50%;transition:opacity .1s linear;opacity:0;box-sizing:border-box;pointer-events:none}:host(:focus-visible) #input::before{opacity:1}#input::after{content:"";position:absolute;width:18px;height:18px;inset:0;margin:auto;background-color:var(--sinch-local-color-background);border:1px solid var(--sinch-local-color-border);border-radius:50%;box-sizing:border-box;pointer-events:none}:host(:hover:not([disabled])) #input::after{background-color:var(--sinch-local-color-background-hover);border-color:var(--sinch-local-color-border-hover)}:host(:active:not([disabled])) #input::after{background-color:var(--sinch-local-color-background-active);border-color:var(--sinch-local-color-border-active)}#knob{position:absolute;width:10px;height:10px;inset:0;margin:auto;border-radius:50%;transition:opacity .1s linear;opacity:0;background-color:var(--sinch-local-color-knob);pointer-events:none}:host([checked]) #knob{opacity:1}:host(:hover:not([disabled])) #knob{background-color:var(--sinch-local-color-knob-hover)}:host(:active:not([disabled])) #knob{background-color:var(--sinch-local-color-knob-active)}@media (prefers-reduced-motion){#input::after,#input::before,#knob{transition:none}}#label{flex:1;align-self:center;padding-left:8px;font:var(--sinch-comp-radio-font-label);color:var(--sinch-local-color-text);cursor:pointer}#label:empty{display:none}:host([disabled]) #label{cursor:initial}</style><div id="wrapper"><div id="input-wrapper"><div id="input"></div><div id="knob"></div></div><span id="label"></span></div>';
|
|
4
4
|
const template = document.createElement("template");
|
|
@@ -15,6 +15,15 @@ class RadioOption extends NectaryElement {
|
|
|
15
15
|
}
|
|
16
16
|
connectedCallback() {
|
|
17
17
|
this.setAttribute("role", "radio");
|
|
18
|
+
this.#$input.setAttribute("role", "radio");
|
|
19
|
+
this.#$input.setAttribute("aria-labelledby", "label");
|
|
20
|
+
const isChecked = getBooleanAttribute(this, "checked");
|
|
21
|
+
const isDisabled = getBooleanAttribute(this, "disabled");
|
|
22
|
+
this.#$input.setAttribute("aria-checked", isChecked ? "true" : "false");
|
|
23
|
+
this.setAttribute("aria-checked", isChecked ? "true" : "false");
|
|
24
|
+
this.#$input.setAttribute("aria-disabled", isDisabled ? "true" : "false");
|
|
25
|
+
this.setAttribute("aria-disabled", isDisabled ? "true" : "false");
|
|
26
|
+
this.#$label.setAttribute("aria-label", this.getAttribute("aria-label") ?? "radio-option");
|
|
18
27
|
this.tabIndex = 0;
|
|
19
28
|
}
|
|
20
29
|
disconnectedCallback() {
|
|
@@ -24,7 +33,8 @@ class RadioOption extends NectaryElement {
|
|
|
24
33
|
"checked",
|
|
25
34
|
"disabled",
|
|
26
35
|
"text",
|
|
27
|
-
"data-invalid"
|
|
36
|
+
"data-invalid",
|
|
37
|
+
"aria-label"
|
|
28
38
|
];
|
|
29
39
|
}
|
|
30
40
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
@@ -32,6 +42,10 @@ class RadioOption extends NectaryElement {
|
|
|
32
42
|
return;
|
|
33
43
|
}
|
|
34
44
|
switch (name) {
|
|
45
|
+
case "aria-label": {
|
|
46
|
+
this.#$label.setAttribute("aria-label", newVal ?? "");
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
35
49
|
case "text": {
|
|
36
50
|
this.#$label.textContent = newVal;
|
|
37
51
|
break;
|
|
@@ -46,6 +60,7 @@ class RadioOption extends NectaryElement {
|
|
|
46
60
|
case "disabled": {
|
|
47
61
|
const isDisabled = isAttrTrue(newVal);
|
|
48
62
|
updateExplicitBooleanAttribute(this, "aria-disabled", isDisabled);
|
|
63
|
+
updateExplicitBooleanAttribute(this.#$input, "aria-disabled", isDisabled);
|
|
49
64
|
updateBooleanAttribute(this, "disabled", isDisabled);
|
|
50
65
|
break;
|
|
51
66
|
}
|