ele-admin-plus 1.4.1-beta.1 → 1.4.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.
Files changed (224) hide show
  1. package/es/core-components.d.ts +2 -0
  2. package/es/core-components.js +104 -100
  3. package/es/ele-app/plus.d.ts +9 -1
  4. package/es/ele-app/plusx.d.ts +26 -13
  5. package/es/ele-backtop/index.js +7 -1
  6. package/es/ele-basic-select/components/select-view.d.ts +53 -22
  7. package/es/ele-basic-select/components/select-view.js +57 -20
  8. package/es/ele-basic-select/index.d.ts +39 -19
  9. package/es/ele-basic-select/index.js +62 -13
  10. package/es/ele-basic-select/props.d.ts +33 -21
  11. package/es/ele-basic-select/props.js +33 -21
  12. package/es/ele-basic-select/style/index.js +2 -0
  13. package/es/ele-basic-select/types.d.ts +1 -1
  14. package/es/ele-config-provider/components/receiver-view.d.ts +2 -0
  15. package/es/ele-config-provider/components/receiver-view.js +74 -72
  16. package/es/ele-config-provider/receiver.d.ts +2 -2
  17. package/es/ele-config-provider/receiver.js +5 -1
  18. package/es/ele-config-provider/types.d.ts +10 -1
  19. package/es/ele-copyable/index.d.ts +2 -4
  20. package/es/ele-cron-builder/index.d.ts +24 -0
  21. package/es/ele-cron-builder/index.js +81 -0
  22. package/es/ele-cron-builder/props.d.ts +31 -0
  23. package/es/ele-cron-builder/props.js +24 -0
  24. package/es/ele-cron-builder/style/index.d.ts +1 -0
  25. package/es/ele-cron-builder/style/index.js +4 -0
  26. package/es/ele-cron-builder/style/index.scss +6 -0
  27. package/es/ele-cron-builder/types.d.ts +8 -0
  28. package/es/ele-cron-panel/components/cron-day.d.ts +25 -0
  29. package/es/ele-cron-panel/components/cron-day.js +232 -0
  30. package/es/ele-cron-panel/components/cron-hour.d.ts +25 -0
  31. package/es/ele-cron-panel/components/cron-hour.js +174 -0
  32. package/es/ele-cron-panel/components/cron-minute.d.ts +25 -0
  33. package/es/ele-cron-panel/components/cron-minute.js +174 -0
  34. package/es/ele-cron-panel/components/cron-month.d.ts +25 -0
  35. package/es/ele-cron-panel/components/cron-month.js +174 -0
  36. package/es/ele-cron-panel/components/cron-second.d.ts +25 -0
  37. package/es/ele-cron-panel/components/cron-second.js +174 -0
  38. package/es/ele-cron-panel/components/cron-week.d.ts +25 -0
  39. package/es/ele-cron-panel/components/cron-week.js +229 -0
  40. package/es/ele-cron-panel/components/cron-year.d.ts +25 -0
  41. package/es/ele-cron-panel/components/cron-year.js +186 -0
  42. package/es/ele-cron-panel/index.d.ts +14 -0
  43. package/es/ele-cron-panel/index.js +348 -0
  44. package/es/ele-cron-panel/props.d.ts +20 -0
  45. package/es/ele-cron-panel/props.js +14 -0
  46. package/es/ele-cron-panel/style/index.d.ts +1 -0
  47. package/es/ele-cron-panel/style/index.js +7 -0
  48. package/es/ele-cron-panel/style/index.scss +282 -0
  49. package/es/ele-cron-panel/types.d.ts +118 -0
  50. package/es/ele-cron-panel/util.d.ts +23 -0
  51. package/es/ele-cron-panel/util.js +542 -0
  52. package/es/ele-cropper/components/cropper-tools.d.ts +2 -2
  53. package/es/ele-cropper-modal/index.d.ts +2 -4
  54. package/es/ele-crud/index.d.ts +3 -3
  55. package/es/ele-drawer/index.d.ts +9 -0
  56. package/es/ele-drawer/index.js +5 -1
  57. package/es/ele-drawer/props.d.ts +5 -0
  58. package/es/ele-drawer/props.js +6 -1
  59. package/es/ele-drawer/style/index.scss +11 -0
  60. package/es/ele-file-list/index.d.ts +3 -3
  61. package/es/ele-icon-select/components/icon-grid.d.ts +8 -3
  62. package/es/ele-icon-select/components/icon-grid.js +20 -12
  63. package/es/ele-icon-select/index.d.ts +58 -59
  64. package/es/ele-icon-select/index.js +92 -86
  65. package/es/ele-icon-select/props.d.ts +35 -35
  66. package/es/ele-icon-select/props.js +34 -34
  67. package/es/ele-icon-select/style/css-var.scss +1 -1
  68. package/es/ele-icon-select/style/index.scss +50 -18
  69. package/es/ele-icon-select/types.d.ts +13 -0
  70. package/es/ele-map-picker/index.d.ts +3 -3
  71. package/es/ele-modal/index.d.ts +4 -2
  72. package/es/ele-modal/index.js +9 -3
  73. package/es/ele-modal/props.d.ts +2 -0
  74. package/es/ele-modal/props.js +2 -0
  75. package/es/ele-modal/style/index.scss +16 -0
  76. package/es/ele-pro-form/components/item-type-data.js +39 -64
  77. package/es/ele-pro-form/index.d.ts +3 -3
  78. package/es/ele-pro-table/components/table-tools.d.ts +12 -97
  79. package/es/ele-pro-table/components/table-tools.js +118 -248
  80. package/es/ele-pro-table/components/tool-export.d.ts +5 -1
  81. package/es/ele-pro-table/components/tool-export.js +32 -20
  82. package/es/ele-pro-table/components/tool-print.d.ts +5 -1
  83. package/es/ele-pro-table/components/tool-print.js +37 -25
  84. package/es/ele-pro-table/exceljs-plugin.d.ts +12 -0
  85. package/es/ele-pro-table/exceljs-plugin.js +81 -0
  86. package/es/ele-pro-table/index.d.ts +6 -7
  87. package/es/ele-pro-table/index.js +117 -46
  88. package/es/ele-pro-table/types.d.ts +11 -0
  89. package/es/ele-split-panel/style/index.scss +1 -1
  90. package/es/ele-table-select/index.d.ts +2 -0
  91. package/es/ele-table-select/props.d.ts +2 -0
  92. package/es/ele-table-select/props.js +3 -1
  93. package/es/ele-tour/index.d.ts +3 -3
  94. package/es/ele-tree-select/index.d.ts +2 -0
  95. package/es/ele-upload-list/index.d.ts +3 -3
  96. package/es/ele-upload-list/index.js +25 -8
  97. package/es/ele-virtual-table/components/body-cell.d.ts +1 -1
  98. package/es/ele-watermark/index.d.ts +20 -7
  99. package/es/ele-watermark/index.js +253 -94
  100. package/es/ele-watermark/props.d.ts +10 -3
  101. package/es/ele-watermark/props.js +10 -3
  102. package/es/ele-watermark/types.d.ts +12 -0
  103. package/es/ele-watermark/util.d.ts +2 -9
  104. package/es/ele-watermark/util.js +10 -19
  105. package/es/lang/en_US.js +116 -0
  106. package/es/lang/zh_CN.js +116 -0
  107. package/es/lang/zh_TW.js +116 -0
  108. package/es/style/plus.scss +3 -1
  109. package/es/style/themes/default.scss +12 -3
  110. package/es/style/themes/rounded.scss +2 -1
  111. package/es/utils/theme-util.d.ts +1 -1
  112. package/lib/core-components.cjs +104 -100
  113. package/lib/core-components.d.ts +2 -0
  114. package/lib/ele-app/plus.d.ts +9 -1
  115. package/lib/ele-app/plusx.d.ts +26 -13
  116. package/lib/ele-backtop/index.cjs +6 -0
  117. package/lib/ele-basic-select/components/select-view.cjs +56 -19
  118. package/lib/ele-basic-select/components/select-view.d.ts +53 -22
  119. package/lib/ele-basic-select/index.cjs +61 -12
  120. package/lib/ele-basic-select/index.d.ts +39 -19
  121. package/lib/ele-basic-select/props.cjs +33 -21
  122. package/lib/ele-basic-select/props.d.ts +33 -21
  123. package/lib/ele-basic-select/style/index.cjs +2 -0
  124. package/lib/ele-basic-select/types.d.ts +1 -1
  125. package/lib/ele-config-provider/components/receiver-view.cjs +2 -2
  126. package/lib/ele-config-provider/components/receiver-view.d.ts +2 -0
  127. package/lib/ele-config-provider/receiver.cjs +5 -1
  128. package/lib/ele-config-provider/receiver.d.ts +2 -2
  129. package/lib/ele-config-provider/types.d.ts +10 -1
  130. package/lib/ele-copyable/index.d.ts +2 -4
  131. package/lib/ele-cron-builder/index.cjs +80 -0
  132. package/lib/ele-cron-builder/index.d.ts +24 -0
  133. package/lib/ele-cron-builder/props.cjs +24 -0
  134. package/lib/ele-cron-builder/props.d.ts +31 -0
  135. package/lib/ele-cron-builder/style/index.cjs +5 -0
  136. package/lib/ele-cron-builder/style/index.d.ts +1 -0
  137. package/lib/ele-cron-builder/style/index.scss +6 -0
  138. package/lib/ele-cron-builder/types.d.ts +8 -0
  139. package/lib/ele-cron-panel/components/cron-day.cjs +231 -0
  140. package/lib/ele-cron-panel/components/cron-day.d.ts +25 -0
  141. package/lib/ele-cron-panel/components/cron-hour.cjs +173 -0
  142. package/lib/ele-cron-panel/components/cron-hour.d.ts +25 -0
  143. package/lib/ele-cron-panel/components/cron-minute.cjs +173 -0
  144. package/lib/ele-cron-panel/components/cron-minute.d.ts +25 -0
  145. package/lib/ele-cron-panel/components/cron-month.cjs +173 -0
  146. package/lib/ele-cron-panel/components/cron-month.d.ts +25 -0
  147. package/lib/ele-cron-panel/components/cron-second.cjs +173 -0
  148. package/lib/ele-cron-panel/components/cron-second.d.ts +25 -0
  149. package/lib/ele-cron-panel/components/cron-week.cjs +228 -0
  150. package/lib/ele-cron-panel/components/cron-week.d.ts +25 -0
  151. package/lib/ele-cron-panel/components/cron-year.cjs +185 -0
  152. package/lib/ele-cron-panel/components/cron-year.d.ts +25 -0
  153. package/lib/ele-cron-panel/index.cjs +347 -0
  154. package/lib/ele-cron-panel/index.d.ts +14 -0
  155. package/lib/ele-cron-panel/props.cjs +14 -0
  156. package/lib/ele-cron-panel/props.d.ts +20 -0
  157. package/lib/ele-cron-panel/style/index.cjs +8 -0
  158. package/lib/ele-cron-panel/style/index.d.ts +1 -0
  159. package/lib/ele-cron-panel/style/index.scss +282 -0
  160. package/lib/ele-cron-panel/types.d.ts +118 -0
  161. package/lib/ele-cron-panel/util.cjs +542 -0
  162. package/lib/ele-cron-panel/util.d.ts +23 -0
  163. package/lib/ele-cropper/components/cropper-tools.d.ts +2 -2
  164. package/lib/ele-cropper-modal/index.d.ts +2 -4
  165. package/lib/ele-crud/index.d.ts +3 -3
  166. package/lib/ele-drawer/index.cjs +4 -0
  167. package/lib/ele-drawer/index.d.ts +9 -0
  168. package/lib/ele-drawer/props.cjs +6 -1
  169. package/lib/ele-drawer/props.d.ts +5 -0
  170. package/lib/ele-drawer/style/index.scss +11 -0
  171. package/lib/ele-file-list/index.d.ts +3 -3
  172. package/lib/ele-icon-select/components/icon-grid.cjs +19 -11
  173. package/lib/ele-icon-select/components/icon-grid.d.ts +8 -3
  174. package/lib/ele-icon-select/index.cjs +91 -85
  175. package/lib/ele-icon-select/index.d.ts +58 -59
  176. package/lib/ele-icon-select/props.cjs +34 -34
  177. package/lib/ele-icon-select/props.d.ts +35 -35
  178. package/lib/ele-icon-select/style/css-var.scss +1 -1
  179. package/lib/ele-icon-select/style/index.scss +50 -18
  180. package/lib/ele-icon-select/types.d.ts +13 -0
  181. package/lib/ele-map-picker/index.d.ts +3 -3
  182. package/lib/ele-modal/index.cjs +9 -3
  183. package/lib/ele-modal/index.d.ts +4 -2
  184. package/lib/ele-modal/props.cjs +2 -0
  185. package/lib/ele-modal/props.d.ts +2 -0
  186. package/lib/ele-modal/style/index.scss +16 -0
  187. package/lib/ele-pro-form/components/item-type-data.cjs +39 -64
  188. package/lib/ele-pro-form/index.d.ts +3 -3
  189. package/lib/ele-pro-table/components/table-tools.cjs +117 -247
  190. package/lib/ele-pro-table/components/table-tools.d.ts +12 -97
  191. package/lib/ele-pro-table/components/tool-export.cjs +32 -20
  192. package/lib/ele-pro-table/components/tool-export.d.ts +5 -1
  193. package/lib/ele-pro-table/components/tool-print.cjs +37 -25
  194. package/lib/ele-pro-table/components/tool-print.d.ts +5 -1
  195. package/lib/ele-pro-table/exceljs-plugin.cjs +81 -0
  196. package/lib/ele-pro-table/exceljs-plugin.d.ts +12 -0
  197. package/lib/ele-pro-table/index.cjs +143 -72
  198. package/lib/ele-pro-table/index.d.ts +6 -7
  199. package/lib/ele-pro-table/types.d.ts +11 -0
  200. package/lib/ele-split-panel/style/index.scss +1 -1
  201. package/lib/ele-table-select/index.d.ts +2 -0
  202. package/lib/ele-table-select/props.cjs +3 -1
  203. package/lib/ele-table-select/props.d.ts +2 -0
  204. package/lib/ele-tour/index.d.ts +3 -3
  205. package/lib/ele-tree-select/index.d.ts +2 -0
  206. package/lib/ele-upload-list/index.cjs +25 -8
  207. package/lib/ele-upload-list/index.d.ts +3 -3
  208. package/lib/ele-virtual-table/components/body-cell.d.ts +1 -1
  209. package/lib/ele-watermark/index.cjs +251 -92
  210. package/lib/ele-watermark/index.d.ts +20 -7
  211. package/lib/ele-watermark/props.cjs +10 -3
  212. package/lib/ele-watermark/props.d.ts +10 -3
  213. package/lib/ele-watermark/types.d.ts +12 -0
  214. package/lib/ele-watermark/util.cjs +10 -19
  215. package/lib/ele-watermark/util.d.ts +2 -9
  216. package/lib/lang/en_US.cjs +116 -0
  217. package/lib/lang/zh_CN.cjs +116 -0
  218. package/lib/lang/zh_TW.cjs +116 -0
  219. package/lib/style/plus.scss +3 -1
  220. package/lib/style/themes/default.scss +12 -3
  221. package/lib/style/themes/rounded.scss +2 -1
  222. package/lib/utils/theme-util.d.ts +1 -1
  223. package/package.json +1 -1
  224. package/typings/global.d.ts +2 -0
@@ -2,6 +2,17 @@
2
2
  const vue = require("vue");
3
3
  const util = require("./util");
4
4
  const props = require("./props");
5
+ const _hoisted_1 = ["id", "width", "height"];
6
+ const _hoisted_2 = ["transform"];
7
+ const _hoisted_3 = ["href", "width", "height", "x", "y"];
8
+ const _hoisted_4 = ["transform"];
9
+ const _hoisted_5 = ["href", "width", "height", "x", "y"];
10
+ const _hoisted_6 = ["id", "width", "height"];
11
+ const _hoisted_7 = ["transform"];
12
+ const _hoisted_8 = ["x", "y", "fill", "font-size", "font-weight", "font-family", "font-style"];
13
+ const _hoisted_9 = ["transform"];
14
+ const _hoisted_10 = ["x", "y", "fill", "font-size", "font-weight", "font-family", "font-style"];
15
+ const _hoisted_11 = ["fill", "transform"];
5
16
  const SIZE = 2;
6
17
  const _sfc_main = /* @__PURE__ */ vue.defineComponent({
7
18
  ...{ name: "EleWatermark" },
@@ -9,7 +20,7 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
9
20
  props: props.watermarkProps,
10
21
  setup(__props) {
11
22
  const props2 = __props;
12
- const { observe, disconnect } = util.useMutation({
23
+ const { observe, observeTextNode, disconnect } = util.useMutation({
13
24
  getRoot: () => rootRef.value,
14
25
  getEl: () => imgRef.value,
15
26
  onDeleted: () => {
@@ -23,95 +34,121 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
23
34
  render();
24
35
  }
25
36
  });
37
+ const svgId = vue.useId();
26
38
  const rootKey = vue.ref(1);
27
39
  const rootRef = vue.ref(null);
28
40
  const imgRef = vue.ref(null);
29
- const imgStyle = vue.ref({ display: "none" });
30
- const updateStyle = (base64, size) => {
41
+ const imgStyle = vue.ref(util.joinStyle({ display: "none" }));
42
+ const markWidth = vue.computed(() => {
43
+ return props2.width ?? 120;
44
+ });
45
+ const markHeight = vue.computed(() => {
46
+ return props2.height ?? 64;
47
+ });
48
+ const markGapX = vue.computed(() => {
49
+ var _a;
50
+ return ((_a = props2.gap) == null ? void 0 : _a[0]) ?? 100;
51
+ });
52
+ const markGapY = vue.computed(() => {
53
+ var _a;
54
+ return ((_a = props2.gap) == null ? void 0 : _a[1]) ?? 100;
55
+ });
56
+ const markOffsetX = vue.computed(() => {
57
+ var _a;
58
+ return ((_a = props2.offset) == null ? void 0 : _a[0]) ?? markGapX.value / 2;
59
+ });
60
+ const markOffsetY = vue.computed(() => {
61
+ var _a;
62
+ return ((_a = props2.offset) == null ? void 0 : _a[1]) ?? markGapY.value / 2;
63
+ });
64
+ const markFont = vue.computed(() => {
65
+ return {
66
+ color: "rgba(122, 122, 122, 0.35)",
67
+ fontSize: 16,
68
+ fontWeight: "normal",
69
+ fontFamily: "sans-serif",
70
+ fontStyle: "normal",
71
+ ...props2.font || {}
72
+ };
73
+ });
74
+ const markContents = vue.computed(() => {
75
+ if (typeof props2.content === "string") {
76
+ return [props2.content];
77
+ }
78
+ return props2.content || [];
79
+ });
80
+ const markCommonStyle = vue.computed(() => {
31
81
  const position = props2.fixed ? "fixed" : "absolute";
32
82
  const width = props2.fixed ? "100vw" : "100%";
33
83
  const height = props2.fixed ? "100vh" : "100%";
34
- const style = {
84
+ return {
35
85
  position: `${position} !important`,
36
86
  top: "0 !important",
37
87
  left: "0 !important",
38
- right: "auto !important",
39
- bottom: "auto !important",
88
+ right: "0 !important",
89
+ bottom: "0 !important",
40
90
  width: `${width} !important`,
41
91
  height: `${height} !important`,
92
+ zIndex: `${props2.zIndex ?? 2147483647} !important`,
42
93
  pointerEvents: "none !important",
43
- backgroundRepeat: "repeat !important",
44
- opacity: "1 !important",
45
- transform: "none !important",
46
- filter: "none !important",
47
- visibility: "visible !important",
48
- transition: "none !important",
49
- maxWidth: "none !important",
50
- maxHeight: "none !important",
51
- zoom: "1 !important",
52
- mask: "none !important",
53
- clipPath: "none !important",
54
- display: "block !important",
55
94
  ...props2.customStyle || {}
56
95
  };
96
+ });
97
+ const infoLog = vue.inject(util.INFO_LOG_KEY, void 0);
98
+ const svgStyle = vue.computed(() => util.joinStyle(markCommonStyle.value));
99
+ const updateStyle = (base64, imgWidth, imgHeight) => {
100
+ disconnect();
101
+ const style = { ...markCommonStyle.value };
57
102
  if (!base64) {
58
103
  style.display = "none !important";
59
104
  } else {
60
105
  style.backgroundImage = `url('${base64}') !important`;
61
- if (size) {
62
- style.backgroundSize = `${size} !important`;
106
+ style.backgroundSize = `${imgWidth}px ${imgHeight}px !important`;
107
+ let positionLeft = markOffsetX.value - markGapX.value / 2;
108
+ let positionTop = markOffsetY.value - markGapY.value / 2;
109
+ if (positionLeft > 0) {
110
+ style.left = `${positionLeft}px !important`;
111
+ style.width = `calc(100% - ${positionLeft}px) !important`;
112
+ positionLeft = 0;
113
+ }
114
+ if (positionTop > 0) {
115
+ style.top = `${positionTop}px !important`;
116
+ style.height = `calc(100% - ${positionTop}px) !important`;
117
+ positionTop = 0;
63
118
  }
64
- style.zIndex = `${props2.zIndex ?? 2147483647} !important`;
119
+ style.backgroundPosition = `${positionLeft}px ${positionTop}px !important`;
65
120
  }
66
- disconnect();
67
- if (imgRef.value && imgRef.value.style && imgRef.value.style.cssText) {
68
- imgRef.value.style.cssText = util.joinStyle(style);
121
+ imgStyle.value = util.joinStyle(style);
122
+ vue.nextTick(() => {
69
123
  observe();
70
- } else {
71
- imgStyle.value = style;
72
- vue.nextTick(() => {
73
- observe();
74
- });
75
- }
76
- };
77
- const infoLog = vue.inject(util.INFO_LOG_KEY, void 0);
78
- const getDefaultWidth = (ctx) => {
79
- if (props2.image || !ctx.measureText) {
80
- return 120;
81
- }
82
- const content = props2.content;
83
- const contents = Array.isArray(content) ? content : [content];
84
- const widths = contents.map((item) => ctx.measureText(item).width);
85
- return Math.ceil(Math.max(...widths));
86
- };
87
- const getDefaultHeight = (ctx) => {
88
- if (props2.image || !ctx.measureText) {
89
- return 64;
90
- }
91
- const lines = Array.isArray(props2.content) ? props2.content.length : 1;
92
- const { fontSize } = util.getFont(props2.font);
93
- return fontSize * lines + (lines - 1) * props2.lineGap;
124
+ });
94
125
  };
95
126
  const getMarkSize = (ctx) => {
96
- const width = props2.width;
97
- const height = props2.height;
98
- return [width ?? getDefaultWidth(ctx), height ?? getDefaultHeight(ctx)];
127
+ if (props2.image || props2.width != null && props2.height != null || !ctx.measureText) {
128
+ return [markWidth.value, markHeight.value];
129
+ }
130
+ const widths = markContents.value.map(
131
+ (text) => ctx.measureText(text).width
132
+ );
133
+ const textWidth = Math.ceil(Math.max(...widths));
134
+ const lines = markContents.value.length;
135
+ const { fontSize } = markFont.value;
136
+ const textHeight = fontSize * lines + (lines - 1) * props2.lineGap;
137
+ return [props2.width ?? textWidth, props2.height ?? textHeight];
99
138
  };
100
139
  const froined = vue.computed(() => !!(infoLog && !infoLog.froined));
140
+ const isDisabled = vue.computed(() => !(!props2.disabled || froined.value));
101
141
  const fillTexts = (ctx, drawX, drawY, drawWidth, drawHeight) => {
102
142
  const ratio = util.getPixelRatio();
103
- const { color, fontSize, fontStyle, fontWeight, fontFamily } = util.getFont(
104
- props2.font
105
- );
143
+ const { color, fontSize, fontStyle, fontWeight, fontFamily } = markFont.value;
106
144
  const mergedFontSize = fontSize * ratio;
107
- ctx.font = `${fontStyle} normal ${fontWeight} ${mergedFontSize}px/${drawHeight}px ${fontFamily}`;
108
145
  ctx.fillStyle = color;
146
+ ctx.font = `${fontStyle} normal ${fontWeight} ${mergedFontSize}px/${drawHeight}px ${fontFamily}`;
147
+ const froin = "el-n-d-s-p";
109
148
  ctx.textAlign = "center";
110
149
  ctx.textBaseline = "top";
111
150
  ctx.translate(drawWidth / 2, 0);
112
- const content = props2.content;
113
- const froin = ["el", "nimda", "sulp"].reverse().join(" ").split("");
114
- const contents = froined.value ? [`e${froin.reduce((n, m) => m + n, "")}`.toUpperCase()] : Array.isArray(content) ? content : content == null ? [] : [content];
151
+ const contents = froined.value ? [`e${observeTextNode(froin)}`.toUpperCase()] : markContents.value;
115
152
  contents.forEach((item, index) => {
116
153
  ctx.fillText(
117
154
  item ?? "",
@@ -121,9 +158,9 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
121
158
  });
122
159
  };
123
160
  const render = () => {
124
- if (props2.disabled && !froined.value) {
161
+ if (props2.svgRender || isDisabled.value) {
125
162
  disconnect();
126
- imgStyle.value = { display: "none" };
163
+ imgStyle.value = util.joinStyle({ display: "none" });
127
164
  return;
128
165
  }
129
166
  const canvas = document.createElement("canvas");
@@ -131,20 +168,21 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
131
168
  if (!ctx) {
132
169
  return;
133
170
  }
134
- const rotate = props2.rotate ?? -22;
171
+ const rotate = props2.rotate;
172
+ const gapX = markGapX.value;
173
+ const gapY = markGapY.value;
135
174
  if (!props2.image && ctx.measureText != null) {
136
- const { fontSize, fontFamily } = util.getFont(props2.font);
175
+ const { fontSize, fontFamily } = markFont.value;
137
176
  ctx.font = `${fontSize}px ${fontFamily}`;
138
177
  }
139
- const [markWidth, markHeight] = getMarkSize(ctx);
178
+ const [markWidth2, markHeight2] = getMarkSize(ctx);
140
179
  const ratio = util.getPixelRatio();
141
- const [gapX, gapY] = util.getGap(props2.gap);
142
- const canvasWidth = (gapX + markWidth) * ratio;
143
- const canvasHeight = (gapY + markHeight) * ratio;
180
+ const canvasWidth = (gapX + markWidth2) * ratio;
181
+ const canvasHeight = (gapY + markHeight2) * ratio;
144
182
  canvas.setAttribute("width", `${canvasWidth * SIZE}px`);
145
183
  canvas.setAttribute("height", `${canvasHeight * SIZE}px`);
146
- const drawWidth = markWidth * ratio;
147
- const drawHeight = markHeight * ratio;
184
+ const drawWidth = markWidth2 * ratio;
185
+ const drawHeight = markHeight2 * ratio;
148
186
  const rotateX = (drawWidth + gapX * ratio) / 2;
149
187
  const rotateY = (drawHeight + gapY * ratio) / 2;
150
188
  ctx.save();
@@ -159,52 +197,173 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
159
197
  const img = new Image();
160
198
  img.onload = () => {
161
199
  ctx.drawImage(img, drawX, drawY, drawWidth, drawHeight);
162
- ctx.restore();
163
- util.rotateWatermark(ctx, alternateRotateX, alternateRotateY, rotate);
164
- ctx.drawImage(
165
- img,
166
- alternateDrawX,
167
- alternateDrawY,
168
- drawWidth,
169
- drawHeight
200
+ {
201
+ ctx.restore();
202
+ util.rotateWatermark(ctx, alternateRotateX, alternateRotateY, rotate);
203
+ ctx.drawImage(
204
+ img,
205
+ alternateDrawX,
206
+ alternateDrawY,
207
+ drawWidth,
208
+ drawHeight
209
+ );
210
+ }
211
+ updateStyle(
212
+ canvas.toDataURL(),
213
+ (gapX + markWidth2) * SIZE,
214
+ (gapY + markHeight2) * SIZE
170
215
  );
171
- updateStyle(canvas.toDataURL(), `${(gapX + markWidth) * SIZE}px`);
172
216
  };
173
217
  img.crossOrigin = "anonymous";
174
218
  img.referrerPolicy = "no-referrer";
175
219
  img.src = props2.image;
176
220
  } else {
177
221
  fillTexts(ctx, drawX, drawY, drawWidth, drawHeight);
178
- ctx.restore();
179
- util.rotateWatermark(ctx, alternateRotateX, alternateRotateY, rotate);
180
- fillTexts(ctx, alternateDrawX, alternateDrawY, drawWidth, drawHeight);
181
- updateStyle(canvas.toDataURL(), `${(gapX + markWidth) * SIZE}px`);
222
+ {
223
+ ctx.restore();
224
+ util.rotateWatermark(ctx, alternateRotateX, alternateRotateY, rotate);
225
+ fillTexts(ctx, alternateDrawX, alternateDrawY, drawWidth, drawHeight);
226
+ }
227
+ updateStyle(
228
+ canvas.toDataURL(),
229
+ (gapX + markWidth2) * SIZE,
230
+ (gapY + markHeight2) * SIZE
231
+ );
182
232
  }
183
233
  };
184
- vue.onMounted(() => {
185
- render();
186
- });
187
234
  vue.watch(
188
- [() => props2, froined],
235
+ [
236
+ () => props2.rotate,
237
+ () => props2.image,
238
+ () => props2.lineGap,
239
+ () => props2.svgRender,
240
+ markWidth,
241
+ markHeight,
242
+ markGapX,
243
+ markGapY,
244
+ markOffsetX,
245
+ markOffsetY,
246
+ markFont,
247
+ markContents,
248
+ markCommonStyle,
249
+ isDisabled
250
+ ],
189
251
  () => {
190
252
  render();
191
253
  },
192
254
  { deep: true }
193
255
  );
256
+ vue.onMounted(() => {
257
+ render();
258
+ });
194
259
  return (_ctx, _cache) => {
195
260
  return vue.openBlock(), vue.createElementBlock("div", {
196
261
  ref_key: "rootRef",
197
262
  ref: rootRef,
198
263
  key: rootKey.value,
199
- style: vue.normalizeStyle(!_ctx.wrapPosition || _ctx.fixed ? void 0 : { position: "relative" })
264
+ style: vue.normalizeStyle([
265
+ props2.wrapHeight == null ? {} : { height: props2.wrapHeight },
266
+ !_ctx.wrapPosition || _ctx.fixed ? {} : { position: "relative" }
267
+ ])
200
268
  }, [
201
269
  vue.renderSlot(_ctx.$slots, "default"),
202
- !_ctx.disabled || froined.value ? (vue.openBlock(), vue.createElementBlock("div", {
203
- key: 0,
204
- ref_key: "imgRef",
205
- ref: imgRef,
206
- style: vue.normalizeStyle(imgStyle.value)
207
- }, null, 4)) : vue.createCommentVNode("", true)
270
+ !isDisabled.value ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
271
+ _ctx.svgRender ? (vue.openBlock(), vue.createElementBlock("svg", {
272
+ key: 0,
273
+ style: vue.normalizeStyle(svgStyle.value)
274
+ }, [
275
+ vue.createElementVNode("defs", null, [
276
+ _ctx.image ? (vue.openBlock(), vue.createElementBlock("pattern", {
277
+ key: 0,
278
+ id: `imgPattern-${vue.unref(svgId)}`,
279
+ patternUnits: "userSpaceOnUse",
280
+ width: (markWidth.value + markGapX.value) * SIZE,
281
+ height: (markHeight.value + markGapY.value) * SIZE
282
+ }, [
283
+ vue.createElementVNode("g", {
284
+ transform: `rotate(${_ctx.rotate}, ${(markWidth.value + markGapX.value) / 2}, ${(markHeight.value + markGapY.value) / 2})`
285
+ }, [
286
+ vue.createElementVNode("image", {
287
+ href: _ctx.image,
288
+ width: markWidth.value,
289
+ height: markHeight.value,
290
+ x: markGapX.value / 2,
291
+ y: markGapY.value / 2
292
+ }, null, 8, _hoisted_3)
293
+ ], 8, _hoisted_2),
294
+ (vue.openBlock(), vue.createElementBlock("g", {
295
+ key: 0,
296
+ transform: `rotate(${_ctx.rotate}, ${(markWidth.value + markGapX.value) / 2 + markWidth.value + markGapX.value}, ${(markHeight.value + markGapY.value) / 2 + markHeight.value + markGapY.value})`
297
+ }, [
298
+ vue.createElementVNode("image", {
299
+ href: _ctx.image,
300
+ width: markWidth.value,
301
+ height: markHeight.value,
302
+ x: markGapX.value / 2 + markWidth.value + markGapX.value,
303
+ y: markGapY.value / 2 + markHeight.value + markGapY.value
304
+ }, null, 8, _hoisted_5)
305
+ ], 8, _hoisted_4))
306
+ ], 8, _hoisted_1)) : (vue.openBlock(), vue.createElementBlock("pattern", {
307
+ key: 1,
308
+ id: `textPattern-${vue.unref(svgId)}`,
309
+ patternUnits: "userSpaceOnUse",
310
+ width: (markWidth.value + markGapX.value) * SIZE,
311
+ height: (markHeight.value + markGapY.value) * SIZE
312
+ }, [
313
+ vue.createElementVNode("g", {
314
+ transform: `rotate(${_ctx.rotate}, ${(markWidth.value + markGapX.value) / 2}, ${(markHeight.value + markGapY.value) / 2})`
315
+ }, [
316
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(markContents.value, (text, index) => {
317
+ return vue.openBlock(), vue.createElementBlock("text", {
318
+ key: index,
319
+ x: (markWidth.value + markGapX.value) / 2,
320
+ y: markGapY.value / 2 + index * (markFont.value.fontSize + _ctx.lineGap),
321
+ fill: markFont.value.color,
322
+ "font-size": markFont.value.fontSize,
323
+ "font-weight": markFont.value.fontWeight,
324
+ "font-family": markFont.value.fontFamily,
325
+ "font-style": markFont.value.fontStyle,
326
+ "text-anchor": "middle",
327
+ "alignment-baseline": "hanging",
328
+ "vector-effect": "non-scaling-stroke"
329
+ }, vue.toDisplayString(text), 9, _hoisted_8);
330
+ }), 128))
331
+ ], 8, _hoisted_7),
332
+ (vue.openBlock(), vue.createElementBlock("g", {
333
+ key: 0,
334
+ transform: `rotate(${_ctx.rotate}, ${(markWidth.value + markGapX.value) / 2 + markWidth.value + markGapX.value}, ${(markHeight.value + markGapY.value) / 2 + markHeight.value + markGapY.value})`
335
+ }, [
336
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(markContents.value, (text, index) => {
337
+ return vue.openBlock(), vue.createElementBlock("text", {
338
+ key: index,
339
+ x: (markWidth.value + markGapX.value) / 2 + markWidth.value + markGapX.value,
340
+ y: markGapY.value / 2 + index * (markFont.value.fontSize + _ctx.lineGap) + markHeight.value + markGapY.value,
341
+ fill: markFont.value.color,
342
+ "font-size": markFont.value.fontSize,
343
+ "font-weight": markFont.value.fontWeight,
344
+ "font-family": markFont.value.fontFamily,
345
+ "font-style": markFont.value.fontStyle,
346
+ "text-anchor": "middle",
347
+ "alignment-baseline": "hanging",
348
+ "vector-effect": "non-scaling-stroke"
349
+ }, vue.toDisplayString(text), 9, _hoisted_10);
350
+ }), 128))
351
+ ], 8, _hoisted_9))
352
+ ], 8, _hoisted_6))
353
+ ]),
354
+ vue.createElementVNode("rect", {
355
+ width: "100%",
356
+ height: "100%",
357
+ fill: `url(#${_ctx.image ? "img" : "text"}Pattern-${vue.unref(svgId)})`,
358
+ transform: `translate(${markOffsetX.value - markGapX.value / 2}, ${markOffsetY.value - markGapY.value / 2})`
359
+ }, null, 8, _hoisted_11)
360
+ ], 4)) : (vue.openBlock(), vue.createElementBlock("div", {
361
+ key: 1,
362
+ ref_key: "imgRef",
363
+ ref: imgRef,
364
+ style: vue.normalizeStyle(imgStyle.value)
365
+ }, null, 4))
366
+ ], 64)) : vue.createCommentVNode("", true)
208
367
  ], 4);
209
368
  };
210
369
  }
@@ -1,4 +1,5 @@
1
1
  import { StyleValue } from '../ele-app/types';
2
+ import { WatermarkFont } from './types';
2
3
 
3
4
  declare function __VLS_template(): {
4
5
  default?(_: {}): any;
@@ -6,11 +7,14 @@ declare function __VLS_template(): {
6
7
  declare const __VLS_component: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
7
8
  width: NumberConstructor;
8
9
  height: NumberConstructor;
9
- rotate: NumberConstructor;
10
+ rotate: {
11
+ type: NumberConstructor;
12
+ default: number;
13
+ };
10
14
  zIndex: NumberConstructor;
11
15
  image: StringConstructor;
12
16
  content: import('vue').PropType<string | string[]>;
13
- font: import('vue').PropType<import('./types').WatermarkFont>;
17
+ font: import('vue').PropType<WatermarkFont>;
14
18
  gap: import('vue').PropType<import('./types').WatermarkGap>;
15
19
  offset: import('vue').PropType<import('./types').WatermarkOffset>;
16
20
  lineGap: {
@@ -18,20 +22,25 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
18
22
  default: number;
19
23
  };
20
24
  customStyle: import('vue').PropType<Exclude<StyleValue, string>>;
25
+ svgRender: BooleanConstructor;
26
+ disabled: BooleanConstructor;
21
27
  fixed: BooleanConstructor;
22
28
  wrapPosition: {
23
29
  type: BooleanConstructor;
24
30
  default: boolean;
25
31
  };
26
- disabled: BooleanConstructor;
32
+ wrapHeight: StringConstructor;
27
33
  }>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
28
34
  width: NumberConstructor;
29
35
  height: NumberConstructor;
30
- rotate: NumberConstructor;
36
+ rotate: {
37
+ type: NumberConstructor;
38
+ default: number;
39
+ };
31
40
  zIndex: NumberConstructor;
32
41
  image: StringConstructor;
33
42
  content: import('vue').PropType<string | string[]>;
34
- font: import('vue').PropType<import('./types').WatermarkFont>;
43
+ font: import('vue').PropType<WatermarkFont>;
35
44
  gap: import('vue').PropType<import('./types').WatermarkGap>;
36
45
  offset: import('vue').PropType<import('./types').WatermarkOffset>;
37
46
  lineGap: {
@@ -39,17 +48,21 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
39
48
  default: number;
40
49
  };
41
50
  customStyle: import('vue').PropType<Exclude<StyleValue, string>>;
51
+ svgRender: BooleanConstructor;
52
+ disabled: BooleanConstructor;
42
53
  fixed: BooleanConstructor;
43
54
  wrapPosition: {
44
55
  type: BooleanConstructor;
45
56
  default: boolean;
46
57
  };
47
- disabled: BooleanConstructor;
58
+ wrapHeight: StringConstructor;
48
59
  }>> & Readonly<{}>, {
49
60
  fixed: boolean;
61
+ rotate: number;
50
62
  lineGap: number;
51
- wrapPosition: boolean;
63
+ svgRender: boolean;
52
64
  disabled: boolean;
65
+ wrapPosition: boolean;
53
66
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
54
67
  declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
55
68
  export default _default;
@@ -6,7 +6,10 @@ const watermarkProps = {
6
6
  /** 高度 */
7
7
  height: Number,
8
8
  /** 旋转角度 */
9
- rotate: Number,
9
+ rotate: {
10
+ type: Number,
11
+ default: -22
12
+ },
10
13
  /** 层级 */
11
14
  zIndex: Number,
12
15
  /** 图片源 */
@@ -26,6 +29,10 @@ const watermarkProps = {
26
29
  },
27
30
  /** 自定义样式 */
28
31
  customStyle: Object,
32
+ /** 是否使用 svg 渲染 */
33
+ svgRender: Boolean,
34
+ /** 是否禁用 */
35
+ disabled: Boolean,
29
36
  /** 是否使用固定定位 */
30
37
  fixed: Boolean,
31
38
  /** 是否为外层添加定位样式 */
@@ -33,7 +40,7 @@ const watermarkProps = {
33
40
  type: Boolean,
34
41
  default: true
35
42
  },
36
- /** 是否禁用 */
37
- disabled: Boolean
43
+ /** 外层高度 */
44
+ wrapHeight: String
38
45
  };
39
46
  exports.watermarkProps = watermarkProps;
@@ -8,7 +8,10 @@ export declare const watermarkProps: {
8
8
  /** 高度 */
9
9
  height: NumberConstructor;
10
10
  /** 旋转角度 */
11
- rotate: NumberConstructor;
11
+ rotate: {
12
+ type: NumberConstructor;
13
+ default: number;
14
+ };
12
15
  /** 层级 */
13
16
  zIndex: NumberConstructor;
14
17
  /** 图片源 */
@@ -28,6 +31,10 @@ export declare const watermarkProps: {
28
31
  };
29
32
  /** 自定义样式 */
30
33
  customStyle: PropType<Exclude<StyleValue, string>>;
34
+ /** 是否使用 svg 渲染 */
35
+ svgRender: BooleanConstructor;
36
+ /** 是否禁用 */
37
+ disabled: BooleanConstructor;
31
38
  /** 是否使用固定定位 */
32
39
  fixed: BooleanConstructor;
33
40
  /** 是否为外层添加定位样式 */
@@ -35,7 +42,7 @@ export declare const watermarkProps: {
35
42
  type: BooleanConstructor;
36
43
  default: boolean;
37
44
  };
38
- /** 是否禁用 */
39
- disabled: BooleanConstructor;
45
+ /** 外层高度 */
46
+ wrapHeight: StringConstructor;
40
47
  };
41
48
  export type WatermarkProps = ExtractPropTypes<typeof watermarkProps>;
@@ -37,3 +37,15 @@ export interface MutationOption {
37
37
  /** 水印样式被篡改回调 */
38
38
  onDalsified: () => void;
39
39
  }
40
+
41
+ /**
42
+ * 水印图片的数据
43
+ */
44
+ export interface WatermarkImgData {
45
+ /** 图片的宽度 */
46
+ width: number;
47
+ /** 图片的高度 */
48
+ height: number;
49
+ /** 图片的base64数据 */
50
+ base64: string;
51
+ }
@@ -2,20 +2,6 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const vue = require("vue");
4
4
  const common = require("../utils/common");
5
- function getFont(font) {
6
- const style = {
7
- color: "rgba(122, 122, 122, .35)",
8
- fontSize: 16,
9
- fontWeight: "normal",
10
- fontFamily: "sans-serif",
11
- fontStyle: "normal"
12
- };
13
- return Object.assign(style, font);
14
- }
15
- function getGap(gap) {
16
- const [gapX, gapY] = gap ?? [];
17
- return [gapX ?? 100, gapY ?? 100];
18
- }
19
5
  function getPixelRatio() {
20
6
  return window.devicePixelRatio || 1;
21
7
  }
@@ -31,9 +17,9 @@ function rotateWatermark(ctx, rotateX, rotateY, rotate) {
31
17
  function joinStyle(style) {
32
18
  const result = Object.keys(style).map((key) => {
33
19
  const name = key.replace(/([A-Z])/g, " $1").trim().split(" ").join("-").toLowerCase();
34
- return `${name}:${style[key]}`;
20
+ return `${name}:${style[key]};`;
35
21
  });
36
- return result.join(";");
22
+ return result.join("");
37
23
  }
38
24
  function useMutation(option) {
39
25
  const { getRoot, getEl, onDeleted, onDalsified } = option;
@@ -48,6 +34,13 @@ function useMutation(option) {
48
34
  const falsifiedObserver = new MutationObserver(() => {
49
35
  onDalsified();
50
36
  });
37
+ const observeTextNode = (text) => {
38
+ let i = 0;
39
+ return text.replace(/-/g, () => {
40
+ i++;
41
+ return ["", "-", "im", "a-", "ul"][i];
42
+ }).split("-").reverse().join(" ").split("").reduce((n, m) => m + n, "");
43
+ };
51
44
  const observe = () => {
52
45
  const el = getEl();
53
46
  if (el) {
@@ -65,14 +58,12 @@ function useMutation(option) {
65
58
  vue.onBeforeUnmount(() => {
66
59
  disconnect();
67
60
  });
68
- return { observe, disconnect };
61
+ return { observe, observeTextNode, disconnect };
69
62
  }
70
63
  Object.defineProperty(exports, "INFO_LOG_KEY", {
71
64
  enumerable: true,
72
65
  get: () => common.ERROR_MESSAGE_KEY
73
66
  });
74
- exports.getFont = getFont;
75
- exports.getGap = getGap;
76
67
  exports.getPixelRatio = getPixelRatio;
77
68
  exports.joinStyle = joinStyle;
78
69
  exports.rotateWatermark = rotateWatermark;