@becklyn/next 4.2.6 → 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/dist/cjs/lib/debounce.d.ts +2 -0
  2. package/dist/cjs/lib/debounce.d.ts.map +1 -0
  3. package/dist/cjs/lib/debounce.js +13 -0
  4. package/dist/cjs/lib/fetcher.d.ts +2 -0
  5. package/dist/cjs/lib/fetcher.d.ts.map +1 -0
  6. package/dist/cjs/lib/fetcher.js +5 -0
  7. package/dist/cjs/lib/useDebounce.d.ts +6 -0
  8. package/dist/cjs/lib/useDebounce.d.ts.map +1 -0
  9. package/dist/cjs/lib/useDebounce.js +11 -0
  10. package/dist/cjs/lib/useInterval.d.ts +5 -0
  11. package/dist/cjs/lib/useInterval.d.ts.map +1 -0
  12. package/dist/cjs/lib/useInterval.js +40 -0
  13. package/dist/cjs/lib/useIsDocumentHidden.d.ts +2 -0
  14. package/dist/cjs/lib/useIsDocumentHidden.d.ts.map +1 -0
  15. package/dist/cjs/lib/useIsDocumentHidden.js +14 -0
  16. package/dist/cjs/lib/useScrollAway.d.ts +6 -0
  17. package/dist/cjs/lib/useScrollAway.d.ts.map +1 -0
  18. package/dist/cjs/lib/useScrollAway.js +47 -0
  19. package/dist/cjs/lib/useTimeout.d.ts +5 -0
  20. package/dist/cjs/lib/useTimeout.d.ts.map +1 -0
  21. package/dist/cjs/lib/useTimeout.js +27 -0
  22. package/dist/cjs/types/prettify.d.ts +4 -0
  23. package/dist/cjs/types/prettify.d.ts.map +1 -0
  24. package/dist/cjs/types/prettify.js +2 -0
  25. package/dist/es/lib/debounce.d.ts +2 -0
  26. package/dist/es/lib/debounce.d.ts.map +1 -0
  27. package/dist/es/lib/debounce.js +13 -0
  28. package/dist/es/lib/fetcher.d.ts +2 -0
  29. package/dist/es/lib/fetcher.d.ts.map +1 -0
  30. package/dist/es/lib/fetcher.js +5 -0
  31. package/dist/es/lib/useDebounce.d.ts +6 -0
  32. package/dist/es/lib/useDebounce.d.ts.map +1 -0
  33. package/dist/es/lib/useDebounce.js +11 -0
  34. package/dist/es/lib/useInterval.d.ts +5 -0
  35. package/dist/es/lib/useInterval.d.ts.map +1 -0
  36. package/dist/es/lib/useInterval.js +40 -0
  37. package/dist/es/lib/useIsDocumentHidden.d.ts +2 -0
  38. package/dist/es/lib/useIsDocumentHidden.d.ts.map +1 -0
  39. package/dist/es/lib/useIsDocumentHidden.js +14 -0
  40. package/dist/es/lib/useScrollAway.d.ts +6 -0
  41. package/dist/es/lib/useScrollAway.d.ts.map +1 -0
  42. package/dist/es/lib/useScrollAway.js +47 -0
  43. package/dist/es/lib/useTimeout.d.ts +5 -0
  44. package/dist/es/lib/useTimeout.d.ts.map +1 -0
  45. package/dist/es/lib/useTimeout.js +27 -0
  46. package/dist/es/types/prettify.d.ts +4 -0
  47. package/dist/es/types/prettify.d.ts.map +1 -0
  48. package/dist/es/types/prettify.js +2 -0
  49. package/package.json +11 -5
@@ -0,0 +1,2 @@
1
+ export declare const debounce: (func: () => void, wait: number) => (() => void);
2
+ //# sourceMappingURL=debounce.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debounce.d.ts","sourceRoot":"","sources":["../../../lib/debounce.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,GAAI,MAAM,MAAM,IAAI,EAAE,MAAM,MAAM,KAAG,CAAC,MAAM,IAAI,CAUpE,CAAC"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.debounce = void 0;
4
+ const debounce = (func, wait) => {
5
+ let timeout = null;
6
+ return () => {
7
+ if (timeout) {
8
+ clearTimeout(timeout);
9
+ }
10
+ timeout = setTimeout(func, wait);
11
+ };
12
+ };
13
+ exports.debounce = debounce;
@@ -0,0 +1,2 @@
1
+ export declare const fetcher: <T>(...args: Parameters<typeof fetch>) => Promise<T>;
2
+ //# sourceMappingURL=fetcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetcher.d.ts","sourceRoot":"","sources":["../../../lib/fetcher.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,GAAI,CAAC,EAAE,GAAG,MAAM,UAAU,CAAC,OAAO,KAAK,CAAC,KAAG,OAAO,CAAC,CAAC,CAC9B,CAAC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fetcher = void 0;
4
+ const fetcher = (...args) => fetch(...args).then(res => res.json());
5
+ exports.fetcher = fetcher;
@@ -0,0 +1,6 @@
1
+ import { DependencyList } from "react";
2
+ import { debounce } from "./debounce";
3
+ type Props = Parameters<typeof debounce>;
4
+ export declare const useDebounce: (fn: Props[0], ms: Props[1], deps?: DependencyList) => void;
5
+ export {};
6
+ //# sourceMappingURL=useDebounce.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDebounce.d.ts","sourceRoot":"","sources":["../../../lib/useDebounce.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAsB,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,KAAK,KAAK,GAAG,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC;AAEzC,eAAO,MAAM,WAAW,GAAI,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,cAAc,SAI5E,CAAC"}
@@ -0,0 +1,11 @@
1
+ "use client";
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useDebounce = void 0;
5
+ const react_1 = require("react");
6
+ const debounce_1 = require("./debounce");
7
+ const useDebounce = (fn, ms, deps) => {
8
+ const bounce = (0, react_1.useMemo)(() => (0, debounce_1.debounce)(fn, ms), [fn, ms]);
9
+ (0, react_1.useEffect)(() => (deps && Array.isArray(deps) ? bounce() : bounce()), [deps, bounce]);
10
+ };
11
+ exports.useDebounce = useDebounce;
@@ -0,0 +1,5 @@
1
+ export declare const useInterval: (callback: (executions: number) => void, interval: number, maxExecutions?: number) => {
2
+ startInterval: () => void;
3
+ cancelInterval: () => void;
4
+ };
5
+ //# sourceMappingURL=useInterval.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useInterval.d.ts","sourceRoot":"","sources":["../../../lib/useInterval.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,WAAW,GACpB,UAAU,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,EACtC,UAAU,MAAM,EAChB,gBAAgB,MAAM;;;CAyCzB,CAAC"}
@@ -0,0 +1,40 @@
1
+ "use client";
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useInterval = void 0;
5
+ const react_1 = require("react");
6
+ const useInterval = (callback, interval, maxExecutions) => {
7
+ const intervalRef = (0, react_1.useRef)(null);
8
+ const executions = (0, react_1.useRef)(0);
9
+ const startInterval = (0, react_1.useCallback)(() => {
10
+ if (intervalRef.current) {
11
+ clearInterval(intervalRef.current);
12
+ }
13
+ executions.current = 0;
14
+ intervalRef.current = setInterval(() => {
15
+ executions.current++;
16
+ callback(executions.current);
17
+ if (undefined !== maxExecutions && executions.current >= maxExecutions) {
18
+ if (intervalRef.current) {
19
+ clearInterval(intervalRef.current);
20
+ intervalRef.current = null;
21
+ }
22
+ }
23
+ }, interval);
24
+ }, [callback, interval, maxExecutions]);
25
+ const cancelInterval = (0, react_1.useCallback)(() => {
26
+ if (intervalRef.current) {
27
+ clearInterval(intervalRef.current);
28
+ intervalRef.current = null;
29
+ }
30
+ }, []);
31
+ (0, react_1.useEffect)(() => {
32
+ return () => {
33
+ if (intervalRef.current) {
34
+ clearInterval(intervalRef.current);
35
+ }
36
+ };
37
+ }, []);
38
+ return { startInterval, cancelInterval };
39
+ };
40
+ exports.useInterval = useInterval;
@@ -0,0 +1,2 @@
1
+ export declare const useIsDocumentHidden: () => boolean;
2
+ //# sourceMappingURL=useIsDocumentHidden.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useIsDocumentHidden.d.ts","sourceRoot":"","sources":["../../../lib/useIsDocumentHidden.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,mBAAmB,eAW/B,CAAC"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useIsDocumentHidden = void 0;
4
+ const react_1 = require("react");
5
+ const useIsDocumentHidden = () => {
6
+ const [isDocumentHidden, setIsDocumentHidden] = (0, react_1.useState)(document.hidden);
7
+ (0, react_1.useEffect)(() => {
8
+ const handleVisibilityChange = () => setIsDocumentHidden(document.hidden);
9
+ document.addEventListener("visibilitychange", handleVisibilityChange);
10
+ return () => document.removeEventListener("visibilitychange", handleVisibilityChange);
11
+ }, []);
12
+ return isDocumentHidden;
13
+ };
14
+ exports.useIsDocumentHidden = useIsDocumentHidden;
@@ -0,0 +1,6 @@
1
+ export declare const useScrollAway: (elementId: string, options?: {
2
+ scrollContainerQuery?: string;
3
+ elementHeight?: number;
4
+ reverseDirection?: boolean;
5
+ }) => void;
6
+ //# sourceMappingURL=useScrollAway.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useScrollAway.d.ts","sourceRoot":"","sources":["../../../lib/useScrollAway.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,aAAa,GACtB,WAAW,MAAM,EACjB,UAAU;IACN,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC9B,SAoDJ,CAAC"}
@@ -0,0 +1,47 @@
1
+ "use client";
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useScrollAway = void 0;
5
+ const react_1 = require("react");
6
+ const useScrollAway = (elementId, options) => {
7
+ (0, react_1.useEffect)(() => {
8
+ if (typeof document === "undefined") {
9
+ return;
10
+ }
11
+ const element = document.getElementById(elementId);
12
+ if (!element) {
13
+ return;
14
+ }
15
+ const { scrollContainerQuery, elementHeight, reverseDirection = false } = options || {};
16
+ const scrollContainer = scrollContainerQuery
17
+ ? document.querySelector(scrollContainerQuery)
18
+ : null;
19
+ const scrollAnchor = scrollContainer || document.documentElement;
20
+ const distanceToTransform = elementHeight !== null && elementHeight !== void 0 ? elementHeight : element.offsetHeight;
21
+ let lastScrollPosition = scrollAnchor.scrollTop;
22
+ let ticking = false;
23
+ const update = () => {
24
+ const currentScroll = scrollAnchor.scrollTop;
25
+ const isScrollingDown = currentScroll > lastScrollPosition;
26
+ const shouldHide = reverseDirection ? !isScrollingDown : isScrollingDown;
27
+ if (currentScroll >= distanceToTransform && shouldHide) {
28
+ element.style.transform = `translateY(${-distanceToTransform}px)`;
29
+ }
30
+ else {
31
+ element.style.transform = "translateY(0)";
32
+ }
33
+ lastScrollPosition = currentScroll;
34
+ ticking = false;
35
+ };
36
+ const handleScroll = () => {
37
+ if (!ticking) {
38
+ window.requestAnimationFrame(update);
39
+ ticking = true;
40
+ }
41
+ };
42
+ const targetElement = scrollContainer || window;
43
+ targetElement.addEventListener("scroll", handleScroll, { passive: true });
44
+ return () => targetElement.removeEventListener("scroll", handleScroll);
45
+ }, [elementId, options]);
46
+ };
47
+ exports.useScrollAway = useScrollAway;
@@ -0,0 +1,5 @@
1
+ export declare const useTimeout: (callback: (executions: number) => void, duration: number, maxExecutions?: number) => {
2
+ startTimeout: () => void;
3
+ cancelTimeout: () => void;
4
+ };
5
+ //# sourceMappingURL=useTimeout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTimeout.d.ts","sourceRoot":"","sources":["../../../lib/useTimeout.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,UAAU,GACnB,UAAU,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,EACtC,UAAU,MAAM,EAChB,gBAAgB,MAAM;;;CA0BzB,CAAC"}
@@ -0,0 +1,27 @@
1
+ "use client";
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useTimeout = void 0;
5
+ const react_1 = require("react");
6
+ const useTimeout = (callback, duration, maxExecutions) => {
7
+ const timeoutRef = (0, react_1.useRef)(null);
8
+ const executions = (0, react_1.useRef)(0);
9
+ const startTimeout = (0, react_1.useCallback)(() => {
10
+ if (undefined !== maxExecutions && maxExecutions <= executions.current) {
11
+ return;
12
+ }
13
+ executions.current++;
14
+ timeoutRef.current = setTimeout(() => {
15
+ callback(executions.current);
16
+ }, duration);
17
+ // eslint-disable-next-line react-hooks/exhaustive-deps
18
+ }, []);
19
+ const cancelTimeout = (0, react_1.useCallback)(() => {
20
+ if (timeoutRef.current) {
21
+ clearTimeout(timeoutRef.current);
22
+ timeoutRef.current = null;
23
+ }
24
+ }, []);
25
+ return { startTimeout, cancelTimeout };
26
+ };
27
+ exports.useTimeout = useTimeout;
@@ -0,0 +1,4 @@
1
+ export type Prettify<T> = {
2
+ [K in keyof T]: T[K];
3
+ } & {};
4
+ //# sourceMappingURL=prettify.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prettify.d.ts","sourceRoot":"","sources":["../../../types/prettify.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI;KACrB,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACvB,GAAG,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export declare const debounce: (func: () => void, wait: number) => (() => void);
2
+ //# sourceMappingURL=debounce.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debounce.d.ts","sourceRoot":"","sources":["../../../lib/debounce.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,GAAI,MAAM,MAAM,IAAI,EAAE,MAAM,MAAM,KAAG,CAAC,MAAM,IAAI,CAUpE,CAAC"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.debounce = void 0;
4
+ const debounce = (func, wait) => {
5
+ let timeout = null;
6
+ return () => {
7
+ if (timeout) {
8
+ clearTimeout(timeout);
9
+ }
10
+ timeout = setTimeout(func, wait);
11
+ };
12
+ };
13
+ exports.debounce = debounce;
@@ -0,0 +1,2 @@
1
+ export declare const fetcher: <T>(...args: Parameters<typeof fetch>) => Promise<T>;
2
+ //# sourceMappingURL=fetcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetcher.d.ts","sourceRoot":"","sources":["../../../lib/fetcher.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,GAAI,CAAC,EAAE,GAAG,MAAM,UAAU,CAAC,OAAO,KAAK,CAAC,KAAG,OAAO,CAAC,CAAC,CAC9B,CAAC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fetcher = void 0;
4
+ const fetcher = (...args) => fetch(...args).then(res => res.json());
5
+ exports.fetcher = fetcher;
@@ -0,0 +1,6 @@
1
+ import { DependencyList } from "react";
2
+ import { debounce } from "./debounce";
3
+ type Props = Parameters<typeof debounce>;
4
+ export declare const useDebounce: (fn: Props[0], ms: Props[1], deps?: DependencyList) => void;
5
+ export {};
6
+ //# sourceMappingURL=useDebounce.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDebounce.d.ts","sourceRoot":"","sources":["../../../lib/useDebounce.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAsB,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,KAAK,KAAK,GAAG,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC;AAEzC,eAAO,MAAM,WAAW,GAAI,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,cAAc,SAI5E,CAAC"}
@@ -0,0 +1,11 @@
1
+ "use client";
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useDebounce = void 0;
5
+ const react_1 = require("react");
6
+ const debounce_1 = require("./debounce");
7
+ const useDebounce = (fn, ms, deps) => {
8
+ const bounce = (0, react_1.useMemo)(() => (0, debounce_1.debounce)(fn, ms), [fn, ms]);
9
+ (0, react_1.useEffect)(() => (deps && Array.isArray(deps) ? bounce() : bounce()), [deps, bounce]);
10
+ };
11
+ exports.useDebounce = useDebounce;
@@ -0,0 +1,5 @@
1
+ export declare const useInterval: (callback: (executions: number) => void, interval: number, maxExecutions?: number) => {
2
+ startInterval: () => void;
3
+ cancelInterval: () => void;
4
+ };
5
+ //# sourceMappingURL=useInterval.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useInterval.d.ts","sourceRoot":"","sources":["../../../lib/useInterval.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,WAAW,GACpB,UAAU,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,EACtC,UAAU,MAAM,EAChB,gBAAgB,MAAM;;;CAyCzB,CAAC"}
@@ -0,0 +1,40 @@
1
+ "use client";
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useInterval = void 0;
5
+ const react_1 = require("react");
6
+ const useInterval = (callback, interval, maxExecutions) => {
7
+ const intervalRef = (0, react_1.useRef)(null);
8
+ const executions = (0, react_1.useRef)(0);
9
+ const startInterval = (0, react_1.useCallback)(() => {
10
+ if (intervalRef.current) {
11
+ clearInterval(intervalRef.current);
12
+ }
13
+ executions.current = 0;
14
+ intervalRef.current = setInterval(() => {
15
+ executions.current++;
16
+ callback(executions.current);
17
+ if (undefined !== maxExecutions && executions.current >= maxExecutions) {
18
+ if (intervalRef.current) {
19
+ clearInterval(intervalRef.current);
20
+ intervalRef.current = null;
21
+ }
22
+ }
23
+ }, interval);
24
+ }, [callback, interval, maxExecutions]);
25
+ const cancelInterval = (0, react_1.useCallback)(() => {
26
+ if (intervalRef.current) {
27
+ clearInterval(intervalRef.current);
28
+ intervalRef.current = null;
29
+ }
30
+ }, []);
31
+ (0, react_1.useEffect)(() => {
32
+ return () => {
33
+ if (intervalRef.current) {
34
+ clearInterval(intervalRef.current);
35
+ }
36
+ };
37
+ }, []);
38
+ return { startInterval, cancelInterval };
39
+ };
40
+ exports.useInterval = useInterval;
@@ -0,0 +1,2 @@
1
+ export declare const useIsDocumentHidden: () => boolean;
2
+ //# sourceMappingURL=useIsDocumentHidden.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useIsDocumentHidden.d.ts","sourceRoot":"","sources":["../../../lib/useIsDocumentHidden.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,mBAAmB,eAW/B,CAAC"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useIsDocumentHidden = void 0;
4
+ const react_1 = require("react");
5
+ const useIsDocumentHidden = () => {
6
+ const [isDocumentHidden, setIsDocumentHidden] = (0, react_1.useState)(document.hidden);
7
+ (0, react_1.useEffect)(() => {
8
+ const handleVisibilityChange = () => setIsDocumentHidden(document.hidden);
9
+ document.addEventListener("visibilitychange", handleVisibilityChange);
10
+ return () => document.removeEventListener("visibilitychange", handleVisibilityChange);
11
+ }, []);
12
+ return isDocumentHidden;
13
+ };
14
+ exports.useIsDocumentHidden = useIsDocumentHidden;
@@ -0,0 +1,6 @@
1
+ export declare const useScrollAway: (elementId: string, options?: {
2
+ scrollContainerQuery?: string;
3
+ elementHeight?: number;
4
+ reverseDirection?: boolean;
5
+ }) => void;
6
+ //# sourceMappingURL=useScrollAway.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useScrollAway.d.ts","sourceRoot":"","sources":["../../../lib/useScrollAway.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,aAAa,GACtB,WAAW,MAAM,EACjB,UAAU;IACN,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC9B,SAoDJ,CAAC"}
@@ -0,0 +1,47 @@
1
+ "use client";
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useScrollAway = void 0;
5
+ const react_1 = require("react");
6
+ const useScrollAway = (elementId, options) => {
7
+ (0, react_1.useEffect)(() => {
8
+ if (typeof document === "undefined") {
9
+ return;
10
+ }
11
+ const element = document.getElementById(elementId);
12
+ if (!element) {
13
+ return;
14
+ }
15
+ const { scrollContainerQuery, elementHeight, reverseDirection = false } = options || {};
16
+ const scrollContainer = scrollContainerQuery
17
+ ? document.querySelector(scrollContainerQuery)
18
+ : null;
19
+ const scrollAnchor = scrollContainer || document.documentElement;
20
+ const distanceToTransform = elementHeight ?? element.offsetHeight;
21
+ let lastScrollPosition = scrollAnchor.scrollTop;
22
+ let ticking = false;
23
+ const update = () => {
24
+ const currentScroll = scrollAnchor.scrollTop;
25
+ const isScrollingDown = currentScroll > lastScrollPosition;
26
+ const shouldHide = reverseDirection ? !isScrollingDown : isScrollingDown;
27
+ if (currentScroll >= distanceToTransform && shouldHide) {
28
+ element.style.transform = `translateY(${-distanceToTransform}px)`;
29
+ }
30
+ else {
31
+ element.style.transform = "translateY(0)";
32
+ }
33
+ lastScrollPosition = currentScroll;
34
+ ticking = false;
35
+ };
36
+ const handleScroll = () => {
37
+ if (!ticking) {
38
+ window.requestAnimationFrame(update);
39
+ ticking = true;
40
+ }
41
+ };
42
+ const targetElement = scrollContainer || window;
43
+ targetElement.addEventListener("scroll", handleScroll, { passive: true });
44
+ return () => targetElement.removeEventListener("scroll", handleScroll);
45
+ }, [elementId, options]);
46
+ };
47
+ exports.useScrollAway = useScrollAway;
@@ -0,0 +1,5 @@
1
+ export declare const useTimeout: (callback: (executions: number) => void, duration: number, maxExecutions?: number) => {
2
+ startTimeout: () => void;
3
+ cancelTimeout: () => void;
4
+ };
5
+ //# sourceMappingURL=useTimeout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTimeout.d.ts","sourceRoot":"","sources":["../../../lib/useTimeout.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,UAAU,GACnB,UAAU,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,EACtC,UAAU,MAAM,EAChB,gBAAgB,MAAM;;;CA0BzB,CAAC"}
@@ -0,0 +1,27 @@
1
+ "use client";
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useTimeout = void 0;
5
+ const react_1 = require("react");
6
+ const useTimeout = (callback, duration, maxExecutions) => {
7
+ const timeoutRef = (0, react_1.useRef)(null);
8
+ const executions = (0, react_1.useRef)(0);
9
+ const startTimeout = (0, react_1.useCallback)(() => {
10
+ if (undefined !== maxExecutions && maxExecutions <= executions.current) {
11
+ return;
12
+ }
13
+ executions.current++;
14
+ timeoutRef.current = setTimeout(() => {
15
+ callback(executions.current);
16
+ }, duration);
17
+ // eslint-disable-next-line react-hooks/exhaustive-deps
18
+ }, []);
19
+ const cancelTimeout = (0, react_1.useCallback)(() => {
20
+ if (timeoutRef.current) {
21
+ clearTimeout(timeoutRef.current);
22
+ timeoutRef.current = null;
23
+ }
24
+ }, []);
25
+ return { startTimeout, cancelTimeout };
26
+ };
27
+ exports.useTimeout = useTimeout;
@@ -0,0 +1,4 @@
1
+ export type Prettify<T> = {
2
+ [K in keyof T]: T[K];
3
+ } & {};
4
+ //# sourceMappingURL=prettify.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prettify.d.ts","sourceRoot":"","sources":["../../../types/prettify.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI;KACrB,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACvB,GAAG,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@becklyn/next",
3
- "version": "4.2.6",
3
+ "version": "4.3.0",
4
4
  "license": "MIT",
5
5
  "homepage": "https://github.com/Becklyn-Studios/ts-libs/tree/main/packages/next",
6
6
  "repository": {
@@ -16,17 +16,17 @@
16
16
  "dependencies": {
17
17
  "@contentful/rich-text-react-renderer": "^16.1.6",
18
18
  "keen-slider": "^6.8.6",
19
- "sass": "^1.97.0",
20
- "zod": "^4.2.1"
19
+ "sass": "^1.97.2",
20
+ "zod": "^4.3.5"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@becklyn/eslint": "*",
24
24
  "@becklyn/tsconfig": "*",
25
25
  "@contentful/rich-text-types": "^17.2.5",
26
- "@types/node": "^24.10.4",
26
+ "@types/node": "^25.0.3",
27
27
  "@types/react": "^19.2.7",
28
28
  "@types/react-dom": "^19.2.3",
29
- "next": "^16.0.10",
29
+ "next": "^16.1.1",
30
30
  "react": "^19.2.3",
31
31
  "typescript": "^5.9.3"
32
32
  },
@@ -46,6 +46,12 @@
46
46
  "import": "./dist/es/contentful/*.js",
47
47
  "default": "./dist/cjs/contentful/*.js"
48
48
  },
49
+ "./error/*": {
50
+ "types": "./dist/cjs/error/*.d.ts",
51
+ "require": "./dist/cjs/error/*.js",
52
+ "import": "./dist/es/error/*.js",
53
+ "default": "./dist/cjs/error/*.js"
54
+ },
49
55
  "./format/*": {
50
56
  "types": "./dist/cjs/format/*.d.ts",
51
57
  "require": "./dist/cjs/format/*.js",