@nectary/components 0.23.0 → 0.25.0

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 (74) hide show
  1. package/accordion/index.js +3 -6
  2. package/accordion-item/index.js +3 -6
  3. package/alert/index.js +3 -5
  4. package/alert-button/index.js +3 -6
  5. package/alert-close/index.js +3 -6
  6. package/avatar/index.js +3 -5
  7. package/avatar-badge/index.js +3 -5
  8. package/avatar-status/index.js +3 -5
  9. package/button/index.js +3 -6
  10. package/card/index.js +3 -6
  11. package/card-button/index.js +3 -6
  12. package/card-container/index.js +3 -6
  13. package/card-link/index.js +3 -6
  14. package/chat/index.js +3 -6
  15. package/chat-avatar/index.js +3 -6
  16. package/chat-block/index.js +3 -6
  17. package/chat-bubble/index.js +3 -6
  18. package/checkbox/index.js +3 -6
  19. package/colors.json +2 -0
  20. package/dialog/index.d.ts +2 -3
  21. package/dialog/index.js +3 -6
  22. package/dropdown/index.js +4 -7
  23. package/dropdown-option/index.d.ts +2 -1
  24. package/dropdown-option/index.js +4 -6
  25. package/grid/index.js +3 -5
  26. package/grid-item/index.js +3 -5
  27. package/help-tooltip/index.js +3 -5
  28. package/icon-button/index.js +3 -6
  29. package/icons/create-icon-class.d.ts +1 -1
  30. package/icons/create-icon-class.js +3 -5
  31. package/icons-branded/create-icon-class.d.ts +1 -1
  32. package/icons-branded/create-icon-class.js +3 -5
  33. package/icons-channel/create-icon-class.d.ts +1 -1
  34. package/icons-channel/create-icon-class.js +3 -5
  35. package/illustration/create-illustration-class.d.ts +1 -1
  36. package/illustration/create-illustration-class.js +3 -5
  37. package/index.d.ts +1 -0
  38. package/index.js +2 -1
  39. package/input/index.js +3 -6
  40. package/link/index.js +5 -26
  41. package/logo/create-logo-class.d.ts +1 -1
  42. package/logo/create-logo-class.js +3 -5
  43. package/package.json +3 -5
  44. package/pagination/index.d.ts +4 -1
  45. package/pagination/index.js +17 -6
  46. package/popover/index.js +3 -6
  47. package/radio/index.js +3 -6
  48. package/radio-option/index.js +3 -6
  49. package/search/index.js +38 -26
  50. package/search-option/index.js +3 -5
  51. package/segment/index.js +3 -6
  52. package/segment-collapse/index.js +13 -33
  53. package/segmented-control/index.d.ts +20 -0
  54. package/segmented-control/index.js +208 -0
  55. package/segmented-control-option/index.d.ts +29 -0
  56. package/segmented-control-option/index.js +112 -0
  57. package/select/index.js +22 -8
  58. package/spinner/index.js +3 -5
  59. package/table/index.js +3 -5
  60. package/table-body/index.js +3 -5
  61. package/table-cell/index.js +3 -5
  62. package/table-head/index.js +3 -5
  63. package/table-head-cell/index.js +3 -5
  64. package/table-row/index.js +3 -5
  65. package/tabs/index.js +4 -7
  66. package/tabs-option/index.js +12 -31
  67. package/tag/index.js +3 -5
  68. package/tag-close/index.js +3 -6
  69. package/textarea/index.js +3 -6
  70. package/title/index.js +3 -6
  71. package/toggle/index.js +3 -6
  72. package/tooltip/index.js +3 -5
  73. package/utils.d.ts +10 -3
  74. package/utils.js +22 -14
package/radio/index.js CHANGED
@@ -12,7 +12,7 @@ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollect
12
12
  function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
13
13
 
14
14
  import { isRadioOptionElement } from '../radio-option';
15
- import { defineCustomElement, getAttribute, updateAttribute } from '../utils';
15
+ import { defineCustomElement, getAttribute, NectaryElement, updateAttribute } from '../utils';
16
16
  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>';
17
17
 
18
18
  const findSelectedOption = elements => {
@@ -21,7 +21,7 @@ const findSelectedOption = elements => {
21
21
 
22
22
  const template = document.createElement('template');
23
23
  template.innerHTML = templateHTML;
24
- defineCustomElement('sinch-radio', (_$slot = new WeakMap(), _onOptionKeyDown = new WeakMap(), _onSlotChange = new WeakMap(), _onOptionChange = new WeakMap(), _onValueChange = new WeakSet(), _dispatchChangeEvent = new WeakSet(), _getFirstOption = new WeakSet(), _getLastOption = new WeakSet(), _getNextOption = new WeakSet(), _getPrevOption = new WeakSet(), _getEnabledRadioElements = new WeakSet(), class extends HTMLElement {
24
+ defineCustomElement('sinch-radio', (_$slot = new WeakMap(), _onOptionKeyDown = new WeakMap(), _onSlotChange = new WeakMap(), _onOptionChange = new WeakMap(), _onValueChange = new WeakSet(), _dispatchChangeEvent = new WeakSet(), _getFirstOption = new WeakSet(), _getLastOption = new WeakSet(), _getNextOption = new WeakSet(), _getPrevOption = new WeakSet(), _getEnabledRadioElements = new WeakSet(), class extends NectaryElement {
25
25
  constructor() {
26
26
  super();
27
27
 
@@ -99,10 +99,7 @@ defineCustomElement('sinch-radio', (_$slot = new WeakMap(), _onOptionKeyDown = n
99
99
  }
100
100
  });
101
101
 
102
- const shadowRoot = this.attachShadow({
103
- mode: 'closed',
104
- delegatesFocus: true
105
- });
102
+ const shadowRoot = this.attachShadow();
106
103
  shadowRoot.appendChild(template.content.cloneNode(true));
107
104
  shadowRoot.addEventListener('keydown', _classPrivateFieldGet(this, _onOptionKeyDown));
108
105
  shadowRoot.addEventListener('change', _classPrivateFieldGet(this, _onOptionChange));
@@ -7,14 +7,14 @@ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedec
7
7
 
8
8
  function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
9
9
 
10
- import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrTrue, updateAttribute, updateBooleanAttribute } from '../utils';
10
+ import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute } from '../utils';
11
11
  const templateHTML = '<style>:host{--sinch-color-radio-outer-circle:var(--sinch-color-transparent);--sinch-color-radio-background:var(--sinch-color-snow-100);--sinch-color-radio-border:var(--sinch-color-stormy-300);--sinch-color-radio-outer-circle-checked:var(--sinch-color-transparent);--sinch-color-radio-border-checked:var(--sinch-color-tropical-500);--sinch-color-radio-outer-circle-hover:var(--sinch-color-snow-500);--sinch-color-radio-border-hover:var(--sinch-color-stormy-300);--sinch-color-radio-outer-circle-hover-checked:var(--sinch-color-tropical-100);--sinch-color-radio-border-hover-checked:var(--sinch-color-tropical-500);--sinch-color-radio-outer-circle-focus:var(--sinch-color-snow-800);--sinch-color-radio-border-focus:var(--sinch-color-stormy-300);--sinch-color-radio-outer-circle-focus-checked:var(--sinch-color-tropical-200);--sinch-color-radio-border-focus-checked:var(--sinch-color-tropical-500);--sinch-color-radio-outer-circle-active:var(--sinch-color-stormy-100);--sinch-color-radio-border-active:var(--sinch-color-stormy-300);--sinch-color-radio-outer-circle-active-checked:var(--sinch-color-tropical-300);--sinch-color-radio-border-active-checked:var(--sinch-color-tropical-500);--sinch-color-radio-outer-circle-disabled:var(--sinch-color-transparent);--sinch-color-radio-border-disabled:var(--sinch-color-stormy-100);--sinch-color-radio-outer-circle-disabled-checked:var(--sinch-color-transparent);--sinch-color-radio-border-disabled-checked:var(--sinch-color-stormy-100);display:block;outline:0}#wrapper{display:flex;height:32px;box-sizing:border-box;width:100%}#input{all:initial;display:block;width:32px;height:32px;cursor:pointer}#input:disabled{cursor:initial}#icon-container{position:relative;width:32px;height:32px}#input::before{content:"";position:absolute;top:0;left:0;width:32px;height:32px;border-radius:50%;pointer-events:none;background-color:var(--sinch-color-radio-outer-circle);transition:background-color .1s linear}#input::after{content:"";position:absolute;top:6px;left:6px;width:20px;height:20px;border-radius:50%;pointer-events:none;background-color:var(--sinch-color-radio-background);box-shadow:0 0 0 2px var(--sinch-color-radio-border) inset;transition:background-color .1s linear}#icon-knob{position:absolute;left:11px;top:11px;width:10px;height:10px;border-radius:50%;transition:opacity .1s linear;opacity:0;background-color:var(--sinch-color-radio-border);pointer-events:none}@media (prefers-reduced-motion){#icon-knob,#input::after,#input::before{transition:none}}#label{align-self:center;flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;padding-left:8px;font:var(--sinch-font-body);color:var(--sinch-color-text-default)}:host([disabled]:not([disabled=false])) #label{color:var(--sinch-color-stormy-200)}#input:checked::before{background-color:var(--sinch-color-radio-outer-circle-checked)}#input:checked::after{box-shadow:0 0 0 2px var(--sinch-color-radio-border-checked) inset}#input:checked~#icon-knob{opacity:1;background-color:var(--sinch-color-radio-border-checked)}#input:focus::before{background-color:var(--sinch-color-radio-outer-circle-focus)}#input:focus::after{box-shadow:0 0 0 2px var(--sinch-color-radio-border-focus) inset}#input:focus~#icon-knob{background-color:var(--sinch-color-radio-border-focus)}#input:hover::before{background-color:var(--sinch-color-radio-outer-circle-hover)}#input:hover::after{box-shadow:0 0 0 2px var(--sinch-color-radio-border-hover) inset}#input:hover~#icon-knob{background-color:var(--sinch-color-radio-border-hover)}#input:active::before{background-color:var(--sinch-color-radio-outer-circle-active)}#input:active::after{box-shadow:0 0 0 2px var(--sinch-color-radio-border-active) inset}#input:active~#icon-knob{background-color:var(--sinch-color-radio-border-active)}#input:disabled::before{background-color:var(--sinch-color-radio-outer-circle-disabled)}#input:disabled::after{box-shadow:0 0 0 2px var(--sinch-color-radio-border-disabled) inset}#input:disabled~#icon-knob{background-color:var(--sinch-color-radio-border-disabled)}#input:focus:checked::before{background-color:var(--sinch-color-radio-outer-circle-focus-checked)}#input:focus:checked::after{box-shadow:0 0 0 2px var(--sinch-color-radio-border-focus-checked) inset}#input:focus:checked~#icon-knob{opacity:1;background-color:var(--sinch-color-radio-border-focus-checked)}#input:hover:checked::before{background-color:var(--sinch-color-radio-outer-circle-hover-checked)}#input:hover:checked::after{box-shadow:0 0 0 2px var(--sinch-color-radio-border-hover-checked) inset}#input:hover:checked~#icon-knob{opacity:1;background-color:var(--sinch-color-radio-border-hover-checked)}#input:active:checked::before{background-color:var(--sinch-color-radio-outer-circle-active-checked)}#input:active:checked::after{box-shadow:0 0 0 2px var(--sinch-color-radio-border-active-checked) inset}#input:active:checked~#icon-knob{opacity:1;background-color:var(--sinch-color-radio-border-active-checked)}#input:disabled:checked::before{background-color:var(--sinch-color-radio-outer-circle-disabled-checked)}#input:disabled:checked::after{box-shadow:0 0 0 2px var(--sinch-color-radio-border-disabled-checked) inset}#input:disabled:checked~#icon-knob{opacity:1;background-color:var(--sinch-color-radio-border-disabled-checked)}</style><div id="wrapper"><div id="icon-container"><input id="input" type="radio"/><div id="icon-knob"></div></div><label for="input" id="label"></label></div>';
12
12
  export const isRadioOptionElement = element => {
13
13
  return element instanceof Element && element.tagName === 'SINCH-RADIO-OPTION';
14
14
  };
15
15
  const template = document.createElement('template');
16
16
  template.innerHTML = templateHTML;
17
- defineCustomElement('sinch-radio-option', (_$input = new WeakMap(), _$label = new WeakMap(), _onInput = new WeakMap(), class extends HTMLElement {
17
+ defineCustomElement('sinch-radio-option', (_$input = new WeakMap(), _$label = new WeakMap(), _onInput = new WeakMap(), class extends NectaryElement {
18
18
  constructor() {
19
19
  super();
20
20
 
@@ -40,10 +40,7 @@ defineCustomElement('sinch-radio-option', (_$input = new WeakMap(), _$label = ne
40
40
  }
41
41
  });
42
42
 
43
- const shadowRoot = this.attachShadow({
44
- mode: 'closed',
45
- delegatesFocus: true
46
- });
43
+ const shadowRoot = this.attachShadow();
47
44
  shadowRoot.appendChild(template.content.cloneNode(true));
48
45
 
49
46
  _classPrivateFieldSet(this, _$input, shadowRoot.querySelector('input'));
package/search/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
2
  import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
3
 
4
- var _$label, _$input, _selectionStart, _selectionEnd, _$optionSlot, _$listbox, _$clear, _isPendingDk, _onCompositionStart, _onInput, _onValueChange, _onClearMouseDown, _onClear, _onInputFocus, _onInputBlur, _onListboxClick, _onListboxKeyPress, _onListboxKeyDown, _onOptionSlotChange, _onExpand, _onCollapse, _getFirstOption, _getLastOption, _getNextOption, _getPrevOption, _selectOption, _getOptionElements;
4
+ var _$label, _$input, _selectionStart, _selectionEnd, _$optionSlot, _$listbox, _$clear, _isPendingDk, _sh, _onCompositionStart, _onInput, _onValueChange, _onClearMouseDown, _onClear, _onInputFocus, _onInputBlur, _onListboxClick, _onListboxKeyUp, _onListboxKeyDown, _onOptionSlotChange, _onExpand, _onCollapse, _setOpen, _isOpen, _getFirstOption, _getLastOption, _getNextOption, _getPrevOption, _selectOption, _getOptionElements;
5
5
 
6
6
  function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
7
7
 
@@ -12,8 +12,8 @@ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollect
12
12
  function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
13
13
 
14
14
  import { isSearchOptionElement } from '../search-option';
15
- import { attrValueToPixels, defineCustomElement, getAttribute, getIntegerAttribute, getRect, updateAttribute, updateIntegerAttribute } from '../utils';
16
- const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{position:relative;width:100%;box-sizing:border-box;--sinch-size-icon:24px}#label{display:none;font:var(--sinch-font-title-s);color:var(--sinch-color-text-default);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:100%;height:24px;margin-bottom:2px}#input{all:initial;display:block;border:1px solid var(--sinch-color-stormy-200);box-sizing:border-box;border-radius:4px;width:100%;height:48px;padding:0 44px;padding-right:12px;font:var(--sinch-font-body);color:var(--sinch-color-text-default);caret-color:var(--sinch-caret-color,auto);background-color:var(--sinch-color-snow-100)}#input::placeholder{font:var(--sinch-font-body);color:var(--sinch-color-text-muted)}#input:focus{border-color:var(--sinch-color-stormy-600)}#icon-search{position:absolute;left:12px;top:12px;pointer-events:none;--sinch-color-icon:var(--sinch-color-stormy-500)}#clear{position:absolute;right:8px;top:8px;display:none;--sinch-color-icon:red}#clear:focus{--sinch-color-icon:var(--sinch-color-stormy-500)}:host([value]:not([value=""])) #clear{display:flex}:host([value]:not([value=""])) #input{padding-right:44px}#listbox{display:none;position:absolute;z-index:1;left:0;top:calc(100% + 8px);width:100%;box-sizing:border-box;font:var(--sinch-font-body);color:var(--sinch-color-text-default);background-color:var(--sinch-color-snow-100);box-shadow:1px 2px 4px rgba(0,0,0,.15);overflow-y:auto;contain:content}:host([aria-expanded=true]) #listbox{display:block}:host([label]:not([label=""])) #label{display:block}</style><label id="label" for="input"></label><div id="wrapper"><input id="input" type="text"/><sinch-icon-search id="icon-search"></sinch-icon-search><sinch-icon-button id="clear" small><sinch-icon-close id="icon-close" slot="icon"></sinch-icon-close></sinch-icon-button><div id="listbox"><slot name="option"></slot></div></div>';
15
+ import { attrValueToPixels, defineCustomElement, getAttribute, getBooleanAttribute, getIntegerAttribute, getRect, NectaryElement, updateAttribute, updateIntegerAttribute } from '../utils';
16
+ const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{position:relative;width:100%;box-sizing:border-box;--sinch-size-icon:24px}#label{display:none;font:var(--sinch-font-title-s);color:var(--sinch-color-text-default);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:100%;height:24px;margin-bottom:2px}#input{all:initial;display:block;border:1px solid var(--sinch-color-stormy-200);box-sizing:border-box;border-radius:4px;width:100%;height:48px;padding:0 44px;padding-right:12px;font:var(--sinch-font-body);color:var(--sinch-color-text-default);caret-color:var(--sinch-caret-color,auto);background-color:var(--sinch-color-snow-100)}#input::placeholder{font:var(--sinch-font-body);color:var(--sinch-color-text-muted)}#input:focus{border-color:var(--sinch-color-stormy-600)}#icon-search{position:absolute;left:12px;top:12px;pointer-events:none;--sinch-color-icon:var(--sinch-color-stormy-500)}#clear{position:absolute;right:8px;top:8px;display:none;--sinch-color-icon:red}#clear:focus{--sinch-color-icon:var(--sinch-color-stormy-500)}:host([value]:not([value=""])) #clear{display:flex}:host([value]:not([value=""])) #input{padding-right:44px}#listbox{display:none;position:absolute;z-index:1;left:0;top:calc(100% + 8px);width:100%;box-sizing:border-box;font:var(--sinch-font-body);color:var(--sinch-color-text-default);background-color:var(--sinch-color-snow-100);box-shadow:1px 2px 4px rgba(0,0,0,.15);overflow-y:auto}:host([aria-expanded=true]) #listbox{display:block}:host([label]:not([label=""])) #label{display:block}</style><label id="label" for="input"></label><div id="wrapper"><input id="input" type="text"/><sinch-icon-search id="icon-search"></sinch-icon-search><sinch-icon-button id="clear" small><sinch-icon-close id="icon-close" slot="icon"></sinch-icon-close></sinch-icon-button><div id="listbox"><slot name="option"></slot></div></div>';
17
17
  import '../icons/search';
18
18
  import '../icons/close';
19
19
  import '../icon-button';
@@ -31,7 +31,7 @@ const findSelectedOption = elements => {
31
31
 
32
32
  const template = document.createElement('template');
33
33
  template.innerHTML = templateHTML;
34
- defineCustomElement('sinch-search', (_$label = new WeakMap(), _$input = new WeakMap(), _selectionStart = new WeakMap(), _selectionEnd = new WeakMap(), _$optionSlot = new WeakMap(), _$listbox = new WeakMap(), _$clear = new WeakMap(), _isPendingDk = new WeakMap(), _onCompositionStart = new WeakMap(), _onInput = new WeakMap(), _onValueChange = new WeakSet(), _onClearMouseDown = new WeakMap(), _onClear = new WeakMap(), _onInputFocus = new WeakMap(), _onInputBlur = new WeakMap(), _onListboxClick = new WeakMap(), _onListboxKeyPress = new WeakMap(), _onListboxKeyDown = new WeakMap(), _onOptionSlotChange = new WeakMap(), _onExpand = new WeakSet(), _onCollapse = new WeakSet(), _getFirstOption = new WeakSet(), _getLastOption = new WeakSet(), _getNextOption = new WeakSet(), _getPrevOption = new WeakSet(), _selectOption = new WeakSet(), _getOptionElements = new WeakSet(), class extends HTMLElement {
34
+ defineCustomElement('sinch-search', (_$label = new WeakMap(), _$input = new WeakMap(), _selectionStart = new WeakMap(), _selectionEnd = new WeakMap(), _$optionSlot = new WeakMap(), _$listbox = new WeakMap(), _$clear = new WeakMap(), _isPendingDk = new WeakMap(), _sh = new WeakMap(), _onCompositionStart = new WeakMap(), _onInput = new WeakMap(), _onValueChange = new WeakSet(), _onClearMouseDown = new WeakMap(), _onClear = new WeakMap(), _onInputFocus = new WeakMap(), _onInputBlur = new WeakMap(), _onListboxClick = new WeakMap(), _onListboxKeyUp = new WeakMap(), _onListboxKeyDown = new WeakMap(), _onOptionSlotChange = new WeakMap(), _onExpand = new WeakSet(), _onCollapse = new WeakSet(), _setOpen = new WeakSet(), _isOpen = new WeakSet(), _getFirstOption = new WeakSet(), _getLastOption = new WeakSet(), _getNextOption = new WeakSet(), _getPrevOption = new WeakSet(), _selectOption = new WeakSet(), _getOptionElements = new WeakSet(), class extends NectaryElement {
35
35
  constructor() {
36
36
  super();
37
37
 
@@ -47,6 +47,10 @@ defineCustomElement('sinch-search', (_$label = new WeakMap(), _$input = new Weak
47
47
 
48
48
  _classPrivateMethodInitSpec(this, _getFirstOption);
49
49
 
50
+ _classPrivateMethodInitSpec(this, _isOpen);
51
+
52
+ _classPrivateMethodInitSpec(this, _setOpen);
53
+
50
54
  _classPrivateMethodInitSpec(this, _onCollapse);
51
55
 
52
56
  _classPrivateMethodInitSpec(this, _onExpand);
@@ -93,6 +97,11 @@ defineCustomElement('sinch-search', (_$label = new WeakMap(), _$input = new Weak
93
97
  value: false
94
98
  });
95
99
 
100
+ _classPrivateFieldInitSpec(this, _sh, {
101
+ writable: true,
102
+ value: void 0
103
+ });
104
+
96
105
  _classPrivateFieldInitSpec(this, _onCompositionStart, {
97
106
  writable: true,
98
107
  value: () => {
@@ -155,7 +164,7 @@ defineCustomElement('sinch-search', (_$label = new WeakMap(), _$input = new Weak
155
164
  }
156
165
  });
157
166
 
158
- _classPrivateFieldInitSpec(this, _onListboxKeyPress, {
167
+ _classPrivateFieldInitSpec(this, _onListboxKeyUp, {
159
168
  writable: true,
160
169
  value: e => {
161
170
  switch (e.code) {
@@ -182,8 +191,6 @@ defineCustomElement('sinch-search', (_$label = new WeakMap(), _$input = new Weak
182
191
  switch (e.code) {
183
192
  case 'ArrowUp':
184
193
  {
185
- e.preventDefault();
186
-
187
194
  _classPrivateMethodGet(this, _selectOption, _selectOption2).call(this, _classPrivateMethodGet(this, _getPrevOption, _getPrevOption2).call(this));
188
195
 
189
196
  break;
@@ -191,8 +198,6 @@ defineCustomElement('sinch-search', (_$label = new WeakMap(), _$input = new Weak
191
198
 
192
199
  case 'ArrowDown':
193
200
  {
194
- e.preventDefault();
195
-
196
201
  _classPrivateMethodGet(this, _selectOption, _selectOption2).call(this, _classPrivateMethodGet(this, _getNextOption, _getNextOption2).call(this));
197
202
 
198
203
  break;
@@ -213,16 +218,21 @@ defineCustomElement('sinch-search', (_$label = new WeakMap(), _$input = new Weak
213
218
  _classPrivateFieldInitSpec(this, _onOptionSlotChange, {
214
219
  writable: true,
215
220
  value: () => {
221
+ const elems = _classPrivateMethodGet(this, _getOptionElements, _getOptionElements2).call(this);
222
+
223
+ if (elems.length === 0) {
224
+ return _classPrivateMethodGet(this, _onCollapse, _onCollapse2).call(this);
225
+ }
226
+
216
227
  _classPrivateMethodGet(this, _onExpand, _onExpand2).call(this);
217
228
  }
218
229
  });
219
230
 
220
- const shadowRoot = this.attachShadow({
221
- mode: 'closed',
222
- delegatesFocus: true
223
- });
231
+ const shadowRoot = this.attachShadow();
224
232
  shadowRoot.appendChild(template.content.cloneNode(true));
225
233
 
234
+ _classPrivateFieldSet(this, _sh, shadowRoot);
235
+
226
236
  _classPrivateFieldSet(this, _$input, shadowRoot.querySelector('#input'));
227
237
 
228
238
  _classPrivateFieldSet(this, _$label, shadowRoot.querySelector('#label'));
@@ -249,9 +259,9 @@ defineCustomElement('sinch-search', (_$label = new WeakMap(), _$input = new Weak
249
259
 
250
260
  _classPrivateFieldGet(this, _$input).addEventListener('keydown', _classPrivateFieldGet(this, _onListboxKeyDown));
251
261
 
252
- _classPrivateFieldGet(this, _$input).addEventListener('keypress', _classPrivateFieldGet(this, _onListboxKeyPress));
262
+ _classPrivateFieldGet(this, _$input).addEventListener('keyup', _classPrivateFieldGet(this, _onListboxKeyUp));
253
263
 
254
- _classPrivateFieldGet(this, _$listbox).addEventListener('click', _classPrivateFieldGet(this, _onListboxClick));
264
+ _classPrivateFieldGet(this, _$listbox).addEventListener('mousedown', _classPrivateFieldGet(this, _onListboxClick));
255
265
 
256
266
  _classPrivateFieldGet(this, _$optionSlot).addEventListener('slotchange', _classPrivateFieldGet(this, _onOptionSlotChange));
257
267
 
@@ -271,9 +281,9 @@ defineCustomElement('sinch-search', (_$label = new WeakMap(), _$input = new Weak
271
281
 
272
282
  _classPrivateFieldGet(this, _$input).removeEventListener('keydown', _classPrivateFieldGet(this, _onListboxKeyDown));
273
283
 
274
- _classPrivateFieldGet(this, _$input).removeEventListener('keypress', _classPrivateFieldGet(this, _onListboxKeyPress));
284
+ _classPrivateFieldGet(this, _$input).removeEventListener('keyup', _classPrivateFieldGet(this, _onListboxKeyUp));
275
285
 
276
- _classPrivateFieldGet(this, _$listbox).removeEventListener('click', _classPrivateFieldGet(this, _onListboxClick));
286
+ _classPrivateFieldGet(this, _$listbox).removeEventListener('mousedown', _classPrivateFieldGet(this, _onListboxClick));
277
287
 
278
288
  _classPrivateFieldGet(this, _$optionSlot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onOptionSlotChange));
279
289
 
@@ -447,21 +457,23 @@ function _onValueChange2(nextValue) {
447
457
  }
448
458
 
449
459
  function _onExpand2() {
450
- const elems = _classPrivateMethodGet(this, _getOptionElements, _getOptionElements2).call(this);
460
+ if (!_classPrivateMethodGet(this, _isOpen, _isOpen2).call(this) && _classPrivateFieldGet(this, _sh).activeElement === _classPrivateFieldGet(this, _$input)) {
461
+ _classPrivateMethodGet(this, _selectOption, _selectOption2).call(this, _classPrivateMethodGet(this, _getFirstOption, _getFirstOption2).call(this));
451
462
 
452
- if (elems.length === 0 || document.activeElement !== this) {
453
- _classPrivateMethodGet(this, _onCollapse, _onCollapse2).call(this);
454
-
455
- return;
463
+ _classPrivateMethodGet(this, _setOpen, _setOpen2).call(this, true);
456
464
  }
465
+ }
457
466
 
458
- this.setAttribute('aria-expanded', 'true');
467
+ function _onCollapse2() {
468
+ _classPrivateMethodGet(this, _setOpen, _setOpen2).call(this, false);
469
+ }
459
470
 
460
- _classPrivateMethodGet(this, _selectOption, _selectOption2).call(this, elems[0]);
471
+ function _setOpen2(isOpen) {
472
+ this.setAttribute('aria-expanded', String(isOpen));
461
473
  }
462
474
 
463
- function _onCollapse2() {
464
- this.setAttribute('aria-expanded', 'false');
475
+ function _isOpen2() {
476
+ return getBooleanAttribute(this, 'aria-expanded');
465
477
  }
466
478
 
467
479
  function _getFirstOption2() {
@@ -5,14 +5,14 @@ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedec
5
5
 
6
6
  function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
7
7
 
8
- import { defineCustomElement, getAttribute, getBooleanAttribute, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
8
+ import { defineCustomElement, getAttribute, getBooleanAttribute, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
9
9
  const templateHTML = '<style>:host{display:block}#wrapper{display:block;box-sizing:border-box;line-height:40px;padding:0 12px;width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}:host(:hover)>#wrapper,:host([data-selected])>#wrapper{background-color:var(--sinch-color-snow-500)}</style><div id="wrapper"></div>';
10
10
  const template = document.createElement('template');
11
11
  template.innerHTML = templateHTML;
12
12
 
13
13
  var _$content = new WeakMap();
14
14
 
15
- class SearchOption extends HTMLElement {
15
+ class SearchOption extends NectaryElement {
16
16
  constructor() {
17
17
  super();
18
18
 
@@ -21,9 +21,7 @@ class SearchOption extends HTMLElement {
21
21
  value: void 0
22
22
  });
23
23
 
24
- const shadowRoot = this.attachShadow({
25
- mode: 'closed'
26
- });
24
+ const shadowRoot = this.attachShadow();
27
25
  shadowRoot.appendChild(template.content.cloneNode(true));
28
26
 
29
27
  _classPrivateFieldSet(this, _$content, shadowRoot.querySelector('#wrapper'));
package/segment/index.js CHANGED
@@ -7,11 +7,11 @@ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedec
7
7
 
8
8
  function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
9
9
 
10
- import { defineCustomElement, getAttribute, getBooleanAttribute, updateAttribute, updateBooleanAttribute } from '../utils';
10
+ import { defineCustomElement, getAttribute, getBooleanAttribute, NectaryElement, updateAttribute, updateBooleanAttribute } from '../utils';
11
11
  const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:column;width:100%;height:100%;border-radius:4px;box-sizing:border-box;background-color:var(--sinch-color-snow-100);color:var(--sinch-color-text-default);font:var(--sinch-font-body);border:none;box-shadow:1px 2px 8px rgba(0,0,0,.1)}#header{position:relative;display:flex;flex-direction:row;align-items:center;gap:16px;height:32px;padding:24px 32px 16px;--sinch-size-icon:32px}#caption{font:var(--sinch-font-title-l);color:var(--sinch-color-text-default);flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#content-wrapper{padding:0 32px;flex:1;min-height:0;overflow:auto}#action{display:flex;flex-direction:row;justify-content:flex-end;gap:16px;padding:16px 32px 24px}#info{position:relative;display:flex;flex-direction:row;align-items:center;gap:16px;z-index:1}:host([collapsed]:not([collapsed=false])) :is(#content-wrapper,#action){display:none}:host([collapsed]:not([collapsed=false])) #header{padding-bottom:24px}</style><div id="wrapper"><div id="header"><slot name="icon"></slot><span id="caption"></span><div id="info"><slot name="info"></slot></div><slot name="collapse"></slot></div><div id="content-wrapper"><slot name="content"></slot></div><div id="action"><slot name="action"></slot></div></div>';
12
12
  const template = document.createElement('template');
13
13
  template.innerHTML = templateHTML;
14
- defineCustomElement('sinch-segment', (_$caption = new WeakMap(), class extends HTMLElement {
14
+ defineCustomElement('sinch-segment', (_$caption = new WeakMap(), class extends NectaryElement {
15
15
  constructor() {
16
16
  super();
17
17
 
@@ -20,10 +20,7 @@ defineCustomElement('sinch-segment', (_$caption = new WeakMap(), class extends H
20
20
  value: void 0
21
21
  });
22
22
 
23
- const shadowRoot = this.attachShadow({
24
- mode: 'closed',
25
- delegatesFocus: true
26
- });
23
+ const shadowRoot = this.attachShadow();
27
24
  shadowRoot.appendChild(template.content.cloneNode(true));
28
25
 
29
26
  _classPrivateFieldSet(this, _$caption, shadowRoot.querySelector('#caption'));
@@ -2,7 +2,7 @@ import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
2
  import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
3
3
  import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
4
4
 
5
- var _$input;
5
+ var _$button;
6
6
 
7
7
  function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
8
8
 
@@ -10,47 +10,41 @@ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollect
10
10
 
11
11
  import '../icons/expand-less';
12
12
  import '../icons/expand-more';
13
- import { defineCustomElement, getBooleanAttribute, isAttrTrue, updateBooleanAttribute } from '../utils';
14
- const templateHTML = '<style>:host{display:contents;--sinch-size-icon:32px}input{all:initial;position:absolute;left:0;top:0;width:100%;height:100%;box-sizing:border-box;cursor:pointer}input:focus~sinch-icon-expand-less,input:focus~sinch-icon-expand-more{border-radius:4px;box-shadow:0 0 0 1px var(--sinch-color-stormy-500) inset}#up{display:block}#down{display:none}:host([value]:not([value=false])) #up{display:none}:host([value]:not([value=false])) #down{display:block}</style><input type="checkbox"/><sinch-icon-expand-less id="up"></sinch-icon-expand-less><sinch-icon-expand-more id="down"></sinch-icon-expand-more>';
13
+ import { defineCustomElement, getBooleanAttribute, NectaryElement, updateBooleanAttribute } from '../utils';
14
+ const templateHTML = '<style>:host{display:contents;--sinch-size-icon:32px}button{all:initial;position:absolute;left:0;top:0;width:100%;height:100%;box-sizing:border-box;cursor:pointer}button:focus~sinch-icon-expand-less,button:focus~sinch-icon-expand-more{border-radius:4px;box-shadow:0 0 0 1px var(--sinch-color-stormy-500) inset}#up{display:block}#down{display:none}:host([value]:not([value=false])) #up{display:none}:host([value]:not([value=false])) #down{display:block}</style><button></button><sinch-icon-expand-less id="up"></sinch-icon-expand-less><sinch-icon-expand-more id="down"></sinch-icon-expand-more>';
15
15
  const template = document.createElement('template');
16
16
  template.innerHTML = templateHTML;
17
- defineCustomElement('sinch-segment-collapse', (_$input = new WeakMap(), class extends HTMLElement {
17
+ defineCustomElement('sinch-segment-collapse', (_$button = new WeakMap(), class extends NectaryElement {
18
18
  constructor() {
19
19
  super();
20
20
 
21
- _classPrivateFieldInitSpec(this, _$input, {
21
+ _classPrivateFieldInitSpec(this, _$button, {
22
22
  writable: true,
23
23
  value: void 0
24
24
  });
25
25
 
26
- _defineProperty(this, 'onCheckboxInput', e => {
26
+ _defineProperty(this, 'onClick', e => {
27
27
  e.stopPropagation();
28
-
29
- const isChecked = _classPrivateFieldGet(this, _$input).checked;
30
-
31
- _classPrivateFieldGet(this, _$input).checked = this.value;
32
28
  this.dispatchEvent(new CustomEvent('change', {
33
- detail: isChecked,
29
+ detail: !this.value,
34
30
  bubbles: true
35
31
  }));
36
32
  });
37
33
 
38
- const shadowRoot = this.attachShadow({
39
- mode: 'closed'
40
- });
34
+ const shadowRoot = this.attachShadow();
41
35
  shadowRoot.appendChild(template.content.cloneNode(true));
42
36
 
43
- _classPrivateFieldSet(this, _$input, shadowRoot.querySelector('input'));
37
+ _classPrivateFieldSet(this, _$button, shadowRoot.querySelector('button'));
44
38
  }
45
39
 
46
40
  connectedCallback() {
47
41
  this.setAttribute('role', 'checkbox');
48
42
 
49
- _classPrivateFieldGet(this, _$input).addEventListener('input', this.onCheckboxInput);
43
+ _classPrivateFieldGet(this, _$button).addEventListener('click', this.onClick);
50
44
  }
51
45
 
52
46
  disconnectedCallback() {
53
- _classPrivateFieldGet(this, _$input).removeEventListener('input', this.onCheckboxInput);
47
+ _classPrivateFieldGet(this, _$button).removeEventListener('click', this.onClick);
54
48
  }
55
49
 
56
50
  get type() {
@@ -61,20 +55,6 @@ defineCustomElement('sinch-segment-collapse', (_$input = new WeakMap(), class ex
61
55
  return 'input';
62
56
  }
63
57
 
64
- static get observedAttributes() {
65
- return ['value'];
66
- }
67
-
68
- attributeChangedCallback(name, _, newVal) {
69
- switch (name) {
70
- case 'value':
71
- {
72
- _classPrivateFieldGet(this, _$input).checked = isAttrTrue(newVal);
73
- break;
74
- }
75
- }
76
- }
77
-
78
58
  set value(isChecked) {
79
59
  updateBooleanAttribute(this, 'value', isChecked);
80
60
  }
@@ -84,11 +64,11 @@ defineCustomElement('sinch-segment-collapse', (_$input = new WeakMap(), class ex
84
64
  }
85
65
 
86
66
  focus() {
87
- _classPrivateFieldGet(this, _$input).focus();
67
+ _classPrivateFieldGet(this, _$button).focus();
88
68
  }
89
69
 
90
70
  blur() {
91
- _classPrivateFieldGet(this, _$input).blur();
71
+ _classPrivateFieldGet(this, _$button).blur();
92
72
  }
93
73
 
94
74
  }));
@@ -0,0 +1,20 @@
1
+ import type { TSinchElementReact } from '../types';
2
+ import type { SyntheticEvent } from 'react';
3
+ export declare type TSinchTabsElement = HTMLElement & {
4
+ value: string;
5
+ };
6
+ export declare type TSinchTabsReact = TSinchElementReact<TSinchTabsElement> & {
7
+ value: string;
8
+ 'aria-label': string;
9
+ onChange: (event: SyntheticEvent<TSinchTabsElement, CustomEvent<string>>) => void;
10
+ };
11
+ declare global {
12
+ namespace JSX {
13
+ interface IntrinsicElements {
14
+ 'sinch-segmented-control': TSinchTabsReact;
15
+ }
16
+ }
17
+ interface HTMLElementTagNameMap {
18
+ 'sinch-segmented-control': TSinchTabsElement;
19
+ }
20
+ }
@@ -0,0 +1,208 @@
1
+ import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
2
+ import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
3
+
4
+ var _$slot, _onOptionKeyDown, _onSlotChange, _onOptionChange, _onValueChange, _dispatchChangeEvent, _getFirstOption, _getLastOption, _getNextOption, _getPrevOption, _getEnabledRadioElements;
5
+
6
+ function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
7
+
8
+ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
9
+
10
+ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
11
+
12
+ function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
13
+
14
+ import { isSegmentedControlOptionElement } from '../segmented-control-option';
15
+ import { defineCustomElement, getAttribute, NectaryElement, updateAttribute } from '../utils';
16
+ 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>';
17
+
18
+ const findSelectedOption = elements => {
19
+ return elements.find(el => el.checked) ?? null;
20
+ };
21
+
22
+ const template = document.createElement('template');
23
+ template.innerHTML = templateHTML;
24
+ defineCustomElement('sinch-segmented-control', (_$slot = new WeakMap(), _onOptionKeyDown = new WeakMap(), _onSlotChange = new WeakMap(), _onOptionChange = new WeakMap(), _onValueChange = new WeakSet(), _dispatchChangeEvent = new WeakSet(), _getFirstOption = new WeakSet(), _getLastOption = new WeakSet(), _getNextOption = new WeakSet(), _getPrevOption = new WeakSet(), _getEnabledRadioElements = new WeakSet(), class extends NectaryElement {
25
+ constructor() {
26
+ super();
27
+
28
+ _classPrivateMethodInitSpec(this, _getEnabledRadioElements);
29
+
30
+ _classPrivateMethodInitSpec(this, _getPrevOption);
31
+
32
+ _classPrivateMethodInitSpec(this, _getNextOption);
33
+
34
+ _classPrivateMethodInitSpec(this, _getLastOption);
35
+
36
+ _classPrivateMethodInitSpec(this, _getFirstOption);
37
+
38
+ _classPrivateMethodInitSpec(this, _dispatchChangeEvent);
39
+
40
+ _classPrivateMethodInitSpec(this, _onValueChange);
41
+
42
+ _classPrivateFieldInitSpec(this, _$slot, {
43
+ writable: true,
44
+ value: void 0
45
+ });
46
+
47
+ _classPrivateFieldInitSpec(this, _onOptionKeyDown, {
48
+ writable: true,
49
+ value: e => {
50
+ switch (e.code) {
51
+ case 'ArrowUp':
52
+ case 'ArrowLeft':
53
+ {
54
+ e.preventDefault();
55
+
56
+ const $option = _classPrivateMethodGet(this, _getPrevOption, _getPrevOption2).call(this);
57
+
58
+ if ($option !== null) {
59
+ $option.focus();
60
+
61
+ _classPrivateMethodGet(this, _dispatchChangeEvent, _dispatchChangeEvent2).call(this, $option.value);
62
+ }
63
+
64
+ break;
65
+ }
66
+
67
+ case 'ArrowDown':
68
+ case 'ArrowRight':
69
+ {
70
+ e.preventDefault();
71
+
72
+ const $option = _classPrivateMethodGet(this, _getNextOption, _getNextOption2).call(this);
73
+
74
+ if ($option !== null) {
75
+ $option.focus();
76
+
77
+ _classPrivateMethodGet(this, _dispatchChangeEvent, _dispatchChangeEvent2).call(this, $option.value);
78
+ }
79
+
80
+ break;
81
+ }
82
+ }
83
+ }
84
+ });
85
+
86
+ _classPrivateFieldInitSpec(this, _onSlotChange, {
87
+ writable: true,
88
+ value: () => {
89
+ _classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this, this.value);
90
+ }
91
+ });
92
+
93
+ _classPrivateFieldInitSpec(this, _onOptionChange, {
94
+ writable: true,
95
+ value: e => {
96
+ e.stopPropagation();
97
+
98
+ _classPrivateMethodGet(this, _dispatchChangeEvent, _dispatchChangeEvent2).call(this, e.detail);
99
+ }
100
+ });
101
+
102
+ const shadowRoot = this.attachShadow();
103
+ shadowRoot.appendChild(template.content.cloneNode(true));
104
+ shadowRoot.addEventListener('keydown', _classPrivateFieldGet(this, _onOptionKeyDown));
105
+ shadowRoot.addEventListener('change', _classPrivateFieldGet(this, _onOptionChange));
106
+
107
+ _classPrivateFieldSet(this, _$slot, shadowRoot.querySelector('slot'));
108
+
109
+ _classPrivateFieldGet(this, _$slot).addEventListener('slotchange', _classPrivateFieldGet(this, _onSlotChange));
110
+ }
111
+
112
+ connectedCallback() {
113
+ this.setAttribute('role', 'tablist');
114
+ }
115
+
116
+ static get observedAttributes() {
117
+ return ['value'];
118
+ }
119
+
120
+ get nodeName() {
121
+ return 'select';
122
+ }
123
+
124
+ set value(value) {
125
+ updateAttribute(this, 'value', value);
126
+ }
127
+
128
+ get value() {
129
+ return getAttribute(this, 'value', '');
130
+ }
131
+
132
+ attributeChangedCallback(name, oldVal, newVal) {
133
+ switch (name) {
134
+ case 'value':
135
+ {
136
+ _classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this, newVal);
137
+
138
+ break;
139
+ }
140
+ }
141
+ }
142
+
143
+ }));
144
+
145
+ function _onValueChange2(value) {
146
+ for (const $option of _classPrivateFieldGet(this, _$slot).assignedElements()) {
147
+ if (isSegmentedControlOptionElement($option)) {
148
+ $option.checked = $option.disabled !== true && $option.value === value;
149
+ }
150
+ }
151
+ }
152
+
153
+ function _dispatchChangeEvent2(value) {
154
+ this.dispatchEvent(new CustomEvent('change', {
155
+ detail: value,
156
+ bubbles: true
157
+ }));
158
+ }
159
+
160
+ function _getFirstOption2() {
161
+ for (const $option of _classPrivateFieldGet(this, _$slot).assignedElements()) {
162
+ if (isSegmentedControlOptionElement($option) && $option.disabled !== true) {
163
+ return $option;
164
+ }
165
+ }
166
+
167
+ return null;
168
+ }
169
+
170
+ function _getLastOption2() {
171
+ for (const $option of _classPrivateFieldGet(this, _$slot).assignedElements().reverse()) {
172
+ if (isSegmentedControlOptionElement($option) && $option.disabled !== true) {
173
+ return $option;
174
+ }
175
+ }
176
+
177
+ return null;
178
+ }
179
+
180
+ function _getNextOption2() {
181
+ const $options = _classPrivateMethodGet(this, _getEnabledRadioElements, _getEnabledRadioElements2).call(this);
182
+
183
+ const $selectedOption = findSelectedOption($options);
184
+ const currentIndex = $selectedOption !== null ? $options.indexOf($selectedOption) : -1;
185
+
186
+ if (currentIndex < 0) {
187
+ return _classPrivateMethodGet(this, _getFirstOption, _getFirstOption2).call(this);
188
+ }
189
+
190
+ return $options[(currentIndex + 1) % $options.length];
191
+ }
192
+
193
+ function _getPrevOption2() {
194
+ const $options = _classPrivateMethodGet(this, _getEnabledRadioElements, _getEnabledRadioElements2).call(this);
195
+
196
+ const $selectedOption = findSelectedOption($options);
197
+ const currentIndex = $selectedOption !== null ? $options.indexOf($selectedOption) : -1;
198
+
199
+ if (currentIndex < 0) {
200
+ return _classPrivateMethodGet(this, _getLastOption, _getLastOption2).call(this);
201
+ }
202
+
203
+ return $options[(currentIndex - 1 + $options.length) % $options.length];
204
+ }
205
+
206
+ function _getEnabledRadioElements2() {
207
+ return _classPrivateFieldGet(this, _$slot).assignedElements().filter(opt => isSegmentedControlOptionElement(opt) && opt.disabled !== true);
208
+ }
@@ -0,0 +1,29 @@
1
+ import type { TSinchElementReact } from '../types';
2
+ import type { FocusEvent } from 'react';
3
+ export declare const isSegmentedControlOptionElement: (element: EventTarget | Element | null) => element is TSinchSegmentedControlOptionElement;
4
+ export declare type TSinchSegmentedControlOptionElement = HTMLElement & {
5
+ value: string;
6
+ disabled: boolean;
7
+ checked: boolean;
8
+ text: string;
9
+ focus(): void;
10
+ blur(): void;
11
+ };
12
+ export declare type TSinchSegmentedControlOptionReact = TSinchElementReact<TSinchSegmentedControlOptionElement> & {
13
+ value: string;
14
+ disabled?: boolean;
15
+ text: string;
16
+ 'aria-label': string;
17
+ onFocus?: (e: FocusEvent<TSinchSegmentedControlOptionElement>) => void;
18
+ onBlur?: (e: FocusEvent<TSinchSegmentedControlOptionElement>) => void;
19
+ };
20
+ declare global {
21
+ namespace JSX {
22
+ interface IntrinsicElements {
23
+ 'sinch-segmented-control-option': TSinchSegmentedControlOptionReact;
24
+ }
25
+ }
26
+ interface HTMLElementTagNameMap {
27
+ 'sinch-segmented-control-option': TSinchSegmentedControlOptionElement;
28
+ }
29
+ }