form-builder-pro 1.2.8 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css +42 -0
- package/dist/index.d.mts +89 -2
- package/dist/index.d.ts +89 -2
- package/dist/index.js +1368 -414
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1363 -415
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.css
CHANGED
|
@@ -866,6 +866,9 @@ body {
|
|
|
866
866
|
.right-1 {
|
|
867
867
|
right: 0.25rem;
|
|
868
868
|
}
|
|
869
|
+
.right-2 {
|
|
870
|
+
right: 0.5rem;
|
|
871
|
+
}
|
|
869
872
|
.right-6 {
|
|
870
873
|
right: 1.5rem;
|
|
871
874
|
}
|
|
@@ -948,6 +951,9 @@ body {
|
|
|
948
951
|
.block {
|
|
949
952
|
display: block;
|
|
950
953
|
}
|
|
954
|
+
.inline {
|
|
955
|
+
display: inline;
|
|
956
|
+
}
|
|
951
957
|
.flex {
|
|
952
958
|
display: flex;
|
|
953
959
|
}
|
|
@@ -987,18 +993,30 @@ body {
|
|
|
987
993
|
.h-screen {
|
|
988
994
|
height: 100vh;
|
|
989
995
|
}
|
|
996
|
+
.max-h-32 {
|
|
997
|
+
max-height: 8rem;
|
|
998
|
+
}
|
|
999
|
+
.max-h-48 {
|
|
1000
|
+
max-height: 12rem;
|
|
1001
|
+
}
|
|
990
1002
|
.max-h-\[90vh\] {
|
|
991
1003
|
max-height: 90vh;
|
|
992
1004
|
}
|
|
993
1005
|
.min-h-\[100px\] {
|
|
994
1006
|
min-height: 100px;
|
|
995
1007
|
}
|
|
1008
|
+
.min-h-\[120px\] {
|
|
1009
|
+
min-height: 120px;
|
|
1010
|
+
}
|
|
996
1011
|
.min-h-\[200px\] {
|
|
997
1012
|
min-height: 200px;
|
|
998
1013
|
}
|
|
999
1014
|
.min-h-\[30px\] {
|
|
1000
1015
|
min-height: 30px;
|
|
1001
1016
|
}
|
|
1017
|
+
.min-h-\[80px\] {
|
|
1018
|
+
min-height: 80px;
|
|
1019
|
+
}
|
|
1002
1020
|
.min-h-touch {
|
|
1003
1021
|
min-height: 44px;
|
|
1004
1022
|
}
|
|
@@ -1029,6 +1047,9 @@ body {
|
|
|
1029
1047
|
.max-w-\[180px\] {
|
|
1030
1048
|
max-width: 180px;
|
|
1031
1049
|
}
|
|
1050
|
+
.max-w-full {
|
|
1051
|
+
max-width: 100%;
|
|
1052
|
+
}
|
|
1032
1053
|
.flex-1 {
|
|
1033
1054
|
flex: 1 1 0%;
|
|
1034
1055
|
}
|
|
@@ -1217,6 +1238,10 @@ body {
|
|
|
1217
1238
|
.border-primary {
|
|
1218
1239
|
border-color: hsl(var(--primary));
|
|
1219
1240
|
}
|
|
1241
|
+
.border-red-200 {
|
|
1242
|
+
--tw-border-opacity: 1;
|
|
1243
|
+
border-color: rgb(254 202 202 / var(--tw-border-opacity, 1));
|
|
1244
|
+
}
|
|
1220
1245
|
.border-red-500 {
|
|
1221
1246
|
--tw-border-opacity: 1;
|
|
1222
1247
|
border-color: rgb(239 68 68 / var(--tw-border-opacity, 1));
|
|
@@ -1273,6 +1298,10 @@ body {
|
|
|
1273
1298
|
--tw-bg-opacity: 1;
|
|
1274
1299
|
background-color: rgb(249 250 251 / var(--tw-bg-opacity, 1));
|
|
1275
1300
|
}
|
|
1301
|
+
.bg-red-500 {
|
|
1302
|
+
--tw-bg-opacity: 1;
|
|
1303
|
+
background-color: rgb(239 68 68 / var(--tw-bg-opacity, 1));
|
|
1304
|
+
}
|
|
1276
1305
|
.bg-transparent {
|
|
1277
1306
|
background-color: transparent;
|
|
1278
1307
|
}
|
|
@@ -1280,6 +1309,10 @@ body {
|
|
|
1280
1309
|
--tw-bg-opacity: 1;
|
|
1281
1310
|
background-color: rgb(255 255 255 / var(--tw-bg-opacity, 1));
|
|
1282
1311
|
}
|
|
1312
|
+
.object-contain {
|
|
1313
|
+
-o-object-fit: contain;
|
|
1314
|
+
object-fit: contain;
|
|
1315
|
+
}
|
|
1283
1316
|
.p-1 {
|
|
1284
1317
|
padding: 0.25rem;
|
|
1285
1318
|
}
|
|
@@ -1758,6 +1791,11 @@ input[type="radio"]:checked::after {
|
|
|
1758
1791
|
background-color: rgb(254 242 242 / var(--tw-bg-opacity, 1));
|
|
1759
1792
|
}
|
|
1760
1793
|
|
|
1794
|
+
.hover\:bg-red-600:hover {
|
|
1795
|
+
--tw-bg-opacity: 1;
|
|
1796
|
+
background-color: rgb(220 38 38 / var(--tw-bg-opacity, 1));
|
|
1797
|
+
}
|
|
1798
|
+
|
|
1761
1799
|
.hover\:text-blue-700:hover {
|
|
1762
1800
|
--tw-text-opacity: 1;
|
|
1763
1801
|
color: rgb(29 78 216 / var(--tw-text-opacity, 1));
|
|
@@ -1995,6 +2033,10 @@ input[type="radio"]:checked::after {
|
|
|
1995
2033
|
background-color: rgb(31 41 55 / 0.5);
|
|
1996
2034
|
}
|
|
1997
2035
|
|
|
2036
|
+
.dark\:hover\:bg-red-900\/20:hover:is(.dark *) {
|
|
2037
|
+
background-color: rgb(127 29 29 / 0.2);
|
|
2038
|
+
}
|
|
2039
|
+
|
|
1998
2040
|
@media (min-width: 640px) {
|
|
1999
2041
|
|
|
2000
2042
|
.sm\:inline-block {
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import * as zustand_vanilla from 'zustand/vanilla';
|
|
3
3
|
|
|
4
|
-
type FieldType = 'text' | 'textarea' | 'number' | 'date' | 'select' | 'checkbox' | 'radio' | 'toggle' | 'file' | 'email' | 'phone';
|
|
4
|
+
type FieldType = 'text' | 'textarea' | 'number' | 'date' | 'select' | 'checkbox' | 'radio' | 'toggle' | 'file' | 'image' | 'email' | 'phone';
|
|
5
5
|
type FieldWidth = '25%' | '33%' | '50%' | '66%' | '75%' | '100%' | number;
|
|
6
6
|
declare function parseWidth(width: FieldWidth): number;
|
|
7
7
|
declare function getColSpanFromWidth(width: FieldWidth): string;
|
|
@@ -17,6 +17,36 @@ interface ValidationObject {
|
|
|
17
17
|
regexMessage?: string;
|
|
18
18
|
minLength?: number;
|
|
19
19
|
maxLength?: number;
|
|
20
|
+
min?: number;
|
|
21
|
+
max?: number;
|
|
22
|
+
minSelected?: number;
|
|
23
|
+
maxSelected?: number;
|
|
24
|
+
minDate?: string;
|
|
25
|
+
maxDate?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Comprehensive validation configuration for form fields.
|
|
29
|
+
* Supports number fields (min, max, decimal) and text-based numeric fields (phone, postal, OTP).
|
|
30
|
+
*/
|
|
31
|
+
interface FieldValidations {
|
|
32
|
+
required?: boolean;
|
|
33
|
+
minLength?: number;
|
|
34
|
+
maxLength?: number;
|
|
35
|
+
min?: number;
|
|
36
|
+
max?: number;
|
|
37
|
+
allowDecimal?: boolean;
|
|
38
|
+
decimalPlaces?: number;
|
|
39
|
+
allowNegative?: boolean;
|
|
40
|
+
pattern?: string;
|
|
41
|
+
validationType?: 'postalCode' | 'phoneNumber' | 'otp' | 'amount' | 'custom';
|
|
42
|
+
customErrorMessages?: {
|
|
43
|
+
required?: string;
|
|
44
|
+
minLength?: string;
|
|
45
|
+
maxLength?: string;
|
|
46
|
+
min?: string;
|
|
47
|
+
max?: string;
|
|
48
|
+
pattern?: string;
|
|
49
|
+
};
|
|
20
50
|
minSelected?: number;
|
|
21
51
|
maxSelected?: number;
|
|
22
52
|
minDate?: string;
|
|
@@ -43,6 +73,7 @@ interface FormField {
|
|
|
43
73
|
}[];
|
|
44
74
|
optionsSource?: AsyncOptionSource;
|
|
45
75
|
validation?: ValidationRule[] | ValidationObject;
|
|
76
|
+
validations?: FieldValidations;
|
|
46
77
|
width?: FieldWidth;
|
|
47
78
|
hidden?: boolean;
|
|
48
79
|
position?: {
|
|
@@ -75,6 +106,10 @@ interface FormField {
|
|
|
75
106
|
lookupValueField?: string;
|
|
76
107
|
lookupLabelField?: string;
|
|
77
108
|
isd?: ISDConfig;
|
|
109
|
+
imageUrl?: string;
|
|
110
|
+
valueSource?: 'manual' | 'formula';
|
|
111
|
+
formula?: string;
|
|
112
|
+
dependencies?: string[];
|
|
78
113
|
}
|
|
79
114
|
/**
|
|
80
115
|
* ISD (International Subscriber Dialing) configuration for phone fields
|
|
@@ -343,9 +378,61 @@ declare const builderToPlatform: (builderSchema: FormSchema) => any;
|
|
|
343
378
|
* @returns
|
|
344
379
|
*/
|
|
345
380
|
declare const platformToBuilder: (platformSchema: any) => FormSchema;
|
|
381
|
+
/**
|
|
382
|
+
* Returns validation config for Angular Reactive Forms compatibility.
|
|
383
|
+
* Use with Validators.required, Validators.minLength(n), Validators.maxLength(n),
|
|
384
|
+
* Validators.min(n), Validators.max(n), Validators.pattern(regex).
|
|
385
|
+
* @param validations Field validations from form schema
|
|
386
|
+
* @returns Object with validator params and custom error messages for Angular
|
|
387
|
+
*/
|
|
388
|
+
declare function getValidationConfigForAngular(validations: FieldValidations | undefined): {
|
|
389
|
+
required: boolean;
|
|
390
|
+
minLength?: number;
|
|
391
|
+
maxLength?: number;
|
|
392
|
+
min?: number;
|
|
393
|
+
max?: number;
|
|
394
|
+
pattern?: string;
|
|
395
|
+
customErrorMessages: FieldValidations['customErrorMessages'];
|
|
396
|
+
};
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* Extracts field references (identifiers) from a formula expression.
|
|
400
|
+
* Supports identifiers: alphanumeric, underscores (e.g. quantity, field_a, price2)
|
|
401
|
+
*/
|
|
402
|
+
declare function parseFormulaDependencies(formula: string): string[];
|
|
403
|
+
/**
|
|
404
|
+
* Validates formula syntax and field references.
|
|
405
|
+
* Returns { valid: true } or { valid: false, error: string }
|
|
406
|
+
*/
|
|
407
|
+
declare function validateFormula(formula: string, availableFieldIds: string[], availableFieldNames: string[], _currentFieldId?: string): {
|
|
408
|
+
valid: true;
|
|
409
|
+
} | {
|
|
410
|
+
valid: false;
|
|
411
|
+
error: string;
|
|
412
|
+
};
|
|
413
|
+
/**
|
|
414
|
+
* Detects circular dependency: if formulaField depends on fields that (transitively) depend on formulaField.
|
|
415
|
+
*/
|
|
416
|
+
declare function detectCircularDependency(schema: FormSchema, formulaFieldId: string, _formula: string, dependencies: string[]): boolean;
|
|
417
|
+
/**
|
|
418
|
+
* Evaluates a formula with given values.
|
|
419
|
+
* Handles: +, -, *, /, parentheses.
|
|
420
|
+
* Empty/missing values are treated as 0.
|
|
421
|
+
* Divide-by-zero returns NaN (caller should handle).
|
|
422
|
+
*/
|
|
423
|
+
declare function evaluateFormula(formula: string, values: Record<string, number | string | undefined>): number;
|
|
424
|
+
/**
|
|
425
|
+
* Get all numeric fields from schema (excluding the given field) for formula selection.
|
|
426
|
+
* Returns fields that can be used in formulas.
|
|
427
|
+
*/
|
|
428
|
+
declare function getNumericFieldsForFormula(schema: FormSchema, excludeFieldId?: string): {
|
|
429
|
+
id: string;
|
|
430
|
+
fieldName: string;
|
|
431
|
+
label: string;
|
|
432
|
+
}[];
|
|
346
433
|
|
|
347
434
|
declare const initFormBuilder: (options: FormBuilderOptions & {
|
|
348
435
|
containerId: string;
|
|
349
436
|
}) => FormBuilder;
|
|
350
437
|
|
|
351
|
-
export { AsyncOptionSource, FieldType, FieldWidth, FormBuilder, FormBuilderOptions, FormField, FormRenderer, FormSchema, FormSchemaValidation, FormSection, ISDConfig, MasterType, ValidationObject, ValidationRule, builderToPlatform, cleanFormSchema, convertValidationObjectToArray, formStore, getColSpanFromWidth, initFormBuilder, parseWidth, platformToBuilder };
|
|
438
|
+
export { AsyncOptionSource, FieldType, FieldValidations, FieldWidth, FormBuilder, FormBuilderOptions, FormField, FormRenderer, FormSchema, FormSchemaValidation, FormSection, ISDConfig, MasterType, ValidationObject, ValidationRule, builderToPlatform, cleanFormSchema, convertValidationObjectToArray, detectCircularDependency, evaluateFormula, formStore, getColSpanFromWidth, getNumericFieldsForFormula, getValidationConfigForAngular, initFormBuilder, parseFormulaDependencies, parseWidth, platformToBuilder, validateFormula };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import * as zustand_vanilla from 'zustand/vanilla';
|
|
3
3
|
|
|
4
|
-
type FieldType = 'text' | 'textarea' | 'number' | 'date' | 'select' | 'checkbox' | 'radio' | 'toggle' | 'file' | 'email' | 'phone';
|
|
4
|
+
type FieldType = 'text' | 'textarea' | 'number' | 'date' | 'select' | 'checkbox' | 'radio' | 'toggle' | 'file' | 'image' | 'email' | 'phone';
|
|
5
5
|
type FieldWidth = '25%' | '33%' | '50%' | '66%' | '75%' | '100%' | number;
|
|
6
6
|
declare function parseWidth(width: FieldWidth): number;
|
|
7
7
|
declare function getColSpanFromWidth(width: FieldWidth): string;
|
|
@@ -17,6 +17,36 @@ interface ValidationObject {
|
|
|
17
17
|
regexMessage?: string;
|
|
18
18
|
minLength?: number;
|
|
19
19
|
maxLength?: number;
|
|
20
|
+
min?: number;
|
|
21
|
+
max?: number;
|
|
22
|
+
minSelected?: number;
|
|
23
|
+
maxSelected?: number;
|
|
24
|
+
minDate?: string;
|
|
25
|
+
maxDate?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Comprehensive validation configuration for form fields.
|
|
29
|
+
* Supports number fields (min, max, decimal) and text-based numeric fields (phone, postal, OTP).
|
|
30
|
+
*/
|
|
31
|
+
interface FieldValidations {
|
|
32
|
+
required?: boolean;
|
|
33
|
+
minLength?: number;
|
|
34
|
+
maxLength?: number;
|
|
35
|
+
min?: number;
|
|
36
|
+
max?: number;
|
|
37
|
+
allowDecimal?: boolean;
|
|
38
|
+
decimalPlaces?: number;
|
|
39
|
+
allowNegative?: boolean;
|
|
40
|
+
pattern?: string;
|
|
41
|
+
validationType?: 'postalCode' | 'phoneNumber' | 'otp' | 'amount' | 'custom';
|
|
42
|
+
customErrorMessages?: {
|
|
43
|
+
required?: string;
|
|
44
|
+
minLength?: string;
|
|
45
|
+
maxLength?: string;
|
|
46
|
+
min?: string;
|
|
47
|
+
max?: string;
|
|
48
|
+
pattern?: string;
|
|
49
|
+
};
|
|
20
50
|
minSelected?: number;
|
|
21
51
|
maxSelected?: number;
|
|
22
52
|
minDate?: string;
|
|
@@ -43,6 +73,7 @@ interface FormField {
|
|
|
43
73
|
}[];
|
|
44
74
|
optionsSource?: AsyncOptionSource;
|
|
45
75
|
validation?: ValidationRule[] | ValidationObject;
|
|
76
|
+
validations?: FieldValidations;
|
|
46
77
|
width?: FieldWidth;
|
|
47
78
|
hidden?: boolean;
|
|
48
79
|
position?: {
|
|
@@ -75,6 +106,10 @@ interface FormField {
|
|
|
75
106
|
lookupValueField?: string;
|
|
76
107
|
lookupLabelField?: string;
|
|
77
108
|
isd?: ISDConfig;
|
|
109
|
+
imageUrl?: string;
|
|
110
|
+
valueSource?: 'manual' | 'formula';
|
|
111
|
+
formula?: string;
|
|
112
|
+
dependencies?: string[];
|
|
78
113
|
}
|
|
79
114
|
/**
|
|
80
115
|
* ISD (International Subscriber Dialing) configuration for phone fields
|
|
@@ -343,9 +378,61 @@ declare const builderToPlatform: (builderSchema: FormSchema) => any;
|
|
|
343
378
|
* @returns
|
|
344
379
|
*/
|
|
345
380
|
declare const platformToBuilder: (platformSchema: any) => FormSchema;
|
|
381
|
+
/**
|
|
382
|
+
* Returns validation config for Angular Reactive Forms compatibility.
|
|
383
|
+
* Use with Validators.required, Validators.minLength(n), Validators.maxLength(n),
|
|
384
|
+
* Validators.min(n), Validators.max(n), Validators.pattern(regex).
|
|
385
|
+
* @param validations Field validations from form schema
|
|
386
|
+
* @returns Object with validator params and custom error messages for Angular
|
|
387
|
+
*/
|
|
388
|
+
declare function getValidationConfigForAngular(validations: FieldValidations | undefined): {
|
|
389
|
+
required: boolean;
|
|
390
|
+
minLength?: number;
|
|
391
|
+
maxLength?: number;
|
|
392
|
+
min?: number;
|
|
393
|
+
max?: number;
|
|
394
|
+
pattern?: string;
|
|
395
|
+
customErrorMessages: FieldValidations['customErrorMessages'];
|
|
396
|
+
};
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* Extracts field references (identifiers) from a formula expression.
|
|
400
|
+
* Supports identifiers: alphanumeric, underscores (e.g. quantity, field_a, price2)
|
|
401
|
+
*/
|
|
402
|
+
declare function parseFormulaDependencies(formula: string): string[];
|
|
403
|
+
/**
|
|
404
|
+
* Validates formula syntax and field references.
|
|
405
|
+
* Returns { valid: true } or { valid: false, error: string }
|
|
406
|
+
*/
|
|
407
|
+
declare function validateFormula(formula: string, availableFieldIds: string[], availableFieldNames: string[], _currentFieldId?: string): {
|
|
408
|
+
valid: true;
|
|
409
|
+
} | {
|
|
410
|
+
valid: false;
|
|
411
|
+
error: string;
|
|
412
|
+
};
|
|
413
|
+
/**
|
|
414
|
+
* Detects circular dependency: if formulaField depends on fields that (transitively) depend on formulaField.
|
|
415
|
+
*/
|
|
416
|
+
declare function detectCircularDependency(schema: FormSchema, formulaFieldId: string, _formula: string, dependencies: string[]): boolean;
|
|
417
|
+
/**
|
|
418
|
+
* Evaluates a formula with given values.
|
|
419
|
+
* Handles: +, -, *, /, parentheses.
|
|
420
|
+
* Empty/missing values are treated as 0.
|
|
421
|
+
* Divide-by-zero returns NaN (caller should handle).
|
|
422
|
+
*/
|
|
423
|
+
declare function evaluateFormula(formula: string, values: Record<string, number | string | undefined>): number;
|
|
424
|
+
/**
|
|
425
|
+
* Get all numeric fields from schema (excluding the given field) for formula selection.
|
|
426
|
+
* Returns fields that can be used in formulas.
|
|
427
|
+
*/
|
|
428
|
+
declare function getNumericFieldsForFormula(schema: FormSchema, excludeFieldId?: string): {
|
|
429
|
+
id: string;
|
|
430
|
+
fieldName: string;
|
|
431
|
+
label: string;
|
|
432
|
+
}[];
|
|
346
433
|
|
|
347
434
|
declare const initFormBuilder: (options: FormBuilderOptions & {
|
|
348
435
|
containerId: string;
|
|
349
436
|
}) => FormBuilder;
|
|
350
437
|
|
|
351
|
-
export { AsyncOptionSource, FieldType, FieldWidth, FormBuilder, FormBuilderOptions, FormField, FormRenderer, FormSchema, FormSchemaValidation, FormSection, ISDConfig, MasterType, ValidationObject, ValidationRule, builderToPlatform, cleanFormSchema, convertValidationObjectToArray, formStore, getColSpanFromWidth, initFormBuilder, parseWidth, platformToBuilder };
|
|
438
|
+
export { AsyncOptionSource, FieldType, FieldValidations, FieldWidth, FormBuilder, FormBuilderOptions, FormField, FormRenderer, FormSchema, FormSchemaValidation, FormSection, ISDConfig, MasterType, ValidationObject, ValidationRule, builderToPlatform, cleanFormSchema, convertValidationObjectToArray, detectCircularDependency, evaluateFormula, formStore, getColSpanFromWidth, getNumericFieldsForFormula, getValidationConfigForAngular, initFormBuilder, parseFormulaDependencies, parseWidth, platformToBuilder, validateFormula };
|