sintonia_webapp/resources/js/composables/content/models/misc/FormInterface.ts

75 lines
1.9 KiB
TypeScript

import type {VCheckbox, VSelect, VTextarea, VTextField} from "vuetify/components";
import type {VFileInput} from "vuetify/components";
import type ColorPickerButton from "@partials/fields/misc/ColorPickerButton.vue";
import type CheckBoxConditional from "@partials/fields/misc/CheckBoxConditional.vue";
type ColorPickerButton = InstanceType<typeof ColorPickerButton>;
type CheckBoxConditionalCompType = InstanceType<typeof CheckBoxConditional>;
interface BaseFieldConfig {
label: string;
component: any;
disabled?: boolean;
props?: Record<string, Object>;
}
export interface CheckBoxConditionalType {
component: typeof CheckBoxConditionalCompType;
checkBoxForm: {
checkBoxField: string;
fields: BaseFieldConfig[]
}
}
export interface ColorPickerFieldConfig extends BaseFieldConfig {
component: typeof ColorPickerButton;
}
export interface CheckboxFieldConfig extends BaseFieldConfig {
component: typeof VCheckbox;
}
export interface SelectFieldConfig extends BaseFieldConfig {
component: typeof VSelect;
props: {
items: { text: string; value: boolean }[];
};
}
export interface TextFieldConfig extends BaseFieldConfig {
component: typeof VTextField;
}
export interface TextareaConfig extends BaseFieldConfig {
component: typeof VTextarea;
}
export interface FileFieldConfig extends BaseFieldConfig {
component: typeof VFileInput;
props: {
type: 'file';
};
}
export interface AutocompleteFieldConfig extends BaseFieldConfig {
component: any;
props: {
items: any[];
labelKey: string;
valueKey: string;
};
}
export type FieldDefinition =
| CheckboxFieldConfig
| CheckBoxConditional
| TextFieldConfig
| TextareaConfig
| FileFieldConfig
| AutocompleteFieldConfig
| SelectFieldConfig
| ColorPickerFieldConfig;
export interface FieldDefinitions {
[key: string]: FieldDefinition;
}