@guodun/antdv 1.7.7 → 1.7.9

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 (47) hide show
  1. package/dist/es/components/pro-contract-template-designer/src/ContractTemplateChoiceOptionsEditor.mjs +5 -0
  2. package/dist/es/components/pro-contract-template-designer/src/ContractTemplateChoiceOptionsEditor.vue.mjs +132 -0
  3. package/dist/es/components/pro-contract-template-designer/src/ContractTemplateDesignerInspector.vue.mjs +209 -246
  4. package/dist/es/components/pro-contract-template-designer/src/DesignerPage.vue.mjs +395 -325
  5. package/dist/es/components/pro-contract-template-designer/src/ProContractTemplateDesigner.vue.mjs +1047 -1015
  6. package/dist/es/components/pro-contract-template-designer/src/composables/use-auto-pagination.mjs +122 -63
  7. package/dist/es/components/pro-contract-template-designer/src/composables/use-template-designer.mjs +192 -162
  8. package/dist/es/components/pro-contract-template-designer/src/extensions/template-variable.mjs +70 -68
  9. package/dist/es/components/pro-contract-template-designer/src/utils/advanced-controls.mjs +63 -25
  10. package/dist/es/components/pro-contract-template-designer/src/utils/caret-viewport.mjs +41 -0
  11. package/dist/es/components/pro-contract-template-designer/src/utils/template-renderer.mjs +129 -75
  12. package/dist/es/components/pro-contract-template-designer/src/utils/template-variable-render.mjs +17 -5
  13. package/dist/es/components/pro-contract-template-designer/style/index.css +1 -1
  14. package/dist/es/index.mjs +22 -22
  15. package/dist/es/node_modules/@tiptap/pm/dist/transform/index.mjs +1 -0
  16. package/dist/es/node_modules/prosemirror-transform/dist/index.mjs +161 -67
  17. package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateChoiceOptionsEditor.cjs +1 -0
  18. package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateChoiceOptionsEditor.vue.cjs +1 -0
  19. package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateDesignerInspector.vue.cjs +1 -2
  20. package/dist/lib/components/pro-contract-template-designer/src/DesignerPage.vue.cjs +2 -2
  21. package/dist/lib/components/pro-contract-template-designer/src/ProContractTemplateDesigner.vue.cjs +1 -1
  22. package/dist/lib/components/pro-contract-template-designer/src/composables/use-auto-pagination.cjs +1 -1
  23. package/dist/lib/components/pro-contract-template-designer/src/composables/use-template-designer.cjs +4 -4
  24. package/dist/lib/components/pro-contract-template-designer/src/extensions/template-variable.cjs +1 -1
  25. package/dist/lib/components/pro-contract-template-designer/src/utils/advanced-controls.cjs +1 -1
  26. package/dist/lib/components/pro-contract-template-designer/src/utils/caret-viewport.cjs +1 -0
  27. package/dist/lib/components/pro-contract-template-designer/src/utils/template-renderer.cjs +3 -3
  28. package/dist/lib/components/pro-contract-template-designer/src/utils/template-variable-render.cjs +1 -1
  29. package/dist/lib/components/pro-contract-template-designer/style/index.css +1 -1
  30. package/dist/lib/index.cjs +1 -1
  31. package/dist/lib/node_modules/@tiptap/pm/dist/transform/index.cjs +1 -0
  32. package/dist/lib/node_modules/prosemirror-transform/dist/index.cjs +2 -2
  33. package/dist/theme/icon.css +1 -1
  34. package/dist/theme/index.css +1 -1
  35. package/dist/types/components/pro-contract-template-designer/src/ContractTemplateChoiceOptionsEditor.vue.d.ts +12 -0
  36. package/dist/types/components/pro-contract-template-designer/src/DesignerPage.vue.d.ts +14 -0
  37. package/dist/types/components/pro-contract-template-designer/src/ProContractTemplateDesigner.vue.d.ts +2 -0
  38. package/dist/types/components/pro-contract-template-designer/src/composables/use-auto-pagination.d.ts +17 -0
  39. package/dist/types/components/pro-contract-template-designer/src/composables/use-template-designer.d.ts +5 -1
  40. package/dist/types/components/pro-contract-template-designer/src/types.d.ts +15 -2
  41. package/dist/types/components/pro-contract-template-designer/src/utils/advanced-controls.d.ts +10 -0
  42. package/dist/types/components/pro-contract-template-designer/src/utils/caret-viewport.d.ts +18 -0
  43. package/dist/types/components/pro-contract-template-designer/src/utils/template-variable-render.d.ts +7 -0
  44. package/package.json +5 -5
  45. package/dist/theme/dept-selector.css +0 -1
  46. package/dist/theme/pro-selector-group.css +0 -1
  47. package/dist/theme/role-selector.css +0 -1
@@ -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 { formatContractTemplateRenderValue as h, isContractTemplateSelectionValue as g } from "./advanced-controls.mjs";
6
- import { CONTRACT_TEMPLATE_RESERVED_VARIABLE_KEYS as _, CONTRACT_TEMPLATE_VARIABLE_KEY_PATTERN as v, DEFAULT_PAGE_SIZE as y, resolvePageSize as b, validateContractTemplateVariableKey as x } from "../composables/use-template-designer.mjs";
5
+ import { buildRadioOptionsHtml as h, formatContractTemplateRenderValue as g, isContractTemplateSelectionValue as _ } from "./advanced-controls.mjs";
6
+ import { CONTRACT_TEMPLATE_RESERVED_VARIABLE_KEYS as v, CONTRACT_TEMPLATE_VARIABLE_KEY_PATTERN as ee, DEFAULT_PAGE_SIZE as y, resolvePageSize as b, validateContractTemplateVariableKey as x } from "../composables/use-template-designer.mjs";
7
7
  import { isSafeContractImageUrl as S } from "./image-url.mjs";
8
8
  //#region src/components/pro-contract-template-designer/src/utils/template-renderer.ts
9
- function C(e) {
10
- let t = Array.isArray(e?.variables) ? e.variables : [], n = t.map((e) => w(e)), r = {};
9
+ function te(e) {
10
+ let t = Array.isArray(e?.variables) ? e.variables : [], n = t.map((e) => C(e)), r = {};
11
11
  return t.forEach((e) => {
12
12
  let t = typeof e?.key == "string" ? e.key : "";
13
13
  if (t) {
@@ -27,30 +27,30 @@ function C(e) {
27
27
  variables: n
28
28
  };
29
29
  }
30
- function w(e) {
30
+ function C(e) {
31
31
  return JSON.parse(JSON.stringify(e));
32
32
  }
33
- var T = new Set([
33
+ var w = new Set([
34
34
  "action",
35
35
  "formaction",
36
36
  "href",
37
37
  "src",
38
38
  "xlink:href"
39
- ]), E = /<[^>]+data-template-variable=["']true["'][^>]*>/gi, D = 100, O = 6e3, k = 6, A = /^data:image\/(?:png|jpe?g|webp|gif);base64,[A-Za-z0-9+/=]+$/i;
40
- function j(e) {
39
+ ]), T = /<[^>]+data-template-variable=["']true["'][^>]*>/gi, E = 100, D = 6e3, O = 6, k = /^data:image\/(?:png|jpe?g|webp|gif);base64,[A-Za-z0-9+/=]+$/i;
40
+ function A(e) {
41
41
  let t = {};
42
42
  return (Array.isArray(e?.variables) ? e.variables : []).forEach((e) => {
43
43
  e?.key && (t[e.key] = U(e));
44
44
  }), t;
45
45
  }
46
- function ee(e, t) {
46
+ function j(e, t) {
47
47
  return {
48
- ...j(e),
48
+ ...A(e),
49
49
  ...t ?? {}
50
50
  };
51
51
  }
52
52
  function M(e, t) {
53
- let n = P(e);
53
+ let n = N(e);
54
54
  if (!e) return n;
55
55
  let r = Array.isArray(e.variables) ? e.variables : [], i = new Set(r.map((e) => e?.key).filter(Boolean));
56
56
  return Object.keys(t).forEach((e) => {
@@ -63,8 +63,8 @@ function M(e, t) {
63
63
  });
64
64
  }), r.forEach((e) => {
65
65
  if (!e?.key) return;
66
- let r = te(e, t[e.key]), i = e.label || e.key;
67
- if (e.required && L(r)) {
66
+ let r = se(e, t[e.key]), i = e.label || e.key;
67
+ if (e.required && I(r)) {
68
68
  n.push({
69
69
  type: "variable",
70
70
  id: e.id,
@@ -74,39 +74,45 @@ function M(e, t) {
74
74
  });
75
75
  return;
76
76
  }
77
- if (L(r)) return;
77
+ if (I(r)) return;
78
78
  let a = e.type ?? "text";
79
- a === "number" && !ne(r, e.precision) && n.push({
79
+ a === "number" && !ce(r, e.precision) && n.push({
80
80
  type: "variable",
81
81
  id: e.id,
82
82
  variableKey: e.key,
83
83
  message: `${i} 不是合法数字或超出精度`,
84
84
  code: "VARIABLE_TYPE_INVALID"
85
- }), a === "checkbox" && !ie(r) && n.push({
85
+ }), a === "checkbox" && !ue(r) && n.push({
86
86
  type: "variable",
87
87
  id: e.id,
88
88
  variableKey: e.key,
89
89
  message: `${i} 不是合法勾选值`,
90
90
  code: "VARIABLE_TYPE_INVALID"
91
- }), a === "date" && !re(r) && n.push({
91
+ }), a === "date" && !le(r) && n.push({
92
92
  type: "variable",
93
93
  id: e.id,
94
94
  variableKey: e.key,
95
95
  message: `${i} 不是合法日期`,
96
96
  code: "VARIABLE_TYPE_INVALID"
97
- }), a === "image" && !ae(String(r).trim()) && n.push({
97
+ }), a === "image" && !de(String(r).trim()) && n.push({
98
98
  type: "security",
99
99
  id: e.id,
100
100
  variableKey: e.key,
101
101
  message: `${i} 必须使用安全的图片 data URL`,
102
102
  code: "UNSAFE_IMAGE_URL"
103
- }), a === "text" && ce(e, String(r)) && n.push({
103
+ }), a === "text" && me(e, String(r)) && n.push({
104
104
  type: "variable",
105
105
  id: e.id,
106
106
  variableKey: e.key,
107
107
  message: `${i} 内容超出变量范围`,
108
108
  code: "VARIABLE_OVERFLOW"
109
- }), oe(a) && (se(r, a !== "radio" && !!e.multiple) || n.push({
109
+ }), fe(a) && (pe(r, a !== "radio" && !!e.multiple) ? K(e) && !q(e, r) && n.push({
110
+ type: "variable",
111
+ id: e.id,
112
+ variableKey: e.key,
113
+ message: `${i} 不在可选项中`,
114
+ code: "VARIABLE_TYPE_INVALID"
115
+ }) : n.push({
110
116
  type: "variable",
111
117
  id: e.id,
112
118
  variableKey: e.key,
@@ -115,10 +121,10 @@ function M(e, t) {
115
121
  }));
116
122
  }), n;
117
123
  }
118
- function N(e, t, n) {
124
+ function ne(e, t, n) {
119
125
  return M(e, t);
120
126
  }
121
- function P(e) {
127
+ function N(e) {
122
128
  if (!e) return [{
123
129
  type: "page",
124
130
  id: "template",
@@ -139,7 +145,7 @@ function P(e) {
139
145
  }), $(e.pageSize) || t.push({
140
146
  type: "page",
141
147
  id: "template-page-size",
142
- message: `模板默认页面尺寸必须在 ${D} ~ ${O} CSS px 之间`,
148
+ message: `模板默认页面尺寸必须在 ${E} ~ ${D} CSS px 之间`,
143
149
  code: "TEMPLATE_PAGE_SIZE_INVALID"
144
150
  });
145
151
  let i = /* @__PURE__ */ new Map();
@@ -153,7 +159,7 @@ function P(e) {
153
159
  });
154
160
  return;
155
161
  }
156
- let a = e.key.trim(), o = r.some((t) => t?.id !== e.id && typeof t?.key == "string" && t.key.trim() === a), s = x(e.key, r, e.id), c = !v.test(a) || _.has(a);
162
+ let a = e.key.trim(), o = r.some((t) => t?.id !== e.id && typeof t?.key == "string" && t.key.trim() === a), s = x(e.key, r, e.id), c = !ee.test(a) || v.has(a);
157
163
  s && (c || !o || e.key !== a) && t.push({
158
164
  type: "variable",
159
165
  id: e.id || `variable-${n}`,
@@ -192,9 +198,9 @@ function P(e) {
192
198
  type: "page",
193
199
  id: `${e.id}-page-size`,
194
200
  pageId: e.id,
195
- message: `${e.title || `第 ${n + 1} 页`}:页面尺寸必须在 ${D} ~ ${O} CSS px 之间`,
201
+ message: `${e.title || `第 ${n + 1} 页`}:页面尺寸必须在 ${E} ~ ${D} CSS px 之间`,
196
202
  code: "PAGE_SIZE_INVALID"
197
- }), J(e.contentHtml).forEach((e) => a.add(e)), Y(e.contentHtml).forEach((r, i) => {
203
+ }), ie(e.contentHtml).forEach((e) => a.add(e)), ae(e.contentHtml).forEach((r, i) => {
198
204
  t.push({
199
205
  type: "security",
200
206
  id: `${e.id}-security-${i}`,
@@ -223,7 +229,7 @@ function P(e) {
223
229
  });
224
230
  }), t.push(...p(e.pageDecorations, r)), t;
225
231
  }
226
- function F(e, t, n = {}) {
232
+ function P(e, t, n = {}) {
227
233
  if (!e || !Array.isArray(e.pages)) return [];
228
234
  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;
229
235
  return e.pages.flatMap((o) => {
@@ -235,47 +241,47 @@ function F(e, t, n = {}) {
235
241
  format: s.format ?? "Custom",
236
242
  width: s.width,
237
243
  height: s.height,
238
- contentHtml: R(o.contentHtml, i, t, n),
244
+ contentHtml: L(o.contentHtml, i, t, n),
239
245
  ...e.pageDecorations ? { pageDecorations: f(e.pageDecorations) } : {},
240
246
  decorationVariables: r,
241
247
  decorationValues: t
242
248
  }];
243
249
  });
244
250
  }
245
- function I(e, t, n = {}) {
246
- return F(e, t, n).map((e, t, n) => {
251
+ function F(e, t, n = {}) {
252
+ return P(e, t, n).map((e, t, n) => {
247
253
  let i = u(e.pageDecorations, t + 1, n.length, e.decorationVariables, e.decorationValues);
248
254
  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>`;
249
255
  }).join("\n");
250
256
  }
251
- function L(e) {
257
+ function I(e) {
252
258
  return e == null || e === "" || Array.isArray(e) && e.length === 0;
253
259
  }
254
- function R(e, n, r, i) {
260
+ function L(e, n, r, i) {
255
261
  if (!e) return e;
256
- let o = q(e);
262
+ let o = X(e);
257
263
  if (t()) {
258
264
  let e = new DOMParser().parseFromString(o, "text/html");
259
265
  return e.querySelectorAll("[data-template-variable]").forEach((e) => {
260
- z(e, n, r, i);
266
+ R(e, n, r, i);
261
267
  }), e.body.innerHTML;
262
268
  }
263
269
  return s(o, (e, t) => {
264
270
  let o = a(t, "data-key");
265
- return o ? B(n.get(o), o, r[o], i) : e;
271
+ return o ? z(n.get(o), o, r[o], i) : e;
266
272
  });
267
273
  }
268
- function z(e, t, n, r) {
274
+ function R(e, t, n, r) {
269
275
  let i = e.dataset.key || "", a = t.get(i);
270
276
  if (!i || !a) return;
271
- let o = new DOMParser().parseFromString(B(a, i, n[i], r), "text/html").body.firstElementChild;
277
+ let o = new DOMParser().parseFromString(z(a, i, n[i], r), "text/html").body.firstElementChild;
272
278
  o && e.replaceWith(o);
273
279
  }
274
- function B(e, t, n, r) {
275
- return r.mode === "display" ? V(e, t, n, r) : H(e, t, n, r);
280
+ function z(e, t, n, r) {
281
+ return r.mode === "display" ? B(e, t, n, r) : V(e, t, n, r);
276
282
  }
277
- function V(e, t, n, a) {
278
- let o = e?.type ?? "text", s = n ?? U(e), l = o === "image" && !L(s) && !S(String(s)) ? "" : s, u = G(l), d = c({
283
+ function B(e, t, n, a) {
284
+ let o = e?.type ?? "text", s = H(e, n), l = o === "image" && !I(s) && !S(String(s)) ? "" : s, u = re(l), d = c({
279
285
  type: o,
280
286
  width: e?.width,
281
287
  height: e?.height,
@@ -296,7 +302,7 @@ function V(e, t, n, a) {
296
302
  "gd-contract-template-renderer__preview-control",
297
303
  ...d.classes,
298
304
  a.activeKey === t ? "is-active" : "",
299
- L(l) ? "is-empty" : ""
305
+ I(l) ? "is-empty" : ""
300
306
  ].filter(Boolean).join(" "))}"`,
301
307
  `style="${r(d.styleText)}"`,
302
308
  "data-contract-render-wrapper=\"true\"",
@@ -307,10 +313,10 @@ function V(e, t, n, a) {
307
313
  a.disabled ? "" : "role=\"button\"",
308
314
  a.disabled ? "" : "tabindex=\"0\""
309
315
  ].filter(Boolean).join(" ");
310
- return o === "checkbox" ? `<span ${p}><span class="gd-contract-template-renderer__checkbox-mark" aria-hidden="true">${K(l) ? "✓" : ""}</span>${i(f)}</span>` : o === "image" && !L(l) ? `<span ${p}></span>` : `<span ${p}>${i(f)}</span>`;
316
+ return o === "checkbox" ? `<span ${p}><span class="gd-contract-template-renderer__checkbox-mark" aria-hidden="true">${Y(l) ? "✓" : ""}</span>${i(f)}</span>` : o === "radio" ? `<span ${p}>${h(e?.options, W(l)) || i(e?.placeholder || f)}</span>` : o === "select" ? `<span ${p}>${i(G(e, l) || f)}</span>` : o === "image" && !I(l) ? `<span ${p}></span>` : `<span ${p}>${i(f)}</span>`;
311
317
  }
312
- function H(e, t, n, a) {
313
- let o = e?.type ?? "text", s = !!a.readonly, l = W(n ?? U(e)), u = c({
318
+ function V(e, t, n, a) {
319
+ let o = e?.type ?? "text", s = !!a.readonly, l = J(H(e, n)), u = c({
314
320
  type: o,
315
321
  width: e?.width,
316
322
  height: e?.height,
@@ -333,49 +339,97 @@ function H(e, t, n, a) {
333
339
  d ? "disabled" : "",
334
340
  s ? "readonly" : ""
335
341
  ].filter(Boolean).join(" "), p = `style="${r(u.styleText)}"`, m = r(["gd-contract-template-renderer__control", ...u.classes].join(" "));
336
- return o === "checkbox" ? `<label class="${m}" ${p} data-contract-render-wrapper="true" data-key="${r(t)}"><input type="checkbox" ${f} ${K(l) ? "checked" : ""}>${i(e?.checkedText || e?.label || t)}</label>` : s ? `<span class="${m}" ${p} data-contract-render-wrapper="true" data-key="${r(t)}">${i(u.displayText || l)}</span>` : o === "number" ? `<input class="${m}" ${p} type="number" ${f} value="${r(l)}" placeholder="${r(e?.placeholder || "")}">` : o === "date" ? `<input class="${m}" ${p} type="date" ${f} value="${r(l)}" placeholder="${r(e?.placeholder || "")}">` : o === "select" || o === "radio" || o.endsWith("-selector") || o === "custom" ? `<span class="${m}" ${p} data-contract-render-wrapper="true" data-key="${r(t)}">${i(h(n))}</span>` : e?.multiline ? `<textarea class="${m}" ${p} ${f} placeholder="${r(e.placeholder || "")}">${i(l)}</textarea>` : `<input class="${m}" ${p} type="text" ${f} value="${r(l)}" placeholder="${r(e?.placeholder || "")}">`;
342
+ if (o === "checkbox") return `<label class="${m}" ${p} data-contract-render-wrapper="true" data-key="${r(t)}"><input type="checkbox" ${f} ${Y(l) ? "checked" : ""}>${i(e?.checkedText || e?.label || t)}</label>`;
343
+ if (o === "radio") {
344
+ let a = H(e, n), o = h(e?.options, W(a)) || i(u.displayText || e?.placeholder || "");
345
+ return `<span class="${m}" ${p} data-contract-render-wrapper="true" data-key="${r(t)}">${o}</span>`;
346
+ }
347
+ if (s) return `<span class="${m}" ${p} data-contract-render-wrapper="true" data-key="${r(t)}">${i(u.displayText || l)}</span>`;
348
+ if (o === "number") return `<input class="${m}" ${p} type="number" ${f} value="${r(l)}" placeholder="${r(e?.placeholder || "")}">`;
349
+ if (o === "date") return `<input class="${m}" ${p} type="date" ${f} value="${r(l)}" placeholder="${r(e?.placeholder || "")}">`;
350
+ if (o === "select" || o.endsWith("-selector") || o === "custom") {
351
+ let a = H(e, n), s = o === "select" ? G(e, a) : g(a);
352
+ return `<span class="${m}" ${p} data-contract-render-wrapper="true" data-key="${r(t)}">${i(s)}</span>`;
353
+ }
354
+ return e?.multiline ? `<textarea class="${m}" ${p} ${f} placeholder="${r(e.placeholder || "")}">${i(l)}</textarea>` : `<input class="${m}" ${p} type="text" ${f} value="${r(l)}" placeholder="${r(e?.placeholder || "")}">`;
355
+ }
356
+ function H(e, t) {
357
+ if (!(e?.type === "select" && e.multiple && I(t))) return t ?? U(e);
337
358
  }
338
359
  function U(e) {
339
360
  if (!e) return "";
340
- if (e.type === "checkbox") return K(e.defaultValue);
361
+ if (e.type === "checkbox") return Y(e.defaultValue);
341
362
  if (e.type === "number" && e.defaultValue !== void 0) {
342
363
  let t = Number(e.defaultValue);
343
364
  return Number.isFinite(t) ? t : e.defaultValue;
344
365
  }
345
- if (!(e.type === "select" || e.type === "radio" || e.type?.endsWith("-selector"))) return e.defaultValue ?? "";
366
+ if (e.type === "select" || e.type === "radio") {
367
+ if (e.type === "select" && e.multiple || !e.defaultValue) return;
368
+ let t = (e.options ?? []).find((t) => String(t.value) === String(e.defaultValue));
369
+ return t ? {
370
+ value: t.value,
371
+ label: t.label,
372
+ type: t.type || e.type
373
+ } : void 0;
374
+ }
375
+ if (!e.type?.endsWith("-selector")) return e.defaultValue ?? "";
346
376
  }
347
377
  function W(e) {
348
- return typeof e == "boolean" ? e ? "true" : "" : e == null ? "" : h(e);
378
+ if (!Array.isArray(e)) {
379
+ if (_(e)) return e.value;
380
+ if (typeof e == "string" || typeof e == "number") return e;
381
+ }
349
382
  }
350
- function G(e) {
351
- return typeof e == "boolean" ? e ? "true" : "false" : e == null ? "" : h(e);
383
+ function G(e, t) {
384
+ let n = Array.isArray(t) ? t : [t];
385
+ if (n.length && n.every((e) => _(e))) return g(t);
386
+ let r = n.flatMap((t) => {
387
+ let n = typeof t == "string" || typeof t == "number" ? t : void 0;
388
+ if (n === void 0) return [];
389
+ let r = e?.options?.find((e) => String(e.value) === String(n));
390
+ return r?.label ? [r.label] : [];
391
+ });
392
+ return r.length ? r.join("、") : g(t);
352
393
  }
353
394
  function K(e) {
395
+ return (e.type === "select" || e.type === "radio") && !e.dataSource && Array.isArray(e.options) && e.options.length > 0;
396
+ }
397
+ function q(e, t) {
398
+ let n = Array.isArray(t) ? t : [t];
399
+ return n.length > 0 && n.every((t) => _(t) && (e.options ?? []).some((e) => String(e.value) === String(t.value)));
400
+ }
401
+ function J(e) {
402
+ return typeof e == "boolean" ? e ? "true" : "" : e == null ? "" : g(e);
403
+ }
404
+ function re(e) {
405
+ return typeof e == "boolean" ? e ? "true" : "false" : e == null ? "" : g(e);
406
+ }
407
+ function Y(e) {
354
408
  return e === !0 || e === "true" || e === "1" || e === "yes" || e === "是" || e === "已选";
355
409
  }
356
- function q(t) {
410
+ function X(t) {
357
411
  if (e()) {
358
412
  let e = new DOMParser().parseFromString(t, "text/html");
359
413
  return e.querySelectorAll("script,style,meta,link,iframe,object,embed").forEach((e) => e.remove()), e.querySelectorAll("*").forEach((e) => {
360
414
  Array.from(e.attributes).forEach((t) => {
361
415
  let n = t.name.toLowerCase();
362
- (n.startsWith("on") || n === "srcdoc" || T.has(n) && X(t.value) || n === "style" && Q(t.value)) && e.removeAttribute(t.name);
416
+ (n.startsWith("on") || n === "srcdoc" || w.has(n) && Z(t.value) || n === "style" && Q(t.value)) && e.removeAttribute(t.name);
363
417
  });
364
418
  }), e.body.innerHTML;
365
419
  }
366
420
  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) => {
367
421
  let a = r ?? i ?? "";
368
- return X(a) ? "" : n ? ` ${t}=${n}${a}${n}` : ` ${t}=${a}`;
422
+ return Z(a) ? "" : n ? ` ${t}=${n}${a}${n}` : ` ${t}=${a}`;
369
423
  }).replace(/\s+style\s*=\s*(["'])(.*?)\1/gi, (e, t, n) => Q(n) ? "" : ` style=${t}${n}${t}`);
370
424
  }
371
- function J(e) {
372
- return n(e, E, (e) => a(e, "data-key"));
425
+ function ie(e) {
426
+ return n(e, T, (e) => a(e, "data-key"));
373
427
  }
374
- function Y(e) {
428
+ function ae(e) {
375
429
  let t = [];
376
- 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("正文包含已移除的事件或嵌入属性"), (Z(e) || /style\s*=\s*["'][^"']*(?:expression\s*\(|url\s*\(\s*["']?\s*(?:javascript|vbscript|data:text\/html))/i.test(e)) && t.push("正文包含已移除的危险 URL 或样式"), t;
430
+ 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("正文包含已移除的事件或嵌入属性"), (oe(e) || /style\s*=\s*["'][^"']*(?:expression\s*\(|url\s*\(\s*["']?\s*(?:javascript|vbscript|data:text\/html))/i.test(e)) && t.push("正文包含已移除的危险 URL 或样式"), t;
377
431
  }
378
- function X(e) {
432
+ function Z(e) {
379
433
  let t = e.replace(/&#(?:x([\da-f]+)|(\d+));?/gi, (e, t, n) => {
380
434
  let r = Number.parseInt(t ?? n ?? "", t ? 16 : 10);
381
435
  try {
@@ -390,10 +444,10 @@ function X(e) {
390
444
  })[t.toLowerCase()] ?? "").trim().replace(/[\u0000-\u0020\u007F]+/g, "");
391
445
  return /^(?:javascript|vbscript|data:text\/html)/i.test(t);
392
446
  }
393
- function Z(e) {
447
+ function oe(e) {
394
448
  let t = /\s+(?:action|formaction|href|src|xlink:href)\s*=\s*(?:(["'])(.*?)\1|([^\s>]+))/gi, n = t.exec(e);
395
449
  for (; n;) {
396
- if (X(n[2] ?? n[3] ?? "")) return !0;
450
+ if (Z(n[2] ?? n[3] ?? "")) return !0;
397
451
  n = t.exec(e);
398
452
  }
399
453
  return !1;
@@ -401,10 +455,10 @@ function Z(e) {
401
455
  function Q(e) {
402
456
  return /expression\s*\(|url\s*\(\s*["']?\s*(?:javascript|vbscript|data:text\/html)/i.test(e);
403
457
  }
404
- function te(e, t) {
405
- return L(t) && !L(e.defaultValue) ? e.defaultValue : t;
458
+ function se(e, t) {
459
+ return I(t) ? e.type === "select" || e.type === "radio" ? U(e) : I(e.defaultValue) ? t : e.defaultValue : t;
406
460
  }
407
- function ne(e, t) {
461
+ function ce(e, t) {
408
462
  if (typeof e == "boolean" || typeof e != "number" && typeof e != "string") return !1;
409
463
  let n = String(e).trim();
410
464
  if (!/^-?(?:\d+)(?:\.\d+)?$/.test(n)) return !1;
@@ -412,18 +466,18 @@ function ne(e, t) {
412
466
  if (!Number.isFinite(r)) return !1;
413
467
  if (t !== void 0) {
414
468
  let e = n.split(".")[1]?.length ?? 0;
415
- if (!Number.isInteger(t) || t < 0 || t > k || e > t) return !1;
469
+ if (!Number.isInteger(t) || t < 0 || t > O || e > t) return !1;
416
470
  }
417
471
  return !0;
418
472
  }
419
- function re(e) {
473
+ function le(e) {
420
474
  if (typeof e != "string" && typeof e != "number") return !1;
421
475
  let t = String(e).trim(), n = /^(\d{4})[-/年](\d{1,2})[-/月](\d{1,2})(?:日)?(?:[T\s].*)?$/.exec(t);
422
476
  if (!n) return !1;
423
477
  let r = Number(n[1]), i = Number(n[2]), a = Number(n[3]), o = new Date(Date.UTC(r, i - 1, a));
424
478
  return o.getUTCFullYear() === r && o.getUTCMonth() === i - 1 && o.getUTCDate() === a;
425
479
  }
426
- function ie(e) {
480
+ function ue(e) {
427
481
  return typeof e == "boolean" ? !0 : [
428
482
  "1",
429
483
  "true",
@@ -439,16 +493,16 @@ function ie(e) {
439
493
  "未选"
440
494
  ].includes(String(e).trim().toLowerCase());
441
495
  }
442
- function ae(e) {
443
- return A.test(e);
496
+ function de(e) {
497
+ return k.test(e);
444
498
  }
445
- function oe(e) {
499
+ function fe(e) {
446
500
  return e === "select" || e === "radio" || e === "user-selector" || e === "dept-selector" || e === "role-selector" || e === "org-selector";
447
501
  }
448
- function se(e, t) {
449
- return t ? Array.isArray(e) && e.every(g) : g(e);
502
+ function pe(e, t) {
503
+ return t ? Array.isArray(e) && e.every(_) : _(e);
450
504
  }
451
- function ce(e, t) {
505
+ function me(e, t) {
452
506
  let n = e.width;
453
507
  if (!Number.isFinite(n) || n <= 0) return !1;
454
508
  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);
@@ -457,7 +511,7 @@ function ce(e, t) {
457
511
  function $(e) {
458
512
  if (!e || typeof e != "object") return !1;
459
513
  let { width: t, height: n } = e;
460
- return typeof t == "number" && typeof n == "number" && Number.isFinite(t) && Number.isFinite(n) && t >= D && n >= D && t <= O && n <= O;
514
+ return typeof t == "number" && typeof n == "number" && Number.isFinite(t) && Number.isFinite(n) && t >= E && n >= E && t <= D && n <= D;
461
515
  }
462
516
  //#endregion
463
- export { j as buildInitialRenderValues, I as buildTemplateRenderHtml, F as buildTemplateRenderPages, C as buildTemplateVariableData, L as isEmptyRenderValue, ee as normalizeRenderValues, N as resolveTemplateRenderSubmitErrors, q as sanitizeContractRendererHtml, P as validateTemplateRenderStructure, M as validateTemplateRenderValues };
517
+ export { A as buildInitialRenderValues, F as buildTemplateRenderHtml, P as buildTemplateRenderPages, te as buildTemplateVariableData, I as isEmptyRenderValue, j as normalizeRenderValues, ne as resolveTemplateRenderSubmitErrors, X as sanitizeContractRendererHtml, N as validateTemplateRenderStructure, M as validateTemplateRenderValues };
@@ -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, o(t.width, 160)), s = Math.max(24, o(t.height, 32)), c = 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, o(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, o(t.rows, 3)), x = Math.max(18, o(t.lineHeight, 28)), S = b * x, C = v === "fill" ? "100% 100%" : v, w = g === "right" ? "flex-end" : g === "center" ? "center" : "flex-start", T = String(t.defaultValue || ""), E = n({
4
+ let r = t.type === void 0 ? "text" : String(t.type), i = Math.max(24, o(t.width, 160)), s = Math.max(24, o(t.height, 32)), c = 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, o(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, o(t.rows, 3)), x = Math.max(18, o(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 || "",
@@ -9,7 +9,9 @@ function t(t) {
9
9
  precision: t.precision,
10
10
  useGrouping: t.useGrouping,
11
11
  checkedText: t.checkedText || "",
12
- uncheckedText: t.uncheckedText || ""
12
+ uncheckedText: t.uncheckedText || "",
13
+ options: t.options,
14
+ multiple: t.multiple
13
15
  }), D = T.trim().length > 0, O = !D && E.trim().length > 0, k = r === "checkbox" && a(T), A = r === "image" && D ? `;--gd-contract-variable-image:url('${T.replaceAll("'", "%27")}')` : "";
14
16
  return {
15
17
  type: r,
@@ -44,12 +46,22 @@ function t(t) {
44
46
  };
45
47
  }
46
48
  function n(e) {
47
- let t = e.type || "text", n = e.defaultValue || "", o = e.placeholder || "";
48
- return t === "checkbox" ? n ? a(n) ? e.checkedText || o : e.uncheckedText || o : o : n ? t === "date" ? r(n, e.format || "") : t === "number" ? i(n, {
49
+ let t = e.type || "text", n = t === "select" && e.multiple ? "" : e.defaultValue || "", o = e.placeholder || "";
50
+ if (t === "checkbox") return n ? a(n) ? e.checkedText || o : e.uncheckedText || o : o;
51
+ if (!n) return o;
52
+ if (t === "date") return r(n, e.format || "");
53
+ if (t === "number") return i(n, {
49
54
  format: e.format || "",
50
55
  precision: e.precision,
51
56
  useGrouping: e.useGrouping
52
- }) : t === "image" ? o : n : o;
57
+ });
58
+ if (t === "image") return o;
59
+ if (t === "select") {
60
+ let t = e.options?.find((e) => String(e.value ?? "") === n);
61
+ if (t?.label) return t.label;
62
+ if (e.options?.length) return o;
63
+ }
64
+ return n;
53
65
  }
54
66
  function r(e, t) {
55
67
  if (!t) return e;