@guodun/antdv 1.7.8 → 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 (31) 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/ProContractTemplateDesigner.vue.mjs +1019 -1009
  5. package/dist/es/components/pro-contract-template-designer/src/composables/use-template-designer.mjs +192 -162
  6. package/dist/es/components/pro-contract-template-designer/src/extensions/template-variable.mjs +70 -68
  7. package/dist/es/components/pro-contract-template-designer/src/utils/advanced-controls.mjs +63 -25
  8. package/dist/es/components/pro-contract-template-designer/src/utils/template-renderer.mjs +129 -75
  9. package/dist/es/components/pro-contract-template-designer/src/utils/template-variable-render.mjs +17 -5
  10. package/dist/es/components/pro-contract-template-designer/style/index.css +1 -1
  11. package/dist/es/index.mjs +22 -22
  12. package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateChoiceOptionsEditor.cjs +1 -0
  13. package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateChoiceOptionsEditor.vue.cjs +1 -0
  14. package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateDesignerInspector.vue.cjs +1 -2
  15. package/dist/lib/components/pro-contract-template-designer/src/ProContractTemplateDesigner.vue.cjs +1 -1
  16. package/dist/lib/components/pro-contract-template-designer/src/composables/use-template-designer.cjs +4 -4
  17. package/dist/lib/components/pro-contract-template-designer/src/extensions/template-variable.cjs +1 -1
  18. package/dist/lib/components/pro-contract-template-designer/src/utils/advanced-controls.cjs +1 -1
  19. package/dist/lib/components/pro-contract-template-designer/src/utils/template-renderer.cjs +3 -3
  20. package/dist/lib/components/pro-contract-template-designer/src/utils/template-variable-render.cjs +1 -1
  21. package/dist/lib/components/pro-contract-template-designer/style/index.css +1 -1
  22. package/dist/lib/index.cjs +1 -1
  23. package/dist/theme/icon.css +1 -1
  24. package/dist/theme/index.css +1 -1
  25. package/dist/types/components/pro-contract-template-designer/src/ContractTemplateChoiceOptionsEditor.vue.d.ts +12 -0
  26. package/dist/types/components/pro-contract-template-designer/src/ProContractTemplateDesigner.vue.d.ts +2 -0
  27. package/dist/types/components/pro-contract-template-designer/src/composables/use-template-designer.d.ts +5 -1
  28. package/dist/types/components/pro-contract-template-designer/src/types.d.ts +15 -2
  29. package/dist/types/components/pro-contract-template-designer/src/utils/advanced-controls.d.ts +10 -0
  30. package/dist/types/components/pro-contract-template-designer/src/utils/template-variable-render.d.ts +7 -0
  31. package/package.json +5 -5
@@ -1,37 +1,37 @@
1
1
  import { DEFAULT_CONTRACT_FONT_FAMILY as e } from "../constants.mjs";
2
2
  import { resolveTemplateVariablePresentation as t } from "../utils/template-variable-render.mjs";
3
- import { decodeContractTemplateJsonAttribute as n, encodeContractTemplateJsonAttribute as r } from "../utils/advanced-controls.mjs";
4
- import { Node as i, mergeAttributes as a } from "@tiptap/core";
3
+ import { buildRadioOptionNodes as n, decodeContractTemplateJsonAttribute as r, encodeContractTemplateJsonAttribute as i, readContractTemplateControlOptions as a } from "../utils/advanced-controls.mjs";
4
+ import { Node as o, mergeAttributes as s } from "@tiptap/core";
5
5
  //#region src/components/pro-contract-template-designer/src/extensions/template-variable.ts
6
- function o(e, t, n = "") {
6
+ function c(e, t, n = "") {
7
7
  return {
8
8
  default: n,
9
9
  parseHTML: (e) => e.getAttribute(t) ?? n,
10
10
  renderHTML: (n) => ({ [t]: n[e] })
11
11
  };
12
12
  }
13
- function s(e, t, n) {
13
+ function l(e, t, n) {
14
14
  return {
15
15
  default: n,
16
16
  parseHTML: (e) => Number(e.getAttribute(t) || n),
17
17
  renderHTML: (n) => ({ [t]: n[e] })
18
18
  };
19
19
  }
20
- function c(e, t) {
20
+ function u(e, t) {
21
21
  return {
22
22
  default: !1,
23
23
  parseHTML: (e) => e.getAttribute(t) === "true",
24
24
  renderHTML: (n) => ({ [t]: String(!!n[e]) })
25
25
  };
26
26
  }
27
- function l(e, t, i) {
27
+ function d(e, t, n) {
28
28
  return {
29
- default: i,
30
- parseHTML: (e) => n(e.getAttribute(t)) ?? i,
31
- renderHTML: (n) => n[e] === void 0 || n[e] === null ? {} : { [t]: r(n[e]) }
29
+ default: n,
30
+ parseHTML: (e) => r(e.getAttribute(t)) ?? n,
31
+ renderHTML: (n) => n[e] === void 0 || n[e] === null ? {} : { [t]: i(n[e]) }
32
32
  };
33
33
  }
34
- var u = i.create({
34
+ var f = o.create({
35
35
  name: "templateVariable",
36
36
  group: "inline",
37
37
  inline: !0,
@@ -40,19 +40,19 @@ var u = i.create({
40
40
  draggable: !0,
41
41
  addAttributes() {
42
42
  return {
43
- key: o("key", "data-key"),
43
+ key: c("key", "data-key"),
44
44
  label: {
45
45
  default: "",
46
46
  parseHTML: (e) => e.getAttribute("data-label") ?? e.textContent ?? "",
47
47
  renderHTML: (e) => ({ "data-label": e.label })
48
48
  },
49
- type: o("type", "data-variable-type", "text"),
50
- placeholder: o("placeholder", "data-placeholder"),
51
- width: s("width", "data-width", 160),
52
- height: s("height", "data-height", 32),
53
- required: c("required", "data-required"),
54
- defaultValue: o("defaultValue", "data-default-value"),
55
- format: o("format", "data-format"),
49
+ type: c("type", "data-variable-type", "text"),
50
+ placeholder: c("placeholder", "data-placeholder"),
51
+ width: l("width", "data-width", 160),
52
+ height: l("height", "data-height", 32),
53
+ required: u("required", "data-required"),
54
+ defaultValue: c("defaultValue", "data-default-value"),
55
+ format: c("format", "data-format"),
56
56
  precision: {
57
57
  default: void 0,
58
58
  parseHTML: (e) => {
@@ -69,52 +69,52 @@ var u = i.create({
69
69
  },
70
70
  renderHTML: (e) => e.useGrouping === void 0 ? {} : { "data-use-grouping": String(!!e.useGrouping) }
71
71
  },
72
- checkedText: o("checkedText", "data-checked-text"),
73
- uncheckedText: o("uncheckedText", "data-unchecked-text"),
74
- options: l("options", "data-control-options", []),
75
- dataSource: l("dataSource", "data-control-source", void 0),
76
- multiple: c("multiple", "data-multiple"),
77
- componentKey: o("componentKey", "data-component-key"),
78
- componentConfig: l("componentConfig", "data-component-config", {}),
79
- multiline: c("multiline", "data-multiline"),
80
- rows: s("rows", "data-rows", 3),
81
- lineHeight: s("lineHeight", "data-line-height", 28),
82
- border: c("border", "data-border"),
83
- underline: c("underline", "data-underline"),
84
- color: o("color", "data-color", "#1f2937"),
85
- background: o("background", "data-background", "transparent"),
86
- fontSize: s("fontSize", "data-font-size", 14),
72
+ checkedText: c("checkedText", "data-checked-text"),
73
+ uncheckedText: c("uncheckedText", "data-unchecked-text"),
74
+ options: d("options", "data-control-options", []),
75
+ dataSource: d("dataSource", "data-control-source", void 0),
76
+ multiple: u("multiple", "data-multiple"),
77
+ componentKey: c("componentKey", "data-component-key"),
78
+ componentConfig: d("componentConfig", "data-component-config", {}),
79
+ multiline: u("multiline", "data-multiline"),
80
+ rows: l("rows", "data-rows", 3),
81
+ lineHeight: l("lineHeight", "data-line-height", 28),
82
+ border: u("border", "data-border"),
83
+ underline: u("underline", "data-underline"),
84
+ color: c("color", "data-color", "#1f2937"),
85
+ background: c("background", "data-background", "transparent"),
86
+ fontSize: l("fontSize", "data-font-size", 14),
87
87
  fontFamily: {
88
88
  default: "",
89
89
  parseHTML: (e) => e.getAttribute("data-font-family") ?? "",
90
90
  renderHTML: (e) => e.fontFamily ? { "data-font-family": e.fontFamily } : {}
91
91
  },
92
- placeholderColor: o("placeholderColor", "data-placeholder-color", "#7a818b"),
93
- lineColor: o("lineColor", "data-line-color", "#565b66"),
94
- textAlign: o("textAlign", "data-text-align", "left"),
95
- borderStyle: o("borderStyle", "data-border-style", "solid"),
96
- objectFit: o("objectFit", "data-object-fit", "contain")
92
+ placeholderColor: c("placeholderColor", "data-placeholder-color", "#7a818b"),
93
+ lineColor: c("lineColor", "data-line-color", "#565b66"),
94
+ textAlign: c("textAlign", "data-text-align", "left"),
95
+ borderStyle: c("borderStyle", "data-border-style", "solid"),
96
+ objectFit: c("objectFit", "data-object-fit", "contain")
97
97
  };
98
98
  },
99
99
  parseHTML() {
100
100
  return [{ tag: "span[data-template-variable]" }];
101
101
  },
102
102
  renderHTML({ HTMLAttributes: e }) {
103
- let n = e["data-border"] ?? e.border, r = e["data-precision"] ?? e.precision, i = r === void 0 || r === "" ? void 0 : Number(r), o = e["data-use-grouping"] ?? e.useGrouping, s = o === void 0 || o === "" ? void 0 : o === !0 || o === "true", c = t({
103
+ let r = e["data-border"] ?? e.border, i = e["data-precision"] ?? e.precision, o = i === void 0 || i === "" ? void 0 : Number(i), c = e["data-use-grouping"] ?? e.useGrouping, l = c === void 0 || c === "" ? void 0 : c === !0 || c === "true", u = e["data-control-options"], d = a(typeof u == "string" && u ? u : e.options), f = String(e["data-default-value"] || e.defaultValue || ""), p = String(e["data-placeholder"] || e.placeholder || ""), m = e["data-multiple"] === "true" || e.multiple === !0, h = t({
104
104
  type: String(e["data-variable-type"] || e.type || "text"),
105
105
  width: e["data-width"] || e.width || 160,
106
106
  height: e["data-height"] || e.height || 32,
107
- border: n === !0 || n === "true",
107
+ border: r === !0 || r === "true",
108
108
  underline: e["data-underline"] === "true" || e.underline === !0,
109
109
  color: String(e["data-color"] || e.color || "#1f2937"),
110
110
  background: String(e["data-background"] || e.background || "transparent"),
111
111
  fontSize: e["data-font-size"] || e.fontSize || 14,
112
112
  fontFamily: String(e["data-font-family"] || e.fontFamily || ""),
113
- placeholder: String(e["data-placeholder"] || e.placeholder || ""),
114
- defaultValue: String(e["data-default-value"] || e.defaultValue || ""),
113
+ placeholder: p,
114
+ defaultValue: f,
115
115
  format: String(e["data-format"] || e.format || ""),
116
- precision: i,
117
- useGrouping: s,
116
+ precision: o,
117
+ useGrouping: l,
118
118
  checkedText: String(e["data-checked-text"] || e.checkedText || ""),
119
119
  uncheckedText: String(e["data-unchecked-text"] || e.uncheckedText || ""),
120
120
  multiline: e["data-multiline"] === "true" || e.multiline === !0,
@@ -124,37 +124,39 @@ var u = i.create({
124
124
  lineColor: String(e["data-line-color"] || e.lineColor || "#565b66"),
125
125
  textAlign: String(e["data-text-align"] || e.textAlign || "left"),
126
126
  borderStyle: String(e["data-border-style"] || e.borderStyle || "solid"),
127
- objectFit: String(e["data-object-fit"] || e.objectFit || "contain")
128
- });
127
+ objectFit: String(e["data-object-fit"] || e.objectFit || "contain"),
128
+ options: d,
129
+ multiple: m
130
+ }), g = h.type === "radio" ? n(d, f) : [], _ = h.type === "image" && h.hasDefaultValue ? " " : h.type === "radio" ? p || " " : h.displayText || " ";
129
131
  return [
130
132
  "span",
131
- a(e, {
133
+ s(e, {
132
134
  "data-template-variable": "true",
133
- "data-variable-type": c.type,
134
- "data-width": String(c.width),
135
- "data-height": String(c.height),
136
- "data-border": String(c.border),
137
- "data-underline": String(c.underline),
135
+ "data-variable-type": h.type,
136
+ "data-width": String(h.width),
137
+ "data-height": String(h.height),
138
+ "data-border": String(h.border),
139
+ "data-underline": String(h.underline),
138
140
  "data-multiline": String(e["data-multiline"] === "true" || e.multiline === !0),
139
141
  "data-rows": String(Math.max(1, Number(e["data-rows"] || e.rows || 3))),
140
142
  "data-line-height": String(Math.max(18, Number(e["data-line-height"] || e.lineHeight || 28))),
141
- "data-color": c.color,
142
- "data-background": c.background,
143
- "data-font-size": String(c.fontSize),
144
- "data-font-family": c.fontFamily,
145
- "data-placeholder-color": c.placeholderColor,
146
- "data-line-color": c.lineColor,
147
- "data-text-align": c.textAlign,
148
- "data-border-style": c.borderStyle,
149
- "data-object-fit": c.objectFit,
150
- class: c.classes.join(" "),
151
- style: c.styleText
143
+ "data-color": h.color,
144
+ "data-background": h.background,
145
+ "data-font-size": String(h.fontSize),
146
+ "data-font-family": h.fontFamily,
147
+ "data-placeholder-color": h.placeholderColor,
148
+ "data-line-color": h.lineColor,
149
+ "data-text-align": h.textAlign,
150
+ "data-border-style": h.borderStyle,
151
+ "data-object-fit": h.objectFit,
152
+ class: h.classes.join(" "),
153
+ style: h.styleText
152
154
  }),
153
- c.type === "image" && c.hasDefaultValue ? " " : c.displayText || " "
155
+ ...g.length ? g : [_]
154
156
  ];
155
157
  }
156
158
  });
157
- function d(t) {
159
+ function p(t) {
158
160
  return {
159
161
  key: t.key,
160
162
  label: t.label,
@@ -190,13 +192,13 @@ function d(t) {
190
192
  objectFit: t.style?.objectFit || "contain"
191
193
  };
192
194
  }
193
- function f(e, t, n) {
195
+ function m(e, t, n) {
194
196
  if (!e) return !1;
195
197
  let r = {
196
198
  type: "templateVariable",
197
- attrs: d(t)
199
+ attrs: p(t)
198
200
  }, i = e.chain().focus();
199
201
  return typeof n == "number" ? i.insertContentAt(n, r).run() : i.insertContent(r).run();
200
202
  }
201
203
  //#endregion
202
- export { u as TemplateVariable, d as buildTemplateVariableAttrs, f as insertTemplateVariableNode };
204
+ export { f as TemplateVariable, p as buildTemplateVariableAttrs, m as insertTemplateVariableNode };
@@ -1,23 +1,24 @@
1
+ import { escapeHtmlText as e } from "./html.mjs";
1
2
  //#region src/components/pro-contract-template-designer/src/utils/advanced-controls.ts
2
- function e(e) {
3
+ function t(e) {
3
4
  if (!e || typeof e != "object" || Array.isArray(e)) return !1;
4
5
  let t = e;
5
6
  return (typeof t.value == "string" || typeof t.value == "number") && typeof t.label == "string" && typeof t.type == "string";
6
7
  }
7
- function t(t, r) {
8
- if (e(t)) return {
9
- ...n(t),
10
- value: t.value,
11
- label: t.label,
12
- type: t.type || r
8
+ function n(e, n) {
9
+ if (t(e)) return {
10
+ ...r(e),
11
+ value: e.value,
12
+ label: e.label,
13
+ type: e.type || n
13
14
  };
14
- if (typeof t == "string" || typeof t == "number") return {
15
- value: t,
16
- label: String(t),
17
- type: r
15
+ if (typeof e == "string" || typeof e == "number") return {
16
+ value: e,
17
+ label: String(e),
18
+ type: n
18
19
  };
19
20
  }
20
- function n(e) {
21
+ function r(e) {
21
22
  let t = {};
22
23
  return Object.entries(e).forEach(([e, n]) => {
23
24
  if (!(e === "value" || e === "label" || e === "type")) try {
@@ -25,29 +26,66 @@ function n(e) {
25
26
  } catch {}
26
27
  }), t;
27
28
  }
28
- function r(e, n, r) {
29
- let i = (Array.isArray(e) ? e : e == null || e === "" ? [] : [e]).map((e) => t(e, n)).filter(Boolean);
29
+ function i(e, t, r) {
30
+ let i = (Array.isArray(e) ? e : e == null || e === "" ? [] : [e]).map((e) => n(e, t)).filter(Boolean);
30
31
  return r ? i : i[0];
31
32
  }
32
- function i(t) {
33
- return Array.isArray(t) ? t.map((e) => e.displayText || e.label || String(e.value)).filter(Boolean).join("、") : e(t) ? t.displayText || t.label || String(t.value) : t == null ? "" : String(t);
34
- }
35
33
  function a(e) {
34
+ return Array.isArray(e) ? e.map((e) => e.displayText || e.label || String(e.value)).filter(Boolean).join("、") : t(e) ? e.displayText || e.label || String(e.value) : e == null ? "" : String(e);
35
+ }
36
+ function o(e) {
36
37
  try {
37
38
  return encodeURIComponent(JSON.stringify(e ?? null));
38
39
  } catch {
39
40
  return "";
40
41
  }
41
42
  }
42
- function o(e) {
43
+ function s(e) {
43
44
  if (!(typeof e != "string" || !e)) try {
44
45
  return JSON.parse(decodeURIComponent(e));
45
46
  } catch {
46
47
  return;
47
48
  }
48
49
  }
49
- function s(e, t, n) {
50
- let r = u(e, t?.dataPath), i = Array.isArray(r) ? r : [], a = t?.valueField || "value", o = t?.labelField || "label";
50
+ function c(e, t) {
51
+ let n = Array.isArray(e) ? e : [], r = t != null && t !== "";
52
+ return n.flatMap((e) => {
53
+ if (!e || typeof e != "object") return [];
54
+ let n = e;
55
+ if (typeof n.label != "string") return [];
56
+ let i = r && String(n.value ?? "") === String(t);
57
+ return [{
58
+ label: n.label,
59
+ mark: i ? "●" : "○",
60
+ className: i ? "gd-contract-template-variable__choice-option is-checked" : "gd-contract-template-variable__choice-option"
61
+ }];
62
+ });
63
+ }
64
+ function l(t, n) {
65
+ return c(t, n).map((t) => `<span class="${t.className}"><span class="gd-contract-template-variable__choice-mark">${t.mark}</span>${e(t.label)}</span>`).join("");
66
+ }
67
+ function u(e, t) {
68
+ return c(e, t).map((e) => [
69
+ "span",
70
+ { class: e.className },
71
+ [
72
+ "span",
73
+ { class: "gd-contract-template-variable__choice-mark" },
74
+ e.mark
75
+ ],
76
+ e.label
77
+ ]);
78
+ }
79
+ function d(e) {
80
+ let t = typeof e == "string" ? s(e) : e;
81
+ return (Array.isArray(t) ? t : []).flatMap((e) => {
82
+ if (!e || typeof e != "object") return [];
83
+ let t = e;
84
+ return typeof t.value != "string" && typeof t.value != "number" || typeof t.label != "string" ? [] : [t];
85
+ });
86
+ }
87
+ function f(e, t, n) {
88
+ let r = h(e, t?.dataPath), i = Array.isArray(r) ? r : [], a = t?.valueField || "value", o = t?.labelField || "label";
51
89
  return i.flatMap((e) => {
52
90
  if (!e || typeof e != "object") return [];
53
91
  let t = e, r = t[a];
@@ -59,7 +97,7 @@ function s(e, t, n) {
59
97
  }];
60
98
  });
61
99
  }
62
- function c(e, t) {
100
+ function p(e, t) {
63
101
  let n = e.trim();
64
102
  if (/^\/(?!\/)/.test(n)) return !0;
65
103
  try {
@@ -75,17 +113,17 @@ function c(e, t) {
75
113
  return !1;
76
114
  }
77
115
  }
78
- function l(e, t = 1e4) {
116
+ function m(e, t = 1e4) {
79
117
  let n = Number.isFinite(t) ? Math.max(500, Math.floor(t)) : 1e4, r = Number(e);
80
118
  return Number.isFinite(r) ? Math.min(n, Math.max(500, Math.floor(r))) : n;
81
119
  }
82
- function u(e, t) {
120
+ function h(e, t) {
83
121
  return t ? t.split(".").filter(Boolean).reduce((e, t) => {
84
122
  if (!(!e || typeof e != "object" || Array.isArray(e))) return e[t];
85
123
  }, e) : e;
86
124
  }
87
- function d(e) {
125
+ function g(e) {
88
126
  return e && typeof e == "object" && !Array.isArray(e) ? e : {};
89
127
  }
90
128
  //#endregion
91
- export { o as decodeContractTemplateJsonAttribute, a as encodeContractTemplateJsonAttribute, i as formatContractTemplateRenderValue, c as isAllowedContractTemplateRemoteUrl, e as isContractTemplateSelectionValue, s as normalizeContractTemplateControlOptions, d as normalizeContractTemplateJsonObject, l as normalizeContractTemplateRequestTimeout, t as normalizeContractTemplateSelectionValue, r as normalizeContractTemplateSelectionValues };
129
+ export { u as buildRadioOptionNodes, l as buildRadioOptionsHtml, s as decodeContractTemplateJsonAttribute, o as encodeContractTemplateJsonAttribute, a as formatContractTemplateRenderValue, p as isAllowedContractTemplateRemoteUrl, t as isContractTemplateSelectionValue, f as normalizeContractTemplateControlOptions, g as normalizeContractTemplateJsonObject, m as normalizeContractTemplateRequestTimeout, n as normalizeContractTemplateSelectionValue, i as normalizeContractTemplateSelectionValues, d as readContractTemplateControlOptions };