@form-engine-ts/react 4.3.2 → 4.5.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/README.md +19 -2
- package/dist/index.cjs +559 -139
- package/dist/index.d.cts +97 -8
- package/dist/index.d.ts +97 -8
- package/dist/index.js +559 -136
- package/dist/styles.css +20 -9
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { QuestionType, FormField, ChoiceOption, FormPage, FormSchema, DisplayCondition, JsonValue, SchemaIssue, FormPolicy, Question, FieldOption, TranslationReport, ValidationError, FormValues, TranslationAdapter, AsyncTranslationAdapter, PopulateTranslationOptions, FormValue,
|
|
1
|
+
import { QuestionType, FormField, ChoiceOption, FormPage, FormSchema, DisplayCondition, JsonValue, SchemaIssue, FormPolicy, Question, FieldOption, TranslationReport, ValidationIssue, ValidationError, FormValues, TranslationAdapter, AsyncTranslationAdapter, PopulateTranslationOptions, FormValue, AnswerValidationResult, TranslationSlot, FieldType } from '@form-engine-ts/core';
|
|
2
2
|
export { QuestionType } from '@form-engine-ts/core';
|
|
3
3
|
import * as react from 'react';
|
|
4
|
-
import { ReactNode, ComponentType, KeyboardEvent, MouseEvent } from 'react';
|
|
4
|
+
import { ReactNode, ComponentType, KeyboardEvent, MouseEvent, CSSProperties } from 'react';
|
|
5
5
|
import { SensitiveDataFinding } from '@form-engine-ts/privacy';
|
|
6
6
|
|
|
7
7
|
interface SubmissionAttempt {
|
|
@@ -37,7 +37,13 @@ interface FormBuilderOptions {
|
|
|
37
37
|
readonly policy?: FormPolicy;
|
|
38
38
|
readonly idFactory?: (kind: BuilderIdKind, existingIds: ReadonlySet<string>) => string;
|
|
39
39
|
readonly factories?: BuilderFactories;
|
|
40
|
+
readonly fieldEditorMode?: FieldEditorMode;
|
|
41
|
+
readonly activeFieldId?: string;
|
|
42
|
+
readonly defaultActiveFieldId?: string;
|
|
43
|
+
readonly onActiveFieldChange?: (fieldId: string | undefined) => void;
|
|
40
44
|
}
|
|
45
|
+
type FieldEditorMode = "all" | "single";
|
|
46
|
+
type UseFormBuilderOptions = FormBuilderOptions;
|
|
41
47
|
type BuilderActionError = {
|
|
42
48
|
readonly type: "invalid_id";
|
|
43
49
|
readonly kind: BuilderIdKind;
|
|
@@ -104,8 +110,19 @@ interface FormBuilderResult {
|
|
|
104
110
|
readonly addLocale: (locale: string) => BuilderActionResult;
|
|
105
111
|
readonly setDefaultLocale: (locale: string) => BuilderActionResult;
|
|
106
112
|
readonly validationIssues: readonly SchemaIssue[];
|
|
113
|
+
readonly activeFieldId?: string;
|
|
114
|
+
readonly setActiveFieldId?: (fieldId: string | undefined) => void;
|
|
115
|
+
readonly getFieldEditorProps?: (fieldId: string) => {
|
|
116
|
+
readonly isActive: boolean;
|
|
117
|
+
readonly isVisible: boolean;
|
|
118
|
+
readonly onSelect: () => void;
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
interface UseFormBuilderResult extends FormBuilderResult {
|
|
122
|
+
readonly setActiveFieldId: (fieldId: string | undefined) => void;
|
|
123
|
+
readonly getFieldEditorProps: NonNullable<FormBuilderResult["getFieldEditorProps"]>;
|
|
107
124
|
}
|
|
108
|
-
declare function useFormBuilder({ schema, onChange, policy, idFactory, factories }: FormBuilderOptions): FormBuilderResult;
|
|
125
|
+
declare function useFormBuilder({ schema, onChange, policy, idFactory, factories, fieldEditorMode, activeFieldId: controlledActiveFieldId, defaultActiveFieldId, onActiveFieldChange }: FormBuilderOptions): FormBuilderResult;
|
|
109
126
|
|
|
110
127
|
interface SubmissionReceipt {
|
|
111
128
|
readonly formId: string;
|
|
@@ -376,7 +393,11 @@ interface BuilderTranslationActionsSlotProps extends BuilderSlotBaseProps {
|
|
|
376
393
|
readonly onClearTranslationError?: () => void;
|
|
377
394
|
readonly translationAdapterAvailable?: boolean;
|
|
378
395
|
}
|
|
379
|
-
type FormBuilderSectionName = "basicSettings" | "completionMessage" | "questions" | "addQuestion" | "localization";
|
|
396
|
+
type FormBuilderSectionName = "basicSettings" | "completionMessage" | "questions" | "addQuestion" | "localization" | "submissionSettings";
|
|
397
|
+
interface FormBuilderSubmissionSettingsOptions {
|
|
398
|
+
readonly enabled: boolean;
|
|
399
|
+
readonly placement?: "beforeQuestions" | "afterQuestions" | "bottom";
|
|
400
|
+
}
|
|
380
401
|
interface FormBuilderSlots {
|
|
381
402
|
readonly toolbar?: ComponentType<BuilderToolbarSlotProps>;
|
|
382
403
|
readonly fieldEditor?: ComponentType<BuilderFieldEditorSlotProps>;
|
|
@@ -478,13 +499,23 @@ type SubmissionGuardResult = {
|
|
|
478
499
|
type SubmissionGuard = (schema: FormSchema, values: Record<string, unknown>) => SubmissionGuardResult | Promise<SubmissionGuardResult>;
|
|
479
500
|
type FormSuccessRenderMode = "append" | "replace";
|
|
480
501
|
type ChoiceFieldLayoutMode = "default" | "grouped";
|
|
502
|
+
interface ChoiceFieldTypeLayoutMap {
|
|
503
|
+
readonly radio?: ChoiceFieldLayoutMode;
|
|
504
|
+
readonly checkbox?: ChoiceFieldLayoutMode;
|
|
505
|
+
readonly "multi-select"?: ChoiceFieldLayoutMode;
|
|
506
|
+
readonly select?: ChoiceFieldLayoutMode;
|
|
507
|
+
}
|
|
508
|
+
type FieldError = ValidationIssue & {
|
|
509
|
+
readonly message: string;
|
|
510
|
+
};
|
|
481
511
|
interface FormRendererAppearance {
|
|
482
512
|
/**
|
|
483
|
-
* Layout preset for radio and
|
|
513
|
+
* Layout preset for choice questions (radio, checkbox, and multi-select).
|
|
484
514
|
* - "default": keep the flat question layout.
|
|
485
515
|
* - "grouped": render a bordered fieldset and legend.
|
|
516
|
+
* - An object can configure each choice question type independently.
|
|
486
517
|
*/
|
|
487
|
-
readonly choiceField?: ChoiceFieldLayoutMode;
|
|
518
|
+
readonly choiceField?: ChoiceFieldLayoutMode | ChoiceFieldTypeLayoutMap;
|
|
488
519
|
}
|
|
489
520
|
type SubmissionConfirmationRenderMode = "inline" | "replace" | "dialog";
|
|
490
521
|
interface SubmissionConfirmationOptions {
|
|
@@ -513,6 +544,23 @@ interface FormFieldsSlotProps {
|
|
|
513
544
|
readonly children: ReactNode;
|
|
514
545
|
readonly className?: string;
|
|
515
546
|
}
|
|
547
|
+
interface ChoiceGroupSlotProps {
|
|
548
|
+
readonly field: Question;
|
|
549
|
+
readonly title: string;
|
|
550
|
+
readonly description?: string;
|
|
551
|
+
readonly required?: boolean;
|
|
552
|
+
readonly error?: FieldError;
|
|
553
|
+
readonly disabled?: boolean;
|
|
554
|
+
readonly readOnly?: boolean;
|
|
555
|
+
readonly children: ReactNode;
|
|
556
|
+
readonly className?: string;
|
|
557
|
+
}
|
|
558
|
+
interface FormRendererSlotProps {
|
|
559
|
+
readonly choiceGroup?: {
|
|
560
|
+
readonly className?: string;
|
|
561
|
+
readonly style?: CSSProperties;
|
|
562
|
+
};
|
|
563
|
+
}
|
|
516
564
|
interface FormRendererSlots {
|
|
517
565
|
readonly renderHeader?: (props: {
|
|
518
566
|
readonly title: string;
|
|
@@ -563,6 +611,7 @@ interface FormRendererSlots {
|
|
|
563
611
|
readonly current: number;
|
|
564
612
|
readonly max: number;
|
|
565
613
|
}) => ReactNode;
|
|
614
|
+
readonly renderChoiceGroup?: (props: ChoiceGroupSlotProps) => ReactNode;
|
|
566
615
|
}
|
|
567
616
|
interface SubmissionProtectionProps {
|
|
568
617
|
readonly submissionGuards?: readonly SubmissionGuard[];
|
|
@@ -604,8 +653,13 @@ interface FormBuilderProps {
|
|
|
604
653
|
readonly sectionOrder?: readonly FormBuilderSectionName[];
|
|
605
654
|
readonly disableDefaultStyles?: boolean;
|
|
606
655
|
readonly unstyled?: boolean;
|
|
656
|
+
readonly fieldEditorMode?: "all" | "single";
|
|
657
|
+
readonly activeFieldId?: string;
|
|
658
|
+
readonly defaultActiveFieldId?: string;
|
|
659
|
+
readonly onActiveFieldChange?: (fieldId: string | undefined) => void;
|
|
660
|
+
readonly submissionSettingsOptions?: FormBuilderSubmissionSettingsOptions;
|
|
607
661
|
}
|
|
608
|
-
declare function FormBuilder({ schema, onChange, locale, translator, translationAdapter, translationOptions, onTranslationReport, policy, idFactory, factories, className, defaultFieldType, onActionError, createManualTranslationMetadata, readOnly, features, fieldEditorControls, fieldTypeOptions, components: componentOverrides, slots, sectionOrder, disableDefaultStyles, unstyled }: FormBuilderProps): react.JSX.Element;
|
|
662
|
+
declare function FormBuilder({ schema, onChange, locale, translator, translationAdapter, translationOptions, onTranslationReport, policy, idFactory, factories, className, defaultFieldType, onActionError, createManualTranslationMetadata, readOnly, features, fieldEditorControls, fieldTypeOptions, components: componentOverrides, slots, sectionOrder, disableDefaultStyles, unstyled, fieldEditorMode, activeFieldId, defaultActiveFieldId, onActiveFieldChange, submissionSettingsOptions }: FormBuilderProps): react.JSX.Element;
|
|
609
663
|
|
|
610
664
|
type SubmitStatus = "idle" | "submitting" | "success" | "error";
|
|
611
665
|
interface FormContextValue {
|
|
@@ -646,6 +700,39 @@ interface FieldState {
|
|
|
646
700
|
}
|
|
647
701
|
declare function useField(fieldId: string): FieldState;
|
|
648
702
|
|
|
703
|
+
interface UseTranslationWorkspaceOptions {
|
|
704
|
+
readonly schema: FormSchema;
|
|
705
|
+
readonly onChange?: (schema: FormSchema) => void;
|
|
706
|
+
readonly sourceLocale?: string;
|
|
707
|
+
readonly targetLocale?: string;
|
|
708
|
+
readonly translationAdapter?: TranslationAdapter | AsyncTranslationAdapter;
|
|
709
|
+
readonly readOnly?: boolean;
|
|
710
|
+
}
|
|
711
|
+
interface TranslationSummary {
|
|
712
|
+
readonly totalSlots: number;
|
|
713
|
+
readonly translatedCount: number;
|
|
714
|
+
readonly missingCount: number;
|
|
715
|
+
readonly staleCount: number;
|
|
716
|
+
readonly manualCount: number;
|
|
717
|
+
readonly completionPercentage: number;
|
|
718
|
+
}
|
|
719
|
+
interface UseTranslationWorkspaceResult {
|
|
720
|
+
readonly sourceLocale: string;
|
|
721
|
+
readonly targetLocale: string;
|
|
722
|
+
readonly targetLocales: readonly string[];
|
|
723
|
+
readonly setTargetLocale: (locale: string) => void;
|
|
724
|
+
readonly slots: readonly TranslationSlot[];
|
|
725
|
+
readonly summary: TranslationSummary;
|
|
726
|
+
readonly addLocale: (locale: string) => void;
|
|
727
|
+
readonly removeLocale: (locale: string) => void;
|
|
728
|
+
readonly setTranslation: (slot: TranslationSlot, text: string) => void;
|
|
729
|
+
readonly translateAll: (options?: PopulateTranslationOptions) => Promise<TranslationReport>;
|
|
730
|
+
readonly translateSlot: (slot: TranslationSlot) => Promise<void>;
|
|
731
|
+
readonly isTranslating: boolean;
|
|
732
|
+
readonly error?: string;
|
|
733
|
+
}
|
|
734
|
+
declare function useTranslationWorkspace({ schema, onChange, sourceLocale, targetLocale, translationAdapter, readOnly }: UseTranslationWorkspaceOptions): UseTranslationWorkspaceResult;
|
|
735
|
+
|
|
649
736
|
declare const BUILDER_TRANSLATION_KEYS: {
|
|
650
737
|
readonly ADD_FIELD: "builder.actions.addField";
|
|
651
738
|
readonly SELECT_FIELD_TYPE: "builder.fields.selectType";
|
|
@@ -665,6 +752,7 @@ declare const BUILDER_TRANSLATION_ALIASES: Readonly<Record<string, string>>;
|
|
|
665
752
|
declare function isTranslationUnresolved(result: unknown, key: string, aliases?: readonly string[]): boolean;
|
|
666
753
|
declare function resolveTranslation(key: string, aliases: readonly string[], adapter?: TranslationAdapter, defaultCatalog?: Readonly<Record<string, string>>, params?: Readonly<Record<string, unknown>>, locale?: string): string;
|
|
667
754
|
|
|
755
|
+
declare function resolveChoiceFieldLayout(type: FieldType, appearance?: FormRendererAppearance, groupedChoiceFieldsLegacy?: boolean): "default" | "grouped";
|
|
668
756
|
interface FieldComponentProps {
|
|
669
757
|
readonly field: FormField;
|
|
670
758
|
readonly value: FormValue;
|
|
@@ -681,6 +769,7 @@ interface FormRendererPresentationProps extends SubmissionProtectionProps {
|
|
|
681
769
|
readonly components?: FieldComponents;
|
|
682
770
|
readonly className?: string;
|
|
683
771
|
readonly appearance?: FormRendererAppearance;
|
|
772
|
+
readonly slotProps?: FormRendererSlotProps;
|
|
684
773
|
/** @deprecated Use appearance.choiceField="grouped" instead. */
|
|
685
774
|
readonly groupedChoiceFields?: boolean;
|
|
686
775
|
/**
|
|
@@ -716,4 +805,4 @@ interface StandaloneFormRendererProps extends FormRendererPresentationProps {
|
|
|
716
805
|
type FormRendererProps = FormRendererPresentationProps | StandaloneFormRendererProps;
|
|
717
806
|
declare function FormRenderer(props: FormRendererProps): react.JSX.Element;
|
|
718
807
|
|
|
719
|
-
export { BUILDER_TRANSLATION_ALIASES, BUILDER_TRANSLATION_KEYS, type BeforeSubmit, type BuilderActionContext, type BuilderActionError, type BuilderActionIconType, type BuilderActionResult, type BuilderButtonProps, type BuilderCheckboxProps, type BuilderErrorMessageProps, type BuilderFactories, type BuilderFieldEditorSlotProps, type BuilderFieldsetProps, type BuilderIconButtonProps, type BuilderIdKind, type BuilderLocalizationSlotProps, type BuilderOptionEditorSlotProps, type BuilderPagesSlotProps, type BuilderPolicy, type BuilderSectionProps, type BuilderSelectOption, type BuilderSelectProps, type BuilderSlotActions, type BuilderTextAreaProps, type BuilderTextInputProps, type BuilderTextTarget, type BuilderToolbarSlotProps, type BuilderTranslationActionsSlotProps, type BuilderTranslationKey, type ChoiceFieldLayoutMode, type ComponentBaseProps, type FieldComponentProps, type FieldComponents, type FieldEditorControlsConfig, type FieldEditorHeaderSlotProps, type FieldPropertyControlMode, type FieldState, type FieldTypeSelectOptionsConfig, type FieldTypeSelectOptionsContext, type FieldTypeSelectOptionsSorter, type FieldTypeSelectOptionsTransformer, type FieldTypeSelectSlotProps, FormBuilder, type FormBuilderActions, type FormBuilderComponents, type FormBuilderFeatures, type FormBuilderOptions, type FormBuilderProps, type FormBuilderResult, type FormBuilderSectionName, type FormBuilderSlots, type FormCompletionSlotProps, type FormContextValue, type FormFieldsSlotProps, FormProvider, type FormProviderProps, FormRenderer, type FormRendererAppearance, type FormRendererMessages, type FormRendererPresentationProps, type FormRendererProps, type FormRendererSlots, type FormServerErrorPayload, FormSubmissionError, type FormSubmitHandler, type FormSubmitState, type FormSubmitStatus, type FormSubmittedAnswerItem, type FormSuccessRenderMode, type IconButtonProps, type InputComponentProps, type LocalizationSummaryContext, type ManualTranslationContext, type ManualTranslationTarget, type RenderSubmitButtonProps, type SelectComponentProps, type StandaloneFormRendererProps, type SubmissionAttempt, type SubmissionAttemptStore, type SubmissionConfirmationOptions, type SubmissionConfirmationRenderMode, type SubmissionConfirmationSlotProps, type SubmissionGuard, type SubmissionGuardResult, type SubmissionProtectionProps, type SubmissionReceipt, type SubmissionReceiptQuery, type SubmissionReceiptStore, type SubmitContext, type SubmitResponse, type SubmitResult, type SubmitStatus, type UseSubmissionReceiptsResult, createLocalStorageSubmissionAttemptStore, createLocalStorageSubmissionReceiptStore, isTranslationUnresolved, resolveFieldEditorControls, resolveFieldTypeSelectOptions, resolveInitialFieldType, resolveTranslation, submissionReceiptQueryKey, useField, useForm, useFormBuilder, useSubmissionReceipts };
|
|
808
|
+
export { BUILDER_TRANSLATION_ALIASES, BUILDER_TRANSLATION_KEYS, type BeforeSubmit, type BuilderActionContext, type BuilderActionError, type BuilderActionIconType, type BuilderActionResult, type BuilderButtonProps, type BuilderCheckboxProps, type BuilderErrorMessageProps, type BuilderFactories, type BuilderFieldEditorSlotProps, type BuilderFieldsetProps, type BuilderIconButtonProps, type BuilderIdKind, type BuilderLocalizationSlotProps, type BuilderOptionEditorSlotProps, type BuilderPagesSlotProps, type BuilderPolicy, type BuilderSectionProps, type BuilderSelectOption, type BuilderSelectProps, type BuilderSlotActions, type BuilderTextAreaProps, type BuilderTextInputProps, type BuilderTextTarget, type BuilderToolbarSlotProps, type BuilderTranslationActionsSlotProps, type BuilderTranslationKey, type ChoiceFieldLayoutMode, type ChoiceFieldTypeLayoutMap, type ChoiceGroupSlotProps, type ComponentBaseProps, type FieldComponentProps, type FieldComponents, type FieldEditorControlsConfig, type FieldEditorHeaderSlotProps, type FieldEditorMode, type FieldError, type FieldPropertyControlMode, type FieldState, type FieldTypeSelectOptionsConfig, type FieldTypeSelectOptionsContext, type FieldTypeSelectOptionsSorter, type FieldTypeSelectOptionsTransformer, type FieldTypeSelectSlotProps, FormBuilder, type FormBuilderActions, type FormBuilderComponents, type FormBuilderFeatures, type FormBuilderOptions, type FormBuilderProps, type FormBuilderResult, type FormBuilderSectionName, type FormBuilderSlots, type FormBuilderSubmissionSettingsOptions, type FormCompletionSlotProps, type FormContextValue, type FormFieldsSlotProps, FormProvider, type FormProviderProps, FormRenderer, type FormRendererAppearance, type FormRendererMessages, type FormRendererPresentationProps, type FormRendererProps, type FormRendererSlotProps, type FormRendererSlots, type FormServerErrorPayload, FormSubmissionError, type FormSubmitHandler, type FormSubmitState, type FormSubmitStatus, type FormSubmittedAnswerItem, type FormSuccessRenderMode, type IconButtonProps, type InputComponentProps, type LocalizationSummaryContext, type ManualTranslationContext, type ManualTranslationTarget, type RenderSubmitButtonProps, type SelectComponentProps, type StandaloneFormRendererProps, type SubmissionAttempt, type SubmissionAttemptStore, type SubmissionConfirmationOptions, type SubmissionConfirmationRenderMode, type SubmissionConfirmationSlotProps, type SubmissionGuard, type SubmissionGuardResult, type SubmissionProtectionProps, type SubmissionReceipt, type SubmissionReceiptQuery, type SubmissionReceiptStore, type SubmitContext, type SubmitResponse, type SubmitResult, type SubmitStatus, type TranslationSummary, type UseFormBuilderOptions, type UseFormBuilderResult, type UseSubmissionReceiptsResult, type UseTranslationWorkspaceOptions, type UseTranslationWorkspaceResult, createLocalStorageSubmissionAttemptStore, createLocalStorageSubmissionReceiptStore, isTranslationUnresolved, resolveChoiceFieldLayout, resolveFieldEditorControls, resolveFieldTypeSelectOptions, resolveInitialFieldType, resolveTranslation, submissionReceiptQueryKey, useField, useForm, useFormBuilder, useSubmissionReceipts, useTranslationWorkspace };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { QuestionType, FormField, ChoiceOption, FormPage, FormSchema, DisplayCondition, JsonValue, SchemaIssue, FormPolicy, Question, FieldOption, TranslationReport, ValidationError, FormValues, TranslationAdapter, AsyncTranslationAdapter, PopulateTranslationOptions, FormValue,
|
|
1
|
+
import { QuestionType, FormField, ChoiceOption, FormPage, FormSchema, DisplayCondition, JsonValue, SchemaIssue, FormPolicy, Question, FieldOption, TranslationReport, ValidationIssue, ValidationError, FormValues, TranslationAdapter, AsyncTranslationAdapter, PopulateTranslationOptions, FormValue, AnswerValidationResult, TranslationSlot, FieldType } from '@form-engine-ts/core';
|
|
2
2
|
export { QuestionType } from '@form-engine-ts/core';
|
|
3
3
|
import * as react from 'react';
|
|
4
|
-
import { ReactNode, ComponentType, KeyboardEvent, MouseEvent } from 'react';
|
|
4
|
+
import { ReactNode, ComponentType, KeyboardEvent, MouseEvent, CSSProperties } from 'react';
|
|
5
5
|
import { SensitiveDataFinding } from '@form-engine-ts/privacy';
|
|
6
6
|
|
|
7
7
|
interface SubmissionAttempt {
|
|
@@ -37,7 +37,13 @@ interface FormBuilderOptions {
|
|
|
37
37
|
readonly policy?: FormPolicy;
|
|
38
38
|
readonly idFactory?: (kind: BuilderIdKind, existingIds: ReadonlySet<string>) => string;
|
|
39
39
|
readonly factories?: BuilderFactories;
|
|
40
|
+
readonly fieldEditorMode?: FieldEditorMode;
|
|
41
|
+
readonly activeFieldId?: string;
|
|
42
|
+
readonly defaultActiveFieldId?: string;
|
|
43
|
+
readonly onActiveFieldChange?: (fieldId: string | undefined) => void;
|
|
40
44
|
}
|
|
45
|
+
type FieldEditorMode = "all" | "single";
|
|
46
|
+
type UseFormBuilderOptions = FormBuilderOptions;
|
|
41
47
|
type BuilderActionError = {
|
|
42
48
|
readonly type: "invalid_id";
|
|
43
49
|
readonly kind: BuilderIdKind;
|
|
@@ -104,8 +110,19 @@ interface FormBuilderResult {
|
|
|
104
110
|
readonly addLocale: (locale: string) => BuilderActionResult;
|
|
105
111
|
readonly setDefaultLocale: (locale: string) => BuilderActionResult;
|
|
106
112
|
readonly validationIssues: readonly SchemaIssue[];
|
|
113
|
+
readonly activeFieldId?: string;
|
|
114
|
+
readonly setActiveFieldId?: (fieldId: string | undefined) => void;
|
|
115
|
+
readonly getFieldEditorProps?: (fieldId: string) => {
|
|
116
|
+
readonly isActive: boolean;
|
|
117
|
+
readonly isVisible: boolean;
|
|
118
|
+
readonly onSelect: () => void;
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
interface UseFormBuilderResult extends FormBuilderResult {
|
|
122
|
+
readonly setActiveFieldId: (fieldId: string | undefined) => void;
|
|
123
|
+
readonly getFieldEditorProps: NonNullable<FormBuilderResult["getFieldEditorProps"]>;
|
|
107
124
|
}
|
|
108
|
-
declare function useFormBuilder({ schema, onChange, policy, idFactory, factories }: FormBuilderOptions): FormBuilderResult;
|
|
125
|
+
declare function useFormBuilder({ schema, onChange, policy, idFactory, factories, fieldEditorMode, activeFieldId: controlledActiveFieldId, defaultActiveFieldId, onActiveFieldChange }: FormBuilderOptions): FormBuilderResult;
|
|
109
126
|
|
|
110
127
|
interface SubmissionReceipt {
|
|
111
128
|
readonly formId: string;
|
|
@@ -376,7 +393,11 @@ interface BuilderTranslationActionsSlotProps extends BuilderSlotBaseProps {
|
|
|
376
393
|
readonly onClearTranslationError?: () => void;
|
|
377
394
|
readonly translationAdapterAvailable?: boolean;
|
|
378
395
|
}
|
|
379
|
-
type FormBuilderSectionName = "basicSettings" | "completionMessage" | "questions" | "addQuestion" | "localization";
|
|
396
|
+
type FormBuilderSectionName = "basicSettings" | "completionMessage" | "questions" | "addQuestion" | "localization" | "submissionSettings";
|
|
397
|
+
interface FormBuilderSubmissionSettingsOptions {
|
|
398
|
+
readonly enabled: boolean;
|
|
399
|
+
readonly placement?: "beforeQuestions" | "afterQuestions" | "bottom";
|
|
400
|
+
}
|
|
380
401
|
interface FormBuilderSlots {
|
|
381
402
|
readonly toolbar?: ComponentType<BuilderToolbarSlotProps>;
|
|
382
403
|
readonly fieldEditor?: ComponentType<BuilderFieldEditorSlotProps>;
|
|
@@ -478,13 +499,23 @@ type SubmissionGuardResult = {
|
|
|
478
499
|
type SubmissionGuard = (schema: FormSchema, values: Record<string, unknown>) => SubmissionGuardResult | Promise<SubmissionGuardResult>;
|
|
479
500
|
type FormSuccessRenderMode = "append" | "replace";
|
|
480
501
|
type ChoiceFieldLayoutMode = "default" | "grouped";
|
|
502
|
+
interface ChoiceFieldTypeLayoutMap {
|
|
503
|
+
readonly radio?: ChoiceFieldLayoutMode;
|
|
504
|
+
readonly checkbox?: ChoiceFieldLayoutMode;
|
|
505
|
+
readonly "multi-select"?: ChoiceFieldLayoutMode;
|
|
506
|
+
readonly select?: ChoiceFieldLayoutMode;
|
|
507
|
+
}
|
|
508
|
+
type FieldError = ValidationIssue & {
|
|
509
|
+
readonly message: string;
|
|
510
|
+
};
|
|
481
511
|
interface FormRendererAppearance {
|
|
482
512
|
/**
|
|
483
|
-
* Layout preset for radio and
|
|
513
|
+
* Layout preset for choice questions (radio, checkbox, and multi-select).
|
|
484
514
|
* - "default": keep the flat question layout.
|
|
485
515
|
* - "grouped": render a bordered fieldset and legend.
|
|
516
|
+
* - An object can configure each choice question type independently.
|
|
486
517
|
*/
|
|
487
|
-
readonly choiceField?: ChoiceFieldLayoutMode;
|
|
518
|
+
readonly choiceField?: ChoiceFieldLayoutMode | ChoiceFieldTypeLayoutMap;
|
|
488
519
|
}
|
|
489
520
|
type SubmissionConfirmationRenderMode = "inline" | "replace" | "dialog";
|
|
490
521
|
interface SubmissionConfirmationOptions {
|
|
@@ -513,6 +544,23 @@ interface FormFieldsSlotProps {
|
|
|
513
544
|
readonly children: ReactNode;
|
|
514
545
|
readonly className?: string;
|
|
515
546
|
}
|
|
547
|
+
interface ChoiceGroupSlotProps {
|
|
548
|
+
readonly field: Question;
|
|
549
|
+
readonly title: string;
|
|
550
|
+
readonly description?: string;
|
|
551
|
+
readonly required?: boolean;
|
|
552
|
+
readonly error?: FieldError;
|
|
553
|
+
readonly disabled?: boolean;
|
|
554
|
+
readonly readOnly?: boolean;
|
|
555
|
+
readonly children: ReactNode;
|
|
556
|
+
readonly className?: string;
|
|
557
|
+
}
|
|
558
|
+
interface FormRendererSlotProps {
|
|
559
|
+
readonly choiceGroup?: {
|
|
560
|
+
readonly className?: string;
|
|
561
|
+
readonly style?: CSSProperties;
|
|
562
|
+
};
|
|
563
|
+
}
|
|
516
564
|
interface FormRendererSlots {
|
|
517
565
|
readonly renderHeader?: (props: {
|
|
518
566
|
readonly title: string;
|
|
@@ -563,6 +611,7 @@ interface FormRendererSlots {
|
|
|
563
611
|
readonly current: number;
|
|
564
612
|
readonly max: number;
|
|
565
613
|
}) => ReactNode;
|
|
614
|
+
readonly renderChoiceGroup?: (props: ChoiceGroupSlotProps) => ReactNode;
|
|
566
615
|
}
|
|
567
616
|
interface SubmissionProtectionProps {
|
|
568
617
|
readonly submissionGuards?: readonly SubmissionGuard[];
|
|
@@ -604,8 +653,13 @@ interface FormBuilderProps {
|
|
|
604
653
|
readonly sectionOrder?: readonly FormBuilderSectionName[];
|
|
605
654
|
readonly disableDefaultStyles?: boolean;
|
|
606
655
|
readonly unstyled?: boolean;
|
|
656
|
+
readonly fieldEditorMode?: "all" | "single";
|
|
657
|
+
readonly activeFieldId?: string;
|
|
658
|
+
readonly defaultActiveFieldId?: string;
|
|
659
|
+
readonly onActiveFieldChange?: (fieldId: string | undefined) => void;
|
|
660
|
+
readonly submissionSettingsOptions?: FormBuilderSubmissionSettingsOptions;
|
|
607
661
|
}
|
|
608
|
-
declare function FormBuilder({ schema, onChange, locale, translator, translationAdapter, translationOptions, onTranslationReport, policy, idFactory, factories, className, defaultFieldType, onActionError, createManualTranslationMetadata, readOnly, features, fieldEditorControls, fieldTypeOptions, components: componentOverrides, slots, sectionOrder, disableDefaultStyles, unstyled }: FormBuilderProps): react.JSX.Element;
|
|
662
|
+
declare function FormBuilder({ schema, onChange, locale, translator, translationAdapter, translationOptions, onTranslationReport, policy, idFactory, factories, className, defaultFieldType, onActionError, createManualTranslationMetadata, readOnly, features, fieldEditorControls, fieldTypeOptions, components: componentOverrides, slots, sectionOrder, disableDefaultStyles, unstyled, fieldEditorMode, activeFieldId, defaultActiveFieldId, onActiveFieldChange, submissionSettingsOptions }: FormBuilderProps): react.JSX.Element;
|
|
609
663
|
|
|
610
664
|
type SubmitStatus = "idle" | "submitting" | "success" | "error";
|
|
611
665
|
interface FormContextValue {
|
|
@@ -646,6 +700,39 @@ interface FieldState {
|
|
|
646
700
|
}
|
|
647
701
|
declare function useField(fieldId: string): FieldState;
|
|
648
702
|
|
|
703
|
+
interface UseTranslationWorkspaceOptions {
|
|
704
|
+
readonly schema: FormSchema;
|
|
705
|
+
readonly onChange?: (schema: FormSchema) => void;
|
|
706
|
+
readonly sourceLocale?: string;
|
|
707
|
+
readonly targetLocale?: string;
|
|
708
|
+
readonly translationAdapter?: TranslationAdapter | AsyncTranslationAdapter;
|
|
709
|
+
readonly readOnly?: boolean;
|
|
710
|
+
}
|
|
711
|
+
interface TranslationSummary {
|
|
712
|
+
readonly totalSlots: number;
|
|
713
|
+
readonly translatedCount: number;
|
|
714
|
+
readonly missingCount: number;
|
|
715
|
+
readonly staleCount: number;
|
|
716
|
+
readonly manualCount: number;
|
|
717
|
+
readonly completionPercentage: number;
|
|
718
|
+
}
|
|
719
|
+
interface UseTranslationWorkspaceResult {
|
|
720
|
+
readonly sourceLocale: string;
|
|
721
|
+
readonly targetLocale: string;
|
|
722
|
+
readonly targetLocales: readonly string[];
|
|
723
|
+
readonly setTargetLocale: (locale: string) => void;
|
|
724
|
+
readonly slots: readonly TranslationSlot[];
|
|
725
|
+
readonly summary: TranslationSummary;
|
|
726
|
+
readonly addLocale: (locale: string) => void;
|
|
727
|
+
readonly removeLocale: (locale: string) => void;
|
|
728
|
+
readonly setTranslation: (slot: TranslationSlot, text: string) => void;
|
|
729
|
+
readonly translateAll: (options?: PopulateTranslationOptions) => Promise<TranslationReport>;
|
|
730
|
+
readonly translateSlot: (slot: TranslationSlot) => Promise<void>;
|
|
731
|
+
readonly isTranslating: boolean;
|
|
732
|
+
readonly error?: string;
|
|
733
|
+
}
|
|
734
|
+
declare function useTranslationWorkspace({ schema, onChange, sourceLocale, targetLocale, translationAdapter, readOnly }: UseTranslationWorkspaceOptions): UseTranslationWorkspaceResult;
|
|
735
|
+
|
|
649
736
|
declare const BUILDER_TRANSLATION_KEYS: {
|
|
650
737
|
readonly ADD_FIELD: "builder.actions.addField";
|
|
651
738
|
readonly SELECT_FIELD_TYPE: "builder.fields.selectType";
|
|
@@ -665,6 +752,7 @@ declare const BUILDER_TRANSLATION_ALIASES: Readonly<Record<string, string>>;
|
|
|
665
752
|
declare function isTranslationUnresolved(result: unknown, key: string, aliases?: readonly string[]): boolean;
|
|
666
753
|
declare function resolveTranslation(key: string, aliases: readonly string[], adapter?: TranslationAdapter, defaultCatalog?: Readonly<Record<string, string>>, params?: Readonly<Record<string, unknown>>, locale?: string): string;
|
|
667
754
|
|
|
755
|
+
declare function resolveChoiceFieldLayout(type: FieldType, appearance?: FormRendererAppearance, groupedChoiceFieldsLegacy?: boolean): "default" | "grouped";
|
|
668
756
|
interface FieldComponentProps {
|
|
669
757
|
readonly field: FormField;
|
|
670
758
|
readonly value: FormValue;
|
|
@@ -681,6 +769,7 @@ interface FormRendererPresentationProps extends SubmissionProtectionProps {
|
|
|
681
769
|
readonly components?: FieldComponents;
|
|
682
770
|
readonly className?: string;
|
|
683
771
|
readonly appearance?: FormRendererAppearance;
|
|
772
|
+
readonly slotProps?: FormRendererSlotProps;
|
|
684
773
|
/** @deprecated Use appearance.choiceField="grouped" instead. */
|
|
685
774
|
readonly groupedChoiceFields?: boolean;
|
|
686
775
|
/**
|
|
@@ -716,4 +805,4 @@ interface StandaloneFormRendererProps extends FormRendererPresentationProps {
|
|
|
716
805
|
type FormRendererProps = FormRendererPresentationProps | StandaloneFormRendererProps;
|
|
717
806
|
declare function FormRenderer(props: FormRendererProps): react.JSX.Element;
|
|
718
807
|
|
|
719
|
-
export { BUILDER_TRANSLATION_ALIASES, BUILDER_TRANSLATION_KEYS, type BeforeSubmit, type BuilderActionContext, type BuilderActionError, type BuilderActionIconType, type BuilderActionResult, type BuilderButtonProps, type BuilderCheckboxProps, type BuilderErrorMessageProps, type BuilderFactories, type BuilderFieldEditorSlotProps, type BuilderFieldsetProps, type BuilderIconButtonProps, type BuilderIdKind, type BuilderLocalizationSlotProps, type BuilderOptionEditorSlotProps, type BuilderPagesSlotProps, type BuilderPolicy, type BuilderSectionProps, type BuilderSelectOption, type BuilderSelectProps, type BuilderSlotActions, type BuilderTextAreaProps, type BuilderTextInputProps, type BuilderTextTarget, type BuilderToolbarSlotProps, type BuilderTranslationActionsSlotProps, type BuilderTranslationKey, type ChoiceFieldLayoutMode, type ComponentBaseProps, type FieldComponentProps, type FieldComponents, type FieldEditorControlsConfig, type FieldEditorHeaderSlotProps, type FieldPropertyControlMode, type FieldState, type FieldTypeSelectOptionsConfig, type FieldTypeSelectOptionsContext, type FieldTypeSelectOptionsSorter, type FieldTypeSelectOptionsTransformer, type FieldTypeSelectSlotProps, FormBuilder, type FormBuilderActions, type FormBuilderComponents, type FormBuilderFeatures, type FormBuilderOptions, type FormBuilderProps, type FormBuilderResult, type FormBuilderSectionName, type FormBuilderSlots, type FormCompletionSlotProps, type FormContextValue, type FormFieldsSlotProps, FormProvider, type FormProviderProps, FormRenderer, type FormRendererAppearance, type FormRendererMessages, type FormRendererPresentationProps, type FormRendererProps, type FormRendererSlots, type FormServerErrorPayload, FormSubmissionError, type FormSubmitHandler, type FormSubmitState, type FormSubmitStatus, type FormSubmittedAnswerItem, type FormSuccessRenderMode, type IconButtonProps, type InputComponentProps, type LocalizationSummaryContext, type ManualTranslationContext, type ManualTranslationTarget, type RenderSubmitButtonProps, type SelectComponentProps, type StandaloneFormRendererProps, type SubmissionAttempt, type SubmissionAttemptStore, type SubmissionConfirmationOptions, type SubmissionConfirmationRenderMode, type SubmissionConfirmationSlotProps, type SubmissionGuard, type SubmissionGuardResult, type SubmissionProtectionProps, type SubmissionReceipt, type SubmissionReceiptQuery, type SubmissionReceiptStore, type SubmitContext, type SubmitResponse, type SubmitResult, type SubmitStatus, type UseSubmissionReceiptsResult, createLocalStorageSubmissionAttemptStore, createLocalStorageSubmissionReceiptStore, isTranslationUnresolved, resolveFieldEditorControls, resolveFieldTypeSelectOptions, resolveInitialFieldType, resolveTranslation, submissionReceiptQueryKey, useField, useForm, useFormBuilder, useSubmissionReceipts };
|
|
808
|
+
export { BUILDER_TRANSLATION_ALIASES, BUILDER_TRANSLATION_KEYS, type BeforeSubmit, type BuilderActionContext, type BuilderActionError, type BuilderActionIconType, type BuilderActionResult, type BuilderButtonProps, type BuilderCheckboxProps, type BuilderErrorMessageProps, type BuilderFactories, type BuilderFieldEditorSlotProps, type BuilderFieldsetProps, type BuilderIconButtonProps, type BuilderIdKind, type BuilderLocalizationSlotProps, type BuilderOptionEditorSlotProps, type BuilderPagesSlotProps, type BuilderPolicy, type BuilderSectionProps, type BuilderSelectOption, type BuilderSelectProps, type BuilderSlotActions, type BuilderTextAreaProps, type BuilderTextInputProps, type BuilderTextTarget, type BuilderToolbarSlotProps, type BuilderTranslationActionsSlotProps, type BuilderTranslationKey, type ChoiceFieldLayoutMode, type ChoiceFieldTypeLayoutMap, type ChoiceGroupSlotProps, type ComponentBaseProps, type FieldComponentProps, type FieldComponents, type FieldEditorControlsConfig, type FieldEditorHeaderSlotProps, type FieldEditorMode, type FieldError, type FieldPropertyControlMode, type FieldState, type FieldTypeSelectOptionsConfig, type FieldTypeSelectOptionsContext, type FieldTypeSelectOptionsSorter, type FieldTypeSelectOptionsTransformer, type FieldTypeSelectSlotProps, FormBuilder, type FormBuilderActions, type FormBuilderComponents, type FormBuilderFeatures, type FormBuilderOptions, type FormBuilderProps, type FormBuilderResult, type FormBuilderSectionName, type FormBuilderSlots, type FormBuilderSubmissionSettingsOptions, type FormCompletionSlotProps, type FormContextValue, type FormFieldsSlotProps, FormProvider, type FormProviderProps, FormRenderer, type FormRendererAppearance, type FormRendererMessages, type FormRendererPresentationProps, type FormRendererProps, type FormRendererSlotProps, type FormRendererSlots, type FormServerErrorPayload, FormSubmissionError, type FormSubmitHandler, type FormSubmitState, type FormSubmitStatus, type FormSubmittedAnswerItem, type FormSuccessRenderMode, type IconButtonProps, type InputComponentProps, type LocalizationSummaryContext, type ManualTranslationContext, type ManualTranslationTarget, type RenderSubmitButtonProps, type SelectComponentProps, type StandaloneFormRendererProps, type SubmissionAttempt, type SubmissionAttemptStore, type SubmissionConfirmationOptions, type SubmissionConfirmationRenderMode, type SubmissionConfirmationSlotProps, type SubmissionGuard, type SubmissionGuardResult, type SubmissionProtectionProps, type SubmissionReceipt, type SubmissionReceiptQuery, type SubmissionReceiptStore, type SubmitContext, type SubmitResponse, type SubmitResult, type SubmitStatus, type TranslationSummary, type UseFormBuilderOptions, type UseFormBuilderResult, type UseSubmissionReceiptsResult, type UseTranslationWorkspaceOptions, type UseTranslationWorkspaceResult, createLocalStorageSubmissionAttemptStore, createLocalStorageSubmissionReceiptStore, isTranslationUnresolved, resolveChoiceFieldLayout, resolveFieldEditorControls, resolveFieldTypeSelectOptions, resolveInitialFieldType, resolveTranslation, submissionReceiptQueryKey, useField, useForm, useFormBuilder, useSubmissionReceipts, useTranslationWorkspace };
|