@pieai/swimmer-ui-kit 3.0.0 → 3.2.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.
@@ -1,6 +1,5 @@
1
1
  "use client";
2
- import { a as e, c as t, f as n, n as r, o as i, r as a, s as o } from "./LiquidGroup-BXw1tv9H.js";
3
- import { l as s, v as c, x as l, y as u } from "./reducedMotion-B8kv-v64.js";
2
+ import { C as e, D as t, b as n, c as r, d as i, l as a, m as o, n as s, r as c, u as l, x as u } from "./LiquidGroup-RTK_Uvgw.js";
4
3
  import { createContext as d, forwardRef as f, useCallback as p, useContext as m, useEffect as h, useId as g, useLayoutEffect as _, useMemo as v, useRef as y, useState as b } from "react";
5
4
  import { Fragment as x, jsx as S, jsxs as C } from "react/jsx-runtime";
6
5
  //#region src/liquid-effects/melt/options.ts
@@ -40,10 +39,10 @@ function E(e, t = 0, n = 1) {
40
39
  function D(e, t) {
41
40
  return e !== void 0 && Number.isFinite(e) ? e : t;
42
41
  }
43
- function O(e, t, r) {
42
+ function O(e, n, r) {
44
43
  let i = e?.ownerDocument.defaultView;
45
44
  if (!i) return r;
46
- let a = n[t], o = /^var\((--[\w-]+)\)$/.exec(a)?.[1];
45
+ let a = t[n], o = /^var\((--[\w-]+)\)$/.exec(a)?.[1];
47
46
  if (!o) return r;
48
47
  let s = Number.parseFloat(i.getComputedStyle(e).getPropertyValue(o));
49
48
  return Number.isFinite(s) ? s : r;
@@ -326,12 +325,12 @@ var re = class {
326
325
  releaseClaim() {
327
326
  this.claimed &&= (u(), !1);
328
327
  }
329
- ensureClaim(e, t, n) {
328
+ ensureClaim(t, r, i) {
330
329
  if (this.claimed) return !0;
331
- if (!l(q(e, t, n))) {
330
+ if (!e(q(t, r, i))) {
332
331
  if (!this.budgetWarningEmitted) {
333
332
  this.budgetWarningEmitted = !0;
334
- let e = c(), t = e.activeGroups >= e.maxAnimatedGroups ? "the active-group limit is reached" : "the filter-area limit is exceeded";
333
+ let e = n(), t = e.activeGroups >= e.maxAnimatedGroups ? "the active-group limit is reached" : "the filter-area limit is exceeded";
335
334
  console.warn(`LiquidGroup: the Melt/dissolve image filter budget is insufficient (${t}); degrading to crisp imagery for this group.`);
336
335
  }
337
336
  return !1;
@@ -1116,20 +1115,20 @@ function Z() {
1116
1115
  }
1117
1116
  //#endregion
1118
1117
  //#region src/liquid-effects/bend/physics.ts
1119
- function Q(n, r) {
1118
+ function Q(e, t) {
1120
1119
  return {
1121
- vertical: e(i(r?.vertical, t(n, "bendVertical", .6))),
1122
- horizontal: e(i(r?.horizontal, t(n, "bendHorizontal", .35))),
1123
- velocityVertical: Math.max(0, t(n, "bendVelocityVertical", .05)),
1124
- velocityHorizontal: Math.max(0, t(n, "bendVelocityHorizontal", .09)),
1125
- smoothing: Math.max(0, t(n, "bendSmoothing", 9)),
1126
- activeThreshold: Math.max(0, t(n, "bendActiveThreshold", .5)),
1127
- verticalCap: Math.max(0, t(n, "bendVerticalCap", .5)),
1128
- horizontalCap: Math.max(0, t(n, "bendHorizontalCap", .9)),
1129
- radiusMin: Math.max(0, t(n, "bendRadiusMin", .2)),
1130
- radiusMax: Math.max(0, t(n, "bendRadiusMax", 3)),
1131
- leadingCapFactor: Math.max(0, t(n, "bendLeadingCapFactor", .8)),
1132
- trailingCapFactor: Math.max(0, t(n, "bendTrailingCapFactor", 1.6))
1120
+ vertical: r(a(t?.vertical, i(e, "bendVertical", .6))),
1121
+ horizontal: r(a(t?.horizontal, i(e, "bendHorizontal", .35))),
1122
+ velocityVertical: Math.max(0, i(e, "bendVelocityVertical", .05)),
1123
+ velocityHorizontal: Math.max(0, i(e, "bendVelocityHorizontal", .09)),
1124
+ smoothing: Math.max(0, i(e, "bendSmoothing", 9)),
1125
+ activeThreshold: Math.max(0, i(e, "bendActiveThreshold", .5)),
1126
+ verticalCap: Math.max(0, i(e, "bendVerticalCap", .5)),
1127
+ horizontalCap: Math.max(0, i(e, "bendHorizontalCap", .9)),
1128
+ radiusMin: Math.max(0, i(e, "bendRadiusMin", .2)),
1129
+ radiusMax: Math.max(0, i(e, "bendRadiusMax", 3)),
1130
+ leadingCapFactor: Math.max(0, i(e, "bendLeadingCapFactor", .8)),
1131
+ trailingCapFactor: Math.max(0, i(e, "bendTrailingCapFactor", 1.6))
1133
1132
  };
1134
1133
  }
1135
1134
  function se(e, t, n, r, i, a) {
@@ -1155,20 +1154,20 @@ function le(e, t) {
1155
1154
  function ue(e, t) {
1156
1155
  return Math.min(e.w, e.h) * t.verticalCap * 2 * t.vertical;
1157
1156
  }
1158
- function de(e, t, n, r, a) {
1159
- let c = Math.max(1 / 240, i(r, 1 / 60));
1157
+ function de(e, t, n, r, i) {
1158
+ let s = Math.max(1 / 240, a(r, 1 / 60));
1160
1159
  e.initialized ||= (e.previousCx = t.cx, e.previousCy = t.cy, !0);
1161
- let l = (t.cx - e.previousCx) / c, u = (t.cy - e.previousCy) / c;
1162
- e.previousCx = t.cx, e.previousCy = t.cy, e.vcx = e.vcx * .7 + l * .3, e.vcy = e.vcy * .7 + u * .3, e.cx = t.cx, e.cy = t.cy;
1163
- let d = Math.min(n.w, n.h), f = d * a.verticalCap, p = Math.max(-f, Math.min(f, e.vcy * a.velocityVertical)) * a.vertical, m = d * a.horizontalCap, h = Math.max(-m, Math.min(m, e.vcx * a.velocityHorizontal)) * a.horizontal;
1164
- e.bendY += (p - e.bendY) * Math.min(1, c * a.smoothing), e.bendX += (h - e.bendX) * Math.min(1, c * a.smoothing);
1165
- let g = Math.abs(e.bendY) > a.activeThreshold || Math.abs(e.bendX) > a.activeThreshold, _ = Math.min(...n.r), v = g ? se(n.w, n.h, _, e.bendY, e.bendX, a) : s(-n.w / 2, -n.h / 2, n.w, n.h, n.r), y = g ? `translate(${o(e.cx - n.w / 2)} ${o(e.cy - n.h / 2)}) scale(${o(t.scale)})` : `translate(${o(e.cx)} ${o(e.cy)}) scale(${o(t.scale)})`, b = Math.round(e.bendX * 10) / 10, x = Math.round(e.bendY * 10) / 10;
1160
+ let c = (t.cx - e.previousCx) / s, u = (t.cy - e.previousCy) / s;
1161
+ e.previousCx = t.cx, e.previousCy = t.cy, e.vcx = e.vcx * .7 + c * .3, e.vcy = e.vcy * .7 + u * .3, e.cx = t.cx, e.cy = t.cy;
1162
+ let d = Math.min(n.w, n.h), f = d * i.verticalCap, p = Math.max(-f, Math.min(f, e.vcy * i.velocityVertical)) * i.vertical, m = d * i.horizontalCap, h = Math.max(-m, Math.min(m, e.vcx * i.velocityHorizontal)) * i.horizontal;
1163
+ e.bendY += (p - e.bendY) * Math.min(1, s * i.smoothing), e.bendX += (h - e.bendX) * Math.min(1, s * i.smoothing);
1164
+ let g = Math.abs(e.bendY) > i.activeThreshold || Math.abs(e.bendX) > i.activeThreshold, _ = Math.min(...n.r), v = g ? se(n.w, n.h, _, e.bendY, e.bendX, i) : o(-n.w / 2, -n.h / 2, n.w, n.h, n.r), y = g ? `translate(${l(e.cx - n.w / 2)} ${l(e.cy - n.h / 2)}) scale(${l(t.scale)})` : `translate(${l(e.cx)} ${l(e.cy)}) scale(${l(t.scale)})`, b = Math.round(e.bendX * 10) / 10, x = Math.round(e.bendY * 10) / 10;
1166
1165
  return {
1167
1166
  path: v,
1168
1167
  transform: y,
1169
1168
  bendX: b,
1170
1169
  bendY: x,
1171
- moving: Math.abs(e.vcx) > 1 || Math.abs(e.vcy) > 1 || Math.abs(e.bendX) > a.activeThreshold * .1 || Math.abs(e.bendY) > a.activeThreshold * .1,
1170
+ moving: Math.abs(e.vcx) > 1 || Math.abs(e.vcy) > 1 || Math.abs(e.bendX) > i.activeThreshold * .1 || Math.abs(e.bendY) > i.activeThreshold * .1,
1172
1171
  fingerprint: `${v}|${y}|${b},${x}`
1173
1172
  };
1174
1173
  }
@@ -1249,10 +1248,10 @@ function me(e) {
1249
1248
  }
1250
1249
  //#endregion
1251
1250
  //#region src/liquid-effects/LiquidEffectsGroup/LiquidEffectsItem.tsx
1252
- var he = f(function({ effect: e, bend: t, dissolve: n, melt: r, ...i }, o) {
1253
- let s = Z(), c = y(null), l = y(null), u = p((e) => {
1254
- c.current = e, typeof o == "function" ? o(e) : o && (o.current = e);
1255
- }, [o]), d = t?.horizontal, f = t?.vertical, m = v(() => e === "bend" ? fe({
1251
+ var he = f(function({ effect: e, bend: t, dissolve: n, melt: r, ...i }, a) {
1252
+ let o = Z(), s = y(null), l = y(null), u = p((e) => {
1253
+ s.current = e, typeof a == "function" ? a(e) : a && (a.current = e);
1254
+ }, [a]), d = t?.horizontal, f = t?.vertical, m = v(() => e === "bend" ? fe({
1256
1255
  ...d === void 0 ? {} : { horizontal: d },
1257
1256
  ...f === void 0 ? {} : { vertical: f }
1258
1257
  }) : void 0, [
@@ -1262,20 +1261,20 @@ var he = f(function({ effect: e, bend: t, dissolve: n, melt: r, ...i }, o) {
1262
1261
  ]), g = JSON.stringify(n ?? null), b = n !== void 0 && n !== !1;
1263
1262
  return _(() => () => {
1264
1263
  l.current?.unregister(), l.current = null;
1265
- }, [s]), _(() => {
1264
+ }, [o]), _(() => {
1266
1265
  if (e === "move" || !b) {
1267
1266
  l.current?.unregister(), l.current = null;
1268
1267
  return;
1269
1268
  }
1270
- c.current && (l.current ? l.current.update(n) : l.current = I(s, c.current, n));
1269
+ s.current && (l.current ? l.current.update(n) : l.current = I(o, s.current, n));
1271
1270
  }, [
1272
1271
  g,
1273
1272
  e,
1274
- s
1273
+ o
1275
1274
  ]), h(() => {
1276
1275
  let t = e;
1277
1276
  t === "move" && console.warn("[swimmer-ui] effect=\"move\" is not an item effect. Use <LiquidGroup motion=\"follow\"> for selection and progress."), t === "move" && b && console.warn("[swimmer-ui] dissolve is ignored for effect=\"move\" because Move intentionally lags the measured image rect.");
1278
- }, [e, b]), /* @__PURE__ */ S(a, {
1277
+ }, [e, b]), /* @__PURE__ */ S(c, {
1279
1278
  ...i,
1280
1279
  ref: u,
1281
1280
  ...e === "morph" ? { effect: e } : {},
@@ -1304,7 +1303,7 @@ var he = f(function({ effect: e, bend: t, dissolve: n, melt: r, ...i }, o) {
1304
1303
  let n = v(() => F(), []);
1305
1304
  return /* @__PURE__ */ S(X.Provider, {
1306
1305
  value: n,
1307
- children: /* @__PURE__ */ S(r, {
1306
+ children: /* @__PURE__ */ S(s, {
1308
1307
  ...e,
1309
1308
  ref: t,
1310
1309
  auxiliary: (e) => /* @__PURE__ */ S(oe, {
@@ -3,6 +3,54 @@ import { Placement } from '@floating-ui/react';
3
3
  import { ReactNode } from 'react';
4
4
  import { RefObject } from 'react';
5
5
 
6
+ /**
7
+ * A presentation-only account menu. The product owns the user, the product
8
+ * list, the destinations and sign-out; this component never fetches or stores.
9
+ */
10
+ export declare function GameAccountMenu({ user, labels, site, products, accountHref, onSignOut, signingOut, defaultTab, className, }: GameAccountMenuProps): ReactNode;
11
+
12
+ export declare interface GameAccountMenuLabels {
13
+ /** Accessible name of the trigger, final string from the product, e.g. "账号:小鱼". */
14
+ trigger: string;
15
+ /** First tab: the current product's own content, usually the product name. */
16
+ siteTab: string;
17
+ productsTab: string;
18
+ accountTab: string;
19
+ /** Badge on the current product. */
20
+ current: string;
21
+ manage: string;
22
+ signOut: string;
23
+ }
24
+
25
+ export declare interface GameAccountMenuProps {
26
+ user: {
27
+ name: string;
28
+ email?: string;
29
+ avatarUrl?: string;
30
+ };
31
+ labels: GameAccountMenuLabels;
32
+ /** Product-owned content for the first tab; the tab is omitted when absent. */
33
+ site?: ReactNode;
34
+ /** All products; the tab is omitted when empty. */
35
+ products?: readonly GameAccountProduct[];
36
+ /** The account center page (security, profile, sign out everywhere). */
37
+ accountHref: string;
38
+ onSignOut: () => void | Promise<void>;
39
+ /** True while the product signs out; the button shows the pending state. */
40
+ signingOut?: boolean;
41
+ defaultTab?: 'site' | 'products' | 'account';
42
+ className?: string;
43
+ }
44
+
45
+ export declare interface GameAccountProduct {
46
+ id: string;
47
+ name: string;
48
+ description?: string;
49
+ href: string;
50
+ /** The product that is showing this menu. It is not a link. */
51
+ current?: boolean;
52
+ }
53
+
6
54
  /** Positions an outlet beside a host-owned body, never positions the body itself.
7
55
  * Reuses Floating UI and the source's native dialog; no second modal manager. */
8
56
  export declare function LiquidAnchor({ source, children, placement, onBoundsChange, }: LiquidAnchorProps): JSX.Element | null;