@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,205 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { cn } from "../../lib/cn.js";
|
|
5
|
+
import { hitAreaClass } from "../../lib/hit-area.js";
|
|
6
|
+
import { highlightCode } from "../../lib/syntax.js";
|
|
7
|
+
function CodeBlock({
|
|
8
|
+
code,
|
|
9
|
+
language,
|
|
10
|
+
appearance,
|
|
11
|
+
theme,
|
|
12
|
+
variant = "standalone",
|
|
13
|
+
collapsible,
|
|
14
|
+
split,
|
|
15
|
+
previewPosition,
|
|
16
|
+
children,
|
|
17
|
+
wrap = false,
|
|
18
|
+
copyable = true,
|
|
19
|
+
state,
|
|
20
|
+
defaultOpen,
|
|
21
|
+
onStateChange,
|
|
22
|
+
description,
|
|
23
|
+
title,
|
|
24
|
+
hitArea,
|
|
25
|
+
className,
|
|
26
|
+
...props
|
|
27
|
+
}) {
|
|
28
|
+
const [copied, setCopied] = useState(false);
|
|
29
|
+
const effectiveAppearance = appearance || theme || "auto";
|
|
30
|
+
const appearanceClass = effectiveAppearance === "dark" ? "dark" : effectiveAppearance === "light" ? "light" : "";
|
|
31
|
+
const isCollapsible = variant === "collapsible" || collapsible === true;
|
|
32
|
+
const effectiveSplit = variant === "split" ? split || "horizontal" : split || "vertical";
|
|
33
|
+
const [internalOpen, setInternalOpen] = useState(
|
|
34
|
+
state !== void 0 ? state.toLowerCase() === "open" : defaultOpen === true
|
|
35
|
+
);
|
|
36
|
+
React.useEffect(() => {
|
|
37
|
+
if (state !== void 0) {
|
|
38
|
+
setInternalOpen(state.toLowerCase() === "open");
|
|
39
|
+
}
|
|
40
|
+
}, [state]);
|
|
41
|
+
const isCollapsibleOpen = internalOpen;
|
|
42
|
+
const handleToggleOpen = () => {
|
|
43
|
+
const next = !isCollapsibleOpen;
|
|
44
|
+
setInternalOpen(next);
|
|
45
|
+
onStateChange?.(next ? "open" : "close");
|
|
46
|
+
};
|
|
47
|
+
const handleCopy = () => {
|
|
48
|
+
navigator.clipboard?.writeText(code).then(() => {
|
|
49
|
+
setCopied(true);
|
|
50
|
+
setTimeout(() => setCopied(false), 1200);
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
const effectivePos = previewPosition || (effectiveSplit === "horizontal" ? "right" : "top");
|
|
54
|
+
const footerText = description || title;
|
|
55
|
+
const codeBox = /* @__PURE__ */ jsxs(
|
|
56
|
+
"div",
|
|
57
|
+
{
|
|
58
|
+
className: cn(
|
|
59
|
+
"group relative flex-1 min-w-0 border border-hairline bg-surface text-fg",
|
|
60
|
+
appearanceClass,
|
|
61
|
+
children && !isCollapsible ? effectiveSplit === "horizontal" ? effectivePos === "right" ? "rounded-t-[var(--radius-panel)] md:rounded-tr-none md:rounded-l-[var(--radius-panel)] border-b md:border-b-0 md:border-r" : "rounded-b-[var(--radius-panel)] md:rounded-bl-none md:rounded-r-[var(--radius-panel)] border-t md:border-t-0 md:border-l" : effectivePos === "top" ? "-mt-px rounded-b-[var(--radius-panel)]" : "rounded-t-[var(--radius-panel)] border-b" : isCollapsible ? "border-t border-hairline/20 rounded-b-[var(--radius-panel)]" : variant === "standalone" ? "rounded-[var(--radius-panel)]" : "-mt-px rounded-b-[var(--radius-panel)]",
|
|
62
|
+
className
|
|
63
|
+
),
|
|
64
|
+
"data-theme": effectiveAppearance !== "auto" ? effectiveAppearance : void 0,
|
|
65
|
+
...!children ? props : {},
|
|
66
|
+
children: [
|
|
67
|
+
copyable && !isCollapsible && /* @__PURE__ */ jsx(
|
|
68
|
+
"button",
|
|
69
|
+
{
|
|
70
|
+
type: "button",
|
|
71
|
+
onClick: handleCopy,
|
|
72
|
+
className: cn("hit-area-touch absolute right-2 top-2 rounded-[var(--radius-lg)] border border-hairline bg-surface px-2 py-1 text-xs text-fg-subtle transition hover:text-fg hover:bg-surface-hover active:scale-[0.97] md:opacity-0 md:group-hover:opacity-100 focus-visible:opacity-100 z-10 cursor-pointer", hitAreaClass(hitArea, "touch", "CodeBlock")),
|
|
73
|
+
children: copied ? "Copied" : "Copy"
|
|
74
|
+
}
|
|
75
|
+
),
|
|
76
|
+
/* @__PURE__ */ jsx("pre", { tabIndex: 0, role: "region", "aria-label": footerText || (language ? `${language} code` : "Code"), className: cn("overflow-x-auto p-4 text-xs leading-relaxed text-fg h-full select-text cursor-text selection:bg-brand/20 selection:text-fg", wrap && "whitespace-pre-wrap break-words"), children: /* @__PURE__ */ jsx("code", { className: "font-mono select-text cursor-text selection:bg-brand/20 selection:text-fg", children: highlightCode(code, language) }) })
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
if (!children) {
|
|
81
|
+
return codeBox;
|
|
82
|
+
}
|
|
83
|
+
if (isCollapsible) {
|
|
84
|
+
return /* @__PURE__ */ jsxs(
|
|
85
|
+
"div",
|
|
86
|
+
{
|
|
87
|
+
className: cn("w-full rounded-[var(--radius-panel)] border border-hairline bg-surface shadow-card overflow-hidden", className),
|
|
88
|
+
...props,
|
|
89
|
+
children: [
|
|
90
|
+
/* @__PURE__ */ jsxs("div", { className: "relative flex flex-wrap items-center justify-center p-8 overflow-auto min-h-[140px] bg-surface", children: [
|
|
91
|
+
/* @__PURE__ */ jsx(
|
|
92
|
+
"div",
|
|
93
|
+
{
|
|
94
|
+
className: "absolute inset-0 opacity-10 pointer-events-none z-0",
|
|
95
|
+
style: {
|
|
96
|
+
backgroundImage: "radial-gradient(currentColor 1px, transparent 1px)",
|
|
97
|
+
backgroundSize: "12px 12px"
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
),
|
|
101
|
+
/* @__PURE__ */ jsx("div", { className: "relative z-10 w-full flex flex-wrap items-center justify-center gap-4", children })
|
|
102
|
+
] }),
|
|
103
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between border-t border-hairline px-4 py-2.5 bg-surface-hover/30 text-xs", children: [
|
|
104
|
+
/* @__PURE__ */ jsx("div", { className: "truncate text-fg-muted font-normal select-none", children: footerText ? /* @__PURE__ */ jsx("span", { className: "font-mono text-fg-subtle", children: footerText }) : /* @__PURE__ */ jsx("span", { className: "font-mono text-fg-subtle", children: "Component Source" }) }),
|
|
105
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 shrink-0", children: [
|
|
106
|
+
copyable && /* @__PURE__ */ jsx(
|
|
107
|
+
"button",
|
|
108
|
+
{
|
|
109
|
+
type: "button",
|
|
110
|
+
onClick: handleCopy,
|
|
111
|
+
className: cn("hit-area-touch flex items-center justify-center h-7 w-7 rounded-[var(--radius-lg)] border border-hairline bg-surface text-fg-muted hover:text-fg hover:bg-surface-hover transition cursor-pointer", hitAreaClass(hitArea, "touch", "CodeBlock")),
|
|
112
|
+
title: "Copy source code",
|
|
113
|
+
"aria-label": "Copy source code",
|
|
114
|
+
children: copied ? /* @__PURE__ */ jsx("svg", { width: "13", height: "13", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", children: /* @__PURE__ */ jsx("path", { d: "M20 6 9 17l-5-5" }) }) : /* @__PURE__ */ jsxs("svg", { width: "13", height: "13", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
115
|
+
/* @__PURE__ */ jsx("rect", { width: "14", height: "14", x: "8", y: "8", rx: "2", ry: "2" }),
|
|
116
|
+
/* @__PURE__ */ jsx("path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" })
|
|
117
|
+
] })
|
|
118
|
+
}
|
|
119
|
+
),
|
|
120
|
+
/* @__PURE__ */ jsxs(
|
|
121
|
+
"button",
|
|
122
|
+
{
|
|
123
|
+
type: "button",
|
|
124
|
+
onClick: handleToggleOpen,
|
|
125
|
+
className: cn("hit-area-touch flex items-center gap-1.5 h-7 px-2.5 rounded-[var(--radius-lg)] border border-hairline bg-surface text-xs font-medium text-fg hover:bg-surface-hover transition cursor-pointer", hitAreaClass(hitArea, "touch", "CodeBlock")),
|
|
126
|
+
"aria-expanded": isCollapsibleOpen,
|
|
127
|
+
children: [
|
|
128
|
+
/* @__PURE__ */ jsx(
|
|
129
|
+
"svg",
|
|
130
|
+
{
|
|
131
|
+
width: "13",
|
|
132
|
+
height: "13",
|
|
133
|
+
viewBox: "0 0 24 24",
|
|
134
|
+
fill: "none",
|
|
135
|
+
stroke: "currentColor",
|
|
136
|
+
strokeWidth: "2",
|
|
137
|
+
className: cn("transition-transform duration-200", isCollapsibleOpen && "rotate-180"),
|
|
138
|
+
children: /* @__PURE__ */ jsx("polyline", { points: "6 9 12 15 18 9" })
|
|
139
|
+
}
|
|
140
|
+
),
|
|
141
|
+
/* @__PURE__ */ jsx("span", { children: isCollapsibleOpen ? "Hide code" : "View code" })
|
|
142
|
+
]
|
|
143
|
+
}
|
|
144
|
+
)
|
|
145
|
+
] })
|
|
146
|
+
] }),
|
|
147
|
+
/* @__PURE__ */ jsx(
|
|
148
|
+
"div",
|
|
149
|
+
{
|
|
150
|
+
className: cn(
|
|
151
|
+
"grid transition-[grid-template-rows,opacity] duration-300 ease-out",
|
|
152
|
+
isCollapsibleOpen ? "grid-rows-[1fr] opacity-100" : "grid-rows-[0fr] opacity-0 pointer-events-none"
|
|
153
|
+
),
|
|
154
|
+
children: /* @__PURE__ */ jsx("div", { className: "overflow-hidden", children: codeBox })
|
|
155
|
+
}
|
|
156
|
+
)
|
|
157
|
+
]
|
|
158
|
+
}
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
const previewBox = /* @__PURE__ */ jsxs(
|
|
162
|
+
"div",
|
|
163
|
+
{
|
|
164
|
+
className: cn(
|
|
165
|
+
"relative flex flex-1 min-w-0 flex-wrap items-center justify-center border border-hairline bg-surface p-6 overflow-auto min-h-[120px]",
|
|
166
|
+
effectiveSplit === "horizontal" ? effectivePos === "right" ? "rounded-b-[var(--radius-panel)] md:rounded-bl-none md:rounded-r-[var(--radius-panel)]" : "rounded-t-[var(--radius-panel)] md:rounded-tr-none md:rounded-l-[var(--radius-panel)]" : effectivePos === "top" ? "rounded-t-[var(--radius-panel)]" : "rounded-b-[var(--radius-panel)]"
|
|
167
|
+
),
|
|
168
|
+
children: [
|
|
169
|
+
/* @__PURE__ */ jsx(
|
|
170
|
+
"div",
|
|
171
|
+
{
|
|
172
|
+
className: "absolute inset-0 opacity-10 pointer-events-none z-0",
|
|
173
|
+
style: {
|
|
174
|
+
backgroundImage: "radial-gradient(currentColor 1px, transparent 1px)",
|
|
175
|
+
backgroundSize: "12px 12px"
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
),
|
|
179
|
+
/* @__PURE__ */ jsx("div", { className: "relative z-10 w-full flex flex-wrap items-center justify-center gap-4", children })
|
|
180
|
+
]
|
|
181
|
+
}
|
|
182
|
+
);
|
|
183
|
+
return /* @__PURE__ */ jsx(
|
|
184
|
+
"div",
|
|
185
|
+
{
|
|
186
|
+
className: cn(
|
|
187
|
+
"w-full overflow-hidden rounded-[var(--radius-panel)] shadow-card",
|
|
188
|
+
effectiveSplit === "horizontal" ? "grid grid-cols-1 md:grid-cols-2" : "flex flex-col",
|
|
189
|
+
className
|
|
190
|
+
),
|
|
191
|
+
...props,
|
|
192
|
+
children: effectivePos === "right" || effectivePos === "bottom" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
193
|
+
codeBox,
|
|
194
|
+
previewBox
|
|
195
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
196
|
+
previewBox,
|
|
197
|
+
codeBox
|
|
198
|
+
] })
|
|
199
|
+
}
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
export {
|
|
203
|
+
CodeBlock,
|
|
204
|
+
highlightCode
|
|
205
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const docs = {
|
|
2
|
+
name: "CodeEditor",
|
|
3
|
+
description: "Lightweight editable code field with syntax highlighting, a filename header, copy and a scoped light/dark toggle.",
|
|
4
|
+
features: [
|
|
5
|
+
"Controlled: pass value and onChange; omit onChange or set readOnly for a read-only view",
|
|
6
|
+
"Header with filename, language badge, copy button and editor-only light/dark toggle (hideHeader removes it)",
|
|
7
|
+
"Tab inserts two spaces while editing; Escape then Tab moves focus on",
|
|
8
|
+
"headerLeft, headerRight and footer slots; footer={null} removes the status bar",
|
|
9
|
+
"Highlighting via the shared syntax helper, so colours follow theme tokens"
|
|
10
|
+
],
|
|
11
|
+
notes: [
|
|
12
|
+
"A plain textarea with a highlighted layer behind it: no autocomplete, linting or multi-cursor. Reach for Monaco or CodeMirror when you need those.",
|
|
13
|
+
"Use CodeBlock to show code that people only read or copy."
|
|
14
|
+
],
|
|
15
|
+
accessibility: [
|
|
16
|
+
"The field is a native textarea named by label, falling back to the filename",
|
|
17
|
+
"The highlighted layer is aria-hidden, so screen readers read the textarea value only",
|
|
18
|
+
'Header buttons are native buttons with labels ("Switch editor to light mode", "Copy code to clipboard")'
|
|
19
|
+
],
|
|
20
|
+
keyboard: "Tab inserts two spaces while editing. Press Escape, then Tab, to move focus out; Shift+Tab always moves focus back. Standard textarea keys otherwise.",
|
|
21
|
+
usage: {
|
|
22
|
+
bestPractices: [
|
|
23
|
+
{
|
|
24
|
+
guidance: true,
|
|
25
|
+
description: "Give the editor a label (or a meaningful filename) so assistive tech announces what the code is."
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
guidance: true,
|
|
29
|
+
description: "Pass readOnly, or leave out onChange, when showing code people should not edit, so Tab keeps moving focus."
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
guidance: false,
|
|
33
|
+
description: "Do not use CodeEditor as a full IDE for large files; it re-highlights the whole value on every keystroke."
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
},
|
|
37
|
+
examples: [
|
|
38
|
+
{
|
|
39
|
+
title: "Editable",
|
|
40
|
+
code: `function EditableSnippet() {
|
|
41
|
+
const [code, setCode] = useState('export function Hello() {\\n return <Button>Hello</Button>;\\n}\\n');
|
|
42
|
+
return <CodeEditor value={code} onChange={setCode} filename="Hello.tsx" label="Hello component source" />;
|
|
43
|
+
}`
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
title: "Read-only, no chrome",
|
|
47
|
+
code: '<CodeEditor value={"npx @shavin/cli init"} language="bash" hideHeader footer={null} readOnly minHeight={64} label="Install command" />'
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
};
|
|
51
|
+
export {
|
|
52
|
+
docs
|
|
53
|
+
};
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useRef, useCallback } from "react";
|
|
3
|
+
import { cn } from "../../lib/cn.js";
|
|
4
|
+
import { Icon } from "../Icon/Icon.js";
|
|
5
|
+
import { highlightCode } from "../../lib/syntax.js";
|
|
6
|
+
function CodeEditor({
|
|
7
|
+
value,
|
|
8
|
+
onChange,
|
|
9
|
+
filename = "Component.tsx",
|
|
10
|
+
language = "React TSX",
|
|
11
|
+
showLanguage = true,
|
|
12
|
+
hideHeader = false,
|
|
13
|
+
showHeader = true,
|
|
14
|
+
theme = "auto",
|
|
15
|
+
allowThemeToggle = true,
|
|
16
|
+
readOnly = false,
|
|
17
|
+
placeholder,
|
|
18
|
+
minHeight = 220,
|
|
19
|
+
copyable = true,
|
|
20
|
+
headerLeft,
|
|
21
|
+
headerRight,
|
|
22
|
+
footer,
|
|
23
|
+
className,
|
|
24
|
+
label,
|
|
25
|
+
...props
|
|
26
|
+
}) {
|
|
27
|
+
const [internalTheme, setInternalTheme] = useState(
|
|
28
|
+
theme === "dark" ? "dark" : theme === "light" ? "light" : "dark"
|
|
29
|
+
);
|
|
30
|
+
const [copied, setCopied] = useState(false);
|
|
31
|
+
const preRef = useRef(null);
|
|
32
|
+
const textareaRef = useRef(null);
|
|
33
|
+
const escapedRef = useRef(false);
|
|
34
|
+
const isDark = internalTheme === "dark";
|
|
35
|
+
const shouldRenderHeader = showHeader && !hideHeader;
|
|
36
|
+
const handleCopy = () => {
|
|
37
|
+
if (!value) return;
|
|
38
|
+
navigator.clipboard?.writeText(value).then(() => {
|
|
39
|
+
setCopied(true);
|
|
40
|
+
setTimeout(() => setCopied(false), 1200);
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
const toggleEditorTheme = () => {
|
|
44
|
+
setInternalTheme((prev) => prev === "dark" ? "light" : "dark");
|
|
45
|
+
};
|
|
46
|
+
const handleScroll = useCallback((e) => {
|
|
47
|
+
if (preRef.current) {
|
|
48
|
+
preRef.current.scrollTop = e.currentTarget.scrollTop;
|
|
49
|
+
preRef.current.scrollLeft = e.currentTarget.scrollLeft;
|
|
50
|
+
}
|
|
51
|
+
}, []);
|
|
52
|
+
const handleKeyDown = useCallback(
|
|
53
|
+
(e) => {
|
|
54
|
+
if (e.key === "Escape") {
|
|
55
|
+
escapedRef.current = true;
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const leaving = escapedRef.current;
|
|
59
|
+
escapedRef.current = false;
|
|
60
|
+
if (e.key === "Tab" && !e.shiftKey && !leaving && !readOnly && onChange) {
|
|
61
|
+
e.preventDefault();
|
|
62
|
+
const textarea = e.currentTarget;
|
|
63
|
+
const start = textarea.selectionStart;
|
|
64
|
+
const end = textarea.selectionEnd;
|
|
65
|
+
const nextValue = value.substring(0, start) + " " + value.substring(end);
|
|
66
|
+
onChange(nextValue);
|
|
67
|
+
setTimeout(() => {
|
|
68
|
+
textarea.selectionStart = textarea.selectionEnd = start + 2;
|
|
69
|
+
}, 0);
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
[value, onChange, readOnly]
|
|
73
|
+
);
|
|
74
|
+
const heightStyle = { minHeight: typeof minHeight === "number" ? `${minHeight}px` : minHeight };
|
|
75
|
+
return /* @__PURE__ */ jsxs(
|
|
76
|
+
"div",
|
|
77
|
+
{
|
|
78
|
+
"data-editor-theme": internalTheme,
|
|
79
|
+
className: cn(
|
|
80
|
+
"group focus-ring-within relative w-full overflow-hidden rounded-[var(--radius-panel)] transition-colors shadow-card",
|
|
81
|
+
isDark ? "dark bg-surface border border-hairline text-fg" : "light bg-surface border border-hairline text-fg",
|
|
82
|
+
className
|
|
83
|
+
),
|
|
84
|
+
...props,
|
|
85
|
+
children: [
|
|
86
|
+
shouldRenderHeader && /* @__PURE__ */ jsxs(
|
|
87
|
+
"div",
|
|
88
|
+
{
|
|
89
|
+
className: cn(
|
|
90
|
+
"flex items-center justify-between px-3.5 py-2 border-b select-none transition-colors",
|
|
91
|
+
isDark ? "border-hairline bg-surface-hover/30 text-fg" : "border-hairline bg-surface-hover/60 text-fg"
|
|
92
|
+
),
|
|
93
|
+
children: [
|
|
94
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 min-w-0", children: headerLeft || /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
95
|
+
/* @__PURE__ */ jsx(Icon, { name: "fileCode", size: 14, color: "brand", className: "shrink-0" }),
|
|
96
|
+
filename && /* @__PURE__ */ jsx("span", { className: "text-xs font-mono font-semibold truncate text-fg", children: filename }),
|
|
97
|
+
showLanguage && language && /* @__PURE__ */ jsx(
|
|
98
|
+
"span",
|
|
99
|
+
{
|
|
100
|
+
className: "text-[10px] px-1.5 py-0.5 rounded-full font-semibold uppercase tracking-wider bg-fg/10 text-fg border border-hairline",
|
|
101
|
+
children: language
|
|
102
|
+
}
|
|
103
|
+
)
|
|
104
|
+
] }) }),
|
|
105
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 shrink-0", children: [
|
|
106
|
+
headerRight,
|
|
107
|
+
allowThemeToggle && /* @__PURE__ */ jsx(
|
|
108
|
+
"button",
|
|
109
|
+
{
|
|
110
|
+
type: "button",
|
|
111
|
+
onClick: toggleEditorTheme,
|
|
112
|
+
className: "flex h-6 w-6 items-center justify-center rounded-[var(--radius-lg)] border border-hairline bg-surface text-fg-subtle hover:text-fg hover:bg-surface-hover transition cursor-pointer",
|
|
113
|
+
title: `Switch editor to ${isDark ? "light" : "dark"} mode`,
|
|
114
|
+
"aria-label": `Switch editor to ${isDark ? "light" : "dark"} mode`,
|
|
115
|
+
children: /* @__PURE__ */ jsx(Icon, { name: isDark ? "sun" : "moon", size: 13, className: "text-fg-subtle" })
|
|
116
|
+
}
|
|
117
|
+
),
|
|
118
|
+
copyable && /* @__PURE__ */ jsxs(
|
|
119
|
+
"button",
|
|
120
|
+
{
|
|
121
|
+
type: "button",
|
|
122
|
+
onClick: handleCopy,
|
|
123
|
+
className: "flex h-6 items-center gap-1.5 px-2 rounded-[var(--radius-lg)] border border-hairline bg-surface text-fg-subtle hover:text-fg hover:bg-surface-hover text-[11px] font-medium transition cursor-pointer",
|
|
124
|
+
title: "Copy code to clipboard",
|
|
125
|
+
children: [
|
|
126
|
+
/* @__PURE__ */ jsx(
|
|
127
|
+
Icon,
|
|
128
|
+
{
|
|
129
|
+
name: copied ? "check" : "copy",
|
|
130
|
+
size: 12,
|
|
131
|
+
className: copied ? "text-success" : "text-fg-subtle"
|
|
132
|
+
}
|
|
133
|
+
),
|
|
134
|
+
/* @__PURE__ */ jsx("span", { children: copied ? "Copied" : "Copy" })
|
|
135
|
+
]
|
|
136
|
+
}
|
|
137
|
+
)
|
|
138
|
+
] })
|
|
139
|
+
]
|
|
140
|
+
}
|
|
141
|
+
),
|
|
142
|
+
/* @__PURE__ */ jsxs("div", { className: "relative w-full overflow-hidden", style: heightStyle, children: [
|
|
143
|
+
/* @__PURE__ */ jsx(
|
|
144
|
+
"pre",
|
|
145
|
+
{
|
|
146
|
+
ref: preRef,
|
|
147
|
+
"aria-hidden": "true",
|
|
148
|
+
className: "pointer-events-none absolute inset-0 m-0 p-4 font-mono text-xs leading-relaxed overflow-hidden whitespace-pre-wrap break-words select-none text-fg",
|
|
149
|
+
style: heightStyle,
|
|
150
|
+
children: /* @__PURE__ */ jsxs("code", { className: "font-mono", children: [
|
|
151
|
+
value ? highlightCode(value, language || filename) : null,
|
|
152
|
+
value.endsWith("\n") && "\n "
|
|
153
|
+
] })
|
|
154
|
+
}
|
|
155
|
+
),
|
|
156
|
+
/* @__PURE__ */ jsx(
|
|
157
|
+
"textarea",
|
|
158
|
+
{
|
|
159
|
+
ref: textareaRef,
|
|
160
|
+
value,
|
|
161
|
+
onChange: (e) => onChange?.(e.target.value),
|
|
162
|
+
onScroll: handleScroll,
|
|
163
|
+
onKeyDown: handleKeyDown,
|
|
164
|
+
readOnly,
|
|
165
|
+
"aria-label": label ?? filename ?? "Code",
|
|
166
|
+
placeholder,
|
|
167
|
+
spellCheck: false,
|
|
168
|
+
autoCapitalize: "off",
|
|
169
|
+
autoComplete: "off",
|
|
170
|
+
autoCorrect: "off",
|
|
171
|
+
style: heightStyle,
|
|
172
|
+
className: cn(
|
|
173
|
+
"relative z-10 block w-full h-full font-mono text-xs p-4 bg-transparent outline-none leading-relaxed resize-y whitespace-pre-wrap break-words border-none",
|
|
174
|
+
value ? "text-transparent" : "text-fg",
|
|
175
|
+
"caret-brand placeholder:text-fg-subtle selection:bg-brand/20 selection:text-transparent",
|
|
176
|
+
readOnly && "cursor-default"
|
|
177
|
+
)
|
|
178
|
+
}
|
|
179
|
+
)
|
|
180
|
+
] }),
|
|
181
|
+
footer !== null && /* @__PURE__ */ jsx(
|
|
182
|
+
"div",
|
|
183
|
+
{
|
|
184
|
+
className: "w-full px-3.5 py-2 transition-colors select-none text-xs border-t border-hairline bg-surface-hover/30 text-fg-subtle",
|
|
185
|
+
children: footer || /* @__PURE__ */ jsxs("div", { className: "w-full flex items-center justify-between gap-2 text-xs", children: [
|
|
186
|
+
/* @__PURE__ */ jsx("span", { className: "truncate text-fg-subtle", children: "Accessible Radix primitives and semantic tokens supported." }),
|
|
187
|
+
/* @__PURE__ */ jsxs("span", { className: "shrink-0 font-mono text-[11px] text-fg-muted", children: [
|
|
188
|
+
value ? value.split("\n").length : 0,
|
|
189
|
+
" ",
|
|
190
|
+
value && value.split("\n").length === 1 ? "line" : "lines",
|
|
191
|
+
" \xB7 ",
|
|
192
|
+
value ? value.length : 0,
|
|
193
|
+
" chars"
|
|
194
|
+
] })
|
|
195
|
+
] })
|
|
196
|
+
}
|
|
197
|
+
)
|
|
198
|
+
]
|
|
199
|
+
}
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
export {
|
|
203
|
+
CodeEditor
|
|
204
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const docs = {
|
|
2
|
+
name: "ColorPicker",
|
|
3
|
+
description: "Pick a colour from preset swatches or a colour area, or type a hex or RGB value. It can sit inline or open in a popover, and offers an eyedropper where the browser supports one.",
|
|
4
|
+
features: [
|
|
5
|
+
"Variants: default (panel popup with swatches grid/scroll) and field (compact field with leading swatch and trailing pipette)",
|
|
6
|
+
"Supports grid vs scroll swatch layouts",
|
|
7
|
+
"Integrates native HTML5 <input type='color'> eyedropper",
|
|
8
|
+
"Uses panel radius --radius-panel for container and control radius --radius-lg for swatches"
|
|
9
|
+
],
|
|
10
|
+
accessibility: [
|
|
11
|
+
"Provides aria-label and aria-pressed attributes for color swatch buttons",
|
|
12
|
+
"Provides screen reader labels for native eyedropper input trigger"
|
|
13
|
+
],
|
|
14
|
+
keyboard: "Tab to browse swatches grid, Space/Enter to pick color, Type hex/RGB value in text box",
|
|
15
|
+
usage: {
|
|
16
|
+
bestPractices: [
|
|
17
|
+
{
|
|
18
|
+
guidance: true,
|
|
19
|
+
description: "Use ColorPicker in design system configurators, theme customizers, or canvas drawing tools."
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
guidance: false,
|
|
23
|
+
description: "Do not use ColorPicker when selecting from a tiny closed set (<= 3 choices) \u2014 reach for RadioGroup or Select instead."
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
examples: [
|
|
28
|
+
{
|
|
29
|
+
title: "Brand Color Swatch Picker",
|
|
30
|
+
// ds-lint-disable-next-line no-hex — example hex value
|
|
31
|
+
code: '<ColorPicker value="#46a758" onChange={() => {}} variant="default" swatchLayout="grid" />'
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
};
|
|
35
|
+
export {
|
|
36
|
+
docs
|
|
37
|
+
};
|