@flikk/ui 1.0.0-beta.30 → 1.0.0-beta.31
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 +97 -0
- package/dist/components/ai/AgentStatus/AgentStatus.d.ts +3 -0
- package/dist/components/ai/AgentStatus/AgentStatus.js +144 -0
- package/dist/components/ai/AgentStatus/AgentStatus.theme.d.ts +2 -0
- package/dist/components/ai/AgentStatus/AgentStatus.theme.js +37 -0
- package/dist/components/ai/AgentStatus/AgentStatus.types.d.ts +116 -0
- package/dist/components/ai/AgentStatus/index.d.ts +3 -0
- package/dist/components/ai/CodeBlock/CodeBlock.js +3 -3
- package/dist/components/ai/CodeBlock/CodeBlock.theme.js +1 -1
- package/dist/components/ai/PromptInput/PromptInput.js +13 -14
- package/dist/components/ai/PromptInput/PromptInput.theme.js +1 -1
- package/dist/components/ai/PromptInput/VoiceRecorder.js +3 -3
- package/dist/components/ai/Reasoning/Reasoning.d.ts +5 -0
- package/dist/components/ai/Reasoning/Reasoning.js +16 -0
- package/dist/components/ai/Reasoning/Reasoning.types.d.ts +20 -0
- package/dist/components/ai/Reasoning/index.d.ts +2 -0
- package/dist/components/ai/SourceCitation/SourceCitation.d.ts +4 -0
- package/dist/components/ai/SourceCitation/SourceCitation.js +29 -0
- package/dist/components/ai/SourceCitation/SourceCitation.theme.d.ts +2 -0
- package/dist/components/ai/SourceCitation/SourceCitation.theme.js +23 -0
- package/dist/components/ai/SourceCitation/SourceCitation.types.d.ts +55 -0
- package/dist/components/ai/SourceCitation/index.d.ts +3 -0
- package/dist/components/ai/StreamingResponse/ErrorDisplay.js +2 -2
- package/dist/components/ai/StreamingResponse/StreamingResponse.js +1 -3
- package/dist/components/ai/StreamingResponse/StreamingResponse.theme.js +3 -1
- package/dist/components/ai/TokenCounter/TokenCounter.js +2 -2
- package/dist/components/ai/index.d.ts +3 -0
- package/dist/components/ai/index.js +6 -3
- package/dist/components/ai/shared/StatusIndicator.d.ts +8 -0
- package/dist/components/ai/shared/StatusIndicator.js +34 -0
- package/dist/components/canvas/CanvasToolbar.js +2 -2
- package/dist/components/canvas/NodeControls.js +2 -2
- package/dist/components/canvas/NodeRenderer.js +2 -2
- package/dist/components/charts/ActivityRings/ActivityRings.js +2 -2
- package/dist/components/charts/AreaChart/AreaChart.js +21 -32
- package/dist/components/charts/AreaChart/AreaChart.theme.d.ts +1 -6
- package/dist/components/charts/AreaChart/AreaChart.theme.js +7 -19
- package/dist/components/charts/AreaChart/AreaChart.types.d.ts +18 -11
- package/dist/components/charts/AreaChart/AreaChart.types.js +10 -3
- package/dist/components/charts/AreaChart/index.d.ts +1 -1
- package/dist/components/charts/BarChart/BarChart.js +9 -28
- package/dist/components/charts/BarChart/BarChart.types.d.ts +20 -16
- package/dist/components/charts/BarChart/BarChart.types.js +11 -4
- package/dist/components/charts/ComboChart/BarRenderer.js +8 -5
- package/dist/components/charts/ComboChart/ComboChart.js +11 -24
- package/dist/components/charts/ComboChart/ComboChart.types.d.ts +15 -13
- package/dist/components/charts/ComboChart/ComboChart.types.js +14 -2
- package/dist/components/charts/ComboChart/LineRenderer.js +15 -10
- package/dist/components/charts/HorizontalBarChart/HorizontalBarChart.d.ts +16 -0
- package/dist/components/charts/HorizontalBarChart/HorizontalBarChart.js +237 -0
- package/dist/components/charts/HorizontalBarChart/HorizontalBarChart.types.d.ts +62 -0
- package/dist/components/charts/HorizontalBarChart/HorizontalBarChart.types.js +21 -0
- package/dist/components/charts/HorizontalBarChart/index.d.ts +3 -0
- package/dist/components/charts/LineChart/LineChart.js +9 -26
- package/dist/components/charts/LineChart/LineChart.types.d.ts +11 -14
- package/dist/components/charts/LineChart/LineChart.types.js +11 -3
- package/dist/components/charts/LollipopChart/LollipopChart.d.ts +3 -0
- package/dist/components/charts/LollipopChart/LollipopChart.js +361 -0
- package/dist/components/charts/LollipopChart/LollipopChart.types.d.ts +42 -0
- package/dist/components/charts/LollipopChart/LollipopChart.types.js +12 -0
- package/dist/components/charts/LollipopChart/index.d.ts +3 -0
- package/dist/components/charts/ScatterPlot/ScatterPlot.js +5 -4
- package/dist/components/charts/ScatterPlot/ScatterPlot.types.d.ts +14 -19
- package/dist/components/charts/ScatterPlot/ScatterPlot.types.js +9 -2
- package/dist/components/charts/StackedBarChart/StackedBarChart.js +150 -132
- package/dist/components/charts/StackedBarChart/StackedBarChart.types.d.ts +20 -18
- package/dist/components/charts/StackedBarChart/StackedBarChart.types.js +10 -4
- package/dist/components/charts/hooks/useChartAccessibility.d.ts +1 -1
- package/dist/components/charts/hooks/useChartAccessibility.js +3 -0
- package/dist/components/charts/hooks/useTooltipPosition.js +18 -6
- package/dist/components/charts/index.d.ts +6 -0
- package/dist/components/charts/index.js +6 -0
- package/dist/components/charts/shared/ChartAxis/CategoryYAxis.d.ts +14 -0
- package/dist/components/charts/shared/ChartAxis/CategoryYAxis.js +35 -0
- package/dist/components/charts/shared/ChartAxis/ChartAxis.types.d.ts +69 -8
- package/dist/components/charts/shared/ChartAxis/ValueXAxis.d.ts +14 -0
- package/dist/components/charts/shared/ChartAxis/ValueXAxis.js +64 -0
- package/dist/components/charts/shared/ChartAxis/XAxis.js +1 -1
- package/dist/components/charts/shared/ChartAxis/YAxis.js +2 -2
- package/dist/components/charts/shared/ChartAxis/index.d.ts +3 -1
- package/dist/components/charts/shared/ChartGrid/HorizontalGrid.d.ts +0 -2
- package/dist/components/charts/shared/ChartGrid/HorizontalGrid.js +1 -1
- package/dist/components/charts/shared/ChartGrid/VerticalGrid.d.ts +29 -0
- package/dist/components/charts/shared/ChartGrid/VerticalGrid.js +26 -0
- package/dist/components/charts/shared/ChartGrid/index.d.ts +2 -0
- package/dist/components/charts/shared/ChartMarker/ChartMarker.js +7 -1
- package/dist/components/charts/theme/chart.theme.js +18 -23
- package/dist/components/charts/types/chart.types.d.ts +9 -5
- package/dist/components/charts/types/chart.types.js +1 -7
- package/dist/components/charts/utils/animation-utils.js +1 -3
- package/dist/components/charts/utils/bar-emphasis.d.ts +32 -3
- package/dist/components/charts/utils/bar-emphasis.js +24 -8
- package/dist/components/charts/utils/index.d.ts +1 -0
- package/dist/components/charts/utils/series-color.d.ts +7 -0
- package/dist/components/charts/utils/series-color.js +20 -0
- package/dist/components/core/Accordion/Accordion.theme.js +2 -2
- package/dist/components/core/Accordion/AccordionTrigger.js +2 -2
- package/dist/components/core/Alert/Alert.animations.d.ts +2 -1
- package/dist/components/core/Alert/Alert.animations.js +21 -6
- package/dist/components/core/Alert/Alert.js +7 -7
- package/dist/components/core/Avatar/Avatar.js +50 -42
- package/dist/components/core/Avatar/Avatar.theme.d.ts +8 -4
- package/dist/components/core/Avatar/Avatar.theme.js +64 -8
- package/dist/components/core/Avatar/Avatar.types.d.ts +13 -2
- package/dist/components/core/Avatar/index.d.ts +1 -1
- package/dist/components/core/AvatarGroup/AvatarGroup.js +6 -8
- package/dist/components/core/AvatarGroup/AvatarGroup.theme.d.ts +1 -2
- package/dist/components/core/AvatarGroup/AvatarGroup.theme.js +2 -6
- package/dist/components/core/AvatarGroup/AvatarGroup.types.d.ts +0 -6
- package/dist/components/core/AvatarGroup/index.d.ts +1 -1
- package/dist/components/core/Badge/Badge.animations.js +4 -2
- package/dist/components/core/Badge/Badge.js +9 -4
- package/dist/components/core/Badge/Badge.theme.js +18 -12
- package/dist/components/core/Breadcrumbs/Breadcrumbs.theme.d.ts +1 -4
- package/dist/components/core/Breadcrumbs/Breadcrumbs.theme.js +2 -2
- package/dist/components/core/Button/Button.js +9 -17
- package/dist/components/core/Button/Button.ripple.js +2 -2
- package/dist/components/core/Button/Button.theme.d.ts +2 -0
- package/dist/components/core/Button/Button.theme.js +34 -21
- package/dist/components/core/Button/Button.types.d.ts +18 -1
- package/dist/components/core/Calendar/Calendar.js +20 -5
- package/dist/components/core/Calendar/Calendar.theme.js +14 -22
- package/dist/components/core/Calendar/Calendar.types.d.ts +0 -1
- package/dist/components/core/Calendar/CalendarMini/CalendarMini.js +3 -3
- package/dist/components/core/Card/Card.theme.js +12 -4
- package/dist/components/core/Card/CardBody.js +1 -1
- package/dist/components/core/Card/CardFooter.js +1 -1
- package/dist/components/core/Card/CardHeader.js +1 -1
- package/dist/components/core/Carousel/CarouselNext.js +2 -2
- package/dist/components/core/Carousel/CarouselPrevious.js +2 -2
- package/dist/components/core/CommandPalette/CommandPalette.js +5 -4
- package/dist/components/core/CommandPalette/CommandPalette.theme.js +3 -7
- package/dist/components/core/CommandPalette/CommandPalette.types.d.ts +2 -0
- package/dist/components/core/ContextMenu/ContextMenuItem.js +2 -2
- package/dist/components/core/ContextMenu/ContextMenuSubTrigger.js +2 -2
- package/dist/components/core/Drawer/Drawer.theme.js +7 -4
- package/dist/components/core/Drawer/DrawerHeader.js +2 -2
- package/dist/components/core/Dropdown/Dropdown.theme.js +3 -1
- package/dist/components/core/Dropdown/DropdownItem.js +2 -2
- package/dist/components/core/Dropdown/DropdownTrigger.js +16 -5
- package/dist/components/core/HeroCard/HeroCard.theme.js +5 -2
- package/dist/components/core/Kbd/Kbd.theme.js +4 -2
- package/dist/components/core/Link/Link.js +6 -4
- package/dist/components/core/Message/Message.js +2 -2
- package/dist/components/core/Message/Message.theme.js +5 -7
- package/dist/components/core/Message/MessageAudio.js +2 -2
- package/dist/components/core/Message/MessageFile.js +2 -2
- package/dist/components/core/Message/MessageLink.js +2 -2
- package/dist/components/core/Message/MessageStatusIndicator.js +5 -5
- package/dist/components/core/Modal/Modal.d.ts +1 -1
- package/dist/components/core/Modal/Modal.js +2 -2
- package/dist/components/core/Modal/Modal.theme.js +9 -4
- package/dist/components/core/Modal/ModalHeader.js +2 -2
- package/dist/components/core/ModalStack/ModalStackModal.js +2 -2
- package/dist/components/core/NavItem/NavItem.js +6 -6
- package/dist/components/core/OfflineIndicator/OfflineIndicator.animations.d.ts +22 -0
- package/dist/components/core/OfflineIndicator/OfflineIndicator.animations.js +54 -0
- package/dist/components/core/OfflineIndicator/OfflineIndicator.js +23 -24
- package/dist/components/core/OfflineIndicator/OfflineIndicator.theme.js +25 -6
- package/dist/components/core/OfflineIndicator/OfflineIndicator.types.d.ts +17 -0
- package/dist/components/core/PageHeading/PageHeading.theme.js +1 -1
- package/dist/components/core/PageHeading/PageHeadingBackButton.js +2 -2
- package/dist/components/core/Pagination/Pagination.js +3 -3
- package/dist/components/core/Pagination/Pagination.theme.js +3 -3
- package/dist/components/core/Pill/Pill.js +4 -2
- package/dist/components/core/Pill/Pill.theme.js +6 -4
- package/dist/components/core/Rating/Rating.js +4 -5
- package/dist/components/core/Rating/Rating.theme.js +1 -1
- package/dist/components/core/Segmented/Segmented.theme.js +9 -6
- package/dist/components/core/Sidebar/Sidebar.types.d.ts +4 -2
- package/dist/components/core/Sidebar/SidebarHeader.js +2 -2
- package/dist/components/core/Sidebar/SidebarMobileTrigger.js +2 -2
- package/dist/components/core/Sidebar/SidebarSearch.js +3 -3
- package/dist/components/core/Sidebar/SidebarToggle.js +3 -3
- package/dist/components/core/Sidebar/SidebarUserProfile.js +2 -2
- package/dist/components/core/Sortable/Sortable.js +2 -2
- package/dist/components/core/Tag/Tag.js +2 -2
- package/dist/components/core/Tag/Tag.theme.js +4 -2
- package/dist/components/core/Toast/Toast.js +3 -3
- package/dist/components/core/Toast/Toast.types.d.ts +1 -1
- package/dist/components/core/Toast/useToast.js +5 -5
- package/dist/components/core/Tooltip/Tooltip.d.ts +1 -1
- package/dist/components/core/Tooltip/Tooltip.js +42 -10
- package/dist/components/core/Tooltip/Tooltip.types.d.ts +25 -0
- package/dist/components/core/Tree/Tree.js +2 -2
- package/dist/components/core/shared/interaction.animations.d.ts +51 -0
- package/dist/components/core/shared/interaction.animations.js +59 -0
- package/dist/components/data-display/Feed/Feed.js +2 -2
- package/dist/components/data-display/GanttChart/GanttChart.theme.js +1 -1
- package/dist/components/data-display/GanttChart/GanttChartPanel.js +2 -2
- package/dist/components/data-display/GanttChart/GanttTableGroupRow.js +3 -3
- package/dist/components/data-display/GanttChart/GanttTaskContextMenu.js +2 -2
- package/dist/components/data-display/GanttChart/GanttToolbar.js +2 -2
- package/dist/components/data-display/KPI/KPI.js +2 -2
- package/dist/components/data-display/KPI/KPI.theme.js +4 -4
- package/dist/components/data-display/Metric/Metric.js +2 -2
- package/dist/components/data-display/Metric/Metric.theme.js +25 -8
- package/dist/components/data-display/Metric/Metric.types.d.ts +1 -1
- package/dist/components/data-display/Table/Table.theme.js +9 -9
- package/dist/components/data-display/Table/TableActions.js +2 -2
- package/dist/components/data-display/Table/TableActionsMenu.js +1 -1
- package/dist/components/data-display/Table/TableColumnManager.js +2 -2
- package/dist/components/data-display/Table/TableDeclarative.js +3 -3
- package/dist/components/data-display/Table/TableFilter.js +4 -4
- package/dist/components/data-display/Table/TableHeader.js +3 -3
- package/dist/components/data-display/Table/TableRow.js +2 -2
- package/dist/components/data-display/Table/TableSelectionHeader.js +3 -3
- package/dist/components/data-display/Timeline/TimelineMarker.js +2 -2
- package/dist/components/effects/CustomCursor/CustomCursor.js +2 -2
- package/dist/components/effects/CustomCursor/CustomCursor.theme.js +2 -2
- package/dist/components/effects/DotPattern/DotPattern.js +6 -0
- package/dist/components/effects/DotPattern/DotPattern.types.d.ts +4 -2
- package/dist/components/effects/MeshGradient/MeshGradient.utils.d.ts +1 -1
- package/dist/components/effects/MeshGradient/MeshGradient.utils.js +1 -1
- package/dist/components/forms/Checkbox/Checkbox.js +2 -1
- package/dist/components/forms/Checkbox/Checkbox.theme.js +2 -2
- package/dist/components/forms/ColorPicker/ColorPickerEyeDropper.js +2 -2
- package/dist/components/forms/ColorPicker/ColorPickerGradient.js +2 -2
- package/dist/components/forms/ColorPicker/ColorPickerHeader.js +2 -2
- package/dist/components/forms/ColorPicker/ColorPickerImage.js +3 -3
- package/dist/components/forms/ColorPicker/ColorPickerInput.js +2 -2
- package/dist/components/forms/ColorPicker/ColorPickerPresets.js +2 -2
- package/dist/components/forms/ColorPicker/ColorPickerSavedColors.js +2 -2
- package/dist/components/forms/Combobox/Combobox.js +3 -3
- package/dist/components/forms/Combobox/Combobox.theme.js +2 -2
- package/dist/components/forms/DatePicker/DatePicker.animations.js +16 -25
- package/dist/components/forms/DatePicker/DatePicker.theme.js +2 -2
- package/dist/components/forms/DatePicker/DatePickerBody.js +1 -1
- package/dist/components/forms/DatePicker/DatePickerTrigger.js +2 -2
- package/dist/components/forms/DateRangePicker/DateRangePicker.theme.js +3 -3
- package/dist/components/forms/DateRangePicker/DateRangePickerBody.js +1 -1
- package/dist/components/forms/DateRangePicker/DateRangePickerPresets.js +2 -2
- package/dist/components/forms/DateRangePicker/DateRangePickerTrigger.js +2 -2
- package/dist/components/forms/FileUpload/FileUpload.js +4 -4
- package/dist/components/forms/FileUpload/FileUpload.theme.js +5 -1
- package/dist/components/forms/FileUpload/FileUploadProgress.js +7 -7
- package/dist/components/forms/Input/Input.js +6 -7
- package/dist/components/forms/Input/Input.theme.js +19 -15
- package/dist/components/forms/InputAddress/InputAddress.js +10 -3
- package/dist/components/forms/InputCounter/InputCounter.js +3 -3
- package/dist/components/forms/InputOTP/InputOTP.d.ts +3 -12
- package/dist/components/forms/InputOTP/InputOTP.js +140 -151
- package/dist/components/forms/InputOTP/InputOTP.theme.d.ts +5 -1
- package/dist/components/forms/InputOTP/InputOTP.theme.js +40 -5
- package/dist/components/forms/InputOTP/InputOTP.types.d.ts +45 -2
- package/dist/components/forms/InputOTP/index.d.ts +1 -1
- package/dist/components/forms/InputTag/InputTag.js +5 -5
- package/dist/components/forms/InputTag/InputTag.theme.js +1 -2
- package/dist/components/forms/Mention/Mention.theme.js +3 -5
- package/dist/components/forms/Radio/Radio.js +3 -2
- package/dist/components/forms/Radio/Radio.theme.js +2 -2
- package/dist/components/forms/RichTextEditor/RichTextEditor.js +22 -23
- package/dist/components/forms/Select/Select.d.ts +5 -1
- package/dist/components/forms/Select/Select.js +12 -11
- package/dist/components/forms/Select/Select.theme.js +4 -4
- package/dist/components/forms/Select/Select.types.d.ts +4 -1
- package/dist/components/forms/SelectableCard/SelectableCard.animations.d.ts +1 -2
- package/dist/components/forms/SelectableCard/SelectableCard.animations.js +6 -7
- package/dist/components/forms/SelectableCard/SelectableCard.js +1 -1
- package/dist/components/forms/Signature/Signature.js +1 -1
- package/dist/components/forms/Slider/Slider.js +24 -11
- package/dist/components/forms/Slider/Slider.theme.js +9 -3
- package/dist/components/forms/Switch/Switch.theme.js +1 -1
- package/dist/components/forms/TimePicker/TimePicker.theme.js +6 -7
- package/dist/components/forms/TimePicker/TimePickerContent.js +1 -1
- package/dist/components/forms/TimePicker/TimePickerTrigger.js +3 -3
- package/dist/components/forms/forms.theme.js +23 -12
- package/dist/components/forms/index.js +1 -1
- package/dist/components/generative/registry.js +195 -2
- package/dist/components/generative/resolvers.js +16 -16
- package/dist/components/generative/schema.generated.js +2687 -379
- package/dist/components/layout/Section/Section.theme.js +1 -1
- package/dist/generative.schema.json +2687 -379
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/useElapsedTime.d.ts +28 -0
- package/dist/hooks/useElapsedTime.js +37 -0
- package/dist/hooks/useSelectPortal.d.ts +10 -2
- package/dist/hooks/useSelectPortal.js +6 -3
- package/dist/index.js +1 -1
- package/dist/registry.json +835 -261
- package/dist/shadcn-compat.css +1 -1
- package/dist/styles.css +1 -1
- package/dist/theme.css +5 -1
- package/dist/themes/ember.css +131 -0
- package/dist/themes/iris.css +94 -0
- package/dist/themes/jade.css +139 -0
- package/dist/tools.json +2705 -361
- package/dist/utils/colorUtils.d.ts +6 -6
- package/dist/utils/colorUtils.js +8 -8
- package/package.json +9 -6
- package/src/global.scss +15 -4
- package/src/styles/theme.css +440 -152
- package/tailwind.preset.cjs +52 -34
- package/dist/components/core/Pill/Pill.animations.d.ts +0 -32
- package/dist/components/core/Pill/Pill.animations.js +0 -16
|
@@ -18,7 +18,7 @@ export interface ComboChartConfig extends ChartConfig {
|
|
|
18
18
|
/**
|
|
19
19
|
* ComboChart props - extends standard chart interfaces
|
|
20
20
|
*/
|
|
21
|
-
export interface ComboChartProps extends BaseChartProps, StandardChartDisplayProps, Omit<StandardVisualProps, 'curved' | 'curveType' | 'showDots'> {
|
|
21
|
+
export interface ComboChartProps extends BaseChartProps, StandardChartDisplayProps, Omit<StandardVisualProps, 'curved' | 'curveType' | 'showDots' | 'fillOpacity' | 'showStroke'> {
|
|
22
22
|
config: ComboChartConfig;
|
|
23
23
|
curved?: boolean;
|
|
24
24
|
curveType?: 'linear' | 'monotone';
|
|
@@ -27,7 +27,21 @@ export interface ComboChartProps extends BaseChartProps, StandardChartDisplayPro
|
|
|
27
27
|
showDualAxis?: boolean;
|
|
28
28
|
showValidationWarnings?: boolean;
|
|
29
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Default values using centralized defaults.
|
|
32
|
+
*
|
|
33
|
+
* 🔴 Picks explicitly rather than spreading `...CHART_DEFAULTS` — the spread pulled in a
|
|
34
|
+
* default for every other chart's props, so this object advertised values ComboChart
|
|
35
|
+
* never reads. List only what the component actually consumes.
|
|
36
|
+
*/
|
|
30
37
|
export declare const COMBO_CHART_DEFAULTS: {
|
|
38
|
+
readonly showGrid: true;
|
|
39
|
+
readonly showXAxis: true;
|
|
40
|
+
readonly showYAxis: true;
|
|
41
|
+
readonly enableKeyboardNavigation: true;
|
|
42
|
+
readonly strokeWidth: 2;
|
|
43
|
+
readonly gap: 4;
|
|
44
|
+
readonly stacked: false;
|
|
31
45
|
readonly barRadius: 32;
|
|
32
46
|
readonly dotRadius: 3;
|
|
33
47
|
readonly categoryGap: 16;
|
|
@@ -36,16 +50,4 @@ export declare const COMBO_CHART_DEFAULTS: {
|
|
|
36
50
|
readonly showDots: false;
|
|
37
51
|
readonly showDualAxis: false;
|
|
38
52
|
readonly variant: ChartVariant;
|
|
39
|
-
readonly showGrid: true;
|
|
40
|
-
readonly showXAxis: true;
|
|
41
|
-
readonly showYAxis: true;
|
|
42
|
-
readonly cellRadius: 4;
|
|
43
|
-
readonly radius: 20;
|
|
44
|
-
readonly strokeWidth: 2;
|
|
45
|
-
readonly gap: 4;
|
|
46
|
-
readonly fillOpacity: 0.3;
|
|
47
|
-
readonly showStroke: true;
|
|
48
|
-
readonly orientation: "vertical" | "horizontal";
|
|
49
|
-
readonly stacked: false;
|
|
50
|
-
readonly enableKeyboardNavigation: true;
|
|
51
53
|
};
|
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
import { CHART_DEFAULTS } from '../types/chart.types.js';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Default values using centralized defaults.
|
|
5
|
+
*
|
|
6
|
+
* 🔴 Picks explicitly rather than spreading `...CHART_DEFAULTS` — the spread pulled in a
|
|
7
|
+
* default for every other chart's props, so this object advertised values ComboChart
|
|
8
|
+
* never reads. List only what the component actually consumes.
|
|
9
|
+
*/
|
|
4
10
|
const COMBO_CHART_DEFAULTS = {
|
|
5
|
-
|
|
11
|
+
showGrid: CHART_DEFAULTS.showGrid,
|
|
12
|
+
showXAxis: CHART_DEFAULTS.showXAxis,
|
|
13
|
+
showYAxis: CHART_DEFAULTS.showYAxis,
|
|
14
|
+
enableKeyboardNavigation: CHART_DEFAULTS.enableKeyboardNavigation,
|
|
15
|
+
strokeWidth: CHART_DEFAULTS.strokeWidth,
|
|
16
|
+
gap: CHART_DEFAULTS.gap,
|
|
17
|
+
stacked: CHART_DEFAULTS.stacked,
|
|
6
18
|
barRadius: CHART_DEFAULTS.barRadius, // 24 - For bar corners
|
|
7
19
|
dotRadius: CHART_DEFAULTS.dotRadius, // 20 - For line markers
|
|
8
20
|
categoryGap: CHART_DEFAULTS.categoryGap,
|
|
@@ -9,26 +9,31 @@ import { generateCurvePath } from '../utils/path-utils.js';
|
|
|
9
9
|
import { RISE_FROM_BASELINE, riseTransition, SCALE_FROM_CENTER, dotEntranceTransition } from '../utils/animation-utils.js';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
* Get series color class
|
|
12
|
+
* Get series color class.
|
|
13
|
+
* Fallback only — ComboChart always resolves a real color onto each series'
|
|
14
|
+
* config before it reaches this renderer (see ComboChart.tsx).
|
|
13
15
|
*/
|
|
14
16
|
const getSeriesColorClass = (index) => {
|
|
15
17
|
const colors = [
|
|
16
|
-
"stroke-[var(--color-
|
|
17
|
-
"stroke-[var(--color-
|
|
18
|
-
"stroke-[var(--color-
|
|
19
|
-
"stroke-[var(--color-
|
|
18
|
+
"stroke-[var(--color-chart-1)]",
|
|
19
|
+
"stroke-[var(--color-chart-2)]",
|
|
20
|
+
"stroke-[var(--color-chart-3)]",
|
|
21
|
+
"stroke-[var(--color-chart-4)]",
|
|
22
|
+
"stroke-[var(--color-chart-5)]",
|
|
20
23
|
];
|
|
21
24
|
return colors[index % colors.length];
|
|
22
25
|
};
|
|
23
26
|
/**
|
|
24
|
-
* Get color value for SVG elements and tooltips
|
|
27
|
+
* Get color value for SVG elements and tooltips.
|
|
28
|
+
* Fallback only — see getSeriesColorClass above.
|
|
25
29
|
*/
|
|
26
30
|
const getSeriesFillColor = (index) => {
|
|
27
31
|
const colorVars = [
|
|
28
|
-
"var(--color-
|
|
29
|
-
"var(--color-
|
|
30
|
-
"var(--color-
|
|
31
|
-
"var(--color-
|
|
32
|
+
"var(--color-chart-1)",
|
|
33
|
+
"var(--color-chart-2)",
|
|
34
|
+
"var(--color-chart-3)",
|
|
35
|
+
"var(--color-chart-4)",
|
|
36
|
+
"var(--color-chart-5)",
|
|
32
37
|
];
|
|
33
38
|
return colorVars[index % colorVars.length];
|
|
34
39
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { HorizontalBarChartProps } from "./HorizontalBarChart.types";
|
|
3
|
+
/**
|
|
4
|
+
* HorizontalBarChart — categories run down the left, values extend to the right.
|
|
5
|
+
*
|
|
6
|
+
* Conventionally a "bar chart" in strict statistical usage (where vertical bars are a
|
|
7
|
+
* "column chart"); most libraries expose it as an orientation. Here it is its own
|
|
8
|
+
* component: it shares BarChart's data model but none of its axis wiring, because the
|
|
9
|
+
* value/category axes are swapped.
|
|
10
|
+
*
|
|
11
|
+
* 🔴 Axis vocabulary: `CategoryYAxis` (categories, vertical) + `ValueXAxis` (values,
|
|
12
|
+
* horizontal) + `VerticalGrid`. Do NOT reach for XAxis/YAxis — those are the CATEGORY-
|
|
13
|
+
* bottom / VALUE-left pair a column chart needs; the axis family splits by what an axis
|
|
14
|
+
* measures, not which way it points.
|
|
15
|
+
*/
|
|
16
|
+
export declare const HorizontalBarChart: React.FC<HorizontalBarChartProps>;
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import React__default, { useRef, useId, useState, useEffect, useMemo } from 'react';
|
|
4
|
+
import { useReducedMotion, motion } from 'motion/react';
|
|
5
|
+
import { cn } from '../../../utils/cn.js';
|
|
6
|
+
import { useTooltipPosition } from '../hooks/useTooltipPosition.js';
|
|
7
|
+
import { useChartAccessibility } from '../hooks/useChartAccessibility.js';
|
|
8
|
+
import { useChartValidation } from '../hooks/useChartValidation.js';
|
|
9
|
+
import { useChartDimensions } from '../hooks/useChartDimensions.js';
|
|
10
|
+
import { ChartErrorBoundary } from '../shared/ChartErrorBoundary/ChartErrorBoundary.js';
|
|
11
|
+
import { CategoryYAxis } from '../shared/ChartAxis/CategoryYAxis.js';
|
|
12
|
+
import { ValueXAxis } from '../shared/ChartAxis/ValueXAxis.js';
|
|
13
|
+
import { VerticalGrid } from '../shared/ChartGrid/VerticalGrid.js';
|
|
14
|
+
import { ChartTooltip } from '../shared/ChartTooltip/ChartTooltip.js';
|
|
15
|
+
import { resolveLegendPosition, ChartLegend } from '../shared/ChartLegend/ChartLegend.js';
|
|
16
|
+
import { HORIZONTAL_BAR_CHART_DEFAULTS } from './HorizontalBarChart.types.js';
|
|
17
|
+
import { X_AXIS_MARGIN } from '../types/chart.types.js';
|
|
18
|
+
import { barEntranceTransition, BAR_GROUP_STAGGER } from '../utils/animation-utils.js';
|
|
19
|
+
import { BarRingDef, BarGlowRing, barDimOpacity, deriveBarEmphasis, barStrokeStyle } from '../utils/bar-emphasis.js';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Bar with only its FAR end rounded — the end the bar grows toward. The baseline end
|
|
23
|
+
* stays square so bars sit flush against the zero line, exactly as BarChart's
|
|
24
|
+
* `createRoundedTopBarPath` keeps a column's base square and rounds its top.
|
|
25
|
+
*
|
|
26
|
+
* `grow` is the direction the bar extends from zero: "right" for positive values,
|
|
27
|
+
* "left" for negative ones (whose far end is on the left).
|
|
28
|
+
*/
|
|
29
|
+
const createRoundedEndBarPath = (x, y, width, height, radius, grow) => {
|
|
30
|
+
const r = Math.max(0, Math.min(radius, width, height / 2));
|
|
31
|
+
if (grow === "right") {
|
|
32
|
+
return `
|
|
33
|
+
M ${x},${y}
|
|
34
|
+
L ${x + width - r},${y}
|
|
35
|
+
Q ${x + width},${y} ${x + width},${y + r}
|
|
36
|
+
L ${x + width},${y + height - r}
|
|
37
|
+
Q ${x + width},${y + height} ${x + width - r},${y + height}
|
|
38
|
+
L ${x},${y + height}
|
|
39
|
+
Z
|
|
40
|
+
`.trim();
|
|
41
|
+
}
|
|
42
|
+
return `
|
|
43
|
+
M ${x + width},${y}
|
|
44
|
+
L ${x + r},${y}
|
|
45
|
+
Q ${x},${y} ${x},${y + r}
|
|
46
|
+
L ${x},${y + height - r}
|
|
47
|
+
Q ${x},${y + height} ${x + r},${y + height}
|
|
48
|
+
L ${x + width},${y + height}
|
|
49
|
+
Z
|
|
50
|
+
`.trim();
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* HorizontalBarChart — categories run down the left, values extend to the right.
|
|
54
|
+
*
|
|
55
|
+
* Conventionally a "bar chart" in strict statistical usage (where vertical bars are a
|
|
56
|
+
* "column chart"); most libraries expose it as an orientation. Here it is its own
|
|
57
|
+
* component: it shares BarChart's data model but none of its axis wiring, because the
|
|
58
|
+
* value/category axes are swapped.
|
|
59
|
+
*
|
|
60
|
+
* 🔴 Axis vocabulary: `CategoryYAxis` (categories, vertical) + `ValueXAxis` (values,
|
|
61
|
+
* horizontal) + `VerticalGrid`. Do NOT reach for XAxis/YAxis — those are the CATEGORY-
|
|
62
|
+
* bottom / VALUE-left pair a column chart needs; the axis family splits by what an axis
|
|
63
|
+
* measures, not which way it points.
|
|
64
|
+
*/
|
|
65
|
+
const HorizontalBarChart = ({ data, config, className, width = "100%", height = 400, title, description, enableKeyboardNavigation = true, showGrid = HORIZONTAL_BAR_CHART_DEFAULTS.showGrid, showXAxis = HORIZONTAL_BAR_CHART_DEFAULTS.showXAxis, showYAxis = HORIZONTAL_BAR_CHART_DEFAULTS.showYAxis, legend, minValue: propMinValue, maxValue: propMaxValue, barRadius, radius, // @deprecated — mapped to barRadius below, same cascade as BarChart
|
|
66
|
+
gap = HORIZONTAL_BAR_CHART_DEFAULTS.gap, categoryGap = HORIZONTAL_BAR_CHART_DEFAULTS.categoryGap, categoryWidth = HORIZONTAL_BAR_CHART_DEFAULTS.categoryWidth, colors, showAnimation = HORIZONTAL_BAR_CHART_DEFAULTS.showAnimation, showValidationWarnings = process.env.NODE_ENV === "development", darkMode = false, valueFormatter, }) => {
|
|
67
|
+
var _a;
|
|
68
|
+
const containerRef = useRef(null);
|
|
69
|
+
const { dimensions, measured } = useChartDimensions(containerRef);
|
|
70
|
+
const shouldReduceMotion = useReducedMotion();
|
|
71
|
+
// Sanitised for SVG url(#…) refs, matching LollipopChart — useId's format is a React
|
|
72
|
+
// implementation detail and has historically contained characters that break a
|
|
73
|
+
// fragment reference.
|
|
74
|
+
const chartId = useId().replace(/[^a-zA-Z0-9_-]/g, "");
|
|
75
|
+
const [hoveredKey, setHoveredKey] = useState(null);
|
|
76
|
+
// Entrance runs once; afterwards `barEntranceTransition` drops the staggered opacity
|
|
77
|
+
// delay so hover/data updates respond immediately instead of re-queueing behind it.
|
|
78
|
+
const [hasAnimated, setHasAnimated] = useState(false);
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
setHasAnimated(true);
|
|
81
|
+
}, [shouldReduceMotion, showAnimation]);
|
|
82
|
+
const isMobile = typeof window !== "undefined" &&
|
|
83
|
+
("ontouchstart" in window || navigator.maxTouchPoints > 0);
|
|
84
|
+
const { tooltipData, tooltipRef, handleMouseEnter, handleMouseMove, handleMouseLeave } = useTooltipPosition({ containerRef, isMobile });
|
|
85
|
+
const { isValid, sanitizedData, safeScale } = useChartValidation(data, config, {
|
|
86
|
+
autoSanitize: true,
|
|
87
|
+
// Wired, not decorative: ESLint caught this prop destructured-but-unread on the
|
|
88
|
+
// first draft — i.e. the exact dead-prop pattern the chart family is full of.
|
|
89
|
+
logWarnings: showValidationWarnings,
|
|
90
|
+
});
|
|
91
|
+
const seriesKeys = useMemo(() => Object.keys(config), [config]);
|
|
92
|
+
const { chartAccessibilityProps, descriptionProps, focusedElementIndex, isKeyboardMode, } = useChartAccessibility({
|
|
93
|
+
chartType: "bar",
|
|
94
|
+
data: sanitizedData,
|
|
95
|
+
config,
|
|
96
|
+
title,
|
|
97
|
+
description,
|
|
98
|
+
enableKeyboardNavigation,
|
|
99
|
+
});
|
|
100
|
+
const resolvedRadius = (_a = barRadius !== null && barRadius !== void 0 ? barRadius : radius) !== null && _a !== void 0 ? _a : HORIZONTAL_BAR_CHART_DEFAULTS.barRadius;
|
|
101
|
+
const seriesColor = (key, index) => { var _a, _b, _c; return (_c = (_a = colors === null || colors === void 0 ? void 0 : colors[index % colors.length]) !== null && _a !== void 0 ? _a : (_b = config[key]) === null || _b === void 0 ? void 0 : _b.color) !== null && _c !== void 0 ? _c : "var(--color-primary)"; };
|
|
102
|
+
// Category labels live on the LEFT, so their width is the left margin. Unlike a
|
|
103
|
+
// bottom axis (which uses the shared X_AXIS_MARGIN so side-by-side charts align),
|
|
104
|
+
// this is caller-controlled — no constant can know how wide "United Kingdom" is.
|
|
105
|
+
const margin = useMemo(() => ({
|
|
106
|
+
top: 8,
|
|
107
|
+
right: 16,
|
|
108
|
+
bottom: showXAxis ? X_AXIS_MARGIN : 8,
|
|
109
|
+
left: showYAxis ? categoryWidth : 8,
|
|
110
|
+
}), [showXAxis, showYAxis, categoryWidth]);
|
|
111
|
+
const innerWidth = Math.max(0, dimensions.width - margin.left - margin.right);
|
|
112
|
+
const innerHeight = Math.max(0, dimensions.height - margin.top - margin.bottom);
|
|
113
|
+
// 🔴 Range via safeScale.calculateRange, exactly as BarChart does — NOT a hand-rolled
|
|
114
|
+
// min/max. It returns a *nice* range, which the axis's Heckbert tick generation then
|
|
115
|
+
// lands on exactly. A raw data max (e.g. 1280) desyncs the two: generateNiceTicks
|
|
116
|
+
// emits 0…2000 while the scale still divides by 1280, so the upper ticks position
|
|
117
|
+
// past the end of the axis. `includeZero` keeps every bar on a shared baseline.
|
|
118
|
+
const { min: minValue, max: maxValue } = safeScale.calculateRange({
|
|
119
|
+
minValue: propMinValue,
|
|
120
|
+
maxValue: propMaxValue,
|
|
121
|
+
includeZero: true,
|
|
122
|
+
});
|
|
123
|
+
const range = maxValue - minValue;
|
|
124
|
+
const scaleX = (value) => range > 0 ? ((value - minValue) / range) * innerWidth : 0;
|
|
125
|
+
// Where value 0 sits — bars grow right from here (or left, for negatives).
|
|
126
|
+
const zeroX = margin.left + scaleX(0);
|
|
127
|
+
const categoryCount = sanitizedData.length;
|
|
128
|
+
const totalCategoryGap = Math.max(0, (categoryCount - 1) * categoryGap);
|
|
129
|
+
const categoryHeight = categoryCount > 0
|
|
130
|
+
? Math.max(0, (innerHeight - totalCategoryGap) / categoryCount)
|
|
131
|
+
: 0;
|
|
132
|
+
// Each series gets a row inside its category band.
|
|
133
|
+
const barHeight = seriesKeys.length > 0
|
|
134
|
+
? Math.max(0, (categoryHeight - gap * (seriesKeys.length - 1)) / seriesKeys.length)
|
|
135
|
+
: 0;
|
|
136
|
+
const legendPosition = resolveLegendPosition(legend, config);
|
|
137
|
+
const legendItems = useMemo(() => seriesKeys.map((key, index) => {
|
|
138
|
+
var _a, _b;
|
|
139
|
+
return ({
|
|
140
|
+
key,
|
|
141
|
+
label: (_b = (_a = config[key]) === null || _a === void 0 ? void 0 : _a.label) !== null && _b !== void 0 ? _b : key,
|
|
142
|
+
color: seriesColor(key, index),
|
|
143
|
+
});
|
|
144
|
+
}),
|
|
145
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
146
|
+
[seriesKeys, config, colors]);
|
|
147
|
+
const formatValue = (value) => valueFormatter ? valueFormatter(value) : String(value);
|
|
148
|
+
if (!isValid || categoryCount === 0) {
|
|
149
|
+
return (jsx("div", { ref: containerRef, className: cn("flex items-center justify-center", darkMode && "dark", className), style: { width, height }, children: jsx("span", { className: "text-sm text-[var(--color-text-muted)]", children: "Invalid Chart Data" }) }));
|
|
150
|
+
}
|
|
151
|
+
return (jsx(ChartErrorBoundary, { children: jsxs("div", { ref: containerRef, className: cn("relative flex flex-col", darkMode && "dark", className), style: { width, height }, ...chartAccessibilityProps, children: [description && jsx("span", { ...descriptionProps }), legendPosition === "top" && (jsx(ChartLegend, { items: legendItems, className: "shrink-0 pb-2" })), jsx("div", { className: "relative min-h-0 flex-1", children: jsxs("svg", { width: "100%", height: "100%", viewBox: `0 0 ${dimensions.width} ${dimensions.height}`,
|
|
152
|
+
// The hover glow ring bleeds past the plot box, so it must not be clipped.
|
|
153
|
+
style: { overflow: "visible" }, children: [jsx("defs", { children: seriesKeys.map((key, index) => (jsx(BarRingDef, { ringId: `${chartId}-hbar-ring-${index}`, color: seriesColor(key, index) }, key))) }), jsx(VerticalGrid, { show: showGrid && measured, x: margin.left, y: margin.top, width: innerWidth, height: innerHeight, lineCount: 5 }), jsx(CategoryYAxis, { show: showYAxis && measured, data: sanitizedData, x: margin.left, y: margin.top, height: innerHeight, categoryHeight: categoryHeight, categoryGap: categoryGap, maxLabelWidth: Math.max(0, categoryWidth - 16) }), jsx(ValueXAxis, { show: showXAxis && measured, min: minValue, max: maxValue, x: margin.left, y: margin.top + innerHeight, width: innerWidth }), measured && (jsx("g", { className: "chart-hbars", children: sanitizedData.map((item, categoryIndex) => {
|
|
154
|
+
const bandY = margin.top + categoryIndex * (categoryHeight + categoryGap);
|
|
155
|
+
return (jsx("g", { children: seriesKeys.map((key, seriesIndex) => {
|
|
156
|
+
const rawValue = item[key];
|
|
157
|
+
const isNull = rawValue === null ||
|
|
158
|
+
rawValue === undefined ||
|
|
159
|
+
!(typeof rawValue === "number" && isFinite(rawValue));
|
|
160
|
+
if (isNull)
|
|
161
|
+
return null;
|
|
162
|
+
const value = rawValue;
|
|
163
|
+
const barY = bandY + seriesIndex * (barHeight + gap);
|
|
164
|
+
const valueX = margin.left + scaleX(value);
|
|
165
|
+
const barX = Math.min(zeroX, valueX);
|
|
166
|
+
const barWidth = Math.abs(valueX - zeroX);
|
|
167
|
+
const fillColor = seriesColor(key, seriesIndex);
|
|
168
|
+
const hoverKey = `${categoryIndex}-${key}`;
|
|
169
|
+
const isHovered = hoveredKey === hoverKey;
|
|
170
|
+
const isFocused = isKeyboardMode && focusedElementIndex === categoryIndex;
|
|
171
|
+
const { isEmphasized, shouldReduceOpacity } = deriveBarEmphasis({
|
|
172
|
+
isHovered,
|
|
173
|
+
isFocused,
|
|
174
|
+
isAnyBarHovered: hoveredKey !== null,
|
|
175
|
+
// Fills are flat, but hover still gets BarChart's premium
|
|
176
|
+
// response: glow ring + colored stroke + the stronger dim.
|
|
177
|
+
isGradientVariant: false,
|
|
178
|
+
premiumEmphasis: true,
|
|
179
|
+
});
|
|
180
|
+
const stroke = barStrokeStyle({
|
|
181
|
+
isFocused,
|
|
182
|
+
isEmphasized,
|
|
183
|
+
isGradientVariant: false,
|
|
184
|
+
fillColor,
|
|
185
|
+
// No resting hairline: these bars read as flat shapes. The
|
|
186
|
+
// focus/emphasis strokes still apply, so keyboard focus and
|
|
187
|
+
// hover stay visible.
|
|
188
|
+
showRestingStroke: false,
|
|
189
|
+
});
|
|
190
|
+
const pathD = createRoundedEndBarPath(barX, barY, barWidth, barHeight, resolvedRadius, value >= 0 ? "right" : "left");
|
|
191
|
+
return (jsxs(React__default.Fragment, { children: [jsx(BarGlowRing, { show: isEmphasized, pathD: pathD, color: fillColor, barWidth: barHeight, filter: `url(#${chartId}-hbar-ring-${seriesIndex})` }), jsx(motion.g, { style: {
|
|
192
|
+
cursor: "pointer",
|
|
193
|
+
transformBox: "fill-box",
|
|
194
|
+
originX: value >= 0 ? 0 : 1,
|
|
195
|
+
originY: 0.5,
|
|
196
|
+
}, initial: showAnimation && !shouldReduceMotion
|
|
197
|
+
? { scaleX: 0, opacity: 0 }
|
|
198
|
+
: { scaleX: 1, opacity: 1 }, animate: {
|
|
199
|
+
scaleX: 1,
|
|
200
|
+
opacity: barDimOpacity(shouldReduceOpacity, true),
|
|
201
|
+
}, transition: barEntranceTransition(categoryIndex * BAR_GROUP_STAGGER, hasAnimated), onMouseEnter: (e) => {
|
|
202
|
+
var _a, _b;
|
|
203
|
+
setHoveredKey(hoverKey);
|
|
204
|
+
handleMouseEnter(e, {
|
|
205
|
+
category: ((_a = item.name) !== null && _a !== void 0 ? _a : `Category ${categoryIndex + 1}`).toString(),
|
|
206
|
+
series: [
|
|
207
|
+
{
|
|
208
|
+
key,
|
|
209
|
+
label: ((_b = config[key]) === null || _b === void 0 ? void 0 : _b.label) || key,
|
|
210
|
+
value: formatValue(value),
|
|
211
|
+
color: fillColor,
|
|
212
|
+
},
|
|
213
|
+
],
|
|
214
|
+
}, {
|
|
215
|
+
x: valueX,
|
|
216
|
+
y: barY + barHeight / 2,
|
|
217
|
+
dimensions,
|
|
218
|
+
});
|
|
219
|
+
}, onMouseMove: (e) => handleMouseMove(e, {
|
|
220
|
+
x: valueX,
|
|
221
|
+
y: barY + barHeight / 2,
|
|
222
|
+
dimensions,
|
|
223
|
+
}), onMouseLeave: () => {
|
|
224
|
+
setHoveredKey(null);
|
|
225
|
+
handleMouseLeave();
|
|
226
|
+
}, children: jsx("path", { d: pathD, fill: fillColor, stroke: stroke.stroke, strokeWidth: stroke.strokeWidth, strokeOpacity: stroke.strokeOpacity, strokeLinejoin: "round",
|
|
227
|
+
// 🔴 Matches BarChart. Required here specifically: the
|
|
228
|
+
// parent <motion.g> carries a scaleX transform, so
|
|
229
|
+
// without this the stroke is scaled with the bar and the
|
|
230
|
+
// hover outline renders far heavier than BarChart's.
|
|
231
|
+
vectorEffect: "non-scaling-stroke" }) })] }, key));
|
|
232
|
+
}) }, categoryIndex));
|
|
233
|
+
}) }))] }) }), legendPosition === "bottom" && (jsx(ChartLegend, { items: legendItems, className: "shrink-0 pt-2" })), jsx(ChartTooltip, { tooltipRef: tooltipRef, content: tooltipData === null || tooltipData === void 0 ? void 0 : tooltipData.content, active: !!tooltipData, position: tooltipData ? { x: tooltipData.x, y: tooltipData.y } : { x: 0, y: 0 } })] }) }));
|
|
234
|
+
};
|
|
235
|
+
HorizontalBarChart.displayName = "HorizontalBarChart";
|
|
236
|
+
|
|
237
|
+
export { HorizontalBarChart };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { BaseChartProps, StandardChartDisplayProps, StandardVisualProps } from "../types/chart.types";
|
|
2
|
+
/**
|
|
3
|
+
* Visual props that actually apply to a horizontal bar chart.
|
|
4
|
+
*
|
|
5
|
+
* 🔴 Narrowed with `Omit` on purpose — see the note on `StandardVisualProps`.
|
|
6
|
+
* Kept: `barRadius` (+ its deprecated `radius` alias) and `gap`.
|
|
7
|
+
* Dropped: dot radius, stroke width, and the line/area/stacked-only props.
|
|
8
|
+
*/
|
|
9
|
+
export type HorizontalBarVisualProps = Omit<StandardVisualProps, "dotRadius" | "strokeWidth" | "curved" | "curveType" | "showDots" | "fillOpacity" | "showStroke" | "stacked">;
|
|
10
|
+
/**
|
|
11
|
+
* 🔴 `variant` is Omitted, not inherited: these bars are flat, single-colour shapes —
|
|
12
|
+
* there is no gradient/minimal treatment to select. Leaving the inherited prop in place
|
|
13
|
+
* would publish a control that silently does nothing (and would reach the generative
|
|
14
|
+
* schema, where an LLM would emit it). Add it back only alongside an implementation.
|
|
15
|
+
*/
|
|
16
|
+
export interface HorizontalBarChartProps extends BaseChartProps, Omit<StandardChartDisplayProps, "variant">, HorizontalBarVisualProps {
|
|
17
|
+
/** Gap between category rows. */
|
|
18
|
+
categoryGap?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Width reserved for the category labels running down the left. Category names are
|
|
21
|
+
* arbitrary ("United Kingdom"), so unlike a bottom axis there is no shared constant
|
|
22
|
+
* that can know how much room they need — hence a prop rather than `X_AXIS_MARGIN`.
|
|
23
|
+
* @default 120
|
|
24
|
+
*/
|
|
25
|
+
categoryWidth?: number;
|
|
26
|
+
/**
|
|
27
|
+
* Custom color palette for bar series, applied in order and cycled if there are more
|
|
28
|
+
* series than colors. Any valid CSS color, including CSS variables.
|
|
29
|
+
* @example ['var(--color-primary)', 'var(--color-success)']
|
|
30
|
+
*/
|
|
31
|
+
colors?: string[];
|
|
32
|
+
/** Whether to play the staggered grow-from-left entrance on mount. */
|
|
33
|
+
showAnimation?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Log data-validation warnings to the console.
|
|
36
|
+
* @default true in development
|
|
37
|
+
*/
|
|
38
|
+
showValidationWarnings?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Force dark mode styling for the chart. Use when placing the chart on a dark
|
|
41
|
+
* background while the page is in light mode.
|
|
42
|
+
*/
|
|
43
|
+
darkMode?: boolean;
|
|
44
|
+
/** Formats the value shown in the tooltip. */
|
|
45
|
+
valueFormatter?: (value: number) => string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* 🔴 Picks explicitly rather than spreading `...CHART_DEFAULTS` — the spread pulled in a
|
|
49
|
+
* default for every other chart's props, so this object advertised values
|
|
50
|
+
* HorizontalBarChart never reads. List only what the component actually consumes.
|
|
51
|
+
*/
|
|
52
|
+
export declare const HORIZONTAL_BAR_CHART_DEFAULTS: {
|
|
53
|
+
readonly showGrid: true;
|
|
54
|
+
readonly showXAxis: true;
|
|
55
|
+
readonly showYAxis: true;
|
|
56
|
+
readonly enableKeyboardNavigation: true;
|
|
57
|
+
readonly barRadius: 32;
|
|
58
|
+
readonly gap: 4;
|
|
59
|
+
readonly categoryGap: 16;
|
|
60
|
+
readonly categoryWidth: 120;
|
|
61
|
+
readonly showAnimation: true;
|
|
62
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { CHART_DEFAULTS } from '../types/chart.types.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 🔴 Picks explicitly rather than spreading `...CHART_DEFAULTS` — the spread pulled in a
|
|
5
|
+
* default for every other chart's props, so this object advertised values
|
|
6
|
+
* HorizontalBarChart never reads. List only what the component actually consumes.
|
|
7
|
+
*/
|
|
8
|
+
const HORIZONTAL_BAR_CHART_DEFAULTS = {
|
|
9
|
+
showGrid: CHART_DEFAULTS.showGrid,
|
|
10
|
+
showXAxis: CHART_DEFAULTS.showXAxis,
|
|
11
|
+
showYAxis: CHART_DEFAULTS.showYAxis,
|
|
12
|
+
enableKeyboardNavigation: CHART_DEFAULTS.enableKeyboardNavigation,
|
|
13
|
+
barRadius: CHART_DEFAULTS.barRadius,
|
|
14
|
+
gap: CHART_DEFAULTS.gap,
|
|
15
|
+
categoryGap: CHART_DEFAULTS.categoryGap,
|
|
16
|
+
categoryWidth: 120,
|
|
17
|
+
// Not in CHART_DEFAULTS — declared here, as BarChart does.
|
|
18
|
+
showAnimation: true,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { HORIZONTAL_BAR_CHART_DEFAULTS };
|
|
@@ -18,39 +18,22 @@ import { generateCurvePath } from '../utils/path-utils.js';
|
|
|
18
18
|
import { LINE_CHART_DEFAULTS } from './LineChart.types.js';
|
|
19
19
|
import { X_AXIS_MARGIN } from '../types/chart.types.js';
|
|
20
20
|
import { RISE_FROM_BASELINE, riseTransition, SCALE_FROM_CENTER, dotEntranceTransition, HALO_FADE_TRANSITION } from '../utils/animation-utils.js';
|
|
21
|
+
import { resolveSeriesColor } from '../utils/series-color.js';
|
|
22
|
+
import { chartTheme } from '../theme/chart.theme.js';
|
|
21
23
|
|
|
22
|
-
//
|
|
24
|
+
// Categorical chart-N tokens, decoupled from the semantic status colors
|
|
23
25
|
const getSeriesColorClass = (index) => {
|
|
24
26
|
const colors = [
|
|
25
|
-
"stroke-[var(--color-
|
|
26
|
-
"stroke-[var(--color-
|
|
27
|
-
"stroke-[var(--color-
|
|
28
|
-
"stroke-[var(--color-
|
|
27
|
+
"stroke-[var(--color-chart-1)]",
|
|
28
|
+
"stroke-[var(--color-chart-2)]",
|
|
29
|
+
"stroke-[var(--color-chart-3)]",
|
|
30
|
+
"stroke-[var(--color-chart-4)]",
|
|
31
|
+
"stroke-[var(--color-chart-5)]",
|
|
29
32
|
];
|
|
30
33
|
return colors[index % colors.length];
|
|
31
34
|
};
|
|
32
35
|
// Get color value for SVG elements and tooltips
|
|
33
|
-
const getSeriesFillColor = (index, key, config) =>
|
|
34
|
-
var _a;
|
|
35
|
-
if (key && config && ((_a = config[key]) === null || _a === void 0 ? void 0 : _a.color)) {
|
|
36
|
-
const customColor = config[key].color;
|
|
37
|
-
if (!customColor.startsWith("var(") &&
|
|
38
|
-
!customColor.startsWith("#") &&
|
|
39
|
-
!customColor.startsWith("rgb") &&
|
|
40
|
-
!customColor.startsWith("hsl") &&
|
|
41
|
-
customColor.includes("-")) {
|
|
42
|
-
return `var(--color-${customColor})`;
|
|
43
|
-
}
|
|
44
|
-
return customColor;
|
|
45
|
-
}
|
|
46
|
-
const colorVars = [
|
|
47
|
-
"var(--color-primary)",
|
|
48
|
-
"var(--color-warning)",
|
|
49
|
-
"var(--color-success)",
|
|
50
|
-
"var(--color-danger)",
|
|
51
|
-
];
|
|
52
|
-
return colorVars[index % colorVars.length];
|
|
53
|
-
};
|
|
36
|
+
const getSeriesFillColor = (index, key, config) => resolveSeriesColor(index, key, config, chartTheme.baseStyle.colors.series);
|
|
54
37
|
const LineChart = ({ data, config,
|
|
55
38
|
// Standardized display props with defaults
|
|
56
39
|
showGrid = LINE_CHART_DEFAULTS.showGrid, showXAxis = LINE_CHART_DEFAULTS.showXAxis, showYAxis = LINE_CHART_DEFAULTS.showYAxis, legend, minValue: propMinValue, maxValue: propMaxValue,
|
|
@@ -9,25 +9,22 @@ export interface LineChartProps extends BaseChartProps, Omit<StandardChartDispla
|
|
|
9
9
|
curveType?: 'linear' | 'monotone';
|
|
10
10
|
showDots?: boolean;
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Default values using centralized defaults.
|
|
14
|
+
*
|
|
15
|
+
* 🔴 Picks explicitly rather than spreading `...CHART_DEFAULTS` — the spread pulled in a
|
|
16
|
+
* default for every other chart's props, so this object advertised values LineChart
|
|
17
|
+
* never reads. List only what the component actually consumes.
|
|
18
|
+
*/
|
|
12
19
|
export declare const LINE_CHART_DEFAULTS: {
|
|
20
|
+
readonly showGrid: true;
|
|
21
|
+
readonly showXAxis: true;
|
|
22
|
+
readonly showYAxis: true;
|
|
23
|
+
readonly enableKeyboardNavigation: true;
|
|
13
24
|
readonly color: undefined;
|
|
14
25
|
readonly dotRadius: 3;
|
|
15
|
-
readonly radius: 3;
|
|
16
26
|
readonly strokeWidth: 2;
|
|
17
27
|
readonly curved: true;
|
|
18
28
|
readonly curveType: import("..").CurveType;
|
|
19
29
|
readonly showDots: false;
|
|
20
|
-
readonly showGrid: true;
|
|
21
|
-
readonly showXAxis: true;
|
|
22
|
-
readonly showYAxis: true;
|
|
23
|
-
readonly barRadius: 32;
|
|
24
|
-
readonly cellRadius: 4;
|
|
25
|
-
readonly gap: 4;
|
|
26
|
-
readonly categoryGap: 16;
|
|
27
|
-
readonly fillOpacity: 0.3;
|
|
28
|
-
readonly showStroke: true;
|
|
29
|
-
readonly orientation: "vertical" | "horizontal";
|
|
30
|
-
readonly stacked: false;
|
|
31
|
-
readonly variant: import("..").ChartVariant;
|
|
32
|
-
readonly enableKeyboardNavigation: true;
|
|
33
30
|
};
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import { CHART_DEFAULTS } from '../types/chart.types.js';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Default values using centralized defaults.
|
|
5
|
+
*
|
|
6
|
+
* 🔴 Picks explicitly rather than spreading `...CHART_DEFAULTS` — the spread pulled in a
|
|
7
|
+
* default for every other chart's props, so this object advertised values LineChart
|
|
8
|
+
* never reads. List only what the component actually consumes.
|
|
9
|
+
*/
|
|
4
10
|
const LINE_CHART_DEFAULTS = {
|
|
5
|
-
|
|
11
|
+
showGrid: CHART_DEFAULTS.showGrid,
|
|
12
|
+
showXAxis: CHART_DEFAULTS.showXAxis,
|
|
13
|
+
showYAxis: CHART_DEFAULTS.showYAxis,
|
|
14
|
+
enableKeyboardNavigation: CHART_DEFAULTS.enableKeyboardNavigation,
|
|
6
15
|
color: undefined, // Defaults to auto-cycling through semantic colors
|
|
7
16
|
dotRadius: CHART_DEFAULTS.dotRadius, // 20 - For dot markers
|
|
8
|
-
radius: CHART_DEFAULTS.dotRadius, // @deprecated - kept for backward compatibility
|
|
9
17
|
strokeWidth: CHART_DEFAULTS.strokeWidth,
|
|
10
18
|
curved: CHART_DEFAULTS.curved,
|
|
11
19
|
curveType: CHART_DEFAULTS.curveType,
|