@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,407 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, ref, inject, type CSSProperties } from 'vue'
|
|
3
|
+
import { cn } from '../../../lib/utils'
|
|
4
|
+
|
|
5
|
+
defineOptions({ inheritAttrs: false })
|
|
6
|
+
|
|
7
|
+
export interface Props {
|
|
8
|
+
modelValue?: any
|
|
9
|
+
value?: any
|
|
10
|
+
size?: 'small' | 'medium' | 'large'
|
|
11
|
+
color?: string
|
|
12
|
+
disabled?: boolean
|
|
13
|
+
loading?: boolean
|
|
14
|
+
label?: string
|
|
15
|
+
labelPosition?: 'left' | 'right'
|
|
16
|
+
variant?: 'default' | 'filled' | 'outlined' | 'button'
|
|
17
|
+
icon?: string
|
|
18
|
+
required?: boolean
|
|
19
|
+
name?: string
|
|
20
|
+
error?: string
|
|
21
|
+
radioClass?: string
|
|
22
|
+
labelClass?: string
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
26
|
+
modelValue: undefined,
|
|
27
|
+
value: undefined,
|
|
28
|
+
size: 'medium',
|
|
29
|
+
color: undefined,
|
|
30
|
+
disabled: false,
|
|
31
|
+
loading: false,
|
|
32
|
+
label: undefined,
|
|
33
|
+
labelPosition: 'right',
|
|
34
|
+
variant: 'default',
|
|
35
|
+
icon: undefined,
|
|
36
|
+
required: false,
|
|
37
|
+
name: undefined,
|
|
38
|
+
error: undefined,
|
|
39
|
+
radioClass: undefined,
|
|
40
|
+
labelClass: undefined
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
const emit = defineEmits<{
|
|
44
|
+
'update:modelValue': [value: any]
|
|
45
|
+
'change': [value: any, event: Event]
|
|
46
|
+
}>()
|
|
47
|
+
|
|
48
|
+
// Inject from RadioGroup if present
|
|
49
|
+
const groupValue = inject<{ value: any } | undefined>('radioGroupValue', undefined)
|
|
50
|
+
const groupDisabled = inject('radioGroupDisabled', false)
|
|
51
|
+
const groupSize = inject<string | undefined>('radioGroupSize', undefined)
|
|
52
|
+
const groupColor = inject<string | undefined>('radioGroupColor', undefined)
|
|
53
|
+
const groupVariant = inject<string | undefined>('radioGroupVariant', undefined)
|
|
54
|
+
const groupUpdate = inject<((val: any) => void) | undefined>('radioGroupUpdate', undefined)
|
|
55
|
+
|
|
56
|
+
// Ripple effect state
|
|
57
|
+
const isRippling = ref(false)
|
|
58
|
+
|
|
59
|
+
// Determine if controlled by group or standalone
|
|
60
|
+
const currentValue = computed(() => groupValue?.value ?? props.modelValue)
|
|
61
|
+
const isDisabled = computed(() => props.disabled || groupDisabled)
|
|
62
|
+
const currentSize = computed(() => groupSize ?? props.size)
|
|
63
|
+
const currentColor = computed(() => groupColor ?? props.color)
|
|
64
|
+
const currentVariant = computed(() => groupVariant ?? props.variant)
|
|
65
|
+
|
|
66
|
+
// Whether a custom color is set
|
|
67
|
+
const hasCustomColor = computed(() => !!currentColor.value)
|
|
68
|
+
|
|
69
|
+
// Determine checked state
|
|
70
|
+
const isChecked = computed(() => currentValue.value === props.value)
|
|
71
|
+
|
|
72
|
+
// Select this radio
|
|
73
|
+
const select = (event: Event) => {
|
|
74
|
+
if (isDisabled.value || props.loading) return
|
|
75
|
+
|
|
76
|
+
// Trigger ripple
|
|
77
|
+
triggerRipple()
|
|
78
|
+
|
|
79
|
+
if (groupUpdate) {
|
|
80
|
+
groupUpdate(props.value)
|
|
81
|
+
} else {
|
|
82
|
+
emit('update:modelValue', props.value)
|
|
83
|
+
emit('change', props.value, event)
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const triggerRipple = () => {
|
|
88
|
+
isRippling.value = true
|
|
89
|
+
setTimeout(() => {
|
|
90
|
+
isRippling.value = false
|
|
91
|
+
}, 500)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const handleKeydown = (e: KeyboardEvent) => {
|
|
95
|
+
if (e.key === ' ' || e.key === 'Enter') {
|
|
96
|
+
e.preventDefault()
|
|
97
|
+
select(e)
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Size configurations
|
|
102
|
+
const sizeConfig = computed(() => {
|
|
103
|
+
const sizes = {
|
|
104
|
+
small: {
|
|
105
|
+
outer: 'w-4 h-4',
|
|
106
|
+
inner: 'w-1.5 h-1.5',
|
|
107
|
+
icon: 'text-[8px]',
|
|
108
|
+
label: 'text-xs',
|
|
109
|
+
gap: 'gap-1.5',
|
|
110
|
+
button: 'px-3 py-1.5 text-xs'
|
|
111
|
+
},
|
|
112
|
+
medium: {
|
|
113
|
+
outer: 'w-5 h-5',
|
|
114
|
+
inner: 'w-2.5 h-2.5',
|
|
115
|
+
icon: 'text-[10px]',
|
|
116
|
+
label: 'text-sm',
|
|
117
|
+
gap: 'gap-2',
|
|
118
|
+
button: 'px-4 py-2 text-sm'
|
|
119
|
+
},
|
|
120
|
+
large: {
|
|
121
|
+
outer: 'w-6 h-6',
|
|
122
|
+
inner: 'w-3 h-3',
|
|
123
|
+
icon: 'text-xs',
|
|
124
|
+
label: 'text-base',
|
|
125
|
+
gap: 'gap-2.5',
|
|
126
|
+
button: 'px-5 py-2.5 text-base'
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return sizes[currentSize.value as keyof typeof sizes]
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
// Computed styles for the radio
|
|
133
|
+
const radioStyle = computed<CSSProperties>(() => {
|
|
134
|
+
if (isChecked.value && currentVariant.value !== 'button' && hasCustomColor.value) {
|
|
135
|
+
return {
|
|
136
|
+
borderColor: currentColor.value,
|
|
137
|
+
boxShadow: `0 0 0 3px ${currentColor.value}20`
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return {}
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
const dotStyle = computed<CSSProperties>(() => {
|
|
144
|
+
if (isChecked.value && hasCustomColor.value) {
|
|
145
|
+
return {
|
|
146
|
+
backgroundColor: currentColor.value
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return {}
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
const buttonStyle = computed<CSSProperties>(() => {
|
|
153
|
+
if (currentVariant.value === 'button') {
|
|
154
|
+
if (isChecked.value && hasCustomColor.value) {
|
|
155
|
+
return {
|
|
156
|
+
backgroundColor: currentColor.value,
|
|
157
|
+
borderColor: currentColor.value,
|
|
158
|
+
color: '#ffffff'
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return {}
|
|
163
|
+
})
|
|
164
|
+
</script>
|
|
165
|
+
|
|
166
|
+
<template>
|
|
167
|
+
<div class="s-radio-container" v-bind="$attrs">
|
|
168
|
+
<!-- Button Variant -->
|
|
169
|
+
<button
|
|
170
|
+
v-if="currentVariant === 'button'"
|
|
171
|
+
type="button"
|
|
172
|
+
role="radio"
|
|
173
|
+
:aria-checked="isChecked"
|
|
174
|
+
:aria-disabled="isDisabled || loading"
|
|
175
|
+
:disabled="isDisabled || loading"
|
|
176
|
+
:class="cn(
|
|
177
|
+
's-radio-button relative inline-flex items-center justify-center border-2 rounded-lg font-medium transition-all duration-300 ease-out focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-ring select-none',
|
|
178
|
+
sizeConfig.button,
|
|
179
|
+
isChecked
|
|
180
|
+
? hasCustomColor
|
|
181
|
+
? 'border-transparent shadow-lg'
|
|
182
|
+
: 'border-transparent shadow-lg bg-primary text-primary-foreground'
|
|
183
|
+
: 'border-border bg-background text-muted-foreground hover:border-input hover:text-foreground',
|
|
184
|
+
{ 'opacity-50 cursor-not-allowed': isDisabled || loading },
|
|
185
|
+
{ 'cursor-pointer': !isDisabled && !loading }
|
|
186
|
+
)"
|
|
187
|
+
:style="buttonStyle"
|
|
188
|
+
@click="select"
|
|
189
|
+
@keydown="handleKeydown"
|
|
190
|
+
>
|
|
191
|
+
<!-- Loading Spinner -->
|
|
192
|
+
<span
|
|
193
|
+
v-if="loading"
|
|
194
|
+
class="mdi mdi-loading animate-spin mr-2"
|
|
195
|
+
></span>
|
|
196
|
+
|
|
197
|
+
<!-- Icon -->
|
|
198
|
+
<span
|
|
199
|
+
v-if="icon && !loading"
|
|
200
|
+
:class="['mdi', `mdi-${icon}`, 'mr-2']"
|
|
201
|
+
></span>
|
|
202
|
+
|
|
203
|
+
<!-- Label -->
|
|
204
|
+
<slot>{{ label }}</slot>
|
|
205
|
+
|
|
206
|
+
<!-- Ripple Effect -->
|
|
207
|
+
<span
|
|
208
|
+
v-if="isRippling"
|
|
209
|
+
class="absolute inset-0 rounded-lg animate-ping opacity-20"
|
|
210
|
+
:style="hasCustomColor ? { backgroundColor: currentColor } : {}"
|
|
211
|
+
:class="{ 'bg-primary': !hasCustomColor }"
|
|
212
|
+
/>
|
|
213
|
+
</button>
|
|
214
|
+
|
|
215
|
+
<!-- Standard Radio Variants -->
|
|
216
|
+
<label
|
|
217
|
+
v-else
|
|
218
|
+
:class="cn(
|
|
219
|
+
's-radio-wrapper relative inline-flex items-center cursor-pointer select-none',
|
|
220
|
+
sizeConfig.gap,
|
|
221
|
+
{ 'opacity-50 cursor-not-allowed': isDisabled },
|
|
222
|
+
{ 'flex-row-reverse': labelPosition === 'left' }
|
|
223
|
+
)"
|
|
224
|
+
>
|
|
225
|
+
<!-- Hidden input for form compatibility -->
|
|
226
|
+
<input
|
|
227
|
+
type="radio"
|
|
228
|
+
:name="name"
|
|
229
|
+
:value="value"
|
|
230
|
+
:checked="isChecked"
|
|
231
|
+
:disabled="isDisabled || loading"
|
|
232
|
+
:required="required"
|
|
233
|
+
tabindex="-1"
|
|
234
|
+
class="sr-only"
|
|
235
|
+
@change="select"
|
|
236
|
+
/>
|
|
237
|
+
|
|
238
|
+
<!-- Radio Circle -->
|
|
239
|
+
<span
|
|
240
|
+
role="radio"
|
|
241
|
+
:aria-checked="isChecked"
|
|
242
|
+
:aria-disabled="isDisabled || loading"
|
|
243
|
+
tabindex="0"
|
|
244
|
+
:class="cn(
|
|
245
|
+
's-radio-outer relative inline-flex items-center justify-center shrink-0 rounded-full border-2 transition-all duration-300 ease-out focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-ring',
|
|
246
|
+
sizeConfig.outer,
|
|
247
|
+
isChecked
|
|
248
|
+
? hasCustomColor
|
|
249
|
+
? ''
|
|
250
|
+
: 'border-primary shadow-[0_0_0_3px_color-mix(in_srgb,var(--s-ring)_12%,transparent)]'
|
|
251
|
+
: 'border-border hover:border-input',
|
|
252
|
+
currentVariant === 'filled' && isChecked ? 'border-transparent' : '',
|
|
253
|
+
currentVariant === 'outlined' && isChecked ? 'border-2' : '',
|
|
254
|
+
{ 'cursor-not-allowed': isDisabled || loading },
|
|
255
|
+
radioClass
|
|
256
|
+
)"
|
|
257
|
+
:style="radioStyle"
|
|
258
|
+
@click.prevent="select"
|
|
259
|
+
@keydown="handleKeydown"
|
|
260
|
+
>
|
|
261
|
+
<!-- Ripple Effect -->
|
|
262
|
+
<span
|
|
263
|
+
v-if="isRippling"
|
|
264
|
+
class="absolute inset-0 rounded-full animate-ping opacity-30"
|
|
265
|
+
:style="hasCustomColor ? { backgroundColor: currentColor } : {}"
|
|
266
|
+
:class="{ 'bg-primary': !hasCustomColor }"
|
|
267
|
+
/>
|
|
268
|
+
|
|
269
|
+
<!-- Background for filled variant -->
|
|
270
|
+
<span
|
|
271
|
+
v-if="currentVariant === 'filled' && isChecked"
|
|
272
|
+
class="absolute inset-0 rounded-full transition-all duration-300"
|
|
273
|
+
:style="hasCustomColor ? { backgroundColor: currentColor } : {}"
|
|
274
|
+
:class="{ 'bg-primary': !hasCustomColor }"
|
|
275
|
+
/>
|
|
276
|
+
|
|
277
|
+
<!-- Loading Spinner -->
|
|
278
|
+
<span
|
|
279
|
+
v-if="loading"
|
|
280
|
+
class="mdi mdi-loading animate-spin z-10"
|
|
281
|
+
:class="[sizeConfig.icon, isChecked && currentVariant === 'filled' ? (hasCustomColor ? 'text-white' : 'text-primary-foreground') : 'text-foreground']"
|
|
282
|
+
/>
|
|
283
|
+
|
|
284
|
+
<!-- Inner Dot / Icon -->
|
|
285
|
+
<Transition
|
|
286
|
+
enter-active-class="transition-all duration-300 ease-out"
|
|
287
|
+
enter-from-class="scale-0 opacity-0"
|
|
288
|
+
enter-to-class="scale-100 opacity-100"
|
|
289
|
+
leave-active-class="transition-all duration-200 ease-in"
|
|
290
|
+
leave-from-class="scale-100 opacity-100"
|
|
291
|
+
leave-to-class="scale-0 opacity-0"
|
|
292
|
+
>
|
|
293
|
+
<span
|
|
294
|
+
v-if="isChecked && !loading"
|
|
295
|
+
class="z-10"
|
|
296
|
+
:class="currentVariant === 'filled' ? (hasCustomColor ? 'text-white' : 'text-primary-foreground') : ''"
|
|
297
|
+
>
|
|
298
|
+
<slot name="icon">
|
|
299
|
+
<span
|
|
300
|
+
v-if="icon"
|
|
301
|
+
:class="cn('mdi', `mdi-${icon}`, sizeConfig.icon, currentVariant !== 'filled' && !hasCustomColor ? 'text-primary' : '')"
|
|
302
|
+
:style="currentVariant !== 'filled' && hasCustomColor ? { color: currentColor } : {}"
|
|
303
|
+
/>
|
|
304
|
+
<span
|
|
305
|
+
v-else
|
|
306
|
+
:class="cn(
|
|
307
|
+
's-radio-inner block rounded-full transition-all duration-300',
|
|
308
|
+
sizeConfig.inner,
|
|
309
|
+
currentVariant === 'filled' ? (hasCustomColor ? 'bg-white' : 'bg-primary-foreground') : '',
|
|
310
|
+
currentVariant !== 'filled' && !hasCustomColor ? 'bg-primary' : ''
|
|
311
|
+
)"
|
|
312
|
+
:style="currentVariant !== 'filled' && hasCustomColor ? dotStyle : {}"
|
|
313
|
+
/>
|
|
314
|
+
</slot>
|
|
315
|
+
</span>
|
|
316
|
+
</Transition>
|
|
317
|
+
</span>
|
|
318
|
+
|
|
319
|
+
<!-- Label -->
|
|
320
|
+
<span
|
|
321
|
+
v-if="label || $slots.default"
|
|
322
|
+
:class="cn(
|
|
323
|
+
's-radio-label text-muted-foreground transition-colors duration-200',
|
|
324
|
+
sizeConfig.label,
|
|
325
|
+
{ 'text-foreground': isChecked },
|
|
326
|
+
labelClass
|
|
327
|
+
)"
|
|
328
|
+
>
|
|
329
|
+
<slot>{{ label }}</slot>
|
|
330
|
+
<span v-if="required" class="text-red-500 ml-0.5">*</span>
|
|
331
|
+
</span>
|
|
332
|
+
</label>
|
|
333
|
+
|
|
334
|
+
<!-- Error message -->
|
|
335
|
+
<p v-if="error" class="mt-1 text-xs text-red-500 flex items-center gap-1">
|
|
336
|
+
<span class="mdi mdi-alert-circle" />
|
|
337
|
+
{{ error }}
|
|
338
|
+
</p>
|
|
339
|
+
</div>
|
|
340
|
+
</template>
|
|
341
|
+
|
|
342
|
+
<style scoped>
|
|
343
|
+
.s-radio-outer {
|
|
344
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
|
|
345
|
+
background: var(--s-background);
|
|
346
|
+
overflow: hidden;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
.s-radio-wrapper:hover:not(.cursor-not-allowed) .s-radio-outer:not([aria-disabled="true"]) {
|
|
350
|
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
|
|
351
|
+
transform: scale(1.05);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
.s-radio-outer:focus-visible {
|
|
355
|
+
box-shadow: 0 0 0 3px rgba(var(--s-primary-rgb, 16, 185, 129), 0.25);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/* Spring bounce animation for the inner dot */
|
|
359
|
+
.s-radio-inner {
|
|
360
|
+
animation: radioBounce 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
@keyframes radioBounce {
|
|
364
|
+
0% {
|
|
365
|
+
transform: scale(0);
|
|
366
|
+
}
|
|
367
|
+
60% {
|
|
368
|
+
transform: scale(1.3);
|
|
369
|
+
}
|
|
370
|
+
80% {
|
|
371
|
+
transform: scale(0.9);
|
|
372
|
+
}
|
|
373
|
+
100% {
|
|
374
|
+
transform: scale(1);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/* Button variant hover lift */
|
|
379
|
+
.s-radio-button:not(:disabled):hover {
|
|
380
|
+
transform: translateY(-1px);
|
|
381
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
.s-radio-button:not(:disabled):active {
|
|
385
|
+
transform: translateY(0);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/* Pulse animation for highlighted options */
|
|
389
|
+
.s-radio-outer[data-pulse="true"]::before {
|
|
390
|
+
content: '';
|
|
391
|
+
position: absolute;
|
|
392
|
+
inset: -4px;
|
|
393
|
+
border-radius: 9999px;
|
|
394
|
+
animation: pulse 2s infinite;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
@keyframes pulse {
|
|
398
|
+
0%, 100% {
|
|
399
|
+
opacity: 0;
|
|
400
|
+
transform: scale(0.8);
|
|
401
|
+
}
|
|
402
|
+
50% {
|
|
403
|
+
opacity: 0.3;
|
|
404
|
+
transform: scale(1.2);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
</style>
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, provide, ref, watch } from 'vue'
|
|
3
|
+
import { cn } from '../../../lib/utils'
|
|
4
|
+
import SRadio from './SRadio.vue'
|
|
5
|
+
|
|
6
|
+
defineOptions({ inheritAttrs: false })
|
|
7
|
+
|
|
8
|
+
export interface RadioOption {
|
|
9
|
+
value: any
|
|
10
|
+
label: string
|
|
11
|
+
disabled?: boolean
|
|
12
|
+
icon?: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface Props {
|
|
16
|
+
modelValue?: any
|
|
17
|
+
options?: RadioOption[]
|
|
18
|
+
orientation?: 'horizontal' | 'vertical' | 'grid'
|
|
19
|
+
size?: 'small' | 'medium' | 'large'
|
|
20
|
+
color?: string
|
|
21
|
+
variant?: 'default' | 'filled' | 'outlined' | 'button'
|
|
22
|
+
disabled?: boolean
|
|
23
|
+
gap?: 'tight' | 'normal' | 'loose'
|
|
24
|
+
gridCols?: number
|
|
25
|
+
name?: string
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
29
|
+
modelValue: undefined,
|
|
30
|
+
options: () => [],
|
|
31
|
+
orientation: 'vertical',
|
|
32
|
+
size: 'medium',
|
|
33
|
+
color: undefined,
|
|
34
|
+
variant: 'default',
|
|
35
|
+
disabled: false,
|
|
36
|
+
gap: 'normal',
|
|
37
|
+
gridCols: 3,
|
|
38
|
+
name: undefined
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
const emit = defineEmits<{
|
|
42
|
+
'update:modelValue': [value: any]
|
|
43
|
+
'change': [value: any]
|
|
44
|
+
}>()
|
|
45
|
+
|
|
46
|
+
// Internal value for keyboard navigation
|
|
47
|
+
const internalValue = ref(props.modelValue)
|
|
48
|
+
|
|
49
|
+
watch(() => props.modelValue, (val) => {
|
|
50
|
+
internalValue.value = val
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
// Provide values to child SRadio components
|
|
54
|
+
provide('radioGroupValue', computed(() => internalValue.value))
|
|
55
|
+
provide('radioGroupDisabled', props.disabled)
|
|
56
|
+
provide('radioGroupSize', props.size)
|
|
57
|
+
provide('radioGroupColor', props.color)
|
|
58
|
+
provide('radioGroupVariant', props.variant)
|
|
59
|
+
provide('radioGroupUpdate', (val: any) => {
|
|
60
|
+
internalValue.value = val
|
|
61
|
+
emit('update:modelValue', val)
|
|
62
|
+
emit('change', val)
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
// Gap configurations
|
|
66
|
+
const gapConfig = computed(() => {
|
|
67
|
+
const gaps = {
|
|
68
|
+
tight: {
|
|
69
|
+
horizontal: 'gap-2',
|
|
70
|
+
vertical: 'gap-1',
|
|
71
|
+
grid: 'gap-2'
|
|
72
|
+
},
|
|
73
|
+
normal: {
|
|
74
|
+
horizontal: 'gap-4',
|
|
75
|
+
vertical: 'gap-2',
|
|
76
|
+
grid: 'gap-3'
|
|
77
|
+
},
|
|
78
|
+
loose: {
|
|
79
|
+
horizontal: 'gap-6',
|
|
80
|
+
vertical: 'gap-4',
|
|
81
|
+
grid: 'gap-4'
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return gaps[props.gap]
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
// Layout classes
|
|
88
|
+
const layoutClass = computed(() => {
|
|
89
|
+
switch (props.orientation) {
|
|
90
|
+
case 'horizontal':
|
|
91
|
+
return `flex flex-wrap items-center ${gapConfig.value.horizontal}`
|
|
92
|
+
case 'grid':
|
|
93
|
+
return `grid ${gapConfig.value.grid}`
|
|
94
|
+
case 'vertical':
|
|
95
|
+
default:
|
|
96
|
+
return `flex flex-col ${gapConfig.value.vertical}`
|
|
97
|
+
}
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
// Grid columns style
|
|
101
|
+
const gridStyle = computed(() => {
|
|
102
|
+
if (props.orientation === 'grid') {
|
|
103
|
+
return {
|
|
104
|
+
gridTemplateColumns: `repeat(${props.gridCols}, minmax(0, 1fr))`
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return {}
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
// Keyboard navigation
|
|
111
|
+
const handleKeydown = (e: KeyboardEvent) => {
|
|
112
|
+
if (!props.options?.length) return
|
|
113
|
+
|
|
114
|
+
const currentIndex = props.options.findIndex(opt => opt.value === internalValue.value)
|
|
115
|
+
let newIndex = currentIndex
|
|
116
|
+
|
|
117
|
+
const isVertical = props.orientation === 'vertical'
|
|
118
|
+
const isGrid = props.orientation === 'grid'
|
|
119
|
+
|
|
120
|
+
switch (e.key) {
|
|
121
|
+
case 'ArrowDown':
|
|
122
|
+
if (isVertical || isGrid) {
|
|
123
|
+
e.preventDefault()
|
|
124
|
+
if (isGrid) {
|
|
125
|
+
newIndex = Math.min(currentIndex + props.gridCols, props.options.length - 1)
|
|
126
|
+
} else {
|
|
127
|
+
newIndex = currentIndex < props.options.length - 1 ? currentIndex + 1 : 0
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
break
|
|
131
|
+
case 'ArrowUp':
|
|
132
|
+
if (isVertical || isGrid) {
|
|
133
|
+
e.preventDefault()
|
|
134
|
+
if (isGrid) {
|
|
135
|
+
newIndex = Math.max(currentIndex - props.gridCols, 0)
|
|
136
|
+
} else {
|
|
137
|
+
newIndex = currentIndex > 0 ? currentIndex - 1 : props.options.length - 1
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
break
|
|
141
|
+
case 'ArrowRight':
|
|
142
|
+
e.preventDefault()
|
|
143
|
+
newIndex = currentIndex < props.options.length - 1 ? currentIndex + 1 : 0
|
|
144
|
+
break
|
|
145
|
+
case 'ArrowLeft':
|
|
146
|
+
e.preventDefault()
|
|
147
|
+
newIndex = currentIndex > 0 ? currentIndex - 1 : props.options.length - 1
|
|
148
|
+
break
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Skip disabled options
|
|
152
|
+
while (props.options[newIndex]?.disabled && newIndex !== currentIndex) {
|
|
153
|
+
if (e.key === 'ArrowUp' || e.key === 'ArrowLeft') {
|
|
154
|
+
newIndex = newIndex > 0 ? newIndex - 1 : props.options.length - 1
|
|
155
|
+
} else {
|
|
156
|
+
newIndex = newIndex < props.options.length - 1 ? newIndex + 1 : 0
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (newIndex !== currentIndex && !props.options[newIndex]?.disabled) {
|
|
161
|
+
internalValue.value = props.options[newIndex].value
|
|
162
|
+
emit('update:modelValue', props.options[newIndex].value)
|
|
163
|
+
emit('change', props.options[newIndex].value)
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
</script>
|
|
167
|
+
|
|
168
|
+
<template>
|
|
169
|
+
<div
|
|
170
|
+
v-bind="$attrs"
|
|
171
|
+
role="radiogroup"
|
|
172
|
+
:class="cn(
|
|
173
|
+
's-radio-group',
|
|
174
|
+
layoutClass,
|
|
175
|
+
{ 'opacity-50': disabled }
|
|
176
|
+
)"
|
|
177
|
+
:style="gridStyle"
|
|
178
|
+
@keydown="handleKeydown"
|
|
179
|
+
>
|
|
180
|
+
<!-- Render from options prop -->
|
|
181
|
+
<SRadio
|
|
182
|
+
v-for="option in options"
|
|
183
|
+
:key="option.value"
|
|
184
|
+
:value="option.value"
|
|
185
|
+
:label="option.label"
|
|
186
|
+
:disabled="option.disabled"
|
|
187
|
+
:icon="option.icon"
|
|
188
|
+
:name="name"
|
|
189
|
+
/>
|
|
190
|
+
|
|
191
|
+
<!-- Or render slotted content -->
|
|
192
|
+
<slot />
|
|
193
|
+
</div>
|
|
194
|
+
</template>
|
|
195
|
+
|
|
196
|
+
<style scoped>
|
|
197
|
+
.s-radio-group {
|
|
198
|
+
outline: none;
|
|
199
|
+
}
|
|
200
|
+
</style>
|