@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
@@ -0,0 +1,346 @@
1
+ import { attrValueToPixels, defineCustomElement, getAttribute, getBooleanAttribute, getCsvSet, getFirstCsvValue, getIntegerAttribute, getReactEventHandler, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateCsv, updateExplicitBooleanAttribute, updateIntegerAttribute } from '../utils';
2
+ const templateHTML = '<style>:host{display:block;outline:0}#listbox{overflow-y:auto}</style><div id="listbox" role="presentation"><slot></slot></div>';
3
+ const ITEM_HEIGHT = 40;
4
+ const template = document.createElement('template');
5
+ template.innerHTML = templateHTML;
6
+ defineCustomElement('sinch-select-menu', class extends NectaryElement {
7
+ #$optionSlot;
8
+ #$listbox;
9
+ #controller = new AbortController();
10
+
11
+ constructor() {
12
+ super();
13
+ const shadowRoot = this.attachShadow();
14
+ shadowRoot.appendChild(template.content.cloneNode(true));
15
+ this.#$optionSlot = shadowRoot.querySelector('slot');
16
+ this.#$listbox = shadowRoot.querySelector('#listbox');
17
+ }
18
+
19
+ connectedCallback() {
20
+ const {
21
+ signal
22
+ } = this.#controller;
23
+ this.setAttribute('role', 'listbox');
24
+ this.setAttribute('tabindex', '0');
25
+ this.addEventListener('keydown', this.#onListboxKeyDown, {
26
+ signal
27
+ });
28
+ this.addEventListener('-keydown', this.#onContexKeydown, {
29
+ signal
30
+ });
31
+ this.addEventListener('blur', this.#onListboxBlur, {
32
+ signal
33
+ });
34
+ this.#$listbox.addEventListener('mousedown', this.#onListboxMousedown, {
35
+ signal
36
+ });
37
+ this.#$listbox.addEventListener('click', this.#onListboxClick, {
38
+ signal
39
+ });
40
+ this.#$optionSlot.addEventListener('slotchange', this.#onOptionSlotChange, {
41
+ signal
42
+ });
43
+ this.addEventListener('-change', this.#onChangeReactHandler, {
44
+ signal
45
+ });
46
+ this.addEventListener('-visibility', this.#onContextVisibility, {
47
+ signal
48
+ });
49
+ this.dispatchEvent(new CustomEvent('-context-connect-keydown', {
50
+ bubbles: true
51
+ }));
52
+ this.dispatchEvent(new CustomEvent('-context-connect-visibility', {
53
+ bubbles: true
54
+ }));
55
+ }
56
+
57
+ disconnectedCallback() {
58
+ this.#controller.abort();
59
+ this.dispatchEvent(new CustomEvent('-context-disconnect-keydown', {
60
+ bubbles: true
61
+ }));
62
+ this.dispatchEvent(new CustomEvent('-context-disconnect-visibility', {
63
+ bubbles: true
64
+ }));
65
+ }
66
+
67
+ static get observedAttributes() {
68
+ return ['value', 'rows', 'multiple'];
69
+ }
70
+
71
+ set value(value) {
72
+ updateAttribute(this, 'value', value);
73
+ }
74
+
75
+ get value() {
76
+ return getAttribute(this, 'value', '');
77
+ }
78
+
79
+ set rows(value) {
80
+ updateIntegerAttribute(this, 'rows', value);
81
+ }
82
+
83
+ get rows() {
84
+ return getIntegerAttribute(this, 'rows', null);
85
+ }
86
+
87
+ set multiple(isMultiple) {
88
+ updateBooleanAttribute(this, 'multiple', isMultiple);
89
+ }
90
+
91
+ get multiple() {
92
+ return getBooleanAttribute(this, 'multiple');
93
+ }
94
+
95
+ attributeChangedCallback(name, oldVal, newVal) {
96
+ if (oldVal === newVal) {
97
+ return;
98
+ }
99
+
100
+ switch (name) {
101
+ case 'multiple':
102
+ {
103
+ this.#onValueChange(this.value);
104
+ updateExplicitBooleanAttribute(this, 'aria-multiselectable', isAttrTrue(newVal));
105
+ break;
106
+ }
107
+
108
+ case 'value':
109
+ {
110
+ this.#onValueChange(newVal ?? '');
111
+ break;
112
+ }
113
+
114
+ case 'rows':
115
+ {
116
+ this.#$listbox.style.maxHeight = attrValueToPixels(newVal, {
117
+ min: 2,
118
+ itemSizeMultiplier: ITEM_HEIGHT
119
+ });
120
+ break;
121
+ }
122
+ }
123
+ }
124
+
125
+ #onListboxMousedown = e => {
126
+ const $elem = e.target;
127
+
128
+ if (!getBooleanAttribute($elem, 'disabled')) {
129
+ this.#dispatchChangeEvent($elem);
130
+ }
131
+ };
132
+ #onListboxBlur = () => {
133
+ this.#selectOption(null);
134
+ };
135
+ #onListboxClick = e => {
136
+ const $elem = e.target;
137
+
138
+ if (!getBooleanAttribute($elem, 'disabled')) {
139
+ this.#selectOption($elem);
140
+ }
141
+ };
142
+ #onContexKeydown = e => {
143
+ this.#handleKeydown(e.detail);
144
+ };
145
+ #onContextVisibility = e => {
146
+ if (e.detail) {
147
+ this.#selectOption(this.#findCheckedOption());
148
+ } else {
149
+ this.#selectOption(null);
150
+ }
151
+ };
152
+ #onListboxKeyDown = e => {
153
+ this.#handleKeydown(e);
154
+ };
155
+
156
+ #handleKeydown(e) {
157
+ switch (e.code) {
158
+ case 'Space':
159
+ case 'Enter':
160
+ {
161
+ const $option = this.#findSelectedOption();
162
+
163
+ if ($option !== null) {
164
+ e.preventDefault();
165
+ this.#dispatchChangeEvent($option);
166
+ }
167
+
168
+ break;
169
+ }
170
+
171
+ case 'ArrowUp':
172
+ {
173
+ e.preventDefault();
174
+ this.#selectOption(this.#getPrevOption());
175
+ break;
176
+ }
177
+
178
+ case 'ArrowDown':
179
+ {
180
+ e.preventDefault();
181
+ this.#selectOption(this.#getNextOption());
182
+ break;
183
+ }
184
+ }
185
+ }
186
+
187
+ #onOptionSlotChange = () => {
188
+ this.#onValueChange(this.value);
189
+ };
190
+
191
+ #onValueChange(csv) {
192
+ if (this.multiple) {
193
+ const values = getCsvSet(csv);
194
+
195
+ for (const $option of this.#getOptionElements()) {
196
+ const isChecked = !getBooleanAttribute($option, 'disabled') && values.has(getAttribute($option, 'value', ''));
197
+ updateBooleanAttribute($option, 'data-checked', isChecked);
198
+ }
199
+ } else {
200
+ const value = getFirstCsvValue(csv);
201
+
202
+ for (const $option of this.#getOptionElements()) {
203
+ const isChecked = !getBooleanAttribute($option, 'disabled') && value === getAttribute($option, 'value', '');
204
+ updateBooleanAttribute($option, 'data-checked', isChecked);
205
+ }
206
+ }
207
+ }
208
+
209
+ #getFirstOption() {
210
+ const $options = this.#getOptionElements();
211
+
212
+ for (let i = 0; i < $options.length; i++) {
213
+ const el = $options[i];
214
+
215
+ if (!getBooleanAttribute(el, 'disabled')) {
216
+ return el;
217
+ }
218
+ }
219
+
220
+ return null;
221
+ }
222
+
223
+ #getLastOption() {
224
+ const $options = this.#getOptionElements();
225
+
226
+ for (let i = $options.length - 1; i >= 0; i--) {
227
+ const el = $options[i];
228
+
229
+ if (!getBooleanAttribute(el, 'disabled')) {
230
+ return el;
231
+ }
232
+ }
233
+
234
+ return null;
235
+ }
236
+
237
+ #getNextOption() {
238
+ const index = this.#getSelectedOptionIndex();
239
+
240
+ if (index !== null) {
241
+ const $options = this.#getOptionElements();
242
+
243
+ for (let i = 1; i <= $options.length; i++) {
244
+ const el = $options[(i + index) % $options.length];
245
+
246
+ if (!getBooleanAttribute(el, 'disabled')) {
247
+ return el;
248
+ }
249
+ }
250
+ }
251
+
252
+ return this.#getFirstOption();
253
+ }
254
+
255
+ #getPrevOption() {
256
+ const index = this.#getSelectedOptionIndex();
257
+
258
+ if (index !== null) {
259
+ const $options = this.#getOptionElements();
260
+
261
+ for (let i = 1; i <= $options.length; i++) {
262
+ const el = $options[(index - i + $options.length) % $options.length];
263
+
264
+ if (!getBooleanAttribute(el, 'disabled')) {
265
+ return el;
266
+ }
267
+ }
268
+ }
269
+
270
+ return this.#getLastOption();
271
+ }
272
+
273
+ #selectOption($option) {
274
+ const hasRows = this.hasAttribute('rows');
275
+
276
+ for (const $op of this.#getOptionElements()) {
277
+ const isSelected = $op === $option;
278
+ updateBooleanAttribute($op, 'data-selected', isSelected);
279
+
280
+ if (isSelected && hasRows) {
281
+ $op.scrollIntoView?.({
282
+ block: 'nearest'
283
+ });
284
+ }
285
+ }
286
+ }
287
+
288
+ #getOptionElements() {
289
+ return this.#$optionSlot.assignedElements();
290
+ }
291
+
292
+ #getSelectedOptionIndex() {
293
+ const elements = this.#getOptionElements();
294
+
295
+ for (let i = 0; i < elements.length; i++) {
296
+ const el = elements[i];
297
+
298
+ if (!getBooleanAttribute(el, 'disabled') && getBooleanAttribute(el, 'data-selected')) {
299
+ return i;
300
+ }
301
+ }
302
+
303
+ return null;
304
+ }
305
+
306
+ #findSelectedOption() {
307
+ const elements = this.#getOptionElements();
308
+
309
+ for (const el of elements) {
310
+ if (!getBooleanAttribute(el, 'disabled') && getBooleanAttribute(el, 'data-selected')) {
311
+ return el;
312
+ }
313
+ }
314
+
315
+ return null;
316
+ }
317
+
318
+ #findCheckedOption() {
319
+ const elements = this.#getOptionElements();
320
+ const value = this.multiple ? getFirstCsvValue(this.value) : this.value;
321
+
322
+ for (const $el of elements) {
323
+ if (!getBooleanAttribute($el, 'disabled') && getAttribute($el, 'value') === value) {
324
+ return $el;
325
+ }
326
+ }
327
+
328
+ return null;
329
+ }
330
+
331
+ #dispatchChangeEvent($opt) {
332
+ if ($opt === null) {
333
+ return;
334
+ }
335
+
336
+ const value = $opt.value;
337
+ const result = this.multiple ? updateCsv(this.value, value, !getBooleanAttribute($opt, 'data-checked')) : value;
338
+ this.dispatchEvent(new CustomEvent('-change', {
339
+ detail: result
340
+ }));
341
+ }
342
+
343
+ #onChangeReactHandler = e => {
344
+ getReactEventHandler(this, 'on-change')?.(e);
345
+ };
346
+ });
@@ -0,0 +1,29 @@
1
+ import type { TSinchElementReact } from '../types';
2
+ export declare type TSinchSelectMenuElement = HTMLElement & {
3
+ /** Selected value, CSV when multiple */
4
+ value: string;
5
+ /** How many rows to show and scroll the rest */
6
+ rows: number | null;
7
+ /** Allows multiple selection */
8
+ multiple: boolean;
9
+ /** Change value event */
10
+ addEventListener(type: '-change', listener: (e: CustomEvent<string>) => void): void;
11
+ /** Selected value, CSV when multiple */
12
+ setAttribute(name: 'value', value: string): void;
13
+ /** How many rows to show and scroll the rest */
14
+ setAttribute(name: 'rows', value: string): void;
15
+ /** Allows multiple selection */
16
+ setAttribute(name: 'multiple', value: ''): void;
17
+ };
18
+ export declare type TSinchSelectMenuReact = TSinchElementReact<TSinchSelectMenuElement> & {
19
+ /** Selected value, CSV when multiple */
20
+ value: string;
21
+ /** How many rows to show and scroll the rest */
22
+ rows?: number;
23
+ /** Allows multiple selection */
24
+ multiple?: boolean;
25
+ /** Label that is used for a11y */
26
+ 'aria-label': string;
27
+ /** Change value handler */
28
+ 'on-change'?: (e: CustomEvent<string>) => void;
29
+ };
@@ -1,7 +1,8 @@
1
1
  import '../icons/check';
2
+ import '../text';
2
3
  import { NectaryElement } from '../utils';
3
- import type { TSinchDropdownTextOptionElement, TSinchDropdownTextOptionReact } from './types';
4
- export declare class DropdownTextOption extends NectaryElement {
4
+ import type { TSinchSelectMenuOptionElement, TSinchSelectMenuOptionReact } from './types';
5
+ export declare class SelectMenuOption extends NectaryElement {
5
6
  #private;
6
7
  constructor();
7
8
  connectedCallback(): void;
@@ -13,17 +14,14 @@ export declare class DropdownTextOption extends NectaryElement {
13
14
  get text(): string;
14
15
  set disabled(isDisabled: boolean);
15
16
  get disabled(): boolean;
16
- set checked(isChecked: boolean);
17
- get checked(): boolean;
18
- get icon(): Element | null;
19
17
  }
20
18
  declare global {
21
19
  namespace JSX {
22
20
  interface IntrinsicElements {
23
- 'sinch-dropdown-text-option': TSinchDropdownTextOptionReact;
21
+ 'sinch-select-menu-option': TSinchSelectMenuOptionReact;
24
22
  }
25
23
  }
26
24
  interface HTMLElementTagNameMap {
27
- 'sinch-dropdown-text-option': TSinchDropdownTextOptionElement;
25
+ 'sinch-select-menu-option': TSinchSelectMenuOptionElement;
28
26
  }
29
27
  }
@@ -0,0 +1,76 @@
1
+ import '../icons/check';
2
+ import '../text';
3
+ import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
4
+ 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;color:var(--sinch-color-text-default);--sinch-color-icon:var(--sinch-color-stormy-500);--sinch-size-icon:24px}#content{flex:1}:host(:hover:not([disabled]))>#wrapper,:host([data-selected])>#wrapper{background-color:var(--sinch-color-snow-400)}#check{display:none;margin-right:-6px}:host([data-checked]) #check{display:block}:host([disabled])>#wrapper{cursor:initial;color:var(--sinch-color-text-disabled);--sinch-color-icon:var(--sinch-color-stormy-100)}::slotted(*){margin-left:-6px}</style><div id="wrapper"><slot name="icon"></slot><sinch-text id="content" type="m" ellipsis></sinch-text><sinch-icon-check id="check"></sinch-icon-check></div>';
5
+ const template = document.createElement('template');
6
+ template.innerHTML = templateHTML;
7
+ export class SelectMenuOption extends NectaryElement {
8
+ #$content;
9
+
10
+ constructor() {
11
+ super();
12
+ const shadowRoot = this.attachShadow();
13
+ shadowRoot.appendChild(template.content.cloneNode(true));
14
+ this.#$content = shadowRoot.querySelector('#content');
15
+ }
16
+
17
+ connectedCallback() {
18
+ this.setAttribute('role', 'option');
19
+ }
20
+
21
+ static get observedAttributes() {
22
+ return ['text', 'data-checked', 'disabled'];
23
+ }
24
+
25
+ attributeChangedCallback(name, oldVal, newVal) {
26
+ if (oldVal === newVal) {
27
+ return;
28
+ }
29
+
30
+ switch (name) {
31
+ case 'text':
32
+ {
33
+ this.#$content.textContent = newVal;
34
+ break;
35
+ }
36
+
37
+ case 'data-checked':
38
+ {
39
+ updateExplicitBooleanAttribute(this, 'aria-selected', isAttrTrue(newVal));
40
+ break;
41
+ }
42
+
43
+ case 'disabled':
44
+ {
45
+ updateBooleanAttribute(this, 'disabled', isAttrTrue(newVal));
46
+ break;
47
+ }
48
+ }
49
+ }
50
+
51
+ set value(value) {
52
+ updateAttribute(this, 'value', value);
53
+ }
54
+
55
+ get value() {
56
+ return getAttribute(this, 'value', '');
57
+ }
58
+
59
+ set text(value) {
60
+ updateAttribute(this, 'text', value);
61
+ }
62
+
63
+ get text() {
64
+ return getAttribute(this, 'text', '');
65
+ }
66
+
67
+ set disabled(isDisabled) {
68
+ updateBooleanAttribute(this, 'disabled', isDisabled);
69
+ }
70
+
71
+ get disabled() {
72
+ return getBooleanAttribute(this, 'disabled');
73
+ }
74
+
75
+ }
76
+ defineCustomElement('sinch-select-menu-option', SelectMenuOption);
@@ -1,25 +1,24 @@
1
1
  import type { TSinchElementReact } from '../types';
2
- export declare type TSinchSelectOptionElement = HTMLElement & {
2
+ export declare type TSinchSelectMenuOptionElement = HTMLElement & {
3
3
  /** Value */
4
4
  value: string;
5
- /** Text */
5
+ /** Display text */
6
6
  text: string;
7
- /** Disabled */
7
+ /** Disabled state */
8
8
  disabled: boolean;
9
- readonly icon: Element | null;
10
9
  /** Value */
11
10
  setAttribute(name: 'value', value: string): void;
12
- /** Text */
11
+ /** Display text */
13
12
  setAttribute(name: 'text', value: string): void;
14
- /** Disabled */
13
+ /** Disabled state */
15
14
  setAttribute(name: 'disabled', value: ''): void;
16
15
  };
17
- export declare type TSinchSelectOptionReact = TSinchElementReact<TSinchSelectOptionElement> & {
16
+ export declare type TSinchSelectMenuOptionReact = TSinchElementReact<TSinchSelectMenuOptionElement> & {
18
17
  /** Value */
19
18
  value: string;
20
- /** Text */
19
+ /** Display text */
21
20
  text: string;
22
- /** Disabled */
21
+ /** Disabled state */
23
22
  disabled?: boolean;
24
23
  /** Label that is used for a11y */
25
24
  'aria-label': string;
@@ -1,23 +1,7 @@
1
- import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
-
3
- var _stopEvent;
4
-
5
- function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
6
-
7
- function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
8
-
9
1
  import { defineCustomElement, getCsvSet } from '../utils';
10
- defineCustomElement('sinch-stop-events', (_stopEvent = new WeakMap(), class extends HTMLElement {
2
+ defineCustomElement('sinch-stop-events', class extends HTMLElement {
11
3
  constructor() {
12
4
  super();
13
-
14
- _classPrivateFieldInitSpec(this, _stopEvent, {
15
- writable: true,
16
- value: e => {
17
- e.stopPropagation();
18
- }
19
- });
20
-
21
5
  this.style.display = 'contents';
22
6
  }
23
7
 
@@ -25,7 +9,7 @@ defineCustomElement('sinch-stop-events', (_stopEvent = new WeakMap(), class exte
25
9
  const events = getCsvSet(this.getAttribute('events'));
26
10
 
27
11
  for (const event of events) {
28
- this.addEventListener(event, _classPrivateFieldGet(this, _stopEvent));
12
+ this.addEventListener(event, this.#stopEvent);
29
13
  }
30
14
  }
31
15
 
@@ -33,8 +17,11 @@ defineCustomElement('sinch-stop-events', (_stopEvent = new WeakMap(), class exte
33
17
  const events = getCsvSet(this.getAttribute('events'));
34
18
 
35
19
  for (const event of events) {
36
- this.removeEventListener(event, _classPrivateFieldGet(this, _stopEvent));
20
+ this.removeEventListener(event, this.#stopEvent);
37
21
  }
38
22
  }
39
23
 
40
- }));
24
+ #stopEvent = e => {
25
+ e.stopPropagation();
26
+ };
27
+ });
@@ -1,30 +1,16 @@
1
- import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
- import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
-
4
- var _$text;
5
-
6
- function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
7
-
8
- function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
9
-
10
1
  import { alignValues } from '../table-cell/utils';
11
2
  import { defineCustomElement, getAttribute, getBooleanAttribute, getLiteralAttribute, NectaryElement, updateAttribute, updateBooleanAttribute, updateLiteralAttribute } from '../utils';
12
3
  const templateHTML = '<style>:host{display:table-cell;border-bottom:1px solid var(--sinch-color-stormy-200);vertical-align:middle;--sinch-color-icon:var(--sinch-color-stormy-200)}#wrapper{position:relative;display:flex;align-items:center;gap:8px;width:100%;height:100%;padding:8px;box-sizing:border-box;font:var(--sinch-font-title-s);color:var(--sinch-color-stormy-300);--sinch-icon-button-color:var(--sinch-color-stormy-100)}#text{flex-shrink:1;min-width:0;font:var(--sinch-font-title-s);color:var(--sinch-color-stormy-200)}:host([align=center])>#wrapper{justify-content:center}:host([align=end])>#wrapper{justify-content:flex-end}:host(:is([text=""],:not([text]))) #text{display:none}:host([fit]:not([fit=false])){width:1px}</style><div id="wrapper"><slot name="checkbox"></slot><slot name="left"></slot><span id="text"></span><slot name="tooltip"></slot><slot name="right"></slot></div>';
13
4
  const template = document.createElement('template');
14
5
  template.innerHTML = templateHTML;
15
- defineCustomElement('sinch-table-head-cell', (_$text = new WeakMap(), class extends NectaryElement {
6
+ defineCustomElement('sinch-table-head-cell', class extends NectaryElement {
7
+ #$text;
8
+
16
9
  constructor() {
17
10
  super();
18
-
19
- _classPrivateFieldInitSpec(this, _$text, {
20
- writable: true,
21
- value: void 0
22
- });
23
-
24
11
  const shadowRoot = this.attachShadow();
25
12
  shadowRoot.appendChild(template.content.cloneNode(true));
26
-
27
- _classPrivateFieldSet(this, _$text, shadowRoot.querySelector('#text'));
13
+ this.#$text = shadowRoot.querySelector('#text');
28
14
  }
29
15
 
30
16
  connectedCallback() {
@@ -40,7 +26,7 @@ defineCustomElement('sinch-table-head-cell', (_$text = new WeakMap(), class exte
40
26
  switch (name) {
41
27
  case 'text':
42
28
  {
43
- _classPrivateFieldGet(this, _$text).textContent = newVal;
29
+ this.#$text.textContent = newVal;
44
30
  break;
45
31
  }
46
32
  }
@@ -51,7 +37,7 @@ defineCustomElement('sinch-table-head-cell', (_$text = new WeakMap(), class exte
51
37
  }
52
38
 
53
39
  get text() {
54
- return getAttribute(this, 'text', null);
40
+ return getAttribute(this, 'text');
55
41
  }
56
42
 
57
43
  set align(value) {
@@ -70,4 +56,4 @@ defineCustomElement('sinch-table-head-cell', (_$text = new WeakMap(), class exte
70
56
  return getBooleanAttribute(this, 'fit');
71
57
  }
72
58
 
73
- }));
59
+ });