@zentauri-ui/zentauri-components 1.1.0 → 1.2.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/README.md +62 -21
- package/dist/chunk-2VQJ6OIL.js +31 -0
- package/dist/chunk-2VQJ6OIL.js.map +1 -0
- package/dist/chunk-73VCO5TE.mjs +29 -0
- package/dist/chunk-73VCO5TE.mjs.map +1 -0
- package/dist/chunk-BSWYZTYK.js +31 -0
- package/dist/chunk-BSWYZTYK.js.map +1 -0
- package/dist/chunk-CY5BQKRZ.mjs +29 -0
- package/dist/chunk-CY5BQKRZ.mjs.map +1 -0
- package/dist/chunk-DFEZH7TC.mjs +27 -0
- package/dist/chunk-DFEZH7TC.mjs.map +1 -0
- package/dist/chunk-FT2LMA66.mjs +25 -0
- package/dist/chunk-FT2LMA66.mjs.map +1 -0
- package/dist/chunk-JE3PD5ZA.js +107 -0
- package/dist/chunk-JE3PD5ZA.js.map +1 -0
- package/dist/chunk-JXCTEAXD.js +38 -0
- package/dist/chunk-JXCTEAXD.js.map +1 -0
- package/dist/chunk-LIJ6BDGP.mjs +36 -0
- package/dist/chunk-LIJ6BDGP.mjs.map +1 -0
- package/dist/chunk-PMAF6FBF.mjs +37 -0
- package/dist/chunk-PMAF6FBF.mjs.map +1 -0
- package/dist/chunk-TZ2JVWTZ.mjs +104 -0
- package/dist/chunk-TZ2JVWTZ.mjs.map +1 -0
- package/dist/chunk-UIYFEP3I.js +39 -0
- package/dist/chunk-UIYFEP3I.js.map +1 -0
- package/dist/chunk-UOZYPWDZ.js +32 -0
- package/dist/chunk-UOZYPWDZ.js.map +1 -0
- package/dist/chunk-WL5I7RVS.mjs +54 -0
- package/dist/chunk-WL5I7RVS.mjs.map +1 -0
- package/dist/chunk-WP7GYBRI.js +27 -0
- package/dist/chunk-WP7GYBRI.js.map +1 -0
- package/dist/chunk-YPLVTUYL.js +56 -0
- package/dist/chunk-YPLVTUYL.js.map +1 -0
- package/dist/hooks/useBodyScrollLock.d.mts +14 -0
- package/dist/hooks/useBodyScrollLock.d.ts +14 -0
- package/dist/hooks/useBodyScrollLock.js +13 -0
- package/dist/hooks/useBodyScrollLock.js.map +1 -0
- package/dist/hooks/useBodyScrollLock.mjs +4 -0
- package/dist/hooks/useBodyScrollLock.mjs.map +1 -0
- package/dist/hooks/useClickOutside.d.mts +23 -0
- package/dist/hooks/useClickOutside.d.ts +23 -0
- package/dist/hooks/useClickOutside.js +13 -0
- package/dist/hooks/useClickOutside.js.map +1 -0
- package/dist/hooks/useClickOutside.mjs +4 -0
- package/dist/hooks/useClickOutside.mjs.map +1 -0
- package/dist/hooks/useClipboard.d.mts +22 -0
- package/dist/hooks/useClipboard.d.ts +22 -0
- package/dist/hooks/useClipboard.js +51 -0
- package/dist/hooks/useClipboard.js.map +1 -0
- package/dist/hooks/useClipboard.mjs +49 -0
- package/dist/hooks/useClipboard.mjs.map +1 -0
- package/dist/hooks/useControllableState.d.mts +22 -0
- package/dist/hooks/useControllableState.d.ts +22 -0
- package/dist/hooks/useControllableState.js +13 -0
- package/dist/hooks/useControllableState.js.map +1 -0
- package/dist/hooks/useControllableState.mjs +4 -0
- package/dist/hooks/useControllableState.mjs.map +1 -0
- package/dist/hooks/useDebouncedValue.d.mts +14 -0
- package/dist/hooks/useDebouncedValue.d.ts +14 -0
- package/dist/hooks/useDebouncedValue.js +22 -0
- package/dist/hooks/useDebouncedValue.js.map +1 -0
- package/dist/hooks/useDebouncedValue.mjs +20 -0
- package/dist/hooks/useDebouncedValue.mjs.map +1 -0
- package/dist/hooks/useDisclosure.d.mts +25 -0
- package/dist/hooks/useDisclosure.d.ts +25 -0
- package/dist/hooks/useDisclosure.js +37 -0
- package/dist/hooks/useDisclosure.js.map +1 -0
- package/dist/hooks/useDisclosure.mjs +35 -0
- package/dist/hooks/useDisclosure.mjs.map +1 -0
- package/dist/hooks/useDocumentTitle.d.mts +19 -0
- package/dist/hooks/useDocumentTitle.d.ts +19 -0
- package/dist/hooks/useDocumentTitle.js +40 -0
- package/dist/hooks/useDocumentTitle.js.map +1 -0
- package/dist/hooks/useDocumentTitle.mjs +38 -0
- package/dist/hooks/useDocumentTitle.mjs.map +1 -0
- package/dist/hooks/useFocusManagement.d.mts +24 -0
- package/dist/hooks/useFocusManagement.d.ts +24 -0
- package/dist/hooks/useFocusManagement.js +14 -0
- package/dist/hooks/useFocusManagement.js.map +1 -0
- package/dist/hooks/useFocusManagement.mjs +5 -0
- package/dist/hooks/useFocusManagement.mjs.map +1 -0
- package/dist/hooks/useHover.d.mts +15 -0
- package/dist/hooks/useHover.d.ts +15 -0
- package/dist/hooks/useHover.js +37 -0
- package/dist/hooks/useHover.js.map +1 -0
- package/dist/hooks/useHover.mjs +35 -0
- package/dist/hooks/useHover.mjs.map +1 -0
- package/dist/hooks/useInView.d.mts +19 -0
- package/dist/hooks/useInView.d.ts +19 -0
- package/dist/hooks/useInView.js +15 -0
- package/dist/hooks/useInView.js.map +1 -0
- package/dist/hooks/useInView.mjs +13 -0
- package/dist/hooks/useInView.mjs.map +1 -0
- package/dist/hooks/useIntersectionObserver.d.mts +19 -0
- package/dist/hooks/useIntersectionObserver.d.ts +19 -0
- package/dist/hooks/useIntersectionObserver.js +13 -0
- package/dist/hooks/useIntersectionObserver.js.map +1 -0
- package/dist/hooks/useIntersectionObserver.mjs +4 -0
- package/dist/hooks/useIntersectionObserver.mjs.map +1 -0
- package/dist/hooks/useIsMounted.d.mts +11 -0
- package/dist/hooks/useIsMounted.d.ts +11 -0
- package/dist/hooks/useIsMounted.js +20 -0
- package/dist/hooks/useIsMounted.js.map +1 -0
- package/dist/hooks/useIsMounted.mjs +18 -0
- package/dist/hooks/useIsMounted.mjs.map +1 -0
- package/dist/hooks/useIsomorphicLayoutEffect.d.mts +11 -0
- package/dist/hooks/useIsomorphicLayoutEffect.d.ts +11 -0
- package/dist/hooks/useIsomorphicLayoutEffect.js +11 -0
- package/dist/hooks/useIsomorphicLayoutEffect.js.map +1 -0
- package/dist/hooks/useIsomorphicLayoutEffect.mjs +9 -0
- package/dist/hooks/useIsomorphicLayoutEffect.mjs.map +1 -0
- package/dist/hooks/useLocalStorage.d.mts +22 -0
- package/dist/hooks/useLocalStorage.d.ts +22 -0
- package/dist/hooks/useLocalStorage.js +84 -0
- package/dist/hooks/useLocalStorage.js.map +1 -0
- package/dist/hooks/useLocalStorage.mjs +82 -0
- package/dist/hooks/useLocalStorage.mjs.map +1 -0
- package/dist/hooks/useMediaQuery.d.mts +13 -0
- package/dist/hooks/useMediaQuery.d.ts +13 -0
- package/dist/hooks/useMediaQuery.js +13 -0
- package/dist/hooks/useMediaQuery.js.map +1 -0
- package/dist/hooks/useMediaQuery.mjs +4 -0
- package/dist/hooks/useMediaQuery.mjs.map +1 -0
- package/dist/hooks/useNetworkStatus.d.mts +10 -0
- package/dist/hooks/useNetworkStatus.d.ts +10 -0
- package/dist/hooks/useNetworkStatus.js +30 -0
- package/dist/hooks/useNetworkStatus.js.map +1 -0
- package/dist/hooks/useNetworkStatus.mjs +28 -0
- package/dist/hooks/useNetworkStatus.mjs.map +1 -0
- package/dist/hooks/usePageVisibility.d.mts +10 -0
- package/dist/hooks/usePageVisibility.d.ts +10 -0
- package/dist/hooks/usePageVisibility.js +28 -0
- package/dist/hooks/usePageVisibility.js.map +1 -0
- package/dist/hooks/usePageVisibility.mjs +26 -0
- package/dist/hooks/usePageVisibility.mjs.map +1 -0
- package/dist/hooks/usePagination.d.mts +5 -0
- package/dist/hooks/usePagination.d.ts +5 -0
- package/dist/hooks/usePagination.js +18 -0
- package/dist/hooks/usePagination.js.map +1 -0
- package/dist/hooks/usePagination.mjs +5 -0
- package/dist/hooks/usePagination.mjs.map +1 -0
- package/dist/hooks/usePrefersColorScheme.d.mts +10 -0
- package/dist/hooks/usePrefersColorScheme.d.ts +10 -0
- package/dist/hooks/usePrefersColorScheme.js +17 -0
- package/dist/hooks/usePrefersColorScheme.js.map +1 -0
- package/dist/hooks/usePrefersColorScheme.mjs +15 -0
- package/dist/hooks/usePrefersColorScheme.mjs.map +1 -0
- package/dist/hooks/usePrefersReducedMotion.d.mts +10 -0
- package/dist/hooks/usePrefersReducedMotion.d.ts +10 -0
- package/dist/hooks/usePrefersReducedMotion.js +13 -0
- package/dist/hooks/usePrefersReducedMotion.js.map +1 -0
- package/dist/hooks/usePrefersReducedMotion.mjs +11 -0
- package/dist/hooks/usePrefersReducedMotion.mjs.map +1 -0
- package/dist/hooks/useResizeObserver.d.mts +23 -0
- package/dist/hooks/useResizeObserver.d.ts +23 -0
- package/dist/hooks/useResizeObserver.js +38 -0
- package/dist/hooks/useResizeObserver.js.map +1 -0
- package/dist/hooks/useResizeObserver.mjs +36 -0
- package/dist/hooks/useResizeObserver.mjs.map +1 -0
- package/dist/hooks/useSessionStorage.d.mts +22 -0
- package/dist/hooks/useSessionStorage.d.ts +22 -0
- package/dist/hooks/useSessionStorage.js +58 -0
- package/dist/hooks/useSessionStorage.js.map +1 -0
- package/dist/hooks/useSessionStorage.mjs +56 -0
- package/dist/hooks/useSessionStorage.mjs.map +1 -0
- package/dist/hooks/useThrottledCallback.d.mts +14 -0
- package/dist/hooks/useThrottledCallback.d.ts +14 -0
- package/dist/hooks/useThrottledCallback.js +27 -0
- package/dist/hooks/useThrottledCallback.js.map +1 -0
- package/dist/hooks/useThrottledCallback.mjs +25 -0
- package/dist/hooks/useThrottledCallback.mjs.map +1 -0
- package/dist/hooks/useToggle.d.mts +9 -0
- package/dist/hooks/useToggle.d.ts +9 -0
- package/dist/hooks/useToggle.js +20 -0
- package/dist/hooks/useToggle.js.map +1 -0
- package/dist/hooks/useToggle.mjs +18 -0
- package/dist/hooks/useToggle.mjs.map +1 -0
- package/dist/hooks/useWindowSize.d.mts +14 -0
- package/dist/hooks/useWindowSize.d.ts +14 -0
- package/dist/hooks/useWindowSize.js +30 -0
- package/dist/hooks/useWindowSize.js.map +1 -0
- package/dist/hooks/useWindowSize.mjs +28 -0
- package/dist/hooks/useWindowSize.mjs.map +1 -0
- package/dist/hooks/utils.d.mts +8 -0
- package/dist/hooks/utils.d.ts +8 -0
- package/dist/hooks/utils.js +24 -0
- package/dist/hooks/utils.js.map +1 -0
- package/dist/hooks/utils.mjs +3 -0
- package/dist/hooks/utils.mjs.map +1 -0
- package/dist/index-ClPu5gDp.d.ts +86 -0
- package/dist/index-D4p9fn1o.d.mts +86 -0
- package/dist/ui/accordion.js +5 -5
- package/dist/ui/accordion.mjs +1 -1
- package/dist/ui/alert.js +7 -7
- package/dist/ui/alert.mjs +1 -1
- package/dist/ui/avatar.js +6 -6
- package/dist/ui/avatar.js.map +1 -1
- package/dist/ui/avatar.mjs +1 -1
- package/dist/ui/avatar.mjs.map +1 -1
- package/dist/ui/badge.js +2 -2
- package/dist/ui/badge.mjs +1 -1
- package/dist/ui/breadcrumb.js +7 -7
- package/dist/ui/breadcrumb.mjs +1 -1
- package/dist/ui/buttons.js +3 -3
- package/dist/ui/buttons.mjs +1 -1
- package/dist/ui/card.js +7 -7
- package/dist/ui/card.js.map +1 -1
- package/dist/ui/card.mjs +1 -1
- package/dist/ui/card.mjs.map +1 -1
- package/dist/ui/divider.js +6 -6
- package/dist/ui/divider.mjs +1 -1
- package/dist/ui/drawer.js +15 -60
- package/dist/ui/drawer.js.map +1 -1
- package/dist/ui/drawer.mjs +9 -54
- package/dist/ui/drawer.mjs.map +1 -1
- package/dist/ui/dropdown.js +6 -13
- package/dist/ui/dropdown.js.map +1 -1
- package/dist/ui/dropdown.mjs +4 -11
- package/dist/ui/dropdown.mjs.map +1 -1
- package/dist/ui/empty-state.js +6 -6
- package/dist/ui/empty-state.js.map +1 -1
- package/dist/ui/empty-state.mjs +1 -1
- package/dist/ui/empty-state.mjs.map +1 -1
- package/dist/ui/file-upload.js +3 -3
- package/dist/ui/file-upload.mjs +1 -1
- package/dist/ui/inputs.js +3 -3
- package/dist/ui/inputs.mjs +1 -1
- package/dist/ui/modal.js +16 -61
- package/dist/ui/modal.js.map +1 -1
- package/dist/ui/modal.mjs +9 -54
- package/dist/ui/modal.mjs.map +1 -1
- package/dist/ui/pagination.d.mts +3 -81
- package/dist/ui/pagination.d.ts +3 -81
- package/dist/ui/pagination.js +13 -122
- package/dist/ui/pagination.js.map +1 -1
- package/dist/ui/pagination.mjs +5 -114
- package/dist/ui/pagination.mjs.map +1 -1
- package/dist/ui/progress.js +7 -10
- package/dist/ui/progress.js.map +1 -1
- package/dist/ui/progress.mjs +1 -4
- package/dist/ui/progress.mjs.map +1 -1
- package/dist/ui/select.js +6 -6
- package/dist/ui/select.mjs +1 -1
- package/dist/ui/skeleton.js +7 -7
- package/dist/ui/skeleton.mjs +1 -1
- package/dist/ui/slider.js +9 -9
- package/dist/ui/slider.js.map +1 -1
- package/dist/ui/slider.mjs +1 -1
- package/dist/ui/slider.mjs.map +1 -1
- package/dist/ui/spinner.js +24 -10
- package/dist/ui/spinner.js.map +1 -1
- package/dist/ui/spinner.mjs +17 -3
- package/dist/ui/spinner.mjs.map +1 -1
- package/dist/ui/stepper.js +6 -6
- package/dist/ui/stepper.mjs +1 -1
- package/dist/ui/table.js +9 -9
- package/dist/ui/table.js.map +1 -1
- package/dist/ui/table.mjs +1 -1
- package/dist/ui/table.mjs.map +1 -1
- package/dist/ui/tabs.js +5 -5
- package/dist/ui/tabs.mjs +1 -1
- package/dist/ui/toast.js +7 -7
- package/dist/ui/toast.js.map +1 -1
- package/dist/ui/toast.mjs +1 -1
- package/dist/ui/toast.mjs.map +1 -1
- package/dist/ui/toggle.js +3 -3
- package/dist/ui/toggle.mjs +1 -1
- package/dist/ui/tooltip.js +2 -2
- package/dist/ui/tooltip.mjs +1 -1
- package/package.json +7 -2
- package/dist/chunk-B23TPTVG.mjs +0 -11
- package/dist/chunk-B23TPTVG.mjs.map +0 -1
- package/dist/chunk-WZ2GOU2J.js +0 -13
- package/dist/chunk-WZ2GOU2J.js.map +0 -1
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var react = require('react');
|
|
5
|
+
|
|
6
|
+
// src/hooks/useSessionStorage/useSessionStorage.ts
|
|
7
|
+
function readValue(key, fallback) {
|
|
8
|
+
if (typeof window === "undefined") {
|
|
9
|
+
return fallback;
|
|
10
|
+
}
|
|
11
|
+
try {
|
|
12
|
+
const raw = window.sessionStorage.getItem(key);
|
|
13
|
+
if (raw == null) {
|
|
14
|
+
return fallback;
|
|
15
|
+
}
|
|
16
|
+
return JSON.parse(raw);
|
|
17
|
+
} catch {
|
|
18
|
+
return fallback;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function useSessionStorage(key, initialValue) {
|
|
22
|
+
const [stored, setStored] = react.useState(initialValue);
|
|
23
|
+
const setValue = react.useCallback(
|
|
24
|
+
(value) => {
|
|
25
|
+
setStored((previous) => {
|
|
26
|
+
const next = typeof value === "function" ? value(previous) : value;
|
|
27
|
+
try {
|
|
28
|
+
if (typeof window !== "undefined") {
|
|
29
|
+
window.sessionStorage.setItem(key, JSON.stringify(next));
|
|
30
|
+
}
|
|
31
|
+
} catch {
|
|
32
|
+
}
|
|
33
|
+
return next;
|
|
34
|
+
});
|
|
35
|
+
},
|
|
36
|
+
[key]
|
|
37
|
+
);
|
|
38
|
+
const remove = react.useCallback(() => {
|
|
39
|
+
try {
|
|
40
|
+
if (typeof window !== "undefined") {
|
|
41
|
+
window.sessionStorage.removeItem(key);
|
|
42
|
+
}
|
|
43
|
+
} catch {
|
|
44
|
+
}
|
|
45
|
+
setStored(initialValue);
|
|
46
|
+
}, [initialValue, key]);
|
|
47
|
+
react.useEffect(() => {
|
|
48
|
+
const next = readValue(key, initialValue);
|
|
49
|
+
setStored((prev) => {
|
|
50
|
+
return JSON.stringify(prev) === JSON.stringify(next) ? prev : next;
|
|
51
|
+
});
|
|
52
|
+
}, [key]);
|
|
53
|
+
return [stored, setValue, remove];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
exports.useSessionStorage = useSessionStorage;
|
|
57
|
+
//# sourceMappingURL=useSessionStorage.js.map
|
|
58
|
+
//# sourceMappingURL=useSessionStorage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/useSessionStorage/useSessionStorage.ts"],"names":["useState","useCallback","useEffect"],"mappings":";;;;;AAIA,SAAS,SAAA,CAAa,KAAa,QAAA,EAAgB;AACjD,EAAA,IAAI,OAAO,WAAW,WAAA,EAAa;AACjC,IAAA,OAAO,QAAA;AAAA,EACT;AACA,EAAA,IAAI;AACF,IAAA,MAAM,GAAA,GAAM,MAAA,CAAO,cAAA,CAAe,OAAA,CAAQ,GAAG,CAAA;AAC7C,IAAA,IAAI,OAAO,IAAA,EAAM;AACf,MAAA,OAAO,QAAA;AAAA,IACT;AACA,IAAA,OAAO,IAAA,CAAK,MAAM,GAAG,CAAA;AAAA,EACvB,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,QAAA;AAAA,EACT;AACF;AAsBO,SAAS,iBAAA,CACd,KACA,YAAA,EAC4B;AAC5B,EAAA,MAAM,CAAC,MAAA,EAAQ,SAAS,CAAA,GAAIA,eAAY,YAAY,CAAA;AAEpD,EAAA,MAAM,QAAA,GAAWC,iBAAA;AAAA,IACf,CAAC,KAAA,KAAoC;AACnC,MAAA,SAAA,CAAU,CAAC,QAAA,KAAa;AACtB,QAAA,MAAM,OACJ,OAAO,KAAA,KAAU,UAAA,GAAc,KAAA,CAAsB,QAAQ,CAAA,GAAI,KAAA;AACnE,QAAA,IAAI;AACF,UAAA,IAAI,OAAO,WAAW,WAAA,EAAa;AACjC,YAAA,MAAA,CAAO,eAAe,OAAA,CAAQ,GAAA,EAAK,IAAA,CAAK,SAAA,CAAU,IAAI,CAAC,CAAA;AAAA,UACzD;AAAA,QACF,CAAA,CAAA,MAAQ;AAAA,QAER;AACA,QAAA,OAAO,IAAA;AAAA,MACT,CAAC,CAAA;AAAA,IACH,CAAA;AAAA,IACA,CAAC,GAAG;AAAA,GACN;AAEA,EAAA,MAAM,MAAA,GAASA,kBAAY,MAAM;AAC/B,IAAA,IAAI;AACF,MAAA,IAAI,OAAO,WAAW,WAAA,EAAa;AACjC,QAAA,MAAA,CAAO,cAAA,CAAe,WAAW,GAAG,CAAA;AAAA,MACtC;AAAA,IACF,CAAA,CAAA,MAAQ;AAAA,IAER;AACA,IAAA,SAAA,CAAU,YAAY,CAAA;AAAA,EACxB,CAAA,EAAG,CAAC,YAAA,EAAc,GAAG,CAAC,CAAA;AAEtB,EAAAC,eAAA,CAAU,MAAM;AACd,IAAA,MAAM,IAAA,GAAO,SAAA,CAAU,GAAA,EAAK,YAAY,CAAA;AAExC,IAAA,SAAA,CAAU,CAAC,IAAA,KAAS;AAClB,MAAA,OAAO,IAAA,CAAK,UAAU,IAAI,CAAA,KAAM,KAAK,SAAA,CAAU,IAAI,IAAI,IAAA,GAAO,IAAA;AAAA,IAChE,CAAC,CAAA;AAAA,EACH,CAAA,EAAG,CAAC,GAAG,CAAC,CAAA;AAER,EAAA,OAAO,CAAC,MAAA,EAAQ,QAAA,EAAU,MAAM,CAAA;AAClC","file":"useSessionStorage.js","sourcesContent":["\"use client\";\n\nimport { useCallback, useEffect, useState } from \"react\";\n\nfunction readValue<T>(key: string, fallback: T): T {\n if (typeof window === \"undefined\") {\n return fallback;\n }\n try {\n const raw = window.sessionStorage.getItem(key);\n if (raw == null) {\n return fallback;\n }\n return JSON.parse(raw) as T;\n } catch {\n return fallback;\n }\n}\n\nexport type UseSessionStorageResult<T> = [\n T,\n (value: T | ((previous: T) => T)) => void,\n () => void,\n];\n\n/**\n * Syncs JSON-serialized state with `window.sessionStorage` for the lifetime of the browser tab.\n *\n * Same persistence semantics as {@link useLocalStorage} but scoped to the session: data clears when the tab closes.\n * Unlike `useLocalStorage`, this hook does **not** subscribe to `storage` events (session storage is not shared across tabs).\n *\n * State is initialized from `initialValue` only so the first client render can match SSR output; the stored value is\n * applied after mount in an effect to avoid hydration mismatches.\n *\n * @typeParam T - Stored value type; must round-trip through `JSON.stringify` / `parse`.\n * @param key - `sessionStorage` key.\n * @param initialValue - Fallback when missing, invalid JSON, or during SSR; also used for the first render before hydrate.\n * @returns `[stored, setValue, remove]` tuple.\n */\nexport function useSessionStorage<T>(\n key: string,\n initialValue: T,\n): UseSessionStorageResult<T> {\n const [stored, setStored] = useState<T>(initialValue);\n\n const setValue = useCallback(\n (value: T | ((previous: T) => T)) => {\n setStored((previous) => {\n const next =\n typeof value === \"function\" ? (value as (p: T) => T)(previous) : value;\n try {\n if (typeof window !== \"undefined\") {\n window.sessionStorage.setItem(key, JSON.stringify(next));\n }\n } catch {\n /* quota or private mode */\n }\n return next;\n });\n },\n [key],\n );\n\n const remove = useCallback(() => {\n try {\n if (typeof window !== \"undefined\") {\n window.sessionStorage.removeItem(key);\n }\n } catch {\n /* ignore */\n }\n setStored(initialValue);\n }, [initialValue, key]);\n\n useEffect(() => {\n const next = readValue(key, initialValue);\n \n setStored((prev) => {\n return JSON.stringify(prev) === JSON.stringify(next) ? prev : next;\n });\n }, [key]);\n\n return [stored, setValue, remove];\n}\n"]}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useState, useCallback, useEffect } from 'react';
|
|
3
|
+
|
|
4
|
+
// src/hooks/useSessionStorage/useSessionStorage.ts
|
|
5
|
+
function readValue(key, fallback) {
|
|
6
|
+
if (typeof window === "undefined") {
|
|
7
|
+
return fallback;
|
|
8
|
+
}
|
|
9
|
+
try {
|
|
10
|
+
const raw = window.sessionStorage.getItem(key);
|
|
11
|
+
if (raw == null) {
|
|
12
|
+
return fallback;
|
|
13
|
+
}
|
|
14
|
+
return JSON.parse(raw);
|
|
15
|
+
} catch {
|
|
16
|
+
return fallback;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function useSessionStorage(key, initialValue) {
|
|
20
|
+
const [stored, setStored] = useState(initialValue);
|
|
21
|
+
const setValue = useCallback(
|
|
22
|
+
(value) => {
|
|
23
|
+
setStored((previous) => {
|
|
24
|
+
const next = typeof value === "function" ? value(previous) : value;
|
|
25
|
+
try {
|
|
26
|
+
if (typeof window !== "undefined") {
|
|
27
|
+
window.sessionStorage.setItem(key, JSON.stringify(next));
|
|
28
|
+
}
|
|
29
|
+
} catch {
|
|
30
|
+
}
|
|
31
|
+
return next;
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
[key]
|
|
35
|
+
);
|
|
36
|
+
const remove = useCallback(() => {
|
|
37
|
+
try {
|
|
38
|
+
if (typeof window !== "undefined") {
|
|
39
|
+
window.sessionStorage.removeItem(key);
|
|
40
|
+
}
|
|
41
|
+
} catch {
|
|
42
|
+
}
|
|
43
|
+
setStored(initialValue);
|
|
44
|
+
}, [initialValue, key]);
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
const next = readValue(key, initialValue);
|
|
47
|
+
setStored((prev) => {
|
|
48
|
+
return JSON.stringify(prev) === JSON.stringify(next) ? prev : next;
|
|
49
|
+
});
|
|
50
|
+
}, [key]);
|
|
51
|
+
return [stored, setValue, remove];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export { useSessionStorage };
|
|
55
|
+
//# sourceMappingURL=useSessionStorage.mjs.map
|
|
56
|
+
//# sourceMappingURL=useSessionStorage.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/useSessionStorage/useSessionStorage.ts"],"names":[],"mappings":";;;AAIA,SAAS,SAAA,CAAa,KAAa,QAAA,EAAgB;AACjD,EAAA,IAAI,OAAO,WAAW,WAAA,EAAa;AACjC,IAAA,OAAO,QAAA;AAAA,EACT;AACA,EAAA,IAAI;AACF,IAAA,MAAM,GAAA,GAAM,MAAA,CAAO,cAAA,CAAe,OAAA,CAAQ,GAAG,CAAA;AAC7C,IAAA,IAAI,OAAO,IAAA,EAAM;AACf,MAAA,OAAO,QAAA;AAAA,IACT;AACA,IAAA,OAAO,IAAA,CAAK,MAAM,GAAG,CAAA;AAAA,EACvB,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,QAAA;AAAA,EACT;AACF;AAsBO,SAAS,iBAAA,CACd,KACA,YAAA,EAC4B;AAC5B,EAAA,MAAM,CAAC,MAAA,EAAQ,SAAS,CAAA,GAAI,SAAY,YAAY,CAAA;AAEpD,EAAA,MAAM,QAAA,GAAW,WAAA;AAAA,IACf,CAAC,KAAA,KAAoC;AACnC,MAAA,SAAA,CAAU,CAAC,QAAA,KAAa;AACtB,QAAA,MAAM,OACJ,OAAO,KAAA,KAAU,UAAA,GAAc,KAAA,CAAsB,QAAQ,CAAA,GAAI,KAAA;AACnE,QAAA,IAAI;AACF,UAAA,IAAI,OAAO,WAAW,WAAA,EAAa;AACjC,YAAA,MAAA,CAAO,eAAe,OAAA,CAAQ,GAAA,EAAK,IAAA,CAAK,SAAA,CAAU,IAAI,CAAC,CAAA;AAAA,UACzD;AAAA,QACF,CAAA,CAAA,MAAQ;AAAA,QAER;AACA,QAAA,OAAO,IAAA;AAAA,MACT,CAAC,CAAA;AAAA,IACH,CAAA;AAAA,IACA,CAAC,GAAG;AAAA,GACN;AAEA,EAAA,MAAM,MAAA,GAAS,YAAY,MAAM;AAC/B,IAAA,IAAI;AACF,MAAA,IAAI,OAAO,WAAW,WAAA,EAAa;AACjC,QAAA,MAAA,CAAO,cAAA,CAAe,WAAW,GAAG,CAAA;AAAA,MACtC;AAAA,IACF,CAAA,CAAA,MAAQ;AAAA,IAER;AACA,IAAA,SAAA,CAAU,YAAY,CAAA;AAAA,EACxB,CAAA,EAAG,CAAC,YAAA,EAAc,GAAG,CAAC,CAAA;AAEtB,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,MAAM,IAAA,GAAO,SAAA,CAAU,GAAA,EAAK,YAAY,CAAA;AAExC,IAAA,SAAA,CAAU,CAAC,IAAA,KAAS;AAClB,MAAA,OAAO,IAAA,CAAK,UAAU,IAAI,CAAA,KAAM,KAAK,SAAA,CAAU,IAAI,IAAI,IAAA,GAAO,IAAA;AAAA,IAChE,CAAC,CAAA;AAAA,EACH,CAAA,EAAG,CAAC,GAAG,CAAC,CAAA;AAER,EAAA,OAAO,CAAC,MAAA,EAAQ,QAAA,EAAU,MAAM,CAAA;AAClC","file":"useSessionStorage.mjs","sourcesContent":["\"use client\";\n\nimport { useCallback, useEffect, useState } from \"react\";\n\nfunction readValue<T>(key: string, fallback: T): T {\n if (typeof window === \"undefined\") {\n return fallback;\n }\n try {\n const raw = window.sessionStorage.getItem(key);\n if (raw == null) {\n return fallback;\n }\n return JSON.parse(raw) as T;\n } catch {\n return fallback;\n }\n}\n\nexport type UseSessionStorageResult<T> = [\n T,\n (value: T | ((previous: T) => T)) => void,\n () => void,\n];\n\n/**\n * Syncs JSON-serialized state with `window.sessionStorage` for the lifetime of the browser tab.\n *\n * Same persistence semantics as {@link useLocalStorage} but scoped to the session: data clears when the tab closes.\n * Unlike `useLocalStorage`, this hook does **not** subscribe to `storage` events (session storage is not shared across tabs).\n *\n * State is initialized from `initialValue` only so the first client render can match SSR output; the stored value is\n * applied after mount in an effect to avoid hydration mismatches.\n *\n * @typeParam T - Stored value type; must round-trip through `JSON.stringify` / `parse`.\n * @param key - `sessionStorage` key.\n * @param initialValue - Fallback when missing, invalid JSON, or during SSR; also used for the first render before hydrate.\n * @returns `[stored, setValue, remove]` tuple.\n */\nexport function useSessionStorage<T>(\n key: string,\n initialValue: T,\n): UseSessionStorageResult<T> {\n const [stored, setStored] = useState<T>(initialValue);\n\n const setValue = useCallback(\n (value: T | ((previous: T) => T)) => {\n setStored((previous) => {\n const next =\n typeof value === \"function\" ? (value as (p: T) => T)(previous) : value;\n try {\n if (typeof window !== \"undefined\") {\n window.sessionStorage.setItem(key, JSON.stringify(next));\n }\n } catch {\n /* quota or private mode */\n }\n return next;\n });\n },\n [key],\n );\n\n const remove = useCallback(() => {\n try {\n if (typeof window !== \"undefined\") {\n window.sessionStorage.removeItem(key);\n }\n } catch {\n /* ignore */\n }\n setStored(initialValue);\n }, [initialValue, key]);\n\n useEffect(() => {\n const next = readValue(key, initialValue);\n \n setStored((prev) => {\n return JSON.stringify(prev) === JSON.stringify(next) ? prev : next;\n });\n }, [key]);\n\n return [stored, setValue, remove];\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a stable, throttled version of `callback` that runs at most once per `intervalMs`.
|
|
3
|
+
*
|
|
4
|
+
* If invoked again inside the cooldown window, the extra calls are **dropped** (no trailing flush). The latest
|
|
5
|
+
* `callback` reference is always used via a ref, so changing the handler does not reset the throttle clock.
|
|
6
|
+
*
|
|
7
|
+
* @typeParam T - Void function type (`(...args) => void`).
|
|
8
|
+
* @param callback - Work to run when the throttle gate opens.
|
|
9
|
+
* @param intervalMs - Minimum milliseconds between invocations.
|
|
10
|
+
* @returns Throttled function with the same call signature as `callback`.
|
|
11
|
+
*/
|
|
12
|
+
declare function useThrottledCallback<T extends (...args: any[]) => void>(callback: T, intervalMs: number): T;
|
|
13
|
+
|
|
14
|
+
export { useThrottledCallback };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a stable, throttled version of `callback` that runs at most once per `intervalMs`.
|
|
3
|
+
*
|
|
4
|
+
* If invoked again inside the cooldown window, the extra calls are **dropped** (no trailing flush). The latest
|
|
5
|
+
* `callback` reference is always used via a ref, so changing the handler does not reset the throttle clock.
|
|
6
|
+
*
|
|
7
|
+
* @typeParam T - Void function type (`(...args) => void`).
|
|
8
|
+
* @param callback - Work to run when the throttle gate opens.
|
|
9
|
+
* @param intervalMs - Minimum milliseconds between invocations.
|
|
10
|
+
* @returns Throttled function with the same call signature as `callback`.
|
|
11
|
+
*/
|
|
12
|
+
declare function useThrottledCallback<T extends (...args: any[]) => void>(callback: T, intervalMs: number): T;
|
|
13
|
+
|
|
14
|
+
export { useThrottledCallback };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var react = require('react');
|
|
5
|
+
|
|
6
|
+
// src/hooks/useThrottledCallback/useThrottledCallback.ts
|
|
7
|
+
function useThrottledCallback(callback, intervalMs) {
|
|
8
|
+
const callbackRef = react.useRef(callback);
|
|
9
|
+
const lastRunRef = react.useRef(0);
|
|
10
|
+
react.useEffect(() => {
|
|
11
|
+
callbackRef.current = callback;
|
|
12
|
+
}, [callback]);
|
|
13
|
+
return react.useCallback(
|
|
14
|
+
(...args) => {
|
|
15
|
+
const now = Date.now();
|
|
16
|
+
if (now - lastRunRef.current >= intervalMs) {
|
|
17
|
+
lastRunRef.current = now;
|
|
18
|
+
callbackRef.current(...args);
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
[intervalMs]
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
exports.useThrottledCallback = useThrottledCallback;
|
|
26
|
+
//# sourceMappingURL=useThrottledCallback.js.map
|
|
27
|
+
//# sourceMappingURL=useThrottledCallback.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/useThrottledCallback/useThrottledCallback.ts"],"names":["useRef","useEffect","useCallback"],"mappings":";;;;;AAeO,SAAS,oBAAA,CAEd,UAAa,UAAA,EAAuB;AACpC,EAAA,MAAM,WAAA,GAAcA,aAAO,QAAQ,CAAA;AACnC,EAAA,MAAM,UAAA,GAAaA,aAAO,CAAC,CAAA;AAE3B,EAAAC,eAAA,CAAU,MAAM;AACd,IAAA,WAAA,CAAY,OAAA,GAAU,QAAA;AAAA,EACxB,CAAA,EAAG,CAAC,QAAQ,CAAC,CAAA;AAEb,EAAA,OAAOC,iBAAA;AAAA,IACL,IAAI,IAAA,KAAwB;AAC1B,MAAA,MAAM,GAAA,GAAM,KAAK,GAAA,EAAI;AACrB,MAAA,IAAI,GAAA,GAAM,UAAA,CAAW,OAAA,IAAW,UAAA,EAAY;AAC1C,QAAA,UAAA,CAAW,OAAA,GAAU,GAAA;AACrB,QAAA,WAAA,CAAY,OAAA,CAAQ,GAAG,IAAI,CAAA;AAAA,MAC7B;AAAA,IACF,CAAA;AAAA,IACA,CAAC,UAAU;AAAA,GACb;AACF","file":"useThrottledCallback.js","sourcesContent":["\"use client\";\n\nimport { useCallback, useEffect, useRef } from \"react\";\n\n/**\n * Returns a stable, throttled version of `callback` that runs at most once per `intervalMs`.\n *\n * If invoked again inside the cooldown window, the extra calls are **dropped** (no trailing flush). The latest\n * `callback` reference is always used via a ref, so changing the handler does not reset the throttle clock.\n *\n * @typeParam T - Void function type (`(...args) => void`).\n * @param callback - Work to run when the throttle gate opens.\n * @param intervalMs - Minimum milliseconds between invocations.\n * @returns Throttled function with the same call signature as `callback`.\n */\nexport function useThrottledCallback<\n T extends (...args: any[]) => void,\n>(callback: T, intervalMs: number): T {\n const callbackRef = useRef(callback);\n const lastRunRef = useRef(0);\n\n useEffect(() => {\n callbackRef.current = callback;\n }, [callback]);\n\n return useCallback(\n (...args: Parameters<T>) => {\n const now = Date.now();\n if (now - lastRunRef.current >= intervalMs) {\n lastRunRef.current = now;\n callbackRef.current(...args);\n }\n },\n [intervalMs],\n ) as T;\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useRef, useEffect, useCallback } from 'react';
|
|
3
|
+
|
|
4
|
+
// src/hooks/useThrottledCallback/useThrottledCallback.ts
|
|
5
|
+
function useThrottledCallback(callback, intervalMs) {
|
|
6
|
+
const callbackRef = useRef(callback);
|
|
7
|
+
const lastRunRef = useRef(0);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
callbackRef.current = callback;
|
|
10
|
+
}, [callback]);
|
|
11
|
+
return useCallback(
|
|
12
|
+
(...args) => {
|
|
13
|
+
const now = Date.now();
|
|
14
|
+
if (now - lastRunRef.current >= intervalMs) {
|
|
15
|
+
lastRunRef.current = now;
|
|
16
|
+
callbackRef.current(...args);
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
[intervalMs]
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { useThrottledCallback };
|
|
24
|
+
//# sourceMappingURL=useThrottledCallback.mjs.map
|
|
25
|
+
//# sourceMappingURL=useThrottledCallback.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/useThrottledCallback/useThrottledCallback.ts"],"names":[],"mappings":";;;AAeO,SAAS,oBAAA,CAEd,UAAa,UAAA,EAAuB;AACpC,EAAA,MAAM,WAAA,GAAc,OAAO,QAAQ,CAAA;AACnC,EAAA,MAAM,UAAA,GAAa,OAAO,CAAC,CAAA;AAE3B,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,WAAA,CAAY,OAAA,GAAU,QAAA;AAAA,EACxB,CAAA,EAAG,CAAC,QAAQ,CAAC,CAAA;AAEb,EAAA,OAAO,WAAA;AAAA,IACL,IAAI,IAAA,KAAwB;AAC1B,MAAA,MAAM,GAAA,GAAM,KAAK,GAAA,EAAI;AACrB,MAAA,IAAI,GAAA,GAAM,UAAA,CAAW,OAAA,IAAW,UAAA,EAAY;AAC1C,QAAA,UAAA,CAAW,OAAA,GAAU,GAAA;AACrB,QAAA,WAAA,CAAY,OAAA,CAAQ,GAAG,IAAI,CAAA;AAAA,MAC7B;AAAA,IACF,CAAA;AAAA,IACA,CAAC,UAAU;AAAA,GACb;AACF","file":"useThrottledCallback.mjs","sourcesContent":["\"use client\";\n\nimport { useCallback, useEffect, useRef } from \"react\";\n\n/**\n * Returns a stable, throttled version of `callback` that runs at most once per `intervalMs`.\n *\n * If invoked again inside the cooldown window, the extra calls are **dropped** (no trailing flush). The latest\n * `callback` reference is always used via a ref, so changing the handler does not reset the throttle clock.\n *\n * @typeParam T - Void function type (`(...args) => void`).\n * @param callback - Work to run when the throttle gate opens.\n * @param intervalMs - Minimum milliseconds between invocations.\n * @returns Throttled function with the same call signature as `callback`.\n */\nexport function useThrottledCallback<\n T extends (...args: any[]) => void,\n>(callback: T, intervalMs: number): T {\n const callbackRef = useRef(callback);\n const lastRunRef = useRef(0);\n\n useEffect(() => {\n callbackRef.current = callback;\n }, [callback]);\n\n return useCallback(\n (...args: Parameters<T>) => {\n const now = Date.now();\n if (now - lastRunRef.current >= intervalMs) {\n lastRunRef.current = now;\n callbackRef.current(...args);\n }\n },\n [intervalMs],\n ) as T;\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simple boolean state with `toggle()` and an explicit `set(next)` setter.
|
|
3
|
+
*
|
|
4
|
+
* @param initialValue - Starting boolean (default `false`).
|
|
5
|
+
* @returns `[on, toggle, set]` where `on` is the flag, `toggle` flips it, and `set` assigns an absolute value.
|
|
6
|
+
*/
|
|
7
|
+
declare function useToggle(initialValue?: boolean): [boolean, () => void, (next: boolean) => void];
|
|
8
|
+
|
|
9
|
+
export { useToggle };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simple boolean state with `toggle()` and an explicit `set(next)` setter.
|
|
3
|
+
*
|
|
4
|
+
* @param initialValue - Starting boolean (default `false`).
|
|
5
|
+
* @returns `[on, toggle, set]` where `on` is the flag, `toggle` flips it, and `set` assigns an absolute value.
|
|
6
|
+
*/
|
|
7
|
+
declare function useToggle(initialValue?: boolean): [boolean, () => void, (next: boolean) => void];
|
|
8
|
+
|
|
9
|
+
export { useToggle };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var react = require('react');
|
|
5
|
+
|
|
6
|
+
// src/hooks/useToggle/useToggle.ts
|
|
7
|
+
function useToggle(initialValue = false) {
|
|
8
|
+
const [on, setOn] = react.useState(initialValue);
|
|
9
|
+
const toggle = react.useCallback(() => {
|
|
10
|
+
setOn((previous) => !previous);
|
|
11
|
+
}, []);
|
|
12
|
+
const set = react.useCallback((next) => {
|
|
13
|
+
setOn(next);
|
|
14
|
+
}, []);
|
|
15
|
+
return [on, toggle, set];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
exports.useToggle = useToggle;
|
|
19
|
+
//# sourceMappingURL=useToggle.js.map
|
|
20
|
+
//# sourceMappingURL=useToggle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/useToggle/useToggle.ts"],"names":["useState","useCallback"],"mappings":";;;;;AAUO,SAAS,SAAA,CACd,eAAe,KAAA,EACiC;AAChD,EAAA,MAAM,CAAC,EAAA,EAAI,KAAK,CAAA,GAAIA,eAAS,YAAY,CAAA;AACzC,EAAA,MAAM,MAAA,GAASC,kBAAY,MAAM;AAC/B,IAAA,KAAA,CAAM,CAAC,QAAA,KAAa,CAAC,QAAQ,CAAA;AAAA,EAC/B,CAAA,EAAG,EAAE,CAAA;AACL,EAAA,MAAM,GAAA,GAAMA,iBAAA,CAAY,CAAC,IAAA,KAAkB;AACzC,IAAA,KAAA,CAAM,IAAI,CAAA;AAAA,EACZ,CAAA,EAAG,EAAE,CAAA;AACL,EAAA,OAAO,CAAC,EAAA,EAAI,MAAA,EAAQ,GAAG,CAAA;AACzB","file":"useToggle.js","sourcesContent":["\"use client\";\n\nimport { useCallback, useState } from \"react\";\n\n/**\n * Simple boolean state with `toggle()` and an explicit `set(next)` setter.\n *\n * @param initialValue - Starting boolean (default `false`).\n * @returns `[on, toggle, set]` where `on` is the flag, `toggle` flips it, and `set` assigns an absolute value.\n */\nexport function useToggle(\n initialValue = false,\n): [boolean, () => void, (next: boolean) => void] {\n const [on, setOn] = useState(initialValue);\n const toggle = useCallback(() => {\n setOn((previous) => !previous);\n }, []);\n const set = useCallback((next: boolean) => {\n setOn(next);\n }, []);\n return [on, toggle, set];\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useState, useCallback } from 'react';
|
|
3
|
+
|
|
4
|
+
// src/hooks/useToggle/useToggle.ts
|
|
5
|
+
function useToggle(initialValue = false) {
|
|
6
|
+
const [on, setOn] = useState(initialValue);
|
|
7
|
+
const toggle = useCallback(() => {
|
|
8
|
+
setOn((previous) => !previous);
|
|
9
|
+
}, []);
|
|
10
|
+
const set = useCallback((next) => {
|
|
11
|
+
setOn(next);
|
|
12
|
+
}, []);
|
|
13
|
+
return [on, toggle, set];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { useToggle };
|
|
17
|
+
//# sourceMappingURL=useToggle.mjs.map
|
|
18
|
+
//# sourceMappingURL=useToggle.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/useToggle/useToggle.ts"],"names":[],"mappings":";;;AAUO,SAAS,SAAA,CACd,eAAe,KAAA,EACiC;AAChD,EAAA,MAAM,CAAC,EAAA,EAAI,KAAK,CAAA,GAAI,SAAS,YAAY,CAAA;AACzC,EAAA,MAAM,MAAA,GAAS,YAAY,MAAM;AAC/B,IAAA,KAAA,CAAM,CAAC,QAAA,KAAa,CAAC,QAAQ,CAAA;AAAA,EAC/B,CAAA,EAAG,EAAE,CAAA;AACL,EAAA,MAAM,GAAA,GAAM,WAAA,CAAY,CAAC,IAAA,KAAkB;AACzC,IAAA,KAAA,CAAM,IAAI,CAAA;AAAA,EACZ,CAAA,EAAG,EAAE,CAAA;AACL,EAAA,OAAO,CAAC,EAAA,EAAI,MAAA,EAAQ,GAAG,CAAA;AACzB","file":"useToggle.mjs","sourcesContent":["\"use client\";\n\nimport { useCallback, useState } from \"react\";\n\n/**\n * Simple boolean state with `toggle()` and an explicit `set(next)` setter.\n *\n * @param initialValue - Starting boolean (default `false`).\n * @returns `[on, toggle, set]` where `on` is the flag, `toggle` flips it, and `set` assigns an absolute value.\n */\nexport function useToggle(\n initialValue = false,\n): [boolean, () => void, (next: boolean) => void] {\n const [on, setOn] = useState(initialValue);\n const toggle = useCallback(() => {\n setOn((previous) => !previous);\n }, []);\n const set = useCallback((next: boolean) => {\n setOn(next);\n }, []);\n return [on, toggle, set];\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
type WindowSize = {
|
|
2
|
+
width: number;
|
|
3
|
+
height: number;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Tracks the viewport size using `window.innerWidth` / `innerHeight` and a `resize` listener.
|
|
7
|
+
*
|
|
8
|
+
* Initializes to `{ width: 0, height: 0 }` on the server; after mount, size updates to the real viewport and on every resize.
|
|
9
|
+
*
|
|
10
|
+
* @returns Latest `{ width, height }` in CSS pixels.
|
|
11
|
+
*/
|
|
12
|
+
declare function useWindowSize(): WindowSize;
|
|
13
|
+
|
|
14
|
+
export { type WindowSize, useWindowSize };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
type WindowSize = {
|
|
2
|
+
width: number;
|
|
3
|
+
height: number;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Tracks the viewport size using `window.innerWidth` / `innerHeight` and a `resize` listener.
|
|
7
|
+
*
|
|
8
|
+
* Initializes to `{ width: 0, height: 0 }` on the server; after mount, size updates to the real viewport and on every resize.
|
|
9
|
+
*
|
|
10
|
+
* @returns Latest `{ width, height }` in CSS pixels.
|
|
11
|
+
*/
|
|
12
|
+
declare function useWindowSize(): WindowSize;
|
|
13
|
+
|
|
14
|
+
export { type WindowSize, useWindowSize };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var react = require('react');
|
|
5
|
+
|
|
6
|
+
// src/hooks/useWindowSize/useWindowSize.ts
|
|
7
|
+
var defaultSize = { width: 0, height: 0 };
|
|
8
|
+
function useWindowSize() {
|
|
9
|
+
const [size, setSize] = react.useState(() => {
|
|
10
|
+
if (typeof window === "undefined") {
|
|
11
|
+
return defaultSize;
|
|
12
|
+
}
|
|
13
|
+
return { width: window.innerWidth || 0, height: window.innerHeight || 0 };
|
|
14
|
+
});
|
|
15
|
+
react.useEffect(() => {
|
|
16
|
+
const onResize = () => {
|
|
17
|
+
setSize({ width: window.innerWidth || 0, height: window.innerHeight || 0 });
|
|
18
|
+
};
|
|
19
|
+
onResize();
|
|
20
|
+
window.addEventListener("resize", onResize);
|
|
21
|
+
return () => {
|
|
22
|
+
window.removeEventListener("resize", onResize);
|
|
23
|
+
};
|
|
24
|
+
}, []);
|
|
25
|
+
return size;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
exports.useWindowSize = useWindowSize;
|
|
29
|
+
//# sourceMappingURL=useWindowSize.js.map
|
|
30
|
+
//# sourceMappingURL=useWindowSize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/useWindowSize/useWindowSize.ts"],"names":["useState","useEffect"],"mappings":";;;;;AASA,IAAM,WAAA,GAA0B,EAAE,KAAA,EAAO,CAAA,EAAG,QAAQ,CAAA,EAAE;AAS/C,SAAS,aAAA,GAA4B;AAC1C,EAAA,MAAM,CAAC,IAAA,EAAM,OAAO,CAAA,GAAIA,eAAqB,MAAM;AACjD,IAAA,IAAI,OAAO,WAAW,WAAA,EAAa;AACjC,MAAA,OAAO,WAAA;AAAA,IACT;AACA,IAAA,OAAO,EAAE,OAAO,MAAA,CAAO,UAAA,IAAc,GAAG,MAAA,EAAQ,MAAA,CAAO,eAAe,CAAA,EAAE;AAAA,EAC1E,CAAC,CAAA;AAED,EAAAC,eAAA,CAAU,MAAM;AACd,IAAA,MAAM,WAAW,MAAM;AACrB,MAAA,OAAA,CAAQ,EAAE,OAAO,MAAA,CAAO,UAAA,IAAc,GAAG,MAAA,EAAQ,MAAA,CAAO,WAAA,IAAe,CAAA,EAAG,CAAA;AAAA,IAC5E,CAAA;AACA,IAAA,QAAA,EAAS;AACT,IAAA,MAAA,CAAO,gBAAA,CAAiB,UAAU,QAAQ,CAAA;AAC1C,IAAA,OAAO,MAAM;AACX,MAAA,MAAA,CAAO,mBAAA,CAAoB,UAAU,QAAQ,CAAA;AAAA,IAC/C,CAAA;AAAA,EACF,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,OAAO,IAAA;AACT","file":"useWindowSize.js","sourcesContent":["\"use client\";\n\nimport { useEffect, useState } from \"react\";\n\nexport type WindowSize = {\n width: number;\n height: number;\n};\n\nconst defaultSize: WindowSize = { width: 0, height: 0 };\n\n/**\n * Tracks the viewport size using `window.innerWidth` / `innerHeight` and a `resize` listener.\n *\n * Initializes to `{ width: 0, height: 0 }` on the server; after mount, size updates to the real viewport and on every resize.\n *\n * @returns Latest `{ width, height }` in CSS pixels.\n */\nexport function useWindowSize(): WindowSize {\n const [size, setSize] = useState<WindowSize>(() => {\n if (typeof window === \"undefined\") {\n return defaultSize;\n }\n return { width: window.innerWidth || 0, height: window.innerHeight || 0 };\n });\n\n useEffect(() => {\n const onResize = () => {\n setSize({ width: window.innerWidth || 0, height: window.innerHeight || 0 });\n };\n onResize();\n window.addEventListener(\"resize\", onResize);\n return () => {\n window.removeEventListener(\"resize\", onResize);\n };\n }, []);\n\n return size;\n}\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useState, useEffect } from 'react';
|
|
3
|
+
|
|
4
|
+
// src/hooks/useWindowSize/useWindowSize.ts
|
|
5
|
+
var defaultSize = { width: 0, height: 0 };
|
|
6
|
+
function useWindowSize() {
|
|
7
|
+
const [size, setSize] = useState(() => {
|
|
8
|
+
if (typeof window === "undefined") {
|
|
9
|
+
return defaultSize;
|
|
10
|
+
}
|
|
11
|
+
return { width: window.innerWidth || 0, height: window.innerHeight || 0 };
|
|
12
|
+
});
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
const onResize = () => {
|
|
15
|
+
setSize({ width: window.innerWidth || 0, height: window.innerHeight || 0 });
|
|
16
|
+
};
|
|
17
|
+
onResize();
|
|
18
|
+
window.addEventListener("resize", onResize);
|
|
19
|
+
return () => {
|
|
20
|
+
window.removeEventListener("resize", onResize);
|
|
21
|
+
};
|
|
22
|
+
}, []);
|
|
23
|
+
return size;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { useWindowSize };
|
|
27
|
+
//# sourceMappingURL=useWindowSize.mjs.map
|
|
28
|
+
//# sourceMappingURL=useWindowSize.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/useWindowSize/useWindowSize.ts"],"names":[],"mappings":";;;AASA,IAAM,WAAA,GAA0B,EAAE,KAAA,EAAO,CAAA,EAAG,QAAQ,CAAA,EAAE;AAS/C,SAAS,aAAA,GAA4B;AAC1C,EAAA,MAAM,CAAC,IAAA,EAAM,OAAO,CAAA,GAAI,SAAqB,MAAM;AACjD,IAAA,IAAI,OAAO,WAAW,WAAA,EAAa;AACjC,MAAA,OAAO,WAAA;AAAA,IACT;AACA,IAAA,OAAO,EAAE,OAAO,MAAA,CAAO,UAAA,IAAc,GAAG,MAAA,EAAQ,MAAA,CAAO,eAAe,CAAA,EAAE;AAAA,EAC1E,CAAC,CAAA;AAED,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,MAAM,WAAW,MAAM;AACrB,MAAA,OAAA,CAAQ,EAAE,OAAO,MAAA,CAAO,UAAA,IAAc,GAAG,MAAA,EAAQ,MAAA,CAAO,WAAA,IAAe,CAAA,EAAG,CAAA;AAAA,IAC5E,CAAA;AACA,IAAA,QAAA,EAAS;AACT,IAAA,MAAA,CAAO,gBAAA,CAAiB,UAAU,QAAQ,CAAA;AAC1C,IAAA,OAAO,MAAM;AACX,MAAA,MAAA,CAAO,mBAAA,CAAoB,UAAU,QAAQ,CAAA;AAAA,IAC/C,CAAA;AAAA,EACF,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,OAAO,IAAA;AACT","file":"useWindowSize.mjs","sourcesContent":["\"use client\";\n\nimport { useEffect, useState } from \"react\";\n\nexport type WindowSize = {\n width: number;\n height: number;\n};\n\nconst defaultSize: WindowSize = { width: 0, height: 0 };\n\n/**\n * Tracks the viewport size using `window.innerWidth` / `innerHeight` and a `resize` listener.\n *\n * Initializes to `{ width: 0, height: 0 }` on the server; after mount, size updates to the real viewport and on every resize.\n *\n * @returns Latest `{ width, height }` in CSS pixels.\n */\nexport function useWindowSize(): WindowSize {\n const [size, setSize] = useState<WindowSize>(() => {\n if (typeof window === \"undefined\") {\n return defaultSize;\n }\n return { width: window.innerWidth || 0, height: window.innerHeight || 0 };\n });\n\n useEffect(() => {\n const onResize = () => {\n setSize({ width: window.innerWidth || 0, height: window.innerHeight || 0 });\n };\n onResize();\n window.addEventListener(\"resize\", onResize);\n return () => {\n window.removeEventListener(\"resize\", onResize);\n };\n }, []);\n\n return size;\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ClassValue } from 'clsx';
|
|
2
|
+
|
|
3
|
+
declare function cn(...inputs: ClassValue[]): string;
|
|
4
|
+
declare const clampPage: (page: number, pageCount: number) => number;
|
|
5
|
+
declare const range: (from: number, to: number) => number[];
|
|
6
|
+
declare const clamp: (value: number, min: number, max: number) => number;
|
|
7
|
+
|
|
8
|
+
export { clamp, clampPage, cn, range };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ClassValue } from 'clsx';
|
|
2
|
+
|
|
3
|
+
declare function cn(...inputs: ClassValue[]): string;
|
|
4
|
+
declare const clampPage: (page: number, pageCount: number) => number;
|
|
5
|
+
declare const range: (from: number, to: number) => number[];
|
|
6
|
+
declare const clamp: (value: number, min: number, max: number) => number;
|
|
7
|
+
|
|
8
|
+
export { clamp, clampPage, cn, range };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkUOZYPWDZ_js = require('../chunk-UOZYPWDZ.js');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "clamp", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return chunkUOZYPWDZ_js.clamp; }
|
|
10
|
+
});
|
|
11
|
+
Object.defineProperty(exports, "clampPage", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return chunkUOZYPWDZ_js.clampPage; }
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, "cn", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return chunkUOZYPWDZ_js.cn; }
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "range", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return chunkUOZYPWDZ_js.range; }
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=utils.js.map
|
|
24
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"utils.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"utils.mjs"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { VariantProps } from 'class-variance-authority';
|
|
2
|
+
import { ComponentPropsWithoutRef } from 'react';
|
|
3
|
+
import { b as buttonVariants } from './variants-Dd9pe-ov.js';
|
|
4
|
+
|
|
5
|
+
type PaginationAppearance = NonNullable<VariantProps<typeof buttonVariants>["appearance"]>;
|
|
6
|
+
type PaginationSize = NonNullable<VariantProps<typeof buttonVariants>["size"]>;
|
|
7
|
+
type PaginationPageItem = {
|
|
8
|
+
type: "page";
|
|
9
|
+
value: number;
|
|
10
|
+
} | {
|
|
11
|
+
type: "ellipsis";
|
|
12
|
+
key: string;
|
|
13
|
+
};
|
|
14
|
+
type UsePaginationParams = {
|
|
15
|
+
pageCount: number;
|
|
16
|
+
page?: number;
|
|
17
|
+
defaultPage?: number;
|
|
18
|
+
siblingCount?: number;
|
|
19
|
+
boundaryCount?: number;
|
|
20
|
+
onPageChange?: (page: number) => void;
|
|
21
|
+
};
|
|
22
|
+
type UsePaginationResult = {
|
|
23
|
+
/** 1-based active page, clamped to `[1, pageCount]`. */
|
|
24
|
+
currentPage: number;
|
|
25
|
+
pageCount: number;
|
|
26
|
+
items: PaginationPageItem[];
|
|
27
|
+
setPage: (page: number) => void;
|
|
28
|
+
goPrev: () => void;
|
|
29
|
+
goNext: () => void;
|
|
30
|
+
canGoPrev: boolean;
|
|
31
|
+
canGoNext: boolean;
|
|
32
|
+
};
|
|
33
|
+
type PaginationProps = Omit<ComponentPropsWithoutRef<"nav">, "onChange"> & VariantProps<typeof buttonVariants> & {
|
|
34
|
+
pageCount: number;
|
|
35
|
+
page?: number;
|
|
36
|
+
defaultPage?: number;
|
|
37
|
+
onPageChange?: (page: number) => void;
|
|
38
|
+
/**
|
|
39
|
+
* Number of page buttons to show on each side of the current page (the “middle” window).
|
|
40
|
+
* @defaultValue 1
|
|
41
|
+
*/
|
|
42
|
+
siblingCount?: number;
|
|
43
|
+
/**
|
|
44
|
+
* Number of pages to keep visible at the start and end of the range.
|
|
45
|
+
* @defaultValue 1
|
|
46
|
+
*/
|
|
47
|
+
boundaryCount?: number;
|
|
48
|
+
showPrevNext?: boolean;
|
|
49
|
+
prevLabel?: string;
|
|
50
|
+
nextLabel?: string;
|
|
51
|
+
ellipsisLabel?: string;
|
|
52
|
+
/**
|
|
53
|
+
* When set, page controls render as anchors suitable for URL-based pagination.
|
|
54
|
+
*/
|
|
55
|
+
getPageHref?: (page: number) => string | undefined;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
type BuildPaginationItemsParams = {
|
|
59
|
+
pageCount: number;
|
|
60
|
+
currentPage: number;
|
|
61
|
+
siblingCount: number;
|
|
62
|
+
boundaryCount: number;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Headless pagination state: current page, derived page button items, and prev/next helpers.
|
|
66
|
+
*
|
|
67
|
+
* Supports controlled mode when `page` is passed from the parent, or internal state seeded by `defaultPage`.
|
|
68
|
+
* All page indices are **1-based** and clamped to `[1, pageCount]` via {@link clampPage}. `items` is memoized from
|
|
69
|
+
* {@link buildPaginationItems} for rendering numeric pages and ellipsis gaps.
|
|
70
|
+
*
|
|
71
|
+
* @param params - See `UsePaginationParams` in `../ui/pagination/types` for full fields (`pageCount`, `page`, `onPageChange`, etc.).
|
|
72
|
+
* @returns Current page, item list, `setPage`, navigation helpers, and `canGoPrev` / `canGoNext` flags.
|
|
73
|
+
*/
|
|
74
|
+
declare function usePagination({ pageCount, page, defaultPage, siblingCount, boundaryCount, onPageChange, }: UsePaginationParams): UsePaginationResult;
|
|
75
|
+
/**
|
|
76
|
+
* Builds the ordered list of page numbers and ellipsis markers for a pagination control.
|
|
77
|
+
*
|
|
78
|
+
* @param params.pageCount - Total number of pages (must be >= 0; empty list when 0).
|
|
79
|
+
* @param params.currentPage - Active page index (1-based).
|
|
80
|
+
* @param params.siblingCount - How many page buttons to show on each side of the current page.
|
|
81
|
+
* @param params.boundaryCount - How many pages to pin at the start and end of the range.
|
|
82
|
+
* @returns Items suitable for rendering, e.g. page `1`, ellipsis gap, middle window, ellipsis, last page.
|
|
83
|
+
*/
|
|
84
|
+
declare function buildPaginationItems({ pageCount, currentPage, siblingCount, boundaryCount, }: BuildPaginationItemsParams): PaginationPageItem[];
|
|
85
|
+
|
|
86
|
+
export { type BuildPaginationItemsParams as B, type PaginationAppearance as P, type UsePaginationParams as U, type PaginationPageItem as a, type PaginationProps as b, type PaginationSize as c, type UsePaginationResult as d, buildPaginationItems as e, usePagination as u };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { VariantProps } from 'class-variance-authority';
|
|
2
|
+
import { ComponentPropsWithoutRef } from 'react';
|
|
3
|
+
import { b as buttonVariants } from './variants-Dd9pe-ov.mjs';
|
|
4
|
+
|
|
5
|
+
type PaginationAppearance = NonNullable<VariantProps<typeof buttonVariants>["appearance"]>;
|
|
6
|
+
type PaginationSize = NonNullable<VariantProps<typeof buttonVariants>["size"]>;
|
|
7
|
+
type PaginationPageItem = {
|
|
8
|
+
type: "page";
|
|
9
|
+
value: number;
|
|
10
|
+
} | {
|
|
11
|
+
type: "ellipsis";
|
|
12
|
+
key: string;
|
|
13
|
+
};
|
|
14
|
+
type UsePaginationParams = {
|
|
15
|
+
pageCount: number;
|
|
16
|
+
page?: number;
|
|
17
|
+
defaultPage?: number;
|
|
18
|
+
siblingCount?: number;
|
|
19
|
+
boundaryCount?: number;
|
|
20
|
+
onPageChange?: (page: number) => void;
|
|
21
|
+
};
|
|
22
|
+
type UsePaginationResult = {
|
|
23
|
+
/** 1-based active page, clamped to `[1, pageCount]`. */
|
|
24
|
+
currentPage: number;
|
|
25
|
+
pageCount: number;
|
|
26
|
+
items: PaginationPageItem[];
|
|
27
|
+
setPage: (page: number) => void;
|
|
28
|
+
goPrev: () => void;
|
|
29
|
+
goNext: () => void;
|
|
30
|
+
canGoPrev: boolean;
|
|
31
|
+
canGoNext: boolean;
|
|
32
|
+
};
|
|
33
|
+
type PaginationProps = Omit<ComponentPropsWithoutRef<"nav">, "onChange"> & VariantProps<typeof buttonVariants> & {
|
|
34
|
+
pageCount: number;
|
|
35
|
+
page?: number;
|
|
36
|
+
defaultPage?: number;
|
|
37
|
+
onPageChange?: (page: number) => void;
|
|
38
|
+
/**
|
|
39
|
+
* Number of page buttons to show on each side of the current page (the “middle” window).
|
|
40
|
+
* @defaultValue 1
|
|
41
|
+
*/
|
|
42
|
+
siblingCount?: number;
|
|
43
|
+
/**
|
|
44
|
+
* Number of pages to keep visible at the start and end of the range.
|
|
45
|
+
* @defaultValue 1
|
|
46
|
+
*/
|
|
47
|
+
boundaryCount?: number;
|
|
48
|
+
showPrevNext?: boolean;
|
|
49
|
+
prevLabel?: string;
|
|
50
|
+
nextLabel?: string;
|
|
51
|
+
ellipsisLabel?: string;
|
|
52
|
+
/**
|
|
53
|
+
* When set, page controls render as anchors suitable for URL-based pagination.
|
|
54
|
+
*/
|
|
55
|
+
getPageHref?: (page: number) => string | undefined;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
type BuildPaginationItemsParams = {
|
|
59
|
+
pageCount: number;
|
|
60
|
+
currentPage: number;
|
|
61
|
+
siblingCount: number;
|
|
62
|
+
boundaryCount: number;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Headless pagination state: current page, derived page button items, and prev/next helpers.
|
|
66
|
+
*
|
|
67
|
+
* Supports controlled mode when `page` is passed from the parent, or internal state seeded by `defaultPage`.
|
|
68
|
+
* All page indices are **1-based** and clamped to `[1, pageCount]` via {@link clampPage}. `items` is memoized from
|
|
69
|
+
* {@link buildPaginationItems} for rendering numeric pages and ellipsis gaps.
|
|
70
|
+
*
|
|
71
|
+
* @param params - See `UsePaginationParams` in `../ui/pagination/types` for full fields (`pageCount`, `page`, `onPageChange`, etc.).
|
|
72
|
+
* @returns Current page, item list, `setPage`, navigation helpers, and `canGoPrev` / `canGoNext` flags.
|
|
73
|
+
*/
|
|
74
|
+
declare function usePagination({ pageCount, page, defaultPage, siblingCount, boundaryCount, onPageChange, }: UsePaginationParams): UsePaginationResult;
|
|
75
|
+
/**
|
|
76
|
+
* Builds the ordered list of page numbers and ellipsis markers for a pagination control.
|
|
77
|
+
*
|
|
78
|
+
* @param params.pageCount - Total number of pages (must be >= 0; empty list when 0).
|
|
79
|
+
* @param params.currentPage - Active page index (1-based).
|
|
80
|
+
* @param params.siblingCount - How many page buttons to show on each side of the current page.
|
|
81
|
+
* @param params.boundaryCount - How many pages to pin at the start and end of the range.
|
|
82
|
+
* @returns Items suitable for rendering, e.g. page `1`, ellipsis gap, middle window, ellipsis, last page.
|
|
83
|
+
*/
|
|
84
|
+
declare function buildPaginationItems({ pageCount, currentPage, siblingCount, boundaryCount, }: BuildPaginationItemsParams): PaginationPageItem[];
|
|
85
|
+
|
|
86
|
+
export { type BuildPaginationItemsParams as B, type PaginationAppearance as P, type UsePaginationParams as U, type PaginationPageItem as a, type PaginationProps as b, type PaginationSize as c, type UsePaginationResult as d, buildPaginationItems as e, usePagination as u };
|