@varlet/ui 2.17.0 → 2.17.1
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/es/dialog/dialog.css +1 -1
- package/es/index.bundle.mjs +1 -1
- package/es/index.mjs +1 -1
- package/es/option/Option.mjs +28 -28
- package/es/option/option.css +1 -1
- package/es/option/props.mjs +2 -1
- package/es/popup/popup.css +1 -1
- package/es/style.css +1 -1
- package/es/themes/dark/option.mjs +1 -1
- package/es/uploader/Uploader.mjs +8 -4
- package/es/uploader/props.mjs +2 -0
- package/es/utils/shared.mjs +4 -4
- package/es/varlet.esm.js +1319 -1319
- package/highlight/web-types.en-US.json +25 -3
- package/highlight/web-types.zh-CN.json +23 -1
- package/lib/style.css +1 -1
- package/lib/varlet.cjs.js +43 -36
- package/package.json +7 -7
- package/types/option.d.ts +1 -0
- package/types/uploader.d.ts +2 -0
- package/umd/varlet.js +6 -6
package/es/uploader/Uploader.mjs
CHANGED
|
@@ -27,7 +27,7 @@ import Ripple from "../ripple/index.mjs";
|
|
|
27
27
|
import Hover from "../hover/index.mjs";
|
|
28
28
|
import { defineComponent, nextTick, reactive, computed, watch, ref } from "vue";
|
|
29
29
|
import { props } from "./props.mjs";
|
|
30
|
-
import { isNumber, toNumber,
|
|
30
|
+
import { isNumber, toNumber, normalizeToArray, toDataURL } from "@varlet/shared";
|
|
31
31
|
import { isHTMLSupportImage, isHTMLSupportVideo } from "../utils/shared.mjs";
|
|
32
32
|
import { call, useValidation, createNamespace, formatElevation } from "../utils/components.mjs";
|
|
33
33
|
import { useForm } from "../form/provide.mjs";
|
|
@@ -276,16 +276,20 @@ const __sfc__ = defineComponent({
|
|
|
276
276
|
{ deep: true }
|
|
277
277
|
);
|
|
278
278
|
function preview(varFile) {
|
|
279
|
-
const { disabled, previewed } = props2;
|
|
279
|
+
const { disabled, previewed, preventDefaultPreview, onPreview } = props2;
|
|
280
280
|
if ((form == null ? void 0 : form.disabled.value) || disabled || !previewed) {
|
|
281
281
|
return;
|
|
282
282
|
}
|
|
283
|
+
call(onPreview, reactive(varFile));
|
|
284
|
+
if (preventDefaultPreview) {
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
283
287
|
const { url } = varFile;
|
|
284
|
-
if (
|
|
288
|
+
if (isHTMLSupportImage(url)) {
|
|
285
289
|
ImagePreview(url);
|
|
286
290
|
return;
|
|
287
291
|
}
|
|
288
|
-
if (
|
|
292
|
+
if (isHTMLSupportVideo(url)) {
|
|
289
293
|
currentPreview.value = varFile;
|
|
290
294
|
showPreview.value = true;
|
|
291
295
|
}
|
package/es/uploader/props.mjs
CHANGED
|
@@ -43,12 +43,14 @@ const props = {
|
|
|
43
43
|
},
|
|
44
44
|
rules: Array,
|
|
45
45
|
hideList: Boolean,
|
|
46
|
+
preventDefaultPreview: Boolean,
|
|
46
47
|
onBeforeFilter: defineListenerProp(),
|
|
47
48
|
onBeforeRead: defineListenerProp(),
|
|
48
49
|
onAfterRead: defineListenerProp(),
|
|
49
50
|
onBeforeRemove: defineListenerProp(),
|
|
50
51
|
onRemove: defineListenerProp(),
|
|
51
52
|
onOversize: defineListenerProp(),
|
|
53
|
+
onPreview: defineListenerProp(),
|
|
52
54
|
"onUpdate:modelValue": defineListenerProp()
|
|
53
55
|
};
|
|
54
56
|
export {
|
package/es/utils/shared.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { removeItem } from "@varlet/shared";
|
|
1
|
+
import { isString, removeItem } from "@varlet/shared";
|
|
2
2
|
const isHTMLSupportImage = (val) => {
|
|
3
|
-
if (val
|
|
3
|
+
if (!isString(val)) {
|
|
4
4
|
return false;
|
|
5
5
|
}
|
|
6
|
-
return val.startsWith("data:image") || /\.(png|jpg|gif|jpeg|svg|webp)
|
|
6
|
+
return val.startsWith("data:image") || /\.(png|jpg|gif|jpeg|svg|webp|ico)$/i.test(val);
|
|
7
7
|
};
|
|
8
8
|
const isHTMLSupportVideo = (val) => {
|
|
9
|
-
if (val
|
|
9
|
+
if (!isString(val)) {
|
|
10
10
|
return false;
|
|
11
11
|
}
|
|
12
12
|
return val.startsWith("data:video") || /\.(mp4|webm|ogg)$/.test(val);
|