@hostlink/nuxt-light 1.0.6 → 1.0.8
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/l-file-manager.vue +22 -12
- package/dist/runtime/components/l-file-upload.vue +131 -0
- package/dist/runtime/components/l-file.vue +39 -20
- package/dist/runtime/formkit/FileUpload.vue +31 -0
- package/dist/runtime/formkit/index.mjs +6 -0
- package/dist/runtime/pages/System/test.vue +5 -21
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -343,19 +343,29 @@ const onUploadFiles = async () => {
|
|
|
343
343
|
message: "Uploading files...",
|
|
344
344
|
});
|
|
345
345
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
346
|
+
try {
|
|
347
|
+
for (let file of uploadFiles.value) {
|
|
348
|
+
|
|
349
|
+
await m("fsUploadFile", {
|
|
350
|
+
path: path.value,
|
|
351
|
+
file: new VariableType("file")
|
|
352
|
+
}, [{
|
|
353
|
+
__variables: {
|
|
354
|
+
file: {
|
|
355
|
+
type: "Upload!",
|
|
356
|
+
value: file
|
|
357
|
+
}
|
|
356
358
|
}
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
+
}]);
|
|
360
|
+
}
|
|
361
|
+
} catch (e) {
|
|
362
|
+
quasar.dialog({
|
|
363
|
+
title: "Error",
|
|
364
|
+
message: e.message,
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
return;
|
|
368
|
+
|
|
359
369
|
}
|
|
360
370
|
uploadFiles.value = [];
|
|
361
371
|
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { VariableType } from "json-to-graphql-query";
|
|
3
|
+
import { ref, computed, useAttrs } from "vue";
|
|
4
|
+
import { useLight, m } from '#imports';
|
|
5
|
+
import { Loading, Dialog } from "quasar";
|
|
6
|
+
import { useI18n } from "vue-i18n";
|
|
7
|
+
|
|
8
|
+
const light = useLight();
|
|
9
|
+
const i18n = useI18n();
|
|
10
|
+
|
|
11
|
+
export interface LFileProps {
|
|
12
|
+
modelValue?: string;
|
|
13
|
+
label?: string;
|
|
14
|
+
filled?: boolean;
|
|
15
|
+
outlined?: boolean;
|
|
16
|
+
standout?: boolean;
|
|
17
|
+
rounded?: boolean;
|
|
18
|
+
dense?: boolean;
|
|
19
|
+
square?: boolean;
|
|
20
|
+
stackLabel?: boolean;
|
|
21
|
+
path?: string;
|
|
22
|
+
accept?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const props = withDefaults(defineProps<LFileProps>(), {
|
|
26
|
+
filled: undefined,
|
|
27
|
+
outlined: undefined,
|
|
28
|
+
standout: undefined,
|
|
29
|
+
rounded: undefined,
|
|
30
|
+
dense: undefined,
|
|
31
|
+
square: undefined,
|
|
32
|
+
stackLabel: undefined,
|
|
33
|
+
path: "",
|
|
34
|
+
accept: "*",
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const emit = defineEmits(["update:modelValue"]);
|
|
38
|
+
|
|
39
|
+
const show = ref(false);
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
const localValue = computed({
|
|
43
|
+
get: () => props.modelValue,
|
|
44
|
+
set: (value) => emit("update:modelValue", value),
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
const attrs = computed(() => {
|
|
50
|
+
const a = { ...useAttrs, ...props };
|
|
51
|
+
if (props.filled === undefined) a.filled = light.getStyle("inputFilled");
|
|
52
|
+
if (props.outlined === undefined) a.outlined = light.getStyle("inputOutlined");
|
|
53
|
+
if (props.standout === undefined) a.standout = light.getStyle("inputStandout");
|
|
54
|
+
if (props.rounded === undefined) a.rounded = light.getStyle("inputRounded");
|
|
55
|
+
if (props.dense === undefined) a.dense = light.getStyle("inputDense");
|
|
56
|
+
if (props.square === undefined) a.square = light.getStyle("inputSquare");
|
|
57
|
+
if (props.stackLabel === undefined) a.stackLabel = light.getStyle("inputStackLabel");
|
|
58
|
+
return a;
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const uploadFile = ref(null);
|
|
62
|
+
|
|
63
|
+
const onUploadFile = async () => {
|
|
64
|
+
|
|
65
|
+
if (!uploadFile.value) {
|
|
66
|
+
Dialog.create({
|
|
67
|
+
title: "Error",
|
|
68
|
+
message: i18n.t("Please select a file"),
|
|
69
|
+
color: "negative"
|
|
70
|
+
});
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
Loading.show({
|
|
75
|
+
message: i18n.t("Uploading file..."),
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
try {
|
|
79
|
+
let v = await m("fsUploadFile", {
|
|
80
|
+
path: props.path,
|
|
81
|
+
file: new VariableType("file"),
|
|
82
|
+
rename: true
|
|
83
|
+
}, [{
|
|
84
|
+
__variables: {
|
|
85
|
+
file: {
|
|
86
|
+
type: "Upload!",
|
|
87
|
+
value: uploadFile.value
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}]);
|
|
91
|
+
|
|
92
|
+
//remove first slash if exists
|
|
93
|
+
if (v.startsWith("/")) v = v.substr(1);
|
|
94
|
+
|
|
95
|
+
localValue.value = v;
|
|
96
|
+
|
|
97
|
+
Loading.hide();
|
|
98
|
+
|
|
99
|
+
show.value = false;
|
|
100
|
+
uploadFile.value = null;
|
|
101
|
+
return;
|
|
102
|
+
} catch (e: any) {
|
|
103
|
+
Dialog.create({
|
|
104
|
+
title: i18n.t("Error"),
|
|
105
|
+
message: e.message,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
Loading.hide();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
</script>
|
|
114
|
+
<template>
|
|
115
|
+
<q-input v-bind="attrs" v-model="localValue" hide-bottom-space>
|
|
116
|
+
<q-dialog v-model="show" persistent transition-show="scale" transition-hide="scale">
|
|
117
|
+
<l-card style="width:300px">
|
|
118
|
+
<q-card-section>
|
|
119
|
+
<q-file ref="file" v-model="uploadFile" name="file" :label="$t('File')" :accept="accept"></q-file>
|
|
120
|
+
</q-card-section>
|
|
121
|
+
<q-card-actions align="right">
|
|
122
|
+
<q-btn flat :label="$t('Cancel')" color="primary" v-close-popup></q-btn>
|
|
123
|
+
<q-btn flat :label="$t('Upload')" color="primary" @click="onUploadFile"></q-btn>
|
|
124
|
+
</q-card-actions>
|
|
125
|
+
</l-card>
|
|
126
|
+
</q-dialog>
|
|
127
|
+
<template v-slot:prepend>
|
|
128
|
+
<q-btn dense flat round icon="sym_o_file_upload" @click="show = true"></q-btn>
|
|
129
|
+
</template>
|
|
130
|
+
</q-input>
|
|
131
|
+
</template>
|
|
@@ -1,20 +1,36 @@
|
|
|
1
|
-
<script setup>
|
|
1
|
+
<script setup lang="ts">
|
|
2
2
|
import { ref, computed, useAttrs } from "vue";
|
|
3
|
-
import { useLight } from '
|
|
3
|
+
import { useLight } from '#imports';
|
|
4
4
|
|
|
5
5
|
const light = useLight();
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
modelValue
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
export interface LFileProps {
|
|
8
|
+
modelValue?: string;
|
|
9
|
+
label?: string;
|
|
10
|
+
filled?: boolean;
|
|
11
|
+
outlined?: boolean;
|
|
12
|
+
standout?: boolean;
|
|
13
|
+
rounded?: boolean;
|
|
14
|
+
dense?: boolean;
|
|
15
|
+
square?: boolean;
|
|
16
|
+
stackLabel?: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const props = withDefaults(defineProps<LFileProps>(), {
|
|
20
|
+
filled: undefined,
|
|
21
|
+
outlined: undefined,
|
|
22
|
+
standout: undefined,
|
|
23
|
+
rounded: undefined,
|
|
24
|
+
dense: undefined,
|
|
25
|
+
square: undefined,
|
|
26
|
+
stackLabel: undefined,
|
|
11
27
|
});
|
|
12
28
|
|
|
13
29
|
const emit = defineEmits(["update:modelValue"]);
|
|
14
30
|
|
|
15
31
|
const show = ref(false);
|
|
16
32
|
|
|
17
|
-
const onInput = (value) => {
|
|
33
|
+
const onInput = (value: string) => {
|
|
18
34
|
localValue.value = value;
|
|
19
35
|
show.value = false;
|
|
20
36
|
|
|
@@ -25,19 +41,22 @@ const localValue = computed({
|
|
|
25
41
|
set: (value) => emit("update:modelValue", value),
|
|
26
42
|
})
|
|
27
43
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
const attrs = computed(() => {
|
|
47
|
+
const a = { ...useAttrs, ...props };
|
|
48
|
+
if (props.filled === undefined) a.filled = light.getStyle("inputFilled");
|
|
49
|
+
if (props.outlined === undefined) a.outlined = light.getStyle("inputOutlined");
|
|
50
|
+
if (props.standout === undefined) a.standout = light.getStyle("inputStandout");
|
|
51
|
+
if (props.rounded === undefined) a.rounded = light.getStyle("inputRounded");
|
|
52
|
+
if (props.dense === undefined) a.dense = light.getStyle("inputDense");
|
|
53
|
+
if (props.square === undefined) a.square = light.getStyle("inputSquare");
|
|
54
|
+
if (props.stackLabel === undefined) a.stackLabel = light.getStyle("inputStackLabel");
|
|
55
|
+
return a;
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
41
60
|
</script>
|
|
42
61
|
<template>
|
|
43
62
|
<q-input v-bind="attrs" v-model="localValue" hide-bottom-space>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed } from 'vue'
|
|
3
|
+
import { getErrorMessage } from 'formkit-quasar';
|
|
4
|
+
|
|
5
|
+
const props = defineProps({
|
|
6
|
+
context: Object
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
const { error, errorMessage } = getErrorMessage(props.context.node);
|
|
10
|
+
|
|
11
|
+
const value = computed({
|
|
12
|
+
get: () => props.context.value,
|
|
13
|
+
set: (val) => props.context.node.input(val)
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
const onBlur = () => {
|
|
17
|
+
if (errorMessage.value) {
|
|
18
|
+
error.value = true
|
|
19
|
+
} else {
|
|
20
|
+
error.value = false
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
</script>
|
|
24
|
+
<template>
|
|
25
|
+
<l-file-upload v-bind="context.attrs" v-model="value" :label="context.label" :error="error" :type="context.inputType"
|
|
26
|
+
:error-message="errorMessage" @blur="onBlur">
|
|
27
|
+
<template v-for="(s, name) in $slots" v-slot:[name]="props" :key="name">
|
|
28
|
+
<slot :name="name" v-bind="props ?? {}"></slot>
|
|
29
|
+
</template>
|
|
30
|
+
</l-file-upload>
|
|
31
|
+
</template>
|
|
@@ -11,10 +11,16 @@ import OptionGroupVue from "./OptionGroup.vue";
|
|
|
11
11
|
import FilePickerVue from "./FilePicker.vue";
|
|
12
12
|
import FileVue from "./File.vue";
|
|
13
13
|
import InputXlsxVue from "./InputXlsx.vue";
|
|
14
|
+
import FileUploadVue from "./FileUpload.vue";
|
|
14
15
|
export const createLightPlugin = () => {
|
|
15
16
|
return (node) => {
|
|
16
17
|
let type = node.props.type + "";
|
|
17
18
|
switch (type) {
|
|
19
|
+
case "l-file-upload":
|
|
20
|
+
return node.define({
|
|
21
|
+
type: "input",
|
|
22
|
+
component: FileUploadVue
|
|
23
|
+
});
|
|
18
24
|
case "l-input-xlsx":
|
|
19
25
|
return node.define({
|
|
20
26
|
type: "input",
|
|
@@ -1,29 +1,13 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { reactive } from 'vue'
|
|
3
|
-
import { m } from "../../"
|
|
4
|
-
const obj = reactive({
|
|
5
|
-
input1: 'test',
|
|
6
|
-
editor: 'test',
|
|
7
|
-
})
|
|
8
|
-
const onSave = async () => {
|
|
9
|
-
console.log(obj)
|
|
10
|
-
|
|
11
|
-
await m("testSystem", {
|
|
12
|
-
data: obj
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
}
|
|
16
2
|
|
|
17
3
|
</script>
|
|
18
4
|
<template>
|
|
19
5
|
<l-page>
|
|
20
|
-
{{ obj }}
|
|
21
|
-
<l-form v-model="obj">
|
|
22
|
-
<l-input v-model="obj.input1" label="Input1" />
|
|
23
|
-
<q-file v-model="obj.file" label="File" accept=".txt" />
|
|
24
|
-
|
|
25
|
-
<q-editor v-model="obj.editor" />
|
|
26
6
|
|
|
27
|
-
|
|
7
|
+
<l-card title="Test">
|
|
8
|
+
<q-card-section>
|
|
9
|
+
</q-card-section>
|
|
10
|
+
</l-card>
|
|
11
|
+
|
|
28
12
|
</l-page>
|
|
29
13
|
</template>
|