@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,491 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ref, computed, watch, onMounted, onBeforeUnmount, nextTick, type CSSProperties } from 'vue'
|
|
3
|
+
import { cn } from '../../lib/utils'
|
|
4
|
+
|
|
5
|
+
defineOptions({ inheritAttrs: false })
|
|
6
|
+
|
|
7
|
+
export interface Props {
|
|
8
|
+
placement?: 'top' | 'bottom' | 'left' | 'right' | 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end' | 'left-start' | 'left-end' | 'right-start' | 'right-end'
|
|
9
|
+
trigger?: 'hover' | 'click' | 'focus' | 'manual'
|
|
10
|
+
content?: string
|
|
11
|
+
showDelay?: number
|
|
12
|
+
hideDelay?: number
|
|
13
|
+
offset?: number
|
|
14
|
+
arrow?: boolean
|
|
15
|
+
arrowSize?: number
|
|
16
|
+
theme?: 'dark' | 'light' | 'custom'
|
|
17
|
+
color?: string
|
|
18
|
+
textColor?: string
|
|
19
|
+
maxWidth?: string
|
|
20
|
+
disabled?: boolean
|
|
21
|
+
visible?: boolean
|
|
22
|
+
teleport?: string
|
|
23
|
+
zIndex?: number
|
|
24
|
+
interactive?: boolean
|
|
25
|
+
transition?: string
|
|
26
|
+
tooltipClass?: string
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
30
|
+
placement: 'top',
|
|
31
|
+
trigger: 'hover',
|
|
32
|
+
content: undefined,
|
|
33
|
+
showDelay: 100,
|
|
34
|
+
hideDelay: 100,
|
|
35
|
+
offset: 8,
|
|
36
|
+
arrow: true,
|
|
37
|
+
arrowSize: 6,
|
|
38
|
+
theme: 'dark',
|
|
39
|
+
color: undefined,
|
|
40
|
+
textColor: undefined,
|
|
41
|
+
maxWidth: '300px',
|
|
42
|
+
disabled: false,
|
|
43
|
+
visible: undefined,
|
|
44
|
+
teleport: 'body',
|
|
45
|
+
zIndex: 9999,
|
|
46
|
+
interactive: false,
|
|
47
|
+
transition: 'tooltip-fade',
|
|
48
|
+
tooltipClass: undefined
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
const emit = defineEmits<{
|
|
52
|
+
show: []
|
|
53
|
+
hide: []
|
|
54
|
+
toggle: [visible: boolean]
|
|
55
|
+
'update:visible': [visible: boolean]
|
|
56
|
+
}>()
|
|
57
|
+
|
|
58
|
+
// Refs
|
|
59
|
+
const triggerRef = ref<HTMLElement | null>(null)
|
|
60
|
+
const tooltipRef = ref<HTMLElement | null>(null)
|
|
61
|
+
const isVisible = ref(false)
|
|
62
|
+
const actualPlacement = ref(props.placement)
|
|
63
|
+
const tooltipPosition = ref({ top: 0, left: 0 })
|
|
64
|
+
const arrowPosition = ref({ top: '', left: '', right: '', bottom: '' })
|
|
65
|
+
|
|
66
|
+
let showTimeout: ReturnType<typeof setTimeout> | null = null
|
|
67
|
+
let hideTimeout: ReturnType<typeof setTimeout> | null = null
|
|
68
|
+
|
|
69
|
+
// Computed
|
|
70
|
+
const isManual = computed(() => props.trigger === 'manual')
|
|
71
|
+
|
|
72
|
+
const tooltipStyle = computed<CSSProperties>(() => {
|
|
73
|
+
const styles: CSSProperties = {
|
|
74
|
+
position: 'fixed',
|
|
75
|
+
top: `${tooltipPosition.value.top}px`,
|
|
76
|
+
left: `${tooltipPosition.value.left}px`,
|
|
77
|
+
maxWidth: props.maxWidth,
|
|
78
|
+
zIndex: props.zIndex
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (props.theme === 'custom') {
|
|
82
|
+
if (props.color) styles.backgroundColor = props.color
|
|
83
|
+
if (props.textColor) styles.color = props.textColor
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return styles
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
const arrowStyle = computed<CSSProperties>(() => {
|
|
90
|
+
const styles: Record<string, string> = {
|
|
91
|
+
position: 'absolute',
|
|
92
|
+
width: '0',
|
|
93
|
+
height: '0',
|
|
94
|
+
borderStyle: 'solid'
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const size = props.arrowSize
|
|
98
|
+
const placement = actualPlacement.value
|
|
99
|
+
|
|
100
|
+
// Set arrow position
|
|
101
|
+
if (arrowPosition.value.top) styles.top = arrowPosition.value.top
|
|
102
|
+
if (arrowPosition.value.left) styles.left = arrowPosition.value.left
|
|
103
|
+
if (arrowPosition.value.right) styles.right = arrowPosition.value.right
|
|
104
|
+
if (arrowPosition.value.bottom) styles.bottom = arrowPosition.value.bottom
|
|
105
|
+
|
|
106
|
+
// Set arrow borders based on placement
|
|
107
|
+
if (placement.startsWith('top')) {
|
|
108
|
+
styles.borderWidth = `${size}px ${size}px 0 ${size}px`
|
|
109
|
+
styles.borderColor = `${getArrowColor()} transparent transparent transparent`
|
|
110
|
+
styles.bottom = `-${size}px`
|
|
111
|
+
} else if (placement.startsWith('bottom')) {
|
|
112
|
+
styles.borderWidth = `0 ${size}px ${size}px ${size}px`
|
|
113
|
+
styles.borderColor = `transparent transparent ${getArrowColor()} transparent`
|
|
114
|
+
styles.top = `-${size}px`
|
|
115
|
+
} else if (placement.startsWith('left')) {
|
|
116
|
+
styles.borderWidth = `${size}px 0 ${size}px ${size}px`
|
|
117
|
+
styles.borderColor = `transparent transparent transparent ${getArrowColor()}`
|
|
118
|
+
styles.right = `-${size}px`
|
|
119
|
+
} else if (placement.startsWith('right')) {
|
|
120
|
+
styles.borderWidth = `${size}px ${size}px ${size}px 0`
|
|
121
|
+
styles.borderColor = `transparent ${getArrowColor()} transparent transparent`
|
|
122
|
+
styles.left = `-${size}px`
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return styles as CSSProperties
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
const tooltipClasses = computed(() => {
|
|
129
|
+
return cn(
|
|
130
|
+
'px-3 py-2 rounded-md text-sm leading-normal break-words pointer-events-auto shadow-lg',
|
|
131
|
+
props.theme === 'dark' && 'bg-popover text-popover-foreground',
|
|
132
|
+
props.theme === 'light' && 'bg-background text-foreground border border-border',
|
|
133
|
+
props.theme === 'custom' && '',
|
|
134
|
+
props.tooltipClass
|
|
135
|
+
)
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
// Methods
|
|
139
|
+
function getArrowColor(): string {
|
|
140
|
+
if (props.theme === 'custom' && props.color) return props.color
|
|
141
|
+
if (props.theme === 'light') return 'var(--s-background)'
|
|
142
|
+
return 'var(--s-popover)'
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function calculatePosition() {
|
|
146
|
+
if (!triggerRef.value || !tooltipRef.value) return
|
|
147
|
+
|
|
148
|
+
const trigger = triggerRef.value.getBoundingClientRect()
|
|
149
|
+
const tooltip = tooltipRef.value.getBoundingClientRect()
|
|
150
|
+
const viewport = {
|
|
151
|
+
width: window.innerWidth,
|
|
152
|
+
height: window.innerHeight
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
let placement = props.placement
|
|
156
|
+
let top = 0
|
|
157
|
+
let left = 0
|
|
158
|
+
|
|
159
|
+
// Calculate initial position based on placement
|
|
160
|
+
const positions: Record<string, { top: number; left: number }> = {
|
|
161
|
+
'top': {
|
|
162
|
+
top: trigger.top - tooltip.height - props.offset,
|
|
163
|
+
left: trigger.left + (trigger.width / 2) - (tooltip.width / 2)
|
|
164
|
+
},
|
|
165
|
+
'top-start': {
|
|
166
|
+
top: trigger.top - tooltip.height - props.offset,
|
|
167
|
+
left: trigger.left
|
|
168
|
+
},
|
|
169
|
+
'top-end': {
|
|
170
|
+
top: trigger.top - tooltip.height - props.offset,
|
|
171
|
+
left: trigger.right - tooltip.width
|
|
172
|
+
},
|
|
173
|
+
'bottom': {
|
|
174
|
+
top: trigger.bottom + props.offset,
|
|
175
|
+
left: trigger.left + (trigger.width / 2) - (tooltip.width / 2)
|
|
176
|
+
},
|
|
177
|
+
'bottom-start': {
|
|
178
|
+
top: trigger.bottom + props.offset,
|
|
179
|
+
left: trigger.left
|
|
180
|
+
},
|
|
181
|
+
'bottom-end': {
|
|
182
|
+
top: trigger.bottom + props.offset,
|
|
183
|
+
left: trigger.right - tooltip.width
|
|
184
|
+
},
|
|
185
|
+
'left': {
|
|
186
|
+
top: trigger.top + (trigger.height / 2) - (tooltip.height / 2),
|
|
187
|
+
left: trigger.left - tooltip.width - props.offset
|
|
188
|
+
},
|
|
189
|
+
'left-start': {
|
|
190
|
+
top: trigger.top,
|
|
191
|
+
left: trigger.left - tooltip.width - props.offset
|
|
192
|
+
},
|
|
193
|
+
'left-end': {
|
|
194
|
+
top: trigger.bottom - tooltip.height,
|
|
195
|
+
left: trigger.left - tooltip.width - props.offset
|
|
196
|
+
},
|
|
197
|
+
'right': {
|
|
198
|
+
top: trigger.top + (trigger.height / 2) - (tooltip.height / 2),
|
|
199
|
+
left: trigger.right + props.offset
|
|
200
|
+
},
|
|
201
|
+
'right-start': {
|
|
202
|
+
top: trigger.top,
|
|
203
|
+
left: trigger.right + props.offset
|
|
204
|
+
},
|
|
205
|
+
'right-end': {
|
|
206
|
+
top: trigger.bottom - tooltip.height,
|
|
207
|
+
left: trigger.right + props.offset
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
const pos = positions[placement]
|
|
212
|
+
top = pos.top
|
|
213
|
+
left = pos.left
|
|
214
|
+
|
|
215
|
+
// Edge detection and auto-repositioning
|
|
216
|
+
const overflow = {
|
|
217
|
+
top: top < 0,
|
|
218
|
+
bottom: (top + tooltip.height) > viewport.height,
|
|
219
|
+
left: left < 0,
|
|
220
|
+
right: (left + tooltip.width) > viewport.width
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// Flip placement if needed
|
|
224
|
+
if (placement.startsWith('top') && overflow.top) {
|
|
225
|
+
placement = placement.replace('top', 'bottom') as typeof props.placement
|
|
226
|
+
const newPos = positions[placement]
|
|
227
|
+
top = newPos.top
|
|
228
|
+
} else if (placement.startsWith('bottom') && overflow.bottom) {
|
|
229
|
+
placement = placement.replace('bottom', 'top') as typeof props.placement
|
|
230
|
+
const newPos = positions[placement]
|
|
231
|
+
top = newPos.top
|
|
232
|
+
} else if (placement.startsWith('left') && overflow.left) {
|
|
233
|
+
placement = placement.replace('left', 'right') as typeof props.placement
|
|
234
|
+
const newPos = positions[placement]
|
|
235
|
+
left = newPos.left
|
|
236
|
+
} else if (placement.startsWith('right') && overflow.right) {
|
|
237
|
+
placement = placement.replace('right', 'left') as typeof props.placement
|
|
238
|
+
const newPos = positions[placement]
|
|
239
|
+
left = newPos.left
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// Constrain to viewport
|
|
243
|
+
if (left < 8) left = 8
|
|
244
|
+
if (left + tooltip.width > viewport.width - 8) {
|
|
245
|
+
left = viewport.width - tooltip.width - 8
|
|
246
|
+
}
|
|
247
|
+
if (top < 8) top = 8
|
|
248
|
+
if (top + tooltip.height > viewport.height - 8) {
|
|
249
|
+
top = viewport.height - tooltip.height - 8
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
actualPlacement.value = placement
|
|
253
|
+
tooltipPosition.value = { top, left }
|
|
254
|
+
|
|
255
|
+
// Calculate arrow position
|
|
256
|
+
calculateArrowPosition(trigger, tooltip, placement)
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function calculateArrowPosition(trigger: DOMRect, tooltip: DOMRect, placement: typeof props.placement) {
|
|
260
|
+
const arrowPos: typeof arrowPosition.value = { top: '', left: '', right: '', bottom: '' }
|
|
261
|
+
|
|
262
|
+
if (placement.startsWith('top') || placement.startsWith('bottom')) {
|
|
263
|
+
const triggerCenter = trigger.left + (trigger.width / 2)
|
|
264
|
+
const tooltipLeft = tooltipPosition.value.left
|
|
265
|
+
const arrowLeft = triggerCenter - tooltipLeft - props.arrowSize
|
|
266
|
+
arrowPos.left = `${Math.max(props.arrowSize, Math.min(arrowLeft, tooltip.width - props.arrowSize * 3))}px`
|
|
267
|
+
} else if (placement.startsWith('left') || placement.startsWith('right')) {
|
|
268
|
+
const triggerCenter = trigger.top + (trigger.height / 2)
|
|
269
|
+
const tooltipTop = tooltipPosition.value.top
|
|
270
|
+
const arrowTop = triggerCenter - tooltipTop - props.arrowSize
|
|
271
|
+
arrowPos.top = `${Math.max(props.arrowSize, Math.min(arrowTop, tooltip.height - props.arrowSize * 3))}px`
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
arrowPosition.value = arrowPos
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
function show() {
|
|
278
|
+
if (props.disabled || isVisible.value) return
|
|
279
|
+
|
|
280
|
+
if (hideTimeout) {
|
|
281
|
+
clearTimeout(hideTimeout)
|
|
282
|
+
hideTimeout = null
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
showTimeout = setTimeout(async () => {
|
|
286
|
+
isVisible.value = true
|
|
287
|
+
emit('update:visible', true)
|
|
288
|
+
emit('show')
|
|
289
|
+
emit('toggle', true)
|
|
290
|
+
|
|
291
|
+
await nextTick()
|
|
292
|
+
calculatePosition()
|
|
293
|
+
}, props.showDelay)
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
function hide() {
|
|
297
|
+
if (!isVisible.value) return
|
|
298
|
+
|
|
299
|
+
if (showTimeout) {
|
|
300
|
+
clearTimeout(showTimeout)
|
|
301
|
+
showTimeout = null
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
hideTimeout = setTimeout(() => {
|
|
305
|
+
isVisible.value = false
|
|
306
|
+
emit('update:visible', false)
|
|
307
|
+
emit('hide')
|
|
308
|
+
emit('toggle', false)
|
|
309
|
+
}, props.hideDelay)
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
function toggle() {
|
|
313
|
+
if (isVisible.value) {
|
|
314
|
+
hide()
|
|
315
|
+
} else {
|
|
316
|
+
show()
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
function handleTriggerMouseEnter() {
|
|
321
|
+
if (props.trigger === 'hover' && !props.disabled) {
|
|
322
|
+
show()
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
function handleTriggerMouseLeave() {
|
|
327
|
+
if (props.trigger === 'hover' && !props.disabled && !props.interactive) {
|
|
328
|
+
hide()
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
function handleTriggerClick() {
|
|
333
|
+
if (props.trigger === 'click' && !props.disabled) {
|
|
334
|
+
toggle()
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
function handleTriggerFocus() {
|
|
339
|
+
if (props.trigger === 'focus' && !props.disabled) {
|
|
340
|
+
show()
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
function handleTriggerBlur() {
|
|
345
|
+
if (props.trigger === 'focus' && !props.disabled) {
|
|
346
|
+
hide()
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
function handleTooltipMouseEnter() {
|
|
351
|
+
if (props.interactive && props.trigger === 'hover') {
|
|
352
|
+
if (hideTimeout) {
|
|
353
|
+
clearTimeout(hideTimeout)
|
|
354
|
+
hideTimeout = null
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
function handleTooltipMouseLeave() {
|
|
360
|
+
if (props.interactive && props.trigger === 'hover') {
|
|
361
|
+
hide()
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
function handleKeydown(event: KeyboardEvent) {
|
|
366
|
+
if (event.key === 'Escape' && isVisible.value) {
|
|
367
|
+
hide()
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
function handleClickOutside(event: MouseEvent) {
|
|
372
|
+
if (props.trigger !== 'click') return
|
|
373
|
+
|
|
374
|
+
const target = event.target as Node
|
|
375
|
+
if (
|
|
376
|
+
triggerRef.value &&
|
|
377
|
+
tooltipRef.value &&
|
|
378
|
+
!triggerRef.value.contains(target) &&
|
|
379
|
+
!tooltipRef.value.contains(target)
|
|
380
|
+
) {
|
|
381
|
+
hide()
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
function handleScroll() {
|
|
386
|
+
if (isVisible.value) {
|
|
387
|
+
calculatePosition()
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
// Watchers
|
|
392
|
+
watch(() => props.visible, (newVal) => {
|
|
393
|
+
if (isManual.value && newVal !== undefined) {
|
|
394
|
+
if (newVal) {
|
|
395
|
+
show()
|
|
396
|
+
} else {
|
|
397
|
+
hide()
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
})
|
|
401
|
+
|
|
402
|
+
// Lifecycle
|
|
403
|
+
onMounted(() => {
|
|
404
|
+
if (props.trigger === 'click') {
|
|
405
|
+
document.addEventListener('click', handleClickOutside)
|
|
406
|
+
}
|
|
407
|
+
document.addEventListener('keydown', handleKeydown)
|
|
408
|
+
window.addEventListener('scroll', handleScroll, true)
|
|
409
|
+
window.addEventListener('resize', handleScroll)
|
|
410
|
+
})
|
|
411
|
+
|
|
412
|
+
onBeforeUnmount(() => {
|
|
413
|
+
if (showTimeout) clearTimeout(showTimeout)
|
|
414
|
+
if (hideTimeout) clearTimeout(hideTimeout)
|
|
415
|
+
document.removeEventListener('click', handleClickOutside)
|
|
416
|
+
document.removeEventListener('keydown', handleKeydown)
|
|
417
|
+
window.removeEventListener('scroll', handleScroll, true)
|
|
418
|
+
window.removeEventListener('resize', handleScroll)
|
|
419
|
+
})
|
|
420
|
+
|
|
421
|
+
// Expose methods for manual control
|
|
422
|
+
defineExpose({
|
|
423
|
+
show,
|
|
424
|
+
hide,
|
|
425
|
+
toggle
|
|
426
|
+
})
|
|
427
|
+
</script>
|
|
428
|
+
|
|
429
|
+
<template>
|
|
430
|
+
<div :class="cn('inline-block', ($attrs as any).class)" v-bind="{ ...$attrs, class: undefined }">
|
|
431
|
+
<!-- Trigger slot -->
|
|
432
|
+
<div
|
|
433
|
+
ref="triggerRef"
|
|
434
|
+
class="inline-block"
|
|
435
|
+
@mouseenter="handleTriggerMouseEnter"
|
|
436
|
+
@mouseleave="handleTriggerMouseLeave"
|
|
437
|
+
@click="handleTriggerClick"
|
|
438
|
+
@focus="handleTriggerFocus"
|
|
439
|
+
@blur="handleTriggerBlur"
|
|
440
|
+
>
|
|
441
|
+
<slot />
|
|
442
|
+
</div>
|
|
443
|
+
|
|
444
|
+
<!-- Tooltip content -->
|
|
445
|
+
<Teleport :to="teleport">
|
|
446
|
+
<Transition :name="transition">
|
|
447
|
+
<div
|
|
448
|
+
v-show="isVisible"
|
|
449
|
+
ref="tooltipRef"
|
|
450
|
+
:class="tooltipClasses"
|
|
451
|
+
:style="tooltipStyle"
|
|
452
|
+
role="tooltip"
|
|
453
|
+
@mouseenter="handleTooltipMouseEnter"
|
|
454
|
+
@mouseleave="handleTooltipMouseLeave"
|
|
455
|
+
>
|
|
456
|
+
<div class="relative z-1">
|
|
457
|
+
<slot name="content">
|
|
458
|
+
{{ content }}
|
|
459
|
+
</slot>
|
|
460
|
+
</div>
|
|
461
|
+
|
|
462
|
+
<!-- Arrow -->
|
|
463
|
+
<div
|
|
464
|
+
v-if="arrow"
|
|
465
|
+
:style="arrowStyle"
|
|
466
|
+
/>
|
|
467
|
+
</div>
|
|
468
|
+
</Transition>
|
|
469
|
+
</Teleport>
|
|
470
|
+
</div>
|
|
471
|
+
</template>
|
|
472
|
+
|
|
473
|
+
<style scoped>
|
|
474
|
+
/* Transitions */
|
|
475
|
+
.tooltip-fade-enter-active,
|
|
476
|
+
.tooltip-fade-leave-active {
|
|
477
|
+
transition: opacity 0.2s ease, transform 0.2s ease;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
.tooltip-fade-enter-from,
|
|
481
|
+
.tooltip-fade-leave-to {
|
|
482
|
+
opacity: 0;
|
|
483
|
+
transform: scale(0.95);
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
.tooltip-fade-enter-to,
|
|
487
|
+
.tooltip-fade-leave-from {
|
|
488
|
+
opacity: 1;
|
|
489
|
+
transform: scale(1);
|
|
490
|
+
}
|
|
491
|
+
</style>
|