@bach.software/vue-dynamic-form 0.1.3 → 0.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.
Files changed (71) hide show
  1. package/README.md +203 -7
  2. package/dist/examples.cjs.js +12 -0
  3. package/dist/examples.cjs.js.map +1 -0
  4. package/dist/examples.es.js +612 -0
  5. package/dist/examples.es.js.map +1 -0
  6. package/dist/src/components/DynamicForm.vue.d.ts +2 -0
  7. package/dist/src/components/DynamicFormItem.vue.d.ts +11 -2
  8. package/dist/src/components/DynamicFormItemArray.vue.d.ts +9 -2
  9. package/dist/src/components/DynamicFormItemChoice.vue.d.ts +9 -2
  10. package/dist/src/components/DynamicFormTemplate.vue.d.ts +72 -21
  11. package/dist/src/components/__tests__/DynamicFormItem.analytics.test.d.ts +1 -0
  12. package/dist/src/components/__tests__/DynamicFormItem.logic.test.d.ts +1 -0
  13. package/dist/src/components/__tests__/DynamicFormItem.test-helpers.d.ts +21 -0
  14. package/dist/src/components/__tests__/DynamicFormItem.validation.test.d.ts +1 -0
  15. package/dist/src/components/__tests__/DynamicFormItemArray.logic.test.d.ts +1 -0
  16. package/dist/src/components/__tests__/DynamicFormItemArray.validation.test.d.ts +1 -0
  17. package/dist/src/components/__tests__/DynamicFormItemChoice.logic.test.d.ts +1 -0
  18. package/dist/src/components/__tests__/DynamicFormItemChoice.validation.test.d.ts +1 -0
  19. package/dist/src/core/__tests__/useValidatePartialForm.test.d.ts +1 -0
  20. package/dist/src/core/__tests__/validation.test.d.ts +1 -0
  21. package/dist/src/core/defineMetadata.d.ts +32 -7
  22. package/dist/src/core/useDynamicForm.d.ts +16 -0
  23. package/dist/src/core/useFieldArrayExtended.d.ts +16 -0
  24. package/dist/src/core/useValidatePartialForm.d.ts +4 -0
  25. package/dist/src/core/validation.d.ts +7 -0
  26. package/dist/src/examples/TestForm.vue.d.ts +13 -0
  27. package/dist/src/examples/TestFormTemplate.vue.d.ts +76 -0
  28. package/dist/src/examples/__tests__/DynamicForm.test.d.ts +1 -0
  29. package/dist/src/examples/__tests__/TestFormTemplate.testcases.d.ts +14 -0
  30. package/dist/src/examples/components/IconButton.vue.d.ts +10 -0
  31. package/dist/src/examples/index.d.ts +3 -0
  32. package/dist/src/index.d.ts +6 -0
  33. package/dist/src/tests/test-setup.d.ts +1 -0
  34. package/dist/src/types/DynamicFormItemProps.d.ts +56 -1
  35. package/dist/src/types/DynamicFormSettings.d.ts +89 -0
  36. package/dist/src/types/FieldMetadata.d.ts +109 -17
  37. package/dist/src/types/InternalFieldMetadata.d.ts +9 -3
  38. package/dist/src/types/KeyValue.d.ts +3 -0
  39. package/dist/src/types/MetadataConfiguration.d.ts +2 -0
  40. package/dist/src/types/ValidationMessage.d.ts +3 -0
  41. package/dist/src/utils/__tests__/checkTreeHasValue.test.d.ts +1 -0
  42. package/dist/src/utils/__tests__/createValidation.test.d.ts +1 -0
  43. package/dist/src/utils/__tests__/mapEachMetadataItem.test.d.ts +16 -0
  44. package/dist/src/utils/__tests__/normalizePath.test.d.ts +1 -0
  45. package/dist/src/utils/__tests__/overridePath.test.d.ts +1 -0
  46. package/dist/src/utils/__tests__/resolveMessage.test.d.ts +1 -0
  47. package/dist/src/utils/__tests__/setInPath.test.d.ts +1 -0
  48. package/dist/src/utils/__tests__/splitValidationFunctions.test.d.ts +1 -0
  49. package/dist/src/utils/camelize.d.ts +5 -0
  50. package/dist/src/utils/checkTreeHasValue.d.ts +9 -0
  51. package/dist/src/utils/createValidation.d.ts +12 -0
  52. package/dist/src/utils/getFieldLabel.d.ts +16 -0
  53. package/dist/src/utils/hashField.d.ts +7 -0
  54. package/dist/src/utils/mapEachMetadataItem.d.ts +10 -0
  55. package/dist/src/utils/normalizePath.d.ts +15 -0
  56. package/dist/src/utils/overridePath.d.ts +19 -0
  57. package/dist/src/utils/resolveMessage.d.ts +17 -0
  58. package/dist/src/utils/setInPath.d.ts +10 -0
  59. package/dist/src/utils/splitValidationFunctions.d.ts +15 -0
  60. package/dist/tsconfig.tsbuildinfo +1 -0
  61. package/dist/useDynamicForm-C6-0mGw4.js +737 -0
  62. package/dist/useDynamicForm-C6-0mGw4.js.map +1 -0
  63. package/dist/useDynamicForm-SHyV1lLH.cjs +6 -0
  64. package/dist/useDynamicForm-SHyV1lLH.cjs.map +1 -0
  65. package/dist/vue-dynamic-form.cjs.js +2 -0
  66. package/dist/vue-dynamic-form.cjs.js.map +1 -0
  67. package/dist/vue-dynamic-form.es.js +13 -178
  68. package/dist/vue-dynamic-form.es.js.map +1 -0
  69. package/package.json +17 -9
  70. package/dist/vue-dynamic-form.umd.js +0 -1
  71. /package/dist/src/components/{DynamicForm.test.d.ts → __tests__/DynamicForm.test.d.ts} +0 -0
@@ -9,5 +9,60 @@ export interface DynamicFormItemProps<InternalMetadata extends InternalFieldMeta
9
9
  choice?: ((props: object) => any) | undefined;
10
10
  array?: ((props: object) => any) | undefined;
11
11
  }>;
12
- field: InternalMetadata;
12
+ fieldMetadata: InternalMetadata;
13
+ /**
14
+ * In case a parent can occur multiple times, its path will have an index in it.
15
+ * This needs to be passed to the child items so they can adjust their own path accordingly.
16
+ *
17
+ * Example scenario:
18
+ * - field.path = root.collections.item.nested.deepItems
19
+ * - pathOverride = root.collections[3]
20
+ * - Result: root.collections[3].item.nested.deepItems
21
+ * Full path specification is unnecessary; partial override suffices.
22
+ */
23
+ pathOverride?: string;
24
+ /**
25
+ * Runtime adjustment of minimum occurrence constraint for this field.
26
+ * Controls requirement level: 0 makes optional, 1 enforces presence, higher values demand repetition.
27
+ *
28
+ * For example: Conditional sections where child validation activates only after
29
+ * user interaction with any descendant field.
30
+ */
31
+ minOccursOverride?: number;
32
+ /**
33
+ * Runtime adjustment of maximum occurrence constraint for this field.
34
+ * Values exceeding 1 transform the field into a repeatable collection with multiple instances.
35
+ *
36
+ * For example: Within choice groups, disable add button when any option
37
+ * reaches the shared occurrence limit.
38
+ */
39
+ maxOccursOverride?: number;
40
+ /**
41
+ * In case this field is part of a array field, it needs to co-operate with that array field and
42
+ * mark all children optional if no value has been filled in.
43
+ */
44
+ partOfArrayField?: boolean;
45
+ /**
46
+ * In case this field is part of a choice field, it needs to co-operate with that choice field and
47
+ * behave differently in some situations.
48
+ */
49
+ partOfChoiceField?: boolean;
50
+ /**
51
+ * We check the maxOccurs to see if the field is an Array. If we want to override this, we can do so with this property.
52
+ * In case the field is a child of a choice field, it needs to be made repeatable and we can set this to true.
53
+ */
54
+ isArrayOverride?: 'auto' | 'array' | 'single';
55
+ /**
56
+ * In case this item is part of a field array, we need some extra info
57
+ */
58
+ index?: number;
59
+ canAddItems?: boolean;
60
+ canRemoveItems?: boolean;
61
+ addItem?: () => void;
62
+ removeItem?: (index?: number) => void;
63
+ /**
64
+ * You can provide additional attributes to the slots in your template. They will be passed to the
65
+ * component below.
66
+ */
67
+ slotProps?: object;
13
68
  }
@@ -0,0 +1,89 @@
1
+ import type { ValidationMessage } from '../types/ValidationMessage';
2
+ export declare const dynamicFormSettingsKey: unique symbol;
3
+ export interface DynamicFormSettings {
4
+ /**
5
+ * Enables diagnostic data output via concealed DOM elements for reactivity testing
6
+ */
7
+ analytics?: boolean;
8
+ /**
9
+ * In case of a complex type the value is stored in a value property, i.e. { value: 'the actual value' }
10
+ * Use complexTypeValueProperty to change the property name, for example 'myValue' will result in { myValue: 'the actual value' }
11
+ */
12
+ complexTypeValueProperty?: string;
13
+ /**
14
+ * When true, validates fields on every value change.
15
+ * When false, only validates on submit.
16
+ *
17
+ * Defaults to true.
18
+ */
19
+ validateOnValueUpdate?: boolean;
20
+ /**
21
+ * When true, validates fields on every value change after the first submit.
22
+ * When false, listen to the validateOnValueUpdate.
23
+ *
24
+ * Defaults to false.
25
+ */
26
+ validateOnValueUpdateAfterSubmit?: boolean;
27
+ /**
28
+ * When true, validates fields on blur.
29
+ *
30
+ * Defaults to false.
31
+ */
32
+ validateOnBlur?: boolean;
33
+ /**
34
+ * When true, validates fields on every value change when the field has an error.
35
+ *
36
+ * Defaults to false.
37
+ */
38
+ validateWhenInError?: boolean;
39
+ /**
40
+ * Use this setting to override the default text of the validation messages.
41
+ *
42
+ * Each message accepts either a `string` template or a `(ctx) => string` function.
43
+ *
44
+ * String templates support the following placeholders:
45
+ * - `{field}` — the field label
46
+ * - `{value}` — the current field value
47
+ * - `{0}`, `{1}`, ... — rule params by position (e.g. `{0}` = the limit value)
48
+ * - Named params where supported (e.g. `{min}`, `{max}`)
49
+ *
50
+ * Examples:
51
+ * ```ts
52
+ * required: 'The {field} field is required'
53
+ * minLength: 'The {field} must be at least {0} characters'
54
+ * minLength: (ctx) => `${ctx.field} is too short`
55
+ * ```
56
+ */
57
+ messages?: {
58
+ /** XSD: required. Available placeholders: `{field}` */
59
+ required?: ValidationMessage;
60
+ /** XSD: minOccurs. Available placeholders: `{field}`, `{0}` or `{min}` (min number of filled items) */
61
+ minOccurs?: ValidationMessage;
62
+ /** XSD: choiceMinOccurs. Available placeholders: `{field}`, `{0}` or `{min}` (min number of filled items) */
63
+ choiceMinOccurs?: ValidationMessage;
64
+ /** XSD: minLength. Available placeholders: `{field}`, `{0}` or `{length}` (min length) */
65
+ minLength?: ValidationMessage;
66
+ /** XSD: maxLength. Available placeholders: `{field}`, `{0}` or `{length}` (max length) */
67
+ maxLength?: ValidationMessage;
68
+ /** XSD: length. Available placeholders: `{field}`, `{0}` or `{length}` (exact length) */
69
+ length?: ValidationMessage;
70
+ /** XSD: pattern. Available placeholders: `{field}`, `{0}` or `{pattern}` (regex pattern) */
71
+ pattern?: ValidationMessage;
72
+ /** XSD: minInclusive. Available placeholders: `{field}`, `{0}` or `{min}` (min value, inclusive) */
73
+ minInclusive?: ValidationMessage;
74
+ /** XSD: maxInclusive. Available placeholders: `{field}`, `{0}` or `{max}` (max value, inclusive) */
75
+ maxInclusive?: ValidationMessage;
76
+ /** XSD: minExclusive. Available placeholders: `{field}`, `{0}` or `{min}` (min value, exclusive) */
77
+ minExclusive?: ValidationMessage;
78
+ /** XSD: maxExclusive. Available placeholders: `{field}`, `{0}` or `{max}` (max value, exclusive) */
79
+ maxExclusive?: ValidationMessage;
80
+ /** XSD: enumeration. Available placeholders: `{field}` */
81
+ enumeration?: ValidationMessage;
82
+ /** XSD: whiteSpace. Available placeholders: `{field}`, `{0}` or `{mode}` (preserve | replace | collapse) */
83
+ whiteSpace?: ValidationMessage;
84
+ /** XSD: fractionDigits. Available placeholders: `{field}`, `{0}` or `{digits}` (max decimal places) */
85
+ fractionDigits?: ValidationMessage;
86
+ /** XSD: totalDigits. Available placeholders: `{field}`, `{0}` or `{digits}` (max total digits) */
87
+ totalDigits?: ValidationMessage;
88
+ };
89
+ }
@@ -1,25 +1,60 @@
1
- import type { WatchSource } from 'vue';
1
+ import type { FieldOptions, RuleExpression } from 'vee-validate';
2
+ import type { Ref } from 'vue';
2
3
  export type FieldMetadata<ExtendedFieldTypes extends string = string, ExtendedProperties extends object = object> = {
3
4
  name?: string;
4
5
  type?: ExtendedFieldTypes;
5
6
  path?: string;
7
+ /**
8
+ * The minimal occurrence of a value.
9
+ * Optional fields have a value of 0.
10
+ * Required fields have a value of 1.
11
+ * We also allow to specify if you need a minimum higher then 1.
12
+ */
6
13
  minOccurs?: number;
14
+ /**
15
+ * The maximal occurrence of a value.
16
+ */
7
17
  maxOccurs?: number;
8
18
  /**
9
- * Simple restrictions to the data
19
+ * Controls whether the array automatically pre-fills empty placeholder items up to `minOccurs`
20
+ * when the form is first rendered and the array is still empty.
21
+ *
22
+ * Defaults to `true` — omitting this property has the same effect as setting it to `true`.
23
+ * Set it explicitly to `false` to suppress auto-filling, which is useful when you want the
24
+ * user to explicitly add the first item themselves even though `minOccurs` is 1 or higher.
25
+ *
26
+ * @example
27
+ * // Will NOT auto-add an initial item, even though minOccurs is 1:
28
+ * { name: 'emails', type: 'text', maxOccurs: 5, minOccurs: 1, autoAddMinOccurs: false }
10
29
  */
11
- restrictions?: {
12
- maxLength?: number;
30
+ autoAddMinOccurs?: boolean;
31
+ /**
32
+ * Simple restrictions to the data, these are available in XSD and can be applied easily.
33
+ * For more advance validation use the validation property.
34
+ */
35
+ restriction?: {
13
36
  minLength?: number;
37
+ maxLength?: number;
14
38
  pattern?: string;
15
39
  minInclusive?: number;
16
40
  maxInclusive?: number;
17
- enumeration?: string;
41
+ minExclusive?: number;
42
+ maxExclusive?: number;
43
+ enumeration?: unknown[];
18
44
  length?: number;
19
- whiteSpace?: string;
45
+ whiteSpace?: 'preserve' | 'replace' | 'collapse';
20
46
  fractionDigits?: number;
21
47
  totalDigits?: number;
22
48
  };
49
+ /**
50
+ * Vee-Validate validation rules that should be applied to this field.
51
+ */
52
+ validation?: RuleExpression<unknown>;
53
+ /**
54
+ * The vee-validate field options.
55
+ * - label: you can set a ref to make this dynamically update.
56
+ */
57
+ fieldOptions?: Partial<FieldOptions<unknown>>;
23
58
  children?: FieldMetadata<ExtendedFieldTypes, ExtendedProperties>[];
24
59
  /**
25
60
  * Choice is similar to children, with the difference that only one of the items in the array
@@ -50,15 +85,34 @@ export type FieldMetadata<ExtendedFieldTypes extends string = string, ExtendedPr
50
85
  * <ContactInfo>
51
86
  * <Email>someone@example.com</Email>
52
87
  * </ContactInfo>
53
- * or
88
+ * <!-- or -->
54
89
  * <ContactInfo>
55
90
  * <Phone>+31 123 456 789</Phone>
56
91
  * </ContactInfo>
57
92
  *
58
- * but this is invalid:
93
+ * <!-- but this is invalid: -->
59
94
  * <ContactInfo>
60
95
  * </ContactInfo>
96
+ * ```
61
97
  *
98
+ * Or json
99
+ * ```json
100
+ * {
101
+ * "contactInfo": {
102
+ * "email": "someone@example.com"
103
+ * }
104
+ * }
105
+ * <!-- or -->
106
+ * {
107
+ * "contactInfo": {
108
+ * "phone": "+31 123 456 789"
109
+ * }
110
+ * }
111
+ *
112
+ * <!-- but this is invalid: -->
113
+ * {
114
+ * "contactInfo": { }
115
+ * }
62
116
  * ```
63
117
  *
64
118
  */
@@ -69,33 +123,71 @@ export type FieldMetadata<ExtendedFieldTypes extends string = string, ExtendedPr
69
123
  * such as for example whether the data is verified.
70
124
  *
71
125
  * These attributes will be shown when the parent will have a value filled in.
126
+ * The field automatically becomes a complex type, meaning that the value will be
127
+ * an object containing the value and the attributes.
72
128
  *
73
129
  * For example:
74
130
  * ```
75
131
  * <ContactInfo>
76
132
  * <Phone certainty="unverified">+31 123 456 789</Phone>
77
133
  * </ContactInfo>
78
- * or
134
+ * <!-- or -->
79
135
  * <ContactInfo>
80
136
  * <Phone certainty="verified">+31 123 456 789</Phone>
81
137
  * </ContactInfo>
82
138
  * ```
83
139
  */
84
140
  attributes?: FieldMetadata<ExtendedFieldTypes, ExtendedProperties>[];
141
+ /**
142
+ * To support generating a form based on a xsd, we need to be able to work with complex types.
143
+ * In case a SimpleContent has a ComplexType as parent, the json converter creates a value object
144
+ * with the value inside i.e. { value: 'the actual value' } and the attributes alongside it.
145
+ *
146
+ * By setting isComplexType to true, the form generator knows it needs to look for the value inside
147
+ * the value property.
148
+ *
149
+ * When attributes are present, isComplexType is automatically set to true.
150
+ *
151
+ * In case you need to change the default value property 'value', do this in the DynamicFormSettings.
152
+ */
153
+ isComplexType?: boolean;
85
154
  /**
86
155
  * The parent of the current field.
156
+ * This is purely for reference, these values cannot be updated.
87
157
  */
88
- parent?: FieldMetadata<ExtendedFieldTypes, ExtendedProperties>;
158
+ parent?: Readonly<FieldMetadata<ExtendedFieldTypes, ExtendedProperties>>;
89
159
  /**
90
- * You can add methods that transform the field metadata based on other external values.
91
- * Make sure to include the reactive value's in your function, so that the function is re-evaluated once
92
- * the value changes (internally we use a computed that is re-valuated when one of the used reactive values is changed).
93
- * This way we can for example change the property minOccurs to 1 (required) if another field has a value or change one of the ExtendedAttributes.
160
+ * Compute field values locally in the component that represents the field.
161
+ *
162
+ * This is a list of functions that are executed inside a computed in the component of the field.
163
+ * This means that if you reference other computed, refs, etc, these functions will be re-evaluated once one of the used reactive values changes.
164
+ *
165
+ * Allowing you to change the properties in the fieldMetadata, based on other values in the form, without re-rendering the entire component tree.
166
+ *
167
+ * It is also possible to read & write
94
168
  *
95
169
  * @param thisField the reactive & cloned current MetadataField that can be changed.
170
+ * @param fieldValue the value of the field, you can read and modify it. If you do, the reactivity is activated and the computed
171
+ * is re-computed every time the value changes. If you don't use it, a change in value will not re-trigger the reactivity of the computed.
96
172
  * @returns A transformed FieldMetadata
97
173
  */
98
- transformReactively?: ((thisField: Omit<FieldMetadata<ExtendedFieldTypes, ExtendedProperties>, 'name' | 'children' | 'choice' | 'attributes'> & {
99
- name: string;
100
- }, fieldValue?: WatchSource<any>) => Omit<FieldMetadata<ExtendedFieldTypes, ExtendedProperties>, 'children'>)[];
174
+ computedProps?: ((thisField: ComputedPropsFieldType<ExtendedFieldTypes, ExtendedProperties>, fieldValue: Ref<unknown>, childFields: Ref<ReadOnlyFieldType<ExtendedFieldTypes, ExtendedProperties>[]>) => void)[];
175
+ /**
176
+ * Normally the computedProps are not re-calculate if a child value changes. If you need this functionality, you can enable this by
177
+ * setting this property to true.
178
+ */
179
+ computeOnChildValueChange?: boolean;
101
180
  } & ExtendedProperties;
181
+ export type ComputedPropsFieldType<ExtendedFieldTypes extends string = string, ExtendedProperties extends object = object> = Omit<FieldMetadata<ExtendedFieldTypes, ExtendedProperties>, 'name' | 'path' | 'parent' | 'children' | 'choice' | 'attributes' | 'fieldOptions' | 'computedProps' | 'maxOccurs' | 'isComplexType' | 'computeOnChildValueChange'> & Readonly<{
182
+ name: string;
183
+ path: string;
184
+ parent: FieldMetadata<ExtendedFieldTypes, ExtendedProperties>;
185
+ }>;
186
+ export type ReadOnlyFieldType<ExtendedFieldTypes extends string = string, ExtendedProperties extends object = object> = Readonly<Omit<FieldMetadata<ExtendedFieldTypes, ExtendedProperties>, 'name' | 'path' | 'children' | 'choice'> & {
187
+ name: string;
188
+ path: string;
189
+ children: ReadOnlyFieldType<ExtendedFieldTypes, ExtendedProperties>[];
190
+ choice: ReadOnlyFieldType<ExtendedFieldTypes, ExtendedProperties>[];
191
+ }>;
192
+ export type ComputedPropsFieldOf<T extends FieldMetadata<any, any>> = T extends FieldMetadata<infer FT, infer EP> ? ComputedPropsFieldType<FT, EP> : never;
193
+ export type ReadOnlyFieldOf<T extends FieldMetadata<any, any>> = T extends FieldMetadata<infer FT, infer EP> ? ReadOnlyFieldType<FT, EP> : never;
@@ -1,3 +1,9 @@
1
- import type { FieldMetadata } from './FieldMetadata.js';
2
- import type { RequireOnly } from './RequireOnly.js';
3
- export type InternalFieldMetadata<Metadata extends FieldMetadata> = RequireOnly<Metadata, 'name' | 'type' | 'minOccurs' | 'maxOccurs'>;
1
+ import type { FieldMetadata } from '../types/FieldMetadata.js';
2
+ import type { RequireOnly } from '../types/RequireOnly.js';
3
+ export type InternalFieldMetadata<Metadata extends FieldMetadata> = RequireOnly<Metadata, 'name' | 'type' | 'minOccurs' | 'maxOccurs'> & {
4
+ /**
5
+ * Internal hash computed by the system to track meaningful changes to the computed field.
6
+ * Do not set this manually — it is overwritten after every computedProps run.
7
+ */
8
+ _hash?: string;
9
+ };
@@ -0,0 +1,3 @@
1
+ export interface KeyValue<T = any> {
2
+ [key: string]: T;
3
+ }
@@ -1,4 +1,6 @@
1
1
  export interface MetadataConfiguration {
2
2
  fieldTypes: readonly string[];
3
3
  extendedProperties: object;
4
+ slotProperties: object;
5
+ valueTypes: Record<string, any>;
4
6
  }
@@ -0,0 +1,3 @@
1
+ import type { GenericValidateFunction } from 'vee-validate';
2
+ export type FieldValidationMetaInfo = Parameters<GenericValidateFunction>[1];
3
+ export type ValidationMessage = string | ((ctx: FieldValidationMetaInfo) => string);
@@ -0,0 +1 @@
1
+ import '../../core/validation';
@@ -0,0 +1,16 @@
1
+ import type { GetMetadataType } from '../../types/GetMetadataType';
2
+ export type TestMetadata = GetMetadataType<typeof _metadata>;
3
+ declare const _metadata: {
4
+ fieldTypes: readonly ("default" | "text")[];
5
+ extendedProperties: {
6
+ visited?: boolean;
7
+ visitOrder?: number;
8
+ };
9
+ slotProperties: object;
10
+ valueTypes: {
11
+ text: string;
12
+ } & {
13
+ default: string;
14
+ };
15
+ };
16
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Coming from vue source code
3
+ * @private
4
+ */
5
+ export declare const camelize: (str: string) => string;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Recursively traverses a data structure to determine if it holds any meaningful data.
3
+ * Returns false only when the entire structure consists of null/undefined values.
4
+ * Particularly useful for validation frameworks to detect populated form fields.
5
+ *
6
+ * @param element Data structure to analyze (supports primitives, objects, arrays)
7
+ * @returns Boolean indicating presence of non-nullish values
8
+ */
9
+ export declare function checkTreeHasValue(element: unknown): boolean;
@@ -0,0 +1,12 @@
1
+ import type { ValidationRule } from '../core/validation';
2
+ import type { FieldValidationMetaInfo, ValidationMessage } from '../types/ValidationMessage';
3
+ /**
4
+ * Creates a validation that uses a globally defined rule in our 'vdf' namespace.
5
+ * When the validation fails we either show the message override from the settings.messages
6
+ * or let the user override the message using the configure.generateMessage
7
+ *
8
+ * @param rule
9
+ * @param param
10
+ * @param customMessage
11
+ */
12
+ export declare function createValidation(rule: ValidationRule, param?: unknown, customMessage?: ValidationMessage): (value: unknown, ctx: FieldValidationMetaInfo) => Promise<string | true>;
@@ -0,0 +1,16 @@
1
+ import type { FieldValidationMetaInfo } from '../types/ValidationMessage';
2
+ /**
3
+ * Resolves the most user-friendly label for a field validation context.
4
+ *
5
+ * Most components (e.g. DynamicFormItem, DynamicFormItemArray) call `useField`
6
+ * with the field's `fieldOptions`, so vee-validate already sets `ctx.label`
7
+ * and `ctx.field` to a human-readable name. Choice fields are special: they
8
+ * validate at the root path (`''`) and historically registered without any
9
+ * `fieldOptions`, which left vee-validate with the literal placeholder
10
+ * string `{field}`. Normalizing the label here ensures shared helpers like
11
+ * createValidation/splitValidationFunctions always receive a real display name
12
+ * even for those “virtual” fields.
13
+ *
14
+ * Preference order: explicit label → ctx.field → ctx.name → empty string.
15
+ */
16
+ export declare function getFieldLabel(ctx: FieldValidationMetaInfo): string;
@@ -0,0 +1,7 @@
1
+ import type { FieldMetadata } from '../types/FieldMetadata';
2
+ /**
3
+ * Creates a deterministic hash of all mutable field properties (those that computedProps can change).
4
+ * Excludes structural/immutable properties: name, path, children, choice, attributes,
5
+ * fieldOptions, computedProps, maxOccurs, parent, and _hash itself.
6
+ */
7
+ export declare function hashField(field: FieldMetadata): string;
@@ -0,0 +1,10 @@
1
+ import type { FieldMetadata } from '../types/FieldMetadata';
2
+ /**
3
+ * Recursively walks a `FieldMetadata` tree (visiting `children` and `choice`) and applies
4
+ * `callbackFunc` to every node, returning the transformed tree.
5
+ *
6
+ * The callback receives a shallow clone of each node, so mutations inside the callback do not
7
+ * affect the original metadata. `children` and `choice` on the returned node are replaced with
8
+ * the recursively-mapped results after the callback runs.
9
+ */
10
+ export declare function mapEachMetadataItem<ExtendedFieldTypes extends string = string, ExtendedProperties extends object = object>(metadata: FieldMetadata<ExtendedFieldTypes, ExtendedProperties>, callbackFunc: (item: FieldMetadata<ExtendedFieldTypes, ExtendedProperties>) => FieldMetadata<ExtendedFieldTypes, ExtendedProperties>): FieldMetadata<ExtendedFieldTypes, ExtendedProperties>;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Helper function that converts a path with bracket notation to a dot notation.
3
+ * When adding an extra path segment, we do this by using the bracket notation, i.e.: person['value'].
4
+ *
5
+ * Vee-validate can't work with this notation, therefore this function fixes those cases.
6
+ *
7
+ * const actualPath = normalizePath(
8
+ * 'this.is["added"].to.my.path.and.more',
9
+ * )
10
+ *
11
+ * console.log(actualPath) // 'this.is.added.to.my.path.and.more'
12
+ *
13
+ * @param path to be normalized
14
+ */
15
+ export declare function normalizePath(path: string): string;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Merges two dot-notation paths by replacing leading segments of the base path
3
+ * with segments from the replacement path. Useful for resolving array indices
4
+ * in nested field paths where parent context contains array positions.
5
+ *
6
+ * @example
7
+ * // Given a generic path and an indexed parent path, produce the indexed child path
8
+ * const result = overridePath(
9
+ * 'data.users.contact.email',
10
+ * 'data.users[2]'
11
+ * )
12
+ *
13
+ * console.log(result) // 'data.users[2].contact.email'
14
+ *
15
+ * @param path Base path string to be modified
16
+ * @param overrideWithPath Replacement path that will substitute initial segments
17
+ * @returns Modified path with replaced segments
18
+ */
19
+ export declare function overridePath(path: string, overrideWithPath: string | undefined): string;
@@ -0,0 +1,17 @@
1
+ import type { FieldValidationMetaInfo, ValidationMessage } from '../types/ValidationMessage';
2
+ /**
3
+ * Helper function to resolve a validation message, with parameters.
4
+ *
5
+ * All three param styles work:
6
+ * 'Must be at least {0} characters' // positional
7
+ * 'Must be at least {min} characters' // named (object params)
8
+ * 'The {field} value {value} is invalid' // context properties
9
+ *
10
+ * This is exactly how @vee-validate/i18n handles it internally.
11
+ * @param message - The message template or function
12
+ * @param ctx - The vee-validate field validation context
13
+ * @param params - Optional param override. Array for positional `{0}, {1}`, or object for
14
+ * named `{min}, {length}` (also supports positional via numeric keys). Falls back to ctx.rule.params if not provided.
15
+ * @returns The resolved message string
16
+ */
17
+ export declare function resolveMessage(message: ValidationMessage, ctx: FieldValidationMetaInfo, params?: unknown[] | Record<string, unknown>): string;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Sets a value at a nested path within an object.
3
+ * Based on vee-validate's internal setInPath implementation.
4
+ * Creates intermediate objects/arrays as needed.
5
+ *
6
+ * @param object - The object to modify
7
+ * @param path - Dot-separated path (e.g., "user.address.city") or with array notation (e.g., "items[0].name")
8
+ * @param value - The value to set at the path
9
+ */
10
+ export declare function setInPath(object: Record<string, any>, path: string, value: unknown): void;
@@ -0,0 +1,15 @@
1
+ import type { GenericValidateFunction, RuleExpression } from 'vee-validate';
2
+ /**
3
+ * Splits a vee-validate `RuleExpression` into an array of individual `GenericValidateFunction`s,
4
+ * one per rule. This allows vee-validate to run each rule independently and collect all errors
5
+ * when `bails: false` is configured.
6
+ *
7
+ * Handles all `RuleExpression` formats:
8
+ * - **Function** — returned as-is in a single-element array
9
+ * - **Array** — each element is recursively split
10
+ * - **String** — pipe-separated rules (e.g. `'required|email'`) are split into separate functions,
11
+ * each delegating to vee-validate's `validate()`
12
+ * - **Object** — each key/value pair (e.g. `{ required: true, min: 3 }`) becomes a separate function,
13
+ * each delegating to vee-validate's `validate()`
14
+ */
15
+ export declare function splitToValidationFunctions(userRules: RuleExpression<unknown>): GenericValidateFunction[];