@codefast/ui 0.3.9 → 0.3.11-canary.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/CHANGELOG.md +30 -0
- package/README.md +277 -167
- package/dist/components/accordion.cjs +97 -1
- package/dist/components/accordion.js +51 -1
- package/dist/components/alert-dialog.cjs +155 -1
- package/dist/components/alert-dialog.d.ts +2 -2
- package/dist/components/alert-dialog.js +94 -1
- package/dist/components/alert.cjs +84 -1
- package/dist/components/alert.d.ts +1 -1
- package/dist/components/alert.js +41 -1
- package/dist/components/aspect-ratio.cjs +43 -1
- package/dist/components/aspect-ratio.js +9 -1
- package/dist/components/avatar.cjs +65 -1
- package/dist/components/avatar.js +25 -1
- package/dist/components/badge.cjs +66 -1
- package/dist/components/badge.d.ts +1 -1
- package/dist/components/badge.js +29 -1
- package/dist/components/breadcrumb.cjs +124 -1
- package/dist/components/breadcrumb.js +72 -1
- package/dist/components/button-group.cjs +86 -1
- package/dist/components/button-group.d.ts +1 -1
- package/dist/components/button-group.js +43 -1
- package/dist/components/button.cjs +92 -1
- package/dist/components/button.d.ts +1 -1
- package/dist/components/button.js +55 -1
- package/dist/components/calendar.cjs +150 -1
- package/dist/components/calendar.d.ts +11 -18
- package/dist/components/calendar.js +113 -1
- package/dist/components/card.cjs +105 -1
- package/dist/components/card.js +53 -1
- package/dist/components/carousel.cjs +210 -1
- package/dist/components/carousel.d.ts +1 -1
- package/dist/components/carousel.js +151 -1
- package/dist/components/chart.cjs +250 -3
- package/dist/components/chart.d.ts +5 -4
- package/dist/components/chart.js +198 -3
- package/dist/components/checkbox-cards.cjs +69 -1
- package/dist/components/checkbox-cards.js +32 -1
- package/dist/components/checkbox-group.cjs +63 -1
- package/dist/components/checkbox-group.js +26 -1
- package/dist/components/checkbox.cjs +53 -1
- package/dist/components/checkbox.js +19 -1
- package/dist/components/collapsible.cjs +61 -1
- package/dist/components/collapsible.js +21 -1
- package/dist/components/command.cjs +167 -1
- package/dist/components/command.js +106 -1
- package/dist/components/context-menu.cjs +218 -1
- package/dist/components/context-menu.js +142 -1
- package/dist/components/dialog.cjs +164 -1
- package/dist/components/dialog.d.ts +2 -2
- package/dist/components/dialog.js +106 -1
- package/dist/components/drawer.cjs +143 -1
- package/dist/components/drawer.d.ts +1 -1
- package/dist/components/drawer.js +85 -1
- package/dist/components/dropdown-menu.cjs +221 -1
- package/dist/components/dropdown-menu.js +145 -1
- package/dist/components/empty.cjs +113 -1
- package/dist/components/empty.d.ts +1 -1
- package/dist/components/empty.js +61 -1
- package/dist/components/field.cjs +193 -1
- package/dist/components/field.d.ts +1 -1
- package/dist/components/field.js +129 -1
- package/dist/components/form.cjs +151 -1
- package/dist/components/form.d.ts +3 -3
- package/dist/components/form.js +96 -1
- package/dist/components/hover-card.cjs +77 -1
- package/dist/components/hover-card.js +34 -1
- package/dist/components/input-group.cjs +155 -1
- package/dist/components/input-group.d.ts +1 -1
- package/dist/components/input-group.js +97 -1
- package/dist/components/input-number.cjs +98 -1
- package/dist/components/input-number.js +64 -1
- package/dist/components/input-otp.cjs +101 -1
- package/dist/components/input-otp.js +49 -1
- package/dist/components/input-password.cjs +71 -1
- package/dist/components/input-password.js +37 -1
- package/dist/components/input-search.cjs +80 -1
- package/dist/components/input-search.js +46 -1
- package/dist/components/input.cjs +45 -1
- package/dist/components/input.js +11 -1
- package/dist/components/item.cjs +186 -1
- package/dist/components/item.d.ts +1 -1
- package/dist/components/item.js +119 -1
- package/dist/components/kbd.cjs +54 -1
- package/dist/components/kbd.js +17 -1
- package/dist/components/label.cjs +45 -1
- package/dist/components/label.js +11 -1
- package/dist/components/menubar.cjs +232 -1
- package/dist/components/menubar.js +153 -1
- package/dist/components/native-select.cjs +75 -1
- package/dist/components/native-select.js +35 -1
- package/dist/components/navigation-menu.cjs +146 -2
- package/dist/components/navigation-menu.js +94 -2
- package/dist/components/pagination.cjs +138 -1
- package/dist/components/pagination.d.ts +1 -1
- package/dist/components/pagination.js +86 -1
- package/dist/components/popover.cjs +86 -1
- package/dist/components/popover.js +40 -1
- package/dist/components/progress-circle.cjs +184 -1
- package/dist/components/progress-circle.d.ts +1 -1
- package/dist/components/progress-circle.js +147 -1
- package/dist/components/progress.cjs +52 -1
- package/dist/components/progress.js +18 -1
- package/dist/components/radio-cards.cjs +66 -1
- package/dist/components/radio-cards.js +29 -1
- package/dist/components/radio-group.cjs +59 -1
- package/dist/components/radio-group.js +22 -1
- package/dist/components/radio.cjs +47 -1
- package/dist/components/radio.js +13 -1
- package/dist/components/resizable.cjs +71 -1
- package/dist/components/resizable.d.ts +6 -6
- package/dist/components/resizable.js +31 -1
- package/dist/components/scroll-area.cjs +140 -1
- package/dist/components/scroll-area.d.ts +1 -1
- package/dist/components/scroll-area.js +100 -1
- package/dist/components/select.cjs +180 -1
- package/dist/components/select.d.ts +2 -2
- package/dist/components/select.js +119 -1
- package/dist/components/separator.cjs +82 -1
- package/dist/components/separator.d.ts +1 -1
- package/dist/components/separator.js +42 -1
- package/dist/components/sheet.cjs +184 -1
- package/dist/components/sheet.d.ts +2 -2
- package/dist/components/sheet.js +123 -1
- package/dist/components/sidebar.cjs +506 -1
- package/dist/components/sidebar.d.ts +1 -1
- package/dist/components/sidebar.js +400 -1
- package/dist/components/skeleton.cjs +44 -1
- package/dist/components/skeleton.js +10 -1
- package/dist/components/slider.cjs +79 -1
- package/dist/components/slider.js +45 -1
- package/dist/components/sonner.cjs +57 -1
- package/dist/components/sonner.js +17 -1
- package/dist/components/spinner.cjs +75 -1
- package/dist/components/spinner.js +41 -1
- package/dist/components/switch.cjs +49 -1
- package/dist/components/switch.js +15 -1
- package/dist/components/table.cjs +118 -1
- package/dist/components/table.js +63 -1
- package/dist/components/tabs.cjs +75 -1
- package/dist/components/tabs.d.ts +1 -1
- package/dist/components/tabs.js +32 -1
- package/dist/components/textarea.cjs +44 -1
- package/dist/components/textarea.js +10 -1
- package/dist/components/toggle-group.cjs +90 -1
- package/dist/components/toggle-group.d.ts +8 -10
- package/dist/components/toggle-group.js +53 -1
- package/dist/components/toggle.cjs +71 -1
- package/dist/components/toggle.d.ts +8 -10
- package/dist/components/toggle.js +34 -1
- package/dist/components/tooltip.cjs +90 -1
- package/dist/components/tooltip.js +44 -1
- package/dist/css/amber.css +95 -1
- package/dist/css/blue.css +95 -1
- package/dist/css/cyan.css +95 -1
- package/dist/css/emerald.css +95 -1
- package/dist/css/fuchsia.css +95 -1
- package/dist/css/gray.css +95 -1
- package/dist/css/green.css +95 -1
- package/dist/css/indigo.css +95 -1
- package/dist/css/lime.css +95 -1
- package/dist/css/neutral.css +95 -1
- package/dist/css/orange.css +95 -1
- package/dist/css/pink.css +95 -1
- package/dist/css/preset.css +118 -1
- package/dist/css/purple.css +95 -1
- package/dist/css/red.css +95 -1
- package/dist/css/rose.css +95 -1
- package/dist/css/sky.css +95 -1
- package/dist/css/slate.css +95 -1
- package/dist/css/stone.css +95 -1
- package/dist/css/style.css +3 -1
- package/dist/css/teal.css +95 -1
- package/dist/css/violet.css +95 -1
- package/dist/css/yellow.css +95 -1
- package/dist/css/zinc.css +95 -1
- package/dist/hooks/use-animated-value.cjs +74 -1
- package/dist/hooks/use-animated-value.d.ts +9 -10
- package/dist/hooks/use-animated-value.js +40 -1
- package/dist/hooks/use-copy-to-clipboard.cjs +57 -1
- package/dist/hooks/use-copy-to-clipboard.d.ts +17 -0
- package/dist/hooks/use-copy-to-clipboard.js +23 -1
- package/dist/hooks/use-is-mobile.cjs +39 -1
- package/dist/hooks/use-is-mobile.d.ts +15 -6
- package/dist/hooks/use-is-mobile.js +5 -1
- package/dist/hooks/use-media-query.cjs +56 -1
- package/dist/hooks/use-media-query.d.ts +11 -3
- package/dist/hooks/use-media-query.js +22 -1
- package/dist/hooks/use-mutation-observer.cjs +56 -1
- package/dist/hooks/use-mutation-observer.d.ts +7 -11
- package/dist/hooks/use-mutation-observer.js +22 -1
- package/dist/hooks/use-pagination.cjs +92 -1
- package/dist/hooks/use-pagination.d.ts +12 -10
- package/dist/hooks/use-pagination.js +55 -1
- package/dist/index.cjs +1081 -1
- package/dist/index.d.ts +4 -5
- package/dist/index.js +69 -1
- package/dist/primitives/checkbox-group.cjs +151 -1
- package/dist/primitives/checkbox-group.d.ts +1 -1
- package/dist/primitives/checkbox-group.js +99 -1
- package/dist/primitives/input-number.cjs +439 -1
- package/dist/primitives/input-number.d.ts +1 -1
- package/dist/primitives/input-number.js +381 -1
- package/dist/primitives/input.cjs +99 -1
- package/dist/primitives/input.d.ts +1 -1
- package/dist/primitives/input.js +53 -1
- package/dist/primitives/progress-circle.cjs +198 -1
- package/dist/primitives/progress-circle.d.ts +1 -1
- package/dist/primitives/progress-circle.js +128 -1
- package/package.json +405 -62
|
@@ -1,2 +1,24 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{useState
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
function useCopyToClipboard({ onCopy, timeout = 2000 } = {}) {
|
|
4
|
+
const [isCopied, setIsCopied] = useState(false);
|
|
5
|
+
const copyToClipboard = async (value)=>{
|
|
6
|
+
if ("u" < typeof window || !("clipboard" in navigator) || "function" != typeof navigator.clipboard.writeText) return;
|
|
7
|
+
if (!value) return;
|
|
8
|
+
try {
|
|
9
|
+
await navigator.clipboard.writeText(value);
|
|
10
|
+
setIsCopied(true);
|
|
11
|
+
if (onCopy) onCopy();
|
|
12
|
+
setTimeout(()=>{
|
|
13
|
+
setIsCopied(false);
|
|
14
|
+
}, timeout);
|
|
15
|
+
} catch (error) {
|
|
16
|
+
console.error(error);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
return {
|
|
20
|
+
copyToClipboard,
|
|
21
|
+
isCopied
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export { useCopyToClipboard };
|
|
@@ -1,2 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
"use client";
|
|
2
|
-
|
|
3
|
+
var __webpack_require__ = {};
|
|
4
|
+
(()=>{
|
|
5
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
6
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: definition[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.r = (exports1)=>{
|
|
17
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
18
|
+
value: 'Module'
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
21
|
+
value: true
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
})();
|
|
25
|
+
var __webpack_exports__ = {};
|
|
26
|
+
__webpack_require__.r(__webpack_exports__);
|
|
27
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
28
|
+
useIsMobile: ()=>useIsMobile
|
|
29
|
+
});
|
|
30
|
+
const external_use_media_query_cjs_namespaceObject = require("./use-media-query.cjs");
|
|
31
|
+
function useIsMobile(mobileBreakpoint = 768) {
|
|
32
|
+
return (0, external_use_media_query_cjs_namespaceObject.useMediaQuery)(`(max-width: ${(mobileBreakpoint - 1).toString()}px)`);
|
|
33
|
+
}
|
|
34
|
+
exports.useIsMobile = __webpack_exports__.useIsMobile;
|
|
35
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
36
|
+
"useIsMobile"
|
|
37
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
38
|
+
Object.defineProperty(exports, '__esModule', {
|
|
39
|
+
value: true
|
|
40
|
+
});
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Determine whether the current viewport should be treated as mobile.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Uses {@link useMediaQuery} to evaluate a max-width media query derived from the
|
|
5
|
+
* provided breakpoint. By default, widths below 768px are considered mobile.
|
|
6
6
|
*
|
|
7
|
-
* @
|
|
8
|
-
*
|
|
7
|
+
* @param mobileBreakpoint - Pixel width used as the mobile breakpoint. Values strictly
|
|
8
|
+
* less than this breakpoint are treated as mobile. Defaults to 768.
|
|
9
|
+
* @returns true when the viewport width is less than the given breakpoint; otherwise false.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* const isMobile = useIsMobile();
|
|
14
|
+
* if (isMobile) {
|
|
15
|
+
* // Render compact layout
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
9
18
|
*/
|
|
10
|
-
export declare function useIsMobile(): boolean;
|
|
19
|
+
export declare function useIsMobile(mobileBreakpoint?: number): boolean;
|
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{useMediaQuery
|
|
2
|
+
import { useMediaQuery } from "./use-media-query.js";
|
|
3
|
+
function useIsMobile(mobileBreakpoint = 768) {
|
|
4
|
+
return useMediaQuery(`(max-width: ${(mobileBreakpoint - 1).toString()}px)`);
|
|
5
|
+
}
|
|
6
|
+
export { useIsMobile };
|
|
@@ -1,2 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
"use client";
|
|
2
|
-
|
|
3
|
+
var __webpack_require__ = {};
|
|
4
|
+
(()=>{
|
|
5
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
6
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: definition[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.r = (exports1)=>{
|
|
17
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
18
|
+
value: 'Module'
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
21
|
+
value: true
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
})();
|
|
25
|
+
var __webpack_exports__ = {};
|
|
26
|
+
__webpack_require__.r(__webpack_exports__);
|
|
27
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
28
|
+
useMediaQuery: ()=>useMediaQuery
|
|
29
|
+
});
|
|
30
|
+
const external_react_namespaceObject = require("react");
|
|
31
|
+
function useMediaQuery(query) {
|
|
32
|
+
const [matches, setMatches] = (0, external_react_namespaceObject.useState)(()=>{
|
|
33
|
+
if ("u" > typeof window && "function" == typeof window.matchMedia) return window.matchMedia(query).matches;
|
|
34
|
+
return false;
|
|
35
|
+
});
|
|
36
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
37
|
+
if ("u" < typeof window) return;
|
|
38
|
+
const mediaQueryList = window.matchMedia(query);
|
|
39
|
+
const onChange = (event)=>{
|
|
40
|
+
setMatches(event.matches);
|
|
41
|
+
};
|
|
42
|
+
mediaQueryList.addEventListener("change", onChange);
|
|
43
|
+
return ()=>{
|
|
44
|
+
mediaQueryList.removeEventListener("change", onChange);
|
|
45
|
+
};
|
|
46
|
+
}, [
|
|
47
|
+
query
|
|
48
|
+
]);
|
|
49
|
+
return matches;
|
|
50
|
+
}
|
|
51
|
+
exports.useMediaQuery = __webpack_exports__.useMediaQuery;
|
|
52
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
53
|
+
"useMediaQuery"
|
|
54
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
55
|
+
Object.defineProperty(exports, '__esModule', {
|
|
56
|
+
value: true
|
|
57
|
+
});
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Subscribe to a CSS media query and receive its match state.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Evaluates the query immediately (when supported) and updates on changes
|
|
5
|
+
* via an event listener.
|
|
6
|
+
*
|
|
7
|
+
* @param query - A valid media query string (e.g., "(max-width: 768px)").
|
|
8
|
+
* @returns true when the media query currently matches; otherwise false.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* const isNarrow = useMediaQuery("(max-width: 768px)");
|
|
13
|
+
* ```
|
|
6
14
|
*/
|
|
7
15
|
export declare function useMediaQuery(query: string): boolean;
|
|
@@ -1,2 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{useEffect
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
function useMediaQuery(query) {
|
|
4
|
+
const [matches, setMatches] = useState(()=>{
|
|
5
|
+
if ("u" > typeof window && "function" == typeof window.matchMedia) return window.matchMedia(query).matches;
|
|
6
|
+
return false;
|
|
7
|
+
});
|
|
8
|
+
useEffect(()=>{
|
|
9
|
+
if ("u" < typeof window) return;
|
|
10
|
+
const mediaQueryList = window.matchMedia(query);
|
|
11
|
+
const onChange = (event)=>{
|
|
12
|
+
setMatches(event.matches);
|
|
13
|
+
};
|
|
14
|
+
mediaQueryList.addEventListener("change", onChange);
|
|
15
|
+
return ()=>{
|
|
16
|
+
mediaQueryList.removeEventListener("change", onChange);
|
|
17
|
+
};
|
|
18
|
+
}, [
|
|
19
|
+
query
|
|
20
|
+
]);
|
|
21
|
+
return matches;
|
|
22
|
+
}
|
|
23
|
+
export { useMediaQuery };
|
|
@@ -1,2 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
"use client";
|
|
2
|
-
|
|
3
|
+
var __webpack_require__ = {};
|
|
4
|
+
(()=>{
|
|
5
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
6
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: definition[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.r = (exports1)=>{
|
|
17
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
18
|
+
value: 'Module'
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
21
|
+
value: true
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
})();
|
|
25
|
+
var __webpack_exports__ = {};
|
|
26
|
+
__webpack_require__.r(__webpack_exports__);
|
|
27
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
28
|
+
useMutationObserver: ()=>useMutationObserver
|
|
29
|
+
});
|
|
30
|
+
const external_react_namespaceObject = require("react");
|
|
31
|
+
const defaultOptions = {
|
|
32
|
+
attributes: true,
|
|
33
|
+
characterData: true,
|
|
34
|
+
childList: true,
|
|
35
|
+
subtree: true
|
|
36
|
+
};
|
|
37
|
+
function useMutationObserver(ref, callback, options = defaultOptions) {
|
|
38
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
39
|
+
if (!ref.current) return;
|
|
40
|
+
const observer = new MutationObserver(callback);
|
|
41
|
+
observer.observe(ref.current, options);
|
|
42
|
+
return ()=>{
|
|
43
|
+
observer.disconnect();
|
|
44
|
+
};
|
|
45
|
+
}, [
|
|
46
|
+
ref,
|
|
47
|
+
callback,
|
|
48
|
+
options
|
|
49
|
+
]);
|
|
50
|
+
}
|
|
51
|
+
exports.useMutationObserver = __webpack_exports__.useMutationObserver;
|
|
52
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
53
|
+
"useMutationObserver"
|
|
54
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
55
|
+
Object.defineProperty(exports, '__esModule', {
|
|
56
|
+
value: true
|
|
57
|
+
});
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
import type { RefObject } from "react";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
* function when mutations occur in the observed elements.
|
|
3
|
+
* Observe DOM mutations on a referenced element and invoke a callback.
|
|
5
4
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @param options - Configuration options for the MutationObserver, defaults to watching all changes
|
|
9
|
-
* @returns void
|
|
5
|
+
* Attaches a MutationObserver to the provided element reference with the given
|
|
6
|
+
* options and calls the callback whenever mutations occur.
|
|
10
7
|
*
|
|
11
|
-
* @
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* when mutations occur.
|
|
8
|
+
* @param ref - Ref to the target HTMLElement to observe.
|
|
9
|
+
* @param callback - Mutation callback invoked with observed records.
|
|
10
|
+
* @param options - Observer configuration. Defaults watch attributes, characterData, childList, subtree.
|
|
11
|
+
* @returns void
|
|
16
12
|
*
|
|
17
13
|
* @see [MutationObserver](https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver)
|
|
18
14
|
*/
|
|
@@ -1,2 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{useEffect
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
const defaultOptions = {
|
|
4
|
+
attributes: true,
|
|
5
|
+
characterData: true,
|
|
6
|
+
childList: true,
|
|
7
|
+
subtree: true
|
|
8
|
+
};
|
|
9
|
+
function useMutationObserver(ref, callback, options = defaultOptions) {
|
|
10
|
+
useEffect(()=>{
|
|
11
|
+
if (!ref.current) return;
|
|
12
|
+
const observer = new MutationObserver(callback);
|
|
13
|
+
observer.observe(ref.current, options);
|
|
14
|
+
return ()=>{
|
|
15
|
+
observer.disconnect();
|
|
16
|
+
};
|
|
17
|
+
}, [
|
|
18
|
+
ref,
|
|
19
|
+
callback,
|
|
20
|
+
options
|
|
21
|
+
]);
|
|
22
|
+
}
|
|
23
|
+
export { useMutationObserver };
|
|
@@ -1,2 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
"use client";
|
|
2
|
-
|
|
3
|
+
var __webpack_require__ = {};
|
|
4
|
+
(()=>{
|
|
5
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
6
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: definition[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.r = (exports1)=>{
|
|
17
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
18
|
+
value: 'Module'
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
21
|
+
value: true
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
})();
|
|
25
|
+
var __webpack_exports__ = {};
|
|
26
|
+
__webpack_require__.r(__webpack_exports__);
|
|
27
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
28
|
+
ELLIPSIS: ()=>ELLIPSIS,
|
|
29
|
+
usePagination: ()=>usePagination
|
|
30
|
+
});
|
|
31
|
+
const external_react_namespaceObject = require("react");
|
|
32
|
+
const ELLIPSIS = "•••";
|
|
33
|
+
const createRange = (start, end)=>{
|
|
34
|
+
const length = end - start + 1;
|
|
35
|
+
return Array.from({
|
|
36
|
+
length
|
|
37
|
+
}, (_, index)=>start + index);
|
|
38
|
+
};
|
|
39
|
+
function usePagination({ currentPage, resultsPerPage, siblingPagesCount = 1, totalResults }) {
|
|
40
|
+
return (0, external_react_namespaceObject.useMemo)(()=>{
|
|
41
|
+
const totalPages = Math.ceil(totalResults / Math.floor(resultsPerPage));
|
|
42
|
+
if (totalPages <= 0) return [];
|
|
43
|
+
const visiblePageNumbers = siblingPagesCount + 5;
|
|
44
|
+
if (visiblePageNumbers >= totalPages) return createRange(1, totalPages);
|
|
45
|
+
const leftSiblingIndex = Math.max(currentPage - siblingPagesCount, 1);
|
|
46
|
+
const rightSiblingIndex = Math.min(currentPage + siblingPagesCount, totalPages);
|
|
47
|
+
const shouldShowLeftEllipsis = leftSiblingIndex > 2;
|
|
48
|
+
const shouldShowRightEllipsis = rightSiblingIndex < totalPages - 2;
|
|
49
|
+
const firstPage = 1;
|
|
50
|
+
const lastPage = totalPages;
|
|
51
|
+
if (!shouldShowLeftEllipsis && shouldShowRightEllipsis) {
|
|
52
|
+
const leftRange = createRange(1, 3 + 2 * siblingPagesCount);
|
|
53
|
+
return [
|
|
54
|
+
...leftRange,
|
|
55
|
+
ELLIPSIS,
|
|
56
|
+
lastPage
|
|
57
|
+
];
|
|
58
|
+
}
|
|
59
|
+
if (shouldShowLeftEllipsis && !shouldShowRightEllipsis) {
|
|
60
|
+
const rightRange = createRange(totalPages - (3 + 2 * siblingPagesCount) + 1, totalPages);
|
|
61
|
+
return [
|
|
62
|
+
firstPage,
|
|
63
|
+
ELLIPSIS,
|
|
64
|
+
...rightRange
|
|
65
|
+
];
|
|
66
|
+
}
|
|
67
|
+
if (shouldShowLeftEllipsis && shouldShowRightEllipsis) {
|
|
68
|
+
const middleRange = createRange(leftSiblingIndex, rightSiblingIndex);
|
|
69
|
+
return [
|
|
70
|
+
firstPage,
|
|
71
|
+
ELLIPSIS,
|
|
72
|
+
...middleRange,
|
|
73
|
+
ELLIPSIS,
|
|
74
|
+
lastPage
|
|
75
|
+
];
|
|
76
|
+
}
|
|
77
|
+
return [];
|
|
78
|
+
}, [
|
|
79
|
+
totalResults,
|
|
80
|
+
resultsPerPage,
|
|
81
|
+
siblingPagesCount,
|
|
82
|
+
currentPage
|
|
83
|
+
]);
|
|
84
|
+
}
|
|
85
|
+
exports.ELLIPSIS = __webpack_exports__.ELLIPSIS;
|
|
86
|
+
exports.usePagination = __webpack_exports__.usePagination;
|
|
87
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
88
|
+
"ELLIPSIS",
|
|
89
|
+
"usePagination"
|
|
90
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
91
|
+
Object.defineProperty(exports, '__esModule', {
|
|
92
|
+
value: true
|
|
93
|
+
});
|
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
export interface UsePaginationProps {
|
|
2
|
-
/**
|
|
2
|
+
/** Current active page number. */
|
|
3
3
|
currentPage: number;
|
|
4
|
-
/**
|
|
4
|
+
/** Number of results displayed per page. */
|
|
5
5
|
resultsPerPage: number;
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Number of sibling pages to show on each side of the current page.
|
|
8
8
|
* Defaults to 1.
|
|
9
9
|
*/
|
|
10
10
|
siblingPagesCount?: number;
|
|
11
|
-
/**
|
|
11
|
+
/** Total number of results across all pages. */
|
|
12
12
|
totalResults: number;
|
|
13
13
|
}
|
|
14
|
-
/**
|
|
14
|
+
/** Ellipsis marker used to collapse ranges in pagination output. */
|
|
15
15
|
export declare const ELLIPSIS = "\u2022\u2022\u2022";
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
18
|
-
* results.
|
|
17
|
+
* Compute a pagination structure for result sets.
|
|
19
18
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
19
|
+
* Returns a mixed array of page numbers and the `ELLIPSIS` marker representing
|
|
20
|
+
* collapsed ranges. The shape adapts to the total pages and the requested
|
|
21
|
+
* sibling window around the current page.
|
|
22
|
+
*
|
|
23
|
+
* @param props - Pagination options. See {@link UsePaginationProps}.
|
|
24
|
+
* @returns Array of page numbers and `ELLIPSIS` representing the pagination model.
|
|
23
25
|
*
|
|
24
26
|
* @example
|
|
25
27
|
* ```tsx
|
|
@@ -1,2 +1,56 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{useMemo
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
const ELLIPSIS = "•••";
|
|
4
|
+
const createRange = (start, end)=>{
|
|
5
|
+
const length = end - start + 1;
|
|
6
|
+
return Array.from({
|
|
7
|
+
length
|
|
8
|
+
}, (_, index)=>start + index);
|
|
9
|
+
};
|
|
10
|
+
function usePagination({ currentPage, resultsPerPage, siblingPagesCount = 1, totalResults }) {
|
|
11
|
+
return useMemo(()=>{
|
|
12
|
+
const totalPages = Math.ceil(totalResults / Math.floor(resultsPerPage));
|
|
13
|
+
if (totalPages <= 0) return [];
|
|
14
|
+
const visiblePageNumbers = siblingPagesCount + 5;
|
|
15
|
+
if (visiblePageNumbers >= totalPages) return createRange(1, totalPages);
|
|
16
|
+
const leftSiblingIndex = Math.max(currentPage - siblingPagesCount, 1);
|
|
17
|
+
const rightSiblingIndex = Math.min(currentPage + siblingPagesCount, totalPages);
|
|
18
|
+
const shouldShowLeftEllipsis = leftSiblingIndex > 2;
|
|
19
|
+
const shouldShowRightEllipsis = rightSiblingIndex < totalPages - 2;
|
|
20
|
+
const firstPage = 1;
|
|
21
|
+
const lastPage = totalPages;
|
|
22
|
+
if (!shouldShowLeftEllipsis && shouldShowRightEllipsis) {
|
|
23
|
+
const leftRange = createRange(1, 3 + 2 * siblingPagesCount);
|
|
24
|
+
return [
|
|
25
|
+
...leftRange,
|
|
26
|
+
ELLIPSIS,
|
|
27
|
+
lastPage
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
if (shouldShowLeftEllipsis && !shouldShowRightEllipsis) {
|
|
31
|
+
const rightRange = createRange(totalPages - (3 + 2 * siblingPagesCount) + 1, totalPages);
|
|
32
|
+
return [
|
|
33
|
+
firstPage,
|
|
34
|
+
ELLIPSIS,
|
|
35
|
+
...rightRange
|
|
36
|
+
];
|
|
37
|
+
}
|
|
38
|
+
if (shouldShowLeftEllipsis && shouldShowRightEllipsis) {
|
|
39
|
+
const middleRange = createRange(leftSiblingIndex, rightSiblingIndex);
|
|
40
|
+
return [
|
|
41
|
+
firstPage,
|
|
42
|
+
ELLIPSIS,
|
|
43
|
+
...middleRange,
|
|
44
|
+
ELLIPSIS,
|
|
45
|
+
lastPage
|
|
46
|
+
];
|
|
47
|
+
}
|
|
48
|
+
return [];
|
|
49
|
+
}, [
|
|
50
|
+
totalResults,
|
|
51
|
+
resultsPerPage,
|
|
52
|
+
siblingPagesCount,
|
|
53
|
+
currentPage
|
|
54
|
+
]);
|
|
55
|
+
}
|
|
56
|
+
export { ELLIPSIS, usePagination };
|