asterui 0.12.10 → 0.12.12

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 (85) hide show
  1. package/dist/components/Anchor.d.ts +10 -0
  2. package/dist/components/Breadcrumb.d.ts +20 -3
  3. package/dist/components/ContextMenu.d.ts +39 -3
  4. package/dist/components/Menu.d.ts +29 -4
  5. package/dist/components/Space.d.ts +1 -0
  6. package/dist/components/Splitter.d.ts +2 -0
  7. package/dist/index.d.ts +2 -4
  8. package/dist/index.js +63 -65
  9. package/dist/index.js.map +1 -1
  10. package/dist/index100.js +11 -44
  11. package/dist/index100.js.map +1 -1
  12. package/dist/index101.js +12 -10
  13. package/dist/index101.js.map +1 -1
  14. package/dist/index102.js +7 -14
  15. package/dist/index102.js.map +1 -1
  16. package/dist/index103.js +12 -7
  17. package/dist/index103.js.map +1 -1
  18. package/dist/index104.js +29 -11
  19. package/dist/index104.js.map +1 -1
  20. package/dist/index105.js +16 -29
  21. package/dist/index105.js.map +1 -1
  22. package/dist/index19.js +161 -63
  23. package/dist/index19.js.map +1 -1
  24. package/dist/index3.js +81 -65
  25. package/dist/index3.js.map +1 -1
  26. package/dist/index51.js +110 -104
  27. package/dist/index51.js.map +1 -1
  28. package/dist/index74.js +37 -25
  29. package/dist/index74.js.map +1 -1
  30. package/dist/index75.js +223 -103
  31. package/dist/index75.js.map +1 -1
  32. package/dist/index76.js +21 -51
  33. package/dist/index76.js.map +1 -1
  34. package/dist/index77.js +31 -22
  35. package/dist/index77.js.map +1 -1
  36. package/dist/index78.js +22 -31
  37. package/dist/index78.js.map +1 -1
  38. package/dist/index79.js +327 -20
  39. package/dist/index79.js.map +1 -1
  40. package/dist/index8.js +32 -8
  41. package/dist/index8.js.map +1 -1
  42. package/dist/index80.js +50 -323
  43. package/dist/index80.js.map +1 -1
  44. package/dist/index81.js +40 -56
  45. package/dist/index81.js.map +1 -1
  46. package/dist/index82.js +23 -40
  47. package/dist/index82.js.map +1 -1
  48. package/dist/index83.js +93 -21
  49. package/dist/index83.js.map +1 -1
  50. package/dist/index84.js +148 -87
  51. package/dist/index84.js.map +1 -1
  52. package/dist/index85.js +152 -147
  53. package/dist/index85.js.map +1 -1
  54. package/dist/index86.js +63 -159
  55. package/dist/index86.js.map +1 -1
  56. package/dist/index87.js +35 -65
  57. package/dist/index87.js.map +1 -1
  58. package/dist/index88.js +234 -35
  59. package/dist/index88.js.map +1 -1
  60. package/dist/index89.js +31 -231
  61. package/dist/index89.js.map +1 -1
  62. package/dist/index90.js +210 -34
  63. package/dist/index90.js.map +1 -1
  64. package/dist/index91.js +198 -195
  65. package/dist/index91.js.map +1 -1
  66. package/dist/index92.js +241 -159
  67. package/dist/index92.js.map +1 -1
  68. package/dist/index93.js +166 -283
  69. package/dist/index93.js.map +1 -1
  70. package/dist/index94.js +253 -173
  71. package/dist/index94.js.map +1 -1
  72. package/dist/index95.js +14 -258
  73. package/dist/index95.js.map +1 -1
  74. package/dist/index96.js +31 -12
  75. package/dist/index96.js.map +1 -1
  76. package/dist/index97.js +5 -32
  77. package/dist/index97.js.map +1 -1
  78. package/dist/index98.js +13 -5
  79. package/dist/index98.js.map +1 -1
  80. package/dist/index99.js +43 -11
  81. package/dist/index99.js.map +1 -1
  82. package/package.json +1 -1
  83. package/dist/components/Stack.d.ts +0 -10
  84. package/dist/index106.js +0 -21
  85. package/dist/index106.js.map +0 -1
@@ -14,8 +14,12 @@ export interface AnchorProps {
14
14
  direction?: 'horizontal' | 'vertical';
15
15
  /** Offset from top when calculating scroll position */
16
16
  offsetTop?: number;
17
+ /** Bounding distance of anchor area */
18
+ bounds?: number;
17
19
  /** Target scroll container (default: window) */
18
20
  getContainer?: () => HTMLElement | Window;
21
+ /** Customize the anchor highlight */
22
+ getCurrentAnchor?: (activeLink: string) => string;
19
23
  /** Callback when active link changes */
20
24
  onChange?: (activeLink: string) => void;
21
25
  /** Callback when link is clicked */
@@ -25,6 +29,12 @@ export interface AnchorProps {
25
29
  }) => void;
26
30
  /** Currently active link (controlled) */
27
31
  activeLink?: string;
32
+ /** Whether to fix the anchor when scrolling */
33
+ affix?: boolean;
34
+ /** Pixels to offset from top when affix is true */
35
+ affixOffsetTop?: number;
36
+ /** Replace history instead of push */
37
+ replace?: boolean;
28
38
  /** Custom class name */
29
39
  className?: string;
30
40
  /** Anchor.Link children */
@@ -1,14 +1,31 @@
1
1
  import { default as React } from 'react';
2
+ export interface BreadcrumbItemType {
3
+ /** Item title/label */
4
+ title: React.ReactNode;
5
+ /** Link URL */
6
+ href?: string;
7
+ /** Click handler */
8
+ onClick?: () => void;
9
+ /** Custom class name */
10
+ className?: string;
11
+ }
2
12
  export interface BreadcrumbProps extends React.HTMLAttributes<HTMLDivElement> {
3
- children: React.ReactNode;
13
+ /** Breadcrumb.Item children (compound pattern) */
14
+ children?: React.ReactNode;
15
+ /** Breadcrumb items data (data-driven pattern) */
16
+ items?: BreadcrumbItemType[];
17
+ /** Custom separator between items */
18
+ separator?: React.ReactNode;
4
19
  }
5
20
  export interface BreadcrumbItemProps extends Omit<React.LiHTMLAttributes<HTMLLIElement>, 'onClick'> {
6
21
  children: React.ReactNode;
7
22
  href?: string;
8
23
  onClick?: () => void;
24
+ /** Icon to display before the label */
25
+ icon?: React.ReactNode;
9
26
  }
10
- declare function BreadcrumbRoot({ children, className, ...rest }: BreadcrumbProps): import("react/jsx-runtime").JSX.Element;
11
- declare function BreadcrumbItem({ children, href, onClick, className, ...rest }: BreadcrumbItemProps): import("react/jsx-runtime").JSX.Element;
27
+ declare function BreadcrumbRoot({ children, items, separator, className, ...rest }: BreadcrumbProps): import("react/jsx-runtime").JSX.Element;
28
+ declare function BreadcrumbItem({ children, href, onClick, icon, className, ...rest }: BreadcrumbItemProps): import("react/jsx-runtime").JSX.Element;
12
29
  export declare const Breadcrumb: typeof BreadcrumbRoot & {
13
30
  Item: typeof BreadcrumbItem;
14
31
  };
@@ -11,8 +11,8 @@ export interface ContextMenuItem {
11
11
  export interface ContextMenuProps {
12
12
  /** Element that triggers the context menu on right-click */
13
13
  children: React.ReactNode;
14
- /** Menu items */
15
- items: ContextMenuItem[];
14
+ /** Menu items (data-driven pattern) */
15
+ items?: ContextMenuItem[];
16
16
  /** Callback when an item is selected */
17
17
  onSelect?: (key: string) => void;
18
18
  /** Whether the context menu is disabled */
@@ -20,4 +20,40 @@ export interface ContextMenuProps {
20
20
  /** Additional CSS classes for the menu */
21
21
  className?: string;
22
22
  }
23
- export declare const ContextMenu: React.FC<ContextMenuProps>;
23
+ export interface ContextMenuItemProps {
24
+ /** Unique key for the item */
25
+ itemKey: string;
26
+ /** Item content */
27
+ children: React.ReactNode;
28
+ /** Icon to display before label */
29
+ icon?: React.ReactNode;
30
+ /** Whether the item is disabled */
31
+ disabled?: boolean;
32
+ /** Show as danger/destructive action */
33
+ danger?: boolean;
34
+ /** Additional CSS classes */
35
+ className?: string;
36
+ }
37
+ export interface ContextMenuDividerProps {
38
+ /** Additional CSS classes */
39
+ className?: string;
40
+ }
41
+ export interface ContextMenuSubMenuProps {
42
+ /** Unique key for the submenu */
43
+ itemKey: string;
44
+ /** Submenu label */
45
+ label: React.ReactNode;
46
+ /** Icon to display before label */
47
+ icon?: React.ReactNode;
48
+ /** Whether the submenu is disabled */
49
+ disabled?: boolean;
50
+ /** Submenu items */
51
+ children: React.ReactNode;
52
+ /** Additional CSS classes */
53
+ className?: string;
54
+ }
55
+ export declare const ContextMenu: React.FC<ContextMenuProps> & {
56
+ Item: React.FC<ContextMenuItemProps>;
57
+ Divider: React.FC<ContextMenuDividerProps>;
58
+ SubMenu: React.FC<ContextMenuSubMenuProps>;
59
+ };
@@ -1,13 +1,35 @@
1
1
  import { default as React } from 'react';
2
2
  export type MenuMode = 'vertical' | 'horizontal' | 'inline';
3
+ export type MenuSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
4
+ export interface MenuItem {
5
+ key: string;
6
+ label: React.ReactNode;
7
+ icon?: React.ReactNode;
8
+ disabled?: boolean;
9
+ children?: MenuItem[];
10
+ divider?: boolean;
11
+ title?: boolean;
12
+ }
3
13
  export interface MenuProps extends Omit<React.HTMLAttributes<HTMLUListElement>, 'onSelect'> {
4
- children: React.ReactNode;
14
+ /** Menu items (compound pattern) */
15
+ children?: React.ReactNode;
16
+ /** Menu items (data-driven pattern) */
17
+ items?: MenuItem[];
18
+ /** Menu display mode */
5
19
  mode?: MenuMode;
20
+ /** Menu size */
21
+ size?: MenuSize;
22
+ /** Controlled selected keys */
6
23
  selectedKeys?: string[];
24
+ /** Default selected keys (uncontrolled) */
7
25
  defaultSelectedKeys?: string[];
26
+ /** Controlled open submenu keys */
8
27
  openKeys?: string[];
28
+ /** Default open submenu keys (uncontrolled) */
9
29
  defaultOpenKeys?: string[];
30
+ /** Callback when item is selected */
10
31
  onSelect?: (key: string) => void;
32
+ /** Callback when submenu open state changes */
11
33
  onOpenChange?: (openKeys: string[]) => void;
12
34
  }
13
35
  export interface MenuItemProps extends Omit<React.HTMLAttributes<HTMLAnchorElement>, 'onClick'> {
@@ -22,7 +44,10 @@ export interface MenuItemProps extends Omit<React.HTMLAttributes<HTMLAnchorEleme
22
44
  export interface MenuSubMenuProps extends React.HTMLAttributes<HTMLLIElement> {
23
45
  children: React.ReactNode;
24
46
  itemKey: string;
25
- label: React.ReactNode;
47
+ /** Submenu label */
48
+ label?: React.ReactNode;
49
+ /** Submenu title (alias for label) */
50
+ title?: React.ReactNode;
26
51
  icon?: React.ReactNode;
27
52
  disabled?: boolean;
28
53
  }
@@ -31,9 +56,9 @@ export interface MenuTitleProps extends React.HTMLAttributes<HTMLLIElement> {
31
56
  }
32
57
  export interface MenuDividerProps extends React.HTMLAttributes<HTMLLIElement> {
33
58
  }
34
- declare function MenuRoot({ children, mode, selectedKeys: controlledSelectedKeys, defaultSelectedKeys, openKeys: controlledOpenKeys, defaultOpenKeys, onSelect, onOpenChange, className, ...rest }: MenuProps): import("react/jsx-runtime").JSX.Element;
59
+ declare function MenuRoot({ children, items, mode, size, selectedKeys: controlledSelectedKeys, defaultSelectedKeys, openKeys: controlledOpenKeys, defaultOpenKeys, onSelect, onOpenChange, className, ...rest }: MenuProps): import("react/jsx-runtime").JSX.Element;
35
60
  declare function MenuItem({ children, itemKey, icon, disabled, onClick, active, className, ...rest }: MenuItemProps): import("react/jsx-runtime").JSX.Element;
36
- declare function MenuSubMenu({ children, itemKey, label, icon, disabled, className, ...rest }: MenuSubMenuProps): import("react/jsx-runtime").JSX.Element;
61
+ declare function MenuSubMenu({ children, itemKey, label, title, icon, disabled, className, ...rest }: MenuSubMenuProps): import("react/jsx-runtime").JSX.Element;
37
62
  declare function MenuTitle({ children, className, ...rest }: MenuTitleProps): import("react/jsx-runtime").JSX.Element;
38
63
  declare function MenuDivider({ className, ...rest }: MenuDividerProps): import("react/jsx-runtime").JSX.Element;
39
64
  export declare const Menu: typeof MenuRoot & {
@@ -5,6 +5,7 @@ export interface SpaceProps extends React.HTMLAttributes<HTMLDivElement> {
5
5
  align?: 'start' | 'end' | 'center' | 'baseline' | 'stretch';
6
6
  justify?: 'start' | 'end' | 'center' | 'between' | 'around' | 'evenly';
7
7
  wrap?: boolean;
8
+ split?: React.ReactNode;
8
9
  children: React.ReactNode;
9
10
  }
10
11
  export declare const Space: React.FC<SpaceProps>;
@@ -7,7 +7,9 @@ export interface SplitterPanelProps {
7
7
  maxSize?: number;
8
8
  collapsible?: boolean;
9
9
  collapsed?: boolean;
10
+ defaultCollapsed?: boolean;
10
11
  onCollapse?: (collapsed: boolean) => void;
12
+ resizable?: boolean;
11
13
  className?: string;
12
14
  }
13
15
  export interface SplitterProps {
package/dist/index.d.ts CHANGED
@@ -33,7 +33,7 @@ export type { CollapseProps, CollapseTitleProps, CollapseContentProps } from './
33
33
  export { Container } from './components/Container';
34
34
  export type { ContainerProps } from './components/Container';
35
35
  export { ContextMenu } from './components/ContextMenu';
36
- export type { ContextMenuProps, ContextMenuItem } from './components/ContextMenu';
36
+ export type { ContextMenuProps, ContextMenuItem, ContextMenuItemProps, ContextMenuDividerProps, ContextMenuSubMenuProps } from './components/ContextMenu';
37
37
  export { Countdown } from './components/Countdown';
38
38
  export type { CountdownProps } from './components/Countdown';
39
39
  export { DatePicker } from './components/DatePicker';
@@ -97,7 +97,7 @@ export type { MasonryProps } from './components/Masonry';
97
97
  export { Mention } from './components/Mention';
98
98
  export type { MentionProps, MentionOption } from './components/Mention';
99
99
  export { Menu } from './components/Menu';
100
- export type { MenuProps, MenuItemProps, MenuSubMenuProps, MenuTitleProps, MenuDividerProps, MenuMode } from './components/Menu';
100
+ export type { MenuProps, MenuItem, MenuItemProps, MenuSubMenuProps, MenuTitleProps, MenuDividerProps, MenuMode, MenuSize } from './components/Menu';
101
101
  export { Browser } from './components/Browser';
102
102
  export type { BrowserProps } from './components/Browser';
103
103
  export { Code } from './components/Code';
@@ -146,8 +146,6 @@ export { Space } from './components/Space';
146
146
  export type { SpaceProps } from './components/Space';
147
147
  export { Splitter } from './components/Splitter';
148
148
  export type { SplitterProps, SplitterPanelProps } from './components/Splitter';
149
- export { Stack } from './components/Stack';
150
- export type { StackProps } from './components/Stack';
151
149
  export { Stats } from './components/Stat';
152
150
  export type { StatsProps, StatProps } from './components/Stat';
153
151
  export { Status } from './components/Status';
package/dist/index.js CHANGED
@@ -72,37 +72,36 @@ import { Segmented as Wr } from "./index72.js";
72
72
  import { Skeleton as Er } from "./index73.js";
73
73
  import { Space as Qr } from "./index74.js";
74
74
  import { Splitter as jr } from "./index75.js";
75
- import { Stack as Vr } from "./index76.js";
76
- import { Stats as Yr } from "./index77.js";
77
- import { Status as _r } from "./index78.js";
78
- import { Steps as oe } from "./index79.js";
79
- import { Table as ee } from "./index80.js";
80
- import { Tabs as pe } from "./index81.js";
81
- import { Textarea as fe } from "./index82.js";
82
- import { TextRotate as ae } from "./index83.js";
83
- import { CheckableTag as ne, Tag as se } from "./index84.js";
84
- import { ThemeController as le } from "./index85.js";
85
- import { TimePicker as ce } from "./index86.js";
86
- import { Timeline as Te } from "./index87.js";
87
- import { Toggle as Pe } from "./index88.js";
88
- import { Tour as be } from "./index89.js";
89
- import { Tooltip as he } from "./index90.js";
90
- import { Transfer as we } from "./index91.js";
91
- import { Tree as Fe } from "./index92.js";
92
- import { TreeSelect as ve } from "./index93.js";
93
- import { Typography as Ae } from "./index94.js";
94
- import { Upload as Le } from "./index95.js";
95
- import { Hide as He, Show as Ke } from "./index96.js";
96
- import { useBreakpoint as Ne } from "./index97.js";
97
- import { useDisclosure as We } from "./index98.js";
98
- import { useClipboard as Ee } from "./index99.js";
99
- import { useLocalStorage as Qe } from "./index100.js";
100
- import { useDebounce as je } from "./index101.js";
101
- import { useClickOutside as Ve } from "./index102.js";
102
- import { usePrevious as Ye } from "./index103.js";
103
- import { useHover as _e } from "./index104.js";
104
- import { useKeyPress as ot, useKeyPressCallback as rt } from "./index105.js";
105
- import { useWindowSize as tt } from "./index106.js";
75
+ import { Stats as Vr } from "./index76.js";
76
+ import { Status as Yr } from "./index77.js";
77
+ import { Steps as _r } from "./index78.js";
78
+ import { Table as oe } from "./index79.js";
79
+ import { Tabs as ee } from "./index80.js";
80
+ import { Textarea as pe } from "./index81.js";
81
+ import { TextRotate as fe } from "./index82.js";
82
+ import { CheckableTag as ae, Tag as ie } from "./index83.js";
83
+ import { ThemeController as se } from "./index84.js";
84
+ import { TimePicker as le } from "./index85.js";
85
+ import { Timeline as ce } from "./index86.js";
86
+ import { Toggle as Te } from "./index87.js";
87
+ import { Tour as Pe } from "./index88.js";
88
+ import { Tooltip as be } from "./index89.js";
89
+ import { Transfer as he } from "./index90.js";
90
+ import { Tree as we } from "./index91.js";
91
+ import { TreeSelect as Fe } from "./index92.js";
92
+ import { Typography as ve } from "./index93.js";
93
+ import { Upload as Ae } from "./index94.js";
94
+ import { Hide as Le, Show as Me } from "./index95.js";
95
+ import { useBreakpoint as Ke } from "./index96.js";
96
+ import { useDisclosure as Ne } from "./index97.js";
97
+ import { useClipboard as We } from "./index98.js";
98
+ import { useLocalStorage as Ee } from "./index99.js";
99
+ import { useDebounce as Qe } from "./index100.js";
100
+ import { useClickOutside as je } from "./index101.js";
101
+ import { usePrevious as Ve } from "./index102.js";
102
+ import { useHover as Ye } from "./index103.js";
103
+ import { useKeyPress as _e, useKeyPressCallback as $e } from "./index104.js";
104
+ import { useWindowSize as rt } from "./index105.js";
106
105
  export {
107
106
  e as Affix,
108
107
  f as Alert,
@@ -119,7 +118,7 @@ export {
119
118
  F as Cascader,
120
119
  v as Chart,
121
120
  b as Chat,
122
- ne as CheckableTag,
121
+ ae as CheckableTag,
123
122
  P as Checkbox,
124
123
  er as Code,
125
124
  co as Col,
@@ -145,7 +144,7 @@ export {
145
144
  so as Form,
146
145
  Co as Grid,
147
146
  Po as Hero,
148
- He as Hide,
147
+ Le as Hide,
149
148
  bo as Image,
150
149
  ho as Indicator,
151
150
  vo as Input,
@@ -178,44 +177,43 @@ export {
178
177
  To as Row,
179
178
  Wr as Segmented,
180
179
  Nr as Select,
181
- Ke as Show,
180
+ Me as Show,
182
181
  Er as Skeleton,
183
182
  Qr as Space,
184
183
  jr as Splitter,
185
- Vr as Stack,
186
- Yr as Stats,
187
- _r as Status,
188
- oe as Steps,
189
- ee as Table,
190
- pe as Tabs,
191
- se as Tag,
192
- ae as TextRotate,
193
- fe as Textarea,
194
- le as ThemeController,
195
- ce as TimePicker,
196
- Te as Timeline,
197
- Pe as Toggle,
198
- he as Tooltip,
199
- be as Tour,
200
- we as Transfer,
201
- Fe as Tree,
202
- ve as TreeSelect,
203
- Ae as Typography,
204
- Le as Upload,
184
+ Vr as Stats,
185
+ Yr as Status,
186
+ _r as Steps,
187
+ oe as Table,
188
+ ee as Tabs,
189
+ ie as Tag,
190
+ fe as TextRotate,
191
+ pe as Textarea,
192
+ se as ThemeController,
193
+ le as TimePicker,
194
+ ce as Timeline,
195
+ Te as Toggle,
196
+ be as Tooltip,
197
+ Pe as Tour,
198
+ he as Transfer,
199
+ we as Tree,
200
+ Fe as TreeSelect,
201
+ ve as Typography,
202
+ Ae as Upload,
205
203
  fr as Window,
206
204
  ur as notification,
207
- Ne as useBreakpoint,
208
- Ve as useClickOutside,
209
- Ee as useClipboard,
210
- je as useDebounce,
211
- We as useDisclosure,
205
+ Ke as useBreakpoint,
206
+ je as useClickOutside,
207
+ We as useClipboard,
208
+ Qe as useDebounce,
209
+ Ne as useDisclosure,
212
210
  uo as useFormInstance,
213
- _e as useHover,
214
- ot as useKeyPress,
215
- rt as useKeyPressCallback,
216
- Qe as useLocalStorage,
217
- Ye as usePrevious,
211
+ Ye as useHover,
212
+ _e as useKeyPress,
213
+ $e as useKeyPressCallback,
214
+ Ee as useLocalStorage,
215
+ Ve as usePrevious,
218
216
  Wo as useSiderContext,
219
- tt as useWindowSize
217
+ rt as useWindowSize
220
218
  };
221
219
  //# 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/index100.js CHANGED
@@ -1,49 +1,16 @@
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
- }
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);
42
10
  };
43
- return window.addEventListener("storage", e), () => window.removeEventListener("storage", e);
44
- }, [o]), [s, d, w];
11
+ }, [e, t]), o;
45
12
  }
46
13
  export {
47
- S as useLocalStorage
14
+ i as useDebounce
48
15
  };
49
16
  //# sourceMappingURL=index100.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index100.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":"index100.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/index101.js CHANGED
@@ -1,16 +1,18 @@
1
- import { useState as r, useEffect as c } from "react";
2
- function i(e, t = 300) {
3
- const [o, u] = r(e);
1
+ import { useRef as s, useEffect as c } from "react";
2
+ function m(t, n = !0) {
3
+ const r = s(null);
4
4
  return c(() => {
5
- const n = setTimeout(() => {
6
- u(e);
7
- }, t);
8
- return () => {
9
- clearTimeout(n);
5
+ if (!n) return;
6
+ const e = (o) => {
7
+ const u = r.current;
8
+ !u || u.contains(o.target) || t(o);
10
9
  };
11
- }, [e, t]), o;
10
+ return document.addEventListener("mousedown", e), document.addEventListener("touchstart", e), () => {
11
+ document.removeEventListener("mousedown", e), document.removeEventListener("touchstart", e);
12
+ };
13
+ }, [t, n]), r;
12
14
  }
13
15
  export {
14
- i as useDebounce
16
+ m as useClickOutside
15
17
  };
16
18
  //# sourceMappingURL=index101.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index101.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":"index101.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/index102.js CHANGED
@@ -1,18 +1,11 @@
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;
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;
14
7
  }
15
8
  export {
16
- m as useClickOutside
9
+ f as usePrevious
17
10
  };
18
11
  //# sourceMappingURL=index102.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index102.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":"index102.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;"}
package/dist/index103.js CHANGED
@@ -1,11 +1,16 @@
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 { 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 };
7
12
  }
8
13
  export {
9
- f as usePrevious
14
+ f as useHover
10
15
  };
11
16
  //# sourceMappingURL=index103.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index103.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":"index103.js","sources":["../src/hooks/useHover.ts"],"sourcesContent":["import { useState, useRef, useEffect, type RefObject } from 'react'\n\nexport interface UseHoverReturn<T extends HTMLElement> {\n ref: RefObject<T | null>\n isHovered: boolean\n}\n\n/**\n * Hook that tracks hover state of an element.\n *\n * @returns Object with ref and isHovered state\n *\n * @example\n * const { ref, isHovered } = useHover<HTMLDivElement>()\n *\n * <div ref={ref} className={isHovered ? 'bg-blue-500' : 'bg-gray-500'}>\n * Hover me!\n * </div>\n */\nexport function useHover<T extends HTMLElement = HTMLElement>(): UseHoverReturn<T> {\n const [isHovered, setIsHovered] = useState(false)\n const ref = useRef<T>(null)\n\n useEffect(() => {\n const node = ref.current\n if (!node) return\n\n const handleMouseEnter = () => setIsHovered(true)\n const handleMouseLeave = () => setIsHovered(false)\n\n node.addEventListener('mouseenter', handleMouseEnter)\n node.addEventListener('mouseleave', handleMouseLeave)\n\n return () => {\n node.removeEventListener('mouseenter', handleMouseEnter)\n node.removeEventListener('mouseleave', handleMouseLeave)\n }\n }, [])\n\n return { ref, isHovered }\n}\n"],"names":["useHover","isHovered","setIsHovered","useState","ref","useRef","useEffect","node","handleMouseEnter","handleMouseLeave"],"mappings":";AAmBO,SAASA,IAAmE;AACjF,QAAM,CAACC,GAAWC,CAAY,IAAIC,EAAS,EAAK,GAC1CC,IAAMC,EAAU,IAAI;AAE1B,SAAAC,EAAU,MAAM;AACd,UAAMC,IAAOH,EAAI;AACjB,QAAI,CAACG,EAAM;AAEX,UAAMC,IAAmB,MAAMN,EAAa,EAAI,GAC1CO,IAAmB,MAAMP,EAAa,EAAK;AAEjD,WAAAK,EAAK,iBAAiB,cAAcC,CAAgB,GACpDD,EAAK,iBAAiB,cAAcE,CAAgB,GAE7C,MAAM;AACX,MAAAF,EAAK,oBAAoB,cAAcC,CAAgB,GACvDD,EAAK,oBAAoB,cAAcE,CAAgB;AAAA,IACzD;AAAA,EACF,GAAG,CAAA,CAAE,GAEE,EAAE,KAAAL,GAAK,WAAAH,EAAA;AAChB;"}