@ox0/hooks 0.1.0 → 0.2.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.
Files changed (66) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +225 -0
  3. package/dist/index.d.ts +26 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +642 -9
  6. package/dist/use-before-unload-warning.d.ts +6 -0
  7. package/dist/use-before-unload-warning.d.ts.map +1 -0
  8. package/dist/use-breakpoint.d.ts +12 -0
  9. package/dist/use-breakpoint.d.ts.map +1 -0
  10. package/dist/use-container-size.d.ts +18 -0
  11. package/dist/use-container-size.d.ts.map +1 -0
  12. package/dist/use-controllable-state.d.ts +15 -0
  13. package/dist/use-controllable-state.d.ts.map +1 -0
  14. package/dist/use-controllable-state.test.d.ts +2 -0
  15. package/dist/use-controllable-state.test.d.ts.map +1 -0
  16. package/dist/use-copy-to-clipboard.d.ts +6 -0
  17. package/dist/use-copy-to-clipboard.d.ts.map +1 -0
  18. package/dist/use-debounced-value.d.ts +2 -0
  19. package/dist/use-debounced-value.d.ts.map +1 -0
  20. package/dist/use-debounced-value.test.d.ts +2 -0
  21. package/dist/use-debounced-value.test.d.ts.map +1 -0
  22. package/dist/use-deferred-presence.d.ts +15 -0
  23. package/dist/use-deferred-presence.d.ts.map +1 -0
  24. package/dist/use-disclosure.d.ts +8 -0
  25. package/dist/use-disclosure.d.ts.map +1 -0
  26. package/dist/use-disclosure.test.d.ts +2 -0
  27. package/dist/use-disclosure.test.d.ts.map +1 -0
  28. package/dist/use-event-listener.d.ts +5 -0
  29. package/dist/use-event-listener.d.ts.map +1 -0
  30. package/dist/use-hover.d.ts +5 -0
  31. package/dist/use-hover.d.ts.map +1 -0
  32. package/dist/use-interval.d.ts +2 -0
  33. package/dist/use-interval.d.ts.map +1 -0
  34. package/dist/use-key-down.d.ts +9 -0
  35. package/dist/use-key-down.d.ts.map +1 -0
  36. package/dist/use-long-press.d.ts +23 -0
  37. package/dist/use-long-press.d.ts.map +1 -0
  38. package/dist/use-media-query.d.ts +2 -0
  39. package/dist/use-media-query.d.ts.map +1 -0
  40. package/dist/use-media-query.test.d.ts +2 -0
  41. package/dist/use-media-query.test.d.ts.map +1 -0
  42. package/dist/use-navigator-online.d.ts +3 -0
  43. package/dist/use-navigator-online.d.ts.map +1 -0
  44. package/dist/use-now.d.ts +6 -0
  45. package/dist/use-now.d.ts.map +1 -0
  46. package/dist/use-os.d.ts +8 -0
  47. package/dist/use-os.d.ts.map +1 -0
  48. package/dist/use-pointer-coarse.d.ts +3 -0
  49. package/dist/use-pointer-coarse.d.ts.map +1 -0
  50. package/dist/use-prefers-reduced-motion.d.ts +3 -0
  51. package/dist/use-prefers-reduced-motion.d.ts.map +1 -0
  52. package/dist/use-press.d.ts +3 -0
  53. package/dist/use-press.d.ts.map +1 -0
  54. package/dist/use-previous.d.ts +2 -0
  55. package/dist/use-previous.d.ts.map +1 -0
  56. package/dist/use-stored-state.d.ts +23 -0
  57. package/dist/use-stored-state.d.ts.map +1 -0
  58. package/dist/use-stored-state.test.d.ts +2 -0
  59. package/dist/use-stored-state.test.d.ts.map +1 -0
  60. package/dist/use-timeout.d.ts +2 -0
  61. package/dist/use-timeout.d.ts.map +1 -0
  62. package/dist/use-viewport.d.ts +12 -0
  63. package/dist/use-viewport.d.ts.map +1 -0
  64. package/dist/use-window-size.d.ts +7 -0
  65. package/dist/use-window-size.d.ts.map +1 -0
  66. package/package.json +11 -2
@@ -0,0 +1,12 @@
1
+ export type Breakpoint = "mobile" | "tablet" | "desktop";
2
+ export interface BreakpointState {
3
+ breakpoint: Breakpoint;
4
+ isMobile: boolean;
5
+ isTablet: boolean;
6
+ isDesktop: boolean;
7
+ isMobileOrTablet: boolean;
8
+ isTabletOrDesktop: boolean;
9
+ }
10
+ /** Tracks the current responsive breakpoint with boolean helpers. */
11
+ export declare function useBreakpoint(): BreakpointState;
12
+ //# sourceMappingURL=use-breakpoint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-breakpoint.d.ts","sourceRoot":"","sources":["../src/use-breakpoint.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAA;AAExD,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,UAAU,CAAA;IACtB,QAAQ,EAAE,OAAO,CAAA;IACjB,QAAQ,EAAE,OAAO,CAAA;IACjB,SAAS,EAAE,OAAO,CAAA;IAClB,gBAAgB,EAAE,OAAO,CAAA;IACzB,iBAAiB,EAAE,OAAO,CAAA;CAC3B;AAuBD,qEAAqE;AACrE,wBAAgB,aAAa,IAAI,eAAe,CAyB/C"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Measures the content size of a DOM element using ResizeObserver.
3
+ * Returns a [ref, { width, height }] tuple. Attach the ref to the element you
4
+ * want to observe. Both values start at 0 and update on every resize.
5
+ *
6
+ * @example
7
+ * const [ref, { width, height }] = useContainerSize<HTMLDivElement>()
8
+ * const columns = width >= 960 ? 3 : width >= 640 ? 2 : 1
9
+ * return <div ref={ref}>...</div>
10
+ */
11
+ export declare function useContainerSize<T extends HTMLElement = HTMLDivElement>(): [
12
+ React.RefObject<T | null>,
13
+ {
14
+ width: number;
15
+ height: number;
16
+ }
17
+ ];
18
+ //# sourceMappingURL=use-container-size.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-container-size.d.ts","sourceRoot":"","sources":["../src/use-container-size.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,WAAW,GAAG,cAAc,KAAK;IAC1E,KAAK,CAAC,SAAS,CAAC,CAAC,GAAG,IAAI,CAAC;IACzB;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;CAClC,CAqBA"}
@@ -0,0 +1,15 @@
1
+ export interface UseControllableStateOptions<TValue> {
2
+ readonly defaultValue: TValue;
3
+ readonly onChange?: (value: TValue) => void;
4
+ readonly value?: TValue;
5
+ }
6
+ /**
7
+ * Controlled/uncontrolled state bridge.
8
+ *
9
+ * Design decision: in uncontrolled mode, internal state resets to `defaultValue` whenever
10
+ * `defaultValue` changes. This is intentional — it supports controlled→uncontrolled transitions
11
+ * (e.g. when a parent stops passing `value`). Pass a stable primitive as `defaultValue` to avoid
12
+ * surprise resets.
13
+ */
14
+ export declare function useControllableState<TValue>(options: UseControllableStateOptions<TValue>): [TValue, (nextValue: TValue) => void];
15
+ //# sourceMappingURL=use-controllable-state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-controllable-state.d.ts","sourceRoot":"","sources":["../src/use-controllable-state.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,2BAA2B,CAAC,MAAM;IACjD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAC3C,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CACxB;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EACzC,OAAO,EAAE,2BAA2B,CAAC,MAAM,CAAC,GAC3C,CAAC,MAAM,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC,CAoBvC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=use-controllable-state.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-controllable-state.test.d.ts","sourceRoot":"","sources":["../src/use-controllable-state.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ export interface CopyToClipboardState {
2
+ copy: (text: string) => Promise<void>;
3
+ copied: boolean;
4
+ }
5
+ export declare function useCopyToClipboard(resetMs?: number): CopyToClipboardState;
6
+ //# sourceMappingURL=use-copy-to-clipboard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-copy-to-clipboard.d.ts","sourceRoot":"","sources":["../src/use-copy-to-clipboard.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACrC,MAAM,EAAE,OAAO,CAAA;CAChB;AAED,wBAAgB,kBAAkB,CAAC,OAAO,SAAO,GAAG,oBAAoB,CAwBvE"}
@@ -0,0 +1,2 @@
1
+ export declare function useDebouncedValue<TValue>(value: TValue, delay?: number): TValue;
2
+ //# sourceMappingURL=use-debounced-value.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-debounced-value.d.ts","sourceRoot":"","sources":["../src/use-debounced-value.ts"],"names":[],"mappings":"AAEA,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,SAAM,GAAG,MAAM,CAe5E"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=use-debounced-value.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-debounced-value.test.d.ts","sourceRoot":"","sources":["../src/use-debounced-value.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,15 @@
1
+ export type DeferredPresencePhase = "hidden" | "visible" | "exiting";
2
+ export interface DeferredPresenceOptions {
3
+ /** Delay before showing, in ms. */
4
+ delayMs: number;
5
+ /** Duration of exit animation, in ms. */
6
+ exitMs: number;
7
+ /** Minimum time the element stays visible before it can exit, in ms. */
8
+ minimumVisibleMs: number;
9
+ }
10
+ /**
11
+ * Manages show/hide lifecycle with entry delay, minimum visible time, and exit
12
+ * duration — useful for tooltips, toasts, and animated presence patterns.
13
+ */
14
+ export declare function useDeferredPresence(isPresent: boolean, { delayMs, exitMs, minimumVisibleMs }: DeferredPresenceOptions): DeferredPresencePhase;
15
+ //# sourceMappingURL=use-deferred-presence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-deferred-presence.d.ts","sourceRoot":"","sources":["../src/use-deferred-presence.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,qBAAqB,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAA;AAIpE,MAAM,WAAW,uBAAuB;IACtC,mCAAmC;IACnC,OAAO,EAAE,MAAM,CAAA;IACf,yCAAyC;IACzC,MAAM,EAAE,MAAM,CAAA;IACd,wEAAwE;IACxE,gBAAgB,EAAE,MAAM,CAAA;CACzB;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,OAAO,EAClB,EAAE,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,EAAE,uBAAuB,GAC7D,qBAAqB,CA8BvB"}
@@ -0,0 +1,8 @@
1
+ export interface DisclosureState {
2
+ readonly isOpen: boolean;
3
+ readonly onClose: () => void;
4
+ readonly onOpen: () => void;
5
+ readonly onToggle: () => void;
6
+ }
7
+ export declare function useDisclosure(initialOpen?: boolean): DisclosureState;
8
+ //# sourceMappingURL=use-disclosure.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-disclosure.d.ts","sourceRoot":"","sources":["../src/use-disclosure.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,CAAA;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,IAAI,CAAA;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,IAAI,CAAA;CAC9B;AAED,wBAAgB,aAAa,CAAC,WAAW,UAAQ,GAAG,eAAe,CAgBlE"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=use-disclosure.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-disclosure.test.d.ts","sourceRoot":"","sources":["../src/use-disclosure.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ import type { RefObject } from "react";
2
+ type Target = Window | Document | HTMLElement | null;
3
+ export declare function useEventListener<K extends keyof WindowEventMap>(type: K, listener: (event: WindowEventMap[K]) => void, target?: RefObject<HTMLElement | null> | Target): void;
4
+ export {};
5
+ //# sourceMappingURL=use-event-listener.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-event-listener.d.ts","sourceRoot":"","sources":["../src/use-event-listener.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGtC,KAAK,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,WAAW,GAAG,IAAI,CAAA;AAEpD,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,cAAc,EAC7D,IAAI,EAAE,CAAC,EACP,QAAQ,EAAE,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,KAAK,IAAI,EAC5C,MAAM,CAAC,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,MAAM,GAC9C,IAAI,CAcN"}
@@ -0,0 +1,5 @@
1
+ export declare function useHover<T extends HTMLElement = HTMLElement>(): [
2
+ React.RefObject<T | null>,
3
+ boolean
4
+ ];
5
+ //# sourceMappingURL=use-hover.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-hover.d.ts","sourceRoot":"","sources":["../src/use-hover.ts"],"names":[],"mappings":"AAEA,wBAAgB,QAAQ,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,KAAK;IAC/D,KAAK,CAAC,SAAS,CAAC,CAAC,GAAG,IAAI,CAAC;IACzB,OAAO;CACR,CAkBA"}
@@ -0,0 +1,2 @@
1
+ export declare function useInterval(callback: () => void, delay: number | null): void;
2
+ //# sourceMappingURL=use-interval.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-interval.d.ts","sourceRoot":"","sources":["../src/use-interval.ts"],"names":[],"mappings":"AAEA,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAW5E"}
@@ -0,0 +1,9 @@
1
+ export interface KeyDownOptions {
2
+ ctrl?: boolean;
3
+ meta?: boolean;
4
+ shift?: boolean;
5
+ alt?: boolean;
6
+ enabled?: boolean;
7
+ }
8
+ export declare function useKeyDown(key: string, callback: (event: KeyboardEvent) => void, { ctrl, meta, shift, alt, enabled }?: KeyDownOptions): void;
9
+ //# sourceMappingURL=use-key-down.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-key-down.d.ts","sourceRoot":"","sources":["../src/use-key-down.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,UAAU,CACxB,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,EACxC,EAAE,IAAY,EAAE,IAAY,EAAE,KAAa,EAAE,GAAW,EAAE,OAAc,EAAE,GAAE,cAAmB,GAC9F,IAAI,CAmBN"}
@@ -0,0 +1,23 @@
1
+ import type { MouseEvent as ReactMouseEvent, PointerEvent as ReactPointerEvent } from "react";
2
+ export interface UseLongPressOptions {
3
+ /** How long to hold before triggering, in ms. Default: 500. */
4
+ delayMs?: number;
5
+ /** Max pointer movement before the press is cancelled, in px. Default: 8. */
6
+ moveThresholdPx?: number;
7
+ /** When true, no long-press events fire. */
8
+ disabled?: boolean;
9
+ onLongPress: () => void;
10
+ }
11
+ /**
12
+ * Returns pointer event handlers that fire `onLongPress` after the pointer has
13
+ * been held for `delayMs` without moving beyond `moveThresholdPx`. Cancels on
14
+ * pointer up, cancel, or excessive movement. Suppresses the subsequent click.
15
+ */
16
+ export declare function useLongPress({ delayMs, moveThresholdPx, disabled, onLongPress, }: UseLongPressOptions): {
17
+ onPointerDown(event: ReactPointerEvent<HTMLElement>): void;
18
+ onPointerMove(event: ReactPointerEvent<HTMLElement>): void;
19
+ onPointerUp(event: ReactPointerEvent<HTMLElement>): void;
20
+ onPointerCancel(event: ReactPointerEvent<HTMLElement>): void;
21
+ onClickCapture(event: ReactMouseEvent<HTMLElement>): void;
22
+ };
23
+ //# sourceMappingURL=use-long-press.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-long-press.d.ts","sourceRoot":"","sources":["../src/use-long-press.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,IAAI,eAAe,EAAE,YAAY,IAAI,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAG7F,MAAM,WAAW,mBAAmB;IAClC,+DAA+D;IAC/D,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,6EAA6E;IAC7E,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,4CAA4C;IAC5C,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,WAAW,EAAE,MAAM,IAAI,CAAA;CACxB;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,EAC3B,OAAa,EACb,eAAmB,EACnB,QAAgB,EAChB,WAAW,GACZ,EAAE,mBAAmB;yBA4BG,iBAAiB,CAAC,WAAW,CAAC;yBAc9B,iBAAiB,CAAC,WAAW,CAAC;uBAMhC,iBAAiB,CAAC,WAAW,CAAC;2BAI1B,iBAAiB,CAAC,WAAW,CAAC;0BAI/B,eAAe,CAAC,WAAW,CAAC;EAQrD"}
@@ -0,0 +1,2 @@
1
+ export declare function useMediaQuery(query: string): boolean;
2
+ //# sourceMappingURL=use-media-query.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-media-query.d.ts","sourceRoot":"","sources":["../src/use-media-query.ts"],"names":[],"mappings":"AAEA,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAyBpD"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=use-media-query.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-media-query.test.d.ts","sourceRoot":"","sources":["../src/use-media-query.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ /** Returns `true` when the browser reports a network connection. */
2
+ export declare function useNavigatorOnline(): boolean;
3
+ //# sourceMappingURL=use-navigator-online.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-navigator-online.d.ts","sourceRoot":"","sources":["../src/use-navigator-online.ts"],"names":[],"mappings":"AAEA,oEAAoE;AACpE,wBAAgB,kBAAkB,IAAI,OAAO,CAiB5C"}
@@ -0,0 +1,6 @@
1
+ type Options = {
2
+ update?: number | false;
3
+ };
4
+ export declare function useNow({ update }?: Options): number;
5
+ export {};
6
+ //# sourceMappingURL=use-now.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-now.d.ts","sourceRoot":"","sources":["../src/use-now.ts"],"names":[],"mappings":"AAEA,KAAK,OAAO,GAAG;IACb,MAAM,CAAC,EAAE,MAAM,GAAG,KAAK,CAAA;CACxB,CAAA;AAED,wBAAgB,MAAM,CAAC,EAAE,MAAa,EAAE,GAAE,OAAY,GAAG,MAAM,CAU9D"}
@@ -0,0 +1,8 @@
1
+ export type OS = "mac" | "windows" | "linux" | "mobile";
2
+ /**
3
+ * Detects the runtime OS for keyboard shortcut and UI adaptation.
4
+ * For layout decisions use `useBreakpoint` instead.
5
+ * Pass `override` to force a value (tests, playground demos).
6
+ */
7
+ export declare function useOS(override?: OS): OS;
8
+ //# sourceMappingURL=use-os.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-os.d.ts","sourceRoot":"","sources":["../src/use-os.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,EAAE,GAAG,KAAK,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,CAAA;AAcvD;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,EAAE,CAEvC"}
@@ -0,0 +1,3 @@
1
+ /** Returns `true` when the primary pointer device is coarse (touch screen). */
2
+ export declare function usePointerCoarse(): boolean;
3
+ //# sourceMappingURL=use-pointer-coarse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-pointer-coarse.d.ts","sourceRoot":"","sources":["../src/use-pointer-coarse.ts"],"names":[],"mappings":"AAEA,+EAA+E;AAC/E,wBAAgB,gBAAgB,IAAI,OAAO,CAE1C"}
@@ -0,0 +1,3 @@
1
+ /** Returns `true` when the user has requested reduced motion. */
2
+ export declare function usePrefersReducedMotion(): boolean;
3
+ //# sourceMappingURL=use-prefers-reduced-motion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-prefers-reduced-motion.d.ts","sourceRoot":"","sources":["../src/use-prefers-reduced-motion.ts"],"names":[],"mappings":"AAEA,iEAAiE;AACjE,wBAAgB,uBAAuB,IAAI,OAAO,CAEjD"}
@@ -0,0 +1,3 @@
1
+ export { isFocusVisible, usePress } from "@react-aria/interactions";
2
+ export type { PressEvent, PressHookProps, PressProps, PressResult } from "@react-aria/interactions";
3
+ //# sourceMappingURL=use-press.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-press.d.ts","sourceRoot":"","sources":["../src/use-press.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AACnE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare function usePrevious<T>(value: T): T | undefined;
2
+ //# sourceMappingURL=use-previous.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-previous.d.ts","sourceRoot":"","sources":["../src/use-previous.ts"],"names":[],"mappings":"AAEA,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS,CAMtD"}
@@ -0,0 +1,23 @@
1
+ import type { ReactNode } from "react";
2
+ /** Anything with a `.parse` method — Zod schemas satisfy this directly. */
3
+ export type Parser<T> = {
4
+ parse: (value: unknown) => T;
5
+ };
6
+ export type StoredStateOptions<T> = {
7
+ defaultValue: T;
8
+ version?: number;
9
+ migrate?: (value: unknown, fromVersion: number) => T;
10
+ };
11
+ export declare function StorageProvider({ scope, children, }: {
12
+ scope: string | null;
13
+ children: ReactNode;
14
+ }): import("react").FunctionComponentElement<import("react").ProviderProps<string | null | undefined>>;
15
+ /** localStorage, tab-private. */
16
+ export declare function usePersistentState<T>(key: string, parser: Parser<T>, options: StoredStateOptions<T>): [T, (next: T | ((prev: T) => T)) => void];
17
+ /** localStorage, shared across tabs. */
18
+ export declare function usePersistentSharedState<T>(key: string, parser: Parser<T>, options: StoredStateOptions<T>): [T, (next: T | ((prev: T) => T)) => void];
19
+ /** sessionStorage, tab-private. */
20
+ export declare function useSessionState<T>(key: string, parser: Parser<T>, options: StoredStateOptions<T>): [T, (next: T | ((prev: T) => T)) => void];
21
+ /** sessionStorage, shared within tab. */
22
+ export declare function useSessionSharedState<T>(key: string, parser: Parser<T>, options: StoredStateOptions<T>): [T, (next: T | ((prev: T) => T)) => void];
23
+ //# sourceMappingURL=use-stored-state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-stored-state.d.ts","sourceRoot":"","sources":["../src/use-stored-state.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,2EAA2E;AAC3E,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI;IAAE,KAAK,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,CAAC,CAAA;CAAE,CAAA;AAExD,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAAI;IAClC,YAAY,EAAE,CAAC,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,KAAK,CAAC,CAAA;CACrD,CAAA;AA0HD,wBAAgB,eAAe,CAAC,EAC9B,KAAK,EACL,QAAQ,GACT,EAAE;IACD,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,QAAQ,EAAE,SAAS,CAAA;CACpB,sGAEA;AAuID,iCAAiC;AACjC,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EACjB,OAAO,EAAE,kBAAkB,CAAC,CAAC,CAAC,uCAzHO,IAAI,EA4H1C;AAED,wCAAwC;AACxC,wBAAgB,wBAAwB,CAAC,CAAC,EACxC,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EACjB,OAAO,EAAE,kBAAkB,CAAC,CAAC,CAAC,uCAlIO,IAAI,EAqI1C;AAED,mCAAmC;AACnC,wBAAgB,eAAe,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,kBAAkB,CAAC,CAAC,CAAC,uCAxI1D,IAAI,EA0I1C;AAED,yCAAyC;AACzC,wBAAgB,qBAAqB,CAAC,CAAC,EACrC,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EACjB,OAAO,EAAE,kBAAkB,CAAC,CAAC,CAAC,uCAhJO,IAAI,EAmJ1C"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=use-stored-state.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-stored-state.test.d.ts","sourceRoot":"","sources":["../src/use-stored-state.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export declare function useTimeout(callback: () => void, delay: number | null): void;
2
+ //# sourceMappingURL=use-timeout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-timeout.d.ts","sourceRoot":"","sources":["../src/use-timeout.ts"],"names":[],"mappings":"AAEA,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAW3E"}
@@ -0,0 +1,12 @@
1
+ export interface ViewportState {
2
+ /** Height of the visual viewport (shrinks when the soft keyboard opens). */
3
+ visualViewportHeight: number;
4
+ /** True when the on-screen keyboard is likely open (mobile). */
5
+ keyboardOpen: boolean;
6
+ }
7
+ /**
8
+ * Tracks visual viewport height and whether the on-screen keyboard is open.
9
+ * Useful for mobile layouts that must avoid the keyboard.
10
+ */
11
+ export declare function useViewport(): ViewportState;
12
+ //# sourceMappingURL=use-viewport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-viewport.d.ts","sourceRoot":"","sources":["../src/use-viewport.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,aAAa;IAC5B,4EAA4E;IAC5E,oBAAoB,EAAE,MAAM,CAAA;IAC5B,gEAAgE;IAChE,YAAY,EAAE,OAAO,CAAA;CACtB;AAWD;;;GAGG;AACH,wBAAgB,WAAW,IAAI,aAAa,CA2B3C"}
@@ -0,0 +1,7 @@
1
+ export interface WindowSize {
2
+ width: number;
3
+ height: number;
4
+ }
5
+ /** Tracks the layout viewport dimensions (window.innerWidth / window.innerHeight). */
6
+ export declare function useWindowSize(): WindowSize;
7
+ //# sourceMappingURL=use-window-size.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-window-size.d.ts","sourceRoot":"","sources":["../src/use-window-size.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CACf;AAOD,sFAAsF;AACtF,wBAAgB,aAAa,IAAI,UAAU,CAmB1C"}
package/package.json CHANGED
@@ -1,12 +1,18 @@
1
1
  {
2
2
  "name": "@ox0/hooks",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "https://github.com/esturcke/ox0-platform.git",
7
+ "directory": "packages/hooks"
8
+ },
4
9
  "files": [
5
10
  "dist"
6
11
  ],
7
12
  "type": "module",
8
13
  "exports": {
9
14
  ".": {
15
+ "source": "./src/index.ts",
10
16
  "import": "./dist/index.js",
11
17
  "types": "./dist/index.d.ts"
12
18
  }
@@ -15,10 +21,13 @@
15
21
  "access": "public"
16
22
  },
17
23
  "dependencies": {
24
+ "@react-aria/interactions": "^3.28.1"
25
+ },
26
+ "peerDependencies": {
18
27
  "react": "^19.0.0"
19
28
  },
20
29
  "scripts": {
21
- "build": "rslib build -c ../../rslib.config.ts",
30
+ "build": "rslib build -c ../../rslib.config.ts && tsc --build --force tsconfig.build.json",
22
31
  "typecheck": "tsc -p tsconfig.json",
23
32
  "lint": "oxlint .",
24
33
  "test": "vitest run"