@shavin/ui 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +94 -0
- package/LICENSE +21 -0
- package/README.md +81 -2
- package/components.json +15771 -0
- package/dist/authoring/types.js +0 -0
- package/dist/icons.d.ts +20 -0
- package/dist/icons.js +6 -0
- package/dist/index.d.ts +3325 -0
- package/dist/index.js +531 -0
- package/dist/inspector/FindingPopover.js +252 -0
- package/dist/inspector/Highlight.js +76 -0
- package/dist/inspector/Inspector.js +420 -0
- package/dist/inspector/InspectorRoot.js +75 -0
- package/dist/inspector/IssuesLayer.js +134 -0
- package/dist/inspector/IssuesList.js +174 -0
- package/dist/inspector/SettingsPanel.js +89 -0
- package/dist/inspector/ShavinMark.js +22 -0
- package/dist/inspector/Toolbar.js +202 -0
- package/dist/inspector/barPlacement.js +117 -0
- package/dist/inspector/env.js +59 -0
- package/dist/inspector/geometry.js +44 -0
- package/dist/inspector/ignored.js +52 -0
- package/dist/inspector/index.js +7 -0
- package/dist/inspector/journalClient.js +57 -0
- package/dist/inspector/journalState.js +36 -0
- package/dist/inspector/pin.js +43 -0
- package/dist/inspector/placement.js +96 -0
- package/dist/inspector/prompt.js +63 -0
- package/dist/inspector/scheme.js +56 -0
- package/dist/inspector/settings.js +54 -0
- package/dist/inspector/strings.js +67 -0
- package/dist/inspector/targets.js +31 -0
- package/dist/inspector/theme/ThemeControls.js +351 -0
- package/dist/inspector/theme/ThemePanel.js +32 -0
- package/dist/inspector/theme/useThemeController.js +560 -0
- package/dist/inspector/usePhone.js +32 -0
- package/dist/inspector/useSelectTool.js +82 -0
- package/dist/inspector/useTimeouts.js +22 -0
- package/dist/inspector/useTrackedRect.js +39 -0
- package/dist/lib/announce.js +47 -0
- package/dist/lib/bridge.js +43 -0
- package/dist/lib/buttonState.js +81 -0
- package/dist/lib/chart-kit.js +226 -0
- package/dist/lib/cn.js +8 -0
- package/dist/lib/color-space.js +315 -0
- package/dist/lib/concentric.js +85 -0
- package/dist/lib/hit-area.js +25 -0
- package/dist/lib/inspector/collect.js +299 -0
- package/dist/lib/inspector/color.js +58 -0
- package/dist/lib/inspector/console-capture.js +96 -0
- package/dist/lib/inspector/index.js +8 -0
- package/dist/lib/inspector/rules.js +232 -0
- package/dist/lib/inspector/run.js +35 -0
- package/dist/lib/inspector/schema.js +110 -0
- package/dist/lib/inspector/selector.js +103 -0
- package/dist/lib/inspector/tokens.js +34 -0
- package/dist/lib/media-overlay-presets.js +284 -0
- package/dist/lib/media-overlays.js +381 -0
- package/dist/lib/meta.js +70 -0
- package/dist/lib/motion-gsap.js +25 -0
- package/dist/lib/motion-runtime.js +283 -0
- package/dist/lib/neutral-tint.js +108 -0
- package/dist/lib/portal-container.js +12 -0
- package/dist/lib/scroll-edges.js +41 -0
- package/dist/lib/surface.js +6 -0
- package/dist/lib/syntax.js +115 -0
- package/dist/lib/theme-presets.d.ts +1 -0
- package/dist/lib/theme-presets.js +759 -0
- package/dist/lib/useClientLocale.js +11 -0
- package/dist/lib/useFieldErrorAnnouncement.js +15 -0
- package/dist/lib/useReducedMotion.js +17 -0
- package/dist/lib/useResizable.js +313 -0
- package/dist/lib/useReturnFocus.js +24 -0
- package/dist/lib/useSlidingIndicator.js +56 -0
- package/dist/panels.d.ts +37 -0
- package/dist/panels.js +19 -0
- package/dist/primitives/Accordion/Accordion.doc.js +37 -0
- package/dist/primitives/Accordion/Accordion.js +87 -0
- package/dist/primitives/Accordion/index.js +2 -0
- package/dist/primitives/ActionBar/ActionBar.doc.js +37 -0
- package/dist/primitives/ActionBar/ActionBar.js +126 -0
- package/dist/primitives/ActionBar/index.js +2 -0
- package/dist/primitives/AlertDialog/AlertDialog.doc.js +54 -0
- package/dist/primitives/AlertDialog/AlertDialog.js +113 -0
- package/dist/primitives/AlertDialog/index.js +2 -0
- package/dist/primitives/AppShell/AppShell.doc.js +81 -0
- package/dist/primitives/AppShell/AppShell.js +178 -0
- package/dist/primitives/AppShell/frame-context.js +10 -0
- package/dist/primitives/AppShell/index.js +2 -0
- package/dist/primitives/AspectRatio/AspectRatio.doc.js +34 -0
- package/dist/primitives/AspectRatio/AspectRatio.js +5 -0
- package/dist/primitives/AspectRatio/index.js +2 -0
- package/dist/primitives/Avatar/Avatar.doc.js +40 -0
- package/dist/primitives/Avatar/Avatar.js +62 -0
- package/dist/primitives/Avatar/index.js +2 -0
- package/dist/primitives/Backdrop/Backdrop.doc.js +24 -0
- package/dist/primitives/Backdrop/Backdrop.js +42 -0
- package/dist/primitives/Backdrop/index.js +2 -0
- package/dist/primitives/Badge/Badge.doc.js +35 -0
- package/dist/primitives/Badge/Badge.js +95 -0
- package/dist/primitives/Badge/index.js +2 -0
- package/dist/primitives/BarChart/BarChart.doc.js +59 -0
- package/dist/primitives/BarChart/BarChart.js +154 -0
- package/dist/primitives/BarChart/index.js +2 -0
- package/dist/primitives/BlockPreview/BlockPreview.doc.js +51 -0
- package/dist/primitives/BlockPreview/BlockPreview.js +485 -0
- package/dist/primitives/BlockPreview/index.js +8 -0
- package/dist/primitives/Blockquote/Blockquote.doc.js +25 -0
- package/dist/primitives/Blockquote/Blockquote.js +19 -0
- package/dist/primitives/Blockquote/index.js +2 -0
- package/dist/primitives/BottomNav/BottomNav.doc.js +37 -0
- package/dist/primitives/BottomNav/BottomNav.js +54 -0
- package/dist/primitives/BottomNav/index.js +2 -0
- package/dist/primitives/Box/Box.doc.js +45 -0
- package/dist/primitives/Box/Box.js +51 -0
- package/dist/primitives/Box/index.js +2 -0
- package/dist/primitives/Breadcrumbs/Breadcrumbs.doc.js +35 -0
- package/dist/primitives/Breadcrumbs/Breadcrumbs.js +40 -0
- package/dist/primitives/Breadcrumbs/index.js +2 -0
- package/dist/primitives/Button/Button.doc.js +80 -0
- package/dist/primitives/Button/Button.js +132 -0
- package/dist/primitives/Button/index.js +2 -0
- package/dist/primitives/Calendar/Calendar.doc.js +36 -0
- package/dist/primitives/Calendar/Calendar.js +502 -0
- package/dist/primitives/Calendar/index.js +2 -0
- package/dist/primitives/Callout/Callout.doc.js +34 -0
- package/dist/primitives/Callout/Callout.js +63 -0
- package/dist/primitives/Callout/index.js +2 -0
- package/dist/primitives/Card/Card.doc.js +46 -0
- package/dist/primitives/Card/Card.js +159 -0
- package/dist/primitives/Card/index.js +2 -0
- package/dist/primitives/Carousel/Carousel.doc.js +61 -0
- package/dist/primitives/Carousel/Carousel.js +369 -0
- package/dist/primitives/Carousel/index.js +1 -0
- package/dist/primitives/ChatBubble/ChatBubble.doc.js +37 -0
- package/dist/primitives/ChatBubble/ChatBubble.js +120 -0
- package/dist/primitives/ChatBubble/index.js +2 -0
- package/dist/primitives/Checkbox/Checkbox.doc.js +36 -0
- package/dist/primitives/Checkbox/Checkbox.js +57 -0
- package/dist/primitives/Checkbox/index.js +2 -0
- package/dist/primitives/CheckboxCards/CheckboxCards.doc.js +35 -0
- package/dist/primitives/CheckboxCards/CheckboxCards.js +47 -0
- package/dist/primitives/CheckboxCards/index.js +2 -0
- package/dist/primitives/CheckboxGroup/CheckboxGroup.doc.js +35 -0
- package/dist/primitives/CheckboxGroup/CheckboxGroup.js +40 -0
- package/dist/primitives/CheckboxGroup/index.js +2 -0
- package/dist/primitives/Code/Code.doc.js +22 -0
- package/dist/primitives/Code/Code.js +17 -0
- package/dist/primitives/Code/index.js +2 -0
- package/dist/primitives/CodeBlock/CodeBlock.doc.js +36 -0
- package/dist/primitives/CodeBlock/CodeBlock.js +205 -0
- package/dist/primitives/CodeBlock/index.js +2 -0
- package/dist/primitives/CodeEditor/CodeEditor.doc.js +53 -0
- package/dist/primitives/CodeEditor/CodeEditor.js +204 -0
- package/dist/primitives/CodeEditor/index.js +4 -0
- package/dist/primitives/ColorPicker/ColorPicker.doc.js +37 -0
- package/dist/primitives/ColorPicker/ColorPicker.js +776 -0
- package/dist/primitives/ColorPicker/index.js +2 -0
- package/dist/primitives/Combobox/Combobox.doc.js +36 -0
- package/dist/primitives/Combobox/Combobox.js +199 -0
- package/dist/primitives/Combobox/index.js +2 -0
- package/dist/primitives/Container/Container.doc.js +46 -0
- package/dist/primitives/Container/Container.js +54 -0
- package/dist/primitives/Container/index.js +2 -0
- package/dist/primitives/ContextMenu/ContextMenu.doc.js +36 -0
- package/dist/primitives/ContextMenu/ContextMenu.js +59 -0
- package/dist/primitives/ContextMenu/index.js +2 -0
- package/dist/primitives/DataList/DataList.doc.js +34 -0
- package/dist/primitives/DataList/DataList.js +35 -0
- package/dist/primitives/DataList/index.js +2 -0
- package/dist/primitives/DatePicker/DatePicker.doc.js +36 -0
- package/dist/primitives/DatePicker/DatePicker.js +398 -0
- package/dist/primitives/DatePicker/index.js +2 -0
- package/dist/primitives/Dialog/Dialog.doc.js +107 -0
- package/dist/primitives/Dialog/Dialog.js +143 -0
- package/dist/primitives/Dialog/index.js +2 -0
- package/dist/primitives/DonutChart/DonutChart.doc.js +26 -0
- package/dist/primitives/DonutChart/DonutChart.js +71 -0
- package/dist/primitives/DonutChart/index.js +2 -0
- package/dist/primitives/Drawer/Drawer.doc.js +44 -0
- package/dist/primitives/Drawer/Drawer.js +158 -0
- package/dist/primitives/Drawer/index.js +2 -0
- package/dist/primitives/Dropdown/Dropdown.doc.js +40 -0
- package/dist/primitives/Dropdown/Dropdown.js +146 -0
- package/dist/primitives/Dropdown/index.js +2 -0
- package/dist/primitives/Emphasis/Emphasis.doc.js +28 -0
- package/dist/primitives/Emphasis/Emphasis.js +25 -0
- package/dist/primitives/Emphasis/index.js +2 -0
- package/dist/primitives/EmptyState/EmptyState.doc.js +76 -0
- package/dist/primitives/EmptyState/EmptyState.js +118 -0
- package/dist/primitives/EmptyState/index.js +2 -0
- package/dist/primitives/FileOutput/FileOutput.doc.js +26 -0
- package/dist/primitives/FileOutput/FileOutput.js +55 -0
- package/dist/primitives/FileOutput/index.js +2 -0
- package/dist/primitives/Flex/Flex.doc.js +58 -0
- package/dist/primitives/Flex/Flex.js +98 -0
- package/dist/primitives/Flex/index.js +2 -0
- package/dist/primitives/FormErrorSummary/FormErrorSummary.doc.js +39 -0
- package/dist/primitives/FormErrorSummary/FormErrorSummary.js +61 -0
- package/dist/primitives/FormErrorSummary/index.js +2 -0
- package/dist/primitives/FormField/FormField.doc.js +68 -0
- package/dist/primitives/FormField/FormField.js +149 -0
- package/dist/primitives/FormField/index.js +2 -0
- package/dist/primitives/FunnelChart/FunnelChart.doc.js +45 -0
- package/dist/primitives/FunnelChart/FunnelChart.js +54 -0
- package/dist/primitives/FunnelChart/index.js +2 -0
- package/dist/primitives/Grid/Grid.doc.js +57 -0
- package/dist/primitives/Grid/Grid.js +122 -0
- package/dist/primitives/Grid/index.js +2 -0
- package/dist/primitives/Heading/Heading.doc.js +46 -0
- package/dist/primitives/Heading/Heading.js +80 -0
- package/dist/primitives/Heading/index.js +2 -0
- package/dist/primitives/Heatmap/Heatmap.doc.js +49 -0
- package/dist/primitives/Heatmap/Heatmap.js +42 -0
- package/dist/primitives/Heatmap/index.js +2 -0
- package/dist/primitives/HoverCard/HoverCard.doc.js +36 -0
- package/dist/primitives/HoverCard/HoverCard.js +39 -0
- package/dist/primitives/HoverCard/index.js +2 -0
- package/dist/primitives/Icon/Icon.doc.js +49 -0
- package/dist/primitives/Icon/Icon.js +214 -0
- package/dist/primitives/Icon/buckets/lucide-a.js +214 -0
- package/dist/primitives/Icon/buckets/lucide-b.js +298 -0
- package/dist/primitives/Icon/buckets/lucide-c.js +524 -0
- package/dist/primitives/Icon/buckets/lucide-d.js +110 -0
- package/dist/primitives/Icon/buckets/lucide-e.js +50 -0
- package/dist/primitives/Icon/buckets/lucide-f.js +264 -0
- package/dist/primitives/Icon/buckets/lucide-g.js +108 -0
- package/dist/primitives/Icon/buckets/lucide-h.js +112 -0
- package/dist/primitives/Icon/buckets/lucide-i.js +46 -0
- package/dist/primitives/Icon/buckets/lucide-j.js +6 -0
- package/dist/primitives/Icon/buckets/lucide-k.js +18 -0
- package/dist/primitives/Icon/buckets/lucide-l.js +162 -0
- package/dist/primitives/Icon/buckets/lucide-m.js +266 -0
- package/dist/primitives/Icon/buckets/lucide-n.js +34 -0
- package/dist/primitives/Icon/buckets/lucide-o.js +20 -0
- package/dist/primitives/Icon/buckets/lucide-p.js +216 -0
- package/dist/primitives/Icon/buckets/lucide-q.js +6 -0
- package/dist/primitives/Icon/buckets/lucide-r.js +140 -0
- package/dist/primitives/Icon/buckets/lucide-s.js +490 -0
- package/dist/primitives/Icon/buckets/lucide-t.js +204 -0
- package/dist/primitives/Icon/buckets/lucide-u.js +84 -0
- package/dist/primitives/Icon/buckets/lucide-v.js +46 -0
- package/dist/primitives/Icon/buckets/lucide-w.js +82 -0
- package/dist/primitives/Icon/buckets/lucide-x.js +6 -0
- package/dist/primitives/Icon/buckets/lucide-z.js +36 -0
- package/dist/primitives/Icon/buckets/phosphor-a.js +250 -0
- package/dist/primitives/Icon/buckets/phosphor-b.js +158 -0
- package/dist/primitives/Icon/buckets/phosphor-c.js +320 -0
- package/dist/primitives/Icon/buckets/phosphor-d.js +90 -0
- package/dist/primitives/Icon/buckets/phosphor-e.js +52 -0
- package/dist/primitives/Icon/buckets/phosphor-f.js +162 -0
- package/dist/primitives/Icon/buckets/phosphor-g.js +92 -0
- package/dist/primitives/Icon/buckets/phosphor-h.js +88 -0
- package/dist/primitives/Icon/buckets/phosphor-i.js +26 -0
- package/dist/primitives/Icon/buckets/phosphor-j.js +8 -0
- package/dist/primitives/Icon/buckets/phosphor-k.js +8 -0
- package/dist/primitives/Icon/buckets/phosphor-l.js +84 -0
- package/dist/primitives/Icon/buckets/phosphor-m.js +110 -0
- package/dist/primitives/Icon/buckets/phosphor-n.js +100 -0
- package/dist/primitives/Icon/buckets/phosphor-o.js +14 -0
- package/dist/primitives/Icon/buckets/phosphor-p.js +166 -0
- package/dist/primitives/Icon/buckets/phosphor-q.js +10 -0
- package/dist/primitives/Icon/buckets/phosphor-r.js +46 -0
- package/dist/primitives/Icon/buckets/phosphor-s.js +254 -0
- package/dist/primitives/Icon/buckets/phosphor-t.js +152 -0
- package/dist/primitives/Icon/buckets/phosphor-u.js +38 -0
- package/dist/primitives/Icon/buckets/phosphor-v.js +22 -0
- package/dist/primitives/Icon/buckets/phosphor-w.js +48 -0
- package/dist/primitives/Icon/buckets/phosphor-x.js +4 -0
- package/dist/primitives/Icon/buckets/phosphor-y.js +8 -0
- package/dist/primitives/Icon/icon-display-names.generated.js +4 -0
- package/dist/primitives/Icon/icon-loaders.generated.js +70 -0
- package/dist/primitives/Icon/icon-names-material.generated.js +4 -0
- package/dist/primitives/Icon/icon-names.js +11 -0
- package/dist/primitives/Icon/index.js +7 -0
- package/dist/primitives/IconButton/IconButton.doc.js +43 -0
- package/dist/primitives/IconButton/IconButton.js +98 -0
- package/dist/primitives/IconButton/index.js +2 -0
- package/dist/primitives/IconPicker/IconPicker.doc.js +52 -0
- package/dist/primitives/IconPicker/IconPicker.js +193 -0
- package/dist/primitives/IconPicker/index.js +2 -0
- package/dist/primitives/IconPicker/registry.js +98 -0
- package/dist/primitives/Image/Image.doc.js +40 -0
- package/dist/primitives/Image/Image.js +76 -0
- package/dist/primitives/Image/index.js +2 -0
- package/dist/primitives/Inset/Inset.doc.js +34 -0
- package/dist/primitives/Inset/Inset.js +51 -0
- package/dist/primitives/Inset/index.js +2 -0
- package/dist/primitives/Kbd/Kbd.doc.js +22 -0
- package/dist/primitives/Kbd/Kbd.js +17 -0
- package/dist/primitives/Kbd/index.js +2 -0
- package/dist/primitives/LineChart/LineChart.doc.js +61 -0
- package/dist/primitives/LineChart/LineChart.js +146 -0
- package/dist/primitives/LineChart/index.js +2 -0
- package/dist/primitives/Link/Link.doc.js +45 -0
- package/dist/primitives/Link/Link.js +37 -0
- package/dist/primitives/Link/index.js +2 -0
- package/dist/primitives/List/List.doc.js +35 -0
- package/dist/primitives/List/List.js +35 -0
- package/dist/primitives/List/index.js +2 -0
- package/dist/primitives/Menu/Menu.doc.js +37 -0
- package/dist/primitives/Menu/Menu.js +117 -0
- package/dist/primitives/Menu/index.js +2 -0
- package/dist/primitives/Murmur/Murmur.doc.js +32 -0
- package/dist/primitives/Murmur/Murmur.js +85 -0
- package/dist/primitives/Murmur/engine.js +163 -0
- package/dist/primitives/Murmur/index.js +12 -0
- package/dist/primitives/Pagination/Pagination.doc.js +37 -0
- package/dist/primitives/Pagination/Pagination.js +183 -0
- package/dist/primitives/Pagination/index.js +2 -0
- package/dist/primitives/PanelGroup/PanelGroup.doc.js +41 -0
- package/dist/primitives/PanelGroup/PanelGroup.js +142 -0
- package/dist/primitives/PanelGroup/index.js +2 -0
- package/dist/primitives/Popover/Popover.doc.js +36 -0
- package/dist/primitives/Popover/Popover.js +41 -0
- package/dist/primitives/Popover/index.js +2 -0
- package/dist/primitives/Progress/Progress.doc.js +35 -0
- package/dist/primitives/Progress/Progress.js +77 -0
- package/dist/primitives/Progress/index.js +2 -0
- package/dist/primitives/RadioGroup/RadioGroup.doc.js +36 -0
- package/dist/primitives/RadioGroup/RadioGroup.js +132 -0
- package/dist/primitives/RadioGroup/index.js +2 -0
- package/dist/primitives/Rating/NpsScale.js +102 -0
- package/dist/primitives/Rating/Rating.doc.js +35 -0
- package/dist/primitives/Rating/Rating.js +116 -0
- package/dist/primitives/Rating/RatingSummary.js +50 -0
- package/dist/primitives/Rating/SentimentRating.js +81 -0
- package/dist/primitives/Rating/index.js +5 -0
- package/dist/primitives/Reasoning/Reasoning.doc.js +28 -0
- package/dist/primitives/Reasoning/Reasoning.js +73 -0
- package/dist/primitives/Reasoning/index.js +2 -0
- package/dist/primitives/Resizable/Resizable.doc.js +50 -0
- package/dist/primitives/Resizable/ResizeHandle.js +185 -0
- package/dist/primitives/Resizable/index.js +2 -0
- package/dist/primitives/Row/Row.doc.js +36 -0
- package/dist/primitives/Row/Row.js +53 -0
- package/dist/primitives/Row/index.js +2 -0
- package/dist/primitives/ScrollArea/ScrollArea.doc.js +35 -0
- package/dist/primitives/ScrollArea/ScrollArea.js +50 -0
- package/dist/primitives/ScrollArea/index.js +2 -0
- package/dist/primitives/Section/Section.doc.js +64 -0
- package/dist/primitives/Section/Section.js +76 -0
- package/dist/primitives/Section/index.js +2 -0
- package/dist/primitives/SegmentedControl/SegmentedControl.doc.js +75 -0
- package/dist/primitives/SegmentedControl/SegmentedControl.js +160 -0
- package/dist/primitives/SegmentedControl/index.js +2 -0
- package/dist/primitives/Select/Select.doc.js +42 -0
- package/dist/primitives/Select/Select.js +180 -0
- package/dist/primitives/Select/index.js +2 -0
- package/dist/primitives/Separator/Separator.doc.js +34 -0
- package/dist/primitives/Separator/Separator.js +84 -0
- package/dist/primitives/Separator/index.js +2 -0
- package/dist/primitives/ShavinDevTools/DevToolsPanel.js +2050 -0
- package/dist/primitives/ShavinDevTools/ShavinDevTools.doc.js +44 -0
- package/dist/primitives/ShavinDevTools/ShavinDevTools.js +15 -0
- package/dist/primitives/ShavinDevTools/index.js +8 -0
- package/dist/primitives/ShavinDevTools/types.js +0 -0
- package/dist/primitives/Sidebar/Sidebar.doc.js +39 -0
- package/dist/primitives/Sidebar/Sidebar.js +295 -0
- package/dist/primitives/Sidebar/index.js +2 -0
- package/dist/primitives/Skeleton/Skeleton.doc.js +38 -0
- package/dist/primitives/Skeleton/Skeleton.js +36 -0
- package/dist/primitives/Skeleton/index.js +2 -0
- package/dist/primitives/Slider/Slider.doc.js +45 -0
- package/dist/primitives/Slider/Slider.js +406 -0
- package/dist/primitives/Slider/index.js +2 -0
- package/dist/primitives/Sortable/Sortable.doc.js +35 -0
- package/dist/primitives/Sortable/Sortable.js +179 -0
- package/dist/primitives/Sortable/index.js +2 -0
- package/dist/primitives/Sparkline/Sparkline.doc.js +25 -0
- package/dist/primitives/Sparkline/Sparkline.js +46 -0
- package/dist/primitives/Sparkline/index.js +2 -0
- package/dist/primitives/Spinner/Spinner.doc.js +35 -0
- package/dist/primitives/Spinner/Spinner.js +162 -0
- package/dist/primitives/Spinner/index.js +2 -0
- package/dist/primitives/Spotlight/Spotlight.doc.js +36 -0
- package/dist/primitives/Spotlight/Spotlight.js +139 -0
- package/dist/primitives/Spotlight/index.js +2 -0
- package/dist/primitives/Stepper/Stepper.doc.js +46 -0
- package/dist/primitives/Stepper/Stepper.js +235 -0
- package/dist/primitives/Stepper/index.js +2 -0
- package/dist/primitives/Switch/Switch.doc.js +36 -0
- package/dist/primitives/Switch/Switch.js +54 -0
- package/dist/primitives/Switch/index.js +2 -0
- package/dist/primitives/Table/Table.doc.js +47 -0
- package/dist/primitives/Table/Table.js +63 -0
- package/dist/primitives/Table/index.js +2 -0
- package/dist/primitives/Tabs/Tabs.doc.js +53 -0
- package/dist/primitives/Tabs/Tabs.js +275 -0
- package/dist/primitives/Tabs/index.js +2 -0
- package/dist/primitives/Text/Text.doc.js +35 -0
- package/dist/primitives/Text/Text.js +67 -0
- package/dist/primitives/Text/index.js +2 -0
- package/dist/primitives/TextArea/TextArea.doc.js +35 -0
- package/dist/primitives/TextArea/TextArea.js +45 -0
- package/dist/primitives/TextArea/index.js +2 -0
- package/dist/primitives/TextField/TextField.doc.js +41 -0
- package/dist/primitives/TextField/TextField.js +290 -0
- package/dist/primitives/TextField/index.js +2 -0
- package/dist/primitives/ThemeProvider/ScopedThemeProvider.js +71 -0
- package/dist/primitives/ThemeProvider/ThemeProvider.doc.js +61 -0
- package/dist/primitives/ThemeProvider/ThemeProvider.js +143 -0
- package/dist/primitives/ThemeProvider/clientTheme.js +47 -0
- package/dist/primitives/ThemeProvider/index.js +3 -0
- package/dist/primitives/ThemeProvider/themeContext.js +11 -0
- package/dist/primitives/ThemeSwitcher/ThemeSwitcher.doc.js +49 -0
- package/dist/primitives/ThemeSwitcher/ThemeSwitcher.js +323 -0
- package/dist/primitives/ThemeSwitcher/index.js +2 -0
- package/dist/primitives/TimePicker/TimePicker.doc.js +36 -0
- package/dist/primitives/TimePicker/TimePicker.js +368 -0
- package/dist/primitives/TimePicker/index.js +2 -0
- package/dist/primitives/Toast/Toast.doc.js +65 -0
- package/dist/primitives/Toast/Toast.js +304 -0
- package/dist/primitives/Toast/index.js +2 -0
- package/dist/primitives/ToolCall/ToolCall.doc.js +29 -0
- package/dist/primitives/ToolCall/ToolCall.js +75 -0
- package/dist/primitives/ToolCall/index.js +2 -0
- package/dist/primitives/Tooltip/Tooltip.doc.js +37 -0
- package/dist/primitives/Tooltip/Tooltip.js +55 -0
- package/dist/primitives/Tooltip/index.js +2 -0
- package/dist/primitives/TopBar/TopBar.doc.js +34 -0
- package/dist/primitives/TopBar/TopBar.js +8 -0
- package/dist/primitives/TopBar/index.js +2 -0
- package/dist/primitives/Video/PauseToggle.js +49 -0
- package/dist/primitives/Video/Video.doc.js +47 -0
- package/dist/primitives/Video/Video.js +104 -0
- package/dist/primitives/Video/index.js +1 -0
- package/dist/primitives/VoiceInput/VoiceInput.doc.js +38 -0
- package/dist/primitives/VoiceInput/VoiceInput.js +96 -0
- package/dist/primitives/VoiceInput/index.js +2 -0
- package/dist/primitives/WiseOwlLogo/WiseOwlLogo.doc.js +38 -0
- package/dist/primitives/WiseOwlLogo/WiseOwlLogo.js +82 -0
- package/dist/primitives/WiseOwlLogo/index.js +2 -0
- package/dist/primitives/WiseOwlLogo/paths.js +10 -0
- package/dist/server.d.ts +256 -0
- package/dist/server.js +22 -0
- package/dist/styles/base-oklch.css +124 -0
- package/dist/styles/base-oklch.d.ts +2 -0
- package/dist/styles/base.css +124 -0
- package/dist/styles/base.d.ts +2 -0
- package/dist/styles/brand-preset.d.ts +22 -0
- package/dist/styles/brand-preset.js +13 -0
- package/dist/styles/brand-theme-v4-oklch.css +2 -0
- package/dist/styles/brand-theme-v4-oklch.d.ts +2 -0
- package/dist/styles/brand-theme-v4.css +2 -0
- package/dist/styles/brand-theme-v4.d.ts +2 -0
- package/dist/styles/brand-tokens-oklch.css +6 -0
- package/dist/styles/brand-tokens-oklch.d.ts +2 -0
- package/dist/styles/brand-tokens.css +6 -0
- package/dist/styles/brand-tokens.d.ts +2 -0
- package/dist/styles/global-oklch.css +1329 -0
- package/dist/styles/global-oklch.d.ts +2 -0
- package/dist/styles/global.css +1329 -0
- package/dist/styles/global.d.ts +2 -0
- package/dist/styles/theme-v4-oklch.css +22 -0
- package/dist/styles/theme-v4-oklch.d.ts +2 -0
- package/dist/styles/theme-v4.css +22 -0
- package/dist/styles/theme-v4.d.ts +2 -0
- package/dist/styles/tokens-oklch.css +1204 -0
- package/dist/styles/tokens-oklch.d.ts +2 -0
- package/dist/styles/tokens.css +1204 -0
- package/dist/styles/tokens.d.ts +2 -0
- package/dist/tailwind-preset.cjs +155 -0
- package/dist/tailwind-preset.d.ts +112 -0
- package/dist/tailwind-preset.js +133 -0
- package/dist/theme-presets-BVWZ_TxX.d.ts +514 -0
- package/global-oklch.css +3 -0
- package/package.json +169 -4
- package/styles.css +3 -0
- package/tailwind-preset.ts +140 -0
- package/tokens.json +423 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { ChevronDown, ChevronRight } from "lucide-react";
|
|
5
|
+
import { Row } from "../primitives/Row/index.js";
|
|
6
|
+
import { Button } from "../primitives/Button/index.js";
|
|
7
|
+
import { SegmentedControl, SegmentedControlItem } from "../primitives/SegmentedControl/index.js";
|
|
8
|
+
import { cn } from "../lib/cn.js";
|
|
9
|
+
import { STR } from "./strings.js";
|
|
10
|
+
import { elementLabel, rowText } from "./targets.js";
|
|
11
|
+
import { ruleTitle } from "./strings.js";
|
|
12
|
+
const GROUP_ABOVE = 10;
|
|
13
|
+
function dotClass(f, isIgnored) {
|
|
14
|
+
if (isIgnored) return "bg-fg-subtle/60";
|
|
15
|
+
return f.severity === "error" ? "bg-danger" : "border-[1.5px] border-warning";
|
|
16
|
+
}
|
|
17
|
+
function IssuesList({ findings, ignored, selectedId, onActive, onOpen, onUndo, canUndo, strip, rowState, errorsToSend = 0, onSendErrors, style, touch = false }) {
|
|
18
|
+
const [filter, setFilter] = React.useState("all");
|
|
19
|
+
const active = findings.filter((f) => !ignored.has(f.id));
|
|
20
|
+
const gray = findings.filter((f) => ignored.has(f.id));
|
|
21
|
+
const errors = active.filter((f) => f.severity === "error");
|
|
22
|
+
const warnings = active.filter((f) => f.severity === "warning");
|
|
23
|
+
const shown = filter === "errors" ? errors : filter === "warnings" ? warnings : filter === "ignored" ? gray : [...active, ...gray];
|
|
24
|
+
const groups = React.useMemo(() => {
|
|
25
|
+
if (shown.length <= GROUP_ABOVE || filter === "ignored") return null;
|
|
26
|
+
const map = /* @__PURE__ */ new Map();
|
|
27
|
+
for (const f of shown) {
|
|
28
|
+
const key = ruleTitle(f.rule, f.message);
|
|
29
|
+
map.set(key, [...map.get(key) ?? [], f]);
|
|
30
|
+
}
|
|
31
|
+
return [...map.entries()].map(([rule, list]) => ({
|
|
32
|
+
rule,
|
|
33
|
+
// Ignored rows sort to the end of their group; counts never include them.
|
|
34
|
+
list: [...list.filter((f) => !ignored.has(f.id)), ...list.filter((f) => ignored.has(f.id))],
|
|
35
|
+
count: list.filter((f) => !ignored.has(f.id)).length
|
|
36
|
+
}));
|
|
37
|
+
}, [shown, filter, ignored]);
|
|
38
|
+
const [openGroups, setOpenGroups] = React.useState({});
|
|
39
|
+
const isOpen = (title, index) => openGroups[title] ?? index === 0;
|
|
40
|
+
const repeated = React.useMemo(() => {
|
|
41
|
+
const seen = /* @__PURE__ */ new Map();
|
|
42
|
+
for (const f of shown) seen.set(f.message, (seen.get(f.message) ?? 0) + 1);
|
|
43
|
+
return new Set([...seen].filter(([, n]) => n > 1).map(([m]) => m));
|
|
44
|
+
}, [shown]);
|
|
45
|
+
const rowLabel = (f) => groups || repeated.has(f.message) ? elementLabel(f) : rowText(f);
|
|
46
|
+
const listRef = React.useRef(null);
|
|
47
|
+
const [focusId, setFocusId] = React.useState(null);
|
|
48
|
+
const flat = groups ? groups.flatMap((g) => g.list) : shown;
|
|
49
|
+
const currentId = focusId && flat.some((f) => f.id === focusId) ? focusId : flat[0]?.id ?? null;
|
|
50
|
+
const onKeyDown = (e) => {
|
|
51
|
+
const i = flat.findIndex((f) => f.id === currentId);
|
|
52
|
+
const go = (n) => {
|
|
53
|
+
const next = flat[Math.max(0, Math.min(flat.length - 1, n))];
|
|
54
|
+
if (!next) return;
|
|
55
|
+
setFocusId(next.id);
|
|
56
|
+
onActive(next.id);
|
|
57
|
+
listRef.current?.querySelector(`[data-finding="${next.id}"]`)?.focus();
|
|
58
|
+
};
|
|
59
|
+
if (e.key === "ArrowDown") {
|
|
60
|
+
e.preventDefault();
|
|
61
|
+
go(i + 1);
|
|
62
|
+
} else if (e.key === "ArrowUp") {
|
|
63
|
+
e.preventDefault();
|
|
64
|
+
go(i - 1);
|
|
65
|
+
} else if (e.key === "Home") {
|
|
66
|
+
e.preventDefault();
|
|
67
|
+
go(0);
|
|
68
|
+
} else if (e.key === "End") {
|
|
69
|
+
e.preventDefault();
|
|
70
|
+
go(flat.length - 1);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
const renderRow = (f) => {
|
|
74
|
+
const isIgnored = ignored.has(f.id);
|
|
75
|
+
const sent = isIgnored ? null : rowState?.(f.id) ?? null;
|
|
76
|
+
return /* @__PURE__ */ jsxs(
|
|
77
|
+
Row,
|
|
78
|
+
{
|
|
79
|
+
as: "div",
|
|
80
|
+
role: "option",
|
|
81
|
+
"aria-selected": selectedId === f.id,
|
|
82
|
+
"data-finding": f.id,
|
|
83
|
+
tabIndex: f.id === currentId ? 0 : -1,
|
|
84
|
+
active: selectedId === f.id,
|
|
85
|
+
title: `${f.message} (${f.selector})`,
|
|
86
|
+
leading: /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: cn("h-2 w-2 rounded-full", dotClass(f, isIgnored)) }),
|
|
87
|
+
className: cn("cursor-pointer rounded-[var(--radius-panel-p2,var(--radius-lg))] py-1.5 [&_.truncate]:overflow-visible [&_.truncate]:whitespace-normal [&_.truncate]:break-words [&_.truncate]:[text-overflow:clip]", isIgnored && "opacity-60", touch && "min-h-[44px]"),
|
|
88
|
+
onClick: () => onOpen(f.id),
|
|
89
|
+
onMouseEnter: () => onActive(f.id),
|
|
90
|
+
onMouseLeave: () => onActive(null),
|
|
91
|
+
onFocus: () => {
|
|
92
|
+
setFocusId(f.id);
|
|
93
|
+
onActive(f.id);
|
|
94
|
+
},
|
|
95
|
+
onBlur: () => onActive(null),
|
|
96
|
+
onKeyDown: (e) => {
|
|
97
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
98
|
+
e.preventDefault();
|
|
99
|
+
onOpen(f.id);
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
children: [
|
|
103
|
+
/* @__PURE__ */ jsxs("span", { className: "sr-only", children: [
|
|
104
|
+
isIgnored ? "Ignored. " : f.severity === "error" ? "Error. " : "Warning. ",
|
|
105
|
+
groups || repeated.has(f.message) ? `${f.message} ` : ""
|
|
106
|
+
] }),
|
|
107
|
+
rowLabel(f),
|
|
108
|
+
sent ? /* @__PURE__ */ jsx("span", { className: "block break-words text-[11px] text-fg-muted", children: sent.text }) : null
|
|
109
|
+
]
|
|
110
|
+
},
|
|
111
|
+
f.id
|
|
112
|
+
);
|
|
113
|
+
};
|
|
114
|
+
const chip = (value, label) => /* @__PURE__ */ jsx(SegmentedControlItem, { value, label }, value);
|
|
115
|
+
return /* @__PURE__ */ jsxs(
|
|
116
|
+
"section",
|
|
117
|
+
{
|
|
118
|
+
"aria-label": "Findings",
|
|
119
|
+
"data-shavin-list": "",
|
|
120
|
+
className: "flex max-h-full w-80 flex-col rounded-[var(--radius-panel)] border border-hairline bg-elevated p-2 text-fg shadow-panel",
|
|
121
|
+
style: { pointerEvents: "auto", ...style },
|
|
122
|
+
children: [
|
|
123
|
+
/* @__PURE__ */ jsx("div", { className: "pb-2", children: /* @__PURE__ */ jsxs(SegmentedControl, { className: touch ? "[&_[role=radio]]:relative [&_[role=radio]]:before:absolute [&_[role=radio]]:before:inset-x-0 [&_[role=radio]]:before:-inset-y-3 [&_[role=radio]]:before:content-['']" : void 0, size: "sm", variant: "subtle", value: filter, onValueChange: (v) => v && setFilter(v), "aria-label": "Filter findings", children: [
|
|
124
|
+
chip("all", `All ${active.length}`),
|
|
125
|
+
chip("errors", `Errors ${errors.length}`),
|
|
126
|
+
chip("warnings", `Warnings ${warnings.length}`),
|
|
127
|
+
gray.length > 0 ? chip("ignored", `Ignored ${gray.length}`) : null
|
|
128
|
+
] }) }),
|
|
129
|
+
/* @__PURE__ */ jsx("div", { ref: listRef, role: "listbox", "aria-label": "Findings list", onKeyDown, className: "min-h-0 flex-1 overflow-y-auto", children: flat.length === 0 ? /* @__PURE__ */ jsx("p", { className: "px-2.5 py-3 text-fg-muted", children: STR.emptyList }) : groups ? groups.map((g, gi) => /* @__PURE__ */ jsxs(
|
|
130
|
+
"details",
|
|
131
|
+
{
|
|
132
|
+
open: isOpen(g.rule, gi),
|
|
133
|
+
onToggle: (e) => {
|
|
134
|
+
const open = e.currentTarget.open;
|
|
135
|
+
setOpenGroups((prev) => prev[g.rule] === open ? prev : { ...prev, [g.rule]: open });
|
|
136
|
+
},
|
|
137
|
+
className: "pb-1",
|
|
138
|
+
children: [
|
|
139
|
+
/* @__PURE__ */ jsxs("summary", { className: "flex cursor-pointer list-none items-center gap-1.5 rounded-[var(--radius-lg)] px-2 py-1 text-xs text-fg-muted hover:bg-fg/[0.05] [&::-webkit-details-marker]:hidden", children: [
|
|
140
|
+
isOpen(g.rule, gi) ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3.5 w-3.5 shrink-0", strokeWidth: 1.75, "aria-hidden": "true" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3.5 w-3.5 shrink-0", strokeWidth: 1.75, "aria-hidden": "true" }),
|
|
141
|
+
/* @__PURE__ */ jsxs("span", { className: "min-w-0", children: [
|
|
142
|
+
g.rule,
|
|
143
|
+
" \xB7 ",
|
|
144
|
+
g.count
|
|
145
|
+
] })
|
|
146
|
+
] }),
|
|
147
|
+
g.list.map(renderRow)
|
|
148
|
+
]
|
|
149
|
+
},
|
|
150
|
+
g.rule
|
|
151
|
+
)) : shown.map(renderRow) }),
|
|
152
|
+
strip ? /* @__PURE__ */ jsx("p", { className: "mt-1 truncate whitespace-nowrap border-t border-hairline px-2.5 pt-2 text-xs text-fg-muted", role: "status", "data-shavin-strip": "", children: strip }) : null,
|
|
153
|
+
errorsToSend > 0 || gray.length > 0 || canUndo ? /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center justify-between gap-2 border-t border-hairline px-1 pt-2 text-xs text-fg-muted", children: [
|
|
154
|
+
errorsToSend > 0 ? /* @__PURE__ */ jsxs(Button, { variant: "ghost", size: "sm", onClick: onSendErrors, children: [
|
|
155
|
+
"Send ",
|
|
156
|
+
errorsToSend,
|
|
157
|
+
" error",
|
|
158
|
+
errorsToSend === 1 ? "" : "s"
|
|
159
|
+
] }) : /* @__PURE__ */ jsx("span", {}),
|
|
160
|
+
gray.length > 0 || canUndo ? /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1", children: [
|
|
161
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
162
|
+
gray.length,
|
|
163
|
+
" ignored"
|
|
164
|
+
] }),
|
|
165
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "sm", onClick: onUndo, disabled: !canUndo, children: "Undo" })
|
|
166
|
+
] }) : null
|
|
167
|
+
] }) : null
|
|
168
|
+
]
|
|
169
|
+
}
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
export {
|
|
173
|
+
IssuesList
|
|
174
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { ExternalLink, X } from "lucide-react";
|
|
4
|
+
import { Button } from "../primitives/Button/index.js";
|
|
5
|
+
import { IconButton } from "../primitives/IconButton/index.js";
|
|
6
|
+
import { Kbd } from "../primitives/Kbd/index.js";
|
|
7
|
+
import { SegmentedControl, SegmentedControlItem } from "../primitives/SegmentedControl/index.js";
|
|
8
|
+
import { Switch } from "../primitives/Switch/index.js";
|
|
9
|
+
const SHORTCUTS = [
|
|
10
|
+
["V", "Select"],
|
|
11
|
+
["I", "Issues"],
|
|
12
|
+
["T", "Theme"],
|
|
13
|
+
[",", "Settings"],
|
|
14
|
+
["Esc", "Back out one step"],
|
|
15
|
+
["Alt Shift S", "Show or hide the inspector"]
|
|
16
|
+
];
|
|
17
|
+
function SettingsPanel({ settings, onChange, ignoredCount, onClearIgnored, onOpenBridge, onClose, insets, floatStyle }) {
|
|
18
|
+
return /* @__PURE__ */ jsxs(
|
|
19
|
+
"section",
|
|
20
|
+
{
|
|
21
|
+
"aria-label": "Settings",
|
|
22
|
+
"data-shavin-settings-panel": "",
|
|
23
|
+
"data-panel": "",
|
|
24
|
+
className: "flex flex-col overflow-hidden rounded-[var(--radius-panel)] border border-hairline bg-elevated text-fg shadow-panel",
|
|
25
|
+
style: { position: "absolute", right: insets?.right ?? 20, top: insets?.top ?? 20, maxHeight: `calc(100% - ${(insets?.top ?? 20) + (insets?.bottom ?? 20)}px)`, width: 300, pointerEvents: "auto", ...floatStyle },
|
|
26
|
+
children: [
|
|
27
|
+
/* @__PURE__ */ jsxs("header", { className: "flex shrink-0 items-center justify-between gap-2 border-b border-hairline px-4 py-2.5", children: [
|
|
28
|
+
/* @__PURE__ */ jsx("h2", { className: "m-0 text-sm font-semibold tracking-tight text-fg", children: "Settings" }),
|
|
29
|
+
/* @__PURE__ */ jsx(IconButton, { variant: "ghost", size: "sm", "aria-label": "Close Settings", onClick: onClose, children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4", strokeWidth: 1.75, "aria-hidden": "true" }) })
|
|
30
|
+
] }),
|
|
31
|
+
/* @__PURE__ */ jsxs("div", { className: "min-h-0 flex-1 space-y-4 overflow-y-auto p-4", style: { fontSize: 12, lineHeight: 1.5 }, onWheel: (e) => e.stopPropagation(), children: [
|
|
32
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-3", children: [
|
|
33
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
|
|
34
|
+
/* @__PURE__ */ jsx("div", { className: "font-medium text-fg", children: "Single-key shortcuts" }),
|
|
35
|
+
/* @__PURE__ */ jsx("div", { className: "text-[11px] text-fg-muted", children: "V, I, T and comma, while the bar has focus or a tool is on." })
|
|
36
|
+
] }),
|
|
37
|
+
/* @__PURE__ */ jsx(Switch, { size: "sm", "aria-label": "Single-key shortcuts", checked: settings.shortcuts, onCheckedChange: (v) => onChange({ shortcuts: v }) })
|
|
38
|
+
] }),
|
|
39
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-3", children: [
|
|
40
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
|
|
41
|
+
/* @__PURE__ */ jsx("div", { className: "font-medium text-fg", children: "Reduce motion" }),
|
|
42
|
+
/* @__PURE__ */ jsx("div", { className: "text-[11px] text-fg-muted", children: "No animation in the inspector. The system setting is always respected." })
|
|
43
|
+
] }),
|
|
44
|
+
/* @__PURE__ */ jsx(Switch, { size: "sm", "aria-label": "Reduce motion", checked: settings.reduceMotion, onCheckedChange: (v) => onChange({ reduceMotion: v }) })
|
|
45
|
+
] }),
|
|
46
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-3", children: [
|
|
47
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
|
|
48
|
+
/* @__PURE__ */ jsx("div", { className: "font-medium text-fg", children: "Reserve space" }),
|
|
49
|
+
/* @__PURE__ */ jsx("div", { className: "text-[11px] text-fg-muted", children: "Pad the page by the bar's height so the bar never covers content." })
|
|
50
|
+
] }),
|
|
51
|
+
/* @__PURE__ */ jsx(Switch, { size: "sm", "aria-label": "Reserve space", checked: settings.reserveSpace, onCheckedChange: (v) => onChange({ reserveSpace: v }) })
|
|
52
|
+
] }),
|
|
53
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-3", children: [
|
|
54
|
+
/* @__PURE__ */ jsx("div", { className: "font-medium text-fg", children: "Inspector colours" }),
|
|
55
|
+
/* @__PURE__ */ jsxs(SegmentedControl, { size: "sm", variant: "subtle", value: settings.scheme, onValueChange: (v) => v && onChange({ scheme: v }), "aria-label": "Inspector colours", children: [
|
|
56
|
+
/* @__PURE__ */ jsx(SegmentedControlItem, { value: "auto", label: "Auto" }),
|
|
57
|
+
/* @__PURE__ */ jsx(SegmentedControlItem, { value: "light", label: "Light" }),
|
|
58
|
+
/* @__PURE__ */ jsx(SegmentedControlItem, { value: "dark", label: "Dark" })
|
|
59
|
+
] })
|
|
60
|
+
] }),
|
|
61
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-3", children: [
|
|
62
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
|
|
63
|
+
/* @__PURE__ */ jsxs("div", { className: "font-medium text-fg", children: [
|
|
64
|
+
"Ignored findings: ",
|
|
65
|
+
ignoredCount
|
|
66
|
+
] }),
|
|
67
|
+
/* @__PURE__ */ jsx("div", { className: "text-[11px] text-fg-muted", children: "An ignore stops applying when the element's selector or text changes." })
|
|
68
|
+
] }),
|
|
69
|
+
/* @__PURE__ */ jsx(Button, { size: "sm", variant: "outline", disabled: ignoredCount === 0, onClick: onClearIgnored, children: "Clear all" })
|
|
70
|
+
] }),
|
|
71
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
72
|
+
/* @__PURE__ */ jsx("div", { className: "mb-1.5 font-medium text-fg", children: "Shortcuts" }),
|
|
73
|
+
/* @__PURE__ */ jsx("dl", { className: "m-0 space-y-1", children: SHORTCUTS.map(([key, what]) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-3", children: [
|
|
74
|
+
/* @__PURE__ */ jsx("dt", { className: "text-fg-muted", children: what }),
|
|
75
|
+
/* @__PURE__ */ jsx("dd", { className: "m-0 flex gap-1", children: key.split(" ").map((k) => /* @__PURE__ */ jsx(Kbd, { className: k.length > 1 ? "min-w-7 text-center font-sans" : "min-w-6 text-center font-sans", children: k }, k)) })
|
|
76
|
+
] }, what)) })
|
|
77
|
+
] }),
|
|
78
|
+
onOpenBridge ? /* @__PURE__ */ jsxs(Button, { size: "sm", variant: "outline", className: "w-full justify-between", onClick: onOpenBridge, children: [
|
|
79
|
+
"Bridge and MCP panel",
|
|
80
|
+
/* @__PURE__ */ jsx(ExternalLink, { className: "h-3.5 w-3.5", strokeWidth: 1.75, "aria-hidden": "true" })
|
|
81
|
+
] }) : null
|
|
82
|
+
] })
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
export {
|
|
88
|
+
SettingsPanel
|
|
89
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
function ShavinMark({ size = 20, className }) {
|
|
3
|
+
return /* @__PURE__ */ jsxs("svg", { width: size, height: size, viewBox: "0 0 200 200", fill: "none", xmlns: "http://www.w3.org/2000/svg", className, "aria-hidden": "true", focusable: "false", children: [
|
|
4
|
+
/* @__PURE__ */ jsx(
|
|
5
|
+
"path",
|
|
6
|
+
{
|
|
7
|
+
d: "M84.3402 106.157L84.6281 78.6112L84.6281 50.7042L17.2256 50.7042L17.2256 24.6892L182.776 24.6892L163.067 50.7042L108.278 50.7042L108.278 78.6112L107.99 86.4491C107.99 86.4491 98.8581 92.2253 95.1816 95.6855C91.5052 99.1457 84.3402 106.157 84.3402 106.157Z",
|
|
8
|
+
fill: "currentColor"
|
|
9
|
+
}
|
|
10
|
+
),
|
|
11
|
+
/* @__PURE__ */ jsx(
|
|
12
|
+
"path",
|
|
13
|
+
{
|
|
14
|
+
d: "M185.14 136.998C185.14 149.611 181.593 159.15 174.498 165.614C167.245 172.079 156.918 175.311 143.516 175.311L114.348 175.311L134.056 150.715L145.408 150.715C156.129 150.715 161.49 146.221 161.49 137.234C161.49 132.82 160.229 129.509 157.706 127.301C155.026 124.936 150.769 123.754 144.935 123.754C137.998 123.754 131.928 125.331 126.725 128.484C121.364 131.637 114.978 137.471 107.568 145.985C98.1081 156.706 89.5941 164.195 82.0261 168.452C74.3004 172.709 65.6288 174.838 56.0111 174.838C42.9248 174.838 32.8341 171.527 25.7391 164.905C18.4864 158.283 14.8601 148.665 14.8601 136.052C14.8601 123.596 18.4864 114.215 25.7391 107.908C32.8341 101.444 43.0824 98.2119 56.4841 98.2119L63.3426 98.2119L63.3426 122.808L54.8286 122.808C49.1526 122.808 45.0533 123.912 42.5306 126.119C39.8503 128.326 38.5101 131.558 38.5101 135.815C38.5101 144.487 43.7919 148.823 54.3556 148.823C60.3469 148.823 65.9441 147.246 71.1471 144.093C76.3501 140.782 82.6568 134.869 90.0671 126.355C99.5271 115.476 108.12 107.987 115.846 103.888C123.571 99.7886 132.637 97.7389 143.043 97.7389C156.602 97.7389 167.008 101.129 174.261 107.908C181.514 114.53 185.14 124.227 185.14 136.998Z",
|
|
15
|
+
fill: "currentColor"
|
|
16
|
+
}
|
|
17
|
+
)
|
|
18
|
+
] });
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
ShavinMark
|
|
22
|
+
};
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { MousePointer2, Palette, Settings, TriangleAlert } from "lucide-react";
|
|
5
|
+
import { IconButton } from "../primitives/IconButton/index.js";
|
|
6
|
+
import { Tooltip } from "../primitives/Tooltip/index.js";
|
|
7
|
+
import { Kbd } from "../primitives/Kbd/index.js";
|
|
8
|
+
import { cn } from "../lib/cn.js";
|
|
9
|
+
import { ShavinMark } from "./ShavinMark.js";
|
|
10
|
+
import { anchorStyle, isVertical, snapAnchor, stepAnchor } from "./barPlacement.js";
|
|
11
|
+
import { STR, TOOLS } from "./strings.js";
|
|
12
|
+
import { DOCK_H } from "./usePhone.js";
|
|
13
|
+
const ICONS = [
|
|
14
|
+
{ id: "select", icon: MousePointer2 },
|
|
15
|
+
{ id: "issues", icon: TriangleAlert },
|
|
16
|
+
{ id: "theme", icon: Palette },
|
|
17
|
+
{ id: "settings", icon: Settings }
|
|
18
|
+
];
|
|
19
|
+
const DRAG_THRESHOLD = 4;
|
|
20
|
+
const DOCK_STYLE = {
|
|
21
|
+
height: `calc(${DOCK_H}px + env(safe-area-inset-bottom, 0px))`,
|
|
22
|
+
paddingBottom: "env(safe-area-inset-bottom, 0px)",
|
|
23
|
+
// ds-lint-disable-next-line no-unknown-class — a CSS value, not a class
|
|
24
|
+
boxSizing: "border-box"
|
|
25
|
+
};
|
|
26
|
+
function Toolbar({ active, onChange, panels, onPanel, errors, warnings, mode, anchor, onAnchor, collapsed, onCollapsed, onFocusFrom, phone = false }) {
|
|
27
|
+
const refs = React.useRef([]);
|
|
28
|
+
const barRef = React.useRef(null);
|
|
29
|
+
const [focusIndex, setFocusIndex] = React.useState(0);
|
|
30
|
+
const [dragPos, setDragPos] = React.useState(null);
|
|
31
|
+
const justDragged = React.useRef(false);
|
|
32
|
+
const vertical = isVertical(anchor) && !collapsed && !phone;
|
|
33
|
+
const count = errors + warnings;
|
|
34
|
+
const dotClass = errors > 0 ? "bg-danger" : "bg-warning";
|
|
35
|
+
const slots = collapsed ? 1 : 1 + ICONS.length;
|
|
36
|
+
const move = (to) => {
|
|
37
|
+
const next = (to + slots) % slots;
|
|
38
|
+
setFocusIndex(next);
|
|
39
|
+
refs.current[next]?.focus();
|
|
40
|
+
};
|
|
41
|
+
const onKeyDown = (e) => {
|
|
42
|
+
if (e.key === "ArrowRight" || e.key === "ArrowDown") {
|
|
43
|
+
if (e.shiftKey && focusIndex === 0) {
|
|
44
|
+
e.preventDefault();
|
|
45
|
+
onAnchor(stepAnchor(anchor, e.key === "ArrowRight" ? "right" : "down"));
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
e.preventDefault();
|
|
49
|
+
move(focusIndex + 1);
|
|
50
|
+
} else if (e.key === "ArrowLeft" || e.key === "ArrowUp") {
|
|
51
|
+
if (e.shiftKey && focusIndex === 0) {
|
|
52
|
+
e.preventDefault();
|
|
53
|
+
onAnchor(stepAnchor(anchor, e.key === "ArrowLeft" ? "left" : "up"));
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
e.preventDefault();
|
|
57
|
+
move(focusIndex - 1);
|
|
58
|
+
} else if (e.key === "Home") {
|
|
59
|
+
e.preventDefault();
|
|
60
|
+
move(0);
|
|
61
|
+
} else if (e.key === "End") {
|
|
62
|
+
e.preventDefault();
|
|
63
|
+
move(slots - 1);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const onMarkPointerDown = (e) => {
|
|
67
|
+
if (e.button !== 0 || phone) return;
|
|
68
|
+
const bar = barRef.current;
|
|
69
|
+
if (!bar) return;
|
|
70
|
+
const startX = e.clientX;
|
|
71
|
+
const startY = e.clientY;
|
|
72
|
+
const rect = bar.getBoundingClientRect();
|
|
73
|
+
const grabX = startX - rect.left;
|
|
74
|
+
const grabY = startY - rect.top;
|
|
75
|
+
let dragging = false;
|
|
76
|
+
const onMove = (ev) => {
|
|
77
|
+
if (!dragging && Math.hypot(ev.clientX - startX, ev.clientY - startY) < DRAG_THRESHOLD) return;
|
|
78
|
+
dragging = true;
|
|
79
|
+
setDragPos({ left: ev.clientX - grabX, top: ev.clientY - grabY });
|
|
80
|
+
};
|
|
81
|
+
const end = (ev) => {
|
|
82
|
+
window.removeEventListener("pointermove", onMove);
|
|
83
|
+
window.removeEventListener("pointerup", end);
|
|
84
|
+
window.removeEventListener("pointercancel", end);
|
|
85
|
+
if (!dragging) return;
|
|
86
|
+
justDragged.current = true;
|
|
87
|
+
window.setTimeout(() => justDragged.current = false, 0);
|
|
88
|
+
const w = rect.width;
|
|
89
|
+
const h = rect.height;
|
|
90
|
+
const cx = ev.clientX - grabX + w / 2;
|
|
91
|
+
const cy = ev.clientY - grabY + h / 2;
|
|
92
|
+
onAnchor(snapAnchor(cx, cy, window.innerWidth, window.innerHeight, w, h));
|
|
93
|
+
setDragPos(null);
|
|
94
|
+
};
|
|
95
|
+
window.addEventListener("pointermove", onMove);
|
|
96
|
+
window.addEventListener("pointerup", end);
|
|
97
|
+
window.addEventListener("pointercancel", end);
|
|
98
|
+
};
|
|
99
|
+
const position = phone ? collapsed ? { position: "fixed", right: 12, bottom: "calc(12px + env(safe-area-inset-bottom, 0px))" } : { position: "fixed", left: 0, right: 0, bottom: 0 } : dragPos ? { position: "fixed", left: dragPos.left, top: dragPos.top, transition: "none" } : {
|
|
100
|
+
position: "fixed",
|
|
101
|
+
...anchorStyle(anchor),
|
|
102
|
+
// ds-lint-disable-next-line no-unknown-class — a CSS value, not a class
|
|
103
|
+
transition: "top var(--dur-base) var(--ease-out), left var(--dur-base) var(--ease-out), right var(--dur-base) var(--ease-out), bottom var(--dur-base) var(--ease-out)"
|
|
104
|
+
};
|
|
105
|
+
const mark = /* @__PURE__ */ jsx(Tooltip, { side: vertical ? "right" : "top", delayDuration: 400, content: collapsed ? STR.expand : STR.collapse, children: /* @__PURE__ */ jsxs(
|
|
106
|
+
"button",
|
|
107
|
+
{
|
|
108
|
+
ref: (el) => {
|
|
109
|
+
refs.current[0] = el;
|
|
110
|
+
},
|
|
111
|
+
type: "button",
|
|
112
|
+
"aria-label": collapsed ? STR.expand : STR.collapse,
|
|
113
|
+
"aria-expanded": !collapsed,
|
|
114
|
+
tabIndex: focusIndex === 0 ? 0 : -1,
|
|
115
|
+
onFocus: () => setFocusIndex(0),
|
|
116
|
+
onPointerDown: onMarkPointerDown,
|
|
117
|
+
onClick: () => {
|
|
118
|
+
if (justDragged.current) return;
|
|
119
|
+
onCollapsed(!collapsed);
|
|
120
|
+
},
|
|
121
|
+
"data-shavin-mark": "",
|
|
122
|
+
style: { touchAction: "none", ...collapsed ? { width: phone ? 44 : 40, height: phone ? 44 : 40 } : phone ? { width: 44, height: 44 } : {} },
|
|
123
|
+
className: cn(
|
|
124
|
+
"relative flex shrink-0 cursor-grab select-none items-center justify-center text-fg active:cursor-grabbing",
|
|
125
|
+
collapsed ? "rounded-full border border-hairline bg-elevated shadow-panel" : "h-8 w-8 rounded-[var(--radius-panel-p1,var(--radius-lg))] hover:bg-fg/[0.08]"
|
|
126
|
+
),
|
|
127
|
+
children: [
|
|
128
|
+
/* @__PURE__ */ jsx(ShavinMark, { size: collapsed ? 20 : 18 }),
|
|
129
|
+
collapsed && count > 0 ? /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: cn("absolute right-0 top-0 h-2.5 w-2.5 rounded-full ring-2 ring-[rgb(var(--bg-elevated))]", dotClass) }) : null
|
|
130
|
+
]
|
|
131
|
+
}
|
|
132
|
+
) });
|
|
133
|
+
return /* @__PURE__ */ jsxs(
|
|
134
|
+
"div",
|
|
135
|
+
{
|
|
136
|
+
ref: barRef,
|
|
137
|
+
role: "toolbar",
|
|
138
|
+
"aria-label": STR.toolbar,
|
|
139
|
+
"aria-orientation": vertical ? "vertical" : "horizontal",
|
|
140
|
+
onKeyDown,
|
|
141
|
+
onFocusCapture: (e) => {
|
|
142
|
+
const from = e.relatedTarget;
|
|
143
|
+
if (!from || !barRef.current?.contains(from)) onFocusFrom?.(from && !from.closest?.("[data-shavin-inspector]") ? from : null);
|
|
144
|
+
},
|
|
145
|
+
"data-shavin-toolbar": "",
|
|
146
|
+
"data-collapsed": collapsed ? "" : void 0,
|
|
147
|
+
className: cn(
|
|
148
|
+
"flex items-center text-fg",
|
|
149
|
+
collapsed ? "" : phone ? "justify-around border-t border-hairline bg-elevated px-2 shadow-panel" : "gap-0.5 rounded-[var(--radius-panel)] border border-hairline bg-elevated p-1 shadow-panel",
|
|
150
|
+
vertical ? "flex-col" : "h-auto"
|
|
151
|
+
),
|
|
152
|
+
style: { pointerEvents: "auto", ...!collapsed && !vertical ? phone ? DOCK_STYLE : { height: 40 } : {}, ...position },
|
|
153
|
+
children: [
|
|
154
|
+
mark,
|
|
155
|
+
collapsed ? null : ICONS.map(({ id, icon: Icon }, n) => {
|
|
156
|
+
const i = n + 1;
|
|
157
|
+
const isPanel = id === "theme" || id === "settings";
|
|
158
|
+
const on = isPanel ? !!panels?.has(id) : active === id;
|
|
159
|
+
const def = TOOLS[id];
|
|
160
|
+
const dot = id === "issues" ? count : 0;
|
|
161
|
+
return /* @__PURE__ */ jsx(
|
|
162
|
+
Tooltip,
|
|
163
|
+
{
|
|
164
|
+
side: vertical ? "right" : "top",
|
|
165
|
+
delayDuration: 400,
|
|
166
|
+
content: /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
|
|
167
|
+
def.label,
|
|
168
|
+
/* @__PURE__ */ jsx(Kbd, { className: "font-sans", children: def.key })
|
|
169
|
+
] }),
|
|
170
|
+
children: /* @__PURE__ */ jsxs(
|
|
171
|
+
IconButton,
|
|
172
|
+
{
|
|
173
|
+
ref: (el) => {
|
|
174
|
+
refs.current[i] = el;
|
|
175
|
+
},
|
|
176
|
+
variant: "ghost",
|
|
177
|
+
size: "sm",
|
|
178
|
+
"aria-label": def.label,
|
|
179
|
+
"aria-pressed": on,
|
|
180
|
+
tabIndex: i === focusIndex ? 0 : -1,
|
|
181
|
+
onFocus: () => setFocusIndex(i),
|
|
182
|
+
onClick: () => isPanel ? onPanel?.(id) : onChange(on ? null : id),
|
|
183
|
+
style: phone ? { width: 44, height: 44 } : void 0,
|
|
184
|
+
className: cn("relative rounded-[var(--radius-panel-p1,var(--radius-lg))]", on && "bg-fg/[0.12] text-fg"),
|
|
185
|
+
children: [
|
|
186
|
+
/* @__PURE__ */ jsx(Icon, { className: "h-4 w-4", strokeWidth: 1.75, "aria-hidden": "true" }),
|
|
187
|
+
dot > 0 ? /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: cn("absolute right-1 top-1 h-2 w-2 rounded-full ring-2 ring-[rgb(var(--bg-elevated))]", dotClass) }) : null
|
|
188
|
+
]
|
|
189
|
+
}
|
|
190
|
+
)
|
|
191
|
+
},
|
|
192
|
+
id
|
|
193
|
+
);
|
|
194
|
+
}),
|
|
195
|
+
collapsed || vertical || phone || !mode ? /* @__PURE__ */ jsx("span", { className: "sr-only", "aria-live": "polite", children: mode }) : /* @__PURE__ */ jsx("span", { className: "px-2 text-xs text-fg-muted", "aria-live": "polite", children: mode })
|
|
196
|
+
]
|
|
197
|
+
}
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
export {
|
|
201
|
+
Toolbar
|
|
202
|
+
};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
const ANCHORS = ["top-left", "top-center", "top-right", "middle-left", "middle-right", "bottom-left", "bottom-center", "bottom-right"];
|
|
2
|
+
const DEFAULT_ANCHOR = "bottom-right";
|
|
3
|
+
const BAR_MARGIN = 20;
|
|
4
|
+
const STORAGE_KEY = "shavin-inspector-bar";
|
|
5
|
+
const isAnchor = (v) => typeof v === "string" && ANCHORS.includes(v);
|
|
6
|
+
const isVertical = (a) => a === "middle-left" || a === "middle-right";
|
|
7
|
+
function anchorCenter(a, vw, vh, w, h, margin = BAR_MARGIN) {
|
|
8
|
+
const [row, col] = a.split("-");
|
|
9
|
+
const x = col === "left" ? margin + w / 2 : col === "right" ? vw - margin - w / 2 : vw / 2;
|
|
10
|
+
const y = row === "top" ? margin + h / 2 : row === "bottom" ? vh - margin - h / 2 : vh / 2;
|
|
11
|
+
return { x, y };
|
|
12
|
+
}
|
|
13
|
+
function snapAnchor(x, y, vw, vh, w, h) {
|
|
14
|
+
let best = DEFAULT_ANCHOR;
|
|
15
|
+
let bestD = Infinity;
|
|
16
|
+
for (const a of ANCHORS) {
|
|
17
|
+
const c = anchorCenter(a, vw, vh, w, h);
|
|
18
|
+
const d = (c.x - x) ** 2 + (c.y - y) ** 2;
|
|
19
|
+
if (d < bestD) {
|
|
20
|
+
bestD = d;
|
|
21
|
+
best = a;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return best;
|
|
25
|
+
}
|
|
26
|
+
function anchorStyle(a, margin = BAR_MARGIN) {
|
|
27
|
+
const [row, col] = a.split("-");
|
|
28
|
+
const s = {};
|
|
29
|
+
if (row === "top") s.top = margin;
|
|
30
|
+
else if (row === "bottom") s.bottom = margin;
|
|
31
|
+
else s.top = "50%";
|
|
32
|
+
if (col === "left") s.left = margin;
|
|
33
|
+
else if (col === "right") s.right = margin;
|
|
34
|
+
else s.left = "50%";
|
|
35
|
+
const tx = col === "center" ? "-50%" : "0";
|
|
36
|
+
const ty = row === "middle" ? "-50%" : "0";
|
|
37
|
+
if (tx !== "0" || ty !== "0") s.transform = `translate(${tx}, ${ty})`;
|
|
38
|
+
return s;
|
|
39
|
+
}
|
|
40
|
+
function dockStyle(a, bar = 40, gap = 8, margin = BAR_MARGIN) {
|
|
41
|
+
const [row, col] = a.split("-");
|
|
42
|
+
const off = margin + bar + gap;
|
|
43
|
+
const justify = col === "left" ? "flex-start" : col === "right" ? "flex-end" : "center";
|
|
44
|
+
if (row === "middle") {
|
|
45
|
+
return { top: margin, bottom: margin, left: col === "left" ? off : margin, right: col === "right" ? off : margin, display: "flex", alignItems: "center", justifyContent: col === "left" ? "flex-start" : "flex-end" };
|
|
46
|
+
}
|
|
47
|
+
return { top: row === "top" ? off : margin, bottom: row === "bottom" ? off : margin, left: margin, right: margin, display: "flex", alignItems: row === "top" ? "flex-start" : "flex-end", justifyContent: justify };
|
|
48
|
+
}
|
|
49
|
+
function stepAnchor(a, dir) {
|
|
50
|
+
const rows = ["top", "middle", "bottom"];
|
|
51
|
+
const cols = ["left", "center", "right"];
|
|
52
|
+
const [row, col] = a.split("-");
|
|
53
|
+
let r = rows.indexOf(row);
|
|
54
|
+
let c = cols.indexOf(col);
|
|
55
|
+
if (dir === "left") c = Math.max(0, c - 1);
|
|
56
|
+
if (dir === "right") c = Math.min(2, c + 1);
|
|
57
|
+
if (dir === "up") r = Math.max(0, r - 1);
|
|
58
|
+
if (dir === "down") r = Math.min(2, r + 1);
|
|
59
|
+
const next = `${rows[r]}-${cols[c]}`;
|
|
60
|
+
return isAnchor(next) ? next : a;
|
|
61
|
+
}
|
|
62
|
+
function loadBarPrefs(startAnchor = DEFAULT_ANCHOR) {
|
|
63
|
+
const fallback = { anchor: startAnchor, collapsed: true };
|
|
64
|
+
try {
|
|
65
|
+
const raw = JSON.parse(localStorage.getItem(STORAGE_KEY) ?? "null");
|
|
66
|
+
return { anchor: isAnchor(raw?.anchor) ? raw.anchor : fallback.anchor, collapsed: typeof raw?.collapsed === "boolean" ? raw.collapsed : fallback.collapsed };
|
|
67
|
+
} catch {
|
|
68
|
+
return fallback;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function saveBarPrefs(p) {
|
|
72
|
+
try {
|
|
73
|
+
localStorage.setItem(STORAGE_KEY, JSON.stringify(p));
|
|
74
|
+
} catch {
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const AVOID_ORDER = ["bottom-right", "bottom-left", "bottom-center", "top-right", "top-left", "top-center"];
|
|
78
|
+
const touches = (a, b) => a.x < b.x + b.w && b.x < a.x + a.w && a.y < b.y + b.h && b.y < a.y + a.h;
|
|
79
|
+
function avoidAnchor(preferred, covered, vw, vh, w, h, pad = 8) {
|
|
80
|
+
if (!covered) return preferred;
|
|
81
|
+
const grown = { x: covered.x - pad, y: covered.y - pad, w: covered.w + 2 * pad, h: covered.h + 2 * pad };
|
|
82
|
+
const slot = (a) => {
|
|
83
|
+
const c = anchorCenter(a, vw, vh, w, h);
|
|
84
|
+
return { x: c.x - w / 2, y: c.y - h / 2, w, h };
|
|
85
|
+
};
|
|
86
|
+
if (!touches(slot(preferred), grown)) return preferred;
|
|
87
|
+
for (const a of AVOID_ORDER) if (!touches(slot(a), grown)) return a;
|
|
88
|
+
return preferred;
|
|
89
|
+
}
|
|
90
|
+
function panelInsets(bar, side, barSize = 40, gap = 8, margin = BAR_MARGIN) {
|
|
91
|
+
const [row, col] = bar.split("-");
|
|
92
|
+
const off = margin + barSize + gap;
|
|
93
|
+
const base = { top: margin, bottom: margin, left: margin, right: margin };
|
|
94
|
+
if (col !== side) return base;
|
|
95
|
+
if (row === "top") base.top = off;
|
|
96
|
+
else if (row === "bottom") base.bottom = off;
|
|
97
|
+
else base[side] = off;
|
|
98
|
+
return base;
|
|
99
|
+
}
|
|
100
|
+
export {
|
|
101
|
+
ANCHORS,
|
|
102
|
+
AVOID_ORDER,
|
|
103
|
+
BAR_MARGIN,
|
|
104
|
+
DEFAULT_ANCHOR,
|
|
105
|
+
STORAGE_KEY,
|
|
106
|
+
anchorCenter,
|
|
107
|
+
anchorStyle,
|
|
108
|
+
avoidAnchor,
|
|
109
|
+
dockStyle,
|
|
110
|
+
isAnchor,
|
|
111
|
+
isVertical,
|
|
112
|
+
loadBarPrefs,
|
|
113
|
+
panelInsets,
|
|
114
|
+
saveBarPrefs,
|
|
115
|
+
snapAnchor,
|
|
116
|
+
stepAnchor
|
|
117
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
function currentTabId() {
|
|
3
|
+
try {
|
|
4
|
+
return sessionStorage.getItem("__shavin_tab_id") || "default";
|
|
5
|
+
} catch {
|
|
6
|
+
return "default";
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
async function copyText(text) {
|
|
10
|
+
try {
|
|
11
|
+
if (navigator.clipboard?.writeText) {
|
|
12
|
+
await navigator.clipboard.writeText(text);
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
} catch {
|
|
16
|
+
}
|
|
17
|
+
try {
|
|
18
|
+
const ta = document.createElement("textarea");
|
|
19
|
+
ta.value = text;
|
|
20
|
+
ta.setAttribute("readonly", "");
|
|
21
|
+
ta.style.cssText = "position:fixed;left:-9999px;top:0;opacity:0";
|
|
22
|
+
document.body.appendChild(ta);
|
|
23
|
+
ta.select();
|
|
24
|
+
const ok = document.execCommand("copy");
|
|
25
|
+
ta.remove();
|
|
26
|
+
return ok;
|
|
27
|
+
} catch {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function useNow(active, ms = 1e3) {
|
|
32
|
+
const [now, setNow] = useState(() => Date.now());
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (!active) return;
|
|
35
|
+
setNow(Date.now());
|
|
36
|
+
const id = window.setInterval(() => setNow(Date.now()), ms);
|
|
37
|
+
return () => window.clearInterval(id);
|
|
38
|
+
}, [active, ms]);
|
|
39
|
+
return active ? now : Date.now();
|
|
40
|
+
}
|
|
41
|
+
function scrollParent(el) {
|
|
42
|
+
for (let n = el?.parentElement ?? null; n && n !== document.body && n !== document.documentElement; n = n.parentElement) {
|
|
43
|
+
const oy = getComputedStyle(n).overflowY;
|
|
44
|
+
if ((oy === "auto" || oy === "scroll" || oy === "overlay") && n.scrollHeight > n.clientHeight + 1) return n;
|
|
45
|
+
}
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
function scrollPageBy(el, dy) {
|
|
49
|
+
const parent = scrollParent(el);
|
|
50
|
+
if (parent) parent.scrollTop += dy;
|
|
51
|
+
else window.scrollBy({ top: dy });
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
copyText,
|
|
55
|
+
currentTabId,
|
|
56
|
+
scrollPageBy,
|
|
57
|
+
scrollParent,
|
|
58
|
+
useNow
|
|
59
|
+
};
|