@mythpe/quasar-ui-qui 0.4.96 → 0.4.97
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/package.json
CHANGED
|
@@ -23,6 +23,7 @@ type P = {
|
|
|
23
23
|
label?: Props['label'];
|
|
24
24
|
placeholder?: Props['placeholder'];
|
|
25
25
|
viewMode?: Props['viewMode'];
|
|
26
|
+
viewModeKey?: Props['viewModeKey'];
|
|
26
27
|
viewModeValue?: Props['viewModeValue'];
|
|
27
28
|
service?: Props['service'];
|
|
28
29
|
guest?: Props['guest'];
|
|
@@ -42,6 +43,7 @@ const props = withDefaults(defineProps<P>(), {
|
|
|
42
43
|
label: undefined,
|
|
43
44
|
placeholder: undefined,
|
|
44
45
|
viewMode: !1,
|
|
46
|
+
viewModeKey: undefined,
|
|
45
47
|
viewModeValue: undefined,
|
|
46
48
|
service: undefined,
|
|
47
49
|
guest: undefined,
|
|
@@ -193,6 +195,7 @@ defineOptions({ name: 'MAxios', inheritAttrs: !1 })
|
|
|
193
195
|
:placeholder="placeholder"
|
|
194
196
|
:required="required"
|
|
195
197
|
:view-mode="viewMode"
|
|
198
|
+
:view-mode-key="viewModeKey"
|
|
196
199
|
:view-mode-value="viewModeValue"
|
|
197
200
|
axios-mode
|
|
198
201
|
no-filter
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
setup
|
|
12
12
|
>
|
|
13
13
|
|
|
14
|
-
import { useField } from 'vee-validate'
|
|
14
|
+
import { useField, useFieldValue } from 'vee-validate'
|
|
15
15
|
import type { MSelectProps as Props } from '../../types'
|
|
16
16
|
import { computed, reactive, ref, toValue, useTemplateRef } from 'vue'
|
|
17
17
|
import { useBindInput, useMyth } from '../../composable'
|
|
@@ -35,6 +35,7 @@ type P = {
|
|
|
35
35
|
required?: Props['required'];
|
|
36
36
|
rules?: Props['rules'];
|
|
37
37
|
viewMode?: Props['viewMode'];
|
|
38
|
+
viewModeKey?: Props['viewModeKey'];
|
|
38
39
|
viewModeValue?: Props['viewModeValue'];
|
|
39
40
|
autocomplete?: Props['autocomplete'];
|
|
40
41
|
topLabel?: Props['topLabel'];
|
|
@@ -83,6 +84,7 @@ const props = withDefaults(defineProps<P>(), {
|
|
|
83
84
|
required: undefined,
|
|
84
85
|
rules: undefined,
|
|
85
86
|
viewMode: !1,
|
|
87
|
+
viewModeKey: undefined,
|
|
86
88
|
viewModeValue: undefined,
|
|
87
89
|
autocomplete: undefined,
|
|
88
90
|
topLabel: undefined,
|
|
@@ -187,25 +189,43 @@ const listeners = {
|
|
|
187
189
|
}
|
|
188
190
|
const input = useTemplateRef<InstanceType<typeof QSelect> | InstanceType<typeof QField>>('input')
|
|
189
191
|
const scopes = reactive(inputScope)
|
|
192
|
+
|
|
193
|
+
const viewModeAttribute = useFieldValue(() => props.viewModeKey || props.name)
|
|
190
194
|
const getViewModeValue = computed(() => {
|
|
195
|
+
if (!props.viewMode) {
|
|
196
|
+
return undefined
|
|
197
|
+
}
|
|
191
198
|
if (props.viewMode && props.loading) {
|
|
192
199
|
return '...'
|
|
193
200
|
}
|
|
194
|
-
if (props.viewModeValue
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
201
|
+
if (props.viewModeValue !== undefined) {
|
|
202
|
+
return props.viewModeValue
|
|
203
|
+
}
|
|
204
|
+
if (props.viewModeKey) {
|
|
205
|
+
return viewModeAttribute.value
|
|
206
|
+
}
|
|
207
|
+
if (props.loading) {
|
|
208
|
+
return '...'
|
|
209
|
+
}
|
|
210
|
+
if (props.multiple) {
|
|
211
|
+
const opts = getOptions.value?.filter((opt) => {
|
|
212
|
+
const k = props.optionValue === undefined ? 'value' : (typeof props.optionValue === 'function' ? props.optionValue(opt) : props.optionValue)
|
|
213
|
+
return value.value?.includes?.(opt[k])
|
|
214
|
+
}).map((opt) => {
|
|
215
|
+
const k = props.optionLabel === undefined ? 'label' : (typeof props.optionLabel === 'function' ? props.optionLabel(opt) : props.optionLabel)
|
|
216
|
+
return opt[k]
|
|
200
217
|
})
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
218
|
+
return opts?.length ? opts?.join(', ') : '-'
|
|
219
|
+
}
|
|
220
|
+
const opt = getOptions.value?.find((e) => {
|
|
221
|
+
const k = props.optionValue === undefined ? 'value' : (typeof props.optionValue === 'function' ? props.optionValue(e) : props.optionValue)
|
|
222
|
+
return e[k] === value.value
|
|
223
|
+
})
|
|
224
|
+
if (opt) {
|
|
225
|
+
const k = props.optionLabel === undefined ? 'label' : (typeof props.optionLabel === 'function' ? props.optionLabel(opt) : props.optionLabel)
|
|
226
|
+
return opt[k]
|
|
207
227
|
}
|
|
208
|
-
return
|
|
228
|
+
return undefined
|
|
209
229
|
})
|
|
210
230
|
defineExpose<typeof scopes & {
|
|
211
231
|
input: typeof input,
|