@luxfi/ui 7.4.5 → 7.4.7

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.
Files changed (159) hide show
  1. package/dist/accordion.d.cts +74 -0
  2. package/dist/accordion.d.ts +74 -0
  3. package/dist/alert.cjs +3 -7
  4. package/dist/alert.d.cts +30 -0
  5. package/dist/alert.d.ts +30 -0
  6. package/dist/alert.js +3 -7
  7. package/dist/auth.cjs +481 -0
  8. package/dist/auth.d.cts +80 -0
  9. package/dist/auth.d.ts +80 -0
  10. package/dist/auth.js +456 -0
  11. package/dist/avatar.d.cts +25 -0
  12. package/dist/avatar.d.ts +25 -0
  13. package/dist/badge.cjs +4 -8
  14. package/dist/badge.d.cts +19 -0
  15. package/dist/badge.d.ts +19 -0
  16. package/dist/badge.js +4 -8
  17. package/dist/bank.d.cts +83 -0
  18. package/dist/bank.d.ts +83 -0
  19. package/dist/button.cjs +3 -7
  20. package/dist/button.d.cts +55 -0
  21. package/dist/button.d.ts +55 -0
  22. package/dist/button.js +3 -7
  23. package/dist/checkbox.d.cts +32 -0
  24. package/dist/checkbox.d.ts +32 -0
  25. package/dist/chrome.d.cts +93 -0
  26. package/dist/chrome.d.ts +93 -0
  27. package/dist/close-button.d.cts +9 -0
  28. package/dist/close-button.d.ts +9 -0
  29. package/dist/collapsible.cjs +3 -7
  30. package/dist/collapsible.d.cts +23 -0
  31. package/dist/collapsible.d.ts +23 -0
  32. package/dist/collapsible.js +3 -7
  33. package/dist/color-mode.d.cts +25 -0
  34. package/dist/color-mode.d.ts +25 -0
  35. package/dist/dialog.d.cts +118 -0
  36. package/dist/dialog.d.ts +118 -0
  37. package/dist/drawer.d.cts +36 -0
  38. package/dist/drawer.d.ts +36 -0
  39. package/dist/empty-state.d.cts +13 -0
  40. package/dist/empty-state.d.ts +13 -0
  41. package/dist/expiration-selector.d.cts +16 -0
  42. package/dist/expiration-selector.d.ts +16 -0
  43. package/dist/field.d.cts +24 -0
  44. package/dist/field.d.ts +24 -0
  45. package/dist/greeks-display.d.cts +14 -0
  46. package/dist/greeks-display.d.ts +14 -0
  47. package/dist/gui.d.cts +2 -0
  48. package/dist/gui.d.ts +2 -0
  49. package/dist/heading.d.cts +10 -0
  50. package/dist/heading.d.ts +10 -0
  51. package/dist/iam.d.cts +65 -0
  52. package/dist/iam.d.ts +65 -0
  53. package/dist/icon-button.cjs +3 -7
  54. package/dist/icon-button.d.cts +33 -0
  55. package/dist/icon-button.d.ts +33 -0
  56. package/dist/icon-button.js +3 -7
  57. package/dist/icons.cjs +0 -1
  58. package/dist/icons.d.cts +1 -0
  59. package/dist/icons.d.ts +1 -0
  60. package/dist/icons.js +0 -1
  61. package/dist/identity.d.cts +64 -0
  62. package/dist/identity.d.ts +64 -0
  63. package/dist/image.cjs +3 -7
  64. package/dist/image.d.cts +57 -0
  65. package/dist/image.d.ts +57 -0
  66. package/dist/image.js +3 -7
  67. package/dist/index.cjs +9 -8
  68. package/dist/index.d.cts +64 -0
  69. package/dist/index.d.ts +64 -0
  70. package/dist/index.js +9 -9
  71. package/dist/input-group.d.cts +17 -0
  72. package/dist/input-group.d.ts +17 -0
  73. package/dist/input.d.cts +17 -0
  74. package/dist/input.d.ts +17 -0
  75. package/dist/link.cjs +3 -7
  76. package/dist/link.d.cts +37 -0
  77. package/dist/link.d.ts +37 -0
  78. package/dist/link.js +3 -7
  79. package/dist/lux.config.d.cts +433 -0
  80. package/dist/lux.config.d.ts +433 -0
  81. package/dist/menu.d.cts +84 -0
  82. package/dist/menu.d.ts +84 -0
  83. package/dist/next.cjs +11 -1
  84. package/dist/next.d.cts +32 -0
  85. package/dist/next.d.ts +32 -0
  86. package/dist/next.js +11 -1
  87. package/dist/option-chain.d.cts +37 -0
  88. package/dist/option-chain.d.ts +37 -0
  89. package/dist/option-position.d.cts +29 -0
  90. package/dist/option-position.d.ts +29 -0
  91. package/dist/pin-input.d.cts +25 -0
  92. package/dist/pin-input.d.ts +25 -0
  93. package/dist/pnl-diagram.d.cts +11 -0
  94. package/dist/pnl-diagram.d.ts +11 -0
  95. package/dist/popover.d.cts +73 -0
  96. package/dist/popover.d.ts +73 -0
  97. package/dist/progress-circle.d.cts +47 -0
  98. package/dist/progress-circle.d.ts +47 -0
  99. package/dist/progress.d.cts +28 -0
  100. package/dist/progress.d.ts +28 -0
  101. package/dist/provider.d.cts +25 -0
  102. package/dist/provider.d.ts +25 -0
  103. package/dist/radio.d.cts +53 -0
  104. package/dist/radio.d.ts +53 -0
  105. package/dist/rating.d.cts +14 -0
  106. package/dist/rating.d.ts +14 -0
  107. package/dist/select.cjs +3 -7
  108. package/dist/select.d.cts +130 -0
  109. package/dist/select.d.ts +130 -0
  110. package/dist/select.js +3 -7
  111. package/dist/separator.d.cts +13 -0
  112. package/dist/separator.d.ts +13 -0
  113. package/dist/skeleton.cjs +8 -7
  114. package/dist/skeleton.d.cts +76 -0
  115. package/dist/skeleton.d.ts +76 -0
  116. package/dist/skeleton.js +8 -8
  117. package/dist/slider.d.cts +24 -0
  118. package/dist/slider.d.ts +24 -0
  119. package/dist/strategy-builder.d.cts +26 -0
  120. package/dist/strategy-builder.d.ts +26 -0
  121. package/dist/switch.d.cts +27 -0
  122. package/dist/switch.d.ts +27 -0
  123. package/dist/table.cjs +3 -7
  124. package/dist/table.d.cts +107 -0
  125. package/dist/table.d.ts +107 -0
  126. package/dist/table.js +3 -7
  127. package/dist/tabs.d.cts +78 -0
  128. package/dist/tabs.d.ts +78 -0
  129. package/dist/tag.cjs +4 -8
  130. package/dist/tag.d.cts +21 -0
  131. package/dist/tag.d.ts +21 -0
  132. package/dist/tag.js +4 -8
  133. package/dist/textarea.d.cts +13 -0
  134. package/dist/textarea.d.ts +13 -0
  135. package/dist/toaster.d.cts +29 -0
  136. package/dist/toaster.d.ts +29 -0
  137. package/dist/tooltip.cjs +1 -1
  138. package/dist/tooltip.d.cts +38 -0
  139. package/dist/tooltip.d.ts +38 -0
  140. package/dist/tooltip.js +1 -1
  141. package/dist/use-narrow.d.cts +12 -0
  142. package/dist/use-narrow.d.ts +12 -0
  143. package/dist/utils.d.cts +5 -0
  144. package/dist/utils.d.ts +5 -0
  145. package/dist/vite.cjs +4 -3
  146. package/dist/vite.d.cts +29 -0
  147. package/dist/vite.d.ts +29 -0
  148. package/dist/vite.js +4 -3
  149. package/dist/white-label.d.cts +59 -0
  150. package/dist/white-label.d.ts +59 -0
  151. package/package.json +12 -2
  152. package/src/auth.tsx +198 -0
  153. package/src/engine.ts +24 -3
  154. package/src/index.ts +1 -1
  155. package/src/next.ts +10 -0
  156. package/src/skeleton.tsx +36 -7
  157. package/src/tooltip.tsx +13 -5
  158. package/src/vite.ts +4 -9
  159. package/tokens.css +828 -317
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luxfi/ui",
3
- "version": "7.4.5",
3
+ "version": "7.4.7",
4
4
  "description": "Cross-platform DeFi UI components built on @hanzo/gui (Tamagui). Native mobile + web.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -50,6 +50,11 @@
50
50
  "import": "./dist/iam.js",
51
51
  "require": "./dist/iam.cjs"
52
52
  },
53
+ "./auth": {
54
+ "types": "./dist/auth.d.ts",
55
+ "import": "./dist/auth.js",
56
+ "require": "./dist/auth.cjs"
57
+ },
53
58
  "./identity": {
54
59
  "types": "./dist/identity.d.ts",
55
60
  "import": "./dist/identity.js",
@@ -321,14 +326,15 @@
321
326
  "tailwind-merge": "^3.0.0"
322
327
  },
323
328
  "peerDependencies": {
324
- "@tanstack/react-query": "^5.76.0",
325
329
  "@hanzo/gui": "^7.3.0",
330
+ "@hanzo/iam": "^0.13.8",
326
331
  "@hanzogui/colors": "^7.3.0",
327
332
  "@hanzogui/config": "^7.3.0",
328
333
  "@hanzogui/core": "^7.3.0",
329
334
  "@hanzogui/lucide-icons-2": "^7.3.0",
330
335
  "@hanzogui/themes": "^7.3.0",
331
336
  "@hanzogui/web": "^7.3.0",
337
+ "@tanstack/react-query": "^5.76.0",
332
338
  "react": ">=19",
333
339
  "react-dom": ">=19"
334
340
  },
@@ -347,10 +353,14 @@
347
353
  },
348
354
  "@hanzogui/web": {
349
355
  "optional": true
356
+ },
357
+ "@hanzo/iam": {
358
+ "optional": true
350
359
  }
351
360
  },
352
361
  "devDependencies": {
353
362
  "@hanzo/gui": "7.3.0",
363
+ "@hanzo/iam": "^0.13.8",
354
364
  "@hanzogui/colors": "7.3.0",
355
365
  "@hanzogui/config": "7.3.0",
356
366
  "@hanzogui/core": "7.3.0",
package/src/auth.tsx ADDED
@@ -0,0 +1,198 @@
1
+ 'use client';
2
+
3
+ import { configureIam, handleCallback, logout, startLogin } from '@hanzo/iam/browser';
4
+ import * as React from 'react';
5
+
6
+ import { IdentityProvider, type IdentityAuth } from './identity';
7
+ import { useWhiteLabel } from './provider';
8
+ import type { WhiteLabel } from './white-label';
9
+
10
+ // The sign-in half of identity, in ONE place.
11
+ //
12
+ // ./identity answers "who is signed in" and ./chrome renders it (the account
13
+ // switcher already shows `Sign in with <iamDomain>` when anonymous and
14
+ // `Sign out` when ready). Neither of them can START a session — `IdentityAuth`
15
+ // is a seam, and every surface filled it in by hand. That is where the fleet
16
+ // diverged:
17
+ //
18
+ // lux/explore/lib/oidc.ts hand-built authorize URL, NO PKCE at all
19
+ // lux/mpc/dashboard/app/providers configureIam + startLogin + logout (right)
20
+ // lux/market/src/app/providers the same three lines again
21
+ // lux/cloud/apps/web/src/iam.ts a third shape: IAMConfig from a brand table
22
+ // plus VITE_IAM_URL / VITE_IAM_CLIENT_ID
23
+ // env overrides — i.e. brand per DEPLOYMENT
24
+ //
25
+ // Four copies, and only one of them was correct. So the flow lives here:
26
+ //
27
+ // <AppProvider> host → brand, theme, issuer, clientId
28
+ // <AuthProvider> the three verbs, wired to that host
29
+ // …and on the callback route:
30
+ // <AuthCallback/>
31
+ //
32
+ // MECHANISM IS NOT OURS. Authorization-Code + PKCE-S256, the state nonce, the
33
+ // verifier, discovery and the token store all belong to `@hanzo/iam/browser`;
34
+ // this module only decides WHICH issuer and WHICH client — and that is a pure
35
+ // function of the Host header (./white-label). A design system that reimplements
36
+ // PKCE is a design system with its own CVEs.
37
+
38
+ /**
39
+ * The ONE callback route. Registered as `https://<host>/auth/callback` for
40
+ * every browser client in the fleet — never under `/api/`, never per app.
41
+ */
42
+ export const CALLBACK_PATH = '/auth/callback';
43
+
44
+ /** What `handleCallback` hands back. Structural, so the SDK's types stay its own. */
45
+ export interface AuthResult {
46
+ readonly token: { readonly accessToken: string };
47
+ readonly redirect: string;
48
+ }
49
+
50
+ /**
51
+ * Point `@hanzo/iam` at the issuer and client this HOST resolves to.
52
+ *
53
+ * Idempotent per config, browser-only, and safe to call from anywhere — which
54
+ * is the point: no ordering rule between a provider's effect and a child's.
55
+ */
56
+ export function configureAuth(wl: WhiteLabel): void {
57
+ if (typeof window === 'undefined') return;
58
+ configureIam({
59
+ issuer: wl.issuer,
60
+ clientId: wl.clientId,
61
+ // The SDK already defaults to `${origin}${CALLBACK_PATH}`; naming it here
62
+ // makes the fleet-wide invariant one readable, testable line instead of a
63
+ // default nobody can see.
64
+ redirect: `${ window.location.origin }${ CALLBACK_PATH }`,
65
+ });
66
+ }
67
+
68
+ export interface Auth {
69
+ /** Start the PKCE login. `redirect` is where to land afterwards. */
70
+ readonly signIn: (redirect?: string) => void;
71
+ /** RP-initiated logout + local token clear. */
72
+ readonly signOut: () => void;
73
+ /** Finish the login on the callback route. */
74
+ readonly complete: () => Promise<AuthResult>;
75
+ /** The host-resolved brand, issuer and client these verbs are bound to. */
76
+ readonly whiteLabel: WhiteLabel;
77
+ }
78
+
79
+ /**
80
+ * The three auth verbs, bound to the current host.
81
+ *
82
+ * Configuration happens during render, before any caller can use a verb, so a
83
+ * callback route works whether or not it sits under an `<AuthProvider>`.
84
+ */
85
+ export function useAuth(defaultRedirect = '/'): Auth {
86
+ const whiteLabel = useWhiteLabel();
87
+ configureAuth(whiteLabel);
88
+ return React.useMemo<Auth>(() => ({
89
+ signIn: (redirect = defaultRedirect) => void startLogin({ redirect }),
90
+ signOut: () => void logout(),
91
+ complete: () => handleCallback() as Promise<AuthResult>,
92
+ whiteLabel,
93
+ }), [ whiteLabel, defaultRedirect ]);
94
+ }
95
+
96
+ export interface AuthProviderProps {
97
+ readonly children: React.ReactNode;
98
+ /** Where a successful sign-in lands. Default `/`. */
99
+ readonly redirect?: string;
100
+ /**
101
+ * Anything the surface must tear down alongside the IAM session — the mirror
102
+ * of {@link AuthCallbackProps.onSignedIn}. A surface that mints its own
103
+ * downstream credential from the IAM token drops it here; the IAM session
104
+ * itself is never the app's to manage.
105
+ */
106
+ readonly onSignOut?: () => void;
107
+ }
108
+
109
+ /**
110
+ * `IdentityProvider` with the credential half filled in.
111
+ *
112
+ * A surface's root becomes `<AppProvider><AuthProvider>…` and nothing else —
113
+ * no `configureIam`, no `startLogin`, no per-app token keys.
114
+ */
115
+ export const AuthProvider = ({ children, redirect = '/', onSignOut }: AuthProviderProps): React.ReactElement => {
116
+ const auth = useAuth(redirect);
117
+ const identityAuth = React.useMemo<IdentityAuth>(() => ({
118
+ signIn: () => auth.signIn(redirect),
119
+ signOut: () => {
120
+ onSignOut?.();
121
+ auth.signOut();
122
+ },
123
+ }), [ auth, redirect, onSignOut ]);
124
+ return <IdentityProvider auth={ identityAuth }>{ children }</IdentityProvider>;
125
+ };
126
+
127
+ export interface AuthCallbackProps {
128
+ /**
129
+ * Anything the surface must do with the fresh session before it navigates —
130
+ * e.g. the MPC dashboard mints its own API JWT from the IAM token. Throwing
131
+ * here does NOT fail the sign-in: the user is signed in, and a downstream
132
+ * service being unreachable is that service's problem to report.
133
+ */
134
+ readonly onSignedIn?: (result: AuthResult) => void | Promise<void>;
135
+ /** Router hop. Defaults to a full replace, which needs no router. */
136
+ readonly navigate?: (to: string) => void;
137
+ /** Where to go when the callback carried no stashed redirect. */
138
+ readonly fallback?: string;
139
+ /** Sign-in entry point offered after a failure. */
140
+ readonly retryPath?: string;
141
+ }
142
+
143
+ /**
144
+ * The ONE callback page body: verify state, exchange the code, go where the
145
+ * user was headed. Mount it at {@link CALLBACK_PATH}.
146
+ */
147
+ export const AuthCallback = ({
148
+ onSignedIn,
149
+ navigate,
150
+ fallback = '/',
151
+ retryPath = '/login',
152
+ }: AuthCallbackProps): React.ReactElement => {
153
+ const auth = useAuth();
154
+ const [ error, setError ] = React.useState<string | null>(null);
155
+
156
+ React.useEffect(() => {
157
+ let live = true;
158
+ void (async () => {
159
+ try {
160
+ const result = await auth.complete();
161
+ if (!live) return;
162
+ try {
163
+ await onSignedIn?.(result);
164
+ } catch {
165
+ // Signed in; the surface's own downstream call failed. Not a login
166
+ // failure, and stranding a good session on this screen was the bug.
167
+ }
168
+ if (!live) return;
169
+ const to = result.redirect || fallback;
170
+ if (navigate) navigate(to);
171
+ else window.location.replace(to);
172
+ } catch (e) {
173
+ if (live) setError(e instanceof Error ? e.message : 'Authentication failed');
174
+ }
175
+ })();
176
+ return () => {
177
+ live = false;
178
+ };
179
+ // `auth` is re-created only when the host changes; the exchange must run once.
180
+ // eslint-disable-next-line react-hooks/exhaustive-deps
181
+ }, []);
182
+
183
+ return (
184
+ <div className="flex min-h-[50vh] items-center justify-center px-4">
185
+ <div className="w-full max-w-sm text-center">
186
+ { error ? (
187
+ <>
188
+ <p className="mb-2 text-lg font-semibold text-[var(--color-text-error)]">Sign-in failed</p>
189
+ <p className="mb-6 text-sm text-[var(--color-text-secondary)]">{ error }</p>
190
+ <a href={ retryPath } className="text-sm underline underline-offset-4">Try again</a>
191
+ </>
192
+ ) : (
193
+ <p className="text-sm text-[var(--color-text-secondary)]">Completing sign in…</p>
194
+ ) }
195
+ </div>
196
+ </div>
197
+ );
198
+ };
package/src/engine.ts CHANGED
@@ -105,8 +105,29 @@ export const GUI_DEFINES: Readonly<Record<string, string>> = {
105
105
  };
106
106
 
107
107
  /**
108
- * Exact-match aliases pinning every engine package to ONE entry file, for
109
- * bundlers that have no `dedupe` of their own (webpack).
108
+ * Every package that must exist exactly ONCE in a bundle — the engine, plus the
109
+ * three libraries outside it that also publish a module-scope React context.
110
+ *
111
+ * `react` and `react-dom` are the classic case. `@tanstack/react-query` is the
112
+ * same failure with a different message: lux.market resolved two copies (one
113
+ * under react@19.1.0, one under react@19.2.8), the app's `QueryClientProvider`
114
+ * came from copy A and `@luxfi/ui`'s `useQuery` read copy B's context, and the
115
+ * whole page died with "No QueryClient set, use QueryClientProvider to set one".
116
+ *
117
+ * ONE list, shared by both bundler wrappers, so vite and next cannot dedupe
118
+ * different sets — which is exactly how that market bug survived: the vite
119
+ * wrapper already listed these three, the Next wrapper did not.
120
+ */
121
+ export const ENGINE_DEDUPE: ReadonlyArray<string> = [
122
+ 'react',
123
+ 'react-dom',
124
+ '@tanstack/react-query',
125
+ ...GUI_PACKAGES,
126
+ ];
127
+
128
+ /**
129
+ * Exact-match aliases pinning every deduped package to ONE entry file, for
130
+ * bundlers that have no `dedupe` of their own (webpack, turbopack).
110
131
  *
111
132
  * Keys carry webpack's `$` exact-match suffix so only the bare specifier is
112
133
  * redirected — a deep import keeps resolving normally. Packages that are not
@@ -119,7 +140,7 @@ export function guiAliases(from: string): Record<string, string> {
119
140
  const { createRequire } = require('node:module') as typeof import('node:module');
120
141
  const require_ = createRequire(`${ from.replace(/\/?$/, '/') }noop.js`);
121
142
  const alias: Record<string, string> = {};
122
- for (const pkg of GUI_PACKAGES) {
143
+ for (const pkg of ENGINE_DEDUPE) {
123
144
  try {
124
145
  alias[`${ pkg }$`] = require_.resolve(pkg);
125
146
  } catch {
package/src/index.ts CHANGED
@@ -199,7 +199,7 @@ export type { SelectOption, ListCollection, SelectRootProps, SelectProps, Select
199
199
  export { Separator } from './separator';
200
200
  export type { SeparatorProps } from './separator';
201
201
 
202
- export { Skeleton, SkeletonCircle, SkeletonText } from './skeleton';
202
+ export { Skeleton, SkeletonCircle, SkeletonText, LoadingBar } from './skeleton';
203
203
  export type { SkeletonProps, SkeletonCircleProps, SkeletonTextProps } from './skeleton';
204
204
 
205
205
  export { Slider } from './slider';
package/src/next.ts CHANGED
@@ -49,6 +49,15 @@ export function withLuxUi(config: LuxUiNextConfig = {}): LuxUiNextConfig {
49
49
  // so the equivalent is an exact-match alias per package, resolved from the app
50
50
  // root — see ./engine for why two copies is a crash and not a size problem.
51
51
  const engine = guiAliases(config.dir ?? process.cwd());
52
+ // The same dedupe for Turbopack, which is the ONLY dev bundler from Next 16 —
53
+ // `webpack()` below is never called by `next dev`, so a webpack-only alias map
54
+ // deduped production and left development with N copies of `@hanzogui/popper`
55
+ // and the `Cannot read properties of undefined (reading 'setReference')`
56
+ // storm that comes with them. Turbopack has no `$` exact-match suffix; a bare
57
+ // key is already exact, so strip it.
58
+ const engineTurbopack = Object.fromEntries(
59
+ Object.entries(engine).map(([ k, v ]) => [ k.replace(/\$$/, ''), v ]),
60
+ );
52
61
  // `dir` is OURS, not Next's — leaving it on the returned object makes Next
53
62
  // print `Unrecognized key(s) in object: 'dir'` on every boot of every surface
54
63
  // that passes it. Consume it here.
@@ -60,6 +69,7 @@ export function withLuxUi(config: LuxUiNextConfig = {}): LuxUiNextConfig {
60
69
  ...config.turbopack,
61
70
  resolveAlias: {
62
71
  'react-native': 'react-native-web',
72
+ ...engineTurbopack,
63
73
  ...config.turbopack?.resolveAlias,
64
74
  },
65
75
  },
package/src/skeleton.tsx CHANGED
@@ -142,11 +142,19 @@ function stripShims<T extends Record<string, unknown>>(props: T): Omit<T, (typeo
142
142
  return out as Omit<T, (typeof SHIM_PROPS)[number]>;
143
143
  }
144
144
 
145
- const SKELETON_CLASSES = [
146
- 'animate-skeleton-shimmer rounded-sm',
147
- 'bg-[linear-gradient(90deg,var(--color-skeleton-start)_0%,var(--color-skeleton-end)_50%,var(--color-skeleton-start)_100%)]',
148
- 'bg-[length:200%_100%]',
149
- ].join(' ');
145
+ // A skeleton reserves space. It does not move.
146
+ //
147
+ // It used to shimmer via a per-element `background-position` animation, which
148
+ // repaints the element's whole box every frame. Under a 4x CPU throttle that
149
+ // costs 33.6fps at 1460 concurrent skeletons and 13.8fps at 3000. Rewriting it
150
+ // as a per-element `transform` sheen — the textbook "animate transform only"
151
+ // fix — measured WORSE: 23.0fps and 5.4fps, because it also adds a layer and a
152
+ // clip per element. Holding still costs 120fps at every n.
153
+ //
154
+ // The "work is in flight" signal is <LoadingBar/> below: one animated element
155
+ // for the whole page instead of one per skeleton. Full numbers and reasoning
156
+ // live next to the CSS, in section 6c of @luxfi/ui/tokens.css.
157
+ const SKELETON_CLASSES = 'lux-skeleton rounded-sm';
150
158
 
151
159
  const HIDE_BELOW_MAP: Record<string, string> = { lg: 'lg:hidden', md: 'md:hidden', sm: 'sm:hidden' };
152
160
 
@@ -176,7 +184,7 @@ export const Skeleton = React.forwardRef<HTMLDivElement, SkeletonProps>(
176
184
  <Component
177
185
  ref={ ref }
178
186
  data-loading
179
- className={ cn(SKELETON_CLASSES, 'text-transparent [&_*]:invisible', cls) }
187
+ className={ cn(SKELETON_CLASSES, '[&_*]:invisible', cls) }
180
188
  style={ mergedStyle }
181
189
  { ...htmlRest }
182
190
  >
@@ -189,7 +197,7 @@ export const Skeleton = React.forwardRef<HTMLDivElement, SkeletonProps>(
189
197
  <Component
190
198
  ref={ ref }
191
199
  data-loading
192
- className={ cn(SKELETON_CLASSES, children ? 'text-transparent [&_*]:invisible' : 'min-h-5', cls) }
200
+ className={ cn(SKELETON_CLASSES, children ? '[&_*]:invisible' : 'min-h-5', cls) }
193
201
  style={ mergedStyle }
194
202
  { ...htmlRest }
195
203
  >
@@ -252,3 +260,24 @@ export const SkeletonText = React.forwardRef<HTMLDivElement, SkeletonTextProps>(
252
260
  );
253
261
  },
254
262
  );
263
+
264
+ // ---------------------------------------------------------------------------
265
+ // LoadingBar
266
+ // ---------------------------------------------------------------------------
267
+
268
+ /**
269
+ * The page-level "work is in flight" signal — one animated element, however
270
+ * many skeletons are on screen. Mount it while any request is outstanding.
271
+ *
272
+ * It is `position: fixed` and 2px tall, so it is out of flow: it cannot shift
273
+ * layout (CLS 0) and it cannot tint content. Under prefers-reduced-motion the
274
+ * sweep stops and the track stays lit, so the state is still legible.
275
+ *
276
+ * This is what replaces a bare spinner. A spinner says "something is
277
+ * happening somewhere"; a skeleton plus this bar says "here is the shape of
278
+ * what is coming, and it is still coming".
279
+ */
280
+ export function LoadingBar({ loading = true }: { readonly loading?: boolean }) {
281
+ if (!loading) return null;
282
+ return <div className="lux-loading" role="progressbar" aria-busy="true" aria-label="Loading"/>;
283
+ }
package/src/tooltip.tsx CHANGED
@@ -138,13 +138,21 @@ export const Tooltip = React.forwardRef<HTMLDivElement, TooltipProps>(
138
138
  // ONE ref, always the same one. Swapping between `triggerRef` and
139
139
  // `undefined` on open/close changes the composed-ref identity, so
140
140
  // React detaches and re-attaches the popper's reference element on
141
- // every hover — two extra `refs.setReference()` calls per open, each
142
- // of which throws uncaught when the Popper context is not the one
143
- // this anchor is reading (see ./engine). The click-away handler
144
- // already no-ops while closed, so the ref never needed to move.
141
+ // every hover — two extra `refs.setReference()` calls per open. Each
142
+ // of those throws uncaught when the Popper context is not the one
143
+ // this anchor is reading, which is what two physical copies of
144
+ // `@hanzogui/popper` produce (see ./engine that duplication, not
145
+ // this ref, is the root cause). The click-away handler already
146
+ // no-ops while closed, so the ref never needed to move.
145
147
  ref={ triggerRef }
146
148
  asChild
147
- {...(isMobile ? { onPress: handleTriggerClick } : {})}
149
+ // `asChild` renders the CONSUMER's node on the web that is a DOM
150
+ // element, so the tap handler has to be a DOM event. `onPress` is a
151
+ // React Native prop: it survives the clone, reaches the element and
152
+ // React logs "Unknown event handler property `onPress`. It will be
153
+ // ignored." — an uncatchable console error AND a dead tap target on
154
+ // every touch device.
155
+ {...(isMobile ? { onClick: handleTriggerClick } : {})}
148
156
  { ...triggerProps as any }
149
157
  >
150
158
  { children }
package/src/vite.ts CHANGED
@@ -14,7 +14,7 @@
14
14
  // Node-only (it is a build-time module) and dependency-free: it returns a plain
15
15
  // Vite plugin object, so it does not force `vite` into anyone's runtime graph.
16
16
 
17
- import { GUI_DEFINES, GUI_PACKAGES } from './engine';
17
+ import { ENGINE_DEDUPE, GUI_DEFINES } from './engine';
18
18
 
19
19
  interface LuxUiViteOptions {
20
20
  /**
@@ -42,14 +42,9 @@ interface LuxUiVitePlugin {
42
42
  // The WHOLE engine, not a hand-picked three. `@hanzogui/popper` and
43
43
  // `@hanzogui/popover` publish the contexts a Tooltip trigger reads, and they
44
44
  // were the two missing from the old list — so a consumer using this plugin
45
- // could still get two poppers and the `setReference` crash it causes. One list,
46
- // shared with the Next wrapper. See ./engine.
47
- const DEDUPE = [
48
- 'react',
49
- 'react-dom',
50
- '@tanstack/react-query',
51
- ...GUI_PACKAGES,
52
- ];
45
+ // could still get two poppers and the `setReference` crash it causes. The list
46
+ // itself lives in ./engine, shared with the Next wrapper.
47
+ const DEDUPE = ENGINE_DEDUPE;
53
48
 
54
49
  const INCLUDE = [
55
50
  'react-native-web',