@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,150 @@
|
|
|
1
|
+
import { Ref, MaybeRef } from 'vue';
|
|
2
|
+
export interface DebounceOptions {
|
|
3
|
+
/** Execute immediately on first call, then debounce subsequent calls */
|
|
4
|
+
immediate?: boolean;
|
|
5
|
+
/** Maximum time to wait before forcing execution */
|
|
6
|
+
maxWait?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface ThrottleOptions {
|
|
9
|
+
/** Execute on the leading edge */
|
|
10
|
+
leading?: boolean;
|
|
11
|
+
/** Execute on the trailing edge */
|
|
12
|
+
trailing?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface DebouncedFn<T extends (...args: any[]) => any> {
|
|
15
|
+
/** The debounced function */
|
|
16
|
+
(...args: Parameters<T>): void;
|
|
17
|
+
/** Cancel any pending execution */
|
|
18
|
+
cancel: () => void;
|
|
19
|
+
/** Immediately execute any pending call */
|
|
20
|
+
flush: () => void;
|
|
21
|
+
/** Whether there's a pending execution */
|
|
22
|
+
isPending: () => boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface ThrottledFn<T extends (...args: any[]) => any> {
|
|
25
|
+
/** The throttled function */
|
|
26
|
+
(...args: Parameters<T>): void;
|
|
27
|
+
/** Cancel any pending execution */
|
|
28
|
+
cancel: () => void;
|
|
29
|
+
/** Whether there's a pending execution */
|
|
30
|
+
isPending: () => boolean;
|
|
31
|
+
}
|
|
32
|
+
export interface UseDebounceReturn<T> {
|
|
33
|
+
/** The debounced value */
|
|
34
|
+
value: Ref<T>;
|
|
35
|
+
/** Cancel any pending update */
|
|
36
|
+
cancel: () => void;
|
|
37
|
+
/** Immediately apply pending value */
|
|
38
|
+
flush: () => void;
|
|
39
|
+
/** Whether there's a pending update */
|
|
40
|
+
isPending: Ref<boolean>;
|
|
41
|
+
}
|
|
42
|
+
export interface UseThrottleReturn<T> {
|
|
43
|
+
/** The throttled value */
|
|
44
|
+
value: Ref<T>;
|
|
45
|
+
/** Cancel any pending update */
|
|
46
|
+
cancel: () => void;
|
|
47
|
+
/** Whether there's a pending update */
|
|
48
|
+
isPending: Ref<boolean>;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Debounce a value - the returned value updates after the specified delay
|
|
52
|
+
* when the source value stops changing.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* // Basic usage
|
|
56
|
+
* const searchTerm = ref('')
|
|
57
|
+
* const debouncedSearch = useDebounce(searchTerm, 300)
|
|
58
|
+
*
|
|
59
|
+
* // Use debouncedSearch.value for API calls
|
|
60
|
+
* watch(debouncedSearch.value, (value) => {
|
|
61
|
+
* fetchResults(value)
|
|
62
|
+
* })
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* // With max wait
|
|
66
|
+
* const { value, cancel, flush } = useDebounce(inputValue, 500, { maxWait: 2000 })
|
|
67
|
+
*/
|
|
68
|
+
export declare function useDebounce<T>(value: MaybeRef<T>, delay?: MaybeRef<number>, options?: DebounceOptions): UseDebounceReturn<T>;
|
|
69
|
+
/**
|
|
70
|
+
* Create a debounced function that delays invoking until after the specified
|
|
71
|
+
* milliseconds have elapsed since the last call.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* // Basic usage
|
|
75
|
+
* const debouncedSearch = useDebounceFn(() => {
|
|
76
|
+
* console.log('Searching...')
|
|
77
|
+
* }, 300)
|
|
78
|
+
*
|
|
79
|
+
* // Call it multiple times - only executes once after 300ms of inactivity
|
|
80
|
+
* debouncedSearch()
|
|
81
|
+
* debouncedSearch()
|
|
82
|
+
* debouncedSearch()
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* // With immediate option
|
|
86
|
+
* const debouncedSave = useDebounceFn(
|
|
87
|
+
* (data) => saveData(data),
|
|
88
|
+
* 1000,
|
|
89
|
+
* { immediate: true }
|
|
90
|
+
* )
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* // With max wait
|
|
94
|
+
* const debouncedResize = useDebounceFn(
|
|
95
|
+
* () => recalculateLayout(),
|
|
96
|
+
* 200,
|
|
97
|
+
* { maxWait: 1000 }
|
|
98
|
+
* )
|
|
99
|
+
*/
|
|
100
|
+
export declare function useDebounceFn<T extends (...args: any[]) => any>(fn: T, delay?: MaybeRef<number>, options?: DebounceOptions): DebouncedFn<T>;
|
|
101
|
+
/**
|
|
102
|
+
* Throttle a value - the returned value updates at most once per specified interval.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* // Basic usage
|
|
106
|
+
* const scrollY = ref(0)
|
|
107
|
+
* const throttledScroll = useThrottle(scrollY, 100)
|
|
108
|
+
*
|
|
109
|
+
* // Updates at most every 100ms
|
|
110
|
+
* window.addEventListener('scroll', () => {
|
|
111
|
+
* scrollY.value = window.scrollY
|
|
112
|
+
* })
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* // With options
|
|
116
|
+
* const { value } = useThrottle(mousePosition, 50, {
|
|
117
|
+
* leading: true,
|
|
118
|
+
* trailing: false
|
|
119
|
+
* })
|
|
120
|
+
*/
|
|
121
|
+
export declare function useThrottle<T>(value: MaybeRef<T>, delay?: MaybeRef<number>, options?: ThrottleOptions): UseThrottleReturn<T>;
|
|
122
|
+
/**
|
|
123
|
+
* Create a throttled function that only invokes at most once per specified interval.
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* // Basic usage
|
|
127
|
+
* const throttledScroll = useThrottleFn(() => {
|
|
128
|
+
* console.log('Scrolled!')
|
|
129
|
+
* }, 100)
|
|
130
|
+
*
|
|
131
|
+
* window.addEventListener('scroll', throttledScroll)
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* // Leading only (execute immediately, then wait)
|
|
135
|
+
* const throttledClick = useThrottleFn(
|
|
136
|
+
* () => handleClick(),
|
|
137
|
+
* 1000,
|
|
138
|
+
* { leading: true, trailing: false }
|
|
139
|
+
* )
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* // Trailing only (wait, then execute)
|
|
143
|
+
* const throttledResize = useThrottleFn(
|
|
144
|
+
* () => recalculate(),
|
|
145
|
+
* 200,
|
|
146
|
+
* { leading: false, trailing: true }
|
|
147
|
+
* )
|
|
148
|
+
*/
|
|
149
|
+
export declare function useThrottleFn<T extends (...args: any[]) => any>(fn: T, delay?: MaybeRef<number>, options?: ThrottleOptions): ThrottledFn<T>;
|
|
150
|
+
export default useDebounce;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { Component } from 'vue';
|
|
2
|
+
export type DialogVariant = 'default' | 'danger' | 'warning' | 'success' | 'info';
|
|
3
|
+
export interface ConfirmOptions {
|
|
4
|
+
/** Dialog title */
|
|
5
|
+
title: string;
|
|
6
|
+
/** Dialog description/message */
|
|
7
|
+
description?: string;
|
|
8
|
+
/** Confirm button text */
|
|
9
|
+
confirmText?: string;
|
|
10
|
+
/** Cancel button text */
|
|
11
|
+
cancelText?: string;
|
|
12
|
+
/** Dialog variant (affects confirm button style) */
|
|
13
|
+
variant?: DialogVariant;
|
|
14
|
+
/** Icon name */
|
|
15
|
+
icon?: string | boolean;
|
|
16
|
+
/** Close on backdrop click */
|
|
17
|
+
closeOnBackdrop?: boolean;
|
|
18
|
+
/** Close on escape key */
|
|
19
|
+
closeOnEscape?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface PromptOptions extends ConfirmOptions {
|
|
22
|
+
/** Input placeholder */
|
|
23
|
+
placeholder?: string;
|
|
24
|
+
/** Default input value */
|
|
25
|
+
defaultValue?: string;
|
|
26
|
+
/** Whether input is required */
|
|
27
|
+
required?: boolean;
|
|
28
|
+
/** Input type */
|
|
29
|
+
inputType?: 'text' | 'password' | 'email' | 'number' | 'textarea';
|
|
30
|
+
/** Minimum length for input */
|
|
31
|
+
minLength?: number;
|
|
32
|
+
/** Maximum length for input */
|
|
33
|
+
maxLength?: number;
|
|
34
|
+
/** Custom validation function */
|
|
35
|
+
validate?: (value: string) => string | true;
|
|
36
|
+
}
|
|
37
|
+
export interface AlertOptions extends Omit<ConfirmOptions, 'cancelText'> {
|
|
38
|
+
/** Button text */
|
|
39
|
+
buttonText?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface CustomDialogOptions<T = unknown> {
|
|
42
|
+
/** Dialog title (optional for custom component) */
|
|
43
|
+
title?: string;
|
|
44
|
+
/** Custom component to render */
|
|
45
|
+
component: Component;
|
|
46
|
+
/** Props to pass to the component */
|
|
47
|
+
props?: Record<string, unknown>;
|
|
48
|
+
/** Close on backdrop click */
|
|
49
|
+
closeOnBackdrop?: boolean;
|
|
50
|
+
/** Close on escape key */
|
|
51
|
+
closeOnEscape?: boolean;
|
|
52
|
+
/** Modal size */
|
|
53
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
54
|
+
}
|
|
55
|
+
export interface DialogInstance {
|
|
56
|
+
/** Unique dialog ID */
|
|
57
|
+
id: string;
|
|
58
|
+
/** Dialog type */
|
|
59
|
+
type: 'confirm' | 'prompt' | 'alert' | 'custom';
|
|
60
|
+
/** Whether dialog is open */
|
|
61
|
+
isOpen: boolean;
|
|
62
|
+
/** Resolve function */
|
|
63
|
+
resolve: (value: unknown) => void;
|
|
64
|
+
/** Reject function */
|
|
65
|
+
reject: (reason?: unknown) => void;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Dialog composable for programmatic dialogs
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* const dialog = useDialog()
|
|
72
|
+
*
|
|
73
|
+
* // Confirm dialog
|
|
74
|
+
* const confirmed = await dialog.confirm({
|
|
75
|
+
* title: 'Delete Item',
|
|
76
|
+
* description: 'Are you sure?',
|
|
77
|
+
* variant: 'danger'
|
|
78
|
+
* })
|
|
79
|
+
*
|
|
80
|
+
* // Prompt dialog
|
|
81
|
+
* const name = await dialog.prompt({
|
|
82
|
+
* title: 'Enter Name',
|
|
83
|
+
* placeholder: 'John Doe'
|
|
84
|
+
* })
|
|
85
|
+
*
|
|
86
|
+
* // Alert dialog
|
|
87
|
+
* await dialog.alert({
|
|
88
|
+
* title: 'Success',
|
|
89
|
+
* description: 'Operation completed!'
|
|
90
|
+
* })
|
|
91
|
+
*/
|
|
92
|
+
export declare function useDialog(): {
|
|
93
|
+
confirm: (options: ConfirmOptions) => Promise<boolean>;
|
|
94
|
+
prompt: (options: PromptOptions) => Promise<string | null>;
|
|
95
|
+
alert: (options: AlertOptions) => Promise<void>;
|
|
96
|
+
custom: <T = unknown>(options: CustomDialogOptions<T>) => Promise<T | null>;
|
|
97
|
+
closeAll: () => void;
|
|
98
|
+
dialogs: Readonly<import('vue').Ref<readonly {
|
|
99
|
+
readonly id: string;
|
|
100
|
+
readonly type: "confirm" | "prompt" | "alert" | "custom";
|
|
101
|
+
readonly isOpen: boolean;
|
|
102
|
+
readonly resolve: (value: unknown) => void;
|
|
103
|
+
readonly reject: (reason?: unknown) => void;
|
|
104
|
+
}[], readonly {
|
|
105
|
+
readonly id: string;
|
|
106
|
+
readonly type: "confirm" | "prompt" | "alert" | "custom";
|
|
107
|
+
readonly isOpen: boolean;
|
|
108
|
+
readonly resolve: (value: unknown) => void;
|
|
109
|
+
readonly reject: (reason?: unknown) => void;
|
|
110
|
+
}[]>>;
|
|
111
|
+
};
|
|
112
|
+
/** Shorthand for confirm dialog */
|
|
113
|
+
export declare function confirm(options: ConfirmOptions | string): Promise<boolean>;
|
|
114
|
+
/** Shorthand for prompt dialog */
|
|
115
|
+
export declare function prompt(options: PromptOptions | string): Promise<string | null>;
|
|
116
|
+
/** Shorthand for alert dialog */
|
|
117
|
+
export declare function alertDialog(options: AlertOptions | string): Promise<void>;
|
|
118
|
+
export default useDialog;
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { Ref, ComputedRef, WatchStopHandle } from 'vue';
|
|
2
|
+
export type ValidationRule<T = unknown> = (value: T, formData?: Record<string, unknown>) => string | true;
|
|
3
|
+
export type AsyncValidationRule<T = unknown> = (value: T, formData?: Record<string, unknown>) => Promise<string | true>;
|
|
4
|
+
export interface FieldConfig<T = unknown> {
|
|
5
|
+
rules?: (ValidationRule<T> | AsyncValidationRule<T>)[];
|
|
6
|
+
validateOn?: 'input' | 'blur' | 'submit';
|
|
7
|
+
/** Debounce delay in ms for async validations (default: 300) */
|
|
8
|
+
debounce?: number;
|
|
9
|
+
/** Field dependencies - revalidate this field when these fields change */
|
|
10
|
+
deps?: string[];
|
|
11
|
+
/** Whether to persist this field (default: true). Set to false to exclude from persistence */
|
|
12
|
+
persist?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface FieldState<T = unknown> {
|
|
15
|
+
value: Ref<T>;
|
|
16
|
+
error: Ref<string>;
|
|
17
|
+
touched: Ref<boolean>;
|
|
18
|
+
dirty: Ref<boolean>;
|
|
19
|
+
valid: ComputedRef<boolean>;
|
|
20
|
+
validate: () => Promise<boolean>;
|
|
21
|
+
reset: () => void;
|
|
22
|
+
}
|
|
23
|
+
/** Mapped type for type-safe field access */
|
|
24
|
+
export type TypedFields<TValues extends Record<string, unknown>> = {
|
|
25
|
+
[K in keyof TValues]: FieldState<TValues[K]>;
|
|
26
|
+
};
|
|
27
|
+
/** Persistence options for form state */
|
|
28
|
+
export interface PersistOptions {
|
|
29
|
+
/** Storage key for the form data */
|
|
30
|
+
key: string;
|
|
31
|
+
/** Storage type: 'localStorage' or 'sessionStorage' (default: 'localStorage') */
|
|
32
|
+
storage?: 'localStorage' | 'sessionStorage';
|
|
33
|
+
/** Debounce delay for saving in ms (default: 500) */
|
|
34
|
+
debounce?: number;
|
|
35
|
+
}
|
|
36
|
+
/** Zod-like schema interface for type inference */
|
|
37
|
+
export interface ZodLikeSchema<T = unknown> {
|
|
38
|
+
safeParse: (data: unknown) => {
|
|
39
|
+
success: true;
|
|
40
|
+
data: T;
|
|
41
|
+
} | {
|
|
42
|
+
success: false;
|
|
43
|
+
error: {
|
|
44
|
+
errors: Array<{
|
|
45
|
+
path: (string | number)[];
|
|
46
|
+
message: string;
|
|
47
|
+
}>;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
shape?: Record<string, unknown>;
|
|
51
|
+
}
|
|
52
|
+
/** Form state returned by useForm composable */
|
|
53
|
+
export interface FormState<TValues extends Record<string, unknown> = Record<string, unknown>> {
|
|
54
|
+
/** Type-safe field access */
|
|
55
|
+
fields: TypedFields<TValues>;
|
|
56
|
+
errors: ComputedRef<Record<string, string>>;
|
|
57
|
+
valid: ComputedRef<boolean>;
|
|
58
|
+
dirty: ComputedRef<boolean>;
|
|
59
|
+
touched: ComputedRef<boolean>;
|
|
60
|
+
validate: () => Promise<boolean>;
|
|
61
|
+
reset: (values?: Partial<TValues>) => void;
|
|
62
|
+
getValues: () => TValues;
|
|
63
|
+
isSubmitting: Ref<boolean>;
|
|
64
|
+
submitError: Ref<string | null>;
|
|
65
|
+
submitCount: Ref<number>;
|
|
66
|
+
isSubmitSuccessful: Ref<boolean>;
|
|
67
|
+
setValue: <K extends keyof TValues>(name: K, value: TValues[K]) => void;
|
|
68
|
+
setValues: (values: Partial<TValues>) => void;
|
|
69
|
+
getFieldValue: <K extends keyof TValues>(name: K) => TValues[K];
|
|
70
|
+
setError: (name: keyof TValues, error: string) => void;
|
|
71
|
+
clearError: (name: keyof TValues) => void;
|
|
72
|
+
clearErrors: () => void;
|
|
73
|
+
resetField: (name: keyof TValues) => void;
|
|
74
|
+
setFieldTouched: (name: keyof TValues, touched?: boolean) => void;
|
|
75
|
+
setFieldDirty: (name: keyof TValues, dirty?: boolean) => void;
|
|
76
|
+
handleSubmit: <TResult = void>(onSubmit: (values: TValues) => Promise<TResult> | TResult, onError?: (error: unknown) => void) => () => Promise<TResult | undefined>;
|
|
77
|
+
watchForm: (callback: (values: TValues) => void) => WatchStopHandle;
|
|
78
|
+
watchField: <K extends keyof TValues>(name: K, callback: (value: TValues[K], oldValue: TValues[K]) => void) => WatchStopHandle;
|
|
79
|
+
clearPersisted: () => void;
|
|
80
|
+
}
|
|
81
|
+
/** Options for useForm composable */
|
|
82
|
+
export interface UseFormOptions<TValues extends Record<string, unknown> = Record<string, unknown>> {
|
|
83
|
+
/** Initial values for form fields */
|
|
84
|
+
initialValues?: Partial<TValues>;
|
|
85
|
+
/** Field configurations with validation rules */
|
|
86
|
+
fields?: {
|
|
87
|
+
[K in keyof TValues]?: FieldConfig<TValues[K]>;
|
|
88
|
+
};
|
|
89
|
+
/** Zod schema for validation (alternative to fields.rules) */
|
|
90
|
+
schema?: ZodLikeSchema<TValues>;
|
|
91
|
+
/** Global debounce delay for async validations (default: 300ms) */
|
|
92
|
+
debounceDelay?: number;
|
|
93
|
+
/** Validation mode: 'onChange' | 'onBlur' | 'onSubmit' | 'all' (default: 'onChange') */
|
|
94
|
+
mode?: 'onChange' | 'onBlur' | 'onSubmit' | 'all';
|
|
95
|
+
/** Persistence options for auto-saving form state */
|
|
96
|
+
persist?: PersistOptions;
|
|
97
|
+
}
|
|
98
|
+
/** Required field validator */
|
|
99
|
+
export declare const required: (msg?: string) => ValidationRule;
|
|
100
|
+
/** Minimum length validator */
|
|
101
|
+
export declare const minLength: (min: number, msg?: string) => ValidationRule;
|
|
102
|
+
/** Maximum length validator */
|
|
103
|
+
export declare const maxLength: (max: number, msg?: string) => ValidationRule;
|
|
104
|
+
/** Minimum value validator (for numbers) */
|
|
105
|
+
export declare const min: (minVal: number, msg?: string) => ValidationRule;
|
|
106
|
+
/** Maximum value validator (for numbers) */
|
|
107
|
+
export declare const max: (maxVal: number, msg?: string) => ValidationRule;
|
|
108
|
+
/** Email format validator */
|
|
109
|
+
export declare const email: (msg?: string) => ValidationRule;
|
|
110
|
+
/** URL format validator */
|
|
111
|
+
export declare const url: (msg?: string) => ValidationRule;
|
|
112
|
+
/** Regex pattern validator */
|
|
113
|
+
export declare const pattern: (regex: RegExp, msg?: string) => ValidationRule;
|
|
114
|
+
/** Match another field validator */
|
|
115
|
+
export declare const sameAs: (fieldName: string, msg?: string) => ValidationRule;
|
|
116
|
+
/** Contain uppercase letter */
|
|
117
|
+
export declare const hasUppercase: (msg?: string) => ValidationRule;
|
|
118
|
+
/** Contain lowercase letter */
|
|
119
|
+
export declare const hasLowercase: (msg?: string) => ValidationRule;
|
|
120
|
+
/** Contain digit */
|
|
121
|
+
export declare const hasDigit: (msg?: string) => ValidationRule;
|
|
122
|
+
/** Contain special character */
|
|
123
|
+
export declare const hasSpecial: (msg?: string) => ValidationRule;
|
|
124
|
+
/** Alphanumeric only */
|
|
125
|
+
export declare const alphanumeric: (msg?: string) => ValidationRule;
|
|
126
|
+
/** Numeric only */
|
|
127
|
+
export declare const numeric: (msg?: string) => ValidationRule;
|
|
128
|
+
/**
|
|
129
|
+
* Create a custom validator from a boolean function
|
|
130
|
+
* @example custom((v) => v.length > 5, 'Too short')
|
|
131
|
+
* @example custom(async (v) => await checkUsername(v), 'Username taken')
|
|
132
|
+
*/
|
|
133
|
+
export declare const custom: (fn: (value: unknown, formData?: Record<string, unknown>) => boolean | Promise<boolean>, msg?: string) => ValidationRule | AsyncValidationRule;
|
|
134
|
+
/** Password strength levels */
|
|
135
|
+
export declare enum PasswordStrength {
|
|
136
|
+
/** 6+ chars */
|
|
137
|
+
WEAK = "weak",
|
|
138
|
+
/** 8+ chars, 1 uppercase, 1 number */
|
|
139
|
+
MEDIUM = "medium",
|
|
140
|
+
/** 10+ chars, 1 uppercase, 1 lowercase, 1 number, 1 special */
|
|
141
|
+
STRONG = "strong",
|
|
142
|
+
/** 12+ chars, 2 uppercase, 2 lowercase, 2 numbers, 1 special */
|
|
143
|
+
VERY_STRONG = "very_strong"
|
|
144
|
+
}
|
|
145
|
+
/** Password strength validator with configurable levels */
|
|
146
|
+
export declare const passwordStrength: (strength?: PasswordStrength, msg?: string) => ValidationRule;
|
|
147
|
+
/** Check if value is different from another field */
|
|
148
|
+
export declare const different: (fieldName: string, msg?: string) => ValidationRule;
|
|
149
|
+
/** Check if value is in a list of allowed values */
|
|
150
|
+
export declare const oneOf: <T>(allowed: T[], msg?: string) => ValidationRule;
|
|
151
|
+
/** Check if value is NOT in a list of disallowed values */
|
|
152
|
+
export declare const notOneOf: <T>(disallowed: T[], msg?: string) => ValidationRule;
|
|
153
|
+
/**
|
|
154
|
+
* Comprehensive form management composable with validation, submission handling,
|
|
155
|
+
* and reactive state management.
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* const form = useForm({
|
|
159
|
+
* initialValues: { email: '', password: '' },
|
|
160
|
+
* fields: {
|
|
161
|
+
* email: { rules: [required(), email()] },
|
|
162
|
+
* password: { rules: [required(), minLength(8)] }
|
|
163
|
+
* }
|
|
164
|
+
* })
|
|
165
|
+
*
|
|
166
|
+
* // With Zod schema
|
|
167
|
+
* const form = useForm({
|
|
168
|
+
* schema: z.object({
|
|
169
|
+
* email: z.string().email(),
|
|
170
|
+
* password: z.string().min(8)
|
|
171
|
+
* })
|
|
172
|
+
* })
|
|
173
|
+
*
|
|
174
|
+
* const onSubmit = form.handleSubmit(async (values) => {
|
|
175
|
+
* await api.login(values)
|
|
176
|
+
* })
|
|
177
|
+
*/
|
|
178
|
+
export declare function useForm<TValues extends Record<string, unknown> = Record<string, unknown>>(options: UseFormOptions<TValues>): FormState<TValues>;
|
|
179
|
+
export interface SimpleFieldBinding {
|
|
180
|
+
modelValue: unknown;
|
|
181
|
+
error: string;
|
|
182
|
+
'onUpdate:modelValue': (value: unknown) => void;
|
|
183
|
+
onBlur: () => void;
|
|
184
|
+
}
|
|
185
|
+
/** Create bindings for a field to use with v-bind on SInput */
|
|
186
|
+
export declare function createFieldBindings(field: FieldState): SimpleFieldBinding;
|
|
187
|
+
/**
|
|
188
|
+
* Helper to get field bindings for use with FormField scoped slots
|
|
189
|
+
* Returns reactive bindings that automatically sync with form validation
|
|
190
|
+
*/
|
|
191
|
+
export declare function useFormFieldBindings(field: FieldState | null): {
|
|
192
|
+
modelValue: ComputedRef<undefined>;
|
|
193
|
+
error: ComputedRef<string>;
|
|
194
|
+
'onUpdate:modelValue': () => void;
|
|
195
|
+
onBlur: () => void;
|
|
196
|
+
onInput: () => void;
|
|
197
|
+
} | {
|
|
198
|
+
modelValue: Ref<unknown, unknown>;
|
|
199
|
+
error: Ref<string, string>;
|
|
200
|
+
'onUpdate:modelValue': (value: unknown) => void;
|
|
201
|
+
onBlur: () => void;
|
|
202
|
+
onInput: () => void;
|
|
203
|
+
};
|
|
204
|
+
export default useForm;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { MaybeRef, Ref } from 'vue';
|
|
2
|
+
export type ModifierKey = 'ctrl' | 'alt' | 'shift' | 'meta';
|
|
3
|
+
export type KeyCombo = string;
|
|
4
|
+
export interface HotkeyOptions {
|
|
5
|
+
/** Target element to attach the listener to (default: window) */
|
|
6
|
+
target?: MaybeRef<HTMLElement | Window | Document | null>;
|
|
7
|
+
/** Prevent default browser behavior */
|
|
8
|
+
preventDefault?: boolean;
|
|
9
|
+
/** Stop event propagation */
|
|
10
|
+
stopPropagation?: boolean;
|
|
11
|
+
/** Whether the hotkey is enabled */
|
|
12
|
+
enabled?: MaybeRef<boolean>;
|
|
13
|
+
/** Event to listen for */
|
|
14
|
+
event?: 'keydown' | 'keyup';
|
|
15
|
+
/** Only trigger when focused on specific element types */
|
|
16
|
+
scope?: 'global' | 'input' | 'non-input';
|
|
17
|
+
/** Whether to use capture phase */
|
|
18
|
+
capture?: boolean;
|
|
19
|
+
/** Repeat while key is held down */
|
|
20
|
+
repeat?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface HotkeyHandler {
|
|
23
|
+
(event: KeyboardEvent): void;
|
|
24
|
+
}
|
|
25
|
+
export interface UseHotkeyReturn {
|
|
26
|
+
/** Stop listening for the hotkey */
|
|
27
|
+
stop: () => void;
|
|
28
|
+
/** Start listening for the hotkey */
|
|
29
|
+
start: () => void;
|
|
30
|
+
/** Whether the listener is currently active */
|
|
31
|
+
isActive: boolean;
|
|
32
|
+
}
|
|
33
|
+
export interface ParsedHotkey {
|
|
34
|
+
key: string;
|
|
35
|
+
ctrl: boolean;
|
|
36
|
+
alt: boolean;
|
|
37
|
+
shift: boolean;
|
|
38
|
+
meta: boolean;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Register a keyboard hotkey handler.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* // Basic usage
|
|
45
|
+
* useHotkey('ctrl+k', () => {
|
|
46
|
+
* openCommandPalette()
|
|
47
|
+
* })
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* // With options
|
|
51
|
+
* useHotkey('ctrl+s', () => {
|
|
52
|
+
* saveDocument()
|
|
53
|
+
* }, {
|
|
54
|
+
* preventDefault: true,
|
|
55
|
+
* stopPropagation: true
|
|
56
|
+
* })
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* // Multiple modifiers
|
|
60
|
+
* useHotkey('ctrl+shift+s', () => {
|
|
61
|
+
* saveAsDocument()
|
|
62
|
+
* })
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* // Scoped to element
|
|
66
|
+
* const editorRef = ref<HTMLElement>()
|
|
67
|
+
*
|
|
68
|
+
* useHotkey('escape', () => {
|
|
69
|
+
* closeEditor()
|
|
70
|
+
* }, {
|
|
71
|
+
* target: editorRef
|
|
72
|
+
* })
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* // Only when not in input
|
|
76
|
+
* useHotkey('/', () => {
|
|
77
|
+
* focusSearch()
|
|
78
|
+
* }, {
|
|
79
|
+
* scope: 'non-input'
|
|
80
|
+
* })
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* // Mac-style command key
|
|
84
|
+
* useHotkey('meta+c', () => {
|
|
85
|
+
* copy()
|
|
86
|
+
* })
|
|
87
|
+
* // Or use 'cmd' alias
|
|
88
|
+
* useHotkey('cmd+v', () => {
|
|
89
|
+
* paste()
|
|
90
|
+
* })
|
|
91
|
+
*/
|
|
92
|
+
export declare function useHotkey(combo: KeyCombo, handler: HotkeyHandler, options?: HotkeyOptions): UseHotkeyReturn;
|
|
93
|
+
/**
|
|
94
|
+
* Register multiple hotkeys at once.
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* useHotkeys({
|
|
98
|
+
* 'ctrl+s': () => save(),
|
|
99
|
+
* 'ctrl+z': () => undo(),
|
|
100
|
+
* 'ctrl+shift+z': () => redo(),
|
|
101
|
+
* 'escape': () => close()
|
|
102
|
+
* }, {
|
|
103
|
+
* preventDefault: true
|
|
104
|
+
* })
|
|
105
|
+
*/
|
|
106
|
+
export declare function useHotkeys(bindings: Record<KeyCombo, HotkeyHandler>, options?: HotkeyOptions): UseHotkeyReturn;
|
|
107
|
+
/**
|
|
108
|
+
* Create a hotkey handler that can be used with v-on.
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* const onKeyDown = createHotkeyHandler({
|
|
112
|
+
* 'enter': () => submit(),
|
|
113
|
+
* 'escape': () => cancel()
|
|
114
|
+
* })
|
|
115
|
+
*
|
|
116
|
+
* // Use in template: @keydown="onKeyDown"
|
|
117
|
+
*/
|
|
118
|
+
export declare function createHotkeyHandler(bindings: Record<KeyCombo, HotkeyHandler>, options?: Omit<HotkeyOptions, 'target' | 'enabled'>): (event: KeyboardEvent) => void;
|
|
119
|
+
/**
|
|
120
|
+
* Check if a hotkey combo is currently pressed.
|
|
121
|
+
* Useful for detecting held keys.
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* const isCtrlPressed = useKeyPressed('ctrl')
|
|
125
|
+
* const isShiftCtrlK = useKeyPressed('ctrl+shift+k')
|
|
126
|
+
*/
|
|
127
|
+
export declare function useKeyPressed(combo: KeyCombo): Ref<boolean>;
|
|
128
|
+
export default useHotkey;
|