@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.
@@ -1,5 +1,5 @@
1
1
  var stdin_default = {
2
- "--options-text-color": "#fff"
2
+ "--option-text-color": "#fff"
3
3
  };
4
4
  export {
5
5
  stdin_default as default
@@ -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, isString, normalizeToArray, toDataURL } from "@varlet/shared";
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 (isString(url) && isHTMLSupportImage(url)) {
288
+ if (isHTMLSupportImage(url)) {
285
289
  ImagePreview(url);
286
290
  return;
287
291
  }
288
- if (isString(url) && isHTMLSupportVideo(url)) {
292
+ if (isHTMLSupportVideo(url)) {
289
293
  currentPreview.value = varFile;
290
294
  showPreview.value = true;
291
295
  }
@@ -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 {
@@ -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 == null) {
3
+ if (!isString(val)) {
4
4
  return false;
5
5
  }
6
- return val.startsWith("data:image") || /\.(png|jpg|gif|jpeg|svg|webp)$/.test(val);
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 == null) {
9
+ if (!isString(val)) {
10
10
  return false;
11
11
  }
12
12
  return val.startsWith("data:video") || /\.(mp4|webm|ogg)$/.test(val);