@hostlink/nuxt-light 1.0.6 → 1.0.7

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "light",
3
3
  "configKey": "light",
4
- "version": "1.0.6"
4
+ "version": "1.0.7"
5
5
  }
@@ -343,19 +343,29 @@ const onUploadFiles = async () => {
343
343
  message: "Uploading files...",
344
344
  });
345
345
 
346
- for (let file of uploadFiles.value) {
347
-
348
- await m("fsUploadFile", {
349
- path: path.value,
350
- file: new VariableType("file")
351
- }, [{
352
- __variables: {
353
- file: {
354
- type: "Upload!",
355
- value: file
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,114 @@
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
+
7
+ const light = useLight();
8
+
9
+ export interface LFileProps {
10
+ modelValue?: string;
11
+ label?: string;
12
+ filled?: boolean;
13
+ outlined?: boolean;
14
+ standout?: boolean;
15
+ rounded?: boolean;
16
+ dense?: boolean;
17
+ square?: boolean;
18
+ stackLabel?: boolean;
19
+ path?: string;
20
+ accept?: string;
21
+ }
22
+
23
+ const props = withDefaults(defineProps<LFileProps>(), {
24
+ filled: undefined,
25
+ outlined: undefined,
26
+ standout: undefined,
27
+ rounded: undefined,
28
+ dense: undefined,
29
+ square: undefined,
30
+ stackLabel: undefined,
31
+ path: "",
32
+ accept: "*",
33
+ });
34
+
35
+ const emit = defineEmits(["update:modelValue"]);
36
+
37
+ const show = ref(false);
38
+
39
+
40
+ const localValue = computed({
41
+ get: () => props.modelValue,
42
+ set: (value) => emit("update:modelValue", value),
43
+ })
44
+
45
+
46
+
47
+ const attrs = computed(() => {
48
+ const a = { ...useAttrs, ...props };
49
+ if (props.filled === undefined) a.filled = light.getStyle("inputFilled");
50
+ if (props.outlined === undefined) a.outlined = light.getStyle("inputOutlined");
51
+ if (props.standout === undefined) a.standout = light.getStyle("inputStandout");
52
+ if (props.rounded === undefined) a.rounded = light.getStyle("inputRounded");
53
+ if (props.dense === undefined) a.dense = light.getStyle("inputDense");
54
+ if (props.square === undefined) a.square = light.getStyle("inputSquare");
55
+ if (props.stackLabel === undefined) a.stackLabel = light.getStyle("inputStackLabel");
56
+ return a;
57
+ });
58
+
59
+ const uploadFile = ref(null);
60
+
61
+ const onUploadFile = async () => {
62
+ Loading.show({
63
+ message: "Uploading file...",
64
+ });
65
+
66
+ try {
67
+ localValue.value = await m("fsUploadFile", {
68
+ path: props.path,
69
+ file: new VariableType("file"),
70
+ rename: true
71
+ }, [{
72
+ __variables: {
73
+ file: {
74
+ type: "Upload!",
75
+ value: uploadFile.value
76
+ }
77
+ }
78
+ }]);
79
+ Loading.hide();
80
+
81
+ show.value = false;
82
+ uploadFile.value = null;
83
+ return;
84
+ } catch (e: any) {
85
+ Dialog.create({
86
+ title: "Error",
87
+ message: e.message,
88
+ });
89
+ }
90
+
91
+
92
+ Loading.hide();
93
+ }
94
+
95
+ </script>
96
+ <template>
97
+ <q-input v-bind="attrs" v-model="localValue" hide-bottom-space>
98
+ <q-dialog v-model="show" persistent transition-show="scale" transition-hide="scale">
99
+ <l-card style="width:300px">
100
+ <q-card-section>
101
+ <q-file ref="file" v-model="uploadFile" name="file" label="Files"></q-file>
102
+ </q-card-section>
103
+
104
+ <q-card-actions align="right">
105
+ <q-btn flat label="Cancel" color="primary" v-close-popup></q-btn>
106
+ <q-btn flat label="Upload" color="primary" @click="onUploadFile"></q-btn>
107
+ </q-card-actions>
108
+ </l-card>
109
+ </q-dialog>
110
+ <template v-slot:prepend>
111
+ <q-btn dense flat round icon="sym_o_file_upload" @click="show = true"></q-btn>
112
+ </template>
113
+ </q-input>
114
+ </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
- const props = defineProps({
8
- modelValue: {
9
- type: String
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
- const attrs = {
29
-
30
- ...{
31
- filled: light.getStyle("inputFilled"),
32
- outlined: light.getStyle("inputOutlined"),
33
- standout: light.getStyle("inputStandout"),
34
- rounded: light.getStyle("inputRounded"),
35
- dense: light.getStyle("inputDense"),
36
- square: light.getStyle("inputSquare"),
37
- stackLabel: light.getStyle("inputStackLabel")
38
- },
39
- ...useAttrs(),
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-model="value" :label="context.label" v-bind="context.attrs" :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
- </l-form>
7
+ <l-card title="Test">
8
+ <q-card-section>
9
+ </q-card-section>
10
+ </l-card>
11
+
28
12
  </l-page>
29
13
  </template>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hostlink/nuxt-light",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "HostLink Nuxt Light Framework",
5
5
  "repository": "@hostlink/nuxt-light",
6
6
  "license": "MIT",