asterui 0.11.0 → 0.12.1
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/README.md +1 -103
- package/dist/components/Anchor.d.ts +45 -0
- package/dist/components/Diff.d.ts +12 -0
- package/dist/components/Form.d.ts +27 -2
- package/dist/components/Kbd.d.ts +8 -0
- package/dist/components/Radio.d.ts +7 -1
- package/dist/components/Status.d.ts +18 -0
- package/dist/components/TextRotate.d.ts +13 -0
- package/dist/index.d.ts +12 -2
- package/dist/index.js +210 -200
- package/dist/index.js.map +1 -1
- package/dist/index10.js +92 -30
- package/dist/index10.js.map +1 -1
- package/dist/index100.js +8 -5
- package/dist/index100.js.map +1 -1
- package/dist/index101.js +12 -41
- package/dist/index101.js.map +1 -1
- package/dist/index102.js +31 -2
- package/dist/index102.js.map +1 -1
- package/dist/index103.js +17 -6
- package/dist/index103.js.map +1 -1
- package/dist/index104.js +10788 -147
- package/dist/index104.js.map +1 -1
- package/dist/index105.js +5 -30
- package/dist/index105.js.map +1 -1
- package/dist/index106.js +39 -27
- package/dist/index106.js.map +1 -1
- package/dist/index108.js +6 -71
- package/dist/index108.js.map +1 -1
- package/dist/index109.js +147 -34
- package/dist/index109.js.map +1 -1
- package/dist/index11.js +28 -263
- package/dist/index11.js.map +1 -1
- package/dist/index110.js +28 -24
- package/dist/index110.js.map +1 -1
- package/dist/index111.js +28 -19
- package/dist/index111.js.map +1 -1
- package/dist/index112.js +2 -24
- package/dist/index112.js.map +1 -1
- package/dist/index113.js +71 -19
- package/dist/index113.js.map +1 -1
- package/dist/index114.js +33 -94
- package/dist/index114.js.map +1 -1
- package/dist/index115.js +24 -358
- package/dist/index115.js.map +1 -1
- package/dist/index116.js +19 -23
- package/dist/index116.js.map +1 -1
- package/dist/index117.js +22 -71
- package/dist/index117.js.map +1 -1
- package/dist/index118.js +17 -13
- package/dist/index118.js.map +1 -1
- package/dist/index119.js +91 -57
- package/dist/index119.js.map +1 -1
- package/dist/index12.js +259 -89
- package/dist/index12.js.map +1 -1
- package/dist/index120.js +357 -141
- package/dist/index120.js.map +1 -1
- package/dist/index121.js +25 -2
- package/dist/index121.js.map +1 -1
- package/dist/index122.js +70 -53
- package/dist/index122.js.map +1 -1
- package/dist/index123.js +16 -2
- package/dist/index123.js.map +1 -1
- package/dist/index124.js +66 -2
- package/dist/index124.js.map +1 -1
- package/dist/index125.js +144 -2
- package/dist/index125.js.map +1 -1
- package/dist/index126.js +2 -2
- package/dist/index127.js +56 -2
- package/dist/index127.js.map +1 -1
- package/dist/index13.js +90 -153
- package/dist/index13.js.map +1 -1
- package/dist/index130.js +2 -32
- package/dist/index130.js.map +1 -1
- package/dist/index132.js +2 -8
- package/dist/index132.js.map +1 -1
- package/dist/index133.js +2 -2
- package/dist/index134.js +2 -2
- package/dist/index135.js +2 -21
- package/dist/index135.js.map +1 -1
- package/dist/index136.js +32 -2
- package/dist/index136.js.map +1 -1
- package/dist/index137.js +2 -24
- package/dist/index137.js.map +1 -1
- package/dist/index138.js +7 -70
- package/dist/index138.js.map +1 -1
- package/dist/index139.js +2 -21
- package/dist/index139.js.map +1 -1
- package/dist/index14.js +154 -146
- package/dist/index14.js.map +1 -1
- package/dist/index140.js +2 -34
- package/dist/index140.js.map +1 -1
- package/dist/index141.js +20 -69
- package/dist/index141.js.map +1 -1
- package/dist/index142.js +2 -2
- package/dist/index143.js +24 -2
- package/dist/index143.js.map +1 -1
- package/dist/index144.js +70 -21
- package/dist/index144.js.map +1 -1
- package/dist/index145.js +21 -2
- package/dist/index145.js.map +1 -1
- package/dist/index146.js +34 -2
- package/dist/index146.js.map +1 -1
- package/dist/index147.js +70 -2
- package/dist/index147.js.map +1 -1
- package/dist/index148.js +2 -2
- package/dist/index149.js +21 -3
- package/dist/index149.js.map +1 -1
- package/dist/index15.js +150 -5
- package/dist/index15.js.map +1 -1
- package/dist/index150.js +5 -0
- package/dist/index150.js.map +1 -0
- package/dist/index151.js +5 -0
- package/dist/index151.js.map +1 -0
- package/dist/index152.js +5 -0
- package/dist/index152.js.map +1 -0
- package/dist/index153.js +5 -0
- package/dist/index153.js.map +1 -0
- package/dist/index154.js +7 -0
- package/dist/index154.js.map +1 -0
- package/dist/index16.js +5 -71
- package/dist/index16.js.map +1 -1
- package/dist/index17.js +71 -17
- package/dist/index17.js.map +1 -1
- package/dist/index18.js +15 -96
- package/dist/index18.js.map +1 -1
- package/dist/index19.js +89 -105
- package/dist/index19.js.map +1 -1
- package/dist/index20.js +107 -177
- package/dist/index20.js.map +1 -1
- package/dist/index21.js +181 -107
- package/dist/index21.js.map +1 -1
- package/dist/index22.js +107 -29
- package/dist/index22.js.map +1 -1
- package/dist/index23.js +19 -41
- package/dist/index23.js.map +1 -1
- package/dist/index24.js +31 -11
- package/dist/index24.js.map +1 -1
- package/dist/index25.js +41 -33
- package/dist/index25.js.map +1 -1
- package/dist/index26.js +12 -63
- package/dist/index26.js.map +1 -1
- package/dist/index27.js +33 -80
- package/dist/index27.js.map +1 -1
- package/dist/index28.js +63 -18
- package/dist/index28.js.map +1 -1
- package/dist/index29.js +78 -159
- package/dist/index29.js.map +1 -1
- package/dist/index3.js +96 -27
- package/dist/index3.js.map +1 -1
- package/dist/index30.js +16 -1080
- package/dist/index30.js.map +1 -1
- package/dist/index31.js +218 -16
- package/dist/index31.js.map +1 -1
- package/dist/index32.js +1081 -121
- package/dist/index32.js.map +1 -1
- package/dist/index33.js +17 -39
- package/dist/index33.js.map +1 -1
- package/dist/index34.js +121 -190
- package/dist/index34.js.map +1 -1
- package/dist/index35.js +37 -94
- package/dist/index35.js.map +1 -1
- package/dist/index36.js +186 -157
- package/dist/index36.js.map +1 -1
- package/dist/index37.js +89 -138
- package/dist/index37.js.map +1 -1
- package/dist/index38.js +161 -14
- package/dist/index38.js.map +1 -1
- package/dist/index39.js +146 -21
- package/dist/index39.js.map +1 -1
- package/dist/index4.js +26 -99
- package/dist/index4.js.map +1 -1
- package/dist/index40.js +12 -116
- package/dist/index40.js.map +1 -1
- package/dist/index41.js +18 -13
- package/dist/index41.js.map +1 -1
- package/dist/index42.js +21 -35
- package/dist/index42.js.map +1 -1
- package/dist/index43.js +117 -114
- package/dist/index43.js.map +1 -1
- package/dist/index44.js +13 -176
- package/dist/index44.js.map +1 -1
- package/dist/index45.js +34 -146
- package/dist/index45.js.map +1 -1
- package/dist/index46.js +116 -12
- package/dist/index46.js.map +1 -1
- package/dist/index47.js +176 -22
- package/dist/index47.js.map +1 -1
- package/dist/index48.js +147 -14
- package/dist/index48.js.map +1 -1
- package/dist/index49.js +10 -5
- package/dist/index49.js.map +1 -1
- package/dist/index5.js +100 -60
- package/dist/index5.js.map +1 -1
- package/dist/index50.js +21 -265
- package/dist/index50.js.map +1 -1
- package/dist/index51.js +10 -13
- package/dist/index51.js.map +1 -1
- package/dist/index52.js +7 -122
- package/dist/index52.js.map +1 -1
- package/dist/index53.js +262 -106
- package/dist/index53.js.map +1 -1
- package/dist/index54.js +14 -167
- package/dist/index54.js.map +1 -1
- package/dist/index55.js +121 -31
- package/dist/index55.js.map +1 -1
- package/dist/index56.js +107 -119
- package/dist/index56.js.map +1 -1
- package/dist/index57.js +161 -77
- package/dist/index57.js.map +1 -1
- package/dist/index58.js +31 -19
- package/dist/index58.js.map +1 -1
- package/dist/index59.js +117 -69
- package/dist/index59.js.map +1 -1
- package/dist/index6.js +61 -130
- package/dist/index6.js.map +1 -1
- package/dist/index60.js +82 -53
- package/dist/index60.js.map +1 -1
- package/dist/index61.js +19 -44
- package/dist/index61.js.map +1 -1
- package/dist/index62.js +70 -48
- package/dist/index62.js.map +1 -1
- package/dist/index63.js +55 -60
- package/dist/index63.js.map +1 -1
- package/dist/index64.js +39 -101
- package/dist/index64.js.map +1 -1
- package/dist/index65.js +52 -41
- package/dist/index65.js.map +1 -1
- package/dist/index66.js +58 -64
- package/dist/index66.js.map +1 -1
- package/dist/index67.js +105 -19
- package/dist/index67.js.map +1 -1
- package/dist/index68.js +41 -46
- package/dist/index68.js.map +1 -1
- package/dist/index69.js +63 -129
- package/dist/index69.js.map +1 -1
- package/dist/index7.js +130 -11
- package/dist/index7.js.map +1 -1
- package/dist/index70.js +19 -50
- package/dist/index70.js.map +1 -1
- package/dist/index71.js +46 -22
- package/dist/index71.js.map +1 -1
- package/dist/index72.js +134 -22
- package/dist/index72.js.map +1 -1
- package/dist/index73.js +51 -328
- package/dist/index73.js.map +1 -1
- package/dist/index74.js +19 -53
- package/dist/index74.js.map +1 -1
- package/dist/index75.js +31 -40
- package/dist/index75.js.map +1 -1
- package/dist/index76.js +22 -95
- package/dist/index76.js.map +1 -1
- package/dist/index77.js +311 -112
- package/dist/index77.js.map +1 -1
- package/dist/index78.js +52 -157
- package/dist/index78.js.map +1 -1
- package/dist/index79.js +40 -65
- package/dist/index79.js.map +1 -1
- package/dist/index8.js +11 -70
- package/dist/index8.js.map +1 -1
- package/dist/index80.js +23 -35
- package/dist/index80.js.map +1 -1
- package/dist/index81.js +88 -227
- package/dist/index81.js.map +1 -1
- package/dist/index82.js +130 -34
- package/dist/index82.js.map +1 -1
- package/dist/index83.js +153 -202
- package/dist/index83.js.map +1 -1
- package/dist/index84.js +61 -209
- package/dist/index84.js.map +1 -1
- package/dist/index85.js +34 -294
- package/dist/index85.js.map +1 -1
- package/dist/index86.js +228 -172
- package/dist/index86.js.map +1 -1
- package/dist/index87.js +32 -256
- package/dist/index87.js.map +1 -1
- package/dist/index88.js +208 -12
- package/dist/index88.js.map +1 -1
- package/dist/index89.js +209 -29
- package/dist/index89.js.map +1 -1
- package/dist/index9.js +69 -91
- package/dist/index9.js.map +1 -1
- package/dist/index90.js +294 -5
- package/dist/index90.js.map +1 -1
- package/dist/index91.js +176 -12
- package/dist/index91.js.map +1 -1
- package/dist/index92.js +256 -44
- package/dist/index92.js.map +1 -1
- package/dist/index93.js +13 -12
- package/dist/index93.js.map +1 -1
- package/dist/index94.js +32 -14
- package/dist/index94.js.map +1 -1
- package/dist/index95.js +5 -7
- package/dist/index95.js.map +1 -1
- package/dist/index96.js +13 -12
- package/dist/index96.js.map +1 -1
- package/dist/index97.js +42 -27
- package/dist/index97.js.map +1 -1
- package/dist/index98.js +11 -16
- package/dist/index98.js.map +1 -1
- package/dist/index99.js +12 -10790
- package/dist/index99.js.map +1 -1
- package/package.json +1 -1
package/dist/index101.js
CHANGED
|
@@ -1,45 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const m = [].slice.call(arguments, 1), i = m.length, g = typeof m[i - 1] == "function";
|
|
13
|
-
if (!g && !q())
|
|
14
|
-
throw new Error("Callback required as last argument");
|
|
15
|
-
if (g) {
|
|
16
|
-
if (i < 2)
|
|
17
|
-
throw new Error("Too few arguments provided");
|
|
18
|
-
i === 2 ? (o = r, r = e, e = n = void 0) : i === 3 && (e.getContext && typeof o > "u" ? (o = n, n = void 0) : (o = n, n = r, r = e, e = void 0));
|
|
19
|
-
} else {
|
|
20
|
-
if (i < 1)
|
|
21
|
-
throw new Error("Too few arguments provided");
|
|
22
|
-
return i === 1 ? (r = e, e = n = void 0) : i === 2 && !e.getContext && (n = r, r = e, e = void 0), new Promise(function(t, c) {
|
|
23
|
-
try {
|
|
24
|
-
const s = f.create(r, n);
|
|
25
|
-
t(d(s, e, n));
|
|
26
|
-
} catch (s) {
|
|
27
|
-
c(s);
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
try {
|
|
32
|
-
const t = f.create(r, n);
|
|
33
|
-
o(null, d(t, e, n));
|
|
34
|
-
} catch (t) {
|
|
35
|
-
o(t);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return u.create = f.create, u.toCanvas = a.bind(null, l.render), u.toDataURL = a.bind(null, l.renderToDataURL), u.toString = a.bind(null, function(d, e, r) {
|
|
39
|
-
return w.render(d, r);
|
|
40
|
-
}), u;
|
|
1
|
+
import { useState as u, useRef as v, useEffect as a } from "react";
|
|
2
|
+
function f() {
|
|
3
|
+
const [o, t] = u(!1), n = v(null);
|
|
4
|
+
return a(() => {
|
|
5
|
+
const e = n.current;
|
|
6
|
+
if (!e) return;
|
|
7
|
+
const r = () => t(!0), s = () => t(!1);
|
|
8
|
+
return e.addEventListener("mouseenter", r), e.addEventListener("mouseleave", s), () => {
|
|
9
|
+
e.removeEventListener("mouseenter", r), e.removeEventListener("mouseleave", s);
|
|
10
|
+
};
|
|
11
|
+
}, []), { ref: n, isHovered: o };
|
|
41
12
|
}
|
|
42
13
|
export {
|
|
43
|
-
|
|
14
|
+
f as useHover
|
|
44
15
|
};
|
|
45
16
|
//# sourceMappingURL=index101.js.map
|
package/dist/index101.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index101.js","sources":["
|
|
1
|
+
{"version":3,"file":"index101.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/index102.js
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
|
-
|
|
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);
|
|
18
|
+
};
|
|
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]);
|
|
29
|
+
}
|
|
2
30
|
export {
|
|
3
|
-
|
|
31
|
+
c as useKeyPress,
|
|
32
|
+
y as useKeyPressCallback
|
|
4
33
|
};
|
|
5
34
|
//# sourceMappingURL=index102.js.map
|
package/dist/index102.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index102.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
1
|
+
{"version":3,"file":"index102.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/index103.js
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
function
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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;
|
|
6
17
|
}
|
|
7
18
|
export {
|
|
8
|
-
|
|
19
|
+
r as useWindowSize
|
|
9
20
|
};
|
|
10
21
|
//# sourceMappingURL=index103.js.map
|
package/dist/index103.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index103.js","sources":["
|
|
1
|
+
{"version":3,"file":"index103.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;"}
|