@mkbabb/glass-ui 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/README.md +172 -0
- package/dist/glass-ui.css +1 -0
- package/dist/glass-ui.js +10019 -0
- package/dist/index.d.ts +6619 -0
- package/package.json +65 -0
- package/src/components/custom/aurora/Aurora.vue +34 -0
- package/src/components/custom/aurora/composables/color.ts +122 -0
- package/src/components/custom/aurora/composables/useAurora.ts +355 -0
- package/src/components/custom/aurora/index.ts +8 -0
- package/src/components/custom/confirm-dialog/ConfirmDialog.vue +88 -0
- package/src/components/custom/confirm-dialog/index.ts +1 -0
- package/src/components/custom/controls/DarkModeToggle.vue +96 -0
- package/src/components/custom/controls/index.ts +1 -0
- package/src/components/custom/dock/DockLayerGroup.vue +21 -0
- package/src/components/custom/dock/DockPopover.vue +263 -0
- package/src/components/custom/dock/GlassDock.vue +276 -0
- package/src/components/custom/dock/composables/index.ts +16 -0
- package/src/components/custom/dock/composables/isTeleportedTarget.ts +19 -0
- package/src/components/custom/dock/composables/useDockActionBar.ts +33 -0
- package/src/components/custom/dock/composables/useDockState.ts +301 -0
- package/src/components/custom/dock/composables/useDockTransition.ts +146 -0
- package/src/components/custom/dock/composables/useLayerTransition.ts +135 -0
- package/src/components/custom/dock/composables/usePopupMutex.ts +83 -0
- package/src/components/custom/dock/index.ts +9 -0
- package/src/components/custom/expandable-container/ExpandableContainer.vue +64 -0
- package/src/components/custom/expandable-container/index.ts +1 -0
- package/src/components/custom/glass-panel/GlassPanel.vue +98 -0
- package/src/components/custom/glass-panel/index.ts +2 -0
- package/src/components/custom/icon-tooltip/IconTooltip.vue +20 -0
- package/src/components/custom/icon-tooltip/index.ts +1 -0
- package/src/components/custom/index.ts +15 -0
- package/src/components/custom/infinite-scroll/InfiniteScroll.vue +55 -0
- package/src/components/custom/infinite-scroll/composables/index.ts +2 -0
- package/src/components/custom/infinite-scroll/composables/types.ts +23 -0
- package/src/components/custom/infinite-scroll/composables/useInfiniteScroll.ts +73 -0
- package/src/components/custom/infinite-scroll/index.ts +1 -0
- package/src/components/custom/labeled-field/LabeledInput.vue +29 -0
- package/src/components/custom/labeled-field/LabeledSelect.vue +59 -0
- package/src/components/custom/labeled-field/LabeledSlider.vue +32 -0
- package/src/components/custom/labeled-field/LabeledSwitch.vue +27 -0
- package/src/components/custom/labeled-field/index.ts +4 -0
- package/src/components/custom/metaballs/MetaballCanvas.vue +23 -0
- package/src/components/custom/metaballs/index.ts +4 -0
- package/src/components/custom/metaballs/shaders.ts +63 -0
- package/src/components/custom/metaballs/types.ts +29 -0
- package/src/components/custom/metaballs/useMetaballs.ts +252 -0
- package/src/components/custom/search/FuzzySearch.vue +589 -0
- package/src/components/custom/search/SearchBar.vue +44 -0
- package/src/components/custom/search/composables/fuzzySearchIndex.ts +224 -0
- package/src/components/custom/search/composables/index.ts +5 -0
- package/src/components/custom/search/composables/types.ts +34 -0
- package/src/components/custom/search/composables/useFuzzySearch.ts +115 -0
- package/src/components/custom/search/index.ts +7 -0
- package/src/components/custom/sidebar/ProgressiveSidebar.vue +256 -0
- package/src/components/custom/sidebar/composables/index.ts +6 -0
- package/src/components/custom/sidebar/composables/useScrollTracker.ts +242 -0
- package/src/components/custom/sidebar/composables/useSidebarFollow.ts +247 -0
- package/src/components/custom/sidebar/composables/useSidebarState.ts +72 -0
- package/src/components/custom/sidebar/composables/useTreeIndex.ts +152 -0
- package/src/components/custom/sidebar/index.ts +15 -0
- package/src/components/custom/sidebar/types.ts +50 -0
- package/src/components/custom/tabs/BouncyTabs.vue +39 -0
- package/src/components/custom/tabs/BouncyToggle.vue +352 -0
- package/src/components/custom/tabs/UnderlineTabs.vue +115 -0
- package/src/components/custom/tabs/index.ts +5 -0
- package/src/components/custom/timeline/GlassTimeline.vue +174 -0
- package/src/components/custom/timeline/index.ts +1 -0
- package/src/components/custom/typewriter/TypewriterText.vue +239 -0
- package/src/components/custom/typewriter/composables/index.ts +1 -0
- package/src/components/custom/typewriter/composables/useTypewriter.ts +413 -0
- package/src/components/custom/typewriter/index.ts +7 -0
- package/src/components/custom/typewriter/types.ts +159 -0
- package/src/components/custom/typewriter/utils/keyboard.ts +213 -0
- package/src/components/custom/typewriter/utils/pausePatterns.ts +55 -0
- package/src/components/custom/typewriter/utils/timing.ts +104 -0
- package/src/components/custom/typewriter/utils/typoStateMachine.ts +197 -0
- package/src/components/index.ts +2 -0
- package/src/components/ui/accordion/Accordion.vue +19 -0
- package/src/components/ui/accordion/AccordionContent.vue +24 -0
- package/src/components/ui/accordion/AccordionItem.vue +24 -0
- package/src/components/ui/accordion/AccordionTrigger.vue +39 -0
- package/src/components/ui/accordion/index.ts +4 -0
- package/src/components/ui/alert/Alert.vue +20 -0
- package/src/components/ui/alert/AlertDescription.vue +17 -0
- package/src/components/ui/alert/AlertTitle.vue +17 -0
- package/src/components/ui/alert/index.ts +23 -0
- package/src/components/ui/avatar/Avatar.vue +21 -0
- package/src/components/ui/avatar/AvatarFallback.vue +11 -0
- package/src/components/ui/avatar/AvatarImage.vue +9 -0
- package/src/components/ui/avatar/index.ts +24 -0
- package/src/components/ui/badge/Badge.vue +16 -0
- package/src/components/ui/badge/index.ts +25 -0
- package/src/components/ui/button/Button.vue +26 -0
- package/src/components/ui/button/index.ts +43 -0
- package/src/components/ui/card/Card.vue +28 -0
- package/src/components/ui/card/CardContent.vue +14 -0
- package/src/components/ui/card/CardDescription.vue +14 -0
- package/src/components/ui/card/CardFooter.vue +14 -0
- package/src/components/ui/card/CardHeader.vue +14 -0
- package/src/components/ui/card/CardTitle.vue +21 -0
- package/src/components/ui/card/index.ts +6 -0
- package/src/components/ui/carousel/Carousel.vue +53 -0
- package/src/components/ui/carousel/CarouselContent.vue +35 -0
- package/src/components/ui/carousel/CarouselItem.vue +24 -0
- package/src/components/ui/carousel/CarouselNext.vue +40 -0
- package/src/components/ui/carousel/CarouselPrevious.vue +40 -0
- package/src/components/ui/carousel/index.ts +10 -0
- package/src/components/ui/carousel/interface.ts +26 -0
- package/src/components/ui/carousel/useCarousel.ts +56 -0
- package/src/components/ui/checkbox/Checkbox.vue +33 -0
- package/src/components/ui/checkbox/index.ts +1 -0
- package/src/components/ui/collapsible/Collapsible.vue +15 -0
- package/src/components/ui/collapsible/CollapsibleContent.vue +11 -0
- package/src/components/ui/collapsible/CollapsibleTrigger.vue +11 -0
- package/src/components/ui/collapsible/index.ts +3 -0
- package/src/components/ui/combobox/Combobox.vue +17 -0
- package/src/components/ui/combobox/ComboboxAnchor.vue +23 -0
- package/src/components/ui/combobox/ComboboxEmpty.vue +21 -0
- package/src/components/ui/combobox/ComboboxGroup.vue +27 -0
- package/src/components/ui/combobox/ComboboxInput.vue +41 -0
- package/src/components/ui/combobox/ComboboxItem.vue +24 -0
- package/src/components/ui/combobox/ComboboxItemIndicator.vue +23 -0
- package/src/components/ui/combobox/ComboboxList.vue +29 -0
- package/src/components/ui/combobox/ComboboxSeparator.vue +21 -0
- package/src/components/ui/combobox/ComboboxViewport.vue +23 -0
- package/src/components/ui/combobox/index.ts +12 -0
- package/src/components/ui/command/Command.vue +30 -0
- package/src/components/ui/command/CommandDialog.vue +21 -0
- package/src/components/ui/command/CommandEmpty.vue +20 -0
- package/src/components/ui/command/CommandGroup.vue +29 -0
- package/src/components/ui/command/CommandInput.vue +33 -0
- package/src/components/ui/command/CommandItem.vue +26 -0
- package/src/components/ui/command/CommandList.vue +27 -0
- package/src/components/ui/command/CommandSeparator.vue +23 -0
- package/src/components/ui/command/CommandShortcut.vue +14 -0
- package/src/components/ui/command/index.ts +9 -0
- package/src/components/ui/context-menu/ContextMenu.vue +15 -0
- package/src/components/ui/context-menu/ContextMenuCheckboxItem.vue +40 -0
- package/src/components/ui/context-menu/ContextMenuContent.vue +36 -0
- package/src/components/ui/context-menu/ContextMenuGroup.vue +11 -0
- package/src/components/ui/context-menu/ContextMenuItem.vue +34 -0
- package/src/components/ui/context-menu/ContextMenuLabel.vue +25 -0
- package/src/components/ui/context-menu/ContextMenuPortal.vue +11 -0
- package/src/components/ui/context-menu/ContextMenuRadioGroup.vue +19 -0
- package/src/components/ui/context-menu/ContextMenuRadioItem.vue +40 -0
- package/src/components/ui/context-menu/ContextMenuSeparator.vue +20 -0
- package/src/components/ui/context-menu/ContextMenuShortcut.vue +14 -0
- package/src/components/ui/context-menu/ContextMenuSub.vue +19 -0
- package/src/components/ui/context-menu/ContextMenuSubContent.vue +35 -0
- package/src/components/ui/context-menu/ContextMenuSubTrigger.vue +34 -0
- package/src/components/ui/context-menu/ContextMenuTrigger.vue +13 -0
- package/src/components/ui/context-menu/index.ts +14 -0
- package/src/components/ui/data-table/DataTable.vue +167 -0
- package/src/components/ui/data-table/DataTablePagination.vue +112 -0
- package/src/components/ui/data-table/index.ts +3 -0
- package/src/components/ui/data-table/types.ts +48 -0
- package/src/components/ui/dialog/Dialog.vue +14 -0
- package/src/components/ui/dialog/DialogClose.vue +11 -0
- package/src/components/ui/dialog/DialogContent.vue +61 -0
- package/src/components/ui/dialog/DialogDescription.vue +24 -0
- package/src/components/ui/dialog/DialogFooter.vue +19 -0
- package/src/components/ui/dialog/DialogHeader.vue +16 -0
- package/src/components/ui/dialog/DialogScrollContent.vue +65 -0
- package/src/components/ui/dialog/DialogTitle.vue +29 -0
- package/src/components/ui/dialog/DialogTrigger.vue +11 -0
- package/src/components/ui/dialog/index.ts +9 -0
- package/src/components/ui/drawer/Drawer.vue +19 -0
- package/src/components/ui/drawer/DrawerContent.vue +28 -0
- package/src/components/ui/drawer/DrawerDescription.vue +20 -0
- package/src/components/ui/drawer/DrawerFooter.vue +14 -0
- package/src/components/ui/drawer/DrawerHeader.vue +14 -0
- package/src/components/ui/drawer/DrawerOverlay.vue +18 -0
- package/src/components/ui/drawer/DrawerTitle.vue +20 -0
- package/src/components/ui/drawer/index.ts +8 -0
- package/src/components/ui/dropdown-menu/DropdownMenu.vue +14 -0
- package/src/components/ui/dropdown-menu/DropdownMenuCheckboxItem.vue +40 -0
- package/src/components/ui/dropdown-menu/DropdownMenuContent.vue +44 -0
- package/src/components/ui/dropdown-menu/DropdownMenuGroup.vue +11 -0
- package/src/components/ui/dropdown-menu/DropdownMenuItem.vue +28 -0
- package/src/components/ui/dropdown-menu/DropdownMenuLabel.vue +24 -0
- package/src/components/ui/dropdown-menu/DropdownMenuRadioGroup.vue +19 -0
- package/src/components/ui/dropdown-menu/DropdownMenuRadioItem.vue +40 -0
- package/src/components/ui/dropdown-menu/DropdownMenuSeparator.vue +22 -0
- package/src/components/ui/dropdown-menu/DropdownMenuShortcut.vue +14 -0
- package/src/components/ui/dropdown-menu/DropdownMenuSub.vue +19 -0
- package/src/components/ui/dropdown-menu/DropdownMenuSubContent.vue +36 -0
- package/src/components/ui/dropdown-menu/DropdownMenuSubTrigger.vue +33 -0
- package/src/components/ui/dropdown-menu/DropdownMenuTrigger.vue +13 -0
- package/src/components/ui/dropdown-menu/index.ts +16 -0
- package/src/components/ui/hover-card/HoverCard.vue +14 -0
- package/src/components/ui/hover-card/HoverCardContent.vue +41 -0
- package/src/components/ui/hover-card/HoverCardTrigger.vue +11 -0
- package/src/components/ui/hover-card/index.ts +3 -0
- package/src/components/ui/index.ts +41 -0
- package/src/components/ui/input/Input.vue +24 -0
- package/src/components/ui/input/index.ts +1 -0
- package/src/components/ui/label/Label.vue +27 -0
- package/src/components/ui/label/index.ts +1 -0
- package/src/components/ui/multi-select/MultiSelect.vue +141 -0
- package/src/components/ui/multi-select/index.ts +7 -0
- package/src/components/ui/notification/Notification.vue +85 -0
- package/src/components/ui/notification/index.ts +1 -0
- package/src/components/ui/number-field/NumberField.vue +23 -0
- package/src/components/ui/number-field/NumberFieldContent.vue +14 -0
- package/src/components/ui/number-field/NumberFieldDecrement.vue +25 -0
- package/src/components/ui/number-field/NumberFieldIncrement.vue +25 -0
- package/src/components/ui/number-field/NumberFieldInput.vue +8 -0
- package/src/components/ui/number-field/index.ts +5 -0
- package/src/components/ui/popover/Popover.vue +15 -0
- package/src/components/ui/popover/PopoverContent.vue +61 -0
- package/src/components/ui/popover/PopoverTrigger.vue +11 -0
- package/src/components/ui/popover/index.ts +3 -0
- package/src/components/ui/progress/Progress.vue +39 -0
- package/src/components/ui/progress/index.ts +1 -0
- package/src/components/ui/radio-group/RadioGroup.vue +25 -0
- package/src/components/ui/radio-group/RadioGroupItem.vue +39 -0
- package/src/components/ui/radio-group/index.ts +2 -0
- package/src/components/ui/scroll-area/ScrollArea.vue +29 -0
- package/src/components/ui/scroll-area/ScrollBar.vue +30 -0
- package/src/components/ui/scroll-area/index.ts +2 -0
- package/src/components/ui/scroll-pane/ScrollPane.vue +25 -0
- package/src/components/ui/scroll-pane/ScrollPaneHeader.vue +75 -0
- package/src/components/ui/scroll-pane/index.ts +2 -0
- package/src/components/ui/select/Select.vue +15 -0
- package/src/components/ui/select/SelectContent.vue +57 -0
- package/src/components/ui/select/SelectGroup.vue +19 -0
- package/src/components/ui/select/SelectItem.vue +47 -0
- package/src/components/ui/select/SelectItemText.vue +11 -0
- package/src/components/ui/select/SelectLabel.vue +13 -0
- package/src/components/ui/select/SelectScrollDownButton.vue +24 -0
- package/src/components/ui/select/SelectScrollUpButton.vue +24 -0
- package/src/components/ui/select/SelectSeparator.vue +17 -0
- package/src/components/ui/select/SelectTrigger.vue +45 -0
- package/src/components/ui/select/SelectValue.vue +11 -0
- package/src/components/ui/select/index.ts +11 -0
- package/src/components/ui/separator/Separator.vue +35 -0
- package/src/components/ui/separator/index.ts +1 -0
- package/src/components/ui/sheet/Sheet.vue +14 -0
- package/src/components/ui/sheet/SheetClose.vue +11 -0
- package/src/components/ui/sheet/SheetContent.vue +56 -0
- package/src/components/ui/sheet/SheetDescription.vue +22 -0
- package/src/components/ui/sheet/SheetFooter.vue +19 -0
- package/src/components/ui/sheet/SheetHeader.vue +16 -0
- package/src/components/ui/sheet/SheetTitle.vue +22 -0
- package/src/components/ui/sheet/SheetTrigger.vue +11 -0
- package/src/components/ui/sheet/index.ts +31 -0
- package/src/components/ui/skeleton/Skeleton.vue +14 -0
- package/src/components/ui/skeleton/index.ts +1 -0
- package/src/components/ui/slider/Slider.vue +66 -0
- package/src/components/ui/slider/index.ts +1 -0
- package/src/components/ui/switch/Switch.vue +37 -0
- package/src/components/ui/switch/index.ts +1 -0
- package/src/components/ui/table/Table.vue +16 -0
- package/src/components/ui/table/TableBody.vue +14 -0
- package/src/components/ui/table/TableCaption.vue +14 -0
- package/src/components/ui/table/TableCell.vue +14 -0
- package/src/components/ui/table/TableEmpty.vue +39 -0
- package/src/components/ui/table/TableFooter.vue +16 -0
- package/src/components/ui/table/TableHead.vue +21 -0
- package/src/components/ui/table/TableHeader.vue +14 -0
- package/src/components/ui/table/TableRow.vue +21 -0
- package/src/components/ui/table/index.ts +9 -0
- package/src/components/ui/tabs/Tabs.vue +15 -0
- package/src/components/ui/tabs/TabsContent.vue +22 -0
- package/src/components/ui/tabs/TabsIndicator.vue +22 -0
- package/src/components/ui/tabs/TabsList.vue +25 -0
- package/src/components/ui/tabs/TabsTrigger.vue +29 -0
- package/src/components/ui/tabs/index.ts +5 -0
- package/src/components/ui/tags-input/TagsInput.vue +22 -0
- package/src/components/ui/tags-input/TagsInputInput.vue +19 -0
- package/src/components/ui/tags-input/TagsInputItem.vue +22 -0
- package/src/components/ui/tags-input/TagsInputItemDelete.vue +24 -0
- package/src/components/ui/tags-input/TagsInputItemText.vue +19 -0
- package/src/components/ui/tags-input/index.ts +5 -0
- package/src/components/ui/textarea/Textarea.vue +24 -0
- package/src/components/ui/textarea/index.ts +1 -0
- package/src/components/ui/toast/Toast.vue +57 -0
- package/src/components/ui/toast/ToastAction.vue +30 -0
- package/src/components/ui/toast/ToastClose.vue +31 -0
- package/src/components/ui/toast/ToastDescription.vue +25 -0
- package/src/components/ui/toast/ToastTitle.vue +25 -0
- package/src/components/ui/toast/Toaster.vue +31 -0
- package/src/components/ui/toast/index.ts +8 -0
- package/src/components/ui/toast/use-toast.ts +136 -0
- package/src/components/ui/toggle/Toggle.vue +35 -0
- package/src/components/ui/toggle/index.ts +27 -0
- package/src/components/ui/toggle-group/ToggleGroup.vue +34 -0
- package/src/components/ui/toggle-group/ToggleGroupItem.vue +35 -0
- package/src/components/ui/toggle-group/index.ts +2 -0
- package/src/components/ui/tooltip/Tooltip.vue +14 -0
- package/src/components/ui/tooltip/TooltipContent.vue +31 -0
- package/src/components/ui/tooltip/TooltipProvider.vue +11 -0
- package/src/components/ui/tooltip/TooltipTrigger.vue +11 -0
- package/src/components/ui/tooltip/index.ts +4 -0
- package/src/composables/glass/index.ts +8 -0
- package/src/composables/glass/useGlassRenderer.ts +252 -0
- package/src/composables/glass/webgl/frostShader.ts +221 -0
- package/src/composables/glass/webgpu/glassShader.wgsl +173 -0
- package/src/composables/index.ts +32 -0
- package/src/composables/infinite-scroll/index.ts +2 -0
- package/src/composables/infinite-scroll/types.ts +25 -0
- package/src/composables/infinite-scroll/useInfiniteScroll.ts +101 -0
- package/src/composables/interaction/index.ts +5 -0
- package/src/composables/interaction/useHeightTransition.ts +82 -0
- package/src/composables/interaction/useHoverPopover.ts +64 -0
- package/src/composables/interaction/useHoverToggle.ts +103 -0
- package/src/composables/interaction/useLeaveTimer.ts +17 -0
- package/src/composables/interaction/useTouchGate.ts +207 -0
- package/src/composables/pagination/index.ts +2 -0
- package/src/composables/pagination/useOffsetPagination.ts +70 -0
- package/src/composables/prng.ts +32 -0
- package/src/composables/useCharSplit.ts +31 -0
- package/src/composables/useClipboard.ts +46 -0
- package/src/composables/useGlobalDark.ts +61 -0
- package/src/composables/useKeyboardShortcuts.ts +205 -0
- package/src/composables/useWatercolorBlob.ts +136 -0
- package/src/composables/virtual/index.ts +22 -0
- package/src/composables/virtual/useVirtualSectionWindow.ts +338 -0
- package/src/composables/virtual/useWindowedStore.ts +86 -0
- package/src/composables/virtual/virtualSectionLayout.ts +212 -0
- package/src/index.ts +9 -0
- package/src/styles/animations.css +233 -0
- package/src/styles/cards.css +66 -0
- package/src/styles/dock.css +221 -0
- package/src/styles/floating-panel.css +49 -0
- package/src/styles/glass.css +266 -0
- package/src/styles/index.css +26 -0
- package/src/styles/scroll-pane.css +10 -0
- package/src/styles/theme.css +138 -0
- package/src/styles/tokens.css +333 -0
- package/src/styles/transitions.css +226 -0
- package/src/styles/typography.css +277 -0
- package/src/styles/utilities.css +697 -0
- package/src/utils/cn.ts +6 -0
- package/src/utils/index.ts +1 -0
|
@@ -0,0 +1,589 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ref, watch, nextTick } from "vue";
|
|
3
|
+
import { Search, X, Maximize2, Minimize2 } from "lucide-vue-next";
|
|
4
|
+
import { fuzzyMatch } from "./composables/fuzzySearchIndex";
|
|
5
|
+
import type { FuzzySearchState, SearchableItem, SearchResult } from "./composables/types";
|
|
6
|
+
|
|
7
|
+
const props = withDefaults(
|
|
8
|
+
defineProps<{
|
|
9
|
+
state: FuzzySearchState;
|
|
10
|
+
variant?: "sidebar" | "floating";
|
|
11
|
+
placeholder?: string;
|
|
12
|
+
typeLabel?: (item: SearchableItem) => string;
|
|
13
|
+
}>(),
|
|
14
|
+
{
|
|
15
|
+
variant: "sidebar",
|
|
16
|
+
placeholder: "Search\u2026",
|
|
17
|
+
},
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
const inputRef = ref<HTMLInputElement | null>(null);
|
|
21
|
+
const resultsRef = ref<HTMLElement | null>(null);
|
|
22
|
+
const modalInputRef = ref<HTMLInputElement | null>(null);
|
|
23
|
+
|
|
24
|
+
// Scroll selected result into view
|
|
25
|
+
watch(
|
|
26
|
+
() => props.state.selectedIndex.value,
|
|
27
|
+
() => {
|
|
28
|
+
nextTick(() => {
|
|
29
|
+
const container = props.state.isExpanded.value
|
|
30
|
+
? document.querySelector(".fuzzy-search-modal-results")
|
|
31
|
+
: resultsRef.value;
|
|
32
|
+
const el = container?.querySelector(".is-selected");
|
|
33
|
+
el?.scrollIntoView({ block: "nearest" });
|
|
34
|
+
});
|
|
35
|
+
},
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
// Auto-focus input when opened
|
|
39
|
+
watch(
|
|
40
|
+
() => props.state.isOpen.value,
|
|
41
|
+
(open) => {
|
|
42
|
+
if (open) nextTick(() => inputRef.value?.focus());
|
|
43
|
+
},
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
// Focus modal input when expanded
|
|
47
|
+
watch(
|
|
48
|
+
() => props.state.isExpanded.value,
|
|
49
|
+
(expanded) => {
|
|
50
|
+
if (expanded) nextTick(() => modalInputRef.value?.focus());
|
|
51
|
+
},
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
function focus() {
|
|
55
|
+
inputRef.value?.focus();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
defineExpose({ focus });
|
|
59
|
+
|
|
60
|
+
function resultLabel(r: SearchResult): string {
|
|
61
|
+
return r.item.label || r.item.text.slice(0, 120);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function getTypeLabel(r: SearchResult): string {
|
|
65
|
+
if (props.typeLabel) return props.typeLabel(r.item);
|
|
66
|
+
return r.item.type ?? "";
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Highlight matched characters using fuzzy match indices.
|
|
71
|
+
* Re-runs fuzzyMatch on the display label for precise positions.
|
|
72
|
+
*/
|
|
73
|
+
function highlightFuzzy(text: string, query: string): string {
|
|
74
|
+
if (!query.trim() || !text) return escapeHtml(text);
|
|
75
|
+
|
|
76
|
+
const tokens = query.toLowerCase().trim().split(/\s+/).filter(Boolean);
|
|
77
|
+
const textLc = text.toLowerCase();
|
|
78
|
+
const matchSet = new Set<number>();
|
|
79
|
+
|
|
80
|
+
for (const token of tokens) {
|
|
81
|
+
const m = fuzzyMatch(token, textLc);
|
|
82
|
+
if (m) {
|
|
83
|
+
for (const idx of m.matches) matchSet.add(idx);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (matchSet.size === 0) return escapeHtml(text);
|
|
88
|
+
|
|
89
|
+
const chars = [...text];
|
|
90
|
+
const parts: string[] = [];
|
|
91
|
+
let i = 0;
|
|
92
|
+
|
|
93
|
+
while (i < chars.length) {
|
|
94
|
+
if (matchSet.has(i)) {
|
|
95
|
+
let j = i;
|
|
96
|
+
while (j < chars.length && matchSet.has(j)) j++;
|
|
97
|
+
parts.push(`<mark>${escapeHtml(chars.slice(i, j).join(""))}</mark>`);
|
|
98
|
+
i = j;
|
|
99
|
+
} else {
|
|
100
|
+
parts.push(escapeHtml(chars[i]));
|
|
101
|
+
i++;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return parts.join("");
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function escapeHtml(s: string): string {
|
|
109
|
+
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
110
|
+
}
|
|
111
|
+
</script>
|
|
112
|
+
|
|
113
|
+
<template>
|
|
114
|
+
<div class="fuzzy-search" :class="`fuzzy-search--${variant}`">
|
|
115
|
+
<!-- Inline input -->
|
|
116
|
+
<div class="fuzzy-search-input-wrap">
|
|
117
|
+
<Search class="fuzzy-search-icon" />
|
|
118
|
+
<input
|
|
119
|
+
ref="inputRef"
|
|
120
|
+
type="text"
|
|
121
|
+
class="fuzzy-search-input"
|
|
122
|
+
:placeholder="placeholder"
|
|
123
|
+
:value="state.query.value"
|
|
124
|
+
@input="state.query.value = ($event.target as HTMLInputElement).value"
|
|
125
|
+
@keydown="state.onKeydown"
|
|
126
|
+
@focus="state.isOpen.value = true"
|
|
127
|
+
/>
|
|
128
|
+
<button
|
|
129
|
+
v-if="state.query.value && state.results.value.length > 0"
|
|
130
|
+
class="fuzzy-search-action-btn"
|
|
131
|
+
@click="state.toggleExpanded()"
|
|
132
|
+
:title="state.isExpanded.value ? 'Collapse' : 'Expand'"
|
|
133
|
+
>
|
|
134
|
+
<Maximize2 v-if="!state.isExpanded.value" class="h-3 w-3" />
|
|
135
|
+
<Minimize2 v-else class="h-3 w-3" />
|
|
136
|
+
</button>
|
|
137
|
+
<button
|
|
138
|
+
v-if="state.query.value"
|
|
139
|
+
class="fuzzy-search-action-btn"
|
|
140
|
+
@click="state.close()"
|
|
141
|
+
title="Clear search"
|
|
142
|
+
>
|
|
143
|
+
<X class="h-3 w-3" />
|
|
144
|
+
</button>
|
|
145
|
+
</div>
|
|
146
|
+
|
|
147
|
+
<!-- Inline dropdown (non-expanded) -->
|
|
148
|
+
<Transition name="fuzzy-search-dropdown">
|
|
149
|
+
<div
|
|
150
|
+
v-if="state.isOpen.value && !state.isExpanded.value && state.results.value.length > 0"
|
|
151
|
+
ref="resultsRef"
|
|
152
|
+
class="fuzzy-search-results"
|
|
153
|
+
>
|
|
154
|
+
<button
|
|
155
|
+
v-for="(r, i) in state.results.value"
|
|
156
|
+
:key="`${r.item.id}-${r.item.type}-${i}`"
|
|
157
|
+
class="fuzzy-search-result"
|
|
158
|
+
:class="{ 'is-selected': i === state.selectedIndex.value }"
|
|
159
|
+
@click="state.selectResult(r)"
|
|
160
|
+
@mouseenter="state.selectedIndex.value = i"
|
|
161
|
+
>
|
|
162
|
+
<span v-if="getTypeLabel(r)" class="fuzzy-search-badge" :data-type="r.item.type">
|
|
163
|
+
{{ getTypeLabel(r) }}
|
|
164
|
+
</span>
|
|
165
|
+
<span
|
|
166
|
+
class="fuzzy-search-label"
|
|
167
|
+
v-html="highlightFuzzy(resultLabel(r), state.query.value)"
|
|
168
|
+
/>
|
|
169
|
+
</button>
|
|
170
|
+
</div>
|
|
171
|
+
</Transition>
|
|
172
|
+
|
|
173
|
+
<!-- Backdrop for inline dropdown (floating variant only) -->
|
|
174
|
+
<div
|
|
175
|
+
v-if="variant === 'floating' && state.isOpen.value && !state.isExpanded.value && state.results.value.length > 0"
|
|
176
|
+
class="fuzzy-search-backdrop"
|
|
177
|
+
@click="state.close()"
|
|
178
|
+
/>
|
|
179
|
+
|
|
180
|
+
<!-- Expanded modal -->
|
|
181
|
+
<Teleport to="body">
|
|
182
|
+
<Transition name="fuzzy-search-modal">
|
|
183
|
+
<div
|
|
184
|
+
v-if="state.isExpanded.value"
|
|
185
|
+
class="fuzzy-search-modal-overlay"
|
|
186
|
+
@click.self="state.toggleExpanded()"
|
|
187
|
+
>
|
|
188
|
+
<div class="fuzzy-search-modal" @click.stop>
|
|
189
|
+
<!-- Modal header -->
|
|
190
|
+
<div class="fuzzy-search-modal-header">
|
|
191
|
+
<Search class="fuzzy-search-modal-icon" />
|
|
192
|
+
<input
|
|
193
|
+
ref="modalInputRef"
|
|
194
|
+
type="text"
|
|
195
|
+
class="fuzzy-search-modal-input"
|
|
196
|
+
:placeholder="placeholder"
|
|
197
|
+
:value="state.query.value"
|
|
198
|
+
@input="state.query.value = ($event.target as HTMLInputElement).value"
|
|
199
|
+
@keydown="state.onKeydown"
|
|
200
|
+
/>
|
|
201
|
+
<button
|
|
202
|
+
class="fuzzy-search-action-btn"
|
|
203
|
+
@click="state.toggleExpanded()"
|
|
204
|
+
title="Collapse"
|
|
205
|
+
>
|
|
206
|
+
<Minimize2 class="h-3.5 w-3.5" />
|
|
207
|
+
</button>
|
|
208
|
+
<button
|
|
209
|
+
class="fuzzy-search-action-btn"
|
|
210
|
+
@click="state.close()"
|
|
211
|
+
title="Close"
|
|
212
|
+
>
|
|
213
|
+
<X class="h-3.5 w-3.5" />
|
|
214
|
+
</button>
|
|
215
|
+
</div>
|
|
216
|
+
|
|
217
|
+
<!-- Modal results -->
|
|
218
|
+
<div class="fuzzy-search-modal-results" v-if="state.results.value.length > 0">
|
|
219
|
+
<button
|
|
220
|
+
v-for="(r, i) in state.results.value"
|
|
221
|
+
:key="`modal-${r.item.id}-${r.item.type}-${i}`"
|
|
222
|
+
class="fuzzy-search-result fuzzy-search-modal-result"
|
|
223
|
+
:class="{ 'is-selected': i === state.selectedIndex.value }"
|
|
224
|
+
@click="state.selectResult(r)"
|
|
225
|
+
@mouseenter="state.selectedIndex.value = i"
|
|
226
|
+
>
|
|
227
|
+
<span v-if="getTypeLabel(r)" class="fuzzy-search-badge" :data-type="r.item.type">
|
|
228
|
+
{{ getTypeLabel(r) }}
|
|
229
|
+
</span>
|
|
230
|
+
<span
|
|
231
|
+
class="fuzzy-search-label"
|
|
232
|
+
v-html="highlightFuzzy(resultLabel(r), state.query.value)"
|
|
233
|
+
/>
|
|
234
|
+
</button>
|
|
235
|
+
</div>
|
|
236
|
+
<div v-else class="fuzzy-search-modal-empty">
|
|
237
|
+
No results
|
|
238
|
+
</div>
|
|
239
|
+
|
|
240
|
+
<!-- Modal footer -->
|
|
241
|
+
<div class="fuzzy-search-modal-footer">
|
|
242
|
+
<span class="fuzzy-search-modal-hint">
|
|
243
|
+
<kbd>↑</kbd><kbd>↓</kbd> navigate
|
|
244
|
+
</span>
|
|
245
|
+
<span class="fuzzy-search-modal-hint">
|
|
246
|
+
<kbd>↵</kbd> select
|
|
247
|
+
</span>
|
|
248
|
+
<span class="fuzzy-search-modal-hint">
|
|
249
|
+
<kbd>esc</kbd> close
|
|
250
|
+
</span>
|
|
251
|
+
</div>
|
|
252
|
+
</div>
|
|
253
|
+
</div>
|
|
254
|
+
</Transition>
|
|
255
|
+
</Teleport>
|
|
256
|
+
</div>
|
|
257
|
+
</template>
|
|
258
|
+
|
|
259
|
+
<style scoped>
|
|
260
|
+
.fuzzy-search {
|
|
261
|
+
position: relative;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
.fuzzy-search-input-wrap {
|
|
265
|
+
display: flex;
|
|
266
|
+
align-items: center;
|
|
267
|
+
gap: 0.375rem;
|
|
268
|
+
border: 1.5px solid color-mix(in srgb, var(--border) 60%, transparent);
|
|
269
|
+
border-radius: var(--radius-pill);
|
|
270
|
+
background: color-mix(in srgb, var(--muted) 30%, transparent);
|
|
271
|
+
padding: 0.35rem 0.625rem;
|
|
272
|
+
transition:
|
|
273
|
+
border-color var(--duration-fast) var(--ease-standard),
|
|
274
|
+
background var(--duration-fast) var(--ease-standard),
|
|
275
|
+
box-shadow var(--duration-fast) var(--ease-standard);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
.fuzzy-search-input-wrap:focus-within {
|
|
279
|
+
border-color: color-mix(in srgb, var(--ring) 40%, transparent);
|
|
280
|
+
background: var(--background);
|
|
281
|
+
box-shadow: var(--focus-ring-shadow);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
.fuzzy-search-icon {
|
|
285
|
+
width: 0.8rem;
|
|
286
|
+
height: 0.8rem;
|
|
287
|
+
flex-shrink: 0;
|
|
288
|
+
color: color-mix(in srgb, var(--muted-foreground) 50%, transparent);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
.fuzzy-search-input {
|
|
292
|
+
flex: 1;
|
|
293
|
+
min-width: 0;
|
|
294
|
+
border: none;
|
|
295
|
+
outline: none;
|
|
296
|
+
background: transparent;
|
|
297
|
+
font-size: 0.78rem;
|
|
298
|
+
color: var(--foreground);
|
|
299
|
+
font-family: inherit;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
.fuzzy-search-input::placeholder {
|
|
303
|
+
color: color-mix(in srgb, var(--muted-foreground) 45%, transparent);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
.fuzzy-search-action-btn {
|
|
307
|
+
display: flex;
|
|
308
|
+
align-items: center;
|
|
309
|
+
justify-content: center;
|
|
310
|
+
padding: 0.15rem;
|
|
311
|
+
border: none;
|
|
312
|
+
background: none;
|
|
313
|
+
color: color-mix(in srgb, var(--muted-foreground) 45%, transparent);
|
|
314
|
+
cursor: pointer;
|
|
315
|
+
border-radius: var(--radius-sm);
|
|
316
|
+
transition: color var(--duration-fast), background var(--duration-fast);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
.fuzzy-search-action-btn:hover {
|
|
320
|
+
color: var(--foreground);
|
|
321
|
+
background: color-mix(in srgb, var(--muted) 50%, transparent);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/* ── Inline dropdown ───────────────────────────────────── */
|
|
325
|
+
.fuzzy-search-results {
|
|
326
|
+
position: absolute;
|
|
327
|
+
top: calc(100% + 4px);
|
|
328
|
+
left: 0;
|
|
329
|
+
right: 0;
|
|
330
|
+
z-index: var(--z-popover);
|
|
331
|
+
max-height: 50vh;
|
|
332
|
+
overflow-y: auto;
|
|
333
|
+
overscroll-behavior: contain;
|
|
334
|
+
background: color-mix(in srgb, var(--background) 97%, transparent);
|
|
335
|
+
backdrop-filter: blur(12px);
|
|
336
|
+
border: 1.5px solid var(--border);
|
|
337
|
+
border-radius: var(--radius-md);
|
|
338
|
+
box-shadow: var(--shadow-md);
|
|
339
|
+
padding: 0.25rem;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
.fuzzy-search-result {
|
|
343
|
+
display: flex;
|
|
344
|
+
align-items: baseline;
|
|
345
|
+
gap: 0.375rem;
|
|
346
|
+
width: 100%;
|
|
347
|
+
padding: 0.35rem 0.5rem;
|
|
348
|
+
border: none;
|
|
349
|
+
background: none;
|
|
350
|
+
cursor: pointer;
|
|
351
|
+
text-align: left;
|
|
352
|
+
border-radius: var(--radius-sm);
|
|
353
|
+
transition: background var(--duration-instant) var(--ease-standard);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
.fuzzy-search-result:hover,
|
|
357
|
+
.fuzzy-search-result.is-selected {
|
|
358
|
+
background: color-mix(in srgb, var(--muted) 50%, transparent);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
.fuzzy-search-badge {
|
|
362
|
+
flex-shrink: 0;
|
|
363
|
+
font-size: 0.6rem;
|
|
364
|
+
font-weight: 700;
|
|
365
|
+
text-transform: uppercase;
|
|
366
|
+
letter-spacing: 0.04em;
|
|
367
|
+
padding: 0.1rem 0.3rem;
|
|
368
|
+
border-radius: var(--radius-sm);
|
|
369
|
+
background: var(--muted);
|
|
370
|
+
color: color-mix(in srgb, var(--muted-foreground) 70%, transparent);
|
|
371
|
+
line-height: 1;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
.fuzzy-search-label {
|
|
375
|
+
flex: 1;
|
|
376
|
+
min-width: 0;
|
|
377
|
+
font-size: 0.875rem;
|
|
378
|
+
color: color-mix(in srgb, var(--foreground) 85%, transparent);
|
|
379
|
+
overflow: hidden;
|
|
380
|
+
text-overflow: ellipsis;
|
|
381
|
+
white-space: nowrap;
|
|
382
|
+
line-height: 1.4;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
.fuzzy-search-label :deep(mark) {
|
|
386
|
+
background: hsl(50 100% 60% / 0.35);
|
|
387
|
+
color: inherit;
|
|
388
|
+
border-radius: var(--radius-sm);
|
|
389
|
+
padding: 0 1px;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
.fuzzy-search-backdrop {
|
|
393
|
+
position: fixed;
|
|
394
|
+
inset: 0;
|
|
395
|
+
z-index: calc(var(--z-popover) - 5);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/* ── Sidebar variant ───────────────────────────────────── */
|
|
399
|
+
.fuzzy-search--sidebar {
|
|
400
|
+
margin-bottom: 0.5rem;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/* ── Floating variant ──────────────────────────────────── */
|
|
404
|
+
.fuzzy-search--floating .fuzzy-search-input-wrap {
|
|
405
|
+
border: none;
|
|
406
|
+
border-radius: 0;
|
|
407
|
+
background: transparent;
|
|
408
|
+
padding: 0;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
.fuzzy-search--floating .fuzzy-search-input {
|
|
412
|
+
font-size: 1rem;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
.fuzzy-search--floating .fuzzy-search-results {
|
|
416
|
+
border-radius: 0;
|
|
417
|
+
border-left: none;
|
|
418
|
+
border-right: none;
|
|
419
|
+
top: 100%;
|
|
420
|
+
max-height: 60vh;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/* ── Inline dropdown transition ────────────────────────── */
|
|
424
|
+
.fuzzy-search-dropdown-enter-active,
|
|
425
|
+
.fuzzy-search-dropdown-leave-active {
|
|
426
|
+
transition:
|
|
427
|
+
opacity var(--duration-fast) var(--ease-standard),
|
|
428
|
+
transform var(--duration-fast) var(--ease-out-expo);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
.fuzzy-search-dropdown-enter-from,
|
|
432
|
+
.fuzzy-search-dropdown-leave-to {
|
|
433
|
+
opacity: 0;
|
|
434
|
+
transform: translateY(-4px);
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/* ── Modal overlay + panel ─────────────────────────────── */
|
|
438
|
+
.fuzzy-search-modal-overlay {
|
|
439
|
+
position: fixed;
|
|
440
|
+
inset: 0;
|
|
441
|
+
z-index: var(--z-modal);
|
|
442
|
+
display: flex;
|
|
443
|
+
align-items: flex-start;
|
|
444
|
+
justify-content: center;
|
|
445
|
+
padding-top: min(12vh, 6rem);
|
|
446
|
+
background: color-mix(in srgb, var(--background) 55%, transparent);
|
|
447
|
+
backdrop-filter: blur(6px);
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
.fuzzy-search-modal {
|
|
451
|
+
width: min(36rem, calc(100vw - 2rem));
|
|
452
|
+
max-height: 70vh;
|
|
453
|
+
display: flex;
|
|
454
|
+
flex-direction: column;
|
|
455
|
+
border-radius: var(--radius-xl);
|
|
456
|
+
border: 1.5px solid var(--border);
|
|
457
|
+
background: var(--background);
|
|
458
|
+
box-shadow: var(--shadow-xl);
|
|
459
|
+
overflow: hidden;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
.fuzzy-search-modal-header {
|
|
463
|
+
display: flex;
|
|
464
|
+
align-items: center;
|
|
465
|
+
gap: 0.5rem;
|
|
466
|
+
padding: 0.75rem 0.875rem;
|
|
467
|
+
border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
.fuzzy-search-modal-icon {
|
|
471
|
+
width: 1rem;
|
|
472
|
+
height: 1rem;
|
|
473
|
+
flex-shrink: 0;
|
|
474
|
+
color: color-mix(in srgb, var(--muted-foreground) 50%, transparent);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
.fuzzy-search-modal-input {
|
|
478
|
+
flex: 1;
|
|
479
|
+
min-width: 0;
|
|
480
|
+
border: none;
|
|
481
|
+
outline: none;
|
|
482
|
+
background: transparent;
|
|
483
|
+
font-size: 1rem;
|
|
484
|
+
color: var(--foreground);
|
|
485
|
+
font-family: inherit;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
.fuzzy-search-modal-input::placeholder {
|
|
489
|
+
color: color-mix(in srgb, var(--muted-foreground) 40%, transparent);
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
.fuzzy-search-modal-results {
|
|
493
|
+
flex: 1;
|
|
494
|
+
min-height: 0;
|
|
495
|
+
overflow-y: auto;
|
|
496
|
+
overscroll-behavior: contain;
|
|
497
|
+
padding: 0.375rem;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
.fuzzy-search-modal-result {
|
|
501
|
+
padding: 0.5rem 0.625rem;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
.fuzzy-search-modal-result .fuzzy-search-badge {
|
|
505
|
+
font-size: 0.65rem;
|
|
506
|
+
padding: 0.125rem 0.375rem;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
.fuzzy-search-modal-result .fuzzy-search-label {
|
|
510
|
+
font-size: 1rem;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
.fuzzy-search-modal-empty {
|
|
514
|
+
padding: 2rem 1rem;
|
|
515
|
+
text-align: center;
|
|
516
|
+
color: color-mix(in srgb, var(--muted-foreground) 50%, transparent);
|
|
517
|
+
font-size: 1rem;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
.fuzzy-search-modal-footer {
|
|
521
|
+
display: flex;
|
|
522
|
+
align-items: center;
|
|
523
|
+
gap: 1rem;
|
|
524
|
+
padding: 0.5rem 0.875rem;
|
|
525
|
+
border-top: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
.fuzzy-search-modal-hint {
|
|
529
|
+
font-size: 0.875rem;
|
|
530
|
+
font-family: var(--font-mono, monospace);
|
|
531
|
+
color: color-mix(in srgb, var(--muted-foreground) 45%, transparent);
|
|
532
|
+
display: flex;
|
|
533
|
+
align-items: center;
|
|
534
|
+
gap: 0.25rem;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
.fuzzy-search-modal-hint kbd {
|
|
538
|
+
display: inline-flex;
|
|
539
|
+
align-items: center;
|
|
540
|
+
justify-content: center;
|
|
541
|
+
min-width: 1.25rem;
|
|
542
|
+
height: 1.125rem;
|
|
543
|
+
padding: 0 0.25rem;
|
|
544
|
+
border-radius: var(--radius-sm);
|
|
545
|
+
border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
|
|
546
|
+
background: color-mix(in srgb, var(--muted) 40%, transparent);
|
|
547
|
+
font-size: 0.6rem;
|
|
548
|
+
line-height: 1;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
/* ── Modal transition ──────────────────────────────────── */
|
|
552
|
+
.fuzzy-search-modal-enter-active {
|
|
553
|
+
transition: opacity 0.2s var(--ease-standard);
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
.fuzzy-search-modal-enter-active .fuzzy-search-modal {
|
|
557
|
+
transition:
|
|
558
|
+
opacity 0.2s var(--ease-standard),
|
|
559
|
+
transform 0.25s var(--ease-out-expo);
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
.fuzzy-search-modal-leave-active {
|
|
563
|
+
transition: opacity var(--duration-fast) var(--ease-standard);
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
.fuzzy-search-modal-leave-active .fuzzy-search-modal {
|
|
567
|
+
transition:
|
|
568
|
+
opacity var(--duration-fast) var(--ease-standard),
|
|
569
|
+
transform var(--duration-fast) var(--ease-in);
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
.fuzzy-search-modal-enter-from {
|
|
573
|
+
opacity: 0;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
.fuzzy-search-modal-enter-from .fuzzy-search-modal {
|
|
577
|
+
opacity: 0;
|
|
578
|
+
transform: scale(0.96) translateY(-8px);
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
.fuzzy-search-modal-leave-to {
|
|
582
|
+
opacity: 0;
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
.fuzzy-search-modal-leave-to .fuzzy-search-modal {
|
|
586
|
+
opacity: 0;
|
|
587
|
+
transform: scale(0.97) translateY(-4px);
|
|
588
|
+
}
|
|
589
|
+
</style>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<component
|
|
3
|
+
:is="tag"
|
|
4
|
+
:class="cn('input-bar', $attrs.class as string)"
|
|
5
|
+
>
|
|
6
|
+
<component :is="icon ?? Search" class="w-3.5 h-3.5 text-muted-foreground shrink-0" />
|
|
7
|
+
<input
|
|
8
|
+
ref="inputRef"
|
|
9
|
+
:value="modelValue"
|
|
10
|
+
:placeholder="placeholder"
|
|
11
|
+
class="input-bar-field"
|
|
12
|
+
@input="emit('update:modelValue', ($event.target as HTMLInputElement).value)"
|
|
13
|
+
/>
|
|
14
|
+
<slot />
|
|
15
|
+
</component>
|
|
16
|
+
</template>
|
|
17
|
+
|
|
18
|
+
<script setup lang="ts">
|
|
19
|
+
import { ref, type Component } from "vue";
|
|
20
|
+
import { Search } from "lucide-vue-next";
|
|
21
|
+
import { cn } from "../../../utils";
|
|
22
|
+
|
|
23
|
+
const props = withDefaults(
|
|
24
|
+
defineProps<{
|
|
25
|
+
modelValue?: string;
|
|
26
|
+
placeholder?: string;
|
|
27
|
+
icon?: Component;
|
|
28
|
+
tag?: string;
|
|
29
|
+
}>(),
|
|
30
|
+
{
|
|
31
|
+
modelValue: "",
|
|
32
|
+
placeholder: "Search\u2026",
|
|
33
|
+
tag: "div",
|
|
34
|
+
},
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
const emit = defineEmits<{
|
|
38
|
+
"update:modelValue": [value: string];
|
|
39
|
+
}>();
|
|
40
|
+
|
|
41
|
+
const inputRef = ref<HTMLInputElement | null>(null);
|
|
42
|
+
|
|
43
|
+
defineExpose({ inputRef });
|
|
44
|
+
</script>
|