@saastro/forms 0.6.2 → 0.7.0
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.d.ts +83 -2
- package/dist/index.js +92 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -815,6 +815,10 @@ type StepCondition = ConditionGroup & {
|
|
|
815
815
|
type Step = {
|
|
816
816
|
/** Step identifier. Optional when using `Record<string, Step>` — the key serves as the id. */
|
|
817
817
|
id?: string;
|
|
818
|
+
/** Human-facing step title (set by the builder; rendered in multi-step UIs). i18n-translatable. */
|
|
819
|
+
title?: string;
|
|
820
|
+
/** Human-facing step description. i18n-translatable. */
|
|
821
|
+
description?: string;
|
|
818
822
|
fields: string[];
|
|
819
823
|
next?: StepCondition[];
|
|
820
824
|
defaultNext?: string;
|
|
@@ -1221,6 +1225,53 @@ interface SubmitConfirmationConfig {
|
|
|
1221
1225
|
*/
|
|
1222
1226
|
showOnce?: boolean;
|
|
1223
1227
|
}
|
|
1228
|
+
/** Overlay de traducciones para un idioma concreto. Solo los campos a
|
|
1229
|
+
* traducir; lo no especificado cae al config base. */
|
|
1230
|
+
interface LocaleOverlay {
|
|
1231
|
+
fields?: Record<string, {
|
|
1232
|
+
label?: string;
|
|
1233
|
+
placeholder?: string;
|
|
1234
|
+
helperText?: string;
|
|
1235
|
+
description?: string;
|
|
1236
|
+
/** Opciones traducidas; se casan con las del base por `value`. */
|
|
1237
|
+
options?: Array<{
|
|
1238
|
+
value: string | number;
|
|
1239
|
+
label: string;
|
|
1240
|
+
}>;
|
|
1241
|
+
}>;
|
|
1242
|
+
buttons?: {
|
|
1243
|
+
submit?: {
|
|
1244
|
+
label?: string;
|
|
1245
|
+
};
|
|
1246
|
+
next?: {
|
|
1247
|
+
label?: string;
|
|
1248
|
+
};
|
|
1249
|
+
back?: {
|
|
1250
|
+
label?: string;
|
|
1251
|
+
};
|
|
1252
|
+
};
|
|
1253
|
+
steps?: Record<string, {
|
|
1254
|
+
title?: string;
|
|
1255
|
+
description?: string;
|
|
1256
|
+
}>;
|
|
1257
|
+
messages?: {
|
|
1258
|
+
success?: string;
|
|
1259
|
+
error?: string;
|
|
1260
|
+
};
|
|
1261
|
+
}
|
|
1262
|
+
/**
|
|
1263
|
+
* Traducciones del formulario. El config base contiene los strings del
|
|
1264
|
+
* `defaultLocale`; `translations[locale]` aporta overlays que se mergean
|
|
1265
|
+
* sobre la base al renderizar (ver `applyLocale`). Aditivo y opcional.
|
|
1266
|
+
*/
|
|
1267
|
+
interface FormI18n {
|
|
1268
|
+
/** Idioma en el que están escritos los strings base del config. */
|
|
1269
|
+
defaultLocale?: string;
|
|
1270
|
+
/** Idiomas disponibles (para el switcher del builder, p.ej. ['es','en','fr']). */
|
|
1271
|
+
locales?: string[];
|
|
1272
|
+
/** Overlays por idioma. */
|
|
1273
|
+
translations?: Record<string, LocaleOverlay>;
|
|
1274
|
+
}
|
|
1224
1275
|
interface FormConfig {
|
|
1225
1276
|
formId: string;
|
|
1226
1277
|
fields: Fields;
|
|
@@ -1258,6 +1309,14 @@ interface FormConfig {
|
|
|
1258
1309
|
* Define si las acciones se ejecutan en paralelo o secuencial.
|
|
1259
1310
|
*/
|
|
1260
1311
|
submitExecution?: SubmitExecutionConfig;
|
|
1312
|
+
/**
|
|
1313
|
+
* Idioma activo a renderizar. Cuando se setea (y hay `i18n.translations`
|
|
1314
|
+
* para ese locale), `useFormState` aplica el overlay sobre el config base.
|
|
1315
|
+
* Lo pasa el consumidor (p.ej. `HubForm locale=`).
|
|
1316
|
+
*/
|
|
1317
|
+
locale?: string;
|
|
1318
|
+
/** Traducciones por idioma (overlays). Ver `FormI18n` / `applyLocale`. */
|
|
1319
|
+
i18n?: FormI18n;
|
|
1261
1320
|
}
|
|
1262
1321
|
|
|
1263
1322
|
/**
|
|
@@ -3460,6 +3519,7 @@ declare function useFormState({ config: rawConfig, fields: rawFields, steps: raw
|
|
|
3460
3519
|
fields: Fields;
|
|
3461
3520
|
steps?: Steps;
|
|
3462
3521
|
}): {
|
|
3522
|
+
config: FormConfig;
|
|
3463
3523
|
currentStepId: string;
|
|
3464
3524
|
loading: boolean;
|
|
3465
3525
|
submitted: boolean;
|
|
@@ -3861,6 +3921,13 @@ interface HubFormProps {
|
|
|
3861
3921
|
hubUrl?: string;
|
|
3862
3922
|
siteId: string;
|
|
3863
3923
|
formSlug: string;
|
|
3924
|
+
/**
|
|
3925
|
+
* Active locale to render the form in. When the fetched schema carries
|
|
3926
|
+
* `i18n.translations[locale]`, labels/placeholders/options/buttons/steps
|
|
3927
|
+
* are translated; untranslated strings fall back to the base. Pass the
|
|
3928
|
+
* host page's current language (e.g. Astro `Astro.locals.lang`).
|
|
3929
|
+
*/
|
|
3930
|
+
locale?: string;
|
|
3864
3931
|
/** Custom UI while the schema is being fetched. Defaults to a skeleton. */
|
|
3865
3932
|
loadingFallback?: ReactNode;
|
|
3866
3933
|
/**
|
|
@@ -3893,7 +3960,21 @@ interface HubFormProps {
|
|
|
3893
3960
|
*/
|
|
3894
3961
|
formProps?: Omit<FormProps, 'config'>;
|
|
3895
3962
|
}
|
|
3896
|
-
declare function HubForm({ hubUrl, siteId, formSlug, loadingFallback, errorFallback, unconfiguredFallback, successFallback, onSuccess, onError, formProps, }: HubFormProps): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | React$1.ReactPortal | React$1.ReactElement<unknown, string | React$1.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element;
|
|
3963
|
+
declare function HubForm({ hubUrl, siteId, formSlug, locale, loadingFallback, errorFallback, unconfiguredFallback, successFallback, onSuccess, onError, formProps, }: HubFormProps): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | React$1.ReactPortal | React$1.ReactElement<unknown, string | React$1.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element;
|
|
3964
|
+
|
|
3965
|
+
/**
|
|
3966
|
+
* Applies a locale's translation overlay onto a base FormConfig.
|
|
3967
|
+
*
|
|
3968
|
+
* The base config holds the strings for `i18n.defaultLocale`. This merges
|
|
3969
|
+
* `config.i18n.translations[locale]` on top — labels, placeholders, helper
|
|
3970
|
+
* text, descriptions, option labels (matched by `value`), button labels,
|
|
3971
|
+
* step titles/descriptions and success/error messages. Anything not
|
|
3972
|
+
* translated falls back to the base value (graceful degradation).
|
|
3973
|
+
*
|
|
3974
|
+
* Pure: returns a new config and never mutates the input. A missing locale
|
|
3975
|
+
* or empty overlay is a no-op (returns the original reference).
|
|
3976
|
+
*/
|
|
3977
|
+
declare function applyLocale(config: FormConfig, locale?: string): FormConfig;
|
|
3897
3978
|
|
|
3898
3979
|
/**
|
|
3899
3980
|
* Test Data Generator — generates realistic field values for form testing.
|
|
@@ -3949,4 +4030,4 @@ declare function getFieldClass(formLayout?: {
|
|
|
3949
4030
|
*/
|
|
3950
4031
|
declare function getHiddenClasses(hidden?: Partial<Record<Breakpoint, 'visible' | 'hidden'>>): string;
|
|
3951
4032
|
|
|
3952
|
-
export { type AccordionContentProps, type AccordionItemProps, type AccordionProps, type AccordionTriggerProps, BUILD_METHODS, BUILTIN_RESOLVERS, type BaseFieldProps, type Breakpoint$1 as Breakpoint, type BuiltinTransform, type ButtonCardFieldProps, type ButtonCardOption, type ButtonCheckboxFieldProps, type ButtonConfig, type ButtonProps, type ButtonRadioFieldProps, COMMON_CLASSES, COMMON_METHODS, COMMON_STRINGS, type CalendarProps, type CheckboxFieldProps, type CheckboxGroupFieldProps, type CheckboxProps, type ColumnsValue, type ComboboxFieldProps, type CommandEmptyProps, type CommandFieldProps, type CommandGroupProps, type CommandInputProps, type CommandItemProps, type CommandListProps, type CommandProps, type ComponentName, type ComponentOverrides, ComponentProvider, type ComponentProviderProps, type ComponentRegistry, type ComponentRegistryInput, ComponentResolver, type ComponentResolverConfig, type Condition, type ConditionGroup, type ConditionOperator, type CreateHubFormSubmitOptions, type CurrencyFieldProps, type CustomSubmitAction, type CustomSubmitConfig, DEFAULT_HUB_URL, type DatabowlConfig, type DateFieldProps, type DateRangeFieldProps, type DefaultSubmitConfig, type DefinePlugin, type DialogContentProps, type DialogDescriptionProps, type DialogHeaderProps, type DialogProps, type DialogTitleProps, type DialogTriggerProps, type EmailProvider, type EmailSubmitAction, type EndpointConfig, FIELD_DEFAULTS, FieldBuilder, type FieldConfig, type FieldDescriptionProps, type FieldErrorProps, type FieldLabelProps, type FieldLayoutConfig, type FieldMapEntry, type FieldMapping, type FieldMappingConfig, type FieldProps, FieldRenderer, type FieldResolver, type FieldTransformFn, type Fields, type FileFieldProps, Form, FormBuilder, type FormButtonProps, type FormButtons, FormComponentsProvider, type FormComponentsProviderProps, type FormConfig, type FormControlProps, type FormFieldProps, type FormLayout, type FormPlugin, type FormProps, type FormRef, type FormStepsInfo, type GapValue, type GlobModules, type HiddenFieldProps, type HtmlFieldProps, type HttpAuthConfig, type HttpBodyConfig, type HttpEndpointConfig, type HttpRetryConfig, type HttpSubmitAction, HubForm, type HubFormProps, type InputGroupFieldProps, type InputOTPGroupProps, type InputOTPProps, type InputOTPSlotProps, type InputProps, type InputSize, type IntegrationSubmitAction, InternalComponentProvider, type InternalComponentProviderProps, type LabelProps, MissingComponentFallback, type MissingComponentFallbackProps, type NativeSelectFieldProps, type NativeSelectProps, OPTION_BASED_TYPES, type Option, type OtpFieldProps, type PartialComponentRegistry, PluginManager, type PopoverContentProps, type PopoverProps, type PopoverTriggerProps, type PropertyMapping, type RadioFieldProps, type RadioGroupItemProps, type RadioGroupProps, type RangeFieldProps, type RecaptchaConfig, type RecaptchaPluginConfig, type RepeaterFieldProps, type ResolvedComponents, SUSPENSE_CONFIG, type SchemaType, type SelectContentProps, type SelectFieldProps, type SelectItemProps, type SelectProps, type SelectTriggerProps, type SelectValueProps, type SeparatorProps, type SerializableFieldResolver, type SerializationHint, type SliderFieldProps, type SliderProps, type Step, type StepCondition, type StepInfo, type StepStatus, type Steps, StepsAccordion, StepsNavigation, StepsProgress, type SubmitAction, type SubmitActionCondition, type SubmitActionNode, type SubmitActionResult, type SubmitActionType, type SubmitActionsResult, type SubmitConfig, type SubmitConfirmationConfig, type SubmitExecutionConfig, type SubmitTrigger, type SubmitTriggerType, type SubmitType, type SwitchFieldProps, type SwitchGroupFieldProps, type SwitchProps, TYPE_SPECIFIC_PROPERTIES, type TestDataLocale, type TestDataOptions, type TextFieldProps, type TextareaFieldProps, type TextareaProps, type TooltipContentProps, type TooltipProps, type TooltipProviderProps, type TooltipTriggerProps, type TurnstilePluginConfig, type UseSubmitConfirmationReturn, VALIDATION_METHODS, type ValidateComponentRegistry, type ValidationContext, type ValidationPresetMeta, type ValidationRules, type WebhookSubmitAction, analyticsPlugin, applyBuiltinTransform, applyFieldMapping, applyFieldMappingSync, applyFieldTransforms, applyTransform, autosavePlugin, buildRequiredOnlySchema, compileValidationRules, configureComponents, coreComponents, createComponentRegistry, createHubFormSubmit, createMissingComponentPlaceholder, createShadcnRegistry, databowlAction, databowlPlugin, defaultSubmit, definePlugin, detectLocale, executeCustomAction, executeEmailAction, executeHttpAction, executeSubmitAction, executeSubmitActions, executeSubmitActionsByTrigger, executeWebhookAction, fieldTypeComponents, generateFieldValue, generateTestData, getActionsByTrigger, getAllKnownMethods, getAvailablePresets, getComponentResolver, getFieldClass, getFormGridClass, getHiddenClasses, getInstallCommand, getMinDelayMs, getMissingComponents, getRequiredComponents, globalPluginManager, groupMissingByPackage, iconVariants, iconVariantsConfig, inputVariants, inputVariantsConfig, isAdvancedMapping, isValidationRules, isZodSchema, localStoragePlugin, mergeComponentRegistries, parseGlobModules, pxToRem, recaptchaPlugin, registerPreset, resolvePreset, resolveValue, resolveValueSync, textareaVariants, textareaVariantsConfig, turnstilePlugin, useComponentMode, useComponents, useComputedFields, useFormLayout, useFormState, useFormStepsInfo, useHasComponentProvider, useHiddenFieldResolvers, usePartialComponents, useRecaptcha, useSubmitActionTriggers, useSubmitConfirmation, withComponents };
|
|
4033
|
+
export { type AccordionContentProps, type AccordionItemProps, type AccordionProps, type AccordionTriggerProps, BUILD_METHODS, BUILTIN_RESOLVERS, type BaseFieldProps, type Breakpoint$1 as Breakpoint, type BuiltinTransform, type ButtonCardFieldProps, type ButtonCardOption, type ButtonCheckboxFieldProps, type ButtonConfig, type ButtonProps, type ButtonRadioFieldProps, COMMON_CLASSES, COMMON_METHODS, COMMON_STRINGS, type CalendarProps, type CheckboxFieldProps, type CheckboxGroupFieldProps, type CheckboxProps, type ColumnsValue, type ComboboxFieldProps, type CommandEmptyProps, type CommandFieldProps, type CommandGroupProps, type CommandInputProps, type CommandItemProps, type CommandListProps, type CommandProps, type ComponentName, type ComponentOverrides, ComponentProvider, type ComponentProviderProps, type ComponentRegistry, type ComponentRegistryInput, ComponentResolver, type ComponentResolverConfig, type Condition, type ConditionGroup, type ConditionOperator, type CreateHubFormSubmitOptions, type CurrencyFieldProps, type CustomSubmitAction, type CustomSubmitConfig, DEFAULT_HUB_URL, type DatabowlConfig, type DateFieldProps, type DateRangeFieldProps, type DefaultSubmitConfig, type DefinePlugin, type DialogContentProps, type DialogDescriptionProps, type DialogHeaderProps, type DialogProps, type DialogTitleProps, type DialogTriggerProps, type EmailProvider, type EmailSubmitAction, type EndpointConfig, FIELD_DEFAULTS, FieldBuilder, type FieldConfig, type FieldDescriptionProps, type FieldErrorProps, type FieldLabelProps, type FieldLayoutConfig, type FieldMapEntry, type FieldMapping, type FieldMappingConfig, type FieldProps, FieldRenderer, type FieldResolver, type FieldTransformFn, type Fields, type FileFieldProps, Form, FormBuilder, type FormButtonProps, type FormButtons, FormComponentsProvider, type FormComponentsProviderProps, type FormConfig, type FormControlProps, type FormFieldProps, type FormI18n, type FormLayout, type FormPlugin, type FormProps, type FormRef, type FormStepsInfo, type GapValue, type GlobModules, type HiddenFieldProps, type HtmlFieldProps, type HttpAuthConfig, type HttpBodyConfig, type HttpEndpointConfig, type HttpRetryConfig, type HttpSubmitAction, HubForm, type HubFormProps, type InputGroupFieldProps, type InputOTPGroupProps, type InputOTPProps, type InputOTPSlotProps, type InputProps, type InputSize, type IntegrationSubmitAction, InternalComponentProvider, type InternalComponentProviderProps, type LabelProps, type LocaleOverlay, MissingComponentFallback, type MissingComponentFallbackProps, type NativeSelectFieldProps, type NativeSelectProps, OPTION_BASED_TYPES, type Option, type OtpFieldProps, type PartialComponentRegistry, PluginManager, type PopoverContentProps, type PopoverProps, type PopoverTriggerProps, type PropertyMapping, type RadioFieldProps, type RadioGroupItemProps, type RadioGroupProps, type RangeFieldProps, type RecaptchaConfig, type RecaptchaPluginConfig, type RepeaterFieldProps, type ResolvedComponents, SUSPENSE_CONFIG, type SchemaType, type SelectContentProps, type SelectFieldProps, type SelectItemProps, type SelectProps, type SelectTriggerProps, type SelectValueProps, type SeparatorProps, type SerializableFieldResolver, type SerializationHint, type SliderFieldProps, type SliderProps, type Step, type StepCondition, type StepInfo, type StepStatus, type Steps, StepsAccordion, StepsNavigation, StepsProgress, type SubmitAction, type SubmitActionCondition, type SubmitActionNode, type SubmitActionResult, type SubmitActionType, type SubmitActionsResult, type SubmitConfig, type SubmitConfirmationConfig, type SubmitExecutionConfig, type SubmitTrigger, type SubmitTriggerType, type SubmitType, type SwitchFieldProps, type SwitchGroupFieldProps, type SwitchProps, TYPE_SPECIFIC_PROPERTIES, type TestDataLocale, type TestDataOptions, type TextFieldProps, type TextareaFieldProps, type TextareaProps, type TooltipContentProps, type TooltipProps, type TooltipProviderProps, type TooltipTriggerProps, type TurnstilePluginConfig, type UseSubmitConfirmationReturn, VALIDATION_METHODS, type ValidateComponentRegistry, type ValidationContext, type ValidationPresetMeta, type ValidationRules, type WebhookSubmitAction, analyticsPlugin, applyBuiltinTransform, applyFieldMapping, applyFieldMappingSync, applyFieldTransforms, applyLocale, applyTransform, autosavePlugin, buildRequiredOnlySchema, compileValidationRules, configureComponents, coreComponents, createComponentRegistry, createHubFormSubmit, createMissingComponentPlaceholder, createShadcnRegistry, databowlAction, databowlPlugin, defaultSubmit, definePlugin, detectLocale, executeCustomAction, executeEmailAction, executeHttpAction, executeSubmitAction, executeSubmitActions, executeSubmitActionsByTrigger, executeWebhookAction, fieldTypeComponents, generateFieldValue, generateTestData, getActionsByTrigger, getAllKnownMethods, getAvailablePresets, getComponentResolver, getFieldClass, getFormGridClass, getHiddenClasses, getInstallCommand, getMinDelayMs, getMissingComponents, getRequiredComponents, globalPluginManager, groupMissingByPackage, iconVariants, iconVariantsConfig, inputVariants, inputVariantsConfig, isAdvancedMapping, isValidationRules, isZodSchema, localStoragePlugin, mergeComponentRegistries, parseGlobModules, pxToRem, recaptchaPlugin, registerPreset, resolvePreset, resolveValue, resolveValueSync, textareaVariants, textareaVariantsConfig, turnstilePlugin, useComponentMode, useComponents, useComputedFields, useFormLayout, useFormState, useFormStepsInfo, useHasComponentProvider, useHiddenFieldResolvers, usePartialComponents, useRecaptcha, useSubmitActionTriggers, useSubmitConfirmation, withComponents };
|
package/dist/index.js
CHANGED
|
@@ -2611,6 +2611,82 @@ function compileValidationRules(rules, fieldType) {
|
|
|
2611
2611
|
return buildStringSchema(mergedRules);
|
|
2612
2612
|
}
|
|
2613
2613
|
|
|
2614
|
+
// src/utils/applyLocale.ts
|
|
2615
|
+
function applyLocale(config, locale) {
|
|
2616
|
+
const overlay = locale ? config.i18n?.translations?.[locale] : void 0;
|
|
2617
|
+
if (!overlay) return config;
|
|
2618
|
+
return {
|
|
2619
|
+
...config,
|
|
2620
|
+
fields: mergeFields(config.fields, overlay.fields),
|
|
2621
|
+
...overlay.steps ? { steps: mergeSteps(config.steps, overlay.steps) } : {},
|
|
2622
|
+
...overlay.buttons ? { buttons: mergeButtons(config.buttons, overlay.buttons) } : {},
|
|
2623
|
+
...mergeMessages(config, overlay.messages)
|
|
2624
|
+
};
|
|
2625
|
+
}
|
|
2626
|
+
function mergeFields(fields, tFields) {
|
|
2627
|
+
if (!tFields) return fields;
|
|
2628
|
+
const out = {};
|
|
2629
|
+
for (const [name, field] of Object.entries(fields)) {
|
|
2630
|
+
const t = tFields[name];
|
|
2631
|
+
if (!t) {
|
|
2632
|
+
out[name] = field;
|
|
2633
|
+
continue;
|
|
2634
|
+
}
|
|
2635
|
+
const merged = { ...field };
|
|
2636
|
+
if (t.label !== void 0) merged.label = t.label;
|
|
2637
|
+
if (t.placeholder !== void 0) merged.placeholder = t.placeholder;
|
|
2638
|
+
if (t.helperText !== void 0) merged.helperText = t.helperText;
|
|
2639
|
+
if (t.description !== void 0) merged.description = t.description;
|
|
2640
|
+
if (t.options) merged.options = mergeOptions(merged.options, t.options);
|
|
2641
|
+
out[name] = merged;
|
|
2642
|
+
}
|
|
2643
|
+
return out;
|
|
2644
|
+
}
|
|
2645
|
+
function mergeOptions(baseOptions, tOptions) {
|
|
2646
|
+
if (!Array.isArray(baseOptions)) return baseOptions;
|
|
2647
|
+
const byValue = new Map(tOptions.map((o) => [o.value, o.label]));
|
|
2648
|
+
return baseOptions.map((opt) => {
|
|
2649
|
+
if (opt && typeof opt === "object" && "value" in opt) {
|
|
2650
|
+
const label = byValue.get(opt.value);
|
|
2651
|
+
if (label !== void 0) return { ...opt, label };
|
|
2652
|
+
}
|
|
2653
|
+
return opt;
|
|
2654
|
+
});
|
|
2655
|
+
}
|
|
2656
|
+
function mergeSteps(steps, tSteps) {
|
|
2657
|
+
const out = {};
|
|
2658
|
+
for (const [id, step] of Object.entries(steps)) {
|
|
2659
|
+
const t = tSteps[id];
|
|
2660
|
+
out[id] = t ? {
|
|
2661
|
+
...step,
|
|
2662
|
+
...t.title !== void 0 ? { title: t.title } : {},
|
|
2663
|
+
...t.description !== void 0 ? { description: t.description } : {}
|
|
2664
|
+
} : step;
|
|
2665
|
+
}
|
|
2666
|
+
return out;
|
|
2667
|
+
}
|
|
2668
|
+
function mergeButtons(buttons, tButtons) {
|
|
2669
|
+
const merged = { ...buttons ?? {} };
|
|
2670
|
+
for (const key of ["submit", "next", "back"]) {
|
|
2671
|
+
const tLabel = tButtons[key]?.label;
|
|
2672
|
+
if (tLabel !== void 0) {
|
|
2673
|
+
merged[key] = { ...merged[key] ?? { type: key }, label: tLabel };
|
|
2674
|
+
}
|
|
2675
|
+
}
|
|
2676
|
+
return merged;
|
|
2677
|
+
}
|
|
2678
|
+
function mergeMessages(config, tMessages) {
|
|
2679
|
+
if (!tMessages) return {};
|
|
2680
|
+
const out = {};
|
|
2681
|
+
if (tMessages.success !== void 0 && typeof config.successMessage !== "function") {
|
|
2682
|
+
out.successMessage = tMessages.success;
|
|
2683
|
+
}
|
|
2684
|
+
if (tMessages.error !== void 0 && typeof config.errorMessage !== "function") {
|
|
2685
|
+
out.errorMessage = tMessages.error;
|
|
2686
|
+
}
|
|
2687
|
+
return out;
|
|
2688
|
+
}
|
|
2689
|
+
|
|
2614
2690
|
// src/hooks/useFormSteps.ts
|
|
2615
2691
|
import { useState as useState2 } from "react";
|
|
2616
2692
|
function useFormSteps(steps, initialStepId) {
|
|
@@ -2939,10 +3015,8 @@ function useFormState({
|
|
|
2939
3015
|
steps: rawSteps
|
|
2940
3016
|
}) {
|
|
2941
3017
|
const config = useMemo3(() => {
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
}
|
|
2945
|
-
return rawConfig;
|
|
3018
|
+
const transformed = rawConfig.pluginManager ? rawConfig.pluginManager.transformConfig(rawConfig) : rawConfig;
|
|
3019
|
+
return transformed.locale ? applyLocale(transformed, transformed.locale) : transformed;
|
|
2946
3020
|
}, [rawConfig]);
|
|
2947
3021
|
const fields = config.fields;
|
|
2948
3022
|
const steps = config.steps;
|
|
@@ -3106,6 +3180,10 @@ function useFormState({
|
|
|
3106
3180
|
return success;
|
|
3107
3181
|
};
|
|
3108
3182
|
return {
|
|
3183
|
+
// The locale-resolved config (plugin transforms + i18n overlay applied).
|
|
3184
|
+
// Consumers MUST render from this, not the raw config prop, so translated
|
|
3185
|
+
// labels/placeholders/options/button labels/step titles reach the UI.
|
|
3186
|
+
config,
|
|
3109
3187
|
currentStepId,
|
|
3110
3188
|
loading,
|
|
3111
3189
|
submitted,
|
|
@@ -3867,9 +3945,12 @@ function getInstallCommand(missing) {
|
|
|
3867
3945
|
|
|
3868
3946
|
// src/components/Form.tsx
|
|
3869
3947
|
import { Fragment as Fragment2, jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
3870
|
-
var FormInner = forwardRef(function FormInner2({ config, onSubmit, onError, className }, ref) {
|
|
3948
|
+
var FormInner = forwardRef(function FormInner2({ config: rawConfig, onSubmit, onError, className }, ref) {
|
|
3871
3949
|
const components = useComponents();
|
|
3872
3950
|
const {
|
|
3951
|
+
// Locale-resolved config (plugin transforms + i18n overlay). Render from
|
|
3952
|
+
// this, NOT rawConfig, so translated labels/placeholders/buttons show up.
|
|
3953
|
+
config,
|
|
3873
3954
|
currentStepId,
|
|
3874
3955
|
loading,
|
|
3875
3956
|
submitted,
|
|
@@ -3883,9 +3964,9 @@ var FormInner = forwardRef(function FormInner2({ config, onSubmit, onError, clas
|
|
|
3883
3964
|
handleSubmit,
|
|
3884
3965
|
stepHistory
|
|
3885
3966
|
} = useFormState({
|
|
3886
|
-
config,
|
|
3887
|
-
fields:
|
|
3888
|
-
steps:
|
|
3967
|
+
config: rawConfig,
|
|
3968
|
+
fields: rawConfig.fields,
|
|
3969
|
+
steps: rawConfig.steps
|
|
3889
3970
|
});
|
|
3890
3971
|
useImperativeHandle(
|
|
3891
3972
|
ref,
|
|
@@ -7120,6 +7201,7 @@ function HubForm({
|
|
|
7120
7201
|
hubUrl,
|
|
7121
7202
|
siteId,
|
|
7122
7203
|
formSlug,
|
|
7204
|
+
locale,
|
|
7123
7205
|
loadingFallback,
|
|
7124
7206
|
errorFallback,
|
|
7125
7207
|
unconfiguredFallback,
|
|
@@ -7205,6 +7287,7 @@ function HubForm({
|
|
|
7205
7287
|
const config = {
|
|
7206
7288
|
...state.schema,
|
|
7207
7289
|
submit: wrappedSubmit,
|
|
7290
|
+
...locale ? { locale } : {},
|
|
7208
7291
|
...captcha ? { pluginManager: captcha.pm } : {}
|
|
7209
7292
|
};
|
|
7210
7293
|
return /* @__PURE__ */ jsxs11(Fragment3, { children: [
|
|
@@ -7495,6 +7578,7 @@ export {
|
|
|
7495
7578
|
applyFieldMapping,
|
|
7496
7579
|
applyFieldMappingSync,
|
|
7497
7580
|
applyFieldTransforms,
|
|
7581
|
+
applyLocale,
|
|
7498
7582
|
applyTransform,
|
|
7499
7583
|
autosavePlugin,
|
|
7500
7584
|
buildRequiredOnlySchema,
|