fix: broken types
This commit is contained in:
parent
a868e4f550
commit
9e54d2b0a9
1 changed files with 8 additions and 5 deletions
|
@ -2,16 +2,16 @@ import type {
|
||||||
Button,
|
Button,
|
||||||
Checkbox,
|
Checkbox,
|
||||||
ControlType,
|
ControlType,
|
||||||
TextInput,
|
|
||||||
Radio,
|
Radio,
|
||||||
Dropdown,
|
Dropdown,
|
||||||
ControlOption,
|
ControlOption,
|
||||||
Submit,
|
Submit,
|
||||||
ValidationError,
|
ValidationError,
|
||||||
TextArea,
|
TextArea,
|
||||||
|
ControlBase,
|
||||||
} from '@astro-reactive/common';
|
} from '@astro-reactive/common';
|
||||||
|
|
||||||
export type ControlConfig = TextInput | Checkbox | Radio | Submit | Button | Dropdown | TextArea;
|
export type ControlConfig = ControlBase | Checkbox | Radio | Submit | Button | Dropdown | TextArea;
|
||||||
|
|
||||||
export class FormControl {
|
export class FormControl {
|
||||||
private _name = '';
|
private _name = '';
|
||||||
|
@ -44,7 +44,6 @@ export class FormControl {
|
||||||
label = '',
|
label = '',
|
||||||
placeholder = null,
|
placeholder = null,
|
||||||
validators = [],
|
validators = [],
|
||||||
options = [],
|
|
||||||
} = config;
|
} = config;
|
||||||
|
|
||||||
this._name = name;
|
this._name = name;
|
||||||
|
@ -53,10 +52,14 @@ export class FormControl {
|
||||||
this._label = label;
|
this._label = label;
|
||||||
this._placeholder = placeholder;
|
this._placeholder = placeholder;
|
||||||
this._validators = validators;
|
this._validators = validators;
|
||||||
|
|
||||||
|
if (type === 'radio' || type === 'dropdown') {
|
||||||
|
const { options = [] } = config as Radio | Dropdown;
|
||||||
this._options = options;
|
this._options = options;
|
||||||
|
}
|
||||||
|
|
||||||
if (config.type === 'textarea') {
|
if (config.type === 'textarea') {
|
||||||
const { rows = null, cols = null } = config;
|
const { rows = null, cols = null } = config as TextArea;
|
||||||
this._rows = rows;
|
this._rows = rows;
|
||||||
this._cols = cols;
|
this._cols = cols;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue