@mapomodule/form 2.0.0-beta.8 → 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 +173 -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__/article.schema.json +193 -0
- package/src/__tests__/camomillaRoundTrip.test.ts +73 -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 +306 -42
- 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__/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,13 +1,18 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { computed,
|
|
2
|
+
import { computed, inject, nextTick, ref, watch } from "vue";
|
|
3
3
|
import {
|
|
4
4
|
resolveFieldComponent,
|
|
5
5
|
resolveFieldAttrs,
|
|
6
6
|
resolveFieldAccessor
|
|
7
7
|
} from "../types/index.js";
|
|
8
8
|
import { injectMapoForm } from "../composables/useMapoForm.js";
|
|
9
|
+
import { toFieldComponent } from "../utils/fieldComponent.js";
|
|
10
|
+
import { valuePath } from "../utils/annotations.js";
|
|
11
|
+
import { focusFieldControl } from "../utils/fieldFocus.js";
|
|
12
|
+
import { useFieldAnnotation } from "../composables/useFieldAnnotation.js";
|
|
9
13
|
import { getNestedValue, debounce } from "@mapomodule/utils";
|
|
10
14
|
import MapoUnknownField from "./MapoUnknownField.vue";
|
|
15
|
+
import MapoFormAnnotation from "./MapoFormAnnotation.vue";
|
|
11
16
|
const props = defineProps({
|
|
12
17
|
descriptor: { type: Object, required: true }
|
|
13
18
|
});
|
|
@@ -25,13 +30,7 @@ const showField = computed(() => {
|
|
|
25
30
|
return false;
|
|
26
31
|
return true;
|
|
27
32
|
});
|
|
28
|
-
const path = computed(() =>
|
|
29
|
-
const lang = currentLang.value;
|
|
30
|
-
if (props.descriptor.translatable && lang) {
|
|
31
|
-
return `translations.${lang}.${props.descriptor.key}`;
|
|
32
|
-
}
|
|
33
|
-
return props.descriptor.key;
|
|
34
|
-
});
|
|
33
|
+
const path = computed(() => valuePath(props.descriptor, currentLang.value));
|
|
35
34
|
const accessor = computed(
|
|
36
35
|
() => resolveFieldAccessor(props.descriptor, registry)
|
|
37
36
|
);
|
|
@@ -99,9 +98,7 @@ const asyncTrailingIconClass = computed(
|
|
|
99
98
|
const fieldComponent = computed(() => {
|
|
100
99
|
const entry = resolveFieldComponent(props.descriptor, registry);
|
|
101
100
|
if (!entry) return MapoUnknownField;
|
|
102
|
-
|
|
103
|
-
return defineAsyncComponent(entry);
|
|
104
|
-
return entry;
|
|
101
|
+
return toFieldComponent(entry);
|
|
105
102
|
});
|
|
106
103
|
const fieldAttrs = computed(
|
|
107
104
|
() => resolveFieldAttrs(props.descriptor, registry)
|
|
@@ -138,6 +135,7 @@ const label = computed(
|
|
|
138
135
|
() => props.descriptor.label ?? autoLabel(props.descriptor.key)
|
|
139
136
|
);
|
|
140
137
|
const fieldId = computed(() => `field-${props.descriptor.key}`);
|
|
138
|
+
const annotation = useFieldAnnotation(() => props.descriptor);
|
|
141
139
|
const groupExpand = inject("mapoGroupExpand", null);
|
|
142
140
|
const isExpanded = computed(
|
|
143
141
|
() => groupExpand ? groupExpand.expandedFieldKey.value === props.descriptor.key : false
|
|
@@ -147,12 +145,33 @@ function toggleExpand() {
|
|
|
147
145
|
if (isExpanded.value) groupExpand.collapseField();
|
|
148
146
|
else groupExpand.expandField(props.descriptor.key);
|
|
149
147
|
}
|
|
148
|
+
const fieldElement = ref(null);
|
|
149
|
+
const REVEAL_RETRY_MS = 50;
|
|
150
|
+
watch(
|
|
151
|
+
() => form.reveal?.value,
|
|
152
|
+
(request) => {
|
|
153
|
+
const isThisField = request !== void 0 && request.rest === "" && request.key === props.descriptor.key;
|
|
154
|
+
if (isThisField) void focusWhenRendered(request);
|
|
155
|
+
},
|
|
156
|
+
{ immediate: true }
|
|
157
|
+
);
|
|
158
|
+
async function focusWhenRendered(request) {
|
|
159
|
+
await nextTick();
|
|
160
|
+
while (form.reveal?.value === request) {
|
|
161
|
+
if (focusFieldControl(fieldElement.value, fieldId.value)) {
|
|
162
|
+
request.settle(true);
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
await new Promise((resolve) => setTimeout(resolve, REVEAL_RETRY_MS));
|
|
166
|
+
}
|
|
167
|
+
}
|
|
150
168
|
</script>
|
|
151
169
|
|
|
152
170
|
<template>
|
|
153
171
|
<div
|
|
154
172
|
v-if="isVisible"
|
|
155
173
|
v-show="showField"
|
|
174
|
+
ref="fieldElement"
|
|
156
175
|
class="mapo-form-field group flex flex-col gap-1"
|
|
157
176
|
:class="[
|
|
158
177
|
descriptor.class,
|
|
@@ -165,6 +184,7 @@ function toggleExpand() {
|
|
|
165
184
|
:name="`field.${descriptor.key}.label`"
|
|
166
185
|
:descriptor="descriptor"
|
|
167
186
|
:label="label"
|
|
187
|
+
:annotation="annotation"
|
|
168
188
|
>
|
|
169
189
|
<label
|
|
170
190
|
:for="fieldId"
|
|
@@ -174,6 +194,22 @@ function toggleExpand() {
|
|
|
174
194
|
<span v-if="descriptor.required" class="text-red-500" aria-hidden="true"
|
|
175
195
|
>*</span
|
|
176
196
|
>
|
|
197
|
+
<MapoFormAnnotation
|
|
198
|
+
v-if="annotation"
|
|
199
|
+
:annotation="annotation"
|
|
200
|
+
:field="fieldId"
|
|
201
|
+
>
|
|
202
|
+
<template
|
|
203
|
+
v-if="$slots[`field.${descriptor.key}.annotation`]"
|
|
204
|
+
#body
|
|
205
|
+
>
|
|
206
|
+
<slot
|
|
207
|
+
:name="`field.${descriptor.key}.annotation`"
|
|
208
|
+
:descriptor="descriptor"
|
|
209
|
+
:annotation="annotation"
|
|
210
|
+
/>
|
|
211
|
+
</template>
|
|
212
|
+
</MapoFormAnnotation>
|
|
177
213
|
<UIcon
|
|
178
214
|
v-if="asyncTrailingIcon"
|
|
179
215
|
:name="asyncTrailingIcon"
|
|
@@ -5,34 +5,40 @@ type __VLS_Props = {
|
|
|
5
5
|
declare var __VLS_2: `field.${string}.label`, __VLS_3: {
|
|
6
6
|
descriptor: AnyFieldDescriptor<any>;
|
|
7
7
|
label: string;
|
|
8
|
-
|
|
8
|
+
annotation: import("../types/annotation.js").FieldAnnotation | undefined;
|
|
9
|
+
}, __VLS_13: `field.${string}.annotation`, __VLS_14: {
|
|
10
|
+
descriptor: AnyFieldDescriptor<any>;
|
|
11
|
+
annotation: import("../types/annotation.js").FieldAnnotation;
|
|
12
|
+
}, __VLS_27: `field.${string}.before`, __VLS_28: {
|
|
9
13
|
descriptor: AnyFieldDescriptor<any>;
|
|
10
14
|
model: Record<string, unknown>;
|
|
11
|
-
},
|
|
15
|
+
}, __VLS_31: `field.${string}.prepend`, __VLS_32: {
|
|
12
16
|
descriptor: AnyFieldDescriptor<any>;
|
|
13
17
|
model: Record<string, unknown>;
|
|
14
|
-
},
|
|
18
|
+
}, __VLS_42: `field.${string}.append`, __VLS_43: {
|
|
15
19
|
descriptor: AnyFieldDescriptor<any>;
|
|
16
20
|
model: Record<string, unknown>;
|
|
17
|
-
},
|
|
21
|
+
}, __VLS_46: `field.${string}.hint`, __VLS_47: {
|
|
18
22
|
descriptor: AnyFieldDescriptor<any>;
|
|
19
23
|
model: Record<string, unknown>;
|
|
20
|
-
},
|
|
24
|
+
}, __VLS_50: `field.${string}.after`, __VLS_51: {
|
|
21
25
|
descriptor: AnyFieldDescriptor<any>;
|
|
22
26
|
model: Record<string, unknown>;
|
|
23
27
|
};
|
|
24
28
|
type __VLS_Slots = {} & {
|
|
25
29
|
[K in NonNullable<typeof __VLS_2>]?: (props: typeof __VLS_3) => any;
|
|
26
30
|
} & {
|
|
27
|
-
[K in NonNullable<typeof
|
|
31
|
+
[K in NonNullable<typeof __VLS_13>]?: (props: typeof __VLS_14) => any;
|
|
28
32
|
} & {
|
|
29
|
-
[K in NonNullable<typeof
|
|
33
|
+
[K in NonNullable<typeof __VLS_27>]?: (props: typeof __VLS_28) => any;
|
|
30
34
|
} & {
|
|
31
35
|
[K in NonNullable<typeof __VLS_31>]?: (props: typeof __VLS_32) => any;
|
|
32
36
|
} & {
|
|
33
|
-
[K in NonNullable<typeof
|
|
37
|
+
[K in NonNullable<typeof __VLS_42>]?: (props: typeof __VLS_43) => any;
|
|
38
|
+
} & {
|
|
39
|
+
[K in NonNullable<typeof __VLS_46>]?: (props: typeof __VLS_47) => any;
|
|
34
40
|
} & {
|
|
35
|
-
[K in NonNullable<typeof
|
|
41
|
+
[K in NonNullable<typeof __VLS_50>]?: (props: typeof __VLS_51) => any;
|
|
36
42
|
};
|
|
37
43
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
38
44
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapoFormField.vue.d.ts","sourceRoot":"","sources":["../../../src/runtime/components/MapoFormField.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MapoFormField.vue.d.ts","sourceRoot":"","sources":["../../../src/runtime/components/MapoFormField.vue"],"names":[],"mappings":"AAgaA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAmB5D,KAAK,WAAW,GAAG;IAAE,UAAU,EAAE,kBAAkB,CAAC,GAAG,CAAC,CAAA;CAAE,CAAC;AA+e3D,QAAA,IAAI,OAAO,yBAAU,EAAE,OAAO;;;;CAAU,EAAE,QAAQ,8BAAW,EAAE,QAAQ;;;CAAW,EAAE,QAAQ,0BAAW,EAAE,QAAQ;;;CAAW,EAAE,QAAQ,2BAAW,EAAE,QAAQ;;;CAAW,EAAE,QAAQ,0BAAW,EAAE,QAAQ;;;CAAW,EAAE,QAAQ,wBAAW,EAAE,QAAQ;;;CAAW,EAAE,QAAQ,yBAAW,EAAE,QAAQ;;;CAAY,CAAE;AACvS,KAAK,WAAW,GAAG,EAAE,GACnB;KAAG,CAAC,IAAI,WAAW,CAAC,OAAO,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG;CAAE,GACvE;KAAG,CAAC,IAAI,WAAW,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,QAAQ,KAAK,GAAG;CAAE,GACzE;KAAG,CAAC,IAAI,WAAW,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,QAAQ,KAAK,GAAG;CAAE,GACzE;KAAG,CAAC,IAAI,WAAW,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,QAAQ,KAAK,GAAG;CAAE,GACzE;KAAG,CAAC,IAAI,WAAW,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,QAAQ,KAAK,GAAG;CAAE,GACzE;KAAG,CAAC,IAAI,WAAW,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,QAAQ,KAAK,GAAG;CAAE,GACzE;KAAG,CAAC,IAAI,WAAW,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,QAAQ,KAAK,GAAG;CAAE,CAAC;AAO5E,QAAA,MAAM,UAAU,kSAEd,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AACzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
ref,
|
|
4
4
|
computed,
|
|
5
5
|
provide,
|
|
6
|
+
watch,
|
|
6
7
|
watchEffect,
|
|
7
8
|
onMounted,
|
|
8
9
|
onUnmounted
|
|
@@ -46,6 +47,21 @@ provide("mapoGroupExpand", { expandField, collapseField, expandedFieldKey });
|
|
|
46
47
|
const form = injectMapoForm();
|
|
47
48
|
const model = computed(() => form?.model.value);
|
|
48
49
|
const currentLang = computed(() => form?.currentLang.value ?? "");
|
|
50
|
+
watch(
|
|
51
|
+
() => form?.reveal?.value,
|
|
52
|
+
(request) => {
|
|
53
|
+
if (!request) return;
|
|
54
|
+
const isOwnField = props.fields.some((field) => field.key === request.key);
|
|
55
|
+
const subtabs = [...props.subtabs?.entries() ?? []];
|
|
56
|
+
const subtab = subtabs.find(
|
|
57
|
+
([, fields]) => fields.some((field) => field.key === request.key)
|
|
58
|
+
);
|
|
59
|
+
if (!isOwnField && !subtab) return;
|
|
60
|
+
expanded.value = true;
|
|
61
|
+
if (subtab) activeSubtab.value = subtab[0];
|
|
62
|
+
},
|
|
63
|
+
{ immediate: true }
|
|
64
|
+
);
|
|
49
65
|
const COL_SPAN = {
|
|
50
66
|
1: "col-span-1",
|
|
51
67
|
2: "col-span-2",
|
|
@@ -193,12 +209,12 @@ function colClass(cols) {
|
|
|
193
209
|
<!-- Sub-tab bar + content (when subtabs are present) -->
|
|
194
210
|
<div v-if="subtabs && subtabs.size > 0" class="px-5 pb-5 pt-4">
|
|
195
211
|
<!-- Sub-tab bar -->
|
|
196
|
-
<div class="flex gap-1 border-b border-gray-200
|
|
212
|
+
<div class="mb-4 flex flex-wrap gap-1 border-b border-gray-200">
|
|
197
213
|
<button
|
|
198
214
|
v-for="[subtabName] of subtabs"
|
|
199
215
|
:key="subtabName"
|
|
200
216
|
type="button"
|
|
201
|
-
class="relative px-3 py-1.5 text-sm font-medium transition-colors focus:outline-none"
|
|
217
|
+
class="relative max-w-full px-3 py-1.5 text-sm font-medium transition-colors focus:outline-none"
|
|
202
218
|
:class="[
|
|
203
219
|
activeSubtab === subtabName ? 'text-primary-600 border-b-2 border-primary-600 -mb-px' : 'text-gray-500 hover:text-gray-700'
|
|
204
220
|
]"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapoFormGroup.vue.d.ts","sourceRoot":"","sources":["../../../src/runtime/components/MapoFormGroup.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MapoFormGroup.vue.d.ts","sourceRoot":"","sources":["../../../src/runtime/components/MapoFormGroup.vue"],"names":[],"mappings":"AA0TA,OAAO,KAAK,EACV,kBAAkB,EAEnB,MAAM,mBAAmB,CAAC;AAI3B,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,kBAAkB,EAAE,CAAC;IAC7B,OAAO,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,EAAE,CAAC,CAAC;IAC5C,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC;AAoeF,QAAA,IAAI,QAAQ,mBAAW,EAAE,QAAQ;;;;CAAW,EAAE,QAAQ,QAAW,EAAE,QAAQ,KAAW,EAAE,QAAQ,mBAAW,EAAE,QAAQ;;;;CAAW,EAAE,QAAQ,QAAW,EAAE,QAAQ,KAAW,EAAE,QAAQ,mBAAW,EAAE,QAAQ;;;;CAAW,EAAE,QAAQ,QAAW,EAAE,QAAQ,KAAY,CAAE;AACjQ,KAAK,WAAW,GAAG,EAAE,GACnB;KAAG,CAAC,IAAI,WAAW,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,QAAQ,KAAK,GAAG;CAAE,GACzE;KAAG,CAAC,IAAI,WAAW,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,QAAQ,KAAK,GAAG;CAAE,GACzE;KAAG,CAAC,IAAI,WAAW,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,QAAQ,KAAK,GAAG;CAAE,GACzE;KAAG,CAAC,IAAI,WAAW,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,QAAQ,KAAK,GAAG;CAAE,GACzE;KAAG,CAAC,IAAI,WAAW,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,QAAQ,KAAK,GAAG;CAAE,GACzE;KAAG,CAAC,IAAI,WAAW,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,QAAQ,KAAK,GAAG;CAAE,CAAC;AAG5E,QAAA,MAAM,UAAU,kSAEd,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AACzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
|
|
@@ -1,15 +1,42 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { ref, computed } from "vue";
|
|
2
|
+
import { ref, computed, watch } from "vue";
|
|
3
3
|
import { useI18n } from "vue-i18n";
|
|
4
4
|
import { injectMapoForm } from "../composables/useMapoForm.js";
|
|
5
|
+
import { tabHoldsField } from "../utils/reveal.js";
|
|
6
|
+
import { pickActiveTab, tabHasShownFields } from "../utils/tabVisibility.js";
|
|
7
|
+
import { tabAnnotationGroups } from "../utils/annotations.js";
|
|
8
|
+
import MapoFormAnnotationBadges from "./MapoFormAnnotationBadges.vue";
|
|
5
9
|
import MapoFormGroup from "./MapoFormGroup.vue";
|
|
6
10
|
import MapoFormFlatSection from "./MapoFormFlatSection.vue";
|
|
7
11
|
const { t } = useI18n();
|
|
8
12
|
const props = defineProps({
|
|
9
13
|
tabs: { type: Array, required: true }
|
|
10
14
|
});
|
|
11
|
-
defineSlots();
|
|
12
|
-
const
|
|
15
|
+
const slots = defineSlots();
|
|
16
|
+
const form = injectMapoForm();
|
|
17
|
+
function tabHasContent(tab) {
|
|
18
|
+
const hasPanelSlot = Boolean(slots[`tab.${tab.name}`]);
|
|
19
|
+
const hasBeforeSlot = Boolean(slots[`tab.${tab.name}.before`]);
|
|
20
|
+
const hasAfterSlot = Boolean(slots[`tab.${tab.name}.after`]);
|
|
21
|
+
if (hasPanelSlot || hasBeforeSlot || hasAfterSlot) return true;
|
|
22
|
+
return tabHasShownFields(tab, form.model.value);
|
|
23
|
+
}
|
|
24
|
+
const shownTabs = computed(() => props.tabs.filter(tabHasContent));
|
|
25
|
+
const pickedTab = ref(null);
|
|
26
|
+
const activeTab = computed(
|
|
27
|
+
() => pickActiveTab(shownTabs.value, pickedTab.value)
|
|
28
|
+
);
|
|
29
|
+
watch(
|
|
30
|
+
() => form.reveal?.value,
|
|
31
|
+
(request) => {
|
|
32
|
+
if (!request) return;
|
|
33
|
+
const holder = shownTabs.value.find(
|
|
34
|
+
(tab) => tabHoldsField(tab, request.key)
|
|
35
|
+
);
|
|
36
|
+
if (holder) pickedTab.value = holder.name;
|
|
37
|
+
},
|
|
38
|
+
{ immediate: true }
|
|
39
|
+
);
|
|
13
40
|
function tabHasErrors(tab, errorKeys) {
|
|
14
41
|
const directError = [...tab.groups.values()].some(
|
|
15
42
|
(g) => g.fields.some((f) => errorKeys.has(f.key))
|
|
@@ -19,7 +46,19 @@ function tabHasErrors(tab, errorKeys) {
|
|
|
19
46
|
(child) => tabHasErrors(child, errorKeys)
|
|
20
47
|
);
|
|
21
48
|
}
|
|
22
|
-
const
|
|
49
|
+
const annotationGroups = computed(
|
|
50
|
+
() => new Map(
|
|
51
|
+
props.tabs.map((tab) => [
|
|
52
|
+
tab.name,
|
|
53
|
+
tabAnnotationGroups(
|
|
54
|
+
tab,
|
|
55
|
+
form.annotations?.value ?? {},
|
|
56
|
+
form.model.value,
|
|
57
|
+
form.currentLang.value
|
|
58
|
+
)
|
|
59
|
+
])
|
|
60
|
+
)
|
|
61
|
+
);
|
|
23
62
|
const tabsWithErrors = computed(() => {
|
|
24
63
|
const errorKeys = new Set(Object.keys(form.errors.value));
|
|
25
64
|
return new Set(
|
|
@@ -31,20 +70,23 @@ const tabsWithErrors = computed(() => {
|
|
|
31
70
|
<template>
|
|
32
71
|
<div class="mapo-form-tabs">
|
|
33
72
|
<!-- Tab bar -->
|
|
34
|
-
<div class="flex gap-1 border-b border-gray-200 pb-px">
|
|
73
|
+
<div class="flex flex-wrap gap-1 border-b border-gray-200 pb-px">
|
|
35
74
|
<button
|
|
36
|
-
v-for="tab in
|
|
75
|
+
v-for="tab in shownTabs"
|
|
37
76
|
:key="tab.name"
|
|
38
77
|
type="button"
|
|
39
|
-
class="relative flex items-center gap-1.5 rounded-t px-4 py-2 text-sm font-medium transition-colors"
|
|
78
|
+
class="relative flex max-w-full items-center gap-1.5 rounded-t px-4 py-2 text-sm font-medium transition-colors"
|
|
40
79
|
:class="[
|
|
41
80
|
activeTab === tab.name ? 'border-b-2 border-primary-500 text-primary-600' : 'text-gray-500 hover:bg-gray-50 hover:text-gray-700'
|
|
42
81
|
]"
|
|
43
|
-
@click="
|
|
82
|
+
@click="pickedTab = tab.name"
|
|
44
83
|
>
|
|
45
84
|
<slot :name="`tab.${tab.name}.label`" :tab="tab">
|
|
46
85
|
{{ tab.label ?? tab.name }}
|
|
47
86
|
</slot>
|
|
87
|
+
<MapoFormAnnotationBadges
|
|
88
|
+
:groups="annotationGroups.get(tab.name) ?? []"
|
|
89
|
+
/>
|
|
48
90
|
<span
|
|
49
91
|
v-if="tabsWithErrors.has(tab.name)"
|
|
50
92
|
class="inline-block h-1.5 w-1.5 rounded-full bg-red-500"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapoFormTabs.vue.d.ts","sourceRoot":"","sources":["../../../src/runtime/components/MapoFormTabs.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MapoFormTabs.vue.d.ts","sourceRoot":"","sources":["../../../src/runtime/components/MapoFormTabs.vue"],"names":[],"mappings":"AAoLA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAWnD,KAAK,WAAW,GAAG;IAAE,IAAI,EAAE,QAAQ,EAAE,CAAA;CAAE,CAAC;AAGxC,KAAK,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAoS3C,QAAA,MAAM,UAAU,kSAEd,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AACzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
|
|
@@ -35,10 +35,12 @@ function clear() {
|
|
|
35
35
|
<MapoMediaUnavailable v-if="!available" />
|
|
36
36
|
|
|
37
37
|
<template v-else>
|
|
38
|
-
<!-- Selected media preview
|
|
38
|
+
<!-- Selected media preview. It and the trigger below paint their own
|
|
39
|
+
surface, like an input: `soft` buttons and transparent cards take
|
|
40
|
+
the page background and vanish on a tinted page. -->
|
|
39
41
|
<div
|
|
40
42
|
v-if="current"
|
|
41
|
-
class="flex items-center gap-3 rounded-lg border border-default p-2"
|
|
43
|
+
class="flex items-center gap-3 rounded-lg border border-default bg-default p-2"
|
|
42
44
|
>
|
|
43
45
|
<MapoMediaPreview :media="current" size="sm" />
|
|
44
46
|
<div class="flex-1 min-w-0">
|
|
@@ -64,7 +66,7 @@ function clear() {
|
|
|
64
66
|
v-if="!readonly && !disabled"
|
|
65
67
|
:icon="current ? 'i-lucide-refresh-cw' : 'i-lucide-image-plus'"
|
|
66
68
|
size="sm"
|
|
67
|
-
variant="
|
|
69
|
+
variant="outline"
|
|
68
70
|
color="neutral"
|
|
69
71
|
:block="!current"
|
|
70
72
|
@click="dialogOpen = true"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapoMediaField.vue.d.ts","sourceRoot":"","sources":["../../../../src/runtime/components/fields/MapoMediaField.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MapoMediaField.vue.d.ts","sourceRoot":"","sources":["../../../../src/runtime/components/fields/MapoMediaField.vue"],"names":[],"mappings":"AA+GA,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGvE,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,SAAS,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAClD,UAAU,EAAE,eAAe,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAiOF,QAAA,MAAM,YAAY;;;;kFAGhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
|
@@ -77,12 +77,13 @@ function onDragEnd() {
|
|
|
77
77
|
</div>
|
|
78
78
|
</div>
|
|
79
79
|
|
|
80
|
-
<!-- Add button
|
|
80
|
+
<!-- Add button: outlined like MapoMediaField's trigger, so it keeps its
|
|
81
|
+
own surface on a tinted page. -->
|
|
81
82
|
<UButton
|
|
82
83
|
v-if="!readonly && !disabled"
|
|
83
84
|
icon="i-lucide-plus"
|
|
84
85
|
size="sm"
|
|
85
|
-
variant="
|
|
86
|
+
variant="outline"
|
|
86
87
|
color="neutral"
|
|
87
88
|
@click="dialogOpen = true"
|
|
88
89
|
>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapoMediaM2mField.vue.d.ts","sourceRoot":"","sources":["../../../../src/runtime/components/fields/MapoMediaM2mField.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MapoMediaM2mField.vue.d.ts","sourceRoot":"","sources":["../../../../src/runtime/components/fields/MapoMediaM2mField.vue"],"names":[],"mappings":"AAwIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAG1E,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,SAAS,EAAE,GAAG,MAAM,EAAE,GAAG,IAAI,GAAG,SAAS,CAAC;IACtD,UAAU,EAAE,kBAAkB,CAAC;IAC/B,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AA+QF,QAAA,MAAM,YAAY;;;;kFAGhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
|
@@ -3,8 +3,15 @@ import { ref, computed, watchEffect } from "vue";
|
|
|
3
3
|
import { useI18n } from "vue-i18n";
|
|
4
4
|
import { VueDraggable } from "vue-draggable-plus";
|
|
5
5
|
import { useConfirmStore } from "@mapomodule/store/runtime/stores/confirm";
|
|
6
|
+
import {
|
|
7
|
+
normalizeTemplates,
|
|
8
|
+
reachesMax,
|
|
9
|
+
repeaterItemFields,
|
|
10
|
+
shouldUseModalPicker
|
|
11
|
+
} from "../../utils/repeaterTemplates.js";
|
|
6
12
|
import { injectMapoForm } from "../../composables/useMapoForm.js";
|
|
7
13
|
import MapoRepeaterItem from "./MapoRepeaterItem.vue";
|
|
14
|
+
import MapoRepeaterBlockPicker from "./MapoRepeaterBlockPicker.vue";
|
|
8
15
|
const props = defineProps({
|
|
9
16
|
modelValue: { type: null, required: true },
|
|
10
17
|
descriptor: { type: Object, required: true },
|
|
@@ -43,20 +50,47 @@ function undo() {
|
|
|
43
50
|
if (prev) emit("update:modelValue", prev);
|
|
44
51
|
}
|
|
45
52
|
const templates = computed(() => attrs.value.templates);
|
|
46
|
-
const
|
|
47
|
-
() => templates.value
|
|
53
|
+
const templateList = computed(
|
|
54
|
+
() => normalizeTemplates(templates.value, attrs.value.templateImageFit)
|
|
48
55
|
);
|
|
56
|
+
const templateByKey = computed(
|
|
57
|
+
() => new Map(templateList.value.map((tpl) => [tpl.key, tpl]))
|
|
58
|
+
);
|
|
59
|
+
const templateKeys = computed(() => templateList.value.map((tpl) => tpl.key));
|
|
49
60
|
const hasTemplates = computed(() => templateKeys.value.length > 0);
|
|
50
61
|
const selectedTemplate = ref("");
|
|
62
|
+
const useModalPicker = computed(
|
|
63
|
+
() => shouldUseModalPicker(attrs.value.picker, templateKeys.value.length)
|
|
64
|
+
);
|
|
65
|
+
const pickerOpen = ref(false);
|
|
66
|
+
const selectItems = computed(
|
|
67
|
+
() => templateList.value.map((tpl) => ({
|
|
68
|
+
label: tpl.label,
|
|
69
|
+
value: tpl.key,
|
|
70
|
+
description: tpl.description,
|
|
71
|
+
icon: tpl.icon
|
|
72
|
+
}))
|
|
73
|
+
);
|
|
74
|
+
function templateLabelFor(item) {
|
|
75
|
+
const key = item._template;
|
|
76
|
+
if (!key) return void 0;
|
|
77
|
+
return templateByKey.value.get(key)?.label ?? key;
|
|
78
|
+
}
|
|
79
|
+
function templateIconFor(item) {
|
|
80
|
+
return templateByKey.value.get(item._template)?.icon;
|
|
81
|
+
}
|
|
51
82
|
watchEffect(() => {
|
|
52
83
|
if (!selectedTemplate.value && templateKeys.value[0]) {
|
|
53
84
|
selectedTemplate.value = templateKeys.value[0];
|
|
54
85
|
}
|
|
55
86
|
});
|
|
56
87
|
function fieldsForItem(item) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
88
|
+
return repeaterItemFields(
|
|
89
|
+
props.descriptor,
|
|
90
|
+
templateList.value,
|
|
91
|
+
item,
|
|
92
|
+
selectedTemplate.value
|
|
93
|
+
);
|
|
60
94
|
}
|
|
61
95
|
const canAdd = computed(
|
|
62
96
|
() => !props.readonly && (!attrs.value.maxItems || items.value.length < attrs.value.maxItems)
|
|
@@ -79,12 +113,22 @@ async function askConfirm(message, title) {
|
|
|
79
113
|
return typeof globalThis.confirm === "function" ? globalThis.confirm(message) : false;
|
|
80
114
|
}
|
|
81
115
|
}
|
|
82
|
-
function addItem() {
|
|
116
|
+
function addItem(templateKey) {
|
|
83
117
|
if (!canAdd.value) return;
|
|
84
118
|
pushUndo();
|
|
85
|
-
const newItem = hasTemplates.value ? { _template: selectedTemplate.value } : {};
|
|
119
|
+
const newItem = hasTemplates.value ? { _template: templateKey ?? selectedTemplate.value } : {};
|
|
86
120
|
emitItems([...items.value, newItem]);
|
|
87
121
|
}
|
|
122
|
+
function onAddClick() {
|
|
123
|
+
if (useModalPicker.value) pickerOpen.value = true;
|
|
124
|
+
else addItem();
|
|
125
|
+
}
|
|
126
|
+
function onPickTemplate(key, keepOpen) {
|
|
127
|
+
const full = reachesMax(items.value.length, attrs.value.maxItems);
|
|
128
|
+
selectedTemplate.value = key;
|
|
129
|
+
addItem(key);
|
|
130
|
+
if (!keepOpen || full) pickerOpen.value = false;
|
|
131
|
+
}
|
|
88
132
|
async function deleteItem(index) {
|
|
89
133
|
if (!canDelete.value) return;
|
|
90
134
|
if (attrs.value.confirmDelete !== false) {
|
|
@@ -289,27 +333,38 @@ const errorPrefix = (index) => `${props.descriptor.key}.${index}`;
|
|
|
289
333
|
@click="toggleSelectionMode"
|
|
290
334
|
/>
|
|
291
335
|
|
|
292
|
-
<!-- Template selector -->
|
|
336
|
+
<!-- Template selector (dropdown mode; the modal picker opens from "Add") -->
|
|
293
337
|
<USelectMenu
|
|
294
|
-
v-if="hasTemplates"
|
|
338
|
+
v-if="hasTemplates && !useModalPicker"
|
|
295
339
|
v-model="selectedTemplate"
|
|
296
|
-
:items="
|
|
340
|
+
:items="selectItems"
|
|
341
|
+
value-key="value"
|
|
342
|
+
:search-input="templateKeys.length > 6"
|
|
343
|
+
:aria-label="t('mapo.repeater.blockType')"
|
|
297
344
|
size="xs"
|
|
298
|
-
class="w-
|
|
345
|
+
class="w-48"
|
|
299
346
|
/>
|
|
300
347
|
|
|
301
348
|
<UButton
|
|
302
349
|
size="sm"
|
|
303
350
|
color="primary"
|
|
304
|
-
icon="i-lucide-plus"
|
|
351
|
+
:icon="useModalPicker ? 'i-lucide-layout-grid' : 'i-lucide-plus'"
|
|
305
352
|
:disabled="!canAdd"
|
|
306
|
-
@click="
|
|
353
|
+
@click="onAddClick"
|
|
307
354
|
>
|
|
308
|
-
{{ t("mapo.add") }}
|
|
355
|
+
{{ useModalPicker ? t("mapo.repeater.addBlock") : t("mapo.add") }}
|
|
309
356
|
</UButton>
|
|
310
357
|
</div>
|
|
311
358
|
</div>
|
|
312
359
|
|
|
360
|
+
<MapoRepeaterBlockPicker
|
|
361
|
+
v-if="useModalPicker"
|
|
362
|
+
v-model:open="pickerOpen"
|
|
363
|
+
:templates="templateList"
|
|
364
|
+
:disabled="!canAdd"
|
|
365
|
+
@select="onPickTemplate"
|
|
366
|
+
/>
|
|
367
|
+
|
|
313
368
|
<!-- ── Bulk actions bar (visible when there is a selection) ───────────── -->
|
|
314
369
|
<Transition name="slide-down">
|
|
315
370
|
<div
|
|
@@ -384,6 +439,8 @@ const errorPrefix = (index) => `${props.descriptor.key}.${index}`;
|
|
|
384
439
|
<MapoRepeaterItem
|
|
385
440
|
v-for="(item, index) in items"
|
|
386
441
|
:key="`${uidFor(item)}-${collapseVersion}`"
|
|
442
|
+
:template-label="templateLabelFor(item)"
|
|
443
|
+
:template-icon="templateIconFor(item)"
|
|
387
444
|
:uid="uidFor(item)"
|
|
388
445
|
:item="item"
|
|
389
446
|
:fields="fieldsForItem(item)"
|
|
@@ -416,6 +473,8 @@ const errorPrefix = (index) => `${props.descriptor.key}.${index}`;
|
|
|
416
473
|
<MapoRepeaterItem
|
|
417
474
|
v-for="(item, index) in items"
|
|
418
475
|
:key="`${uidFor(item)}-${collapseVersion}`"
|
|
476
|
+
:template-label="templateLabelFor(item)"
|
|
477
|
+
:template-icon="templateIconFor(item)"
|
|
419
478
|
:uid="uidFor(item)"
|
|
420
479
|
:item="item"
|
|
421
480
|
:fields="fieldsForItem(item)"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapoRepeater.vue.d.ts","sourceRoot":"","sources":["../../../../src/runtime/components/fields/MapoRepeater.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MapoRepeater.vue.d.ts","sourceRoot":"","sources":["../../../../src/runtime/components/fields/MapoRepeater.vue"],"names":[],"mappings":"AA2nBA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAW/D,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,kBAAkB,CAAC;IAC/B,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AA0oCF,QAAA,MAAM,YAAY;;;;kFAGhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|