cherry-styled-components 0.2.12 → 0.2.14

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.
@@ -0,0 +1,25 @@
1
+ "use client";
2
+ "use client";
3
+ import { useEffect } from "react";
4
+ //#region src/lib/utils/use-lock-body-scroll.tsx
5
+ var lockCount = 0;
6
+ var previousOverflow = "";
7
+ /**
8
+ * Freezes body scrolling while `isLocked` is true. Safe to nest: the body is
9
+ * restored only when every active lock has been released.
10
+ */ function useLockBodyScroll(isLocked) {
11
+ useEffect(() => {
12
+ if (!isLocked) return;
13
+ if (lockCount === 0) {
14
+ previousOverflow = document.body.style.overflow;
15
+ document.body.style.overflow = "hidden";
16
+ }
17
+ lockCount += 1;
18
+ return () => {
19
+ lockCount -= 1;
20
+ if (lockCount === 0) document.body.style.overflow = previousOverflow;
21
+ };
22
+ }, [isLocked]);
23
+ }
24
+ //#endregion
25
+ export { useLockBodyScroll };
@@ -0,0 +1,14 @@
1
+ import { Breakpoints } from './theme';
2
+ /**
3
+ * Subscribes to a media query. Returns `false` on the server and during the
4
+ * first client render so hydration matches, then re-renders with the real
5
+ * match. Pass a full media query string, e.g. "(max-width: 991px)".
6
+ */
7
+ export declare function useMediaQuery(query: string): boolean;
8
+ /**
9
+ * True while the viewport is narrower than the named breakpoint, i.e. the
10
+ * inverse of the `mq()` helper's min-width query. Handy for behavior (not
11
+ * styling) that has to change below a breakpoint, such as a side panel turning
12
+ * into a full-screen modal.
13
+ */
14
+ export declare function useBelowBreakpoint(size: keyof Breakpoints): boolean;
@@ -0,0 +1,28 @@
1
+ "use client";
2
+ "use client";
3
+ import { breakpoints } from "./theme.js";
4
+ import { useCallback, useSyncExternalStore } from "react";
5
+ //#region src/lib/utils/use-media-query.tsx
6
+ /**
7
+ * Subscribes to a media query. Returns `false` on the server and during the
8
+ * first client render so hydration matches, then re-renders with the real
9
+ * match. Pass a full media query string, e.g. "(max-width: 991px)".
10
+ */ function useMediaQuery(query) {
11
+ const subscribe = useCallback((onChange) => {
12
+ const mediaQuery = window.matchMedia(query);
13
+ mediaQuery.addEventListener("change", onChange);
14
+ return () => mediaQuery.removeEventListener("change", onChange);
15
+ }, [query]);
16
+ const getSnapshot = useCallback(() => window.matchMedia(query).matches, [query]);
17
+ return useSyncExternalStore(subscribe, getSnapshot, () => false);
18
+ }
19
+ /**
20
+ * True while the viewport is narrower than the named breakpoint, i.e. the
21
+ * inverse of the `mq()` helper's min-width query. Handy for behavior (not
22
+ * styling) that has to change below a breakpoint, such as a side panel turning
23
+ * into a full-screen modal.
24
+ */ function useBelowBreakpoint(size) {
25
+ return useMediaQuery(`(max-width: ${breakpoints[size] - 1}px)`);
26
+ }
27
+ //#endregion
28
+ export { useBelowBreakpoint, useMediaQuery };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cherry-styled-components",
3
- "version": "0.2.12",
3
+ "version": "0.2.14",
4
4
  "description": "Cherry is a design system for the modern web. Designed in Figma, built in React using Typescript.",
5
5
  "private": false,
6
6
  "type": "module",
@@ -20,6 +20,7 @@
20
20
  "homepage": "https://cherry.al",
21
21
  "repository": "https://github.com/cherry-design-system/styled-components",
22
22
  "license": "MIT",
23
+ "packageManager": "pnpm@11.20.0",
23
24
  "engines": {
24
25
  "node": ">=18.0.0"
25
26
  },
@@ -40,6 +41,7 @@
40
41
  "build": "vite build",
41
42
  "build:demo": "vite build --mode demo",
42
43
  "format": "prettier --write .",
44
+ "format:check": "prettier --check .",
43
45
  "screenshots": "node scripts/screenshot-previews.cjs"
44
46
  },
45
47
  "dependencies": {
@@ -53,14 +55,14 @@
53
55
  "devDependencies": {
54
56
  "@swc/plugin-styled-components": "^12.15.0",
55
57
  "@types/node": "^26.1.2",
56
- "@types/react": "^19.2.17",
57
- "@types/react-dom": "^19.2.3",
58
+ "@types/react": "^19.2.18",
59
+ "@types/react-dom": "^19.2.4",
58
60
  "@typescript/typescript6": "^6.0.2",
59
61
  "@vitejs/plugin-react-swc": "^4.3.3",
60
62
  "eslint-plugin-react-hooks": "^7.1.1",
61
63
  "eslint-plugin-react-refresh": "^0.5.3",
62
- "next": "^16.2.12",
63
- "playwright-core": "^1.62.0",
64
+ "next": "^16.3.0",
65
+ "playwright-core": "^1.62.1",
64
66
  "prettier": "^3.9.6",
65
67
  "react": "^19.2.8",
66
68
  "react-dom": "^19.2.8",
@@ -68,7 +70,7 @@
68
70
  "sharp": "^0.35.3",
69
71
  "styled-components": "^6.4.4",
70
72
  "typescript": "^7.0.2",
71
- "vite": "^8.1.5",
73
+ "vite": "^8.2.0",
72
74
  "vite-plugin-dts": "^5.0.3"
73
75
  }
74
76
  }