@zoreal/oauth2-react 0.2.15 → 0.2.16

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
@@ -41,7 +41,7 @@ var import_react2 = require("react");
41
41
 
42
42
  // src/wire.ts
43
43
  var WIRE_VERSION = 1;
44
- var SDK_VERSION = "0.2.15";
44
+ var SDK_VERSION = "0.2.16";
45
45
  var DEFAULT_ISSUER = "https://id.zoreal.com";
46
46
  var POLL_INTERVAL_MS = 2e3;
47
47
  var POLL_INTERVAL_ENROLLING_MS = 5e3;
@@ -1370,10 +1370,15 @@ var CSS = `
1370
1370
  sides and lights two edges at once near the ends. So here the light is a
1371
1371
  dash on an SVG outline, which moves at one speed the whole way round
1372
1372
  whatever the shape, drawn with the well's tokens: its colour and head
1373
- tint, its line width, its halo, its four second lap. pathLength makes the
1374
- outline 100 units long, so every dash and offset is a percentage of the
1375
- way round; the three layers share one head at 30 and differ in length
1376
- and brightness, which is the comet's tail. Shown only while busy. */
1373
+ tint, its line width, its halo, its four second lap. The outline's length
1374
+ is measured by the component and set as --zrl-ring-len, and every dash
1375
+ and offset is a fraction of it, because pathLength does not scale dash
1376
+ values given from CSS. A stroke cannot fade along its length, so the tail
1377
+ is a stack of dashes sharing one head, each shorter and more opaque than
1378
+ the one under it, with opacities chosen so the stack composes to a
1379
+ straight fade from the head to nothing three tenths of the way back; the
1380
+ component sets each layer's length, offset and opacity. Shown only while
1381
+ busy. */
1377
1382
  .${PREFIX}-ring {
1378
1383
  position: relative;
1379
1384
  display: inline-flex;
@@ -1392,6 +1397,7 @@ var CSS = `
1392
1397
  }
1393
1398
  .${PREFIX}-ring[data-busy="true"] > .${PREFIX}-ring-svg { opacity: 1; }
1394
1399
  .${PREFIX}-ring-svg rect {
1400
+ --zrl-l: var(--zrl-ring-len, 600px);
1395
1401
  x: 2px;
1396
1402
  y: 2px;
1397
1403
  width: calc(100% - 4px);
@@ -1400,23 +1406,18 @@ var CSS = `
1400
1406
  stroke: var(--zrl-beam);
1401
1407
  stroke-width: var(--zrl-beam-line);
1402
1408
  stroke-linecap: round;
1409
+ stroke-dashoffset: var(--zrl-s, 0px);
1403
1410
  animation: ${PREFIX}-dash var(--zrl-beam-time) linear infinite;
1404
1411
  }
1405
- .${PREFIX}-ring-tail { stroke-dasharray: 30 70; stroke-dashoffset: 0; opacity: 0.35; }
1406
- .${PREFIX}-ring-body { stroke-dasharray: 16 84; stroke-dashoffset: -14; opacity: 0.8; }
1407
- .${PREFIX}-ring-head { stroke-dasharray: 5 95; stroke-dashoffset: -25; stroke: var(--zrl-beam-head); }
1412
+ .${PREFIX}-ring-head { stroke: var(--zrl-beam-head); }
1408
1413
  .${PREFIX}-ring-halo {
1409
- stroke-dasharray: 30 70;
1410
- stroke-dashoffset: 0;
1411
1414
  stroke-width: calc(var(--zrl-glow-core) * 2 + var(--zrl-beam-line));
1412
- opacity: calc(var(--zrl-glow-opacity) * 0.5);
1413
1415
  filter: blur(var(--zrl-glow-blur));
1414
1416
  }
1415
1417
  @keyframes ${PREFIX}-dash {
1416
- to { stroke-dashoffset: calc(var(--zrl-dash-start, 0) - 100); }
1418
+ from { stroke-dashoffset: var(--zrl-s, 0px); }
1419
+ to { stroke-dashoffset: calc(var(--zrl-s, 0px) - var(--zrl-l)); }
1417
1420
  }
1418
- .${PREFIX}-ring-body { --zrl-dash-start: -14; }
1419
- .${PREFIX}-ring-head { --zrl-dash-start: -25; }
1420
1421
  @media (prefers-reduced-motion: reduce) {
1421
1422
  .${PREFIX}-ring-svg rect { animation: none; stroke-dasharray: none; opacity: 0.45; }
1422
1423
  .${PREFIX}-ring-halo, .${PREFIX}-ring-head { display: none; }
@@ -2000,6 +2001,9 @@ function useZorealLogin(options) {
2000
2001
  // src/ring.tsx
2001
2002
  var import_react4 = require("react");
2002
2003
  var import_jsx_runtime5 = require("react/jsx-runtime");
2004
+ var TAIL = 0.3;
2005
+ var STACK = Array.from({ length: 12 }, (_, i) => 12 - i);
2006
+ var HALO = [3, 2, 1];
2003
2007
  function ZorealBusyRing({
2004
2008
  busy,
2005
2009
  radius = 8,
@@ -2012,11 +2016,42 @@ function ZorealBusyRing({
2012
2016
  (0, import_react4.useEffect)(() => {
2013
2017
  ensureStyles();
2014
2018
  }, []);
2019
+ const wrapRef = (0, import_react4.useRef)(null);
2020
+ const measureRef = (0, import_react4.useRef)(null);
2021
+ (0, import_react4.useLayoutEffect)(() => {
2022
+ const wrap = wrapRef.current;
2023
+ const rect = measureRef.current;
2024
+ if (!wrap || !rect) return;
2025
+ const measure = () => {
2026
+ const length = rect.getTotalLength();
2027
+ if (length > 0) wrap.style.setProperty("--zrl-ring-len", `${length}px`);
2028
+ };
2029
+ measure();
2030
+ if (typeof ResizeObserver === "undefined") return;
2031
+ const observer = new ResizeObserver(measure);
2032
+ observer.observe(wrap);
2033
+ return () => observer.disconnect();
2034
+ }, [radius]);
2015
2035
  const rx = radius + 2;
2016
- const layer = (name) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("rect", { className: cx(name), rx, ry: rx, pathLength: 100 });
2036
+ const layer = (key, name, len, alpha, ref) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2037
+ "rect",
2038
+ {
2039
+ ref,
2040
+ className: cx(name),
2041
+ rx,
2042
+ ry: rx,
2043
+ style: {
2044
+ strokeDasharray: `calc(var(--zrl-l) * ${len}) calc(var(--zrl-l) * ${1 - len})`,
2045
+ "--zrl-s": `calc(var(--zrl-l) * ${-(TAIL - len)})`,
2046
+ opacity: alpha
2047
+ }
2048
+ },
2049
+ key
2050
+ );
2017
2051
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
2018
2052
  "span",
2019
2053
  {
2054
+ ref: wrapRef,
2020
2055
  className: className ? `${cx("root")} ${cx("ring")} ${className}` : `${cx("root")} ${cx("ring")}`,
2021
2056
  "data-theme": theme,
2022
2057
  "data-busy": busy,
@@ -2024,10 +2059,10 @@ function ZorealBusyRing({
2024
2059
  children: [
2025
2060
  children,
2026
2061
  /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("svg", { className: cx("ring-svg"), "aria-hidden": "true", children: [
2027
- layer("ring-halo"),
2028
- layer("ring-tail"),
2029
- layer("ring-body"),
2030
- layer("ring-head")
2062
+ HALO.map(
2063
+ (n, i) => layer(`h${n}`, "ring-halo", TAIL * n / HALO.length, `calc(var(--zrl-glow-opacity) * 0.6 / ${n})`, i === 0 ? measureRef : void 0)
2064
+ ),
2065
+ STACK.map((n) => layer(`t${n}`, n <= 2 ? "ring-head" : "ring-tail", TAIL * n / STACK.length, String(1 / n)))
2031
2066
  ] })
2032
2067
  ]
2033
2068
  }