SqInput.js (1399B)
1 import { vInput } from "../../value/index.js"; 2 export const wrapInput = (value) => { 3 switch (value.type) { 4 case "text": 5 return new SqTextInput(value); 6 case "textArea": 7 return new SqTextAreaInput(value); 8 case "checkbox": 9 return new SqCheckboxInput(value); 10 case "select": 11 return new SqSelectInput(value); 12 } 13 }; 14 class SqAbstractInput { 15 constructor(_value) { 16 this._value = _value; 17 } 18 toString() { 19 return vInput(this._value).toString(); 20 } 21 get name() { 22 return this._value.name; 23 } 24 get description() { 25 return this._value.description; 26 } 27 get default() { 28 return this._value.default; 29 } 30 } 31 export class SqTextInput extends SqAbstractInput { 32 constructor() { 33 super(...arguments); 34 this.tag = "text"; 35 } 36 } 37 export class SqTextAreaInput extends SqAbstractInput { 38 constructor() { 39 super(...arguments); 40 this.tag = "textArea"; 41 } 42 } 43 export class SqCheckboxInput extends SqAbstractInput { 44 constructor() { 45 super(...arguments); 46 this.tag = "checkbox"; 47 } 48 } 49 export class SqSelectInput extends SqAbstractInput { 50 constructor() { 51 super(...arguments); 52 this.tag = "select"; 53 } 54 get options() { 55 return this._value.options; 56 } 57 } 58 //# sourceMappingURL=SqInput.js.map