asterui 0.12.18 → 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/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/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
|
@@ -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;"}
|
package/dist/index106.js
CHANGED
|
@@ -1,21 +1,34 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
function
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
n(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { useState as v, useCallback as i, useEffect as l } from "react";
|
|
2
|
+
function c(n, f = {}) {
|
|
3
|
+
const { target: u, event: o = "keydown", preventDefault: r = !1 } = f, [a, d] = v(!1), t = i(
|
|
4
|
+
(e) => {
|
|
5
|
+
e.key === n && (r && e.preventDefault(), d(!0));
|
|
6
|
+
},
|
|
7
|
+
[n, r]
|
|
8
|
+
), s = i(
|
|
9
|
+
(e) => {
|
|
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);
|
|
14
18
|
};
|
|
15
|
-
|
|
16
|
-
|
|
19
|
+
}, [u, o, t, s]), a;
|
|
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]);
|
|
17
29
|
}
|
|
18
30
|
export {
|
|
19
|
-
|
|
31
|
+
c as useKeyPress,
|
|
32
|
+
y as useKeyPressCallback
|
|
20
33
|
};
|
|
21
34
|
//# sourceMappingURL=index106.js.map
|
package/dist/index106.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index106.js","sources":["../src/hooks/
|
|
1
|
+
{"version":3,"file":"index106.js","sources":["../src/hooks/useKeyPress.ts"],"sourcesContent":["import { useState, useEffect, useCallback } from 'react'\n\nexport interface UseKeyPressOptions {\n /** Target element (default: window) */\n target?: HTMLElement | Window | null\n /** Event type: 'keydown' | 'keyup' (default: 'keydown') */\n event?: 'keydown' | 'keyup'\n /** Prevent default browser behavior */\n preventDefault?: boolean\n}\n\n/**\n * Hook that detects when a specific key is pressed.\n *\n * @param targetKey - Key to detect (e.g., 'Enter', 'Escape', 'a')\n * @param options - Configuration options\n * @returns Whether the key is currently pressed\n *\n * @example\n * const enterPressed = useKeyPress('Enter')\n * const escapePressed = useKeyPress('Escape')\n *\n * useEffect(() => {\n * if (escapePressed) closeModal()\n * }, [escapePressed])\n *\n * @example\n * // With callback for immediate action\n * useKeyPress('Escape', { preventDefault: true })\n */\nexport function useKeyPress(\n targetKey: string,\n options: UseKeyPressOptions = {}\n): boolean {\n const { target, event = 'keydown', preventDefault = false } = options\n const [keyPressed, setKeyPressed] = useState(false)\n\n const downHandler = useCallback(\n (e: KeyboardEvent) => {\n if (e.key === targetKey) {\n if (preventDefault) e.preventDefault()\n setKeyPressed(true)\n }\n },\n [targetKey, preventDefault]\n )\n\n const upHandler = useCallback(\n (e: KeyboardEvent) => {\n if (e.key === targetKey) {\n setKeyPressed(false)\n }\n },\n [targetKey]\n )\n\n useEffect(() => {\n const targetElement = target ?? window\n\n if (event === 'keydown') {\n targetElement.addEventListener('keydown', downHandler as EventListener)\n targetElement.addEventListener('keyup', upHandler as EventListener)\n } else {\n targetElement.addEventListener('keyup', downHandler as EventListener)\n }\n\n return () => {\n targetElement.removeEventListener('keydown', downHandler as EventListener)\n targetElement.removeEventListener('keyup', upHandler as EventListener)\n }\n }, [target, event, downHandler, upHandler])\n\n return keyPressed\n}\n\n/**\n * Hook that calls a callback when a specific key is pressed.\n *\n * @param targetKey - Key to detect\n * @param callback - Function to call when key is pressed\n * @param options - Configuration options\n *\n * @example\n * useKeyPressCallback('Escape', () => closeModal())\n * useKeyPressCallback('Enter', () => submitForm(), { preventDefault: true })\n */\nexport function useKeyPressCallback(\n targetKey: string,\n callback: (event: KeyboardEvent) => void,\n options: UseKeyPressOptions = {}\n): void {\n const { target, event = 'keydown', preventDefault = false } = options\n\n useEffect(() => {\n const targetElement = target ?? window\n\n const handler = (e: KeyboardEvent) => {\n if (e.key === targetKey) {\n if (preventDefault) e.preventDefault()\n callback(e)\n }\n }\n\n targetElement.addEventListener(event, handler as EventListener)\n return () => targetElement.removeEventListener(event, handler as EventListener)\n }, [target, targetKey, callback, event, preventDefault])\n}\n"],"names":["useKeyPress","targetKey","options","target","event","preventDefault","keyPressed","setKeyPressed","useState","downHandler","useCallback","upHandler","useEffect","targetElement","useKeyPressCallback","callback","handler","e"],"mappings":";AA8BO,SAASA,EACdC,GACAC,IAA8B,IACrB;AACT,QAAM,EAAE,QAAAC,GAAQ,OAAAC,IAAQ,WAAW,gBAAAC,IAAiB,OAAUH,GACxD,CAACI,GAAYC,CAAa,IAAIC,EAAS,EAAK,GAE5CC,IAAcC;AAAA,IAClB,CAAC,MAAqB;AACpB,MAAI,EAAE,QAAQT,MACRI,OAAkB,eAAA,GACtBE,EAAc,EAAI;AAAA,IAEtB;AAAA,IACA,CAACN,GAAWI,CAAc;AAAA,EAAA,GAGtBM,IAAYD;AAAA,IAChB,CAAC,MAAqB;AACpB,MAAI,EAAE,QAAQT,KACZM,EAAc,EAAK;AAAA,IAEvB;AAAA,IACA,CAACN,CAAS;AAAA,EAAA;AAGZ,SAAAW,EAAU,MAAM;AACd,UAAMC,IAAgBV,KAAU;AAEhC,WAAIC,MAAU,aACZS,EAAc,iBAAiB,WAAWJ,CAA4B,GACtEI,EAAc,iBAAiB,SAASF,CAA0B,KAElEE,EAAc,iBAAiB,SAASJ,CAA4B,GAG/D,MAAM;AACX,MAAAI,EAAc,oBAAoB,WAAWJ,CAA4B,GACzEI,EAAc,oBAAoB,SAASF,CAA0B;AAAA,IACvE;AAAA,EACF,GAAG,CAACR,GAAQC,GAAOK,GAAaE,CAAS,CAAC,GAEnCL;AACT;AAaO,SAASQ,EACdb,GACAc,GACAb,IAA8B,CAAA,GACxB;AACN,QAAM,EAAE,QAAAC,GAAQ,OAAAC,IAAQ,WAAW,gBAAAC,IAAiB,OAAUH;AAE9D,EAAAU,EAAU,MAAM;AACd,UAAMC,IAAgBV,KAAU,QAE1Ba,IAAU,CAACC,MAAqB;AACpC,MAAIA,EAAE,QAAQhB,MACRI,OAAkB,eAAA,GACtBU,EAASE,CAAC;AAAA,IAEd;AAEA,WAAAJ,EAAc,iBAAiBT,GAAOY,CAAwB,GACvD,MAAMH,EAAc,oBAAoBT,GAAOY,CAAwB;AAAA,EAChF,GAAG,CAACb,GAAQF,GAAWc,GAAUX,GAAOC,CAAc,CAAC;AACzD;"}
|
package/dist/index107.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useState as t, useEffect as d } from "react";
|
|
2
|
+
function r() {
|
|
3
|
+
const [i, n] = t(() => typeof window > "u" ? { width: 0, height: 0 } : {
|
|
4
|
+
width: window.innerWidth,
|
|
5
|
+
height: window.innerHeight
|
|
6
|
+
});
|
|
7
|
+
return d(() => {
|
|
8
|
+
if (typeof window > "u") return;
|
|
9
|
+
const e = () => {
|
|
10
|
+
n({
|
|
11
|
+
width: window.innerWidth,
|
|
12
|
+
height: window.innerHeight
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
return window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
|
|
16
|
+
}, []), i;
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
r as useWindowSize
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=index107.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index107.js","sources":["../src/hooks/useWindowSize.ts"],"sourcesContent":["import { useState, useEffect } from 'react'\n\nexport interface WindowSize {\n width: number\n height: number\n}\n\n/**\n * Hook that tracks window dimensions.\n * Updates on window resize.\n *\n * @returns Object with current width and height\n *\n * @example\n * const { width, height } = useWindowSize()\n *\n * return (\n * <div>\n * Window: {width} x {height}\n * {width < 768 && <MobileNav />}\n * </div>\n * )\n */\nexport function useWindowSize(): WindowSize {\n const [windowSize, setWindowSize] = useState<WindowSize>(() => {\n if (typeof window === 'undefined') {\n return { width: 0, height: 0 }\n }\n return {\n width: window.innerWidth,\n height: window.innerHeight,\n }\n })\n\n useEffect(() => {\n if (typeof window === 'undefined') return\n\n const handleResize = () => {\n setWindowSize({\n width: window.innerWidth,\n height: window.innerHeight,\n })\n }\n\n window.addEventListener('resize', handleResize)\n return () => window.removeEventListener('resize', handleResize)\n }, [])\n\n return windowSize\n}\n"],"names":["useWindowSize","windowSize","setWindowSize","useState","useEffect","handleResize"],"mappings":";AAuBO,SAASA,IAA4B;AAC1C,QAAM,CAACC,GAAYC,CAAa,IAAIC,EAAqB,MACnD,OAAO,SAAW,MACb,EAAE,OAAO,GAAG,QAAQ,EAAA,IAEtB;AAAA,IACL,OAAO,OAAO;AAAA,IACd,QAAQ,OAAO;AAAA,EAAA,CAElB;AAED,SAAAC,EAAU,MAAM;AACd,QAAI,OAAO,SAAW,IAAa;AAEnC,UAAMC,IAAe,MAAM;AACzB,MAAAH,EAAc;AAAA,QACZ,OAAO,OAAO;AAAA,QACd,QAAQ,OAAO;AAAA,MAAA,CAChB;AAAA,IACH;AAEA,kBAAO,iBAAiB,UAAUG,CAAY,GACvC,MAAM,OAAO,oBAAoB,UAAUA,CAAY;AAAA,EAChE,GAAG,CAAA,CAAE,GAEEJ;AACT;"}
|
package/dist/index96.js
CHANGED
|
@@ -1,17 +1,129 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
1
|
+
import { jsxs as z, jsx as R } from "react/jsx-runtime";
|
|
2
|
+
import { useState as V, useMemo as P, useEffect as Y } from "react";
|
|
3
|
+
const D = "asterui", O = 0.22, U = (t, c = O) => {
|
|
4
|
+
const r = `rgba(0,0,0,${c})`;
|
|
5
|
+
if (t && t.includes("var(--bc")) {
|
|
6
|
+
if (typeof window < "u") {
|
|
7
|
+
const a = getComputedStyle(document.documentElement).getPropertyValue("--bc").trim(), g = getComputedStyle(document.body).getPropertyValue("--bc").trim(), m = a || g;
|
|
8
|
+
if (m)
|
|
9
|
+
return t.replace(/var\(--bc\)/g, m);
|
|
10
|
+
}
|
|
11
|
+
return r;
|
|
12
|
+
}
|
|
13
|
+
if (t) return t;
|
|
14
|
+
if (typeof window > "u") return r;
|
|
15
|
+
const i = getComputedStyle(document.documentElement).getPropertyValue("--bc").trim(), d = getComputedStyle(document.body).getPropertyValue("--bc").trim(), s = i || d;
|
|
16
|
+
return s ? `hsl(${s} / ${c})` : r;
|
|
17
|
+
}, M = (t, c) => {
|
|
18
|
+
const r = t?.fontSize ?? 16;
|
|
19
|
+
return {
|
|
20
|
+
color: c,
|
|
21
|
+
fontSize: r,
|
|
22
|
+
fontWeight: t?.fontWeight ?? 600,
|
|
23
|
+
fontStyle: t?.fontStyle ?? "normal",
|
|
24
|
+
fontFamily: t?.fontFamily ?? "sans-serif",
|
|
25
|
+
lineHeight: t?.lineHeight ?? r * 1.2
|
|
26
|
+
};
|
|
27
|
+
}, X = ({
|
|
28
|
+
children: t,
|
|
29
|
+
className: c = "",
|
|
30
|
+
style: r,
|
|
31
|
+
content: i,
|
|
32
|
+
image: d,
|
|
33
|
+
width: s = 120,
|
|
34
|
+
height: a = 64,
|
|
35
|
+
gap: g,
|
|
36
|
+
offset: m,
|
|
37
|
+
rotate: T = -22,
|
|
38
|
+
zIndex: W = 1e3,
|
|
39
|
+
font: S,
|
|
40
|
+
...A
|
|
41
|
+
}) => {
|
|
42
|
+
const [y, $] = V(null), u = g?.[0] ?? 120, f = g?.[1] ?? 120, B = m?.[0] ?? u / 2, F = m?.[1] ?? f / 2, E = P(
|
|
43
|
+
() => typeof i == "string" ? [i] : Array.isArray(i) ? i : [D],
|
|
44
|
+
[i]
|
|
45
|
+
), k = U(S?.color), l = P(
|
|
46
|
+
() => M(S, k),
|
|
47
|
+
[S, k]
|
|
48
|
+
), h = Math.PI / 180 * T, I = E.join("|");
|
|
49
|
+
Y(() => {
|
|
50
|
+
if (typeof window > "u") return;
|
|
51
|
+
let p = !1;
|
|
52
|
+
const n = window.devicePixelRatio || 1, w = s + u, C = a + f, v = document.createElement("canvas");
|
|
53
|
+
v.width = w * n, v.height = C * n;
|
|
54
|
+
const e = v.getContext("2d");
|
|
55
|
+
if (!e) return;
|
|
56
|
+
const L = () => {
|
|
57
|
+
const o = v.toDataURL();
|
|
58
|
+
p || $({ url: o, width: w, height: C });
|
|
59
|
+
}, N = () => {
|
|
60
|
+
e.save(), e.translate((u / 2 + s / 2) * n, (f / 2 + a / 2) * n), e.rotate(h), e.fillStyle = l.color, e.textAlign = "center", e.textBaseline = "middle", e.font = `${l.fontStyle} normal ${l.fontWeight} ${l.fontSize * n}px ${l.fontFamily}`;
|
|
61
|
+
const o = l.lineHeight * n, b = -((E.length - 1) * o) / 2;
|
|
62
|
+
E.forEach((x, j) => {
|
|
63
|
+
e.fillText(x, 0, b + j * o);
|
|
64
|
+
}), e.restore();
|
|
65
|
+
};
|
|
66
|
+
if (d) {
|
|
67
|
+
const o = new Image();
|
|
68
|
+
o.crossOrigin = "anonymous", o.referrerPolicy = "no-referrer";
|
|
69
|
+
const b = () => {
|
|
70
|
+
e.save(), e.translate((u / 2 + s / 2) * n, (f / 2 + a / 2) * n), e.rotate(h), e.drawImage(
|
|
71
|
+
o,
|
|
72
|
+
-s / 2 * n,
|
|
73
|
+
-a / 2 * n,
|
|
74
|
+
s * n,
|
|
75
|
+
a * n
|
|
76
|
+
), e.restore(), L();
|
|
77
|
+
}, x = () => {
|
|
78
|
+
p || $(null);
|
|
79
|
+
};
|
|
80
|
+
return o.addEventListener("load", b), o.addEventListener("error", x), o.src = d, () => {
|
|
81
|
+
p = !0, o.removeEventListener("load", b), o.removeEventListener("error", x);
|
|
82
|
+
};
|
|
83
|
+
} else
|
|
84
|
+
N(), L();
|
|
85
|
+
return () => {
|
|
86
|
+
p = !0;
|
|
87
|
+
};
|
|
88
|
+
}, [
|
|
89
|
+
l,
|
|
90
|
+
u,
|
|
91
|
+
f,
|
|
92
|
+
a,
|
|
93
|
+
d,
|
|
94
|
+
h,
|
|
95
|
+
I,
|
|
96
|
+
s
|
|
97
|
+
]);
|
|
98
|
+
const H = ["relative", c].filter(Boolean).join(" ");
|
|
99
|
+
return /* @__PURE__ */ z(
|
|
100
|
+
"div",
|
|
101
|
+
{
|
|
102
|
+
className: H,
|
|
103
|
+
style: { position: r?.position ?? "relative", ...r },
|
|
104
|
+
...A,
|
|
105
|
+
children: [
|
|
106
|
+
t,
|
|
107
|
+
y && /* @__PURE__ */ R(
|
|
108
|
+
"div",
|
|
109
|
+
{
|
|
110
|
+
"aria-hidden": !0,
|
|
111
|
+
className: "pointer-events-none absolute inset-0",
|
|
112
|
+
style: {
|
|
113
|
+
zIndex: W,
|
|
114
|
+
backgroundImage: `url(${y.url})`,
|
|
115
|
+
backgroundRepeat: "repeat",
|
|
116
|
+
backgroundSize: `${y.width}px ${y.height}px`,
|
|
117
|
+
backgroundPosition: `${B}px ${F}px`
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
)
|
|
121
|
+
]
|
|
122
|
+
}
|
|
123
|
+
);
|
|
124
|
+
};
|
|
125
|
+
X.displayName = "Watermark";
|
|
13
126
|
export {
|
|
14
|
-
|
|
15
|
-
h as Show
|
|
127
|
+
X as Watermark
|
|
16
128
|
};
|
|
17
129
|
//# sourceMappingURL=index96.js.map
|
package/dist/index96.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index96.js","sources":["../src/components/Responsive.tsx"],"sourcesContent":["import React, { ReactNode } from 'react'\nimport { useBreakpoint, Breakpoint } from '../hooks/useBreakpoint'\n\nexport interface ShowProps {\n children: ReactNode\n above?: Breakpoint\n below?: Breakpoint\n at?: Breakpoint | Breakpoint[]\n between?: [Breakpoint, Breakpoint]\n}\n\nexport function Show({ children, above, below, at, between }: ShowProps): React.ReactElement | null {\n const { isAbove, isBelow, isAt, isBetween } = useBreakpoint()\n\n let shouldShow = false\n\n if (above !== undefined) {\n shouldShow = isAbove(above)\n } else if (below !== undefined) {\n shouldShow = isBelow(below)\n } else if (at !== undefined) {\n if (Array.isArray(at)) {\n shouldShow = at.some((bp) => isAt(bp))\n } else {\n shouldShow = isAt(at)\n }\n } else if (between !== undefined) {\n shouldShow = isBetween(between[0], between[1])\n } else {\n shouldShow = true\n }\n\n return shouldShow ? <>{children}</> : null\n}\n\nexport interface HideProps {\n children: ReactNode\n above?: Breakpoint\n below?: Breakpoint\n at?: Breakpoint | Breakpoint[]\n between?: [Breakpoint, Breakpoint]\n}\n\nexport function Hide({ children, above, below, at, between }: HideProps): React.ReactElement | null {\n const { isAbove, isBelow, isAt, isBetween } = useBreakpoint()\n\n let shouldHide = false\n\n if (above !== undefined) {\n shouldHide = isAbove(above)\n } else if (below !== undefined) {\n shouldHide = isBelow(below)\n } else if (at !== undefined) {\n if (Array.isArray(at)) {\n shouldHide = at.some((bp) => isAt(bp))\n } else {\n shouldHide = isAt(at)\n }\n } else if (between !== undefined) {\n shouldHide = isBetween(between[0], between[1])\n }\n\n return shouldHide ? null : <>{children}</>\n}\n"],"names":["Show","children","above","below","at","between","isAbove","isBelow","isAt","isBetween","useBreakpoint","shouldShow","bp","jsx","Fragment","Hide","shouldHide"],"mappings":";;AAWO,SAASA,EAAK,EAAE,UAAAC,GAAU,OAAAC,GAAO,OAAAC,GAAO,IAAAC,GAAI,SAAAC,KAAiD;AAClG,QAAM,EAAE,SAAAC,GAAS,SAAAC,GAAS,MAAAC,GAAM,WAAAC,EAAA,IAAcC,EAAA;AAE9C,MAAIC,IAAa;AAEjB,SAAIT,MAAU,SACZS,IAAaL,EAAQJ,CAAK,IACjBC,MAAU,SACnBQ,IAAaJ,EAAQJ,CAAK,IACjBC,MAAO,SACZ,MAAM,QAAQA,CAAE,IAClBO,IAAaP,EAAG,KAAK,CAACQ,MAAOJ,EAAKI,CAAE,CAAC,IAErCD,IAAaH,EAAKJ,CAAE,IAEbC,MAAY,SACrBM,IAAaF,EAAUJ,EAAQ,CAAC,GAAGA,EAAQ,CAAC,CAAC,IAE7CM,IAAa,IAGRA,IAAa,gBAAAE,EAAAC,GAAA,EAAG,UAAAb,EAAA,CAAS,IAAM;AACxC;AAUO,SAASc,EAAK,EAAE,UAAAd,GAAU,OAAAC,GAAO,OAAAC,GAAO,IAAAC,GAAI,SAAAC,KAAiD;AAClG,QAAM,EAAE,SAAAC,GAAS,SAAAC,GAAS,MAAAC,GAAM,WAAAC,EAAA,IAAcC,EAAA;AAE9C,MAAIM,IAAa;AAEjB,SAAId,MAAU,SACZc,IAAaV,EAAQJ,CAAK,IACjBC,MAAU,SACnBa,IAAaT,EAAQJ,CAAK,IACjBC,MAAO,SACZ,MAAM,QAAQA,CAAE,IAClBY,IAAaZ,EAAG,KAAK,CAACQ,MAAOJ,EAAKI,CAAE,CAAC,IAErCI,IAAaR,EAAKJ,CAAE,IAEbC,MAAY,WACrBW,IAAaP,EAAUJ,EAAQ,CAAC,GAAGA,EAAQ,CAAC,CAAC,IAGxCW,IAAa,OAAO,gBAAAH,EAAAC,GAAA,EAAG,UAAAb,EAAA,CAAS;AACzC;"}
|
|
1
|
+
{"version":3,"file":"index96.js","sources":["../src/components/Watermark.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useState } from 'react'\n\nexport type WatermarkGap = [number, number]\nexport type WatermarkOffset = [number, number]\n\nexport interface WatermarkFontOptions {\n /** Text color for watermark content */\n color?: string\n /** Font size in pixels */\n fontSize?: number\n /** Font weight for watermark text */\n fontWeight?: number | 'normal' | 'bold' | 'bolder' | 'lighter'\n /** Font style for watermark text */\n fontStyle?: 'normal' | 'italic' | 'oblique'\n /** Font family for watermark text */\n fontFamily?: string\n /** Line height in pixels for multi-line content */\n lineHeight?: number\n}\n\nexport interface WatermarkProps\n extends Omit<React.HTMLAttributes<HTMLDivElement>, 'content'> {\n /** Text to render inside the watermark; falls back to \"asterui\" */\n content?: string | string[]\n /** Image source (URL or base64) to render instead of text */\n image?: string\n /** Width of a single watermark tile in pixels */\n width?: number\n /** Height of a single watermark tile in pixels */\n height?: number\n /** Horizontal/vertical gap between watermarks in pixels */\n gap?: WatermarkGap\n /** Offset for the first watermark tile from the top-left corner */\n offset?: WatermarkOffset\n /** Rotation angle in degrees */\n rotate?: number\n /** z-index for the overlay layer */\n zIndex?: number\n /** Font settings for text watermarks */\n font?: WatermarkFontOptions\n /** Content to protect with the watermark */\n children?: React.ReactNode\n}\n\ntype WatermarkImage = {\n url: string\n width: number\n height: number\n}\n\nconst DEFAULT_CONTENT = 'asterui'\nconst DEFAULT_OPACITY = 0.22\n\nconst resolveThemeColor = (requested?: string, opacity = DEFAULT_OPACITY) => {\n const fallback = `rgba(0,0,0,${opacity})`\n\n if (requested && requested.includes('var(--bc')) {\n if (typeof window !== 'undefined') {\n const docBase = getComputedStyle(document.documentElement).getPropertyValue('--bc').trim()\n const bodyBase = getComputedStyle(document.body).getPropertyValue('--bc').trim()\n const base = docBase || bodyBase\n if (base) {\n return requested.replace(/var\\(--bc\\)/g, base)\n }\n }\n return fallback\n }\n\n if (requested) return requested\n\n if (typeof window === 'undefined') return fallback\n\n const docBase = getComputedStyle(document.documentElement).getPropertyValue('--bc').trim()\n const bodyBase = getComputedStyle(document.body).getPropertyValue('--bc').trim()\n const base = docBase || bodyBase\n\n return base ? `hsl(${base} / ${opacity})` : fallback\n}\n\nconst getFontSettings = (font: WatermarkFontOptions | undefined, resolvedColor: string) => {\n const fontSize = font?.fontSize ?? 16\n\n return {\n color: resolvedColor,\n fontSize,\n fontWeight: font?.fontWeight ?? 600,\n fontStyle: font?.fontStyle ?? 'normal',\n fontFamily: font?.fontFamily ?? 'sans-serif',\n lineHeight: font?.lineHeight ?? fontSize * 1.2,\n }\n}\n\nexport const Watermark: React.FC<WatermarkProps> = ({\n children,\n className = '',\n style,\n content,\n image,\n width = 120,\n height = 64,\n gap,\n offset,\n rotate = -22,\n zIndex = 1000,\n font,\n ...rest\n}) => {\n const [watermark, setWatermark] = useState<WatermarkImage | null>(null)\n\n const gapX = gap?.[0] ?? 120\n const gapY = gap?.[1] ?? 120\n const offsetX = offset?.[0] ?? gapX / 2\n const offsetY = offset?.[1] ?? gapY / 2\n const textLines = useMemo(\n () =>\n typeof content === 'string'\n ? [content]\n : Array.isArray(content)\n ? content\n : [DEFAULT_CONTENT],\n [content]\n )\n const resolvedColor = resolveThemeColor(font?.color)\n const fontSettings = useMemo(\n () => getFontSettings(font, resolvedColor),\n [font, resolvedColor]\n )\n const rotationInRadians = (Math.PI / 180) * rotate\n const textKey = textLines.join('|')\n\n useEffect(() => {\n if (typeof window === 'undefined') return\n\n let cancelled = false\n const ratio = window.devicePixelRatio || 1\n const tileWidth = width + gapX\n const tileHeight = height + gapY\n const canvas = document.createElement('canvas')\n canvas.width = tileWidth * ratio\n canvas.height = tileHeight * ratio\n const ctx = canvas.getContext('2d')\n\n if (!ctx) return\n\n const commitWatermark = () => {\n const url = canvas.toDataURL()\n if (!cancelled) {\n setWatermark({ url, width: tileWidth, height: tileHeight })\n }\n }\n\n const drawText = () => {\n ctx.save()\n ctx.translate((gapX / 2 + width / 2) * ratio, (gapY / 2 + height / 2) * ratio)\n ctx.rotate(rotationInRadians)\n ctx.fillStyle = fontSettings.color\n ctx.textAlign = 'center'\n ctx.textBaseline = 'middle'\n ctx.font = `${fontSettings.fontStyle} normal ${fontSettings.fontWeight} ${fontSettings.fontSize * ratio}px ${fontSettings.fontFamily}`\n\n const lineHeight = fontSettings.lineHeight * ratio\n const startY = -((textLines.length - 1) * lineHeight) / 2\n\n textLines.forEach((line, index) => {\n ctx.fillText(line, 0, startY + index * lineHeight)\n })\n\n ctx.restore()\n }\n\n if (image) {\n const img = new Image()\n img.crossOrigin = 'anonymous'\n img.referrerPolicy = 'no-referrer'\n\n const handleLoad = () => {\n ctx.save()\n ctx.translate((gapX / 2 + width / 2) * ratio, (gapY / 2 + height / 2) * ratio)\n ctx.rotate(rotationInRadians)\n ctx.drawImage(\n img,\n (-width / 2) * ratio,\n (-height / 2) * ratio,\n width * ratio,\n height * ratio\n )\n ctx.restore()\n commitWatermark()\n }\n\n const handleError = () => {\n if (!cancelled) setWatermark(null)\n }\n\n img.addEventListener('load', handleLoad)\n img.addEventListener('error', handleError)\n img.src = image\n\n return () => {\n cancelled = true\n img.removeEventListener('load', handleLoad)\n img.removeEventListener('error', handleError)\n }\n } else {\n drawText()\n commitWatermark()\n }\n\n return () => {\n cancelled = true\n }\n }, [\n fontSettings,\n gapX,\n gapY,\n height,\n image,\n rotationInRadians,\n textKey,\n width,\n ])\n\n const classes = ['relative', className].filter(Boolean).join(' ')\n\n return (\n <div\n className={classes}\n style={{ position: style?.position ?? 'relative', ...style }}\n {...rest}\n >\n {children}\n {watermark && (\n <div\n aria-hidden\n className=\"pointer-events-none absolute inset-0\"\n style={{\n zIndex,\n backgroundImage: `url(${watermark.url})`,\n backgroundRepeat: 'repeat',\n backgroundSize: `${watermark.width}px ${watermark.height}px`,\n backgroundPosition: `${offsetX}px ${offsetY}px`,\n }}\n />\n )}\n </div>\n )\n}\n\nWatermark.displayName = 'Watermark'\n"],"names":["DEFAULT_CONTENT","DEFAULT_OPACITY","resolveThemeColor","requested","opacity","fallback","docBase","bodyBase","base","getFontSettings","font","resolvedColor","fontSize","Watermark","children","className","style","content","image","width","height","gap","offset","rotate","zIndex","rest","watermark","setWatermark","useState","gapX","gapY","offsetX","offsetY","textLines","useMemo","fontSettings","rotationInRadians","textKey","useEffect","cancelled","ratio","tileWidth","tileHeight","canvas","ctx","commitWatermark","url","drawText","lineHeight","startY","line","index","img","handleLoad","handleError","classes","jsxs","jsx"],"mappings":"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"}
|
package/dist/index97.js
CHANGED
|
@@ -1,36 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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";
|
|
1
|
+
import { jsx as v, Fragment as A } from "react/jsx-runtime";
|
|
2
|
+
import { useBreakpoint as m } from "./index98.js";
|
|
3
|
+
function h({ children: f, above: o, below: r, at: s, between: e }) {
|
|
4
|
+
const { isAbove: d, isBelow: n, isAt: l, isBetween: u } = m();
|
|
5
|
+
let i = !1;
|
|
6
|
+
return o !== void 0 ? i = d(o) : r !== void 0 ? i = n(r) : s !== void 0 ? Array.isArray(s) ? i = s.some((t) => l(t)) : i = l(s) : e !== void 0 ? i = u(e[0], e[1]) : i = !0, i ? /* @__PURE__ */ v(A, { children: f }) : null;
|
|
11
7
|
}
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
};
|
|
8
|
+
function p({ children: f, above: o, below: r, at: s, between: e }) {
|
|
9
|
+
const { isAbove: d, isBelow: n, isAt: l, isBetween: u } = m();
|
|
10
|
+
let i = !1;
|
|
11
|
+
return o !== void 0 ? i = d(o) : r !== void 0 ? i = n(r) : s !== void 0 ? Array.isArray(s) ? i = s.some((t) => l(t)) : i = l(s) : e !== void 0 && (i = u(e[0], e[1])), i ? null : /* @__PURE__ */ v(A, { children: f });
|
|
32
12
|
}
|
|
33
13
|
export {
|
|
34
|
-
|
|
14
|
+
p as Hide,
|
|
15
|
+
h as Show
|
|
35
16
|
};
|
|
36
17
|
//# sourceMappingURL=index97.js.map
|
package/dist/index97.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index97.js","sources":["../src/
|
|
1
|
+
{"version":3,"file":"index97.js","sources":["../src/components/Responsive.tsx"],"sourcesContent":["import React, { ReactNode } from 'react'\nimport { useBreakpoint, Breakpoint } from '../hooks/useBreakpoint'\n\nexport interface ShowProps {\n children: ReactNode\n above?: Breakpoint\n below?: Breakpoint\n at?: Breakpoint | Breakpoint[]\n between?: [Breakpoint, Breakpoint]\n}\n\nexport function Show({ children, above, below, at, between }: ShowProps): React.ReactElement | null {\n const { isAbove, isBelow, isAt, isBetween } = useBreakpoint()\n\n let shouldShow = false\n\n if (above !== undefined) {\n shouldShow = isAbove(above)\n } else if (below !== undefined) {\n shouldShow = isBelow(below)\n } else if (at !== undefined) {\n if (Array.isArray(at)) {\n shouldShow = at.some((bp) => isAt(bp))\n } else {\n shouldShow = isAt(at)\n }\n } else if (between !== undefined) {\n shouldShow = isBetween(between[0], between[1])\n } else {\n shouldShow = true\n }\n\n return shouldShow ? <>{children}</> : null\n}\n\nexport interface HideProps {\n children: ReactNode\n above?: Breakpoint\n below?: Breakpoint\n at?: Breakpoint | Breakpoint[]\n between?: [Breakpoint, Breakpoint]\n}\n\nexport function Hide({ children, above, below, at, between }: HideProps): React.ReactElement | null {\n const { isAbove, isBelow, isAt, isBetween } = useBreakpoint()\n\n let shouldHide = false\n\n if (above !== undefined) {\n shouldHide = isAbove(above)\n } else if (below !== undefined) {\n shouldHide = isBelow(below)\n } else if (at !== undefined) {\n if (Array.isArray(at)) {\n shouldHide = at.some((bp) => isAt(bp))\n } else {\n shouldHide = isAt(at)\n }\n } else if (between !== undefined) {\n shouldHide = isBetween(between[0], between[1])\n }\n\n return shouldHide ? null : <>{children}</>\n}\n"],"names":["Show","children","above","below","at","between","isAbove","isBelow","isAt","isBetween","useBreakpoint","shouldShow","bp","jsx","Fragment","Hide","shouldHide"],"mappings":";;AAWO,SAASA,EAAK,EAAE,UAAAC,GAAU,OAAAC,GAAO,OAAAC,GAAO,IAAAC,GAAI,SAAAC,KAAiD;AAClG,QAAM,EAAE,SAAAC,GAAS,SAAAC,GAAS,MAAAC,GAAM,WAAAC,EAAA,IAAcC,EAAA;AAE9C,MAAIC,IAAa;AAEjB,SAAIT,MAAU,SACZS,IAAaL,EAAQJ,CAAK,IACjBC,MAAU,SACnBQ,IAAaJ,EAAQJ,CAAK,IACjBC,MAAO,SACZ,MAAM,QAAQA,CAAE,IAClBO,IAAaP,EAAG,KAAK,CAACQ,MAAOJ,EAAKI,CAAE,CAAC,IAErCD,IAAaH,EAAKJ,CAAE,IAEbC,MAAY,SACrBM,IAAaF,EAAUJ,EAAQ,CAAC,GAAGA,EAAQ,CAAC,CAAC,IAE7CM,IAAa,IAGRA,IAAa,gBAAAE,EAAAC,GAAA,EAAG,UAAAb,EAAA,CAAS,IAAM;AACxC;AAUO,SAASc,EAAK,EAAE,UAAAd,GAAU,OAAAC,GAAO,OAAAC,GAAO,IAAAC,GAAI,SAAAC,KAAiD;AAClG,QAAM,EAAE,SAAAC,GAAS,SAAAC,GAAS,MAAAC,GAAM,WAAAC,EAAA,IAAcC,EAAA;AAE9C,MAAIM,IAAa;AAEjB,SAAId,MAAU,SACZc,IAAaV,EAAQJ,CAAK,IACjBC,MAAU,SACnBa,IAAaT,EAAQJ,CAAK,IACjBC,MAAO,SACZ,MAAM,QAAQA,CAAE,IAClBY,IAAaZ,EAAG,KAAK,CAACQ,MAAOJ,EAAKI,CAAE,CAAC,IAErCI,IAAaR,EAAKJ,CAAE,IAEbC,MAAY,WACrBW,IAAaP,EAAUJ,EAAQ,CAAC,GAAGA,EAAQ,CAAC,CAAC,IAGxCW,IAAa,OAAO,gBAAAH,EAAAC,GAAA,EAAG,UAAAb,EAAA,CAAS;AACzC;"}
|
package/dist/index98.js
CHANGED
|
@@ -1,9 +1,36 @@
|
|
|
1
|
-
import { useState as u,
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
34
|
+
m as useBreakpoint
|
|
8
35
|
};
|
|
9
36
|
//# sourceMappingURL=index98.js.map
|
package/dist/index98.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index98.js","sources":["../src/hooks/
|
|
1
|
+
{"version":3,"file":"index98.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/index99.js
CHANGED
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
function p(
|
|
3
|
-
const [n,
|
|
4
|
-
|
|
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
|
|
7
|
+
p as useDisclosure
|
|
16
8
|
};
|
|
17
9
|
//# sourceMappingURL=index99.js.map
|
package/dist/index99.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index99.js","sources":["../src/hooks/
|
|
1
|
+
{"version":3,"file":"index99.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;"}
|