rift-ds 1.0.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/LICENSE +21 -0
- package/README.md +107 -0
- package/behaviors/focusable.d.ts +26 -0
- package/behaviors/focusable.js +18 -0
- package/behaviors/useFocusScope.d.ts +38 -0
- package/behaviors/useFocusScope.js +82 -0
- package/behaviors/useLayer.d.ts +43 -0
- package/behaviors/useLayer.js +55 -0
- package/behaviors/useMounted.d.ts +7 -0
- package/behaviors/useMounted.js +14 -0
- package/behaviors/useScrollLock.d.ts +55 -0
- package/behaviors/useScrollLock.js +59 -0
- package/bin/rift-ds.mjs +82 -0
- package/charts.d.ts +16 -0
- package/charts.js +24 -0
- package/components/Accordion/Accordion.css +119 -0
- package/components/Accordion/Accordion.d.ts +24 -0
- package/components/Accordion/Accordion.js +76 -0
- package/components/AgentPlan/AgentPlan.css +251 -0
- package/components/AgentPlan/AgentPlan.d.ts +41 -0
- package/components/AgentPlan/AgentPlan.js +100 -0
- package/components/AgentRail/AgentRail.css +282 -0
- package/components/AgentRail/AgentRail.d.ts +72 -0
- package/components/AgentRail/AgentRail.js +101 -0
- package/components/AgentStatus/AgentStatus.css +511 -0
- package/components/AgentStatus/AgentStatus.d.ts +41 -0
- package/components/AgentStatus/AgentStatus.js +86 -0
- package/components/AgentStatus/AgentStatusPatterns.d.ts +17 -0
- package/components/AgentStatus/AgentStatusPatterns.js +20 -0
- package/components/AiButton/AiButton.css +559 -0
- package/components/AiButton/AiButton.d.ts +79 -0
- package/components/AiButton/AiButton.js +183 -0
- package/components/Alert/Alert.css +261 -0
- package/components/Alert/Alert.d.ts +25 -0
- package/components/Alert/Alert.js +53 -0
- package/components/AlertDialog/AlertDialog.css +133 -0
- package/components/AlertDialog/AlertDialog.d.ts +29 -0
- package/components/AlertDialog/AlertDialog.js +98 -0
- package/components/AnchorNav/AnchorNav.css +137 -0
- package/components/AnchorNav/AnchorNav.d.ts +40 -0
- package/components/AnchorNav/AnchorNav.js +135 -0
- package/components/AnimatedNumber/AnimatedNumber.css +31 -0
- package/components/AnimatedNumber/AnimatedNumber.d.ts +36 -0
- package/components/AnimatedNumber/AnimatedNumber.js +55 -0
- package/components/AppLayout/AppLayout.css +52 -0
- package/components/AppLayout/AppLayout.d.ts +33 -0
- package/components/AppLayout/AppLayout.js +47 -0
- package/components/AppSidebar/AppSidebar.css +592 -0
- package/components/AppSidebar/AppSidebar.d.ts +90 -0
- package/components/AppSidebar/AppSidebar.js +295 -0
- package/components/Avatar/Avatar.css +133 -0
- package/components/Avatar/Avatar.d.ts +20 -0
- package/components/Avatar/Avatar.js +58 -0
- package/components/Avatar/demoAvatars.d.ts +18 -0
- package/components/Avatar/demoAvatars.js +16 -0
- package/components/AvatarGroup/AvatarGroup.css +61 -0
- package/components/AvatarGroup/AvatarGroup.d.ts +32 -0
- package/components/AvatarGroup/AvatarGroup.js +31 -0
- package/components/Badge/Badge.css +67 -0
- package/components/Badge/Badge.d.ts +13 -0
- package/components/Badge/Badge.js +15 -0
- package/components/Banner/Banner.css +110 -0
- package/components/Banner/Banner.d.ts +36 -0
- package/components/Banner/Banner.js +59 -0
- package/components/Breadcrumb/Breadcrumb.css +100 -0
- package/components/Breadcrumb/Breadcrumb.d.ts +25 -0
- package/components/Breadcrumb/Breadcrumb.js +40 -0
- package/components/Button/Button.css +473 -0
- package/components/Button/Button.d.ts +73 -0
- package/components/Button/Button.js +91 -0
- package/components/ButtonGroup/ButtonGroup.css +39 -0
- package/components/ButtonGroup/ButtonGroup.d.ts +13 -0
- package/components/ButtonGroup/ButtonGroup.js +30 -0
- package/components/Card/Card.css +190 -0
- package/components/Card/Card.d.ts +48 -0
- package/components/Card/Card.js +113 -0
- package/components/CardStack/CardStack.css +106 -0
- package/components/CardStack/CardStack.d.ts +44 -0
- package/components/CardStack/CardStack.js +140 -0
- package/components/Carousel/Carousel.css +121 -0
- package/components/Carousel/Carousel.d.ts +25 -0
- package/components/Carousel/Carousel.js +160 -0
- package/components/Chart/AreaChart.d.ts +40 -0
- package/components/Chart/AreaChart.js +101 -0
- package/components/Chart/BarChart.d.ts +36 -0
- package/components/Chart/BarChart.js +107 -0
- package/components/Chart/Chart.css +224 -0
- package/components/Chart/ComboChart.d.ts +40 -0
- package/components/Chart/ComboChart.js +142 -0
- package/components/Chart/LineChart.d.ts +36 -0
- package/components/Chart/LineChart.js +91 -0
- package/components/Chart/PieChart.d.ts +36 -0
- package/components/Chart/PieChart.js +93 -0
- package/components/Chart/RadarChart.d.ts +36 -0
- package/components/Chart/RadarChart.js +92 -0
- package/components/Chart/RadialChart.d.ts +43 -0
- package/components/Chart/RadialChart.js +114 -0
- package/components/Chart/ScatterChart.d.ts +38 -0
- package/components/Chart/ScatterChart.js +99 -0
- package/components/Chart/StackedBarChart.d.ts +36 -0
- package/components/Chart/StackedBarChart.js +98 -0
- package/components/Chart/Treemap.d.ts +35 -0
- package/components/Chart/Treemap.js +95 -0
- package/components/Chart/palette.d.ts +1 -0
- package/components/Chart/palette.js +17 -0
- package/components/ChatHeader/ChatHeader.css +35 -0
- package/components/ChatHeader/ChatHeader.d.ts +30 -0
- package/components/ChatHeader/ChatHeader.js +17 -0
- package/components/ChatMarker/ChatMarker.css +61 -0
- package/components/ChatMarker/ChatMarker.d.ts +22 -0
- package/components/ChatMarker/ChatMarker.js +18 -0
- package/components/ChatMessage/ChatMessage.css +326 -0
- package/components/ChatMessage/ChatMessage.d.ts +74 -0
- package/components/ChatMessage/ChatMessage.js +71 -0
- package/components/ChatThread/ChatThread.css +171 -0
- package/components/ChatThread/ChatThread.d.ts +41 -0
- package/components/ChatThread/ChatThread.js +175 -0
- package/components/Checkbox/Checkbox.css +183 -0
- package/components/Checkbox/Checkbox.d.ts +81 -0
- package/components/Checkbox/Checkbox.js +176 -0
- package/components/Chip/Chip.css +231 -0
- package/components/Chip/Chip.d.ts +27 -0
- package/components/Chip/Chip.js +80 -0
- package/components/CircularButton/CircularButton.css +263 -0
- package/components/CircularButton/CircularButton.d.ts +68 -0
- package/components/CircularButton/CircularButton.js +72 -0
- package/components/CodeBlock/CodeBlock.css +189 -0
- package/components/CodeBlock/CodeBlock.d.ts +23 -0
- package/components/CodeBlock/CodeBlock.js +96 -0
- package/components/CodeDiff/CodeDiff.css +175 -0
- package/components/CodeDiff/CodeDiff.d.ts +58 -0
- package/components/CodeDiff/CodeDiff.js +114 -0
- package/components/ColorPicker/ColorPicker.css +278 -0
- package/components/ColorPicker/ColorPicker.d.ts +50 -0
- package/components/ColorPicker/ColorPicker.js +349 -0
- package/components/ColourSwatch/ColourSwatch.css +88 -0
- package/components/ColourSwatch/ColourSwatch.d.ts +34 -0
- package/components/ColourSwatch/ColourSwatch.js +42 -0
- package/components/Combobox/Combobox.css +384 -0
- package/components/Combobox/Combobox.d.ts +93 -0
- package/components/Combobox/Combobox.js +331 -0
- package/components/CommandPalette/CommandPalette.css +342 -0
- package/components/CommandPalette/CommandPalette.d.ts +62 -0
- package/components/CommandPalette/CommandPalette.js +247 -0
- package/components/Composer/Composer.css +427 -0
- package/components/Composer/Composer.d.ts +97 -0
- package/components/Composer/Composer.js +146 -0
- package/components/ContactCard/ContactCard.css +132 -0
- package/components/ContactCard/ContactCard.d.ts +24 -0
- package/components/ContactCard/ContactCard.js +79 -0
- package/components/ContextMenu/ContextMenu.css +258 -0
- package/components/ContextMenu/ContextMenu.d.ts +26 -0
- package/components/ContextMenu/ContextMenu.js +387 -0
- package/components/ContributionGraph/ContributionGraph.css +169 -0
- package/components/ContributionGraph/ContributionGraph.d.ts +34 -0
- package/components/ContributionGraph/ContributionGraph.js +149 -0
- package/components/DataTable/DataTable.css +109 -0
- package/components/DataTable/DataTable.d.ts +81 -0
- package/components/DataTable/DataTable.js +236 -0
- package/components/DateInput/DateInput.css +127 -0
- package/components/DateInput/DateInput.d.ts +44 -0
- package/components/DateInput/DateInput.js +82 -0
- package/components/DatePicker/DatePicker.css +198 -0
- package/components/DatePicker/DatePicker.d.ts +29 -0
- package/components/DatePicker/DatePicker.js +196 -0
- package/components/Dialog/Dialog.css +178 -0
- package/components/Dialog/Dialog.d.ts +39 -0
- package/components/Dialog/Dialog.js +99 -0
- package/components/Divider/Divider.css +100 -0
- package/components/Divider/Divider.d.ts +18 -0
- package/components/Divider/Divider.js +31 -0
- package/components/DocumentChip/DocumentChip.css +190 -0
- package/components/DocumentChip/DocumentChip.d.ts +41 -0
- package/components/DocumentChip/DocumentChip.js +78 -0
- package/components/Drawer/Drawer.css +262 -0
- package/components/Drawer/Drawer.d.ts +41 -0
- package/components/Drawer/Drawer.js +101 -0
- package/components/Dropdown/Dropdown.css +288 -0
- package/components/Dropdown/Dropdown.d.ts +85 -0
- package/components/Dropdown/Dropdown.js +308 -0
- package/components/DropdownMenu/DropdownMenu.css +301 -0
- package/components/DropdownMenu/DropdownMenu.d.ts +42 -0
- package/components/DropdownMenu/DropdownMenu.js +371 -0
- package/components/EmptyState/EmptyState.css +136 -0
- package/components/EmptyState/EmptyState.d.ts +27 -0
- package/components/EmptyState/EmptyState.js +32 -0
- package/components/EntityCard/EntityCard.css +69 -0
- package/components/EntityCard/EntityCard.d.ts +19 -0
- package/components/EntityCard/EntityCard.js +26 -0
- package/components/EventCalendar/EventCalendar.css +363 -0
- package/components/EventCalendar/EventCalendar.d.ts +59 -0
- package/components/EventCalendar/EventCalendar.js +230 -0
- package/components/Field/Field.css +80 -0
- package/components/Field/Field.d.ts +57 -0
- package/components/Field/Field.js +70 -0
- package/components/Field/FieldContext.d.ts +42 -0
- package/components/Field/FieldContext.js +8 -0
- package/components/Figure/Figure.css +71 -0
- package/components/Figure/Figure.d.ts +17 -0
- package/components/Figure/Figure.js +26 -0
- package/components/FileInput/FileInput.css +281 -0
- package/components/FileInput/FileInput.d.ts +54 -0
- package/components/FileInput/FileInput.js +205 -0
- package/components/FilterBar/FilterBar.css +202 -0
- package/components/FilterBar/FilterBar.d.ts +55 -0
- package/components/FilterBar/FilterBar.js +249 -0
- package/components/FunnelChart/FunnelChart.css +17 -0
- package/components/FunnelChart/FunnelChart.d.ts +51 -0
- package/components/FunnelChart/FunnelChart.js +96 -0
- package/components/GanttChart/GanttChart.css +326 -0
- package/components/GanttChart/GanttChart.d.ts +82 -0
- package/components/GanttChart/GanttChart.js +202 -0
- package/components/Gauge/Gauge.css +120 -0
- package/components/Gauge/Gauge.d.ts +64 -0
- package/components/Gauge/Gauge.js +111 -0
- package/components/Globe/Globe.css +155 -0
- package/components/Globe/Globe.d.ts +103 -0
- package/components/Globe/Globe.js +416 -0
- package/components/HoverCard/HoverCard.css +125 -0
- package/components/HoverCard/HoverCard.d.ts +29 -0
- package/components/HoverCard/HoverCard.js +83 -0
- package/components/ImageCompare/ImageCompare.css +112 -0
- package/components/ImageCompare/ImageCompare.d.ts +40 -0
- package/components/ImageCompare/ImageCompare.js +134 -0
- package/components/Input/Input.css +150 -0
- package/components/Input/Input.d.ts +45 -0
- package/components/Input/Input.js +99 -0
- package/components/Instructions/Instructions.css +216 -0
- package/components/Instructions/Instructions.d.ts +29 -0
- package/components/Instructions/Instructions.js +32 -0
- package/components/InterruptCard/InterruptCard.css +164 -0
- package/components/InterruptCard/InterruptCard.d.ts +54 -0
- package/components/InterruptCard/InterruptCard.js +57 -0
- package/components/Kbd/Kbd.css +28 -0
- package/components/Kbd/Kbd.d.ts +19 -0
- package/components/Kbd/Kbd.js +14 -0
- package/components/LegendTile/LegendTile.css +60 -0
- package/components/LegendTile/LegendTile.d.ts +30 -0
- package/components/LegendTile/LegendTile.js +21 -0
- package/components/Lightbox/Lightbox.css +210 -0
- package/components/Lightbox/Lightbox.d.ts +45 -0
- package/components/Lightbox/Lightbox.js +109 -0
- package/components/LinkList/LinkList.css +71 -0
- package/components/LinkList/LinkList.d.ts +24 -0
- package/components/LinkList/LinkList.js +42 -0
- package/components/MapCallout/MapCallout.css +46 -0
- package/components/MapCallout/MapCallout.d.ts +29 -0
- package/components/MapCallout/MapCallout.js +17 -0
- package/components/MapLegend/MapLegend.css +88 -0
- package/components/MapLegend/MapLegend.d.ts +40 -0
- package/components/MapLegend/MapLegend.js +68 -0
- package/components/MessageActions/MessageActions.css +85 -0
- package/components/MessageActions/MessageActions.d.ts +38 -0
- package/components/MessageActions/MessageActions.js +40 -0
- package/components/MessageCard/MessageCard.css +163 -0
- package/components/MessageCard/MessageCard.d.ts +35 -0
- package/components/MessageCard/MessageCard.js +30 -0
- package/components/Meter/Meter.css +98 -0
- package/components/Meter/Meter.d.ts +36 -0
- package/components/Meter/Meter.js +48 -0
- package/components/ModelPicker/ModelPicker.css +243 -0
- package/components/ModelPicker/ModelPicker.d.ts +60 -0
- package/components/ModelPicker/ModelPicker.js +261 -0
- package/components/MotionSwatch/MotionSwatch.css +176 -0
- package/components/MotionSwatch/MotionSwatch.d.ts +25 -0
- package/components/MotionSwatch/MotionSwatch.js +74 -0
- package/components/Nav/Nav.css +51 -0
- package/components/Nav/Nav.d.ts +19 -0
- package/components/Nav/Nav.js +26 -0
- package/components/NavList/NavList.css +155 -0
- package/components/NavList/NavList.d.ts +56 -0
- package/components/NavList/NavList.js +100 -0
- package/components/NotificationCenter/NotificationCenter.css +279 -0
- package/components/NotificationCenter/NotificationCenter.d.ts +72 -0
- package/components/NotificationCenter/NotificationCenter.js +145 -0
- package/components/NumberInput/NumberInput.css +163 -0
- package/components/NumberInput/NumberInput.d.ts +44 -0
- package/components/NumberInput/NumberInput.js +147 -0
- package/components/Pagination/Pagination.css +126 -0
- package/components/Pagination/Pagination.d.ts +22 -0
- package/components/Pagination/Pagination.js +84 -0
- package/components/Panel/Panel.css +26 -0
- package/components/Panel/Panel.d.ts +22 -0
- package/components/Panel/Panel.js +19 -0
- package/components/PinInput/PinInput.css +92 -0
- package/components/PinInput/PinInput.d.ts +46 -0
- package/components/PinInput/PinInput.js +161 -0
- package/components/Popover/Popover.css +118 -0
- package/components/Popover/Popover.d.ts +22 -0
- package/components/Popover/Popover.js +113 -0
- package/components/ProgressBar/ProgressBar.css +60 -0
- package/components/ProgressBar/ProgressBar.d.ts +16 -0
- package/components/ProgressBar/ProgressBar.js +27 -0
- package/components/PromptSuggestions/PromptSuggestions.css +264 -0
- package/components/PromptSuggestions/PromptSuggestions.d.ts +68 -0
- package/components/PromptSuggestions/PromptSuggestions.js +87 -0
- package/components/Prose/Prose.css +269 -0
- package/components/Prose/Prose.d.ts +21 -0
- package/components/Prose/Prose.js +14 -0
- package/components/Quote/Quote.css +78 -0
- package/components/Quote/Quote.d.ts +18 -0
- package/components/Quote/Quote.js +26 -0
- package/components/RadioButton/RadioButton.css +151 -0
- package/components/RadioButton/RadioButton.d.ts +90 -0
- package/components/RadioButton/RadioButton.js +138 -0
- package/components/Rating/Rating.css +74 -0
- package/components/Rating/Rating.d.ts +41 -0
- package/components/Rating/Rating.js +124 -0
- package/components/Reasoning/Reasoning.css +291 -0
- package/components/Reasoning/Reasoning.d.ts +55 -0
- package/components/Reasoning/Reasoning.js +99 -0
- package/components/RichDropdown/RichDropdown.css +239 -0
- package/components/RichDropdown/RichDropdown.d.ts +78 -0
- package/components/RichDropdown/RichDropdown.js +227 -0
- package/components/SectionTitle/SectionTitle.css +45 -0
- package/components/SectionTitle/SectionTitle.d.ts +12 -0
- package/components/SectionTitle/SectionTitle.js +22 -0
- package/components/SegmentedControl/SegmentedControl.css +231 -0
- package/components/SegmentedControl/SegmentedControl.d.ts +44 -0
- package/components/SegmentedControl/SegmentedControl.js +240 -0
- package/components/SelectionCard/SelectionCard.css +255 -0
- package/components/SelectionCard/SelectionCard.d.ts +36 -0
- package/components/SelectionCard/SelectionCard.js +102 -0
- package/components/ShaderField/ShaderField.css +24 -0
- package/components/ShaderField/ShaderField.d.ts +68 -0
- package/components/ShaderField/ShaderField.js +55 -0
- package/components/ShaderField/field.glsl.d.ts +39 -0
- package/components/ShaderField/field.glsl.js +178 -0
- package/components/ShaderField/useShaderField.d.ts +103 -0
- package/components/ShaderField/useShaderField.js +410 -0
- package/components/Skeleton/Skeleton.css +81 -0
- package/components/Skeleton/Skeleton.d.ts +16 -0
- package/components/Skeleton/Skeleton.js +30 -0
- package/components/Slider/Slider.css +104 -0
- package/components/Slider/Slider.d.ts +48 -0
- package/components/Slider/Slider.js +86 -0
- package/components/SourceChip/SourceChip.css +111 -0
- package/components/SourceChip/SourceChip.d.ts +32 -0
- package/components/SourceChip/SourceChip.js +31 -0
- package/components/SourceTrail/SourceTrail.css +209 -0
- package/components/SourceTrail/SourceTrail.d.ts +49 -0
- package/components/SourceTrail/SourceTrail.js +108 -0
- package/components/SpacingSwatch/SpacingSwatch.css +108 -0
- package/components/SpacingSwatch/SpacingSwatch.d.ts +20 -0
- package/components/SpacingSwatch/SpacingSwatch.js +50 -0
- package/components/Sparkline/Sparkline.css +76 -0
- package/components/Sparkline/Sparkline.d.ts +51 -0
- package/components/Sparkline/Sparkline.js +116 -0
- package/components/Spinner/Spinner.css +84 -0
- package/components/Spinner/Spinner.d.ts +14 -0
- package/components/Spinner/Spinner.js +42 -0
- package/components/SplitButton/SplitButton.css +93 -0
- package/components/SplitButton/SplitButton.d.ts +43 -0
- package/components/SplitButton/SplitButton.js +67 -0
- package/components/SplitPane/SplitPane.css +106 -0
- package/components/SplitPane/SplitPane.d.ts +36 -0
- package/components/SplitPane/SplitPane.js +130 -0
- package/components/Stat/Stat.css +121 -0
- package/components/Stat/Stat.d.ts +22 -0
- package/components/Stat/Stat.js +36 -0
- package/components/StatusDot/StatusDot.css +104 -0
- package/components/StatusDot/StatusDot.d.ts +34 -0
- package/components/StatusDot/StatusDot.js +23 -0
- package/components/Stepper/Stepper.css +216 -0
- package/components/Stepper/Stepper.d.ts +41 -0
- package/components/Stepper/Stepper.js +61 -0
- package/components/StreamingText/StreamingText.css +40 -0
- package/components/StreamingText/StreamingText.d.ts +62 -0
- package/components/StreamingText/StreamingText.js +49 -0
- package/components/StreamingText/useStreamReveal.d.ts +70 -0
- package/components/StreamingText/useStreamReveal.js +121 -0
- package/components/Swatch/Swatch.css +52 -0
- package/components/Swatch/Swatch.d.ts +34 -0
- package/components/Swatch/Swatch.js +44 -0
- package/components/Table/Table.css +223 -0
- package/components/Table/Table.d.ts +53 -0
- package/components/Table/Table.js +65 -0
- package/components/Tabs/Tabs.css +140 -0
- package/components/Tabs/Tabs.d.ts +28 -0
- package/components/Tabs/Tabs.js +78 -0
- package/components/TagInput/TagInput.css +169 -0
- package/components/TagInput/TagInput.d.ts +43 -0
- package/components/TagInput/TagInput.js +137 -0
- package/components/Textarea/Textarea.css +109 -0
- package/components/Textarea/Textarea.d.ts +43 -0
- package/components/Textarea/Textarea.js +86 -0
- package/components/ThreadPanel/ThreadPanel.css +862 -0
- package/components/ThreadPanel/ThreadPanel.d.ts +175 -0
- package/components/ThreadPanel/ThreadPanel.js +466 -0
- package/components/ThreadTabs/ThreadTabs.css +252 -0
- package/components/ThreadTabs/ThreadTabs.d.ts +54 -0
- package/components/ThreadTabs/ThreadTabs.js +201 -0
- package/components/TimePicker/TimePicker.css +230 -0
- package/components/TimePicker/TimePicker.d.ts +46 -0
- package/components/TimePicker/TimePicker.js +250 -0
- package/components/Timeline/Timeline.css +366 -0
- package/components/Timeline/Timeline.d.ts +67 -0
- package/components/Timeline/Timeline.js +73 -0
- package/components/Toast/Toast.css +363 -0
- package/components/Toast/Toast.d.ts +63 -0
- package/components/Toast/Toast.js +215 -0
- package/components/ToggleGroup/ToggleGroup.css +110 -0
- package/components/ToggleGroup/ToggleGroup.d.ts +50 -0
- package/components/ToggleGroup/ToggleGroup.js +73 -0
- package/components/ToggleSwitch/ToggleSwitch.css +172 -0
- package/components/ToggleSwitch/ToggleSwitch.d.ts +43 -0
- package/components/ToggleSwitch/ToggleSwitch.js +76 -0
- package/components/ToolCall/ToolCall.css +234 -0
- package/components/ToolCall/ToolCall.d.ts +43 -0
- package/components/ToolCall/ToolCall.js +90 -0
- package/components/Toolbar/Toolbar.css +56 -0
- package/components/Toolbar/Toolbar.d.ts +35 -0
- package/components/Toolbar/Toolbar.js +62 -0
- package/components/Tooltip/Tooltip.css +175 -0
- package/components/Tooltip/Tooltip.d.ts +22 -0
- package/components/Tooltip/Tooltip.js +74 -0
- package/components/TreeView/TreeView.css +119 -0
- package/components/TreeView/TreeView.d.ts +45 -0
- package/components/TreeView/TreeView.js +232 -0
- package/components/TypographySwatch/TypographySwatch.css +81 -0
- package/components/TypographySwatch/TypographySwatch.d.ts +24 -0
- package/components/TypographySwatch/TypographySwatch.js +40 -0
- package/components/UsageCard/UsageCard.css +30 -0
- package/components/UsageCard/UsageCard.d.ts +48 -0
- package/components/UsageCard/UsageCard.js +54 -0
- package/components/Waveform/Waveform.css +97 -0
- package/components/Waveform/Waveform.d.ts +44 -0
- package/components/Waveform/Waveform.js +46 -0
- package/components/WorldMap/WorldMap.css +234 -0
- package/components/WorldMap/WorldMap.d.ts +113 -0
- package/components/WorldMap/WorldMap.js +427 -0
- package/components/WorldMap/land.d.ts +14 -0
- package/components/WorldMap/land.js +4 -0
- package/components/registry.d.ts +79 -0
- package/components/registry.js +13 -0
- package/components/registry.json +1153 -0
- package/components/registry.json.d.ts +1156 -0
- package/components/registry.json.js +11 -0
- package/fonts/MaterialSymbolsRounded-VariableFont_FILL,GRAD,opsz,wght.woff2 +0 -0
- package/fonts/material-symbols.css +94 -0
- package/fonts/presets/dm-sans-300-700-latin-ext.woff2 +0 -0
- package/fonts/presets/dm-sans-300-700-latin.woff2 +0 -0
- package/fonts/presets/fraunces-300-700-latin-ext.woff2 +0 -0
- package/fonts/presets/fraunces-300-700-latin.woff2 +0 -0
- package/fonts/presets/ibm-plex-mono-300-latin-ext.woff2 +0 -0
- package/fonts/presets/ibm-plex-mono-300-latin.woff2 +0 -0
- package/fonts/presets/ibm-plex-mono-400-latin-ext.woff2 +0 -0
- package/fonts/presets/ibm-plex-mono-400-latin.woff2 +0 -0
- package/fonts/presets/ibm-plex-mono-500-latin-ext.woff2 +0 -0
- package/fonts/presets/ibm-plex-mono-500-latin.woff2 +0 -0
- package/fonts/presets/ibm-plex-mono-600-latin-ext.woff2 +0 -0
- package/fonts/presets/ibm-plex-mono-600-latin.woff2 +0 -0
- package/fonts/presets/ibm-plex-mono-700-latin-ext.woff2 +0 -0
- package/fonts/presets/ibm-plex-mono-700-latin.woff2 +0 -0
- package/fonts/presets/ibm-plex-sans-300-700-latin-ext.woff2 +0 -0
- package/fonts/presets/ibm-plex-sans-300-700-latin.woff2 +0 -0
- package/fonts/presets/inter-300-700-latin-ext.woff2 +0 -0
- package/fonts/presets/inter-300-700-latin.woff2 +0 -0
- package/fonts/presets/inter-tight-300-900-latin-ext.woff2 +0 -0
- package/fonts/presets/inter-tight-300-900-latin.woff2 +0 -0
- package/fonts/presets/lora-400-700-latin-ext.woff2 +0 -0
- package/fonts/presets/lora-400-700-latin.woff2 +0 -0
- package/fonts/presets/montserrat-300-700-latin-ext.woff2 +0 -0
- package/fonts/presets/montserrat-300-700-latin.woff2 +0 -0
- package/fonts/presets/poppins-300-latin-ext.woff2 +0 -0
- package/fonts/presets/poppins-300-latin.woff2 +0 -0
- package/fonts/presets/poppins-400-latin-ext.woff2 +0 -0
- package/fonts/presets/poppins-400-latin.woff2 +0 -0
- package/fonts/presets/poppins-500-latin-ext.woff2 +0 -0
- package/fonts/presets/poppins-500-latin.woff2 +0 -0
- package/fonts/presets/poppins-600-latin-ext.woff2 +0 -0
- package/fonts/presets/poppins-600-latin.woff2 +0 -0
- package/fonts/presets/poppins-700-latin-ext.woff2 +0 -0
- package/fonts/presets/poppins-700-latin.woff2 +0 -0
- package/fonts/presets/source-sans-3-300-700-latin-ext.woff2 +0 -0
- package/fonts/presets/source-sans-3-300-700-latin.woff2 +0 -0
- package/fonts/presets/space-grotesk-300-700-latin-ext.woff2 +0 -0
- package/fonts/presets/space-grotesk-300-700-latin.woff2 +0 -0
- package/fonts/presets/work-sans-300-700-latin-ext.woff2 +0 -0
- package/fonts/presets/work-sans-300-700-latin.woff2 +0 -0
- package/index.d.ts +132 -0
- package/index.js +277 -0
- package/package.json +87 -0
- package/tokens/motion.d.ts +44 -0
- package/tokens/motion.js +32 -0
- package/tokens/presets/contrast.css +316 -0
- package/tokens/presets/coral.css +356 -0
- package/tokens/presets/forest.css +334 -0
- package/tokens/presets/gold.css +303 -0
- package/tokens/presets/mono.css +286 -0
- package/tokens/presets/pink.css +349 -0
- package/tokens/presets/presets.css +17 -0
- package/tokens/presets/terminal.css +378 -0
- package/tokens/presets/violet.css +314 -0
- package/tokens/presets/warm.css +320 -0
- package/tokens/presets/zest.css +359 -0
- package/tokens/registry.d.ts +22 -0
- package/tokens/registry.js +14 -0
- package/tokens/registry.json +276 -0
- package/tokens/registry.json.d.ts +279 -0
- package/tokens/registry.json.js +8 -0
- package/tokens/tokens-dark.css +186 -0
- package/tokens/tokens-light.css +276 -0
- package/tokens/tokens-motion.css +72 -0
- package/tokens/tokens-primitives.css +213 -0
- package/tokens/tokens-typography.css +210 -0
- package/tokens/tokens.css +11 -0
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
/* ============================================
|
|
2
|
+
COLORPICKER COMPONENT
|
|
3
|
+
Swatch trigger + saturation/hue/alpha panel
|
|
4
|
+
|
|
5
|
+
Colour-mixing constants: the white/black
|
|
6
|
+
gradient overlays and the hue spectrum are
|
|
7
|
+
colour-space physics, not theme decisions —
|
|
8
|
+
they are written as hsl() literals because no
|
|
9
|
+
semantic token can represent them. Everything
|
|
10
|
+
themeable uses tokens as usual.
|
|
11
|
+
|
|
12
|
+
ds-allow-file(color): colour-space physics —
|
|
13
|
+
the gradients and spectrum cannot be theme
|
|
14
|
+
tokens.
|
|
15
|
+
============================================ */
|
|
16
|
+
|
|
17
|
+
/* Base */
|
|
18
|
+
|
|
19
|
+
.ds-colorpicker {
|
|
20
|
+
position: relative;
|
|
21
|
+
/* Field owns no layout — the root class stacks label, trigger and helper */
|
|
22
|
+
display: inline-flex;
|
|
23
|
+
flex-direction: column;
|
|
24
|
+
align-items: flex-start;
|
|
25
|
+
gap: var(--gap-200);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/* Trigger */
|
|
29
|
+
|
|
30
|
+
.ds-colorpicker__trigger {
|
|
31
|
+
display: inline-flex;
|
|
32
|
+
align-items: center;
|
|
33
|
+
gap: var(--gap-200);
|
|
34
|
+
padding: var(--padding-100);
|
|
35
|
+
border: var(--border-025) solid var(--color-input-border-primary);
|
|
36
|
+
border-radius: var(--radius-300);
|
|
37
|
+
background-color: transparent;
|
|
38
|
+
cursor: pointer;
|
|
39
|
+
transition: border-color var(--motion-duration-base) var(--motion-ease-standard);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.ds-colorpicker__trigger:hover:not(:disabled) {
|
|
43
|
+
border-color: var(--color-input-border-hover);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.ds-colorpicker__trigger:focus-visible {
|
|
47
|
+
outline: none;
|
|
48
|
+
border-color: var(--color-input-border-selected);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.ds-colorpicker--open .ds-colorpicker__trigger {
|
|
52
|
+
border-color: var(--color-input-border-selected);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.ds-colorpicker__trigger-swatch {
|
|
56
|
+
width: 24px;
|
|
57
|
+
height: 24px;
|
|
58
|
+
border-radius: var(--radius-200);
|
|
59
|
+
/* Checkerboard shows through translucent colours */
|
|
60
|
+
background-color: var(--color-bg-page-primary);
|
|
61
|
+
background-image:
|
|
62
|
+
linear-gradient(var(--ds-cp-color), var(--ds-cp-color)),
|
|
63
|
+
repeating-conic-gradient(var(--color-bg-container-tertiary) 0% 25%, transparent 0% 50%);
|
|
64
|
+
background-size: 100% 100%, 8px 8px;
|
|
65
|
+
box-shadow: inset 0 0 0 var(--border-025) var(--color-bg-container-border);
|
|
66
|
+
flex-shrink: 0;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.ds-colorpicker__trigger-text {
|
|
70
|
+
font-family: var(--font-paragraph-sm-family);
|
|
71
|
+
font-size: var(--font-paragraph-sm-size);
|
|
72
|
+
line-height: var(--font-paragraph-sm-line-height);
|
|
73
|
+
color: var(--color-text-primary);
|
|
74
|
+
font-variant-numeric: tabular-nums;
|
|
75
|
+
padding-right: var(--padding-100);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/* Sizes */
|
|
79
|
+
|
|
80
|
+
.ds-colorpicker--compact .ds-colorpicker__trigger-swatch {
|
|
81
|
+
width: 20px;
|
|
82
|
+
height: 20px;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/* Panel */
|
|
86
|
+
|
|
87
|
+
.ds-colorpicker__panel {
|
|
88
|
+
position: absolute;
|
|
89
|
+
top: 100%;
|
|
90
|
+
left: 0;
|
|
91
|
+
margin-top: var(--gap-050);
|
|
92
|
+
width: 240px;
|
|
93
|
+
padding: var(--padding-300);
|
|
94
|
+
display: flex;
|
|
95
|
+
flex-direction: column;
|
|
96
|
+
gap: var(--gap-300);
|
|
97
|
+
background-color: var(--color-bg-page-primary);
|
|
98
|
+
border: var(--border-025) solid var(--color-input-border-primary);
|
|
99
|
+
border-radius: var(--radius-300);
|
|
100
|
+
box-shadow: var(--shadow-floating);
|
|
101
|
+
z-index: 10;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/* Saturation / brightness area */
|
|
105
|
+
|
|
106
|
+
.ds-colorpicker__saturation {
|
|
107
|
+
position: relative;
|
|
108
|
+
height: 150px;
|
|
109
|
+
border-radius: var(--radius-200);
|
|
110
|
+
cursor: crosshair;
|
|
111
|
+
touch-action: none;
|
|
112
|
+
background:
|
|
113
|
+
linear-gradient(to top, hsl(0 0% 0%), transparent),
|
|
114
|
+
linear-gradient(to right, hsl(0 0% 100%), transparent),
|
|
115
|
+
hsl(var(--ds-cp-hue) 100% 50%);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.ds-colorpicker__saturation:focus-visible {
|
|
119
|
+
outline: var(--border-050) solid var(--color-input-border-selected);
|
|
120
|
+
outline-offset: var(--border-050);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.ds-colorpicker__handle {
|
|
124
|
+
position: absolute;
|
|
125
|
+
left: var(--ds-cp-x);
|
|
126
|
+
top: var(--ds-cp-y);
|
|
127
|
+
transform: translate(-50%, -50%);
|
|
128
|
+
width: 14px;
|
|
129
|
+
height: 14px;
|
|
130
|
+
border-radius: var(--radius-pill);
|
|
131
|
+
border: var(--border-050) solid hsl(0 0% 100%);
|
|
132
|
+
box-shadow: var(--shadow-floating);
|
|
133
|
+
pointer-events: none;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/* Sliders + preview */
|
|
137
|
+
|
|
138
|
+
.ds-colorpicker__controls {
|
|
139
|
+
display: flex;
|
|
140
|
+
align-items: center;
|
|
141
|
+
gap: var(--gap-300);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.ds-colorpicker__sliders {
|
|
145
|
+
flex: 1;
|
|
146
|
+
display: flex;
|
|
147
|
+
flex-direction: column;
|
|
148
|
+
gap: var(--gap-200);
|
|
149
|
+
min-width: 0;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.ds-colorpicker__hue,
|
|
153
|
+
.ds-colorpicker__alpha {
|
|
154
|
+
appearance: none;
|
|
155
|
+
-webkit-appearance: none;
|
|
156
|
+
width: 100%;
|
|
157
|
+
height: 12px;
|
|
158
|
+
border-radius: var(--radius-pill);
|
|
159
|
+
outline: none;
|
|
160
|
+
cursor: pointer;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.ds-colorpicker__hue {
|
|
164
|
+
background: linear-gradient(
|
|
165
|
+
to right,
|
|
166
|
+
hsl(0 100% 50%),
|
|
167
|
+
hsl(60 100% 50%),
|
|
168
|
+
hsl(120 100% 50%),
|
|
169
|
+
hsl(180 100% 50%),
|
|
170
|
+
hsl(240 100% 50%),
|
|
171
|
+
hsl(300 100% 50%),
|
|
172
|
+
hsl(360 100% 50%)
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.ds-colorpicker__alpha {
|
|
177
|
+
background-color: var(--color-bg-page-primary);
|
|
178
|
+
background-image:
|
|
179
|
+
linear-gradient(to right, transparent, var(--ds-cp-solid)),
|
|
180
|
+
repeating-conic-gradient(var(--color-bg-container-tertiary) 0% 25%, transparent 0% 50%);
|
|
181
|
+
background-size: 100% 100%, 8px 8px;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.ds-colorpicker__hue::-webkit-slider-thumb,
|
|
185
|
+
.ds-colorpicker__alpha::-webkit-slider-thumb {
|
|
186
|
+
appearance: none;
|
|
187
|
+
-webkit-appearance: none;
|
|
188
|
+
width: 16px;
|
|
189
|
+
height: 16px;
|
|
190
|
+
border-radius: var(--radius-pill);
|
|
191
|
+
background: hsl(0 0% 100%);
|
|
192
|
+
border: var(--border-025) solid var(--color-bg-container-border);
|
|
193
|
+
box-shadow: var(--shadow-floating);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.ds-colorpicker__hue::-moz-range-thumb,
|
|
197
|
+
.ds-colorpicker__alpha::-moz-range-thumb {
|
|
198
|
+
width: 16px;
|
|
199
|
+
height: 16px;
|
|
200
|
+
border-radius: var(--radius-pill);
|
|
201
|
+
background: hsl(0 0% 100%);
|
|
202
|
+
border: var(--border-025) solid var(--color-bg-container-border);
|
|
203
|
+
box-shadow: var(--shadow-floating);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.ds-colorpicker__hue:focus-visible,
|
|
207
|
+
.ds-colorpicker__alpha:focus-visible {
|
|
208
|
+
outline: var(--border-050) solid var(--color-input-border-selected);
|
|
209
|
+
outline-offset: var(--border-050);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.ds-colorpicker__preview {
|
|
213
|
+
width: 32px;
|
|
214
|
+
height: 32px;
|
|
215
|
+
border-radius: var(--radius-200);
|
|
216
|
+
background-color: var(--color-bg-page-primary);
|
|
217
|
+
background-image:
|
|
218
|
+
linear-gradient(var(--ds-cp-color), var(--ds-cp-color)),
|
|
219
|
+
repeating-conic-gradient(var(--color-bg-container-tertiary) 0% 25%, transparent 0% 50%);
|
|
220
|
+
background-size: 100% 100%, 8px 8px;
|
|
221
|
+
box-shadow: inset 0 0 0 var(--border-025) var(--color-bg-container-border);
|
|
222
|
+
flex-shrink: 0;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/* Hex + alpha inputs */
|
|
226
|
+
|
|
227
|
+
.ds-colorpicker__inputs {
|
|
228
|
+
display: flex;
|
|
229
|
+
align-items: center;
|
|
230
|
+
gap: var(--gap-200);
|
|
231
|
+
padding: var(--padding-100) var(--padding-200);
|
|
232
|
+
border: var(--border-025) solid var(--color-input-border-primary);
|
|
233
|
+
border-radius: var(--radius-300);
|
|
234
|
+
transition: border-color var(--motion-duration-base) var(--motion-ease-standard);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
.ds-colorpicker__inputs:focus-within {
|
|
238
|
+
border-color: var(--color-input-border-selected);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.ds-colorpicker__hash {
|
|
242
|
+
font-family: var(--font-paragraph-sm-family);
|
|
243
|
+
font-size: var(--font-paragraph-sm-size);
|
|
244
|
+
color: var(--color-text-tertiary);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
.ds-colorpicker__hex-field {
|
|
248
|
+
flex: 1;
|
|
249
|
+
min-width: 0;
|
|
250
|
+
border: none;
|
|
251
|
+
background: transparent;
|
|
252
|
+
outline: none;
|
|
253
|
+
padding: 0;
|
|
254
|
+
font-family: var(--font-paragraph-sm-family);
|
|
255
|
+
font-size: var(--font-paragraph-sm-size);
|
|
256
|
+
line-height: var(--font-paragraph-sm-line-height);
|
|
257
|
+
color: var(--color-text-primary);
|
|
258
|
+
text-transform: uppercase;
|
|
259
|
+
font-variant-numeric: tabular-nums;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
.ds-colorpicker__alpha-value {
|
|
263
|
+
font-family: var(--font-paragraph-sm-family);
|
|
264
|
+
font-size: var(--font-paragraph-sm-size);
|
|
265
|
+
color: var(--color-text-secondary);
|
|
266
|
+
font-variant-numeric: tabular-nums;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/* States */
|
|
270
|
+
|
|
271
|
+
.ds-colorpicker--disabled .ds-colorpicker__trigger {
|
|
272
|
+
opacity: 0.4;
|
|
273
|
+
cursor: not-allowed;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
.ds-colorpicker--error .ds-colorpicker__trigger {
|
|
277
|
+
border-color: var(--color-status-error-border);
|
|
278
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
/** Props owned by ColorPicker itself — everything else falls through to the trigger <button>. */
|
|
3
|
+
type ColorPickerOwnProps = {
|
|
4
|
+
/** Field label text */
|
|
5
|
+
label?: string;
|
|
6
|
+
/** Current colour as a hex string — 3, 6 or 8 digit, with or without `#` */
|
|
7
|
+
value?: string;
|
|
8
|
+
/** Initial colour for uncontrolled use */
|
|
9
|
+
defaultValue?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Convenience callback receiving the colour as an uppercase hex string
|
|
12
|
+
* (`#RRGGBB`, or `#RRGGBBAA` when `showAlpha` and alpha < 100%). Fires
|
|
13
|
+
* live while dragging.
|
|
14
|
+
*/
|
|
15
|
+
onValueChange?: (value: string) => void;
|
|
16
|
+
/** Show the current hex value as text inside the trigger */
|
|
17
|
+
showText?: boolean;
|
|
18
|
+
/** Add an alpha (opacity) slider and emit 8-digit hex when alpha < 100% */
|
|
19
|
+
showAlpha?: boolean;
|
|
20
|
+
/** Component size */
|
|
21
|
+
size?: 'default' | 'compact';
|
|
22
|
+
/** Whether the picker is disabled */
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
/** Whether the field is required */
|
|
25
|
+
required?: boolean;
|
|
26
|
+
/** Error state */
|
|
27
|
+
error?: boolean;
|
|
28
|
+
/** Helper or error message */
|
|
29
|
+
helperText?: string;
|
|
30
|
+
/**
|
|
31
|
+
* When set, a hidden `<input type="hidden">` carries the current hex value
|
|
32
|
+
* under this name so the picker participates in native form submission.
|
|
33
|
+
*/
|
|
34
|
+
name?: string;
|
|
35
|
+
/** Additional CSS classes — applied to the wrapper, not the trigger */
|
|
36
|
+
className?: string;
|
|
37
|
+
};
|
|
38
|
+
export interface ColorPickerProps extends ColorPickerOwnProps, Omit<React.ComponentPropsWithoutRef<'button'>, keyof ColorPickerOwnProps | 'type'> {
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Colour picker: a swatch trigger that opens a panel with a
|
|
42
|
+
* saturation/brightness area, hue slider, optional alpha slider and a hex
|
|
43
|
+
* field. Works controlled (`value` + `onValueChange`) or uncontrolled
|
|
44
|
+
* (`defaultValue`).
|
|
45
|
+
*
|
|
46
|
+
* Forwards a ref to the trigger `<button>` and spreads unrecognised props
|
|
47
|
+
* onto it.
|
|
48
|
+
*/
|
|
49
|
+
export declare const ColorPicker: React.ForwardRefExoticComponent<ColorPickerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
50
|
+
export {};
|
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
3
|
+
import React, { useState, useRef, useEffect, useCallback } from "react";
|
|
4
|
+
import { Field } from "../Field/Field.js";
|
|
5
|
+
import "./ColorPicker.css";
|
|
6
|
+
const clamp = (n, min, max) => Math.min(max, Math.max(min, n));
|
|
7
|
+
function parseHex(input) {
|
|
8
|
+
const hex = input.trim().replace(/^#/, "");
|
|
9
|
+
if (!/^([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(hex)) return null;
|
|
10
|
+
let r, g, b;
|
|
11
|
+
let a = 255;
|
|
12
|
+
if (hex.length === 3) {
|
|
13
|
+
r = parseInt(hex[0] + hex[0], 16);
|
|
14
|
+
g = parseInt(hex[1] + hex[1], 16);
|
|
15
|
+
b = parseInt(hex[2] + hex[2], 16);
|
|
16
|
+
} else {
|
|
17
|
+
r = parseInt(hex.slice(0, 2), 16);
|
|
18
|
+
g = parseInt(hex.slice(2, 4), 16);
|
|
19
|
+
b = parseInt(hex.slice(4, 6), 16);
|
|
20
|
+
if (hex.length === 8) a = parseInt(hex.slice(6, 8), 16);
|
|
21
|
+
}
|
|
22
|
+
const max = Math.max(r, g, b);
|
|
23
|
+
const min = Math.min(r, g, b);
|
|
24
|
+
const d = max - min;
|
|
25
|
+
let h = 0;
|
|
26
|
+
if (d !== 0) {
|
|
27
|
+
if (max === r) h = 60 * ((g - b) / d % 6);
|
|
28
|
+
else if (max === g) h = 60 * ((b - r) / d + 2);
|
|
29
|
+
else h = 60 * ((r - g) / d + 4);
|
|
30
|
+
}
|
|
31
|
+
if (h < 0) h += 360;
|
|
32
|
+
return {
|
|
33
|
+
// h stays a float — rounding it here makes the hex → HSV → hex round
|
|
34
|
+
// trip drift by one on some colours.
|
|
35
|
+
h: clamp(h, 0, 359.999),
|
|
36
|
+
s: max === 0 ? 0 : d / max * 100,
|
|
37
|
+
v: max / 255 * 100,
|
|
38
|
+
a: a / 255 * 100
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function hsvToRgb({ h, s, v }) {
|
|
42
|
+
const sf = s / 100;
|
|
43
|
+
const vf = v / 100;
|
|
44
|
+
const c = vf * sf;
|
|
45
|
+
const x = c * (1 - Math.abs(h / 60 % 2 - 1));
|
|
46
|
+
const m = vf - c;
|
|
47
|
+
const [r, g, b] = h < 60 ? [c, x, 0] : h < 120 ? [x, c, 0] : h < 180 ? [0, c, x] : h < 240 ? [0, x, c] : h < 300 ? [x, 0, c] : [c, 0, x];
|
|
48
|
+
return [Math.round((r + m) * 255), Math.round((g + m) * 255), Math.round((b + m) * 255)];
|
|
49
|
+
}
|
|
50
|
+
const channelHex = (n) => n.toString(16).padStart(2, "0").toUpperCase();
|
|
51
|
+
function formatHex(hsva, withAlpha) {
|
|
52
|
+
const [r, g, b] = hsvToRgb(hsva);
|
|
53
|
+
const base = `#${channelHex(r)}${channelHex(g)}${channelHex(b)}`;
|
|
54
|
+
if (withAlpha && hsva.a < 100) {
|
|
55
|
+
return base + channelHex(Math.round(hsva.a / 100 * 255));
|
|
56
|
+
}
|
|
57
|
+
return base;
|
|
58
|
+
}
|
|
59
|
+
function toCssColor(hsva) {
|
|
60
|
+
const [r, g, b] = hsvToRgb(hsva);
|
|
61
|
+
return `rgba(${r}, ${g}, ${b}, ${hsva.a / 100})`;
|
|
62
|
+
}
|
|
63
|
+
const ColorPicker = React.forwardRef(
|
|
64
|
+
({
|
|
65
|
+
label,
|
|
66
|
+
value,
|
|
67
|
+
defaultValue = "#118AB2",
|
|
68
|
+
onValueChange,
|
|
69
|
+
showText = false,
|
|
70
|
+
showAlpha = false,
|
|
71
|
+
size = "default",
|
|
72
|
+
disabled = false,
|
|
73
|
+
required = false,
|
|
74
|
+
error = false,
|
|
75
|
+
helperText,
|
|
76
|
+
name,
|
|
77
|
+
className = "",
|
|
78
|
+
id,
|
|
79
|
+
...rest
|
|
80
|
+
}, ref) => {
|
|
81
|
+
const baseClass = "ds-colorpicker";
|
|
82
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
83
|
+
const [hsva, setHsva] = useState(
|
|
84
|
+
() => parseHex(value ?? defaultValue) ?? { h: 0, s: 0, v: 0, a: 100 }
|
|
85
|
+
);
|
|
86
|
+
const [hexDraft, setHexDraft] = useState(null);
|
|
87
|
+
const rootRef = useRef(null);
|
|
88
|
+
const triggerRef = useRef(null);
|
|
89
|
+
const satRef = useRef(null);
|
|
90
|
+
const hsvaRef = useRef(hsva);
|
|
91
|
+
hsvaRef.current = hsva;
|
|
92
|
+
const lastEmitted = useRef(null);
|
|
93
|
+
const setTriggerRef = (node) => {
|
|
94
|
+
triggerRef.current = node;
|
|
95
|
+
if (typeof ref === "function") ref(node);
|
|
96
|
+
else if (ref) ref.current = node;
|
|
97
|
+
};
|
|
98
|
+
useEffect(() => {
|
|
99
|
+
if (value == null || value === lastEmitted.current) return;
|
|
100
|
+
const parsed = parseHex(value);
|
|
101
|
+
if (parsed) setHsva(parsed);
|
|
102
|
+
}, [value]);
|
|
103
|
+
const commit = useCallback(
|
|
104
|
+
(next) => {
|
|
105
|
+
setHsva(next);
|
|
106
|
+
const hex = formatHex(next, showAlpha);
|
|
107
|
+
lastEmitted.current = hex;
|
|
108
|
+
onValueChange?.(hex);
|
|
109
|
+
},
|
|
110
|
+
[onValueChange, showAlpha]
|
|
111
|
+
);
|
|
112
|
+
useEffect(() => {
|
|
113
|
+
if (!isOpen) return;
|
|
114
|
+
const onMouseDown = (e) => {
|
|
115
|
+
if (rootRef.current && !rootRef.current.contains(e.target)) {
|
|
116
|
+
setIsOpen(false);
|
|
117
|
+
setHexDraft(null);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
document.addEventListener("mousedown", onMouseDown);
|
|
121
|
+
return () => document.removeEventListener("mousedown", onMouseDown);
|
|
122
|
+
}, [isOpen]);
|
|
123
|
+
const handleRootKeyDown = (e) => {
|
|
124
|
+
if (e.key === "Escape" && isOpen) {
|
|
125
|
+
e.stopPropagation();
|
|
126
|
+
setIsOpen(false);
|
|
127
|
+
setHexDraft(null);
|
|
128
|
+
triggerRef.current?.focus();
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
const updateFromPointer = useCallback(
|
|
132
|
+
(clientX, clientY) => {
|
|
133
|
+
const el = satRef.current;
|
|
134
|
+
if (!el) return;
|
|
135
|
+
const rect = el.getBoundingClientRect();
|
|
136
|
+
const s = clamp((clientX - rect.left) / rect.width * 100, 0, 100);
|
|
137
|
+
const v = clamp((1 - (clientY - rect.top) / rect.height) * 100, 0, 100);
|
|
138
|
+
commit({ ...hsvaRef.current, s, v });
|
|
139
|
+
},
|
|
140
|
+
[commit]
|
|
141
|
+
);
|
|
142
|
+
const handleSatPointerDown = (e) => {
|
|
143
|
+
e.preventDefault();
|
|
144
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
145
|
+
e.currentTarget.focus();
|
|
146
|
+
updateFromPointer(e.clientX, e.clientY);
|
|
147
|
+
};
|
|
148
|
+
const handleSatPointerMove = (e) => {
|
|
149
|
+
if (e.currentTarget.hasPointerCapture(e.pointerId)) {
|
|
150
|
+
updateFromPointer(e.clientX, e.clientY);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
const handleSatKeyDown = (e) => {
|
|
154
|
+
const step = e.shiftKey ? 10 : 2;
|
|
155
|
+
const { h, s, v, a } = hsvaRef.current;
|
|
156
|
+
switch (e.key) {
|
|
157
|
+
case "ArrowLeft":
|
|
158
|
+
e.preventDefault();
|
|
159
|
+
commit({ h, s: clamp(s - step, 0, 100), v, a });
|
|
160
|
+
break;
|
|
161
|
+
case "ArrowRight":
|
|
162
|
+
e.preventDefault();
|
|
163
|
+
commit({ h, s: clamp(s + step, 0, 100), v, a });
|
|
164
|
+
break;
|
|
165
|
+
case "ArrowUp":
|
|
166
|
+
e.preventDefault();
|
|
167
|
+
commit({ h, s, v: clamp(v + step, 0, 100), a });
|
|
168
|
+
break;
|
|
169
|
+
case "ArrowDown":
|
|
170
|
+
e.preventDefault();
|
|
171
|
+
commit({ h, s, v: clamp(v - step, 0, 100), a });
|
|
172
|
+
break;
|
|
173
|
+
// The slider pattern requires Home/End; they act on the horizontal
|
|
174
|
+
// (saturation) axis, matching the arrow keys above.
|
|
175
|
+
case "Home":
|
|
176
|
+
e.preventDefault();
|
|
177
|
+
commit({ h, s: 0, v, a });
|
|
178
|
+
break;
|
|
179
|
+
case "End":
|
|
180
|
+
e.preventDefault();
|
|
181
|
+
commit({ h, s: 100, v, a });
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
const displayHex = formatHex(hsva, showAlpha);
|
|
186
|
+
const handleHexChange = (e) => {
|
|
187
|
+
const text = e.target.value;
|
|
188
|
+
setHexDraft(text);
|
|
189
|
+
const parsed = parseHex(text);
|
|
190
|
+
if (parsed) {
|
|
191
|
+
const keepAlpha = text.replace(/^#/, "").length < 8;
|
|
192
|
+
commit(keepAlpha ? { ...parsed, a: hsvaRef.current.a } : parsed);
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
const inputId = id || name || label?.toLowerCase().replace(/\s+/g, "-");
|
|
196
|
+
const cssColor = toCssColor(hsva);
|
|
197
|
+
const solidHex = formatHex({ ...hsva, a: 100 }, false);
|
|
198
|
+
const classes = [
|
|
199
|
+
baseClass,
|
|
200
|
+
size === "compact" ? `${baseClass}--compact` : "",
|
|
201
|
+
isOpen ? `${baseClass}--open` : "",
|
|
202
|
+
error ? `${baseClass}--error` : "",
|
|
203
|
+
disabled ? `${baseClass}--disabled` : "",
|
|
204
|
+
className
|
|
205
|
+
].filter(Boolean).join(" ");
|
|
206
|
+
return /* @__PURE__ */ jsxs(
|
|
207
|
+
Field,
|
|
208
|
+
{
|
|
209
|
+
ref: rootRef,
|
|
210
|
+
className: classes,
|
|
211
|
+
label,
|
|
212
|
+
helperText,
|
|
213
|
+
error,
|
|
214
|
+
required,
|
|
215
|
+
disabled,
|
|
216
|
+
size,
|
|
217
|
+
id: inputId,
|
|
218
|
+
onKeyDown: handleRootKeyDown,
|
|
219
|
+
children: [
|
|
220
|
+
/* @__PURE__ */ jsxs(
|
|
221
|
+
"button",
|
|
222
|
+
{
|
|
223
|
+
...rest,
|
|
224
|
+
ref: setTriggerRef,
|
|
225
|
+
type: "button",
|
|
226
|
+
id: inputId,
|
|
227
|
+
className: `${baseClass}__trigger`,
|
|
228
|
+
disabled,
|
|
229
|
+
"aria-haspopup": "dialog",
|
|
230
|
+
"aria-expanded": isOpen,
|
|
231
|
+
"aria-describedby": helperText ? `${inputId}-helper` : rest["aria-describedby"],
|
|
232
|
+
"aria-invalid": error || void 0,
|
|
233
|
+
"aria-label": rest["aria-label"] ?? (!label ? `Choose colour, ${displayHex}` : void 0),
|
|
234
|
+
onClick: () => {
|
|
235
|
+
if (!disabled) setIsOpen((prev) => !prev);
|
|
236
|
+
},
|
|
237
|
+
children: [
|
|
238
|
+
/* @__PURE__ */ jsx(
|
|
239
|
+
"span",
|
|
240
|
+
{
|
|
241
|
+
className: `${baseClass}__trigger-swatch`,
|
|
242
|
+
style: { "--ds-cp-color": cssColor },
|
|
243
|
+
"aria-hidden": "true"
|
|
244
|
+
}
|
|
245
|
+
),
|
|
246
|
+
showText && /* @__PURE__ */ jsx("span", { className: `${baseClass}__trigger-text`, children: displayHex })
|
|
247
|
+
]
|
|
248
|
+
}
|
|
249
|
+
),
|
|
250
|
+
name && /* @__PURE__ */ jsx("input", { type: "hidden", name, value: displayHex }),
|
|
251
|
+
isOpen && /* @__PURE__ */ jsxs(
|
|
252
|
+
"div",
|
|
253
|
+
{
|
|
254
|
+
className: `${baseClass}__panel`,
|
|
255
|
+
role: "dialog",
|
|
256
|
+
"aria-label": label ? `${label} colour picker` : "Colour picker",
|
|
257
|
+
style: {
|
|
258
|
+
"--ds-cp-hue": hsva.h,
|
|
259
|
+
"--ds-cp-color": cssColor,
|
|
260
|
+
"--ds-cp-solid": solidHex
|
|
261
|
+
},
|
|
262
|
+
children: [
|
|
263
|
+
/* @__PURE__ */ jsx(
|
|
264
|
+
"div",
|
|
265
|
+
{
|
|
266
|
+
ref: satRef,
|
|
267
|
+
className: `${baseClass}__saturation`,
|
|
268
|
+
role: "slider",
|
|
269
|
+
tabIndex: 0,
|
|
270
|
+
"aria-label": "Saturation and brightness",
|
|
271
|
+
"aria-valuemin": 0,
|
|
272
|
+
"aria-valuemax": 100,
|
|
273
|
+
"aria-valuenow": Math.round(hsva.v),
|
|
274
|
+
"aria-valuetext": `Saturation ${Math.round(hsva.s)}%, brightness ${Math.round(hsva.v)}%`,
|
|
275
|
+
onPointerDown: handleSatPointerDown,
|
|
276
|
+
onPointerMove: handleSatPointerMove,
|
|
277
|
+
onKeyDown: handleSatKeyDown,
|
|
278
|
+
style: {
|
|
279
|
+
"--ds-cp-x": `${hsva.s}%`,
|
|
280
|
+
"--ds-cp-y": `${100 - hsva.v}%`
|
|
281
|
+
},
|
|
282
|
+
children: /* @__PURE__ */ jsx("span", { className: `${baseClass}__handle` })
|
|
283
|
+
}
|
|
284
|
+
),
|
|
285
|
+
/* @__PURE__ */ jsxs("div", { className: `${baseClass}__controls`, children: [
|
|
286
|
+
/* @__PURE__ */ jsxs("div", { className: `${baseClass}__sliders`, children: [
|
|
287
|
+
/* @__PURE__ */ jsx(
|
|
288
|
+
"input",
|
|
289
|
+
{
|
|
290
|
+
type: "range",
|
|
291
|
+
className: `${baseClass}__hue`,
|
|
292
|
+
min: 0,
|
|
293
|
+
max: 359,
|
|
294
|
+
step: 1,
|
|
295
|
+
value: Math.round(hsva.h),
|
|
296
|
+
"aria-label": "Hue",
|
|
297
|
+
onChange: (e) => commit({ ...hsvaRef.current, h: Number(e.target.value) })
|
|
298
|
+
}
|
|
299
|
+
),
|
|
300
|
+
showAlpha && /* @__PURE__ */ jsx(
|
|
301
|
+
"input",
|
|
302
|
+
{
|
|
303
|
+
type: "range",
|
|
304
|
+
className: `${baseClass}__alpha`,
|
|
305
|
+
min: 0,
|
|
306
|
+
max: 100,
|
|
307
|
+
step: 1,
|
|
308
|
+
value: Math.round(hsva.a),
|
|
309
|
+
"aria-label": "Alpha",
|
|
310
|
+
onChange: (e) => commit({ ...hsvaRef.current, a: Number(e.target.value) })
|
|
311
|
+
}
|
|
312
|
+
)
|
|
313
|
+
] }),
|
|
314
|
+
/* @__PURE__ */ jsx("span", { className: `${baseClass}__preview`, "aria-hidden": "true" })
|
|
315
|
+
] }),
|
|
316
|
+
/* @__PURE__ */ jsxs("div", { className: `${baseClass}__inputs`, children: [
|
|
317
|
+
/* @__PURE__ */ jsx("span", { className: `${baseClass}__hash`, "aria-hidden": "true", children: "#" }),
|
|
318
|
+
/* @__PURE__ */ jsx(
|
|
319
|
+
"input",
|
|
320
|
+
{
|
|
321
|
+
type: "text",
|
|
322
|
+
className: `${baseClass}__hex-field`,
|
|
323
|
+
value: (hexDraft ?? displayHex).replace(/^#/, ""),
|
|
324
|
+
maxLength: 8,
|
|
325
|
+
spellCheck: false,
|
|
326
|
+
autoComplete: "off",
|
|
327
|
+
"aria-label": "Hex colour value",
|
|
328
|
+
onChange: handleHexChange,
|
|
329
|
+
onFocus: () => setHexDraft(displayHex.replace(/^#/, "")),
|
|
330
|
+
onBlur: () => setHexDraft(null)
|
|
331
|
+
}
|
|
332
|
+
),
|
|
333
|
+
showAlpha && /* @__PURE__ */ jsxs("span", { className: `${baseClass}__alpha-value`, children: [
|
|
334
|
+
Math.round(hsva.a),
|
|
335
|
+
"%"
|
|
336
|
+
] })
|
|
337
|
+
] })
|
|
338
|
+
]
|
|
339
|
+
}
|
|
340
|
+
)
|
|
341
|
+
]
|
|
342
|
+
}
|
|
343
|
+
);
|
|
344
|
+
}
|
|
345
|
+
);
|
|
346
|
+
ColorPicker.displayName = "ColorPicker";
|
|
347
|
+
export {
|
|
348
|
+
ColorPicker
|
|
349
|
+
};
|