@guodun/antdv 1.7.3 → 1.7.5

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 (42) hide show
  1. package/dist/es/components/contract-signing-location/src/ContractSigningLocation.vue.mjs +313 -308
  2. package/dist/es/components/pro-contract-template-designer/src/ContractTemplateAuthoringBar.vue.mjs +1 -1
  3. package/dist/es/components/pro-contract-template-designer/src/ContractTemplateSingleRenderer.mjs +5 -0
  4. package/dist/es/components/pro-contract-template-designer/src/ContractTemplateSingleRenderer.vue.mjs +796 -0
  5. package/dist/es/components/pro-contract-template-designer/src/DesignerPage.vue.mjs +16 -5
  6. package/dist/es/components/pro-contract-template-designer/src/ProContractTemplateDesigner.vue.mjs +3 -1
  7. package/dist/es/components/pro-contract-template-designer/src/ProContractTemplateRenderer.vue.mjs +123 -710
  8. package/dist/es/components/pro-contract-template-designer/src/composables/use-renderer-files.mjs +80 -0
  9. package/dist/es/components/pro-contract-template-designer/src/composables/use-template-designer.mjs +172 -134
  10. package/dist/es/components/pro-contract-template-designer/src/composables/use-toolbar-overflow.mjs +11 -9
  11. package/dist/es/components/pro-contract-template-designer/src/extensions/editor-extensions.mjs +37 -35
  12. package/dist/es/components/pro-contract-template-designer/src/extensions/paragraph-enter.mjs +28 -0
  13. package/dist/es/components/pro-contract-template-designer/src/utils/template-renderer.mjs +136 -76
  14. package/dist/es/components/pro-contract-template-designer/src/utils/toolbar-overflow.mjs +10 -9
  15. package/dist/es/components/pro-contract-template-designer/style/index.css +1 -1
  16. package/dist/lib/components/contract-signing-location/src/ContractSigningLocation.vue.cjs +1 -1
  17. package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateAuthoringBar.vue.cjs +1 -1
  18. package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateSingleRenderer.cjs +1 -0
  19. package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateSingleRenderer.vue.cjs +1 -0
  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/ProContractTemplateRenderer.vue.cjs +1 -1
  23. package/dist/lib/components/pro-contract-template-designer/src/composables/use-renderer-files.cjs +1 -0
  24. package/dist/lib/components/pro-contract-template-designer/src/composables/use-template-designer.cjs +4 -4
  25. package/dist/lib/components/pro-contract-template-designer/src/composables/use-toolbar-overflow.cjs +1 -1
  26. package/dist/lib/components/pro-contract-template-designer/src/extensions/editor-extensions.cjs +1 -1
  27. package/dist/lib/components/pro-contract-template-designer/src/extensions/paragraph-enter.cjs +1 -0
  28. package/dist/lib/components/pro-contract-template-designer/src/utils/template-renderer.cjs +3 -3
  29. package/dist/lib/components/pro-contract-template-designer/src/utils/toolbar-overflow.cjs +1 -1
  30. package/dist/lib/components/pro-contract-template-designer/style/index.css +1 -1
  31. package/dist/theme/icon.css +1 -1
  32. package/dist/theme/index.css +1 -1
  33. package/dist/types/components/pro-contract-template-designer/src/ContractTemplateSingleRenderer.vue.d.ts +89 -0
  34. package/dist/types/components/pro-contract-template-designer/src/DesignerPage.vue.d.ts +2 -0
  35. package/dist/types/components/pro-contract-template-designer/src/ProContractTemplateRenderer.vue.d.ts +388 -10
  36. package/dist/types/components/pro-contract-template-designer/src/composables/use-renderer-files.d.ts +14 -0
  37. package/dist/types/components/pro-contract-template-designer/src/composables/use-template-designer.d.ts +9 -2
  38. package/dist/types/components/pro-contract-template-designer/src/extensions/paragraph-enter.d.ts +6 -0
  39. package/dist/types/components/pro-contract-template-designer/src/types.d.ts +16 -2
  40. package/dist/types/components/pro-contract-template-designer/src/utils/template-renderer.d.ts +3 -3
  41. package/dist/types/components/pro-contract-template-designer/src/utils/toolbar-overflow.d.ts +2 -0
  42. package/package.json +3 -3
@@ -31,12 +31,12 @@ function d(d) {
31
31
  v([], n);
32
32
  return;
33
33
  }
34
- let i = r.clientWidth;
35
- if (i <= 0) return;
36
- let a = d.toolbarMoreElement.value, o = 0;
34
+ let i = window.getComputedStyle(r), a = Number.parseFloat(i.paddingLeft) + Number.parseFloat(i.paddingRight), o = r.clientWidth - a;
35
+ if (o <= 0) return;
36
+ let s = Number.parseFloat(i.columnGap) || 0, u = d.toolbarMoreElement.value, f = 0, h = 0;
37
37
  for (let e of Array.from(r.children)) {
38
38
  if (!(e instanceof HTMLElement)) continue;
39
- if (e === a) {
39
+ if (e === u) {
40
40
  e.offsetWidth > 0 && (m = e.offsetWidth);
41
41
  continue;
42
42
  }
@@ -45,14 +45,16 @@ function d(d) {
45
45
  e.offsetWidth > 0 && p.set(t, e.offsetWidth);
46
46
  continue;
47
47
  }
48
- o += e.offsetWidth;
48
+ f += e.offsetWidth, h += 1;
49
49
  }
50
- let s = Object.fromEntries(e.map((e) => [e, p.get(e) ?? 0]));
50
+ let g = Object.fromEntries(e.map((e) => [e, p.get(e) ?? 0]));
51
51
  v(t({
52
- availableWidth: i,
53
- fixedWidth: o,
54
- groupWidths: s,
52
+ availableWidth: o,
53
+ fixedWidth: f,
54
+ fixedItemCount: h,
55
+ groupWidths: g,
55
56
  moreWidth: m || c,
57
+ itemGap: s,
56
58
  buffer: l
57
59
  }), n);
58
60
  }
@@ -6,17 +6,18 @@ import { ContractContentImage as i, ContractSubscript as a, ContractSuperscript
6
6
  import { WordPaste as c } from "./word-paste.mjs";
7
7
  import { SigningMark as l } from "./signing-mark.mjs";
8
8
  import { buildSigningLayoutContent as u, buildSigningLayoutPresetContent as d, isSigningLayoutAttributeValue as f, isSigningLayoutPresetKey as p } from "../utils/signing-layout-presets.mjs";
9
- import m from "@tiptap/starter-kit";
10
- import h from "@tiptap/extension-text-align";
11
- import { BackgroundColor as g, FontFamily as _, TextStyle as v } from "@tiptap/extension-text-style";
12
- import y from "@tiptap/extension-color";
13
- import b from "@tiptap/extension-placeholder";
14
- import { Table as x, TableView as S } from "@tiptap/extension-table";
15
- import C from "@tiptap/extension-table-row";
16
- import w from "@tiptap/extension-table-header";
17
- import T from "@tiptap/extension-table-cell";
9
+ import { ContractParagraphEnter as m } from "./paragraph-enter.mjs";
10
+ import h from "@tiptap/starter-kit";
11
+ import g from "@tiptap/extension-text-align";
12
+ import { BackgroundColor as _, FontFamily as v, TextStyle as y } from "@tiptap/extension-text-style";
13
+ import b from "@tiptap/extension-color";
14
+ import x from "@tiptap/extension-placeholder";
15
+ import { Table as S, TableView as C } from "@tiptap/extension-table";
16
+ import w from "@tiptap/extension-table-row";
17
+ import T from "@tiptap/extension-table-header";
18
+ import E from "@tiptap/extension-table-cell";
18
19
  //#region src/components/pro-contract-template-designer/src/extensions/editor-extensions.ts
19
- var E = ["heading", "paragraph"], D = ["textStyle"], O = [
20
+ var D = ["heading", "paragraph"], O = ["textStyle"], k = [
20
21
  1,
21
22
  2,
22
23
  3,
@@ -24,7 +25,7 @@ var E = ["heading", "paragraph"], D = ["textStyle"], O = [
24
25
  5,
25
26
  6
26
27
  ];
27
- function k(e) {
28
+ function A(e) {
28
29
  return e.extend({ addAttributes() {
29
30
  return {
30
31
  ...this.parent?.(),
@@ -36,7 +37,7 @@ function k(e) {
36
37
  };
37
38
  } });
38
39
  }
39
- var A = class extends S {
40
+ var j = class extends C {
40
41
  constructor(e, t, n, r = {}) {
41
42
  super(e, t, n, r), this.syncSigningLayoutAttribute(e);
42
43
  }
@@ -47,7 +48,7 @@ var A = class extends S {
47
48
  let t = f(e.attrs.signingLayout) ? e.attrs.signingLayout : "";
48
49
  t ? this.table.getAttribute("data-signing-layout") !== t && this.table.setAttribute("data-signing-layout", t) : this.table.hasAttribute("data-signing-layout") && this.table.removeAttribute("data-signing-layout");
49
50
  }
50
- }, j = x.extend({ addAttributes() {
51
+ }, M = S.extend({ addAttributes() {
51
52
  return {
52
53
  ...this.parent?.(),
53
54
  signingLayout: {
@@ -60,42 +61,43 @@ var A = class extends S {
60
61
  }
61
62
  };
62
63
  } });
63
- function M(e, t) {
64
+ function N(e, t) {
64
65
  return t ? u(t, p(e) ? e : void 0) : d(p(e) ? e : "dual-party");
65
66
  }
66
- function N(e = "请输入合同正文", t = {}) {
67
+ function P(e = "请输入合同正文", t = {}) {
67
68
  return [
68
- m.configure({ heading: { levels: O } }),
69
- h.configure({ types: E }),
70
- v,
71
- _.configure({ types: D }),
72
- y.configure({ types: D }),
69
+ h.configure({ heading: { levels: k } }),
73
70
  g.configure({ types: D }),
71
+ y,
72
+ v.configure({ types: O }),
73
+ b.configure({ types: O }),
74
+ _.configure({ types: O }),
74
75
  r,
75
76
  o,
76
77
  a,
77
78
  s,
78
- b.configure({ placeholder: e }),
79
- j.configure({
79
+ x.configure({ placeholder: e }),
80
+ M.configure({
80
81
  resizable: !0,
81
- View: A
82
+ View: j
82
83
  }),
83
- C,
84
- k(w),
85
- k(T),
84
+ w,
85
+ A(T),
86
+ A(E),
86
87
  i.configure({ getZoom: t.getZoom }),
87
88
  l.configure({ getZoom: t.getZoom }),
88
89
  n,
89
90
  c.configure({
90
91
  processImageFile: t.processImageFile,
91
92
  confirmExternalFontPaste: t.confirmExternalFontPaste
92
- })
93
+ }),
94
+ m
93
95
  ];
94
96
  }
95
- function P(e) {
97
+ function F(e) {
96
98
  return Number.isFinite(e) ? `${Math.max(10, Math.round(e))}px` : "14px";
97
99
  }
98
- function F(n, r) {
100
+ function I(n, r) {
99
101
  switch (r.type) {
100
102
  case "undo": return n.undo();
101
103
  case "redo": return n.redo();
@@ -119,13 +121,13 @@ function F(n, r) {
119
121
  case "unset-text-align": return n.unsetTextAlign();
120
122
  case "set-color": return r.value.trim() ? n.setColor(r.value) : n.unsetColor();
121
123
  case "unset-color": return n.unsetColor();
122
- case "set-font-size": return n.setFontSize(P(r.value));
124
+ case "set-font-size": return n.setFontSize(F(r.value));
123
125
  case "unset-font-size": return n.unsetFontSize();
124
126
  case "set-font-family": return r.value.trim() ? n.setFontFamily(r.value) : n.unsetFontFamily();
125
127
  case "unset-font-family": return n.unsetFontFamily();
126
128
  case "clear-text-format": return n.unsetBold().unsetItalic().unsetUnderline().unsetColor().unsetFontSize().unsetFontFamily();
127
129
  case "clear-block-format": return n.setParagraph().unsetTextAlign();
128
- case "apply-text-style-preset": return t(r.preset).reduce(F, n);
130
+ case "apply-text-style-preset": return t(r.preset).reduce(I, n);
129
131
  case "insert-horizontal-rule": return n.setHorizontalRule();
130
132
  case "insert-content-image": return r.position === void 0 ? n.insertContent({
131
133
  type: "image",
@@ -141,7 +143,7 @@ function F(n, r) {
141
143
  };
142
144
  return r.position === void 0 ? n.insertContent(t) : n.insertContentAt(r.position, t);
143
145
  }
144
- case "insert-signing-layout": return n.insertContent(M(r.preset, r.options));
146
+ case "insert-signing-layout": return n.insertContent(N(r.preset, r.options));
145
147
  case "insert-table": return n.insertTable({
146
148
  rows: Math.max(1, Math.round(r.options.rows)),
147
149
  cols: Math.max(1, Math.round(r.options.cols)),
@@ -162,8 +164,8 @@ function F(n, r) {
162
164
  case "delete-table": return n.deleteTable();
163
165
  }
164
166
  }
165
- function I(e, t, n = {}) {
166
- return e ? F(n.focus === !1 ? e.chain() : e.chain().focus(), t).run() : !1;
167
+ function L(e, t, n = {}) {
168
+ return e ? I(n.focus === !1 ? e.chain() : e.chain().focus(), t).run() : !1;
167
169
  }
168
170
  //#endregion
169
- export { N as createEditorExtensions, I as runContractTemplateEditorCommand };
171
+ export { P as createEditorExtensions, L as runContractTemplateEditorCommand };
@@ -0,0 +1,28 @@
1
+ import { Extension as e } from "@tiptap/core";
2
+ import { TextSelection as t } from "@tiptap/pm/state";
3
+ //#region src/components/pro-contract-template-designer/src/extensions/paragraph-enter.ts
4
+ var n = ["heading", "paragraph"], r = e.create({
5
+ name: "contractParagraphEnter",
6
+ addKeyboardShortcuts() {
7
+ return { Enter: () => {
8
+ let { selection: e } = this.editor.state, { $from: r, $to: i } = e;
9
+ return !(e instanceof t) || r.depth !== 1 || i.depth !== 1 || r.parent !== i.parent || !n.includes(r.parent.type.name) ? !1 : this.editor.chain().command(({ commands: e, tr: t }) => {
10
+ if (!e.splitBlock()) return !1;
11
+ let { $from: r } = t.selection;
12
+ if (r.depth === 1 && n.includes(r.parent.type.name)) {
13
+ let e = r.before(), n = t.doc.nodeAt(e);
14
+ if (n) {
15
+ let r = t.storedMarks;
16
+ t.setNodeMarkup(e, void 0, {
17
+ ...n.attrs,
18
+ textAlign: null
19
+ }), t.setStoredMarks(r);
20
+ }
21
+ }
22
+ return !0;
23
+ }).run();
24
+ } };
25
+ }
26
+ });
27
+ //#endregion
28
+ export { r as ContractParagraphEnter };
@@ -36,21 +36,21 @@ var T = new Set([
36
36
  "href",
37
37
  "src",
38
38
  "xlink:href"
39
- ]), E = /<[^>]+data-template-variable=["']true["'][^>]*>/gi;
40
- function D(e) {
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) {
41
41
  let t = {};
42
42
  return (Array.isArray(e?.variables) ? e.variables : []).forEach((e) => {
43
- e?.key && (t[e.key] = B(e));
43
+ e?.key && (t[e.key] = U(e));
44
44
  }), t;
45
45
  }
46
- function O(e, t) {
46
+ function ee(e, t) {
47
47
  return {
48
- ...D(e),
48
+ ...j(e),
49
49
  ...t ?? {}
50
50
  };
51
51
  }
52
- function k(e, t) {
53
- let n = j(e);
52
+ function M(e, t) {
53
+ let n = P(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) => {
@@ -59,58 +59,66 @@ function k(e, t) {
59
59
  id: e,
60
60
  variableKey: e,
61
61
  message: `提交值 ${e} 不属于模板变量`,
62
- code: "VARIABLE_UNKNOWN"
62
+ code: "VARIABLE_TYPE_INVALID"
63
63
  });
64
64
  }), r.forEach((e) => {
65
65
  if (!e?.key) return;
66
- let r = t[e.key];
67
- if (e.required && P(r)) {
66
+ let r = te(e, t[e.key]), i = e.label || e.key;
67
+ if (e.required && L(r)) {
68
68
  n.push({
69
69
  type: "variable",
70
70
  id: e.id,
71
71
  variableKey: e.key,
72
- message: `请填写${e.label || e.key}`,
72
+ message: `请填写${i}`,
73
73
  code: "VARIABLE_REQUIRED"
74
74
  });
75
75
  return;
76
76
  }
77
- P(r) || (e.type === "number" && (typeof r != "number" || !Number.isFinite(r)) && n.push({
77
+ if (L(r)) return;
78
+ let a = e.type ?? "text";
79
+ a === "number" && !ne(r, e.precision) && n.push({
78
80
  type: "variable",
79
81
  id: e.id,
80
82
  variableKey: e.key,
81
- message: `${e.label || e.key} 不是合法数字`,
83
+ message: `${i} 不是合法数字或超出精度`,
82
84
  code: "VARIABLE_TYPE_INVALID"
83
- }), e.type === "checkbox" && typeof r != "boolean" && n.push({
85
+ }), a === "checkbox" && !ie(r) && n.push({
84
86
  type: "variable",
85
87
  id: e.id,
86
88
  variableKey: e.key,
87
- message: `${e.label || e.key} 不是合法复选值`,
89
+ message: `${i} 不是合法勾选值`,
88
90
  code: "VARIABLE_TYPE_INVALID"
89
- }), e.type === "date" && !X(r) && n.push({
91
+ }), a === "date" && !re(r) && n.push({
90
92
  type: "variable",
91
93
  id: e.id,
92
94
  variableKey: e.key,
93
- message: `${e.label || e.key} 不是合法日期`,
95
+ message: `${i} 不是合法日期`,
94
96
  code: "VARIABLE_TYPE_INVALID"
95
- }), e.type === "image" && !S(String(r)) && n.push({
97
+ }), a === "image" && !ae(String(r).trim()) && n.push({
96
98
  type: "security",
97
99
  id: e.id,
98
100
  variableKey: e.key,
99
- message: `${e.label || e.key} 不是安全的图片地址`,
100
- code: "IMAGE_URL_UNSAFE"
101
- }), (e.type === "select" || e.type === "radio" || e.type === "user-selector" || e.type === "dept-selector" || e.type === "role-selector" || e.type === "org-selector") && r !== void 0 && ((Array.isArray(r) ? r.every(g) : g(r)) || n.push({
101
+ message: `${i} 必须使用安全的图片 data URL`,
102
+ code: "UNSAFE_IMAGE_URL"
103
+ }), a === "text" && ce(e, String(r)) && n.push({
104
+ type: "variable",
105
+ id: e.id,
106
+ variableKey: e.key,
107
+ message: `${i} 内容超出变量范围`,
108
+ code: "VARIABLE_OVERFLOW"
109
+ }), oe(a) && (se(r, a !== "radio" && !!e.multiple) || n.push({
102
110
  type: "variable",
103
111
  id: e.id,
104
112
  variableKey: e.key,
105
- message: `${e.label || e.key} 不是合法选择值`,
106
- code: "VARIABLE_SELECTION_INVALID"
107
- })));
113
+ message: `${i} 不是合法选择值`,
114
+ code: "VARIABLE_TYPE_INVALID"
115
+ }));
108
116
  }), n;
109
117
  }
110
- function A(e, t, n) {
111
- return n ? k(e, t) : j(e);
118
+ function N(e, t, n) {
119
+ return M(e, t);
112
120
  }
113
- function j(e) {
121
+ function P(e) {
114
122
  if (!e) return [{
115
123
  type: "page",
116
124
  id: "template",
@@ -128,10 +136,10 @@ function j(e) {
128
136
  id: "template-variables",
129
137
  message: "模板变量列表格式无效",
130
138
  code: "TEMPLATE_VARIABLES_INVALID"
131
- }), o(e.pageSize) || t.push({
139
+ }), $(e.pageSize) || t.push({
132
140
  type: "page",
133
141
  id: "template-page-size",
134
- message: "模板默认页面尺寸无效,已回退为安全默认尺寸",
142
+ message: `模板默认页面尺寸必须在 ${D} ~ ${O} CSS px 之间`,
135
143
  code: "TEMPLATE_PAGE_SIZE_INVALID"
136
144
  });
137
145
  let i = /* @__PURE__ */ new Map();
@@ -180,13 +188,13 @@ function j(e) {
180
188
  });
181
189
  return;
182
190
  }
183
- e.pageSize !== void 0 && !o(e.pageSize) && t.push({
191
+ e.pageSize !== void 0 && !$(e.pageSize) && t.push({
184
192
  type: "page",
185
193
  id: `${e.id}-page-size`,
186
194
  pageId: e.id,
187
- message: `${e.title || `第 ${n + 1} 页`}:页面尺寸无效,已回退为安全尺寸`,
195
+ message: `${e.title || `第 ${n + 1} 页`}:页面尺寸必须在 ${D} ~ ${O} CSS px 之间`,
188
196
  code: "PAGE_SIZE_INVALID"
189
- }), G(e.contentHtml).forEach((e) => a.add(e)), K(e.contentHtml).forEach((r, i) => {
197
+ }), J(e.contentHtml).forEach((e) => a.add(e)), Y(e.contentHtml).forEach((r, i) => {
190
198
  t.push({
191
199
  type: "security",
192
200
  id: `${e.id}-security-${i}`,
@@ -204,9 +212,9 @@ function j(e) {
204
212
  code: "VARIABLE_CONFIG_MISSING"
205
213
  });
206
214
  });
207
- let s = d(e.pageDecorations);
215
+ let o = d(e.pageDecorations);
208
216
  return i.forEach((e, n) => {
209
- !a.has(n) && !s.has(n) && t.push({
217
+ !a.has(n) && !o.has(n) && t.push({
210
218
  type: "variable",
211
219
  id: n,
212
220
  variableKey: n,
@@ -215,7 +223,7 @@ function j(e) {
215
223
  });
216
224
  }), t.push(...p(e.pageDecorations, r)), t;
217
225
  }
218
- function M(e, t, n = {}) {
226
+ function F(e, t, n = {}) {
219
227
  if (!e || !Array.isArray(e.pages)) return [];
220
228
  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;
221
229
  return e.pages.flatMap((o) => {
@@ -227,47 +235,47 @@ function M(e, t, n = {}) {
227
235
  format: s.format ?? "Custom",
228
236
  width: s.width,
229
237
  height: s.height,
230
- contentHtml: F(o.contentHtml, i, t, n),
238
+ contentHtml: R(o.contentHtml, i, t, n),
231
239
  ...e.pageDecorations ? { pageDecorations: f(e.pageDecorations) } : {},
232
240
  decorationVariables: r,
233
241
  decorationValues: t
234
242
  }];
235
243
  });
236
244
  }
237
- function N(e, t, n = {}) {
238
- return M(e, t, n).map((e, t, n) => {
245
+ function I(e, t, n = {}) {
246
+ return F(e, t, n).map((e, t, n) => {
239
247
  let i = u(e.pageDecorations, t + 1, n.length, e.decorationVariables, e.decorationValues);
240
248
  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>`;
241
249
  }).join("\n");
242
250
  }
243
- function P(e) {
251
+ function L(e) {
244
252
  return e == null || e === "" || Array.isArray(e) && e.length === 0;
245
253
  }
246
- function F(e, n, r, i) {
254
+ function R(e, n, r, i) {
247
255
  if (!e) return e;
248
- let o = W(e);
256
+ let o = q(e);
249
257
  if (t()) {
250
258
  let e = new DOMParser().parseFromString(o, "text/html");
251
259
  return e.querySelectorAll("[data-template-variable]").forEach((e) => {
252
- I(e, n, r, i);
260
+ z(e, n, r, i);
253
261
  }), e.body.innerHTML;
254
262
  }
255
263
  return s(o, (e, t) => {
256
264
  let o = a(t, "data-key");
257
- return o ? L(n.get(o), o, r[o], i) : e;
265
+ return o ? B(n.get(o), o, r[o], i) : e;
258
266
  });
259
267
  }
260
- function I(e, t, n, r) {
268
+ function z(e, t, n, r) {
261
269
  let i = e.dataset.key || "", a = t.get(i);
262
270
  if (!i || !a) return;
263
- let o = new DOMParser().parseFromString(L(a, i, n[i], r), "text/html").body.firstElementChild;
271
+ let o = new DOMParser().parseFromString(B(a, i, n[i], r), "text/html").body.firstElementChild;
264
272
  o && e.replaceWith(o);
265
273
  }
266
- function L(e, t, n, r) {
267
- return r.mode === "display" ? R(e, t, n, r) : z(e, t, n, r);
274
+ function B(e, t, n, r) {
275
+ return r.mode === "display" ? V(e, t, n, r) : H(e, t, n, r);
268
276
  }
269
- function R(e, t, n, a) {
270
- let o = e?.type ?? "text", s = n ?? B(e), l = o === "image" && !P(s) && !S(String(s)) ? "" : s, u = H(l), d = c({
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({
271
279
  type: o,
272
280
  width: e?.width,
273
281
  height: e?.height,
@@ -288,7 +296,7 @@ function R(e, t, n, a) {
288
296
  "gd-contract-template-renderer__preview-control",
289
297
  ...d.classes,
290
298
  a.activeKey === t ? "is-active" : "",
291
- P(l) ? "is-empty" : ""
299
+ L(l) ? "is-empty" : ""
292
300
  ].filter(Boolean).join(" "))}"`,
293
301
  `style="${r(d.styleText)}"`,
294
302
  "data-contract-render-wrapper=\"true\"",
@@ -299,10 +307,10 @@ function R(e, t, n, a) {
299
307
  a.disabled ? "" : "role=\"button\"",
300
308
  a.disabled ? "" : "tabindex=\"0\""
301
309
  ].filter(Boolean).join(" ");
302
- return o === "checkbox" ? `<span ${p}><span class="gd-contract-template-renderer__checkbox-mark" aria-hidden="true">${U(l) ? "✓" : ""}</span>${i(f)}</span>` : o === "image" && !P(l) ? `<span ${p}></span>` : `<span ${p}>${i(f)}</span>`;
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>`;
303
311
  }
304
- function z(e, t, n, a) {
305
- let o = e?.type ?? "text", s = !!a.readonly, l = V(n ?? B(e)), u = c({
312
+ function H(e, t, n, a) {
313
+ let o = e?.type ?? "text", s = !!a.readonly, l = W(n ?? U(e)), u = c({
306
314
  type: o,
307
315
  width: e?.width,
308
316
  height: e?.height,
@@ -325,49 +333,49 @@ function z(e, t, n, a) {
325
333
  d ? "disabled" : "",
326
334
  s ? "readonly" : ""
327
335
  ].filter(Boolean).join(" "), p = `style="${r(u.styleText)}"`, m = r(["gd-contract-template-renderer__control", ...u.classes].join(" "));
328
- return o === "checkbox" ? `<label class="${m}" ${p} data-contract-render-wrapper="true" data-key="${r(t)}"><input type="checkbox" ${f} ${U(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 || "")}">`;
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 || "")}">`;
329
337
  }
330
- function B(e) {
338
+ function U(e) {
331
339
  if (!e) return "";
332
- if (e.type === "checkbox") return U(e.defaultValue);
340
+ if (e.type === "checkbox") return K(e.defaultValue);
333
341
  if (e.type === "number" && e.defaultValue !== void 0) {
334
342
  let t = Number(e.defaultValue);
335
343
  return Number.isFinite(t) ? t : e.defaultValue;
336
344
  }
337
345
  if (!(e.type === "select" || e.type === "radio" || e.type?.endsWith("-selector"))) return e.defaultValue ?? "";
338
346
  }
339
- function V(e) {
347
+ function W(e) {
340
348
  return typeof e == "boolean" ? e ? "true" : "" : e == null ? "" : h(e);
341
349
  }
342
- function H(e) {
350
+ function G(e) {
343
351
  return typeof e == "boolean" ? e ? "true" : "false" : e == null ? "" : h(e);
344
352
  }
345
- function U(e) {
353
+ function K(e) {
346
354
  return e === !0 || e === "true" || e === "1" || e === "yes" || e === "是" || e === "已选";
347
355
  }
348
- function W(t) {
356
+ function q(t) {
349
357
  if (e()) {
350
358
  let e = new DOMParser().parseFromString(t, "text/html");
351
359
  return e.querySelectorAll("script,style,meta,link,iframe,object,embed").forEach((e) => e.remove()), e.querySelectorAll("*").forEach((e) => {
352
360
  Array.from(e.attributes).forEach((t) => {
353
361
  let n = t.name.toLowerCase();
354
- (n.startsWith("on") || n === "srcdoc" || T.has(n) && q(t.value) || n === "style" && Y(t.value)) && e.removeAttribute(t.name);
362
+ (n.startsWith("on") || n === "srcdoc" || T.has(n) && X(t.value) || n === "style" && Q(t.value)) && e.removeAttribute(t.name);
355
363
  });
356
364
  }), e.body.innerHTML;
357
365
  }
358
366
  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) => {
359
367
  let a = r ?? i ?? "";
360
- return q(a) ? "" : n ? ` ${t}=${n}${a}${n}` : ` ${t}=${a}`;
361
- }).replace(/\s+style\s*=\s*(["'])(.*?)\1/gi, (e, t, n) => Y(n) ? "" : ` style=${t}${n}${t}`);
368
+ return X(a) ? "" : n ? ` ${t}=${n}${a}${n}` : ` ${t}=${a}`;
369
+ }).replace(/\s+style\s*=\s*(["'])(.*?)\1/gi, (e, t, n) => Q(n) ? "" : ` style=${t}${n}${t}`);
362
370
  }
363
- function G(e) {
371
+ function J(e) {
364
372
  return n(e, E, (e) => a(e, "data-key"));
365
373
  }
366
- function K(e) {
374
+ function Y(e) {
367
375
  let t = [];
368
- 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("正文包含已移除的事件或嵌入属性"), (J(e) || /style\s*=\s*["'][^"']*(?:expression\s*\(|url\s*\(\s*["']?\s*(?:javascript|vbscript|data:text\/html))/i.test(e)) && t.push("正文包含已移除的危险 URL 或样式"), 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;
369
377
  }
370
- function q(e) {
378
+ function X(e) {
371
379
  let t = e.replace(/&#(?:x([\da-f]+)|(\d+));?/gi, (e, t, n) => {
372
380
  let r = Number.parseInt(t ?? n ?? "", t ? 16 : 10);
373
381
  try {
@@ -382,22 +390,74 @@ function q(e) {
382
390
  })[t.toLowerCase()] ?? "").trim().replace(/[\u0000-\u0020\u007F]+/g, "");
383
391
  return /^(?:javascript|vbscript|data:text\/html)/i.test(t);
384
392
  }
385
- function J(e) {
393
+ function Z(e) {
386
394
  let t = /\s+(?:action|formaction|href|src|xlink:href)\s*=\s*(?:(["'])(.*?)\1|([^\s>]+))/gi, n = t.exec(e);
387
395
  for (; n;) {
388
- if (q(n[2] ?? n[3] ?? "")) return !0;
396
+ if (X(n[2] ?? n[3] ?? "")) return !0;
389
397
  n = t.exec(e);
390
398
  }
391
399
  return !1;
392
400
  }
393
- function Y(e) {
401
+ function Q(e) {
394
402
  return /expression\s*\(|url\s*\(\s*["']?\s*(?:javascript|vbscript|data:text\/html)/i.test(e);
395
403
  }
396
- function X(e) {
397
- let t = /^(\d{4})-(\d{2})-(\d{2})$/.exec(String(e));
398
- if (!t) return !1;
399
- let n = /* @__PURE__ */ new Date(`${t[1]}-${t[2]}-${t[3]}T00:00:00Z`);
400
- return !Number.isNaN(n.getTime()) && n.getUTCFullYear() === Number(t[1]) && n.getUTCMonth() + 1 === Number(t[2]) && n.getUTCDate() === Number(t[3]);
404
+ function te(e, t) {
405
+ return L(t) && !L(e.defaultValue) ? e.defaultValue : t;
406
+ }
407
+ function ne(e, t) {
408
+ if (typeof e == "boolean" || typeof e != "number" && typeof e != "string") return !1;
409
+ let n = String(e).trim();
410
+ if (!/^-?(?:\d+)(?:\.\d+)?$/.test(n)) return !1;
411
+ let r = Number(n);
412
+ if (!Number.isFinite(r)) return !1;
413
+ if (t !== void 0) {
414
+ let e = n.split(".")[1]?.length ?? 0;
415
+ if (!Number.isInteger(t) || t < 0 || t > k || e > t) return !1;
416
+ }
417
+ return !0;
418
+ }
419
+ function re(e) {
420
+ if (typeof e != "string" && typeof e != "number") return !1;
421
+ let t = String(e).trim(), n = /^(\d{4})[-/年](\d{1,2})[-/月](\d{1,2})(?:日)?(?:[T\s].*)?$/.exec(t);
422
+ if (!n) return !1;
423
+ let r = Number(n[1]), i = Number(n[2]), a = Number(n[3]), o = new Date(Date.UTC(r, i - 1, a));
424
+ return o.getUTCFullYear() === r && o.getUTCMonth() === i - 1 && o.getUTCDate() === a;
425
+ }
426
+ function ie(e) {
427
+ return typeof e == "boolean" ? !0 : [
428
+ "1",
429
+ "true",
430
+ "yes",
431
+ "checked",
432
+ "是",
433
+ "已选",
434
+ "0",
435
+ "false",
436
+ "no",
437
+ "unchecked",
438
+ "否",
439
+ "未选"
440
+ ].includes(String(e).trim().toLowerCase());
441
+ }
442
+ function ae(e) {
443
+ return A.test(e);
444
+ }
445
+ function oe(e) {
446
+ return e === "select" || e === "radio" || e === "user-selector" || e === "dept-selector" || e === "role-selector" || e === "org-selector";
447
+ }
448
+ function se(e, t) {
449
+ return t ? Array.isArray(e) && e.every(g) : g(e);
450
+ }
451
+ function ce(e, t) {
452
+ let n = e.width;
453
+ if (!Number.isFinite(n) || n <= 0) return !1;
454
+ 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);
455
+ return e.multiline ? t.split(/\r?\n/).reduce((e, t) => e + Math.max(1, Math.ceil(a(t) / i)), 0) > (e.rows ?? 3) : a(t) > i;
456
+ }
457
+ function $(e) {
458
+ if (!e || typeof e != "object") return !1;
459
+ 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;
401
461
  }
402
462
  //#endregion
403
- export { D as buildInitialRenderValues, N as buildTemplateRenderHtml, M as buildTemplateRenderPages, C as buildTemplateVariableData, P as isEmptyRenderValue, O as normalizeRenderValues, A as resolveTemplateRenderSubmitErrors, W as sanitizeContractRendererHtml, j as validateTemplateRenderStructure, k as validateTemplateRenderValues };
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 };
@@ -9,15 +9,16 @@ var e = [
9
9
  "signing",
10
10
  "insert"
11
11
  ];
12
- function t(t) {
13
- let n = t.buffer ?? 0, r = e.reduce((e, n) => e + (t.groupWidths[n] ?? 0), 0);
14
- if (t.fixedWidth + r + n <= t.availableWidth) return [];
15
- let i = [], a = t.fixedWidth + r + t.moreWidth;
16
- for (let n of e) {
17
- if (a <= t.availableWidth) break;
18
- i.push(n), a -= t.groupWidths[n] ?? 0;
19
- }
12
+ function t(t, n, r) {
13
+ let i = new Set(n), a = e.filter((e) => !i.has(e)), o = t.fixedItemCount + a.length + +!!r, s = a.reduce((e, n) => e + (t.groupWidths[n] ?? 0), 0), c = Math.max(0, o - 1) * (t.itemGap ?? 0);
14
+ return t.fixedWidth + s + (r ? t.moreWidth : 0) + c;
15
+ }
16
+ function n(n) {
17
+ let r = n.buffer ?? 0;
18
+ if (t(n, [], !1) + r <= n.availableWidth) return [];
19
+ let i = [];
20
+ for (let a of e) if (i.push(a), t(n, i, !0) + r <= n.availableWidth) break;
20
21
  return i;
21
22
  }
22
23
  //#endregion
23
- export { e as CONTRACT_TEMPLATE_TOOLBAR_OVERFLOW_PRIORITY, t as resolveContractTemplateToolbarOverflowKeys };
24
+ export { e as CONTRACT_TEMPLATE_TOOLBAR_OVERFLOW_PRIORITY, n as resolveContractTemplateToolbarOverflowKeys };