@ramathibodi/nuxt-commons 4.0.20 → 4.0.22
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/components/master/Autocomplete.vue +6 -2
- package/dist/runtime/components/master/Combobox.vue +6 -2
- 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/dist/runtime/composables/lookupListMaster.d.ts +3 -1
- package/dist/runtime/composables/lookupListMaster.js +2 -2
- package/package.json +2 -2
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { DocumentTemplateInputType } from '../../composables/document/templateInputTypes.js';
|
|
2
|
+
interface Props {
|
|
3
|
+
title?: string;
|
|
4
|
+
types?: string[];
|
|
5
|
+
exclude?: string[];
|
|
6
|
+
searchable?: boolean;
|
|
7
|
+
grouped?: boolean;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
}
|
|
10
|
+
type Thumb = 'text' | 'textarea' | 'date' | 'time' | 'datetime' | 'select' | 'radio' | 'radio-inline' | 'checkbox' | 'checkbox-group' | 'switch' | 'file' | 'images' | 'sign' | 'table' | 'header' | 'separator' | 'hidden' | 'form' | 'code' | 'custom';
|
|
11
|
+
interface PaletteCard {
|
|
12
|
+
entry: DocumentTemplateInputType;
|
|
13
|
+
value: string;
|
|
14
|
+
label: string;
|
|
15
|
+
group: string;
|
|
16
|
+
thumb: Thumb;
|
|
17
|
+
icon?: string;
|
|
18
|
+
}
|
|
19
|
+
declare var __VLS_1: {};
|
|
20
|
+
type __VLS_Slots = {} & {
|
|
21
|
+
title?: (props: typeof __VLS_1) => any;
|
|
22
|
+
};
|
|
23
|
+
declare const __VLS_base: import("vue").DefineComponent<Props, {
|
|
24
|
+
search: import("vue").Ref<string, string>;
|
|
25
|
+
cards: import("vue").ComputedRef<PaletteCard[]>;
|
|
26
|
+
sections: import("vue").ComputedRef<{
|
|
27
|
+
key: string;
|
|
28
|
+
label: string;
|
|
29
|
+
cards: PaletteCard[];
|
|
30
|
+
}[]>;
|
|
31
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
32
|
+
select: (...args: any[]) => void;
|
|
33
|
+
dragend: (...args: any[]) => void;
|
|
34
|
+
dragstart: (...args: any[]) => void;
|
|
35
|
+
}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
|
|
36
|
+
onSelect?: ((...args: any[]) => any) | undefined;
|
|
37
|
+
onDragend?: ((...args: any[]) => any) | undefined;
|
|
38
|
+
onDragstart?: ((...args: any[]) => any) | undefined;
|
|
39
|
+
}>, {
|
|
40
|
+
disabled: boolean;
|
|
41
|
+
title: string;
|
|
42
|
+
types: string[];
|
|
43
|
+
exclude: string[];
|
|
44
|
+
searchable: boolean;
|
|
45
|
+
grouped: boolean;
|
|
46
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
47
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
48
|
+
declare const _default: typeof __VLS_export;
|
|
49
|
+
export default _default;
|
|
50
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
51
|
+
new (): {
|
|
52
|
+
$slots: S;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed, ref } from "vue";
|
|
3
|
+
import { useDocumentTemplateInputTypes } from "../../composables/document/templateInputTypes";
|
|
4
|
+
import { DOCUMENT_TEMPLATE_PALETTE_MIME } from "../../composables/document/templatePalette";
|
|
5
|
+
const props = defineProps({
|
|
6
|
+
title: { type: String, required: false, default: "" },
|
|
7
|
+
types: { type: Array, required: false, default: void 0 },
|
|
8
|
+
exclude: { type: Array, required: false, default: () => [] },
|
|
9
|
+
searchable: { type: Boolean, required: false, default: true },
|
|
10
|
+
grouped: { type: Boolean, required: false, default: true },
|
|
11
|
+
disabled: { type: Boolean, required: false, default: false }
|
|
12
|
+
});
|
|
13
|
+
const emit = defineEmits(["select", "dragstart", "dragend"]);
|
|
14
|
+
const search = ref("");
|
|
15
|
+
const draggingValue = ref(null);
|
|
16
|
+
const THUMBS = {
|
|
17
|
+
VTextField: "text",
|
|
18
|
+
VTextarea: "textarea",
|
|
19
|
+
FormDate: "date",
|
|
20
|
+
FormTime: "time",
|
|
21
|
+
FormDateTime: "datetime",
|
|
22
|
+
VSelect: "select",
|
|
23
|
+
VCombobox: "select",
|
|
24
|
+
VAutocomplete: "select",
|
|
25
|
+
MasterAutocomplete: "select",
|
|
26
|
+
VRadio: "radio",
|
|
27
|
+
VRadioInline: "radio-inline",
|
|
28
|
+
VCheckbox: "checkbox",
|
|
29
|
+
FormCheckboxGroup: "checkbox-group",
|
|
30
|
+
VSwitch: "switch",
|
|
31
|
+
FormFile: "file",
|
|
32
|
+
FormImagesField: "images",
|
|
33
|
+
FormSignPad: "sign",
|
|
34
|
+
FormTable: "table",
|
|
35
|
+
FormTableData: "table",
|
|
36
|
+
Header: "header",
|
|
37
|
+
Separator: "separator",
|
|
38
|
+
FormHidden: "hidden",
|
|
39
|
+
DocumentForm: "form",
|
|
40
|
+
CustomCode: "code"
|
|
41
|
+
};
|
|
42
|
+
const THUMB_ICON = {
|
|
43
|
+
images: "mdi:mdi-image-multiple-outline",
|
|
44
|
+
sign: "mdi:mdi-draw",
|
|
45
|
+
hidden: "mdi:mdi-eye-off-outline",
|
|
46
|
+
form: "mdi:mdi-file-document-outline",
|
|
47
|
+
code: "mdi:mdi-code-tags",
|
|
48
|
+
custom: "mdi:mdi-puzzle-outline"
|
|
49
|
+
};
|
|
50
|
+
const GROUPS = [
|
|
51
|
+
{ key: "text", label: "Text & dates" },
|
|
52
|
+
{ key: "choice", label: "Choices" },
|
|
53
|
+
{ key: "media", label: "Files & signature" },
|
|
54
|
+
{ key: "table", label: "Tables" },
|
|
55
|
+
{ key: "layout", label: "Layout" },
|
|
56
|
+
{ key: "advanced", label: "Advanced" },
|
|
57
|
+
{ key: "custom", label: "Custom" }
|
|
58
|
+
];
|
|
59
|
+
const THUMB_GROUP = {
|
|
60
|
+
"text": "text",
|
|
61
|
+
"textarea": "text",
|
|
62
|
+
"date": "text",
|
|
63
|
+
"time": "text",
|
|
64
|
+
"datetime": "text",
|
|
65
|
+
"select": "choice",
|
|
66
|
+
"radio": "choice",
|
|
67
|
+
"radio-inline": "choice",
|
|
68
|
+
"checkbox": "choice",
|
|
69
|
+
"checkbox-group": "choice",
|
|
70
|
+
"switch": "choice",
|
|
71
|
+
"file": "media",
|
|
72
|
+
"images": "media",
|
|
73
|
+
"sign": "media",
|
|
74
|
+
"table": "table",
|
|
75
|
+
"header": "layout",
|
|
76
|
+
"separator": "layout",
|
|
77
|
+
"hidden": "advanced",
|
|
78
|
+
"form": "advanced",
|
|
79
|
+
"code": "advanced",
|
|
80
|
+
"custom": "custom"
|
|
81
|
+
};
|
|
82
|
+
function toCard(entry) {
|
|
83
|
+
const match = entry.label.match(/^\[([^\]]+)\](.*)$/);
|
|
84
|
+
const thumb = THUMBS[entry.value] ?? "custom";
|
|
85
|
+
return {
|
|
86
|
+
entry,
|
|
87
|
+
value: entry.value,
|
|
88
|
+
label: match ? match[2].trim() : entry.label,
|
|
89
|
+
group: THUMB_GROUP[thumb],
|
|
90
|
+
thumb,
|
|
91
|
+
icon: THUMB_ICON[thumb]
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
const cards = computed(() => {
|
|
95
|
+
const all = useDocumentTemplateInputTypes();
|
|
96
|
+
const picked = props.types ? props.types.map((value) => all.find((t) => t.value === value) ?? { label: value, value }) : all;
|
|
97
|
+
const q = search.value.trim().toLowerCase();
|
|
98
|
+
return picked.filter((t) => !props.exclude.includes(t.value)).map(toCard).filter((c) => !q || c.label.toLowerCase().includes(q) || c.value.toLowerCase().includes(q));
|
|
99
|
+
});
|
|
100
|
+
const sections = computed(() => {
|
|
101
|
+
if (!props.grouped || props.types) return [{ key: "all", label: "", cards: cards.value }];
|
|
102
|
+
return GROUPS.map((g) => ({ ...g, cards: cards.value.filter((c) => c.group === g.key) })).filter((g) => g.cards.length);
|
|
103
|
+
});
|
|
104
|
+
function onDragStart(event, card) {
|
|
105
|
+
if (props.disabled) {
|
|
106
|
+
event.preventDefault();
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (event.dataTransfer) {
|
|
110
|
+
event.dataTransfer.effectAllowed = "copy";
|
|
111
|
+
event.dataTransfer.setData(DOCUMENT_TEMPLATE_PALETTE_MIME, card.value);
|
|
112
|
+
event.dataTransfer.setData("text/plain", card.value);
|
|
113
|
+
}
|
|
114
|
+
draggingValue.value = card.value;
|
|
115
|
+
emit("dragstart", card.value);
|
|
116
|
+
}
|
|
117
|
+
function onDragEnd(card) {
|
|
118
|
+
draggingValue.value = null;
|
|
119
|
+
emit("dragend", card.value);
|
|
120
|
+
}
|
|
121
|
+
function onSelect(card) {
|
|
122
|
+
if (props.disabled) return;
|
|
123
|
+
emit("select", card.value);
|
|
124
|
+
}
|
|
125
|
+
defineExpose({ search, cards, sections });
|
|
126
|
+
</script>
|
|
127
|
+
|
|
128
|
+
<template>
|
|
129
|
+
<div
|
|
130
|
+
class="doc-palette"
|
|
131
|
+
:class="{ 'doc-palette--disabled': disabled }"
|
|
132
|
+
>
|
|
133
|
+
<div
|
|
134
|
+
v-if="title || $slots.title || searchable"
|
|
135
|
+
class="doc-palette__head"
|
|
136
|
+
>
|
|
137
|
+
<div
|
|
138
|
+
v-if="title || $slots.title"
|
|
139
|
+
class="doc-palette__title text-overline"
|
|
140
|
+
>
|
|
141
|
+
<slot name="title">
|
|
142
|
+
{{ title }}
|
|
143
|
+
</slot>
|
|
144
|
+
</div>
|
|
145
|
+
<v-text-field
|
|
146
|
+
v-if="searchable"
|
|
147
|
+
v-model="search"
|
|
148
|
+
density="compact"
|
|
149
|
+
variant="solo-filled"
|
|
150
|
+
flat
|
|
151
|
+
rounded="lg"
|
|
152
|
+
hide-details
|
|
153
|
+
clearable
|
|
154
|
+
prepend-inner-icon="mdi:mdi-magnify"
|
|
155
|
+
placeholder="Find a field…"
|
|
156
|
+
class="doc-palette__search"
|
|
157
|
+
/>
|
|
158
|
+
</div>
|
|
159
|
+
|
|
160
|
+
<div class="doc-palette__body">
|
|
161
|
+
<section
|
|
162
|
+
v-for="section in sections"
|
|
163
|
+
:key="section.key"
|
|
164
|
+
class="doc-palette__section"
|
|
165
|
+
:data-group="section.key"
|
|
166
|
+
>
|
|
167
|
+
<div
|
|
168
|
+
v-if="section.label"
|
|
169
|
+
class="doc-palette__section-label text-overline"
|
|
170
|
+
>
|
|
171
|
+
{{ section.label }}
|
|
172
|
+
</div>
|
|
173
|
+
<div class="doc-palette__grid">
|
|
174
|
+
<div
|
|
175
|
+
v-for="card in section.cards"
|
|
176
|
+
:key="card.value"
|
|
177
|
+
class="doc-palette__card"
|
|
178
|
+
:class="{ 'doc-palette__card--dragging': draggingValue === card.value }"
|
|
179
|
+
role="button"
|
|
180
|
+
:tabindex="disabled ? -1 : 0"
|
|
181
|
+
:aria-disabled="disabled || void 0"
|
|
182
|
+
:draggable="!disabled"
|
|
183
|
+
:data-input-type="card.value"
|
|
184
|
+
:data-group="card.group"
|
|
185
|
+
@dragstart="onDragStart($event, card)"
|
|
186
|
+
@dragend="onDragEnd(card)"
|
|
187
|
+
@click="onSelect(card)"
|
|
188
|
+
@keydown.enter.prevent="onSelect(card)"
|
|
189
|
+
@keydown.space.prevent="onSelect(card)"
|
|
190
|
+
>
|
|
191
|
+
<!-- The miniature is decoration only: `inert` keeps it out of the tab order and off the pointer. -->
|
|
192
|
+
<div
|
|
193
|
+
class="doc-palette__thumb"
|
|
194
|
+
:class="`doc-palette__thumb--${card.thumb}`"
|
|
195
|
+
inert
|
|
196
|
+
>
|
|
197
|
+
<v-text-field
|
|
198
|
+
v-if="card.thumb === 'text'"
|
|
199
|
+
label="Text"
|
|
200
|
+
density="compact"
|
|
201
|
+
variant="outlined"
|
|
202
|
+
hide-details
|
|
203
|
+
readonly
|
|
204
|
+
/>
|
|
205
|
+
<v-textarea
|
|
206
|
+
v-else-if="card.thumb === 'textarea'"
|
|
207
|
+
label="Text"
|
|
208
|
+
rows="2"
|
|
209
|
+
no-resize
|
|
210
|
+
density="compact"
|
|
211
|
+
variant="outlined"
|
|
212
|
+
hide-details
|
|
213
|
+
readonly
|
|
214
|
+
/>
|
|
215
|
+
<v-text-field
|
|
216
|
+
v-else-if="card.thumb === 'date'"
|
|
217
|
+
label="Date"
|
|
218
|
+
append-inner-icon="mdi:mdi-calendar"
|
|
219
|
+
density="compact"
|
|
220
|
+
variant="outlined"
|
|
221
|
+
hide-details
|
|
222
|
+
readonly
|
|
223
|
+
/>
|
|
224
|
+
<v-text-field
|
|
225
|
+
v-else-if="card.thumb === 'time'"
|
|
226
|
+
label="Time"
|
|
227
|
+
append-inner-icon="mdi:mdi-clock-outline"
|
|
228
|
+
density="compact"
|
|
229
|
+
variant="outlined"
|
|
230
|
+
hide-details
|
|
231
|
+
readonly
|
|
232
|
+
/>
|
|
233
|
+
<v-text-field
|
|
234
|
+
v-else-if="card.thumb === 'datetime'"
|
|
235
|
+
label="Date & time"
|
|
236
|
+
append-inner-icon="mdi:mdi-calendar-clock"
|
|
237
|
+
density="compact"
|
|
238
|
+
variant="outlined"
|
|
239
|
+
hide-details
|
|
240
|
+
readonly
|
|
241
|
+
/>
|
|
242
|
+
<v-select
|
|
243
|
+
v-else-if="card.thumb === 'select'"
|
|
244
|
+
label="Choose"
|
|
245
|
+
:items="[]"
|
|
246
|
+
density="compact"
|
|
247
|
+
variant="outlined"
|
|
248
|
+
hide-details
|
|
249
|
+
readonly
|
|
250
|
+
/>
|
|
251
|
+
<v-radio-group
|
|
252
|
+
v-else-if="card.thumb === 'radio' || card.thumb === 'radio-inline'"
|
|
253
|
+
:inline="card.thumb === 'radio-inline'"
|
|
254
|
+
model-value="a"
|
|
255
|
+
density="compact"
|
|
256
|
+
hide-details
|
|
257
|
+
>
|
|
258
|
+
<v-radio
|
|
259
|
+
label="A"
|
|
260
|
+
value="a"
|
|
261
|
+
/>
|
|
262
|
+
<v-radio
|
|
263
|
+
label="B"
|
|
264
|
+
value="b"
|
|
265
|
+
/>
|
|
266
|
+
</v-radio-group>
|
|
267
|
+
<v-checkbox
|
|
268
|
+
v-else-if="card.thumb === 'checkbox'"
|
|
269
|
+
label="Yes"
|
|
270
|
+
:model-value="true"
|
|
271
|
+
density="compact"
|
|
272
|
+
hide-details
|
|
273
|
+
/>
|
|
274
|
+
<template v-else-if="card.thumb === 'checkbox-group'">
|
|
275
|
+
<v-checkbox
|
|
276
|
+
label="A"
|
|
277
|
+
:model-value="true"
|
|
278
|
+
density="compact"
|
|
279
|
+
hide-details
|
|
280
|
+
/>
|
|
281
|
+
<v-checkbox
|
|
282
|
+
label="B"
|
|
283
|
+
:model-value="false"
|
|
284
|
+
density="compact"
|
|
285
|
+
hide-details
|
|
286
|
+
/>
|
|
287
|
+
</template>
|
|
288
|
+
<v-switch
|
|
289
|
+
v-else-if="card.thumb === 'switch'"
|
|
290
|
+
label="On"
|
|
291
|
+
:model-value="true"
|
|
292
|
+
color="primary"
|
|
293
|
+
density="compact"
|
|
294
|
+
hide-details
|
|
295
|
+
/>
|
|
296
|
+
<v-file-input
|
|
297
|
+
v-else-if="card.thumb === 'file'"
|
|
298
|
+
label="File"
|
|
299
|
+
density="compact"
|
|
300
|
+
variant="outlined"
|
|
301
|
+
hide-details
|
|
302
|
+
/>
|
|
303
|
+
<v-table
|
|
304
|
+
v-else-if="card.thumb === 'table'"
|
|
305
|
+
density="compact"
|
|
306
|
+
class="doc-palette__table"
|
|
307
|
+
>
|
|
308
|
+
<thead><tr><th>A</th><th>B</th></tr></thead>
|
|
309
|
+
<tbody>
|
|
310
|
+
<tr><td>…</td><td>…</td></tr>
|
|
311
|
+
<tr><td>…</td><td>…</td></tr>
|
|
312
|
+
</tbody>
|
|
313
|
+
</v-table>
|
|
314
|
+
<template v-else-if="card.thumb === 'header'">
|
|
315
|
+
<div class="text-subtitle-2 font-weight-bold">
|
|
316
|
+
Heading
|
|
317
|
+
</div>
|
|
318
|
+
<v-divider class="mt-1" />
|
|
319
|
+
</template>
|
|
320
|
+
<v-divider
|
|
321
|
+
v-else-if="card.thumb === 'separator'"
|
|
322
|
+
class="doc-palette__separator"
|
|
323
|
+
/>
|
|
324
|
+
<div
|
|
325
|
+
v-else
|
|
326
|
+
class="doc-palette__icon"
|
|
327
|
+
>
|
|
328
|
+
<v-icon size="24">
|
|
329
|
+
{{ card.icon }}
|
|
330
|
+
</v-icon>
|
|
331
|
+
</div>
|
|
332
|
+
</div>
|
|
333
|
+
<div class="doc-palette__foot">
|
|
334
|
+
<span class="doc-palette__name">{{ card.label }}</span>
|
|
335
|
+
<v-btn
|
|
336
|
+
class="doc-palette__add"
|
|
337
|
+
icon="mdi:mdi-plus"
|
|
338
|
+
size="x-small"
|
|
339
|
+
variant="tonal"
|
|
340
|
+
color="primary"
|
|
341
|
+
density="comfortable"
|
|
342
|
+
:aria-label="`Add ${card.label}`"
|
|
343
|
+
:disabled="disabled"
|
|
344
|
+
@click.stop="onSelect(card)"
|
|
345
|
+
/>
|
|
346
|
+
</div>
|
|
347
|
+
</div>
|
|
348
|
+
</div>
|
|
349
|
+
</section>
|
|
350
|
+
<div
|
|
351
|
+
v-if="!cards.length"
|
|
352
|
+
class="doc-palette__empty text-caption text-medium-emphasis"
|
|
353
|
+
>
|
|
354
|
+
No input types match.
|
|
355
|
+
</div>
|
|
356
|
+
</div>
|
|
357
|
+
</div>
|
|
358
|
+
</template>
|
|
359
|
+
|
|
360
|
+
<style scoped>
|
|
361
|
+
.doc-palette{--doc-palette-radius:10px;display:flex;flex-direction:column;min-height:0}.doc-palette__head{background:rgb(var(--v-theme-surface));border-bottom:thin solid rgba(var(--v-border-color),var(--v-border-opacity));padding:10px 10px 8px;position:sticky;top:0;z-index:1}.doc-palette__title{color:rgba(var(--v-theme-on-surface),var(--v-medium-emphasis-opacity));letter-spacing:.12em;line-height:1.6;margin-bottom:4px}.doc-palette__search :deep(.v-field__input){font-size:.8125rem;min-height:34px}.doc-palette__body{max-height:70vh;overflow-y:auto;padding:8px 8px 12px}.doc-palette__section+.doc-palette__section{margin-top:12px}.doc-palette__section-label{color:rgba(var(--v-theme-on-surface),var(--v-medium-emphasis-opacity));font-size:.625rem;letter-spacing:.14em;line-height:1.6;padding:0 2px 6px}.doc-palette__grid{display:grid;gap:8px;grid-template-columns:repeat(auto-fill,minmax(96px,1fr))}.doc-palette__card{background:rgb(var(--v-theme-surface));border:thin solid rgba(var(--v-border-color),var(--v-border-opacity));border-radius:var(--doc-palette-radius);cursor:grab;display:flex;flex-direction:column;outline:none;position:relative;transition:border-color .14s ease,box-shadow .14s ease,transform .14s ease,opacity .14s ease;-webkit-user-select:none;-moz-user-select:none;user-select:none}.doc-palette__card:focus-visible,.doc-palette__card:hover{border-color:rgba(var(--v-theme-primary),.7);box-shadow:0 2px 10px rgba(var(--v-theme-on-surface),.08);transform:translateY(-1px)}.doc-palette__card:focus-visible{box-shadow:0 0 0 2px rgba(var(--v-theme-primary),.35)}.doc-palette__card:active{cursor:grabbing;transform:translateY(0)}.doc-palette__card--dragging{opacity:.45}.doc-palette__thumb{background:linear-gradient(rgba(var(--v-theme-on-surface),.035),rgba(var(--v-theme-on-surface),.035)),rgb(var(--v-theme-surface));border-radius:var(--doc-palette-radius) var(--doc-palette-radius) 0 0;display:flex;flex-direction:column;height:56px;justify-content:center;overflow:hidden;padding:4px 8px 0;pointer-events:none}.doc-palette__thumb :deep(.v-input){font-size:.75rem}.doc-palette__thumb :deep(.v-field){--v-field-padding-start:8px;--v-field-padding-end:6px}.doc-palette__thumb :deep(.v-field__input){min-height:32px;padding-bottom:0;padding-top:0}.doc-palette__thumb :deep(.v-label){font-size:.75rem}.doc-palette__thumb :deep(.v-selection-control){--v-selection-control-size:22px;min-height:0}.doc-palette__thumb :deep(.v-selection-control-group){-moz-column-gap:8px;column-gap:8px;row-gap:0}.doc-palette__thumb :deep(.v-selection-control .v-label){font-size:.7rem}.doc-palette__thumb :deep(.v-input__control){min-height:0}.doc-palette__thumb--textarea :deep(.v-field__input){min-height:40px}.doc-palette__thumb--checkbox-group,.doc-palette__thumb--radio,.doc-palette__thumb--table{justify-content:flex-start}.doc-palette__table{background:transparent;font-size:.65rem}.doc-palette__table :deep(td),.doc-palette__table :deep(th){height:16px!important;line-height:16px;padding:0 6px!important}.doc-palette__separator{border-style:dashed}.doc-palette__icon{align-items:center;color:rgba(var(--v-theme-on-surface),var(--v-medium-emphasis-opacity));display:flex;height:100%;justify-content:center}.doc-palette__foot{align-items:center;border-top:thin solid rgba(var(--v-border-color),var(--v-border-opacity));display:flex;gap:4px;min-height:30px;padding:2px 4px 2px 8px}.doc-palette__name{display:-webkit-box;flex:1 1 auto;font-size:.75rem;line-height:1.2;min-width:0;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden;overflow-wrap:anywhere}.doc-palette__add{flex:0 0 auto;opacity:0;transition:opacity .14s ease}.doc-palette__card:focus-within .doc-palette__add,.doc-palette__card:hover .doc-palette__add{opacity:1}@media (hover:none){.doc-palette__add{opacity:1}}.doc-palette--disabled .doc-palette__card{border-color:rgba(var(--v-border-color),var(--v-border-opacity));box-shadow:none;cursor:default;opacity:.55;transform:none}.doc-palette--disabled .doc-palette__add{display:none}.doc-palette__empty{padding:8px 2px}
|
|
362
|
+
</style>
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { DocumentTemplateInputType } from '../../composables/document/templateInputTypes.js';
|
|
2
|
+
interface Props {
|
|
3
|
+
title?: string;
|
|
4
|
+
types?: string[];
|
|
5
|
+
exclude?: string[];
|
|
6
|
+
searchable?: boolean;
|
|
7
|
+
grouped?: boolean;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
}
|
|
10
|
+
type Thumb = 'text' | 'textarea' | 'date' | 'time' | 'datetime' | 'select' | 'radio' | 'radio-inline' | 'checkbox' | 'checkbox-group' | 'switch' | 'file' | 'images' | 'sign' | 'table' | 'header' | 'separator' | 'hidden' | 'form' | 'code' | 'custom';
|
|
11
|
+
interface PaletteCard {
|
|
12
|
+
entry: DocumentTemplateInputType;
|
|
13
|
+
value: string;
|
|
14
|
+
label: string;
|
|
15
|
+
group: string;
|
|
16
|
+
thumb: Thumb;
|
|
17
|
+
icon?: string;
|
|
18
|
+
}
|
|
19
|
+
declare var __VLS_1: {};
|
|
20
|
+
type __VLS_Slots = {} & {
|
|
21
|
+
title?: (props: typeof __VLS_1) => any;
|
|
22
|
+
};
|
|
23
|
+
declare const __VLS_base: import("vue").DefineComponent<Props, {
|
|
24
|
+
search: import("vue").Ref<string, string>;
|
|
25
|
+
cards: import("vue").ComputedRef<PaletteCard[]>;
|
|
26
|
+
sections: import("vue").ComputedRef<{
|
|
27
|
+
key: string;
|
|
28
|
+
label: string;
|
|
29
|
+
cards: PaletteCard[];
|
|
30
|
+
}[]>;
|
|
31
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
32
|
+
select: (...args: any[]) => void;
|
|
33
|
+
dragend: (...args: any[]) => void;
|
|
34
|
+
dragstart: (...args: any[]) => void;
|
|
35
|
+
}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
|
|
36
|
+
onSelect?: ((...args: any[]) => any) | undefined;
|
|
37
|
+
onDragend?: ((...args: any[]) => any) | undefined;
|
|
38
|
+
onDragstart?: ((...args: any[]) => any) | undefined;
|
|
39
|
+
}>, {
|
|
40
|
+
disabled: boolean;
|
|
41
|
+
title: string;
|
|
42
|
+
types: string[];
|
|
43
|
+
exclude: string[];
|
|
44
|
+
searchable: boolean;
|
|
45
|
+
grouped: boolean;
|
|
46
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
47
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
48
|
+
declare const _default: typeof __VLS_export;
|
|
49
|
+
export default _default;
|
|
50
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
51
|
+
new (): {
|
|
52
|
+
$slots: S;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
@@ -313,5 +313,5 @@ defineExpose({
|
|
|
313
313
|
</template>
|
|
314
314
|
|
|
315
315
|
<style>
|
|
316
|
-
.form-data-dirty:not(.v-input--error) :not(.v-chip):not(.v-chip *):not(.v-toolbar):not(.v-toolbar *):not(.dp__main):not(.dp__main *){color:color-mix(in srgb,currentColor 70%,rgb(var(--v-theme-primary)))!important;text-shadow:0 0 .02em currentColor}
|
|
316
|
+
.form-data-dirty:not(.v-input--error) :not(.v-chip):not(.v-chip *):not(.v-toolbar):not(.v-toolbar *):not(.dp__main):not(.dp__main *){color:color-mix(in srgb,currentColor 70%,rgb(var(--v-theme-primary)))!important;text-shadow:0 0 .02em currentColor}.v-radio>.v-label:has(>.form-radio-text-field){flex:1 1 auto}
|
|
317
317
|
</style>
|
|
@@ -65,14 +65,18 @@ const {
|
|
|
65
65
|
|
|
66
66
|
<template v-if="!$slots.item && props.meilisearch" #item="{ props: itemProps, item }">
|
|
67
67
|
<v-list-item v-bind="itemProps">
|
|
68
|
-
|
|
68
|
+
<!-- Vuetify's VAutocomplete #item slot passes the raw data object directly as `item`
|
|
69
|
+
(the old wrapped {raw, title, value, props} shape moved to a separate `internalItem`
|
|
70
|
+
param) -- `item.raw ?? item` handles both shapes, same defensive fallback
|
|
71
|
+
formatItemTitle already uses. -->
|
|
72
|
+
<template #title v-if="(item.raw ?? item)?._formatted?.itemValue">
|
|
69
73
|
<span v-html="formatItemTitle(item)" class="meilisearch-item"></span>
|
|
70
74
|
</template>
|
|
71
75
|
</v-list-item>
|
|
72
76
|
</template>
|
|
73
77
|
|
|
74
78
|
<template v-if="!$slots.selection && props.showCode" #selection="{ item }">
|
|
75
|
-
{{ formatItemTitle(item) }}
|
|
79
|
+
{{ formatItemTitle(item, { plain: true }) }}
|
|
76
80
|
</template>
|
|
77
81
|
</model-autocomplete>
|
|
78
82
|
</template>
|
|
@@ -65,14 +65,18 @@ const {
|
|
|
65
65
|
|
|
66
66
|
<template v-if="!$slots.item && props.meilisearch" #item="{ props: itemProps, item }">
|
|
67
67
|
<v-list-item v-bind="itemProps">
|
|
68
|
-
|
|
68
|
+
<!-- Vuetify's VCombobox #item slot passes the raw data object directly as `item`
|
|
69
|
+
(the old wrapped {raw, title, value, props} shape moved to a separate `internalItem`
|
|
70
|
+
param) -- `item.raw ?? item` handles both shapes, same defensive fallback
|
|
71
|
+
formatItemTitle already uses. -->
|
|
72
|
+
<template #title v-if="(item.raw ?? item)?._formatted?.itemValue">
|
|
69
73
|
<span v-html="formatItemTitle(item)" class="meilisearch-item"></span>
|
|
70
74
|
</template>
|
|
71
75
|
</v-list-item>
|
|
72
76
|
</template>
|
|
73
77
|
|
|
74
78
|
<template v-if="!$slots.selection && props.showCode" #selection="{ item }">
|
|
75
|
-
{{ formatItemTitle(item) }}
|
|
79
|
+
{{ formatItemTitle(item, { plain: true }) }}
|
|
76
80
|
</template>
|
|
77
81
|
</model-combobox>
|
|
78
82
|
</template>
|
|
@@ -37,10 +37,81 @@ export interface PrintConfigRow {
|
|
|
37
37
|
export interface ChoiceItem {
|
|
38
38
|
label: string;
|
|
39
39
|
value: string;
|
|
40
|
+
/**
|
|
41
|
+
* `VRadio` / `VRadioInline` only. `true` renders a text field right after
|
|
42
|
+
* this option's label, bound to `data.{radioChoiceTextVariable(...)}`
|
|
43
|
+
* (radio `treatment` + value `t1` → `data.treatmentT1Text`). The field is
|
|
44
|
+
* disabled while another option is selected and cleared when the
|
|
45
|
+
* selection moves to another option. Ignored by the select /
|
|
46
|
+
* checkbox-group inputs.
|
|
47
|
+
*/
|
|
48
|
+
textField?: boolean;
|
|
49
|
+
/** Placeholder shown in the `textField` input while it is empty. Only used when `textField` is `true`. */
|
|
50
|
+
textFieldPlaceholder?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Validation rules for the `textField` input, in the same comma-separated
|
|
53
|
+
* format as {@link DocumentTemplateItem.validationRules} (e.g.
|
|
54
|
+
* `"require,length(50)"`). They apply only while this option is selected,
|
|
55
|
+
* so an unselected (disabled) field never blocks the form. Only used when
|
|
56
|
+
* `textField` is `true`.
|
|
57
|
+
*/
|
|
58
|
+
textFieldRules?: string;
|
|
40
59
|
}
|
|
41
60
|
export declare const validationRulesRegex: RegExp;
|
|
42
|
-
export
|
|
61
|
+
export interface DocumentTemplateRenderOptions {
|
|
62
|
+
/**
|
|
63
|
+
* Builder-only. When set, every top-level item that renders inside a
|
|
64
|
+
* `<v-col>` gets `<attribute>="<index>"` on that column so a design
|
|
65
|
+
* surface (e.g. `<DocumentTemplateBuilderLiveView>`) can map a click back
|
|
66
|
+
* to the item it came from. `Separator` and `FormHidden` render no column
|
|
67
|
+
* and are not annotated. Nested templates (FormTable / FormTableData)
|
|
68
|
+
* are never annotated. Omit for production rendering — the output is then
|
|
69
|
+
* unchanged.
|
|
70
|
+
*/
|
|
71
|
+
itemIndexAttribute?: string;
|
|
72
|
+
}
|
|
73
|
+
export declare function useDocumentTemplate(items: string | object, parentTemplates?: string | string[], options?: DocumentTemplateRenderOptions): string;
|
|
43
74
|
export declare function templateItemToString(inputItem: DocumentTemplateItem, parentTemplates: string | string[], dataVariable?: string): string;
|
|
75
|
+
/**
|
|
76
|
+
* Name of the `data` property that holds the text typed beside a radio choice
|
|
77
|
+
* (see {@link ChoiceItem.textField}): the radio's own `variableName`, then the
|
|
78
|
+
* choice value in PascalCase with non-identifier characters dropped, then
|
|
79
|
+
* `Text`.
|
|
80
|
+
*
|
|
81
|
+
* radioChoiceTextVariable('treatment', 't1') → 'treatmentT1Text'
|
|
82
|
+
* radioChoiceTextVariable('reason', 'other-one') → 'reasonOtherOneText'
|
|
83
|
+
*
|
|
84
|
+
* Use ASCII choice values: a value made only of non-identifier characters
|
|
85
|
+
* collapses to `{variableName}Text` and would collide with a sibling.
|
|
86
|
+
*/
|
|
87
|
+
export declare function radioChoiceTextVariable(variableName: string | undefined, value: string | undefined): string;
|
|
88
|
+
export interface RadioChoiceContext {
|
|
89
|
+
/** The radio item's `variableName` (`data.{variableName}` holds the selection). */
|
|
90
|
+
variableName?: string;
|
|
91
|
+
/** Name of the data object in the emitted bindings (`data` at top level, a row alias inside tables). */
|
|
92
|
+
dataVariable?: string;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Emit one `<v-radio>` for a {@link ChoiceItem}. When the choice has
|
|
96
|
+
* `textField: true`, the label text and a `<v-text-field>` are rendered
|
|
97
|
+
* together in the radio's `#label` slot so the field sits right after the
|
|
98
|
+
* label (the `label` prop is kept for the accessible name). The field binds
|
|
99
|
+
* `{dataVariable}.{radioChoiceTextVariable(variableName, value)}` and is
|
|
100
|
+
* disabled while another option is selected.
|
|
101
|
+
*/
|
|
102
|
+
export declare function radioChoiceToString(choiceItem: ChoiceItem, inputAttributes?: string, context?: RadioChoiceContext): string;
|
|
103
|
+
/**
|
|
104
|
+
* Build the `@update:model-value` handler for a radio group whose choices
|
|
105
|
+
* have `textField: true`. Each such choice's text variable is cleared (set to
|
|
106
|
+
* `undefined`) whenever the group changes to a value other than that choice —
|
|
107
|
+
* so a note typed beside T1 does not survive a switch to T2. The newly
|
|
108
|
+
* selected choice's own field is left untouched.
|
|
109
|
+
*
|
|
110
|
+
* Returns `''` when no choice has a text field, or when `inputAttributes`
|
|
111
|
+
* already defines an `@update:model-value` listener (the author's handler
|
|
112
|
+
* wins; a duplicate attribute would be a compile error).
|
|
113
|
+
*/
|
|
114
|
+
export declare function radioTextFieldClearHandler(choice: ChoiceItem[], variableName: string | undefined, dataVariable?: string, inputAttributes?: string): string;
|
|
44
115
|
export declare function optionStringToChoiceObject(option: string | object): ChoiceItem[];
|
|
45
116
|
export declare function escapeObjectForInlineBinding(obj: object): string;
|
|
46
117
|
/**
|