@medixdeck/ui 0.1.7 → 0.1.8

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.ts CHANGED
@@ -2219,6 +2219,10 @@ export declare const textStyleTokens: {
2219
2219
  };
2220
2220
  };
2221
2221
 
2222
+ export declare type ThemeMode = "light" | "dark";
2223
+
2224
+ export declare type ThemeModeSetting = ThemeMode | "system";
2225
+
2222
2226
  export declare const toast: {
2223
2227
  (options: Omit<ToastOptions, "id">): string;
2224
2228
  success(title: string, options?: Partial<ToastOptions>): string;
@@ -2374,6 +2378,66 @@ export declare const typographyTokens: {
2374
2378
  };
2375
2379
  };
2376
2380
 
2381
+ /**
2382
+ * Convenience hook for checking whether the active MedixDeck theme is dark.
2383
+ *
2384
+ * Returns `false` until the component has mounted and `next-themes` has had a
2385
+ * chance to resolve the active theme. This avoids reporting light mode during
2386
+ * SSR or initial hydration when the resolved client theme is actually dark.
2387
+ */
2388
+ export declare function useIsDarkMode(): boolean;
2389
+
2390
+ /**
2391
+ * Accesses the current MedixDeck theme mode and helpers for updating it.
2392
+ *
2393
+ * In SSR environments (e.g. Next.js), `next-themes` resolves the theme after
2394
+ * hydration. Gate any theme-dependent UI on `mounted` to avoid hydration
2395
+ * mismatches and flicker. In Next.js App Router, this hook must be called
2396
+ * inside a `"use client"` component.
2397
+ *
2398
+ * @example
2399
+ * ```tsx
2400
+ * // Avoid hydration mismatch: render theme-dependent UI only after mount.
2401
+ * const { mounted, themeMode, toggleThemeMode } = useThemeMode();
2402
+ *
2403
+ * if (!mounted) return null;
2404
+ *
2405
+ * return (
2406
+ * <button onClick={toggleThemeMode}>
2407
+ * Switch to {themeMode === "dark" ? "light" : "dark"} mode
2408
+ * </button>
2409
+ * );
2410
+ * ```
2411
+ */
2412
+ export declare function useThemeMode(): UseThemeModeResult;
2413
+
2414
+ export declare interface UseThemeModeResult {
2415
+ /**
2416
+ * Indicates whether the hook has mounted on the client.
2417
+ * Primarily useful for avoiding SSR hydration mismatches with `next-themes`.
2418
+ */
2419
+ mounted: boolean;
2420
+ /**
2421
+ * The currently resolved theme mode.
2422
+ * Falls back to `"light"` before client-side theme values are available.
2423
+ */
2424
+ themeMode: ThemeMode;
2425
+ /**
2426
+ * The user's current theme preference (`"light"`, `"dark"`, or `"system"`).
2427
+ * Defaults to `"system"` before client-side hydration or when the provider
2428
+ * returns an unrecognised value (e.g. outside a `MedixProvider`).
2429
+ */
2430
+ themeSetting: ThemeModeSetting;
2431
+ /**
2432
+ * Updates the active theme preference.
2433
+ */
2434
+ setThemeMode: (mode: ThemeModeSetting) => void;
2435
+ /**
2436
+ * Toggles between `"light"` and `"dark"` modes.
2437
+ */
2438
+ toggleThemeMode: () => void;
2439
+ }
2440
+
2377
2441
  /**
2378
2442
  * MedixDeck VitalBadge
2379
2443
  *