| 1 | import {BaseComponent} from './BaseComponent.js'; |
| 2 | |
| 3 | export class BaseInputComponent extends BaseComponent{ |
| 4 | constructor(args = null) |
| 5 | { |
| 6 | super(args); |
| 7 | Object.setPrototypeOf(this, BaseInputComponent.prototype); |
| 8 | |
| 9 | return this; |
| 10 | } |
| 11 | |
| 12 | changed(innerEvent){ |
| 13 | let event = new CustomEvent(`checkout:${this.componentType}:changed`, { detail: |
| 14 | { |
| 15 | event: innerEvent, |
| 16 | value: this.value |
| 17 | } |
| 18 | }); |
| 19 | this.dispatchEvent(event); |
| 20 | } |
| 21 | |
| 22 | /** |
| 23 | * Add an event listener to a specific event |
| 24 | * @param {string} event Event name |
| 25 | * @param {function} callback Callback function to execute when event triggers |
| 26 | */ |
| 27 | on(event, callback){ |
| 28 | this.addEventListener(`checkout:${this.componentType}:${event}`, callback, false); |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * Call a callback when the value of the component changes. |
| 33 | * @param {function} callback Callback function to execute when the component changes |
| 34 | */ |
| 35 | onValueChanged(callback){ |
| 36 | this.on(`changed`, callback); |
| 37 | } |
| 38 | } |
nothing calls this directly
no outgoing calls
no test coverage detected