@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
@@ -1,10 +1,10 @@
1
1
  import { DEFAULT_CONTRACT_FONT_FAMILY as e } from "../constants.mjs";
2
2
  import { canUseDomHtml as t, createElementAttributeReader as n, createTagAttributeReader as r, escapeHtmlAttribute as i, escapeHtmlText as a, forEachHtmlTag as o, readNumberAttribute as s, readOptionalBoolean as c, readOptionalNumber as l, replaceTemplateVariableSpans as u } from "../utils/html.mjs";
3
3
  import { resolveTemplateVariablePresentation as ee } from "../utils/template-variable-render.mjs";
4
- import { buildPageDecorationClassNames as te, buildPageDecorationsHtml as d, collectPageDecorationVariableKeys as f, normalizePageDecorations as p, validatePageDecorations as m } from "../utils/page-decorations.mjs";
4
+ import { buildPageDecorationClassNames as d, buildPageDecorationsHtml as f, collectPageDecorationVariableKeys as te, normalizePageDecorations as p, validatePageDecorations as m } from "../utils/page-decorations.mjs";
5
5
  import { isContractTemplateFieldType as ne } from "../types.mjs";
6
- import { decodeContractTemplateJsonAttribute as h } from "../utils/advanced-controls.mjs";
7
- import { toRaw as re } from "vue";
6
+ import { buildRadioOptionsHtml as re, decodeContractTemplateJsonAttribute as h } from "../utils/advanced-controls.mjs";
7
+ import { toRaw as ie } from "vue";
8
8
  //#region src/components/pro-contract-template-designer/src/composables/use-template-designer.ts
9
9
  var g = [
10
10
  {
@@ -65,20 +65,30 @@ var g = [
65
65
  textAlign: "left",
66
66
  borderStyle: "solid",
67
67
  objectFit: "contain"
68
- }, ie = 3, ae = 28, oe = "contract-template-renderer-1.0.0", se = "contract-render-css-1.0.0", ce = /^[A-Za-z][A-Za-z0-9_]{1,63}$/, y = new Set([
68
+ }, ae = 3, oe = 28, y = "contract-template-renderer-1.0.0", se = "contract-render-css-1.0.0", ce = /^[A-Za-z][A-Za-z0-9_]{1,63}$/, le = new Set([
69
69
  "pageNumber",
70
70
  "totalPages",
71
71
  "rendererVersion"
72
72
  ]);
73
73
  function b(e, t, n) {
74
74
  let r = typeof e == "string" ? e.trim() : "";
75
- return r ? ce.test(r) ? y.has(r) ? `${r} 是系统保留标识` : t.some((e) => e.id !== n && e.key.trim() === r) ? `变量标识 ${r} 已存在` : "" : "变量标识需以字母开头,仅包含字母、数字和下划线,长度为 2~64 位" : "请输入变量标识";
75
+ return r ? ce.test(r) ? le.has(r) ? `${r} 是系统保留标识` : t.some((e) => e.id !== n && e.key.trim() === r) ? `变量标识 ${r} 已存在` : "" : "变量标识需以字母开头,仅包含字母、数字和下划线,长度为 2~64 位" : "请输入变量标识";
76
76
  }
77
- function le(e) {
77
+ function ue(e) {
78
78
  let t = Number(e);
79
79
  return Number.isFinite(t) && t >= 1 ? Math.max(1, Math.floor(t)) : 20;
80
80
  }
81
- var x = [
81
+ var x = {
82
+ type: "image",
83
+ label: "图片",
84
+ defaultWidth: 160,
85
+ defaultHeight: 96
86
+ }, S = {
87
+ type: "checkbox",
88
+ label: "复选框",
89
+ defaultWidth: 96,
90
+ defaultHeight: 28
91
+ }, C = [
82
92
  {
83
93
  type: "text",
84
94
  label: "输入框",
@@ -98,18 +108,18 @@ var x = [
98
108
  defaultHeight: 32
99
109
  },
100
110
  {
101
- type: "image",
102
- label: "图片",
103
- defaultWidth: 160,
104
- defaultHeight: 96
111
+ type: "select",
112
+ label: "下拉框",
113
+ defaultWidth: 180,
114
+ defaultHeight: 32
105
115
  },
106
116
  {
107
- type: "checkbox",
108
- label: "复选框",
109
- defaultWidth: 96,
110
- defaultHeight: 28
117
+ type: "radio",
118
+ label: "单选框",
119
+ defaultWidth: 220,
120
+ defaultHeight: 32
111
121
  }
112
- ], S = [{
122
+ ], w = [{
113
123
  type: "select",
114
124
  label: "下拉框",
115
125
  defaultWidth: 180,
@@ -119,7 +129,7 @@ var x = [
119
129
  label: "单选框",
120
130
  defaultWidth: 220,
121
131
  defaultHeight: 32
122
- }], ue = [
132
+ }], T = [
123
133
  {
124
134
  type: "user-selector",
125
135
  label: "用户选择器",
@@ -144,31 +154,33 @@ var x = [
144
154
  defaultWidth: 240,
145
155
  defaultHeight: 36
146
156
  }
147
- ], C = [{
157
+ ], E = [{
148
158
  type: "custom",
149
159
  label: "自定义控件",
150
160
  defaultWidth: 200,
151
161
  defaultHeight: 36
152
- }], w = [
153
- ...x,
154
- ...S,
155
- ...ue,
156
- ...C
157
- ], T = 0;
158
- function E(e) {
159
- return T += 1, `${e}-${Date.now().toString(36)}-${T.toString(36)}`;
160
- }
161
- function D(e) {
162
+ }], D = [
163
+ ...C,
164
+ x,
165
+ S,
166
+ ...w,
167
+ ...T,
168
+ ...E
169
+ ], O = 0;
170
+ function k(e) {
171
+ return O += 1, `${e}-${Date.now().toString(36)}-${O.toString(36)}`;
172
+ }
173
+ function A(e) {
162
174
  return JSON.parse(JSON.stringify(e));
163
175
  }
164
- function O(e) {
176
+ function j(e) {
165
177
  return g.find((t) => t.format === e);
166
178
  }
167
- function k(e) {
179
+ function M(e) {
168
180
  if (e) return e.format && e.format !== "Custom" ? e.format : g.find((t) => t.width === e.width && t.height === e.height)?.format;
169
181
  }
170
- function A(e, t = _) {
171
- let n = k(t) ?? t.format, r = e?.format ?? k(e) ?? n ?? "Custom", i = r === "Custom" ? void 0 : O(r), a = P(i?.width ?? e?.width, t.width), o = P(i?.height ?? e?.height, t.height);
182
+ function N(e, t = _) {
183
+ let n = M(t) ?? t.format, r = e?.format ?? M(e) ?? n ?? "Custom", i = r === "Custom" ? void 0 : j(r), a = L(i?.width ?? e?.width, t.width), o = L(i?.height ?? e?.height, t.height);
172
184
  return {
173
185
  format: i?.format ?? r,
174
186
  width: a,
@@ -176,22 +188,22 @@ function A(e, t = _) {
176
188
  label: e?.label ?? i?.label ?? t.label ?? r
177
189
  };
178
190
  }
179
- function j(e) {
191
+ function P(e) {
180
192
  return `${e.format ?? "Custom"}:${e.width}:${e.height}`;
181
193
  }
182
- function M(e) {
194
+ function F(e) {
183
195
  let t = (Array.isArray(e) ? e : g).map((e) => {
184
196
  let t = Number(e?.width), n = Number(e?.height);
185
197
  if (!Number.isFinite(t) || t <= 0 || !Number.isFinite(n) || n <= 0) return;
186
198
  let r = e?.format;
187
199
  if (r && r !== "Custom") {
188
- let t = O(r);
200
+ let t = j(r);
189
201
  return t ? {
190
202
  ...t,
191
203
  label: e.label ?? t.label
192
204
  } : void 0;
193
205
  }
194
- let i = r ? void 0 : k(e), a = i ? O(i) : void 0;
206
+ let i = r ? void 0 : M(e), a = i ? j(i) : void 0;
195
207
  if (a) return {
196
208
  ...a,
197
209
  label: e.label ?? a.label
@@ -205,19 +217,19 @@ function M(e) {
205
217
  label: e.label ?? "Custom"
206
218
  };
207
219
  }).filter(Boolean), n = /* @__PURE__ */ new Set(), r = t.filter((e) => {
208
- let t = j(e);
220
+ let t = P(e);
209
221
  return n.has(t) ? !1 : (n.add(t), !0);
210
222
  });
211
223
  return (r.length ? r : g).map((e) => ({ ...e }));
212
224
  }
213
- function N(e, t) {
214
- let n = j(e);
215
- return t.find((e) => j(e) === n);
225
+ function I(e, t) {
226
+ let n = P(e);
227
+ return t.find((e) => P(e) === n);
216
228
  }
217
229
  function de(e, t) {
218
- let n = M(t), r = n[0], i = A(e.pageSize, r), a = N(i, n) ?? r, o = /* @__PURE__ */ new Map(), s = e.pages.map((e) => {
219
- let t = A(e.pageSize, i), a = N(t, n) ?? r;
220
- return j(t) !== j(a) && o.set(e.id, {
230
+ let n = F(t), r = n[0], i = N(e.pageSize, r), a = I(i, n) ?? r, o = /* @__PURE__ */ new Map(), s = e.pages.map((e) => {
231
+ let t = N(e.pageSize, i), a = I(t, n) ?? r;
232
+ return P(t) !== P(a) && o.set(e.id, {
221
233
  source: t,
222
234
  target: a
223
235
  }), {
@@ -231,50 +243,50 @@ function de(e, t) {
231
243
  pages: s
232
244
  };
233
245
  }
234
- function P(e, t) {
246
+ function L(e, t) {
235
247
  let n = Number(e);
236
248
  return !Number.isFinite(n) || n <= 0 ? t : Math.round(n);
237
249
  }
238
- function F(e = 1, t) {
250
+ function R(e = 1, t) {
239
251
  return {
240
- id: E("page"),
252
+ id: k("page"),
241
253
  title: `第 ${e} 页`,
242
- pageSize: t ? A(t) : void 0,
254
+ pageSize: t ? N(t) : void 0,
243
255
  contentHtml: "<p>请输入合同正文。</p>"
244
256
  };
245
257
  }
246
- function I(e = 1, t, n = "<p></p>", r) {
258
+ function z(e = 1, t, n = "<p></p>", r) {
247
259
  return {
248
- id: E("page"),
260
+ id: k("page"),
249
261
  title: `第 ${e} 页`,
250
- pageSize: t ? A(t) : void 0,
262
+ pageSize: t ? N(t) : void 0,
251
263
  contentHtml: n,
252
264
  contentJson: r
253
265
  };
254
266
  }
255
- function L(e = _) {
256
- let t = A(e);
267
+ function B(e = _) {
268
+ let t = N(e);
257
269
  return {
258
- pages: [F(1, t)],
270
+ pages: [R(1, t)],
259
271
  variables: [],
260
272
  pageSize: t
261
273
  };
262
274
  }
263
275
  function fe(e = _) {
264
- let t = A(e);
276
+ let t = N(e);
265
277
  return {
266
- pages: [I(1, t, "<p></p>")],
278
+ pages: [z(1, t, "<p></p>")],
267
279
  variables: [],
268
280
  pageSize: t
269
281
  };
270
282
  }
271
- function R(e, t = x) {
272
- return t.find((t) => t.type === e) ?? w.find((t) => t.type === e) ?? x[0];
283
+ function pe(e, t = C) {
284
+ return t.find((t) => t.type === e) ?? D.find((t) => t.type === e) ?? C[0];
273
285
  }
274
- function z(e, t = x, n = {}) {
275
- let r = e.type === void 0 ? "text" : e.type, i = R(r, t), a = pe(r);
286
+ function V(e, t = C, n = {}) {
287
+ let r = e.type === void 0 ? "text" : e.type, i = pe(r, t), a = me(r);
276
288
  return {
277
- id: e.id ?? E("variable"),
289
+ id: e.id ?? k("variable"),
278
290
  key: e.key,
279
291
  label: e.label ?? i.label ?? e.key,
280
292
  type: r,
@@ -288,7 +300,7 @@ function z(e, t = x, n = {}) {
288
300
  useGrouping: e.useGrouping ?? a.useGrouping,
289
301
  checkedText: e.checkedText ?? a.checkedText ?? "",
290
302
  uncheckedText: e.uncheckedText ?? a.uncheckedText ?? "",
291
- options: Array.isArray(e.options) ? e.options.map((e) => ({ ...e })) : [],
303
+ options: Array.isArray(e.options) ? e.options.map((e) => ({ ...e })) : (a.options ?? []).map((e) => ({ ...e })),
292
304
  dataSource: e.dataSource ? { ...e.dataSource } : void 0,
293
305
  multiple: e.multiple ?? !1,
294
306
  componentKey: e.componentKey ?? "",
@@ -304,7 +316,7 @@ function z(e, t = x, n = {}) {
304
316
  }
305
317
  };
306
318
  }
307
- function pe(e) {
319
+ function me(e) {
308
320
  return e === "date" ? {
309
321
  placeholder: "年 月 日",
310
322
  format: "YYYY年MM月DD日",
@@ -344,6 +356,15 @@ function pe(e) {
344
356
  } : e === "select" || e === "radio" ? {
345
357
  placeholder: e === "select" ? "请选择" : "请选择一项",
346
358
  multiple: !1,
359
+ options: [{
360
+ value: "option1",
361
+ label: "选项1",
362
+ type: e
363
+ }, {
364
+ value: "option2",
365
+ label: "选项2",
366
+ type: e
367
+ }],
347
368
  style: {
348
369
  border: !0,
349
370
  underline: !1
@@ -360,35 +381,36 @@ function pe(e) {
360
381
  underline: !0
361
382
  } };
362
383
  }
363
- function B(e) {
384
+ function H(e) {
364
385
  return e !== void 0 && !ne(e);
365
386
  }
366
- function me(e, t = _) {
367
- if (!e) return L(t);
368
- let n = A(e.pageSize, t), r = (e.pages?.length ? e.pages : [F(1, n)]).map((e, t) => ({
369
- id: e.id || E("page"),
387
+ function he(e, t = _) {
388
+ if (!e) return B(t);
389
+ let n = N(e.pageSize, t), r = (e.pages?.length ? e.pages : [R(1, n)]).map((e, t) => ({
390
+ id: e.id || k("page"),
370
391
  title: e.title || `第 ${t + 1} 页`,
371
- pageSize: A(e.pageSize, n),
392
+ pageSize: N(e.pageSize, n),
372
393
  contentHtml: e.contentHtml || "<p></p>",
373
394
  contentJson: e.contentJson
374
395
  })), i = [], a = /* @__PURE__ */ new Map();
375
- return Object.fromEntries(r.map((e) => [e.id, A(e.pageSize, n)])), (e.variables ?? []).forEach((e) => {
376
- let t = z({
396
+ return Object.fromEntries(r.map((e) => [e.id, N(e.pageSize, n)])), (e.variables ?? []).forEach((e) => {
397
+ let t = V({
377
398
  ...e,
378
- id: e.id || E("variable")
399
+ id: e.id || k("variable"),
400
+ options: Array.isArray(e.options) ? e.options : []
379
401
  });
380
402
  i.push(t), t.key && a.set(t.key, t);
381
403
  }), r.forEach((e) => {
382
- Y(e).forEach((e) => {
404
+ De(e).forEach((e) => {
383
405
  if (!e.key) return;
384
406
  let t = a.get(e.key);
385
407
  if (!t) {
386
- let t = z(e);
408
+ let t = V(e);
387
409
  i.push(t), a.set(e.key, t);
388
410
  return;
389
411
  }
390
- if (B(e.type)) {
391
- let n = z({
412
+ if (H(e.type)) {
413
+ let n = V({
392
414
  ...t,
393
415
  type: e.type
394
416
  });
@@ -404,45 +426,45 @@ function me(e, t = _) {
404
426
  ...e.pageDecorations ? { pageDecorations: p(e.pageDecorations) } : {}
405
427
  };
406
428
  }
407
- function he(e) {
408
- return e.pages.map((t, n) => q(e, t, n, t.contentHtml, {})).join("\n");
429
+ function ge(e) {
430
+ return e.pages.map((t, n) => Y(e, t, n, t.contentHtml, {})).join("\n");
409
431
  }
410
- function V(e) {
411
- return e.pages.map((t, n) => q(e, t, n, Ie(t.contentHtml))).join("\n");
432
+ function U(e) {
433
+ return e.pages.map((t, n) => Y(e, t, n, Be(t.contentHtml))).join("\n");
412
434
  }
413
- function ge(e) {
414
- return H(e).map(({ page: t, contentHtml: n }, r) => {
415
- let i = A(t.pageSize, e.pageSize), a = d(e.pageDecorations, r + 1, e.pages.length, e.variables, {});
416
- return `<section ${J(t, e.pageSize, e.pageDecorations, r + 1)} style="width:${i.width}px;min-height:${i.height}px">${a}<div class="gd-contract-template-page__content">${n}</div></section>`;
435
+ function _e(e) {
436
+ return W(e).map(({ page: t, contentHtml: n }, r) => {
437
+ let i = N(t.pageSize, e.pageSize), a = f(e.pageDecorations, r + 1, e.pages.length, e.variables, {});
438
+ return `<section ${Te(t, e.pageSize, e.pageDecorations, r + 1)} style="width:${i.width}px;min-height:${i.height}px">${a}<div class="gd-contract-template-page__content">${n}</div></section>`;
417
439
  }).join("\n");
418
440
  }
419
- function H(e) {
441
+ function W(e) {
420
442
  let t = new Map(e.variables.map((e) => [e.key, e]));
421
443
  return e.pages.map((e) => ({
422
444
  page: {
423
445
  ...e,
424
446
  ...e.pageSize ? { pageSize: { ...e.pageSize } } : {}
425
447
  },
426
- contentHtml: De(e.contentHtml, t)
448
+ contentHtml: Ae(e.contentHtml, t)
427
449
  }));
428
450
  }
429
- var U = class extends Error {
451
+ var G = class extends Error {
430
452
  constructor(e) {
431
453
  super(e[0]?.message || "页面装饰配置无效"), this.errors = e, this.name = "ContractTemplatePageDecorationValidationError";
432
454
  }
433
455
  };
434
- function _e(e) {
456
+ function ve(e) {
435
457
  let t = m(e.pageDecorations, e.variables);
436
- if (t.length) throw new U(t);
437
- let n = D(e);
458
+ if (t.length) throw new G(t);
459
+ let n = A(e);
438
460
  return n.pageDecorations &&= p(n.pageDecorations), {
439
461
  ...n,
440
- rendererVersion: oe,
462
+ rendererVersion: y,
441
463
  styleVersion: se,
442
- html: V(n)
464
+ html: U(n)
443
465
  };
444
466
  }
445
- function ve(e, t = {}) {
467
+ function ye(e, t = {}) {
446
468
  let n = [], r = /* @__PURE__ */ new Set();
447
469
  typeof t.maxPages == "number" && e.pages.length > t.maxPages && n.push({
448
470
  type: "page",
@@ -464,7 +486,7 @@ function ve(e, t = {}) {
464
486
  variableKey: t.key,
465
487
  message: `变量标识 ${t.key} 重复`,
466
488
  code: "VARIABLE_KEY_DUPLICATED"
467
- }), r.add(t.key)), B(t.type) && n.push({
489
+ }), r.add(t.key)), H(t.type) && n.push({
468
490
  type: "variable",
469
491
  id: t.id,
470
492
  variableKey: t.key,
@@ -472,9 +494,9 @@ function ve(e, t = {}) {
472
494
  code: "VARIABLE_TYPE_UNSUPPORTED"
473
495
  });
474
496
  });
475
- let i = new Set(e.variables.map((e) => e.key).filter(Boolean)), a = /* @__PURE__ */ new Set(), o = f(e.pageDecorations);
497
+ let i = new Set(e.variables.map((e) => e.key).filter(Boolean)), a = /* @__PURE__ */ new Set(), o = te(e.pageDecorations);
476
498
  return e.pages.forEach((e) => {
477
- W(e).forEach((t) => {
499
+ K(e).forEach((t) => {
478
500
  a.add(t), i.has(t) || n.push({
479
501
  type: "variable",
480
502
  id: e.id,
@@ -489,12 +511,12 @@ function ve(e, t = {}) {
489
511
  });
490
512
  }), n.push(...m(e.pageDecorations, e.variables)), n;
491
513
  }
492
- function W(e) {
514
+ function K(e) {
493
515
  let t = /* @__PURE__ */ new Set();
494
516
  function n(e) {
495
517
  if (!e || typeof e != "object") return;
496
518
  let r = e;
497
- ye(r.type) && r.attrs?.key && t.add(r.attrs.key), r.content?.forEach(n);
519
+ be(r.type) && r.attrs?.key && t.add(r.attrs.key), r.content?.forEach(n);
498
520
  }
499
521
  n(e.contentJson);
500
522
  let r = e.contentHtml || "", i = /data-template-variable=["']true["'][^>]*data-key=["']([^"']+)["']|data-key=["']([^"']+)["'][^>]*data-template-variable=["']true["']/g, a = i.exec(r);
@@ -504,31 +526,31 @@ function W(e) {
504
526
  }
505
527
  return t;
506
528
  }
507
- function ye(e) {
529
+ function be(e) {
508
530
  return e === "templateVariable" || e === "templateField";
509
531
  }
510
- function G(e) {
532
+ function q(e) {
511
533
  let t = /* @__PURE__ */ new Set();
512
534
  return e.pages.forEach((e) => {
513
- W(e).forEach((e) => t.add(e));
535
+ K(e).forEach((e) => t.add(e));
514
536
  }), t;
515
537
  }
516
- function K(e, t = G(e)) {
517
- let n = f(e.pageDecorations), r = /* @__PURE__ */ new Map();
538
+ function J(e, t = q(e)) {
539
+ let n = te(e.pageDecorations), r = /* @__PURE__ */ new Map();
518
540
  for (let t of e.variables) r.set(t.key, (r.get(t.key) ?? 0) + 1);
519
541
  return {
520
542
  ...e,
521
543
  variables: e.variables.filter((i) => (r.get(i.key) ?? 0) > 1 || b(i.key, e.variables, i.id) ? !0 : t.has(i.key) || n.has(i.key))
522
544
  };
523
545
  }
524
- function be() {
546
+ function xe() {
525
547
  let e = /* @__PURE__ */ new Map();
526
548
  function t(t) {
527
- let n = t.contentJson && re(t.contentJson), r = e.get(t.id);
549
+ let n = t.contentJson && ie(t.contentJson), r = e.get(t.id);
528
550
  return (!r || r.html !== t.contentHtml || r.json !== n) && (r = {
529
551
  html: t.contentHtml,
530
552
  json: n,
531
- keys: W(t)
553
+ keys: K(t)
532
554
  }, e.set(t.id, r)), r;
533
555
  }
534
556
  function n(n) {
@@ -542,14 +564,14 @@ function be() {
542
564
  let r = n(e), i = e.variables.slice(), a = new Map(i.filter((e) => e.key).map((e) => [e.key, e]));
543
565
  for (let n of e.pages) {
544
566
  let e = t(n);
545
- e.variables ??= Y(n);
567
+ e.variables ??= De(n);
546
568
  for (let t of e.variables) {
547
569
  let e = a.get(t.key);
548
570
  if (!e) {
549
- let e = z(t);
571
+ let e = V(t);
550
572
  i.push(e), a.set(e.key, e);
551
- } else if (B(t.type) && e.type !== t.type) {
552
- let n = z({
573
+ } else if (H(t.type) && e.type !== t.type) {
574
+ let n = V({
553
575
  ...e,
554
576
  type: t.type
555
577
  }), r = i.findIndex((t) => t.id === e.id);
@@ -557,7 +579,7 @@ function be() {
557
579
  }
558
580
  }
559
581
  }
560
- let o = K({
582
+ let o = J({
561
583
  ...e,
562
584
  variables: i
563
585
  }, r);
@@ -569,7 +591,7 @@ function be() {
569
591
  clear: () => e.clear()
570
592
  };
571
593
  }
572
- function xe(e, t) {
594
+ function Se(e, t) {
573
595
  for (let n = 0; n < t; n += 1) {
574
596
  let r = e[n]?.content ?? [];
575
597
  for (let e of r) {
@@ -579,7 +601,7 @@ function xe(e, t) {
579
601
  }
580
602
  return !0;
581
603
  }
582
- function Se(e, t, n) {
604
+ function Ce(e, t, n) {
583
605
  let r = e.content ?? [], i = t.tableRows ?? [], a = Math.min(r.length, i.length), o = n - Math.max(0, t.trailingTextBlockHeight ?? 0), s = 0;
584
606
  for (let e = 0; e < a; e += 1) {
585
607
  let t = i[e];
@@ -588,7 +610,7 @@ function Se(e, t, n) {
588
610
  }
589
611
  if (s <= 0 || s >= r.length) return;
590
612
  let c = s;
591
- for (; c > 0 && !xe(r, c);) --c;
613
+ for (; c > 0 && !Se(r, c);) --c;
592
614
  if (!(c <= 0 || c >= r.length)) return {
593
615
  currentTable: {
594
616
  ...e,
@@ -600,7 +622,7 @@ function Se(e, t, n) {
600
622
  }
601
623
  };
602
624
  }
603
- function Ce(e, t, n) {
625
+ function we(e, t, n) {
604
626
  let r = e ?? [];
605
627
  if (!r.length || n <= 0) return;
606
628
  let i = Math.min(r.length, t.length), a = -1;
@@ -612,7 +634,7 @@ function Ce(e, t, n) {
612
634
  }
613
635
  }
614
636
  if (a < 0) return;
615
- let o = r[a], s = o?.type === "table" ? Se(o, t[a], n) : void 0;
637
+ let o = r[a], s = o?.type === "table" ? Ce(o, t[a], n) : void 0;
616
638
  if (s) return {
617
639
  splitIndex: a,
618
640
  currentContent: [...r.slice(0, a), s.currentTable],
@@ -624,14 +646,14 @@ function Ce(e, t, n) {
624
646
  overflowContent: r.slice(a)
625
647
  };
626
648
  }
627
- function q(e, t, n, r, i) {
628
- let a = d(e.pageDecorations, n + 1, e.pages.length, e.variables, i);
629
- return `<section ${J(t, e.pageSize, e.pageDecorations, n + 1)}>${a}<div class="gd-contract-template-page__content">${r}</div></section>`;
649
+ function Y(e, t, n, r, i) {
650
+ let a = f(e.pageDecorations, n + 1, e.pages.length, e.variables, i);
651
+ return `<section ${Te(t, e.pageSize, e.pageDecorations, n + 1)}>${a}<div class="gd-contract-template-page__content">${r}</div></section>`;
630
652
  }
631
- function J(e, t, n, r = 1) {
632
- let a = A(e.pageSize, t);
653
+ function Te(e, t, n, r = 1) {
654
+ let a = N(e.pageSize, t);
633
655
  return [
634
- `class="${te(n, r)}"`,
656
+ `class="${d(n, r)}"`,
635
657
  `data-page-id="${i(e.id)}"`,
636
658
  `data-page-format="${i(a.format ?? "Custom")}"`,
637
659
  `data-page-label="${i(a.label ?? a.format ?? "自定义")}"`,
@@ -639,28 +661,28 @@ function J(e, t, n, r = 1) {
639
661
  `data-page-height="${a.height}"`
640
662
  ].join(" ");
641
663
  }
642
- var we = /<span\b[^>]*data-template-variable=["']true["'][^>]*>/g;
643
- function Y(e) {
664
+ var Ee = /<span\b[^>]*data-template-variable=["']true["'][^>]*>/g;
665
+ function De(e) {
644
666
  let i = /* @__PURE__ */ new Map();
645
667
  function a(e) {
646
668
  if (!e.key) return;
647
669
  let t = i.get(e.key);
648
- (!t || B(e.type) && !B(t.type)) && i.set(e.key, e);
670
+ (!t || H(e.type) && !H(t.type)) && i.set(e.key, e);
649
671
  }
650
672
  function s(e) {
651
673
  if (!e || typeof e != "object") return;
652
674
  let t = e;
653
- t.type === "templateVariable" && typeof t.attrs?.key == "string" && a(Ee(t.attrs, t.attrs.key)), t.content?.forEach(s);
675
+ t.type === "templateVariable" && typeof t.attrs?.key == "string" && a(ke(t.attrs, t.attrs.key)), t.content?.forEach(s);
654
676
  }
655
677
  s(e.contentJson);
656
678
  let c = e.contentHtml || "";
657
679
  return t() ? new DOMParser().parseFromString(c, "text/html").querySelectorAll("[data-template-variable]").forEach((e) => {
658
- a(Te(n(e)));
659
- }) : o(c, we, (e) => {
660
- a(Te(r(e)));
680
+ a(Oe(n(e)));
681
+ }) : o(c, Ee, (e) => {
682
+ a(Oe(r(e)));
661
683
  }), Array.from(i.values());
662
684
  }
663
- function Te(e) {
685
+ function Oe(e) {
664
686
  let t = e("data-key") ?? "", n = e("data-variable-type"), r = e("data-precision"), i = e("data-use-grouping");
665
687
  return {
666
688
  key: t,
@@ -699,7 +721,7 @@ function Te(e) {
699
721
  }
700
722
  };
701
723
  }
702
- function Ee(e, t) {
724
+ function ke(e, t) {
703
725
  let n = (t) => typeof e[t] == "string" ? e[t] : void 0;
704
726
  return {
705
727
  key: t,
@@ -738,20 +760,20 @@ function Ee(e, t) {
738
760
  }
739
761
  };
740
762
  }
741
- function De(e, n) {
763
+ function Ae(e, n) {
742
764
  if (!e) return e;
743
765
  if (t()) {
744
766
  let t = new DOMParser().parseFromString(e, "text/html");
745
- return Oe(t), t.querySelectorAll("[data-template-variable]").forEach((e) => {
746
- Ae(e, n);
767
+ return je(t), t.querySelectorAll("[data-template-variable]").forEach((e) => {
768
+ Pe(e, n);
747
769
  }), t.body.innerHTML;
748
770
  }
749
- return u(Me(e), (e, t) => {
771
+ return u(Ie(e), (e, t) => {
750
772
  let i = r(t);
751
- return i("data-key") ? je(i, n) : e;
773
+ return i("data-key") ? Fe(i, n) : e;
752
774
  });
753
775
  }
754
- function Oe(e) {
776
+ function je(e) {
755
777
  e.querySelectorAll("script,style,meta,link").forEach((e) => e.remove()), e.querySelectorAll("*").forEach((e) => {
756
778
  Array.from(e.attributes).forEach((t) => {
757
779
  let n = t.name.toLowerCase(), r = t.value;
@@ -763,12 +785,12 @@ function Oe(e) {
763
785
  e.removeAttribute(t.name);
764
786
  return;
765
787
  }
766
- n === "style" && Fe(r) && e.removeAttribute(t.name);
788
+ n === "style" && ze(r) && e.removeAttribute(t.name);
767
789
  });
768
790
  });
769
791
  }
770
- function ke(e, t) {
771
- let n = e("data-key") ?? "", r = t.get(n), i = r?.type ?? e("data-variable-type") ?? "text", a = Pe(i, r?.defaultValue ?? e("data-default-value") ?? ""), o = ee({
792
+ function Me(e, t) {
793
+ let n = e("data-key") ?? "", r = t.get(n), i = r?.type ?? e("data-variable-type") ?? "text", a = Re(i, r?.defaultValue ?? e("data-default-value") ?? ""), o = Ne(r, e), s = r ? !!r.multiple : e("data-multiple") === "true", u = ee({
772
794
  type: i,
773
795
  width: r?.width ?? e("data-width"),
774
796
  height: r?.height ?? e("data-height"),
@@ -782,27 +804,35 @@ function ke(e, t) {
782
804
  multiline: r?.multiline ?? c(e("data-multiline")) ?? !1,
783
805
  rows: r?.rows ?? e("data-rows"),
784
806
  lineHeight: r?.lineHeight ?? e("data-line-height"),
785
- style: Ne(r, e)
786
- });
807
+ options: o,
808
+ multiple: s,
809
+ style: Le(r, e)
810
+ }), d = u.type === "radio" && o.length ? re(o, a) : "";
787
811
  return {
788
812
  key: n,
789
813
  label: r?.label ?? e("data-label") ?? n,
790
- presentation: o,
791
- text: o.type === "image" && o.hasDefaultValue ? " " : o.displayText || " "
814
+ presentation: u,
815
+ radioHtml: d,
816
+ text: u.type === "image" && u.hasDefaultValue ? " " : u.type === "radio" && !d ? r?.placeholder || e("data-placeholder") || " " : u.displayText || " "
792
817
  };
793
818
  }
794
- function Ae(e, t) {
795
- let { key: r, label: i, presentation: a, text: o } = ke(n(e), t);
796
- e.setAttribute("data-template-variable", "true"), e.setAttribute("data-key", r), e.setAttribute("data-label", i), e.setAttribute("data-variable-type", a.type), e.setAttribute("data-width", String(a.width)), e.setAttribute("data-height", String(a.height)), e.setAttribute("data-border", String(a.border)), e.setAttribute("data-underline", String(a.underline)), e.setAttribute("data-color", a.color), e.setAttribute("data-background", a.background), e.setAttribute("data-font-size", String(a.fontSize)), e.setAttribute("data-font-family", a.fontFamily), e.setAttribute("data-placeholder-color", a.placeholderColor), e.setAttribute("data-line-color", a.lineColor), e.setAttribute("data-text-align", a.textAlign), e.setAttribute("data-border-style", a.borderStyle), e.setAttribute("data-object-fit", a.objectFit), e.className = a.classes.join(" "), e.setAttribute("style", a.styleText), e.textContent = o;
819
+ function Ne(e, t) {
820
+ if (e) return Array.isArray(e.options) ? e.options : [];
821
+ let n = h(t("data-control-options"));
822
+ return Array.isArray(n) ? n : [];
797
823
  }
798
- function je(e, t) {
799
- let { key: n, label: r, presentation: o, text: s } = ke(e, t);
800
- return `<span data-template-variable="true" data-key="${i(n)}" data-label="${i(r)}" data-variable-type="${i(o.type)}" data-width="${o.width}" data-height="${o.height}" data-border="${o.border}" data-underline="${o.underline}" data-font-family="${i(o.fontFamily)}" class="${i(o.classes.join(" "))}" style="${i(o.styleText)}">${a(s)}</span>`;
824
+ function Pe(e, t) {
825
+ let { key: r, label: i, presentation: a, radioHtml: o, text: s } = Me(n(e), t);
826
+ e.setAttribute("data-template-variable", "true"), e.setAttribute("data-key", r), e.setAttribute("data-label", i), e.setAttribute("data-variable-type", a.type), e.setAttribute("data-width", String(a.width)), e.setAttribute("data-height", String(a.height)), e.setAttribute("data-border", String(a.border)), e.setAttribute("data-underline", String(a.underline)), e.setAttribute("data-color", a.color), e.setAttribute("data-background", a.background), e.setAttribute("data-font-size", String(a.fontSize)), e.setAttribute("data-font-family", a.fontFamily), e.setAttribute("data-placeholder-color", a.placeholderColor), e.setAttribute("data-line-color", a.lineColor), e.setAttribute("data-text-align", a.textAlign), e.setAttribute("data-border-style", a.borderStyle), e.setAttribute("data-object-fit", a.objectFit), e.className = a.classes.join(" "), e.setAttribute("style", a.styleText), o ? e.innerHTML = o : e.textContent = s;
801
827
  }
802
- function Me(e) {
803
- return e.replace(/<\s*(script|style|meta|link)\b[\s\S]*?<\s*\/\s*\1\s*>/gi, "").replace(/<\s*(meta|link)\b[^>]*>/gi, "").replace(/\s+on[a-z]+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi, "").replace(/\s+srcdoc\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi, "").replace(/\s+(href|src)\s*=\s*(["'])(.*?)\2/gi, (e, t, n, r) => X(r) ? "" : ` ${t}=${n}${r}${n}`).replace(/\s+style\s*=\s*(["'])(.*?)\1/gi, (e, t, n) => Fe(n) ? "" : ` style=${t}${n}${t}`);
828
+ function Fe(e, t) {
829
+ let { key: n, label: r, presentation: o, radioHtml: s, text: c } = Me(e, t);
830
+ return `<span data-template-variable="true" data-key="${i(n)}" data-label="${i(r)}" data-variable-type="${i(o.type)}" data-width="${o.width}" data-height="${o.height}" data-border="${o.border}" data-underline="${o.underline}" data-font-family="${i(o.fontFamily)}" class="${i(o.classes.join(" "))}" style="${i(o.styleText)}">${s || a(c)}</span>`;
804
831
  }
805
- function Ne(e, t) {
832
+ function Ie(e) {
833
+ return e.replace(/<\s*(script|style|meta|link)\b[\s\S]*?<\s*\/\s*\1\s*>/gi, "").replace(/<\s*(meta|link)\b[^>]*>/gi, "").replace(/\s+on[a-z]+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi, "").replace(/\s+srcdoc\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi, "").replace(/\s+(href|src)\s*=\s*(["'])(.*?)\2/gi, (e, t, n, r) => X(r) ? "" : ` ${t}=${n}${r}${n}`).replace(/\s+style\s*=\s*(["'])(.*?)\1/gi, (e, t, n) => ze(n) ? "" : ` style=${t}${n}${t}`);
834
+ }
835
+ function Le(e, t) {
806
836
  return {
807
837
  border: e?.style?.border ?? c(t("data-border")),
808
838
  underline: e?.style?.underline ?? c(t("data-underline")),
@@ -817,17 +847,17 @@ function Ne(e, t) {
817
847
  objectFit: e?.style?.objectFit ?? $(t("data-object-fit"))
818
848
  };
819
849
  }
820
- function Pe(e, t) {
850
+ function Re(e, t) {
821
851
  return e === "image" && X(t) ? "" : t;
822
852
  }
823
853
  function X(e) {
824
854
  let t = e.trim().replace(/[\u0000-\u001F\s]+/g, "").toLowerCase();
825
855
  return t.startsWith("javascript:") || t.startsWith("vbscript:") || t.startsWith("data:") && !t.startsWith("data:image/");
826
856
  }
827
- function Fe(e) {
857
+ function ze(e) {
828
858
  return /expression\s*\(|javascript:|vbscript:/i.test(e);
829
859
  }
830
- function Ie(e) {
860
+ function Be(e) {
831
861
  if (!e) return e;
832
862
  if (t()) {
833
863
  let t = new DOMParser().parseFromString(e, "text/html");
@@ -841,23 +871,23 @@ function Ie(e) {
841
871
  return n ? `<span${t}>\${{${n}}}</span>` : e;
842
872
  });
843
873
  }
844
- function Le(e) {
874
+ function Ve(e) {
845
875
  return e === "left" || e === "center" || e === "right";
846
876
  }
847
- function Re(e) {
877
+ function He(e) {
848
878
  return e === "solid" || e === "dashed";
849
879
  }
850
- function ze(e) {
880
+ function Ue(e) {
851
881
  return e === "contain" || e === "cover" || e === "fill";
852
882
  }
853
883
  function Z(e) {
854
- return Le(e) ? e : void 0;
884
+ return Ve(e) ? e : void 0;
855
885
  }
856
886
  function Q(e) {
857
- return Re(e) ? e : void 0;
887
+ return He(e) ? e : void 0;
858
888
  }
859
889
  function $(e) {
860
- return ze(e) ? e : void 0;
890
+ return Ue(e) ? e : void 0;
861
891
  }
862
892
  //#endregion
863
- export { w as ALL_DEFAULT_FIELD_TYPES, oe as CONTRACT_TEMPLATE_RENDERER_VERSION, y as CONTRACT_TEMPLATE_RESERVED_VARIABLE_KEYS, se as CONTRACT_TEMPLATE_STYLE_VERSION, ce as CONTRACT_TEMPLATE_VARIABLE_KEY_PATTERN, U as ContractTemplatePageDecorationValidationError, S as DEFAULT_ADVANCED_CHOICE_FIELD_TYPES, ue as DEFAULT_BUILTIN_SELECTOR_FIELD_TYPES, C as DEFAULT_CUSTOM_FIELD_TYPES, v as DEFAULT_FIELD_STYLE, x as DEFAULT_FIELD_TYPES, ae as DEFAULT_MULTILINE_LINE_HEIGHT, ie as DEFAULT_MULTILINE_ROWS, _ as DEFAULT_PAGE_SIZE, g as PAGE_SIZE_OPTIONS, V as buildTemplateExpressionHtml, he as buildTemplateHtml, ge as buildTemplatePreviewHtml, H as buildTemplatePreviewPages, D as cloneTemplateValue, G as collectTemplateValueVariableKeys, W as collectTemplateVariableKeys, de as constrainTemplatePageSizes, I as createBlankPage, fe as createBlankTemplate, F as createDefaultPage, L as createDefaultTemplate, E as createDesignerId, be as createTemplateBodySync, z as createTemplateVariable, _e as exportTemplateValue, N as findPageSizeOption, R as getFieldOption, j as getPageSizeKey, O as getPageSizeOption, k as inferPageFormat, le as normalizeContractTemplateMaxPages, M as normalizePageSizeOptions, me as normalizeTemplateValue, A as resolvePageSize, Ce as splitPageContentByMeasurements, K as syncTemplateVariablesWithPages, b as validateContractTemplateVariableKey, ve as validateTemplateValue };
893
+ export { D as ALL_DEFAULT_FIELD_TYPES, y as CONTRACT_TEMPLATE_RENDERER_VERSION, le as CONTRACT_TEMPLATE_RESERVED_VARIABLE_KEYS, se as CONTRACT_TEMPLATE_STYLE_VERSION, ce as CONTRACT_TEMPLATE_VARIABLE_KEY_PATTERN, G as ContractTemplatePageDecorationValidationError, w as DEFAULT_ADVANCED_CHOICE_FIELD_TYPES, T as DEFAULT_BUILTIN_SELECTOR_FIELD_TYPES, S as DEFAULT_CHECKBOX_FIELD_TYPE, E as DEFAULT_CUSTOM_FIELD_TYPES, v as DEFAULT_FIELD_STYLE, C as DEFAULT_FIELD_TYPES, x as DEFAULT_IMAGE_FIELD_TYPE, oe as DEFAULT_MULTILINE_LINE_HEIGHT, ae as DEFAULT_MULTILINE_ROWS, _ as DEFAULT_PAGE_SIZE, g as PAGE_SIZE_OPTIONS, U as buildTemplateExpressionHtml, ge as buildTemplateHtml, _e as buildTemplatePreviewHtml, W as buildTemplatePreviewPages, A as cloneTemplateValue, q as collectTemplateValueVariableKeys, K as collectTemplateVariableKeys, de as constrainTemplatePageSizes, z as createBlankPage, fe as createBlankTemplate, R as createDefaultPage, B as createDefaultTemplate, k as createDesignerId, xe as createTemplateBodySync, V as createTemplateVariable, ve as exportTemplateValue, I as findPageSizeOption, pe as getFieldOption, P as getPageSizeKey, j as getPageSizeOption, M as inferPageFormat, ue as normalizeContractTemplateMaxPages, F as normalizePageSizeOptions, he as normalizeTemplateValue, N as resolvePageSize, we as splitPageContentByMeasurements, J as syncTemplateVariablesWithPages, b as validateContractTemplateVariableKey, ye as validateTemplateValue };