@redvars/peacock 3.3.2 → 3.3.3
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/dist/custom-elements.json +423 -0
- package/dist/index.js +1 -1
- package/dist/peacock-loader.js +4 -1
- package/dist/peacock-loader.js.map +1 -1
- package/dist/{snackbar-74YCdMPL.js → radio-b70_Ie9n.js} +545 -92
- package/dist/radio-b70_Ie9n.js.map +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/radio/index.d.ts +1 -0
- package/dist/src/radio/radio.d.ts +73 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/readme.md +2 -2
- package/src/index.ts +1 -0
- package/src/peacock-loader.ts +4 -0
- package/src/radio/index.ts +1 -0
- package/src/radio/radio.scss +181 -0
- package/src/radio/radio.ts +362 -0
- package/src/tabs/tab.ts +1 -1
- package/dist/snackbar-74YCdMPL.js.map +0 -1
package/src/index.ts
CHANGED
package/src/peacock-loader.ts
CHANGED
|
@@ -19,6 +19,7 @@ import { TimePicker } from './time-picker/time-picker.js';
|
|
|
19
19
|
import { Textarea } from './textarea/textarea.js';
|
|
20
20
|
import { Switch } from './switch/switch.js';
|
|
21
21
|
import { Checkbox } from './checkbox/checkbox.js';
|
|
22
|
+
import { Radio } from './radio/radio.js';
|
|
22
23
|
|
|
23
24
|
import { Menu } from './menu/menu/menu.js';
|
|
24
25
|
import { MenuItem } from './menu/menu-item/menu-item.js';
|
|
@@ -195,6 +196,9 @@ const loaderConfig: LoaderConfig = {
|
|
|
195
196
|
'wc-checkbox': {
|
|
196
197
|
CustomElementClass: Checkbox,
|
|
197
198
|
},
|
|
199
|
+
'wc-radio': {
|
|
200
|
+
CustomElementClass: Radio,
|
|
201
|
+
},
|
|
198
202
|
'wc-spinner': {
|
|
199
203
|
CustomElementClass: Spinner,
|
|
200
204
|
},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Radio } from './radio.js';
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
@use '../../scss/mixin';
|
|
2
|
+
|
|
3
|
+
@include mixin.base-styles;
|
|
4
|
+
|
|
5
|
+
:host {
|
|
6
|
+
display: inline-block;
|
|
7
|
+
--radio-size: 20px;
|
|
8
|
+
--radio-dot-size: 12px;
|
|
9
|
+
--radio-selected-color: var(--color-primary);
|
|
10
|
+
--radio-unselected-color: var(--color-on-surface-variant);
|
|
11
|
+
--radio-state-layer-size: 40px;
|
|
12
|
+
--radio-disabled-opacity: 0.38;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.radio {
|
|
16
|
+
position: relative;
|
|
17
|
+
display: inline-flex;
|
|
18
|
+
align-items: center;
|
|
19
|
+
cursor: pointer;
|
|
20
|
+
user-select: none;
|
|
21
|
+
vertical-align: middle;
|
|
22
|
+
gap: 8px;
|
|
23
|
+
|
|
24
|
+
@include mixin.get-typography('body-medium');
|
|
25
|
+
|
|
26
|
+
.input-native {
|
|
27
|
+
position: absolute;
|
|
28
|
+
width: 1px;
|
|
29
|
+
height: 1px;
|
|
30
|
+
padding: 0;
|
|
31
|
+
margin: -1px;
|
|
32
|
+
overflow: hidden;
|
|
33
|
+
clip: rect(0, 0, 0, 0);
|
|
34
|
+
border: 0;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.container {
|
|
38
|
+
position: relative;
|
|
39
|
+
display: inline-flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
justify-content: center;
|
|
42
|
+
width: var(--radio-state-layer-size);
|
|
43
|
+
height: var(--radio-state-layer-size);
|
|
44
|
+
cursor: inherit;
|
|
45
|
+
outline: none;
|
|
46
|
+
flex-shrink: 0;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.state-layer {
|
|
50
|
+
position: absolute;
|
|
51
|
+
inset: 0;
|
|
52
|
+
border-radius: 50%;
|
|
53
|
+
opacity: 0;
|
|
54
|
+
transition: opacity var(--duration-short2) var(--easing-standard);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.outer-circle {
|
|
58
|
+
position: absolute;
|
|
59
|
+
width: var(--radio-size);
|
|
60
|
+
height: var(--radio-size);
|
|
61
|
+
border: 2px solid var(--radio-unselected-color);
|
|
62
|
+
border-radius: 50%;
|
|
63
|
+
box-sizing: border-box;
|
|
64
|
+
transition: border-color var(--duration-short2) var(--easing-standard);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.inner-circle {
|
|
68
|
+
position: absolute;
|
|
69
|
+
width: var(--radio-dot-size);
|
|
70
|
+
height: var(--radio-dot-size);
|
|
71
|
+
background: var(--radio-selected-color);
|
|
72
|
+
border-radius: 50%;
|
|
73
|
+
opacity: 0;
|
|
74
|
+
transform: scale(0.5);
|
|
75
|
+
transition:
|
|
76
|
+
transform var(--duration-short2) var(--easing-standard),
|
|
77
|
+
opacity var(--duration-short2) var(--easing-standard);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.label {
|
|
81
|
+
color: var(--color-on-surface);
|
|
82
|
+
cursor: inherit;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Hover state
|
|
86
|
+
&:hover:not(.disabled):not(.readonly) {
|
|
87
|
+
.state-layer {
|
|
88
|
+
opacity: 0.08;
|
|
89
|
+
background: var(--color-on-surface);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
&.state-checked .state-layer {
|
|
93
|
+
background: var(--radio-selected-color);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Focus state
|
|
98
|
+
&.has-focus:not(.active):not(.disabled):not(.readonly) {
|
|
99
|
+
.state-layer {
|
|
100
|
+
opacity: 0.12;
|
|
101
|
+
background: var(--color-on-surface);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.container {
|
|
105
|
+
outline: 3px solid var(--color-primary);
|
|
106
|
+
outline-offset: 2px;
|
|
107
|
+
border-radius: 50%;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
&.state-checked .state-layer {
|
|
111
|
+
background: var(--radio-selected-color);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Active/pressed state
|
|
116
|
+
&.active:not(.disabled):not(.readonly) {
|
|
117
|
+
.state-layer {
|
|
118
|
+
opacity: 0.12;
|
|
119
|
+
background: var(--color-on-surface);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
&.state-checked .state-layer {
|
|
123
|
+
background: var(--radio-selected-color);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Checked state
|
|
129
|
+
.radio.state-checked {
|
|
130
|
+
.outer-circle {
|
|
131
|
+
border-color: var(--radio-selected-color);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.inner-circle {
|
|
135
|
+
opacity: 1;
|
|
136
|
+
transform: scale(1);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Readonly state
|
|
141
|
+
.radio.readonly {
|
|
142
|
+
cursor: default;
|
|
143
|
+
|
|
144
|
+
.state-layer {
|
|
145
|
+
display: none;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.outer-circle {
|
|
149
|
+
border-color: var(--color-on-surface-variant);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
&.state-checked {
|
|
153
|
+
.inner-circle {
|
|
154
|
+
background: var(--color-on-surface-variant);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Disabled state
|
|
160
|
+
.radio.disabled {
|
|
161
|
+
cursor: not-allowed;
|
|
162
|
+
opacity: var(--radio-disabled-opacity);
|
|
163
|
+
|
|
164
|
+
.state-layer {
|
|
165
|
+
display: none;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.label {
|
|
169
|
+
color: var(--color-on-surface);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.outer-circle {
|
|
173
|
+
border-color: var(--color-on-surface);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
&.state-checked {
|
|
177
|
+
.inner-circle {
|
|
178
|
+
background: var(--color-on-surface);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
import { html, LitElement } from 'lit';
|
|
2
|
+
import { property, query, state } from 'lit/decorators.js';
|
|
3
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
4
|
+
import { spread } from '../spread.js';
|
|
5
|
+
import styles from './radio.scss';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @label Radio
|
|
9
|
+
* @tag wc-radio
|
|
10
|
+
* @rawTag radio
|
|
11
|
+
* @summary Allows selection of a single option from a set.
|
|
12
|
+
* @overview
|
|
13
|
+
* <p>Radio buttons follow the Material Design 3 specifications with clear focus, hover, and selected states.</p>
|
|
14
|
+
*
|
|
15
|
+
* @cssprop --radio-size: Size of the outer radio circle.
|
|
16
|
+
* @cssprop --radio-dot-size: Size of the inner dot when selected.
|
|
17
|
+
* @cssprop --radio-selected-color: Color of the radio when selected.
|
|
18
|
+
* @cssprop --radio-unselected-color: Color of the radio outline when unselected.
|
|
19
|
+
* @cssprop --radio-state-layer-size: Size of the state layer for touch target.
|
|
20
|
+
* @cssprop --radio-disabled-opacity: Opacity applied when the radio is disabled.
|
|
21
|
+
*
|
|
22
|
+
* @fires {CustomEvent} change - Dispatched when the radio selection changes.
|
|
23
|
+
* @fires {CustomEvent} blur - Dispatched when the radio loses focus.
|
|
24
|
+
* @fires {CustomEvent} focus - Dispatched when the radio receives focus.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```html
|
|
28
|
+
* <wc-radio name="fruits" value="apple" label="Apple"></wc-radio>
|
|
29
|
+
* ```
|
|
30
|
+
* @tags input, form
|
|
31
|
+
*/
|
|
32
|
+
type RadioDirection = 1 | -1;
|
|
33
|
+
|
|
34
|
+
export class Radio extends LitElement {
|
|
35
|
+
private static readonly DIRECTION_NEXT: RadioDirection = 1;
|
|
36
|
+
private static readonly DIRECTION_PREVIOUS: RadioDirection = -1;
|
|
37
|
+
|
|
38
|
+
static styles = [styles];
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The input field name for grouping radios.
|
|
42
|
+
*/
|
|
43
|
+
@property({ type: String })
|
|
44
|
+
name: string = '';
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The submitted value when this radio is selected.
|
|
48
|
+
*/
|
|
49
|
+
@property({ type: String })
|
|
50
|
+
value: string = '';
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The radio label.
|
|
54
|
+
*/
|
|
55
|
+
@property({ type: String })
|
|
56
|
+
label: string = '';
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Whether the radio is selected.
|
|
60
|
+
*/
|
|
61
|
+
@property({ type: Boolean, reflect: true })
|
|
62
|
+
checked: boolean = false;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* If true, required icon is shown. Defaults to `false`.
|
|
66
|
+
*/
|
|
67
|
+
@property({ type: Boolean, reflect: true })
|
|
68
|
+
required: boolean = false;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* If true, the radio is readonly. Defaults to `false`.
|
|
72
|
+
*/
|
|
73
|
+
@property({ type: Boolean, reflect: true })
|
|
74
|
+
readonly: boolean = false;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* If true, the user cannot interact with the radio. Defaults to `false`.
|
|
78
|
+
*/
|
|
79
|
+
@property({ type: Boolean, reflect: true })
|
|
80
|
+
disabled: boolean = false;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Configuration object for aria attributes.
|
|
84
|
+
*/
|
|
85
|
+
@property({ type: Object })
|
|
86
|
+
configAria: Record<string, string> = {};
|
|
87
|
+
|
|
88
|
+
@state()
|
|
89
|
+
private hasFocus = false;
|
|
90
|
+
|
|
91
|
+
@state()
|
|
92
|
+
private isActive = false;
|
|
93
|
+
|
|
94
|
+
@state()
|
|
95
|
+
private slotHasContent = false;
|
|
96
|
+
|
|
97
|
+
@state()
|
|
98
|
+
private isGroupFocusTarget = false;
|
|
99
|
+
|
|
100
|
+
@query('.container')
|
|
101
|
+
private containerElement?: HTMLElement;
|
|
102
|
+
|
|
103
|
+
@query('.input-native')
|
|
104
|
+
private nativeElement?: HTMLInputElement;
|
|
105
|
+
|
|
106
|
+
private tabindex?: number;
|
|
107
|
+
|
|
108
|
+
connectedCallback() {
|
|
109
|
+
super.connectedCallback();
|
|
110
|
+
this.handleInitialAttributes();
|
|
111
|
+
window.addEventListener('mouseup', this.windowMouseUp);
|
|
112
|
+
window.addEventListener('keyup', this.windowKeyUp);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
disconnectedCallback() {
|
|
116
|
+
super.disconnectedCallback();
|
|
117
|
+
window.removeEventListener('mouseup', this.windowMouseUp);
|
|
118
|
+
window.removeEventListener('keyup', this.windowKeyUp);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
firstUpdated() {
|
|
122
|
+
this.slotHasContent = this.hasChildNodes() || !!this.label;
|
|
123
|
+
this.updateGroupFocusTarget();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
updated(changedProps: Map<string, unknown>) {
|
|
127
|
+
if (changedProps.has('label')) {
|
|
128
|
+
this.slotHasContent = this.hasChildNodes() || !!this.label;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (changedProps.has('checked') && this.checked) {
|
|
132
|
+
this.uncheckSiblings();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (changedProps.has('checked') || changedProps.has('name')) {
|
|
136
|
+
this.updateGroupFocusTarget();
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
private handleInitialAttributes() {
|
|
141
|
+
if (this.hasAttribute('tabindex')) {
|
|
142
|
+
const attrValue = this.getAttribute('tabindex');
|
|
143
|
+
if (attrValue !== null) {
|
|
144
|
+
this.tabindex = parseInt(attrValue, 10);
|
|
145
|
+
}
|
|
146
|
+
this.removeAttribute('tabindex');
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
Array.from(this.attributes).forEach(attr => {
|
|
150
|
+
if (attr.name.startsWith('aria-')) {
|
|
151
|
+
this.configAria[attr.name] = attr.value;
|
|
152
|
+
this.removeAttribute(attr.name);
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
private windowMouseUp = () => {
|
|
158
|
+
if (this.isActive) {
|
|
159
|
+
this.isActive = false;
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
private windowKeyUp = (evt: KeyboardEvent) => {
|
|
164
|
+
if (this.isActive && evt.key === ' ') {
|
|
165
|
+
evt.preventDefault();
|
|
166
|
+
this.isActive = false;
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
private mouseDownHandler = () => {
|
|
171
|
+
this.isActive = true;
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
private keyDownHandler = (evt: KeyboardEvent) => {
|
|
175
|
+
if (evt.key === ' ') {
|
|
176
|
+
evt.preventDefault();
|
|
177
|
+
this.isActive = true;
|
|
178
|
+
this.selectRadio(evt);
|
|
179
|
+
} else if (evt.key === 'ArrowRight' || evt.key === 'ArrowDown') {
|
|
180
|
+
evt.preventDefault();
|
|
181
|
+
this.navigateGroup(Radio.DIRECTION_NEXT);
|
|
182
|
+
} else if (evt.key === 'ArrowLeft' || evt.key === 'ArrowUp') {
|
|
183
|
+
evt.preventDefault();
|
|
184
|
+
this.navigateGroup(Radio.DIRECTION_PREVIOUS);
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
private clickHandler = (ev: MouseEvent | KeyboardEvent) => {
|
|
189
|
+
this.selectRadio(ev);
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
private blurHandler = (ev: FocusEvent) => {
|
|
193
|
+
this.hasFocus = false;
|
|
194
|
+
this.dispatchEvent(
|
|
195
|
+
new CustomEvent('blur', {
|
|
196
|
+
detail: ev,
|
|
197
|
+
bubbles: true,
|
|
198
|
+
composed: true,
|
|
199
|
+
}),
|
|
200
|
+
);
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
private focusHandler = (ev: FocusEvent) => {
|
|
204
|
+
this.hasFocus = true;
|
|
205
|
+
this.dispatchEvent(
|
|
206
|
+
new CustomEvent('focus', {
|
|
207
|
+
detail: ev,
|
|
208
|
+
bubbles: true,
|
|
209
|
+
composed: true,
|
|
210
|
+
}),
|
|
211
|
+
);
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
private selectRadio(ev?: Event) {
|
|
215
|
+
if (this.disabled || this.readonly) return;
|
|
216
|
+
|
|
217
|
+
if (!this.checked) {
|
|
218
|
+
this.checked = true;
|
|
219
|
+
this.uncheckSiblings();
|
|
220
|
+
this.dispatchChange(ev);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
this.containerElement?.focus();
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
private dispatchChange(ev?: Event) {
|
|
227
|
+
this.dispatchEvent(
|
|
228
|
+
new CustomEvent('change', {
|
|
229
|
+
detail: { value: this.value, checked: this.checked, originalEvent: ev },
|
|
230
|
+
bubbles: true,
|
|
231
|
+
composed: true,
|
|
232
|
+
}),
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
private uncheckSiblings() {
|
|
237
|
+
if (!this.name || !this.checked) return;
|
|
238
|
+
const radios = this.getGroupRadios();
|
|
239
|
+
|
|
240
|
+
radios.forEach(radio => {
|
|
241
|
+
if (radio === this) return;
|
|
242
|
+
radio.checked = false;
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
private getGroupRadios(): Radio[] {
|
|
247
|
+
if (!this.name) return [this];
|
|
248
|
+
const scopeRoot = this.closest('form') ?? document;
|
|
249
|
+
return Array.from(
|
|
250
|
+
scopeRoot.querySelectorAll<Radio>(`wc-radio[name="${this.name}"]`),
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
private isRadioEnabled(radio: Radio) {
|
|
255
|
+
return !radio.disabled && !radio.readonly;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
private updateGroupFocusTarget() {
|
|
259
|
+
const group = this.getGroupRadios();
|
|
260
|
+
if (!group.length) return;
|
|
261
|
+
|
|
262
|
+
const enabledGroup = group.filter(radio => this.isRadioEnabled(radio));
|
|
263
|
+
if (!enabledGroup.length) {
|
|
264
|
+
group.forEach(radio => {
|
|
265
|
+
radio.isGroupFocusTarget = false;
|
|
266
|
+
});
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
const target =
|
|
271
|
+
enabledGroup.find(radio => radio.checked) || enabledGroup[0];
|
|
272
|
+
|
|
273
|
+
group.forEach(radio => {
|
|
274
|
+
radio.isGroupFocusTarget = radio === target;
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
private navigateGroup(direction: RadioDirection) {
|
|
279
|
+
const group = this.getGroupRadios().filter(radio =>
|
|
280
|
+
this.isRadioEnabled(radio),
|
|
281
|
+
);
|
|
282
|
+
if (!group.length) return;
|
|
283
|
+
|
|
284
|
+
const currentIndex = group.indexOf(this);
|
|
285
|
+
const startIndex = currentIndex >= 0 ? currentIndex : 0;
|
|
286
|
+
const nextIndex = (startIndex + direction + group.length) % group.length;
|
|
287
|
+
const target = group[nextIndex];
|
|
288
|
+
|
|
289
|
+
target.selectRadio();
|
|
290
|
+
target.containerElement?.focus();
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Sets focus on the radio.
|
|
295
|
+
*/
|
|
296
|
+
focus() {
|
|
297
|
+
this.containerElement?.focus();
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Removes focus from the radio.
|
|
302
|
+
*/
|
|
303
|
+
blur() {
|
|
304
|
+
this.containerElement?.blur();
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
render() {
|
|
308
|
+
const cssClasses = {
|
|
309
|
+
radio: true,
|
|
310
|
+
'state-checked': this.checked,
|
|
311
|
+
'has-focus': this.hasFocus,
|
|
312
|
+
active: this.isActive,
|
|
313
|
+
disabled: this.disabled,
|
|
314
|
+
readonly: this.readonly,
|
|
315
|
+
required: this.required,
|
|
316
|
+
'has-content': this.slotHasContent,
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
return html`
|
|
320
|
+
<label class=${classMap(cssClasses)}>
|
|
321
|
+
<div
|
|
322
|
+
class="container"
|
|
323
|
+
tabindex=${this.isGroupFocusTarget
|
|
324
|
+
? this.tabindex !== undefined
|
|
325
|
+
? this.tabindex
|
|
326
|
+
: 0
|
|
327
|
+
: -1}
|
|
328
|
+
role="radio"
|
|
329
|
+
aria-disabled=${this.disabled}
|
|
330
|
+
aria-required=${this.required}
|
|
331
|
+
aria-checked=${this.checked}
|
|
332
|
+
@click=${this.clickHandler}
|
|
333
|
+
@mousedown=${this.mouseDownHandler}
|
|
334
|
+
@keydown=${this.keyDownHandler}
|
|
335
|
+
@blur=${this.blurHandler}
|
|
336
|
+
@focus=${this.focusHandler}
|
|
337
|
+
${spread(this.configAria)}
|
|
338
|
+
>
|
|
339
|
+
<div class="state-layer"></div>
|
|
340
|
+
<div class="outer-circle"></div>
|
|
341
|
+
<div class="inner-circle"></div>
|
|
342
|
+
</div>
|
|
343
|
+
|
|
344
|
+
<input
|
|
345
|
+
type="radio"
|
|
346
|
+
class="input-native"
|
|
347
|
+
name=${this.name}
|
|
348
|
+
.value=${this.value}
|
|
349
|
+
.checked=${this.checked}
|
|
350
|
+
aria-hidden="true"
|
|
351
|
+
?required=${this.required}
|
|
352
|
+
?disabled=${this.disabled}
|
|
353
|
+
tabindex="-1"
|
|
354
|
+
/>
|
|
355
|
+
|
|
356
|
+
${this.label
|
|
357
|
+
? html`<div class="label">${this.label}</div>`
|
|
358
|
+
: html`<div class="label slot-container"><slot></slot></div>`}
|
|
359
|
+
</label>
|
|
360
|
+
`;
|
|
361
|
+
}
|
|
362
|
+
}
|
package/src/tabs/tab.ts
CHANGED
|
@@ -91,7 +91,7 @@ export class Tab extends LitElement {
|
|
|
91
91
|
this.throttleDelay,
|
|
92
92
|
);
|
|
93
93
|
observerSlotChangesWithCallback(
|
|
94
|
-
this.renderRoot.querySelector('slot'),
|
|
94
|
+
this.renderRoot.querySelector('slot:not([name])'),
|
|
95
95
|
hasContent => {
|
|
96
96
|
this.slotHasContent = hasContent;
|
|
97
97
|
this.requestUpdate();
|