@nectary/components 0.13.0 → 0.15.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 (131) hide show
  1. package/card/index.js +1 -1
  2. package/checkbox/index.js +1 -1
  3. package/dialog/index.js +1 -1
  4. package/icon/add-alert/index.d.ts +11 -0
  5. package/icon/add-alert/index.js +4 -0
  6. package/icon/app-settings-alt/index.d.ts +11 -0
  7. package/icon/app-settings-alt/index.js +4 -0
  8. package/icon/apps/index.d.ts +11 -0
  9. package/icon/apps/index.js +4 -0
  10. package/icon/arrow-drop-down/index.d.ts +11 -0
  11. package/icon/arrow-drop-down/index.js +4 -0
  12. package/icon/arrow-drop-down-circle/index.d.ts +11 -0
  13. package/icon/arrow-drop-down-circle/index.js +4 -0
  14. package/icon/arrow-drop-up/index.d.ts +11 -0
  15. package/icon/arrow-drop-up/index.js +4 -0
  16. package/icon/arrow-left/index.d.ts +11 -0
  17. package/icon/arrow-left/index.js +4 -0
  18. package/icon/arrow-right/index.d.ts +11 -0
  19. package/icon/arrow-right/index.js +4 -0
  20. package/icon/attach-email/index.d.ts +11 -0
  21. package/icon/attach-email/index.js +4 -0
  22. package/icon/attachment/index.d.ts +11 -0
  23. package/icon/attachment/index.js +4 -0
  24. package/icon/auto-delete/index.d.ts +11 -0
  25. package/icon/auto-delete/index.js +4 -0
  26. package/icon/campaign/index.d.ts +11 -0
  27. package/icon/campaign/index.js +4 -0
  28. package/icon/check/index.d.ts +11 -0
  29. package/icon/check/index.js +4 -0
  30. package/icon/cloud/index.d.ts +11 -0
  31. package/icon/cloud/index.js +4 -0
  32. package/icon/cloud-circle/index.d.ts +11 -0
  33. package/icon/cloud-circle/index.js +4 -0
  34. package/icon/cloud-done/index.d.ts +11 -0
  35. package/icon/cloud-done/index.js +4 -0
  36. package/icon/cloud-download/index.d.ts +11 -0
  37. package/icon/cloud-download/index.js +4 -0
  38. package/icon/cloud-off/index.d.ts +11 -0
  39. package/icon/cloud-off/index.js +4 -0
  40. package/icon/cloud-queue/index.d.ts +11 -0
  41. package/icon/cloud-queue/index.js +4 -0
  42. package/icon/cloud-upload/index.d.ts +11 -0
  43. package/icon/cloud-upload/index.js +4 -0
  44. package/icon/create-icon-class.d.ts +38 -36
  45. package/icon/create-new-folder/index.d.ts +11 -0
  46. package/icon/create-new-folder/index.js +4 -0
  47. package/icon/double-arrow/index.d.ts +11 -0
  48. package/icon/double-arrow/index.js +4 -0
  49. package/icon/download/index.d.ts +11 -0
  50. package/icon/download/index.js +4 -0
  51. package/icon/download-done/index.d.ts +11 -0
  52. package/icon/download-done/index.js +4 -0
  53. package/icon/error/index.d.ts +11 -0
  54. package/icon/error/index.js +4 -0
  55. package/icon/error-outline/index.d.ts +11 -0
  56. package/icon/error-outline/index.js +4 -0
  57. package/icon/first-page/index.d.ts +11 -0
  58. package/icon/first-page/index.js +4 -0
  59. package/icon/folder/index.d.ts +11 -0
  60. package/icon/folder/index.js +4 -0
  61. package/icon/folder-open/index.d.ts +11 -0
  62. package/icon/folder-open/index.js +4 -0
  63. package/icon/folder-shared/index.d.ts +11 -0
  64. package/icon/folder-shared/index.js +4 -0
  65. package/icon/fullscreen/index.d.ts +11 -0
  66. package/icon/fullscreen/index.js +4 -0
  67. package/icon/fullscreen-exit/index.d.ts +11 -0
  68. package/icon/fullscreen-exit/index.js +4 -0
  69. package/icon/home-work/index.d.ts +11 -0
  70. package/icon/home-work/index.js +4 -0
  71. package/icon/last-page/index.d.ts +11 -0
  72. package/icon/last-page/index.js +4 -0
  73. package/icon/legend-toggle/index.d.ts +11 -0
  74. package/icon/legend-toggle/index.js +4 -0
  75. package/icon/menu/index.d.ts +11 -0
  76. package/icon/menu/index.js +4 -0
  77. package/icon/menu-open/index.d.ts +11 -0
  78. package/icon/menu-open/index.js +4 -0
  79. package/icon/notification-important/index.d.ts +11 -0
  80. package/icon/notification-important/index.js +4 -0
  81. package/icon/payments/index.d.ts +11 -0
  82. package/icon/payments/index.js +4 -0
  83. package/icon/refresh/index.d.ts +11 -0
  84. package/icon/refresh/index.js +4 -0
  85. package/icon/request-quote/index.d.ts +11 -0
  86. package/icon/request-quote/index.js +4 -0
  87. package/icon/rule-folder/index.d.ts +11 -0
  88. package/icon/rule-folder/index.js +4 -0
  89. package/icon/search/index.d.ts +11 -0
  90. package/icon/search/index.js +4 -0
  91. package/icon/snippet-folder/index.d.ts +11 -0
  92. package/icon/snippet-folder/index.js +4 -0
  93. package/icon/subdirectory-arrow-left/index.d.ts +11 -0
  94. package/icon/subdirectory-arrow-left/index.js +4 -0
  95. package/icon/subdirectory-arrow-right/index.d.ts +11 -0
  96. package/icon/subdirectory-arrow-right/index.js +4 -0
  97. package/icon/switch-left/index.d.ts +11 -0
  98. package/icon/switch-left/index.js +4 -0
  99. package/icon/switch-right/index.d.ts +11 -0
  100. package/icon/switch-right/index.js +4 -0
  101. package/icon/text-snippet/index.d.ts +11 -0
  102. package/icon/text-snippet/index.js +4 -0
  103. package/icon/topic/index.d.ts +11 -0
  104. package/icon/topic/index.js +4 -0
  105. package/icon/unfold-less/index.d.ts +11 -0
  106. package/icon/unfold-less/index.js +4 -0
  107. package/icon/unfold-more/index.d.ts +11 -0
  108. package/icon/unfold-more/index.js +4 -0
  109. package/icon/upload/index.d.ts +11 -0
  110. package/icon/upload/index.js +4 -0
  111. package/icon/warning/index.d.ts +11 -0
  112. package/icon/warning/index.js +4 -0
  113. package/icon/warning-amber/index.d.ts +11 -0
  114. package/icon/warning-amber/index.js +4 -0
  115. package/icon-branded/create-icon-class.d.ts +38 -36
  116. package/illustration/create-illustration-class.d.ts +38 -36
  117. package/index.d.ts +57 -0
  118. package/index.js +58 -1
  119. package/input/index.d.ts +5 -0
  120. package/input/index.js +18 -7
  121. package/logo/create-logo-class.d.ts +38 -36
  122. package/package.json +1 -1
  123. package/radio-option/index.js +1 -1
  124. package/search/index.d.ts +34 -0
  125. package/search/index.js +470 -0
  126. package/search-option/index.d.ts +20 -0
  127. package/search-option/index.js +76 -0
  128. package/spinner/index.js +5 -0
  129. package/tooltip/index.js +1 -1
  130. package/utils.d.ts +2 -1
  131. package/utils.js +3 -0
@@ -0,0 +1,470 @@
1
+ import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
+ import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
+
4
+ var _$label, _$input, _selectionStart, _selectionEnd, _$optionSlot, _$listbox, _$clear, _onInput, _onValueChange, _onClearMouseDown, _onClear, _onInputFocus, _onInputBlur, _onListboxClick, _onListboxKeyPress, _onListboxKeyDown, _onOptionSlotChange, _onExpand, _onCollapse, _getFirstOption, _getLastOption, _getNextOption, _getPrevOption, _selectOption, _getOptionElements;
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 { 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-4);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;font:var(--sinch-font-body);color:var(--sinch-color-text-default);caret-color:var(--sinch-caret-color,auto)}#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{all:initial;position:absolute;right:8px;top:8px;width:32px;height:32px;display:flex;align-items:center;justify-content:center;cursor:pointer;--sinch-color-icon:var(--sinch-color-stormy-300)}#clear:focus{--sinch-color-icon:var(--sinch-color-stormy-500)}:host([value=""]) #clear{display:none}:host([value=""]) #input{padding-right:12px}#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 rgb(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><button id="clear"><sinch-icon-close id="icon-close"></sinch-icon-close></button><div id="listbox"><slot name="option"></slot></div></div>';
17
+ import '../icon/search';
18
+ import '../icon/close';
19
+ const ITEM_HEIGHT = 40;
20
+
21
+ const findSelectedOption = elements => {
22
+ for (const el of elements) {
23
+ if (el.selected) {
24
+ return el;
25
+ }
26
+ }
27
+
28
+ return null;
29
+ };
30
+
31
+ const template = document.createElement('template');
32
+ template.innerHTML = templateHTML;
33
+ defineCustomElement('sinch-search', (_$label = new WeakMap(), _$input = new WeakMap(), _selectionStart = new WeakMap(), _selectionEnd = new WeakMap(), _$optionSlot = new WeakMap(), _$listbox = new WeakMap(), _$clear = 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
+ constructor() {
35
+ super();
36
+
37
+ _classPrivateMethodInitSpec(this, _getOptionElements);
38
+
39
+ _classPrivateMethodInitSpec(this, _selectOption);
40
+
41
+ _classPrivateMethodInitSpec(this, _getPrevOption);
42
+
43
+ _classPrivateMethodInitSpec(this, _getNextOption);
44
+
45
+ _classPrivateMethodInitSpec(this, _getLastOption);
46
+
47
+ _classPrivateMethodInitSpec(this, _getFirstOption);
48
+
49
+ _classPrivateMethodInitSpec(this, _onCollapse);
50
+
51
+ _classPrivateMethodInitSpec(this, _onExpand);
52
+
53
+ _classPrivateMethodInitSpec(this, _onValueChange);
54
+
55
+ _classPrivateFieldInitSpec(this, _$label, {
56
+ writable: true,
57
+ value: void 0
58
+ });
59
+
60
+ _classPrivateFieldInitSpec(this, _$input, {
61
+ writable: true,
62
+ value: void 0
63
+ });
64
+
65
+ _classPrivateFieldInitSpec(this, _selectionStart, {
66
+ writable: true,
67
+ value: null
68
+ });
69
+
70
+ _classPrivateFieldInitSpec(this, _selectionEnd, {
71
+ writable: true,
72
+ value: null
73
+ });
74
+
75
+ _classPrivateFieldInitSpec(this, _$optionSlot, {
76
+ writable: true,
77
+ value: void 0
78
+ });
79
+
80
+ _classPrivateFieldInitSpec(this, _$listbox, {
81
+ writable: true,
82
+ value: void 0
83
+ });
84
+
85
+ _classPrivateFieldInitSpec(this, _$clear, {
86
+ writable: true,
87
+ value: void 0
88
+ });
89
+
90
+ _classPrivateFieldInitSpec(this, _onInput, {
91
+ writable: true,
92
+ value: e => {
93
+ e.stopPropagation();
94
+
95
+ _classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this, _classPrivateFieldGet(this, _$input).value, true);
96
+ }
97
+ });
98
+
99
+ _classPrivateFieldInitSpec(this, _onClearMouseDown, {
100
+ writable: true,
101
+ value: e => {
102
+ e.preventDefault();
103
+ }
104
+ });
105
+
106
+ _classPrivateFieldInitSpec(this, _onClear, {
107
+ writable: true,
108
+ value: e => {
109
+ e.stopPropagation();
110
+
111
+ _classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this, '');
112
+
113
+ _classPrivateFieldGet(this, _$input).focus();
114
+ }
115
+ });
116
+
117
+ _classPrivateFieldInitSpec(this, _onInputFocus, {
118
+ writable: true,
119
+ value: () => {
120
+ _classPrivateMethodGet(this, _onExpand, _onExpand2).call(this);
121
+ }
122
+ });
123
+
124
+ _classPrivateFieldInitSpec(this, _onInputBlur, {
125
+ writable: true,
126
+ value: () => {
127
+ _classPrivateMethodGet(this, _onCollapse, _onCollapse2).call(this);
128
+ }
129
+ });
130
+
131
+ _classPrivateFieldInitSpec(this, _onListboxClick, {
132
+ writable: true,
133
+ value: e => {
134
+ e.stopPropagation();
135
+ const $elem = e.target;
136
+
137
+ if (isSearchOptionElement($elem)) {
138
+ _classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this, $elem.text);
139
+ }
140
+
141
+ _classPrivateMethodGet(this, _onCollapse, _onCollapse2).call(this);
142
+ }
143
+ });
144
+
145
+ _classPrivateFieldInitSpec(this, _onListboxKeyPress, {
146
+ writable: true,
147
+ value: e => {
148
+ switch (e.code) {
149
+ case 'Enter':
150
+ {
151
+ e.preventDefault();
152
+ const $elem = findSelectedOption(_classPrivateMethodGet(this, _getOptionElements, _getOptionElements2).call(this));
153
+
154
+ if ($elem != null) {
155
+ _classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this, $elem.text);
156
+ }
157
+
158
+ _classPrivateMethodGet(this, _onCollapse, _onCollapse2).call(this);
159
+
160
+ break;
161
+ }
162
+ }
163
+ }
164
+ });
165
+
166
+ _classPrivateFieldInitSpec(this, _onListboxKeyDown, {
167
+ writable: true,
168
+ value: e => {
169
+ switch (e.code) {
170
+ case 'ArrowUp':
171
+ {
172
+ e.preventDefault();
173
+
174
+ _classPrivateMethodGet(this, _selectOption, _selectOption2).call(this, _classPrivateMethodGet(this, _getPrevOption, _getPrevOption2).call(this));
175
+
176
+ break;
177
+ }
178
+
179
+ case 'ArrowDown':
180
+ {
181
+ e.preventDefault();
182
+
183
+ _classPrivateMethodGet(this, _selectOption, _selectOption2).call(this, _classPrivateMethodGet(this, _getNextOption, _getNextOption2).call(this));
184
+
185
+ break;
186
+ }
187
+
188
+ case 'Escape':
189
+ {
190
+ e.preventDefault();
191
+
192
+ _classPrivateMethodGet(this, _onCollapse, _onCollapse2).call(this);
193
+
194
+ break;
195
+ }
196
+ }
197
+ }
198
+ });
199
+
200
+ _classPrivateFieldInitSpec(this, _onOptionSlotChange, {
201
+ writable: true,
202
+ value: () => {
203
+ _classPrivateMethodGet(this, _onExpand, _onExpand2).call(this);
204
+ }
205
+ });
206
+
207
+ const shadowRoot = this.attachShadow({
208
+ mode: 'closed',
209
+ delegatesFocus: true
210
+ });
211
+ shadowRoot.appendChild(template.content.cloneNode(true));
212
+
213
+ _classPrivateFieldSet(this, _$input, shadowRoot.querySelector('#input'));
214
+
215
+ _classPrivateFieldSet(this, _$label, shadowRoot.querySelector('#label'));
216
+
217
+ _classPrivateFieldSet(this, _$listbox, shadowRoot.querySelector('#listbox'));
218
+
219
+ _classPrivateFieldSet(this, _$optionSlot, shadowRoot.querySelector('slot[name="option"]'));
220
+
221
+ _classPrivateFieldSet(this, _$clear, shadowRoot.querySelector('#clear'));
222
+ }
223
+
224
+ connectedCallback() {
225
+ this.setAttribute('role', 'listbox');
226
+ this.setAttribute('autocomplete', 'off');
227
+ this.setAttribute('aria-expanded', 'false');
228
+
229
+ _classPrivateFieldGet(this, _$input).addEventListener('input', _classPrivateFieldGet(this, _onInput));
230
+
231
+ _classPrivateFieldGet(this, _$input).addEventListener('focus', _classPrivateFieldGet(this, _onInputFocus));
232
+
233
+ _classPrivateFieldGet(this, _$input).addEventListener('blur', _classPrivateFieldGet(this, _onInputBlur));
234
+
235
+ _classPrivateFieldGet(this, _$input).addEventListener('keydown', _classPrivateFieldGet(this, _onListboxKeyDown));
236
+
237
+ _classPrivateFieldGet(this, _$input).addEventListener('keypress', _classPrivateFieldGet(this, _onListboxKeyPress));
238
+
239
+ _classPrivateFieldGet(this, _$listbox).addEventListener('click', _classPrivateFieldGet(this, _onListboxClick));
240
+
241
+ _classPrivateFieldGet(this, _$optionSlot).addEventListener('slotchange', _classPrivateFieldGet(this, _onOptionSlotChange));
242
+
243
+ _classPrivateFieldGet(this, _$clear).addEventListener('mousedown', _classPrivateFieldGet(this, _onClearMouseDown));
244
+
245
+ _classPrivateFieldGet(this, _$clear).addEventListener('click', _classPrivateFieldGet(this, _onClear));
246
+ }
247
+
248
+ disconnectedCallback() {
249
+ _classPrivateFieldGet(this, _$input).removeEventListener('input', _classPrivateFieldGet(this, _onInput));
250
+
251
+ _classPrivateFieldGet(this, _$input).removeEventListener('focus', _classPrivateFieldGet(this, _onInputFocus));
252
+
253
+ _classPrivateFieldGet(this, _$input).removeEventListener('blur', _classPrivateFieldGet(this, _onInputBlur));
254
+
255
+ _classPrivateFieldGet(this, _$input).removeEventListener('keydown', _classPrivateFieldGet(this, _onListboxKeyDown));
256
+
257
+ _classPrivateFieldGet(this, _$input).removeEventListener('keypress', _classPrivateFieldGet(this, _onListboxKeyPress));
258
+
259
+ _classPrivateFieldGet(this, _$listbox).removeEventListener('click', _classPrivateFieldGet(this, _onListboxClick));
260
+
261
+ _classPrivateFieldGet(this, _$optionSlot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onOptionSlotChange));
262
+
263
+ _classPrivateFieldGet(this, _$clear).removeEventListener('mousedown', _classPrivateFieldGet(this, _onClearMouseDown));
264
+
265
+ _classPrivateFieldGet(this, _$clear).removeEventListener('click', _classPrivateFieldGet(this, _onClear));
266
+ }
267
+
268
+ static get observedAttributes() {
269
+ return ['label', 'value', 'placeholder', 'maxvisibleitems', 'clear-aria-label'];
270
+ }
271
+
272
+ get type() {
273
+ return 'text';
274
+ }
275
+
276
+ get nodeName() {
277
+ return 'input';
278
+ }
279
+
280
+ set value(value) {
281
+ updateAttribute(this, 'value', value);
282
+ }
283
+
284
+ get value() {
285
+ return getAttribute(this, 'value', '');
286
+ }
287
+
288
+ set placeholder(value) {
289
+ updateAttribute(this, 'placeholder', value);
290
+ }
291
+
292
+ get placeholder() {
293
+ return getAttribute(this, 'placeholder', null);
294
+ }
295
+
296
+ set label(value) {
297
+ updateAttribute(this, 'label', value);
298
+ }
299
+
300
+ get label() {
301
+ return getAttribute(this, 'label', null);
302
+ }
303
+
304
+ set maxVisibleItems(value) {
305
+ updateIntegerAttribute(this, 'maxvisibleitems', value);
306
+ }
307
+
308
+ get maxVisibleItems() {
309
+ return getIntegerAttribute(this, 'maxvisibleitems', null);
310
+ }
311
+
312
+ get dropdownRect() {
313
+ return getRect(_classPrivateFieldGet(this, _$listbox));
314
+ }
315
+
316
+ attributeChangedCallback(name, oldVal, newVal) {
317
+ switch (name) {
318
+ case 'value':
319
+ {
320
+ const nextVal = newVal ?? '';
321
+
322
+ if (nextVal !== _classPrivateFieldGet(this, _$input).value) {
323
+ _classPrivateFieldGet(this, _$input).value = nextVal;
324
+ const isNextCursorEnd = _classPrivateFieldGet(this, _selectionStart) === null || _classPrivateFieldGet(this, _selectionStart) === nextVal.length;
325
+
326
+ if (!isNextCursorEnd) {
327
+ _classPrivateFieldGet(this, _$input).setSelectionRange(_classPrivateFieldGet(this, _selectionStart), _classPrivateFieldGet(this, _selectionEnd));
328
+ }
329
+ }
330
+
331
+ break;
332
+ }
333
+
334
+ case 'label':
335
+ {
336
+ _classPrivateFieldGet(this, _$label).textContent = newVal;
337
+ break;
338
+ }
339
+
340
+ case 'placeholder':
341
+ {
342
+ _classPrivateFieldGet(this, _$input).placeholder = newVal ?? '';
343
+ updateAttribute(this, 'aria-placeholder', newVal);
344
+ break;
345
+ }
346
+
347
+ case 'maxvisibleitems':
348
+ {
349
+ _classPrivateFieldGet(this, _$listbox).style.maxHeight = attrValueToPixels(newVal, {
350
+ min: 2,
351
+ multiplier: ITEM_HEIGHT
352
+ });
353
+ break;
354
+ }
355
+
356
+ case 'clear-aria-label':
357
+ {
358
+ updateAttribute(_classPrivateFieldGet(this, _$clear), 'aria-label', newVal);
359
+ }
360
+ }
361
+ }
362
+
363
+ focus() {
364
+ _classPrivateFieldGet(this, _$input).focus();
365
+ }
366
+
367
+ blur() {
368
+ _classPrivateFieldGet(this, _$input).blur();
369
+ }
370
+
371
+ }));
372
+
373
+ function _onValueChange2(nextValue) {
374
+ let preserveCursorPosition = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
375
+ const prevValue = this.value;
376
+
377
+ if (prevValue !== nextValue) {
378
+ const nextSelectionStart = preserveCursorPosition ? _classPrivateFieldGet(this, _$input).selectionStart : nextValue.length;
379
+ const nextSelectionEnd = preserveCursorPosition ? _classPrivateFieldGet(this, _$input).selectionEnd : nextValue.length;
380
+
381
+ const prevSelectionStart = _classPrivateFieldGet(this, _selectionStart);
382
+
383
+ const prevSelectionEnd = _classPrivateFieldGet(this, _selectionEnd);
384
+
385
+ const isPrevCursorEnd = prevSelectionStart === prevSelectionEnd && prevSelectionStart === prevValue.length;
386
+ _classPrivateFieldGet(this, _$input).value = prevValue;
387
+
388
+ if (!isPrevCursorEnd) {
389
+ _classPrivateFieldGet(this, _$input).setSelectionRange(prevSelectionStart, prevSelectionEnd);
390
+ }
391
+
392
+ _classPrivateFieldSet(this, _selectionStart, nextSelectionStart);
393
+
394
+ _classPrivateFieldSet(this, _selectionEnd, nextSelectionEnd);
395
+
396
+ this.dispatchEvent(new CustomEvent('change', {
397
+ detail: nextValue,
398
+ bubbles: true
399
+ }));
400
+ }
401
+ }
402
+
403
+ function _onExpand2() {
404
+ const elems = _classPrivateMethodGet(this, _getOptionElements, _getOptionElements2).call(this);
405
+
406
+ if (elems.length === 0 || document.activeElement !== this) {
407
+ _classPrivateMethodGet(this, _onCollapse, _onCollapse2).call(this);
408
+
409
+ return;
410
+ }
411
+
412
+ this.setAttribute('aria-expanded', 'true');
413
+
414
+ _classPrivateMethodGet(this, _selectOption, _selectOption2).call(this, elems[0]);
415
+ }
416
+
417
+ function _onCollapse2() {
418
+ this.setAttribute('aria-expanded', 'false');
419
+ }
420
+
421
+ function _getFirstOption2() {
422
+ return _classPrivateMethodGet(this, _getOptionElements, _getOptionElements2).call(this)[0] ?? null;
423
+ }
424
+
425
+ function _getLastOption2() {
426
+ return _classPrivateMethodGet(this, _getOptionElements, _getOptionElements2).call(this).reverse()[0] ?? null;
427
+ }
428
+
429
+ function _getNextOption2() {
430
+ const $options = _classPrivateMethodGet(this, _getOptionElements, _getOptionElements2).call(this);
431
+
432
+ const $selectedOption = findSelectedOption($options);
433
+ const currentIndex = $selectedOption !== null ? $options.indexOf($selectedOption) : -1;
434
+
435
+ if (currentIndex < 0) {
436
+ return _classPrivateMethodGet(this, _getFirstOption, _getFirstOption2).call(this);
437
+ }
438
+
439
+ return $options[(currentIndex + 1) % $options.length];
440
+ }
441
+
442
+ function _getPrevOption2() {
443
+ const $options = _classPrivateMethodGet(this, _getOptionElements, _getOptionElements2).call(this);
444
+
445
+ const $selectedOption = findSelectedOption($options);
446
+ const currentIndex = $selectedOption !== null ? $options.indexOf($selectedOption) : -1;
447
+
448
+ if (currentIndex < 0) {
449
+ return _classPrivateMethodGet(this, _getLastOption, _getLastOption2).call(this);
450
+ }
451
+
452
+ return $options[(currentIndex - 1 + $options.length) % $options.length];
453
+ }
454
+
455
+ function _selectOption2($option) {
456
+ for (const $op of _classPrivateMethodGet(this, _getOptionElements, _getOptionElements2).call(this)) {
457
+ const isSelected = $op === $option;
458
+ $op.selected = isSelected;
459
+
460
+ if (isSelected) {
461
+ $op.scrollIntoView?.({
462
+ block: 'nearest'
463
+ });
464
+ }
465
+ }
466
+ }
467
+
468
+ function _getOptionElements2() {
469
+ return _classPrivateFieldGet(this, _$optionSlot).assignedElements().filter(isSearchOptionElement);
470
+ }
@@ -0,0 +1,20 @@
1
+ import type { TSinchElementReact } from '../types';
2
+ export declare const isSearchOptionElement: (element: EventTarget | Element | null) => element is TSinchSearchOptionElement;
3
+ export declare type TSinchSearchOptionElement = HTMLElement & {
4
+ text: string;
5
+ selected: boolean;
6
+ };
7
+ export declare type TSinchSearchOptionReact = TSinchElementReact<TSinchSearchOptionElement> & {
8
+ text: string;
9
+ 'aria-label': string;
10
+ };
11
+ declare global {
12
+ namespace JSX {
13
+ interface IntrinsicElements {
14
+ 'sinch-search-option': TSinchSearchOptionReact;
15
+ }
16
+ }
17
+ interface HTMLElementTagNameMap {
18
+ 'sinch-search-option': TSinchSearchOptionElement;
19
+ }
20
+ }
@@ -0,0 +1,76 @@
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, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
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
+ const template = document.createElement('template');
11
+ template.innerHTML = templateHTML;
12
+
13
+ var _$content = new WeakMap();
14
+
15
+ class SearchOption extends HTMLElement {
16
+ constructor() {
17
+ super();
18
+
19
+ _classPrivateFieldInitSpec(this, _$content, {
20
+ writable: true,
21
+ value: void 0
22
+ });
23
+
24
+ const shadowRoot = this.attachShadow({
25
+ mode: 'closed'
26
+ });
27
+ shadowRoot.appendChild(template.content.cloneNode(true));
28
+
29
+ _classPrivateFieldSet(this, _$content, shadowRoot.querySelector('#wrapper'));
30
+ }
31
+
32
+ connectedCallback() {
33
+ this.setAttribute('role', 'option');
34
+ }
35
+
36
+ static get observedAttributes() {
37
+ return ['text'];
38
+ }
39
+
40
+ attributeChangedCallback(name, oldVal, newVal) {
41
+ if (oldVal === newVal) {
42
+ return;
43
+ }
44
+
45
+ switch (name) {
46
+ case 'text':
47
+ {
48
+ _classPrivateFieldGet(this, _$content).textContent = newVal;
49
+ break;
50
+ }
51
+ }
52
+ }
53
+
54
+ set text(value) {
55
+ updateAttribute(this, 'text', value);
56
+ }
57
+
58
+ get text() {
59
+ return getAttribute(this, 'text', '');
60
+ }
61
+
62
+ set selected(isSelected) {
63
+ updateBooleanAttribute(this, 'data-selected', isSelected);
64
+ updateExplicitBooleanAttribute(this, 'aria-selected', isSelected);
65
+ }
66
+
67
+ get selected() {
68
+ return getBooleanAttribute(this, 'data-selected');
69
+ }
70
+
71
+ }
72
+
73
+ defineCustomElement('sinch-search-option', SearchOption);
74
+ export const isSearchOptionElement = element => {
75
+ return element instanceof SearchOption;
76
+ };
package/spinner/index.js CHANGED
@@ -12,6 +12,11 @@ defineCustomElement('sinch-spinner', class extends HTMLElement {
12
12
  shadowRoot.appendChild(template.content.cloneNode(true));
13
13
  }
14
14
 
15
+ connectedCallback() {
16
+ this.setAttribute('aria-live', 'polite');
17
+ this.setAttribute('aria-busy', 'true');
18
+ }
19
+
15
20
  set type(value) {
16
21
  updateLiteralAttribute(this, spinnerTypes, 'type', value);
17
22
  }
package/tooltip/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { attrValueToPixels, defineCustomElement, getBooleanAttribute, getIntegerAttribute, getAttribute, getLiteralAttribute, updateBooleanAttribute, updateAttribute, updateLiteralAttribute, getRect } from '../utils';
2
- const templateHTML = '<style>:host{display:inline-block;vertical-align:middle}#wrapper{position:relative;display:block}#tooltip{position:absolute;left:0;top:0;width:100%;height:100%;pointer-events:none;opacity:0%;transition:opacity .2s linear .2s}@media (prefers-reduced-motion){#tooltip{transition:none}}:host(:hover) #tooltip{opacity:100%}#text{position:absolute;padding:2px 6px;font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-default);background-color:var(--sinch-color-snow-600);width:max-content;border-radius:2px;top:-8px;left:50%;transform:translateX(-50%) translateY(-100%)}#arrow{position:absolute;top:-8px;left:50%;transform:translateX(-50%);fill:var(--sinch-color-snow-600)}:host([orientation=top-left]) #text{transform:translateX(-80%) translateY(-100%)}:host([orientation=top-right]) #text{transform:translateX(-20%) translateY(-100%)}:host([orientation=bottom-right]) #text{top:calc(100% + 8px);transform:translateX(-20%)}:host([orientation=bottom-left]) #text{top:calc(100% + 8px);transform:translateX(-80%)}:host([orientation=bottom]) #text{top:calc(100% + 8px);transform:translateX(-50%)}:host([orientation^=bottom]) #arrow{top:calc(100% + 4px);transform:translateX(-50%) rotate(180deg)}:host([orientation=left]) #text{left:unset;right:calc(100% + 8px);top:50%;transform:translateY(-50%)}:host([orientation=left]) #arrow{left:-11px;top:50%;transform:translateY(-50%) rotate(270deg)}:host([orientation=right]) #text{left:calc(100% + 8px);top:50%;transform:translateY(-50%)}:host([orientation=right]) #arrow{top:50%;left:calc(100% + 2px);transform:translateY(-50%) rotate(90deg)}:host([inverted]:not([inverted=false])) #text{color:var(--sinch-color-text-inverted);background-color:var(--sinch-color-stormy-500)}:host([inverted]:not([inverted=false])) #arrow{fill:var(--sinch-color-stormy-500)}::slotted(*){display:block}</style><div id="wrapper"><slot></slot><div id="tooltip"><div id="text"></div><svg id="arrow" width="9" height="4" aria-hidden="true"><path d="m4.5 4 4-4h-8l4 4Z"/></svg></div></div>';
2
+ const templateHTML = '<style>:host{display:inline-block;vertical-align:middle}#wrapper{position:relative;display:block}#tooltip{position:absolute;left:0;top:0;width:100%;height:100%;pointer-events:none;opacity:0;transition:opacity .2s linear .2s}@media (prefers-reduced-motion){#tooltip{transition:none}}:host(:hover) #tooltip{opacity:1}#text{position:absolute;padding:2px 6px;font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-default);background-color:var(--sinch-color-snow-600);width:max-content;border-radius:2px;top:-8px;left:50%;transform:translateX(-50%) translateY(-100%)}#arrow{position:absolute;top:-8px;left:50%;transform:translateX(-50%);fill:var(--sinch-color-snow-600)}:host([orientation=top-left]) #text{transform:translateX(-80%) translateY(-100%)}:host([orientation=top-right]) #text{transform:translateX(-20%) translateY(-100%)}:host([orientation=bottom-right]) #text{top:calc(100% + 8px);transform:translateX(-20%)}:host([orientation=bottom-left]) #text{top:calc(100% + 8px);transform:translateX(-80%)}:host([orientation=bottom]) #text{top:calc(100% + 8px);transform:translateX(-50%)}:host([orientation^=bottom]) #arrow{top:calc(100% + 4px);transform:translateX(-50%) rotate(180deg)}:host([orientation=left]) #text{left:unset;right:calc(100% + 8px);top:50%;transform:translateY(-50%)}:host([orientation=left]) #arrow{left:-11px;top:50%;transform:translateY(-50%) rotate(270deg)}:host([orientation=right]) #text{left:calc(100% + 8px);top:50%;transform:translateY(-50%)}:host([orientation=right]) #arrow{top:50%;left:calc(100% + 2px);transform:translateY(-50%) rotate(90deg)}:host([inverted]:not([inverted=false])) #text{color:var(--sinch-color-text-inverted);background-color:var(--sinch-color-stormy-500)}:host([inverted]:not([inverted=false])) #arrow{fill:var(--sinch-color-stormy-500)}::slotted(*){display:block}</style><div id="wrapper"><slot></slot><div id="tooltip"><div id="text"></div><svg id="arrow" width="9" height="4" aria-hidden="true"><path d="m4.5 4 4-4h-8l4 4Z"/></svg></div></div>';
3
3
  const orientationValues = ['top', 'bottom', 'left', 'right', 'top-left', 'top-right', 'bottom-left', 'bottom-right'];
4
4
  const template = document.createElement('template');
5
5
  template.innerHTML = templateHTML;
package/utils.d.ts CHANGED
@@ -3,6 +3,7 @@ export declare const defineCustomElement: (name: string, constructor: CustomElem
3
3
  export declare const defineNectaryElements: (registry: CustomElementRegistry) => void;
4
4
  export declare type TEventHandler = (arg?: any) => void;
5
5
  export declare const updateBooleanAttribute: ($element: Element, attrName: string, attrValue: boolean | null | undefined) => void;
6
+ export declare const updateExplicitBooleanAttribute: ($element: Element, attrName: string, attrValue: boolean | null | undefined) => void;
6
7
  export declare const isAttrTrue: (attrValue: string | null) => boolean;
7
8
  export declare const getBooleanAttribute: ($element: Element, attrName: string) => boolean;
8
9
  export declare const updateAttribute: ($element: Element, attrName: string, attrValue: string | number | boolean | null | undefined) => void;
@@ -10,7 +11,7 @@ export declare function getAttribute($element: Element, attrName: string): strin
10
11
  export declare function getAttribute($element: Element, attrName: string, defaultValue: null): string | null;
11
12
  export declare function getAttribute($element: Element, attrName: string, defaultValue: string): string;
12
13
  export declare const isLiteralValue: <T extends readonly string[]>(literals: T, value: string | null | undefined) => value is T[number];
13
- export declare const updateLiteralAttribute: <T extends readonly string[]>($element: Element, literals: T, attrName: string, attrValue: T[number] | null | undefined) => void;
14
+ export declare const updateLiteralAttribute: <T extends readonly string[]>($element: Element, literals: T, attrName: string, attrValue: string | null | undefined) => void;
14
15
  export declare function getLiteralAttribute<T extends readonly string[]>($element: Element, literals: T, attrName: string): T[number] | undefined;
15
16
  export declare function getLiteralAttribute<T extends readonly string[]>($element: Element, literals: T, attrName: string, defaultValue: null): T[number] | null;
16
17
  export declare function getLiteralAttribute<T extends readonly string[]>($element: Element, literals: T, attrName: string, defaultValue: T[number]): T[number];
package/utils.js CHANGED
@@ -35,6 +35,9 @@ export const updateBooleanAttribute = ($element, attrName, attrValue) => {
35
35
  $element.removeAttribute(attrName);
36
36
  }
37
37
  };
38
+ export const updateExplicitBooleanAttribute = ($element, attrName, attrValue) => {
39
+ $element.setAttribute(attrName, attrValue === true ? 'true' : 'false');
40
+ };
38
41
  export const isAttrTrue = attrValue => {
39
42
  return attrValue === '' || attrValue !== 'false' && attrValue !== null;
40
43
  };