@ramathibodi/nuxt-commons 4.0.20 → 4.0.21
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/TemplateBuilder.d.vue.ts +7 -1
- package/dist/runtime/components/document/TemplateBuilder.vue +7 -461
- package/dist/runtime/components/document/TemplateBuilder.vue.d.ts +7 -1
- package/dist/runtime/components/document/TemplateBuilderLiveView.d.vue.ts +185 -0
- package/dist/runtime/components/document/TemplateBuilderLiveView.vue +579 -0
- package/dist/runtime/components/document/TemplateBuilderLiveView.vue.d.ts +185 -0
- package/dist/runtime/components/document/TemplateItemForm.d.vue.ts +11 -0
- package/dist/runtime/components/document/TemplateItemForm.vue +437 -0
- package/dist/runtime/components/document/TemplateItemForm.vue.d.ts +11 -0
- package/dist/runtime/components/document/TemplatePalette.d.vue.ts +54 -0
- package/dist/runtime/components/document/TemplatePalette.vue +362 -0
- package/dist/runtime/components/document/TemplatePalette.vue.d.ts +54 -0
- package/dist/runtime/components/form/Pad.vue +1 -1
- package/dist/runtime/composables/document/template.d.ts +72 -1
- package/dist/runtime/composables/document/template.js +47 -8
- package/dist/runtime/composables/document/templateBuilderModel.d.ts +51 -0
- package/dist/runtime/composables/document/templateBuilderModel.js +62 -0
- package/dist/runtime/composables/document/templateFormHidden.js +3 -1
- package/dist/runtime/composables/document/templatePalette.d.ts +21 -0
- package/dist/runtime/composables/document/templatePalette.js +10 -0
- package/dist/runtime/composables/document/validateTemplate.js +61 -2
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import 'vue-json-pretty/lib/styles.css';
|
|
2
2
|
interface Props {
|
|
3
3
|
title?: string;
|
|
4
|
+
customCode?: boolean;
|
|
4
5
|
disableAdvanceMode?: boolean;
|
|
5
6
|
}
|
|
6
7
|
/**
|
|
@@ -10,7 +11,11 @@ interface Props {
|
|
|
10
11
|
* `registerDocumentTemplateInputType()` from a Nuxt plugin (app-wide) or
|
|
11
12
|
* `useDocumentTemplateInputType()` inside `<script setup>` of a page
|
|
12
13
|
* (page-scoped, auto-cleanup on unmount). Both flow through the same
|
|
13
|
-
* runtime registry that
|
|
14
|
+
* runtime registry that the item form reads via `useDocumentTemplateInputTypes()`.
|
|
15
|
+
*
|
|
16
|
+
* The per-item editor is `<DocumentTemplateItemForm>`, shared with
|
|
17
|
+
* `<DocumentTemplateBuilderLiveView>` (a design-surface variant of this
|
|
18
|
+
* builder that renders the template through FormPad as you edit).
|
|
14
19
|
*/
|
|
15
20
|
type __VLS_Props = Props;
|
|
16
21
|
type __VLS_ModelProps = {
|
|
@@ -23,6 +28,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
|
|
|
23
28
|
"onUpdate:modelValue"?: ((value: string | Record<string, any>[] | undefined) => any) | undefined;
|
|
24
29
|
}>, {
|
|
25
30
|
title: string;
|
|
31
|
+
customCode: boolean;
|
|
26
32
|
disableAdvanceMode: boolean;
|
|
27
33
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
28
34
|
declare const _default: typeof __VLS_export;
|
|
@@ -1,36 +1,21 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import {
|
|
3
|
-
import * as prettier from "prettier";
|
|
4
|
-
import prettierPluginHtml from "prettier/plugins/html";
|
|
2
|
+
import { ref } from "vue";
|
|
5
3
|
import {
|
|
6
|
-
useDocumentTemplate,
|
|
7
|
-
validationRulesRegex,
|
|
8
|
-
optionStringToChoiceObject,
|
|
9
|
-
printConfigToRows,
|
|
10
|
-
rowsToPrintConfig,
|
|
11
4
|
printConfigToAttributes,
|
|
12
|
-
|
|
13
|
-
rowsToConfigString
|
|
5
|
+
rowsToPrintConfig
|
|
14
6
|
} from "../../composables/document/template";
|
|
15
|
-
import {
|
|
16
|
-
useDocumentTemplateInputTypes
|
|
17
|
-
} from "../../composables/document/templateInputTypes";
|
|
18
|
-
import { autoActionHeader, templateToHeader } from "../../composables/document/templateFormTable";
|
|
19
|
-
import { cloneDeep, isPlainObject } from "lodash-es";
|
|
7
|
+
import { useDocumentTemplateBuilderModel } from "../../composables/document/templateBuilderModel";
|
|
20
8
|
import VueJsonPretty from "vue-json-pretty";
|
|
21
9
|
import "vue-json-pretty/lib/styles.css";
|
|
22
10
|
import { safeParseJSONDeep } from "../../utils/object";
|
|
23
11
|
const props = defineProps({
|
|
24
12
|
title: { type: String, required: false, default: "Document Template" },
|
|
13
|
+
customCode: { type: Boolean, required: false, default: false },
|
|
25
14
|
disableAdvanceMode: { type: Boolean, required: false, default: false }
|
|
26
15
|
});
|
|
27
16
|
const emit = defineEmits(["update:modelValue"]);
|
|
28
17
|
const modelValue = defineModel({ type: [String, Array] });
|
|
29
|
-
const advanceModeCode =
|
|
30
|
-
const isAdvanceMode = computed(() => {
|
|
31
|
-
return modelValue.value && (typeof modelValue.value === "string" && !isValidJsonArrayOfObjects(modelValue.value));
|
|
32
|
-
});
|
|
33
|
-
const templateItems = ref([]);
|
|
18
|
+
const { templateItems, isAdvanceMode, advanceModeCode, convertToAdvanceMode } = useDocumentTemplateBuilderModel(modelValue);
|
|
34
19
|
const headers = ref([
|
|
35
20
|
{
|
|
36
21
|
title: "",
|
|
@@ -67,132 +52,10 @@ const headers = ref([
|
|
|
67
52
|
width: "120px"
|
|
68
53
|
}
|
|
69
54
|
]);
|
|
70
|
-
const formTableHeaders = ref([
|
|
71
|
-
{
|
|
72
|
-
title: "Title",
|
|
73
|
-
key: "title"
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
title: "Key",
|
|
77
|
-
key: "key"
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
title: "Width",
|
|
81
|
-
key: "width"
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
title: "Action",
|
|
85
|
-
key: "action",
|
|
86
|
-
width: "120px"
|
|
87
|
-
}
|
|
88
|
-
]);
|
|
89
|
-
const choiceHeaders = ref([
|
|
90
|
-
{
|
|
91
|
-
title: "Label",
|
|
92
|
-
key: "label"
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
title: "Value",
|
|
96
|
-
key: "value"
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
title: "Action",
|
|
100
|
-
key: "action",
|
|
101
|
-
width: "120px"
|
|
102
|
-
}
|
|
103
|
-
]);
|
|
104
|
-
const printConfigHeaders = ref([
|
|
105
|
-
{
|
|
106
|
-
title: "Attribute",
|
|
107
|
-
key: "key"
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
title: "Value",
|
|
111
|
-
key: "value"
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
title: "Action",
|
|
115
|
-
key: "action",
|
|
116
|
-
width: "120px"
|
|
117
|
-
}
|
|
118
|
-
]);
|
|
119
|
-
function itemsForEdit(items) {
|
|
120
|
-
return items.map((item) => isPlainObject(item.printConfig) ? { ...item, printConfig: printConfigToRows(item.printConfig) } : item);
|
|
121
|
-
}
|
|
122
|
-
function itemsForStore(items) {
|
|
123
|
-
return items.map((item) => {
|
|
124
|
-
if (Array.isArray(item.printConfig)) {
|
|
125
|
-
const map = rowsToPrintConfig(item.printConfig);
|
|
126
|
-
const { printConfig, ...rest } = item;
|
|
127
|
-
return Object.keys(map).length ? { ...rest, printConfig: map } : rest;
|
|
128
|
-
}
|
|
129
|
-
if (typeof item.printConfig === "string" && item.printConfig.trim() === "") {
|
|
130
|
-
const { printConfig, ...rest } = item;
|
|
131
|
-
return rest;
|
|
132
|
-
}
|
|
133
|
-
return item;
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
function setPrintConfigMode(item, mode) {
|
|
137
|
-
if (mode === "raw") {
|
|
138
|
-
if (typeof item.printConfig === "string") return;
|
|
139
|
-
item.printConfig = rowsToConfigString(Array.isArray(item.printConfig) ? item.printConfig : []);
|
|
140
|
-
} else {
|
|
141
|
-
if (Array.isArray(item.printConfig)) return;
|
|
142
|
-
item.printConfig = configStringToRows(typeof item.printConfig === "string" ? item.printConfig : "");
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
55
|
function printConfigPreview(printConfig) {
|
|
146
56
|
if (Array.isArray(printConfig)) return printConfigToAttributes(rowsToPrintConfig(printConfig));
|
|
147
57
|
return printConfigToAttributes(printConfig);
|
|
148
58
|
}
|
|
149
|
-
function isValidJsonArrayOfObjects(str) {
|
|
150
|
-
try {
|
|
151
|
-
const parsed = JSON.parse(str);
|
|
152
|
-
return Array.isArray(parsed) && parsed.every((item) => typeof item === "object" && item !== null && !Array.isArray(item));
|
|
153
|
-
} catch (e) {
|
|
154
|
-
return false;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
watch(templateItems, (newValue) => {
|
|
158
|
-
if (!isAdvanceMode.value) modelValue.value = JSON.stringify(itemsForStore(newValue));
|
|
159
|
-
}, { deep: true });
|
|
160
|
-
watch(modelValue, (newValue) => {
|
|
161
|
-
if (typeof newValue === "string" && isValidJsonArrayOfObjects(newValue)) templateItems.value = itemsForEdit(JSON.parse(newValue));
|
|
162
|
-
else if (typeof newValue === "string") advanceModeCode.value = newValue;
|
|
163
|
-
else if (newValue) templateItems.value = itemsForEdit(cloneDeep(newValue));
|
|
164
|
-
}, { deep: true, immediate: true });
|
|
165
|
-
watch(advanceModeCode, (newValue) => {
|
|
166
|
-
if (isAdvanceMode.value) modelValue.value = newValue;
|
|
167
|
-
});
|
|
168
|
-
async function convertToAdvanceMode() {
|
|
169
|
-
if (!isAdvanceMode.value) {
|
|
170
|
-
modelValue.value = await prettier.format(useDocumentTemplate(itemsForStore(templateItems.value)).replaceAll(">", ">\n"), { parser: "html", plugins: [prettierPluginHtml] });
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
const inputTypes = computed(() => useDocumentTemplateInputTypes());
|
|
174
|
-
const inputTypeChoice = computed(() => inputTypes.value.map((t) => ({ label: t.label, value: t.value })));
|
|
175
|
-
const requireOption = computed(() => inputTypes.value.filter((t) => t.requiresOptions).map((t) => t.value));
|
|
176
|
-
const notRequireVariable = computed(() => inputTypes.value.filter((t) => t.needsVariableName === false).map((t) => t.value));
|
|
177
|
-
const notRequireLabel = computed(() => inputTypes.value.filter((t) => t.needsLabel === false).map((t) => t.value));
|
|
178
|
-
const notRequireWidth = computed(() => inputTypes.value.filter((t) => t.needsWidth === false).map((t) => t.value));
|
|
179
|
-
const notRequireOptions = computed(() => inputTypes.value.filter((t) => t.showsOptions === false).map((t) => t.value));
|
|
180
|
-
const notRequireRules = computed(() => inputTypes.value.filter((t) => t.hidesValidationRules).map((t) => t.value));
|
|
181
|
-
const notRequireInputAttributes = computed(() => inputTypes.value.filter((t) => t.hidesInputAttributes).map((t) => t.value));
|
|
182
|
-
const notRequireColumnAttributes = computed(() => inputTypes.value.filter((t) => t.hidesColumnAttributes).map((t) => t.value));
|
|
183
|
-
const notRequireAdvancedSetting = computed(() => inputTypes.value.filter((t) => t.hidesAdvancedSettings).map((t) => t.value));
|
|
184
|
-
const notRequireClassAndStyle = computed(() => inputTypes.value.filter((t) => t.hidesClassAndStyle).map((t) => t.value));
|
|
185
|
-
const hasSpecificOption = computed(() => inputTypes.value.filter((t) => t.hasSpecificOptionEditor).map((t) => t.value));
|
|
186
|
-
const choiceOption = computed(() => inputTypes.value.filter((t) => t.optionsAsChoice).map((t) => t.value));
|
|
187
|
-
const inputOptionsLabel = computed(() => {
|
|
188
|
-
const acc = {};
|
|
189
|
-
for (const t of inputTypes.value) if (t.optionsLabel) acc[t.value] = t.optionsLabel;
|
|
190
|
-
return acc;
|
|
191
|
-
});
|
|
192
|
-
const ruleOptions = (inputType) => (value) => {
|
|
193
|
-
if (choiceOption.value.includes(inputType) && !/^[^'",]+(,[^'",]+)*$/.test(value)) return "Invalid options format";
|
|
194
|
-
return true;
|
|
195
|
-
};
|
|
196
59
|
</script>
|
|
197
60
|
|
|
198
61
|
<template>
|
|
@@ -207,7 +70,7 @@ const ruleOptions = (inputType) => (value) => {
|
|
|
207
70
|
color="primary"
|
|
208
71
|
variant="flat"
|
|
209
72
|
@click="convertToAdvanceMode()"
|
|
210
|
-
v-if="!disableAdvanceMode"
|
|
73
|
+
v-if="customCode && !disableAdvanceMode"
|
|
211
74
|
>
|
|
212
75
|
Convert To Advance
|
|
213
76
|
</VBtn>
|
|
@@ -216,324 +79,7 @@ const ruleOptions = (inputType) => (value) => {
|
|
|
216
79
|
{{ internalItem.index }}
|
|
217
80
|
</template>
|
|
218
81
|
<template #form="{ data, rules }">
|
|
219
|
-
<
|
|
220
|
-
<v-row density="compact">
|
|
221
|
-
<v-col cols="3">
|
|
222
|
-
<v-combobox
|
|
223
|
-
v-model="data.inputType"
|
|
224
|
-
label="Input Type"
|
|
225
|
-
:items="inputTypeChoice"
|
|
226
|
-
item-title="label"
|
|
227
|
-
item-value="value"
|
|
228
|
-
:return-object="false"
|
|
229
|
-
:rules="[rules.require()]"
|
|
230
|
-
/>
|
|
231
|
-
</v-col>
|
|
232
|
-
<v-col cols="1" v-if="!notRequireWidth.includes(data.inputType)">
|
|
233
|
-
<v-text-field
|
|
234
|
-
v-model="data.width"
|
|
235
|
-
label="Width"
|
|
236
|
-
:rules="[rules.require()]"
|
|
237
|
-
type="number"
|
|
238
|
-
/>
|
|
239
|
-
<form-hidden v-model="data.inputOptions" :item-value="data.inputType" :hook="(_result, model, newValue, oldValue) => {
|
|
240
|
-
return newValue && oldValue ? void 0 : model;
|
|
241
|
-
}"></form-hidden>
|
|
242
|
-
</v-col>
|
|
243
|
-
<v-col cols="4" v-if="!notRequireLabel.includes(data.inputType)">
|
|
244
|
-
<v-text-field
|
|
245
|
-
v-model="data.inputLabel"
|
|
246
|
-
label="Input Label"
|
|
247
|
-
:rules="[rules.require()]"
|
|
248
|
-
/>
|
|
249
|
-
</v-col>
|
|
250
|
-
<v-col cols="4" v-if="!notRequireVariable.includes(data.inputType)">
|
|
251
|
-
<v-text-field
|
|
252
|
-
v-model="data.variableName"
|
|
253
|
-
label="Variable Name"
|
|
254
|
-
:rules="[rules.require()]"
|
|
255
|
-
/>
|
|
256
|
-
</v-col>
|
|
257
|
-
<v-col
|
|
258
|
-
v-if="!notRequireOptions.includes(data.inputType)"
|
|
259
|
-
cols="12"
|
|
260
|
-
>
|
|
261
|
-
<form-pad v-model="data.inputOptions" v-if="data.inputType == 'FormTable'">
|
|
262
|
-
<template #default="{ data: optionData }">
|
|
263
|
-
<v-row density="compact">
|
|
264
|
-
<v-col cols="12">
|
|
265
|
-
<form-table v-model="optionData.headers" :headers="formTableHeaders" title="Headers">
|
|
266
|
-
<template #form="{ data: headerData, rules }">
|
|
267
|
-
<v-container fluid>
|
|
268
|
-
<v-row density="compact">
|
|
269
|
-
<v-col cols="6"><v-text-field v-model="headerData.title" label="Title"></v-text-field></v-col>
|
|
270
|
-
<v-col cols="3"><v-text-field v-model="headerData.key" label="Key" :rules="[rules.require()]"></v-text-field></v-col>
|
|
271
|
-
<v-col cols="3"><v-text-field v-model="headerData.width" label="Width"></v-text-field></v-col>
|
|
272
|
-
</v-row>
|
|
273
|
-
<v-row density="compact">
|
|
274
|
-
<v-col cols="12"><v-textarea v-model="headerData.template" label="Item Template"></v-textarea></v-col>
|
|
275
|
-
</v-row>
|
|
276
|
-
</v-container>
|
|
277
|
-
</template>
|
|
278
|
-
</form-table>
|
|
279
|
-
</v-col>
|
|
280
|
-
<v-col cols="12">
|
|
281
|
-
<document-template-builder v-model="optionData.formTemplate" title="Form Template"></document-template-builder>
|
|
282
|
-
</v-col>
|
|
283
|
-
</v-row>
|
|
284
|
-
</template>
|
|
285
|
-
</form-pad>
|
|
286
|
-
<form-pad v-model="data.inputOptions" v-if="data.inputType == 'FormTableData'">
|
|
287
|
-
<template #default="{ data: optionData }">
|
|
288
|
-
<v-row density="compact">
|
|
289
|
-
<v-col cols="12">
|
|
290
|
-
<tabs-group>
|
|
291
|
-
<template #tabs>
|
|
292
|
-
<v-tab value="itemTemplate">Item Template</v-tab>
|
|
293
|
-
<v-tab value="dataTemplate">Data Template</v-tab>
|
|
294
|
-
<v-tab value="header">Header</v-tab>
|
|
295
|
-
</template>
|
|
296
|
-
<template #items>
|
|
297
|
-
<v-tabs-window-item value="itemTemplate">
|
|
298
|
-
<document-template-builder v-model="optionData.itemTemplate" title="Item Template" disable-advance-mode></document-template-builder>
|
|
299
|
-
</v-tabs-window-item>
|
|
300
|
-
<v-tabs-window-item value="dataTemplate">
|
|
301
|
-
<document-template-builder v-model="optionData.dataTemplate" title="Data Template" disable-advance-mode></document-template-builder>
|
|
302
|
-
</v-tabs-window-item>
|
|
303
|
-
<v-tabs-window-item value="header">
|
|
304
|
-
<form-table v-model="optionData.headers" :headers="formTableHeaders" title="Headers">
|
|
305
|
-
<template #form="{ data: headerData, rules }">
|
|
306
|
-
<v-container fluid>
|
|
307
|
-
<v-row density="compact">
|
|
308
|
-
<v-col cols="6"><v-text-field v-model="headerData.title" label="Title"></v-text-field></v-col>
|
|
309
|
-
<v-col cols="3"><v-text-field v-model="headerData.key" label="Key" :rules="[rules.require()]"></v-text-field></v-col>
|
|
310
|
-
<v-col cols="3"><v-text-field v-model="headerData.width" label="Width"></v-text-field></v-col>
|
|
311
|
-
</v-row>
|
|
312
|
-
<v-row density="compact">
|
|
313
|
-
<v-col cols="12"><v-text-field v-model="headerData.value" label="Value"></v-text-field></v-col>
|
|
314
|
-
<v-col cols="12"><v-textarea v-model="headerData.template" label="Item Template"></v-textarea></v-col>
|
|
315
|
-
</v-row>
|
|
316
|
-
</v-container>
|
|
317
|
-
</template>
|
|
318
|
-
</form-table>
|
|
319
|
-
</v-tabs-window-item>
|
|
320
|
-
</template>
|
|
321
|
-
</tabs-group>
|
|
322
|
-
</v-col>
|
|
323
|
-
<v-col cols="12">
|
|
324
|
-
<form-table v-model="optionData.items" :headers="optionData.headers && optionData.headers.length > 0 ? autoActionHeader(optionData.headers) : autoActionHeader(templateToHeader(optionData.itemTemplate))" title="Items">
|
|
325
|
-
<template #form="{ data }">
|
|
326
|
-
<form-pad :model-value="data" :template="optionData.itemTemplate"></form-pad>
|
|
327
|
-
</template>
|
|
328
|
-
</form-table>
|
|
329
|
-
</v-col>
|
|
330
|
-
<v-col cols="12">
|
|
331
|
-
<v-row density="compact">
|
|
332
|
-
<v-col cols="4">
|
|
333
|
-
<v-radio-group v-model="optionData.disableApplyToAll" inline>
|
|
334
|
-
<template #prepend>
|
|
335
|
-
<span class="opacity-60"> Disable Apply to All</span>
|
|
336
|
-
</template>
|
|
337
|
-
<v-radio label="No" value="false" hide-details> </v-radio>
|
|
338
|
-
<v-radio label="Yes" value="true" hide-details> </v-radio>
|
|
339
|
-
<v-radio label="Partial" value="partial" hide-details> </v-radio>
|
|
340
|
-
</v-radio-group>
|
|
341
|
-
</v-col>
|
|
342
|
-
<v-col cols="8">
|
|
343
|
-
<VTextField
|
|
344
|
-
variant="underlined"
|
|
345
|
-
v-model="optionData.disableApplyToAllPartial"
|
|
346
|
-
label="Disable Apply To All Column"
|
|
347
|
-
v-if="optionData.disableApplyToAll == 'partial'"
|
|
348
|
-
>
|
|
349
|
-
</VTextField>
|
|
350
|
-
</v-col>
|
|
351
|
-
</v-row>
|
|
352
|
-
</v-col>
|
|
353
|
-
</v-row>
|
|
354
|
-
</template>
|
|
355
|
-
</form-pad>
|
|
356
|
-
<form-pad v-model="data.inputOptions" v-if="data.inputType == 'FormHidden'">
|
|
357
|
-
<template #default="{ data: optionData }">
|
|
358
|
-
<v-row density="compact">
|
|
359
|
-
<v-col cols="12">
|
|
360
|
-
<v-text-field
|
|
361
|
-
v-model="optionData.hook"
|
|
362
|
-
label="Hook"
|
|
363
|
-
/>
|
|
364
|
-
</v-col>
|
|
365
|
-
<v-col cols="12">
|
|
366
|
-
<v-text-field
|
|
367
|
-
v-model="optionData.itemValue"
|
|
368
|
-
label="Item Value"
|
|
369
|
-
/>
|
|
370
|
-
</v-col>
|
|
371
|
-
</v-row>
|
|
372
|
-
</template>
|
|
373
|
-
</form-pad>
|
|
374
|
-
<form-table v-model="data.inputOptions" :headers="choiceHeaders" title="Choices" v-if="choiceOption.includes(data.inputType) && (!data.inputOptions || typeof data.inputOptions === 'object')">
|
|
375
|
-
<template #form="{ data: optionData, rules }">
|
|
376
|
-
<v-container fluid>
|
|
377
|
-
<v-row density="compact">
|
|
378
|
-
<v-col cols="6"><v-text-field v-model="optionData.label" label="Label"></v-text-field></v-col>
|
|
379
|
-
<v-col cols="6"><v-text-field v-model="optionData.value" label="Value" :rules="[rules.require()]"></v-text-field></v-col>
|
|
380
|
-
</v-row>
|
|
381
|
-
</v-container>
|
|
382
|
-
</template>
|
|
383
|
-
</form-table>
|
|
384
|
-
<form-hidden v-model="data.inputOptions" :itemValue="data.inputOptions" :hook="(option) => optionStringToChoiceObject(option)" v-if="choiceOption.includes(data.inputType) && data.inputOptions && typeof data.inputOptions === 'string'"></form-hidden>
|
|
385
|
-
<v-textarea
|
|
386
|
-
v-model="data.inputOptions"
|
|
387
|
-
:label="inputOptionsLabel[data.inputType] || 'Input Options'"
|
|
388
|
-
auto-grow
|
|
389
|
-
:rules="[rules.requireIf(requireOption.includes(data.inputType)), ruleOptions(data.inputType)]"
|
|
390
|
-
v-if="!hasSpecificOption.includes(data.inputType) && !choiceOption.includes(data.inputType)"
|
|
391
|
-
/>
|
|
392
|
-
</v-col>
|
|
393
|
-
|
|
394
|
-
<v-col
|
|
395
|
-
v-if="data.inputType == 'CustomCode'"
|
|
396
|
-
cols="12"
|
|
397
|
-
>
|
|
398
|
-
<FormCodeEditor
|
|
399
|
-
v-model="data.inputCustomCode"
|
|
400
|
-
label="Custom Code"
|
|
401
|
-
:rules="[rules.require()]"
|
|
402
|
-
/>
|
|
403
|
-
</v-col>
|
|
404
|
-
</v-row>
|
|
405
|
-
<v-row density="compact">
|
|
406
|
-
<v-col>
|
|
407
|
-
<v-expansion-panels>
|
|
408
|
-
<v-expansion-panel v-if="!notRequireRules.includes(data.inputType)">
|
|
409
|
-
<v-expansion-panel-title collapse-icon="mdi mdi-minus" expand-icon="mdi mdi-plus" class="font-weight-bold">Validations</v-expansion-panel-title>
|
|
410
|
-
<v-expansion-panel-text>
|
|
411
|
-
<v-container fluid>
|
|
412
|
-
<v-row density="compact">
|
|
413
|
-
<v-col cols="12">
|
|
414
|
-
<v-text-field
|
|
415
|
-
v-model="data.validationRules"
|
|
416
|
-
label="Validation Rules"
|
|
417
|
-
:rules="[rules.regex(validationRulesRegex)]"
|
|
418
|
-
/>
|
|
419
|
-
<b>Available rules :</b> require, requireIf(condition), requireTrue, requireTrueIf(condition), requireNotEmpty, numeric, range(min,max), integer, unique, length(length), lengthGreater(length), lengthLess(length), telephone, email, regex(regex), idcard, DateFuture, DatetimeFuture, DateHappen, DatetimeHappen, DateAfter(date), DateBefore(Date), DateEqual(date)
|
|
420
|
-
</v-col>
|
|
421
|
-
</v-row>
|
|
422
|
-
</v-container>
|
|
423
|
-
</v-expansion-panel-text>
|
|
424
|
-
</v-expansion-panel>
|
|
425
|
-
<v-expansion-panel v-if="!notRequireAdvancedSetting.includes(data.inputType)">
|
|
426
|
-
<v-expansion-panel-title collapse-icon="mdi mdi-minus" expand-icon="mdi mdi-plus" class="font-weight-bold">Advanced settings</v-expansion-panel-title>
|
|
427
|
-
<v-expansion-panel-text>
|
|
428
|
-
<v-container fluid>
|
|
429
|
-
<v-row density="compact">
|
|
430
|
-
<v-col cols="12" md="6" v-if="!notRequireInputAttributes.includes(data.inputType)">
|
|
431
|
-
<v-text-field
|
|
432
|
-
v-model="data.inputAttributes"
|
|
433
|
-
label="Input Attributes"
|
|
434
|
-
/>
|
|
435
|
-
</v-col>
|
|
436
|
-
<v-col cols="12" md="6" v-if="!notRequireColumnAttributes.includes(data.inputType)">
|
|
437
|
-
<v-text-field
|
|
438
|
-
v-model="data.columnAttributes"
|
|
439
|
-
label="Column Attributes"
|
|
440
|
-
/>
|
|
441
|
-
</v-col>
|
|
442
|
-
<v-col cols="12" md="6">
|
|
443
|
-
<v-text-field
|
|
444
|
-
v-model="data.conditionalDisplay"
|
|
445
|
-
label="Conditional Display"
|
|
446
|
-
/>
|
|
447
|
-
</v-col>
|
|
448
|
-
<v-col cols="12" md="6">
|
|
449
|
-
<v-text-field
|
|
450
|
-
v-model="data.computedValue"
|
|
451
|
-
label="Computed Value"
|
|
452
|
-
/>
|
|
453
|
-
</v-col>
|
|
454
|
-
<v-col cols="12" md="6">
|
|
455
|
-
<v-text-field
|
|
456
|
-
v-model="data.retrievedValue"
|
|
457
|
-
label="Retrieved Value"
|
|
458
|
-
/>
|
|
459
|
-
</v-col>
|
|
460
|
-
<v-col cols="12">
|
|
461
|
-
<div class="d-flex align-center ga-2 mb-1">
|
|
462
|
-
<span class="opacity-60">Print Config</span>
|
|
463
|
-
<span class="text-caption opacity-60">— print/docx-only; ignored by the form renderer</span>
|
|
464
|
-
<v-spacer />
|
|
465
|
-
<v-btn-toggle
|
|
466
|
-
:model-value="typeof data.printConfig === 'string' ? 'raw' : 'map'"
|
|
467
|
-
@update:model-value="(mode) => setPrintConfigMode(data, mode)"
|
|
468
|
-
density="compact"
|
|
469
|
-
variant="outlined"
|
|
470
|
-
divided
|
|
471
|
-
mandatory
|
|
472
|
-
>
|
|
473
|
-
<v-btn value="map" size="small">Key / Value</v-btn>
|
|
474
|
-
<v-btn value="raw" size="small">Raw string</v-btn>
|
|
475
|
-
</v-btn-toggle>
|
|
476
|
-
</div>
|
|
477
|
-
<v-textarea
|
|
478
|
-
v-if="typeof data.printConfig === 'string'"
|
|
479
|
-
v-model="data.printConfig"
|
|
480
|
-
label="Print Config (raw attributes)"
|
|
481
|
-
placeholder="format=dd/MM/yyyy; locale=th_TH"
|
|
482
|
-
auto-grow
|
|
483
|
-
rows="1"
|
|
484
|
-
/>
|
|
485
|
-
<form-table
|
|
486
|
-
v-else
|
|
487
|
-
v-model="data.printConfig"
|
|
488
|
-
:headers="printConfigHeaders"
|
|
489
|
-
title="Print Config"
|
|
490
|
-
>
|
|
491
|
-
<template #form="{ data: rowData, rules }">
|
|
492
|
-
<v-container fluid>
|
|
493
|
-
<v-row density="compact">
|
|
494
|
-
<v-col cols="6">
|
|
495
|
-
<v-text-field v-model="rowData.key" label="Attribute" :rules="[rules.require()]" />
|
|
496
|
-
</v-col>
|
|
497
|
-
<v-col cols="6">
|
|
498
|
-
<v-text-field v-model="rowData.value" label="Value (blank = flag)" />
|
|
499
|
-
</v-col>
|
|
500
|
-
</v-row>
|
|
501
|
-
</v-container>
|
|
502
|
-
</template>
|
|
503
|
-
</form-table>
|
|
504
|
-
<div class="text-caption opacity-60 mt-1" v-if="printConfigPreview(data.printConfig)">
|
|
505
|
-
Appends to placeholder: <code>{{ printConfigPreview(data.printConfig) }}</code>
|
|
506
|
-
</div>
|
|
507
|
-
</v-col>
|
|
508
|
-
</v-row>
|
|
509
|
-
</v-container>
|
|
510
|
-
</v-expansion-panel-text>
|
|
511
|
-
</v-expansion-panel>
|
|
512
|
-
<v-expansion-panel v-if="!notRequireClassAndStyle.includes(data.inputType)">
|
|
513
|
-
<v-expansion-panel-title collapse-icon="mdi mdi-minus" expand-icon="mdi mdi-plus" class="font-weight-bold">Class and Styles</v-expansion-panel-title>
|
|
514
|
-
<v-expansion-panel-text>
|
|
515
|
-
<v-container fluid>
|
|
516
|
-
<v-row density="compact">
|
|
517
|
-
<v-col cols="12">
|
|
518
|
-
<v-text-field
|
|
519
|
-
v-model="data.customClass"
|
|
520
|
-
label="Custom Class"
|
|
521
|
-
/>
|
|
522
|
-
</v-col>
|
|
523
|
-
<v-col cols="12">
|
|
524
|
-
<v-text-field
|
|
525
|
-
v-model="data.customStyle"
|
|
526
|
-
label="Custom Styles"
|
|
527
|
-
/>
|
|
528
|
-
</v-col>
|
|
529
|
-
</v-row>
|
|
530
|
-
</v-container>
|
|
531
|
-
</v-expansion-panel-text>
|
|
532
|
-
</v-expansion-panel>
|
|
533
|
-
</v-expansion-panels>
|
|
534
|
-
</v-col>
|
|
535
|
-
</v-row>
|
|
536
|
-
</v-container>
|
|
82
|
+
<document-template-item-form :data="data" :rules="rules" :custom-code="customCode" />
|
|
537
83
|
</template>
|
|
538
84
|
<template #item.configuration="props">
|
|
539
85
|
<v-sheet
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import 'vue-json-pretty/lib/styles.css';
|
|
2
2
|
interface Props {
|
|
3
3
|
title?: string;
|
|
4
|
+
customCode?: boolean;
|
|
4
5
|
disableAdvanceMode?: boolean;
|
|
5
6
|
}
|
|
6
7
|
/**
|
|
@@ -10,7 +11,11 @@ interface Props {
|
|
|
10
11
|
* `registerDocumentTemplateInputType()` from a Nuxt plugin (app-wide) or
|
|
11
12
|
* `useDocumentTemplateInputType()` inside `<script setup>` of a page
|
|
12
13
|
* (page-scoped, auto-cleanup on unmount). Both flow through the same
|
|
13
|
-
* runtime registry that
|
|
14
|
+
* runtime registry that the item form reads via `useDocumentTemplateInputTypes()`.
|
|
15
|
+
*
|
|
16
|
+
* The per-item editor is `<DocumentTemplateItemForm>`, shared with
|
|
17
|
+
* `<DocumentTemplateBuilderLiveView>` (a design-surface variant of this
|
|
18
|
+
* builder that renders the template through FormPad as you edit).
|
|
14
19
|
*/
|
|
15
20
|
type __VLS_Props = Props;
|
|
16
21
|
type __VLS_ModelProps = {
|
|
@@ -23,6 +28,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
|
|
|
23
28
|
"onUpdate:modelValue"?: ((value: string | Record<string, any>[] | undefined) => any) | undefined;
|
|
24
29
|
}>, {
|
|
25
30
|
title: string;
|
|
31
|
+
customCode: boolean;
|
|
26
32
|
disableAdvanceMode: boolean;
|
|
27
33
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
28
34
|
declare const _default: typeof __VLS_export;
|