@rootnative/core 0.0.0-alpha.2 → 0.0.0-alpha.20

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.d.mts CHANGED
@@ -1,8 +1,9 @@
1
- import { T as Theme, a as TopAppBarTokens, B as BaseTheme, M as Motion, S as Shape } from './types-xq2X5AuN.mjs';
2
- export { C as Colors, E as Elevation, b as ElevationLevel, F as FontWeight, c as MaterialTheme, d as MotionSpring, e as ShadowOffset, f as Spacing, g as StateLayer, h as TextStyle, i as Typography } from './types-xq2X5AuN.mjs';
1
+ import { T as Theme, a as TopAppBarTokens, B as BaseTheme, M as Motion, S as Shape } from './types-NiRbh4dM.mjs';
2
+ export { C as Colors, E as Elevation, b as ElevationLevel, F as FontWeight, c as MaterialTheme, d as MotionSpring, e as ShadowOffset, f as Spacing, g as StateLayer, h as Typography, i as TypographyToken } from './types-NiRbh4dM.mjs';
3
3
  import { TransitionConfig, NamedTransitions } from '@rootnative/inertia';
4
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
5
5
  import * as React from 'react';
6
+ import { ScaledSize } from 'react-native';
6
7
 
7
8
  declare const lightTheme: Theme;
8
9
 
@@ -34,6 +35,10 @@ declare module '@rootnative/inertia' {
34
35
  'state-focus': TransitionConfig;
35
36
  'spring-fast-spatial': TransitionConfig;
36
37
  'spring-default-spatial': TransitionConfig;
38
+ 'spring-slow-spatial': TransitionConfig;
39
+ 'spring-fast-effects': TransitionConfig;
40
+ 'spring-default-effects': TransitionConfig;
41
+ 'spring-slow-effects': TransitionConfig;
37
42
  }
38
43
  }
39
44
  /**
@@ -43,10 +48,10 @@ declare module '@rootnative/inertia' {
43
48
  * reference by name instead of hand-rolling `withTiming`/`withSpring`
44
49
  * configs.
45
50
  *
46
- * The state-layer names encode the library's interaction timing policy —
47
- * hover `durationShort3` (150ms), press `durationShort2` (100ms), focus
48
- * `durationShort4` (200ms), all on the standard easing curve. The spring
49
- * names expose the theme's `MotionSpring` tokens verbatim.
51
+ * The state-layer names encode the library's interaction motion policy —
52
+ * per MD3 Expressive, state-layer color/opacity feedback rides the
53
+ * fast-effects spring (small-element effects, critically damped). The
54
+ * spring names expose the theme's `MotionSpring` tokens verbatim.
50
55
  */
51
56
  declare function motionTransitions(motion: Motion): NamedTransitions;
52
57
 
@@ -80,15 +85,122 @@ interface IconRenderProps {
80
85
  * etc. without forking components.
81
86
  */
82
87
  type IconResolver = (name: string, props: IconRenderProps) => React.ReactNode;
83
- declare const IconResolverContext: React.Context<IconResolver | null>;
88
+ /**
89
+ * Anything a component will accept for an icon prop:
90
+ *
91
+ * - **string** — a name resolved via the `iconResolver` registered on
92
+ * `ThemeProvider`. Falls back to `MaterialCommunityIcons` when no
93
+ * resolver is set, preserving the legacy default.
94
+ * - **ReactElement** — a pre-rendered icon. The caller is responsible for
95
+ * passing size and color; the component will not override them.
96
+ * - **(props) => ReactNode** — a render function that receives the
97
+ * component's resolved size and color. Useful for plugging in Lucide,
98
+ * SF Symbols, or custom SVGs without losing theme integration.
99
+ */
100
+ type IconSource = string | React.ReactElement | ((props: IconRenderProps) => React.ReactNode);
101
+
102
+ /**
103
+ * What the app asks for. `'system'` follows the OS setting and keeps
104
+ * following it as the OS changes; `'light'` / `'dark'` pin the scheme.
105
+ */
106
+ type ThemeMode = 'system' | 'light' | 'dark';
107
+ /** What the app actually renders. `'system'` is always resolved away. */
108
+ type ColorScheme = 'light' | 'dark';
109
+ /**
110
+ * Persists the user's mode choice across launches. Deliberately structural
111
+ * rather than a dependency on any one storage library: pass an
112
+ * AsyncStorage-shaped object, MMKV, `localStorage`, SecureStore, or your own
113
+ * wrapper. `@rootnative/core` takes no storage dependency of its own.
114
+ *
115
+ * Both methods may be sync or async — the provider awaits either.
116
+ *
117
+ * @example
118
+ * import AsyncStorage from '@react-native-async-storage/async-storage'
119
+ *
120
+ * <ThemeProvider theme={{ light, dark }} storage={AsyncStorage}>
121
+ */
122
+ interface ThemeModeStorage {
123
+ getItem: (key: string) => string | null | Promise<string | null>;
124
+ setItem: (key: string, value: string) => unknown | Promise<unknown>;
125
+ }
126
+ interface ThemeModeContextValue {
127
+ /** The requested mode, including `'system'`. */
128
+ mode: ThemeMode;
129
+ /**
130
+ * The resolved scheme actually in use. `mode: 'system'` resolves this from
131
+ * the OS; `'light'` / `'dark'` pass straight through. Use this to sync
132
+ * anything outside the theme — most commonly the status bar.
133
+ */
134
+ scheme: ColorScheme;
135
+ /** Sets the mode, and persists it when a `storage` is configured. */
136
+ setMode: (mode: ThemeMode) => void;
137
+ /**
138
+ * `false` until a persisted mode has been read back from `storage`. Always
139
+ * `true` when no `storage` is configured, since there is nothing to wait
140
+ * for. Gate a splash screen on this to avoid a light-to-dark flash on
141
+ * launch.
142
+ */
143
+ isReady: boolean;
144
+ }
84
145
 
146
+ /**
147
+ * A light/dark pair. Matches what `createMaterialTheme()` returns, so its
148
+ * result can be renamed straight into the prop:
149
+ * `const { lightTheme: light, darkTheme: dark } = createMaterialTheme(seed)`.
150
+ */
151
+ interface ThemePair {
152
+ light: BaseTheme;
153
+ dark: BaseTheme;
154
+ }
155
+ /** Storage key for the persisted mode. Namespaced to avoid app collisions. */
156
+ declare const THEME_MODE_STORAGE_KEY = "rootnative.theme-mode";
85
157
  interface ThemeProviderProps {
86
158
  /**
87
159
  * Theme object to provide to all child components via context.
88
160
  * Accepts any theme extending `BaseTheme` — Material, Apple, or custom.
161
+ *
162
+ * Pass a `{ light, dark }` pair to enable light/dark switching: the provider
163
+ * then resolves which one to use from `mode` plus the OS setting, and
164
+ * `useThemeMode()` becomes available to descendants.
165
+ *
89
166
  * @default lightTheme (Material Design 3)
90
167
  */
91
- theme?: BaseTheme;
168
+ theme?: BaseTheme | ThemePair;
169
+ /**
170
+ * Which theme of the pair to use. `'system'` follows the OS and keeps
171
+ * following it; `'light'` / `'dark'` pin it. Ignored when `theme` is a
172
+ * single theme.
173
+ *
174
+ * Leave uncontrolled (the default) and drive it with `setMode()` from
175
+ * `useThemeMode()`. Pass it to control the mode from your own state — the
176
+ * provider then never changes it on its own, so pair it with `onModeChange`.
177
+ *
178
+ * @default 'system'
179
+ */
180
+ mode?: ThemeMode;
181
+ /**
182
+ * Initial mode for the uncontrolled case. A persisted value from `storage`
183
+ * wins over this once it loads.
184
+ *
185
+ * @default 'system'
186
+ */
187
+ defaultMode?: ThemeMode;
188
+ /** Called whenever `setMode()` runs, controlled or not. */
189
+ onModeChange?: (mode: ThemeMode) => void;
190
+ /**
191
+ * Persists the mode across launches. Any object with `getItem`/`setItem` —
192
+ * AsyncStorage, MMKV, `localStorage`. `@rootnative/core` takes no storage
193
+ * dependency of its own, so nothing is persisted unless you pass this.
194
+ *
195
+ * Ignored when `mode` is controlled: your own state is then the source of
196
+ * truth and persisting behind it would fight it.
197
+ *
198
+ * @example
199
+ * import AsyncStorage from '@react-native-async-storage/async-storage'
200
+ *
201
+ * <ThemeProvider theme={{ light, dark }} storage={AsyncStorage}>
202
+ */
203
+ storage?: ThemeModeStorage;
92
204
  /**
93
205
  * Resolves string icon names (e.g. `leadingIcon="check"`) to icon nodes.
94
206
  * Set this once at the app root to use SF Symbols, Lucide, custom SVGs,
@@ -124,6 +236,14 @@ interface ThemeProviderProps {
124
236
  * </ThemeProvider>
125
237
  *
126
238
  * @example
239
+ * // Light/dark, following the OS
240
+ * import { ThemeProvider, lightTheme, darkTheme } from '@rootnative/core'
241
+ *
242
+ * <ThemeProvider theme={{ light: lightTheme, dark: darkTheme }}>
243
+ * <App />
244
+ * </ThemeProvider>
245
+ *
246
+ * @example
127
247
  * // Custom or Apple theme
128
248
  * import { ThemeProvider } from '@rootnative/core'
129
249
  *
@@ -131,7 +251,7 @@ interface ThemeProviderProps {
131
251
  * <App />
132
252
  * </ThemeProvider>
133
253
  */
134
- declare function ThemeProvider({ theme, iconResolver, children, }: ThemeProviderProps): react_jsx_runtime.JSX.Element;
254
+ declare function ThemeProvider({ theme, mode: controlledMode, defaultMode, onModeChange, storage, iconResolver, children, }: ThemeProviderProps): react_jsx_runtime.JSX.Element;
135
255
 
136
256
  /**
137
257
  * Returns the current theme from the nearest `ThemeProvider`.
@@ -150,6 +270,21 @@ declare function ThemeProvider({ theme, iconResolver, children, }: ThemeProvider
150
270
  */
151
271
  declare function useTheme<T extends BaseTheme = Theme>(): T;
152
272
 
273
+ /**
274
+ * Reads and controls the light/dark mode of the nearest `ThemeProvider`.
275
+ *
276
+ * Requires a provider configured with a theme *pair* — `theme={{ light, dark }}`.
277
+ * A provider given a single theme has no mode to report, so this throws rather
278
+ * than inventing one.
279
+ *
280
+ * @example
281
+ * const { mode, scheme, setMode } = useThemeMode()
282
+ *
283
+ * <StatusBar style={scheme === 'dark' ? 'light' : 'dark'} />
284
+ * <Button onPress={() => setMode(scheme === 'dark' ? 'light' : 'dark')} />
285
+ */
286
+ declare function useThemeMode(): ThemeModeContextValue;
287
+
153
288
  /**
154
289
  * Returns the icon resolver registered on the nearest `ThemeProvider`,
155
290
  * or `null` if none was provided. Components fall back to
@@ -173,6 +308,30 @@ declare const breakpoints: {
173
308
  * Returns the current Material Design 3 window size class based on viewport width.
174
309
  * Reactively updates when the window is resized.
175
310
  *
311
+ * **Hydration-safe by construction.** A static export renders on a server with
312
+ * no DOM, where react-native-web's `Dimensions` is hard-wired to `width: 0`,
313
+ * so every breakpoint resolves to `compact` and that is what ships in the
314
+ * HTML. On the client `Dimensions` reports the real width immediately, so
315
+ * without care the first client render disagrees with the markup it is
316
+ * hydrating — and **React does not repair that**. Measured against React
317
+ * 19.2.3: a `className` / `style` mismatch is adopted from the server DOM,
318
+ * left on screen, and reported through *zero* recoverable errors. A tablet
319
+ * gets the phone layout, permanently, with no console signal.
320
+ *
321
+ * So this hook reports `compact` for as long as the client is hydrating,
322
+ * matching the markup exactly, and switches to the measured breakpoint on the
323
+ * re-render React schedules once hydration finishes. The correction is an
324
+ * ordinary update, which *does* patch the DOM. The guard lives in this
325
+ * package's `useWindowDimensions`, which this hook reads. Use that hook, not
326
+ * the `react-native` one, when a layout needs the raw width.
327
+ *
328
+ * **It costs nothing where there is no hydration.** On native, and on a
329
+ * single-page web build, `getServerSnapshot` is never called, so the measured
330
+ * breakpoint is returned from the first render with no extra pass. Consumers
331
+ * need no `useHydrated` gate of their own, and neither does `Grid`, which
332
+ * resolves a breakpoint map internally and gives a consumer nowhere to put
333
+ * one.
334
+ *
176
335
  * @example
177
336
  * const breakpoint = useBreakpoint()
178
337
  * const columns = breakpoint === 'compact' ? 2 : 4
@@ -191,6 +350,34 @@ type BreakpointValues<T> = Partial<Record<Breakpoint, T>> & Record<'compact', T>
191
350
  */
192
351
  declare function useBreakpointValue<T>(values: BreakpointValues<T>): T;
193
352
 
353
+ /**
354
+ * Returns the window size, the same as `useWindowDimensions` from
355
+ * `react-native`, but safe to use in a static web export.
356
+ *
357
+ * **Use this instead of the `react-native` hook for any value that reaches a
358
+ * style or the tree.** A static export (`web.output: 'static'`) renders on a
359
+ * server with no DOM, where react-native-web measures a 0 by 0 window. The
360
+ * client measures the real window on its first render, so the `react-native`
361
+ * hook disagrees with the markup it hydrates, and React 19 keeps the server's
362
+ * style with no error. A carousel slot sized from the width, or a hero height
363
+ * set as a fraction of it, then keeps the layout of a 0 wide window until the
364
+ * reader resizes the window.
365
+ *
366
+ * This hook returns the server's 0 by 0 window while the client hydrates, and
367
+ * the measured window on the re-render React schedules after hydration. That
368
+ * re-render is an ordinary update, which does patch the DOM. On native, and on
369
+ * a single-page web build, nothing hydrates, so the measured window comes back
370
+ * from the first render with no extra pass.
371
+ *
372
+ * `useBreakpoint` reads this hook, so a breakpoint and a raw width cannot
373
+ * disagree during hydration.
374
+ *
375
+ * @example
376
+ * const { width } = useWindowDimensions()
377
+ * const heroHeight = width * 0.56
378
+ */
379
+ declare function useWindowDimensions(): ScaledSize;
380
+
194
381
  /**
195
382
  * Material Design 3 preset — groups all MD3-specific theme values.
196
383
  *
@@ -207,4 +394,4 @@ declare const material: {
207
394
  readonly defaultTopAppBarTokens: TopAppBarTokens;
208
395
  };
209
396
 
210
- export { BaseTheme, type Breakpoint, type BreakpointValues, type IconRenderProps, type IconResolver, IconResolverContext, Motion, Shape, Theme, ThemeProvider, type ThemeProviderProps, TopAppBarTokens, applyRoundness, breakpoints, darkTheme, defaultTopAppBarTokens, defineTheme, lightTheme, material, motionTransitions, useBreakpoint, useBreakpointValue, useIconResolver, useTheme };
397
+ export { BaseTheme, type Breakpoint, type BreakpointValues, type ColorScheme, type IconRenderProps, type IconResolver, type IconSource, Motion, Shape, THEME_MODE_STORAGE_KEY, Theme, type ThemeMode, type ThemeModeContextValue, type ThemeModeStorage, type ThemePair, ThemeProvider, type ThemeProviderProps, TopAppBarTokens, applyRoundness, breakpoints, darkTheme, defaultTopAppBarTokens, defineTheme, lightTheme, material, motionTransitions, useBreakpoint, useBreakpointValue, useIconResolver, useTheme, useThemeMode, useWindowDimensions };
package/dist/index.mjs CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  defaultTopAppBarTokens,
4
4
  defaultTypography,
5
5
  lightTheme
6
- } from "./chunk-67NS34RT.mjs";
6
+ } from "./chunk-HMQZLDPN.mjs";
7
7
 
8
8
  // src/theme/dark.ts
9
9
  var darkTheme = {
@@ -171,8 +171,14 @@ var darkTheme = {
171
171
  easingEmphasized: "cubic-bezier(0.2, 0, 0, 1)",
172
172
  easingEmphasizedAccelerate: "cubic-bezier(0.3, 0, 0.8, 0.15)",
173
173
  easingEmphasizedDecelerate: "cubic-bezier(0.05, 0.7, 0.1, 1)",
174
- springFastSpatial: { tension: 380, friction: 33, mass: 1 },
175
- springDefaultSpatial: { tension: 380, friction: 26, mass: 1 }
174
+ // MD3 Expressive scheme, androidx ExpressiveMotionTokens.kt v0_14_0.
175
+ // tension = Compose stiffness; friction = dampingRatio * 2 * sqrt(tension).
176
+ springFastSpatial: { tension: 800, friction: 33.94, mass: 1 },
177
+ springDefaultSpatial: { tension: 380, friction: 31.19, mass: 1 },
178
+ springSlowSpatial: { tension: 200, friction: 22.63, mass: 1 },
179
+ springFastEffects: { tension: 3800, friction: 123.29, mass: 1 },
180
+ springDefaultEffects: { tension: 1600, friction: 80, mass: 1 },
181
+ springSlowEffects: { tension: 800, friction: 56.57, mass: 1 }
176
182
  }
177
183
  };
178
184
 
@@ -182,38 +188,30 @@ function defineTheme(theme) {
182
188
  }
183
189
 
184
190
  // src/theme/motionAdapter.ts
185
- import {
186
- cubicBezier
187
- } from "@rootnative/inertia";
188
191
  function motionTransitions(motion) {
189
- const standard = cubicBezier(motion.easingStandard);
190
192
  return {
191
- "state-hover": {
192
- type: "timing",
193
- duration: motion.durationShort3,
194
- easing: standard
195
- },
196
- "state-press": {
197
- type: "timing",
198
- duration: motion.durationShort2,
199
- easing: standard
200
- },
201
- "state-focus": {
202
- type: "timing",
203
- duration: motion.durationShort4,
204
- easing: standard
205
- },
193
+ "state-hover": { type: "spring", ...motion.springFastEffects },
194
+ "state-press": { type: "spring", ...motion.springFastEffects },
195
+ "state-focus": { type: "spring", ...motion.springFastEffects },
206
196
  "spring-fast-spatial": { type: "spring", ...motion.springFastSpatial },
207
197
  "spring-default-spatial": {
208
198
  type: "spring",
209
199
  ...motion.springDefaultSpatial
210
- }
200
+ },
201
+ "spring-slow-spatial": { type: "spring", ...motion.springSlowSpatial },
202
+ "spring-fast-effects": { type: "spring", ...motion.springFastEffects },
203
+ "spring-default-effects": {
204
+ type: "spring",
205
+ ...motion.springDefaultEffects
206
+ },
207
+ "spring-slow-effects": { type: "spring", ...motion.springSlowEffects }
211
208
  };
212
209
  }
213
210
 
214
211
  // src/provider/ThemeProvider.tsx
215
212
  import { MotionConfig } from "@rootnative/inertia";
216
- import * as React3 from "react";
213
+ import * as React4 from "react";
214
+ import { useColorScheme } from "react-native";
217
215
 
218
216
  // src/provider/IconResolverContext.ts
219
217
  import * as React from "react";
@@ -225,19 +223,98 @@ var IconResolverContext = React.createContext(
225
223
  import * as React2 from "react";
226
224
  var ThemeContext = React2.createContext(lightTheme);
227
225
 
226
+ // src/provider/ThemeModeContext.ts
227
+ import * as React3 from "react";
228
+ var ThemeModeContext = React3.createContext(null);
229
+
228
230
  // src/provider/ThemeProvider.tsx
229
231
  import { jsx } from "react/jsx-runtime";
232
+ var THEME_MODE_STORAGE_KEY = "rootnative.theme-mode";
233
+ function isThemePair(theme) {
234
+ return !("colors" in theme);
235
+ }
236
+ function isThemeMode(value) {
237
+ return value === "system" || value === "light" || value === "dark";
238
+ }
230
239
  function ThemeProvider({
231
240
  theme,
241
+ mode: controlledMode,
242
+ defaultMode = "system",
243
+ onModeChange,
244
+ storage,
232
245
  iconResolver,
233
246
  children
234
247
  }) {
235
- const resolvedTheme = theme != null ? theme : lightTheme;
236
- const transitions = React3.useMemo(
248
+ const pair = theme && isThemePair(theme) ? theme : null;
249
+ const systemScheme = useColorScheme();
250
+ const [uncontrolledMode, setUncontrolledMode] = React4.useState(defaultMode);
251
+ const isControlled = controlledMode !== void 0;
252
+ const mode = isControlled ? controlledMode : uncontrolledMode;
253
+ const [isReady, setIsReady] = React4.useState(
254
+ () => !storage || isControlled || !pair
255
+ );
256
+ const storageRef = React4.useRef(storage);
257
+ React4.useEffect(() => {
258
+ storageRef.current = storage;
259
+ });
260
+ const shouldLoad = Boolean(storage) && !isControlled && Boolean(pair);
261
+ React4.useEffect(() => {
262
+ if (!shouldLoad) {
263
+ setIsReady(true);
264
+ return;
265
+ }
266
+ let cancelled = false;
267
+ const load = async () => {
268
+ var _a;
269
+ try {
270
+ const stored = await ((_a = storageRef.current) == null ? void 0 : _a.getItem(THEME_MODE_STORAGE_KEY));
271
+ if (!cancelled && isThemeMode(stored)) {
272
+ setUncontrolledMode(stored);
273
+ }
274
+ } catch {
275
+ } finally {
276
+ if (!cancelled) {
277
+ setIsReady(true);
278
+ }
279
+ }
280
+ };
281
+ void load();
282
+ return () => {
283
+ cancelled = true;
284
+ };
285
+ }, [shouldLoad]);
286
+ const setMode = React4.useCallback(
287
+ (nextMode) => {
288
+ var _a;
289
+ if (!isControlled) {
290
+ setUncontrolledMode(nextMode);
291
+ }
292
+ onModeChange == null ? void 0 : onModeChange(nextMode);
293
+ if (!isControlled) {
294
+ try {
295
+ const result = (_a = storageRef.current) == null ? void 0 : _a.setItem(
296
+ THEME_MODE_STORAGE_KEY,
297
+ nextMode
298
+ );
299
+ void Promise.resolve(result).catch(() => {
300
+ });
301
+ } catch {
302
+ }
303
+ }
304
+ },
305
+ [isControlled, onModeChange]
306
+ );
307
+ const scheme = mode === "system" ? systemScheme === "dark" ? "dark" : "light" : mode;
308
+ const resolvedTheme = pair ? scheme === "dark" ? pair.dark : pair.light : theme != null ? theme : lightTheme;
309
+ const modeValue = React4.useMemo(
310
+ () => pair ? { mode, scheme, setMode, isReady } : null,
311
+ [pair, mode, scheme, setMode, isReady]
312
+ );
313
+ const transitions = React4.useMemo(
237
314
  () => motionTransitions(resolvedTheme.motion),
238
315
  [resolvedTheme.motion]
239
316
  );
240
- return /* @__PURE__ */ jsx(ThemeContext.Provider, { value: resolvedTheme, children: /* @__PURE__ */ jsx(IconResolverContext.Provider, { value: iconResolver != null ? iconResolver : null, children: /* @__PURE__ */ jsx(MotionConfig, { transitions, children }) }) });
317
+ return /* @__PURE__ */ jsx(ThemeContext.Provider, { value: resolvedTheme, children: /* @__PURE__ */ jsx(ThemeModeContext.Provider, { value: modeValue, children: /* @__PURE__ */ jsx(IconResolverContext.Provider, { value: iconResolver != null ? iconResolver : null, children: /* @__PURE__ */ jsx(MotionConfig, { transitions, children }) }) }) });
241
318
  }
242
319
 
243
320
  // src/provider/useTheme.ts
@@ -246,14 +323,48 @@ function useTheme() {
246
323
  return useContext(ThemeContext);
247
324
  }
248
325
 
249
- // src/provider/useIconResolver.ts
326
+ // src/provider/useThemeMode.ts
250
327
  import { useContext as useContext2 } from "react";
328
+ function useThemeMode() {
329
+ const value = useContext2(ThemeModeContext);
330
+ if (value === null) {
331
+ throw new Error(
332
+ "useThemeMode() requires a <ThemeProvider theme={{ light, dark }}>. A provider with a single theme has no light/dark mode to control."
333
+ );
334
+ }
335
+ return value;
336
+ }
337
+
338
+ // src/provider/useIconResolver.ts
339
+ import { useContext as useContext3 } from "react";
251
340
  function useIconResolver() {
252
- return useContext2(IconResolverContext);
341
+ return useContext3(IconResolverContext);
342
+ }
343
+
344
+ // src/responsive/useWindowDimensions.ts
345
+ import { useSyncExternalStore } from "react";
346
+ import { useWindowDimensions as useMeasuredWindowDimensions } from "react-native";
347
+ var subscribeToNothing = () => () => {
348
+ };
349
+ var notHydrating = () => false;
350
+ var isHydratingOnServer = () => true;
351
+ var SERVER_WINDOW = Object.freeze({
352
+ width: 0,
353
+ height: 0,
354
+ scale: 1,
355
+ fontScale: 1
356
+ });
357
+ function useWindowDimensions() {
358
+ const measured = useMeasuredWindowDimensions();
359
+ const hydrating = useSyncExternalStore(
360
+ subscribeToNothing,
361
+ notHydrating,
362
+ isHydratingOnServer
363
+ );
364
+ return hydrating ? SERVER_WINDOW : measured;
253
365
  }
254
366
 
255
367
  // src/responsive/useBreakpoint.ts
256
- import { useWindowDimensions } from "react-native";
257
368
  var breakpoints = {
258
369
  compact: 0,
259
370
  medium: 600,
@@ -298,7 +409,7 @@ var material = {
298
409
  defaultTopAppBarTokens
299
410
  };
300
411
  export {
301
- IconResolverContext,
412
+ THEME_MODE_STORAGE_KEY,
302
413
  ThemeProvider,
303
414
  applyRoundness,
304
415
  breakpoints,
@@ -311,5 +422,7 @@ export {
311
422
  useBreakpoint,
312
423
  useBreakpointValue,
313
424
  useIconResolver,
314
- useTheme
425
+ useTheme,
426
+ useThemeMode,
427
+ useWindowDimensions
315
428
  };
@@ -6,12 +6,12 @@
6
6
  * @example
7
7
  * interface MyTheme extends BaseTheme {
8
8
  * colors: { brand: string; background: string; text: string }
9
- * typography: { heading: TextStyle; body: TextStyle }
9
+ * typography: { heading: TypographyToken; body: TypographyToken }
10
10
  * }
11
11
  */
12
12
  interface BaseTheme {
13
13
  colors: Record<string, string>;
14
- typography: Record<string, TextStyle>;
14
+ typography: Record<string, TypographyToken>;
15
15
  shape: Shape;
16
16
  spacing: Spacing;
17
17
  stateLayer: StateLayer;
@@ -37,8 +37,7 @@ interface Theme extends BaseTheme {
37
37
  */
38
38
  type MaterialTheme = Theme;
39
39
  /** Material Design 3 color roles. All values are CSS color strings (hex, rgb, etc.). */
40
- interface Colors {
41
- [key: string]: string;
40
+ type Colors = {
42
41
  primary: string;
43
42
  onPrimary: string;
44
43
  primaryContainer: string;
@@ -88,28 +87,49 @@ interface Colors {
88
87
  inverseSurface: string;
89
88
  inverseOnSurface: string;
90
89
  inversePrimary: string;
91
- }
92
- /** Material Design 3 type scale with 15 roles across 5 categories (display, headline, title, body, label). */
93
- interface Typography {
94
- [key: string]: TextStyle;
95
- displayLarge: TextStyle;
96
- displayMedium: TextStyle;
97
- displaySmall: TextStyle;
98
- headlineLarge: TextStyle;
99
- headlineMedium: TextStyle;
100
- headlineSmall: TextStyle;
101
- titleLarge: TextStyle;
102
- titleMedium: TextStyle;
103
- titleSmall: TextStyle;
104
- bodyLarge: TextStyle;
105
- bodyMedium: TextStyle;
106
- bodySmall: TextStyle;
107
- labelLarge: TextStyle;
108
- labelMedium: TextStyle;
109
- labelSmall: TextStyle;
110
- }
90
+ };
91
+ /**
92
+ * Material Design 3 type scale with 15 roles across 5 categories (display,
93
+ * headline, title, body, label), plus the 15 MD3 Expressive emphasized
94
+ * variants. Emphasized styles keep the base size/line-height and step the
95
+ * weight up (regular→medium, medium→bold); a few also adjust tracking. The
96
+ * spec additionally varies width/grade on variable fonts, which React Native
97
+ * cannot express — weight (+tracking) is the documented approximation.
98
+ */
99
+ type Typography = {
100
+ displayLarge: TypographyToken;
101
+ displayMedium: TypographyToken;
102
+ displaySmall: TypographyToken;
103
+ headlineLarge: TypographyToken;
104
+ headlineMedium: TypographyToken;
105
+ headlineSmall: TypographyToken;
106
+ titleLarge: TypographyToken;
107
+ titleMedium: TypographyToken;
108
+ titleSmall: TypographyToken;
109
+ bodyLarge: TypographyToken;
110
+ bodyMedium: TypographyToken;
111
+ bodySmall: TypographyToken;
112
+ labelLarge: TypographyToken;
113
+ labelMedium: TypographyToken;
114
+ labelSmall: TypographyToken;
115
+ displayLargeEmphasized: TypographyToken;
116
+ displayMediumEmphasized: TypographyToken;
117
+ displaySmallEmphasized: TypographyToken;
118
+ headlineLargeEmphasized: TypographyToken;
119
+ headlineMediumEmphasized: TypographyToken;
120
+ headlineSmallEmphasized: TypographyToken;
121
+ titleLargeEmphasized: TypographyToken;
122
+ titleMediumEmphasized: TypographyToken;
123
+ titleSmallEmphasized: TypographyToken;
124
+ bodyLargeEmphasized: TypographyToken;
125
+ bodyMediumEmphasized: TypographyToken;
126
+ bodySmallEmphasized: TypographyToken;
127
+ labelLargeEmphasized: TypographyToken;
128
+ labelMediumEmphasized: TypographyToken;
129
+ labelSmallEmphasized: TypographyToken;
130
+ };
111
131
  type FontWeight = 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900';
112
- interface TextStyle {
132
+ interface TypographyToken {
113
133
  fontFamily: string;
114
134
  fontSize: number;
115
135
  fontWeight: FontWeight;
@@ -216,17 +236,41 @@ interface Motion {
216
236
  easingEmphasizedAccelerate: string;
217
237
  easingEmphasizedDecelerate: string;
218
238
  /**
219
- * Spring for fast spatial transitions — selection morphs that track user
220
- * input snappily (Switch thumb, Slider press-grow). Slight overshoot,
221
- * ~0.85 damping ratio. Named after the MD3 Expressive motion-physics token
222
- * scheme (fast/default/slow × spatial/effects).
239
+ * Spring for fast spatial transitions — small-element position/size/corner
240
+ * morphs that track user input snappily (Switch thumb, Slider press-grow,
241
+ * press shape-morphs). Pronounced overshoot (damping ratio 0.6). Named
242
+ * after the MD3 Expressive motion-physics token scheme
243
+ * (fast/default/slow × spatial/effects).
223
244
  */
224
245
  springFastSpatial: MotionSpring;
225
246
  /**
226
- * Spring for default spatial transitions — selection morphs with a softer,
227
- * bouncier settle (Checkbox and Radio marks).
247
+ * Spring for default spatial transitions — standard-size element morphs
248
+ * with a softer, bouncier settle (Checkbox and Radio marks). Damping
249
+ * ratio 0.8.
228
250
  */
229
251
  springDefaultSpatial: MotionSpring;
252
+ /**
253
+ * Spring for slow spatial transitions — large-element position/size/corner
254
+ * morphs (full-screen or container-scale movement). Damping ratio 0.8 at
255
+ * low stiffness.
256
+ */
257
+ springSlowSpatial: MotionSpring;
258
+ /**
259
+ * Spring for fast effects transitions — small-element color/opacity
260
+ * feedback (state layers). Critically damped (damping ratio 1.0) — effects
261
+ * springs never overshoot.
262
+ */
263
+ springFastEffects: MotionSpring;
264
+ /**
265
+ * Spring for default effects transitions — standard color/opacity changes.
266
+ * Critically damped.
267
+ */
268
+ springDefaultEffects: MotionSpring;
269
+ /**
270
+ * Spring for slow effects transitions — large-surface color/opacity
271
+ * changes. Critically damped.
272
+ */
273
+ springSlowEffects: MotionSpring;
230
274
  }
231
275
 
232
- export type { BaseTheme as B, Colors as C, Elevation as E, FontWeight as F, Motion as M, Shape as S, Theme as T, TopAppBarTokens as a, ElevationLevel as b, MaterialTheme as c, MotionSpring as d, ShadowOffset as e, Spacing as f, StateLayer as g, TextStyle as h, Typography as i };
276
+ export type { BaseTheme as B, Colors as C, Elevation as E, FontWeight as F, Motion as M, Shape as S, Theme as T, TopAppBarTokens as a, ElevationLevel as b, MaterialTheme as c, MotionSpring as d, ShadowOffset as e, Spacing as f, StateLayer as g, Typography as h, TypographyToken as i };