@remit/web-client 0.0.151 → 0.0.153

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remit/web-client",
3
- "version": "0.0.151",
3
+ "version": "0.0.153",
4
4
  "type": "module",
5
5
  "description": "Remit web client, published as composable primitives — the app shell, auth shells, and runtime config. A distributor imports what it composes and bundles it.",
6
6
  "exports": {
@@ -29,7 +29,7 @@
29
29
  "build:dist": "npm run generate:routes && node --import tsx harness/build.mjs",
30
30
  "preview": "vite preview",
31
31
  "test:typecheck": "npm run generate:routes && tsgo --noEmit && tsgo --noEmit -p tsconfig.node.json",
32
- "test:run": "TSX_TSCONFIG_PATH=./tsconfig.test.json node --import tsx --import ./test-support/register.mjs --experimental-test-coverage --test-coverage-include='src/**' --test-coverage-exclude='src/**/*.test.ts' --test-coverage-exclude='src/**/*.test.tsx' --test-coverage-exclude='src/test-support/**' --test-coverage-lines=86 --test 'src/**/*.test.ts'",
32
+ "test:run": "TSX_TSCONFIG_PATH=./tsconfig.test.json node $NODE_TEST_FLAGS --import tsx --import ./test-support/register.mjs --experimental-test-coverage --test-coverage-include='src/**' --test-coverage-exclude='src/**/*.test.ts' --test-coverage-exclude='src/**/*.test.tsx' --test-coverage-exclude='src/test-support/**' --test-coverage-lines=86 --test 'src/**/*.test.ts'",
33
33
  "test": "npm run test:typecheck && npm run test:run"
34
34
  },
35
35
  "peerDependencies": {
@@ -1,5 +1,8 @@
1
- import { DESKTOP_MEDIA_QUERY, DESKTOP_MIN_WIDTH } from "@remit/ui";
2
- import { useMediaQuery } from "./useMediaQuery";
1
+ import {
2
+ DESKTOP_MEDIA_QUERY,
3
+ DESKTOP_MIN_WIDTH,
4
+ useMatchMedia,
5
+ } from "@remit/ui";
3
6
 
4
7
  /**
5
8
  * Responsive layout tiers for the mail shell:
@@ -46,11 +49,11 @@ export const isSinglePaneTier = (tier: LayoutTier): boolean =>
46
49
 
47
50
  /**
48
51
  * Returns the current layout tier. SSR-safe (falls back to `phone` before
49
- * hydration, matching `useMediaQuery`'s server default).
52
+ * hydration, matching `useMatchMedia`'s server default).
50
53
  */
51
54
  export const useLayoutTier = (): LayoutTier => {
52
- const isTabletUp = useMediaQuery(`(min-width: ${TABLET_MIN_WIDTH}px)`);
53
- const isDesktop = useMediaQuery(DESKTOP_MEDIA_QUERY);
55
+ const isTabletUp = useMatchMedia(`(min-width: ${TABLET_MIN_WIDTH}px)`);
56
+ const isDesktop = useMatchMedia(DESKTOP_MEDIA_QUERY);
54
57
  if (isDesktop) return "desktop";
55
58
  if (isTabletUp) return "tablet";
56
59
  return "phone";
@@ -1,31 +1,4 @@
1
- import { DESKTOP_MEDIA_QUERY } from "@remit/ui";
2
- import { useEffect, useState } from "react";
3
-
4
- /**
5
- * Subscribes to a CSS media query and returns its current `matches` value.
6
- * SSR-safe: returns `false` on the server / initial render before hydration.
7
- *
8
- * Layout breakpoints are exported by `@remit/ui` alongside the Tailwind
9
- * variants they mirror — pass those, not a hand-written width.
10
- */
11
- export const useMediaQuery = (query: string): boolean => {
12
- const [matches, setMatches] = useState(() => {
13
- if (typeof window === "undefined" || !window.matchMedia) return false;
14
- return window.matchMedia(query).matches;
15
- });
16
-
17
- useEffect(() => {
18
- if (typeof window === "undefined" || !window.matchMedia) return;
19
- const mql = window.matchMedia(query);
20
- const handler = (event: MediaQueryListEvent) => setMatches(event.matches);
21
- // Sync state on mount in case the SSR/initial render disagreed.
22
- setMatches(mql.matches);
23
- mql.addEventListener("change", handler);
24
- return () => mql.removeEventListener("change", handler);
25
- }, [query]);
26
-
27
- return matches;
28
- };
1
+ import { DESKTOP_MEDIA_QUERY, useMatchMedia } from "@remit/ui";
29
2
 
30
3
  /**
31
4
  * True at desktop (Tailwind `lg:` and up): at least 1024px wide and not a
@@ -37,4 +10,4 @@ export const useMediaQuery = (query: string): boolean => {
37
10
  * `lg` variant is redefined in `@remit/ui`'s token sheet with the same
38
11
  * condition — change `DESKTOP_MEDIA_QUERY` and both move together.
39
12
  */
40
- export const useIsDesktop = (): boolean => useMediaQuery(DESKTOP_MEDIA_QUERY);
13
+ export const useIsDesktop = (): boolean => useMatchMedia(DESKTOP_MEDIA_QUERY);