asterui 0.12.21 → 0.12.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/components/VirtualList.d.ts +29 -0
  2. package/dist/index.d.ts +2 -0
  3. package/dist/index.js +46 -44
  4. package/dist/index.js.map +1 -1
  5. package/dist/index10.js +1 -1
  6. package/dist/index100.js +32 -5
  7. package/dist/index100.js.map +1 -1
  8. package/dist/index101.js +5 -13
  9. package/dist/index101.js.map +1 -1
  10. package/dist/index102.js +11 -43
  11. package/dist/index102.js.map +1 -1
  12. package/dist/index103.js +44 -11
  13. package/dist/index103.js.map +1 -1
  14. package/dist/index104.js +10 -12
  15. package/dist/index104.js.map +1 -1
  16. package/dist/index105.js +14 -7
  17. package/dist/index105.js.map +1 -1
  18. package/dist/index106.js +7 -12
  19. package/dist/index106.js.map +1 -1
  20. package/dist/index107.js +11 -29
  21. package/dist/index107.js.map +1 -1
  22. package/dist/index108.js +29 -16
  23. package/dist/index108.js.map +1 -1
  24. package/dist/index109.js +21 -0
  25. package/dist/index109.js.map +1 -0
  26. package/dist/index11.js +14 -14
  27. package/dist/index110.js +36 -0
  28. package/dist/index110.js.map +1 -0
  29. package/dist/index111.js +523 -0
  30. package/dist/index111.js.map +1 -0
  31. package/dist/index112.js +53 -0
  32. package/dist/index112.js.map +1 -0
  33. package/dist/index20.js +8 -8
  34. package/dist/index23.js +13 -13
  35. package/dist/index28.js +2 -2
  36. package/dist/index36.js +5 -5
  37. package/dist/index40.js +6 -6
  38. package/dist/index41.js +30 -30
  39. package/dist/index45.js +5 -5
  40. package/dist/index47.js +15 -15
  41. package/dist/index51.js +18 -18
  42. package/dist/index51.js.map +1 -1
  43. package/dist/index55.js +4 -4
  44. package/dist/index55.js.map +1 -1
  45. package/dist/index58.js +22 -22
  46. package/dist/index62.js +12 -12
  47. package/dist/index64.js +13 -13
  48. package/dist/index68.js +12 -12
  49. package/dist/index71.js +19 -19
  50. package/dist/index76.js +2 -2
  51. package/dist/index77.js +21 -21
  52. package/dist/index8.js +18 -18
  53. package/dist/index80.js +13 -13
  54. package/dist/index82.js +23 -23
  55. package/dist/index88.js +2 -2
  56. package/dist/index97.js +61 -121
  57. package/dist/index97.js.map +1 -1
  58. package/dist/index98.js +126 -14
  59. package/dist/index98.js.map +1 -1
  60. package/dist/index99.js +12 -31
  61. package/dist/index99.js.map +1 -1
  62. package/package.json +6 -1
@@ -0,0 +1,29 @@
1
+ import { default as React } from 'react';
2
+ export interface VirtualListProps<T> {
3
+ /** Array of items to render */
4
+ items: T[];
5
+ /** Height of the scrollable container */
6
+ height: number | string;
7
+ /** Height of each item, or function returning estimated height per item */
8
+ itemHeight: number | ((item: T, index: number) => number);
9
+ /** Render function for each item */
10
+ renderItem: (item: T, index: number) => React.ReactNode;
11
+ /** Number of items to render outside visible area */
12
+ overscan?: number;
13
+ /** Additional class for the scroll container */
14
+ className?: string;
15
+ /** Additional class for the inner container */
16
+ innerClassName?: string;
17
+ /** Additional class for each item wrapper */
18
+ itemClassName?: string;
19
+ /** Width of the container */
20
+ width?: number | string;
21
+ /** Gap between items */
22
+ gap?: number;
23
+ /** Callback when scroll position changes */
24
+ onScroll?: (scrollTop: number) => void;
25
+ }
26
+ export declare function VirtualList<T>({ items, height, itemHeight, renderItem, overscan, className, innerClassName, itemClassName, width, gap, onScroll, }: VirtualListProps<T>): import("react/jsx-runtime").JSX.Element;
27
+ export declare namespace VirtualList {
28
+ var displayName: string;
29
+ }
package/dist/index.d.ts CHANGED
@@ -188,6 +188,8 @@ export { Typography } from './components/Typography';
188
188
  export type { TypographyProps, TitleProps, ParagraphProps, TextProps, TypographyLinkProps, TypographySize, TitleLevel, } from './components/Typography';
189
189
  export { Upload } from './components/Upload';
190
190
  export type { UploadProps, UploadFile } from './components/Upload';
191
+ export { VirtualList } from './components/VirtualList';
192
+ export type { VirtualListProps } from './components/VirtualList';
191
193
  export { Watermark } from './components/Watermark';
192
194
  export type { WatermarkProps, WatermarkFontOptions, WatermarkGap, WatermarkOffset, } from './components/Watermark';
193
195
  export { Show, Hide } from './components/Responsive';
package/dist/index.js CHANGED
@@ -13,14 +13,14 @@ import { ColorPicker as h } from "./index13.js";
13
13
  import { Card as v } from "./index14.js";
14
14
  import { Cascader as R } from "./index15.js";
15
15
  import { Chart as I } from "./index16.js";
16
- import { Carousel as M } from "./index17.js";
16
+ import { Carousel as L } from "./index17.js";
17
17
  import { Collapse as H } from "./index18.js";
18
18
  import { Container as K } from "./index19.js";
19
19
  import { ContextMenu as N } from "./index20.js";
20
20
  import { Countdown as z } from "./index21.js";
21
21
  import { DatePicker as J } from "./index22.js";
22
22
  import { Descriptions as U } from "./index23.js";
23
- import { Diff as q } from "./index24.js";
23
+ import { Diff as j } from "./index24.js";
24
24
  import { Dock as X } from "./index25.js";
25
25
  import { Divider as Z } from "./index26.js";
26
26
  import { Drawer as $ } from "./index27.js";
@@ -38,14 +38,14 @@ import { HoverGallery as ho } from "./index38.js";
38
38
  import { Image as vo } from "./index39.js";
39
39
  import { Indicator as Ro } from "./index40.js";
40
40
  import { Dropdown as Io } from "./index41.js";
41
- import { Empty as Mo } from "./index42.js";
41
+ import { Empty as Lo } from "./index42.js";
42
42
  import { Input as Ho } from "./index43.js";
43
43
  import { InputNumber as Ko } from "./index44.js";
44
44
  import { Join as No } from "./index45.js";
45
45
  import { Kbd as zo } from "./index46.js";
46
46
  import { Layout as Jo, useSiderContext as Qo } from "./index47.js";
47
- import { List as jo } from "./index48.js";
48
- import { Loading as Vo } from "./index49.js";
47
+ import { List as Vo } from "./index48.js";
48
+ import { Loading as qo } from "./index49.js";
49
49
  import { Mask as Yo } from "./index50.js";
50
50
  import { Masonry as _o } from "./index51.js";
51
51
  import { Mention as or } from "./index52.js";
@@ -65,14 +65,14 @@ import { Popover as wr } from "./index65.js";
65
65
  import { Progress as Fr } from "./index66.js";
66
66
  import { QRCode as Br } from "./index67.js";
67
67
  import { Radio as Ar } from "./index68.js";
68
- import { RadialProgress as Lr } from "./index69.js";
68
+ import { RadialProgress as Mr } from "./index69.js";
69
69
  import { Range as Gr } from "./index70.js";
70
70
  import { Rating as Wr } from "./index71.js";
71
71
  import { Result as Or } from "./index72.js";
72
72
  import { Select as Er } from "./index73.js";
73
73
  import { Segmented as Qr } from "./index74.js";
74
- import { Skeleton as jr } from "./index75.js";
75
- import { Space as Vr } from "./index76.js";
74
+ import { Skeleton as Vr } from "./index75.js";
75
+ import { Space as qr } from "./index76.js";
76
76
  import { Splitter as Yr } from "./index77.js";
77
77
  import { Stats as _r } from "./index78.js";
78
78
  import { Status as oe } from "./index79.js";
@@ -91,20 +91,21 @@ import { Tooltip as he } from "./index91.js";
91
91
  import { Transfer as ve } from "./index92.js";
92
92
  import { Tree as Re } from "./index93.js";
93
93
  import { TreeSelect as Ie } from "./index94.js";
94
- import { Typography as Me } from "./index95.js";
94
+ import { Typography as Le } from "./index95.js";
95
95
  import { Upload as He } from "./index96.js";
96
- import { Watermark as Ke } from "./index97.js";
97
- import { Hide as Ne, Show as Oe } from "./index98.js";
98
- import { useBreakpoint as Ee } from "./index99.js";
99
- import { useDisclosure as Qe } from "./index100.js";
100
- import { useClipboard as je } from "./index101.js";
101
- import { useLocalStorage as Ve } from "./index102.js";
102
- import { useDebounce as Ye } from "./index103.js";
103
- import { useClickOutside as _e } from "./index104.js";
104
- import { usePrevious as ot } from "./index105.js";
105
- import { useHover as et } from "./index106.js";
106
- import { useKeyPress as pt, useKeyPressCallback as mt } from "./index107.js";
107
- import { useWindowSize as xt } from "./index108.js";
96
+ import { VirtualList as Ke } from "./index97.js";
97
+ import { Watermark as Ne } from "./index98.js";
98
+ import { Hide as ze, Show as Ee } from "./index99.js";
99
+ import { useBreakpoint as Qe } from "./index100.js";
100
+ import { useDisclosure as Ve } from "./index101.js";
101
+ import { useClipboard as qe } from "./index102.js";
102
+ import { useLocalStorage as Ye } from "./index103.js";
103
+ import { useDebounce as _e } from "./index104.js";
104
+ import { useClickOutside as ot } from "./index105.js";
105
+ import { usePrevious as et } from "./index106.js";
106
+ import { useHover as pt } from "./index107.js";
107
+ import { useKeyPress as ft, useKeyPressCallback as xt } from "./index108.js";
108
+ import { useWindowSize as it } from "./index109.js";
108
109
  export {
109
110
  e as Affix,
110
111
  f as Alert,
@@ -117,7 +118,7 @@ export {
117
118
  pr as Browser,
118
119
  T as Button,
119
120
  v as Card,
120
- M as Carousel,
121
+ L as Carousel,
121
122
  R as Cascader,
122
123
  I as Chart,
123
124
  y as Chat,
@@ -133,12 +134,12 @@ export {
133
134
  z as Countdown,
134
135
  J as DatePicker,
135
136
  U as Descriptions,
136
- q as Diff,
137
+ j as Diff,
137
138
  Z as Divider,
138
139
  X as Dock,
139
140
  $ as Drawer,
140
141
  Io as Dropdown,
141
- Mo as Empty,
142
+ Lo as Empty,
142
143
  to as Fieldset,
143
144
  mo as FileInput,
144
145
  xo as Filter,
@@ -148,7 +149,7 @@ export {
148
149
  Co as Form,
149
150
  So as Grid,
150
151
  yo as Hero,
151
- Ne as Hide,
152
+ ze as Hide,
152
153
  ho as HoverGallery,
153
154
  vo as Image,
154
155
  Ro as Indicator,
@@ -157,8 +158,8 @@ export {
157
158
  No as Join,
158
159
  zo as Kbd,
159
160
  Jo as Layout,
160
- jo as List,
161
- Vo as Loading,
161
+ Vo as List,
162
+ qo as Loading,
162
163
  Yo as Mask,
163
164
  _o as Masonry,
164
165
  or as Mention,
@@ -173,7 +174,7 @@ export {
173
174
  wr as Popover,
174
175
  Fr as Progress,
175
176
  Br as QRCode,
176
- Lr as RadialProgress,
177
+ Mr as RadialProgress,
177
178
  Ar as Radio,
178
179
  Gr as Range,
179
180
  Wr as Rating,
@@ -181,10 +182,10 @@ export {
181
182
  bo as Row,
182
183
  Qr as Segmented,
183
184
  Er as Select,
184
- Oe as Show,
185
+ Ee as Show,
185
186
  ro as SidebarDrawer,
186
- jr as Skeleton,
187
- Vr as Space,
187
+ Vr as Skeleton,
188
+ qr as Space,
188
189
  Yr as Splitter,
189
190
  _r as Stats,
190
191
  oe as Status,
@@ -203,23 +204,24 @@ export {
203
204
  ve as Transfer,
204
205
  Re as Tree,
205
206
  Ie as TreeSelect,
206
- Me as Typography,
207
+ Le as Typography,
207
208
  He as Upload,
208
- Ke as Watermark,
209
+ Ke as VirtualList,
210
+ Ne as Watermark,
209
211
  nr as Window,
210
212
  Cr as notification,
211
- Ee as useBreakpoint,
212
- _e as useClickOutside,
213
- je as useClipboard,
214
- Ye as useDebounce,
215
- Qe as useDisclosure,
213
+ Qe as useBreakpoint,
214
+ ot as useClickOutside,
215
+ qe as useClipboard,
216
+ _e as useDebounce,
217
+ Ve as useDisclosure,
216
218
  To as useFormInstance,
217
- et as useHover,
218
- pt as useKeyPress,
219
- mt as useKeyPressCallback,
220
- Ve as useLocalStorage,
221
- ot as usePrevious,
219
+ pt as useHover,
220
+ ft as useKeyPress,
221
+ xt as useKeyPressCallback,
222
+ Ye as useLocalStorage,
223
+ et as usePrevious,
222
224
  Qo as useSiderContext,
223
- xt as useWindowSize
225
+ it as useWindowSize
224
226
  };
225
227
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/index10.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsx as n } from "react/jsx-runtime";
2
- import { useClipboard as z } from "./index101.js";
2
+ import { useClipboard as z } from "./index102.js";
3
3
  const W = () => /* @__PURE__ */ n(
4
4
  "svg",
5
5
  {
package/dist/index100.js CHANGED
@@ -1,9 +1,36 @@
1
- import { useState as u, useCallback as s } from "react";
2
- function p(o = !1) {
3
- const [n, e] = u(o), t = s(() => e(!0), []), c = s(() => e(!1), []), l = s(() => e((r) => !r), []);
4
- return { isOpen: n, onOpen: t, onClose: c, onToggle: l, setIsOpen: e };
1
+ import { useState as u, useEffect as f } from "react";
2
+ const t = {
3
+ sm: 640,
4
+ md: 768,
5
+ lg: 1024,
6
+ xl: 1280,
7
+ "2xl": 1536
8
+ }, s = ["xs", "sm", "md", "lg", "xl", "2xl"];
9
+ function l(e) {
10
+ return e >= t["2xl"] ? "2xl" : e >= t.xl ? "xl" : e >= t.lg ? "lg" : e >= t.md ? "md" : e >= t.sm ? "sm" : "xs";
11
+ }
12
+ function i(e, o) {
13
+ return s.indexOf(e) - s.indexOf(o);
14
+ }
15
+ function m() {
16
+ const [e, o] = u(
17
+ () => typeof window < "u" ? window.innerWidth : 1024
18
+ );
19
+ f(() => {
20
+ const n = () => o(window.innerWidth);
21
+ return window.addEventListener("resize", n), () => window.removeEventListener("resize", n);
22
+ }, []);
23
+ const r = l(e);
24
+ return {
25
+ breakpoint: r,
26
+ width: e,
27
+ isAbove: (n) => i(r, n) >= 0,
28
+ isBelow: (n) => i(r, n) < 0,
29
+ isAt: (n) => r === n,
30
+ isBetween: (n, d) => i(r, n) >= 0 && i(r, d) <= 0
31
+ };
5
32
  }
6
33
  export {
7
- p as useDisclosure
34
+ m as useBreakpoint
8
35
  };
9
36
  //# sourceMappingURL=index100.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index100.js","sources":["../src/hooks/useDisclosure.ts"],"sourcesContent":["import { useState, useCallback } from 'react'\n\nexport interface UseDisclosureReturn {\n isOpen: boolean\n onOpen: () => void\n onClose: () => void\n onToggle: () => void\n setIsOpen: (value: boolean) => void\n}\n\n/**\n * Hook for managing open/close state of modals, drawers, dropdowns, etc.\n *\n * @param defaultIsOpen - Initial open state (default: false)\n * @returns Object with isOpen state and control functions\n *\n * @example\n * const { isOpen, onOpen, onClose } = useDisclosure()\n *\n * <Button onClick={onOpen}>Open Modal</Button>\n * <Modal open={isOpen} onClose={onClose}>Content</Modal>\n */\nexport function useDisclosure(defaultIsOpen = false): UseDisclosureReturn {\n const [isOpen, setIsOpen] = useState(defaultIsOpen)\n\n const onOpen = useCallback(() => setIsOpen(true), [])\n const onClose = useCallback(() => setIsOpen(false), [])\n const onToggle = useCallback(() => setIsOpen(prev => !prev), [])\n\n return { isOpen, onOpen, onClose, onToggle, setIsOpen }\n}\n"],"names":["useDisclosure","defaultIsOpen","isOpen","setIsOpen","useState","onOpen","useCallback","onClose","onToggle","prev"],"mappings":";AAsBO,SAASA,EAAcC,IAAgB,IAA4B;AACxE,QAAM,CAACC,GAAQC,CAAS,IAAIC,EAASH,CAAa,GAE5CI,IAASC,EAAY,MAAMH,EAAU,EAAI,GAAG,CAAA,CAAE,GAC9CI,IAAUD,EAAY,MAAMH,EAAU,EAAK,GAAG,CAAA,CAAE,GAChDK,IAAWF,EAAY,MAAMH,EAAU,OAAQ,CAACM,CAAI,GAAG,EAAE;AAE/D,SAAO,EAAE,QAAAP,GAAQ,QAAAG,GAAQ,SAAAE,GAAS,UAAAC,GAAU,WAAAL,EAAA;AAC9C;"}
1
+ {"version":3,"file":"index100.js","sources":["../src/hooks/useBreakpoint.ts"],"sourcesContent":["import { useState, useEffect } from 'react'\n\nexport type Breakpoint = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl'\n\nconst breakpoints: Record<Breakpoint, number> = {\n xs: 0,\n sm: 640,\n md: 768,\n lg: 1024,\n xl: 1280,\n '2xl': 1536,\n}\n\nconst breakpointOrder: Breakpoint[] = ['xs', 'sm', 'md', 'lg', 'xl', '2xl']\n\nfunction getBreakpoint(width: number): Breakpoint {\n if (width >= breakpoints['2xl']) return '2xl'\n if (width >= breakpoints.xl) return 'xl'\n if (width >= breakpoints.lg) return 'lg'\n if (width >= breakpoints.md) return 'md'\n if (width >= breakpoints.sm) return 'sm'\n return 'xs'\n}\n\nfunction compareBreakpoints(a: Breakpoint, b: Breakpoint): number {\n return breakpointOrder.indexOf(a) - breakpointOrder.indexOf(b)\n}\n\nexport interface UseBreakpointReturn {\n breakpoint: Breakpoint\n width: number\n isAbove: (bp: Breakpoint) => boolean\n isBelow: (bp: Breakpoint) => boolean\n isAt: (bp: Breakpoint) => boolean\n isBetween: (min: Breakpoint, max: Breakpoint) => boolean\n}\n\nexport function useBreakpoint(): UseBreakpointReturn {\n const [width, setWidth] = useState(() =>\n typeof window !== 'undefined' ? window.innerWidth : 1024\n )\n\n useEffect(() => {\n const handleResize = () => setWidth(window.innerWidth)\n\n window.addEventListener('resize', handleResize)\n return () => window.removeEventListener('resize', handleResize)\n }, [])\n\n const breakpoint = getBreakpoint(width)\n\n return {\n breakpoint,\n width,\n isAbove: (bp: Breakpoint) => compareBreakpoints(breakpoint, bp) >= 0,\n isBelow: (bp: Breakpoint) => compareBreakpoints(breakpoint, bp) < 0,\n isAt: (bp: Breakpoint) => breakpoint === bp,\n isBetween: (min: Breakpoint, max: Breakpoint) =>\n compareBreakpoints(breakpoint, min) >= 0 && compareBreakpoints(breakpoint, max) <= 0,\n }\n}\n"],"names":["breakpoints","breakpointOrder","getBreakpoint","width","compareBreakpoints","a","b","useBreakpoint","setWidth","useState","useEffect","handleResize","breakpoint","bp","min","max"],"mappings":";AAIA,MAAMA,IAA0C;AAAA,EAE9C,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,OAAO;AACT,GAEMC,IAAgC,CAAC,MAAM,MAAM,MAAM,MAAM,MAAM,KAAK;AAE1E,SAASC,EAAcC,GAA2B;AAChD,SAAIA,KAASH,EAAY,KAAK,IAAU,QACpCG,KAASH,EAAY,KAAW,OAChCG,KAASH,EAAY,KAAW,OAChCG,KAASH,EAAY,KAAW,OAChCG,KAASH,EAAY,KAAW,OAC7B;AACT;AAEA,SAASI,EAAmBC,GAAeC,GAAuB;AAChE,SAAOL,EAAgB,QAAQI,CAAC,IAAIJ,EAAgB,QAAQK,CAAC;AAC/D;AAWO,SAASC,IAAqC;AACnD,QAAM,CAACJ,GAAOK,CAAQ,IAAIC;AAAA,IAAS,MACjC,OAAO,SAAW,MAAc,OAAO,aAAa;AAAA,EAAA;AAGtD,EAAAC,EAAU,MAAM;AACd,UAAMC,IAAe,MAAMH,EAAS,OAAO,UAAU;AAErD,kBAAO,iBAAiB,UAAUG,CAAY,GACvC,MAAM,OAAO,oBAAoB,UAAUA,CAAY;AAAA,EAChE,GAAG,CAAA,CAAE;AAEL,QAAMC,IAAaV,EAAcC,CAAK;AAEtC,SAAO;AAAA,IACL,YAAAS;AAAA,IACA,OAAAT;AAAA,IACA,SAAS,CAACU,MAAmBT,EAAmBQ,GAAYC,CAAE,KAAK;AAAA,IACnE,SAAS,CAACA,MAAmBT,EAAmBQ,GAAYC,CAAE,IAAI;AAAA,IAClE,MAAM,CAACA,MAAmBD,MAAeC;AAAA,IACzC,WAAW,CAACC,GAAiBC,MAC3BX,EAAmBQ,GAAYE,CAAG,KAAK,KAAKV,EAAmBQ,GAAYG,CAAG,KAAK;AAAA,EAAA;AAEzF;"}
package/dist/index101.js CHANGED
@@ -1,17 +1,9 @@
1
- import { useState as a, useCallback as s } from "react";
2
- function p(t = 2e3) {
3
- const [n, r] = a(!1), [l, e] = a(null), c = s(async (i) => {
4
- try {
5
- return await navigator.clipboard.writeText(i), r(!0), e(null), setTimeout(() => r(!1), t), !0;
6
- } catch (o) {
7
- return e(o instanceof Error ? o : new Error("Failed to copy")), r(!1), !1;
8
- }
9
- }, [t]), u = s(() => {
10
- r(!1), e(null);
11
- }, []);
12
- return { copy: c, copied: n, error: l, reset: u };
1
+ import { useState as u, useCallback as s } from "react";
2
+ function p(o = !1) {
3
+ const [n, e] = u(o), t = s(() => e(!0), []), c = s(() => e(!1), []), l = s(() => e((r) => !r), []);
4
+ return { isOpen: n, onOpen: t, onClose: c, onToggle: l, setIsOpen: e };
13
5
  }
14
6
  export {
15
- p as useClipboard
7
+ p as useDisclosure
16
8
  };
17
9
  //# sourceMappingURL=index101.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index101.js","sources":["../src/hooks/useClipboard.ts"],"sourcesContent":["import { useState, useCallback } from 'react'\n\nexport interface UseClipboardReturn {\n copy: (text: string) => Promise<boolean>\n copied: boolean\n error: Error | null\n reset: () => void\n}\n\n/**\n * Hook for copying text to clipboard with success/error state.\n *\n * @param timeout - Duration in ms to show copied state (default: 2000)\n * @returns Object with copy function and state\n *\n * @example\n * const { copy, copied } = useClipboard()\n *\n * <Button onClick={() => copy('Hello!')}>\n * {copied ? 'Copied!' : 'Copy'}\n * </Button>\n */\nexport function useClipboard(timeout = 2000): UseClipboardReturn {\n const [copied, setCopied] = useState(false)\n const [error, setError] = useState<Error | null>(null)\n\n const copy = useCallback(async (text: string): Promise<boolean> => {\n try {\n await navigator.clipboard.writeText(text)\n setCopied(true)\n setError(null)\n\n setTimeout(() => setCopied(false), timeout)\n return true\n } catch (err) {\n setError(err instanceof Error ? err : new Error('Failed to copy'))\n setCopied(false)\n return false\n }\n }, [timeout])\n\n const reset = useCallback(() => {\n setCopied(false)\n setError(null)\n }, [])\n\n return { copy, copied, error, reset }\n}\n"],"names":["useClipboard","timeout","copied","setCopied","useState","error","setError","copy","useCallback","text","err","reset"],"mappings":";AAsBO,SAASA,EAAaC,IAAU,KAA0B;AAC/D,QAAM,CAACC,GAAQC,CAAS,IAAIC,EAAS,EAAK,GACpC,CAACC,GAAOC,CAAQ,IAAIF,EAAuB,IAAI,GAE/CG,IAAOC,EAAY,OAAOC,MAAmC;AACjE,QAAI;AACF,mBAAM,UAAU,UAAU,UAAUA,CAAI,GACxCN,EAAU,EAAI,GACdG,EAAS,IAAI,GAEb,WAAW,MAAMH,EAAU,EAAK,GAAGF,CAAO,GACnC;AAAA,IACT,SAASS,GAAK;AACZ,aAAAJ,EAASI,aAAe,QAAQA,IAAM,IAAI,MAAM,gBAAgB,CAAC,GACjEP,EAAU,EAAK,GACR;AAAA,IACT;AAAA,EACF,GAAG,CAACF,CAAO,CAAC,GAENU,IAAQH,EAAY,MAAM;AAC9B,IAAAL,EAAU,EAAK,GACfG,EAAS,IAAI;AAAA,EACf,GAAG,CAAA,CAAE;AAEL,SAAO,EAAE,MAAAC,GAAM,QAAAL,GAAQ,OAAAG,GAAO,OAAAM,EAAA;AAChC;"}
1
+ {"version":3,"file":"index101.js","sources":["../src/hooks/useDisclosure.ts"],"sourcesContent":["import { useState, useCallback } from 'react'\n\nexport interface UseDisclosureReturn {\n isOpen: boolean\n onOpen: () => void\n onClose: () => void\n onToggle: () => void\n setIsOpen: (value: boolean) => void\n}\n\n/**\n * Hook for managing open/close state of modals, drawers, dropdowns, etc.\n *\n * @param defaultIsOpen - Initial open state (default: false)\n * @returns Object with isOpen state and control functions\n *\n * @example\n * const { isOpen, onOpen, onClose } = useDisclosure()\n *\n * <Button onClick={onOpen}>Open Modal</Button>\n * <Modal open={isOpen} onClose={onClose}>Content</Modal>\n */\nexport function useDisclosure(defaultIsOpen = false): UseDisclosureReturn {\n const [isOpen, setIsOpen] = useState(defaultIsOpen)\n\n const onOpen = useCallback(() => setIsOpen(true), [])\n const onClose = useCallback(() => setIsOpen(false), [])\n const onToggle = useCallback(() => setIsOpen(prev => !prev), [])\n\n return { isOpen, onOpen, onClose, onToggle, setIsOpen }\n}\n"],"names":["useDisclosure","defaultIsOpen","isOpen","setIsOpen","useState","onOpen","useCallback","onClose","onToggle","prev"],"mappings":";AAsBO,SAASA,EAAcC,IAAgB,IAA4B;AACxE,QAAM,CAACC,GAAQC,CAAS,IAAIC,EAASH,CAAa,GAE5CI,IAASC,EAAY,MAAMH,EAAU,EAAI,GAAG,CAAA,CAAE,GAC9CI,IAAUD,EAAY,MAAMH,EAAU,EAAK,GAAG,CAAA,CAAE,GAChDK,IAAWF,EAAY,MAAMH,EAAU,OAAQ,CAACM,CAAI,GAAG,EAAE;AAE/D,SAAO,EAAE,QAAAP,GAAQ,QAAAG,GAAQ,SAAAE,GAAS,UAAAC,GAAU,WAAAL,EAAA;AAC9C;"}
package/dist/index102.js CHANGED
@@ -1,49 +1,17 @@
1
- import { useState as u, useCallback as c, useEffect as f } from "react";
2
- function S(o, t) {
3
- const [s, n] = u(() => {
4
- if (typeof window > "u")
5
- return t;
1
+ import { useState as a, useCallback as s } from "react";
2
+ function p(t = 2e3) {
3
+ const [n, r] = a(!1), [l, e] = a(null), c = s(async (i) => {
6
4
  try {
7
- const e = window.localStorage.getItem(o);
8
- return e ? JSON.parse(e) : t;
9
- } catch {
10
- return t;
5
+ return await navigator.clipboard.writeText(i), r(!0), e(null), setTimeout(() => r(!1), t), !0;
6
+ } catch (o) {
7
+ return e(o instanceof Error ? o : new Error("Failed to copy")), r(!1), !1;
11
8
  }
12
- }), d = c(
13
- (e) => {
14
- n((r) => {
15
- const a = e instanceof Function ? e(r) : e;
16
- if (typeof window < "u")
17
- try {
18
- window.localStorage.setItem(o, JSON.stringify(a));
19
- } catch (l) {
20
- console.warn(`Failed to save to localStorage key "${o}":`, l);
21
- }
22
- return a;
23
- });
24
- },
25
- [o]
26
- ), w = c(() => {
27
- if (typeof window < "u")
28
- try {
29
- window.localStorage.removeItem(o);
30
- } catch (e) {
31
- console.warn(`Failed to remove localStorage key "${o}":`, e);
32
- }
33
- n(t);
34
- }, [o, t]);
35
- return f(() => {
36
- const e = (r) => {
37
- if (r.key === o && r.newValue !== null)
38
- try {
39
- n(JSON.parse(r.newValue));
40
- } catch {
41
- }
42
- };
43
- return window.addEventListener("storage", e), () => window.removeEventListener("storage", e);
44
- }, [o]), [s, d, w];
9
+ }, [t]), u = s(() => {
10
+ r(!1), e(null);
11
+ }, []);
12
+ return { copy: c, copied: n, error: l, reset: u };
45
13
  }
46
14
  export {
47
- S as useLocalStorage
15
+ p as useClipboard
48
16
  };
49
17
  //# sourceMappingURL=index102.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index102.js","sources":["../src/hooks/useLocalStorage.ts"],"sourcesContent":["import { useState, useCallback, useEffect } from 'react'\n\n/**\n * Hook for persisting state to localStorage.\n *\n * @param key - localStorage key\n * @param initialValue - Initial value if key doesn't exist\n * @returns [value, setValue, removeValue] tuple\n *\n * @example\n * const [theme, setTheme] = useLocalStorage('theme', 'light')\n * const [user, setUser, removeUser] = useLocalStorage('user', null)\n */\nexport function useLocalStorage<T>(\n key: string,\n initialValue: T\n): [T, (value: T | ((prev: T) => T)) => void, () => void] {\n // Get initial value from localStorage or use default\n const [storedValue, setStoredValue] = useState<T>(() => {\n if (typeof window === 'undefined') {\n return initialValue\n }\n\n try {\n const item = window.localStorage.getItem(key)\n return item ? (JSON.parse(item) as T) : initialValue\n } catch {\n return initialValue\n }\n })\n\n // Update localStorage when value changes\n const setValue = useCallback(\n (value: T | ((prev: T) => T)) => {\n setStoredValue(prev => {\n const valueToStore = value instanceof Function ? value(prev) : value\n\n if (typeof window !== 'undefined') {\n try {\n window.localStorage.setItem(key, JSON.stringify(valueToStore))\n } catch (error) {\n console.warn(`Failed to save to localStorage key \"${key}\":`, error)\n }\n }\n\n return valueToStore\n })\n },\n [key]\n )\n\n // Remove from localStorage\n const removeValue = useCallback(() => {\n if (typeof window !== 'undefined') {\n try {\n window.localStorage.removeItem(key)\n } catch (error) {\n console.warn(`Failed to remove localStorage key \"${key}\":`, error)\n }\n }\n setStoredValue(initialValue)\n }, [key, initialValue])\n\n // Sync with other tabs/windows\n useEffect(() => {\n const handleStorageChange = (e: StorageEvent) => {\n if (e.key === key && e.newValue !== null) {\n try {\n setStoredValue(JSON.parse(e.newValue) as T)\n } catch {\n // Ignore parse errors\n }\n }\n }\n\n window.addEventListener('storage', handleStorageChange)\n return () => window.removeEventListener('storage', handleStorageChange)\n }, [key])\n\n return [storedValue, setValue, removeValue]\n}\n"],"names":["useLocalStorage","key","initialValue","storedValue","setStoredValue","useState","item","setValue","useCallback","value","prev","valueToStore","error","removeValue","useEffect","handleStorageChange","e"],"mappings":";AAaO,SAASA,EACdC,GACAC,GACwD;AAExD,QAAM,CAACC,GAAaC,CAAc,IAAIC,EAAY,MAAM;AACtD,QAAI,OAAO,SAAW;AACpB,aAAOH;AAGT,QAAI;AACF,YAAMI,IAAO,OAAO,aAAa,QAAQL,CAAG;AAC5C,aAAOK,IAAQ,KAAK,MAAMA,CAAI,IAAUJ;AAAA,IAC1C,QAAQ;AACN,aAAOA;AAAA,IACT;AAAA,EACF,CAAC,GAGKK,IAAWC;AAAA,IACf,CAACC,MAAgC;AAC/B,MAAAL,EAAe,CAAAM,MAAQ;AACrB,cAAMC,IAAeF,aAAiB,WAAWA,EAAMC,CAAI,IAAID;AAE/D,YAAI,OAAO,SAAW;AACpB,cAAI;AACF,mBAAO,aAAa,QAAQR,GAAK,KAAK,UAAUU,CAAY,CAAC;AAAA,UAC/D,SAASC,GAAO;AACd,oBAAQ,KAAK,uCAAuCX,CAAG,MAAMW,CAAK;AAAA,UACpE;AAGF,eAAOD;AAAA,MACT,CAAC;AAAA,IACH;AAAA,IACA,CAACV,CAAG;AAAA,EAAA,GAIAY,IAAcL,EAAY,MAAM;AACpC,QAAI,OAAO,SAAW;AACpB,UAAI;AACF,eAAO,aAAa,WAAWP,CAAG;AAAA,MACpC,SAASW,GAAO;AACd,gBAAQ,KAAK,sCAAsCX,CAAG,MAAMW,CAAK;AAAA,MACnE;AAEF,IAAAR,EAAeF,CAAY;AAAA,EAC7B,GAAG,CAACD,GAAKC,CAAY,CAAC;AAGtB,SAAAY,EAAU,MAAM;AACd,UAAMC,IAAsB,CAACC,MAAoB;AAC/C,UAAIA,EAAE,QAAQf,KAAOe,EAAE,aAAa;AAClC,YAAI;AACF,UAAAZ,EAAe,KAAK,MAAMY,EAAE,QAAQ,CAAM;AAAA,QAC5C,QAAQ;AAAA,QAER;AAAA,IAEJ;AAEA,kBAAO,iBAAiB,WAAWD,CAAmB,GAC/C,MAAM,OAAO,oBAAoB,WAAWA,CAAmB;AAAA,EACxE,GAAG,CAACd,CAAG,CAAC,GAED,CAACE,GAAaI,GAAUM,CAAW;AAC5C;"}
1
+ {"version":3,"file":"index102.js","sources":["../src/hooks/useClipboard.ts"],"sourcesContent":["import { useState, useCallback } from 'react'\n\nexport interface UseClipboardReturn {\n copy: (text: string) => Promise<boolean>\n copied: boolean\n error: Error | null\n reset: () => void\n}\n\n/**\n * Hook for copying text to clipboard with success/error state.\n *\n * @param timeout - Duration in ms to show copied state (default: 2000)\n * @returns Object with copy function and state\n *\n * @example\n * const { copy, copied } = useClipboard()\n *\n * <Button onClick={() => copy('Hello!')}>\n * {copied ? 'Copied!' : 'Copy'}\n * </Button>\n */\nexport function useClipboard(timeout = 2000): UseClipboardReturn {\n const [copied, setCopied] = useState(false)\n const [error, setError] = useState<Error | null>(null)\n\n const copy = useCallback(async (text: string): Promise<boolean> => {\n try {\n await navigator.clipboard.writeText(text)\n setCopied(true)\n setError(null)\n\n setTimeout(() => setCopied(false), timeout)\n return true\n } catch (err) {\n setError(err instanceof Error ? err : new Error('Failed to copy'))\n setCopied(false)\n return false\n }\n }, [timeout])\n\n const reset = useCallback(() => {\n setCopied(false)\n setError(null)\n }, [])\n\n return { copy, copied, error, reset }\n}\n"],"names":["useClipboard","timeout","copied","setCopied","useState","error","setError","copy","useCallback","text","err","reset"],"mappings":";AAsBO,SAASA,EAAaC,IAAU,KAA0B;AAC/D,QAAM,CAACC,GAAQC,CAAS,IAAIC,EAAS,EAAK,GACpC,CAACC,GAAOC,CAAQ,IAAIF,EAAuB,IAAI,GAE/CG,IAAOC,EAAY,OAAOC,MAAmC;AACjE,QAAI;AACF,mBAAM,UAAU,UAAU,UAAUA,CAAI,GACxCN,EAAU,EAAI,GACdG,EAAS,IAAI,GAEb,WAAW,MAAMH,EAAU,EAAK,GAAGF,CAAO,GACnC;AAAA,IACT,SAASS,GAAK;AACZ,aAAAJ,EAASI,aAAe,QAAQA,IAAM,IAAI,MAAM,gBAAgB,CAAC,GACjEP,EAAU,EAAK,GACR;AAAA,IACT;AAAA,EACF,GAAG,CAACF,CAAO,CAAC,GAENU,IAAQH,EAAY,MAAM;AAC9B,IAAAL,EAAU,EAAK,GACfG,EAAS,IAAI;AAAA,EACf,GAAG,CAAA,CAAE;AAEL,SAAO,EAAE,MAAAC,GAAM,QAAAL,GAAQ,OAAAG,GAAO,OAAAM,EAAA;AAChC;"}
package/dist/index103.js CHANGED
@@ -1,16 +1,49 @@
1
- import { useState as r, useEffect as c } from "react";
2
- function i(e, t = 300) {
3
- const [o, u] = r(e);
4
- return c(() => {
5
- const n = setTimeout(() => {
6
- u(e);
7
- }, t);
8
- return () => {
9
- clearTimeout(n);
1
+ import { useState as u, useCallback as c, useEffect as f } from "react";
2
+ function S(o, t) {
3
+ const [s, n] = u(() => {
4
+ if (typeof window > "u")
5
+ return t;
6
+ try {
7
+ const e = window.localStorage.getItem(o);
8
+ return e ? JSON.parse(e) : t;
9
+ } catch {
10
+ return t;
11
+ }
12
+ }), d = c(
13
+ (e) => {
14
+ n((r) => {
15
+ const a = e instanceof Function ? e(r) : e;
16
+ if (typeof window < "u")
17
+ try {
18
+ window.localStorage.setItem(o, JSON.stringify(a));
19
+ } catch (l) {
20
+ console.warn(`Failed to save to localStorage key "${o}":`, l);
21
+ }
22
+ return a;
23
+ });
24
+ },
25
+ [o]
26
+ ), w = c(() => {
27
+ if (typeof window < "u")
28
+ try {
29
+ window.localStorage.removeItem(o);
30
+ } catch (e) {
31
+ console.warn(`Failed to remove localStorage key "${o}":`, e);
32
+ }
33
+ n(t);
34
+ }, [o, t]);
35
+ return f(() => {
36
+ const e = (r) => {
37
+ if (r.key === o && r.newValue !== null)
38
+ try {
39
+ n(JSON.parse(r.newValue));
40
+ } catch {
41
+ }
10
42
  };
11
- }, [e, t]), o;
43
+ return window.addEventListener("storage", e), () => window.removeEventListener("storage", e);
44
+ }, [o]), [s, d, w];
12
45
  }
13
46
  export {
14
- i as useDebounce
47
+ S as useLocalStorage
15
48
  };
16
49
  //# sourceMappingURL=index103.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index103.js","sources":["../src/hooks/useDebounce.ts"],"sourcesContent":["import { useState, useEffect } from 'react'\n\n/**\n * Hook that delays updating a value until after a specified delay.\n * Useful for search inputs to avoid excessive API calls.\n *\n * @param value - Value to debounce\n * @param delay - Delay in milliseconds (default: 300)\n * @returns Debounced value\n *\n * @example\n * const [search, setSearch] = useState('')\n * const debouncedSearch = useDebounce(search, 500)\n *\n * useEffect(() => {\n * // This runs 500ms after user stops typing\n * fetchResults(debouncedSearch)\n * }, [debouncedSearch])\n */\nexport function useDebounce<T>(value: T, delay = 300): T {\n const [debouncedValue, setDebouncedValue] = useState<T>(value)\n\n useEffect(() => {\n const timer = setTimeout(() => {\n setDebouncedValue(value)\n }, delay)\n\n return () => {\n clearTimeout(timer)\n }\n }, [value, delay])\n\n return debouncedValue\n}\n"],"names":["useDebounce","value","delay","debouncedValue","setDebouncedValue","useState","useEffect","timer"],"mappings":";AAmBO,SAASA,EAAeC,GAAUC,IAAQ,KAAQ;AACvD,QAAM,CAACC,GAAgBC,CAAiB,IAAIC,EAAYJ,CAAK;AAE7D,SAAAK,EAAU,MAAM;AACd,UAAMC,IAAQ,WAAW,MAAM;AAC7B,MAAAH,EAAkBH,CAAK;AAAA,IACzB,GAAGC,CAAK;AAER,WAAO,MAAM;AACX,mBAAaK,CAAK;AAAA,IACpB;AAAA,EACF,GAAG,CAACN,GAAOC,CAAK,CAAC,GAEVC;AACT;"}
1
+ {"version":3,"file":"index103.js","sources":["../src/hooks/useLocalStorage.ts"],"sourcesContent":["import { useState, useCallback, useEffect } from 'react'\n\n/**\n * Hook for persisting state to localStorage.\n *\n * @param key - localStorage key\n * @param initialValue - Initial value if key doesn't exist\n * @returns [value, setValue, removeValue] tuple\n *\n * @example\n * const [theme, setTheme] = useLocalStorage('theme', 'light')\n * const [user, setUser, removeUser] = useLocalStorage('user', null)\n */\nexport function useLocalStorage<T>(\n key: string,\n initialValue: T\n): [T, (value: T | ((prev: T) => T)) => void, () => void] {\n // Get initial value from localStorage or use default\n const [storedValue, setStoredValue] = useState<T>(() => {\n if (typeof window === 'undefined') {\n return initialValue\n }\n\n try {\n const item = window.localStorage.getItem(key)\n return item ? (JSON.parse(item) as T) : initialValue\n } catch {\n return initialValue\n }\n })\n\n // Update localStorage when value changes\n const setValue = useCallback(\n (value: T | ((prev: T) => T)) => {\n setStoredValue(prev => {\n const valueToStore = value instanceof Function ? value(prev) : value\n\n if (typeof window !== 'undefined') {\n try {\n window.localStorage.setItem(key, JSON.stringify(valueToStore))\n } catch (error) {\n console.warn(`Failed to save to localStorage key \"${key}\":`, error)\n }\n }\n\n return valueToStore\n })\n },\n [key]\n )\n\n // Remove from localStorage\n const removeValue = useCallback(() => {\n if (typeof window !== 'undefined') {\n try {\n window.localStorage.removeItem(key)\n } catch (error) {\n console.warn(`Failed to remove localStorage key \"${key}\":`, error)\n }\n }\n setStoredValue(initialValue)\n }, [key, initialValue])\n\n // Sync with other tabs/windows\n useEffect(() => {\n const handleStorageChange = (e: StorageEvent) => {\n if (e.key === key && e.newValue !== null) {\n try {\n setStoredValue(JSON.parse(e.newValue) as T)\n } catch {\n // Ignore parse errors\n }\n }\n }\n\n window.addEventListener('storage', handleStorageChange)\n return () => window.removeEventListener('storage', handleStorageChange)\n }, [key])\n\n return [storedValue, setValue, removeValue]\n}\n"],"names":["useLocalStorage","key","initialValue","storedValue","setStoredValue","useState","item","setValue","useCallback","value","prev","valueToStore","error","removeValue","useEffect","handleStorageChange","e"],"mappings":";AAaO,SAASA,EACdC,GACAC,GACwD;AAExD,QAAM,CAACC,GAAaC,CAAc,IAAIC,EAAY,MAAM;AACtD,QAAI,OAAO,SAAW;AACpB,aAAOH;AAGT,QAAI;AACF,YAAMI,IAAO,OAAO,aAAa,QAAQL,CAAG;AAC5C,aAAOK,IAAQ,KAAK,MAAMA,CAAI,IAAUJ;AAAA,IAC1C,QAAQ;AACN,aAAOA;AAAA,IACT;AAAA,EACF,CAAC,GAGKK,IAAWC;AAAA,IACf,CAACC,MAAgC;AAC/B,MAAAL,EAAe,CAAAM,MAAQ;AACrB,cAAMC,IAAeF,aAAiB,WAAWA,EAAMC,CAAI,IAAID;AAE/D,YAAI,OAAO,SAAW;AACpB,cAAI;AACF,mBAAO,aAAa,QAAQR,GAAK,KAAK,UAAUU,CAAY,CAAC;AAAA,UAC/D,SAASC,GAAO;AACd,oBAAQ,KAAK,uCAAuCX,CAAG,MAAMW,CAAK;AAAA,UACpE;AAGF,eAAOD;AAAA,MACT,CAAC;AAAA,IACH;AAAA,IACA,CAACV,CAAG;AAAA,EAAA,GAIAY,IAAcL,EAAY,MAAM;AACpC,QAAI,OAAO,SAAW;AACpB,UAAI;AACF,eAAO,aAAa,WAAWP,CAAG;AAAA,MACpC,SAASW,GAAO;AACd,gBAAQ,KAAK,sCAAsCX,CAAG,MAAMW,CAAK;AAAA,MACnE;AAEF,IAAAR,EAAeF,CAAY;AAAA,EAC7B,GAAG,CAACD,GAAKC,CAAY,CAAC;AAGtB,SAAAY,EAAU,MAAM;AACd,UAAMC,IAAsB,CAACC,MAAoB;AAC/C,UAAIA,EAAE,QAAQf,KAAOe,EAAE,aAAa;AAClC,YAAI;AACF,UAAAZ,EAAe,KAAK,MAAMY,EAAE,QAAQ,CAAM;AAAA,QAC5C,QAAQ;AAAA,QAER;AAAA,IAEJ;AAEA,kBAAO,iBAAiB,WAAWD,CAAmB,GAC/C,MAAM,OAAO,oBAAoB,WAAWA,CAAmB;AAAA,EACxE,GAAG,CAACd,CAAG,CAAC,GAED,CAACE,GAAaI,GAAUM,CAAW;AAC5C;"}
package/dist/index104.js CHANGED
@@ -1,18 +1,16 @@
1
- import { useRef as s, useEffect as c } from "react";
2
- function m(t, n = !0) {
3
- const r = s(null);
1
+ import { useState as r, useEffect as c } from "react";
2
+ function i(e, t = 300) {
3
+ const [o, u] = r(e);
4
4
  return c(() => {
5
- if (!n) return;
6
- const e = (o) => {
7
- const u = r.current;
8
- !u || u.contains(o.target) || t(o);
5
+ const n = setTimeout(() => {
6
+ u(e);
7
+ }, t);
8
+ return () => {
9
+ clearTimeout(n);
9
10
  };
10
- return document.addEventListener("mousedown", e), document.addEventListener("touchstart", e), () => {
11
- document.removeEventListener("mousedown", e), document.removeEventListener("touchstart", e);
12
- };
13
- }, [t, n]), r;
11
+ }, [e, t]), o;
14
12
  }
15
13
  export {
16
- m as useClickOutside
14
+ i as useDebounce
17
15
  };
18
16
  //# sourceMappingURL=index104.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index104.js","sources":["../src/hooks/useClickOutside.ts"],"sourcesContent":["import { useEffect, useRef, type RefObject } from 'react'\n\n/**\n * Hook that detects clicks outside of a referenced element.\n * Useful for closing dropdowns, modals, or menus.\n *\n * @param handler - Callback when click outside is detected\n * @param enabled - Whether the listener is active (default: true)\n * @returns Ref to attach to the element\n *\n * @example\n * const ref = useClickOutside(() => setIsOpen(false))\n *\n * <div ref={ref}>\n * <Dropdown>...</Dropdown>\n * </div>\n */\nexport function useClickOutside<T extends HTMLElement = HTMLElement>(\n handler: (event: MouseEvent | TouchEvent) => void,\n enabled = true\n): RefObject<T | null> {\n const ref = useRef<T>(null)\n\n useEffect(() => {\n if (!enabled) return\n\n const listener = (event: MouseEvent | TouchEvent) => {\n const el = ref.current\n if (!el || el.contains(event.target as Node)) {\n return\n }\n handler(event)\n }\n\n document.addEventListener('mousedown', listener)\n document.addEventListener('touchstart', listener)\n\n return () => {\n document.removeEventListener('mousedown', listener)\n document.removeEventListener('touchstart', listener)\n }\n }, [handler, enabled])\n\n return ref\n}\n"],"names":["useClickOutside","handler","enabled","ref","useRef","useEffect","listener","event","el"],"mappings":";AAiBO,SAASA,EACdC,GACAC,IAAU,IACW;AACrB,QAAMC,IAAMC,EAAU,IAAI;AAE1B,SAAAC,EAAU,MAAM;AACd,QAAI,CAACH,EAAS;AAEd,UAAMI,IAAW,CAACC,MAAmC;AACnD,YAAMC,IAAKL,EAAI;AACf,MAAI,CAACK,KAAMA,EAAG,SAASD,EAAM,MAAc,KAG3CN,EAAQM,CAAK;AAAA,IACf;AAEA,oBAAS,iBAAiB,aAAaD,CAAQ,GAC/C,SAAS,iBAAiB,cAAcA,CAAQ,GAEzC,MAAM;AACX,eAAS,oBAAoB,aAAaA,CAAQ,GAClD,SAAS,oBAAoB,cAAcA,CAAQ;AAAA,IACrD;AAAA,EACF,GAAG,CAACL,GAASC,CAAO,CAAC,GAEdC;AACT;"}
1
+ {"version":3,"file":"index104.js","sources":["../src/hooks/useDebounce.ts"],"sourcesContent":["import { useState, useEffect } from 'react'\n\n/**\n * Hook that delays updating a value until after a specified delay.\n * Useful for search inputs to avoid excessive API calls.\n *\n * @param value - Value to debounce\n * @param delay - Delay in milliseconds (default: 300)\n * @returns Debounced value\n *\n * @example\n * const [search, setSearch] = useState('')\n * const debouncedSearch = useDebounce(search, 500)\n *\n * useEffect(() => {\n * // This runs 500ms after user stops typing\n * fetchResults(debouncedSearch)\n * }, [debouncedSearch])\n */\nexport function useDebounce<T>(value: T, delay = 300): T {\n const [debouncedValue, setDebouncedValue] = useState<T>(value)\n\n useEffect(() => {\n const timer = setTimeout(() => {\n setDebouncedValue(value)\n }, delay)\n\n return () => {\n clearTimeout(timer)\n }\n }, [value, delay])\n\n return debouncedValue\n}\n"],"names":["useDebounce","value","delay","debouncedValue","setDebouncedValue","useState","useEffect","timer"],"mappings":";AAmBO,SAASA,EAAeC,GAAUC,IAAQ,KAAQ;AACvD,QAAM,CAACC,GAAgBC,CAAiB,IAAIC,EAAYJ,CAAK;AAE7D,SAAAK,EAAU,MAAM;AACd,UAAMC,IAAQ,WAAW,MAAM;AAC7B,MAAAH,EAAkBH,CAAK;AAAA,IACzB,GAAGC,CAAK;AAER,WAAO,MAAM;AACX,mBAAaK,CAAK;AAAA,IACpB;AAAA,EACF,GAAG,CAACN,GAAOC,CAAK,CAAC,GAEVC;AACT;"}
package/dist/index105.js CHANGED
@@ -1,11 +1,18 @@
1
- import { useRef as t, useEffect as o } from "react";
2
- function f(r) {
3
- const e = t(void 0);
4
- return o(() => {
5
- e.current = r;
6
- }, [r]), e.current;
1
+ import { useRef as s, useEffect as c } from "react";
2
+ function m(t, n = !0) {
3
+ const r = s(null);
4
+ return c(() => {
5
+ if (!n) return;
6
+ const e = (o) => {
7
+ const u = r.current;
8
+ !u || u.contains(o.target) || t(o);
9
+ };
10
+ return document.addEventListener("mousedown", e), document.addEventListener("touchstart", e), () => {
11
+ document.removeEventListener("mousedown", e), document.removeEventListener("touchstart", e);
12
+ };
13
+ }, [t, n]), r;
7
14
  }
8
15
  export {
9
- f as usePrevious
16
+ m as useClickOutside
10
17
  };
11
18
  //# sourceMappingURL=index105.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index105.js","sources":["../src/hooks/usePrevious.ts"],"sourcesContent":["import { useRef, useEffect } from 'react'\n\n/**\n * Hook that returns the previous value of a variable.\n * Useful for comparing current and previous values in effects.\n *\n * @param value - Current value\n * @returns Previous value (undefined on first render)\n *\n * @example\n * const [count, setCount] = useState(0)\n * const prevCount = usePrevious(count)\n *\n * // prevCount is the value from previous render\n * console.log(`Changed from ${prevCount} to ${count}`)\n */\nexport function usePrevious<T>(value: T): T | undefined {\n const ref = useRef<T | undefined>(undefined)\n\n useEffect(() => {\n ref.current = value\n }, [value])\n\n return ref.current\n}\n"],"names":["usePrevious","value","ref","useRef","useEffect"],"mappings":";AAgBO,SAASA,EAAeC,GAAyB;AACtD,QAAMC,IAAMC,EAAsB,MAAS;AAE3C,SAAAC,EAAU,MAAM;AACd,IAAAF,EAAI,UAAUD;AAAA,EAChB,GAAG,CAACA,CAAK,CAAC,GAEHC,EAAI;AACb;"}
1
+ {"version":3,"file":"index105.js","sources":["../src/hooks/useClickOutside.ts"],"sourcesContent":["import { useEffect, useRef, type RefObject } from 'react'\n\n/**\n * Hook that detects clicks outside of a referenced element.\n * Useful for closing dropdowns, modals, or menus.\n *\n * @param handler - Callback when click outside is detected\n * @param enabled - Whether the listener is active (default: true)\n * @returns Ref to attach to the element\n *\n * @example\n * const ref = useClickOutside(() => setIsOpen(false))\n *\n * <div ref={ref}>\n * <Dropdown>...</Dropdown>\n * </div>\n */\nexport function useClickOutside<T extends HTMLElement = HTMLElement>(\n handler: (event: MouseEvent | TouchEvent) => void,\n enabled = true\n): RefObject<T | null> {\n const ref = useRef<T>(null)\n\n useEffect(() => {\n if (!enabled) return\n\n const listener = (event: MouseEvent | TouchEvent) => {\n const el = ref.current\n if (!el || el.contains(event.target as Node)) {\n return\n }\n handler(event)\n }\n\n document.addEventListener('mousedown', listener)\n document.addEventListener('touchstart', listener)\n\n return () => {\n document.removeEventListener('mousedown', listener)\n document.removeEventListener('touchstart', listener)\n }\n }, [handler, enabled])\n\n return ref\n}\n"],"names":["useClickOutside","handler","enabled","ref","useRef","useEffect","listener","event","el"],"mappings":";AAiBO,SAASA,EACdC,GACAC,IAAU,IACW;AACrB,QAAMC,IAAMC,EAAU,IAAI;AAE1B,SAAAC,EAAU,MAAM;AACd,QAAI,CAACH,EAAS;AAEd,UAAMI,IAAW,CAACC,MAAmC;AACnD,YAAMC,IAAKL,EAAI;AACf,MAAI,CAACK,KAAMA,EAAG,SAASD,EAAM,MAAc,KAG3CN,EAAQM,CAAK;AAAA,IACf;AAEA,oBAAS,iBAAiB,aAAaD,CAAQ,GAC/C,SAAS,iBAAiB,cAAcA,CAAQ,GAEzC,MAAM;AACX,eAAS,oBAAoB,aAAaA,CAAQ,GAClD,SAAS,oBAAoB,cAAcA,CAAQ;AAAA,IACrD;AAAA,EACF,GAAG,CAACL,GAASC,CAAO,CAAC,GAEdC;AACT;"}
package/dist/index106.js CHANGED
@@ -1,16 +1,11 @@
1
- import { useState as u, useRef as v, useEffect as a } from "react";
2
- function f() {
3
- const [o, t] = u(!1), n = v(null);
4
- return a(() => {
5
- const e = n.current;
6
- if (!e) return;
7
- const r = () => t(!0), s = () => t(!1);
8
- return e.addEventListener("mouseenter", r), e.addEventListener("mouseleave", s), () => {
9
- e.removeEventListener("mouseenter", r), e.removeEventListener("mouseleave", s);
10
- };
11
- }, []), { ref: n, isHovered: o };
1
+ import { useRef as t, useEffect as o } from "react";
2
+ function f(r) {
3
+ const e = t(void 0);
4
+ return o(() => {
5
+ e.current = r;
6
+ }, [r]), e.current;
12
7
  }
13
8
  export {
14
- f as useHover
9
+ f as usePrevious
15
10
  };
16
11
  //# sourceMappingURL=index106.js.map