@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,387 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cva, type VariantProps } from 'class-variance-authority'
|
|
3
|
+
|
|
4
|
+
export const buttonVariants = cva(
|
|
5
|
+
'relative inline-flex items-center justify-center font-medium transition-all duration-200 ease-out overflow-hidden select-none focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 border-[1.5px] border-transparent',
|
|
6
|
+
{
|
|
7
|
+
variants: {
|
|
8
|
+
variant: {
|
|
9
|
+
filled: 'bg-primary text-primary-foreground hover:brightness-110 active:scale-[0.98]',
|
|
10
|
+
outlined: 'bg-transparent border-primary text-primary hover:bg-primary/10',
|
|
11
|
+
light: 'bg-primary/15 text-primary hover:bg-primary/25',
|
|
12
|
+
ghost: 'bg-transparent text-primary hover:bg-accent',
|
|
13
|
+
link: 'bg-transparent text-primary hover:underline',
|
|
14
|
+
},
|
|
15
|
+
size: {
|
|
16
|
+
xs: 'px-1.5 py-0.5 text-xs gap-1',
|
|
17
|
+
small: 'px-2 py-0.5 text-sm gap-1.5',
|
|
18
|
+
medium: 'px-2 py-0.5 text-sm gap-2',
|
|
19
|
+
large: 'px-2.5 py-0.5 text-base gap-2',
|
|
20
|
+
xl: 'px-3 py-0.5 text-lg gap-2.5',
|
|
21
|
+
},
|
|
22
|
+
rounded: {
|
|
23
|
+
none: 'rounded-none',
|
|
24
|
+
sm: 'rounded',
|
|
25
|
+
md: 'rounded-lg',
|
|
26
|
+
lg: 'rounded-xl',
|
|
27
|
+
full: 'rounded-full',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
defaultVariants: {
|
|
31
|
+
variant: 'filled',
|
|
32
|
+
size: 'medium',
|
|
33
|
+
rounded: 'md',
|
|
34
|
+
},
|
|
35
|
+
}
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
export type ButtonVariants = VariantProps<typeof buttonVariants>
|
|
39
|
+
|
|
40
|
+
export interface Props {
|
|
41
|
+
variant?: 'filled' | 'outlined' | 'light' | 'ghost' | 'link'
|
|
42
|
+
size?: 'xs' | 'small' | 'medium' | 'large' | 'xl'
|
|
43
|
+
color?: string
|
|
44
|
+
disabled?: boolean
|
|
45
|
+
loading?: boolean
|
|
46
|
+
preserveSize?: boolean
|
|
47
|
+
block?: boolean
|
|
48
|
+
rounded?: 'none' | 'sm' | 'md' | 'lg' | 'full'
|
|
49
|
+
iconLeft?: string
|
|
50
|
+
iconRight?: string
|
|
51
|
+
iconOnly?: boolean
|
|
52
|
+
tag?: string
|
|
53
|
+
href?: string
|
|
54
|
+
to?: string | object
|
|
55
|
+
type?: 'button' | 'submit' | 'reset'
|
|
56
|
+
ripple?: boolean
|
|
57
|
+
animationType?: 'slide' | 'vertical' | 'scale' | 'rotate'
|
|
58
|
+
animateInactive?: boolean
|
|
59
|
+
contentClass?: string
|
|
60
|
+
iconClass?: string
|
|
61
|
+
}
|
|
62
|
+
</script>
|
|
63
|
+
|
|
64
|
+
<script setup lang="ts">
|
|
65
|
+
import { computed, ref, useSlots, type CSSProperties } from 'vue'
|
|
66
|
+
import { cn } from '../../lib/utils'
|
|
67
|
+
|
|
68
|
+
const iconOnlySizes: Record<string, string> = {
|
|
69
|
+
xs: 'w-6 h-6 text-xs',
|
|
70
|
+
small: 'w-8 h-8 text-sm',
|
|
71
|
+
medium: 'w-10 h-10 text-base',
|
|
72
|
+
large: 'w-12 h-12 text-lg',
|
|
73
|
+
xl: 'w-14 h-14 text-xl',
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
77
|
+
variant: 'filled',
|
|
78
|
+
size: 'medium',
|
|
79
|
+
color: undefined,
|
|
80
|
+
disabled: false,
|
|
81
|
+
loading: false,
|
|
82
|
+
preserveSize: false,
|
|
83
|
+
block: false,
|
|
84
|
+
rounded: 'md',
|
|
85
|
+
iconLeft: undefined,
|
|
86
|
+
iconRight: undefined,
|
|
87
|
+
iconOnly: false,
|
|
88
|
+
tag: 'button',
|
|
89
|
+
href: undefined,
|
|
90
|
+
to: undefined,
|
|
91
|
+
type: 'button',
|
|
92
|
+
ripple: true,
|
|
93
|
+
animationType: 'slide',
|
|
94
|
+
animateInactive: false,
|
|
95
|
+
contentClass: undefined,
|
|
96
|
+
iconClass: undefined,
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
defineOptions({ inheritAttrs: false })
|
|
100
|
+
|
|
101
|
+
const slots = useSlots()
|
|
102
|
+
const hasAnimateSlot = computed(() => !!slots.animate)
|
|
103
|
+
|
|
104
|
+
const emit = defineEmits<{
|
|
105
|
+
click: [event: MouseEvent]
|
|
106
|
+
}>()
|
|
107
|
+
|
|
108
|
+
// Ripple effect state
|
|
109
|
+
const ripples = ref<{ id: number; x: number; y: number; size: number }[]>([])
|
|
110
|
+
let rippleId = 0
|
|
111
|
+
|
|
112
|
+
const createRipple = (event: MouseEvent) => {
|
|
113
|
+
if (!props.ripple || props.disabled || props.loading) return
|
|
114
|
+
|
|
115
|
+
const button = event.currentTarget as HTMLElement
|
|
116
|
+
const rect = button.getBoundingClientRect()
|
|
117
|
+
const size = Math.max(rect.width, rect.height) * 2
|
|
118
|
+
const x = event.clientX - rect.left - size / 2
|
|
119
|
+
const y = event.clientY - rect.top - size / 2
|
|
120
|
+
|
|
121
|
+
const id = rippleId++
|
|
122
|
+
ripples.value.push({ id, x, y, size })
|
|
123
|
+
|
|
124
|
+
setTimeout(() => {
|
|
125
|
+
ripples.value = ripples.value.filter(r => r.id !== id)
|
|
126
|
+
}, 600)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const handleClick = (event: MouseEvent) => {
|
|
130
|
+
if (props.disabled || props.loading) {
|
|
131
|
+
event.preventDefault()
|
|
132
|
+
return
|
|
133
|
+
}
|
|
134
|
+
createRipple(event)
|
|
135
|
+
emit('click', event)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const handleKeydown = (event: KeyboardEvent) => {
|
|
139
|
+
if (props.disabled || props.loading) return
|
|
140
|
+
if (event.key === ' ' || event.key === 'Enter') {
|
|
141
|
+
event.preventDefault()
|
|
142
|
+
const mouseEvent = new MouseEvent('click', {
|
|
143
|
+
bubbles: true,
|
|
144
|
+
clientX: (event.target as HTMLElement).getBoundingClientRect().left + 20,
|
|
145
|
+
clientY: (event.target as HTMLElement).getBoundingClientRect().top + 20,
|
|
146
|
+
})
|
|
147
|
+
;(event.target as HTMLElement).dispatchEvent(mouseEvent)
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const componentTag = computed(() => {
|
|
152
|
+
if (props.to) return 'router-link'
|
|
153
|
+
if (props.href) return 'a'
|
|
154
|
+
return props.tag
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
const iconSizes = computed(() => {
|
|
158
|
+
const sizes: Record<string, string> = {
|
|
159
|
+
xs: 'text-xs',
|
|
160
|
+
small: 'text-sm',
|
|
161
|
+
medium: 'text-base',
|
|
162
|
+
large: 'text-lg',
|
|
163
|
+
xl: 'text-xl',
|
|
164
|
+
}
|
|
165
|
+
return sizes[props.size]
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
// Custom color override: when color prop is set, use inline styles for color-specific properties
|
|
169
|
+
const colorStyle = computed<CSSProperties | undefined>(() => {
|
|
170
|
+
if (!props.color) return undefined
|
|
171
|
+
|
|
172
|
+
const c = props.color
|
|
173
|
+
|
|
174
|
+
if (props.variant === 'filled') {
|
|
175
|
+
return { backgroundColor: c, color: '#fff', borderColor: 'transparent' }
|
|
176
|
+
} else if (props.variant === 'outlined') {
|
|
177
|
+
return { backgroundColor: 'transparent', borderColor: c, color: c }
|
|
178
|
+
} else if (props.variant === 'light') {
|
|
179
|
+
const bg = c.startsWith('var(') ? `color-mix(in srgb, ${c} 15%, transparent)` : `${c}20`
|
|
180
|
+
return { backgroundColor: bg, color: c, borderColor: 'transparent' }
|
|
181
|
+
} else if (props.variant === 'ghost') {
|
|
182
|
+
return { backgroundColor: 'transparent', color: c, borderColor: 'transparent' }
|
|
183
|
+
} else if (props.variant === 'link') {
|
|
184
|
+
return { backgroundColor: 'transparent', color: c, borderColor: 'transparent' }
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return undefined
|
|
188
|
+
})
|
|
189
|
+
|
|
190
|
+
const buttonClasses = computed(() => {
|
|
191
|
+
return cn(
|
|
192
|
+
// Base + size + rounded from cva; skip variant when color is set (inline style handles it)
|
|
193
|
+
buttonVariants({
|
|
194
|
+
variant: props.color ? null : props.variant,
|
|
195
|
+
size: props.iconOnly ? null : props.size,
|
|
196
|
+
rounded: props.rounded,
|
|
197
|
+
}),
|
|
198
|
+
props.iconOnly && iconOnlySizes[props.size],
|
|
199
|
+
// Hover/active interactions when color is set
|
|
200
|
+
props.color && props.variant === 'filled' && 'hover:brightness-110 active:scale-[0.98]',
|
|
201
|
+
props.color && props.variant === 'link' && 'hover:underline',
|
|
202
|
+
{
|
|
203
|
+
'w-full': props.block,
|
|
204
|
+
'opacity-50 cursor-not-allowed': props.disabled || props.loading,
|
|
205
|
+
'cursor-pointer': !props.disabled && !props.loading,
|
|
206
|
+
's-button--animate': hasAnimateSlot.value && !props.animateInactive,
|
|
207
|
+
[`s-button--animate-${props.animationType}`]: hasAnimateSlot.value && !props.animateInactive,
|
|
208
|
+
},
|
|
209
|
+
)
|
|
210
|
+
})
|
|
211
|
+
|
|
212
|
+
const componentBindings = computed(() => {
|
|
213
|
+
const bindings: Record<string, unknown> = {}
|
|
214
|
+
|
|
215
|
+
if (props.to) bindings.to = props.to
|
|
216
|
+
if (props.href) bindings.href = props.href
|
|
217
|
+
if (componentTag.value === 'button') bindings.type = props.type
|
|
218
|
+
if (props.disabled) bindings.disabled = true
|
|
219
|
+
|
|
220
|
+
return bindings
|
|
221
|
+
})
|
|
222
|
+
</script>
|
|
223
|
+
|
|
224
|
+
<template>
|
|
225
|
+
<component
|
|
226
|
+
:is="componentTag"
|
|
227
|
+
v-bind="{ ...componentBindings, ...$attrs }"
|
|
228
|
+
:class="cn(buttonClasses, ($attrs.class as string))"
|
|
229
|
+
:style="colorStyle"
|
|
230
|
+
@click="handleClick"
|
|
231
|
+
@keydown="handleKeydown"
|
|
232
|
+
>
|
|
233
|
+
<!-- Ripple effects -->
|
|
234
|
+
<span
|
|
235
|
+
v-for="ripple in ripples"
|
|
236
|
+
:key="ripple.id"
|
|
237
|
+
class="absolute rounded-full bg-white/30 animate-ripple pointer-events-none"
|
|
238
|
+
:style="{
|
|
239
|
+
left: `${ripple.x}px`,
|
|
240
|
+
top: `${ripple.y}px`,
|
|
241
|
+
width: `${ripple.size}px`,
|
|
242
|
+
height: `${ripple.size}px`,
|
|
243
|
+
}"
|
|
244
|
+
/>
|
|
245
|
+
|
|
246
|
+
<!-- Loading spinner (absolute when preserveSize) -->
|
|
247
|
+
<span
|
|
248
|
+
v-if="loading"
|
|
249
|
+
class="mdi mdi-loading animate-spin"
|
|
250
|
+
:class="[iconSizes, { 'absolute inset-0 flex items-center justify-center': preserveSize }]"
|
|
251
|
+
/>
|
|
252
|
+
|
|
253
|
+
<!-- Default content wrapper -->
|
|
254
|
+
<span
|
|
255
|
+
class="s-button__content flex items-center justify-center gap-2"
|
|
256
|
+
:class="[contentClass, { 'opacity-0': loading && preserveSize }]"
|
|
257
|
+
>
|
|
258
|
+
<template v-if="!loading || preserveSize">
|
|
259
|
+
<slot name="icon-left">
|
|
260
|
+
<span
|
|
261
|
+
v-if="iconLeft"
|
|
262
|
+
:class="['mdi', `mdi-${iconLeft}`, iconSizes, iconClass]"
|
|
263
|
+
/>
|
|
264
|
+
</slot>
|
|
265
|
+
</template>
|
|
266
|
+
|
|
267
|
+
<span v-if="!iconOnly && (!loading || preserveSize)">
|
|
268
|
+
<slot />
|
|
269
|
+
</span>
|
|
270
|
+
|
|
271
|
+
<template v-if="iconOnly && (!loading || preserveSize) && !iconLeft">
|
|
272
|
+
<slot />
|
|
273
|
+
</template>
|
|
274
|
+
|
|
275
|
+
<template v-if="!loading || preserveSize">
|
|
276
|
+
<slot name="icon-right">
|
|
277
|
+
<span
|
|
278
|
+
v-if="iconRight"
|
|
279
|
+
:class="['mdi', `mdi-${iconRight}`, iconSizes, iconClass]"
|
|
280
|
+
/>
|
|
281
|
+
</slot>
|
|
282
|
+
</template>
|
|
283
|
+
</span>
|
|
284
|
+
|
|
285
|
+
<!-- Animate slot content -->
|
|
286
|
+
<span
|
|
287
|
+
v-if="hasAnimateSlot"
|
|
288
|
+
class="s-button__animate flex items-center justify-center gap-2"
|
|
289
|
+
:class="[`s-button__animate--${animationType}`]"
|
|
290
|
+
>
|
|
291
|
+
<slot name="animate" />
|
|
292
|
+
</span>
|
|
293
|
+
</component>
|
|
294
|
+
</template>
|
|
295
|
+
|
|
296
|
+
<style scoped>
|
|
297
|
+
/* Ripple animation */
|
|
298
|
+
@keyframes ripple {
|
|
299
|
+
0% {
|
|
300
|
+
transform: scale(0);
|
|
301
|
+
opacity: 0.5;
|
|
302
|
+
}
|
|
303
|
+
100% {
|
|
304
|
+
transform: scale(1);
|
|
305
|
+
opacity: 0;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
.animate-ripple {
|
|
310
|
+
animation: ripple 0.6s ease-out forwards;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/* Button content wrapper */
|
|
314
|
+
.s-button__content {
|
|
315
|
+
transition: transform 0.3s ease, opacity 0.3s ease;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/* Animate slot - positioned absolute over content */
|
|
319
|
+
.s-button__animate {
|
|
320
|
+
position: absolute;
|
|
321
|
+
width: 100%;
|
|
322
|
+
height: 100%;
|
|
323
|
+
top: 0;
|
|
324
|
+
left: 0;
|
|
325
|
+
pointer-events: none;
|
|
326
|
+
transition: transform 0.3s ease, opacity 0.3s ease;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/* Slide animation (default) */
|
|
330
|
+
.s-button__animate--slide {
|
|
331
|
+
transform: translateX(100%);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
.s-button--animate-slide:hover .s-button__content {
|
|
335
|
+
transform: translateX(-100%);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
.s-button--animate-slide:hover .s-button__animate--slide {
|
|
339
|
+
transform: translateX(0);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/* Vertical animation */
|
|
343
|
+
.s-button__animate--vertical {
|
|
344
|
+
transform: translateY(100%);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
.s-button--animate-vertical:hover .s-button__content {
|
|
348
|
+
transform: translateY(-100%);
|
|
349
|
+
opacity: 0;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
.s-button--animate-vertical:hover .s-button__animate--vertical {
|
|
353
|
+
transform: translateY(0);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/* Scale animation */
|
|
357
|
+
.s-button__animate--scale {
|
|
358
|
+
transform: scale(0.5);
|
|
359
|
+
opacity: 0;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
.s-button--animate-scale:hover .s-button__content {
|
|
363
|
+
transform: scale(1.4);
|
|
364
|
+
opacity: 0;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
.s-button--animate-scale:hover .s-button__animate--scale {
|
|
368
|
+
transform: scale(1);
|
|
369
|
+
opacity: 1;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/* Rotate animation */
|
|
373
|
+
.s-button__animate--rotate {
|
|
374
|
+
transform: rotate(-180deg);
|
|
375
|
+
opacity: 0;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
.s-button--animate-rotate:hover .s-button__content {
|
|
379
|
+
transform: rotate(180deg);
|
|
380
|
+
opacity: 0;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
.s-button--animate-rotate:hover .s-button__animate--rotate {
|
|
384
|
+
transform: rotate(0);
|
|
385
|
+
opacity: 1;
|
|
386
|
+
}
|
|
387
|
+
</style>
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, ref, type CSSProperties } from 'vue'
|
|
3
|
+
import { cva, type VariantProps } from 'class-variance-authority'
|
|
4
|
+
import { cn } from '../../lib/utils'
|
|
5
|
+
|
|
6
|
+
defineOptions({ inheritAttrs: false })
|
|
7
|
+
|
|
8
|
+
const checkboxVariants = cva(
|
|
9
|
+
'relative inline-flex items-center justify-center shrink-0 border-2 transition-all duration-200 ease-out focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-ring',
|
|
10
|
+
{
|
|
11
|
+
variants: {
|
|
12
|
+
size: {
|
|
13
|
+
small: 'w-4 h-4',
|
|
14
|
+
medium: 'w-5 h-5',
|
|
15
|
+
large: 'w-6 h-6',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
defaultVariants: {
|
|
19
|
+
size: 'medium',
|
|
20
|
+
},
|
|
21
|
+
}
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
export type CheckboxVariants = VariantProps<typeof checkboxVariants>
|
|
25
|
+
|
|
26
|
+
export interface Props {
|
|
27
|
+
modelValue?: boolean | string | number | any[]
|
|
28
|
+
value?: any
|
|
29
|
+
size?: 'small' | 'medium' | 'large'
|
|
30
|
+
color?: string
|
|
31
|
+
disabled?: boolean
|
|
32
|
+
loading?: boolean
|
|
33
|
+
indeterminate?: boolean
|
|
34
|
+
label?: string
|
|
35
|
+
labelPosition?: 'left' | 'right'
|
|
36
|
+
rounded?: boolean
|
|
37
|
+
icon?: string
|
|
38
|
+
required?: boolean
|
|
39
|
+
name?: string
|
|
40
|
+
error?: string
|
|
41
|
+
checkboxClass?: string
|
|
42
|
+
labelClass?: string
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
46
|
+
modelValue: false,
|
|
47
|
+
value: undefined,
|
|
48
|
+
size: 'medium',
|
|
49
|
+
color: undefined,
|
|
50
|
+
disabled: false,
|
|
51
|
+
loading: false,
|
|
52
|
+
indeterminate: false,
|
|
53
|
+
label: undefined,
|
|
54
|
+
labelPosition: 'right',
|
|
55
|
+
rounded: false,
|
|
56
|
+
icon: 'check',
|
|
57
|
+
required: false,
|
|
58
|
+
name: undefined,
|
|
59
|
+
error: undefined,
|
|
60
|
+
checkboxClass: undefined,
|
|
61
|
+
labelClass: undefined
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
const emit = defineEmits<{
|
|
65
|
+
'update:modelValue': [value: boolean | string | number | any[]]
|
|
66
|
+
'change': [value: boolean | string | number | any[], event: Event]
|
|
67
|
+
}>()
|
|
68
|
+
|
|
69
|
+
// Ripple effect state
|
|
70
|
+
const isRippling = ref(false)
|
|
71
|
+
|
|
72
|
+
// Determine if this is an array-based checkbox group
|
|
73
|
+
const isArrayModel = computed(() => Array.isArray(props.modelValue))
|
|
74
|
+
|
|
75
|
+
// Determine checked state
|
|
76
|
+
const isChecked = computed(() => {
|
|
77
|
+
if (isArrayModel.value) {
|
|
78
|
+
return (props.modelValue as any[]).includes(props.value)
|
|
79
|
+
}
|
|
80
|
+
return props.modelValue === true || props.modelValue === props.value
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
// Toggle checkbox
|
|
84
|
+
const toggle = (event: Event) => {
|
|
85
|
+
if (props.disabled || props.loading) return
|
|
86
|
+
|
|
87
|
+
// Trigger ripple
|
|
88
|
+
triggerRipple()
|
|
89
|
+
|
|
90
|
+
let newValue: boolean | string | number | any[]
|
|
91
|
+
|
|
92
|
+
if (isArrayModel.value) {
|
|
93
|
+
const arr = [...(props.modelValue as any[])]
|
|
94
|
+
const index = arr.indexOf(props.value)
|
|
95
|
+
if (index === -1) {
|
|
96
|
+
arr.push(props.value)
|
|
97
|
+
} else {
|
|
98
|
+
arr.splice(index, 1)
|
|
99
|
+
}
|
|
100
|
+
newValue = arr
|
|
101
|
+
} else {
|
|
102
|
+
newValue = !isChecked.value
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
emit('update:modelValue', newValue)
|
|
106
|
+
emit('change', newValue, event)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const triggerRipple = () => {
|
|
110
|
+
isRippling.value = true
|
|
111
|
+
setTimeout(() => {
|
|
112
|
+
isRippling.value = false
|
|
113
|
+
}, 400)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const handleKeydown = (e: KeyboardEvent) => {
|
|
117
|
+
if (e.key === ' ' || e.key === 'Enter') {
|
|
118
|
+
e.preventDefault()
|
|
119
|
+
toggle(e)
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Size configurations for icon and label
|
|
124
|
+
const sizeConfig = computed(() => {
|
|
125
|
+
const sizes = {
|
|
126
|
+
small: {
|
|
127
|
+
icon: 'text-[10px]',
|
|
128
|
+
label: 'text-xs',
|
|
129
|
+
gap: 'gap-1.5'
|
|
130
|
+
},
|
|
131
|
+
medium: {
|
|
132
|
+
icon: 'text-xs',
|
|
133
|
+
label: 'text-sm',
|
|
134
|
+
gap: 'gap-2'
|
|
135
|
+
},
|
|
136
|
+
large: {
|
|
137
|
+
icon: 'text-sm',
|
|
138
|
+
label: 'text-base',
|
|
139
|
+
gap: 'gap-2.5'
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return sizes[props.size]
|
|
143
|
+
})
|
|
144
|
+
|
|
145
|
+
// Custom color override style (only when color prop is explicitly set)
|
|
146
|
+
const colorStyle = computed<CSSProperties | undefined>(() => {
|
|
147
|
+
if (!props.color) return undefined
|
|
148
|
+
if (!(isChecked.value || props.indeterminate)) return undefined
|
|
149
|
+
return {
|
|
150
|
+
backgroundColor: props.color,
|
|
151
|
+
borderColor: props.color
|
|
152
|
+
}
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
// Ripple color style
|
|
156
|
+
const rippleStyle = computed<CSSProperties | undefined>(() => {
|
|
157
|
+
if (!props.color) return undefined
|
|
158
|
+
return { backgroundColor: props.color }
|
|
159
|
+
})
|
|
160
|
+
|
|
161
|
+
// Determine which icon to show
|
|
162
|
+
const displayIcon = computed(() => {
|
|
163
|
+
if (props.indeterminate) return 'minus'
|
|
164
|
+
return props.icon
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
const boxClasses = computed(() => {
|
|
168
|
+
return cn(
|
|
169
|
+
checkboxVariants({ size: props.size }),
|
|
170
|
+
rounded.value ? 'rounded-full' : 'rounded-md',
|
|
171
|
+
isChecked.value || props.indeterminate
|
|
172
|
+
? props.color
|
|
173
|
+
? 'border-transparent'
|
|
174
|
+
: 'border-transparent bg-primary'
|
|
175
|
+
: 'border-border bg-background hover:border-muted-foreground',
|
|
176
|
+
{ 'cursor-not-allowed': props.disabled || props.loading },
|
|
177
|
+
props.checkboxClass
|
|
178
|
+
)
|
|
179
|
+
})
|
|
180
|
+
|
|
181
|
+
const rounded = computed(() => props.rounded)
|
|
182
|
+
</script>
|
|
183
|
+
|
|
184
|
+
<template>
|
|
185
|
+
<div v-bind="$attrs">
|
|
186
|
+
<label
|
|
187
|
+
:class="cn(
|
|
188
|
+
'relative inline-flex items-center cursor-pointer select-none',
|
|
189
|
+
sizeConfig.gap,
|
|
190
|
+
{ 'opacity-50 cursor-not-allowed': disabled },
|
|
191
|
+
{ 'flex-row-reverse': labelPosition === 'left' }
|
|
192
|
+
)"
|
|
193
|
+
>
|
|
194
|
+
<!-- Hidden input for form compatibility -->
|
|
195
|
+
<input
|
|
196
|
+
type="checkbox"
|
|
197
|
+
:name="name"
|
|
198
|
+
:checked="isChecked"
|
|
199
|
+
:disabled="disabled || loading"
|
|
200
|
+
:required="required"
|
|
201
|
+
tabindex="-1"
|
|
202
|
+
class="sr-only"
|
|
203
|
+
@change="toggle"
|
|
204
|
+
/>
|
|
205
|
+
|
|
206
|
+
<!-- Checkbox Box -->
|
|
207
|
+
<span
|
|
208
|
+
role="checkbox"
|
|
209
|
+
:aria-checked="indeterminate ? 'mixed' : isChecked"
|
|
210
|
+
:aria-disabled="disabled || loading"
|
|
211
|
+
tabindex="0"
|
|
212
|
+
:class="boxClasses"
|
|
213
|
+
:style="colorStyle"
|
|
214
|
+
@click.prevent="toggle"
|
|
215
|
+
@keydown="handleKeydown"
|
|
216
|
+
>
|
|
217
|
+
<!-- Ripple Effect -->
|
|
218
|
+
<span
|
|
219
|
+
v-if="isRippling"
|
|
220
|
+
class="absolute inset-0 animate-ping opacity-30 z-0"
|
|
221
|
+
:class="[rounded ? 'rounded-full' : 'rounded-md', !color && 'bg-primary']"
|
|
222
|
+
:style="rippleStyle"
|
|
223
|
+
/>
|
|
224
|
+
|
|
225
|
+
<!-- Loading Spinner -->
|
|
226
|
+
<span
|
|
227
|
+
v-if="loading"
|
|
228
|
+
:class="cn(
|
|
229
|
+
'mdi mdi-loading animate-spin',
|
|
230
|
+
sizeConfig.icon,
|
|
231
|
+
isChecked || indeterminate ? (color ? 'text-white' : 'text-primary-foreground') : 'text-foreground'
|
|
232
|
+
)"
|
|
233
|
+
/>
|
|
234
|
+
|
|
235
|
+
<!-- Check Icon / Indeterminate Icon -->
|
|
236
|
+
<Transition
|
|
237
|
+
enter-active-class="transition-all duration-200 ease-out"
|
|
238
|
+
enter-from-class="scale-0 opacity-0"
|
|
239
|
+
enter-to-class="scale-100 opacity-100"
|
|
240
|
+
leave-active-class="transition-all duration-150 ease-in"
|
|
241
|
+
leave-from-class="scale-100 opacity-100"
|
|
242
|
+
leave-to-class="scale-0 opacity-0"
|
|
243
|
+
>
|
|
244
|
+
<span
|
|
245
|
+
v-if="(isChecked || indeterminate) && !loading"
|
|
246
|
+
:class="cn('absolute inset-0 flex items-center justify-center', color ? 'text-white' : 'text-primary-foreground', sizeConfig.icon)"
|
|
247
|
+
>
|
|
248
|
+
<slot name="icon">
|
|
249
|
+
<span :class="['mdi', `mdi-${displayIcon}`]" />
|
|
250
|
+
</slot>
|
|
251
|
+
</span>
|
|
252
|
+
</Transition>
|
|
253
|
+
</span>
|
|
254
|
+
|
|
255
|
+
<!-- Label -->
|
|
256
|
+
<span
|
|
257
|
+
v-if="label || $slots.default"
|
|
258
|
+
:class="cn(
|
|
259
|
+
'transition-colors text-muted-foreground',
|
|
260
|
+
sizeConfig.label,
|
|
261
|
+
{ 'text-foreground': isChecked },
|
|
262
|
+
labelClass
|
|
263
|
+
)"
|
|
264
|
+
>
|
|
265
|
+
<slot>{{ label }}</slot>
|
|
266
|
+
<span v-if="required" class="text-destructive ml-0.5">*</span>
|
|
267
|
+
</span>
|
|
268
|
+
</label>
|
|
269
|
+
|
|
270
|
+
<!-- Error message -->
|
|
271
|
+
<p v-if="error" class="mt-1 text-xs text-destructive flex items-center gap-1">
|
|
272
|
+
<span class="mdi mdi-alert-circle" />
|
|
273
|
+
{{ error }}
|
|
274
|
+
</p>
|
|
275
|
+
</div>
|
|
276
|
+
</template>
|
|
277
|
+
|
|
278
|
+
<style scoped>
|
|
279
|
+
.s-checkbox-box {
|
|
280
|
+
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
|
|
281
|
+
overflow: hidden;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
.s-checkbox-wrapper:hover:not(.cursor-not-allowed) .s-checkbox-box:not([aria-disabled="true"]) {
|
|
285
|
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
286
|
+
transform: scale(1.02);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
.s-checkbox-box:focus-visible {
|
|
290
|
+
box-shadow: 0 0 0 3px rgba(var(--s-primary-rgb, 16, 185, 129), 0.2);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/* Bounce animation for check icon */
|
|
294
|
+
.s-checkbox-box span[class*="mdi-check"],
|
|
295
|
+
.s-checkbox-box span[class*="mdi-minus"] {
|
|
296
|
+
animation: checkBounce 0.2s ease-out;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
@keyframes checkBounce {
|
|
300
|
+
0% {
|
|
301
|
+
transform: scale(0);
|
|
302
|
+
}
|
|
303
|
+
50% {
|
|
304
|
+
transform: scale(1.2);
|
|
305
|
+
}
|
|
306
|
+
100% {
|
|
307
|
+
transform: scale(1);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
</style>
|