@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
package/radio/index.js
CHANGED
|
@@ -1,133 +1,30 @@
|
|
|
1
|
-
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
|
-
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
|
-
|
|
4
|
-
var _$slot, _onOptionKeyDown, _onSlotChange, _onOptionChange, _onValueChange, _dispatchChangeEvent, _getFirstOption, _getLastOption, _getNextOption, _getPrevOption, _getEnabledRadioElements, _findSelectedOption, _onChangeReactHandler;
|
|
5
|
-
|
|
6
|
-
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
|
7
|
-
|
|
8
|
-
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
9
|
-
|
|
10
|
-
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
11
|
-
|
|
12
|
-
function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
|
|
13
|
-
|
|
14
1
|
import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, NectaryElement, updateAttribute, updateBooleanAttribute } from '../utils';
|
|
15
2
|
const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:column;gap:8px;box-sizing:border-box;width:100%}</style><div id="wrapper"><slot></slot></div>';
|
|
16
3
|
const template = document.createElement('template');
|
|
17
4
|
template.innerHTML = templateHTML;
|
|
18
|
-
defineCustomElement('sinch-radio',
|
|
5
|
+
defineCustomElement('sinch-radio', class extends NectaryElement {
|
|
6
|
+
#$slot;
|
|
7
|
+
|
|
19
8
|
constructor() {
|
|
20
9
|
super();
|
|
21
|
-
|
|
22
|
-
_classPrivateMethodInitSpec(this, _findSelectedOption);
|
|
23
|
-
|
|
24
|
-
_classPrivateMethodInitSpec(this, _getEnabledRadioElements);
|
|
25
|
-
|
|
26
|
-
_classPrivateMethodInitSpec(this, _getPrevOption);
|
|
27
|
-
|
|
28
|
-
_classPrivateMethodInitSpec(this, _getNextOption);
|
|
29
|
-
|
|
30
|
-
_classPrivateMethodInitSpec(this, _getLastOption);
|
|
31
|
-
|
|
32
|
-
_classPrivateMethodInitSpec(this, _getFirstOption);
|
|
33
|
-
|
|
34
|
-
_classPrivateMethodInitSpec(this, _dispatchChangeEvent);
|
|
35
|
-
|
|
36
|
-
_classPrivateMethodInitSpec(this, _onValueChange);
|
|
37
|
-
|
|
38
|
-
_classPrivateFieldInitSpec(this, _$slot, {
|
|
39
|
-
writable: true,
|
|
40
|
-
value: void 0
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
_classPrivateFieldInitSpec(this, _onOptionKeyDown, {
|
|
44
|
-
writable: true,
|
|
45
|
-
value: e => {
|
|
46
|
-
switch (e.code) {
|
|
47
|
-
case 'ArrowUp':
|
|
48
|
-
case 'ArrowLeft':
|
|
49
|
-
{
|
|
50
|
-
e.preventDefault();
|
|
51
|
-
|
|
52
|
-
const $option = _classPrivateMethodGet(this, _getPrevOption, _getPrevOption2).call(this);
|
|
53
|
-
|
|
54
|
-
if ($option !== null) {
|
|
55
|
-
$option.focus();
|
|
56
|
-
|
|
57
|
-
_classPrivateMethodGet(this, _dispatchChangeEvent, _dispatchChangeEvent2).call(this, $option.value);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
break;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
case 'ArrowDown':
|
|
64
|
-
case 'ArrowRight':
|
|
65
|
-
{
|
|
66
|
-
e.preventDefault();
|
|
67
|
-
|
|
68
|
-
const $option = _classPrivateMethodGet(this, _getNextOption, _getNextOption2).call(this);
|
|
69
|
-
|
|
70
|
-
if ($option !== null) {
|
|
71
|
-
$option.focus();
|
|
72
|
-
|
|
73
|
-
_classPrivateMethodGet(this, _dispatchChangeEvent, _dispatchChangeEvent2).call(this, $option.value);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
break;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
_classPrivateFieldInitSpec(this, _onSlotChange, {
|
|
83
|
-
writable: true,
|
|
84
|
-
value: () => {
|
|
85
|
-
_classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this, this.value);
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
_classPrivateFieldInitSpec(this, _onOptionChange, {
|
|
90
|
-
writable: true,
|
|
91
|
-
value: e => {
|
|
92
|
-
e.stopPropagation();
|
|
93
|
-
|
|
94
|
-
_classPrivateMethodGet(this, _dispatchChangeEvent, _dispatchChangeEvent2).call(this, e.detail);
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
_classPrivateFieldInitSpec(this, _onChangeReactHandler, {
|
|
99
|
-
writable: true,
|
|
100
|
-
value: e => {
|
|
101
|
-
getReactEventHandler(this, 'on-change')?.(e);
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
|
|
105
10
|
const shadowRoot = this.attachShadow();
|
|
106
11
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
107
|
-
|
|
108
|
-
_classPrivateFieldSet(this, _$slot, shadowRoot.querySelector('slot'));
|
|
12
|
+
this.#$slot = shadowRoot.querySelector('slot');
|
|
109
13
|
}
|
|
110
14
|
|
|
111
15
|
connectedCallback() {
|
|
112
16
|
this.setAttribute('role', 'radiogroup');
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
_classPrivateFieldGet(this, _$slot).addEventListener('option-change', _classPrivateFieldGet(this, _onOptionChange));
|
|
119
|
-
|
|
120
|
-
this.addEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
|
|
17
|
+
this.#$slot.addEventListener('slotchange', this.#onSlotChange);
|
|
18
|
+
this.#$slot.addEventListener('keydown', this.#onOptionKeyDown);
|
|
19
|
+
this.#$slot.addEventListener('option-change', this.#onOptionChange);
|
|
20
|
+
this.addEventListener('-change', this.#onChangeReactHandler);
|
|
121
21
|
}
|
|
122
22
|
|
|
123
23
|
disconnectedCallback() {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
_classPrivateFieldGet(this, _$slot).removeEventListener('option-change', _classPrivateFieldGet(this, _onOptionChange));
|
|
129
|
-
|
|
130
|
-
this.removeEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
|
|
24
|
+
this.#$slot.removeEventListener('slotchange', this.#onSlotChange);
|
|
25
|
+
this.#$slot.removeEventListener('keydown', this.#onOptionKeyDown);
|
|
26
|
+
this.#$slot.removeEventListener('option-change', this.#onOptionChange);
|
|
27
|
+
this.removeEventListener('-change', this.#onChangeReactHandler);
|
|
131
28
|
}
|
|
132
29
|
|
|
133
30
|
static get observedAttributes() {
|
|
@@ -154,84 +51,121 @@ defineCustomElement('sinch-radio', (_$slot = new WeakMap(), _onOptionKeyDown = n
|
|
|
154
51
|
switch (name) {
|
|
155
52
|
case 'value':
|
|
156
53
|
{
|
|
157
|
-
|
|
158
|
-
|
|
54
|
+
this.#onValueChange(newVal ?? '');
|
|
159
55
|
break;
|
|
160
56
|
}
|
|
161
57
|
}
|
|
162
58
|
}
|
|
163
59
|
|
|
164
|
-
|
|
60
|
+
#onOptionKeyDown = e => {
|
|
61
|
+
switch (e.code) {
|
|
62
|
+
case 'ArrowUp':
|
|
63
|
+
case 'ArrowLeft':
|
|
64
|
+
{
|
|
65
|
+
e.preventDefault();
|
|
66
|
+
const $option = this.#getPrevOption();
|
|
165
67
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
171
|
-
}
|
|
68
|
+
if ($option !== null) {
|
|
69
|
+
$option.focus();
|
|
70
|
+
this.#dispatchChangeEvent($option.value);
|
|
71
|
+
}
|
|
172
72
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
detail: value,
|
|
176
|
-
bubbles: true
|
|
177
|
-
}));
|
|
178
|
-
this.dispatchEvent(new CustomEvent('-change', {
|
|
179
|
-
detail: value
|
|
180
|
-
}));
|
|
181
|
-
}
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
182
75
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
}
|
|
76
|
+
case 'ArrowDown':
|
|
77
|
+
case 'ArrowRight':
|
|
78
|
+
{
|
|
79
|
+
e.preventDefault();
|
|
80
|
+
const $option = this.#getNextOption();
|
|
189
81
|
|
|
190
|
-
|
|
191
|
-
|
|
82
|
+
if ($option !== null) {
|
|
83
|
+
$option.focus();
|
|
84
|
+
this.#dispatchChangeEvent($option.value);
|
|
85
|
+
}
|
|
192
86
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
#onSlotChange = () => {
|
|
92
|
+
this.#onValueChange(this.value);
|
|
93
|
+
};
|
|
94
|
+
#onOptionChange = e => {
|
|
95
|
+
e.stopPropagation();
|
|
96
|
+
this.#dispatchChangeEvent(e.detail);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
#onValueChange(value) {
|
|
100
|
+
for (const $option of this.#$slot.assignedElements()) {
|
|
101
|
+
const isChecked = !getBooleanAttribute($option, 'disabled') && value === getAttribute($option, 'value', '');
|
|
102
|
+
updateBooleanAttribute($option, 'checked', isChecked);
|
|
197
103
|
}
|
|
198
104
|
}
|
|
199
105
|
|
|
200
|
-
|
|
201
|
-
|
|
106
|
+
#dispatchChangeEvent(value) {
|
|
107
|
+
this.dispatchEvent(new CustomEvent('change', {
|
|
108
|
+
detail: value,
|
|
109
|
+
bubbles: true
|
|
110
|
+
}));
|
|
111
|
+
this.dispatchEvent(new CustomEvent('-change', {
|
|
112
|
+
detail: value
|
|
113
|
+
}));
|
|
114
|
+
}
|
|
202
115
|
|
|
203
|
-
|
|
204
|
-
|
|
116
|
+
#getFirstOption() {
|
|
117
|
+
for (const $option of this.#$slot.assignedElements()) {
|
|
118
|
+
if ($option.disabled !== true) {
|
|
119
|
+
return $option;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
205
122
|
|
|
206
|
-
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
207
125
|
|
|
208
|
-
|
|
126
|
+
#getLastOption() {
|
|
127
|
+
for (const $option of this.#$slot.assignedElements().reverse()) {
|
|
128
|
+
if ($option.disabled !== true) {
|
|
129
|
+
return $option;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
209
132
|
|
|
210
|
-
|
|
211
|
-
return _classPrivateMethodGet(this, _getFirstOption, _getFirstOption2).call(this);
|
|
133
|
+
return null;
|
|
212
134
|
}
|
|
213
135
|
|
|
214
|
-
|
|
215
|
-
|
|
136
|
+
#getNextOption() {
|
|
137
|
+
const $options = this.#getEnabledRadioElements();
|
|
138
|
+
const $selectedOption = this.#findSelectedOption($options);
|
|
139
|
+
const currentIndex = $selectedOption !== null ? $options.indexOf($selectedOption) : -1;
|
|
140
|
+
|
|
141
|
+
if (currentIndex < 0) {
|
|
142
|
+
return this.#getFirstOption();
|
|
143
|
+
}
|
|
216
144
|
|
|
217
|
-
|
|
218
|
-
|
|
145
|
+
return $options[(currentIndex + 1) % $options.length];
|
|
146
|
+
}
|
|
219
147
|
|
|
220
|
-
|
|
148
|
+
#getPrevOption() {
|
|
149
|
+
const $options = this.#getEnabledRadioElements();
|
|
150
|
+
const $selectedOption = this.#findSelectedOption($options);
|
|
151
|
+
const currentIndex = $selectedOption !== null ? $options.indexOf($selectedOption) : -1;
|
|
221
152
|
|
|
222
|
-
|
|
153
|
+
if (currentIndex < 0) {
|
|
154
|
+
return this.#getLastOption();
|
|
155
|
+
}
|
|
223
156
|
|
|
224
|
-
|
|
225
|
-
return _classPrivateMethodGet(this, _getLastOption, _getLastOption2).call(this);
|
|
157
|
+
return $options[(currentIndex - 1 + $options.length) % $options.length];
|
|
226
158
|
}
|
|
227
159
|
|
|
228
|
-
|
|
229
|
-
|
|
160
|
+
#getEnabledRadioElements() {
|
|
161
|
+
return this.#$slot.assignedElements().filter(el => el.disabled !== true);
|
|
162
|
+
}
|
|
230
163
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
}
|
|
164
|
+
#findSelectedOption(elements) {
|
|
165
|
+
return elements.find(el => el.checked) ?? null;
|
|
166
|
+
}
|
|
234
167
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
}
|
|
168
|
+
#onChangeReactHandler = e => {
|
|
169
|
+
getReactEventHandler(this, 'on-change')?.(e);
|
|
170
|
+
};
|
|
171
|
+
});
|
package/radio-option/index.js
CHANGED
|
@@ -1,58 +1,26 @@
|
|
|
1
|
-
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
|
-
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
|
-
|
|
4
|
-
var _$input, _$label, _onInput;
|
|
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 { defineCustomElement, getAttribute, getBooleanAttribute, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute } from '../utils';
|
|
11
|
-
const templateHTML = '<style>:host{--sinch-color-radio-outer-circle:var(--sinch-color-transparent);--sinch-color-radio-background:var(--sinch-color-snow-100);--sinch-color-radio-border:var(--sinch-color-stormy-300);--sinch-color-radio-outer-circle-checked:var(--sinch-color-transparent);--sinch-color-radio-border-checked:var(--sinch-color-tropical-500);--sinch-color-radio-outer-circle-hover:var(--sinch-color-snow-500);--sinch-color-radio-border-hover:var(--sinch-color-stormy-300);--sinch-color-radio-outer-circle-hover-checked:var(--sinch-color-tropical-100);--sinch-color-radio-border-hover-checked:var(--sinch-color-tropical-500);--sinch-color-radio-outer-circle-focus:var(--sinch-color-snow-
|
|
2
|
+
const templateHTML = '<style>:host{--sinch-color-radio-outer-circle:var(--sinch-color-transparent);--sinch-color-radio-background:var(--sinch-color-snow-100);--sinch-color-radio-border:var(--sinch-color-stormy-300);--sinch-color-radio-outer-circle-checked:var(--sinch-color-transparent);--sinch-color-radio-border-checked:var(--sinch-color-tropical-500);--sinch-color-radio-outer-circle-hover:var(--sinch-color-snow-500);--sinch-color-radio-border-hover:var(--sinch-color-stormy-300);--sinch-color-radio-outer-circle-hover-checked:var(--sinch-color-tropical-100);--sinch-color-radio-border-hover-checked:var(--sinch-color-tropical-500);--sinch-color-radio-outer-circle-focus:var(--sinch-color-snow-700);--sinch-color-radio-border-focus:var(--sinch-color-stormy-300);--sinch-color-radio-outer-circle-focus-checked:var(--sinch-color-tropical-200);--sinch-color-radio-border-focus-checked:var(--sinch-color-tropical-500);--sinch-color-radio-outer-circle-active:var(--sinch-color-stormy-100);--sinch-color-radio-border-active:var(--sinch-color-stormy-300);--sinch-color-radio-outer-circle-active-checked:var(--sinch-color-tropical-300);--sinch-color-radio-border-active-checked:var(--sinch-color-tropical-500);--sinch-color-radio-outer-circle-disabled:var(--sinch-color-transparent);--sinch-color-radio-border-disabled:var(--sinch-color-stormy-100);--sinch-color-radio-outer-circle-disabled-checked:var(--sinch-color-transparent);--sinch-color-radio-border-disabled-checked:var(--sinch-color-stormy-100);display:block;outline:0}#wrapper{display:flex;height:32px;box-sizing:border-box;width:100%}#input{all:initial;display:block;width:32px;height:32px;cursor:pointer}#input:disabled{cursor:initial}#icon-container{position:relative;width:32px;height:32px}#input::before{content:"";position:absolute;top:0;left:0;width:32px;height:32px;border-radius:50%;pointer-events:none;background-color:var(--sinch-color-radio-outer-circle);transition:background-color .1s linear}#input::after{content:"";position:absolute;top:6px;left:6px;width:20px;height:20px;border-radius:50%;pointer-events:none;background-color:var(--sinch-color-radio-background);border:2px solid var(--sinch-color-radio-border);transition:background-color .1s linear;box-sizing:border-box}#icon-knob{position:absolute;left:11px;top:11px;width:10px;height:10px;border-radius:50%;transition:opacity .1s linear;opacity:0;background-color:var(--sinch-color-radio-border);pointer-events:none}@media (prefers-reduced-motion){#icon-knob,#input::after,#input::before{transition:none}}#label{align-self:center;flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;padding-left:8px;font:var(--sinch-font-body);color:var(--sinch-color-text-default)}:host([disabled]:not([disabled=false])) #label{color:var(--sinch-color-stormy-200)}#input:checked::before{background-color:var(--sinch-color-radio-outer-circle-checked)}#input:checked::after{border-color:var(--sinch-color-radio-border-checked)}#input:checked~#icon-knob{opacity:1;background-color:var(--sinch-color-radio-border-checked)}#input:focus::before{background-color:var(--sinch-color-radio-outer-circle-focus)}#input:focus::after{border-color:var(--sinch-color-radio-border-focus)}#input:focus~#icon-knob{background-color:var(--sinch-color-radio-border-focus)}#input:hover::before{background-color:var(--sinch-color-radio-outer-circle-hover)}#input:hover::after{border-color:var(--sinch-color-radio-border-hover)}#input:hover~#icon-knob{background-color:var(--sinch-color-radio-border-hover)}#input:active::before{background-color:var(--sinch-color-radio-outer-circle-active)}#input:active::after{border-color:var(--sinch-color-radio-border-active)}#input:active~#icon-knob{background-color:var(--sinch-color-radio-border-active)}#input:disabled::before{background-color:var(--sinch-color-radio-outer-circle-disabled)}#input:disabled::after{border-color:var(--sinch-color-radio-border-disabled)}#input:disabled~#icon-knob{background-color:var(--sinch-color-radio-border-disabled)}#input:focus:checked::before{background-color:var(--sinch-color-radio-outer-circle-focus-checked)}#input:focus:checked::after{border-color:var(--sinch-color-radio-border-focus-checked)}#input:focus:checked~#icon-knob{opacity:1;background-color:var(--sinch-color-radio-border-focus-checked)}#input:hover:checked::before{background-color:var(--sinch-color-radio-outer-circle-hover-checked)}#input:hover:checked::after{border-color:var(--sinch-color-radio-border-hover-checked)}#input:hover:checked~#icon-knob{opacity:1;background-color:var(--sinch-color-radio-border-hover-checked)}#input:active:checked::before{background-color:var(--sinch-color-radio-outer-circle-active-checked)}#input:active:checked::after{border-color:var(--sinch-color-radio-border-active-checked)}#input:active:checked~#icon-knob{opacity:1;background-color:var(--sinch-color-radio-border-active-checked)}#input:disabled:checked::before{background-color:var(--sinch-color-radio-outer-circle-disabled-checked)}#input:disabled:checked::after{border-color:var(--sinch-color-radio-border-disabled-checked)}#input:disabled:checked~#icon-knob{opacity:1;background-color:var(--sinch-color-radio-border-disabled-checked)}</style><div id="wrapper"><div id="icon-container"><input id="input" type="radio"/><div id="icon-knob"></div></div><label for="input" id="label"></label></div>';
|
|
12
3
|
const template = document.createElement('template');
|
|
13
4
|
template.innerHTML = templateHTML;
|
|
14
|
-
defineCustomElement('sinch-radio-option',
|
|
5
|
+
defineCustomElement('sinch-radio-option', class extends NectaryElement {
|
|
6
|
+
#$input;
|
|
7
|
+
#$label;
|
|
8
|
+
|
|
15
9
|
constructor() {
|
|
16
10
|
super();
|
|
17
|
-
|
|
18
|
-
_classPrivateFieldInitSpec(this, _$input, {
|
|
19
|
-
writable: true,
|
|
20
|
-
value: void 0
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
_classPrivateFieldInitSpec(this, _$label, {
|
|
24
|
-
writable: true,
|
|
25
|
-
value: void 0
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
_classPrivateFieldInitSpec(this, _onInput, {
|
|
29
|
-
writable: true,
|
|
30
|
-
value: e => {
|
|
31
|
-
e.stopPropagation();
|
|
32
|
-
_classPrivateFieldGet(this, _$input).checked = false;
|
|
33
|
-
this.dispatchEvent(new CustomEvent('option-change', {
|
|
34
|
-
bubbles: true,
|
|
35
|
-
detail: this.value
|
|
36
|
-
}));
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
|
|
40
11
|
const shadowRoot = this.attachShadow();
|
|
41
12
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
_classPrivateFieldSet(this, _$label, shadowRoot.querySelector('label'));
|
|
13
|
+
this.#$input = shadowRoot.querySelector('input');
|
|
14
|
+
this.#$label = shadowRoot.querySelector('label');
|
|
46
15
|
}
|
|
47
16
|
|
|
48
17
|
connectedCallback() {
|
|
49
18
|
this.setAttribute('role', 'radio');
|
|
50
|
-
|
|
51
|
-
_classPrivateFieldGet(this, _$input).addEventListener('input', _classPrivateFieldGet(this, _onInput));
|
|
19
|
+
this.#$input.addEventListener('input', this.#onInput);
|
|
52
20
|
}
|
|
53
21
|
|
|
54
22
|
disconnectedCallback() {
|
|
55
|
-
|
|
23
|
+
this.#$input.removeEventListener('input', this.#onInput);
|
|
56
24
|
}
|
|
57
25
|
|
|
58
26
|
static get observedAttributes() {
|
|
@@ -95,13 +63,13 @@ defineCustomElement('sinch-radio-option', (_$input = new WeakMap(), _$label = ne
|
|
|
95
63
|
switch (name) {
|
|
96
64
|
case 'text':
|
|
97
65
|
{
|
|
98
|
-
|
|
66
|
+
this.#$label.textContent = newVal;
|
|
99
67
|
break;
|
|
100
68
|
}
|
|
101
69
|
|
|
102
70
|
case 'checked':
|
|
103
71
|
{
|
|
104
|
-
|
|
72
|
+
this.#$input.checked = isAttrTrue(newVal);
|
|
105
73
|
updateAttribute(this, 'aria-checked', isAttrTrue(newVal));
|
|
106
74
|
break;
|
|
107
75
|
}
|
|
@@ -109,25 +77,33 @@ defineCustomElement('sinch-radio-option', (_$input = new WeakMap(), _$label = ne
|
|
|
109
77
|
case 'disabled':
|
|
110
78
|
{
|
|
111
79
|
const isDisabled = isAttrTrue(newVal);
|
|
112
|
-
|
|
80
|
+
this.#$input.disabled = isDisabled;
|
|
113
81
|
updateBooleanAttribute(this, 'disabled', isDisabled);
|
|
114
82
|
break;
|
|
115
83
|
}
|
|
116
84
|
|
|
117
85
|
case 'value':
|
|
118
86
|
{
|
|
119
|
-
|
|
87
|
+
this.#$input.value = newVal ?? '';
|
|
120
88
|
break;
|
|
121
89
|
}
|
|
122
90
|
}
|
|
123
91
|
}
|
|
124
92
|
|
|
125
93
|
focus() {
|
|
126
|
-
|
|
94
|
+
this.#$input.focus();
|
|
127
95
|
}
|
|
128
96
|
|
|
129
97
|
blur() {
|
|
130
|
-
|
|
98
|
+
this.#$input.blur();
|
|
131
99
|
}
|
|
132
100
|
|
|
133
|
-
|
|
101
|
+
#onInput = e => {
|
|
102
|
+
e.stopPropagation();
|
|
103
|
+
this.#$input.checked = false;
|
|
104
|
+
this.dispatchEvent(new CustomEvent('option-change', {
|
|
105
|
+
bubbles: true,
|
|
106
|
+
detail: this.value
|
|
107
|
+
}));
|
|
108
|
+
};
|
|
109
|
+
});
|