@nectary/components 2.2.1 → 2.2.3

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.
Files changed (71) hide show
  1. package/accordion/index.js +21 -16
  2. package/accordion-item/index.js +9 -17
  3. package/action-menu/index.js +6 -9
  4. package/action-menu-option/index.js +3 -7
  5. package/alert/index.js +12 -12
  6. package/avatar/index.js +26 -23
  7. package/badge/index.js +2 -2
  8. package/button/index.js +6 -4
  9. package/card/index.js +6 -6
  10. package/checkbox/index.js +3 -3
  11. package/chip/index.js +2 -2
  12. package/code-tag/index.js +6 -9
  13. package/color-menu/index.js +10 -17
  14. package/color-menu-option/index.d.ts +0 -1
  15. package/color-menu-option/index.js +2 -6
  16. package/color-swatch/index.js +9 -9
  17. package/date-picker/index.js +0 -3
  18. package/dialog/index.js +16 -10
  19. package/dialog/types.d.ts +2 -0
  20. package/emoji/index.js +3 -0
  21. package/field/index.js +4 -4
  22. package/file-drop/index.js +21 -19
  23. package/file-picker/index.js +18 -18
  24. package/file-status/index.js +8 -5
  25. package/flag/index.js +3 -0
  26. package/help-tooltip/index.d.ts +1 -0
  27. package/help-tooltip/index.js +2 -1
  28. package/horizontal-stepper/index.js +1 -4
  29. package/horizontal-stepper-item/index.js +0 -3
  30. package/icon-button/index.js +5 -6
  31. package/input/index.js +8 -5
  32. package/link/index.js +2 -2
  33. package/package.json +1 -1
  34. package/pagination/index.js +2 -6
  35. package/pop/index.js +5 -4
  36. package/popover/index.js +2 -2
  37. package/progress/index.js +4 -4
  38. package/progress-stepper/index.js +1 -4
  39. package/progress-stepper-item/index.js +5 -5
  40. package/radio/index.js +28 -24
  41. package/radio-option/index.js +12 -34
  42. package/rich-text/index.js +12 -12
  43. package/segment/index.js +5 -2
  44. package/segmented-control/index.js +42 -21
  45. package/segmented-control-option/index.js +23 -30
  46. package/segmented-icon-control/index.js +46 -26
  47. package/segmented-icon-control-option/index.js +25 -32
  48. package/select-button/index.js +3 -4
  49. package/select-menu/index.js +0 -3
  50. package/select-menu-option/index.js +2 -2
  51. package/skeleton/index.js +0 -3
  52. package/spinner/index.js +0 -3
  53. package/table-head-cell/index.js +2 -2
  54. package/table-row/index.js +2 -2
  55. package/tabs/index.js +7 -7
  56. package/tabs-icon-option/index.js +2 -2
  57. package/tabs-option/index.js +2 -2
  58. package/tag/index.js +5 -2
  59. package/text/index.js +5 -2
  60. package/textarea/index.js +12 -6
  61. package/tile-control/index.js +2 -2
  62. package/tile-control-option/index.js +0 -3
  63. package/time-picker/index.js +3 -4
  64. package/title/index.js +4 -4
  65. package/toast/index.js +0 -3
  66. package/toggle/index.js +2 -2
  67. package/tooltip/index.js +1 -1
  68. package/utils/dom.d.ts +1 -0
  69. package/utils/dom.js +5 -2
  70. package/vertical-stepper/index.js +1 -4
  71. package/vertical-stepper-item/index.js +0 -3
package/progress/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import '../text';
2
- import { defineCustomElement, updateAttribute, NectaryElement, updateBooleanAttribute, getIntegerAttribute, getBooleanAttribute, attrValueToInteger, isAttrTrue } from '../utils';
2
+ import { defineCustomElement, updateAttribute, NectaryElement, updateBooleanAttribute, getIntegerAttribute, getBooleanAttribute, attrValueToInteger, isAttrTrue, isAttrEqual } from '../utils';
3
3
  const templateHTML = '<style>:host{display:block}#wrapper{display:flex;align-items:center;height:24px}#bar,#progress{height:8px;border-radius:4px}#progress{background-color:var(--sinch-comp-progress-color-default-background-initial);flex:1;min-width:0}#bar{background-color:var(--sinch-comp-progress-color-default-bar-initial);width:0}#text{display:none;width:46px;--sinch-global-color-text:var(--sinch-comp-progress-color-default-text-initial)}:host([detailed]) #text{display:block}</style><div id="wrapper"><sinch-text id="text" type="m"></sinch-text><div id="progress"><div id="bar"></div></div></div>';
4
4
  const template = document.createElement('template');
5
5
  template.innerHTML = templateHTML;
@@ -20,9 +20,6 @@ defineCustomElement('sinch-progress', class extends NectaryElement {
20
20
  return ['value', 'detailed'];
21
21
  }
22
22
  attributeChangedCallback(name, oldVal, newVal) {
23
- if (oldVal === newVal) {
24
- return;
25
- }
26
23
  switch (name) {
27
24
  case 'value':
28
25
  {
@@ -38,6 +35,9 @@ defineCustomElement('sinch-progress', class extends NectaryElement {
38
35
  }
39
36
  case 'detailed':
40
37
  {
38
+ if (isAttrEqual(oldVal, newVal)) {
39
+ break;
40
+ }
41
41
  updateBooleanAttribute(this, name, isAttrTrue(newVal));
42
42
  break;
43
43
  }
@@ -40,10 +40,7 @@ defineCustomElement('sinch-progress-stepper', class extends NectaryElement {
40
40
  static get observedAttributes() {
41
41
  return ['value', 'progressvalue'];
42
42
  }
43
- attributeChangedCallback(name, oldVal, newVal) {
44
- if (oldVal === newVal) {
45
- return;
46
- }
43
+ attributeChangedCallback(name, _, newVal) {
47
44
  switch (name) {
48
45
  case 'value':
49
46
  {
@@ -1,5 +1,5 @@
1
1
  import '../text';
2
- import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
2
+ import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrEqual, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
3
3
  const templateHTML = '<style>:host{display:block;outline:0}#button{position:relative;display:flex;flex-direction:column;gap:4px;width:100%;height:100%;padding:8px 4px 4px;box-sizing:border-box;cursor:pointer;border-radius:var(--sinch-comp-progress-stepper-step-shape-radius)}:host([data-status=inactive])>#button{cursor:not-allowed}:host([data-status=incomplete]:hover)>#button{background-color:var(--sinch-comp-progress-stepper-step-color-incomplete-background-hover)}:host([data-status=complete]:hover)>#button{background-color:var(--sinch-comp-progress-stepper-step-color-complete-background-hover)}:host([data-status=invalid]:hover)>#button{background-color:var(--sinch-comp-progress-stepper-step-color-invalid-background-hover)}#outline{position:absolute;inset:-2px;border:2px solid var(--sinch-comp-progress-stepper-step-color-outline-focus);border-radius:calc(var(--sinch-comp-progress-stepper-step-shape-radius) + 2px);pointer-events:none;opacity:0}:host(:focus-visible) #outline{opacity:1}#text{flex-shrink:1;flex-basis:auto;min-width:0;transform:translate(0,0);will-change:transform;transition:transform .25s ease-out;padding-right:24px}:host([data-status=incomplete]) #text{--sinch-global-color-text:var(--sinch-comp-progress-stepper-step-color-incomplete-label-default);--sinch-comp-text-font:var(--sinch-comp-progress-stepper-step-font-incomplete-label)}:host([data-status=complete]) #text{--sinch-global-color-text:var(--sinch-comp-progress-stepper-step-color-complete-label-default);--sinch-comp-text-font:var(--sinch-comp-progress-stepper-step-font-complete-label)}:host([data-status=inactive]) #text{--sinch-global-color-text:var(--sinch-comp-progress-stepper-step-color-inactive-label-default);--sinch-comp-text-font:var(--sinch-comp-progress-stepper-step-font-inactive-label)}:host([invalid]) #text{--sinch-global-color-text:var(--sinch-comp-progress-stepper-step-color-invalid-label-default);--sinch-comp-text-font:var(--sinch-comp-progress-stepper-step-font-invalid-label);transform:translate(24px,0)}:host([data-status=incomplete][data-checked]) #text{--sinch-global-color-text:var(--sinch-comp-progress-stepper-step-color-incomplete-current-label-default);--sinch-comp-text-font:var(--sinch-comp-progress-stepper-step-font-incomplete-current-label)}:host([data-status=complete][data-checked]) #text{--sinch-global-color-text:var(--sinch-comp-progress-stepper-step-color-complete-current-label-default);--sinch-comp-text-font:var(--sinch-comp-progress-stepper-step-font-complete-current-label)}:host([invalid][data-checked]) #text{--sinch-global-color-text:var(--sinch-comp-progress-stepper-step-color-invalid-label-default);--sinch-comp-text-font:var(--sinch-comp-progress-stepper-step-font-invalid-current-label)}#icon-error{position:absolute;left:0;top:4px;pointer-events:none;opacity:0;transition:opacity .25s ease-in-out;--sinch-global-color-icon:var(--sinch-comp-progress-stepper-step-color-invalid-icon-default);--sinch-global-size-icon:16px}:host([invalid]) #icon-error{opacity:1}#progress{height:8px;border-radius:4px;transition:background-color .25s ease-in-out}:host([data-status=incomplete]) #progress{background-color:var(--sinch-comp-progress-stepper-step-color-incomplete-progress-background)}:host([data-status=complete]) #progress{background-color:var(--sinch-comp-progress-stepper-step-color-complete-progress-background)}:host([data-status=inactive]) #progress{background-color:var(--sinch-comp-progress-stepper-step-color-inactive-progress-background)}:host([invalid]) #progress{background-color:var(--sinch-comp-progress-stepper-step-color-invalid-progress-background)}#bar{width:8px;height:8px;border-radius:4px;opacity:0;transition:width .25s ease-in-out,opacity .25s ease-in-out}:host([data-status=incomplete]) #bar{background-color:var(--sinch-comp-progress-stepper-step-color-incomplete-progress-bar)}:host([data-status=complete]) #bar{background-color:var(--sinch-comp-progress-stepper-step-color-complete-progress-bar);width:100%}:host([data-status=complete]:not([invalid])) #bar,:host([data-status=incomplete]:not([invalid])) #bar{opacity:1}#label-bar{position:relative}</style><div id="button"><div id="progress"><div id="bar"></div></div><div id="label-bar"><sinch-icon id="icon-error" name="report_problem" aria-hidden="true"></sinch-icon><sinch-text id="text" type="m"></sinch-text></div><div id="outline"></div></div>';
4
4
  import { ATTR_PROGRESS_STEPPER_ITEM_ACTIVE_DESCENDANT, ATTR_PROGRESS_STEPPER_ITEM_CHECKED, ATTR_PROGRESS_STEPPER_ITEM_STATUS, isProgressStepperItemActive, isProgressStepperItemActiveDescendant } from './utils';
5
5
  const template = document.createElement('template');
@@ -22,9 +22,6 @@ defineCustomElement('sinch-progress-stepper-item', class extends NectaryElement
22
22
  return ['text', 'invalid', ATTR_PROGRESS_STEPPER_ITEM_STATUS, ATTR_PROGRESS_STEPPER_ITEM_CHECKED, ATTR_PROGRESS_STEPPER_ITEM_ACTIVE_DESCENDANT];
23
23
  }
24
24
  attributeChangedCallback(name, oldVal, newVal) {
25
- if (oldVal === newVal) {
26
- return;
27
- }
28
25
  switch (name) {
29
26
  case 'text':
30
27
  {
@@ -48,9 +45,12 @@ defineCustomElement('sinch-progress-stepper-item', class extends NectaryElement
48
45
  }
49
46
  case 'invalid':
50
47
  {
48
+ if (isAttrEqual(oldVal, newVal)) {
49
+ return;
50
+ }
51
51
  const isInvalid = isAttrTrue(newVal);
52
- updateBooleanAttribute(this, 'invalid', isInvalid);
53
52
  updateExplicitBooleanAttribute(this, 'aria-invalid', isInvalid);
53
+ updateBooleanAttribute(this, 'invalid', isInvalid);
54
54
  break;
55
55
  }
56
56
  }
package/radio/index.js CHANGED
@@ -1,9 +1,10 @@
1
- import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute } from '../utils';
1
+ import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, getTargetByAttribute, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute } from '../utils';
2
2
  const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:column;gap:8px;box-sizing:border-box;width:100%}</style><div id="wrapper"><slot></slot></div>';
3
3
  const template = document.createElement('template');
4
4
  template.innerHTML = templateHTML;
5
5
  defineCustomElement('sinch-radio', class extends NectaryElement {
6
6
  #$slot;
7
+ #controller = null;
7
8
  constructor() {
8
9
  super();
9
10
  const shadowRoot = this.attachShadow();
@@ -11,17 +12,22 @@ defineCustomElement('sinch-radio', class extends NectaryElement {
11
12
  this.#$slot = shadowRoot.querySelector('slot');
12
13
  }
13
14
  connectedCallback() {
14
- this.setAttribute('role', 'radiogroup');
15
- this.#$slot.addEventListener('slotchange', this.#onSlotChange);
16
- this.#$slot.addEventListener('keydown', this.#onOptionKeyDown);
17
- this.#$slot.addEventListener('option-change', this.#onOptionChange);
18
- this.addEventListener('-change', this.#onChangeReactHandler);
15
+ this.#controller = new AbortController();
16
+ const {
17
+ signal
18
+ } = this.#controller;
19
+ const options = {
20
+ signal
21
+ };
22
+ this.role = 'radiogroup';
23
+ this.#$slot.addEventListener('slotchange', this.#onSlotChange, options);
24
+ this.#$slot.addEventListener('keydown', this.#onOptionKeyDown, options);
25
+ this.#$slot.addEventListener('click', this.#onOptionClick, options);
26
+ this.addEventListener('-change', this.#onChangeReactHandler, options);
19
27
  }
20
28
  disconnectedCallback() {
21
- this.#$slot.removeEventListener('slotchange', this.#onSlotChange);
22
- this.#$slot.removeEventListener('keydown', this.#onOptionKeyDown);
23
- this.#$slot.removeEventListener('option-change', this.#onOptionChange);
24
- this.removeEventListener('-change', this.#onChangeReactHandler);
29
+ this.#controller.abort();
30
+ this.#controller = null;
25
31
  }
26
32
  static get observedAttributes() {
27
33
  return ['value', 'invalid'];
@@ -39,9 +45,6 @@ defineCustomElement('sinch-radio', class extends NectaryElement {
39
45
  return getBooleanAttribute(this, 'invalid');
40
46
  }
41
47
  attributeChangedCallback(name, oldVal, newVal) {
42
- if (oldVal === newVal) {
43
- return;
44
- }
45
48
  switch (name) {
46
49
  case 'value':
47
50
  {
@@ -64,7 +67,7 @@ defineCustomElement('sinch-radio', class extends NectaryElement {
64
67
  const $option = this.#getPrevOption();
65
68
  if ($option !== null) {
66
69
  $option.focus();
67
- this.#dispatchChangeEvent($option.value);
70
+ $option.click();
68
71
  }
69
72
  break;
70
73
  }
@@ -75,7 +78,7 @@ defineCustomElement('sinch-radio', class extends NectaryElement {
75
78
  const $option = this.#getNextOption();
76
79
  if ($option !== null) {
77
80
  $option.focus();
78
- this.#dispatchChangeEvent($option.value);
81
+ $option.click();
79
82
  }
80
83
  break;
81
84
  }
@@ -84,9 +87,15 @@ defineCustomElement('sinch-radio', class extends NectaryElement {
84
87
  #onSlotChange = () => {
85
88
  this.#onValueChange(this.value);
86
89
  };
87
- #onOptionChange = e => {
88
- e.stopPropagation();
89
- this.#dispatchChangeEvent(e.detail);
90
+ #onOptionClick = e => {
91
+ const target = getTargetByAttribute(e, 'value');
92
+ if (target === null || target.hasAttribute('disabled')) {
93
+ return;
94
+ }
95
+ const value = getAttribute(target, 'value');
96
+ this.dispatchEvent(new CustomEvent('-change', {
97
+ detail: value
98
+ }));
90
99
  };
91
100
  #onValueChange(value) {
92
101
  for (const $option of this.#$slot.assignedElements()) {
@@ -94,11 +103,6 @@ defineCustomElement('sinch-radio', class extends NectaryElement {
94
103
  updateBooleanAttribute($option, 'checked', isChecked);
95
104
  }
96
105
  }
97
- #dispatchChangeEvent(value) {
98
- this.dispatchEvent(new CustomEvent('-change', {
99
- detail: value
100
- }));
101
- }
102
106
  #getFirstOption() {
103
107
  for (const $option of this.#$slot.assignedElements()) {
104
108
  if ($option.disabled !== true) {
@@ -134,7 +138,7 @@ defineCustomElement('sinch-radio', class extends NectaryElement {
134
138
  return $options[(currentIndex - 1 + $options.length) % $options.length];
135
139
  }
136
140
  #getEnabledRadioElements() {
137
- return this.#$slot.assignedElements().filter(el => el.disabled !== true);
141
+ return this.#$slot.assignedElements().filter(el => !el.hasAttribute('disabled'));
138
142
  }
139
143
  #findSelectedOption(elements) {
140
144
  return elements.find(el => el.checked) ?? null;
@@ -1,29 +1,25 @@
1
- import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute } from '../utils';
2
- const templateHTML = '<style>:host{display:block;outline:0}#wrapper{display:flex;flex-direction:row;box-sizing:border-box;width:100%;--sinch-local-size: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:var(--sinch-local-size);height:var(--sinch-local-size);cursor:pointer}#input:disabled{cursor:initial}#input::before{content:"";position:absolute;top:0;left:0;width:var(--sinch-local-size);height:var(--sinch-local-size);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}#input:focus-visible::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}#input:enabled:hover::after{background-color:var(--sinch-local-color-background-hover);border-color:var(--sinch-local-color-border-hover)}#input:enabled:active::after{background-color:var(--sinch-local-color-background-active);border-color:var(--sinch-local-color-border-active)}#input-wrapper{position:relative;width:var(--sinch-local-size);height:var(--sinch-local-size);align-self:flex-start}#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}#input:checked+#knob{opacity:1}#input:enabled:hover+#knob{background-color:var(--sinch-local-color-knob-hover)}#input:enabled:active+#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}:host([disabled]) #label{cursor:initial}</style><div id="wrapper"><div id="input-wrapper"><input id="input" type="radio"/><div id="knob"></div></div><label for="input" id="label"></label></div>';
1
+ import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrEqual, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
2
+ 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>';
3
3
  const template = document.createElement('template');
4
4
  template.innerHTML = templateHTML;
5
5
  defineCustomElement('sinch-radio-option', class extends NectaryElement {
6
- #$input;
7
6
  #$label;
8
7
  constructor() {
9
8
  super();
10
9
  const shadowRoot = this.attachShadow();
11
10
  shadowRoot.appendChild(template.content.cloneNode(true));
12
- this.#$input = shadowRoot.querySelector('input');
13
- this.#$label = shadowRoot.querySelector('label');
11
+ this.#$label = shadowRoot.querySelector('#label');
14
12
  }
15
13
  connectedCallback() {
16
- this.setAttribute('role', 'radio');
17
- this.#$input.addEventListener('input', this.#onInput);
18
- }
19
- disconnectedCallback() {
20
- this.#$input.removeEventListener('input', this.#onInput);
14
+ this.role = 'radio';
15
+ this.tabIndex = 0;
21
16
  }
17
+ disconnectedCallback() {}
22
18
  static get observedAttributes() {
23
- return ['checked', 'disabled', 'text', 'value', 'data-invalid'];
19
+ return ['checked', 'disabled', 'text', 'data-invalid'];
24
20
  }
25
21
  attributeChangedCallback(name, oldVal, newVal) {
26
- if (oldVal === newVal) {
22
+ if (isAttrEqual(oldVal, newVal)) {
27
23
  return;
28
24
  }
29
25
  switch (name) {
@@ -34,14 +30,15 @@ defineCustomElement('sinch-radio-option', class extends NectaryElement {
34
30
  }
35
31
  case 'checked':
36
32
  {
37
- this.#$input.checked = isAttrTrue(newVal);
38
- updateAttribute(this, 'aria-checked', isAttrTrue(newVal));
33
+ const isChecked = isAttrTrue(newVal);
34
+ updateExplicitBooleanAttribute(this, 'aria-checked', isChecked);
35
+ updateBooleanAttribute(this, 'checked', isChecked);
39
36
  break;
40
37
  }
41
38
  case 'disabled':
42
39
  {
43
40
  const isDisabled = isAttrTrue(newVal);
44
- this.#$input.disabled = isDisabled;
41
+ updateExplicitBooleanAttribute(this, 'aria-disabled', isDisabled);
45
42
  updateBooleanAttribute(this, 'disabled', isDisabled);
46
43
  break;
47
44
  }
@@ -50,11 +47,6 @@ defineCustomElement('sinch-radio-option', class extends NectaryElement {
50
47
  updateBooleanAttribute(this, 'data-invalid', isAttrTrue(newVal));
51
48
  break;
52
49
  }
53
- case 'value':
54
- {
55
- this.#$input.value = newVal ?? '';
56
- break;
57
- }
58
50
  }
59
51
  }
60
52
  set checked(isChecked) {
@@ -84,18 +76,4 @@ defineCustomElement('sinch-radio-option', class extends NectaryElement {
84
76
  get focusable() {
85
77
  return true;
86
78
  }
87
- focus() {
88
- this.#$input.focus();
89
- }
90
- blur() {
91
- this.#$input.blur();
92
- }
93
- #onInput = e => {
94
- e.stopPropagation();
95
- this.#$input.checked = false;
96
- this.dispatchEvent(new CustomEvent('option-change', {
97
- bubbles: true,
98
- detail: this.value
99
- }));
100
- };
101
79
  });
@@ -14,18 +14,6 @@ defineCustomElement('sinch-rich-text', class extends NectaryElement {
14
14
  connectedCallback() {
15
15
  this.setAttribute('role', 'paragraph');
16
16
  }
17
- get size() {
18
- return getLiteralAttribute(this, sizeValues, 'size', 'm');
19
- }
20
- set size(value) {
21
- updateLiteralAttribute(this, sizeValues, 'size', value);
22
- }
23
- get text() {
24
- return getAttribute(this, 'text', '');
25
- }
26
- set text(value) {
27
- updateAttribute(this, 'text', value);
28
- }
29
17
  static get observedAttributes() {
30
18
  return ['text'];
31
19
  }
@@ -38,6 +26,18 @@ defineCustomElement('sinch-rich-text', class extends NectaryElement {
38
26
  }
39
27
  }
40
28
  }
29
+ get size() {
30
+ return getLiteralAttribute(this, sizeValues, 'size', 'm');
31
+ }
32
+ set size(value) {
33
+ updateLiteralAttribute(this, sizeValues, 'size', value);
34
+ }
35
+ get text() {
36
+ return getAttribute(this, 'text', '');
37
+ }
38
+ set text(value) {
39
+ updateAttribute(this, 'text', value);
40
+ }
41
41
  #updateText(text) {
42
42
  if (text === null) {
43
43
  this.#wrapper.innerHTML = '';
package/segment/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import '../title';
2
2
  import { getTitleLevelFromType } from '../title/utils';
3
- import { defineCustomElement, getAttribute, getBooleanAttribute, getLiteralAttribute, getRect, isAttrTrue, NectaryElement, setClass, updateAttribute, updateBooleanAttribute, updateLiteralAttribute } from '../utils';
3
+ import { defineCustomElement, getAttribute, getBooleanAttribute, getLiteralAttribute, getRect, isAttrEqual, isAttrTrue, NectaryElement, setClass, updateAttribute, updateBooleanAttribute, updateLiteralAttribute } from '../utils';
4
4
  import { DEFAULT_SIZE, sizeValues } from '../utils/size';
5
5
  const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:column;gap:12px;width:100%;height:100%;border:1px solid var(--sinch-comp-segment-color-default-border-initial);border-radius:var(--sinch-comp-segment-shape-radius);box-sizing:border-box;background-color:var(--sinch-comp-segment-color-default-background-initial);padding:8px 0 16px}#header{display:flex;flex-direction:row;align-items:center;height:48px;gap:8px;padding:0 24px}#icon{--sinch-global-size-icon:32px}#caption{min-width:1em;--sinch-comp-title-font:var(--sinch-comp-segment-font-size-m-title)}:host([size="l"]) #caption{--sinch-comp-title-font:var(--sinch-comp-segment-font-size-l-title)}:host([size="s"]) #caption{--sinch-comp-title-font:var(--sinch-comp-segment-font-size-s-title)}#info{display:flex;flex-direction:row;align-items:center;gap:8px;margin-left:auto;align-self:stretch}#info.empty{display:none}#preview{flex:1;flex-basis:auto;height:48px;min-width:0;overflow:hidden;margin-left:24px}#preview.empty{display:none}#info.empty+#collapse{margin-left:auto}#collapse.empty{display:none}#preview:not(.empty)+#info.empty+#collapse:not(.empty),#preview:not(.empty)+#info:not(.empty){margin-left:24px}#content-wrapper{flex:1;min-height:0;overflow-y:auto;padding:4px 24px}#action{display:flex;flex-direction:row;justify-content:flex-end;gap:16px;padding:0 24px}#action.empty{display:none}:host([collapsed]) :is(#content-wrapper,#action){display:none}:host([collapsed]) #wrapper{padding-bottom:8px}::slotted([slot=icon]){margin-right:8px}</style><div id="wrapper"><div id="header"><slot id="icon" name="icon"></slot><sinch-title id="caption" level="3" type="m" ellipsis></sinch-title><div id="preview"><slot name="preview"></slot></div><div id="info"><slot name="info"></slot></div><div id="collapse"><slot name="collapse"></slot></div></div><div id="content-wrapper"><slot name="content"></slot></div><div id="action"><slot name="action"></slot></div></div>';
6
6
  import { getTitleTypeFromSize } from './utils';
@@ -49,7 +49,7 @@ defineCustomElement('sinch-segment', class extends NectaryElement {
49
49
  static get observedAttributes() {
50
50
  return ['caption', 'collapsed', 'size'];
51
51
  }
52
- attributeChangedCallback(name, _, newVal) {
52
+ attributeChangedCallback(name, oldVal, newVal) {
53
53
  switch (name) {
54
54
  case 'caption':
55
55
  {
@@ -58,6 +58,9 @@ defineCustomElement('sinch-segment', class extends NectaryElement {
58
58
  }
59
59
  case 'collapsed':
60
60
  {
61
+ if (isAttrEqual(oldVal, newVal)) {
62
+ return;
63
+ }
61
64
  updateBooleanAttribute(this, name, isAttrTrue(newVal));
62
65
  break;
63
66
  }
@@ -1,9 +1,10 @@
1
- import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, NectaryElement, updateAttribute, updateBooleanAttribute } from '../utils';
2
- const templateHTML = '<style>:host{display:block;outline:0}#wrapper{display:flex;flex-direction:row;width:100%;box-sizing:border-box}</style><div id="wrapper"><slot></slot></div>';
1
+ import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, getTargetByAttribute, NectaryElement, updateAttribute, updateBooleanAttribute } from '../utils';
2
+ const templateHTML = '<style>:host{display:block;outline:0}#wrapper{display:flex;flex-direction:row;width:100%;box-sizing:border-box;position:relative;z-index:0}</style><div id="wrapper"><slot></slot></div>';
3
3
  const template = document.createElement('template');
4
4
  template.innerHTML = templateHTML;
5
5
  defineCustomElement('sinch-segmented-control', class extends NectaryElement {
6
6
  #$slot;
7
+ #controller = null;
7
8
  constructor() {
8
9
  super();
9
10
  const shadowRoot = this.attachShadow();
@@ -11,29 +12,27 @@ defineCustomElement('sinch-segmented-control', class extends NectaryElement {
11
12
  this.#$slot = shadowRoot.querySelector('slot');
12
13
  }
13
14
  connectedCallback() {
14
- this.setAttribute('role', 'tablist');
15
- this.#$slot.addEventListener('option-change', this.#onOptionChange);
16
- this.#$slot.addEventListener('slotchange', this.#onSlotChange);
15
+ this.#controller = new AbortController();
16
+ const {
17
+ signal
18
+ } = this.#controller;
19
+ const options = {
20
+ signal
21
+ };
22
+ this.role = 'tablist';
23
+ this.#$slot.addEventListener('slotchange', this.#onSlotChange, options);
24
+ this.#$slot.addEventListener('click', this.#onOptionClick, options);
25
+ this.#$slot.addEventListener('keydown', this.#onOptionKeydown, options);
17
26
  this.addEventListener('-change', this.#onChangeReactHandler);
18
27
  }
19
28
  disconnectedCallback() {
20
- this.#$slot.removeEventListener('option-change', this.#onOptionChange);
21
- this.#$slot.removeEventListener('slotchange', this.#onSlotChange);
22
- this.removeEventListener('-change', this.#onChangeReactHandler);
29
+ this.#controller.abort();
30
+ this.#controller = null;
23
31
  }
24
32
  static get observedAttributes() {
25
33
  return ['value'];
26
34
  }
27
- set value(value) {
28
- updateAttribute(this, 'value', value);
29
- }
30
- get value() {
31
- return getAttribute(this, 'value', '');
32
- }
33
35
  attributeChangedCallback(name, oldVal, newVal) {
34
- if (oldVal === newVal) {
35
- return;
36
- }
37
36
  switch (name) {
38
37
  case 'value':
39
38
  {
@@ -42,16 +41,38 @@ defineCustomElement('sinch-segmented-control', class extends NectaryElement {
42
41
  }
43
42
  }
44
43
  }
44
+ set value(value) {
45
+ updateAttribute(this, 'value', value);
46
+ }
47
+ get value() {
48
+ return getAttribute(this, 'value', '');
49
+ }
45
50
  #onSlotChange = () => {
46
51
  this.#onValueChange(this.value);
47
52
  };
48
- #onOptionChange = e => {
49
- e.stopPropagation();
50
- const detail = e.detail;
53
+ #onOptionClick = e => {
54
+ const target = getTargetByAttribute(e, 'value');
55
+ if (target === null || getBooleanAttribute(target, 'disabled')) {
56
+ return;
57
+ }
58
+ const value = getAttribute(target, 'value', '');
51
59
  this.dispatchEvent(new CustomEvent('-change', {
52
- detail
60
+ detail: value
53
61
  }));
54
62
  };
63
+ #onOptionKeydown = e => {
64
+ switch (e.code) {
65
+ case 'Space':
66
+ case 'Enter':
67
+ {
68
+ e.preventDefault();
69
+ const target = getTargetByAttribute(e, 'value');
70
+ if (target !== null) {
71
+ target.click();
72
+ }
73
+ }
74
+ }
75
+ };
55
76
  #onValueChange(value) {
56
77
  for (const $option of this.#$slot.assignedElements()) {
57
78
  const isChecked = !getBooleanAttribute($option, 'disabled') && value === getAttribute($option, 'value', '');
@@ -1,39 +1,39 @@
1
- import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
2
- const templateHTML = '<style>:host{display:block;outline:0}#wrapper{position:relative;display:flex;flex-direction:row;align-items:center;gap:12px;width:100%;height:32px;padding:0 16px;box-sizing:border-box;color:var(--sinch-local-color-text);background-color:var(--sinch-local-color-background);--sinch-local-color-text:var(--sinch-comp-segmented-control-color-default-text-initial);--sinch-local-shape-radius:var(--sinch-comp-segmented-control-shape-radius);--sinch-local-color-border:var(--sinch-comp-segmented-control-color-default-border-initial);--sinch-local-color-background:var(--sinch-comp-segmented-control-color-default-background-initial);--sinch-global-color-icon:var(--sinch-comp-segmented-control-color-default-icon-initial);--sinch-global-size-icon:var(--sinch-comp-segmented-control-size-icon)}#wrapper:hover{--sinch-local-color-background:var(--sinch-comp-segmented-control-color-default-background-hover)}:host(:first-child) #wrapper{border-top-left-radius:var(--sinch-local-shape-radius);border-bottom-left-radius:var(--sinch-local-shape-radius)}:host(:last-child) #wrapper{border-top-right-radius:var(--sinch-local-shape-radius);border-bottom-right-radius:var(--sinch-local-shape-radius)}:host([data-checked]) #wrapper{--sinch-local-color-text:var(--sinch-comp-segmented-control-color-checked-text-initial);--sinch-global-color-icon:var(--sinch-comp-segmented-control-color-checked-icon-initial);--sinch-local-color-border:var(--sinch-comp-segmented-control-color-checked-border-initial);--sinch-local-color-background:var(--sinch-comp-segmented-control-color-checked-background-initial)}#border{position:absolute;inset:0;border:1px solid var(--sinch-local-color-border);border-right-width:0;pointer-events:none;box-sizing:border-box}:host(:first-child) #border{border-top-left-radius:var(--sinch-local-shape-radius);border-bottom-left-radius:var(--sinch-local-shape-radius)}:host(:last-child) #border{border-right-width:1px;border-top-right-radius:var(--sinch-local-shape-radius);border-bottom-right-radius:var(--sinch-local-shape-radius)}:host(:not(:first-child)) #border{left:-1px}:host(:not(:last-child)) #border{right:-1px}:host([data-checked]) #border{border-width:2px;z-index:1}#button{all:initial;position:absolute;left:0;top:0;width:100%;height:100%;box-sizing:border-box;cursor:pointer;z-index:1}#button:disabled{cursor:unset}#button:focus-visible::before{content:"";position:absolute;inset:-4px;border:2px solid var(--sinch-comp-segmented-control-color-default-outline-focus)}:host(:first-child) #button:focus-visible::before{border-top-left-radius:calc(var(--sinch-local-shape-radius) + 3px);border-bottom-left-radius:calc(var(--sinch-local-shape-radius) + 3px)}:host(:last-child) #button:focus-visible::before{border-top-right-radius:calc(var(--sinch-local-shape-radius) + 3px);border-bottom-right-radius:calc(var(--sinch-local-shape-radius) + 3px)}:host([disabled]) #wrapper{--sinch-local-color-text:var(--sinch-comp-segmented-control-color-disabled-text-initial);--sinch-global-color-icon:var(--sinch-comp-segmented-control-color-disabled-icon-initial);--sinch-local-color-border:var(--sinch-comp-segmented-control-color-disabled-border-initial);--sinch-local-color-background:var(--sinch-comp-segmented-control-color-disabled-background-initial)}#content{font:var(--sinch-comp-segmented-control-font-label);flex-shrink:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}::slotted(*){display:block}</style><div id="wrapper"><slot name="icon"></slot><label for="button" id="content"></label><div id="border"></div><button id="button"></button></div>';
1
+ import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, isAttrEqual, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
2
+ const templateHTML = '<style>:host{display:block;outline:0}#wrapper{position:relative;display:flex;flex-direction:row;align-items:center;gap:12px;width:100%;height:32px;padding:0 16px;box-sizing:border-box;color:var(--sinch-local-color-text);background-color:var(--sinch-local-color-background);cursor:pointer;--sinch-local-color-text:var(--sinch-comp-segmented-control-color-default-text-initial);--sinch-local-shape-radius:var(--sinch-comp-segmented-control-shape-radius);--sinch-local-color-border:var(--sinch-comp-segmented-control-color-default-border-initial);--sinch-local-color-background:var(--sinch-comp-segmented-control-color-default-background-initial);--sinch-global-color-icon:var(--sinch-comp-segmented-control-color-default-icon-initial);--sinch-global-size-icon:var(--sinch-comp-segmented-control-size-icon)}:host(:hover){--sinch-local-color-background:var(--sinch-comp-segmented-control-color-default-background-hover)}:host(:first-child) #wrapper{border-top-left-radius:var(--sinch-local-shape-radius);border-bottom-left-radius:var(--sinch-local-shape-radius)}:host(:last-child) #wrapper{border-top-right-radius:var(--sinch-local-shape-radius);border-bottom-right-radius:var(--sinch-local-shape-radius)}:host([data-checked]) #wrapper{--sinch-local-color-text:var(--sinch-comp-segmented-control-color-checked-text-initial);--sinch-global-color-icon:var(--sinch-comp-segmented-control-color-checked-icon-initial);--sinch-local-color-border:var(--sinch-comp-segmented-control-color-checked-border-initial);--sinch-local-color-background:var(--sinch-comp-segmented-control-color-checked-background-initial)}:host([disabled]) #wrapper{--sinch-local-color-text:var(--sinch-comp-segmented-control-color-disabled-text-initial);--sinch-global-color-icon:var(--sinch-comp-segmented-control-color-disabled-icon-initial);--sinch-local-color-border:var(--sinch-comp-segmented-control-color-disabled-border-initial);--sinch-local-color-background:var(--sinch-comp-segmented-control-color-disabled-background-initial)}#border{position:absolute;inset:0;border:1px solid var(--sinch-local-color-border);pointer-events:none;box-sizing:border-box}:host(:first-child) #border{border-top-left-radius:var(--sinch-local-shape-radius);border-bottom-left-radius:var(--sinch-local-shape-radius)}:host(:last-child) #border{border-top-right-radius:var(--sinch-local-shape-radius);border-bottom-right-radius:var(--sinch-local-shape-radius)}:host(:not(:first-child)) #border{border-left-width:0}:host([data-checked]) #border{border-width:2px}:host([data-checked]:not(:first-child)) #border{left:-1px}#outline{display:none;position:absolute;inset:-3px;border:2px solid var(--sinch-comp-segmented-control-color-default-outline-focus);pointer-events:none;box-sizing:border-box;z-index:1}:host(:focus-visible) #outline{display:block}:host(:first-child) #outline{border-top-left-radius:calc(var(--sinch-local-shape-radius) + 3px);border-bottom-left-radius:calc(var(--sinch-local-shape-radius) + 3px)}:host(:last-child) #outline{border-top-right-radius:calc(var(--sinch-local-shape-radius) + 3px);border-bottom-right-radius:calc(var(--sinch-local-shape-radius) + 3px)}:host(:not(:first-child)) #outline{left:-4px}#content{font:var(--sinch-comp-segmented-control-font-label);flex-shrink:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;pointer-events:none}::slotted(*){display:block;pointer-events:none}</style><div id="wrapper"><slot name="icon"></slot><span id="content"></span><div id="border"></div><div id="outline"></div></div>';
3
3
  const template = document.createElement('template');
4
4
  template.innerHTML = templateHTML;
5
5
  defineCustomElement('sinch-segmented-control-option', class extends NectaryElement {
6
- #$button;
7
6
  #$label;
7
+ #controller = null;
8
8
  constructor() {
9
9
  super();
10
10
  const shadowRoot = this.attachShadow();
11
11
  shadowRoot.appendChild(template.content.cloneNode(true));
12
- this.#$button = shadowRoot.querySelector('#button');
13
12
  this.#$label = shadowRoot.querySelector('#content');
14
13
  }
15
14
  connectedCallback() {
16
- this.setAttribute('role', 'tab');
17
- this.#$button.addEventListener('click', this.#onButtonClick);
18
- this.#$button.addEventListener('focus', this.#onButtonFocus);
19
- this.#$button.addEventListener('blur', this.#onButtonBlur);
15
+ this.#controller = new AbortController();
16
+ const {
17
+ signal
18
+ } = this.#controller;
19
+ const options = {
20
+ signal
21
+ };
22
+ this.role = 'tab';
23
+ this.addEventListener('focus', this.#onButtonFocus, options);
24
+ this.addEventListener('blur', this.#onButtonBlur, options);
20
25
  this.addEventListener('-focus', this.#onFocusReactHandler);
21
26
  this.addEventListener('-blur', this.#onBlurReactHandler);
27
+ this.#updateTabIndex();
22
28
  }
23
29
  disconnectedCallback() {
24
- this.#$button.removeEventListener('click', this.#onButtonClick);
25
- this.#$button.removeEventListener('focus', this.#onButtonFocus);
26
- this.#$button.removeEventListener('blur', this.#onButtonBlur);
27
- this.removeEventListener('-focus', this.#onFocusReactHandler);
28
- this.removeEventListener('-blur', this.#onBlurReactHandler);
30
+ this.#controller.abort();
31
+ this.#controller = null;
29
32
  }
30
33
  static get observedAttributes() {
31
34
  return ['data-checked', 'disabled', 'text'];
32
35
  }
33
36
  attributeChangedCallback(name, oldVal, newVal) {
34
- if (oldVal === newVal) {
35
- return;
36
- }
37
37
  switch (name) {
38
38
  case 'text':
39
39
  {
@@ -47,8 +47,11 @@ defineCustomElement('sinch-segmented-control-option', class extends NectaryEleme
47
47
  }
48
48
  case 'disabled':
49
49
  {
50
- this.#$button.disabled = isAttrTrue(newVal);
51
- updateBooleanAttribute(this, name, this.#$button.disabled);
50
+ if (isAttrEqual(oldVal, newVal)) {
51
+ return;
52
+ }
53
+ this.#updateTabIndex();
54
+ updateBooleanAttribute(this, name, isAttrTrue(newVal));
52
55
  break;
53
56
  }
54
57
  }
@@ -74,19 +77,9 @@ defineCustomElement('sinch-segmented-control-option', class extends NectaryEleme
74
77
  get focusable() {
75
78
  return true;
76
79
  }
77
- focus() {
78
- this.#$button.focus();
79
- }
80
- blur() {
81
- this.#$button.blur();
80
+ #updateTabIndex() {
81
+ this.tabIndex = this.disabled ? -1 : 0;
82
82
  }
83
- #onButtonClick = e => {
84
- e.stopPropagation();
85
- this.dispatchEvent(new CustomEvent('option-change', {
86
- detail: this.value,
87
- bubbles: true
88
- }));
89
- };
90
83
  #onButtonFocus = () => {
91
84
  this.dispatchEvent(new CustomEvent('-focus'));
92
85
  };