mirror of
https://github.com/woodchen-ink/certimate.git
synced 2025-07-18 17:31:55 +08:00
chore(ui): clean code
This commit is contained in:
parent
c5498b92a2
commit
3b50741f19
136
ui/package-lock.json
generated
136
ui/package-lock.json
generated
@ -11,14 +11,11 @@
|
|||||||
"@ant-design/pro-components": "^2.8.2",
|
"@ant-design/pro-components": "^2.8.2",
|
||||||
"@hookform/resolvers": "^3.9.0",
|
"@hookform/resolvers": "^3.9.0",
|
||||||
"@radix-ui/react-accordion": "^1.2.0",
|
"@radix-ui/react-accordion": "^1.2.0",
|
||||||
"@radix-ui/react-alert-dialog": "^1.1.1",
|
|
||||||
"@radix-ui/react-collapsible": "^1.1.1",
|
"@radix-ui/react-collapsible": "^1.1.1",
|
||||||
"@radix-ui/react-dialog": "^1.1.2",
|
"@radix-ui/react-dialog": "^1.1.2",
|
||||||
"@radix-ui/react-dropdown-menu": "^2.1.1",
|
"@radix-ui/react-dropdown-menu": "^2.1.1",
|
||||||
"@radix-ui/react-label": "^2.1.0",
|
"@radix-ui/react-label": "^2.1.0",
|
||||||
"@radix-ui/react-navigation-menu": "^1.2.0",
|
|
||||||
"@radix-ui/react-popover": "^1.1.2",
|
"@radix-ui/react-popover": "^1.1.2",
|
||||||
"@radix-ui/react-progress": "^1.1.0",
|
|
||||||
"@radix-ui/react-radio-group": "^1.2.0",
|
"@radix-ui/react-radio-group": "^1.2.0",
|
||||||
"@radix-ui/react-scroll-area": "^1.1.0",
|
"@radix-ui/react-scroll-area": "^1.1.0",
|
||||||
"@radix-ui/react-select": "^2.1.1",
|
"@radix-ui/react-select": "^2.1.1",
|
||||||
@ -52,7 +49,6 @@
|
|||||||
"react-router-dom": "^6.25.1",
|
"react-router-dom": "^6.25.1",
|
||||||
"tailwind-merge": "^2.4.0",
|
"tailwind-merge": "^2.4.0",
|
||||||
"tailwindcss-animate": "^1.0.7",
|
"tailwindcss-animate": "^1.0.7",
|
||||||
"vaul": "^0.9.1",
|
|
||||||
"zod": "^3.23.8",
|
"zod": "^3.23.8",
|
||||||
"zustand": "^5.0.1"
|
"zustand": "^5.0.1"
|
||||||
},
|
},
|
||||||
@ -1688,68 +1684,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@radix-ui/react-alert-dialog": {
|
|
||||||
"version": "1.1.1",
|
|
||||||
"resolved": "https://registry.npmmirror.com/@radix-ui/react-alert-dialog/-/react-alert-dialog-1.1.1.tgz",
|
|
||||||
"integrity": "sha512-wmCoJwj7byuVuiLKqDLlX7ClSUU0vd9sdCeM+2Ls+uf13+cpSJoMgwysHq1SGVVkJj5Xn0XWi1NoRCdkMpr6Mw==",
|
|
||||||
"dependencies": {
|
|
||||||
"@radix-ui/primitive": "1.1.0",
|
|
||||||
"@radix-ui/react-compose-refs": "1.1.0",
|
|
||||||
"@radix-ui/react-context": "1.1.0",
|
|
||||||
"@radix-ui/react-dialog": "1.1.1",
|
|
||||||
"@radix-ui/react-primitive": "2.0.0",
|
|
||||||
"@radix-ui/react-slot": "1.1.0"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"@types/react": "*",
|
|
||||||
"@types/react-dom": "*",
|
|
||||||
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
|
|
||||||
"react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
|
|
||||||
},
|
|
||||||
"peerDependenciesMeta": {
|
|
||||||
"@types/react": {
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"@types/react-dom": {
|
|
||||||
"optional": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@radix-ui/react-alert-dialog/node_modules/@radix-ui/react-dialog": {
|
|
||||||
"version": "1.1.1",
|
|
||||||
"resolved": "https://registry.npmmirror.com/@radix-ui/react-dialog/-/react-dialog-1.1.1.tgz",
|
|
||||||
"integrity": "sha512-zysS+iU4YP3STKNS6USvFVqI4qqx8EpiwmT5TuCApVEBca+eRCbONi4EgzfNSuVnOXvC5UPHHMjs8RXO6DH9Bg==",
|
|
||||||
"dependencies": {
|
|
||||||
"@radix-ui/primitive": "1.1.0",
|
|
||||||
"@radix-ui/react-compose-refs": "1.1.0",
|
|
||||||
"@radix-ui/react-context": "1.1.0",
|
|
||||||
"@radix-ui/react-dismissable-layer": "1.1.0",
|
|
||||||
"@radix-ui/react-focus-guards": "1.1.0",
|
|
||||||
"@radix-ui/react-focus-scope": "1.1.0",
|
|
||||||
"@radix-ui/react-id": "1.1.0",
|
|
||||||
"@radix-ui/react-portal": "1.1.1",
|
|
||||||
"@radix-ui/react-presence": "1.1.0",
|
|
||||||
"@radix-ui/react-primitive": "2.0.0",
|
|
||||||
"@radix-ui/react-slot": "1.1.0",
|
|
||||||
"@radix-ui/react-use-controllable-state": "1.1.0",
|
|
||||||
"aria-hidden": "^1.1.1",
|
|
||||||
"react-remove-scroll": "2.5.7"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"@types/react": "*",
|
|
||||||
"@types/react-dom": "*",
|
|
||||||
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
|
|
||||||
"react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
|
|
||||||
},
|
|
||||||
"peerDependenciesMeta": {
|
|
||||||
"@types/react": {
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"@types/react-dom": {
|
|
||||||
"optional": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@radix-ui/react-arrow": {
|
"node_modules/@radix-ui/react-arrow": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmmirror.com/@radix-ui/react-arrow/-/react-arrow-1.1.0.tgz",
|
"resolved": "https://registry.npmmirror.com/@radix-ui/react-arrow/-/react-arrow-1.1.0.tgz",
|
||||||
@ -2234,41 +2168,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@radix-ui/react-navigation-menu": {
|
|
||||||
"version": "1.2.0",
|
|
||||||
"resolved": "https://registry.npmmirror.com/@radix-ui/react-navigation-menu/-/react-navigation-menu-1.2.0.tgz",
|
|
||||||
"integrity": "sha512-OQ8tcwAOR0DhPlSY3e4VMXeHiol7la4PPdJWhhwJiJA+NLX0SaCaonOkRnI3gCDHoZ7Fo7bb/G6q25fRM2Y+3Q==",
|
|
||||||
"dependencies": {
|
|
||||||
"@radix-ui/primitive": "1.1.0",
|
|
||||||
"@radix-ui/react-collection": "1.1.0",
|
|
||||||
"@radix-ui/react-compose-refs": "1.1.0",
|
|
||||||
"@radix-ui/react-context": "1.1.0",
|
|
||||||
"@radix-ui/react-direction": "1.1.0",
|
|
||||||
"@radix-ui/react-dismissable-layer": "1.1.0",
|
|
||||||
"@radix-ui/react-id": "1.1.0",
|
|
||||||
"@radix-ui/react-presence": "1.1.0",
|
|
||||||
"@radix-ui/react-primitive": "2.0.0",
|
|
||||||
"@radix-ui/react-use-callback-ref": "1.1.0",
|
|
||||||
"@radix-ui/react-use-controllable-state": "1.1.0",
|
|
||||||
"@radix-ui/react-use-layout-effect": "1.1.0",
|
|
||||||
"@radix-ui/react-use-previous": "1.1.0",
|
|
||||||
"@radix-ui/react-visually-hidden": "1.1.0"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"@types/react": "*",
|
|
||||||
"@types/react-dom": "*",
|
|
||||||
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
|
|
||||||
"react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
|
|
||||||
},
|
|
||||||
"peerDependenciesMeta": {
|
|
||||||
"@types/react": {
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"@types/react-dom": {
|
|
||||||
"optional": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@radix-ui/react-popover": {
|
"node_modules/@radix-ui/react-popover": {
|
||||||
"version": "1.1.2",
|
"version": "1.1.2",
|
||||||
"resolved": "https://registry.npmmirror.com/@radix-ui/react-popover/-/react-popover-1.1.2.tgz",
|
"resolved": "https://registry.npmmirror.com/@radix-ui/react-popover/-/react-popover-1.1.2.tgz",
|
||||||
@ -2528,29 +2427,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@radix-ui/react-progress": {
|
|
||||||
"version": "1.1.0",
|
|
||||||
"resolved": "https://registry.npmmirror.com/@radix-ui/react-progress/-/react-progress-1.1.0.tgz",
|
|
||||||
"integrity": "sha512-aSzvnYpP725CROcxAOEBVZZSIQVQdHgBr2QQFKySsaD14u8dNT0batuXI+AAGDdAHfXH8rbnHmjYFqVJ21KkRg==",
|
|
||||||
"dependencies": {
|
|
||||||
"@radix-ui/react-context": "1.1.0",
|
|
||||||
"@radix-ui/react-primitive": "2.0.0"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"@types/react": "*",
|
|
||||||
"@types/react-dom": "*",
|
|
||||||
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
|
|
||||||
"react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
|
|
||||||
},
|
|
||||||
"peerDependenciesMeta": {
|
|
||||||
"@types/react": {
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"@types/react-dom": {
|
|
||||||
"optional": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@radix-ui/react-radio-group": {
|
"node_modules/@radix-ui/react-radio-group": {
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
"resolved": "https://registry.npmmirror.com/@radix-ui/react-radio-group/-/react-radio-group-1.2.0.tgz",
|
"resolved": "https://registry.npmmirror.com/@radix-ui/react-radio-group/-/react-radio-group-1.2.0.tgz",
|
||||||
@ -7866,18 +7742,6 @@
|
|||||||
"resolved": "https://registry.npmmirror.com/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
"resolved": "https://registry.npmmirror.com/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
||||||
"integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw=="
|
"integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw=="
|
||||||
},
|
},
|
||||||
"node_modules/vaul": {
|
|
||||||
"version": "0.9.1",
|
|
||||||
"resolved": "https://registry.npmmirror.com/vaul/-/vaul-0.9.1.tgz",
|
|
||||||
"integrity": "sha512-fAhd7i4RNMinx+WEm6pF3nOl78DFkAazcN04ElLPFF9BMCNGbY/kou8UMhIcicm0rJCNePJP0Yyza60gGOD0Jw==",
|
|
||||||
"dependencies": {
|
|
||||||
"@radix-ui/react-dialog": "^1.0.4"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"react": "^16.8 || ^17.0 || ^18.0",
|
|
||||||
"react-dom": "^16.8 || ^17.0 || ^18.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/vite": {
|
"node_modules/vite": {
|
||||||
"version": "5.4.8",
|
"version": "5.4.8",
|
||||||
"resolved": "https://registry.npmjs.org/vite/-/vite-5.4.8.tgz",
|
"resolved": "https://registry.npmjs.org/vite/-/vite-5.4.8.tgz",
|
||||||
|
@ -13,14 +13,11 @@
|
|||||||
"@ant-design/pro-components": "^2.8.2",
|
"@ant-design/pro-components": "^2.8.2",
|
||||||
"@hookform/resolvers": "^3.9.0",
|
"@hookform/resolvers": "^3.9.0",
|
||||||
"@radix-ui/react-accordion": "^1.2.0",
|
"@radix-ui/react-accordion": "^1.2.0",
|
||||||
"@radix-ui/react-alert-dialog": "^1.1.1",
|
|
||||||
"@radix-ui/react-collapsible": "^1.1.1",
|
"@radix-ui/react-collapsible": "^1.1.1",
|
||||||
"@radix-ui/react-dialog": "^1.1.2",
|
"@radix-ui/react-dialog": "^1.1.2",
|
||||||
"@radix-ui/react-dropdown-menu": "^2.1.1",
|
"@radix-ui/react-dropdown-menu": "^2.1.1",
|
||||||
"@radix-ui/react-label": "^2.1.0",
|
"@radix-ui/react-label": "^2.1.0",
|
||||||
"@radix-ui/react-navigation-menu": "^1.2.0",
|
|
||||||
"@radix-ui/react-popover": "^1.1.2",
|
"@radix-ui/react-popover": "^1.1.2",
|
||||||
"@radix-ui/react-progress": "^1.1.0",
|
|
||||||
"@radix-ui/react-radio-group": "^1.2.0",
|
"@radix-ui/react-radio-group": "^1.2.0",
|
||||||
"@radix-ui/react-scroll-area": "^1.1.0",
|
"@radix-ui/react-scroll-area": "^1.1.0",
|
||||||
"@radix-ui/react-select": "^2.1.1",
|
"@radix-ui/react-select": "^2.1.1",
|
||||||
@ -54,7 +51,6 @@
|
|||||||
"react-router-dom": "^6.25.1",
|
"react-router-dom": "^6.25.1",
|
||||||
"tailwind-merge": "^2.4.0",
|
"tailwind-merge": "^2.4.0",
|
||||||
"tailwindcss-animate": "^1.0.7",
|
"tailwindcss-animate": "^1.0.7",
|
||||||
"vaul": "^0.9.1",
|
|
||||||
"zod": "^3.23.8",
|
"zod": "^3.23.8",
|
||||||
"zustand": "^5.0.1"
|
"zustand": "^5.0.1"
|
||||||
},
|
},
|
||||||
|
@ -1,92 +0,0 @@
|
|||||||
import { Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink } from "@/components/ui/pagination";
|
|
||||||
|
|
||||||
type PaginationProps = {
|
|
||||||
totalPages: number;
|
|
||||||
currentPage: number;
|
|
||||||
onPageChange: (page: number) => void;
|
|
||||||
};
|
|
||||||
|
|
||||||
type PageNumber = number | string;
|
|
||||||
|
|
||||||
const XPagination = ({ totalPages, currentPage, onPageChange }: PaginationProps) => {
|
|
||||||
const pageNeighbours = 1; // Number of page numbers to show on either side of the current page
|
|
||||||
|
|
||||||
const getPageNumbers = () => {
|
|
||||||
const totalNumbers = pageNeighbours * 2 + 3; // total pages to display (left + right neighbours + current + 2 for start and end)
|
|
||||||
const totalBlocks = totalNumbers + 2; // adding 2 for the start and end page numbers
|
|
||||||
|
|
||||||
if (totalPages > totalBlocks) {
|
|
||||||
let pages: PageNumber[] = [];
|
|
||||||
|
|
||||||
const leftBound = Math.max(2, currentPage - pageNeighbours);
|
|
||||||
const rightBound = Math.min(totalPages - 1, currentPage + pageNeighbours);
|
|
||||||
|
|
||||||
const beforeLastPage = totalPages - 1;
|
|
||||||
|
|
||||||
pages = range(leftBound, rightBound);
|
|
||||||
|
|
||||||
if (currentPage > pageNeighbours + 2) {
|
|
||||||
pages.unshift("...");
|
|
||||||
}
|
|
||||||
if (currentPage < beforeLastPage - pageNeighbours) {
|
|
||||||
pages.push("...");
|
|
||||||
}
|
|
||||||
|
|
||||||
pages.unshift(1);
|
|
||||||
pages.push(totalPages);
|
|
||||||
|
|
||||||
return pages;
|
|
||||||
}
|
|
||||||
|
|
||||||
return range(1, totalPages);
|
|
||||||
};
|
|
||||||
|
|
||||||
const range = (from: number, to: number, step = 1) => {
|
|
||||||
let i = from;
|
|
||||||
const range = [];
|
|
||||||
|
|
||||||
while (i <= to) {
|
|
||||||
range.push(i);
|
|
||||||
i += step;
|
|
||||||
}
|
|
||||||
|
|
||||||
return range;
|
|
||||||
};
|
|
||||||
|
|
||||||
const pages = getPageNumbers();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<Pagination className="dark:text-stone-200 justify-end mt-3">
|
|
||||||
<PaginationContent>
|
|
||||||
{pages.map((page, index) => {
|
|
||||||
if (page === "...") {
|
|
||||||
return (
|
|
||||||
<PaginationItem key={index}>
|
|
||||||
<PaginationEllipsis />
|
|
||||||
</PaginationItem>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<PaginationItem key={index}>
|
|
||||||
<PaginationLink
|
|
||||||
href="#"
|
|
||||||
isActive={currentPage == page}
|
|
||||||
onClick={(e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
onPageChange(page as number);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{page}
|
|
||||||
</PaginationLink>
|
|
||||||
</PaginationItem>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</PaginationContent>
|
|
||||||
</Pagination>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default XPagination;
|
|
@ -1,94 +0,0 @@
|
|||||||
import * as React from "react";
|
|
||||||
import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog";
|
|
||||||
|
|
||||||
import { cn } from "./utils";
|
|
||||||
import { buttonVariants } from "@/components/ui/button";
|
|
||||||
|
|
||||||
const AlertDialog = AlertDialogPrimitive.Root;
|
|
||||||
|
|
||||||
const AlertDialogTrigger = AlertDialogPrimitive.Trigger;
|
|
||||||
|
|
||||||
const AlertDialogPortal = AlertDialogPrimitive.Portal;
|
|
||||||
|
|
||||||
const AlertDialogOverlay = React.forwardRef<
|
|
||||||
React.ElementRef<typeof AlertDialogPrimitive.Overlay>,
|
|
||||||
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Overlay>
|
|
||||||
>(({ className, ...props }, ref) => (
|
|
||||||
<AlertDialogPrimitive.Overlay
|
|
||||||
className={cn(
|
|
||||||
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
||||||
className
|
|
||||||
)}
|
|
||||||
{...props}
|
|
||||||
ref={ref}
|
|
||||||
/>
|
|
||||||
));
|
|
||||||
AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName;
|
|
||||||
|
|
||||||
const AlertDialogContent = React.forwardRef<
|
|
||||||
React.ElementRef<typeof AlertDialogPrimitive.Content>,
|
|
||||||
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Content>
|
|
||||||
>(({ className, ...props }, ref) => (
|
|
||||||
<AlertDialogPortal>
|
|
||||||
<AlertDialogOverlay />
|
|
||||||
<AlertDialogPrimitive.Content
|
|
||||||
ref={ref}
|
|
||||||
className={cn(
|
|
||||||
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
|
|
||||||
className
|
|
||||||
)}
|
|
||||||
{...props}
|
|
||||||
/>
|
|
||||||
</AlertDialogPortal>
|
|
||||||
));
|
|
||||||
AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName;
|
|
||||||
|
|
||||||
const AlertDialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
|
||||||
<div className={cn("flex flex-col space-y-2 text-center sm:text-left", className)} {...props} />
|
|
||||||
);
|
|
||||||
AlertDialogHeader.displayName = "AlertDialogHeader";
|
|
||||||
|
|
||||||
const AlertDialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
|
||||||
<div className={cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className)} {...props} />
|
|
||||||
);
|
|
||||||
AlertDialogFooter.displayName = "AlertDialogFooter";
|
|
||||||
|
|
||||||
const AlertDialogTitle = React.forwardRef<
|
|
||||||
React.ElementRef<typeof AlertDialogPrimitive.Title>,
|
|
||||||
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Title>
|
|
||||||
>(({ className, ...props }, ref) => <AlertDialogPrimitive.Title ref={ref} className={cn("text-lg font-semibold", className)} {...props} />);
|
|
||||||
AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName;
|
|
||||||
|
|
||||||
const AlertDialogDescription = React.forwardRef<
|
|
||||||
React.ElementRef<typeof AlertDialogPrimitive.Description>,
|
|
||||||
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Description>
|
|
||||||
>(({ className, ...props }, ref) => <AlertDialogPrimitive.Description ref={ref} className={cn("text-sm text-muted-foreground", className)} {...props} />);
|
|
||||||
AlertDialogDescription.displayName = AlertDialogPrimitive.Description.displayName;
|
|
||||||
|
|
||||||
const AlertDialogAction = React.forwardRef<
|
|
||||||
React.ElementRef<typeof AlertDialogPrimitive.Action>,
|
|
||||||
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Action>
|
|
||||||
>(({ className, ...props }, ref) => <AlertDialogPrimitive.Action ref={ref} className={cn(buttonVariants(), className)} {...props} />);
|
|
||||||
AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName;
|
|
||||||
|
|
||||||
const AlertDialogCancel = React.forwardRef<
|
|
||||||
React.ElementRef<typeof AlertDialogPrimitive.Cancel>,
|
|
||||||
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Cancel>
|
|
||||||
>(({ className, ...props }, ref) => (
|
|
||||||
<AlertDialogPrimitive.Cancel ref={ref} className={cn(buttonVariants({ variant: "outline" }), "mt-2 sm:mt-0", className)} {...props} />
|
|
||||||
));
|
|
||||||
AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName;
|
|
||||||
|
|
||||||
export {
|
|
||||||
AlertDialog,
|
|
||||||
AlertDialogPortal,
|
|
||||||
AlertDialogOverlay,
|
|
||||||
AlertDialogTrigger,
|
|
||||||
AlertDialogContent,
|
|
||||||
AlertDialogHeader,
|
|
||||||
AlertDialogFooter,
|
|
||||||
AlertDialogTitle,
|
|
||||||
AlertDialogDescription,
|
|
||||||
AlertDialogAction,
|
|
||||||
AlertDialogCancel,
|
|
||||||
};
|
|
@ -1,29 +0,0 @@
|
|||||||
import * as React from "react";
|
|
||||||
import { cva, type VariantProps } from "class-variance-authority";
|
|
||||||
|
|
||||||
import { cn } from "./utils";
|
|
||||||
|
|
||||||
const badgeVariants = cva(
|
|
||||||
"inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
||||||
{
|
|
||||||
variants: {
|
|
||||||
variant: {
|
|
||||||
default: "border-transparent bg-primary text-primary-foreground hover:bg-primary/80",
|
|
||||||
secondary: "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
||||||
destructive: "border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",
|
|
||||||
outline: "text-foreground",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
defaultVariants: {
|
|
||||||
variant: "default",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
export interface BadgeProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof badgeVariants> {}
|
|
||||||
|
|
||||||
function Badge({ className, variant, ...props }: BadgeProps) {
|
|
||||||
return <div className={cn(badgeVariants({ variant }), className)} {...props} />;
|
|
||||||
}
|
|
||||||
|
|
||||||
export { Badge, badgeVariants };
|
|
@ -1,57 +0,0 @@
|
|||||||
import * as React from "react";
|
|
||||||
import { Slot } from "@radix-ui/react-slot";
|
|
||||||
import { ChevronRight, MoreHorizontal } from "lucide-react";
|
|
||||||
|
|
||||||
import { cn } from "./utils";
|
|
||||||
|
|
||||||
const Breadcrumb = React.forwardRef<
|
|
||||||
HTMLElement,
|
|
||||||
React.ComponentPropsWithoutRef<"nav"> & {
|
|
||||||
separator?: React.ReactNode;
|
|
||||||
}
|
|
||||||
>(({ ...props }, ref) => <nav ref={ref} aria-label="breadcrumb" {...props} />);
|
|
||||||
Breadcrumb.displayName = "Breadcrumb";
|
|
||||||
|
|
||||||
const BreadcrumbList = React.forwardRef<HTMLOListElement, React.ComponentPropsWithoutRef<"ol">>(({ className, ...props }, ref) => (
|
|
||||||
<ol ref={ref} className={cn("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5", className)} {...props} />
|
|
||||||
));
|
|
||||||
BreadcrumbList.displayName = "BreadcrumbList";
|
|
||||||
|
|
||||||
const BreadcrumbItem = React.forwardRef<HTMLLIElement, React.ComponentPropsWithoutRef<"li">>(({ className, ...props }, ref) => (
|
|
||||||
<li ref={ref} className={cn("inline-flex items-center gap-1.5", className)} {...props} />
|
|
||||||
));
|
|
||||||
BreadcrumbItem.displayName = "BreadcrumbItem";
|
|
||||||
|
|
||||||
const BreadcrumbLink = React.forwardRef<
|
|
||||||
HTMLAnchorElement,
|
|
||||||
React.ComponentPropsWithoutRef<"a"> & {
|
|
||||||
asChild?: boolean;
|
|
||||||
}
|
|
||||||
>(({ asChild, className, ...props }, ref) => {
|
|
||||||
const Comp = asChild ? Slot : "a";
|
|
||||||
|
|
||||||
return <Comp ref={ref} className={cn("transition-colors hover:text-foreground", className)} {...props} />;
|
|
||||||
});
|
|
||||||
BreadcrumbLink.displayName = "BreadcrumbLink";
|
|
||||||
|
|
||||||
const BreadcrumbPage = React.forwardRef<HTMLSpanElement, React.ComponentPropsWithoutRef<"span">>(({ className, ...props }, ref) => (
|
|
||||||
<span ref={ref} role="link" aria-disabled="true" aria-current="page" className={cn("font-normal text-foreground", className)} {...props} />
|
|
||||||
));
|
|
||||||
BreadcrumbPage.displayName = "BreadcrumbPage";
|
|
||||||
|
|
||||||
const BreadcrumbSeparator = ({ children, className, ...props }: React.ComponentProps<"li">) => (
|
|
||||||
<li role="presentation" aria-hidden="true" className={cn("[&>svg]:size-3.5", className)} {...props}>
|
|
||||||
{children ?? <ChevronRight />}
|
|
||||||
</li>
|
|
||||||
);
|
|
||||||
BreadcrumbSeparator.displayName = "BreadcrumbSeparator";
|
|
||||||
|
|
||||||
const BreadcrumbEllipsis = ({ className, ...props }: React.ComponentProps<"span">) => (
|
|
||||||
<span role="presentation" aria-hidden="true" className={cn("flex h-9 w-9 items-center justify-center", className)} {...props}>
|
|
||||||
<MoreHorizontal className="h-4 w-4" />
|
|
||||||
<span className="sr-only">More</span>
|
|
||||||
</span>
|
|
||||||
);
|
|
||||||
BreadcrumbEllipsis.displayName = "BreadcrumbElipssis";
|
|
||||||
|
|
||||||
export { Breadcrumb, BreadcrumbList, BreadcrumbItem, BreadcrumbLink, BreadcrumbPage, BreadcrumbSeparator, BreadcrumbEllipsis };
|
|
@ -1,35 +0,0 @@
|
|||||||
import * as React from "react";
|
|
||||||
|
|
||||||
import { cn } from "./utils";
|
|
||||||
|
|
||||||
const Card = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(({ className, ...props }, ref) => (
|
|
||||||
<div ref={ref} className={cn("rounded-lg border bg-card text-card-foreground shadow-sm", className)} {...props} />
|
|
||||||
));
|
|
||||||
Card.displayName = "Card";
|
|
||||||
|
|
||||||
const CardHeader = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(({ className, ...props }, ref) => (
|
|
||||||
<div ref={ref} className={cn("flex flex-col space-y-1.5 p-6", className)} {...props} />
|
|
||||||
));
|
|
||||||
CardHeader.displayName = "CardHeader";
|
|
||||||
|
|
||||||
const CardTitle = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLHeadingElement>>(({ className, ...props }, ref) => (
|
|
||||||
<h3 ref={ref} className={cn("text-2xl font-semibold leading-none tracking-tight", className)} {...props} />
|
|
||||||
));
|
|
||||||
CardTitle.displayName = "CardTitle";
|
|
||||||
|
|
||||||
const CardDescription = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(({ className, ...props }, ref) => (
|
|
||||||
<p ref={ref} className={cn("text-sm text-muted-foreground", className)} {...props} />
|
|
||||||
));
|
|
||||||
CardDescription.displayName = "CardDescription";
|
|
||||||
|
|
||||||
const CardContent = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(({ className, ...props }, ref) => (
|
|
||||||
<div ref={ref} className={cn("p-6 pt-0", className)} {...props} />
|
|
||||||
));
|
|
||||||
CardContent.displayName = "CardContent";
|
|
||||||
|
|
||||||
const CardFooter = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(({ className, ...props }, ref) => (
|
|
||||||
<div ref={ref} className={cn("flex items-center p-6 pt-0", className)} {...props} />
|
|
||||||
));
|
|
||||||
CardFooter.displayName = "CardFooter";
|
|
||||||
|
|
||||||
export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent };
|
|
@ -1,62 +0,0 @@
|
|||||||
import * as React from "react";
|
|
||||||
import { Drawer as DrawerPrimitive } from "vaul";
|
|
||||||
|
|
||||||
import { cn } from "./utils";
|
|
||||||
|
|
||||||
const Drawer = ({ shouldScaleBackground = true, ...props }: React.ComponentProps<typeof DrawerPrimitive.Root>) => (
|
|
||||||
<DrawerPrimitive.Root shouldScaleBackground={shouldScaleBackground} {...props} />
|
|
||||||
);
|
|
||||||
Drawer.displayName = "Drawer";
|
|
||||||
|
|
||||||
const DrawerTrigger = DrawerPrimitive.Trigger;
|
|
||||||
|
|
||||||
const DrawerPortal = DrawerPrimitive.Portal;
|
|
||||||
|
|
||||||
const DrawerClose = DrawerPrimitive.Close;
|
|
||||||
|
|
||||||
const DrawerOverlay = React.forwardRef<React.ElementRef<typeof DrawerPrimitive.Overlay>, React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Overlay>>(
|
|
||||||
({ className, ...props }, ref) => <DrawerPrimitive.Overlay ref={ref} className={cn("fixed inset-0 z-50 bg-black/80", className)} {...props} />
|
|
||||||
);
|
|
||||||
DrawerOverlay.displayName = DrawerPrimitive.Overlay.displayName;
|
|
||||||
|
|
||||||
const DrawerContent = React.forwardRef<React.ElementRef<typeof DrawerPrimitive.Content>, React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Content>>(
|
|
||||||
({ className, children, ...props }, ref) => (
|
|
||||||
<DrawerPortal>
|
|
||||||
<DrawerOverlay />
|
|
||||||
<DrawerPrimitive.Content
|
|
||||||
ref={ref}
|
|
||||||
className={cn("fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background", className)}
|
|
||||||
{...props}
|
|
||||||
>
|
|
||||||
<div className="mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted" />
|
|
||||||
{children}
|
|
||||||
</DrawerPrimitive.Content>
|
|
||||||
</DrawerPortal>
|
|
||||||
)
|
|
||||||
);
|
|
||||||
DrawerContent.displayName = "DrawerContent";
|
|
||||||
|
|
||||||
const DrawerHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
|
||||||
<div className={cn("grid gap-1.5 p-4 text-center sm:text-left", className)} {...props} />
|
|
||||||
);
|
|
||||||
DrawerHeader.displayName = "DrawerHeader";
|
|
||||||
|
|
||||||
const DrawerFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
|
||||||
<div className={cn("mt-auto flex flex-col gap-2 p-4", className)} {...props} />
|
|
||||||
);
|
|
||||||
DrawerFooter.displayName = "DrawerFooter";
|
|
||||||
|
|
||||||
const DrawerTitle = React.forwardRef<React.ElementRef<typeof DrawerPrimitive.Title>, React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Title>>(
|
|
||||||
({ className, ...props }, ref) => (
|
|
||||||
<DrawerPrimitive.Title ref={ref} className={cn("text-lg font-semibold leading-none tracking-tight", className)} {...props} />
|
|
||||||
)
|
|
||||||
);
|
|
||||||
DrawerTitle.displayName = DrawerPrimitive.Title.displayName;
|
|
||||||
|
|
||||||
const DrawerDescription = React.forwardRef<
|
|
||||||
React.ElementRef<typeof DrawerPrimitive.Description>,
|
|
||||||
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Description>
|
|
||||||
>(({ className, ...props }, ref) => <DrawerPrimitive.Description ref={ref} className={cn("text-sm text-muted-foreground", className)} {...props} />);
|
|
||||||
DrawerDescription.displayName = DrawerPrimitive.Description.displayName;
|
|
||||||
|
|
||||||
export { Drawer, DrawerPortal, DrawerOverlay, DrawerTrigger, DrawerClose, DrawerContent, DrawerHeader, DrawerFooter, DrawerTitle, DrawerDescription };
|
|
@ -1,104 +0,0 @@
|
|||||||
import * as React from "react";
|
|
||||||
import * as NavigationMenuPrimitive from "@radix-ui/react-navigation-menu";
|
|
||||||
import { ChevronDown } from "lucide-react";
|
|
||||||
import { cva } from "class-variance-authority";
|
|
||||||
|
|
||||||
import { cn } from "./utils";
|
|
||||||
|
|
||||||
const NavigationMenu = React.forwardRef<
|
|
||||||
React.ElementRef<typeof NavigationMenuPrimitive.Root>,
|
|
||||||
React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.Root>
|
|
||||||
>(({ className, children, ...props }, ref) => (
|
|
||||||
<NavigationMenuPrimitive.Root ref={ref} className={cn("relative z-10 flex max-w-max flex-1 items-center justify-center", className)} {...props}>
|
|
||||||
{children}
|
|
||||||
<NavigationMenuViewport />
|
|
||||||
</NavigationMenuPrimitive.Root>
|
|
||||||
));
|
|
||||||
NavigationMenu.displayName = NavigationMenuPrimitive.Root.displayName;
|
|
||||||
|
|
||||||
const NavigationMenuList = React.forwardRef<
|
|
||||||
React.ElementRef<typeof NavigationMenuPrimitive.List>,
|
|
||||||
React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.List>
|
|
||||||
>(({ className, ...props }, ref) => (
|
|
||||||
<NavigationMenuPrimitive.List ref={ref} className={cn("group flex flex-1 list-none items-center justify-center space-x-1", className)} {...props} />
|
|
||||||
));
|
|
||||||
NavigationMenuList.displayName = NavigationMenuPrimitive.List.displayName;
|
|
||||||
|
|
||||||
const NavigationMenuItem = NavigationMenuPrimitive.Item;
|
|
||||||
|
|
||||||
const navigationMenuTriggerStyle = cva(
|
|
||||||
"group inline-flex h-10 w-max items-center justify-center rounded-md bg-background px-4 py-2 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground focus:outline-none disabled:pointer-events-none disabled:opacity-50 data-[active]:bg-accent/50 data-[state=open]:bg-accent/50"
|
|
||||||
);
|
|
||||||
|
|
||||||
const NavigationMenuTrigger = React.forwardRef<
|
|
||||||
React.ElementRef<typeof NavigationMenuPrimitive.Trigger>,
|
|
||||||
React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.Trigger>
|
|
||||||
>(({ className, children, ...props }, ref) => (
|
|
||||||
<NavigationMenuPrimitive.Trigger ref={ref} className={cn(navigationMenuTriggerStyle(), "group", className)} {...props}>
|
|
||||||
{children} <ChevronDown className="relative top-[1px] ml-1 h-3 w-3 transition duration-200 group-data-[state=open]:rotate-180" aria-hidden="true" />
|
|
||||||
</NavigationMenuPrimitive.Trigger>
|
|
||||||
));
|
|
||||||
NavigationMenuTrigger.displayName = NavigationMenuPrimitive.Trigger.displayName;
|
|
||||||
|
|
||||||
const NavigationMenuContent = React.forwardRef<
|
|
||||||
React.ElementRef<typeof NavigationMenuPrimitive.Content>,
|
|
||||||
React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.Content>
|
|
||||||
>(({ className, ...props }, ref) => (
|
|
||||||
<NavigationMenuPrimitive.Content
|
|
||||||
ref={ref}
|
|
||||||
className={cn(
|
|
||||||
"left-0 top-0 w-full data-[motion^=from-]:animate-in data-[motion^=to-]:animate-out data-[motion^=from-]:fade-in data-[motion^=to-]:fade-out data-[motion=from-end]:slide-in-from-right-52 data-[motion=from-start]:slide-in-from-left-52 data-[motion=to-end]:slide-out-to-right-52 data-[motion=to-start]:slide-out-to-left-52 md:absolute md:w-auto ",
|
|
||||||
className
|
|
||||||
)}
|
|
||||||
{...props}
|
|
||||||
/>
|
|
||||||
));
|
|
||||||
NavigationMenuContent.displayName = NavigationMenuPrimitive.Content.displayName;
|
|
||||||
|
|
||||||
const NavigationMenuLink = NavigationMenuPrimitive.Link;
|
|
||||||
|
|
||||||
const NavigationMenuViewport = React.forwardRef<
|
|
||||||
React.ElementRef<typeof NavigationMenuPrimitive.Viewport>,
|
|
||||||
React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.Viewport>
|
|
||||||
>(({ className, ...props }, ref) => (
|
|
||||||
<div className={cn("absolute left-0 top-full flex justify-center")}>
|
|
||||||
<NavigationMenuPrimitive.Viewport
|
|
||||||
className={cn(
|
|
||||||
"origin-top-center relative mt-1.5 h-[var(--radix-navigation-menu-viewport-height)] w-full overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-90 md:w-[var(--radix-navigation-menu-viewport-width)]",
|
|
||||||
className
|
|
||||||
)}
|
|
||||||
ref={ref}
|
|
||||||
{...props}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
));
|
|
||||||
NavigationMenuViewport.displayName = NavigationMenuPrimitive.Viewport.displayName;
|
|
||||||
|
|
||||||
const NavigationMenuIndicator = React.forwardRef<
|
|
||||||
React.ElementRef<typeof NavigationMenuPrimitive.Indicator>,
|
|
||||||
React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.Indicator>
|
|
||||||
>(({ className, ...props }, ref) => (
|
|
||||||
<NavigationMenuPrimitive.Indicator
|
|
||||||
ref={ref}
|
|
||||||
className={cn(
|
|
||||||
"top-full z-[1] flex h-1.5 items-end justify-center overflow-hidden data-[state=visible]:animate-in data-[state=hidden]:animate-out data-[state=hidden]:fade-out data-[state=visible]:fade-in",
|
|
||||||
className
|
|
||||||
)}
|
|
||||||
{...props}
|
|
||||||
>
|
|
||||||
<div className="relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm bg-border shadow-md" />
|
|
||||||
</NavigationMenuPrimitive.Indicator>
|
|
||||||
));
|
|
||||||
NavigationMenuIndicator.displayName = NavigationMenuPrimitive.Indicator.displayName;
|
|
||||||
|
|
||||||
export {
|
|
||||||
navigationMenuTriggerStyle,
|
|
||||||
NavigationMenu,
|
|
||||||
NavigationMenuList,
|
|
||||||
NavigationMenuItem,
|
|
||||||
NavigationMenuContent,
|
|
||||||
NavigationMenuTrigger,
|
|
||||||
NavigationMenuLink,
|
|
||||||
NavigationMenuIndicator,
|
|
||||||
NavigationMenuViewport,
|
|
||||||
};
|
|
@ -1,79 +0,0 @@
|
|||||||
import * as React from "react";
|
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
import { ChevronLeft, ChevronRight, MoreHorizontal } from "lucide-react";
|
|
||||||
|
|
||||||
import { cn } from "./utils";
|
|
||||||
import { ButtonProps, buttonVariants } from "@/components/ui/button";
|
|
||||||
|
|
||||||
const Pagination = ({ className, ...props }: React.ComponentProps<"nav">) => (
|
|
||||||
<nav role="navigation" aria-label="pagination" className={cn("mx-auto flex w-full justify-center", className)} {...props} />
|
|
||||||
);
|
|
||||||
Pagination.displayName = "Pagination";
|
|
||||||
|
|
||||||
const PaginationContent = React.forwardRef<HTMLUListElement, React.ComponentProps<"ul">>(({ className, ...props }, ref) => (
|
|
||||||
<ul ref={ref} className={cn("flex flex-row items-center gap-1", className)} {...props} />
|
|
||||||
));
|
|
||||||
PaginationContent.displayName = "PaginationContent";
|
|
||||||
|
|
||||||
const PaginationItem = React.forwardRef<HTMLLIElement, React.ComponentProps<"li">>(({ className, ...props }, ref) => (
|
|
||||||
<li ref={ref} className={cn("", className)} {...props} />
|
|
||||||
));
|
|
||||||
PaginationItem.displayName = "PaginationItem";
|
|
||||||
|
|
||||||
type PaginationLinkProps = {
|
|
||||||
isActive?: boolean;
|
|
||||||
} & Pick<ButtonProps, "size"> &
|
|
||||||
React.ComponentProps<"a">;
|
|
||||||
|
|
||||||
const PaginationLink = ({ className, isActive, size = "icon", ...props }: PaginationLinkProps) => (
|
|
||||||
<a
|
|
||||||
aria-current={isActive ? "page" : undefined}
|
|
||||||
className={cn(
|
|
||||||
buttonVariants({
|
|
||||||
variant: isActive ? "outline" : "ghost",
|
|
||||||
size,
|
|
||||||
}),
|
|
||||||
className
|
|
||||||
)}
|
|
||||||
{...props}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
PaginationLink.displayName = "PaginationLink";
|
|
||||||
|
|
||||||
const PaginationPrevious = ({ className, ...props }: React.ComponentProps<typeof PaginationLink>) => {
|
|
||||||
const { t } = useTranslation();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<PaginationLink aria-label="Go to previous page" size="default" className={cn("gap-1 pl-2.5", className)} {...props}>
|
|
||||||
<ChevronLeft className="h-4 w-4" />
|
|
||||||
<span>{t("common.pagination.prev")}</span>
|
|
||||||
</PaginationLink>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
PaginationPrevious.displayName = "PaginationPrevious";
|
|
||||||
|
|
||||||
const PaginationNext = ({ className, ...props }: React.ComponentProps<typeof PaginationLink>) => {
|
|
||||||
const { t } = useTranslation();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<PaginationLink aria-label="Go to next page" size="default" className={cn("gap-1 pr-2.5", className)} {...props}>
|
|
||||||
<span>{t("common.pagination.next")}</span>
|
|
||||||
<ChevronRight className="h-4 w-4" />
|
|
||||||
</PaginationLink>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
PaginationNext.displayName = "PaginationNext";
|
|
||||||
|
|
||||||
const PaginationEllipsis = ({ className, ...props }: React.ComponentProps<"span">) => {
|
|
||||||
const { t } = useTranslation();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<span aria-hidden className={cn("flex h-9 w-9 items-center justify-center", className)} {...props}>
|
|
||||||
<MoreHorizontal className="h-4 w-4" />
|
|
||||||
<span className="sr-only">{t("common.pagination.more")}</span>
|
|
||||||
</span>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
PaginationEllipsis.displayName = "PaginationEllipsis";
|
|
||||||
|
|
||||||
export { Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious };
|
|
@ -1,15 +0,0 @@
|
|||||||
import * as React from "react";
|
|
||||||
import * as ProgressPrimitive from "@radix-ui/react-progress";
|
|
||||||
|
|
||||||
import { cn } from "./utils";
|
|
||||||
|
|
||||||
const Progress = React.forwardRef<React.ElementRef<typeof ProgressPrimitive.Root>, React.ComponentPropsWithoutRef<typeof ProgressPrimitive.Root>>(
|
|
||||||
({ className, value, ...props }, ref) => (
|
|
||||||
<ProgressPrimitive.Root ref={ref} className={cn("relative h-4 w-full overflow-hidden rounded-full bg-secondary", className)} {...props}>
|
|
||||||
<ProgressPrimitive.Indicator className="h-full w-full flex-1 bg-primary transition-all" style={{ transform: `translateX(-${100 - (value || 0)}%)` }} />
|
|
||||||
</ProgressPrimitive.Root>
|
|
||||||
)
|
|
||||||
);
|
|
||||||
Progress.displayName = ProgressPrimitive.Root.displayName;
|
|
||||||
|
|
||||||
export { Progress };
|
|
@ -3,7 +3,7 @@ import { Plus } from "lucide-react";
|
|||||||
import { BrandNodeProps, NodeProps } from "./types";
|
import { BrandNodeProps, NodeProps } from "./types";
|
||||||
|
|
||||||
import { newWorkflowNode, workflowNodeDropdownList, WorkflowNodeType } from "@/domain/workflow";
|
import { newWorkflowNode, workflowNodeDropdownList, WorkflowNodeType } from "@/domain/workflow";
|
||||||
import { useWorkflowStore, WorkflowState } from "@/providers/workflow";
|
import { useWorkflowStore, WorkflowState } from "@/stores/workflow";
|
||||||
import { useShallow } from "zustand/shallow";
|
import { useShallow } from "zustand/shallow";
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
|
@ -22,7 +22,7 @@ import { useConfigContext } from "@/providers/config";
|
|||||||
import { Switch } from "@/components/ui/switch";
|
import { Switch } from "@/components/ui/switch";
|
||||||
import { TooltipFast } from "@/components/ui/tooltip";
|
import { TooltipFast } from "@/components/ui/tooltip";
|
||||||
import { WorkflowNode, WorkflowNodeConfig } from "@/domain/workflow";
|
import { WorkflowNode, WorkflowNodeConfig } from "@/domain/workflow";
|
||||||
import { useWorkflowStore, WorkflowState } from "@/providers/workflow";
|
import { useWorkflowStore, WorkflowState } from "@/stores/workflow";
|
||||||
import { useShallow } from "zustand/shallow";
|
import { useShallow } from "zustand/shallow";
|
||||||
import { usePanel } from "./PanelProvider";
|
import { usePanel } from "./PanelProvider";
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import { WorkflowBranchNode, WorkflowNode } from "@/domain/workflow";
|
|||||||
import NodeRender from "./NodeRender";
|
import NodeRender from "./NodeRender";
|
||||||
import { memo } from "react";
|
import { memo } from "react";
|
||||||
import { BrandNodeProps } from "./types";
|
import { BrandNodeProps } from "./types";
|
||||||
import { useWorkflowStore, WorkflowState } from "@/providers/workflow";
|
import { useWorkflowStore, WorkflowState } from "@/stores/workflow";
|
||||||
import { useShallow } from "zustand/shallow";
|
import { useShallow } from "zustand/shallow";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { useWorkflowStore, WorkflowState } from "@/providers/workflow";
|
import { useWorkflowStore, WorkflowState } from "@/stores/workflow";
|
||||||
import AddNode from "./AddNode";
|
import AddNode from "./AddNode";
|
||||||
import { NodeProps } from "./types";
|
import { NodeProps } from "./types";
|
||||||
import { useShallow } from "zustand/shallow";
|
import { useShallow } from "zustand/shallow";
|
||||||
|
@ -1,46 +0,0 @@
|
|||||||
import {
|
|
||||||
AlertDialog,
|
|
||||||
AlertDialogAction,
|
|
||||||
AlertDialogCancel,
|
|
||||||
AlertDialogContent,
|
|
||||||
AlertDialogDescription,
|
|
||||||
AlertDialogFooter,
|
|
||||||
AlertDialogHeader,
|
|
||||||
AlertDialogTitle,
|
|
||||||
} from "@/components/ui/alert-dialog";
|
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
|
|
||||||
type CustomAlertDialogProps = {
|
|
||||||
open: boolean;
|
|
||||||
onOpenChange?: (open: boolean) => void;
|
|
||||||
title?: string;
|
|
||||||
description?: string;
|
|
||||||
confirm?: () => void;
|
|
||||||
};
|
|
||||||
|
|
||||||
const CustomAlertDialog = ({ open, title, description, confirm, onOpenChange }: CustomAlertDialogProps) => {
|
|
||||||
const { t } = useTranslation();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<AlertDialog open={open} onOpenChange={onOpenChange}>
|
|
||||||
<AlertDialogContent>
|
|
||||||
<AlertDialogHeader className="dark:text-stone-200">
|
|
||||||
<AlertDialogTitle>{title}</AlertDialogTitle>
|
|
||||||
<AlertDialogDescription>{description}</AlertDialogDescription>
|
|
||||||
</AlertDialogHeader>
|
|
||||||
<AlertDialogFooter>
|
|
||||||
<AlertDialogCancel className="dark:text-stone-200">{t("common.cancel")}</AlertDialogCancel>
|
|
||||||
<AlertDialogAction
|
|
||||||
onClick={() => {
|
|
||||||
confirm && confirm();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{t("common.confirm")}
|
|
||||||
</AlertDialogAction>
|
|
||||||
</AlertDialogFooter>
|
|
||||||
</AlertDialogContent>
|
|
||||||
</AlertDialog>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default CustomAlertDialog;
|
|
@ -6,7 +6,7 @@ import { Input } from "@/components/ui/input";
|
|||||||
import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectTrigger, SelectValue } from "@/components/ui/select";
|
import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||||
import { DeployFormProps } from "./DeployForm";
|
import { DeployFormProps } from "./DeployForm";
|
||||||
import { WorkflowNode, WorkflowNodeConfig } from "@/domain/workflow";
|
import { WorkflowNode, WorkflowNodeConfig } from "@/domain/workflow";
|
||||||
import { useWorkflowStore, WorkflowState } from "@/providers/workflow";
|
import { useWorkflowStore, WorkflowState } from "@/stores/workflow";
|
||||||
import { useShallow } from "zustand/shallow";
|
import { useShallow } from "zustand/shallow";
|
||||||
import { usePanel } from "./PanelProvider";
|
import { usePanel } from "./PanelProvider";
|
||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
|
@ -7,7 +7,7 @@ import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from "
|
|||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { WorkflowNode, WorkflowNodeConfig } from "@/domain/workflow";
|
import { WorkflowNode, WorkflowNodeConfig } from "@/domain/workflow";
|
||||||
import { useWorkflowStore, WorkflowState } from "@/providers/workflow";
|
import { useWorkflowStore, WorkflowState } from "@/stores/workflow";
|
||||||
import { useShallow } from "zustand/shallow";
|
import { useShallow } from "zustand/shallow";
|
||||||
import { usePanel } from "./PanelProvider";
|
import { usePanel } from "./PanelProvider";
|
||||||
import { Button } from "../ui/button";
|
import { Button } from "../ui/button";
|
||||||
|
@ -6,7 +6,7 @@ import { Input } from "@/components/ui/input";
|
|||||||
import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectTrigger, SelectValue } from "@/components/ui/select";
|
import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||||
import { DeployFormProps } from "./DeployForm";
|
import { DeployFormProps } from "./DeployForm";
|
||||||
import { WorkflowNode, WorkflowNodeConfig } from "@/domain/workflow";
|
import { WorkflowNode, WorkflowNodeConfig } from "@/domain/workflow";
|
||||||
import { useWorkflowStore, WorkflowState } from "@/providers/workflow";
|
import { useWorkflowStore, WorkflowState } from "@/stores/workflow";
|
||||||
import { useShallow } from "zustand/shallow";
|
import { useShallow } from "zustand/shallow";
|
||||||
import { usePanel } from "./PanelProvider";
|
import { usePanel } from "./PanelProvider";
|
||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
|
@ -6,7 +6,7 @@ import { Input } from "@/components/ui/input";
|
|||||||
import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectTrigger, SelectValue } from "@/components/ui/select";
|
import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||||
import { DeployFormProps } from "./DeployForm";
|
import { DeployFormProps } from "./DeployForm";
|
||||||
import { WorkflowNode, WorkflowNodeConfig } from "@/domain/workflow";
|
import { WorkflowNode, WorkflowNodeConfig } from "@/domain/workflow";
|
||||||
import { useWorkflowStore, WorkflowState } from "@/providers/workflow";
|
import { useWorkflowStore, WorkflowState } from "@/stores/workflow";
|
||||||
import { useShallow } from "zustand/shallow";
|
import { useShallow } from "zustand/shallow";
|
||||||
import { usePanel } from "./PanelProvider";
|
import { usePanel } from "./PanelProvider";
|
||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
|
@ -7,7 +7,7 @@ import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from "
|
|||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { WorkflowNode, WorkflowNodeConfig } from "@/domain/workflow";
|
import { WorkflowNode, WorkflowNodeConfig } from "@/domain/workflow";
|
||||||
import { useWorkflowStore, WorkflowState } from "@/providers/workflow";
|
import { useWorkflowStore, WorkflowState } from "@/stores/workflow";
|
||||||
import { useShallow } from "zustand/shallow";
|
import { useShallow } from "zustand/shallow";
|
||||||
import { usePanel } from "./PanelProvider";
|
import { usePanel } from "./PanelProvider";
|
||||||
import { Button } from "../ui/button";
|
import { Button } from "../ui/button";
|
||||||
|
@ -7,7 +7,7 @@ import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from "
|
|||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { WorkflowNode, WorkflowNodeConfig } from "@/domain/workflow";
|
import { WorkflowNode, WorkflowNodeConfig } from "@/domain/workflow";
|
||||||
import { useWorkflowStore, WorkflowState } from "@/providers/workflow";
|
import { useWorkflowStore, WorkflowState } from "@/stores/workflow";
|
||||||
import { useShallow } from "zustand/shallow";
|
import { useShallow } from "zustand/shallow";
|
||||||
import { usePanel } from "./PanelProvider";
|
import { usePanel } from "./PanelProvider";
|
||||||
import { Button } from "../ui/button";
|
import { Button } from "../ui/button";
|
||||||
|
@ -7,7 +7,7 @@ import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from "
|
|||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { WorkflowNode, WorkflowNodeConfig } from "@/domain/workflow";
|
import { WorkflowNode, WorkflowNodeConfig } from "@/domain/workflow";
|
||||||
import { useWorkflowStore, WorkflowState } from "@/providers/workflow";
|
import { useWorkflowStore, WorkflowState } from "@/stores/workflow";
|
||||||
import { useShallow } from "zustand/shallow";
|
import { useShallow } from "zustand/shallow";
|
||||||
import { usePanel } from "./PanelProvider";
|
import { usePanel } from "./PanelProvider";
|
||||||
import { Button } from "../ui/button";
|
import { Button } from "../ui/button";
|
||||||
|
@ -7,7 +7,7 @@ import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from "
|
|||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { WorkflowNode, WorkflowNodeConfig } from "@/domain/workflow";
|
import { WorkflowNode, WorkflowNodeConfig } from "@/domain/workflow";
|
||||||
import { useWorkflowStore, WorkflowState } from "@/providers/workflow";
|
import { useWorkflowStore, WorkflowState } from "@/stores/workflow";
|
||||||
import { useShallow } from "zustand/shallow";
|
import { useShallow } from "zustand/shallow";
|
||||||
import { usePanel } from "./PanelProvider";
|
import { usePanel } from "./PanelProvider";
|
||||||
import { Button } from "../ui/button";
|
import { Button } from "../ui/button";
|
||||||
|
@ -7,7 +7,7 @@ import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from "
|
|||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { WorkflowNode, WorkflowNodeConfig } from "@/domain/workflow";
|
import { WorkflowNode, WorkflowNodeConfig } from "@/domain/workflow";
|
||||||
import { useWorkflowStore, WorkflowState } from "@/providers/workflow";
|
import { useWorkflowStore, WorkflowState } from "@/stores/workflow";
|
||||||
import { useShallow } from "zustand/shallow";
|
import { useShallow } from "zustand/shallow";
|
||||||
import { usePanel } from "./PanelProvider";
|
import { usePanel } from "./PanelProvider";
|
||||||
import { Button } from "../ui/button";
|
import { Button } from "../ui/button";
|
||||||
|
@ -7,7 +7,7 @@ import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from "
|
|||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { WorkflowNode, WorkflowNodeConfig } from "@/domain/workflow";
|
import { WorkflowNode, WorkflowNodeConfig } from "@/domain/workflow";
|
||||||
import { useWorkflowStore, WorkflowState } from "@/providers/workflow";
|
import { useWorkflowStore, WorkflowState } from "@/stores/workflow";
|
||||||
import { useShallow } from "zustand/shallow";
|
import { useShallow } from "zustand/shallow";
|
||||||
import { usePanel } from "./PanelProvider";
|
import { usePanel } from "./PanelProvider";
|
||||||
import { Button } from "../ui/button";
|
import { Button } from "../ui/button";
|
||||||
|
@ -7,7 +7,7 @@ import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from "
|
|||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { WorkflowNode, WorkflowNodeConfig } from "@/domain/workflow";
|
import { WorkflowNode, WorkflowNodeConfig } from "@/domain/workflow";
|
||||||
import { useWorkflowStore, WorkflowState } from "@/providers/workflow";
|
import { useWorkflowStore, WorkflowState } from "@/stores/workflow";
|
||||||
import { useShallow } from "zustand/shallow";
|
import { useShallow } from "zustand/shallow";
|
||||||
import { usePanel } from "./PanelProvider";
|
import { usePanel } from "./PanelProvider";
|
||||||
import { Button } from "../ui/button";
|
import { Button } from "../ui/button";
|
||||||
|
@ -7,7 +7,7 @@ import { Input } from "@/components/ui/input";
|
|||||||
import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectTrigger, SelectValue } from "../ui/select";
|
import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectTrigger, SelectValue } from "../ui/select";
|
||||||
import { Button } from "../ui/button";
|
import { Button } from "../ui/button";
|
||||||
import { DeployFormProps } from "./DeployForm";
|
import { DeployFormProps } from "./DeployForm";
|
||||||
import { useWorkflowStore, WorkflowState } from "@/providers/workflow";
|
import { useWorkflowStore, WorkflowState } from "@/stores/workflow";
|
||||||
import { useShallow } from "zustand/shallow";
|
import { useShallow } from "zustand/shallow";
|
||||||
import { usePanel } from "./PanelProvider";
|
import { usePanel } from "./PanelProvider";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
|
@ -7,7 +7,7 @@ import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from "
|
|||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { WorkflowNode, WorkflowNodeConfig } from "@/domain/workflow";
|
import { WorkflowNode, WorkflowNodeConfig } from "@/domain/workflow";
|
||||||
import { useWorkflowStore, WorkflowState } from "@/providers/workflow";
|
import { useWorkflowStore, WorkflowState } from "@/stores/workflow";
|
||||||
import { useShallow } from "zustand/shallow";
|
import { useShallow } from "zustand/shallow";
|
||||||
import { usePanel } from "./PanelProvider";
|
import { usePanel } from "./PanelProvider";
|
||||||
import { Button } from "../ui/button";
|
import { Button } from "../ui/button";
|
||||||
|
@ -7,7 +7,7 @@ import { Input } from "@/components/ui/input";
|
|||||||
import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectTrigger, SelectValue } from "../ui/select";
|
import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectTrigger, SelectValue } from "../ui/select";
|
||||||
import { Button } from "../ui/button";
|
import { Button } from "../ui/button";
|
||||||
import { DeployFormProps } from "./DeployForm";
|
import { DeployFormProps } from "./DeployForm";
|
||||||
import { useWorkflowStore, WorkflowState } from "@/providers/workflow";
|
import { useWorkflowStore, WorkflowState } from "@/stores/workflow";
|
||||||
import { useShallow } from "zustand/shallow";
|
import { useShallow } from "zustand/shallow";
|
||||||
import { usePanel } from "./PanelProvider";
|
import { usePanel } from "./PanelProvider";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
|
@ -7,7 +7,7 @@ import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from "
|
|||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { WorkflowNode, WorkflowNodeConfig } from "@/domain/workflow";
|
import { WorkflowNode, WorkflowNodeConfig } from "@/domain/workflow";
|
||||||
import { useWorkflowStore, WorkflowState } from "@/providers/workflow";
|
import { useWorkflowStore, WorkflowState } from "@/stores/workflow";
|
||||||
import { useShallow } from "zustand/shallow";
|
import { useShallow } from "zustand/shallow";
|
||||||
import { usePanel } from "./PanelProvider";
|
import { usePanel } from "./PanelProvider";
|
||||||
import { Button } from "../ui/button";
|
import { Button } from "../ui/button";
|
||||||
|
@ -7,7 +7,7 @@ import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from "
|
|||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { WorkflowNode, WorkflowNodeConfig } from "@/domain/workflow";
|
import { WorkflowNode, WorkflowNodeConfig } from "@/domain/workflow";
|
||||||
import { useWorkflowStore, WorkflowState } from "@/providers/workflow";
|
import { useWorkflowStore, WorkflowState } from "@/stores/workflow";
|
||||||
import { useShallow } from "zustand/shallow";
|
import { useShallow } from "zustand/shallow";
|
||||||
import { usePanel } from "./PanelProvider";
|
import { usePanel } from "./PanelProvider";
|
||||||
import { Button } from "../ui/button";
|
import { Button } from "../ui/button";
|
||||||
|
@ -7,7 +7,7 @@ import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from "
|
|||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { WorkflowNode, WorkflowNodeConfig } from "@/domain/workflow";
|
import { WorkflowNode, WorkflowNodeConfig } from "@/domain/workflow";
|
||||||
import { useWorkflowStore, WorkflowState } from "@/providers/workflow";
|
import { useWorkflowStore, WorkflowState } from "@/stores/workflow";
|
||||||
import { useShallow } from "zustand/shallow";
|
import { useShallow } from "zustand/shallow";
|
||||||
import { usePanel } from "./PanelProvider";
|
import { usePanel } from "./PanelProvider";
|
||||||
import { Button } from "../ui/button";
|
import { Button } from "../ui/button";
|
||||||
|
@ -7,7 +7,7 @@ import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from "
|
|||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { WorkflowNode, WorkflowNodeConfig } from "@/domain/workflow";
|
import { WorkflowNode, WorkflowNodeConfig } from "@/domain/workflow";
|
||||||
import { useWorkflowStore, WorkflowState } from "@/providers/workflow";
|
import { useWorkflowStore, WorkflowState } from "@/stores/workflow";
|
||||||
import { useShallow } from "zustand/shallow";
|
import { useShallow } from "zustand/shallow";
|
||||||
import { usePanel } from "./PanelProvider";
|
import { usePanel } from "./PanelProvider";
|
||||||
import { Button } from "../ui/button";
|
import { Button } from "../ui/button";
|
||||||
|
@ -7,7 +7,7 @@ import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from "
|
|||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { WorkflowNode, WorkflowNodeConfig } from "@/domain/workflow";
|
import { WorkflowNode, WorkflowNodeConfig } from "@/domain/workflow";
|
||||||
import { useWorkflowStore, WorkflowState } from "@/providers/workflow";
|
import { useWorkflowStore, WorkflowState } from "@/stores/workflow";
|
||||||
import { useShallow } from "zustand/shallow";
|
import { useShallow } from "zustand/shallow";
|
||||||
import { usePanel } from "./PanelProvider";
|
import { usePanel } from "./PanelProvider";
|
||||||
import { Button } from "../ui/button";
|
import { Button } from "../ui/button";
|
||||||
|
@ -7,7 +7,7 @@ import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from "
|
|||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { WorkflowNode, WorkflowNodeConfig } from "@/domain/workflow";
|
import { WorkflowNode, WorkflowNodeConfig } from "@/domain/workflow";
|
||||||
import { useWorkflowStore, WorkflowState } from "@/providers/workflow";
|
import { useWorkflowStore, WorkflowState } from "@/stores/workflow";
|
||||||
import { useShallow } from "zustand/shallow";
|
import { useShallow } from "zustand/shallow";
|
||||||
import { usePanel } from "./PanelProvider";
|
import { usePanel } from "./PanelProvider";
|
||||||
import { Button } from "../ui/button";
|
import { Button } from "../ui/button";
|
||||||
|
@ -6,7 +6,7 @@ import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from "
|
|||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { WorkflowNode, WorkflowNodeConfig } from "@/domain/workflow";
|
import { WorkflowNode, WorkflowNodeConfig } from "@/domain/workflow";
|
||||||
import { useWorkflowStore, WorkflowState } from "@/providers/workflow";
|
import { useWorkflowStore, WorkflowState } from "@/stores/workflow";
|
||||||
import { useShallow } from "zustand/shallow";
|
import { useShallow } from "zustand/shallow";
|
||||||
import { usePanel } from "./PanelProvider";
|
import { usePanel } from "./PanelProvider";
|
||||||
import { Button } from "../ui/button";
|
import { Button } from "../ui/button";
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { WorkflowNode, WorkflowNodeType } from "@/domain/workflow";
|
import { WorkflowNode, WorkflowNodeType } from "@/domain/workflow";
|
||||||
import AddNode from "./AddNode";
|
import AddNode from "./AddNode";
|
||||||
import { useWorkflowStore, WorkflowState } from "@/providers/workflow";
|
import { useWorkflowStore, WorkflowState } from "@/stores/workflow";
|
||||||
import { useShallow } from "zustand/shallow";
|
import { useShallow } from "zustand/shallow";
|
||||||
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "../ui/dropdown-menu";
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "../ui/dropdown-menu";
|
||||||
import { Ellipsis, Trash2 } from "lucide-react";
|
import { Ellipsis, Trash2 } from "lucide-react";
|
||||||
|
@ -5,7 +5,7 @@ import { z } from "zod";
|
|||||||
import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from "../ui/form";
|
import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from "../ui/form";
|
||||||
import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger } from "../ui/select";
|
import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger } from "../ui/select";
|
||||||
import { Input } from "../ui/input";
|
import { Input } from "../ui/input";
|
||||||
import { useWorkflowStore, WorkflowState } from "@/providers/workflow";
|
import { useWorkflowStore, WorkflowState } from "@/stores/workflow";
|
||||||
import { useShallow } from "zustand/shallow";
|
import { useShallow } from "zustand/shallow";
|
||||||
import { usePanel } from "./PanelProvider";
|
import { usePanel } from "./PanelProvider";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
@ -10,7 +10,7 @@ import { RadioGroup, RadioGroupItem } from "../ui/radio-group";
|
|||||||
import { Label } from "../ui/label";
|
import { Label } from "../ui/label";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { parseExpression } from "cron-parser";
|
import { parseExpression } from "cron-parser";
|
||||||
import { useWorkflowStore, WorkflowState } from "@/providers/workflow";
|
import { useWorkflowStore, WorkflowState } from "@/stores/workflow";
|
||||||
import { useShallow } from "zustand/shallow";
|
import { useShallow } from "zustand/shallow";
|
||||||
import { usePanel } from "./PanelProvider";
|
import { usePanel } from "./PanelProvider";
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger } from "../ui/dialog";
|
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger } from "../ui/dialog";
|
||||||
import { useWorkflowStore, WorkflowState } from "@/providers/workflow";
|
import { useWorkflowStore, WorkflowState } from "@/stores/workflow";
|
||||||
import { useShallow } from "zustand/shallow";
|
import { useShallow } from "zustand/shallow";
|
||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
|
@ -14,7 +14,7 @@ import { cn } from "@/components/ui/utils";
|
|||||||
import WorkflowProvider from "@/components/workflow/WorkflowProvider";
|
import WorkflowProvider from "@/components/workflow/WorkflowProvider";
|
||||||
import { allNodesValidated, WorkflowNode } from "@/domain/workflow";
|
import { allNodesValidated, WorkflowNode } from "@/domain/workflow";
|
||||||
import { getErrMessage } from "@/lib/error";
|
import { getErrMessage } from "@/lib/error";
|
||||||
import { useWorkflowStore, WorkflowState } from "@/providers/workflow";
|
import { useWorkflowStore, WorkflowState } from "@/stores/workflow";
|
||||||
import { ArrowLeft } from "lucide-react";
|
import { ArrowLeft } from "lucide-react";
|
||||||
import { useEffect, useMemo, useState } from "react";
|
import { useEffect, useMemo, useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import { create } from "zustand";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
addBranch,
|
addBranch,
|
||||||
addNode,
|
addNode,
|
||||||
@ -12,8 +14,7 @@ import {
|
|||||||
WorkflowNode,
|
WorkflowNode,
|
||||||
WorkflowNodeType,
|
WorkflowNodeType,
|
||||||
} from "@/domain/workflow";
|
} from "@/domain/workflow";
|
||||||
import { save, get as getWrokflow } from "@/repository/workflow";
|
import { get as getWorkflow, save as saveWorkflow } from "@/repository/workflow";
|
||||||
import { create } from "zustand";
|
|
||||||
|
|
||||||
export type WorkflowState = {
|
export type WorkflowState = {
|
||||||
workflow: Workflow;
|
workflow: Workflow;
|
||||||
@ -47,7 +48,7 @@ export const useWorkflowStore = create<WorkflowState>((set, get) => ({
|
|||||||
if (!id) {
|
if (!id) {
|
||||||
data = initWorkflow();
|
data = initWorkflow();
|
||||||
} else {
|
} else {
|
||||||
data = await getWrokflow(id);
|
data = await getWorkflow(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
set({
|
set({
|
||||||
@ -64,7 +65,7 @@ export const useWorkflowStore = create<WorkflowState>((set, get) => ({
|
|||||||
if (!data.id) {
|
if (!data.id) {
|
||||||
data.draft = get().workflow.draft as WorkflowNode;
|
data.draft = get().workflow.draft as WorkflowNode;
|
||||||
}
|
}
|
||||||
const resp = await save(data);
|
const resp = await saveWorkflow(data);
|
||||||
set((state: WorkflowState) => {
|
set((state: WorkflowState) => {
|
||||||
return {
|
return {
|
||||||
workflow: {
|
workflow: {
|
||||||
@ -79,7 +80,7 @@ export const useWorkflowStore = create<WorkflowState>((set, get) => ({
|
|||||||
switchEnable: async () => {
|
switchEnable: async () => {
|
||||||
const root = get().workflow.draft as WorkflowNode;
|
const root = get().workflow.draft as WorkflowNode;
|
||||||
const executeMethod = getExecuteMethod(root);
|
const executeMethod = getExecuteMethod(root);
|
||||||
const resp = await save({
|
const resp = await saveWorkflow({
|
||||||
id: (get().workflow.id as string) ?? "",
|
id: (get().workflow.id as string) ?? "",
|
||||||
content: root,
|
content: root,
|
||||||
enabled: !get().workflow.enabled,
|
enabled: !get().workflow.enabled,
|
||||||
@ -104,7 +105,7 @@ export const useWorkflowStore = create<WorkflowState>((set, get) => ({
|
|||||||
save: async () => {
|
save: async () => {
|
||||||
const root = get().workflow.draft as WorkflowNode;
|
const root = get().workflow.draft as WorkflowNode;
|
||||||
const executeMethod = getExecuteMethod(root);
|
const executeMethod = getExecuteMethod(root);
|
||||||
const resp = await save({
|
const resp = await saveWorkflow({
|
||||||
id: (get().workflow.id as string) ?? "",
|
id: (get().workflow.id as string) ?? "",
|
||||||
content: root,
|
content: root,
|
||||||
hasDraft: false,
|
hasDraft: false,
|
||||||
@ -126,7 +127,7 @@ export const useWorkflowStore = create<WorkflowState>((set, get) => ({
|
|||||||
},
|
},
|
||||||
updateNode: async (node: WorkflowNode | WorkflowBranchNode) => {
|
updateNode: async (node: WorkflowNode | WorkflowBranchNode) => {
|
||||||
const newRoot = updateNode(get().workflow.draft as WorkflowNode, node);
|
const newRoot = updateNode(get().workflow.draft as WorkflowNode, node);
|
||||||
const resp = await save({
|
const resp = await saveWorkflow({
|
||||||
id: (get().workflow.id as string) ?? "",
|
id: (get().workflow.id as string) ?? "",
|
||||||
draft: newRoot,
|
draft: newRoot,
|
||||||
hasDraft: true,
|
hasDraft: true,
|
||||||
@ -144,7 +145,7 @@ export const useWorkflowStore = create<WorkflowState>((set, get) => ({
|
|||||||
},
|
},
|
||||||
addNode: async (node: WorkflowNode | WorkflowBranchNode, preId: string) => {
|
addNode: async (node: WorkflowNode | WorkflowBranchNode, preId: string) => {
|
||||||
const newRoot = addNode(get().workflow.draft as WorkflowNode, preId, node);
|
const newRoot = addNode(get().workflow.draft as WorkflowNode, preId, node);
|
||||||
const resp = await save({
|
const resp = await saveWorkflow({
|
||||||
id: (get().workflow.id as string) ?? "",
|
id: (get().workflow.id as string) ?? "",
|
||||||
draft: newRoot,
|
draft: newRoot,
|
||||||
hasDraft: true,
|
hasDraft: true,
|
||||||
@ -162,7 +163,7 @@ export const useWorkflowStore = create<WorkflowState>((set, get) => ({
|
|||||||
},
|
},
|
||||||
addBranch: async (branchId: string) => {
|
addBranch: async (branchId: string) => {
|
||||||
const newRoot = addBranch(get().workflow.draft as WorkflowNode, branchId);
|
const newRoot = addBranch(get().workflow.draft as WorkflowNode, branchId);
|
||||||
const resp = await save({
|
const resp = await saveWorkflow({
|
||||||
id: (get().workflow.id as string) ?? "",
|
id: (get().workflow.id as string) ?? "",
|
||||||
draft: newRoot,
|
draft: newRoot,
|
||||||
hasDraft: true,
|
hasDraft: true,
|
||||||
@ -180,7 +181,7 @@ export const useWorkflowStore = create<WorkflowState>((set, get) => ({
|
|||||||
},
|
},
|
||||||
removeBranch: async (branchId: string, index: number) => {
|
removeBranch: async (branchId: string, index: number) => {
|
||||||
const newRoot = removeBranch(get().workflow.draft as WorkflowNode, branchId, index);
|
const newRoot = removeBranch(get().workflow.draft as WorkflowNode, branchId, index);
|
||||||
const resp = await save({
|
const resp = await saveWorkflow({
|
||||||
id: (get().workflow.id as string) ?? "",
|
id: (get().workflow.id as string) ?? "",
|
||||||
draft: newRoot,
|
draft: newRoot,
|
||||||
hasDraft: true,
|
hasDraft: true,
|
||||||
@ -198,7 +199,7 @@ export const useWorkflowStore = create<WorkflowState>((set, get) => ({
|
|||||||
},
|
},
|
||||||
removeNode: async (nodeId: string) => {
|
removeNode: async (nodeId: string) => {
|
||||||
const newRoot = removeNode(get().workflow.draft as WorkflowNode, nodeId);
|
const newRoot = removeNode(get().workflow.draft as WorkflowNode, nodeId);
|
||||||
const resp = await save({
|
const resp = await saveWorkflow({
|
||||||
id: (get().workflow.id as string) ?? "",
|
id: (get().workflow.id as string) ?? "",
|
||||||
draft: newRoot,
|
draft: newRoot,
|
||||||
hasDraft: true,
|
hasDraft: true,
|
Loading…
x
Reference in New Issue
Block a user