@betterinternship/components 3.0.3 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/animated-shiny-text.js +12 -0
- package/dist/components/animated-shiny-text.js.map +1 -0
- package/dist/components/autocomplete.js +335 -0
- package/dist/components/autocomplete.js.map +1 -0
- package/dist/components/carousel.js +126 -0
- package/dist/components/carousel.js.map +1 -0
- package/dist/components/chip-select.js +22 -0
- package/dist/components/chip-select.js.map +1 -0
- package/dist/components/collapsible.js +45 -0
- package/dist/components/collapsible.js.map +1 -0
- package/dist/components/context-menu.js +37 -0
- package/dist/components/context-menu.js.map +1 -0
- package/dist/components/dialog.js +10 -10
- package/dist/components/dialog.js.map +1 -1
- package/dist/components/dot-matrix.js +163 -0
- package/dist/components/dot-matrix.js.map +1 -0
- package/dist/components/dropdown.js +262 -0
- package/dist/components/dropdown.js.map +1 -0
- package/dist/components/error.js +19 -0
- package/dist/components/error.js.map +1 -0
- package/dist/components/fab.js +9 -0
- package/dist/components/fab.js.map +1 -0
- package/dist/components/form.js +71 -0
- package/dist/components/form.js.map +1 -0
- package/dist/components/hover-card.js +13 -0
- package/dist/components/hover-card.js.map +1 -0
- package/dist/components/input-otp.js +24 -0
- package/dist/components/input-otp.js.map +1 -0
- package/dist/components/magnetic-button.js +32 -0
- package/dist/components/magnetic-button.js.map +1 -0
- package/dist/components/messages.js +9 -0
- package/dist/components/messages.js.map +1 -0
- package/dist/components/mobile-sheet-portal.js +17 -0
- package/dist/components/mobile-sheet-portal.js.map +1 -0
- package/dist/components/paginator.js +44 -0
- package/dist/components/paginator.js.map +1 -0
- package/dist/components/progress.js +11 -0
- package/dist/components/progress.js.map +1 -0
- package/dist/components/sheet.d.ts +1 -1
- package/dist/components/sheet.js +40 -0
- package/dist/components/sheet.js.map +1 -0
- package/dist/components/slider.js +11 -0
- package/dist/components/slider.js.map +1 -0
- package/dist/components/sonner-toast.js +78 -0
- package/dist/components/sonner-toast.js.map +1 -0
- package/dist/components/timeline.js +16 -0
- package/dist/components/timeline.js.map +1 -0
- package/dist/components/toggle.js +15 -0
- package/dist/components/toggle.js.map +1 -0
- package/dist/hooks/use-detect-click-outside.js +29 -0
- package/dist/hooks/use-detect-click-outside.js.map +1 -0
- package/dist/hooks/use-resource-table.js +284 -0
- package/dist/hooks/use-resource-table.js.map +1 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -1
- package/dist/node_modules/embla-carousel/esm/embla-carousel.esm.js +1670 -0
- package/dist/node_modules/embla-carousel/esm/embla-carousel.esm.js.map +1 -0
- package/dist/node_modules/embla-carousel-react/esm/embla-carousel-react.esm.js +38 -0
- package/dist/node_modules/embla-carousel-react/esm/embla-carousel-react.esm.js.map +1 -0
- package/dist/node_modules/embla-carousel-reactive-utils/esm/embla-carousel-reactive-utils.esm.js +39 -0
- package/dist/node_modules/embla-carousel-reactive-utils/esm/embla-carousel-reactive-utils.esm.js.map +1 -0
- package/dist/node_modules/input-otp/dist/index.js +25 -0
- package/dist/node_modules/input-otp/dist/index.js.map +1 -0
- package/dist/node_modules/react-hook-form/dist/index.esm.js +706 -0
- package/dist/node_modules/react-hook-form/dist/index.esm.js.map +1 -0
- package/package.json +37 -2
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { ChevronLeft, ChevronRight } from 'lucide-react';
|
|
4
|
+
import { useState } from 'react';
|
|
5
|
+
import { Button } from './button.js';
|
|
6
|
+
|
|
7
|
+
const Paginator = ({ totalItems, itemsPerPage, currentPage: controlledPage, onPageChange, }) => {
|
|
8
|
+
const [internalPage, setInternalPage] = useState(1);
|
|
9
|
+
const isControlled = controlledPage !== undefined;
|
|
10
|
+
const currentPage = isControlled ? controlledPage : internalPage;
|
|
11
|
+
const totalPages = Math.ceil(totalItems / itemsPerPage);
|
|
12
|
+
const goToPage = (page) => {
|
|
13
|
+
const clamped = Math.max(1, Math.min(page, totalPages));
|
|
14
|
+
if (!isControlled)
|
|
15
|
+
setInternalPage(clamped);
|
|
16
|
+
if (onPageChange)
|
|
17
|
+
onPageChange(clamped);
|
|
18
|
+
};
|
|
19
|
+
const getDisplayedPages = () => {
|
|
20
|
+
const pages = [];
|
|
21
|
+
// Always show first page
|
|
22
|
+
pages.push(1);
|
|
23
|
+
const left = Math.max(2, currentPage - 1);
|
|
24
|
+
const right = Math.min(totalPages - 1, currentPage + 1);
|
|
25
|
+
if (left > 2) {
|
|
26
|
+
pages.push("ellipsis-left");
|
|
27
|
+
}
|
|
28
|
+
for (let i = left; i <= right; i++) {
|
|
29
|
+
pages.push(i);
|
|
30
|
+
}
|
|
31
|
+
if (right < totalPages - 1) {
|
|
32
|
+
pages.push("ellipsis-right");
|
|
33
|
+
}
|
|
34
|
+
// Always show last page if more than one
|
|
35
|
+
if (totalPages > 1) {
|
|
36
|
+
pages.push(totalPages);
|
|
37
|
+
}
|
|
38
|
+
return pages;
|
|
39
|
+
};
|
|
40
|
+
return (jsxs("div", { className: "flex justify-center items-center space-x-2 mt-4", children: [jsx(Button, { variant: "ghost", iconOnly: true, "aria-label": "Previous page", onClick: () => goToPage(currentPage - 1), disabled: currentPage === 1, children: jsx(ChevronLeft, {}) }), getDisplayedPages().map((page, idx) => typeof page === "number" ? (jsx(Button, { variant: currentPage === page ? "solid" : "ghost", className: "size-11 p-0", onClick: () => goToPage(page), children: page }, idx)) : (jsx("span", { className: "px-2 text-muted-foreground", children: "\u2026" }, idx))), jsx(Button, { variant: "ghost", iconOnly: true, "aria-label": "Next page", onClick: () => goToPage(currentPage + 1), disabled: currentPage === totalPages, children: jsx(ChevronRight, {}) })] }));
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export { Paginator };
|
|
44
|
+
//# sourceMappingURL=paginator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paginator.js","sources":["../../src/components/paginator.tsx"],"sourcesContent":["'use client';\n\nimport { ChevronLeft, ChevronRight } from \"lucide-react\";\nimport React, { useState } from \"react\";\nimport { Button } from \"./button\";\n\ninterface PaginatorProps {\n totalItems: number;\n itemsPerPage: number;\n currentPage?: number;\n onPageChange?: (page: number) => void;\n}\n\nexport const Paginator: React.FC<PaginatorProps> = ({\n totalItems,\n itemsPerPage,\n currentPage: controlledPage,\n onPageChange,\n}) => {\n const [internalPage, setInternalPage] = useState(1);\n const isControlled = controlledPage !== undefined;\n const currentPage = isControlled ? controlledPage : internalPage;\n const totalPages = Math.ceil(totalItems / itemsPerPage);\n\n const goToPage = (page: number) => {\n const clamped = Math.max(1, Math.min(page, totalPages));\n if (!isControlled) setInternalPage(clamped);\n if (onPageChange) onPageChange(clamped);\n };\n\n const getDisplayedPages = () => {\n const pages = [];\n\n // Always show first page\n pages.push(1);\n\n const left = Math.max(2, currentPage - 1);\n const right = Math.min(totalPages - 1, currentPage + 1);\n\n if (left > 2) {\n pages.push(\"ellipsis-left\");\n }\n\n for (let i = left; i <= right; i++) {\n pages.push(i);\n }\n\n if (right < totalPages - 1) {\n pages.push(\"ellipsis-right\");\n }\n\n // Always show last page if more than one\n if (totalPages > 1) {\n pages.push(totalPages);\n }\n\n return pages;\n };\n\n return (\n <div className=\"flex justify-center items-center space-x-2 mt-4\">\n <Button\n variant={\"ghost\"}\n iconOnly\n aria-label=\"Previous page\"\n onClick={() => goToPage(currentPage - 1)}\n disabled={currentPage === 1}\n >\n <ChevronLeft></ChevronLeft>\n </Button>\n\n {getDisplayedPages().map((page, idx) =>\n typeof page === \"number\" ? (\n <Button\n key={idx}\n variant={currentPage === page ? \"solid\" : \"ghost\"}\n className=\"size-11 p-0\"\n onClick={() => goToPage(page)}\n >\n {page}\n </Button>\n ) : (\n <span key={idx} className=\"px-2 text-muted-foreground\">\n …\n </span>\n ),\n )}\n\n <Button\n variant={\"ghost\"}\n iconOnly\n aria-label=\"Next page\"\n onClick={() => goToPage(currentPage + 1)}\n disabled={currentPage === totalPages}\n >\n <ChevronRight></ChevronRight>\n </Button>\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;AAaO;;AAOL;;;AAIA;AACE;AACA;;AACA;;AACF;;;;AAME;AAEA;AACA;AAEA;AACE;;AAGF;AACE;;AAGF;AACE;;;AAIF;AACE;;AAGF;AACF;AAEA;AAwCF;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import * as ProgressPrimitive from '@radix-ui/react-progress';
|
|
5
|
+
import { cn } from '../utils.js';
|
|
6
|
+
|
|
7
|
+
const Progress = React.forwardRef(({ className, value, ...props }, ref) => (jsx(ProgressPrimitive.Root, { ref: ref, className: cn("relative h-2 w-full overflow-hidden rounded-pill bg-muted", className), value: value, ...props, children: jsx(ProgressPrimitive.Indicator, { className: "h-full rounded-pill bg-primary transition-[width] duration-state ease-landing-out motion-reduce:transition-none", style: { width: `${Math.max(0, Math.min(100, ((value ?? 0) / (props.max ?? 100)) * 100))}%` } }) })));
|
|
8
|
+
Progress.displayName = ProgressPrimitive.Root.displayName;
|
|
9
|
+
|
|
10
|
+
export { Progress };
|
|
11
|
+
//# sourceMappingURL=progress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.js","sources":["../../src/components/progress.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport * as ProgressPrimitive from \"@radix-ui/react-progress\";\n\nimport { cn } from \"@/utils\";\n\nconst Progress = React.forwardRef<\n React.ElementRef<typeof ProgressPrimitive.Root>,\n React.ComponentPropsWithoutRef<typeof ProgressPrimitive.Root>\n>(({ className, value, ...props }, ref) => (\n <ProgressPrimitive.Root\n ref={ref}\n className={cn(\n \"relative h-2 w-full overflow-hidden rounded-pill bg-muted\",\n className,\n )}\n value={value}\n {...props}\n >\n <ProgressPrimitive.Indicator\n className=\"h-full rounded-pill bg-primary transition-[width] duration-state ease-landing-out motion-reduce:transition-none\"\n style={{ width: `${Math.max(0, Math.min(100, ((value ?? 0) / (props.max ?? 100)) * 100))}%` }}\n />\n </ProgressPrimitive.Root>\n));\nProgress.displayName = ProgressPrimitive.Root.displayName;\n\nexport { Progress };\n"],"names":[],"mappings":";;;;;;AAOA;AAmBA;;"}
|
|
@@ -7,7 +7,7 @@ declare const SheetClose: React.ForwardRefExoticComponent<SheetPrimitive.DialogC
|
|
|
7
7
|
declare const SheetPortal: React.FC<SheetPrimitive.DialogPortalProps>;
|
|
8
8
|
declare const SheetOverlay: React.ForwardRefExoticComponent<Omit<SheetPrimitive.DialogOverlayProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
9
9
|
declare const sheetVariants: (props?: ({
|
|
10
|
-
side?: "
|
|
10
|
+
side?: "left" | "right" | "top" | "bottom" | null | undefined;
|
|
11
11
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
12
12
|
interface SheetContentProps extends React.ComponentPropsWithoutRef<typeof SheetPrimitive.Content>, VariantProps<typeof sheetVariants> {
|
|
13
13
|
showCloseButton?: boolean;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import * as SheetPrimitive from '@radix-ui/react-dialog';
|
|
5
|
+
import { cva } from '../node_modules/class-variance-authority/dist/index.js';
|
|
6
|
+
import { X } from 'lucide-react';
|
|
7
|
+
import { cn } from '../utils.js';
|
|
8
|
+
|
|
9
|
+
const Sheet = SheetPrimitive.Root;
|
|
10
|
+
const SheetTrigger = SheetPrimitive.Trigger;
|
|
11
|
+
const SheetClose = SheetPrimitive.Close;
|
|
12
|
+
const SheetPortal = SheetPrimitive.Portal;
|
|
13
|
+
const SheetOverlay = React.forwardRef(({ className, ...props }, ref) => (jsx(SheetPrimitive.Overlay, { className: cn("fixed inset-0 z-[1100] bg-black/30 data-[state=open]:animate-in motion-reduce:animate-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0", className), ...props, ref: ref })));
|
|
14
|
+
SheetOverlay.displayName = SheetPrimitive.Overlay.displayName;
|
|
15
|
+
const sheetVariants = cva("fixed z-[1101] gap-4 overflow-y-auto overscroll-contain border-border bg-background p-6 text-base text-foreground shadow-card transition ease-out-strong data-[state=open]:animate-in motion-reduce:animate-none data-[state=closed]:animate-out data-[state=closed]:duration-200 data-[state=open]:duration-200", {
|
|
16
|
+
variants: {
|
|
17
|
+
side: {
|
|
18
|
+
top: "inset-x-0 top-0 max-h-[90dvh] rounded-b-control-lg border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",
|
|
19
|
+
bottom: "inset-x-0 bottom-0 max-h-[90dvh] rounded-t-control-lg border-t pb-[max(1.5rem,env(safe-area-inset-bottom))] data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",
|
|
20
|
+
left: "inset-y-0 left-0 h-full w-3/4 rounded-r-control-lg border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",
|
|
21
|
+
right: "inset-y-0 right-0 h-full w-3/4 rounded-l-control-lg border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm",
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
defaultVariants: {
|
|
25
|
+
side: "right",
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
const SheetContent = React.forwardRef(({ side = "right", className, children, showCloseButton = true, overlayClassName, ...props }, ref) => (jsxs(SheetPortal, { children: [jsx(SheetOverlay, { className: overlayClassName }), jsxs(SheetPrimitive.Content, { ref: ref, className: cn(sheetVariants({ side }), className), ...props, children: [children, showCloseButton && jsxs(SheetPrimitive.Close, { className: "absolute right-4 top-4 flex size-11 items-center justify-center rounded-control-lg text-muted-foreground transition-colors duration-state hover:bg-accent hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring disabled:pointer-events-none motion-reduce:transition-none [&_svg]:size-4", children: [jsx(X, { className: "h-4 w-4" }), jsx("span", { className: "sr-only", children: "Close" })] })] })] })));
|
|
29
|
+
SheetContent.displayName = SheetPrimitive.Content.displayName;
|
|
30
|
+
const SheetHeader = ({ className, ...props }) => (jsx("div", { className: cn("flex flex-col space-y-2 pr-10 text-left", className), ...props }));
|
|
31
|
+
SheetHeader.displayName = "SheetHeader";
|
|
32
|
+
const SheetFooter = ({ className, ...props }) => (jsx("div", { className: cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className), ...props }));
|
|
33
|
+
SheetFooter.displayName = "SheetFooter";
|
|
34
|
+
const SheetTitle = React.forwardRef(({ className, ...props }, ref) => (jsx(SheetPrimitive.Title, { ref: ref, className: cn("text-xl font-semibold text-foreground", className), ...props })));
|
|
35
|
+
SheetTitle.displayName = SheetPrimitive.Title.displayName;
|
|
36
|
+
const SheetDescription = React.forwardRef(({ className, ...props }, ref) => (jsx(SheetPrimitive.Description, { ref: ref, className: cn("text-sm text-muted-foreground", className), ...props })));
|
|
37
|
+
SheetDescription.displayName = SheetPrimitive.Description.displayName;
|
|
38
|
+
|
|
39
|
+
export { Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetPortal, SheetTitle, SheetTrigger };
|
|
40
|
+
//# sourceMappingURL=sheet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sheet.js","sources":["../../src/components/sheet.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport * as SheetPrimitive from \"@radix-ui/react-dialog\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport { X } from \"lucide-react\";\n\nimport { cn } from \"@/utils\";\n\nconst Sheet = SheetPrimitive.Root;\n\nconst SheetTrigger = SheetPrimitive.Trigger;\n\nconst SheetClose = SheetPrimitive.Close;\n\nconst SheetPortal = SheetPrimitive.Portal;\n\nconst SheetOverlay = React.forwardRef<\n React.ElementRef<typeof SheetPrimitive.Overlay>,\n React.ComponentPropsWithoutRef<typeof SheetPrimitive.Overlay>\n>(({ className, ...props }, ref) => (\n <SheetPrimitive.Overlay\n className={cn(\n \"fixed inset-0 z-[1100] bg-black/30 data-[state=open]:animate-in motion-reduce:animate-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0\",\n className,\n )}\n {...props}\n ref={ref}\n />\n));\nSheetOverlay.displayName = SheetPrimitive.Overlay.displayName;\n\nconst sheetVariants = cva(\n \"fixed z-[1101] gap-4 overflow-y-auto overscroll-contain border-border bg-background p-6 text-base text-foreground shadow-card transition ease-out-strong data-[state=open]:animate-in motion-reduce:animate-none data-[state=closed]:animate-out data-[state=closed]:duration-200 data-[state=open]:duration-200\",\n {\n variants: {\n side: {\n top: \"inset-x-0 top-0 max-h-[90dvh] rounded-b-control-lg border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top\",\n bottom:\n \"inset-x-0 bottom-0 max-h-[90dvh] rounded-t-control-lg border-t pb-[max(1.5rem,env(safe-area-inset-bottom))] data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom\",\n left: \"inset-y-0 left-0 h-full w-3/4 rounded-r-control-lg border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm\",\n right:\n \"inset-y-0 right-0 h-full w-3/4 rounded-l-control-lg border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm\",\n },\n },\n defaultVariants: {\n side: \"right\",\n },\n },\n);\n\ninterface SheetContentProps\n extends\n React.ComponentPropsWithoutRef<typeof SheetPrimitive.Content>,\n VariantProps<typeof sheetVariants> {\n showCloseButton?: boolean;\n overlayClassName?: string;\n}\n\nconst SheetContent = React.forwardRef<\n React.ElementRef<typeof SheetPrimitive.Content>,\n SheetContentProps\n>(({ side = \"right\", className, children, showCloseButton = true, overlayClassName, ...props }, ref) => (\n <SheetPortal>\n <SheetOverlay className={overlayClassName} />\n <SheetPrimitive.Content\n ref={ref}\n className={cn(sheetVariants({ side }), className)}\n {...props}\n >\n {children}\n {showCloseButton && <SheetPrimitive.Close className=\"absolute right-4 top-4 flex size-11 items-center justify-center rounded-control-lg text-muted-foreground transition-colors duration-state hover:bg-accent hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring disabled:pointer-events-none motion-reduce:transition-none [&_svg]:size-4\">\n <X className=\"h-4 w-4\" />\n <span className=\"sr-only\">Close</span>\n </SheetPrimitive.Close>}\n </SheetPrimitive.Content>\n </SheetPortal>\n));\nSheetContent.displayName = SheetPrimitive.Content.displayName;\n\nconst SheetHeader = ({\n className,\n ...props\n}: React.HTMLAttributes<HTMLDivElement>) => (\n <div\n className={cn(\n \"flex flex-col space-y-2 pr-10 text-left\",\n className,\n )}\n {...props}\n />\n);\nSheetHeader.displayName = \"SheetHeader\";\n\nconst SheetFooter = ({\n className,\n ...props\n}: React.HTMLAttributes<HTMLDivElement>) => (\n <div\n className={cn(\n \"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2\",\n className,\n )}\n {...props}\n />\n);\nSheetFooter.displayName = \"SheetFooter\";\n\nconst SheetTitle = React.forwardRef<\n React.ElementRef<typeof SheetPrimitive.Title>,\n React.ComponentPropsWithoutRef<typeof SheetPrimitive.Title>\n>(({ className, ...props }, ref) => (\n <SheetPrimitive.Title\n ref={ref}\n className={cn(\"text-xl font-semibold text-foreground\", className)}\n {...props}\n />\n));\nSheetTitle.displayName = SheetPrimitive.Title.displayName;\n\nconst SheetDescription = React.forwardRef<\n React.ElementRef<typeof SheetPrimitive.Description>,\n React.ComponentPropsWithoutRef<typeof SheetPrimitive.Description>\n>(({ className, ...props }, ref) => (\n <SheetPrimitive.Description\n ref={ref}\n className={cn(\"text-sm text-muted-foreground\", className)}\n {...props}\n />\n));\nSheetDescription.displayName = SheetPrimitive.Description.displayName;\n\nexport {\n Sheet,\n SheetPortal,\n SheetOverlay,\n SheetTrigger,\n SheetClose,\n SheetContent,\n SheetHeader,\n SheetFooter,\n SheetTitle,\n SheetDescription,\n};\n"],"names":[],"mappings":";;;;;;;;AASA;AAEA;AAEA;AAEA;AAEA;AAaA;AAEA;AAGI;AACE;AACE;AACA;AAEA;AACA;AAED;AACF;AACD;AACE;AACD;AACF;AAWH;AAmBA;AAEA;AAYA;AAEA;AAYA;AAEA;AAUA;AAEA;AAUA;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import * as SliderPrimitive from '@radix-ui/react-slider';
|
|
5
|
+
import { cn } from '../utils.js';
|
|
6
|
+
|
|
7
|
+
const Slider = React.forwardRef(({ className, ...props }, ref) => (jsxs(SliderPrimitive.Root, { ref: ref, className: cn("group/slider relative flex min-h-11 w-full touch-none select-none items-center data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50", className), ...props, children: [jsx(SliderPrimitive.Track, { className: "relative h-2 w-full grow overflow-hidden rounded-pill bg-muted", children: jsx(SliderPrimitive.Range, { className: "absolute h-full rounded-pill bg-primary" }) }), jsx(SliderPrimitive.Thumb, { className: "relative block size-5 cursor-grab rounded-pill border-2 border-primary bg-background shadow-xs outline-none ring-0 ring-primary/15 transition-[scale,box-shadow,border-color] duration-interactive ease-landing-out after:absolute after:-inset-3 after:content-[''] hover:ring-4 group-active/slider:cursor-grabbing group-active/slider:ring-8 motion-safe:group-active/slider:scale-110 focus-visible:outline-3 focus-visible:outline-offset-4 focus-visible:outline-landing-blue data-[disabled]:pointer-events-none motion-reduce:transition-none" })] })));
|
|
8
|
+
Slider.displayName = SliderPrimitive.Root.displayName;
|
|
9
|
+
|
|
10
|
+
export { Slider };
|
|
11
|
+
//# sourceMappingURL=slider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slider.js","sources":["../../src/components/slider.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport * as SliderPrimitive from \"@radix-ui/react-slider\";\n\nimport { cn } from \"@/utils\";\n\nconst Slider = React.forwardRef<\n React.ElementRef<typeof SliderPrimitive.Root>,\n React.ComponentPropsWithoutRef<typeof SliderPrimitive.Root>\n>(({ className, ...props }, ref) => (\n <SliderPrimitive.Root\n ref={ref}\n className={cn(\n \"group/slider relative flex min-h-11 w-full touch-none select-none items-center data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50\",\n className,\n )}\n {...props}\n >\n <SliderPrimitive.Track className=\"relative h-2 w-full grow overflow-hidden rounded-pill bg-muted\">\n <SliderPrimitive.Range className=\"absolute h-full rounded-pill bg-primary\" />\n </SliderPrimitive.Track>\n <SliderPrimitive.Thumb className=\"relative block size-5 cursor-grab rounded-pill border-2 border-primary bg-background shadow-xs outline-none ring-0 ring-primary/15 transition-[scale,box-shadow,border-color] duration-interactive ease-landing-out after:absolute after:-inset-3 after:content-[''] hover:ring-4 group-active/slider:cursor-grabbing group-active/slider:ring-8 motion-safe:group-active/slider:scale-110 focus-visible:outline-3 focus-visible:outline-offset-4 focus-visible:outline-landing-blue data-[disabled]:pointer-events-none motion-reduce:transition-none\" />\n </SliderPrimitive.Root>\n));\nSlider.displayName = SliderPrimitive.Root.displayName;\n\nexport { Slider };\n"],"names":[],"mappings":";;;;;;AAOA;AAkBA;;"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { Toaster } from 'sonner';
|
|
3
|
+
import { Loader2, Info, AlertTriangle, AlertCircle, CheckCircle } from 'lucide-react';
|
|
4
|
+
|
|
5
|
+
const createToastPreset = (icon, background, options = {}) => {
|
|
6
|
+
const { center = false, fitContent = false, color = "var(--color-foreground)" } = options;
|
|
7
|
+
return {
|
|
8
|
+
icon,
|
|
9
|
+
style: {
|
|
10
|
+
background: `color-mix(in srgb, ${background} 9%, var(--color-background))`,
|
|
11
|
+
color,
|
|
12
|
+
border: `1px solid color-mix(in srgb, ${background} 48%, var(--color-border))`,
|
|
13
|
+
display: "flex",
|
|
14
|
+
alignItems: "center",
|
|
15
|
+
justifyContent: center ? "center" : "flex-start",
|
|
16
|
+
borderRadius: "var(--radius-control-lg)",
|
|
17
|
+
boxShadow: "0 16px 40px -16px rgb(16 16 68 / 0.55)",
|
|
18
|
+
padding: "0.75rem 1rem",
|
|
19
|
+
minHeight: "3.25rem",
|
|
20
|
+
...(fitContent && { width: "fit-content" }),
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
const toastPresets = {
|
|
25
|
+
success: createToastPreset(jsx(CheckCircle, { className: "h-5 w-5 text-supportive" }), "var(--color-supportive)"),
|
|
26
|
+
destructive: createToastPreset(jsx(AlertCircle, { className: "h-5 w-5 text-destructive" }), "var(--color-destructive)"),
|
|
27
|
+
alert: createToastPreset(jsx(AlertTriangle, { className: "h-5 w-5 text-warning" }), "var(--color-warning)"),
|
|
28
|
+
info: createToastPreset(jsx(Info, { className: "h-5 w-5 text-landing-blue" }), "var(--color-landing-control)"),
|
|
29
|
+
loading: {
|
|
30
|
+
...createToastPreset(jsx(Loader2, { className: "h-5 w-5 animate-spin" }), "#ffffff", { color: "#111827" }),
|
|
31
|
+
duration: Infinity,
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
function createCustomToastPreset(background, icon, options) {
|
|
35
|
+
return createToastPreset(icon, background, options);
|
|
36
|
+
}
|
|
37
|
+
function SonnerToaster() {
|
|
38
|
+
return (jsxs(Fragment, { children: [jsx("style", { children: `
|
|
39
|
+
[data-sonner-toast] {
|
|
40
|
+
padding-right: 2.75rem;
|
|
41
|
+
}
|
|
42
|
+
[data-sonner-toast] [data-close-button],
|
|
43
|
+
[data-sonner-toast] .sonner-close-button {
|
|
44
|
+
left: auto !important;
|
|
45
|
+
right: 0.625rem !important;
|
|
46
|
+
top: 50% !important;
|
|
47
|
+
transform: translateY(-50%) !important;
|
|
48
|
+
background: transparent !important;
|
|
49
|
+
border: 0 !important;
|
|
50
|
+
box-shadow: none !important;
|
|
51
|
+
color: var(--color-foreground) !important;
|
|
52
|
+
width: 2rem !important;
|
|
53
|
+
height: 2rem !important;
|
|
54
|
+
font-size: 1.25rem !important;
|
|
55
|
+
}
|
|
56
|
+
[data-sonner-toast][data-type="success"] .sonner-close-button {
|
|
57
|
+
color: var(--color-supportive) !important;
|
|
58
|
+
}
|
|
59
|
+
[data-sonner-toast][data-type="error"] .sonner-close-button {
|
|
60
|
+
color: var(--color-destructive) !important;
|
|
61
|
+
}
|
|
62
|
+
[data-sonner-toast][data-type="warning"] .sonner-close-button {
|
|
63
|
+
color: var(--color-warning) !important;
|
|
64
|
+
}
|
|
65
|
+
[data-sonner-toast][data-type="info"] .sonner-close-button {
|
|
66
|
+
color: var(--color-landing-blue) !important;
|
|
67
|
+
}
|
|
68
|
+
` }), jsx(Toaster, { position: "bottom-right", closeButton: true, toastOptions: {
|
|
69
|
+
className: "!rounded-control-lg !shadow-card !max-w-sm",
|
|
70
|
+
style: {
|
|
71
|
+
fontFamily: "var(--font-sans)",
|
|
72
|
+
padding: "0.75rem 1rem",
|
|
73
|
+
},
|
|
74
|
+
} })] }));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export { SonnerToaster, createCustomToastPreset, toastPresets };
|
|
78
|
+
//# sourceMappingURL=sonner-toast.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sonner-toast.js","sources":["../../src/components/sonner-toast.tsx"],"sourcesContent":["import { Toaster } from \"sonner\";\nimport { CheckCircle, AlertCircle, AlertTriangle, Info, Loader2 } from \"lucide-react\";\n\ninterface ToastOptions {\n center?: boolean;\n fitContent?: boolean;\n color?: string;\n}\n\nconst createToastPreset = (\n icon: React.ReactNode,\n background: string,\n options: ToastOptions = {}\n) => {\n const { center = false, fitContent = false, color = \"var(--color-foreground)\" } = options;\n return {\n icon,\n style: {\n background: `color-mix(in srgb, ${background} 9%, var(--color-background))`,\n color,\n border: `1px solid color-mix(in srgb, ${background} 48%, var(--color-border))`,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: center ? \"center\" : \"flex-start\",\n borderRadius: \"var(--radius-control-lg)\",\n boxShadow: \"0 16px 40px -16px rgb(16 16 68 / 0.55)\",\n padding: \"0.75rem 1rem\",\n minHeight: \"3.25rem\",\n ...(fitContent && { width: \"fit-content\" }),\n },\n };\n};\n\nexport const toastPresets = {\n success: createToastPreset(<CheckCircle className=\"h-5 w-5 text-supportive\" />, \"var(--color-supportive)\"),\n destructive: createToastPreset(<AlertCircle className=\"h-5 w-5 text-destructive\" />, \"var(--color-destructive)\"),\n alert: createToastPreset(<AlertTriangle className=\"h-5 w-5 text-warning\" />, \"var(--color-warning)\"),\n info: createToastPreset(<Info className=\"h-5 w-5 text-landing-blue\" />, \"var(--color-landing-control)\"),\n loading: {\n ...createToastPreset(\n <Loader2 className=\"h-5 w-5 animate-spin\" />,\n \"#ffffff\",\n { color: \"#111827\" },\n ),\n duration: Infinity,\n },\n};\n\nexport function createCustomToastPreset(\n background: string,\n icon: React.ReactNode,\n options?: ToastOptions\n) {\n return createToastPreset(icon, background, options);\n}\n\nexport function SonnerToaster() {\n return (\n <>\n <style>{`\n [data-sonner-toast] {\n padding-right: 2.75rem;\n }\n [data-sonner-toast] [data-close-button],\n [data-sonner-toast] .sonner-close-button {\n left: auto !important;\n right: 0.625rem !important;\n top: 50% !important;\n transform: translateY(-50%) !important;\n background: transparent !important;\n border: 0 !important;\n box-shadow: none !important;\n color: var(--color-foreground) !important;\n width: 2rem !important;\n height: 2rem !important;\n font-size: 1.25rem !important;\n }\n [data-sonner-toast][data-type=\"success\"] .sonner-close-button {\n color: var(--color-supportive) !important;\n }\n [data-sonner-toast][data-type=\"error\"] .sonner-close-button {\n color: var(--color-destructive) !important;\n }\n [data-sonner-toast][data-type=\"warning\"] .sonner-close-button {\n color: var(--color-warning) !important;\n }\n [data-sonner-toast][data-type=\"info\"] .sonner-close-button {\n color: var(--color-landing-blue) !important;\n }\n `}</style>\n <Toaster\n position=\"bottom-right\"\n closeButton\n toastOptions={{\n className: \"!rounded-control-lg !shadow-card !max-w-sm\",\n style: {\n fontFamily: \"var(--font-sans)\",\n padding: \"0.75rem 1rem\",\n },\n }}\n />\n </>\n );\n}\n"],"names":["_jsx","_jsxs"],"mappings":";;;;AASA,MAAM,iBAAiB,GAAG,CACxB,IAAqB,EACrB,UAAkB,EAClB,OAAA,GAAwB,EAAE,KACxB;AACF,IAAA,MAAM,EAAE,MAAM,GAAG,KAAK,EAAE,UAAU,GAAG,KAAK,EAAE,KAAK,GAAG,yBAAyB,EAAE,GAAG,OAAO;IACzF,OAAO;QACL,IAAI;AACJ,QAAA,KAAK,EAAE;YACL,UAAU,EAAE,CAAA,mBAAA,EAAsB,UAAU,CAAA,6BAAA,CAA+B;YAC3E,KAAK;YACL,MAAM,EAAE,CAAA,6BAAA,EAAgC,UAAU,CAAA,0BAAA,CAA4B;AAC9E,YAAA,OAAO,EAAE,MAAM;AACf,YAAA,UAAU,EAAE,QAAQ;YACpB,cAAc,EAAE,MAAM,GAAG,QAAQ,GAAG,YAAY;AAChD,YAAA,YAAY,EAAE,0BAA0B;AACxC,YAAA,SAAS,EAAE,wCAAwC;AACnD,YAAA,OAAO,EAAE,cAAc;AACvB,YAAA,SAAS,EAAE,SAAS;YACpB,IAAI,UAAU,IAAI,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC;AAC5C,SAAA;KACF;AACH,CAAC;AAEM,MAAM,YAAY,GAAG;AAC1B,IAAA,OAAO,EAAE,iBAAiB,CAACA,GAAA,CAAC,WAAW,EAAA,EAAC,SAAS,EAAC,yBAAyB,EAAA,CAAG,EAAE,yBAAyB,CAAC;AAC1G,IAAA,WAAW,EAAE,iBAAiB,CAACA,GAAA,CAAC,WAAW,EAAA,EAAC,SAAS,EAAC,0BAA0B,EAAA,CAAG,EAAE,0BAA0B,CAAC;AAChH,IAAA,KAAK,EAAE,iBAAiB,CAACA,GAAA,CAAC,aAAa,EAAA,EAAC,SAAS,EAAC,sBAAsB,EAAA,CAAG,EAAE,sBAAsB,CAAC;AACpG,IAAA,IAAI,EAAE,iBAAiB,CAACA,GAAA,CAAC,IAAI,EAAA,EAAC,SAAS,EAAC,2BAA2B,EAAA,CAAG,EAAE,8BAA8B,CAAC;AACvG,IAAA,OAAO,EAAE;AACP,QAAA,GAAG,iBAAiB,CAClBA,GAAA,CAAC,OAAO,EAAA,EAAC,SAAS,EAAC,sBAAsB,EAAA,CAAG,EAC5C,SAAS,EACT,EAAE,KAAK,EAAE,SAAS,EAAE,CACrB;AACD,QAAA,QAAQ,EAAE,QAAQ;AACnB,KAAA;;SAGa,uBAAuB,CACrC,UAAkB,EAClB,IAAqB,EACrB,OAAsB,EAAA;IAEtB,OAAO,iBAAiB,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC;AACrD;SAEgB,aAAa,GAAA;IAC3B,QACEC,4BACED,GAAA,CAAA,OAAA,EAAA,EAAA,QAAA,EAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BP,EAAA,CAAS,EACVA,GAAA,CAAC,OAAO,EAAA,EACN,QAAQ,EAAC,cAAc,EACvB,WAAW,EAAA,IAAA,EACX,YAAY,EAAE;AACZ,oBAAA,SAAS,EAAE,4CAA4C;AACvD,oBAAA,KAAK,EAAE;AACL,wBAAA,UAAU,EAAE,kBAAkB;AAC9B,wBAAA,OAAO,EAAE,cAAc;AACxB,qBAAA;iBACF,EAAA,CACD,CAAA,EAAA,CACD;AAEP;;;;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { CheckIcon, MailWarningIcon } from 'lucide-react';
|
|
3
|
+
import { Badge } from './badge.js';
|
|
4
|
+
import { cn } from '../utils.js';
|
|
5
|
+
|
|
6
|
+
const Timeline = ({ children, className }) => {
|
|
7
|
+
return jsx("div", { className: cn('w-full', className), children: children });
|
|
8
|
+
};
|
|
9
|
+
const TimelineItem = ({ number, title, subtitle, isLast = false, children, fromMe, isMe, className, }) => {
|
|
10
|
+
const isCheckmark = number === -1;
|
|
11
|
+
const isExclamation = fromMe;
|
|
12
|
+
return (jsxs("div", { className: cn('relative flex items-start gap-3', !isLast && 'pb-6', className), children: [jsxs("div", { className: "relative flex w-6 shrink-0 self-stretch justify-center", children: [isCheckmark ? (jsx("div", { className: "relative z-10 flex size-6 shrink-0 items-center justify-center rounded-full bg-supportive text-supportive-foreground", children: jsx(CheckIcon, { className: "size-3.5", "aria-hidden": "true" }) })) : isExclamation ? (jsx("div", { className: "relative z-10 flex size-6 shrink-0 items-center justify-center rounded-full bg-primary text-xs font-semibold text-primary-foreground", children: jsx(MailWarningIcon, { className: "size-3.5", "aria-hidden": "true" }) })) : (jsx("div", { className: "relative z-10 flex size-6 shrink-0 items-center justify-center rounded-full border border-input bg-muted text-xs font-semibold text-muted-foreground", children: number })), !isLast && jsx("div", { "aria-hidden": "true", className: "absolute -bottom-5 top-7 w-px bg-border" })] }), jsxs("div", { className: "flex min-w-0 flex-1 flex-wrap items-start justify-between gap-x-3 gap-y-2", children: [jsxs("div", { className: "min-w-0 flex-1", children: [jsxs("div", { className: "flex min-h-6 flex-wrap items-center gap-2", children: [fromMe ? (jsx("div", { className: "text-sm font-semibold text-primary", children: title })) : (jsx("div", { className: "text-sm font-medium text-foreground", children: title })), isMe && (jsx(Badge, { variant: "solid", type: "secondary", children: "You" }))] }), subtitle && (jsx("div", { className: "mt-1 text-sm leading-relaxed text-muted-foreground", children: subtitle }))] }), children && jsx("div", { className: "flex min-h-6 shrink-0 items-center", children: children })] })] }));
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export { Timeline, TimelineItem };
|
|
16
|
+
//# sourceMappingURL=timeline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeline.js","sources":["../../src/components/timeline.tsx"],"sourcesContent":["import React from \"react\";\nimport { CheckIcon, MailWarningIcon } from \"lucide-react\";\nimport { Badge } from './badge';\nimport { cn } from '@/utils';\n\nexport const Timeline = ({ children, className }: { children: React.ReactNode; className?: string }) => {\n return <div className={cn('w-full', className)}>{children}</div>;\n};\n\ninterface TimelineItemProps {\n number: number;\n title: string | React.ReactNode;\n subtitle?: React.ReactNode;\n isLast?: boolean;\n children?: React.ReactNode;\n fromMe?: boolean;\n isMe?: boolean;\n className?: string;\n}\n\nexport const TimelineItem = ({\n number,\n title,\n subtitle,\n isLast = false,\n children,\n fromMe,\n isMe,\n className,\n}: TimelineItemProps) => {\n const isCheckmark = number === -1;\n const isExclamation = fromMe;\n\n return (\n <div className={cn('relative flex items-start gap-3', !isLast && 'pb-6', className)}>\n <div className=\"relative flex w-6 shrink-0 self-stretch justify-center\">\n {isCheckmark ? (\n <div className=\"relative z-10 flex size-6 shrink-0 items-center justify-center rounded-full bg-supportive text-supportive-foreground\">\n <CheckIcon className=\"size-3.5\" aria-hidden=\"true\" />\n </div>\n ) : isExclamation ? (\n <div className=\"relative z-10 flex size-6 shrink-0 items-center justify-center rounded-full bg-primary text-xs font-semibold text-primary-foreground\">\n <MailWarningIcon className=\"size-3.5\" aria-hidden=\"true\" />\n </div>\n ) : (\n <div className=\"relative z-10 flex size-6 shrink-0 items-center justify-center rounded-full border border-input bg-muted text-xs font-semibold text-muted-foreground\">\n {number}\n </div>\n )}\n {!isLast && <div aria-hidden=\"true\" className=\"absolute -bottom-5 top-7 w-px bg-border\" />}\n </div>\n\n {/* Content */}\n <div className=\"flex min-w-0 flex-1 flex-wrap items-start justify-between gap-x-3 gap-y-2\">\n <div className=\"min-w-0 flex-1\">\n <div className=\"flex min-h-6 flex-wrap items-center gap-2\">\n {fromMe ? (\n <div className=\"text-sm font-semibold text-primary\">{title}</div>\n ) : (\n <div className=\"text-sm font-medium text-foreground\">{title}</div>\n )}\n {isMe && (\n <Badge variant=\"solid\" type=\"secondary\">\n You\n </Badge>\n )}\n </div>\n {subtitle && (\n <div className=\"mt-1 text-sm leading-relaxed text-muted-foreground\">{subtitle}</div>\n )}\n </div>\n {children && <div className=\"flex min-h-6 shrink-0 items-center\">{children}</div>}\n </div>\n </div>\n );\n};\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;AAKO,MAAM,QAAQ,GAAG,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAqD,KAAI;AACrG,IAAA,OAAOA,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAO;AAClE;AAaO,MAAM,YAAY,GAAG,CAAC,EAC3B,MAAM,EACN,KAAK,EACL,QAAQ,EACR,MAAM,GAAG,KAAK,EACd,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,SAAS,GACS,KAAI;AACtB,IAAA,MAAM,WAAW,GAAG,MAAM,KAAK,EAAE;IACjC,MAAM,aAAa,GAAG,MAAM;AAE5B,IAAA,QACEC,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,EAAE,CAAC,iCAAiC,EAAE,CAAC,MAAM,IAAI,MAAM,EAAE,SAAS,CAAC,EAAA,QAAA,EAAA,CACjFA,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,wDAAwD,EAAA,QAAA,EAAA,CACpE,WAAW,IACVD,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,sHAAsH,EAAA,QAAA,EACnIA,GAAA,CAAC,SAAS,IAAC,SAAS,EAAC,UAAU,EAAA,aAAA,EAAa,MAAM,GAAG,EAAA,CACjD,IACJ,aAAa,IACfA,aAAK,SAAS,EAAC,sIAAsI,EAAA,QAAA,EACnJA,IAAC,eAAe,EAAA,EAAC,SAAS,EAAC,UAAU,iBAAa,MAAM,EAAA,CAAG,EAAA,CACvD,KAENA,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,sJAAsJ,EAAA,QAAA,EAClK,MAAM,EAAA,CACH,CACP,EACA,CAAC,MAAM,IAAIA,GAAA,CAAA,KAAA,EAAA,EAAA,aAAA,EAAiB,MAAM,EAAC,SAAS,EAAC,yCAAyC,EAAA,CAAG,IACtF,EAGNC,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,2EAA2E,aACxFA,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,gBAAgB,aAC7BA,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,2CAA2C,EAAA,QAAA,EAAA,CACvD,MAAM,IACLD,aAAK,SAAS,EAAC,oCAAoC,EAAA,QAAA,EAAE,KAAK,GAAO,KAEjEA,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,qCAAqC,EAAA,QAAA,EAAE,KAAK,EAAA,CAAO,CACnE,EACA,IAAI,KACHA,GAAA,CAAC,KAAK,EAAA,EAAC,OAAO,EAAC,OAAO,EAAC,IAAI,EAAC,WAAW,EAAA,QAAA,EAAA,KAAA,EAAA,CAE/B,CACT,IACG,EACL,QAAQ,KACPA,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,oDAAoD,EAAA,QAAA,EAAE,QAAQ,GAAO,CACrF,CAAA,EAAA,CACG,EACL,QAAQ,IAAIA,aAAK,SAAS,EAAC,oCAAoC,EAAA,QAAA,EAAE,QAAQ,GAAO,CAAA,EAAA,CAC7E,CAAA,EAAA,CACF;AAEV;;;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { cn } from '../utils.js';
|
|
4
|
+
|
|
5
|
+
const Toggle = ({ state, onClick, loading, }) => {
|
|
6
|
+
return (jsx("button", { type: "button", disabled: loading, onClick: (e) => {
|
|
7
|
+
e.stopPropagation();
|
|
8
|
+
if (loading)
|
|
9
|
+
return;
|
|
10
|
+
onClick();
|
|
11
|
+
}, className: cn("relative z-30 flex h-5 w-9 items-center rounded-full transition-colors focus:ring-transparent", state ? "bg-primary" : "bg-input", loading ? "cursor-wait opacity-60" : "cursor-pointer"), children: jsx("span", { className: cn("inline-block h-3 w-3 transform rounded-full bg-background transition-transform", state ? "translate-x-5" : "translate-x-1") }) }));
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { Toggle };
|
|
15
|
+
//# sourceMappingURL=toggle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toggle.js","sources":["../../src/components/toggle.tsx"],"sourcesContent":["'use client';\n\nimport { cn } from \"@/utils\";\n\nexport const Toggle = ({\n state,\n onClick,\n loading,\n}: {\n state: boolean | null | undefined;\n onClick: () => void;\n loading?: boolean;\n}) => {\n return (\n <button\n type=\"button\"\n disabled={loading}\n onClick={(e) => {\n e.stopPropagation();\n if (loading) return;\n onClick();\n }}\n className={cn(\n \"relative z-30 flex h-5 w-9 items-center rounded-full transition-colors focus:ring-transparent\",\n state ? \"bg-primary\" : \"bg-input\",\n loading ? \"cursor-wait opacity-60\" : \"cursor-pointer\",\n )}\n >\n <span\n className={cn(\n \"inline-block h-3 w-3 transform rounded-full bg-background transition-transform\",\n state ? \"translate-x-5\" : \"translate-x-1\",\n )}\n />\n </button>\n );\n};\n"],"names":[],"mappings":";;;;AAIO;AASL;;AAMM;;AACA;;AAgBR;;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useRef, useEffect } from 'react';
|
|
3
|
+
|
|
4
|
+
/** Dismiss floating controls on outside pointer interaction or Escape. */
|
|
5
|
+
function useDetectClickOutside({ onTriggered }) {
|
|
6
|
+
const ref = useRef(null);
|
|
7
|
+
const callback = useRef(onTriggered);
|
|
8
|
+
useEffect(() => { callback.current = onTriggered; }, [onTriggered]);
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
const outside = (event) => {
|
|
11
|
+
if (ref.current && !event.composedPath().includes(ref.current))
|
|
12
|
+
callback.current();
|
|
13
|
+
};
|
|
14
|
+
const escape = (event) => {
|
|
15
|
+
if (event.key === 'Escape')
|
|
16
|
+
callback.current();
|
|
17
|
+
};
|
|
18
|
+
document.addEventListener('pointerdown', outside);
|
|
19
|
+
document.addEventListener('keydown', escape);
|
|
20
|
+
return () => {
|
|
21
|
+
document.removeEventListener('pointerdown', outside);
|
|
22
|
+
document.removeEventListener('keydown', escape);
|
|
23
|
+
};
|
|
24
|
+
}, []);
|
|
25
|
+
return ref;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { useDetectClickOutside };
|
|
29
|
+
//# sourceMappingURL=use-detect-click-outside.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-detect-click-outside.js","sources":["../../src/hooks/use-detect-click-outside.ts"],"sourcesContent":["'use client';\n\nimport { useEffect, useRef } from 'react';\n\n/** Dismiss floating controls on outside pointer interaction or Escape. */\nexport function useDetectClickOutside({ onTriggered }: { onTriggered: () => void }) {\n const ref = useRef<HTMLDivElement | null>(null);\n const callback = useRef(onTriggered);\n useEffect(() => { callback.current = onTriggered; }, [onTriggered]);\n useEffect(() => {\n const outside = (event: PointerEvent) => {\n if (ref.current && !event.composedPath().includes(ref.current)) callback.current();\n };\n const escape = (event: KeyboardEvent) => {\n if (event.key === 'Escape') callback.current();\n };\n document.addEventListener('pointerdown', outside);\n document.addEventListener('keydown', escape);\n return () => {\n document.removeEventListener('pointerdown', outside);\n document.removeEventListener('keydown', escape);\n };\n }, []);\n return ref;\n}\n"],"names":[],"mappings":";;;AAIA;AACM;AACJ;AACA;AACA;;AAEE;AACE;;AACF;AACA;AACE;;AACF;AACA;AACA;AACA;AACE;AACA;AACF;;AAEF;AACF;;"}
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useState, useEffect, useMemo } from 'react';
|
|
3
|
+
|
|
4
|
+
function countActiveFilters(value) {
|
|
5
|
+
return Object.values(value).reduce((total, values) => total + values.length, 0);
|
|
6
|
+
}
|
|
7
|
+
function sameStringSet(left, right) {
|
|
8
|
+
if (left.length !== right.length)
|
|
9
|
+
return false;
|
|
10
|
+
const rightSet = new Set(right);
|
|
11
|
+
return left.every((value) => rightSet.has(value));
|
|
12
|
+
}
|
|
13
|
+
function getColumnSorts(columns) {
|
|
14
|
+
return columns.flatMap((column) => {
|
|
15
|
+
if (column.sortable === false || !column.getSortValue)
|
|
16
|
+
return [];
|
|
17
|
+
return [
|
|
18
|
+
{
|
|
19
|
+
id: column.id,
|
|
20
|
+
getValue: column.getSortValue,
|
|
21
|
+
defaultDirection: column.defaultSortDirection,
|
|
22
|
+
},
|
|
23
|
+
];
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
function useResourceTable({ data, getRowId, columns = [], search, filters, sort, pagination, selection, }) {
|
|
27
|
+
const sortColumns = sort?.columns ?? getColumnSorts(columns);
|
|
28
|
+
const [searchValue, setSearchValue] = useState(search?.initialValue ?? "");
|
|
29
|
+
const [filterOpen, setFilterOpen] = useState(false);
|
|
30
|
+
const [filterValue, setFilterValue] = useState(filters?.initialValue ?? {});
|
|
31
|
+
const [draftFilterValue, setDraftFilterValue] = useState(filters?.initialValue ?? {});
|
|
32
|
+
const initialSortColumn = sort?.initialColumn ?? sortColumns[0]?.id ?? null;
|
|
33
|
+
const [sortColumn, setSortColumn] = useState(initialSortColumn);
|
|
34
|
+
const [sortDirection, setSortDirection] = useState(sort?.initialDirection ??
|
|
35
|
+
sortColumns.find((column) => column.id === initialSortColumn)
|
|
36
|
+
?.defaultDirection ??
|
|
37
|
+
"asc");
|
|
38
|
+
const [page, setPageState] = useState(Math.max(pagination.initialPage ?? 1, 1));
|
|
39
|
+
const [pageSize, setPageSizeState] = useState(Math.max(Math.floor(pagination.pageSize), 1));
|
|
40
|
+
const pageSizeOptions = Array.from(new Set([...(pagination.pageSizeOptions ?? [10, 15, 20, 50]), pageSize]))
|
|
41
|
+
.filter((option) => option > 0)
|
|
42
|
+
.sort((left, right) => left - right);
|
|
43
|
+
const [selectedIds, setSelectedIds] = useState(new Set());
|
|
44
|
+
// Prune stale ids when the underlying data identity changes (a row was
|
|
45
|
+
// removed, or the caller swapped in an entirely different dataset — e.g.
|
|
46
|
+
// a tab switch that reuses the same hook instance).
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (!selection?.enabled)
|
|
49
|
+
return;
|
|
50
|
+
setSelectedIds((prev) => {
|
|
51
|
+
if (prev.size === 0)
|
|
52
|
+
return prev;
|
|
53
|
+
const validIds = new Set(data.map(getRowId));
|
|
54
|
+
const next = new Set([...prev].filter((id) => validIds.has(id)));
|
|
55
|
+
return next.size === prev.size ? prev : next;
|
|
56
|
+
});
|
|
57
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
58
|
+
}, [data]);
|
|
59
|
+
const normalizedQuery = searchValue.trim().toLowerCase();
|
|
60
|
+
const filteredRows = useMemo(() => {
|
|
61
|
+
return data.filter((row) => {
|
|
62
|
+
const matchesSearch = !normalizedQuery || !search || search.matches(row, normalizedQuery);
|
|
63
|
+
const matchesFilters = !filters || filters.matches(row, filterValue);
|
|
64
|
+
return matchesSearch && matchesFilters;
|
|
65
|
+
});
|
|
66
|
+
}, [data, filterValue, filters, normalizedQuery, search]);
|
|
67
|
+
const sortedRows = useMemo(() => {
|
|
68
|
+
const column = sortColumns.find((item) => item.id === sortColumn);
|
|
69
|
+
if (!column)
|
|
70
|
+
return filteredRows;
|
|
71
|
+
return [...filteredRows].sort((a, b) => {
|
|
72
|
+
const left = column.getValue(a);
|
|
73
|
+
const right = column.getValue(b);
|
|
74
|
+
const leftEmpty = left == null || left === "";
|
|
75
|
+
const rightEmpty = right == null || right === "";
|
|
76
|
+
if (leftEmpty && rightEmpty)
|
|
77
|
+
return 0;
|
|
78
|
+
if (leftEmpty)
|
|
79
|
+
return 1;
|
|
80
|
+
if (rightEmpty)
|
|
81
|
+
return -1;
|
|
82
|
+
let result;
|
|
83
|
+
if (left instanceof Date || right instanceof Date) {
|
|
84
|
+
result = new Date(left).getTime() - new Date(right).getTime();
|
|
85
|
+
}
|
|
86
|
+
else if (typeof left === "number" && typeof right === "number") {
|
|
87
|
+
result = left - right;
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
result = String(left).localeCompare(String(right));
|
|
91
|
+
}
|
|
92
|
+
return sortDirection === "asc" ? result : -result;
|
|
93
|
+
});
|
|
94
|
+
}, [filteredRows, sortColumns, sortColumn, sortDirection]);
|
|
95
|
+
const pageCount = Math.max(1, Math.ceil(sortedRows.length / pageSize));
|
|
96
|
+
const currentPage = Math.min(Math.max(page, 1), pageCount);
|
|
97
|
+
const pageStart = (currentPage - 1) * pageSize;
|
|
98
|
+
const pageEnd = Math.min(pageStart + pageSize, sortedRows.length);
|
|
99
|
+
const pagedRows = sortedRows.slice(pageStart, pageEnd);
|
|
100
|
+
const isRowSelectable = (row) => !selection?.isSelectable || selection.isSelectable(row);
|
|
101
|
+
const selectablePageRows = pagedRows.filter(isRowSelectable);
|
|
102
|
+
const selectableMatchingRows = sortedRows.filter(isRowSelectable);
|
|
103
|
+
const isAllPageSelected = selectablePageRows.length > 0 &&
|
|
104
|
+
selectablePageRows.every((row) => selectedIds.has(getRowId(row)));
|
|
105
|
+
const isAllMatchingSelected = selectableMatchingRows.length > 0 &&
|
|
106
|
+
selectableMatchingRows.every((row) => selectedIds.has(getRowId(row)));
|
|
107
|
+
const toggleSelected = (row) => {
|
|
108
|
+
if (!isRowSelectable(row))
|
|
109
|
+
return;
|
|
110
|
+
const id = getRowId(row);
|
|
111
|
+
setSelectedIds((prev) => {
|
|
112
|
+
const next = new Set(prev);
|
|
113
|
+
if (next.has(id))
|
|
114
|
+
next.delete(id);
|
|
115
|
+
else
|
|
116
|
+
next.add(id);
|
|
117
|
+
return next;
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
const selectPage = () => {
|
|
121
|
+
setSelectedIds((prev) => {
|
|
122
|
+
const next = new Set(prev);
|
|
123
|
+
for (const row of selectablePageRows)
|
|
124
|
+
next.add(getRowId(row));
|
|
125
|
+
return next;
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
const deselectPage = () => {
|
|
129
|
+
setSelectedIds((prev) => {
|
|
130
|
+
const next = new Set(prev);
|
|
131
|
+
for (const row of pagedRows)
|
|
132
|
+
next.delete(getRowId(row));
|
|
133
|
+
return next;
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
const selectAllMatching = () => {
|
|
137
|
+
setSelectedIds(new Set(selectableMatchingRows.map(getRowId)));
|
|
138
|
+
};
|
|
139
|
+
const clearSelection = () => setSelectedIds(new Set());
|
|
140
|
+
const setPage = (nextPage) => {
|
|
141
|
+
const clamped = Math.min(Math.max(nextPage, 1), pageCount);
|
|
142
|
+
setPageState(clamped);
|
|
143
|
+
pagination.onPageChange?.(clamped);
|
|
144
|
+
};
|
|
145
|
+
const setPageSize = (nextPageSize) => {
|
|
146
|
+
const normalizedPageSize = Math.max(Math.floor(nextPageSize), 1);
|
|
147
|
+
setPageSizeState(normalizedPageSize);
|
|
148
|
+
setPageState(1);
|
|
149
|
+
pagination.onPageChange?.(1);
|
|
150
|
+
};
|
|
151
|
+
const setSearch = (value) => {
|
|
152
|
+
setSearchValue(value);
|
|
153
|
+
setPageState(1);
|
|
154
|
+
search?.onChange?.(value);
|
|
155
|
+
};
|
|
156
|
+
const setOpen = (open) => {
|
|
157
|
+
setFilterOpen(open);
|
|
158
|
+
if (open)
|
|
159
|
+
setDraftFilterValue(filterValue);
|
|
160
|
+
};
|
|
161
|
+
const applyFilters = () => {
|
|
162
|
+
setFilterValue(draftFilterValue);
|
|
163
|
+
setPageState(1);
|
|
164
|
+
setFilterOpen(false);
|
|
165
|
+
filters?.onApply?.(draftFilterValue);
|
|
166
|
+
};
|
|
167
|
+
const cancelFilters = () => {
|
|
168
|
+
setDraftFilterValue(filterValue);
|
|
169
|
+
setFilterOpen(false);
|
|
170
|
+
};
|
|
171
|
+
const clearDraftFilters = () => {
|
|
172
|
+
setDraftFilterValue({});
|
|
173
|
+
};
|
|
174
|
+
const clearFilters = () => {
|
|
175
|
+
setFilterValue({});
|
|
176
|
+
setDraftFilterValue({});
|
|
177
|
+
setPageState(1);
|
|
178
|
+
filters?.onApply?.({});
|
|
179
|
+
};
|
|
180
|
+
const toggleDraftOption = (groupId, optionValue, checked) => {
|
|
181
|
+
setDraftFilterValue((current) => {
|
|
182
|
+
const values = current[groupId] ?? [];
|
|
183
|
+
const nextValues = checked
|
|
184
|
+
? [...values, optionValue].filter((value, index, array) => array.indexOf(value) === index)
|
|
185
|
+
: values.filter((value) => value !== optionValue);
|
|
186
|
+
return { ...current, [groupId]: nextValues };
|
|
187
|
+
});
|
|
188
|
+
};
|
|
189
|
+
const toggleDraftGroup = (groupId) => {
|
|
190
|
+
const group = filters?.groups.find((item) => item.id === groupId);
|
|
191
|
+
if (!group)
|
|
192
|
+
return;
|
|
193
|
+
const allValues = group.options.map((option) => option.value);
|
|
194
|
+
setDraftFilterValue((current) => {
|
|
195
|
+
const currentValues = current[groupId] ?? [];
|
|
196
|
+
return {
|
|
197
|
+
...current,
|
|
198
|
+
[groupId]: sameStringSet(currentValues, allValues) ? [] : allValues,
|
|
199
|
+
};
|
|
200
|
+
});
|
|
201
|
+
};
|
|
202
|
+
const setSort = (columnId, defaultDirection) => {
|
|
203
|
+
if (sortColumn === columnId) {
|
|
204
|
+
setSortDirection((current) => (current === "asc" ? "desc" : "asc"));
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
setSortColumn(columnId);
|
|
208
|
+
setSortDirection(defaultDirection ?? "asc");
|
|
209
|
+
};
|
|
210
|
+
return {
|
|
211
|
+
columns,
|
|
212
|
+
dataCount: data.length,
|
|
213
|
+
rows: sortedRows,
|
|
214
|
+
pagedRows,
|
|
215
|
+
totalCount: sortedRows.length,
|
|
216
|
+
pageCount,
|
|
217
|
+
page: currentPage,
|
|
218
|
+
pageStart,
|
|
219
|
+
pageEnd,
|
|
220
|
+
getRowId,
|
|
221
|
+
search: search
|
|
222
|
+
? {
|
|
223
|
+
value: searchValue,
|
|
224
|
+
placeholder: search.placeholder,
|
|
225
|
+
ariaLabel: search.ariaLabel,
|
|
226
|
+
setValue: setSearch,
|
|
227
|
+
}
|
|
228
|
+
: undefined,
|
|
229
|
+
filters: filters
|
|
230
|
+
? {
|
|
231
|
+
groups: filters.groups,
|
|
232
|
+
open: filterOpen,
|
|
233
|
+
setOpen,
|
|
234
|
+
value: filterValue,
|
|
235
|
+
draftValue: draftFilterValue,
|
|
236
|
+
setDraftValue: setDraftFilterValue,
|
|
237
|
+
activeCount: countActiveFilters(filterValue),
|
|
238
|
+
draftActiveCount: countActiveFilters(draftFilterValue),
|
|
239
|
+
apply: applyFilters,
|
|
240
|
+
cancel: cancelFilters,
|
|
241
|
+
clear: clearFilters,
|
|
242
|
+
clearDraft: clearDraftFilters,
|
|
243
|
+
toggleDraftOption,
|
|
244
|
+
toggleDraftGroup,
|
|
245
|
+
}
|
|
246
|
+
: undefined,
|
|
247
|
+
sort: sortColumns.length
|
|
248
|
+
? {
|
|
249
|
+
column: sortColumn,
|
|
250
|
+
direction: sortDirection,
|
|
251
|
+
columns: sortColumns,
|
|
252
|
+
setSort,
|
|
253
|
+
}
|
|
254
|
+
: undefined,
|
|
255
|
+
pagination: {
|
|
256
|
+
page: currentPage,
|
|
257
|
+
pageSize,
|
|
258
|
+
pageSizeOptions,
|
|
259
|
+
setPage,
|
|
260
|
+
setPageSize,
|
|
261
|
+
},
|
|
262
|
+
selection: selection?.enabled
|
|
263
|
+
? {
|
|
264
|
+
selectedIds,
|
|
265
|
+
selectedRows: data.filter((row) => selectedIds.has(getRowId(row))),
|
|
266
|
+
isSelected: (row) => selectedIds.has(getRowId(row)),
|
|
267
|
+
isRowSelectable,
|
|
268
|
+
toggle: toggleSelected,
|
|
269
|
+
selectPage,
|
|
270
|
+
deselectPage,
|
|
271
|
+
selectAllMatching,
|
|
272
|
+
clear: clearSelection,
|
|
273
|
+
selectedCount: selectedIds.size,
|
|
274
|
+
selectablePageCount: selectablePageRows.length,
|
|
275
|
+
selectableMatchingCount: selectableMatchingRows.length,
|
|
276
|
+
isAllPageSelected,
|
|
277
|
+
isAllMatchingSelected,
|
|
278
|
+
}
|
|
279
|
+
: undefined,
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
export { useResourceTable };
|
|
284
|
+
//# sourceMappingURL=use-resource-table.js.map
|