@ramathibodi/nuxt-commons 4.0.26 → 4.0.27
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/module.json +1 -1
- package/dist/runtime/components/document/TemplateBuilderLiveView.d.vue.ts +28 -15
- package/dist/runtime/components/document/TemplateBuilderLiveView.vue +175 -68
- package/dist/runtime/components/document/TemplateBuilderLiveView.vue.d.ts +28 -15
- package/dist/runtime/components/document/TemplatePalette.d.vue.ts +1 -1
- package/dist/runtime/components/document/TemplatePalette.vue.d.ts +1 -1
- package/dist/runtime/components/form/DateTime.d.vue.ts +1 -1
- package/dist/runtime/components/form/DateTime.vue.d.ts +1 -1
- package/dist/runtime/components/form/Pad.d.vue.ts +1 -1
- package/dist/runtime/components/form/Pad.vue.d.ts +1 -1
- package/dist/runtime/components/label/Date.d.vue.ts +1 -1
- package/dist/runtime/components/label/Date.vue.d.ts +1 -1
- package/dist/runtime/composables/document/template.d.ts +9 -1
- package/dist/runtime/composables/document/template.js +12 -3
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -17,6 +17,7 @@ interface Props {
|
|
|
17
17
|
sortable?: boolean;
|
|
18
18
|
palette?: boolean;
|
|
19
19
|
paletteTypes?: string[];
|
|
20
|
+
height?: number | string;
|
|
20
21
|
}
|
|
21
22
|
/**
|
|
22
23
|
* Public props accepted by DocumentTemplateBuilderLiveView.
|
|
@@ -30,9 +31,15 @@ interface Props {
|
|
|
30
31
|
* - **Preview** — the preview is a live, fillable form so you can try the
|
|
31
32
|
* validations; the data typed is shown in the "Preview data" panel.
|
|
32
33
|
*
|
|
33
|
-
* Items with no visual (`FormHidden`, `Separator`)
|
|
34
|
-
*
|
|
35
|
-
*
|
|
34
|
+
* Items with no visual (`FormHidden`, `Separator`) get a placeholder in Design
|
|
35
|
+
* mode (hidden in Preview mode), so they can be selected, moved and deleted
|
|
36
|
+
* like any field. They are also reachable from the **Outline** list (a click
|
|
37
|
+
* opens the editor dialog), which offers reordering and deletion for every item.
|
|
38
|
+
*
|
|
39
|
+
* Both the overlay and the outline carry a **move to position** button between
|
|
40
|
+
* their up / down arrows (DocumentTemplateBuilder's "Enter the new position"):
|
|
41
|
+
* it opens a small menu that takes the new 1-based position (the numbering the
|
|
42
|
+
* outline and the overlay show) and moves the item there on Move / Enter.
|
|
36
43
|
*
|
|
37
44
|
* In Design mode every rendered field is also a drag handle: drop it on the
|
|
38
45
|
* left / top half of another field to insert before it, on the right / bottom
|
|
@@ -44,6 +51,11 @@ interface Props {
|
|
|
44
51
|
* the preview appends), or click a card to add one after the selected item.
|
|
45
52
|
* The new item's settings dialog opens at once; cancelling it removes the
|
|
46
53
|
* item again, saving keeps it.
|
|
54
|
+
*
|
|
55
|
+
* With `height` set the card has a fixed height: the toolbar and the live
|
|
56
|
+
* view bar stay put and only the form (plus the outline and the palette,
|
|
57
|
+
* each on its own from `md` up) scrolls. Use it inside dialogs, where the
|
|
58
|
+
* natural height would scroll the toolbar out of reach.
|
|
47
59
|
*/
|
|
48
60
|
type __VLS_Props = Props;
|
|
49
61
|
/** Select (highlight + pin the edit overlay on) the item at `index`, or clear the selection with `null`. */
|
|
@@ -105,7 +117,7 @@ declare var __VLS_19: {}, __VLS_27: {
|
|
|
105
117
|
importItems: typeof importItems;
|
|
106
118
|
convertToAdvanceMode: () => Promise<void>;
|
|
107
119
|
};
|
|
108
|
-
},
|
|
120
|
+
}, __VLS_217: {
|
|
109
121
|
operation: {
|
|
110
122
|
openCreate: typeof openCreate;
|
|
111
123
|
openEdit: typeof openEdit;
|
|
@@ -121,7 +133,7 @@ declare var __VLS_19: {}, __VLS_27: {
|
|
|
121
133
|
importItems: typeof importItems;
|
|
122
134
|
convertToAdvanceMode: () => Promise<void>;
|
|
123
135
|
};
|
|
124
|
-
},
|
|
136
|
+
}, __VLS_238: {
|
|
125
137
|
index: number;
|
|
126
138
|
item: Record<string, any>;
|
|
127
139
|
operation: {
|
|
@@ -139,7 +151,7 @@ declare var __VLS_19: {}, __VLS_27: {
|
|
|
139
151
|
importItems: typeof importItems;
|
|
140
152
|
convertToAdvanceMode: () => Promise<void>;
|
|
141
153
|
};
|
|
142
|
-
},
|
|
154
|
+
}, __VLS_312: {
|
|
143
155
|
insert: typeof insertInputType;
|
|
144
156
|
disabled: boolean;
|
|
145
157
|
};
|
|
@@ -148,11 +160,11 @@ type __VLS_Slots = {} & {
|
|
|
148
160
|
} & {
|
|
149
161
|
toolbarItems?: (props: typeof __VLS_27) => any;
|
|
150
162
|
} & {
|
|
151
|
-
empty?: (props: typeof
|
|
163
|
+
empty?: (props: typeof __VLS_217) => any;
|
|
152
164
|
} & {
|
|
153
|
-
itemOverlay?: (props: typeof
|
|
165
|
+
itemOverlay?: (props: typeof __VLS_238) => any;
|
|
154
166
|
} & {
|
|
155
|
-
palette?: (props: typeof
|
|
167
|
+
palette?: (props: typeof __VLS_312) => any;
|
|
156
168
|
};
|
|
157
169
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
158
170
|
templateItems: import("vue").Ref<Record<string, any>[], Record<string, any>[]>;
|
|
@@ -216,20 +228,21 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
|
216
228
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
217
229
|
"onUpdate:modelValue"?: ((value: string | Record<string, any>[] | undefined) => any) | undefined;
|
|
218
230
|
}>, {
|
|
231
|
+
height: string | number;
|
|
219
232
|
title: string;
|
|
220
233
|
stringFields: string[];
|
|
221
234
|
initialData: Record<string, any>;
|
|
222
|
-
dialogFullscreen: boolean;
|
|
223
|
-
toolbarColor: string;
|
|
224
|
-
importable: boolean;
|
|
225
|
-
exportable: boolean;
|
|
226
|
-
sortable: boolean;
|
|
227
|
-
dialogMaxWidth: string | number;
|
|
228
235
|
roleCustomCode: string | string[];
|
|
229
236
|
disableAdvanceMode: boolean;
|
|
237
|
+
toolbarColor: string;
|
|
230
238
|
editorWidth: string | number;
|
|
239
|
+
dialogMaxWidth: string | number;
|
|
240
|
+
dialogFullscreen: boolean;
|
|
231
241
|
outline: boolean;
|
|
242
|
+
importable: boolean;
|
|
243
|
+
exportable: boolean;
|
|
232
244
|
importMode: DocumentTemplateImportMode;
|
|
245
|
+
sortable: boolean;
|
|
233
246
|
palette: boolean;
|
|
234
247
|
paletteTypes: string[];
|
|
235
248
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -25,7 +25,8 @@ const props = defineProps({
|
|
|
25
25
|
stringFields: { type: Array, required: false, default: () => [] },
|
|
26
26
|
sortable: { type: Boolean, required: false, default: true },
|
|
27
27
|
palette: { type: Boolean, required: false, default: true },
|
|
28
|
-
paletteTypes: { type: Array, required: false, default: void 0 }
|
|
28
|
+
paletteTypes: { type: Array, required: false, default: void 0 },
|
|
29
|
+
height: { type: [Number, String], required: false, default: void 0 }
|
|
29
30
|
});
|
|
30
31
|
const emit = defineEmits(["update:modelValue", "select", "import", "reorder", "insert"]);
|
|
31
32
|
const modelValue = defineModel({ type: [String, Array] });
|
|
@@ -33,6 +34,7 @@ const { templateItems, isAdvanceMode, advanceModeCode, storedItems, convertToAdv
|
|
|
33
34
|
const ITEM_INDEX_ATTRIBUTE = "data-doc-item";
|
|
34
35
|
const mode = ref("design");
|
|
35
36
|
const isDesignMode = computed(() => mode.value === "design" && !isAdvanceMode.value);
|
|
37
|
+
const isBounded = computed(() => props.height !== void 0 && props.height !== null && props.height !== "");
|
|
36
38
|
const outlineOpen = ref(props.outline);
|
|
37
39
|
const paletteOpen = ref(props.palette);
|
|
38
40
|
const selectedIndex = ref(null);
|
|
@@ -47,7 +49,7 @@ const showPreviewData = ref();
|
|
|
47
49
|
const previewTemplate = computed(() => {
|
|
48
50
|
if (isAdvanceMode.value) return advanceModeCode.value || "";
|
|
49
51
|
if (!storedItems.value.length) return "";
|
|
50
|
-
return useDocumentTemplate(storedItems.value, void 0, { itemIndexAttribute: ITEM_INDEX_ATTRIBUTE });
|
|
52
|
+
return useDocumentTemplate(storedItems.value, void 0, { itemIndexAttribute: ITEM_INDEX_ATTRIBUTE, noVisualPlaceholders: true });
|
|
51
53
|
});
|
|
52
54
|
const inputTypeLabel = computed(() => {
|
|
53
55
|
const acc = {};
|
|
@@ -169,6 +171,38 @@ function moveSelected(delta) {
|
|
|
169
171
|
function moveItem(from, delta) {
|
|
170
172
|
moveItemTo(from, from + delta);
|
|
171
173
|
}
|
|
174
|
+
const moveTo = ref(null);
|
|
175
|
+
const moveToPosition = ref("");
|
|
176
|
+
function openMoveTo(index, event) {
|
|
177
|
+
if (!Number.isInteger(index) || index < 0 || index >= templateItems.value.length) return;
|
|
178
|
+
selectItem(index);
|
|
179
|
+
moveToPosition.value = "";
|
|
180
|
+
moveTo.value = { index, target: event?.currentTarget ?? void 0 };
|
|
181
|
+
}
|
|
182
|
+
function closeMoveTo() {
|
|
183
|
+
moveTo.value = null;
|
|
184
|
+
}
|
|
185
|
+
const moveToIndex = computed(() => {
|
|
186
|
+
if (!moveTo.value) return null;
|
|
187
|
+
const raw = String(moveToPosition.value ?? "").trim();
|
|
188
|
+
if (!/^\d+$/.test(raw)) return null;
|
|
189
|
+
const position = Number(raw);
|
|
190
|
+
if (position < 1 || position > templateItems.value.length || position - 1 === moveTo.value.index) return null;
|
|
191
|
+
return position - 1;
|
|
192
|
+
});
|
|
193
|
+
const moveToError = computed(() => {
|
|
194
|
+
const raw = String(moveToPosition.value ?? "").trim();
|
|
195
|
+
if (!moveTo.value || !raw || moveToIndex.value !== null) return void 0;
|
|
196
|
+
return raw === String(moveTo.value.index + 1) ? `Item ${raw} is already at position ${raw}` : `Enter a number from 1 to ${templateItems.value.length}`;
|
|
197
|
+
});
|
|
198
|
+
function submitMoveTo() {
|
|
199
|
+
const to = moveToIndex.value;
|
|
200
|
+
if (!moveTo.value || to === null) return;
|
|
201
|
+
const from = moveTo.value.index;
|
|
202
|
+
closeMoveTo();
|
|
203
|
+
moveItemTo(from, to);
|
|
204
|
+
}
|
|
205
|
+
watch(() => templateItems.value.length, closeMoveTo);
|
|
172
206
|
function duplicateItem(index) {
|
|
173
207
|
const source = templateItems.value[index];
|
|
174
208
|
if (!source) return;
|
|
@@ -279,10 +313,17 @@ function updateOverlay() {
|
|
|
279
313
|
const origin = canvas.getBoundingClientRect();
|
|
280
314
|
overlayRect.value = { top: box.top - origin.top, left: box.left - origin.left, width: box.width, height: box.height };
|
|
281
315
|
}
|
|
316
|
+
const OVERLAY_INSET = 4;
|
|
317
|
+
const overlayRoot = ref();
|
|
318
|
+
const overlayWidth = ref(0);
|
|
319
|
+
function measureOverlay() {
|
|
320
|
+
overlayWidth.value = overlayRoot.value?.offsetWidth || 0;
|
|
321
|
+
}
|
|
282
322
|
const overlayStyle = computed(() => {
|
|
283
323
|
const rect = overlayRect.value;
|
|
284
324
|
if (!rect) return {};
|
|
285
|
-
|
|
325
|
+
const left = Math.max(0, rect.left + rect.width - OVERLAY_INSET - overlayWidth.value);
|
|
326
|
+
return { top: `${rect.top}px`, left: `${left}px` };
|
|
286
327
|
});
|
|
287
328
|
const DRAGGING_CLASS = "doc-live-view__item--dragging";
|
|
288
329
|
const DROP_CLASSES = {
|
|
@@ -422,6 +463,8 @@ watch(isDesignMode, (design) => {
|
|
|
422
463
|
if (!design) hoveredIndex.value = null;
|
|
423
464
|
});
|
|
424
465
|
useResizeObserver(previewRoot, () => updateOverlay());
|
|
466
|
+
useResizeObserver(overlayRoot, measureOverlay);
|
|
467
|
+
watch([overlayRect, overlayIndex], measureOverlay, { flush: "post" });
|
|
425
468
|
useEventListener(typeof window === "undefined" ? void 0 : window, "resize", () => updateOverlay());
|
|
426
469
|
watch(isAdvanceMode, (advance) => {
|
|
427
470
|
if (!advance) return;
|
|
@@ -448,7 +491,11 @@ defineExpose({
|
|
|
448
491
|
</script>
|
|
449
492
|
|
|
450
493
|
<template>
|
|
451
|
-
<v-card
|
|
494
|
+
<v-card
|
|
495
|
+
class="doc-live-view"
|
|
496
|
+
:class="{ 'doc-live-view--bounded': isBounded }"
|
|
497
|
+
:height="isBounded ? height : void 0"
|
|
498
|
+
>
|
|
452
499
|
<v-toolbar :color="toolbarColor">
|
|
453
500
|
<v-toolbar-title class="pl-3">
|
|
454
501
|
<slot name="title">{{ title }}</slot>
|
|
@@ -536,8 +583,19 @@ defineExpose({
|
|
|
536
583
|
{{ itemTypeLabel(item) }}<span v-if="hasNoVisual(item)"> · not rendered</span>
|
|
537
584
|
</v-list-item-subtitle>
|
|
538
585
|
<template #append>
|
|
539
|
-
<v-btn icon="mdi:mdi-arrow-up-thick" size="x-small" variant="text" density="comfortable" :disabled="index === 0" @click.stop="moveItem(index, -1)" />
|
|
540
|
-
<v-btn
|
|
586
|
+
<v-btn icon="mdi:mdi-arrow-up-thick" size="x-small" variant="text" density="comfortable" title="Move up" :disabled="index === 0" @click.stop="moveItem(index, -1)" />
|
|
587
|
+
<v-btn
|
|
588
|
+
class="doc-live-view__outline-move-to"
|
|
589
|
+
icon="fa:fas fa-arrow-right-to-bracket"
|
|
590
|
+
size="x-small"
|
|
591
|
+
variant="text"
|
|
592
|
+
density="comfortable"
|
|
593
|
+
title="Move to position…"
|
|
594
|
+
:disabled="templateItems.length < 2"
|
|
595
|
+
@click.stop="openMoveTo(index, $event)"
|
|
596
|
+
/>
|
|
597
|
+
<v-btn icon="mdi:mdi-arrow-down-thick" size="x-small" variant="text" density="comfortable" title="Move down" :disabled="index === templateItems.length - 1" @click.stop="moveItem(index, 1)" />
|
|
598
|
+
<v-btn class="doc-live-view__outline-delete" icon="mdi:mdi-delete" size="x-small" variant="text" density="comfortable" color="error" title="Delete" @click.stop="confirmDeleteItem(index)" />
|
|
541
599
|
</template>
|
|
542
600
|
</v-list-item>
|
|
543
601
|
<v-list-item v-if="!templateItems.length">
|
|
@@ -547,7 +605,7 @@ defineExpose({
|
|
|
547
605
|
</v-col>
|
|
548
606
|
|
|
549
607
|
<!-- Live view: full row when the outline / editor stack below md, flexible remainder from md up -->
|
|
550
|
-
<v-col cols="12" md class="doc-live-view__preview-col">
|
|
608
|
+
<v-col cols="12" md class="doc-live-view__preview-col" :class="{ 'doc-live-view__preview-col--live': !isAdvanceMode }">
|
|
551
609
|
<template v-if="isAdvanceMode">
|
|
552
610
|
<v-row no-gutters>
|
|
553
611
|
<v-col cols="12" md="6" class="pa-2">
|
|
@@ -604,68 +662,82 @@ defineExpose({
|
|
|
604
662
|
{{ templateItems.length }} {{ templateItems.length === 1 ? "field" : "fields" }}
|
|
605
663
|
</span>
|
|
606
664
|
</div>
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
<
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
665
|
+
<!-- Bounded height: only this part scrolls; the live view bar above stays put. -->
|
|
666
|
+
<div class="doc-live-view__scroll">
|
|
667
|
+
<div ref="canvasRoot" class="doc-live-view__canvas" @mouseleave="hoveredIndex = null">
|
|
668
|
+
<div
|
|
669
|
+
ref="previewRoot"
|
|
670
|
+
class="doc-live-view__preview px-2 pb-2"
|
|
671
|
+
:class="{ 'doc-live-view__preview--design': isDesignMode, 'doc-live-view__preview--sortable': canSort, 'doc-live-view__preview--dragging': dragIndex !== null, 'doc-live-view__preview--drop-end': dropAtEnd }"
|
|
672
|
+
@click.capture="onPreviewClick"
|
|
673
|
+
@dblclick.capture="onPreviewDblClick"
|
|
674
|
+
@mouseover="onPreviewHover"
|
|
675
|
+
@dragstart="onPreviewDragStart"
|
|
676
|
+
@dragover="onPreviewDragOver"
|
|
677
|
+
@dragleave="onPreviewDragLeave"
|
|
678
|
+
@drop="onPreviewDrop"
|
|
679
|
+
@dragend="finishDrag"
|
|
680
|
+
>
|
|
681
|
+
<slot name="empty" v-if="!templateItems.length" :operation="operation">
|
|
682
|
+
<v-sheet
|
|
683
|
+
class="d-flex flex-column align-center justify-center text-medium-emphasis pa-8 ma-2"
|
|
684
|
+
border
|
|
685
|
+
rounded
|
|
686
|
+
style="border-style: dashed !important; cursor: pointer"
|
|
687
|
+
@click="openCreate()"
|
|
688
|
+
>
|
|
689
|
+
<v-icon size="40" class="mb-2">mdi:mdi-plus-box-outline</v-icon>
|
|
690
|
+
<div class="text-body-2">No fields yet. Click <b>add</b> to create the first one.</div>
|
|
691
|
+
</v-sheet>
|
|
692
|
+
</slot>
|
|
693
|
+
<form-pad
|
|
694
|
+
v-else
|
|
695
|
+
v-model="previewData"
|
|
696
|
+
:template="previewTemplate"
|
|
697
|
+
:template-script="templateScript"
|
|
698
|
+
isolated
|
|
699
|
+
/>
|
|
700
|
+
</div>
|
|
701
|
+
<!-- Edit overlay: pinned to the hovered item, else the selected one -->
|
|
702
|
+
<div
|
|
703
|
+
v-if="overlayIndex !== null && overlayRect"
|
|
704
|
+
ref="overlayRoot"
|
|
705
|
+
class="doc-live-view__overlay"
|
|
706
|
+
:style="overlayStyle"
|
|
707
|
+
role="toolbar"
|
|
708
|
+
:aria-label="`Item ${overlayIndex + 1} actions`"
|
|
709
|
+
@click.stop
|
|
710
|
+
@dblclick.stop
|
|
711
|
+
>
|
|
712
|
+
<slot name="itemOverlay" :index="overlayIndex" :item="templateItems[overlayIndex]" :operation="operation">
|
|
713
|
+
<span class="doc-live-view__overlay-label text-caption">{{ overlayIndex + 1 }} · {{ itemTypeLabel(templateItems[overlayIndex]) }}</span>
|
|
714
|
+
<v-btn class="doc-live-view__overlay-edit" icon="mdi:mdi-pencil" size="x-small" variant="flat" color="primary" density="comfortable" title="Edit" @click="openEdit(overlayIndex)" />
|
|
715
|
+
<v-btn icon="mdi:mdi-arrow-up-thick" size="x-small" variant="text" density="comfortable" title="Move up" :disabled="overlayIndex === 0" @click="moveItem(overlayIndex, -1)" />
|
|
716
|
+
<v-btn
|
|
717
|
+
class="doc-live-view__overlay-move-to"
|
|
718
|
+
icon="fa:fas fa-arrow-right-to-bracket"
|
|
719
|
+
size="x-small"
|
|
720
|
+
variant="text"
|
|
721
|
+
density="comfortable"
|
|
722
|
+
title="Move to position…"
|
|
723
|
+
:disabled="templateItems.length < 2"
|
|
724
|
+
@click="openMoveTo(overlayIndex, $event)"
|
|
725
|
+
/>
|
|
726
|
+
<v-btn icon="mdi:mdi-arrow-down-thick" size="x-small" variant="text" density="comfortable" title="Move down" :disabled="overlayIndex === templateItems.length - 1" @click="moveItem(overlayIndex, 1)" />
|
|
727
|
+
<v-btn icon="mdi:mdi-content-copy" size="x-small" variant="text" density="comfortable" title="Duplicate" @click="duplicateItem(overlayIndex)" />
|
|
728
|
+
<v-btn class="doc-live-view__overlay-delete" icon="mdi:mdi-delete" size="x-small" variant="text" density="comfortable" color="error" title="Delete" @click="confirmDeleteItem(overlayIndex)" />
|
|
729
|
+
</slot>
|
|
730
|
+
</div>
|
|
659
731
|
</div>
|
|
732
|
+
<v-expansion-panels v-model="showPreviewData" variant="accordion" class="px-2 pb-2" v-if="mode === 'preview' && templateItems.length">
|
|
733
|
+
<v-expansion-panel :value="true">
|
|
734
|
+
<v-expansion-panel-title class="text-caption">Preview data</v-expansion-panel-title>
|
|
735
|
+
<v-expansion-panel-text>
|
|
736
|
+
<pre class="text-caption ma-0">{{ previewData }}</pre>
|
|
737
|
+
</v-expansion-panel-text>
|
|
738
|
+
</v-expansion-panel>
|
|
739
|
+
</v-expansion-panels>
|
|
660
740
|
</div>
|
|
661
|
-
<v-expansion-panels v-model="showPreviewData" variant="accordion" class="px-2 pb-2" v-if="mode === 'preview' && templateItems.length">
|
|
662
|
-
<v-expansion-panel :value="true">
|
|
663
|
-
<v-expansion-panel-title class="text-caption">Preview data</v-expansion-panel-title>
|
|
664
|
-
<v-expansion-panel-text>
|
|
665
|
-
<pre class="text-caption ma-0">{{ previewData }}</pre>
|
|
666
|
-
</v-expansion-panel-text>
|
|
667
|
-
</v-expansion-panel>
|
|
668
|
-
</v-expansion-panels>
|
|
669
741
|
</template>
|
|
670
742
|
</v-col>
|
|
671
743
|
|
|
@@ -678,6 +750,41 @@ defineExpose({
|
|
|
678
750
|
|
|
679
751
|
</v-row>
|
|
680
752
|
|
|
753
|
+
<!-- Move to position: one menu, hung from whichever overlay / outline button opened it -->
|
|
754
|
+
<v-menu
|
|
755
|
+
:model-value="moveTo !== null"
|
|
756
|
+
:target="moveTo?.target"
|
|
757
|
+
location="bottom end"
|
|
758
|
+
:close-on-content-click="false"
|
|
759
|
+
@update:model-value="(open) => {
|
|
760
|
+
if (!open) closeMoveTo();
|
|
761
|
+
}"
|
|
762
|
+
>
|
|
763
|
+
<v-card v-if="moveTo" class="doc-live-view__move-to" min-width="260">
|
|
764
|
+
<v-card-text class="pb-0">
|
|
765
|
+
<div class="text-body-2 mb-3">Move item {{ moveTo.index + 1 }} to position</div>
|
|
766
|
+
<v-text-field
|
|
767
|
+
v-model="moveToPosition"
|
|
768
|
+
type="number"
|
|
769
|
+
min="1"
|
|
770
|
+
:max="templateItems.length"
|
|
771
|
+
density="compact"
|
|
772
|
+
variant="outlined"
|
|
773
|
+
autofocus
|
|
774
|
+
persistent-hint
|
|
775
|
+
:hint="`1 \u2013 ${templateItems.length}`"
|
|
776
|
+
:error-messages="moveToError"
|
|
777
|
+
@keydown.enter.prevent="submitMoveTo()"
|
|
778
|
+
/>
|
|
779
|
+
</v-card-text>
|
|
780
|
+
<v-card-actions>
|
|
781
|
+
<v-spacer />
|
|
782
|
+
<v-btn variant="text" @click="closeMoveTo()">Cancel</v-btn>
|
|
783
|
+
<v-btn class="doc-live-view__move-to-submit" color="primary" variant="flat" :disabled="moveToIndex === null" @click="submitMoveTo()">Move</v-btn>
|
|
784
|
+
</v-card-actions>
|
|
785
|
+
</v-card>
|
|
786
|
+
</v-menu>
|
|
787
|
+
|
|
681
788
|
<!-- Item editor dialog: opens on a new item straight away, and from an item's edit overlay -->
|
|
682
789
|
<FormDialog
|
|
683
790
|
v-model="dialogOpen"
|
|
@@ -726,5 +833,5 @@ defineExpose({
|
|
|
726
833
|
</template>
|
|
727
834
|
|
|
728
835
|
<style scoped>
|
|
729
|
-
.doc-live-view__outline{border-right:thin solid rgba(var(--v-border-color),var(--v-border-opacity))}.doc-live-view__palette{border-left:thin solid rgba(var(--v-border-color),var(--v-border-opacity))}.doc-live-view__canvas{position:relative}.doc-live-view__overlay{align-items:center;background:rgb(var(--v-theme-surface));border-radius:999px;box-shadow:0 1px 3px rgba(0,0,0,.18),0 0 0 1px rgba(var(--v-theme-primary),.35);display:inline-flex;gap:2px;padding:2px 4px 2px 8px;position:absolute;transform:
|
|
836
|
+
.doc-live-view__outline{border-right:thin solid rgba(var(--v-border-color),var(--v-border-opacity))}.doc-live-view__palette{border-left:thin solid rgba(var(--v-border-color),var(--v-border-opacity))}.doc-live-view__canvas{position:relative}.doc-live-view__overlay{align-items:center;background:rgb(var(--v-theme-surface));border-radius:999px;box-shadow:0 1px 3px rgba(0,0,0,.18),0 0 0 1px rgba(var(--v-theme-primary),.35);display:inline-flex;gap:2px;padding:2px 4px 2px 8px;position:absolute;transform:translateY(-50%);white-space:nowrap;z-index:2}.doc-live-view__overlay-label{color:rgba(var(--v-theme-on-surface),var(--v-medium-emphasis-opacity));margin-right:4px;max-width:14em;overflow:hidden;text-overflow:ellipsis}.doc-live-view__preview--drop-end{background-color:rgba(var(--v-theme-primary),.03);border-radius:4px;outline:2px dashed rgba(var(--v-theme-primary),.7);outline-offset:-4px}.doc-live-view__preview-col{min-width:0}.doc-live-view__preview-bar{align-items:center;border-bottom:thin solid rgba(var(--v-border-color),var(--v-border-opacity));display:flex;gap:12px;min-height:44px;padding:4px 12px}.doc-live-view__bar-label{color:rgba(var(--v-theme-on-surface),var(--v-medium-emphasis-opacity));flex-shrink:0;letter-spacing:.12em;line-height:1}.doc-live-view__hint{min-width:0}.doc-live-view__count{font-variant-numeric:tabular-nums}.doc-live-view__mode-toggle{background:rgba(var(--v-theme-on-surface),.06);border-radius:999px;display:inline-flex;flex-shrink:0;gap:2px;padding:3px}.doc-live-view__mode{align-items:center;background:transparent;border:0;border-radius:999px;color:rgba(var(--v-theme-on-surface),var(--v-medium-emphasis-opacity));cursor:pointer;display:inline-flex;font:inherit;font-size:.8125rem;font-weight:500;gap:6px;height:28px;line-height:1;padding:0 12px 0 10px;transition:background-color .18s ease,color .18s ease,box-shadow .18s ease}.doc-live-view__mode:hover{color:rgba(var(--v-theme-on-surface),var(--v-high-emphasis-opacity))}.doc-live-view__mode:focus-visible{outline:2px solid rgba(var(--v-theme-primary),.5);outline-offset:1px}.doc-live-view__mode--active{background:rgb(var(--v-theme-surface));box-shadow:0 1px 2px rgba(0,0,0,.14),0 0 0 1px rgba(var(--v-theme-on-surface),.06);color:rgb(var(--v-theme-primary))}.doc-live-view__preview{padding-top:8px;transition:background-color .22s ease}.doc-live-view__preview--design{background-color:rgba(var(--v-theme-on-surface),.015);background-image:radial-gradient(rgba(var(--v-theme-on-surface),.14) 1px,transparent 1px);background-position:8px 8px;background-size:16px 16px}.doc-live-view__preview--design :deep([data-doc-item]){border-radius:4px;cursor:pointer;outline:1px dashed transparent;outline-offset:2px;transition:outline-color .12s ease,background-color .12s ease}.doc-live-view__preview--design :deep([data-doc-item]>*){pointer-events:none}.doc-live-view__preview--design :deep([data-doc-item]:hover){background-color:rgba(var(--v-theme-primary),.04);outline-color:rgba(var(--v-theme-primary),.6)}.doc-live-view__preview:not(.doc-live-view__preview--design) :deep([data-doc-placeholder]){display:none}.doc-live-view__preview :deep(.doc-template-placeholder){border:1px dashed rgba(var(--v-theme-on-surface),.3);border-radius:4px;color:rgba(var(--v-theme-on-surface),var(--v-medium-emphasis-opacity));font-size:.75rem;line-height:1.4;padding:2px 8px;white-space:nowrap}.doc-live-view__preview :deep([data-doc-placeholder=Separator] .doc-template-placeholder){align-items:center;border:none;display:flex;gap:8px;padding:0}.doc-live-view__preview :deep([data-doc-placeholder=Separator] .doc-template-placeholder):after,.doc-live-view__preview :deep([data-doc-placeholder=Separator] .doc-template-placeholder):before{border-top:1px dashed rgba(var(--v-theme-on-surface),.3);content:"";flex:1}.doc-live-view__preview :deep([data-doc-item].doc-live-view__item--selected){background-color:rgba(var(--v-theme-primary),.06);border-radius:4px;outline:2px solid rgb(var(--v-theme-primary));outline-offset:2px}.doc-live-view__preview--sortable :deep([data-doc-item]){cursor:grab}.doc-live-view__preview--dragging :deep([data-doc-item]){cursor:grabbing}.doc-live-view__preview :deep([data-doc-item].doc-live-view__item--dragging){opacity:.4}.doc-live-view__preview :deep([data-doc-item].doc-live-view__item--drop-before){box-shadow:-4px 0 0 0 rgb(var(--v-theme-primary))}.doc-live-view__preview :deep([data-doc-item].doc-live-view__item--drop-after){box-shadow:4px 0 0 0 rgb(var(--v-theme-primary))}.doc-live-view__preview :deep([data-doc-item].doc-live-view__item--drop-above){box-shadow:0 -4px 0 0 rgb(var(--v-theme-primary))}.doc-live-view__preview :deep([data-doc-item].doc-live-view__item--drop-below){box-shadow:0 4px 0 0 rgb(var(--v-theme-primary))}.doc-live-view--bounded{display:flex;flex-direction:column}.doc-live-view--bounded>.v-toolbar{flex:0 0 auto}.doc-live-view--bounded .doc-live-view__body{flex:1 1 auto;min-height:0;overflow-y:auto}@media (min-width:840px){.doc-live-view--bounded .doc-live-view__body{flex-wrap:nowrap;overflow:hidden}.doc-live-view--bounded .doc-live-view__outline,.doc-live-view--bounded .doc-live-view__palette,.doc-live-view--bounded .doc-live-view__preview-col{height:100%;overflow-y:auto}.doc-live-view--bounded .doc-live-view__preview-col--live{display:flex;flex-direction:column;overflow:hidden}.doc-live-view--bounded .doc-live-view__scroll{flex:1 1 auto;min-height:0;overflow-y:auto}.doc-live-view--bounded .doc-live-view__palette :deep(.doc-palette__body){max-height:none;overflow:visible}}
|
|
730
837
|
</style>
|
|
@@ -17,6 +17,7 @@ interface Props {
|
|
|
17
17
|
sortable?: boolean;
|
|
18
18
|
palette?: boolean;
|
|
19
19
|
paletteTypes?: string[];
|
|
20
|
+
height?: number | string;
|
|
20
21
|
}
|
|
21
22
|
/**
|
|
22
23
|
* Public props accepted by DocumentTemplateBuilderLiveView.
|
|
@@ -30,9 +31,15 @@ interface Props {
|
|
|
30
31
|
* - **Preview** — the preview is a live, fillable form so you can try the
|
|
31
32
|
* validations; the data typed is shown in the "Preview data" panel.
|
|
32
33
|
*
|
|
33
|
-
* Items with no visual (`FormHidden`, `Separator`)
|
|
34
|
-
*
|
|
35
|
-
*
|
|
34
|
+
* Items with no visual (`FormHidden`, `Separator`) get a placeholder in Design
|
|
35
|
+
* mode (hidden in Preview mode), so they can be selected, moved and deleted
|
|
36
|
+
* like any field. They are also reachable from the **Outline** list (a click
|
|
37
|
+
* opens the editor dialog), which offers reordering and deletion for every item.
|
|
38
|
+
*
|
|
39
|
+
* Both the overlay and the outline carry a **move to position** button between
|
|
40
|
+
* their up / down arrows (DocumentTemplateBuilder's "Enter the new position"):
|
|
41
|
+
* it opens a small menu that takes the new 1-based position (the numbering the
|
|
42
|
+
* outline and the overlay show) and moves the item there on Move / Enter.
|
|
36
43
|
*
|
|
37
44
|
* In Design mode every rendered field is also a drag handle: drop it on the
|
|
38
45
|
* left / top half of another field to insert before it, on the right / bottom
|
|
@@ -44,6 +51,11 @@ interface Props {
|
|
|
44
51
|
* the preview appends), or click a card to add one after the selected item.
|
|
45
52
|
* The new item's settings dialog opens at once; cancelling it removes the
|
|
46
53
|
* item again, saving keeps it.
|
|
54
|
+
*
|
|
55
|
+
* With `height` set the card has a fixed height: the toolbar and the live
|
|
56
|
+
* view bar stay put and only the form (plus the outline and the palette,
|
|
57
|
+
* each on its own from `md` up) scrolls. Use it inside dialogs, where the
|
|
58
|
+
* natural height would scroll the toolbar out of reach.
|
|
47
59
|
*/
|
|
48
60
|
type __VLS_Props = Props;
|
|
49
61
|
/** Select (highlight + pin the edit overlay on) the item at `index`, or clear the selection with `null`. */
|
|
@@ -105,7 +117,7 @@ declare var __VLS_19: {}, __VLS_27: {
|
|
|
105
117
|
importItems: typeof importItems;
|
|
106
118
|
convertToAdvanceMode: () => Promise<void>;
|
|
107
119
|
};
|
|
108
|
-
},
|
|
120
|
+
}, __VLS_217: {
|
|
109
121
|
operation: {
|
|
110
122
|
openCreate: typeof openCreate;
|
|
111
123
|
openEdit: typeof openEdit;
|
|
@@ -121,7 +133,7 @@ declare var __VLS_19: {}, __VLS_27: {
|
|
|
121
133
|
importItems: typeof importItems;
|
|
122
134
|
convertToAdvanceMode: () => Promise<void>;
|
|
123
135
|
};
|
|
124
|
-
},
|
|
136
|
+
}, __VLS_238: {
|
|
125
137
|
index: number;
|
|
126
138
|
item: Record<string, any>;
|
|
127
139
|
operation: {
|
|
@@ -139,7 +151,7 @@ declare var __VLS_19: {}, __VLS_27: {
|
|
|
139
151
|
importItems: typeof importItems;
|
|
140
152
|
convertToAdvanceMode: () => Promise<void>;
|
|
141
153
|
};
|
|
142
|
-
},
|
|
154
|
+
}, __VLS_312: {
|
|
143
155
|
insert: typeof insertInputType;
|
|
144
156
|
disabled: boolean;
|
|
145
157
|
};
|
|
@@ -148,11 +160,11 @@ type __VLS_Slots = {} & {
|
|
|
148
160
|
} & {
|
|
149
161
|
toolbarItems?: (props: typeof __VLS_27) => any;
|
|
150
162
|
} & {
|
|
151
|
-
empty?: (props: typeof
|
|
163
|
+
empty?: (props: typeof __VLS_217) => any;
|
|
152
164
|
} & {
|
|
153
|
-
itemOverlay?: (props: typeof
|
|
165
|
+
itemOverlay?: (props: typeof __VLS_238) => any;
|
|
154
166
|
} & {
|
|
155
|
-
palette?: (props: typeof
|
|
167
|
+
palette?: (props: typeof __VLS_312) => any;
|
|
156
168
|
};
|
|
157
169
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
158
170
|
templateItems: import("vue").Ref<Record<string, any>[], Record<string, any>[]>;
|
|
@@ -216,20 +228,21 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
|
216
228
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
217
229
|
"onUpdate:modelValue"?: ((value: string | Record<string, any>[] | undefined) => any) | undefined;
|
|
218
230
|
}>, {
|
|
231
|
+
height: string | number;
|
|
219
232
|
title: string;
|
|
220
233
|
stringFields: string[];
|
|
221
234
|
initialData: Record<string, any>;
|
|
222
|
-
dialogFullscreen: boolean;
|
|
223
|
-
toolbarColor: string;
|
|
224
|
-
importable: boolean;
|
|
225
|
-
exportable: boolean;
|
|
226
|
-
sortable: boolean;
|
|
227
|
-
dialogMaxWidth: string | number;
|
|
228
235
|
roleCustomCode: string | string[];
|
|
229
236
|
disableAdvanceMode: boolean;
|
|
237
|
+
toolbarColor: string;
|
|
230
238
|
editorWidth: string | number;
|
|
239
|
+
dialogMaxWidth: string | number;
|
|
240
|
+
dialogFullscreen: boolean;
|
|
231
241
|
outline: boolean;
|
|
242
|
+
importable: boolean;
|
|
243
|
+
exportable: boolean;
|
|
232
244
|
importMode: DocumentTemplateImportMode;
|
|
245
|
+
sortable: boolean;
|
|
233
246
|
palette: boolean;
|
|
234
247
|
paletteTypes: string[];
|
|
235
248
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -39,9 +39,9 @@ declare const __VLS_base: import("vue").DefineComponent<Props, {
|
|
|
39
39
|
}>, {
|
|
40
40
|
disabled: boolean;
|
|
41
41
|
title: string;
|
|
42
|
-
searchable: boolean;
|
|
43
42
|
types: string[];
|
|
44
43
|
exclude: string[];
|
|
44
|
+
searchable: boolean;
|
|
45
45
|
grouped: boolean;
|
|
46
46
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
47
47
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
@@ -39,9 +39,9 @@ declare const __VLS_base: import("vue").DefineComponent<Props, {
|
|
|
39
39
|
}>, {
|
|
40
40
|
disabled: boolean;
|
|
41
41
|
title: string;
|
|
42
|
-
searchable: boolean;
|
|
43
42
|
types: string[];
|
|
44
43
|
exclude: string[];
|
|
44
|
+
searchable: boolean;
|
|
45
45
|
grouped: boolean;
|
|
46
46
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
47
47
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
@@ -22,7 +22,7 @@ declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {},
|
|
|
22
22
|
}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
|
|
23
23
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
24
24
|
}>, {
|
|
25
|
-
locale: "
|
|
25
|
+
locale: "TH" | "EN";
|
|
26
26
|
format: string;
|
|
27
27
|
readonly: boolean;
|
|
28
28
|
dense: boolean;
|
|
@@ -22,7 +22,7 @@ declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {},
|
|
|
22
22
|
}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
|
|
23
23
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
24
24
|
}>, {
|
|
25
|
-
locale: "
|
|
25
|
+
locale: "TH" | "EN";
|
|
26
26
|
format: string;
|
|
27
27
|
readonly: boolean;
|
|
28
28
|
dense: boolean;
|
|
@@ -681,9 +681,9 @@ declare const __VLS_base: import("vue").DefineComponent<Props, {
|
|
|
681
681
|
}>, {
|
|
682
682
|
disabled: boolean;
|
|
683
683
|
readonly: boolean;
|
|
684
|
+
parentTemplates: string | string[];
|
|
684
685
|
isolated: boolean;
|
|
685
686
|
decoration: object;
|
|
686
|
-
parentTemplates: string | string[];
|
|
687
687
|
dirtyClass: string;
|
|
688
688
|
dirtyOnCreate: boolean;
|
|
689
689
|
sanitizeDelay: number;
|
|
@@ -681,9 +681,9 @@ declare const __VLS_base: import("vue").DefineComponent<Props, {
|
|
|
681
681
|
}>, {
|
|
682
682
|
disabled: boolean;
|
|
683
683
|
readonly: boolean;
|
|
684
|
+
parentTemplates: string | string[];
|
|
684
685
|
isolated: boolean;
|
|
685
686
|
decoration: object;
|
|
686
|
-
parentTemplates: string | string[];
|
|
687
687
|
dirtyClass: string;
|
|
688
688
|
dirtyOnCreate: boolean;
|
|
689
689
|
sanitizeDelay: number;
|
|
@@ -6,7 +6,7 @@ interface Props {
|
|
|
6
6
|
format?: dateFormat | dateTimeFormat | string;
|
|
7
7
|
}
|
|
8
8
|
declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {
|
|
9
|
-
locale: "
|
|
9
|
+
locale: "TH" | "EN";
|
|
10
10
|
format: string;
|
|
11
11
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
12
12
|
declare const _default: typeof __VLS_export;
|
|
@@ -6,7 +6,7 @@ interface Props {
|
|
|
6
6
|
format?: dateFormat | dateTimeFormat | string;
|
|
7
7
|
}
|
|
8
8
|
declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {
|
|
9
|
-
locale: "
|
|
9
|
+
locale: "TH" | "EN";
|
|
10
10
|
format: string;
|
|
11
11
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
12
12
|
declare const _default: typeof __VLS_export;
|
|
@@ -64,11 +64,19 @@ export interface DocumentTemplateRenderOptions {
|
|
|
64
64
|
* `<v-col>` gets `<attribute>="<index>"` on that column so a design
|
|
65
65
|
* surface (e.g. `<DocumentTemplateBuilderLiveView>`) can map a click back
|
|
66
66
|
* to the item it came from. `Separator` and `FormHidden` render no column
|
|
67
|
-
* and are not annotated. Nested templates (FormTable / FormTableData)
|
|
67
|
+
* and are not annotated unless `noVisualPlaceholders` is set. Nested templates (FormTable / FormTableData)
|
|
68
68
|
* are never annotated. Omit for production rendering — the output is then
|
|
69
69
|
* unchanged.
|
|
70
70
|
*/
|
|
71
71
|
itemIndexAttribute?: string;
|
|
72
|
+
/**
|
|
73
|
+
* Builder-only, needs `itemIndexAttribute`. Gives `Separator` and
|
|
74
|
+
* `FormHidden` an annotated placeholder column (marked
|
|
75
|
+
* `data-doc-placeholder="<inputType>"`) so a design surface can show,
|
|
76
|
+
* select and delete them. The builder hides placeholders outside Design
|
|
77
|
+
* mode. Never set this for production rendering.
|
|
78
|
+
*/
|
|
79
|
+
noVisualPlaceholders?: boolean;
|
|
72
80
|
}
|
|
73
81
|
export declare function useDocumentTemplate(items: string | object, parentTemplates?: string | string[], options?: DocumentTemplateRenderOptions): string;
|
|
74
82
|
export declare function templateItemToString(inputItem: DocumentTemplateItem, parentTemplates: string | string[], dataVariable?: string): string;
|
|
@@ -5,6 +5,13 @@ import { some, includes, cloneDeep } from "lodash-es";
|
|
|
5
5
|
import { migrateInputAttributes, migrateTemplateString } from "./templateMigrate.js";
|
|
6
6
|
import { getDocumentTemplateInputTypeEntry } from "./templateInputTypes.js";
|
|
7
7
|
export const validationRulesRegex = /^(require(?:\([^)]*\))?|requireIf\([^)]*\)|requireTrue(?:\([^)]*\))?|requireTrueIf\([^)]*\)|requireNotEmpty(?:\([^)]*\))?|numeric(?:\([^)]*\))?|range\([^)]*\)|integer(?:\([^)]*\))?|unique\([^)]*\)|length(?:\([^)]*\))?|lengthGreater\([^)]*\)|lengthLess\([^)]*\)|telephone(?:\([^)]*\))?|email(?:\([^)]*\))?|regex\([^)]*\)|idcard(?:\([^)]*\))?|DateFuture(?:\([^)]*\))?|DatetimeFuture(?:\([^)]*\))?|DateHappen(?:\([^)]*\))?|DatetimeHappen(?:\([^)]*\))?|DateAfter\([^)]*\)|DateBefore\([^)]*\)|DateEqual\([^)]*\))(,(require(?:\([^)]*\))?|requireIf\([^)]*\)|requireTrue(?:\([^)]*\))?|requireTrueIf\([^)]*\)|requireNotEmpty(?:\([^)]*\))?|numeric(?:\([^)]*\))?|range\([^)]*\)|integer(?:\([^)]*\))?|unique\([^)]*\)|length(?:\([^)]*\))?|lengthGreater\([^)]*\)|lengthLess\([^)]*\)|telephone(?:\([^)]*\))?|email(?:\([^)]*\))?|regex\([^)]*\)|idcard(?:\([^)]*\))?|DateFuture(?:\([^)]*\))?|DatetimeFuture(?:\([^)]*\))?|DateHappen(?:\([^)]*\))?|DatetimeHappen(?:\([^)]*\))?|DateAfter\([^)]*\)|DateBefore\([^)]*\)|DateEqual\([^)]*\)))*$/;
|
|
8
|
+
const NO_VISUAL_INPUT_TYPES = ["Separator", "FormHidden"];
|
|
9
|
+
function noVisualPlaceholder(item, columnAttributes) {
|
|
10
|
+
const variableName = (item.variableName || "").replace(/[^\w$.]/g, "");
|
|
11
|
+
const label = item.inputType === "Separator" ? "Separator" : `Hidden field${variableName ? ` \xB7 ${variableName}` : ""}`;
|
|
12
|
+
const cols = item.inputType === "Separator" ? "12" : "auto";
|
|
13
|
+
return `<v-col${columnAttributes} cols="${cols}" data-doc-placeholder="${item.inputType}"><div class="doc-template-placeholder">${label}</div></v-col>`;
|
|
14
|
+
}
|
|
8
15
|
export function useDocumentTemplate(items, parentTemplates, options) {
|
|
9
16
|
if (!items) return "";
|
|
10
17
|
if (typeof items === "string") {
|
|
@@ -18,7 +25,8 @@ export function useDocumentTemplate(items, parentTemplates, options) {
|
|
|
18
25
|
return "";
|
|
19
26
|
}
|
|
20
27
|
const indexAttribute = options?.itemIndexAttribute;
|
|
21
|
-
const
|
|
28
|
+
const placeholders = !!indexAttribute && !!options?.noVisualPlaceholders;
|
|
29
|
+
const templateString = items.map((item, index) => columnWrapTemplateItemString(item, parentTemplates || [], "data", indexAttribute ? ` ${indexAttribute}="${index}"` : "", placeholders)).join("");
|
|
22
30
|
const wrapped = !parentTemplates || parentTemplates.length == 0 ? `<v-container fluid><v-row density='compact'>${templateString}</v-row></v-container>` : `<v-row density='compact'>${templateString}</v-row>`;
|
|
23
31
|
return migrateTemplateString(wrapped);
|
|
24
32
|
}
|
|
@@ -105,9 +113,10 @@ export function templateItemToString(inputItem, parentTemplates, dataVariable =
|
|
|
105
113
|
}
|
|
106
114
|
return templateString || "";
|
|
107
115
|
}
|
|
108
|
-
function columnWrapTemplateItemString(item, parentTemplates, dataVariable = "data", extraColumnAttributes = "") {
|
|
116
|
+
function columnWrapTemplateItemString(item, parentTemplates, dataVariable = "data", extraColumnAttributes = "", noVisualPlaceholders = false) {
|
|
109
117
|
let templateString = templateItemToString(item, parentTemplates, dataVariable);
|
|
110
|
-
if (
|
|
118
|
+
if (noVisualPlaceholders && NO_VISUAL_INPUT_TYPES.includes(item.inputType)) return `${noVisualPlaceholder(item, extraColumnAttributes)}${templateString || ""}`;
|
|
119
|
+
if (!NO_VISUAL_INPUT_TYPES.includes(item.inputType)) templateString = `<v-col${extraColumnAttributes}${item.width ? ` cols="${item.width}"` : ""}${item.columnAttributes ? " " + item.columnAttributes : ""} :class="(injectedClass) ? injectedClass['${item.variableName || ""}'] : undefined"${item.customClass ? ` class="${item.customClass}"` : ""}${item.customStyle ? ` class="${item.customStyle}"` : ""}>${templateString}</v-col>`;
|
|
111
120
|
if (["Header", "DocumentForm"].includes(item.inputType)) templateString = `</v-row><v-row density='compact' ${item.customClass ? ` class="${item.customClass}"` : ""}${item.customStyle ? ` class="${item.customStyle}"` : ""}>${templateString}</v-row><v-row density='compact'>`;
|
|
112
121
|
return templateString || "";
|
|
113
122
|
}
|