@mantine/hooks 8.0.2 → 8.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/index.cjs +3 -1
- package/cjs/index.cjs.map +1 -1
- package/cjs/use-clipboard/use-clipboard.cjs +4 -4
- package/cjs/use-clipboard/use-clipboard.cjs.map +1 -1
- package/cjs/use-color-scheme/use-color-scheme.cjs.map +1 -1
- package/cjs/use-counter/use-counter.cjs +13 -4
- package/cjs/use-counter/use-counter.cjs.map +1 -1
- package/cjs/use-debounced-callback/use-debounced-callback.cjs +26 -21
- package/cjs/use-debounced-callback/use-debounced-callback.cjs.map +1 -1
- package/cjs/use-debounced-state/use-debounced-state.cjs.map +1 -1
- package/cjs/use-debounced-value/use-debounced-value.cjs.map +1 -1
- package/cjs/use-disclosure/use-disclosure.cjs +5 -6
- package/cjs/use-disclosure/use-disclosure.cjs.map +1 -1
- package/cjs/use-event-listener/use-event-listener.cjs +24 -9
- package/cjs/use-event-listener/use-event-listener.cjs.map +1 -1
- package/cjs/use-eye-dropper/use-eye-dropper.cjs +3 -3
- package/cjs/use-eye-dropper/use-eye-dropper.cjs.map +1 -1
- package/cjs/use-fetch/use-fetch.cjs +0 -3
- package/cjs/use-fetch/use-fetch.cjs.map +1 -1
- package/cjs/use-file-dialog/use-file-dialog.cjs.map +1 -1
- package/cjs/use-focus-return/use-focus-return.cjs +4 -1
- package/cjs/use-focus-return/use-focus-return.cjs.map +1 -1
- package/cjs/use-focus-trap/use-focus-trap.cjs.map +1 -1
- package/cjs/use-focus-within/use-focus-within.cjs +43 -26
- package/cjs/use-focus-within/use-focus-within.cjs.map +1 -1
- package/cjs/use-fullscreen/use-fullscreen.cjs.map +1 -1
- package/cjs/use-hash/use-hash.cjs +3 -1
- package/cjs/use-hash/use-hash.cjs.map +1 -1
- package/cjs/use-headroom/use-headroom.cjs +1 -1
- package/cjs/use-headroom/use-headroom.cjs.map +1 -1
- package/cjs/use-hotkeys/parse-hotkey.cjs +3 -2
- package/cjs/use-hotkeys/parse-hotkey.cjs.map +1 -1
- package/cjs/use-hover/use-hover.cjs +21 -15
- package/cjs/use-hover/use-hover.cjs.map +1 -1
- package/cjs/use-idle/use-idle.cjs +3 -9
- package/cjs/use-idle/use-idle.cjs.map +1 -1
- package/cjs/use-in-viewport/use-in-viewport.cjs.map +1 -1
- package/cjs/use-input-state/use-input-state.cjs.map +1 -1
- package/cjs/use-intersection/use-intersection.cjs.map +1 -1
- package/cjs/use-interval/use-interval.cjs +6 -6
- package/cjs/use-interval/use-interval.cjs.map +1 -1
- package/cjs/use-list-state/use-list-state.cjs.map +1 -1
- package/cjs/use-local-storage/create-storage.cjs.map +1 -1
- package/cjs/use-local-storage/use-local-storage.cjs.map +1 -1
- package/cjs/use-long-press/use-long-press.cjs +65 -0
- package/cjs/use-long-press/use-long-press.cjs.map +1 -0
- package/cjs/use-media-query/use-media-query.cjs +1 -1
- package/cjs/use-media-query/use-media-query.cjs.map +1 -1
- package/cjs/use-merged-ref/use-merged-ref.cjs.map +1 -1
- package/cjs/use-mouse/use-mouse.cjs +2 -2
- package/cjs/use-mouse/use-mouse.cjs.map +1 -1
- package/cjs/use-move/use-move.cjs +76 -75
- package/cjs/use-move/use-move.cjs.map +1 -1
- package/cjs/use-network/use-network.cjs +1 -3
- package/cjs/use-network/use-network.cjs.map +1 -1
- package/cjs/use-orientation/use-orientation.cjs.map +1 -1
- package/cjs/use-os/use-os.cjs +3 -1
- package/cjs/use-os/use-os.cjs.map +1 -1
- package/cjs/use-pagination/use-pagination.cjs.map +1 -1
- package/cjs/use-queue/use-queue.cjs +4 -1
- package/cjs/use-queue/use-queue.cjs.map +1 -1
- package/cjs/use-radial-move/use-radial-move.cjs +63 -62
- package/cjs/use-radial-move/use-radial-move.cjs.map +1 -1
- package/cjs/use-scroll-into-view/use-scroll-into-view.cjs +84 -8
- package/cjs/use-scroll-into-view/use-scroll-into-view.cjs.map +1 -1
- package/cjs/use-session-storage/use-session-storage.cjs.map +1 -1
- package/cjs/use-set/use-set.cjs +16 -0
- package/cjs/use-set/use-set.cjs.map +1 -1
- package/cjs/use-set-state/use-set-state.cjs.map +1 -1
- package/cjs/use-state-history/use-state-history.cjs.map +1 -1
- package/cjs/use-throttled-callback/use-throttled-callback.cjs +1 -1
- package/cjs/use-throttled-callback/use-throttled-callback.cjs.map +1 -1
- package/cjs/use-timeout/use-timeout.cjs +2 -2
- package/cjs/use-timeout/use-timeout.cjs.map +1 -1
- package/cjs/use-toggle/use-toggle.cjs.map +1 -1
- package/cjs/use-uncontrolled/use-uncontrolled.cjs.map +1 -1
- package/cjs/use-validated-state/use-validated-state.cjs +4 -4
- package/cjs/use-validated-state/use-validated-state.cjs.map +1 -1
- package/cjs/use-window-scroll/use-window-scroll.cjs +1 -1
- package/cjs/use-window-scroll/use-window-scroll.cjs.map +1 -1
- package/cjs/utils/use-callback-ref/use-callback-ref.cjs.map +1 -0
- package/esm/index.mjs +2 -1
- package/esm/index.mjs.map +1 -1
- package/esm/use-clipboard/use-clipboard.mjs +4 -4
- package/esm/use-clipboard/use-clipboard.mjs.map +1 -1
- package/esm/use-color-scheme/use-color-scheme.mjs.map +1 -1
- package/esm/use-counter/use-counter.mjs +14 -5
- package/esm/use-counter/use-counter.mjs.map +1 -1
- package/esm/use-debounced-callback/use-debounced-callback.mjs +27 -22
- package/esm/use-debounced-callback/use-debounced-callback.mjs.map +1 -1
- package/esm/use-debounced-state/use-debounced-state.mjs.map +1 -1
- package/esm/use-debounced-value/use-debounced-value.mjs.map +1 -1
- package/esm/use-disclosure/use-disclosure.mjs +5 -6
- package/esm/use-disclosure/use-disclosure.mjs.map +1 -1
- package/esm/use-event-listener/use-event-listener.mjs +25 -10
- package/esm/use-event-listener/use-event-listener.mjs.map +1 -1
- package/esm/use-eye-dropper/use-eye-dropper.mjs +3 -3
- package/esm/use-eye-dropper/use-eye-dropper.mjs.map +1 -1
- package/esm/use-fetch/use-fetch.mjs +0 -3
- package/esm/use-fetch/use-fetch.mjs.map +1 -1
- package/esm/use-file-dialog/use-file-dialog.mjs.map +1 -1
- package/esm/use-focus-return/use-focus-return.mjs +4 -1
- package/esm/use-focus-return/use-focus-return.mjs.map +1 -1
- package/esm/use-focus-trap/use-focus-trap.mjs.map +1 -1
- package/esm/use-focus-within/use-focus-within.mjs +44 -27
- package/esm/use-focus-within/use-focus-within.mjs.map +1 -1
- package/esm/use-fullscreen/use-fullscreen.mjs.map +1 -1
- package/esm/use-hash/use-hash.mjs +3 -1
- package/esm/use-hash/use-hash.mjs.map +1 -1
- package/esm/use-headroom/use-headroom.mjs +1 -1
- package/esm/use-headroom/use-headroom.mjs.map +1 -1
- package/esm/use-hotkeys/parse-hotkey.mjs +3 -2
- package/esm/use-hotkeys/parse-hotkey.mjs.map +1 -1
- package/esm/use-hover/use-hover.mjs +22 -16
- package/esm/use-hover/use-hover.mjs.map +1 -1
- package/esm/use-idle/use-idle.mjs +3 -9
- package/esm/use-idle/use-idle.mjs.map +1 -1
- package/esm/use-in-viewport/use-in-viewport.mjs.map +1 -1
- package/esm/use-input-state/use-input-state.mjs.map +1 -1
- package/esm/use-intersection/use-intersection.mjs.map +1 -1
- package/esm/use-interval/use-interval.mjs +7 -7
- package/esm/use-interval/use-interval.mjs.map +1 -1
- package/esm/use-list-state/use-list-state.mjs.map +1 -1
- package/esm/use-local-storage/create-storage.mjs.map +1 -1
- package/esm/use-local-storage/use-local-storage.mjs.map +1 -1
- package/esm/use-long-press/use-long-press.mjs +63 -0
- package/esm/use-long-press/use-long-press.mjs.map +1 -0
- package/esm/use-media-query/use-media-query.mjs +1 -1
- package/esm/use-media-query/use-media-query.mjs.map +1 -1
- package/esm/use-merged-ref/use-merged-ref.mjs.map +1 -1
- package/esm/use-mouse/use-mouse.mjs +2 -2
- package/esm/use-mouse/use-mouse.mjs.map +1 -1
- package/esm/use-move/use-move.mjs +77 -76
- package/esm/use-move/use-move.mjs.map +1 -1
- package/esm/use-network/use-network.mjs +1 -3
- package/esm/use-network/use-network.mjs.map +1 -1
- package/esm/use-orientation/use-orientation.mjs.map +1 -1
- package/esm/use-os/use-os.mjs +3 -1
- package/esm/use-os/use-os.mjs.map +1 -1
- package/esm/use-pagination/use-pagination.mjs.map +1 -1
- package/esm/use-queue/use-queue.mjs +4 -1
- package/esm/use-queue/use-queue.mjs.map +1 -1
- package/esm/use-radial-move/use-radial-move.mjs +64 -63
- package/esm/use-radial-move/use-radial-move.mjs.map +1 -1
- package/esm/use-scroll-into-view/use-scroll-into-view.mjs +80 -4
- package/esm/use-scroll-into-view/use-scroll-into-view.mjs.map +1 -1
- package/esm/use-session-storage/use-session-storage.mjs.map +1 -1
- package/esm/use-set/use-set.mjs +16 -1
- package/esm/use-set/use-set.mjs.map +1 -1
- package/esm/use-set-state/use-set-state.mjs.map +1 -1
- package/esm/use-state-history/use-state-history.mjs.map +1 -1
- package/esm/use-throttled-callback/use-throttled-callback.mjs +1 -1
- package/esm/use-throttled-callback/use-throttled-callback.mjs.map +1 -1
- package/esm/use-timeout/use-timeout.mjs +2 -2
- package/esm/use-timeout/use-timeout.mjs.map +1 -1
- package/esm/use-toggle/use-toggle.mjs.map +1 -1
- package/esm/use-uncontrolled/use-uncontrolled.mjs.map +1 -1
- package/esm/use-validated-state/use-validated-state.mjs +4 -4
- package/esm/use-validated-state/use-validated-state.mjs.map +1 -1
- package/esm/use-window-scroll/use-window-scroll.mjs +1 -1
- package/esm/use-window-scroll/use-window-scroll.mjs.map +1 -1
- package/esm/utils/use-callback-ref/use-callback-ref.mjs.map +1 -0
- package/lib/index.d.mts +41 -8
- package/lib/index.d.ts +41 -8
- package/lib/use-clipboard/use-clipboard.d.ts +12 -5
- package/lib/use-color-scheme/use-color-scheme.d.ts +2 -1
- package/lib/use-counter/use-counter.d.ts +12 -9
- package/lib/use-debounced-callback/use-debounced-callback.d.ts +9 -2
- package/lib/use-debounced-state/use-debounced-state.d.ts +5 -3
- package/lib/use-debounced-value/use-debounced-value.d.ts +5 -3
- package/lib/use-disclosure/use-disclosure.d.ts +9 -6
- package/lib/use-event-listener/use-event-listener.d.ts +1 -1
- package/lib/use-eye-dropper/use-eye-dropper.d.ts +4 -4
- package/lib/use-fetch/use-fetch.d.ts +4 -3
- package/lib/use-file-dialog/use-file-dialog.d.ts +3 -2
- package/lib/use-focus-return/use-focus-return.d.ts +3 -4
- package/lib/use-focus-trap/use-focus-trap.d.ts +1 -1
- package/lib/use-focus-within/use-focus-within.d.ts +4 -3
- package/lib/use-fullscreen/use-fullscreen.d.ts +6 -5
- package/lib/use-hash/use-hash.d.ts +3 -3
- package/lib/use-headroom/use-headroom.d.ts +3 -4
- package/lib/use-hover/use-hover.d.ts +4 -3
- package/lib/use-idle/use-idle.d.ts +5 -4
- package/lib/use-in-viewport/use-in-viewport.d.ts +4 -3
- package/lib/use-input-state/use-input-state.d.ts +5 -1
- package/lib/use-intersection/use-intersection.d.ts +4 -3
- package/lib/use-interval/use-interval.d.ts +8 -4
- package/lib/use-list-state/use-list-state.d.ts +2 -2
- package/lib/use-local-storage/create-storage.d.ts +8 -3
- package/lib/use-local-storage/use-local-storage.d.ts +3 -3
- package/lib/use-long-press/use-long-press.d.ts +19 -0
- package/lib/use-media-query/use-media-query.d.ts +1 -1
- package/lib/use-merged-ref/use-merged-ref.d.ts +2 -2
- package/lib/use-move/use-move.d.ts +5 -5
- package/lib/use-network/use-network.d.ts +3 -5
- package/lib/use-orientation/use-orientation.d.ts +2 -3
- package/lib/use-os/use-os.d.ts +3 -4
- package/lib/use-pagination/use-pagination.d.ts +13 -5
- package/lib/use-queue/use-queue.d.ts +13 -4
- package/lib/use-radial-move/use-radial-move.d.ts +6 -3
- package/lib/use-reduced-motion/use-reduced-motion.d.ts +1 -1
- package/lib/use-scroll-into-view/use-scroll-into-view.d.ts +7 -7
- package/lib/use-session-storage/use-session-storage.d.ts +3 -3
- package/lib/use-set/use-set.d.ts +1 -0
- package/lib/use-set-state/use-set-state.d.ts +3 -1
- package/lib/use-state-history/use-state-history.d.ts +7 -2
- package/lib/use-timeout/use-timeout.d.ts +6 -4
- package/lib/use-toggle/use-toggle.d.ts +4 -1
- package/lib/use-uncontrolled/use-uncontrolled.d.ts +10 -3
- package/lib/use-validated-state/use-validated-state.d.ts +15 -5
- package/lib/use-window-scroll/use-window-scroll.d.ts +4 -4
- package/lib/utils/index.d.ts +1 -0
- package/package.json +1 -1
- package/cjs/use-callback-ref/use-callback-ref.cjs.map +0 -1
- package/cjs/use-scroll-into-view/utils/ease-in-out-quad.cjs +0 -7
- package/cjs/use-scroll-into-view/utils/ease-in-out-quad.cjs.map +0 -1
- package/cjs/use-scroll-into-view/utils/get-relative-position.cjs +0 -66
- package/cjs/use-scroll-into-view/utils/get-relative-position.cjs.map +0 -1
- package/cjs/use-scroll-into-view/utils/get-scroll-start.cjs +0 -17
- package/cjs/use-scroll-into-view/utils/get-scroll-start.cjs.map +0 -1
- package/cjs/use-scroll-into-view/utils/set-scroll-param.cjs +0 -19
- package/cjs/use-scroll-into-view/utils/set-scroll-param.cjs.map +0 -1
- package/esm/use-callback-ref/use-callback-ref.mjs.map +0 -1
- package/esm/use-scroll-into-view/utils/ease-in-out-quad.mjs +0 -5
- package/esm/use-scroll-into-view/utils/ease-in-out-quad.mjs.map +0 -1
- package/esm/use-scroll-into-view/utils/get-relative-position.mjs +0 -64
- package/esm/use-scroll-into-view/utils/get-relative-position.mjs.map +0 -1
- package/esm/use-scroll-into-view/utils/get-scroll-start.mjs +0 -15
- package/esm/use-scroll-into-view/utils/get-scroll-start.mjs.map +0 -1
- package/esm/use-scroll-into-view/utils/set-scroll-param.mjs +0 -17
- package/esm/use-scroll-into-view/utils/set-scroll-param.mjs.map +0 -1
- package/lib/use-scroll-into-view/utils/ease-in-out-quad.d.ts +0 -1
- package/lib/use-scroll-into-view/utils/get-relative-position.d.ts +0 -1
- package/lib/use-scroll-into-view/utils/get-scroll-start.d.ts +0 -1
- package/lib/use-scroll-into-view/utils/set-scroll-param.d.ts +0 -1
- /package/cjs/{use-callback-ref → utils/use-callback-ref}/use-callback-ref.cjs +0 -0
- /package/esm/{use-callback-ref → utils/use-callback-ref}/use-callback-ref.mjs +0 -0
- /package/lib/{use-callback-ref → utils/use-callback-ref}/use-callback-ref.d.ts +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-timeout.mjs","sources":["../../src/use-timeout/use-timeout.ts"],"sourcesContent":["import { useCallback, useEffect, useRef } from 'react';\n\nexport function useTimeout(\n callback: (...
|
|
1
|
+
{"version":3,"file":"use-timeout.mjs","sources":["../../src/use-timeout/use-timeout.ts"],"sourcesContent":["import { useCallback, useEffect, useRef } from 'react';\n\nexport interface UseTimeoutOptions {\n autoInvoke: boolean;\n}\n\nexport interface UseTimeoutReturnValue {\n start: (...args: any[]) => void;\n clear: () => void;\n}\n\nexport function useTimeout(\n callback: (...args: any[]) => void,\n delay: number,\n options: UseTimeoutOptions = { autoInvoke: false }\n): UseTimeoutReturnValue {\n const timeoutRef = useRef<number | null>(null);\n\n const start = useCallback(\n (...args: any[]) => {\n if (!timeoutRef.current) {\n timeoutRef.current = window.setTimeout(() => {\n callback(args);\n timeoutRef.current = null;\n }, delay);\n }\n },\n [delay]\n );\n\n const clear = useCallback(() => {\n if (timeoutRef.current) {\n window.clearTimeout(timeoutRef.current);\n timeoutRef.current = null;\n }\n }, []);\n\n useEffect(() => {\n if (options.autoInvoke) {\n start();\n }\n\n return clear;\n }, [clear, start]);\n\n return { start, clear };\n}\n"],"names":[],"mappings":";;;AAWO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,WACd,CACA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CACA,UAA6B,CAAE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAY,CAAA,CAAA,CAAA,CAAA,CAAA,GACpB,CAAA,CAAA,CAAA;AACvB,C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A,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAY,CAAA,CAAA,CAAA;AACtB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,KAAA,CAAA,CAAA,CAAA;AAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAGR,CAAA,CAAA,CAAA,CAAO,OAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA,CAAA,CACN,EAAA,CAAC,CAAA,CAAA,CAAA,CAAA,CAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAK,CAAC,CAAA,CAAA;AAEjB,CAAA,CAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAE,OAAO,KAAM,CAAA,CAAA,CAAA;AACxB,CAAA;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-toggle.mjs","sources":["../../src/use-toggle/use-toggle.ts"],"sourcesContent":["import { useReducer } from 'react';\n\nexport function useToggle<T = boolean>(options: readonly T[] = [false, true] as any) {\n const [[option], toggle] = useReducer((state: T[], action: React.SetStateAction<T>) => {\n const value = action instanceof Function ? action(state[0]) : action;\n const index = Math.abs(state.indexOf(value));\n\n return state.slice(index).concat(state.slice(0, index));\n }, options as T[]);\n\n return [option, toggle as
|
|
1
|
+
{"version":3,"file":"use-toggle.mjs","sources":["../../src/use-toggle/use-toggle.ts"],"sourcesContent":["import { useReducer } from 'react';\n\ntype UseToggleAction<T> = (value?: React.SetStateAction<T>) => void;\nexport type UseToggleReturnValue<T> = [T, UseToggleAction<T>];\n\nexport function useToggle<T = boolean>(\n options: readonly T[] = [false, true] as any\n): UseToggleReturnValue<T> {\n const [[option], toggle] = useReducer((state: T[], action: React.SetStateAction<T>) => {\n const value = action instanceof Function ? action(state[0]) : action;\n const index = Math.abs(state.indexOf(value));\n\n return state.slice(index).concat(state.slice(0, index));\n }, options as T[]);\n\n return [option, toggle as UseToggleAction<T>];\n}\n"],"names":[],"mappings":";;;AA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MAAM,CAAA,CAAA,CAAA,CAAA,CAAK,CAAA,CAAE,CAAA,CAAA,CAAA,CAAA,CAAA,EAAO,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAG,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAK,CAAC,CAAA,CAAA;AAAA,KACrD,OAAc,CAAA,CAAA;AAEjB,CAAA,CAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAC,QAAQ,MAA4B,CAAA,CAAA;AAC9C,CAAA;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-uncontrolled.mjs","sources":["../../src/use-uncontrolled/use-uncontrolled.ts"],"sourcesContent":["import { useState } from 'react';\n\
|
|
1
|
+
{"version":3,"file":"use-uncontrolled.mjs","sources":["../../src/use-uncontrolled/use-uncontrolled.ts"],"sourcesContent":["import { useState } from 'react';\n\nexport interface UseUncontrolledOptions<T> {\n /** Value for controlled state */\n value?: T;\n\n /** Initial value for uncontrolled state */\n defaultValue?: T;\n\n /** Final value for uncontrolled state when value and defaultValue are not provided */\n finalValue?: T;\n\n /** Controlled state onChange handler */\n onChange?: (value: T, ...payload: any[]) => void;\n}\n\nexport type UseUncontrolledReturnValue<T> = [\n /** Current value */\n T,\n\n /** Handler to update the state, passes `value` and `payload` to `onChange` */\n (value: T, ...payload: any[]) => void,\n\n /** True if the state is controlled, false if uncontrolled */\n boolean,\n];\n\nexport function useUncontrolled<T>({\n value,\n defaultValue,\n finalValue,\n onChange = () => {},\n}: UseUncontrolledOptions<T>): UseUncontrolledReturnValue<T> {\n const [uncontrolledValue, setUncontrolledValue] = useState(\n defaultValue !== undefined ? defaultValue : finalValue\n );\n\n const handleUncontrolledChange = (val: T, ...payload: any[]) => {\n setUncontrolledValue(val);\n onChange?.(val, ...payload);\n };\n\n if (value !== undefined) {\n return [value as T, onChange, true];\n }\n\n return [uncontrolledValue as T, handleUncontrolledChange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AA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAqB,CAAA,CAAA,CAAG,CAAA,CAAA;AACxB,CAAA,CAAA,CAAA,CAAW,QAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAK,CAAA,CAAA,CAAA,CAAG,OAAO,CAAA,CAAA;AAAA,CAC5B,CAAA,CAAA,CAAA;AAEA,CAAA,CAAA,CAAI,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAU,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAW,CAAA,CAAA,CAAA,CAAA;AACvB,CAAA,CAAA,CAAA,CAAO,OAAA,CAAC,CAAA,CAAA,CAAA,CAAA,CAAY,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAU,IAAI,CAAA,CAAA;AAAA,CAAA,CAAA,CAAA;AAGpC,CAAA,CAAO,OAAA,CAAC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAwB,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAA0B,KAAK,CAAA,CAAA;AACjE,CAAA;;"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
|
|
4
|
-
function useValidatedState(initialValue,
|
|
4
|
+
function useValidatedState(initialValue, validate, initialValidationState) {
|
|
5
5
|
const [value, setValue] = useState(initialValue);
|
|
6
6
|
const [lastValidValue, setLastValidValue] = useState(
|
|
7
|
-
|
|
7
|
+
validate(initialValue) ? initialValue : void 0
|
|
8
8
|
);
|
|
9
9
|
const [valid, setValid] = useState(
|
|
10
|
-
typeof initialValidationState === "boolean" ? initialValidationState :
|
|
10
|
+
typeof initialValidationState === "boolean" ? initialValidationState : validate(initialValue)
|
|
11
11
|
);
|
|
12
12
|
const onChange = (val) => {
|
|
13
|
-
if (
|
|
13
|
+
if (validate(val)) {
|
|
14
14
|
setLastValidValue(val);
|
|
15
15
|
setValid(true);
|
|
16
16
|
} else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-validated-state.mjs","sources":["../../src/use-validated-state/use-validated-state.ts"],"sourcesContent":["import { useState } from 'react';\n\nexport function useValidatedState<T>(\n initialValue: T,\n
|
|
1
|
+
{"version":3,"file":"use-validated-state.mjs","sources":["../../src/use-validated-state/use-validated-state.ts"],"sourcesContent":["import { useState } from 'react';\n\nexport interface UseValidatedStateValue<T> {\n /** Current value */\n value: T;\n\n /** Last valid value */\n lastValidValue: T | undefined;\n\n /** True if the current value is valid, false otherwise */\n valid: boolean;\n}\n\nexport type UseValidatedStateReturnValue<T> = [\n /** Current value */\n UseValidatedStateValue<T>,\n /** Handler to update the state, passes `value` and `payload` to `onChange` */\n (value: T) => void,\n];\n\nexport function useValidatedState<T>(\n initialValue: T,\n validate: (value: T) => boolean,\n initialValidationState?: boolean\n): UseValidatedStateReturnValue<T> {\n const [value, setValue] = useState<T>(initialValue);\n const [lastValidValue, setLastValidValue] = useState<T | undefined>(\n validate(initialValue) ? initialValue : undefined\n );\n const [valid, setValid] = useState<boolean>(\n typeof initialValidationState === 'boolean' ? initialValidationState : validate(initialValue)\n );\n\n const onChange = (val: T) => {\n if (validate(val)) {\n setLastValidValue(val);\n setValid(true);\n } else {\n setValid(false);\n }\n\n setValue(val);\n };\n\n return [{ value, lastValidValue, valid }, onChange] as const;\n}\n"],"names":[],"mappings":";;;AAoBgB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,iBAA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,CAAA,CAAS,CAAA,CAAA,CAAA,CAAA,CAAK,CAAA,CAAA;AAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAGhB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,CAAA,CAAA,CAAG,CAAA,CAAA;AAAA,CACd,CAAA,CAAA,CAAA;AAEA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,CAAC,CAAA,CAAE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,CAAgB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAQ,CAAA,CAAA;AACpD,CAAA;;"}
|
|
@@ -3,7 +3,7 @@ import { useState, useEffect } from 'react';
|
|
|
3
3
|
import { useWindowEvent } from '../use-window-event/use-window-event.mjs';
|
|
4
4
|
|
|
5
5
|
function getScrollPosition() {
|
|
6
|
-
return typeof window !== "undefined" ? { x: window.
|
|
6
|
+
return typeof window !== "undefined" ? { x: window.scrollX, y: window.scrollY } : { x: 0, y: 0 };
|
|
7
7
|
}
|
|
8
8
|
function scrollTo({ x, y }) {
|
|
9
9
|
if (typeof window !== "undefined") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-window-scroll.mjs","sources":["../../src/use-window-scroll/use-window-scroll.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport { useWindowEvent } from '../use-window-event/use-window-event';\n\
|
|
1
|
+
{"version":3,"file":"use-window-scroll.mjs","sources":["../../src/use-window-scroll/use-window-scroll.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport { useWindowEvent } from '../use-window-event/use-window-event';\n\nexport interface UseWindowScrollPosition {\n x: number;\n y: number;\n}\n\nexport type UseWindowScrollTo = (position: Partial<UseWindowScrollPosition>) => void;\nexport type UseWindowScrollReturnValue = [UseWindowScrollPosition, UseWindowScrollTo];\n\nfunction getScrollPosition(): UseWindowScrollPosition {\n return typeof window !== 'undefined' ? { x: window.scrollX, y: window.scrollY } : { x: 0, y: 0 };\n}\n\nfunction scrollTo({ x, y }: Partial<UseWindowScrollPosition>) {\n if (typeof window !== 'undefined') {\n const scrollOptions: ScrollToOptions = { behavior: 'smooth' };\n\n if (typeof x === 'number') {\n scrollOptions.left = x;\n }\n\n if (typeof y === 'number') {\n scrollOptions.top = y;\n }\n\n window.scrollTo(scrollOptions);\n }\n}\n\nexport function useWindowScroll(): UseWindowScrollReturnValue {\n const [position, setPosition] = useState<UseWindowScrollPosition>({ x: 0, y: 0 });\n\n useWindowEvent('scroll', () => setPosition(getScrollPosition()));\n useWindowEvent('resize', () => setPosition(getScrollPosition()));\n\n useEffect(() => {\n setPosition(getScrollPosition());\n }, []);\n\n return [position, scrollTo] as const;\n}\n"],"names":[],"mappings":";;;;AAWA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,iBAA6C,CAAA,CAAA,CAAA,CAAA;AACpD,CAAA,CAAA,CAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAW,CAAc,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAE,CAAA,EAAG,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,CAAA,CAAG,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAY,CAAA,CAAA,CAAA,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,CAAA,CAAC,CAAA,CAAA;AAE/D,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAU,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AACd,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAY,mBAAmB,CAAA,CAAA;AAAA,CACjC,CAAA,CAAA,CAAA,CAAG,EAAE,CAAA,CAAA;AAEL,CAAA,CAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAC,UAAU,QAAQ,CAAA,CAAA;AAC5B,CAAA;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-callback-ref.mjs","sources":["../../../src/utils/use-callback-ref/use-callback-ref.ts"],"sourcesContent":["import { useEffect, useMemo, useRef } from 'react';\n\nexport function useCallbackRef<T extends (...args: any[]) => any>(callback: T | undefined): T {\n const callbackRef = useRef(callback);\n\n useEffect(() => {\n callbackRef.current = callback;\n });\n\n return useMemo(() => ((...args) => callbackRef.current?.(...args)) as T, []);\n}\n"],"names":[],"mappings":";;;AAEO,CAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAkD,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAA4B,CAAA,CAAA,CAAA;AAC5F,CAAA,CAAM,MAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAc,OAAO,QAAQ,CAAA,CAAA;AAEnC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAU,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AACd,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAY,CAAU,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA,CAAA,CACvB,CAAA,CAAA;AAED,CAAA,CAAO,OAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAQ,CAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAAI,CAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAY,QAAU,CAAA,CAAA,CAAA,CAAA,CAAG,IAAI,CAAS,CAAA,CAAA,EAAE,CAAA,CAAA;AAC7E,CAAA;;"}
|
package/lib/index.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export * from './utils/index.js';
|
|
2
|
-
export { useCallbackRef } from './use-callback-ref/use-callback-ref';
|
|
3
2
|
export { useDebouncedCallback } from './use-debounced-callback/use-debounced-callback';
|
|
4
3
|
export { useClickOutside } from './use-click-outside/use-click-outside';
|
|
5
4
|
export { useClipboard } from './use-clipboard/use-clipboard';
|
|
@@ -71,12 +70,46 @@ export { useFetch } from './use-fetch/use-fetch';
|
|
|
71
70
|
export { useRadialMove, normalizeRadialValue } from './use-radial-move/use-radial-move';
|
|
72
71
|
export { useScrollSpy } from './use-scroll-spy/use-scroll-spy';
|
|
73
72
|
export { useFileDialog } from './use-file-dialog/use-file-dialog';
|
|
74
|
-
export
|
|
75
|
-
export type { OS } from './use-os/use-os';
|
|
76
|
-
export type { HotkeyItem, HotkeyItemOptions } from './use-hotkeys/use-hotkeys';
|
|
77
|
-
export type { UseListStateHandlers } from './use-list-state/use-list-state';
|
|
78
|
-
export type { EyeDropperOpenReturnType } from './use-eye-dropper/use-eye-dropper';
|
|
73
|
+
export { useLongPress } from './use-long-press/use-long-press';
|
|
79
74
|
export type { UseMediaQueryOptions } from './use-media-query/use-media-query';
|
|
80
|
-
export type {
|
|
81
|
-
export type {
|
|
75
|
+
export type { UseClipboardOptions, UseClipboardReturnValue } from './use-clipboard/use-clipboard';
|
|
76
|
+
export type { UseColorSchemeValue } from './use-color-scheme/use-color-scheme';
|
|
77
|
+
export type { UseCounterOptions, UseCounterHandlers, UseCounterReturnValue, } from './use-counter/use-counter';
|
|
78
|
+
export type { UseDebouncedCallbackOptions, UseDebouncedCallbackReturnValue, } from './use-debounced-callback/use-debounced-callback';
|
|
79
|
+
export type { UseDebouncedStateOptions, UseDebouncedStateReturnValue, } from './use-debounced-state/use-debounced-state';
|
|
80
|
+
export type { UseDebouncedValueOptions, UseDebouncedValueReturnValue, } from './use-debounced-value/use-debounced-value';
|
|
81
|
+
export type { UseDisclosureOptions, UseDisclosureHandlers, UseDisclosureReturnValue, } from './use-disclosure/use-disclosure';
|
|
82
|
+
export type { EyeDropperOpenOptions, EyeDropperOpenReturnType, UseEyeDropperReturnValue, } from './use-eye-dropper/use-eye-dropper';
|
|
83
|
+
export type { UseFetchOptions, UseFetchReturnValue } from './use-fetch/use-fetch';
|
|
84
|
+
export type { UseFileDialogOptions, UseFileDialogReturnValue, } from './use-file-dialog/use-file-dialog';
|
|
85
|
+
export type { UseFocusReturnOptions, UseFocusReturnReturnValue, } from './use-focus-return/use-focus-return';
|
|
86
|
+
export type { UseFocusWithinOptions, UseFocusWithinReturnValue, } from './use-focus-within/use-focus-within';
|
|
87
|
+
export type { UseFullscreenReturnValue } from './use-fullscreen/use-fullscreen';
|
|
88
|
+
export type { UseHashOptions, UseHashReturnValue } from './use-hash/use-hash';
|
|
89
|
+
export type { UseHeadroomOptions } from './use-headroom/use-headroom';
|
|
90
|
+
export type { HotkeyItemOptions, HotkeyItem } from './use-hotkeys/use-hotkeys';
|
|
91
|
+
export type { UseHoverReturnValue } from './use-hover/use-hover';
|
|
92
|
+
export type { UseIdleOptions } from './use-idle/use-idle';
|
|
93
|
+
export type { UseInViewportReturnValue } from './use-in-viewport/use-in-viewport';
|
|
94
|
+
export type { UseInputStateReturnValue } from './use-input-state/use-input-state';
|
|
95
|
+
export type { UseIntersectionReturnValue } from './use-intersection/use-intersection';
|
|
96
|
+
export type { UseIntervalOptions, UseIntervalReturnValue } from './use-interval/use-interval';
|
|
97
|
+
export type { UseListStateReturnValue, UseListStateHandlers, } from './use-list-state/use-list-state';
|
|
98
|
+
export type { UseStorageOptions, UseStorageReturnValue } from './use-local-storage/create-storage';
|
|
99
|
+
export type { UseMovePosition, UseMoveHandlers, UseMoveReturnValue } from './use-move/use-move';
|
|
100
|
+
export type { UserNetworkReturnValue } from './use-network/use-network';
|
|
101
|
+
export type { UseOrientationOptions, UseOrientationReturnType, } from './use-orientation/use-orientation';
|
|
102
|
+
export type { UseOSReturnValue as OS, UseOSReturnValue, UseOsOptions } from './use-os/use-os';
|
|
103
|
+
export type { UsePaginationOptions, UsePaginationReturnValue, } from './use-pagination/use-pagination';
|
|
104
|
+
export type { UseQueueOptions, UseQueueReturnValue } from './use-queue/use-queue';
|
|
105
|
+
export type { UseRadialMoveOptions, UseRadialMoveReturnValue, } from './use-radial-move/use-radial-move';
|
|
106
|
+
export type { UseScrollIntoViewOptions, UseScrollIntoViewReturnValue, } from './use-scroll-into-view/use-scroll-into-view';
|
|
82
107
|
export type { UseScrollSpyOptions, UseScrollSpyHeadingData, UseScrollSpyReturnType, } from './use-scroll-spy/use-scroll-spy';
|
|
108
|
+
export type { UseSetStateCallback, UseSetStateReturnValue } from './use-set-state/use-set-state';
|
|
109
|
+
export type { UseStateHistoryHandlers, UseStateHistoryValue as StateHistory, UseStateHistoryValue, UseStateHistoryReturnValue, } from './use-state-history/use-state-history';
|
|
110
|
+
export type { UseTimeoutOptions, UseTimeoutReturnValue } from './use-timeout/use-timeout';
|
|
111
|
+
export type { UseToggleReturnValue } from './use-toggle/use-toggle';
|
|
112
|
+
export type { UseUncontrolledOptions, UseUncontrolledReturnValue, } from './use-uncontrolled/use-uncontrolled';
|
|
113
|
+
export type { UseValidatedStateValue, UseValidatedStateReturnValue, } from './use-validated-state/use-validated-state';
|
|
114
|
+
export type { UseWindowScrollPosition, UseWindowScrollTo, UseWindowScrollReturnValue, } from './use-window-scroll/use-window-scroll';
|
|
115
|
+
export type { UseLongPressOptions, UseLongPressReturnValue } from './use-long-press/use-long-press';
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export * from './utils/index.js';
|
|
2
|
-
export { useCallbackRef } from './use-callback-ref/use-callback-ref';
|
|
3
2
|
export { useDebouncedCallback } from './use-debounced-callback/use-debounced-callback';
|
|
4
3
|
export { useClickOutside } from './use-click-outside/use-click-outside';
|
|
5
4
|
export { useClipboard } from './use-clipboard/use-clipboard';
|
|
@@ -71,12 +70,46 @@ export { useFetch } from './use-fetch/use-fetch';
|
|
|
71
70
|
export { useRadialMove, normalizeRadialValue } from './use-radial-move/use-radial-move';
|
|
72
71
|
export { useScrollSpy } from './use-scroll-spy/use-scroll-spy';
|
|
73
72
|
export { useFileDialog } from './use-file-dialog/use-file-dialog';
|
|
74
|
-
export
|
|
75
|
-
export type { OS } from './use-os/use-os';
|
|
76
|
-
export type { HotkeyItem, HotkeyItemOptions } from './use-hotkeys/use-hotkeys';
|
|
77
|
-
export type { UseListStateHandlers } from './use-list-state/use-list-state';
|
|
78
|
-
export type { EyeDropperOpenReturnType } from './use-eye-dropper/use-eye-dropper';
|
|
73
|
+
export { useLongPress } from './use-long-press/use-long-press';
|
|
79
74
|
export type { UseMediaQueryOptions } from './use-media-query/use-media-query';
|
|
80
|
-
export type {
|
|
81
|
-
export type {
|
|
75
|
+
export type { UseClipboardOptions, UseClipboardReturnValue } from './use-clipboard/use-clipboard';
|
|
76
|
+
export type { UseColorSchemeValue } from './use-color-scheme/use-color-scheme';
|
|
77
|
+
export type { UseCounterOptions, UseCounterHandlers, UseCounterReturnValue, } from './use-counter/use-counter';
|
|
78
|
+
export type { UseDebouncedCallbackOptions, UseDebouncedCallbackReturnValue, } from './use-debounced-callback/use-debounced-callback';
|
|
79
|
+
export type { UseDebouncedStateOptions, UseDebouncedStateReturnValue, } from './use-debounced-state/use-debounced-state';
|
|
80
|
+
export type { UseDebouncedValueOptions, UseDebouncedValueReturnValue, } from './use-debounced-value/use-debounced-value';
|
|
81
|
+
export type { UseDisclosureOptions, UseDisclosureHandlers, UseDisclosureReturnValue, } from './use-disclosure/use-disclosure';
|
|
82
|
+
export type { EyeDropperOpenOptions, EyeDropperOpenReturnType, UseEyeDropperReturnValue, } from './use-eye-dropper/use-eye-dropper';
|
|
83
|
+
export type { UseFetchOptions, UseFetchReturnValue } from './use-fetch/use-fetch';
|
|
84
|
+
export type { UseFileDialogOptions, UseFileDialogReturnValue, } from './use-file-dialog/use-file-dialog';
|
|
85
|
+
export type { UseFocusReturnOptions, UseFocusReturnReturnValue, } from './use-focus-return/use-focus-return';
|
|
86
|
+
export type { UseFocusWithinOptions, UseFocusWithinReturnValue, } from './use-focus-within/use-focus-within';
|
|
87
|
+
export type { UseFullscreenReturnValue } from './use-fullscreen/use-fullscreen';
|
|
88
|
+
export type { UseHashOptions, UseHashReturnValue } from './use-hash/use-hash';
|
|
89
|
+
export type { UseHeadroomOptions } from './use-headroom/use-headroom';
|
|
90
|
+
export type { HotkeyItemOptions, HotkeyItem } from './use-hotkeys/use-hotkeys';
|
|
91
|
+
export type { UseHoverReturnValue } from './use-hover/use-hover';
|
|
92
|
+
export type { UseIdleOptions } from './use-idle/use-idle';
|
|
93
|
+
export type { UseInViewportReturnValue } from './use-in-viewport/use-in-viewport';
|
|
94
|
+
export type { UseInputStateReturnValue } from './use-input-state/use-input-state';
|
|
95
|
+
export type { UseIntersectionReturnValue } from './use-intersection/use-intersection';
|
|
96
|
+
export type { UseIntervalOptions, UseIntervalReturnValue } from './use-interval/use-interval';
|
|
97
|
+
export type { UseListStateReturnValue, UseListStateHandlers, } from './use-list-state/use-list-state';
|
|
98
|
+
export type { UseStorageOptions, UseStorageReturnValue } from './use-local-storage/create-storage';
|
|
99
|
+
export type { UseMovePosition, UseMoveHandlers, UseMoveReturnValue } from './use-move/use-move';
|
|
100
|
+
export type { UserNetworkReturnValue } from './use-network/use-network';
|
|
101
|
+
export type { UseOrientationOptions, UseOrientationReturnType, } from './use-orientation/use-orientation';
|
|
102
|
+
export type { UseOSReturnValue as OS, UseOSReturnValue, UseOsOptions } from './use-os/use-os';
|
|
103
|
+
export type { UsePaginationOptions, UsePaginationReturnValue, } from './use-pagination/use-pagination';
|
|
104
|
+
export type { UseQueueOptions, UseQueueReturnValue } from './use-queue/use-queue';
|
|
105
|
+
export type { UseRadialMoveOptions, UseRadialMoveReturnValue, } from './use-radial-move/use-radial-move';
|
|
106
|
+
export type { UseScrollIntoViewOptions, UseScrollIntoViewReturnValue, } from './use-scroll-into-view/use-scroll-into-view';
|
|
82
107
|
export type { UseScrollSpyOptions, UseScrollSpyHeadingData, UseScrollSpyReturnType, } from './use-scroll-spy/use-scroll-spy';
|
|
108
|
+
export type { UseSetStateCallback, UseSetStateReturnValue } from './use-set-state/use-set-state';
|
|
109
|
+
export type { UseStateHistoryHandlers, UseStateHistoryValue as StateHistory, UseStateHistoryValue, UseStateHistoryReturnValue, } from './use-state-history/use-state-history';
|
|
110
|
+
export type { UseTimeoutOptions, UseTimeoutReturnValue } from './use-timeout/use-timeout';
|
|
111
|
+
export type { UseToggleReturnValue } from './use-toggle/use-toggle';
|
|
112
|
+
export type { UseUncontrolledOptions, UseUncontrolledReturnValue, } from './use-uncontrolled/use-uncontrolled';
|
|
113
|
+
export type { UseValidatedStateValue, UseValidatedStateReturnValue, } from './use-validated-state/use-validated-state';
|
|
114
|
+
export type { UseWindowScrollPosition, UseWindowScrollTo, UseWindowScrollReturnValue, } from './use-window-scroll/use-window-scroll';
|
|
115
|
+
export type { UseLongPressOptions, UseLongPressReturnValue } from './use-long-press/use-long-press';
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
export interface UseClipboardOptions {
|
|
2
|
+
/** Time in ms after which the copied state will reset, `2000` by default */
|
|
3
|
+
timeout?: number;
|
|
4
|
+
}
|
|
5
|
+
export interface UseClipboardReturnValue {
|
|
6
|
+
/** Function to copy value to clipboard */
|
|
7
|
+
copy: (value: any) => void;
|
|
8
|
+
/** Function to reset copied state and error */
|
|
5
9
|
reset: () => void;
|
|
10
|
+
/** Error if copying failed */
|
|
6
11
|
error: Error | null;
|
|
12
|
+
/** Boolean indicating if the value was copied successfully */
|
|
7
13
|
copied: boolean;
|
|
8
|
-
}
|
|
14
|
+
}
|
|
15
|
+
export declare function useClipboard(options?: UseClipboardOptions): UseClipboardReturnValue;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { UseMediaQueryOptions } from '../use-media-query/use-media-query';
|
|
2
|
-
export
|
|
2
|
+
export type UseColorSchemeValue = 'dark' | 'light';
|
|
3
|
+
export declare function useColorScheme(initialValue?: UseColorSchemeValue, options?: UseMediaQueryOptions): UseColorSchemeValue;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
export
|
|
2
|
-
min
|
|
3
|
-
max
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
export interface UseCounterOptions {
|
|
2
|
+
min?: number;
|
|
3
|
+
max?: number;
|
|
4
|
+
}
|
|
5
|
+
export interface UseCounterHandlers {
|
|
6
|
+
increment: () => void;
|
|
7
|
+
decrement: () => void;
|
|
8
|
+
set: (value: number) => void;
|
|
9
|
+
reset: () => void;
|
|
10
|
+
}
|
|
11
|
+
export type UseCounterReturnValue = [number, UseCounterHandlers];
|
|
12
|
+
export declare function useCounter(initialValue?: number, options?: UseCounterOptions): [number, UseCounterHandlers];
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface UseDebouncedCallbackOptions {
|
|
2
2
|
delay: number;
|
|
3
3
|
flushOnUnmount?: boolean;
|
|
4
4
|
leading?: boolean;
|
|
5
|
-
}
|
|
5
|
+
}
|
|
6
|
+
export type UseDebouncedCallbackReturnValue<T extends (...args: any[]) => any> = ((...args: Parameters<T>) => void) & {
|
|
6
7
|
flush: () => void;
|
|
8
|
+
cancel: () => void;
|
|
9
|
+
};
|
|
10
|
+
export declare function useDebouncedCallback<T extends (...args: any[]) => any>(callback: T, options: number | UseDebouncedCallbackOptions): ((...args: Parameters<T>) => void) & {
|
|
11
|
+
flush: () => void;
|
|
12
|
+
cancel: () => void;
|
|
13
|
+
_isFirstCall: boolean;
|
|
7
14
|
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { SetStateAction } from 'react';
|
|
2
|
-
export
|
|
3
|
-
leading
|
|
4
|
-
}
|
|
2
|
+
export interface UseDebouncedStateOptions {
|
|
3
|
+
leading?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export type UseDebouncedStateReturnValue<T> = [T, (newValue: SetStateAction<T>) => void];
|
|
6
|
+
export declare function useDebouncedState<T = any>(defaultValue: T, wait: number, options?: UseDebouncedStateOptions): UseDebouncedStateReturnValue<T>;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
leading
|
|
3
|
-
}
|
|
1
|
+
export interface UseDebouncedValueOptions {
|
|
2
|
+
leading?: boolean;
|
|
3
|
+
}
|
|
4
|
+
export type UseDebouncedValueReturnValue<T> = [T, () => void];
|
|
5
|
+
export declare function useDebouncedValue<T = any>(value: T, wait: number, options?: UseDebouncedValueOptions): UseDebouncedValueReturnValue<T>;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface UseDisclosureOptions {
|
|
2
2
|
onOpen?: () => void;
|
|
3
3
|
onClose?: () => void;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
}
|
|
5
|
+
export interface UseDisclosureHandlers {
|
|
6
|
+
open: () => void;
|
|
7
|
+
close: () => void;
|
|
8
|
+
toggle: () => void;
|
|
9
|
+
}
|
|
10
|
+
export type UseDisclosureReturnValue = [boolean, UseDisclosureHandlers];
|
|
11
|
+
export declare function useDisclosure(initialState?: boolean, options?: UseDisclosureOptions): UseDisclosureReturnValue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function useEventListener<K extends keyof HTMLElementEventMap, T extends HTMLElement = any>(type: K, listener: (this: HTMLDivElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions):
|
|
1
|
+
export declare function useEventListener<K extends keyof HTMLElementEventMap, T extends HTMLElement = any>(type: K, listener: (this: HTMLDivElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): React.RefCallback<T | null>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
interface EyeDropperOpenOptions {
|
|
1
|
+
export interface EyeDropperOpenOptions {
|
|
2
2
|
signal?: AbortSignal;
|
|
3
3
|
}
|
|
4
4
|
export interface EyeDropperOpenReturnType {
|
|
5
5
|
sRGBHex: string;
|
|
6
6
|
}
|
|
7
|
-
export
|
|
7
|
+
export interface UseEyeDropperReturnValue {
|
|
8
8
|
supported: boolean;
|
|
9
9
|
open: (options?: EyeDropperOpenOptions) => Promise<EyeDropperOpenReturnType | undefined>;
|
|
10
|
-
}
|
|
11
|
-
export
|
|
10
|
+
}
|
|
11
|
+
export declare function useEyeDropper(): UseEyeDropperReturnValue;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export interface UseFetchOptions extends RequestInit {
|
|
2
2
|
autoInvoke?: boolean;
|
|
3
3
|
}
|
|
4
|
-
export
|
|
4
|
+
export interface UseFetchReturnValue<T> {
|
|
5
5
|
data: T | null;
|
|
6
6
|
loading: boolean;
|
|
7
7
|
error: Error | null;
|
|
8
|
-
refetch: () => Promise<any
|
|
8
|
+
refetch: () => Promise<any>;
|
|
9
9
|
abort: () => void;
|
|
10
|
-
}
|
|
10
|
+
}
|
|
11
|
+
export declare function useFetch<T>(url: string, { autoInvoke, ...options }?: UseFetchOptions): UseFetchReturnValue<T>;
|
|
@@ -16,8 +16,9 @@ export interface UseFileDialogOptions {
|
|
|
16
16
|
/** Called when file dialog is canceled */
|
|
17
17
|
onCancel?: () => void;
|
|
18
18
|
}
|
|
19
|
-
export
|
|
19
|
+
export interface UseFileDialogReturnValue {
|
|
20
20
|
files: FileList | null;
|
|
21
21
|
open: () => void;
|
|
22
22
|
reset: () => void;
|
|
23
|
-
}
|
|
23
|
+
}
|
|
24
|
+
export declare function useFileDialog(input?: UseFileDialogOptions): UseFileDialogReturnValue;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
interface
|
|
1
|
+
export interface UseFocusReturnOptions {
|
|
2
2
|
opened: boolean;
|
|
3
3
|
shouldReturnFocus?: boolean;
|
|
4
4
|
}
|
|
5
|
-
|
|
6
|
-
export declare function useFocusReturn({ opened, shouldReturnFocus }:
|
|
7
|
-
export {};
|
|
5
|
+
export type UseFocusReturnReturnValue = () => void;
|
|
6
|
+
export declare function useFocusReturn({ opened, shouldReturnFocus, }: UseFocusReturnOptions): UseFocusReturnReturnValue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function useFocusTrap(active?: boolean):
|
|
1
|
+
export declare function useFocusTrap(active?: boolean): React.RefCallback<HTMLElement | null>;
|
|
@@ -2,7 +2,8 @@ export interface UseFocusWithinOptions {
|
|
|
2
2
|
onFocus?: (event: FocusEvent) => void;
|
|
3
3
|
onBlur?: (event: FocusEvent) => void;
|
|
4
4
|
}
|
|
5
|
-
export
|
|
6
|
-
ref: React.
|
|
5
|
+
export interface UseFocusWithinReturnValue<T extends HTMLElement = any> {
|
|
6
|
+
ref: React.RefCallback<T | null>;
|
|
7
7
|
focused: boolean;
|
|
8
|
-
}
|
|
8
|
+
}
|
|
9
|
+
export declare function useFocusWithin<T extends HTMLElement = any>({ onBlur, onFocus, }?: UseFocusWithinOptions): UseFocusWithinReturnValue<T>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
1
|
+
export interface UseFullscreenReturnValue<T extends HTMLElement = any> {
|
|
2
|
+
ref: React.RefCallback<T | null>;
|
|
3
|
+
toggle: () => Promise<void>;
|
|
4
|
+
fullscreen: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare function useFullscreen<T extends HTMLElement = any>(): UseFullscreenReturnValue<T>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
interface UseHashOptions {
|
|
1
|
+
export interface UseHashOptions {
|
|
2
2
|
getInitialValueInEffect?: boolean;
|
|
3
3
|
}
|
|
4
|
-
export
|
|
5
|
-
export {};
|
|
4
|
+
export type UseHashReturnValue = [string, (value: string) => void];
|
|
5
|
+
export declare function useHash({ getInitialValueInEffect, }?: UseHashOptions): UseHashReturnValue;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export declare const isFixed: (current: number, fixedAt: number) => boolean;
|
|
2
2
|
export declare const isPinned: (current: number, previous: number) => boolean;
|
|
3
3
|
export declare const isReleased: (current: number, previous: number, fixedAt: number) => boolean;
|
|
4
|
-
export declare const isPinnedOrReleased: (current: number, fixedAt: number, isCurrentlyPinnedRef: React.
|
|
4
|
+
export declare const isPinnedOrReleased: (current: number, fixedAt: number, isCurrentlyPinnedRef: React.RefObject<boolean>, isScrollingUp: boolean, onPin?: () => void, onRelease?: () => void) => void;
|
|
5
5
|
export declare const useScrollDirection: () => boolean;
|
|
6
|
-
interface
|
|
6
|
+
export interface UseHeadroomOptions {
|
|
7
7
|
/** Number in px at which element should be fixed */
|
|
8
8
|
fixedAt?: number;
|
|
9
9
|
/** Called when element is pinned */
|
|
@@ -13,5 +13,4 @@ interface UseHeadroomInput {
|
|
|
13
13
|
/** Called when element is unpinned */
|
|
14
14
|
onRelease?: () => void;
|
|
15
15
|
}
|
|
16
|
-
export declare function useHeadroom({ fixedAt, onPin, onFix, onRelease }?:
|
|
17
|
-
export {};
|
|
16
|
+
export declare function useHeadroom({ fixedAt, onPin, onFix, onRelease }?: UseHeadroomOptions): boolean;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
ref: import("react").RefObject<T | null>;
|
|
1
|
+
export interface UseHoverReturnValue<T extends HTMLElement = any> {
|
|
3
2
|
hovered: boolean;
|
|
4
|
-
|
|
3
|
+
ref: React.RefCallback<T | null>;
|
|
4
|
+
}
|
|
5
|
+
export declare function useHover<T extends HTMLElement = any>(): UseHoverReturnValue<T>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
events
|
|
3
|
-
initialState
|
|
4
|
-
}
|
|
1
|
+
export interface UseIdleOptions {
|
|
2
|
+
events?: (keyof DocumentEventMap)[];
|
|
3
|
+
initialState?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare function useIdle(timeout: number, options?: UseIdleOptions): boolean;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
ref: (node: T | null) => void;
|
|
1
|
+
export interface UseInViewportReturnValue<T extends HTMLElement = any> {
|
|
3
2
|
inViewport: boolean;
|
|
4
|
-
|
|
3
|
+
ref: React.RefCallback<T | null>;
|
|
4
|
+
}
|
|
5
|
+
export declare function useInViewport<T extends HTMLElement = any>(): UseInViewportReturnValue<T>;
|
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
export declare function getInputOnChange<T>(setValue: (value: null | undefined | T | ((current: T) => T)) => void): (val: null | undefined | T | React.ChangeEvent<any> | ((current: T) => T)) => void;
|
|
2
|
-
export
|
|
2
|
+
export type UseInputStateReturnValue<T> = [
|
|
3
|
+
T,
|
|
4
|
+
(value: null | undefined | T | React.ChangeEvent<any>) => void
|
|
5
|
+
];
|
|
6
|
+
export declare function useInputState<T>(initialState: T): UseInputStateReturnValue<T>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
ref:
|
|
1
|
+
export interface UseIntersectionReturnValue<T> {
|
|
2
|
+
ref: React.RefCallback<T | null>;
|
|
3
3
|
entry: IntersectionObserverEntry | null;
|
|
4
|
-
}
|
|
4
|
+
}
|
|
5
|
+
export declare function useIntersection<T extends HTMLElement = any>(options?: IntersectionObserverInit): UseIntersectionReturnValue<T>;
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
interface UseIntervalOptions {
|
|
1
|
+
export interface UseIntervalOptions {
|
|
2
2
|
/** If set, the interval will start automatically when the component is mounted, `false` by default */
|
|
3
3
|
autoInvoke?: boolean;
|
|
4
4
|
}
|
|
5
|
-
export
|
|
5
|
+
export interface UseIntervalReturnValue {
|
|
6
|
+
/** Starts the interval */
|
|
6
7
|
start: () => void;
|
|
8
|
+
/** Stops the interval */
|
|
7
9
|
stop: () => void;
|
|
10
|
+
/** Toggles the interval */
|
|
8
11
|
toggle: () => void;
|
|
12
|
+
/** Indicates if the interval is active */
|
|
9
13
|
active: boolean;
|
|
10
|
-
}
|
|
11
|
-
export {};
|
|
14
|
+
}
|
|
15
|
+
export declare function useInterval(fn: () => void, interval: number, { autoInvoke }?: UseIntervalOptions): UseIntervalReturnValue;
|
|
@@ -20,5 +20,5 @@ export interface UseListStateHandlers<T> {
|
|
|
20
20
|
setItemProp: <K extends keyof T, U extends T[K]>(index: number, prop: K, value: U) => void;
|
|
21
21
|
filter: (fn: (item: T, i: number) => boolean) => void;
|
|
22
22
|
}
|
|
23
|
-
export type
|
|
24
|
-
export declare function useListState<T>(initialValue?: T[]):
|
|
23
|
+
export type UseListStateReturnValue<T> = [T[], UseListStateHandlers<T>];
|
|
24
|
+
export declare function useListState<T>(initialValue?: T[]): UseListStateReturnValue<T>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type StorageType = 'localStorage' | 'sessionStorage';
|
|
2
|
-
export interface
|
|
2
|
+
export interface UseStorageOptions<T> {
|
|
3
3
|
/** Storage key */
|
|
4
4
|
key: string;
|
|
5
5
|
/** Default value that will be set if value is not found in storage */
|
|
@@ -13,5 +13,10 @@ export interface StorageProperties<T> {
|
|
|
13
13
|
/** Function to deserialize string value from storage to value */
|
|
14
14
|
deserialize?: (value: string | undefined) => T;
|
|
15
15
|
}
|
|
16
|
-
export
|
|
17
|
-
|
|
16
|
+
export type UseStorageReturnValue<T> = [
|
|
17
|
+
T,
|
|
18
|
+
(val: T | ((prevState: T) => T)) => void,
|
|
19
|
+
() => void
|
|
20
|
+
];
|
|
21
|
+
export declare function createStorage<T>(type: StorageType, hookName: string): ({ key, defaultValue, getInitialValueInEffect, sync, deserialize, serialize, }: UseStorageOptions<T>) => UseStorageReturnValue<T>;
|
|
22
|
+
export declare function readValue(type: StorageType): <T>({ key, defaultValue, deserialize, }: UseStorageOptions<T>) => T;
|