@siberiacancode/reactuse 0.3.3 → 0.3.5
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/dist/cjs/hooks/useActiveElement/useActiveElement.cjs +1 -1
- package/dist/cjs/hooks/useActiveElement/useActiveElement.cjs.map +1 -1
- package/dist/cjs/hooks/useAutoScroll/useAutoScroll.cjs +1 -1
- package/dist/cjs/hooks/useAutoScroll/useAutoScroll.cjs.map +1 -1
- package/dist/cjs/hooks/useBreakpoints/useBreakpoints.cjs +1 -1
- package/dist/cjs/hooks/useBreakpoints/useBreakpoints.cjs.map +1 -1
- package/dist/cjs/hooks/useClickOutside/useClickOutside.cjs +1 -1
- package/dist/cjs/hooks/useClickOutside/useClickOutside.cjs.map +1 -1
- package/dist/cjs/hooks/useCookie/useCookie.cjs +1 -1
- package/dist/cjs/hooks/useCookie/useCookie.cjs.map +1 -1
- package/dist/cjs/hooks/useCounter/useCounter.cjs +1 -1
- package/dist/cjs/hooks/useCounter/useCounter.cjs.map +1 -1
- package/dist/cjs/hooks/useCssVar/useCssVar.cjs +1 -1
- package/dist/cjs/hooks/useCssVar/useCssVar.cjs.map +1 -1
- package/dist/cjs/hooks/useDeviceMotion/useDeviceMotion.cjs +1 -1
- package/dist/cjs/hooks/useDeviceMotion/useDeviceMotion.cjs.map +1 -1
- package/dist/cjs/hooks/useDisplayMedia/useDisplayMedia.cjs +1 -1
- package/dist/cjs/hooks/useDisplayMedia/useDisplayMedia.cjs.map +1 -1
- package/dist/cjs/hooks/useDoubleClick/useDoubleClick.cjs +1 -1
- package/dist/cjs/hooks/useDoubleClick/useDoubleClick.cjs.map +1 -1
- package/dist/cjs/hooks/useDropZone/useDropZone.cjs +1 -1
- package/dist/cjs/hooks/useDropZone/useDropZone.cjs.map +1 -1
- package/dist/cjs/hooks/useElementSize/useElementSize.cjs +1 -1
- package/dist/cjs/hooks/useElementSize/useElementSize.cjs.map +1 -1
- package/dist/cjs/hooks/useEventListener/useEventListener.cjs +1 -1
- package/dist/cjs/hooks/useEventListener/useEventListener.cjs.map +1 -1
- package/dist/cjs/hooks/useEventSource/useEventSource.cjs +1 -1
- package/dist/cjs/hooks/useEventSource/useEventSource.cjs.map +1 -1
- package/dist/cjs/hooks/useField/useField.cjs +1 -1
- package/dist/cjs/hooks/useField/useField.cjs.map +1 -1
- package/dist/cjs/hooks/useFileDialog/useFileDialog.cjs +1 -1
- package/dist/cjs/hooks/useFileDialog/useFileDialog.cjs.map +1 -1
- package/dist/cjs/hooks/useFocus/useFocus.cjs +1 -1
- package/dist/cjs/hooks/useFocus/useFocus.cjs.map +1 -1
- package/dist/cjs/hooks/useFocusTrap/useFocusTrap.cjs +1 -1
- package/dist/cjs/hooks/useFocusTrap/useFocusTrap.cjs.map +1 -1
- package/dist/cjs/hooks/useFullscreen/useFullscreen.cjs +1 -1
- package/dist/cjs/hooks/useFullscreen/useFullscreen.cjs.map +1 -1
- package/dist/cjs/hooks/useHash/useHash.cjs +1 -1
- package/dist/cjs/hooks/useHash/useHash.cjs.map +1 -1
- package/dist/cjs/hooks/useHotkeys/useHotkeys.cjs +1 -1
- package/dist/cjs/hooks/useHotkeys/useHotkeys.cjs.map +1 -1
- package/dist/cjs/hooks/useHover/useHover.cjs +1 -1
- package/dist/cjs/hooks/useHover/useHover.cjs.map +1 -1
- package/dist/cjs/hooks/useInfiniteScroll/useInfiniteScroll.cjs +1 -1
- package/dist/cjs/hooks/useInfiniteScroll/useInfiniteScroll.cjs.map +1 -1
- package/dist/cjs/hooks/useIntersectionObserver/useIntersectionObserver.cjs +1 -1
- package/dist/cjs/hooks/useIntersectionObserver/useIntersectionObserver.cjs.map +1 -1
- package/dist/cjs/hooks/useInterval/useInterval.cjs +1 -1
- package/dist/cjs/hooks/useInterval/useInterval.cjs.map +1 -1
- package/dist/cjs/hooks/useKeyPress/useKeyPress.cjs +1 -1
- package/dist/cjs/hooks/useKeyPress/useKeyPress.cjs.map +1 -1
- package/dist/cjs/hooks/useKeyPressEvent/useKeyPressEvent.cjs +1 -1
- package/dist/cjs/hooks/useKeyPressEvent/useKeyPressEvent.cjs.map +1 -1
- package/dist/cjs/hooks/useKeyboard/useKeyboard.cjs +1 -1
- package/dist/cjs/hooks/useKeyboard/useKeyboard.cjs.map +1 -1
- package/dist/cjs/hooks/useKeysPressed/useKeysPressed.cjs +1 -1
- package/dist/cjs/hooks/useKeysPressed/useKeysPressed.cjs.map +1 -1
- package/dist/cjs/hooks/useLockScroll/useLockScroll.cjs +1 -1
- package/dist/cjs/hooks/useLockScroll/useLockScroll.cjs.map +1 -1
- package/dist/cjs/hooks/useLongPress/useLongPress.cjs +1 -1
- package/dist/cjs/hooks/useLongPress/useLongPress.cjs.map +1 -1
- package/dist/cjs/hooks/useMeasure/useMeasure.cjs +1 -1
- package/dist/cjs/hooks/useMeasure/useMeasure.cjs.map +1 -1
- package/dist/cjs/hooks/useMediaControls/useMediaControls.cjs +1 -1
- package/dist/cjs/hooks/useMediaControls/useMediaControls.cjs.map +1 -1
- package/dist/cjs/hooks/useMouse/useMouse.cjs +1 -1
- package/dist/cjs/hooks/useMouse/useMouse.cjs.map +1 -1
- package/dist/cjs/hooks/useMutationObserver/useMutationObserver.cjs +1 -1
- package/dist/cjs/hooks/useMutationObserver/useMutationObserver.cjs.map +1 -1
- package/dist/cjs/hooks/useOtpCredential/useOtpCredential.cjs +1 -1
- package/dist/cjs/hooks/useOtpCredential/useOtpCredential.cjs.map +1 -1
- package/dist/cjs/hooks/usePaint/usePaint.cjs +1 -1
- package/dist/cjs/hooks/usePaint/usePaint.cjs.map +1 -1
- package/dist/cjs/hooks/useParallax/useParallax.cjs +1 -1
- package/dist/cjs/hooks/useParallax/useParallax.cjs.map +1 -1
- package/dist/cjs/hooks/usePictureInPicture/usePictureInPicture.cjs +1 -1
- package/dist/cjs/hooks/usePictureInPicture/usePictureInPicture.cjs.map +1 -1
- package/dist/cjs/hooks/useRefState/useRefState.cjs +1 -1
- package/dist/cjs/hooks/useRefState/useRefState.cjs.map +1 -1
- package/dist/cjs/hooks/useResizeObserver/useResizeObserver.cjs +1 -1
- package/dist/cjs/hooks/useResizeObserver/useResizeObserver.cjs.map +1 -1
- package/dist/cjs/hooks/useRightClick/useRightClick.cjs +1 -1
- package/dist/cjs/hooks/useRightClick/useRightClick.cjs.map +1 -1
- package/dist/cjs/hooks/useScroll/useScroll.cjs +1 -1
- package/dist/cjs/hooks/useScroll/useScroll.cjs.map +1 -1
- package/dist/cjs/hooks/useScrollIntoView/useScrollIntoView.cjs +1 -1
- package/dist/cjs/hooks/useScrollIntoView/useScrollIntoView.cjs.map +1 -1
- package/dist/cjs/hooks/useScrollTo/useScrollTo.cjs +1 -1
- package/dist/cjs/hooks/useScrollTo/useScrollTo.cjs.map +1 -1
- package/dist/cjs/hooks/useSpeechRecognition/useSpeechRecognition.cjs +1 -1
- package/dist/cjs/hooks/useSpeechRecognition/useSpeechRecognition.cjs.map +1 -1
- package/dist/cjs/hooks/useSpeechSynthesis/useSpeechSynthesis.cjs +1 -1
- package/dist/cjs/hooks/useSpeechSynthesis/useSpeechSynthesis.cjs.map +1 -1
- package/dist/cjs/hooks/useSticky/useSticky.cjs +1 -1
- package/dist/cjs/hooks/useSticky/useSticky.cjs.map +1 -1
- package/dist/cjs/hooks/useStopwatch/useStopwatch.cjs +1 -1
- package/dist/cjs/hooks/useStopwatch/useStopwatch.cjs.map +1 -1
- package/dist/cjs/hooks/useStorage/useStorage.cjs +1 -1
- package/dist/cjs/hooks/useStorage/useStorage.cjs.map +1 -1
- package/dist/cjs/hooks/useTextDirection/useTextDirection.cjs +1 -1
- package/dist/cjs/hooks/useTextDirection/useTextDirection.cjs.map +1 -1
- package/dist/cjs/hooks/useTextareaAutosize/useTextareaAutosize.cjs +1 -1
- package/dist/cjs/hooks/useTextareaAutosize/useTextareaAutosize.cjs.map +1 -1
- package/dist/cjs/hooks/useTimer/useTimer.cjs +1 -1
- package/dist/cjs/hooks/useTimer/useTimer.cjs.map +1 -1
- package/dist/cjs/hooks/useUrlSearchParam/useUrlSearchParam.cjs +1 -1
- package/dist/cjs/hooks/useUrlSearchParam/useUrlSearchParam.cjs.map +1 -1
- package/dist/cjs/hooks/useUrlSearchParams/useUrlSearchParams.cjs +1 -1
- package/dist/cjs/hooks/useUrlSearchParams/useUrlSearchParams.cjs.map +1 -1
- package/dist/cjs/hooks/useVisibility/useVisibility.cjs +1 -1
- package/dist/cjs/hooks/useVisibility/useVisibility.cjs.map +1 -1
- package/dist/cjs/hooks/useWindowFocus/useWindowFocus.cjs +1 -1
- package/dist/cjs/hooks/useWindowFocus/useWindowFocus.cjs.map +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/utils/helpers/isTarget.cjs +1 -1
- package/dist/cjs/utils/helpers/isTarget.cjs.map +1 -1
- package/dist/esm/hooks/useActiveElement/useActiveElement.mjs +13 -13
- package/dist/esm/hooks/useActiveElement/useActiveElement.mjs.map +1 -1
- package/dist/esm/hooks/useAutoScroll/useAutoScroll.mjs +24 -24
- package/dist/esm/hooks/useAutoScroll/useAutoScroll.mjs.map +1 -1
- package/dist/esm/hooks/useBreakpoints/useBreakpoints.mjs +30 -35
- package/dist/esm/hooks/useBreakpoints/useBreakpoints.mjs.map +1 -1
- package/dist/esm/hooks/useClickOutside/useClickOutside.mjs +15 -14
- package/dist/esm/hooks/useClickOutside/useClickOutside.mjs.map +1 -1
- package/dist/esm/hooks/useCookie/useCookie.mjs +2 -2
- package/dist/esm/hooks/useCookie/useCookie.mjs.map +1 -1
- package/dist/esm/hooks/useCounter/useCounter.mjs +2 -2
- package/dist/esm/hooks/useCounter/useCounter.mjs.map +1 -1
- package/dist/esm/hooks/useCssVar/useCssVar.mjs +8 -8
- package/dist/esm/hooks/useCssVar/useCssVar.mjs.map +1 -1
- package/dist/esm/hooks/useDeviceMotion/useDeviceMotion.mjs +2 -2
- package/dist/esm/hooks/useDeviceMotion/useDeviceMotion.mjs.map +1 -1
- package/dist/esm/hooks/useDisplayMedia/useDisplayMedia.mjs +17 -17
- package/dist/esm/hooks/useDisplayMedia/useDisplayMedia.mjs.map +1 -1
- package/dist/esm/hooks/useDoubleClick/useDoubleClick.mjs +14 -14
- package/dist/esm/hooks/useDoubleClick/useDoubleClick.mjs.map +1 -1
- package/dist/esm/hooks/useDropZone/useDropZone.mjs +23 -23
- package/dist/esm/hooks/useDropZone/useDropZone.mjs.map +1 -1
- package/dist/esm/hooks/useElementSize/useElementSize.mjs +14 -14
- package/dist/esm/hooks/useElementSize/useElementSize.mjs.map +1 -1
- package/dist/esm/hooks/useEventListener/useEventListener.mjs +14 -14
- package/dist/esm/hooks/useEventListener/useEventListener.mjs.map +1 -1
- package/dist/esm/hooks/useEventSource/useEventSource.mjs +33 -34
- package/dist/esm/hooks/useEventSource/useEventSource.mjs.map +1 -1
- package/dist/esm/hooks/useField/useField.mjs +2 -1
- package/dist/esm/hooks/useField/useField.mjs.map +1 -1
- package/dist/esm/hooks/useFileDialog/useFileDialog.mjs +2 -2
- package/dist/esm/hooks/useFileDialog/useFileDialog.mjs.map +1 -1
- package/dist/esm/hooks/useFocus/useFocus.mjs +20 -20
- package/dist/esm/hooks/useFocus/useFocus.mjs.map +1 -1
- package/dist/esm/hooks/useFocusTrap/useFocusTrap.mjs +21 -21
- package/dist/esm/hooks/useFocusTrap/useFocusTrap.mjs.map +1 -1
- package/dist/esm/hooks/useFullscreen/useFullscreen.mjs +2 -2
- package/dist/esm/hooks/useFullscreen/useFullscreen.mjs.map +1 -1
- package/dist/esm/hooks/useHash/useHash.mjs +2 -2
- package/dist/esm/hooks/useHash/useHash.mjs.map +1 -1
- package/dist/esm/hooks/useHotkeys/useHotkeys.mjs +24 -16
- package/dist/esm/hooks/useHotkeys/useHotkeys.mjs.map +1 -1
- package/dist/esm/hooks/useHover/useHover.mjs +16 -16
- package/dist/esm/hooks/useHover/useHover.mjs.map +1 -1
- package/dist/esm/hooks/useInfiniteScroll/useInfiniteScroll.mjs +16 -16
- package/dist/esm/hooks/useInfiniteScroll/useInfiniteScroll.mjs.map +1 -1
- package/dist/esm/hooks/useIntersectionObserver/useIntersectionObserver.mjs +26 -18
- package/dist/esm/hooks/useIntersectionObserver/useIntersectionObserver.mjs.map +1 -1
- package/dist/esm/hooks/useInterval/useInterval.mjs +2 -2
- package/dist/esm/hooks/useInterval/useInterval.mjs.map +1 -1
- package/dist/esm/hooks/useKeyPress/useKeyPress.mjs +15 -15
- package/dist/esm/hooks/useKeyPress/useKeyPress.mjs.map +1 -1
- package/dist/esm/hooks/useKeyPressEvent/useKeyPressEvent.mjs +22 -15
- package/dist/esm/hooks/useKeyPressEvent/useKeyPressEvent.mjs.map +1 -1
- package/dist/esm/hooks/useKeyboard/useKeyboard.mjs +10 -10
- package/dist/esm/hooks/useKeyboard/useKeyboard.mjs.map +1 -1
- package/dist/esm/hooks/useKeysPressed/useKeysPressed.mjs +12 -12
- package/dist/esm/hooks/useKeysPressed/useKeysPressed.mjs.map +1 -1
- package/dist/esm/hooks/useLockScroll/useLockScroll.mjs +23 -23
- package/dist/esm/hooks/useLockScroll/useLockScroll.mjs.map +1 -1
- package/dist/esm/hooks/useLongPress/useLongPress.mjs +22 -22
- package/dist/esm/hooks/useLongPress/useLongPress.mjs.map +1 -1
- package/dist/esm/hooks/useMeasure/useMeasure.mjs +15 -15
- package/dist/esm/hooks/useMeasure/useMeasure.mjs.map +1 -1
- package/dist/esm/hooks/useMediaControls/useMediaControls.mjs +28 -28
- package/dist/esm/hooks/useMediaControls/useMediaControls.mjs.map +1 -1
- package/dist/esm/hooks/useMouse/useMouse.mjs +17 -17
- package/dist/esm/hooks/useMouse/useMouse.mjs.map +1 -1
- package/dist/esm/hooks/useMutationObserver/useMutationObserver.mjs +17 -16
- package/dist/esm/hooks/useMutationObserver/useMutationObserver.mjs.map +1 -1
- package/dist/esm/hooks/useOtpCredential/useOtpCredential.mjs +2 -2
- package/dist/esm/hooks/useOtpCredential/useOtpCredential.mjs.map +1 -1
- package/dist/esm/hooks/usePaint/usePaint.mjs +31 -31
- package/dist/esm/hooks/usePaint/usePaint.mjs.map +1 -1
- package/dist/esm/hooks/useParallax/useParallax.mjs +24 -23
- package/dist/esm/hooks/useParallax/useParallax.mjs.map +1 -1
- package/dist/esm/hooks/usePictureInPicture/usePictureInPicture.mjs +25 -25
- package/dist/esm/hooks/usePictureInPicture/usePictureInPicture.mjs.map +1 -1
- package/dist/esm/hooks/useRefState/useRefState.mjs +1 -0
- package/dist/esm/hooks/useRefState/useRefState.mjs.map +1 -1
- package/dist/esm/hooks/useResizeObserver/useResizeObserver.mjs +16 -16
- package/dist/esm/hooks/useResizeObserver/useResizeObserver.mjs.map +1 -1
- package/dist/esm/hooks/useRightClick/useRightClick.mjs +14 -14
- package/dist/esm/hooks/useRightClick/useRightClick.mjs.map +1 -1
- package/dist/esm/hooks/useScroll/useScroll.mjs +22 -22
- package/dist/esm/hooks/useScroll/useScroll.mjs.map +1 -1
- package/dist/esm/hooks/useScrollIntoView/useScrollIntoView.mjs +16 -16
- package/dist/esm/hooks/useScrollIntoView/useScrollIntoView.mjs.map +1 -1
- package/dist/esm/hooks/useScrollTo/useScrollTo.mjs +10 -10
- package/dist/esm/hooks/useScrollTo/useScrollTo.mjs.map +1 -1
- package/dist/esm/hooks/useSpeechRecognition/useSpeechRecognition.mjs +20 -21
- package/dist/esm/hooks/useSpeechRecognition/useSpeechRecognition.mjs.map +1 -1
- package/dist/esm/hooks/useSpeechSynthesis/useSpeechSynthesis.mjs +51 -36
- package/dist/esm/hooks/useSpeechSynthesis/useSpeechSynthesis.mjs.map +1 -1
- package/dist/esm/hooks/useSticky/useSticky.mjs +17 -17
- package/dist/esm/hooks/useSticky/useSticky.mjs.map +1 -1
- package/dist/esm/hooks/useStopwatch/useStopwatch.mjs +4 -4
- package/dist/esm/hooks/useStopwatch/useStopwatch.mjs.map +1 -1
- package/dist/esm/hooks/useStorage/useStorage.mjs +40 -37
- package/dist/esm/hooks/useStorage/useStorage.mjs.map +1 -1
- package/dist/esm/hooks/useTextDirection/useTextDirection.mjs +12 -12
- package/dist/esm/hooks/useTextDirection/useTextDirection.mjs.map +1 -1
- package/dist/esm/hooks/useTextareaAutosize/useTextareaAutosize.mjs +20 -20
- package/dist/esm/hooks/useTextareaAutosize/useTextareaAutosize.mjs.map +1 -1
- package/dist/esm/hooks/useTimer/useTimer.mjs +3 -3
- package/dist/esm/hooks/useTimer/useTimer.mjs.map +1 -1
- package/dist/esm/hooks/useUrlSearchParam/useUrlSearchParam.mjs +2 -2
- package/dist/esm/hooks/useUrlSearchParam/useUrlSearchParam.mjs.map +1 -1
- package/dist/esm/hooks/useUrlSearchParams/useUrlSearchParams.mjs +2 -2
- package/dist/esm/hooks/useUrlSearchParams/useUrlSearchParams.mjs.map +1 -1
- package/dist/esm/hooks/useVisibility/useVisibility.mjs +25 -17
- package/dist/esm/hooks/useVisibility/useVisibility.mjs.map +1 -1
- package/dist/esm/hooks/useWindowFocus/useWindowFocus.mjs +1 -1
- package/dist/esm/hooks/useWindowFocus/useWindowFocus.mjs.map +1 -1
- package/dist/esm/index.mjs +98 -96
- package/dist/esm/utils/helpers/isTarget.mjs +10 -8
- package/dist/esm/utils/helpers/isTarget.mjs.map +1 -1
- package/dist/types/hooks/useBreakpoints/useBreakpoints.d.ts +1 -11
- package/dist/types/hooks/useClickOutside/useClickOutside.d.ts +1 -1
- package/dist/types/hooks/useEventSource/useEventSource.d.ts +2 -2
- package/dist/types/hooks/useField/useField.d.ts +3 -0
- package/dist/types/hooks/useHover/useHover.d.ts +6 -6
- package/dist/types/hooks/useRefState/useRefState.d.ts +1 -0
- package/dist/types/hooks/useSpeechSynthesis/useSpeechSynthesis.d.ts +1 -1
- package/dist/types/utils/helpers/isTarget.d.ts +9 -1
- package/package.json +89 -89
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
const
|
|
1
|
+
const u = /* @__PURE__ */ Symbol("target"), o = (e) => "current" in e ? e.current : typeof e.value == "function" ? e.value() : typeof e.value == "string" ? document.querySelector(e.value) : (e.value instanceof Document || e.value instanceof Window || e.value instanceof Element, e.value), i = (e) => ({
|
|
2
2
|
value: e,
|
|
3
|
-
type:
|
|
4
|
-
}),
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
type: u
|
|
4
|
+
}), n = (e) => typeof e == "object" && ("current" in e || e && e.type === u) || typeof e == "function" && "state" in e && "current" in e, c = (e) => e && "state" in e && e.state;
|
|
5
|
+
n.wrap = i;
|
|
6
|
+
n.getElement = o;
|
|
7
|
+
n.getRefState = c;
|
|
7
8
|
export {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
c as getRefState,
|
|
10
|
+
n as isTarget,
|
|
11
|
+
i as target,
|
|
12
|
+
u as targetSymbol
|
|
11
13
|
};
|
|
12
14
|
//# sourceMappingURL=isTarget.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isTarget.mjs","sources":["../../../../src/utils/helpers/isTarget.ts"],"sourcesContent":["import type { RefObject } from 'react';\n\nexport const targetSymbol = Symbol('target');\n\nexport type Target = (() => Element) | string | Document | Element | Window;\n\nexport type HookTarget =\n | RefObject<Element | null | undefined>\n | {\n value: Target;\n type: symbol;\n };\n\nconst getElement = (target: HookTarget) => {\n if ('current' in target) {\n return target.current;\n }\n\n if (typeof target.value === 'function') {\n return target.value();\n }\n\n if (typeof target.value === 'string') {\n return document.querySelector(target.value);\n }\n\n if (target.value instanceof Document) {\n return target.value;\n }\n\n if (target.value instanceof Window) {\n return target.value;\n }\n\n if (target.value instanceof Element) {\n return target.value;\n }\n\n return target.value;\n};\n\nexport const target = (target: Target) => ({\n value: target,\n type: targetSymbol\n});\n\nexport const isTarget = (target: HookTarget) =>\n typeof target === 'object' &&\n
|
|
1
|
+
{"version":3,"file":"isTarget.mjs","sources":["../../../../src/utils/helpers/isTarget.ts"],"sourcesContent":["import type { RefObject } from 'react';\n\nexport const targetSymbol = Symbol('target');\n\nexport type Target = (() => Element) | string | Document | Element | Window;\ninterface StateRef<Value> {\n (node: Value): void;\n current: Value;\n state: Value;\n}\n\nexport type HookTarget =\n | RefObject<Element | null | undefined>\n | StateRef<Element | null | undefined>\n | {\n value: Target;\n type: symbol;\n };\n\nconst getElement = (target: HookTarget) => {\n if ('current' in target) {\n return target.current;\n }\n\n if (typeof target.value === 'function') {\n return target.value();\n }\n\n if (typeof target.value === 'string') {\n return document.querySelector(target.value);\n }\n\n if (target.value instanceof Document) {\n return target.value;\n }\n\n if (target.value instanceof Window) {\n return target.value;\n }\n\n if (target.value instanceof Element) {\n return target.value;\n }\n\n return target.value;\n};\n\nexport const target = (target: Target) => ({\n value: target,\n type: targetSymbol\n});\n\nexport const isTarget = (target: HookTarget) =>\n (typeof target === 'object' &&\n ('current' in target || (target && (target as any).type === targetSymbol))) ||\n (typeof target === 'function' && 'state' in target && 'current' in target);\n\nexport const getRefState = (target?: HookTarget) => target && 'state' in target && target.state;\n\nisTarget.wrap = target;\nisTarget.getElement = getElement;\nisTarget.getRefState = getRefState;\n"],"names":["targetSymbol","getElement","target","isTarget","getRefState"],"mappings":"AAEO,MAAMA,2BAAsB,QAAQ,GAiBrCC,IAAa,CAACC,MACd,aAAaA,IACRA,EAAO,UAGZ,OAAOA,EAAO,SAAU,aACnBA,EAAO,MAAA,IAGZ,OAAOA,EAAO,SAAU,WACnB,SAAS,cAAcA,EAAO,KAAK,KAGxCA,EAAO,iBAAiB,YAIxBA,EAAO,iBAAiB,UAIxBA,EAAO,iBAAiB,SACnBA,EAAO,QAMLA,IAAS,CAACA,OAAoB;AAAA,EACzC,OAAOA;AAAAA,EACP,MAAMF;AACR,IAEaG,IAAW,CAACD,MACtB,OAAOA,KAAW,aAChB,aAAaA,KAAWA,KAAWA,EAAe,SAASF,MAC7D,OAAOE,KAAW,cAAc,WAAWA,KAAU,aAAaA,GAExDE,IAAc,CAACF,MAAwBA,KAAU,WAAWA,KAAUA,EAAO;AAE1FC,EAAS,OAAOD;AAChBC,EAAS,aAAaF;AACtBE,EAAS,cAAcC;"}
|
|
@@ -14,16 +14,6 @@ export type UseBreakpointsReturn<Breakpoint extends string = string> = {
|
|
|
14
14
|
smallerOrEqual: (breakpoint: Breakpoint) => boolean;
|
|
15
15
|
/** The function that checks if the current breakpoint is between to the given breakpoints */
|
|
16
16
|
between: (a: Breakpoint, b: Breakpoint) => boolean;
|
|
17
|
-
/** The function that checks if the current breakpoint is greater than to the given breakpoint */
|
|
18
|
-
isGreater: (breakpoint: Breakpoint) => boolean;
|
|
19
|
-
/** The function that checks if the current breakpoint is greater than or equal to the given breakpoint */
|
|
20
|
-
isGreaterOrEqual: (breakpoint: Breakpoint) => boolean;
|
|
21
|
-
/** The function that checks if the current breakpoint is smaller than to the given breakpoint */
|
|
22
|
-
isSmaller: (breakpoint: Breakpoint) => boolean;
|
|
23
|
-
/** The function that checks if the current breakpoint is smaller than or equal to the given breakpoint */
|
|
24
|
-
isSmallerOrEqual: (breakpoint: Breakpoint) => boolean;
|
|
25
|
-
/** The function that checks if the current breakpoint is between to the given breakpoints */
|
|
26
|
-
isInBetween: (a: Breakpoint, b: Breakpoint) => boolean;
|
|
27
17
|
/** The function that returns the current breakpoints */
|
|
28
18
|
current: () => Breakpoint[];
|
|
29
19
|
/** The function that returns the current active breakpoint */
|
|
@@ -41,7 +31,7 @@ export type UseBreakpointsReturn<Breakpoint extends string = string> = {
|
|
|
41
31
|
* @returns {UseBreakpointsReturn<Breakpoint>} An object containing the current breakpoint
|
|
42
32
|
*
|
|
43
33
|
* @example
|
|
44
|
-
* const {
|
|
34
|
+
* const { greater, smaller, between, current, active, ...breakpoints } = useBreakpoints({ mobile: 0, tablet: 640, laptop: 1024, desktop: 1280 });
|
|
45
35
|
*/
|
|
46
36
|
export declare const useBreakpoints: <Breakpoint extends string>(breakpoints: Breakpoints<Breakpoint>, strategy?: UseBreakpointsStrategy) => UseBreakpointsReturn<Breakpoint>;
|
|
47
37
|
/** Breakpoints from Material UI */
|
|
@@ -21,7 +21,7 @@ export interface UseClickOutside {
|
|
|
21
21
|
* @overload
|
|
22
22
|
* @template Target The target element(s)
|
|
23
23
|
* @param {(event: Event) => void} callback The callback to execute when a click outside the target is detected
|
|
24
|
-
* @returns {
|
|
24
|
+
* @returns {StateRef<Target>} A ref to attach to the target element
|
|
25
25
|
*
|
|
26
26
|
* @example
|
|
27
27
|
* const ref = useClickOutside<HTMLDivElement>(() => console.log('click outside'));
|
|
@@ -22,7 +22,7 @@ interface UseEventSourceReturn<Data = any> {
|
|
|
22
22
|
instance?: EventSource;
|
|
23
23
|
isConnecting: boolean;
|
|
24
24
|
isError: boolean;
|
|
25
|
-
|
|
25
|
+
opened: boolean;
|
|
26
26
|
/** Closes the EventSource connection gracefully */
|
|
27
27
|
close: () => void;
|
|
28
28
|
/** Reopen the EventSource connection */
|
|
@@ -42,7 +42,7 @@ interface UseEventSourceReturn<Data = any> {
|
|
|
42
42
|
* @returns {UseEventSourceReturn<Data>} The EventSource state and controls
|
|
43
43
|
*
|
|
44
44
|
* @example
|
|
45
|
-
* const { instance, data,
|
|
45
|
+
* const { instance, data, connecting, opened, isError, close, open } = useEventSource('url', ['message']);
|
|
46
46
|
*/
|
|
47
47
|
export declare const useEventSource: <QueryData = any, Data = QueryData>(url: string | URL, events?: string[], options?: UseEventSourceOptions<QueryData, Data>) => UseEventSourceReturn<Data>;
|
|
48
48
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
1
2
|
/** The use field params type */
|
|
2
3
|
export interface UseFieldParams<Value> {
|
|
3
4
|
/** The auto focus */
|
|
@@ -51,6 +52,8 @@ export interface UseFieldReturn<Value> {
|
|
|
51
52
|
dirty: boolean;
|
|
52
53
|
/** The error state */
|
|
53
54
|
error?: string;
|
|
55
|
+
/** The input ref */
|
|
56
|
+
ref: RefObject<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement | null>;
|
|
54
57
|
/** The set error function */
|
|
55
58
|
touched: boolean;
|
|
56
59
|
/** The set error function */
|
|
@@ -31,7 +31,7 @@ export interface UseHover {
|
|
|
31
31
|
* @overload
|
|
32
32
|
* @param {HookTarget} target The target element to be hovered
|
|
33
33
|
* @param {(event: Event) => void} [callback] The callback function to be invoked on mouse enter
|
|
34
|
-
* @returns {boolean} The
|
|
34
|
+
* @returns {boolean} The value of the hover
|
|
35
35
|
*
|
|
36
36
|
* @example
|
|
37
37
|
* const hovering = useHover(ref, () => console.log('callback'));
|
|
@@ -40,7 +40,7 @@ export interface UseHover {
|
|
|
40
40
|
* @param {HookTarget} target The target element to be hovered
|
|
41
41
|
* @param {(event: Event) => void} [options.onEntry] The callback function to be invoked on mouse enter
|
|
42
42
|
* @param {(event: Event) => void} [options.onLeave] The callback function to be invoked on mouse leave
|
|
43
|
-
* @returns {boolean} The
|
|
43
|
+
* @returns {boolean} The value of the hover
|
|
44
44
|
*
|
|
45
45
|
* @example
|
|
46
46
|
* const hovering = useHover(ref, options);
|
|
@@ -48,18 +48,18 @@ export interface UseHover {
|
|
|
48
48
|
* @overload
|
|
49
49
|
* @template Target The target element
|
|
50
50
|
* @param {(event: Event) => void} [callback] The callback function to be invoked on mouse enter
|
|
51
|
-
* @returns {{ ref: StateRef<Target> } & UseHoverReturn} The
|
|
51
|
+
* @returns {{ ref: StateRef<Target> } & UseHoverReturn} The object with the ref and the value of the hover
|
|
52
52
|
*
|
|
53
53
|
* @example
|
|
54
|
-
* const
|
|
54
|
+
* const { ref, value } = useHover(() => console.log('callback'));
|
|
55
55
|
*
|
|
56
56
|
* @overload
|
|
57
57
|
* @template Target The target element
|
|
58
58
|
* @param {(event: Event) => void} [options.onEntry] The callback function to be invoked on mouse enter
|
|
59
59
|
* @param {(event: Event) => void} [options.onLeave] The callback function to be invoked on mouse leave
|
|
60
|
-
* @returns {{ ref: StateRef<Target> } & UseHoverReturn} The
|
|
60
|
+
* @returns {{ ref: StateRef<Target> } & UseHoverReturn} The object with the ref and the value of the hover
|
|
61
61
|
*
|
|
62
62
|
* @example
|
|
63
|
-
* const
|
|
63
|
+
* const { ref, value } = useHover(options);
|
|
64
64
|
*/
|
|
65
65
|
export declare const useHover: UseHover;
|
|
@@ -3,6 +3,7 @@ export interface StateRef<Value> {
|
|
|
3
3
|
current: Value;
|
|
4
4
|
state?: Value;
|
|
5
5
|
}
|
|
6
|
+
export declare const createRefState: <Value>(initialValue: Value | undefined, setState: (value: Value) => void) => StateRef<Value>;
|
|
6
7
|
/**
|
|
7
8
|
* @name useRefState
|
|
8
9
|
* @description - Hook that returns the state reference of the value
|
|
@@ -26,7 +26,7 @@ export interface UseSpeechSynthesisReturn {
|
|
|
26
26
|
/** Indicates if the SpeechSynthesis API is supported in the current environment. */
|
|
27
27
|
supported: boolean;
|
|
28
28
|
/** The SpeechSynthesisUtterance instance. */
|
|
29
|
-
utterance: SpeechSynthesisUtterance |
|
|
29
|
+
utterance: SpeechSynthesisUtterance | undefined;
|
|
30
30
|
/** Function to pause speech synthesis. */
|
|
31
31
|
pause: () => void;
|
|
32
32
|
/** Function to resume speech synthesis. */
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { RefObject } from 'react';
|
|
2
2
|
export declare const targetSymbol: unique symbol;
|
|
3
3
|
export type Target = (() => Element) | string | Document | Element | Window;
|
|
4
|
-
|
|
4
|
+
interface StateRef<Value> {
|
|
5
|
+
(node: Value): void;
|
|
6
|
+
current: Value;
|
|
7
|
+
state: Value;
|
|
8
|
+
}
|
|
9
|
+
export type HookTarget = RefObject<Element | null | undefined> | StateRef<Element | null | undefined> | {
|
|
5
10
|
value: Target;
|
|
6
11
|
type: symbol;
|
|
7
12
|
};
|
|
@@ -16,4 +21,7 @@ export declare const isTarget: {
|
|
|
16
21
|
type: symbol;
|
|
17
22
|
};
|
|
18
23
|
getElement: (target: HookTarget) => Window | Document | Element | null | undefined;
|
|
24
|
+
getRefState: (target?: HookTarget) => false | Element | null | undefined;
|
|
19
25
|
};
|
|
26
|
+
export declare const getRefState: (target?: HookTarget) => false | Element | null | undefined;
|
|
27
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,89 +1,89 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@siberiacancode/reactuse",
|
|
3
|
-
"version": "0.3.
|
|
4
|
-
"description": "The ultimate collection of react hooks",
|
|
5
|
-
"author": {
|
|
6
|
-
"name": "SIBERIA CAN CODE 🧊",
|
|
7
|
-
"url": "https://github.com/siberiacancode"
|
|
8
|
-
},
|
|
9
|
-
"license": "MIT",
|
|
10
|
-
"homepage": "https://siberiacancode.github.io/reactuse/",
|
|
11
|
-
"repository": {
|
|
12
|
-
"type": "git",
|
|
13
|
-
"url": "git+https://github.com/siberiacancode/reactuse.git",
|
|
14
|
-
"directory": "packages/core"
|
|
15
|
-
},
|
|
16
|
-
"bugs": "https://github.com/siberiacancode/reactuse/issues",
|
|
17
|
-
"keywords": [
|
|
18
|
-
"react",
|
|
19
|
-
"react hooks",
|
|
20
|
-
"react use",
|
|
21
|
-
"use",
|
|
22
|
-
"hooks"
|
|
23
|
-
],
|
|
24
|
-
"sideEffects": false,
|
|
25
|
-
"exports": {
|
|
26
|
-
"types": "./dist/types/index.d.ts",
|
|
27
|
-
"import": "./dist/esm/index.mjs",
|
|
28
|
-
"require": "./dist/cjs/index.cjs"
|
|
29
|
-
},
|
|
30
|
-
"main": "dist/cjs/index.cjs",
|
|
31
|
-
"module": "dist/esm/index.mjs",
|
|
32
|
-
"types": "dist/types/index.d.ts",
|
|
33
|
-
"files": [
|
|
34
|
-
"dist"
|
|
35
|
-
],
|
|
36
|
-
"engines": {
|
|
37
|
-
"node": ">=14"
|
|
38
|
-
},
|
|
39
|
-
"publishConfig": {
|
|
40
|
-
"access": "public"
|
|
41
|
-
},
|
|
42
|
-
"scripts": {
|
|
43
|
-
"prepublishOnly": "pnpm unit-test run && pnpm build",
|
|
44
|
-
"build": "shx rm -rf dist && vite build",
|
|
45
|
-
"build:js": "tsc --project tsconfig.build.json && prettier --write src/bundle",
|
|
46
|
-
"lint": "eslint . --fix",
|
|
47
|
-
"lint-inspector": "npx @eslint/config-inspector@latest",
|
|
48
|
-
"format": "prettier --write .",
|
|
49
|
-
"pretty": "pnpm lint && pnpm format",
|
|
50
|
-
"unit-test": "vitest",
|
|
51
|
-
"lint-staged": "lint-staged"
|
|
52
|
-
},
|
|
53
|
-
"peerDependencies": {
|
|
54
|
-
"@types/react": "^18 || ^19",
|
|
55
|
-
"react": "^18 || ^19",
|
|
56
|
-
"react-dom": "^18 || ^19"
|
|
57
|
-
},
|
|
58
|
-
"peerDependenciesMeta": {
|
|
59
|
-
"@types/react": {
|
|
60
|
-
"optional": true
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
"dependencies": {
|
|
64
|
-
"screenfull": "^6.0.2"
|
|
65
|
-
},
|
|
66
|
-
"devDependencies": {
|
|
67
|
-
"@siberiacancode/vitest": "^2.
|
|
68
|
-
"@testing-library/dom": "^10.4.1",
|
|
69
|
-
"@testing-library/react": "^16.3.
|
|
70
|
-
"@types/dom-speech-recognition": "^0.0.7",
|
|
71
|
-
"@types/react": "^19.2.
|
|
72
|
-
"@types/react-dom": "^19.2.
|
|
73
|
-
"@types/web-bluetooth": "^0.0.21",
|
|
74
|
-
"@vitejs/plugin-react": "^5.1.
|
|
75
|
-
"core-js": "^3.
|
|
76
|
-
"react": "^19.2.
|
|
77
|
-
"react-dom": "^19.2.
|
|
78
|
-
"shx": "^0.4.0",
|
|
79
|
-
"vite": "^7.
|
|
80
|
-
"vite-plugin-dts": "^4.5.4",
|
|
81
|
-
"vitest": "^4.0.
|
|
82
|
-
},
|
|
83
|
-
"lint-staged": {
|
|
84
|
-
"*.{js,ts,tsx}": [
|
|
85
|
-
"eslint --fix",
|
|
86
|
-
"prettier --write"
|
|
87
|
-
]
|
|
88
|
-
}
|
|
89
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@siberiacancode/reactuse",
|
|
3
|
+
"version": "0.3.5",
|
|
4
|
+
"description": "The ultimate collection of react hooks",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "SIBERIA CAN CODE 🧊",
|
|
7
|
+
"url": "https://github.com/siberiacancode"
|
|
8
|
+
},
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"homepage": "https://siberiacancode.github.io/reactuse/",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/siberiacancode/reactuse.git",
|
|
14
|
+
"directory": "packages/core"
|
|
15
|
+
},
|
|
16
|
+
"bugs": "https://github.com/siberiacancode/reactuse/issues",
|
|
17
|
+
"keywords": [
|
|
18
|
+
"react",
|
|
19
|
+
"react hooks",
|
|
20
|
+
"react use",
|
|
21
|
+
"use",
|
|
22
|
+
"hooks"
|
|
23
|
+
],
|
|
24
|
+
"sideEffects": false,
|
|
25
|
+
"exports": {
|
|
26
|
+
"types": "./dist/types/index.d.ts",
|
|
27
|
+
"import": "./dist/esm/index.mjs",
|
|
28
|
+
"require": "./dist/cjs/index.cjs"
|
|
29
|
+
},
|
|
30
|
+
"main": "dist/cjs/index.cjs",
|
|
31
|
+
"module": "dist/esm/index.mjs",
|
|
32
|
+
"types": "dist/types/index.d.ts",
|
|
33
|
+
"files": [
|
|
34
|
+
"dist"
|
|
35
|
+
],
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=14"
|
|
38
|
+
},
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"prepublishOnly": "pnpm unit-test run && pnpm build",
|
|
44
|
+
"build": "shx rm -rf dist && vite build",
|
|
45
|
+
"build:js": "tsc --project tsconfig.build.json && prettier --write src/bundle",
|
|
46
|
+
"lint": "eslint . --fix",
|
|
47
|
+
"lint-inspector": "npx @eslint/config-inspector@latest",
|
|
48
|
+
"format": "prettier --write .",
|
|
49
|
+
"pretty": "pnpm lint && pnpm format",
|
|
50
|
+
"unit-test": "vitest",
|
|
51
|
+
"lint-staged": "lint-staged"
|
|
52
|
+
},
|
|
53
|
+
"peerDependencies": {
|
|
54
|
+
"@types/react": "^18 || ^19",
|
|
55
|
+
"react": "^18 || ^19",
|
|
56
|
+
"react-dom": "^18 || ^19"
|
|
57
|
+
},
|
|
58
|
+
"peerDependenciesMeta": {
|
|
59
|
+
"@types/react": {
|
|
60
|
+
"optional": true
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"dependencies": {
|
|
64
|
+
"screenfull": "^6.0.2"
|
|
65
|
+
},
|
|
66
|
+
"devDependencies": {
|
|
67
|
+
"@siberiacancode/vitest": "^2.3.0",
|
|
68
|
+
"@testing-library/dom": "^10.4.1",
|
|
69
|
+
"@testing-library/react": "^16.3.1",
|
|
70
|
+
"@types/dom-speech-recognition": "^0.0.7",
|
|
71
|
+
"@types/react": "^19.2.7",
|
|
72
|
+
"@types/react-dom": "^19.2.3",
|
|
73
|
+
"@types/web-bluetooth": "^0.0.21",
|
|
74
|
+
"@vitejs/plugin-react": "^5.1.2",
|
|
75
|
+
"core-js": "^3.47.0",
|
|
76
|
+
"react": "^19.2.3",
|
|
77
|
+
"react-dom": "^19.2.3",
|
|
78
|
+
"shx": "^0.4.0",
|
|
79
|
+
"vite": "^7.3.0",
|
|
80
|
+
"vite-plugin-dts": "^4.5.4",
|
|
81
|
+
"vitest": "^4.0.16"
|
|
82
|
+
},
|
|
83
|
+
"lint-staged": {
|
|
84
|
+
"*.{js,ts,tsx}": [
|
|
85
|
+
"eslint --fix",
|
|
86
|
+
"prettier --write"
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
}
|