@mlola-ui/motion 1.0.13 → 1.1.1

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,15 +1,17 @@
1
1
  "use client";
2
2
  import * as React from "react";
3
3
  const query = "(prefers-reduced-motion: reduce)";
4
+ // Test environments such as jsdom have a window but no matchMedia.
5
+ const supported = () => typeof window !== "undefined" && typeof window.matchMedia === "function";
4
6
  function subscribe(listener) {
5
- if (typeof window === "undefined")
7
+ if (!supported())
6
8
  return () => { };
7
9
  const media = window.matchMedia(query);
8
10
  media.addEventListener("change", listener);
9
11
  return () => media.removeEventListener("change", listener);
10
12
  }
11
13
  function snapshot() {
12
- return typeof window !== "undefined" && window.matchMedia(query).matches;
14
+ return supported() && window.matchMedia(query).matches;
13
15
  }
14
16
  export function useReducedMotion() {
15
17
  return React.useSyncExternalStore(subscribe, snapshot, () => false);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mlola-ui/motion",
3
- "version": "1.0.13",
3
+ "version": "1.1.1",
4
4
  "description": "Reduced-motion-aware kinetic primitives for Mlola UI",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",