|
|
|
@ -1,35 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
|
|
|
type ValueProvider,
|
|
|
|
|
|
|
|
type BooleanProvider,
|
|
|
|
|
|
|
|
type StringProvider,
|
|
|
|
|
|
|
|
type NumberProvider,
|
|
|
|
|
|
|
|
type OptionValueProvider
|
|
|
|
|
|
|
|
} from './provider';
|
|
|
|
|
|
|
|
import { type Quantity } from './quantity';
|
|
|
|
|
|
|
|
|
|
|
|
export type OptionValue = string | number | boolean;
|
|
|
|
export type OptionValue = string | number | boolean;
|
|
|
|
|
|
|
|
|
|
|
|
export type OptionValuer= OptionValue | (() => OptionValue);
|
|
|
|
export type IdToIndexMap= 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';
|
|
|
|
|
|
|
|
|
|
|
|
export type OptionRestriction =
|
|
|
|
interface RestrictionBase<T extends RestrictionType> {
|
|
|
|
| { mode: 'choices'; values: OptionValue[] }
|
|
|
|
mode: T;
|
|
|
|
| {
|
|
|
|
}
|
|
|
|
mode: 'range';
|
|
|
|
|
|
|
|
|
|
|
|
export interface ChoicesRestriction extends RestrictionBase<'choices'> {
|
|
|
|
|
|
|
|
values: OptionValue[];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export interface RangeRestriction extends RestrictionBase<'range'> {
|
|
|
|
range: {
|
|
|
|
range: {
|
|
|
|
min: number | (() => number);
|
|
|
|
min: NumberProvider;
|
|
|
|
max: number | (() => number);
|
|
|
|
max: NumberProvider;
|
|
|
|
step?: number;
|
|
|
|
step?: number;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export type OptionRestriction = ChoicesRestriction | RangeRestriction;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export type OptionRestrictions = OptionRestriction[];
|
|
|
|
export type OptionRestrictions = OptionRestriction[];
|
|
|
|
@ -39,7 +44,7 @@ export type OptionRestrictions = OptionRestriction[];
|
|
|
|
|
|
|
|
|
|
|
|
export type ValidatorType = "min" | "max" | "regex" | "allowed" | "custom";
|
|
|
|
export type ValidatorType = "min" | "max" | "regex" | "allowed" | "custom";
|
|
|
|
|
|
|
|
|
|
|
|
export type Validator = (v: OptionRestriction) => boolean;
|
|
|
|
export type Validator = (v: OptionValue) => boolean;
|
|
|
|
|
|
|
|
|
|
|
|
export interface OptionValidator {
|
|
|
|
export interface OptionValidator {
|
|
|
|
mode : ValidatorType;
|
|
|
|
mode : ValidatorType;
|
|
|
|
@ -57,7 +62,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 : OptionValuer;
|
|
|
|
value : OptionValueProvider;
|
|
|
|
operator? : DependencyOperator; // Por defecto '=' si no se indica
|
|
|
|
operator? : DependencyOperator; // Por defecto '=' si no se indica
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -67,40 +72,40 @@ export type Dependencies = Dependency[];
|
|
|
|
|
|
|
|
|
|
|
|
export interface ImageContent {
|
|
|
|
export interface ImageContent {
|
|
|
|
id : string;
|
|
|
|
id : string;
|
|
|
|
name : string;
|
|
|
|
name : StringProvider;
|
|
|
|
src : string;
|
|
|
|
src : string;
|
|
|
|
thumb? : string;
|
|
|
|
thumb? : string;
|
|
|
|
large? : string;
|
|
|
|
large? : string;
|
|
|
|
title? : string;
|
|
|
|
title? : StringProvider;
|
|
|
|
text? : string;
|
|
|
|
text? : StringProvider;
|
|
|
|
alt? : string;
|
|
|
|
alt? : StringProvider;
|
|
|
|
width? : number;
|
|
|
|
width? : number;
|
|
|
|
height? : number;
|
|
|
|
height? : number;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export interface PdfContent {
|
|
|
|
export interface PdfContent {
|
|
|
|
title : string;
|
|
|
|
title : StringProvider;
|
|
|
|
text : string;
|
|
|
|
text : StringProvider;
|
|
|
|
image? : string;
|
|
|
|
image? : StringProvider;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export interface TextContent {
|
|
|
|
export interface TextContent {
|
|
|
|
label? : string; // Etiqueta corta, ideal para botones o encabezados
|
|
|
|
label? : StringProvider; // Etiqueta corta, ideal para botones o encabezados
|
|
|
|
title? : string; // Título principal o destacado
|
|
|
|
title? : StringProvider; // Título principal o destacado
|
|
|
|
description? : string; // Texto descriptivo o explicativo
|
|
|
|
description? : StringProvider; // Texto descriptivo o explicativo
|
|
|
|
help? : string; // Texto de ayuda o aclaración contextual
|
|
|
|
help? : StringProvider; // Texto de ayuda o aclaración contextual
|
|
|
|
message_ok? : string; // Mensaje positivo (éxito, selección válida)
|
|
|
|
messageOk? : StringProvider; // Mensaje positivo (éxito, selección válida)
|
|
|
|
message_err? : string; // Mensaje de error o validación
|
|
|
|
messageErr? : StringProvider; // Mensaje de error o validación
|
|
|
|
placeholder? : string; // Texto de entrada (para inputs)
|
|
|
|
placeholder? : StringProvider; // Texto de entrada (para inputs)
|
|
|
|
tooltip? : string; // Texto breve al pasar el cursor
|
|
|
|
tooltip? : StringProvider; // Texto breve al pasar el cursor
|
|
|
|
|
|
|
|
|
|
|
|
// 🔹 Campos relacionados con precio
|
|
|
|
// 🔹 Campos relacionados con precio
|
|
|
|
priceLabel? : string; // Ej: "Precio"
|
|
|
|
priceLabel? : StringProvider; // Ej: "Precio"
|
|
|
|
priceUnit? : string; // Ej: "€/m²", "€/ud"
|
|
|
|
priceUnit? : StringProvider; // Ej: "€/m²", "€/ud"
|
|
|
|
priceMsg? : string; // Mensaje contextual sobre precio (ej. "Incluye IVA")
|
|
|
|
priceMsg? : StringProvider; // Mensaje contextual sobre precio (ej. "Incluye IVA")
|
|
|
|
priceRangeMsg?: string; // Mensaje contextual si es un precio calculado por rango
|
|
|
|
priceRangeMsg?: StringProvider; // Mensaje contextual si es un precio calculado por rango
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -122,14 +127,14 @@ export interface Content {
|
|
|
|
|
|
|
|
|
|
|
|
export interface Group {
|
|
|
|
export interface Group {
|
|
|
|
id : string;
|
|
|
|
id : string;
|
|
|
|
name : string;
|
|
|
|
name : StringProvider;
|
|
|
|
default : number; // idx default option, normally 0
|
|
|
|
default : number; // idx default option, normally 0
|
|
|
|
|
|
|
|
|
|
|
|
enabled : Enabler;
|
|
|
|
enabled : BooleanProvider;
|
|
|
|
required : boolean;
|
|
|
|
required : BooleanProvider;
|
|
|
|
multiple : boolean;
|
|
|
|
multiple : boolean;
|
|
|
|
options : Options;
|
|
|
|
options : Options;
|
|
|
|
optionIds : IdsPos;
|
|
|
|
optionIds : IdToIndexMap;
|
|
|
|
|
|
|
|
|
|
|
|
content? : Content;
|
|
|
|
content? : Content;
|
|
|
|
|
|
|
|
|
|
|
|
@ -141,9 +146,9 @@ export type Groups = Group[];
|
|
|
|
|
|
|
|
|
|
|
|
export interface Option {
|
|
|
|
export interface Option {
|
|
|
|
id : string;
|
|
|
|
id : string;
|
|
|
|
name : string;
|
|
|
|
name : StringProvider;
|
|
|
|
|
|
|
|
|
|
|
|
enabled : Enabler;
|
|
|
|
enabled : BooleanProvider;
|
|
|
|
value : OptionValue;
|
|
|
|
value : OptionValue;
|
|
|
|
price? : Price;
|
|
|
|
price? : Price;
|
|
|
|
choices? : OptionValue[];
|
|
|
|
choices? : OptionValue[];
|
|
|
|
@ -161,17 +166,18 @@ export type Options = Option[];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export interface Entity {
|
|
|
|
export interface Entity {
|
|
|
|
name : string;
|
|
|
|
id : string;
|
|
|
|
|
|
|
|
name : StringProvider;
|
|
|
|
|
|
|
|
|
|
|
|
content? : Content;
|
|
|
|
content? : Content;
|
|
|
|
|
|
|
|
|
|
|
|
groups : Groups;
|
|
|
|
groups : Groups;
|
|
|
|
groupsIds : IdsPos;
|
|
|
|
groupsIds : IdToIndexMap;
|
|
|
|
|
|
|
|
|
|
|
|
dependsOn? : Dependencies;
|
|
|
|
dependsOn? : Dependencies;
|
|
|
|
|
|
|
|
|
|
|
|
entities? : Entities;
|
|
|
|
entities? : Entities;
|
|
|
|
entitiesIds : Record<string, number>;
|
|
|
|
entitiesIds : IdToIndexMap ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -181,5 +187,29 @@ export type Entities = Entity[];
|
|
|
|
|
|
|
|
|
|
|
|
// ============ Utilidades de tipo ============
|
|
|
|
// ============ Utilidades de tipo ============
|
|
|
|
export type DeepPartial<T> = {
|
|
|
|
export type DeepPartial<T> = {
|
|
|
|
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
|
|
[P in keyof T]?: T[P] extends object
|
|
|
|
|
|
|
|
? T[P] extends Function
|
|
|
|
|
|
|
|
? T[P]
|
|
|
|
|
|
|
|
: DeepPartial<T[P]>
|
|
|
|
|
|
|
|
: T[P];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|