@mythpe/quasar-ui-qui 0.2.64 → 0.2.65
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
|
@@ -31,6 +31,7 @@ interface P {
|
|
|
31
31
|
images?: Props['images'];
|
|
32
32
|
svg?: Props['svg'];
|
|
33
33
|
video?: Props['video'];
|
|
34
|
+
audio?: Props['audio'];
|
|
34
35
|
pdf?: Props['pdf'];
|
|
35
36
|
excel?: Props['excel'];
|
|
36
37
|
autoUpload?: Props['autoUpload'];
|
|
@@ -61,6 +62,9 @@ interface P {
|
|
|
61
62
|
shadow?: Props['shadow'];
|
|
62
63
|
fieldOptions?: Props['fieldOptions'];
|
|
63
64
|
mediaLabel?: Props['mediaLabel'];
|
|
65
|
+
ratio?: Props['ratio'];
|
|
66
|
+
videoProps?: Props['videoProps'];
|
|
67
|
+
audioProps?: Props['audioProps'];
|
|
64
68
|
}
|
|
65
69
|
|
|
66
70
|
const props = withDefaults(defineProps<P>(), {
|
|
@@ -78,6 +82,7 @@ const props = withDefaults(defineProps<P>(), {
|
|
|
78
82
|
images: () => !1,
|
|
79
83
|
svg: () => !1,
|
|
80
84
|
video: () => !1,
|
|
85
|
+
audio: () => !1,
|
|
81
86
|
pdf: () => !1,
|
|
82
87
|
excel: () => !1,
|
|
83
88
|
autoUpload: () => !0,
|
|
@@ -93,9 +98,9 @@ const props = withDefaults(defineProps<P>(), {
|
|
|
93
98
|
updateBtn: () => !1,
|
|
94
99
|
service: undefined,
|
|
95
100
|
modelId: undefined,
|
|
96
|
-
defaultFileIcon:
|
|
97
|
-
deleteMediaIcon:
|
|
98
|
-
uploadFilesIcon:
|
|
101
|
+
defaultFileIcon: 'ion-ios-document',
|
|
102
|
+
deleteMediaIcon: 'ion-ios-trash',
|
|
103
|
+
uploadFilesIcon: 'ion-cloud-upload',
|
|
99
104
|
pickFilesIcon: () => 'o_upload_file',
|
|
100
105
|
removeUploadedIcon: () => 'o_done_all',
|
|
101
106
|
removeQueuedIcon: () => 'o_clear_all',
|
|
@@ -107,7 +112,10 @@ const props = withDefaults(defineProps<P>(), {
|
|
|
107
112
|
displayMode: () => 'card',
|
|
108
113
|
shadow: () => 'shadow-5',
|
|
109
114
|
fieldOptions: undefined,
|
|
110
|
-
mediaLabel: () => 'name'
|
|
115
|
+
mediaLabel: () => 'name',
|
|
116
|
+
ratio: 16 / 9,
|
|
117
|
+
videoProps: undefined,
|
|
118
|
+
audioProps: undefined
|
|
111
119
|
})
|
|
112
120
|
|
|
113
121
|
type Emits = {
|
|
@@ -141,7 +149,7 @@ watch(field, v => (modelValue.value = v), { deep: !0 })
|
|
|
141
149
|
const { error, setErrors } = useError(() => props.name)
|
|
142
150
|
const resetForm = useResetForm<Form>()
|
|
143
151
|
const formValues = useFormValues<Form>()
|
|
144
|
-
const { fields: attachments } = useFieldArray<MUploaderMediaItem
|
|
152
|
+
const { fields: attachments } = useFieldArray<MUploaderMediaItem & File>(() => props.name)
|
|
145
153
|
|
|
146
154
|
// const setFormValues = useSetFormValues()
|
|
147
155
|
// const setFormTouched = useSetFormTouched()
|
|
@@ -466,6 +474,7 @@ defineOptions({
|
|
|
466
474
|
:key="`fi-${i}`"
|
|
467
475
|
>
|
|
468
476
|
<MUploaderItem
|
|
477
|
+
:audio-props="audioProps"
|
|
469
478
|
:collection="collection"
|
|
470
479
|
:default-file-icon="defaultFileIcon"
|
|
471
480
|
:delete-media-icon="deleteMediaIcon"
|
|
@@ -477,9 +486,11 @@ defineOptions({
|
|
|
477
486
|
:model-id="modelIdProp"
|
|
478
487
|
:model-value="file"
|
|
479
488
|
:name="name"
|
|
489
|
+
:ratio="ratio"
|
|
480
490
|
:return-type="returnType"
|
|
481
491
|
:scope="scope"
|
|
482
492
|
:service="service"
|
|
493
|
+
:video-props="videoProps"
|
|
483
494
|
@remove-file="onDeleteUploaderFile"
|
|
484
495
|
@delete-media="onDeleteMedia"
|
|
485
496
|
/>
|
|
@@ -18,11 +18,11 @@ import { useQuasar } from 'quasar'
|
|
|
18
18
|
import { useMyth } from '../../composable'
|
|
19
19
|
import { useI18n } from 'vue-i18n'
|
|
20
20
|
|
|
21
|
-
type ModelValue = MUploaderMediaItem
|
|
21
|
+
type ModelValue = MUploaderMediaItem & File & {
|
|
22
22
|
__sizeLabel?: string;
|
|
23
23
|
__progressLabel?: string;
|
|
24
24
|
__status?: string;
|
|
25
|
-
__img?:
|
|
25
|
+
__img?: any;
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
interface P {
|
|
@@ -41,6 +41,9 @@ interface P {
|
|
|
41
41
|
deleteMediaIcon?: Props['deleteMediaIcon'];
|
|
42
42
|
downloadFileIcon?: Props['downloadFileIcon'];
|
|
43
43
|
mediaLabel?: Props['mediaLabel'];
|
|
44
|
+
ratio?: Props['ratio'];
|
|
45
|
+
videoProps?: Props['videoProps'];
|
|
46
|
+
audioProps?: Props['audioProps'];
|
|
44
47
|
}
|
|
45
48
|
|
|
46
49
|
const props = withDefaults(defineProps<P>(), {
|
|
@@ -58,7 +61,10 @@ const props = withDefaults(defineProps<P>(), {
|
|
|
58
61
|
defaultFileIcon: undefined,
|
|
59
62
|
deleteMediaIcon: undefined,
|
|
60
63
|
downloadFileIcon: undefined,
|
|
61
|
-
mediaLabel: () => ''
|
|
64
|
+
mediaLabel: () => '',
|
|
65
|
+
ratio: 16 / 9,
|
|
66
|
+
videoProps: undefined,
|
|
67
|
+
audioProps: undefined
|
|
62
68
|
})
|
|
63
69
|
const modelValue = defineModel<ModelValue>({ required: !0, default: () => ({} as ModelValue) })
|
|
64
70
|
const mediaProp = computed<MUploaderMediaItem>(() => modelValue.value as MUploaderMediaItem)
|
|
@@ -158,7 +164,7 @@ defineOptions({
|
|
|
158
164
|
<q-item
|
|
159
165
|
:class="displayMode === 'card' ? `rounded-borders ${shadow || 'shadow-1'}` : undefined"
|
|
160
166
|
:dense="displayMode === 'card'"
|
|
161
|
-
:style="displayMode === 'card' ? 'max-width:
|
|
167
|
+
:style="displayMode === 'card' ? 'max-width: 350px; min-width: 200px;' : undefined"
|
|
162
168
|
>
|
|
163
169
|
<q-item-section
|
|
164
170
|
v-if="displayMode === 'list'"
|
|
@@ -169,10 +175,14 @@ defineOptions({
|
|
|
169
175
|
v-if="!!mediaProp.icon"
|
|
170
176
|
:name="mediaProp.icon"
|
|
171
177
|
:size="iconsSize"
|
|
172
|
-
|
|
178
|
+
/>
|
|
179
|
+
<q-icon
|
|
180
|
+
v-else-if="!!modelValue.icon"
|
|
181
|
+
:name="modelValue.icon"
|
|
182
|
+
:size="iconsSize"
|
|
173
183
|
/>
|
|
174
184
|
<q-img
|
|
175
|
-
v-else-if="!!modelValue.__img || (mediaProp.url && modelValue.
|
|
185
|
+
v-else-if="!!modelValue.__img || (mediaProp.url && modelValue.is_image)"
|
|
176
186
|
:ratio="1"
|
|
177
187
|
:src="modelValue.__img ? modelValue.__img.src : mediaProp.url"
|
|
178
188
|
fit="contain"
|
|
@@ -180,9 +190,10 @@ defineOptions({
|
|
|
180
190
|
/>
|
|
181
191
|
<q-icon
|
|
182
192
|
v-else
|
|
183
|
-
:name="modelValue.
|
|
193
|
+
:name="modelValue.is_pdf ? 'far fa-file-pdf' : (
|
|
194
|
+
modelValue.is_excel ? 'far fa-file-excel' :
|
|
195
|
+
modelValue.is_audio ? 'ion-ios-musical-notes' : ( modelValue.is_video ? 'ion-ios-videocam' : (modelValue.is_image ? 'ion-ios-image' :defaultFileIcon )))"
|
|
184
196
|
:size="props.iconsSize"
|
|
185
|
-
color="primary"
|
|
186
197
|
/>
|
|
187
198
|
</q-item-section>
|
|
188
199
|
<q-item-section :class="{'overflow-hidden': displayMode === 'card'}">
|
|
@@ -191,8 +202,7 @@ defineOptions({
|
|
|
191
202
|
<q-icon
|
|
192
203
|
v-if="updateBtn"
|
|
193
204
|
class="cursor-pointer"
|
|
194
|
-
|
|
195
|
-
name="o_edit"
|
|
205
|
+
name="ion-ios-create"
|
|
196
206
|
right
|
|
197
207
|
>
|
|
198
208
|
<q-popup-edit
|
|
@@ -262,7 +272,7 @@ defineOptions({
|
|
|
262
272
|
caption
|
|
263
273
|
class="print-hide"
|
|
264
274
|
>
|
|
265
|
-
<span v-if="!!mediaProp.size_to_string">{{ mediaProp.size_to_string }} | {{ modelValue.type }}</span>
|
|
275
|
+
<span v-if="!!mediaProp.size_to_string">{{ mediaProp.size_to_string }} | {{ modelValue.type_to_string || modelValue.type }}</span>
|
|
266
276
|
<span v-if="modelValue.__sizeLabel">{{ modelValue.__sizeLabel }} / {{ modelValue.__progressLabel }}</span>
|
|
267
277
|
</q-item-label>
|
|
268
278
|
<q-item-label
|
|
@@ -296,6 +306,30 @@ defineOptions({
|
|
|
296
306
|
</q-tooltip>
|
|
297
307
|
</q-btn>
|
|
298
308
|
</q-item-label>
|
|
309
|
+
<q-item-label v-if="modelValue.is_audio">
|
|
310
|
+
<audio controls>
|
|
311
|
+
<source
|
|
312
|
+
v-if="!!modelValue.url"
|
|
313
|
+
:src="modelValue.url"
|
|
314
|
+
:type="modelValue.mime_type"
|
|
315
|
+
v-bind="audioProps"
|
|
316
|
+
>
|
|
317
|
+
Your browser does not support the audio element.
|
|
318
|
+
</audio>
|
|
319
|
+
</q-item-label>
|
|
320
|
+
<q-item-label v-if="modelValue.is_video">
|
|
321
|
+
<div
|
|
322
|
+
class="col-12 items-center self-center"
|
|
323
|
+
style="min-height: 120px;width: 100%"
|
|
324
|
+
>
|
|
325
|
+
<q-video
|
|
326
|
+
v-if="!!modelValue.url"
|
|
327
|
+
:ratio="ratio"
|
|
328
|
+
:src="modelValue.url"
|
|
329
|
+
v-bind="videoProps"
|
|
330
|
+
/>
|
|
331
|
+
</div>
|
|
332
|
+
</q-item-label>
|
|
299
333
|
</q-item-section>
|
|
300
334
|
</q-item>
|
|
301
335
|
</template>
|
|
@@ -3,7 +3,6 @@ import { computed, ref, toValue, useAttrs } from 'vue'
|
|
|
3
3
|
import { useI18n } from 'vue-i18n'
|
|
4
4
|
import { useMyth } from './useMyth'
|
|
5
5
|
import type { MythComponentsProps as UiOpt } from '../types/plugin-props-option'
|
|
6
|
-
import { biRadar } from '@quasar/extras/bootstrap-icons'
|
|
7
6
|
|
|
8
7
|
type G = { name: string; [k: string]: any };
|
|
9
8
|
type OptsContext = { choose?: boolean; };
|
|
@@ -143,7 +142,14 @@ export const useBindInput = <P extends G = G> (Props: MaybeRefOrGetter<P>, key:
|
|
|
143
142
|
if (typeof props.video === 'string' && props.video?.length > 0) {
|
|
144
143
|
l.push(props.video)
|
|
145
144
|
} else {
|
|
146
|
-
l.push('video
|
|
145
|
+
l.push('video/*')
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
if (props.audio) {
|
|
149
|
+
if (typeof props.audio === 'string' && props.audio?.length > 0) {
|
|
150
|
+
l.push(props.audio)
|
|
151
|
+
} else {
|
|
152
|
+
l.push('audio/*')
|
|
147
153
|
}
|
|
148
154
|
}
|
|
149
155
|
if (props.pdf) {
|
|
@@ -7,17 +7,20 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import type { HelpersStubSchema } from '../api-helpers'
|
|
10
|
-
import type { QUploaderProps, QUploaderSlots } from 'quasar'
|
|
10
|
+
import type { QUploaderProps, QUploaderSlots, QVideoProps } from 'quasar'
|
|
11
11
|
import type { VNode } from 'vue'
|
|
12
12
|
import type { MColProps } from './MCol'
|
|
13
13
|
import type { BaseInputsProps } from './MInput'
|
|
14
14
|
|
|
15
|
-
export type
|
|
15
|
+
export type MediaType = 'image' | 'video' | 'audio' | 'pdf' | 'excel' | 'other';
|
|
16
|
+
|
|
17
|
+
export interface MUploaderMediaItem {
|
|
16
18
|
id: number;
|
|
17
19
|
value: number;
|
|
18
20
|
name: string;
|
|
19
21
|
file_name: string;
|
|
20
|
-
type:
|
|
22
|
+
type: MediaType;
|
|
23
|
+
type_to_string: string;
|
|
21
24
|
size: number;
|
|
22
25
|
size_to_string: string;
|
|
23
26
|
url: string;
|
|
@@ -25,13 +28,24 @@ export type MUploaderMediaItem = {
|
|
|
25
28
|
icon: string;
|
|
26
29
|
description: string;
|
|
27
30
|
attachment_type: string;
|
|
28
|
-
|
|
31
|
+
collection_to_string: string;
|
|
32
|
+
attachment_type_id: number | null;
|
|
29
33
|
attachment_type_id_to_string: string;
|
|
30
34
|
user_id: number | null;
|
|
31
35
|
user_id_to_string: string;
|
|
32
36
|
order_column: number;
|
|
37
|
+
original_url: boolean;
|
|
38
|
+
preview_url: boolean;
|
|
39
|
+
model_type_to_string: boolean;
|
|
40
|
+
is_image: boolean;
|
|
41
|
+
is_pdf: boolean;
|
|
42
|
+
is_excel: boolean;
|
|
43
|
+
is_video: boolean;
|
|
44
|
+
is_audio: boolean;
|
|
45
|
+
|
|
33
46
|
[k: string]: any;
|
|
34
|
-
}
|
|
47
|
+
}
|
|
48
|
+
|
|
35
49
|
export type MUploaderServiceType = Pick<HelpersStubSchema, 'getUploadAttachmentsUrl' | 'updateAttachment' | 'uploadAttachments' | 'deleteAttachment'>
|
|
36
50
|
export type MUploaderProps = Omit<QUploaderProps, 'formFields' | 'headers' | 'url'> & MColProps & Pick<BaseInputsProps, 'fieldOptions'> & {
|
|
37
51
|
/**
|
|
@@ -48,7 +62,7 @@ export type MUploaderProps = Omit<QUploaderProps, 'formFields' | 'headers' | 'ur
|
|
|
48
62
|
*/
|
|
49
63
|
readonly?: boolean;
|
|
50
64
|
/**
|
|
51
|
-
* Comma separated list of unique file type specifiers. Maps to 'accept' attribute of native input type=file element
|
|
65
|
+
* Comma separated a list of unique file type specifiers. Maps to 'accept' attribute of native input type=file element
|
|
52
66
|
*/
|
|
53
67
|
accept?: string;
|
|
54
68
|
/**
|
|
@@ -64,11 +78,15 @@ export type MUploaderProps = Omit<QUploaderProps, 'formFields' | 'headers' | 'ur
|
|
|
64
78
|
*/
|
|
65
79
|
video?: boolean;
|
|
66
80
|
/**
|
|
67
|
-
* Support for uploading
|
|
81
|
+
* Support for uploading audio
|
|
82
|
+
*/
|
|
83
|
+
audio?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Support for uploading PDF
|
|
68
86
|
*/
|
|
69
87
|
pdf?: boolean;
|
|
70
88
|
/**
|
|
71
|
-
* Support for uploading
|
|
89
|
+
* Support for uploading Excel
|
|
72
90
|
*/
|
|
73
91
|
excel?: boolean;
|
|
74
92
|
/**
|
|
@@ -145,6 +163,9 @@ export type MUploaderProps = Omit<QUploaderProps, 'formFields' | 'headers' | 'ur
|
|
|
145
163
|
* Default is: name.
|
|
146
164
|
*/
|
|
147
165
|
mediaLabel?: string | undefined;
|
|
166
|
+
ratio?: QVideoProps['ratio'];
|
|
167
|
+
videoProps?: Omit<QVideoProps, 'ratio' | 'src'>;
|
|
168
|
+
audioProps?: any;
|
|
148
169
|
}
|
|
149
170
|
export type MUploaderSlots = QUploaderSlots & {
|
|
150
171
|
/**
|