@embedpdf/plugin-signature 2.13.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.
- package/LICENSE +21 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +516 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/actions.d.ts +14 -0
- package/dist/lib/handlers/signature-ink.handler.d.ts +4 -0
- package/dist/lib/handlers/signature-stamp.handler.d.ts +4 -0
- package/dist/lib/index.d.ts +12 -0
- package/dist/lib/manifest.d.ts +4 -0
- package/dist/lib/reducer.d.ts +5 -0
- package/dist/lib/serialization.d.ts +30 -0
- package/dist/lib/signature-plugin.d.ts +27 -0
- package/dist/lib/tools.d.ts +113 -0
- package/dist/lib/types.d.ts +114 -0
- package/dist/preact/adapter.d.ts +5 -0
- package/dist/preact/annotation.d.ts +1 -0
- package/dist/preact/core.d.ts +1 -0
- package/dist/preact/index.cjs +2 -0
- package/dist/preact/index.cjs.map +1 -0
- package/dist/preact/index.d.ts +1 -0
- package/dist/preact/index.js +464 -0
- package/dist/preact/index.js.map +1 -0
- package/dist/react/adapter.d.ts +2 -0
- package/dist/react/annotation.d.ts +1 -0
- package/dist/react/core.d.ts +1 -0
- package/dist/react/index.cjs +2 -0
- package/dist/react/index.cjs.map +1 -0
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.js +463 -0
- package/dist/react/index.js.map +1 -0
- package/dist/shared/components/crop-canvas.d.ts +14 -0
- package/dist/shared/components/index.d.ts +2 -0
- package/dist/shared/components/signature-draw-pad.d.ts +12 -0
- package/dist/shared/components/signature-type-pad.d.ts +14 -0
- package/dist/shared/hooks/index.d.ts +2 -0
- package/dist/shared/hooks/use-signature-upload.d.ts +21 -0
- package/dist/shared/hooks/use-signature.d.ts +16 -0
- package/dist/shared/index.d.ts +4 -0
- package/dist/shared-preact/components/crop-canvas.d.ts +14 -0
- package/dist/shared-preact/components/index.d.ts +2 -0
- package/dist/shared-preact/components/signature-draw-pad.d.ts +12 -0
- package/dist/shared-preact/components/signature-type-pad.d.ts +14 -0
- package/dist/shared-preact/hooks/index.d.ts +2 -0
- package/dist/shared-preact/hooks/use-signature-upload.d.ts +21 -0
- package/dist/shared-preact/hooks/use-signature.d.ts +16 -0
- package/dist/shared-preact/index.d.ts +4 -0
- package/dist/shared-react/components/crop-canvas.d.ts +14 -0
- package/dist/shared-react/components/index.d.ts +2 -0
- package/dist/shared-react/components/signature-draw-pad.d.ts +12 -0
- package/dist/shared-react/components/signature-type-pad.d.ts +14 -0
- package/dist/shared-react/hooks/index.d.ts +2 -0
- package/dist/shared-react/hooks/use-signature-upload.d.ts +21 -0
- package/dist/shared-react/hooks/use-signature.d.ts +16 -0
- package/dist/shared-react/index.d.ts +4 -0
- package/dist/shared-vue/components/crop-canvas.d.ts +14 -0
- package/dist/svelte/components/SignatureDrawPad.svelte.d.ts +12 -0
- package/dist/svelte/components/SignatureTypePad.svelte.d.ts +14 -0
- package/dist/svelte/components/index.d.ts +2 -0
- package/dist/svelte/hooks/index.d.ts +2 -0
- package/dist/svelte/hooks/use-signature-upload.svelte.d.ts +21 -0
- package/dist/svelte/hooks/use-signature.svelte.d.ts +17 -0
- package/dist/svelte/index.cjs +2 -0
- package/dist/svelte/index.cjs.map +1 -0
- package/dist/svelte/index.d.ts +4 -0
- package/dist/svelte/index.js +415 -0
- package/dist/svelte/index.js.map +1 -0
- package/dist/vue/components/SignatureDrawPad.vue.d.ts +15 -0
- package/dist/vue/components/SignatureTypePad.vue.d.ts +19 -0
- package/dist/vue/components/index.d.ts +2 -0
- package/dist/vue/hooks/index.d.ts +2 -0
- package/dist/vue/hooks/use-signature-upload.d.ts +20 -0
- package/dist/vue/hooks/use-signature.d.ts +176 -0
- package/dist/vue/index.cjs +2 -0
- package/dist/vue/index.cjs.map +1 -0
- package/dist/vue/index.d.ts +4 -0
- package/dist/vue/index.js +453 -0
- package/dist/vue/index.js.map +1 -0
- package/package.json +82 -0
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
import { createPluginPackage } from "@embedpdf/core";
|
|
2
|
+
import { SignaturePlugin, SignatureCreationType, SignaturePluginPackage as SignaturePluginPackage$1 } from "@embedpdf/plugin-signature";
|
|
3
|
+
export * from "@embedpdf/plugin-signature";
|
|
4
|
+
import * as $ from "svelte/internal/client";
|
|
5
|
+
import { usePlugin, useCapability } from "@embedpdf/core/svelte";
|
|
6
|
+
import "svelte/internal/disclose-version";
|
|
7
|
+
const useSignaturePlugin = () => usePlugin(SignaturePlugin.id);
|
|
8
|
+
const useSignatureCapability = () => useCapability(SignaturePlugin.id);
|
|
9
|
+
function useSignatureEntries() {
|
|
10
|
+
const capability = useSignatureCapability();
|
|
11
|
+
let entries = $.state($.proxy([]));
|
|
12
|
+
$.user_effect(() => {
|
|
13
|
+
if (!capability.provides) {
|
|
14
|
+
$.set(entries, [], true);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
$.set(entries, capability.provides.getEntries(), true);
|
|
18
|
+
return capability.provides.onEntriesChange((updated) => {
|
|
19
|
+
$.set(entries, updated, true);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
return {
|
|
23
|
+
get entries() {
|
|
24
|
+
return $.get(entries);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function useActivePlacement(getDocumentId) {
|
|
29
|
+
const capability = useSignatureCapability();
|
|
30
|
+
let activePlacement = $.state(null);
|
|
31
|
+
const documentId = $.derived(getDocumentId);
|
|
32
|
+
$.user_effect(() => {
|
|
33
|
+
if (!capability.provides || !$.get(documentId)) {
|
|
34
|
+
$.set(activePlacement, null);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const scope = capability.provides.forDocument($.get(documentId));
|
|
38
|
+
$.set(activePlacement, scope.getActivePlacement(), true);
|
|
39
|
+
return scope.onActivePlacementChange((placement) => {
|
|
40
|
+
$.set(activePlacement, placement, true);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
return {
|
|
44
|
+
get activePlacement() {
|
|
45
|
+
return $.get(activePlacement);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function useSignatureUpload({ accept = "image/png,image/jpeg,image/svg+xml", onResult }) {
|
|
50
|
+
const inputRef = { current: null };
|
|
51
|
+
let previewUrl = $.state(null);
|
|
52
|
+
let isDragging = $.state(false);
|
|
53
|
+
function processFile(file) {
|
|
54
|
+
const reader = new FileReader();
|
|
55
|
+
reader.onload = () => {
|
|
56
|
+
const arrayBuffer = reader.result;
|
|
57
|
+
const blob = new Blob([arrayBuffer], { type: file.type });
|
|
58
|
+
const dataUrl = URL.createObjectURL(blob);
|
|
59
|
+
if ($.get(previewUrl)) URL.revokeObjectURL($.get(previewUrl));
|
|
60
|
+
$.set(previewUrl, dataUrl, true);
|
|
61
|
+
const img = new Image();
|
|
62
|
+
img.onload = () => {
|
|
63
|
+
const previewCanvas = document.createElement("canvas");
|
|
64
|
+
previewCanvas.width = img.width;
|
|
65
|
+
previewCanvas.height = img.height;
|
|
66
|
+
const ctx = previewCanvas.getContext("2d");
|
|
67
|
+
if (ctx) {
|
|
68
|
+
ctx.drawImage(img, 0, 0);
|
|
69
|
+
}
|
|
70
|
+
const result = {
|
|
71
|
+
creationType: SignatureCreationType.Upload,
|
|
72
|
+
imageMimeType: file.type,
|
|
73
|
+
imageSize: { width: img.width, height: img.height },
|
|
74
|
+
previewDataUrl: previewCanvas.toDataURL("image/png"),
|
|
75
|
+
imageData: arrayBuffer
|
|
76
|
+
};
|
|
77
|
+
onResult(result);
|
|
78
|
+
};
|
|
79
|
+
img.src = dataUrl;
|
|
80
|
+
};
|
|
81
|
+
reader.readAsArrayBuffer(file);
|
|
82
|
+
}
|
|
83
|
+
function handleFileInputChange(e) {
|
|
84
|
+
const files = e.target.files;
|
|
85
|
+
if (files && files[0]) {
|
|
86
|
+
processFile(files[0]);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function handleDrop(e) {
|
|
90
|
+
var _a;
|
|
91
|
+
e.preventDefault();
|
|
92
|
+
$.set(isDragging, false);
|
|
93
|
+
const files = (_a = e.dataTransfer) == null ? void 0 : _a.files;
|
|
94
|
+
if (files && files[0]) {
|
|
95
|
+
processFile(files[0]);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function handleDragOver(e) {
|
|
99
|
+
e.preventDefault();
|
|
100
|
+
$.set(isDragging, true);
|
|
101
|
+
}
|
|
102
|
+
function handleDragLeave() {
|
|
103
|
+
$.set(isDragging, false);
|
|
104
|
+
}
|
|
105
|
+
function openFilePicker() {
|
|
106
|
+
var _a;
|
|
107
|
+
(_a = inputRef.current) == null ? void 0 : _a.click();
|
|
108
|
+
}
|
|
109
|
+
function clear() {
|
|
110
|
+
if ($.get(previewUrl)) URL.revokeObjectURL($.get(previewUrl));
|
|
111
|
+
$.set(previewUrl, null);
|
|
112
|
+
onResult(null);
|
|
113
|
+
if (inputRef.current) {
|
|
114
|
+
inputRef.current.value = "";
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
inputRef,
|
|
119
|
+
openFilePicker,
|
|
120
|
+
processFile,
|
|
121
|
+
handleFileInputChange,
|
|
122
|
+
handleDrop,
|
|
123
|
+
handleDragOver,
|
|
124
|
+
handleDragLeave,
|
|
125
|
+
get previewUrl() {
|
|
126
|
+
return $.get(previewUrl);
|
|
127
|
+
},
|
|
128
|
+
get isDragging() {
|
|
129
|
+
return $.get(isDragging);
|
|
130
|
+
},
|
|
131
|
+
clear,
|
|
132
|
+
accept
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
function cropCanvas(source, padding = 4) {
|
|
136
|
+
const ctx = source.getContext("2d");
|
|
137
|
+
if (!ctx) return null;
|
|
138
|
+
const { width, height } = source;
|
|
139
|
+
if (width === 0 || height === 0) return null;
|
|
140
|
+
const imageData = ctx.getImageData(0, 0, width, height);
|
|
141
|
+
const { data } = imageData;
|
|
142
|
+
let minX = width;
|
|
143
|
+
let minY = height;
|
|
144
|
+
let maxX = 0;
|
|
145
|
+
let maxY = 0;
|
|
146
|
+
for (let y = 0; y < height; y++) {
|
|
147
|
+
for (let x = 0; x < width; x++) {
|
|
148
|
+
const alpha = data[(y * width + x) * 4 + 3];
|
|
149
|
+
if (alpha > 0) {
|
|
150
|
+
if (x < minX) minX = x;
|
|
151
|
+
if (x > maxX) maxX = x;
|
|
152
|
+
if (y < minY) minY = y;
|
|
153
|
+
if (y > maxY) maxY = y;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (maxX < minX || maxY < minY) return null;
|
|
158
|
+
const cropX = Math.max(0, minX - padding);
|
|
159
|
+
const cropY = Math.max(0, minY - padding);
|
|
160
|
+
const cropW = Math.min(width, maxX + padding + 1) - cropX;
|
|
161
|
+
const cropH = Math.min(height, maxY + padding + 1) - cropY;
|
|
162
|
+
const cropped = document.createElement("canvas");
|
|
163
|
+
cropped.width = cropW;
|
|
164
|
+
cropped.height = cropH;
|
|
165
|
+
const croppedCtx = cropped.getContext("2d");
|
|
166
|
+
if (!croppedCtx) return null;
|
|
167
|
+
croppedCtx.drawImage(source, cropX, cropY, cropW, cropH, 0, 0, cropW, cropH);
|
|
168
|
+
return {
|
|
169
|
+
canvas: cropped,
|
|
170
|
+
bounds: { x: cropX, y: cropY, width: cropW, height: cropH }
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
var root$1 = $.from_html(`<canvas style="touch-action: none; width: 100%; height: 100%; display: block;"></canvas>`);
|
|
174
|
+
function SignatureDrawPad($$anchor, $$props) {
|
|
175
|
+
$.push($$props, true);
|
|
176
|
+
let strokeColor = $.prop($$props, "strokeColor", 3, "#000000"), strokeWidth = $.prop($$props, "strokeWidth", 3, 4), className = $.prop($$props, "class", 3, "");
|
|
177
|
+
let canvasEl = $.state(void 0);
|
|
178
|
+
let strokes = $.state($.proxy([]));
|
|
179
|
+
let isDrawing = false;
|
|
180
|
+
const dpr = typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1;
|
|
181
|
+
function getCanvasPos(e) {
|
|
182
|
+
if (!$.get(canvasEl)) return { x: 0, y: 0 };
|
|
183
|
+
const rect = $.get(canvasEl).getBoundingClientRect();
|
|
184
|
+
return {
|
|
185
|
+
x: (e.clientX - rect.left) * ($.get(canvasEl).width / dpr / rect.width),
|
|
186
|
+
y: (e.clientY - rect.top) * ($.get(canvasEl).height / dpr / rect.height)
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
function redraw(currentStrokes) {
|
|
190
|
+
if (!$.get(canvasEl)) return;
|
|
191
|
+
const ctx = $.get(canvasEl).getContext("2d");
|
|
192
|
+
if (!ctx) return;
|
|
193
|
+
ctx.clearRect(0, 0, $.get(canvasEl).width, $.get(canvasEl).height);
|
|
194
|
+
ctx.save();
|
|
195
|
+
ctx.scale(dpr, dpr);
|
|
196
|
+
ctx.strokeStyle = strokeColor();
|
|
197
|
+
ctx.lineWidth = strokeWidth();
|
|
198
|
+
ctx.lineCap = "round";
|
|
199
|
+
ctx.lineJoin = "round";
|
|
200
|
+
for (const stroke of currentStrokes) {
|
|
201
|
+
if (stroke.points.length === 0) continue;
|
|
202
|
+
ctx.beginPath();
|
|
203
|
+
ctx.moveTo(stroke.points[0].x, stroke.points[0].y);
|
|
204
|
+
for (let i = 1; i < stroke.points.length; i++) {
|
|
205
|
+
ctx.lineTo(stroke.points[i].x, stroke.points[i].y);
|
|
206
|
+
}
|
|
207
|
+
ctx.stroke();
|
|
208
|
+
}
|
|
209
|
+
ctx.restore();
|
|
210
|
+
}
|
|
211
|
+
function emitResult(currentStrokes) {
|
|
212
|
+
if (currentStrokes.length === 0 || currentStrokes.every((s) => s.points.length < 2)) {
|
|
213
|
+
$$props.onResult(null);
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
if (!$.get(canvasEl)) return;
|
|
217
|
+
const cropped = cropCanvas($.get(canvasEl), Math.ceil(strokeWidth() * dpr));
|
|
218
|
+
if (!cropped) {
|
|
219
|
+
$$props.onResult(null);
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
const offsetX = cropped.bounds.x / dpr;
|
|
223
|
+
const offsetY = cropped.bounds.y / dpr;
|
|
224
|
+
const croppedWidth = Math.round(cropped.bounds.width / dpr);
|
|
225
|
+
const croppedHeight = Math.round(cropped.bounds.height / dpr);
|
|
226
|
+
const result = {
|
|
227
|
+
creationType: SignatureCreationType.Draw,
|
|
228
|
+
inkData: {
|
|
229
|
+
inkList: currentStrokes.filter((s) => s.points.length >= 2).map((s) => ({
|
|
230
|
+
points: s.points.map((p) => ({ x: p.x - offsetX, y: p.y - offsetY }))
|
|
231
|
+
})),
|
|
232
|
+
strokeWidth: strokeWidth(),
|
|
233
|
+
strokeColor: strokeColor(),
|
|
234
|
+
size: { width: croppedWidth, height: croppedHeight }
|
|
235
|
+
},
|
|
236
|
+
previewDataUrl: cropped.canvas.toDataURL("image/png")
|
|
237
|
+
};
|
|
238
|
+
$$props.onResult(result);
|
|
239
|
+
}
|
|
240
|
+
function clear() {
|
|
241
|
+
$.set(strokes, [], true);
|
|
242
|
+
redraw([]);
|
|
243
|
+
$$props.onResult(null);
|
|
244
|
+
}
|
|
245
|
+
function handlePointerDown(e) {
|
|
246
|
+
var _a, _b;
|
|
247
|
+
isDrawing = true;
|
|
248
|
+
const pos = getCanvasPos(e);
|
|
249
|
+
$.set(strokes, [...$.get(strokes), { points: [pos] }], true);
|
|
250
|
+
redraw($.get(strokes));
|
|
251
|
+
(_b = (_a = e.target) == null ? void 0 : _a.setPointerCapture) == null ? void 0 : _b.call(_a, e.pointerId);
|
|
252
|
+
}
|
|
253
|
+
function handlePointerMove(e) {
|
|
254
|
+
if (!isDrawing) return;
|
|
255
|
+
const pos = getCanvasPos(e);
|
|
256
|
+
const last = $.get(strokes)[$.get(strokes).length - 1];
|
|
257
|
+
if (last) {
|
|
258
|
+
last.points.push(pos);
|
|
259
|
+
$.set(strokes, [...$.get(strokes)], true);
|
|
260
|
+
redraw($.get(strokes));
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
function handlePointerUp(e) {
|
|
264
|
+
var _a, _b;
|
|
265
|
+
isDrawing = false;
|
|
266
|
+
(_b = (_a = e.target) == null ? void 0 : _a.releasePointerCapture) == null ? void 0 : _b.call(_a, e.pointerId);
|
|
267
|
+
emitResult($.get(strokes));
|
|
268
|
+
}
|
|
269
|
+
$.user_effect(() => {
|
|
270
|
+
if (!$.get(canvasEl)) return;
|
|
271
|
+
const observer = new ResizeObserver((entries) => {
|
|
272
|
+
const { width: w, height: h } = entries[0].contentRect;
|
|
273
|
+
if (w > 0 && h > 0 && $.get(canvasEl)) {
|
|
274
|
+
$.get(canvasEl).width = Math.round(w) * dpr;
|
|
275
|
+
$.get(canvasEl).height = Math.round(h) * dpr;
|
|
276
|
+
redraw($.get(strokes));
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
observer.observe($.get(canvasEl));
|
|
280
|
+
return () => observer.disconnect();
|
|
281
|
+
});
|
|
282
|
+
$.user_effect(() => {
|
|
283
|
+
void strokeColor();
|
|
284
|
+
void strokeWidth();
|
|
285
|
+
redraw($.get(strokes));
|
|
286
|
+
if ($.get(strokes).length > 0 && $.get(strokes).some((s) => s.points.length >= 2)) {
|
|
287
|
+
emitResult($.get(strokes));
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
var $$exports = { clear };
|
|
291
|
+
var canvas = root$1();
|
|
292
|
+
canvas.__pointerdown = handlePointerDown;
|
|
293
|
+
canvas.__pointermove = handlePointerMove;
|
|
294
|
+
canvas.__pointerup = handlePointerUp;
|
|
295
|
+
$.bind_this(canvas, ($$value) => $.set(canvasEl, $$value), () => $.get(canvasEl));
|
|
296
|
+
$.template_effect(() => $.set_class(canvas, 1, $.clsx(className())));
|
|
297
|
+
$.append($$anchor, canvas);
|
|
298
|
+
return $.pop($$exports);
|
|
299
|
+
}
|
|
300
|
+
$.delegate(["pointerdown", "pointermove", "pointerup"]);
|
|
301
|
+
var root = $.from_html(`<div style="width: 100%; height: 100%;"><!> <input type="text"/> <canvas style="display: none;"></canvas></div>`);
|
|
302
|
+
function SignatureTypePad($$anchor, $$props) {
|
|
303
|
+
$.push($$props, true);
|
|
304
|
+
let fontFamily = $.prop($$props, "fontFamily", 3, "'Dancing Script', cursive"), fontSize = $.prop($$props, "fontSize", 3, 48), color = $.prop($$props, "color", 3, "#000000"), className = $.prop($$props, "class", 3, ""), placeholder = $.prop($$props, "placeholder", 3, "Type your signature...");
|
|
305
|
+
let wrapperEl = $.state(void 0);
|
|
306
|
+
let canvasEl = $.state(void 0);
|
|
307
|
+
let text = $.state("");
|
|
308
|
+
let size = { width: 0, height: 0 };
|
|
309
|
+
const inputId = `sig-type-${Math.random().toString(36).slice(2, 8)}`;
|
|
310
|
+
const dpr = typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1;
|
|
311
|
+
function renderText(currentText) {
|
|
312
|
+
if (!$.get(canvasEl)) return;
|
|
313
|
+
const { width, height } = size;
|
|
314
|
+
if (width === 0 || height === 0) return;
|
|
315
|
+
$.get(canvasEl).width = width * dpr;
|
|
316
|
+
$.get(canvasEl).height = height * dpr;
|
|
317
|
+
const ctx = $.get(canvasEl).getContext("2d");
|
|
318
|
+
if (!ctx) return;
|
|
319
|
+
ctx.clearRect(0, 0, $.get(canvasEl).width, $.get(canvasEl).height);
|
|
320
|
+
if (!currentText.trim()) {
|
|
321
|
+
$$props.onResult(null);
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
ctx.scale(dpr, dpr);
|
|
325
|
+
ctx.fillStyle = color();
|
|
326
|
+
ctx.font = `${fontSize()}px ${fontFamily()}`;
|
|
327
|
+
ctx.textBaseline = "middle";
|
|
328
|
+
ctx.textAlign = "center";
|
|
329
|
+
ctx.fillText(currentText, width / 2, height / 2, width - 20);
|
|
330
|
+
const cropped = cropCanvas($.get(canvasEl), Math.ceil(4 * dpr));
|
|
331
|
+
if (!cropped) {
|
|
332
|
+
$$props.onResult(null);
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
const croppedWidth = Math.round(cropped.bounds.width / dpr);
|
|
336
|
+
const croppedHeight = Math.round(cropped.bounds.height / dpr);
|
|
337
|
+
cropped.canvas.toBlob(
|
|
338
|
+
(blob) => {
|
|
339
|
+
if (!blob) return;
|
|
340
|
+
blob.arrayBuffer().then((imageData) => {
|
|
341
|
+
const result = {
|
|
342
|
+
creationType: SignatureCreationType.Type,
|
|
343
|
+
label: currentText,
|
|
344
|
+
imageMimeType: "image/png",
|
|
345
|
+
imageSize: { width: croppedWidth, height: croppedHeight },
|
|
346
|
+
previewDataUrl: cropped.canvas.toDataURL("image/png"),
|
|
347
|
+
imageData
|
|
348
|
+
};
|
|
349
|
+
$$props.onResult(result);
|
|
350
|
+
});
|
|
351
|
+
},
|
|
352
|
+
"image/png"
|
|
353
|
+
);
|
|
354
|
+
}
|
|
355
|
+
function clear() {
|
|
356
|
+
$.set(text, "");
|
|
357
|
+
$$props.onResult(null);
|
|
358
|
+
}
|
|
359
|
+
function handleInput(e) {
|
|
360
|
+
$.set(text, e.target.value, true);
|
|
361
|
+
}
|
|
362
|
+
$.user_effect(() => {
|
|
363
|
+
if (!$.get(wrapperEl)) return;
|
|
364
|
+
const observer = new ResizeObserver((entries) => {
|
|
365
|
+
const { width: w, height: h } = entries[0].contentRect;
|
|
366
|
+
if (w > 0 && h > 0) {
|
|
367
|
+
size = { width: Math.round(w), height: Math.round(h) };
|
|
368
|
+
renderText($.get(text));
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
observer.observe($.get(wrapperEl));
|
|
372
|
+
return () => observer.disconnect();
|
|
373
|
+
});
|
|
374
|
+
$.user_effect(() => {
|
|
375
|
+
void fontFamily();
|
|
376
|
+
void color();
|
|
377
|
+
renderText($.get(text));
|
|
378
|
+
});
|
|
379
|
+
var $$exports = { clear };
|
|
380
|
+
var div = root();
|
|
381
|
+
var node = $.child(div);
|
|
382
|
+
$.html(node, () => `<style>#${inputId}::placeholder { color: ${color()}; opacity: 0.5; }</style>`);
|
|
383
|
+
var input = $.sibling(node, 2);
|
|
384
|
+
$.remove_input_defaults(input);
|
|
385
|
+
input.__input = handleInput;
|
|
386
|
+
var canvas = $.sibling(input, 2);
|
|
387
|
+
$.bind_this(canvas, ($$value) => $.set(canvasEl, $$value), () => $.get(canvasEl));
|
|
388
|
+
$.reset(div);
|
|
389
|
+
$.bind_this(div, ($$value) => $.set(wrapperEl, $$value), () => $.get(wrapperEl));
|
|
390
|
+
$.template_effect(
|
|
391
|
+
($0) => {
|
|
392
|
+
$.set_class(div, 1, $.clsx(className()));
|
|
393
|
+
$.set_attribute(input, "id", inputId);
|
|
394
|
+
$.set_value(input, $.get(text));
|
|
395
|
+
$.set_attribute(input, "placeholder", placeholder());
|
|
396
|
+
$.set_style(input, `font-family: ${fontFamily() ?? ""}; font-size: ${$0 ?? ""}px; color: ${color() ?? ""}; width: 100%; height: 100%; border: none; outline: none; background: transparent; text-indent: 8px;`);
|
|
397
|
+
},
|
|
398
|
+
[() => Math.min(fontSize(), 32)]
|
|
399
|
+
);
|
|
400
|
+
$.append($$anchor, div);
|
|
401
|
+
return $.pop($$exports);
|
|
402
|
+
}
|
|
403
|
+
$.delegate(["input"]);
|
|
404
|
+
const SignaturePluginPackage = createPluginPackage(SignaturePluginPackage$1).build();
|
|
405
|
+
export {
|
|
406
|
+
SignatureDrawPad,
|
|
407
|
+
SignaturePluginPackage,
|
|
408
|
+
SignatureTypePad,
|
|
409
|
+
useActivePlacement,
|
|
410
|
+
useSignatureCapability,
|
|
411
|
+
useSignatureEntries,
|
|
412
|
+
useSignaturePlugin,
|
|
413
|
+
useSignatureUpload
|
|
414
|
+
};
|
|
415
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/svelte/hooks/use-signature.svelte.ts","../../src/svelte/hooks/use-signature-upload.svelte.ts","../../src/shared/components/crop-canvas.ts","../../src/svelte/components/SignatureDrawPad.svelte","../../src/svelte/components/SignatureTypePad.svelte","../../src/svelte/index.ts"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/svelte';\nimport { SignaturePlugin } from '@embedpdf/plugin-signature';\nimport type { SignatureEntry, ActivePlacementInfo } from '@embedpdf/plugin-signature';\n\nexport const useSignaturePlugin = () => usePlugin<SignaturePlugin>(SignaturePlugin.id);\nexport const useSignatureCapability = () => useCapability<SignaturePlugin>(SignaturePlugin.id);\n\nexport function useSignatureEntries() {\n const capability = useSignatureCapability();\n let entries = $state<SignatureEntry[]>([]);\n\n $effect(() => {\n if (!capability.provides) {\n entries = [];\n return;\n }\n\n entries = capability.provides.getEntries();\n return capability.provides.onEntriesChange((updated) => {\n entries = updated;\n });\n });\n\n return {\n get entries() {\n return entries;\n },\n };\n}\n\nexport function useActivePlacement(getDocumentId: () => string) {\n const capability = useSignatureCapability();\n let activePlacement = $state<ActivePlacementInfo | null>(null);\n const documentId = $derived(getDocumentId());\n\n $effect(() => {\n if (!capability.provides || !documentId) {\n activePlacement = null;\n return;\n }\n\n const scope = capability.provides.forDocument(documentId);\n activePlacement = scope.getActivePlacement();\n return scope.onActivePlacementChange((placement) => {\n activePlacement = placement;\n });\n });\n\n return {\n get activePlacement() {\n return activePlacement;\n },\n };\n}\n","import { SignatureStampFieldDefinition, SignatureCreationType } from '@embedpdf/plugin-signature';\n\nexport interface UseSignatureUploadOptions {\n accept?: string;\n onResult: (result: SignatureStampFieldDefinition | null) => void;\n}\n\nexport interface UseSignatureUploadReturn {\n inputRef: { current: HTMLInputElement | null };\n openFilePicker: () => void;\n processFile: (file: File) => void;\n handleFileInputChange: (e: Event) => void;\n handleDrop: (e: DragEvent) => void;\n handleDragOver: (e: DragEvent) => void;\n handleDragLeave: () => void;\n readonly previewUrl: string | null;\n readonly isDragging: boolean;\n clear: () => void;\n accept: string;\n}\n\nexport function useSignatureUpload({\n accept = 'image/png,image/jpeg,image/svg+xml',\n onResult,\n}: UseSignatureUploadOptions): UseSignatureUploadReturn {\n const inputRef = { current: null as HTMLInputElement | null };\n let previewUrl = $state<string | null>(null);\n let isDragging = $state(false);\n\n function processFile(file: File) {\n const reader = new FileReader();\n reader.onload = () => {\n const arrayBuffer = reader.result as ArrayBuffer;\n const blob = new Blob([arrayBuffer], { type: file.type });\n const dataUrl = URL.createObjectURL(blob);\n\n if (previewUrl) URL.revokeObjectURL(previewUrl);\n previewUrl = dataUrl;\n\n const img = new Image();\n img.onload = () => {\n const previewCanvas = document.createElement('canvas');\n previewCanvas.width = img.width;\n previewCanvas.height = img.height;\n const ctx = previewCanvas.getContext('2d');\n if (ctx) {\n ctx.drawImage(img, 0, 0);\n }\n\n const result: SignatureStampFieldDefinition = {\n creationType: SignatureCreationType.Upload,\n imageMimeType: file.type,\n imageSize: { width: img.width, height: img.height },\n previewDataUrl: previewCanvas.toDataURL('image/png'),\n imageData: arrayBuffer,\n };\n onResult(result);\n };\n img.src = dataUrl;\n };\n reader.readAsArrayBuffer(file);\n }\n\n function handleFileInputChange(e: Event) {\n const files = (e.target as HTMLInputElement).files;\n if (files && files[0]) {\n processFile(files[0]);\n }\n }\n\n function handleDrop(e: DragEvent) {\n e.preventDefault();\n isDragging = false;\n const files = e.dataTransfer?.files;\n if (files && files[0]) {\n processFile(files[0]);\n }\n }\n\n function handleDragOver(e: DragEvent) {\n e.preventDefault();\n isDragging = true;\n }\n\n function handleDragLeave() {\n isDragging = false;\n }\n\n function openFilePicker() {\n inputRef.current?.click();\n }\n\n function clear() {\n if (previewUrl) URL.revokeObjectURL(previewUrl);\n previewUrl = null;\n onResult(null);\n if (inputRef.current) {\n inputRef.current.value = '';\n }\n }\n\n return {\n inputRef,\n openFilePicker,\n processFile,\n handleFileInputChange,\n handleDrop,\n handleDragOver,\n handleDragLeave,\n get previewUrl() {\n return previewUrl;\n },\n get isDragging() {\n return isDragging;\n },\n clear,\n accept,\n };\n}\n","export interface CropResult {\n canvas: HTMLCanvasElement;\n bounds: { x: number; y: number; width: number; height: number };\n}\n\n/**\n * Scans a canvas for non-transparent pixels and returns a tightly cropped copy.\n * Returns null if the canvas has no visible content.\n */\nexport function cropCanvas(source: HTMLCanvasElement, padding = 4): CropResult | null {\n const ctx = source.getContext('2d');\n if (!ctx) return null;\n\n const { width, height } = source;\n if (width === 0 || height === 0) return null;\n\n const imageData = ctx.getImageData(0, 0, width, height);\n const { data } = imageData;\n\n let minX = width;\n let minY = height;\n let maxX = 0;\n let maxY = 0;\n\n for (let y = 0; y < height; y++) {\n for (let x = 0; x < width; x++) {\n const alpha = data[(y * width + x) * 4 + 3];\n if (alpha > 0) {\n if (x < minX) minX = x;\n if (x > maxX) maxX = x;\n if (y < minY) minY = y;\n if (y > maxY) maxY = y;\n }\n }\n }\n\n if (maxX < minX || maxY < minY) return null;\n\n const cropX = Math.max(0, minX - padding);\n const cropY = Math.max(0, minY - padding);\n const cropW = Math.min(width, maxX + padding + 1) - cropX;\n const cropH = Math.min(height, maxY + padding + 1) - cropY;\n\n const cropped = document.createElement('canvas');\n cropped.width = cropW;\n cropped.height = cropH;\n\n const croppedCtx = cropped.getContext('2d');\n if (!croppedCtx) return null;\n\n croppedCtx.drawImage(source, cropX, cropY, cropW, cropH, 0, 0, cropW, cropH);\n\n return {\n canvas: cropped,\n bounds: { x: cropX, y: cropY, width: cropW, height: cropH },\n };\n}\n","<script lang=\"ts\">\n import { SignatureInkFieldDefinition, SignatureCreationType } from '@embedpdf/plugin-signature';\n import { cropCanvas } from '../../shared/components/crop-canvas';\n\n interface Props {\n onResult: (result: SignatureInkFieldDefinition | null) => void;\n strokeColor?: string;\n strokeWidth?: number;\n class?: string;\n }\n\n let {\n onResult,\n strokeColor = '#000000',\n strokeWidth = 4,\n class: className = '',\n }: Props = $props();\n\n let canvasEl: HTMLCanvasElement | undefined = $state();\n let strokes = $state<Array<{ points: Array<{ x: number; y: number }> }>>([]);\n let isDrawing = false;\n let size = { width: 0, height: 0 };\n const dpr = typeof window !== 'undefined' ? window.devicePixelRatio || 1 : 1;\n\n function getCanvasPos(e: PointerEvent): { x: number; y: number } {\n if (!canvasEl) return { x: 0, y: 0 };\n const rect = canvasEl.getBoundingClientRect();\n return {\n x: (e.clientX - rect.left) * (canvasEl.width / dpr / rect.width),\n y: (e.clientY - rect.top) * (canvasEl.height / dpr / rect.height),\n };\n }\n\n function redraw(currentStrokes: Array<{ points: Array<{ x: number; y: number }> }>) {\n if (!canvasEl) return;\n const ctx = canvasEl.getContext('2d');\n if (!ctx) return;\n\n ctx.clearRect(0, 0, canvasEl.width, canvasEl.height);\n ctx.save();\n ctx.scale(dpr, dpr);\n ctx.strokeStyle = strokeColor;\n ctx.lineWidth = strokeWidth;\n ctx.lineCap = 'round';\n ctx.lineJoin = 'round';\n\n for (const stroke of currentStrokes) {\n if (stroke.points.length === 0) continue;\n ctx.beginPath();\n ctx.moveTo(stroke.points[0].x, stroke.points[0].y);\n for (let i = 1; i < stroke.points.length; i++) {\n ctx.lineTo(stroke.points[i].x, stroke.points[i].y);\n }\n ctx.stroke();\n }\n ctx.restore();\n }\n\n function emitResult(currentStrokes: Array<{ points: Array<{ x: number; y: number }> }>) {\n if (currentStrokes.length === 0 || currentStrokes.every((s) => s.points.length < 2)) {\n onResult(null);\n return;\n }\n\n if (!canvasEl) return;\n\n const cropped = cropCanvas(canvasEl, Math.ceil(strokeWidth * dpr));\n if (!cropped) {\n onResult(null);\n return;\n }\n\n const offsetX = cropped.bounds.x / dpr;\n const offsetY = cropped.bounds.y / dpr;\n const croppedWidth = Math.round(cropped.bounds.width / dpr);\n const croppedHeight = Math.round(cropped.bounds.height / dpr);\n\n const result: SignatureInkFieldDefinition = {\n creationType: SignatureCreationType.Draw,\n inkData: {\n inkList: currentStrokes\n .filter((s) => s.points.length >= 2)\n .map((s) => ({\n points: s.points.map((p) => ({\n x: p.x - offsetX,\n y: p.y - offsetY,\n })),\n })),\n strokeWidth,\n strokeColor,\n size: { width: croppedWidth, height: croppedHeight },\n },\n previewDataUrl: cropped.canvas.toDataURL('image/png'),\n };\n\n onResult(result);\n }\n\n export function clear() {\n strokes = [];\n redraw([]);\n onResult(null);\n }\n\n function handlePointerDown(e: PointerEvent) {\n isDrawing = true;\n const pos = getCanvasPos(e);\n strokes = [...strokes, { points: [pos] }];\n redraw(strokes);\n (e.target as HTMLElement)?.setPointerCapture?.(e.pointerId);\n }\n\n function handlePointerMove(e: PointerEvent) {\n if (!isDrawing) return;\n const pos = getCanvasPos(e);\n const last = strokes[strokes.length - 1];\n if (last) {\n last.points.push(pos);\n strokes = [...strokes];\n redraw(strokes);\n }\n }\n\n function handlePointerUp(e: PointerEvent) {\n isDrawing = false;\n (e.target as HTMLElement)?.releasePointerCapture?.(e.pointerId);\n emitResult(strokes);\n }\n\n $effect(() => {\n if (!canvasEl) return;\n const observer = new ResizeObserver((entries) => {\n const { width: w, height: h } = entries[0].contentRect;\n if (w > 0 && h > 0 && canvasEl) {\n size = { width: Math.round(w), height: Math.round(h) };\n canvasEl.width = Math.round(w) * dpr;\n canvasEl.height = Math.round(h) * dpr;\n redraw(strokes);\n }\n });\n observer.observe(canvasEl);\n return () => observer.disconnect();\n });\n\n $effect(() => {\n // Re-render when strokeColor or strokeWidth changes\n void strokeColor;\n void strokeWidth;\n redraw(strokes);\n if (strokes.length > 0 && strokes.some((s) => s.points.length >= 2)) {\n emitResult(strokes);\n }\n });\n</script>\n\n<canvas\n bind:this={canvasEl}\n class={className}\n style=\"touch-action: none; width: 100%; height: 100%; display: block;\"\n onpointerdown={handlePointerDown}\n onpointermove={handlePointerMove}\n onpointerup={handlePointerUp}\n></canvas>\n","<script lang=\"ts\">\n import { SignatureStampFieldDefinition, SignatureCreationType } from '@embedpdf/plugin-signature';\n import { cropCanvas } from '../../shared/components/crop-canvas';\n\n interface Props {\n onResult: (result: SignatureStampFieldDefinition | null) => void;\n fontFamily?: string;\n fontSize?: number;\n color?: string;\n class?: string;\n placeholder?: string;\n }\n\n let {\n onResult,\n fontFamily = \"'Dancing Script', cursive\",\n fontSize = 48,\n color = '#000000',\n class: className = '',\n placeholder = 'Type your signature...',\n }: Props = $props();\n\n let wrapperEl: HTMLDivElement | undefined = $state();\n let canvasEl: HTMLCanvasElement | undefined = $state();\n let text = $state('');\n let size = { width: 0, height: 0 };\n const inputId = `sig-type-${Math.random().toString(36).slice(2, 8)}`;\n const dpr = typeof window !== 'undefined' ? window.devicePixelRatio || 1 : 1;\n\n function renderText(currentText: string) {\n if (!canvasEl) return;\n\n const { width, height } = size;\n if (width === 0 || height === 0) return;\n\n canvasEl.width = width * dpr;\n canvasEl.height = height * dpr;\n\n const ctx = canvasEl.getContext('2d');\n if (!ctx) return;\n\n ctx.clearRect(0, 0, canvasEl.width, canvasEl.height);\n\n if (!currentText.trim()) {\n onResult(null);\n return;\n }\n\n ctx.scale(dpr, dpr);\n ctx.fillStyle = color;\n ctx.font = `${fontSize}px ${fontFamily}`;\n ctx.textBaseline = 'middle';\n ctx.textAlign = 'center';\n ctx.fillText(currentText, width / 2, height / 2, width - 20);\n\n const cropped = cropCanvas(canvasEl, Math.ceil(4 * dpr));\n if (!cropped) {\n onResult(null);\n return;\n }\n\n const croppedWidth = Math.round(cropped.bounds.width / dpr);\n const croppedHeight = Math.round(cropped.bounds.height / dpr);\n\n cropped.canvas.toBlob((blob) => {\n if (!blob) return;\n blob.arrayBuffer().then((imageData) => {\n const result: SignatureStampFieldDefinition = {\n creationType: SignatureCreationType.Type,\n label: currentText,\n imageMimeType: 'image/png',\n imageSize: { width: croppedWidth, height: croppedHeight },\n previewDataUrl: cropped.canvas.toDataURL('image/png'),\n imageData,\n };\n onResult(result);\n });\n }, 'image/png');\n }\n\n export function clear() {\n text = '';\n onResult(null);\n }\n\n function handleInput(e: Event) {\n text = (e.target as HTMLInputElement).value;\n }\n\n $effect(() => {\n if (!wrapperEl) return;\n const observer = new ResizeObserver((entries) => {\n const { width: w, height: h } = entries[0].contentRect;\n if (w > 0 && h > 0) {\n size = { width: Math.round(w), height: Math.round(h) };\n renderText(text);\n }\n });\n observer.observe(wrapperEl);\n return () => observer.disconnect();\n });\n\n $effect(() => {\n void fontFamily;\n void color;\n renderText(text);\n });\n</script>\n\n<div bind:this={wrapperEl} class={className} style=\"width: 100%; height: 100%;\">\n {@html `<style>#${inputId}::placeholder { color: ${color}; opacity: 0.5; }</style>`}\n <input\n id={inputId}\n type=\"text\"\n value={text}\n oninput={handleInput}\n {placeholder}\n style=\"font-family: {fontFamily}; font-size: {Math.min(\n fontSize,\n 32,\n )}px; color: {color}; width: 100%; height: 100%; border: none; outline: none; background: transparent; text-indent: 8px;\"\n />\n <canvas bind:this={canvasEl} style=\"display: none;\"></canvas>\n</div>\n","import { createPluginPackage } from '@embedpdf/core';\nimport { SignaturePluginPackage as BaseSignaturePackage } from '@embedpdf/plugin-signature';\n\nexport * from './hooks';\nexport * from './components';\nexport * from '@embedpdf/plugin-signature';\n\nexport const SignaturePluginPackage = createPluginPackage(BaseSignaturePackage).build();\n"],"names":["root","BaseSignaturePackage"],"mappings":";;;;;;AAIa,MAAA,qBAAA,MAA2B,UAA2B,gBAAgB,EAAE;AACxE,MAAA,yBAAA,MAA+B,cAA+B,gBAAgB,EAAE;AAE7E,SAAA,sBAAsB;AAC9B,QAAA,aAAa,uBAAA;AACf,MAAA,UAAU,EAAA,MAAA,EAAA,MAAA,CAAA,CAAA,CAAA;AAEd,IAAA,kBAAc;SACP,WAAW,UAAU;YACxB,SAAA,CAAA,GAAA,IAAA;;IAEF;AAEA,MAAA,IAAA,SAAU,WAAW,SAAS,WAAA,GAAA,IAAA;AACvB,WAAA,WAAW,SAAS,gBAAA,CAAiB,YAAY;AACtD,QAAA,IAAA,SAAU,SAAA,IAAA;AAAA,IACZ,CAAC;AAAA,EACH,CAAC;;IAGK,IAAA,UAAU;mBACL,OAAA;AAAA,IACT;AAAA;AAEJ;SAEgB,mBAAmB,eAA6B;AACxD,QAAA,aAAa,uBAAA;MACf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,CAAA,YAAA,EAAA,IAAY,WAAS,OAAA,GAAA,MAAA,EAAA,IAAT,SAAS,CAAA;;;AAAxB,QAAA,UAAA,eAAiC,UAAS,CAAA,CAAA;AAExC,QAAA,cAAA,aACK,OAAO;AADZ,QAAA,UAAA,aAGQ,IAAI,CAAA;AAHZ,QAAA,cAAA,sBAKE,YAAW,CAAA;kBALb,OAAI,gBAMkB,WAAU,KAAA,EAAA,gBAAA,MAAA,EAAA,cAGjB,MAAK,KAAA,EAAA,sGAAA;AAAA;IAH2B,CAAA,MAAA,KAAK,IACjD,SAAQ,GACR,EAAE,CAAA;AAAA;qBAVP,GAAG;;AAFI;;ACpGD,MAAM,yBAAyB,oBAAoBC,wBAAoB,EAAE,MAAA;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SignatureInkFieldDefinition } from '../../lib/index.ts';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
onResult: (result: SignatureInkFieldDefinition | null) => void;
|
|
4
|
+
strokeColor?: string;
|
|
5
|
+
strokeWidth?: number;
|
|
6
|
+
};
|
|
7
|
+
declare function clear(): void;
|
|
8
|
+
declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {
|
|
9
|
+
clear: typeof clear;
|
|
10
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
11
|
+
strokeWidth: number;
|
|
12
|
+
strokeColor: string;
|
|
13
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
14
|
+
declare const _default: typeof __VLS_export;
|
|
15
|
+
export default _default;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SignatureStampFieldDefinition } from '../../lib/index.ts';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
onResult: (result: SignatureStampFieldDefinition | null) => void;
|
|
4
|
+
fontFamily?: string;
|
|
5
|
+
fontSize?: number;
|
|
6
|
+
color?: string;
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
};
|
|
9
|
+
declare function clear(): void;
|
|
10
|
+
declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {
|
|
11
|
+
clear: typeof clear;
|
|
12
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
13
|
+
color: string;
|
|
14
|
+
fontFamily: string;
|
|
15
|
+
fontSize: number;
|
|
16
|
+
placeholder: string;
|
|
17
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
18
|
+
declare const _default: typeof __VLS_export;
|
|
19
|
+
export default _default;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
import { SignatureStampFieldDefinition } from '../../lib/index.ts';
|
|
3
|
+
export interface UseSignatureUploadOptions {
|
|
4
|
+
accept?: string;
|
|
5
|
+
onResult: (result: SignatureStampFieldDefinition | null) => void;
|
|
6
|
+
}
|
|
7
|
+
export interface UseSignatureUploadReturn {
|
|
8
|
+
inputRef: Ref<HTMLInputElement | null>;
|
|
9
|
+
openFilePicker: () => void;
|
|
10
|
+
processFile: (file: File) => void;
|
|
11
|
+
handleFileInputChange: (e: Event) => void;
|
|
12
|
+
handleDrop: (e: DragEvent) => void;
|
|
13
|
+
handleDragOver: (e: DragEvent) => void;
|
|
14
|
+
handleDragLeave: () => void;
|
|
15
|
+
previewUrl: Ref<string | null>;
|
|
16
|
+
isDragging: Ref<boolean>;
|
|
17
|
+
clear: () => void;
|
|
18
|
+
accept: string;
|
|
19
|
+
}
|
|
20
|
+
export declare function useSignatureUpload({ accept, onResult, }: UseSignatureUploadOptions): UseSignatureUploadReturn;
|