From a1fd792350ab0d04892e7321bee4c89d907116ff Mon Sep 17 00:00:00 2001 From: rizky Date: Wed, 14 Aug 2024 20:55:08 -0700 Subject: [PATCH] fix --- comps/ui/carousel.tsx | 260 -------------------------------- exports.tsx | 20 ++- modules.json | 53 +++++++ preset/profile/ButtonUpload.tsx | 6 - 4 files changed, 67 insertions(+), 272 deletions(-) delete mode 100755 comps/ui/carousel.tsx create mode 100644 modules.json diff --git a/comps/ui/carousel.tsx b/comps/ui/carousel.tsx deleted file mode 100755 index 7d51928..0000000 --- a/comps/ui/carousel.tsx +++ /dev/null @@ -1,260 +0,0 @@ -import * as React from "react" -import useEmblaCarousel, { - type UseEmblaCarouselType, -} from "embla-carousel-react" -import { ArrowLeft, ArrowRight } from "lucide-react" - -import { cn } from "@/utils" -import { Button } from "@/comps/ui/button" - -type CarouselApi = UseEmblaCarouselType[1] -type UseCarouselParameters = Parameters -type CarouselOptions = UseCarouselParameters[0] -type CarouselPlugin = UseCarouselParameters[1] - -type CarouselProps = { - opts?: CarouselOptions - plugins?: CarouselPlugin - orientation?: "horizontal" | "vertical" - setApi?: (api: CarouselApi) => void -} - -type CarouselContextProps = { - carouselRef: ReturnType[0] - api: ReturnType[1] - scrollPrev: () => void - scrollNext: () => void - canScrollPrev: boolean - canScrollNext: boolean -} & CarouselProps - -const CarouselContext = React.createContext(null) - -function useCarousel() { - const context = React.useContext(CarouselContext) - - if (!context) { - throw new Error("useCarousel must be used within a ") - } - - return context -} - -const Carousel = React.forwardRef< - HTMLDivElement, - React.HTMLAttributes & CarouselProps ->( - ( - { - orientation = "horizontal", - opts, - setApi, - plugins, - className, - children, - ...props - }, - ref - ) => { - const [carouselRef, api] = useEmblaCarousel( - { - ...opts, - axis: orientation === "horizontal" ? "x" : "y", - }, - plugins - ) - const [canScrollPrev, setCanScrollPrev] = React.useState(false) - const [canScrollNext, setCanScrollNext] = React.useState(false) - - const onSelect = React.useCallback((api: CarouselApi) => { - if (!api) { - return - } - - setCanScrollPrev(api.canScrollPrev()) - setCanScrollNext(api.canScrollNext()) - }, []) - - const scrollPrev = React.useCallback(() => { - api?.scrollPrev() - }, [api]) - - const scrollNext = React.useCallback(() => { - api?.scrollNext() - }, [api]) - - const handleKeyDown = React.useCallback( - (event: React.KeyboardEvent) => { - if (event.key === "ArrowLeft") { - event.preventDefault() - scrollPrev() - } else if (event.key === "ArrowRight") { - event.preventDefault() - scrollNext() - } - }, - [scrollPrev, scrollNext] - ) - - React.useEffect(() => { - if (!api || !setApi) { - return - } - - setApi(api) - }, [api, setApi]) - - React.useEffect(() => { - if (!api) { - return - } - - onSelect(api) - api.on("reInit", onSelect) - api.on("select", onSelect) - - return () => { - api?.off("select", onSelect) - } - }, [api, onSelect]) - - return ( - -
- {children} -
-
- ) - } -) -Carousel.displayName = "Carousel" - -const CarouselContent = React.forwardRef< - HTMLDivElement, - React.HTMLAttributes ->(({ className, ...props }, ref) => { - const { carouselRef, orientation } = useCarousel() - - return ( -
-
-
- ) -}) -CarouselContent.displayName = "CarouselContent" - -const CarouselItem = React.forwardRef< - HTMLDivElement, - React.HTMLAttributes ->(({ className, ...props }, ref) => { - const { orientation } = useCarousel() - - return ( -
- ) -}) -CarouselItem.displayName = "CarouselItem" - -const CarouselPrevious = React.forwardRef< - HTMLButtonElement, - React.ComponentProps ->(({ className, variant = "outline", size = "icon", ...props }, ref) => { - const { orientation, scrollPrev, canScrollPrev } = useCarousel() - - return ( - - ) -}) -CarouselPrevious.displayName = "CarouselPrevious" - -const CarouselNext = React.forwardRef< - HTMLButtonElement, - React.ComponentProps ->(({ className, variant = "outline", size = "icon", ...props }, ref) => { - const { orientation, scrollNext, canScrollNext } = useCarousel() - - return ( - - ) -}) -CarouselNext.displayName = "CarouselNext" - -export { - type CarouselApi, - Carousel, - CarouselContent, - CarouselItem, - CarouselPrevious, - CarouselNext, -} diff --git a/exports.tsx b/exports.tsx index 3429425..ed9bdea 100755 --- a/exports.tsx +++ b/exports.tsx @@ -6,7 +6,7 @@ import { lazify, lazifyMany } from "@/utils/lazify"; import __get from "lodash.get"; import { sum } from "./utils/sum"; -export const _sum = sum; +export const _sum = sum; export const _get = __get; export const Accordion = lazify( @@ -19,7 +19,7 @@ export const Popover = lazify( export const Progress = lazify( async () => (await import("@/comps/ui/progress")).Progress ); - + export const Dialog = lazify( async () => (await import("@/comps/ui/dialog")).Dialog ); @@ -87,10 +87,18 @@ export const HeaderProfile = lazify( ); /** charts */ -export { BarChart } from "@/comps/charts/bar"; -export { PieChart } from "@/comps/charts/pie"; -export { DoughnutChart } from "@/comps/charts/doughnut"; -export { LineChart } from "@/comps/charts/line"; +export const BarChart = lazify( + async () => (await import("@/comps/charts/bar")).BarChart +); +export const PieChart = lazify( + async () => (await import("@/comps/charts/pie")).PieChart +); +export const DoughnutChart = lazify( + async () => (await import("@/comps/charts/doughnut")).DoughnutChart +); +export const LineChart = lazify( + async () => (await import("@/comps/charts/line")).LineChart +); /** Generator */ export { generateFilter as genereteFilter } from "@/comps/filter/gen/gen-filter"; diff --git a/modules.json b/modules.json new file mode 100644 index 0000000..ce5d354 --- /dev/null +++ b/modules.json @@ -0,0 +1,53 @@ +{ + "dependencies": { + "@floating-ui/react": "^0.26.12", + "@hookform/resolvers": "^3.3.4", + "@paralleldrive/cuid2": "^2.2.2", + "@prisma/client": "^5.13.0", + "@radix-ui/react-alert-dialog": "^1.1.1", + "@radix-ui/react-dialog": "^1.1.1", + "@radix-ui/react-dropdown-menu": "^2.1.1", + "@radix-ui/react-label": "^2.0.2", + "@radix-ui/react-navigation-menu": "^1.2.0", + "@radix-ui/react-popover": "^1.0.7", + "@radix-ui/react-progress": "^1.1.0", + "@radix-ui/react-scroll-area": "^1.1.0", + "@radix-ui/react-slider": "^1.1.2", + "@radix-ui/react-slot": "^1.0.2", + "@radix-ui/react-switch": "^1.1.0", + "@radix-ui/react-tabs": "^1.0.4", + "@types/autosize": "^4.0.3", + "@types/lodash.capitalize": "^4.2.9", + "@types/lodash.get": "^4.4.9", + "@types/react": "^18.2.65", + "@types/react-dom": "^18.3.0", + "@types/uuid": "^9.0.8", + "@wojtekmaj/react-qr-svg": "^1.0.0", + "any-date-parser": "^1.5.4", + "autosize": "^6.0.1", + "class-variance-authority": "^0.7.0", + "clsx": "^2.1.0", + "date-fns": "^3.3.1", + "dayjs": "^1.11.11", + "embla-carousel-react": "^8.0.2", + "lodash.capitalize": "^4.2.1", + "lodash.get": "^4.4.2", + "lucide-react": "^0.418.0", + "next-themes": "^0.3.0", + "prisma": "^5.13.0", + "quill": "^2.0.2", + "react": "^18.2.0", + "react-arborist": "^3.4.0", + "react-chartjs-2": "^5.2.0", + "react-data-grid": "^7.0.0-beta.43", + "react-dom": "^18.2.0", + "react-hook-form": "^7.51.0", + "react-resizable-panels": "^2.0.11", + "read-excel-file": "^5.7.1", + "sonner": "^1.4.41", + "tailwind-merge": "^2.2.1", + "tailwindcss-animate": "^1.0.7", + "uuid": "^9.0.1", + "xlsx": "npm:@e965/xlsx" + } +} diff --git a/preset/profile/ButtonUpload.tsx b/preset/profile/ButtonUpload.tsx index 827cb1d..cb8121a 100755 --- a/preset/profile/ButtonUpload.tsx +++ b/preset/profile/ButtonUpload.tsx @@ -68,9 +68,3 @@ export const ButtonUpload: FC<{
); }; -const formatMoney = (res: number) => { - const formattedAmount = new Intl.NumberFormat("id-ID", { - minimumFractionDigits: 0, - }).format(res); - return formattedAmount; -};