@mapomodule/form 2.0.0-beta.9 → 2.0.0-experimental.1
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/README.md +38 -119
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +1 -0
- package/dist/module.d.mts +1 -0
- package/dist/module.d.ts.map +1 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +9 -0
- package/dist/runtime/components/MapoFocusPortal.vue +9 -2
- package/dist/runtime/components/MapoFocusPortal.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoForm.vue +28 -6
- package/dist/runtime/components/MapoForm.vue.d.ts +13 -1
- package/dist/runtime/components/MapoForm.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoFormAnnotation.vue +79 -0
- package/dist/runtime/components/MapoFormAnnotation.vue.d.ts +27 -0
- package/dist/runtime/components/MapoFormAnnotation.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoFormAnnotationBadges.vue +28 -0
- package/dist/runtime/components/MapoFormAnnotationBadges.vue.d.ts +13 -0
- package/dist/runtime/components/MapoFormAnnotationBadges.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoFormField.vue +47 -11
- package/dist/runtime/components/MapoFormField.vue.d.ts +15 -9
- package/dist/runtime/components/MapoFormField.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoFormGroup.vue +18 -2
- package/dist/runtime/components/MapoFormGroup.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoFormTabs.vue +50 -8
- package/dist/runtime/components/MapoFormTabs.vue.d.ts.map +1 -1
- package/dist/runtime/components/fields/MapoMediaField.vue +5 -3
- package/dist/runtime/components/fields/MapoMediaField.vue.d.ts.map +1 -1
- package/dist/runtime/components/fields/MapoMediaM2mField.vue +3 -2
- package/dist/runtime/components/fields/MapoMediaM2mField.vue.d.ts.map +1 -1
- package/dist/runtime/components/fields/MapoRepeater.vue +73 -14
- package/dist/runtime/components/fields/MapoRepeater.vue.d.ts.map +1 -1
- package/dist/runtime/components/fields/MapoRepeaterBlockPicker.vue +167 -0
- package/dist/runtime/components/fields/MapoRepeaterBlockPicker.vue.d.ts +20 -0
- package/dist/runtime/components/fields/MapoRepeaterBlockPicker.vue.d.ts.map +1 -0
- package/dist/runtime/components/fields/MapoRepeaterItem.vue +46 -10
- package/dist/runtime/components/fields/MapoRepeaterItem.vue.d.ts +6 -2
- package/dist/runtime/components/fields/MapoRepeaterItem.vue.d.ts.map +1 -1
- package/dist/runtime/components/fields/MapoWygEditor.vue +19 -13
- package/dist/runtime/components/fields/MapoWygEditor.vue.d.ts.map +1 -1
- package/dist/runtime/composables/useFieldAnnotation.d.ts +18 -0
- package/dist/runtime/composables/useFieldAnnotation.d.ts.map +1 -0
- package/dist/runtime/composables/useFieldAnnotation.js +16 -0
- package/dist/runtime/composables/useFocusMode.d.ts +3 -1
- package/dist/runtime/composables/useFocusMode.d.ts.map +1 -1
- package/dist/runtime/composables/useFormFromSchema.d.ts +23 -1
- package/dist/runtime/composables/useFormFromSchema.d.ts.map +1 -1
- package/dist/runtime/composables/useFormFromSchema.js +171 -32
- package/dist/runtime/composables/useMapoForm.d.ts +21 -3
- package/dist/runtime/composables/useMapoForm.d.ts.map +1 -1
- package/dist/runtime/composables/useMapoForm.js +49 -15
- package/dist/runtime/types/annotation.d.ts +43 -0
- package/dist/runtime/types/annotation.d.ts.map +1 -0
- package/dist/runtime/types/annotation.js +0 -0
- package/dist/runtime/types/descriptor.d.ts +81 -4
- package/dist/runtime/types/descriptor.d.ts.map +1 -1
- package/dist/runtime/types/index.d.ts +2 -1
- package/dist/runtime/types/index.d.ts.map +1 -1
- package/dist/runtime/utils/annotations.d.ts +40 -0
- package/dist/runtime/utils/annotations.d.ts.map +1 -0
- package/dist/runtime/utils/annotations.js +78 -0
- package/dist/runtime/utils/draft.d.ts +21 -0
- package/dist/runtime/utils/draft.d.ts.map +1 -0
- package/dist/runtime/utils/draft.js +108 -0
- package/dist/runtime/utils/fieldComponent.d.ts +9 -0
- package/dist/runtime/utils/fieldComponent.d.ts.map +1 -0
- package/dist/runtime/utils/fieldComponent.js +12 -0
- package/dist/runtime/utils/fieldFocus.d.ts +24 -0
- package/dist/runtime/utils/fieldFocus.d.ts.map +1 -0
- package/dist/runtime/utils/fieldFocus.js +41 -0
- package/dist/runtime/utils/fieldsToJsonSchema.d.ts +38 -0
- package/dist/runtime/utils/fieldsToJsonSchema.d.ts.map +1 -0
- package/dist/runtime/utils/fieldsToJsonSchema.js +248 -0
- package/dist/runtime/utils/repeaterTemplates.d.ts +26 -0
- package/dist/runtime/utils/repeaterTemplates.d.ts.map +1 -0
- package/dist/runtime/utils/repeaterTemplates.js +51 -0
- package/dist/runtime/utils/reveal.d.ts +34 -0
- package/dist/runtime/utils/reveal.d.ts.map +1 -0
- package/dist/runtime/utils/reveal.js +29 -0
- package/dist/runtime/utils/tabVisibility.d.ts +18 -0
- package/dist/runtime/utils/tabVisibility.d.ts.map +1 -0
- package/dist/runtime/utils/tabVisibility.js +18 -0
- package/package.json +5 -5
- package/src/__tests__/MapoFocusPortal.component.test.ts +97 -0
- package/src/__tests__/MapoForm.component.test.ts +79 -0
- package/src/__tests__/MapoFormAnnotation.component.test.ts +244 -0
- package/src/__tests__/MapoFormField.component.test.ts +508 -0
- package/src/__tests__/MapoFormGroup.component.test.ts +141 -0
- package/src/__tests__/MapoFormTabs.component.test.ts +254 -0
- package/src/__tests__/MapoRepeaterItem.component.test.ts +286 -0
- package/src/__tests__/MapoWygEditor.component.test.ts +95 -0
- package/src/__tests__/annotations.test.ts +227 -0
- package/src/__tests__/draft.test.ts +221 -0
- package/src/__tests__/fieldComponent.test.ts +31 -0
- package/src/__tests__/fieldExtensions.test.ts +63 -0
- package/src/__tests__/fieldFocus.test.ts +178 -0
- package/src/__tests__/fieldsToJsonSchema.test.ts +630 -0
- package/src/__tests__/headlessRenderer.ts +85 -0
- package/src/__tests__/repeaterTemplates.test.ts +154 -0
- package/src/__tests__/reveal.test.ts +89 -0
- package/src/__tests__/schemaSources.test.ts +132 -0
- package/src/__tests__/tabVisibility.test.ts +102 -0
- package/src/__tests__/useFormFromSchema.test.ts +387 -0
- package/src/__tests__/useMapoForm.test.ts +213 -2
- package/src/index.ts +9 -0
- package/src/module.ts +9 -0
- package/src/runtime/components/MapoFocusPortal.vue +15 -2
- package/src/runtime/components/MapoForm.vue +47 -4
- package/src/runtime/components/MapoFormAnnotation.vue +113 -0
- package/src/runtime/components/MapoFormAnnotationBadges.vue +41 -0
- package/src/runtime/components/MapoFormField.vue +72 -11
- package/src/runtime/components/MapoFormGroup.vue +20 -2
- package/src/runtime/components/MapoFormTabs.vue +64 -8
- package/src/runtime/components/fields/MapoMediaField.vue +5 -3
- package/src/runtime/components/fields/MapoMediaM2mField.vue +3 -2
- package/src/runtime/components/fields/MapoRepeater.vue +82 -14
- package/src/runtime/components/fields/MapoRepeaterBlockPicker.vue +188 -0
- package/src/runtime/components/fields/MapoRepeaterItem.vue +56 -8
- package/src/runtime/components/fields/MapoWygEditor.vue +22 -14
- package/src/runtime/composables/useFieldAnnotation.ts +38 -0
- package/src/runtime/composables/useFocusMode.ts +7 -1
- package/src/runtime/composables/useFormFromSchema.ts +303 -41
- package/src/runtime/composables/useMapoForm.ts +103 -23
- package/src/runtime/types/annotation.ts +53 -0
- package/src/runtime/types/descriptor.ts +94 -4
- package/src/runtime/types/index.ts +10 -0
- package/src/runtime/utils/annotations.ts +169 -0
- package/src/runtime/utils/draft.ts +158 -0
- package/src/runtime/utils/fieldComponent.ts +34 -0
- package/src/runtime/utils/fieldFocus.ts +73 -0
- package/src/runtime/utils/fieldsToJsonSchema.ts +405 -0
- package/src/runtime/utils/repeaterTemplates.ts +103 -0
- package/src/runtime/utils/reveal.ts +68 -0
- package/src/runtime/utils/tabVisibility.ts +44 -0
- package/dist/__tests__/__mocks__/nuxt-imports.d.ts +0 -4
- package/dist/__tests__/__mocks__/nuxt-imports.d.ts.map +0 -1
- package/dist/__tests__/camomillaRoundTrip.test.d.ts +0 -2
- package/dist/__tests__/camomillaRoundTrip.test.d.ts.map +0 -1
- package/dist/__tests__/registry.test.d.ts +0 -2
- package/dist/__tests__/registry.test.d.ts.map +0 -1
- package/dist/__tests__/useFormFromSchema.test.d.ts +0 -2
- package/dist/__tests__/useFormFromSchema.test.d.ts.map +0 -1
- package/dist/__tests__/useMapoForm.test.d.ts +0 -2
- package/dist/__tests__/useMapoForm.test.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"descriptor.d.ts","sourceRoot":"","sources":["../../../src/runtime/types/descriptor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAErC,2DAA2D;AAC3D,KAAK,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAEnC;;;;;GAKG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAChE,KAAK,GACL,CAAC,SAAS,MAAM,GACd;KACG,CAAC,IAAI,MAAM,CAAC,GAAG,MAAM,GAClB,CAAC,GACD,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,OAAO,EAAE,GAChC,KAAK,GACL,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,GAC9B,GAAG,CAAC,IAAI,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,GAC/C,KAAK,CAAC;CACjB,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,GACnB,KAAK,CAAC;AAEZ;;;GAGG;AACH,oBAAY,cAAc;IACxB,IAAI,SAAS;IAC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GACrB,eAAe,CAAC,CAAC,CAAC,GAClB,kBAAkB,CAAC,CAAC,CAAC,GACrB,uBAAuB,CAAC,CAAC,CAAC,CAAC;AAE/B;;;;;;;;GAQG;AACH,MAAM,MAAM,kBAAkB,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IACtD,eAAe,CAAC,CAAC,CAAC,GAClB,gBAAgB,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
* and registry helpers.
|
|
5
5
|
*/
|
|
6
6
|
export { KnownFieldType } from "./descriptor.js";
|
|
7
|
-
export type { FieldType, FieldAccessor, FieldDescriptor, AnyFieldDescriptor, TextDescriptor, NumberDescriptor, BooleanDescriptor, SelectDescriptor, FksDescriptor, DateDescriptor, ColorDescriptor, FileDescriptor, EditorDescriptor, SeoDescriptor, MapDescriptor, RepeaterDescriptor, MediaDescriptor, MediaM2mDescriptor, EnhancedMediaDescriptor, CustomDescriptor, } from "./descriptor.js";
|
|
7
|
+
export type { FieldType, FieldAccessor, FieldDescriptor, AnyFieldDescriptor, FieldExtensions, TextDescriptor, NumberDescriptor, BooleanDescriptor, SelectDescriptor, FksDescriptor, DateDescriptor, ColorDescriptor, FileDescriptor, EditorDescriptor, SeoDescriptor, MapDescriptor, RepeaterDescriptor, RepeaterTemplate, RepeaterImageFit, MediaDescriptor, MediaM2mDescriptor, EnhancedMediaDescriptor, CustomDescriptor, } from "./descriptor.js";
|
|
8
8
|
export type { MediaLink, MediaItem, EnhancedMediaValue } from "./media.js";
|
|
9
|
+
export type { FieldAnnotation, FieldAnnotationAction, FieldAnnotationColor, FieldAnnotations, } from "./annotation.js";
|
|
9
10
|
export type { FieldComponentEntry, FieldRegistry, PartialFieldRegistry, } from "./registry.js";
|
|
10
11
|
export { resolveFieldComponent, resolveFieldAttrs, resolveFieldAccessor, } from "./registry.js";
|
|
11
12
|
export type { MapoFormRuntimeConfig } from "./registry.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/types/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,YAAY,EACV,SAAS,EACT,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,uBAAuB,EACvB,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAE3E,YAAY,EACV,mBAAmB,EACnB,aAAa,EACb,oBAAoB,GACrB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,eAAe,CAAC;AAEvB,YAAY,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/types/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,YAAY,EACV,SAAS,EACT,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,uBAAuB,EACvB,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAE3E,YAAY,EACV,eAAe,EACf,qBAAqB,EACrB,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EACV,mBAAmB,EACnB,aAAa,EACb,oBAAoB,GACrB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,eAAe,CAAC;AAEvB,YAAY,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { AnyFieldDescriptor, FieldAnnotation, FieldAnnotationColor, FieldAnnotations } from "../types/index.js";
|
|
2
|
+
import type { TabEntry } from "../types/layout.js";
|
|
3
|
+
/** Icon of a mark that does not choose one. */
|
|
4
|
+
export declare const DEFAULT_ANNOTATION_ICON = "i-lucide-info";
|
|
5
|
+
/** Color of a mark that does not choose one. */
|
|
6
|
+
export declare const DEFAULT_ANNOTATION_COLOR: FieldAnnotationColor;
|
|
7
|
+
/**
|
|
8
|
+
* The path of a field's value in the model: its key, or its translation in the
|
|
9
|
+
* current language for a translatable field.
|
|
10
|
+
*/
|
|
11
|
+
export declare function valuePath(field: AnyFieldDescriptor, lang: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* The annotation of a field: the one at the path of its value; for a
|
|
14
|
+
* translatable field, otherwise the one at its bare key, which holds in every
|
|
15
|
+
* language.
|
|
16
|
+
*/
|
|
17
|
+
export declare function annotationFor(annotations: FieldAnnotations, key: string, path: string): FieldAnnotation | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* The entries under `prefix`, keyed relative to it: with prefix `blocks.0`,
|
|
20
|
+
* `blocks.0.title` becomes `title`. A repeater item reads its errors and its
|
|
21
|
+
* annotations from the parent form this way.
|
|
22
|
+
*/
|
|
23
|
+
export declare function entriesUnder<V>(record: Record<string, V>, prefix: string): Record<string, V>;
|
|
24
|
+
/** The annotations of one icon and one color: one badge with their count. */
|
|
25
|
+
export interface AnnotationGroup {
|
|
26
|
+
icon: string;
|
|
27
|
+
color: FieldAnnotationColor;
|
|
28
|
+
count: number;
|
|
29
|
+
/** The distinct labels, for the accessible name of the badge. */
|
|
30
|
+
labels: string[];
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The badges for a list of fields: the marks of the shown fields, those inside
|
|
34
|
+
* repeater items included, grouped by icon and color in the order they first
|
|
35
|
+
* appear.
|
|
36
|
+
*/
|
|
37
|
+
export declare function annotationGroups(fields: AnyFieldDescriptor[], annotations: FieldAnnotations, model: Record<string, unknown>, lang: string): AnnotationGroup[];
|
|
38
|
+
/** The badges of a tab: those of its fields, sub-tabs and child tabs included. */
|
|
39
|
+
export declare function tabAnnotationGroups(tab: TabEntry, annotations: FieldAnnotations, model: Record<string, unknown>, lang: string): AnnotationGroup[];
|
|
40
|
+
//# sourceMappingURL=annotations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotations.d.ts","sourceRoot":"","sources":["../../../src/runtime/utils/annotations.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,kBAAkB,EAClB,eAAe,EACf,oBAAoB,EACpB,gBAAgB,EAEjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAInD,+CAA+C;AAC/C,eAAO,MAAM,uBAAuB,kBAAkB,CAAC;AAEvD,gDAAgD;AAChD,eAAO,MAAM,wBAAwB,EAAE,oBAAgC,CAAC;AAExE;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAIzE;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,WAAW,EAAE,gBAAgB,EAC7B,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,GACX,eAAe,GAAG,SAAS,CAM7B;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAC5B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,EACzB,MAAM,EAAE,MAAM,GACb,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAOnB;AAED,6EAA6E;AAC7E,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,oBAAoB,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAgED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,kBAAkB,EAAE,EAC5B,WAAW,EAAE,gBAAgB,EAC7B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,IAAI,EAAE,MAAM,GACX,eAAe,EAAE,CAenB;AAED,kFAAkF;AAClF,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,QAAQ,EACb,WAAW,EAAE,gBAAgB,EAC7B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,IAAI,EAAE,MAAM,GACX,eAAe,EAAE,CAEnB"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { getNestedValue } from "@mapomodule/utils";
|
|
2
|
+
import { isFieldShown } from "./tabVisibility.js";
|
|
3
|
+
import { normalizeTemplates, repeaterItemFields } from "./repeaterTemplates.js";
|
|
4
|
+
export const DEFAULT_ANNOTATION_ICON = "i-lucide-info";
|
|
5
|
+
export const DEFAULT_ANNOTATION_COLOR = "neutral";
|
|
6
|
+
export function valuePath(field, lang) {
|
|
7
|
+
const key = field.key;
|
|
8
|
+
const isTranslated = Boolean(field.translatable) && Boolean(lang);
|
|
9
|
+
return isTranslated ? `translations.${lang}.${key}` : key;
|
|
10
|
+
}
|
|
11
|
+
export function annotationFor(annotations, key, path) {
|
|
12
|
+
const atPath = annotations[path];
|
|
13
|
+
if (atPath) return atPath;
|
|
14
|
+
const isTranslatedPath = path !== key;
|
|
15
|
+
if (!isTranslatedPath) return void 0;
|
|
16
|
+
return annotations[key];
|
|
17
|
+
}
|
|
18
|
+
export function entriesUnder(record, prefix) {
|
|
19
|
+
const start = `${prefix}.`;
|
|
20
|
+
const result = {};
|
|
21
|
+
for (const [path, value] of Object.entries(record)) {
|
|
22
|
+
if (path.startsWith(start)) result[path.slice(start.length)] = value;
|
|
23
|
+
}
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
function tabFields(tab) {
|
|
27
|
+
const own = [...tab.groups.values()].flatMap((group) => [
|
|
28
|
+
...group.fields,
|
|
29
|
+
...[...group.subtabs.values()].flat()
|
|
30
|
+
]);
|
|
31
|
+
const nested = [...tab.children.values()].flatMap(tabFields);
|
|
32
|
+
return [...own, ...nested];
|
|
33
|
+
}
|
|
34
|
+
function shownAnnotations(fields, annotations, model, lang) {
|
|
35
|
+
return fields.filter((field) => isFieldShown(field, model)).flatMap((field) => fieldAnnotations(field, annotations, model, lang));
|
|
36
|
+
}
|
|
37
|
+
function fieldAnnotations(field, annotations, model, lang) {
|
|
38
|
+
const key = field.key;
|
|
39
|
+
const path = valuePath(field, lang);
|
|
40
|
+
const own = annotationFor(annotations, key, path);
|
|
41
|
+
const marks = own ? [own] : [];
|
|
42
|
+
const isRepeater = field.type === "repeater";
|
|
43
|
+
if (!isRepeater) return marks;
|
|
44
|
+
const items = getNestedValue(model, path);
|
|
45
|
+
if (!Array.isArray(items)) return marks;
|
|
46
|
+
const repeater = field;
|
|
47
|
+
const templates = normalizeTemplates(repeater.attrs?.templates);
|
|
48
|
+
const firstTemplate = templates[0]?.key;
|
|
49
|
+
items.forEach((item, index) => {
|
|
50
|
+
const itemFields = repeaterItemFields(
|
|
51
|
+
repeater,
|
|
52
|
+
templates,
|
|
53
|
+
item,
|
|
54
|
+
firstTemplate
|
|
55
|
+
);
|
|
56
|
+
const itemAnnotations = entriesUnder(annotations, `${key}.${index}`);
|
|
57
|
+
marks.push(...shownAnnotations(itemFields, itemAnnotations, item, lang));
|
|
58
|
+
});
|
|
59
|
+
return marks;
|
|
60
|
+
}
|
|
61
|
+
export function annotationGroups(fields, annotations, model, lang) {
|
|
62
|
+
const hasAnnotations = Object.keys(annotations).length > 0;
|
|
63
|
+
if (!hasAnnotations) return [];
|
|
64
|
+
const groups = /* @__PURE__ */ new Map();
|
|
65
|
+
for (const mark of shownAnnotations(fields, annotations, model, lang)) {
|
|
66
|
+
const icon = mark.icon ?? DEFAULT_ANNOTATION_ICON;
|
|
67
|
+
const color = mark.color ?? DEFAULT_ANNOTATION_COLOR;
|
|
68
|
+
const groupKey = `${icon}|${color}`;
|
|
69
|
+
const group = groups.get(groupKey) ?? { icon, color, count: 0, labels: [] };
|
|
70
|
+
group.count++;
|
|
71
|
+
if (!group.labels.includes(mark.label)) group.labels.push(mark.label);
|
|
72
|
+
groups.set(groupKey, group);
|
|
73
|
+
}
|
|
74
|
+
return [...groups.values()];
|
|
75
|
+
}
|
|
76
|
+
export function tabAnnotationGroups(tab, annotations, model, lang) {
|
|
77
|
+
return annotationGroups(tabFields(tab), annotations, model, lang);
|
|
78
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { AnyFieldDescriptor } from "../types/index.js";
|
|
2
|
+
type Field = AnyFieldDescriptor<any>;
|
|
3
|
+
/**
|
|
4
|
+
* The model as a draft keeps it: a copy of what JSON writes and reads back
|
|
5
|
+
* as it was (texts, finite numbers, booleans, `null`, and lists and plain
|
|
6
|
+
* objects of them), in which the fields marked `noDraft` hold nothing.
|
|
7
|
+
* Anything else stays out, so a restore never writes it back changed: a
|
|
8
|
+
* file not uploaded yet, a date, a map; and so does a value met again
|
|
9
|
+
* inside itself. A field's value is removed at its key (`password`,
|
|
10
|
+
* `api.key`), and for a translatable or `synci18n` field in every language
|
|
11
|
+
* of `translations` too; inside a repeater, at the same paths of each item,
|
|
12
|
+
* by the fields the item renders. A field whose accessor writes its value
|
|
13
|
+
* somewhere else keeps it there.
|
|
14
|
+
*
|
|
15
|
+
* @param model The form's values.
|
|
16
|
+
* @param fields The form's fields, the sidebar's included.
|
|
17
|
+
* @returns The copy to store.
|
|
18
|
+
*/
|
|
19
|
+
export declare function modelForDraft<T extends object>(model: T, fields: readonly Field[]): T;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=draft.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"draft.d.ts","sourceRoot":"","sources":["../../../src/runtime/utils/draft.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAsB,MAAM,mBAAmB,CAAC;AAehF,KAAK,KAAK,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;AAerC;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,EAC5C,KAAK,EAAE,CAAC,EACR,MAAM,EAAE,SAAS,KAAK,EAAE,GACvB,CAAC,CAMH"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { normalizeTemplates, repeaterItemFields } from "./repeaterTemplates.js";
|
|
2
|
+
const UNSAFE_SEGMENTS = /* @__PURE__ */ new Set([
|
|
3
|
+
"__proto__",
|
|
4
|
+
"constructor",
|
|
5
|
+
"prototype"
|
|
6
|
+
]);
|
|
7
|
+
function isValues(value) {
|
|
8
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9
|
+
}
|
|
10
|
+
function isPlainObject(value) {
|
|
11
|
+
if (!isValues(value)) return false;
|
|
12
|
+
const prototype = Object.getPrototypeOf(value);
|
|
13
|
+
const isLiteral = prototype === Object.prototype;
|
|
14
|
+
const isBare = prototype === null;
|
|
15
|
+
return isLiteral || isBare;
|
|
16
|
+
}
|
|
17
|
+
export function modelForDraft(model, fields) {
|
|
18
|
+
const copy = plainCopy(model, /* @__PURE__ */ new Set());
|
|
19
|
+
const values = isPlainObject(copy) ? copy : {};
|
|
20
|
+
removeNoDraft(values, fields);
|
|
21
|
+
return values;
|
|
22
|
+
}
|
|
23
|
+
function plainCopy(value, inside) {
|
|
24
|
+
if (value === null) return null;
|
|
25
|
+
if (typeof value === "string") return value;
|
|
26
|
+
if (typeof value === "boolean") return value;
|
|
27
|
+
if (typeof value === "number") {
|
|
28
|
+
return Number.isFinite(value) ? value : void 0;
|
|
29
|
+
}
|
|
30
|
+
const isList = Array.isArray(value);
|
|
31
|
+
if (!isList && !isPlainObject(value)) return void 0;
|
|
32
|
+
if (inside.has(value)) return void 0;
|
|
33
|
+
inside.add(value);
|
|
34
|
+
let copy;
|
|
35
|
+
if (isList) {
|
|
36
|
+
copy = value.flatMap((item) => {
|
|
37
|
+
const kept = plainCopy(item, inside);
|
|
38
|
+
return kept === void 0 ? [] : [kept];
|
|
39
|
+
});
|
|
40
|
+
} else {
|
|
41
|
+
const kept = {};
|
|
42
|
+
for (const [key, item] of Object.entries(value)) {
|
|
43
|
+
const one = plainCopy(item, inside);
|
|
44
|
+
if (one === void 0) continue;
|
|
45
|
+
Object.defineProperty(kept, key, {
|
|
46
|
+
value: one,
|
|
47
|
+
enumerable: true,
|
|
48
|
+
writable: true,
|
|
49
|
+
configurable: true
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
copy = kept;
|
|
53
|
+
}
|
|
54
|
+
inside.delete(value);
|
|
55
|
+
return copy;
|
|
56
|
+
}
|
|
57
|
+
function removeNoDraft(values, fields) {
|
|
58
|
+
const languages = isValues(values.translations) ? Object.values(values.translations).filter(isValues) : [];
|
|
59
|
+
for (const field of fields) {
|
|
60
|
+
const key = String(field.key);
|
|
61
|
+
const isTranslated = Boolean(field.translatable) || Boolean(field.synci18n);
|
|
62
|
+
const holders = isTranslated ? [values, ...languages] : [values];
|
|
63
|
+
if (field.noDraft) {
|
|
64
|
+
for (const holder of holders) removeAt(holder, key);
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if (field.type !== "repeater") continue;
|
|
68
|
+
const repeater = field;
|
|
69
|
+
const templates = normalizeTemplates(repeater.attrs?.templates);
|
|
70
|
+
const fallback = templates[0]?.key;
|
|
71
|
+
for (const holder of holders) {
|
|
72
|
+
const items = readAt(holder, key);
|
|
73
|
+
if (!Array.isArray(items)) continue;
|
|
74
|
+
for (const item of items) {
|
|
75
|
+
if (!isValues(item)) continue;
|
|
76
|
+
const itemFields = repeaterItemFields(
|
|
77
|
+
repeater,
|
|
78
|
+
templates,
|
|
79
|
+
item,
|
|
80
|
+
fallback
|
|
81
|
+
);
|
|
82
|
+
removeNoDraft(item, itemFields);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function readAt(values, path) {
|
|
88
|
+
const segments = path.split(".");
|
|
89
|
+
if (segments.some((segment) => UNSAFE_SEGMENTS.has(segment))) {
|
|
90
|
+
return void 0;
|
|
91
|
+
}
|
|
92
|
+
let current = values;
|
|
93
|
+
for (const segment of segments) {
|
|
94
|
+
const isOwn = isValues(current) && Object.hasOwn(current, segment);
|
|
95
|
+
if (!isOwn) return void 0;
|
|
96
|
+
current = current[segment];
|
|
97
|
+
}
|
|
98
|
+
return current;
|
|
99
|
+
}
|
|
100
|
+
function removeAt(values, path) {
|
|
101
|
+
const segments = path.split(".");
|
|
102
|
+
const last = segments.pop();
|
|
103
|
+
if (last === void 0) return;
|
|
104
|
+
if (UNSAFE_SEGMENTS.has(last)) return;
|
|
105
|
+
const parent = segments.length ? readAt(values, segments.join(".")) : values;
|
|
106
|
+
const isOwn = isValues(parent) && Object.hasOwn(parent, last);
|
|
107
|
+
if (isOwn) delete parent[last];
|
|
108
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Component } from "vue";
|
|
2
|
+
import type { FieldComponentEntry } from "../types/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Returns the component that `<component :is>` renders for a registry entry.
|
|
5
|
+
* A lazy loader becomes an async component, created once per loader and reused;
|
|
6
|
+
* a component name or a component is returned as it is.
|
|
7
|
+
*/
|
|
8
|
+
export declare function toFieldComponent(entry: FieldComponentEntry): string | Component;
|
|
9
|
+
//# sourceMappingURL=fieldComponent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fieldComponent.d.ts","sourceRoot":"","sources":["../../../src/runtime/utils/fieldComponent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AACrC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAa7D;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,mBAAmB,GACzB,MAAM,GAAG,SAAS,CAWpB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { defineAsyncComponent } from "vue";
|
|
2
|
+
const asyncFields = /* @__PURE__ */ new WeakMap();
|
|
3
|
+
export function toFieldComponent(entry) {
|
|
4
|
+
const isLoader = typeof entry === "function";
|
|
5
|
+
if (!isLoader) return entry;
|
|
6
|
+
const loader = entry;
|
|
7
|
+
const cached = asyncFields.get(loader);
|
|
8
|
+
if (cached) return cached;
|
|
9
|
+
const component = defineAsyncComponent(loader);
|
|
10
|
+
asyncFields.set(loader, component);
|
|
11
|
+
return component;
|
|
12
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Puts the focus back on a field's control when nothing holds it. An action
|
|
3
|
+
* in a field's mark can take the mark away, or replace the button pressed,
|
|
4
|
+
* and the browser then drops the focus on the page: the field is where the
|
|
5
|
+
* operator was. A focus held elsewhere, as by a dialog the action opened,
|
|
6
|
+
* stays where it is.
|
|
7
|
+
*
|
|
8
|
+
* @param id The id of the field's control, as `MapoFormField` gives it: `field-<key>`.
|
|
9
|
+
* @returns Whether the focus went to the field.
|
|
10
|
+
*/
|
|
11
|
+
export declare function refocusField(id: string): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Puts the focus on a field's control and scrolls the field into view, its
|
|
14
|
+
* label and mark included: what `revealField()` ends with. The control is
|
|
15
|
+
* the element with the field's id inside the field's own element: an id
|
|
16
|
+
* alone could name the same field of another repeater item.
|
|
17
|
+
*
|
|
18
|
+
* @param field The field's element, as `MapoFormField` renders it.
|
|
19
|
+
* @param id The id of the field's control: `field-<key>`.
|
|
20
|
+
* @returns Whether the control took the focus. Not while it cannot have it,
|
|
21
|
+
* as when it is disabled or not rendered yet.
|
|
22
|
+
*/
|
|
23
|
+
export declare function focusFieldControl(field: unknown, id: string): boolean;
|
|
24
|
+
//# sourceMappingURL=fieldFocus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fieldFocus.d.ts","sourceRoot":"","sources":["../../../src/runtime/utils/fieldFocus.ts"],"names":[],"mappings":"AAUA;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAahD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAcrE"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const FOCUSABLE = [
|
|
2
|
+
'input:not([type="hidden"])',
|
|
3
|
+
"textarea",
|
|
4
|
+
"select",
|
|
5
|
+
"button",
|
|
6
|
+
'[contenteditable="true"]',
|
|
7
|
+
'[tabindex]:not([tabindex="-1"])'
|
|
8
|
+
].join(", ");
|
|
9
|
+
export function refocusField(id) {
|
|
10
|
+
if (typeof document === "undefined") return false;
|
|
11
|
+
const active = document.activeElement;
|
|
12
|
+
const isLost = active === null || active === document.body;
|
|
13
|
+
if (!isLost) return false;
|
|
14
|
+
const root = document.getElementById(id);
|
|
15
|
+
if (!root) return false;
|
|
16
|
+
const control = root.matches(FOCUSABLE) ? root : root.querySelector(FOCUSABLE);
|
|
17
|
+
if (!control) return false;
|
|
18
|
+
control.focus();
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
export function focusFieldControl(field, id) {
|
|
22
|
+
if (!isElement(field)) return false;
|
|
23
|
+
const escaped = id.replace(/["\\]/g, "\\$&");
|
|
24
|
+
const root = field.querySelector(`[id="${escaped}"]`);
|
|
25
|
+
if (!root) return false;
|
|
26
|
+
const control = root.matches(FOCUSABLE) ? root : root.querySelector(FOCUSABLE);
|
|
27
|
+
if (!control) return false;
|
|
28
|
+
const behavior = prefersReducedMotion() ? "auto" : "smooth";
|
|
29
|
+
field.scrollIntoView?.({ block: "center", behavior });
|
|
30
|
+
control.focus({ preventScroll: true });
|
|
31
|
+
return field.ownerDocument.activeElement === control;
|
|
32
|
+
}
|
|
33
|
+
function isElement(value) {
|
|
34
|
+
const isObject = typeof value === "object" && value !== null;
|
|
35
|
+
return isObject && typeof value.querySelector === "function";
|
|
36
|
+
}
|
|
37
|
+
function prefersReducedMotion() {
|
|
38
|
+
if (typeof window === "undefined") return false;
|
|
39
|
+
if (typeof window.matchMedia !== "function") return false;
|
|
40
|
+
return window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
41
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { JSONSchema } from "@mapomodule/utils";
|
|
2
|
+
import type { AnyFieldDescriptor } from "../types/index.js";
|
|
3
|
+
/** Options of {@link fieldsToJsonSchema}. */
|
|
4
|
+
export interface FieldsToJsonSchemaOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Called for every field, those of repeaters and templates included, with the
|
|
7
|
+
* schema written for it. Return the schema to use, or `undefined` to leave
|
|
8
|
+
* the field out. This is how a property declared with `FieldExtensions`
|
|
9
|
+
* reaches the schema. `x-mapo-field` is decided afterwards, on the schema
|
|
10
|
+
* returned.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* property: (schema, field) =>
|
|
14
|
+
* field.help ? { ...schema, description: field.help } : schema
|
|
15
|
+
*/
|
|
16
|
+
property?: (schema: JSONSchema, field: AnyFieldDescriptor<any>) => JSONSchema | undefined;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Describes a form as a JSON Schema: one property per field, named by the
|
|
20
|
+
* field key, in the dialect `useFormFromSchema()` reads. The schema reads back
|
|
21
|
+
* into equivalent descriptors.
|
|
22
|
+
*
|
|
23
|
+
* Each property carries the field's type, label, required, readonly,
|
|
24
|
+
* translatable and `noDraft` flags, and its `attrs`: as standard keywords
|
|
25
|
+
* (`minimum`, `maxLength`, `enum`…) where one exists, in `x-mapo-attrs`
|
|
26
|
+
* otherwise. Layout (`tab`, `group`, `cols`…), functions (`visible`,
|
|
27
|
+
* `validate`…) and components (`is`) are not written.
|
|
28
|
+
*
|
|
29
|
+
* @param fields The descriptors, as passed to `MapoForm`.
|
|
30
|
+
* @param options `property` customises the schema of each field.
|
|
31
|
+
* @returns A JSON Schema of type `object`.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* const schema = fieldsToJsonSchema(fields);
|
|
35
|
+
* const same = useFormFromSchema(schema); // equivalent descriptors
|
|
36
|
+
*/
|
|
37
|
+
export declare function fieldsToJsonSchema(fields: readonly AnyFieldDescriptor<any>[], options?: FieldsToJsonSchemaOptions): JSONSchema;
|
|
38
|
+
//# sourceMappingURL=fieldsToJsonSchema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fieldsToJsonSchema.d.ts","sourceRoot":"","sources":["../../../src/runtime/utils/fieldsToJsonSchema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAOpD,OAAO,KAAK,EAAE,kBAAkB,EAAoB,MAAM,mBAAmB,CAAC;AAO9E,6CAA6C;AAC7C,MAAM,WAAW,yBAAyB;IACxC;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,EAAE,CACT,MAAM,EAAE,UAAU,EAGlB,KAAK,EAAE,kBAAkB,CAAC,GAAG,CAAC,KAC3B,UAAU,GAAG,SAAS,CAAC;CAC7B;AAyVD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,kBAAkB,CAEhC,MAAM,EAAE,SAAS,kBAAkB,CAAC,GAAG,CAAC,EAAE,EAC1C,OAAO,GAAE,yBAA8B,GACtC,UAAU,CAEZ"}
|