@superdoc-dev/esign 1.4.2 → 2.0.0-next.1
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.
- package/LICENSE +661 -0
- package/README.md +11 -11
- package/dist/__tests__/signature.test.d.ts +2 -0
- package/dist/__tests__/signature.test.d.ts.map +1 -0
- package/dist/defaults/DownloadButton.d.ts.map +1 -1
- package/dist/defaults/SubmitButton.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +299 -216
- package/dist/types.d.ts +23 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/signature.d.ts +2 -0
- package/dist/utils/signature.d.ts.map +1 -0
- package/package.json +3 -4
- package/src/styles.css +26 -0
package/dist/index.mjs
CHANGED
|
@@ -1,24 +1,29 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
1
|
+
import { jsxs as b, jsx as d } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as ye, useState as v, useRef as C, useEffect as A, useCallback as D, useImperativeHandle as ve } from "react";
|
|
3
|
+
const be = (u) => {
|
|
4
|
+
const l = globalThis.document.createElement("canvas"), s = l.getContext("2d"), o = 30;
|
|
5
|
+
s.font = `italic ${o}px cursive`;
|
|
6
|
+
const a = s.measureText(u).width, m = o * 1.3, p = 4, R = 6;
|
|
7
|
+
return l.width = Math.ceil(a + p * 2) + 20, l.height = Math.ceil(m + R * 2), s.font = `italic ${o}px cursive`, s.fillStyle = "black", s.textAlign = "center", s.textBaseline = "middle", s.fillText(u, l.width / 2, l.height / 2), l.toDataURL("image/png");
|
|
8
|
+
}, xe = ({
|
|
9
|
+
value: u,
|
|
10
|
+
onChange: l,
|
|
11
|
+
isDisabled: s,
|
|
12
|
+
label: o
|
|
13
|
+
}) => /* @__PURE__ */ b(
|
|
9
14
|
"div",
|
|
10
15
|
{
|
|
11
16
|
className: "superdoc-esign-signature-input",
|
|
12
17
|
style: { display: "flex", flexDirection: "column", gap: "8px" },
|
|
13
18
|
children: [
|
|
14
|
-
|
|
15
|
-
/* @__PURE__ */
|
|
19
|
+
o && /* @__PURE__ */ d("label", { children: o }),
|
|
20
|
+
/* @__PURE__ */ d(
|
|
16
21
|
"input",
|
|
17
22
|
{
|
|
18
23
|
type: "text",
|
|
19
|
-
value: String(
|
|
20
|
-
onChange: (r) =>
|
|
21
|
-
disabled:
|
|
24
|
+
value: String(u || ""),
|
|
25
|
+
onChange: (r) => l(r.target.value),
|
|
26
|
+
disabled: s,
|
|
22
27
|
placeholder: "Type your full name",
|
|
23
28
|
style: {
|
|
24
29
|
fontFamily: "cursive",
|
|
@@ -28,323 +33,401 @@ const ue = ({
|
|
|
28
33
|
)
|
|
29
34
|
]
|
|
30
35
|
}
|
|
31
|
-
),
|
|
32
|
-
value:
|
|
33
|
-
onChange:
|
|
34
|
-
isDisabled:
|
|
35
|
-
label:
|
|
36
|
-
}) => /* @__PURE__ */
|
|
37
|
-
/* @__PURE__ */
|
|
36
|
+
), we = ({
|
|
37
|
+
value: u,
|
|
38
|
+
onChange: l,
|
|
39
|
+
isDisabled: s,
|
|
40
|
+
label: o
|
|
41
|
+
}) => /* @__PURE__ */ b("label", { className: "superdoc-esign-checkbox-input", style: { display: "flex", gap: "8px" }, children: [
|
|
42
|
+
/* @__PURE__ */ d(
|
|
38
43
|
"input",
|
|
39
44
|
{
|
|
40
45
|
type: "checkbox",
|
|
41
|
-
checked: !!
|
|
42
|
-
onChange: (r) =>
|
|
43
|
-
disabled:
|
|
46
|
+
checked: !!u,
|
|
47
|
+
onChange: (r) => l(r.target.checked),
|
|
48
|
+
disabled: s
|
|
44
49
|
}
|
|
45
50
|
),
|
|
46
|
-
/* @__PURE__ */
|
|
47
|
-
] }),
|
|
48
|
-
|
|
49
|
-
|
|
51
|
+
/* @__PURE__ */ d("span", { children: o })
|
|
52
|
+
] }), Se = (u) => ({
|
|
53
|
+
onClick: s,
|
|
54
|
+
fileName: o,
|
|
55
|
+
isDisabled: r,
|
|
56
|
+
isDownloading: a
|
|
57
|
+
}) => {
|
|
58
|
+
const m = u?.label || "Download", p = r || a;
|
|
59
|
+
return /* @__PURE__ */ b(
|
|
50
60
|
"button",
|
|
51
61
|
{
|
|
52
|
-
onClick:
|
|
53
|
-
disabled:
|
|
54
|
-
className:
|
|
62
|
+
onClick: s,
|
|
63
|
+
disabled: p,
|
|
64
|
+
className: `superdoc-esign-btn superdoc-esign-btn--download${a ? " superdoc-esign-btn--loading" : ""}`,
|
|
55
65
|
style: {
|
|
56
66
|
padding: "8px 16px",
|
|
57
67
|
borderRadius: "6px",
|
|
58
68
|
border: "1px solid #d0d5dd",
|
|
59
69
|
background: "#ffffff",
|
|
60
70
|
color: "#333",
|
|
61
|
-
cursor:
|
|
62
|
-
opacity:
|
|
71
|
+
cursor: p ? "not-allowed" : "pointer",
|
|
72
|
+
opacity: p ? 0.7 : 1,
|
|
63
73
|
fontSize: "16px",
|
|
64
|
-
fontWeight: "bold"
|
|
74
|
+
fontWeight: "bold",
|
|
75
|
+
display: "inline-flex",
|
|
76
|
+
alignItems: "center",
|
|
77
|
+
gap: "8px",
|
|
78
|
+
transition: "opacity 0.2s ease"
|
|
65
79
|
},
|
|
66
80
|
children: [
|
|
67
|
-
|
|
68
|
-
"
|
|
69
|
-
|
|
81
|
+
a && /* @__PURE__ */ d("span", { className: "superdoc-esign-spinner" }),
|
|
82
|
+
a ? "Downloading..." : m,
|
|
83
|
+
!a && o && ` (${o})`
|
|
70
84
|
]
|
|
71
85
|
}
|
|
72
86
|
);
|
|
73
|
-
},
|
|
74
|
-
onClick:
|
|
75
|
-
isValid:
|
|
87
|
+
}, Ce = (u) => ({
|
|
88
|
+
onClick: s,
|
|
89
|
+
isValid: o,
|
|
76
90
|
isDisabled: r,
|
|
77
|
-
isSubmitting:
|
|
78
|
-
}) =>
|
|
79
|
-
"
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
91
|
+
isSubmitting: a
|
|
92
|
+
}) => {
|
|
93
|
+
const m = u?.label || "Submit", p = !o || r || a;
|
|
94
|
+
return /* @__PURE__ */ b(
|
|
95
|
+
"button",
|
|
96
|
+
{
|
|
97
|
+
onClick: s,
|
|
98
|
+
disabled: p,
|
|
99
|
+
className: `superdoc-esign-btn superdoc-esign-btn--submit${a ? " superdoc-esign-btn--loading" : ""}`,
|
|
100
|
+
style: {
|
|
101
|
+
padding: "12px 24px",
|
|
102
|
+
borderRadius: "6px",
|
|
103
|
+
border: "none",
|
|
104
|
+
background: "#007bff",
|
|
105
|
+
color: "#fff",
|
|
106
|
+
cursor: p ? "not-allowed" : "pointer",
|
|
107
|
+
opacity: p && !a ? 0.5 : 1,
|
|
108
|
+
fontSize: "16px",
|
|
109
|
+
fontWeight: "bold",
|
|
110
|
+
display: "inline-flex",
|
|
111
|
+
alignItems: "center",
|
|
112
|
+
gap: "8px",
|
|
113
|
+
transition: "opacity 0.2s ease"
|
|
114
|
+
},
|
|
115
|
+
children: [
|
|
116
|
+
a && /* @__PURE__ */ d("span", { className: "superdoc-esign-spinner superdoc-esign-spinner--light" }),
|
|
117
|
+
a ? "Submitting..." : m
|
|
118
|
+
]
|
|
119
|
+
}
|
|
120
|
+
);
|
|
121
|
+
}, De = ye(
|
|
122
|
+
(u, l) => {
|
|
99
123
|
const {
|
|
100
|
-
eventId:
|
|
101
|
-
document:
|
|
124
|
+
eventId: s,
|
|
125
|
+
document: o,
|
|
102
126
|
fields: r = {},
|
|
103
|
-
download:
|
|
104
|
-
submit:
|
|
105
|
-
onSubmit:
|
|
106
|
-
onDownload:
|
|
107
|
-
onStateChange:
|
|
108
|
-
onFieldChange:
|
|
109
|
-
onFieldsDiscovered:
|
|
110
|
-
isDisabled:
|
|
111
|
-
className:
|
|
112
|
-
style:
|
|
113
|
-
documentHeight:
|
|
114
|
-
} =
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}, [
|
|
118
|
-
const
|
|
119
|
-
if (!
|
|
120
|
-
const t =
|
|
121
|
-
|
|
122
|
-
|
|
127
|
+
download: a,
|
|
128
|
+
submit: m,
|
|
129
|
+
onSubmit: p,
|
|
130
|
+
onDownload: R,
|
|
131
|
+
onStateChange: _,
|
|
132
|
+
onFieldChange: z,
|
|
133
|
+
onFieldsDiscovered: U,
|
|
134
|
+
isDisabled: f = !1,
|
|
135
|
+
className: te,
|
|
136
|
+
style: ne,
|
|
137
|
+
documentHeight: oe = "600px"
|
|
138
|
+
} = u, [x, $] = v(!o.validation?.scroll?.required), [g, H] = v(/* @__PURE__ */ new Map()), [w, O] = v(!1), [h, j] = v(!1), [q, P] = v(!1), [W, L] = v([]), [K, re] = v(!1), k = C(null), F = C(null), se = C(Date.now()), S = C(r), M = C([]), X = C(U);
|
|
139
|
+
S.current = r, X.current = U, A(() => {
|
|
140
|
+
M.current = W;
|
|
141
|
+
}, [W]);
|
|
142
|
+
const y = D((e) => {
|
|
143
|
+
if (!F.current?.activeEditor) return;
|
|
144
|
+
const t = F.current.activeEditor, i = S.current.signer?.find((n) => n.id === e.id);
|
|
145
|
+
if (e.type === "table" && Array.isArray(e.value)) {
|
|
146
|
+
const T = t.helpers?.structuredContentCommands?.getStructuredContentTablesById?.(e.id, t.state) || [];
|
|
147
|
+
if (T.length) {
|
|
148
|
+
const { node: B, pos: me } = T[0], Q = B.childCount;
|
|
149
|
+
if (Q > 1) {
|
|
150
|
+
let E = t.state.tr;
|
|
151
|
+
for (let I = Q - 1; I >= 1; I--) {
|
|
152
|
+
let Z = 1;
|
|
153
|
+
for (let V = 0; V < I; V++)
|
|
154
|
+
Z += B.child(V).nodeSize;
|
|
155
|
+
const fe = B.child(I), ee = me + Z, he = ee + fe.nodeSize;
|
|
156
|
+
E = E.delete(E.mapping.map(ee), E.mapping.map(he));
|
|
157
|
+
}
|
|
158
|
+
t.view?.dispatch(E);
|
|
159
|
+
}
|
|
160
|
+
t.commands?.appendRowsToStructuredContentTable?.({
|
|
161
|
+
id: e.id,
|
|
162
|
+
rows: e.value,
|
|
163
|
+
copyRowStyle: !0
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
let c;
|
|
169
|
+
i?.type === "signature" && e.value ? c = {
|
|
123
170
|
json: {
|
|
124
171
|
type: "image",
|
|
125
|
-
attrs: { src: typeof e.value == "string" && e.value.startsWith("data:image/") ? e.value :
|
|
172
|
+
attrs: { src: typeof e.value == "string" && e.value.startsWith("data:image/") ? e.value : be(String(e.value)), alt: "Signature" }
|
|
126
173
|
}
|
|
127
|
-
} :
|
|
128
|
-
}, [])
|
|
129
|
-
function J(e) {
|
|
130
|
-
const t = globalThis.document.createElement("canvas"), n = t.getContext("2d"), i = 30;
|
|
131
|
-
n.font = `italic ${i}px cursive`;
|
|
132
|
-
const p = n.measureText(e).width, ie = i * 1.3, ae = 4, ce = 6;
|
|
133
|
-
return t.width = Math.ceil(p + ae * 2) + 20, t.height = Math.ceil(ie + ce * 2), n.font = `italic ${i}px cursive`, n.fillStyle = "black", n.textAlign = "center", n.textBaseline = "middle", n.fillText(e, t.width / 2, t.height / 2), t.toDataURL("image/png");
|
|
134
|
-
}
|
|
135
|
-
const W = y(
|
|
174
|
+
} : c = { text: String(e.value ?? "") }, e.id && t.commands?.updateStructuredContentById?.(e.id, c);
|
|
175
|
+
}, []), Y = D(
|
|
136
176
|
(e) => {
|
|
137
177
|
if (!e) return;
|
|
138
178
|
const t = e.helpers.structuredContentCommands.getStructuredContentTags(
|
|
139
179
|
e.state
|
|
140
|
-
),
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}),
|
|
144
|
-
|
|
180
|
+
), i = /* @__PURE__ */ new Map();
|
|
181
|
+
S.current.document?.forEach((n) => {
|
|
182
|
+
n.id && i.set(n.id, n.value);
|
|
183
|
+
}), S.current.signer?.forEach((n) => {
|
|
184
|
+
n.value !== void 0 && i.set(n.id, n.value);
|
|
145
185
|
});
|
|
146
|
-
const
|
|
147
|
-
id:
|
|
148
|
-
label:
|
|
149
|
-
value:
|
|
150
|
-
})).filter((
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
186
|
+
const c = t.map(({ node: n }) => ({
|
|
187
|
+
id: n.attrs.id,
|
|
188
|
+
label: n.attrs.label,
|
|
189
|
+
value: i.get(n.attrs.id) ?? n.textContent ?? ""
|
|
190
|
+
})).filter((n) => n.id);
|
|
191
|
+
c.length > 0 && (X.current?.(c), (S.current.document || []).filter((n) => n.value !== void 0).forEach(
|
|
192
|
+
(n) => y({
|
|
193
|
+
id: n.id,
|
|
194
|
+
value: n.value,
|
|
195
|
+
type: n.type
|
|
196
|
+
})
|
|
197
|
+
), (S.current.signer || []).filter((n) => n.value !== void 0).forEach(
|
|
198
|
+
(n) => y({
|
|
199
|
+
id: n.id,
|
|
200
|
+
value: n.value
|
|
158
201
|
})
|
|
159
202
|
));
|
|
160
203
|
},
|
|
161
|
-
[
|
|
162
|
-
),
|
|
204
|
+
[y]
|
|
205
|
+
), N = (e) => {
|
|
163
206
|
const t = {
|
|
164
207
|
...e,
|
|
165
208
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
166
|
-
},
|
|
167
|
-
|
|
168
|
-
const
|
|
169
|
-
return
|
|
209
|
+
}, i = globalThis?.__SUPERDOC_AUDIT_MOCK__;
|
|
210
|
+
i && i(t);
|
|
211
|
+
const c = [...M.current, t];
|
|
212
|
+
return M.current = c, L(c), c;
|
|
170
213
|
};
|
|
171
|
-
|
|
172
|
-
if (!
|
|
214
|
+
A(() => {
|
|
215
|
+
if (!k.current) return;
|
|
173
216
|
let e = !1, t = null;
|
|
174
217
|
return (async () => {
|
|
175
|
-
const { SuperDoc:
|
|
176
|
-
e || (t = new
|
|
177
|
-
selector:
|
|
178
|
-
document:
|
|
218
|
+
const { SuperDoc: c } = await import("superdoc");
|
|
219
|
+
e || (t = new c({
|
|
220
|
+
selector: k.current,
|
|
221
|
+
document: o.source,
|
|
179
222
|
documentMode: "viewing",
|
|
180
223
|
modules: {
|
|
181
224
|
comments: !1
|
|
182
225
|
},
|
|
226
|
+
// @ts-expect-error - layoutMode is not supported in SuperDoc v1.1.0 yet
|
|
227
|
+
layoutMode: o.layoutMode,
|
|
228
|
+
layoutMargins: o.layoutMargins,
|
|
183
229
|
onReady: () => {
|
|
184
|
-
e || (t?.activeEditor &&
|
|
230
|
+
e || (t?.activeEditor && Y(t.activeEditor), N({ type: "ready" }), re(!0));
|
|
185
231
|
}
|
|
186
|
-
}),
|
|
232
|
+
}), F.current = t);
|
|
187
233
|
})(), () => {
|
|
188
|
-
e = !0, t && typeof t.destroy == "function" && t.destroy(),
|
|
234
|
+
e = !0, t && typeof t.destroy == "function" && t.destroy(), F.current = null;
|
|
189
235
|
};
|
|
190
|
-
}, [
|
|
191
|
-
|
|
192
|
-
|
|
236
|
+
}, [
|
|
237
|
+
o.source,
|
|
238
|
+
o.mode,
|
|
239
|
+
o.layoutMode,
|
|
240
|
+
o.layoutMargins?.top,
|
|
241
|
+
o.layoutMargins?.bottom,
|
|
242
|
+
o.layoutMargins?.left,
|
|
243
|
+
o.layoutMargins?.right,
|
|
244
|
+
Y
|
|
245
|
+
]), A(() => {
|
|
246
|
+
if (!o.validation?.scroll?.required || !K) return;
|
|
247
|
+
const e = k.current;
|
|
193
248
|
if (!e) return;
|
|
194
249
|
const t = () => {
|
|
195
|
-
const { scrollTop:
|
|
196
|
-
(
|
|
250
|
+
const { scrollTop: i, scrollHeight: c, clientHeight: n } = e, T = i / (c - n);
|
|
251
|
+
(T >= 0.95 || c <= n) && ($(!0), N({
|
|
197
252
|
type: "scroll",
|
|
198
|
-
data: { percent: Math.round(
|
|
253
|
+
data: { percent: Math.round(T * 100) }
|
|
199
254
|
}));
|
|
200
255
|
};
|
|
201
256
|
return e.addEventListener("scroll", t), t(), () => e.removeEventListener("scroll", t);
|
|
202
|
-
}, [
|
|
203
|
-
const
|
|
257
|
+
}, [o.validation?.scroll?.required, K]);
|
|
258
|
+
const ae = D(
|
|
204
259
|
(e, t) => {
|
|
205
|
-
|
|
206
|
-
const
|
|
207
|
-
return
|
|
260
|
+
H((i) => {
|
|
261
|
+
const c = i.get(e), n = new Map(i);
|
|
262
|
+
return n.set(e, t), y({
|
|
208
263
|
id: e,
|
|
209
264
|
value: t
|
|
210
|
-
}),
|
|
265
|
+
}), N({
|
|
211
266
|
type: "field_change",
|
|
212
|
-
data: { fieldId: e, value: t, previousValue:
|
|
213
|
-
}),
|
|
267
|
+
data: { fieldId: e, value: t, previousValue: c }
|
|
268
|
+
}), z?.({
|
|
214
269
|
id: e,
|
|
215
270
|
value: t,
|
|
216
|
-
previousValue:
|
|
217
|
-
}),
|
|
271
|
+
previousValue: c
|
|
272
|
+
}), n;
|
|
218
273
|
});
|
|
219
274
|
},
|
|
220
|
-
[
|
|
221
|
-
),
|
|
275
|
+
[z, y]
|
|
276
|
+
), G = D(() => o.validation?.scroll?.required && !x ? !1 : (r.signer || []).every((e) => {
|
|
222
277
|
if (!e.validation?.required) return !0;
|
|
223
|
-
const t =
|
|
278
|
+
const t = g.get(e.id);
|
|
224
279
|
return t && (typeof t != "string" || t.trim());
|
|
225
|
-
}), [
|
|
226
|
-
|
|
227
|
-
const e =
|
|
228
|
-
|
|
229
|
-
scrolled:
|
|
230
|
-
fields:
|
|
280
|
+
}), [x, r.signer, g, o.validation?.scroll?.required]);
|
|
281
|
+
A(() => {
|
|
282
|
+
const e = G();
|
|
283
|
+
O(e), _?.({
|
|
284
|
+
scrolled: x,
|
|
285
|
+
fields: g,
|
|
231
286
|
isValid: e,
|
|
232
|
-
isSubmitting:
|
|
287
|
+
isSubmitting: h
|
|
233
288
|
});
|
|
234
|
-
}, [
|
|
235
|
-
const
|
|
236
|
-
if (
|
|
289
|
+
}, [x, g, h, G, _]);
|
|
290
|
+
const ie = D(async () => {
|
|
291
|
+
if (f || q) return;
|
|
292
|
+
P(!0);
|
|
237
293
|
const e = {
|
|
238
|
-
eventId:
|
|
239
|
-
documentSource:
|
|
294
|
+
eventId: s,
|
|
295
|
+
documentSource: o.source,
|
|
240
296
|
fields: {
|
|
241
297
|
document: r.document || [],
|
|
242
298
|
signer: (r.signer || []).map((t) => ({
|
|
243
299
|
id: t.id,
|
|
244
|
-
value:
|
|
300
|
+
value: g.get(t.id) ?? null
|
|
245
301
|
}))
|
|
246
302
|
},
|
|
247
|
-
fileName:
|
|
303
|
+
fileName: a?.fileName || "document.pdf"
|
|
248
304
|
};
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
305
|
+
try {
|
|
306
|
+
await R?.(e);
|
|
307
|
+
} finally {
|
|
308
|
+
P(!1);
|
|
309
|
+
}
|
|
310
|
+
}, [
|
|
311
|
+
f,
|
|
312
|
+
q,
|
|
313
|
+
s,
|
|
314
|
+
o.source,
|
|
315
|
+
r,
|
|
316
|
+
g,
|
|
317
|
+
a,
|
|
318
|
+
R
|
|
319
|
+
]), ce = D(async () => {
|
|
320
|
+
if (!w || f || h) return;
|
|
321
|
+
j(!0), N({ type: "submit" });
|
|
322
|
+
const e = N({ type: "submit" }), t = {
|
|
323
|
+
eventId: s,
|
|
255
324
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
256
|
-
duration: Math.floor((Date.now() -
|
|
325
|
+
duration: Math.floor((Date.now() - se.current) / 1e3),
|
|
257
326
|
auditTrail: e,
|
|
258
327
|
documentFields: r.document || [],
|
|
259
|
-
signerFields: (r.signer || []).map((
|
|
260
|
-
id:
|
|
261
|
-
value:
|
|
328
|
+
signerFields: (r.signer || []).map((i) => ({
|
|
329
|
+
id: i.id,
|
|
330
|
+
value: g.get(i.id) ?? null
|
|
262
331
|
})),
|
|
263
332
|
isFullyCompleted: w
|
|
264
333
|
};
|
|
265
334
|
try {
|
|
266
|
-
await
|
|
335
|
+
await p(t);
|
|
267
336
|
} finally {
|
|
268
|
-
|
|
337
|
+
j(!1);
|
|
269
338
|
}
|
|
270
|
-
}, [w,
|
|
271
|
-
const t = e.component ||
|
|
272
|
-
return /* @__PURE__ */
|
|
339
|
+
}, [w, f, h, s, r, g, p]), le = (e) => {
|
|
340
|
+
const t = e.component || de(e.type);
|
|
341
|
+
return /* @__PURE__ */ d(
|
|
273
342
|
t,
|
|
274
343
|
{
|
|
275
|
-
value:
|
|
276
|
-
onChange: (
|
|
277
|
-
isDisabled:
|
|
344
|
+
value: g.get(e.id) ?? null,
|
|
345
|
+
onChange: (i) => ae(e.id, i),
|
|
346
|
+
isDisabled: f,
|
|
278
347
|
label: e.label
|
|
279
348
|
},
|
|
280
349
|
e.id
|
|
281
350
|
);
|
|
282
|
-
},
|
|
351
|
+
}, de = (e) => {
|
|
283
352
|
switch (e) {
|
|
284
353
|
case "signature":
|
|
285
354
|
case "text":
|
|
286
|
-
return
|
|
355
|
+
return xe;
|
|
287
356
|
case "checkbox":
|
|
288
|
-
return
|
|
357
|
+
return we;
|
|
289
358
|
}
|
|
290
|
-
},
|
|
291
|
-
const e =
|
|
292
|
-
return e ? /* @__PURE__ */
|
|
359
|
+
}, ue = () => {
|
|
360
|
+
const e = a?.component || Se(a);
|
|
361
|
+
return e ? /* @__PURE__ */ d(
|
|
293
362
|
e,
|
|
294
363
|
{
|
|
295
|
-
onClick:
|
|
296
|
-
fileName:
|
|
297
|
-
isDisabled:
|
|
364
|
+
onClick: ie,
|
|
365
|
+
fileName: a?.fileName,
|
|
366
|
+
isDisabled: f,
|
|
367
|
+
isDownloading: q
|
|
298
368
|
}
|
|
299
369
|
) : null;
|
|
300
|
-
},
|
|
301
|
-
if (
|
|
370
|
+
}, pe = () => {
|
|
371
|
+
if (o.mode === "download")
|
|
302
372
|
return null;
|
|
303
|
-
const e =
|
|
304
|
-
return /* @__PURE__ */
|
|
373
|
+
const e = m?.component || Ce(m);
|
|
374
|
+
return /* @__PURE__ */ d("div", { className: "superdoc-esign-actions superdoc-esign-form-actions", children: /* @__PURE__ */ d(
|
|
305
375
|
e,
|
|
306
376
|
{
|
|
307
|
-
onClick:
|
|
377
|
+
onClick: ce,
|
|
308
378
|
isValid: w,
|
|
309
|
-
isDisabled:
|
|
310
|
-
isSubmitting:
|
|
379
|
+
isDisabled: f,
|
|
380
|
+
isSubmitting: h
|
|
311
381
|
}
|
|
312
382
|
) });
|
|
313
|
-
},
|
|
314
|
-
return
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
383
|
+
}, J = ue(), ge = pe();
|
|
384
|
+
return ve(
|
|
385
|
+
l,
|
|
386
|
+
() => ({
|
|
387
|
+
getState: () => ({
|
|
388
|
+
scrolled: x,
|
|
389
|
+
fields: g,
|
|
390
|
+
isValid: w,
|
|
391
|
+
isSubmitting: h
|
|
392
|
+
}),
|
|
393
|
+
getAuditTrail: () => M.current,
|
|
394
|
+
reset: () => {
|
|
395
|
+
$(!o.validation?.scroll?.required), H(/* @__PURE__ */ new Map()), O(!1), M.current = [], L([]);
|
|
396
|
+
},
|
|
397
|
+
updateFieldInDocument: y
|
|
320
398
|
}),
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
399
|
+
[
|
|
400
|
+
x,
|
|
401
|
+
g,
|
|
402
|
+
w,
|
|
403
|
+
h,
|
|
404
|
+
o.validation?.scroll?.required,
|
|
405
|
+
y
|
|
406
|
+
]
|
|
407
|
+
), /* @__PURE__ */ b("div", { className: `superdoc-esign-container ${te || ""}`, style: ne, children: [
|
|
408
|
+
/* @__PURE__ */ b("div", { className: "superdoc-esign-document", "data-testid": "superdoc-esign-document", children: [
|
|
409
|
+
J && /* @__PURE__ */ d("div", { className: "superdoc-esign-document-toolbar", children: /* @__PURE__ */ d("div", { className: "superdoc-esign-document-controls", children: J }) }),
|
|
410
|
+
/* @__PURE__ */ d(
|
|
329
411
|
"div",
|
|
330
412
|
{
|
|
331
|
-
ref:
|
|
413
|
+
ref: k,
|
|
332
414
|
className: "superdoc-esign-document-viewer",
|
|
333
415
|
"data-testid": "superdoc-scroll-container",
|
|
334
|
-
style: { height:
|
|
416
|
+
style: { height: oe, overflow: "auto" }
|
|
335
417
|
}
|
|
336
418
|
)
|
|
337
419
|
] }),
|
|
338
|
-
/* @__PURE__ */
|
|
339
|
-
r.signer && r.signer.length > 0 && /* @__PURE__ */
|
|
340
|
-
|
|
420
|
+
/* @__PURE__ */ b("div", { className: "superdoc-esign-controls", "data-testid": "superdoc-esign-controls", children: [
|
|
421
|
+
r.signer && r.signer.length > 0 && /* @__PURE__ */ d("div", { className: "superdoc-esign-fields", "data-testid": "superdoc-esign-fields", children: r.signer.map(le) }),
|
|
422
|
+
ge
|
|
341
423
|
] })
|
|
342
424
|
] });
|
|
343
425
|
}
|
|
344
426
|
);
|
|
345
|
-
|
|
427
|
+
De.displayName = "SuperDocESign";
|
|
346
428
|
export {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
429
|
+
we as CheckboxInput,
|
|
430
|
+
xe as SignatureInput,
|
|
431
|
+
De as default,
|
|
432
|
+
be as textToImageDataUrl
|
|
350
433
|
};
|