vant 4.1.2 → 4.2.0

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/index.d.ts CHANGED
@@ -93,10 +93,11 @@ export * from "./time-picker";
93
93
  export * from "./toast";
94
94
  export * from "./tree-select";
95
95
  export * from "./uploader";
96
+ export * from "./watermark";
96
97
  declare namespace _default {
97
98
  export { install };
98
99
  export { version };
99
100
  }
100
101
  export default _default;
101
102
  export function install(app: any): void;
102
- export const version: "4.1.2";
103
+ export const version: "4.2.0";
package/es/index.mjs CHANGED
@@ -92,7 +92,8 @@ import { TimePicker } from "./time-picker/index.mjs";
92
92
  import { Toast } from "./toast/index.mjs";
93
93
  import { TreeSelect } from "./tree-select/index.mjs";
94
94
  import { Uploader } from "./uploader/index.mjs";
95
- const version = "4.1.2";
95
+ import { Watermark } from "./watermark/index.mjs";
96
+ const version = "4.2.0";
96
97
  function install(app) {
97
98
  const components = [
98
99
  ActionBar,
@@ -188,7 +189,8 @@ function install(app) {
188
189
  TimePicker,
189
190
  Toast,
190
191
  TreeSelect,
191
- Uploader
192
+ Uploader,
193
+ Watermark
192
194
  ];
193
195
  components.forEach((item) => {
194
196
  if (item.install) {
@@ -293,6 +295,7 @@ export * from "./time-picker/index.mjs";
293
295
  export * from "./toast/index.mjs";
294
296
  export * from "./tree-select/index.mjs";
295
297
  export * from "./uploader/index.mjs";
298
+ export * from "./watermark/index.mjs";
296
299
  var stdin_default = {
297
300
  install,
298
301
  version
@@ -4,6 +4,7 @@ import { pick, extend, truthProp, makeArrayProp, createNamespace, HAPTICS_FEEDBA
4
4
  import { popupSharedProps, popupSharedPropKeys } from "../popup/shared.mjs";
5
5
  import { Icon } from "../icon/index.mjs";
6
6
  import { Popup } from "../popup/index.mjs";
7
+ const isImage = (name2) => name2 == null ? void 0 : name2.includes("/");
7
8
  const popupInheritKeys = [...popupSharedPropKeys, "round", "closeOnPopstate", "safeAreaInsetBottom"];
8
9
  const iconMap = {
9
10
  qq: "qq",
@@ -53,17 +54,17 @@ var stdin_default = defineComponent({
53
54
  }
54
55
  };
55
56
  const renderIcon = (icon) => {
56
- if (iconMap[icon]) {
57
- return _createVNode("div", {
58
- "class": bem("icon", [icon])
59
- }, [_createVNode(Icon, {
60
- "name": iconMap[icon] || icon
61
- }, null)]);
57
+ if (isImage(icon)) {
58
+ return _createVNode("img", {
59
+ "src": icon,
60
+ "class": bem("image-icon")
61
+ }, null);
62
62
  }
63
- return _createVNode("img", {
64
- "src": icon,
65
- "class": bem("image-icon")
66
- }, null);
63
+ return _createVNode("div", {
64
+ "class": bem("icon", [icon])
65
+ }, [_createVNode(Icon, {
66
+ "name": iconMap[icon] || icon
67
+ }, null)]);
67
68
  };
68
69
  const renderOption = (option, index) => {
69
70
  const {
@@ -336,7 +336,7 @@ var stdin_default = defineComponent({
336
336
  watch(() => props.initialSwipe, (value) => initialize(+value));
337
337
  watch(count, () => initialize(state.active));
338
338
  watch(() => props.autoplay, autoplay);
339
- watch([windowWidth, windowHeight], resize);
339
+ watch([windowWidth, windowHeight, () => props.width, () => props.height], resize);
340
340
  watch(usePageVisibility(), (visible) => {
341
341
  if (visible === "visible") {
342
342
  autoplay();
@@ -4,6 +4,10 @@ export declare const textEllipsisProps: {
4
4
  type: (NumberConstructor | StringConstructor)[];
5
5
  default: number;
6
6
  };
7
+ dots: {
8
+ type: import("vue").PropType<string>;
9
+ default: string;
10
+ };
7
11
  content: {
8
12
  type: import("vue").PropType<string>;
9
13
  default: string;
@@ -23,6 +27,10 @@ declare const _default: import("vue").DefineComponent<{
23
27
  type: (NumberConstructor | StringConstructor)[];
24
28
  default: number;
25
29
  };
30
+ dots: {
31
+ type: import("vue").PropType<string>;
32
+ default: string;
33
+ };
26
34
  content: {
27
35
  type: import("vue").PropType<string>;
28
36
  default: string;
@@ -40,6 +48,10 @@ declare const _default: import("vue").DefineComponent<{
40
48
  type: (NumberConstructor | StringConstructor)[];
41
49
  default: number;
42
50
  };
51
+ dots: {
52
+ type: import("vue").PropType<string>;
53
+ default: string;
54
+ };
43
55
  content: {
44
56
  type: import("vue").PropType<string>;
45
57
  default: string;
@@ -57,6 +69,7 @@ declare const _default: import("vue").DefineComponent<{
57
69
  }, {
58
70
  content: string;
59
71
  rows: string | number;
72
+ dots: string;
60
73
  expandText: string;
61
74
  collapseText: string;
62
75
  }>;
@@ -5,6 +5,7 @@ import { makeNumericProp, makeStringProp, createNamespace } from "../utils/index
5
5
  const [name, bem] = createNamespace("text-ellipsis");
6
6
  const textEllipsisProps = {
7
7
  rows: makeNumericProp(1),
8
+ dots: makeStringProp("..."),
8
9
  content: makeStringProp(""),
9
10
  expandText: makeStringProp(""),
10
11
  collapseText: makeStringProp("")
@@ -48,16 +49,16 @@ var stdin_default = defineComponent({
48
49
  };
49
50
  const calcEllipsisText = (container2, maxHeight2) => {
50
51
  const {
52
+ dots,
51
53
  content,
52
54
  expandText
53
55
  } = props;
54
- const dot = "...";
55
56
  let left = 0;
56
57
  let right = content.length;
57
58
  let res = -1;
58
59
  while (left <= right) {
59
60
  const mid = Math.floor((left + right) / 2);
60
- container2.innerText = content.slice(0, mid) + dot + expandText;
61
+ container2.innerText = content.slice(0, mid) + dots + expandText;
61
62
  if (container2.offsetHeight <= maxHeight2) {
62
63
  left = mid + 1;
63
64
  res = mid;
@@ -65,7 +66,7 @@ var stdin_default = defineComponent({
65
66
  right = mid - 1;
66
67
  }
67
68
  }
68
- return content.slice(0, res) + dot;
69
+ return content.slice(0, res) + dots;
69
70
  };
70
71
  const container = cloneContainer();
71
72
  if (!container)
@@ -3,6 +3,10 @@ export declare const TextEllipsis: import("../utils").WithInstall<import("vue").
3
3
  type: (NumberConstructor | StringConstructor)[];
4
4
  default: number;
5
5
  };
6
+ dots: {
7
+ type: import("vue").PropType<string>;
8
+ default: string;
9
+ };
6
10
  content: {
7
11
  type: import("vue").PropType<string>;
8
12
  default: string;
@@ -20,6 +24,10 @@ export declare const TextEllipsis: import("../utils").WithInstall<import("vue").
20
24
  type: (NumberConstructor | StringConstructor)[];
21
25
  default: number;
22
26
  };
27
+ dots: {
28
+ type: import("vue").PropType<string>;
29
+ default: string;
30
+ };
23
31
  content: {
24
32
  type: import("vue").PropType<string>;
25
33
  default: string;
@@ -37,6 +45,7 @@ export declare const TextEllipsis: import("../utils").WithInstall<import("vue").
37
45
  }, {
38
46
  content: string;
39
47
  rows: string | number;
48
+ dots: string;
40
49
  expandText: string;
41
50
  collapseText: string;
42
51
  }>>;
@@ -0,0 +1,112 @@
1
+ import { type ExtractPropTypes } from 'vue';
2
+ export declare const watermarkProps: {
3
+ gapX: {
4
+ type: NumberConstructor;
5
+ default: number;
6
+ };
7
+ gapY: {
8
+ type: NumberConstructor;
9
+ default: number;
10
+ };
11
+ image: StringConstructor;
12
+ width: {
13
+ type: NumberConstructor;
14
+ default: number;
15
+ };
16
+ height: {
17
+ type: NumberConstructor;
18
+ default: number;
19
+ };
20
+ rotate: {
21
+ type: (NumberConstructor | StringConstructor)[];
22
+ default: number;
23
+ };
24
+ zIndex: (NumberConstructor | StringConstructor)[];
25
+ content: StringConstructor;
26
+ opacity: (NumberConstructor | StringConstructor)[];
27
+ fullPage: {
28
+ type: BooleanConstructor;
29
+ default: true;
30
+ };
31
+ textColor: {
32
+ type: import("vue").PropType<string>;
33
+ default: string;
34
+ };
35
+ };
36
+ export type WatermarkProps = ExtractPropTypes<typeof watermarkProps>;
37
+ declare const _default: import("vue").DefineComponent<{
38
+ gapX: {
39
+ type: NumberConstructor;
40
+ default: number;
41
+ };
42
+ gapY: {
43
+ type: NumberConstructor;
44
+ default: number;
45
+ };
46
+ image: StringConstructor;
47
+ width: {
48
+ type: NumberConstructor;
49
+ default: number;
50
+ };
51
+ height: {
52
+ type: NumberConstructor;
53
+ default: number;
54
+ };
55
+ rotate: {
56
+ type: (NumberConstructor | StringConstructor)[];
57
+ default: number;
58
+ };
59
+ zIndex: (NumberConstructor | StringConstructor)[];
60
+ content: StringConstructor;
61
+ opacity: (NumberConstructor | StringConstructor)[];
62
+ fullPage: {
63
+ type: BooleanConstructor;
64
+ default: true;
65
+ };
66
+ textColor: {
67
+ type: import("vue").PropType<string>;
68
+ default: string;
69
+ };
70
+ }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<ExtractPropTypes<{
71
+ gapX: {
72
+ type: NumberConstructor;
73
+ default: number;
74
+ };
75
+ gapY: {
76
+ type: NumberConstructor;
77
+ default: number;
78
+ };
79
+ image: StringConstructor;
80
+ width: {
81
+ type: NumberConstructor;
82
+ default: number;
83
+ };
84
+ height: {
85
+ type: NumberConstructor;
86
+ default: number;
87
+ };
88
+ rotate: {
89
+ type: (NumberConstructor | StringConstructor)[];
90
+ default: number;
91
+ };
92
+ zIndex: (NumberConstructor | StringConstructor)[];
93
+ content: StringConstructor;
94
+ opacity: (NumberConstructor | StringConstructor)[];
95
+ fullPage: {
96
+ type: BooleanConstructor;
97
+ default: true;
98
+ };
99
+ textColor: {
100
+ type: import("vue").PropType<string>;
101
+ default: string;
102
+ };
103
+ }>>, {
104
+ width: number;
105
+ height: number;
106
+ textColor: string;
107
+ rotate: string | number;
108
+ gapX: number;
109
+ gapY: number;
110
+ fullPage: boolean;
111
+ }>;
112
+ export default _default;
@@ -0,0 +1,131 @@
1
+ import { createVNode as _createVNode } from "vue";
2
+ import { defineComponent, nextTick, onUnmounted, ref, watch, watchEffect } from "vue";
3
+ import { extend, truthProp, numericProp, createNamespace, getZIndexStyle, makeNumberProp, makeNumericProp, makeStringProp } from "../utils/index.mjs";
4
+ const [name, bem] = createNamespace("watermark");
5
+ const watermarkProps = {
6
+ gapX: makeNumberProp(0),
7
+ gapY: makeNumberProp(0),
8
+ image: String,
9
+ width: makeNumberProp(100),
10
+ height: makeNumberProp(100),
11
+ rotate: makeNumericProp(-22),
12
+ zIndex: numericProp,
13
+ content: String,
14
+ opacity: numericProp,
15
+ fullPage: truthProp,
16
+ textColor: makeStringProp("#dcdee0")
17
+ };
18
+ var stdin_default = defineComponent({
19
+ name,
20
+ props: watermarkProps,
21
+ setup(props, {
22
+ slots
23
+ }) {
24
+ const svgElRef = ref();
25
+ const watermarkUrl = ref("");
26
+ const imageBase64 = ref("");
27
+ const renderWatermark = () => {
28
+ const rotateStyle = {
29
+ transformOrigin: "center",
30
+ transform: `rotate(${props.rotate}deg)`
31
+ };
32
+ const svgInner = () => {
33
+ if (props.image && !slots.content) {
34
+ return _createVNode("image", {
35
+ "href": imageBase64.value,
36
+ "x": "0",
37
+ "y": "0",
38
+ "width": props.width,
39
+ "height": props.height,
40
+ "style": rotateStyle
41
+ }, null);
42
+ }
43
+ return _createVNode("foreignObject", {
44
+ "x": "0",
45
+ "y": "0",
46
+ "width": props.width,
47
+ "height": props.height
48
+ }, [_createVNode("div", {
49
+ "xmlns": "http://www.w3.org/1999/xhtml",
50
+ "style": rotateStyle
51
+ }, [slots.content ? slots.content() : _createVNode("span", {
52
+ "style": {
53
+ color: props.textColor
54
+ }
55
+ }, [props.content])])]);
56
+ };
57
+ const svgWidth = props.width + props.gapX;
58
+ const svgHeight = props.height + props.gapY;
59
+ return _createVNode("svg", {
60
+ "viewBox": `0 0 ${svgWidth} ${svgHeight}`,
61
+ "width": svgWidth,
62
+ "height": svgHeight,
63
+ "xmlns": "http://www.w3.org/2000/svg",
64
+ "style": {
65
+ padding: `0 ${props.gapX}px ${props.gapY}px 0`,
66
+ opacity: props.opacity
67
+ }
68
+ }, [svgInner()]);
69
+ };
70
+ const makeImageToBase64 = (url) => {
71
+ const canvas = document.createElement("canvas");
72
+ const image = new Image();
73
+ image.crossOrigin = "anonymous";
74
+ image.referrerPolicy = "no-referrer";
75
+ image.onload = () => {
76
+ canvas.width = image.naturalWidth;
77
+ canvas.height = image.naturalHeight;
78
+ const ctx = canvas.getContext("2d");
79
+ ctx == null ? void 0 : ctx.drawImage(image, 0, 0);
80
+ imageBase64.value = canvas.toDataURL();
81
+ };
82
+ image.src = url;
83
+ };
84
+ const makeSvgToBlobUrl = (svgStr) => {
85
+ const svgBlob = new Blob([svgStr], {
86
+ type: "image/svg+xml;charset=utf-8"
87
+ });
88
+ return URL.createObjectURL(svgBlob);
89
+ };
90
+ watchEffect(() => {
91
+ if (props.image) {
92
+ makeImageToBase64(props.image);
93
+ }
94
+ });
95
+ watch(() => [imageBase64.value, props.content, props.textColor, props.height, props.width, props.rotate, props.gapX, props.gapY], () => {
96
+ nextTick(() => {
97
+ if (svgElRef.value) {
98
+ if (watermarkUrl.value) {
99
+ URL.revokeObjectURL(watermarkUrl.value);
100
+ }
101
+ watermarkUrl.value = makeSvgToBlobUrl(svgElRef.value.innerHTML);
102
+ }
103
+ });
104
+ }, {
105
+ immediate: true
106
+ });
107
+ onUnmounted(() => {
108
+ if (watermarkUrl.value) {
109
+ URL.revokeObjectURL(watermarkUrl.value);
110
+ }
111
+ });
112
+ return () => {
113
+ const style = extend({
114
+ backgroundImage: `url(${watermarkUrl.value})`
115
+ }, getZIndexStyle(props.zIndex));
116
+ return _createVNode("div", {
117
+ "class": bem({
118
+ full: props.fullPage
119
+ }),
120
+ "style": style
121
+ }, [_createVNode("div", {
122
+ "class": bem("wrapper"),
123
+ "ref": svgElRef
124
+ }, [renderWatermark()])]);
125
+ };
126
+ }
127
+ });
128
+ export {
129
+ stdin_default as default,
130
+ watermarkProps
131
+ };
@@ -0,0 +1 @@
1
+ :root{--van-watermark-z-index: 100}.van-watermark{position:absolute;height:100%;width:100%;left:0;top:0;z-index:var(--van-watermark-z-index);background-repeat:repeat;pointer-events:none}.van-watermark__wrapper{display:none}.van-watermark--full{position:fixed}
@@ -0,0 +1,83 @@
1
+ export declare const Watermark: import("../utils").WithInstall<import("vue").DefineComponent<{
2
+ gapX: {
3
+ type: NumberConstructor;
4
+ default: number;
5
+ };
6
+ gapY: {
7
+ type: NumberConstructor;
8
+ default: number;
9
+ };
10
+ image: StringConstructor;
11
+ width: {
12
+ type: NumberConstructor;
13
+ default: number;
14
+ };
15
+ height: {
16
+ type: NumberConstructor;
17
+ default: number;
18
+ };
19
+ rotate: {
20
+ type: (NumberConstructor | StringConstructor)[];
21
+ default: number;
22
+ };
23
+ zIndex: (NumberConstructor | StringConstructor)[];
24
+ content: StringConstructor;
25
+ opacity: (NumberConstructor | StringConstructor)[];
26
+ fullPage: {
27
+ type: BooleanConstructor;
28
+ default: true;
29
+ };
30
+ textColor: {
31
+ type: import("vue").PropType<string>;
32
+ default: string;
33
+ };
34
+ }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
35
+ gapX: {
36
+ type: NumberConstructor;
37
+ default: number;
38
+ };
39
+ gapY: {
40
+ type: NumberConstructor;
41
+ default: number;
42
+ };
43
+ image: StringConstructor;
44
+ width: {
45
+ type: NumberConstructor;
46
+ default: number;
47
+ };
48
+ height: {
49
+ type: NumberConstructor;
50
+ default: number;
51
+ };
52
+ rotate: {
53
+ type: (NumberConstructor | StringConstructor)[];
54
+ default: number;
55
+ };
56
+ zIndex: (NumberConstructor | StringConstructor)[];
57
+ content: StringConstructor;
58
+ opacity: (NumberConstructor | StringConstructor)[];
59
+ fullPage: {
60
+ type: BooleanConstructor;
61
+ default: true;
62
+ };
63
+ textColor: {
64
+ type: import("vue").PropType<string>;
65
+ default: string;
66
+ };
67
+ }>>, {
68
+ width: number;
69
+ height: number;
70
+ textColor: string;
71
+ rotate: string | number;
72
+ gapX: number;
73
+ gapY: number;
74
+ fullPage: boolean;
75
+ }>>;
76
+ export default Watermark;
77
+ export { watermarkProps } from './Watermark';
78
+ export type { WatermarkProps } from './Watermark';
79
+ declare module 'vue' {
80
+ interface GlobalComponents {
81
+ VanWatermark: typeof Watermark;
82
+ }
83
+ }
@@ -0,0 +1,10 @@
1
+ import { withInstall } from "../utils/index.mjs";
2
+ import _Watermark from "./Watermark.mjs";
3
+ const Watermark = withInstall(_Watermark);
4
+ var stdin_default = Watermark;
5
+ import { watermarkProps } from "./Watermark.mjs";
6
+ export {
7
+ Watermark,
8
+ stdin_default as default,
9
+ watermarkProps
10
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import "../../style/base.css";
2
+ import "../index.css";