@nectary/components 0.41.1 → 0.42.1
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 +3 -1
- package/pagination/index.js +0 -31
- package/pop/index.js +26 -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/theme/avatar.css +25 -0
- package/theme/badge.css +15 -0
- package/theme/chip.css +53 -0
- package/theme/color-swatch.css +65 -0
- package/{utils → theme}/colors.d.ts +0 -1
- package/{utils → theme}/colors.js +0 -1
- package/theme/elevation.css +7 -0
- package/theme/fonts.css +76 -0
- package/theme/fonts.json +79 -0
- package/theme/palette.css +90 -0
- package/theme/shapes.css +7 -0
- package/theme/tag.css +53 -0
- package/theme/typography.css +16 -0
- 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
package/progress/index.js
CHANGED
|
@@ -11,7 +11,6 @@ template.innerHTML = templateHTML;
|
|
|
11
11
|
defineCustomElement('sinch-progress', class extends NectaryElement {
|
|
12
12
|
#$bar;
|
|
13
13
|
#$text;
|
|
14
|
-
|
|
15
14
|
constructor() {
|
|
16
15
|
super();
|
|
17
16
|
const shadowRoot = this.attachShadow();
|
|
@@ -19,36 +18,28 @@ defineCustomElement('sinch-progress', class extends NectaryElement {
|
|
|
19
18
|
this.#$bar = shadowRoot.querySelector('#bar');
|
|
20
19
|
this.#$text = shadowRoot.querySelector('#text');
|
|
21
20
|
}
|
|
22
|
-
|
|
23
21
|
connectedCallback() {
|
|
24
22
|
this.setAttribute('role', 'progressbar');
|
|
25
23
|
}
|
|
26
|
-
|
|
27
24
|
get value() {
|
|
28
25
|
return getIntegerAttribute(this, 'value', 0);
|
|
29
26
|
}
|
|
30
|
-
|
|
31
27
|
set value(value) {
|
|
32
28
|
updateAttribute(this, 'value', value);
|
|
33
29
|
}
|
|
34
|
-
|
|
35
30
|
get detailed() {
|
|
36
31
|
return getBooleanAttribute(this, 'detailed');
|
|
37
32
|
}
|
|
38
|
-
|
|
39
33
|
set detailed(isDetailed) {
|
|
40
34
|
updateBooleanAttribute(this, 'detailed', isDetailed);
|
|
41
35
|
}
|
|
42
|
-
|
|
43
36
|
static get observedAttributes() {
|
|
44
37
|
return ['value'];
|
|
45
38
|
}
|
|
46
|
-
|
|
47
39
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
48
40
|
if (oldVal === newVal) {
|
|
49
41
|
return;
|
|
50
42
|
}
|
|
51
|
-
|
|
52
43
|
switch (name) {
|
|
53
44
|
case 'value':
|
|
54
45
|
{
|
|
@@ -64,5 +55,4 @@ defineCustomElement('sinch-progress', class extends NectaryElement {
|
|
|
64
55
|
}
|
|
65
56
|
}
|
|
66
57
|
}
|
|
67
|
-
|
|
68
58
|
});
|
package/radio/index.js
CHANGED
|
@@ -4,14 +4,12 @@ const template = document.createElement('template');
|
|
|
4
4
|
template.innerHTML = templateHTML;
|
|
5
5
|
defineCustomElement('sinch-radio', 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', 'radiogroup');
|
|
17
15
|
this.#$slot.addEventListener('slotchange', this.#onSlotChange);
|
|
@@ -19,35 +17,28 @@ defineCustomElement('sinch-radio', class extends NectaryElement {
|
|
|
19
17
|
this.#$slot.addEventListener('option-change', this.#onOptionChange);
|
|
20
18
|
this.addEventListener('-change', this.#onChangeReactHandler);
|
|
21
19
|
}
|
|
22
|
-
|
|
23
20
|
disconnectedCallback() {
|
|
24
21
|
this.#$slot.removeEventListener('slotchange', this.#onSlotChange);
|
|
25
22
|
this.#$slot.removeEventListener('keydown', this.#onOptionKeyDown);
|
|
26
23
|
this.#$slot.removeEventListener('option-change', this.#onOptionChange);
|
|
27
24
|
this.removeEventListener('-change', this.#onChangeReactHandler);
|
|
28
25
|
}
|
|
29
|
-
|
|
30
26
|
static get observedAttributes() {
|
|
31
27
|
return ['value'];
|
|
32
28
|
}
|
|
33
|
-
|
|
34
29
|
get nodeName() {
|
|
35
30
|
return 'select';
|
|
36
31
|
}
|
|
37
|
-
|
|
38
32
|
set value(value) {
|
|
39
33
|
updateAttribute(this, 'value', value);
|
|
40
34
|
}
|
|
41
|
-
|
|
42
35
|
get value() {
|
|
43
36
|
return getAttribute(this, 'value', '');
|
|
44
37
|
}
|
|
45
|
-
|
|
46
38
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
47
39
|
if (oldVal === newVal) {
|
|
48
40
|
return;
|
|
49
41
|
}
|
|
50
|
-
|
|
51
42
|
switch (name) {
|
|
52
43
|
case 'value':
|
|
53
44
|
{
|
|
@@ -56,7 +47,6 @@ defineCustomElement('sinch-radio', class extends NectaryElement {
|
|
|
56
47
|
}
|
|
57
48
|
}
|
|
58
49
|
}
|
|
59
|
-
|
|
60
50
|
#onOptionKeyDown = e => {
|
|
61
51
|
switch (e.code) {
|
|
62
52
|
case 'ArrowUp':
|
|
@@ -64,26 +54,21 @@ defineCustomElement('sinch-radio', class extends NectaryElement {
|
|
|
64
54
|
{
|
|
65
55
|
e.preventDefault();
|
|
66
56
|
const $option = this.#getPrevOption();
|
|
67
|
-
|
|
68
57
|
if ($option !== null) {
|
|
69
58
|
$option.focus();
|
|
70
59
|
this.#dispatchChangeEvent($option.value);
|
|
71
60
|
}
|
|
72
|
-
|
|
73
61
|
break;
|
|
74
62
|
}
|
|
75
|
-
|
|
76
63
|
case 'ArrowDown':
|
|
77
64
|
case 'ArrowRight':
|
|
78
65
|
{
|
|
79
66
|
e.preventDefault();
|
|
80
67
|
const $option = this.#getNextOption();
|
|
81
|
-
|
|
82
68
|
if ($option !== null) {
|
|
83
69
|
$option.focus();
|
|
84
70
|
this.#dispatchChangeEvent($option.value);
|
|
85
71
|
}
|
|
86
|
-
|
|
87
72
|
break;
|
|
88
73
|
}
|
|
89
74
|
}
|
|
@@ -95,14 +80,12 @@ defineCustomElement('sinch-radio', class extends NectaryElement {
|
|
|
95
80
|
e.stopPropagation();
|
|
96
81
|
this.#dispatchChangeEvent(e.detail);
|
|
97
82
|
};
|
|
98
|
-
|
|
99
83
|
#onValueChange(value) {
|
|
100
84
|
for (const $option of this.#$slot.assignedElements()) {
|
|
101
85
|
const isChecked = !getBooleanAttribute($option, 'disabled') && value === getAttribute($option, 'value', '');
|
|
102
86
|
updateBooleanAttribute($option, 'checked', isChecked);
|
|
103
87
|
}
|
|
104
88
|
}
|
|
105
|
-
|
|
106
89
|
#dispatchChangeEvent(value) {
|
|
107
90
|
this.dispatchEvent(new CustomEvent('change', {
|
|
108
91
|
detail: value,
|
|
@@ -112,59 +95,46 @@ defineCustomElement('sinch-radio', class extends NectaryElement {
|
|
|
112
95
|
detail: value
|
|
113
96
|
}));
|
|
114
97
|
}
|
|
115
|
-
|
|
116
98
|
#getFirstOption() {
|
|
117
99
|
for (const $option of this.#$slot.assignedElements()) {
|
|
118
100
|
if ($option.disabled !== true) {
|
|
119
101
|
return $option;
|
|
120
102
|
}
|
|
121
103
|
}
|
|
122
|
-
|
|
123
104
|
return null;
|
|
124
105
|
}
|
|
125
|
-
|
|
126
106
|
#getLastOption() {
|
|
127
107
|
for (const $option of this.#$slot.assignedElements().reverse()) {
|
|
128
108
|
if ($option.disabled !== true) {
|
|
129
109
|
return $option;
|
|
130
110
|
}
|
|
131
111
|
}
|
|
132
|
-
|
|
133
112
|
return null;
|
|
134
113
|
}
|
|
135
|
-
|
|
136
114
|
#getNextOption() {
|
|
137
115
|
const $options = this.#getEnabledRadioElements();
|
|
138
116
|
const $selectedOption = this.#findSelectedOption($options);
|
|
139
117
|
const currentIndex = $selectedOption !== null ? $options.indexOf($selectedOption) : -1;
|
|
140
|
-
|
|
141
118
|
if (currentIndex < 0) {
|
|
142
119
|
return this.#getFirstOption();
|
|
143
120
|
}
|
|
144
|
-
|
|
145
121
|
return $options[(currentIndex + 1) % $options.length];
|
|
146
122
|
}
|
|
147
|
-
|
|
148
123
|
#getPrevOption() {
|
|
149
124
|
const $options = this.#getEnabledRadioElements();
|
|
150
125
|
const $selectedOption = this.#findSelectedOption($options);
|
|
151
126
|
const currentIndex = $selectedOption !== null ? $options.indexOf($selectedOption) : -1;
|
|
152
|
-
|
|
153
127
|
if (currentIndex < 0) {
|
|
154
128
|
return this.#getLastOption();
|
|
155
129
|
}
|
|
156
|
-
|
|
157
130
|
return $options[(currentIndex - 1 + $options.length) % $options.length];
|
|
158
131
|
}
|
|
159
|
-
|
|
160
132
|
#getEnabledRadioElements() {
|
|
161
133
|
return this.#$slot.assignedElements().filter(el => el.disabled !== true);
|
|
162
134
|
}
|
|
163
|
-
|
|
164
135
|
#findSelectedOption(elements) {
|
|
165
136
|
return elements.find(el => el.checked) ?? null;
|
|
166
137
|
}
|
|
167
|
-
|
|
168
138
|
#onChangeReactHandler = e => {
|
|
169
139
|
getReactEventHandler(this, 'on-change')?.(e);
|
|
170
140
|
};
|
package/radio-option/index.js
CHANGED
|
@@ -5,7 +5,6 @@ template.innerHTML = templateHTML;
|
|
|
5
5
|
defineCustomElement('sinch-radio-option', class extends NectaryElement {
|
|
6
6
|
#$input;
|
|
7
7
|
#$label;
|
|
8
|
-
|
|
9
8
|
constructor() {
|
|
10
9
|
super();
|
|
11
10
|
const shadowRoot = this.attachShadow();
|
|
@@ -13,52 +12,40 @@ defineCustomElement('sinch-radio-option', class extends NectaryElement {
|
|
|
13
12
|
this.#$input = shadowRoot.querySelector('input');
|
|
14
13
|
this.#$label = shadowRoot.querySelector('label');
|
|
15
14
|
}
|
|
16
|
-
|
|
17
15
|
connectedCallback() {
|
|
18
16
|
this.setAttribute('role', 'radio');
|
|
19
17
|
this.#$input.addEventListener('input', this.#onInput);
|
|
20
18
|
}
|
|
21
|
-
|
|
22
19
|
disconnectedCallback() {
|
|
23
20
|
this.#$input.removeEventListener('input', this.#onInput);
|
|
24
21
|
}
|
|
25
|
-
|
|
26
22
|
static get observedAttributes() {
|
|
27
23
|
return ['checked', 'disabled', 'text', 'value'];
|
|
28
24
|
}
|
|
29
|
-
|
|
30
25
|
set checked(isChecked) {
|
|
31
26
|
updateBooleanAttribute(this, 'checked', isChecked);
|
|
32
27
|
}
|
|
33
|
-
|
|
34
28
|
get checked() {
|
|
35
29
|
return getBooleanAttribute(this, 'checked');
|
|
36
30
|
}
|
|
37
|
-
|
|
38
31
|
set value(value) {
|
|
39
32
|
updateAttribute(this, 'value', value);
|
|
40
33
|
}
|
|
41
|
-
|
|
42
34
|
get value() {
|
|
43
35
|
return getAttribute(this, 'value', '');
|
|
44
36
|
}
|
|
45
|
-
|
|
46
37
|
set disabled(isDisabled) {
|
|
47
38
|
updateBooleanAttribute(this, 'disabled', isDisabled);
|
|
48
39
|
}
|
|
49
|
-
|
|
50
40
|
get disabled() {
|
|
51
41
|
return getBooleanAttribute(this, 'disabled');
|
|
52
42
|
}
|
|
53
|
-
|
|
54
43
|
set text(value) {
|
|
55
44
|
updateAttribute(this, 'text', value);
|
|
56
45
|
}
|
|
57
|
-
|
|
58
46
|
get text() {
|
|
59
47
|
return getAttribute(this, 'text', '');
|
|
60
48
|
}
|
|
61
|
-
|
|
62
49
|
attributeChangedCallback(name, _, newVal) {
|
|
63
50
|
switch (name) {
|
|
64
51
|
case 'text':
|
|
@@ -66,14 +53,12 @@ defineCustomElement('sinch-radio-option', class extends NectaryElement {
|
|
|
66
53
|
this.#$label.textContent = newVal;
|
|
67
54
|
break;
|
|
68
55
|
}
|
|
69
|
-
|
|
70
56
|
case 'checked':
|
|
71
57
|
{
|
|
72
58
|
this.#$input.checked = isAttrTrue(newVal);
|
|
73
59
|
updateAttribute(this, 'aria-checked', isAttrTrue(newVal));
|
|
74
60
|
break;
|
|
75
61
|
}
|
|
76
|
-
|
|
77
62
|
case 'disabled':
|
|
78
63
|
{
|
|
79
64
|
const isDisabled = isAttrTrue(newVal);
|
|
@@ -81,7 +66,6 @@ defineCustomElement('sinch-radio-option', class extends NectaryElement {
|
|
|
81
66
|
updateBooleanAttribute(this, 'disabled', isDisabled);
|
|
82
67
|
break;
|
|
83
68
|
}
|
|
84
|
-
|
|
85
69
|
case 'value':
|
|
86
70
|
{
|
|
87
71
|
this.#$input.value = newVal ?? '';
|
|
@@ -89,19 +73,15 @@ defineCustomElement('sinch-radio-option', class extends NectaryElement {
|
|
|
89
73
|
}
|
|
90
74
|
}
|
|
91
75
|
}
|
|
92
|
-
|
|
93
76
|
get focusable() {
|
|
94
77
|
return true;
|
|
95
78
|
}
|
|
96
|
-
|
|
97
79
|
focus() {
|
|
98
80
|
this.#$input.focus();
|
|
99
81
|
}
|
|
100
|
-
|
|
101
82
|
blur() {
|
|
102
83
|
this.#$input.blur();
|
|
103
84
|
}
|
|
104
|
-
|
|
105
85
|
#onInput = e => {
|
|
106
86
|
e.stopPropagation();
|
|
107
87
|
this.#$input.checked = false;
|
package/segment/index.js
CHANGED
|
@@ -15,7 +15,6 @@ defineCustomElement('sinch-segment', class extends NectaryElement {
|
|
|
15
15
|
#$collapseWrapper;
|
|
16
16
|
#$actionSlot;
|
|
17
17
|
#$actionWrapper;
|
|
18
|
-
|
|
19
18
|
constructor() {
|
|
20
19
|
super();
|
|
21
20
|
const shadowRoot = this.attachShadow();
|
|
@@ -30,7 +29,6 @@ defineCustomElement('sinch-segment', class extends NectaryElement {
|
|
|
30
29
|
this.#$collapseWrapper = shadowRoot.querySelector('#collapse');
|
|
31
30
|
this.#$actionWrapper = shadowRoot.querySelector('#action');
|
|
32
31
|
}
|
|
33
|
-
|
|
34
32
|
connectedCallback() {
|
|
35
33
|
this.#$previewSlot.addEventListener('slotchange', this.#onPreviewSlotChange);
|
|
36
34
|
this.#$infoSlot.addEventListener('slotchange', this.#onInfoSlotChange);
|
|
@@ -41,18 +39,15 @@ defineCustomElement('sinch-segment', class extends NectaryElement {
|
|
|
41
39
|
this.#onCollapseSlotChange();
|
|
42
40
|
this.#onActionSlotChange();
|
|
43
41
|
}
|
|
44
|
-
|
|
45
42
|
disconnectedCallback() {
|
|
46
43
|
this.#$previewSlot.removeEventListener('slotchange', this.#onPreviewSlotChange);
|
|
47
44
|
this.#$infoSlot.removeEventListener('slotchange', this.#onInfoSlotChange);
|
|
48
45
|
this.#$collapseSlot.removeEventListener('slotchange', this.#onCollapseSlotChange);
|
|
49
46
|
this.#$actionSlot.removeEventListener('slotchange', this.#onActionSlotChange);
|
|
50
47
|
}
|
|
51
|
-
|
|
52
48
|
static get observedAttributes() {
|
|
53
49
|
return ['caption', 'collapsed', 'size'];
|
|
54
50
|
}
|
|
55
|
-
|
|
56
51
|
attributeChangedCallback(name, _, newVal) {
|
|
57
52
|
switch (name) {
|
|
58
53
|
case 'caption':
|
|
@@ -60,13 +55,11 @@ defineCustomElement('sinch-segment', class extends NectaryElement {
|
|
|
60
55
|
updateAttribute(this.#$caption, 'text', newVal);
|
|
61
56
|
break;
|
|
62
57
|
}
|
|
63
|
-
|
|
64
58
|
case 'collapsed':
|
|
65
59
|
{
|
|
66
60
|
updateBooleanAttribute(this, 'collapsed', isAttrTrue(newVal));
|
|
67
61
|
break;
|
|
68
62
|
}
|
|
69
|
-
|
|
70
63
|
case 'size':
|
|
71
64
|
{
|
|
72
65
|
assertSize(newVal);
|
|
@@ -76,36 +69,28 @@ defineCustomElement('sinch-segment', class extends NectaryElement {
|
|
|
76
69
|
}
|
|
77
70
|
}
|
|
78
71
|
}
|
|
79
|
-
|
|
80
72
|
set caption(caption) {
|
|
81
73
|
updateAttribute(this, 'caption', caption);
|
|
82
74
|
}
|
|
83
|
-
|
|
84
75
|
get caption() {
|
|
85
76
|
return getAttribute(this, 'caption', '');
|
|
86
77
|
}
|
|
87
|
-
|
|
88
78
|
set collapsed(isChecked) {
|
|
89
79
|
updateBooleanAttribute(this, 'collapsed', isChecked);
|
|
90
80
|
}
|
|
91
|
-
|
|
92
81
|
get collapsed() {
|
|
93
82
|
return getBooleanAttribute(this, 'collapsed');
|
|
94
83
|
}
|
|
95
|
-
|
|
96
84
|
get size() {
|
|
97
85
|
return getLiteralAttribute(this, sizeValues, 'size', 'm');
|
|
98
86
|
}
|
|
99
|
-
|
|
100
87
|
set size(value) {
|
|
101
88
|
updateLiteralAttribute(this, sizeValues, 'size', value);
|
|
102
89
|
}
|
|
103
|
-
|
|
104
90
|
get collapseButtonRect() {
|
|
105
91
|
const $collapseButton = this.#$collapseSlot.assignedElements()[0];
|
|
106
92
|
return $collapseButton != null ? getRect($collapseButton) : null;
|
|
107
93
|
}
|
|
108
|
-
|
|
109
94
|
#onPreviewSlotChange = () => {
|
|
110
95
|
setClass(this.#$previewWrapper, 'empty', this.#$previewSlot.assignedElements().length === 0);
|
|
111
96
|
};
|
|
@@ -7,29 +7,24 @@ const template = document.createElement('template');
|
|
|
7
7
|
template.innerHTML = templateHTML;
|
|
8
8
|
defineCustomElement('sinch-segment-collapse', class extends NectaryElement {
|
|
9
9
|
#$button;
|
|
10
|
-
|
|
11
10
|
constructor() {
|
|
12
11
|
super();
|
|
13
12
|
const shadowRoot = this.attachShadow();
|
|
14
13
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
15
14
|
this.#$button = shadowRoot.querySelector('#button');
|
|
16
15
|
}
|
|
17
|
-
|
|
18
16
|
connectedCallback() {
|
|
19
17
|
this.setAttribute('role', 'checkbox');
|
|
20
18
|
this.#$button.addEventListener('click', this.#onClick);
|
|
21
19
|
this.addEventListener('-change', this.#onChangeReactHandler);
|
|
22
20
|
}
|
|
23
|
-
|
|
24
21
|
disconnectedCallback() {
|
|
25
22
|
this.#$button.removeEventListener('click', this.#onClick);
|
|
26
23
|
this.removeEventListener('-change', this.#onChangeReactHandler);
|
|
27
24
|
}
|
|
28
|
-
|
|
29
25
|
static get observedAttributes() {
|
|
30
26
|
return ['value'];
|
|
31
27
|
}
|
|
32
|
-
|
|
33
28
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
34
29
|
switch (name) {
|
|
35
30
|
case 'value':
|
|
@@ -39,35 +34,27 @@ defineCustomElement('sinch-segment-collapse', class extends NectaryElement {
|
|
|
39
34
|
}
|
|
40
35
|
}
|
|
41
36
|
}
|
|
42
|
-
|
|
43
37
|
get type() {
|
|
44
38
|
return 'text';
|
|
45
39
|
}
|
|
46
|
-
|
|
47
40
|
get nodeName() {
|
|
48
41
|
return 'input';
|
|
49
42
|
}
|
|
50
|
-
|
|
51
43
|
set value(isChecked) {
|
|
52
44
|
updateBooleanAttribute(this, 'value', isChecked);
|
|
53
45
|
}
|
|
54
|
-
|
|
55
46
|
get value() {
|
|
56
47
|
return getBooleanAttribute(this, 'value');
|
|
57
48
|
}
|
|
58
|
-
|
|
59
49
|
get focusable() {
|
|
60
50
|
return true;
|
|
61
51
|
}
|
|
62
|
-
|
|
63
52
|
focus() {
|
|
64
53
|
this.#$button.focus();
|
|
65
54
|
}
|
|
66
|
-
|
|
67
55
|
blur() {
|
|
68
56
|
this.#$button.blur();
|
|
69
57
|
}
|
|
70
|
-
|
|
71
58
|
#onClick = () => {
|
|
72
59
|
const detail = !this.value;
|
|
73
60
|
this.dispatchEvent(new CustomEvent('change', {
|
|
@@ -4,48 +4,39 @@ const template = document.createElement('template');
|
|
|
4
4
|
template.innerHTML = templateHTML;
|
|
5
5
|
defineCustomElement('sinch-segmented-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('option-change', this.#onOptionChange);
|
|
18
16
|
this.#$slot.addEventListener('slotchange', this.#onSlotChange);
|
|
19
17
|
this.addEventListener('-change', this.#onChangeReactHandler);
|
|
20
18
|
}
|
|
21
|
-
|
|
22
19
|
disconnectedCallback() {
|
|
23
20
|
this.#$slot.removeEventListener('option-change', this.#onOptionChange);
|
|
24
21
|
this.#$slot.removeEventListener('slotchange', this.#onSlotChange);
|
|
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
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
45
37
|
if (oldVal === newVal) {
|
|
46
38
|
return;
|
|
47
39
|
}
|
|
48
|
-
|
|
49
40
|
switch (name) {
|
|
50
41
|
case 'value':
|
|
51
42
|
{
|
|
@@ -54,7 +45,6 @@ defineCustomElement('sinch-segmented-control', class extends NectaryElement {
|
|
|
54
45
|
}
|
|
55
46
|
}
|
|
56
47
|
}
|
|
57
|
-
|
|
58
48
|
#onSlotChange = () => {
|
|
59
49
|
this.#onValueChange(this.value);
|
|
60
50
|
};
|
|
@@ -69,14 +59,12 @@ defineCustomElement('sinch-segmented-control', class extends NectaryElement {
|
|
|
69
59
|
detail
|
|
70
60
|
}));
|
|
71
61
|
};
|
|
72
|
-
|
|
73
62
|
#onValueChange(value) {
|
|
74
63
|
for (const $option of this.#$slot.assignedElements()) {
|
|
75
64
|
const isChecked = !getBooleanAttribute($option, 'disabled') && value === getAttribute($option, 'value', '');
|
|
76
65
|
updateBooleanAttribute($option, 'data-checked', isChecked);
|
|
77
66
|
}
|
|
78
67
|
}
|
|
79
|
-
|
|
80
68
|
#onChangeReactHandler = e => {
|
|
81
69
|
getReactEventHandler(this, 'on-change')?.(e);
|
|
82
70
|
};
|
|
@@ -5,7 +5,6 @@ template.innerHTML = templateHTML;
|
|
|
5
5
|
defineCustomElement('sinch-segmented-control-option', class extends NectaryElement {
|
|
6
6
|
#$button;
|
|
7
7
|
#$label;
|
|
8
|
-
|
|
9
8
|
constructor() {
|
|
10
9
|
super();
|
|
11
10
|
const shadowRoot = this.attachShadow();
|
|
@@ -13,7 +12,6 @@ defineCustomElement('sinch-segmented-control-option', class extends NectaryEleme
|
|
|
13
12
|
this.#$button = shadowRoot.querySelector('#button');
|
|
14
13
|
this.#$label = shadowRoot.querySelector('#content');
|
|
15
14
|
}
|
|
16
|
-
|
|
17
15
|
connectedCallback() {
|
|
18
16
|
this.setAttribute('role', 'tab');
|
|
19
17
|
this.#$button.addEventListener('click', this.#onButtonClick);
|
|
@@ -22,7 +20,6 @@ defineCustomElement('sinch-segmented-control-option', class extends NectaryEleme
|
|
|
22
20
|
this.addEventListener('-focus', this.#onFocusReactHandler);
|
|
23
21
|
this.addEventListener('-blur', this.#onBlurReactHandler);
|
|
24
22
|
}
|
|
25
|
-
|
|
26
23
|
disconnectedCallback() {
|
|
27
24
|
this.#$button.removeEventListener('click', this.#onButtonClick);
|
|
28
25
|
this.#$button.removeEventListener('focus', this.#onButtonFocus);
|
|
@@ -30,53 +27,42 @@ defineCustomElement('sinch-segmented-control-option', class extends NectaryEleme
|
|
|
30
27
|
this.removeEventListener('-focus', this.#onFocusReactHandler);
|
|
31
28
|
this.removeEventListener('-blur', this.#onBlurReactHandler);
|
|
32
29
|
}
|
|
33
|
-
|
|
34
30
|
static get observedAttributes() {
|
|
35
31
|
return ['data-checked', 'disabled', 'text'];
|
|
36
32
|
}
|
|
37
|
-
|
|
38
33
|
set value(value) {
|
|
39
34
|
updateAttribute(this, 'value', value);
|
|
40
35
|
}
|
|
41
|
-
|
|
42
36
|
get value() {
|
|
43
37
|
return getAttribute(this, 'value', '');
|
|
44
38
|
}
|
|
45
|
-
|
|
46
39
|
set disabled(isDisabled) {
|
|
47
40
|
updateBooleanAttribute(this, 'disabled', isDisabled);
|
|
48
41
|
}
|
|
49
|
-
|
|
50
42
|
get disabled() {
|
|
51
43
|
return getBooleanAttribute(this, 'disabled');
|
|
52
44
|
}
|
|
53
|
-
|
|
54
45
|
set text(value) {
|
|
55
46
|
updateAttribute(this, 'text', value);
|
|
56
47
|
}
|
|
57
|
-
|
|
58
48
|
get text() {
|
|
59
49
|
return getAttribute(this, 'text', '');
|
|
60
50
|
}
|
|
61
|
-
|
|
62
51
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
63
52
|
if (oldVal === newVal) {
|
|
64
53
|
return;
|
|
65
54
|
}
|
|
66
|
-
|
|
67
55
|
switch (name) {
|
|
68
56
|
case 'text':
|
|
69
57
|
{
|
|
70
58
|
this.#$label.textContent = newVal;
|
|
71
59
|
break;
|
|
72
60
|
}
|
|
73
|
-
|
|
74
61
|
case 'data-checked':
|
|
75
62
|
{
|
|
76
63
|
updateExplicitBooleanAttribute(this, 'aria-selected', isAttrTrue(newVal));
|
|
77
64
|
break;
|
|
78
65
|
}
|
|
79
|
-
|
|
80
66
|
case 'disabled':
|
|
81
67
|
{
|
|
82
68
|
this.#$button.disabled = isAttrTrue(newVal);
|
|
@@ -84,19 +70,15 @@ defineCustomElement('sinch-segmented-control-option', class extends NectaryEleme
|
|
|
84
70
|
}
|
|
85
71
|
}
|
|
86
72
|
}
|
|
87
|
-
|
|
88
73
|
get focusable() {
|
|
89
74
|
return true;
|
|
90
75
|
}
|
|
91
|
-
|
|
92
76
|
focus() {
|
|
93
77
|
this.#$button.focus();
|
|
94
78
|
}
|
|
95
|
-
|
|
96
79
|
blur() {
|
|
97
80
|
this.#$button.blur();
|
|
98
81
|
}
|
|
99
|
-
|
|
100
82
|
#onButtonClick = e => {
|
|
101
83
|
e.stopPropagation();
|
|
102
84
|
this.dispatchEvent(new CustomEvent('option-change', {
|