@cosxai/ui 0.13.0 → 0.13.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cosxai/ui",
3
- "version": "0.13.0",
3
+ "version": "0.13.1",
4
4
  "description": "COSX design system — React 19 component primitives shared across product-meta and other consumers",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -165,6 +165,30 @@ export const SignaturePad = forwardRef<SignaturePadHandle, SignaturePadProps>(
165
165
  };
166
166
  }, [fontReady]);
167
167
 
168
+ // Mode switch — clear the canvas so a stale typed baseline
169
+ // doesn't hang around behind a drawn signature (or vice versa).
170
+ // MUST be declared BEFORE the typed-repaint + drawn-restore
171
+ // effects: effects run in declaration order, and v0.13.0 had
172
+ // this clear declared LAST — on switching to typed mode with a
173
+ // prefilled name the repaint painted first and this then wiped
174
+ // it (QA 2026-07-17: Type tab showed an empty pad until the
175
+ // signer edited the name). Skips the mount run so a parent-held
176
+ // captured value isn't nulled on first render.
177
+ const prevModeRef = useRef(mode);
178
+ useEffect(() => {
179
+ if (prevModeRef.current === mode) return;
180
+ prevModeRef.current = mode;
181
+ const canvas = canvasRef.current;
182
+ if (!canvas) return;
183
+ const ctx = canvas.getContext("2d");
184
+ if (!ctx) return;
185
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
186
+ dirtyRef.current = false;
187
+ onChange(null);
188
+ // Only fire when mode itself changes.
189
+ // eslint-disable-next-line react-hooks/exhaustive-deps
190
+ }, [mode]);
191
+
168
192
  // Repaint on typedName / mode / fontReady change. Drawn mode
169
193
  // doesn't repaint imperatively — strokes are appended as the user
170
194
  // draws.
@@ -233,20 +257,6 @@ export const SignaturePad = forwardRef<SignaturePadHandle, SignaturePadProps>(
233
257
  // eslint-disable-next-line react-hooks/exhaustive-deps
234
258
  }, [mode]);
235
259
 
236
- // Mode switch — clear the canvas so a stale typed baseline
237
- // doesn't hang around behind a drawn signature (or vice versa).
238
- useEffect(() => {
239
- const canvas = canvasRef.current;
240
- if (!canvas) return;
241
- const ctx = canvas.getContext("2d");
242
- if (!ctx) return;
243
- ctx.clearRect(0, 0, canvas.width, canvas.height);
244
- dirtyRef.current = false;
245
- onChange(null);
246
- // Only fire when mode itself changes.
247
- // eslint-disable-next-line react-hooks/exhaustive-deps
248
- }, [mode]);
249
-
250
260
  const clear = useCallback(() => {
251
261
  const canvas = canvasRef.current;
252
262
  if (canvas) {