@akad/form-builder 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/components/FormBuilder/FormBuilder.config.d.ts +333 -0
- package/components/FormBuilder/FormBuilder.d.ts +31 -0
- package/components/FormBuilder/components/AddressFormGroup/AddressFormGroup.d.ts +53 -0
- package/components/FormBuilder/components/AddressFormGroup/AddressFormGroup.test.d.ts +1 -0
- package/components/FormBuilder/components/AddressFormGroup/index.d.ts +4 -0
- package/components/FormBuilder/components/FieldRenderer/FieldRenderer.d.ts +39 -0
- package/components/FormBuilder/components/FieldRenderer/FieldRenderer.test.d.ts +1 -0
- package/components/FormBuilder/components/FieldRenderer/index.d.ts +3 -0
- package/components/FormBuilder/components/GenericWrapper/GenericWrapper.d.ts +61 -0
- package/components/FormBuilder/components/GenericWrapper/GenericWrapper.test.d.ts +1 -0
- package/components/FormBuilder/components/GenericWrapper/index.d.ts +4 -0
- package/components/FormBuilder/components/RadioGroup/RadioGroup.d.ts +67 -0
- package/components/FormBuilder/components/RadioGroup/RadioGroup.test.d.ts +1 -0
- package/components/FormBuilder/components/RadioGroup/index.d.ts +4 -0
- package/components/FormBuilder/hooks/useForm.d.ts +30 -0
- package/components/FormBuilder/hooks/useForm.test.d.ts +1 -0
- package/components/FormBuilder/hooks/useFormParser.d.ts +7 -0
- package/components/FormBuilder/hooks/useFormParser.test.d.ts +1 -0
- package/components/FormBuilder/hooks/useFormState.d.ts +28 -0
- package/components/FormBuilder/hooks/useFormState.test.d.ts +1 -0
- package/components/FormBuilder/hooks/useFormStepper.d.ts +64 -0
- package/components/FormBuilder/hooks/useFormStepper.test.d.ts +1 -0
- package/components/FormBuilder/hooks/useFormValidation.d.ts +7 -0
- package/components/FormBuilder/hooks/useFormValidation.test.d.ts +1 -0
- package/components/FormBuilder/index.d.ts +27 -0
- package/components/FormBuilder/utils/ajv/formats.d.ts +27 -0
- package/components/FormBuilder/utils/ajv/formats.test.d.ts +1 -0
- package/components/FormBuilder/utils/ajv/instance.d.ts +2 -0
- package/components/FormBuilder/utils/ajv/instance.test.d.ts +1 -0
- package/components/FormBuilder/utils/componentDetection.d.ts +24 -0
- package/components/FormBuilder/utils/componentDetection.test.d.ts +1 -0
- package/components/FormBuilder/utils/componentRegistry.d.ts +10 -0
- package/components/FormBuilder/utils/componentRegistry.test.d.ts +1 -0
- package/components/FormBuilder/utils/facade/AddressFormLegacy.d.ts +20 -0
- package/components/FormBuilder/utils/facade/AddressFormLegacy.test.d.ts +1 -0
- package/components/FormBuilder/utils/facade/PaymentOptionsLegacy.d.ts +22 -0
- package/components/FormBuilder/utils/facade/PaymentOptionsLegacy.test.d.ts +1 -0
- package/components/FormBuilder/utils/facade/index.d.ts +6 -0
- package/components/FormBuilder/utils/facade/makeFullFormHookFacade.d.ts +111 -0
- package/components/FormBuilder/utils/facade/makeFullFormHookFacade.test.d.ts +1 -0
- package/components/FormBuilder/utils/facade/useLegacyFormHook.d.ts +45 -0
- package/components/FormBuilder/utils/facade/useLegacyFormHook.test.d.ts +1 -0
- package/components/FormBuilder/utils/fieldExtractors.d.ts +68 -0
- package/components/FormBuilder/utils/fieldExtractors.test.d.ts +1 -0
- package/components/FormBuilder/utils/generateFieldsFromSchema.d.ts +67 -0
- package/components/FormBuilder/utils/generateFieldsFromSchema.test.d.ts +1 -0
- package/components/FormBuilder/utils/objectAccess.d.ts +7 -0
- package/components/FormBuilder/utils/objectAccess.test.d.ts +1 -0
- package/components/FormBuilder/utils/schemaUtils.d.ts +113 -0
- package/components/FormBuilder/utils/schemaUtils.test.d.ts +1 -0
- package/components/FormBuilder/utils/typeCoercion.d.ts +57 -0
- package/components/FormBuilder/utils/typeCoercion.test.d.ts +1 -0
- package/components/index.d.ts +2 -0
- package/main.d.ts +1 -0
- package/main.test.d.ts +1 -0
- package/package.json +13 -0
- package/react-lib.css +1 -0
- package/react-lib.js +72330 -0
- package/react-lib.umd.cjs +215 -0
- package/vite.svg +1 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { UISchemaField } from '../FormBuilder.config';
|
|
2
|
+
/**
|
|
3
|
+
* Resolve UI config from nested or flat UISchema
|
|
4
|
+
* @description Supports BOTH flat dot notation and nested object notation
|
|
5
|
+
* @param fieldPath Field path (e.g., "insured.name" or "email")
|
|
6
|
+
* @param uiSchema UI Schema object to search in
|
|
7
|
+
* @returns UISchemaField configuration or empty object if not found
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* // Flat notation
|
|
11
|
+
* resolveUIConfig('insured.name', { 'insured.name': { 'ui:component': 'Input' } })
|
|
12
|
+
* // Returns { 'ui:component': 'Input' }
|
|
13
|
+
*
|
|
14
|
+
* // Nested notation
|
|
15
|
+
* resolveUIConfig('insured.name', { insured: { name: { 'ui:component': 'Input' } } })
|
|
16
|
+
* // Returns { 'ui:component': 'Input' }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare const resolveUIConfig: (fieldPath: string, uiSchema: Record<string, unknown>) => UISchemaField;
|
|
20
|
+
/**
|
|
21
|
+
* Flatten nested schema properties into dot notation paths
|
|
22
|
+
* @description Recursively extracts all fields from nested object schemas into flat paths
|
|
23
|
+
* @param properties Schema properties object
|
|
24
|
+
* @param prefix Current path prefix for nested fields
|
|
25
|
+
* @param parentRequired Parent required array for tracking required status
|
|
26
|
+
* @returns Array of [fieldPath, fieldSchema, isRequired] tuples
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* flattenSchemaProperties({
|
|
30
|
+
* name: { type: 'string' },
|
|
31
|
+
* address: {
|
|
32
|
+
* type: 'object',
|
|
33
|
+
* properties: {
|
|
34
|
+
* city: { type: 'string' }
|
|
35
|
+
* }
|
|
36
|
+
* }
|
|
37
|
+
* })
|
|
38
|
+
* // Returns [
|
|
39
|
+
* // ['name', { type: 'string' }, false],
|
|
40
|
+
* // ['address.city', { type: 'string' }, false]
|
|
41
|
+
* // ]
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare const flattenSchemaProperties: (properties: Record<string, unknown>, prefix?: string, parentRequired?: string[]) => Array<[string, Record<string, unknown>, boolean]>;
|
|
45
|
+
/**
|
|
46
|
+
* Flatten nested UISchema children to dot notation
|
|
47
|
+
* @description Converts nested object notation to flat dot notation in wrapper children
|
|
48
|
+
* @param children Children object from wrapper ui:props.children
|
|
49
|
+
* @param prefix Current path prefix for nested fields
|
|
50
|
+
* @returns Flattened children with dot notation keys
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* flattenUISchemaChildren({
|
|
54
|
+
* title: { 'ui:component': 'DsHeading' },
|
|
55
|
+
* PEP: {
|
|
56
|
+
* isPep: { 'ui:component': 'RadioGroup' }
|
|
57
|
+
* },
|
|
58
|
+
* insured: {
|
|
59
|
+
* document: { 'ui:component': 'Input' },
|
|
60
|
+
* name: { 'ui:component': 'Input' }
|
|
61
|
+
* }
|
|
62
|
+
* })
|
|
63
|
+
* // Returns {
|
|
64
|
+
* // title: { 'ui:component': 'DsHeading' },
|
|
65
|
+
* // 'PEP.isPep': { 'ui:component': 'RadioGroup' },
|
|
66
|
+
* // 'insured.document': { 'ui:component': 'Input' },
|
|
67
|
+
* // 'insured.name': { 'ui:component': 'Input' }
|
|
68
|
+
* // }
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export declare const flattenUISchemaChildren: (children: Record<string, unknown>, prefix?: string) => Record<string, unknown>;
|
|
72
|
+
/**
|
|
73
|
+
* Get the specific field object at a given path
|
|
74
|
+
* @description Navigates to the specified path and returns the field object directly (not wrapped in a key).
|
|
75
|
+
* Supports both flat object notation and JSON Schema format (with properties key).
|
|
76
|
+
* @param path Dot-notation path to navigate (e.g., "insured.address.number")
|
|
77
|
+
* @param obj Object to navigate through
|
|
78
|
+
* @returns The field object directly, or empty object if path doesn't exist
|
|
79
|
+
* @example
|
|
80
|
+
* ```ts
|
|
81
|
+
* // Flat notation
|
|
82
|
+
* getObjectAtPath('insured.address.number', {
|
|
83
|
+
* insured: {
|
|
84
|
+
* address: {
|
|
85
|
+
* number: { type: 'string', minLength: 1 },
|
|
86
|
+
* street: { type: 'string' }
|
|
87
|
+
* }
|
|
88
|
+
* }
|
|
89
|
+
* })
|
|
90
|
+
* // Returns { type: 'string', minLength: 1 }
|
|
91
|
+
*
|
|
92
|
+
* // JSON Schema notation
|
|
93
|
+
* getObjectAtPath('insured.address.number', {
|
|
94
|
+
* type: 'object',
|
|
95
|
+
* properties: {
|
|
96
|
+
* insured: {
|
|
97
|
+
* type: 'object',
|
|
98
|
+
* properties: {
|
|
99
|
+
* address: {
|
|
100
|
+
* type: 'object',
|
|
101
|
+
* properties: {
|
|
102
|
+
* number: { type: 'string', minLength: 1 },
|
|
103
|
+
* street: { type: 'string' }
|
|
104
|
+
* }
|
|
105
|
+
* }
|
|
106
|
+
* }
|
|
107
|
+
* }
|
|
108
|
+
* }
|
|
109
|
+
* })
|
|
110
|
+
* // Returns { type: 'string', minLength: 1 }
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
export declare const getObjectAtPath: (path: string, obj: Record<string, unknown>) => Record<string, unknown>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get schema properties for a field path
|
|
3
|
+
* @description Navigates through nested schema properties using dot notation
|
|
4
|
+
* @param path Dot notation path to field (e.g., "user.address.city")
|
|
5
|
+
* @param rootSchema Root JSON Schema object
|
|
6
|
+
* @returns Schema properties for the field or null if not found
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* const schema = {
|
|
10
|
+
* properties: {
|
|
11
|
+
* user: {
|
|
12
|
+
* type: 'object',
|
|
13
|
+
* properties: {
|
|
14
|
+
* name: { type: 'string' }
|
|
15
|
+
* }
|
|
16
|
+
* }
|
|
17
|
+
* }
|
|
18
|
+
* };
|
|
19
|
+
* getSchemaProperties('user.name', schema); // Returns { type: 'string' }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function getSchemaProperties(path: string, rootSchema: Record<string, unknown>): Record<string, unknown> | null;
|
|
23
|
+
/**
|
|
24
|
+
* Coerce value to correct type based on schema
|
|
25
|
+
* @description Converts string values to their proper types (boolean, number, integer)
|
|
26
|
+
* based on JSON Schema type definition
|
|
27
|
+
* @param value Value to coerce (typically a string from HTML form elements)
|
|
28
|
+
* @param schemaProps Schema properties containing type information
|
|
29
|
+
* @returns Coerced value with correct type
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* coerceType('true', { type: 'boolean' }); // Returns true
|
|
33
|
+
* coerceType('42', { type: 'number' }); // Returns 42
|
|
34
|
+
* coerceType('hello', { type: 'string' }); // Returns 'hello' (unchanged)
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare function coerceType(value: unknown, schemaProps: Record<string, unknown>): unknown;
|
|
38
|
+
/**
|
|
39
|
+
* Coerce field value based on JSON Schema
|
|
40
|
+
* @description Main utility function that looks up field schema and coerces value
|
|
41
|
+
* @param fieldPath Dot notation path to field
|
|
42
|
+
* @param value Value to coerce
|
|
43
|
+
* @param schema Root JSON Schema object
|
|
44
|
+
* @returns Coerced value with correct type
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* const schema = {
|
|
48
|
+
* properties: {
|
|
49
|
+
* isActive: { type: 'boolean' },
|
|
50
|
+
* age: { type: 'number' }
|
|
51
|
+
* }
|
|
52
|
+
* };
|
|
53
|
+
* coerceFieldValue('isActive', 'true', schema); // Returns true
|
|
54
|
+
* coerceFieldValue('age', '25', schema); // Returns 25
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare function coerceFieldValue(fieldPath: string, value: unknown, schema: Record<string, unknown>): unknown;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/main.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './components/index';
|
package/main.test.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
package/react-lib.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.ds-radio-group{display:block;width:100%}.ds-radio-group__error{display:block;margin-top:.25rem;font-size:.875rem;color:var(--ds-color-danger-500, #dc3545)}
|