@nectary/components 5.20.8 → 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 CHANGED
@@ -8563,14 +8563,25 @@ const template$p = document.createElement("template");
8563
8563
  template$p.innerHTML = templateHTML$p;
8564
8564
  class RadioOption extends NectaryElement {
8565
8565
  #$label;
8566
+ #$input;
8566
8567
  constructor() {
8567
8568
  super();
8568
8569
  const shadowRoot = this.attachShadow();
8569
8570
  shadowRoot.appendChild(template$p.content.cloneNode(true));
8570
8571
  this.#$label = shadowRoot.querySelector("#label");
8572
+ this.#$input = shadowRoot.querySelector("#input");
8571
8573
  }
8572
8574
  connectedCallback() {
8573
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");
8574
8585
  this.tabIndex = 0;
8575
8586
  }
8576
8587
  disconnectedCallback() {
@@ -8580,7 +8591,8 @@ class RadioOption extends NectaryElement {
8580
8591
  "checked",
8581
8592
  "disabled",
8582
8593
  "text",
8583
- "data-invalid"
8594
+ "data-invalid",
8595
+ "aria-label"
8584
8596
  ];
8585
8597
  }
8586
8598
  attributeChangedCallback(name, oldVal, newVal) {
@@ -8588,6 +8600,10 @@ class RadioOption extends NectaryElement {
8588
8600
  return;
8589
8601
  }
8590
8602
  switch (name) {
8603
+ case "aria-label": {
8604
+ this.#$label.setAttribute("aria-label", newVal ?? "");
8605
+ break;
8606
+ }
8591
8607
  case "text": {
8592
8608
  this.#$label.textContent = newVal;
8593
8609
  break;
@@ -8595,12 +8611,14 @@ class RadioOption extends NectaryElement {
8595
8611
  case "checked": {
8596
8612
  const isChecked = isAttrTrue(newVal);
8597
8613
  updateExplicitBooleanAttribute(this, "aria-checked", isChecked);
8614
+ updateExplicitBooleanAttribute(this.#$input, "aria-checked", isChecked);
8598
8615
  updateBooleanAttribute(this, "checked", isChecked);
8599
8616
  break;
8600
8617
  }
8601
8618
  case "disabled": {
8602
8619
  const isDisabled = isAttrTrue(newVal);
8603
8620
  updateExplicitBooleanAttribute(this, "aria-disabled", isDisabled);
8621
+ updateExplicitBooleanAttribute(this.#$input, "aria-disabled", isDisabled);
8604
8622
  updateBooleanAttribute(this, "disabled", isDisabled);
8605
8623
  break;
8606
8624
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nectary/components",
3
- "version": "5.20.8",
3
+ "version": "5.20.10",
4
4
  "files": [
5
5
  "**/*/*.css",
6
6
  "**/*/*.json",
@@ -1,18 +1,29 @@
1
- import { isAttrEqual, updateBooleanAttribute, isAttrTrue, updateExplicitBooleanAttribute, getBooleanAttribute, updateAttribute, getAttribute } from "../utils/dom.js";
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");
5
5
  template.innerHTML = templateHTML;
6
6
  class RadioOption extends NectaryElement {
7
7
  #$label;
8
+ #$input;
8
9
  constructor() {
9
10
  super();
10
11
  const shadowRoot = this.attachShadow();
11
12
  shadowRoot.appendChild(template.content.cloneNode(true));
12
13
  this.#$label = shadowRoot.querySelector("#label");
14
+ this.#$input = shadowRoot.querySelector("#input");
13
15
  }
14
16
  connectedCallback() {
15
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");
16
27
  this.tabIndex = 0;
17
28
  }
18
29
  disconnectedCallback() {
@@ -22,7 +33,8 @@ class RadioOption extends NectaryElement {
22
33
  "checked",
23
34
  "disabled",
24
35
  "text",
25
- "data-invalid"
36
+ "data-invalid",
37
+ "aria-label"
26
38
  ];
27
39
  }
28
40
  attributeChangedCallback(name, oldVal, newVal) {
@@ -30,6 +42,10 @@ class RadioOption extends NectaryElement {
30
42
  return;
31
43
  }
32
44
  switch (name) {
45
+ case "aria-label": {
46
+ this.#$label.setAttribute("aria-label", newVal ?? "");
47
+ break;
48
+ }
33
49
  case "text": {
34
50
  this.#$label.textContent = newVal;
35
51
  break;
@@ -37,12 +53,14 @@ class RadioOption extends NectaryElement {
37
53
  case "checked": {
38
54
  const isChecked = isAttrTrue(newVal);
39
55
  updateExplicitBooleanAttribute(this, "aria-checked", isChecked);
56
+ updateExplicitBooleanAttribute(this.#$input, "aria-checked", isChecked);
40
57
  updateBooleanAttribute(this, "checked", isChecked);
41
58
  break;
42
59
  }
43
60
  case "disabled": {
44
61
  const isDisabled = isAttrTrue(newVal);
45
62
  updateExplicitBooleanAttribute(this, "aria-disabled", isDisabled);
63
+ updateExplicitBooleanAttribute(this.#$input, "aria-disabled", isDisabled);
46
64
  updateBooleanAttribute(this, "disabled", isDisabled);
47
65
  break;
48
66
  }