@dipusevilla/componentes-iu 1.1.0 → 1.1.1
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/index.cjs.js +33 -25
- package/dist/index.css +1 -1
- package/dist/index.es.js +17502 -15688
- package/dist/index.umd.js +34 -26
- package/dist/types/components/Checkbox.d.ts +3 -1
- package/dist/types/components/DateInput.d.ts +2 -0
- package/dist/types/components/SearchField.d.ts +3 -1
- package/dist/types/editor/adapters/inMemoryTranslationAdapter.d.ts +36 -0
- package/dist/types/editor/adapters/index.d.ts +2 -0
- package/dist/types/editor/adapters/types.d.ts +11 -0
- package/dist/types/editor/components/Palette.d.ts +3 -0
- package/dist/types/editor/components/TranslatableInput.d.ts +11 -0
- package/dist/types/editor/dnd/renderField.d.ts +1 -0
- package/dist/types/editor/utils/extractTranslations.d.ts +19 -0
- package/dist/types/i18n.d.ts +3 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/types/FormTypes.d.ts +2 -0
- package/dist/types/utils/translationHelpers.d.ts +59 -0
- package/package.json +1 -1
|
@@ -13,8 +13,10 @@ export interface CheckboxProps {
|
|
|
13
13
|
className?: string;
|
|
14
14
|
hasError?: boolean;
|
|
15
15
|
errorMessage?: string;
|
|
16
|
+
reserveErrorSpace?: boolean;
|
|
17
|
+
disableErrorPlaceholder?: boolean;
|
|
16
18
|
/** --- Modo no-RHF (headless) --- */
|
|
17
19
|
checked?: boolean;
|
|
18
20
|
onChange?: (checked: boolean) => void;
|
|
19
21
|
}
|
|
20
|
-
export declare function Checkbox({ control, name, rules, defaultValue, label, labelHidden, disabled, size, className, hasError, errorMessage, checked, onChange, }: CheckboxProps): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export declare function Checkbox({ control, name, rules, defaultValue, label, labelHidden, disabled, size, className, hasError, errorMessage, reserveErrorSpace, disableErrorPlaceholder, checked, onChange, }: CheckboxProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -15,6 +15,8 @@ export interface DateInputProps extends Omit<InputHTMLAttributes<HTMLInputElemen
|
|
|
15
15
|
labelHidden?: boolean;
|
|
16
16
|
hasError?: boolean;
|
|
17
17
|
errorMessage?: string;
|
|
18
|
+
reserveErrorSpace?: boolean;
|
|
19
|
+
disableErrorPlaceholder?: boolean;
|
|
18
20
|
disabled?: boolean;
|
|
19
21
|
className?: string;
|
|
20
22
|
}
|
|
@@ -24,6 +24,8 @@ export interface SearchFieldProps {
|
|
|
24
24
|
/** Icon props for input field */
|
|
25
25
|
prefixIcon?: HeroIconComponent;
|
|
26
26
|
suffixIcon?: HeroIconComponent;
|
|
27
|
+
reserveErrorSpace?: boolean;
|
|
28
|
+
disableErrorPlaceholder?: boolean;
|
|
27
29
|
}
|
|
28
|
-
export declare function SearchField({ name, control, searchFn, resolveByValue, label, size, width, disabled, searchMode, minChars, debounceMs, labelPrefixIcon, labelSuffixIcon, prefixIcon, suffixIcon, }: SearchFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
30
|
+
export declare function SearchField({ name, control, searchFn, resolveByValue, label, size, width, disabled, searchMode, minChars, debounceMs, labelPrefixIcon, labelSuffixIcon, prefixIcon, suffixIcon, reserveErrorSpace, disableErrorPlaceholder, }: SearchFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
29
31
|
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { TranslationAdapter } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Adaptador de traducción en memoria que usa i18next
|
|
4
|
+
* Guarda las traducciones en memoria y las sincroniza con i18next
|
|
5
|
+
*/
|
|
6
|
+
export declare class InMemoryTranslationAdapter implements TranslationAdapter {
|
|
7
|
+
private translations;
|
|
8
|
+
currentLanguage: string;
|
|
9
|
+
languages: string[];
|
|
10
|
+
constructor(languages?: string[], defaultLanguage?: string);
|
|
11
|
+
/**
|
|
12
|
+
* Obtiene una traducción
|
|
13
|
+
*/
|
|
14
|
+
getTranslation(key: string, lang?: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Actualiza o crea una traducción
|
|
17
|
+
*/
|
|
18
|
+
updateTranslation(key: string, value: string, lang?: string): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Obtiene todas las traducciones de un idioma
|
|
21
|
+
*/
|
|
22
|
+
getAllTranslations(lang?: string): Record<string, string>;
|
|
23
|
+
/**
|
|
24
|
+
* Exporta todas las traducciones en formato jerárquico
|
|
25
|
+
*/
|
|
26
|
+
exportTranslations(lang?: string): Record<string, any>;
|
|
27
|
+
/**
|
|
28
|
+
* Importa traducciones desde un objeto plano
|
|
29
|
+
*/
|
|
30
|
+
importTranslations(translations: Record<string, string>, lang?: string): void;
|
|
31
|
+
/**
|
|
32
|
+
* Limpia todas las traducciones en memoria
|
|
33
|
+
*/
|
|
34
|
+
clear(lang?: string): void;
|
|
35
|
+
}
|
|
36
|
+
export declare const inMemoryTranslationAdapter: InMemoryTranslationAdapter;
|
|
@@ -10,8 +10,19 @@ export type FileSystemAdapter = {
|
|
|
10
10
|
export type ServicesAdapter = {
|
|
11
11
|
registry: Record<string, unknown>;
|
|
12
12
|
};
|
|
13
|
+
export type TranslationAdapter = {
|
|
14
|
+
/** Obtiene el valor traducido para una clave */
|
|
15
|
+
getTranslation(key: string, lang?: string): string;
|
|
16
|
+
/** Actualiza o crea una traducción */
|
|
17
|
+
updateTranslation(key: string, value: string, lang?: string): Promise<void>;
|
|
18
|
+
/** Idioma actual del editor */
|
|
19
|
+
currentLanguage: string;
|
|
20
|
+
/** Lista de idiomas disponibles */
|
|
21
|
+
languages: string[];
|
|
22
|
+
};
|
|
13
23
|
export type EditorAdapters = {
|
|
14
24
|
fs: FileSystemAdapter;
|
|
15
25
|
services: ServicesAdapter;
|
|
26
|
+
translations?: TranslationAdapter;
|
|
16
27
|
baseDir: string;
|
|
17
28
|
};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { FieldKind } from "../utils/fieldKinds";
|
|
1
3
|
export declare const DRAG_MIME_FIELD = "application/x-ds-field-template";
|
|
2
4
|
export declare const DRAG_MIME_LAYOUT = "application/x-ds-layout-kind";
|
|
5
|
+
export declare const PALETTE_OVERLAY_PREVIEW: Partial<Record<FieldKind, React.ReactNode>>;
|
|
3
6
|
export declare function Palette(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { InputProps } from "../../components/Input";
|
|
2
|
+
interface TranslatableInputProps extends Omit<InputProps, "value" | "onChange"> {
|
|
3
|
+
value?: string;
|
|
4
|
+
onChange: (value: string) => void;
|
|
5
|
+
formId?: string;
|
|
6
|
+
fieldId?: string;
|
|
7
|
+
property: string;
|
|
8
|
+
contextType: "field" | "section" | "tab" | "row" | "form";
|
|
9
|
+
}
|
|
10
|
+
export declare function TranslatableInput({ value, onChange, formId, fieldId, property, contextType, label, ...props }: TranslatableInputProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -19,6 +19,7 @@ export type RenderFieldDeps = {
|
|
|
19
19
|
disabledMap: Record<string, boolean>;
|
|
20
20
|
registry?: Record<string, unknown>;
|
|
21
21
|
methods: any;
|
|
22
|
+
translateFn: (key: string, fallback?: string) => string;
|
|
22
23
|
};
|
|
23
24
|
export declare function renderFieldFactory(deps: RenderFieldDeps): (item: string | FieldSchema | ButtonField | InputGroupField) => React.ReactNode;
|
|
24
25
|
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { FormSchema } from "../../types/FormTypes";
|
|
2
|
+
/**
|
|
3
|
+
* Extrae todas las claves de traducción usadas en un schema de formulario
|
|
4
|
+
* @param schema - El schema del formulario
|
|
5
|
+
* @returns Un objeto con las claves de traducción encontradas (sin valores)
|
|
6
|
+
*/
|
|
7
|
+
export declare function extractTranslationKeys(schema: FormSchema): Record<string, string>;
|
|
8
|
+
/**
|
|
9
|
+
* Genera un JSON de traducciones con valores desde el adaptador de traducción o i18next
|
|
10
|
+
* @param schema - El schema del formulario
|
|
11
|
+
* @param translationAdapter - Adaptador de traducción para obtener los valores
|
|
12
|
+
* @param i18n - Instancia de i18next (opcional)
|
|
13
|
+
* @returns Un objeto JSON con las traducciones
|
|
14
|
+
*/
|
|
15
|
+
export declare function generateTranslationsJSON(schema: FormSchema, translationAdapter?: {
|
|
16
|
+
getTranslation: (key: string) => string;
|
|
17
|
+
getAllTranslations?: () => Record<string, string>;
|
|
18
|
+
exportTranslations?: () => Record<string, any>;
|
|
19
|
+
}, i18n?: any): Record<string, any>;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -70,4 +70,7 @@ export { Canvas } from "./editor/components/Canvas";
|
|
|
70
70
|
export { ColumnDropZone } from "./editor/components/ColumnDropZone";
|
|
71
71
|
export type { EditorAdapters, FileSystemAdapter, ServicesAdapter } from "./editor/adapters/types";
|
|
72
72
|
export { AdaptersProvider } from "./editor/context/adaptersProvider";
|
|
73
|
+
export { ChoiceGroup } from './components/ChoiceGroup';
|
|
74
|
+
export type { ChoiceGroupProps, ChoiceOption } from './components/ChoiceGroup';
|
|
75
|
+
export { setComponentsLanguage } from './i18n';
|
|
73
76
|
import './styles/index.css';
|
|
@@ -196,6 +196,8 @@ export type LayoutNode = {
|
|
|
196
196
|
* Esquema completo del formulario.
|
|
197
197
|
*/
|
|
198
198
|
export interface FormSchema {
|
|
199
|
+
/** Identificador único del formulario (usado para namespace de traducciones). */
|
|
200
|
+
formId?: string;
|
|
199
201
|
/** Esquema Yup para validación dinámica (opcional). */
|
|
200
202
|
validationSchema?: ObjectSchema<AnyObject>;
|
|
201
203
|
/** Layout principal: array de LayoutNode. */
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper para traducir valores de campos del formulario.
|
|
3
|
+
* Si el valor es una clave de traducción válida, la traduce.
|
|
4
|
+
* Si no existe la traducción, devuelve el valor original (compatibilidad retroactiva).
|
|
5
|
+
*
|
|
6
|
+
* @param t - Función de traducción de i18next
|
|
7
|
+
* @param value - Valor a traducir (puede ser clave o texto directo)
|
|
8
|
+
* @param fallback - Valor por defecto si value es undefined
|
|
9
|
+
* @returns Texto traducido o valor original
|
|
10
|
+
*/
|
|
11
|
+
export declare function translateField(t: ReturnType<typeof import('react-i18next').useTranslation>['t'], value: string | undefined, fallback?: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* Helper para traducir mensajes de validación.
|
|
14
|
+
* Maneja tanto strings simples como objetos con message.
|
|
15
|
+
*
|
|
16
|
+
* @param t - Función de traducción de i18next
|
|
17
|
+
* @param validation - Objeto de validación o string
|
|
18
|
+
* @returns Mensaje traducido
|
|
19
|
+
*/
|
|
20
|
+
export declare function translateValidationMessage(t: ReturnType<typeof import('react-i18next').useTranslation>['t'], validation: string | {
|
|
21
|
+
message: string;
|
|
22
|
+
} | boolean | undefined): string;
|
|
23
|
+
/**
|
|
24
|
+
* Helper para traducir un objeto de validación completo.
|
|
25
|
+
* Traduce todos los mensajes dentro del objeto de validación.
|
|
26
|
+
*
|
|
27
|
+
* @param t - Función de traducción de i18next
|
|
28
|
+
* @param validation - Objeto de validación del campo
|
|
29
|
+
* @returns Objeto de validación con mensajes traducidos
|
|
30
|
+
*/
|
|
31
|
+
export declare function translateValidation(t: ReturnType<typeof import('react-i18next').useTranslation>['t'], validation?: {
|
|
32
|
+
required?: boolean | string;
|
|
33
|
+
minLength?: {
|
|
34
|
+
value: number;
|
|
35
|
+
message: string;
|
|
36
|
+
};
|
|
37
|
+
maxLength?: {
|
|
38
|
+
value: number;
|
|
39
|
+
message: string;
|
|
40
|
+
};
|
|
41
|
+
pattern?: {
|
|
42
|
+
value: RegExp;
|
|
43
|
+
message: string;
|
|
44
|
+
};
|
|
45
|
+
}): {
|
|
46
|
+
required?: boolean | string;
|
|
47
|
+
minLength?: {
|
|
48
|
+
value: number;
|
|
49
|
+
message: string;
|
|
50
|
+
};
|
|
51
|
+
maxLength?: {
|
|
52
|
+
value: number;
|
|
53
|
+
message: string;
|
|
54
|
+
};
|
|
55
|
+
pattern?: {
|
|
56
|
+
value: RegExp;
|
|
57
|
+
message: string;
|
|
58
|
+
};
|
|
59
|
+
} | undefined;
|