@cosxai/ui 0.13.2 → 0.13.4
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/package.json
CHANGED
|
@@ -251,13 +251,21 @@ export const SignaturePad = forwardRef<SignaturePadHandle, SignaturePadProps>(
|
|
|
251
251
|
strokeColor,
|
|
252
252
|
]);
|
|
253
253
|
|
|
254
|
-
// Restore a previously-captured value into the canvas on
|
|
255
|
-
//
|
|
256
|
-
//
|
|
257
|
-
//
|
|
254
|
+
// Restore a previously-captured value into the canvas on MOUNT
|
|
255
|
+
// only (parent phase round-trips remount the pad). Typed mode
|
|
256
|
+
// uses the repaint effect above; drawn mode needs to explicitly
|
|
257
|
+
// paint the dataURL back so subsequent strokes continue on top.
|
|
258
|
+
//
|
|
259
|
+
// Deliberately NOT re-run on mode switch: the clear effect wipes
|
|
260
|
+
// the canvas on switch, and re-painting the old capture here
|
|
261
|
+
// resurrected the TYPED baseline inside the drawn pad (v0.13.2
|
|
262
|
+
// regression — switching Type → Draw showed the handwriting-font
|
|
263
|
+
// bake as if it had been drawn).
|
|
264
|
+
const didRestoreRef = useRef(false);
|
|
258
265
|
useEffect(() => {
|
|
259
|
-
if (
|
|
260
|
-
|
|
266
|
+
if (didRestoreRef.current) return;
|
|
267
|
+
didRestoreRef.current = true;
|
|
268
|
+
if (mode !== "drawn" || !value) return;
|
|
261
269
|
const canvas = canvasRef.current;
|
|
262
270
|
if (!canvas) return;
|
|
263
271
|
const ctx = canvas.getContext("2d");
|
|
@@ -270,7 +278,7 @@ export const SignaturePad = forwardRef<SignaturePadHandle, SignaturePadProps>(
|
|
|
270
278
|
};
|
|
271
279
|
img.src = value;
|
|
272
280
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
273
|
-
}, [
|
|
281
|
+
}, []);
|
|
274
282
|
|
|
275
283
|
const clear = useCallback(() => {
|
|
276
284
|
const canvas = canvasRef.current;
|
|
@@ -379,6 +387,11 @@ export const SignaturePad = forwardRef<SignaturePadHandle, SignaturePadProps>(
|
|
|
379
387
|
const canvasStyle: CSSProperties = useMemo(
|
|
380
388
|
() => ({
|
|
381
389
|
width,
|
|
390
|
+
// Never overflow a narrow container (phone signing surface) —
|
|
391
|
+
// the bitmap keeps its logical resolution and the pointer
|
|
392
|
+
// handlers already rescale via getBoundingClientRect, so CSS
|
|
393
|
+
// shrink is loss-free for drawing accuracy.
|
|
394
|
+
maxWidth: "100%",
|
|
382
395
|
height,
|
|
383
396
|
border: "1px solid var(--ck-border-subtle, #d4d4d8)",
|
|
384
397
|
borderRadius: "var(--ck-radius-sm, 6px)",
|
|
@@ -401,6 +414,8 @@ export const SignaturePad = forwardRef<SignaturePadHandle, SignaturePadProps>(
|
|
|
401
414
|
fontSize: 14,
|
|
402
415
|
fontFamily: "inherit",
|
|
403
416
|
width,
|
|
417
|
+
maxWidth: "100%",
|
|
418
|
+
boxSizing: "border-box",
|
|
404
419
|
}),
|
|
405
420
|
[width],
|
|
406
421
|
);
|