@sakoa/ui 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +171 -0
- package/dist/App.d.ts +2 -0
- package/dist/cli/index.js +9243 -0
- package/dist/components/DemoSection.d.ts +30 -0
- package/dist/components/SApiKeyboard.d.ts +22 -0
- package/dist/components/SApiSection.d.ts +21 -0
- package/dist/components/SApiTable.d.ts +46 -0
- package/dist/components/STableOfContents.d.ts +2 -0
- package/dist/components/ui/SAlert.d.ts +76 -0
- package/dist/components/ui/SBadge.d.ts +56 -0
- package/dist/components/ui/SButton.d.ts +67 -0
- package/dist/components/ui/SCheckbox.d.ts +64 -0
- package/dist/components/ui/SChip.d.ts +43 -0
- package/dist/components/ui/SDatePicker.d.ts +77 -0
- package/dist/components/ui/SGlassButton.d.ts +70 -0
- package/dist/components/ui/SIcon.d.ts +29 -0
- package/dist/components/ui/SInput.d.ts +129 -0
- package/dist/components/ui/SKbd.d.ts +24 -0
- package/dist/components/ui/SKbdShortcut.d.ts +14 -0
- package/dist/components/ui/SSelect.d.ts +148 -0
- package/dist/components/ui/SSkeleton.d.ts +37 -0
- package/dist/components/ui/SSwitch.d.ts +61 -0
- package/dist/components/ui/STooltip.d.ts +82 -0
- package/dist/components/ui/accordion/SAccordionContent.d.ts +23 -0
- package/dist/components/ui/accordion/SAccordionItem.d.ts +70 -0
- package/dist/components/ui/accordion/SAccordionTrigger.d.ts +37 -0
- package/dist/components/ui/accordion/index.d.ts +4 -0
- package/dist/components/ui/avatar/SAvatar.d.ts +36 -0
- package/dist/components/ui/avatar/SAvatarFallback.d.ts +26 -0
- package/dist/components/ui/avatar/SAvatarGroup.d.ts +30 -0
- package/dist/components/ui/avatar/SAvatarImage.d.ts +23 -0
- package/dist/components/ui/avatar/index.d.ts +4 -0
- package/dist/components/ui/breadcrumb/SBreadcrumb.d.ts +22 -0
- package/dist/components/ui/breadcrumb/SBreadcrumbEllipsis.d.ts +17 -0
- package/dist/components/ui/breadcrumb/SBreadcrumbItem.d.ts +17 -0
- package/dist/components/ui/breadcrumb/SBreadcrumbLink.d.ts +26 -0
- package/dist/components/ui/breadcrumb/SBreadcrumbList.d.ts +17 -0
- package/dist/components/ui/breadcrumb/SBreadcrumbPage.d.ts +17 -0
- package/dist/components/ui/breadcrumb/SBreadcrumbSeparator.d.ts +17 -0
- package/dist/components/ui/breadcrumb/index.d.ts +7 -0
- package/dist/components/ui/card/SCard.d.ts +103 -0
- package/dist/components/ui/card/SCardActions.d.ts +44 -0
- package/dist/components/ui/card/SCardContent.d.ts +35 -0
- package/dist/components/ui/card/SCardFooter.d.ts +38 -0
- package/dist/components/ui/card/SCardHeader.d.ts +53 -0
- package/dist/components/ui/card/SCardMedia.d.ts +83 -0
- package/dist/components/ui/card/SGlassCard.d.ts +103 -0
- package/dist/components/ui/card/SMorphingCardContent.d.ts +18 -0
- package/dist/components/ui/card/index.d.ts +24 -0
- package/dist/components/ui/carousel/SCarousel.d.ts +166 -0
- package/dist/components/ui/carousel/index.d.ts +2 -0
- package/dist/components/ui/color-picker/SColorPickerAlphaSlider.d.ts +4 -0
- package/dist/components/ui/color-picker/SColorPickerCopy.d.ts +19 -0
- package/dist/components/ui/color-picker/SColorPickerEyeDropper.d.ts +17 -0
- package/dist/components/ui/color-picker/SColorPickerHueSlider.d.ts +4 -0
- package/dist/components/ui/color-picker/SColorPickerInputs.d.ts +2 -0
- package/dist/components/ui/color-picker/SColorPickerPresets.d.ts +9 -0
- package/dist/components/ui/color-picker/SColorPickerPreview.d.ts +2 -0
- package/dist/components/ui/color-picker/SColorPickerRecent.d.ts +7 -0
- package/dist/components/ui/color-picker/SColorPickerSpectrum.d.ts +4 -0
- package/dist/components/ui/color-picker/index.d.ts +11 -0
- package/dist/components/ui/drawer/index.d.ts +11 -0
- package/dist/components/ui/dropdown/SDropdownDivider.d.ts +8 -0
- package/dist/components/ui/dropdown/SDropdownGroup.d.ts +25 -0
- package/dist/components/ui/dropdown/SDropdownItem.d.ts +56 -0
- package/dist/components/ui/dropdown/index.d.ts +4 -0
- package/dist/components/ui/form/SForm.d.ts +38 -0
- package/dist/components/ui/form/SFormField.d.ts +31 -0
- package/dist/components/ui/form/index.d.ts +5 -0
- package/dist/components/ui/modal/index.d.ts +19 -0
- package/dist/components/ui/option/SOption.d.ts +32 -0
- package/dist/components/ui/option/SOptionGroup.d.ts +28 -0
- package/dist/components/ui/option/index.d.ts +2 -0
- package/dist/components/ui/otp/SOTP.d.ts +122 -0
- package/dist/components/ui/otp/SOTPGroup.d.ts +23 -0
- package/dist/components/ui/otp/SOTPSeparator.d.ts +17 -0
- package/dist/components/ui/otp/SOTPSlot.d.ts +49 -0
- package/dist/components/ui/otp/index.d.ts +7 -0
- package/dist/components/ui/otp/types.d.ts +26 -0
- package/dist/components/ui/otp/useOTPContext.d.ts +42 -0
- package/dist/components/ui/pagination/SPagination.d.ts +151 -0
- package/dist/components/ui/pagination/index.d.ts +2 -0
- package/dist/components/ui/progress/SProgress.d.ts +62 -0
- package/dist/components/ui/progress/SProgressRange.d.ts +91 -0
- package/dist/components/ui/progress/index.d.ts +4 -0
- package/dist/components/ui/radio/SRadio.d.ts +58 -0
- package/dist/components/ui/radio/SRadioGroup.d.ts +52 -0
- package/dist/components/ui/radio/index.d.ts +2 -0
- package/dist/components/ui/stepper/SStepper.d.ts +83 -0
- package/dist/components/ui/stepper/SStepperContent.d.ts +24 -0
- package/dist/components/ui/stepper/SStepperDescription.d.ts +20 -0
- package/dist/components/ui/stepper/SStepperIndicator.d.ts +37 -0
- package/dist/components/ui/stepper/SStepperItem.d.ts +37 -0
- package/dist/components/ui/stepper/SStepperSeparator.d.ts +5 -0
- package/dist/components/ui/stepper/SStepperTitle.d.ts +20 -0
- package/dist/components/ui/stepper/SStepperTrigger.d.ts +22 -0
- package/dist/components/ui/stepper/index.d.ts +11 -0
- package/dist/components/ui/table/STableBody.d.ts +27 -0
- package/dist/components/ui/table/STableCell.d.ts +55 -0
- package/dist/components/ui/table/STableColumn.d.ts +87 -0
- package/dist/components/ui/table/STableEmpty.d.ts +54 -0
- package/dist/components/ui/table/STableHeader.d.ts +25 -0
- package/dist/components/ui/table/STableRow.d.ts +38 -0
- package/dist/components/ui/table/STableSkeleton.d.ts +29 -0
- package/dist/components/ui/table/index.d.ts +98 -0
- package/dist/components/ui/table/useDataTable.d.ts +80 -0
- package/dist/components/ui/tabs/STabPane.d.ts +31 -0
- package/dist/components/ui/tabs/STabsContent.d.ts +21 -0
- package/dist/components/ui/tabs/STabsIndicator.d.ts +9 -0
- package/dist/components/ui/tabs/STabsTrigger.d.ts +28 -0
- package/dist/components/ui/tabs/index.d.ts +6 -0
- package/dist/components/ui/toast/SToast.d.ts +49 -0
- package/dist/components/ui/toast/SToastContainer.d.ts +21 -0
- package/dist/components/ui/toast/index.d.ts +2 -0
- package/dist/composables/useAsync.d.ts +134 -0
- package/dist/composables/useClickOutside.d.ts +69 -0
- package/dist/composables/useClipboard.d.ts +46 -0
- package/dist/composables/useDebounce.d.ts +150 -0
- package/dist/composables/useDialog.d.ts +118 -0
- package/dist/composables/useForm.d.ts +204 -0
- package/dist/composables/useHotkey.d.ts +128 -0
- package/dist/composables/useIntersectionObserver.d.ts +156 -0
- package/dist/composables/useLocalStorage.d.ts +120 -0
- package/dist/composables/useMediaQuery.d.ts +115 -0
- package/dist/composables/useTheme.d.ts +8 -0
- package/dist/composables/useToast.d.ts +1619 -0
- package/dist/index.d.ts +71 -0
- package/dist/layouts/UILayout.d.ts +2 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/main.d.ts +0 -0
- package/dist/router.d.ts +2 -0
- package/dist/saka-ui.css +1 -0
- package/dist/saka-ui.js +18513 -0
- package/dist/saka-ui.umd.cjs +38 -0
- package/dist/views/docs/CustomizationView.d.ts +2 -0
- package/dist/views/docs/FormValidationView.d.ts +2 -0
- package/dist/views/docs/StylingGuideView.d.ts +2 -0
- package/dist/views/docs/UseAsyncView.d.ts +2 -0
- package/dist/views/docs/UseClickOutsideView.d.ts +124 -0
- package/dist/views/docs/UseClipboardView.d.ts +4 -0
- package/dist/views/docs/UseDebounceView.d.ts +2 -0
- package/dist/views/docs/UseHotkeyView.d.ts +205 -0
- package/dist/views/docs/UseIntersectionObserverView.d.ts +5 -0
- package/dist/views/docs/UseLocalStorageView.d.ts +2 -0
- package/dist/views/docs/UseMediaQueryView.d.ts +2 -0
- package/dist/views/docs/UseThemeView.d.ts +2 -0
- package/dist/views/examples/AuthFormView.d.ts +2 -0
- package/dist/views/examples/CreditCardFormView.d.ts +6 -0
- package/dist/views/examples/FormFieldExampleView.d.ts +2 -0
- package/dist/views/examples/ProjectFormView.d.ts +2 -0
- package/dist/views/ui/AccordionView.d.ts +2 -0
- package/dist/views/ui/AlertView.d.ts +2 -0
- package/dist/views/ui/AvatarView.d.ts +2 -0
- package/dist/views/ui/BadgeView.d.ts +2 -0
- package/dist/views/ui/BreadcrumbView.d.ts +2 -0
- package/dist/views/ui/ButtonView.d.ts +2 -0
- package/dist/views/ui/CardView.d.ts +2 -0
- package/dist/views/ui/CarouselView.d.ts +274 -0
- package/dist/views/ui/CheckboxView.d.ts +2 -0
- package/dist/views/ui/ChipView.d.ts +2 -0
- package/dist/views/ui/ColorPickerView.d.ts +2 -0
- package/dist/views/ui/DatePickerView.d.ts +2 -0
- package/dist/views/ui/DialogView.d.ts +2 -0
- package/dist/views/ui/DrawerView.d.ts +2 -0
- package/dist/views/ui/DropdownView.d.ts +2 -0
- package/dist/views/ui/GlassButtonView.d.ts +2 -0
- package/dist/views/ui/GlassCardView.d.ts +2 -0
- package/dist/views/ui/HomeView.d.ts +2 -0
- package/dist/views/ui/IconsView.d.ts +2 -0
- package/dist/views/ui/InputView.d.ts +2 -0
- package/dist/views/ui/KbdView.d.ts +2 -0
- package/dist/views/ui/ModalView.d.ts +2 -0
- package/dist/views/ui/MorphingCardView.d.ts +2 -0
- package/dist/views/ui/MorphingModalView.d.ts +2 -0
- package/dist/views/ui/OTPView.d.ts +206 -0
- package/dist/views/ui/PaginationView.d.ts +2 -0
- package/dist/views/ui/ProgressView.d.ts +2 -0
- package/dist/views/ui/RadioView.d.ts +2 -0
- package/dist/views/ui/SelectView.d.ts +2 -0
- package/dist/views/ui/SkeletonView.d.ts +2 -0
- package/dist/views/ui/StepperView.d.ts +2 -0
- package/dist/views/ui/SwitchView.d.ts +2 -0
- package/dist/views/ui/TableView.d.ts +2 -0
- package/dist/views/ui/TabsView.d.ts +2 -0
- package/dist/views/ui/ToastView.d.ts +2 -0
- package/dist/views/ui/TooltipView.d.ts +2 -0
- package/dist/vite.svg +1 -0
- package/package.json +64 -0
- package/registry/components/accordion.json +19 -0
- package/registry/components/alert.json +17 -0
- package/registry/components/avatar.json +18 -0
- package/registry/components/badge.json +14 -0
- package/registry/components/breadcrumb.json +24 -0
- package/registry/components/button.json +17 -0
- package/registry/components/card.json +23 -0
- package/registry/components/carousel.json +19 -0
- package/registry/components/checkbox.json +17 -0
- package/registry/components/chip.json +17 -0
- package/registry/components/color-picker.json +24 -0
- package/registry/components/date-picker.json +17 -0
- package/registry/components/drawer.json +26 -0
- package/registry/components/dropdown.json +21 -0
- package/registry/components/form.json +16 -0
- package/registry/components/glass-button.json +17 -0
- package/registry/components/icon.json +17 -0
- package/registry/components/input.json +17 -0
- package/registry/components/kbd.json +16 -0
- package/registry/components/modal.json +32 -0
- package/registry/components/option.json +16 -0
- package/registry/components/otp.json +23 -0
- package/registry/components/pagination.json +18 -0
- package/registry/components/progress.json +16 -0
- package/registry/components/radio.json +19 -0
- package/registry/components/select.json +17 -0
- package/registry/components/skeleton.json +14 -0
- package/registry/components/switch.json +17 -0
- package/registry/components/table.json +26 -0
- package/registry/components/tabs.json +19 -0
- package/registry/components/toast.json +19 -0
- package/registry/components/tooltip.json +14 -0
- package/registry/index.json +4 -0
- package/registry/source/components/ui/SAlert.vue +388 -0
- package/registry/source/components/ui/SBadge.vue +243 -0
- package/registry/source/components/ui/SButton.vue +387 -0
- package/registry/source/components/ui/SCheckbox.vue +310 -0
- package/registry/source/components/ui/SChip.vue +130 -0
- package/registry/source/components/ui/SDatePicker.vue +1290 -0
- package/registry/source/components/ui/SGlassButton.vue +547 -0
- package/registry/source/components/ui/SIcon.vue +78 -0
- package/registry/source/components/ui/SInput.vue +1054 -0
- package/registry/source/components/ui/SKbd.vue +96 -0
- package/registry/source/components/ui/SKbdShortcut.vue +36 -0
- package/registry/source/components/ui/SSelect.vue +1290 -0
- package/registry/source/components/ui/SSkeleton.vue +185 -0
- package/registry/source/components/ui/SSwitch.vue +275 -0
- package/registry/source/components/ui/STooltip.vue +491 -0
- package/registry/source/components/ui/accordion/SAccordion.vue +248 -0
- package/registry/source/components/ui/accordion/SAccordionItem.vue +353 -0
- package/registry/source/components/ui/accordion/index.ts +5 -0
- package/registry/source/components/ui/avatar/SAvatar.vue +169 -0
- package/registry/source/components/ui/avatar/SAvatarFallback.vue +66 -0
- package/registry/source/components/ui/avatar/SAvatarGroup.vue +69 -0
- package/registry/source/components/ui/avatar/SAvatarImage.vue +92 -0
- package/registry/source/components/ui/avatar/index.ts +5 -0
- package/registry/source/components/ui/breadcrumb/SBreadcrumb.vue +23 -0
- package/registry/source/components/ui/breadcrumb/SBreadcrumbEllipsis.vue +17 -0
- package/registry/source/components/ui/breadcrumb/SBreadcrumbItem.vue +14 -0
- package/registry/source/components/ui/breadcrumb/SBreadcrumbLink.vue +46 -0
- package/registry/source/components/ui/breadcrumb/SBreadcrumbList.vue +17 -0
- package/registry/source/components/ui/breadcrumb/SBreadcrumbPage.vue +15 -0
- package/registry/source/components/ui/breadcrumb/SBreadcrumbSeparator.vue +18 -0
- package/registry/source/components/ui/breadcrumb/index.ts +7 -0
- package/registry/source/components/ui/card/SCard.vue +517 -0
- package/registry/source/components/ui/card/SCardActions.vue +129 -0
- package/registry/source/components/ui/card/SCardContent.vue +117 -0
- package/registry/source/components/ui/card/SCardFooter.vue +103 -0
- package/registry/source/components/ui/card/SCardHeader.vue +163 -0
- package/registry/source/components/ui/card/SCardMedia.vue +312 -0
- package/registry/source/components/ui/card/index.ts +34 -0
- package/registry/source/components/ui/carousel/SCarousel.vue +1069 -0
- package/registry/source/components/ui/carousel/SCarouselSlide.vue +107 -0
- package/registry/source/components/ui/carousel/index.ts +3 -0
- package/registry/source/components/ui/color-picker/SColorPicker.vue +772 -0
- package/registry/source/components/ui/color-picker/SColorPickerAlphaSlider.vue +158 -0
- package/registry/source/components/ui/color-picker/SColorPickerCopy.vue +76 -0
- package/registry/source/components/ui/color-picker/SColorPickerEyeDropper.vue +68 -0
- package/registry/source/components/ui/color-picker/SColorPickerHueSlider.vue +138 -0
- package/registry/source/components/ui/color-picker/SColorPickerInputs.vue +227 -0
- package/registry/source/components/ui/color-picker/SColorPickerPresets.vue +87 -0
- package/registry/source/components/ui/color-picker/SColorPickerPreview.vue +46 -0
- package/registry/source/components/ui/color-picker/SColorPickerRecent.vue +74 -0
- package/registry/source/components/ui/color-picker/SColorPickerSpectrum.vue +149 -0
- package/registry/source/components/ui/color-picker/index.ts +11 -0
- package/registry/source/components/ui/drawer/SDrawer.vue +797 -0
- package/registry/source/components/ui/drawer/SDrawerClose.vue +64 -0
- package/registry/source/components/ui/drawer/SDrawerContent.vue +81 -0
- package/registry/source/components/ui/drawer/SDrawerDescription.vue +40 -0
- package/registry/source/components/ui/drawer/SDrawerFooter.vue +97 -0
- package/registry/source/components/ui/drawer/SDrawerHandle.vue +79 -0
- package/registry/source/components/ui/drawer/SDrawerHeader.vue +117 -0
- package/registry/source/components/ui/drawer/SDrawerTitle.vue +40 -0
- package/registry/source/components/ui/drawer/SDrawerTrigger.vue +51 -0
- package/registry/source/components/ui/drawer/index.ts +20 -0
- package/registry/source/components/ui/dropdown/SDropdown.vue +843 -0
- package/registry/source/components/ui/dropdown/SDropdownDivider.vue +23 -0
- package/registry/source/components/ui/dropdown/SDropdownGroup.vue +53 -0
- package/registry/source/components/ui/dropdown/SDropdownItem.vue +179 -0
- package/registry/source/components/ui/dropdown/index.ts +5 -0
- package/registry/source/components/ui/form/SForm.vue +84 -0
- package/registry/source/components/ui/form/SFormField.vue +78 -0
- package/registry/source/components/ui/form/index.ts +8 -0
- package/registry/source/components/ui/modal/SModal.vue +648 -0
- package/registry/source/components/ui/modal/SModalClose.vue +49 -0
- package/registry/source/components/ui/modal/SModalContent.vue +74 -0
- package/registry/source/components/ui/modal/SModalDescription.vue +39 -0
- package/registry/source/components/ui/modal/SModalFooter.vue +84 -0
- package/registry/source/components/ui/modal/SModalHeader.vue +107 -0
- package/registry/source/components/ui/modal/SModalTitle.vue +39 -0
- package/registry/source/components/ui/modal/SModalTrigger.vue +61 -0
- package/registry/source/components/ui/modal/SMorphingModal.vue +429 -0
- package/registry/source/components/ui/modal/SMorphingModalClose.vue +42 -0
- package/registry/source/components/ui/modal/SMorphingModalDescription.vue +49 -0
- package/registry/source/components/ui/modal/SMorphingModalImage.vue +44 -0
- package/registry/source/components/ui/modal/SMorphingModalSubtitle.vue +29 -0
- package/registry/source/components/ui/modal/SMorphingModalTitle.vue +34 -0
- package/registry/source/components/ui/modal/SMorphingModalTrigger.vue +95 -0
- package/registry/source/components/ui/modal/index.ts +32 -0
- package/registry/source/components/ui/option/SOption.vue +180 -0
- package/registry/source/components/ui/option/SOptionGroup.vue +77 -0
- package/registry/source/components/ui/option/index.ts +3 -0
- package/registry/source/components/ui/otp/SOTP.vue +843 -0
- package/registry/source/components/ui/otp/SOTPGroup.vue +29 -0
- package/registry/source/components/ui/otp/SOTPSeparator.vue +15 -0
- package/registry/source/components/ui/otp/SOTPSlot.vue +462 -0
- package/registry/source/components/ui/otp/index.ts +7 -0
- package/registry/source/components/ui/otp/types.ts +27 -0
- package/registry/source/components/ui/otp/useOTPContext.ts +62 -0
- package/registry/source/components/ui/pagination/SPagination.vue +923 -0
- package/registry/source/components/ui/pagination/index.ts +8 -0
- package/registry/source/components/ui/progress/SProgress.vue +635 -0
- package/registry/source/components/ui/progress/SProgressRange.vue +715 -0
- package/registry/source/components/ui/progress/index.ts +4 -0
- package/registry/source/components/ui/radio/SRadio.vue +407 -0
- package/registry/source/components/ui/radio/SRadioGroup.vue +200 -0
- package/registry/source/components/ui/radio/index.ts +3 -0
- package/registry/source/components/ui/table/SDataTable.vue +828 -0
- package/registry/source/components/ui/table/STableBody.vue +70 -0
- package/registry/source/components/ui/table/STableCell.vue +147 -0
- package/registry/source/components/ui/table/STableColumn.vue +120 -0
- package/registry/source/components/ui/table/STableEmpty.vue +159 -0
- package/registry/source/components/ui/table/STableHeader.vue +132 -0
- package/registry/source/components/ui/table/STableRow.vue +106 -0
- package/registry/source/components/ui/table/STableSkeleton.vue +208 -0
- package/registry/source/components/ui/table/index.ts +126 -0
- package/registry/source/components/ui/table/useDataTable.ts +519 -0
- package/registry/source/components/ui/tabs/STabPane.vue +130 -0
- package/registry/source/components/ui/tabs/STabs.vue +467 -0
- package/registry/source/components/ui/tabs/index.ts +7 -0
- package/registry/source/components/ui/toast/SToast.vue +261 -0
- package/registry/source/components/ui/toast/SToastContainer.vue +209 -0
- package/registry/source/components/ui/toast/index.ts +2 -0
- package/registry/source/composables/useForm.ts +960 -0
- package/registry/source/composables/useTheme.ts +86 -0
- package/registry/source/composables/useToast.ts +440 -0
- package/registry/source/lib/utils.ts +6 -0
|
@@ -0,0 +1,828 @@
|
|
|
1
|
+
<script setup lang="ts" generic="T extends Record<string, unknown>">
|
|
2
|
+
/**
|
|
3
|
+
* SDataTable - Production-ready Data Table Component
|
|
4
|
+
*
|
|
5
|
+
* A highly customizable, accessible table with sorting, selection,
|
|
6
|
+
* pagination, and smooth animations.
|
|
7
|
+
*/
|
|
8
|
+
import { provide, computed, toRef, watch, ref } from 'vue'
|
|
9
|
+
import { cn } from '../../../lib/utils'
|
|
10
|
+
import {
|
|
11
|
+
SDataTableContextKey,
|
|
12
|
+
type TableColumn,
|
|
13
|
+
type TableVariant,
|
|
14
|
+
type TableSize,
|
|
15
|
+
type SelectionMode,
|
|
16
|
+
type SortState
|
|
17
|
+
} from './index'
|
|
18
|
+
import { useDataTable } from './useDataTable'
|
|
19
|
+
import { SPagination } from '../pagination'
|
|
20
|
+
|
|
21
|
+
defineOptions({ inheritAttrs: false })
|
|
22
|
+
|
|
23
|
+
export interface Props {
|
|
24
|
+
/** Table data array */
|
|
25
|
+
data?: T[]
|
|
26
|
+
/** Column definitions */
|
|
27
|
+
columns?: TableColumn<T>[]
|
|
28
|
+
/** Row key accessor */
|
|
29
|
+
rowKey?: keyof T | ((row: T, index: number) => string | number)
|
|
30
|
+
/** Visual variant */
|
|
31
|
+
variant?: TableVariant
|
|
32
|
+
/** Size preset */
|
|
33
|
+
size?: TableSize
|
|
34
|
+
/** Selection mode */
|
|
35
|
+
selectionMode?: SelectionMode
|
|
36
|
+
/** Enable hoverable rows */
|
|
37
|
+
hoverable?: boolean
|
|
38
|
+
/** Enable sticky header */
|
|
39
|
+
stickyHeader?: boolean
|
|
40
|
+
/** Sticky header offset (for fixed navbars) */
|
|
41
|
+
stickyOffset?: string
|
|
42
|
+
/** Enable row animations */
|
|
43
|
+
animateRows?: boolean
|
|
44
|
+
/** Loading state */
|
|
45
|
+
loading?: boolean
|
|
46
|
+
/** Number of skeleton rows when loading */
|
|
47
|
+
skeletonRows?: number
|
|
48
|
+
/** Enable pagination */
|
|
49
|
+
pagination?: boolean
|
|
50
|
+
/** Page size options */
|
|
51
|
+
pageSizeOptions?: number[]
|
|
52
|
+
/** Initial page size */
|
|
53
|
+
pageSize?: number
|
|
54
|
+
/** Enable multi-select (requires selectionMode="multiple") */
|
|
55
|
+
multiSelect?: boolean
|
|
56
|
+
/** Initial sort state */
|
|
57
|
+
initialSort?: SortState
|
|
58
|
+
/** Custom table class */
|
|
59
|
+
tableClass?: string
|
|
60
|
+
/** Fixed table layout */
|
|
61
|
+
fixedLayout?: boolean
|
|
62
|
+
/** Max height for scrollable body */
|
|
63
|
+
maxHeight?: string
|
|
64
|
+
/** Empty state message */
|
|
65
|
+
emptyMessage?: string
|
|
66
|
+
/** Empty state icon */
|
|
67
|
+
emptyIcon?: string
|
|
68
|
+
/** Caption for accessibility */
|
|
69
|
+
caption?: string
|
|
70
|
+
/** Caption placement */
|
|
71
|
+
captionSide?: 'top' | 'bottom'
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
75
|
+
data: () => [],
|
|
76
|
+
columns: () => [],
|
|
77
|
+
rowKey: undefined,
|
|
78
|
+
variant: 'default',
|
|
79
|
+
size: 'md',
|
|
80
|
+
selectionMode: 'none',
|
|
81
|
+
hoverable: true,
|
|
82
|
+
stickyHeader: false,
|
|
83
|
+
stickyOffset: '0px',
|
|
84
|
+
animateRows: true,
|
|
85
|
+
loading: false,
|
|
86
|
+
skeletonRows: 5,
|
|
87
|
+
pagination: false,
|
|
88
|
+
pageSizeOptions: () => [10, 25, 50, 100],
|
|
89
|
+
pageSize: 10,
|
|
90
|
+
multiSelect: false,
|
|
91
|
+
initialSort: undefined,
|
|
92
|
+
tableClass: '',
|
|
93
|
+
fixedLayout: false,
|
|
94
|
+
maxHeight: undefined,
|
|
95
|
+
emptyMessage: 'No data available',
|
|
96
|
+
emptyIcon: 'mdi-table-off',
|
|
97
|
+
caption: undefined,
|
|
98
|
+
captionSide: 'top'
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
const emit = defineEmits<{
|
|
102
|
+
'update:selected': [keys: (string | number)[]]
|
|
103
|
+
'row-click': [row: T, index: number, event: MouseEvent]
|
|
104
|
+
'row-dblclick': [row: T, index: number, event: MouseEvent]
|
|
105
|
+
'sort-change': [state: SortState]
|
|
106
|
+
'selection-change': [selectedRows: T[], selectedKeys: (string | number)[]]
|
|
107
|
+
'page-change': [page: number]
|
|
108
|
+
'page-size-change': [size: number]
|
|
109
|
+
'expanded-change': [expandedKeys: (string | number)[]]
|
|
110
|
+
}>()
|
|
111
|
+
|
|
112
|
+
// Initialize the headless table logic
|
|
113
|
+
const table = useDataTable<T>({
|
|
114
|
+
data: toRef(props, 'data'),
|
|
115
|
+
columns: toRef(props, 'columns'),
|
|
116
|
+
rowKey: props.rowKey,
|
|
117
|
+
initialSort: props.initialSort,
|
|
118
|
+
pagination: props.pagination ? { pageSize: props.pageSize } : false,
|
|
119
|
+
multiSelect: props.multiSelect
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
// Sync loading state
|
|
123
|
+
const loadingRef = ref(props.loading)
|
|
124
|
+
watch(() => props.loading, (val) => {
|
|
125
|
+
loadingRef.value = val
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
// Watch for external changes and emit events
|
|
129
|
+
watch(table.sortState, (state) => {
|
|
130
|
+
emit('sort-change', state)
|
|
131
|
+
}, { deep: true })
|
|
132
|
+
|
|
133
|
+
watch(table.selectedKeys, () => {
|
|
134
|
+
emit('selection-change', table.selectedRows.value, Array.from(table.selectedKeys.value))
|
|
135
|
+
emit('update:selected', Array.from(table.selectedKeys.value))
|
|
136
|
+
}, { deep: true })
|
|
137
|
+
|
|
138
|
+
watch(table.expandedKeys, () => {
|
|
139
|
+
emit('expanded-change', Array.from(table.expandedKeys.value))
|
|
140
|
+
}, { deep: true })
|
|
141
|
+
|
|
142
|
+
watch(() => table.pagination.value.page, (page) => {
|
|
143
|
+
emit('page-change', page)
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
// Provide context to children
|
|
147
|
+
provide(SDataTableContextKey, {
|
|
148
|
+
variant: props.variant,
|
|
149
|
+
size: props.size,
|
|
150
|
+
selectionMode: props.selectionMode,
|
|
151
|
+
loading: loadingRef,
|
|
152
|
+
hoverable: props.hoverable,
|
|
153
|
+
stickyHeader: props.stickyHeader,
|
|
154
|
+
animateRows: props.animateRows,
|
|
155
|
+
columns: table.columns,
|
|
156
|
+
visibleColumns: table.visibleColumns,
|
|
157
|
+
sortState: table.sortState,
|
|
158
|
+
selectedKeys: table.selectedKeys,
|
|
159
|
+
expandedKeys: table.expandedKeys,
|
|
160
|
+
getRowKey: table.getRowKey,
|
|
161
|
+
toggleSort: table.toggleSort,
|
|
162
|
+
toggleRowSelection: table.toggleRowSelection,
|
|
163
|
+
toggleAllSelection: table.toggleAllSelection,
|
|
164
|
+
toggleRowExpansion: table.toggleRowExpansion,
|
|
165
|
+
isRowSelected: table.isRowSelected,
|
|
166
|
+
isRowExpanded: table.isRowExpanded,
|
|
167
|
+
isAllSelected: table.isAllSelected,
|
|
168
|
+
isSomeSelected: table.isSomeSelected,
|
|
169
|
+
showColumn: table.showColumn,
|
|
170
|
+
hideColumn: table.hideColumn,
|
|
171
|
+
toggleColumn: table.toggleColumn
|
|
172
|
+
})
|
|
173
|
+
|
|
174
|
+
// Computed classes
|
|
175
|
+
const wrapperClasses = computed(() => {
|
|
176
|
+
return [
|
|
177
|
+
's-data-table-wrapper',
|
|
178
|
+
'relative overflow-hidden rounded-xl',
|
|
179
|
+
{
|
|
180
|
+
'border border-border': props.variant === 'bordered',
|
|
181
|
+
}
|
|
182
|
+
]
|
|
183
|
+
})
|
|
184
|
+
|
|
185
|
+
const tableClasses = computed(() => {
|
|
186
|
+
const base = 'w-full border-collapse'
|
|
187
|
+
|
|
188
|
+
const variants: Record<TableVariant, string> = {
|
|
189
|
+
default: 's-table-default',
|
|
190
|
+
compact: 's-table-compact',
|
|
191
|
+
bordered: 's-table-bordered',
|
|
192
|
+
striped: 's-table-striped',
|
|
193
|
+
minimal: 's-table-minimal'
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const sizes: Record<TableSize, string> = {
|
|
197
|
+
sm: 's-table-sm',
|
|
198
|
+
md: 's-table-md',
|
|
199
|
+
lg: 's-table-lg'
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return [
|
|
203
|
+
base,
|
|
204
|
+
variants[props.variant],
|
|
205
|
+
sizes[props.size],
|
|
206
|
+
props.tableClass,
|
|
207
|
+
{
|
|
208
|
+
'table-fixed': props.fixedLayout
|
|
209
|
+
}
|
|
210
|
+
]
|
|
211
|
+
})
|
|
212
|
+
|
|
213
|
+
const containerStyles = computed(() => {
|
|
214
|
+
const styles: Record<string, string> = {}
|
|
215
|
+
if (props.maxHeight) {
|
|
216
|
+
styles.maxHeight = props.maxHeight
|
|
217
|
+
styles.overflowY = 'auto'
|
|
218
|
+
}
|
|
219
|
+
return styles
|
|
220
|
+
})
|
|
221
|
+
|
|
222
|
+
// Row click handlers
|
|
223
|
+
const handleRowClick = (row: T, index: number, event: MouseEvent) => {
|
|
224
|
+
emit('row-click', row, index, event)
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const handleRowDblClick = (row: T, index: number, event: MouseEvent) => {
|
|
228
|
+
emit('row-dblclick', row, index, event)
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// Expose table methods
|
|
232
|
+
defineExpose({
|
|
233
|
+
...table,
|
|
234
|
+
refresh: table.refresh,
|
|
235
|
+
selectAll: table.selectAll,
|
|
236
|
+
deselectAll: table.deselectAll,
|
|
237
|
+
expandAll: table.expandAll,
|
|
238
|
+
collapseAll: table.collapseAll
|
|
239
|
+
})
|
|
240
|
+
</script>
|
|
241
|
+
|
|
242
|
+
<template>
|
|
243
|
+
<div
|
|
244
|
+
v-bind="$attrs"
|
|
245
|
+
:class="cn(wrapperClasses, $attrs.class ?? '')"
|
|
246
|
+
:style="containerStyles"
|
|
247
|
+
role="region"
|
|
248
|
+
:aria-busy="loading"
|
|
249
|
+
aria-live="polite"
|
|
250
|
+
>
|
|
251
|
+
<!-- Toolbar slot -->
|
|
252
|
+
<slot name="toolbar" :table="table" />
|
|
253
|
+
|
|
254
|
+
<!-- Table container -->
|
|
255
|
+
<div
|
|
256
|
+
class="s-table-container overflow-x-auto"
|
|
257
|
+
:class="{ 's-table-scrollable': maxHeight }"
|
|
258
|
+
>
|
|
259
|
+
<table
|
|
260
|
+
:class="tableClasses"
|
|
261
|
+
role="table"
|
|
262
|
+
>
|
|
263
|
+
<!-- Caption for accessibility -->
|
|
264
|
+
<caption
|
|
265
|
+
v-if="caption"
|
|
266
|
+
class="sr-only"
|
|
267
|
+
:style="{ captionSide }"
|
|
268
|
+
>
|
|
269
|
+
{{ caption }}
|
|
270
|
+
</caption>
|
|
271
|
+
|
|
272
|
+
<!-- Header slot or default -->
|
|
273
|
+
<slot name="header" :columns="table.visibleColumns.value" :table="table">
|
|
274
|
+
<thead
|
|
275
|
+
class="s-table-head"
|
|
276
|
+
:class="{
|
|
277
|
+
'sticky z-10': stickyHeader,
|
|
278
|
+
'bg-background': stickyHeader
|
|
279
|
+
}"
|
|
280
|
+
:style="stickyHeader ? { top: stickyOffset } : {}"
|
|
281
|
+
>
|
|
282
|
+
<tr>
|
|
283
|
+
<!-- Selection column -->
|
|
284
|
+
<th
|
|
285
|
+
v-if="selectionMode !== 'none'"
|
|
286
|
+
class="s-table-th s-table-th-select w-12"
|
|
287
|
+
scope="col"
|
|
288
|
+
>
|
|
289
|
+
<slot name="select-header" :table="table">
|
|
290
|
+
<div
|
|
291
|
+
v-if="selectionMode === 'multiple'"
|
|
292
|
+
class="flex items-center justify-center"
|
|
293
|
+
>
|
|
294
|
+
<input
|
|
295
|
+
type="checkbox"
|
|
296
|
+
class="s-table-checkbox"
|
|
297
|
+
:checked="table.isAllSelected.value"
|
|
298
|
+
:indeterminate="table.isSomeSelected.value"
|
|
299
|
+
@change="table.toggleAllSelection()"
|
|
300
|
+
aria-label="Select all rows"
|
|
301
|
+
/>
|
|
302
|
+
</div>
|
|
303
|
+
</slot>
|
|
304
|
+
</th>
|
|
305
|
+
|
|
306
|
+
<!-- Column headers -->
|
|
307
|
+
<th
|
|
308
|
+
v-for="column in table.visibleColumns.value"
|
|
309
|
+
:key="column.key"
|
|
310
|
+
class="s-table-th"
|
|
311
|
+
:class="[
|
|
312
|
+
column.headerClass,
|
|
313
|
+
{
|
|
314
|
+
's-table-th-sortable cursor-pointer select-none': column.sortable,
|
|
315
|
+
's-table-th-sorted': table.sortState.value.column === column.key,
|
|
316
|
+
'text-left': column.align === 'left' || !column.align,
|
|
317
|
+
'text-center': column.align === 'center',
|
|
318
|
+
'text-right': column.align === 'right',
|
|
319
|
+
'sticky left-0 z-5 bg-background': column.sticky === 'left',
|
|
320
|
+
'sticky right-0 z-5 bg-background': column.sticky === 'right'
|
|
321
|
+
}
|
|
322
|
+
]"
|
|
323
|
+
:style="{
|
|
324
|
+
width: column.width,
|
|
325
|
+
minWidth: column.minWidth,
|
|
326
|
+
maxWidth: column.maxWidth
|
|
327
|
+
}"
|
|
328
|
+
scope="col"
|
|
329
|
+
:aria-sort="
|
|
330
|
+
table.sortState.value.column === column.key
|
|
331
|
+
? (table.sortState.value.direction === 'asc' ? 'ascending' : 'descending')
|
|
332
|
+
: undefined
|
|
333
|
+
"
|
|
334
|
+
@click="column.sortable ? table.toggleSort(column.key) : undefined"
|
|
335
|
+
@keydown.enter="column.sortable ? table.toggleSort(column.key) : undefined"
|
|
336
|
+
@keydown.space.prevent="column.sortable ? table.toggleSort(column.key) : undefined"
|
|
337
|
+
:tabindex="column.sortable ? 0 : undefined"
|
|
338
|
+
>
|
|
339
|
+
<slot
|
|
340
|
+
:name="`header-${column.key}`"
|
|
341
|
+
:column="column"
|
|
342
|
+
:sort-state="table.sortState.value"
|
|
343
|
+
>
|
|
344
|
+
<div class="flex items-center gap-2" :class="{ 'justify-center': column.align === 'center', 'justify-end': column.align === 'right' }">
|
|
345
|
+
<span>{{ column.label || column.key }}</span>
|
|
346
|
+
|
|
347
|
+
<!-- Sort indicator -->
|
|
348
|
+
<span
|
|
349
|
+
v-if="column.sortable"
|
|
350
|
+
class="s-table-sort-icon inline-flex flex-col text-xs leading-none opacity-40 transition-opacity"
|
|
351
|
+
:class="{ 'opacity-100': table.sortState.value.column === column.key }"
|
|
352
|
+
>
|
|
353
|
+
<span
|
|
354
|
+
class="mdi mdi-chevron-up transition-transform"
|
|
355
|
+
:class="{
|
|
356
|
+
'text-primary': table.sortState.value.column === column.key && table.sortState.value.direction === 'asc',
|
|
357
|
+
'-mb-1.5': true
|
|
358
|
+
}"
|
|
359
|
+
/>
|
|
360
|
+
<span
|
|
361
|
+
class="mdi mdi-chevron-down transition-transform"
|
|
362
|
+
:class="{
|
|
363
|
+
'text-primary': table.sortState.value.column === column.key && table.sortState.value.direction === 'desc'
|
|
364
|
+
}"
|
|
365
|
+
/>
|
|
366
|
+
</span>
|
|
367
|
+
</div>
|
|
368
|
+
</slot>
|
|
369
|
+
</th>
|
|
370
|
+
|
|
371
|
+
<!-- Actions column -->
|
|
372
|
+
<th
|
|
373
|
+
v-if="$slots['row-actions']"
|
|
374
|
+
class="s-table-th s-table-th-actions"
|
|
375
|
+
scope="col"
|
|
376
|
+
>
|
|
377
|
+
<span class="sr-only">Actions</span>
|
|
378
|
+
</th>
|
|
379
|
+
</tr>
|
|
380
|
+
</thead>
|
|
381
|
+
</slot>
|
|
382
|
+
|
|
383
|
+
<!-- Body -->
|
|
384
|
+
<tbody class="s-table-body">
|
|
385
|
+
<!-- Loading state -->
|
|
386
|
+
<template v-if="loading">
|
|
387
|
+
<slot name="loading" :skeleton-rows="skeletonRows">
|
|
388
|
+
<tr
|
|
389
|
+
v-for="i in skeletonRows"
|
|
390
|
+
:key="`skeleton-${i}`"
|
|
391
|
+
class="s-table-row s-table-row-skeleton"
|
|
392
|
+
>
|
|
393
|
+
<td
|
|
394
|
+
v-if="selectionMode !== 'none'"
|
|
395
|
+
class="s-table-td"
|
|
396
|
+
>
|
|
397
|
+
<div class="s-skeleton w-4 h-4 rounded" />
|
|
398
|
+
</td>
|
|
399
|
+
<td
|
|
400
|
+
v-for="column in table.visibleColumns.value"
|
|
401
|
+
:key="column.key"
|
|
402
|
+
class="s-table-td"
|
|
403
|
+
>
|
|
404
|
+
<div class="s-skeleton h-4 rounded" :style="{ width: `${60 + Math.random() * 40}%` }" />
|
|
405
|
+
</td>
|
|
406
|
+
<td v-if="$slots['row-actions']" class="s-table-td">
|
|
407
|
+
<div class="s-skeleton w-8 h-4 rounded" />
|
|
408
|
+
</td>
|
|
409
|
+
</tr>
|
|
410
|
+
</slot>
|
|
411
|
+
</template>
|
|
412
|
+
|
|
413
|
+
<!-- Empty state -->
|
|
414
|
+
<template v-else-if="table.paginatedData.value.length === 0">
|
|
415
|
+
<tr>
|
|
416
|
+
<td
|
|
417
|
+
:colspan="table.visibleColumns.value.length + (selectionMode !== 'none' ? 1 : 0) + ($slots['row-actions'] ? 1 : 0)"
|
|
418
|
+
class="s-table-td"
|
|
419
|
+
>
|
|
420
|
+
<slot name="empty">
|
|
421
|
+
<div class="s-table-empty flex flex-col items-center justify-center py-12 text-muted-foreground">
|
|
422
|
+
<span :class="['mdi', emptyIcon, 'text-4xl mb-3 opacity-50']" />
|
|
423
|
+
<p class="text-sm">{{ emptyMessage }}</p>
|
|
424
|
+
</div>
|
|
425
|
+
</slot>
|
|
426
|
+
</td>
|
|
427
|
+
</tr>
|
|
428
|
+
</template>
|
|
429
|
+
|
|
430
|
+
<!-- Data rows - using key on the wrapper to force clean re-render on page change -->
|
|
431
|
+
<template v-else v-for="(row, index) in table.paginatedData.value" :key="`${table.pagination.value.page}-${table.getRowKey(row, index)}`">
|
|
432
|
+
<tr
|
|
433
|
+
class="s-table-row"
|
|
434
|
+
:class="{
|
|
435
|
+
's-table-row-hoverable': hoverable,
|
|
436
|
+
's-table-row-selected': table.isRowSelected(table.getRowKey(row, index)),
|
|
437
|
+
's-table-row-expanded': table.isRowExpanded(table.getRowKey(row, index)),
|
|
438
|
+
's-table-row-even': index % 2 === 1 && variant === 'striped'
|
|
439
|
+
}"
|
|
440
|
+
:data-row-key="table.getRowKey(row, index)"
|
|
441
|
+
:aria-selected="selectionMode !== 'none' ? table.isRowSelected(table.getRowKey(row, index)) : undefined"
|
|
442
|
+
@click="handleRowClick(row, index, $event)"
|
|
443
|
+
@dblclick="handleRowDblClick(row, index, $event)"
|
|
444
|
+
>
|
|
445
|
+
<!-- Selection cell -->
|
|
446
|
+
<td
|
|
447
|
+
v-if="selectionMode !== 'none'"
|
|
448
|
+
class="s-table-td s-table-td-select"
|
|
449
|
+
@click.stop
|
|
450
|
+
>
|
|
451
|
+
<slot
|
|
452
|
+
name="select-cell"
|
|
453
|
+
:row="row"
|
|
454
|
+
:index="index"
|
|
455
|
+
:selected="table.isRowSelected(table.getRowKey(row, index))"
|
|
456
|
+
:toggle="() => table.toggleRowSelection(table.getRowKey(row, index))"
|
|
457
|
+
>
|
|
458
|
+
<div class="flex items-center justify-center">
|
|
459
|
+
<input
|
|
460
|
+
:type="selectionMode === 'multiple' ? 'checkbox' : 'radio'"
|
|
461
|
+
class="s-table-checkbox"
|
|
462
|
+
:checked="table.isRowSelected(table.getRowKey(row, index))"
|
|
463
|
+
@change="table.toggleRowSelection(table.getRowKey(row, index))"
|
|
464
|
+
:aria-label="`Select row ${index + 1}`"
|
|
465
|
+
/>
|
|
466
|
+
</div>
|
|
467
|
+
</slot>
|
|
468
|
+
</td>
|
|
469
|
+
|
|
470
|
+
<!-- Data cells -->
|
|
471
|
+
<td
|
|
472
|
+
v-for="column in table.visibleColumns.value"
|
|
473
|
+
:key="column.key"
|
|
474
|
+
class="s-table-td"
|
|
475
|
+
:class="[
|
|
476
|
+
column.cellClass,
|
|
477
|
+
{
|
|
478
|
+
'text-left': column.align === 'left' || !column.align,
|
|
479
|
+
'text-center': column.align === 'center',
|
|
480
|
+
'text-right': column.align === 'right',
|
|
481
|
+
'sticky left-0 bg-background': column.sticky === 'left',
|
|
482
|
+
'sticky right-0 bg-background': column.sticky === 'right'
|
|
483
|
+
}
|
|
484
|
+
]"
|
|
485
|
+
:style="{
|
|
486
|
+
width: column.width,
|
|
487
|
+
minWidth: column.minWidth,
|
|
488
|
+
maxWidth: column.maxWidth
|
|
489
|
+
}"
|
|
490
|
+
>
|
|
491
|
+
<slot
|
|
492
|
+
:name="`cell-${column.key}`"
|
|
493
|
+
:row="row"
|
|
494
|
+
:column="column"
|
|
495
|
+
:index="index"
|
|
496
|
+
:value="getCellValue(row, column)"
|
|
497
|
+
>
|
|
498
|
+
{{ getCellValue(row, column) }}
|
|
499
|
+
</slot>
|
|
500
|
+
</td>
|
|
501
|
+
|
|
502
|
+
<!-- Actions cell -->
|
|
503
|
+
<td
|
|
504
|
+
v-if="$slots['row-actions']"
|
|
505
|
+
class="s-table-td s-table-td-actions"
|
|
506
|
+
@click.stop
|
|
507
|
+
>
|
|
508
|
+
<slot name="row-actions" :row="row" :index="index" />
|
|
509
|
+
</td>
|
|
510
|
+
</tr>
|
|
511
|
+
|
|
512
|
+
<!-- Expanded content row -->
|
|
513
|
+
<tr
|
|
514
|
+
v-if="table.isRowExpanded(table.getRowKey(row, index)) && $slots['expanded']"
|
|
515
|
+
:key="`expanded-${table.pagination.value.page}-${table.getRowKey(row, index)}`"
|
|
516
|
+
class="s-table-row-expansion"
|
|
517
|
+
>
|
|
518
|
+
<td
|
|
519
|
+
:colspan="table.visibleColumns.value.length + (selectionMode !== 'none' ? 1 : 0) + ($slots['row-actions'] ? 1 : 0)"
|
|
520
|
+
class="s-table-td-expansion"
|
|
521
|
+
>
|
|
522
|
+
<slot name="expanded" :row="row" :index="index" />
|
|
523
|
+
</td>
|
|
524
|
+
</tr>
|
|
525
|
+
</template>
|
|
526
|
+
</tbody>
|
|
527
|
+
|
|
528
|
+
<!-- Footer -->
|
|
529
|
+
<slot name="footer" :table="table" />
|
|
530
|
+
</table>
|
|
531
|
+
</div>
|
|
532
|
+
|
|
533
|
+
<!-- Pagination slot -->
|
|
534
|
+
<slot
|
|
535
|
+
name="pagination"
|
|
536
|
+
:table="table"
|
|
537
|
+
:page="table.pagination.value.page"
|
|
538
|
+
:page-size="table.pagination.value.pageSize"
|
|
539
|
+
:total="table.pagination.value.total || table.processedData.value.length"
|
|
540
|
+
:total-pages="table.totalPages.value"
|
|
541
|
+
:go-to-page="table.goToPage"
|
|
542
|
+
:next-page="table.nextPage"
|
|
543
|
+
:prev-page="table.prevPage"
|
|
544
|
+
:set-page-size="(size: number) => { table.setPageSize(size); emit('page-size-change', size) }"
|
|
545
|
+
>
|
|
546
|
+
<SPagination
|
|
547
|
+
v-if="pagination && !loading && table.paginatedData.value.length > 0"
|
|
548
|
+
:model-value="table.pagination.value.page"
|
|
549
|
+
:total="table.pagination.value.total || table.processedData.value.length"
|
|
550
|
+
:page-size="table.pagination.value.pageSize"
|
|
551
|
+
:page-size-options="pageSizeOptions"
|
|
552
|
+
show-total
|
|
553
|
+
show-page-size
|
|
554
|
+
show-first-last
|
|
555
|
+
size="sm"
|
|
556
|
+
class="px-4 py-3 border-t border-border justify-between"
|
|
557
|
+
@update:model-value="(page: number) => { table.goToPage(page); emit('page-change', page) }"
|
|
558
|
+
@update:page-size="(size: number) => { table.setPageSize(size); emit('page-size-change', size) }"
|
|
559
|
+
/>
|
|
560
|
+
</slot>
|
|
561
|
+
|
|
562
|
+
<!-- Loading overlay -->
|
|
563
|
+
<Transition name="fade">
|
|
564
|
+
<div
|
|
565
|
+
v-if="loading && table.paginatedData.value.length > 0"
|
|
566
|
+
class="absolute inset-0 bg-background/60 backdrop-blur-sm flex items-center justify-center z-20"
|
|
567
|
+
>
|
|
568
|
+
<div class="flex items-center gap-3">
|
|
569
|
+
<span class="mdi mdi-loading animate-spin text-xl text-primary" />
|
|
570
|
+
<span class="text-sm text-muted-foreground">Loading...</span>
|
|
571
|
+
</div>
|
|
572
|
+
</div>
|
|
573
|
+
</Transition>
|
|
574
|
+
</div>
|
|
575
|
+
</template>
|
|
576
|
+
|
|
577
|
+
<script lang="ts">
|
|
578
|
+
import type { TableColumn } from './index'
|
|
579
|
+
|
|
580
|
+
// Helper to get cell value
|
|
581
|
+
function getCellValue<T>(row: T, column: TableColumn<T>): unknown {
|
|
582
|
+
if (typeof column.accessor === 'function') {
|
|
583
|
+
return column.accessor(row, 0)
|
|
584
|
+
}
|
|
585
|
+
if (column.accessor) {
|
|
586
|
+
return (row as Record<string, unknown>)[column.accessor as string]
|
|
587
|
+
}
|
|
588
|
+
return (row as Record<string, unknown>)[column.key]
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
// Check for reduced motion preference
|
|
592
|
+
const prefersReducedMotion = typeof window !== 'undefined'
|
|
593
|
+
? window.matchMedia('(prefers-reduced-motion: reduce)').matches
|
|
594
|
+
: false
|
|
595
|
+
</script>
|
|
596
|
+
|
|
597
|
+
<style scoped>
|
|
598
|
+
/* ===== CSS Variables ===== */
|
|
599
|
+
.s-data-table-wrapper {
|
|
600
|
+
--table-header-bg: var(--s-muted);
|
|
601
|
+
--table-row-hover: var(--s-accent);
|
|
602
|
+
--table-row-selected: color-mix(in srgb, var(--s-primary) 15%, transparent);
|
|
603
|
+
--table-border-color: var(--s-border);
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
/* ===== Base Table Styles ===== */
|
|
607
|
+
.s-table-head {
|
|
608
|
+
background-color: var(--table-header-bg);
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
.s-table-th {
|
|
612
|
+
font-weight: 600;
|
|
613
|
+
font-size: 0.75rem;
|
|
614
|
+
text-transform: uppercase;
|
|
615
|
+
letter-spacing: 0.05em;
|
|
616
|
+
color: var(--s-muted-foreground);
|
|
617
|
+
white-space: nowrap;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
.s-table-td {
|
|
621
|
+
color: var(--s-foreground);
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
/* ===== Size Variants ===== */
|
|
625
|
+
.s-table-sm .s-table-th,
|
|
626
|
+
.s-table-sm .s-table-td {
|
|
627
|
+
padding: 0.5rem 0.75rem;
|
|
628
|
+
font-size: 0.8125rem;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
.s-table-md .s-table-th,
|
|
632
|
+
.s-table-md .s-table-td {
|
|
633
|
+
padding: 0.75rem 1rem;
|
|
634
|
+
font-size: 0.875rem;
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
.s-table-lg .s-table-th,
|
|
638
|
+
.s-table-lg .s-table-td {
|
|
639
|
+
padding: 1rem 1.25rem;
|
|
640
|
+
font-size: 0.9375rem;
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
/* ===== Variant Styles ===== */
|
|
644
|
+
|
|
645
|
+
/* Default */
|
|
646
|
+
.s-table-default .s-table-row {
|
|
647
|
+
border-bottom: 1px solid var(--table-border-color);
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
/* Compact */
|
|
651
|
+
.s-table-compact .s-table-th,
|
|
652
|
+
.s-table-compact .s-table-td {
|
|
653
|
+
padding: 0.375rem 0.5rem;
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
/* Bordered */
|
|
657
|
+
.s-table-bordered .s-table-th,
|
|
658
|
+
.s-table-bordered .s-table-td {
|
|
659
|
+
border: 1px solid var(--table-border-color);
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
/* Striped */
|
|
663
|
+
.s-table-striped .s-table-row-even {
|
|
664
|
+
background-color: var(--s-muted);
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
/* Minimal */
|
|
668
|
+
.s-table-minimal .s-table-head {
|
|
669
|
+
background-color: transparent;
|
|
670
|
+
border-bottom: 2px solid var(--table-border-color);
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
.s-table-minimal .s-table-th {
|
|
674
|
+
font-weight: 500;
|
|
675
|
+
text-transform: none;
|
|
676
|
+
letter-spacing: normal;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
/* ===== Row States ===== */
|
|
680
|
+
.s-table-row-hoverable {
|
|
681
|
+
transition: background-color 0.15s ease;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
.s-table-row-hoverable:hover {
|
|
685
|
+
background-color: var(--table-row-hover);
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
.s-table-row-selected {
|
|
689
|
+
background-color: var(--table-row-selected) !important;
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
.s-table-row-selected:hover {
|
|
693
|
+
background-color: var(--table-row-selected) !important;
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
/* ===== Sortable Header ===== */
|
|
697
|
+
.s-table-th-sortable {
|
|
698
|
+
transition: background-color 0.15s ease;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
.s-table-th-sortable:hover {
|
|
702
|
+
background-color: var(--s-accent);
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
.s-table-th-sortable:focus-visible {
|
|
706
|
+
outline: 2px solid var(--s-primary);
|
|
707
|
+
outline-offset: -2px;
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
/* ===== Checkbox ===== */
|
|
711
|
+
.s-table-checkbox {
|
|
712
|
+
width: 1rem;
|
|
713
|
+
height: 1rem;
|
|
714
|
+
accent-color: var(--s-primary);
|
|
715
|
+
cursor: pointer;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
.s-table-checkbox:focus-visible {
|
|
719
|
+
outline: 2px solid var(--s-primary);
|
|
720
|
+
outline-offset: 2px;
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
/* ===== Skeleton Loading ===== */
|
|
724
|
+
.s-skeleton {
|
|
725
|
+
background: linear-gradient(
|
|
726
|
+
90deg,
|
|
727
|
+
var(--s-accent) 25%,
|
|
728
|
+
var(--s-muted) 50%,
|
|
729
|
+
var(--s-accent) 75%
|
|
730
|
+
);
|
|
731
|
+
background-size: 200% 100%;
|
|
732
|
+
animation: s-skeleton-shimmer 1.5s infinite;
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
@keyframes s-skeleton-shimmer {
|
|
736
|
+
0% {
|
|
737
|
+
background-position: 200% 0;
|
|
738
|
+
}
|
|
739
|
+
100% {
|
|
740
|
+
background-position: -200% 0;
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
/* ===== Row Animation ===== */
|
|
745
|
+
.s-table-row-enter-active,
|
|
746
|
+
.s-table-row-leave-active {
|
|
747
|
+
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
.s-table-row-enter-from {
|
|
751
|
+
opacity: 0;
|
|
752
|
+
transform: translateY(-10px);
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
.s-table-row-leave-to {
|
|
756
|
+
opacity: 0;
|
|
757
|
+
transform: translateX(-20px);
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
.s-table-row-move {
|
|
761
|
+
transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
/* ===== Fade Transition ===== */
|
|
765
|
+
.fade-enter-active,
|
|
766
|
+
.fade-leave-active {
|
|
767
|
+
transition: opacity 0.2s ease;
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
.fade-enter-from,
|
|
771
|
+
.fade-leave-to {
|
|
772
|
+
opacity: 0;
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
/* ===== Expansion Row ===== */
|
|
776
|
+
.s-table-td-expansion {
|
|
777
|
+
padding: 1rem;
|
|
778
|
+
background-color: var(--s-muted);
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
/* ===== Reduced Motion ===== */
|
|
782
|
+
@media (prefers-reduced-motion: reduce) {
|
|
783
|
+
.s-table-row-enter-active,
|
|
784
|
+
.s-table-row-leave-active,
|
|
785
|
+
.s-table-row-move {
|
|
786
|
+
transition: none;
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
.s-skeleton {
|
|
790
|
+
animation: none;
|
|
791
|
+
background: var(--s-accent);
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
/* ===== Scrollable Container ===== */
|
|
796
|
+
.s-table-scrollable {
|
|
797
|
+
overflow-y: auto;
|
|
798
|
+
scrollbar-width: thin;
|
|
799
|
+
scrollbar-color: var(--s-border) transparent;
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
.s-table-scrollable::-webkit-scrollbar {
|
|
803
|
+
width: 6px;
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
.s-table-scrollable::-webkit-scrollbar-track {
|
|
807
|
+
background: transparent;
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
.s-table-scrollable::-webkit-scrollbar-thumb {
|
|
811
|
+
background-color: var(--s-border);
|
|
812
|
+
border-radius: 3px;
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
|
|
816
|
+
/* ===== Screen Reader Only ===== */
|
|
817
|
+
.sr-only {
|
|
818
|
+
position: absolute;
|
|
819
|
+
width: 1px;
|
|
820
|
+
height: 1px;
|
|
821
|
+
padding: 0;
|
|
822
|
+
margin: -1px;
|
|
823
|
+
overflow: hidden;
|
|
824
|
+
clip: rect(0, 0, 0, 0);
|
|
825
|
+
white-space: nowrap;
|
|
826
|
+
border-width: 0;
|
|
827
|
+
}
|
|
828
|
+
</style>
|