@bach.software/vue-dynamic-form 0.6.0 → 0.8.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/examples.cjs.js +5 -5
- package/dist/examples.cjs.js.map +1 -1
- package/dist/examples.es.js +709 -492
- package/dist/examples.es.js.map +1 -1
- package/dist/mapEachMetadataItem-CZmoxEoA.js +1234 -0
- package/dist/mapEachMetadataItem-CZmoxEoA.js.map +1 -0
- package/dist/mapEachMetadataItem-Dw1U9jf2.cjs +2 -0
- package/dist/mapEachMetadataItem-Dw1U9jf2.cjs.map +1 -0
- package/dist/src/components/__tests__/DynamicFormItem.formApi.test.d.ts +1 -0
- package/dist/src/components/__tests__/DynamicFormItem.test-helpers.d.ts +8 -0
- package/dist/src/components/__tests__/DynamicFormItemArray.formApi.test.d.ts +1 -0
- package/dist/src/components/__tests__/DynamicFormItemArray.test-helpers.d.ts +2 -0
- package/dist/src/components/__tests__/DynamicFormItemChoice.formApi.test.d.ts +1 -0
- package/dist/src/components/__tests__/DynamicFormItemChoice.test-helpers.d.ts +9 -0
- package/dist/src/components/__tests__/DynamicFormItemWizard.formApi.test.d.ts +1 -0
- package/dist/src/core/__tests__/useIsResetPending.test.d.ts +1 -0
- package/dist/src/core/__tests__/useIsValidationSuppressed.test.d.ts +1 -0
- package/dist/src/core/useIsResetPending.d.ts +13 -0
- package/dist/src/core/useIsValidationSuppressed.d.ts +20 -0
- package/dist/src/examples/ProgrammaticWritesTestCase.vue.d.ts +2 -0
- package/dist/src/examples/TestForm.vue.d.ts +6 -1
- package/dist/src/examples/__tests__/TestFormTemplate.testcases.d.ts +270 -37
- package/dist/src/examples/index.d.ts +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/types/FieldMetadata.d.ts +32 -1
- package/dist/src/utils/__tests__/deepEqual.test.d.ts +1 -0
- package/dist/src/utils/__tests__/hashField.test.d.ts +1 -0
- package/dist/src/utils/__tests__/isPathInSection.test.d.ts +1 -0
- package/dist/src/utils/buildRestrictionValidations.d.ts +11 -0
- package/dist/src/utils/deepEqual.d.ts +9 -0
- package/dist/src/utils/isPathInSection.d.ts +9 -0
- package/dist/src/utils/removeNullValues.d.ts +4 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/vue-dynamic-form.cjs.js +1 -1
- package/dist/vue-dynamic-form.cjs.js.map +1 -1
- package/dist/vue-dynamic-form.es.js +22 -21
- package/dist/vue-dynamic-form.es.js.map +1 -1
- package/package.json +4 -3
- package/dist/mapEachMetadataItem-Cxfn86Z2.cjs +0 -2
- package/dist/mapEachMetadataItem-Cxfn86Z2.cjs.map +0 -1
- package/dist/mapEachMetadataItem-Dvf3R5jd.js +0 -1159
- package/dist/mapEachMetadataItem-Dvf3R5jd.js.map +0 -1
|
@@ -219,6 +219,37 @@ export type FieldMetadata<ExtendedFieldTypes extends string = string, ExtendedPr
|
|
|
219
219
|
* `computedProps` cannot flip it mid-form.
|
|
220
220
|
*/
|
|
221
221
|
wizard?: boolean | WizardConfig;
|
|
222
|
+
/**
|
|
223
|
+
* The value stored in the form when the user selects this choice branch.
|
|
224
|
+
*
|
|
225
|
+
* Normally a branch has fields, and filling those in is what marks the branch as selected.
|
|
226
|
+
* A branch without any fields has nothing to fill in, so without help its value stays
|
|
227
|
+
* `undefined`: validation thinks nothing was selected, and the selection is lost when the
|
|
228
|
+
* form values are submitted or loaded back in. Set `presenceValue` to fix that: the moment
|
|
229
|
+
* the user picks the branch, this value is written as the branch's value, so the selection
|
|
230
|
+
* validates and survives a save/reload round-trip.
|
|
231
|
+
*
|
|
232
|
+
* Any JSON-serializable value works (`true`, `'selected'`, `{}`, ...), except `null` and the
|
|
233
|
+
* empty string: those read as selected but still fail the branch's own required check, so the
|
|
234
|
+
* selection would show an error. When the form loads existing values, the branch shows as
|
|
235
|
+
* selected whenever its value is not `undefined`.
|
|
236
|
+
*
|
|
237
|
+
* Selecting the branch is a session action: `resetForm()` clears a marker written by a click
|
|
238
|
+
* this session and deselects the branch, while a marker that was part of the loaded values is
|
|
239
|
+
* restored and keeps the branch selected.
|
|
240
|
+
*
|
|
241
|
+
* Only useful on a non-repeatable (`maxOccurs: 1`) branch without `children`, inside a
|
|
242
|
+
* `choice` with `explicitChoiceSelection: true`. On other branches it is ignored, because
|
|
243
|
+
* their values already show that they were selected (a repeated branch has its occurrences,
|
|
244
|
+
* a branch with children has its filled-in fields). Using it on a branch with `children`
|
|
245
|
+
* logs a development warning.
|
|
246
|
+
*
|
|
247
|
+
* Two things to keep in mind:
|
|
248
|
+
* - Prefer a non-empty value: if you clean up the submitted values with `removeNullValues`,
|
|
249
|
+
* an empty `{}` or `[]` marker is removed and the selection is lost.
|
|
250
|
+
* - This is static metadata only; `computedProps` cannot set or change it at runtime.
|
|
251
|
+
*/
|
|
252
|
+
presenceValue?: unknown;
|
|
222
253
|
/**
|
|
223
254
|
* Attributes are additional metadata that can be attached to a field.
|
|
224
255
|
* These attributes can be used to provide extra information about the field,
|
|
@@ -300,7 +331,7 @@ export interface WizardGotoStepOptions {
|
|
|
300
331
|
allowForwardJump?: boolean;
|
|
301
332
|
validateOnJump?: boolean;
|
|
302
333
|
}
|
|
303
|
-
export type ComputedPropsFieldType<ExtendedFieldTypes extends string = string, ExtendedProperties extends object = object> = Omit<FieldMetadata<ExtendedFieldTypes, ExtendedProperties>, 'name' | 'path' | 'parent' | 'children' | 'choice' | 'attributes' | 'fieldOptions' | 'computedProps' | 'maxOccurs' | 'maxOccursTotal' | 'isComplexType' | 'computeOnChildValueChange' | 'explicitChoiceSelection' | 'preserveOnSwitch' | 'displayOrder' | 'preserveOrder' | 'wizard'> & Readonly<{
|
|
334
|
+
export type ComputedPropsFieldType<ExtendedFieldTypes extends string = string, ExtendedProperties extends object = object> = Omit<FieldMetadata<ExtendedFieldTypes, ExtendedProperties>, 'name' | 'path' | 'parent' | 'children' | 'choice' | 'attributes' | 'fieldOptions' | 'computedProps' | 'maxOccurs' | 'maxOccursTotal' | 'isComplexType' | 'computeOnChildValueChange' | 'explicitChoiceSelection' | 'preserveOnSwitch' | 'displayOrder' | 'preserveOrder' | 'wizard' | 'presenceValue'> & Readonly<{
|
|
304
335
|
name: string;
|
|
305
336
|
path: string;
|
|
306
337
|
parent: FieldMetadata<ExtendedFieldTypes, ExtendedProperties>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { GenericValidateFunction } from 'vee-validate';
|
|
2
|
+
import type { DynamicFormSettings } from '../types/DynamicFormSettings';
|
|
3
|
+
import type { FieldMetadata } from '../types/FieldMetadata';
|
|
4
|
+
/**
|
|
5
|
+
* Builds the XSD restriction rules plus any custom validation declared directly on a field,
|
|
6
|
+
* shared by every place that registers a vee-validate field for that metadata (a plain field, or
|
|
7
|
+
* a choice-hosting field whose own restriction/validation is folded into its nested choice).
|
|
8
|
+
* Required/minOccurs is intentionally not part of this: it is a separate concern each caller
|
|
9
|
+
* decides for itself.
|
|
10
|
+
*/
|
|
11
|
+
export declare function buildRestrictionValidations(restriction: FieldMetadata['restriction'] | undefined, validation: FieldMetadata['validation'], messages: DynamicFormSettings['messages'] | undefined): GenericValidateFunction[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compares two values by content instead of by reference. Primitives, plain objects, arrays and
|
|
3
|
+
* Dates are compared recursively; everything else (functions, class instances, Maps, ...) only
|
|
4
|
+
* counts as equal when it is the exact same reference.
|
|
5
|
+
*
|
|
6
|
+
* Mirrors the value scope of `deepCloneValue`. Useful to detect "rebuilt but identical" objects,
|
|
7
|
+
* such as metadata that computedProps functions recreate on every run.
|
|
8
|
+
*/
|
|
9
|
+
export declare function deepEqual(a: unknown, b: unknown): boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks whether a field path falls at or under a section path.
|
|
3
|
+
* Matches the section itself, `section.child`, and `section[0]`, but not
|
|
4
|
+
* unrelated paths that happen to share a prefix string (e.g. `addressLine` vs `address`).
|
|
5
|
+
*
|
|
6
|
+
* @param path - Dot-notated field path (e.g. `'address.street'` or `'contacts[0].email'`)
|
|
7
|
+
* @param sectionPath - Dot-notated path prefix (e.g. `'address'` or `'contacts[0]'`)
|
|
8
|
+
*/
|
|
9
|
+
export declare function isPathInSection(path: string, sectionPath: string): boolean;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Removes all null value's from object properties and array's.
|
|
3
|
+
*
|
|
4
|
+
* Note: an empty-object or empty-array `presenceValue` marker on a choice branch is stripped
|
|
5
|
+
* back to `undefined` by this cleanup, same as any other empty object/array; use a non-empty
|
|
6
|
+
* marker if the branch's selection must survive this round-trip.
|
|
3
7
|
* @param element any value
|
|
4
8
|
*/
|
|
5
9
|
export declare function removeNullValues<T>(element: T): T | undefined;
|