@forgedevstack/bear 1.0.3 → 1.0.4
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/components/Accordion/Accordion.cjs +1 -1
- package/dist/components/Accordion/Accordion.const.cjs +1 -0
- package/dist/components/Accordion/Accordion.const.d.ts +10 -0
- package/dist/components/Accordion/Accordion.const.js +8 -0
- package/dist/components/Accordion/Accordion.d.ts +1 -0
- package/dist/components/Accordion/Accordion.js +49 -44
- package/dist/components/Accordion/Accordion.types.d.ts +2 -0
- package/dist/components/Accordion/index.d.ts +3 -2
- package/dist/components/ActivityItem/ActivityItem.cjs +1 -0
- package/dist/components/ActivityItem/ActivityItem.d.ts +7 -0
- package/dist/components/ActivityItem/ActivityItem.js +44 -0
- package/dist/components/ActivityItem/ActivityItem.types.d.ts +17 -0
- package/dist/components/ActivityItem/index.d.ts +2 -0
- package/dist/components/Alert/Alert.cjs +1 -1
- package/dist/components/Alert/Alert.const.cjs +1 -0
- package/dist/components/Alert/Alert.const.d.ts +14 -0
- package/dist/components/Alert/Alert.const.js +27 -0
- package/dist/components/Alert/Alert.js +54 -63
- package/dist/components/Alert/Alert.types.d.ts +3 -1
- package/dist/components/Avatar/Avatar.cjs +1 -1
- package/dist/components/Avatar/Avatar.const.cjs +1 -0
- package/dist/components/Avatar/Avatar.const.d.ts +28 -0
- package/dist/components/Avatar/Avatar.const.js +28 -0
- package/dist/components/Avatar/Avatar.js +49 -60
- package/dist/components/Avatar/index.d.ts +1 -0
- package/dist/components/Badge/Badge.cjs +1 -1
- package/dist/components/Badge/Badge.js +24 -22
- package/dist/components/BearLogo/EmberLogo.cjs +17 -0
- package/dist/components/BearLogo/EmberLogo.js +91 -0
- package/dist/components/BearLogo/index.d.ts +2 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.cjs +1 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.const.cjs +1 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.const.d.ts +16 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.const.js +19 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.js +49 -34
- package/dist/components/Breadcrumbs/Breadcrumbs.types.d.ts +8 -1
- package/dist/components/Button/Button.cjs +1 -1
- package/dist/components/Button/Button.constants.cjs +1 -1
- package/dist/components/Button/Button.constants.d.ts +2 -2
- package/dist/components/Button/Button.constants.js +2 -2
- package/dist/components/Button/Button.js +41 -46
- package/dist/components/Calendar/Calendar.cjs +1 -1
- package/dist/components/Calendar/Calendar.helpers.cjs +1 -0
- package/dist/components/Calendar/Calendar.helpers.d.ts +10 -0
- package/dist/components/Calendar/Calendar.helpers.js +9 -0
- package/dist/components/Calendar/Calendar.js +112 -115
- package/dist/components/Card/Card.cjs +1 -1
- package/dist/components/Card/Card.const.cjs +1 -0
- package/dist/components/Card/Card.const.d.ts +13 -0
- package/dist/components/Card/Card.const.js +32 -0
- package/dist/components/Card/Card.d.ts +1 -0
- package/dist/components/Card/Card.js +101 -105
- package/dist/components/Card/index.d.ts +3 -2
- package/dist/components/Chart/Chart.cjs +1 -0
- package/dist/components/Chart/Chart.const.d.ts +15 -0
- package/dist/components/Chart/Chart.d.ts +18 -0
- package/dist/components/Chart/Chart.js +225 -0
- package/dist/components/Chart/Chart.types.d.ts +51 -0
- package/dist/components/Chart/Chart.utils.d.ts +31 -0
- package/dist/components/Chart/index.d.ts +2 -0
- package/dist/components/CodeBlock/CodeBlock.cjs +2 -2
- package/dist/components/CodeBlock/CodeBlock.js +65 -52
- package/dist/components/CodeBlock/CodeBlock.types.d.ts +12 -1
- package/dist/components/Editable/Editable.cjs +1 -1
- package/dist/components/Editable/Editable.js +115 -115
- package/dist/components/Gauge/Gauge.cjs +1 -0
- package/dist/components/Gauge/Gauge.d.ts +3 -0
- package/dist/components/Gauge/Gauge.js +92 -0
- package/dist/components/Gauge/Gauge.types.d.ts +27 -0
- package/dist/components/Gauge/index.d.ts +2 -0
- package/dist/components/Icon/icons/editor.cjs +1 -1
- package/dist/components/Icon/icons/editor.d.ts +1 -0
- package/dist/components/Icon/icons/editor.js +66 -61
- package/dist/components/Icon/icons/misc.cjs +1 -1
- package/dist/components/Icon/icons/misc.d.ts +13 -0
- package/dist/components/Icon/icons/misc.js +157 -88
- package/dist/components/Icon/index.d.ts +22 -0
- package/dist/components/Input/Input.cjs +1 -1
- package/dist/components/Input/Input.js +36 -35
- package/dist/components/Modal/Modal.cjs +1 -1
- package/dist/components/Modal/Modal.const.cjs +1 -0
- package/dist/components/Modal/Modal.const.d.ts +10 -0
- package/dist/components/Modal/Modal.const.js +17 -0
- package/dist/components/Modal/Modal.d.ts +11 -0
- package/dist/components/Modal/Modal.js +80 -77
- package/dist/components/Modal/Modal.types.d.ts +6 -1
- package/dist/components/Modal/index.d.ts +3 -2
- package/dist/components/Rating/Rating.cjs +1 -1
- package/dist/components/Rating/Rating.const.cjs +1 -0
- package/dist/components/Rating/Rating.const.d.ts +14 -0
- package/dist/components/Rating/Rating.const.js +22 -0
- package/dist/components/Rating/Rating.d.ts +5 -10
- package/dist/components/Rating/Rating.js +135 -93
- package/dist/components/Rating/Rating.types.d.ts +27 -25
- package/dist/components/Rating/index.d.ts +2 -2
- package/dist/components/RichEditor/RichEditor.cjs +1 -10
- package/dist/components/RichEditor/RichEditor.const.cjs +141 -0
- package/dist/components/RichEditor/RichEditor.const.d.ts +137 -0
- package/dist/components/RichEditor/RichEditor.const.js +279 -0
- package/dist/components/RichEditor/RichEditor.d.ts +14 -0
- package/dist/components/RichEditor/RichEditor.js +341 -129
- package/dist/components/RichEditor/RichEditor.types.d.ts +38 -1
- package/dist/components/RichEditor/components/ToolbarButton/ToolbarButton.cjs +1 -0
- package/dist/components/RichEditor/components/ToolbarButton/ToolbarButton.d.ts +4 -0
- package/dist/components/RichEditor/components/ToolbarButton/ToolbarButton.js +25 -0
- package/dist/components/RichEditor/components/ToolbarButton/index.d.ts +1 -0
- package/dist/components/RichEditor/components/ToolbarColorPicker/ToolbarColorPicker.cjs +1 -0
- package/dist/components/RichEditor/components/ToolbarColorPicker/ToolbarColorPicker.d.ts +4 -0
- package/dist/components/RichEditor/components/ToolbarColorPicker/ToolbarColorPicker.js +126 -0
- package/dist/components/RichEditor/components/ToolbarColorPicker/index.d.ts +1 -0
- package/dist/components/RichEditor/components/ToolbarDropdown/ToolbarDropdown.cjs +1 -0
- package/dist/components/RichEditor/components/ToolbarDropdown/ToolbarDropdown.d.ts +4 -0
- package/dist/components/RichEditor/components/ToolbarDropdown/ToolbarDropdown.js +57 -0
- package/dist/components/RichEditor/components/ToolbarDropdown/index.d.ts +1 -0
- package/dist/components/RichEditor/components/ToolbarMore/ToolbarMore.cjs +1 -0
- package/dist/components/RichEditor/components/ToolbarMore/ToolbarMore.d.ts +7 -0
- package/dist/components/RichEditor/components/ToolbarMore/ToolbarMore.js +45 -0
- package/dist/components/RichEditor/components/ToolbarMore/index.d.ts +2 -0
- package/dist/components/RichEditor/components/index.d.ts +4 -0
- package/dist/components/RichEditor/helpers/formatHelpers.cjs +1 -0
- package/dist/components/RichEditor/helpers/formatHelpers.d.ts +57 -0
- package/dist/components/RichEditor/helpers/formatHelpers.js +26 -0
- package/dist/components/RichEditor/helpers/index.d.ts +1 -0
- package/dist/components/RichEditor/index.d.ts +4 -2
- package/dist/components/Sidebar/Sidebar.cjs +1 -1
- package/dist/components/Sidebar/Sidebar.const.cjs +1 -0
- package/dist/components/Sidebar/Sidebar.const.d.ts +16 -0
- package/dist/components/Sidebar/Sidebar.const.js +22 -0
- package/dist/components/Sidebar/Sidebar.d.ts +14 -2
- package/dist/components/Sidebar/Sidebar.js +50 -138
- package/dist/components/Sidebar/Sidebar.types.d.ts +7 -3
- package/dist/components/Sidebar/components/SidebarGroup/SidebarGroup.cjs +1 -0
- package/dist/components/Sidebar/components/SidebarGroup/SidebarGroup.d.ts +4 -0
- package/dist/components/Sidebar/components/SidebarGroup/SidebarGroup.js +45 -0
- package/dist/components/Sidebar/components/SidebarGroup/index.d.ts +2 -0
- package/dist/components/Sidebar/components/SidebarItem/SidebarItem.cjs +1 -0
- package/dist/components/Sidebar/components/SidebarItem/SidebarItem.d.ts +4 -0
- package/dist/components/Sidebar/components/SidebarItem/SidebarItem.js +66 -0
- package/dist/components/Sidebar/components/SidebarItem/index.d.ts +2 -0
- package/dist/components/Sidebar/components/index.d.ts +2 -0
- package/dist/components/Sidebar/index.d.ts +5 -2
- package/dist/components/SignPad/SignPad.cjs +1 -0
- package/dist/components/SignPad/SignPad.const.cjs +1 -0
- package/dist/components/SignPad/SignPad.const.d.ts +19 -0
- package/dist/components/SignPad/SignPad.const.js +20 -0
- package/dist/components/SignPad/SignPad.d.ts +17 -0
- package/dist/components/SignPad/SignPad.js +161 -0
- package/dist/components/SignPad/SignPad.types.d.ts +37 -0
- package/dist/components/SignPad/index.d.ts +3 -0
- package/dist/components/Skeleton/Skeleton.cjs +1 -1
- package/dist/components/Skeleton/Skeleton.const.cjs +36 -0
- package/dist/components/Skeleton/Skeleton.const.d.ts +12 -0
- package/dist/components/Skeleton/Skeleton.const.js +58 -0
- package/dist/components/Skeleton/Skeleton.d.ts +15 -24
- package/dist/components/Skeleton/Skeleton.js +132 -103
- package/dist/components/Skeleton/Skeleton.types.d.ts +18 -8
- package/dist/components/Skeleton/index.d.ts +2 -2
- package/dist/components/Sparkline/Sparkline.cjs +1 -0
- package/dist/components/Sparkline/Sparkline.const.cjs +1 -0
- package/dist/components/Sparkline/Sparkline.const.d.ts +16 -0
- package/dist/components/Sparkline/Sparkline.const.js +16 -0
- package/dist/components/Sparkline/Sparkline.d.ts +3 -0
- package/dist/components/Sparkline/Sparkline.js +80 -0
- package/dist/components/Sparkline/Sparkline.types.d.ts +19 -0
- package/dist/components/Sparkline/Sparkline.utils.cjs +1 -0
- package/dist/components/Sparkline/Sparkline.utils.d.ts +27 -0
- package/dist/components/Sparkline/Sparkline.utils.js +30 -0
- package/dist/components/Sparkline/index.d.ts +5 -0
- package/dist/components/SpeedDial/SpeedDial.cjs +12 -1
- package/dist/components/SpeedDial/SpeedDial.const.cjs +1 -0
- package/dist/components/SpeedDial/SpeedDial.const.d.ts +22 -0
- package/dist/components/SpeedDial/SpeedDial.const.js +26 -0
- package/dist/components/SpeedDial/SpeedDial.d.ts +5 -7
- package/dist/components/SpeedDial/SpeedDial.js +154 -144
- package/dist/components/SpeedDial/SpeedDial.types.d.ts +26 -29
- package/dist/components/SpeedDial/index.d.ts +1 -1
- package/dist/components/Spinner/Spinner.cjs +1 -1
- package/dist/components/Spinner/Spinner.js +17 -15
- package/dist/components/StatCard/StatCard.cjs +1 -0
- package/dist/components/StatCard/StatCard.d.ts +7 -0
- package/dist/components/StatCard/StatCard.js +36 -0
- package/dist/components/StatCard/StatCard.types.d.ts +13 -0
- package/dist/components/StatCard/index.d.ts +2 -0
- package/dist/components/Stepper/Stepper.cjs +1 -1
- package/dist/components/Stepper/Stepper.const.cjs +1 -0
- package/dist/components/Stepper/Stepper.const.d.ts +29 -0
- package/dist/components/Stepper/Stepper.const.js +46 -0
- package/dist/components/Stepper/Stepper.d.ts +10 -3
- package/dist/components/Stepper/Stepper.js +143 -92
- package/dist/components/Stepper/Stepper.types.d.ts +63 -13
- package/dist/components/Stepper/index.d.ts +2 -2
- package/dist/components/Switch/Switch.cjs +1 -1
- package/dist/components/Switch/Switch.js +74 -47
- package/dist/components/Switch/Switch.types.d.ts +11 -1
- package/dist/components/Tabs/Tabs.cjs +1 -1
- package/dist/components/Tabs/Tabs.js +33 -29
- package/dist/components/TimePicker/TimePicker.cjs +1 -1
- package/dist/components/TimePicker/TimePicker.constants.cjs +1 -1
- package/dist/components/TimePicker/TimePicker.constants.d.ts +14 -0
- package/dist/components/TimePicker/TimePicker.constants.js +18 -4
- package/dist/components/TimePicker/TimePicker.js +92 -91
- package/dist/components/Timeline/Timeline.cjs +1 -1
- package/dist/components/Timeline/Timeline.const.cjs +1 -0
- package/dist/components/Timeline/Timeline.const.d.ts +40 -0
- package/dist/components/Timeline/Timeline.const.js +58 -0
- package/dist/components/Timeline/Timeline.d.ts +16 -2
- package/dist/components/Timeline/Timeline.js +131 -63
- package/dist/components/Timeline/Timeline.types.d.ts +30 -11
- package/dist/components/Timeline/index.d.ts +1 -1
- package/dist/components/Tooltip/Tooltip.cjs +1 -1
- package/dist/components/Tooltip/Tooltip.js +37 -35
- package/dist/components/Typography/Typography.cjs +1 -1
- package/dist/components/Typography/Typography.js +38 -36
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.d.ts +17 -5
- package/dist/components/index.js +216 -195
- package/dist/hooks/index.cjs +1 -1
- package/dist/hooks/index.d.ts +24 -0
- package/dist/hooks/index.js +42 -14
- package/dist/hooks/useBounce/index.d.ts +2 -0
- package/dist/hooks/useBounce/useBounce.cjs +1 -0
- package/dist/hooks/useBounce/useBounce.d.ts +2 -0
- package/dist/hooks/useBounce/useBounce.js +36 -0
- package/dist/hooks/useBounce/useBounce.types.d.ts +27 -0
- package/dist/hooks/useClickOutside/index.d.ts +2 -0
- package/dist/hooks/useClickOutside/useClickOutside.d.ts +22 -0
- package/dist/hooks/useClickOutside/useClickOutside.types.d.ts +10 -0
- package/dist/hooks/useClipboard/index.d.ts +2 -0
- package/dist/hooks/useClipboard/useClipboard.cjs +1 -0
- package/dist/hooks/useClipboard/useClipboard.d.ts +15 -0
- package/dist/hooks/useClipboard/useClipboard.js +22 -0
- package/dist/hooks/useClipboard/useClipboard.types.d.ts +20 -0
- package/dist/hooks/useDebounce/index.d.ts +2 -0
- package/dist/hooks/useDebounce/useDebounce.cjs +1 -0
- package/dist/hooks/useDebounce/useDebounce.d.ts +32 -0
- package/dist/hooks/useDebounce/useDebounce.js +39 -0
- package/dist/hooks/useDebounce/useDebounce.types.d.ts +20 -0
- package/dist/hooks/useFloat/index.d.ts +2 -0
- package/dist/hooks/useFloat/useFloat.cjs +1 -0
- package/dist/hooks/useFloat/useFloat.d.ts +2 -0
- package/dist/hooks/useFloat/useFloat.js +37 -0
- package/dist/hooks/useFloat/useFloat.types.d.ts +25 -0
- package/dist/hooks/useIntersectionObserver/index.d.ts +2 -0
- package/dist/hooks/useIntersectionObserver/useIntersectionObserver.cjs +1 -0
- package/dist/hooks/useIntersectionObserver/useIntersectionObserver.d.ts +25 -0
- package/dist/hooks/useIntersectionObserver/useIntersectionObserver.js +39 -0
- package/dist/hooks/useIntersectionObserver/useIntersectionObserver.types.d.ts +22 -0
- package/dist/hooks/useKeyPress/index.d.ts +2 -0
- package/dist/hooks/useKeyPress/useKeyPress.cjs +1 -0
- package/dist/hooks/useKeyPress/useKeyPress.d.ts +22 -0
- package/dist/hooks/useKeyPress/useKeyPress.js +39 -0
- package/dist/hooks/useKeyPress/useKeyPress.types.d.ts +19 -0
- package/dist/hooks/useLocalStorage/index.d.ts +2 -0
- package/dist/hooks/useLocalStorage/useLocalStorage.cjs +1 -0
- package/dist/hooks/useLocalStorage/useLocalStorage.d.ts +11 -0
- package/dist/hooks/useLocalStorage/useLocalStorage.js +47 -0
- package/dist/hooks/useLocalStorage/useLocalStorage.types.d.ts +16 -0
- package/dist/hooks/useMediaQuery/index.d.ts +3 -0
- package/dist/hooks/useMediaQuery/useMediaQuery.d.ts +12 -0
- package/dist/hooks/useMediaQuery/useMediaQuery.types.d.ts +21 -0
- package/dist/hooks/useParallax/index.d.ts +2 -0
- package/dist/hooks/useParallax/useParallax.cjs +1 -0
- package/dist/hooks/useParallax/useParallax.d.ts +2 -0
- package/dist/hooks/useParallax/useParallax.js +36 -0
- package/dist/hooks/useParallax/useParallax.types.d.ts +19 -0
- package/dist/hooks/usePulse/index.d.ts +2 -0
- package/dist/hooks/usePulse/usePulse.cjs +1 -0
- package/dist/hooks/usePulse/usePulse.d.ts +2 -0
- package/dist/hooks/usePulse/usePulse.js +38 -0
- package/dist/hooks/usePulse/usePulse.types.d.ts +29 -0
- package/dist/hooks/useShake/index.d.ts +2 -0
- package/dist/hooks/useShake/useShake.cjs +1 -0
- package/dist/hooks/useShake/useShake.d.ts +2 -0
- package/dist/hooks/useShake/useShake.js +14 -0
- package/dist/hooks/useShake/useShake.types.d.ts +19 -0
- package/dist/hooks/useSlide/index.d.ts +2 -0
- package/dist/hooks/useSlide/useSlide.cjs +1 -0
- package/dist/hooks/useSlide/useSlide.d.ts +2 -0
- package/dist/hooks/useSlide/useSlide.js +68 -0
- package/dist/hooks/useSlide/useSlide.types.d.ts +36 -0
- package/dist/hooks/useThrottle/index.d.ts +2 -0
- package/dist/hooks/useThrottle/useThrottle.cjs +1 -0
- package/dist/hooks/useThrottle/useThrottle.d.ts +26 -0
- package/dist/hooks/useThrottle/useThrottle.js +44 -0
- package/dist/hooks/useThrottle/useThrottle.types.d.ts +8 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +273 -224
- package/dist/styles.css +1 -1
- package/package.json +14 -21
- package/dist/components/RichEditor/RichEditor.icons.cjs +0 -1
- package/dist/components/RichEditor/RichEditor.icons.d.ts +0 -16
- package/dist/components/RichEditor/RichEditor.icons.js +0 -62
- package/dist/components/RichEditor/RichEditor.utils.cjs +0 -1
- package/dist/components/RichEditor/RichEditor.utils.d.ts +0 -3
- package/dist/components/RichEditor/RichEditor.utils.js +0 -22
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
export interface UseClickOutsideOptions {
|
|
3
|
+
/** Event type to listen for */
|
|
4
|
+
events?: ('mousedown' | 'mouseup' | 'touchstart' | 'touchend')[];
|
|
5
|
+
/** Ignore elements with these selectors */
|
|
6
|
+
ignoreSelectors?: string[];
|
|
7
|
+
/** Whether the hook is enabled */
|
|
8
|
+
enabled?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export type UseClickOutsideRef<T extends HTMLElement> = RefObject<T>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),T=2e3,C=(p={})=>{const{timeout:u=T,onSuccess:r,onError:t}=p,[b,a]=e.useState(!1),[d,f]=e.useState(null),[y,s]=e.useState(null),o=e.useRef(null),l=e.useCallback(()=>{a(!1),s(null),o.current&&(clearTimeout(o.current),o.current=null)},[]);return{copy:e.useCallback(async n=>{l();try{if(!(navigator!=null&&navigator.clipboard))throw new Error("Clipboard API not available");return await navigator.clipboard.writeText(n),f(n),a(!0),r==null||r(n),o.current=setTimeout(()=>{a(!1)},u),!0}catch(c){const i=c instanceof Error?c:new Error("Failed to copy");return s(i),t==null||t(i),!1}},[u,r,t,l]),copied:b,value:d,reset:l,error:y}};exports.useClipboard=C;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { UseClipboardOptions, UseClipboardReturn } from './useClipboard.types';
|
|
2
|
+
/**
|
|
3
|
+
* useClipboard - Copy text to clipboard with status tracking
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```tsx
|
|
7
|
+
* const { copy, copied } = useClipboard();
|
|
8
|
+
*
|
|
9
|
+
* <Button onClick={() => copy('Hello!')}>
|
|
10
|
+
* {copied ? 'Copied!' : 'Copy'}
|
|
11
|
+
* </Button>
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare const useClipboard: (options?: UseClipboardOptions) => UseClipboardReturn;
|
|
15
|
+
export default useClipboard;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useState as l, useRef as w, useCallback as p } from "react";
|
|
2
|
+
const y = 2e3, C = (f = {}) => {
|
|
3
|
+
const { timeout: c = y, onSuccess: r, onError: e } = f, [d, o] = l(!1), [b, m] = l(null), [T, s] = l(null), t = w(null), n = p(() => {
|
|
4
|
+
o(!1), s(null), t.current && (clearTimeout(t.current), t.current = null);
|
|
5
|
+
}, []);
|
|
6
|
+
return { copy: p(async (a) => {
|
|
7
|
+
n();
|
|
8
|
+
try {
|
|
9
|
+
if (!(navigator != null && navigator.clipboard))
|
|
10
|
+
throw new Error("Clipboard API not available");
|
|
11
|
+
return await navigator.clipboard.writeText(a), m(a), o(!0), r == null || r(a), t.current = setTimeout(() => {
|
|
12
|
+
o(!1);
|
|
13
|
+
}, c), !0;
|
|
14
|
+
} catch (u) {
|
|
15
|
+
const i = u instanceof Error ? u : new Error("Failed to copy");
|
|
16
|
+
return s(i), e == null || e(i), !1;
|
|
17
|
+
}
|
|
18
|
+
}, [c, r, e, n]), copied: d, value: b, reset: n, error: T };
|
|
19
|
+
};
|
|
20
|
+
export {
|
|
21
|
+
C as useClipboard
|
|
22
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface UseClipboardOptions {
|
|
2
|
+
/** Timeout in ms before resetting copied state */
|
|
3
|
+
timeout?: number;
|
|
4
|
+
/** Callback when copy succeeds */
|
|
5
|
+
onSuccess?: (value: string) => void;
|
|
6
|
+
/** Callback when copy fails */
|
|
7
|
+
onError?: (error: Error) => void;
|
|
8
|
+
}
|
|
9
|
+
export interface UseClipboardReturn {
|
|
10
|
+
/** Copy text to clipboard */
|
|
11
|
+
copy: (value: string) => Promise<boolean>;
|
|
12
|
+
/** Whether text was recently copied */
|
|
13
|
+
copied: boolean;
|
|
14
|
+
/** Last copied value */
|
|
15
|
+
value: string | null;
|
|
16
|
+
/** Reset copied state */
|
|
17
|
+
reset: () => void;
|
|
18
|
+
/** Error if copy failed */
|
|
19
|
+
error: Error | null;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),R=300;function k(n,c=R){const[a,i]=e.useState(n);return e.useEffect(()=>{const l=setTimeout(()=>{i(n)},c);return()=>{clearTimeout(l)}},[n,c]),a}function g(n,c=R,a={}){const{leading:i=!1,trailing:l=!0,maxWait:f}=a,s=e.useRef(n),t=e.useRef(null),o=e.useRef(null),u=e.useRef(null),b=e.useRef(null);e.useEffect(()=>{s.current=n},[n]);const r=e.useCallback(()=>{t.current&&(clearTimeout(t.current),t.current=null),o.current&&(clearTimeout(o.current),o.current=null),u.current=null,b.current=null},[]),T=e.useCallback(()=>{u.current&&(s.current(...u.current),r())},[r]),d=e.useCallback(()=>t.current!==null,[]),C=e.useCallback((...m)=>{u.current=m;const D=Date.now();i&&!t.current&&s.current(...m),t.current&&clearTimeout(t.current),l&&(t.current=setTimeout(()=>{u.current&&l&&s.current(...u.current),r()},c)),f!==void 0&&!o.current&&(b.current=D,o.current=setTimeout(()=>{u.current&&s.current(...u.current),r()},f))},[c,i,l,f,r]);return e.useEffect(()=>()=>{r()},[r]),{callback:C,cancel:r,flush:T,isPending:d}}exports.useDebounce=k;exports.useDebouncedCallback=g;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { UseDebounceOptions } from './useDebounce.types';
|
|
2
|
+
/**
|
|
3
|
+
* useDebounce - Debounce a value
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```tsx
|
|
7
|
+
* const [search, setSearch] = useState('');
|
|
8
|
+
* const debouncedSearch = useDebounce(search, 500);
|
|
9
|
+
*
|
|
10
|
+
* useEffect(() => {
|
|
11
|
+
* fetchResults(debouncedSearch);
|
|
12
|
+
* }, [debouncedSearch]);
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare function useDebounce<T>(value: T, delay?: number): T;
|
|
16
|
+
/**
|
|
17
|
+
* useDebouncedCallback - Debounce a callback function
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* const debouncedSave = useDebouncedCallback((value) => {
|
|
22
|
+
* saveToServer(value);
|
|
23
|
+
* }, 500);
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function useDebouncedCallback<T extends (...args: unknown[]) => unknown>(callback: T, delay?: number, options?: UseDebounceOptions): {
|
|
27
|
+
callback: (...args: Parameters<T>) => void;
|
|
28
|
+
cancel: () => void;
|
|
29
|
+
flush: () => void;
|
|
30
|
+
isPending: () => boolean;
|
|
31
|
+
};
|
|
32
|
+
export default useDebounce;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useState as x, useEffect as T, useRef as i, useCallback as f } from "react";
|
|
2
|
+
const D = 300;
|
|
3
|
+
function E(n, u = D) {
|
|
4
|
+
const [a, s] = x(n);
|
|
5
|
+
return T(() => {
|
|
6
|
+
const c = setTimeout(() => {
|
|
7
|
+
s(n);
|
|
8
|
+
}, u);
|
|
9
|
+
return () => {
|
|
10
|
+
clearTimeout(c);
|
|
11
|
+
};
|
|
12
|
+
}, [n, u]), a;
|
|
13
|
+
}
|
|
14
|
+
function p(n, u = D, a = {}) {
|
|
15
|
+
const { leading: s = !1, trailing: c = !0, maxWait: m } = a, o = i(n), e = i(null), l = i(null), r = i(null), b = i(null);
|
|
16
|
+
T(() => {
|
|
17
|
+
o.current = n;
|
|
18
|
+
}, [n]);
|
|
19
|
+
const t = f(() => {
|
|
20
|
+
e.current && (clearTimeout(e.current), e.current = null), l.current && (clearTimeout(l.current), l.current = null), r.current = null, b.current = null;
|
|
21
|
+
}, []), R = f(() => {
|
|
22
|
+
r.current && (o.current(...r.current), t());
|
|
23
|
+
}, [t]), C = f(() => e.current !== null, []), g = f((...d) => {
|
|
24
|
+
r.current = d;
|
|
25
|
+
const k = Date.now();
|
|
26
|
+
s && !e.current && o.current(...d), e.current && clearTimeout(e.current), c && (e.current = setTimeout(() => {
|
|
27
|
+
r.current && c && o.current(...r.current), t();
|
|
28
|
+
}, u)), m !== void 0 && !l.current && (b.current = k, l.current = setTimeout(() => {
|
|
29
|
+
r.current && o.current(...r.current), t();
|
|
30
|
+
}, m));
|
|
31
|
+
}, [u, s, c, m, t]);
|
|
32
|
+
return T(() => () => {
|
|
33
|
+
t();
|
|
34
|
+
}, [t]), { callback: g, cancel: t, flush: R, isPending: C };
|
|
35
|
+
}
|
|
36
|
+
export {
|
|
37
|
+
E as useDebounce,
|
|
38
|
+
p as useDebouncedCallback
|
|
39
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface UseDebounceOptions {
|
|
2
|
+
/** Delay in milliseconds */
|
|
3
|
+
delay?: number;
|
|
4
|
+
/** Execute on leading edge */
|
|
5
|
+
leading?: boolean;
|
|
6
|
+
/** Execute on trailing edge */
|
|
7
|
+
trailing?: boolean;
|
|
8
|
+
/** Maximum time to wait */
|
|
9
|
+
maxWait?: number;
|
|
10
|
+
}
|
|
11
|
+
export interface UseDebouncedCallbackReturn<T extends (...args: unknown[]) => unknown> {
|
|
12
|
+
/** Debounced function */
|
|
13
|
+
callback: T;
|
|
14
|
+
/** Cancel pending execution */
|
|
15
|
+
cancel: () => void;
|
|
16
|
+
/** Flush pending execution immediately */
|
|
17
|
+
flush: () => void;
|
|
18
|
+
/** Check if pending */
|
|
19
|
+
isPending: () => boolean;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react");function g(s={}){const{distance:r=10,duration:c=3e3,delay:a=0,direction:l="vertical",autoStart:o=!0}=s,u=t.useRef(null),[n,i]=t.useState(!1),e=t.useCallback(()=>{i(!0)},[]),f=t.useCallback(()=>{i(!1)},[]);t.useEffect(()=>{if(o){const m=setTimeout(e,a);return()=>clearTimeout(m)}},[o,a,e]);const d=n?{animation:`${(()=>{switch(l){case"horizontal":return"float-horizontal";case"diagonal":return"float-diagonal";default:return"float-vertical"}})()} ${c}ms ease-in-out infinite`,"--float-distance":`${r}px`}:{};return{ref:u,style:d,isActive:n,start:e,stop:f}}exports.useFloat=g;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { useRef as g, useState as p, useCallback as i, useEffect as v } from "react";
|
|
2
|
+
function $(s = {}) {
|
|
3
|
+
const {
|
|
4
|
+
distance: r = 10,
|
|
5
|
+
duration: c = 3e3,
|
|
6
|
+
delay: e = 0,
|
|
7
|
+
direction: l = "vertical",
|
|
8
|
+
autoStart: a = !0
|
|
9
|
+
} = s, u = g(null), [o, n] = p(!1), t = i(() => {
|
|
10
|
+
n(!0);
|
|
11
|
+
}, []), f = i(() => {
|
|
12
|
+
n(!1);
|
|
13
|
+
}, []);
|
|
14
|
+
v(() => {
|
|
15
|
+
if (a) {
|
|
16
|
+
const d = setTimeout(t, e);
|
|
17
|
+
return () => clearTimeout(d);
|
|
18
|
+
}
|
|
19
|
+
}, [a, e, t]);
|
|
20
|
+
const m = o ? {
|
|
21
|
+
animation: `${(() => {
|
|
22
|
+
switch (l) {
|
|
23
|
+
case "horizontal":
|
|
24
|
+
return "float-horizontal";
|
|
25
|
+
case "diagonal":
|
|
26
|
+
return "float-diagonal";
|
|
27
|
+
default:
|
|
28
|
+
return "float-vertical";
|
|
29
|
+
}
|
|
30
|
+
})()} ${c}ms ease-in-out infinite`,
|
|
31
|
+
"--float-distance": `${r}px`
|
|
32
|
+
} : {};
|
|
33
|
+
return { ref: u, style: m, isActive: o, start: t, stop: f };
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
$ as useFloat
|
|
37
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { RefObject, CSSProperties } from 'react';
|
|
2
|
+
export interface UseFloatOptions {
|
|
3
|
+
/** Float distance in pixels */
|
|
4
|
+
distance?: number;
|
|
5
|
+
/** Duration of one float cycle (in ms) */
|
|
6
|
+
duration?: number;
|
|
7
|
+
/** Delay before starting (in ms) */
|
|
8
|
+
delay?: number;
|
|
9
|
+
/** Direction of float */
|
|
10
|
+
direction?: 'vertical' | 'horizontal' | 'diagonal';
|
|
11
|
+
/** Start animation on mount */
|
|
12
|
+
autoStart?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface UseFloatReturn<T extends HTMLElement> {
|
|
15
|
+
/** Ref to attach to the element */
|
|
16
|
+
ref: RefObject<T>;
|
|
17
|
+
/** Style object to apply */
|
|
18
|
+
style: CSSProperties;
|
|
19
|
+
/** Whether floating is active */
|
|
20
|
+
isActive: boolean;
|
|
21
|
+
/** Start floating */
|
|
22
|
+
start: () => void;
|
|
23
|
+
/** Stop floating */
|
|
24
|
+
stop: () => void;
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react"),b=(t,s={})=>{const{threshold:n=0,root:l=null,rootMargin:f="0px",freezeOnceVisible:i=!1,enabled:a=!0,onChange:r}=s,[e,d]=u.useState(null),I=u.useRef(!1);return u.useEffect(()=>{if(!a||!t.current||typeof IntersectionObserver>"u"||I.current&&i)return;const c=new IntersectionObserver(([o])=>{d(o),r==null||r(o),i&&o.isIntersecting&&(I.current=!0,c.disconnect())},{threshold:n,root:l,rootMargin:f});return c.observe(t.current),()=>{c.disconnect()}},[t,n,l,f,i,a,r]),{isIntersecting:(e==null?void 0:e.isIntersecting)??!1,entry:e,intersectionRatio:(e==null?void 0:e.intersectionRatio)??0}},g=(t,s={})=>{const{isIntersecting:n}=b(t,s);return n};exports.useInView=g;exports.useIntersectionObserver=b;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
import { UseIntersectionObserverOptions, UseIntersectionObserverReturn } from './useIntersectionObserver.types';
|
|
3
|
+
/**
|
|
4
|
+
* useIntersectionObserver - Detect when an element enters/leaves the viewport
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* const ref = useRef<HTMLDivElement>(null);
|
|
9
|
+
* const { isIntersecting, intersectionRatio } = useIntersectionObserver(ref, {
|
|
10
|
+
* threshold: 0.5,
|
|
11
|
+
* });
|
|
12
|
+
*
|
|
13
|
+
* return (
|
|
14
|
+
* <div ref={ref} style={{ opacity: isIntersecting ? 1 : 0.5 }}>
|
|
15
|
+
* {isIntersecting ? 'Visible!' : 'Not visible'}
|
|
16
|
+
* </div>
|
|
17
|
+
* );
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare const useIntersectionObserver: <T extends HTMLElement>(ref: RefObject<T>, options?: UseIntersectionObserverOptions) => UseIntersectionObserverReturn;
|
|
21
|
+
/**
|
|
22
|
+
* useInView - Simple boolean for whether element is in view
|
|
23
|
+
*/
|
|
24
|
+
export declare const useInView: <T extends HTMLElement>(ref: RefObject<T>, options?: Omit<UseIntersectionObserverOptions, "onChange">) => boolean;
|
|
25
|
+
export default useIntersectionObserver;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useState as d, useRef as b, useEffect as g } from "react";
|
|
2
|
+
const p = (t, s = {}) => {
|
|
3
|
+
const {
|
|
4
|
+
threshold: n = 0,
|
|
5
|
+
root: u = null,
|
|
6
|
+
rootMargin: f = "0px",
|
|
7
|
+
freezeOnceVisible: i = !1,
|
|
8
|
+
enabled: l = !0,
|
|
9
|
+
onChange: r
|
|
10
|
+
} = s, [e, a] = d(null), I = b(!1);
|
|
11
|
+
return g(() => {
|
|
12
|
+
if (!l || !t.current || typeof IntersectionObserver > "u" || I.current && i)
|
|
13
|
+
return;
|
|
14
|
+
const c = new IntersectionObserver(
|
|
15
|
+
([o]) => {
|
|
16
|
+
a(o), r == null || r(o), i && o.isIntersecting && (I.current = !0, c.disconnect());
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
threshold: n,
|
|
20
|
+
root: u,
|
|
21
|
+
rootMargin: f
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
return c.observe(t.current), () => {
|
|
25
|
+
c.disconnect();
|
|
26
|
+
};
|
|
27
|
+
}, [t, n, u, f, i, l, r]), {
|
|
28
|
+
isIntersecting: (e == null ? void 0 : e.isIntersecting) ?? !1,
|
|
29
|
+
entry: e,
|
|
30
|
+
intersectionRatio: (e == null ? void 0 : e.intersectionRatio) ?? 0
|
|
31
|
+
};
|
|
32
|
+
}, v = (t, s = {}) => {
|
|
33
|
+
const { isIntersecting: n } = p(t, s);
|
|
34
|
+
return n;
|
|
35
|
+
};
|
|
36
|
+
export {
|
|
37
|
+
v as useInView,
|
|
38
|
+
p as useIntersectionObserver
|
|
39
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface UseIntersectionObserverOptions {
|
|
2
|
+
/** Threshold(s) at which to trigger callback */
|
|
3
|
+
threshold?: number | number[];
|
|
4
|
+
/** Root element for intersection */
|
|
5
|
+
root?: Element | Document | null;
|
|
6
|
+
/** Margin around root */
|
|
7
|
+
rootMargin?: string;
|
|
8
|
+
/** Freeze updates after first intersection */
|
|
9
|
+
freezeOnceVisible?: boolean;
|
|
10
|
+
/** Whether the hook is enabled */
|
|
11
|
+
enabled?: boolean;
|
|
12
|
+
/** Callback when intersection changes */
|
|
13
|
+
onChange?: (entry: IntersectionObserverEntry) => void;
|
|
14
|
+
}
|
|
15
|
+
export interface UseIntersectionObserverReturn {
|
|
16
|
+
/** Whether element is visible */
|
|
17
|
+
isIntersecting: boolean;
|
|
18
|
+
/** Current intersection entry */
|
|
19
|
+
entry: IntersectionObserverEntry | null;
|
|
20
|
+
/** Intersection ratio (0-1) */
|
|
21
|
+
intersectionRatio: number;
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react"),P=(r,e)=>typeof e=="function"?e(r):(Array.isArray(e)?e:[e]).some(o=>{const s=o.toLowerCase();return r.key.toLowerCase()===s||r.code.toLowerCase()===s}),a=(r,e,f={})=>{const{target:o,event:s="keydown",preventDefault:c=!1,stopPropagation:i=!1,metaKey:l=!1,ctrlKey:y=!1,shiftKey:K=!1,altKey:d=!1}=f,p=n.useRef(e);n.useEffect(()=>{p.current=e},[e]);const u=n.useCallback(t=>{l&&!t.metaKey||y&&!t.ctrlKey||K&&!t.shiftKey||d&&!t.altKey||P(t,r)&&(c&&t.preventDefault(),i&&t.stopPropagation(),p.current(t))},[r,l,y,K,d,c,i]);n.useEffect(()=>{const t=o||document;return t.addEventListener(s,u),()=>{t.removeEventListener(s,u)}},[o,s,u])},m=r=>{const e=n.useRef(!1);return a(r,()=>{e.current=!0},{event:"keydown"}),a(r,()=>{e.current=!1},{event:"keyup"}),e.current};exports.useKeyPress=a;exports.useKeyPressState=m;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { UseKeyPressOptions, KeyFilter } from './useKeyPress.types';
|
|
2
|
+
/**
|
|
3
|
+
* useKeyPress - Detect when a key is pressed
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```tsx
|
|
7
|
+
* // Single key
|
|
8
|
+
* useKeyPress('Escape', () => closeModal());
|
|
9
|
+
*
|
|
10
|
+
* // Multiple keys
|
|
11
|
+
* useKeyPress(['ArrowUp', 'ArrowDown'], (e) => handleArrow(e));
|
|
12
|
+
*
|
|
13
|
+
* // With modifiers
|
|
14
|
+
* useKeyPress('k', () => openSearch(), { metaKey: true });
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare const useKeyPress: (key: KeyFilter, callback: (event: KeyboardEvent) => void, options?: UseKeyPressOptions) => void;
|
|
18
|
+
/**
|
|
19
|
+
* useKeyPressState - Track if a key is currently pressed
|
|
20
|
+
*/
|
|
21
|
+
export declare const useKeyPressState: (key: KeyFilter) => boolean;
|
|
22
|
+
export default useKeyPress;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useRef as m, useEffect as p, useCallback as v } from "react";
|
|
2
|
+
const w = (r, e) => typeof e == "function" ? e(r) : (Array.isArray(e) ? e : [e]).some((n) => {
|
|
3
|
+
const s = n.toLowerCase();
|
|
4
|
+
return r.key.toLowerCase() === s || r.code.toLowerCase() === s;
|
|
5
|
+
}), d = (r, e, a = {}) => {
|
|
6
|
+
const {
|
|
7
|
+
target: n,
|
|
8
|
+
event: s = "keydown",
|
|
9
|
+
preventDefault: f = !1,
|
|
10
|
+
stopPropagation: u = !1,
|
|
11
|
+
metaKey: c = !1,
|
|
12
|
+
ctrlKey: i = !1,
|
|
13
|
+
shiftKey: l = !1,
|
|
14
|
+
altKey: y = !1
|
|
15
|
+
} = a, K = m(e);
|
|
16
|
+
p(() => {
|
|
17
|
+
K.current = e;
|
|
18
|
+
}, [e]);
|
|
19
|
+
const o = v((t) => {
|
|
20
|
+
c && !t.metaKey || i && !t.ctrlKey || l && !t.shiftKey || y && !t.altKey || w(t, r) && (f && t.preventDefault(), u && t.stopPropagation(), K.current(t));
|
|
21
|
+
}, [r, c, i, l, y, f, u]);
|
|
22
|
+
p(() => {
|
|
23
|
+
const t = n || document;
|
|
24
|
+
return t.addEventListener(s, o), () => {
|
|
25
|
+
t.removeEventListener(s, o);
|
|
26
|
+
};
|
|
27
|
+
}, [n, s, o]);
|
|
28
|
+
}, P = (r) => {
|
|
29
|
+
const e = m(!1);
|
|
30
|
+
return d(r, () => {
|
|
31
|
+
e.current = !0;
|
|
32
|
+
}, { event: "keydown" }), d(r, () => {
|
|
33
|
+
e.current = !1;
|
|
34
|
+
}, { event: "keyup" }), e.current;
|
|
35
|
+
};
|
|
36
|
+
export {
|
|
37
|
+
d as useKeyPress,
|
|
38
|
+
P as useKeyPressState
|
|
39
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface UseKeyPressOptions {
|
|
2
|
+
/** Target element (defaults to document) */
|
|
3
|
+
target?: HTMLElement | null;
|
|
4
|
+
/** Event type */
|
|
5
|
+
event?: 'keydown' | 'keyup' | 'keypress';
|
|
6
|
+
/** Prevent default behavior */
|
|
7
|
+
preventDefault?: boolean;
|
|
8
|
+
/** Stop propagation */
|
|
9
|
+
stopPropagation?: boolean;
|
|
10
|
+
/** Only trigger when meta key is pressed */
|
|
11
|
+
metaKey?: boolean;
|
|
12
|
+
/** Only trigger when ctrl key is pressed */
|
|
13
|
+
ctrlKey?: boolean;
|
|
14
|
+
/** Only trigger when shift key is pressed */
|
|
15
|
+
shiftKey?: boolean;
|
|
16
|
+
/** Only trigger when alt key is pressed */
|
|
17
|
+
altKey?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export type KeyFilter = string | string[] | ((event: KeyboardEvent) => boolean);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react"),g=e=>JSON.stringify(e),S=e=>JSON.parse(e);function m(e,t,u={}){const{serializer:l=g,deserializer:c=S,syncTabs:d=!0}=u,[s,n]=a.useState(()=>{if(typeof window>"u")return t;try{const r=window.localStorage.getItem(e);return r?c(r):t}catch(r){return console.warn(`Error reading localStorage key "${e}":`,r),t}}),i=a.useCallback(r=>{try{const o=r instanceof Function?r(s):r;n(o),typeof window<"u"&&window.localStorage.setItem(e,l(o))}catch(o){console.warn(`Error setting localStorage key "${e}":`,o)}},[e,s,l]),w=a.useCallback(()=>{try{n(t),typeof window<"u"&&window.localStorage.removeItem(e)}catch(r){console.warn(`Error removing localStorage key "${e}":`,r)}},[e,t]);return a.useEffect(()=>{if(!d||typeof window>"u")return;const r=o=>{if(o.key===e&&o.newValue!==null)try{n(c(o.newValue))}catch(f){console.warn(`Error syncing localStorage key "${e}":`,f)}else o.key===e&&o.newValue===null&&n(t)};return window.addEventListener("storage",r),()=>window.removeEventListener("storage",r)},[e,t,c,d]),[s,i,w]}exports.useLocalStorage=m;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { UseLocalStorageOptions, UseLocalStorageReturn } from './useLocalStorage.types';
|
|
2
|
+
/**
|
|
3
|
+
* useLocalStorage - Persist state in localStorage
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```tsx
|
|
7
|
+
* const [theme, setTheme, removeTheme] = useLocalStorage('theme', 'light');
|
|
8
|
+
* ```
|
|
9
|
+
*/
|
|
10
|
+
export declare function useLocalStorage<T>(key: string, initialValue: T, options?: UseLocalStorageOptions<T>): UseLocalStorageReturn<T>;
|
|
11
|
+
export default useLocalStorage;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { useState as g, useCallback as d, useEffect as S } from "react";
|
|
2
|
+
const m = (e) => JSON.stringify(e), p = (e) => JSON.parse(e);
|
|
3
|
+
function h(e, t, w = {}) {
|
|
4
|
+
const {
|
|
5
|
+
serializer: s = m,
|
|
6
|
+
deserializer: a = p,
|
|
7
|
+
syncTabs: l = !0
|
|
8
|
+
} = w, [c, n] = g(() => {
|
|
9
|
+
if (typeof window > "u")
|
|
10
|
+
return t;
|
|
11
|
+
try {
|
|
12
|
+
const r = window.localStorage.getItem(e);
|
|
13
|
+
return r ? a(r) : t;
|
|
14
|
+
} catch (r) {
|
|
15
|
+
return console.warn(`Error reading localStorage key "${e}":`, r), t;
|
|
16
|
+
}
|
|
17
|
+
}), f = d((r) => {
|
|
18
|
+
try {
|
|
19
|
+
const o = r instanceof Function ? r(c) : r;
|
|
20
|
+
n(o), typeof window < "u" && window.localStorage.setItem(e, s(o));
|
|
21
|
+
} catch (o) {
|
|
22
|
+
console.warn(`Error setting localStorage key "${e}":`, o);
|
|
23
|
+
}
|
|
24
|
+
}, [e, c, s]), i = d(() => {
|
|
25
|
+
try {
|
|
26
|
+
n(t), typeof window < "u" && window.localStorage.removeItem(e);
|
|
27
|
+
} catch (r) {
|
|
28
|
+
console.warn(`Error removing localStorage key "${e}":`, r);
|
|
29
|
+
}
|
|
30
|
+
}, [e, t]);
|
|
31
|
+
return S(() => {
|
|
32
|
+
if (!l || typeof window > "u") return;
|
|
33
|
+
const r = (o) => {
|
|
34
|
+
if (o.key === e && o.newValue !== null)
|
|
35
|
+
try {
|
|
36
|
+
n(a(o.newValue));
|
|
37
|
+
} catch (u) {
|
|
38
|
+
console.warn(`Error syncing localStorage key "${e}":`, u);
|
|
39
|
+
}
|
|
40
|
+
else o.key === e && o.newValue === null && n(t);
|
|
41
|
+
};
|
|
42
|
+
return window.addEventListener("storage", r), () => window.removeEventListener("storage", r);
|
|
43
|
+
}, [e, t, a, l]), [c, f, i];
|
|
44
|
+
}
|
|
45
|
+
export {
|
|
46
|
+
h as useLocalStorage
|
|
47
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface UseLocalStorageOptions<T> {
|
|
2
|
+
/** Serializer function */
|
|
3
|
+
serializer?: (value: T) => string;
|
|
4
|
+
/** Deserializer function */
|
|
5
|
+
deserializer?: (value: string) => T;
|
|
6
|
+
/** Sync across tabs */
|
|
7
|
+
syncTabs?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export type UseLocalStorageReturn<T> = [
|
|
10
|
+
/** Current value */
|
|
11
|
+
T,
|
|
12
|
+
/** Set value */
|
|
13
|
+
(value: T | ((prev: T) => T)) => void,
|
|
14
|
+
/** Remove value */
|
|
15
|
+
() => void
|
|
16
|
+
];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { UseMediaQueryOptions, UseMediaQueryReturn, BreakpointKey } from './useMediaQuery.types';
|
|
2
|
+
/**
|
|
3
|
+
* useMediaQuery - Track media query matches
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```tsx
|
|
7
|
+
* const isMobile = useMediaQuery('(max-width: 768px)');
|
|
8
|
+
* const isDark = useMediaQuery('dark'); // Uses predefined breakpoint
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export declare const useMediaQuery: (query: string | BreakpointKey, options?: UseMediaQueryOptions) => UseMediaQueryReturn;
|
|
12
|
+
export default useMediaQuery;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface UseMediaQueryOptions {
|
|
2
|
+
/** Default value for SSR */
|
|
3
|
+
defaultValue?: boolean;
|
|
4
|
+
/** Initialize with window check */
|
|
5
|
+
initializeWithValue?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export type UseMediaQueryReturn = boolean;
|
|
8
|
+
/** Predefined breakpoints matching Tailwind */
|
|
9
|
+
export declare const BREAKPOINTS: {
|
|
10
|
+
readonly sm: "(min-width: 640px)";
|
|
11
|
+
readonly md: "(min-width: 768px)";
|
|
12
|
+
readonly lg: "(min-width: 1024px)";
|
|
13
|
+
readonly xl: "(min-width: 1280px)";
|
|
14
|
+
readonly '2xl': "(min-width: 1536px)";
|
|
15
|
+
readonly dark: "(prefers-color-scheme: dark)";
|
|
16
|
+
readonly light: "(prefers-color-scheme: light)";
|
|
17
|
+
readonly reducedMotion: "(prefers-reduced-motion: reduce)";
|
|
18
|
+
readonly portrait: "(orientation: portrait)";
|
|
19
|
+
readonly landscape: "(orientation: landscape)";
|
|
20
|
+
};
|
|
21
|
+
export type BreakpointKey = keyof typeof BREAKPOINTS;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react");function m(a={}){const{speed:s=.5,direction:i="vertical",disableOnMobile:o=!0,useTransform:u=!0}=a,r=t.useRef(null),[n,d]=t.useState(0),[l,f]=t.useState(!1);t.useEffect(()=>{const e=()=>{f(window.innerWidth<768)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),t.useEffect(()=>{if(o&&l)return;const e=()=>{if(!r.current)return;const c=r.current.getBoundingClientRect(),v=window.innerHeight,p=c.top+c.height/2,g=v/2,h=p-g;d(h*s)};return window.addEventListener("scroll",e,{passive:!0}),e(),()=>window.removeEventListener("scroll",e)},[s,o,l]);const w={...u?{transform:i==="vertical"?`translate3d(0, ${n}px, 0)`:`translate3d(${n}px, 0, 0)`}:{position:"relative",[i==="vertical"?"top":"left"]:n},willChange:"transform"};return{ref:r,style:w,offset:n}}exports.useParallax=m;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useRef as b, useState as c, useEffect as a } from "react";
|
|
2
|
+
function E(d = {}) {
|
|
3
|
+
const {
|
|
4
|
+
speed: r = 0.5,
|
|
5
|
+
direction: o = "vertical",
|
|
6
|
+
disableOnMobile: s = !0,
|
|
7
|
+
useTransform: u = !0
|
|
8
|
+
} = d, n = b(null), [t, f] = c(0), [i, w] = c(!1);
|
|
9
|
+
a(() => {
|
|
10
|
+
const e = () => {
|
|
11
|
+
w(window.innerWidth < 768);
|
|
12
|
+
};
|
|
13
|
+
return e(), window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
|
|
14
|
+
}, []), a(() => {
|
|
15
|
+
if (s && i) return;
|
|
16
|
+
const e = () => {
|
|
17
|
+
if (!n.current) return;
|
|
18
|
+
const l = n.current.getBoundingClientRect(), p = window.innerHeight, m = l.top + l.height / 2, h = p / 2, g = m - h;
|
|
19
|
+
f(g * r);
|
|
20
|
+
};
|
|
21
|
+
return window.addEventListener("scroll", e, { passive: !0 }), e(), () => window.removeEventListener("scroll", e);
|
|
22
|
+
}, [r, s, i]);
|
|
23
|
+
const v = {
|
|
24
|
+
...u ? {
|
|
25
|
+
transform: o === "vertical" ? `translate3d(0, ${t}px, 0)` : `translate3d(${t}px, 0, 0)`
|
|
26
|
+
} : {
|
|
27
|
+
position: "relative",
|
|
28
|
+
[o === "vertical" ? "top" : "left"]: t
|
|
29
|
+
},
|
|
30
|
+
willChange: "transform"
|
|
31
|
+
};
|
|
32
|
+
return { ref: n, style: v, offset: t };
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
E as useParallax
|
|
36
|
+
};
|