@guodun/antdv 1.7.11 → 1.7.13
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/dist/es/components/contract-signing-location/src/ContractSigningLocation.vue.mjs +370 -294
- package/dist/es/components/contract-signing-location/src/ContractSigningLocationCanvas.vue.mjs +219 -202
- package/dist/es/components/contract-signing-location/src/ContractSigningTemplatePage.vue.mjs +18 -18
- package/dist/es/components/contract-signing-location/src/template-source.mjs +62 -49
- package/dist/es/components/index.mjs +1 -0
- package/dist/es/components/pro-contract-template-designer/index.mjs +1 -0
- package/dist/es/components/pro-contract-template-designer/src/ContractTemplatePreviewPage.vue.mjs +37 -42
- package/dist/es/components/pro-contract-template-designer/src/ContractTemplateRendererPage.vue.mjs +69 -55
- package/dist/es/components/pro-contract-template-designer/src/ContractTemplateSingleRenderer.vue.mjs +278 -270
- package/dist/es/components/pro-contract-template-designer/src/DesignerPage.vue.mjs +344 -343
- package/dist/es/components/pro-contract-template-designer/src/ProContractTemplateDesigner.vue.mjs +1046 -1000
- package/dist/es/components/pro-contract-template-designer/src/ProContractTemplateRenderer.vue.mjs +120 -74
- package/dist/es/components/pro-contract-template-designer/src/composables/use-template-designer.mjs +133 -132
- package/dist/es/components/pro-contract-template-designer/src/constants.mjs +7 -7
- package/dist/es/components/pro-contract-template-designer/src/utils/contract-layout-check.mjs +239 -0
- package/dist/es/components/pro-contract-template-designer/src/utils/contract-print-document.mjs +99 -75
- package/dist/es/components/pro-contract-template-designer/src/utils/page-decorations.mjs +67 -76
- package/dist/es/components/pro-contract-template-designer/src/utils/template-renderer.mjs +96 -83
- package/dist/es/components/pro-contract-template-designer/src/utils/template-variable-render.mjs +23 -15
- package/dist/es/components/pro-contract-template-designer/style/index.css +1 -1
- package/dist/es/contract-print-css/index.mjs +473 -0
- package/dist/es/contract-print.mjs +2 -0
- package/dist/es/index.mjs +21 -20
- package/dist/lib/components/contract-signing-location/src/ContractSigningLocation.vue.cjs +1 -1
- package/dist/lib/components/contract-signing-location/src/ContractSigningLocationCanvas.vue.cjs +1 -1
- package/dist/lib/components/contract-signing-location/src/ContractSigningTemplatePage.vue.cjs +1 -1
- package/dist/lib/components/contract-signing-location/src/template-source.cjs +1 -1
- package/dist/lib/components/index.cjs +1 -1
- package/dist/lib/components/pro-contract-template-designer/index.cjs +1 -1
- package/dist/lib/components/pro-contract-template-designer/src/ContractTemplatePreviewPage.vue.cjs +1 -1
- package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateRendererPage.vue.cjs +1 -1
- package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateSingleRenderer.vue.cjs +1 -1
- package/dist/lib/components/pro-contract-template-designer/src/DesignerPage.vue.cjs +2 -2
- package/dist/lib/components/pro-contract-template-designer/src/ProContractTemplateDesigner.vue.cjs +1 -1
- package/dist/lib/components/pro-contract-template-designer/src/ProContractTemplateRenderer.vue.cjs +1 -1
- package/dist/lib/components/pro-contract-template-designer/src/composables/use-template-designer.cjs +4 -4
- package/dist/lib/components/pro-contract-template-designer/src/constants.cjs +1 -1
- package/dist/lib/components/pro-contract-template-designer/src/utils/contract-layout-check.cjs +1 -0
- package/dist/lib/components/pro-contract-template-designer/src/utils/contract-print-document.cjs +52 -30
- package/dist/lib/components/pro-contract-template-designer/src/utils/page-decorations.cjs +1 -1
- package/dist/lib/components/pro-contract-template-designer/src/utils/template-renderer.cjs +5 -5
- package/dist/lib/components/pro-contract-template-designer/src/utils/template-variable-render.cjs +1 -1
- package/dist/lib/components/pro-contract-template-designer/style/index.css +1 -1
- package/dist/lib/contract-print-css/index.cjs +413 -0
- package/dist/lib/contract-print.cjs +1 -0
- package/dist/lib/index.cjs +1 -1
- package/dist/theme/icon.css +1 -1
- package/dist/theme/index.css +1 -1
- package/dist/types/components/contract-signing-location/src/ContractSigningLocation.vue.d.ts +9 -0
- package/dist/types/components/contract-signing-location/src/ContractSigningLocationCanvas.vue.d.ts +7 -0
- package/dist/types/components/contract-signing-location/src/template-source.d.ts +6 -0
- package/dist/types/components/pro-contract-template-designer/index.d.ts +1 -0
- package/dist/types/components/pro-contract-template-designer/src/ContractTemplateSingleRenderer.vue.d.ts +2 -0
- package/dist/types/components/pro-contract-template-designer/src/ProContractTemplateDesigner.vue.d.ts +5 -1
- package/dist/types/components/pro-contract-template-designer/src/ProContractTemplateRenderer.vue.d.ts +7 -2
- package/dist/types/components/pro-contract-template-designer/src/composables/use-template-designer.d.ts +2 -2
- package/dist/types/components/pro-contract-template-designer/src/types.d.ts +36 -0
- package/dist/types/components/pro-contract-template-designer/src/utils/contract-layout-check.d.ts +104 -0
- package/dist/types/components/pro-contract-template-designer/src/utils/contract-print-document.d.ts +4 -1
- package/dist/types/components/pro-contract-template-designer/src/utils/page-decorations.d.ts +2 -8
- package/dist/types/components/pro-contract-template-designer/src/utils/template-renderer.d.ts +6 -1
- package/dist/types/contract-print-css/index.d.ts +99 -0
- package/dist/types/contract-print.d.ts +2 -0
- package/package.json +16 -5
|
@@ -2,12 +2,12 @@ import { canParseHtmlDocument as e, canUseDomHtml as t, collectFromHtmlTags as n
|
|
|
2
2
|
import { resolveTemplateVariablePresentation as c } from "./template-variable-render.mjs";
|
|
3
3
|
import { buildPageDecorationClassNames as l, buildPageDecorationsHtml as u, collectPageDecorationVariableKeys as d, normalizePageDecorations as f, validatePageDecorations as p } from "./page-decorations.mjs";
|
|
4
4
|
import { isContractTemplateFieldType as m } from "../types.mjs";
|
|
5
|
-
import { buildRadioOptionsHtml as h, formatContractTemplateRenderValue as g, isContractTemplateSelectionValue as _ } from "./advanced-controls.mjs";
|
|
6
|
-
import { CONTRACT_TEMPLATE_RESERVED_VARIABLE_KEYS as
|
|
7
|
-
import { isSafeContractImageUrl as
|
|
5
|
+
import { buildRadioOptionsHtml as h, formatContractTemplateRenderValue as g, isContractTemplateSelectionValue as _, normalizeContractTemplateJsonObject as ee } from "./advanced-controls.mjs";
|
|
6
|
+
import { CONTRACT_TEMPLATE_RESERVED_VARIABLE_KEYS as te, CONTRACT_TEMPLATE_VARIABLE_KEY_PATTERN as v, DEFAULT_PAGE_SIZE as y, resolvePageSize as b, validateContractTemplateVariableKey as ne } from "../composables/use-template-designer.mjs";
|
|
7
|
+
import { isSafeContractImageUrl as x } from "./image-url.mjs";
|
|
8
8
|
//#region src/components/pro-contract-template-designer/src/utils/template-renderer.ts
|
|
9
|
-
function
|
|
10
|
-
let t = Array.isArray(e?.variables) ? e.variables : [], n = t.map((e) =>
|
|
9
|
+
function re(e) {
|
|
10
|
+
let t = Array.isArray(e?.variables) ? e.variables : [], n = t.map((e) => ie(e)), r = {};
|
|
11
11
|
return t.forEach((e) => {
|
|
12
12
|
let t = typeof e?.key == "string" ? e.key : "";
|
|
13
13
|
if (t) {
|
|
@@ -27,10 +27,10 @@ function ie(e) {
|
|
|
27
27
|
variables: n
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
|
-
function
|
|
30
|
+
function ie(e) {
|
|
31
31
|
return JSON.parse(JSON.stringify(e));
|
|
32
32
|
}
|
|
33
|
-
var
|
|
33
|
+
var ae = new Set([
|
|
34
34
|
"action",
|
|
35
35
|
"formaction",
|
|
36
36
|
"href",
|
|
@@ -40,17 +40,30 @@ var x = new Set([
|
|
|
40
40
|
function D(e) {
|
|
41
41
|
let t = {};
|
|
42
42
|
return (Array.isArray(e?.variables) ? e.variables : []).forEach((e) => {
|
|
43
|
-
e?.key && (t[e.key] =
|
|
43
|
+
e?.key && (t[e.key] = H(e));
|
|
44
44
|
}), t;
|
|
45
45
|
}
|
|
46
|
-
function
|
|
46
|
+
function O(e, t) {
|
|
47
47
|
return {
|
|
48
48
|
...D(e),
|
|
49
49
|
...t ?? {}
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
|
-
function
|
|
53
|
-
let
|
|
52
|
+
function k(e, t, n) {
|
|
53
|
+
let r = { ...t };
|
|
54
|
+
return (Array.isArray(e?.variables) ? e.variables : []).forEach((e) => {
|
|
55
|
+
if (!e?.key || !m(e.type ?? "text")) return;
|
|
56
|
+
let t = e.componentKey || e.type || "", i = t ? n?.[t] : void 0;
|
|
57
|
+
if (i?.toDisplayText) try {
|
|
58
|
+
r[e.key] = i.toDisplayText(r[e.key], {
|
|
59
|
+
variable: e,
|
|
60
|
+
config: ee(e.componentConfig)
|
|
61
|
+
});
|
|
62
|
+
} catch {}
|
|
63
|
+
}), r;
|
|
64
|
+
}
|
|
65
|
+
function A(e, t) {
|
|
66
|
+
let n = M(e);
|
|
54
67
|
if (!e) return n;
|
|
55
68
|
let r = Array.isArray(e.variables) ? e.variables : [], i = new Set(r.map((e) => e?.key).filter(Boolean));
|
|
56
69
|
return Object.keys(t).forEach((e) => {
|
|
@@ -63,8 +76,8 @@ function O(e, t) {
|
|
|
63
76
|
});
|
|
64
77
|
}), r.forEach((e) => {
|
|
65
78
|
if (!e?.key) return;
|
|
66
|
-
let r =
|
|
67
|
-
if (e.required &&
|
|
79
|
+
let r = Q(e, t[e.key]), i = e.label || e.key;
|
|
80
|
+
if (e.required && F(r)) {
|
|
68
81
|
n.push({
|
|
69
82
|
type: "variable",
|
|
70
83
|
id: e.id,
|
|
@@ -74,33 +87,33 @@ function O(e, t) {
|
|
|
74
87
|
});
|
|
75
88
|
return;
|
|
76
89
|
}
|
|
77
|
-
if (
|
|
90
|
+
if (F(r)) return;
|
|
78
91
|
let a = e.type ?? "text";
|
|
79
|
-
a === "number" && !
|
|
92
|
+
a === "number" && !de(r, e.precision, e.format) && n.push({
|
|
80
93
|
type: "variable",
|
|
81
94
|
id: e.id,
|
|
82
95
|
variableKey: e.key,
|
|
83
96
|
message: `${i} 不是合法数字或超出精度`,
|
|
84
97
|
code: "VARIABLE_TYPE_INVALID"
|
|
85
|
-
}), a === "checkbox" && !
|
|
98
|
+
}), a === "checkbox" && !pe(r) && n.push({
|
|
86
99
|
type: "variable",
|
|
87
100
|
id: e.id,
|
|
88
101
|
variableKey: e.key,
|
|
89
102
|
message: `${i} 不是合法勾选值`,
|
|
90
103
|
code: "VARIABLE_TYPE_INVALID"
|
|
91
|
-
}), a === "date" && !
|
|
104
|
+
}), a === "date" && !fe(r) && n.push({
|
|
92
105
|
type: "variable",
|
|
93
106
|
id: e.id,
|
|
94
107
|
variableKey: e.key,
|
|
95
108
|
message: `${i} 不是合法日期`,
|
|
96
109
|
code: "VARIABLE_TYPE_INVALID"
|
|
97
|
-
}), a === "image" && !
|
|
110
|
+
}), a === "image" && !me(String(r).trim()) && n.push({
|
|
98
111
|
type: "security",
|
|
99
112
|
id: e.id,
|
|
100
113
|
variableKey: e.key,
|
|
101
114
|
message: `${i} 必须使用安全的图片 data URL`,
|
|
102
115
|
code: "UNSAFE_IMAGE_URL"
|
|
103
|
-
}), n.push(...
|
|
116
|
+
}), n.push(...j(e, r)), he(a) && (ge(r, a !== "radio" && !!e.multiple) ? G(e) && !K(e, r) && n.push({
|
|
104
117
|
type: "variable",
|
|
105
118
|
id: e.id,
|
|
106
119
|
variableKey: e.key,
|
|
@@ -115,10 +128,10 @@ function O(e, t) {
|
|
|
115
128
|
}));
|
|
116
129
|
}), n;
|
|
117
130
|
}
|
|
118
|
-
function
|
|
131
|
+
function j(e, t) {
|
|
119
132
|
if ((e.type ?? "text") !== "text") return [];
|
|
120
|
-
let n =
|
|
121
|
-
if (
|
|
133
|
+
let n = Q(e, t);
|
|
134
|
+
if (F(n) || !_e(e, String(n))) return [];
|
|
122
135
|
let r = e.label || e.key;
|
|
123
136
|
return [{
|
|
124
137
|
type: "variable",
|
|
@@ -129,9 +142,9 @@ function k(e, t) {
|
|
|
129
142
|
}];
|
|
130
143
|
}
|
|
131
144
|
function oe(e, t, n) {
|
|
132
|
-
return
|
|
145
|
+
return A(e, t);
|
|
133
146
|
}
|
|
134
|
-
function
|
|
147
|
+
function M(e) {
|
|
135
148
|
if (!e) return [{
|
|
136
149
|
type: "page",
|
|
137
150
|
id: "template",
|
|
@@ -166,7 +179,7 @@ function A(e) {
|
|
|
166
179
|
});
|
|
167
180
|
return;
|
|
168
181
|
}
|
|
169
|
-
let a = e.key.trim(), o = r.some((t) => t?.id !== e.id && typeof t?.key == "string" && t.key.trim() === a), s = ne(e.key, r, e.id), c = !
|
|
182
|
+
let a = e.key.trim(), o = r.some((t) => t?.id !== e.id && typeof t?.key == "string" && t.key.trim() === a), s = ne(e.key, r, e.id), c = !v.test(a) || te.has(a);
|
|
170
183
|
s && (c || !o || e.key !== a) && t.push({
|
|
171
184
|
type: "variable",
|
|
172
185
|
id: e.id || `variable-${n}`,
|
|
@@ -207,7 +220,7 @@ function A(e) {
|
|
|
207
220
|
pageId: e.id,
|
|
208
221
|
message: `${e.title || `第 ${n + 1} 页`}:页面尺寸必须在 ${C} ~ ${w} CSS px 之间`,
|
|
209
222
|
code: "PAGE_SIZE_INVALID"
|
|
210
|
-
}),
|
|
223
|
+
}), ce(e.contentHtml).forEach((e) => a.add(e)), le(e.contentHtml).forEach((r, i) => {
|
|
211
224
|
t.push({
|
|
212
225
|
type: "security",
|
|
213
226
|
id: `${e.id}-security-${i}`,
|
|
@@ -236,59 +249,59 @@ function A(e) {
|
|
|
236
249
|
});
|
|
237
250
|
}), t.push(...p(e.pageDecorations, r)), t;
|
|
238
251
|
}
|
|
239
|
-
function
|
|
252
|
+
function N(e, t, n = {}) {
|
|
240
253
|
if (!e || !Array.isArray(e.pages)) return [];
|
|
241
|
-
let r = Array.isArray(e.variables) ? e.variables : [], i = new Map(r.filter((e) => e?.key).map((e) => [e.key, e])), a = o(e.pageSize) ? e.pageSize :
|
|
254
|
+
let r = Array.isArray(e.variables) ? e.variables : [], i = new Map(r.filter((e) => e?.key).map((e) => [e.key, e])), a = o(e.pageSize) ? e.pageSize : y;
|
|
242
255
|
return e.pages.flatMap((o) => {
|
|
243
256
|
if (!o || typeof o.id != "string" || !o.id.trim() || typeof o.contentHtml != "string") return [];
|
|
244
|
-
let s =
|
|
257
|
+
let s = b(o.pageSize, a);
|
|
245
258
|
return [{
|
|
246
259
|
id: o.id,
|
|
247
260
|
title: o.title || "未命名页面",
|
|
248
261
|
format: s.format ?? "Custom",
|
|
249
262
|
width: s.width,
|
|
250
263
|
height: s.height,
|
|
251
|
-
contentHtml:
|
|
264
|
+
contentHtml: I(o.contentHtml, i, t, n),
|
|
252
265
|
...e.pageDecorations ? { pageDecorations: f(e.pageDecorations) } : {},
|
|
253
266
|
decorationVariables: r,
|
|
254
267
|
decorationValues: t
|
|
255
268
|
}];
|
|
256
269
|
});
|
|
257
270
|
}
|
|
258
|
-
function
|
|
259
|
-
return
|
|
271
|
+
function P(e, t, n = {}) {
|
|
272
|
+
return N(e, t, n).map((e, t, n) => {
|
|
260
273
|
let i = u(e.pageDecorations, t + 1, n.length, e.decorationVariables, e.decorationValues);
|
|
261
274
|
return `<section class="${l(e.pageDecorations, t + 1)}" data-page-id="${r(e.id)}" data-page-format="${r(e.format)}" data-page-width="${e.width}" data-page-height="${e.height}" style="width:${e.width}px;min-height:${e.height}px">${i}<div class="gd-contract-template-page__content">${e.contentHtml}</div></section>`;
|
|
262
275
|
}).join("\n");
|
|
263
276
|
}
|
|
264
|
-
function
|
|
277
|
+
function F(e) {
|
|
265
278
|
return e == null || e === "" || Array.isArray(e) && e.length === 0;
|
|
266
279
|
}
|
|
267
|
-
function
|
|
280
|
+
function I(e, n, r, i) {
|
|
268
281
|
if (!e) return e;
|
|
269
|
-
let o =
|
|
282
|
+
let o = Y(e);
|
|
270
283
|
if (t()) {
|
|
271
284
|
let e = new DOMParser().parseFromString(o, "text/html");
|
|
272
285
|
return e.querySelectorAll("[data-template-variable]").forEach((e) => {
|
|
273
|
-
|
|
286
|
+
L(e, n, r, i);
|
|
274
287
|
}), e.body.innerHTML.replace(/(<textarea\b[^>]*data-contract-render-control="true"[^>]*>)(?=[\r\n])/gi, "$1\n");
|
|
275
288
|
}
|
|
276
289
|
return s(o, (e, t) => {
|
|
277
290
|
let o = a(t, "data-key");
|
|
278
|
-
return o ?
|
|
291
|
+
return o ? R(n.get(o), o, r[o], i) : e;
|
|
279
292
|
});
|
|
280
293
|
}
|
|
281
|
-
function
|
|
294
|
+
function L(e, t, n, r) {
|
|
282
295
|
let i = e.dataset.key || "", a = t.get(i);
|
|
283
296
|
if (!i || !a) return;
|
|
284
|
-
let o = new DOMParser().parseFromString(
|
|
285
|
-
o && (o.tagName === "TEXTAREA" && (o.textContent =
|
|
297
|
+
let o = new DOMParser().parseFromString(R(a, i, n[i], r), "text/html").body.firstElementChild;
|
|
298
|
+
o && (o.tagName === "TEXTAREA" && (o.textContent = q(V(a, n[i]))), e.replaceWith(o));
|
|
286
299
|
}
|
|
287
|
-
function
|
|
288
|
-
return r.mode === "display" ?
|
|
300
|
+
function R(e, t, n, r) {
|
|
301
|
+
return r.mode === "display" ? z(e, t, n, r) : B(e, t, n, r);
|
|
289
302
|
}
|
|
290
|
-
function
|
|
291
|
-
let o = e?.type ?? "text", s =
|
|
303
|
+
function z(e, t, n, a) {
|
|
304
|
+
let o = e?.type ?? "text", s = V(e, n), l = o === "image" && !F(s) && !x(String(s)) ? "" : s, u = se(l), d = c({
|
|
292
305
|
type: o,
|
|
293
306
|
width: e?.width,
|
|
294
307
|
height: e?.height,
|
|
@@ -309,7 +322,7 @@ function L(e, t, n, a) {
|
|
|
309
322
|
"gd-contract-template-renderer__preview-control",
|
|
310
323
|
...d.classes,
|
|
311
324
|
a.activeKey === t ? "is-active" : "",
|
|
312
|
-
|
|
325
|
+
F(l) ? "is-empty" : ""
|
|
313
326
|
].filter(Boolean).join(" "))}"`,
|
|
314
327
|
`style="${r(d.styleText)}"`,
|
|
315
328
|
"data-contract-render-wrapper=\"true\"",
|
|
@@ -320,10 +333,10 @@ function L(e, t, n, a) {
|
|
|
320
333
|
a.disabled ? "" : "role=\"button\"",
|
|
321
334
|
a.disabled ? "" : "tabindex=\"0\""
|
|
322
335
|
].filter(Boolean).join(" ");
|
|
323
|
-
return o === "checkbox" ? `<span ${p}><span class="gd-contract-template-renderer__checkbox-mark" aria-hidden="true">${
|
|
336
|
+
return o === "checkbox" ? `<span ${p}><span class="gd-contract-template-renderer__checkbox-mark" aria-hidden="true">${J(l) ? "✓" : ""}</span>${i(f)}</span>` : o === "radio" ? `<span ${p}>${h(e?.options, U(l)) || i(e?.placeholder || f)}</span>` : o === "select" ? `<span ${p}>${i(W(e, l) || f)}</span>` : o === "image" && !F(l) ? `<span ${p}></span>` : `<span ${p}>${i(f)}</span>`;
|
|
324
337
|
}
|
|
325
|
-
function
|
|
326
|
-
let o = e?.type ?? "text", s = !!a.readonly, l =
|
|
338
|
+
function B(e, t, n, a) {
|
|
339
|
+
let o = e?.type ?? "text", s = !!a.readonly, l = q(V(e, n)), u = c({
|
|
327
340
|
type: o,
|
|
328
341
|
width: e?.width,
|
|
329
342
|
height: e?.height,
|
|
@@ -346,16 +359,16 @@ function R(e, t, n, a) {
|
|
|
346
359
|
d ? "disabled" : "",
|
|
347
360
|
s ? "readonly" : ""
|
|
348
361
|
].filter(Boolean).join(" "), p = `style="${r(u.styleText)}"`, m = r(["gd-contract-template-renderer__control", ...u.classes].join(" "));
|
|
349
|
-
if (o === "checkbox") return `<label class="${m}" ${p} data-contract-render-wrapper="true" data-key="${r(t)}"><input type="checkbox" ${f} ${
|
|
362
|
+
if (o === "checkbox") return `<label class="${m}" ${p} data-contract-render-wrapper="true" data-key="${r(t)}"><input type="checkbox" ${f} ${J(l) ? "checked" : ""}>${i(e?.checkedText || e?.label || t)}</label>`;
|
|
350
363
|
if (o === "radio") {
|
|
351
|
-
let a =
|
|
364
|
+
let a = V(e, n), o = h(e?.options, U(a)) || i(u.displayText || e?.placeholder || "");
|
|
352
365
|
return `<span class="${m}" ${p} data-contract-render-wrapper="true" data-key="${r(t)}">${o}</span>`;
|
|
353
366
|
}
|
|
354
367
|
if (s) return `<span class="${m}" ${p} data-contract-render-wrapper="true" data-key="${r(t)}">${i(u.displayText || l)}</span>`;
|
|
355
368
|
if (o === "number") return `<input class="${m}" ${p} type="number" ${f} value="${r(l)}" placeholder="${r(e?.placeholder || "")}">`;
|
|
356
369
|
if (o === "date") return `<input class="${m}" ${p} type="date" ${f} value="${r(l)}" placeholder="${r(e?.placeholder || "")}">`;
|
|
357
370
|
if (o === "select" || o.endsWith("-selector") || o === "custom") {
|
|
358
|
-
let a =
|
|
371
|
+
let a = V(e, n), s = o === "select" ? W(e, a) : g(a);
|
|
359
372
|
return `<span class="${m}" ${p} data-contract-render-wrapper="true" data-key="${r(t)}">${i(s)}</span>`;
|
|
360
373
|
}
|
|
361
374
|
if (e?.multiline) {
|
|
@@ -364,12 +377,12 @@ function R(e, t, n, a) {
|
|
|
364
377
|
}
|
|
365
378
|
return `<input class="${m}" ${p} type="text" ${f} value="${r(l)}" placeholder="${r(e?.placeholder || "")}">`;
|
|
366
379
|
}
|
|
367
|
-
function
|
|
368
|
-
if (!(e?.type === "select" && e.multiple &&
|
|
380
|
+
function V(e, t) {
|
|
381
|
+
if (!(e?.type === "select" && e.multiple && F(t))) return t ?? H(e);
|
|
369
382
|
}
|
|
370
|
-
function
|
|
383
|
+
function H(e) {
|
|
371
384
|
if (!e) return "";
|
|
372
|
-
if (e.type === "checkbox") return
|
|
385
|
+
if (e.type === "checkbox") return J(e.defaultValue);
|
|
373
386
|
if (e.type === "number" && e.defaultValue !== void 0) {
|
|
374
387
|
let t = Number(e.defaultValue);
|
|
375
388
|
return Number.isFinite(t) ? t : e.defaultValue;
|
|
@@ -385,13 +398,13 @@ function B(e) {
|
|
|
385
398
|
}
|
|
386
399
|
if (!e.type?.endsWith("-selector")) return e.defaultValue ?? "";
|
|
387
400
|
}
|
|
388
|
-
function
|
|
401
|
+
function U(e) {
|
|
389
402
|
if (!Array.isArray(e)) {
|
|
390
403
|
if (_(e)) return e.value;
|
|
391
404
|
if (typeof e == "string" || typeof e == "number") return e;
|
|
392
405
|
}
|
|
393
406
|
}
|
|
394
|
-
function
|
|
407
|
+
function W(e, t) {
|
|
395
408
|
let n = Array.isArray(t) ? t : [t];
|
|
396
409
|
if (n.length && n.every((e) => _(e))) return g(t);
|
|
397
410
|
let r = n.flatMap((t) => {
|
|
@@ -402,45 +415,45 @@ function H(e, t) {
|
|
|
402
415
|
});
|
|
403
416
|
return r.length ? r.join("、") : g(t);
|
|
404
417
|
}
|
|
405
|
-
function
|
|
418
|
+
function G(e) {
|
|
406
419
|
return (e.type === "select" || e.type === "radio") && !e.dataSource && Array.isArray(e.options) && e.options.length > 0;
|
|
407
420
|
}
|
|
408
|
-
function
|
|
421
|
+
function K(e, t) {
|
|
409
422
|
let n = Array.isArray(t) ? t : [t];
|
|
410
423
|
return n.length > 0 && n.every((t) => _(t) && (e.options ?? []).some((e) => String(e.value) === String(t.value)));
|
|
411
424
|
}
|
|
412
|
-
function
|
|
425
|
+
function q(e) {
|
|
413
426
|
return typeof e == "boolean" ? e ? "true" : "" : e == null ? "" : g(e);
|
|
414
427
|
}
|
|
415
|
-
function
|
|
428
|
+
function se(e) {
|
|
416
429
|
return typeof e == "boolean" ? e ? "true" : "false" : e == null ? "" : g(e);
|
|
417
430
|
}
|
|
418
|
-
function
|
|
431
|
+
function J(e) {
|
|
419
432
|
return e === !0 || e === "true" || e === "1" || e === "yes" || e === "是" || e === "已选";
|
|
420
433
|
}
|
|
421
|
-
function
|
|
434
|
+
function Y(t) {
|
|
422
435
|
if (e()) {
|
|
423
436
|
let e = new DOMParser().parseFromString(t, "text/html");
|
|
424
437
|
return e.querySelectorAll("script,style,meta,link,iframe,object,embed").forEach((e) => e.remove()), e.querySelectorAll("*").forEach((e) => {
|
|
425
438
|
Array.from(e.attributes).forEach((t) => {
|
|
426
439
|
let n = t.name.toLowerCase();
|
|
427
|
-
(n.startsWith("on") || n === "srcdoc" ||
|
|
440
|
+
(n.startsWith("on") || n === "srcdoc" || ae.has(n) && X(t.value) || n === "style" && Z(t.value)) && e.removeAttribute(t.name);
|
|
428
441
|
});
|
|
429
442
|
}), e.body.innerHTML;
|
|
430
443
|
}
|
|
431
444
|
return t.replace(/<\s*(script|style|iframe|object|embed)\b[^>]*>[\s\S]*?<\s*\/\s*\1\s*>/gi, "").replace(/<\s*\/?\s*(?:script|style|meta|link|iframe|object|embed)\b[^>]*>/gi, "").replace(/\s+on[a-z]+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi, "").replace(/\s+srcdoc\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi, "").replace(/\s+(action|formaction|href|src|xlink:href)\s*=\s*(?:(["'])(.*?)\2|([^\s>]+))/gi, (e, t, n, r, i) => {
|
|
432
445
|
let a = r ?? i ?? "";
|
|
433
|
-
return
|
|
434
|
-
}).replace(/\s+style\s*=\s*(["'])(.*?)\1/gi, (e, t, n) =>
|
|
446
|
+
return X(a) ? "" : n ? ` ${t}=${n}${a}${n}` : ` ${t}=${a}`;
|
|
447
|
+
}).replace(/\s+style\s*=\s*(["'])(.*?)\1/gi, (e, t, n) => Z(n) ? "" : ` style=${t}${n}${t}`);
|
|
435
448
|
}
|
|
436
|
-
function
|
|
449
|
+
function ce(e) {
|
|
437
450
|
return n(e, S, (e) => a(e, "data-key"));
|
|
438
451
|
}
|
|
439
|
-
function
|
|
452
|
+
function le(e) {
|
|
440
453
|
let t = [];
|
|
441
|
-
return /<\s*(script|style|meta|link|iframe|object|embed)\b/i.test(e) && t.push("正文包含已移除的危险标签"), /\s(?:on[a-z]+|srcdoc)\s*=/i.test(e) && t.push("正文包含已移除的事件或嵌入属性"), (
|
|
454
|
+
return /<\s*(script|style|meta|link|iframe|object|embed)\b/i.test(e) && t.push("正文包含已移除的危险标签"), /\s(?:on[a-z]+|srcdoc)\s*=/i.test(e) && t.push("正文包含已移除的事件或嵌入属性"), (ue(e) || /style\s*=\s*["'][^"']*(?:expression\s*\(|url\s*\(\s*["']?\s*(?:javascript|vbscript|data:text\/html))/i.test(e)) && t.push("正文包含已移除的危险 URL 或样式"), t;
|
|
442
455
|
}
|
|
443
|
-
function
|
|
456
|
+
function X(e) {
|
|
444
457
|
let t = e.replace(/&#(?:x([\da-f]+)|(\d+));?/gi, (e, t, n) => {
|
|
445
458
|
let r = Number.parseInt(t ?? n ?? "", t ? 16 : 10);
|
|
446
459
|
try {
|
|
@@ -455,21 +468,21 @@ function Y(e) {
|
|
|
455
468
|
})[t.toLowerCase()] ?? "").trim().replace(/[\u0000-\u0020\u007F]+/g, "");
|
|
456
469
|
return /^(?:javascript|vbscript|data:text\/html)/i.test(t);
|
|
457
470
|
}
|
|
458
|
-
function
|
|
471
|
+
function ue(e) {
|
|
459
472
|
let t = /\s+(?:action|formaction|href|src|xlink:href)\s*=\s*(?:(["'])(.*?)\1|([^\s>]+))/gi, n = t.exec(e);
|
|
460
473
|
for (; n;) {
|
|
461
|
-
if (
|
|
474
|
+
if (X(n[2] ?? n[3] ?? "")) return !0;
|
|
462
475
|
n = t.exec(e);
|
|
463
476
|
}
|
|
464
477
|
return !1;
|
|
465
478
|
}
|
|
466
|
-
function
|
|
479
|
+
function Z(e) {
|
|
467
480
|
return /expression\s*\(|url\s*\(\s*["']?\s*(?:javascript|vbscript|data:text\/html)/i.test(e);
|
|
468
481
|
}
|
|
469
|
-
function
|
|
470
|
-
return
|
|
482
|
+
function Q(e, t) {
|
|
483
|
+
return F(t) ? e.type === "select" || e.type === "radio" ? H(e) : F(e.defaultValue) ? t : e.defaultValue : t;
|
|
471
484
|
}
|
|
472
|
-
function
|
|
485
|
+
function de(e, t, n) {
|
|
473
486
|
if (typeof e == "boolean" || typeof e != "number" && typeof e != "string") return !1;
|
|
474
487
|
let r = String(e).trim();
|
|
475
488
|
if (!/^-?(?:\d+)(?:\.\d+)?$/.test(r)) return !1;
|
|
@@ -481,14 +494,14 @@ function ue(e, t, n) {
|
|
|
481
494
|
}
|
|
482
495
|
return !0;
|
|
483
496
|
}
|
|
484
|
-
function
|
|
497
|
+
function fe(e) {
|
|
485
498
|
if (typeof e != "string" && typeof e != "number") return !1;
|
|
486
499
|
let t = String(e).trim(), n = /^(\d{4})[-/年](\d{1,2})[-/月](\d{1,2})(?:日)?(?:[T\s].*)?$/.exec(t);
|
|
487
500
|
if (!n) return !1;
|
|
488
501
|
let r = Number(n[1]), i = Number(n[2]), a = Number(n[3]), o = new Date(Date.UTC(r, i - 1, a));
|
|
489
502
|
return o.getUTCFullYear() === r && o.getUTCMonth() === i - 1 && o.getUTCDate() === a;
|
|
490
503
|
}
|
|
491
|
-
function
|
|
504
|
+
function pe(e) {
|
|
492
505
|
return typeof e == "boolean" ? !0 : [
|
|
493
506
|
"1",
|
|
494
507
|
"true",
|
|
@@ -504,16 +517,16 @@ function de(e) {
|
|
|
504
517
|
"未选"
|
|
505
518
|
].includes(String(e).trim().toLowerCase());
|
|
506
519
|
}
|
|
507
|
-
function
|
|
520
|
+
function me(e) {
|
|
508
521
|
return E.test(e);
|
|
509
522
|
}
|
|
510
|
-
function
|
|
523
|
+
function he(e) {
|
|
511
524
|
return e === "select" || e === "radio" || e === "user-selector" || e === "dept-selector" || e === "role-selector" || e === "org-selector";
|
|
512
525
|
}
|
|
513
|
-
function
|
|
526
|
+
function ge(e, t) {
|
|
514
527
|
return t ? Array.isArray(e) && e.every(_) : _(e);
|
|
515
528
|
}
|
|
516
|
-
function
|
|
529
|
+
function _e(e, t) {
|
|
517
530
|
let n = e.width;
|
|
518
531
|
if (!Number.isFinite(n) || n <= 0) return !1;
|
|
519
532
|
let r = Math.max(10, Number.isFinite(e.style?.fontSize) && (e.style?.fontSize ?? 0) > 0 ? e.style.fontSize : 14), i = Math.max(1, n - 12) / r, a = (e) => Array.from(e).reduce((e, t) => e + (/[^\x00-\x7f]/.test(t) ? 1 : .55), 0);
|
|
@@ -525,4 +538,4 @@ function $(e) {
|
|
|
525
538
|
return typeof t == "number" && typeof n == "number" && Number.isFinite(t) && Number.isFinite(n) && t >= C && n >= C && t <= w && n <= w;
|
|
526
539
|
}
|
|
527
540
|
//#endregion
|
|
528
|
-
export { D as buildInitialRenderValues,
|
|
541
|
+
export { D as buildInitialRenderValues, P as buildTemplateRenderHtml, N as buildTemplateRenderPages, re as buildTemplateVariableData, F as isEmptyRenderValue, O as normalizeRenderValues, k as resolveTemplateDisplayValues, oe as resolveTemplateRenderSubmitErrors, Y as sanitizeContractRendererHtml, M as validateTemplateRenderStructure, A as validateTemplateRenderValues, j as validateTemplateTextOverflow };
|
package/dist/es/components/pro-contract-template-designer/src/utils/template-variable-render.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DEFAULT_CONTRACT_FONT_FAMILY as e } from "../constants.mjs";
|
|
2
2
|
//#region src/components/pro-contract-template-designer/src/utils/template-variable-render.ts
|
|
3
3
|
function t(t) {
|
|
4
|
-
let r = t.type === void 0 ? "text" : String(t.type), i = Math.max(24,
|
|
4
|
+
let r = t.type === void 0 ? "text" : String(t.type), i = Math.max(24, c(t.width, 160)), a = Math.max(24, c(t.height, 32)), o = t.style?.border ?? t.border ?? r === "image", l = t.style?.underline ?? t.underline ?? (r !== "image" && r !== "checkbox"), u = t.style?.color || t.color || "#1f2937", d = t.style?.background || t.background || "transparent", f = Math.max(10, c(t.style?.fontSize ?? t.fontSize, 14)), p = t.style?.fontFamily || t.fontFamily || e, m = t.style?.placeholderColor || t.placeholderColor || "#7a818b", h = t.style?.lineColor || t.lineColor || "#565b66", g = t.style?.textAlign || t.textAlign || "left", _ = t.style?.borderStyle || t.borderStyle || "solid", v = t.style?.objectFit || t.objectFit || "contain", y = !!t.multiline, b = Math.max(1, c(t.rows, 3)), x = Math.max(18, c(t.lineHeight, 28)), S = b * x, C = v === "fill" ? "100% 100%" : v, w = g === "right" ? "flex-end" : g === "center" ? "center" : "flex-start", T = r === "select" && t.multiple ? "" : String(t.defaultValue || ""), E = n({
|
|
5
5
|
type: r,
|
|
6
6
|
defaultValue: T,
|
|
7
7
|
placeholder: t.placeholder || "",
|
|
@@ -12,12 +12,12 @@ function t(t) {
|
|
|
12
12
|
uncheckedText: t.uncheckedText || "",
|
|
13
13
|
options: t.options,
|
|
14
14
|
multiple: t.multiple
|
|
15
|
-
}), D = T.trim().length > 0, O = !D && E.trim().length > 0, k = r === "checkbox" &&
|
|
15
|
+
}), D = T.trim().length > 0, O = !D && E.trim().length > 0, k = r === "checkbox" && s(T), A = r === "image" && D ? `;--gd-contract-variable-image:url('${T.replaceAll("'", "%27")}')` : "";
|
|
16
16
|
return {
|
|
17
17
|
type: r,
|
|
18
18
|
width: i,
|
|
19
19
|
height: a,
|
|
20
|
-
border:
|
|
20
|
+
border: o,
|
|
21
21
|
underline: l,
|
|
22
22
|
color: u,
|
|
23
23
|
background: d,
|
|
@@ -35,7 +35,7 @@ function t(t) {
|
|
|
35
35
|
classes: [
|
|
36
36
|
"gd-contract-template-variable",
|
|
37
37
|
`is-${r}`,
|
|
38
|
-
|
|
38
|
+
o ? "has-border" : "",
|
|
39
39
|
l ? "has-underline" : "",
|
|
40
40
|
y ? "is-multiline" : "",
|
|
41
41
|
O ? "is-placeholder" : "",
|
|
@@ -47,10 +47,10 @@ function t(t) {
|
|
|
47
47
|
}
|
|
48
48
|
function n(e) {
|
|
49
49
|
let t = e.type || "text", n = t === "select" && e.multiple ? "" : e.defaultValue || "", i = e.placeholder || "";
|
|
50
|
-
if (t === "checkbox") return n ?
|
|
50
|
+
if (t === "checkbox") return n ? s(n) ? e.checkedText || i : e.uncheckedText || i : i;
|
|
51
51
|
if (!n) return i;
|
|
52
52
|
if (t === "date") return r(n, e.format || "");
|
|
53
|
-
if (t === "number") return
|
|
53
|
+
if (t === "number") return o(n, {
|
|
54
54
|
format: e.format || "",
|
|
55
55
|
precision: e.precision,
|
|
56
56
|
useGrouping: e.useGrouping
|
|
@@ -65,12 +65,20 @@ function n(e) {
|
|
|
65
65
|
}
|
|
66
66
|
function r(e, t) {
|
|
67
67
|
if (!t) return e;
|
|
68
|
-
let n =
|
|
69
|
-
|
|
70
|
-
let [, r, i, a] = n;
|
|
71
|
-
return t.replace("YYYY", r).replace("MM", i.padStart(2, "0")).replace("DD", a.padStart(2, "0"));
|
|
68
|
+
let n = i(e);
|
|
69
|
+
return n ? t.replaceAll("YYYY", n.year).replaceAll("MM", n.month).replaceAll("DD", n.day) : e;
|
|
72
70
|
}
|
|
73
|
-
|
|
71
|
+
function i(e) {
|
|
72
|
+
let t = String(e).trim(), n = /^(\d{4})[-/年](\d{1,2})[-/月](\d{1,2})(?:日)?(?:[T\s].*)?$/.exec(t);
|
|
73
|
+
if (!n) return;
|
|
74
|
+
let r = Number(n[1]), i = Number(n[2]), a = Number(n[3]), o = new Date(Date.UTC(r, i - 1, a));
|
|
75
|
+
if (!(o.getUTCFullYear() !== r || o.getUTCMonth() !== i - 1 || o.getUTCDate() !== a)) return {
|
|
76
|
+
year: String(o.getUTCFullYear()),
|
|
77
|
+
month: String(o.getUTCMonth() + 1).padStart(2, "0"),
|
|
78
|
+
day: String(o.getUTCDate()).padStart(2, "0")
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
var a = [
|
|
74
82
|
{
|
|
75
83
|
value: "decimal",
|
|
76
84
|
label: "常规数字"
|
|
@@ -84,7 +92,7 @@ var i = [
|
|
|
84
92
|
label: "人民币金额"
|
|
85
93
|
}
|
|
86
94
|
];
|
|
87
|
-
function
|
|
95
|
+
function o(e, t) {
|
|
88
96
|
let n = Number(e);
|
|
89
97
|
if (!e.trim() || !Number.isFinite(n)) return e;
|
|
90
98
|
let r = typeof t.precision == "number" && Number.isInteger(t.precision) && t.precision >= 0 && t.precision <= 20 ? t.precision : void 0, i = n.toLocaleString("zh-CN", {
|
|
@@ -95,7 +103,7 @@ function a(e, t) {
|
|
|
95
103
|
});
|
|
96
104
|
return t.format === "currency" ? `¥${i}` : i;
|
|
97
105
|
}
|
|
98
|
-
function
|
|
106
|
+
function s(e) {
|
|
99
107
|
return [
|
|
100
108
|
"1",
|
|
101
109
|
"true",
|
|
@@ -105,10 +113,10 @@ function o(e) {
|
|
|
105
113
|
"已选"
|
|
106
114
|
].includes(e.trim().toLowerCase());
|
|
107
115
|
}
|
|
108
|
-
function
|
|
116
|
+
function c(e, t) {
|
|
109
117
|
if (e == null || e === "") return t;
|
|
110
118
|
let n = Number(e);
|
|
111
119
|
return Number.isFinite(n) ? n : t;
|
|
112
120
|
}
|
|
113
121
|
//#endregion
|
|
114
|
-
export {
|
|
122
|
+
export { a as TEMPLATE_NUMBER_FORMAT_OPTIONS, t as resolveTemplateVariablePresentation };
|