@edgedev/create-edge-app 1.0.40 → 1.0.42
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/.env.dev +1 -0
- package/.vscode/settings.json +1 -1
- package/app.vue +72 -21
- package/assets/css/tailwind.css +78 -0
- package/bin/cli.js +1 -1
- package/components/subToolbar.vue +4 -13
- package/components/ui/accordion/Accordion.vue +19 -0
- package/components/ui/accordion/AccordionContent.vue +24 -0
- package/components/ui/accordion/AccordionItem.vue +24 -0
- package/components/ui/accordion/AccordionTrigger.vue +39 -0
- package/components/ui/accordion/index.js +4 -0
- package/components/ui/accordion/index.ts +4 -0
- package/components/ui/alert/Alert.vue +16 -0
- package/components/ui/alert/AlertDescription.vue +14 -0
- package/components/ui/alert/AlertTitle.vue +14 -0
- package/components/ui/alert/index.js +21 -0
- package/components/ui/alert/index.ts +23 -0
- package/components/ui/alert-dialog/AlertDialog.vue +14 -0
- package/components/ui/alert-dialog/AlertDialogAction.vue +20 -0
- package/components/ui/alert-dialog/AlertDialogCancel.vue +20 -0
- package/components/ui/alert-dialog/AlertDialogContent.vue +42 -0
- package/components/ui/alert-dialog/AlertDialogDescription.vue +25 -0
- package/components/ui/alert-dialog/AlertDialogFooter.vue +21 -0
- package/components/ui/alert-dialog/AlertDialogHeader.vue +16 -0
- package/components/ui/alert-dialog/AlertDialogTitle.vue +22 -0
- package/components/ui/alert-dialog/AlertDialogTrigger.vue +11 -0
- package/components/ui/alert-dialog/index.ts +9 -0
- package/components/ui/aspect-ratio/AspectRatio.vue +11 -0
- package/components/ui/aspect-ratio/index.ts +1 -0
- package/components/ui/auto-form/AutoForm.vue +105 -0
- package/components/ui/auto-form/AutoFormField.vue +45 -0
- package/components/ui/auto-form/AutoFormFieldArray.vue +110 -0
- package/components/ui/auto-form/AutoFormFieldBoolean.vue +41 -0
- package/components/ui/auto-form/AutoFormFieldDate.vue +57 -0
- package/components/ui/auto-form/AutoFormFieldEnum.vue +49 -0
- package/components/ui/auto-form/AutoFormFieldFile.vue +74 -0
- package/components/ui/auto-form/AutoFormFieldInput.vue +36 -0
- package/components/ui/auto-form/AutoFormFieldNumber.vue +32 -0
- package/components/ui/auto-form/AutoFormFieldObject.vue +78 -0
- package/components/ui/auto-form/AutoFormLabel.vue +14 -0
- package/components/ui/auto-form/constant.ts +39 -0
- package/components/ui/auto-form/dependencies.ts +92 -0
- package/components/ui/auto-form/index.ts +15 -0
- package/components/ui/auto-form/interface.ts +81 -0
- package/components/ui/auto-form/utils.ts +171 -0
- package/components/ui/avatar/Avatar.vue +21 -0
- package/components/ui/avatar/AvatarFallback.vue +11 -0
- package/components/ui/avatar/AvatarImage.vue +9 -0
- package/components/ui/avatar/index.ts +24 -0
- package/components/ui/badge/Badge.vue +16 -0
- package/components/ui/badge/index.ts +25 -0
- package/components/ui/breadcrumb/Breadcrumb.vue +13 -0
- package/components/ui/breadcrumb/BreadcrumbEllipsis.vue +22 -0
- package/components/ui/breadcrumb/BreadcrumbItem.vue +16 -0
- package/components/ui/breadcrumb/BreadcrumbLink.vue +19 -0
- package/components/ui/breadcrumb/BreadcrumbList.vue +16 -0
- package/components/ui/breadcrumb/BreadcrumbPage.vue +19 -0
- package/components/ui/breadcrumb/BreadcrumbSeparator.vue +21 -0
- package/components/ui/breadcrumb/index.ts +7 -0
- package/components/ui/button/Button.vue +26 -0
- package/components/ui/button/index.js +33 -0
- package/components/ui/button/index.ts +35 -0
- package/components/ui/calendar/Calendar.vue +60 -0
- package/components/ui/calendar/CalendarCell.vue +24 -0
- package/components/ui/calendar/CalendarCellTrigger.vue +38 -0
- package/components/ui/calendar/CalendarGrid.vue +24 -0
- package/components/ui/calendar/CalendarGridBody.vue +11 -0
- package/components/ui/calendar/CalendarGridHead.vue +11 -0
- package/components/ui/calendar/CalendarGridRow.vue +21 -0
- package/components/ui/calendar/CalendarHeadCell.vue +21 -0
- package/components/ui/calendar/CalendarHeader.vue +21 -0
- package/components/ui/calendar/CalendarHeading.vue +27 -0
- package/components/ui/calendar/CalendarNextButton.vue +32 -0
- package/components/ui/calendar/CalendarPrevButton.vue +32 -0
- package/components/ui/calendar/index.ts +12 -0
- package/components/ui/card/Card.vue +21 -0
- package/components/ui/card/CardContent.vue +14 -0
- package/components/ui/card/CardDescription.vue +14 -0
- package/components/ui/card/CardFooter.vue +14 -0
- package/components/ui/card/CardHeader.vue +14 -0
- package/components/ui/card/CardTitle.vue +18 -0
- package/components/ui/card/index.js +6 -0
- package/components/ui/card/index.ts +6 -0
- package/components/ui/carousel/Carousel.vue +44 -0
- package/components/ui/carousel/CarouselContent.vue +29 -0
- package/components/ui/carousel/CarouselItem.vue +23 -0
- package/components/ui/carousel/CarouselNext.vue +30 -0
- package/components/ui/carousel/CarouselPrevious.vue +30 -0
- package/components/ui/carousel/index.ts +10 -0
- package/components/ui/carousel/interface.ts +20 -0
- package/components/ui/carousel/useCarousel.ts +59 -0
- package/components/ui/chart/ChartCrosshair.vue +44 -0
- package/components/ui/chart/ChartLegend.vue +50 -0
- package/components/ui/chart/ChartSingleTooltip.vue +63 -0
- package/components/ui/chart/ChartTooltip.vue +40 -0
- package/components/ui/chart/index.ts +18 -0
- package/components/ui/chart/interface.ts +64 -0
- package/components/ui/chart-area/AreaChart.vue +136 -0
- package/components/ui/chart-area/index.ts +66 -0
- package/components/ui/chart-bar/BarChart.vue +115 -0
- package/components/ui/chart-bar/index.ts +66 -0
- package/components/ui/chart-donut/DonutChart.vue +100 -0
- package/components/ui/chart-donut/index.ts +39 -0
- package/components/ui/chart-line/LineChart.vue +105 -0
- package/components/ui/chart-line/index.ts +66 -0
- package/components/ui/checkbox/Checkbox.vue +33 -0
- package/components/ui/checkbox/index.ts +1 -0
- package/components/ui/collapsible/Collapsible.vue +15 -0
- package/components/ui/collapsible/CollapsibleContent.vue +11 -0
- package/components/ui/collapsible/CollapsibleTrigger.vue +11 -0
- package/components/ui/collapsible/index.ts +3 -0
- package/components/ui/command/Command.vue +30 -0
- package/components/ui/command/CommandDialog.vue +21 -0
- package/components/ui/command/CommandEmpty.vue +20 -0
- package/components/ui/command/CommandGroup.vue +29 -0
- package/components/ui/command/CommandInput.vue +33 -0
- package/components/ui/command/CommandItem.vue +26 -0
- package/components/ui/command/CommandList.vue +27 -0
- package/components/ui/command/CommandSeparator.vue +23 -0
- package/components/ui/command/CommandShortcut.vue +14 -0
- package/components/ui/command/index.js +9 -0
- package/components/ui/command/index.ts +9 -0
- package/components/ui/context-menu/ContextMenu.vue +15 -0
- package/components/ui/context-menu/ContextMenuCheckboxItem.vue +40 -0
- package/components/ui/context-menu/ContextMenuContent.vue +36 -0
- package/components/ui/context-menu/ContextMenuGroup.vue +11 -0
- package/components/ui/context-menu/ContextMenuItem.vue +34 -0
- package/components/ui/context-menu/ContextMenuLabel.vue +25 -0
- package/components/ui/context-menu/ContextMenuPortal.vue +11 -0
- package/components/ui/context-menu/ContextMenuRadioGroup.vue +19 -0
- package/components/ui/context-menu/ContextMenuRadioItem.vue +40 -0
- package/components/ui/context-menu/ContextMenuSeparator.vue +20 -0
- package/components/ui/context-menu/ContextMenuShortcut.vue +14 -0
- package/components/ui/context-menu/ContextMenuSub.vue +19 -0
- package/components/ui/context-menu/ContextMenuSubContent.vue +35 -0
- package/components/ui/context-menu/ContextMenuSubTrigger.vue +34 -0
- package/components/ui/context-menu/ContextMenuTrigger.vue +13 -0
- package/components/ui/context-menu/index.ts +14 -0
- package/components/ui/dialog/Dialog.vue +14 -0
- package/components/ui/dialog/DialogClose.vue +11 -0
- package/components/ui/dialog/DialogContent.vue +50 -0
- package/components/ui/dialog/DialogDescription.vue +24 -0
- package/components/ui/dialog/DialogFooter.vue +19 -0
- package/components/ui/dialog/DialogHeader.vue +16 -0
- package/components/ui/dialog/DialogScrollContent.vue +59 -0
- package/components/ui/dialog/DialogTitle.vue +29 -0
- package/components/ui/dialog/DialogTrigger.vue +11 -0
- package/components/ui/dialog/index.js +9 -0
- package/components/ui/dialog/index.ts +9 -0
- package/components/ui/drawer/Drawer.vue +19 -0
- package/components/ui/drawer/DrawerContent.vue +28 -0
- package/components/ui/drawer/DrawerDescription.vue +20 -0
- package/components/ui/drawer/DrawerFooter.vue +14 -0
- package/components/ui/drawer/DrawerHeader.vue +14 -0
- package/components/ui/drawer/DrawerOverlay.vue +18 -0
- package/components/ui/drawer/DrawerTitle.vue +20 -0
- package/components/ui/drawer/index.ts +8 -0
- package/components/ui/dropdown-menu/DropdownMenu.vue +14 -0
- package/components/ui/dropdown-menu/DropdownMenuCheckboxItem.vue +40 -0
- package/components/ui/dropdown-menu/DropdownMenuContent.vue +38 -0
- package/components/ui/dropdown-menu/DropdownMenuGroup.vue +11 -0
- package/components/ui/dropdown-menu/DropdownMenuItem.vue +28 -0
- package/components/ui/dropdown-menu/DropdownMenuLabel.vue +24 -0
- package/components/ui/dropdown-menu/DropdownMenuRadioGroup.vue +19 -0
- package/components/ui/dropdown-menu/DropdownMenuRadioItem.vue +41 -0
- package/components/ui/dropdown-menu/DropdownMenuSeparator.vue +22 -0
- package/components/ui/dropdown-menu/DropdownMenuShortcut.vue +14 -0
- package/components/ui/dropdown-menu/DropdownMenuSub.vue +19 -0
- package/components/ui/dropdown-menu/DropdownMenuSubContent.vue +30 -0
- package/components/ui/dropdown-menu/DropdownMenuSubTrigger.vue +33 -0
- package/components/ui/dropdown-menu/DropdownMenuTrigger.vue +13 -0
- package/components/ui/dropdown-menu/index.ts +16 -0
- package/components/ui/form/FormControl.vue +16 -0
- package/components/ui/form/FormDescription.vue +20 -0
- package/components/ui/form/FormItem.vue +19 -0
- package/components/ui/form/FormLabel.vue +23 -0
- package/components/ui/form/FormMessage.vue +16 -0
- package/components/ui/form/index.js +7 -0
- package/components/ui/form/index.ts +7 -0
- package/components/ui/form/injectionKeys.js +1 -0
- package/components/ui/form/injectionKeys.ts +4 -0
- package/components/ui/form/useFormField.js +36 -0
- package/components/ui/form/useFormField.ts +30 -0
- package/components/ui/hover-card/HoverCard.vue +14 -0
- package/components/ui/hover-card/HoverCardContent.vue +41 -0
- package/components/ui/hover-card/HoverCardTrigger.vue +11 -0
- package/components/ui/hover-card/index.ts +3 -0
- package/components/ui/input/Input.vue +24 -0
- package/components/ui/input/index.js +1 -0
- package/components/ui/input/index.ts +1 -0
- package/components/ui/label/Label.vue +27 -0
- package/components/ui/label/index.js +1 -0
- package/components/ui/label/index.ts +1 -0
- package/components/ui/menubar/Menubar.vue +35 -0
- package/components/ui/menubar/MenubarCheckboxItem.vue +40 -0
- package/components/ui/menubar/MenubarContent.vue +43 -0
- package/components/ui/menubar/MenubarGroup.vue +11 -0
- package/components/ui/menubar/MenubarItem.vue +35 -0
- package/components/ui/menubar/MenubarLabel.vue +13 -0
- package/components/ui/menubar/MenubarMenu.vue +11 -0
- package/components/ui/menubar/MenubarRadioGroup.vue +20 -0
- package/components/ui/menubar/MenubarRadioItem.vue +40 -0
- package/components/ui/menubar/MenubarSeparator.vue +19 -0
- package/components/ui/menubar/MenubarShortcut.vue +14 -0
- package/components/ui/menubar/MenubarSub.vue +19 -0
- package/components/ui/menubar/MenubarSubContent.vue +39 -0
- package/components/ui/menubar/MenubarSubTrigger.vue +30 -0
- package/components/ui/menubar/MenubarTrigger.vue +29 -0
- package/components/ui/menubar/index.ts +15 -0
- package/components/ui/navigation-menu/NavigationMenu.vue +33 -0
- package/components/ui/navigation-menu/NavigationMenuContent.vue +34 -0
- package/components/ui/navigation-menu/NavigationMenuIndicator.vue +24 -0
- package/components/ui/navigation-menu/NavigationMenuItem.vue +11 -0
- package/components/ui/navigation-menu/NavigationMenuLink.vue +19 -0
- package/components/ui/navigation-menu/NavigationMenuList.vue +29 -0
- package/components/ui/navigation-menu/NavigationMenuTrigger.vue +34 -0
- package/components/ui/navigation-menu/NavigationMenuViewport.vue +33 -0
- package/components/ui/navigation-menu/index.ts +12 -0
- package/components/ui/number-field/NumberField.vue +23 -0
- package/components/ui/number-field/NumberFieldContent.vue +14 -0
- package/components/ui/number-field/NumberFieldDecrement.vue +25 -0
- package/components/ui/number-field/NumberFieldIncrement.vue +25 -0
- package/components/ui/number-field/NumberFieldInput.vue +8 -0
- package/components/ui/number-field/index.ts +5 -0
- package/components/ui/pagination/PaginationEllipsis.vue +22 -0
- package/components/ui/pagination/PaginationFirst.vue +29 -0
- package/components/ui/pagination/PaginationLast.vue +29 -0
- package/components/ui/pagination/PaginationNext.vue +29 -0
- package/components/ui/pagination/PaginationPrev.vue +29 -0
- package/components/ui/pagination/index.ts +10 -0
- package/components/ui/pin-input/PinInput.vue +23 -0
- package/components/ui/pin-input/PinInputGroup.vue +18 -0
- package/components/ui/pin-input/PinInputInput.vue +18 -0
- package/components/ui/pin-input/PinInputSeparator.vue +15 -0
- package/components/ui/pin-input/index.ts +4 -0
- package/components/ui/popover/Popover.vue +15 -0
- package/components/ui/popover/PopoverContent.vue +48 -0
- package/components/ui/popover/PopoverTrigger.vue +11 -0
- package/components/ui/popover/index.js +3 -0
- package/components/ui/popover/index.ts +3 -0
- package/components/ui/progress/Progress.vue +39 -0
- package/components/ui/progress/index.js +1 -0
- package/components/ui/progress/index.ts +1 -0
- package/components/ui/radio-group/RadioGroup.vue +25 -0
- package/components/ui/radio-group/RadioGroupItem.vue +39 -0
- package/components/ui/radio-group/index.ts +2 -0
- package/components/ui/range-calendar/RangeCalendar.vue +60 -0
- package/components/ui/range-calendar/RangeCalendarCell.vue +24 -0
- package/components/ui/range-calendar/RangeCalendarCellTrigger.vue +40 -0
- package/components/ui/range-calendar/RangeCalendarGrid.vue +24 -0
- package/components/ui/range-calendar/RangeCalendarGridBody.vue +11 -0
- package/components/ui/range-calendar/RangeCalendarGridHead.vue +11 -0
- package/components/ui/range-calendar/RangeCalendarGridRow.vue +21 -0
- package/components/ui/range-calendar/RangeCalendarHeadCell.vue +21 -0
- package/components/ui/range-calendar/RangeCalendarHeader.vue +21 -0
- package/components/ui/range-calendar/RangeCalendarHeading.vue +27 -0
- package/components/ui/range-calendar/RangeCalendarNextButton.vue +32 -0
- package/components/ui/range-calendar/RangeCalendarPrevButton.vue +32 -0
- package/components/ui/range-calendar/index.ts +12 -0
- package/components/ui/resizable/ResizableHandle.vue +26 -0
- package/components/ui/resizable/ResizablePanelGroup.vue +21 -0
- package/components/ui/resizable/index.ts +3 -0
- package/components/ui/scroll-area/ScrollArea.vue +29 -0
- package/components/ui/scroll-area/ScrollBar.vue +30 -0
- package/components/ui/scroll-area/index.ts +2 -0
- package/components/ui/select/Select.vue +15 -0
- package/components/ui/select/SelectContent.vue +53 -0
- package/components/ui/select/SelectGroup.vue +19 -0
- package/components/ui/select/SelectItem.vue +44 -0
- package/components/ui/select/SelectItemText.vue +11 -0
- package/components/ui/select/SelectLabel.vue +13 -0
- package/components/ui/select/SelectScrollDownButton.vue +24 -0
- package/components/ui/select/SelectScrollUpButton.vue +24 -0
- package/components/ui/select/SelectSeparator.vue +17 -0
- package/components/ui/select/SelectTrigger.vue +31 -0
- package/components/ui/select/SelectValue.vue +11 -0
- package/components/ui/select/index.ts +11 -0
- package/components/ui/separator/Separator.vue +20 -0
- package/components/ui/separator/index.js +1 -0
- package/components/ui/separator/index.ts +1 -0
- package/components/ui/sheet/Sheet.vue +14 -0
- package/components/ui/sheet/SheetClose.vue +11 -0
- package/components/ui/sheet/SheetContent.vue +56 -0
- package/components/ui/sheet/SheetDescription.vue +22 -0
- package/components/ui/sheet/SheetFooter.vue +19 -0
- package/components/ui/sheet/SheetHeader.vue +16 -0
- package/components/ui/sheet/SheetTitle.vue +22 -0
- package/components/ui/sheet/SheetTrigger.vue +11 -0
- package/components/ui/sheet/index.ts +31 -0
- package/components/ui/skeleton/Skeleton.vue +14 -0
- package/components/ui/skeleton/index.ts +1 -0
- package/components/ui/slider/Slider.vue +36 -0
- package/components/ui/slider/index.ts +1 -0
- package/components/ui/sonner/Sonner.vue +22 -0
- package/components/ui/sonner/index.ts +1 -0
- package/components/ui/switch/Switch.vue +37 -0
- package/components/ui/switch/index.ts +1 -0
- package/components/ui/table/Table.vue +16 -0
- package/components/ui/table/TableBody.vue +14 -0
- package/components/ui/table/TableCaption.vue +14 -0
- package/components/ui/table/TableCell.vue +21 -0
- package/components/ui/table/TableEmpty.vue +37 -0
- package/components/ui/table/TableFooter.vue +14 -0
- package/components/ui/table/TableHead.vue +14 -0
- package/components/ui/table/TableHeader.vue +14 -0
- package/components/ui/table/TableRow.vue +14 -0
- package/components/ui/table/index.ts +8 -0
- package/components/ui/tabs/Tabs.vue +15 -0
- package/components/ui/tabs/TabsContent.vue +22 -0
- package/components/ui/tabs/TabsList.vue +25 -0
- package/components/ui/tabs/TabsTrigger.vue +27 -0
- package/components/ui/tabs/index.ts +4 -0
- package/components/ui/tags-input/TagsInput.vue +22 -0
- package/components/ui/tags-input/TagsInputInput.vue +19 -0
- package/components/ui/tags-input/TagsInputItem.vue +22 -0
- package/components/ui/tags-input/TagsInputItemDelete.vue +24 -0
- package/components/ui/tags-input/TagsInputItemText.vue +19 -0
- package/components/ui/tags-input/index.ts +5 -0
- package/components/ui/textarea/Textarea.vue +24 -0
- package/components/ui/textarea/index.ts +1 -0
- package/components/ui/toast/Toast.vue +28 -0
- package/components/ui/toast/ToastAction.vue +19 -0
- package/components/ui/toast/ToastClose.vue +22 -0
- package/components/ui/toast/ToastDescription.vue +19 -0
- package/components/ui/toast/ToastProvider.vue +11 -0
- package/components/ui/toast/ToastTitle.vue +19 -0
- package/components/ui/toast/ToastViewport.vue +17 -0
- package/components/ui/toast/Toaster.vue +30 -0
- package/components/ui/toast/index.ts +38 -0
- package/components/ui/toast/use-toast.ts +165 -0
- package/components/ui/toggle/Toggle.vue +35 -0
- package/components/ui/toggle/index.ts +27 -0
- package/components/ui/toggle-group/ToggleGroup.vue +34 -0
- package/components/ui/toggle-group/ToggleGroupItem.vue +35 -0
- package/components/ui/toggle-group/index.ts +2 -0
- package/components/ui/tooltip/Tooltip.vue +14 -0
- package/components/ui/tooltip/TooltipContent.vue +31 -0
- package/components/ui/tooltip/TooltipProvider.vue +11 -0
- package/components/ui/tooltip/TooltipTrigger.vue +11 -0
- package/components/ui/tooltip/index.ts +4 -0
- package/components/ui/v-calendar/Calendar.vue +331 -0
- package/components/ui/v-calendar/index.ts +22 -0
- package/components.json +17 -0
- package/edge-components-install.sh +1 -0
- package/jsconfig.json +9 -0
- package/lib/utils.ts +6 -0
- package/nuxt.config.ts +28 -11
- package/package.json +33 -14
- package/pages/app/account/[page].vue +71 -0
- package/pages/app/dashboard/[[collection]]/[[docId]].vue +181 -0
- package/pages/app/login.vue +9 -7
- package/pages/app/signup.vue +9 -7
- package/plugins/icons.ts +72 -0
- package/tailwind.config.js +85 -0
- package/components/.gitkeep +0 -0
- package/components/account.vue +0 -101
- package/components/billing.vue +0 -8
- package/components/bottomMenu.vue +0 -35
- package/components/dashboard.vue +0 -186
- package/components/editor.vue +0 -247
- package/components/topMenu.vue +0 -17
- package/components/userMenu.vue +0 -64
- package/composables/vuetify.ts +0 -10
- package/pages/app/[[page]]/[[collection]]/[[docId]].vue +0 -48
- package/plugins/edgeFirebaseFramework.ts +0 -5
- package/plugins/vuetify.ts +0 -14
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { AlertDialogTrigger, type AlertDialogTriggerProps } from 'radix-vue'
|
|
3
|
+
|
|
4
|
+
const props = defineProps<AlertDialogTriggerProps>()
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<template>
|
|
8
|
+
<AlertDialogTrigger v-bind="props">
|
|
9
|
+
<slot />
|
|
10
|
+
</AlertDialogTrigger>
|
|
11
|
+
</template>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { default as AlertDialog } from './AlertDialog.vue'
|
|
2
|
+
export { default as AlertDialogTrigger } from './AlertDialogTrigger.vue'
|
|
3
|
+
export { default as AlertDialogContent } from './AlertDialogContent.vue'
|
|
4
|
+
export { default as AlertDialogHeader } from './AlertDialogHeader.vue'
|
|
5
|
+
export { default as AlertDialogTitle } from './AlertDialogTitle.vue'
|
|
6
|
+
export { default as AlertDialogDescription } from './AlertDialogDescription.vue'
|
|
7
|
+
export { default as AlertDialogFooter } from './AlertDialogFooter.vue'
|
|
8
|
+
export { default as AlertDialogAction } from './AlertDialogAction.vue'
|
|
9
|
+
export { default as AlertDialogCancel } from './AlertDialogCancel.vue'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as AspectRatio } from './AspectRatio.vue'
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
<script setup lang="ts" generic="T extends ZodObjectOrWrapped">
|
|
2
|
+
import { computed, toRefs } from 'vue'
|
|
3
|
+
import type { ZodAny, z } from 'zod'
|
|
4
|
+
import { toTypedSchema } from '@vee-validate/zod'
|
|
5
|
+
import type { FormContext, GenericObject } from 'vee-validate'
|
|
6
|
+
import { type ZodObjectOrWrapped, getBaseSchema, getBaseType, getDefaultValueInZodStack, getObjectFormSchema } from './utils'
|
|
7
|
+
import type { Config, ConfigItem, Dependency, Shape } from './interface'
|
|
8
|
+
import AutoFormField from './AutoFormField.vue'
|
|
9
|
+
import { provideDependencies } from './dependencies'
|
|
10
|
+
import { Form } from '@/components/ui/form'
|
|
11
|
+
|
|
12
|
+
const props = defineProps<{
|
|
13
|
+
schema: T
|
|
14
|
+
form?: FormContext<GenericObject>
|
|
15
|
+
fieldConfig?: Config<z.infer<T>>
|
|
16
|
+
dependencies?: Dependency<z.infer<T>>[]
|
|
17
|
+
}>()
|
|
18
|
+
|
|
19
|
+
const emits = defineEmits<{
|
|
20
|
+
submit: [event: GenericObject]
|
|
21
|
+
}>()
|
|
22
|
+
|
|
23
|
+
const { dependencies } = toRefs(props)
|
|
24
|
+
provideDependencies(dependencies)
|
|
25
|
+
|
|
26
|
+
const shapes = computed(() => {
|
|
27
|
+
// @ts-expect-error ignore {} not assignable to object
|
|
28
|
+
const val: { [key in keyof T]: Shape } = {}
|
|
29
|
+
const baseSchema = getObjectFormSchema(props.schema)
|
|
30
|
+
const shape = baseSchema.shape
|
|
31
|
+
Object.keys(shape).forEach((name) => {
|
|
32
|
+
const item = shape[name] as ZodAny
|
|
33
|
+
const baseItem = getBaseSchema(item) as ZodAny
|
|
34
|
+
let options = (baseItem && 'values' in baseItem._def) ? baseItem._def.values as string[] : undefined
|
|
35
|
+
if (!Array.isArray(options) && typeof options === 'object')
|
|
36
|
+
options = Object.values(options)
|
|
37
|
+
|
|
38
|
+
val[name as keyof T] = {
|
|
39
|
+
type: getBaseType(item),
|
|
40
|
+
default: getDefaultValueInZodStack(item),
|
|
41
|
+
options,
|
|
42
|
+
required: !['ZodOptional', 'ZodNullable'].includes(item._def.typeName),
|
|
43
|
+
schema: baseItem,
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
return val
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
const fields = computed(() => {
|
|
50
|
+
// @ts-expect-error ignore {} not assignable to object
|
|
51
|
+
const val: { [key in keyof z.infer<T>]: { shape: Shape, fieldName: string, config: ConfigItem } } = {}
|
|
52
|
+
for (const key in shapes.value) {
|
|
53
|
+
const shape = shapes.value[key]
|
|
54
|
+
val[key as keyof z.infer<T>] = {
|
|
55
|
+
shape,
|
|
56
|
+
config: props.fieldConfig?.[key] as ConfigItem,
|
|
57
|
+
fieldName: key,
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return val
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
const formComponent = computed(() => props.form ? 'form' : Form)
|
|
64
|
+
const formComponentProps = computed(() => {
|
|
65
|
+
if (props.form) {
|
|
66
|
+
return {
|
|
67
|
+
onSubmit: props.form.handleSubmit(val => emits('submit', val)),
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
const formSchema = toTypedSchema(props.schema)
|
|
72
|
+
return {
|
|
73
|
+
keepValues: true,
|
|
74
|
+
validationSchema: formSchema,
|
|
75
|
+
onSubmit: (val: GenericObject) => emits('submit', val),
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
})
|
|
79
|
+
</script>
|
|
80
|
+
|
|
81
|
+
<template>
|
|
82
|
+
<component
|
|
83
|
+
:is="formComponent"
|
|
84
|
+
v-bind="formComponentProps"
|
|
85
|
+
>
|
|
86
|
+
<slot name="customAutoForm" :fields="fields">
|
|
87
|
+
<template v-for="(shape, key) of shapes" :key="key">
|
|
88
|
+
<slot
|
|
89
|
+
:shape="shape"
|
|
90
|
+
:name="key.toString() as keyof z.infer<T>"
|
|
91
|
+
:field-name="key.toString()"
|
|
92
|
+
:config="fieldConfig?.[key as keyof typeof fieldConfig] as ConfigItem"
|
|
93
|
+
>
|
|
94
|
+
<AutoFormField
|
|
95
|
+
:config="fieldConfig?.[key as keyof typeof fieldConfig] as ConfigItem"
|
|
96
|
+
:field-name="key.toString()"
|
|
97
|
+
:shape="shape"
|
|
98
|
+
/>
|
|
99
|
+
</slot>
|
|
100
|
+
</template>
|
|
101
|
+
</slot>
|
|
102
|
+
|
|
103
|
+
<slot :shapes="shapes" />
|
|
104
|
+
</component>
|
|
105
|
+
</template>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<script setup lang="ts" generic="U extends ZodAny">
|
|
2
|
+
import type { ZodAny } from 'zod'
|
|
3
|
+
import { computed } from 'vue'
|
|
4
|
+
import type { Config, ConfigItem, Shape } from './interface'
|
|
5
|
+
import { DEFAULT_ZOD_HANDLERS, INPUT_COMPONENTS } from './constant'
|
|
6
|
+
import useDependencies from './dependencies'
|
|
7
|
+
|
|
8
|
+
const props = defineProps<{
|
|
9
|
+
fieldName: string
|
|
10
|
+
shape: Shape
|
|
11
|
+
config?: ConfigItem | Config<U>
|
|
12
|
+
}>()
|
|
13
|
+
|
|
14
|
+
function isValidConfig(config: any): config is ConfigItem {
|
|
15
|
+
return !!config?.component
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const delegatedProps = computed(() => {
|
|
19
|
+
if (['ZodObject', 'ZodArray'].includes(props.shape?.type))
|
|
20
|
+
return { schema: props.shape?.schema }
|
|
21
|
+
return undefined
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
const { isDisabled, isHidden, isRequired, overrideOptions } = useDependencies(props.fieldName)
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<template>
|
|
28
|
+
<component
|
|
29
|
+
:is="isValidConfig(config)
|
|
30
|
+
? typeof config.component === 'string'
|
|
31
|
+
? INPUT_COMPONENTS[config.component!]
|
|
32
|
+
: config.component
|
|
33
|
+
: INPUT_COMPONENTS[DEFAULT_ZOD_HANDLERS[shape.type]] "
|
|
34
|
+
v-if="!isHidden"
|
|
35
|
+
:field-name="fieldName"
|
|
36
|
+
:label="shape.schema?.description"
|
|
37
|
+
:required="isRequired || shape.required"
|
|
38
|
+
:options="overrideOptions || shape.options"
|
|
39
|
+
:disabled="isDisabled"
|
|
40
|
+
:config="config"
|
|
41
|
+
v-bind="delegatedProps"
|
|
42
|
+
>
|
|
43
|
+
<slot />
|
|
44
|
+
</component>
|
|
45
|
+
</template>
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
<script setup lang="ts" generic="T extends z.ZodAny">
|
|
2
|
+
import * as z from 'zod'
|
|
3
|
+
import { computed, provide } from 'vue'
|
|
4
|
+
import { PlusIcon, TrashIcon } from 'lucide-vue-next'
|
|
5
|
+
import { FieldArray, FieldContextKey, useField } from 'vee-validate'
|
|
6
|
+
import type { Config, ConfigItem } from './interface'
|
|
7
|
+
import { beautifyObjectName, getBaseType } from './utils'
|
|
8
|
+
import AutoFormField from './AutoFormField.vue'
|
|
9
|
+
import AutoFormLabel from './AutoFormLabel.vue'
|
|
10
|
+
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@/components/ui/accordion'
|
|
11
|
+
import { Button } from '@/components/ui/button'
|
|
12
|
+
import { Separator } from '@/components/ui/separator'
|
|
13
|
+
import { FormItem, FormMessage } from '@/components/ui/form'
|
|
14
|
+
|
|
15
|
+
const props = defineProps<{
|
|
16
|
+
fieldName: string
|
|
17
|
+
required?: boolean
|
|
18
|
+
config?: Config<T>
|
|
19
|
+
schema?: z.ZodArray<T>
|
|
20
|
+
disabled?: boolean
|
|
21
|
+
}>()
|
|
22
|
+
|
|
23
|
+
function isZodArray(
|
|
24
|
+
item: z.ZodArray<any> | z.ZodDefault<any>,
|
|
25
|
+
): item is z.ZodArray<any> {
|
|
26
|
+
return item instanceof z.ZodArray
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function isZodDefault(
|
|
30
|
+
item: z.ZodArray<any> | z.ZodDefault<any>,
|
|
31
|
+
): item is z.ZodDefault<any> {
|
|
32
|
+
return item instanceof z.ZodDefault
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const itemShape = computed(() => {
|
|
36
|
+
if (!props.schema)
|
|
37
|
+
return
|
|
38
|
+
|
|
39
|
+
const schema: z.ZodAny = isZodArray(props.schema)
|
|
40
|
+
? props.schema._def.type
|
|
41
|
+
: isZodDefault(props.schema)
|
|
42
|
+
// @ts-expect-error missing schema
|
|
43
|
+
? props.schema._def.innerType._def.type
|
|
44
|
+
: null
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
type: getBaseType(schema),
|
|
48
|
+
schema,
|
|
49
|
+
}
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
const fieldContext = useField(props.fieldName)
|
|
53
|
+
// @ts-expect-error ignore missing `id`
|
|
54
|
+
provide(FieldContextKey, fieldContext)
|
|
55
|
+
</script>
|
|
56
|
+
|
|
57
|
+
<template>
|
|
58
|
+
<FieldArray v-slot="{ fields, remove, push }" as="section" :name="fieldName">
|
|
59
|
+
<slot v-bind="props">
|
|
60
|
+
<Accordion type="multiple" class="w-full" collapsible :disabled="disabled" as-child>
|
|
61
|
+
<FormItem>
|
|
62
|
+
<AccordionItem :value="fieldName" class="border-none">
|
|
63
|
+
<AccordionTrigger>
|
|
64
|
+
<AutoFormLabel class="text-base" :required="required">
|
|
65
|
+
{{ schema?.description || beautifyObjectName(fieldName) }}
|
|
66
|
+
</AutoFormLabel>
|
|
67
|
+
</AccordionTrigger>
|
|
68
|
+
|
|
69
|
+
<AccordionContent>
|
|
70
|
+
<template v-for="(field, index) of fields" :key="field.key">
|
|
71
|
+
<div class="mb-4 p-1">
|
|
72
|
+
<AutoFormField
|
|
73
|
+
:field-name="`${fieldName}[${index}]`"
|
|
74
|
+
:label="fieldName"
|
|
75
|
+
:shape="itemShape!"
|
|
76
|
+
:config="config as ConfigItem"
|
|
77
|
+
/>
|
|
78
|
+
|
|
79
|
+
<div class="!my-4 flex justify-end">
|
|
80
|
+
<Button
|
|
81
|
+
type="button"
|
|
82
|
+
size="icon"
|
|
83
|
+
variant="secondary"
|
|
84
|
+
@click="remove(index)"
|
|
85
|
+
>
|
|
86
|
+
<TrashIcon :size="16" />
|
|
87
|
+
</Button>
|
|
88
|
+
</div>
|
|
89
|
+
<Separator v-if="!field.isLast" class="dark:bg-slate-600" />
|
|
90
|
+
</div>
|
|
91
|
+
</template>
|
|
92
|
+
|
|
93
|
+
<Button
|
|
94
|
+
type="button"
|
|
95
|
+
variant="secondary"
|
|
96
|
+
class="mt-4 flex items-center"
|
|
97
|
+
@click="push(null)"
|
|
98
|
+
>
|
|
99
|
+
<PlusIcon class="mr-2" :size="16" />
|
|
100
|
+
Add
|
|
101
|
+
</Button>
|
|
102
|
+
</AccordionContent>
|
|
103
|
+
|
|
104
|
+
<FormMessage />
|
|
105
|
+
</AccordionItem>
|
|
106
|
+
</FormItem>
|
|
107
|
+
</Accordion>
|
|
108
|
+
</slot>
|
|
109
|
+
</FieldArray>
|
|
110
|
+
</template>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from 'vue'
|
|
3
|
+
import { beautifyObjectName } from './utils'
|
|
4
|
+
import type { FieldProps } from './interface'
|
|
5
|
+
import AutoFormLabel from './AutoFormLabel.vue'
|
|
6
|
+
import { FormControl, FormDescription, FormField, FormItem, FormMessage } from '@/components/ui/form'
|
|
7
|
+
import { Switch } from '@/components/ui/switch'
|
|
8
|
+
import { Checkbox } from '@/components/ui/checkbox'
|
|
9
|
+
|
|
10
|
+
const props = defineProps<FieldProps>()
|
|
11
|
+
|
|
12
|
+
const booleanComponent = computed(() => props.config?.component === 'switch' ? Switch : Checkbox)
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<template>
|
|
16
|
+
<FormField v-slot="slotProps" :name="fieldName">
|
|
17
|
+
<FormItem>
|
|
18
|
+
<div class="space-y-0 mb-3 flex items-center gap-3">
|
|
19
|
+
<FormControl>
|
|
20
|
+
<slot v-bind="slotProps">
|
|
21
|
+
<component
|
|
22
|
+
:is="booleanComponent"
|
|
23
|
+
v-bind="{ ...slotProps.componentField }"
|
|
24
|
+
:disabled="disabled"
|
|
25
|
+
:checked="slotProps.componentField.modelValue"
|
|
26
|
+
@update:checked="slotProps.componentField['onUpdate:modelValue']"
|
|
27
|
+
/>
|
|
28
|
+
</slot>
|
|
29
|
+
</FormControl>
|
|
30
|
+
<AutoFormLabel v-if="!config?.hideLabel" :required="required">
|
|
31
|
+
{{ config?.label || beautifyObjectName(label ?? fieldName) }}
|
|
32
|
+
</AutoFormLabel>
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
<FormDescription v-if="config?.description">
|
|
36
|
+
{{ config.description }}
|
|
37
|
+
</FormDescription>
|
|
38
|
+
<FormMessage />
|
|
39
|
+
</FormItem>
|
|
40
|
+
</FormField>
|
|
41
|
+
</template>
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { DateFormatter, getLocalTimeZone } from '@internationalized/date'
|
|
3
|
+
import { CalendarIcon } from 'lucide-vue-next'
|
|
4
|
+
import { beautifyObjectName } from './utils'
|
|
5
|
+
import AutoFormLabel from './AutoFormLabel.vue'
|
|
6
|
+
import type { FieldProps } from './interface'
|
|
7
|
+
import { FormControl, FormDescription, FormField, FormItem, FormMessage } from '@/components/ui/form'
|
|
8
|
+
|
|
9
|
+
import { Calendar } from '@/components/ui/calendar'
|
|
10
|
+
import { Button } from '@/components/ui/button'
|
|
11
|
+
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover'
|
|
12
|
+
import { cn } from '@/lib/utils'
|
|
13
|
+
|
|
14
|
+
defineProps<FieldProps>()
|
|
15
|
+
|
|
16
|
+
const df = new DateFormatter('en-US', {
|
|
17
|
+
dateStyle: 'long',
|
|
18
|
+
})
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<template>
|
|
22
|
+
<FormField v-slot="slotProps" :name="fieldName">
|
|
23
|
+
<FormItem>
|
|
24
|
+
<AutoFormLabel v-if="!config?.hideLabel" :required="required">
|
|
25
|
+
{{ config?.label || beautifyObjectName(label ?? fieldName) }}
|
|
26
|
+
</AutoFormLabel>
|
|
27
|
+
<FormControl>
|
|
28
|
+
<slot v-bind="slotProps">
|
|
29
|
+
<div>
|
|
30
|
+
<Popover>
|
|
31
|
+
<PopoverTrigger as-child :disabled="disabled">
|
|
32
|
+
<Button
|
|
33
|
+
variant="outline"
|
|
34
|
+
:class="cn(
|
|
35
|
+
'w-full justify-start text-left font-normal',
|
|
36
|
+
!slotProps.componentField.modelValue && 'text-muted-foreground',
|
|
37
|
+
)"
|
|
38
|
+
>
|
|
39
|
+
<CalendarIcon class="mr-2 h-4 w-4" :size="16" />
|
|
40
|
+
{{ slotProps.componentField.modelValue ? df.format(slotProps.componentField.modelValue.toDate(getLocalTimeZone())) : "Pick a date" }}
|
|
41
|
+
</Button>
|
|
42
|
+
</PopoverTrigger>
|
|
43
|
+
<PopoverContent class="w-auto p-0">
|
|
44
|
+
<Calendar initial-focus v-bind="slotProps.componentField" />
|
|
45
|
+
</PopoverContent>
|
|
46
|
+
</Popover>
|
|
47
|
+
</div>
|
|
48
|
+
</slot>
|
|
49
|
+
</FormControl>
|
|
50
|
+
|
|
51
|
+
<FormDescription v-if="config?.description">
|
|
52
|
+
{{ config.description }}
|
|
53
|
+
</FormDescription>
|
|
54
|
+
<FormMessage />
|
|
55
|
+
</FormItem>
|
|
56
|
+
</FormField>
|
|
57
|
+
</template>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import AutoFormLabel from './AutoFormLabel.vue'
|
|
3
|
+
import { beautifyObjectName } from './utils'
|
|
4
|
+
import type { FieldProps } from './interface'
|
|
5
|
+
import { FormControl, FormDescription, FormField, FormItem, FormMessage } from '@/components/ui/form'
|
|
6
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'
|
|
7
|
+
import { Label } from '@/components/ui/label'
|
|
8
|
+
import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group'
|
|
9
|
+
|
|
10
|
+
defineProps<FieldProps & {
|
|
11
|
+
options?: string[]
|
|
12
|
+
}>()
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<template>
|
|
16
|
+
<FormField v-slot="slotProps" :name="fieldName">
|
|
17
|
+
<FormItem>
|
|
18
|
+
<AutoFormLabel v-if="!config?.hideLabel" :required="required">
|
|
19
|
+
{{ config?.label || beautifyObjectName(label ?? fieldName) }}
|
|
20
|
+
</AutoFormLabel>
|
|
21
|
+
<FormControl>
|
|
22
|
+
<slot v-bind="slotProps">
|
|
23
|
+
<RadioGroup v-if="config?.component === 'radio'" :disabled="disabled" :orientation="'vertical'" v-bind="{ ...slotProps.componentField }">
|
|
24
|
+
<div v-for="(option, index) in options" :key="option" class="mb-2 flex items-center gap-3 space-y-0">
|
|
25
|
+
<RadioGroupItem :id="`${option}-${index}`" :value="option" />
|
|
26
|
+
<Label :for="`${option}-${index}`">{{ beautifyObjectName(option) }}</Label>
|
|
27
|
+
</div>
|
|
28
|
+
</RadioGroup>
|
|
29
|
+
|
|
30
|
+
<Select v-else :disabled="disabled" v-bind="{ ...slotProps.componentField }">
|
|
31
|
+
<SelectTrigger class="w-full">
|
|
32
|
+
<SelectValue :placeholder="config?.inputProps?.placeholder" />
|
|
33
|
+
</SelectTrigger>
|
|
34
|
+
<SelectContent>
|
|
35
|
+
<SelectItem v-for="option in options" :key="option" :value="option">
|
|
36
|
+
{{ beautifyObjectName(option) }}
|
|
37
|
+
</SelectItem>
|
|
38
|
+
</SelectContent>
|
|
39
|
+
</Select>
|
|
40
|
+
</slot>
|
|
41
|
+
</FormControl>
|
|
42
|
+
|
|
43
|
+
<FormDescription v-if="config?.description">
|
|
44
|
+
{{ config.description }}
|
|
45
|
+
</FormDescription>
|
|
46
|
+
<FormMessage />
|
|
47
|
+
</FormItem>
|
|
48
|
+
</FormField>
|
|
49
|
+
</template>
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ref } from 'vue'
|
|
3
|
+
import { TrashIcon } from 'lucide-vue-next'
|
|
4
|
+
import AutoFormLabel from './AutoFormLabel.vue'
|
|
5
|
+
import { beautifyObjectName } from './utils'
|
|
6
|
+
import type { FieldProps } from './interface'
|
|
7
|
+
import { FormControl, FormDescription, FormField, FormItem, FormMessage } from '@/components/ui/form'
|
|
8
|
+
import { Input } from '@/components/ui/input'
|
|
9
|
+
import { Button } from '@/components/ui/button'
|
|
10
|
+
|
|
11
|
+
defineProps<FieldProps>()
|
|
12
|
+
|
|
13
|
+
const inputFile = ref<File>()
|
|
14
|
+
async function parseFileAsString(file: File | undefined): Promise<string> {
|
|
15
|
+
return new Promise((resolve, reject) => {
|
|
16
|
+
if (file) {
|
|
17
|
+
const reader = new FileReader()
|
|
18
|
+
reader.onloadend = () => {
|
|
19
|
+
resolve(reader.result as string)
|
|
20
|
+
}
|
|
21
|
+
reader.onerror = (err) => {
|
|
22
|
+
reject(err)
|
|
23
|
+
}
|
|
24
|
+
reader.readAsDataURL(file)
|
|
25
|
+
}
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<template>
|
|
31
|
+
<FormField v-slot="slotProps" :name="fieldName">
|
|
32
|
+
<FormItem v-bind="$attrs">
|
|
33
|
+
<AutoFormLabel v-if="!config?.hideLabel" :required="required">
|
|
34
|
+
{{ config?.label || beautifyObjectName(label ?? fieldName) }}
|
|
35
|
+
</AutoFormLabel>
|
|
36
|
+
<FormControl>
|
|
37
|
+
<slot v-bind="slotProps">
|
|
38
|
+
<Input
|
|
39
|
+
v-if="!inputFile"
|
|
40
|
+
type="file"
|
|
41
|
+
v-bind="{ ...config?.inputProps }"
|
|
42
|
+
:disabled="disabled"
|
|
43
|
+
@change="async (ev: InputEvent) => {
|
|
44
|
+
const file = (ev.target as HTMLInputElement).files?.[0]
|
|
45
|
+
inputFile = file
|
|
46
|
+
const parsed = await parseFileAsString(file)
|
|
47
|
+
slotProps.componentField.onInput(parsed)
|
|
48
|
+
}"
|
|
49
|
+
/>
|
|
50
|
+
<div v-else class="flex h-10 w-full items-center justify-between rounded-md border border-input bg-transparent pl-3 pr-1 py-1 text-sm shadow-sm transition-colors">
|
|
51
|
+
<p>{{ inputFile?.name }}</p>
|
|
52
|
+
<Button
|
|
53
|
+
:size="'icon'"
|
|
54
|
+
:variant="'ghost'"
|
|
55
|
+
class="h-[26px] w-[26px]"
|
|
56
|
+
aria-label="Remove file"
|
|
57
|
+
type="button"
|
|
58
|
+
@click="() => {
|
|
59
|
+
inputFile = undefined
|
|
60
|
+
slotProps.componentField.onInput(undefined)
|
|
61
|
+
}"
|
|
62
|
+
>
|
|
63
|
+
<TrashIcon :size="16" />
|
|
64
|
+
</Button>
|
|
65
|
+
</div>
|
|
66
|
+
</slot>
|
|
67
|
+
</FormControl>
|
|
68
|
+
<FormDescription v-if="config?.description">
|
|
69
|
+
{{ config.description }}
|
|
70
|
+
</FormDescription>
|
|
71
|
+
<FormMessage />
|
|
72
|
+
</FormItem>
|
|
73
|
+
</FormField>
|
|
74
|
+
</template>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from 'vue'
|
|
3
|
+
import AutoFormLabel from './AutoFormLabel.vue'
|
|
4
|
+
import { beautifyObjectName } from './utils'
|
|
5
|
+
import type { FieldProps } from './interface'
|
|
6
|
+
import { FormControl, FormDescription, FormField, FormItem, FormMessage } from '@/components/ui/form'
|
|
7
|
+
import { Input } from '@/components/ui/input'
|
|
8
|
+
import { Textarea } from '@/components/ui/textarea'
|
|
9
|
+
|
|
10
|
+
const props = defineProps<FieldProps>()
|
|
11
|
+
const inputComponent = computed(() => props.config?.component === 'textarea' ? Textarea : Input)
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<template>
|
|
15
|
+
<FormField v-slot="slotProps" :name="fieldName">
|
|
16
|
+
<FormItem v-bind="$attrs">
|
|
17
|
+
<AutoFormLabel v-if="!config?.hideLabel" :required="required">
|
|
18
|
+
{{ config?.label || beautifyObjectName(label ?? fieldName) }}
|
|
19
|
+
</AutoFormLabel>
|
|
20
|
+
<FormControl>
|
|
21
|
+
<slot v-bind="slotProps">
|
|
22
|
+
<component
|
|
23
|
+
:is="inputComponent"
|
|
24
|
+
type="text"
|
|
25
|
+
v-bind="{ ...slotProps.componentField, ...config?.inputProps }"
|
|
26
|
+
:disabled="disabled"
|
|
27
|
+
/>
|
|
28
|
+
</slot>
|
|
29
|
+
</FormControl>
|
|
30
|
+
<FormDescription v-if="config?.description">
|
|
31
|
+
{{ config.description }}
|
|
32
|
+
</FormDescription>
|
|
33
|
+
<FormMessage />
|
|
34
|
+
</FormItem>
|
|
35
|
+
</FormField>
|
|
36
|
+
</template>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import AutoFormLabel from './AutoFormLabel.vue'
|
|
3
|
+
import { beautifyObjectName } from './utils'
|
|
4
|
+
import type { FieldProps } from './interface'
|
|
5
|
+
import { FormControl, FormDescription, FormField, FormItem, FormMessage } from '@/components/ui/form'
|
|
6
|
+
import { Input } from '@/components/ui/input'
|
|
7
|
+
|
|
8
|
+
defineOptions({
|
|
9
|
+
inheritAttrs: false,
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
defineProps<FieldProps>()
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<template>
|
|
16
|
+
<FormField v-slot="slotProps" :name="fieldName">
|
|
17
|
+
<FormItem>
|
|
18
|
+
<AutoFormLabel v-if="!config?.hideLabel" :required="required">
|
|
19
|
+
{{ config?.label || beautifyObjectName(label ?? fieldName) }}
|
|
20
|
+
</AutoFormLabel>
|
|
21
|
+
<FormControl>
|
|
22
|
+
<slot v-bind="slotProps">
|
|
23
|
+
<Input type="number" v-bind="{ ...slotProps.componentField, ...config?.inputProps }" :disabled="disabled" />
|
|
24
|
+
</slot>
|
|
25
|
+
</FormControl>
|
|
26
|
+
<FormDescription v-if="config?.description">
|
|
27
|
+
{{ config.description }}
|
|
28
|
+
</FormDescription>
|
|
29
|
+
<FormMessage />
|
|
30
|
+
</FormItem>
|
|
31
|
+
</FormField>
|
|
32
|
+
</template>
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
<script setup lang="ts" generic="T extends ZodRawShape">
|
|
2
|
+
import type { ZodAny, ZodObject, ZodRawShape } from 'zod'
|
|
3
|
+
import { computed, provide } from 'vue'
|
|
4
|
+
import { FieldContextKey, useField } from 'vee-validate'
|
|
5
|
+
import AutoFormField from './AutoFormField.vue'
|
|
6
|
+
import type { Config, ConfigItem, Shape } from './interface'
|
|
7
|
+
import { beautifyObjectName, getBaseSchema, getBaseType, getDefaultValueInZodStack } from './utils'
|
|
8
|
+
import AutoFormLabel from './AutoFormLabel.vue'
|
|
9
|
+
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@/components/ui/accordion'
|
|
10
|
+
import { FormItem } from '@/components/ui/form'
|
|
11
|
+
|
|
12
|
+
const props = defineProps<{
|
|
13
|
+
fieldName: string
|
|
14
|
+
required?: boolean
|
|
15
|
+
config?: Config<T>
|
|
16
|
+
schema?: ZodObject<T>
|
|
17
|
+
disabled?: boolean
|
|
18
|
+
}>()
|
|
19
|
+
|
|
20
|
+
const shapes = computed(() => {
|
|
21
|
+
// @ts-expect-error ignore {} not assignable to object
|
|
22
|
+
const val: { [key in keyof T]: Shape } = {}
|
|
23
|
+
|
|
24
|
+
if (!props.schema)
|
|
25
|
+
return
|
|
26
|
+
const shape = getBaseSchema(props.schema)?.shape
|
|
27
|
+
if (!shape)
|
|
28
|
+
return
|
|
29
|
+
Object.keys(shape).forEach((name) => {
|
|
30
|
+
const item = shape[name] as ZodAny
|
|
31
|
+
const baseItem = getBaseSchema(item) as ZodAny
|
|
32
|
+
let options = (baseItem && 'values' in baseItem._def) ? baseItem._def.values as string[] : undefined
|
|
33
|
+
if (!Array.isArray(options) && typeof options === 'object')
|
|
34
|
+
options = Object.values(options)
|
|
35
|
+
|
|
36
|
+
val[name as keyof T] = {
|
|
37
|
+
type: getBaseType(item),
|
|
38
|
+
default: getDefaultValueInZodStack(item),
|
|
39
|
+
options,
|
|
40
|
+
required: !['ZodOptional', 'ZodNullable'].includes(item._def.typeName),
|
|
41
|
+
schema: item,
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
return val
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
const fieldContext = useField(props.fieldName)
|
|
48
|
+
// @ts-expect-error ignore missing `id`
|
|
49
|
+
provide(FieldContextKey, fieldContext)
|
|
50
|
+
</script>
|
|
51
|
+
|
|
52
|
+
<template>
|
|
53
|
+
<section>
|
|
54
|
+
<slot v-bind="props">
|
|
55
|
+
<Accordion type="single" as-child class="w-full" collapsible :disabled="disabled">
|
|
56
|
+
<FormItem>
|
|
57
|
+
<AccordionItem :value="fieldName" class="border-none">
|
|
58
|
+
<AccordionTrigger>
|
|
59
|
+
<AutoFormLabel class="text-base" :required="required">
|
|
60
|
+
{{ schema?.description || beautifyObjectName(fieldName) }}
|
|
61
|
+
</AutoFormLabel>
|
|
62
|
+
</AccordionTrigger>
|
|
63
|
+
<AccordionContent class="p-1 space-y-5">
|
|
64
|
+
<template v-for="(shape, key) in shapes" :key="key">
|
|
65
|
+
<AutoFormField
|
|
66
|
+
:config="config?.[key as keyof typeof config] as ConfigItem"
|
|
67
|
+
:field-name="`${fieldName}.${key.toString()}`"
|
|
68
|
+
:label="key.toString()"
|
|
69
|
+
:shape="shape"
|
|
70
|
+
/>
|
|
71
|
+
</template>
|
|
72
|
+
</AccordionContent>
|
|
73
|
+
</AccordionItem>
|
|
74
|
+
</FormItem>
|
|
75
|
+
</Accordion>
|
|
76
|
+
</slot>
|
|
77
|
+
</section>
|
|
78
|
+
</template>
|