@versaur/react 1.0.18 → 1.0.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.
@@ -0,0 +1,89 @@
1
+ import { RefObject } from 'react';
2
+
3
+ /**
4
+ * Hook to detect if viewport is at desktop breakpoint (exclusive)
5
+ * Returns true only if viewport width is 1024px or greater
6
+ *
7
+ * @example
8
+ * ```tsx
9
+ * function MyComponent() {
10
+ * const isDesktop = useDesktopBreakpoint();
11
+ * return <div>{isDesktop ? "Desktop view" : "Smaller view"}</div>;
12
+ * }
13
+ * ```
14
+ */
15
+ export declare function useDesktopBreakpoint(): boolean;
16
+
17
+ /**
18
+ * Hook to detect if viewport is at mobile breakpoint (exclusive)
19
+ * Returns true only if viewport width is less than 640px
20
+ *
21
+ * @example
22
+ * ```tsx
23
+ * function MyComponent() {
24
+ * const isMobile = useMobileBreakpoint();
25
+ * return <div>{isMobile ? "Mobile view" : "Larger view"}</div>;
26
+ * }
27
+ * ```
28
+ */
29
+ export declare function useMobileBreakpoint(): boolean;
30
+
31
+ /**
32
+ * Hook to detect if viewport is mobile or tablet (combined)
33
+ * Returns true if viewport width is less than 1024px
34
+ *
35
+ * @example
36
+ * ```tsx
37
+ * function MyComponent() {
38
+ * const isSmall = useMobileOrTabletBreakpoint();
39
+ * return <div>{isSmall ? "Small screen" : "Large screen"}</div>;
40
+ * }
41
+ * ```
42
+ */
43
+ export declare function useMobileOrTabletBreakpoint(): boolean;
44
+
45
+ /**
46
+ * Hook for observing resize events on a DOM element
47
+ *
48
+ * @param ref - React ref to the element to observe
49
+ * @param callback - Function to call when element is resized
50
+ *
51
+ * @example
52
+ * ```tsx
53
+ * const containerRef = useRef<HTMLDivElement>(null);
54
+ * useResizeObserver(containerRef, () => {
55
+ * console.log("Container resized!");
56
+ * });
57
+ * ```
58
+ */
59
+ export declare function useResizeObserver(ref: RefObject<HTMLElement>, callback: () => void): void;
60
+
61
+ /**
62
+ * Hook to detect if viewport is at tablet breakpoint (exclusive)
63
+ * Returns true only if viewport width is 640px to 1023px (not mobile, not desktop)
64
+ *
65
+ * @example
66
+ * ```tsx
67
+ * function MyComponent() {
68
+ * const isTablet = useTabletBreakpoint();
69
+ * return <div>{isTablet ? "Tablet-only view" : "Other view"}</div>;
70
+ * }
71
+ * ```
72
+ */
73
+ export declare function useTabletBreakpoint(): boolean;
74
+
75
+ /**
76
+ * Hook to detect if viewport is tablet or desktop (combined)
77
+ * Returns true if viewport width is 640px or greater
78
+ *
79
+ * @example
80
+ * ```tsx
81
+ * function MyComponent() {
82
+ * const isLarge = useTabletOrDesktopBreakpoint();
83
+ * return <div>{isLarge ? "Large screen" : "Mobile"}</div>;
84
+ * }
85
+ * ```
86
+ */
87
+ export declare function useTabletOrDesktopBreakpoint(): boolean;
88
+
89
+ export { }
package/dist/hooks.js ADDED
@@ -0,0 +1,10 @@
1
+ import { u as a, a as o, b as r, c as t, d as p } from "./use-breakpoints-DGKHJ-Jb.js";
2
+ import { u } from "./use-resize-observer-DLkpn8HX.js";
3
+ export {
4
+ a as useDesktopBreakpoint,
5
+ o as useMobileBreakpoint,
6
+ r as useMobileOrTabletBreakpoint,
7
+ u as useResizeObserver,
8
+ t as useTabletBreakpoint,
9
+ p as useTabletOrDesktopBreakpoint
10
+ };
@@ -0,0 +1,44 @@
1
+ import { useState as p, useEffect as c } from "react";
2
+ import { getBreakpointPx as e } from "@versaur/core/utils";
3
+ function n(t) {
4
+ const [a, i] = p(!1);
5
+ return c(() => {
6
+ const o = window.matchMedia(t);
7
+ i(o.matches);
8
+ const r = (s) => {
9
+ i(s.matches);
10
+ };
11
+ return o.addEventListener("change", r), () => {
12
+ o.removeEventListener("change", r);
13
+ };
14
+ }, [t]), a;
15
+ }
16
+ function l() {
17
+ const t = e("mobile");
18
+ return n(`(max-width: ${parseInt(t) - 1}px)`);
19
+ }
20
+ function b() {
21
+ const t = e("mobile"), a = e("tablet");
22
+ return n(
23
+ `(min-width: ${parseInt(t)}px) and (max-width: ${parseInt(a) - 1}px)`
24
+ );
25
+ }
26
+ function h() {
27
+ const t = e("tablet");
28
+ return n(`(min-width: ${parseInt(t)}px)`);
29
+ }
30
+ function d() {
31
+ const t = e("tablet");
32
+ return n(`(max-width: ${parseInt(t) - 1}px)`);
33
+ }
34
+ function k() {
35
+ const t = e("mobile");
36
+ return n(`(min-width: ${parseInt(t)}px)`);
37
+ }
38
+ export {
39
+ l as a,
40
+ d as b,
41
+ b as c,
42
+ k as d,
43
+ h as u
44
+ };
@@ -0,0 +1,14 @@
1
+ import { useEffect as n } from "react";
2
+ function u(e, r) {
3
+ n(() => {
4
+ if (!e.current)
5
+ return;
6
+ const s = new ResizeObserver(r);
7
+ return s.observe(e.current), () => {
8
+ s.disconnect();
9
+ };
10
+ }, [e, r]);
11
+ }
12
+ export {
13
+ u
14
+ };
package/dist/utils.js CHANGED
@@ -1,64 +1,28 @@
1
- import { b as v, a as S, c as g, O as D } from "./overlay-parts-BtD-Qj_k.js";
2
- import { useState as l, useEffect as c } from "react";
3
- import { getBreakpointPx as n } from "@versaur/core/utils";
4
- function r(e) {
5
- const [t, a] = l(!1);
6
- return c(() => {
7
- const o = window.matchMedia(e);
8
- a(o.matches);
9
- const i = (s) => {
10
- a(s.matches);
11
- };
12
- return o.addEventListener("change", i), () => {
13
- o.removeEventListener("change", i);
14
- };
15
- }, [e]), t;
1
+ import { b as O, a as T, c as f, O as D } from "./overlay-parts-BtD-Qj_k.js";
2
+ import { a as r, c as o, u as n, b as a, d as s } from "./use-breakpoints-DGKHJ-Jb.js";
3
+ function l({ children: e }) {
4
+ return r() ? e : null;
16
5
  }
17
- function p() {
18
- const e = n("mobile");
19
- return r(`(max-width: ${parseInt(e) - 1}px)`);
6
+ function u({ children: e }) {
7
+ return o() ? e : null;
20
8
  }
21
- function u() {
22
- const e = n("mobile"), t = n("tablet");
23
- return r(
24
- `(min-width: ${parseInt(e)}px) and (max-width: ${parseInt(t) - 1}px)`
25
- );
9
+ function p({ children: e }) {
10
+ return n() ? e : null;
26
11
  }
27
- function b() {
28
- const e = n("tablet");
29
- return r(`(min-width: ${parseInt(e)}px)`);
12
+ function b({ children: e }) {
13
+ return a() ? e : null;
30
14
  }
31
- function m() {
32
- const e = n("tablet");
33
- return r(`(max-width: ${parseInt(e) - 1}px)`);
34
- }
35
- function k() {
36
- const e = n("mobile");
37
- return r(`(min-width: ${parseInt(e)}px)`);
38
- }
39
- function h({ children: e }) {
40
- return p() ? e : null;
41
- }
42
- function d({ children: e }) {
43
- return u() ? e : null;
44
- }
45
- function x({ children: e }) {
46
- return b() ? e : null;
47
- }
48
- function M({ children: e }) {
49
- return m() ? e : null;
50
- }
51
- function O({ children: e }) {
52
- return k() ? e : null;
15
+ function c({ children: e }) {
16
+ return s() ? e : null;
53
17
  }
54
18
  export {
55
- x as DesktopBreakpoint,
56
- h as MobileBreakpoint,
57
- M as MobileOrTabletBreakpoint,
58
- v as OverlayBody,
59
- S as OverlayFooter,
60
- g as OverlayHeader,
19
+ p as DesktopBreakpoint,
20
+ l as MobileBreakpoint,
21
+ b as MobileOrTabletBreakpoint,
22
+ O as OverlayBody,
23
+ T as OverlayFooter,
24
+ f as OverlayHeader,
61
25
  D as OverlayTitle,
62
- d as TabletBreakpoint,
63
- O as TabletOrDesktopBreakpoint
26
+ u as TabletBreakpoint,
27
+ c as TabletOrDesktopBreakpoint
64
28
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@versaur/react",
3
- "version": "1.0.18",
3
+ "version": "1.0.20",
4
4
  "description": "React components for Versaur Design System",
5
5
  "repository": {
6
6
  "type": "git",
@@ -30,6 +30,11 @@
30
30
  "types": "./dist/utils/index.d.ts",
31
31
  "source": "./src/components/utils/index.ts",
32
32
  "import": "./dist/utils.js"
33
+ },
34
+ "./hooks": {
35
+ "types": "./dist/hooks/index.d.ts",
36
+ "source": "./src/hooks/index.ts",
37
+ "import": "./dist/hooks.js"
33
38
  }
34
39
  },
35
40
  "publishConfig": {
@@ -49,8 +54,8 @@
49
54
  "peerDependencies": {
50
55
  "react": "^18.0.0 || ^19.0.0",
51
56
  "react-dom": "^18.0.0 || ^19.0.0",
52
- "@versaur/core": "0.0.14",
53
- "@versaur/icons": "1.0.0"
57
+ "@versaur/icons": "1.0.0",
58
+ "@versaur/core": "0.0.15"
54
59
  },
55
60
  "scripts": {
56
61
  "build": "vite build",