@mythpe/quasar-ui-qui 0.1.60 → 0.1.62
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
|
@@ -82,7 +82,7 @@ const props = withDefaults(defineProps<P>(), {
|
|
|
82
82
|
loading: !1,
|
|
83
83
|
required: undefined,
|
|
84
84
|
rules: () => ({}),
|
|
85
|
-
contentClass:
|
|
85
|
+
contentClass: 'items-center',
|
|
86
86
|
emptyColor: 'grey-2',
|
|
87
87
|
btnLabel: 'choose_file'
|
|
88
88
|
})
|
|
@@ -90,7 +90,7 @@ type Emits = {
|
|
|
90
90
|
(e: 'click', evt?: Event): void;
|
|
91
91
|
}
|
|
92
92
|
const emit = defineEmits<Emits>()
|
|
93
|
-
const { __ } = useMyth()
|
|
93
|
+
const { __, openWindow } = useMyth()
|
|
94
94
|
const { accepts, inputRules } = useBindInput<any>(() => props, 'avatarViewer')
|
|
95
95
|
const modelValueScope = useField<Props['modelValue']>(() => props.name, inputRules, {
|
|
96
96
|
syncVModel: !0
|
|
@@ -139,7 +139,16 @@ const isFile = computed(() => {
|
|
|
139
139
|
}
|
|
140
140
|
return modelValue.value instanceof File && modelValue.value?.type.slice(0, 6) !== 'image/'
|
|
141
141
|
})
|
|
142
|
-
const
|
|
142
|
+
const getFileType = computed(() => (type: string) => {
|
|
143
|
+
if (modelValue.value instanceof File) {
|
|
144
|
+
return modelValue.value?.type.slice(0, type.length) === type || modelValue.value?.type.slice(-1 * type.length) === type
|
|
145
|
+
}
|
|
146
|
+
return url.value?.slice(-1 * type.length) === type
|
|
147
|
+
})
|
|
148
|
+
const isImage = computed(() => getFileType.value('image/'))
|
|
149
|
+
// const isPdf = computed(() => getFileType.value('pdf'))
|
|
150
|
+
const isFileNotImage = computed(() => hasSrc.value && !isImage.value)
|
|
151
|
+
const getAvatarText = computed<string | undefined>(() => props.avatarText ? props.avatarText.slice(0, 1).toUpperCase() : undefined)
|
|
143
152
|
const loadingSrc = ref(!1)
|
|
144
153
|
const onClick = (e?: Event) => {
|
|
145
154
|
if (props.readonly) {
|
|
@@ -169,6 +178,14 @@ const onClearInput = () => {
|
|
|
169
178
|
handleRemoved(!0, !1)
|
|
170
179
|
handleUrl(undefined, !1)
|
|
171
180
|
}
|
|
181
|
+
const hideImage = ref(!1)
|
|
182
|
+
const onLoadImage = () => {
|
|
183
|
+
isLoaded.value = !0
|
|
184
|
+
}
|
|
185
|
+
const onErrorImage = () => {
|
|
186
|
+
isLoaded.value = !0
|
|
187
|
+
hideImage.value = !0
|
|
188
|
+
}
|
|
172
189
|
onBeforeUnmount(() => {
|
|
173
190
|
revoke()
|
|
174
191
|
removeFile()
|
|
@@ -204,7 +221,7 @@ defineOptions({
|
|
|
204
221
|
<slot name="top" />
|
|
205
222
|
<MTransition>
|
|
206
223
|
<div
|
|
207
|
-
v-if="
|
|
224
|
+
v-if="label !== undefined"
|
|
208
225
|
key="label"
|
|
209
226
|
class="row items-center"
|
|
210
227
|
>
|
|
@@ -218,7 +235,7 @@ defineOptions({
|
|
|
218
235
|
v-else
|
|
219
236
|
:class="`text-h6 q-px-sm rounded-borders q-mb-sm ${!!errorMessage ? 'text-negative' : ''}`"
|
|
220
237
|
>
|
|
221
|
-
{{ __(label) }}
|
|
238
|
+
{{ label ? __(label) : label }}
|
|
222
239
|
<span
|
|
223
240
|
v-if="required && !readonly"
|
|
224
241
|
class="text-negative"
|
|
@@ -232,12 +249,12 @@ defineOptions({
|
|
|
232
249
|
</div>
|
|
233
250
|
<slot name="hint">
|
|
234
251
|
<div
|
|
235
|
-
v-if="
|
|
252
|
+
v-if="hint !== undefined && !loading"
|
|
236
253
|
key="hint"
|
|
237
254
|
class="m--input__hint"
|
|
238
255
|
v-bind="hintProps"
|
|
239
256
|
>
|
|
240
|
-
<span>{{ __(hint) }}</span>
|
|
257
|
+
<span>{{ hint ? __(hint) : hint }}</span>
|
|
241
258
|
</div>
|
|
242
259
|
</slot>
|
|
243
260
|
<div
|
|
@@ -251,20 +268,20 @@ defineOptions({
|
|
|
251
268
|
/>
|
|
252
269
|
<q-avatar
|
|
253
270
|
v-else
|
|
254
|
-
:color="
|
|
255
|
-
:icon="
|
|
271
|
+
:color="errorMessage ? 'negative' : ((!isLoaded || !hasSrc || isFile || isFileNotImage) ? emptyColor : undefined)"
|
|
272
|
+
:icon="isFileNotImage ? 'o_description' : undefined"
|
|
256
273
|
:rounded="rounded"
|
|
257
274
|
:size="size"
|
|
258
275
|
text-color="white"
|
|
259
276
|
>
|
|
260
277
|
<q-img
|
|
261
|
-
v-if="hasSrc && !isFile"
|
|
278
|
+
v-if="hasSrc && !isFile && !hideImage"
|
|
262
279
|
:fit="fit"
|
|
280
|
+
:ratio="1"
|
|
263
281
|
:size="size"
|
|
264
282
|
:src="blobUrl || url"
|
|
265
|
-
|
|
266
|
-
@
|
|
267
|
-
@load="isLoaded = !0"
|
|
283
|
+
@error="onErrorImage"
|
|
284
|
+
@load="onLoadImage"
|
|
268
285
|
>
|
|
269
286
|
<template #loading>
|
|
270
287
|
<div class="text-white">
|
|
@@ -273,7 +290,7 @@ defineOptions({
|
|
|
273
290
|
</template>
|
|
274
291
|
</q-img>
|
|
275
292
|
<div
|
|
276
|
-
v-if="getAvatarText && !hasSrc"
|
|
293
|
+
v-else-if="getAvatarText !== undefined && !hasSrc"
|
|
277
294
|
class="text-white text-h3"
|
|
278
295
|
v-text="getAvatarText"
|
|
279
296
|
/>
|
|
@@ -290,6 +307,7 @@ defineOptions({
|
|
|
290
307
|
/>
|
|
291
308
|
<MBtn
|
|
292
309
|
v-else
|
|
310
|
+
:color="undefined"
|
|
293
311
|
:disable="!isLoaded && !!url"
|
|
294
312
|
:label="'labels.' + ( clearable ? ( hasSrc ? 'remove' : btnLabel ) : ( required ? ( hasSrc ? 'change' : btnLabel ) : btnLabel ) )"
|
|
295
313
|
:loading="loadingSrc"
|
|
@@ -305,6 +323,19 @@ defineOptions({
|
|
|
305
323
|
>
|
|
306
324
|
<span class="text-body2 text-negative">{{ errorMessage }}</span>
|
|
307
325
|
</div>
|
|
326
|
+
<div
|
|
327
|
+
v-if="isFileNotImage && url"
|
|
328
|
+
key="btn-download"
|
|
329
|
+
class="q-mt-lg"
|
|
330
|
+
>
|
|
331
|
+
<MBtn
|
|
332
|
+
:color="undefined"
|
|
333
|
+
icon="ion-ios-download"
|
|
334
|
+
label="labels.download"
|
|
335
|
+
outline
|
|
336
|
+
@click="openWindow(url)"
|
|
337
|
+
/>
|
|
338
|
+
</div>
|
|
308
339
|
</MTransition>
|
|
309
340
|
<slot name="caption">
|
|
310
341
|
<div
|