@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
@@ -1,22 +1,30 @@
1
- import { isContractTemplateFieldType as e } from "./types.mjs";
2
- import { isAllowedContractTemplateRemoteUrl as t, normalizeContractTemplateControlOptions as n, normalizeContractTemplateJsonObject as r, normalizeContractTemplateRequestTimeout as i } from "./utils/advanced-controls.mjs";
3
- import { buildInitialRenderValues as a, buildTemplateRenderPages as o, isEmptyRenderValue as s, normalizeRenderValues as c, resolveTemplateRenderSubmitErrors as ee, validateTemplateRenderStructure as te, validateTemplateRenderValues as ne } from "./utils/template-renderer.mjs";
4
- import re from "./ContractTemplateRendererField.mjs";
5
- import ie from "./ContractTemplateRendererHeader.mjs";
6
- import ae from "./ContractTemplateRendererPage.mjs";
7
- import oe from "./ContractTemplateRendererValidation.mjs";
8
- import { Fragment as se, computed as l, createBlock as u, createCommentVNode as d, createElementBlock as f, createElementVNode as p, createSlots as ce, createTextVNode as le, createVNode as m, defineComponent as h, mergeProps as ue, nextTick as de, normalizeClass as fe, onBeforeUnmount as pe, openBlock as g, ref as _, renderList as me, renderSlot as he, toDisplayString as v, unref as y, watch as b, withCtx as x } from "vue";
9
- import { Button as ge, Empty as S, Input as _e, Modal as ve, Progress as ye, Segmented as be, Tooltip as xe } from "ant-design-vue";
10
- import { useElementSize as Se } from "@vueuse/core";
11
- import { LeftOutlined as Ce, RightOutlined as we, SearchOutlined as Te } from "@ant-design/icons-vue";
1
+ import { validateTemplateRenderValues as e } from "./utils/template-renderer.mjs";
2
+ import { resolveContractTemplateFileTabTargetIndex as t } from "./utils/file-tabs.mjs";
3
+ import n from "./ContractTemplateSingleRenderer.mjs";
4
+ import { useRendererFiles as r } from "./composables/use-renderer-files.mjs";
5
+ import { Fragment as i, createBlock as a, createElementBlock as o, createElementVNode as s, createSlots as c, defineComponent as l, guardReactiveProps as u, mergeProps as d, nextTick as f, normalizeProps as p, openBlock as m, ref as h, renderList as g, renderSlot as _, toDisplayString as v, unref as y, withCtx as b } from "vue";
12
6
  //#region src/components/pro-contract-template-designer/src/ProContractTemplateRenderer.vue?vue&type=script&setup=true&lang.ts
13
- var Ee = {
14
- key: 2,
15
- class: "gd-contract-template-renderer__empty"
16
- }, De = ["data-highlighted-variable-key"], Oe = { class: "gd-contract-template-renderer__pages" }, ke = ["aria-label", "aria-expanded"], Ae = { class: "gd-contract-template-renderer__panel-clip" }, je = { class: "gd-contract-template-renderer__panel" }, Me = { class: "gd-contract-template-renderer__panel-head" }, Ne = { class: "gd-contract-template-renderer__panel-head-row" }, Pe = { class: "gd-contract-template-renderer__panel-head-actions" }, Fe = { class: "gd-contract-template-renderer__field-group-head" }, Ie = { class: "gd-contract-template-renderer__field-group-items" }, Le = ["data-field-key"], Re = .5, ze = 1.5, C = .1, Be = 3e3, Ve = /* @__PURE__ */ h({
7
+ var x = {
8
+ class: "gd-contract-template-renderer__files",
9
+ "aria-label": "合同文件"
10
+ }, S = {
11
+ class: "gd-contract-template-renderer__file-tabs",
12
+ role: "tablist",
13
+ "aria-label": "合同文件列表"
14
+ }, C = [
15
+ "data-renderer-file-id",
16
+ "aria-selected",
17
+ "tabindex",
18
+ "disabled",
19
+ "onClick",
20
+ "onKeydown"
21
+ ], w = /* @__PURE__ */ l({
17
22
  name: "ProContractTemplateRenderer",
18
23
  __name: "ProContractTemplateRenderer",
19
24
  props: {
25
+ files: {},
26
+ activeFileId: {},
27
+ valuesByFile: {},
20
28
  template: { default: void 0 },
21
29
  values: { default: void 0 },
22
30
  interactionMode: { default: "panel" },
@@ -75,6 +83,8 @@ var Ee = {
75
83
  contractFontBaseUrl: { default: void 0 }
76
84
  },
77
85
  emits: [
86
+ "update:activeFileId",
87
+ "update:valuesByFile",
78
88
  "update:values",
79
89
  "change",
80
90
  "validate",
@@ -82,705 +92,108 @@ var Ee = {
82
92
  "update:zoom",
83
93
  "control-warning"
84
94
  ],
85
- setup(h, { expose: Ve, emit: He }) {
86
- let w = h, T = He, Ue = [
87
- {
88
- label: "全部",
89
- value: "all"
90
- },
91
- {
92
- label: "未填写",
93
- value: "unfilled"
94
- },
95
- {
96
- label: "有错误",
97
- value: "error"
98
- }
99
- ], We = _(), E = _(), Ge = _(), D = _(c(w.template, w.values)), Ke = _({ ...D.value }), O = _(!1), k = _([]), A = _(!1), j = _(!1), M = _(""), N = _(""), P = _(""), qe = _(0), F = _(Zt(w.zoom)), I = _(""), L = _("all"), R = _(!1), Je = _(/* @__PURE__ */ new Map()), z = /* @__PURE__ */ new Map(), Ye = /* @__PURE__ */ new Map(), B = /* @__PURE__ */ new Map(), Xe = /* @__PURE__ */ new Set(), { width: Ze } = Se(E), Qe = l(() => w.readonly || w.disabled), V = l(() => te(w.template)), $e = l(() => O.value ? k.value : V.value), H = l(() => (Array.isArray(w.template?.variables) ? w.template.variables : []).filter((t) => !!t?.key && e(t.type ?? "text"))), et = l(() => {
100
- let e = { ...D.value };
101
- return H.value.forEach((t) => {
102
- let n = jt(t);
103
- if (n?.toDisplayText) try {
104
- e[t.key] = n.toDisplayText(e[t.key], {
105
- variable: t,
106
- config: r(t.componentConfig)
107
- });
108
- } catch {}
109
- }), e;
110
- }), tt = l(() => H.value.filter((e) => s(D.value[e.key])).length), nt = l(() => {
111
- let e = /* @__PURE__ */ new Map();
112
- return $e.value.forEach((t) => {
113
- t.variableKey && e.set(t.variableKey, [...e.get(t.variableKey) ?? [], t]);
114
- }), e;
115
- }), U = l(() => {
116
- let e = w.interactionMode === "panel";
117
- return o(w.template, e ? et.value : Ke.value, {
118
- readonly: w.readonly,
119
- disabled: w.disabled,
120
- mode: e ? "display" : "control"
121
- });
122
- }), rt = l(() => {
123
- let e = /* @__PURE__ */ new Map(), t = new Set(H.value.map((e) => e.key));
124
- return U.value.forEach((n) => {
125
- Gt(n.contentHtml).forEach((r) => {
126
- t.has(r) && !e.has(r) && e.set(r, n.id);
127
- });
128
- }), e;
129
- }), it = l(() => H.value.filter(Bt)), at = l(() => {
130
- let e = U.value.map((e, t) => ({
131
- id: `page:${e.id}`,
132
- pageId: e.id,
133
- title: `第 ${t + 1} 页${e.title ? ` · ${e.title}` : ""}`,
134
- allVariables: [],
135
- variables: []
136
- })), t = new Map(e.map((e) => [e.pageId, e])), n = {
137
- id: "unlocated",
138
- title: "未定位字段",
139
- allVariables: [],
140
- variables: []
141
- };
142
- return H.value.forEach((e) => {
143
- let r = t.get(rt.value.get(e.key) ?? "") ?? n;
144
- r.allVariables.push(e), Bt(e) && r.variables.push(e);
145
- }), [...e, n].filter((e) => e.variables.length > 0).map((e) => ({
146
- id: e.id,
147
- title: e.title,
148
- totalCount: e.allVariables.length,
149
- variables: e.variables
150
- }));
151
- }), ot = l(() => U.value.length > 0), st = l(() => H.value.filter((e) => !s(D.value[e.key])).length), ct = l(() => H.value.filter((e) => e.required && s(D.value[e.key])).length), lt = l(() => H.value.length ? Math.round(st.value / H.value.length * 100) : 0), ut = l(() => O.value && k.value.length === 0), dt = l(() => O.value ? ut.value ? "校验通过,模板与填写值均符合规则" : `发现 ${k.value.length} 个模板或填写问题` : V.value.length ? `模板存在 ${V.value.length} 个问题,已安全降级展示` : ""), ft = l(() => O.value ? $e.value.length > 0 || j.value : V.value.length > 0);
152
- b(() => w.template, (e) => {
153
- W(c(e, w.values), !1), Ct();
154
- let t = Array.isArray(e?.pages) ? e.pages.map((e) => e?.id) : [];
155
- t.includes(P.value) || (P.value = t.find(Boolean) ?? ""), N.value && !H.value.some((e) => e.key === N.value) && Dt();
156
- }, { deep: !0 }), b(() => [
157
- w.template?.variables,
158
- w.optionResolver,
159
- w.requester,
160
- w.allowedRemoteOrigins,
161
- w.remoteRequestTimeoutMs,
162
- w.remoteOptionsCacheTtlMs
163
- ], () => {
164
- Nt();
165
- }, {
166
- deep: !0,
167
- immediate: !0
168
- }), b(() => w.values, (e) => {
169
- let t = c(w.template, e);
170
- Qt(t, D.value) || (W(t, !1, { refreshInlineHtml: w.interactionMode !== "inline" }), Ct());
171
- }, { deep: !0 }), b(() => w.interactionMode, (e) => {
172
- e === "inline" && (Ke.value = { ...D.value });
173
- }), b(() => w.collapsiblePanel, (e) => {
174
- e || (R.value = !1);
175
- }), b(() => w.zoom, (e) => F.value = Zt(e)), b(U, (e) => {
176
- !P.value && e.length && (P.value = e[0].id);
177
- }, { immediate: !0 });
178
- function W(e, t = !0, n = {}) {
179
- D.value = { ...e }, n.refreshInlineHtml !== !1 && (Ke.value = { ...e }), t && (T("update:values", { ...D.value }), T("change", { ...D.value }));
180
- }
181
- function G(e, t) {
182
- !e || Qe.value || (W({
183
- ...D.value,
184
- [e]: t
185
- }, !0, { refreshInlineHtml: w.interactionMode !== "inline" }), O.value && yt());
186
- }
187
- function pt(e) {
188
- if (w.interactionMode !== "inline") return;
189
- let t = e.target;
190
- if (!(t instanceof HTMLInputElement) && !(t instanceof HTMLTextAreaElement)) return;
191
- let n = t.dataset.key || "";
192
- n && (t instanceof HTMLInputElement && t.type === "checkbox" ? G(n, t.checked) : t instanceof HTMLInputElement && t.type === "number" ? G(n, t.value === "" ? void 0 : t.valueAsNumber) : G(n, t.value));
193
- }
194
- function mt(e) {
195
- let t = e.target;
196
- if (!(t instanceof Element)) return;
197
- let n = t.closest("[data-render-page-id]");
198
- n?.dataset.renderPageId && (P.value = n.dataset.renderPageId);
199
- let r = t.closest("[data-contract-render-wrapper], [data-contract-render-control]")?.dataset.key || "";
200
- r && Y(r);
201
- }
202
- function ht(e) {
203
- let t = U.value.find((t) => t.id === e.pageId), n = H.value.some((t) => t.key === e.key);
204
- if (!(!t || !n || !Gt(t.contentHtml).has(e.key)) && !(e.kind === "input" && w.interactionMode !== "inline")) {
205
- if (P.value = e.pageId, e.kind === "input") {
206
- G(e.key, e.value);
207
- return;
208
- }
209
- Y(e.key);
210
- }
211
- }
212
- function gt(e) {
213
- if (e.key !== "Enter" && e.key !== " ") return;
214
- let t = e.target;
215
- !(t instanceof HTMLElement) || !t.dataset.key || (e.preventDefault(), Y(t.dataset.key));
216
- }
217
- function _t() {
218
- return { ...D.value };
219
- }
220
- function vt(e) {
221
- W(c(w.template, e));
222
- }
223
- function yt() {
224
- let e = ne(w.template, D.value);
225
- return wt(e), T("validate", e), e;
226
- }
227
- function bt() {
228
- let e = ee(w.template, D.value, w.validateOnSubmit);
229
- if ((w.validateOnSubmit || e.length) && (wt(e), T("validate", e)), e.length) return kt(e[0]), !1;
230
- let t = _t();
231
- return T("submit", t), t;
232
- }
233
- function xt() {
234
- return W(a(w.template)), Ct(), _t();
235
- }
236
- function St() {
237
- Qe.value || ve.confirm({
238
- title: "重置填写内容?",
239
- content: "将恢复模板中的默认值,当前未提交的填写内容会被覆盖。",
240
- okText: "确认重置",
241
- cancelText: "取消",
242
- onOk: () => xt()
243
- });
244
- }
245
- function Ct() {
246
- O.value = !1, k.value = [], A.value = !1, j.value = !1, q();
247
- }
248
- function wt(e) {
249
- if (k.value = e, O.value = !0, A.value = !1, e.length) {
250
- j.value = !1, q();
251
- return;
252
- }
253
- Tt();
254
- }
255
- let K;
256
- function q() {
257
- K &&= (clearTimeout(K), void 0);
258
- }
259
- function Tt() {
260
- q(), j.value = !0, K = setTimeout(() => {
261
- j.value = !1, K = void 0;
262
- }, Be);
263
- }
264
- function J(e) {
265
- Y(e, !0);
266
- }
267
- function Et(e) {
268
- w.interactionMode === "panel" && (R.value &&= !1, H.value.some((t) => t.key === e) && !it.value.some((t) => t.key === e) && Vt());
269
- }
270
- function Y(e, t = !1) {
271
- if (!e) return;
272
- Et(e), N.value = e, M.value = e;
273
- let n = rt.value.get(e);
274
- n && (P.value = n), t && (qe.value += 1), de(() => {
275
- Ot(e);
276
- let r = n ? E.value?.querySelector(`[data-render-page-id="${$(n)}"]`) : void 0;
277
- t && r?.scrollIntoView({
278
- behavior: "smooth",
279
- block: "center",
280
- inline: "center"
281
- }), w.interactionMode === "panel" && Ge.value?.querySelector(`[data-field-key="${$(e)}"]`)?.scrollIntoView({
282
- behavior: "smooth",
283
- block: "nearest"
284
- });
285
- });
286
- }
287
- function Dt() {
288
- N.value = "", M.value = "", Ot("");
289
- }
290
- function Ot(e) {
291
- E.value?.querySelectorAll("[data-contract-render-wrapper], [data-contract-render-control]").forEach((t) => t.classList.toggle("is-active", !!e && t.dataset.key === e));
292
- }
293
- function kt(e) {
294
- e.variableKey ? J(e.variableKey) : e.pageId && Xt(e.pageId);
295
- }
296
- function At(e) {
297
- return nt.value.get(e) ?? [];
298
- }
299
- function X(e) {
300
- return Je.value.get(e.key) ?? {
301
- options: e.options ?? [],
302
- loading: !1
303
- };
304
- }
305
- function jt(e) {
306
- let t = e.componentKey || e.type || "";
307
- return t ? w.controlRegistry?.[t] : void 0;
308
- }
309
- function Z(e, t) {
310
- let n = new Map(Je.value);
311
- n.set(e, t), Je.value = n;
312
- }
313
- function Mt(e) {
314
- T("control-warning", e);
315
- }
316
- async function Nt() {
317
- z.forEach((e) => e.abort()), z.clear(), Ye.clear(), Xe.clear();
318
- let e = Array.isArray(w.template?.variables) ? w.template.variables : [];
319
- await Promise.all(e.map(async (e) => {
320
- if (!e?.key) return;
321
- let t = Array.isArray(e.options) ? e.options.map((e) => ({ ...e })) : [];
322
- if (e.dataSource ? await Pt(e, t) : Z(e.key, {
323
- options: t,
324
- loading: !1
325
- }), e.type === "custom" && !jt(e)) {
326
- let t = e.componentKey || "", n = `${e.key}:${t}`;
327
- Xe.has(n) || (Xe.add(n), Mt({
328
- code: "CONTROL_COMPONENT_MISSING",
329
- variableKey: e.key,
330
- componentKey: t,
331
- message: `${e.label || e.key} 未注册自定义控件 ${t || "(空)"}`
332
- }));
333
- }
334
- }));
335
- }
336
- async function Pt(e, n) {
337
- let r = e.dataSource;
338
- if (!r) return;
339
- let i = new AbortController();
340
- z.set(e.key, i), Z(e.key, {
341
- options: n,
342
- loading: !0
343
- });
344
- let a = Ft(e), o = Date.now(), s = Ye.get(a);
345
- if (s && s.expiresAt > o) {
346
- Z(e.key, {
347
- options: s.options,
348
- loading: !1
349
- }), z.delete(e.key);
350
- return;
351
- }
352
- let c = "CONTROL_OPTIONS_LOAD_FAILED";
353
- try {
354
- r.kind === "url" && !t(r.url, w.allowedRemoteOrigins) && (c = "CONTROL_REMOTE_URL_BLOCKED");
355
- let o = B.get(a);
356
- o || (o = It(e, r, c, i), B.set(a, o), o.finally(() => {
357
- B.get(a) === o && B.delete(a);
358
- }).catch(() => void 0));
359
- let s = await o;
360
- if (i.signal.aborted) return;
361
- let ee = Math.max(0, Number(w.remoteOptionsCacheTtlMs) || 0);
362
- ee > 0 && Ye.set(a, {
363
- options: s,
364
- expiresAt: Date.now() + ee
365
- }), Z(e.key, {
366
- options: s.length ? s : n,
367
- loading: !1
368
- });
369
- } catch (t) {
370
- let r = t instanceof Error && t.message.startsWith("高级控件请求超时");
371
- if (i.signal.aborted && !r) return;
372
- let a = t instanceof Error ? t.message : "高级控件选项加载失败";
373
- Z(e.key, {
374
- options: n,
375
- loading: !1,
376
- error: a
377
- }), Mt({
378
- code: c,
379
- variableKey: e.key,
380
- message: `${e.label || e.key}:${a}`,
381
- cause: t
382
- });
383
- } finally {
384
- z.get(e.key) === i && z.delete(e.key);
385
- }
386
- }
387
- function Ft(e) {
388
- try {
389
- return JSON.stringify([e.type, e.dataSource]);
390
- } catch {
391
- return `${e.key}:${e.type}`;
392
- }
393
- }
394
- async function It(e, r, a, o) {
395
- let s;
396
- if (r.kind === "resolver") {
397
- if (!w.optionResolver) throw Error(`缺少 resolver ${r.resolverKey} 的宿主实现`);
398
- s = await w.optionResolver({
399
- resolverKey: r.resolverKey,
400
- params: r.params,
401
- variable: e,
402
- signal: o.signal
403
- });
404
- } else {
405
- if (!t(r.url, w.allowedRemoteOrigins)) throw Error(`远程地址未在 allowlist 中:${r.url}`);
406
- if (!w.requester) throw Error("缺少宿主 requester,组件库不会直接发起网络请求");
407
- let n = i(r.timeoutMs, w.remoteRequestTimeoutMs);
408
- s = await Lt(w.requester({
409
- url: r.url,
410
- method: r.method || "GET",
411
- params: r.params,
412
- headers: r.headers,
413
- timeoutMs: n,
414
- signal: o.signal,
415
- variable: e
416
- }), o, n);
417
- }
418
- return n(s, r.kind === "url" ? r : void 0, e.type || "select");
419
- }
420
- function Lt(e, t, n) {
421
- return new Promise((r, i) => {
422
- let a = () => {
423
- clearTimeout(c), t.signal.removeEventListener("abort", s);
424
- }, o = (e) => {
425
- a(), e();
426
- }, s = () => o(() => i(/* @__PURE__ */ Error("高级控件请求已取消"))), c = setTimeout(() => {
427
- o(() => i(/* @__PURE__ */ Error(`高级控件请求超时(${n}ms)`))), t.abort();
428
- }, n);
429
- t.signal.addEventListener("abort", s, { once: !0 }), e.then((e) => o(() => r(e)), (e) => o(() => i(e)));
430
- });
431
- }
432
- function Rt(e) {
433
- let t = X(e);
434
- return {
435
- variable: e,
436
- value: D.value[e.key],
437
- errors: At(e.key),
438
- active: N.value === e.key,
439
- readonly: w.readonly,
440
- disabled: w.disabled,
441
- options: t.options,
442
- loading: t.loading,
443
- loadError: t.error,
444
- updateValue: (t) => G(e.key, t),
445
- focusVariable: () => J(e.key)
446
- };
447
- }
448
- function zt() {
449
- let e = H.value;
450
- if (!e.length) return;
451
- let t = e.findIndex((e) => e.key === N.value), n = t < 0 ? 0 : t + 1;
452
- for (let t = 0; t < e.length; t += 1) {
453
- let r = e[(n + t) % e.length];
454
- if (s(D.value[r.key])) {
455
- J(r.key);
456
- return;
457
- }
458
- }
459
- }
460
- function Bt(e) {
461
- let t = I.value.trim().toLocaleLowerCase();
462
- return !t || e.key.toLocaleLowerCase().includes(t) || (e.label ?? "").toLocaleLowerCase().includes(t) ? L.value === "unfilled" ? s(D.value[e.key]) : L.value === "error" ? At(e.key).length > 0 : !0 : !1;
463
- }
464
- function Vt() {
465
- I.value = "", L.value = "all";
466
- }
467
- function Ht(e, t) {
468
- let n = it.value;
469
- if (!n.length) return;
470
- let r = n.findIndex((t) => t.key === e), i = n[r < 0 ? 0 : (r + t + n.length) % n.length]?.key;
471
- i && (J(i), de(() => Ut(i)));
472
- }
473
- function Ut(e) {
474
- (Ge.value?.querySelector(`[data-field-key="${$(e)}"]`))?.querySelector("input:not([disabled]), textarea:not([disabled]), button:not([disabled])")?.focus();
475
- }
476
- function Wt(e) {
477
- if (e.key !== "Enter" || e.target instanceof HTMLTextAreaElement) return;
478
- let t = e.target;
479
- if (!(t instanceof Element)) return;
480
- let n = t.closest("[data-field-key]")?.dataset.fieldKey;
481
- n && (e.preventDefault(), Ht(n, e.shiftKey ? -1 : 1));
482
- }
483
- function Gt(e) {
484
- let t = /* @__PURE__ */ new Set();
485
- if (typeof DOMParser < "u") return new DOMParser().parseFromString(e, "text/html").querySelectorAll("[data-key]").forEach((e) => {
486
- let n = e.getAttribute("data-key")?.trim();
487
- n && t.add(n);
488
- }), t;
489
- let n = /\bdata-key\s*=\s*(?:"([^"]+)"|'([^']+)'|([^\s>]+))/gi, r;
490
- for (; r = n.exec(e);) {
491
- let e = (r[1] ?? r[2] ?? r[3] ?? "").trim();
492
- e && t.add(e);
493
- }
494
- return t;
495
- }
496
- function Kt() {
497
- !w.collapsiblePanel || w.interactionMode !== "panel" || (R.value = !R.value);
498
- }
499
- function Q(e) {
500
- let t = Zt(e);
501
- return F.value = t, T("update:zoom", t), t;
502
- }
503
- function qt() {
504
- return Q(1);
505
- }
506
- function Jt() {
507
- return F.value;
508
- }
509
- function Yt() {
510
- let e = Math.max(...U.value.map((e) => e.width), 1);
511
- return Q(Math.max(0, Ze.value - 48) / e);
512
- }
513
- function Xt(e) {
514
- e && (P.value = e, de(() => {
515
- E.value?.querySelector(`[data-render-page-id="${$(e)}"]`)?.scrollIntoView({
516
- behavior: "smooth",
517
- block: "start",
518
- inline: "center"
519
- });
95
+ setup(l, { expose: w, emit: T }) {
96
+ let E = l, D = T, O = h(), { enabled: k, files: A, activeId: j, activeFile: M, values: N, fileErrors: P, select: F, update: I, getAllValues: L, validateAll: R } = r(E, (e) => D("update:activeFileId", e), (e) => D("update:valuesByFile", e));
97
+ function z(e) {
98
+ k.value ? I(e) : D("update:values", e);
99
+ }
100
+ function B(e) {
101
+ D("validate", k.value ? e.map((e) => ({
102
+ ...e,
103
+ fileId: j.value || void 0
104
+ })) : e);
105
+ }
106
+ function V() {
107
+ let t = O.value?.validate() ?? e(E.template, E.values ?? {});
108
+ return k.value ? t.map((e) => ({
109
+ ...e,
110
+ fileId: j.value || void 0
111
+ })) : t;
112
+ }
113
+ function H() {
114
+ if (!k.value) return V();
115
+ let e = R();
116
+ D("validate", e);
117
+ let t = e[0];
118
+ return t?.fileId && A.value.some((e) => e.id === t.fileId) && !E.disabled ? (F(t.fileId), f(() => {
119
+ j.value === t.fileId && (O.value?.showValidation(e.filter((e) => e.fileId === j.value)), O.value?.focusError(t));
120
+ })) : O.value?.showValidation(e.filter((e) => !e.fileId || e.fileId === j.value)), e;
121
+ }
122
+ function U(e, n) {
123
+ if (E.disabled) return;
124
+ let r = t(n, e.key, A.value.length), i = r === void 0 ? void 0 : A.value[r];
125
+ i && (e.preventDefault(), F(i.id), f(() => {
126
+ let e = (O.value?.$el)?.querySelectorAll("[data-renderer-file-id]") ?? [];
127
+ Array.from(e).find((e) => e.dataset.rendererFileId === i.id)?.focus();
520
128
  }));
521
129
  }
522
- function Zt(e) {
523
- let t = Number(e);
524
- return Number.isFinite(t) ? Math.min(ze, Math.max(Re, Math.round(t * 100) / 100)) : 1;
525
- }
526
- function $(e) {
527
- return e.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"");
528
- }
529
- function Qt(e, t) {
530
- let n = new Set([...Object.keys(e), ...Object.keys(t)]);
531
- return Array.from(n).every((n) => e[n] === t[n]);
532
- }
533
- function $t(e) {
534
- !(e.ctrlKey || e.metaKey) || !ot.value || (e.preventDefault(), Q(e.deltaY > 0 ? F.value - C : F.value + C));
535
- }
536
- let en;
537
- function tn() {
538
- en?.removeEventListener("wheel", $t), en = void 0;
539
- }
540
- function nn(e) {
541
- tn(), e && (e.addEventListener("wheel", $t, { passive: !1 }), en = e);
542
- }
543
- return b(E, (e) => {
544
- nn(e);
545
- }, { immediate: !0 }), pe(() => {
546
- tn(), q(), z.forEach((e) => e.abort()), z.clear();
547
- }), Ve({
548
- getValues: _t,
549
- setValues: vt,
550
- validate: yt,
551
- submit: bt,
552
- resetValues: xt,
553
- scrollToVariable: J,
554
- setZoom: Q,
555
- resetZoom: qt,
556
- getZoom: Jt,
557
- fitWidth: Yt,
558
- scrollToPage: Xt
559
- }), (e, t) => (g(), f("section", {
560
- ref_key: "rendererElement",
561
- ref: We,
562
- class: fe(["gd-contract-template-renderer", {
563
- "is-disabled": h.disabled,
564
- "is-readonly": h.readonly,
565
- "is-panel": h.interactionMode === "panel",
566
- "is-inline": h.interactionMode === "inline"
567
- }]),
568
- onClick: mt,
569
- onKeydown: gt,
570
- onInput: pt,
571
- onChange: pt
572
- }, [
573
- ot.value ? (g(), u(ie, {
574
- key: 0,
575
- title: h.title,
576
- "filled-count": st.value,
577
- "total-count": H.value.length,
578
- "required-missing-count": ct.value,
579
- zoom: F.value,
580
- pages: U.value,
581
- "active-page-id": P.value,
582
- "min-zoom": Re,
583
- "max-zoom": ze,
584
- "show-toolbar": h.showToolbar,
585
- "show-validate-button": h.showValidateButton,
586
- "show-reset-button": h.showResetButton,
587
- "show-submit-button": h.showSubmitButton,
588
- "show-panel-toggle": h.interactionMode === "panel" && h.collapsiblePanel,
589
- "panel-collapsed": R.value,
590
- readonly: h.readonly,
591
- disabled: h.disabled,
592
- onZoomIn: t[0] ||= (e) => Q(F.value + C),
593
- onZoomOut: t[1] ||= (e) => Q(F.value - C),
594
- onResetZoom: qt,
595
- onFitWidth: Yt,
596
- onSelectPage: Xt,
597
- onValidate: yt,
598
- onReset: St,
599
- onSubmit: bt,
600
- onTogglePanel: Kt
601
- }, {
602
- extra: x(() => [he(e.$slots, "headerExtra")]),
603
- _: 3
604
- }, 8, [
605
- "title",
606
- "filled-count",
607
- "total-count",
608
- "required-missing-count",
609
- "zoom",
610
- "pages",
611
- "active-page-id",
612
- "show-toolbar",
613
- "show-validate-button",
614
- "show-reset-button",
615
- "show-submit-button",
616
- "show-panel-toggle",
617
- "panel-collapsed",
618
- "readonly",
619
- "disabled"
620
- ])) : d("", !0),
621
- ft.value ? (g(), u(oe, {
622
- key: 1,
623
- passed: ut.value,
624
- summary: dt.value,
625
- errors: $e.value,
626
- expanded: A.value,
627
- onToggle: t[2] ||= (e) => A.value = !A.value,
628
- onFocusError: kt
629
- }, null, 8, [
630
- "passed",
631
- "summary",
632
- "errors",
633
- "expanded"
634
- ])) : d("", !0),
635
- ot.value ? (g(), f("div", {
636
- key: 3,
637
- class: fe(["gd-contract-template-renderer__workspace", { "is-inline": h.interactionMode === "inline" }])
638
- }, [p("div", {
639
- ref_key: "pagesViewportElement",
640
- ref: E,
641
- class: "gd-contract-template-renderer__pages-viewport",
642
- "data-highlighted-variable-key": M.value
643
- }, [p("div", Oe, [(g(!0), f(se, null, me(U.value, (e, t) => (g(), u(ae, {
644
- key: e.id,
645
- page: e,
646
- index: t,
647
- total: U.value.length,
648
- zoom: F.value,
649
- "show-meta": h.showPageMeta,
650
- "font-base-url": h.contractFontBaseUrl,
651
- "active-key": M.value,
652
- "scroll-request": qe.value,
653
- onInteraction: ht
654
- }, null, 8, [
655
- "page",
656
- "index",
657
- "total",
658
- "zoom",
659
- "show-meta",
660
- "font-base-url",
661
- "active-key",
662
- "scroll-request"
663
- ]))), 128))])], 8, De), h.interactionMode === "panel" ? (g(), f("div", {
664
- key: 0,
665
- class: fe(["gd-contract-template-renderer__panel-wrap", { "is-collapsed": R.value && h.collapsiblePanel }])
666
- }, [h.collapsiblePanel ? (g(), u(y(xe), {
667
- key: 0,
668
- title: R.value ? "展开填写面板" : "收起填写面板"
669
- }, {
670
- default: x(() => [p("button", {
130
+ return w({
131
+ getAllValues: L,
132
+ validateAll: H,
133
+ getValues: () => O.value?.getValues() ?? {},
134
+ setValues: (e) => {
135
+ (!k.value || !E.disabled) && O.value?.setValues(e);
136
+ },
137
+ resetValues: () => k.value && E.disabled ? O.value?.getValues() ?? {} : O.value?.resetValues() ?? {},
138
+ validate: V,
139
+ submit: () => O.value?.submit() ?? !1,
140
+ scrollToVariable: (e) => O.value?.scrollToVariable(e),
141
+ scrollToPage: (e) => O.value?.scrollToPage(e),
142
+ setZoom: (e) => O.value?.setZoom(e) ?? 1,
143
+ resetZoom: () => O.value?.resetZoom() ?? 1,
144
+ getZoom: () => O.value?.getZoom() ?? 1,
145
+ fitWidth: () => O.value?.fitWidth() ?? 1
146
+ }), (e, t) => (m(), a(n, d({
147
+ key: y(k) ? `file:${y(j)}` : "single",
148
+ ref_key: "renderer",
149
+ ref: O
150
+ }, E, {
151
+ class: { "is-multi-file": y(k) },
152
+ template: y(k) ? y(M)?.template : l.template,
153
+ values: y(k) ? y(N)[y(j)] : E.values,
154
+ "onUpdate:values": z,
155
+ onChange: t[0] ||= (e) => D("change", e),
156
+ onValidate: B,
157
+ onSubmit: t[1] ||= (e) => D("submit", e),
158
+ "onUpdate:zoom": t[2] ||= (e) => D("update:zoom", e),
159
+ onControlWarning: t[3] ||= (e) => D("control-warning", e)
160
+ }), c({ _: 2 }, [
161
+ y(k) ? {
162
+ name: "fileBar",
163
+ fn: b(() => [s("nav", x, [s("div", S, [(m(!0), o(i, null, g(y(A), (e, t) => (m(), o("button", {
164
+ key: e.id,
671
165
  type: "button",
672
- class: "gd-contract-template-renderer__panel-handle",
673
- "aria-label": R.value ? "展开填写面板" : "收起填写面板",
674
- "aria-expanded": !R.value,
675
- onClick: t[3] ||= (e) => R.value = !R.value
676
- }, [R.value ? (g(), u(y(Ce), {
677
- key: 0,
678
- "aria-hidden": "true"
679
- })) : (g(), u(y(we), {
680
- key: 1,
681
- "aria-hidden": "true"
682
- }))], 8, ke)]),
683
- _: 1
684
- }, 8, ["title"])) : d("", !0), p("div", Ae, [p("aside", je, [p("div", Me, [
685
- p("div", Ne, [p("div", null, [t[6] ||= p("strong", null, "填写项", -1), p("span", null, v(st.value) + " / " + v(H.value.length) + " 已填写", 1)]), p("span", null, v(ct.value ? `${ct.value} 项必填未完成` : "必填项已完成"), 1)]),
686
- m(y(_e), {
687
- value: I.value,
688
- "onUpdate:value": t[4] ||= (e) => I.value = e,
689
- "allow-clear": "",
690
- size: "small",
691
- class: "gd-contract-template-renderer__field-search",
692
- placeholder: "搜索字段名称或标识"
693
- }, {
694
- prefix: x(() => [m(y(Te), { "aria-hidden": "true" })]),
695
- _: 1
696
- }, 8, ["value"]),
697
- p("div", Pe, [m(y(be), {
698
- value: L.value,
699
- "onUpdate:value": t[5] ||= (e) => L.value = e,
700
- size: "small",
701
- class: "gd-contract-template-renderer__field-filter",
702
- options: Ue
703
- }, null, 8, ["value"]), m(y(ge), {
704
- size: "small",
705
- disabled: !tt.value,
706
- onClick: zt
707
- }, {
708
- default: x(() => [...t[7] ||= [le(" 下一个未填项 ", -1)]]),
709
- _: 1
710
- }, 8, ["disabled"])]),
711
- m(y(ye), {
712
- percent: lt.value,
713
- size: "small",
714
- "show-info": !1
715
- }, null, 8, ["percent"])
716
- ]), it.value.length ? (g(), f("div", {
717
- key: 1,
718
- ref_key: "fieldListElement",
719
- ref: Ge,
720
- class: "gd-contract-template-renderer__field-list",
721
- onKeydownCapture: Wt
722
- }, [(g(!0), f(se, null, me(at.value, (t) => (g(), f("div", {
723
- key: t.id,
724
- class: "gd-contract-template-renderer__field-group"
725
- }, [p("div", Fe, [p("strong", null, v(t.title), 1), p("span", null, v(t.variables.length) + " / " + v(t.totalCount) + " 项", 1)]), p("div", Ie, [(g(!0), f(se, null, me(t.variables, (t) => (g(), f("div", {
726
- key: t.id || t.key,
727
- "data-field-key": t.key
728
- }, [he(e.$slots, "field", ue({ ref_for: !0 }, Rt(t)), () => [m(re, {
729
- variable: t,
730
- value: D.value[t.key],
731
- errors: At(t.key),
732
- active: N.value === t.key,
733
- readonly: h.readonly,
734
- disabled: h.disabled,
735
- options: X(t).options,
736
- loading: X(t).loading,
737
- "load-error": X(t).error,
738
- registration: jt(t),
739
- "selector-http": h.selectorHttp,
740
- "selector-url-prefix": h.selectorUrlPrefix,
741
- onUpdateValue: (e) => G(t.key, e),
742
- onFocusVariable: (e) => J(t.key)
743
- }, null, 8, [
744
- "variable",
745
- "value",
746
- "errors",
747
- "active",
748
- "readonly",
749
- "disabled",
750
- "options",
751
- "loading",
752
- "load-error",
753
- "registration",
754
- "selector-http",
755
- "selector-url-prefix",
756
- "onUpdateValue",
757
- "onFocusVariable"
758
- ])])], 8, Le))), 128))])]))), 128))], 544)) : (g(), u(y(S), {
759
- key: 0,
760
- class: "gd-contract-template-renderer__field-empty",
761
- description: H.value.length ? "没有符合条件的填写项" : "暂无填写项",
762
- image: y(S).PRESENTED_IMAGE_SIMPLE
763
- }, ce({
764
- default: x(() => [I.value || L.value !== "all" ? (g(), u(y(ge), {
765
- key: 0,
766
- type: "link",
767
- size: "small",
768
- onClick: Vt
769
- }, {
770
- default: x(() => [...t[9] ||= [le("清除筛选", -1)]]),
771
- _: 1
772
- })) : d("", !0)]),
773
- _: 2
774
- }, [I.value || L.value !== "all" ? {
775
- name: "description",
776
- fn: x(() => [t[8] ||= p("span", null, "没有符合条件的填写项", -1)]),
166
+ role: "tab",
167
+ class: "gd-contract-template-renderer__file-tab",
168
+ "data-renderer-file-id": e.id,
169
+ "aria-selected": y(j) === e.id,
170
+ tabindex: y(j) === e.id ? 0 : -1,
171
+ disabled: l.disabled,
172
+ onClick: (t) => y(F)(e.id),
173
+ onKeydown: (e) => U(e, t)
174
+ }, v(e.name || e.id), 41, C))), 128))]), (m(!0), o(i, null, g(y(P), (e) => (m(), o("p", {
175
+ key: e.id,
176
+ class: "gd-contract-template-renderer__file-error",
177
+ role: "alert"
178
+ }, v(e.message), 1))), 128))])]),
777
179
  key: "0"
778
- } : void 0]), 1032, ["description", "image"]))])])], 2)) : d("", !0)], 2)) : (g(), f("div", Ee, [m(y(S), {
779
- description: "暂无可渲染的合同页面",
780
- image: y(S).PRESENTED_IMAGE_SIMPLE
781
- }, null, 8, ["image"])]))
782
- ], 34));
180
+ } : void 0,
181
+ e.$slots.field ? {
182
+ name: "field",
183
+ fn: b((t) => [_(e.$slots, "field", p(u(t)))]),
184
+ key: "1"
185
+ } : void 0,
186
+ e.$slots.headerExtra ? {
187
+ name: "headerExtra",
188
+ fn: b(() => [_(e.$slots, "headerExtra")]),
189
+ key: "2"
190
+ } : void 0
191
+ ]), 1040, [
192
+ "class",
193
+ "template",
194
+ "values"
195
+ ]));
783
196
  }
784
197
  });
785
198
  //#endregion
786
- export { Ve as default };
199
+ export { w as default };