@infineon/infineon-design-system-stencil 30.13.0 → 30.14.0--canary.1702.6f18411c74e90931047649b364aab54e4f74cf6a.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/dist/cjs/ifx-radio-button.cjs.entry.js +70 -33
- package/dist/cjs/ifx-radio-button.cjs.entry.js.map +1 -1
- package/dist/cjs/infineon-design-system-stencil.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/radio-button/radio-button.css +13 -0
- package/dist/collection/components/radio-button/radio-button.js +87 -63
- package/dist/collection/components/radio-button/radio-button.js.map +1 -1
- package/dist/components/ifx-list-entry.js +1 -1
- package/dist/components/ifx-radio-button.js +1 -1
- package/dist/components/p-7bb46b29.js +134 -0
- package/dist/components/p-7bb46b29.js.map +1 -0
- package/dist/esm/ifx-radio-button.entry.js +70 -33
- package/dist/esm/ifx-radio-button.entry.js.map +1 -1
- package/dist/esm/infineon-design-system-stencil.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/infineon-design-system-stencil/infineon-design-system-stencil.esm.js +1 -1
- package/dist/infineon-design-system-stencil/infineon-design-system-stencil.esm.js.map +1 -1
- package/dist/infineon-design-system-stencil/p-94071380.entry.js +2 -0
- package/dist/infineon-design-system-stencil/p-94071380.entry.js.map +1 -0
- package/dist/types/components/radio-button/radio-button.d.ts +9 -19
- package/dist/types/components.d.ts +0 -4
- package/package.json +1 -1
- package/dist/components/p-91f2864c.js +0 -95
- package/dist/components/p-91f2864c.js.map +0 -1
- package/dist/infineon-design-system-stencil/p-fba11471.entry.js +0 -2
- package/dist/infineon-design-system-stencil/p-fba11471.entry.js.map +0 -1
@@ -5,28 +5,52 @@ export class RadioButton {
|
|
5
5
|
this.error = false;
|
6
6
|
this.size = "s";
|
7
7
|
this.internalChecked = false;
|
8
|
-
this.hasSlot =
|
9
|
-
}
|
10
|
-
/**
|
11
|
-
* @returns whether the radio button is checked.
|
12
|
-
*/
|
13
|
-
async isChecked() {
|
14
|
-
return this.internalChecked;
|
8
|
+
this.hasSlot = false;
|
15
9
|
}
|
16
10
|
componentWillLoad() {
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
11
|
+
// Fallback for form association
|
12
|
+
this.fallbackInput = document.createElement('input');
|
13
|
+
this.fallbackInput.type = 'radio';
|
14
|
+
this.fallbackInput.hidden = true;
|
15
|
+
this.fallbackInput.className = '_ifx-radiobutton-fallback';
|
16
|
+
this.fallbackInput.style.cssText = `
|
17
|
+
display: none !important;
|
18
|
+
position: absolute !important;
|
19
|
+
opacity: 0 !important;
|
20
|
+
pointer-events: none !important;
|
21
|
+
width: 0 !important;
|
22
|
+
height: 0 !important;
|
23
|
+
`;
|
24
|
+
this.fallbackInput.setAttribute('aria-hidden', 'true');
|
25
|
+
this.fallbackInput.tabIndex = -1;
|
26
|
+
this.el.appendChild(this.fallbackInput);
|
27
|
+
// Initialize ElementInternals if supported
|
28
|
+
if ('attachInternals' in HTMLElement.prototype) {
|
29
|
+
try {
|
30
|
+
this.internals = this.el.attachInternals();
|
31
|
+
}
|
32
|
+
catch (e) {
|
33
|
+
console.warn('ElementInternals not supported');
|
34
|
+
}
|
22
35
|
}
|
23
|
-
|
24
|
-
|
36
|
+
// Initial state
|
37
|
+
this.internalChecked = this.checked || false;
|
38
|
+
this.hasSlot = !!this.el.querySelector('[slot]') || this.el.innerHTML.trim() !== '';
|
39
|
+
}
|
40
|
+
handleCheckedChange(newValue) {
|
41
|
+
this.internalChecked = newValue;
|
42
|
+
}
|
43
|
+
updateFormValue() {
|
44
|
+
var _a;
|
45
|
+
// Update both ElementInternals and fallback input
|
46
|
+
if ((_a = this.internals) === null || _a === void 0 ? void 0 : _a.setFormValue) {
|
47
|
+
this.internals.setFormValue(this.internalChecked ? this.value : null);
|
48
|
+
}
|
49
|
+
this.fallbackInput.checked = this.internalChecked;
|
50
|
+
this.fallbackInput.name = this.name;
|
51
|
+
this.fallbackInput.value = this.value;
|
52
|
+
this.fallbackInput.disabled = this.disabled;
|
25
53
|
}
|
26
|
-
/**
|
27
|
-
* Click the hidden input element to let it handle the state
|
28
|
-
* and emit ifxChange event.
|
29
|
-
*/
|
30
54
|
handleRadioButtonClick(event) {
|
31
55
|
if (this.disabled) {
|
32
56
|
event.stopPropagation();
|
@@ -34,28 +58,38 @@ export class RadioButton {
|
|
34
58
|
}
|
35
59
|
this.inputElement.click();
|
36
60
|
this.internalChecked = this.inputElement.checked;
|
61
|
+
this.checked = this.internalChecked;
|
37
62
|
this.ifxChange.emit(this.internalChecked);
|
63
|
+
const changeEvent = new CustomEvent('change', {
|
64
|
+
bubbles: true,
|
65
|
+
composed: true,
|
66
|
+
detail: { checked: this.internalChecked }
|
67
|
+
});
|
68
|
+
this.el.dispatchEvent(changeEvent);
|
38
69
|
}
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
handleChange(event) {
|
70
|
+
handleKeyDown(ev) {
|
71
|
+
if ([' ', 'Enter'].includes(ev.key)) {
|
72
|
+
ev.preventDefault();
|
73
|
+
this.handleRadioButtonClick(new PointerEvent('click'));
|
74
|
+
}
|
75
|
+
}
|
76
|
+
handleExternalChange(event) {
|
47
77
|
const target = event.target;
|
48
|
-
if (target
|
49
|
-
|
78
|
+
if (target === this.el || target.tagName.toLowerCase() !== 'ifx-radio-button')
|
79
|
+
return;
|
80
|
+
if (target.getAttribute('name') === this.name) {
|
81
|
+
this.internalChecked = false;
|
50
82
|
}
|
51
83
|
}
|
52
84
|
render() {
|
53
|
-
return (h("div", { key: '
|
54
|
-
|
55
|
-
|
56
|
-
|
85
|
+
return (h("div", { key: '78fb99e348f1f87ff7a51ffba6cdc41e7c0954ed', role: "radio", "aria-checked": String(this.internalChecked), "aria-disabled": String(this.disabled), class: `radioButton__container ${this.size} ${this.disabled ? 'disabled' : ''}`, onClick: (e) => this.handleRadioButtonClick(e), tabindex: this.disabled ? -1 : 0 }, h("div", { key: '064187ce7ca62db30e4f190f8566b06028599981', class: `radioButton__wrapper
|
86
|
+
${this.internalChecked ? 'checked' : ''}
|
87
|
+
${this.disabled ? 'disabled' : ''}
|
88
|
+
${this.error ? 'error' : ''}` }, this.internalChecked && h("div", { key: 'a6993ca1888fc1c5ee41bc481c6ccac9538dbae8', class: "radioButton__wrapper-mark" })), this.hasSlot && (h("div", { key: '530f4ab560e608aabe3f0d91fbf36518c131578a', class: `label ${this.size === "m" ? "label-m" : ""} ${this.disabled ? 'disabled' : ''}` }, h("slot", { key: 'cb4ac01adcb5377cd4c675b90f7ad95a8c318ad2' }))), h("input", { key: 'f4f2118841914a8285728d42b55108c3adbfdaea', type: "radio", hidden: true, ref: el => this.inputElement = el, name: this.name, value: this.value, checked: this.internalChecked, disabled: this.disabled, onClick: (e) => e.stopPropagation() })));
|
57
89
|
}
|
58
90
|
static get is() { return "ifx-radio-button"; }
|
91
|
+
static get encapsulation() { return "shadow"; }
|
92
|
+
static get formAssociated() { return true; }
|
59
93
|
static get originalStyleUrls() {
|
60
94
|
return {
|
61
95
|
"$": ["radio-button.scss"]
|
@@ -144,7 +178,7 @@ export class RadioButton {
|
|
144
178
|
"getter": false,
|
145
179
|
"setter": false,
|
146
180
|
"attribute": "size",
|
147
|
-
"reflect":
|
181
|
+
"reflect": true,
|
148
182
|
"defaultValue": "\"s\""
|
149
183
|
},
|
150
184
|
"name": {
|
@@ -164,11 +198,11 @@ export class RadioButton {
|
|
164
198
|
"getter": false,
|
165
199
|
"setter": false,
|
166
200
|
"attribute": "name",
|
167
|
-
"reflect":
|
201
|
+
"reflect": true
|
168
202
|
},
|
169
203
|
"checked": {
|
170
204
|
"type": "boolean",
|
171
|
-
"mutable":
|
205
|
+
"mutable": true,
|
172
206
|
"complexType": {
|
173
207
|
"original": "boolean",
|
174
208
|
"resolved": "boolean",
|
@@ -190,8 +224,7 @@ export class RadioButton {
|
|
190
224
|
static get states() {
|
191
225
|
return {
|
192
226
|
"internalChecked": {},
|
193
|
-
"hasSlot": {}
|
194
|
-
"inputElement": {}
|
227
|
+
"hasSlot": {}
|
195
228
|
};
|
196
229
|
}
|
197
230
|
static get events() {
|
@@ -212,36 +245,27 @@ export class RadioButton {
|
|
212
245
|
}
|
213
246
|
}];
|
214
247
|
}
|
215
|
-
static get methods() {
|
216
|
-
return {
|
217
|
-
"isChecked": {
|
218
|
-
"complexType": {
|
219
|
-
"signature": "() => Promise<boolean>",
|
220
|
-
"parameters": [],
|
221
|
-
"references": {
|
222
|
-
"Promise": {
|
223
|
-
"location": "global",
|
224
|
-
"id": "global::Promise"
|
225
|
-
}
|
226
|
-
},
|
227
|
-
"return": "Promise<boolean>"
|
228
|
-
},
|
229
|
-
"docs": {
|
230
|
-
"text": "",
|
231
|
-
"tags": [{
|
232
|
-
"name": "returns",
|
233
|
-
"text": "whether the radio button is checked."
|
234
|
-
}]
|
235
|
-
}
|
236
|
-
}
|
237
|
-
};
|
238
|
-
}
|
239
248
|
static get elementRef() { return "el"; }
|
249
|
+
static get watchers() {
|
250
|
+
return [{
|
251
|
+
"propName": "checked",
|
252
|
+
"methodName": "handleCheckedChange"
|
253
|
+
}, {
|
254
|
+
"propName": "internalChecked",
|
255
|
+
"methodName": "updateFormValue"
|
256
|
+
}];
|
257
|
+
}
|
240
258
|
static get listeners() {
|
241
259
|
return [{
|
260
|
+
"name": "keydown",
|
261
|
+
"method": "handleKeyDown",
|
262
|
+
"target": undefined,
|
263
|
+
"capture": false,
|
264
|
+
"passive": false
|
265
|
+
}, {
|
242
266
|
"name": "change",
|
243
|
-
"method": "
|
244
|
-
"target": "
|
267
|
+
"method": "handleExternalChange",
|
268
|
+
"target": "document",
|
245
269
|
"capture": false,
|
246
270
|
"passive": false
|
247
271
|
}];
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"radio-button.js","sourceRoot":"","sources":["../../../src/components/radio-button/radio-button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC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;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, h, Prop, Element, State, Event, EventEmitter, Listen, Watch } from '@stencil/core';\n\n@Component({\n tag: 'ifx-radio-button',\n styleUrl: 'radio-button.scss',\n shadow: true,\n formAssociated: true\n})\nexport class RadioButton {\n @Element() el: HTMLElement;\n @Prop() disabled: boolean = false;\n @Prop() value: string;\n @Prop() error: boolean = false;\n @Prop({ reflect: true }) size: \"s\" | \"m\" = \"s\";\n @Prop({ reflect: true }) name: string;\n @Prop({ mutable: true }) checked: boolean;\n @State() internalChecked: boolean = false;\n @State() hasSlot: boolean = false;\n\n private inputElement: HTMLInputElement;\n private internals: ElementInternals;\n private fallbackInput: HTMLInputElement;\n\n @Event({ eventName: 'ifxChange' }) ifxChange: EventEmitter;\n\n componentWillLoad() {\n // Fallback for form association\n this.fallbackInput = document.createElement('input');\n this.fallbackInput.type = 'radio';\n this.fallbackInput.hidden = true;\n this.fallbackInput.className = '_ifx-radiobutton-fallback';\n this.fallbackInput.style.cssText = `\n display: none !important;\n position: absolute !important;\n opacity: 0 !important;\n pointer-events: none !important;\n width: 0 !important;\n height: 0 !important;\n `;\n this.fallbackInput.setAttribute('aria-hidden', 'true');\n this.fallbackInput.tabIndex = -1;\n this.el.appendChild(this.fallbackInput);\n\n // Initialize ElementInternals if supported\n if ('attachInternals' in HTMLElement.prototype) {\n try {\n this.internals = this.el.attachInternals();\n } catch (e) {\n console.warn('ElementInternals not supported');\n }\n }\n\n // Initial state\n this.internalChecked = this.checked || false;\n this.hasSlot = !!this.el.querySelector('[slot]') || this.el.innerHTML.trim() !== '';\n }\n\n @Watch('checked')\n handleCheckedChange(newValue: boolean) {\n this.internalChecked = newValue;\n }\n\n @Watch('internalChecked')\n updateFormValue() {\n // Update both ElementInternals and fallback input\n if (this.internals?.setFormValue) {\n this.internals.setFormValue(this.internalChecked ? this.value : null);\n }\n this.fallbackInput.checked = this.internalChecked;\n this.fallbackInput.name = this.name;\n this.fallbackInput.value = this.value;\n this.fallbackInput.disabled = this.disabled;\n }\n\n handleRadioButtonClick(event: Event) {\n if (this.disabled) {\n event.stopPropagation();\n return;\n }\n\n this.inputElement.click();\n this.internalChecked = this.inputElement.checked;\n this.checked = this.internalChecked;\n this.ifxChange.emit(this.internalChecked);\n\n const changeEvent = new CustomEvent('change', {\n bubbles: true,\n composed: true,\n detail: { checked: this.internalChecked }\n });\n this.el.dispatchEvent(changeEvent);\n }\n\n @Listen('keydown')\n handleKeyDown(ev: KeyboardEvent) {\n if ([' ', 'Enter'].includes(ev.key)) {\n ev.preventDefault();\n this.handleRadioButtonClick(new PointerEvent('click'));\n }\n }\n\n @Listen('change', { target: 'document' })\n handleExternalChange(event: Event) {\n const target = event.target as HTMLElement;\n if (target === this.el || target.tagName.toLowerCase() !== 'ifx-radio-button') return;\n \n if (target.getAttribute('name') === this.name) {\n this.internalChecked = false;\n }\n }\n\n render() {\n return (\n <div\n role=\"radio\"\n aria-checked={String(this.internalChecked)}\n aria-disabled={String(this.disabled)}\n class={`radioButton__container ${this.size} ${this.disabled ? 'disabled' : ''}`}\n onClick={(e) => this.handleRadioButtonClick(e)}\n tabindex={this.disabled ? -1 : 0}\n >\n <div\n class={`radioButton__wrapper \n ${this.internalChecked ? 'checked' : ''} \n ${this.disabled ? 'disabled' : ''} \n ${this.error ? 'error' : ''}`}\n >\n {this.internalChecked && <div class=\"radioButton__wrapper-mark\"></div>}\n </div>\n\n {this.hasSlot && (\n <div class={`label ${this.size === \"m\" ? \"label-m\" : \"\"} ${this.disabled ? 'disabled' : ''}`}>\n <slot />\n </div>\n )}\n\n <input\n type=\"radio\"\n hidden\n ref={el => this.inputElement = el}\n name={this.name}\n value={this.value}\n checked={this.internalChecked}\n disabled={this.disabled}\n onClick={(e) => e.stopPropagation()}\n />\n </div>\n );\n }\n}"]}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { p as proxyCustomElement, H, c as createEvent, h } from './p-3ee20ed5.js';
|
2
2
|
import { d as defineCustomElement$4 } from './p-6fd6d1a9.js';
|
3
3
|
import { d as defineCustomElement$3 } from './p-828bbb25.js';
|
4
|
-
import { d as defineCustomElement$2 } from './p-
|
4
|
+
import { d as defineCustomElement$2 } from './p-7bb46b29.js';
|
5
5
|
|
6
6
|
const listEntryCss = ".list-entry{display:flex;align-items:center;margin-top:8px;align-self:stretch}";
|
7
7
|
const IfxListEntryStyle0 = listEntryCss;
|
@@ -0,0 +1,134 @@
|
|
1
|
+
import { p as proxyCustomElement, H, c as createEvent, h } from './p-3ee20ed5.js';
|
2
|
+
|
3
|
+
const radioButtonCss = ":root{--ifx-font-family:\"Source Sans 3\";font-family:var(--ifx-font-family, sans-serif)}:host{display:inline-flex;--_ifx-fallback-display:none !important}._ifx-radiobutton-fallback{display:var(--_ifx-fallback-display);position:absolute !important;width:1px !important;height:1px !important;padding:0 !important;margin:-1px !important;overflow:hidden !important;clip:rect(0, 0, 0, 0) !important;border:0 !important}.radioButton__container{box-sizing:border-box;display:inline-flex;flex-direction:row;align-items:center;padding:0px;gap:8px;cursor:pointer;font-family:var(--ifx-font-family)}.radioButton__container.m .radioButton__wrapper{width:24px;height:24px}.radioButton__container .radioButton__wrapper{width:20px;height:20px;position:relative;display:block;border-radius:50%;background-color:#FFFFFF;border:1px solid #575352}.radioButton__container .radioButton__wrapper:focus{outline:none}.radioButton__container .radioButton__wrapper:focus::before{content:\"\";position:absolute;width:calc(100% + 4px);height:calc(100% + 4px);top:50%;left:50%;transform:translate(-50%, -50%);border:2px solid #0A8276;border-radius:50%}.radioButton__container .radioButton__wrapper .radioButton__wrapper-mark{position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);background-color:#0A8276;border-radius:50%;display:flex;justify-content:center;align-items:center;border-color:transparent}.radioButton__container .radioButton__wrapper:hover{background-color:#EEEDED}.radioButton__container .radioButton__wrapper.disabled{background-color:#BFBBBB;border-color:#BFBBBB}.radioButton__container .radioButton__wrapper.disabled.error:hover,.radioButton__container .radioButton__wrapper.disabled.error:focus-visible{border-color:#CD002F}.radioButton__container .radioButton__wrapper.checked{border-color:#0A8276}.radioButton__container .radioButton__wrapper.checked::after{content:\"\";position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);width:10px;height:10px;background-color:#0A8276;border-radius:50%}.radioButton__container .radioButton__wrapper.checked.disabled::after{background-color:#BFBBBB}.radioButton__container .radioButton__wrapper.checked:hover{border-color:#08665C}.radioButton__container .radioButton__wrapper.checked:hover .radioButton__wrapper-mark{background-color:#08665C}.radioButton__container .radioButton__wrapper.checked.disabled{background-color:#FFFFFF;border-color:#BFBBBB}.radioButton__container .radioButton__wrapper.checked.disabled.disabled::after{background-color:#BFBBBB}.radioButton__container .radioButton__wrapper.checked.disabled .radioButton__wrapper-mark{background-color:#BFBBBB}.radioButton__container .radioButton__wrapper.error:not(.disabled){border-color:#CD002F}.radioButton__container .radioButton__wrapper.error:not(.disabled):hover,.radioButton__container .radioButton__wrapper.error:not(.disabled):focus-visible{border-color:#CD002F}.radioButton__container .label{display:flex;align-items:center;height:20px;font-style:normal;font-weight:400;font-size:0.875rem;line-height:1.25rem;color:#1D1D1D;flex:none;order:1;flex-grow:0}.radioButton__container .label.label-m{height:24px;font-size:1rem;line-height:1.5rem}.radioButton__container .label.disabled{color:#BFBBBB}.radioButton__container .label:hover{cursor:pointer}";
|
4
|
+
const IfxRadioButtonStyle0 = radioButtonCss;
|
5
|
+
|
6
|
+
const RadioButton = /*@__PURE__*/ proxyCustomElement(class RadioButton extends H {
|
7
|
+
constructor() {
|
8
|
+
super();
|
9
|
+
this.__registerHost();
|
10
|
+
this.__attachShadow();
|
11
|
+
this.ifxChange = createEvent(this, "ifxChange", 7);
|
12
|
+
this.disabled = false;
|
13
|
+
this.error = false;
|
14
|
+
this.size = "s";
|
15
|
+
this.internalChecked = false;
|
16
|
+
this.hasSlot = false;
|
17
|
+
}
|
18
|
+
componentWillLoad() {
|
19
|
+
// Fallback for form association
|
20
|
+
this.fallbackInput = document.createElement('input');
|
21
|
+
this.fallbackInput.type = 'radio';
|
22
|
+
this.fallbackInput.hidden = true;
|
23
|
+
this.fallbackInput.className = '_ifx-radiobutton-fallback';
|
24
|
+
this.fallbackInput.style.cssText = `
|
25
|
+
display: none !important;
|
26
|
+
position: absolute !important;
|
27
|
+
opacity: 0 !important;
|
28
|
+
pointer-events: none !important;
|
29
|
+
width: 0 !important;
|
30
|
+
height: 0 !important;
|
31
|
+
`;
|
32
|
+
this.fallbackInput.setAttribute('aria-hidden', 'true');
|
33
|
+
this.fallbackInput.tabIndex = -1;
|
34
|
+
this.el.appendChild(this.fallbackInput);
|
35
|
+
// Initialize ElementInternals if supported
|
36
|
+
if ('attachInternals' in H.prototype) {
|
37
|
+
try {
|
38
|
+
this.internals = this.el.attachInternals();
|
39
|
+
}
|
40
|
+
catch (e) {
|
41
|
+
console.warn('ElementInternals not supported');
|
42
|
+
}
|
43
|
+
}
|
44
|
+
// Initial state
|
45
|
+
this.internalChecked = this.checked || false;
|
46
|
+
this.hasSlot = !!this.el.querySelector('[slot]') || this.el.innerHTML.trim() !== '';
|
47
|
+
}
|
48
|
+
handleCheckedChange(newValue) {
|
49
|
+
this.internalChecked = newValue;
|
50
|
+
}
|
51
|
+
updateFormValue() {
|
52
|
+
var _a;
|
53
|
+
// Update both ElementInternals and fallback input
|
54
|
+
if ((_a = this.internals) === null || _a === void 0 ? void 0 : _a.setFormValue) {
|
55
|
+
this.internals.setFormValue(this.internalChecked ? this.value : null);
|
56
|
+
}
|
57
|
+
this.fallbackInput.checked = this.internalChecked;
|
58
|
+
this.fallbackInput.name = this.name;
|
59
|
+
this.fallbackInput.value = this.value;
|
60
|
+
this.fallbackInput.disabled = this.disabled;
|
61
|
+
}
|
62
|
+
handleRadioButtonClick(event) {
|
63
|
+
if (this.disabled) {
|
64
|
+
event.stopPropagation();
|
65
|
+
return;
|
66
|
+
}
|
67
|
+
this.inputElement.click();
|
68
|
+
this.internalChecked = this.inputElement.checked;
|
69
|
+
this.checked = this.internalChecked;
|
70
|
+
this.ifxChange.emit(this.internalChecked);
|
71
|
+
const changeEvent = new CustomEvent('change', {
|
72
|
+
bubbles: true,
|
73
|
+
composed: true,
|
74
|
+
detail: { checked: this.internalChecked }
|
75
|
+
});
|
76
|
+
this.el.dispatchEvent(changeEvent);
|
77
|
+
}
|
78
|
+
handleKeyDown(ev) {
|
79
|
+
if ([' ', 'Enter'].includes(ev.key)) {
|
80
|
+
ev.preventDefault();
|
81
|
+
this.handleRadioButtonClick(new PointerEvent('click'));
|
82
|
+
}
|
83
|
+
}
|
84
|
+
handleExternalChange(event) {
|
85
|
+
const target = event.target;
|
86
|
+
if (target === this.el || target.tagName.toLowerCase() !== 'ifx-radio-button')
|
87
|
+
return;
|
88
|
+
if (target.getAttribute('name') === this.name) {
|
89
|
+
this.internalChecked = false;
|
90
|
+
}
|
91
|
+
}
|
92
|
+
render() {
|
93
|
+
return (h("div", { key: '78fb99e348f1f87ff7a51ffba6cdc41e7c0954ed', role: "radio", "aria-checked": String(this.internalChecked), "aria-disabled": String(this.disabled), class: `radioButton__container ${this.size} ${this.disabled ? 'disabled' : ''}`, onClick: (e) => this.handleRadioButtonClick(e), tabindex: this.disabled ? -1 : 0 }, h("div", { key: '064187ce7ca62db30e4f190f8566b06028599981', class: `radioButton__wrapper
|
94
|
+
${this.internalChecked ? 'checked' : ''}
|
95
|
+
${this.disabled ? 'disabled' : ''}
|
96
|
+
${this.error ? 'error' : ''}` }, this.internalChecked && h("div", { key: 'a6993ca1888fc1c5ee41bc481c6ccac9538dbae8', class: "radioButton__wrapper-mark" })), this.hasSlot && (h("div", { key: '530f4ab560e608aabe3f0d91fbf36518c131578a', class: `label ${this.size === "m" ? "label-m" : ""} ${this.disabled ? 'disabled' : ''}` }, h("slot", { key: 'cb4ac01adcb5377cd4c675b90f7ad95a8c318ad2' }))), h("input", { key: 'f4f2118841914a8285728d42b55108c3adbfdaea', type: "radio", hidden: true, ref: el => this.inputElement = el, name: this.name, value: this.value, checked: this.internalChecked, disabled: this.disabled, onClick: (e) => e.stopPropagation() })));
|
97
|
+
}
|
98
|
+
static get formAssociated() { return true; }
|
99
|
+
get el() { return this; }
|
100
|
+
static get watchers() { return {
|
101
|
+
"checked": ["handleCheckedChange"],
|
102
|
+
"internalChecked": ["updateFormValue"]
|
103
|
+
}; }
|
104
|
+
static get style() { return IfxRadioButtonStyle0; }
|
105
|
+
}, [65, "ifx-radio-button", {
|
106
|
+
"disabled": [4],
|
107
|
+
"value": [1],
|
108
|
+
"error": [4],
|
109
|
+
"size": [513],
|
110
|
+
"name": [513],
|
111
|
+
"checked": [1028],
|
112
|
+
"internalChecked": [32],
|
113
|
+
"hasSlot": [32]
|
114
|
+
}, [[0, "keydown", "handleKeyDown"], [4, "change", "handleExternalChange"]], {
|
115
|
+
"checked": ["handleCheckedChange"],
|
116
|
+
"internalChecked": ["updateFormValue"]
|
117
|
+
}]);
|
118
|
+
function defineCustomElement() {
|
119
|
+
if (typeof customElements === "undefined") {
|
120
|
+
return;
|
121
|
+
}
|
122
|
+
const components = ["ifx-radio-button"];
|
123
|
+
components.forEach(tagName => { switch (tagName) {
|
124
|
+
case "ifx-radio-button":
|
125
|
+
if (!customElements.get(tagName)) {
|
126
|
+
customElements.define(tagName, RadioButton);
|
127
|
+
}
|
128
|
+
break;
|
129
|
+
} });
|
130
|
+
}
|
131
|
+
|
132
|
+
export { RadioButton as R, defineCustomElement as d };
|
133
|
+
|
134
|
+
//# sourceMappingURL=p-7bb46b29.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"file":"p-7bb46b29.js","mappings":";;AAAA,MAAM,cAAc,GAAG,0sGAA0sG,CAAC;AACluG,6BAAe,cAAc;;MCOhB,WAAW;IANxB;;;;;QAQU,aAAQ,GAAY,KAAK,CAAC;QAE1B,UAAK,GAAY,KAAK,CAAC;QACN,SAAI,GAAc,GAAG,CAAC;QAGtC,oBAAe,GAAY,KAAK,CAAC;QACjC,YAAO,GAAY,KAAK,CAAC;KAoInC;IA5HC,iBAAiB;;QAEf,IAA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AC,eAAe,EAC7B,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,eAAe,EAAE,GACnC,CACE,EACN;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["HTMLElement"],"sources":["src/components/radio-button/radio-button.scss?tag=ifx-radio-button&encapsulation=shadow","src/components/radio-button/radio-button.tsx"],"sourcesContent":["@use \"~@infineon/design-system-tokens/dist/tokens\";\n@use \"../../global/font.scss\";\n\n:host {\n display: inline-flex;\n --_ifx-fallback-display: none !important;\n}\n\n._ifx-radiobutton-fallback {\n display: var(--_ifx-fallback-display);\n position: absolute !important;\n width: 1px !important;\n height: 1px !important;\n padding: 0 !important;\n margin: -1px !important;\n overflow: hidden !important;\n clip: rect(0,0,0,0) !important;\n border: 0 !important;\n }\n\n.radioButton__container {\n box-sizing: border-box;\n display: inline-flex;\n flex-direction: row;\n align-items: center;\n padding: 0px;\n gap: tokens.$ifxSpace100;\n cursor: pointer;\n font-family: var(--ifx-font-family);\n\n &.m .radioButton__wrapper {\n width: tokens.$ifxSize300;\n height: tokens.$ifxSize300;\n }\n\n .radioButton__wrapper {\n width: tokens.$ifxSize250;\n height: tokens.$ifxSize250;\n position: relative;\n display: block;\n border-radius: 50%;\n background-color: tokens.$ifxColorBaseWhite;\n border: 1px solid #575352;\n\n &:focus {\n outline: none;\n\n &::before {\n content: '';\n position: absolute;\n width: calc(100% + 4px);\n height: calc(100% + 4px);\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n border: 2px solid tokens.$ifxColorOcean500;\n border-radius: 50%;\n }\n }\n\n .radioButton__wrapper-mark {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n background-color: #0A8276;\n border-radius: 50%;\n display: flex;\n justify-content: center;\n align-items: center;\n border-color: tokens.$ifxColorBaseTransparent;\n }\n\n &:hover {\n background-color: tokens.$ifxColorEngineering200;\n }\n\n &.disabled {\n background-color: #BFBBBB;\n border-color: #BFBBBB;\n\n &.error {\n\n &:hover,\n &:focus-visible {\n border-color: #CD002F;\n }\n }\n }\n\n &.checked {\n border-color: #0A8276;\n\n &::after {\n content: \"\";\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n width: 10px;\n height: 10px;\n background-color: #0A8276;\n border-radius: 50%;\n }\n\n &.disabled::after {\n background-color: #BFBBBB;\n }\n\n\n &:hover {\n border-color: tokens.$ifxColorOcean600;\n\n & .radioButton__wrapper-mark {\n background-color: tokens.$ifxColorOcean600;\n }\n }\n\n &.disabled {\n background-color: tokens.$ifxColorBaseWhite;\n border-color: #BFBBBB;\n\n &.disabled::after {\n background-color: #BFBBBB;\n }\n\n & .radioButton__wrapper-mark {\n background-color: #BFBBBB;\n }\n }\n }\n\n &.error:not(.disabled) {\n border-color: #CD002F;\n\n &:hover,\n &:focus-visible {\n border-color: #CD002F;\n }\n }\n }\n\n .label {\n display: flex;\n align-items: center;\n height: tokens.$ifxSize250;\n font-style: normal;\n font-weight: 400;\n font-size: tokens.$ifxFontSizeS;\n line-height: tokens.$ifxLineHeightS;\n color: tokens.$ifxColorBaseBlack;\n flex: none;\n order: 1;\n flex-grow: 0;\n\n &.label-m {\n height: tokens.$ifxSize300;\n font-size: tokens.$ifxFontSizeM;\n line-height: tokens.$ifxLineHeightM;\n }\n\n &.disabled {\n color: #BFBBBB;\n }\n\n\n\n &:hover {\n cursor: pointer;\n }\n }\n}\n\n","import { Component, h, Prop, Element, State, Event, EventEmitter, Listen, Watch } from '@stencil/core';\n\n@Component({\n tag: 'ifx-radio-button',\n styleUrl: 'radio-button.scss',\n shadow: true,\n formAssociated: true\n})\nexport class RadioButton {\n @Element() el: HTMLElement;\n @Prop() disabled: boolean = false;\n @Prop() value: string;\n @Prop() error: boolean = false;\n @Prop({ reflect: true }) size: \"s\" | \"m\" = \"s\";\n @Prop({ reflect: true }) name: string;\n @Prop({ mutable: true }) checked: boolean;\n @State() internalChecked: boolean = false;\n @State() hasSlot: boolean = false;\n\n private inputElement: HTMLInputElement;\n private internals: ElementInternals;\n private fallbackInput: HTMLInputElement;\n\n @Event({ eventName: 'ifxChange' }) ifxChange: EventEmitter;\n\n componentWillLoad() {\n // Fallback for form association\n this.fallbackInput = document.createElement('input');\n this.fallbackInput.type = 'radio';\n this.fallbackInput.hidden = true;\n this.fallbackInput.className = '_ifx-radiobutton-fallback';\n this.fallbackInput.style.cssText = `\n display: none !important;\n position: absolute !important;\n opacity: 0 !important;\n pointer-events: none !important;\n width: 0 !important;\n height: 0 !important;\n `;\n this.fallbackInput.setAttribute('aria-hidden', 'true');\n this.fallbackInput.tabIndex = -1;\n this.el.appendChild(this.fallbackInput);\n\n // Initialize ElementInternals if supported\n if ('attachInternals' in HTMLElement.prototype) {\n try {\n this.internals = this.el.attachInternals();\n } catch (e) {\n console.warn('ElementInternals not supported');\n }\n }\n\n // Initial state\n this.internalChecked = this.checked || false;\n this.hasSlot = !!this.el.querySelector('[slot]') || this.el.innerHTML.trim() !== '';\n }\n\n @Watch('checked')\n handleCheckedChange(newValue: boolean) {\n this.internalChecked = newValue;\n }\n\n @Watch('internalChecked')\n updateFormValue() {\n // Update both ElementInternals and fallback input\n if (this.internals?.setFormValue) {\n this.internals.setFormValue(this.internalChecked ? this.value : null);\n }\n this.fallbackInput.checked = this.internalChecked;\n this.fallbackInput.name = this.name;\n this.fallbackInput.value = this.value;\n this.fallbackInput.disabled = this.disabled;\n }\n\n handleRadioButtonClick(event: Event) {\n if (this.disabled) {\n event.stopPropagation();\n return;\n }\n\n this.inputElement.click();\n this.internalChecked = this.inputElement.checked;\n this.checked = this.internalChecked;\n this.ifxChange.emit(this.internalChecked);\n\n const changeEvent = new CustomEvent('change', {\n bubbles: true,\n composed: true,\n detail: { checked: this.internalChecked }\n });\n this.el.dispatchEvent(changeEvent);\n }\n\n @Listen('keydown')\n handleKeyDown(ev: KeyboardEvent) {\n if ([' ', 'Enter'].includes(ev.key)) {\n ev.preventDefault();\n this.handleRadioButtonClick(new PointerEvent('click'));\n }\n }\n\n @Listen('change', { target: 'document' })\n handleExternalChange(event: Event) {\n const target = event.target as HTMLElement;\n if (target === this.el || target.tagName.toLowerCase() !== 'ifx-radio-button') return;\n \n if (target.getAttribute('name') === this.name) {\n this.internalChecked = false;\n }\n }\n\n render() {\n return (\n <div\n role=\"radio\"\n aria-checked={String(this.internalChecked)}\n aria-disabled={String(this.disabled)}\n class={`radioButton__container ${this.size} ${this.disabled ? 'disabled' : ''}`}\n onClick={(e) => this.handleRadioButtonClick(e)}\n tabindex={this.disabled ? -1 : 0}\n >\n <div\n class={`radioButton__wrapper \n ${this.internalChecked ? 'checked' : ''} \n ${this.disabled ? 'disabled' : ''} \n ${this.error ? 'error' : ''}`}\n >\n {this.internalChecked && <div class=\"radioButton__wrapper-mark\"></div>}\n </div>\n\n {this.hasSlot && (\n <div class={`label ${this.size === \"m\" ? \"label-m\" : \"\"} ${this.disabled ? 'disabled' : ''}`}>\n <slot />\n </div>\n )}\n\n <input\n type=\"radio\"\n hidden\n ref={el => this.inputElement = el}\n name={this.name}\n value={this.value}\n checked={this.internalChecked}\n disabled={this.disabled}\n onClick={(e) => e.stopPropagation()}\n />\n </div>\n );\n }\n}"],"version":3}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { r as registerInstance, c as createEvent, h, g as getElement } from './index-f6e95f3d.js';
|
2
2
|
|
3
|
-
const radioButtonCss = ":root{--ifx-font-family:\"Source Sans 3\";font-family:var(--ifx-font-family, sans-serif)}:host{display:inline-flex}.radioButton__container{box-sizing:border-box;display:inline-flex;flex-direction:row;align-items:center;padding:0px;gap:8px;cursor:pointer;font-family:var(--ifx-font-family)}.radioButton__container.m .radioButton__wrapper{width:24px;height:24px}.radioButton__container .radioButton__wrapper{width:20px;height:20px;position:relative;display:block;border-radius:50%;background-color:#FFFFFF;border:1px solid #575352}.radioButton__container .radioButton__wrapper:focus{outline:none}.radioButton__container .radioButton__wrapper:focus::before{content:\"\";position:absolute;width:calc(100% + 4px);height:calc(100% + 4px);top:50%;left:50%;transform:translate(-50%, -50%);border:2px solid #0A8276;border-radius:50%}.radioButton__container .radioButton__wrapper .radioButton__wrapper-mark{position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);background-color:#0A8276;border-radius:50%;display:flex;justify-content:center;align-items:center;border-color:transparent}.radioButton__container .radioButton__wrapper:hover{background-color:#EEEDED}.radioButton__container .radioButton__wrapper.disabled{background-color:#BFBBBB;border-color:#BFBBBB}.radioButton__container .radioButton__wrapper.disabled.error:hover,.radioButton__container .radioButton__wrapper.disabled.error:focus-visible{border-color:#CD002F}.radioButton__container .radioButton__wrapper.checked{border-color:#0A8276}.radioButton__container .radioButton__wrapper.checked::after{content:\"\";position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);width:10px;height:10px;background-color:#0A8276;border-radius:50%}.radioButton__container .radioButton__wrapper.checked.disabled::after{background-color:#BFBBBB}.radioButton__container .radioButton__wrapper.checked:hover{border-color:#08665C}.radioButton__container .radioButton__wrapper.checked:hover .radioButton__wrapper-mark{background-color:#08665C}.radioButton__container .radioButton__wrapper.checked.disabled{background-color:#FFFFFF;border-color:#BFBBBB}.radioButton__container .radioButton__wrapper.checked.disabled.disabled::after{background-color:#BFBBBB}.radioButton__container .radioButton__wrapper.checked.disabled .radioButton__wrapper-mark{background-color:#BFBBBB}.radioButton__container .radioButton__wrapper.error:not(.disabled){border-color:#CD002F}.radioButton__container .radioButton__wrapper.error:not(.disabled):hover,.radioButton__container .radioButton__wrapper.error:not(.disabled):focus-visible{border-color:#CD002F}.radioButton__container .label{display:flex;align-items:center;height:20px;font-style:normal;font-weight:400;font-size:0.875rem;line-height:1.25rem;color:#1D1D1D;flex:none;order:1;flex-grow:0}.radioButton__container .label.label-m{height:24px;font-size:1rem;line-height:1.5rem}.radioButton__container .label.disabled{color:#BFBBBB}.radioButton__container .label:hover{cursor:pointer}";
|
3
|
+
const radioButtonCss = ":root{--ifx-font-family:\"Source Sans 3\";font-family:var(--ifx-font-family, sans-serif)}:host{display:inline-flex;--_ifx-fallback-display:none !important}._ifx-radiobutton-fallback{display:var(--_ifx-fallback-display);position:absolute !important;width:1px !important;height:1px !important;padding:0 !important;margin:-1px !important;overflow:hidden !important;clip:rect(0, 0, 0, 0) !important;border:0 !important}.radioButton__container{box-sizing:border-box;display:inline-flex;flex-direction:row;align-items:center;padding:0px;gap:8px;cursor:pointer;font-family:var(--ifx-font-family)}.radioButton__container.m .radioButton__wrapper{width:24px;height:24px}.radioButton__container .radioButton__wrapper{width:20px;height:20px;position:relative;display:block;border-radius:50%;background-color:#FFFFFF;border:1px solid #575352}.radioButton__container .radioButton__wrapper:focus{outline:none}.radioButton__container .radioButton__wrapper:focus::before{content:\"\";position:absolute;width:calc(100% + 4px);height:calc(100% + 4px);top:50%;left:50%;transform:translate(-50%, -50%);border:2px solid #0A8276;border-radius:50%}.radioButton__container .radioButton__wrapper .radioButton__wrapper-mark{position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);background-color:#0A8276;border-radius:50%;display:flex;justify-content:center;align-items:center;border-color:transparent}.radioButton__container .radioButton__wrapper:hover{background-color:#EEEDED}.radioButton__container .radioButton__wrapper.disabled{background-color:#BFBBBB;border-color:#BFBBBB}.radioButton__container .radioButton__wrapper.disabled.error:hover,.radioButton__container .radioButton__wrapper.disabled.error:focus-visible{border-color:#CD002F}.radioButton__container .radioButton__wrapper.checked{border-color:#0A8276}.radioButton__container .radioButton__wrapper.checked::after{content:\"\";position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);width:10px;height:10px;background-color:#0A8276;border-radius:50%}.radioButton__container .radioButton__wrapper.checked.disabled::after{background-color:#BFBBBB}.radioButton__container .radioButton__wrapper.checked:hover{border-color:#08665C}.radioButton__container .radioButton__wrapper.checked:hover .radioButton__wrapper-mark{background-color:#08665C}.radioButton__container .radioButton__wrapper.checked.disabled{background-color:#FFFFFF;border-color:#BFBBBB}.radioButton__container .radioButton__wrapper.checked.disabled.disabled::after{background-color:#BFBBBB}.radioButton__container .radioButton__wrapper.checked.disabled .radioButton__wrapper-mark{background-color:#BFBBBB}.radioButton__container .radioButton__wrapper.error:not(.disabled){border-color:#CD002F}.radioButton__container .radioButton__wrapper.error:not(.disabled):hover,.radioButton__container .radioButton__wrapper.error:not(.disabled):focus-visible{border-color:#CD002F}.radioButton__container .label{display:flex;align-items:center;height:20px;font-style:normal;font-weight:400;font-size:0.875rem;line-height:1.25rem;color:#1D1D1D;flex:none;order:1;flex-grow:0}.radioButton__container .label.label-m{height:24px;font-size:1rem;line-height:1.5rem}.radioButton__container .label.disabled{color:#BFBBBB}.radioButton__container .label:hover{cursor:pointer}";
|
4
4
|
const IfxRadioButtonStyle0 = radioButtonCss;
|
5
5
|
|
6
6
|
const RadioButton = class {
|
@@ -11,28 +11,52 @@ const RadioButton = class {
|
|
11
11
|
this.error = false;
|
12
12
|
this.size = "s";
|
13
13
|
this.internalChecked = false;
|
14
|
-
this.hasSlot =
|
15
|
-
}
|
16
|
-
/**
|
17
|
-
* @returns whether the radio button is checked.
|
18
|
-
*/
|
19
|
-
async isChecked() {
|
20
|
-
return this.internalChecked;
|
14
|
+
this.hasSlot = false;
|
21
15
|
}
|
22
16
|
componentWillLoad() {
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
17
|
+
// Fallback for form association
|
18
|
+
this.fallbackInput = document.createElement('input');
|
19
|
+
this.fallbackInput.type = 'radio';
|
20
|
+
this.fallbackInput.hidden = true;
|
21
|
+
this.fallbackInput.className = '_ifx-radiobutton-fallback';
|
22
|
+
this.fallbackInput.style.cssText = `
|
23
|
+
display: none !important;
|
24
|
+
position: absolute !important;
|
25
|
+
opacity: 0 !important;
|
26
|
+
pointer-events: none !important;
|
27
|
+
width: 0 !important;
|
28
|
+
height: 0 !important;
|
29
|
+
`;
|
30
|
+
this.fallbackInput.setAttribute('aria-hidden', 'true');
|
31
|
+
this.fallbackInput.tabIndex = -1;
|
32
|
+
this.el.appendChild(this.fallbackInput);
|
33
|
+
// Initialize ElementInternals if supported
|
34
|
+
if ('attachInternals' in HTMLElement.prototype) {
|
35
|
+
try {
|
36
|
+
this.internals = this.el.attachInternals();
|
37
|
+
}
|
38
|
+
catch (e) {
|
39
|
+
console.warn('ElementInternals not supported');
|
40
|
+
}
|
41
|
+
}
|
42
|
+
// Initial state
|
43
|
+
this.internalChecked = this.checked || false;
|
44
|
+
this.hasSlot = !!this.el.querySelector('[slot]') || this.el.innerHTML.trim() !== '';
|
45
|
+
}
|
46
|
+
handleCheckedChange(newValue) {
|
47
|
+
this.internalChecked = newValue;
|
48
|
+
}
|
49
|
+
updateFormValue() {
|
50
|
+
var _a;
|
51
|
+
// Update both ElementInternals and fallback input
|
52
|
+
if ((_a = this.internals) === null || _a === void 0 ? void 0 : _a.setFormValue) {
|
53
|
+
this.internals.setFormValue(this.internalChecked ? this.value : null);
|
28
54
|
}
|
29
|
-
|
30
|
-
|
55
|
+
this.fallbackInput.checked = this.internalChecked;
|
56
|
+
this.fallbackInput.name = this.name;
|
57
|
+
this.fallbackInput.value = this.value;
|
58
|
+
this.fallbackInput.disabled = this.disabled;
|
31
59
|
}
|
32
|
-
/**
|
33
|
-
* Click the hidden input element to let it handle the state
|
34
|
-
* and emit ifxChange event.
|
35
|
-
*/
|
36
60
|
handleRadioButtonClick(event) {
|
37
61
|
if (this.disabled) {
|
38
62
|
event.stopPropagation();
|
@@ -40,28 +64,41 @@ const RadioButton = class {
|
|
40
64
|
}
|
41
65
|
this.inputElement.click();
|
42
66
|
this.internalChecked = this.inputElement.checked;
|
67
|
+
this.checked = this.internalChecked;
|
43
68
|
this.ifxChange.emit(this.internalChecked);
|
69
|
+
const changeEvent = new CustomEvent('change', {
|
70
|
+
bubbles: true,
|
71
|
+
composed: true,
|
72
|
+
detail: { checked: this.internalChecked }
|
73
|
+
});
|
74
|
+
this.el.dispatchEvent(changeEvent);
|
44
75
|
}
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
handleChange(event) {
|
76
|
+
handleKeyDown(ev) {
|
77
|
+
if ([' ', 'Enter'].includes(ev.key)) {
|
78
|
+
ev.preventDefault();
|
79
|
+
this.handleRadioButtonClick(new PointerEvent('click'));
|
80
|
+
}
|
81
|
+
}
|
82
|
+
handleExternalChange(event) {
|
53
83
|
const target = event.target;
|
54
|
-
if (target
|
55
|
-
|
84
|
+
if (target === this.el || target.tagName.toLowerCase() !== 'ifx-radio-button')
|
85
|
+
return;
|
86
|
+
if (target.getAttribute('name') === this.name) {
|
87
|
+
this.internalChecked = false;
|
56
88
|
}
|
57
89
|
}
|
58
90
|
render() {
|
59
|
-
return (h("div", { key: '
|
60
|
-
|
61
|
-
|
62
|
-
|
91
|
+
return (h("div", { key: '78fb99e348f1f87ff7a51ffba6cdc41e7c0954ed', role: "radio", "aria-checked": String(this.internalChecked), "aria-disabled": String(this.disabled), class: `radioButton__container ${this.size} ${this.disabled ? 'disabled' : ''}`, onClick: (e) => this.handleRadioButtonClick(e), tabindex: this.disabled ? -1 : 0 }, h("div", { key: '064187ce7ca62db30e4f190f8566b06028599981', class: `radioButton__wrapper
|
92
|
+
${this.internalChecked ? 'checked' : ''}
|
93
|
+
${this.disabled ? 'disabled' : ''}
|
94
|
+
${this.error ? 'error' : ''}` }, this.internalChecked && h("div", { key: 'a6993ca1888fc1c5ee41bc481c6ccac9538dbae8', class: "radioButton__wrapper-mark" })), this.hasSlot && (h("div", { key: '530f4ab560e608aabe3f0d91fbf36518c131578a', class: `label ${this.size === "m" ? "label-m" : ""} ${this.disabled ? 'disabled' : ''}` }, h("slot", { key: 'cb4ac01adcb5377cd4c675b90f7ad95a8c318ad2' }))), h("input", { key: 'f4f2118841914a8285728d42b55108c3adbfdaea', type: "radio", hidden: true, ref: el => this.inputElement = el, name: this.name, value: this.value, checked: this.internalChecked, disabled: this.disabled, onClick: (e) => e.stopPropagation() })));
|
63
95
|
}
|
96
|
+
static get formAssociated() { return true; }
|
64
97
|
get el() { return getElement(this); }
|
98
|
+
static get watchers() { return {
|
99
|
+
"checked": ["handleCheckedChange"],
|
100
|
+
"internalChecked": ["updateFormValue"]
|
101
|
+
}; }
|
65
102
|
};
|
66
103
|
RadioButton.style = IfxRadioButtonStyle0;
|
67
104
|
|