|
|
|
|
@ -2,9 +2,21 @@
|
|
|
|
|
|
|
|
|
|
export type OptionValue = string | number | boolean;
|
|
|
|
|
|
|
|
|
|
export type OptionValuer= OptionValue | (() => OptionValue);
|
|
|
|
|
|
|
|
|
|
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';
|
|
|
|
|
|
|
|
|
|
@ -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 {
|
|
|
|
|
mode : ValidatorType;
|
|
|
|
|
value? : OptionValue | OptionValue[];
|
|
|
|
|
func? : (v :OptionValue) => boolean;
|
|
|
|
|
func? : Validator;
|
|
|
|
|
message? : (v :OptionValue) => string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -43,7 +57,7 @@ export type DependencyOperator = '=' | '!=' | '<=' | '<' | '>=' | '>';
|
|
|
|
|
export interface Dependency {
|
|
|
|
|
entity : string;
|
|
|
|
|
group : string; // Nombre del grupo del que depende
|
|
|
|
|
value : OptionValue;
|
|
|
|
|
value : OptionValuer;
|
|
|
|
|
operator? : DependencyOperator; // Por defecto '=' si no se indica
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -83,10 +97,10 @@ export interface TextContent {
|
|
|
|
|
tooltip? : string; // Texto breve al pasar el cursor
|
|
|
|
|
|
|
|
|
|
// 🔹 Campos relacionados con precio
|
|
|
|
|
price_label? : string; // Ej: "Precio"
|
|
|
|
|
price_unit? : string; // Ej: "€/m²", "€/ud"
|
|
|
|
|
price_message?: string; // Mensaje contextual sobre precio (ej. "Incluye IVA")
|
|
|
|
|
price_range_message? : string; // Mensaje contextual si es un precio calculado por rango
|
|
|
|
|
priceLabel? : string; // Ej: "Precio"
|
|
|
|
|
priceUnit? : string; // Ej: "€/m²", "€/ud"
|
|
|
|
|
priceMsg? : string; // Mensaje contextual sobre precio (ej. "Incluye IVA")
|
|
|
|
|
priceRangeMsg?: string; // Mensaje contextual si es un precio calculado por rango
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -111,6 +125,9 @@ export interface Group {
|
|
|
|
|
name : string;
|
|
|
|
|
default : number; // idx default option, normally 0
|
|
|
|
|
|
|
|
|
|
enabled : Enabler;
|
|
|
|
|
required : boolean;
|
|
|
|
|
multiple : boolean;
|
|
|
|
|
options : Options;
|
|
|
|
|
optionIds : IdsPos;
|
|
|
|
|
|
|
|
|
|
@ -126,10 +143,12 @@ export interface Option {
|
|
|
|
|
id : string;
|
|
|
|
|
name : string;
|
|
|
|
|
|
|
|
|
|
enabled : Enabler;
|
|
|
|
|
value : OptionValue;
|
|
|
|
|
Price? : Price;
|
|
|
|
|
price? : Price;
|
|
|
|
|
choices? : OptionValue[];
|
|
|
|
|
unit? : string;
|
|
|
|
|
quantity? : Quantity;
|
|
|
|
|
|
|
|
|
|
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];
|
|
|
|
|
};
|