quasar-ui-danx 0.3.21 → 0.3.23

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quasar-ui-danx",
3
- "version": "0.3.21",
3
+ "version": "0.3.23",
4
4
  "author": "Dan <dan@flytedesk.com>",
5
5
  "description": "DanX Vue / Quasar component library",
6
6
  "license": "MIT",
@@ -8,7 +8,6 @@
8
8
  {{ text }}
9
9
  </slot>
10
10
 
11
- {{ "accept: " + ((geolocation && cameraOnly) ? "image/*;capture=camera" : undefined) }}
12
11
  <input
13
12
  ref="fileUpload"
14
13
  data-testid="file-upload"
@@ -30,7 +30,7 @@
30
30
  controls
31
31
  >
32
32
  <source
33
- :src="file.url + '#t=0.1'"
33
+ :src="getPreviewUrl(file) + '#t=0.1'"
34
34
  :type="file.mime"
35
35
  >
36
36
  </video>
@@ -38,7 +38,7 @@
38
38
  <img
39
39
  v-else
40
40
  :alt="file.filename"
41
- :src="file.url"
41
+ :src="getPreviewUrl(file)"
42
42
  >
43
43
  </div>
44
44
  </QCarouselSlide>
@@ -56,54 +56,59 @@ import { XIcon as CloseIcon } from "../../../svg";
56
56
 
57
57
  defineEmits(["close"]);
58
58
  const props = defineProps({
59
- files: {
60
- type: Array,
61
- default: () => []
62
- },
63
- defaultSlide: {
64
- type: String,
65
- default: ""
66
- }
59
+ files: {
60
+ type: Array,
61
+ default: () => []
62
+ },
63
+ defaultSlide: {
64
+ type: String,
65
+ default: ""
66
+ }
67
67
  });
68
68
 
69
69
  const carousel = ref(null);
70
70
  const currentSlide = ref(props.defaultSlide);
71
71
  function isVideo(file) {
72
- return file.mime?.startsWith("video");
72
+ return file.mime?.startsWith("video");
73
73
  }
74
+
75
+ function getPreviewUrl(file) {
76
+ return file.transcodes?.compress?.url || file.blobUrl || file.url;
77
+ }
78
+
74
79
  function getThumbUrl(file) {
75
- if (file.thumb) {
76
- return file.thumb.url;
77
- } else if (isVideo(file)) {
78
- // Base64 encode a PlayIcon for the placeholder image
79
- return `data:image/svg+xml;base64,${btoa(
80
- `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M0 0h24v24H0z" fill="none"/><path d="M8 5v14l11-7z"/></svg>`
81
- )}`;
82
- } else {
83
- return file.url;
84
- }
80
+ if (file.thumb) {
81
+ return file.thumb.url;
82
+ } else if (isVideo(file)) {
83
+ // Base64 encode a PlayIcon for the placeholder image
84
+ return `data:image/svg+xml;base64,${btoa(
85
+ `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M0 0h24v24H0z" fill="none"/><path d="M8 5v14l11-7z"/></svg>`
86
+ )}`;
87
+ } else {
88
+ return getPreviewUrl(file);
89
+ }
85
90
  }
86
91
  </script>
87
92
  <style module="cls" lang="scss">
88
93
  .slide-image {
89
- width: 100%;
90
- height: 100%;
91
- background: black;
92
- display: flex;
93
- justify-content: center;
94
- align-items: center;
94
+ width: 100%;
95
+ height: 100%;
96
+ background: black;
97
+ display: flex;
98
+ justify-content: center;
99
+ align-items: center;
95
100
 
96
- img {
97
- max-height: 100%;
98
- max-width: 100%;
99
- object-fit: contain;
100
- }
101
+ img {
102
+ max-height: 100%;
103
+ max-width: 100%;
104
+ object-fit: contain;
105
+ }
101
106
  }
102
107
 
103
108
  .carousel {
104
- :deep(.q-carousel__navigation--bottom) {
105
- position: relative;
106
- bottom: 8em;
107
- }
109
+ :deep(.q-carousel__navigation--bottom) {
110
+ position: relative;
111
+ bottom: 8em;
112
+ }
108
113
  }
109
114
  </style>
@@ -122,91 +122,91 @@ import { FullScreenCarouselDialog } from "../Dialogs";
122
122
 
123
123
  const emit = defineEmits(["remove"]);
124
124
  const props = defineProps({
125
- src: {
126
- type: String,
127
- default: ""
128
- },
129
- image: {
130
- type: Object,
131
- default: null
132
- },
133
- relatedFiles: {
134
- type: Array,
135
- default: null
136
- },
137
- missingIcon: {
138
- type: [Function, Object],
139
- default: ImageIcon
140
- },
141
- downloadButtonClass: {
142
- type: String,
143
- default: "bg-blue-600 text-white"
144
- },
145
- downloadable: Boolean,
146
- removable: Boolean,
147
- disabled: Boolean,
148
- square: Boolean
125
+ src: {
126
+ type: String,
127
+ default: ""
128
+ },
129
+ image: {
130
+ type: Object,
131
+ default: null
132
+ },
133
+ relatedFiles: {
134
+ type: Array,
135
+ default: null
136
+ },
137
+ missingIcon: {
138
+ type: [Function, Object],
139
+ default: ImageIcon
140
+ },
141
+ downloadButtonClass: {
142
+ type: String,
143
+ default: "bg-blue-600 text-white"
144
+ },
145
+ downloadable: Boolean,
146
+ removable: Boolean,
147
+ disabled: Boolean,
148
+ square: Boolean
149
149
  });
150
150
 
151
151
  const showPreview = ref(false);
152
152
  const computedImage = computed(() => {
153
- if (props.image) {
154
- return props.image;
155
- } else if (props.src) {
156
- return {
157
- id: props.src,
158
- url: props.src,
159
- type: "image/" + props.src.split(".").pop().toLowerCase()
160
- };
161
- }
162
- return null;
153
+ if (props.image) {
154
+ return props.image;
155
+ } else if (props.src) {
156
+ return {
157
+ id: props.src,
158
+ url: props.src,
159
+ type: "image/" + props.src.split(".").pop().toLowerCase()
160
+ };
161
+ }
162
+ return null;
163
163
  });
164
164
  const mimeType = computed(
165
- () => computedImage.value.type || computedImage.value.mime
165
+ () => computedImage.value?.type || computedImage.value?.mime || ""
166
166
  );
167
- const isImage = computed(() => mimeType.value.match(/^image\//));
168
- const isVideo = computed(() => mimeType.value.match(/^video\//));
169
- const isPdf = computed(() => mimeType.value.match(/^application\/pdf/));
167
+ const isImage = computed(() => !!mimeType.value.match(/^image\//));
168
+ const isVideo = computed(() => !!mimeType.value.match(/^video\//));
169
+ const isPdf = computed(() => !!mimeType.value.match(/^application\/pdf/));
170
170
  const previewUrl = computed(
171
- () => computedImage.value.transcodes?.compress?.url || computedImage.value.blobUrl || computedImage.value.url
171
+ () => computedImage.value?.transcodes?.compress?.url || computedImage.value?.blobUrl || computedImage.value?.url
172
172
  );
173
173
  const thumbUrl = computed(() => {
174
- return computedImage.value.transcodes?.thumb?.url;
174
+ return computedImage.value?.transcodes?.thumb?.url;
175
175
  });
176
176
  const isPreviewable = computed(() => {
177
- return !!thumbUrl.value || isVideo.value || isImage.value;
177
+ return !!thumbUrl.value || isVideo.value || isImage.value;
178
178
  });
179
179
  const isConfirmingRemove = ref(false);
180
180
  function onRemove() {
181
- if (!isConfirmingRemove.value) {
182
- isConfirmingRemove.value = true;
183
- setTimeout(() => {
184
- isConfirmingRemove.value = false;
185
- }, 2000);
186
- } else {
187
- emit("remove");
188
- }
181
+ if (!isConfirmingRemove.value) {
182
+ isConfirmingRemove.value = true;
183
+ setTimeout(() => {
184
+ isConfirmingRemove.value = false;
185
+ }, 2000);
186
+ } else {
187
+ emit("remove");
188
+ }
189
189
  }
190
190
  </script>
191
191
 
192
192
  <style module="cls" lang="scss">
193
193
  .action-button {
194
- position: absolute;
195
- bottom: 1.5em;
196
- right: 1em;
197
- z-index: 1;
194
+ position: absolute;
195
+ bottom: 1.5em;
196
+ right: 1em;
197
+ z-index: 1;
198
198
  }
199
199
 
200
200
  .play-button {
201
- position: absolute;
202
- top: 0;
203
- left: 0;
204
- display: flex;
205
- justify-content: center;
206
- align-items: center;
207
- width: 100%;
208
- height: 100%;
209
- pointer-events: none;
210
- @apply text-blue-200;
201
+ position: absolute;
202
+ top: 0;
203
+ left: 0;
204
+ display: flex;
205
+ justify-content: center;
206
+ align-items: center;
207
+ width: 100%;
208
+ height: 100%;
209
+ pointer-events: none;
210
+ @apply text-blue-200;
211
211
  }
212
212
  </style>