@tresjs/leches
Version:
Tasty GUI for Vue controls 🍰
83 lines (82 loc) • 3.15 kB
TypeScript
export interface LechesSelectOption {
text: string;
alias: string;
value: string | number;
}
export type LechesValue = string | number | boolean;
export type LechesCotrolConfigTypes = 'select' | 'button' | 'range' | 'boolean' | 'text' | 'number';
export interface LechesBaseControlConfig {
value: unknown;
label?: string;
icon?: string;
type?: LechesCotrolConfigTypes;
}
export interface LechesSelectControlConfig extends LechesBaseControlConfig {
options: string[] | LechesSelectOption[];
}
export interface LechesSelectControlButton extends LechesBaseControlConfig {
variant: 'primary' | 'secondary';
onClick?: () => void;
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'block';
}
export interface LechesBooleanControl extends Omit<LechesControl<boolean>, 'type'> {
type: 'boolean';
value: boolean;
}
export interface LechesNumberControl extends Omit<LechesControl<number>, 'type'> {
type: 'number' | 'range';
value: number;
min?: number;
max?: number;
step?: number;
format?: (value: number) => string;
}
export interface LechesStringControl extends Omit<LechesControl<string>, 'type'> {
type: 'text' | 'color';
value: string;
}
export interface LechesSelectControl extends Omit<LechesControl<string | number>, 'type'> {
type: 'select';
value: string | number;
options: LechesSelectOption[];
}
export interface LechesButtonControl extends Omit<LechesControl<LechesSelectControlButton>, 'type'> {
type: 'button';
value: LechesSelectControlButton;
}
export interface LechesVectorControl extends Omit<LechesControl<any>, 'type'> {
type: 'vector';
value: any;
step?: number;
min?: number;
max?: number;
format?: (value: number) => string;
}
export interface LechesGraphControl extends Omit<LechesControl<any>, 'type'> {
type: 'graph' | 'fpsgraph';
value: any;
}
export type LechesControlUnion = LechesBooleanControl | LechesNumberControl | LechesStringControl | LechesSelectControl | LechesButtonControl | LechesVectorControl | LechesGraphControl;
export declare function isBooleanControl(control: LechesControlUnion): control is LechesBooleanControl;
export declare function isNumberControl(control: LechesControlUnion): control is LechesNumberControl;
export declare function isStringControl(control: LechesControlUnion): control is LechesStringControl;
export declare function isSelectControl(control: LechesControlUnion): control is LechesSelectControl;
export declare function isButtonControl(control: LechesControlUnion): control is LechesButtonControl;
export declare function isVectorControl(control: LechesControlUnion): control is LechesVectorControl;
export declare function isGraphControl(control: LechesControlUnion): control is LechesGraphControl;
export interface LechesControl<T = unknown> {
key: string;
label: string;
name: string;
type: string;
value: T;
visible: boolean;
icon?: string;
uniqueKey: string;
folder?: string;
options?: LechesSelectOption[];
min?: number;
max?: number;
step?: number;
onUpdate?: (values: unknown[]) => void;
}