@svadmin/ui 0.120.0 → 0.122.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/dist/app.css +336 -7
- package/dist/app.theme.css +336 -7
- package/dist/components/AboutSettings.svelte +1 -1
- package/dist/components/AnnouncementBanner.svelte +314 -0
- package/dist/components/AnnouncementBanner.svelte.d.ts +45 -0
- package/dist/components/AsyncExportModal.svelte +551 -0
- package/dist/components/AsyncExportModal.svelte.d.ts +50 -0
- package/dist/components/AudioFeedbackProvider.svelte +131 -0
- package/dist/components/AudioFeedbackProvider.svelte.d.ts +11 -0
- package/dist/components/AuditLogViewer.svelte +1 -1
- package/dist/components/CanvasAnnotation.svelte +1 -1
- package/dist/components/ColumnFilterBuilder.svelte +135 -0
- package/dist/components/ColumnFilterBuilder.svelte.d.ts +20 -0
- package/dist/components/ColumnSettings.svelte +1 -1
- package/dist/components/ColumnVisibilityDrawer.svelte +541 -0
- package/dist/components/ColumnVisibilityDrawer.svelte.d.ts +16 -0
- package/dist/components/ConcurrentConflictModal.svelte +7 -7
- package/dist/components/ContextMenu.svelte +268 -0
- package/dist/components/ContextMenu.svelte.d.ts +22 -0
- package/dist/components/ConversionFunnel.svelte +154 -0
- package/dist/components/ConversionFunnel.svelte.d.ts +22 -0
- package/dist/components/CronExpressionBuilder.svelte +1 -1
- package/dist/components/DecisionTable.svelte +1 -1
- package/dist/components/DevTools.svelte +1 -1
- package/dist/components/DraggableRowTable.svelte +1 -1
- package/dist/components/DualApprovalGate.svelte +418 -0
- package/dist/components/DualApprovalGate.svelte.d.ts +39 -0
- package/dist/components/EditableTable.svelte +1 -1
- package/dist/components/ExcelImportWizard.svelte +2 -2
- package/dist/components/GlobalShortcuts.svelte +1 -1
- package/dist/components/ImageCropper.svelte +1 -1
- package/dist/components/ImportWizard.svelte +1 -1
- package/dist/components/JsonSchemaForm.svelte +1 -1
- package/dist/components/JsonViewer.svelte +323 -0
- package/dist/components/JsonViewer.svelte.d.ts +20 -0
- package/dist/components/KeyboardShortcutsModal.svelte +362 -0
- package/dist/components/KeyboardShortcutsModal.svelte.d.ts +22 -0
- package/dist/components/KpiCard.svelte +250 -0
- package/dist/components/KpiCard.svelte.d.ts +44 -0
- package/dist/components/MasterDetailView.svelte +1 -1
- package/dist/components/MetricGrid.svelte +2 -2
- package/dist/components/MicroAppBridge.svelte +59 -0
- package/dist/components/MicroAppBridge.svelte.d.ts +11 -0
- package/dist/components/OfflineSyncBanner.svelte +1 -1
- package/dist/components/OrgChart.svelte +1 -1
- package/dist/components/OrgTreePicker.svelte +1 -1
- package/dist/components/OtpInput.svelte +209 -0
- package/dist/components/OtpInput.svelte.d.ts +17 -0
- package/dist/components/PdfDocumentViewer.svelte +2 -2
- package/dist/components/PivotDrilldownModal.svelte +6 -6
- package/dist/components/PivotTable.svelte +1 -1
- package/dist/components/PricingCard.svelte +1 -1
- package/dist/components/PricingTable.svelte +1 -1
- package/dist/components/PrintableBill.svelte +2 -2
- package/dist/components/PrintableReportLayout.svelte +259 -0
- package/dist/components/PrintableReportLayout.svelte.d.ts +32 -0
- package/dist/components/ProSkeleton.svelte +6 -6
- package/dist/components/RecordCompareModal.svelte +428 -0
- package/dist/components/RecordCompareModal.svelte.d.ts +42 -0
- package/dist/components/ResultPage.svelte +166 -0
- package/dist/components/ResultPage.svelte.d.ts +28 -0
- package/dist/components/SafeDeleteConfirm.svelte +5 -5
- package/dist/components/SankeyChart.svelte +111 -0
- package/dist/components/SankeyChart.svelte.d.ts +22 -0
- package/dist/components/SchemaVisualModeler.svelte +336 -0
- package/dist/components/SchemaVisualModeler.svelte.d.ts +17 -0
- package/dist/components/SensitiveDataMask.svelte +81 -22
- package/dist/components/SensitiveDataMask.svelte.d.ts +15 -10
- package/dist/components/SessionTimeoutGuard.svelte +154 -0
- package/dist/components/SessionTimeoutGuard.svelte.d.ts +25 -0
- package/dist/components/SignaturePad.svelte +231 -67
- package/dist/components/SignaturePad.svelte.d.ts +6 -5
- package/dist/components/SliderCaptcha.svelte +1 -1
- package/dist/components/SplitPaneLayout.svelte +1 -1
- package/dist/components/SpreadsheetView.svelte +1 -1
- package/dist/components/StepForm.svelte +1 -1
- package/dist/components/StepWizard.svelte +513 -0
- package/dist/components/StepWizard.svelte.d.ts +49 -0
- package/dist/components/TableClipboardManager.svelte +307 -0
- package/dist/components/TableClipboardManager.svelte.d.ts +13 -0
- package/dist/components/TaskCenter.svelte +9 -9
- package/dist/components/TextDiffViewer.svelte +613 -0
- package/dist/components/TextDiffViewer.svelte.d.ts +39 -0
- package/dist/components/Tour.svelte +71 -13
- package/dist/components/Tour.svelte.d.ts +1 -1
- package/dist/components/TreeTransfer.svelte +1 -1
- package/dist/components/TrendIndicator.svelte +21 -13
- package/dist/components/TrendIndicator.svelte.d.ts +4 -2
- package/dist/components/UnsavedChangesGuard.svelte +138 -0
- package/dist/components/UnsavedChangesGuard.svelte.d.ts +32 -0
- package/dist/components/UsageCard.svelte +1 -1
- package/dist/components/VersionDiffViewer.svelte +1 -1
- package/dist/components/VirtualTable.svelte +1 -1
- package/dist/components/VirtualTreeSelect.svelte +1 -1
- package/dist/components/WatermarkContainer.svelte +196 -0
- package/dist/components/WatermarkContainer.svelte.d.ts +20 -0
- package/dist/components/WorkflowDesigner.svelte +3 -3
- package/dist/components/WorkflowProcessCard.svelte +1 -1
- package/dist/components/WorkflowStepper.svelte +250 -0
- package/dist/components/WorkflowStepper.svelte.d.ts +27 -0
- package/dist/components/charts/GaugeChart.svelte +1 -1
- package/dist/components/useAudioAlert.d.svelte.ts +1 -0
- package/dist/components/useAudioAlert.svelte.d.ts +13 -0
- package/dist/components/useAudioAlert.svelte.js +90 -0
- package/dist/components/useHotkeys.d.svelte.ts +1 -0
- package/dist/components/useHotkeys.svelte.d.ts +44 -0
- package/dist/components/useHotkeys.svelte.js +190 -0
- package/dist/components/useMicroAppEvent.d.svelte.ts +1 -0
- package/dist/components/useMicroAppEvent.svelte.d.ts +16 -0
- package/dist/components/useMicroAppEvent.svelte.js +61 -0
- package/dist/components/usePrintExport.d.svelte.ts +1 -0
- package/dist/components/usePrintExport.svelte.d.ts +11 -0
- package/dist/components/usePrintExport.svelte.js +45 -0
- package/dist/components/useSessionTimeout.d.svelte.ts +1 -0
- package/dist/components/useSessionTimeout.svelte.d.ts +28 -0
- package/dist/components/useSessionTimeout.svelte.js +182 -0
- package/dist/components/useTableClipboard.d.svelte.ts +1 -0
- package/dist/components/useTableClipboard.svelte.d.ts +28 -0
- package/dist/components/useTableClipboard.svelte.js +116 -0
- package/dist/components/useUnsavedChanges.d.svelte.ts +1 -0
- package/dist/components/useUnsavedChanges.svelte.d.ts +22 -0
- package/dist/components/useUnsavedChanges.svelte.js +105 -0
- package/dist/index.d.ts +47 -28
- package/dist/index.js +49 -2
- package/package.json +1 -1
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { onMount } from 'svelte';
|
|
3
3
|
import { Button } from './ui/button/index.js';
|
|
4
|
-
import { RotateCcw, Trash2, Check, Download } from '@lucide/svelte';
|
|
4
|
+
import { RotateCcw, RotateCw, Trash2, Check, Download, FileCode } from '@lucide/svelte';
|
|
5
5
|
import { cn } from '../utils.js';
|
|
6
6
|
|
|
7
|
-
interface
|
|
7
|
+
export interface SignaturePadProps {
|
|
8
8
|
value?: string;
|
|
9
9
|
width?: number;
|
|
10
10
|
height?: number;
|
|
11
11
|
strokeColor?: string;
|
|
12
12
|
strokeWidth?: number;
|
|
13
13
|
disabled?: boolean;
|
|
14
|
+
withTimestamp?: boolean;
|
|
14
15
|
onchange?: (dataUrl: string) => void;
|
|
15
16
|
onsave?: (dataUrl: string) => void;
|
|
16
17
|
class?: string;
|
|
@@ -23,22 +24,26 @@
|
|
|
23
24
|
strokeColor = 'currentColor',
|
|
24
25
|
strokeWidth = 2.5,
|
|
25
26
|
disabled = false,
|
|
27
|
+
withTimestamp = false,
|
|
26
28
|
onchange,
|
|
27
29
|
onsave,
|
|
28
30
|
class: className = '',
|
|
29
|
-
}:
|
|
31
|
+
}: SignaturePadProps = $props();
|
|
30
32
|
|
|
31
33
|
let canvasEl = $state<HTMLCanvasElement | null>(null);
|
|
32
34
|
let isDrawing = $state(false);
|
|
33
35
|
let isEmpty = $state(true);
|
|
34
|
-
let
|
|
36
|
+
let undoHistory = $state<ImageData[]>([]);
|
|
37
|
+
let redoHistory = $state<ImageData[]>([]);
|
|
35
38
|
|
|
36
39
|
interface Point {
|
|
37
40
|
x: number;
|
|
38
41
|
y: number;
|
|
39
42
|
}
|
|
40
43
|
|
|
41
|
-
let
|
|
44
|
+
let currentStroke = $state<Point[]>([]);
|
|
45
|
+
let allStrokes = $state<Point[][]>([]);
|
|
46
|
+
let redoStrokes = $state<Point[][]>([]);
|
|
42
47
|
|
|
43
48
|
function getCanvasPos(e: MouseEvent | TouchEvent): Point | null {
|
|
44
49
|
if (!canvasEl) return null;
|
|
@@ -64,18 +69,38 @@
|
|
|
64
69
|
}
|
|
65
70
|
}
|
|
66
71
|
|
|
72
|
+
function setupContext(ctx: CanvasRenderingContext2D) {
|
|
73
|
+
ctx.strokeStyle = strokeColor === 'currentColor'
|
|
74
|
+
? (canvasEl ? getComputedStyle(canvasEl).color || 'rgb(24, 24, 27)' : 'rgb(24, 24, 27)')
|
|
75
|
+
: strokeColor;
|
|
76
|
+
ctx.lineWidth = strokeWidth;
|
|
77
|
+
ctx.lineCap = 'round';
|
|
78
|
+
ctx.lineJoin = 'round';
|
|
79
|
+
}
|
|
80
|
+
|
|
67
81
|
function startDrawing(e: MouseEvent | TouchEvent) {
|
|
68
82
|
if (disabled || !canvasEl) return;
|
|
69
83
|
const pos = getCanvasPos(e);
|
|
70
84
|
if (!pos) return;
|
|
71
85
|
|
|
72
86
|
const ctx = canvasEl.getContext('2d');
|
|
73
|
-
if (ctx)
|
|
74
|
-
|
|
75
|
-
|
|
87
|
+
if (!ctx) return;
|
|
88
|
+
|
|
89
|
+
// Save state before this new stroke for undo
|
|
90
|
+
const snapshot = ctx.getImageData(0, 0, canvasEl.width, canvasEl.height);
|
|
91
|
+
undoHistory = [...undoHistory, snapshot];
|
|
92
|
+
redoHistory = [];
|
|
93
|
+
redoStrokes = [];
|
|
76
94
|
|
|
77
95
|
isDrawing = true;
|
|
78
|
-
|
|
96
|
+
isEmpty = false;
|
|
97
|
+
currentStroke = [pos];
|
|
98
|
+
|
|
99
|
+
setupContext(ctx);
|
|
100
|
+
ctx.beginPath();
|
|
101
|
+
ctx.arc(pos.x, pos.y, strokeWidth / 2, 0, Math.PI * 2);
|
|
102
|
+
ctx.fillStyle = ctx.strokeStyle;
|
|
103
|
+
ctx.fill();
|
|
79
104
|
}
|
|
80
105
|
|
|
81
106
|
function draw(e: MouseEvent | TouchEvent) {
|
|
@@ -83,50 +108,45 @@
|
|
|
83
108
|
const pos = getCanvasPos(e);
|
|
84
109
|
if (!pos) return;
|
|
85
110
|
|
|
86
|
-
points.push(pos);
|
|
87
111
|
const ctx = canvasEl.getContext('2d');
|
|
88
112
|
if (!ctx) return;
|
|
89
113
|
|
|
90
|
-
|
|
91
|
-
ctx
|
|
92
|
-
|
|
93
|
-
|
|
114
|
+
currentStroke.push(pos);
|
|
115
|
+
setupContext(ctx);
|
|
116
|
+
|
|
117
|
+
// Quadratic Bezier curve smoothing for natural calligraphy stroke
|
|
118
|
+
if (currentStroke.length >= 3) {
|
|
119
|
+
const p0 = currentStroke[currentStroke.length - 3];
|
|
120
|
+
const p1 = currentStroke[currentStroke.length - 2];
|
|
121
|
+
const p2 = currentStroke[currentStroke.length - 1];
|
|
122
|
+
|
|
123
|
+
if (p0 && p1 && p2) {
|
|
124
|
+
const mid1 = { x: (p0.x + p1.x) / 2, y: (p0.y + p1.y) / 2 };
|
|
125
|
+
const mid2 = { x: (p1.x + p2.x) / 2, y: (p1.y + p2.y) / 2 };
|
|
94
126
|
|
|
95
|
-
if (points.length < 3) {
|
|
96
|
-
const b = points[0];
|
|
97
|
-
if (b) {
|
|
98
127
|
ctx.beginPath();
|
|
99
|
-
ctx.
|
|
100
|
-
ctx.
|
|
101
|
-
ctx.
|
|
102
|
-
ctx.closePath();
|
|
128
|
+
ctx.moveTo(mid1.x, mid1.y);
|
|
129
|
+
ctx.quadraticCurveTo(p1.x, p1.y, mid2.x, mid2.y);
|
|
130
|
+
ctx.stroke();
|
|
103
131
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
ctx.moveTo(p0.x, p0.y);
|
|
112
|
-
}
|
|
113
|
-
for (let i = 1; i < points.length - 1; i++) {
|
|
114
|
-
const pi = points[i];
|
|
115
|
-
const pi1 = points[i + 1];
|
|
116
|
-
if (pi && pi1) {
|
|
117
|
-
const xc = (pi.x + pi1.x) / 2;
|
|
118
|
-
const yc = (pi.y + pi1.y) / 2;
|
|
119
|
-
ctx.quadraticCurveTo(pi.x, pi.y, xc, yc);
|
|
132
|
+
} else if (currentStroke.length === 2) {
|
|
133
|
+
const p0 = currentStroke[0];
|
|
134
|
+
if (p0) {
|
|
135
|
+
ctx.beginPath();
|
|
136
|
+
ctx.moveTo(p0.x, p0.y);
|
|
137
|
+
ctx.lineTo(pos.x, pos.y);
|
|
138
|
+
ctx.stroke();
|
|
120
139
|
}
|
|
121
140
|
}
|
|
122
|
-
ctx.stroke();
|
|
123
|
-
isEmpty = false;
|
|
124
141
|
}
|
|
125
142
|
|
|
126
143
|
function stopDrawing() {
|
|
127
144
|
if (!isDrawing || !canvasEl) return;
|
|
128
145
|
isDrawing = false;
|
|
129
|
-
|
|
146
|
+
if (currentStroke.length > 0) {
|
|
147
|
+
allStrokes = [...allStrokes, [...currentStroke]];
|
|
148
|
+
currentStroke = [];
|
|
149
|
+
}
|
|
130
150
|
|
|
131
151
|
const dataUrl = canvasEl.toDataURL('image/png');
|
|
132
152
|
value = dataUrl;
|
|
@@ -137,55 +157,170 @@
|
|
|
137
157
|
if (!canvasEl) return;
|
|
138
158
|
const ctx = canvasEl.getContext('2d');
|
|
139
159
|
if (!ctx) return;
|
|
160
|
+
|
|
161
|
+
const snapshot = ctx.getImageData(0, 0, canvasEl.width, canvasEl.height);
|
|
162
|
+
undoHistory = [...undoHistory, snapshot];
|
|
163
|
+
redoHistory = [];
|
|
164
|
+
redoStrokes = [];
|
|
165
|
+
allStrokes = [];
|
|
166
|
+
currentStroke = [];
|
|
167
|
+
|
|
140
168
|
ctx.clearRect(0, 0, canvasEl.width, canvasEl.height);
|
|
141
|
-
history = [];
|
|
142
169
|
isEmpty = true;
|
|
143
170
|
value = '';
|
|
144
171
|
onchange?.('');
|
|
145
172
|
}
|
|
146
173
|
|
|
147
|
-
export function toDataURL(type = 'image/png'): string {
|
|
148
|
-
return canvasEl ? canvasEl.toDataURL(type) : '';
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
export function toSVG(): string {
|
|
152
|
-
if (!canvasEl) return '';
|
|
153
|
-
return `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}"><image href="${toDataURL()}" width="${width}" height="${height}" /></svg>`;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
export function getIsEmpty(): boolean {
|
|
157
|
-
return isEmpty;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
174
|
export function undo() {
|
|
161
|
-
if (!canvasEl ||
|
|
175
|
+
if (!canvasEl || undoHistory.length === 0) return;
|
|
162
176
|
const ctx = canvasEl.getContext('2d');
|
|
163
177
|
if (!ctx) return;
|
|
164
|
-
|
|
165
|
-
|
|
178
|
+
|
|
179
|
+
const currentFrame = ctx.getImageData(0, 0, canvasEl.width, canvasEl.height);
|
|
180
|
+
redoHistory = [...redoHistory, currentFrame];
|
|
181
|
+
|
|
182
|
+
if (allStrokes.length > 0) {
|
|
183
|
+
const lastStroke = allStrokes[allStrokes.length - 1];
|
|
184
|
+
if (lastStroke) {
|
|
185
|
+
redoStrokes = [...redoStrokes, lastStroke];
|
|
186
|
+
}
|
|
187
|
+
allStrokes = allStrokes.slice(0, -1);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const previous = undoHistory[undoHistory.length - 1];
|
|
191
|
+
undoHistory = undoHistory.slice(0, -1);
|
|
166
192
|
if (previous) {
|
|
167
193
|
ctx.putImageData(previous, 0, 0);
|
|
168
194
|
}
|
|
169
|
-
|
|
195
|
+
|
|
196
|
+
isEmpty = undoHistory.length === 0 && allStrokes.length === 0;
|
|
170
197
|
const dataUrl = isEmpty ? '' : canvasEl.toDataURL('image/png');
|
|
171
198
|
value = dataUrl;
|
|
172
199
|
onchange?.(dataUrl);
|
|
173
200
|
}
|
|
174
201
|
|
|
202
|
+
export function redo() {
|
|
203
|
+
if (!canvasEl || redoHistory.length === 0) return;
|
|
204
|
+
const ctx = canvasEl.getContext('2d');
|
|
205
|
+
if (!ctx) return;
|
|
206
|
+
|
|
207
|
+
const currentFrame = ctx.getImageData(0, 0, canvasEl.width, canvasEl.height);
|
|
208
|
+
undoHistory = [...undoHistory, currentFrame];
|
|
209
|
+
|
|
210
|
+
const nextFrame = redoHistory[redoHistory.length - 1];
|
|
211
|
+
redoHistory = redoHistory.slice(0, -1);
|
|
212
|
+
if (nextFrame) {
|
|
213
|
+
ctx.putImageData(nextFrame, 0, 0);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
if (redoStrokes.length > 0) {
|
|
217
|
+
const nextStroke = redoStrokes[redoStrokes.length - 1];
|
|
218
|
+
if (nextStroke) {
|
|
219
|
+
allStrokes = [...allStrokes, nextStroke];
|
|
220
|
+
}
|
|
221
|
+
redoStrokes = redoStrokes.slice(0, -1);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
isEmpty = false;
|
|
225
|
+
const dataUrl = canvasEl.toDataURL('image/png');
|
|
226
|
+
value = dataUrl;
|
|
227
|
+
onchange?.(dataUrl);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export function toSVG(): string {
|
|
231
|
+
const strokeHex = strokeColor === 'currentColor' ? 'currentColor' : strokeColor;
|
|
232
|
+
let paths = '';
|
|
233
|
+
|
|
234
|
+
for (const stroke of allStrokes) {
|
|
235
|
+
if (stroke.length === 0) continue;
|
|
236
|
+
const first = stroke[0];
|
|
237
|
+
if (!first) continue;
|
|
238
|
+
|
|
239
|
+
if (stroke.length === 1) {
|
|
240
|
+
paths += `<circle cx="${first.x.toFixed(1)}" cy="${first.y.toFixed(1)}" r="${(strokeWidth / 2).toFixed(1)}" fill="${strokeHex}" />\n`;
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
let d = `M ${first.x.toFixed(1)} ${first.y.toFixed(1)}`;
|
|
244
|
+
if (stroke.length === 2) {
|
|
245
|
+
const second = stroke[1];
|
|
246
|
+
if (second) {
|
|
247
|
+
d += ` L ${second.x.toFixed(1)} ${second.y.toFixed(1)}`;
|
|
248
|
+
}
|
|
249
|
+
} else {
|
|
250
|
+
for (let i = 1; i < stroke.length - 1; i++) {
|
|
251
|
+
const p1 = stroke[i];
|
|
252
|
+
const p2 = stroke[i + 1];
|
|
253
|
+
if (p1 && p2) {
|
|
254
|
+
const mid = { x: (p1.x + p2.x) / 2, y: (p1.y + p2.y) / 2 };
|
|
255
|
+
d += ` Q ${p1.x.toFixed(1)} ${p1.y.toFixed(1)}, ${mid.x.toFixed(1)} ${mid.y.toFixed(1)}`;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
const last = stroke[stroke.length - 1];
|
|
259
|
+
if (last) {
|
|
260
|
+
d += ` L ${last.x.toFixed(1)} ${last.y.toFixed(1)}`;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
paths += `<path d="${d}" fill="none" stroke="${strokeHex}" stroke-width="${strokeWidth}" stroke-linecap="round" stroke-linejoin="round" />\n`;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
let timestampSvg = '';
|
|
267
|
+
if (withTimestamp) {
|
|
268
|
+
const ts = new Date().toISOString().replace('T', ' ').slice(0, 19) + ' UTC';
|
|
269
|
+
timestampSvg = `<text x="${width - 12}" y="${height - 10}" text-anchor="end" font-family="monospace" font-size="10" fill="currentColor" opacity="0.65">Signed: ${ts} (Verified)</text>\n`;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}" viewBox="0 0 ${width} ${height}">\n${paths}${timestampSvg}</svg>`;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
export function toDataURL(type = 'image/png'): string {
|
|
276
|
+
if (!canvasEl || isEmpty) return '';
|
|
277
|
+
if (!withTimestamp) {
|
|
278
|
+
return canvasEl.toDataURL(type);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// Embed tamper-evident verification timestamp watermark
|
|
282
|
+
const offscreen = document.createElement('canvas');
|
|
283
|
+
offscreen.width = canvasEl.width;
|
|
284
|
+
offscreen.height = canvasEl.height;
|
|
285
|
+
const ctx = offscreen.getContext('2d');
|
|
286
|
+
if (!ctx) return canvasEl.toDataURL(type);
|
|
287
|
+
|
|
288
|
+
ctx.drawImage(canvasEl, 0, 0);
|
|
289
|
+
ctx.font = '10px monospace';
|
|
290
|
+
ctx.fillStyle = 'rgba(113, 113, 122, 0.8)';
|
|
291
|
+
ctx.textAlign = 'right';
|
|
292
|
+
const ts = new Date().toISOString().replace('T', ' ').slice(0, 19) + ' UTC';
|
|
293
|
+
ctx.fillText(`Signed: ${ts} (Verified)`, offscreen.width - 12, offscreen.height - 10);
|
|
294
|
+
|
|
295
|
+
return offscreen.toDataURL(type);
|
|
296
|
+
}
|
|
297
|
+
|
|
175
298
|
function handleSave() {
|
|
176
299
|
if (isEmpty || !canvasEl) return;
|
|
177
|
-
const dataUrl =
|
|
300
|
+
const dataUrl = toDataURL('image/png');
|
|
178
301
|
onsave?.(dataUrl);
|
|
179
302
|
}
|
|
180
303
|
|
|
181
|
-
function
|
|
304
|
+
function handleDownloadPNG() {
|
|
182
305
|
if (isEmpty || !canvasEl) return;
|
|
183
306
|
const a = document.createElement('a');
|
|
184
|
-
a.href =
|
|
307
|
+
a.href = toDataURL('image/png');
|
|
185
308
|
a.download = `signature_${Date.now()}.png`;
|
|
186
309
|
a.click();
|
|
187
310
|
}
|
|
188
311
|
|
|
312
|
+
function handleDownloadSVG() {
|
|
313
|
+
if (isEmpty) return;
|
|
314
|
+
const svgContent = toSVG();
|
|
315
|
+
const blob = new Blob([svgContent], { type: 'image/svg+xml;charset=utf-8' });
|
|
316
|
+
const url = URL.createObjectURL(blob);
|
|
317
|
+
const a = document.createElement('a');
|
|
318
|
+
a.href = url;
|
|
319
|
+
a.download = `signature_${Date.now()}.svg`;
|
|
320
|
+
a.click();
|
|
321
|
+
URL.revokeObjectURL(url);
|
|
322
|
+
}
|
|
323
|
+
|
|
189
324
|
onMount(() => {
|
|
190
325
|
if (canvasEl && value) {
|
|
191
326
|
const img = new Image();
|
|
@@ -201,10 +336,16 @@
|
|
|
201
336
|
});
|
|
202
337
|
</script>
|
|
203
338
|
|
|
204
|
-
<div data-svadmin-component="SignaturePad" class={cn('rounded-
|
|
339
|
+
<div data-svadmin-component="SignaturePad" class={cn('rounded-md border border-border bg-card p-4 shadow-xs text-xs space-y-3', className)}>
|
|
205
340
|
<div class="flex items-center justify-between gap-2 pb-2 border-b border-border/60">
|
|
206
|
-
<div class="font-semibold text-foreground">
|
|
207
|
-
|
|
341
|
+
<div class="font-semibold text-foreground flex items-center gap-2">
|
|
342
|
+
<span>Electronic Signature</span>
|
|
343
|
+
<span class="text-muted-foreground font-normal">(Sign inside the box)</span>
|
|
344
|
+
{#if withTimestamp}
|
|
345
|
+
<span class="font-mono text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground">
|
|
346
|
+
Timestamped
|
|
347
|
+
</span>
|
|
348
|
+
{/if}
|
|
208
349
|
</div>
|
|
209
350
|
|
|
210
351
|
<div class="flex items-center gap-1.5">
|
|
@@ -212,13 +353,24 @@
|
|
|
212
353
|
variant="ghost"
|
|
213
354
|
size="sm"
|
|
214
355
|
class="h-7 text-xs gap-1 text-muted-foreground hover:text-foreground"
|
|
215
|
-
disabled={
|
|
356
|
+
disabled={undoHistory.length === 0 || disabled}
|
|
216
357
|
onclick={undo}
|
|
217
358
|
>
|
|
218
359
|
<RotateCcw class="h-3 w-3" />
|
|
219
360
|
Undo
|
|
220
361
|
</Button>
|
|
221
362
|
|
|
363
|
+
<Button
|
|
364
|
+
variant="ghost"
|
|
365
|
+
size="sm"
|
|
366
|
+
class="h-7 text-xs gap-1 text-muted-foreground hover:text-foreground"
|
|
367
|
+
disabled={redoHistory.length === 0 || disabled}
|
|
368
|
+
onclick={redo}
|
|
369
|
+
>
|
|
370
|
+
<RotateCw class="h-3 w-3" />
|
|
371
|
+
Redo
|
|
372
|
+
</Button>
|
|
373
|
+
|
|
222
374
|
<Button
|
|
223
375
|
variant="ghost"
|
|
224
376
|
size="sm"
|
|
@@ -230,6 +382,18 @@
|
|
|
230
382
|
Clear
|
|
231
383
|
</Button>
|
|
232
384
|
|
|
385
|
+
<Button
|
|
386
|
+
variant="outline"
|
|
387
|
+
size="sm"
|
|
388
|
+
class="h-7 text-xs gap-1 text-muted-foreground hover:text-foreground"
|
|
389
|
+
disabled={isEmpty || disabled}
|
|
390
|
+
onclick={handleDownloadSVG}
|
|
391
|
+
title="Export Vector SVG"
|
|
392
|
+
>
|
|
393
|
+
<FileCode class="h-3 w-3" />
|
|
394
|
+
SVG
|
|
395
|
+
</Button>
|
|
396
|
+
|
|
233
397
|
{#if onsave}
|
|
234
398
|
<Button
|
|
235
399
|
size="sm"
|
|
@@ -244,9 +408,9 @@
|
|
|
244
408
|
<Button
|
|
245
409
|
variant="outline"
|
|
246
410
|
size="sm"
|
|
247
|
-
class="h-7 text-xs gap-1"
|
|
411
|
+
class="h-7 text-xs gap-1 text-muted-foreground hover:text-foreground"
|
|
248
412
|
disabled={isEmpty || disabled}
|
|
249
|
-
onclick={
|
|
413
|
+
onclick={handleDownloadPNG}
|
|
250
414
|
>
|
|
251
415
|
<Download class="h-3 w-3" />
|
|
252
416
|
Download
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
interface
|
|
1
|
+
export interface SignaturePadProps {
|
|
2
2
|
value?: string;
|
|
3
3
|
width?: number;
|
|
4
4
|
height?: number;
|
|
5
5
|
strokeColor?: string;
|
|
6
6
|
strokeWidth?: number;
|
|
7
7
|
disabled?: boolean;
|
|
8
|
+
withTimestamp?: boolean;
|
|
8
9
|
onchange?: (dataUrl: string) => void;
|
|
9
10
|
onsave?: (dataUrl: string) => void;
|
|
10
11
|
class?: string;
|
|
11
12
|
}
|
|
12
|
-
declare const SignaturePad: import("svelte").Component<
|
|
13
|
+
declare const SignaturePad: import("svelte").Component<SignaturePadProps, {
|
|
13
14
|
clear: () => void;
|
|
14
|
-
toDataURL: (type?: string) => string;
|
|
15
|
-
toSVG: () => string;
|
|
16
|
-
getIsEmpty: () => boolean;
|
|
17
15
|
undo: () => void;
|
|
16
|
+
redo: () => void;
|
|
17
|
+
toSVG: () => string;
|
|
18
|
+
toDataURL: (type?: string) => string;
|
|
18
19
|
}, "value">;
|
|
19
20
|
type SignaturePad = ReturnType<typeof SignaturePad>;
|
|
20
21
|
export default SignaturePad;
|
|
@@ -326,7 +326,7 @@
|
|
|
326
326
|
|
|
327
327
|
<div
|
|
328
328
|
class={cn(
|
|
329
|
-
'relative select-none rounded-
|
|
329
|
+
'relative select-none rounded-md border border-border bg-card p-3 shadow-md transition-all',
|
|
330
330
|
isShaking && 'animate-shake',
|
|
331
331
|
className
|
|
332
332
|
)}
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
<div
|
|
68
68
|
bind:this={containerEl}
|
|
69
69
|
class={cn(
|
|
70
|
-
'relative flex w-full h-full min-h-72 rounded-
|
|
70
|
+
'relative flex w-full h-full min-h-72 rounded-md border border-border bg-card shadow-xs overflow-hidden select-none',
|
|
71
71
|
direction === 'horizontal' ? 'flex-row' : 'flex-col',
|
|
72
72
|
className
|
|
73
73
|
)}
|
|
@@ -1057,7 +1057,7 @@
|
|
|
1057
1057
|
}
|
|
1058
1058
|
</script>
|
|
1059
1059
|
|
|
1060
|
-
<div data-testid="spreadsheet-view" class={cn('rounded-
|
|
1060
|
+
<div data-testid="spreadsheet-view" class={cn('rounded-md border border-border bg-card shadow-xs text-xs space-y-2 p-3 overflow-hidden', className)}>
|
|
1061
1061
|
<div class="flex flex-wrap items-center justify-between gap-2 pb-2 border-b border-border/60">
|
|
1062
1062
|
<div class="flex items-center gap-2">
|
|
1063
1063
|
<FileSpreadsheet class="h-4 w-4 text-primary shrink-0" />
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
}
|
|
74
74
|
</script>
|
|
75
75
|
|
|
76
|
-
<div class={cn('space-y-6 rounded-
|
|
76
|
+
<div class={cn('space-y-6 rounded-md border border-border bg-card p-6 shadow-xs', className)}>
|
|
77
77
|
<!-- Step Navigation Header -->
|
|
78
78
|
<div class="flex items-center justify-between gap-2 overflow-x-auto pb-4 border-b border-border/60">
|
|
79
79
|
{#each steps as step, index (index)}
|