@nectary/components 0.38.0 → 0.40.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 (148) hide show
  1. package/accordion/index.js +47 -84
  2. package/accordion/types.d.ts +1 -0
  3. package/accordion-item/index.js +26 -53
  4. package/action-menu/index.d.ts +0 -1
  5. package/action-menu/index.js +179 -223
  6. package/action-menu/types.d.ts +8 -18
  7. package/action-menu-option/index.d.ts +1 -0
  8. package/action-menu-option/index.js +51 -62
  9. package/action-menu-option/types.d.ts +9 -0
  10. package/action-menu-option/utils.d.ts +2 -0
  11. package/action-menu-option/utils.js +3 -0
  12. package/alert/index.js +6 -20
  13. package/avatar/index.js +12 -31
  14. package/avatar-badge/index.js +8 -22
  15. package/avatar-status/index.js +1 -1
  16. package/button/index.js +42 -92
  17. package/card/index.d.ts +2 -0
  18. package/card/index.js +24 -87
  19. package/chat-avatar/index.js +8 -22
  20. package/chat-block/index.js +29 -69
  21. package/chat-bubble/index.js +6 -20
  22. package/checkbox/index.js +55 -107
  23. package/chip/index.d.ts +13 -0
  24. package/chip/index.js +137 -0
  25. package/chip/types.d.ts +38 -0
  26. package/color-menu/index.d.ts +13 -0
  27. package/color-menu/index.js +464 -0
  28. package/color-menu/types.d.ts +37 -0
  29. package/color-swatch/index.d.ts +13 -0
  30. package/color-swatch/index.js +59 -0
  31. package/color-swatch/types.d.ts +12 -0
  32. package/colors.json +57 -49
  33. package/date-picker/index.js +196 -287
  34. package/date-picker/types.d.ts +25 -1
  35. package/dialog/index.d.ts +1 -0
  36. package/dialog/index.js +72 -143
  37. package/dropdown-checkbox-option/index.js +6 -20
  38. package/dropdown-radio-option/index.js +6 -20
  39. package/field/index.js +25 -63
  40. package/file-drop/index.js +123 -200
  41. package/file-picker/index.d.ts +0 -1
  42. package/file-picker/index.js +55 -108
  43. package/file-status/index.js +15 -39
  44. package/help-tooltip/index.js +1 -1
  45. package/horizontal-stepper/index.js +33 -59
  46. package/horizontal-stepper-item/index.js +13 -37
  47. package/icon-button/index.js +39 -84
  48. package/icons-channel/notify/index.d.ts +11 -0
  49. package/icons-channel/notify/index.js +4 -0
  50. package/illustrations/create-illustration-class.js +1 -1
  51. package/inline-alert/index.js +30 -82
  52. package/input/index.js +113 -222
  53. package/link/index.js +46 -96
  54. package/list-item/index.js +1 -1
  55. package/package.json +12 -14
  56. package/pagination/index.js +109 -163
  57. package/pagination/types.d.ts +1 -0
  58. package/popover/index.js +224 -294
  59. package/progress/index.js +9 -28
  60. package/radio/index.js +103 -169
  61. package/radio/types.d.ts +1 -0
  62. package/radio-option/index.js +24 -48
  63. package/segment/index.js +50 -131
  64. package/segment-collapse/index.js +24 -49
  65. package/segment-collapse/types.d.ts +1 -0
  66. package/segmented-control/index.js +36 -73
  67. package/segmented-control/types.d.ts +1 -0
  68. package/segmented-control-option/index.js +41 -87
  69. package/segmented-icon-control/index.js +47 -84
  70. package/segmented-icon-control/types.d.ts +1 -0
  71. package/segmented-icon-control-option/index.js +38 -79
  72. package/select-button/index.d.ts +13 -0
  73. package/select-button/index.js +153 -0
  74. package/select-button/types.d.ts +43 -0
  75. package/select-menu/index.d.ts +11 -0
  76. package/select-menu/index.js +346 -0
  77. package/select-menu/types.d.ts +29 -0
  78. package/{dropdown-text-option → select-menu-option}/index.d.ts +5 -7
  79. package/select-menu-option/index.js +76 -0
  80. package/{select-option → select-menu-option}/types.d.ts +8 -9
  81. package/stop-events/index.js +7 -20
  82. package/table-head-cell/index.js +7 -21
  83. package/tabs/index.js +103 -165
  84. package/tabs/types.d.ts +1 -0
  85. package/tabs-option/index.js +20 -44
  86. package/tag/index.d.ts +1 -1
  87. package/tag/index.js +42 -36
  88. package/tag/types.d.ts +13 -7
  89. package/textarea/index.js +92 -167
  90. package/theme.css +80 -49
  91. package/tile-control/index.js +55 -96
  92. package/tile-control-option/index.js +40 -86
  93. package/time-picker/index.js +224 -368
  94. package/time-picker/types.d.ts +5 -1
  95. package/title/index.js +6 -20
  96. package/toast/index.d.ts +17 -0
  97. package/toast/index.js +115 -0
  98. package/toast/types.d.ts +28 -0
  99. package/toast/utils.d.ts +5 -0
  100. package/toast/utils.js +6 -0
  101. package/toast-manager/index.d.ts +17 -0
  102. package/toast-manager/index.js +195 -0
  103. package/toast-manager/types.d.ts +7 -0
  104. package/toggle/index.js +55 -108
  105. package/toggle/types.d.ts +1 -0
  106. package/types.d.ts +7 -0
  107. package/utils/colors.d.ts +10 -0
  108. package/utils/colors.js +121 -0
  109. package/{utils.d.ts → utils/index.d.ts} +18 -9
  110. package/{utils.js → utils/index.js} +118 -39
  111. package/vertical-stepper/index.js +29 -50
  112. package/vertical-stepper-item/index.js +13 -37
  113. package/card-button/index.d.ts +0 -11
  114. package/card-button/index.js +0 -77
  115. package/card-button/types.d.ts +0 -12
  116. package/card-link/index.d.ts +0 -12
  117. package/card-link/index.js +0 -115
  118. package/card-link/types.d.ts +0 -14
  119. package/dropdown/index.d.ts +0 -12
  120. package/dropdown/index.js +0 -415
  121. package/dropdown/types.d.ts +0 -30
  122. package/dropdown-text-option/index.js +0 -104
  123. package/dropdown-text-option/types.d.ts +0 -16
  124. package/search/index.d.ts +0 -14
  125. package/search/index.js +0 -523
  126. package/search/types.d.ts +0 -25
  127. package/search-option/index.d.ts +0 -11
  128. package/search-option/index.js +0 -55
  129. package/search-option/types.d.ts +0 -9
  130. package/select/index.d.ts +0 -13
  131. package/select/index.js +0 -316
  132. package/select/types.d.ts +0 -53
  133. package/select-option/index.d.ts +0 -11
  134. package/select-option/index.js +0 -8
  135. package/tag/utils.d.ts +0 -2
  136. package/tag/utils.js +0 -1
  137. package/tag-close/index.d.ts +0 -12
  138. package/tag-close/index.js +0 -38
  139. package/tag-close/types.d.ts +0 -3
  140. package/tag-close/types.js +0 -1
  141. /package/{card-button → chip}/types.js +0 -0
  142. /package/{card-link → color-menu}/types.js +0 -0
  143. /package/{dropdown-text-option → color-swatch}/types.js +0 -0
  144. /package/{dropdown → select-button}/types.js +0 -0
  145. /package/{search → select-menu}/types.js +0 -0
  146. /package/{search-option → select-menu-option}/types.js +0 -0
  147. /package/{select → toast}/types.js +0 -0
  148. /package/{select-option → toast-manager}/types.js +0 -0
package/dropdown/index.js DELETED
@@ -1,415 +0,0 @@
1
- import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
- import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
-
4
- var _$optionSlot, _$listbox, _$popover, _onListboxClick, _onListboxKeyDown, _onOptionSlotChange, _onValueChange, _getFirstOption, _getLastOption, _getNextOption, _getPrevOption, _selectOption, _getOptionWithValue, _getOptionElements, _findSelectedOption, _getEnabledOptionElements, _dispatchChangeEvent, _onClose, _onCloseReactHandler, _onChangeReactHandler;
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 { orientationValues } from '../popover/utils';
15
- import '../popover';
16
- import { attrValueToPixels, defineCustomElement, getAttribute, getBooleanAttribute, getCsvSet, getFirstCsvValue, getIntegerAttribute, getLiteralAttribute, getReactEventHandler, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateCsv, updateIntegerAttribute, updateLiteralAttribute } from '../utils';
17
- const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{width:100%;--sinch-popover-shape-radius:var(--sinch-shape-radius-s)}#listbox{overflow-y:auto}</style><sinch-popover id="wrapper" modal><slot name="target" slot="target"></slot><div id="listbox" slot="content"><slot name="option"></slot></div></sinch-popover>';
18
- const ITEM_HEIGHT = 40;
19
- const template = document.createElement('template');
20
- template.innerHTML = templateHTML;
21
- defineCustomElement('sinch-dropdown', (_$optionSlot = new WeakMap(), _$listbox = new WeakMap(), _$popover = new WeakMap(), _onListboxClick = new WeakMap(), _onListboxKeyDown = new WeakMap(), _onOptionSlotChange = new WeakMap(), _onValueChange = new WeakSet(), _getFirstOption = new WeakSet(), _getLastOption = new WeakSet(), _getNextOption = new WeakSet(), _getPrevOption = new WeakSet(), _selectOption = new WeakSet(), _getOptionWithValue = new WeakSet(), _getOptionElements = new WeakSet(), _findSelectedOption = new WeakSet(), _getEnabledOptionElements = new WeakSet(), _dispatchChangeEvent = new WeakSet(), _onClose = new WeakMap(), _onCloseReactHandler = new WeakMap(), _onChangeReactHandler = new WeakMap(), class extends NectaryElement {
22
- constructor() {
23
- super();
24
-
25
- _classPrivateMethodInitSpec(this, _dispatchChangeEvent);
26
-
27
- _classPrivateMethodInitSpec(this, _getEnabledOptionElements);
28
-
29
- _classPrivateMethodInitSpec(this, _findSelectedOption);
30
-
31
- _classPrivateMethodInitSpec(this, _getOptionElements);
32
-
33
- _classPrivateMethodInitSpec(this, _getOptionWithValue);
34
-
35
- _classPrivateMethodInitSpec(this, _selectOption);
36
-
37
- _classPrivateMethodInitSpec(this, _getPrevOption);
38
-
39
- _classPrivateMethodInitSpec(this, _getNextOption);
40
-
41
- _classPrivateMethodInitSpec(this, _getLastOption);
42
-
43
- _classPrivateMethodInitSpec(this, _getFirstOption);
44
-
45
- _classPrivateMethodInitSpec(this, _onValueChange);
46
-
47
- _classPrivateFieldInitSpec(this, _$optionSlot, {
48
- writable: true,
49
- value: void 0
50
- });
51
-
52
- _classPrivateFieldInitSpec(this, _$listbox, {
53
- writable: true,
54
- value: void 0
55
- });
56
-
57
- _classPrivateFieldInitSpec(this, _$popover, {
58
- writable: true,
59
- value: void 0
60
- });
61
-
62
- _classPrivateFieldInitSpec(this, _onListboxClick, {
63
- writable: true,
64
- value: e => {
65
- const $elem = e.target;
66
-
67
- if (getBooleanAttribute($elem, 'disabled')) {
68
- return;
69
- }
70
-
71
- e.stopPropagation();
72
-
73
- _classPrivateMethodGet(this, _dispatchChangeEvent, _dispatchChangeEvent2).call(this, $elem);
74
- }
75
- });
76
-
77
- _classPrivateFieldInitSpec(this, _onListboxKeyDown, {
78
- writable: true,
79
- value: e => {
80
- switch (e.code) {
81
- case 'Space':
82
- case 'Enter':
83
- {
84
- const $option = _classPrivateMethodGet(this, _findSelectedOption, _findSelectedOption2).call(this, _classPrivateMethodGet(this, _getEnabledOptionElements, _getEnabledOptionElements2).call(this));
85
-
86
- if ($option !== null) {
87
- e.preventDefault();
88
-
89
- _classPrivateMethodGet(this, _dispatchChangeEvent, _dispatchChangeEvent2).call(this, $option);
90
- }
91
-
92
- break;
93
- }
94
-
95
- case 'ArrowUp':
96
- case 'ArrowLeft':
97
- {
98
- e.preventDefault();
99
-
100
- _classPrivateMethodGet(this, _selectOption, _selectOption2).call(this, _classPrivateMethodGet(this, _getPrevOption, _getPrevOption2).call(this));
101
-
102
- break;
103
- }
104
-
105
- case 'ArrowDown':
106
- case 'ArrowRight':
107
- {
108
- e.preventDefault();
109
-
110
- _classPrivateMethodGet(this, _selectOption, _selectOption2).call(this, _classPrivateMethodGet(this, _getNextOption, _getNextOption2).call(this));
111
-
112
- break;
113
- }
114
- }
115
- }
116
- });
117
-
118
- _classPrivateFieldInitSpec(this, _onOptionSlotChange, {
119
- writable: true,
120
- value: () => {
121
- _classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this, this.value);
122
- }
123
- });
124
-
125
- _classPrivateFieldInitSpec(this, _onClose, {
126
- writable: true,
127
- value: () => {
128
- this.dispatchEvent(new CustomEvent('-close'));
129
- }
130
- });
131
-
132
- _classPrivateFieldInitSpec(this, _onCloseReactHandler, {
133
- writable: true,
134
- value: e => {
135
- getReactEventHandler(this, 'onClose')?.();
136
- getReactEventHandler(this, 'on-close')?.(e);
137
- }
138
- });
139
-
140
- _classPrivateFieldInitSpec(this, _onChangeReactHandler, {
141
- writable: true,
142
- value: e => {
143
- getReactEventHandler(this, 'on-change')?.(e);
144
- }
145
- });
146
-
147
- const shadowRoot = this.attachShadow();
148
- shadowRoot.appendChild(template.content.cloneNode(true));
149
-
150
- _classPrivateFieldSet(this, _$optionSlot, shadowRoot.querySelector('slot[name="option"]'));
151
-
152
- _classPrivateFieldSet(this, _$listbox, shadowRoot.querySelector('#listbox'));
153
-
154
- _classPrivateFieldSet(this, _$popover, shadowRoot.querySelector('sinch-popover'));
155
- }
156
-
157
- connectedCallback() {
158
- this.setAttribute('role', 'listbox');
159
-
160
- _classPrivateFieldGet(this, _$optionSlot).addEventListener('slotchange', _classPrivateFieldGet(this, _onOptionSlotChange));
161
-
162
- this.addEventListener('-close', _classPrivateFieldGet(this, _onCloseReactHandler));
163
- this.addEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
164
- }
165
-
166
- disconnectedCallback() {
167
- _classPrivateFieldGet(this, _$optionSlot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onOptionSlotChange));
168
-
169
- this.removeEventListener('-close', _classPrivateFieldGet(this, _onCloseReactHandler));
170
- this.removeEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
171
- }
172
-
173
- static get observedAttributes() {
174
- return ['open', 'value', 'orientation', 'maxvisibleitems', 'multiple'];
175
- }
176
-
177
- get nodeName() {
178
- return 'select';
179
- }
180
-
181
- set value(value) {
182
- updateAttribute(this, 'value', value);
183
- }
184
-
185
- get value() {
186
- return getAttribute(this, 'value', '');
187
- }
188
-
189
- set maxVisibleItems(value) {
190
- updateIntegerAttribute(this, 'maxvisibleitems', value);
191
- }
192
-
193
- get maxVisibleItems() {
194
- return getIntegerAttribute(this, 'maxvisibleitems', null);
195
- }
196
-
197
- get orientation() {
198
- return getLiteralAttribute(this, orientationValues, 'orientation', 'bottom-right');
199
- }
200
-
201
- set orientation(value) {
202
- updateLiteralAttribute(this, orientationValues, 'orientation', value);
203
- }
204
-
205
- set open(isOpen) {
206
- updateBooleanAttribute(this, 'open', isOpen);
207
- }
208
-
209
- get open() {
210
- return getBooleanAttribute(this, 'open');
211
- }
212
-
213
- set multiple(isMultiple) {
214
- updateBooleanAttribute(this, 'multiple', isMultiple);
215
- }
216
-
217
- get multiple() {
218
- return getBooleanAttribute(this, 'multiple');
219
- }
220
-
221
- get dropdownRect() {
222
- return _classPrivateFieldGet(this, _$popover).popoverRect;
223
- }
224
-
225
- attributeChangedCallback(name, oldVal, newVal) {
226
- if (oldVal === newVal) {
227
- return;
228
- }
229
-
230
- switch (name) {
231
- case 'open':
232
- {
233
- updateAttribute(_classPrivateFieldGet(this, _$popover), 'open', newVal);
234
-
235
- if (isAttrTrue(newVal)) {
236
- _classPrivateMethodGet(this, _selectOption, _selectOption2).call(this, _classPrivateMethodGet(this, _getOptionWithValue, _getOptionWithValue2).call(this, getFirstCsvValue(this.value)) ?? _classPrivateMethodGet(this, _getFirstOption, _getFirstOption2).call(this));
237
-
238
- _classPrivateFieldGet(this, _$popover).addEventListener('keydown', _classPrivateFieldGet(this, _onListboxKeyDown));
239
-
240
- _classPrivateFieldGet(this, _$listbox).addEventListener('click', _classPrivateFieldGet(this, _onListboxClick));
241
-
242
- _classPrivateFieldGet(this, _$popover).addEventListener('-close', _classPrivateFieldGet(this, _onClose));
243
- } else {
244
- _classPrivateFieldGet(this, _$popover).removeEventListener('keydown', _classPrivateFieldGet(this, _onListboxKeyDown));
245
-
246
- _classPrivateFieldGet(this, _$listbox).removeEventListener('click', _classPrivateFieldGet(this, _onListboxClick));
247
-
248
- _classPrivateFieldGet(this, _$popover).removeEventListener('-close', _classPrivateFieldGet(this, _onClose));
249
- }
250
-
251
- break;
252
- }
253
-
254
- case 'multiple':
255
- {
256
- _classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this, this.value);
257
-
258
- break;
259
- }
260
-
261
- case 'orientation':
262
- {
263
- updateAttribute(_classPrivateFieldGet(this, _$popover), 'orientation', newVal);
264
- break;
265
- }
266
-
267
- case 'value':
268
- {
269
- _classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this, newVal ?? '');
270
-
271
- break;
272
- }
273
-
274
- case 'maxvisibleitems':
275
- {
276
- const $list = _classPrivateFieldGet(this, _$listbox);
277
-
278
- if (newVal === '0') {
279
- $list.style.maxHeight = 'unset';
280
- } else {
281
- $list.style.maxHeight = attrValueToPixels(newVal, {
282
- min: 2,
283
- multiplier: ITEM_HEIGHT
284
- });
285
- }
286
-
287
- break;
288
- }
289
- }
290
- }
291
-
292
- }));
293
-
294
- function _onValueChange2(csv) {
295
- if (this.multiple) {
296
- const values = getCsvSet(csv);
297
-
298
- for (const $option of _classPrivateMethodGet(this, _getOptionElements, _getOptionElements2).call(this)) {
299
- const isChecked = !getBooleanAttribute($option, 'disabled') && values.has(getAttribute($option, 'value', ''));
300
- updateBooleanAttribute($option, 'data-checked', isChecked);
301
- }
302
- } else {
303
- const value = getFirstCsvValue(csv);
304
-
305
- for (const $option of _classPrivateMethodGet(this, _getOptionElements, _getOptionElements2).call(this)) {
306
- const isChecked = !getBooleanAttribute($option, 'disabled') && value === getAttribute($option, 'value', '');
307
- updateBooleanAttribute($option, 'data-checked', isChecked);
308
- }
309
- }
310
- }
311
-
312
- function _getFirstOption2() {
313
- return _classPrivateMethodGet(this, _getEnabledOptionElements, _getEnabledOptionElements2).call(this)[0] ?? null;
314
- }
315
-
316
- function _getLastOption2() {
317
- return _classPrivateMethodGet(this, _getEnabledOptionElements, _getEnabledOptionElements2).call(this).reverse()[0] ?? null;
318
- }
319
-
320
- function _getNextOption2() {
321
- const $options = _classPrivateMethodGet(this, _getEnabledOptionElements, _getEnabledOptionElements2).call(this);
322
-
323
- const $selectedOption = _classPrivateMethodGet(this, _findSelectedOption, _findSelectedOption2).call(this, $options);
324
-
325
- const currentIndex = $selectedOption !== null ? $options.indexOf($selectedOption) : -1;
326
-
327
- if (currentIndex < 0) {
328
- return _classPrivateMethodGet(this, _getFirstOption, _getFirstOption2).call(this);
329
- }
330
-
331
- return $options[(currentIndex + 1) % $options.length];
332
- }
333
-
334
- function _getPrevOption2() {
335
- const $options = _classPrivateMethodGet(this, _getEnabledOptionElements, _getEnabledOptionElements2).call(this);
336
-
337
- const $selectedOption = _classPrivateMethodGet(this, _findSelectedOption, _findSelectedOption2).call(this, $options);
338
-
339
- const currentIndex = $selectedOption !== null ? $options.indexOf($selectedOption) : -1;
340
-
341
- if (currentIndex < 0) {
342
- return _classPrivateMethodGet(this, _getLastOption, _getLastOption2).call(this);
343
- }
344
-
345
- return $options[(currentIndex - 1 + $options.length) % $options.length];
346
- }
347
-
348
- function _selectOption2($option) {
349
- const hasMaxVisibleItems = this.hasAttribute('maxvisibleitems');
350
-
351
- for (const $op of _classPrivateMethodGet(this, _getOptionElements, _getOptionElements2).call(this)) {
352
- const isSelected = $op === $option;
353
- updateBooleanAttribute($op, 'data-selected', isSelected);
354
-
355
- if (isSelected && hasMaxVisibleItems) {
356
- $op.scrollIntoView?.({
357
- block: 'nearest'
358
- });
359
- }
360
- }
361
- }
362
-
363
- function _getOptionWithValue2(value) {
364
- if (value === null) {
365
- return null;
366
- }
367
-
368
- for (const $option of _classPrivateMethodGet(this, _getOptionElements, _getOptionElements2).call(this)) {
369
- if ($option.disabled !== true && $option.value === value) {
370
- return $option;
371
- }
372
- }
373
-
374
- return null;
375
- }
376
-
377
- function _getOptionElements2() {
378
- let $elements = _classPrivateFieldGet(this, _$optionSlot).assignedElements();
379
-
380
- if ($elements.length === 1 && $elements[0].tagName === 'SLOT') {
381
- $elements = $elements[0].assignedElements();
382
- }
383
-
384
- return $elements;
385
- }
386
-
387
- function _findSelectedOption2(elements) {
388
- for (const el of elements) {
389
- if (getBooleanAttribute(el, 'data-selected')) {
390
- return el;
391
- }
392
- }
393
-
394
- return null;
395
- }
396
-
397
- function _getEnabledOptionElements2() {
398
- return _classPrivateMethodGet(this, _getOptionElements, _getOptionElements2).call(this).filter(opt => opt.disabled !== true);
399
- }
400
-
401
- function _dispatchChangeEvent2($opt) {
402
- if ($opt === null) {
403
- return;
404
- }
405
-
406
- const value = $opt.value;
407
- const result = this.multiple ? updateCsv(this.value, value, !getBooleanAttribute($opt, 'data-checked')) : value;
408
- this.dispatchEvent(new CustomEvent('change', {
409
- detail: result,
410
- bubbles: true
411
- }));
412
- this.dispatchEvent(new CustomEvent('-change', {
413
- detail: result
414
- }));
415
- }
@@ -1,30 +0,0 @@
1
- import type { TSinchPopoverOrientation } from '../popover/types';
2
- import type { TRect, TSinchElementReact } from '../types';
3
- import type { SyntheticEvent } from 'react';
4
- export declare type TSinchDropdownElement = HTMLElement & {
5
- open: boolean;
6
- multiple: boolean;
7
- orientation: TSinchPopoverOrientation;
8
- value: string;
9
- maxVisibleItems: number | null;
10
- readonly dropdownRect: TRect;
11
- addEventListener(type: '-change', listener: (e: CustomEvent<string>) => void): void;
12
- addEventListener(type: '-close', listener: (e: CustomEvent<void>) => void): void;
13
- setAttribute(name: 'open', value: ''): void;
14
- setAttribute(name: 'multiple', value: ''): void;
15
- setAttribute(name: 'orientation', value: TSinchPopoverOrientation): void;
16
- setAttribute(name: 'value', value: string): void;
17
- setAttribute(name: 'maxvisibleitems', value: string): void;
18
- };
19
- export declare type TSinchDropdownReact = TSinchElementReact<TSinchDropdownElement> & {
20
- open: boolean;
21
- multiple?: boolean;
22
- orientation?: TSinchPopoverOrientation;
23
- value: string;
24
- maxVisibleItems?: number;
25
- 'aria-label': string;
26
- onClose?: () => void;
27
- 'on-close'?: (e: CustomEvent<void>) => void;
28
- onChange?: (e: SyntheticEvent<TSinchDropdownElement, CustomEvent<string>>) => void;
29
- 'on-change'?: (e: CustomEvent<string>) => void;
30
- };
@@ -1,104 +0,0 @@
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 '../icons/check';
9
- import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
10
- const templateHTML = '<style>:host{display:block}#wrapper{display:flex;position:relative;box-sizing:border-box;height:40px;padding:8px 16px;align-items:center;gap:10px;user-select:none;cursor:pointer;--sinch-color-icon:var(--sinch-color-stormy-500);--sinch-size-icon:24px}#content{flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}:host(:hover)>#wrapper,:host([data-selected])>#wrapper{background-color:var(--sinch-color-snow-500)}#check{display:none;margin-right:-6px}:host([data-checked]) #check{display:block}:host([disabled]:not([disabled=false]))>#wrapper{color:var(--sinch-color-stormy-100);cursor:initial;--sinch-color-icon:var(--sinch-color-stormy-100)}::slotted(*){margin-left:-6px}</style><div id="wrapper"><slot name="icon"></slot><span id="content"></span><sinch-icon-check id="check"></sinch-icon-check></div>';
11
- const template = document.createElement('template');
12
- template.innerHTML = templateHTML;
13
-
14
- var _$iconSlot = new WeakMap();
15
-
16
- var _$content = new WeakMap();
17
-
18
- export class DropdownTextOption extends NectaryElement {
19
- constructor() {
20
- super();
21
-
22
- _classPrivateFieldInitSpec(this, _$iconSlot, {
23
- writable: true,
24
- value: void 0
25
- });
26
-
27
- _classPrivateFieldInitSpec(this, _$content, {
28
- writable: true,
29
- value: void 0
30
- });
31
-
32
- const shadowRoot = this.attachShadow();
33
- shadowRoot.appendChild(template.content.cloneNode(true));
34
-
35
- _classPrivateFieldSet(this, _$iconSlot, shadowRoot.querySelector('slot'));
36
-
37
- _classPrivateFieldSet(this, _$content, shadowRoot.querySelector('#content'));
38
- }
39
-
40
- connectedCallback() {
41
- this.setAttribute('role', 'option');
42
- }
43
-
44
- static get observedAttributes() {
45
- return ['text', 'checked'];
46
- }
47
-
48
- attributeChangedCallback(name, oldVal, newVal) {
49
- if (oldVal === newVal) {
50
- return;
51
- }
52
-
53
- switch (name) {
54
- case 'text':
55
- {
56
- _classPrivateFieldGet(this, _$content).textContent = newVal;
57
- break;
58
- }
59
-
60
- case 'checked':
61
- {
62
- updateExplicitBooleanAttribute(this, 'aria-selected', isAttrTrue(newVal));
63
- }
64
- }
65
- }
66
-
67
- set value(value) {
68
- updateAttribute(this, 'value', value);
69
- }
70
-
71
- get value() {
72
- return getAttribute(this, 'value', '');
73
- }
74
-
75
- set text(value) {
76
- updateAttribute(this, 'text', value);
77
- }
78
-
79
- get text() {
80
- return getAttribute(this, 'text', '');
81
- }
82
-
83
- set disabled(isDisabled) {
84
- updateBooleanAttribute(this, 'disabled', isDisabled);
85
- }
86
-
87
- get disabled() {
88
- return getBooleanAttribute(this, 'disabled');
89
- }
90
-
91
- set checked(isChecked) {
92
- updateBooleanAttribute(this, 'checked', isChecked);
93
- }
94
-
95
- get checked() {
96
- return getBooleanAttribute(this, 'checked');
97
- }
98
-
99
- get icon() {
100
- return _classPrivateFieldGet(this, _$iconSlot).assignedElements()[0] ?? null;
101
- }
102
-
103
- }
104
- defineCustomElement('sinch-dropdown-text-option', DropdownTextOption);
@@ -1,16 +0,0 @@
1
- import type { TSinchElementReact } from '../types';
2
- export declare type TSinchDropdownTextOptionElement = HTMLElement & {
3
- value: string;
4
- text: string;
5
- disabled: boolean;
6
- readonly icon: Element | null;
7
- setAttribute(name: 'value', value: string): void;
8
- setAttribute(name: 'text', value: string): void;
9
- setAttribute(name: 'disabled', value: ''): void;
10
- };
11
- export declare type TSinchDropdownTextOptionReact = TSinchElementReact<TSinchDropdownTextOptionElement> & {
12
- value: string;
13
- text: string;
14
- disabled?: boolean;
15
- 'aria-label': string;
16
- };
package/search/index.d.ts DELETED
@@ -1,14 +0,0 @@
1
- import '../icons/search';
2
- import '../icons/close';
3
- import '../icon-button';
4
- import type { TSinchSearchElement, TSinchSearchReact } from './types';
5
- declare global {
6
- namespace JSX {
7
- interface IntrinsicElements {
8
- 'sinch-search': TSinchSearchReact;
9
- }
10
- }
11
- interface HTMLElementTagNameMap {
12
- 'sinch-search': TSinchSearchElement;
13
- }
14
- }