@guodun/antdv 1.3.2 → 1.4.0

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 (109) hide show
  1. package/dist/es/components/contract-signing-location/index.mjs +1 -0
  2. package/dist/es/components/contract-signing-location/src/ContractSigningLocation.vue.mjs +304 -289
  3. package/dist/es/components/contract-signing-location/src/ContractSigningLocationCanvas.vue.mjs +337 -326
  4. package/dist/es/components/contract-signing-location/src/ContractSigningLocationNavigator.vue.mjs +41 -33
  5. package/dist/es/components/contract-signing-location/src/ContractSigningTemplatePage.mjs +5 -0
  6. package/dist/es/components/contract-signing-location/src/ContractSigningTemplatePage.vue.mjs +23 -0
  7. package/dist/es/components/contract-signing-location/src/location-rules.mjs +115 -77
  8. package/dist/es/components/contract-signing-location/src/template-source.mjs +85 -0
  9. package/dist/es/components/contract-signing-location/style/index.css +1 -1
  10. package/dist/es/components/index.mjs +8 -6
  11. package/dist/es/components/pro-contract-signing-flow/src/ContractSigningFlowCanvas.vue.mjs +164 -57
  12. package/dist/es/components/pro-contract-signing-flow/src/ContractSigningFlowInspector.vue.mjs +128 -125
  13. package/dist/es/components/pro-contract-signing-flow/src/ContractSigningFlowNodeCard.vue.mjs +75 -49
  14. package/dist/es/components/pro-contract-signing-flow/src/ProContractSigningFlow.vue.mjs +135 -91
  15. package/dist/es/components/pro-contract-signing-flow/src/constants.mjs +25 -5
  16. package/dist/es/components/pro-contract-signing-flow/style/index.css +1 -1
  17. package/dist/es/components/pro-contract-template-designer/index.mjs +5 -4
  18. package/dist/es/components/pro-contract-template-designer/src/ContractTemplateDesignerInspector.mjs +5 -0
  19. package/dist/es/components/pro-contract-template-designer/src/ContractTemplateDesignerInspector.vue.mjs +347 -0
  20. package/dist/es/components/pro-contract-template-designer/src/ContractTemplateDesignerSidebar.mjs +5 -0
  21. package/dist/es/components/pro-contract-template-designer/src/ContractTemplateDesignerSidebar.vue.mjs +171 -0
  22. package/dist/es/components/pro-contract-template-designer/src/ContractTemplateFileBar.mjs +5 -0
  23. package/dist/es/components/pro-contract-template-designer/src/ContractTemplateFileBar.vue.mjs +166 -0
  24. package/dist/es/components/pro-contract-template-designer/src/ContractTemplateRendererField.vue.mjs +4 -4
  25. package/dist/es/components/pro-contract-template-designer/src/ContractTemplateRendererValidation.mjs +5 -0
  26. package/dist/es/components/pro-contract-template-designer/src/ContractTemplateRendererValidation.vue.mjs +36 -0
  27. package/dist/es/components/pro-contract-template-designer/src/DesignerPage.vue.mjs +202 -202
  28. package/dist/es/components/pro-contract-template-designer/src/ProContractTemplateDesigner.vue.mjs +1591 -1612
  29. package/dist/es/components/pro-contract-template-designer/src/ProContractTemplateRenderer.vue.mjs +235 -239
  30. package/dist/es/components/pro-contract-template-designer/src/SigningPlacementLayer.vue.mjs +16 -16
  31. package/dist/es/components/pro-contract-template-designer/src/composables/use-template-designer.mjs +166 -166
  32. package/dist/es/components/pro-contract-template-designer/src/composables/use-template-draft-cache.mjs +100 -33
  33. package/dist/es/components/pro-contract-template-designer/src/composables/use-template-files.mjs +77 -0
  34. package/dist/es/components/pro-contract-template-designer/src/extensions/word-paste.mjs +23 -23
  35. package/dist/es/components/pro-contract-template-designer/src/utils/file-tabs.mjs +14 -0
  36. package/dist/es/components/pro-contract-template-designer/src/utils/template-renderer.mjs +121 -121
  37. package/dist/es/components/pro-contract-template-designer/src/utils/toolbar-overflow.mjs +19 -0
  38. package/dist/es/components/pro-contract-template-designer/style/index.css +1 -1
  39. package/dist/es/index.mjs +23 -21
  40. package/dist/lib/components/contract-signing-location/index.cjs +1 -1
  41. package/dist/lib/components/contract-signing-location/src/ContractSigningLocation.vue.cjs +1 -1
  42. package/dist/lib/components/contract-signing-location/src/ContractSigningLocationCanvas.vue.cjs +1 -1
  43. package/dist/lib/components/contract-signing-location/src/ContractSigningLocationNavigator.vue.cjs +1 -1
  44. package/dist/lib/components/contract-signing-location/src/ContractSigningTemplatePage.cjs +1 -0
  45. package/dist/lib/components/contract-signing-location/src/ContractSigningTemplatePage.vue.cjs +1 -0
  46. package/dist/lib/components/contract-signing-location/src/location-rules.cjs +1 -1
  47. package/dist/lib/components/contract-signing-location/src/template-source.cjs +1 -0
  48. package/dist/lib/components/contract-signing-location/style/index.css +1 -1
  49. package/dist/lib/components/index.cjs +1 -1
  50. package/dist/lib/components/pro-contract-signing-flow/src/ContractSigningFlowCanvas.vue.cjs +1 -1
  51. package/dist/lib/components/pro-contract-signing-flow/src/ContractSigningFlowInspector.vue.cjs +1 -1
  52. package/dist/lib/components/pro-contract-signing-flow/src/ContractSigningFlowNodeCard.vue.cjs +1 -1
  53. package/dist/lib/components/pro-contract-signing-flow/src/ProContractSigningFlow.vue.cjs +1 -1
  54. package/dist/lib/components/pro-contract-signing-flow/src/constants.cjs +1 -1
  55. package/dist/lib/components/pro-contract-signing-flow/style/index.css +1 -1
  56. package/dist/lib/components/pro-contract-template-designer/index.cjs +1 -1
  57. package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateDesignerInspector.cjs +1 -0
  58. package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateDesignerInspector.vue.cjs +1 -0
  59. package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateDesignerSidebar.cjs +1 -0
  60. package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateDesignerSidebar.vue.cjs +1 -0
  61. package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateFileBar.cjs +1 -0
  62. package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateFileBar.vue.cjs +1 -0
  63. package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateRendererField.vue.cjs +1 -1
  64. package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateRendererValidation.cjs +1 -0
  65. package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateRendererValidation.vue.cjs +1 -0
  66. package/dist/lib/components/pro-contract-template-designer/src/DesignerPage.vue.cjs +2 -2
  67. package/dist/lib/components/pro-contract-template-designer/src/ProContractTemplateDesigner.vue.cjs +1 -1
  68. package/dist/lib/components/pro-contract-template-designer/src/ProContractTemplateRenderer.vue.cjs +1 -1
  69. package/dist/lib/components/pro-contract-template-designer/src/SigningPlacementLayer.vue.cjs +1 -1
  70. package/dist/lib/components/pro-contract-template-designer/src/composables/use-template-designer.cjs +2 -2
  71. package/dist/lib/components/pro-contract-template-designer/src/composables/use-template-draft-cache.cjs +1 -1
  72. package/dist/lib/components/pro-contract-template-designer/src/composables/use-template-files.cjs +2 -0
  73. package/dist/lib/components/pro-contract-template-designer/src/extensions/word-paste.cjs +1 -1
  74. package/dist/lib/components/pro-contract-template-designer/src/utils/file-tabs.cjs +1 -0
  75. package/dist/lib/components/pro-contract-template-designer/src/utils/template-renderer.cjs +2 -2
  76. package/dist/lib/components/pro-contract-template-designer/src/utils/toolbar-overflow.cjs +1 -0
  77. package/dist/lib/components/pro-contract-template-designer/style/index.css +1 -1
  78. package/dist/lib/index.cjs +1 -1
  79. package/dist/theme/contract-signing-location.css +1 -1
  80. package/dist/theme/icon.css +1 -1
  81. package/dist/theme/index.css +1 -1
  82. package/dist/theme/pro-contract-signing-flow.css +1 -1
  83. package/dist/types/components/contract-signing-location/index.d.ts +1 -0
  84. package/dist/types/components/contract-signing-location/src/ContractSigningLocation.vue.d.ts +3 -1
  85. package/dist/types/components/contract-signing-location/src/ContractSigningLocationInspector.vue.d.ts +2 -2
  86. package/dist/types/components/contract-signing-location/src/ContractSigningTemplatePage.vue.d.ts +6 -0
  87. package/dist/types/components/contract-signing-location/src/location-rules.d.ts +3 -3
  88. package/dist/types/components/contract-signing-location/src/template-source.d.ts +20 -0
  89. package/dist/types/components/contract-signing-location/src/types.d.ts +47 -2
  90. package/dist/types/components/pro-contract-signing-flow/src/ContractSigningFlowCanvas.vue.d.ts +19 -3
  91. package/dist/types/components/pro-contract-signing-flow/src/ProContractSigningFlow.vue.d.ts +223 -2
  92. package/dist/types/components/pro-contract-signing-flow/src/constants.d.ts +15 -0
  93. package/dist/types/components/pro-contract-signing-flow/src/types.d.ts +12 -0
  94. package/dist/types/components/pro-contract-template-designer/index.d.ts +1 -0
  95. package/dist/types/components/pro-contract-template-designer/src/ContractTemplateDesignerInspector.vue.d.ts +103 -0
  96. package/dist/types/components/pro-contract-template-designer/src/ContractTemplateDesignerSidebar.vue.d.ts +48 -0
  97. package/dist/types/components/pro-contract-template-designer/src/ContractTemplateFileBar.vue.d.ts +231 -0
  98. package/dist/types/components/pro-contract-template-designer/src/ContractTemplateRendererValidation.vue.d.ts +15 -0
  99. package/dist/types/components/pro-contract-template-designer/src/DesignerPage.vue.d.ts +1 -1
  100. package/dist/types/components/pro-contract-template-designer/src/ProContractTemplateDesigner.vue.d.ts +25 -2
  101. package/dist/types/components/pro-contract-template-designer/src/SigningPlacementInspector.vue.d.ts +2 -2
  102. package/dist/types/components/pro-contract-template-designer/src/composables/use-template-designer.d.ts +1 -1
  103. package/dist/types/components/pro-contract-template-designer/src/composables/use-template-draft-cache.d.ts +29 -1
  104. package/dist/types/components/pro-contract-template-designer/src/composables/use-template-files.d.ts +24 -0
  105. package/dist/types/components/pro-contract-template-designer/src/constants.d.ts +2 -2
  106. package/dist/types/components/pro-contract-template-designer/src/types.d.ts +59 -1
  107. package/dist/types/components/pro-contract-template-designer/src/utils/file-tabs.d.ts +3 -0
  108. package/dist/types/components/pro-contract-template-designer/src/utils/toolbar-overflow.d.ts +11 -0
  109. package/package.json +2 -1
@@ -1,21 +1,22 @@
1
- import { getContractSigningHomePage as e } from "./location-rules.mjs";
2
- import { Fragment as t, computed as n, createBlock as r, createElementBlock as i, createElementVNode as a, createVNode as o, defineComponent as s, normalizeClass as c, openBlock as l, renderList as u, toDisplayString as d, unref as f } from "vue";
3
- import { FilePdfOutlined as p, LoadingOutlined as m } from "@ant-design/icons-vue";
1
+ import { isContractSigningTemplateFile as e } from "./template-source.mjs";
2
+ import { getContractSigningHomePage as t } from "./location-rules.mjs";
3
+ import { Fragment as n, computed as r, createBlock as i, createElementBlock as a, createElementVNode as o, createVNode as s, defineComponent as c, normalizeClass as l, openBlock as u, renderList as d, toDisplayString as f, unref as p } from "vue";
4
+ import { FilePdfOutlined as m, FileTextOutlined as h, LoadingOutlined as g } from "@ant-design/icons-vue";
4
5
  //#region src/components/contract-signing-location/src/ContractSigningLocationNavigator.vue?vue&type=script&setup=true&lang.ts
5
- var h = {
6
+ var _ = {
6
7
  class: "gd-ant-contract-signing-location__navigator",
7
8
  "aria-label": "合同文件"
8
- }, g = { class: "gd-ant-contract-signing-location__panel-head" }, _ = {
9
+ }, v = { class: "gd-ant-contract-signing-location__panel-head" }, y = {
9
10
  key: 0,
10
11
  class: "gd-ant-contract-signing-location__file-list"
11
- }, v = [
12
+ }, b = [
12
13
  "aria-pressed",
13
14
  "title",
14
15
  "onClick"
15
- ], y = { class: "gd-ant-contract-signing-location__thumbnail-preview" }, b = ["src"], x = { key: 2 }, S = { key: 3 }, C = { class: "gd-ant-contract-signing-location__file-title" }, w = {
16
+ ], x = { class: "gd-ant-contract-signing-location__thumbnail-preview" }, S = ["src"], C = { key: 2 }, w = { key: 3 }, T = { class: "gd-ant-contract-signing-location__file-title" }, E = {
16
17
  key: 1,
17
18
  class: "gd-ant-contract-signing-location__panel-empty"
18
- }, T = /* @__PURE__ */ s({
19
+ }, D = /* @__PURE__ */ c({
19
20
  name: "ContractSigningLocationNavigator",
20
21
  __name: "ContractSigningLocationNavigator",
21
22
  props: {
@@ -25,46 +26,53 @@ var h = {
25
26
  errorPreviewKeys: {}
26
27
  },
27
28
  emits: ["select"],
28
- setup(s, { emit: T }) {
29
- let E = s, D = T, O = n(() => E.files.map((t) => {
30
- let n = e(t.pages), r = n ? `${t.fileId}:${n.pageIndex}` : "";
29
+ setup(c, { emit: D }) {
30
+ let O = c, k = D, A = r(() => O.files.map((n) => {
31
+ let r = t(n.pages), i = r ? `${n.fileId}:${r.pageIndex}` : "";
31
32
  return {
32
- file: t,
33
- home: n,
34
- key: r,
35
- previewUrl: n?.thumbnailUrl || n?.previewUrl,
36
- loading: !!(r && E.loadingPreviewKeys.includes(r)),
37
- error: !!(r && E.errorPreviewKeys.includes(r))
33
+ file: n,
34
+ home: r,
35
+ key: i,
36
+ previewUrl: r?.thumbnailUrl || r?.previewUrl,
37
+ loading: !!(i && O.loadingPreviewKeys.includes(i)),
38
+ error: !!(i && O.errorPreviewKeys.includes(i)),
39
+ template: e(n)
38
40
  };
39
41
  }));
40
- return (e, n) => (l(), i("aside", h, [a("header", g, [a("div", null, [n[0] ||= a("strong", null, "合同文件", -1), a("span", null, d(s.files.length) + " 个文件", 1)])]), O.value.length ? (l(), i("div", _, [(l(!0), i(t, null, u(O.value, (e) => (l(), i("button", {
42
+ return (e, t) => (u(), a("aside", _, [o("header", v, [o("div", null, [t[0] ||= o("strong", null, "合同文件", -1), o("span", null, f(c.files.length) + " 个文件", 1)])]), A.value.length ? (u(), a("div", y, [(u(!0), a(n, null, d(A.value, (e) => (u(), a("button", {
41
43
  key: e.file.fileId,
42
44
  type: "button",
43
- class: c(["gd-ant-contract-signing-location__thumbnail", {
44
- "is-active": s.activeFileId === e.file.fileId,
45
+ class: l(["gd-ant-contract-signing-location__thumbnail", {
46
+ "is-active": c.activeFileId === e.file.fileId,
45
47
  "is-error": e.error
46
48
  }]),
47
- "aria-pressed": s.activeFileId === e.file.fileId,
49
+ "aria-pressed": c.activeFileId === e.file.fileId,
48
50
  title: e.file.fileName,
49
- onClick: (t) => D("select", e.file.fileId)
50
- }, [a("span", y, [e.previewUrl ? (l(), i("img", {
51
+ onClick: (t) => k("select", e.file.fileId)
52
+ }, [o("span", x, [e.previewUrl ? (u(), a("img", {
51
53
  key: 0,
52
54
  src: e.previewUrl,
53
55
  alt: ""
54
- }, null, 8, b)) : e.loading ? (l(), r(f(m), {
56
+ }, null, 8, S)) : e.loading ? (u(), i(p(g), {
55
57
  key: 1,
56
58
  spin: "",
57
59
  "aria-label": "缩略图加载中"
58
- })) : e.error ? (l(), i("span", x, "重试")) : (l(), i("span", S, "PDF"))]), a("span", C, [
59
- o(f(p), { "aria-hidden": "true" }),
60
- a("span", null, d(e.file.fileName), 1),
61
- a("small", null, d(e.file.pages.length) + " 页", 1)
62
- ])], 10, v))), 128))])) : (l(), i("div", w, [
63
- o(f(p), { "aria-hidden": "true" }),
64
- n[1] ||= a("strong", null, "暂无合同文件", -1),
65
- n[2] ||= a("span", null, "请由宿主传入文件,或配置 dataProvider 自动加载。", -1)
60
+ })) : e.error ? (u(), a("span", C, "重试")) : (u(), a("span", w, f(e.template ? "HTML" : "PDF"), 1))]), o("span", T, [
61
+ e.template ? (u(), i(p(h), {
62
+ key: 0,
63
+ "aria-hidden": "true"
64
+ })) : (u(), i(p(m), {
65
+ key: 1,
66
+ "aria-hidden": "true"
67
+ })),
68
+ o("span", null, f(e.file.fileName), 1),
69
+ o("small", null, f(e.file.pages.length) + " 页", 1)
70
+ ])], 10, b))), 128))])) : (u(), a("div", E, [
71
+ s(p(m), { "aria-hidden": "true" }),
72
+ t[1] ||= o("strong", null, "暂无合同文件", -1),
73
+ t[2] ||= o("span", null, "请由宿主传入文件,或配置 dataProvider 自动加载。", -1)
66
74
  ]))]));
67
75
  }
68
76
  });
69
77
  //#endregion
70
- export { T as default };
78
+ export { D as default };
@@ -0,0 +1,5 @@
1
+ import e from "./ContractSigningTemplatePage.vue.mjs";
2
+ //#region src/components/contract-signing-location/src/ContractSigningTemplatePage.vue
3
+ var t = e;
4
+ //#endregion
5
+ export { t as default };
@@ -0,0 +1,23 @@
1
+ import { createCommentVNode as e, createElementBlock as t, createElementVNode as n, defineComponent as r, openBlock as i, toDisplayString as a } from "vue";
2
+ //#region src/components/contract-signing-location/src/ContractSigningTemplatePage.vue?vue&type=script&setup=true&lang.ts
3
+ var o = ["data-template-page-id", "data-template-page-index"], s = ["innerHTML"], c = {
4
+ key: 0,
5
+ class: "gd-ant-contract-signing-location__template-warning",
6
+ role: "alert"
7
+ }, l = /* @__PURE__ */ r({
8
+ name: "ContractSigningTemplatePage",
9
+ __name: "ContractSigningTemplatePage",
10
+ props: { page: {} },
11
+ setup(r) {
12
+ return (l, u) => (i(), t("div", {
13
+ class: "gd-ant-contract-signing-location__template-page gd-contract-template-page",
14
+ "data-template-page-id": r.page.pageId,
15
+ "data-template-page-index": r.page.pageIndex
16
+ }, [n("div", {
17
+ class: "gd-ant-contract-signing-location__template-page-content",
18
+ innerHTML: r.page.contentHtml
19
+ }, null, 8, s), r.page.errors.length ? (i(), t("div", c, [u[0] ||= n("strong", null, "模板已安全降级展示", -1), n("span", null, a(r.page.errors[0]), 1)])) : e("", !0)], 8, o));
20
+ }
21
+ });
22
+ //#endregion
23
+ export { l as default };
@@ -1,21 +1,22 @@
1
1
  import { CONTRACT_SIGNING_PLACEMENT_LABELS as e, resolveContractSigningSealSizeInPixels as t } from "./constants.mjs";
2
2
  import { clampContractSigningPlacement as n, getContractSigningPlacementSize as r, getContractSigningRuleGeometry as i, normalizeContractSigningCoordinateDimension as a, normalizeContractSigningCoordinateScale as o } from "./coordinates.mjs";
3
+ import { buildContractSigningTemplateRenderPages as s, isContractSigningTemplateFile as c, validateContractSigningTemplateFile as l } from "./template-source.mjs";
3
4
  //#region src/components/contract-signing-location/src/location-rules.ts
4
- var s = 0;
5
- function c(e = "") {
5
+ var u = 0;
6
+ function d(e = "") {
6
7
  return {
7
8
  contractId: e,
8
9
  files: [],
9
10
  placements: []
10
11
  };
11
12
  }
12
- function l(e, t) {
13
- let r = S(e?.files), i = E(r);
13
+ function f(e, t) {
14
+ let r = T(e?.files), i = M(r);
14
15
  return {
15
16
  contractId: String(e?.contractId ?? "").trim(),
16
17
  files: r,
17
- placements: Array.isArray(e?.placements) ? e.placements.map(w).map((e) => {
18
- let r = i.get(D(e.fileId, e.pageIndex));
18
+ placements: Array.isArray(e?.placements) ? e.placements.map(A).map((e) => {
19
+ let r = i.get(N(e.fileId, e.pageIndex));
19
20
  return r ? n(e, r, {
20
21
  sealSizeLimit: t?.sealSizeLimit,
21
22
  sealTypes: e.sealType,
@@ -24,12 +25,17 @@ function l(e, t) {
24
25
  }) : []
25
26
  };
26
27
  }
27
- function u(e) {
28
+ function p(e) {
28
29
  return {
29
30
  contractId: e.contractId,
30
31
  files: e.files.map((e) => ({
31
32
  ...e,
32
- pages: e.pages.map((e) => ({ ...e }))
33
+ pages: e.pages.map((e) => ({ ...e })),
34
+ ...e.source?.type === "template" ? { source: {
35
+ type: "template",
36
+ template: k(e.source.template),
37
+ ...e.source.values ? { values: { ...e.source.values } } : {}
38
+ } } : e.source ? { source: { type: "preview" } } : {}
33
39
  })),
34
40
  placements: e.placements.map((e) => ({
35
41
  ...e,
@@ -37,36 +43,36 @@ function u(e) {
37
43
  }))
38
44
  };
39
45
  }
40
- function d(e, t = 1) {
41
- let n = o(t);
42
- if (n === 1) return e;
43
- let r = (e) => a(e, n);
46
+ function m(e, t = 1) {
47
+ let n = f(e), r = o(t);
48
+ if (r === 1) return n;
49
+ let i = (e) => a(e, r);
44
50
  return {
45
- ...e,
46
- files: e.files.map((e) => ({
51
+ ...n,
52
+ files: n.files.map((e) => c(e) ? e : {
47
53
  ...e,
48
54
  pages: e.pages.map((e) => ({
49
55
  ...e,
50
- width: r(e.width),
51
- height: r(e.height)
56
+ width: i(e.width),
57
+ height: i(e.height)
52
58
  }))
53
- })),
54
- placements: e.placements.map((e) => ({
59
+ }),
60
+ placements: n.placements.map((e) => c(n.files.find((t) => t.fileId === e.fileId)) ? e : {
55
61
  ...e,
56
- signLeft: r(e.signLeft),
57
- signTop: r(e.signTop),
58
- signWidth: r(e.signWidth),
59
- signHeight: r(e.signHeight)
60
- }))
62
+ signLeft: i(e.signLeft),
63
+ signTop: i(e.signTop),
64
+ signWidth: i(e.signWidth),
65
+ signHeight: i(e.signHeight)
66
+ })
61
67
  };
62
68
  }
63
- function f(e, t, n) {
69
+ function h(e, t, n) {
64
70
  return e.files.find((e) => e.fileId === t)?.pages.find((e) => e.pageIndex === n);
65
71
  }
66
- function p(e) {
72
+ function g(e) {
67
73
  if (e?.length) return e.reduce((e, t) => t.pageIndex < e.pageIndex ? t : e);
68
74
  }
69
- function m(e, r, i, a) {
75
+ function _(e, r, i, a) {
70
76
  let o = {
71
77
  ...e,
72
78
  ...r,
@@ -94,37 +100,37 @@ function m(e, r, i, a) {
94
100
  sealTypeOptions: a?.sealTypeOptions
95
101
  }) : o;
96
102
  }
97
- function h(e) {
98
- return !!(e && M(e.width) && M(e.height));
103
+ function v(e) {
104
+ return !!(e && R(e.width) && R(e.height));
99
105
  }
100
- function g(e, t, n = 1, r = !1) {
101
- if (r || h(e) || !t.width || !t.height) return;
106
+ function y(e, t, n = 1, r = !1) {
107
+ if (r || v(e) || !t.width || !t.height) return;
102
108
  let i = a(t.width, n), o = a(t.height, n);
103
109
  return i > 0 && o > 0 ? {
104
110
  width: i,
105
111
  height: o
106
112
  } : void 0;
107
113
  }
108
- function _(e, i, a, o = {}) {
109
- let c = e === "seal" ? t(o.sealType ?? ["04"], o.sealTypeOptions) : r(e, o.sizeProfile);
110
- return s += 1, n({
111
- id: `contract-signing-placement-${Date.now().toString(36)}-${s.toString(36)}`,
114
+ function b(e, i, a, o = {}) {
115
+ let s = e === "seal" ? t(o.sealType ?? ["04"], o.sealTypeOptions) : r(e, o.sizeProfile);
116
+ return u += 1, n({
117
+ id: `contract-signing-placement-${Date.now().toString(36)}-${u.toString(36)}`,
112
118
  fileId: i,
113
119
  pageIndex: a.pageIndex,
114
120
  signType: e,
115
- signLeft: o.signLeft ?? (a.width - c.width) / 2,
116
- signTop: o.signTop ?? (a.height - c.height) / 2,
117
- signWidth: c.width,
118
- signHeight: c.height,
121
+ signLeft: o.signLeft ?? (a.width - s.width) / 2,
122
+ signTop: o.signTop ?? (a.height - s.height) / 2,
123
+ signWidth: s.width,
124
+ signHeight: s.height,
119
125
  mustSign: !0,
120
- ...e === "seal" ? { sealType: o.sealType === void 0 ? ["04"] : T(o.sealType) } : {}
126
+ ...e === "seal" ? { sealType: o.sealType === void 0 ? ["04"] : j(o.sealType) } : {}
121
127
  }, a, {
122
128
  sealSizeLimit: o.sealSizeLimit,
123
129
  sealTypes: o.sealType,
124
130
  sealTypeOptions: o.sealTypeOptions
125
131
  });
126
132
  }
127
- function v(t, n = {}) {
133
+ function x(t, n = {}) {
128
134
  let r = [], i = n.allowedSealTypes ? new Set(Array.from(n.allowedSealTypes, (e) => String(e).trim()).filter(Boolean)) : void 0;
129
135
  t.files.length || r.push({
130
136
  code: "CONTRACT_FILES_MISSING",
@@ -146,7 +152,7 @@ function v(t, n = {}) {
146
152
  code: "CONTRACT_PAGES_MISSING",
147
153
  message: `文件 ${e.fileName || e.fileId} 没有页面元数据`,
148
154
  fileId: e.fileId
149
- });
155
+ }), r.push(...l(e));
150
156
  let t = /* @__PURE__ */ new Set();
151
157
  e.pages.forEach((n) => {
152
158
  !Number.isInteger(n.pageIndex) || n.pageIndex < 0 ? r.push({
@@ -159,7 +165,7 @@ function v(t, n = {}) {
159
165
  message: `文件 ${e.fileName || e.fileId} 的页面索引 ${n.pageIndex} 重复`,
160
166
  fileId: e.fileId,
161
167
  pageIndex: n.pageIndex
162
- }), t.add(n.pageIndex), h(n) || r.push({
168
+ }), t.add(n.pageIndex), v(n) || r.push({
163
169
  code: "CONTRACT_PAGE_SIZE_INVALID",
164
170
  message: "页面缺少有效的原始宽高",
165
171
  fileId: e.fileId,
@@ -176,7 +182,7 @@ function v(t, n = {}) {
176
182
  code: "SIGNING_PLACEMENT_ID_MISSING",
177
183
  message: `${a}缺少唯一 ID`
178
184
  }), o.add(n.id);
179
- let s = f(t, n.fileId, n.pageIndex);
185
+ let s = h(t, n.fileId, n.pageIndex);
180
186
  if (!s) {
181
187
  r.push({
182
188
  code: "SIGNING_PLACEMENT_PAGE_MISSING",
@@ -221,9 +227,9 @@ function v(t, n = {}) {
221
227
  });
222
228
  }), r;
223
229
  }
224
- function y(e, t = {}) {
225
- let n = v(e, t);
226
- if (n.length) throw new x(n);
230
+ function S(e, t = {}) {
231
+ let n = x(e, t);
232
+ if (n.length) throw new w(n);
227
233
  return e.placements.map((e) => {
228
234
  let t = i(e);
229
235
  return {
@@ -240,78 +246,110 @@ function y(e, t = {}) {
240
246
  };
241
247
  });
242
248
  }
243
- function b(e, t = {}) {
244
- let n = u(e);
249
+ function C(e, t = {}) {
250
+ let n = p(e);
245
251
  return {
246
252
  ...n,
247
- locationRules: y(n, t)
253
+ locationRules: S(n, t)
248
254
  };
249
255
  }
250
- var x = class extends Error {
256
+ var w = class extends Error {
251
257
  constructor(e) {
252
258
  super(e[0]?.message || "指定签署位置数据不完整"), this.code = "CONTRACT_SIGNING_LOCATION_INVALID", this.name = "ContractSigningLocationBuildError", this.errors = e;
253
259
  }
254
260
  };
255
- function S(e) {
261
+ function T(e) {
256
262
  return Array.isArray(e) ? e.map((e, t) => {
257
- let n = e && typeof e == "object" ? e : {}, r = String(n.fileId ?? "").trim(), i = Array.isArray(n.pages) ? n.pages : [];
263
+ let n = e && typeof e == "object" ? e : {}, r = String(n.fileId ?? "").trim(), i = E(n.source), a = i?.type === "template" ? D(i.template, i.values) : Array.isArray(n.pages) ? n.pages.map((e, t) => O(e, t)) : [];
258
264
  return {
259
265
  fileId: r,
260
266
  fileName: String(n.fileName ?? `合同文件 ${t + 1}`),
261
- pages: i.map((e, t) => C(e, t))
267
+ pages: a,
268
+ ...i ? { source: i } : {}
262
269
  };
263
270
  }) : [];
264
271
  }
265
- function C(e, t) {
266
- let n = e && typeof e == "object" ? e : {}, r = A(n.pageIndex, t);
272
+ function E(e) {
273
+ if (!e || typeof e != "object") return;
274
+ let t = e;
275
+ return t.type === "template" ? {
276
+ type: "template",
277
+ template: k(t.template),
278
+ ...t.values && typeof t.values == "object" && !Array.isArray(t.values) ? { values: { ...t.values } } : {}
279
+ } : t.type === "preview" ? { type: "preview" } : void 0;
280
+ }
281
+ function D(e, t) {
282
+ return s({
283
+ type: "template",
284
+ template: e,
285
+ ...t ? { values: t } : {}
286
+ }).map((e) => ({
287
+ pageIndex: e.pageIndex,
288
+ displayPageNumber: e.pageIndex + 1,
289
+ pageId: e.pageId,
290
+ width: F(e.width, 0),
291
+ height: F(e.height, 0)
292
+ }));
293
+ }
294
+ function O(e, t) {
295
+ let n = e && typeof e == "object" ? e : {}, r = I(n.pageIndex, t);
267
296
  return {
268
297
  pageIndex: r,
269
- displayPageNumber: j(n.displayPageNumber, r + 1),
270
- width: k(n.width, 0),
271
- height: k(n.height, 0),
298
+ displayPageNumber: L(n.displayPageNumber, r + 1),
299
+ width: F(n.width, 0),
300
+ height: F(n.height, 0),
301
+ ...n.pageId ? { pageId: String(n.pageId) } : {},
272
302
  ...n.previewUrl ? { previewUrl: String(n.previewUrl) } : {},
273
303
  ...n.thumbnailUrl ? { thumbnailUrl: String(n.thumbnailUrl) } : {}
274
304
  };
275
305
  }
276
- function w(e) {
306
+ function k(e) {
307
+ if (e == null) return e;
308
+ try {
309
+ return JSON.parse(JSON.stringify(e));
310
+ } catch {
311
+ return e;
312
+ }
313
+ }
314
+ function A(e) {
277
315
  let t = e?.signType === "seal" || e?.signType === "signature" || e?.signType === "date" ? e.signType : "signature";
278
316
  return {
279
317
  id: String(e?.id ?? ""),
280
318
  fileId: String(e?.fileId ?? "").trim(),
281
- pageIndex: A(e?.pageIndex, 0),
319
+ pageIndex: I(e?.pageIndex, 0),
282
320
  signType: t,
283
- signLeft: O(e?.signLeft, 0),
284
- signTop: O(e?.signTop, 0),
285
- signWidth: O(e?.signWidth, 0),
286
- signHeight: O(e?.signHeight, 0),
321
+ signLeft: P(e?.signLeft, 0),
322
+ signTop: P(e?.signTop, 0),
323
+ signWidth: P(e?.signWidth, 0),
324
+ signHeight: P(e?.signHeight, 0),
287
325
  mustSign: e?.mustSign !== !1,
288
326
  ...t === "seal" && Array.isArray(e?.sealType) ? { sealType: e.sealType.map(String) } : {}
289
327
  };
290
328
  }
291
- function T(e) {
329
+ function j(e) {
292
330
  return Array.isArray(e) ? Array.from(new Set(e.map(String).map((e) => e.trim()).filter(Boolean))) : [];
293
331
  }
294
- function E(e) {
295
- return new Map(e.flatMap((e) => e.pages.map((t) => [D(e.fileId, t.pageIndex), t])));
332
+ function M(e) {
333
+ return new Map(e.flatMap((e) => e.pages.map((t) => [N(e.fileId, t.pageIndex), t])));
296
334
  }
297
- function D(e, t) {
335
+ function N(e, t) {
298
336
  return `${e}\u0000${t}`;
299
337
  }
300
- function O(e, t) {
338
+ function P(e, t) {
301
339
  let n = Number(e);
302
340
  return Number.isFinite(n) ? n : t;
303
341
  }
304
- function k(e, t) {
305
- return Math.max(0, O(e, t));
342
+ function F(e, t) {
343
+ return Math.max(0, P(e, t));
306
344
  }
307
- function A(e, t) {
308
- return Math.max(0, Math.round(O(e, t)));
345
+ function I(e, t) {
346
+ return Math.max(0, Math.round(P(e, t)));
309
347
  }
310
- function j(e, t) {
311
- return Math.max(1, Math.round(O(e, t)));
348
+ function L(e, t) {
349
+ return Math.max(1, Math.round(P(e, t)));
312
350
  }
313
- function M(e) {
351
+ function R(e) {
314
352
  return typeof e == "number" && Number.isFinite(e) && e > 0;
315
353
  }
316
354
  //#endregion
317
- export { x as ContractSigningLocationBuildError, b as buildContractSigningLocationOutput, y as buildContractSigningLocationRules, u as cloneContractSigningLocationValue, c as createContractSigningLocationValue, _ as createContractSigningPlacement, f as findContractSigningPage, p as getContractSigningHomePage, h as isContractSigningPageUsable, l as normalizeContractSigningLocationValue, d as normalizeContractSigningProviderValue, m as patchContractSigningPlacement, g as resolveContractSigningPreviewPageSize, v as validateContractSigningLocationValue };
355
+ export { w as ContractSigningLocationBuildError, C as buildContractSigningLocationOutput, S as buildContractSigningLocationRules, p as cloneContractSigningLocationValue, d as createContractSigningLocationValue, b as createContractSigningPlacement, h as findContractSigningPage, g as getContractSigningHomePage, v as isContractSigningPageUsable, f as normalizeContractSigningLocationValue, m as normalizeContractSigningProviderValue, _ as patchContractSigningPlacement, y as resolveContractSigningPreviewPageSize, x as validateContractSigningLocationValue };
@@ -0,0 +1,85 @@
1
+ import { buildTemplateRenderPages as e, normalizeRenderValues as t, validateTemplateRenderStructure as n } from "../../pro-contract-template-designer/src/utils/template-renderer.mjs";
2
+ //#region src/components/contract-signing-location/src/template-source.ts
3
+ function r(e) {
4
+ return !!(e && typeof e == "object" && e.type === "template");
5
+ }
6
+ function i(e) {
7
+ return r(e?.source);
8
+ }
9
+ function a(n) {
10
+ if (!r(n) || !l(n.template)) return [];
11
+ try {
12
+ let r = n.template, i = Array.isArray(r.pages) ? r.pages : [], a = t(r, n.values), o = c(r);
13
+ return i.flatMap((t, n) => {
14
+ let i = e({
15
+ ...r,
16
+ pages: [t]
17
+ }, a, {
18
+ readonly: !0,
19
+ disabled: !0,
20
+ mode: "display"
21
+ })[0];
22
+ if (!i) return [];
23
+ let s = u(t?.pageSize, r.pageSize, i);
24
+ return [{
25
+ pageIndex: n,
26
+ pageId: i.id,
27
+ title: i.title,
28
+ width: s.width,
29
+ height: s.height,
30
+ contentHtml: i.contentHtml,
31
+ errors: o.filter((e) => !e.pageId || e.pageId === i.id).map((e) => e.message)
32
+ }];
33
+ });
34
+ } catch {
35
+ return [];
36
+ }
37
+ }
38
+ function o(e) {
39
+ if (!r(e.source)) return [];
40
+ if (!l(e.source.template)) return [{
41
+ code: "CONTRACT_TEMPLATE_MISSING",
42
+ message: `文件 ${e.fileName || e.fileId} 缺少可渲染的合同模板`,
43
+ fileId: e.fileId
44
+ }];
45
+ try {
46
+ let t = Array.isArray(e.source.template.pages) ? e.source.template.pages : [];
47
+ return c(e.source.template).map((n) => {
48
+ let r = n.pageId ? t.findIndex((e) => e?.id === n.pageId) : -1;
49
+ return {
50
+ code: `CONTRACT_${n.code || "TEMPLATE_INVALID"}`,
51
+ message: `${e.fileName || e.fileId}:${n.message}`,
52
+ fileId: e.fileId,
53
+ ...r >= 0 ? { pageIndex: r } : {}
54
+ };
55
+ });
56
+ } catch (t) {
57
+ return [{
58
+ code: "CONTRACT_TEMPLATE_RENDER_FAILED",
59
+ message: `文件 ${e.fileName || e.fileId} 的模板数据无法安全渲染`,
60
+ fileId: e.fileId,
61
+ cause: t
62
+ }];
63
+ }
64
+ }
65
+ function s(e) {
66
+ return !e || !r(e.source) ? "" : o(e)[0]?.message ?? "";
67
+ }
68
+ function c(e) {
69
+ return n(e);
70
+ }
71
+ function l(e) {
72
+ return !!(e && typeof e == "object");
73
+ }
74
+ function u(e, t, n) {
75
+ return {
76
+ width: d(e?.width, d(t?.width, n.width)),
77
+ height: d(e?.height, d(t?.height, n.height))
78
+ };
79
+ }
80
+ function d(e, t) {
81
+ let n = Number(e);
82
+ return Number.isFinite(n) && n > 0 ? n : t;
83
+ }
84
+ //#endregion
85
+ export { a as buildContractSigningTemplateRenderPages, s as getContractSigningTemplateDisplayError, i as isContractSigningTemplateFile, r as isContractSigningTemplateSource, o as validateContractSigningTemplateFile };