nuxt-unified-ui 0.3.4 → 0.4.0
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.
|
@@ -16,18 +16,29 @@ import FormElementSelect from '../elements/form-element-select.vue';
|
|
|
16
16
|
import FormElementSeries from '../elements/form-element-series.vue';
|
|
17
17
|
import FormElementCheckbox from '../elements/form-element-checkbox.vue';
|
|
18
18
|
import FormElementDate from '../elements/form-element-date.vue';
|
|
19
|
-
import FormElementMedia from '../elements/form-element-media.vue';
|
|
20
19
|
|
|
21
20
|
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
const formExtraElements = useFormExtraElements();
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
const elementsMap = computed(() => {
|
|
25
|
+
return {
|
|
26
|
+
'input': FormElementInput,
|
|
27
|
+
'textarea': FormElementTextarea,
|
|
28
|
+
'select': FormElementSelect,
|
|
29
|
+
'series': FormElementSeries,
|
|
30
|
+
'date': FormElementDate,
|
|
31
|
+
'checkbox': FormElementCheckbox,
|
|
32
|
+
...(Object.fromEntries(
|
|
33
|
+
formExtraElements.value.map(it =>
|
|
34
|
+
[
|
|
35
|
+
it.identifier,
|
|
36
|
+
it.component,
|
|
37
|
+
],
|
|
38
|
+
),
|
|
39
|
+
)),
|
|
40
|
+
};
|
|
41
|
+
});
|
|
31
42
|
|
|
32
43
|
|
|
33
44
|
/* v-if */
|
package/nuxt.config.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-unified-ui",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
5
|
-
"packageManager": "bun@1.3.
|
|
4
|
+
"version": "0.4.0",
|
|
5
|
+
"packageManager": "bun@1.3.13",
|
|
6
6
|
"main": "./nuxt.config.ts",
|
|
7
7
|
"types": "./index.d.ts",
|
|
8
8
|
"exports": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@formkit/tempo": "1.0.0",
|
|
23
|
-
"@iconify-json/lucide": "1.2.
|
|
23
|
+
"@iconify-json/lucide": "1.2.103",
|
|
24
24
|
"@nuxt/kit": "4.4.2",
|
|
25
25
|
"@nuxt/ui": "4.6.1",
|
|
26
26
|
"@nuxtjs/i18n": "10.2.4",
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
<script setup>
|
|
2
|
-
|
|
3
|
-
/* interface */
|
|
4
|
-
|
|
5
|
-
const props = defineProps({
|
|
6
|
-
field: Object,
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
const modelValue = defineModel();
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
/* media */
|
|
13
|
-
|
|
14
|
-
const { data: media, pending } = useUFetch(
|
|
15
|
-
computed(() => `/media/${modelValue.value}`),
|
|
16
|
-
{
|
|
17
|
-
method: computed(() => !modelValue.value ? '' : 'get'),
|
|
18
|
-
},
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const fieldTitle = computed(() => {
|
|
23
|
-
return media.value?.name;
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
/* upload */
|
|
28
|
-
|
|
29
|
-
const isUploading = ref(false);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const { open: openFilePicker, onChange, reset: resetFilePicker } = useFileDialog({
|
|
33
|
-
accept: () => props.field.accept,
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
onChange(async files => {
|
|
38
|
-
|
|
39
|
-
const file = files?.[0];
|
|
40
|
-
|
|
41
|
-
if (!file) {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const body = new FormData();
|
|
47
|
-
body.append('file', file);
|
|
48
|
-
|
|
49
|
-
const response = await ufetch('/media/upload', {
|
|
50
|
-
loading: isUploading,
|
|
51
|
-
method: 'post',
|
|
52
|
-
body,
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
modelValue.value = response?._id;
|
|
57
|
-
resetFilePicker();
|
|
58
|
-
|
|
59
|
-
toastSuccess({
|
|
60
|
-
title: $t('un.media.uploadSuccess'),
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
</script>
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
<template>
|
|
69
|
-
<u-form-field v-bind="radPick(props.field, [ 'label', 'hint', 'help', 'description' ])">
|
|
70
|
-
<div class="flex items-start gap-2 ltr">
|
|
71
|
-
|
|
72
|
-
<!-- <template v-if="media?.type?.startsWith('image')">
|
|
73
|
-
<u-popover mode="hover">
|
|
74
|
-
|
|
75
|
-
<img
|
|
76
|
-
:src="makeMediaFullPath(media?.path)"
|
|
77
|
-
class="size-8 rounded object-cover"
|
|
78
|
-
/>
|
|
79
|
-
|
|
80
|
-
<template #content>
|
|
81
|
-
<img
|
|
82
|
-
:src="makeMediaFullPath(media?.path)"
|
|
83
|
-
class="w-64 rounded"
|
|
84
|
-
/>
|
|
85
|
-
</template>
|
|
86
|
-
|
|
87
|
-
</u-popover>
|
|
88
|
-
</template> -->
|
|
89
|
-
|
|
90
|
-
<u-input
|
|
91
|
-
class="w-full ltr"
|
|
92
|
-
icon="lucide:file"
|
|
93
|
-
v-bind="radOmit(props.field, [ 'key', 'identifier', 'label', 'hint', 'help', 'description' ])"
|
|
94
|
-
readonly
|
|
95
|
-
:loading="pending || isUploading"
|
|
96
|
-
:model-value="fieldTitle"
|
|
97
|
-
@click="openFilePicker()"
|
|
98
|
-
/>
|
|
99
|
-
|
|
100
|
-
</div>
|
|
101
|
-
</u-form-field>
|
|
102
|
-
</template>
|