@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,29 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
defineOptions({ inheritAttrs: false })
|
|
3
|
+
|
|
4
|
+
import type { SOTPGap } from './types'
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
gap?: SOTPGap
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
11
|
+
gap: 'normal'
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
const gapClasses: Record<SOTPGap, string> = {
|
|
15
|
+
tight: 'gap-1',
|
|
16
|
+
normal: 'gap-2',
|
|
17
|
+
wide: 'gap-4'
|
|
18
|
+
}
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<template>
|
|
22
|
+
<div
|
|
23
|
+
v-bind="$attrs"
|
|
24
|
+
class="s-otp-group flex items-center"
|
|
25
|
+
:class="gapClasses[props.gap]"
|
|
26
|
+
>
|
|
27
|
+
<slot />
|
|
28
|
+
</div>
|
|
29
|
+
</template>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
defineOptions({ inheritAttrs: false })
|
|
3
|
+
|
|
4
|
+
import { cn } from '../../../lib/utils'
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<template>
|
|
8
|
+
<div
|
|
9
|
+
v-bind="$attrs"
|
|
10
|
+
:class="cn('s-otp-separator flex items-center justify-center px-1 text-muted-foreground font-bold select-none text-2xl', $attrs.class ?? '')"
|
|
11
|
+
role="separator"
|
|
12
|
+
>
|
|
13
|
+
<slot>-</slot>
|
|
14
|
+
</div>
|
|
15
|
+
</template>
|
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
defineOptions({ inheritAttrs: false })
|
|
3
|
+
|
|
4
|
+
import { computed } from 'vue'
|
|
5
|
+
import { cn } from '../../../lib/utils'
|
|
6
|
+
import { useSOTPContext } from './useOTPContext'
|
|
7
|
+
import type {
|
|
8
|
+
SOTPVariant, SOTPSize, SOTPRounded,
|
|
9
|
+
SOTPAnimation, SOTPEntryAnimation, SOTPInputAnimation,
|
|
10
|
+
SOTPSuccessAnimation, SOTPErrorAnimation
|
|
11
|
+
} from './types'
|
|
12
|
+
|
|
13
|
+
interface Props {
|
|
14
|
+
index: number
|
|
15
|
+
variant?: SOTPVariant
|
|
16
|
+
size?: SOTPSize
|
|
17
|
+
color?: string
|
|
18
|
+
rounded?: SOTPRounded
|
|
19
|
+
animation?: SOTPAnimation
|
|
20
|
+
entryAnimation?: SOTPEntryAnimation
|
|
21
|
+
inputAnimation?: SOTPInputAnimation
|
|
22
|
+
successAnimation?: SOTPSuccessAnimation
|
|
23
|
+
errorAnimation?: SOTPErrorAnimation
|
|
24
|
+
morphText?: boolean
|
|
25
|
+
morphDuration?: number
|
|
26
|
+
showPlaceholder?: boolean
|
|
27
|
+
placeholderChar?: string
|
|
28
|
+
maskChar?: string
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const props = defineProps<Props>()
|
|
32
|
+
const ctx = useSOTPContext()
|
|
33
|
+
|
|
34
|
+
// Resolve visual props: own prop > root default
|
|
35
|
+
const r = computed(() => {
|
|
36
|
+
const d = ctx.defaults.value
|
|
37
|
+
return {
|
|
38
|
+
variant: props.variant ?? d.variant,
|
|
39
|
+
size: props.size ?? d.size,
|
|
40
|
+
color: props.color ?? d.color,
|
|
41
|
+
rounded: props.rounded ?? d.rounded,
|
|
42
|
+
animation: props.animation ?? d.animation,
|
|
43
|
+
entryAnimation: props.entryAnimation ?? d.entryAnimation,
|
|
44
|
+
inputAnimation: props.inputAnimation ?? d.inputAnimation,
|
|
45
|
+
successAnimation: props.successAnimation ?? d.successAnimation,
|
|
46
|
+
errorAnimation: props.errorAnimation ?? d.errorAnimation,
|
|
47
|
+
morphText: props.morphText ?? d.morphText,
|
|
48
|
+
morphDuration: props.morphDuration ?? d.morphDuration,
|
|
49
|
+
showPlaceholder: props.showPlaceholder ?? d.showPlaceholder,
|
|
50
|
+
placeholderChar: props.placeholderChar ?? d.placeholderChar,
|
|
51
|
+
maskChar: props.maskChar ?? d.maskChar,
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
// Size configurations
|
|
56
|
+
const sizeConfig = computed(() => {
|
|
57
|
+
const sizes: Record<SOTPSize, { box: string; text: string }> = {
|
|
58
|
+
small: { box: 'w-9 h-10', text: 'text-lg' },
|
|
59
|
+
medium: { box: 'w-12 h-14', text: 'text-2xl' },
|
|
60
|
+
large: { box: 'w-14 h-16', text: 'text-3xl' },
|
|
61
|
+
xl: { box: 'w-18 h-20', text: 'text-4xl' }
|
|
62
|
+
}
|
|
63
|
+
return sizes[r.value.size]
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
// Rounded configurations
|
|
67
|
+
const roundedConfig = computed(() => {
|
|
68
|
+
const radii: Record<SOTPRounded, string> = {
|
|
69
|
+
none: 'rounded-none',
|
|
70
|
+
sm: 'rounded',
|
|
71
|
+
md: 'rounded-lg',
|
|
72
|
+
lg: 'rounded-xl',
|
|
73
|
+
full: 'rounded-full'
|
|
74
|
+
}
|
|
75
|
+
return radii[r.value.rounded]
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
// Variant classes
|
|
79
|
+
const variantClasses = computed(() => {
|
|
80
|
+
const base: Record<SOTPVariant, string> = {
|
|
81
|
+
outlined: 'border-2 bg-background border-border',
|
|
82
|
+
filled: 'border-2 border-transparent bg-accent',
|
|
83
|
+
underlined: 'border-b-2 border-t-0 border-l-0 border-r-0 rounded-none! bg-transparent border-border',
|
|
84
|
+
ghost: 'border-2 border-transparent bg-transparent',
|
|
85
|
+
morphing: 'border-2 bg-muted border-border shadow-inner'
|
|
86
|
+
}
|
|
87
|
+
return base[r.value.variant]
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
// Template ref callback — registers input element with parent context
|
|
91
|
+
const setInputRef = (el: any) => {
|
|
92
|
+
ctx.registerInput(props.index, el as HTMLInputElement | null)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Convenience accessors
|
|
96
|
+
const digit = computed(() => ctx.digits.value[props.index])
|
|
97
|
+
const isFocused = computed(() => ctx.activeIndex.value === props.index)
|
|
98
|
+
const isAnimating = computed(() => ctx.animatingIndices.value.has(props.index))
|
|
99
|
+
const isMorphing = computed(() => ctx.morphingIndices.value.has(props.index))
|
|
100
|
+
</script>
|
|
101
|
+
|
|
102
|
+
<template>
|
|
103
|
+
<div
|
|
104
|
+
v-bind="$attrs"
|
|
105
|
+
style="perspective: 500px;"
|
|
106
|
+
:class="cn(
|
|
107
|
+
's-otp-box relative flex items-center justify-center overflow-hidden transition-all duration-200',
|
|
108
|
+
sizeConfig.box,
|
|
109
|
+
roundedConfig,
|
|
110
|
+
variantClasses,
|
|
111
|
+
{
|
|
112
|
+
// Focus states
|
|
113
|
+
'ring-2 ring-primary/40 border-primary!': isFocused && r.variant !== 'underlined',
|
|
114
|
+
'border-primary!': isFocused && r.variant === 'underlined',
|
|
115
|
+
|
|
116
|
+
// Success state
|
|
117
|
+
'border-emerald-500! ring-emerald-500/30': ctx.showSuccess.value,
|
|
118
|
+
'bg-emerald-500/10': ctx.showSuccess.value && (r.variant === 'filled' || r.variant === 'morphing'),
|
|
119
|
+
|
|
120
|
+
// Error state
|
|
121
|
+
'border-red-500!': ctx.showError.value || ctx.error.value,
|
|
122
|
+
'bg-red-500/10': (ctx.showError.value || ctx.error.value) && (r.variant === 'filled' || r.variant === 'morphing'),
|
|
123
|
+
|
|
124
|
+
// Entry animation
|
|
125
|
+
'animate-fade-in': r.entryAnimation === 'fade',
|
|
126
|
+
'animate-slide-up': r.entryAnimation === 'slide-up',
|
|
127
|
+
'animate-slide-down': r.entryAnimation === 'slide-down',
|
|
128
|
+
'animate-scale-in': r.entryAnimation === 'scale',
|
|
129
|
+
'animate-rotate-in': r.entryAnimation === 'rotate',
|
|
130
|
+
'animate-blur-in': r.entryAnimation === 'blur',
|
|
131
|
+
|
|
132
|
+
// Error animation
|
|
133
|
+
'animate-shake': ctx.showError.value && r.errorAnimation === 'shake',
|
|
134
|
+
'animate-wobble': ctx.showError.value && r.errorAnimation === 'wobble',
|
|
135
|
+
'animate-flash': ctx.showError.value && r.errorAnimation === 'flash',
|
|
136
|
+
|
|
137
|
+
// Success animation
|
|
138
|
+
'animate-celebrate': ctx.showSuccess.value && r.successAnimation === 'celebrate',
|
|
139
|
+
'animate-check-pop': ctx.showSuccess.value && r.successAnimation === 'check',
|
|
140
|
+
'animate-success-ripple': ctx.showSuccess.value && r.successAnimation === 'ripple',
|
|
141
|
+
|
|
142
|
+
// Hover state
|
|
143
|
+
'hover:border-input': !ctx.disabled.value && !isFocused && !ctx.showSuccess.value && !ctx.showError.value && !ctx.error.value,
|
|
144
|
+
|
|
145
|
+
// Morphing variant special styles
|
|
146
|
+
'shadow-lg': r.variant === 'morphing' && isFocused
|
|
147
|
+
},
|
|
148
|
+
$attrs.class ?? ''
|
|
149
|
+
)"
|
|
150
|
+
:style="{
|
|
151
|
+
'--entry-delay': `${props.index * 50}ms`,
|
|
152
|
+
animationDelay: `${props.index * 50}ms`
|
|
153
|
+
}"
|
|
154
|
+
@click="ctx.focusInput(props.index)"
|
|
155
|
+
>
|
|
156
|
+
<!-- Glow effect for morphing variant -->
|
|
157
|
+
<div
|
|
158
|
+
v-if="r.variant === 'morphing' && isFocused"
|
|
159
|
+
class="absolute inset-0 bg-gradient-to-br from-primary/20 to-transparent animate-pulse rounded-inherit"
|
|
160
|
+
/>
|
|
161
|
+
|
|
162
|
+
<!-- Background pulse on input -->
|
|
163
|
+
<div
|
|
164
|
+
v-if="isAnimating && r.inputAnimation !== 'none'"
|
|
165
|
+
class="absolute inset-0 bg-primary/10 animate-ping-once rounded-inherit"
|
|
166
|
+
/>
|
|
167
|
+
|
|
168
|
+
<!-- Hidden input -->
|
|
169
|
+
<input
|
|
170
|
+
:ref="setInputRef"
|
|
171
|
+
type="text"
|
|
172
|
+
:inputmode="ctx.inputMode.value"
|
|
173
|
+
:value="digit"
|
|
174
|
+
:disabled="ctx.disabled.value"
|
|
175
|
+
:readonly="ctx.readonly.value"
|
|
176
|
+
:aria-label="`${ctx.ariaLabel.value || 'OTP'} digit ${props.index + 1}`"
|
|
177
|
+
class="absolute inset-0 w-full h-full text-center bg-transparent outline-none opacity-0 cursor-pointer"
|
|
178
|
+
:class="{ 'cursor-not-allowed': ctx.disabled.value }"
|
|
179
|
+
maxlength="2"
|
|
180
|
+
autocomplete="one-time-code"
|
|
181
|
+
@input="ctx.handleInput($event, props.index)"
|
|
182
|
+
@keydown="ctx.handleKeydown($event, props.index)"
|
|
183
|
+
@paste="ctx.handlePaste($event, props.index)"
|
|
184
|
+
@focus="ctx.handleFocus(props.index)"
|
|
185
|
+
@blur="ctx.handleBlur(props.index)"
|
|
186
|
+
/>
|
|
187
|
+
|
|
188
|
+
<!-- Display character with morph animation -->
|
|
189
|
+
<span
|
|
190
|
+
class="s-otp-char relative z-10 font-bold text-foreground select-none pointer-events-none flex items-center justify-center"
|
|
191
|
+
:class="[
|
|
192
|
+
sizeConfig.text,
|
|
193
|
+
{
|
|
194
|
+
// Character animations (only when not morphing)
|
|
195
|
+
'animate-pop': isAnimating && !isMorphing && r.inputAnimation === 'pop' && digit,
|
|
196
|
+
'animate-squeeze': isAnimating && !isMorphing && r.inputAnimation === 'squeeze' && digit,
|
|
197
|
+
'animate-jelly': isAnimating && !isMorphing && r.inputAnimation === 'jelly' && digit,
|
|
198
|
+
'animate-rubber': isAnimating && !isMorphing && r.inputAnimation === 'rubber' && digit,
|
|
199
|
+
|
|
200
|
+
// Placeholder styling
|
|
201
|
+
'text-muted-foreground': !digit && !isMorphing,
|
|
202
|
+
'opacity-60': !digit && !isMorphing,
|
|
203
|
+
|
|
204
|
+
// Masked styling
|
|
205
|
+
'text-primary': ctx.masked.value && digit,
|
|
206
|
+
|
|
207
|
+
// Active digit glow
|
|
208
|
+
'drop-shadow-[0_0_8px_color-mix(in_srgb,var(--s-primary)_50%,transparent)]': isFocused && digit,
|
|
209
|
+
|
|
210
|
+
// Success color
|
|
211
|
+
'text-emerald-500!': ctx.showSuccess.value && digit,
|
|
212
|
+
|
|
213
|
+
// Morphing 3D perspective
|
|
214
|
+
'will-change-transform': isMorphing
|
|
215
|
+
}
|
|
216
|
+
]"
|
|
217
|
+
:style="ctx.getMorphStyle(props.index)"
|
|
218
|
+
>
|
|
219
|
+
<!-- Custom placeholder slot for empty unfilled state -->
|
|
220
|
+
<template v-if="!digit && !isMorphing">
|
|
221
|
+
<slot
|
|
222
|
+
name="placeholder"
|
|
223
|
+
:index="props.index"
|
|
224
|
+
:is-focused="isFocused"
|
|
225
|
+
:size="r.size"
|
|
226
|
+
>
|
|
227
|
+
{{ r.placeholderChar }}
|
|
228
|
+
</slot>
|
|
229
|
+
</template>
|
|
230
|
+
|
|
231
|
+
<!-- Custom mask slot for hidden/masked input -->
|
|
232
|
+
<template v-else-if="ctx.masked.value && digit && !isMorphing">
|
|
233
|
+
<slot
|
|
234
|
+
name="mask"
|
|
235
|
+
:index="props.index"
|
|
236
|
+
:value="digit"
|
|
237
|
+
:size="r.size"
|
|
238
|
+
>
|
|
239
|
+
{{ r.maskChar }}
|
|
240
|
+
</slot>
|
|
241
|
+
</template>
|
|
242
|
+
|
|
243
|
+
<!-- Custom digit slot for displayed value -->
|
|
244
|
+
<template v-else-if="digit && !isMorphing">
|
|
245
|
+
<slot
|
|
246
|
+
name="digit"
|
|
247
|
+
:index="props.index"
|
|
248
|
+
:value="digit"
|
|
249
|
+
:size="r.size"
|
|
250
|
+
>
|
|
251
|
+
{{ digit.toUpperCase() }}
|
|
252
|
+
</slot>
|
|
253
|
+
</template>
|
|
254
|
+
|
|
255
|
+
<!-- Morphing animation state (no slot customization during morph) -->
|
|
256
|
+
<template v-else>
|
|
257
|
+
{{ ctx.getDisplayChar(props.index) }}
|
|
258
|
+
</template>
|
|
259
|
+
</span>
|
|
260
|
+
|
|
261
|
+
<!-- Cursor blink for empty focused -->
|
|
262
|
+
<span
|
|
263
|
+
v-if="isFocused && !digit && !ctx.disabled.value && !ctx.readonly.value"
|
|
264
|
+
class="absolute h-1/2 w-0.5 bg-primary animate-blink rounded-full"
|
|
265
|
+
/>
|
|
266
|
+
</div>
|
|
267
|
+
</template>
|
|
268
|
+
|
|
269
|
+
<style scoped>
|
|
270
|
+
/* Entry animations */
|
|
271
|
+
@keyframes fade-in {
|
|
272
|
+
from { opacity: 0; }
|
|
273
|
+
to { opacity: 1; }
|
|
274
|
+
}
|
|
275
|
+
.animate-fade-in {
|
|
276
|
+
animation: fade-in 0.3s ease-out both;
|
|
277
|
+
animation-delay: var(--entry-delay);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
@keyframes slide-up {
|
|
281
|
+
from { opacity: 0; transform: translateY(20px); }
|
|
282
|
+
to { opacity: 1; transform: translateY(0); }
|
|
283
|
+
}
|
|
284
|
+
.animate-slide-up {
|
|
285
|
+
animation: slide-up 0.4s ease-out both;
|
|
286
|
+
animation-delay: var(--entry-delay);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
@keyframes slide-down {
|
|
290
|
+
from { opacity: 0; transform: translateY(-20px); }
|
|
291
|
+
to { opacity: 1; transform: translateY(0); }
|
|
292
|
+
}
|
|
293
|
+
.animate-slide-down {
|
|
294
|
+
animation: slide-down 0.4s ease-out both;
|
|
295
|
+
animation-delay: var(--entry-delay);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
@keyframes scale-in {
|
|
299
|
+
from { opacity: 0; transform: scale(0.5); }
|
|
300
|
+
to { opacity: 1; transform: scale(1); }
|
|
301
|
+
}
|
|
302
|
+
.animate-scale-in {
|
|
303
|
+
animation: scale-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
|
|
304
|
+
animation-delay: var(--entry-delay);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
@keyframes rotate-in {
|
|
308
|
+
from { opacity: 0; transform: rotate(-180deg) scale(0.5); }
|
|
309
|
+
to { opacity: 1; transform: rotate(0) scale(1); }
|
|
310
|
+
}
|
|
311
|
+
.animate-rotate-in {
|
|
312
|
+
animation: rotate-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
|
|
313
|
+
animation-delay: var(--entry-delay);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
@keyframes blur-in {
|
|
317
|
+
from { opacity: 0; filter: blur(10px); }
|
|
318
|
+
to { opacity: 1; filter: blur(0); }
|
|
319
|
+
}
|
|
320
|
+
.animate-blur-in {
|
|
321
|
+
animation: blur-in 0.4s ease-out both;
|
|
322
|
+
animation-delay: var(--entry-delay);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/* Input animations */
|
|
326
|
+
@keyframes pop {
|
|
327
|
+
0% { transform: scale(1); }
|
|
328
|
+
50% { transform: scale(1.3); }
|
|
329
|
+
100% { transform: scale(1); }
|
|
330
|
+
}
|
|
331
|
+
.animate-pop {
|
|
332
|
+
animation: pop 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
@keyframes squeeze {
|
|
336
|
+
0% { transform: scale(1, 1); }
|
|
337
|
+
30% { transform: scale(1.2, 0.8); }
|
|
338
|
+
50% { transform: scale(0.9, 1.1); }
|
|
339
|
+
70% { transform: scale(1.05, 0.95); }
|
|
340
|
+
100% { transform: scale(1, 1); }
|
|
341
|
+
}
|
|
342
|
+
.animate-squeeze {
|
|
343
|
+
animation: squeeze 0.3s ease-out;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
@keyframes jelly {
|
|
347
|
+
0% { transform: scale(1, 1); }
|
|
348
|
+
25% { transform: scale(0.9, 1.1); }
|
|
349
|
+
50% { transform: scale(1.1, 0.9); }
|
|
350
|
+
75% { transform: scale(0.95, 1.05); }
|
|
351
|
+
100% { transform: scale(1, 1); }
|
|
352
|
+
}
|
|
353
|
+
.animate-jelly {
|
|
354
|
+
animation: jelly 0.4s ease-out;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
@keyframes rubber {
|
|
358
|
+
0% { transform: scale(1, 1); }
|
|
359
|
+
30% { transform: scale(1.25, 0.75); }
|
|
360
|
+
40% { transform: scale(0.75, 1.25); }
|
|
361
|
+
50% { transform: scale(1.15, 0.85); }
|
|
362
|
+
65% { transform: scale(0.95, 1.05); }
|
|
363
|
+
75% { transform: scale(1.05, 0.95); }
|
|
364
|
+
100% { transform: scale(1, 1); }
|
|
365
|
+
}
|
|
366
|
+
.animate-rubber {
|
|
367
|
+
animation: rubber 0.5s ease-out;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/* Error animations */
|
|
371
|
+
@keyframes shake {
|
|
372
|
+
0%, 100% { transform: translateX(0); }
|
|
373
|
+
10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
|
|
374
|
+
20%, 40%, 60%, 80% { transform: translateX(4px); }
|
|
375
|
+
}
|
|
376
|
+
.animate-shake {
|
|
377
|
+
animation: shake 0.5s ease-out;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
@keyframes wobble {
|
|
381
|
+
0% { transform: translateX(0) rotate(0); }
|
|
382
|
+
15% { transform: translateX(-8px) rotate(-5deg); }
|
|
383
|
+
30% { transform: translateX(6px) rotate(3deg); }
|
|
384
|
+
45% { transform: translateX(-4px) rotate(-3deg); }
|
|
385
|
+
60% { transform: translateX(2px) rotate(2deg); }
|
|
386
|
+
75% { transform: translateX(-1px) rotate(-1deg); }
|
|
387
|
+
100% { transform: translateX(0) rotate(0); }
|
|
388
|
+
}
|
|
389
|
+
.animate-wobble {
|
|
390
|
+
animation: wobble 0.6s ease-out;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
@keyframes flash {
|
|
394
|
+
0%, 50%, 100% { opacity: 1; }
|
|
395
|
+
25%, 75% { opacity: 0.3; }
|
|
396
|
+
}
|
|
397
|
+
.animate-flash {
|
|
398
|
+
animation: flash 0.5s ease-out;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/* Success animations */
|
|
402
|
+
@keyframes celebrate {
|
|
403
|
+
0% { transform: scale(1); }
|
|
404
|
+
10% { transform: scale(1.1) rotate(-3deg); }
|
|
405
|
+
20% { transform: scale(1.1) rotate(3deg); }
|
|
406
|
+
30% { transform: scale(1.1) rotate(-3deg); }
|
|
407
|
+
40% { transform: scale(1.1) rotate(3deg); }
|
|
408
|
+
50% { transform: scale(1.1) rotate(0); }
|
|
409
|
+
100% { transform: scale(1) rotate(0); }
|
|
410
|
+
}
|
|
411
|
+
.animate-celebrate {
|
|
412
|
+
animation: celebrate 0.6s ease-out;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
@keyframes check-pop {
|
|
416
|
+
0% { transform: scale(0); }
|
|
417
|
+
50% { transform: scale(1.2); }
|
|
418
|
+
100% { transform: scale(1); }
|
|
419
|
+
}
|
|
420
|
+
.animate-check-pop {
|
|
421
|
+
animation: check-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
@keyframes success-ripple {
|
|
425
|
+
0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
|
|
426
|
+
100% { box-shadow: 0 0 0 20px rgba(16, 185, 129, 0); }
|
|
427
|
+
}
|
|
428
|
+
.animate-success-ripple {
|
|
429
|
+
animation: success-ripple 0.6s ease-out;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/* Cursor blink */
|
|
433
|
+
@keyframes blink {
|
|
434
|
+
0%, 100% { opacity: 1; }
|
|
435
|
+
50% { opacity: 0; }
|
|
436
|
+
}
|
|
437
|
+
.animate-blink {
|
|
438
|
+
animation: blink 1s step-end infinite;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/* Ping once */
|
|
442
|
+
@keyframes ping-once {
|
|
443
|
+
0% { transform: scale(1); opacity: 0.5; }
|
|
444
|
+
100% { transform: scale(1.5); opacity: 0; }
|
|
445
|
+
}
|
|
446
|
+
.animate-ping-once {
|
|
447
|
+
animation: ping-once 0.3s ease-out forwards;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/* Rounded inherit utility */
|
|
451
|
+
.rounded-inherit {
|
|
452
|
+
border-radius: inherit;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
/* Size for xl */
|
|
456
|
+
.w-18 {
|
|
457
|
+
width: 4.5rem;
|
|
458
|
+
}
|
|
459
|
+
.h-20 {
|
|
460
|
+
height: 5rem;
|
|
461
|
+
}
|
|
462
|
+
</style>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { default as SOTP } from './SOTP.vue'
|
|
2
|
+
export { default as SOTPSlot } from './SOTPSlot.vue'
|
|
3
|
+
export { default as SOTPGroup } from './SOTPGroup.vue'
|
|
4
|
+
export { default as SOTPSeparator } from './SOTPSeparator.vue'
|
|
5
|
+
export { SOTP_INJECTION_KEY, useSOTPContext } from './useOTPContext'
|
|
6
|
+
export type { SOTPContext, MorphData } from './useOTPContext'
|
|
7
|
+
export type * from './types'
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type SOTPVariant = 'outlined' | 'filled' | 'underlined' | 'ghost' | 'morphing'
|
|
2
|
+
export type SOTPSize = 'small' | 'medium' | 'large' | 'xl'
|
|
3
|
+
export type SOTPRounded = 'none' | 'sm' | 'md' | 'lg' | 'full'
|
|
4
|
+
export type SOTPGap = 'tight' | 'normal' | 'wide'
|
|
5
|
+
export type SOTPMode = 'numeric' | 'alphanumeric' | 'alphabetic' | 'any'
|
|
6
|
+
export type SOTPAnimation = 'none' | 'bounce' | 'shake' | 'pulse' | 'flip' | 'morph' | 'glow' | 'wave'
|
|
7
|
+
export type SOTPEntryAnimation = 'none' | 'fade' | 'slide-up' | 'slide-down' | 'scale' | 'rotate' | 'blur'
|
|
8
|
+
export type SOTPInputAnimation = 'none' | 'pop' | 'squeeze' | 'jelly' | 'rubber'
|
|
9
|
+
export type SOTPSuccessAnimation = 'none' | 'celebrate' | 'check' | 'ripple'
|
|
10
|
+
export type SOTPErrorAnimation = 'none' | 'shake' | 'wobble' | 'flash'
|
|
11
|
+
|
|
12
|
+
export interface SOTPVisualDefaults {
|
|
13
|
+
variant: SOTPVariant
|
|
14
|
+
size: SOTPSize
|
|
15
|
+
color: string
|
|
16
|
+
rounded: SOTPRounded
|
|
17
|
+
animation: SOTPAnimation
|
|
18
|
+
entryAnimation: SOTPEntryAnimation
|
|
19
|
+
inputAnimation: SOTPInputAnimation
|
|
20
|
+
successAnimation: SOTPSuccessAnimation
|
|
21
|
+
errorAnimation: SOTPErrorAnimation
|
|
22
|
+
morphText: boolean
|
|
23
|
+
morphDuration: number
|
|
24
|
+
showPlaceholder: boolean
|
|
25
|
+
placeholderChar: string
|
|
26
|
+
maskChar: string
|
|
27
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { inject } from 'vue'
|
|
2
|
+
import type { InjectionKey, Ref } from 'vue'
|
|
3
|
+
import type { SOTPMode, SOTPVisualDefaults } from './types'
|
|
4
|
+
|
|
5
|
+
export interface MorphData {
|
|
6
|
+
from: string
|
|
7
|
+
to: string
|
|
8
|
+
progress: number
|
|
9
|
+
phase: 'out' | 'in'
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface SOTPContext {
|
|
13
|
+
// Reactive state
|
|
14
|
+
digits: Ref<string[]>
|
|
15
|
+
activeIndex: Ref<number>
|
|
16
|
+
isComplete: Ref<boolean>
|
|
17
|
+
showSuccess: Ref<boolean>
|
|
18
|
+
showError: Ref<boolean>
|
|
19
|
+
animatingIndices: Ref<Set<number>>
|
|
20
|
+
morphingIndices: Ref<Map<number, MorphData>>
|
|
21
|
+
|
|
22
|
+
// Behavior props (readonly refs)
|
|
23
|
+
maxlength: Readonly<Ref<number>>
|
|
24
|
+
mode: Readonly<Ref<SOTPMode>>
|
|
25
|
+
masked: Readonly<Ref<boolean>>
|
|
26
|
+
disabled: Readonly<Ref<boolean>>
|
|
27
|
+
readonly: Readonly<Ref<boolean>>
|
|
28
|
+
loading: Readonly<Ref<boolean>>
|
|
29
|
+
allowPaste: Readonly<Ref<boolean>>
|
|
30
|
+
error: Readonly<Ref<string | boolean>>
|
|
31
|
+
success: Readonly<Ref<string | boolean>>
|
|
32
|
+
ariaLabel: Readonly<Ref<string>>
|
|
33
|
+
|
|
34
|
+
// Visual defaults (SOTPSlot falls back to these)
|
|
35
|
+
defaults: Readonly<Ref<SOTPVisualDefaults>>
|
|
36
|
+
|
|
37
|
+
// Computed helpers
|
|
38
|
+
inputPattern: Readonly<Ref<string>>
|
|
39
|
+
inputMode: Readonly<Ref<string>>
|
|
40
|
+
|
|
41
|
+
// Methods for SOTPSlot to call
|
|
42
|
+
registerInput: (index: number, el: HTMLInputElement | null) => void
|
|
43
|
+
handleInput: (event: Event, index: number) => void
|
|
44
|
+
handleKeydown: (event: KeyboardEvent, index: number) => void
|
|
45
|
+
handlePaste: (event: ClipboardEvent, index: number) => void
|
|
46
|
+
handleFocus: (index: number) => void
|
|
47
|
+
handleBlur: (index: number) => void
|
|
48
|
+
focusInput: (index: number) => void
|
|
49
|
+
startMorphAnimation: (index: number, from: string, to: string) => void
|
|
50
|
+
getMorphStyle: (index: number) => Record<string, any>
|
|
51
|
+
getDisplayChar: (index: number) => string
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const SOTP_INJECTION_KEY: InjectionKey<SOTPContext> = Symbol('SOTPContext')
|
|
55
|
+
|
|
56
|
+
export function useSOTPContext(): SOTPContext {
|
|
57
|
+
const ctx = inject(SOTP_INJECTION_KEY)
|
|
58
|
+
if (!ctx) {
|
|
59
|
+
throw new Error('[saka-ui] SOTPSlot must be used inside an SOTP component.')
|
|
60
|
+
}
|
|
61
|
+
return ctx
|
|
62
|
+
}
|