y-element-ultra 0.0.4 → 0.0.6
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/utils/common.d.ts +13 -0
- package/es/utils/common.js +10 -0
- package/es/y-config-provider/components/receiver-view.js +12 -12
- package/es/y-watermark/index.js +11 -17
- package/lib/utils/common.cjs +10 -0
- package/lib/utils/common.d.ts +13 -0
- package/lib/y-config-provider/components/receiver-view.cjs +1 -1
- package/lib/y-watermark/index.cjs +9 -15
- package/package.json +1 -1
package/es/utils/common.d.ts
CHANGED
|
@@ -45,6 +45,19 @@ export declare function joinStyle(style?: StyleValue | string): string;
|
|
|
45
45
|
* @param reduce 处理方法
|
|
46
46
|
*/
|
|
47
47
|
export declare function normalizeStringArray(content: string | string[] | undefined, comment: Array<any>, reduce: (item: string) => string): string[];
|
|
48
|
+
/**
|
|
49
|
+
* 将内容统一转换为字符串数组。
|
|
50
|
+
* 规则说明:
|
|
51
|
+
* - 如果 content 为数组,则原样返回;
|
|
52
|
+
* - 如果 content 为 null / undefined / false / '',则返回空数组 [];
|
|
53
|
+
* - 其他情况则包装为单元素数组 [content]。
|
|
54
|
+
*
|
|
55
|
+
* @param content - 需要处理的内容
|
|
56
|
+
* @returns 规范化后的字符串数组
|
|
57
|
+
*
|
|
58
|
+
* @author 姚成健
|
|
59
|
+
*/
|
|
60
|
+
export declare function normalizeContentArray(content: any): any[];
|
|
48
61
|
/**
|
|
49
62
|
* 获取映射后的组件插槽数据
|
|
50
63
|
* @param slots 原始的插槽数据
|
package/es/utils/common.js
CHANGED
|
@@ -88,6 +88,15 @@ function normalizeStringArray(content, comment, reduce) {
|
|
|
88
88
|
];
|
|
89
89
|
return [flat.join("").toUpperCase()];
|
|
90
90
|
}
|
|
91
|
+
function normalizeContentArray(content) {
|
|
92
|
+
if (content === null || content === void 0 || content === false || content === "") {
|
|
93
|
+
return [];
|
|
94
|
+
}
|
|
95
|
+
if (Array.isArray(content)) {
|
|
96
|
+
return content;
|
|
97
|
+
}
|
|
98
|
+
return [content];
|
|
99
|
+
}
|
|
91
100
|
function getMappedSlots(slots, compSlotsMap, excludeMapNames, excludeSlots, reserveSlots) {
|
|
92
101
|
const resultSlots = {};
|
|
93
102
|
const compSlotNames = compSlotsMap || {};
|
|
@@ -200,6 +209,7 @@ export {
|
|
|
200
209
|
getValue,
|
|
201
210
|
joinStyle,
|
|
202
211
|
localize,
|
|
212
|
+
normalizeContentArray,
|
|
203
213
|
normalizeStringArray,
|
|
204
214
|
omit,
|
|
205
215
|
pick,
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { defineComponent as v, ref as u, computed as
|
|
1
|
+
import { defineComponent as v, ref as u, computed as l, watch as h, createVNode as w } from "vue";
|
|
2
2
|
import x from "../../y-watermark/index";
|
|
3
|
-
import { svgText as e, getProps as P, svgContents as s, svgProp as
|
|
3
|
+
import { svgText as e, getProps as P, svgContents as s, svgProp as n, getOption as C } from "../../y-watermark/util";
|
|
4
4
|
const b = /* @__PURE__ */ v({
|
|
5
5
|
name: "ReceiverView",
|
|
6
6
|
props: {
|
|
7
7
|
wrapHeight: [String, Number]
|
|
8
8
|
},
|
|
9
|
-
setup(
|
|
10
|
-
slots:
|
|
9
|
+
setup(a, {
|
|
10
|
+
slots: g
|
|
11
11
|
}) {
|
|
12
|
-
const
|
|
12
|
+
const o = u(), r = e[e.length - 2], {
|
|
13
13
|
svgKey: p,
|
|
14
14
|
svgProps: i,
|
|
15
15
|
svgConfig: d
|
|
16
16
|
// imageId
|
|
17
|
-
} = P(s),
|
|
18
|
-
return
|
|
19
|
-
|
|
17
|
+
} = P(s), f = l(() => d.key), m = n[e.findIndex((t) => t === e[e.length - 1])];
|
|
18
|
+
return h(f, (t) => {
|
|
19
|
+
o.value = C(t, m, i, 2, 13, r, p, s, n, n[e.findIndex((c) => c === r)]);
|
|
20
20
|
}, {
|
|
21
21
|
immediate: !0
|
|
22
22
|
}), () => (
|
|
@@ -35,14 +35,14 @@ const b = /* @__PURE__ */ v({
|
|
|
35
35
|
w(x, {
|
|
36
36
|
width: 236,
|
|
37
37
|
height: 74,
|
|
38
|
-
wrapHeight:
|
|
39
|
-
disabled: !
|
|
40
|
-
fixed: !
|
|
38
|
+
wrapHeight: a.wrapHeight,
|
|
39
|
+
disabled: !1,
|
|
40
|
+
fixed: !o.value,
|
|
41
41
|
content: "\u6C34\u5370",
|
|
42
42
|
wrapPosition: !1,
|
|
43
43
|
svgRender: !0
|
|
44
44
|
}, {
|
|
45
|
-
default: () => [
|
|
45
|
+
default: () => [g.default?.(i)]
|
|
46
46
|
})
|
|
47
47
|
);
|
|
48
48
|
}
|
package/es/y-watermark/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { defineComponent, ref, computed, inject, watch, onActivated, onDeactivated, createElementBlock, openBlock, normalizeStyle, unref, renderSlot,
|
|
2
|
-
import {
|
|
1
|
+
import { defineComponent, ref, computed, inject, watch, onActivated, onDeactivated, createElementBlock, openBlock, normalizeStyle, unref, renderSlot, createCommentVNode } from "vue";
|
|
2
|
+
import { normalizeContentArray } from "../utils/common";
|
|
3
3
|
import { useMutation } from "../y-qr-code-svg/util";
|
|
4
|
-
import SvgRender from "../y-qr-code-svg/components/svg-render";
|
|
5
4
|
import { svgContents } from "./util";
|
|
6
5
|
import { watermarkProps } from "./props";
|
|
7
6
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
@@ -69,11 +68,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
69
68
|
fontStyle: "normal",
|
|
70
69
|
...props.font || {}
|
|
71
70
|
},
|
|
72
|
-
contents:
|
|
73
|
-
props.content,
|
|
74
|
-
[imageConfig && !imageConfig.id, "el", "NDSP"],
|
|
75
|
-
observeText
|
|
76
|
-
),
|
|
71
|
+
contents: normalizeContentArray(props.content),
|
|
77
72
|
image: props.image,
|
|
78
73
|
width: props.width,
|
|
79
74
|
height: props.height,
|
|
@@ -99,12 +94,17 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
99
94
|
offsetY: props.offset?.[1] ?? 0
|
|
100
95
|
};
|
|
101
96
|
};
|
|
102
|
-
const {
|
|
97
|
+
const {
|
|
98
|
+
imageId,
|
|
99
|
+
imageStyleId,
|
|
100
|
+
imageStyle,
|
|
101
|
+
// observeText,
|
|
102
|
+
updateImageStyle
|
|
103
|
+
} = useMutation({
|
|
103
104
|
getWrapperEl: () => wrapperRef.value,
|
|
104
105
|
getImageEl: () => imageRef.value,
|
|
105
106
|
getImageStyleOption
|
|
106
107
|
});
|
|
107
|
-
const markTeleport = computed(() => isDeactivated.value || !props.fixed);
|
|
108
108
|
const markDisabled = computed(() => !props.disabled || markId.value);
|
|
109
109
|
watch(
|
|
110
110
|
[
|
|
@@ -145,13 +145,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
145
145
|
ref: imageRef,
|
|
146
146
|
key: unref(imageStyleId),
|
|
147
147
|
style: normalizeStyle(unref(imageStyle))
|
|
148
|
-
}, null, 4)) :
|
|
149
|
-
key: 1,
|
|
150
|
-
to: "body",
|
|
151
|
-
disabled: markTeleport.value
|
|
152
|
-
}, [
|
|
153
|
-
createVNode(SvgRender, normalizeProps(guardReactiveProps(svgMarkOption.value)), null, 16)
|
|
154
|
-
], 8, ["disabled"])) : createCommentVNode("", true)
|
|
148
|
+
}, null, 4)) : createCommentVNode("", true)
|
|
155
149
|
], 4);
|
|
156
150
|
};
|
|
157
151
|
}
|
package/lib/utils/common.cjs
CHANGED
|
@@ -90,6 +90,15 @@ function normalizeStringArray(content, comment, reduce) {
|
|
|
90
90
|
];
|
|
91
91
|
return [flat.join("").toUpperCase()];
|
|
92
92
|
}
|
|
93
|
+
function normalizeContentArray(content) {
|
|
94
|
+
if (content === null || content === void 0 || content === false || content === "") {
|
|
95
|
+
return [];
|
|
96
|
+
}
|
|
97
|
+
if (Array.isArray(content)) {
|
|
98
|
+
return content;
|
|
99
|
+
}
|
|
100
|
+
return [content];
|
|
101
|
+
}
|
|
93
102
|
function getMappedSlots(slots, compSlotsMap, excludeMapNames, excludeSlots, reserveSlots) {
|
|
94
103
|
const resultSlots = {};
|
|
95
104
|
const compSlotNames = compSlotsMap || {};
|
|
@@ -201,6 +210,7 @@ exports.getSlotsMap = getSlotsMap;
|
|
|
201
210
|
exports.getValue = getValue;
|
|
202
211
|
exports.joinStyle = joinStyle;
|
|
203
212
|
exports.localize = localize;
|
|
213
|
+
exports.normalizeContentArray = normalizeContentArray;
|
|
204
214
|
exports.normalizeStringArray = normalizeStringArray;
|
|
205
215
|
exports.omit = omit;
|
|
206
216
|
exports.pick = pick;
|
package/lib/utils/common.d.ts
CHANGED
|
@@ -45,6 +45,19 @@ export declare function joinStyle(style?: StyleValue | string): string;
|
|
|
45
45
|
* @param reduce 处理方法
|
|
46
46
|
*/
|
|
47
47
|
export declare function normalizeStringArray(content: string | string[] | undefined, comment: Array<any>, reduce: (item: string) => string): string[];
|
|
48
|
+
/**
|
|
49
|
+
* 将内容统一转换为字符串数组。
|
|
50
|
+
* 规则说明:
|
|
51
|
+
* - 如果 content 为数组,则原样返回;
|
|
52
|
+
* - 如果 content 为 null / undefined / false / '',则返回空数组 [];
|
|
53
|
+
* - 其他情况则包装为单元素数组 [content]。
|
|
54
|
+
*
|
|
55
|
+
* @param content - 需要处理的内容
|
|
56
|
+
* @returns 规范化后的字符串数组
|
|
57
|
+
*
|
|
58
|
+
* @author 姚成健
|
|
59
|
+
*/
|
|
60
|
+
export declare function normalizeContentArray(content: any): any[];
|
|
48
61
|
/**
|
|
49
62
|
* 获取映射后的组件插槽数据
|
|
50
63
|
* @param slots 原始的插槽数据
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const t=require("vue"),
|
|
1
|
+
"use strict";const t=require("vue"),u=require("../../y-watermark/index"),e=require("../../y-watermark/util"),f=t.defineComponent({name:"ReceiverView",props:{wrapHeight:[String,Number]},setup(g,{slots:i}){const n=t.ref(),r=e.svgText[e.svgText.length-2],{svgKey:v,svgProps:o,svgConfig:a}=e.getProps(e.svgContents),c=t.computed(()=>a.key),p=e.svgProp[e.svgText.findIndex(s=>s===e.svgText[e.svgText.length-1])];return t.watch(c,s=>{n.value=e.getOption(s,p,o,2,13,r,v,e.svgContents,e.svgProp,e.svgProp[e.svgText.findIndex(d=>d===r)])},{immediate:!0}),()=>t.createVNode(u,{width:236,height:74,wrapHeight:g.wrapHeight,disabled:!1,fixed:!n.value,content:"\u6C34\u5370",wrapPosition:!1,svgRender:!0},{default:()=>[i.default?.(o)]})}});module.exports=f;
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
const vue = require("vue");
|
|
3
3
|
const common = require("../utils/common");
|
|
4
4
|
const util$1 = require("../y-qr-code-svg/util");
|
|
5
|
-
const SvgRender = require("../y-qr-code-svg/components/svg-render");
|
|
6
5
|
const util = require("./util");
|
|
7
6
|
const props = require("./props");
|
|
8
7
|
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
@@ -70,11 +69,7 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
|
70
69
|
fontStyle: "normal",
|
|
71
70
|
...props2.font || {}
|
|
72
71
|
},
|
|
73
|
-
contents: common.
|
|
74
|
-
props2.content,
|
|
75
|
-
[imageConfig && !imageConfig.id, "el", "NDSP"],
|
|
76
|
-
observeText
|
|
77
|
-
),
|
|
72
|
+
contents: common.normalizeContentArray(props2.content),
|
|
78
73
|
image: props2.image,
|
|
79
74
|
width: props2.width,
|
|
80
75
|
height: props2.height,
|
|
@@ -100,12 +95,17 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
|
100
95
|
offsetY: props2.offset?.[1] ?? 0
|
|
101
96
|
};
|
|
102
97
|
};
|
|
103
|
-
const {
|
|
98
|
+
const {
|
|
99
|
+
imageId,
|
|
100
|
+
imageStyleId,
|
|
101
|
+
imageStyle,
|
|
102
|
+
// observeText,
|
|
103
|
+
updateImageStyle
|
|
104
|
+
} = util$1.useMutation({
|
|
104
105
|
getWrapperEl: () => wrapperRef.value,
|
|
105
106
|
getImageEl: () => imageRef.value,
|
|
106
107
|
getImageStyleOption
|
|
107
108
|
});
|
|
108
|
-
const markTeleport = vue.computed(() => isDeactivated.value || !props2.fixed);
|
|
109
109
|
const markDisabled = vue.computed(() => !props2.disabled || markId.value);
|
|
110
110
|
vue.watch(
|
|
111
111
|
[
|
|
@@ -146,13 +146,7 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
|
146
146
|
ref: imageRef,
|
|
147
147
|
key: vue.unref(imageStyleId),
|
|
148
148
|
style: vue.normalizeStyle(vue.unref(imageStyle))
|
|
149
|
-
}, null, 4)) :
|
|
150
|
-
key: 1,
|
|
151
|
-
to: "body",
|
|
152
|
-
disabled: markTeleport.value
|
|
153
|
-
}, [
|
|
154
|
-
vue.createVNode(SvgRender, vue.normalizeProps(vue.guardReactiveProps(svgMarkOption.value)), null, 16)
|
|
155
|
-
], 8, ["disabled"])) : vue.createCommentVNode("", true)
|
|
149
|
+
}, null, 4)) : vue.createCommentVNode("", true)
|
|
156
150
|
], 4);
|
|
157
151
|
};
|
|
158
152
|
}
|