@dipusevilla/componentes-iu 1.1.5 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/html-6Zgdkrh7.mjs +2784 -0
- package/dist/html-KxqAGR9q.js +25 -0
- package/dist/index.cjs.js +227 -128
- package/dist/index.css +1 -1
- package/dist/index.es.js +27472 -20220
- package/dist/index.umd.js +285 -134
- package/dist/standalone-CUhUiIuV.mjs +2458 -0
- package/dist/standalone-RFBVEkze.js +29 -0
- package/dist/types/components/FileUploader.d.ts +1 -0
- package/dist/types/components/FormFieldInput.d.ts +5 -1
- package/dist/types/components/FormLabel.d.ts +5 -1
- package/dist/types/components/FormRenderer.d.ts +1 -2
- package/dist/types/components/FormRenderer.test.d.ts +1 -0
- package/dist/types/components/InfoButton.d.ts +5 -0
- package/dist/types/components/Input.d.ts +6 -1
- package/dist/types/components/Modal.d.ts +5 -1
- package/dist/types/components/Select.d.ts +2 -0
- package/dist/types/components/Tabs.d.ts +3 -1
- package/dist/types/components/TextArea.d.ts +2 -1
- package/dist/types/editor/SchemaEditorHost.d.ts +2 -1
- package/dist/types/editor/adapters/inMemoryTranslationAdapter.d.ts +2 -0
- package/dist/types/editor/components/CodeEditor.d.ts +18 -0
- package/dist/types/editor/components/EndpointBrowser.d.ts +1 -1
- package/dist/types/editor/components/EndpointConfigModal.d.ts +3 -2
- package/dist/types/editor/components/EndpointParameterConfig.d.ts +2 -1
- package/dist/types/editor/components/InfoBuilderModal.d.ts +11 -0
- package/dist/types/editor/components/OnloadEndpointsManager.d.ts +6 -0
- package/dist/types/editor/components/RuleBuilderModal.d.ts +22 -0
- package/dist/types/editor/components/SystemVariablesModal.d.ts +7 -0
- package/dist/types/editor/components/ValidationBuilderModal.d.ts +12 -0
- package/dist/types/editor/dnd/dndPaths.d.ts +4 -0
- package/dist/types/editor/importers/dto/analysis/analyzer.d.ts +11 -0
- package/dist/types/editor/importers/dto/generator.d.ts +11 -0
- package/dist/types/editor/importers/dto/inference.d.ts +8 -0
- package/dist/types/editor/importers/dto/layout.d.ts +5 -0
- package/dist/types/editor/importers/dto/naming.d.ts +5 -0
- package/dist/types/editor/importers/dto/parser.d.ts +9 -0
- package/dist/types/editor/importers/dto/strategies/MasterDetailStrategy.d.ts +8 -0
- package/dist/types/editor/importers/dto/strategies/MixedStrategy.d.ts +8 -0
- package/dist/types/editor/importers/dto/strategies/StandardStrategy.d.ts +8 -0
- package/dist/types/editor/importers/dto/strategies/TabsStrategy.d.ts +8 -0
- package/dist/types/editor/importers/dto/strategies/types.d.ts +14 -0
- package/dist/types/editor/importers/dto/strategies.d.ts +20 -0
- package/dist/types/editor/importers/dto/translations.d.ts +5 -0
- package/dist/types/editor/importers/dto/types.d.ts +45 -0
- package/dist/types/editor/importers/dto/utils.d.ts +11 -0
- package/dist/types/editor/importers/generateFromDTO.d.ts +3 -56
- package/dist/types/editor/store/runtimeDebugStore.d.ts +11 -0
- package/dist/types/editor/store.d.ts +43 -11
- package/dist/types/editor/types/endpointMetadata.d.ts +5 -3
- package/dist/types/editor/utils/adapterGenerator.d.ts +2 -3
- package/dist/types/editor/utils/exportProject.d.ts +10 -0
- package/dist/types/editor/utils/fieldKinds.d.ts +1 -1
- package/dist/types/editor/utils/generateServicesCode.d.ts +8 -0
- package/dist/types/editor/utils/importProject.d.ts +9 -0
- package/dist/types/rules/RuleDSL.d.ts +12 -0
- package/dist/types/types/EndpointTypes.d.ts +30 -0
- package/dist/types/types/FormTypes.d.ts +120 -19
- package/dist/types/utils/SecureValidator.d.ts +16 -0
- package/dist/types/utils/endpointHelpers.d.ts +2 -2
- package/dist/types/utils/interpolationHelpers.d.ts +1 -0
- package/dist/types/utils/translationHelpers.d.ts +5 -1
- package/package.json +16 -2
- package/dist/types/editor/components/ServiceAdapterGenerator.d.ts +0 -4
- package/dist/types/editor/helpers/serviceParser.d.ts +0 -6
|
@@ -4,6 +4,60 @@ import { InputProps } from "../components/Input";
|
|
|
4
4
|
import { SelectProps } from "../components/Select";
|
|
5
5
|
import { UseFormGetValues, UseFormWatch } from "react-hook-form";
|
|
6
6
|
import type { VisibilityRule, ClearWhenRule } from "../rules/RuleDSL";
|
|
7
|
+
import type { EndpointConfig } from "./EndpointTypes";
|
|
8
|
+
/**
|
|
9
|
+
* Configuración de un botón del footer del modal
|
|
10
|
+
*/
|
|
11
|
+
export interface ModalFooterButton {
|
|
12
|
+
/** Texto del botón */
|
|
13
|
+
label: string;
|
|
14
|
+
/** Variante visual del botón */
|
|
15
|
+
variant: 'primary' | 'outline' | 'ghost';
|
|
16
|
+
/** Acción al hacer click */
|
|
17
|
+
action: 'close' | 'link';
|
|
18
|
+
/** URL si action es 'link' */
|
|
19
|
+
linkUrl?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Configuración del modal al hacer click en el botón de información
|
|
23
|
+
*/
|
|
24
|
+
export interface InfoModalConfig {
|
|
25
|
+
/** Si está habilitado el modal al hacer click */
|
|
26
|
+
enabled: boolean;
|
|
27
|
+
/** Título del modal */
|
|
28
|
+
title?: string;
|
|
29
|
+
/** Icono del título (nombre e estilo de Heroicons) */
|
|
30
|
+
titleIcon?: {
|
|
31
|
+
name: string;
|
|
32
|
+
style: 'outline' | 'solid';
|
|
33
|
+
};
|
|
34
|
+
/** Contenido del modal (puede ser diferente al tooltip) */
|
|
35
|
+
content?: string;
|
|
36
|
+
/** Formato del contenido: 'text' para texto plano, 'html' para HTML */
|
|
37
|
+
contentFormat?: 'text' | 'html';
|
|
38
|
+
/** Ancho máximo del modal */
|
|
39
|
+
maxWidth?: 'sm' | 'md' | 'lg' | 'xl' | '2xl' | 'full';
|
|
40
|
+
/** Alto máximo del modal */
|
|
41
|
+
maxHeight?: string;
|
|
42
|
+
/** Si mostrar el footer */
|
|
43
|
+
showFooter?: boolean;
|
|
44
|
+
/** Botones del footer */
|
|
45
|
+
footerButtons?: ModalFooterButton[];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Configuración de mensaje de información complejo
|
|
49
|
+
*/
|
|
50
|
+
export interface ComplexInfoConfig {
|
|
51
|
+
type: 'complex';
|
|
52
|
+
/** Título/cabecera del tooltip */
|
|
53
|
+
header?: string;
|
|
54
|
+
/** Plantilla de texto del tooltip con soporte para interpolación {{fieldName}} */
|
|
55
|
+
template: string;
|
|
56
|
+
/** Endpoint opcional para cargar datos dinámicos */
|
|
57
|
+
endpoint?: EndpointConfig;
|
|
58
|
+
/** Configuración del modal al hacer click (opcional) */
|
|
59
|
+
modalConfig?: InfoModalConfig;
|
|
60
|
+
}
|
|
7
61
|
export type Condition = {
|
|
8
62
|
watchField: string;
|
|
9
63
|
watchValue: unknown | ((vals: Record<string, unknown>) => boolean);
|
|
@@ -38,8 +92,8 @@ export interface FieldSchema {
|
|
|
38
92
|
options?: any[];
|
|
39
93
|
/** Función asíncrona para cargar opciones dinámicas en <Select>. */
|
|
40
94
|
loadOptions?: () => Promise<any[]>;
|
|
41
|
-
/** Información adicional (ReactNode). */
|
|
42
|
-
info?: React.ReactNode;
|
|
95
|
+
/** Información adicional (string, ReactNode o configuración compleja). */
|
|
96
|
+
info?: React.ReactNode | ComplexInfoConfig;
|
|
43
97
|
/** Reglas de validación para Yup / react-hook-form. */
|
|
44
98
|
validation?: {
|
|
45
99
|
required?: boolean | string;
|
|
@@ -55,6 +109,40 @@ export interface FieldSchema {
|
|
|
55
109
|
value: RegExp;
|
|
56
110
|
message: string;
|
|
57
111
|
};
|
|
112
|
+
customFn?: string;
|
|
113
|
+
customMessages?: Record<string, string>;
|
|
114
|
+
emailMessage?: string;
|
|
115
|
+
urlMessage?: string;
|
|
116
|
+
phoneMessage?: string;
|
|
117
|
+
numberMin?: {
|
|
118
|
+
value: number;
|
|
119
|
+
message: string;
|
|
120
|
+
};
|
|
121
|
+
numberMax?: {
|
|
122
|
+
value: number;
|
|
123
|
+
message: string;
|
|
124
|
+
};
|
|
125
|
+
step?: {
|
|
126
|
+
value: number;
|
|
127
|
+
message: string;
|
|
128
|
+
};
|
|
129
|
+
integerOnly?: boolean | string;
|
|
130
|
+
positiveOnly?: boolean | string;
|
|
131
|
+
typeError?: string;
|
|
132
|
+
dateMin?: {
|
|
133
|
+
value: string | Date;
|
|
134
|
+
message: string;
|
|
135
|
+
};
|
|
136
|
+
dateMax?: {
|
|
137
|
+
value: string | Date;
|
|
138
|
+
message: string;
|
|
139
|
+
};
|
|
140
|
+
disallowPast?: boolean | string;
|
|
141
|
+
disallowFuture?: boolean | string;
|
|
142
|
+
fileMaxSizeMB?: {
|
|
143
|
+
value: number;
|
|
144
|
+
message: string;
|
|
145
|
+
};
|
|
58
146
|
};
|
|
59
147
|
/** Límite de caracteres (solo para textarea). */
|
|
60
148
|
maxLength?: number;
|
|
@@ -64,6 +152,7 @@ export interface FieldSchema {
|
|
|
64
152
|
accept?: string;
|
|
65
153
|
maxFiles?: number;
|
|
66
154
|
multiple?: boolean;
|
|
155
|
+
hideDropZone?: boolean;
|
|
67
156
|
/** Para optionGroup: disposición vertical. */
|
|
68
157
|
vertical?: boolean;
|
|
69
158
|
/** Etiqueta del grupo (solo para optionGroup). */
|
|
@@ -109,6 +198,8 @@ export interface FieldSchema {
|
|
|
109
198
|
optionSource?: string;
|
|
110
199
|
/** Nueva configuración avanzada de endpoint (reemplaza optionSource/searchSource) */
|
|
111
200
|
endpointConfig?: EndpointConfig;
|
|
201
|
+
/** Configuración de validación asíncrona */
|
|
202
|
+
asyncValidation?: AsyncValidationConfig;
|
|
112
203
|
/** Valores por defecto sincrónicos. */
|
|
113
204
|
defaultValue?: Record<string, unknown>;
|
|
114
205
|
}
|
|
@@ -195,6 +286,15 @@ export type LayoutNode = {
|
|
|
195
286
|
key: string;
|
|
196
287
|
label: string;
|
|
197
288
|
sections: SectionBlock[];
|
|
289
|
+
disabled?: boolean;
|
|
290
|
+
icon?: {
|
|
291
|
+
name: string;
|
|
292
|
+
style: 'outline' | 'solid';
|
|
293
|
+
};
|
|
294
|
+
id?: string;
|
|
295
|
+
visibleWhen?: VisibilityRule & {
|
|
296
|
+
enabled?: boolean;
|
|
297
|
+
};
|
|
198
298
|
}>;
|
|
199
299
|
};
|
|
200
300
|
/**
|
|
@@ -221,32 +321,33 @@ export interface FormSchema {
|
|
|
221
321
|
defaultValues?: Record<string, unknown>;
|
|
222
322
|
/** Función asíncrona para obtener defaultValues. */
|
|
223
323
|
loadDefaultValues?: () => Promise<Record<string, unknown>>;
|
|
324
|
+
/** @deprecated Use onloadEndpoints instead. Configuración de endpoint para cargar datos al inicio */
|
|
325
|
+
onloadEndpoint?: EndpointConfig;
|
|
326
|
+
/** Configuración de endpoints para cargar datos al inicio (múltiples llamadas) */
|
|
327
|
+
onloadEndpoints?: EndpointConfig[];
|
|
328
|
+
/** Variables de sistema definidas por el usuario */
|
|
329
|
+
variables?: SystemVariable[];
|
|
330
|
+
}
|
|
331
|
+
export interface SystemVariable {
|
|
332
|
+
key: string;
|
|
333
|
+
type: 'constant' | 'computed' | 'external';
|
|
334
|
+
value: any;
|
|
224
335
|
}
|
|
225
336
|
export type Option = {
|
|
226
337
|
label?: string;
|
|
227
338
|
value: string | number;
|
|
228
339
|
};
|
|
229
340
|
/**
|
|
230
|
-
* Configuración de
|
|
341
|
+
* Configuración de validación asíncrona
|
|
231
342
|
*/
|
|
232
|
-
export interface EndpointParameter {
|
|
233
|
-
/** Nombre del parámetro */
|
|
234
|
-
name: string;
|
|
235
|
-
/** Tipo de valor: estático o referencia a campo */
|
|
236
|
-
type: 'static' | 'field';
|
|
237
|
-
/** Valor estático (si type === 'static') */
|
|
238
|
-
value?: any;
|
|
239
|
-
/** Referencia a campo del formulario (si type === 'field') */
|
|
240
|
-
fieldRef?: string;
|
|
241
|
-
}
|
|
242
343
|
/**
|
|
243
|
-
* Configuración
|
|
344
|
+
* Configuración de validación asíncrona
|
|
244
345
|
*/
|
|
245
|
-
export interface
|
|
246
|
-
/**
|
|
247
|
-
|
|
248
|
-
/**
|
|
249
|
-
|
|
346
|
+
export interface AsyncValidationConfig {
|
|
347
|
+
/** Configuración del endpoint de validación */
|
|
348
|
+
endpoint: EndpointConfig;
|
|
349
|
+
/** Cuándo disparar la validación */
|
|
350
|
+
trigger: 'onSubmit' | 'onBlur';
|
|
250
351
|
}
|
|
251
352
|
export type ConditionalProp = VisibilityRule | {
|
|
252
353
|
watchField: string;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ejecuta código de validación de usuario en un entorno aislado (Web Worker).
|
|
3
|
+
*
|
|
4
|
+
* @param code Código proporcionado por el usuario (cuerpo de la función).
|
|
5
|
+
* @param context Objeto con datos disponibles (value, form, utils).
|
|
6
|
+
* @param options Opciones adicionales (translations, timeoutMs).
|
|
7
|
+
* @returns Promise que resuelve a:
|
|
8
|
+
* - true (válido)
|
|
9
|
+
* - string (mensaje de error)
|
|
10
|
+
* - false (inválido genérico)
|
|
11
|
+
* Reject si hay error de sintaxis o timeout.
|
|
12
|
+
*/
|
|
13
|
+
export declare function validateWithWorker(code: string, context: Record<string, any>, optionsOrTimeout?: number | {
|
|
14
|
+
timeoutMs?: number;
|
|
15
|
+
translations?: Record<string, string>;
|
|
16
|
+
}): Promise<boolean | string>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { EndpointConfig, EndpointParameter } from '../types/
|
|
1
|
+
import type { EndpointConfig, EndpointParameter } from '../types/EndpointTypes';
|
|
2
2
|
import type { UseFormGetValues } from 'react-hook-form';
|
|
3
3
|
/**
|
|
4
4
|
* Resuelve los parámetros de un EndpointConfig convirtiendo referencias
|
|
5
5
|
* a campos en valores actuales del formulario
|
|
6
6
|
*/
|
|
7
|
-
export declare function resolveEndpointParameters(parameters: Record<string, EndpointParameter> | undefined, getValues: UseFormGetValues<any>): Record<string, any>;
|
|
7
|
+
export declare function resolveEndpointParameters(parameters: Record<string, EndpointParameter> | undefined, getValues: UseFormGetValues<any>, systemContext?: Record<string, any>): Record<string, any>;
|
|
8
8
|
/**
|
|
9
9
|
* Obtiene la clave del registry desde optionSource (string) o endpointConfig (objeto)
|
|
10
10
|
* Mantiene compatibilidad hacia atrás
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function interpolateText(text: string | undefined | null, context: Record<string, any>): string;
|
|
@@ -8,7 +8,11 @@
|
|
|
8
8
|
* @param fallback - Valor por defecto si value es undefined
|
|
9
9
|
* @returns Texto traducido o valor original
|
|
10
10
|
*/
|
|
11
|
-
export declare function translateField(t: ReturnType<typeof import('react-i18next').useTranslation>['t'], value: string | undefined
|
|
11
|
+
export declare function translateField(t: ReturnType<typeof import('react-i18next').useTranslation>['t'], value: string | undefined | {
|
|
12
|
+
type?: string;
|
|
13
|
+
header?: string;
|
|
14
|
+
template?: string;
|
|
15
|
+
}, fallback?: string): string;
|
|
12
16
|
/**
|
|
13
17
|
* Helper para traducir mensajes de validación.
|
|
14
18
|
* Maneja tanto strings simples como objetos con message.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dipusevilla/componentes-iu",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.7",
|
|
4
4
|
"description": "Librería de componentes React de Dipusevilla",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -34,7 +34,12 @@
|
|
|
34
34
|
"prepublishOnly": "npm run build",
|
|
35
35
|
"preview": "vite preview",
|
|
36
36
|
"publish": "npm publish --access public",
|
|
37
|
-
"storybook": "storybook dev -p 6006"
|
|
37
|
+
"storybook": "storybook dev -p 6006",
|
|
38
|
+
"test": "vitest",
|
|
39
|
+
"test:watch": "vitest",
|
|
40
|
+
"test:run": "vitest run",
|
|
41
|
+
"test:coverage": "vitest run --coverage",
|
|
42
|
+
"test:coverage:ui": "vitest run --coverage --open"
|
|
38
43
|
},
|
|
39
44
|
"dependencies": {
|
|
40
45
|
"@dnd-kit/core": "^6.3.1",
|
|
@@ -43,9 +48,15 @@
|
|
|
43
48
|
"@headlessui/react": "^2.2.9",
|
|
44
49
|
"@heroicons/react": "^2.2.0",
|
|
45
50
|
"@hookform/resolvers": "^5.2.2",
|
|
51
|
+
"@monaco-editor/react": "^4.7.0",
|
|
52
|
+
"@types/file-saver": "^2.0.7",
|
|
53
|
+
"@types/jszip": "^3.4.0",
|
|
46
54
|
"clsx": "^2.1.1",
|
|
55
|
+
"file-saver": "^2.0.5",
|
|
47
56
|
"i18next": "^25.6.2",
|
|
48
57
|
"immer": "^10.2.0",
|
|
58
|
+
"jszip": "^3.10.1",
|
|
59
|
+
"prettier": "^3.7.4",
|
|
49
60
|
"react-hook-form": "^7.66.0",
|
|
50
61
|
"react-i18next": "^16.3.3",
|
|
51
62
|
"react-router-dom": "^7.9.6",
|
|
@@ -71,6 +82,8 @@
|
|
|
71
82
|
"@storybook/test": "^8.6.14",
|
|
72
83
|
"@tailwindcss/postcss": "^4.1.8",
|
|
73
84
|
"@tailwindcss/vite": "^4.1.7",
|
|
85
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
86
|
+
"@testing-library/react": "^16.3.1",
|
|
74
87
|
"@types/i18next": "^12.1.0",
|
|
75
88
|
"@types/node": "^22.15.29",
|
|
76
89
|
"@types/react": "^19.1.6",
|
|
@@ -86,6 +99,7 @@
|
|
|
86
99
|
"eslint-plugin-react-refresh": "^0.4.19",
|
|
87
100
|
"eslint-plugin-storybook": "^0.12.0",
|
|
88
101
|
"globals": "^16.0.0",
|
|
102
|
+
"jsdom": "^27.4.0",
|
|
89
103
|
"playwright": "^1.52.0",
|
|
90
104
|
"postcss": "^8.5.4",
|
|
91
105
|
"storybook": "^8.6.14",
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { ServicesAdapter } from "../adapters/types";
|
|
2
|
-
/**
|
|
3
|
-
* Parses TypeScript/JavaScript service code to extract exported function names
|
|
4
|
-
* and generates a mock ServicesAdapter.
|
|
5
|
-
*/
|
|
6
|
-
export declare function generateAdapterFromCode(code: string, prefix?: string): ServicesAdapter;
|