@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
@@ -0,0 +1,451 @@
1
+ import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
+ import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
+
4
+ var _$button, _$optionSlot, _$listbox, _$targetElement, _$targetSlot, _onTargetFocusin, _onButtonClick, _onListboxClick, _onListboxKeyPress, _onListboxKeyDown, _onOptionSlotChange, _onTargetSlotChange, _onListboxBlur, _onExpand, _onCollapse, _onValueChange, _getFirstOption, _getLastOption, _getNextOption, _getPrevOption, _selectOption, _getOptionWithValue, _getOptionElements, _getEnabledOptionElements, _dispatchChangeEvent, _focusTargetElement;
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 { isDropdownOptionElement } from '../dropdown-option';
15
+ import { attrValueToPixels, defineCustomElement, getAttribute, getBooleanAttribute, getIntegerAttribute, getLiteralAttribute, getRect, updateAttribute, updateBooleanAttribute, updateIntegerAttribute, updateLiteralAttribute } from '../utils';
16
+ const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{position:relative;width:100%;box-sizing:border-box}#listbox{display:none;position:absolute;z-index:1;top:0;left:0;width:100%;height:100%;box-sizing:border-box;outline:0}#listbox-body{position:absolute;left:0;top:calc(100% + 8px);min-width:100%;width:max-content;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 rgb(0 0 0 / 15%);overflow-y:auto;contain:content}:host([orientation=bottom-left]) #listbox-body{left:unset;right:0}:host([orientation=top-right]) #listbox-body{top:-8px;transform:translateY(-100%)}:host([orientation=top-left]) #listbox-body{top:-8px;transform:translateY(-100%);left:unset;right:0}#button[aria-expanded=true]~#listbox{display:block}::slotted(*){display:block}</style><div id="wrapper"><div id="button" aria-haspopup="listbox" aria-expanded="false"><slot name="target"></slot></div><div id="listbox" tabindex="-1"><div id="listbox-body"><slot name="option"></slot></div></div></div>';
17
+ const orientationValues = ['top-left', 'top-right', 'bottom-left', 'bottom-right'];
18
+ const ITEM_HEIGHT = 36;
19
+
20
+ const findSelectedOption = elements => {
21
+ for (const el of elements) {
22
+ if (el.selected) {
23
+ return el;
24
+ }
25
+ }
26
+
27
+ return null;
28
+ };
29
+
30
+ const template = document.createElement('template');
31
+ template.innerHTML = templateHTML;
32
+ defineCustomElement('sinch-dropdown', (_$button = new WeakMap(), _$optionSlot = new WeakMap(), _$listbox = new WeakMap(), _$targetElement = new WeakMap(), _$targetSlot = new WeakMap(), _onTargetFocusin = new WeakMap(), _onButtonClick = new WeakMap(), _onListboxClick = new WeakMap(), _onListboxKeyPress = new WeakMap(), _onListboxKeyDown = new WeakMap(), _onOptionSlotChange = new WeakMap(), _onTargetSlotChange = new WeakMap(), _onListboxBlur = new WeakMap(), _onExpand = new WeakSet(), _onCollapse = new WeakSet(), _onValueChange = new WeakSet(), _getFirstOption = new WeakSet(), _getLastOption = new WeakSet(), _getNextOption = new WeakSet(), _getPrevOption = new WeakSet(), _selectOption = new WeakSet(), _getOptionWithValue = new WeakSet(), _getOptionElements = new WeakSet(), _getEnabledOptionElements = new WeakSet(), _dispatchChangeEvent = new WeakSet(), _focusTargetElement = new WeakSet(), class extends HTMLElement {
33
+ constructor() {
34
+ super();
35
+
36
+ _classPrivateMethodInitSpec(this, _focusTargetElement);
37
+
38
+ _classPrivateMethodInitSpec(this, _dispatchChangeEvent);
39
+
40
+ _classPrivateMethodInitSpec(this, _getEnabledOptionElements);
41
+
42
+ _classPrivateMethodInitSpec(this, _getOptionElements);
43
+
44
+ _classPrivateMethodInitSpec(this, _getOptionWithValue);
45
+
46
+ _classPrivateMethodInitSpec(this, _selectOption);
47
+
48
+ _classPrivateMethodInitSpec(this, _getPrevOption);
49
+
50
+ _classPrivateMethodInitSpec(this, _getNextOption);
51
+
52
+ _classPrivateMethodInitSpec(this, _getLastOption);
53
+
54
+ _classPrivateMethodInitSpec(this, _getFirstOption);
55
+
56
+ _classPrivateMethodInitSpec(this, _onValueChange);
57
+
58
+ _classPrivateMethodInitSpec(this, _onCollapse);
59
+
60
+ _classPrivateMethodInitSpec(this, _onExpand);
61
+
62
+ _classPrivateFieldInitSpec(this, _$button, {
63
+ writable: true,
64
+ value: void 0
65
+ });
66
+
67
+ _classPrivateFieldInitSpec(this, _$optionSlot, {
68
+ writable: true,
69
+ value: void 0
70
+ });
71
+
72
+ _classPrivateFieldInitSpec(this, _$listbox, {
73
+ writable: true,
74
+ value: void 0
75
+ });
76
+
77
+ _classPrivateFieldInitSpec(this, _$targetElement, {
78
+ writable: true,
79
+ value: null
80
+ });
81
+
82
+ _classPrivateFieldInitSpec(this, _$targetSlot, {
83
+ writable: true,
84
+ value: void 0
85
+ });
86
+
87
+ _classPrivateFieldInitSpec(this, _onTargetFocusin, {
88
+ writable: true,
89
+ value: e => {
90
+ _classPrivateFieldSet(this, _$targetElement, e.target);
91
+ }
92
+ });
93
+
94
+ _classPrivateFieldInitSpec(this, _onButtonClick, {
95
+ writable: true,
96
+ value: e => {
97
+ e.stopPropagation();
98
+
99
+ if (this.disabled) {
100
+ return;
101
+ }
102
+
103
+ if (_classPrivateFieldGet(this, _$button).getAttribute('aria-expanded') !== 'true') {
104
+ _classPrivateMethodGet(this, _onExpand, _onExpand2).call(this);
105
+ }
106
+ }
107
+ });
108
+
109
+ _classPrivateFieldInitSpec(this, _onListboxClick, {
110
+ writable: true,
111
+ value: e => {
112
+ e.stopPropagation();
113
+ const $elem = e.target;
114
+
115
+ if ($elem !== _classPrivateFieldGet(this, _$listbox) && isDropdownOptionElement($elem) && $elem.disabled !== true) {
116
+ _classPrivateMethodGet(this, _dispatchChangeEvent, _dispatchChangeEvent2).call(this, $elem);
117
+ }
118
+
119
+ _classPrivateMethodGet(this, _onCollapse, _onCollapse2).call(this);
120
+
121
+ _classPrivateMethodGet(this, _focusTargetElement, _focusTargetElement2).call(this);
122
+ }
123
+ });
124
+
125
+ _classPrivateFieldInitSpec(this, _onListboxKeyPress, {
126
+ writable: true,
127
+ value: e => {
128
+ switch (e.code) {
129
+ case 'Space':
130
+ case 'Enter':
131
+ {
132
+ e.preventDefault();
133
+
134
+ _classPrivateMethodGet(this, _dispatchChangeEvent, _dispatchChangeEvent2).call(this, findSelectedOption(_classPrivateMethodGet(this, _getEnabledOptionElements, _getEnabledOptionElements2).call(this)));
135
+
136
+ _classPrivateMethodGet(this, _onCollapse, _onCollapse2).call(this);
137
+
138
+ _classPrivateMethodGet(this, _focusTargetElement, _focusTargetElement2).call(this);
139
+
140
+ break;
141
+ }
142
+ }
143
+ }
144
+ });
145
+
146
+ _classPrivateFieldInitSpec(this, _onListboxKeyDown, {
147
+ writable: true,
148
+ value: e => {
149
+ switch (e.code) {
150
+ case 'ArrowUp':
151
+ case 'ArrowLeft':
152
+ {
153
+ e.preventDefault();
154
+
155
+ _classPrivateMethodGet(this, _selectOption, _selectOption2).call(this, _classPrivateMethodGet(this, _getPrevOption, _getPrevOption2).call(this));
156
+
157
+ break;
158
+ }
159
+
160
+ case 'ArrowDown':
161
+ case 'ArrowRight':
162
+ {
163
+ e.preventDefault();
164
+
165
+ _classPrivateMethodGet(this, _selectOption, _selectOption2).call(this, _classPrivateMethodGet(this, _getNextOption, _getNextOption2).call(this));
166
+
167
+ break;
168
+ }
169
+
170
+ case 'Escape':
171
+ {
172
+ e.preventDefault();
173
+
174
+ _classPrivateMethodGet(this, _onCollapse, _onCollapse2).call(this);
175
+
176
+ _classPrivateMethodGet(this, _focusTargetElement, _focusTargetElement2).call(this);
177
+
178
+ break;
179
+ }
180
+ }
181
+ }
182
+ });
183
+
184
+ _classPrivateFieldInitSpec(this, _onOptionSlotChange, {
185
+ writable: true,
186
+ value: () => {
187
+ _classPrivateMethodGet(this, _onCollapse, _onCollapse2).call(this);
188
+
189
+ _classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this, this.value);
190
+ }
191
+ });
192
+
193
+ _classPrivateFieldInitSpec(this, _onTargetSlotChange, {
194
+ writable: true,
195
+ value: () => {
196
+ _classPrivateFieldSet(this, _$targetElement, null);
197
+ }
198
+ });
199
+
200
+ _classPrivateFieldInitSpec(this, _onListboxBlur, {
201
+ writable: true,
202
+ value: e => {
203
+ e.stopPropagation();
204
+
205
+ _classPrivateMethodGet(this, _onCollapse, _onCollapse2).call(this);
206
+ }
207
+ });
208
+
209
+ const shadowRoot = this.attachShadow({
210
+ mode: 'closed',
211
+ delegatesFocus: true
212
+ });
213
+ shadowRoot.appendChild(template.content.cloneNode(true));
214
+
215
+ _classPrivateFieldSet(this, _$button, shadowRoot.querySelector('#button'));
216
+
217
+ _classPrivateFieldSet(this, _$listbox, shadowRoot.querySelector('#listbox'));
218
+
219
+ _classPrivateFieldSet(this, _$optionSlot, shadowRoot.querySelector('slot[name="option"]'));
220
+
221
+ _classPrivateFieldSet(this, _$targetSlot, shadowRoot.querySelector('slot[name="target"]'));
222
+ }
223
+
224
+ connectedCallback() {
225
+ this.setAttribute('role', 'listbox');
226
+
227
+ _classPrivateFieldGet(this, _$button).addEventListener('click', _classPrivateFieldGet(this, _onButtonClick));
228
+
229
+ _classPrivateFieldGet(this, _$button).addEventListener('focusin', _classPrivateFieldGet(this, _onTargetFocusin));
230
+
231
+ _classPrivateFieldGet(this, _$listbox).addEventListener('blur', _classPrivateFieldGet(this, _onListboxBlur));
232
+
233
+ _classPrivateFieldGet(this, _$listbox).addEventListener('click', _classPrivateFieldGet(this, _onListboxClick));
234
+
235
+ _classPrivateFieldGet(this, _$listbox).addEventListener('keydown', _classPrivateFieldGet(this, _onListboxKeyDown));
236
+
237
+ _classPrivateFieldGet(this, _$listbox).addEventListener('keypress', _classPrivateFieldGet(this, _onListboxKeyPress));
238
+
239
+ _classPrivateFieldGet(this, _$optionSlot).addEventListener('slotchange', _classPrivateFieldGet(this, _onOptionSlotChange));
240
+
241
+ _classPrivateFieldGet(this, _$targetSlot).addEventListener('slotchange', _classPrivateFieldGet(this, _onTargetSlotChange));
242
+ }
243
+
244
+ disconnectedCallback() {
245
+ _classPrivateFieldGet(this, _$button).removeEventListener('click', _classPrivateFieldGet(this, _onButtonClick));
246
+
247
+ _classPrivateFieldGet(this, _$button).removeEventListener('focusin', _classPrivateFieldGet(this, _onTargetFocusin));
248
+
249
+ _classPrivateFieldGet(this, _$listbox).removeEventListener('blur', _classPrivateFieldGet(this, _onListboxBlur));
250
+
251
+ _classPrivateFieldGet(this, _$listbox).removeEventListener('click', _classPrivateFieldGet(this, _onListboxClick));
252
+
253
+ _classPrivateFieldGet(this, _$listbox).removeEventListener('keydown', _classPrivateFieldGet(this, _onListboxKeyDown));
254
+
255
+ _classPrivateFieldGet(this, _$listbox).removeEventListener('keypress', _classPrivateFieldGet(this, _onListboxKeyPress));
256
+
257
+ _classPrivateFieldGet(this, _$optionSlot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onOptionSlotChange));
258
+
259
+ _classPrivateFieldGet(this, _$targetSlot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onTargetSlotChange));
260
+ }
261
+
262
+ static get observedAttributes() {
263
+ return ['value', 'maxvisibleitems'];
264
+ }
265
+
266
+ get nodeName() {
267
+ return 'select';
268
+ }
269
+
270
+ set value(value) {
271
+ updateAttribute(this, 'value', value);
272
+ }
273
+
274
+ get value() {
275
+ return getAttribute(this, 'value', '');
276
+ }
277
+
278
+ set maxVisibleItems(value) {
279
+ updateIntegerAttribute(this, 'maxvisibleitems', value);
280
+ }
281
+
282
+ get maxVisibleItems() {
283
+ return getIntegerAttribute(this, 'maxvisibleitems', null);
284
+ }
285
+
286
+ get orientation() {
287
+ return getLiteralAttribute(this, orientationValues, 'orientation', 'bottom-right');
288
+ }
289
+
290
+ set orientation(value) {
291
+ updateLiteralAttribute(this, orientationValues, 'orientation', value);
292
+ }
293
+
294
+ set disabled(isDisabled) {
295
+ updateBooleanAttribute(this, 'disabled', isDisabled);
296
+ }
297
+
298
+ get disabled() {
299
+ return getBooleanAttribute(this, 'disabled');
300
+ }
301
+
302
+ get dropdownRect() {
303
+ return getRect(_classPrivateFieldGet(this, _$listbox).firstElementChild);
304
+ }
305
+
306
+ attributeChangedCallback(name, oldVal, newVal) {
307
+ switch (name) {
308
+ case 'value':
309
+ {
310
+ _classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this, newVal ?? '');
311
+
312
+ break;
313
+ }
314
+
315
+ case 'maxvisibleitems':
316
+ {
317
+ const $list = _classPrivateFieldGet(this, _$listbox).firstElementChild;
318
+
319
+ $list.style.maxHeight = attrValueToPixels(newVal, {
320
+ min: 2,
321
+ multiplier: ITEM_HEIGHT
322
+ });
323
+ break;
324
+ }
325
+ }
326
+ }
327
+
328
+ focus() {
329
+ _classPrivateMethodGet(this, _focusTargetElement, _focusTargetElement2).call(this);
330
+ }
331
+
332
+ blur() {
333
+ _classPrivateFieldGet(this, _$button).blur();
334
+
335
+ _classPrivateFieldGet(this, _$listbox).blur();
336
+ }
337
+
338
+ }));
339
+
340
+ function _onExpand2() {
341
+ _classPrivateFieldGet(this, _$button).setAttribute('aria-expanded', 'true');
342
+
343
+ _classPrivateFieldGet(this, _$listbox).focus();
344
+
345
+ _classPrivateMethodGet(this, _selectOption, _selectOption2).call(this, _classPrivateMethodGet(this, _getOptionWithValue, _getOptionWithValue2).call(this, this.value) ?? _classPrivateMethodGet(this, _getFirstOption, _getFirstOption2).call(this));
346
+ }
347
+
348
+ function _onCollapse2() {
349
+ _classPrivateFieldGet(this, _$button).setAttribute('aria-expanded', 'false');
350
+ }
351
+
352
+ function _onValueChange2(value) {
353
+ let $checkedOption = null;
354
+
355
+ for (const $option of _classPrivateMethodGet(this, _getOptionElements, _getOptionElements2).call(this)) {
356
+ const isChecked = $checkedOption === null && $option.disabled !== true && $option.value === value;
357
+ $option.checked = isChecked;
358
+
359
+ if (isChecked) {
360
+ $checkedOption = $option;
361
+ }
362
+ }
363
+ }
364
+
365
+ function _getFirstOption2() {
366
+ return _classPrivateMethodGet(this, _getEnabledOptionElements, _getEnabledOptionElements2).call(this)[0] ?? null;
367
+ }
368
+
369
+ function _getLastOption2() {
370
+ return _classPrivateMethodGet(this, _getEnabledOptionElements, _getEnabledOptionElements2).call(this).reverse()[0] ?? null;
371
+ }
372
+
373
+ function _getNextOption2() {
374
+ const $options = _classPrivateMethodGet(this, _getEnabledOptionElements, _getEnabledOptionElements2).call(this);
375
+
376
+ const $selectedOption = findSelectedOption($options);
377
+ const currentIndex = $selectedOption !== null ? $options.indexOf($selectedOption) : -1;
378
+
379
+ if (currentIndex < 0) {
380
+ return _classPrivateMethodGet(this, _getFirstOption, _getFirstOption2).call(this);
381
+ }
382
+
383
+ return $options[(currentIndex + 1) % $options.length];
384
+ }
385
+
386
+ function _getPrevOption2() {
387
+ const $options = _classPrivateMethodGet(this, _getEnabledOptionElements, _getEnabledOptionElements2).call(this);
388
+
389
+ const $selectedOption = findSelectedOption($options);
390
+ const currentIndex = $selectedOption !== null ? $options.indexOf($selectedOption) : -1;
391
+
392
+ if (currentIndex < 0) {
393
+ return _classPrivateMethodGet(this, _getLastOption, _getLastOption2).call(this);
394
+ }
395
+
396
+ return $options[(currentIndex - 1 + $options.length) % $options.length];
397
+ }
398
+
399
+ function _selectOption2($option) {
400
+ for (const $op of _classPrivateMethodGet(this, _getOptionElements, _getOptionElements2).call(this)) {
401
+ const isSelected = $op === $option;
402
+ $op.selected = isSelected;
403
+
404
+ if (isSelected) {
405
+ $op.scrollIntoView?.({
406
+ block: 'nearest'
407
+ });
408
+ }
409
+ }
410
+ }
411
+
412
+ function _getOptionWithValue2(value) {
413
+ for (const $option of _classPrivateMethodGet(this, _getOptionElements, _getOptionElements2).call(this)) {
414
+ if ($option.disabled !== true && $option.value === value) {
415
+ return $option;
416
+ }
417
+ }
418
+
419
+ return null;
420
+ }
421
+
422
+ function _getOptionElements2() {
423
+ let $elements = _classPrivateFieldGet(this, _$optionSlot).assignedElements();
424
+
425
+ if ($elements.length === 1 && $elements[0].tagName === 'SLOT') {
426
+ $elements = $elements[0].assignedElements();
427
+ }
428
+
429
+ return $elements.filter(isDropdownOptionElement);
430
+ }
431
+
432
+ function _getEnabledOptionElements2() {
433
+ return _classPrivateMethodGet(this, _getOptionElements, _getOptionElements2).call(this).filter(opt => opt.disabled !== true);
434
+ }
435
+
436
+ function _dispatchChangeEvent2($opt) {
437
+ if ($opt != null && this.value !== $opt.value) {
438
+ this.dispatchEvent(new CustomEvent('change', {
439
+ detail: $opt.value,
440
+ bubbles: true
441
+ }));
442
+ }
443
+ }
444
+
445
+ function _focusTargetElement2() {
446
+ const el = _classPrivateFieldGet(this, _$targetElement);
447
+
448
+ _classPrivateFieldSet(this, _$targetElement, null);
449
+
450
+ el?.focus();
451
+ }
@@ -0,0 +1,44 @@
1
+ import type { TSinchElementReact } from '../types';
2
+ export declare class DropdownOption extends HTMLElement {
3
+ #private;
4
+ constructor();
5
+ connectedCallback(): void;
6
+ static get observedAttributes(): string[];
7
+ attributeChangedCallback(name: string, oldVal: string | null, newVal: string | null): void;
8
+ set value(value: string);
9
+ get value(): string;
10
+ set text(value: string);
11
+ get text(): string;
12
+ set disabled(isDisabled: boolean);
13
+ get disabled(): boolean;
14
+ set checked(isChecked: boolean);
15
+ get checked(): boolean;
16
+ set selected(isSelected: boolean);
17
+ get selected(): boolean;
18
+ get icon(): Element | null;
19
+ }
20
+ export declare const isDropdownOptionElement: (element: EventTarget | Element | null) => element is TSinchDropdownOptionElement;
21
+ export declare type TSinchDropdownOptionElement = HTMLElement & {
22
+ value: string;
23
+ text: string;
24
+ checked: boolean;
25
+ selected: boolean;
26
+ disabled: boolean;
27
+ readonly icon: Element | null;
28
+ };
29
+ export declare type TSinchDropdownOptionReact = TSinchElementReact<TSinchDropdownOptionElement> & {
30
+ value: string;
31
+ text: string;
32
+ disabled?: boolean;
33
+ 'aria-label': string;
34
+ };
35
+ declare global {
36
+ namespace JSX {
37
+ interface IntrinsicElements {
38
+ 'sinch-dropdown-option': TSinchDropdownOptionReact;
39
+ }
40
+ }
41
+ interface HTMLElementTagNameMap {
42
+ 'sinch-dropdown-option': TSinchDropdownOptionElement;
43
+ }
44
+ }
@@ -0,0 +1,116 @@
1
+ import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
+ import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
+
4
+ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
5
+
6
+ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
7
+
8
+ import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrTrue, updateAttribute, updateBooleanAttribute } from '../utils';
9
+ const templateHTML = '<style>:host{display:block}*{pointer-events:none}#wrapper{display:flex;position:relative;box-sizing:border-box;padding:6px 12px;width:100%;align-items:center;gap:12px}#content{flex-shrink:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}:host(:hover)>#wrapper,:host([data-selected])>#wrapper{background-color:var(--sinch-color-snow-500)}:host([checked])>#wrapper{padding-right:36px}:host([checked])>#wrapper::after{content:"";position:absolute;top:10px;right:11px;width:18px;height:14px;background-image:url("data:image/svg+xml,%3Csvg xmlns=\'http://www.w3.org/2000/svg\'%3E%3Cpath d=\'M6 11.17 1.83 7 .41 8.41 6 14 18 2 16.59.59 6 11.17Z\' fill=\'%230A273D\'/%3E%3C/svg%3E");background-size:cover;background-repeat:no-repeat}:host([disabled]:not([disabled=false]))>#wrapper{color:var(--sinch-color-stormy-100);--sinch-color-icon:var(--sinch-color-stormy-100)}</style><div id="wrapper"><slot name="icon"></slot><span id="content"></span></div>';
10
+ const template = document.createElement('template');
11
+ template.innerHTML = templateHTML;
12
+
13
+ var _$iconSlot = new WeakMap();
14
+
15
+ var _$content = new WeakMap();
16
+
17
+ export class DropdownOption extends HTMLElement {
18
+ constructor() {
19
+ super();
20
+
21
+ _classPrivateFieldInitSpec(this, _$iconSlot, {
22
+ writable: true,
23
+ value: void 0
24
+ });
25
+
26
+ _classPrivateFieldInitSpec(this, _$content, {
27
+ writable: true,
28
+ value: void 0
29
+ });
30
+
31
+ const shadowRoot = this.attachShadow({
32
+ mode: 'closed'
33
+ });
34
+ shadowRoot.appendChild(template.content.cloneNode(true));
35
+
36
+ _classPrivateFieldSet(this, _$iconSlot, shadowRoot.querySelector('slot'));
37
+
38
+ _classPrivateFieldSet(this, _$content, shadowRoot.querySelector('span'));
39
+ }
40
+
41
+ connectedCallback() {
42
+ this.setAttribute('role', 'option');
43
+ }
44
+
45
+ static get observedAttributes() {
46
+ return ['text', 'checked'];
47
+ }
48
+
49
+ attributeChangedCallback(name, oldVal, newVal) {
50
+ if (oldVal === newVal) {
51
+ return;
52
+ }
53
+
54
+ switch (name) {
55
+ case 'text':
56
+ {
57
+ _classPrivateFieldGet(this, _$content).textContent = newVal;
58
+ break;
59
+ }
60
+
61
+ case 'checked':
62
+ {
63
+ updateAttribute(this, 'aria-selected', isAttrTrue(newVal));
64
+ }
65
+ }
66
+ }
67
+
68
+ set value(value) {
69
+ updateAttribute(this, 'value', value);
70
+ }
71
+
72
+ get value() {
73
+ return getAttribute(this, 'value', '');
74
+ }
75
+
76
+ set text(value) {
77
+ updateAttribute(this, 'text', value);
78
+ }
79
+
80
+ get text() {
81
+ return getAttribute(this, 'text', '');
82
+ }
83
+
84
+ set disabled(isDisabled) {
85
+ updateBooleanAttribute(this, 'disabled', isDisabled);
86
+ }
87
+
88
+ get disabled() {
89
+ return getBooleanAttribute(this, 'disabled');
90
+ }
91
+
92
+ set checked(isChecked) {
93
+ updateBooleanAttribute(this, 'checked', isChecked);
94
+ }
95
+
96
+ get checked() {
97
+ return getBooleanAttribute(this, 'checked');
98
+ }
99
+
100
+ set selected(isSelected) {
101
+ updateBooleanAttribute(this, 'data-selected', isSelected);
102
+ }
103
+
104
+ get selected() {
105
+ return getBooleanAttribute(this, 'data-selected');
106
+ }
107
+
108
+ get icon() {
109
+ return _classPrivateFieldGet(this, _$iconSlot).assignedElements()[0] ?? null;
110
+ }
111
+
112
+ }
113
+ defineCustomElement('sinch-dropdown-option', DropdownOption);
114
+ export const isDropdownOptionElement = element => {
115
+ return element instanceof DropdownOption;
116
+ };
@@ -8,7 +8,7 @@ defineCustomElement('sinch-help-tooltip', class extends HTMLElement {
8
8
  constructor() {
9
9
  super();
10
10
  const shadowRoot = this.attachShadow({
11
- mode: 'production' === 'development' ? 'open' : 'closed'
11
+ mode: 'closed'
12
12
  });
13
13
  shadowRoot.appendChild(template.content.cloneNode(true));
14
14
  this.$tooltip = shadowRoot.querySelector('sinch-tooltip');
@@ -50,6 +50,10 @@ defineCustomElement('sinch-help-tooltip', class extends HTMLElement {
50
50
  updateAttribute(this, 'orientation', value);
51
51
  }
52
52
 
53
+ get tooltipRect() {
54
+ return this.$tooltip.tooltipRect;
55
+ }
56
+
53
57
  attributeChangedCallback(name, _, newVal) {
54
58
  switch (name) {
55
59
  case 'text':
@@ -1,4 +1,4 @@
1
1
  import { defineCustomElement } from '../../utils';
2
2
  import { createIconClass } from '../create-icon-class';
3
- const templateHTML = '<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2Zm4.3 14.3a.996.996 0 0 1-1.41 0L12 13.41 9.11 16.3a.996.996 0 1 1-1.41-1.41L10.59 12 7.7 9.11A.996.996 0 1 1 9.11 7.7L12 10.59l2.89-2.89a.996.996 0 1 1 1.41 1.41L13.41 12l2.89 2.89c.38.38.38 1.02 0 1.41Z"/></svg>';
3
+ const templateHTML = '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2Zm4.3 14.3a.996.996 0 0 1-1.41 0L12 13.41 9.11 16.3a.996.996 0 1 1-1.41-1.41L10.59 12 7.7 9.11A.996.996 0 1 1 9.11 7.7L12 10.59l2.89-2.89a.996.996 0 1 1 1.41 1.41L13.41 12l2.89 2.89c.38.38.38 1.02 0 1.41Z"/></svg>';
4
4
  defineCustomElement('sinch-icon-cancel', createIconClass(templateHTML));
@@ -1,4 +1,4 @@
1
1
  import { defineCustomElement } from '../../utils';
2
2
  import { createIconClass } from '../create-icon-class';
3
- const templateHTML = '<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M18.3 5.71a.996.996 0 0 0-1.41 0L12 10.59 7.11 5.7A.996.996 0 1 0 5.7 7.11L10.59 12 5.7 16.89a.996.996 0 1 0 1.41 1.41L12 13.41l4.89 4.89a.996.996 0 1 0 1.41-1.41L13.41 12l4.89-4.89c.38-.38.38-1.02 0-1.4Z"/></svg>';
3
+ const templateHTML = '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M18.3 5.71a.996.996 0 0 0-1.41 0L12 10.59 7.11 5.7A.996.996 0 1 0 5.7 7.11L10.59 12 5.7 16.89a.996.996 0 1 0 1.41 1.41L12 13.41l4.89 4.89a.996.996 0 1 0 1.41-1.41L13.41 12l4.89-4.89c.38-.38.38-1.02 0-1.4Z"/></svg>';
4
4
  defineCustomElement('sinch-icon-close', createIconClass(templateHTML));
@@ -10,7 +10,7 @@ export const createIconClass = templateHTML => {
10
10
  constructor() {
11
11
  super();
12
12
  const shadowRoot = this.attachShadow({
13
- mode: 'production' === 'development' ? 'open' : 'closed'
13
+ mode: 'closed'
14
14
  });
15
15
  shadowRoot.appendChild(template.content.cloneNode(true));
16
16
  this.$svg = shadowRoot.querySelector('svg');
@@ -1,4 +1,4 @@
1
1
  import { defineCustomElement } from '../../utils';
2
2
  import { createIconClass } from '../create-icon-class';
3
- const templateHTML = '<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M14.29 5.71a.996.996 0 0 0 0 1.41L18.17 11H3c-.55 0-1 .45-1 1s.45 1 1 1h15.18l-3.88 3.88a.996.996 0 1 0 1.41 1.41l5.59-5.59a.996.996 0 0 0 0-1.41l-5.6-5.58a.996.996 0 0 0-1.41 0Z"/></svg>';
3
+ const templateHTML = '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M14.29 5.71a.996.996 0 0 0 0 1.41L18.17 11H3c-.55 0-1 .45-1 1s.45 1 1 1h15.18l-3.88 3.88a.996.996 0 1 0 1.41 1.41l5.59-5.59a.996.996 0 0 0 0-1.41l-5.6-5.58a.996.996 0 0 0-1.41 0Z"/></svg>';
4
4
  defineCustomElement('sinch-icon-east', createIconClass(templateHTML));
@@ -1,4 +1,4 @@
1
1
  import { defineCustomElement } from '../../utils';
2
2
  import { createIconClass } from '../create-icon-class';
3
- const templateHTML = '<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2Zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8Zm-1-4h2v2h-2v-2Zm1.61-9.96c-2.06-.3-3.88.97-4.43 2.79-.18.58.26 1.17.87 1.17h.2c.41 0 .74-.29.88-.67.32-.89 1.27-1.5 2.3-1.28.95.2 1.65 1.13 1.57 2.1-.1 1.34-1.62 1.63-2.45 2.88 0 .01-.01.01-.01.02-.01.02-.02.03-.03.05-.09.15-.18.32-.25.5-.01.03-.03.05-.04.08-.01.02-.01.04-.02.07-.12.34-.2.75-.2 1.25h2c0-.42.11-.77.28-1.07.02-.03.03-.06.05-.09.08-.14.18-.27.28-.39.01-.01.02-.03.03-.04.1-.12.21-.23.33-.34.96-.91 2.26-1.65 1.99-3.56-.24-1.74-1.61-3.21-3.35-3.47Z"/></svg>';
3
+ const templateHTML = '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2Zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8Zm-1-4h2v2h-2v-2Zm1.61-9.96c-2.06-.3-3.88.97-4.43 2.79-.18.58.26 1.17.87 1.17h.2c.41 0 .74-.29.88-.67.32-.89 1.27-1.5 2.3-1.28.95.2 1.65 1.13 1.57 2.1-.1 1.34-1.62 1.63-2.45 2.88 0 .01-.01.01-.01.02-.01.02-.02.03-.03.05-.09.15-.18.32-.25.5-.01.03-.03.05-.04.08-.01.02-.01.04-.02.07-.12.34-.2.75-.2 1.25h2c0-.42.11-.77.28-1.07.02-.03.03-.06.05-.09.08-.14.18-.27.28-.39.01-.01.02-.03.03-.04.1-.12.21-.23.33-.34.96-.91 2.26-1.65 1.99-3.56-.24-1.74-1.61-3.21-3.35-3.47Z"/></svg>';
4
4
  defineCustomElement('sinch-icon-help-outline', createIconClass(templateHTML));
@@ -1,4 +1,4 @@
1
1
  import { defineCustomElement } from '../../utils';
2
2
  import { createIconClass } from '../create-icon-class';
3
- const templateHTML = '<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M6 10c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2Zm12 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2Zm-6 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2Z"/></svg>';
3
+ const templateHTML = '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M6 10c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2Zm12 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2Zm-6 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2Z"/></svg>';
4
4
  defineCustomElement('sinch-icon-more-horiz', createIconClass(templateHTML));