reactaform 1.0.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/LICENSE +21 -0
- package/README.md +499 -0
- package/dist/common-BD9zx3GT.js +1 -0
- package/dist/common-BQcVe8MY.mjs +87 -0
- package/dist/common-BnnwzTl2.mjs +87 -0
- package/dist/common-BxyjIoe1.js +1 -0
- package/dist/common-Bzz0clAC.mjs +87 -0
- package/dist/common-COyDhNL-.js +1 -0
- package/dist/common-DLqVHgfX.mjs +87 -0
- package/dist/common-hRFTL4KF.js +1 -0
- package/dist/components/LayoutComponents.d.ts +74 -0
- package/dist/components/PopupOptionMenu.d.ts +15 -0
- package/dist/components/ReactaForm.d.ts +4 -0
- package/dist/components/ReactaFormProvider.d.ts +3 -0
- package/dist/components/ReactaFormRenderer.d.ts +13 -0
- package/dist/components/Tooltip.d.ts +8 -0
- package/dist/components/VirtualizedFieldList.d.ts +36 -0
- package/dist/components/fields/CheckboxInput.d.ts +9 -0
- package/dist/components/fields/ColorInput.d.ts +17 -0
- package/dist/components/fields/DateInput.d.ts +11 -0
- package/dist/components/fields/DropdownInput.d.ts +13 -0
- package/dist/components/fields/EmailInput.d.ts +5 -0
- package/dist/components/fields/FileInput.d.ts +5 -0
- package/dist/components/fields/FloatArrayInput.d.ts +5 -0
- package/dist/components/fields/FloatInput.d.ts +24 -0
- package/dist/components/fields/ImageDisplay.d.ts +17 -0
- package/dist/components/fields/IntegerArrayInput.d.ts +23 -0
- package/dist/components/fields/IntegerInput.d.ts +28 -0
- package/dist/components/fields/MultiSelection.d.ts +9 -0
- package/dist/components/fields/MultilineTextInput.d.ts +6 -0
- package/dist/components/fields/NumericStepperInput.d.ts +6 -0
- package/dist/components/fields/PhoneInput.d.ts +6 -0
- package/dist/components/fields/RadioInput.d.ts +13 -0
- package/dist/components/fields/RatingInput.d.ts +6 -0
- package/dist/components/fields/Separator.d.ts +20 -0
- package/dist/components/fields/SliderInput.d.ts +22 -0
- package/dist/components/fields/SpinInput.d.ts +6 -0
- package/dist/components/fields/SwitchInput.d.ts +13 -0
- package/dist/components/fields/TextInput.d.ts +6 -0
- package/dist/components/fields/TimeInput.d.ts +6 -0
- package/dist/components/fields/UnitValueInput.d.ts +5 -0
- package/dist/components/fields/UrlInput.d.ts +21 -0
- package/dist/components/renderFields.d.ts +4 -0
- package/dist/core/fieldVisibility.d.ts +25 -0
- package/dist/core/index.d.ts +19 -0
- package/dist/core/reactaFormModel.d.ts +38 -0
- package/dist/core/reactaFormTypes.d.ts +137 -0
- package/dist/core/registries/baseRegistry.d.ts +15 -0
- package/dist/core/registries/componentRegistry.d.ts +9 -0
- package/dist/core/registries/index.d.ts +7 -0
- package/dist/core/registries/submissionHandlerRegistry.d.ts +6 -0
- package/dist/core/registries/validationHandlerRegistry.d.ts +16 -0
- package/dist/core/submitForm.d.ts +12 -0
- package/dist/core/validation.d.ts +10 -0
- package/dist/hooks/useDebouncedCallback.d.ts +25 -0
- package/dist/hooks/useReactaFormContext.d.ts +4 -0
- package/dist/index.d.ts +15 -0
- package/dist/reactaform.cjs.js +289 -0
- package/dist/reactaform.css +1 -0
- package/dist/reactaform.es.js +5085 -0
- package/dist/templates/conditionalAddress.d.ts +3 -0
- package/dist/templates/contactForm.d.ts +3 -0
- package/dist/templates/optionsAndParents.d.ts +3 -0
- package/dist/templates/surveyForm.d.ts +3 -0
- package/dist/utils/cssClasses.d.ts +14 -0
- package/dist/utils/definitionSerializers.d.ts +62 -0
- package/dist/utils/groupingHelpers.d.ts +24 -0
- package/dist/utils/index.d.ts +11 -0
- package/dist/utils/translationCache.d.ts +43 -0
- package/dist/utils/unitValueMapper.d.ts +8 -0
- package/package.json +54 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { DefinitionPropertyField } from "../../core/reactaFormTypes";
|
|
3
|
+
import type { BaseInputProps } from "../../core/reactaFormTypes";
|
|
4
|
+
export type OptionsField = DefinitionPropertyField & {
|
|
5
|
+
options: NonNullable<DefinitionPropertyField['options']>;
|
|
6
|
+
};
|
|
7
|
+
type MultiSelectionProps = BaseInputProps<string[] | null, OptionsField>;
|
|
8
|
+
declare const MultiSelect: React.FC<MultiSelectionProps>;
|
|
9
|
+
export default MultiSelect;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { DefinitionPropertyField } from "../../core/reactaFormTypes";
|
|
3
|
+
import type { BaseInputProps } from "../../core/reactaFormTypes";
|
|
4
|
+
type TextInputProps = BaseInputProps<string, DefinitionPropertyField>;
|
|
5
|
+
declare const MultilineTextInput: React.FC<TextInputProps>;
|
|
6
|
+
export default MultilineTextInput;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { DefinitionPropertyField } from "../../core/reactaFormTypes";
|
|
3
|
+
import type { BaseInputProps } from "../../core/reactaFormTypes";
|
|
4
|
+
export type NumericStepperInputProps = BaseInputProps<number, DefinitionPropertyField>;
|
|
5
|
+
declare const NumericStepperInput: React.FC<NumericStepperInputProps>;
|
|
6
|
+
export default NumericStepperInput;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { DefinitionPropertyField } from "../../core/reactaFormTypes";
|
|
3
|
+
import type { BaseInputProps } from "../../core/reactaFormTypes";
|
|
4
|
+
export type PhoneInputProps = BaseInputProps<string, DefinitionPropertyField>;
|
|
5
|
+
export declare const PhoneInput: React.FC<PhoneInputProps>;
|
|
6
|
+
export default PhoneInput;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { BaseInputProps, DefinitionPropertyField } from "../../core/reactaFormTypes";
|
|
3
|
+
export type RadioInputProps = BaseInputProps<string, DefinitionPropertyField>;
|
|
4
|
+
/**
|
|
5
|
+
* RadioInput
|
|
6
|
+
*
|
|
7
|
+
* Renders radio button options for selecting a single value.
|
|
8
|
+
* - Supports horizontal and vertical layouts
|
|
9
|
+
* - Validates that the selected value is in the options list
|
|
10
|
+
* - Auto-corrects to first option if invalid value provided
|
|
11
|
+
*/
|
|
12
|
+
declare const RadioInput: React.FC<RadioInputProps>;
|
|
13
|
+
export default RadioInput;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { DefinitionPropertyField } from "../../core/reactaFormTypes";
|
|
3
|
+
import type { BaseInputProps } from "../../core/reactaFormTypes";
|
|
4
|
+
export type RatingInputProps = BaseInputProps<number, DefinitionPropertyField>;
|
|
5
|
+
declare const RatingInput: React.FC<RatingInputProps>;
|
|
6
|
+
export default RatingInput;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
interface SeparatorProps {
|
|
2
|
+
color?: string;
|
|
3
|
+
thickness?: number;
|
|
4
|
+
margin?: string | number;
|
|
5
|
+
label?: string | null;
|
|
6
|
+
alignment?: "left" | "center" | "right";
|
|
7
|
+
}
|
|
8
|
+
export declare const Separator: React.FC<SeparatorProps>;
|
|
9
|
+
interface FieldSeparatorProps {
|
|
10
|
+
field: {
|
|
11
|
+
color?: string;
|
|
12
|
+
thickness?: number;
|
|
13
|
+
margin?: string | number;
|
|
14
|
+
label?: string;
|
|
15
|
+
alignment?: "left" | "center" | "right";
|
|
16
|
+
};
|
|
17
|
+
t: (text: string) => string;
|
|
18
|
+
}
|
|
19
|
+
declare const FieldSeparator: React.FC<FieldSeparatorProps>;
|
|
20
|
+
export default FieldSeparator;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { BaseInputProps, DefinitionPropertyField } from "../../core/reactaFormTypes";
|
|
3
|
+
/**
|
|
4
|
+
* SliderInput component
|
|
5
|
+
*
|
|
6
|
+
* A reusable UI component that displays a range slider with a linked numeric input.
|
|
7
|
+
* Designed for numeric fields defined in a JSON schema, this component supports:
|
|
8
|
+
* - Validation (min/max, required, and custom rules)
|
|
9
|
+
* - Real-time synchronization between slider and text input
|
|
10
|
+
* - Tooltip display on hover
|
|
11
|
+
* - Integration with ReactaForm context (for styling, translation, and validation)
|
|
12
|
+
*
|
|
13
|
+
* Props:
|
|
14
|
+
* - field: DefinitionPropertyField
|
|
15
|
+
* - Required: min, max
|
|
16
|
+
* - Optional: tooltip
|
|
17
|
+
* - value: current numeric value
|
|
18
|
+
* - onChange: callback triggered with new value and optional error string
|
|
19
|
+
*/
|
|
20
|
+
type SliderInputProps = BaseInputProps<string | number, DefinitionPropertyField>;
|
|
21
|
+
declare const SliderInput: React.FC<SliderInputProps>;
|
|
22
|
+
export default SliderInput;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { DefinitionPropertyField } from "../../core/reactaFormTypes";
|
|
3
|
+
import type { BaseInputProps } from "../../core/reactaFormTypes";
|
|
4
|
+
export type SpinInputProps = BaseInputProps<number, DefinitionPropertyField>;
|
|
5
|
+
declare const SpinInput: React.FC<SpinInputProps>;
|
|
6
|
+
export default SpinInput;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { BaseInputProps, DefinitionPropertyField } from "../../core/reactaFormTypes";
|
|
3
|
+
type SwitchInputProps = BaseInputProps<boolean, DefinitionPropertyField>;
|
|
4
|
+
/**
|
|
5
|
+
* SwitchInput
|
|
6
|
+
*
|
|
7
|
+
* Renders a toggle switch UI for boolean values.
|
|
8
|
+
* - Clicking anywhere on the container toggles the switch.
|
|
9
|
+
* - Visual toggle with sliding knob and background color changes.
|
|
10
|
+
* - Displays label and optional tooltip.
|
|
11
|
+
*/
|
|
12
|
+
export declare const SwitchInput: React.FC<SwitchInputProps>;
|
|
13
|
+
export default SwitchInput;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { DefinitionPropertyField } from "../../core/reactaFormTypes";
|
|
3
|
+
import type { BaseInputProps } from "../../core/reactaFormTypes";
|
|
4
|
+
type TextInputProps = BaseInputProps<string, DefinitionPropertyField>;
|
|
5
|
+
declare const TextInput: React.FC<TextInputProps>;
|
|
6
|
+
export default TextInput;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { DefinitionPropertyField } from "../../core/reactaFormTypes";
|
|
3
|
+
import type { BaseInputProps } from "../../core/reactaFormTypes";
|
|
4
|
+
type TimeInputProps = BaseInputProps<string, DefinitionPropertyField>;
|
|
5
|
+
declare const TimeInput: React.FC<TimeInputProps>;
|
|
6
|
+
export default TimeInput;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { BaseInputProps } from "../../core/reactaFormTypes";
|
|
2
|
+
import type { DefinitionPropertyField } from "../../core/reactaFormTypes";
|
|
3
|
+
type UnitValueInputProps = BaseInputProps<[string | number, string], DefinitionPropertyField>;
|
|
4
|
+
declare function UnitValueInput({ field, value, onChange }: UnitValueInputProps): import("react/jsx-runtime").JSX.Element | null;
|
|
5
|
+
export default UnitValueInput;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { DefinitionPropertyField } from "../../core/reactaFormTypes";
|
|
3
|
+
import type { BaseInputProps } from "../../core/reactaFormTypes";
|
|
4
|
+
/**
|
|
5
|
+
* UrlInput component
|
|
6
|
+
*
|
|
7
|
+
* This component provides a controlled input field for URL values.
|
|
8
|
+
* It validates required fields, URL format, and integrates with Reacta form context.
|
|
9
|
+
*
|
|
10
|
+
* Props:
|
|
11
|
+
* - field: Field metadata (name, displayName, tooltip, validation rules).
|
|
12
|
+
* - value: Current URL string.
|
|
13
|
+
* - onChange: Callback called with (value, error).
|
|
14
|
+
*
|
|
15
|
+
* Features:
|
|
16
|
+
* - Validates using a robust URL regex and `URL` constructor fallback.
|
|
17
|
+
* - Supports tooltip, localization, and inline validation errors.
|
|
18
|
+
*/
|
|
19
|
+
export type UrlInputProps = BaseInputProps<string, DefinitionPropertyField>;
|
|
20
|
+
declare const UrlInput: React.FC<UrlInputProps>;
|
|
21
|
+
export default UrlInput;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DefinitionPropertyField, FieldValueType, ErrorType } from "../core/reactaFormTypes";
|
|
2
|
+
import type { JSX } from "react/jsx-runtime";
|
|
3
|
+
export declare const renderFields: (fields: DefinitionPropertyField[], valuesMap: Record<string, FieldValueType>, handleChange: (fieldName: string, value: FieldValueType, error: ErrorType) => void, visibility: Record<string, boolean>, loadedCount: number, handleError?: (fieldName: string, error: ErrorType) => void) => (JSX.Element | null)[];
|
|
4
|
+
export declare const renderFieldsWithGroups: (groupState: Record<string, boolean>, fields: DefinitionPropertyField[], valuesMap: Record<string, FieldValueType>, t: (key: string) => string, handleChange: (fieldName: string, value: FieldValueType, error: ErrorType) => void, handleError: (fieldName: string, error: ErrorType) => void, visibility: Record<string, boolean>, loadedCount: number, toggleGroup: (groupName: string) => void) => JSX.Element[];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { DefinitionPropertyField, FieldValueType } from "./reactaFormTypes";
|
|
2
|
+
/**
|
|
3
|
+
* Initializes the visibility map for all fields by setting them to `false`.
|
|
4
|
+
*/
|
|
5
|
+
export declare const initializeVisibility: (fields: DefinitionPropertyField[]) => Record<string, boolean>;
|
|
6
|
+
/**
|
|
7
|
+
* Creates a lookup map for faster field access during visibility calculations
|
|
8
|
+
*/
|
|
9
|
+
export declare const createFieldMap: (fields: DefinitionPropertyField[]) => Record<string, DefinitionPropertyField>;
|
|
10
|
+
/**
|
|
11
|
+
* Updates visibility map based on current field values and parent-child relationships
|
|
12
|
+
*/
|
|
13
|
+
export declare const updateVisibilityMap: (fields: DefinitionPropertyField[], values: Record<string, FieldValueType>, oldVisibility: Record<string, boolean>, fieldMapRef: Record<string, DefinitionPropertyField>) => Record<string, boolean>;
|
|
14
|
+
/**
|
|
15
|
+
* Updates visibility when a specific field value changes
|
|
16
|
+
*/
|
|
17
|
+
export declare const updateVisibilityBasedOnSelection: (visibility: Record<string, boolean>, fieldMap: Record<string, DefinitionPropertyField>, valuesMap: Record<string, FieldValueType>, fieldName: string, value: FieldValueType) => Record<string, boolean>;
|
|
18
|
+
/**
|
|
19
|
+
* Checks if a field should be visible based on its parent relationships
|
|
20
|
+
*/
|
|
21
|
+
export declare const isFieldVisible: (fieldName: string, fieldMap: Record<string, DefinitionPropertyField>, values: Record<string, FieldValueType>) => boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Gets all visible fields efficiently
|
|
24
|
+
*/
|
|
25
|
+
export declare const getVisibleFields: (fields: DefinitionPropertyField[], values: Record<string, FieldValueType>) => DefinitionPropertyField[];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export * from "./reactaFormTypes";
|
|
2
|
+
export * from "./validation";
|
|
3
|
+
export * from "./submitForm";
|
|
4
|
+
export * from "./fieldVisibility";
|
|
5
|
+
export * from "./reactaFormModel";
|
|
6
|
+
export * from "./registries";
|
|
7
|
+
import * as registries from "./registries";
|
|
8
|
+
import * as validation from "./validation";
|
|
9
|
+
import * as submitForm from "./submitForm";
|
|
10
|
+
import * as fieldVisibility from "./fieldVisibility";
|
|
11
|
+
import * as reactaFormModel from "./reactaFormModel";
|
|
12
|
+
declare const _default: {
|
|
13
|
+
registries: typeof registries;
|
|
14
|
+
validation: typeof validation;
|
|
15
|
+
submitForm: typeof submitForm;
|
|
16
|
+
fieldVisibility: typeof fieldVisibility;
|
|
17
|
+
reactaFormModel: typeof reactaFormModel;
|
|
18
|
+
};
|
|
19
|
+
export default _default;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ReactaDefinition, ReactaInstance } from "./reactaFormTypes";
|
|
2
|
+
export interface LoadDefinitionOptions {
|
|
3
|
+
validateSchema?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export interface DefinitionLoadResult {
|
|
6
|
+
success: boolean;
|
|
7
|
+
definition?: ReactaDefinition;
|
|
8
|
+
error?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Validates that a definition object has the required structure
|
|
12
|
+
*/
|
|
13
|
+
export declare function validateDefinitionSchema(definition: ReactaDefinition): string | null;
|
|
14
|
+
/**
|
|
15
|
+
* Load definition from a JSON string. This intentionally does not perform any file I/O.
|
|
16
|
+
*/
|
|
17
|
+
export declare function loadJsonDefinition(jsonData: string, options?: LoadDefinitionOptions): Promise<DefinitionLoadResult>;
|
|
18
|
+
/**
|
|
19
|
+
* Create instance from definition with validation and error handling
|
|
20
|
+
*/
|
|
21
|
+
export declare function createInstanceFromDefinition(definition: ReactaDefinition, name: string): {
|
|
22
|
+
success: boolean;
|
|
23
|
+
instance?: ReactaInstance;
|
|
24
|
+
error?: string;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Load instance data with validation
|
|
28
|
+
*/
|
|
29
|
+
export declare function loadInstance(instanceData: string | Record<string, unknown>): {
|
|
30
|
+
success: boolean;
|
|
31
|
+
instance?: ReactaInstance;
|
|
32
|
+
error?: string;
|
|
33
|
+
};
|
|
34
|
+
export declare function upgradeInstanceToLatestDefinition(instance: ReactaInstance, latestDefinition: ReactaDefinition, callback?: (oldInstance: ReactaInstance, newInstance: Record<string, unknown>, latestDefinition: ReactaDefinition) => void): {
|
|
35
|
+
success: boolean;
|
|
36
|
+
upgradedInstance?: Record<string, unknown>;
|
|
37
|
+
error?: string;
|
|
38
|
+
};
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
type Integer = number;
|
|
3
|
+
type Float = number;
|
|
4
|
+
export type FieldValueType = boolean | Integer | Float | string | Integer[] | Float[] | string[] | [number, string] | File | File[];
|
|
5
|
+
export type ErrorType = string | null;
|
|
6
|
+
export type ParentField = Record<string, string[] | Integer[] | boolean[]>;
|
|
7
|
+
export interface DefinitionPropertyField {
|
|
8
|
+
name: string;
|
|
9
|
+
displayName: string;
|
|
10
|
+
type: string;
|
|
11
|
+
defaultValue: FieldValueType;
|
|
12
|
+
required?: boolean;
|
|
13
|
+
parents?: ParentField;
|
|
14
|
+
children?: Record<string, string[]>;
|
|
15
|
+
group?: string;
|
|
16
|
+
tooltip?: string;
|
|
17
|
+
labelLayout?: 'row' | 'column-left' | 'column-center';
|
|
18
|
+
validationHandlerName?: string;
|
|
19
|
+
dimension?: string;
|
|
20
|
+
defaultUnit?: string;
|
|
21
|
+
options?: Array<{
|
|
22
|
+
label: string;
|
|
23
|
+
value: string;
|
|
24
|
+
}>;
|
|
25
|
+
minLength?: number;
|
|
26
|
+
maxLength?: number;
|
|
27
|
+
pattern?: string;
|
|
28
|
+
placeholder?: string;
|
|
29
|
+
min?: number;
|
|
30
|
+
max?: number;
|
|
31
|
+
minInclusive?: boolean;
|
|
32
|
+
maxInclusive?: boolean;
|
|
33
|
+
step?: number;
|
|
34
|
+
minCount?: number;
|
|
35
|
+
maxCount?: number;
|
|
36
|
+
minDate?: string;
|
|
37
|
+
maxDate?: string;
|
|
38
|
+
includeSeconds?: boolean;
|
|
39
|
+
layout?: 'horizontal' | 'vertical' | 'row' | 'column';
|
|
40
|
+
alignment?: 'left' | 'center' | 'right';
|
|
41
|
+
width?: number;
|
|
42
|
+
height?: number;
|
|
43
|
+
localized?: string;
|
|
44
|
+
minHeight?: string;
|
|
45
|
+
accept?: string;
|
|
46
|
+
multiple?: boolean;
|
|
47
|
+
}
|
|
48
|
+
export interface ReactaDefinition {
|
|
49
|
+
name: string;
|
|
50
|
+
version: string;
|
|
51
|
+
displayName: string;
|
|
52
|
+
localization?: string;
|
|
53
|
+
properties: DefinitionPropertyField[];
|
|
54
|
+
validationHandlerName?: string;
|
|
55
|
+
submitHandlerName?: string;
|
|
56
|
+
}
|
|
57
|
+
export interface ReactaInstance {
|
|
58
|
+
name: string;
|
|
59
|
+
definition: string;
|
|
60
|
+
version: string;
|
|
61
|
+
values: Record<string, FieldValueType>;
|
|
62
|
+
}
|
|
63
|
+
export interface ReactaFormProps {
|
|
64
|
+
definitionData: string | Record<string, unknown>;
|
|
65
|
+
language?: string;
|
|
66
|
+
instance?: ReactaInstance;
|
|
67
|
+
className?: string;
|
|
68
|
+
darkMode?: boolean;
|
|
69
|
+
style?: React.CSSProperties;
|
|
70
|
+
}
|
|
71
|
+
export type FieldValidationHandler = (value: FieldValueType | unknown, t: (defaultText: string, ...args: unknown[]) => string) => string | undefined;
|
|
72
|
+
export type FormValidationHandler = (valuesMap: Record<string, FieldValueType | unknown>, t: (key: string, ...args: unknown[]) => string) => string[] | undefined;
|
|
73
|
+
export type FormSubmissionHandler = (definition: ReactaDefinition | Record<string, unknown>, instanceName: string | null, valuesMap: Record<string, FieldValueType | unknown>, t: (defaultText: string, ...args: unknown[]) => string) => string[] | undefined;
|
|
74
|
+
export type InputOnChange<T> = (value: T | string, error: string | null) => void;
|
|
75
|
+
export interface BaseInputProps<TValue = unknown, TField extends DefinitionPropertyField = DefinitionPropertyField> {
|
|
76
|
+
field: TField;
|
|
77
|
+
value: TValue;
|
|
78
|
+
placeholder?: string;
|
|
79
|
+
onChange?: InputOnChange<TValue>;
|
|
80
|
+
onError?: (error: string | null) => void;
|
|
81
|
+
}
|
|
82
|
+
export type ReactaFormContextType = {
|
|
83
|
+
definitionName: string;
|
|
84
|
+
language: string;
|
|
85
|
+
darkMode: boolean;
|
|
86
|
+
formStyle: {
|
|
87
|
+
container?: React.CSSProperties;
|
|
88
|
+
titleStyle?: React.CSSProperties;
|
|
89
|
+
};
|
|
90
|
+
fieldStyle: Record<string, unknown>;
|
|
91
|
+
t: (defaultText: string, ...args: unknown[]) => string;
|
|
92
|
+
};
|
|
93
|
+
export type ReactaFormProviderProps = {
|
|
94
|
+
children: ReactNode;
|
|
95
|
+
defaultDefinitionName?: string;
|
|
96
|
+
defaultStyle?: Record<string, unknown>;
|
|
97
|
+
defaultLanguage?: string;
|
|
98
|
+
defaultDarkMode?: boolean;
|
|
99
|
+
defaultLocalizeName?: string;
|
|
100
|
+
className?: string;
|
|
101
|
+
};
|
|
102
|
+
export type TranslationMap = Record<string, string>;
|
|
103
|
+
export type TranslationCache = Map<string, TranslationMap>;
|
|
104
|
+
export interface RegistryResult<T = unknown> {
|
|
105
|
+
success: boolean;
|
|
106
|
+
data?: T;
|
|
107
|
+
error?: string;
|
|
108
|
+
}
|
|
109
|
+
export interface FieldGroup {
|
|
110
|
+
name: string;
|
|
111
|
+
displayName: string;
|
|
112
|
+
description?: string;
|
|
113
|
+
collapsed?: boolean;
|
|
114
|
+
order?: number;
|
|
115
|
+
}
|
|
116
|
+
export interface ValidationResult {
|
|
117
|
+
isValid: boolean;
|
|
118
|
+
errors: string[];
|
|
119
|
+
warnings?: string[];
|
|
120
|
+
}
|
|
121
|
+
export type FormEventType = 'init' | 'change' | 'validate' | 'submit' | 'reset';
|
|
122
|
+
export interface FormEvent {
|
|
123
|
+
type: FormEventType;
|
|
124
|
+
timestamp: Date;
|
|
125
|
+
data?: unknown;
|
|
126
|
+
}
|
|
127
|
+
export interface EnhancedDefinitionPropertyField extends DefinitionPropertyField {
|
|
128
|
+
category?: string;
|
|
129
|
+
tags?: string[];
|
|
130
|
+
dependencies?: string[];
|
|
131
|
+
conditional?: {
|
|
132
|
+
field: string;
|
|
133
|
+
value: unknown;
|
|
134
|
+
operator?: 'equals' | 'not_equals' | 'contains' | 'greater_than' | 'less_than';
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare class BaseRegistry<T> {
|
|
2
|
+
private map;
|
|
3
|
+
register(name: string, value: T): void;
|
|
4
|
+
get(name: string): T | undefined;
|
|
5
|
+
has(name: string): boolean;
|
|
6
|
+
list(): string[];
|
|
7
|
+
entries(): [string, T][];
|
|
8
|
+
values(): T[];
|
|
9
|
+
size(): number;
|
|
10
|
+
unregister(name: string): boolean;
|
|
11
|
+
clear(): void;
|
|
12
|
+
registerAll(entries: Record<string, T> | [string, T][]): void;
|
|
13
|
+
getOrDefault(name: string, defaultValue: T): T;
|
|
14
|
+
}
|
|
15
|
+
export default BaseRegistry;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import BaseRegistry from "./baseRegistry";
|
|
2
|
+
import React from "react";
|
|
3
|
+
type ComponentType = React.ComponentType<any>;
|
|
4
|
+
declare const registry: BaseRegistry<ComponentType>;
|
|
5
|
+
export declare function registerComponent(type: string, component: ComponentType): void;
|
|
6
|
+
export declare function getComponent(type: string): ComponentType | undefined;
|
|
7
|
+
export declare function listComponents(): string[];
|
|
8
|
+
export declare function registerBaseComponents(): void;
|
|
9
|
+
export default registry;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "./componentRegistry";
|
|
2
|
+
export * from "./submissionHandlerRegistry";
|
|
3
|
+
export * from "./validationHandlerRegistry";
|
|
4
|
+
export * from "./baseRegistry";
|
|
5
|
+
export { default as componentRegistry } from "./componentRegistry";
|
|
6
|
+
export { default as submissionRegistry } from "./submissionHandlerRegistry";
|
|
7
|
+
export { default as validatorRegistry } from "./validationHandlerRegistry";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { FormSubmissionHandler } from "../reactaFormTypes";
|
|
2
|
+
import BaseRegistry from "./baseRegistry";
|
|
3
|
+
declare const registry: BaseRegistry<FormSubmissionHandler>;
|
|
4
|
+
export declare function registerSubmissionHandler(submitterName: string, fn: FormSubmissionHandler): void;
|
|
5
|
+
export declare function getFormSubmissionHandler(submitterName: string): FormSubmissionHandler | undefined;
|
|
6
|
+
export default registry;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { FieldValidationHandler, FormValidationHandler } from "../reactaFormTypes";
|
|
2
|
+
export declare function registerFormValidationHandler(name: string, fn: FormValidationHandler): void;
|
|
3
|
+
export declare function registerFieldValidationHandler(category: string, name: string, fn: FieldValidationHandler): void;
|
|
4
|
+
export declare function getFieldValidationHandler(category: string, name: string): FieldValidationHandler | null;
|
|
5
|
+
export declare function getFormValidationHandler(name: string): FormValidationHandler | null;
|
|
6
|
+
export declare function listFieldValidationHandlers(category?: string): string[];
|
|
7
|
+
export declare function listFormValidationHandlers(): string[];
|
|
8
|
+
declare const _default: {
|
|
9
|
+
registerFormValidationHandler: typeof registerFormValidationHandler;
|
|
10
|
+
registerFieldValidationHandler: typeof registerFieldValidationHandler;
|
|
11
|
+
getFieldValidationHandler: typeof getFieldValidationHandler;
|
|
12
|
+
getFormValidationHandler: typeof getFormValidationHandler;
|
|
13
|
+
listFieldValidationHandlers: typeof listFieldValidationHandlers;
|
|
14
|
+
listFormValidationHandlers: typeof listFormValidationHandlers;
|
|
15
|
+
};
|
|
16
|
+
export default _default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ReactaDefinition, FieldValueType, ReactaInstance } from "./reactaFormTypes";
|
|
2
|
+
export interface SubmitResult {
|
|
3
|
+
success: boolean;
|
|
4
|
+
message: string;
|
|
5
|
+
data?: Record<string, unknown>;
|
|
6
|
+
errors?: string[];
|
|
7
|
+
}
|
|
8
|
+
export declare function submitForm(definition: ReactaDefinition, instance: ReactaInstance | null, valuesMap: Record<string, FieldValueType | unknown>, t: (key: string) => string, errors: Record<string, string>): SubmitResult;
|
|
9
|
+
declare const _default: {
|
|
10
|
+
submitForm: typeof submitForm;
|
|
11
|
+
};
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ReactaDefinition, FieldValueType, DefinitionPropertyField } from "./reactaFormTypes";
|
|
2
|
+
export declare function validateFieldValue(definitionName: string, field: Partial<DefinitionPropertyField>, value: FieldValueType | unknown, t: (key: string) => string): string | null;
|
|
3
|
+
export declare function validateFormValues(definition: ReactaDefinition | null, valuesMap: Record<string, FieldValueType | unknown>, t: (key: string) => string): string[] | null;
|
|
4
|
+
export declare function clearValidationCache(): void;
|
|
5
|
+
declare const _default: {
|
|
6
|
+
validateFieldValue: typeof validateFieldValue;
|
|
7
|
+
validateFormValues: typeof validateFormValues;
|
|
8
|
+
clearValidationCache: typeof clearValidationCache;
|
|
9
|
+
};
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type DebouncedCallback = {
|
|
2
|
+
callback: (...args: unknown[]) => void;
|
|
3
|
+
cancel: () => void;
|
|
4
|
+
flush: () => void;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* useDebouncedCallback
|
|
8
|
+
* - callback: function to call
|
|
9
|
+
* - wait: debounce delay in ms
|
|
10
|
+
* - options.leading: if true, call on leading edge (optional)
|
|
11
|
+
*
|
|
12
|
+
* Returns { callback, cancel, flush } where callback is debounced.
|
|
13
|
+
*/
|
|
14
|
+
export declare function useDebouncedCallback(callback: (...args: unknown[]) => unknown, wait?: number, options?: {
|
|
15
|
+
leading?: boolean;
|
|
16
|
+
}): DebouncedCallback;
|
|
17
|
+
/**
|
|
18
|
+
* createDebouncedCallback - non-hook variant that returns the same API but
|
|
19
|
+
* doesn't use React hooks. Useful for creating many debounced callbacks
|
|
20
|
+
* programmatically (e.g., driven from a static schema) while handling
|
|
21
|
+
* lifecycle cleanup manually.
|
|
22
|
+
*/
|
|
23
|
+
export declare function createDebouncedCallback(callback: (...args: unknown[]) => unknown, wait?: number, options?: {
|
|
24
|
+
leading?: boolean;
|
|
25
|
+
}): DebouncedCallback;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ReactaFormContextType } from '../core/reactaFormTypes';
|
|
2
|
+
export declare const ReactaFormContext: import("react").Context<ReactaFormContextType | undefined>;
|
|
3
|
+
declare const useReactaFormContext: () => ReactaFormContextType;
|
|
4
|
+
export default useReactaFormContext;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { default as ReactaForm } from './components/ReactaForm';
|
|
2
|
+
export { default as ReactaFormRenderer } from './components/ReactaFormRenderer';
|
|
3
|
+
export type { ReactaFormRendererProps } from './components/ReactaFormRenderer';
|
|
4
|
+
export { ReactaFormProvider } from './components/ReactaFormProvider';
|
|
5
|
+
export { default as useReactaFormContext } from './hooks/useReactaFormContext';
|
|
6
|
+
export type { ReactaFormContextType, ReactaFormProviderProps, DefinitionPropertyField, ReactaDefinition, ReactaInstance, ReactaFormProps, FieldValueType, ErrorType, FieldValidationHandler, FormValidationHandler, FormSubmissionHandler, InputOnChange, BaseInputProps } from './core/reactaFormTypes';
|
|
7
|
+
export { registerComponent, getComponent, } from './core/registries/componentRegistry';
|
|
8
|
+
export { validateFieldValue, validateFormValues } from './core/validation';
|
|
9
|
+
export { loadJsonDefinition, createInstanceFromDefinition, // Create new instance with default values
|
|
10
|
+
loadInstance } from './core/reactaFormModel';
|
|
11
|
+
export { registerSubmissionHandler, } from './core/registries/submissionHandlerRegistry';
|
|
12
|
+
export { registerFieldValidationHandler, registerFormValidationHandler, } from './core/registries/validationHandlerRegistry';
|
|
13
|
+
export { useDebouncedCallback } from './hooks/useDebouncedCallback';
|
|
14
|
+
export * as Units from './utils/unitValueMapper';
|
|
15
|
+
export { serializeInstance, deserializeInstance, serializeDefinition, deserializeDefinition } from './utils/definitionSerializers';
|