@nectary/components 0.39.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.
- package/accordion/index.js +47 -84
- package/accordion-item/index.js +26 -53
- package/action-menu/index.d.ts +0 -1
- package/action-menu/index.js +179 -223
- package/action-menu/types.d.ts +8 -18
- package/action-menu-option/index.d.ts +1 -0
- package/action-menu-option/index.js +51 -62
- package/action-menu-option/types.d.ts +9 -0
- package/action-menu-option/utils.d.ts +2 -0
- package/action-menu-option/utils.js +3 -0
- package/alert/index.js +6 -20
- package/avatar/index.js +12 -31
- package/avatar-badge/index.js +8 -22
- package/avatar-status/index.js +1 -1
- package/button/index.js +42 -92
- package/card/index.js +21 -59
- package/chat-avatar/index.js +8 -22
- package/chat-block/index.js +29 -69
- package/chat-bubble/index.js +6 -20
- package/checkbox/index.js +55 -107
- package/chip/index.d.ts +13 -0
- package/chip/index.js +137 -0
- package/chip/types.d.ts +38 -0
- package/color-menu/index.d.ts +13 -0
- package/color-menu/index.js +464 -0
- package/color-menu/types.d.ts +37 -0
- package/color-swatch/index.d.ts +13 -0
- package/color-swatch/index.js +59 -0
- package/color-swatch/types.d.ts +12 -0
- package/colors.json +57 -49
- package/date-picker/index.js +161 -292
- package/dialog/index.js +70 -142
- package/dropdown-checkbox-option/index.js +6 -20
- package/dropdown-radio-option/index.js +6 -20
- package/field/index.js +25 -63
- package/file-drop/index.js +123 -200
- package/file-picker/index.d.ts +0 -1
- package/file-picker/index.js +55 -108
- package/file-status/index.js +15 -39
- package/help-tooltip/index.js +1 -1
- package/horizontal-stepper/index.js +33 -59
- package/horizontal-stepper-item/index.js +13 -37
- package/icon-button/index.js +39 -84
- package/icons-channel/notify/index.d.ts +11 -0
- package/icons-channel/notify/index.js +4 -0
- package/illustrations/create-illustration-class.js +1 -1
- package/inline-alert/index.js +29 -81
- package/input/index.js +113 -222
- package/link/index.js +46 -96
- package/list-item/index.js +1 -1
- package/package.json +12 -14
- package/pagination/index.js +109 -163
- package/popover/index.js +224 -294
- package/progress/index.js +9 -28
- package/radio/index.js +103 -169
- package/radio-option/index.js +24 -48
- package/segment/index.js +49 -130
- package/segment-collapse/index.js +24 -49
- package/segmented-control/index.js +36 -73
- package/segmented-control-option/index.js +41 -87
- package/segmented-icon-control/index.js +47 -84
- package/segmented-icon-control-option/index.js +38 -79
- package/select-button/index.d.ts +13 -0
- package/select-button/index.js +153 -0
- package/select-button/types.d.ts +43 -0
- package/select-menu/index.d.ts +11 -0
- package/select-menu/index.js +346 -0
- package/select-menu/types.d.ts +29 -0
- package/select-menu/types.js +1 -0
- package/{dropdown-text-option → select-menu-option}/index.d.ts +5 -7
- package/select-menu-option/index.js +76 -0
- package/{select-option → select-menu-option}/types.d.ts +8 -9
- package/stop-events/index.js +7 -20
- package/table-head-cell/index.js +7 -21
- package/tabs/index.js +103 -165
- package/tabs-option/index.js +20 -44
- package/tag/index.d.ts +0 -1
- package/tag/index.js +37 -38
- package/tag/types.d.ts +13 -7
- package/textarea/index.js +92 -167
- package/theme.css +80 -49
- package/tile-control/index.js +55 -96
- package/tile-control-option/index.js +40 -86
- package/time-picker/index.js +216 -368
- package/title/index.js +6 -20
- package/toast/index.js +32 -70
- package/toast-manager/index.js +141 -217
- package/toggle/index.js +54 -106
- package/types.d.ts +7 -0
- package/utils/colors.d.ts +10 -0
- package/utils/colors.js +121 -0
- package/{utils.d.ts → utils/index.d.ts} +17 -9
- package/{utils.js → utils/index.js} +96 -39
- package/vertical-stepper/index.js +29 -50
- package/vertical-stepper-item/index.js +13 -37
- package/dropdown/index.d.ts +0 -12
- package/dropdown/index.js +0 -415
- package/dropdown/types.d.ts +0 -32
- package/dropdown-text-option/index.js +0 -104
- package/dropdown-text-option/types.d.ts +0 -16
- package/select/index.d.ts +0 -13
- package/select/index.js +0 -316
- package/select/types.d.ts +0 -53
- package/select-option/index.d.ts +0 -11
- package/select-option/index.js +0 -8
- package/tag/utils.d.ts +0 -5
- package/tag/utils.js +0 -6
- package/tag-close/index.d.ts +0 -12
- package/tag-close/index.js +0 -42
- package/tag-close/types.d.ts +0 -5
- /package/{dropdown-text-option → chip}/types.js +0 -0
- /package/{dropdown → color-menu}/types.js +0 -0
- /package/{select-option → color-swatch}/types.js +0 -0
- /package/{select → select-button}/types.js +0 -0
- /package/{tag-close → select-menu-option}/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
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import '../icons/check';
|
|
2
|
+
import '../text';
|
|
2
3
|
import { NectaryElement } from '../utils';
|
|
3
|
-
import type {
|
|
4
|
-
export declare class
|
|
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-
|
|
21
|
+
'sinch-select-menu-option': TSinchSelectMenuOptionReact;
|
|
24
22
|
}
|
|
25
23
|
}
|
|
26
24
|
interface HTMLElementTagNameMap {
|
|
27
|
-
'sinch-
|
|
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
|
|
2
|
+
export declare type TSinchSelectMenuOptionElement = HTMLElement & {
|
|
3
3
|
/** Value */
|
|
4
4
|
value: string;
|
|
5
|
-
/**
|
|
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
|
-
/**
|
|
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
|
|
16
|
+
export declare type TSinchSelectMenuOptionReact = TSinchElementReact<TSinchSelectMenuOptionElement> & {
|
|
18
17
|
/** Value */
|
|
19
18
|
value: string;
|
|
20
|
-
/**
|
|
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;
|
package/stop-events/index.js
CHANGED
|
@@ -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',
|
|
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,
|
|
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,
|
|
20
|
+
this.removeEventListener(event, this.#stopEvent);
|
|
37
21
|
}
|
|
38
22
|
}
|
|
39
23
|
|
|
40
|
-
|
|
24
|
+
#stopEvent = e => {
|
|
25
|
+
e.stopPropagation();
|
|
26
|
+
};
|
|
27
|
+
});
|
package/table-head-cell/index.js
CHANGED
|
@@ -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',
|
|
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
|
-
|
|
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'
|
|
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
|
+
});
|