@spatika/react 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/AGENTS.md +71 -0
- package/README.md +4 -3
- package/dist/composites/Card.d.ts +7 -1
- package/dist/composites/Card.d.ts.map +1 -1
- package/dist/composites/Card.js +10 -0
- package/dist/composites/ChartDataGrid.d.ts +33 -0
- package/dist/composites/ChartDataGrid.d.ts.map +1 -0
- package/dist/composites/ChartDataGrid.js +77 -0
- package/dist/composites/CoverHero.d.ts +1 -1
- package/dist/composites/CoverHero.d.ts.map +1 -1
- package/dist/composites/CoverHero.js +2 -2
- package/dist/composites/EntityMediaCard.d.ts +1 -1
- package/dist/composites/EntityMediaCard.d.ts.map +1 -1
- package/dist/composites/EntityMediaCard.js +12 -4
- package/dist/composites/EventCalendar.d.ts +35 -0
- package/dist/composites/EventCalendar.d.ts.map +1 -0
- package/dist/composites/EventCalendar.js +339 -0
- package/dist/composites/EventEditor.d.ts +22 -0
- package/dist/composites/EventEditor.d.ts.map +1 -0
- package/dist/composites/EventEditor.js +86 -0
- package/dist/composites/EventTimeline.d.ts +24 -0
- package/dist/composites/EventTimeline.d.ts.map +1 -0
- package/dist/composites/EventTimeline.js +184 -0
- package/dist/composites/MapChart.d.ts +24 -0
- package/dist/composites/MapChart.d.ts.map +1 -0
- package/dist/composites/MapChart.js +58 -0
- package/dist/composites/ProfileHero.d.ts +6 -4
- package/dist/composites/ProfileHero.d.ts.map +1 -1
- package/dist/composites/ProfileHero.js +8 -8
- package/dist/composites/ScatterWebGL.d.ts +22 -0
- package/dist/composites/ScatterWebGL.d.ts.map +1 -0
- package/dist/composites/ScatterWebGL.js +45 -0
- package/dist/composites/SiteFooter.d.ts +1 -1
- package/dist/composites/SiteFooter.js +1 -1
- package/dist/composites/SiteNav.d.ts +7 -2
- package/dist/composites/SiteNav.d.ts.map +1 -1
- package/dist/composites/SiteNav.js +9 -5
- package/dist/composites/StatCard.d.ts +2 -1
- package/dist/composites/StatCard.d.ts.map +1 -1
- package/dist/composites/StatCard.js +3 -3
- package/dist/composites/StatusDot.d.ts +1 -1
- package/dist/composites/Wordmark.d.ts +2 -2
- package/dist/composites/Wordmark.d.ts.map +1 -1
- package/dist/composites/cartesian-charts.d.ts +138 -0
- package/dist/composites/cartesian-charts.d.ts.map +1 -0
- package/dist/composites/cartesian-charts.js +401 -0
- package/dist/composites/chart-composition.d.ts +139 -0
- package/dist/composites/chart-composition.d.ts.map +1 -0
- package/dist/composites/chart-composition.js +486 -0
- package/dist/composites/chart-ui.d.ts +83 -0
- package/dist/composites/chart-ui.d.ts.map +1 -0
- package/dist/composites/chart-ui.js +108 -0
- package/dist/composites/charts-3d.d.ts +37 -0
- package/dist/composites/charts-3d.d.ts.map +1 -0
- package/dist/composites/charts-3d.js +121 -0
- package/dist/composites/flow-charts.d.ts +89 -0
- package/dist/composites/flow-charts.d.ts.map +1 -0
- package/dist/composites/flow-charts.js +186 -0
- package/dist/composites/radial-charts.d.ts +109 -0
- package/dist/composites/radial-charts.d.ts.map +1 -0
- package/dist/composites/radial-charts.js +176 -0
- package/dist/composites/scheduler-ui.d.ts +43 -0
- package/dist/composites/scheduler-ui.d.ts.map +1 -0
- package/dist/composites/scheduler-ui.js +71 -0
- package/dist/index.d.ts +67 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +57 -7
- package/dist/lib/chart-export.d.ts +10 -0
- package/dist/lib/chart-export.d.ts.map +1 -0
- package/dist/lib/chart-export.js +102 -0
- package/dist/lib/charts.d.ts +235 -0
- package/dist/lib/charts.d.ts.map +1 -0
- package/dist/lib/charts.js +744 -0
- package/dist/lib/geo.d.ts +39 -0
- package/dist/lib/geo.d.ts.map +1 -0
- package/dist/lib/geo.js +101 -0
- package/dist/lib/iso.d.ts +21 -0
- package/dist/lib/iso.d.ts.map +1 -0
- package/dist/lib/iso.js +56 -0
- package/dist/lib/rrule.d.ts +20 -0
- package/dist/lib/rrule.d.ts.map +1 -0
- package/dist/lib/rrule.js +236 -0
- package/dist/lib/scheduler.d.ts +152 -0
- package/dist/lib/scheduler.d.ts.map +1 -0
- package/dist/lib/scheduler.js +501 -0
- package/dist/lib/webgl-scatter.d.ts +44 -0
- package/dist/lib/webgl-scatter.d.ts.map +1 -0
- package/dist/lib/webgl-scatter.js +185 -0
- package/dist/primitives/Accordion.d.ts +44 -20
- package/dist/primitives/Accordion.d.ts.map +1 -1
- package/dist/primitives/Accordion.js +82 -22
- package/dist/primitives/AppBar.d.ts +13 -0
- package/dist/primitives/AppBar.d.ts.map +1 -0
- package/dist/primitives/AppBar.js +27 -0
- package/dist/primitives/Autocomplete.d.ts +28 -0
- package/dist/primitives/Autocomplete.d.ts.map +1 -0
- package/dist/primitives/Autocomplete.js +118 -0
- package/dist/primitives/Avatar.d.ts +13 -1
- package/dist/primitives/Avatar.d.ts.map +1 -1
- package/dist/primitives/Avatar.js +17 -2
- package/dist/primitives/Backdrop.d.ts +17 -0
- package/dist/primitives/Backdrop.d.ts.map +1 -0
- package/dist/primitives/Backdrop.js +17 -0
- package/dist/primitives/BottomNavigation.d.ts +23 -0
- package/dist/primitives/BottomNavigation.d.ts.map +1 -0
- package/dist/primitives/BottomNavigation.js +30 -0
- package/dist/primitives/ButtonBase.d.ts +14 -0
- package/dist/primitives/ButtonBase.d.ts.map +1 -0
- package/dist/primitives/ButtonBase.js +13 -0
- package/dist/primitives/ButtonGroup.d.ts +25 -0
- package/dist/primitives/ButtonGroup.d.ts.map +1 -0
- package/dist/primitives/ButtonGroup.js +44 -0
- package/dist/primitives/CircularProgress.d.ts +16 -0
- package/dist/primitives/CircularProgress.d.ts.map +1 -0
- package/dist/primitives/CircularProgress.js +17 -0
- package/dist/primitives/ClickAwayListener.d.ts +16 -0
- package/dist/primitives/ClickAwayListener.d.ts.map +1 -0
- package/dist/primitives/ClickAwayListener.js +33 -0
- package/dist/primitives/Collapse.d.ts +19 -0
- package/dist/primitives/Collapse.d.ts.map +1 -0
- package/dist/primitives/Collapse.js +14 -0
- package/dist/primitives/Container.d.ts +13 -0
- package/dist/primitives/Container.d.ts.map +1 -0
- package/dist/primitives/Container.js +26 -0
- package/dist/primitives/Fab.d.ts +22 -0
- package/dist/primitives/Fab.d.ts.map +1 -0
- package/dist/primitives/Fab.js +42 -0
- package/dist/primitives/FormControl.d.ts +27 -0
- package/dist/primitives/FormControl.d.ts.map +1 -0
- package/dist/primitives/FormControl.js +24 -0
- package/dist/primitives/FormControlLabel.d.ts +18 -0
- package/dist/primitives/FormControlLabel.d.ts.map +1 -0
- package/dist/primitives/FormControlLabel.js +19 -0
- package/dist/primitives/Grid.d.ts +32 -0
- package/dist/primitives/Grid.d.ts.map +1 -0
- package/dist/primitives/Grid.js +50 -0
- package/dist/primitives/IconButton.d.ts +22 -0
- package/dist/primitives/IconButton.d.ts.map +1 -0
- package/dist/primitives/IconButton.js +39 -0
- package/dist/primitives/ImageList.d.ts +31 -0
- package/dist/primitives/ImageList.d.ts.map +1 -0
- package/dist/primitives/ImageList.js +33 -0
- package/dist/primitives/InputAdornment.d.ts +28 -0
- package/dist/primitives/InputAdornment.d.ts.map +1 -0
- package/dist/primitives/InputAdornment.js +13 -0
- package/dist/primitives/Link.d.ts +17 -0
- package/dist/primitives/Link.d.ts.map +1 -0
- package/dist/primitives/Link.js +29 -0
- package/dist/primitives/List.d.ts +41 -0
- package/dist/primitives/List.d.ts.map +1 -0
- package/dist/primitives/List.js +22 -0
- package/dist/primitives/Masonry.d.ts +14 -0
- package/dist/primitives/Masonry.d.ts.map +1 -0
- package/dist/primitives/Masonry.js +15 -0
- package/dist/primitives/Menu.d.ts +28 -0
- package/dist/primitives/Menu.d.ts.map +1 -0
- package/dist/primitives/Menu.js +54 -0
- package/dist/primitives/MobileStepper.d.ts +15 -0
- package/dist/primitives/MobileStepper.d.ts.map +1 -0
- package/dist/primitives/MobileStepper.js +8 -0
- package/dist/primitives/Modal.d.ts +18 -0
- package/dist/primitives/Modal.d.ts.map +1 -0
- package/dist/primitives/Modal.js +29 -0
- package/dist/primitives/NoSsr.d.ts +15 -0
- package/dist/primitives/NoSsr.d.ts.map +1 -0
- package/dist/primitives/NoSsr.js +19 -0
- package/dist/primitives/Paper.d.ts +22 -0
- package/dist/primitives/Paper.d.ts.map +1 -0
- package/dist/primitives/Paper.js +33 -0
- package/dist/primitives/Progress.d.ts +6 -2
- package/dist/primitives/Progress.d.ts.map +1 -1
- package/dist/primitives/Progress.js +8 -3
- package/dist/primitives/Snackbar.d.ts +23 -0
- package/dist/primitives/Snackbar.d.ts.map +1 -0
- package/dist/primitives/Snackbar.js +33 -0
- package/dist/primitives/SpeedDial.d.ts +26 -0
- package/dist/primitives/SpeedDial.d.ts.map +1 -0
- package/dist/primitives/SpeedDial.js +26 -0
- package/dist/primitives/Stack.d.ts +15 -0
- package/dist/primitives/Stack.d.ts.map +1 -0
- package/dist/primitives/Stack.js +45 -0
- package/dist/primitives/StarRating.d.ts +19 -1
- package/dist/primitives/StarRating.d.ts.map +1 -1
- package/dist/primitives/StarRating.js +36 -6
- package/dist/primitives/Stepper.d.ts +36 -0
- package/dist/primitives/Stepper.d.ts.map +1 -0
- package/dist/primitives/Stepper.js +53 -0
- package/dist/primitives/TablePagination.d.ts +16 -0
- package/dist/primitives/TablePagination.d.ts.map +1 -0
- package/dist/primitives/TablePagination.js +12 -0
- package/dist/primitives/TextField.d.ts +24 -0
- package/dist/primitives/TextField.d.ts.map +1 -0
- package/dist/primitives/TextField.js +19 -0
- package/dist/primitives/TextareaAutosize.d.ts +11 -0
- package/dist/primitives/TextareaAutosize.d.ts.map +1 -0
- package/dist/primitives/TextareaAutosize.js +26 -0
- package/dist/primitives/ToggleButton.d.ts +28 -0
- package/dist/primitives/ToggleButton.d.ts.map +1 -0
- package/dist/primitives/ToggleButton.js +56 -0
- package/dist/primitives/TransferList.d.ts +21 -0
- package/dist/primitives/TransferList.d.ts.map +1 -0
- package/dist/primitives/TransferList.js +40 -0
- package/dist/primitives/Typography.d.ts +23 -0
- package/dist/primitives/Typography.d.ts.map +1 -0
- package/dist/primitives/Typography.js +69 -0
- package/dist/primitives/transitions.d.ts +29 -0
- package/dist/primitives/transitions.d.ts.map +1 -0
- package/dist/primitives/transitions.js +52 -0
- package/package.json +28 -4
- package/skills/spatika-ui/SKILL.md +96 -0
- package/src/composites/Card.tsx +51 -1
- package/src/composites/ChartDataGrid.test.tsx +57 -0
- package/src/composites/ChartDataGrid.tsx +196 -0
- package/src/composites/CoverHero.test.tsx +38 -0
- package/src/composites/CoverHero.tsx +29 -22
- package/src/composites/EntityMediaCard.test.tsx +58 -0
- package/src/composites/EntityMediaCard.tsx +31 -13
- package/src/composites/EventCalendar.tsx +928 -0
- package/src/composites/EventEditor.tsx +268 -0
- package/src/composites/EventTimeline.tsx +357 -0
- package/src/composites/MapChart.test.tsx +39 -0
- package/src/composites/MapChart.tsx +130 -0
- package/src/composites/ProfileHero.test.tsx +33 -0
- package/src/composites/ProfileHero.tsx +96 -79
- package/src/composites/ScatterWebGL.test.tsx +25 -0
- package/src/composites/ScatterWebGL.tsx +79 -0
- package/src/composites/SiteFooter.test.tsx +37 -0
- package/src/composites/SiteFooter.tsx +1 -1
- package/src/composites/SiteNav.test.tsx +46 -0
- package/src/composites/SiteNav.tsx +14 -4
- package/src/composites/StatCard.test.tsx +30 -0
- package/src/composites/StatCard.tsx +4 -0
- package/src/composites/Wordmark.test.tsx +23 -0
- package/src/composites/Wordmark.tsx +2 -2
- package/src/composites/cartesian-charts.test.tsx +52 -0
- package/src/composites/cartesian-charts.tsx +1287 -0
- package/src/composites/chart-composition.test.tsx +53 -0
- package/src/composites/chart-composition.tsx +898 -0
- package/src/composites/chart-ui.tsx +328 -0
- package/src/composites/charts-3d.test.tsx +25 -0
- package/src/composites/charts-3d.tsx +318 -0
- package/src/composites/charts.test.tsx +254 -0
- package/src/composites/chrome.test.tsx +29 -0
- package/src/composites/flow-charts.test.tsx +79 -0
- package/src/composites/flow-charts.tsx +607 -0
- package/src/composites/marketing.test.tsx +38 -34
- package/src/composites/radial-charts.test.tsx +74 -0
- package/src/composites/radial-charts.tsx +617 -0
- package/src/composites/scheduler-ui.tsx +304 -0
- package/src/composites/scheduler.test.tsx +194 -0
- package/src/index.test.ts +22 -0
- package/src/index.ts +277 -5
- package/src/lib/chart-export.test.ts +20 -0
- package/src/lib/chart-export.ts +99 -0
- package/src/lib/charts-platform.test.ts +93 -0
- package/src/lib/charts.test.ts +132 -0
- package/src/lib/charts.ts +1021 -0
- package/src/lib/geo.test.ts +42 -0
- package/src/lib/geo.ts +138 -0
- package/src/lib/iso.test.ts +22 -0
- package/src/lib/iso.ts +102 -0
- package/src/lib/rrule.test.ts +53 -0
- package/src/lib/rrule.ts +281 -0
- package/src/lib/scheduler.test.ts +186 -0
- package/src/lib/scheduler.ts +688 -0
- package/src/lib/tokens.test.ts +2 -2
- package/src/lib/webgl-scatter.test.ts +36 -0
- package/src/lib/webgl-scatter.ts +230 -0
- package/src/primitives/Accordion.tsx +218 -63
- package/src/primitives/AppBar.tsx +39 -0
- package/src/primitives/Autocomplete.tsx +236 -0
- package/src/primitives/Avatar.tsx +52 -1
- package/src/primitives/Backdrop.tsx +48 -0
- package/src/primitives/BottomNavigation.tsx +102 -0
- package/src/primitives/ButtonBase.tsx +34 -0
- package/src/primitives/ButtonGroup.tsx +90 -0
- package/src/primitives/CircularProgress.tsx +104 -0
- package/src/primitives/ClickAwayListener.tsx +46 -0
- package/src/primitives/Collapse.tsx +39 -0
- package/src/primitives/Container.tsx +40 -0
- package/src/primitives/Fab.tsx +62 -0
- package/src/primitives/FormControl.tsx +90 -0
- package/src/primitives/FormControlLabel.tsx +51 -0
- package/src/primitives/Grid.tsx +101 -0
- package/src/primitives/IconButton.tsx +59 -0
- package/src/primitives/ImageList.test.tsx +48 -0
- package/src/primitives/ImageList.tsx +112 -0
- package/src/primitives/InputAdornment.tsx +86 -0
- package/src/primitives/Link.tsx +48 -0
- package/src/primitives/List.tsx +121 -0
- package/src/primitives/Masonry.tsx +32 -0
- package/src/primitives/Menu.tsx +112 -0
- package/src/primitives/MobileStepper.tsx +64 -0
- package/src/primitives/Modal.tsx +70 -0
- package/src/primitives/NoSsr.tsx +28 -0
- package/src/primitives/Paper.tsx +55 -0
- package/src/primitives/Progress.tsx +25 -7
- package/src/primitives/Snackbar.tsx +83 -0
- package/src/primitives/SpeedDial.tsx +110 -0
- package/src/primitives/Stack.tsx +88 -0
- package/src/primitives/StarRating.tsx +87 -28
- package/src/primitives/Stepper.tsx +184 -0
- package/src/primitives/TablePagination.tsx +58 -0
- package/src/primitives/TextField.tsx +105 -0
- package/src/primitives/TextareaAutosize.tsx +49 -0
- package/src/primitives/ToggleButton.tsx +148 -0
- package/src/primitives/TransferList.tsx +110 -0
- package/src/primitives/Typography.tsx +90 -0
- package/src/primitives/mui-more.test.tsx +76 -0
- package/src/primitives/mui.test.tsx +134 -0
- package/src/primitives/transitions.tsx +120 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { X } from "lucide-react";
|
|
3
|
+
import { Portal } from "../lib/portal";
|
|
4
|
+
import { cn } from "../lib/cn";
|
|
5
|
+
import { OVERLAY_Z_INDEX, fixedLayerStyle } from "../lib/overlay-stack";
|
|
6
|
+
import { IconButton } from "./IconButton";
|
|
7
|
+
|
|
8
|
+
export type SnackbarOrigin = {
|
|
9
|
+
vertical?: "top" | "bottom";
|
|
10
|
+
horizontal?: "left" | "center" | "right";
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type SnackbarProps = Omit<React.ComponentPropsWithoutRef<"div">, "content"> & {
|
|
14
|
+
open?: boolean;
|
|
15
|
+
onClose?: () => void;
|
|
16
|
+
autoHideDuration?: number | null;
|
|
17
|
+
message?: React.ReactNode;
|
|
18
|
+
action?: React.ReactNode;
|
|
19
|
+
anchorOrigin?: SnackbarOrigin;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const originClass = {
|
|
23
|
+
"top-left": "top-4 left-4",
|
|
24
|
+
"top-center": "top-4 left-1/2 -translate-x-1/2",
|
|
25
|
+
"top-right": "top-4 right-4",
|
|
26
|
+
"bottom-left": "bottom-4 left-4",
|
|
27
|
+
"bottom-center": "bottom-4 left-1/2 -translate-x-1/2",
|
|
28
|
+
"bottom-right": "bottom-4 right-4",
|
|
29
|
+
} as const;
|
|
30
|
+
|
|
31
|
+
function Snackbar({
|
|
32
|
+
open = false,
|
|
33
|
+
onClose,
|
|
34
|
+
autoHideDuration = 4000,
|
|
35
|
+
message,
|
|
36
|
+
action,
|
|
37
|
+
anchorOrigin = { vertical: "bottom", horizontal: "left" },
|
|
38
|
+
className,
|
|
39
|
+
children,
|
|
40
|
+
...props
|
|
41
|
+
}: SnackbarProps) {
|
|
42
|
+
React.useEffect(() => {
|
|
43
|
+
if (!open || !autoHideDuration || !onClose) return;
|
|
44
|
+
const id = window.setTimeout(onClose, autoHideDuration);
|
|
45
|
+
return () => window.clearTimeout(id);
|
|
46
|
+
}, [open, autoHideDuration, onClose]);
|
|
47
|
+
|
|
48
|
+
if (!open) return null;
|
|
49
|
+
|
|
50
|
+
const key = `${anchorOrigin.vertical ?? "bottom"}-${anchorOrigin.horizontal ?? "left"}` as keyof typeof originClass;
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<Portal>
|
|
54
|
+
<div
|
|
55
|
+
role="status"
|
|
56
|
+
data-slot="snackbar"
|
|
57
|
+
className={cn(
|
|
58
|
+
"glass-menu fixed z-[11000] flex max-w-sm items-center gap-3 rounded-xl border border-border/50 px-4 py-3 text-sm font-medium shadow-xl",
|
|
59
|
+
originClass[key],
|
|
60
|
+
className,
|
|
61
|
+
)}
|
|
62
|
+
style={fixedLayerStyle(OVERLAY_Z_INDEX.modal)}
|
|
63
|
+
{...props}
|
|
64
|
+
>
|
|
65
|
+
<div className="min-w-0 flex-1">{message ?? children}</div>
|
|
66
|
+
{action}
|
|
67
|
+
{onClose ? (
|
|
68
|
+
<IconButton aria-label="Close" size="sm" onClick={onClose}>
|
|
69
|
+
<X className="size-3.5" />
|
|
70
|
+
</IconButton>
|
|
71
|
+
) : null}
|
|
72
|
+
</div>
|
|
73
|
+
</Portal>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
Snackbar.displayName = "Snackbar";
|
|
77
|
+
|
|
78
|
+
function SnackbarContent({ className, ...props }: React.ComponentPropsWithoutRef<"div">) {
|
|
79
|
+
return <div data-slot="snackbar-content" className={cn("text-sm font-medium", className)} {...props} />;
|
|
80
|
+
}
|
|
81
|
+
SnackbarContent.displayName = "SnackbarContent";
|
|
82
|
+
|
|
83
|
+
export { Snackbar, SnackbarContent };
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Plus, X } from "lucide-react";
|
|
3
|
+
import { useControllableState } from "../lib/use-controllable-state";
|
|
4
|
+
import { cn } from "../lib/cn";
|
|
5
|
+
import { Backdrop } from "./Backdrop";
|
|
6
|
+
import { Fab } from "./Fab";
|
|
7
|
+
|
|
8
|
+
export type SpeedDialProps = Omit<React.ComponentPropsWithoutRef<"div">, "onChange"> & {
|
|
9
|
+
ariaLabel: string;
|
|
10
|
+
icon?: React.ReactNode;
|
|
11
|
+
openIcon?: React.ReactNode;
|
|
12
|
+
open?: boolean;
|
|
13
|
+
defaultOpen?: boolean;
|
|
14
|
+
onOpenChange?: (open: boolean) => void;
|
|
15
|
+
direction?: "up" | "down" | "left" | "right";
|
|
16
|
+
/** Hide the dimmer behind actions. */
|
|
17
|
+
hideBackdrop?: boolean;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const directionClass = {
|
|
21
|
+
up: "bottom-full mb-3 flex-col-reverse",
|
|
22
|
+
down: "top-full mt-3 flex-col",
|
|
23
|
+
left: "right-full mr-3 flex-row-reverse",
|
|
24
|
+
right: "left-full ml-3 flex-row",
|
|
25
|
+
} as const;
|
|
26
|
+
|
|
27
|
+
function SpeedDial({
|
|
28
|
+
ariaLabel,
|
|
29
|
+
icon,
|
|
30
|
+
openIcon,
|
|
31
|
+
open: openProp,
|
|
32
|
+
defaultOpen = false,
|
|
33
|
+
onOpenChange,
|
|
34
|
+
direction = "up",
|
|
35
|
+
hideBackdrop = false,
|
|
36
|
+
className,
|
|
37
|
+
children,
|
|
38
|
+
...props
|
|
39
|
+
}: SpeedDialProps) {
|
|
40
|
+
const [open = false, setOpen] = useControllableState({
|
|
41
|
+
prop: openProp,
|
|
42
|
+
defaultProp: defaultOpen,
|
|
43
|
+
onChange: onOpenChange,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<div
|
|
48
|
+
data-slot="speed-dial"
|
|
49
|
+
data-open={open ? "" : undefined}
|
|
50
|
+
className={cn("relative inline-flex", className)}
|
|
51
|
+
{...props}
|
|
52
|
+
>
|
|
53
|
+
{!hideBackdrop ? (
|
|
54
|
+
<Backdrop open={open} invisible onClick={() => setOpen(false)} />
|
|
55
|
+
) : null}
|
|
56
|
+
<div
|
|
57
|
+
className={cn(
|
|
58
|
+
"absolute z-10 flex items-center gap-3 transition-[opacity,transform] duration-200",
|
|
59
|
+
directionClass[direction],
|
|
60
|
+
open ? "pointer-events-auto opacity-100" : "pointer-events-none opacity-0",
|
|
61
|
+
)}
|
|
62
|
+
role="menu"
|
|
63
|
+
aria-hidden={!open}
|
|
64
|
+
>
|
|
65
|
+
{children}
|
|
66
|
+
</div>
|
|
67
|
+
<Fab
|
|
68
|
+
aria-label={ariaLabel}
|
|
69
|
+
aria-expanded={open}
|
|
70
|
+
size="md"
|
|
71
|
+
onClick={() => setOpen(!open)}
|
|
72
|
+
>
|
|
73
|
+
{open ? (openIcon ?? <X className="size-5" />) : (icon ?? <Plus className="size-5" />)}
|
|
74
|
+
</Fab>
|
|
75
|
+
</div>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
SpeedDial.displayName = "SpeedDial";
|
|
79
|
+
|
|
80
|
+
export type SpeedDialActionProps = React.ComponentPropsWithoutRef<"button"> & {
|
|
81
|
+
icon: React.ReactNode;
|
|
82
|
+
tooltipTitle?: React.ReactNode;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
function SpeedDialAction({
|
|
86
|
+
icon,
|
|
87
|
+
tooltipTitle,
|
|
88
|
+
className,
|
|
89
|
+
...props
|
|
90
|
+
}: SpeedDialActionProps) {
|
|
91
|
+
return (
|
|
92
|
+
<button
|
|
93
|
+
type="button"
|
|
94
|
+
role="menuitem"
|
|
95
|
+
data-slot="speed-dial-action"
|
|
96
|
+
title={typeof tooltipTitle === "string" ? tooltipTitle : undefined}
|
|
97
|
+
className={cn(
|
|
98
|
+
"flex size-10 items-center justify-center rounded-full border border-border/50 bg-card text-foreground shadow-md outline-none transition-[transform,box-shadow] duration-150 hover:-translate-y-0.5 hover:shadow-lg focus-visible:ring-ring/50 focus-visible:ring-[3px]",
|
|
99
|
+
className,
|
|
100
|
+
)}
|
|
101
|
+
{...props}
|
|
102
|
+
>
|
|
103
|
+
<span className="sr-only">{tooltipTitle}</span>
|
|
104
|
+
{icon}
|
|
105
|
+
</button>
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
SpeedDialAction.displayName = "SpeedDialAction";
|
|
109
|
+
|
|
110
|
+
export { SpeedDial, SpeedDialAction };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { cn } from "../lib/cn";
|
|
3
|
+
|
|
4
|
+
const gapClass: Record<number, string> = {
|
|
5
|
+
0: "gap-0",
|
|
6
|
+
1: "gap-1",
|
|
7
|
+
2: "gap-2",
|
|
8
|
+
3: "gap-3",
|
|
9
|
+
4: "gap-4",
|
|
10
|
+
5: "gap-5",
|
|
11
|
+
6: "gap-6",
|
|
12
|
+
8: "gap-8",
|
|
13
|
+
10: "gap-10",
|
|
14
|
+
12: "gap-12",
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type StackProps = React.ComponentPropsWithoutRef<"div"> & {
|
|
18
|
+
direction?: "row" | "column" | "row-reverse" | "column-reverse";
|
|
19
|
+
spacing?: number;
|
|
20
|
+
align?: "start" | "center" | "end" | "stretch" | "baseline";
|
|
21
|
+
justify?: "start" | "center" | "end" | "between" | "around" | "evenly";
|
|
22
|
+
wrap?: boolean;
|
|
23
|
+
divider?: React.ReactNode;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const directionClass = {
|
|
27
|
+
row: "flex-row",
|
|
28
|
+
column: "flex-col",
|
|
29
|
+
"row-reverse": "flex-row-reverse",
|
|
30
|
+
"column-reverse": "flex-col-reverse",
|
|
31
|
+
} as const;
|
|
32
|
+
|
|
33
|
+
const alignClass = {
|
|
34
|
+
start: "items-start",
|
|
35
|
+
center: "items-center",
|
|
36
|
+
end: "items-end",
|
|
37
|
+
stretch: "items-stretch",
|
|
38
|
+
baseline: "items-baseline",
|
|
39
|
+
} as const;
|
|
40
|
+
|
|
41
|
+
const justifyClass = {
|
|
42
|
+
start: "justify-start",
|
|
43
|
+
center: "justify-center",
|
|
44
|
+
end: "justify-end",
|
|
45
|
+
between: "justify-between",
|
|
46
|
+
around: "justify-around",
|
|
47
|
+
evenly: "justify-evenly",
|
|
48
|
+
} as const;
|
|
49
|
+
|
|
50
|
+
function Stack({
|
|
51
|
+
direction = "column",
|
|
52
|
+
spacing = 2,
|
|
53
|
+
align,
|
|
54
|
+
justify,
|
|
55
|
+
wrap = false,
|
|
56
|
+
divider,
|
|
57
|
+
className,
|
|
58
|
+
children,
|
|
59
|
+
...props
|
|
60
|
+
}: StackProps) {
|
|
61
|
+
const items = React.Children.toArray(children).filter(Boolean);
|
|
62
|
+
const gap = gapClass[spacing] ?? "gap-2";
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<div
|
|
66
|
+
data-slot="stack"
|
|
67
|
+
className={cn(
|
|
68
|
+
"flex",
|
|
69
|
+
directionClass[direction],
|
|
70
|
+
align && alignClass[align],
|
|
71
|
+
justify && justifyClass[justify],
|
|
72
|
+
wrap && "flex-wrap",
|
|
73
|
+
!divider && gap,
|
|
74
|
+
className,
|
|
75
|
+
)}
|
|
76
|
+
{...props}
|
|
77
|
+
>
|
|
78
|
+
{divider
|
|
79
|
+
? items.flatMap((child, index) =>
|
|
80
|
+
index === 0 ? [child] : [divider, child],
|
|
81
|
+
)
|
|
82
|
+
: items}
|
|
83
|
+
</div>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
Stack.displayName = "Stack";
|
|
87
|
+
|
|
88
|
+
export { Stack };
|
|
@@ -1,53 +1,112 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { Star } from "lucide-react";
|
|
3
|
+
import { useControllableState } from "../lib/use-controllable-state";
|
|
3
4
|
import { cn } from "../lib/cn";
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
value
|
|
6
|
+
export type RatingProps = Omit<React.ComponentPropsWithoutRef<"div">, "onChange" | "defaultValue"> & {
|
|
7
|
+
value?: number;
|
|
8
|
+
defaultValue?: number;
|
|
9
|
+
onChange?: (value: number) => void;
|
|
10
|
+
max?: number;
|
|
11
|
+
precision?: 0.5 | 1;
|
|
12
|
+
readOnly?: boolean;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
size?: "sm" | "md" | "lg";
|
|
15
|
+
emptyLabelText?: string;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const sizeClass = {
|
|
19
|
+
sm: "size-4",
|
|
20
|
+
md: "size-5",
|
|
21
|
+
lg: "size-6",
|
|
22
|
+
} as const;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Star rating. `StarRating` is the same component with a required `value`.
|
|
26
|
+
*/
|
|
27
|
+
function Rating({
|
|
28
|
+
value: valueProp,
|
|
29
|
+
defaultValue = 0,
|
|
7
30
|
onChange,
|
|
8
31
|
max = 5,
|
|
32
|
+
precision = 1,
|
|
9
33
|
readOnly = false,
|
|
34
|
+
disabled = false,
|
|
35
|
+
size = "md",
|
|
36
|
+
emptyLabelText = "Rating",
|
|
10
37
|
className,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
})
|
|
38
|
+
...props
|
|
39
|
+
}: RatingProps) {
|
|
40
|
+
const [value = 0, setValue] = useControllableState({
|
|
41
|
+
prop: valueProp,
|
|
42
|
+
defaultProp: defaultValue,
|
|
43
|
+
onChange,
|
|
44
|
+
});
|
|
45
|
+
const [hover, setHover] = React.useState<number | null>(null);
|
|
46
|
+
const display = hover ?? value;
|
|
47
|
+
const locked = readOnly || disabled;
|
|
48
|
+
|
|
18
49
|
return (
|
|
19
50
|
<div
|
|
20
|
-
data-slot="
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
51
|
+
data-slot="rating"
|
|
52
|
+
role={locked ? "img" : "radiogroup"}
|
|
53
|
+
aria-label={`${display} of ${max} stars`}
|
|
54
|
+
className={cn("inline-flex items-center gap-0.5", disabled && "opacity-50", className)}
|
|
55
|
+
{...props}
|
|
24
56
|
>
|
|
25
57
|
{Array.from({ length: max }, (_, i) => {
|
|
26
58
|
const n = i + 1;
|
|
27
|
-
const
|
|
59
|
+
const fill = Math.min(1, Math.max(0, display - i));
|
|
28
60
|
return (
|
|
29
61
|
<button
|
|
30
62
|
key={n}
|
|
31
63
|
type="button"
|
|
32
|
-
|
|
33
|
-
aria-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
)
|
|
38
|
-
|
|
64
|
+
role={locked ? undefined : "radio"}
|
|
65
|
+
aria-checked={locked ? undefined : n === Math.ceil(value)}
|
|
66
|
+
aria-label={`${n} ${emptyLabelText}`}
|
|
67
|
+
disabled={locked}
|
|
68
|
+
className={cn("relative rounded p-0.5", locked ? "cursor-default" : "hover:scale-110 active:scale-95")}
|
|
69
|
+
onMouseEnter={() => {
|
|
70
|
+
if (!locked) setHover(n);
|
|
71
|
+
}}
|
|
72
|
+
onMouseLeave={() => setHover(null)}
|
|
73
|
+
onClick={() => {
|
|
74
|
+
if (locked) return;
|
|
75
|
+
const next = precision === 0.5 && value === n ? n - 0.5 : n;
|
|
76
|
+
setValue(next);
|
|
77
|
+
}}
|
|
39
78
|
>
|
|
40
|
-
<Star
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
79
|
+
<Star className={cn(sizeClass[size], "text-muted-foreground/35")} />
|
|
80
|
+
<span
|
|
81
|
+
className="absolute inset-0.5 overflow-hidden"
|
|
82
|
+
style={{ width: `${fill * 100}%` }}
|
|
83
|
+
>
|
|
84
|
+
<Star className={cn(sizeClass[size], "fill-primary text-primary")} />
|
|
85
|
+
</span>
|
|
46
86
|
</button>
|
|
47
87
|
);
|
|
48
88
|
})}
|
|
49
89
|
</div>
|
|
50
90
|
);
|
|
51
91
|
}
|
|
92
|
+
Rating.displayName = "Rating";
|
|
93
|
+
|
|
94
|
+
function StarRating({
|
|
95
|
+
value,
|
|
96
|
+
onChange,
|
|
97
|
+
max = 5,
|
|
98
|
+
readOnly = false,
|
|
99
|
+
className,
|
|
100
|
+
}: {
|
|
101
|
+
value: number;
|
|
102
|
+
onChange?: (next: number) => void;
|
|
103
|
+
max?: number;
|
|
104
|
+
readOnly?: boolean;
|
|
105
|
+
className?: string;
|
|
106
|
+
}) {
|
|
107
|
+
return (
|
|
108
|
+
<Rating value={value} onChange={onChange} max={max} readOnly={readOnly} className={className} />
|
|
109
|
+
);
|
|
110
|
+
}
|
|
52
111
|
|
|
53
|
-
export { StarRating };
|
|
112
|
+
export { Rating, StarRating };
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Check } from "lucide-react";
|
|
3
|
+
import { cn } from "../lib/cn";
|
|
4
|
+
|
|
5
|
+
type StepperContextValue = {
|
|
6
|
+
activeStep: number;
|
|
7
|
+
orientation: "horizontal" | "vertical";
|
|
8
|
+
alternativeLabel: boolean;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const StepperContext = React.createContext<StepperContextValue | null>(null);
|
|
12
|
+
const StepIndexContext = React.createContext(0);
|
|
13
|
+
|
|
14
|
+
function useStepper(component: string) {
|
|
15
|
+
const ctx = React.useContext(StepperContext);
|
|
16
|
+
if (!ctx) throw new Error(`${component} must be used within <Stepper>`);
|
|
17
|
+
return ctx;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type StepperProps = React.ComponentPropsWithoutRef<"div"> & {
|
|
21
|
+
activeStep?: number;
|
|
22
|
+
orientation?: "horizontal" | "vertical";
|
|
23
|
+
alternativeLabel?: boolean;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
function Stepper({
|
|
27
|
+
activeStep = 0,
|
|
28
|
+
orientation = "horizontal",
|
|
29
|
+
alternativeLabel = false,
|
|
30
|
+
className,
|
|
31
|
+
children,
|
|
32
|
+
...props
|
|
33
|
+
}: StepperProps) {
|
|
34
|
+
const steps = React.Children.toArray(children);
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<StepperContext.Provider
|
|
38
|
+
value={{ activeStep, orientation, alternativeLabel }}
|
|
39
|
+
>
|
|
40
|
+
<div
|
|
41
|
+
data-slot="stepper"
|
|
42
|
+
data-orientation={orientation}
|
|
43
|
+
className={cn(
|
|
44
|
+
"flex w-full",
|
|
45
|
+
orientation === "vertical" ? "flex-col gap-0" : "flex-row items-start",
|
|
46
|
+
className,
|
|
47
|
+
)}
|
|
48
|
+
{...props}
|
|
49
|
+
>
|
|
50
|
+
{steps.map((child, index) => (
|
|
51
|
+
<StepIndexContext.Provider key={index} value={index}>
|
|
52
|
+
{child}
|
|
53
|
+
{index < steps.length - 1 ? <StepConnector /> : null}
|
|
54
|
+
</StepIndexContext.Provider>
|
|
55
|
+
))}
|
|
56
|
+
</div>
|
|
57
|
+
</StepperContext.Provider>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
Stepper.displayName = "Stepper";
|
|
61
|
+
|
|
62
|
+
export type StepProps = React.ComponentPropsWithoutRef<"div"> & {
|
|
63
|
+
completed?: boolean;
|
|
64
|
+
disabled?: boolean;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
function Step({ completed, disabled, className, children, ...props }: StepProps) {
|
|
68
|
+
const stepper = useStepper("Step");
|
|
69
|
+
const index = React.useContext(StepIndexContext);
|
|
70
|
+
const active = stepper.activeStep === index;
|
|
71
|
+
const isCompleted = completed ?? index < stepper.activeStep;
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<div
|
|
75
|
+
data-slot="step"
|
|
76
|
+
data-active={active ? "" : undefined}
|
|
77
|
+
data-completed={isCompleted ? "" : undefined}
|
|
78
|
+
data-disabled={disabled ? "" : undefined}
|
|
79
|
+
className={cn(
|
|
80
|
+
"flex min-w-0",
|
|
81
|
+
stepper.orientation === "vertical" ? "flex-col" : "flex-none",
|
|
82
|
+
stepper.alternativeLabel && "flex-col items-center",
|
|
83
|
+
className,
|
|
84
|
+
)}
|
|
85
|
+
{...props}
|
|
86
|
+
>
|
|
87
|
+
{children}
|
|
88
|
+
</div>
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
Step.displayName = "Step";
|
|
92
|
+
|
|
93
|
+
function StepConnector({ className, ...props }: React.ComponentPropsWithoutRef<"div">) {
|
|
94
|
+
const stepper = useStepper("StepConnector");
|
|
95
|
+
const index = React.useContext(StepIndexContext);
|
|
96
|
+
const completed = index < stepper.activeStep;
|
|
97
|
+
|
|
98
|
+
return (
|
|
99
|
+
<div
|
|
100
|
+
data-slot="step-connector"
|
|
101
|
+
aria-hidden
|
|
102
|
+
className={cn(
|
|
103
|
+
stepper.orientation === "vertical"
|
|
104
|
+
? "ml-[15px] h-6 w-px shrink-0"
|
|
105
|
+
: "mx-2 mt-[15px] h-px min-w-4 flex-1",
|
|
106
|
+
completed ? "bg-primary" : "bg-border",
|
|
107
|
+
className,
|
|
108
|
+
)}
|
|
109
|
+
{...props}
|
|
110
|
+
/>
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
StepConnector.displayName = "StepConnector";
|
|
114
|
+
|
|
115
|
+
export type StepLabelProps = React.ComponentPropsWithoutRef<"div"> & {
|
|
116
|
+
optional?: React.ReactNode;
|
|
117
|
+
error?: boolean;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
function StepLabel({ className, optional, error, children, ...props }: StepLabelProps) {
|
|
121
|
+
const stepper = useStepper("StepLabel");
|
|
122
|
+
const index = React.useContext(StepIndexContext);
|
|
123
|
+
const active = stepper.activeStep === index;
|
|
124
|
+
const completed = index < stepper.activeStep;
|
|
125
|
+
|
|
126
|
+
return (
|
|
127
|
+
<div
|
|
128
|
+
data-slot="step-label"
|
|
129
|
+
className={cn(
|
|
130
|
+
"flex items-center gap-3",
|
|
131
|
+
stepper.alternativeLabel && "flex-col gap-2 text-center",
|
|
132
|
+
className,
|
|
133
|
+
)}
|
|
134
|
+
{...props}
|
|
135
|
+
>
|
|
136
|
+
<span
|
|
137
|
+
className={cn(
|
|
138
|
+
"flex size-8 shrink-0 items-center justify-center rounded-full text-xs font-black",
|
|
139
|
+
completed && "bg-primary text-primary-foreground",
|
|
140
|
+
active && !completed && "bg-primary text-primary-foreground ring-4 ring-primary/20",
|
|
141
|
+
!active && !completed && "border border-border/60 bg-muted/40 text-muted-foreground",
|
|
142
|
+
error && "bg-destructive text-white ring-0",
|
|
143
|
+
)}
|
|
144
|
+
>
|
|
145
|
+
{completed ? <Check className="size-4" /> : index + 1}
|
|
146
|
+
</span>
|
|
147
|
+
<div className="min-w-0">
|
|
148
|
+
<div
|
|
149
|
+
className={cn(
|
|
150
|
+
"text-sm font-bold",
|
|
151
|
+
active || completed ? "text-foreground" : "text-muted-foreground",
|
|
152
|
+
error && "text-destructive",
|
|
153
|
+
)}
|
|
154
|
+
>
|
|
155
|
+
{children}
|
|
156
|
+
</div>
|
|
157
|
+
{optional ? (
|
|
158
|
+
<div className="text-xs font-medium text-muted-foreground">{optional}</div>
|
|
159
|
+
) : null}
|
|
160
|
+
</div>
|
|
161
|
+
</div>
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
StepLabel.displayName = "StepLabel";
|
|
165
|
+
|
|
166
|
+
function StepContent({ className, children, ...props }: React.ComponentPropsWithoutRef<"div">) {
|
|
167
|
+
const stepper = useStepper("StepContent");
|
|
168
|
+
const index = React.useContext(StepIndexContext);
|
|
169
|
+
if (stepper.orientation !== "vertical") return null;
|
|
170
|
+
if (stepper.activeStep !== index) return null;
|
|
171
|
+
|
|
172
|
+
return (
|
|
173
|
+
<div
|
|
174
|
+
data-slot="step-content"
|
|
175
|
+
className={cn("ml-4 border-l border-border/40 py-3 pl-7 text-sm", className)}
|
|
176
|
+
{...props}
|
|
177
|
+
>
|
|
178
|
+
{children}
|
|
179
|
+
</div>
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
StepContent.displayName = "StepContent";
|
|
183
|
+
|
|
184
|
+
export { Stepper, Step, StepLabel, StepContent, StepConnector };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { cn } from "../lib/cn";
|
|
3
|
+
import { NativeSelect } from "./NativeSelect";
|
|
4
|
+
import { Pagination } from "../composites/Pagination";
|
|
5
|
+
|
|
6
|
+
export type TablePaginationProps = {
|
|
7
|
+
count: number;
|
|
8
|
+
page: number;
|
|
9
|
+
onPageChange: (page: number) => void;
|
|
10
|
+
rowsPerPage?: number;
|
|
11
|
+
onRowsPerPageChange?: (rows: number) => void;
|
|
12
|
+
rowsPerPageOptions?: number[];
|
|
13
|
+
className?: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
function TablePagination({
|
|
17
|
+
count,
|
|
18
|
+
page,
|
|
19
|
+
onPageChange,
|
|
20
|
+
rowsPerPage = 10,
|
|
21
|
+
onRowsPerPageChange,
|
|
22
|
+
rowsPerPageOptions = [5, 10, 25],
|
|
23
|
+
className,
|
|
24
|
+
}: TablePaginationProps) {
|
|
25
|
+
const pageCount = Math.max(1, Math.ceil(count / rowsPerPage));
|
|
26
|
+
const from = count === 0 ? 0 : page * rowsPerPage + 1;
|
|
27
|
+
const to = Math.min(count, (page + 1) * rowsPerPage);
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<div
|
|
31
|
+
data-slot="table-pagination"
|
|
32
|
+
className={cn("flex flex-wrap items-center justify-end gap-4 px-2 py-2 text-sm", className)}
|
|
33
|
+
>
|
|
34
|
+
{onRowsPerPageChange ? (
|
|
35
|
+
<label className="flex items-center gap-2 text-xs font-bold text-muted-foreground">
|
|
36
|
+
Rows
|
|
37
|
+
<NativeSelect
|
|
38
|
+
value={String(rowsPerPage)}
|
|
39
|
+
onChange={(event) => onRowsPerPageChange(Number(event.target.value))}
|
|
40
|
+
>
|
|
41
|
+
{rowsPerPageOptions.map((n) => (
|
|
42
|
+
<option key={n} value={n}>
|
|
43
|
+
{n}
|
|
44
|
+
</option>
|
|
45
|
+
))}
|
|
46
|
+
</NativeSelect>
|
|
47
|
+
</label>
|
|
48
|
+
) : null}
|
|
49
|
+
<span className="text-xs font-medium text-muted-foreground">
|
|
50
|
+
{from}–{to} of {count}
|
|
51
|
+
</span>
|
|
52
|
+
<Pagination page={page + 1} pageCount={pageCount} onPageChange={(next) => onPageChange(next - 1)} />
|
|
53
|
+
</div>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
TablePagination.displayName = "TablePagination";
|
|
57
|
+
|
|
58
|
+
export { TablePagination };
|