@hostlink/nuxt-light 1.1.4 → 1.1.5
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
|
@@ -3,7 +3,6 @@ import { computed, ref } from "vue";
|
|
|
3
3
|
import { useLight } from '#imports';
|
|
4
4
|
import { type QSelectProps } from "quasar";
|
|
5
5
|
import { useI18n } from "vue-i18n";
|
|
6
|
-
import { normalizeOptions } from "@formkit/inputs"
|
|
7
6
|
|
|
8
7
|
const emits = defineEmits(["update:modelValue"]);
|
|
9
8
|
|
|
@@ -44,7 +43,40 @@ if (props.required) {
|
|
|
44
43
|
});
|
|
45
44
|
}
|
|
46
45
|
|
|
47
|
-
|
|
46
|
+
function normalizeOptions(options: any, i = { count: 1 }) {
|
|
47
|
+
if (Array.isArray(options)) {
|
|
48
|
+
return options.map(
|
|
49
|
+
(option): any => {
|
|
50
|
+
if (typeof option === 'string' || typeof option === 'number') {
|
|
51
|
+
return {
|
|
52
|
+
label: String(option),
|
|
53
|
+
value: String(option),
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (typeof option == 'object') {
|
|
57
|
+
if ('group' in option) {
|
|
58
|
+
option.options = normalizeOptions(option.options || [], i)
|
|
59
|
+
return option as any
|
|
60
|
+
} else if ('value' in option && typeof option.value !== 'string') {
|
|
61
|
+
Object.assign(option, {
|
|
62
|
+
value: option.value,
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return option as any
|
|
67
|
+
}
|
|
68
|
+
) as any
|
|
69
|
+
}
|
|
70
|
+
return Object.keys(options).map((value: string) => {
|
|
71
|
+
return {
|
|
72
|
+
label: options[value],
|
|
73
|
+
value,
|
|
74
|
+
}
|
|
75
|
+
})
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
const select_options = ref(props.options);
|
|
48
80
|
|
|
49
81
|
const filterFn = (val, update, abort) => {
|
|
50
82
|
|
|
@@ -91,11 +123,15 @@ const attrs = computed(() => {
|
|
|
91
123
|
|
|
92
124
|
const localValue = computed({
|
|
93
125
|
get: () => props.modelValue,
|
|
94
|
-
set: (value) =>
|
|
126
|
+
set: (value) => {
|
|
127
|
+
emits('update:modelValue', value)
|
|
128
|
+
}
|
|
95
129
|
});
|
|
96
130
|
|
|
131
|
+
|
|
97
132
|
</script>
|
|
98
133
|
<template>
|
|
134
|
+
{{ select_options }}
|
|
99
135
|
<q-select v-bind="attrs" v-model="localValue" :options="select_options" @filter="filterFn" :option-label="optionLabel"
|
|
100
136
|
hide-bottom-space :rules="rules" :clearable="clearable" />
|
|
101
137
|
</template>
|