@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,261 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
defineOptions({ inheritAttrs: false })
|
|
3
|
+
|
|
4
|
+
import { computed, onMounted, onBeforeUnmount, ref } from 'vue'
|
|
5
|
+
import { cn } from '../../../lib/utils'
|
|
6
|
+
import type { ToastType, ToastOptions } from '../../../composables/useToast'
|
|
7
|
+
import { dismissToast, pauseToast, resumeToast } from '../../../composables/useToast'
|
|
8
|
+
import SIcon from '../SIcon.vue'
|
|
9
|
+
|
|
10
|
+
export interface Props {
|
|
11
|
+
/** Unique toast ID */
|
|
12
|
+
id: string
|
|
13
|
+
/** Toast type */
|
|
14
|
+
type: ToastType
|
|
15
|
+
/** Toast title */
|
|
16
|
+
title?: string
|
|
17
|
+
/** Toast description */
|
|
18
|
+
description?: string
|
|
19
|
+
/** Duration in ms (for display purposes) */
|
|
20
|
+
duration?: number
|
|
21
|
+
/** Show progress bar */
|
|
22
|
+
showProgress?: boolean
|
|
23
|
+
/** Show close button */
|
|
24
|
+
closable?: boolean
|
|
25
|
+
/** Icon name or false to hide */
|
|
26
|
+
icon?: string | boolean
|
|
27
|
+
/** Custom color for custom type */
|
|
28
|
+
color?: string
|
|
29
|
+
/** Progress percentage (0-100) */
|
|
30
|
+
progress?: number
|
|
31
|
+
/** Whether toast is paused */
|
|
32
|
+
paused?: boolean
|
|
33
|
+
/** Custom component to render */
|
|
34
|
+
component?: object
|
|
35
|
+
/** Props for custom component */
|
|
36
|
+
componentProps?: Record<string, unknown>
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
40
|
+
title: undefined,
|
|
41
|
+
description: undefined,
|
|
42
|
+
duration: 5000,
|
|
43
|
+
showProgress: true,
|
|
44
|
+
closable: true,
|
|
45
|
+
icon: undefined,
|
|
46
|
+
color: undefined,
|
|
47
|
+
progress: 100,
|
|
48
|
+
paused: false,
|
|
49
|
+
component: undefined,
|
|
50
|
+
componentProps: undefined
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
const emit = defineEmits<{
|
|
54
|
+
close: []
|
|
55
|
+
click: []
|
|
56
|
+
}>()
|
|
57
|
+
|
|
58
|
+
// Hover state for pause/resume
|
|
59
|
+
const isHovering = ref(false)
|
|
60
|
+
|
|
61
|
+
const handleMouseEnter = () => {
|
|
62
|
+
isHovering.value = true
|
|
63
|
+
pauseToast(props.id)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const handleMouseLeave = () => {
|
|
67
|
+
isHovering.value = false
|
|
68
|
+
resumeToast(props.id)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const handleClose = () => {
|
|
72
|
+
dismissToast(props.id)
|
|
73
|
+
emit('close')
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const handleClick = () => {
|
|
77
|
+
emit('click')
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Type-based styling
|
|
81
|
+
const typeConfig = computed(() => {
|
|
82
|
+
const configs: Record<ToastType, {
|
|
83
|
+
bg: string
|
|
84
|
+
border: string
|
|
85
|
+
text: string
|
|
86
|
+
icon: string
|
|
87
|
+
iconColor: string
|
|
88
|
+
progress: string
|
|
89
|
+
}> = {
|
|
90
|
+
success: {
|
|
91
|
+
bg: 'bg-emerald-50 dark:bg-emerald-950/80',
|
|
92
|
+
border: 'border-emerald-200 dark:border-emerald-800',
|
|
93
|
+
text: 'text-emerald-800 dark:text-emerald-200',
|
|
94
|
+
icon: 'check-circle',
|
|
95
|
+
iconColor: 'text-emerald-600 dark:text-emerald-400',
|
|
96
|
+
progress: 'bg-emerald-500'
|
|
97
|
+
},
|
|
98
|
+
error: {
|
|
99
|
+
bg: 'bg-red-50 dark:bg-red-950/80',
|
|
100
|
+
border: 'border-red-200 dark:border-red-800',
|
|
101
|
+
text: 'text-red-800 dark:text-red-200',
|
|
102
|
+
icon: 'alert-circle',
|
|
103
|
+
iconColor: 'text-red-600 dark:text-red-400',
|
|
104
|
+
progress: 'bg-red-500'
|
|
105
|
+
},
|
|
106
|
+
warning: {
|
|
107
|
+
bg: 'bg-amber-50 dark:bg-amber-950/80',
|
|
108
|
+
border: 'border-amber-200 dark:border-amber-800',
|
|
109
|
+
text: 'text-amber-800 dark:text-amber-200',
|
|
110
|
+
icon: 'alert',
|
|
111
|
+
iconColor: 'text-amber-600 dark:text-amber-400',
|
|
112
|
+
progress: 'bg-amber-500'
|
|
113
|
+
},
|
|
114
|
+
info: {
|
|
115
|
+
bg: 'bg-blue-50 dark:bg-blue-950/80',
|
|
116
|
+
border: 'border-blue-200 dark:border-blue-800',
|
|
117
|
+
text: 'text-blue-800 dark:text-blue-200',
|
|
118
|
+
icon: 'information',
|
|
119
|
+
iconColor: 'text-blue-600 dark:text-blue-400',
|
|
120
|
+
progress: 'bg-blue-500'
|
|
121
|
+
},
|
|
122
|
+
loading: {
|
|
123
|
+
bg: 'bg-slate-50 dark:bg-slate-900/80',
|
|
124
|
+
border: 'border-slate-200 dark:border-slate-700',
|
|
125
|
+
text: 'text-slate-800 dark:text-slate-200',
|
|
126
|
+
icon: 'loading',
|
|
127
|
+
iconColor: 'text-slate-600 dark:text-slate-400',
|
|
128
|
+
progress: 'bg-slate-500'
|
|
129
|
+
},
|
|
130
|
+
custom: {
|
|
131
|
+
bg: 'bg-muted',
|
|
132
|
+
border: 'border-border',
|
|
133
|
+
text: 'text-foreground',
|
|
134
|
+
icon: 'bell',
|
|
135
|
+
iconColor: 'text-muted-foreground',
|
|
136
|
+
progress: 'bg-primary'
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return configs[props.type]
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
const displayIcon = computed(() => {
|
|
143
|
+
if (props.icon === false) return null
|
|
144
|
+
if (typeof props.icon === 'string') return props.icon
|
|
145
|
+
return typeConfig.value.icon
|
|
146
|
+
})
|
|
147
|
+
|
|
148
|
+
const customStyle = computed(() => {
|
|
149
|
+
if (props.type === 'custom' && props.color) {
|
|
150
|
+
return {
|
|
151
|
+
'--toast-color': props.color,
|
|
152
|
+
borderLeftColor: props.color
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return {}
|
|
156
|
+
})
|
|
157
|
+
|
|
158
|
+
const isLoading = computed(() => props.type === 'loading')
|
|
159
|
+
</script>
|
|
160
|
+
|
|
161
|
+
<template>
|
|
162
|
+
<div
|
|
163
|
+
v-bind="$attrs"
|
|
164
|
+
:class="cn(
|
|
165
|
+
's-toast relative flex items-start gap-3 p-4 rounded-xl border shadow-lg backdrop-blur-sm min-w-[320px] max-w-[420px] cursor-pointer transition-all duration-200',
|
|
166
|
+
typeConfig.bg,
|
|
167
|
+
typeConfig.border,
|
|
168
|
+
typeConfig.text,
|
|
169
|
+
!isLoading && 'hover:scale-[1.02]',
|
|
170
|
+
$attrs.class ?? ''
|
|
171
|
+
)"
|
|
172
|
+
:style="customStyle"
|
|
173
|
+
role="alert"
|
|
174
|
+
aria-live="polite"
|
|
175
|
+
@mouseenter="handleMouseEnter"
|
|
176
|
+
@mouseleave="handleMouseLeave"
|
|
177
|
+
@click="handleClick"
|
|
178
|
+
>
|
|
179
|
+
<!-- Icon -->
|
|
180
|
+
<div
|
|
181
|
+
v-if="displayIcon"
|
|
182
|
+
class="flex-shrink-0 mt-0.5"
|
|
183
|
+
:class="typeConfig.iconColor"
|
|
184
|
+
>
|
|
185
|
+
<SIcon
|
|
186
|
+
:name="displayIcon"
|
|
187
|
+
:class="{ 'animate-spin': isLoading }"
|
|
188
|
+
size="20"
|
|
189
|
+
/>
|
|
190
|
+
</div>
|
|
191
|
+
|
|
192
|
+
<!-- Content -->
|
|
193
|
+
<div class="flex-1 min-w-0">
|
|
194
|
+
<!-- Custom component -->
|
|
195
|
+
<component
|
|
196
|
+
v-if="component"
|
|
197
|
+
:is="component"
|
|
198
|
+
v-bind="componentProps"
|
|
199
|
+
/>
|
|
200
|
+
|
|
201
|
+
<!-- Default content -->
|
|
202
|
+
<template v-else>
|
|
203
|
+
<p
|
|
204
|
+
v-if="title"
|
|
205
|
+
class="font-semibold text-sm leading-tight"
|
|
206
|
+
:class="typeConfig.text"
|
|
207
|
+
>
|
|
208
|
+
{{ title }}
|
|
209
|
+
</p>
|
|
210
|
+
<p
|
|
211
|
+
v-if="description"
|
|
212
|
+
class="text-sm opacity-90 mt-0.5"
|
|
213
|
+
:class="{ 'mt-1': title }"
|
|
214
|
+
>
|
|
215
|
+
{{ description }}
|
|
216
|
+
</p>
|
|
217
|
+
</template>
|
|
218
|
+
</div>
|
|
219
|
+
|
|
220
|
+
<!-- Close button -->
|
|
221
|
+
<button
|
|
222
|
+
v-if="closable && !isLoading"
|
|
223
|
+
type="button"
|
|
224
|
+
class="flex-shrink-0 p-1 -m-1 rounded-lg opacity-60 hover:opacity-100 transition-opacity"
|
|
225
|
+
:class="typeConfig.iconColor"
|
|
226
|
+
aria-label="Dismiss"
|
|
227
|
+
@click.stop="handleClose"
|
|
228
|
+
>
|
|
229
|
+
<SIcon name="close" size="16" />
|
|
230
|
+
</button>
|
|
231
|
+
|
|
232
|
+
<!-- Progress bar -->
|
|
233
|
+
<div
|
|
234
|
+
v-if="showProgress && duration > 0 && !isLoading"
|
|
235
|
+
class="absolute bottom-0 left-0 right-0 h-1 rounded-b-xl overflow-hidden"
|
|
236
|
+
>
|
|
237
|
+
<div
|
|
238
|
+
class="h-full transition-all duration-100 ease-linear"
|
|
239
|
+
:class="typeConfig.progress"
|
|
240
|
+
:style="{ width: `${progress}%` }"
|
|
241
|
+
/>
|
|
242
|
+
</div>
|
|
243
|
+
</div>
|
|
244
|
+
</template>
|
|
245
|
+
|
|
246
|
+
<style scoped>
|
|
247
|
+
.s-toast {
|
|
248
|
+
animation: toast-enter 0.3s ease-out;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
@keyframes toast-enter {
|
|
252
|
+
from {
|
|
253
|
+
opacity: 0;
|
|
254
|
+
transform: translateY(-10px) scale(0.95);
|
|
255
|
+
}
|
|
256
|
+
to {
|
|
257
|
+
opacity: 1;
|
|
258
|
+
transform: translateY(0) scale(1);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
</style>
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
defineOptions({ inheritAttrs: false })
|
|
3
|
+
|
|
4
|
+
import { computed, Teleport, TransitionGroup } from 'vue'
|
|
5
|
+
import { getToasts, getToastConfig, type ToastPosition } from '../../../composables/useToast'
|
|
6
|
+
import SToast from './SToast.vue'
|
|
7
|
+
|
|
8
|
+
export interface Props {
|
|
9
|
+
/** Position to render toasts (defaults to global config) */
|
|
10
|
+
position?: ToastPosition
|
|
11
|
+
/** Maximum toasts to show (defaults to global config) */
|
|
12
|
+
maxToasts?: number
|
|
13
|
+
/** Gap between toasts in px */
|
|
14
|
+
gap?: number
|
|
15
|
+
/** Teleport target */
|
|
16
|
+
teleport?: boolean | string
|
|
17
|
+
/** Z-index for the container */
|
|
18
|
+
zIndex?: number
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
22
|
+
position: undefined,
|
|
23
|
+
maxToasts: undefined,
|
|
24
|
+
gap: undefined,
|
|
25
|
+
teleport: true,
|
|
26
|
+
zIndex: 9999
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
const toasts = getToasts()
|
|
30
|
+
const config = getToastConfig()
|
|
31
|
+
|
|
32
|
+
const effectivePosition = computed(() => props.position ?? config.position)
|
|
33
|
+
const effectiveMaxToasts = computed(() => props.maxToasts ?? config.maxToasts)
|
|
34
|
+
const effectiveGap = computed(() => props.gap ?? config.gap)
|
|
35
|
+
|
|
36
|
+
// Filter toasts for this position
|
|
37
|
+
const positionToasts = computed(() => {
|
|
38
|
+
const filtered = toasts.value.filter(t => {
|
|
39
|
+
const toastPosition = t.options.position ?? config.position
|
|
40
|
+
return toastPosition === effectivePosition.value
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
// Limit to max toasts
|
|
44
|
+
return filtered.slice(0, effectiveMaxToasts.value)
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
// Position classes
|
|
48
|
+
const positionClasses = computed(() => {
|
|
49
|
+
const classes: Record<ToastPosition, string> = {
|
|
50
|
+
'top-left': 'top-4 left-4 items-start',
|
|
51
|
+
'top-right': 'top-4 right-4 items-end',
|
|
52
|
+
'top-center': 'top-4 left-1/2 -translate-x-1/2 items-center',
|
|
53
|
+
'bottom-left': 'bottom-4 left-4 items-start',
|
|
54
|
+
'bottom-right': 'bottom-4 right-4 items-end',
|
|
55
|
+
'bottom-center': 'bottom-4 left-1/2 -translate-x-1/2 items-center'
|
|
56
|
+
}
|
|
57
|
+
return classes[effectivePosition.value]
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
// Stack direction (bottom positions stack upward)
|
|
61
|
+
const isBottomPosition = computed(() =>
|
|
62
|
+
effectivePosition.value.startsWith('bottom')
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
const teleportTarget = computed(() => {
|
|
66
|
+
if (props.teleport === true) return 'body'
|
|
67
|
+
if (typeof props.teleport === 'string') return props.teleport
|
|
68
|
+
return undefined
|
|
69
|
+
})
|
|
70
|
+
</script>
|
|
71
|
+
|
|
72
|
+
<template>
|
|
73
|
+
<Teleport v-if="teleportTarget" :to="teleportTarget" :disabled="!teleportTarget">
|
|
74
|
+
<div
|
|
75
|
+
v-if="positionToasts.length > 0"
|
|
76
|
+
v-bind="$attrs"
|
|
77
|
+
class="s-toast-container fixed flex flex-col pointer-events-none"
|
|
78
|
+
:class="[positionClasses, isBottomPosition ? 'flex-col-reverse' : 'flex-col']"
|
|
79
|
+
:style="{
|
|
80
|
+
zIndex,
|
|
81
|
+
gap: `${effectiveGap}px`
|
|
82
|
+
}"
|
|
83
|
+
role="region"
|
|
84
|
+
aria-label="Notifications"
|
|
85
|
+
aria-live="polite"
|
|
86
|
+
>
|
|
87
|
+
<TransitionGroup
|
|
88
|
+
:name="isBottomPosition ? 'toast-bottom' : 'toast-top'"
|
|
89
|
+
tag="div"
|
|
90
|
+
class="flex flex-col"
|
|
91
|
+
:class="[isBottomPosition ? 'flex-col-reverse' : 'flex-col']"
|
|
92
|
+
:style="{ gap: `${effectiveGap}px` }"
|
|
93
|
+
>
|
|
94
|
+
<div
|
|
95
|
+
v-for="toast in positionToasts"
|
|
96
|
+
:key="toast.id"
|
|
97
|
+
class="pointer-events-auto"
|
|
98
|
+
>
|
|
99
|
+
<SToast
|
|
100
|
+
:id="toast.id"
|
|
101
|
+
:type="toast.type"
|
|
102
|
+
:title="toast.options.title"
|
|
103
|
+
:description="toast.options.description"
|
|
104
|
+
:duration="toast.options.duration"
|
|
105
|
+
:show-progress="toast.options.showProgress"
|
|
106
|
+
:closable="toast.options.closable"
|
|
107
|
+
:icon="toast.options.icon"
|
|
108
|
+
:color="toast.options.color"
|
|
109
|
+
:progress="toast.progress"
|
|
110
|
+
:paused="toast.paused"
|
|
111
|
+
:component="toast.options.component"
|
|
112
|
+
:component-props="toast.options.componentProps"
|
|
113
|
+
@click="toast.options.onClick?.()"
|
|
114
|
+
/>
|
|
115
|
+
</div>
|
|
116
|
+
</TransitionGroup>
|
|
117
|
+
</div>
|
|
118
|
+
</Teleport>
|
|
119
|
+
|
|
120
|
+
<!-- Non-teleported fallback -->
|
|
121
|
+
<template v-else>
|
|
122
|
+
<div
|
|
123
|
+
v-if="positionToasts.length > 0"
|
|
124
|
+
v-bind="$attrs"
|
|
125
|
+
class="s-toast-container fixed flex flex-col pointer-events-none"
|
|
126
|
+
:class="[positionClasses, isBottomPosition ? 'flex-col-reverse' : 'flex-col']"
|
|
127
|
+
:style="{
|
|
128
|
+
zIndex,
|
|
129
|
+
gap: `${effectiveGap}px`
|
|
130
|
+
}"
|
|
131
|
+
role="region"
|
|
132
|
+
aria-label="Notifications"
|
|
133
|
+
aria-live="polite"
|
|
134
|
+
>
|
|
135
|
+
<TransitionGroup
|
|
136
|
+
:name="isBottomPosition ? 'toast-bottom' : 'toast-top'"
|
|
137
|
+
tag="div"
|
|
138
|
+
class="flex flex-col"
|
|
139
|
+
:class="[isBottomPosition ? 'flex-col-reverse' : 'flex-col']"
|
|
140
|
+
:style="{ gap: `${effectiveGap}px` }"
|
|
141
|
+
>
|
|
142
|
+
<div
|
|
143
|
+
v-for="toast in positionToasts"
|
|
144
|
+
:key="toast.id"
|
|
145
|
+
class="pointer-events-auto"
|
|
146
|
+
>
|
|
147
|
+
<SToast
|
|
148
|
+
:id="toast.id"
|
|
149
|
+
:type="toast.type"
|
|
150
|
+
:title="toast.options.title"
|
|
151
|
+
:description="toast.options.description"
|
|
152
|
+
:duration="toast.options.duration"
|
|
153
|
+
:show-progress="toast.options.showProgress"
|
|
154
|
+
:closable="toast.options.closable"
|
|
155
|
+
:icon="toast.options.icon"
|
|
156
|
+
:color="toast.options.color"
|
|
157
|
+
:progress="toast.progress"
|
|
158
|
+
:paused="toast.paused"
|
|
159
|
+
:component="toast.options.component"
|
|
160
|
+
:component-props="toast.options.componentProps"
|
|
161
|
+
@click="toast.options.onClick?.()"
|
|
162
|
+
/>
|
|
163
|
+
</div>
|
|
164
|
+
</TransitionGroup>
|
|
165
|
+
</div>
|
|
166
|
+
</template>
|
|
167
|
+
</template>
|
|
168
|
+
|
|
169
|
+
<style scoped>
|
|
170
|
+
/* Top position transitions */
|
|
171
|
+
.toast-top-enter-active,
|
|
172
|
+
.toast-top-leave-active {
|
|
173
|
+
transition: all 0.3s ease;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.toast-top-enter-from {
|
|
177
|
+
opacity: 0;
|
|
178
|
+
transform: translateY(-20px) scale(0.95);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.toast-top-leave-to {
|
|
182
|
+
opacity: 0;
|
|
183
|
+
transform: translateX(100%) scale(0.95);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.toast-top-move {
|
|
187
|
+
transition: transform 0.3s ease;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/* Bottom position transitions */
|
|
191
|
+
.toast-bottom-enter-active,
|
|
192
|
+
.toast-bottom-leave-active {
|
|
193
|
+
transition: all 0.3s ease;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.toast-bottom-enter-from {
|
|
197
|
+
opacity: 0;
|
|
198
|
+
transform: translateY(20px) scale(0.95);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.toast-bottom-leave-to {
|
|
202
|
+
opacity: 0;
|
|
203
|
+
transform: translateX(100%) scale(0.95);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.toast-bottom-move {
|
|
207
|
+
transition: transform 0.3s ease;
|
|
208
|
+
}
|
|
209
|
+
</style>
|