@geniusdynamics/ns8-ui-lib 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +167 -0
- package/dist/index.d.ts +14 -0
- package/dist/ns8-ui-lib.es.js +4278 -0
- package/dist/ns8-ui-lib.es.js.map +1 -0
- package/dist/ns8-ui-lib.umd.js +7 -0
- package/dist/ns8-ui-lib.umd.js.map +1 -0
- package/dist/src/App.vue.d.ts +2 -0
- package/dist/src/components/HelloWorld.vue.d.ts +5 -0
- package/dist/src/components/NS/cards/NSBackupCard.vue.d.ts +51 -0
- package/dist/src/components/NS/cards/NSSystemInfoCard.vue.d.ts +58 -0
- package/dist/src/components/NS/cards/NSSystemdServiceCard.vue.d.ts +47 -0
- package/dist/src/components/NS/cards/index.d.ts +3 -0
- package/dist/src/components/NS/checkbox/NSCheckbox.vue.d.ts +37 -0
- package/dist/src/components/NS/checkbox/index.d.ts +1 -0
- package/dist/src/components/NS/data-table/NSDataTable.vue.d.ts +98 -0
- package/dist/src/components/NS/data-table/index.d.ts +1 -0
- package/dist/src/components/NS/empty-state/NSEmptyState.vue.d.ts +45 -0
- package/dist/src/components/NS/empty-state/index.d.ts +1 -0
- package/dist/src/components/NS/index.d.ts +35 -0
- package/dist/src/components/NS/inline-notification/NSInlineNotification.vue.d.ts +44 -0
- package/dist/src/components/NS/inline-notification/index.d.ts +1 -0
- package/dist/src/components/NS/lottie-animation/NSLottieAnimation.vue.d.ts +75 -0
- package/dist/src/components/NS/lottie-animation/index.d.ts +1 -0
- package/dist/src/components/NS/modal/NSModal.vue.d.ts +56 -0
- package/dist/src/components/NS/modal/NSModalTrigger.vue.d.ts +64 -0
- package/dist/src/components/NS/modal/index.d.ts +2 -0
- package/dist/src/components/NS/pagination/NSPagination.vue.d.ts +36 -0
- package/dist/src/components/NS/pagination/index.d.ts +1 -0
- package/dist/src/components/NS/progress/NSProgress.vue.d.ts +37 -0
- package/dist/src/components/NS/progress/NSProgressBar.vue.d.ts +39 -0
- package/dist/src/components/NS/progress/index.d.ts +2 -0
- package/dist/src/components/NS/slider/NSByteSlider.vue.d.ts +50 -0
- package/dist/src/components/NS/slider/NSSlider.vue.d.ts +49 -0
- package/dist/src/components/NS/slider/index.d.ts +2 -0
- package/dist/src/components/NS/tag/NSTag.vue.d.ts +41 -0
- package/dist/src/components/NS/tag/index.d.ts +1 -0
- package/dist/src/components/NS/text-input/NSTextInput.vue.d.ts +67 -0
- package/dist/src/components/NS/text-input/index.d.ts +1 -0
- package/dist/src/components/NS/toast-notification/NSToastNotification.vue.d.ts +44 -0
- package/dist/src/components/NS/toast-notification/index.d.ts +1 -0
- package/dist/src/components/NS/toggle/NSToggle.vue.d.ts +51 -0
- package/dist/src/components/NS/toggle/index.d.ts +1 -0
- package/dist/src/components/NS/wizard/NSWizard.vue.d.ts +86 -0
- package/dist/src/components/NS/wizard/index.d.ts +1 -0
- package/dist/src/components/ui/button/Button.vue.d.ts +27 -0
- package/dist/src/components/ui/button/index.d.ts +7 -0
- package/dist/src/components/ui/card/Card.vue.d.ts +21 -0
- package/dist/src/components/ui/card/CardAction.vue.d.ts +21 -0
- package/dist/src/components/ui/card/CardContent.vue.d.ts +21 -0
- package/dist/src/components/ui/card/CardDescription.vue.d.ts +21 -0
- package/dist/src/components/ui/card/CardFooter.vue.d.ts +21 -0
- package/dist/src/components/ui/card/CardHeader.vue.d.ts +21 -0
- package/dist/src/components/ui/card/CardTitle.vue.d.ts +21 -0
- package/dist/src/components/ui/card/index.d.ts +7 -0
- package/dist/src/components/ui/checkbox/NsCheckbox.vue.d.ts +49 -0
- package/dist/src/components/ui/checkbox/index.d.ts +11 -0
- package/dist/src/components/ui/dialog/Dialog.vue.d.ts +28 -0
- package/dist/src/components/ui/dialog/index.d.ts +1 -0
- package/dist/src/components/ui/empty-state/NsEmptyState.vue.d.ts +45 -0
- package/dist/src/components/ui/empty-state/index.d.ts +11 -0
- package/dist/src/components/ui/inline-notification/NsInlineNotification.vue.d.ts +45 -0
- package/dist/src/components/ui/inline-notification/index.d.ts +6 -0
- package/dist/src/components/ui/input/Input.vue.d.ts +12 -0
- package/dist/src/components/ui/input/index.d.ts +1 -0
- package/dist/src/components/ui/input-group/InputGroup.vue.d.ts +21 -0
- package/dist/src/components/ui/input-group/InputGroupAddon.vue.d.ts +25 -0
- package/dist/src/components/ui/input-group/InputGroupButton.vue.d.ts +22 -0
- package/dist/src/components/ui/input-group/InputGroupInput.vue.d.ts +6 -0
- package/dist/src/components/ui/input-group/InputGroupText.vue.d.ts +21 -0
- package/dist/src/components/ui/input-group/InputGroupTextarea.vue.d.ts +6 -0
- package/dist/src/components/ui/input-group/index.d.ts +22 -0
- package/dist/src/components/ui/item/Item.vue.d.ts +27 -0
- package/dist/src/components/ui/item/ItemActions.vue.d.ts +21 -0
- package/dist/src/components/ui/item/ItemContent.vue.d.ts +21 -0
- package/dist/src/components/ui/item/ItemDescription.vue.d.ts +21 -0
- package/dist/src/components/ui/item/ItemFooter.vue.d.ts +21 -0
- package/dist/src/components/ui/item/ItemGroup.vue.d.ts +21 -0
- package/dist/src/components/ui/item/ItemHeader.vue.d.ts +21 -0
- package/dist/src/components/ui/item/ItemMedia.vue.d.ts +23 -0
- package/dist/src/components/ui/item/ItemSeparator.vue.d.ts +7 -0
- package/dist/src/components/ui/item/ItemTitle.vue.d.ts +21 -0
- package/dist/src/components/ui/item/index.d.ts +20 -0
- package/dist/src/components/ui/label/Label.vue.d.ts +22 -0
- package/dist/src/components/ui/label/index.d.ts +1 -0
- package/dist/src/components/ui/scroll-area/ScrollArea.vue.d.ts +22 -0
- package/dist/src/components/ui/scroll-area/ScrollBar.vue.d.ts +9 -0
- package/dist/src/components/ui/scroll-area/index.d.ts +2 -0
- package/dist/src/components/ui/select/Select.vue.d.ts +28 -0
- package/dist/src/components/ui/select/SelectContent.vue.d.ts +32 -0
- package/dist/src/components/ui/select/SelectGroup.vue.d.ts +18 -0
- package/dist/src/components/ui/select/SelectItem.vue.d.ts +23 -0
- package/dist/src/components/ui/select/SelectItemText.vue.d.ts +18 -0
- package/dist/src/components/ui/select/SelectLabel.vue.d.ts +22 -0
- package/dist/src/components/ui/select/SelectScrollDownButton.vue.d.ts +22 -0
- package/dist/src/components/ui/select/SelectScrollUpButton.vue.d.ts +22 -0
- package/dist/src/components/ui/select/SelectSeparator.vue.d.ts +7 -0
- package/dist/src/components/ui/select/SelectTrigger.vue.d.ts +25 -0
- package/dist/src/components/ui/select/SelectValue.vue.d.ts +18 -0
- package/dist/src/components/ui/select/index.d.ts +11 -0
- package/dist/src/components/ui/separator/Separator.vue.d.ts +10 -0
- package/dist/src/components/ui/separator/index.d.ts +1 -0
- package/dist/src/components/ui/sheet/Sheet.vue.d.ts +25 -0
- package/dist/src/components/ui/sheet/SheetClose.vue.d.ts +18 -0
- package/dist/src/components/ui/sheet/SheetContent.vue.d.ts +39 -0
- package/dist/src/components/ui/sheet/SheetDescription.vue.d.ts +22 -0
- package/dist/src/components/ui/sheet/SheetFooter.vue.d.ts +21 -0
- package/dist/src/components/ui/sheet/SheetHeader.vue.d.ts +21 -0
- package/dist/src/components/ui/sheet/SheetOverlay.vue.d.ts +22 -0
- package/dist/src/components/ui/sheet/SheetTitle.vue.d.ts +22 -0
- package/dist/src/components/ui/sheet/SheetTrigger.vue.d.ts +18 -0
- package/dist/src/components/ui/sheet/index.d.ts +8 -0
- package/dist/src/components/ui/sidebar/Sidebar.vue.d.ts +24 -0
- package/dist/src/components/ui/sidebar/SidebarContent.vue.d.ts +21 -0
- package/dist/src/components/ui/sidebar/SidebarFooter.vue.d.ts +21 -0
- package/dist/src/components/ui/sidebar/SidebarGroup.vue.d.ts +21 -0
- package/dist/src/components/ui/sidebar/SidebarGroupAction.vue.d.ts +22 -0
- package/dist/src/components/ui/sidebar/SidebarGroupContent.vue.d.ts +21 -0
- package/dist/src/components/ui/sidebar/SidebarGroupLabel.vue.d.ts +22 -0
- package/dist/src/components/ui/sidebar/SidebarHeader.vue.d.ts +21 -0
- package/dist/src/components/ui/sidebar/SidebarInput.vue.d.ts +21 -0
- package/dist/src/components/ui/sidebar/SidebarInset.vue.d.ts +21 -0
- package/dist/src/components/ui/sidebar/SidebarMenu.vue.d.ts +21 -0
- package/dist/src/components/ui/sidebar/SidebarMenuAction.vue.d.ts +25 -0
- package/dist/src/components/ui/sidebar/SidebarMenuBadge.vue.d.ts +21 -0
- package/dist/src/components/ui/sidebar/SidebarMenuButton.vue.d.ts +27 -0
- package/dist/src/components/ui/sidebar/SidebarMenuButtonChild.vue.d.ts +30 -0
- package/dist/src/components/ui/sidebar/SidebarMenuItem.vue.d.ts +21 -0
- package/dist/src/components/ui/sidebar/SidebarMenuSkeleton.vue.d.ts +7 -0
- package/dist/src/components/ui/sidebar/SidebarMenuSub.vue.d.ts +21 -0
- package/dist/src/components/ui/sidebar/SidebarMenuSubButton.vue.d.ts +27 -0
- package/dist/src/components/ui/sidebar/SidebarMenuSubItem.vue.d.ts +21 -0
- package/dist/src/components/ui/sidebar/SidebarProvider.vue.d.ts +30 -0
- package/dist/src/components/ui/sidebar/SidebarRail.vue.d.ts +21 -0
- package/dist/src/components/ui/sidebar/SidebarSeparator.vue.d.ts +21 -0
- package/dist/src/components/ui/sidebar/SidebarTrigger.vue.d.ts +6 -0
- package/dist/src/components/ui/sidebar/index.d.ts +37 -0
- package/dist/src/components/ui/sidebar/utils.d.ts +56 -0
- package/dist/src/components/ui/skeleton/Skeleton.vue.d.ts +6 -0
- package/dist/src/components/ui/skeleton/index.d.ts +1 -0
- package/dist/src/components/ui/sonner/Sonner.vue.d.ts +3 -0
- package/dist/src/components/ui/sonner/index.d.ts +1 -0
- package/dist/src/components/ui/switch/Switch.vue.d.ts +28 -0
- package/dist/src/components/ui/switch/index.d.ts +1 -0
- package/dist/src/components/ui/table/Table.vue.d.ts +21 -0
- package/dist/src/components/ui/table/TableBody.vue.d.ts +21 -0
- package/dist/src/components/ui/table/TableCaption.vue.d.ts +21 -0
- package/dist/src/components/ui/table/TableCell.vue.d.ts +21 -0
- package/dist/src/components/ui/table/TableEmpty.vue.d.ts +24 -0
- package/dist/src/components/ui/table/TableFooter.vue.d.ts +21 -0
- package/dist/src/components/ui/table/TableHead.vue.d.ts +21 -0
- package/dist/src/components/ui/table/TableHeader.vue.d.ts +21 -0
- package/dist/src/components/ui/table/TableRow.vue.d.ts +21 -0
- package/dist/src/components/ui/table/index.d.ts +9 -0
- package/dist/src/components/ui/table/utils.d.ts +3 -0
- package/dist/src/components/ui/tabs/Tabs.vue.d.ts +28 -0
- package/dist/src/components/ui/tabs/TabsContent.vue.d.ts +22 -0
- package/dist/src/components/ui/tabs/TabsList.vue.d.ts +22 -0
- package/dist/src/components/ui/tabs/TabsTrigger.vue.d.ts +22 -0
- package/dist/src/components/ui/tabs/index.d.ts +4 -0
- package/dist/src/components/ui/tag/NsTag.vue.d.ts +42 -0
- package/dist/src/components/ui/tag/index.d.ts +8 -0
- package/dist/src/components/ui/text-input/NsTextInput.vue.d.ts +79 -0
- package/dist/src/components/ui/text-input/index.d.ts +15 -0
- package/dist/src/components/ui/textarea/Textarea.vue.d.ts +12 -0
- package/dist/src/components/ui/textarea/index.d.ts +1 -0
- package/dist/src/components/ui/toggle/NsToggle.vue.d.ts +54 -0
- package/dist/src/components/ui/toggle/index.d.ts +15 -0
- package/dist/src/components/ui/tooltip/Tooltip.vue.d.ts +24 -0
- package/dist/src/components/ui/tooltip/TooltipContent.vue.d.ts +30 -0
- package/dist/src/components/ui/tooltip/TooltipProvider.vue.d.ts +20 -0
- package/dist/src/components/ui/tooltip/TooltipTrigger.vue.d.ts +18 -0
- package/dist/src/components/ui/tooltip/index.d.ts +4 -0
- package/dist/src/composables/index.d.ts +8 -0
- package/dist/src/composables/useDateTimeService.d.ts +10 -0
- package/dist/src/composables/useFilterService.d.ts +8 -0
- package/dist/src/composables/useIconService.d.ts +153 -0
- package/dist/src/composables/usePageTitleService.d.ts +3 -0
- package/dist/src/composables/useQueryParamService.d.ts +13 -0
- package/dist/src/composables/useStorageService.d.ts +5 -0
- package/dist/src/composables/useTaskService.d.ts +18 -0
- package/dist/src/composables/useUtilService.d.ts +27 -0
- package/dist/src/lib/utils.d.ts +2 -0
- package/dist/src/main.d.ts +0 -0
- package/dist/vite.svg +1 -0
- package/package.json +80 -0
- package/src/App.vue +30 -0
- package/src/components/HelloWorld.vue +41 -0
- package/src/components/NS/CompleteDemo.vue +475 -0
- package/src/components/NS/Demo.vue +191 -0
- package/src/components/NS/cards/NSBackupCard.vue +272 -0
- package/src/components/NS/cards/NSSystemInfoCard.vue +252 -0
- package/src/components/NS/cards/NSSystemdServiceCard.vue +250 -0
- package/src/components/NS/checkbox/NSCheckbox.vue +104 -0
- package/src/components/NS/data-table/NSDataTable.vue +434 -0
- package/src/components/NS/empty-state/NSEmptyState.vue +188 -0
- package/src/components/NS/inline-notification/NSInlineNotification.vue +162 -0
- package/src/components/NS/lottie-animation/NSLottieAnimation.vue +255 -0
- package/src/components/NS/modal/NSModal.vue +193 -0
- package/src/components/NS/modal/NSModalTrigger.vue +109 -0
- package/src/components/NS/pagination/NSPagination.vue +247 -0
- package/src/components/NS/progress/NSProgress.vue +115 -0
- package/src/components/NS/progress/NSProgressBar.vue +137 -0
- package/src/components/NS/slider/NSByteSlider.vue +144 -0
- package/src/components/NS/slider/NSSlider.vue +142 -0
- package/src/components/NS/tag/NSTag.vue +139 -0
- package/src/components/NS/text-input/NSTextInput.vue +242 -0
- package/src/components/NS/toast-notification/NSToastNotification.vue +163 -0
- package/src/components/NS/toggle/NSToggle.vue +156 -0
- package/src/components/NS/wizard/NSWizard.vue +399 -0
- package/src/components/ui/button/Button.vue +29 -0
- package/src/components/ui/card/Card.vue +22 -0
- package/src/components/ui/card/CardAction.vue +17 -0
- package/src/components/ui/card/CardContent.vue +17 -0
- package/src/components/ui/card/CardDescription.vue +17 -0
- package/src/components/ui/card/CardFooter.vue +17 -0
- package/src/components/ui/card/CardHeader.vue +17 -0
- package/src/components/ui/card/CardTitle.vue +17 -0
- package/src/components/ui/checkbox/NsCheckbox.vue +123 -0
- package/src/components/ui/dialog/Dialog.vue +68 -0
- package/src/components/ui/empty-state/NsEmptyState.vue +149 -0
- package/src/components/ui/inline-notification/NsInlineNotification.vue +163 -0
- package/src/components/ui/input/Input.vue +33 -0
- package/src/components/ui/input-group/InputGroup.vue +35 -0
- package/src/components/ui/input-group/InputGroupAddon.vue +36 -0
- package/src/components/ui/input-group/InputGroupButton.vue +21 -0
- package/src/components/ui/input-group/InputGroupInput.vue +19 -0
- package/src/components/ui/input-group/InputGroupText.vue +19 -0
- package/src/components/ui/input-group/InputGroupTextarea.vue +19 -0
- package/src/components/ui/item/Item.vue +27 -0
- package/src/components/ui/item/ItemActions.vue +17 -0
- package/src/components/ui/item/ItemContent.vue +17 -0
- package/src/components/ui/item/ItemDescription.vue +21 -0
- package/src/components/ui/item/ItemFooter.vue +17 -0
- package/src/components/ui/item/ItemGroup.vue +18 -0
- package/src/components/ui/item/ItemHeader.vue +17 -0
- package/src/components/ui/item/ItemMedia.vue +21 -0
- package/src/components/ui/item/ItemSeparator.vue +18 -0
- package/src/components/ui/item/ItemTitle.vue +17 -0
- package/src/components/ui/label/Label.vue +26 -0
- package/src/components/ui/scroll-area/ScrollArea.vue +33 -0
- package/src/components/ui/scroll-area/ScrollBar.vue +32 -0
- package/src/components/ui/select/Select.vue +19 -0
- package/src/components/ui/select/SelectContent.vue +51 -0
- package/src/components/ui/select/SelectGroup.vue +15 -0
- package/src/components/ui/select/SelectItem.vue +44 -0
- package/src/components/ui/select/SelectItemText.vue +15 -0
- package/src/components/ui/select/SelectLabel.vue +17 -0
- package/src/components/ui/select/SelectScrollDownButton.vue +26 -0
- package/src/components/ui/select/SelectScrollUpButton.vue +26 -0
- package/src/components/ui/select/SelectSeparator.vue +19 -0
- package/src/components/ui/select/SelectTrigger.vue +33 -0
- package/src/components/ui/select/SelectValue.vue +15 -0
- package/src/components/ui/separator/Separator.vue +29 -0
- package/src/components/ui/sheet/Sheet.vue +19 -0
- package/src/components/ui/sheet/SheetClose.vue +15 -0
- package/src/components/ui/sheet/SheetContent.vue +62 -0
- package/src/components/ui/sheet/SheetDescription.vue +21 -0
- package/src/components/ui/sheet/SheetFooter.vue +16 -0
- package/src/components/ui/sheet/SheetHeader.vue +15 -0
- package/src/components/ui/sheet/SheetOverlay.vue +21 -0
- package/src/components/ui/sheet/SheetTitle.vue +21 -0
- package/src/components/ui/sheet/SheetTrigger.vue +15 -0
- package/src/components/ui/sidebar/Sidebar.vue +96 -0
- package/src/components/ui/sidebar/SidebarContent.vue +18 -0
- package/src/components/ui/sidebar/SidebarFooter.vue +18 -0
- package/src/components/ui/sidebar/SidebarGroup.vue +18 -0
- package/src/components/ui/sidebar/SidebarGroupAction.vue +27 -0
- package/src/components/ui/sidebar/SidebarGroupContent.vue +18 -0
- package/src/components/ui/sidebar/SidebarGroupLabel.vue +25 -0
- package/src/components/ui/sidebar/SidebarHeader.vue +18 -0
- package/src/components/ui/sidebar/SidebarInput.vue +22 -0
- package/src/components/ui/sidebar/SidebarInset.vue +21 -0
- package/src/components/ui/sidebar/SidebarMenu.vue +18 -0
- package/src/components/ui/sidebar/SidebarMenuAction.vue +35 -0
- package/src/components/ui/sidebar/SidebarMenuBadge.vue +26 -0
- package/src/components/ui/sidebar/SidebarMenuButton.vue +48 -0
- package/src/components/ui/sidebar/SidebarMenuButtonChild.vue +36 -0
- package/src/components/ui/sidebar/SidebarMenuItem.vue +18 -0
- package/src/components/ui/sidebar/SidebarMenuSkeleton.vue +35 -0
- package/src/components/ui/sidebar/SidebarMenuSub.vue +22 -0
- package/src/components/ui/sidebar/SidebarMenuSubButton.vue +36 -0
- package/src/components/ui/sidebar/SidebarMenuSubItem.vue +18 -0
- package/src/components/ui/sidebar/SidebarProvider.vue +82 -0
- package/src/components/ui/sidebar/SidebarRail.vue +33 -0
- package/src/components/ui/sidebar/SidebarSeparator.vue +19 -0
- package/src/components/ui/sidebar/SidebarTrigger.vue +27 -0
- package/src/components/ui/skeleton/Skeleton.vue +17 -0
- package/src/components/ui/sonner/Sonner.vue +42 -0
- package/src/components/ui/switch/Switch.vue +38 -0
- package/src/components/ui/table/Table.vue +16 -0
- package/src/components/ui/table/TableBody.vue +17 -0
- package/src/components/ui/table/TableCaption.vue +17 -0
- package/src/components/ui/table/TableCell.vue +22 -0
- package/src/components/ui/table/TableEmpty.vue +34 -0
- package/src/components/ui/table/TableFooter.vue +17 -0
- package/src/components/ui/table/TableHead.vue +17 -0
- package/src/components/ui/table/TableHeader.vue +17 -0
- package/src/components/ui/table/TableRow.vue +17 -0
- package/src/components/ui/tabs/Tabs.vue +24 -0
- package/src/components/ui/tabs/TabsContent.vue +21 -0
- package/src/components/ui/tabs/TabsList.vue +24 -0
- package/src/components/ui/tabs/TabsTrigger.vue +26 -0
- package/src/components/ui/tag/NsTag.vue +114 -0
- package/src/components/ui/text-input/NsTextInput.vue +269 -0
- package/src/components/ui/textarea/Textarea.vue +28 -0
- package/src/components/ui/toggle/NsToggle.vue +126 -0
- package/src/components/ui/tooltip/Tooltip.vue +19 -0
- package/src/components/ui/tooltip/TooltipContent.vue +34 -0
- package/src/components/ui/tooltip/TooltipProvider.vue +14 -0
- package/src/components/ui/tooltip/TooltipTrigger.vue +15 -0
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from 'vue'
|
|
3
|
+
import { ChevronLeft, ChevronRight, MoreHorizontal } from 'lucide-vue-next'
|
|
4
|
+
import { cn } from '@/lib/utils'
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
currentPage?: number
|
|
8
|
+
totalItems?: number
|
|
9
|
+
itemsPerPage?: number
|
|
10
|
+
totalPages?: number
|
|
11
|
+
showSizeChanger?: boolean
|
|
12
|
+
pageSizeOptions?: number[]
|
|
13
|
+
showQuickJumper?: boolean
|
|
14
|
+
showTotal?: boolean
|
|
15
|
+
disabled?: boolean
|
|
16
|
+
size?: 'sm' | 'default' | 'lg'
|
|
17
|
+
align?: 'start' | 'center' | 'end'
|
|
18
|
+
class?: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
22
|
+
currentPage: 1,
|
|
23
|
+
itemsPerPage: 10,
|
|
24
|
+
showSizeChanger: false,
|
|
25
|
+
pageSizeOptions: () => [10, 20, 50, 100],
|
|
26
|
+
showQuickJumper: false,
|
|
27
|
+
showTotal: true,
|
|
28
|
+
disabled: false,
|
|
29
|
+
size: 'default',
|
|
30
|
+
align: 'start',
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
const emit = defineEmits<{
|
|
34
|
+
'update:currentPage': [page: number]
|
|
35
|
+
'update:itemsPerPage': [size: number]
|
|
36
|
+
'page-change': [page: number]
|
|
37
|
+
'size-change': [size: number]
|
|
38
|
+
}>()
|
|
39
|
+
|
|
40
|
+
const calculatedTotalPages = computed(() => {
|
|
41
|
+
if (props.totalPages) {
|
|
42
|
+
return props.totalPages
|
|
43
|
+
}
|
|
44
|
+
return Math.ceil((props.totalItems || 0) / props.itemsPerPage)
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
const currentPageInternal = computed({
|
|
48
|
+
get: () => props.currentPage,
|
|
49
|
+
set: (page: number) => {
|
|
50
|
+
emit('update:currentPage', page)
|
|
51
|
+
emit('page-change', page)
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
const itemsPerPageInternal = computed({
|
|
56
|
+
get: () => props.itemsPerPage,
|
|
57
|
+
set: (size: number) => {
|
|
58
|
+
emit('update:itemsPerPage', size)
|
|
59
|
+
emit('size-change', size)
|
|
60
|
+
}
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
const pages = computed(() => {
|
|
64
|
+
const total = calculatedTotalPages.value
|
|
65
|
+
const current = currentPageInternal.value
|
|
66
|
+
const delta = 2 // Number of pages to show on each side
|
|
67
|
+
|
|
68
|
+
const range = []
|
|
69
|
+
const rangeWithDots = []
|
|
70
|
+
let l
|
|
71
|
+
|
|
72
|
+
for (let i = 1; i <= total; i++) {
|
|
73
|
+
if (i === 1 || i === total || (i >= current - delta && i <= current + delta)) {
|
|
74
|
+
range.push(i)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
range.forEach((i, index) => {
|
|
79
|
+
if (l) {
|
|
80
|
+
if (i - l === 2) {
|
|
81
|
+
rangeWithDots.push(l + 1)
|
|
82
|
+
} else if (i - l !== 1) {
|
|
83
|
+
rangeWithDots.push('...')
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
rangeWithDots.push(i)
|
|
87
|
+
l = i
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
return rangeWithDots
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
const canGoPrev = computed(() => currentPageInternal.value > 1)
|
|
94
|
+
const canGoNext = computed(() => currentPageInternal.value < calculatedTotalPages.value)
|
|
95
|
+
|
|
96
|
+
const containerClasses = computed(() => {
|
|
97
|
+
const baseClasses = 'flex flex-wrap items-center gap-2'
|
|
98
|
+
|
|
99
|
+
const alignClasses = {
|
|
100
|
+
start: 'justify-start',
|
|
101
|
+
center: 'justify-center',
|
|
102
|
+
end: 'justify-end'
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const sizeClasses = {
|
|
106
|
+
sm: 'text-xs',
|
|
107
|
+
default: 'text-sm',
|
|
108
|
+
lg: 'text-base'
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return cn(baseClasses, alignClasses[props.align], sizeClasses[props.size], props.class)
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
const buttonClasses = computed(() => {
|
|
115
|
+
const baseClasses = 'inline-flex items-center justify-center rounded-md border border-input bg-background hover:bg-accent hover:text-accent-foreground h-8 w-8 p-0 font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50'
|
|
116
|
+
|
|
117
|
+
const sizeClasses = {
|
|
118
|
+
sm: 'h-6 w-6 text-xs',
|
|
119
|
+
default: 'h-8 w-8 text-sm',
|
|
120
|
+
lg: 'h-10 w-10 text-base'
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return cn(baseClasses, sizeClasses[props.size])
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
const activeButtonClasses = computed(() => {
|
|
127
|
+
return cn(buttonClasses.value, 'border-primary bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground')
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
const jumperClasses = computed(() => {
|
|
131
|
+
const baseClasses = 'inline-flex items-center rounded-md border border-input bg-background px-3 py-1 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2'
|
|
132
|
+
|
|
133
|
+
const sizeClasses = {
|
|
134
|
+
sm: 'px-2 py-0.5 text-xs',
|
|
135
|
+
default: 'px-3 py-1 text-sm',
|
|
136
|
+
lg: 'px-4 py-2 text-base'
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return cn(baseClasses, sizeClasses[props.size])
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
const goToPage = (page: number) => {
|
|
143
|
+
if (page >= 1 && page <= calculatedTotalPages.value && !props.disabled) {
|
|
144
|
+
currentPageInternal.value = page
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const handlePrev = () => {
|
|
149
|
+
if (canGoPrev.value && !props.disabled) {
|
|
150
|
+
currentPageInternal.value--
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const handleNext = () => {
|
|
155
|
+
if (canGoNext.value && !props.disabled) {
|
|
156
|
+
currentPageInternal.value++
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const handleJumperChange = (event: Event) => {
|
|
161
|
+
const target = event.target as HTMLInputElement
|
|
162
|
+
const page = parseInt(target.value, 10)
|
|
163
|
+
|
|
164
|
+
if (!isNaN(page)) {
|
|
165
|
+
goToPage(page)
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
</script>
|
|
169
|
+
|
|
170
|
+
<template>
|
|
171
|
+
<div :class="containerClasses">
|
|
172
|
+
<!-- Total items display -->
|
|
173
|
+
<div v-if="showTotal && totalItems" class="text-sm text-muted-foreground">
|
|
174
|
+
Total: {{ totalItems }} items
|
|
175
|
+
</div>
|
|
176
|
+
|
|
177
|
+
<!-- Page size changer -->
|
|
178
|
+
<div v-if="showSizeChanger" class="flex items-center gap-2">
|
|
179
|
+
<span class="text-sm text-muted-foreground">Items per page:</span>
|
|
180
|
+
<select
|
|
181
|
+
v-model="itemsPerPageInternal"
|
|
182
|
+
:disabled="disabled"
|
|
183
|
+
:class="jumperClasses"
|
|
184
|
+
>
|
|
185
|
+
<option v-for="size in pageSizeOptions" :key="size" :value="size">
|
|
186
|
+
{{ size }}
|
|
187
|
+
</option>
|
|
188
|
+
</select>
|
|
189
|
+
</div>
|
|
190
|
+
|
|
191
|
+
<!-- Pagination buttons -->
|
|
192
|
+
<div class="flex items-center gap-1">
|
|
193
|
+
<!-- Previous button -->
|
|
194
|
+
<button
|
|
195
|
+
:class="buttonClasses"
|
|
196
|
+
:disabled="!canGoPrev || disabled"
|
|
197
|
+
@click="handlePrev"
|
|
198
|
+
aria-label="Previous page"
|
|
199
|
+
>
|
|
200
|
+
<ChevronLeft class="h-4 w-4" />
|
|
201
|
+
</button>
|
|
202
|
+
|
|
203
|
+
<!-- Page numbers -->
|
|
204
|
+
<template v-for="(page, index) in pages" :key="`page-${index}`">
|
|
205
|
+
<button
|
|
206
|
+
v-if="typeof page === 'number'"
|
|
207
|
+
:class="page === currentPageInternal ? activeButtonClasses : buttonClasses"
|
|
208
|
+
:disabled="disabled"
|
|
209
|
+
@click="goToPage(page)"
|
|
210
|
+
>
|
|
211
|
+
{{ page }}
|
|
212
|
+
</button>
|
|
213
|
+
<span
|
|
214
|
+
v-else
|
|
215
|
+
class="flex items-center justify-center h-8 w-8 text-sm text-muted-foreground"
|
|
216
|
+
>
|
|
217
|
+
<MoreHorizontal class="h-4 w-4" />
|
|
218
|
+
</span>
|
|
219
|
+
</template>
|
|
220
|
+
|
|
221
|
+
<!-- Next button -->
|
|
222
|
+
<button
|
|
223
|
+
:class="buttonClasses"
|
|
224
|
+
:disabled="!canGoNext || disabled"
|
|
225
|
+
@click="handleNext"
|
|
226
|
+
aria-label="Next page"
|
|
227
|
+
>
|
|
228
|
+
<ChevronRight class="h-4 w-4" />
|
|
229
|
+
</button>
|
|
230
|
+
</div>
|
|
231
|
+
|
|
232
|
+
<!-- Quick jumper -->
|
|
233
|
+
<div v-if="showQuickJumper" class="flex items-center gap-2">
|
|
234
|
+
<span class="text-sm text-muted-foreground">Go to page:</span>
|
|
235
|
+
<input
|
|
236
|
+
type="number"
|
|
237
|
+
:min="1"
|
|
238
|
+
:max="calculatedTotalPages"
|
|
239
|
+
:value="currentPageInternal"
|
|
240
|
+
:disabled="disabled"
|
|
241
|
+
:class="jumperClasses"
|
|
242
|
+
@change="handleJumperChange"
|
|
243
|
+
@keyup.enter="handleJumperChange"
|
|
244
|
+
/>
|
|
245
|
+
</div>
|
|
246
|
+
</div>
|
|
247
|
+
</template>
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from 'vue'
|
|
3
|
+
import { cn } from '@/lib/utils'
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
value?: number
|
|
7
|
+
max?: number
|
|
8
|
+
variant?: 'default' | 'destructive' | 'success' | 'warning' | 'info'
|
|
9
|
+
size?: 'default' | 'sm' | 'lg'
|
|
10
|
+
showLabel?: boolean
|
|
11
|
+
label?: string
|
|
12
|
+
indeterminate?: boolean
|
|
13
|
+
class?: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
17
|
+
max: 100,
|
|
18
|
+
variant: 'default',
|
|
19
|
+
size: 'default',
|
|
20
|
+
showLabel: false,
|
|
21
|
+
indeterminate: false,
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
const percentage = computed(() => {
|
|
25
|
+
if (props.indeterminate) return 0
|
|
26
|
+
return Math.min(Math.max((props.value || 0) / props.max * 100, 0), 100)
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
const containerClasses = computed(() => {
|
|
30
|
+
const baseClasses = 'relative w-full overflow-hidden rounded-full bg-secondary'
|
|
31
|
+
|
|
32
|
+
const sizeClasses = {
|
|
33
|
+
default: 'h-2',
|
|
34
|
+
sm: 'h-1',
|
|
35
|
+
lg: 'h-3'
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return cn(baseClasses, sizeClasses[props.size], props.class)
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
const progressClasses = computed(() => {
|
|
42
|
+
const baseClasses = 'h-full w-full flex-1 bg-primary transition-all'
|
|
43
|
+
|
|
44
|
+
const variantClasses = {
|
|
45
|
+
default: 'bg-primary',
|
|
46
|
+
destructive: 'bg-destructive',
|
|
47
|
+
success: 'bg-green-500',
|
|
48
|
+
warning: 'bg-orange-500',
|
|
49
|
+
info: 'bg-blue-500'
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return cn(baseClasses, variantClasses[props.variant], {
|
|
53
|
+
'animate-pulse': props.indeterminate,
|
|
54
|
+
'transition-all': !props.indeterminate
|
|
55
|
+
})
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
const labelClasses = computed(() => {
|
|
59
|
+
const baseClasses = 'text-sm font-medium'
|
|
60
|
+
|
|
61
|
+
const variantClasses = {
|
|
62
|
+
default: 'text-foreground',
|
|
63
|
+
destructive: 'text-destructive',
|
|
64
|
+
success: 'text-green-600',
|
|
65
|
+
warning: 'text-orange-600',
|
|
66
|
+
info: 'text-blue-600'
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return cn(baseClasses, variantClasses[props.variant])
|
|
70
|
+
})
|
|
71
|
+
</script>
|
|
72
|
+
|
|
73
|
+
<template>
|
|
74
|
+
<div class="space-y-2">
|
|
75
|
+
<!-- Label -->
|
|
76
|
+
<div v-if="showLabel && (label || $slots.label)" class="flex items-center justify-between">
|
|
77
|
+
<div :class="labelClasses">
|
|
78
|
+
<slot name="label">{{ label }}</slot>
|
|
79
|
+
</div>
|
|
80
|
+
<div :class="labelClasses" v-if="!indeterminate">
|
|
81
|
+
{{ Math.round(percentage) }}%
|
|
82
|
+
</div>
|
|
83
|
+
</div>
|
|
84
|
+
|
|
85
|
+
<!-- Progress container -->
|
|
86
|
+
<div :class="containerClasses" role="progressbar" :aria-valuenow="value" :aria-valuemax="max">
|
|
87
|
+
<div
|
|
88
|
+
:class="progressClasses"
|
|
89
|
+
:style="{
|
|
90
|
+
width: indeterminate ? '100%' : `${percentage}%`,
|
|
91
|
+
animation: indeterminate ? 'indeterminate 2s ease-in-out infinite' : undefined
|
|
92
|
+
}"
|
|
93
|
+
/>
|
|
94
|
+
</div>
|
|
95
|
+
|
|
96
|
+
<!-- Value display -->
|
|
97
|
+
<div v-if="$slots.value" class="text-sm text-muted-foreground">
|
|
98
|
+
<slot name="value" :value="value" :percentage="percentage" />
|
|
99
|
+
</div>
|
|
100
|
+
</div>
|
|
101
|
+
</template>
|
|
102
|
+
|
|
103
|
+
<style scoped>
|
|
104
|
+
@keyframes indeterminate {
|
|
105
|
+
0% {
|
|
106
|
+
transform: translateX(-100%);
|
|
107
|
+
}
|
|
108
|
+
50% {
|
|
109
|
+
transform: translateX(0%);
|
|
110
|
+
}
|
|
111
|
+
100% {
|
|
112
|
+
transform: translateX(100%);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
</style>
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from 'vue'
|
|
3
|
+
import { cn } from '@/lib/utils'
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
value?: number
|
|
7
|
+
max?: number
|
|
8
|
+
variant?: 'default' | 'destructive' | 'success' | 'warning' | 'info'
|
|
9
|
+
size?: 'default' | 'sm' | 'lg'
|
|
10
|
+
showLabel?: boolean
|
|
11
|
+
label?: string
|
|
12
|
+
indeterminate?: boolean
|
|
13
|
+
animated?: boolean
|
|
14
|
+
class?: string
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
18
|
+
max: 100,
|
|
19
|
+
variant: 'default',
|
|
20
|
+
size: 'default',
|
|
21
|
+
showLabel: false,
|
|
22
|
+
indeterminate: false,
|
|
23
|
+
animated: true,
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
const percentage = computed(() => {
|
|
27
|
+
if (props.indeterminate) return 0
|
|
28
|
+
return Math.min(Math.max((props.value || 0) / props.max * 100, 0), 100)
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
const containerClasses = computed(() => {
|
|
32
|
+
const baseClasses = 'relative w-full bg-secondary overflow-hidden rounded-md'
|
|
33
|
+
|
|
34
|
+
const sizeClasses = {
|
|
35
|
+
default: 'h-4',
|
|
36
|
+
sm: 'h-3',
|
|
37
|
+
lg: 'h-6'
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return cn(baseClasses, sizeClasses[props.size], props.class)
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
const barClasses = computed(() => {
|
|
44
|
+
const baseClasses = 'h-full flex-1 transition-all'
|
|
45
|
+
|
|
46
|
+
const variantClasses = {
|
|
47
|
+
default: 'bg-primary',
|
|
48
|
+
destructive: 'bg-destructive',
|
|
49
|
+
success: 'bg-green-500',
|
|
50
|
+
warning: 'bg-orange-500',
|
|
51
|
+
info: 'bg-blue-500'
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return cn(baseClasses, variantClasses[props.variant], {
|
|
55
|
+
'transition-all': props.animated && !props.indeterminate,
|
|
56
|
+
'animate-pulse': props.indeterminate,
|
|
57
|
+
'bg-gradient-to-r from-primary/80 to-primary': props.animated && props.variant === 'default',
|
|
58
|
+
'bg-gradient-to-r from-destructive/80 to-destructive': props.animated && props.variant === 'destructive',
|
|
59
|
+
'bg-gradient-to-r from-green-400 to-green-500': props.animated && props.variant === 'success',
|
|
60
|
+
'bg-gradient-to-r from-orange-400 to-orange-500': props.animated && props.variant === 'warning',
|
|
61
|
+
'bg-gradient-to-r from-blue-400 to-blue-500': props.animated && props.variant === 'info',
|
|
62
|
+
})
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
const labelClasses = computed(() => {
|
|
66
|
+
const baseClasses = 'text-sm font-medium'
|
|
67
|
+
|
|
68
|
+
const variantClasses = {
|
|
69
|
+
default: 'text-foreground',
|
|
70
|
+
destructive: 'text-destructive',
|
|
71
|
+
success: 'text-green-600',
|
|
72
|
+
warning: 'text-orange-600',
|
|
73
|
+
info: 'text-blue-600'
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return cn(baseClasses, variantClasses[props.variant])
|
|
77
|
+
})
|
|
78
|
+
</script>
|
|
79
|
+
|
|
80
|
+
<template>
|
|
81
|
+
<div class="space-y-2">
|
|
82
|
+
<!-- Label -->
|
|
83
|
+
<div v-if="showLabel && (label || $slots.label)" class="flex items-center justify-between">
|
|
84
|
+
<div :class="labelClasses">
|
|
85
|
+
<slot name="label">{{ label }}</slot>
|
|
86
|
+
</div>
|
|
87
|
+
<div :class="labelClasses" v-if="!indeterminate">
|
|
88
|
+
{{ Math.round(percentage) }}%
|
|
89
|
+
</div>
|
|
90
|
+
</div>
|
|
91
|
+
|
|
92
|
+
<!-- Progress bar container -->
|
|
93
|
+
<div :class="containerClasses" role="progressbar" :aria-valuenow="value" :aria-valuemax="max">
|
|
94
|
+
<div
|
|
95
|
+
:class="barClasses"
|
|
96
|
+
:style="{
|
|
97
|
+
width: indeterminate ? '100%' : `${percentage}%`,
|
|
98
|
+
animation: indeterminate ? 'indeterminate 2s ease-in-out infinite' : undefined
|
|
99
|
+
}"
|
|
100
|
+
>
|
|
101
|
+
<!-- Animated shimmer effect -->
|
|
102
|
+
<div
|
|
103
|
+
v-if="animated && !indeterminate"
|
|
104
|
+
class="h-full w-full bg-gradient-to-r from-transparent via-white/20 to-transparent animate-[shimmer_2s_ease-in-out_infinite]"
|
|
105
|
+
/>
|
|
106
|
+
</div>
|
|
107
|
+
</div>
|
|
108
|
+
|
|
109
|
+
<!-- Value display -->
|
|
110
|
+
<div v-if="$slots.value" class="text-sm text-muted-foreground">
|
|
111
|
+
<slot name="value" :value="value" :percentage="percentage" />
|
|
112
|
+
</div>
|
|
113
|
+
</div>
|
|
114
|
+
</template>
|
|
115
|
+
|
|
116
|
+
<style scoped>
|
|
117
|
+
@keyframes indeterminate {
|
|
118
|
+
0% {
|
|
119
|
+
transform: translateX(-100%);
|
|
120
|
+
}
|
|
121
|
+
50% {
|
|
122
|
+
transform: translateX(0%);
|
|
123
|
+
}
|
|
124
|
+
100% {
|
|
125
|
+
transform: translateX(100%);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
@keyframes shimmer {
|
|
130
|
+
0% {
|
|
131
|
+
transform: translateX(-100%);
|
|
132
|
+
}
|
|
133
|
+
100% {
|
|
134
|
+
transform: translateX(100%);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
</style>
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from 'vue'
|
|
3
|
+
import { SliderRoot, SliderTrack, SliderRange, SliderThumb } from 'radix-vue'
|
|
4
|
+
import { cn } from '@/lib/utils'
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
modelValue?: number
|
|
8
|
+
defaultValue?: number
|
|
9
|
+
min?: number
|
|
10
|
+
max?: number
|
|
11
|
+
step?: number
|
|
12
|
+
disabled?: boolean
|
|
13
|
+
showLabel?: boolean
|
|
14
|
+
label?: string
|
|
15
|
+
showValue?: boolean
|
|
16
|
+
formatBytes?: (bytes: number) => string
|
|
17
|
+
showByteUnits?: boolean
|
|
18
|
+
customUnits?: string[]
|
|
19
|
+
class?: string
|
|
20
|
+
trackClass?: string
|
|
21
|
+
thumbClass?: string
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
25
|
+
min: 0,
|
|
26
|
+
max: 1024, // 1GB default
|
|
27
|
+
step: 1,
|
|
28
|
+
showLabel: false,
|
|
29
|
+
showValue: true,
|
|
30
|
+
showByteUnits: true,
|
|
31
|
+
customUnits: () => ['B', 'KB', 'MB', 'GB', 'TB'],
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
const emit = defineEmits<{
|
|
35
|
+
'update:modelValue': [value: number]
|
|
36
|
+
}>()
|
|
37
|
+
|
|
38
|
+
const value = computed({
|
|
39
|
+
get: () => props.modelValue ?? props.defaultValue ?? 0,
|
|
40
|
+
set: (value: number) => {
|
|
41
|
+
emit('update:modelValue', value)
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
const formatBytesDefault = (bytes: number): string => {
|
|
46
|
+
if (bytes === 0) return '0 B'
|
|
47
|
+
|
|
48
|
+
const k = 1024
|
|
49
|
+
const dm = decimals < 0 ? 0 : decimals
|
|
50
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k))
|
|
51
|
+
|
|
52
|
+
const units = props.customUnits
|
|
53
|
+
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + units[i]
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const displayValue = computed(() => {
|
|
57
|
+
if (props.showByteUnits && props.formatBytes) {
|
|
58
|
+
return props.formatBytes(value.value)
|
|
59
|
+
} else if (props.showByteUnits) {
|
|
60
|
+
return formatBytesDefault(value.value)
|
|
61
|
+
} else {
|
|
62
|
+
return value.value.toString()
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
const containerClasses = computed(() => {
|
|
67
|
+
return cn('relative', props.class)
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
const rootClasses = computed(() => {
|
|
71
|
+
return cn('relative flex w-full touch-none select-none items-center flex-col')
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
const trackClasses = computed(() => {
|
|
75
|
+
return cn('relative h-2 w-full grow overflow-hidden rounded-full bg-secondary', props.trackClass)
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
const rangeClasses = computed(() => {
|
|
79
|
+
return cn('absolute h-full bg-primary')
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
const thumbClasses = computed(() => {
|
|
83
|
+
return cn('block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50', props.thumbClass)
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
const labelClasses = computed(() => {
|
|
87
|
+
return 'text-sm font-medium text-foreground'
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
const valueClasses = computed(() => {
|
|
91
|
+
return 'text-sm font-mono text-muted-foreground'
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
// Calculate optimal decimal places based on range
|
|
95
|
+
const decimals = computed(() => {
|
|
96
|
+
const range = props.max - props.min
|
|
97
|
+
if (range >= 1024 * 1024) return 1 // GB+
|
|
98
|
+
if (range >= 1024) return 0 // MB+
|
|
99
|
+
return 0 // KB and below
|
|
100
|
+
})
|
|
101
|
+
</script>
|
|
102
|
+
|
|
103
|
+
<template>
|
|
104
|
+
<div :class="containerClasses">
|
|
105
|
+
<!-- Label -->
|
|
106
|
+
<div
|
|
107
|
+
v-if="showLabel && (label || $slots.label)"
|
|
108
|
+
class="flex items-center justify-between mb-2"
|
|
109
|
+
>
|
|
110
|
+
<div :class="labelClasses">
|
|
111
|
+
<slot name="label">{{ label }}</slot>
|
|
112
|
+
</div>
|
|
113
|
+
<div v-if="showValue" :class="valueClasses">
|
|
114
|
+
{{ displayValue }}
|
|
115
|
+
</div>
|
|
116
|
+
</div>
|
|
117
|
+
|
|
118
|
+
<!-- Slider -->
|
|
119
|
+
<SliderRoot
|
|
120
|
+
:class="rootClasses"
|
|
121
|
+
v-model="value"
|
|
122
|
+
:min="min"
|
|
123
|
+
:max="max"
|
|
124
|
+
:step="step"
|
|
125
|
+
:disabled="disabled"
|
|
126
|
+
>
|
|
127
|
+
<SliderTrack :class="trackClasses">
|
|
128
|
+
<SliderRange :class="rangeClasses" />
|
|
129
|
+
</SliderTrack>
|
|
130
|
+
<SliderThumb :class="thumbClasses" />
|
|
131
|
+
</SliderRoot>
|
|
132
|
+
|
|
133
|
+
<!-- Scale markers for byte units -->
|
|
134
|
+
<div class="relative mt-2 flex justify-between text-xs text-muted-foreground">
|
|
135
|
+
<span v-if="showByteUnits">{{ formatBytes(min) }}</span>
|
|
136
|
+
<span v-if="showByteUnits">{{ formatBytes(max) }}</span>
|
|
137
|
+
</div>
|
|
138
|
+
|
|
139
|
+
<!-- Custom value display -->
|
|
140
|
+
<div v-if="$slots.value" class="mt-2">
|
|
141
|
+
<slot name="value" :value="value" :display-value="displayValue" />
|
|
142
|
+
</div>
|
|
143
|
+
</div>
|
|
144
|
+
</template>
|