@oneplatformdev/hooks
Advanced tools
| ## 0.1.0-12 (2025-09-15) | ||
| This was a version bump only for @oneplatformdev/hooks to align it with other projects, there were no code changes. | ||
| ## 0.1.0-11 (2025-09-15) | ||
| This was a version bump only for @oneplatformdev/hooks to align it with other projects, there were no code changes. | ||
| ## 0.1.0-10 (2025-09-11) | ||
| This was a version bump only for @oneplatformdev/hooks to align it with other projects, there were no code changes. | ||
| ## 0.1.0-9 (2025-09-11) | ||
| This was a version bump only for @oneplatformdev/hooks to align it with other projects, there were no code changes. | ||
| ## 0.1.0-8 (2025-09-11) | ||
| This was a version bump only for @oneplatformdev/hooks to align it with other projects, there were no code changes. | ||
| ## 0.1.0-7 (2025-09-11) | ||
| This was a version bump only for @oneplatformdev/hooks to align it with other projects, there were no code changes. | ||
| ## 0.1.0-6 (2025-09-11) | ||
| This was a version bump only for @oneplatformdev/hooks to align it with other projects, there were no code changes. | ||
| ## 0.1.0-5 (2025-09-11) | ||
| This was a version bump only for @oneplatformdev/hooks to align it with other projects, there were no code changes. | ||
| ## 0.1.0-4 (2025-09-11) | ||
| This was a version bump only for @oneplatformdev/hooks to align it with other projects, there were no code changes. |
| export * from './useBoolean'; | ||
| export * from './useClickAnyWhere'; | ||
| export * from './useCopyToClipboard'; | ||
| export * from './useCountdown'; | ||
| export * from './useCounter'; | ||
| export * from './useDarkMode'; | ||
| export * from './useDebounceCallback'; | ||
| export * from './useDebounceValue'; | ||
| export * from './useDocumentTitle'; | ||
| export * from './useEventCallback'; | ||
| export * from './useEventListener'; | ||
| export * from './useHover'; | ||
| export * from './useIntersectionObserver'; | ||
| export * from './useInterval'; | ||
| export * from './useIsClient'; | ||
| export * from './useIsMobile'; | ||
| export * from './useIsMounted'; | ||
| export * from './useIsomorphicLayoutEffect'; | ||
| export * from './useLocalStorage'; | ||
| export * from './useLockBody'; | ||
| export * from './useMap'; | ||
| export * from './useMediaQuery'; | ||
| export * from './useOnClickOutside'; | ||
| export * from './useReadLocalStorage'; | ||
| export * from './useResizeObserver'; | ||
| export * from './useScreen'; | ||
| export * from './useScript'; | ||
| export * from './useScrollLock'; | ||
| export * from './useSessionStorage'; | ||
| export * from './useStep'; | ||
| export * from './useTernaryDarkMode'; | ||
| export * from './useTimeout'; | ||
| export * from './useToggle'; | ||
| export * from './useUnmount'; | ||
| export * from './useWindowSize'; | ||
| export * from './useQueryString'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,WAAW,CAAC;AAC1B,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC"} |
| import { useBoolean as r } from "./useBoolean/useBoolean.js"; | ||
| import { useClickAnyWhere as u } from "./useClickAnyWhere/useClickAnyWhere.js"; | ||
| import { useCopyToClipboard as p } from "./useCopyToClipboard/useCopyToClipboard.js"; | ||
| import { useCountdown as f } from "./useCountdown/useCountdown.js"; | ||
| import { useCounter as n } from "./useCounter/useCounter.js"; | ||
| import { useDarkMode as i } from "./useDarkMode/useDarkMode.js"; | ||
| import { useDebounceCallback as c } from "./useDebounceCallback/useDebounceCallback.js"; | ||
| import { useDebounceValue as S } from "./useDebounceValue/useDebounceValue.js"; | ||
| import { useDocumentTitle as b } from "./useDocumentTitle/useDocumentTitle.js"; | ||
| import { useEventCallback as y } from "./useEventCallback/useEventCallback.js"; | ||
| import { useEventListener as v } from "./useEventListener/useEventListener.js"; | ||
| import { useHover as L } from "./useHover/useHover.js"; | ||
| import { useIntersectionObserver as D } from "./useIntersectionObserver/useIntersectionObserver.js"; | ||
| import { useInterval as O } from "./useInterval/useInterval.js"; | ||
| import { useIsClient as h } from "./useIsClient/useIsClient.js"; | ||
| import { useIsMobile as z } from "./useIsMobile/useIsMobile.js"; | ||
| import { useIsMounted as Q } from "./useIsMounted/useIsMounted.js"; | ||
| import { useIsomorphicLayoutEffect as W } from "./useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js"; | ||
| import { useLocalStorage as H } from "./useLocalStorage/useLocalStorage.js"; | ||
| import { useLockBody as V } from "./useLockBody/useLockBody.js"; | ||
| import { useMap as q } from "./useMap/useMap.js"; | ||
| import { useMediaQuery as G } from "./useMediaQuery/useMediaQuery.js"; | ||
| import { useOnClickOutside as K } from "./useOnClickOutside/useOnClickOutside.js"; | ||
| import { useReadLocalStorage as P } from "./useReadLocalStorage/useReadLocalStorage.js"; | ||
| import { useResizeObserver as Y } from "./useResizeObserver/useResizeObserver.js"; | ||
| import { useScreen as _ } from "./useScreen/useScreen.js"; | ||
| import { useScript as ee } from "./useScript/useScript.js"; | ||
| import { useScrollLock as re } from "./useScrollLock/useScrollLock.js"; | ||
| import { useSessionStorage as ue } from "./useSessionStorage/useSessionStorage.js"; | ||
| import { useStep as pe } from "./useStep/useStep.js"; | ||
| import { useTernaryDarkMode as fe } from "./useTernaryDarkMode/useTernaryDarkMode.js"; | ||
| import { useTimeout as ne } from "./useTimeout/useTimeout.js"; | ||
| import { useToggle as ie } from "./useToggle/useToggle.js"; | ||
| import { useUnmount as ce } from "./useUnmount/useUnmount.js"; | ||
| import { useWindowSize as Se } from "./useWindowSize/useWindowSize.js"; | ||
| import { useQueryString as be } from "./useQueryString/useQueryString.js"; | ||
| export { | ||
| r as useBoolean, | ||
| u as useClickAnyWhere, | ||
| p as useCopyToClipboard, | ||
| f as useCountdown, | ||
| n as useCounter, | ||
| i as useDarkMode, | ||
| c as useDebounceCallback, | ||
| S as useDebounceValue, | ||
| b as useDocumentTitle, | ||
| y as useEventCallback, | ||
| v as useEventListener, | ||
| L as useHover, | ||
| D as useIntersectionObserver, | ||
| O as useInterval, | ||
| h as useIsClient, | ||
| z as useIsMobile, | ||
| Q as useIsMounted, | ||
| W as useIsomorphicLayoutEffect, | ||
| H as useLocalStorage, | ||
| V as useLockBody, | ||
| q as useMap, | ||
| G as useMediaQuery, | ||
| K as useOnClickOutside, | ||
| be as useQueryString, | ||
| P as useReadLocalStorage, | ||
| Y as useResizeObserver, | ||
| _ as useScreen, | ||
| ee as useScript, | ||
| re as useScrollLock, | ||
| ue as useSessionStorage, | ||
| pe as useStep, | ||
| fe as useTernaryDarkMode, | ||
| ne as useTimeout, | ||
| ie as useToggle, | ||
| ce as useUnmount, | ||
| Se as useWindowSize | ||
| }; |
+21
| The MIT License (MIT) | ||
| Copyright (c) 2025 Oleh Maksimenko | ||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. |
| { | ||
| "name": "@oneplatformdev/hooks", | ||
| "version": "0.1.0-12", | ||
| "description": "React hook library", | ||
| "author": "One Platform Development Team", | ||
| "keywords": [ | ||
| "react", | ||
| "oneplatform", | ||
| "hooks", | ||
| "typescript" | ||
| ], | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/oneplatformdev/core.git", | ||
| "directory": "packages/hooks" | ||
| }, | ||
| "bugs": { | ||
| "url": "https://github.com/oneplatformdev/core/issues" | ||
| }, | ||
| "homepage": "private package", | ||
| "private": false, | ||
| "license": "MIT", | ||
| "type": "module", | ||
| "main": "./index.js", | ||
| "module": "./index.js", | ||
| "types": "./index.d.ts", | ||
| "exports": { | ||
| "./package.json": "./package.json", | ||
| ".": { | ||
| "@oneplatformdev/source": "./src/index.ts", | ||
| "types": "./index.d.ts", | ||
| "import": "./index.js", | ||
| "default": "./index.js" | ||
| }, | ||
| "./*": { | ||
| "types": "./*.d.ts", | ||
| "import": "./*.js", | ||
| "default": "./*.js" | ||
| } | ||
| }, | ||
| "files": [ | ||
| "dist", | ||
| "README.md", | ||
| "LICENSE", | ||
| "!**/*.tsbuildinfo" | ||
| ], | ||
| "dependencies": { | ||
| "lodash.debounce": "^4.0.8" | ||
| }, | ||
| "peerDependencies": { | ||
| "react": ">=18", | ||
| "react-dom": ">=18", | ||
| "@types/react": ">=18", | ||
| "@types/lodash.debounce": "^4.0.9" | ||
| }, | ||
| "peerDependenciesMeta": { | ||
| "@types/react": { | ||
| "optional": true | ||
| }, | ||
| "@types/react-dom": { | ||
| "optional": true | ||
| }, | ||
| "@types/lodash.debounce": { | ||
| "optional": true | ||
| } | ||
| } | ||
| } |
| # @oneplatformdev/hooks | ||
| This library was generated with [Nx](https://nx.dev). | ||
| ## Running unit tests | ||
| Run `nx test @oneplatformdev/hooks` to execute the unit tests via [Vitest](https://vitest.dev/). |
| export * from './useBoolean'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useBoolean/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA"} |
| import { useBoolean as r } from "./useBoolean.js"; | ||
| export { | ||
| r as useBoolean | ||
| }; |
| import { Dispatch, SetStateAction } from 'react'; | ||
| /** The useBoolean return type. */ | ||
| type UseBooleanReturn = { | ||
| /** The current boolean state value. */ | ||
| value: boolean; | ||
| /** Function to set the boolean state directly. */ | ||
| setValue: Dispatch<SetStateAction<boolean>>; | ||
| /** Function to set the boolean state to `true`. */ | ||
| setTrue: () => void; | ||
| /** Function to set the boolean state to `false`. */ | ||
| setFalse: () => void; | ||
| /** Function to toggle the boolean state. */ | ||
| toggle: () => void; | ||
| }; | ||
| /** | ||
| * Custom hook that handles boolean state with useful utility functions. | ||
| * @param {boolean} [defaultValue] - The initial value for the boolean state (default is `false`). | ||
| * @returns {UseBooleanReturn} An object containing the boolean state value and utility functions to manipulate the state. | ||
| * @throws Will throw an error if `defaultValue` is an invalid boolean value. | ||
| * @public | ||
| * @see [Documentation](https://usehooks-ts.com/react-hook/use-boolean) | ||
| * @example | ||
| * ```tsx | ||
| * const { value, setTrue, setFalse, toggle } = useBoolean(true); | ||
| * ``` | ||
| */ | ||
| export declare function useBoolean(defaultValue?: boolean): UseBooleanReturn; | ||
| export {}; | ||
| //# sourceMappingURL=useBoolean.d.ts.map |
| {"version":3,"file":"useBoolean.d.ts","sourceRoot":"","sources":["../../src/useBoolean/useBoolean.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAErD,kCAAkC;AAClC,KAAK,gBAAgB,GAAG;IACtB,uCAAuC;IACvC,KAAK,EAAE,OAAO,CAAA;IACd,kDAAkD;IAClD,QAAQ,EAAE,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAA;IAC3C,mDAAmD;IACnD,OAAO,EAAE,MAAM,IAAI,CAAA;IACnB,oDAAoD;IACpD,QAAQ,EAAE,MAAM,IAAI,CAAA;IACpB,4CAA4C;IAC5C,MAAM,EAAE,MAAM,IAAI,CAAA;CACnB,CAAA;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CAAC,YAAY,UAAQ,GAAG,gBAAgB,CAmBjE"} |
| import { useState as n, useCallback as t } from "react"; | ||
| function c(o = !1) { | ||
| if (typeof o != "boolean") | ||
| throw new Error("defaultValue must be `true` or `false`"); | ||
| const [s, e] = n(o), r = t(() => { | ||
| e(!0); | ||
| }, []), a = t(() => { | ||
| e(!1); | ||
| }, []), l = t(() => { | ||
| e((u) => !u); | ||
| }, []); | ||
| return { value: s, setValue: e, setTrue: r, setFalse: a, toggle: l }; | ||
| } | ||
| export { | ||
| c as useBoolean | ||
| }; |
| export * from './useClickAnyWhere'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useClickAnyWhere/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA"} |
| import { useClickAnyWhere as o } from "./useClickAnyWhere.js"; | ||
| export { | ||
| o as useClickAnyWhere | ||
| }; |
| /** | ||
| * Custom hook that handles click events anywhere on the document. | ||
| * @param {Function} handler - The function to be called when a click event is detected anywhere on the document. | ||
| * @public | ||
| * @see [Documentation](https://usehooks-ts.com/react-hook/use-click-any-where) | ||
| * @example | ||
| * ```tsx | ||
| * const handleClick = (event) => { | ||
| * console.log('Document clicked!', event); | ||
| * }; | ||
| * | ||
| * // Attach click event handler to document | ||
| * useClickAnywhere(handleClick); | ||
| * ``` | ||
| */ | ||
| export declare function useClickAnyWhere(handler: (event: MouseEvent) => void): void; | ||
| //# sourceMappingURL=useClickAnyWhere.d.ts.map |
| {"version":3,"file":"useClickAnyWhere.d.ts","sourceRoot":"","sources":["../../src/useClickAnyWhere/useClickAnyWhere.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,QAIpE"} |
| import { useEventListener as n } from "../useEventListener/useEventListener.js"; | ||
| function t(e) { | ||
| n("click", (i) => { | ||
| e(i); | ||
| }); | ||
| } | ||
| export { | ||
| t as useClickAnyWhere | ||
| }; |
| export * from './useCopyToClipboard'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useCopyToClipboard/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA"} |
| import { useCopyToClipboard as r } from "./useCopyToClipboard.js"; | ||
| export { | ||
| r as useCopyToClipboard | ||
| }; |
| /** | ||
| * The copied text as `string` or `null` if nothing has been copied yet. | ||
| */ | ||
| type CopiedValue = string | null; | ||
| /** | ||
| * Function to copy text to the clipboard. | ||
| * @param text - The text to copy to the clipboard. | ||
| * @returns {Promise<boolean>} A promise that resolves to `true` if the text was copied successfully, or `false` otherwise. | ||
| */ | ||
| type CopyFn = (text: string) => Promise<boolean>; | ||
| /** | ||
| * Custom hook that copies text to the clipboard using the [`Clipboard API`](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard_API). | ||
| * @returns {[CopiedValue, CopyFn]} An tuple containing the copied text and a function to copy text to the clipboard. | ||
| * @public | ||
| * @see [Documentation](https://usehooks-ts.com/react-hook/use-copy-to-clipboard) | ||
| * @example | ||
| * ```tsx | ||
| * const [copiedText, copyToClipboard] = useCopyToClipboard(); | ||
| * const textToCopy = 'Hello, world!'; | ||
| * | ||
| * // Attempt to copy text to the clipboard | ||
| * copyToClipboard(textToCopy) | ||
| * .then(success => { | ||
| * if (success) { | ||
| * console.log(`Text "${textToCopy}" copied to clipboard successfully.`); | ||
| * } else { | ||
| * console.error('Failed to copy text to clipboard.'); | ||
| * } | ||
| * }); | ||
| * ``` | ||
| */ | ||
| export declare function useCopyToClipboard(): [CopiedValue, CopyFn]; | ||
| export {}; | ||
| //# sourceMappingURL=useCopyToClipboard.d.ts.map |
| {"version":3,"file":"useCopyToClipboard.d.ts","sourceRoot":"","sources":["../../src/useCopyToClipboard/useCopyToClipboard.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,KAAK,WAAW,GAAG,MAAM,GAAG,IAAI,CAAA;AAEhC;;;;GAIG;AACH,KAAK,MAAM,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;AAEhD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,kBAAkB,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,CAsB1D"} |
| import { useState as n, useCallback as l } from "react"; | ||
| function c() { | ||
| const [e, r] = n(null), t = l(async (o) => { | ||
| if (!navigator?.clipboard) | ||
| return console.warn("Clipboard not supported"), !1; | ||
| try { | ||
| return await navigator.clipboard.writeText(o), r(o), !0; | ||
| } catch (a) { | ||
| return console.warn("Copy failed", a), r(null), !1; | ||
| } | ||
| }, []); | ||
| return [e, t]; | ||
| } | ||
| export { | ||
| c as useCopyToClipboard | ||
| }; |
| export * from './useCountdown'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useCountdown/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA"} |
| import { useCountdown as n } from "./useCountdown.js"; | ||
| export { | ||
| n as useCountdown | ||
| }; |
| /** The countdown's options. */ | ||
| type CountdownOptions = { | ||
| /** The countdown's starting number, initial value of the returned number. */ | ||
| countStart: number; | ||
| /** | ||
| * The countdown's interval, in milliseconds. | ||
| * @default 1000 | ||
| */ | ||
| intervalMs?: number; | ||
| /** | ||
| * True if the countdown is increment. | ||
| * @default false | ||
| */ | ||
| isIncrement?: boolean; | ||
| /** | ||
| * The countdown's stopping number. Pass `-Infinity` to decrease forever. | ||
| * @default 0 | ||
| */ | ||
| countStop?: number; | ||
| }; | ||
| /** The countdown's controllers. */ | ||
| type CountdownControllers = { | ||
| /** Start the countdown. */ | ||
| startCountdown: () => void; | ||
| /** Stop the countdown. */ | ||
| stopCountdown: () => void; | ||
| /** Reset the countdown. */ | ||
| resetCountdown: () => void; | ||
| }; | ||
| /** | ||
| * Custom hook that manages countdown. | ||
| * @param {CountdownOptions} countdownOptions - The countdown's options. | ||
| * @returns {[number, CountdownControllers]} An array containing the countdown's count and its controllers. | ||
| * @public | ||
| * @see [Documentation](https://usehooks-ts.com/react-hook/use-countdown) | ||
| * @example | ||
| * ```tsx | ||
| * const [counter, { start, stop, reset }] = useCountdown({ | ||
| * countStart: 10, | ||
| * intervalMs: 1000, | ||
| * isIncrement: false, | ||
| * }); | ||
| * ``` | ||
| */ | ||
| export declare function useCountdown({ countStart, countStop, intervalMs, isIncrement, }: CountdownOptions): [number, CountdownControllers]; | ||
| export {}; | ||
| //# sourceMappingURL=useCountdown.d.ts.map |
| {"version":3,"file":"useCountdown.d.ts","sourceRoot":"","sources":["../../src/useCountdown/useCountdown.ts"],"names":[],"mappings":"AAMA,+BAA+B;AAC/B,KAAK,gBAAgB,GAAG;IACtB,6EAA6E;IAC7E,UAAU,EAAE,MAAM,CAAA;IAElB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;IAErB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,mCAAmC;AACnC,KAAK,oBAAoB,GAAG;IAC1B,2BAA2B;IAC3B,cAAc,EAAE,MAAM,IAAI,CAAA;IAC1B,0BAA0B;IAC1B,aAAa,EAAE,MAAM,IAAI,CAAA;IACzB,2BAA2B;IAC3B,cAAc,EAAE,MAAM,IAAI,CAAA;CAC3B,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,YAAY,CAAC,EAC3B,UAAU,EACV,SAAa,EACb,UAAiB,EACjB,WAAmB,GACpB,EAAE,gBAAgB,GAAG,CAAC,MAAM,EAAE,oBAAoB,CAAC,CA0CnD"} |
| import { useCallback as l } from "react"; | ||
| import { useBoolean as d } from "../useBoolean/useBoolean.js"; | ||
| import { useCounter as w } from "../useCounter/useCounter.js"; | ||
| import { useInterval as p } from "../useInterval/useInterval.js"; | ||
| function x({ | ||
| countStart: a, | ||
| countStop: n = 0, | ||
| intervalMs: c = 1e3, | ||
| isIncrement: t = !1 | ||
| }) { | ||
| const { | ||
| count: o, | ||
| increment: r, | ||
| decrement: s, | ||
| reset: u | ||
| } = w(a), { | ||
| value: f, | ||
| setTrue: i, | ||
| setFalse: e | ||
| } = d(!1), m = l(() => { | ||
| e(), u(); | ||
| }, [e, u]), C = l(() => { | ||
| if (o === n) { | ||
| e(); | ||
| return; | ||
| } | ||
| t ? r() : s(); | ||
| }, [o, n, s, r, t, e]); | ||
| return p(C, f ? c : null), [o, { startCountdown: i, stopCountdown: e, resetCountdown: m }]; | ||
| } | ||
| export { | ||
| x as useCountdown | ||
| }; |
| export * from './useCounter'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useCounter/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA"} |
| import { useCounter as r } from "./useCounter.js"; | ||
| export { | ||
| r as useCounter | ||
| }; |
| import { Dispatch, SetStateAction } from 'react'; | ||
| /** The hook return type. */ | ||
| type UseCounterReturn = { | ||
| /** The current count value. */ | ||
| count: number; | ||
| /** Function to increment the counter by 1. */ | ||
| increment: () => void; | ||
| /** Function to decrement the counter by 1. */ | ||
| decrement: () => void; | ||
| /** Function to reset the counter to its initial value. */ | ||
| reset: () => void; | ||
| /** Function to set a specific value to the counter. */ | ||
| setCount: Dispatch<SetStateAction<number>>; | ||
| }; | ||
| /** | ||
| * Custom hook that manages a counter with increment, decrement, reset, and setCount functionalities. | ||
| * @param {number} [initialValue] - The initial value for the counter. | ||
| * @returns {UseCounterReturn} An object containing the current count and functions to interact with the counter. | ||
| * @public | ||
| * @see [Documentation](https://usehooks-ts.com/react-hook/use-counter) | ||
| * @example | ||
| * ```tsx | ||
| * const { count, increment, decrement, reset, setCount } = useCounter(5); | ||
| * ``` | ||
| */ | ||
| export declare function useCounter(initialValue?: number): UseCounterReturn; | ||
| export {}; | ||
| //# sourceMappingURL=useCounter.d.ts.map |
| {"version":3,"file":"useCounter.d.ts","sourceRoot":"","sources":["../../src/useCounter/useCounter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAErD,4BAA4B;AAC5B,KAAK,gBAAgB,GAAG;IACtB,+BAA+B;IAC/B,KAAK,EAAE,MAAM,CAAA;IACb,8CAA8C;IAC9C,SAAS,EAAE,MAAM,IAAI,CAAA;IACrB,8CAA8C;IAC9C,SAAS,EAAE,MAAM,IAAI,CAAA;IACrB,0DAA0D;IAC1D,KAAK,EAAE,MAAM,IAAI,CAAA;IACjB,uDAAuD;IACvD,QAAQ,EAAE,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAA;CAC3C,CAAA;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,gBAAgB,CAsBlE"} |
| import { useState as m, useCallback as o } from "react"; | ||
| function f(e) { | ||
| const [c, t] = m(e ?? 0), r = o(() => { | ||
| t((n) => n + 1); | ||
| }, []), s = o(() => { | ||
| t((n) => n - 1); | ||
| }, []), u = o(() => { | ||
| t(e ?? 0); | ||
| }, [e]); | ||
| return { | ||
| count: c, | ||
| increment: r, | ||
| decrement: s, | ||
| reset: u, | ||
| setCount: t | ||
| }; | ||
| } | ||
| export { | ||
| f as useCounter | ||
| }; |
| export * from './useDarkMode'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useDarkMode/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA"} |
| import { useDarkMode as r } from "./useDarkMode.js"; | ||
| export { | ||
| r as useDarkMode | ||
| }; |
| /** The hook options. */ | ||
| type DarkModeOptions = { | ||
| /** | ||
| * The initial value of the dark mode. | ||
| * @default false | ||
| */ | ||
| defaultValue?: boolean; | ||
| /** | ||
| * The key to use in the local storage. | ||
| * @default 'usehooks-ts-dark-mode' | ||
| */ | ||
| localStorageKey?: string; | ||
| /** | ||
| * If `true` (default), the hook will initialize reading `localStorage`. | ||
| * In SSR, you should set it to `false`, returning the `defaultValue` or `false` initially. | ||
| * @default true | ||
| */ | ||
| initializeWithValue?: boolean; | ||
| }; | ||
| /** The hook return type. */ | ||
| type DarkModeReturn = { | ||
| /** The current state of the dark mode. */ | ||
| isDarkMode: boolean; | ||
| /** Function to toggle the dark mode. */ | ||
| toggle: () => void; | ||
| /** Function to enable the dark mode. */ | ||
| enable: () => void; | ||
| /** Function to disable the dark mode. */ | ||
| disable: () => void; | ||
| /** Function to set a specific value to the dark mode. */ | ||
| set: (value: boolean) => void; | ||
| }; | ||
| /** | ||
| * Custom hook that returns the current state of the dark mode. | ||
| * @param {?DarkModeOptions} [options] - The initial value of the dark mode, default `false`. | ||
| * @returns {DarkModeReturn} An object containing the dark mode's state and its controllers. | ||
| * @public | ||
| * @see [Documentation](https://usehooks-ts.com/react-hook/use-dark-mode) | ||
| * @example | ||
| * ```tsx | ||
| * const { isDarkMode, toggle, enable, disable, set } = useDarkMode({ defaultValue: true }); | ||
| * ``` | ||
| */ | ||
| export declare function useDarkMode(options?: DarkModeOptions): DarkModeReturn; | ||
| export {}; | ||
| //# sourceMappingURL=useDarkMode.d.ts.map |
| {"version":3,"file":"useDarkMode.d.ts","sourceRoot":"","sources":["../../src/useDarkMode/useDarkMode.ts"],"names":[],"mappings":"AAOA,wBAAwB;AACxB,KAAK,eAAe,GAAG;IACrB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAA;CAC9B,CAAA;AAED,4BAA4B;AAC5B,KAAK,cAAc,GAAG;IACpB,0CAA0C;IAC1C,UAAU,EAAE,OAAO,CAAA;IACnB,wCAAwC;IACxC,MAAM,EAAE,MAAM,IAAI,CAAA;IAClB,wCAAwC;IACxC,MAAM,EAAE,MAAM,IAAI,CAAA;IAClB,yCAAyC;IACzC,OAAO,EAAE,MAAM,IAAI,CAAA;IACnB,yDAAyD;IACzD,GAAG,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;CAC9B,CAAA;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,OAAO,GAAE,eAAoB,GAAG,cAAc,CAuCzE"} |
| import { useIsomorphicLayoutEffect as l } from "../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js"; | ||
| import { useLocalStorage as c } from "../useLocalStorage/useLocalStorage.js"; | ||
| import { useMediaQuery as f } from "../useMediaQuery/useMediaQuery.js"; | ||
| const n = "(prefers-color-scheme: dark)", d = "usehooks-ts-dark-mode"; | ||
| function E(i = {}) { | ||
| const { | ||
| defaultValue: t, | ||
| localStorageKey: u = d, | ||
| initializeWithValue: s = !0 | ||
| } = i, o = f(n, { | ||
| initializeWithValue: s, | ||
| defaultValue: t | ||
| }), [a, e] = c( | ||
| u, | ||
| t ?? o ?? !1, | ||
| { initializeWithValue: s } | ||
| ); | ||
| return l(() => { | ||
| o !== a && e(o); | ||
| }, [o]), { | ||
| isDarkMode: a, | ||
| toggle: () => { | ||
| e((r) => !r); | ||
| }, | ||
| enable: () => { | ||
| e(!0); | ||
| }, | ||
| disable: () => { | ||
| e(!1); | ||
| }, | ||
| set: (r) => { | ||
| e(r); | ||
| } | ||
| }; | ||
| } | ||
| export { | ||
| E as useDarkMode | ||
| }; |
| export * from './useDebounceCallback'; | ||
| export { useDebounceCallback as default } from './useDebounceCallback'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useDebounceCallback/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,OAAO,EAAC,mBAAmB,IAAI,OAAO,EAAE,MAAM,uBAAuB,CAAA"} |
| import { useDebounceCallback as l, useDebounceCallback as u } from "./useDebounceCallback.js"; | ||
| export { | ||
| l as default, | ||
| u as useDebounceCallback | ||
| }; |
| /** Configuration options for controlling the behavior of the debounced function. */ | ||
| type DebounceOptions = { | ||
| /** | ||
| * Determines whether the function should be invoked on the leading edge of the timeout. | ||
| * @default false | ||
| */ | ||
| leading?: boolean; | ||
| /** | ||
| * Determines whether the function should be invoked on the trailing edge of the timeout. | ||
| * @default false | ||
| */ | ||
| trailing?: boolean; | ||
| /** | ||
| * The maximum time the specified function is allowed to be delayed before it is invoked. | ||
| */ | ||
| maxWait?: number; | ||
| }; | ||
| /** Functions to manage a debounced callback. */ | ||
| type ControlFunctions = { | ||
| /** Cancels pending function invocations. */ | ||
| cancel: () => void; | ||
| /** Immediately invokes pending function invocations. */ | ||
| flush: () => void; | ||
| /** | ||
| * Checks if there are any pending function invocations. | ||
| * @returns `true` if there are pending invocations, otherwise `false`. | ||
| */ | ||
| isPending: () => boolean; | ||
| }; | ||
| /** | ||
| * Represents the state and control functions of a debounced callback. | ||
| * Subsequent calls to the debounced function return the result of the last invocation. | ||
| * Note: If there are no previous invocations, the result will be undefined. | ||
| * Ensure proper handling in your code. | ||
| */ | ||
| export type DebouncedState<T extends (...args: any) => ReturnType<T>> = ((...args: Parameters<T>) => ReturnType<T> | undefined) & ControlFunctions; | ||
| /** | ||
| * Custom hook that creates a debounced version of a callback function. | ||
| * @template T - Type of the original callback function. | ||
| * @param {T} func - The callback function to be debounced. | ||
| * @param {number} delay - The delay in milliseconds before the callback is invoked (default is `500` milliseconds). | ||
| * @param {DebounceOptions} [options] - Options to control the behavior of the debounced function. | ||
| * @returns {DebouncedState<T>} A debounced version of the original callback along with control functions. | ||
| * @public | ||
| * @see [Documentation](https://usehooks-ts.com/react-hook/use-debounce-callback) | ||
| * @example | ||
| * ```tsx | ||
| * const debouncedCallback = useDebounceCallback( | ||
| * (searchTerm) => { | ||
| * // Perform search after user stops typing for 500 milliseconds | ||
| * searchApi(searchTerm); | ||
| * }, | ||
| * 500 | ||
| * ); | ||
| * | ||
| * // Later in the component | ||
| * debouncedCallback('react hooks'); // Will invoke the callback after 500 milliseconds of inactivity. | ||
| * ``` | ||
| */ | ||
| export declare function useDebounceCallback<T extends (...args: any) => ReturnType<T>>(func: T, delay?: number, options?: DebounceOptions): DebouncedState<T>; | ||
| export {}; | ||
| //# sourceMappingURL=useDebounceCallback.d.ts.map |
| {"version":3,"file":"useDebounceCallback.d.ts","sourceRoot":"","sources":["../../src/useDebounceCallback/useDebounceCallback.ts"],"names":[],"mappings":"AAMA,oFAAoF;AACpF,KAAK,eAAe,GAAG;IACrB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,gDAAgD;AAChD,KAAK,gBAAgB,GAAG;IACtB,4CAA4C;IAC5C,MAAM,EAAE,MAAM,IAAI,CAAA;IAClB,wDAAwD;IACxD,KAAK,EAAE,MAAM,IAAI,CAAA;IACjB;;;OAGG;IACH,SAAS,EAAE,MAAM,OAAO,CAAA;CACzB,CAAA;AAED;;;;;GAKG;AAEH,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CACvE,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KACnB,UAAU,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,GAC7B,gBAAgB,CAAA;AAElB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,UAAU,CAAC,CAAC,CAAC,EAC3E,IAAI,EAAE,CAAC,EACP,KAAK,SAAM,EACX,OAAO,CAAC,EAAE,eAAe,GACxB,cAAc,CAAC,CAAC,CAAC,CAqCnB"} |
| import { useRef as f, useMemo as b, useEffect as d } from "react"; | ||
| import o from "lodash.debounce"; | ||
| import { useUnmount as l } from "../useUnmount/useUnmount.js"; | ||
| function F(e, n = 500, r) { | ||
| const u = f(null); | ||
| l(() => { | ||
| u.current && u.current.cancel(); | ||
| }); | ||
| const s = b(() => { | ||
| const t = o(e, n, r), c = (...m) => t(...m); | ||
| return c.cancel = () => { | ||
| t.cancel(); | ||
| }, c.isPending = () => !!u.current, c.flush = () => t.flush(), c; | ||
| }, [e, n, r]); | ||
| return d(() => { | ||
| u.current = o(e, n, r); | ||
| }, [e, n, r]), s; | ||
| } | ||
| export { | ||
| F as useDebounceCallback | ||
| }; |
| export * from './useDebounceValue'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useDebounceValue/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA"} |
| import { useDebounceValue as u } from "./useDebounceValue.js"; | ||
| export { | ||
| u as useDebounceValue | ||
| }; |
| import { DebouncedState } from '../useDebounceCallback'; | ||
| /** | ||
| * Hook options. | ||
| * @template T - The type of the value. | ||
| */ | ||
| type UseDebounceValueOptions<T> = { | ||
| /** | ||
| * Determines whether the function should be invoked on the leading edge of the timeout. | ||
| * @default false | ||
| */ | ||
| leading?: boolean; | ||
| /** | ||
| * Determines whether the function should be invoked on the trailing edge of the timeout. | ||
| * @default false | ||
| */ | ||
| trailing?: boolean; | ||
| /** | ||
| * The maximum time the specified function is allowed to be delayed before it is invoked. | ||
| */ | ||
| maxWait?: number; | ||
| /** A function to determine if the value has changed. Defaults to a function that checks if the value is strictly equal to the previous value. */ | ||
| equalityFn?: (left: T, right: T) => boolean; | ||
| }; | ||
| /** | ||
| * Custom hook that returns a debounced version of the provided value, along with a function to update it. | ||
| * @template T - The type of the value. | ||
| * @param {T | (() => T)} initialValue - The value to be debounced. | ||
| * @param {number} delay - The delay in milliseconds before the value is updated (default is 500ms). | ||
| * @param {object} [options] - Optional configurations for the debouncing behavior. | ||
| * @returns {[T, DebouncedState<(value: T) => void>]} An array containing the debounced value and the function to update it. | ||
| * @public | ||
| * @see [Documentation](https://usehooks-ts.com/react-hook/use-debounce-value) | ||
| * @example | ||
| * ```tsx | ||
| * const [debouncedValue, updateDebouncedValue] = useDebounceValue(inputValue, 500, { leading: true }); | ||
| * ``` | ||
| */ | ||
| export declare function useDebounceValue<T>(initialValue: T | (() => T), delay: number, options?: UseDebounceValueOptions<T>): [T, DebouncedState<(value: T) => void>]; | ||
| export {}; | ||
| //# sourceMappingURL=useDebounceValue.d.ts.map |
| {"version":3,"file":"useDebounceValue.d.ts","sourceRoot":"","sources":["../../src/useDebounceValue/useDebounceValue.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAG5D;;;GAGG;AACH,KAAK,uBAAuB,CAAC,CAAC,IAAI;IAChC;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,iJAAiJ;IACjJ,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,OAAO,CAAA;CAC5C,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAChC,YAAY,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,EAC3B,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,uBAAuB,CAAC,CAAC,CAAC,GACnC,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC,CAAC,CAoBzC"} |
| import { useState as d, useRef as l } from "react"; | ||
| import { useDebounceCallback as p } from "../useDebounceCallback/useDebounceCallback.js"; | ||
| function V(u, c, n) { | ||
| const r = n?.equalityFn ?? ((f, b) => f === b), e = u instanceof Function ? u() : u, [s, a] = d(e), o = l(e), t = p( | ||
| a, | ||
| c, | ||
| n | ||
| ); | ||
| return r(o.current, e) || (t(e), o.current = e), [s, t]; | ||
| } | ||
| export { | ||
| V as useDebounceValue | ||
| }; |
| export * from './useDocumentTitle'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useDocumentTitle/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA"} |
| import { useDocumentTitle as t } from "./useDocumentTitle.js"; | ||
| export { | ||
| t as useDocumentTitle | ||
| }; |
| /** Hook options. */ | ||
| type UseDocumentTitleOptions = { | ||
| /** Whether to keep the title after unmounting the component (default is `true`). */ | ||
| preserveTitleOnUnmount?: boolean; | ||
| }; | ||
| /** | ||
| * Custom hook that sets the document title. | ||
| * @param {string} title - The title to set. | ||
| * @param {?UseDocumentTitleOptions} [options] - The options. | ||
| * @public | ||
| * @see [Documentation](https://usehooks-ts.com/react-hook/use-document-title) | ||
| * @example | ||
| * ```tsx | ||
| * useDocumentTitle('My new title'); | ||
| * ``` | ||
| */ | ||
| export declare function useDocumentTitle(title: string, options?: UseDocumentTitleOptions): void; | ||
| export {}; | ||
| //# sourceMappingURL=useDocumentTitle.d.ts.map |
| {"version":3,"file":"useDocumentTitle.d.ts","sourceRoot":"","sources":["../../src/useDocumentTitle/useDocumentTitle.ts"],"names":[],"mappings":"AAKA,oBAAoB;AACpB,KAAK,uBAAuB,GAAG;IAC7B,oFAAoF;IACpF,sBAAsB,CAAC,EAAE,OAAO,CAAA;CACjC,CAAA;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,uBAA4B,GACpC,IAAI,CAiBN"} |
| import { useRef as r } from "react"; | ||
| import { useIsomorphicLayoutEffect as o } from "../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js"; | ||
| import { useUnmount as i } from "../useUnmount/useUnmount.js"; | ||
| function l(e, n = {}) { | ||
| const { preserveTitleOnUnmount: u = !0 } = n, t = r(null); | ||
| o(() => { | ||
| t.current = window.document.title; | ||
| }, []), o(() => { | ||
| window.document.title = e; | ||
| }, [e]), i(() => { | ||
| !u && t.current && (window.document.title = t.current); | ||
| }); | ||
| } | ||
| export { | ||
| l as useDocumentTitle | ||
| }; |
| export * from './useEventCallback'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useEventCallback/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA"} |
| import { useEventCallback as l } from "./useEventCallback.js"; | ||
| export { | ||
| l as useEventCallback | ||
| }; |
| /** | ||
| * Custom hook that creates a memoized event callback. | ||
| * @template Args - An array of argument types for the event callback. | ||
| * @template R - The return type of the event callback. | ||
| * @param {(...args: Args) => R} fn - The callback function. | ||
| * @returns {(...args: Args) => R} A memoized event callback function. | ||
| * @public | ||
| * @see [Documentation](https://usehooks-ts.com/react-hook/use-event-callback) | ||
| * @example | ||
| * ```tsx | ||
| * const handleClick = useEventCallback((event) => { | ||
| * // Handle the event here | ||
| * }); | ||
| * ``` | ||
| */ | ||
| export declare function useEventCallback<Args extends unknown[], R>(fn: (...args: Args) => R): (...args: Args) => R; | ||
| export declare function useEventCallback<Args extends unknown[], R>(fn: ((...args: Args) => R) | undefined): ((...args: Args) => R) | undefined; | ||
| //# sourceMappingURL=useEventCallback.d.ts.map |
| {"version":3,"file":"useEventCallback.d.ts","sourceRoot":"","sources":["../../src/useEventCallback/useEventCallback.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,SAAS,OAAO,EAAE,EAAE,CAAC,EACxD,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,CAAC,GACvB,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,CAAC,CAAA;AACvB,wBAAgB,gBAAgB,CAAC,IAAI,SAAS,OAAO,EAAE,EAAE,CAAC,EACxD,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,CAAC,CAAC,GAAG,SAAS,GACrC,CAAC,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,CAAC,CAAC,GAAG,SAAS,CAAA"} |
| import { useRef as t, useCallback as o } from "react"; | ||
| import { useIsomorphicLayoutEffect as a } from "../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js"; | ||
| function l(e) { | ||
| const r = t(() => { | ||
| throw new Error("Cannot call an event handler while rendering."); | ||
| }); | ||
| return a(() => { | ||
| r.current = e; | ||
| }, [e]), o((...n) => r.current?.(...n), [r]); | ||
| } | ||
| export { | ||
| l as useEventCallback | ||
| }; |
| export * from './useEventListener'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useEventListener/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA"} |
| import { useEventListener as t } from "./useEventListener.js"; | ||
| export { | ||
| t as useEventListener | ||
| }; |
| import { RefObject } from 'react'; | ||
| declare function useEventListener<K extends keyof MediaQueryListEventMap>(eventName: K, handler: (event: MediaQueryListEventMap[K]) => void, element: RefObject<MediaQueryList>, options?: boolean | AddEventListenerOptions): void; | ||
| declare function useEventListener<K extends keyof WindowEventMap>(eventName: K, handler: (event: WindowEventMap[K]) => void, element?: undefined, options?: boolean | AddEventListenerOptions): void; | ||
| declare function useEventListener<K extends keyof HTMLElementEventMap & keyof SVGElementEventMap, T extends Element = K extends keyof HTMLElementEventMap ? HTMLDivElement : SVGElement>(eventName: K, handler: ((event: HTMLElementEventMap[K]) => void) | ((event: SVGElementEventMap[K]) => void), element: RefObject<T>, options?: boolean | AddEventListenerOptions): void; | ||
| declare function useEventListener<K extends keyof DocumentEventMap>(eventName: K, handler: (event: DocumentEventMap[K]) => void, element: RefObject<Document>, options?: boolean | AddEventListenerOptions): void; | ||
| export { useEventListener }; | ||
| //# sourceMappingURL=useEventListener.d.ts.map |
| {"version":3,"file":"useEventListener.d.ts","sourceRoot":"","sources":["../../src/useEventListener/useEventListener.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAKtC,iBAAS,gBAAgB,CAAC,CAAC,SAAS,MAAM,sBAAsB,EAC9D,SAAS,EAAE,CAAC,EACZ,OAAO,EAAE,CAAC,KAAK,EAAE,sBAAsB,CAAC,CAAC,CAAC,KAAK,IAAI,EACnD,OAAO,EAAE,SAAS,CAAC,cAAc,CAAC,EAClC,OAAO,CAAC,EAAE,OAAO,GAAG,uBAAuB,GAC1C,IAAI,CAAA;AAGP,iBAAS,gBAAgB,CAAC,CAAC,SAAS,MAAM,cAAc,EACtD,SAAS,EAAE,CAAC,EACZ,OAAO,EAAE,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,KAAK,IAAI,EAC3C,OAAO,CAAC,EAAE,SAAS,EACnB,OAAO,CAAC,EAAE,OAAO,GAAG,uBAAuB,GAC1C,IAAI,CAAA;AAGP,iBAAS,gBAAgB,CACvB,CAAC,SAAS,MAAM,mBAAmB,GAAG,MAAM,kBAAkB,EAC9D,CAAC,SAAS,OAAO,GAAG,CAAC,SAAS,MAAM,mBAAmB,GACnD,cAAc,GACd,UAAU,EAEd,SAAS,EAAE,CAAC,EACZ,OAAO,EACH,CAAC,CAAC,KAAK,EAAE,mBAAmB,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,GACzC,CAAC,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,EAC5C,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,EACrB,OAAO,CAAC,EAAE,OAAO,GAAG,uBAAuB,GAC1C,IAAI,CAAA;AAGP,iBAAS,gBAAgB,CAAC,CAAC,SAAS,MAAM,gBAAgB,EACxD,SAAS,EAAE,CAAC,EACZ,OAAO,EAAE,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC,CAAC,KAAK,IAAI,EAC7C,OAAO,EAAE,SAAS,CAAC,QAAQ,CAAC,EAC5B,OAAO,CAAC,EAAE,OAAO,GAAG,uBAAuB,GAC1C,IAAI,CAAA;AA6EP,OAAO,EAAE,gBAAgB,EAAE,CAAA"} |
| import { useRef as f, useEffect as i } from "react"; | ||
| import { useIsomorphicLayoutEffect as E } from "../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js"; | ||
| function m(r, t, s, n) { | ||
| const u = f(t); | ||
| E(() => { | ||
| u.current = t; | ||
| }, [t]), i(() => { | ||
| const e = s?.current ?? window; | ||
| if (!(e && e.addEventListener)) return; | ||
| const c = (o) => { | ||
| u.current(o); | ||
| }; | ||
| return e.addEventListener(r, c, n), () => { | ||
| e.removeEventListener(r, c, n); | ||
| }; | ||
| }, [r, s, n]); | ||
| } | ||
| export { | ||
| m as useEventListener | ||
| }; |
| export * from './useHover'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useHover/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA"} |
| import { useHover as r } from "./useHover.js"; | ||
| export { | ||
| r as useHover | ||
| }; |
| import { RefObject } from 'react'; | ||
| /** | ||
| * Custom hook that tracks whether a DOM element is being hovered over. | ||
| * @template T - The type of the DOM element. Defaults to `HTMLElement`. | ||
| * @param {RefObject<T>} elementRef - The ref object for the DOM element to track. | ||
| * @returns {boolean} A boolean value indicating whether the element is being hovered over. | ||
| * @public | ||
| * @see [Documentation](https://usehooks-ts.com/react-hook/use-hover) | ||
| * @example | ||
| * ```tsx | ||
| * const buttonRef = useRef<HTMLButtonElement>(null); | ||
| * const isHovered = useHover(buttonRef); | ||
| * // Access the isHovered variable to determine if the button is being hovered over. | ||
| * ``` | ||
| */ | ||
| export declare function useHover<T extends HTMLElement = HTMLElement>(elementRef: RefObject<T>): boolean; | ||
| //# sourceMappingURL=useHover.d.ts.map |
| {"version":3,"file":"useHover.d.ts","sourceRoot":"","sources":["../../src/useHover/useHover.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAItC;;;;;;;;;;;;;GAaG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,EAC1D,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC,GACvB,OAAO,CAcT"} |
| import { useState as n } from "react"; | ||
| import { useEventListener as o } from "../useEventListener/useEventListener.js"; | ||
| function m(e) { | ||
| const [s, t] = n(!1), r = () => { | ||
| t(!0); | ||
| }, u = () => { | ||
| t(!1); | ||
| }; | ||
| return o("mouseenter", r, e), o("mouseleave", u, e), s; | ||
| } | ||
| export { | ||
| m as useHover | ||
| }; |
| export * from './useIntersectionObserver'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useIntersectionObserver/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAA"} |
| import { useIntersectionObserver as o } from "./useIntersectionObserver.js"; | ||
| export { | ||
| o as useIntersectionObserver | ||
| }; |
| /** Represents the options for configuring the Intersection Observer. */ | ||
| type UseIntersectionObserverOptions = { | ||
| /** | ||
| * The element that is used as the viewport for checking visibility of the target. | ||
| * @default null | ||
| */ | ||
| root?: Element | Document | null; | ||
| /** | ||
| * A margin around the root. | ||
| * @default '0%' | ||
| */ | ||
| rootMargin?: string; | ||
| /** | ||
| * A threshold indicating the percentage of the target's visibility needed to trigger the callback. | ||
| * @default 0 | ||
| */ | ||
| threshold?: number | number[]; | ||
| /** | ||
| * If true, freezes the intersection state once the element becomes visible. | ||
| * @default false | ||
| */ | ||
| freezeOnceVisible?: boolean; | ||
| /** | ||
| * A callback function to be invoked when the intersection state changes. | ||
| * @param {boolean} isIntersecting - A boolean indicating if the element is intersecting. | ||
| * @param {IntersectionObserverEntry} entry - The intersection observer Entry. | ||
| * @default undefined | ||
| */ | ||
| onChange?: (isIntersecting: boolean, entry: IntersectionObserverEntry) => void; | ||
| /** | ||
| * The initial state of the intersection. | ||
| * @default false | ||
| */ | ||
| initialIsIntersecting?: boolean; | ||
| }; | ||
| /** | ||
| * The return type of the useIntersectionObserver hook. | ||
| * | ||
| * Supports both tuple and object destructing. | ||
| * @param {(node: Element | null) => void} ref - The ref callback function. | ||
| * @param {boolean} isIntersecting - A boolean indicating if the element is intersecting. | ||
| * @param {IntersectionObserverEntry | undefined} entry - The intersection observer Entry. | ||
| */ | ||
| type IntersectionReturn = [ | ||
| (node?: Element | null) => void, | ||
| boolean, | ||
| IntersectionObserverEntry | undefined | ||
| ] & { | ||
| ref: (node?: Element | null) => void; | ||
| isIntersecting: boolean; | ||
| entry?: IntersectionObserverEntry; | ||
| }; | ||
| /** | ||
| * Custom hook that tracks the intersection of a DOM element with its containing element or the viewport using the [`Intersection Observer API`](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API). | ||
| * @param {UseIntersectionObserverOptions} options - The options for the Intersection Observer. | ||
| * @returns {IntersectionReturn} The ref callback, a boolean indicating if the element is intersecting, and the intersection observer entry. | ||
| * @public | ||
| * @see [Documentation](https://usehooks-ts.com/react-hook/use-intersection-observer) | ||
| * @example | ||
| * ```tsx | ||
| * // Example 1 | ||
| * const [ref, isIntersecting, entry] = useIntersectionObserver({ threshold: 0.5 }); | ||
| * ``` | ||
| * | ||
| * ```tsx | ||
| * // Example 2 | ||
| * const { ref, isIntersecting, entry } = useIntersectionObserver({ threshold: 0.5 }); | ||
| * ``` | ||
| */ | ||
| export declare function useIntersectionObserver({ threshold, root, rootMargin, freezeOnceVisible, initialIsIntersecting, onChange, }?: UseIntersectionObserverOptions): IntersectionReturn; | ||
| export {}; | ||
| //# sourceMappingURL=useIntersectionObserver.d.ts.map |
| {"version":3,"file":"useIntersectionObserver.d.ts","sourceRoot":"","sources":["../../src/useIntersectionObserver/useIntersectionObserver.ts"],"names":[],"mappings":"AAUA,wEAAwE;AACxE,KAAK,8BAA8B,GAAG;IACpC;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,IAAI,CAAA;IAChC;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IAC7B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,CAAC,cAAc,EAAE,OAAO,EAAE,KAAK,EAAE,yBAAyB,KAAK,IAAI,CAAA;IAC9E;;;OAGG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAChC,CAAA;AAED;;;;;;;GAOG;AACH,KAAK,kBAAkB,GAAG;IACxB,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI;IAC/B,OAAO;IACP,yBAAyB,GAAG,SAAS;CACtC,GAAG;IACF,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI,CAAA;IACpC,cAAc,EAAE,OAAO,CAAA;IACvB,KAAK,CAAC,EAAE,yBAAyB,CAAA;CAClC,CAAA;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,uBAAuB,CAAC,EACtC,SAAa,EACb,IAAW,EACX,UAAiB,EACjB,iBAAyB,EACzB,qBAA6B,EAC7B,QAAQ,GACT,GAAE,8BAAmC,GAAG,kBAAkB,CAiG1D"} |
| import { useState as d, useRef as h, useEffect as I } from "react"; | ||
| function A({ | ||
| threshold: f = 0, | ||
| root: a = null, | ||
| rootMargin: l = "0%", | ||
| freezeOnceVisible: s = !1, | ||
| initialIsIntersecting: i = !1, | ||
| onChange: R | ||
| } = {}) { | ||
| const [r, b] = d(null), [t, y] = d(() => ({ | ||
| isIntersecting: i, | ||
| entry: void 0 | ||
| })), u = h(null); | ||
| u.current = R; | ||
| const c = t.entry?.isIntersecting && s; | ||
| I(() => { | ||
| if (!r || !("IntersectionObserver" in window) || c) return; | ||
| const n = new IntersectionObserver( | ||
| (m) => { | ||
| const p = Array.isArray(n.thresholds) ? n.thresholds : [n.thresholds]; | ||
| m.forEach((o) => { | ||
| const v = o.isIntersecting && p.some((w) => o.intersectionRatio >= w); | ||
| y({ isIntersecting: v, entry: o }), u.current && u.current(v, o); | ||
| }); | ||
| }, | ||
| { threshold: f, root: a, rootMargin: l } | ||
| ); | ||
| return n.observe(r), () => { | ||
| n.disconnect(); | ||
| }; | ||
| }, [ | ||
| r, | ||
| // eslint-disable-next-line react-hooks/exhaustive-deps | ||
| JSON.stringify(f), | ||
| a, | ||
| l, | ||
| c, | ||
| s | ||
| ]); | ||
| const g = h(null); | ||
| I(() => { | ||
| !r && t.entry?.target && !s && !c && g.current !== t.entry.target && (g.current = t.entry.target, y({ isIntersecting: i, entry: void 0 })); | ||
| }, [r, t.entry, s, c, i]); | ||
| const e = [ | ||
| b, | ||
| !!t.isIntersecting, | ||
| t.entry | ||
| ]; | ||
| return e.ref = e[0], e.isIntersecting = e[1], e.entry = e[2], e; | ||
| } | ||
| export { | ||
| A as useIntersectionObserver | ||
| }; |
| export * from './useInterval'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useInterval/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA"} |
| import { useInterval as o } from "./useInterval.js"; | ||
| export { | ||
| o as useInterval | ||
| }; |
| /** | ||
| * Custom hook that creates an interval that invokes a callback function at a specified delay using the [`setInterval API`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setInterval). | ||
| * @param {() => void} callback - The function to be invoked at each interval. | ||
| * @param {number | null} delay - The time, in milliseconds, between each invocation of the callback. Use `null` to clear the interval. | ||
| * @public | ||
| * @see [Documentation](https://usehooks-ts.com/react-hook/use-interval) | ||
| * @example | ||
| * ```tsx | ||
| * const handleInterval = () => { | ||
| * // Code to be executed at each interval | ||
| * }; | ||
| * useInterval(handleInterval, 1000); | ||
| * ``` | ||
| */ | ||
| export declare function useInterval(callback: () => void, delay: number | null): void; | ||
| //# sourceMappingURL=useInterval.d.ts.map |
| {"version":3,"file":"useInterval.d.ts","sourceRoot":"","sources":["../../src/useInterval/useInterval.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,QAwBrE"} |
| import { useRef as o, useEffect as u } from "react"; | ||
| import { useIsomorphicLayoutEffect as f } from "../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js"; | ||
| function i(r, t) { | ||
| const e = o(r); | ||
| f(() => { | ||
| e.current = r; | ||
| }, [r]), u(() => { | ||
| if (t === null) | ||
| return; | ||
| const n = setInterval(() => { | ||
| e.current(); | ||
| }, t); | ||
| return () => { | ||
| clearInterval(n); | ||
| }; | ||
| }, [t]); | ||
| } | ||
| export { | ||
| i as useInterval | ||
| }; |
| export * from './useIsClient'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useIsClient/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA"} |
| import { useIsClient as r } from "./useIsClient.js"; | ||
| export { | ||
| r as useIsClient | ||
| }; |
| /** | ||
| * Custom hook that determines if the code is running on the client side (in the browser). | ||
| * @returns {boolean} A boolean value indicating whether the code is running on the client side. | ||
| * @public | ||
| * @see [Documentation](https://usehooks-ts.com/react-hook/use-is-client) | ||
| * @example | ||
| * ```tsx | ||
| * const isClient = useIsClient(); | ||
| * // Use isClient to conditionally render or execute code specific to the client side. | ||
| * ``` | ||
| */ | ||
| export declare function useIsClient(): boolean; | ||
| //# sourceMappingURL=useIsClient.d.ts.map |
| {"version":3,"file":"useIsClient.d.ts","sourceRoot":"","sources":["../../src/useIsClient/useIsClient.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,YAQ1B"} |
| import { useState as s, useEffect as n } from "react"; | ||
| function r() { | ||
| const [e, t] = s(!1); | ||
| return n(() => { | ||
| t(!0); | ||
| }, []), e; | ||
| } | ||
| export { | ||
| r as useIsClient | ||
| }; |
| export * from './useIsMobile'; | ||
| export type * from './types'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useIsMobile/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,mBAAmB,SAAS,CAAA"} |
| import { useIsMobile as r } from "./useIsMobile.js"; | ||
| export { | ||
| r as useIsMobile | ||
| }; |
| export interface IUseIsMobileParams { | ||
| mobileBreakpoint?: number; | ||
| } | ||
| //# sourceMappingURL=types.d.ts.map |
| {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/useIsMobile/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IACjC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B"} |
| import { IUseIsMobileParams } from './types'; | ||
| export declare function useIsMobile(params?: IUseIsMobileParams): boolean; | ||
| //# sourceMappingURL=useIsMobile.d.ts.map |
| {"version":3,"file":"useIsMobile.d.ts","sourceRoot":"","sources":["../../src/useIsMobile/useIsMobile.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAI7C,wBAAgB,WAAW,CAAC,MAAM,GAAE,kBAAuB,WAiB1D"} |
| import * as o from "react"; | ||
| const a = 768; | ||
| function c(s = {}) { | ||
| const { | ||
| mobileBreakpoint: e = a | ||
| } = s, [r, n] = o.useState(void 0); | ||
| return o.useEffect(() => { | ||
| const t = window.matchMedia(`(max-width: ${e - 1}px)`), i = () => { | ||
| n(window.innerWidth < e); | ||
| }; | ||
| return t.addEventListener("change", i), n(window.innerWidth < e), () => t.removeEventListener("change", i); | ||
| }, [e]), !!r; | ||
| } | ||
| export { | ||
| c as useIsMobile | ||
| }; |
| export * from './useIsMounted'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useIsMounted/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA"} |
| import { useIsMounted as r } from "./useIsMounted.js"; | ||
| export { | ||
| r as useIsMounted | ||
| }; |
| export declare function useIsMounted(): () => boolean; | ||
| //# sourceMappingURL=useIsMounted.d.ts.map |
| {"version":3,"file":"useIsMounted.d.ts","sourceRoot":"","sources":["../../src/useIsMounted/useIsMounted.ts"],"names":[],"mappings":"AAEA,wBAAgB,YAAY,IAAI,MAAM,OAAO,CAY5C"} |
| import { useRef as r, useEffect as t, useCallback as u } from "react"; | ||
| function s() { | ||
| const e = r(!1); | ||
| return t(() => (e.current = !0, () => { | ||
| e.current = !1; | ||
| }), []), u(() => e.current, []); | ||
| } | ||
| export { | ||
| s as useIsMounted | ||
| }; |
| export * from './useIsomorphicLayoutEffect'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useIsomorphicLayoutEffect/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAA"} |
| import { useIsomorphicLayoutEffect as f } from "./useIsomorphicLayoutEffect.js"; | ||
| export { | ||
| f as useIsomorphicLayoutEffect | ||
| }; |
| import { useLayoutEffect } from 'react'; | ||
| /** | ||
| * Custom hook that uses either `useLayoutEffect` or `useEffect` based on the environment (client-side or server-side). | ||
| * @param {Function} effect - The effect function to be executed. | ||
| * @param {Array<any>} [dependencies] - An array of dependencies for the effect (optional). | ||
| * @public | ||
| * @see [Documentation](https://usehooks-ts.com/react-hook/use-isomorphic-layout-effect) | ||
| * @example | ||
| * ```tsx | ||
| * useIsomorphicLayoutEffect(() => { | ||
| * // Code to be executed during the layout phase on the client side | ||
| * }, [dependency1, dependency2]); | ||
| * ``` | ||
| */ | ||
| export declare const useIsomorphicLayoutEffect: typeof useLayoutEffect; | ||
| //# sourceMappingURL=useIsomorphicLayoutEffect.d.ts.map |
| {"version":3,"file":"useIsomorphicLayoutEffect.d.ts","sourceRoot":"","sources":["../../src/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,eAAe,EAAE,MAAM,OAAO,CAAA;AAElD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,yBAAyB,wBACuB,CAAA"} |
| import { useLayoutEffect as e, useEffect as o } from "react"; | ||
| const t = typeof window < "u" ? e : o; | ||
| export { | ||
| t as useIsomorphicLayoutEffect | ||
| }; |
| export * from './useLocalStorage'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useLocalStorage/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA"} |
| import { useLocalStorage as r } from "./useLocalStorage.js"; | ||
| export { | ||
| r as useLocalStorage | ||
| }; |
| import { Dispatch, SetStateAction } from 'react'; | ||
| declare global { | ||
| interface WindowEventMap { | ||
| 'local-storage': CustomEvent; | ||
| } | ||
| } | ||
| /** | ||
| * Options for customizing the behavior of serialization and deserialization. | ||
| * @template T - The type of the state to be stored in local storage. | ||
| */ | ||
| type UseLocalStorageOptions<T> = { | ||
| /** A function to serialize the value before storing it. */ | ||
| serializer?: (value: T) => string; | ||
| /** A function to deserialize the stored value. */ | ||
| deserializer?: (value: string) => T; | ||
| /** | ||
| * If `true` (default), the hook will initialize reading the local storage. In SSR, you should set it to `false`, returning the initial value initially. | ||
| * @default true | ||
| */ | ||
| initializeWithValue?: boolean; | ||
| }; | ||
| /** | ||
| * Custom hook that uses the [`localStorage API`](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage) to persist state across page reloads. | ||
| * @template T - The type of the state to be stored in local storage. | ||
| * @param {string} key - The key under which the value will be stored in local storage. | ||
| * @param {T | (() => T)} initialValue - The initial value of the state or a function that returns the initial value. | ||
| * @param {UseLocalStorageOptions<T>} [options] - Options for customizing the behavior of serialization and deserialization (optional). | ||
| * @returns {[T, Dispatch<SetStateAction<T>>, () => void]} A tuple containing the stored value, a function to set the value and a function to remove the key from storage. | ||
| * @public | ||
| * @see [Documentation](https://usehooks-ts.com/react-hook/use-local-storage) | ||
| * @example | ||
| * ```tsx | ||
| * const [count, setCount, removeCount] = useLocalStorage('count', 0); | ||
| * // Access the `count` value, the `setCount` function to update it and `removeCount` function to remove the key from storage. | ||
| * ``` | ||
| */ | ||
| export declare function useLocalStorage<T>(key: string, initialValue: T | (() => T), options?: UseLocalStorageOptions<T>): [T, Dispatch<SetStateAction<T>>, () => void]; | ||
| export {}; | ||
| //# sourceMappingURL=useLocalStorage.d.ts.map |
| {"version":3,"file":"useLocalStorage.d.ts","sourceRoot":"","sources":["../../src/useLocalStorage/useLocalStorage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAKrD,OAAO,CAAC,MAAM,CAAC;IAEb,UAAU,cAAc;QACtB,eAAe,EAAE,WAAW,CAAA;KAC7B;CACF;AAED;;;GAGG;AACH,KAAK,sBAAsB,CAAC,CAAC,IAAI;IAC/B,2DAA2D;IAC3D,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,CAAA;IACjC,kDAAkD;IAClD,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,CAAC,CAAA;IACnC;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAA;CAC9B,CAAA;AAID;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAC/B,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,EAC3B,OAAO,GAAE,sBAAsB,CAAC,CAAC,CAAM,GACtC,CAAC,CAAC,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,IAAI,CAAC,CA2I9C"} |
| import { useCallback as a, useState as z, useEffect as F } from "react"; | ||
| import { useEventCallback as u } from "../useEventCallback/useEventCallback.js"; | ||
| import { useEventListener as l } from "../useEventListener/useEventListener.js"; | ||
| const d = typeof window > "u"; | ||
| function C(t, r, n = {}) { | ||
| const { initializeWithValue: w = !0 } = n, S = a( | ||
| (e) => n.serializer ? n.serializer(e) : JSON.stringify(e), | ||
| [n] | ||
| ), f = a( | ||
| (e) => { | ||
| if (n.deserializer) | ||
| return n.deserializer(e); | ||
| if (e === "undefined") | ||
| return; | ||
| const o = r instanceof Function ? r() : r; | ||
| let i; | ||
| try { | ||
| i = JSON.parse(e); | ||
| } catch (v) { | ||
| return console.error("Error parsing JSON:", v), o; | ||
| } | ||
| return i; | ||
| }, | ||
| [n, r] | ||
| ), c = a(() => { | ||
| const e = r instanceof Function ? r() : r; | ||
| if (d) | ||
| return e; | ||
| try { | ||
| const o = window.localStorage.getItem(t); | ||
| return o ? f(o) : e; | ||
| } catch (o) { | ||
| return console.warn(`Error reading localStorage key “${t}”:`, o), e; | ||
| } | ||
| }, [r, t, f]), [m, s] = z(() => w ? c() : r instanceof Function ? r() : r), h = u((e) => { | ||
| d && console.warn( | ||
| `Tried setting localStorage key “${t}” even though environment is not a client` | ||
| ); | ||
| try { | ||
| const o = e instanceof Function ? e(c()) : e; | ||
| window.localStorage.setItem(t, S(o)), s(o), window.dispatchEvent(new StorageEvent("local-storage", { key: t })); | ||
| } catch (o) { | ||
| console.warn(`Error setting localStorage key “${t}”:`, o); | ||
| } | ||
| }), E = u(() => { | ||
| d && console.warn( | ||
| `Tried removing localStorage key “${t}” even though environment is not a client` | ||
| ); | ||
| const e = r instanceof Function ? r() : r; | ||
| window.localStorage.removeItem(t), s(e), window.dispatchEvent(new StorageEvent("local-storage", { key: t })); | ||
| }); | ||
| F(() => { | ||
| s(c()); | ||
| }, [t]); | ||
| const g = a( | ||
| (e) => { | ||
| e.key && e.key !== t || s(c()); | ||
| }, | ||
| [t, c] | ||
| ); | ||
| return l("storage", g), l("local-storage", g), [m, h, E]; | ||
| } | ||
| export { | ||
| C as useLocalStorage | ||
| }; |
| export * from './useLockBody'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useLockBody/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA"} |
| import { useLockBody as r } from "./useLockBody.js"; | ||
| export { | ||
| r as useLockBody | ||
| }; |
| export declare function useLockBody(): void; | ||
| //# sourceMappingURL=useLockBody.d.ts.map |
| {"version":3,"file":"useLockBody.d.ts","sourceRoot":"","sources":["../../src/useLockBody/useLockBody.tsx"],"names":[],"mappings":"AAGA,wBAAgB,WAAW,SAQ1B"} |
| import * as e from "react"; | ||
| function t() { | ||
| e.useLayoutEffect(() => { | ||
| const o = window.getComputedStyle( | ||
| document.body | ||
| ).overflow; | ||
| return document.body.style.overflow = "hidden", () => document.body.style.overflow = o; | ||
| }, []); | ||
| } | ||
| export { | ||
| t as useLockBody | ||
| }; |
| export * from './useMap'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useMap/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA"} |
| import { useMap as p } from "./useMap.js"; | ||
| export { | ||
| p as useMap | ||
| }; |
| /** | ||
| * Represents the type for either a Map or an array of key-value pairs. | ||
| * @template K - The type of keys in the map. | ||
| * @template V - The type of values in the map. | ||
| */ | ||
| type MapOrEntries<K, V> = Map<K, V> | [K, V][]; | ||
| /** | ||
| * Represents the actions available to interact with the map state. | ||
| * @template K - The type of keys in the map. | ||
| * @template V - The type of values in the map. | ||
| */ | ||
| type UseMapActions<K, V> = { | ||
| /** Set a key-value pair in the map. */ | ||
| set: (key: K, value: V) => void; | ||
| /** Set all key-value pairs in the map. */ | ||
| setAll: (entries: MapOrEntries<K, V>) => void; | ||
| /** Remove a key-value pair from the map. */ | ||
| remove: (key: K) => void; | ||
| /** Reset the map to an empty state. */ | ||
| reset: Map<K, V>['clear']; | ||
| }; | ||
| /** | ||
| * Represents the return type of the `useMap` hook. | ||
| * We hide some setters from the returned map to disable autocompletion. | ||
| * @template K - The type of keys in the map. | ||
| * @template V - The type of values in the map. | ||
| */ | ||
| type UseMapReturn<K, V> = [ | ||
| Omit<Map<K, V>, 'set' | 'clear' | 'delete'>, | ||
| UseMapActions<K, V> | ||
| ]; | ||
| /** | ||
| * Custom hook that manages a key-value [`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) state with setter actions. | ||
| * @template K - The type of keys in the map. | ||
| * @template V - The type of values in the map. | ||
| * @param {MapOrEntries<K, V>} [initialState] - The initial state of the map as a Map or an array of key-value pairs (optional). | ||
| * @returns {UseMapReturn<K, V>} A tuple containing the map state and actions to interact with the map. | ||
| * @public | ||
| * @see [Documentation](https://usehooks-ts.com/react-hook/use-map) | ||
| * @example | ||
| * ```tsx | ||
| * const [map, mapActions] = useMap(); | ||
| * // Access the `map` state and use `mapActions` to set, remove, or reset entries. | ||
| * ``` | ||
| */ | ||
| export declare function useMap<K, V>(initialState?: MapOrEntries<K, V>): UseMapReturn<K, V>; | ||
| export {}; | ||
| //# sourceMappingURL=useMap.d.ts.map |
| {"version":3,"file":"useMap.d.ts","sourceRoot":"","sources":["../../src/useMap/useMap.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,KAAK,YAAY,CAAC,CAAC,EAAE,CAAC,IAAI,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAA;AAE9C;;;;GAIG;AACH,KAAK,aAAa,CAAC,CAAC,EAAE,CAAC,IAAI;IACzB,uCAAuC;IACvC,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,IAAI,CAAA;IAC/B,0CAA0C;IAC1C,MAAM,EAAE,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,IAAI,CAAA;IAC7C,4CAA4C;IAC5C,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,IAAI,CAAA;IACxB,uCAAuC;IACvC,KAAK,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;CAC1B,CAAA;AAED;;;;;GAKG;AACH,KAAK,YAAY,CAAC,CAAC,EAAE,CAAC,IAAI;IACxB,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;IAC3C,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC;CACpB,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,CAAC,EACzB,YAAY,GAAE,YAAY,CAAC,CAAC,EAAE,CAAC,CAAa,GAC3C,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,CA8BpB"} |
| import { useState as M, useCallback as a } from "react"; | ||
| function w(o = /* @__PURE__ */ new Map()) { | ||
| const [r, t] = M(new Map(o)), c = { | ||
| set: a((e, p) => { | ||
| t((n) => { | ||
| const s = new Map(n); | ||
| return s.set(e, p), s; | ||
| }); | ||
| }, []), | ||
| setAll: a((e) => { | ||
| t(() => new Map(e)); | ||
| }, []), | ||
| remove: a((e) => { | ||
| t((p) => { | ||
| const n = new Map(p); | ||
| return n.delete(e), n; | ||
| }); | ||
| }, []), | ||
| reset: a(() => { | ||
| t(() => /* @__PURE__ */ new Map()); | ||
| }, []) | ||
| }; | ||
| return [r, c]; | ||
| } | ||
| export { | ||
| w as useMap | ||
| }; |
| export * from './useMediaQuery'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useMediaQuery/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA"} |
| import { useMediaQuery as o } from "./useMediaQuery.js"; | ||
| export { | ||
| o as useMediaQuery | ||
| }; |
| /** Hook options. */ | ||
| type UseMediaQueryOptions = { | ||
| /** | ||
| * The default value to return if the hook is being run on the server. | ||
| * @default false | ||
| */ | ||
| defaultValue?: boolean; | ||
| /** | ||
| * If `true` (default), the hook will initialize reading the media query. In SSR, you should set it to `false`, returning `options.defaultValue` or `false` initially. | ||
| * @default true | ||
| */ | ||
| initializeWithValue?: boolean; | ||
| }; | ||
| /** | ||
| * Custom hook that tracks the state of a media query using the [`Match Media API`](https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia). | ||
| * @param {string} query - The media query to track. | ||
| * @param {?UseMediaQueryOptions} [options] - The options for customizing the behavior of the hook (optional). | ||
| * @returns {boolean} The current state of the media query (true if the query matches, false otherwise). | ||
| * @public | ||
| * @see [Documentation](https://usehooks-ts.com/react-hook/use-media-query) | ||
| * @example | ||
| * ```tsx | ||
| * const isSmallScreen = useMediaQuery('(max-width: 600px)'); | ||
| * // Use `isSmallScreen` to conditionally apply styles or logic based on the screen size. | ||
| * ``` | ||
| */ | ||
| export declare function useMediaQuery(query: string, { defaultValue, initializeWithValue, }?: UseMediaQueryOptions): boolean; | ||
| export {}; | ||
| //# sourceMappingURL=useMediaQuery.d.ts.map |
| {"version":3,"file":"useMediaQuery.d.ts","sourceRoot":"","sources":["../../src/useMediaQuery/useMediaQuery.ts"],"names":[],"mappings":"AAIA,oBAAoB;AACpB,KAAK,oBAAoB,GAAG;IAC1B;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAA;CAC9B,CAAA;AAID;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,MAAM,EACb,EACE,YAAoB,EACpB,mBAA0B,GAC3B,GAAE,oBAAyB,GAC3B,OAAO,CA2CT"} |
| import { useState as c } from "react"; | ||
| import { useIsomorphicLayoutEffect as d } from "../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js"; | ||
| const m = typeof window > "u"; | ||
| function u(n, { | ||
| defaultValue: r = !1, | ||
| initializeWithValue: s = !0 | ||
| } = {}) { | ||
| const i = (e) => m ? r : window.matchMedia(e).matches, [o, a] = c(() => s ? i(n) : r); | ||
| function t() { | ||
| a(i(n)); | ||
| } | ||
| return d(() => { | ||
| const e = window.matchMedia(n); | ||
| return t(), e.addListener ? e.addListener(t) : e.addEventListener("change", t), () => { | ||
| e.removeListener ? e.removeListener(t) : e.removeEventListener("change", t); | ||
| }; | ||
| }, [n]), o; | ||
| } | ||
| export { | ||
| u as useMediaQuery | ||
| }; |
| export * from './useOnClickOutside'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useOnClickOutside/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA"} |
| import { useOnClickOutside as o } from "./useOnClickOutside.js"; | ||
| export { | ||
| o as useOnClickOutside | ||
| }; |
| import { RefObject } from 'react'; | ||
| /** Supported event types. */ | ||
| type EventType = 'mousedown' | 'mouseup' | 'touchstart' | 'touchend' | 'focusin' | 'focusout'; | ||
| /** | ||
| * Custom hook that handles clicks outside a specified element. | ||
| * @template T - The type of the element's reference. | ||
| * @param {RefObject<T> | RefObject<T>[]} ref - The React ref object(s) representing the element(s) to watch for outside clicks. | ||
| * @param {(event: MouseEvent | TouchEvent | FocusEvent) => void} handler - The callback function to be executed when a click outside the element occurs. | ||
| * @param {EventType} [eventType] - The mouse event type to listen for (optional, default is 'mousedown'). | ||
| * @param {?AddEventListenerOptions} [eventListenerOptions] - The options object to be passed to the `addEventListener` method (optional). | ||
| * @returns {void} | ||
| * @public | ||
| * @see [Documentation](https://usehooks-ts.com/react-hook/use-on-click-outside) | ||
| * @example | ||
| * ```tsx | ||
| * const containerRef = useRef(null); | ||
| * useOnClickOutside([containerRef], () => { | ||
| * // Handle clicks outside the container. | ||
| * }); | ||
| * ``` | ||
| */ | ||
| export declare function useOnClickOutside<T extends HTMLElement = HTMLElement>(ref: RefObject<T> | RefObject<T>[], handler: (event: MouseEvent | TouchEvent | FocusEvent) => void, eventType?: EventType, eventListenerOptions?: AddEventListenerOptions): void; | ||
| export {}; | ||
| //# sourceMappingURL=useOnClickOutside.d.ts.map |
| {"version":3,"file":"useOnClickOutside.d.ts","sourceRoot":"","sources":["../../src/useOnClickOutside/useOnClickOutside.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAItC,6BAA6B;AAC7B,KAAK,SAAS,GACV,WAAW,GACX,SAAS,GACT,YAAY,GACZ,UAAU,GACV,SAAS,GACT,UAAU,CAAA;AAEd;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,EACnE,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,EAAE,EAClC,OAAO,EAAE,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,GAAG,UAAU,KAAK,IAAI,EAC9D,SAAS,GAAE,SAAuB,EAClC,oBAAoB,GAAE,uBAA4B,GACjD,IAAI,CAwBN"} |
| import { useEventListener as u } from "../useEventListener/useEventListener.js"; | ||
| function d(t, i, s = "mousedown", o = {}) { | ||
| u( | ||
| s, | ||
| (e) => { | ||
| const n = e.target; | ||
| if (!n || !n.isConnected) | ||
| return; | ||
| (Array.isArray(t) ? t.filter((r) => !!r.current).every((r) => r.current && !r.current.contains(n)) : t.current && !t.current.contains(n)) && i(e); | ||
| }, | ||
| void 0, | ||
| o | ||
| ); | ||
| } | ||
| export { | ||
| d as useOnClickOutside | ||
| }; |
| export * from './useQueryString'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useQueryString/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA"} |
| import { useQueryString as o } from "./useQueryString.js"; | ||
| export { | ||
| o as useQueryString | ||
| }; |
| type Nullable<T> = { | ||
| [P in keyof T]: T[P] | null; | ||
| }; | ||
| type QueryParamsValue = Nullable<string | number | boolean | undefined>; | ||
| type QueryParams = Record<string, QueryParamsValue>; | ||
| export declare const useQueryString: (searchParams: URLSearchParams) => { | ||
| createQueryString: (baseUrl: string, params: QueryParams) => string; | ||
| }; | ||
| export {}; | ||
| //# sourceMappingURL=useQueryString.d.ts.map |
| {"version":3,"file":"useQueryString.d.ts","sourceRoot":"","sources":["../../src/useQueryString/useQueryString.ts"],"names":[],"mappings":"AAEA,KAAK,QAAQ,CAAC,CAAC,IAAI;KACd,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI;CAC5B,CAAC;AACJ,KAAK,gBAAgB,GAAG,QAAQ,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAA;AACvE,KAAK,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;AAEnD,eAAO,MAAM,cAAc,GAAI,cAAc,eAAe;iCAER,MAAM,UAAU,WAAW;CAe9E,CAAC"} |
| import { useCallback as c } from "react"; | ||
| const g = (e) => ({ createQueryString: c((i, o) => { | ||
| const t = new URLSearchParams(e?.toString()); | ||
| return Object.entries(o).forEach(([n, r]) => { | ||
| r === null || r === "" || r === void 0 ? t.delete(n) : t.set(n, String(r)); | ||
| }), `${i}?${t.toString()}`; | ||
| }, [e]) }); | ||
| export { | ||
| g as useQueryString | ||
| }; |
| export * from './useReadLocalStorage'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useReadLocalStorage/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA"} |
| import { useReadLocalStorage as a } from "./useReadLocalStorage.js"; | ||
| export { | ||
| a as useReadLocalStorage | ||
| }; |
| /** | ||
| * Represents the type for the options available when reading from local storage. | ||
| * @template T - The type of the stored value. | ||
| */ | ||
| type Options<T, InitializeWithValue extends boolean | undefined> = { | ||
| /** Custom deserializer function to convert the stored string value to the desired type (optional). */ | ||
| deserializer?: (value: string) => T; | ||
| /** If `true` (default), the hook will initialize reading the local storage. In SSR, you should set it to `false`, returning `undefined` initially. */ | ||
| initializeWithValue: InitializeWithValue; | ||
| }; | ||
| export declare function useReadLocalStorage<T>(key: string, options: Options<T, false>): T | null | undefined; | ||
| export declare function useReadLocalStorage<T>(key: string, options?: Partial<Options<T, true>>): T | null; | ||
| export {}; | ||
| //# sourceMappingURL=useReadLocalStorage.d.ts.map |
| {"version":3,"file":"useReadLocalStorage.d.ts","sourceRoot":"","sources":["../../src/useReadLocalStorage/useReadLocalStorage.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,KAAK,OAAO,CAAC,CAAC,EAAE,mBAAmB,SAAS,OAAO,GAAG,SAAS,IAAI;IACjE,sGAAsG;IACtG,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,CAAC,CAAA;IACnC,sJAAsJ;IACtJ,mBAAmB,EAAE,mBAAmB,CAAA;CACzC,CAAA;AAGD,wBAAgB,mBAAmB,CAAC,CAAC,EACnC,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,GACzB,CAAC,GAAG,IAAI,GAAG,SAAS,CAAA;AAEvB,wBAAgB,mBAAmB,CAAC,CAAC,EACnC,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,GAClC,CAAC,GAAG,IAAI,CAAA"} |
| import { useCallback as a, useState as S, useEffect as w } from "react"; | ||
| import { useEventListener as c } from "../useEventListener/useEventListener.js"; | ||
| const d = typeof window > "u"; | ||
| function m(e, t = {}) { | ||
| let { initializeWithValue: o = !0 } = t; | ||
| d && (o = !1); | ||
| const l = a( | ||
| (r) => { | ||
| if (t.deserializer) | ||
| return t.deserializer(r); | ||
| if (r === "undefined") | ||
| return; | ||
| let s; | ||
| try { | ||
| s = JSON.parse(r); | ||
| } catch (g) { | ||
| return console.error("Error parsing JSON:", g), null; | ||
| } | ||
| return s; | ||
| }, | ||
| [t] | ||
| ), n = a(() => { | ||
| if (d) | ||
| return null; | ||
| try { | ||
| const r = window.localStorage.getItem(e); | ||
| return r ? l(r) : null; | ||
| } catch (r) { | ||
| return console.warn(`Error reading localStorage key “${e}”:`, r), null; | ||
| } | ||
| }, [e, l]), [f, i] = S(() => { | ||
| if (o) | ||
| return n(); | ||
| }); | ||
| w(() => { | ||
| i(n()); | ||
| }, [e]); | ||
| const u = a( | ||
| (r) => { | ||
| r.key && r.key !== e || i(n()); | ||
| }, | ||
| [e, n] | ||
| ); | ||
| return c("storage", u), c("local-storage", u), f; | ||
| } | ||
| export { | ||
| m as useReadLocalStorage | ||
| }; |
| export * from './useResizeObserver'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useResizeObserver/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA"} |
| import { useResizeObserver as s } from "./useResizeObserver.js"; | ||
| export { | ||
| s as useResizeObserver | ||
| }; |
| import { RefObject } from 'react'; | ||
| /** The size of the observed element. */ | ||
| type Size = { | ||
| /** The width of the observed element. */ | ||
| width: number | undefined; | ||
| /** The height of the observed element. */ | ||
| height: number | undefined; | ||
| }; | ||
| /** The options for the ResizeObserver. */ | ||
| type UseResizeObserverOptions<T extends HTMLElement = HTMLElement> = { | ||
| /** The ref of the element to observe. */ | ||
| ref: RefObject<T>; | ||
| /** | ||
| * When using `onResize`, the hook doesn't re-render on element size changes; it delegates handling to the provided callback. | ||
| * @default undefined | ||
| */ | ||
| onResize?: (size: Size) => void; | ||
| /** | ||
| * The box model to use for the ResizeObserver. | ||
| * @default 'content-box' | ||
| */ | ||
| box?: 'border-box' | 'content-box' | 'device-pixel-content-box'; | ||
| }; | ||
| /** | ||
| * Custom hook that observes the size of an element using the [`ResizeObserver API`](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver). | ||
| * @template T - The type of the element to observe. | ||
| * @param {UseResizeObserverOptions<T>} options - The options for the ResizeObserver. | ||
| * @returns {Size} - The size of the observed element. | ||
| * @public | ||
| * @see [Documentation](https://usehooks-ts.com/react-hook/use-resize-observer) | ||
| * @example | ||
| * ```tsx | ||
| * const myRef = useRef(null); | ||
| * const { width = 0, height = 0 } = useResizeObserver({ | ||
| * ref: myRef, | ||
| * box: 'content-box', | ||
| * }); | ||
| * | ||
| * <div ref={myRef}>Hello, world!</div> | ||
| * ``` | ||
| */ | ||
| export declare function useResizeObserver<T extends HTMLElement = HTMLElement>(options: UseResizeObserverOptions<T>): Size; | ||
| export {}; | ||
| //# sourceMappingURL=useResizeObserver.d.ts.map |
| {"version":3,"file":"useResizeObserver.d.ts","sourceRoot":"","sources":["../../src/useResizeObserver/useResizeObserver.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAItC,wCAAwC;AACxC,KAAK,IAAI,GAAG;IACV,yCAAyC;IACzC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;IACzB,0CAA0C;IAC1C,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;CAC3B,CAAA;AAED,0CAA0C;AAC1C,KAAK,wBAAwB,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,IAAI;IACnE,yCAAyC;IACzC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,CAAA;IACjB;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAA;IAC/B;;;OAGG;IACH,GAAG,CAAC,EAAE,YAAY,GAAG,aAAa,GAAG,0BAA0B,CAAA;CAChE,CAAA;AAOD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,EACnE,OAAO,EAAE,wBAAwB,CAAC,CAAC,CAAC,GACnC,IAAI,CAmDN"} |
| import { useState as g, useRef as z, useEffect as x } from "react"; | ||
| import { useIsMounted as l } from "../useIsMounted/useIsMounted.js"; | ||
| const w = { | ||
| width: void 0, | ||
| height: void 0 | ||
| }; | ||
| function B(t) { | ||
| const { ref: e, box: i = "content-box" } = t, [{ width: v, height: a }, b] = g(w), s = l(), n = z({ ...w }), r = z(void 0); | ||
| return r.current = t.onResize, x(() => { | ||
| if (!e.current || typeof window > "u" || !("ResizeObserver" in window)) return; | ||
| const u = new ResizeObserver(([d]) => { | ||
| const h = i === "border-box" ? "borderBoxSize" : i === "device-pixel-content-box" ? "devicePixelContentBoxSize" : "contentBoxSize", o = S(d, h, "inlineSize"), c = S(d, h, "blockSize"); | ||
| if (n.current.width !== o || n.current.height !== c) { | ||
| const f = { width: o, height: c }; | ||
| n.current.width = o, n.current.height = c, r.current ? r.current(f) : s() && b(f); | ||
| } | ||
| }); | ||
| return u.observe(e.current, { box: i }), () => { | ||
| u.disconnect(); | ||
| }; | ||
| }, [i, e, s]), { width: v, height: a }; | ||
| } | ||
| function S(t, e, i) { | ||
| return t[e] ? Array.isArray(t[e]) ? t[e][0][i] : ( | ||
| // @ts-ignore Support Firefox's non-standard behavior | ||
| t[e][i] | ||
| ) : e === "contentBoxSize" ? t.contentRect[i === "inlineSize" ? "width" : "height"] : void 0; | ||
| } | ||
| export { | ||
| B as useResizeObserver | ||
| }; |
| export * from './useScreen'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useScreen/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA"} |
| import { useScreen as o } from "./useScreen.js"; | ||
| export { | ||
| o as useScreen | ||
| }; |
| /** | ||
| * The hooks options. | ||
| * @template InitializeWithValue - If `true` (default), the hook will initialize reading the screen dimensions. In SSR, you should set it to `false`, returning `undefined` initially. | ||
| */ | ||
| type UseScreenOptions<InitializeWithValue extends boolean | undefined> = { | ||
| /** | ||
| * If `true` (default), the hook will initialize reading the screen dimensions. In SSR, you should set it to `false`, returning `undefined` initially. | ||
| * @default true | ||
| */ | ||
| initializeWithValue: InitializeWithValue; | ||
| /** | ||
| * The delay in milliseconds before the state is updated (disabled by default for retro-compatibility). | ||
| * @default undefined | ||
| */ | ||
| debounceDelay?: number; | ||
| }; | ||
| export declare function useScreen(options: UseScreenOptions<false>): Screen | undefined; | ||
| export declare function useScreen(options?: Partial<UseScreenOptions<true>>): Screen; | ||
| export {}; | ||
| //# sourceMappingURL=useScreen.d.ts.map |
| {"version":3,"file":"useScreen.d.ts","sourceRoot":"","sources":["../../src/useScreen/useScreen.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,KAAK,gBAAgB,CAAC,mBAAmB,SAAS,OAAO,GAAG,SAAS,IAAI;IACvE;;;OAGG;IACH,mBAAmB,EAAE,mBAAmB,CAAA;IACxC;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB,CAAA;AAKD,wBAAgB,SAAS,CAAC,OAAO,EAAE,gBAAgB,CAAC,KAAK,CAAC,GAAG,MAAM,GAAG,SAAS,CAAA;AAE/E,wBAAgB,SAAS,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,GAAG,MAAM,CAAA"} |
| import { useState as w } from "react"; | ||
| import { useDebounceCallback as b } from "../useDebounceCallback/useDebounceCallback.js"; | ||
| import { useEventListener as v } from "../useEventListener/useEventListener.js"; | ||
| import { useIsomorphicLayoutEffect as D } from "../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js"; | ||
| const c = typeof window > "u"; | ||
| function x(e = {}) { | ||
| let { initializeWithValue: t = !0 } = e; | ||
| c && (t = !1); | ||
| const n = () => { | ||
| if (!c) | ||
| return window.screen; | ||
| }, [u, r] = w(() => { | ||
| if (t) | ||
| return n(); | ||
| }), s = b( | ||
| r, | ||
| e.debounceDelay | ||
| ); | ||
| function i() { | ||
| const o = n(), a = e.debounceDelay ? s : r; | ||
| if (o) { | ||
| const { | ||
| width: f, | ||
| height: d, | ||
| availHeight: l, | ||
| availWidth: S, | ||
| colorDepth: h, | ||
| orientation: m, | ||
| pixelDepth: p | ||
| } = o; | ||
| a({ | ||
| width: f, | ||
| height: d, | ||
| availHeight: l, | ||
| availWidth: S, | ||
| colorDepth: h, | ||
| orientation: m, | ||
| pixelDepth: p | ||
| }); | ||
| } | ||
| } | ||
| return v("resize", i), D(() => { | ||
| i(); | ||
| }, []), u; | ||
| } | ||
| export { | ||
| x as useScreen | ||
| }; |
| export * from './useScript'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useScript/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA"} |
| import { useScript as o } from "./useScript.js"; | ||
| export { | ||
| o as useScript | ||
| }; |
| /** Script loading status. */ | ||
| type UseScriptStatus = 'idle' | 'loading' | 'ready' | 'error'; | ||
| /** Hook options. */ | ||
| type UseScriptOptions = { | ||
| /** If `true`, prevents the script from being loaded (optional). */ | ||
| shouldPreventLoad?: boolean; | ||
| /** If `true`, removes the script from the DOM when the component unmounts (optional). */ | ||
| removeOnUnmount?: boolean; | ||
| /** Script's `id` (optional). */ | ||
| id?: string; | ||
| }; | ||
| /** | ||
| * Custom hook that dynamically loads scripts and tracking their loading status. | ||
| * @param {string | null} src - The source URL of the script to load. Set to `null` or omit to prevent loading (optional). | ||
| * @param {UseScriptOptions} [options] - Additional options for controlling script loading (optional). | ||
| * @returns {UseScriptStatus} The status of the script loading, which can be one of 'idle', 'loading', 'ready', or 'error'. | ||
| * @see [Documentation](https://usehooks-ts.com/react-hook/use-script) | ||
| * @example | ||
| * const scriptStatus = useScript('https://example.com/script.js', { removeOnUnmount: true }); | ||
| * // Access the status of the script loading (e.g., 'loading', 'ready', 'error'). | ||
| */ | ||
| export declare function useScript(src: string | null, options?: UseScriptOptions): UseScriptStatus; | ||
| export {}; | ||
| //# sourceMappingURL=useScript.d.ts.map |
| {"version":3,"file":"useScript.d.ts","sourceRoot":"","sources":["../../src/useScript/useScript.ts"],"names":[],"mappings":"AAEA,6BAA6B;AAC7B,KAAK,eAAe,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,CAAA;AAE7D,oBAAoB;AACpB,KAAK,gBAAgB,GAAG;IACtB,mEAAmE;IACnE,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,yFAAyF;IACzF,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,gCAAgC;IAChC,EAAE,CAAC,EAAE,MAAM,CAAA;CACZ,CAAA;AA6BD;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CACvB,GAAG,EAAE,MAAM,GAAG,IAAI,EAClB,OAAO,CAAC,EAAE,gBAAgB,GACzB,eAAe,CAsFjB"} |
| import { useState as v, useEffect as f } from "react"; | ||
| const s = /* @__PURE__ */ new Map(); | ||
| function m(t) { | ||
| const r = document.querySelector( | ||
| `script[src="${t}"]` | ||
| ), u = r?.getAttribute("data-status"); | ||
| return { | ||
| node: r, | ||
| status: u | ||
| }; | ||
| } | ||
| function p(t, r) { | ||
| const [u, i] = v(() => !t || r?.shouldPreventLoad ? "idle" : typeof window > "u" ? "loading" : s.get(t) ?? "loading"); | ||
| return f(() => { | ||
| if (!t || r?.shouldPreventLoad) | ||
| return; | ||
| const n = s.get(t); | ||
| if (n === "ready" || n === "error") { | ||
| i(n); | ||
| return; | ||
| } | ||
| const c = m(t); | ||
| let e = c.node; | ||
| if (e) | ||
| i(c.status ?? n ?? "loading"); | ||
| else { | ||
| e = document.createElement("script"), e.src = t, e.async = !0, r?.id && (e.id = r.id), e.setAttribute("data-status", "loading"), document.body.appendChild(e); | ||
| const a = (o) => { | ||
| const l = o.type === "load" ? "ready" : "error"; | ||
| e?.setAttribute("data-status", l); | ||
| }; | ||
| e.addEventListener("load", a), e.addEventListener("error", a); | ||
| } | ||
| const d = (a) => { | ||
| const o = a.type === "load" ? "ready" : "error"; | ||
| i(o), s.set(t, o); | ||
| }; | ||
| return e.addEventListener("load", d), e.addEventListener("error", d), () => { | ||
| e && (e.removeEventListener("load", d), e.removeEventListener("error", d)), e && r?.removeOnUnmount && (e.remove(), s.delete(t)); | ||
| }; | ||
| }, [t, r?.shouldPreventLoad, r?.removeOnUnmount, r?.id]), u; | ||
| } | ||
| export { | ||
| p as useScript | ||
| }; |
| export * from './useScrollLock'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useScrollLock/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA"} |
| import { useScrollLock as c } from "./useScrollLock.js"; | ||
| export { | ||
| c as useScrollLock | ||
| }; |
| /** Hook options. */ | ||
| type UseScrollLockOptions = { | ||
| /** | ||
| * Whether to lock the scroll initially. | ||
| * @default true | ||
| */ | ||
| autoLock?: boolean; | ||
| /** | ||
| * The target element to lock the scroll (default is the body element). | ||
| * @default document.body | ||
| */ | ||
| lockTarget?: HTMLElement | string; | ||
| /** | ||
| * Whether to prevent width reflow when locking the scroll. | ||
| * @default true | ||
| */ | ||
| widthReflow?: boolean; | ||
| }; | ||
| /** Hook return type. */ | ||
| type UseScrollLockReturn = { | ||
| /** Whether the scroll is locked. */ | ||
| isLocked: boolean; | ||
| /** Lock the scroll. */ | ||
| lock: () => void; | ||
| /** Unlock the scroll. */ | ||
| unlock: () => void; | ||
| }; | ||
| /** | ||
| * A custom hook that locks and unlocks scroll. | ||
| * @param {UseScrollLockOptions} [options] - Options to configure the hook, by default it will lock the scroll automatically. | ||
| * @returns {UseScrollLockReturn} - An object containing the lock and unlock functions. | ||
| * @public | ||
| * @see [Documentation](https://usehooks-ts.com/react-hook/use-scroll-lock) | ||
| * @example | ||
| * ```tsx | ||
| * // Lock the scroll when the modal is mounted, and unlock it when it's unmounted | ||
| * useScrollLock() | ||
| * ``` | ||
| * @example | ||
| * ```tsx | ||
| * // Manually lock and unlock the scroll | ||
| * const { lock, unlock } = useScrollLock({ autoLock: false }) | ||
| * | ||
| * return ( | ||
| * <div> | ||
| * <button onClick={lock}>Lock</button> | ||
| * <button onClick={unlock}>Unlock</button> | ||
| * </div> | ||
| * ) | ||
| * ``` | ||
| */ | ||
| export declare function useScrollLock(options?: UseScrollLockOptions): UseScrollLockReturn; | ||
| export {}; | ||
| //# sourceMappingURL=useScrollLock.d.ts.map |
| {"version":3,"file":"useScrollLock.d.ts","sourceRoot":"","sources":["../../src/useScrollLock/useScrollLock.ts"],"names":[],"mappings":"AAIA,oBAAoB;AACpB,KAAK,oBAAoB,GAAG;IAC1B;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;;OAGG;IACH,UAAU,CAAC,EAAE,WAAW,GAAG,MAAM,CAAA;IACjC;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB,CAAA;AAED,wBAAwB;AACxB,KAAK,mBAAmB,GAAG;IACzB,oCAAoC;IACpC,QAAQ,EAAE,OAAO,CAAA;IACjB,uBAAuB;IACvB,IAAI,EAAE,MAAM,IAAI,CAAA;IAChB,yBAAyB;IACzB,MAAM,EAAE,MAAM,IAAI,CAAA;CACnB,CAAA;AASD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,aAAa,CAC3B,OAAO,GAAE,oBAAyB,GACjC,mBAAmB,CA0ErB"} |
| import { useState as y, useRef as d } from "react"; | ||
| import { useIsomorphicLayoutEffect as w } from "../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js"; | ||
| const R = typeof window > "u"; | ||
| function S(s = {}) { | ||
| const { autoLock: o = !0, lockTarget: e, widthReflow: n = !0 } = s, [l, c] = y(!1), t = d(null), r = d(null), u = () => { | ||
| if (t.current) { | ||
| const { overflow: f, paddingRight: g } = t.current.style; | ||
| if (r.current = { overflow: f, paddingRight: g }, n) { | ||
| const a = t.current === document.body ? window.innerWidth : t.current.offsetWidth, h = parseInt(window.getComputedStyle(t.current).paddingRight, 10) || 0, p = a - t.current.scrollWidth; | ||
| t.current.style.paddingRight = `${p + h}px`; | ||
| } | ||
| t.current.style.overflow = "hidden", c(!0); | ||
| } | ||
| }, i = () => { | ||
| t.current && r.current && (t.current.style.overflow = r.current.overflow, n && (t.current.style.paddingRight = r.current.paddingRight)), c(!1); | ||
| }; | ||
| return w(() => { | ||
| if (!R) | ||
| return e && (t.current = typeof e == "string" ? document.querySelector(e) : e), t.current || (t.current = document.body), o && u(), () => { | ||
| i(); | ||
| }; | ||
| }, [o, e, n]), { isLocked: l, lock: u, unlock: i }; | ||
| } | ||
| export { | ||
| S as useScrollLock | ||
| }; |
| export * from './useSessionStorage'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useSessionStorage/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA"} |
| import { useSessionStorage as r } from "./useSessionStorage.js"; | ||
| export { | ||
| r as useSessionStorage | ||
| }; |
| import { Dispatch, SetStateAction } from 'react'; | ||
| declare global { | ||
| interface WindowEventMap { | ||
| 'session-storage': CustomEvent; | ||
| } | ||
| } | ||
| /** | ||
| * Represents the options for customizing the behavior of serialization and deserialization. | ||
| * @template T - The type of the state to be stored in session storage. | ||
| */ | ||
| type UseSessionStorageOptions<T> = { | ||
| /** A function to serialize the value before storing it. */ | ||
| serializer?: (value: T) => string; | ||
| /** A function to deserialize the stored value. */ | ||
| deserializer?: (value: string) => T; | ||
| /** | ||
| * If `true` (default), the hook will initialize reading the session storage. In SSR, you should set it to `false`, returning the initial value initially. | ||
| * @default true | ||
| */ | ||
| initializeWithValue?: boolean; | ||
| }; | ||
| /** | ||
| * Custom hook that uses the [`sessionStorage API`](https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage) to persist state across page reloads. | ||
| * @template T - The type of the state to be stored in session storage. | ||
| * @param {string} key - The key under which the value will be stored in session storage. | ||
| * @param {T | (() => T)} initialValue - The initial value of the state or a function that returns the initial value. | ||
| * @param {?UseSessionStorageOptions<T>} [options] - Options for customizing the behavior of serialization and deserialization (optional). | ||
| * @returns {[T, Dispatch<SetStateAction<T>>, () => void]} A tuple containing the stored value, a function to set the value and a function to remove the key from storage. | ||
| * @public | ||
| * @see [Documentation](https://usehooks-ts.com/react-hook/use-session-storage) | ||
| * @example | ||
| * ```tsx | ||
| * const [count, setCount, removeCount] = useSessionStorage('count', 0); | ||
| * // Access the `count` value, the `setCount` function to update it and `removeCount` function to remove the key from storage. | ||
| * ``` | ||
| */ | ||
| export declare function useSessionStorage<T>(key: string, initialValue: T | (() => T), options?: UseSessionStorageOptions<T>): [T, Dispatch<SetStateAction<T>>, () => void]; | ||
| export {}; | ||
| //# sourceMappingURL=useSessionStorage.d.ts.map |
| {"version":3,"file":"useSessionStorage.d.ts","sourceRoot":"","sources":["../../src/useSessionStorage/useSessionStorage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAKrD,OAAO,CAAC,MAAM,CAAC;IAEb,UAAU,cAAc;QACtB,iBAAiB,EAAE,WAAW,CAAA;KAC/B;CACF;AAED;;;GAGG;AACH,KAAK,wBAAwB,CAAC,CAAC,IAAI;IACjC,2DAA2D;IAC3D,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,CAAA;IACjC,kDAAkD;IAClD,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,CAAC,CAAA;IACnC;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAA;CAC9B,CAAA;AAID;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EACjC,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,EAC3B,OAAO,GAAE,wBAAwB,CAAC,CAAC,CAAM,GACxC,CAAC,CAAC,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,IAAI,CAAC,CA2I9C"} |
| import { useCallback as i, useState as F, useEffect as p } from "react"; | ||
| import { useEventCallback as u } from "../useEventCallback/useEventCallback.js"; | ||
| import { useEventListener as w } from "../useEventListener/useEventListener.js"; | ||
| const a = typeof window > "u"; | ||
| function J(n, r, o = {}) { | ||
| const { initializeWithValue: S = !0 } = o, m = i( | ||
| (e) => o.serializer ? o.serializer(e) : JSON.stringify(e), | ||
| [o] | ||
| ), d = i( | ||
| (e) => { | ||
| if (o.deserializer) | ||
| return o.deserializer(e); | ||
| if (e === "undefined") | ||
| return; | ||
| const t = r instanceof Function ? r() : r; | ||
| let g; | ||
| try { | ||
| g = JSON.parse(e); | ||
| } catch (z) { | ||
| return console.error("Error parsing JSON:", z), t; | ||
| } | ||
| return g; | ||
| }, | ||
| [o, r] | ||
| ), s = i(() => { | ||
| const e = r instanceof Function ? r() : r; | ||
| if (a) | ||
| return e; | ||
| try { | ||
| const t = window.sessionStorage.getItem(n); | ||
| return t ? d(t) : e; | ||
| } catch (t) { | ||
| return console.warn(`Error reading sessionStorage key “${n}”:`, t), e; | ||
| } | ||
| }, [r, n, d]), [h, c] = F(() => S ? s() : r instanceof Function ? r() : r), E = u((e) => { | ||
| a && console.warn( | ||
| `Tried setting sessionStorage key “${n}” even though environment is not a client` | ||
| ); | ||
| try { | ||
| const t = e instanceof Function ? e(s()) : e; | ||
| window.sessionStorage.setItem(n, m(t)), c(t), window.dispatchEvent(new StorageEvent("session-storage", { key: n })); | ||
| } catch (t) { | ||
| console.warn(`Error setting sessionStorage key “${n}”:`, t); | ||
| } | ||
| }), v = u(() => { | ||
| a && console.warn( | ||
| `Tried removing sessionStorage key “${n}” even though environment is not a client` | ||
| ); | ||
| const e = r instanceof Function ? r() : r; | ||
| window.sessionStorage.removeItem(n), c(e), window.dispatchEvent(new StorageEvent("session-storage", { key: n })); | ||
| }); | ||
| p(() => { | ||
| c(s()); | ||
| }, [n]); | ||
| const f = i( | ||
| (e) => { | ||
| e.key && e.key !== n || c(s()); | ||
| }, | ||
| [n, s] | ||
| ); | ||
| return w("storage", f), w("session-storage", f), [h, E, v]; | ||
| } | ||
| export { | ||
| J as useSessionStorage | ||
| }; |
| export * from './useStep'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useStep/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA"} |
| import { useStep as p } from "./useStep.js"; | ||
| export { | ||
| p as useStep | ||
| }; |
| import { Dispatch, SetStateAction } from 'react'; | ||
| /** Represents the second element of the output of the `useStep` hook. */ | ||
| type UseStepActions = { | ||
| /** Go to the next step in the process. */ | ||
| goToNextStep: () => void; | ||
| /** Go to the previous step in the process. */ | ||
| goToPrevStep: () => void; | ||
| /** Reset the step to the initial step. */ | ||
| reset: () => void; | ||
| /** Check if the next step is available. */ | ||
| canGoToNextStep: boolean; | ||
| /** Check if the previous step is available. */ | ||
| canGoToPrevStep: boolean; | ||
| /** Set the current step to a specific value. */ | ||
| setStep: Dispatch<SetStateAction<number>>; | ||
| }; | ||
| /** | ||
| * Custom hook that manages and navigates between steps in a multi-step process. | ||
| * @param {number} maxStep - The maximum step in the process. | ||
| * @returns {[number, UseStepActions]} An tuple containing the current step and helper functions for navigating steps. | ||
| * @public | ||
| * @see [Documentation](https://usehooks-ts.com/react-hook/use-step) | ||
| * @example | ||
| * ```tsx | ||
| * const [currentStep, { goToNextStep, goToPrevStep, reset, canGoToNextStep, canGoToPrevStep, setStep }] = useStep(3); | ||
| * // Access and use the current step and provided helper functions. | ||
| * ``` | ||
| */ | ||
| export declare function useStep(maxStep: number): [number, UseStepActions]; | ||
| export {}; | ||
| //# sourceMappingURL=useStep.d.ts.map |
| {"version":3,"file":"useStep.d.ts","sourceRoot":"","sources":["../../src/useStep/useStep.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAErD,yEAAyE;AACzE,KAAK,cAAc,GAAG;IACpB,0CAA0C;IAC1C,YAAY,EAAE,MAAM,IAAI,CAAA;IACxB,8CAA8C;IAC9C,YAAY,EAAE,MAAM,IAAI,CAAA;IACxB,0CAA0C;IAC1C,KAAK,EAAE,MAAM,IAAI,CAAA;IACjB,2CAA2C;IAC3C,eAAe,EAAE,OAAO,CAAA;IACxB,+CAA+C;IAC/C,eAAe,EAAE,OAAO,CAAA;IACxB,gDAAgD;IAChD,OAAO,EAAE,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAA;CAC1C,CAAA;AAID;;;;;;;;;;;GAWG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAgDjE"} |
| import { useState as a, useCallback as n } from "react"; | ||
| function l(r) { | ||
| const [e, o] = a(1), c = e + 1 <= r, s = e - 1 > 0, S = n( | ||
| (t) => { | ||
| const u = t instanceof Function ? t(e) : t; | ||
| if (u >= 1 && u <= r) { | ||
| o(u); | ||
| return; | ||
| } | ||
| throw new Error("Step not valid"); | ||
| }, | ||
| [r, e] | ||
| ), i = n(() => { | ||
| c && o((t) => t + 1); | ||
| }, [c]), p = n(() => { | ||
| s && o((t) => t - 1); | ||
| }, [s]), f = n(() => { | ||
| o(1); | ||
| }, []); | ||
| return [ | ||
| e, | ||
| { | ||
| goToNextStep: i, | ||
| goToPrevStep: p, | ||
| canGoToNextStep: c, | ||
| canGoToPrevStep: s, | ||
| setStep: S, | ||
| reset: f | ||
| } | ||
| ]; | ||
| } | ||
| export { | ||
| l as useStep | ||
| }; |
| export * from './useTernaryDarkMode'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useTernaryDarkMode/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA"} |
| import { useTernaryDarkMode as o } from "./useTernaryDarkMode.js"; | ||
| export { | ||
| o as useTernaryDarkMode | ||
| }; |
| import { Dispatch, SetStateAction } from 'react'; | ||
| /** Ternary dark mode options. */ | ||
| export type TernaryDarkMode = 'system' | 'dark' | 'light'; | ||
| /** Options for the `useTernaryDarkMode` hook. */ | ||
| export type TernaryDarkModeOptions = { | ||
| /** | ||
| * The default value for the dark mode. | ||
| * @default 'system' | ||
| */ | ||
| defaultValue?: TernaryDarkMode; | ||
| /** | ||
| * The key for storing dark mode preference in local storage. | ||
| * @default 'usehooks-ts-ternary-dark-mode' | ||
| */ | ||
| localStorageKey?: string; | ||
| /** | ||
| * If `true` (default), the hook will initialize reading `localStorage`. In SSR, you should set it to `false`, returning default values initially. | ||
| * @default true | ||
| */ | ||
| initializeWithValue?: boolean; | ||
| }; | ||
| /** Represents the return type of the `useTernaryDarkMode` hook. */ | ||
| export type TernaryDarkModeReturn = { | ||
| /** The current state of the dark mode. */ | ||
| isDarkMode: boolean; | ||
| /** The current state of the dark mode. */ | ||
| ternaryDarkMode: TernaryDarkMode; | ||
| /** A function to set the dark mode state. */ | ||
| setTernaryDarkMode: Dispatch<SetStateAction<TernaryDarkMode>>; | ||
| /** A function to toggle the dark mode state. */ | ||
| toggleTernaryDarkMode: () => void; | ||
| }; | ||
| /** | ||
| * Custom hook that manages ternary (system, dark, light) dark mode with local storage support. | ||
| * @param {?TernaryDarkModeOptions | string} [options] - Options or the local storage key for the hook. | ||
| * @returns {TernaryDarkModeReturn} An object containing the dark mode state and helper functions. | ||
| * @public | ||
| * @see [Documentation](https://usehooks-ts.com/react-hook/use-ternary-dark-mode) | ||
| * @example | ||
| * ```tsx | ||
| * const { isDarkMode, ternaryDarkMode, setTernaryDarkMode, toggleTernaryDarkMode } = useTernaryDarkMode({ defaultValue: 'dark' }); | ||
| * // Access and use the dark mode state and provided helper functions. | ||
| * ``` | ||
| */ | ||
| export declare function useTernaryDarkMode({ defaultValue, localStorageKey, initializeWithValue, }?: TernaryDarkModeOptions): TernaryDarkModeReturn; | ||
| //# sourceMappingURL=useTernaryDarkMode.d.ts.map |
| {"version":3,"file":"useTernaryDarkMode.d.ts","sourceRoot":"","sources":["../../src/useTernaryDarkMode/useTernaryDarkMode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAQrD,iCAAiC;AACjC,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAA;AAEzD,iDAAiD;AACjD,MAAM,MAAM,sBAAsB,GAAG;IACnC;;;OAGG;IACH,YAAY,CAAC,EAAE,eAAe,CAAA;IAC9B;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAA;CAC9B,CAAA;AAED,mEAAmE;AACnE,MAAM,MAAM,qBAAqB,GAAG;IAClC,0CAA0C;IAC1C,UAAU,EAAE,OAAO,CAAA;IACnB,0CAA0C;IAC1C,eAAe,EAAE,eAAe,CAAA;IAChC,6CAA6C;IAC7C,kBAAkB,EAAE,QAAQ,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC,CAAA;IAC7D,gDAAgD;IAChD,qBAAqB,EAAE,MAAM,IAAI,CAAA;CAClC,CAAA;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,YAAuB,EACvB,eAAmC,EACnC,mBAA0B,GAC3B,GAAE,sBAA2B,GAAG,qBAAqB,CAsBrD"} |
| import { useLocalStorage as c } from "../useLocalStorage/useLocalStorage.js"; | ||
| import { useMediaQuery as m } from "../useMediaQuery/useMediaQuery.js"; | ||
| const y = "(prefers-color-scheme: dark)", M = "usehooks-ts-ternary-dark-mode"; | ||
| function f({ | ||
| defaultValue: t = "system", | ||
| localStorageKey: n = M, | ||
| initializeWithValue: o = !0 | ||
| } = {}) { | ||
| const a = m(y, { initializeWithValue: o }), [e, s] = c(n, t, { | ||
| initializeWithValue: o | ||
| }); | ||
| return { | ||
| isDarkMode: e === "dark" || e === "system" && a, | ||
| ternaryDarkMode: e, | ||
| setTernaryDarkMode: s, | ||
| toggleTernaryDarkMode: () => { | ||
| const r = ["light", "system", "dark"]; | ||
| s((d) => { | ||
| const k = (r.indexOf(d) + 1) % r.length; | ||
| return r[k]; | ||
| }); | ||
| } | ||
| }; | ||
| } | ||
| export { | ||
| f as useTernaryDarkMode | ||
| }; |
| export * from './useTimeout'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useTimeout/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA"} |
| import { useTimeout as m } from "./useTimeout.js"; | ||
| export { | ||
| m as useTimeout | ||
| }; |
| /** | ||
| * Custom hook that handles timeouts in React components using the [`setTimeout API`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout). | ||
| * @param {() => void} callback - The function to be executed when the timeout elapses. | ||
| * @param {number | null} delay - The duration (in milliseconds) for the timeout. Set to `null` to clear the timeout. | ||
| * @returns {void} This hook does not return anything. | ||
| * @public | ||
| * @see [Documentation](https://usehooks-ts.com/react-hook/use-timeout) | ||
| * @example | ||
| * ```tsx | ||
| * // Usage of useTimeout hook | ||
| * useTimeout(() => { | ||
| * // Code to be executed after the specified delay | ||
| * }, 1000); // Set a timeout of 1000 milliseconds (1 second) | ||
| * ``` | ||
| */ | ||
| export declare function useTimeout(callback: () => void, delay: number | null): void; | ||
| //# sourceMappingURL=useTimeout.d.ts.map |
| {"version":3,"file":"useTimeout.d.ts","sourceRoot":"","sources":["../../src/useTimeout/useTimeout.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAwB3E"} |
| import { useRef as u, useEffect as f } from "react"; | ||
| import { useIsomorphicLayoutEffect as i } from "../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js"; | ||
| function n(e, t) { | ||
| const r = u(e); | ||
| i(() => { | ||
| r.current = e; | ||
| }, [e]), f(() => { | ||
| if (!t && t !== 0) | ||
| return; | ||
| const o = setTimeout(() => { | ||
| r.current(); | ||
| }, t); | ||
| return () => { | ||
| clearTimeout(o); | ||
| }; | ||
| }, [t]); | ||
| } | ||
| export { | ||
| n as useTimeout | ||
| }; |
| export * from './useToggle'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useToggle/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA"} |
| import { useToggle as g } from "./useToggle.js"; | ||
| export { | ||
| g as useToggle | ||
| }; |
| import { Dispatch, SetStateAction } from 'react'; | ||
| /** | ||
| * Custom hook that manages a boolean toggle state in React components. | ||
| * @param {boolean} [defaultValue] - The initial value for the toggle state. | ||
| * @returns {[boolean, () => void, Dispatch<SetStateAction<boolean>>]} A tuple containing the current state, | ||
| * a function to toggle the state, and a function to set the state explicitly. | ||
| * @public | ||
| * @see [Documentation](https://usehooks-ts.com/react-hook/use-toggle) | ||
| * @example | ||
| * ```tsx | ||
| * const [isToggled, toggle, setToggle] = useToggle(); // Initial value is false | ||
| * // OR | ||
| * const [isToggled, toggle, setToggle] = useToggle(true); // Initial value is true | ||
| * // Use isToggled in your component, toggle to switch the state, setToggle to set the state explicitly. | ||
| * ``` | ||
| */ | ||
| export declare function useToggle(defaultValue?: boolean): [boolean, () => void, Dispatch<SetStateAction<boolean>>]; | ||
| //# sourceMappingURL=useToggle.d.ts.map |
| {"version":3,"file":"useToggle.d.ts","sourceRoot":"","sources":["../../src/useToggle/useToggle.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAErD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,SAAS,CACvB,YAAY,CAAC,EAAE,OAAO,GACrB,CAAC,OAAO,EAAE,MAAM,IAAI,EAAE,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,CAQ1D"} |
| import { useState as s, useCallback as a } from "react"; | ||
| function r(t) { | ||
| const [o, e] = s(!!t), u = a(() => { | ||
| e((l) => !l); | ||
| }, []); | ||
| return [o, u, e]; | ||
| } | ||
| export { | ||
| r as useToggle | ||
| }; |
| export * from './useUnmount'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useUnmount/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA"} |
| import { useUnmount as m } from "./useUnmount.js"; | ||
| export { | ||
| m as useUnmount | ||
| }; |
| /** | ||
| * Custom hook that runs a cleanup function when the component is unmounted. | ||
| * @param {() => void} func - The cleanup function to be executed on unmount. | ||
| * @public | ||
| * @see [Documentation](https://usehooks-ts.com/react-hook/use-unmount) | ||
| * @example | ||
| * ```tsx | ||
| * useUnmount(() => { | ||
| * // Cleanup logic here | ||
| * }); | ||
| * ``` | ||
| */ | ||
| export declare function useUnmount(func: () => void): void; | ||
| //# sourceMappingURL=useUnmount.d.ts.map |
| {"version":3,"file":"useUnmount.d.ts","sourceRoot":"","sources":["../../src/useUnmount/useUnmount.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,IAAI,QAW1C"} |
| import { useRef as n, useEffect as r } from "react"; | ||
| function f(e) { | ||
| const t = n(e); | ||
| t.current = e, r( | ||
| () => () => { | ||
| t.current(); | ||
| }, | ||
| [] | ||
| ); | ||
| } | ||
| export { | ||
| f as useUnmount | ||
| }; |
| export * from './useWindowSize'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useWindowSize/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA"} |
| import { useWindowSize as i } from "./useWindowSize.js"; | ||
| export { | ||
| i as useWindowSize | ||
| }; |
| /** | ||
| * Represent the dimension of the window. | ||
| * @template T - The type of the dimension (number or undefined). | ||
| */ | ||
| type WindowSize<T extends number | undefined = number | undefined> = { | ||
| /** The width of the window. */ | ||
| width: T; | ||
| /** The height of the window. */ | ||
| height: T; | ||
| }; | ||
| /** | ||
| * Hook options. | ||
| * @template InitializeWithValue - If `true` (default), the hook will initialize reading the window size. In SSR, you should set it to `false`, returning `undefined` initially. | ||
| */ | ||
| type UseWindowSizeOptions<InitializeWithValue extends boolean | undefined> = { | ||
| /** | ||
| * If `true` (default), the hook will initialize reading the window size. In SSR, you should set it to `false`, returning `undefined` initially. | ||
| * @default true | ||
| */ | ||
| initializeWithValue: InitializeWithValue; | ||
| /** | ||
| * The delay in milliseconds before the state is updated (disabled by default for retro-compatibility). | ||
| * @default undefined | ||
| */ | ||
| debounceDelay?: number; | ||
| }; | ||
| export declare function useWindowSize(options: UseWindowSizeOptions<false>): WindowSize; | ||
| export declare function useWindowSize(options?: Partial<UseWindowSizeOptions<true>>): WindowSize<number>; | ||
| export {}; | ||
| //# sourceMappingURL=useWindowSize.d.ts.map |
| {"version":3,"file":"useWindowSize.d.ts","sourceRoot":"","sources":["../../src/useWindowSize/useWindowSize.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,KAAK,UAAU,CAAC,CAAC,SAAS,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,IAAI;IACnE,+BAA+B;IAC/B,KAAK,EAAE,CAAC,CAAA;IACR,gCAAgC;IAChC,MAAM,EAAE,CAAC,CAAA;CACV,CAAA;AAED;;;GAGG;AACH,KAAK,oBAAoB,CAAC,mBAAmB,SAAS,OAAO,GAAG,SAAS,IAAI;IAC3E;;;OAGG;IACH,mBAAmB,EAAE,mBAAmB,CAAA;IACxC;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB,CAAA;AAKD,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,CAAC,KAAK,CAAC,GAAG,UAAU,CAAA;AAE/E,wBAAgB,aAAa,CAC3B,OAAO,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,GAC5C,UAAU,CAAC,MAAM,CAAC,CAAA"} |
| import { useState as r } from "react"; | ||
| import { useDebounceCallback as u } from "../useDebounceCallback/useDebounceCallback.js"; | ||
| import { useEventListener as w } from "../useEventListener/useEventListener.js"; | ||
| import { useIsomorphicLayoutEffect as h } from "../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js"; | ||
| const s = typeof window > "u"; | ||
| function m(e = {}) { | ||
| let { initializeWithValue: i = !0 } = e; | ||
| s && (i = !1); | ||
| const [o, t] = r(() => i ? { | ||
| width: window.innerWidth, | ||
| height: window.innerHeight | ||
| } : { | ||
| width: void 0, | ||
| height: void 0 | ||
| }), d = u( | ||
| t, | ||
| e.debounceDelay | ||
| ); | ||
| function n() { | ||
| (e.debounceDelay ? d : t)({ | ||
| width: window.innerWidth, | ||
| height: window.innerHeight | ||
| }); | ||
| } | ||
| return w("resize", n), h(() => { | ||
| n(); | ||
| }, []), o; | ||
| } | ||
| export { | ||
| m as useWindowSize | ||
| }; |
+1
-5
| { | ||
| "name": "@oneplatformdev/hooks", | ||
| "version": "0.1.0-11", | ||
| "version": "0.1.0-13", | ||
| "description": "React hook library", | ||
@@ -41,5 +41,2 @@ "author": "One Platform Development Team", | ||
| }, | ||
| "publishConfig": { | ||
| "directory": "dist" | ||
| }, | ||
| "files": [ | ||
@@ -49,3 +46,2 @@ "dist", | ||
| "LICENSE", | ||
| "package.json", | ||
| "!**/*.tsbuildinfo" | ||
@@ -52,0 +48,0 @@ ], |
-74
| import { useBoolean as r } from "./useBoolean/useBoolean.js"; | ||
| import { useClickAnyWhere as u } from "./useClickAnyWhere/useClickAnyWhere.js"; | ||
| import { useCopyToClipboard as p } from "./useCopyToClipboard/useCopyToClipboard.js"; | ||
| import { useCountdown as f } from "./useCountdown/useCountdown.js"; | ||
| import { useCounter as n } from "./useCounter/useCounter.js"; | ||
| import { useDarkMode as i } from "./useDarkMode/useDarkMode.js"; | ||
| import { useDebounceCallback as c } from "./useDebounceCallback/useDebounceCallback.js"; | ||
| import { useDebounceValue as S } from "./useDebounceValue/useDebounceValue.js"; | ||
| import { useDocumentTitle as b } from "./useDocumentTitle/useDocumentTitle.js"; | ||
| import { useEventCallback as y } from "./useEventCallback/useEventCallback.js"; | ||
| import { useEventListener as v } from "./useEventListener/useEventListener.js"; | ||
| import { useHover as L } from "./useHover/useHover.js"; | ||
| import { useIntersectionObserver as D } from "./useIntersectionObserver/useIntersectionObserver.js"; | ||
| import { useInterval as O } from "./useInterval/useInterval.js"; | ||
| import { useIsClient as h } from "./useIsClient/useIsClient.js"; | ||
| import { useIsMobile as z } from "./useIsMobile/useIsMobile.js"; | ||
| import { useIsMounted as Q } from "./useIsMounted/useIsMounted.js"; | ||
| import { useIsomorphicLayoutEffect as W } from "./useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js"; | ||
| import { useLocalStorage as H } from "./useLocalStorage/useLocalStorage.js"; | ||
| import { useLockBody as V } from "./useLockBody/useLockBody.js"; | ||
| import { useMap as q } from "./useMap/useMap.js"; | ||
| import { useMediaQuery as G } from "./useMediaQuery/useMediaQuery.js"; | ||
| import { useOnClickOutside as K } from "./useOnClickOutside/useOnClickOutside.js"; | ||
| import { useReadLocalStorage as P } from "./useReadLocalStorage/useReadLocalStorage.js"; | ||
| import { useResizeObserver as Y } from "./useResizeObserver/useResizeObserver.js"; | ||
| import { useScreen as _ } from "./useScreen/useScreen.js"; | ||
| import { useScript as ee } from "./useScript/useScript.js"; | ||
| import { useScrollLock as re } from "./useScrollLock/useScrollLock.js"; | ||
| import { useSessionStorage as ue } from "./useSessionStorage/useSessionStorage.js"; | ||
| import { useStep as pe } from "./useStep/useStep.js"; | ||
| import { useTernaryDarkMode as fe } from "./useTernaryDarkMode/useTernaryDarkMode.js"; | ||
| import { useTimeout as ne } from "./useTimeout/useTimeout.js"; | ||
| import { useToggle as ie } from "./useToggle/useToggle.js"; | ||
| import { useUnmount as ce } from "./useUnmount/useUnmount.js"; | ||
| import { useWindowSize as Se } from "./useWindowSize/useWindowSize.js"; | ||
| import { useQueryString as be } from "./useQueryString/useQueryString.js"; | ||
| export { | ||
| r as useBoolean, | ||
| u as useClickAnyWhere, | ||
| p as useCopyToClipboard, | ||
| f as useCountdown, | ||
| n as useCounter, | ||
| i as useDarkMode, | ||
| c as useDebounceCallback, | ||
| S as useDebounceValue, | ||
| b as useDocumentTitle, | ||
| y as useEventCallback, | ||
| v as useEventListener, | ||
| L as useHover, | ||
| D as useIntersectionObserver, | ||
| O as useInterval, | ||
| h as useIsClient, | ||
| z as useIsMobile, | ||
| Q as useIsMounted, | ||
| W as useIsomorphicLayoutEffect, | ||
| H as useLocalStorage, | ||
| V as useLockBody, | ||
| q as useMap, | ||
| G as useMediaQuery, | ||
| K as useOnClickOutside, | ||
| be as useQueryString, | ||
| P as useReadLocalStorage, | ||
| Y as useResizeObserver, | ||
| _ as useScreen, | ||
| ee as useScript, | ||
| re as useScrollLock, | ||
| ue as useSessionStorage, | ||
| pe as useStep, | ||
| fe as useTernaryDarkMode, | ||
| ne as useTimeout, | ||
| ie as useToggle, | ||
| ce as useUnmount, | ||
| Se as useWindowSize | ||
| }; |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
109507
1658.58%229
5625%2142
2794.59%1
Infinity%