@ghostvue/vue 0.0.0-stage → 0.2.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/LICENSE +22 -0
- package/README.md +40 -2
- package/dist/.registries/component-names.generated.d.ts +3 -0
- package/dist/GhostAccordion.vue.d.ts +38 -0
- package/dist/GhostAccordionContent.vue.d.ts +26 -0
- package/dist/GhostAccordionItem.vue.d.ts +20 -0
- package/dist/GhostAccordionTrigger.vue.d.ts +23 -0
- package/dist/GhostAvatar.vue.d.ts +27 -0
- package/dist/GhostBadge.vue.d.ts +16 -0
- package/dist/GhostBreadcrumb.vue.d.ts +28 -0
- package/dist/GhostBreadcrumbEllipsis.vue.d.ts +20 -0
- package/dist/GhostBreadcrumbItem.vue.d.ts +25 -0
- package/dist/GhostBreadcrumbLink.vue.d.ts +25 -0
- package/dist/GhostBreadcrumbList.vue.d.ts +25 -0
- package/dist/GhostBreadcrumbPage.vue.d.ts +25 -0
- package/dist/GhostBreadcrumbSeparator.vue.d.ts +25 -0
- package/dist/GhostButton.vue.d.ts +25 -0
- package/dist/GhostCalendar.vue.d.ts +57 -0
- package/dist/GhostCalendarCell.vue.d.ts +35 -0
- package/dist/GhostCalendarGrid.vue.d.ts +19 -0
- package/dist/GhostCalendarHeader.vue.d.ts +24 -0
- package/dist/GhostCalendarHeading.vue.d.ts +22 -0
- package/dist/GhostCalendarNextButton.vue.d.ts +24 -0
- package/dist/GhostCalendarPrevButton.vue.d.ts +24 -0
- package/dist/GhostCard.vue.d.ts +18 -0
- package/dist/GhostCheckbox.vue.d.ts +48 -0
- package/dist/GhostCheckboxGroup.vue.d.ts +24 -0
- package/dist/GhostCollapsible.vue.d.ts +31 -0
- package/dist/GhostCollapsibleContent.vue.d.ts +30 -0
- package/dist/GhostCollapsibleTrigger.vue.d.ts +28 -0
- package/dist/GhostCombobox.vue.d.ts +69 -0
- package/dist/GhostComboboxContent.vue.d.ts +41 -0
- package/dist/GhostComboboxEmpty.vue.d.ts +21 -0
- package/dist/GhostComboboxGroup.vue.d.ts +21 -0
- package/dist/GhostComboboxInput.vue.d.ts +11 -0
- package/dist/GhostComboboxLabel.vue.d.ts +21 -0
- package/dist/GhostComboboxOption.vue.d.ts +29 -0
- package/dist/GhostComboboxTrigger.vue.d.ts +26 -0
- package/dist/GhostCommandPalette.vue.d.ts +57 -0
- package/dist/GhostCommandPaletteContent.vue.d.ts +47 -0
- package/dist/GhostCommandPaletteEmpty.vue.d.ts +25 -0
- package/dist/GhostCommandPaletteGroup.vue.d.ts +25 -0
- package/dist/GhostCommandPaletteInput.vue.d.ts +13 -0
- package/dist/GhostCommandPaletteItem.vue.d.ts +33 -0
- package/dist/GhostCommandPaletteLabel.vue.d.ts +25 -0
- package/dist/GhostCommandPaletteList.vue.d.ts +25 -0
- package/dist/GhostCommandPaletteOverlay.vue.d.ts +32 -0
- package/dist/GhostCommandPaletteSeparator.vue.d.ts +10 -0
- package/dist/GhostCommandPaletteTitle.vue.d.ts +25 -0
- package/dist/GhostCommandPaletteTrigger.vue.d.ts +28 -0
- package/dist/GhostContextMenu.vue.d.ts +26 -0
- package/dist/GhostContextMenuCheckboxItem.vue.d.ts +63 -0
- package/dist/GhostContextMenuContent.vue.d.ts +39 -0
- package/dist/GhostContextMenuGroup.vue.d.ts +21 -0
- package/dist/GhostContextMenuItem.vue.d.ts +30 -0
- package/dist/GhostContextMenuLabel.vue.d.ts +21 -0
- package/dist/GhostContextMenuRadioGroup.vue.d.ts +31 -0
- package/dist/GhostContextMenuRadioItem.vue.d.ts +31 -0
- package/dist/GhostContextMenuSeparator.vue.d.ts +11 -0
- package/dist/GhostContextMenuTrigger.vue.d.ts +28 -0
- package/dist/GhostDataTable.vue.d.ts +29 -0
- package/dist/GhostDataTablePreset.vue.d.ts +21 -0
- package/dist/GhostDataTableTable.vue.d.ts +20 -0
- package/dist/GhostDatePicker.vue.d.ts +106 -0
- package/dist/GhostDatePickerCalendar.vue.d.ts +16 -0
- package/dist/GhostDatePickerContent.vue.d.ts +46 -0
- package/dist/GhostDatePickerInput.vue.d.ts +19 -0
- package/dist/GhostDatePickerTrigger.vue.d.ts +14 -0
- package/dist/GhostDialog.vue.d.ts +31 -0
- package/dist/GhostDialogClose.vue.d.ts +28 -0
- package/dist/GhostDialogContent.vue.d.ts +50 -0
- package/dist/GhostDialogDescription.vue.d.ts +25 -0
- package/dist/GhostDialogOverlay.vue.d.ts +32 -0
- package/dist/GhostDialogTitle.vue.d.ts +25 -0
- package/dist/GhostDialogTrigger.vue.d.ts +28 -0
- package/dist/GhostDrawer.vue.d.ts +39 -0
- package/dist/GhostDrawerClose.vue.d.ts +28 -0
- package/dist/GhostDrawerContent.vue.d.ts +47 -0
- package/dist/GhostDrawerDescription.vue.d.ts +25 -0
- package/dist/GhostDrawerOverlay.vue.d.ts +32 -0
- package/dist/GhostDrawerTitle.vue.d.ts +25 -0
- package/dist/GhostDrawerTrigger.vue.d.ts +28 -0
- package/dist/GhostDropdownMenu.vue.d.ts +26 -0
- package/dist/GhostDropdownMenuCheckboxItem.vue.d.ts +63 -0
- package/dist/GhostDropdownMenuContent.vue.d.ts +39 -0
- package/dist/GhostDropdownMenuGroup.vue.d.ts +21 -0
- package/dist/GhostDropdownMenuItem.vue.d.ts +30 -0
- package/dist/GhostDropdownMenuLabel.vue.d.ts +21 -0
- package/dist/GhostDropdownMenuRadioGroup.vue.d.ts +31 -0
- package/dist/GhostDropdownMenuRadioItem.vue.d.ts +31 -0
- package/dist/GhostDropdownMenuSeparator.vue.d.ts +11 -0
- package/dist/GhostDropdownMenuTrigger.vue.d.ts +26 -0
- package/dist/GhostEmptyState.vue.d.ts +19 -0
- package/dist/GhostField.vue.d.ts +31 -0
- package/dist/GhostFieldControl.vue.d.ts +13 -0
- package/dist/GhostFieldDescription.vue.d.ts +21 -0
- package/dist/GhostFieldError.vue.d.ts +18 -0
- package/dist/GhostFieldLabel.vue.d.ts +30 -0
- package/dist/GhostFileUpload.vue.d.ts +64 -0
- package/dist/GhostFileUploadDropzone.vue.d.ts +13 -0
- package/dist/GhostFileUploadItem.vue.d.ts +17 -0
- package/dist/GhostFileUploadItemRemove.vue.d.ts +13 -0
- package/dist/GhostFileUploadList.vue.d.ts +13 -0
- package/dist/GhostFileUploadTrigger.vue.d.ts +19 -0
- package/dist/GhostForm.vue.d.ts +25 -0
- package/dist/GhostHoverCard.vue.d.ts +37 -0
- package/dist/GhostHoverCardContent.vue.d.ts +47 -0
- package/dist/GhostHoverCardTrigger.vue.d.ts +28 -0
- package/dist/GhostInlineAlert.vue.d.ts +19 -0
- package/dist/GhostInput.vue.d.ts +26 -0
- package/dist/GhostInteractiveSurface.vue.d.ts +25 -0
- package/dist/GhostKbd.vue.d.ts +25 -0
- package/dist/GhostLink.vue.d.ts +25 -0
- package/dist/GhostMenubar.vue.d.ts +27 -0
- package/dist/GhostMenubarCheckboxItem.vue.d.ts +63 -0
- package/dist/GhostMenubarContent.vue.d.ts +39 -0
- package/dist/GhostMenubarGroup.vue.d.ts +21 -0
- package/dist/GhostMenubarItem.vue.d.ts +30 -0
- package/dist/GhostMenubarLabel.vue.d.ts +21 -0
- package/dist/GhostMenubarMenu.vue.d.ts +26 -0
- package/dist/GhostMenubarRadioGroup.vue.d.ts +31 -0
- package/dist/GhostMenubarRadioItem.vue.d.ts +31 -0
- package/dist/GhostMenubarSeparator.vue.d.ts +11 -0
- package/dist/GhostMenubarTrigger.vue.d.ts +26 -0
- package/dist/GhostNumberInput.vue.d.ts +37 -0
- package/dist/GhostPagination.vue.d.ts +53 -0
- package/dist/GhostPopover.vue.d.ts +28 -0
- package/dist/GhostPopoverClose.vue.d.ts +28 -0
- package/dist/GhostPopoverContent.vue.d.ts +47 -0
- package/dist/GhostPopoverTrigger.vue.d.ts +28 -0
- package/dist/GhostPortal.vue.d.ts +28 -0
- package/dist/GhostPresence.vue.d.ts +27 -0
- package/dist/GhostProgress.vue.d.ts +14 -0
- package/dist/GhostRadioGroup.vue.d.ts +36 -0
- package/dist/GhostRadioGroupItem.vue.d.ts +10 -0
- package/dist/GhostScrollArea.vue.d.ts +17 -0
- package/dist/GhostScrollSpy.vue.d.ts +57 -0
- package/dist/GhostScrollSpyItem.vue.d.ts +26 -0
- package/dist/GhostScrollSpyLink.vue.d.ts +27 -0
- package/dist/GhostScrollSpyList.vue.d.ts +24 -0
- package/dist/GhostSegmentedControl.vue.d.ts +44 -0
- package/dist/GhostSegmentedControlIndicator.vue.d.ts +3 -0
- package/dist/GhostSegmentedControlItem.vue.d.ts +30 -0
- package/dist/GhostSelect.vue.d.ts +24 -0
- package/dist/GhostSelectContent.vue.d.ts +41 -0
- package/dist/GhostSelectGroup.vue.d.ts +21 -0
- package/dist/GhostSelectLabel.vue.d.ts +21 -0
- package/dist/GhostSelectOption.vue.d.ts +29 -0
- package/dist/GhostSelectTrigger.vue.d.ts +26 -0
- package/dist/GhostSelectValue.vue.d.ts +14 -0
- package/dist/GhostSeparator.vue.d.ts +7 -0
- package/dist/GhostSkeleton.vue.d.ts +18 -0
- package/dist/GhostSlider.vue.d.ts +141 -0
- package/dist/GhostSpinner.vue.d.ts +8 -0
- package/dist/GhostSubmenu.vue.d.ts +23 -0
- package/dist/GhostSubmenuContent.vue.d.ts +20 -0
- package/dist/GhostSubmenuTrigger.vue.d.ts +17 -0
- package/dist/GhostSwitch.vue.d.ts +37 -0
- package/dist/GhostTable.vue.d.ts +15 -0
- package/dist/GhostTableBody.vue.d.ts +13 -0
- package/dist/GhostTableCaption.vue.d.ts +13 -0
- package/dist/GhostTableCell.vue.d.ts +13 -0
- package/dist/GhostTableFoot.vue.d.ts +13 -0
- package/dist/GhostTableHead.vue.d.ts +13 -0
- package/dist/GhostTableHeaderCell.vue.d.ts +13 -0
- package/dist/GhostTableRow.vue.d.ts +13 -0
- package/dist/GhostTabs.vue.d.ts +37 -0
- package/dist/GhostTabsContent.vue.d.ts +27 -0
- package/dist/GhostTabsList.vue.d.ts +25 -0
- package/dist/GhostTabsTrigger.vue.d.ts +30 -0
- package/dist/GhostTagsInput.vue.d.ts +26 -0
- package/dist/GhostTextarea.vue.d.ts +29 -0
- package/dist/GhostToast.vue.d.ts +17 -0
- package/dist/GhostToastAction.vue.d.ts +17 -0
- package/dist/GhostToastClose.vue.d.ts +16 -0
- package/dist/GhostToastDescription.vue.d.ts +12 -0
- package/dist/GhostToastProvider.vue.d.ts +24 -0
- package/dist/GhostToastTitle.vue.d.ts +12 -0
- package/dist/GhostToastViewport.vue.d.ts +25 -0
- package/dist/GhostToggleGroup.vue.d.ts +41 -0
- package/dist/GhostToggleGroupItem.vue.d.ts +30 -0
- package/dist/GhostToolbar.vue.d.ts +29 -0
- package/dist/GhostTooltip.vue.d.ts +36 -0
- package/dist/GhostTooltipContent.vue.d.ts +47 -0
- package/dist/GhostTooltipProvider.vue.d.ts +16 -0
- package/dist/GhostTooltipTrigger.vue.d.ts +28 -0
- package/dist/GhostTree.vue.d.ts +59 -0
- package/dist/GhostTreeGroup.vue.d.ts +22 -0
- package/dist/GhostTreeItem.vue.d.ts +27 -0
- package/dist/GhostTreeTrigger.vue.d.ts +25 -0
- package/dist/GhostVisuallyHidden.vue.d.ts +19 -0
- package/dist/accordion-header-keyboard.d.ts +11 -0
- package/dist/calendar-date-math.d.ts +16 -0
- package/dist/calendar-intl.d.ts +7 -0
- package/dist/calendar-public-date.d.ts +1 -0
- package/dist/command-palette-context.d.ts +6 -0
- package/dist/data-table-interaction.d.ts +57 -0
- package/dist/data-table-processing.d.ts +32 -0
- package/dist/data-table-render.d.ts +40 -0
- package/dist/data-table-slot-bindings.d.ts +21 -0
- package/dist/date-picker-calendar-bridge.d.ts +25 -0
- package/dist/date-picker-value.d.ts +33 -0
- package/dist/define-data-table-columns.d.ts +89 -0
- package/dist/dev-codes.d.ts +179 -0
- package/dist/dialog-shared.d.ts +178 -0
- package/dist/dismissable-layer-stack.d.ts +28 -0
- package/dist/form-reset.d.ts +29 -0
- package/dist/get-pagination-range.d.ts +24 -0
- package/dist/get-tabbable-elements.d.ts +22 -0
- package/dist/ghost-accordion.d.ts +120 -0
- package/dist/ghost-avatar.d.ts +41 -0
- package/dist/ghost-badge.d.ts +11 -0
- package/dist/ghost-breadcrumb.d.ts +114 -0
- package/dist/ghost-button.d.ts +39 -0
- package/dist/ghost-calendar.d.ts +148 -0
- package/dist/ghost-card.d.ts +29 -0
- package/dist/ghost-checkbox-group.d.ts +88 -0
- package/dist/ghost-checkbox.d.ts +51 -0
- package/dist/ghost-collapsible.d.ts +104 -0
- package/dist/ghost-combobox.d.ts +217 -0
- package/dist/ghost-command-palette.d.ts +377 -0
- package/dist/ghost-context-menu.d.ts +226 -0
- package/dist/ghost-data-table-preset.d.ts +107 -0
- package/dist/ghost-data-table-table.d.ts +76 -0
- package/dist/ghost-data-table.d.ts +508 -0
- package/dist/ghost-date-picker.d.ts +301 -0
- package/dist/ghost-dialog.d.ts +256 -0
- package/dist/ghost-drawer.d.ts +268 -0
- package/dist/ghost-dropdown-menu.d.ts +226 -0
- package/dist/ghost-empty-state.d.ts +26 -0
- package/dist/ghost-field.d.ts +172 -0
- package/dist/ghost-file-upload-accept.d.ts +32 -0
- package/dist/ghost-file-upload-messages.d.ts +14 -0
- package/dist/ghost-file-upload.d.ts +325 -0
- package/dist/ghost-form.d.ts +273 -0
- package/dist/ghost-hover-card.d.ts +192 -0
- package/dist/ghost-inline-alert.d.ts +34 -0
- package/dist/ghost-input.d.ts +71 -0
- package/dist/ghost-interactive-surface.d.ts +41 -0
- package/dist/ghost-kbd.d.ts +39 -0
- package/dist/ghost-link.d.ts +58 -0
- package/dist/ghost-menubar.d.ts +260 -0
- package/dist/ghost-number-input.d.ts +88 -0
- package/dist/ghost-pagination.d.ts +92 -0
- package/dist/ghost-popover.d.ts +188 -0
- package/dist/ghost-portal.d.ts +21 -0
- package/dist/ghost-presence.d.ts +78 -0
- package/dist/ghost-progress.d.ts +40 -0
- package/dist/ghost-radio-group.d.ts +100 -0
- package/dist/ghost-scroll-area.d.ts +46 -0
- package/dist/ghost-scroll-spy.d.ts +150 -0
- package/dist/ghost-segmented-control.d.ts +124 -0
- package/dist/ghost-select.d.ts +188 -0
- package/dist/ghost-separator.d.ts +33 -0
- package/dist/ghost-skeleton.d.ts +14 -0
- package/dist/ghost-slider.d.ts +99 -0
- package/dist/ghost-spinner.d.ts +22 -0
- package/dist/ghost-submenu.d.ts +20 -0
- package/dist/ghost-switch.d.ts +77 -0
- package/dist/ghost-table.d.ts +62 -0
- package/dist/ghost-tabs.d.ts +154 -0
- package/dist/ghost-tags-input.d.ts +41 -0
- package/dist/ghost-textarea.d.ts +78 -0
- package/dist/ghost-toast.d.ts +219 -0
- package/dist/ghost-toggle-group.d.ts +123 -0
- package/dist/ghost-toolbar.d.ts +23 -0
- package/dist/ghost-tooltip-provider.d.ts +48 -0
- package/dist/ghost-tooltip.d.ts +190 -0
- package/dist/ghost-tree.d.ts +355 -0
- package/dist/ghost-visually-hidden.d.ts +27 -0
- package/dist/ghostvue.js +19653 -0
- package/dist/has-tabbable-descendants.d.ts +2 -0
- package/dist/index.d.ts +322 -0
- package/dist/invoke-attr-handler.d.ts +15 -0
- package/dist/is-ime-composing.d.ts +28 -0
- package/dist/manifest.json +18406 -0
- package/dist/measure-scroll-overflow.d.ts +6 -0
- package/dist/menu-item-activation.d.ts +39 -0
- package/dist/resolver.d.ts +49 -0
- package/dist/resolver.js +14 -0
- package/dist/scroll-spy-motion.d.ts +26 -0
- package/dist/sort-by-document-order.d.ts +23 -0
- package/dist/sync-calendar-focus-tab-stops.d.ts +2 -0
- package/dist/sync-segmented-control-item-order.d.ts +5 -0
- package/dist/sync-tabs-selection-tab-stops.d.ts +7 -0
- package/dist/sync-toggle-group-selection-tab-stops.d.ts +14 -0
- package/dist/track-reactive-reads.d.ts +13 -0
- package/dist/typeahead-match.d.ts +15 -0
- package/dist/use-collapsible-content-hidden.d.ts +28 -0
- package/dist/use-controllable-state.d.ts +20 -0
- package/dist/use-dismissable-layer.d.ts +48 -0
- package/dist/use-floating.d.ts +38 -0
- package/dist/use-focus-scope.d.ts +41 -0
- package/dist/use-ghost-accordion.d.ts +5 -0
- package/dist/use-ghost-avatar.d.ts +28 -0
- package/dist/use-ghost-badge.d.ts +13 -0
- package/dist/use-ghost-breadcrumb.d.ts +19 -0
- package/dist/use-ghost-button.d.ts +18 -0
- package/dist/use-ghost-calendar.d.ts +3 -0
- package/dist/use-ghost-card.d.ts +15 -0
- package/dist/use-ghost-checkbox-group.d.ts +13 -0
- package/dist/use-ghost-checkbox.d.ts +24 -0
- package/dist/use-ghost-collapsible.d.ts +8 -0
- package/dist/use-ghost-combobox.d.ts +65 -0
- package/dist/use-ghost-command-palette.d.ts +24 -0
- package/dist/use-ghost-context-menu.d.ts +14 -0
- package/dist/use-ghost-data-table.d.ts +55 -0
- package/dist/use-ghost-date-picker.d.ts +11 -0
- package/dist/use-ghost-dialog.d.ts +10 -0
- package/dist/use-ghost-drawer.d.ts +11 -0
- package/dist/use-ghost-dropdown-menu.d.ts +5 -0
- package/dist/use-ghost-empty-state.d.ts +18 -0
- package/dist/use-ghost-field-part-content.d.ts +15 -0
- package/dist/use-ghost-field.d.ts +10 -0
- package/dist/use-ghost-file-upload.d.ts +16 -0
- package/dist/use-ghost-form.d.ts +7 -0
- package/dist/use-ghost-hover-card.d.ts +8 -0
- package/dist/use-ghost-id.d.ts +6 -0
- package/dist/use-ghost-inline-alert.d.ts +20 -0
- package/dist/use-ghost-input.d.ts +29 -0
- package/dist/use-ghost-interactive-surface.d.ts +21 -0
- package/dist/use-ghost-kbd.d.ts +35 -0
- package/dist/use-ghost-link.d.ts +20 -0
- package/dist/use-ghost-menu-branch.d.ts +54 -0
- package/dist/use-ghost-menu-collection.d.ts +30 -0
- package/dist/use-ghost-menu-root.d.ts +13 -0
- package/dist/use-ghost-menubar-menu.d.ts +3 -0
- package/dist/use-ghost-menubar.d.ts +10 -0
- package/dist/use-ghost-number-input.d.ts +63 -0
- package/dist/use-ghost-pagination.d.ts +22 -0
- package/dist/use-ghost-popover.d.ts +8 -0
- package/dist/use-ghost-presence.d.ts +48 -0
- package/dist/use-ghost-progress.d.ts +33 -0
- package/dist/use-ghost-radio-group.d.ts +5 -0
- package/dist/use-ghost-scroll-area.d.ts +23 -0
- package/dist/use-ghost-scroll-spy.d.ts +25 -0
- package/dist/use-ghost-segmented-control.d.ts +6 -0
- package/dist/use-ghost-select.d.ts +62 -0
- package/dist/use-ghost-separator.d.ts +19 -0
- package/dist/use-ghost-skeleton.d.ts +19 -0
- package/dist/use-ghost-slider.d.ts +65 -0
- package/dist/use-ghost-spinner.d.ts +18 -0
- package/dist/use-ghost-switch.d.ts +39 -0
- package/dist/use-ghost-table.d.ts +70 -0
- package/dist/use-ghost-tabs.d.ts +5 -0
- package/dist/use-ghost-textarea.d.ts +44 -0
- package/dist/use-ghost-toast.d.ts +56 -0
- package/dist/use-ghost-toggle-group.d.ts +6 -0
- package/dist/use-ghost-toolbar.d.ts +23 -0
- package/dist/use-ghost-tooltip.d.ts +8 -0
- package/dist/use-ghost-tree.d.ts +14 -0
- package/dist/use-ghost-visually-hidden.d.ts +35 -0
- package/dist/use-inert-others.d.ts +20 -0
- package/dist/use-roving-focus.d.ts +22 -0
- package/dist/use-scroll-lock.d.ts +13 -0
- package/package.json +60 -4
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal `accept` matcher for {@link GhostFileUpload}. Private to
|
|
3
|
+
* `@ghostvue/vue` until a second consumer proves a need (see the spec's
|
|
4
|
+
* Composition section).
|
|
5
|
+
*
|
|
6
|
+
* The matcher is client-side UX only: `file.type` and `file.name` come from
|
|
7
|
+
* the operating system and the user, so a match is not a guarantee about the
|
|
8
|
+
* file's real content.
|
|
9
|
+
*/
|
|
10
|
+
/** One parsed, valid `accept` token. Values are lowercased. */
|
|
11
|
+
export type GhostFileUploadAcceptToken = {
|
|
12
|
+
kind: 'extension';
|
|
13
|
+
value: string;
|
|
14
|
+
} | {
|
|
15
|
+
kind: 'wildcard';
|
|
16
|
+
value: string;
|
|
17
|
+
} | {
|
|
18
|
+
kind: 'mime';
|
|
19
|
+
value: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Parses native `accept` grammar into valid tokens. Tokens are comma-separated,
|
|
23
|
+
* trimmed, and lowercased; empty and invalid tokens are dropped, matching how
|
|
24
|
+
* browsers ignore them in the picker. An empty result means "accept everything".
|
|
25
|
+
*/
|
|
26
|
+
export declare function parseGhostFileUploadAccept(accept: string | undefined): GhostFileUploadAcceptToken[];
|
|
27
|
+
/**
|
|
28
|
+
* Whether `file` satisfies at least one token. An empty token list accepts
|
|
29
|
+
* every file. An empty `file.type` (unknown to the operating system) matches
|
|
30
|
+
* extension tokens only: the matcher never guesses a MIME type.
|
|
31
|
+
*/
|
|
32
|
+
export declare function matchesGhostFileUploadAccept(file: Pick<File, 'name' | 'type'>, tokens: readonly GhostFileUploadAcceptToken[]): boolean;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { GhostFileUploadMessages } from './ghost-file-upload.js';
|
|
2
|
+
/**
|
|
3
|
+
* Formats a byte count for `{limit}`, for example `5 MB` or `1.5 kB`, with
|
|
4
|
+
* `Intl.NumberFormat('en', { style: 'unit', unitDisplay: 'short',
|
|
5
|
+
* maximumFractionDigits: 1 })`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function formatGhostFileUploadSize(bytes: number): string;
|
|
8
|
+
/** English defaults for every {@link GhostFileUploadMessages} key. */
|
|
9
|
+
export declare const ghostFileUploadDefaultMessages: GhostFileUploadMessages;
|
|
10
|
+
/**
|
|
11
|
+
* Resolves one message key against consumer overrides at call time, so a
|
|
12
|
+
* reactive `messages` object updates later announcements without caching.
|
|
13
|
+
*/
|
|
14
|
+
export declare function resolveGhostFileUploadMessage<Key extends keyof GhostFileUploadMessages>(overrides: Partial<GhostFileUploadMessages> | undefined, key: Key): GhostFileUploadMessages[Key];
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
import type { ComputedRef, CSSProperties, InjectionKey, MaybeRef, MaybeRefOrGetter, ShallowRef } from 'vue';
|
|
2
|
+
/** Why a file was not added. The first failing validation step decides. */
|
|
3
|
+
export type GhostFileUploadRejectionReason = 'file-type' | 'file-too-large' | 'too-many-files' | 'custom';
|
|
4
|
+
/** Second argument of {@link GhostFileUploadValidate}. */
|
|
5
|
+
export interface GhostFileUploadValidateContext {
|
|
6
|
+
/** Accepted files so far: the current list plus earlier accepted files of this batch. */
|
|
7
|
+
readonly files: readonly File[];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Synchronous, pure consumer check that runs after `accept` and `maxFileSize`
|
|
11
|
+
* and before capacity. Return `null` or `undefined` to accept, or a string
|
|
12
|
+
* (the rejection `code`, possibly empty) to reject. A throw propagates to
|
|
13
|
+
* Vue's error handler and nothing from the batch is committed.
|
|
14
|
+
*/
|
|
15
|
+
export type GhostFileUploadValidate = (file: File, context: GhostFileUploadValidateContext) => string | null | undefined;
|
|
16
|
+
/** Everything `messages.rejected` needs; also the basis of the public payload. */
|
|
17
|
+
export interface GhostFileUploadRejectionContext {
|
|
18
|
+
file: File;
|
|
19
|
+
reason: GhostFileUploadRejectionReason;
|
|
20
|
+
/** The string returned by `validate` when `reason` is `'custom'`. */
|
|
21
|
+
code?: string;
|
|
22
|
+
/** Present when `reason` is `'too-many-files'`. */
|
|
23
|
+
maxFiles?: number;
|
|
24
|
+
/** Present when `reason` is `'file-too-large'`, in bytes. */
|
|
25
|
+
maxFileSize?: number;
|
|
26
|
+
/** Present when `reason` is `'file-type'`. */
|
|
27
|
+
accept?: string;
|
|
28
|
+
}
|
|
29
|
+
/** One rejected file from an intake batch, emitted through `reject`. */
|
|
30
|
+
export interface GhostFileUploadRejection extends GhostFileUploadRejectionContext {
|
|
31
|
+
/** English default from `messages.rejected`; localize through `messages`. */
|
|
32
|
+
message: string;
|
|
33
|
+
}
|
|
34
|
+
/** A list entry with a key for `v-for`. */
|
|
35
|
+
export interface GhostFileUploadEntry {
|
|
36
|
+
/** Opaque, unique within a root, stable for a File instance; not for persistence. */
|
|
37
|
+
id: string;
|
|
38
|
+
file: File;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Announcement and label text. Callbacks own pluralization. Overrides are
|
|
42
|
+
* read when a message is produced, so a reactive object updates later
|
|
43
|
+
* announcements. Returning an empty string omits that part of an announcement.
|
|
44
|
+
*/
|
|
45
|
+
export interface GhostFileUploadMessages {
|
|
46
|
+
/** @default `1 file added.` / `{count} files added.` */
|
|
47
|
+
added(count: number): string;
|
|
48
|
+
/** @default `{name} removed. {n} files remaining.` (with zero and one forms) */
|
|
49
|
+
removed(file: File, remaining: number): string;
|
|
50
|
+
/** @default `All files removed.` */
|
|
51
|
+
cleared(): string;
|
|
52
|
+
/** Per-reason sentence, also used as `GhostFileUploadRejection.message`. */
|
|
53
|
+
rejected(rejection: GhostFileUploadRejectionContext): string;
|
|
54
|
+
/** Used when one intake has more than three rejections. @default `{count} files were not added.` */
|
|
55
|
+
rejectedSummary(count: number): string;
|
|
56
|
+
/** Default accessible name of `GhostFileUploadItemRemove`. @default `Remove {name}` */
|
|
57
|
+
removeLabel(file: File): string;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Props for the {@link GhostFileUpload} root. `aria-describedby` set on the
|
|
61
|
+
* root is routed to the trigger; `aria-invalid` is ignored in favor of
|
|
62
|
+
* `invalid`; every other attribute, `class`, `style`, and listener falls
|
|
63
|
+
* through to the root element.
|
|
64
|
+
*/
|
|
65
|
+
export interface GhostFileUploadProps {
|
|
66
|
+
/** Controlled list. `undefined` is uncontrolled; `[]` is a real empty value. */
|
|
67
|
+
modelValue?: File[];
|
|
68
|
+
/**
|
|
69
|
+
* Uncontrolled seed and form-reset baseline, captured once at setup.
|
|
70
|
+
* @default []
|
|
71
|
+
*/
|
|
72
|
+
defaultValue?: File[];
|
|
73
|
+
/** Native `accept` grammar; a picker hint that is also enforced on intake. */
|
|
74
|
+
accept?: string;
|
|
75
|
+
/** Total list capacity. Floored; not finite or below 1 is unlimited. `1` turns `multiple` off. */
|
|
76
|
+
maxFiles?: number;
|
|
77
|
+
/** Per-file limit in bytes (equal is accepted). Not finite or negative is unset. */
|
|
78
|
+
maxFileSize?: number;
|
|
79
|
+
/** Synchronous, pure consumer check run after `accept` and `maxFileSize`. */
|
|
80
|
+
validate?: GhostFileUploadValidate;
|
|
81
|
+
/** @default false */
|
|
82
|
+
disabled?: boolean;
|
|
83
|
+
/** Consumer validity, combined with native constraint failure. @default false */
|
|
84
|
+
invalid?: boolean;
|
|
85
|
+
/** Native `required` on the form mirror; no effect without `name`. @default false */
|
|
86
|
+
required?: boolean;
|
|
87
|
+
/** Form mirror `name`. Without it nothing is submitted. */
|
|
88
|
+
name?: string;
|
|
89
|
+
/** `form` attribute for the mirror and picker. */
|
|
90
|
+
form?: string;
|
|
91
|
+
/** Id of the trigger (the labelable control), not of the root. */
|
|
92
|
+
id?: string;
|
|
93
|
+
/** Typed, reactive overrides of announcement and label text. */
|
|
94
|
+
messages?: Partial<GhostFileUploadMessages>;
|
|
95
|
+
/**
|
|
96
|
+
* Cancel file drags and drops outside every dropzone while an enabled
|
|
97
|
+
* dropzone is mounted, so a missed drop does not navigate away.
|
|
98
|
+
* @default true
|
|
99
|
+
*/
|
|
100
|
+
preventDocumentDrop?: boolean;
|
|
101
|
+
}
|
|
102
|
+
/** Props for {@link GhostFileUploadTrigger}. */
|
|
103
|
+
export interface GhostFileUploadTriggerProps {
|
|
104
|
+
/** Disables this trigger; combines with the root `disabled`. @default false */
|
|
105
|
+
disabled?: boolean;
|
|
106
|
+
}
|
|
107
|
+
/** Props for {@link GhostFileUploadItem}. */
|
|
108
|
+
export interface GhostFileUploadItemProps {
|
|
109
|
+
/** The entry this item represents. */
|
|
110
|
+
file: File;
|
|
111
|
+
}
|
|
112
|
+
/** Root default slot props. */
|
|
113
|
+
export interface GhostFileUploadSlotProps {
|
|
114
|
+
/** Current list with stable ids for `v-for` keys. */
|
|
115
|
+
entries: readonly GhostFileUploadEntry[];
|
|
116
|
+
/** Rejections from the most recent intake only. */
|
|
117
|
+
rejections: readonly GhostFileUploadRejection[];
|
|
118
|
+
/** `maxFiles` minus list length, never below 0; `undefined` when unlimited. */
|
|
119
|
+
remaining: number | undefined;
|
|
120
|
+
/** Effective invalid state: `invalid` prop or native constraint failure. */
|
|
121
|
+
invalid: boolean;
|
|
122
|
+
/** Opens the native picker. No-op when disabled. */
|
|
123
|
+
openPicker: () => void;
|
|
124
|
+
/** Removes the first identical entry and applies the focus rule. */
|
|
125
|
+
remove: (file: File) => void;
|
|
126
|
+
/** Empties the list and `rejections`, and announces it. */
|
|
127
|
+
clear: () => void;
|
|
128
|
+
/** Empties `rejections` without touching the list. */
|
|
129
|
+
clearRejections: () => void;
|
|
130
|
+
}
|
|
131
|
+
/** {@link GhostFileUploadDropzone} default slot props. */
|
|
132
|
+
export interface GhostFileUploadDropzoneSlotProps {
|
|
133
|
+
/** A file drag is over the dropzone. */
|
|
134
|
+
dragging: boolean;
|
|
135
|
+
}
|
|
136
|
+
/** Template ref contract of {@link GhostFileUpload}. */
|
|
137
|
+
export interface GhostFileUploadExposed {
|
|
138
|
+
/** The root element. */
|
|
139
|
+
readonly element: HTMLElement | null;
|
|
140
|
+
/** Focuses the trigger. */
|
|
141
|
+
focus(options?: FocusOptions): void;
|
|
142
|
+
/** Blurs the trigger. */
|
|
143
|
+
blur(): void;
|
|
144
|
+
/** Opens the native picker; call inside a user gesture. */
|
|
145
|
+
openPicker(): void;
|
|
146
|
+
/** Same as the slot `clear`. */
|
|
147
|
+
clear(): void;
|
|
148
|
+
}
|
|
149
|
+
/** Template ref contract of {@link GhostFileUploadDropzone}. */
|
|
150
|
+
export interface GhostFileUploadDropzoneExposed {
|
|
151
|
+
readonly element: HTMLElement | null;
|
|
152
|
+
}
|
|
153
|
+
/** Template ref contract of {@link GhostFileUploadTrigger}. */
|
|
154
|
+
export interface GhostFileUploadTriggerExposed {
|
|
155
|
+
readonly element: HTMLElement | null;
|
|
156
|
+
focus(options?: FocusOptions): void;
|
|
157
|
+
blur(): void;
|
|
158
|
+
}
|
|
159
|
+
/** Template ref contract of {@link GhostFileUploadList}. */
|
|
160
|
+
export interface GhostFileUploadListExposed {
|
|
161
|
+
/** `null` while the list is empty (the list is not rendered). */
|
|
162
|
+
readonly element: HTMLElement | null;
|
|
163
|
+
}
|
|
164
|
+
/** Template ref contract of {@link GhostFileUploadItem}. */
|
|
165
|
+
export interface GhostFileUploadItemExposed {
|
|
166
|
+
readonly element: HTMLElement | null;
|
|
167
|
+
}
|
|
168
|
+
/** Template ref contract of {@link GhostFileUploadItemRemove}. */
|
|
169
|
+
export interface GhostFileUploadItemRemoveExposed {
|
|
170
|
+
readonly element: HTMLElement | null;
|
|
171
|
+
focus(options?: FocusOptions): void;
|
|
172
|
+
blur(): void;
|
|
173
|
+
}
|
|
174
|
+
/** Options for {@link useGhostFileUpload}. Every value may be a ref or getter. */
|
|
175
|
+
export interface UseGhostFileUploadOptions {
|
|
176
|
+
modelValue?: MaybeRefOrGetter<File[] | undefined>;
|
|
177
|
+
defaultValue?: MaybeRefOrGetter<File[] | undefined>;
|
|
178
|
+
accept?: MaybeRefOrGetter<string | undefined>;
|
|
179
|
+
maxFiles?: MaybeRefOrGetter<number | undefined>;
|
|
180
|
+
maxFileSize?: MaybeRefOrGetter<number | undefined>;
|
|
181
|
+
/**
|
|
182
|
+
* A function or a ref holding one. Not a getter: a bare function is the
|
|
183
|
+
* validator itself, so pass `toRef(props, 'validate')` for a reactive prop.
|
|
184
|
+
*/
|
|
185
|
+
validate?: MaybeRef<GhostFileUploadValidate | undefined>;
|
|
186
|
+
disabled?: MaybeRefOrGetter<boolean | undefined>;
|
|
187
|
+
invalid?: MaybeRefOrGetter<boolean | undefined>;
|
|
188
|
+
required?: MaybeRefOrGetter<boolean | undefined>;
|
|
189
|
+
name?: MaybeRefOrGetter<string | undefined>;
|
|
190
|
+
form?: MaybeRefOrGetter<string | undefined>;
|
|
191
|
+
messages?: MaybeRefOrGetter<Partial<GhostFileUploadMessages> | undefined>;
|
|
192
|
+
/** @default true */
|
|
193
|
+
preventDocumentDrop?: MaybeRefOrGetter<boolean | undefined>;
|
|
194
|
+
/** Id applied to the trigger props. Generated when omitted. */
|
|
195
|
+
id?: MaybeRefOrGetter<string | undefined>;
|
|
196
|
+
/** Transient picker input (bind `pickerProps`). */
|
|
197
|
+
picker?: MaybeRefOrGetter<HTMLInputElement | null | undefined>;
|
|
198
|
+
/** Form mirror input (bind `mirrorProps` when `name` is set). */
|
|
199
|
+
mirror?: MaybeRefOrGetter<HTMLInputElement | null | undefined>;
|
|
200
|
+
/** Trigger button, focused on native invalid and as the last removal fallback. */
|
|
201
|
+
trigger?: MaybeRefOrGetter<HTMLElement | null | undefined>;
|
|
202
|
+
/** Synchronous list write; emit `update:modelValue` here. Receives a new array. */
|
|
203
|
+
onChange?: (files: File[]) => void;
|
|
204
|
+
/** Once per intake with at least one rejection, after `onChange`. */
|
|
205
|
+
onReject?: (rejections: GhostFileUploadRejection[]) => void;
|
|
206
|
+
}
|
|
207
|
+
/** Bindings for the transient picker `input[type="file"]`. */
|
|
208
|
+
export interface GhostFileUploadPickerProps {
|
|
209
|
+
type: 'file';
|
|
210
|
+
hidden: true;
|
|
211
|
+
accept: string | undefined;
|
|
212
|
+
multiple: boolean;
|
|
213
|
+
form: string | undefined;
|
|
214
|
+
disabled: boolean;
|
|
215
|
+
tabindex: -1;
|
|
216
|
+
'data-part': 'picker';
|
|
217
|
+
onChange: (event: Event) => void;
|
|
218
|
+
onClick: (event: MouseEvent) => void;
|
|
219
|
+
}
|
|
220
|
+
/** Bindings for the visually hidden form mirror `input[type="file"]`. */
|
|
221
|
+
export interface GhostFileUploadMirrorProps {
|
|
222
|
+
type: 'file';
|
|
223
|
+
name: string | undefined;
|
|
224
|
+
form: string | undefined;
|
|
225
|
+
multiple: boolean;
|
|
226
|
+
required: boolean;
|
|
227
|
+
disabled: boolean;
|
|
228
|
+
tabindex: -1;
|
|
229
|
+
'aria-hidden': 'true';
|
|
230
|
+
style: CSSProperties;
|
|
231
|
+
'data-part': 'form-input';
|
|
232
|
+
onInvalid: (event: Event) => void;
|
|
233
|
+
}
|
|
234
|
+
/** Bindings for a dropzone element. */
|
|
235
|
+
export interface GhostFileUploadDropzoneProps {
|
|
236
|
+
class: 'ghost-file-upload-dropzone';
|
|
237
|
+
'data-part': 'dropzone';
|
|
238
|
+
'data-state': 'dragging' | 'invalid' | 'disabled' | undefined;
|
|
239
|
+
onDragenter: (event: DragEvent) => void;
|
|
240
|
+
onDragover: (event: DragEvent) => void;
|
|
241
|
+
onDragleave: (event: DragEvent) => void;
|
|
242
|
+
onDrop: (event: DragEvent) => void;
|
|
243
|
+
onClick: (event: MouseEvent) => void;
|
|
244
|
+
}
|
|
245
|
+
/** Bindings for the trigger button. */
|
|
246
|
+
export interface GhostFileUploadTriggerBindings {
|
|
247
|
+
id: string;
|
|
248
|
+
type: 'button';
|
|
249
|
+
class: 'ghost-file-upload-trigger';
|
|
250
|
+
disabled: boolean;
|
|
251
|
+
'aria-invalid': 'true' | undefined;
|
|
252
|
+
'data-part': 'trigger';
|
|
253
|
+
'data-state': 'invalid' | 'disabled' | undefined;
|
|
254
|
+
onClick: (event: MouseEvent) => void;
|
|
255
|
+
}
|
|
256
|
+
/** Bindings for the polite live region. */
|
|
257
|
+
export interface GhostFileUploadLiveRegionProps {
|
|
258
|
+
role: 'status';
|
|
259
|
+
'aria-live': 'polite';
|
|
260
|
+
'aria-atomic': 'true';
|
|
261
|
+
style: CSSProperties;
|
|
262
|
+
'data-part': 'announcer';
|
|
263
|
+
}
|
|
264
|
+
/** Latest announcement; `key` changes on every announcement. */
|
|
265
|
+
export interface GhostFileUploadAnnouncement {
|
|
266
|
+
key: number;
|
|
267
|
+
text: string;
|
|
268
|
+
}
|
|
269
|
+
/** A rendered item registered for the focus-after-removal rule. */
|
|
270
|
+
export interface GhostFileUploadItemRegistration {
|
|
271
|
+
file: () => File;
|
|
272
|
+
element: () => HTMLElement | null;
|
|
273
|
+
removeButton: () => HTMLElement | null;
|
|
274
|
+
}
|
|
275
|
+
/** Return value of {@link useGhostFileUpload}. */
|
|
276
|
+
export interface UseGhostFileUploadReturn {
|
|
277
|
+
files: ComputedRef<File[]>;
|
|
278
|
+
entries: ComputedRef<readonly GhostFileUploadEntry[]>;
|
|
279
|
+
rejections: ShallowRef<readonly GhostFileUploadRejection[]>;
|
|
280
|
+
remaining: ComputedRef<number | undefined>;
|
|
281
|
+
isDisabled: ComputedRef<boolean>;
|
|
282
|
+
isInvalid: ComputedRef<boolean>;
|
|
283
|
+
isRequired: ComputedRef<boolean>;
|
|
284
|
+
isDragging: ShallowRef<boolean>;
|
|
285
|
+
announcement: ShallowRef<GhostFileUploadAnnouncement>;
|
|
286
|
+
/** Single intake path for the picker, drops, and consumer paste surfaces. */
|
|
287
|
+
addFiles: (files: Iterable<File>) => void;
|
|
288
|
+
remove: (file: File) => void;
|
|
289
|
+
clear: () => void;
|
|
290
|
+
clearRejections: () => void;
|
|
291
|
+
openPicker: () => void;
|
|
292
|
+
applyFormReset: () => void;
|
|
293
|
+
/**
|
|
294
|
+
* Call when a dropzone mounts (client only); returns its cleanup. While at
|
|
295
|
+
* least one is registered, the root is enabled, and `preventDocumentDrop`
|
|
296
|
+
* is not false, the shared document drop guard is installed.
|
|
297
|
+
*/
|
|
298
|
+
registerDropzone: () => () => void;
|
|
299
|
+
/** Registers a rendered item for focus after removal; returns cleanup. */
|
|
300
|
+
registerItem: (item: GhostFileUploadItemRegistration) => () => void;
|
|
301
|
+
pickerProps: ComputedRef<GhostFileUploadPickerProps>;
|
|
302
|
+
mirrorProps: ComputedRef<GhostFileUploadMirrorProps>;
|
|
303
|
+
dropzoneProps: ComputedRef<GhostFileUploadDropzoneProps>;
|
|
304
|
+
triggerProps: ComputedRef<GhostFileUploadTriggerBindings>;
|
|
305
|
+
liveRegionProps: ComputedRef<GhostFileUploadLiveRegionProps>;
|
|
306
|
+
}
|
|
307
|
+
/** Internal context shared from the root to its parts. */
|
|
308
|
+
export interface GhostFileUploadContext {
|
|
309
|
+
upload: UseGhostFileUploadReturn;
|
|
310
|
+
/** Trigger id from the root `id` prop or generated. */
|
|
311
|
+
triggerId: ComputedRef<string>;
|
|
312
|
+
/** `aria-describedby` routed from the root attributes. */
|
|
313
|
+
describedBy: ComputedRef<string | undefined>;
|
|
314
|
+
/** Field label id when inside `GhostField`, for the composed trigger name. */
|
|
315
|
+
fieldLabelId: ComputedRef<string | undefined>;
|
|
316
|
+
messages: ComputedRef<Partial<GhostFileUploadMessages> | undefined>;
|
|
317
|
+
setTriggerElement: (element: HTMLElement | null) => void;
|
|
318
|
+
}
|
|
319
|
+
/** Internal context from an item to its remove button. */
|
|
320
|
+
export interface GhostFileUploadItemContext {
|
|
321
|
+
file: ComputedRef<File>;
|
|
322
|
+
setRemoveButton: (element: HTMLElement | null) => void;
|
|
323
|
+
}
|
|
324
|
+
export declare const ghostFileUploadContextKey: InjectionKey<GhostFileUploadContext>;
|
|
325
|
+
export declare const ghostFileUploadItemContextKey: InjectionKey<GhostFileUploadItemContext>;
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import type { ComponentPublicInstance, ComputedRef, InjectionKey, MaybeRefOrGetter, Ref } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* Standard Schema v1 structural interface (`~standard`), compatible with Zod,
|
|
4
|
+
* Valibot, ArkType, Yup, and plain inline validators without a runtime
|
|
5
|
+
* dependency.
|
|
6
|
+
*/
|
|
7
|
+
export interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
8
|
+
readonly '~standard': StandardSchemaV1.Props<Input, Output>;
|
|
9
|
+
}
|
|
10
|
+
export declare namespace StandardSchemaV1 {
|
|
11
|
+
interface Props<Input = unknown, Output = Input> {
|
|
12
|
+
readonly version: 1;
|
|
13
|
+
readonly vendor: string;
|
|
14
|
+
readonly validate: (value: unknown, options?: Options) => Result<Output> | Promise<Result<Output>>;
|
|
15
|
+
readonly types?: Types<Input, Output> | undefined;
|
|
16
|
+
}
|
|
17
|
+
interface Options {
|
|
18
|
+
readonly libraryOptions?: Record<string, unknown> | undefined;
|
|
19
|
+
}
|
|
20
|
+
type Result<Output> = SuccessResult<Output> | FailureResult;
|
|
21
|
+
interface SuccessResult<Output> {
|
|
22
|
+
readonly value: Output;
|
|
23
|
+
readonly issues?: undefined;
|
|
24
|
+
}
|
|
25
|
+
interface FailureResult {
|
|
26
|
+
readonly issues: readonly Issue[];
|
|
27
|
+
}
|
|
28
|
+
interface Issue {
|
|
29
|
+
readonly message: string;
|
|
30
|
+
readonly path?: readonly (PropertyKey | PathSegment)[] | undefined;
|
|
31
|
+
}
|
|
32
|
+
interface PathSegment {
|
|
33
|
+
readonly key: PropertyKey;
|
|
34
|
+
}
|
|
35
|
+
interface Types<Input = unknown, Output = Input> {
|
|
36
|
+
readonly input: Input;
|
|
37
|
+
readonly output: Output;
|
|
38
|
+
}
|
|
39
|
+
type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['input'];
|
|
40
|
+
type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['output'];
|
|
41
|
+
}
|
|
42
|
+
/** Validation timing trigger for {@link GhostForm} and {@link useGhostForm}. */
|
|
43
|
+
export type GhostFormValidateTrigger = 'submit' | 'blur' | 'change';
|
|
44
|
+
/** Root `data-state` values exposed by {@link GhostForm}. */
|
|
45
|
+
export type GhostFormDataState = 'submitting' | 'validating' | 'invalid';
|
|
46
|
+
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
47
|
+
type IsUnknown<T> = IsAny<T> extends true ? false : unknown extends T ? [keyof T] extends [never] ? true : false : false;
|
|
48
|
+
type GhostFormTerminalValue = string | number | boolean | bigint | symbol | null | undefined | Date | URL | RegExp | File | Blob | Map<unknown, unknown> | Set<unknown> | ((...args: never[]) => unknown);
|
|
49
|
+
type GhostFormFieldPathDepth<T, Depth extends readonly unknown[]> = Depth['length'] extends 4 ? never : T extends GhostFormTerminalValue ? never : T extends readonly (infer E)[] ? `${number}` | (E extends GhostFormTerminalValue ? never : `${number}.${GhostFormFieldPathDepth<E, [...Depth, unknown]>}`) : string extends keyof T ? string : {
|
|
50
|
+
[K in keyof T & string]: NonNullable<T[K]> extends GhostFormTerminalValue ? K : NonNullable<T[K]> extends readonly (infer E)[] ? K | `${K}.${number}` | (E extends GhostFormTerminalValue ? never : `${K}.${number}.${GhostFormFieldPathDepth<E, [...Depth, unknown]>}`) : string extends keyof NonNullable<T[K]> ? K | `${K}.${string}` : K | `${K}.${GhostFormFieldPathDepth<NonNullable<T[K]>, [...Depth, unknown]>}`;
|
|
51
|
+
}[keyof T & string];
|
|
52
|
+
/**
|
|
53
|
+
* Bounded-depth (4 levels) canonical dot-path helper for nested objects and
|
|
54
|
+
* arrays in `TValues`. Widens to `string` for `unknown` or index-signature
|
|
55
|
+
* records.
|
|
56
|
+
*/
|
|
57
|
+
export type GhostFormFieldPath<TValues> = IsAny<TValues> extends true ? string : IsUnknown<TValues> extends true ? string : string extends keyof TValues ? string : [GhostFormFieldPathDepth<NonNullable<TValues>, []>] extends [never] ? string : GhostFormFieldPathDepth<NonNullable<TValues>, []>;
|
|
58
|
+
/** Payload delivered to `@submit` and `onSubmit` when validation succeeds. */
|
|
59
|
+
export interface GhostFormSubmitPayload<TOutput, TValues> {
|
|
60
|
+
/** Validated and transformed schema output (`StandardSchemaV1.InferOutput<TSchema>`). */
|
|
61
|
+
readonly output: TOutput;
|
|
62
|
+
/** Snapshot reference to the consumer `values` passed into validation. */
|
|
63
|
+
readonly values: TValues;
|
|
64
|
+
/** Originating native `SubmitEvent` when triggered from `<form>`, or `null` for `submit()`. */
|
|
65
|
+
readonly event: SubmitEvent | null;
|
|
66
|
+
/**
|
|
67
|
+
* Registers an asynchronous post-validation mutation on `<GhostForm>`
|
|
68
|
+
* `@submit` listeners so `isSubmitting`, `isPending`, `aria-busy`, and
|
|
69
|
+
* duplicate-submit protection remain active until `promise` settles.
|
|
70
|
+
*/
|
|
71
|
+
readonly waitUntil: (promise: PromiseLike<unknown>) => void;
|
|
72
|
+
/** Imperative server-error helper scoped to the active form submission. */
|
|
73
|
+
readonly setFieldErrors: (path: GhostFormFieldPath<TValues> | (string & {}), messages: readonly string[]) => void;
|
|
74
|
+
/** Imperative form-level error helper scoped to the active form submission. */
|
|
75
|
+
readonly setFormErrors: (messages: readonly string[]) => void;
|
|
76
|
+
/** Resets errors, tracking state, and pending epochs. */
|
|
77
|
+
readonly reset: () => void;
|
|
78
|
+
}
|
|
79
|
+
/** Payload delivered to `@invalid` and `onInvalid` when submit validation fails. */
|
|
80
|
+
export interface GhostFormInvalidPayload<TValues> {
|
|
81
|
+
/** All issues returned by the schema for this validation pass, in vendor order. */
|
|
82
|
+
readonly issues: readonly StandardSchemaV1.Issue[];
|
|
83
|
+
/** Visible field-scoped error messages keyed by canonical dot-path. */
|
|
84
|
+
readonly fieldErrors: Readonly<Record<string, readonly string[]>>;
|
|
85
|
+
/** Visible form-level error messages (empty/missing or symbol path). */
|
|
86
|
+
readonly formErrors: readonly string[];
|
|
87
|
+
readonly values: TValues;
|
|
88
|
+
readonly event: SubmitEvent | null;
|
|
89
|
+
}
|
|
90
|
+
/** Result returned by `submit()`. */
|
|
91
|
+
export type GhostFormSubmitResult<TOutput> = {
|
|
92
|
+
readonly status: 'submitted';
|
|
93
|
+
readonly output: TOutput;
|
|
94
|
+
} | {
|
|
95
|
+
readonly status: 'invalid';
|
|
96
|
+
readonly issues: readonly StandardSchemaV1.Issue[];
|
|
97
|
+
} | {
|
|
98
|
+
readonly status: 'aborted';
|
|
99
|
+
} | {
|
|
100
|
+
readonly status: 'ignored';
|
|
101
|
+
};
|
|
102
|
+
/** Result returned by `validate()`. */
|
|
103
|
+
export interface GhostFormValidateResult<TOutput> {
|
|
104
|
+
readonly valid: boolean;
|
|
105
|
+
readonly output?: TOutput;
|
|
106
|
+
readonly issues: readonly StandardSchemaV1.Issue[];
|
|
107
|
+
}
|
|
108
|
+
/** Escape-hatch bindings returned by `fieldProps(path)`. */
|
|
109
|
+
export interface GhostFormFieldBindings {
|
|
110
|
+
readonly name: string;
|
|
111
|
+
readonly invalid: boolean;
|
|
112
|
+
}
|
|
113
|
+
/** Root `<form>` attributes returned by `useGhostForm().formProps`. */
|
|
114
|
+
export interface GhostFormRootAttributes {
|
|
115
|
+
ref: (el: Element | ComponentPublicInstance | null) => void;
|
|
116
|
+
class: 'ghost-form';
|
|
117
|
+
novalidate: true | undefined;
|
|
118
|
+
'aria-busy'?: 'true' | undefined;
|
|
119
|
+
'data-part': 'root';
|
|
120
|
+
'data-ghost-form': '';
|
|
121
|
+
'data-state'?: GhostFormDataState | undefined;
|
|
122
|
+
onSubmit: (event: SubmitEvent) => void;
|
|
123
|
+
onReset: (event: Event) => void;
|
|
124
|
+
}
|
|
125
|
+
/** Props for {@link GhostForm}. */
|
|
126
|
+
export interface GhostFormProps<TSchema extends StandardSchemaV1 = StandardSchemaV1, TValues = StandardSchemaV1.InferInput<TSchema>> {
|
|
127
|
+
/** Standard Schema v1 validator (`schema['~standard'].version === 1`). */
|
|
128
|
+
schema: TSchema;
|
|
129
|
+
/** Consumer-owned input state passed to `schema['~standard'].validate`. */
|
|
130
|
+
values: NoInfer<TValues>;
|
|
131
|
+
/**
|
|
132
|
+
* Trigger that first reveals issues on an untouched field before the first submit.
|
|
133
|
+
* @default 'submit'
|
|
134
|
+
*/
|
|
135
|
+
validateOn?: GhostFormValidateTrigger;
|
|
136
|
+
/**
|
|
137
|
+
* Trigger that re-validates a field once it has visible issues or after submit.
|
|
138
|
+
* @default 'change'
|
|
139
|
+
*/
|
|
140
|
+
revalidateOn?: GhostFormValidateTrigger;
|
|
141
|
+
/**
|
|
142
|
+
* Sets HTML `novalidate` on `<form>` so Standard Schema v1 owns submit validation.
|
|
143
|
+
* @default true
|
|
144
|
+
*/
|
|
145
|
+
novalidate?: boolean;
|
|
146
|
+
/**
|
|
147
|
+
* Moves focus after DOM flush to the first focusable invalid control when submit fails.
|
|
148
|
+
* @default true
|
|
149
|
+
*/
|
|
150
|
+
focusInvalidOnSubmit?: boolean;
|
|
151
|
+
/** Optional seed issues partitioned synchronously at setup without calling `validate()`. */
|
|
152
|
+
initialIssues?: readonly StandardSchemaV1.Issue[] | undefined;
|
|
153
|
+
/** Optional vendor options forwarded as the second argument to `validate()`. */
|
|
154
|
+
schemaOptions?: StandardSchemaV1.Options | undefined;
|
|
155
|
+
}
|
|
156
|
+
/** Events emitted by {@link GhostForm}. */
|
|
157
|
+
export interface GhostFormEmits<TSchema extends StandardSchemaV1 = StandardSchemaV1, TValues = StandardSchemaV1.InferInput<TSchema>> {
|
|
158
|
+
/** Emitted when schema validation succeeds for an accepted submit attempt. */
|
|
159
|
+
submit: [
|
|
160
|
+
payload: GhostFormSubmitPayload<StandardSchemaV1.InferOutput<TSchema>, TValues>
|
|
161
|
+
];
|
|
162
|
+
/** Emitted when schema validation returns issues for an accepted submit attempt. */
|
|
163
|
+
invalid: [payload: GhostFormInvalidPayload<TValues>];
|
|
164
|
+
/** Emitted when a non-cancelled DOM reset or imperative `reset()` completes. */
|
|
165
|
+
reset: [event: Event | null];
|
|
166
|
+
}
|
|
167
|
+
/** Scoped slot props exposed by {@link GhostForm}'s default slot. */
|
|
168
|
+
export interface GhostFormSlotProps<TSchema extends StandardSchemaV1 = StandardSchemaV1, TValues = StandardSchemaV1.InferInput<TSchema>> {
|
|
169
|
+
readonly fieldErrors: Readonly<Record<string, readonly string[]>>;
|
|
170
|
+
readonly formErrors: readonly string[];
|
|
171
|
+
readonly issues: readonly StandardSchemaV1.Issue[];
|
|
172
|
+
readonly isValid: boolean;
|
|
173
|
+
readonly isInvalid: boolean;
|
|
174
|
+
readonly isValidating: boolean;
|
|
175
|
+
readonly isSubmitting: boolean;
|
|
176
|
+
readonly isPending: boolean;
|
|
177
|
+
readonly isDirty: boolean;
|
|
178
|
+
readonly hasSubmitted: boolean;
|
|
179
|
+
readonly submitCount: number;
|
|
180
|
+
readonly getFieldError: (path: GhostFormFieldPath<TValues>) => string | undefined;
|
|
181
|
+
readonly getFieldErrors: (path: GhostFormFieldPath<TValues>) => readonly string[];
|
|
182
|
+
readonly getFieldIssues: (path: GhostFormFieldPath<TValues>) => readonly StandardSchemaV1.Issue[];
|
|
183
|
+
readonly isFieldInvalid: (path: GhostFormFieldPath<TValues>) => boolean;
|
|
184
|
+
readonly isFieldTouched: (path: GhostFormFieldPath<TValues>) => boolean;
|
|
185
|
+
readonly isFieldDirty: (path: GhostFormFieldPath<TValues>) => boolean;
|
|
186
|
+
readonly fieldProps: (path: GhostFormFieldPath<TValues>) => GhostFormFieldBindings;
|
|
187
|
+
readonly validate: () => Promise<GhostFormValidateResult<StandardSchemaV1.InferOutput<TSchema>>>;
|
|
188
|
+
readonly validateField: (path: GhostFormFieldPath<TValues>) => Promise<readonly StandardSchemaV1.Issue[]>;
|
|
189
|
+
readonly submit: (event?: SubmitEvent | null) => Promise<GhostFormSubmitResult<StandardSchemaV1.InferOutput<TSchema>>>;
|
|
190
|
+
readonly reset: () => void;
|
|
191
|
+
readonly clearErrors: (path?: GhostFormFieldPath<TValues>) => void;
|
|
192
|
+
readonly setFieldErrors: (path: GhostFormFieldPath<TValues> | (string & {}), messages: readonly string[]) => void;
|
|
193
|
+
readonly setFormErrors: (messages: readonly string[]) => void;
|
|
194
|
+
readonly touchField: (path: GhostFormFieldPath<TValues>) => void;
|
|
195
|
+
readonly blurField: (path: GhostFormFieldPath<TValues>) => void;
|
|
196
|
+
}
|
|
197
|
+
/** Methods and DOM ref exposed by {@link GhostForm}. */
|
|
198
|
+
export interface GhostFormExposed<TSchema extends StandardSchemaV1 = StandardSchemaV1, TValues = StandardSchemaV1.InferInput<TSchema>> {
|
|
199
|
+
readonly element: HTMLFormElement | null;
|
|
200
|
+
readonly submit: (event?: SubmitEvent | null) => Promise<GhostFormSubmitResult<StandardSchemaV1.InferOutput<TSchema>>>;
|
|
201
|
+
readonly validate: () => Promise<GhostFormValidateResult<StandardSchemaV1.InferOutput<TSchema>>>;
|
|
202
|
+
readonly validateField: (path: GhostFormFieldPath<TValues>) => Promise<readonly StandardSchemaV1.Issue[]>;
|
|
203
|
+
readonly reset: () => void;
|
|
204
|
+
readonly clearErrors: (path?: GhostFormFieldPath<TValues>) => void;
|
|
205
|
+
readonly setFieldErrors: (path: GhostFormFieldPath<TValues> | (string & {}), messages: readonly string[]) => void;
|
|
206
|
+
readonly setFormErrors: (messages: readonly string[]) => void;
|
|
207
|
+
}
|
|
208
|
+
/** Options for {@link useGhostForm}. */
|
|
209
|
+
export interface UseGhostFormOptions<TSchema extends StandardSchemaV1 = StandardSchemaV1, TValues = StandardSchemaV1.InferInput<TSchema>> {
|
|
210
|
+
schema: MaybeRefOrGetter<TSchema>;
|
|
211
|
+
values: MaybeRefOrGetter<NoInfer<TValues>>;
|
|
212
|
+
validateOn?: MaybeRefOrGetter<GhostFormValidateTrigger | undefined>;
|
|
213
|
+
revalidateOn?: MaybeRefOrGetter<GhostFormValidateTrigger | undefined>;
|
|
214
|
+
novalidate?: MaybeRefOrGetter<boolean | undefined>;
|
|
215
|
+
focusInvalidOnSubmit?: MaybeRefOrGetter<boolean | undefined>;
|
|
216
|
+
initialIssues?: readonly StandardSchemaV1.Issue[] | undefined;
|
|
217
|
+
schemaOptions?: MaybeRefOrGetter<StandardSchemaV1.Options | undefined>;
|
|
218
|
+
/**
|
|
219
|
+
* Provides `ghostFormContextKey` to descendant `GhostField` components when
|
|
220
|
+
* called inside `setup()`. Disable when hosting multiple `useGhostForm`
|
|
221
|
+
* instances in a single component setup scope without `<GhostForm>` wrappers.
|
|
222
|
+
* @default true
|
|
223
|
+
*/
|
|
224
|
+
provideContext?: boolean;
|
|
225
|
+
onSubmit?: (payload: GhostFormSubmitPayload<StandardSchemaV1.InferOutput<TSchema>, TValues>) => unknown;
|
|
226
|
+
onInvalid?: (payload: GhostFormInvalidPayload<TValues>) => void;
|
|
227
|
+
onReset?: (event: Event | null) => void;
|
|
228
|
+
}
|
|
229
|
+
/** Reactive state, actions, and root attributes returned by {@link useGhostForm}. */
|
|
230
|
+
export interface UseGhostFormReturn<TSchema extends StandardSchemaV1 = StandardSchemaV1, TValues = StandardSchemaV1.InferInput<TSchema>> {
|
|
231
|
+
readonly element: Ref<HTMLFormElement | null>;
|
|
232
|
+
readonly formRef: (el: Element | ComponentPublicInstance | null) => void;
|
|
233
|
+
readonly formProps: ComputedRef<GhostFormRootAttributes>;
|
|
234
|
+
readonly fieldErrors: ComputedRef<Readonly<Record<string, readonly string[]>>>;
|
|
235
|
+
readonly formErrors: ComputedRef<readonly string[]>;
|
|
236
|
+
readonly issues: ComputedRef<readonly StandardSchemaV1.Issue[]>;
|
|
237
|
+
readonly isValid: ComputedRef<boolean>;
|
|
238
|
+
readonly isInvalid: ComputedRef<boolean>;
|
|
239
|
+
readonly isValidating: ComputedRef<boolean>;
|
|
240
|
+
readonly isSubmitting: ComputedRef<boolean>;
|
|
241
|
+
readonly isPending: ComputedRef<boolean>;
|
|
242
|
+
readonly isDirty: ComputedRef<boolean>;
|
|
243
|
+
readonly hasSubmitted: ComputedRef<boolean>;
|
|
244
|
+
readonly submitCount: ComputedRef<number>;
|
|
245
|
+
readonly getFieldError: (path: GhostFormFieldPath<TValues>) => string | undefined;
|
|
246
|
+
readonly getFieldErrors: (path: GhostFormFieldPath<TValues>) => readonly string[];
|
|
247
|
+
readonly getFieldIssues: (path: GhostFormFieldPath<TValues>) => readonly StandardSchemaV1.Issue[];
|
|
248
|
+
readonly isFieldInvalid: (path: GhostFormFieldPath<TValues>) => boolean;
|
|
249
|
+
readonly isFieldTouched: (path: GhostFormFieldPath<TValues>) => boolean;
|
|
250
|
+
readonly isFieldDirty: (path: GhostFormFieldPath<TValues>) => boolean;
|
|
251
|
+
readonly fieldProps: (path: GhostFormFieldPath<TValues>) => GhostFormFieldBindings;
|
|
252
|
+
readonly validate: () => Promise<GhostFormValidateResult<StandardSchemaV1.InferOutput<TSchema>>>;
|
|
253
|
+
readonly validateField: (path: GhostFormFieldPath<TValues>) => Promise<readonly StandardSchemaV1.Issue[]>;
|
|
254
|
+
readonly submit: (event?: SubmitEvent | null) => Promise<GhostFormSubmitResult<StandardSchemaV1.InferOutput<TSchema>>>;
|
|
255
|
+
readonly reset: () => void;
|
|
256
|
+
readonly clearErrors: (path?: GhostFormFieldPath<TValues>) => void;
|
|
257
|
+
readonly setFieldErrors: (path: GhostFormFieldPath<TValues> | (string & {}), messages: readonly string[]) => void;
|
|
258
|
+
readonly setFormErrors: (messages: readonly string[]) => void;
|
|
259
|
+
readonly touchField: (path: GhostFormFieldPath<TValues>) => void;
|
|
260
|
+
readonly blurField: (path: GhostFormFieldPath<TValues>) => void;
|
|
261
|
+
}
|
|
262
|
+
/** Form context provided to descendant {@link GhostField} instances. */
|
|
263
|
+
export interface GhostFormContext {
|
|
264
|
+
readonly isFieldInvalid: (path: string) => boolean;
|
|
265
|
+
readonly getFieldError: (path: string) => string | undefined;
|
|
266
|
+
readonly getFieldErrors: (path: string) => readonly string[];
|
|
267
|
+
readonly isFieldTouched: (path: string) => boolean;
|
|
268
|
+
readonly isFieldDirty: (path: string) => boolean;
|
|
269
|
+
readonly registerField: (path: string) => () => void;
|
|
270
|
+
readonly blurField: (path: string) => void;
|
|
271
|
+
}
|
|
272
|
+
export declare const ghostFormContextKey: InjectionKey<GhostFormContext>;
|
|
273
|
+
export {};
|