asterui 0.12.17 → 0.12.19
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/Card.d.ts +14 -2
- package/dist/components/Select.d.ts +8 -0
- package/dist/components/Watermark.d.ts +40 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +34 -32
- package/dist/index.js.map +1 -1
- package/dist/index100.js +11 -43
- package/dist/index100.js.map +1 -1
- package/dist/index101.js +44 -11
- package/dist/index101.js.map +1 -1
- package/dist/index102.js +10 -12
- package/dist/index102.js.map +1 -1
- package/dist/index103.js +14 -7
- package/dist/index103.js.map +1 -1
- package/dist/index104.js +7 -12
- package/dist/index104.js.map +1 -1
- package/dist/index105.js +11 -29
- package/dist/index105.js.map +1 -1
- package/dist/index106.js +29 -16
- package/dist/index106.js.map +1 -1
- package/dist/index107.js +21 -0
- package/dist/index107.js.map +1 -0
- package/dist/index13.js +86 -68
- package/dist/index13.js.map +1 -1
- package/dist/index72.js +55 -22
- package/dist/index72.js.map +1 -1
- package/dist/index96.js +126 -14
- package/dist/index96.js.map +1 -1
- package/dist/index97.js +12 -31
- package/dist/index97.js.map +1 -1
- package/dist/index98.js +32 -5
- package/dist/index98.js.map +1 -1
- package/dist/index99.js +5 -13
- package/dist/index99.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
export interface CardProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'title'> {
|
|
3
|
-
children
|
|
3
|
+
children?: React.ReactNode;
|
|
4
4
|
title?: React.ReactNode;
|
|
5
|
+
/** Content in the top-right corner of the card header */
|
|
6
|
+
extra?: React.ReactNode;
|
|
5
7
|
cover?: React.ReactNode;
|
|
6
8
|
actions?: React.ReactNode;
|
|
7
9
|
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
@@ -14,13 +16,23 @@ export interface CardProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 't
|
|
|
14
16
|
avatar?: React.ReactNode;
|
|
15
17
|
description?: React.ReactNode;
|
|
16
18
|
}
|
|
19
|
+
export interface CardMetaProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'title'> {
|
|
20
|
+
/** Avatar or icon element */
|
|
21
|
+
avatar?: React.ReactNode;
|
|
22
|
+
/** Title content */
|
|
23
|
+
title?: React.ReactNode;
|
|
24
|
+
/** Description content */
|
|
25
|
+
description?: React.ReactNode;
|
|
26
|
+
}
|
|
17
27
|
export interface CardGridProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
18
28
|
children: React.ReactNode;
|
|
19
29
|
hoverable?: boolean;
|
|
20
30
|
}
|
|
21
31
|
declare function CardGrid({ children, hoverable, className, style, ...rest }: CardGridProps): import("react/jsx-runtime").JSX.Element;
|
|
22
|
-
declare function
|
|
32
|
+
declare function CardMeta({ avatar, title, description, className, ...rest }: CardMetaProps): import("react/jsx-runtime").JSX.Element;
|
|
33
|
+
declare function CardRoot({ children, title, extra, cover, actions, className, style, size, bordered, side, imageFull, actionsJustify, loading, hoverable, avatar, description, ...rest }: CardProps): import("react/jsx-runtime").JSX.Element;
|
|
23
34
|
export declare const Card: typeof CardRoot & {
|
|
24
35
|
Grid: typeof CardGrid;
|
|
36
|
+
Meta: typeof CardMeta;
|
|
25
37
|
};
|
|
26
38
|
export default Card;
|
|
@@ -2,8 +2,16 @@ import { default as React } from 'react';
|
|
|
2
2
|
export interface SelectProps extends Omit<React.SelectHTMLAttributes<HTMLSelectElement>, 'size'> {
|
|
3
3
|
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
4
4
|
color?: 'neutral' | 'primary' | 'secondary' | 'accent' | 'info' | 'success' | 'warning' | 'error';
|
|
5
|
+
/** Validation status */
|
|
6
|
+
status?: 'error' | 'warning';
|
|
5
7
|
ghost?: boolean;
|
|
6
8
|
bordered?: boolean;
|
|
9
|
+
/** Floating label text (uses DaisyUI floating-label) */
|
|
10
|
+
floatingLabel?: string;
|
|
11
|
+
/** Text/element before select (outside, using DaisyUI label) */
|
|
12
|
+
addonBefore?: React.ReactNode;
|
|
13
|
+
/** Text/element after select (outside, using DaisyUI label) */
|
|
14
|
+
addonAfter?: React.ReactNode;
|
|
7
15
|
className?: string;
|
|
8
16
|
children?: React.ReactNode;
|
|
9
17
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export type WatermarkGap = [number, number];
|
|
3
|
+
export type WatermarkOffset = [number, number];
|
|
4
|
+
export interface WatermarkFontOptions {
|
|
5
|
+
/** Text color for watermark content */
|
|
6
|
+
color?: string;
|
|
7
|
+
/** Font size in pixels */
|
|
8
|
+
fontSize?: number;
|
|
9
|
+
/** Font weight for watermark text */
|
|
10
|
+
fontWeight?: number | 'normal' | 'bold' | 'bolder' | 'lighter';
|
|
11
|
+
/** Font style for watermark text */
|
|
12
|
+
fontStyle?: 'normal' | 'italic' | 'oblique';
|
|
13
|
+
/** Font family for watermark text */
|
|
14
|
+
fontFamily?: string;
|
|
15
|
+
/** Line height in pixels for multi-line content */
|
|
16
|
+
lineHeight?: number;
|
|
17
|
+
}
|
|
18
|
+
export interface WatermarkProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'content'> {
|
|
19
|
+
/** Text to render inside the watermark; falls back to "asterui" */
|
|
20
|
+
content?: string | string[];
|
|
21
|
+
/** Image source (URL or base64) to render instead of text */
|
|
22
|
+
image?: string;
|
|
23
|
+
/** Width of a single watermark tile in pixels */
|
|
24
|
+
width?: number;
|
|
25
|
+
/** Height of a single watermark tile in pixels */
|
|
26
|
+
height?: number;
|
|
27
|
+
/** Horizontal/vertical gap between watermarks in pixels */
|
|
28
|
+
gap?: WatermarkGap;
|
|
29
|
+
/** Offset for the first watermark tile from the top-left corner */
|
|
30
|
+
offset?: WatermarkOffset;
|
|
31
|
+
/** Rotation angle in degrees */
|
|
32
|
+
rotate?: number;
|
|
33
|
+
/** z-index for the overlay layer */
|
|
34
|
+
zIndex?: number;
|
|
35
|
+
/** Font settings for text watermarks */
|
|
36
|
+
font?: WatermarkFontOptions;
|
|
37
|
+
/** Content to protect with the watermark */
|
|
38
|
+
children?: React.ReactNode;
|
|
39
|
+
}
|
|
40
|
+
export declare const Watermark: React.FC<WatermarkProps>;
|
package/dist/index.d.ts
CHANGED
|
@@ -186,6 +186,8 @@ export { Typography } from './components/Typography';
|
|
|
186
186
|
export type { TypographyProps, TitleProps, ParagraphProps, TextProps, TypographyLinkProps, TypographySize, TitleLevel, } from './components/Typography';
|
|
187
187
|
export { Upload } from './components/Upload';
|
|
188
188
|
export type { UploadProps, UploadFile } from './components/Upload';
|
|
189
|
+
export { Watermark } from './components/Watermark';
|
|
190
|
+
export type { WatermarkProps, WatermarkFontOptions, WatermarkGap, WatermarkOffset, } from './components/Watermark';
|
|
189
191
|
export { Show, Hide } from './components/Responsive';
|
|
190
192
|
export type { ShowProps, HideProps } from './components/Responsive';
|
|
191
193
|
export { useBreakpoint } from './hooks/useBreakpoint';
|
package/dist/index.js
CHANGED
|
@@ -16,7 +16,7 @@ import { Carousel as A } from "./index16.js";
|
|
|
16
16
|
import { Collapse as M } from "./index17.js";
|
|
17
17
|
import { Container as H } from "./index18.js";
|
|
18
18
|
import { ContextMenu as K } from "./index19.js";
|
|
19
|
-
import { Countdown as
|
|
19
|
+
import { Countdown as N } from "./index20.js";
|
|
20
20
|
import { DatePicker as z } from "./index21.js";
|
|
21
21
|
import { Descriptions as J } from "./index22.js";
|
|
22
22
|
import { Diff as U } from "./index23.js";
|
|
@@ -41,7 +41,7 @@ import { Empty as Ao } from "./index41.js";
|
|
|
41
41
|
import { Input as Mo } from "./index42.js";
|
|
42
42
|
import { InputNumber as Ho } from "./index43.js";
|
|
43
43
|
import { Join as Ko } from "./index44.js";
|
|
44
|
-
import { Kbd as
|
|
44
|
+
import { Kbd as No } from "./index45.js";
|
|
45
45
|
import { Layout as zo, useSiderContext as Eo } from "./index46.js";
|
|
46
46
|
import { List as Qo } from "./index47.js";
|
|
47
47
|
import { Loading as jo } from "./index48.js";
|
|
@@ -67,8 +67,8 @@ import { Radio as Ir } from "./index67.js";
|
|
|
67
67
|
import { RadialProgress as Br } from "./index68.js";
|
|
68
68
|
import { Range as Lr } from "./index69.js";
|
|
69
69
|
import { Rating as Gr } from "./index70.js";
|
|
70
|
-
import { Result as
|
|
71
|
-
import { Select as
|
|
70
|
+
import { Result as Wr } from "./index71.js";
|
|
71
|
+
import { Select as Or } from "./index72.js";
|
|
72
72
|
import { Segmented as Er } from "./index73.js";
|
|
73
73
|
import { Skeleton as Qr } from "./index74.js";
|
|
74
74
|
import { Space as jr } from "./index75.js";
|
|
@@ -92,17 +92,18 @@ import { Tree as ve } from "./index92.js";
|
|
|
92
92
|
import { TreeSelect as Re } from "./index93.js";
|
|
93
93
|
import { Typography as Ae } from "./index94.js";
|
|
94
94
|
import { Upload as Me } from "./index95.js";
|
|
95
|
-
import {
|
|
96
|
-
import {
|
|
97
|
-
import {
|
|
98
|
-
import {
|
|
99
|
-
import {
|
|
100
|
-
import {
|
|
101
|
-
import {
|
|
102
|
-
import {
|
|
103
|
-
import {
|
|
104
|
-
import {
|
|
105
|
-
import {
|
|
95
|
+
import { Watermark as He } from "./index96.js";
|
|
96
|
+
import { Hide as Ke, Show as We } from "./index97.js";
|
|
97
|
+
import { useBreakpoint as Oe } from "./index98.js";
|
|
98
|
+
import { useDisclosure as Ee } from "./index99.js";
|
|
99
|
+
import { useClipboard as Qe } from "./index100.js";
|
|
100
|
+
import { useLocalStorage as je } from "./index101.js";
|
|
101
|
+
import { useDebounce as Ve } from "./index102.js";
|
|
102
|
+
import { useClickOutside as Ye } from "./index103.js";
|
|
103
|
+
import { usePrevious as _e } from "./index104.js";
|
|
104
|
+
import { useHover as ot } from "./index105.js";
|
|
105
|
+
import { useKeyPress as et, useKeyPressCallback as tt } from "./index106.js";
|
|
106
|
+
import { useWindowSize as mt } from "./index107.js";
|
|
106
107
|
export {
|
|
107
108
|
e as Affix,
|
|
108
109
|
f as Alert,
|
|
@@ -127,7 +128,7 @@ export {
|
|
|
127
128
|
D as ColorPicker,
|
|
128
129
|
H as Container,
|
|
129
130
|
K as ContextMenu,
|
|
130
|
-
|
|
131
|
+
N as Countdown,
|
|
131
132
|
z as DatePicker,
|
|
132
133
|
J as Descriptions,
|
|
133
134
|
U as Diff,
|
|
@@ -145,14 +146,14 @@ export {
|
|
|
145
146
|
lo as Form,
|
|
146
147
|
go as Grid,
|
|
147
148
|
bo as Hero,
|
|
148
|
-
|
|
149
|
+
Ke as Hide,
|
|
149
150
|
Do as HoverGallery,
|
|
150
151
|
wo as Image,
|
|
151
152
|
vo as Indicator,
|
|
152
153
|
Mo as Input,
|
|
153
154
|
Ho as InputNumber,
|
|
154
155
|
Ko as Join,
|
|
155
|
-
|
|
156
|
+
No as Kbd,
|
|
156
157
|
zo as Layout,
|
|
157
158
|
Qo as List,
|
|
158
159
|
jo as Loading,
|
|
@@ -174,11 +175,11 @@ export {
|
|
|
174
175
|
Ir as Radio,
|
|
175
176
|
Lr as Range,
|
|
176
177
|
Gr as Rating,
|
|
177
|
-
|
|
178
|
+
Wr as Result,
|
|
178
179
|
Po as Row,
|
|
179
180
|
Er as Segmented,
|
|
180
|
-
|
|
181
|
-
|
|
181
|
+
Or as Select,
|
|
182
|
+
We as Show,
|
|
182
183
|
$ as SidebarDrawer,
|
|
183
184
|
Qr as Skeleton,
|
|
184
185
|
jr as Space,
|
|
@@ -202,20 +203,21 @@ export {
|
|
|
202
203
|
Re as TreeSelect,
|
|
203
204
|
Ae as Typography,
|
|
204
205
|
Me as Upload,
|
|
206
|
+
He as Watermark,
|
|
205
207
|
ar as Window,
|
|
206
208
|
dr as notification,
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
209
|
+
Oe as useBreakpoint,
|
|
210
|
+
Ye as useClickOutside,
|
|
211
|
+
Qe as useClipboard,
|
|
212
|
+
Ve as useDebounce,
|
|
213
|
+
Ee as useDisclosure,
|
|
212
214
|
co as useFormInstance,
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
215
|
+
ot as useHover,
|
|
216
|
+
et as useKeyPress,
|
|
217
|
+
tt as useKeyPressCallback,
|
|
218
|
+
je as useLocalStorage,
|
|
219
|
+
_e as usePrevious,
|
|
218
220
|
Eo as useSiderContext,
|
|
219
|
-
|
|
221
|
+
mt as useWindowSize
|
|
220
222
|
};
|
|
221
223
|
//# 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,17 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
function
|
|
3
|
-
const [
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
}),
|
|
13
|
-
(e)
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
15
|
+
p as useClipboard
|
|
48
16
|
};
|
|
49
17
|
//# sourceMappingURL=index100.js.map
|
package/dist/index100.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index100.js","sources":["../src/hooks/
|
|
1
|
+
{"version":3,"file":"index100.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/index101.js
CHANGED
|
@@ -1,16 +1,49 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
function
|
|
3
|
-
const [
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
43
|
+
return window.addEventListener("storage", e), () => window.removeEventListener("storage", e);
|
|
44
|
+
}, [o]), [s, d, w];
|
|
12
45
|
}
|
|
13
46
|
export {
|
|
14
|
-
|
|
47
|
+
S as useLocalStorage
|
|
15
48
|
};
|
|
16
49
|
//# sourceMappingURL=index101.js.map
|
package/dist/index101.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index101.js","sources":["../src/hooks/
|
|
1
|
+
{"version":3,"file":"index101.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/index102.js
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
function
|
|
3
|
-
const
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
const n = setTimeout(() => {
|
|
6
|
+
u(e);
|
|
7
|
+
}, t);
|
|
8
|
+
return () => {
|
|
9
|
+
clearTimeout(n);
|
|
9
10
|
};
|
|
10
|
-
|
|
11
|
-
document.removeEventListener("mousedown", e), document.removeEventListener("touchstart", e);
|
|
12
|
-
};
|
|
13
|
-
}, [t, n]), r;
|
|
11
|
+
}, [e, t]), o;
|
|
14
12
|
}
|
|
15
13
|
export {
|
|
16
|
-
|
|
14
|
+
i as useDebounce
|
|
17
15
|
};
|
|
18
16
|
//# sourceMappingURL=index102.js.map
|
package/dist/index102.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index102.js","sources":["../src/hooks/
|
|
1
|
+
{"version":3,"file":"index102.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/index103.js
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
import { useRef as
|
|
2
|
-
function
|
|
3
|
-
const
|
|
4
|
-
return
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
16
|
+
m as useClickOutside
|
|
10
17
|
};
|
|
11
18
|
//# sourceMappingURL=index103.js.map
|
package/dist/index103.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index103.js","sources":["../src/hooks/
|
|
1
|
+
{"version":3,"file":"index103.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/index104.js
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
function f() {
|
|
3
|
-
const
|
|
4
|
-
return
|
|
5
|
-
|
|
6
|
-
|
|
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
|
|
9
|
+
f as usePrevious
|
|
15
10
|
};
|
|
16
11
|
//# sourceMappingURL=index104.js.map
|
package/dist/index104.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index104.js","sources":["../src/hooks/
|
|
1
|
+
{"version":3,"file":"index104.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/index105.js
CHANGED
|
@@ -1,34 +1,16 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
function
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
e.key === n && d(!1);
|
|
11
|
-
},
|
|
12
|
-
[n]
|
|
13
|
-
);
|
|
14
|
-
return l(() => {
|
|
15
|
-
const e = u ?? window;
|
|
16
|
-
return o === "keydown" ? (e.addEventListener("keydown", t), e.addEventListener("keyup", s)) : e.addEventListener("keyup", t), () => {
|
|
17
|
-
e.removeEventListener("keydown", t), e.removeEventListener("keyup", s);
|
|
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);
|
|
18
10
|
};
|
|
19
|
-
}, [
|
|
20
|
-
}
|
|
21
|
-
function y(n, f, u = {}) {
|
|
22
|
-
const { target: o, event: r = "keydown", preventDefault: a = !1 } = u;
|
|
23
|
-
l(() => {
|
|
24
|
-
const d = o ?? window, t = (s) => {
|
|
25
|
-
s.key === n && (a && s.preventDefault(), f(s));
|
|
26
|
-
};
|
|
27
|
-
return d.addEventListener(r, t), () => d.removeEventListener(r, t);
|
|
28
|
-
}, [o, n, f, r, a]);
|
|
11
|
+
}, []), { ref: n, isHovered: o };
|
|
29
12
|
}
|
|
30
13
|
export {
|
|
31
|
-
|
|
32
|
-
y as useKeyPressCallback
|
|
14
|
+
f as useHover
|
|
33
15
|
};
|
|
34
16
|
//# sourceMappingURL=index105.js.map
|
package/dist/index105.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index105.js","sources":["../src/hooks/
|
|
1
|
+
{"version":3,"file":"index105.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;"}
|