@nectary/components 0.41.0 → 0.42.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 +0 -16
- package/accordion/types.d.ts +9 -1
- package/accordion-item/index.js +0 -24
- package/accordion-item/types.d.ts +18 -3
- package/action-menu/index.js +1 -45
- package/action-menu-option/index.js +0 -18
- package/alert/index.js +0 -10
- package/alert/types.d.ts +6 -0
- package/avatar/index.js +57 -20
- package/avatar/types.d.ts +25 -7
- package/avatar/utils.d.ts +10 -2
- package/avatar/utils.js +23 -2
- package/badge/index.d.ts +11 -0
- package/badge/index.js +140 -0
- package/badge/types.d.ts +38 -0
- package/badge/utils.d.ts +11 -0
- package/badge/utils.js +23 -0
- package/button/index.js +0 -18
- package/card/index.js +0 -16
- package/card/types.d.ts +15 -3
- package/card-container/index.js +0 -1
- package/chat/index.js +0 -1
- package/chat-block/index.js +0 -19
- package/chat-block/types.d.ts +16 -4
- package/chat-bubble/index.js +0 -9
- package/chat-bubble/types.d.ts +6 -0
- package/checkbox/index.js +0 -23
- package/chip/index.js +16 -25
- package/chip/utils.d.ts +3 -0
- package/chip/utils.js +11 -0
- package/color-menu/index.js +8 -86
- package/color-menu/utils.js +0 -4
- package/color-swatch/index.js +17 -17
- package/color-swatch/types.d.ts +2 -2
- package/color-swatch/utils.d.ts +3 -0
- package/color-swatch/utils.js +11 -0
- package/date-picker/index.js +1 -50
- package/date-picker/utils.js +0 -7
- package/dialog/index.js +1 -17
- package/field/index.js +0 -19
- package/file-drop/index.js +0 -40
- package/file-drop/utils.js +0 -6
- package/file-picker/index.js +0 -17
- package/file-picker/utils.js +0 -1
- package/file-status/index.js +0 -12
- package/grid/index.js +0 -1
- package/grid-item/index.js +0 -9
- package/help-tooltip/index.js +0 -14
- package/horizontal-stepper/index.js +0 -12
- package/horizontal-stepper-item/index.js +0 -14
- package/icon-button/index.js +0 -15
- package/icons/create-icon-class.js +0 -2
- package/icons-branded/create-icon-class.js +0 -8
- package/icons-channel/create-icon-class.js +0 -6
- package/illustrations/create-illustration-class.js +0 -11
- package/inline-alert/index.js +0 -14
- package/input/index.js +0 -37
- package/link/index.js +0 -25
- package/list/index.js +0 -2
- package/list-item/index.js +0 -2
- package/logo/create-logo-class.js +0 -9
- package/package.json +1 -1
- package/pagination/index.js +0 -31
- package/pop/index.js +64 -68
- package/pop/utils.js +0 -1
- package/popover/index.js +0 -33
- package/popover/utils.js +0 -2
- package/progress/index.js +0 -10
- package/radio/index.js +0 -30
- package/radio-option/index.js +0 -20
- package/segment/index.js +0 -15
- package/segment-collapse/index.js +0 -13
- package/segmented-control/index.js +0 -12
- package/segmented-control-option/index.js +0 -18
- package/segmented-icon-control/index.js +0 -16
- package/segmented-icon-control-option/index.js +0 -14
- package/select-button/index.js +0 -23
- package/select-menu/index.js +1 -63
- package/select-menu-option/index.js +0 -14
- package/spinner/index.js +0 -4
- package/stop-events/index.js +0 -5
- package/table/index.js +0 -2
- package/table-body/index.js +0 -2
- package/table-cell/index.js +0 -4
- package/table-head/index.js +0 -2
- package/table-head-cell/index.js +0 -11
- package/table-row/index.js +0 -6
- package/tabs/index.js +0 -30
- package/tabs-option/index.js +0 -19
- package/tag/index.js +18 -21
- package/tag/utils.d.ts +3 -0
- package/tag/utils.js +11 -0
- package/text/index.js +1 -12
- package/textarea/index.js +0 -40
- package/{utils → theme}/colors.d.ts +0 -1
- package/{utils → theme}/colors.js +0 -1
- package/theme.css +13 -209
- package/tile-control/index.js +0 -24
- package/tile-control-option/index.js +0 -18
- package/time-picker/index.js +2 -51
- package/time-picker/utils.js +0 -18
- package/title/index.js +1 -12
- package/title/utils.js +0 -5
- package/toast/index.js +0 -19
- package/toast-manager/index.js +0 -27
- package/toggle/index.js +0 -23
- package/tooltip/index.js +0 -27
- package/tooltip/utils.js +0 -4
- package/utils/animation.js +0 -20
- package/utils/context.js +0 -6
- package/utils/index.d.ts +1 -0
- package/utils/index.js +11 -52
- package/vertical-stepper/index.js +0 -12
- package/vertical-stepper-item/index.js +0 -14
- package/avatar-badge/index.d.ts +0 -11
- package/avatar-badge/index.js +0 -38
- package/avatar-badge/types.d.ts +0 -8
- package/avatar-status/index.d.ts +0 -11
- package/avatar-status/index.js +0 -37
- package/avatar-status/types.d.ts +0 -9
- package/avatar-status/types.js +0 -1
- package/avatar-status/utils.d.ts +0 -5
- package/avatar-status/utils.js +0 -6
- package/chat-avatar/index.d.ts +0 -12
- package/chat-avatar/index.js +0 -52
- package/chat-avatar/types.d.ts +0 -12
- package/chat-avatar/types.js +0 -1
- /package/{avatar-badge → badge}/types.js +0 -0
|
@@ -4,56 +4,45 @@ const template = document.createElement('template');
|
|
|
4
4
|
template.innerHTML = templateHTML;
|
|
5
5
|
defineCustomElement('sinch-segmented-icon-control', class extends NectaryElement {
|
|
6
6
|
#$slot;
|
|
7
|
-
|
|
8
7
|
constructor() {
|
|
9
8
|
super();
|
|
10
9
|
const shadowRoot = this.attachShadow();
|
|
11
10
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
12
11
|
this.#$slot = shadowRoot.querySelector('slot');
|
|
13
12
|
}
|
|
14
|
-
|
|
15
13
|
connectedCallback() {
|
|
16
14
|
this.setAttribute('role', 'tablist');
|
|
17
15
|
this.#$slot.addEventListener('slotchange', this.#onSlotChange);
|
|
18
16
|
this.#$slot.addEventListener('option-change', this.#onOptionChange);
|
|
19
17
|
this.addEventListener('-change', this.#onChangeReactHandler);
|
|
20
18
|
}
|
|
21
|
-
|
|
22
19
|
disconnectedCallback() {
|
|
23
20
|
this.#$slot.removeEventListener('slotchange', this.#onSlotChange);
|
|
24
21
|
this.#$slot.removeEventListener('option-change', this.#onOptionChange);
|
|
25
22
|
this.removeEventListener('-change', this.#onChangeReactHandler);
|
|
26
23
|
}
|
|
27
|
-
|
|
28
24
|
static get observedAttributes() {
|
|
29
25
|
return ['value'];
|
|
30
26
|
}
|
|
31
|
-
|
|
32
27
|
get nodeName() {
|
|
33
28
|
return 'select';
|
|
34
29
|
}
|
|
35
|
-
|
|
36
30
|
set value(value) {
|
|
37
31
|
updateAttribute(this, 'value', value);
|
|
38
32
|
}
|
|
39
|
-
|
|
40
33
|
get value() {
|
|
41
34
|
return getAttribute(this, 'value', '');
|
|
42
35
|
}
|
|
43
|
-
|
|
44
36
|
set multiple(isMultiple) {
|
|
45
37
|
updateBooleanAttribute(this, 'multiple', isMultiple);
|
|
46
38
|
}
|
|
47
|
-
|
|
48
39
|
get multiple() {
|
|
49
40
|
return getBooleanAttribute(this, 'multiple');
|
|
50
41
|
}
|
|
51
|
-
|
|
52
42
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
53
43
|
if (oldVal === newVal) {
|
|
54
44
|
return;
|
|
55
45
|
}
|
|
56
|
-
|
|
57
46
|
switch (name) {
|
|
58
47
|
case 'value':
|
|
59
48
|
{
|
|
@@ -62,7 +51,6 @@ defineCustomElement('sinch-segmented-icon-control', class extends NectaryElement
|
|
|
62
51
|
}
|
|
63
52
|
}
|
|
64
53
|
}
|
|
65
|
-
|
|
66
54
|
#onSlotChange = () => {
|
|
67
55
|
this.#onValueChange(this.value);
|
|
68
56
|
};
|
|
@@ -79,25 +67,21 @@ defineCustomElement('sinch-segmented-icon-control', class extends NectaryElement
|
|
|
79
67
|
detail
|
|
80
68
|
}));
|
|
81
69
|
};
|
|
82
|
-
|
|
83
70
|
#onValueChange(csv) {
|
|
84
71
|
if (this.multiple) {
|
|
85
72
|
const values = getCsvSet(csv);
|
|
86
|
-
|
|
87
73
|
for (const $option of this.#$slot.assignedElements()) {
|
|
88
74
|
const isChecked = !getBooleanAttribute($option, 'disabled') && values.has(getAttribute($option, 'value', ''));
|
|
89
75
|
updateBooleanAttribute($option, 'data-checked', isChecked);
|
|
90
76
|
}
|
|
91
77
|
} else {
|
|
92
78
|
const value = getFirstCsvValue(csv);
|
|
93
|
-
|
|
94
79
|
for (const $option of this.#$slot.assignedElements()) {
|
|
95
80
|
const isChecked = !getBooleanAttribute($option, 'disabled') && value === getAttribute($option, 'value', '');
|
|
96
81
|
updateBooleanAttribute($option, 'data-checked', isChecked);
|
|
97
82
|
}
|
|
98
83
|
}
|
|
99
84
|
}
|
|
100
|
-
|
|
101
85
|
#onChangeReactHandler = e => {
|
|
102
86
|
getReactEventHandler(this, 'on-change')?.(e);
|
|
103
87
|
};
|
|
@@ -4,14 +4,12 @@ const template = document.createElement('template');
|
|
|
4
4
|
template.innerHTML = templateHTML;
|
|
5
5
|
defineCustomElement('sinch-segmented-icon-control-option', class extends NectaryElement {
|
|
6
6
|
#$button;
|
|
7
|
-
|
|
8
7
|
constructor() {
|
|
9
8
|
super();
|
|
10
9
|
const shadowRoot = this.attachShadow();
|
|
11
10
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
12
11
|
this.#$button = shadowRoot.querySelector('#button');
|
|
13
12
|
}
|
|
14
|
-
|
|
15
13
|
connectedCallback() {
|
|
16
14
|
this.setAttribute('role', 'tab');
|
|
17
15
|
this.#$button.addEventListener('click', this.#onButtonClick);
|
|
@@ -20,7 +18,6 @@ defineCustomElement('sinch-segmented-icon-control-option', class extends Nectary
|
|
|
20
18
|
this.addEventListener('-focus', this.#onFocusReactHandler);
|
|
21
19
|
this.addEventListener('-blur', this.#onBlurReactHandler);
|
|
22
20
|
}
|
|
23
|
-
|
|
24
21
|
disconnectedCallback() {
|
|
25
22
|
this.#$button.removeEventListener('click', this.#onButtonClick);
|
|
26
23
|
this.#$button.removeEventListener('focus', this.#onButtonFocus);
|
|
@@ -28,27 +25,21 @@ defineCustomElement('sinch-segmented-icon-control-option', class extends Nectary
|
|
|
28
25
|
this.removeEventListener('-focus', this.#onFocusReactHandler);
|
|
29
26
|
this.removeEventListener('-blur', this.#onBlurReactHandler);
|
|
30
27
|
}
|
|
31
|
-
|
|
32
28
|
static get observedAttributes() {
|
|
33
29
|
return ['data-checked', 'disabled'];
|
|
34
30
|
}
|
|
35
|
-
|
|
36
31
|
set value(value) {
|
|
37
32
|
updateAttribute(this, 'value', value);
|
|
38
33
|
}
|
|
39
|
-
|
|
40
34
|
get value() {
|
|
41
35
|
return getAttribute(this, 'value', '');
|
|
42
36
|
}
|
|
43
|
-
|
|
44
37
|
set disabled(isDisabled) {
|
|
45
38
|
updateBooleanAttribute(this, 'disabled', isDisabled);
|
|
46
39
|
}
|
|
47
|
-
|
|
48
40
|
get disabled() {
|
|
49
41
|
return getBooleanAttribute(this, 'disabled');
|
|
50
42
|
}
|
|
51
|
-
|
|
52
43
|
attributeChangedCallback(name, _, newVal) {
|
|
53
44
|
switch (name) {
|
|
54
45
|
case 'data-checked':
|
|
@@ -56,7 +47,6 @@ defineCustomElement('sinch-segmented-icon-control-option', class extends Nectary
|
|
|
56
47
|
updateExplicitBooleanAttribute(this, 'aria-selected', isAttrTrue(newVal));
|
|
57
48
|
break;
|
|
58
49
|
}
|
|
59
|
-
|
|
60
50
|
case 'disabled':
|
|
61
51
|
{
|
|
62
52
|
this.#$button.disabled = isAttrTrue(newVal);
|
|
@@ -64,19 +54,15 @@ defineCustomElement('sinch-segmented-icon-control-option', class extends Nectary
|
|
|
64
54
|
}
|
|
65
55
|
}
|
|
66
56
|
}
|
|
67
|
-
|
|
68
57
|
get focusable() {
|
|
69
58
|
return true;
|
|
70
59
|
}
|
|
71
|
-
|
|
72
60
|
focus() {
|
|
73
61
|
this.#$button.focus();
|
|
74
62
|
}
|
|
75
|
-
|
|
76
63
|
blur() {
|
|
77
64
|
this.#$button.blur();
|
|
78
65
|
}
|
|
79
|
-
|
|
80
66
|
#onButtonClick = e => {
|
|
81
67
|
e.stopPropagation();
|
|
82
68
|
this.dispatchEvent(new CustomEvent('option-change', {
|
package/select-button/index.js
CHANGED
|
@@ -8,7 +8,6 @@ defineCustomElement('sinch-select-button', class extends NectaryElement {
|
|
|
8
8
|
#$button;
|
|
9
9
|
#$text;
|
|
10
10
|
#controller = null;
|
|
11
|
-
|
|
12
11
|
constructor() {
|
|
13
12
|
super();
|
|
14
13
|
const shadowRoot = this.attachShadow();
|
|
@@ -16,7 +15,6 @@ defineCustomElement('sinch-select-button', class extends NectaryElement {
|
|
|
16
15
|
this.#$button = shadowRoot.querySelector('#button');
|
|
17
16
|
this.#$text = shadowRoot.querySelector('#text');
|
|
18
17
|
}
|
|
19
|
-
|
|
20
18
|
connectedCallback() {
|
|
21
19
|
this.#controller = new AbortController();
|
|
22
20
|
const {
|
|
@@ -42,52 +40,40 @@ defineCustomElement('sinch-select-button', class extends NectaryElement {
|
|
|
42
40
|
signal
|
|
43
41
|
});
|
|
44
42
|
}
|
|
45
|
-
|
|
46
43
|
disconnectedCallback() {
|
|
47
44
|
this.#controller.abort();
|
|
48
45
|
}
|
|
49
|
-
|
|
50
46
|
static get observedAttributes() {
|
|
51
47
|
return ['text', 'placeholder', 'invalid', 'disabled'];
|
|
52
48
|
}
|
|
53
|
-
|
|
54
49
|
set text(value) {
|
|
55
50
|
updateAttribute(this, 'text', value);
|
|
56
51
|
}
|
|
57
|
-
|
|
58
52
|
get text() {
|
|
59
53
|
return getAttribute(this, 'text', '');
|
|
60
54
|
}
|
|
61
|
-
|
|
62
55
|
set placeholder(value) {
|
|
63
56
|
updateAttribute(this, 'placeholder', value);
|
|
64
57
|
}
|
|
65
|
-
|
|
66
58
|
get placeholder() {
|
|
67
59
|
return getAttribute(this, 'placeholder');
|
|
68
60
|
}
|
|
69
|
-
|
|
70
61
|
set invalid(isInvalid) {
|
|
71
62
|
updateBooleanAttribute(this, 'invalid', isInvalid);
|
|
72
63
|
}
|
|
73
|
-
|
|
74
64
|
get invalid() {
|
|
75
65
|
return getBooleanAttribute(this, 'invalid');
|
|
76
66
|
}
|
|
77
|
-
|
|
78
67
|
set disabled(isDisabled) {
|
|
79
68
|
updateBooleanAttribute(this, 'disabled', isDisabled);
|
|
80
69
|
}
|
|
81
|
-
|
|
82
70
|
get disabled() {
|
|
83
71
|
return getBooleanAttribute(this, 'disabled');
|
|
84
72
|
}
|
|
85
|
-
|
|
86
73
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
87
74
|
if (oldVal === newVal) {
|
|
88
75
|
return;
|
|
89
76
|
}
|
|
90
|
-
|
|
91
77
|
switch (name) {
|
|
92
78
|
case 'text':
|
|
93
79
|
{
|
|
@@ -95,18 +81,14 @@ defineCustomElement('sinch-select-button', class extends NectaryElement {
|
|
|
95
81
|
this.#$text.textContent = value.length > 0 ? value : this.placeholder;
|
|
96
82
|
break;
|
|
97
83
|
}
|
|
98
|
-
|
|
99
84
|
case 'placeholder':
|
|
100
85
|
{
|
|
101
86
|
const value = this.text;
|
|
102
|
-
|
|
103
87
|
if (value.length === 0) {
|
|
104
88
|
this.#$text.textContent = newVal ?? '';
|
|
105
89
|
}
|
|
106
|
-
|
|
107
90
|
break;
|
|
108
91
|
}
|
|
109
|
-
|
|
110
92
|
case 'invalid':
|
|
111
93
|
{
|
|
112
94
|
const isInvalid = isAttrTrue(newVal);
|
|
@@ -114,7 +96,6 @@ defineCustomElement('sinch-select-button', class extends NectaryElement {
|
|
|
114
96
|
updateExplicitBooleanAttribute(this, 'aria-invalid', isInvalid);
|
|
115
97
|
break;
|
|
116
98
|
}
|
|
117
|
-
|
|
118
99
|
case 'disabled':
|
|
119
100
|
{
|
|
120
101
|
const isDisabled = isAttrTrue(newVal);
|
|
@@ -124,19 +105,15 @@ defineCustomElement('sinch-select-button', class extends NectaryElement {
|
|
|
124
105
|
}
|
|
125
106
|
}
|
|
126
107
|
}
|
|
127
|
-
|
|
128
108
|
get focusable() {
|
|
129
109
|
return true;
|
|
130
110
|
}
|
|
131
|
-
|
|
132
111
|
focus() {
|
|
133
112
|
this.#$button.focus();
|
|
134
113
|
}
|
|
135
|
-
|
|
136
114
|
blur() {
|
|
137
115
|
this.#$button.blur();
|
|
138
116
|
}
|
|
139
|
-
|
|
140
117
|
#onButtonFocus = () => {
|
|
141
118
|
this.dispatchEvent(new CustomEvent('-focus'));
|
|
142
119
|
};
|
package/select-menu/index.js
CHANGED
|
@@ -8,7 +8,6 @@ defineCustomElement('sinch-select-menu', class extends NectaryElement {
|
|
|
8
8
|
#$optionSlot;
|
|
9
9
|
#$listbox;
|
|
10
10
|
#controller = null;
|
|
11
|
-
|
|
12
11
|
constructor() {
|
|
13
12
|
super();
|
|
14
13
|
const shadowRoot = this.attachShadow();
|
|
@@ -16,7 +15,6 @@ defineCustomElement('sinch-select-menu', class extends NectaryElement {
|
|
|
16
15
|
this.#$optionSlot = shadowRoot.querySelector('slot');
|
|
17
16
|
this.#$listbox = shadowRoot.querySelector('#listbox');
|
|
18
17
|
}
|
|
19
|
-
|
|
20
18
|
connectedCallback() {
|
|
21
19
|
this.#controller = new AbortController();
|
|
22
20
|
const {
|
|
@@ -51,46 +49,36 @@ defineCustomElement('sinch-select-menu', class extends NectaryElement {
|
|
|
51
49
|
dispatchContextConnectEvent(this, 'keydown');
|
|
52
50
|
dispatchContextConnectEvent(this, 'visibility');
|
|
53
51
|
}
|
|
54
|
-
|
|
55
52
|
disconnectedCallback() {
|
|
56
53
|
dispatchContextDisconnectEvent(this, 'keydown');
|
|
57
54
|
dispatchContextDisconnectEvent(this, 'visibility');
|
|
58
55
|
this.#controller.abort();
|
|
59
56
|
}
|
|
60
|
-
|
|
61
57
|
static get observedAttributes() {
|
|
62
58
|
return ['value', 'rows', 'multiple'];
|
|
63
59
|
}
|
|
64
|
-
|
|
65
60
|
set value(value) {
|
|
66
61
|
updateAttribute(this, 'value', value);
|
|
67
62
|
}
|
|
68
|
-
|
|
69
63
|
get value() {
|
|
70
64
|
return getAttribute(this, 'value', '');
|
|
71
65
|
}
|
|
72
|
-
|
|
73
66
|
set rows(value) {
|
|
74
67
|
updateIntegerAttribute(this, 'rows', value);
|
|
75
68
|
}
|
|
76
|
-
|
|
77
69
|
get rows() {
|
|
78
70
|
return getIntegerAttribute(this, 'rows', null);
|
|
79
71
|
}
|
|
80
|
-
|
|
81
72
|
set multiple(isMultiple) {
|
|
82
73
|
updateBooleanAttribute(this, 'multiple', isMultiple);
|
|
83
74
|
}
|
|
84
|
-
|
|
85
75
|
get multiple() {
|
|
86
76
|
return getBooleanAttribute(this, 'multiple');
|
|
87
77
|
}
|
|
88
|
-
|
|
89
78
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
90
79
|
if (oldVal === newVal) {
|
|
91
80
|
return;
|
|
92
81
|
}
|
|
93
|
-
|
|
94
82
|
switch (name) {
|
|
95
83
|
case 'multiple':
|
|
96
84
|
{
|
|
@@ -98,13 +86,11 @@ defineCustomElement('sinch-select-menu', class extends NectaryElement {
|
|
|
98
86
|
updateExplicitBooleanAttribute(this, 'aria-multiselectable', isAttrTrue(newVal));
|
|
99
87
|
break;
|
|
100
88
|
}
|
|
101
|
-
|
|
102
89
|
case 'value':
|
|
103
90
|
{
|
|
104
91
|
this.#onValueChange(newVal ?? '');
|
|
105
92
|
break;
|
|
106
93
|
}
|
|
107
|
-
|
|
108
94
|
case 'rows':
|
|
109
95
|
{
|
|
110
96
|
this.#$listbox.style.maxHeight = attrValueToPixels(newVal, {
|
|
@@ -115,10 +101,8 @@ defineCustomElement('sinch-select-menu', class extends NectaryElement {
|
|
|
115
101
|
}
|
|
116
102
|
}
|
|
117
103
|
}
|
|
118
|
-
|
|
119
104
|
#onListboxMousedown = e => {
|
|
120
105
|
const $elem = e.target;
|
|
121
|
-
|
|
122
106
|
if (!getBooleanAttribute($elem, 'disabled')) {
|
|
123
107
|
this.#dispatchChangeEvent($elem);
|
|
124
108
|
}
|
|
@@ -128,7 +112,6 @@ defineCustomElement('sinch-select-menu', class extends NectaryElement {
|
|
|
128
112
|
};
|
|
129
113
|
#onListboxClick = e => {
|
|
130
114
|
const $elem = e.target;
|
|
131
|
-
|
|
132
115
|
if (!getBooleanAttribute($elem, 'disabled')) {
|
|
133
116
|
this.#selectOption($elem);
|
|
134
117
|
}
|
|
@@ -146,29 +129,24 @@ defineCustomElement('sinch-select-menu', class extends NectaryElement {
|
|
|
146
129
|
#onListboxKeyDown = e => {
|
|
147
130
|
this.#handleKeydown(e);
|
|
148
131
|
};
|
|
149
|
-
|
|
150
132
|
#handleKeydown(e) {
|
|
151
133
|
switch (e.code) {
|
|
152
134
|
case 'Space':
|
|
153
135
|
case 'Enter':
|
|
154
136
|
{
|
|
155
137
|
const $option = this.#findSelectedOption();
|
|
156
|
-
|
|
157
138
|
if ($option !== null) {
|
|
158
139
|
e.preventDefault();
|
|
159
140
|
this.#dispatchChangeEvent($option);
|
|
160
141
|
}
|
|
161
|
-
|
|
162
142
|
break;
|
|
163
143
|
}
|
|
164
|
-
|
|
165
144
|
case 'ArrowUp':
|
|
166
145
|
{
|
|
167
146
|
e.preventDefault();
|
|
168
147
|
this.#selectOption(this.#getPrevOption());
|
|
169
148
|
break;
|
|
170
149
|
}
|
|
171
|
-
|
|
172
150
|
case 'ArrowDown':
|
|
173
151
|
{
|
|
174
152
|
e.preventDefault();
|
|
@@ -177,100 +155,76 @@ defineCustomElement('sinch-select-menu', class extends NectaryElement {
|
|
|
177
155
|
}
|
|
178
156
|
}
|
|
179
157
|
}
|
|
180
|
-
|
|
181
158
|
#onOptionSlotChange = () => {
|
|
182
159
|
this.#onValueChange(this.value);
|
|
183
160
|
};
|
|
184
|
-
|
|
185
161
|
#onValueChange(csv) {
|
|
186
162
|
if (this.multiple) {
|
|
187
163
|
const values = getCsvSet(csv);
|
|
188
|
-
|
|
189
164
|
for (const $option of this.#getOptionElements()) {
|
|
190
165
|
const isChecked = !getBooleanAttribute($option, 'disabled') && values.has(getAttribute($option, 'value', ''));
|
|
191
166
|
updateBooleanAttribute($option, 'data-checked', isChecked);
|
|
192
167
|
}
|
|
193
168
|
} else {
|
|
194
169
|
const value = getFirstCsvValue(csv);
|
|
195
|
-
|
|
196
170
|
for (const $option of this.#getOptionElements()) {
|
|
197
171
|
const isChecked = !getBooleanAttribute($option, 'disabled') && value === getAttribute($option, 'value', '');
|
|
198
172
|
updateBooleanAttribute($option, 'data-checked', isChecked);
|
|
199
173
|
}
|
|
200
174
|
}
|
|
201
175
|
}
|
|
202
|
-
|
|
203
176
|
#getFirstOption() {
|
|
204
177
|
const $options = this.#getOptionElements();
|
|
205
|
-
|
|
206
178
|
for (let i = 0; i < $options.length; i++) {
|
|
207
179
|
const el = $options[i];
|
|
208
|
-
|
|
209
180
|
if (!getBooleanAttribute(el, 'disabled')) {
|
|
210
181
|
return el;
|
|
211
182
|
}
|
|
212
183
|
}
|
|
213
|
-
|
|
214
184
|
return null;
|
|
215
185
|
}
|
|
216
|
-
|
|
217
186
|
#getLastOption() {
|
|
218
187
|
const $options = this.#getOptionElements();
|
|
219
|
-
|
|
220
188
|
for (let i = $options.length - 1; i >= 0; i--) {
|
|
221
189
|
const el = $options[i];
|
|
222
|
-
|
|
223
190
|
if (!getBooleanAttribute(el, 'disabled')) {
|
|
224
191
|
return el;
|
|
225
192
|
}
|
|
226
193
|
}
|
|
227
|
-
|
|
228
194
|
return null;
|
|
229
195
|
}
|
|
230
|
-
|
|
231
196
|
#getNextOption() {
|
|
232
197
|
const index = this.#getSelectedOptionIndex();
|
|
233
|
-
|
|
234
198
|
if (index !== null) {
|
|
235
199
|
const $options = this.#getOptionElements();
|
|
236
|
-
|
|
237
200
|
for (let i = 1; i <= $options.length; i++) {
|
|
238
201
|
const el = $options[(i + index) % $options.length];
|
|
239
|
-
|
|
240
202
|
if (!getBooleanAttribute(el, 'disabled')) {
|
|
241
203
|
return el;
|
|
242
204
|
}
|
|
243
205
|
}
|
|
244
206
|
}
|
|
245
|
-
|
|
246
207
|
return this.#getFirstOption();
|
|
247
208
|
}
|
|
248
|
-
|
|
249
209
|
#getPrevOption() {
|
|
250
210
|
const index = this.#getSelectedOptionIndex();
|
|
251
|
-
|
|
252
211
|
if (index !== null) {
|
|
253
212
|
const $options = this.#getOptionElements();
|
|
254
|
-
|
|
255
213
|
for (let i = 1; i <= $options.length; i++) {
|
|
256
214
|
const el = $options[(index - i + $options.length) % $options.length];
|
|
257
|
-
|
|
258
215
|
if (!getBooleanAttribute(el, 'disabled')) {
|
|
259
216
|
return el;
|
|
260
217
|
}
|
|
261
218
|
}
|
|
262
219
|
}
|
|
263
|
-
|
|
264
220
|
return this.#getLastOption();
|
|
265
221
|
}
|
|
266
|
-
|
|
267
222
|
#selectOption($option) {
|
|
268
223
|
const hasRows = this.hasAttribute('rows');
|
|
269
|
-
|
|
270
224
|
for (const $op of this.#getOptionElements()) {
|
|
271
225
|
const isSelected = $op === $option;
|
|
272
|
-
updateBooleanAttribute($op, 'data-selected', isSelected);
|
|
273
226
|
|
|
227
|
+
updateBooleanAttribute($op, 'data-selected', isSelected);
|
|
274
228
|
if (isSelected && hasRows) {
|
|
275
229
|
$op.scrollIntoView?.({
|
|
276
230
|
block: 'nearest'
|
|
@@ -278,68 +232,52 @@ defineCustomElement('sinch-select-menu', class extends NectaryElement {
|
|
|
278
232
|
}
|
|
279
233
|
}
|
|
280
234
|
}
|
|
281
|
-
|
|
282
235
|
#getOptionElements() {
|
|
283
236
|
return this.#$optionSlot.assignedElements();
|
|
284
237
|
}
|
|
285
|
-
|
|
286
238
|
#getSelectedOptionIndex() {
|
|
287
239
|
const elements = this.#getOptionElements();
|
|
288
|
-
|
|
289
240
|
for (let i = 0; i < elements.length; i++) {
|
|
290
241
|
const el = elements[i];
|
|
291
|
-
|
|
292
242
|
if (!getBooleanAttribute(el, 'disabled') && getBooleanAttribute(el, 'data-selected')) {
|
|
293
243
|
return i;
|
|
294
244
|
}
|
|
295
245
|
}
|
|
296
|
-
|
|
297
246
|
return null;
|
|
298
247
|
}
|
|
299
|
-
|
|
300
248
|
#findSelectedOption() {
|
|
301
249
|
const elements = this.#getOptionElements();
|
|
302
|
-
|
|
303
250
|
for (const el of elements) {
|
|
304
251
|
if (!getBooleanAttribute(el, 'disabled') && getBooleanAttribute(el, 'data-selected')) {
|
|
305
252
|
return el;
|
|
306
253
|
}
|
|
307
254
|
}
|
|
308
|
-
|
|
309
255
|
return null;
|
|
310
256
|
}
|
|
311
|
-
|
|
312
257
|
#findCheckedOption() {
|
|
313
258
|
const elements = this.#getOptionElements();
|
|
314
259
|
const value = this.multiple ? getFirstCsvValue(this.value) : this.value;
|
|
315
|
-
|
|
316
260
|
for (const $el of elements) {
|
|
317
261
|
if (!getBooleanAttribute($el, 'disabled') && getAttribute($el, 'value') === value) {
|
|
318
262
|
return $el;
|
|
319
263
|
}
|
|
320
264
|
}
|
|
321
|
-
|
|
322
265
|
return null;
|
|
323
266
|
}
|
|
324
|
-
|
|
325
267
|
#dispatchChangeEvent($opt) {
|
|
326
268
|
if ($opt === null) {
|
|
327
269
|
return;
|
|
328
270
|
}
|
|
329
|
-
|
|
330
271
|
const value = $opt.value;
|
|
331
272
|
const result = this.multiple ? updateCsv(this.value, value, !getBooleanAttribute($opt, 'data-checked')) : value;
|
|
332
273
|
this.dispatchEvent(new CustomEvent('-change', {
|
|
333
274
|
detail: result
|
|
334
275
|
}));
|
|
335
276
|
}
|
|
336
|
-
|
|
337
277
|
#onChangeReactHandler = e => {
|
|
338
278
|
getReactEventHandler(this, 'on-change')?.(e);
|
|
339
279
|
};
|
|
340
|
-
|
|
341
280
|
get focusable() {
|
|
342
281
|
return true;
|
|
343
282
|
}
|
|
344
|
-
|
|
345
283
|
});
|
|
@@ -6,40 +6,33 @@ const template = document.createElement('template');
|
|
|
6
6
|
template.innerHTML = templateHTML;
|
|
7
7
|
export class SelectMenuOption extends NectaryElement {
|
|
8
8
|
#$content;
|
|
9
|
-
|
|
10
9
|
constructor() {
|
|
11
10
|
super();
|
|
12
11
|
const shadowRoot = this.attachShadow();
|
|
13
12
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
14
13
|
this.#$content = shadowRoot.querySelector('#content');
|
|
15
14
|
}
|
|
16
|
-
|
|
17
15
|
connectedCallback() {
|
|
18
16
|
this.setAttribute('role', 'option');
|
|
19
17
|
}
|
|
20
|
-
|
|
21
18
|
static get observedAttributes() {
|
|
22
19
|
return ['text', 'data-checked', 'disabled'];
|
|
23
20
|
}
|
|
24
|
-
|
|
25
21
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
26
22
|
if (oldVal === newVal) {
|
|
27
23
|
return;
|
|
28
24
|
}
|
|
29
|
-
|
|
30
25
|
switch (name) {
|
|
31
26
|
case 'text':
|
|
32
27
|
{
|
|
33
28
|
this.#$content.textContent = newVal;
|
|
34
29
|
break;
|
|
35
30
|
}
|
|
36
|
-
|
|
37
31
|
case 'data-checked':
|
|
38
32
|
{
|
|
39
33
|
updateExplicitBooleanAttribute(this, 'aria-selected', isAttrTrue(newVal));
|
|
40
34
|
break;
|
|
41
35
|
}
|
|
42
|
-
|
|
43
36
|
case 'disabled':
|
|
44
37
|
{
|
|
45
38
|
updateBooleanAttribute(this, 'disabled', isAttrTrue(newVal));
|
|
@@ -47,30 +40,23 @@ export class SelectMenuOption extends NectaryElement {
|
|
|
47
40
|
}
|
|
48
41
|
}
|
|
49
42
|
}
|
|
50
|
-
|
|
51
43
|
set value(value) {
|
|
52
44
|
updateAttribute(this, 'value', value);
|
|
53
45
|
}
|
|
54
|
-
|
|
55
46
|
get value() {
|
|
56
47
|
return getAttribute(this, 'value', '');
|
|
57
48
|
}
|
|
58
|
-
|
|
59
49
|
set text(value) {
|
|
60
50
|
updateAttribute(this, 'text', value);
|
|
61
51
|
}
|
|
62
|
-
|
|
63
52
|
get text() {
|
|
64
53
|
return getAttribute(this, 'text', '');
|
|
65
54
|
}
|
|
66
|
-
|
|
67
55
|
set disabled(isDisabled) {
|
|
68
56
|
updateBooleanAttribute(this, 'disabled', isDisabled);
|
|
69
57
|
}
|
|
70
|
-
|
|
71
58
|
get disabled() {
|
|
72
59
|
return getBooleanAttribute(this, 'disabled');
|
|
73
60
|
}
|
|
74
|
-
|
|
75
61
|
}
|
|
76
62
|
defineCustomElement('sinch-select-menu-option', SelectMenuOption);
|
package/spinner/index.js
CHANGED
|
@@ -9,18 +9,14 @@ defineCustomElement('sinch-spinner', class extends NectaryElement {
|
|
|
9
9
|
const shadowRoot = this.attachShadow();
|
|
10
10
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
11
11
|
}
|
|
12
|
-
|
|
13
12
|
connectedCallback() {
|
|
14
13
|
this.setAttribute('aria-live', 'polite');
|
|
15
14
|
this.setAttribute('aria-busy', 'true');
|
|
16
15
|
}
|
|
17
|
-
|
|
18
16
|
set type(value) {
|
|
19
17
|
updateLiteralAttribute(this, spinnerTypes, 'type', value);
|
|
20
18
|
}
|
|
21
|
-
|
|
22
19
|
get type() {
|
|
23
20
|
return getLiteralAttribute(this, spinnerTypes, 'type', 'medium');
|
|
24
21
|
}
|
|
25
|
-
|
|
26
22
|
});
|
package/stop-events/index.js
CHANGED
|
@@ -4,23 +4,18 @@ defineCustomElement('sinch-stop-events', class extends HTMLElement {
|
|
|
4
4
|
super();
|
|
5
5
|
this.style.display = 'contents';
|
|
6
6
|
}
|
|
7
|
-
|
|
8
7
|
connectedCallback() {
|
|
9
8
|
const events = getCsvSet(this.getAttribute('events'));
|
|
10
|
-
|
|
11
9
|
for (const event of events) {
|
|
12
10
|
this.addEventListener(event, this.#stopEvent);
|
|
13
11
|
}
|
|
14
12
|
}
|
|
15
|
-
|
|
16
13
|
disconnectedCallback() {
|
|
17
14
|
const events = getCsvSet(this.getAttribute('events'));
|
|
18
|
-
|
|
19
15
|
for (const event of events) {
|
|
20
16
|
this.removeEventListener(event, this.#stopEvent);
|
|
21
17
|
}
|
|
22
18
|
}
|
|
23
|
-
|
|
24
19
|
#stopEvent = e => {
|
|
25
20
|
e.stopPropagation();
|
|
26
21
|
};
|
package/table/index.js
CHANGED