Configuracion del proyecto en svelte kit + tailwind css + typescript

- Definicion de los tipos propios del configurador
master
dev 12 months ago
parent 1187392454
commit 45b09207bf

@ -2,9 +2,21 @@
export type OptionValue = string | number | boolean; export type OptionValue = string | number | boolean;
export type OptionValuer= OptionValue | (() => OptionValue);
export type IdsPos = Record<string, number>; export type IdsPos = Record<string, number>;
export type Enabler = boolean | (() => boolean);
// ============ Cantidad ============
export interface Quantity {
value : OptionValuer;
min? : OptionValuer;
max? : OptionValuer;
step? : number; // Para incrementos (ej: de 5 en 5)
}
export type RestrictionType = 'choices' | 'range'; export type RestrictionType = 'choices' | 'range';
@ -25,12 +37,14 @@ export type OptionRestrictions = OptionRestriction[];
export type ValidatorType = "min" | "max" | "regex" | "allowedValues" | "custom"; export type ValidatorType = "min" | "max" | "regex" | "allowed" | "custom";
export type Validator = (v: OptionRestriction) => boolean;
export interface OptionValidator { export interface OptionValidator {
mode : ValidatorType; mode : ValidatorType;
value? : OptionValue | OptionValue[]; value? : OptionValue | OptionValue[];
func? : (v :OptionValue) => boolean; func? : Validator;
message? : (v :OptionValue) => string; message? : (v :OptionValue) => string;
} }
@ -43,7 +57,7 @@ export type DependencyOperator = '=' | '!=' | '<=' | '<' | '>=' | '>';
export interface Dependency { export interface Dependency {
entity : string; entity : string;
group : string; // Nombre del grupo del que depende group : string; // Nombre del grupo del que depende
value : OptionValue; value : OptionValuer;
operator? : DependencyOperator; // Por defecto '=' si no se indica operator? : DependencyOperator; // Por defecto '=' si no se indica
} }
@ -83,10 +97,10 @@ export interface TextContent {
tooltip? : string; // Texto breve al pasar el cursor tooltip? : string; // Texto breve al pasar el cursor
// 🔹 Campos relacionados con precio // 🔹 Campos relacionados con precio
price_label? : string; // Ej: "Precio" priceLabel? : string; // Ej: "Precio"
price_unit? : string; // Ej: "€/m²", "€/ud" priceUnit? : string; // Ej: "€/m²", "€/ud"
price_message?: string; // Mensaje contextual sobre precio (ej. "Incluye IVA") priceMsg? : string; // Mensaje contextual sobre precio (ej. "Incluye IVA")
price_range_message? : string; // Mensaje contextual si es un precio calculado por rango priceRangeMsg?: string; // Mensaje contextual si es un precio calculado por rango
} }
@ -111,6 +125,9 @@ export interface Group {
name : string; name : string;
default : number; // idx default option, normally 0 default : number; // idx default option, normally 0
enabled : Enabler;
required : boolean;
multiple : boolean;
options : Options; options : Options;
optionIds : IdsPos; optionIds : IdsPos;
@ -126,10 +143,12 @@ export interface Option {
id : string; id : string;
name : string; name : string;
enabled : Enabler;
value : OptionValue; value : OptionValue;
Price? : Price; price? : Price;
choices? : OptionValue[]; choices? : OptionValue[];
unit? : string; unit? : string;
quantity? : Quantity;
content? : Content; content? : Content;
@ -156,4 +175,11 @@ export interface Entity {
} }
export type Entities = Entity[]; export type Entities = Entity[];
// ============ Utilidades de tipo ============
export type DeepPartial<T> = {
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
};
Loading…
Cancel
Save

Powered by TurnKey Linux.