reifyui 0.13.8 → 0.14.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/index.cjs CHANGED
@@ -2363,6 +2363,24 @@ function GoogleButton({ onCredential, onError, divider = true }) {
2363
2363
  if (!CLIENT_ID || !ref.current) return void 0;
2364
2364
  const SRC = "https://accounts.google.com/gsi/client";
2365
2365
  let done = false;
2366
+ let drawn = 0;
2367
+ let observer = null;
2368
+ const draw = () => {
2369
+ const g = window.google;
2370
+ if (!g?.accounts?.id || !ref.current) return;
2371
+ const box = ref.current.getBoundingClientRect().width || 320;
2372
+ const width = Math.round(Math.max(200, Math.min(400, box)));
2373
+ if (Math.abs(width - drawn) < 2) return;
2374
+ drawn = width;
2375
+ ref.current.innerHTML = "";
2376
+ g.accounts.id.renderButton(ref.current, {
2377
+ theme: "outline",
2378
+ size: "large",
2379
+ shape: "pill",
2380
+ text: "continue_with",
2381
+ width
2382
+ });
2383
+ };
2366
2384
  const render = () => {
2367
2385
  if (done) return;
2368
2386
  const g = window.google;
@@ -2376,14 +2394,16 @@ function GoogleButton({ onCredential, onError, divider = true }) {
2376
2394
  else cb.current.onError?.("Google sign in was cancelled.");
2377
2395
  }
2378
2396
  });
2379
- ref.current.innerHTML = "";
2380
- g.accounts.id.renderButton(ref.current, {
2381
- theme: "outline",
2382
- size: "large",
2383
- shape: "pill",
2384
- text: "continue_with",
2385
- width: 320
2386
- });
2397
+ draw();
2398
+ if (typeof ResizeObserver === "function") {
2399
+ observer = new ResizeObserver(() => {
2400
+ try {
2401
+ draw();
2402
+ } catch {
2403
+ }
2404
+ });
2405
+ observer.observe(ref.current);
2406
+ }
2387
2407
  } catch {
2388
2408
  setFailed(true);
2389
2409
  }
@@ -2407,6 +2427,7 @@ function GoogleButton({ onCredential, onError, divider = true }) {
2407
2427
  return () => {
2408
2428
  s?.removeEventListener("load", render);
2409
2429
  window.clearTimeout(check);
2430
+ observer?.disconnect();
2410
2431
  };
2411
2432
  }, []);
2412
2433
  if (!CLIENT_ID || failed) return null;