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,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CSS class constants and helpers
|
|
3
|
+
*/
|
|
4
|
+
export declare const CSS_CLASSES: {
|
|
5
|
+
readonly field: "reactaform-field";
|
|
6
|
+
readonly label: "reactaform-label";
|
|
7
|
+
readonly input: "reactaform-input";
|
|
8
|
+
readonly textInput: "reactaform-input--text";
|
|
9
|
+
readonly inputNumber: "reactaform-input--number";
|
|
10
|
+
readonly inputSelect: "reactaform-select";
|
|
11
|
+
readonly rangeInput: "reactaform-input--range";
|
|
12
|
+
readonly button: "reactaform-button";
|
|
13
|
+
};
|
|
14
|
+
export declare const combineClasses: (...classes: (string | undefined | null | false | Record<string, boolean>)[]) => string;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { ReactaDefinition, DefinitionPropertyField } from "../core/reactaFormTypes";
|
|
2
|
+
export declare function isDefinitionPropertyField(obj: unknown): obj is DefinitionPropertyField;
|
|
3
|
+
export declare function isReactaDefinition(obj: unknown): obj is ReactaDefinition;
|
|
4
|
+
/**
|
|
5
|
+
* Enhanced serialization options for better control over the process
|
|
6
|
+
*/
|
|
7
|
+
export interface SerializationOptions {
|
|
8
|
+
includeMetadata?: boolean;
|
|
9
|
+
dateFormat?: 'iso' | 'timestamp' | 'locale';
|
|
10
|
+
fileHandling?: 'metadata' | 'skip' | 'base64';
|
|
11
|
+
prettify?: boolean;
|
|
12
|
+
excludeFields?: string[];
|
|
13
|
+
includeOnlyFields?: string[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Enhanced deserialization options
|
|
17
|
+
*/
|
|
18
|
+
export interface DeserializationOptions {
|
|
19
|
+
strict?: boolean;
|
|
20
|
+
validateTypes?: boolean;
|
|
21
|
+
preserveUnknownFields?: boolean;
|
|
22
|
+
dateFormat?: 'auto' | 'iso' | 'timestamp';
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Serialization result with metadata
|
|
26
|
+
*/
|
|
27
|
+
export interface SerializationResult {
|
|
28
|
+
success: boolean;
|
|
29
|
+
data?: string;
|
|
30
|
+
error?: string;
|
|
31
|
+
metadata?: {
|
|
32
|
+
fieldCount: number;
|
|
33
|
+
excludedFields: string[];
|
|
34
|
+
warnings: string[];
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Deserialization result with validation info
|
|
39
|
+
*/
|
|
40
|
+
export interface DeserializationResult<T = unknown> {
|
|
41
|
+
success: boolean;
|
|
42
|
+
data?: T;
|
|
43
|
+
error?: string;
|
|
44
|
+
warnings?: string[];
|
|
45
|
+
validationErrors?: string[];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Enhanced instance serialization with comprehensive options and error handling
|
|
49
|
+
*/
|
|
50
|
+
export declare function serializeInstance(instance: Record<string, unknown>, definition?: ReactaDefinition | Record<string, unknown>, options?: SerializationOptions): SerializationResult;
|
|
51
|
+
/**
|
|
52
|
+
* Enhanced instance deserialization with comprehensive validation and error handling
|
|
53
|
+
*/
|
|
54
|
+
export declare function deserializeInstance(serialized: string, definition?: ReactaDefinition | Record<string, unknown>, options?: DeserializationOptions): DeserializationResult<Record<string, unknown>>;
|
|
55
|
+
/**
|
|
56
|
+
* Enhanced definition serialization with validation and metadata
|
|
57
|
+
*/
|
|
58
|
+
export declare function serializeDefinition(definition: ReactaDefinition | Record<string, unknown>, options?: SerializationOptions): SerializationResult;
|
|
59
|
+
/**
|
|
60
|
+
* Enhanced definition deserialization with comprehensive validation
|
|
61
|
+
*/
|
|
62
|
+
export declare function deserializeDefinition(input: string | Record<string, unknown>, options?: DeserializationOptions): DeserializationResult<ReactaDefinition>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { DefinitionPropertyField } from "../core/reactaFormTypes";
|
|
2
|
+
/**
|
|
3
|
+
* Enhanced rename duplicated groups with better conflict resolution
|
|
4
|
+
* For example: g1, g1, g2, g1 becomes g1, g1, g2, g1(1)
|
|
5
|
+
* This mutates the provided nameToField map so downstream code sees the
|
|
6
|
+
* renamed group values.
|
|
7
|
+
*/
|
|
8
|
+
export declare const renameDuplicatedGroups: (properties: DefinitionPropertyField[], nameToField: Record<string, DefinitionPropertyField>) => number;
|
|
9
|
+
/**
|
|
10
|
+
* Enhanced consecutive field grouping with metadata
|
|
11
|
+
*/
|
|
12
|
+
export declare const groupConsecutiveFields: (items: DefinitionPropertyField[], options?: {
|
|
13
|
+
includeEmpty?: boolean;
|
|
14
|
+
}) => {
|
|
15
|
+
groups: Array<{
|
|
16
|
+
name: string | null;
|
|
17
|
+
fields: DefinitionPropertyField[];
|
|
18
|
+
}>;
|
|
19
|
+
metadata: {
|
|
20
|
+
totalGroups: number;
|
|
21
|
+
emptyGroups: number;
|
|
22
|
+
largestGroup: number;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ReactaForm Utils - Comprehensive utility functions
|
|
3
|
+
*
|
|
4
|
+
* This module provides enhanced utility functions for form building,
|
|
5
|
+
* styling, serialization, translation, and component management.
|
|
6
|
+
*/
|
|
7
|
+
export { combineClasses, CSS_CLASSES, } from './cssClasses';
|
|
8
|
+
export { serializeInstance, deserializeInstance, serializeDefinition, deserializeDefinition, type SerializationOptions, type DeserializationOptions, type SerializationResult, type DeserializationResult } from './definitionSerializers';
|
|
9
|
+
export { renameDuplicatedGroups, groupConsecutiveFields } from './groupingHelpers';
|
|
10
|
+
export { loadCommonTranslation, loadUserTranslation, createTranslationFunction, } from './translationCache';
|
|
11
|
+
export * from './unitValueMapper';
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { TranslationMap, TranslationCache } from "../core/reactaFormTypes";
|
|
2
|
+
/**
|
|
3
|
+
* Translation loading result
|
|
4
|
+
*/
|
|
5
|
+
export interface TranslationLoadResult {
|
|
6
|
+
success: boolean;
|
|
7
|
+
translations: TranslationMap;
|
|
8
|
+
error?: string;
|
|
9
|
+
fromCache?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare const userTranslationCache: TranslationCache;
|
|
12
|
+
export declare const userFailedSet: Set<string>;
|
|
13
|
+
/**
|
|
14
|
+
* Enhanced common translation loader with better error handling
|
|
15
|
+
*/
|
|
16
|
+
export declare const loadCommon: (language: string) => Promise<TranslationLoadResult>;
|
|
17
|
+
/**
|
|
18
|
+
* Enhanced common translation loading with caching and metadata
|
|
19
|
+
*/
|
|
20
|
+
export declare const loadCommonTranslation: (language: string) => Promise<TranslationLoadResult>;
|
|
21
|
+
/**
|
|
22
|
+
* Enhanced user translation loading with better error handling and caching
|
|
23
|
+
*/
|
|
24
|
+
export declare const loadUserTranslation: (language: string, localizeName: string) => Promise<TranslationLoadResult>;
|
|
25
|
+
/**
|
|
26
|
+
* Return whether translation subsystem should run in debug mode.
|
|
27
|
+
* Checks multiple env sources (Vite, webpack, Next.js, etc.) for dev/debug mode.
|
|
28
|
+
*/
|
|
29
|
+
export declare function isDebugMode(): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Create a translation function using provided maps
|
|
32
|
+
* @returns A translation function
|
|
33
|
+
* This function processes text using only dictionary lookups and basic string interpolation.
|
|
34
|
+
* Note: handling pluralization is not supported now
|
|
35
|
+
* @example
|
|
36
|
+
* const t = createTranslationFunction('fr', commonMap, userMap);
|
|
37
|
+
* const translated = t("Hello, {{1}}!", "world");
|
|
38
|
+
*/
|
|
39
|
+
export declare const createTranslationFunction: (language: string, commonMap: TranslationMap, userMap: TranslationMap) => (defaultText: string, ...args: unknown[]) => string;
|
|
40
|
+
/**
|
|
41
|
+
* Clear all caches
|
|
42
|
+
*/
|
|
43
|
+
export declare function clearTranslationCaches(): void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const dimensionUnitsMap: Record<string, string[]>;
|
|
2
|
+
export declare const dimensionUnitDisplayMap: Record<string, Record<string, string>>;
|
|
3
|
+
export declare const dimensonUnitFactorsMap: Record<string, Record<string, number>>;
|
|
4
|
+
export declare const unitsByDimension: Record<string, Record<string, {
|
|
5
|
+
name: string;
|
|
6
|
+
shortName: string;
|
|
7
|
+
factor?: number;
|
|
8
|
+
}>>;
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "reactaform",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A powerful, type-safe React form builder library with dynamic field rendering, conditional visibility, multi-language support, and extensible validation",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"react",
|
|
7
|
+
"form",
|
|
8
|
+
"form-builder",
|
|
9
|
+
"typescript",
|
|
10
|
+
"validation",
|
|
11
|
+
"dynamic-forms",
|
|
12
|
+
"i18n",
|
|
13
|
+
"react-form",
|
|
14
|
+
"form-library",
|
|
15
|
+
"conditional-fields"
|
|
16
|
+
],
|
|
17
|
+
"author": "yanggmtl",
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/yanggmtl/reactaform.git",
|
|
22
|
+
"directory": "packages/reactaform"
|
|
23
|
+
},
|
|
24
|
+
"homepage": "https://github.com/yanggmtl/reactaform#readme",
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/yanggmtl/reactaform/issues"
|
|
27
|
+
},
|
|
28
|
+
"main": "dist/reactaform.cjs.js",
|
|
29
|
+
"module": "dist/reactaform.es.js",
|
|
30
|
+
"types": "dist/index.d.ts",
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"import": "./dist/reactaform.es.js",
|
|
35
|
+
"require": "./dist/reactaform.cjs.js"
|
|
36
|
+
},
|
|
37
|
+
"./style.css": "./dist/reactaform.css"
|
|
38
|
+
},
|
|
39
|
+
"files": [
|
|
40
|
+
"dist",
|
|
41
|
+
"README.md",
|
|
42
|
+
"LICENSE"
|
|
43
|
+
],
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"react": "^19.2.0",
|
|
46
|
+
"react-dom": "^19.2.0"
|
|
47
|
+
},
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build:lib": "vite build --config vite.lib.config.ts && tsc -p tsconfig.build.json",
|
|
50
|
+
"pack:staging": "node ./scripts/pack-staging.cjs",
|
|
51
|
+
"test": "vitest run --config ./vitest.config.ts",
|
|
52
|
+
"typecheck": "tsc -p tsconfig.app.json --noEmit"
|
|
53
|
+
}
|
|
54
|
+
}
|