1import { ProductOptionControlChangedEvent } from "./product-events.js"; 2import { ProductOptionControl } from "./product-option-control.js"; 3export class ProductOptionRadio extends ProductOptionControl { 4 _inputs; 5 constructor(target, group) { 6 const inputs = Array.from(target.querySelectorAll('[data-radio-list-option]')); 7 super(inputs[0], group); 8 this._inputs = inputs; 9 for (const input of this._inputs) { 10 input.addEventListener('change', (e) => { 11 e.stopPropagation(); 12 if (input.checked) { 13 input.dispatchEvent(new ProductOptionControlChangedEvent({ control: this })); 14 } 15 }); 16 } 17 } 18 get hasValue() { 19 return this._inputs.some(i => i.checked); 20 } 21 get value() { 22 return this._inputs.find(i => i.checked)?.value ?? ''; 23 } 24 get isRequired() { 25 return this._inputs[0]?.required ?? false; 26 } 27 set isRequired(required) { 28 for (const input of this._inputs) { 29 input.required = required; 30 } 31 } 32 get isValid() { 33 return this._inputs.length > 0 ? this._inputs[0].checkValidity() : true; 34 } 35 get validationTarget() { 36 return this._inputs[0]; 37 } 38 disable() { 39 for (const input of this._inputs) { 40 input.checked = false; 41 input.disabled = true; 42 } 43 } 44 enable() { 45 for (const input of this._inputs) { 46 input.disabled = false; 47 } 48 } 49 disableInputs(values) { 50 for (const input of this._inputs.filter(c => values.has(c.value))) { 51 input.checked = false; 52 input.disabled = true; 53 } 54 } 55 enableInputs(values) { 56 for (const input of this._inputs.filter(c => values.has(c.value))) { 57 input.disabled = false; 58 } 59 } 60} 61//# sourceMappingURL=product-option-radio.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.