@nectary/components 0.9.0 → 0.10.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 (84) hide show
  1. package/accordion/index.js +5 -1
  2. package/accordion-item/index.js +7 -7
  3. package/alert/index.js +2 -2
  4. package/alert-button/index.js +1 -1
  5. package/alert-close/index.js +2 -2
  6. package/button/index.d.ts +2 -1
  7. package/button/index.js +7 -3
  8. package/checkbox/index.d.ts +3 -0
  9. package/checkbox/index.js +27 -18
  10. package/dropdown/index.d.ts +34 -0
  11. package/dropdown/index.js +451 -0
  12. package/dropdown-option/index.d.ts +44 -0
  13. package/dropdown-option/index.js +116 -0
  14. package/help-tooltip/index.js +5 -1
  15. package/icon/cancel/index.js +1 -1
  16. package/icon/close/index.js +1 -1
  17. package/icon/create-icon-class.js +1 -1
  18. package/icon/east/index.js +1 -1
  19. package/icon/help-outline/index.js +1 -1
  20. package/icon/more-horiz/index.js +1 -1
  21. package/icon/more-vert/index.js +1 -1
  22. package/icon/north/index.js +1 -1
  23. package/icon/north-east/index.js +1 -1
  24. package/icon/north-west/index.js +1 -1
  25. package/icon/open-in-new/index.js +1 -1
  26. package/icon/south/index.js +1 -1
  27. package/icon/south-east/index.js +1 -1
  28. package/icon/south-west/index.js +1 -1
  29. package/icon/west/index.js +1 -1
  30. package/icon-branded/barchart-down/index.js +1 -1
  31. package/icon-branded/barchart-up/index.js +1 -1
  32. package/icon-branded/campaigns/index.js +1 -1
  33. package/icon-branded/chatbot/index.js +1 -1
  34. package/icon-branded/contact/index.js +1 -1
  35. package/icon-branded/create-icon-class.js +1 -1
  36. package/icon-branded/home/index.js +1 -1
  37. package/icon-branded/multiple-channels/index.js +1 -1
  38. package/icon-branded/rocket/index.js +1 -1
  39. package/icon-branded/settings/index.js +1 -1
  40. package/icon-branded/user/index.js +1 -1
  41. package/icon-branded/users/index.js +1 -1
  42. package/index.d.ts +2 -0
  43. package/index.js +2 -0
  44. package/input/index.d.ts +3 -1
  45. package/input/index.js +59 -11
  46. package/link/index.js +2 -2
  47. package/logo/create-logo-class.js +1 -1
  48. package/logo/sinch-icon/index.js +1 -1
  49. package/logo/sinch-icon-wordmark/index.js +1 -1
  50. package/package.json +1 -1
  51. package/pagination/index.js +1 -6
  52. package/radio/index.d.ts +1 -0
  53. package/radio/index.js +97 -71
  54. package/radio-option/index.d.ts +1 -0
  55. package/radio-option/index.js +4 -1
  56. package/select/index.d.ts +4 -1
  57. package/select/index.js +72 -265
  58. package/select-option/index.d.ts +3 -17
  59. package/select-option/index.js +4 -103
  60. package/spinner/index.js +1 -1
  61. package/table/index.js +1 -1
  62. package/table-body/index.js +1 -1
  63. package/table-cell/index.js +1 -1
  64. package/table-head/index.js +1 -1
  65. package/table-head-cell/index.js +3 -2
  66. package/table-head-sort/index.d.ts +1 -0
  67. package/table-head-sort/index.js +3 -1
  68. package/table-row/index.js +1 -1
  69. package/tabs/index.d.ts +1 -0
  70. package/tabs/index.js +96 -66
  71. package/tabs-option/index.d.ts +1 -0
  72. package/tabs-option/index.js +4 -2
  73. package/tag/index.js +1 -1
  74. package/tag-close/index.js +2 -2
  75. package/textarea/index.d.ts +3 -1
  76. package/textarea/index.js +58 -11
  77. package/theme.css +3 -0
  78. package/toggle/index.d.ts +1 -0
  79. package/toggle/index.js +4 -5
  80. package/tooltip/index.d.ts +2 -1
  81. package/tooltip/index.js +7 -3
  82. package/types.d.ts +7 -0
  83. package/utils.d.ts +3 -0
  84. package/utils.js +17 -0
@@ -8,7 +8,7 @@ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedec
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
10
  import { defineCustomElement, getAttribute, getBooleanAttribute, getLiteralAttribute, updateAttribute, updateBooleanAttribute, updateLiteralAttribute } from '../utils';
11
- const templateHTML = '<style>:host{display:table-cell;border-bottom:1px solid var(--sinch-color-stormy-200);height:48px;vertical-align:middle;padding:0 6px;--sinch-color-icon:var(--sinch-color-stormy-200)}:host(:first-child){padding-left:8px}:host(:last-child){padding-right:8px}#wrapper{position:relative;display:flex;align-items:center;gap:4px;width:100%;height:100%;box-sizing:border-box}#text{flex-shrink:1;min-width:0;font:var(--sinch-font-title-4);color:var(--sinch-color-stormy-200);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}:host([align=center])>#wrapper{justify-content:center}:host([align=end]) #text{margin-left:auto}:host(:is([text=""],:not([text])))>#wrapper{display:none}:host([fit]:not([fit=false])){width:1px}::slotted(sinch-help-tooltip){position:relative;z-index:1}</style><slot name="checkbox"></slot><div id="wrapper"><span id="text"></span><slot name="tooltip"></slot><slot name="sort"></slot></div>';
11
+ const templateHTML = '<style>:host{display:table-cell;border-bottom:1px solid var(--sinch-color-stormy-200);height:48px;vertical-align:middle;padding:0 6px;--sinch-color-icon:var(--sinch-color-stormy-200)}:host(:first-child){padding-left:8px}:host(:last-child){padding-right:8px}#wrapper{position:relative;width:100%;height:100%;box-sizing:border-box;font:var(--sinch-font-title-4);color:var(--sinch-color-stormy-300);display:flex;align-items:center;gap:4px}#text{flex-shrink:1;min-width:0;font:var(--sinch-font-title-4);color:var(--sinch-color-stormy-200);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}:host([align=center])>#wrapper{justify-content:center}:host([align=end]) #text{margin-left:auto}:host(:is([text=""],:not([text])))>#wrapper{display:none}:host([fit]:not([fit=false])){width:1px}::slotted(sinch-help-tooltip){position:relative;z-index:1}</style><slot name="checkbox"></slot><div id="wrapper"><span id="text"></span><slot name="tooltip"></slot><slot name="sort"></slot></div>';
12
12
  const template = document.createElement('template');
13
13
  template.innerHTML = templateHTML;
14
14
  const alignValues = ['start', 'center', 'end'];
@@ -22,7 +22,7 @@ defineCustomElement('sinch-table-head-cell', (_$text = new WeakMap(), class exte
22
22
  });
23
23
 
24
24
  const shadowRoot = this.attachShadow({
25
- mode: 'production' === 'development' ? 'open' : 'closed'
25
+ mode: 'closed'
26
26
  });
27
27
  shadowRoot.appendChild(template.content.cloneNode(true));
28
28
 
@@ -31,6 +31,7 @@ defineCustomElement('sinch-table-head-cell', (_$text = new WeakMap(), class exte
31
31
 
32
32
  connectedCallback() {
33
33
  this.setAttribute('role', 'columnheader');
34
+ this.setAttribute('scope', 'col');
34
35
  }
35
36
 
36
37
  static get observedAttributes() {
@@ -9,6 +9,7 @@ export declare type TSinchTableHeaderSortElement = HTMLElement & {
9
9
  };
10
10
  export declare type TSinchTableHeaderSortReact = TSinchElementReact<TSinchTableHeaderSortElement> & {
11
11
  value: boolean;
12
+ 'aria-label': string;
12
13
  onChange: (e: SyntheticEvent<TSinchTableHeaderSortElement, CustomEvent<boolean>>) => void;
13
14
  onFocus?: (e: FocusEvent<TSinchTableHeaderSortElement>) => void;
14
15
  onBlur?: (e: FocusEvent<TSinchTableHeaderSortElement>) => void;
@@ -36,7 +36,7 @@ defineCustomElement('sinch-table-head-sort', (_$input = new WeakMap(), class ext
36
36
  });
37
37
 
38
38
  const shadowRoot = this.attachShadow({
39
- mode: 'production' === 'development' ? 'open' : 'closed'
39
+ mode: 'closed'
40
40
  });
41
41
  shadowRoot.appendChild(template.content.cloneNode(true));
42
42
 
@@ -44,6 +44,8 @@ defineCustomElement('sinch-table-head-sort', (_$input = new WeakMap(), class ext
44
44
  }
45
45
 
46
46
  connectedCallback() {
47
+ this.setAttribute('role', 'checkbox');
48
+
47
49
  _classPrivateFieldGet(this, _$input).addEventListener('input', this.onCheckboxInput);
48
50
  }
49
51
 
@@ -6,7 +6,7 @@ defineCustomElement('sinch-table-row', class extends HTMLElement {
6
6
  constructor() {
7
7
  super();
8
8
  const shadowRoot = this.attachShadow({
9
- mode: 'production' === 'development' ? 'open' : 'closed'
9
+ mode: 'closed'
10
10
  });
11
11
  shadowRoot.appendChild(template.content.cloneNode(true));
12
12
  }
package/tabs/index.d.ts CHANGED
@@ -5,6 +5,7 @@ export declare type TSinchTabsElement = HTMLElement & {
5
5
  };
6
6
  export declare type TSinchTabsReact = TSinchElementReact<TSinchTabsElement> & {
7
7
  value: string;
8
+ 'aria-label': string;
8
9
  onChange: (event: SyntheticEvent<TSinchTabsElement, CustomEvent<string>>) => void;
9
10
  };
10
11
  declare global {
package/tabs/index.js CHANGED
@@ -1,73 +1,43 @@
1
1
  import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
2
2
  import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
3
3
 
4
- var _$slot, _onOptionKeyDown, _onSlotChange, _onOptionChange;
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); }
5
7
 
6
8
  function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
7
9
 
8
10
  function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
9
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
+
10
14
  import { isTabsOptionElement } from '../tabs-option';
11
15
  import { defineCustomElement, getAttribute, updateAttribute } from '../utils';
12
16
  const templateHTML = '<style>:host{display:block;outline:0}#wrapper{display:flex;flex-direction:row;height:60px;width:100%;box-sizing:border-box;overflow-x:auto}</style><div id="wrapper"><slot></slot></div>';
13
17
 
14
- const getEnabledRadioElements = $slot => {
15
- return $slot.assignedElements().filter(opt => isTabsOptionElement(opt) && opt.disabled !== true);
16
- };
17
-
18
18
  const findSelectedOption = elements => {
19
19
  return elements.find(el => el.checked) ?? null;
20
20
  };
21
21
 
22
- const getFirstOption = $slot => {
23
- for (const $option of $slot.assignedElements()) {
24
- if (isTabsOptionElement($option) && $option.disabled !== true) {
25
- return $option;
26
- }
27
- }
28
-
29
- return null;
30
- };
31
-
32
- const getLastOption = $slot => {
33
- for (const $option of $slot.assignedElements().reverse()) {
34
- if (isTabsOptionElement($option) && $option.disabled !== true) {
35
- return $option;
36
- }
37
- }
38
-
39
- return null;
40
- };
22
+ const template = document.createElement('template');
23
+ template.innerHTML = templateHTML;
24
+ defineCustomElement('sinch-tabs', (_$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 {
25
+ constructor() {
26
+ super();
41
27
 
42
- const getNextOption = $slot => {
43
- const $options = getEnabledRadioElements($slot);
44
- const $selectedOption = findSelectedOption($options);
45
- const currentIndex = $selectedOption !== null ? $options.indexOf($selectedOption) : -1;
28
+ _classPrivateMethodInitSpec(this, _getEnabledRadioElements);
46
29
 
47
- if (currentIndex < 0) {
48
- return getFirstOption($slot);
49
- }
30
+ _classPrivateMethodInitSpec(this, _getPrevOption);
50
31
 
51
- return $options[(currentIndex + 1) % $options.length];
52
- };
32
+ _classPrivateMethodInitSpec(this, _getNextOption);
53
33
 
54
- const getPrevOption = $slot => {
55
- const $options = getEnabledRadioElements($slot);
56
- const $selectedOption = findSelectedOption($options);
57
- const currentIndex = $selectedOption !== null ? $options.indexOf($selectedOption) : -1;
34
+ _classPrivateMethodInitSpec(this, _getLastOption);
58
35
 
59
- if (currentIndex < 0) {
60
- return getLastOption($slot);
61
- }
36
+ _classPrivateMethodInitSpec(this, _getFirstOption);
62
37
 
63
- return $options[(currentIndex - 1 + $options.length) % $options.length];
64
- };
38
+ _classPrivateMethodInitSpec(this, _dispatchChangeEvent);
65
39
 
66
- const template = document.createElement('template');
67
- template.innerHTML = templateHTML;
68
- defineCustomElement('sinch-tabs', (_$slot = new WeakMap(), _onOptionKeyDown = new WeakMap(), _onSlotChange = new WeakMap(), _onOptionChange = new WeakMap(), class extends HTMLElement {
69
- constructor() {
70
- super();
40
+ _classPrivateMethodInitSpec(this, _onValueChange);
71
41
 
72
42
  _classPrivateFieldInitSpec(this, _$slot, {
73
43
  writable: true,
@@ -82,11 +52,13 @@ defineCustomElement('sinch-tabs', (_$slot = new WeakMap(), _onOptionKeyDown = ne
82
52
  case 'ArrowLeft':
83
53
  {
84
54
  e.preventDefault();
85
- const $option = getPrevOption(_classPrivateFieldGet(this, _$slot));
55
+
56
+ const $option = _classPrivateMethodGet(this, _getPrevOption, _getPrevOption2).call(this);
86
57
 
87
58
  if ($option !== null) {
88
59
  $option.focus();
89
- this.dispatchChangeEvent($option.value);
60
+
61
+ _classPrivateMethodGet(this, _dispatchChangeEvent, _dispatchChangeEvent2).call(this, $option.value);
90
62
  }
91
63
 
92
64
  break;
@@ -96,11 +68,13 @@ defineCustomElement('sinch-tabs', (_$slot = new WeakMap(), _onOptionKeyDown = ne
96
68
  case 'ArrowRight':
97
69
  {
98
70
  e.preventDefault();
99
- const $option = getNextOption(_classPrivateFieldGet(this, _$slot));
71
+
72
+ const $option = _classPrivateMethodGet(this, _getNextOption, _getNextOption2).call(this);
100
73
 
101
74
  if ($option !== null) {
102
75
  $option.focus();
103
- this.dispatchChangeEvent($option.value);
76
+
77
+ _classPrivateMethodGet(this, _dispatchChangeEvent, _dispatchChangeEvent2).call(this, $option.value);
104
78
  }
105
79
 
106
80
  break;
@@ -112,7 +86,7 @@ defineCustomElement('sinch-tabs', (_$slot = new WeakMap(), _onOptionKeyDown = ne
112
86
  _classPrivateFieldInitSpec(this, _onSlotChange, {
113
87
  writable: true,
114
88
  value: () => {
115
- this.onValueChange(this.value);
89
+ _classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this, this.value);
116
90
  }
117
91
  });
118
92
 
@@ -120,12 +94,13 @@ defineCustomElement('sinch-tabs', (_$slot = new WeakMap(), _onOptionKeyDown = ne
120
94
  writable: true,
121
95
  value: e => {
122
96
  e.stopPropagation();
123
- this.dispatchChangeEvent(e.detail);
97
+
98
+ _classPrivateMethodGet(this, _dispatchChangeEvent, _dispatchChangeEvent2).call(this, e.detail);
124
99
  }
125
100
  });
126
101
 
127
102
  const shadowRoot = this.attachShadow({
128
- mode: 'production' === 'development' ? 'open' : 'closed',
103
+ mode: 'closed',
129
104
  delegatesFocus: true
130
105
  });
131
106
  shadowRoot.appendChild(template.content.cloneNode(true));
@@ -137,6 +112,10 @@ defineCustomElement('sinch-tabs', (_$slot = new WeakMap(), _onOptionKeyDown = ne
137
112
  _classPrivateFieldGet(this, _$slot).addEventListener('slotchange', _classPrivateFieldGet(this, _onSlotChange));
138
113
  }
139
114
 
115
+ connectedCallback() {
116
+ this.setAttribute('role', 'tablist');
117
+ }
118
+
140
119
  static get observedAttributes() {
141
120
  return ['value'];
142
121
  }
@@ -157,25 +136,76 @@ defineCustomElement('sinch-tabs', (_$slot = new WeakMap(), _onOptionKeyDown = ne
157
136
  switch (name) {
158
137
  case 'value':
159
138
  {
160
- this.onValueChange(newVal ?? '');
139
+ _classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this, newVal);
140
+
161
141
  break;
162
142
  }
163
143
  }
164
144
  }
165
145
 
166
- onValueChange(value) {
167
- for (const $option of _classPrivateFieldGet(this, _$slot).assignedElements()) {
168
- if (isTabsOptionElement($option)) {
169
- $option.checked = $option.disabled !== true && $option.value === value;
170
- }
146
+ }));
147
+
148
+ function _onValueChange2(value) {
149
+ for (const $option of _classPrivateFieldGet(this, _$slot).assignedElements()) {
150
+ if (isTabsOptionElement($option)) {
151
+ $option.checked = $option.disabled !== true && $option.value === value;
152
+ }
153
+ }
154
+ }
155
+
156
+ function _dispatchChangeEvent2(value) {
157
+ this.dispatchEvent(new CustomEvent('change', {
158
+ detail: value,
159
+ bubbles: true
160
+ }));
161
+ }
162
+
163
+ function _getFirstOption2() {
164
+ for (const $option of _classPrivateFieldGet(this, _$slot).assignedElements()) {
165
+ if (isTabsOptionElement($option) && $option.disabled !== true) {
166
+ return $option;
167
+ }
168
+ }
169
+
170
+ return null;
171
+ }
172
+
173
+ function _getLastOption2() {
174
+ for (const $option of _classPrivateFieldGet(this, _$slot).assignedElements().reverse()) {
175
+ if (isTabsOptionElement($option) && $option.disabled !== true) {
176
+ return $option;
171
177
  }
172
178
  }
173
179
 
174
- dispatchChangeEvent(value) {
175
- this.dispatchEvent(new CustomEvent('change', {
176
- detail: value,
177
- bubbles: true
178
- }));
180
+ return null;
181
+ }
182
+
183
+ function _getNextOption2() {
184
+ const $options = _classPrivateMethodGet(this, _getEnabledRadioElements, _getEnabledRadioElements2).call(this);
185
+
186
+ const $selectedOption = findSelectedOption($options);
187
+ const currentIndex = $selectedOption !== null ? $options.indexOf($selectedOption) : -1;
188
+
189
+ if (currentIndex < 0) {
190
+ return _classPrivateMethodGet(this, _getFirstOption, _getFirstOption2).call(this);
191
+ }
192
+
193
+ return $options[(currentIndex + 1) % $options.length];
194
+ }
195
+
196
+ function _getPrevOption2() {
197
+ const $options = _classPrivateMethodGet(this, _getEnabledRadioElements, _getEnabledRadioElements2).call(this);
198
+
199
+ const $selectedOption = findSelectedOption($options);
200
+ const currentIndex = $selectedOption !== null ? $options.indexOf($selectedOption) : -1;
201
+
202
+ if (currentIndex < 0) {
203
+ return _classPrivateMethodGet(this, _getLastOption, _getLastOption2).call(this);
179
204
  }
180
205
 
181
- }));
206
+ return $options[(currentIndex - 1 + $options.length) % $options.length];
207
+ }
208
+
209
+ function _getEnabledRadioElements2() {
210
+ return _classPrivateFieldGet(this, _$slot).assignedElements().filter(opt => isTabsOptionElement(opt) && opt.disabled !== true);
211
+ }
@@ -13,6 +13,7 @@ export declare type TSinchTabsOptionReact = TSinchElementReact<TSinchTabsOptionE
13
13
  value: string;
14
14
  disabled?: boolean;
15
15
  text: string;
16
+ 'aria-label': string;
16
17
  onFocus?: (e: FocusEvent<TSinchTabsOptionElement>) => void;
17
18
  onBlur?: (e: FocusEvent<TSinchTabsOptionElement>) => void;
18
19
  };
@@ -7,7 +7,7 @@ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedec
7
7
  function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
8
8
 
9
9
  import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrTrue, updateAttribute, updateBooleanAttribute } from '../utils';
10
- const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}*{pointer-events:none}#wrapper{display:flex;flex-direction:row;align-items:center;gap:12px;position:relative;width:100%;height:42px;padding:8px 20px;box-sizing:border-box;box-shadow:0 1px 0 0 var(--sinch-color-stormy-100);font:var(--sinch-font-body);color:var(--sinch-color-text-default)}#content{flex-shrink:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}:host([checked]) #wrapper{box-shadow:0 2px 0 0 var(--sinch-color-stormy-500);font:var(--sinch-font-emphasized-body)}input{all:initial;position:absolute;left:0;top:0;box-sizing:border-box;width:100%;height:100%;cursor:pointer}:host([disabled]:not([disabled=false])) #wrapper{color:var(--sinch-color-stormy-100);--sinch-color-icon:var(--sinch-color-stormy-100)}input:disabled{cursor:unset}</style><div id="wrapper"><slot name="icon"></slot><span id="content"></span> <input type="radio"/></div>';
10
+ const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}*{pointer-events:none}#wrapper{display:flex;flex-direction:row;align-items:center;gap:12px;position:relative;width:100%;height:42px;padding:8px 20px;box-sizing:border-box;box-shadow:0 1px 0 0 var(--sinch-color-stormy-100);font:var(--sinch-font-body);color:var(--sinch-color-text-default)}#content{flex-shrink:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}:host([checked]) #wrapper{box-shadow:0 2px 0 0 var(--sinch-color-stormy-500);font:var(--sinch-font-emphasized-body)}input{all:initial;position:absolute;left:0;top:0;box-sizing:border-box;width:100%;height:100%;cursor:pointer}:host([disabled]:not([disabled=false])) #wrapper{color:var(--sinch-color-stormy-100);--sinch-color-icon:var(--sinch-color-stormy-100)}input:disabled{cursor:unset}</style><div id="wrapper"><slot name="icon"></slot><label for="input" id="content" aria-hidden="true"></label> <input id="input" type="radio" aria-hidden="true"/></div>';
11
11
  export const isTabsOptionElement = element => {
12
12
  return element instanceof Element && element.tagName === 'SINCH-TABS-OPTION';
13
13
  };
@@ -30,7 +30,7 @@ defineCustomElement('sinch-tabs-option', (_onInput = new WeakMap(), class extend
30
30
  });
31
31
 
32
32
  const shadowRoot = this.attachShadow({
33
- mode: 'production' === 'development' ? 'open' : 'closed',
33
+ mode: 'closed',
34
34
  delegatesFocus: true
35
35
  });
36
36
  shadowRoot.appendChild(template.content.cloneNode(true));
@@ -39,6 +39,7 @@ defineCustomElement('sinch-tabs-option', (_onInput = new WeakMap(), class extend
39
39
  }
40
40
 
41
41
  connectedCallback() {
42
+ this.setAttribute('role', 'tab');
42
43
  this.$input.addEventListener('input', _classPrivateFieldGet(this, _onInput));
43
44
  }
44
45
 
@@ -101,6 +102,7 @@ defineCustomElement('sinch-tabs-option', (_onInput = new WeakMap(), class extend
101
102
  });
102
103
  }
103
104
 
105
+ updateAttribute(this, 'aria-selected', isAttrTrue(newVal));
104
106
  break;
105
107
  }
106
108
 
package/tag/index.js CHANGED
@@ -23,7 +23,7 @@ defineCustomElement('sinch-tag', (_$text = new WeakMap(), class extends HTMLElem
23
23
  });
24
24
 
25
25
  const shadowRoot = this.attachShadow({
26
- mode: 'production' === 'development' ? 'open' : 'closed'
26
+ mode: 'closed'
27
27
  });
28
28
  shadowRoot.appendChild(template.content.cloneNode(true));
29
29
 
@@ -9,7 +9,7 @@ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollect
9
9
 
10
10
  import '../icon/cancel';
11
11
  import { defineCustomElement, getBooleanAttribute, updateAttribute, isAttrTrue } from '../utils';
12
- const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{position:relative;width:14px;height:14px}:host([small]:not([small=false])) #wrapper{width:12px;height:12px}button{all:initial;position:absolute;display:flex;align-items:center;justify-content:center;width:24px;height:24px;box-sizing:border-box;left:50%;top:50%;transform:translateX(-50%) translateY(-50%);cursor:pointer}button>*{pointer-events:none}</style><div id="wrapper"><button><sinch-icon-cancel></sinch-icon-cancel></button></div>';
12
+ const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{position:relative;width:14px;height:14px}:host([small]:not([small=false])) #wrapper{width:12px;height:12px}button{all:initial;position:absolute;display:flex;align-items:center;justify-content:center;width:24px;height:24px;box-sizing:border-box;left:50%;top:50%;transform:translateX(-50%) translateY(-50%);cursor:pointer}button>*{pointer-events:none}</style><div id="wrapper"><button aria-label="dismiss tag"><sinch-icon-cancel></sinch-icon-cancel></button></div>';
13
13
  const template = document.createElement('template');
14
14
  template.innerHTML = templateHTML;
15
15
  defineCustomElement('sinch-tag-close', (_$icon = new WeakMap(), _$button = new WeakMap(), class extends HTMLElement {
@@ -27,7 +27,7 @@ defineCustomElement('sinch-tag-close', (_$icon = new WeakMap(), _$button = new W
27
27
  });
28
28
 
29
29
  const shadowRoot = this.attachShadow({
30
- mode: 'production' === 'development' ? 'open' : 'closed',
30
+ mode: 'closed',
31
31
  delegatesFocus: true
32
32
  });
33
33
  shadowRoot.appendChild(template.content.cloneNode(true));
@@ -1,5 +1,5 @@
1
1
  import type { TSinchElementReact } from '../types';
2
- import type { FocusEvent, SyntheticEvent } from 'react';
2
+ import type { DOMAttributes, FocusEvent, SyntheticEvent } from 'react';
3
3
  export declare type TSinchTextareaElement = HTMLElement & {
4
4
  value: string;
5
5
  label: string;
@@ -19,7 +19,9 @@ export declare type TSinchTextareaReact = TSinchElementReact<TSinchTextareaEleme
19
19
  invalidText?: string;
20
20
  additionalText?: string;
21
21
  disabled?: boolean;
22
+ 'aria-label': string;
22
23
  onChange: (e: SyntheticEvent<TSinchTextareaElement, CustomEvent<string>>) => void;
24
+ onKeyPress?: DOMAttributes<TSinchTextareaElement>['onKeyPress'];
23
25
  onFocus?: (e: FocusEvent<TSinchTextareaElement>) => void;
24
26
  onBlur?: (e: FocusEvent<TSinchTextareaElement>) => void;
25
27
  };
package/textarea/index.js CHANGED
@@ -1,17 +1,17 @@
1
1
  import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
2
  import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
3
 
4
- var _$input, _$label, _$optionalText, _$additionalText, _$invalidText, _onInput;
4
+ var _$input, _$label, _$optionalText, _$additionalText, _$invalidText, _selectionStart, _selectionEnd, _onInput;
5
5
 
6
6
  function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
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
10
  import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrTrue, updateAttribute, updateBooleanAttribute } from '../utils';
11
- const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{width:100%;box-sizing:border-box}#input{all:initial;border:1px solid var(--sinch-color-stormy-200);box-sizing:border-box;border-radius:2px;width:100%;min-height:86px;margin:2px 0;padding:8px 12px;font:var(--sinch-font-body);color:var(--sinch-color-text-default);caret-color:var(--sinch-caret-color,auto);resize:vertical}#input::placeholder{font:var(--sinch-font-body);color:var(--sinch-color-text-muted)}#input:disabled{border-color:var(--sinch-color-snow-500);color:var(--sinch-color-stormy-100)}#input:disabled::placeholder{color:var(--sinch-color-snow-500)}#input:focus{border-color:var(--sinch-color-stormy-300)}:host([invalidtext]:not([invalidtext=""])) #input:not(:disabled){border-color:var(--sinch-color-text-invalid)}#bottom,#top{display:flex;align-items:baseline}#top{height:24px}#bottom{height:20px}#additional,#invalid,#label,#optional{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#label{font:var(--sinch-font-title-4);color:var(--sinch-color-text-default)}#optional{flex:1;text-align:right;font:var(--sinch-font-small-text);color:var(--sinch-color-text-muted)}#additional{flex:1;text-align:right;font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-muted)}#invalid{font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-invalid)}::slotted(sinch-help-tooltip){align-self:center;margin:0 8px}:host([disabled]:not([disabled=false])) :is(#label,#additional,#optional,#invalid){color:var(--sinch-color-stormy-100)}:host([disabled]:not([disabled=false])){--sinch-color-icon:var(--sinch-color-stormy-100)}</style><div id="wrapper"><div id="top"><label id="label" for="input"></label><slot name="tooltip"></slot><span id="optional"></span></div><textarea id="input" rows="3"></textarea><div id="bottom"><span id="invalid"></span> <span id="additional"></span></div></div>';
11
+ const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0;--sinch-color-icon:var(--sinch-color-stormy-500)}#wrapper{width:100%;box-sizing:border-box}#input{all:initial;border:1px solid var(--sinch-color-stormy-200);box-sizing:border-box;border-radius:2px;width:100%;min-height:86px;margin:2px 0;padding:8px 12px;font:var(--sinch-font-body);color:var(--sinch-color-text-default);caret-color:var(--sinch-caret-color,auto);resize:vertical}#input::placeholder{font:var(--sinch-font-body);color:var(--sinch-color-text-muted)}#input:disabled{border-color:var(--sinch-color-snow-500);color:var(--sinch-color-stormy-100)}#input:disabled::placeholder{color:var(--sinch-color-snow-500)}#input:focus{border-color:var(--sinch-color-stormy-300)}:host([invalidtext]:not([invalidtext=""])) #input:not(:disabled){border-color:var(--sinch-color-text-invalid)}#bottom,#top{display:flex;align-items:baseline}#top{height:24px}#bottom{height:20px}#additional,#invalid,#label,#optional{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#label{font:var(--sinch-font-title-4);color:var(--sinch-color-text-default)}#optional{flex:1;text-align:right;font:var(--sinch-font-small-text);color:var(--sinch-color-text-muted)}#additional{flex:1;text-align:right;font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-muted)}#invalid{font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-invalid)}::slotted(sinch-help-tooltip){align-self:center;margin:0 8px}:host([disabled]:not([disabled=false])) :is(#label,#additional,#optional,#invalid){color:var(--sinch-color-stormy-100)}:host([disabled]:not([disabled=false])){--sinch-color-icon:var(--sinch-color-stormy-100)}</style><div id="wrapper"><div id="top"><label id="label" for="input"></label><slot name="tooltip"></slot><span id="optional"></span></div><textarea id="input" rows="3"></textarea><div id="bottom"><span id="invalid"></span> <span id="additional"></span></div></div>';
12
12
  const template = document.createElement('template');
13
13
  template.innerHTML = templateHTML;
14
- defineCustomElement('sinch-textarea', (_$input = new WeakMap(), _$label = new WeakMap(), _$optionalText = new WeakMap(), _$additionalText = new WeakMap(), _$invalidText = new WeakMap(), _onInput = new WeakMap(), class extends HTMLElement {
14
+ defineCustomElement('sinch-textarea', (_$input = new WeakMap(), _$label = new WeakMap(), _$optionalText = new WeakMap(), _$additionalText = new WeakMap(), _$invalidText = new WeakMap(), _selectionStart = new WeakMap(), _selectionEnd = new WeakMap(), _onInput = new WeakMap(), class extends HTMLElement {
15
15
  constructor() {
16
16
  super();
17
17
 
@@ -40,23 +40,55 @@ defineCustomElement('sinch-textarea', (_$input = new WeakMap(), _$label = new We
40
40
  value: void 0
41
41
  });
42
42
 
43
+ _classPrivateFieldInitSpec(this, _selectionStart, {
44
+ writable: true,
45
+ value: null
46
+ });
47
+
48
+ _classPrivateFieldInitSpec(this, _selectionEnd, {
49
+ writable: true,
50
+ value: null
51
+ });
52
+
43
53
  _classPrivateFieldInitSpec(this, _onInput, {
44
54
  writable: true,
45
55
  value: e => {
46
56
  e.stopPropagation();
47
57
 
48
- const value = _classPrivateFieldGet(this, _$input).value;
58
+ const nextValue = _classPrivateFieldGet(this, _$input).value;
59
+
60
+ const prevValue = this.value;
61
+
62
+ if (prevValue !== nextValue) {
63
+ const nextSelectionStart = _classPrivateFieldGet(this, _$input).selectionStart;
64
+
65
+ const nextSelectionEnd = _classPrivateFieldGet(this, _$input).selectionEnd;
66
+
67
+ const prevSelectionStart = _classPrivateFieldGet(this, _selectionStart);
49
68
 
50
- _classPrivateFieldGet(this, _$input).value = this.value;
51
- this.dispatchEvent(new CustomEvent('change', {
52
- detail: value,
53
- bubbles: true
54
- }));
69
+ const prevSelectionEnd = _classPrivateFieldGet(this, _selectionEnd);
70
+
71
+ const isPrevCursorEnd = prevSelectionStart === prevSelectionEnd && prevSelectionStart === prevValue.length;
72
+ _classPrivateFieldGet(this, _$input).value = prevValue;
73
+
74
+ if (!isPrevCursorEnd) {
75
+ _classPrivateFieldGet(this, _$input).setSelectionRange(prevSelectionStart, prevSelectionEnd);
76
+ }
77
+
78
+ _classPrivateFieldSet(this, _selectionStart, nextSelectionStart);
79
+
80
+ _classPrivateFieldSet(this, _selectionEnd, nextSelectionEnd);
81
+
82
+ this.dispatchEvent(new CustomEvent('change', {
83
+ detail: nextValue,
84
+ bubbles: true
85
+ }));
86
+ }
55
87
  }
56
88
  });
57
89
 
58
90
  const shadowRoot = this.attachShadow({
59
- mode: 'production' === 'development' ? 'open' : 'closed',
91
+ mode: 'closed',
60
92
  delegatesFocus: true
61
93
  });
62
94
  shadowRoot.appendChild(template.content.cloneNode(true));
@@ -73,6 +105,9 @@ defineCustomElement('sinch-textarea', (_$input = new WeakMap(), _$label = new We
73
105
  }
74
106
 
75
107
  connectedCallback() {
108
+ this.setAttribute('role', 'textbox');
109
+ this.setAttribute('aria-multiline', 'true');
110
+
76
111
  _classPrivateFieldGet(this, _$input).addEventListener('input', _classPrivateFieldGet(this, _onInput));
77
112
  }
78
113
 
@@ -88,7 +123,17 @@ defineCustomElement('sinch-textarea', (_$input = new WeakMap(), _$label = new We
88
123
  switch (name) {
89
124
  case 'value':
90
125
  {
91
- _classPrivateFieldGet(this, _$input).value = newVal ?? '';
126
+ const nextVal = newVal ?? '';
127
+
128
+ if (nextVal !== _classPrivateFieldGet(this, _$input).value) {
129
+ _classPrivateFieldGet(this, _$input).value = nextVal;
130
+ const isNextCursorEnd = _classPrivateFieldGet(this, _selectionStart) === _classPrivateFieldGet(this, _selectionEnd) && (_classPrivateFieldGet(this, _selectionStart) === null || _classPrivateFieldGet(this, _selectionStart) === nextVal.length);
131
+
132
+ if (!isNextCursorEnd) {
133
+ _classPrivateFieldGet(this, _$input).setSelectionRange(_classPrivateFieldGet(this, _selectionStart), _classPrivateFieldGet(this, _selectionEnd));
134
+ }
135
+ }
136
+
92
137
  break;
93
138
  }
94
139
 
@@ -101,6 +146,7 @@ defineCustomElement('sinch-textarea', (_$input = new WeakMap(), _$label = new We
101
146
  case 'placeholder':
102
147
  {
103
148
  _classPrivateFieldGet(this, _$input).placeholder = newVal ?? '';
149
+ updateAttribute(this, 'aria-placeholder', newVal);
104
150
  break;
105
151
  }
106
152
 
@@ -119,6 +165,7 @@ defineCustomElement('sinch-textarea', (_$input = new WeakMap(), _$label = new We
119
165
  case 'invalidtext':
120
166
  {
121
167
  _classPrivateFieldGet(this, _$invalidText).textContent = newVal;
168
+ updateAttribute(this, 'aria-invalid', String(newVal !== null && newVal !== ''));
122
169
  break;
123
170
  }
124
171
 
package/theme.css CHANGED
@@ -85,6 +85,7 @@
85
85
  font-family: "Gilroy";
86
86
  font-weight: 400;
87
87
  font-style: normal;
88
+ font-display: swap;
88
89
  src:
89
90
  local("Gilroy-Regular"),
90
91
  url("https://d2vu40klajma73.cloudfront.net/Gilroy-Regular.woff2") format("woff2"),
@@ -95,6 +96,7 @@
95
96
  font-family: "Gilroy";
96
97
  font-weight: 600;
97
98
  font-style: normal;
99
+ font-display: swap;
98
100
  src:
99
101
  local("Gilroy-SemiBold"),
100
102
  url("https://d2vu40klajma73.cloudfront.net/Gilroy-SemiBold.woff2") format("woff2"),
@@ -105,6 +107,7 @@
105
107
  font-family: "Gilroy";
106
108
  font-weight: 700;
107
109
  font-style: normal;
110
+ font-display: swap;
108
111
  src:
109
112
  local("Gilroy-Bold"),
110
113
  url("https://d2vu40klajma73.cloudfront.net/Gilroy-Bold.woff2") format("woff2"),
package/toggle/index.d.ts CHANGED
@@ -15,6 +15,7 @@ export declare type TSinchToggleReact = TSinchElementReact<TSinchToggleElement>
15
15
  labeled?: boolean;
16
16
  disabled?: boolean;
17
17
  text?: string;
18
+ 'aria-label': string;
18
19
  onChange: (e: SyntheticEvent<TSinchToggleElement, CustomEvent<boolean>>) => void;
19
20
  onFocus?: (e: FocusEvent<TSinchToggleElement>) => void;
20
21
  onBlur?: (e: FocusEvent<TSinchToggleElement>) => void;
package/toggle/index.js CHANGED
@@ -41,7 +41,7 @@ defineCustomElement('sinch-toggle', (_$input = new WeakMap(), _$label = new Weak
41
41
  });
42
42
 
43
43
  const shadowRoot = this.attachShadow({
44
- mode: 'production' === 'development' ? 'open' : 'closed',
44
+ mode: 'closed',
45
45
  delegatesFocus: true
46
46
  });
47
47
  shadowRoot.appendChild(template.content.cloneNode(true));
@@ -49,14 +49,13 @@ defineCustomElement('sinch-toggle', (_$input = new WeakMap(), _$label = new Weak
49
49
  _classPrivateFieldSet(this, _$input, shadowRoot.querySelector('input'));
50
50
 
51
51
  _classPrivateFieldSet(this, _$label, shadowRoot.querySelector('label'));
52
- }
53
52
 
54
- connectedCallback() {
55
53
  _classPrivateFieldGet(this, _$input).addEventListener('input', _classPrivateFieldGet(this, _onInput));
56
54
  }
57
55
 
58
- disconnectedCallback() {
59
- _classPrivateFieldGet(this, _$input).removeEventListener('input', _classPrivateFieldGet(this, _onInput));
56
+ connectedCallback() {
57
+ this.setAttribute('role', 'checkbox');
58
+ this.setAttribute('aria-label', 'toggle');
60
59
  }
61
60
 
62
61
  static get observedAttributes() {
@@ -1,4 +1,4 @@
1
- import type { TSinchElementReact } from '../types';
1
+ import type { TRect, TSinchElementReact } from '../types';
2
2
  declare const orientationValues: readonly ["top", "bottom", "left", "right", "top-left", "top-right", "bottom-left", "bottom-right"];
3
3
  export declare type TSinchTooltipOrientation = typeof orientationValues[number];
4
4
  export declare type TSinchTooltipElement = HTMLElement & {
@@ -6,6 +6,7 @@ export declare type TSinchTooltipElement = HTMLElement & {
6
6
  width: number | null;
7
7
  inverted: boolean;
8
8
  orientation: TSinchTooltipOrientation;
9
+ readonly tooltipRect: TRect;
9
10
  };
10
11
  export declare type TSinchTooltipReact = TSinchElementReact<TSinchTooltipElement> & {
11
12
  text: string;