@refraction-ui/astro 0.4.0 → 0.4.4
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/dist/accordion/index.ts +1 -0
- package/dist/ai/ai-manager.ts +121 -0
- package/dist/ai/index.ts +23 -0
- package/dist/ai/mock-providers.ts +68 -0
- package/dist/ai/sanitizer.ts +174 -0
- package/dist/ai/tts-manager.ts +80 -0
- package/dist/ai/types.ts +72 -0
- package/dist/animated-text/animated-text.styles.ts +28 -0
- package/dist/animated-text/animated-text.ts +83 -0
- package/dist/animated-text/index.ts +15 -0
- package/dist/app-shell/app-shell.ts +252 -0
- package/dist/app-shell/auth-shell.ts +84 -0
- package/dist/app-shell/index.ts +22 -0
- package/dist/app-shell/page-shell.ts +125 -0
- package/dist/astro-accordion/Button.astro +55 -0
- package/dist/astro-accordion/index.ts +1 -0
- package/dist/astro-ai/AIScript.astro +69 -0
- package/dist/astro-ai/TTSScript.astro +60 -0
- package/dist/astro-ai/index.ts +16 -0
- package/dist/astro-animated-text/AnimatedText.astro +81 -0
- package/dist/astro-animated-text/TypewriterText.astro +90 -0
- package/dist/astro-animated-text/index.ts +1 -0
- package/dist/astro-app-shell/AppShell.astro +195 -0
- package/dist/astro-app-shell/AppShellContent.astro +29 -0
- package/dist/astro-app-shell/AppShellHeader.astro +54 -0
- package/dist/astro-app-shell/AppShellMain.astro +18 -0
- package/dist/astro-app-shell/AppShellMobileNav.astro +27 -0
- package/dist/astro-app-shell/AppShellOverlay.astro +21 -0
- package/dist/astro-app-shell/AppShellSidebar.astro +26 -0
- package/dist/astro-app-shell/AuthShell.astro +31 -0
- package/dist/astro-app-shell/AuthShellCard.astro +24 -0
- package/dist/astro-app-shell/PageShell.astro +36 -0
- package/dist/astro-app-shell/PageShellFooter.astro +30 -0
- package/dist/astro-app-shell/PageShellNav.astro +33 -0
- package/dist/astro-app-shell/PageShellSection.astro +32 -0
- package/dist/astro-app-shell/index.ts +21 -0
- package/dist/astro-auth/AuthGuard.astro +133 -0
- package/dist/astro-auth/index.ts +5 -0
- package/dist/astro-avatar/Avatar.astro +22 -0
- package/dist/astro-avatar/AvatarFallback.astro +18 -0
- package/dist/astro-avatar/AvatarImage.astro +48 -0
- package/dist/astro-avatar/index.ts +1 -0
- package/dist/astro-avatar-group/AvatarGroup.astro +42 -0
- package/dist/astro-avatar-group/index.ts +1 -0
- package/dist/astro-badge/Badge.astro +27 -0
- package/dist/astro-badge/index.ts +1 -0
- package/dist/astro-bottom-nav/BottomNav.astro +40 -0
- package/dist/astro-bottom-nav/index.ts +1 -0
- package/dist/astro-breadcrumbs/Breadcrumbs.astro +56 -0
- package/dist/astro-breadcrumbs/index.ts +1 -0
- package/dist/astro-button/Button.astro +55 -0
- package/dist/astro-button/index.ts +1 -0
- package/dist/astro-calendar/Calendar.astro +259 -0
- package/dist/astro-calendar/index.ts +1 -0
- package/dist/astro-callout/Callout.astro +3 -0
- package/dist/astro-callout/index.ts +1 -0
- package/dist/astro-card/Card.astro +20 -0
- package/dist/astro-card/CardContent.astro +13 -0
- package/dist/astro-card/CardDescription.astro +13 -0
- package/dist/astro-card/CardFooter.astro +13 -0
- package/dist/astro-card/CardHeader.astro +13 -0
- package/dist/astro-card/CardTitle.astro +15 -0
- package/dist/astro-card/index.ts +1 -0
- package/dist/astro-card-grid/CardGrid.astro +17 -0
- package/dist/astro-card-grid/index.ts +1 -0
- package/dist/astro-carousel/Button.astro +55 -0
- package/dist/astro-carousel/index.ts +1 -0
- package/dist/astro-charts/Bars.astro +53 -0
- package/dist/astro-charts/Chart.astro +31 -0
- package/dist/astro-charts/Circles.astro +48 -0
- package/dist/astro-charts/Gradient.astro +34 -0
- package/dist/astro-charts/Histogram.astro +107 -0
- package/dist/astro-charts/Line.astro +55 -0
- package/dist/astro-charts/PieChart.astro +63 -0
- package/dist/astro-charts/ScatterPlot.astro +95 -0
- package/dist/astro-charts/XAxis.astro +46 -0
- package/dist/astro-charts/YAxis.astro +44 -0
- package/dist/astro-charts/index.ts +26 -0
- package/dist/astro-checkbox/Checkbox.astro +129 -0
- package/dist/astro-checkbox/index.ts +1 -0
- package/dist/astro-code-block/CodeBlock.astro +3 -0
- package/dist/astro-code-block/index.ts +1 -0
- package/dist/astro-code-editor/CodeEditor.astro +123 -0
- package/dist/astro-code-editor/index.ts +1 -0
- package/dist/astro-collapsible/Collapsible.astro +58 -0
- package/dist/astro-collapsible/CollapsibleContent.astro +21 -0
- package/dist/astro-collapsible/CollapsibleTrigger.astro +17 -0
- package/dist/astro-collapsible/index.ts +1 -0
- package/dist/astro-command/Command.astro +170 -0
- package/dist/astro-command/CommandEmpty.astro +17 -0
- package/dist/astro-command/CommandGroup.astro +25 -0
- package/dist/astro-command/CommandInput.astro +21 -0
- package/dist/astro-command/CommandItem.astro +26 -0
- package/dist/astro-command/CommandList.astro +17 -0
- package/dist/astro-command/CommandSeparator.astro +14 -0
- package/dist/astro-command/index.ts +1 -0
- package/dist/astro-command-input/CommandInput.astro +6 -0
- package/dist/astro-command-input/index.ts +1 -0
- package/dist/astro-content-protection/ContentProtection.astro +104 -0
- package/dist/astro-content-protection/index.ts +1 -0
- package/dist/astro-data-table/DataTable.astro +263 -0
- package/dist/astro-data-table/index.ts +1 -0
- package/dist/astro-date-picker/DatePicker.astro +398 -0
- package/dist/astro-date-picker/index.ts +1 -0
- package/dist/astro-device-frame/DeviceFrame.astro +44 -0
- package/dist/astro-device-frame/index.ts +1 -0
- package/dist/astro-dialog/Dialog.astro +138 -0
- package/dist/astro-dialog/DialogClose.astro +16 -0
- package/dist/astro-dialog/DialogContent.astro +24 -0
- package/dist/astro-dialog/DialogDescription.astro +15 -0
- package/dist/astro-dialog/DialogFooter.astro +14 -0
- package/dist/astro-dialog/DialogHeader.astro +14 -0
- package/dist/astro-dialog/DialogOverlay.astro +17 -0
- package/dist/astro-dialog/DialogTitle.astro +15 -0
- package/dist/astro-dialog/DialogTrigger.astro +18 -0
- package/dist/astro-dialog/index.ts +1 -0
- package/dist/astro-diff-viewer/DiffViewer.astro +371 -0
- package/dist/astro-diff-viewer/index.ts +1 -0
- package/dist/astro-dropdown-menu/DropdownMenu.astro +138 -0
- package/dist/astro-dropdown-menu/DropdownMenuContent.astro +20 -0
- package/dist/astro-dropdown-menu/DropdownMenuItem.astro +21 -0
- package/dist/astro-dropdown-menu/DropdownMenuLabel.astro +14 -0
- package/dist/astro-dropdown-menu/DropdownMenuSeparator.astro +14 -0
- package/dist/astro-dropdown-menu/DropdownMenuTrigger.astro +18 -0
- package/dist/astro-dropdown-menu/index.ts +1 -0
- package/dist/astro-emoji-picker/EmojiPicker.astro +255 -0
- package/dist/astro-emoji-picker/index.ts +1 -0
- package/dist/astro-feedback-dialog/FeedbackDialog.astro +152 -0
- package/dist/astro-feedback-dialog/index.ts +1 -0
- package/dist/astro-file-tree/astro-file-tree.astro +4 -0
- package/dist/astro-file-tree/index.ts +1 -0
- package/dist/astro-file-upload/FileUpload.astro +306 -0
- package/dist/astro-file-upload/index.ts +1 -0
- package/dist/astro-footer/Footer.astro +61 -0
- package/dist/astro-footer/index.ts +1 -0
- package/dist/astro-icon-system/astro-icon-system.astro +4 -0
- package/dist/astro-icon-system/index.ts +1 -0
- package/dist/astro-inline-editor/InlineEditor.astro +169 -0
- package/dist/astro-inline-editor/index.ts +1 -0
- package/dist/astro-input/Input.astro +49 -0
- package/dist/astro-input/index.ts +1 -0
- package/dist/astro-input-group/InputGroup.astro +29 -0
- package/dist/astro-input-group/InputGroupAddon.astro +14 -0
- package/dist/astro-input-group/InputGroupButton.astro +19 -0
- package/dist/astro-input-group/InputGroupText.astro +11 -0
- package/dist/astro-input-group/index.ts +1 -0
- package/dist/astro-install-prompt/InstallPrompt.astro +115 -0
- package/dist/astro-install-prompt/index.ts +1 -0
- package/dist/astro-keyboard-shortcut/KeyboardShortcut.astro +83 -0
- package/dist/astro-keyboard-shortcut/ShortcutBadge.astro +41 -0
- package/dist/astro-keyboard-shortcut/index.ts +1 -0
- package/dist/astro-language-selector/LanguageSelector.astro +247 -0
- package/dist/astro-language-selector/index.ts +1 -0
- package/dist/astro-link-card/LinkCard.astro +17 -0
- package/dist/astro-link-card/index.ts +1 -0
- package/dist/astro-markdown-renderer/MarkdownRenderer.astro +62 -0
- package/dist/astro-markdown-renderer/index.ts +1 -0
- package/dist/astro-mobile-nav/MobileNav.astro +84 -0
- package/dist/astro-mobile-nav/MobileNavContent.astro +29 -0
- package/dist/astro-mobile-nav/MobileNavLink.astro +16 -0
- package/dist/astro-mobile-nav/MobileNavTrigger.astro +57 -0
- package/dist/astro-mobile-nav/index.ts +1 -0
- package/dist/astro-navbar/Navbar.astro +49 -0
- package/dist/astro-navbar/index.ts +1 -0
- package/dist/astro-otp-input/OtpInput.astro +253 -0
- package/dist/astro-otp-input/index.ts +1 -0
- package/dist/astro-pagination/Pagination.astro +3 -0
- package/dist/astro-pagination/index.ts +1 -0
- package/dist/astro-payment/Payment.astro +19 -0
- package/dist/astro-payment/index.ts +1 -0
- package/dist/astro-popover/Popover.astro +87 -0
- package/dist/astro-popover/PopoverClose.astro +16 -0
- package/dist/astro-popover/PopoverContent.astro +23 -0
- package/dist/astro-popover/PopoverTrigger.astro +18 -0
- package/dist/astro-popover/index.ts +1 -0
- package/dist/astro-presence-indicator/PresenceIndicator.astro +26 -0
- package/dist/astro-presence-indicator/index.ts +1 -0
- package/dist/astro-progress-display/BadgeDisplay.astro +33 -0
- package/dist/astro-progress-display/ProgressBar.astro +27 -0
- package/dist/astro-progress-display/StatsGrid.astro +32 -0
- package/dist/astro-progress-display/index.ts +1 -0
- package/dist/astro-radio/RadioGroup.astro +111 -0
- package/dist/astro-radio/RadioItem.astro +36 -0
- package/dist/astro-radio/index.ts +1 -0
- package/dist/astro-reaction-bar/ReactionBar.astro +117 -0
- package/dist/astro-reaction-bar/index.ts +1 -0
- package/dist/astro-resizable-layout/ResizableDivider.astro +27 -0
- package/dist/astro-resizable-layout/ResizableLayout.astro +162 -0
- package/dist/astro-resizable-layout/ResizablePane.astro +28 -0
- package/dist/astro-resizable-layout/index.ts +11 -0
- package/dist/astro-rich-editor/RichEditor.astro +260 -0
- package/dist/astro-rich-editor/index.ts +25 -0
- package/dist/astro-search-bar/SearchBar.astro +140 -0
- package/dist/astro-search-bar/SearchResultItem.astro +16 -0
- package/dist/astro-search-bar/SearchResults.astro +17 -0
- package/dist/astro-search-bar/index.ts +1 -0
- package/dist/astro-select/Select.astro +165 -0
- package/dist/astro-select/SelectContent.astro +19 -0
- package/dist/astro-select/SelectItem.astro +42 -0
- package/dist/astro-select/SelectTrigger.astro +36 -0
- package/dist/astro-select/index.ts +1 -0
- package/dist/astro-sidebar/Sidebar.astro +64 -0
- package/dist/astro-sidebar/index.ts +1 -0
- package/dist/astro-skeleton/Skeleton.astro +39 -0
- package/dist/astro-skeleton/SkeletonText.astro +22 -0
- package/dist/astro-skeleton/index.ts +1 -0
- package/dist/astro-skip-to-content/SkipToContent.astro +3 -0
- package/dist/astro-skip-to-content/index.ts +1 -0
- package/dist/astro-slide-viewer/SlideViewer.astro +231 -0
- package/dist/astro-slide-viewer/index.ts +1 -0
- package/dist/astro-slider/index.ts +1 -0
- package/dist/astro-status-indicator/StatusIndicator.astro +31 -0
- package/dist/astro-status-indicator/index.ts +1 -0
- package/dist/astro-steps/Steps.astro +3 -0
- package/dist/astro-steps/index.ts +1 -0
- package/dist/astro-switch/Switch.astro +89 -0
- package/dist/astro-switch/index.ts +1 -0
- package/dist/astro-table-of-contents/TableOfContents.astro +53 -0
- package/dist/astro-table-of-contents/index.ts +1 -0
- package/dist/astro-tabs/Tabs.astro +96 -0
- package/dist/astro-tabs/TabsContent.astro +20 -0
- package/dist/astro-tabs/TabsList.astro +16 -0
- package/dist/astro-tabs/TabsTrigger.astro +24 -0
- package/dist/astro-tabs/index.ts +1 -0
- package/dist/astro-textarea/Textarea.astro +51 -0
- package/dist/astro-textarea/index.ts +1 -0
- package/dist/astro-theme/ThemeScript.astro +13 -0
- package/dist/astro-theme/ThemeToggle.astro +279 -0
- package/dist/astro-theme/index.ts +1 -0
- package/dist/astro-thread-view/ThreadView.astro +159 -0
- package/dist/astro-thread-view/index.ts +1 -0
- package/dist/astro-toast/Toast.astro +49 -0
- package/dist/astro-toast/Toaster.astro +142 -0
- package/dist/astro-toast/index.ts +1 -0
- package/dist/astro-tooltip/Tooltip.astro +95 -0
- package/dist/astro-tooltip/TooltipContent.astro +22 -0
- package/dist/astro-tooltip/TooltipTrigger.astro +16 -0
- package/dist/astro-tooltip/index.ts +1 -0
- package/dist/astro-version-selector/VersionSelector.astro +174 -0
- package/dist/astro-version-selector/index.ts +1 -0
- package/dist/astro-video-player/VideoPlayer.astro +153 -0
- package/dist/astro-video-player/index.ts +1 -0
- package/dist/auth/adapters/mock.ts +74 -0
- package/dist/auth/auth-machine.ts +120 -0
- package/dist/auth/index.ts +22 -0
- package/dist/auth/rbac.ts +44 -0
- package/dist/auth/types.ts +44 -0
- package/dist/avatar/avatar.styles.ts +47 -0
- package/dist/avatar/avatar.ts +73 -0
- package/dist/avatar/index.ts +15 -0
- package/dist/avatar-group/avatar-group.styles.ts +63 -0
- package/dist/avatar-group/avatar-group.ts +106 -0
- package/dist/avatar-group/index.ts +18 -0
- package/dist/badge/badge.styles.ts +24 -0
- package/dist/badge/badge.ts +48 -0
- package/dist/badge/index.ts +10 -0
- package/dist/bottom-nav/bottom-nav.styles.ts +18 -0
- package/dist/bottom-nav/bottom-nav.ts +33 -0
- package/dist/bottom-nav/index.ts +2 -0
- package/dist/breadcrumbs/breadcrumbs.styles.ts +20 -0
- package/dist/breadcrumbs/breadcrumbs.ts +72 -0
- package/dist/breadcrumbs/index.ts +8 -0
- package/dist/button/button.styles.ts +38 -0
- package/dist/button/button.ts +64 -0
- package/dist/button/index.ts +10 -0
- package/dist/calendar/calendar.styles.ts +21 -0
- package/dist/calendar/calendar.ts +202 -0
- package/dist/calendar/index.ts +9 -0
- package/dist/callout/callout.ts +1 -0
- package/dist/callout/index.ts +1 -0
- package/dist/card/card.styles.ts +55 -0
- package/dist/card/card.ts +45 -0
- package/dist/card/index.ts +20 -0
- package/dist/card-grid/card-grid.ts +9 -0
- package/dist/card-grid/index.ts +1 -0
- package/dist/carousel/index.ts +1 -0
- package/dist/charts/axis.ts +50 -0
- package/dist/charts/chart.ts +73 -0
- package/dist/charts/colorblind.ts +100 -0
- package/dist/charts/data.ts +72 -0
- package/dist/charts/geometry.ts +54 -0
- package/dist/charts/index.ts +61 -0
- package/dist/charts/scales.ts +151 -0
- package/dist/checkbox/checkbox.styles.ts +33 -0
- package/dist/checkbox/checkbox.ts +73 -0
- package/dist/checkbox/index.ts +10 -0
- package/dist/code-block/code-block.ts +1 -0
- package/dist/code-block/index.ts +1 -0
- package/dist/code-editor/code-editor.styles.ts +32 -0
- package/dist/code-editor/code-editor.ts +140 -0
- package/dist/code-editor/index.ts +9 -0
- package/dist/collapsible/collapsible.styles.ts +14 -0
- package/dist/collapsible/collapsible.ts +93 -0
- package/dist/collapsible/index.ts +7 -0
- package/dist/command/command.styles.ts +27 -0
- package/dist/command/command.ts +179 -0
- package/dist/command/index.ts +14 -0
- package/dist/command-input/command-input.ts +176 -0
- package/dist/command-input/index.ts +1 -0
- package/dist/content-protection/content-protection.styles.ts +9 -0
- package/dist/content-protection/content-protection.ts +68 -0
- package/dist/content-protection/index.ts +8 -0
- package/dist/data-table/data-table.styles.ts +55 -0
- package/dist/data-table/data-table.ts +183 -0
- package/dist/data-table/index.ts +15 -0
- package/dist/date-picker/date-picker.styles.ts +31 -0
- package/dist/date-picker/date-picker.ts +333 -0
- package/dist/date-picker/index.ts +18 -0
- package/dist/device-frame/device-frame.styles.ts +21 -0
- package/dist/device-frame/device-frame.ts +112 -0
- package/dist/device-frame/index.ts +10 -0
- package/dist/dialog/dialog.styles.ts +8 -0
- package/dist/dialog/dialog.ts +133 -0
- package/dist/dialog/index.ts +8 -0
- package/dist/diff-viewer/diff-viewer.styles.ts +124 -0
- package/dist/diff-viewer/diff-viewer.ts +255 -0
- package/dist/diff-viewer/index.ts +20 -0
- package/dist/dropdown-menu/dropdown-menu.styles.ts +9 -0
- package/dist/dropdown-menu/dropdown-menu.ts +139 -0
- package/dist/dropdown-menu/index.ts +9 -0
- package/dist/emoji-picker/emoji-data.ts +282 -0
- package/dist/emoji-picker/emoji-picker.styles.ts +32 -0
- package/dist/emoji-picker/emoji-picker.ts +165 -0
- package/dist/emoji-picker/index.ts +25 -0
- package/dist/feedback-dialog/feedback-dialog.styles.ts +15 -0
- package/dist/feedback-dialog/feedback-dialog.ts +147 -0
- package/dist/feedback-dialog/index.ts +11 -0
- package/dist/file-upload/file-upload.styles.ts +30 -0
- package/dist/file-upload/file-upload.ts +260 -0
- package/dist/file-upload/index.ts +19 -0
- package/dist/footer/footer.styles.ts +5 -0
- package/dist/footer/footer.ts +32 -0
- package/dist/footer/index.ts +9 -0
- package/dist/index.ts +77 -0
- package/dist/inline-editor/index.ts +13 -0
- package/dist/inline-editor/inline-editor.styles.ts +42 -0
- package/dist/inline-editor/inline-editor.ts +96 -0
- package/dist/input/index.ts +9 -0
- package/dist/input/input.styles.ts +15 -0
- package/dist/input/input.ts +84 -0
- package/dist/input-group/index.ts +13 -0
- package/dist/input-group/input-group.styles.ts +50 -0
- package/dist/input-group/input-group.ts +44 -0
- package/dist/install-prompt/index.ts +9 -0
- package/dist/install-prompt/install-prompt.styles.ts +5 -0
- package/dist/install-prompt/install-prompt.ts +68 -0
- package/dist/keyboard-shortcut/index.ts +12 -0
- package/dist/keyboard-shortcut/keyboard-shortcut.styles.ts +8 -0
- package/dist/keyboard-shortcut/keyboard-shortcut.ts +153 -0
- package/dist/language-selector/index.ts +8 -0
- package/dist/language-selector/language-selector.styles.ts +28 -0
- package/dist/language-selector/language-selector.ts +149 -0
- package/dist/link-card/index.ts +1 -0
- package/dist/link-card/link-card.ts +9 -0
- package/dist/markdown-renderer/index.ts +8 -0
- package/dist/markdown-renderer/markdown-renderer.styles.ts +31 -0
- package/dist/markdown-renderer/markdown-renderer.ts +251 -0
- package/dist/mobile-nav/index.ts +14 -0
- package/dist/mobile-nav/mobile-nav.styles.ts +39 -0
- package/dist/mobile-nav/mobile-nav.ts +74 -0
- package/dist/navbar/index.ts +9 -0
- package/dist/navbar/navbar.styles.ts +29 -0
- package/dist/navbar/navbar.ts +39 -0
- package/dist/otp-input/index.ts +13 -0
- package/dist/otp-input/otp-input.styles.ts +51 -0
- package/dist/otp-input/otp-input.ts +198 -0
- package/dist/pagination/index.ts +1 -0
- package/dist/payment/index.ts +1 -0
- package/dist/payment/payment.ts +16 -0
- package/dist/popover/index.ts +7 -0
- package/dist/popover/popover.styles.ts +16 -0
- package/dist/popover/popover.ts +89 -0
- package/dist/presence-indicator/index.ts +14 -0
- package/dist/presence-indicator/presence-indicator.styles.ts +29 -0
- package/dist/presence-indicator/presence-indicator.ts +63 -0
- package/dist/progress-display/index.ts +15 -0
- package/dist/progress-display/progress-display.styles.ts +72 -0
- package/dist/progress-display/progress-display.ts +60 -0
- package/dist/radio/index.ts +8 -0
- package/dist/radio/radio.styles.ts +34 -0
- package/dist/radio/radio.ts +70 -0
- package/dist/reaction-bar/index.ts +14 -0
- package/dist/reaction-bar/reaction-bar.styles.ts +23 -0
- package/dist/reaction-bar/reaction-bar.ts +87 -0
- package/dist/resizable-layout/index.ts +12 -0
- package/dist/resizable-layout/resizable-layout.styles.ts +50 -0
- package/dist/resizable-layout/resizable-layout.ts +139 -0
- package/dist/rich-editor/editor.ts +342 -0
- package/dist/rich-editor/emoji.ts +175 -0
- package/dist/rich-editor/history.ts +79 -0
- package/dist/rich-editor/index.ts +106 -0
- package/dist/rich-editor/markdown-shortcuts.ts +248 -0
- package/dist/rich-editor/mentions.ts +162 -0
- package/dist/rich-editor/model.ts +206 -0
- package/dist/rich-editor/operations.ts +772 -0
- package/dist/rich-editor/selection.ts +157 -0
- package/dist/rich-editor/serialization.ts +711 -0
- package/dist/rich-editor/slash-commands.ts +212 -0
- package/dist/search-bar/index.ts +7 -0
- package/dist/search-bar/search-bar.styles.ts +29 -0
- package/dist/search-bar/search-bar.ts +130 -0
- package/dist/select/index.ts +13 -0
- package/dist/select/select.styles.ts +52 -0
- package/dist/select/select.ts +152 -0
- package/dist/shared/a11y.ts +33 -0
- package/dist/shared/aria.ts +30 -0
- package/dist/shared/cn.ts +35 -0
- package/dist/shared/cva.ts +79 -0
- package/dist/shared/engine-adapter.ts +10 -0
- package/dist/shared/focus-trap.ts +123 -0
- package/dist/shared/index.ts +60 -0
- package/dist/shared/keyboard.ts +36 -0
- package/dist/shared/live-region.ts +90 -0
- package/dist/shared/motion.ts +15 -0
- package/dist/shared/skip-link.ts +35 -0
- package/dist/shared/state-machine.ts +57 -0
- package/dist/shared/tokens.ts +16 -0
- package/dist/shared/types.ts +45 -0
- package/dist/shared/variants.ts +17 -0
- package/dist/sidebar/index.ts +9 -0
- package/dist/sidebar/sidebar.styles.ts +27 -0
- package/dist/sidebar/sidebar.ts +59 -0
- package/dist/skeleton/index.ts +8 -0
- package/dist/skeleton/skeleton.styles.ts +16 -0
- package/dist/skeleton/skeleton.ts +39 -0
- package/dist/skip-to-content/index.ts +1 -0
- package/dist/skip-to-content/skip-to-content.ts +1 -0
- package/dist/slide-viewer/index.ts +16 -0
- package/dist/slide-viewer/slide-viewer.styles.ts +57 -0
- package/dist/slide-viewer/slide-viewer.ts +152 -0
- package/dist/slider/index.ts +1 -0
- package/dist/slider/slider.ts +2 -0
- package/dist/status-indicator/index.ts +15 -0
- package/dist/status-indicator/status-indicator.styles.ts +41 -0
- package/dist/status-indicator/status-indicator.ts +66 -0
- package/dist/steps/index.ts +1 -0
- package/dist/steps/steps.ts +1 -0
- package/dist/switch/index.ts +7 -0
- package/dist/switch/switch.styles.ts +55 -0
- package/dist/switch/switch.ts +63 -0
- package/dist/table-of-contents/index.ts +1 -0
- package/dist/table-of-contents/table-of-contents.ts +37 -0
- package/dist/tabs/index.ts +8 -0
- package/dist/tabs/tabs.styles.ts +9 -0
- package/dist/tabs/tabs.ts +133 -0
- package/dist/textarea/index.ts +7 -0
- package/dist/textarea/textarea.styles.ts +15 -0
- package/dist/textarea/textarea.ts +59 -0
- package/dist/theme/dom-adapters.ts +60 -0
- package/dist/theme/index.ts +18 -0
- package/dist/theme/theme-machine.ts +130 -0
- package/dist/theme/theme-script.ts +18 -0
- package/dist/thread-view/index.ts +26 -0
- package/dist/thread-view/thread-view.styles.ts +35 -0
- package/dist/thread-view/thread-view.ts +176 -0
- package/dist/toast/index.ts +13 -0
- package/dist/toast/toast.styles.ts +19 -0
- package/dist/toast/toast.ts +203 -0
- package/dist/tooltip/index.ts +7 -0
- package/dist/tooltip/tooltip.styles.ts +16 -0
- package/dist/tooltip/tooltip.ts +109 -0
- package/dist/version-selector/index.ts +12 -0
- package/dist/version-selector/version-selector.styles.ts +41 -0
- package/dist/version-selector/version-selector.ts +136 -0
- package/dist/video-player/index.ts +12 -0
- package/dist/video-player/video-player.styles.ts +42 -0
- package/dist/video-player/video-player.ts +100 -0
- package/package.json +20 -19
- package/src/index.ts +0 -94
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { AccessibilityProps, KeyboardHandlerMap } from '../shared/index.ts'
|
|
2
|
+
import { Keys } from '../shared/index.ts'
|
|
3
|
+
|
|
4
|
+
export type CheckedState = boolean | 'indeterminate'
|
|
5
|
+
|
|
6
|
+
export interface CheckboxProps {
|
|
7
|
+
checked?: CheckedState
|
|
8
|
+
disabled?: boolean
|
|
9
|
+
required?: boolean
|
|
10
|
+
name?: string
|
|
11
|
+
value?: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface CheckboxAPI {
|
|
15
|
+
/** ARIA attributes to spread on the element */
|
|
16
|
+
ariaProps: Partial<AccessibilityProps>
|
|
17
|
+
/** Keyboard handlers to attach */
|
|
18
|
+
keyboardHandlers: KeyboardHandlerMap
|
|
19
|
+
/** Whether interaction should be blocked */
|
|
20
|
+
isInteractive: boolean
|
|
21
|
+
/** Data attributes for CSS styling hooks */
|
|
22
|
+
dataAttributes: Record<string, string>
|
|
23
|
+
/** Current state */
|
|
24
|
+
state: {
|
|
25
|
+
checked: CheckedState
|
|
26
|
+
disabled: boolean
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function createCheckbox(props: CheckboxProps = {}): CheckboxAPI {
|
|
31
|
+
const { checked = false, disabled = false } = props
|
|
32
|
+
const isInteractive = !disabled
|
|
33
|
+
|
|
34
|
+
const ariaProps: Partial<AccessibilityProps> = {
|
|
35
|
+
role: 'checkbox',
|
|
36
|
+
'aria-checked': checked === 'indeterminate' ? 'mixed' : checked,
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (disabled) {
|
|
40
|
+
ariaProps['aria-disabled'] = true
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const dataAttributes: Record<string, string> = {}
|
|
44
|
+
if (checked === 'indeterminate') {
|
|
45
|
+
dataAttributes['data-state'] = 'indeterminate'
|
|
46
|
+
} else if (checked) {
|
|
47
|
+
dataAttributes['data-state'] = 'checked'
|
|
48
|
+
} else {
|
|
49
|
+
dataAttributes['data-state'] = 'unchecked'
|
|
50
|
+
}
|
|
51
|
+
if (disabled) {
|
|
52
|
+
dataAttributes['data-disabled'] = ''
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const keyboardHandlers: KeyboardHandlerMap = {}
|
|
56
|
+
if (!isInteractive) {
|
|
57
|
+
keyboardHandlers[Keys.Space] = (e) => e.preventDefault()
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
ariaProps,
|
|
62
|
+
keyboardHandlers,
|
|
63
|
+
isInteractive,
|
|
64
|
+
dataAttributes,
|
|
65
|
+
state: { checked, disabled },
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** SVG path data for the check icon */
|
|
70
|
+
export const checkIconPath = 'M20 6L9 17l-5-5'
|
|
71
|
+
|
|
72
|
+
/** SVG path data for the indeterminate/minus icon */
|
|
73
|
+
export const indeterminateIconPath = 'M5 12h14'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './code-block';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { cva } from '../shared/index.ts'
|
|
2
|
+
import type { TokenContract } from '../shared/index.ts'
|
|
3
|
+
|
|
4
|
+
export const codeEditorTokens: TokenContract = {
|
|
5
|
+
name: 'code-editor',
|
|
6
|
+
tokens: {
|
|
7
|
+
bg: { variable: '--rfr-code-editor-bg', fallback: 'hsl(var(--background))' },
|
|
8
|
+
fg: { variable: '--rfr-code-editor-fg', fallback: 'hsl(var(--foreground))' },
|
|
9
|
+
headerBg: { variable: '--rfr-code-editor-header-bg', fallback: 'hsl(var(--muted))' },
|
|
10
|
+
border: { variable: '--rfr-code-editor-border', fallback: 'hsl(var(--border))' },
|
|
11
|
+
lineNumberFg: { variable: '--rfr-code-editor-line-number', fallback: 'hsl(var(--muted-foreground))' },
|
|
12
|
+
},
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const codeEditorVariants = cva({
|
|
16
|
+
base: 'flex flex-col rounded-lg border overflow-hidden font-mono text-sm',
|
|
17
|
+
variants: {
|
|
18
|
+
theme: {
|
|
19
|
+
light: 'bg-white text-gray-900 border-gray-200',
|
|
20
|
+
dark: 'bg-gray-900 text-gray-100 border-gray-700',
|
|
21
|
+
},
|
|
22
|
+
size: {
|
|
23
|
+
sm: 'text-xs',
|
|
24
|
+
default: 'text-sm',
|
|
25
|
+
lg: 'text-base',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
defaultVariants: {
|
|
29
|
+
theme: 'light',
|
|
30
|
+
size: 'default',
|
|
31
|
+
},
|
|
32
|
+
})
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import type { AccessibilityProps } from '../shared/index.ts'
|
|
2
|
+
|
|
3
|
+
export type CodeEditorTheme = 'light' | 'dark'
|
|
4
|
+
|
|
5
|
+
export interface CodeEditorProps {
|
|
6
|
+
value?: string
|
|
7
|
+
onChange?: (value: string) => void
|
|
8
|
+
language?: string
|
|
9
|
+
readOnly?: boolean
|
|
10
|
+
theme?: CodeEditorTheme
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface CodeEditorState {
|
|
14
|
+
value: string
|
|
15
|
+
language: string
|
|
16
|
+
theme: CodeEditorTheme
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface CodeEditorAPI {
|
|
20
|
+
/** Current editor state */
|
|
21
|
+
state: CodeEditorState
|
|
22
|
+
/** ARIA attributes for the editor element */
|
|
23
|
+
ariaProps: Partial<AccessibilityProps> & { 'aria-multiline'?: boolean }
|
|
24
|
+
/** Data attributes for CSS styling hooks */
|
|
25
|
+
dataAttributes: Record<string, string>
|
|
26
|
+
/** Update the editor value */
|
|
27
|
+
setValue: (value: string) => void
|
|
28
|
+
/** Get a human-readable label for the current language */
|
|
29
|
+
getLanguageLabel: () => string
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Map of language identifiers to human-readable labels */
|
|
33
|
+
const languageLabels: Record<string, string> = {
|
|
34
|
+
js: 'JavaScript',
|
|
35
|
+
javascript: 'JavaScript',
|
|
36
|
+
ts: 'TypeScript',
|
|
37
|
+
typescript: 'TypeScript',
|
|
38
|
+
jsx: 'JSX',
|
|
39
|
+
tsx: 'TSX',
|
|
40
|
+
py: 'Python',
|
|
41
|
+
python: 'Python',
|
|
42
|
+
rb: 'Ruby',
|
|
43
|
+
ruby: 'Ruby',
|
|
44
|
+
go: 'Go',
|
|
45
|
+
rust: 'Rust',
|
|
46
|
+
rs: 'Rust',
|
|
47
|
+
java: 'Java',
|
|
48
|
+
cpp: 'C++',
|
|
49
|
+
c: 'C',
|
|
50
|
+
cs: 'C#',
|
|
51
|
+
csharp: 'C#',
|
|
52
|
+
html: 'HTML',
|
|
53
|
+
css: 'CSS',
|
|
54
|
+
json: 'JSON',
|
|
55
|
+
yaml: 'YAML',
|
|
56
|
+
yml: 'YAML',
|
|
57
|
+
md: 'Markdown',
|
|
58
|
+
markdown: 'Markdown',
|
|
59
|
+
sql: 'SQL',
|
|
60
|
+
sh: 'Shell',
|
|
61
|
+
bash: 'Bash',
|
|
62
|
+
zsh: 'Zsh',
|
|
63
|
+
xml: 'XML',
|
|
64
|
+
toml: 'TOML',
|
|
65
|
+
swift: 'Swift',
|
|
66
|
+
kotlin: 'Kotlin',
|
|
67
|
+
dart: 'Dart',
|
|
68
|
+
php: 'PHP',
|
|
69
|
+
lua: 'Lua',
|
|
70
|
+
r: 'R',
|
|
71
|
+
scala: 'Scala',
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Create a headless code editor API.
|
|
76
|
+
*
|
|
77
|
+
* This provides the headless interface for a code editor — state management,
|
|
78
|
+
* ARIA props, and data attributes. Actual rendering (Monaco, CodeMirror, or
|
|
79
|
+
* a simple textarea) is handled by framework-specific wrappers.
|
|
80
|
+
*/
|
|
81
|
+
export function createCodeEditor(props: CodeEditorProps = {}): CodeEditorAPI {
|
|
82
|
+
const {
|
|
83
|
+
value = '',
|
|
84
|
+
onChange,
|
|
85
|
+
language = 'plaintext',
|
|
86
|
+
readOnly = false,
|
|
87
|
+
theme = 'light',
|
|
88
|
+
} = props
|
|
89
|
+
|
|
90
|
+
let currentValue = value
|
|
91
|
+
|
|
92
|
+
const state: CodeEditorState = {
|
|
93
|
+
value: currentValue,
|
|
94
|
+
language,
|
|
95
|
+
theme,
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const ariaProps: Partial<AccessibilityProps> & { 'aria-multiline'?: boolean; 'aria-readonly'?: boolean } = {
|
|
99
|
+
role: 'textbox',
|
|
100
|
+
'aria-multiline': true,
|
|
101
|
+
'aria-label': `Code editor - ${getLabel(language)}`,
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (readOnly) {
|
|
105
|
+
ariaProps['aria-readonly'] = true
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const dataAttributes: Record<string, string> = {
|
|
109
|
+
'data-language': language,
|
|
110
|
+
'data-theme': theme,
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (readOnly) {
|
|
114
|
+
dataAttributes['data-readonly'] = ''
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function setValue(newValue: string) {
|
|
118
|
+
currentValue = newValue
|
|
119
|
+
state.value = newValue
|
|
120
|
+
if (onChange) {
|
|
121
|
+
onChange(newValue)
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function getLabel(lang: string): string {
|
|
126
|
+
return languageLabels[lang.toLowerCase()] ?? lang.charAt(0).toUpperCase() + lang.slice(1)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function getLanguageLabel(): string {
|
|
130
|
+
return getLabel(language)
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return {
|
|
134
|
+
state,
|
|
135
|
+
ariaProps,
|
|
136
|
+
dataAttributes,
|
|
137
|
+
setValue,
|
|
138
|
+
getLanguageLabel,
|
|
139
|
+
}
|
|
140
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { cva } from '../shared/index.ts'
|
|
2
|
+
|
|
3
|
+
export const collapsibleContentVariants = cva({
|
|
4
|
+
base: 'overflow-hidden transition-all',
|
|
5
|
+
variants: {
|
|
6
|
+
state: {
|
|
7
|
+
open: 'animate-accordion-down',
|
|
8
|
+
closed: 'animate-accordion-up',
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
defaultVariants: {
|
|
12
|
+
state: 'closed',
|
|
13
|
+
},
|
|
14
|
+
})
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { generateId, Keys, createKeyboardHandler } from '../shared/index.ts'
|
|
2
|
+
|
|
3
|
+
export interface CollapsibleProps {
|
|
4
|
+
open?: boolean
|
|
5
|
+
defaultOpen?: boolean
|
|
6
|
+
onOpenChange?: (open: boolean) => void
|
|
7
|
+
disabled?: boolean
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface CollapsibleAPI {
|
|
11
|
+
/** Current open state */
|
|
12
|
+
state: { open: boolean }
|
|
13
|
+
/** Props to spread on the trigger element */
|
|
14
|
+
triggerProps: {
|
|
15
|
+
'aria-expanded': boolean
|
|
16
|
+
'aria-controls': string
|
|
17
|
+
'data-state': 'open' | 'closed'
|
|
18
|
+
'data-disabled': string | undefined
|
|
19
|
+
}
|
|
20
|
+
/** Props to spread on the content element */
|
|
21
|
+
contentProps: {
|
|
22
|
+
id: string
|
|
23
|
+
role: 'region'
|
|
24
|
+
'data-state': 'open' | 'closed'
|
|
25
|
+
hidden: boolean
|
|
26
|
+
}
|
|
27
|
+
/** Toggle the open state */
|
|
28
|
+
toggle: () => void
|
|
29
|
+
/** Open the collapsible */
|
|
30
|
+
open: () => void
|
|
31
|
+
/** Close the collapsible */
|
|
32
|
+
close: () => void
|
|
33
|
+
/** Keyboard event handler for Enter/Space toggle */
|
|
34
|
+
keyboardHandler: (event: KeyboardEvent) => void
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function createCollapsible(props: CollapsibleProps = {}): CollapsibleAPI {
|
|
38
|
+
const {
|
|
39
|
+
open: controlledOpen,
|
|
40
|
+
defaultOpen = false,
|
|
41
|
+
onOpenChange,
|
|
42
|
+
disabled = false,
|
|
43
|
+
} = props
|
|
44
|
+
|
|
45
|
+
const isControlled = controlledOpen !== undefined
|
|
46
|
+
let internalOpen = isControlled ? controlledOpen : defaultOpen
|
|
47
|
+
const contentId = generateId('rfr-collapsible')
|
|
48
|
+
|
|
49
|
+
const setOpen = (next: boolean) => {
|
|
50
|
+
if (disabled) return
|
|
51
|
+
if (!isControlled) {
|
|
52
|
+
internalOpen = next
|
|
53
|
+
}
|
|
54
|
+
onOpenChange?.(next)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const toggle = () => setOpen(!internalOpen)
|
|
58
|
+
const openFn = () => setOpen(true)
|
|
59
|
+
const closeFn = () => setOpen(false)
|
|
60
|
+
|
|
61
|
+
const keyboardHandler = createKeyboardHandler({
|
|
62
|
+
[Keys.Enter]: (event: KeyboardEvent) => {
|
|
63
|
+
event.preventDefault()
|
|
64
|
+
toggle()
|
|
65
|
+
},
|
|
66
|
+
[Keys.Space]: (event: KeyboardEvent) => {
|
|
67
|
+
event.preventDefault()
|
|
68
|
+
toggle()
|
|
69
|
+
},
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
const dataState = internalOpen ? 'open' : 'closed'
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
state: { open: internalOpen },
|
|
76
|
+
triggerProps: {
|
|
77
|
+
'aria-expanded': internalOpen,
|
|
78
|
+
'aria-controls': contentId,
|
|
79
|
+
'data-state': dataState,
|
|
80
|
+
'data-disabled': disabled ? '' : undefined,
|
|
81
|
+
},
|
|
82
|
+
contentProps: {
|
|
83
|
+
id: contentId,
|
|
84
|
+
role: 'region',
|
|
85
|
+
'data-state': dataState,
|
|
86
|
+
hidden: !internalOpen,
|
|
87
|
+
},
|
|
88
|
+
toggle,
|
|
89
|
+
open: openFn,
|
|
90
|
+
close: closeFn,
|
|
91
|
+
keyboardHandler,
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { cva } from '../shared/index.ts'
|
|
2
|
+
|
|
3
|
+
export const commandVariants = cva({
|
|
4
|
+
base: 'flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground',
|
|
5
|
+
})
|
|
6
|
+
|
|
7
|
+
export const commandInputVariants = cva({
|
|
8
|
+
base: 'flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50',
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
export const commandItemVariants = cva({
|
|
12
|
+
base: 'relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none',
|
|
13
|
+
variants: {
|
|
14
|
+
state: {
|
|
15
|
+
default: '',
|
|
16
|
+
selected: 'bg-accent text-accent-foreground',
|
|
17
|
+
disabled: 'pointer-events-none opacity-50',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
defaultVariants: {
|
|
21
|
+
state: 'default',
|
|
22
|
+
},
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
export const commandGroupVariants = cva({
|
|
26
|
+
base: 'overflow-hidden p-1 text-foreground',
|
|
27
|
+
})
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import type { KeyboardHandlerMap } from '../shared/index.ts'
|
|
2
|
+
import { Keys, generateId } from '../shared/index.ts'
|
|
3
|
+
|
|
4
|
+
export interface CommandProps {
|
|
5
|
+
/** Whether the command palette is open (controlled) */
|
|
6
|
+
open?: boolean
|
|
7
|
+
/** Callback when open state changes */
|
|
8
|
+
onOpenChange?: (open: boolean) => void
|
|
9
|
+
/** Custom filter function — receives item value and search query, returns true to include */
|
|
10
|
+
filter?: (value: string, search: string) => boolean
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface CommandItemData {
|
|
14
|
+
/** Unique identifier for the item */
|
|
15
|
+
id: string
|
|
16
|
+
/** Display label */
|
|
17
|
+
label: string
|
|
18
|
+
/** Searchable value */
|
|
19
|
+
value: string
|
|
20
|
+
/** Whether the item is disabled */
|
|
21
|
+
disabled?: boolean
|
|
22
|
+
/** Optional group the item belongs to */
|
|
23
|
+
group?: string
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface CommandState {
|
|
27
|
+
/** Current search query */
|
|
28
|
+
search: string
|
|
29
|
+
/** Items after filtering */
|
|
30
|
+
filteredItems: CommandItemData[]
|
|
31
|
+
/** Index of the currently highlighted item in filteredItems */
|
|
32
|
+
selectedIndex: number
|
|
33
|
+
/** Whether the palette is open */
|
|
34
|
+
open: boolean
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface CommandAPI {
|
|
38
|
+
/** Current command state */
|
|
39
|
+
state: CommandState
|
|
40
|
+
/** Update the search query and re-filter items */
|
|
41
|
+
search(query: string): void
|
|
42
|
+
/** Select the item at the given index (or the currently highlighted item) */
|
|
43
|
+
select(index?: number): CommandItemData | undefined
|
|
44
|
+
/** Keyboard handlers for the command palette */
|
|
45
|
+
keyboardHandlers: KeyboardHandlerMap
|
|
46
|
+
/** ARIA attributes for the command root */
|
|
47
|
+
ariaProps: Record<string, unknown>
|
|
48
|
+
/** ARIA attributes for the input */
|
|
49
|
+
inputAriaProps: Record<string, unknown>
|
|
50
|
+
/** ARIA attributes for the list */
|
|
51
|
+
listAriaProps: Record<string, unknown>
|
|
52
|
+
/** Get ARIA attributes for a specific item */
|
|
53
|
+
getItemAriaProps(item: CommandItemData, index: number): Record<string, unknown>
|
|
54
|
+
/** Generated IDs */
|
|
55
|
+
ids: {
|
|
56
|
+
root: string
|
|
57
|
+
input: string
|
|
58
|
+
list: string
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Default filter: case-insensitive includes */
|
|
63
|
+
function defaultFilter(value: string, search: string): boolean {
|
|
64
|
+
return value.toLowerCase().includes(search.toLowerCase())
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function createCommand(
|
|
68
|
+
props: CommandProps = {},
|
|
69
|
+
items: CommandItemData[] = [],
|
|
70
|
+
): CommandAPI {
|
|
71
|
+
const {
|
|
72
|
+
open: controlledOpen,
|
|
73
|
+
onOpenChange,
|
|
74
|
+
filter = defaultFilter,
|
|
75
|
+
} = props
|
|
76
|
+
|
|
77
|
+
const rootId = generateId('rfr-cmd')
|
|
78
|
+
const inputId = generateId('rfr-cmd-input')
|
|
79
|
+
const listId = generateId('rfr-cmd-list')
|
|
80
|
+
|
|
81
|
+
let searchQuery = ''
|
|
82
|
+
let selectedIndex = 0
|
|
83
|
+
let filteredItems = [...items]
|
|
84
|
+
const isOpen = controlledOpen ?? true
|
|
85
|
+
|
|
86
|
+
function applyFilter(query: string): CommandItemData[] {
|
|
87
|
+
if (!query) return [...items]
|
|
88
|
+
return items.filter((item) => filter(item.value, query))
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function doSearch(query: string): void {
|
|
92
|
+
searchQuery = query
|
|
93
|
+
filteredItems = applyFilter(query)
|
|
94
|
+
selectedIndex = 0
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function doSelect(index?: number): CommandItemData | undefined {
|
|
98
|
+
const idx = index ?? selectedIndex
|
|
99
|
+
const item = filteredItems[idx]
|
|
100
|
+
if (!item || item.disabled) return undefined
|
|
101
|
+
return item
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const keyboardHandlers: KeyboardHandlerMap = {
|
|
105
|
+
[Keys.ArrowDown]: (e) => {
|
|
106
|
+
e.preventDefault()
|
|
107
|
+
if (filteredItems.length > 0) {
|
|
108
|
+
selectedIndex = (selectedIndex + 1) % filteredItems.length
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
[Keys.ArrowUp]: (e) => {
|
|
112
|
+
e.preventDefault()
|
|
113
|
+
if (filteredItems.length > 0) {
|
|
114
|
+
selectedIndex = (selectedIndex - 1 + filteredItems.length) % filteredItems.length
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
[Keys.Enter]: (e) => {
|
|
118
|
+
e.preventDefault()
|
|
119
|
+
doSelect()
|
|
120
|
+
},
|
|
121
|
+
[Keys.Escape]: (e) => {
|
|
122
|
+
e.preventDefault()
|
|
123
|
+
onOpenChange?.(false)
|
|
124
|
+
},
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const ariaProps: Record<string, unknown> = {
|
|
128
|
+
role: 'combobox',
|
|
129
|
+
'aria-expanded': isOpen,
|
|
130
|
+
'aria-haspopup': 'listbox',
|
|
131
|
+
'aria-owns': listId,
|
|
132
|
+
id: rootId,
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const inputAriaProps: Record<string, unknown> = {
|
|
136
|
+
role: 'searchbox',
|
|
137
|
+
'aria-autocomplete': 'list',
|
|
138
|
+
'aria-controls': listId,
|
|
139
|
+
id: inputId,
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const listAriaProps: Record<string, unknown> = {
|
|
143
|
+
role: 'listbox',
|
|
144
|
+
id: listId,
|
|
145
|
+
'aria-label': 'Command suggestions',
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function getItemAriaProps(item: CommandItemData, index: number): Record<string, unknown> {
|
|
149
|
+
return {
|
|
150
|
+
role: 'option',
|
|
151
|
+
'aria-selected': index === selectedIndex,
|
|
152
|
+
'aria-disabled': item.disabled ?? false,
|
|
153
|
+
id: `${listId}-item-${item.id}`,
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return {
|
|
158
|
+
get state(): CommandState {
|
|
159
|
+
return {
|
|
160
|
+
search: searchQuery,
|
|
161
|
+
filteredItems,
|
|
162
|
+
selectedIndex,
|
|
163
|
+
open: isOpen,
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
search: doSearch,
|
|
167
|
+
select: doSelect,
|
|
168
|
+
keyboardHandlers,
|
|
169
|
+
ariaProps,
|
|
170
|
+
inputAriaProps,
|
|
171
|
+
listAriaProps,
|
|
172
|
+
getItemAriaProps,
|
|
173
|
+
ids: {
|
|
174
|
+
root: rootId,
|
|
175
|
+
input: inputId,
|
|
176
|
+
list: listId,
|
|
177
|
+
},
|
|
178
|
+
}
|
|
179
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export {
|
|
2
|
+
createCommand,
|
|
3
|
+
type CommandProps,
|
|
4
|
+
type CommandItemData,
|
|
5
|
+
type CommandState,
|
|
6
|
+
type CommandAPI,
|
|
7
|
+
} from './command.js'
|
|
8
|
+
|
|
9
|
+
export {
|
|
10
|
+
commandVariants,
|
|
11
|
+
commandInputVariants,
|
|
12
|
+
commandItemVariants,
|
|
13
|
+
commandGroupVariants,
|
|
14
|
+
} from './command.styles.js'
|