@becklyn/next 4.2.4 → 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.
- package/dist/cjs/lib/debounce.d.ts +2 -0
- package/dist/cjs/lib/debounce.d.ts.map +1 -0
- package/dist/cjs/lib/debounce.js +13 -0
- package/dist/cjs/lib/fetcher.d.ts +2 -0
- package/dist/cjs/lib/fetcher.d.ts.map +1 -0
- package/dist/cjs/lib/fetcher.js +5 -0
- package/dist/cjs/lib/focusTrap.d.ts.map +1 -1
- package/dist/cjs/lib/focusTrap.js +1 -0
- package/dist/cjs/lib/isMounted.d.ts.map +1 -1
- package/dist/cjs/lib/isMounted.js +2 -0
- package/dist/cjs/lib/staticContent.d.ts.map +1 -1
- package/dist/cjs/lib/staticContent.js +1 -0
- package/dist/cjs/lib/useDebounce.d.ts +6 -0
- package/dist/cjs/lib/useDebounce.d.ts.map +1 -0
- package/dist/cjs/lib/useDebounce.js +11 -0
- package/dist/cjs/lib/useInterval.d.ts +5 -0
- package/dist/cjs/lib/useInterval.d.ts.map +1 -0
- package/dist/cjs/lib/useInterval.js +40 -0
- package/dist/cjs/lib/useIsDocumentHidden.d.ts +2 -0
- package/dist/cjs/lib/useIsDocumentHidden.d.ts.map +1 -0
- package/dist/cjs/lib/useIsDocumentHidden.js +14 -0
- package/dist/cjs/lib/useMediaQuery.d.ts.map +1 -1
- package/dist/cjs/lib/useMediaQuery.js +1 -0
- package/dist/cjs/lib/useScrollAway.d.ts +6 -0
- package/dist/cjs/lib/useScrollAway.d.ts.map +1 -0
- package/dist/cjs/lib/useScrollAway.js +47 -0
- package/dist/cjs/lib/useTimeout.d.ts +5 -0
- package/dist/cjs/lib/useTimeout.d.ts.map +1 -0
- package/dist/cjs/lib/useTimeout.js +27 -0
- package/dist/cjs/types/prettify.d.ts +4 -0
- package/dist/cjs/types/prettify.d.ts.map +1 -0
- package/dist/cjs/types/prettify.js +2 -0
- package/dist/es/lib/debounce.d.ts +2 -0
- package/dist/es/lib/debounce.d.ts.map +1 -0
- package/dist/es/lib/debounce.js +13 -0
- package/dist/es/lib/fetcher.d.ts +2 -0
- package/dist/es/lib/fetcher.d.ts.map +1 -0
- package/dist/es/lib/fetcher.js +5 -0
- package/dist/es/lib/focusTrap.d.ts.map +1 -1
- package/dist/es/lib/focusTrap.js +1 -0
- package/dist/es/lib/isMounted.d.ts.map +1 -1
- package/dist/es/lib/isMounted.js +2 -0
- package/dist/es/lib/staticContent.d.ts.map +1 -1
- package/dist/es/lib/staticContent.js +1 -0
- package/dist/es/lib/useDebounce.d.ts +6 -0
- package/dist/es/lib/useDebounce.d.ts.map +1 -0
- package/dist/es/lib/useDebounce.js +11 -0
- package/dist/es/lib/useInterval.d.ts +5 -0
- package/dist/es/lib/useInterval.d.ts.map +1 -0
- package/dist/es/lib/useInterval.js +40 -0
- package/dist/es/lib/useIsDocumentHidden.d.ts +2 -0
- package/dist/es/lib/useIsDocumentHidden.d.ts.map +1 -0
- package/dist/es/lib/useIsDocumentHidden.js +14 -0
- package/dist/es/lib/useMediaQuery.d.ts.map +1 -1
- package/dist/es/lib/useMediaQuery.js +1 -0
- package/dist/es/lib/useScrollAway.d.ts +6 -0
- package/dist/es/lib/useScrollAway.d.ts.map +1 -0
- package/dist/es/lib/useScrollAway.js +47 -0
- package/dist/es/lib/useTimeout.d.ts +5 -0
- package/dist/es/lib/useTimeout.d.ts.map +1 -0
- package/dist/es/lib/useTimeout.js +27 -0
- package/dist/es/types/prettify.d.ts +4 -0
- package/dist/es/types/prettify.d.ts.map +1 -0
- package/dist/es/types/prettify.js +2 -0
- package/package.json +12 -6
|
@@ -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 @@
|
|
|
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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"focusTrap.d.ts","sourceRoot":"","sources":["../../../lib/focusTrap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAA4C,MAAM,OAAO,CAAC;AAEnF,eAAO,MAAM,iBAAiB,GAAU,WAAW,CAAC,WAAW,GAAG,UAAU,CAAC,EAAE,kBAa9E,CAAC;AAEF,eAAO,MAAM,kBAAkB,kMACwJ,CAAC;AAExL,KAAK,YAAY,CAAC,CAAC,IAAI;IACnB,gBAAgB,CAAC,CAAC,GAAG,IAAI,CAAC;IAC1B;QACI,MAAM,EAAE,MAAM,IAAI,CAAC;KACtB;CACJ,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,WAAW,EAAE,YAAY,CAAC,GAAG,IAAI,KAAG,YAAY,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"focusTrap.d.ts","sourceRoot":"","sources":["../../../lib/focusTrap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAA4C,MAAM,OAAO,CAAC;AAEnF,eAAO,MAAM,iBAAiB,GAAU,WAAW,CAAC,WAAW,GAAG,UAAU,CAAC,EAAE,kBAa9E,CAAC;AAEF,eAAO,MAAM,kBAAkB,kMACwJ,CAAC;AAExL,KAAK,YAAY,CAAC,CAAC,IAAI;IACnB,gBAAgB,CAAC,CAAC,GAAG,IAAI,CAAC;IAC1B;QACI,MAAM,EAAE,MAAM,IAAI,CAAC;KACtB;CACJ,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,WAAW,EAAE,YAAY,CAAC,GAAG,IAAI,KAAG,YAAY,CAAC,CAAC,CA0DxF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isMounted.d.ts","sourceRoot":"","sources":["../../../lib/isMounted.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"isMounted.d.ts","sourceRoot":"","sources":["../../../lib/isMounted.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,eASxB,CAAC;AAEF,eAAO,MAAM,kBAAkB,eAS9B,CAAC"}
|
|
@@ -5,6 +5,7 @@ const react_1 = require("react");
|
|
|
5
5
|
const useIsMounted = () => {
|
|
6
6
|
const [isMounted, setIsMounted] = (0, react_1.useState)(false);
|
|
7
7
|
(0, react_1.useEffect)(() => {
|
|
8
|
+
// eslint-disable-next-line react-hooks/set-state-in-effect
|
|
8
9
|
setIsMounted(true);
|
|
9
10
|
}, []);
|
|
10
11
|
return isMounted;
|
|
@@ -13,6 +14,7 @@ exports.useIsMounted = useIsMounted;
|
|
|
13
14
|
const useIsLayoutMounted = () => {
|
|
14
15
|
const [isLayoutMounted, setIsLayoutMounted] = (0, react_1.useState)(false);
|
|
15
16
|
(0, react_1.useLayoutEffect)(() => {
|
|
17
|
+
// eslint-disable-next-line react-hooks/set-state-in-effect
|
|
16
18
|
setIsLayoutMounted(true);
|
|
17
19
|
}, []);
|
|
18
20
|
return isLayoutMounted;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"staticContent.d.ts","sourceRoot":"","sources":["../../../lib/staticContent.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,gBAAgB;eACO,MAAM;
|
|
1
|
+
{"version":3,"file":"staticContent.d.ts","sourceRoot":"","sources":["../../../lib/staticContent.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,gBAAgB;eACO,MAAM;YAczC,CAAC"}
|
|
@@ -11,6 +11,7 @@ const useStaticContent = () => {
|
|
|
11
11
|
// need to render the component without server-side backup
|
|
12
12
|
const isEmpty = ((_a = ref.current) === null || _a === void 0 ? void 0 : _a.innerHTML) === "";
|
|
13
13
|
if (isEmpty) {
|
|
14
|
+
// eslint-disable-next-line react-hooks/set-state-in-effect
|
|
14
15
|
setRender(true);
|
|
15
16
|
}
|
|
16
17
|
}, []);
|
|
@@ -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 @@
|
|
|
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 @@
|
|
|
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;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMediaQuery.d.ts","sourceRoot":"","sources":["../../../lib/useMediaQuery.ts"],"names":[],"mappings":"AAIA,KAAK,KAAK,GACJ,eAAe,MAAM,KAAK,GAC1B,eAAe,MAAM,KAAK,GAC1B,eAAe,MAAM,uBAAuB,MAAM,KAAK,CAAC;AAE9D;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,KAAK,KAAG,
|
|
1
|
+
{"version":3,"file":"useMediaQuery.d.ts","sourceRoot":"","sources":["../../../lib/useMediaQuery.ts"],"names":[],"mappings":"AAIA,KAAK,KAAK,GACJ,eAAe,MAAM,KAAK,GAC1B,eAAe,MAAM,KAAK,GAC1B,eAAe,MAAM,uBAAuB,MAAM,KAAK,CAAC;AAE9D;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,KAAK,KAAG,OAsC5C,CAAC"}
|
|
@@ -19,6 +19,7 @@ const useMediaQuery = (query) => {
|
|
|
19
19
|
}
|
|
20
20
|
const mediaQuery = window.matchMedia(query);
|
|
21
21
|
// Set initial value
|
|
22
|
+
// eslint-disable-next-line react-hooks/set-state-in-effect
|
|
22
23
|
setMatches(mediaQuery.matches);
|
|
23
24
|
currentMatches.current = mediaQuery.matches;
|
|
24
25
|
// Create event listener
|
|
@@ -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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"focusTrap.d.ts","sourceRoot":"","sources":["../../../lib/focusTrap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAA4C,MAAM,OAAO,CAAC;AAEnF,eAAO,MAAM,iBAAiB,GAAU,WAAW,CAAC,WAAW,GAAG,UAAU,CAAC,EAAE,kBAa9E,CAAC;AAEF,eAAO,MAAM,kBAAkB,kMACwJ,CAAC;AAExL,KAAK,YAAY,CAAC,CAAC,IAAI;IACnB,gBAAgB,CAAC,CAAC,GAAG,IAAI,CAAC;IAC1B;QACI,MAAM,EAAE,MAAM,IAAI,CAAC;KACtB;CACJ,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,WAAW,EAAE,YAAY,CAAC,GAAG,IAAI,KAAG,YAAY,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"focusTrap.d.ts","sourceRoot":"","sources":["../../../lib/focusTrap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAA4C,MAAM,OAAO,CAAC;AAEnF,eAAO,MAAM,iBAAiB,GAAU,WAAW,CAAC,WAAW,GAAG,UAAU,CAAC,EAAE,kBAa9E,CAAC;AAEF,eAAO,MAAM,kBAAkB,kMACwJ,CAAC;AAExL,KAAK,YAAY,CAAC,CAAC,IAAI;IACnB,gBAAgB,CAAC,CAAC,GAAG,IAAI,CAAC;IAC1B;QACI,MAAM,EAAE,MAAM,IAAI,CAAC;KACtB;CACJ,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,WAAW,EAAE,YAAY,CAAC,GAAG,IAAI,KAAG,YAAY,CAAC,CAAC,CA0DxF,CAAC"}
|
package/dist/es/lib/focusTrap.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isMounted.d.ts","sourceRoot":"","sources":["../../../lib/isMounted.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"isMounted.d.ts","sourceRoot":"","sources":["../../../lib/isMounted.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,eASxB,CAAC;AAEF,eAAO,MAAM,kBAAkB,eAS9B,CAAC"}
|
package/dist/es/lib/isMounted.js
CHANGED
|
@@ -5,6 +5,7 @@ const react_1 = require("react");
|
|
|
5
5
|
const useIsMounted = () => {
|
|
6
6
|
const [isMounted, setIsMounted] = (0, react_1.useState)(false);
|
|
7
7
|
(0, react_1.useEffect)(() => {
|
|
8
|
+
// eslint-disable-next-line react-hooks/set-state-in-effect
|
|
8
9
|
setIsMounted(true);
|
|
9
10
|
}, []);
|
|
10
11
|
return isMounted;
|
|
@@ -13,6 +14,7 @@ exports.useIsMounted = useIsMounted;
|
|
|
13
14
|
const useIsLayoutMounted = () => {
|
|
14
15
|
const [isLayoutMounted, setIsLayoutMounted] = (0, react_1.useState)(false);
|
|
15
16
|
(0, react_1.useLayoutEffect)(() => {
|
|
17
|
+
// eslint-disable-next-line react-hooks/set-state-in-effect
|
|
16
18
|
setIsLayoutMounted(true);
|
|
17
19
|
}, []);
|
|
18
20
|
return isLayoutMounted;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"staticContent.d.ts","sourceRoot":"","sources":["../../../lib/staticContent.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,gBAAgB;eACO,MAAM;
|
|
1
|
+
{"version":3,"file":"staticContent.d.ts","sourceRoot":"","sources":["../../../lib/staticContent.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,gBAAgB;eACO,MAAM;YAczC,CAAC"}
|
|
@@ -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 @@
|
|
|
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 @@
|
|
|
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;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMediaQuery.d.ts","sourceRoot":"","sources":["../../../lib/useMediaQuery.ts"],"names":[],"mappings":"AAIA,KAAK,KAAK,GACJ,eAAe,MAAM,KAAK,GAC1B,eAAe,MAAM,KAAK,GAC1B,eAAe,MAAM,uBAAuB,MAAM,KAAK,CAAC;AAE9D;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,KAAK,KAAG,
|
|
1
|
+
{"version":3,"file":"useMediaQuery.d.ts","sourceRoot":"","sources":["../../../lib/useMediaQuery.ts"],"names":[],"mappings":"AAIA,KAAK,KAAK,GACJ,eAAe,MAAM,KAAK,GAC1B,eAAe,MAAM,KAAK,GAC1B,eAAe,MAAM,uBAAuB,MAAM,KAAK,CAAC;AAE9D;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,KAAK,KAAG,OAsC5C,CAAC"}
|
|
@@ -19,6 +19,7 @@ const useMediaQuery = (query) => {
|
|
|
19
19
|
}
|
|
20
20
|
const mediaQuery = window.matchMedia(query);
|
|
21
21
|
// Set initial value
|
|
22
|
+
// eslint-disable-next-line react-hooks/set-state-in-effect
|
|
22
23
|
setMatches(mediaQuery.matches);
|
|
23
24
|
currentMatches.current = mediaQuery.matches;
|
|
24
25
|
// Create event listener
|
|
@@ -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 @@
|
|
|
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 @@
|
|
|
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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@becklyn/next",
|
|
3
|
-
"version": "4.
|
|
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,18 +16,18 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@contentful/rich-text-react-renderer": "^16.1.6",
|
|
18
18
|
"keen-slider": "^6.8.6",
|
|
19
|
-
"sass": "^1.
|
|
20
|
-
"zod": "^4.
|
|
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": "^
|
|
26
|
+
"@types/node": "^25.0.3",
|
|
27
27
|
"@types/react": "^19.2.7",
|
|
28
28
|
"@types/react-dom": "^19.2.3",
|
|
29
|
-
"next": "^
|
|
30
|
-
"react": "^19.2.
|
|
29
|
+
"next": "^16.1.1",
|
|
30
|
+
"react": "^19.2.3",
|
|
31
31
|
"typescript": "^5.9.3"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
@@ -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",
|