@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,290 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { forwardRef, useState, useRef, useId } from "react";
|
|
5
|
+
import { Eye, EyeOff, CircleAlert } from "lucide-react";
|
|
6
|
+
import { cva } from "class-variance-authority";
|
|
7
|
+
import { cn } from "../../lib/cn.js";
|
|
8
|
+
import { hitAreaClass } from "../../lib/hit-area.js";
|
|
9
|
+
import { useFieldErrorAnnouncement } from "../../lib/useFieldErrorAnnouncement.js";
|
|
10
|
+
const textFieldVariants = cva(
|
|
11
|
+
// A native <input> cannot carry the invisible hit-area pseudo-element, so under a coarse pointer the
|
|
12
|
+
// field itself grows (`hit-area-input`: min-height --tap-min-touch, 44px by default, none when the provider is
|
|
13
|
+
// compact). 2.5.8 (24px) is met at every size.
|
|
14
|
+
"w-full rounded-[var(--radius-lg)] border text-fg transition placeholder:text-fg-subtle disabled:cursor-not-allowed disabled:opacity-50 hit-area-input",
|
|
15
|
+
{
|
|
16
|
+
variants: {
|
|
17
|
+
/**
|
|
18
|
+
* outline (default): a 3:1 control border (WCAG 1.4.11), for forms on any background.
|
|
19
|
+
* soft: filled, no border, for dense tool panels where a visible label and the value or
|
|
20
|
+
* placeholder identify the field. Both show the 2px focus ring.
|
|
21
|
+
*/
|
|
22
|
+
variant: {
|
|
23
|
+
outline: "bg-surface",
|
|
24
|
+
soft: "bg-surface-hover hover:bg-hairline/60"
|
|
25
|
+
},
|
|
26
|
+
size: {
|
|
27
|
+
sm: "h-8 px-2.5 text-xs",
|
|
28
|
+
md: "h-10 px-3 text-base md:text-sm",
|
|
29
|
+
lg: "h-12 px-3.5 text-base"
|
|
30
|
+
},
|
|
31
|
+
invalid: {
|
|
32
|
+
true: "border-danger focus-visible:outline-danger",
|
|
33
|
+
false: ""
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
compoundVariants: [
|
|
37
|
+
{ variant: "outline", invalid: false, class: "border-border-control" },
|
|
38
|
+
{ variant: "soft", invalid: false, class: "border-transparent" }
|
|
39
|
+
],
|
|
40
|
+
defaultVariants: { variant: "outline", size: "md", invalid: false }
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
const TextField = forwardRef(function TextField2({
|
|
44
|
+
className,
|
|
45
|
+
slotClassName,
|
|
46
|
+
variant,
|
|
47
|
+
size = "md",
|
|
48
|
+
invalid = false,
|
|
49
|
+
leadingIcon,
|
|
50
|
+
trailingIcon,
|
|
51
|
+
label,
|
|
52
|
+
hint,
|
|
53
|
+
type,
|
|
54
|
+
length = 6,
|
|
55
|
+
mask = false,
|
|
56
|
+
separator,
|
|
57
|
+
separatorIndex,
|
|
58
|
+
onComplete,
|
|
59
|
+
showHidePassword,
|
|
60
|
+
errorMessage,
|
|
61
|
+
announceError = true,
|
|
62
|
+
hitArea,
|
|
63
|
+
value,
|
|
64
|
+
defaultValue,
|
|
65
|
+
onChange,
|
|
66
|
+
disabled,
|
|
67
|
+
id: customId,
|
|
68
|
+
...props
|
|
69
|
+
}, ref) {
|
|
70
|
+
const autoId = useId();
|
|
71
|
+
const inputId = customId || autoId;
|
|
72
|
+
useFieldErrorAnnouncement(errorMessage, announceError);
|
|
73
|
+
const resolvedSize = size ?? "md";
|
|
74
|
+
const hintId = `${inputId}-hint`;
|
|
75
|
+
const errorId = `${inputId}-error`;
|
|
76
|
+
const describedBy = [props["aria-describedby"], errorMessage ? errorId : hint ? hintId : void 0].filter(Boolean).join(" ") || void 0;
|
|
77
|
+
const fieldA11y = {
|
|
78
|
+
"aria-describedby": describedBy,
|
|
79
|
+
"aria-invalid": invalid || Boolean(errorMessage) || props["aria-invalid"] || void 0
|
|
80
|
+
};
|
|
81
|
+
const isOtp = type === "otp";
|
|
82
|
+
const numLength = Math.min(typeof length === "string" ? parseInt(length, 10) || 6 : Number(length) || 6, 10);
|
|
83
|
+
const [internalOtpVal, setInternalOtpVal] = useState(
|
|
84
|
+
defaultValue !== void 0 ? String(defaultValue).slice(0, numLength) : ""
|
|
85
|
+
);
|
|
86
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
87
|
+
const [caretPos, setCaretPos] = useState(0);
|
|
88
|
+
const innerInputRef = useRef(null);
|
|
89
|
+
const [pwVisible, setPwVisible] = useState(false);
|
|
90
|
+
const otpValue = value !== void 0 ? String(value).slice(0, numLength) : internalOtpVal;
|
|
91
|
+
const effectiveSepIndex = separatorIndex !== void 0 ? separatorIndex : Math.floor(numLength / 2);
|
|
92
|
+
const effectiveSeparator = separator ?? (separatorIndex !== void 0 ? "-" : void 0);
|
|
93
|
+
const syncCaret = () => {
|
|
94
|
+
if (innerInputRef.current) {
|
|
95
|
+
setCaretPos(innerInputRef.current.selectionStart ?? otpValue.length);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
const handleOtpChange = (e) => {
|
|
99
|
+
const raw = e.target.value.replace(/\D/g, "").slice(0, numLength);
|
|
100
|
+
if (value === void 0) {
|
|
101
|
+
setInternalOtpVal(raw);
|
|
102
|
+
}
|
|
103
|
+
onChange?.(e);
|
|
104
|
+
setCaretPos(raw.length);
|
|
105
|
+
if (raw.length === numLength) {
|
|
106
|
+
onComplete?.(raw);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
const handleSlotClick = (index) => {
|
|
110
|
+
if (disabled) return;
|
|
111
|
+
if (innerInputRef.current) {
|
|
112
|
+
innerInputRef.current.focus();
|
|
113
|
+
const pos = Math.min(index, otpValue.length);
|
|
114
|
+
innerInputRef.current.setSelectionRange(pos, pos);
|
|
115
|
+
setCaretPos(pos);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
if (isOtp) {
|
|
119
|
+
const slotSizeClasses = resolvedSize === "sm" ? "h-8 w-8 min-w-[2rem] text-xs" : resolvedSize === "lg" ? "h-12 w-12 min-w-[3rem] text-base" : "h-10 w-10 min-w-[2.5rem] text-sm";
|
|
120
|
+
const otpSlots = /* @__PURE__ */ jsxs(
|
|
121
|
+
"div",
|
|
122
|
+
{
|
|
123
|
+
className: cn(
|
|
124
|
+
"relative inline-flex items-center gap-2 select-none cursor-text",
|
|
125
|
+
disabled && "opacity-50 cursor-not-allowed",
|
|
126
|
+
className
|
|
127
|
+
),
|
|
128
|
+
onClick: () => {
|
|
129
|
+
if (!disabled && innerInputRef.current) {
|
|
130
|
+
innerInputRef.current.focus();
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
children: [
|
|
134
|
+
/* @__PURE__ */ jsx(
|
|
135
|
+
"input",
|
|
136
|
+
{
|
|
137
|
+
ref: (node) => {
|
|
138
|
+
innerInputRef.current = node;
|
|
139
|
+
if (typeof ref === "function") ref(node);
|
|
140
|
+
else if (ref) ref.current = node;
|
|
141
|
+
},
|
|
142
|
+
id: inputId,
|
|
143
|
+
type: "text",
|
|
144
|
+
inputMode: "numeric",
|
|
145
|
+
pattern: "[0-9]*",
|
|
146
|
+
autoComplete: "one-time-code",
|
|
147
|
+
maxLength: numLength,
|
|
148
|
+
value: otpValue,
|
|
149
|
+
onChange: handleOtpChange,
|
|
150
|
+
onFocus: () => {
|
|
151
|
+
setIsFocused(true);
|
|
152
|
+
syncCaret();
|
|
153
|
+
},
|
|
154
|
+
onBlur: () => setIsFocused(false),
|
|
155
|
+
onKeyUp: syncCaret,
|
|
156
|
+
onKeyDown: syncCaret,
|
|
157
|
+
onSelect: syncCaret,
|
|
158
|
+
disabled,
|
|
159
|
+
className: "absolute inset-0 h-full w-full opacity-0 z-20 cursor-text select-none text-transparent bg-transparent caret-transparent",
|
|
160
|
+
...props,
|
|
161
|
+
...fieldA11y
|
|
162
|
+
}
|
|
163
|
+
),
|
|
164
|
+
/* @__PURE__ */ jsx("div", { className: "relative z-10 flex items-center gap-2 select-none pointer-events-none", children: Array.from({ length: numLength }).map((_, i) => {
|
|
165
|
+
const digit = otpValue[i];
|
|
166
|
+
const hasValue = digit !== void 0 && digit !== "";
|
|
167
|
+
const activeSlotIndex = Math.min(otpValue.length, numLength - 1);
|
|
168
|
+
const isSlotActive = isFocused && i === activeSlotIndex;
|
|
169
|
+
return /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
|
170
|
+
effectiveSeparator && i === effectiveSepIndex && /* @__PURE__ */ jsx("span", { className: "text-fg-muted font-mono px-0.5 select-none text-sm shrink-0", children: effectiveSeparator }),
|
|
171
|
+
/* @__PURE__ */ jsxs(
|
|
172
|
+
"div",
|
|
173
|
+
{
|
|
174
|
+
className: cn(
|
|
175
|
+
"relative shrink-0 flex items-center justify-center font-mono font-normal rounded-[var(--radius-lg)] border bg-surface transition-all text-fg",
|
|
176
|
+
slotSizeClasses,
|
|
177
|
+
// Slot boxes are the visible field: 3:1 control border (WCAG 1.4.11); the active
|
|
178
|
+
// slot shows the same 2px focus ring as other inputs (WCAG 2.4.7).
|
|
179
|
+
invalid ? "border-danger ring-2 ring-danger/20 text-danger" : isSlotActive ? "border-transparent outline [outline-width:var(--focus-width)] [outline-offset:var(--focus-offset-inset)] outline-[rgb(var(--focus))] text-fg shadow-1" : hasValue ? "border-border-control text-fg" : "border-border-control text-fg-muted",
|
|
180
|
+
slotClassName
|
|
181
|
+
),
|
|
182
|
+
children: [
|
|
183
|
+
hasValue ? /* @__PURE__ */ jsx("span", { className: "font-mono select-none", children: mask ? "\u2022" : digit }) : null,
|
|
184
|
+
isSlotActive && !hasValue && /* @__PURE__ */ jsx(
|
|
185
|
+
"span",
|
|
186
|
+
{
|
|
187
|
+
className: "h-4 w-[1.5px] bg-brand rounded-full",
|
|
188
|
+
style: { animation: "caret-blink 1s steps(2, start) infinite" }
|
|
189
|
+
}
|
|
190
|
+
)
|
|
191
|
+
]
|
|
192
|
+
}
|
|
193
|
+
)
|
|
194
|
+
] }, i);
|
|
195
|
+
}) })
|
|
196
|
+
]
|
|
197
|
+
}
|
|
198
|
+
);
|
|
199
|
+
if (!label && !hint && !errorMessage) return otpSlots;
|
|
200
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5 w-full", children: [
|
|
201
|
+
label && /* @__PURE__ */ jsx("label", { htmlFor: inputId, className: cn("text-xs font-semibold text-fg-muted", resolvedSize === "sm" && "text-[11px]"), children: label }),
|
|
202
|
+
otpSlots,
|
|
203
|
+
errorMessage ? /* @__PURE__ */ jsxs("span", { id: errorId, className: cn("flex items-start gap-1 text-xs text-danger", resolvedSize === "sm" && "text-[11px]"), children: [
|
|
204
|
+
/* @__PURE__ */ jsx(CircleAlert, { "aria-hidden": "true", className: "mt-px h-3.5 w-3.5 shrink-0" }),
|
|
205
|
+
errorMessage
|
|
206
|
+
] }) : hint ? /* @__PURE__ */ jsx("span", { id: hintId, className: cn("text-xs text-fg-subtle", resolvedSize === "sm" && "text-[11px]"), children: hint }) : null
|
|
207
|
+
] });
|
|
208
|
+
}
|
|
209
|
+
const hasLeading = !!leadingIcon;
|
|
210
|
+
const isPassword = (type ?? "text").toLowerCase() === "password";
|
|
211
|
+
const usePwToggle = isPassword && showHidePassword !== false;
|
|
212
|
+
const hasTrailingIcon = !!trailingIcon;
|
|
213
|
+
const hasTrailing = hasTrailingIcon || usePwToggle;
|
|
214
|
+
const effectiveType = usePwToggle && pwVisible ? "text" : isPassword && mask ? "password" : type;
|
|
215
|
+
const hasBothTrailing = hasTrailingIcon && usePwToggle;
|
|
216
|
+
const trailingPad = hasBothTrailing ? resolvedSize === "sm" ? "pr-16" : resolvedSize === "lg" ? "pr-20" : "pr-[72px]" : resolvedSize === "sm" ? "pr-8" : resolvedSize === "lg" ? "pr-10" : "pr-9";
|
|
217
|
+
const input = /* @__PURE__ */ jsx(
|
|
218
|
+
"input",
|
|
219
|
+
{
|
|
220
|
+
ref,
|
|
221
|
+
id: inputId,
|
|
222
|
+
type: effectiveType,
|
|
223
|
+
value,
|
|
224
|
+
defaultValue,
|
|
225
|
+
onChange,
|
|
226
|
+
disabled,
|
|
227
|
+
className: cn(
|
|
228
|
+
textFieldVariants({ variant, size, invalid: invalid || Boolean(errorMessage) }),
|
|
229
|
+
hitAreaClass(hitArea, "input", "TextField"),
|
|
230
|
+
hasLeading && (resolvedSize === "sm" ? "pl-8" : resolvedSize === "lg" ? "pl-10" : "pl-9"),
|
|
231
|
+
hasTrailing && trailingPad,
|
|
232
|
+
className
|
|
233
|
+
),
|
|
234
|
+
...props,
|
|
235
|
+
...fieldA11y
|
|
236
|
+
}
|
|
237
|
+
);
|
|
238
|
+
const field = !hasLeading && !hasTrailing ? input : /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
|
|
239
|
+
leadingIcon && /* @__PURE__ */ jsx(
|
|
240
|
+
"span",
|
|
241
|
+
{
|
|
242
|
+
className: cn(
|
|
243
|
+
"pointer-events-none absolute inset-y-0 left-0 flex items-center text-fg-muted",
|
|
244
|
+
resolvedSize === "sm" ? "pl-2.5" : resolvedSize === "lg" ? "pl-3.5" : "pl-3"
|
|
245
|
+
),
|
|
246
|
+
children: leadingIcon
|
|
247
|
+
}
|
|
248
|
+
),
|
|
249
|
+
input,
|
|
250
|
+
hasTrailingIcon && /* @__PURE__ */ jsx(
|
|
251
|
+
"span",
|
|
252
|
+
{
|
|
253
|
+
className: cn(
|
|
254
|
+
"pointer-events-none absolute inset-y-0 flex items-center text-fg-muted",
|
|
255
|
+
usePwToggle ? resolvedSize === "sm" ? "right-8" : resolvedSize === "lg" ? "right-10" : "right-9" : "right-0",
|
|
256
|
+
resolvedSize === "sm" ? "pr-2.5" : resolvedSize === "lg" ? "pr-3.5" : "pr-3"
|
|
257
|
+
),
|
|
258
|
+
children: trailingIcon
|
|
259
|
+
}
|
|
260
|
+
),
|
|
261
|
+
usePwToggle && /* @__PURE__ */ jsx(
|
|
262
|
+
"button",
|
|
263
|
+
{
|
|
264
|
+
type: "button",
|
|
265
|
+
"aria-label": "Show password",
|
|
266
|
+
"aria-pressed": pwVisible,
|
|
267
|
+
onClick: () => setPwVisible((v) => !v),
|
|
268
|
+
className: cn(
|
|
269
|
+
"hit-area-touch absolute inset-y-0 right-0 flex min-w-7 items-center justify-end text-fg-muted hover:text-fg transition-colors",
|
|
270
|
+
resolvedSize === "sm" ? "pr-2.5" : resolvedSize === "lg" ? "pr-3.5" : "pr-3",
|
|
271
|
+
hitAreaClass(hitArea, "touch", "TextField")
|
|
272
|
+
),
|
|
273
|
+
children: pwVisible ? /* @__PURE__ */ jsx(EyeOff, { className: "h-4 w-4" }) : /* @__PURE__ */ jsx(Eye, { className: "h-4 w-4" })
|
|
274
|
+
}
|
|
275
|
+
)
|
|
276
|
+
] });
|
|
277
|
+
if (!label && !hint && !errorMessage) return field;
|
|
278
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1 w-full", children: [
|
|
279
|
+
label && /* @__PURE__ */ jsx("label", { htmlFor: inputId, className: cn("text-xs font-semibold text-fg-muted", resolvedSize === "sm" && "text-[11px]"), children: label }),
|
|
280
|
+
field,
|
|
281
|
+
errorMessage ? /* @__PURE__ */ jsxs("span", { id: errorId, className: cn("flex items-start gap-1 text-xs text-danger", resolvedSize === "sm" && "text-[11px]"), children: [
|
|
282
|
+
/* @__PURE__ */ jsx(CircleAlert, { "aria-hidden": "true", className: "mt-px h-3.5 w-3.5 shrink-0" }),
|
|
283
|
+
errorMessage
|
|
284
|
+
] }) : hint ? /* @__PURE__ */ jsx("span", { id: hintId, className: cn("text-xs text-fg-subtle", resolvedSize === "sm" && "text-[11px]"), children: hint }) : null
|
|
285
|
+
] });
|
|
286
|
+
});
|
|
287
|
+
export {
|
|
288
|
+
TextField,
|
|
289
|
+
textFieldVariants
|
|
290
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
import { scopedThemeVars, isBrandSolidMode } from "../../lib/theme-presets.js";
|
|
5
|
+
import { ThemeInheritanceContext, useThemeInheritance } from "./themeContext.js";
|
|
6
|
+
import { cn } from "../../lib/cn.js";
|
|
7
|
+
function ScopedThemeProvider({
|
|
8
|
+
theme,
|
|
9
|
+
appearance = "inherit",
|
|
10
|
+
brandColor,
|
|
11
|
+
grayColor,
|
|
12
|
+
radius,
|
|
13
|
+
scaling,
|
|
14
|
+
displayFont,
|
|
15
|
+
bodyFont,
|
|
16
|
+
panelBackground,
|
|
17
|
+
focusRing,
|
|
18
|
+
colorSpace = "rgb",
|
|
19
|
+
touchTargets,
|
|
20
|
+
brandSolid,
|
|
21
|
+
className,
|
|
22
|
+
style,
|
|
23
|
+
children,
|
|
24
|
+
...rest
|
|
25
|
+
}) {
|
|
26
|
+
const isDark = appearance === "dark" ? true : appearance === "light" ? false : void 0;
|
|
27
|
+
const numericScaling = useMemo(() => {
|
|
28
|
+
if (typeof scaling === "number") return scaling;
|
|
29
|
+
if (typeof scaling === "string") {
|
|
30
|
+
const parsed = parseInt(scaling.replace("%", ""), 10);
|
|
31
|
+
return isNaN(parsed) ? void 0 : parsed;
|
|
32
|
+
}
|
|
33
|
+
return void 0;
|
|
34
|
+
}, [scaling]);
|
|
35
|
+
const inherited = useThemeInheritance();
|
|
36
|
+
const solidMode = isBrandSolidMode(brandSolid) ? brandSolid : inherited.brandSolid;
|
|
37
|
+
const brand = brandColor ?? (isBrandSolidMode(brandSolid) && brandSolid !== inherited.brandSolid ? inherited.brand : void 0);
|
|
38
|
+
const computedVars = useMemo(() => {
|
|
39
|
+
return scopedThemeVars(
|
|
40
|
+
brand,
|
|
41
|
+
grayColor,
|
|
42
|
+
radius,
|
|
43
|
+
isDark ?? false,
|
|
44
|
+
displayFont,
|
|
45
|
+
bodyFont,
|
|
46
|
+
numericScaling,
|
|
47
|
+
colorSpace,
|
|
48
|
+
solidMode
|
|
49
|
+
);
|
|
50
|
+
}, [brand, grayColor, radius, isDark, displayFont, bodyFont, numericScaling, colorSpace, solidMode]);
|
|
51
|
+
const nested = useMemo(() => ({ brandSolid: solidMode, brand: brandColor ?? inherited.brand }), [solidMode, brandColor, inherited.brand]);
|
|
52
|
+
return /* @__PURE__ */ jsx(ThemeInheritanceContext.Provider, { value: nested, children: /* @__PURE__ */ jsx(
|
|
53
|
+
"div",
|
|
54
|
+
{
|
|
55
|
+
"data-touch-targets": touchTargets,
|
|
56
|
+
"data-focus-ring": focusRing,
|
|
57
|
+
"data-brand-solid": brand ? solidMode : void 0,
|
|
58
|
+
"data-theme": appearance === "dark" ? "dark" : appearance === "light" ? "light" : void 0,
|
|
59
|
+
className: cn(appearance === "dark" && "dark", className),
|
|
60
|
+
style: {
|
|
61
|
+
...computedVars,
|
|
62
|
+
...style
|
|
63
|
+
},
|
|
64
|
+
...rest,
|
|
65
|
+
children
|
|
66
|
+
}
|
|
67
|
+
) });
|
|
68
|
+
}
|
|
69
|
+
export {
|
|
70
|
+
ScopedThemeProvider
|
|
71
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const docs = {
|
|
2
|
+
name: "ThemeProvider",
|
|
3
|
+
description: "Global runtime design system theme provider mutating CSS variables on document root for brand colours, radius, and scaling.",
|
|
4
|
+
features: [
|
|
5
|
+
"Configures brand color palette, gray scale, radius preset, scaling, and fonts",
|
|
6
|
+
"Applies CSS variable mutations globally on :root element",
|
|
7
|
+
"Integrates preset themes (e.g. Editorial, Corporate, Modern)",
|
|
8
|
+
"focusRing sets the keyboard focus ring weight for the page: subtle (default, 1px), default (2px) or strong (3px); ScopedThemeProvider takes the same prop and inherits when unset. Tune --focus-width / --focus-offset in CSS for anything else",
|
|
9
|
+
'brandSolid chooses the fill under text on the brand (solid Button, Badge, selected states): "accessible" (default) darkens the brand just enough for white text at 4.6:1, "exact" keeps the exact brand fill, "perceptual" keeps it and picks text by APCA (not WCAG 2 AA on every brand)',
|
|
10
|
+
'neutrals: "neutral" (default) keeps the plain grey. Opt in with neutrals="brand" to tint the greys toward the brand hue at very low chroma, with the same lightness as the plain greys so contrast is unchanged; it wins over a gray preset, and grey or monochrome brands never tint. neutralsAmount (with neutrals="brand"): "subtle" (default) or "medium"',
|
|
11
|
+
"Can be used standalone or wrapping application root",
|
|
12
|
+
'touchTargets: "comfortable" (default) grows primary controls to 44px on touch; "compact" keeps their size (the 24px WCAG 2.5.8 floor stays). Tune with --tap-min and --tap-min-touch',
|
|
13
|
+
'ScopedThemeProvider touchTargets: unset inherits from the nearest parent provider (it is not an explicit "comfortable"), so a compact page keeps unset scoped islands compact; pass "comfortable" or "compact" to override'
|
|
14
|
+
],
|
|
15
|
+
accessibility: [
|
|
16
|
+
"Text and control-boundary colours meet WCAG 2.2 AA contrast (4.5:1 text, 3:1 UI) across dark and light themes",
|
|
17
|
+
"Target size: meets WCAG 2.2 AA 2.5.8 (24px) at every pointer; 44px on touch is a comfortable default, not a claim",
|
|
18
|
+
'Focus ring colour is the contrast-guaranteed brand text colour (at least 3:1 against page fills for any brand, WCAG 1.4.11) in every focusRing mode. WCAG 2.4.13 Focus Appearance (AAA) is not claimed for the subtle default; use focusRing="default" or "strong" if you target it',
|
|
19
|
+
'Brand text and the solid brand fill are contrast-guaranteed for any brand colour: --brand-text >= 4.6:1 on every page surface, --brand-fg >= 4.5:1 on --brand-solid and --brand-solid-hover (brandSolid="accessible", the default)',
|
|
20
|
+
'brandSolid="perceptual" does not meet WCAG 2 AA on 14 of the 24 shipped brand colours; development builds log a one-time warning',
|
|
21
|
+
"Overriding --brand-solid, --brand-solid-hover or --brand-fg in your own CSS bypasses the guarantee; keep --brand-fg at 4.5:1 or more on both fills (shavin doctor checks literal overrides)"
|
|
22
|
+
],
|
|
23
|
+
usage: {
|
|
24
|
+
bestPractices: [
|
|
25
|
+
{
|
|
26
|
+
guidance: true,
|
|
27
|
+
description: "Mount ThemeProvider once near application root to apply active theme presets."
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
guidance: false,
|
|
31
|
+
description: "Do not wrap individual small components in multiple nested ThemeProviders \u2014 tokens are global on document root."
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
examples: [
|
|
36
|
+
{
|
|
37
|
+
title: "Keep the exact brand fill under button text",
|
|
38
|
+
code: '<ThemeProvider brandColor="Blue" brandSolid="exact" />'
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
title: "Root Theme Initialization",
|
|
42
|
+
code: '<ThemeProvider brandColor="Monochrome" grayColor="Zinc" radius="large" scaling={100} panelBackground="solid" />'
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
title: "Brand-tinted greys (opt in), subtle or stronger",
|
|
46
|
+
code: '<ThemeProvider brandColor="Tomato" neutrals="brand" />\n<ThemeProvider brandColor="Tomato" neutrals="brand" neutralsAmount="medium" />'
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
title: "Compact touch targets (dense product UI)",
|
|
50
|
+
code: '<ThemeProvider touchTargets="compact" />'
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
title: "Focus ring weight",
|
|
54
|
+
description: 'Thin 1px ring by default (focusRing="subtle"); opt back into the 2px ring or go stronger.',
|
|
55
|
+
code: '<ThemeProvider brandColor="Indigo" focusRing="default" />'
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
};
|
|
59
|
+
export {
|
|
60
|
+
docs
|
|
61
|
+
};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useLayoutEffect, useMemo } from "react";
|
|
4
|
+
import {
|
|
5
|
+
applyBrandColor,
|
|
6
|
+
applyGrayColor,
|
|
7
|
+
applyNeutralsTint,
|
|
8
|
+
applyPanelBackground,
|
|
9
|
+
applyRadiusPreset,
|
|
10
|
+
applyScalingPreset,
|
|
11
|
+
applyDisplayFontPreset,
|
|
12
|
+
applyBodyFontPreset,
|
|
13
|
+
applySubheadingFont,
|
|
14
|
+
applyThemePreset,
|
|
15
|
+
preloadGoogleFontsBundle,
|
|
16
|
+
resolveThemeConfig,
|
|
17
|
+
themeCss,
|
|
18
|
+
setBrandSolidMode,
|
|
19
|
+
perceptualAaFailures
|
|
20
|
+
} from "../../lib/theme-presets.js";
|
|
21
|
+
import { ThemeInheritanceContext } from "./themeContext.js";
|
|
22
|
+
import { setColorSpace } from "../../lib/color-space.js";
|
|
23
|
+
import { ThemeScript } from "../ThemeSwitcher/index.js";
|
|
24
|
+
import { ShavinDevTools } from "../ShavinDevTools/index.js";
|
|
25
|
+
import { initMotionRuntime } from "../../lib/motion-runtime.js";
|
|
26
|
+
import { resolveClientTheme } from "./clientTheme.js";
|
|
27
|
+
const useIsoLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
|
|
28
|
+
const warnedPerceptual = /* @__PURE__ */ new Set();
|
|
29
|
+
function warnPerceptualOnce(mode) {
|
|
30
|
+
if (mode !== "perceptual" || process.env.NODE_ENV === "production" || typeof window === "undefined") return;
|
|
31
|
+
if (warnedPerceptual.has(mode)) return;
|
|
32
|
+
warnedPerceptual.add(mode);
|
|
33
|
+
const light = perceptualAaFailures(false);
|
|
34
|
+
const dark = perceptualAaFailures(true);
|
|
35
|
+
const total = new Set([...light, ...dark].map((f) => f.name)).size;
|
|
36
|
+
console.warn(
|
|
37
|
+
`[shavin] ThemeProvider brandSolid="perceptual": text on solid brand fills (Button, Badge, selected states) is white wherever APCA prefers it, which does NOT meet WCAG 2 AA (4.5:1) on ${total} of the 24 shipped brand colours (e.g. ${light.slice(0, 3).map((f) => `${f.name} ${f.ratio.toFixed(2)}:1`).join(", ")}), so an accessibility audit against WCAG 2 AA will fail on them. To restore the guarantee, remove the prop or set brandSolid="accessible".`
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
function ThemeProvider({
|
|
41
|
+
theme,
|
|
42
|
+
defaultTheme = "system",
|
|
43
|
+
brandColor,
|
|
44
|
+
grayColor,
|
|
45
|
+
radius,
|
|
46
|
+
scaling,
|
|
47
|
+
panelBackground,
|
|
48
|
+
displayFont,
|
|
49
|
+
bodyFont,
|
|
50
|
+
subheadingFont,
|
|
51
|
+
focusRing,
|
|
52
|
+
brandSolid = "accessible",
|
|
53
|
+
neutrals,
|
|
54
|
+
neutralsAmount,
|
|
55
|
+
colorSpace = "rgb",
|
|
56
|
+
preloadFonts,
|
|
57
|
+
devTools,
|
|
58
|
+
bridgePort,
|
|
59
|
+
touchTargets = "comfortable",
|
|
60
|
+
children
|
|
61
|
+
}) {
|
|
62
|
+
const { translucentPanels: translucentForTheme } = resolveThemeConfig({ theme, brandColor, grayColor, radius, panelBackground, displayFont, bodyFont });
|
|
63
|
+
useIsoLayoutEffect(() => resolveClientTheme({ defaultTheme, translucentPanels: translucentForTheme }) ?? void 0, []);
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
initMotionRuntime();
|
|
66
|
+
}, []);
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
const root = document.documentElement;
|
|
69
|
+
root.setAttribute("data-touch-targets", touchTargets);
|
|
70
|
+
return () => root.removeAttribute("data-touch-targets");
|
|
71
|
+
}, [touchTargets]);
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
setColorSpace(colorSpace);
|
|
74
|
+
}, [colorSpace]);
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
setBrandSolidMode(brandSolid);
|
|
77
|
+
warnPerceptualOnce(brandSolid);
|
|
78
|
+
}, [brandSolid]);
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
if (preloadFonts) preloadGoogleFontsBundle();
|
|
81
|
+
}, [preloadFonts]);
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
if (theme) {
|
|
84
|
+
applyThemePreset(theme);
|
|
85
|
+
} else if (!brandColor && !grayColor && !radius && !displayFont && !bodyFont) {
|
|
86
|
+
applyThemePreset("Monochrome");
|
|
87
|
+
}
|
|
88
|
+
}, [theme, brandColor, grayColor, radius, displayFont, bodyFont, scaling]);
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
if (brandColor) applyBrandColor(brandColor);
|
|
91
|
+
}, [brandColor]);
|
|
92
|
+
useEffect(() => {
|
|
93
|
+
if (grayColor) applyGrayColor(grayColor);
|
|
94
|
+
}, [grayColor]);
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
const t = resolveThemeConfig({ theme, brandColor, grayColor, neutrals, neutralsAmount }).neutralsTint;
|
|
97
|
+
applyNeutralsTint(t?.brand, t?.amount);
|
|
98
|
+
}, [theme, brandColor, grayColor, neutrals, neutralsAmount, colorSpace]);
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
if (radius) applyRadiusPreset(radius);
|
|
101
|
+
}, [radius]);
|
|
102
|
+
useEffect(() => {
|
|
103
|
+
if (scaling) applyScalingPreset(scaling);
|
|
104
|
+
}, [scaling]);
|
|
105
|
+
useEffect(() => {
|
|
106
|
+
if (panelBackground) applyPanelBackground(panelBackground === "translucent");
|
|
107
|
+
}, [panelBackground]);
|
|
108
|
+
useEffect(() => {
|
|
109
|
+
if (displayFont) applyDisplayFontPreset(displayFont);
|
|
110
|
+
}, [displayFont]);
|
|
111
|
+
useEffect(() => {
|
|
112
|
+
if (bodyFont) applyBodyFontPreset(bodyFont);
|
|
113
|
+
}, [bodyFont]);
|
|
114
|
+
useEffect(() => {
|
|
115
|
+
applySubheadingFont(subheadingFont ?? "body");
|
|
116
|
+
}, [subheadingFont]);
|
|
117
|
+
useEffect(() => {
|
|
118
|
+
const root = document.documentElement;
|
|
119
|
+
if (focusRing) root.setAttribute("data-focus-ring", focusRing);
|
|
120
|
+
else root.removeAttribute("data-focus-ring");
|
|
121
|
+
}, [focusRing]);
|
|
122
|
+
const showDevTools = devTools ?? process.env.NODE_ENV !== "production";
|
|
123
|
+
const resolved = resolveThemeConfig({ theme, brandColor, grayColor, radius, scaling, panelBackground, displayFont, bodyFont, subheadingFont, brandSolid, neutrals, neutralsAmount });
|
|
124
|
+
const configSig = JSON.stringify([theme, resolved]);
|
|
125
|
+
useEffect(() => {
|
|
126
|
+
const detail = { theme, ...resolved };
|
|
127
|
+
window.__SHAVIN_THEME_CONFIG__ = detail;
|
|
128
|
+
window.dispatchEvent(new CustomEvent("shavin-theme-init", { detail }));
|
|
129
|
+
}, [configSig]);
|
|
130
|
+
const css = themeCss({ theme, brandColor, grayColor, radius, scaling, displayFont, bodyFont, subheadingFont, brandSolid, neutrals, neutralsAmount, colorSpace });
|
|
131
|
+
const inheritance = useMemo(() => ({ brandSolid: resolved.brandSolid, brand: resolved.brand }), [resolved.brandSolid, resolved.brand]);
|
|
132
|
+
const { translucentPanels } = resolveThemeConfig({ theme, brandColor, grayColor, radius, panelBackground, displayFont, bodyFont });
|
|
133
|
+
return /* @__PURE__ */ jsxs(ThemeInheritanceContext.Provider, { value: inheritance, children: [
|
|
134
|
+
touchTargets === "compact" ? /* @__PURE__ */ jsx("style", { id: "shavin-touch-targets", dangerouslySetInnerHTML: { __html: ":root{--tap-min-touch:var(--tap-min,24px)}" } }) : null,
|
|
135
|
+
css ? /* @__PURE__ */ jsx("style", { id: "shavin-theme-vars", dangerouslySetInnerHTML: { __html: css } }) : null,
|
|
136
|
+
/* @__PURE__ */ jsx(ThemeScript, { defaultTheme, translucentPanels, focusRing }),
|
|
137
|
+
children ?? null,
|
|
138
|
+
showDevTools && /* @__PURE__ */ jsx(ShavinDevTools, { bridgePort })
|
|
139
|
+
] });
|
|
140
|
+
}
|
|
141
|
+
export {
|
|
142
|
+
ThemeProvider
|
|
143
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { reapplyBrandColor } from "../../lib/theme-presets.js";
|
|
2
|
+
const MARK = "data-shavin-theme-resolved";
|
|
3
|
+
function read(storage, key) {
|
|
4
|
+
try {
|
|
5
|
+
return storage().getItem(key);
|
|
6
|
+
} catch {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
function readThemePreference(storageKey, defaultTheme) {
|
|
11
|
+
return read(() => localStorage, storageKey) || read(() => sessionStorage, storageKey) || read(() => localStorage, "shavin-appearance") || read(() => sessionStorage, "shavin-appearance") || defaultTheme;
|
|
12
|
+
}
|
|
13
|
+
function writeMode(root, dark) {
|
|
14
|
+
if (dark) root.classList.add("dark");
|
|
15
|
+
else root.classList.remove("dark");
|
|
16
|
+
root.setAttribute("data-theme", dark ? "dark" : "light");
|
|
17
|
+
root.style.colorScheme = dark ? "dark" : "light";
|
|
18
|
+
}
|
|
19
|
+
function resolveClientTheme({ storageKey = "shavin-theme", defaultTheme = "system", translucentPanels = false } = {}) {
|
|
20
|
+
if (typeof document === "undefined") return null;
|
|
21
|
+
const root = document.documentElement;
|
|
22
|
+
const ours = root.getAttribute(MARK) === "1";
|
|
23
|
+
const alreadyResolved = root.hasAttribute("data-theme") || root.classList.contains("dark") || root.classList.contains("light");
|
|
24
|
+
if (alreadyResolved && !ours) return null;
|
|
25
|
+
const mql = typeof window !== "undefined" && window.matchMedia ? window.matchMedia("(prefers-color-scheme: dark)") : null;
|
|
26
|
+
const isDark = (preference2) => preference2 === "dark" || preference2 === "system" && !!mql && mql.matches;
|
|
27
|
+
const preference = readThemePreference(storageKey, defaultTheme);
|
|
28
|
+
if (!ours) {
|
|
29
|
+
root.setAttribute(MARK, "1");
|
|
30
|
+
if (translucentPanels) root.classList.add("translucent-panels");
|
|
31
|
+
writeMode(root, isDark(preference));
|
|
32
|
+
}
|
|
33
|
+
if (preference !== "system" || !mql) return () => {
|
|
34
|
+
};
|
|
35
|
+
const onChange = () => {
|
|
36
|
+
const now = readThemePreference(storageKey, defaultTheme);
|
|
37
|
+
if (now !== "system") return;
|
|
38
|
+
writeMode(root, isDark(now));
|
|
39
|
+
reapplyBrandColor();
|
|
40
|
+
};
|
|
41
|
+
mql.addEventListener("change", onChange);
|
|
42
|
+
return () => mql.removeEventListener("change", onChange);
|
|
43
|
+
}
|
|
44
|
+
export {
|
|
45
|
+
readThemePreference,
|
|
46
|
+
resolveClientTheme
|
|
47
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
import { DEFAULT_BRAND_SOLID } from "../../lib/theme-presets.js";
|
|
4
|
+
const ThemeInheritanceContext = createContext({ brandSolid: DEFAULT_BRAND_SOLID });
|
|
5
|
+
function useThemeInheritance() {
|
|
6
|
+
return useContext(ThemeInheritanceContext);
|
|
7
|
+
}
|
|
8
|
+
export {
|
|
9
|
+
ThemeInheritanceContext,
|
|
10
|
+
useThemeInheritance
|
|
11
|
+
};
|