@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
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import type { ChartDataPoint } from '../../types/chart.types';
|
|
2
|
+
/**
|
|
3
|
+
* 🔴 No `color` / `fontSize` here on purpose. Axis lines and labels are themed via CSS
|
|
4
|
+
* variables (`stroke-[var(--color-border)]` and the text utilities), so both props were
|
|
5
|
+
* accepted and then ignored. Restyle an axis with `className`, or change the token.
|
|
6
|
+
*/
|
|
2
7
|
export interface BaseAxisProps {
|
|
3
8
|
/** Whether to show the axis */
|
|
4
9
|
show?: boolean;
|
|
5
10
|
/** Custom className for styling */
|
|
6
11
|
className?: string;
|
|
7
|
-
/** Color of the axis line and text */
|
|
8
|
-
color?: string;
|
|
9
|
-
/** Font size for axis labels */
|
|
10
|
-
fontSize?: number;
|
|
11
12
|
/** Whether to show tick marks */
|
|
12
13
|
showTicks?: boolean;
|
|
13
14
|
/** Length of tick marks */
|
|
@@ -64,9 +65,73 @@ export interface YAxisProps extends BaseAxisProps {
|
|
|
64
65
|
showGrid?: boolean;
|
|
65
66
|
/** Width of the chart area for grid lines */
|
|
66
67
|
gridWidth?: number;
|
|
68
|
+
/** Custom className for the grid lines this axis draws (`className` styles the axis group) */
|
|
69
|
+
gridClassName?: string;
|
|
67
70
|
/** Custom tick values */
|
|
68
71
|
ticks?: number[];
|
|
69
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* A VALUE axis rendered horizontally (ticks along the bottom).
|
|
75
|
+
*
|
|
76
|
+
* The mirror of `YAxisProps`, for charts whose value axis runs left-to-right
|
|
77
|
+
* (HorizontalBarChart). Note `XAxis` is a CATEGORY axis despite also being
|
|
78
|
+
* horizontal — the two axis families are split by what they measure, not by
|
|
79
|
+
* which way they point.
|
|
80
|
+
*/
|
|
81
|
+
export interface ValueXAxisProps extends BaseAxisProps {
|
|
82
|
+
/** Minimum value for the axis */
|
|
83
|
+
min: number;
|
|
84
|
+
/** Maximum value for the axis */
|
|
85
|
+
max: number;
|
|
86
|
+
/** Number of ticks */
|
|
87
|
+
tickCount?: number;
|
|
88
|
+
/** X position of the axis */
|
|
89
|
+
x: number;
|
|
90
|
+
/** Y position of the axis (its baseline) */
|
|
91
|
+
y: number;
|
|
92
|
+
/** Width of the axis */
|
|
93
|
+
width: number;
|
|
94
|
+
/** Text anchor for labels */
|
|
95
|
+
textAnchor?: 'start' | 'middle' | 'end';
|
|
96
|
+
/** Custom tick formatter */
|
|
97
|
+
tickFormatter?: (value: number) => string;
|
|
98
|
+
/** Whether to draw grid lines up from each tick */
|
|
99
|
+
showGrid?: boolean;
|
|
100
|
+
/** Height of the chart area for grid lines */
|
|
101
|
+
gridHeight?: number;
|
|
102
|
+
/** Custom tick values */
|
|
103
|
+
ticks?: number[];
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* A CATEGORY axis rendered vertically (one label per category, down the left).
|
|
107
|
+
*
|
|
108
|
+
* The mirror of `XAxisProps`, for charts whose categories stack vertically
|
|
109
|
+
* (HorizontalBarChart).
|
|
110
|
+
*/
|
|
111
|
+
export interface CategoryYAxisProps extends BaseAxisProps {
|
|
112
|
+
/** Data points for the axis */
|
|
113
|
+
data: Array<{
|
|
114
|
+
name?: string;
|
|
115
|
+
label?: string;
|
|
116
|
+
[key: string]: string | number | null | undefined;
|
|
117
|
+
}>;
|
|
118
|
+
/** X position of the axis (its line) */
|
|
119
|
+
x: number;
|
|
120
|
+
/** Y position of the axis */
|
|
121
|
+
y: number;
|
|
122
|
+
/** Height of the axis */
|
|
123
|
+
height: number;
|
|
124
|
+
/** Height of each category/bar group */
|
|
125
|
+
categoryHeight: number;
|
|
126
|
+
/** Gap between categories */
|
|
127
|
+
categoryGap?: number;
|
|
128
|
+
/** Text anchor for labels */
|
|
129
|
+
textAnchor?: 'start' | 'middle' | 'end';
|
|
130
|
+
/** Custom label formatter */
|
|
131
|
+
labelFormatter?: (value: ChartDataPoint, index: number) => string;
|
|
132
|
+
/** Maximum width for labels before truncation */
|
|
133
|
+
maxLabelWidth?: number;
|
|
134
|
+
}
|
|
70
135
|
export interface AxisTickProps {
|
|
71
136
|
/** Value of the tick */
|
|
72
137
|
value: number | string;
|
|
@@ -82,10 +147,6 @@ export interface AxisTickProps {
|
|
|
82
147
|
textAnchor?: 'start' | 'middle' | 'end';
|
|
83
148
|
/** Custom formatter */
|
|
84
149
|
formatter?: (value: number | string) => string;
|
|
85
|
-
/** Font size */
|
|
86
|
-
fontSize?: number;
|
|
87
|
-
/** Color */
|
|
88
|
-
color?: string;
|
|
89
150
|
/** Rotation angle */
|
|
90
151
|
rotation?: number;
|
|
91
152
|
/** Maximum width before truncation */
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { ValueXAxisProps } from "./ChartAxis.types";
|
|
3
|
+
/**
|
|
4
|
+
* ValueXAxis component for charts
|
|
5
|
+
* Renders a horizontal VALUE axis: nice ticks, labels below, optional grid lines
|
|
6
|
+
* rising from each tick.
|
|
7
|
+
*
|
|
8
|
+
* This is `YAxis` rotated — same Heckbert nice-ticks and the same tick formatting,
|
|
9
|
+
* so a horizontal chart's value ticks read identically to a vertical one's. Kept as a
|
|
10
|
+
* separate component rather than an `orientation` prop on YAxis because every position
|
|
11
|
+
* calculation and text anchor differs; a branchy shared axis would be harder to follow
|
|
12
|
+
* than two flat mirrors.
|
|
13
|
+
*/
|
|
14
|
+
export declare const ValueXAxis: React.FC<ValueXAxisProps>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
import { cn } from '../../../../utils/cn.js';
|
|
4
|
+
import { ChartText } from '../ChartText/ChartText.js';
|
|
5
|
+
import { generateNiceTicks } from '../../utils/chart-validation.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* ValueXAxis component for charts
|
|
9
|
+
* Renders a horizontal VALUE axis: nice ticks, labels below, optional grid lines
|
|
10
|
+
* rising from each tick.
|
|
11
|
+
*
|
|
12
|
+
* This is `YAxis` rotated — same Heckbert nice-ticks and the same tick formatting,
|
|
13
|
+
* so a horizontal chart's value ticks read identically to a vertical one's. Kept as a
|
|
14
|
+
* separate component rather than an `orientation` prop on YAxis because every position
|
|
15
|
+
* calculation and text anchor differs; a branchy shared axis would be harder to follow
|
|
16
|
+
* than two flat mirrors.
|
|
17
|
+
*/
|
|
18
|
+
const ValueXAxis = React__default.memo(({ min, max, tickCount = 5, x, y, width, show = true, className, showTicks = true, tickLength = 6, tickPadding = 12, textAnchor = "middle", tickFormatter, showGrid = false, gridHeight = 0, ticks: customTicks, }) => {
|
|
19
|
+
if (!show)
|
|
20
|
+
return null;
|
|
21
|
+
// Generate tick values using Heckbert's nice numbers algorithm (same as YAxis)
|
|
22
|
+
const ticks = (() => {
|
|
23
|
+
if (customTicks)
|
|
24
|
+
return customTicks;
|
|
25
|
+
if (tickCount <= 1)
|
|
26
|
+
return [min];
|
|
27
|
+
const { ticks: niceTicks } = generateNiceTicks(min, max, tickCount);
|
|
28
|
+
return niceTicks;
|
|
29
|
+
})();
|
|
30
|
+
// Identical to YAxis.formatTick — the two must agree, or the same dataset would
|
|
31
|
+
// label differently depending on orientation.
|
|
32
|
+
const formatTick = (value) => {
|
|
33
|
+
if (tickFormatter) {
|
|
34
|
+
return tickFormatter(value);
|
|
35
|
+
}
|
|
36
|
+
if (Math.abs(value) >= 1000000) {
|
|
37
|
+
return `${Math.round(value / 1000000)}M`;
|
|
38
|
+
}
|
|
39
|
+
else if (Math.abs(value) >= 1000) {
|
|
40
|
+
return `${Math.round(value / 1000)}K`;
|
|
41
|
+
}
|
|
42
|
+
else if (Number.isInteger(value) ||
|
|
43
|
+
Math.abs(value - Math.round(value)) < 0.01) {
|
|
44
|
+
return Math.round(value).toString();
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
return value.toFixed(1);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const getTickX = (value) => {
|
|
51
|
+
if (max === min) {
|
|
52
|
+
return x + width / 2; // Center position when no range
|
|
53
|
+
}
|
|
54
|
+
const ratio = (value - min) / (max - min);
|
|
55
|
+
return x + ratio * width;
|
|
56
|
+
};
|
|
57
|
+
return (jsxs("g", { className: cn("chart-value-x-axis", className), children: [jsx("line", { x1: x, y1: y, x2: x + width, y2: y, className: "stroke-[var(--color-border)]", strokeWidth: 1 }), ticks.map((tick, index) => {
|
|
58
|
+
const tickX = getTickX(tick);
|
|
59
|
+
return (jsxs("g", { children: [showGrid && gridHeight > 0 && (jsx("line", { x1: tickX, y1: y, x2: tickX, y2: y - gridHeight, className: "opacity-80 stroke-[var(--color-border)]", strokeWidth: 1 })), showTicks && (jsx("line", { x1: tickX, y1: y, x2: tickX, y2: y + tickLength, className: "stroke-[var(--color-border)]", strokeWidth: 1 })), jsx(ChartText, { x: tickX, y: y + tickLength + tickPadding, textAnchor: textAnchor, children: formatTick(tick) })] }, index));
|
|
60
|
+
})] }));
|
|
61
|
+
});
|
|
62
|
+
ValueXAxis.displayName = "ValueXAxis";
|
|
63
|
+
|
|
64
|
+
export { ValueXAxis };
|
|
@@ -7,7 +7,7 @@ import { ChartText } from '../ChartText/ChartText.js';
|
|
|
7
7
|
* XAxis component for charts
|
|
8
8
|
* Renders horizontal axis with labels and optional tick marks
|
|
9
9
|
*/
|
|
10
|
-
const XAxis = React__default.memo(({ data, x, y, width, categoryWidth, categoryGap = 0, show = true, className,
|
|
10
|
+
const XAxis = React__default.memo(({ data, x, y, width, categoryWidth, categoryGap = 0, show = true, className, showTicks = true, tickLength = 6, tickPadding = 12, textAnchor = "middle", labelRotation = 0, labelFormatter, maxLabelWidth = 100, alignWithEdge = false, }) => {
|
|
11
11
|
if (!show)
|
|
12
12
|
return null;
|
|
13
13
|
const formatLabel = (item, index) => {
|
|
@@ -8,7 +8,7 @@ import { generateNiceTicks } from '../../utils/chart-validation.js';
|
|
|
8
8
|
* YAxis component for charts
|
|
9
9
|
* Renders vertical axis with labels, optional tick marks, and grid lines
|
|
10
10
|
*/
|
|
11
|
-
const YAxis = React__default.memo(({ min, max, tickCount = 5, x, y, height, show = true, className,
|
|
11
|
+
const YAxis = React__default.memo(({ min, max, tickCount = 5, x, y, height, show = true, className, showTicks = true, tickLength = 6, tickPadding = 8, textAnchor = "end", tickFormatter, showGrid = false, gridWidth = 0, gridClassName, ticks: customTicks, }) => {
|
|
12
12
|
if (!show)
|
|
13
13
|
return null;
|
|
14
14
|
// Generate tick values using Heckbert's nice numbers algorithm
|
|
@@ -48,7 +48,7 @@ const YAxis = React__default.memo(({ min, max, tickCount = 5, x, y, height, show
|
|
|
48
48
|
};
|
|
49
49
|
return (jsxs("g", { className: cn("chart-y-axis", className), children: [jsx("line", { x1: x, y1: y, x2: x, y2: y + height, className: "stroke-[var(--color-border)]", strokeWidth: 1 }), ticks.map((tick, index) => {
|
|
50
50
|
const tickY = getTickY(tick);
|
|
51
|
-
return (jsxs("g", { children: [showGrid && gridWidth > 0 && (jsx("line", { x1: x, y1: tickY, x2: x + gridWidth, y2: tickY, className: "opacity-80 stroke-[var(--color-border)]", strokeWidth: 1 })), showTicks && (jsx("line", { x1: x - tickLength, y1: tickY, x2: x, y2: tickY, className: "stroke-[var(--color-border)]", strokeWidth: 1 })), jsx(ChartText, { x: x - tickLength - tickPadding, y: tickY, textAnchor: textAnchor, dominantBaseline: "middle", children: formatTick(tick) })] }, index));
|
|
51
|
+
return (jsxs("g", { children: [showGrid && gridWidth > 0 && (jsx("line", { x1: x, y1: tickY, x2: x + gridWidth, y2: tickY, className: cn("opacity-80 stroke-[var(--color-border)]", gridClassName), strokeWidth: 1 })), showTicks && (jsx("line", { x1: x - tickLength, y1: tickY, x2: x, y2: tickY, className: "stroke-[var(--color-border)]", strokeWidth: 1 })), jsx(ChartText, { x: x - tickLength - tickPadding, y: tickY, textAnchor: textAnchor, dominantBaseline: "middle", children: formatTick(tick) })] }, index));
|
|
52
52
|
})] }));
|
|
53
53
|
});
|
|
54
54
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { XAxis } from './XAxis';
|
|
2
2
|
export { YAxis } from './YAxis';
|
|
3
|
-
export
|
|
3
|
+
export { ValueXAxis } from './ValueXAxis';
|
|
4
|
+
export { CategoryYAxis } from './CategoryYAxis';
|
|
5
|
+
export type { BaseAxisProps, XAxisProps, YAxisProps, ValueXAxisProps, CategoryYAxisProps, AxisTickProps, } from './ChartAxis.types';
|
|
@@ -12,8 +12,6 @@ export interface HorizontalGridProps {
|
|
|
12
12
|
lineCount?: number;
|
|
13
13
|
/** Whether to show the grid */
|
|
14
14
|
show?: boolean;
|
|
15
|
-
/** Grid line color */
|
|
16
|
-
color?: string;
|
|
17
15
|
/** Additional CSS classes */
|
|
18
16
|
className?: string;
|
|
19
17
|
/** Custom tick positions (overrides lineCount) */
|
|
@@ -5,7 +5,7 @@ import { cn } from '../../../../utils/cn.js';
|
|
|
5
5
|
* HorizontalGrid component for charts
|
|
6
6
|
* Renders horizontal grid lines at specified intervals
|
|
7
7
|
*/
|
|
8
|
-
const HorizontalGrid = ({ x, y, width, height, lineCount = 5, show = true,
|
|
8
|
+
const HorizontalGrid = ({ x, y, width, height, lineCount = 5, show = true, className, tickPositions, }) => {
|
|
9
9
|
if (!show)
|
|
10
10
|
return null;
|
|
11
11
|
// Generate grid line positions
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface VerticalGridProps {
|
|
3
|
+
/** X position to start the grid */
|
|
4
|
+
x: number;
|
|
5
|
+
/** Y position to start the grid */
|
|
6
|
+
y: number;
|
|
7
|
+
/** Width of the grid area */
|
|
8
|
+
width: number;
|
|
9
|
+
/** Height of the grid area */
|
|
10
|
+
height: number;
|
|
11
|
+
/** Number of grid lines */
|
|
12
|
+
lineCount?: number;
|
|
13
|
+
/** Whether to show the grid */
|
|
14
|
+
show?: boolean;
|
|
15
|
+
/** Additional CSS classes */
|
|
16
|
+
className?: string;
|
|
17
|
+
/** Custom tick positions (overrides lineCount) */
|
|
18
|
+
tickPositions?: number[];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* VerticalGrid component for charts
|
|
22
|
+
* Renders vertical grid lines at specified intervals — the mirror of HorizontalGrid,
|
|
23
|
+
* for charts whose VALUE axis runs horizontally (e.g. HorizontalBarChart), where the
|
|
24
|
+
* reference lines a reader traces are vertical.
|
|
25
|
+
*
|
|
26
|
+
* Deliberately has NO `color` prop: the line is themed via `stroke-[var(--color-border)]`.
|
|
27
|
+
* Don't add one here without wiring it up.
|
|
28
|
+
*/
|
|
29
|
+
export declare const VerticalGrid: React.FC<VerticalGridProps>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { cn } from '../../../../utils/cn.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* VerticalGrid component for charts
|
|
6
|
+
* Renders vertical grid lines at specified intervals — the mirror of HorizontalGrid,
|
|
7
|
+
* for charts whose VALUE axis runs horizontally (e.g. HorizontalBarChart), where the
|
|
8
|
+
* reference lines a reader traces are vertical.
|
|
9
|
+
*
|
|
10
|
+
* Deliberately has NO `color` prop: the line is themed via `stroke-[var(--color-border)]`.
|
|
11
|
+
* Don't add one here without wiring it up.
|
|
12
|
+
*/
|
|
13
|
+
const VerticalGrid = ({ x, y, width, height, lineCount = 5, show = true, className, tickPositions, }) => {
|
|
14
|
+
if (!show)
|
|
15
|
+
return null;
|
|
16
|
+
// Generate grid line positions
|
|
17
|
+
const positions = tickPositions ||
|
|
18
|
+
Array.from({ length: lineCount }, (_, i) => {
|
|
19
|
+
if (lineCount <= 1)
|
|
20
|
+
return x;
|
|
21
|
+
return x + (i * width) / (lineCount - 1);
|
|
22
|
+
});
|
|
23
|
+
return (jsx("g", { className: cn("chart-vertical-grid", className), children: positions.map((lineX, index) => (jsx("line", { x1: lineX, y1: y, x2: lineX, y2: y + height, className: "opacity-80 stroke-[var(--color-border)]", strokeWidth: 1 }, index))) }));
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { VerticalGrid };
|
|
@@ -16,7 +16,13 @@ const ChartMarker = ({ cx, cy, radius, colorClass, className, strokeWidth = 2, f
|
|
|
16
16
|
const currentRadius = isHovered ? radius * 1.1 : radius;
|
|
17
17
|
return (jsx("g", { className: "chart-marker", children: jsx("circle", { cx: cx, cy: cy, r: currentRadius, className: baseClasses, fill: fillColor || "white", stroke: strokeColor, strokeWidth: strokeWidth, onMouseEnter: () => setIsHovered(true), onMouseLeave: () => setIsHovered(false), style: {
|
|
18
18
|
transition: 'linear 0.2s ease-out',
|
|
19
|
-
cursor: 'pointer'
|
|
19
|
+
cursor: 'pointer',
|
|
20
|
+
// `fill-white`/`stroke-2` in the theme's baseStyle are CSS class rules, which
|
|
21
|
+
// beat the `fill`/`stroke` presentation attributes below in the cascade — so an
|
|
22
|
+
// explicit fillColor/strokeColor prop needs inline style (highest specificity)
|
|
23
|
+
// to actually take effect, not just the attribute.
|
|
24
|
+
...(fillColor ? { fill: fillColor } : {}),
|
|
25
|
+
...(strokeColor ? { stroke: strokeColor } : {}),
|
|
20
26
|
} }) }));
|
|
21
27
|
};
|
|
22
28
|
|
|
@@ -5,16 +5,14 @@
|
|
|
5
5
|
const chartTheme = {
|
|
6
6
|
baseStyle: {
|
|
7
7
|
colors: {
|
|
8
|
-
//
|
|
8
|
+
// Categorical series palette — dedicated chart-N tokens, decoupled
|
|
9
|
+
// from the semantic status colors (primary/success/warning/danger).
|
|
9
10
|
series: [
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"fill-[var(--color-warning-400)] stroke-[var(--color-warning-400)]", // Warning lighter
|
|
16
|
-
"fill-[var(--color-success-400)] stroke-[var(--color-success-400)]", // Success lighter
|
|
17
|
-
"fill-[var(--color-danger-400)] stroke-[var(--color-danger-400)]", // Danger lighter
|
|
11
|
+
"var(--color-chart-1)",
|
|
12
|
+
"var(--color-chart-2)",
|
|
13
|
+
"var(--color-chart-3)",
|
|
14
|
+
"var(--color-chart-4)",
|
|
15
|
+
"var(--color-chart-5)",
|
|
18
16
|
],
|
|
19
17
|
// Chart infrastructure colors
|
|
20
18
|
grid: "stroke-[var(--color-border)]",
|
|
@@ -37,24 +35,21 @@ const chartTheme = {
|
|
|
37
35
|
variants: {
|
|
38
36
|
default: {
|
|
39
37
|
colors: [
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"fill-[var(--color-warning-400)] stroke-[var(--color-warning-400)]",
|
|
46
|
-
"fill-[var(--color-success-400)] stroke-[var(--color-success-400)]",
|
|
47
|
-
"fill-[var(--color-danger-400)] stroke-[var(--color-danger-400)]",
|
|
38
|
+
"var(--color-chart-1)",
|
|
39
|
+
"var(--color-chart-2)",
|
|
40
|
+
"var(--color-chart-3)",
|
|
41
|
+
"var(--color-chart-4)",
|
|
42
|
+
"var(--color-chart-5)",
|
|
48
43
|
],
|
|
49
44
|
},
|
|
50
45
|
minimal: {
|
|
51
46
|
colors: [
|
|
52
|
-
"fill-[var(--color-
|
|
53
|
-
"fill-[var(--color-
|
|
54
|
-
"fill-[var(--color-
|
|
55
|
-
"fill-[var(--color-
|
|
56
|
-
"fill-[var(--color-
|
|
57
|
-
"fill-[var(--color-
|
|
47
|
+
"fill-[var(--color-mono-600)] stroke-[var(--color-mono-600)]",
|
|
48
|
+
"fill-[var(--color-mono-500)] stroke-[var(--color-mono-500)]",
|
|
49
|
+
"fill-[var(--color-mono-400)] stroke-[var(--color-mono-400)]",
|
|
50
|
+
"fill-[var(--color-mono-300)] stroke-[var(--color-mono-300)]",
|
|
51
|
+
"fill-[var(--color-mono-700)] stroke-[var(--color-mono-700)]",
|
|
52
|
+
"fill-[var(--color-mono-800)] stroke-[var(--color-mono-800)]",
|
|
58
53
|
],
|
|
59
54
|
},
|
|
60
55
|
gradient: {
|
|
@@ -52,8 +52,6 @@ export declare const CHART_DEFAULTS: {
|
|
|
52
52
|
readonly showYAxis: true;
|
|
53
53
|
readonly barRadius: 32;
|
|
54
54
|
readonly dotRadius: 3;
|
|
55
|
-
readonly cellRadius: 4;
|
|
56
|
-
readonly radius: 20;
|
|
57
55
|
readonly strokeWidth: 2;
|
|
58
56
|
readonly gap: 4;
|
|
59
57
|
readonly categoryGap: 16;
|
|
@@ -62,7 +60,6 @@ export declare const CHART_DEFAULTS: {
|
|
|
62
60
|
readonly fillOpacity: 0.3;
|
|
63
61
|
readonly showStroke: true;
|
|
64
62
|
readonly showDots: false;
|
|
65
|
-
readonly orientation: "vertical" | "horizontal";
|
|
66
63
|
readonly stacked: false;
|
|
67
64
|
readonly variant: ChartVariant;
|
|
68
65
|
readonly enableKeyboardNavigation: true;
|
|
@@ -93,10 +90,18 @@ export interface StandardChartDisplayProps {
|
|
|
93
90
|
variant?: ChartVariant;
|
|
94
91
|
theme?: ChartThemeOverrides;
|
|
95
92
|
}
|
|
93
|
+
/**
|
|
94
|
+
* The union of every chart's visual props.
|
|
95
|
+
*
|
|
96
|
+
* 🔴 Narrow this with `Omit` per chart — never `extends StandardVisualProps` wholesale.
|
|
97
|
+
* Doing so advertises other charts' props: they type-check, reach the generative schema,
|
|
98
|
+
* and do nothing. `BaseChartProps` does not extend HTMLAttributes, so they can't even be
|
|
99
|
+
* forwarded via `{...props}` — they land on a <div> as unknown attributes. Add a prop
|
|
100
|
+
* back to a chart only alongside an implementation that reads it.
|
|
101
|
+
*/
|
|
96
102
|
export interface StandardVisualProps {
|
|
97
103
|
barRadius?: number;
|
|
98
104
|
dotRadius?: number;
|
|
99
|
-
cellRadius?: number;
|
|
100
105
|
radius?: number;
|
|
101
106
|
strokeWidth?: number;
|
|
102
107
|
gap?: number;
|
|
@@ -108,7 +113,6 @@ export interface StandardVisualProps {
|
|
|
108
113
|
stacked?: boolean;
|
|
109
114
|
}
|
|
110
115
|
export interface BarChartSpecificProps {
|
|
111
|
-
orientation?: 'vertical' | 'horizontal';
|
|
112
116
|
categoryGap?: number;
|
|
113
117
|
}
|
|
114
118
|
export interface StandardAxisConfig {
|
|
@@ -14,10 +14,8 @@ const CHART_DEFAULTS = {
|
|
|
14
14
|
// Visual properties
|
|
15
15
|
barRadius: 32, // For bar corners (rounded top)
|
|
16
16
|
dotRadius: 3, // For line/area dot markers
|
|
17
|
-
cellRadius: 4, // For heatmap cells
|
|
18
|
-
radius: 20, // @deprecated Use barRadius, dotRadius, or cellRadius instead
|
|
19
17
|
strokeWidth: 2,
|
|
20
|
-
gap: 4, // For bars
|
|
18
|
+
gap: 4, // For bars
|
|
21
19
|
categoryGap: 16, // For bar categories
|
|
22
20
|
// Line/Area specific
|
|
23
21
|
curved: true,
|
|
@@ -25,12 +23,8 @@ const CHART_DEFAULTS = {
|
|
|
25
23
|
fillOpacity: 0.3,
|
|
26
24
|
showStroke: true,
|
|
27
25
|
showDots: false,
|
|
28
|
-
// Bar specific
|
|
29
|
-
orientation: 'vertical',
|
|
30
26
|
// Layout
|
|
31
27
|
stacked: false,
|
|
32
|
-
// Theme
|
|
33
|
-
variant: 'default',
|
|
34
28
|
// Accessibility
|
|
35
29
|
enableKeyboardNavigation: true,
|
|
36
30
|
};
|
|
@@ -178,8 +178,6 @@ const CARTESIAN_ENTRANCE_DURATION = 0.7;
|
|
|
178
178
|
const LINE_DOT_STAGGER = 0.06;
|
|
179
179
|
/** Grouped-bar stagger (BarChart + shared BarRenderer grouped path). */
|
|
180
180
|
const BAR_GROUP_STAGGER = 0.05;
|
|
181
|
-
/** Stacked-bar per-category stagger (StackedBarChart). */
|
|
182
|
-
const STACKED_BAR_STAGGER = 0.08;
|
|
183
181
|
/** Shared BarRenderer stacked-mode per-category delay. */
|
|
184
182
|
const BAR_STACK_CATEGORY_DELAY = 0.25;
|
|
185
183
|
/** Shared BarRenderer stacked-mode per-segment stagger. */
|
|
@@ -261,4 +259,4 @@ function stackedSegmentTransition(delay, hasAnimated) {
|
|
|
261
259
|
};
|
|
262
260
|
}
|
|
263
261
|
|
|
264
|
-
export { BAR_GROUP_STAGGER, BAR_SPRING, BAR_STACK_CATEGORY_DELAY, BAR_STACK_SEGMENT_STAGGER, CARTESIAN_ENTRANCE_DURATION, CIRCULAR_CHART_ANIMATIONS, CROSSHAIR_FADE_TRANSITION, CROSSHAIR_FOLLOW_TRANSITION, DOT_SPRING, HALO_FADE_TRANSITION, LINE_DOT_STAGGER, RING_FADE_TRANSITION, RISE_FROM_BASELINE, SCALE_FROM_CENTER, SCATTER_POINT_DURATION, SCATTER_POINT_STAGGER, SEGMENT_HOVER_TRANSITION, SPRING_PRESETS,
|
|
262
|
+
export { BAR_GROUP_STAGGER, BAR_SPRING, BAR_STACK_CATEGORY_DELAY, BAR_STACK_SEGMENT_STAGGER, CARTESIAN_ENTRANCE_DURATION, CIRCULAR_CHART_ANIMATIONS, CROSSHAIR_FADE_TRANSITION, CROSSHAIR_FOLLOW_TRANSITION, DOT_SPRING, HALO_FADE_TRANSITION, LINE_DOT_STAGGER, RING_FADE_TRANSITION, RISE_FROM_BASELINE, SCALE_FROM_CENTER, SCATTER_POINT_DURATION, SCATTER_POINT_STAGGER, SEGMENT_HOVER_TRANSITION, SPRING_PRESETS, TOOLTIP_ENTER_TRANSITION, TOOLTIP_EXIT_TRANSITION, barEntranceTransition, dotEntranceTransition, getSpringAnimation, getStaggerDelay, riseTransition, stackedSegmentTransition };
|
|
@@ -25,6 +25,16 @@ export interface BarEmphasisInput {
|
|
|
25
25
|
isFocused: boolean;
|
|
26
26
|
isAnyBarHovered: boolean;
|
|
27
27
|
isGradientVariant: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Whether hover/focus gets the premium emphasis (glow ring + colored stroke + the
|
|
30
|
+
* stronger sibling dim). Defaults to `isGradientVariant`, since for column bars the
|
|
31
|
+
* two travel together — so BarChart and ComboChart are unaffected.
|
|
32
|
+
*
|
|
33
|
+
* Pass it explicitly for a chart whose fills are flat but which still wants the
|
|
34
|
+
* premium hover (HorizontalBarChart). The two really are separate axes: "how the bar
|
|
35
|
+
* is painted" vs "how it responds to hover".
|
|
36
|
+
*/
|
|
37
|
+
premiumEmphasis?: boolean;
|
|
28
38
|
}
|
|
29
39
|
export interface BarEmphasisState {
|
|
30
40
|
/** Hover OR keyboard focus, gradient variant only — drives ring + stroke. */
|
|
@@ -32,7 +42,7 @@ export interface BarEmphasisState {
|
|
|
32
42
|
/** A sibling is hovered and this bar isn't — drives the dim. */
|
|
33
43
|
shouldReduceOpacity: boolean;
|
|
34
44
|
}
|
|
35
|
-
export declare function deriveBarEmphasis({ isHovered, isFocused, isAnyBarHovered, isGradientVariant, }: BarEmphasisInput): BarEmphasisState;
|
|
45
|
+
export declare function deriveBarEmphasis({ isHovered, isFocused, isAnyBarHovered, isGradientVariant, premiumEmphasis, }: BarEmphasisInput): BarEmphasisState;
|
|
36
46
|
/**
|
|
37
47
|
* Animated hover-dim opacity. Belongs in the motion `animate` prop, not
|
|
38
48
|
* `style` — motion.path freezes plain style values at mount.
|
|
@@ -46,17 +56,36 @@ export declare function barFill({ isGradientVariant, gradientFill, isNull, shoul
|
|
|
46
56
|
shouldReduceOpacity: boolean;
|
|
47
57
|
fillColor: string;
|
|
48
58
|
}): string;
|
|
49
|
-
/**
|
|
50
|
-
|
|
59
|
+
/**
|
|
60
|
+
* Stroke cascade: keyboard-focus ring › emphasis › resting hairline › none.
|
|
61
|
+
*
|
|
62
|
+
* `showRestingStroke` (default `true`) keeps the resting white hairline that gradient
|
|
63
|
+
* column bars carry. Set it `false` for bars that should read as flat shapes with no
|
|
64
|
+
* outline at rest — the focus and emphasis strokes still apply, so keyboard focus stays
|
|
65
|
+
* visible either way. Prefer this flag over re-deriving the cascade at a call site:
|
|
66
|
+
* the two hand-copies of this logic drifted once already (§19).
|
|
67
|
+
*/
|
|
68
|
+
export declare function barStrokeStyle({ isFocused, isEmphasized, isGradientVariant, fillColor, showRestingStroke, }: {
|
|
51
69
|
isFocused: boolean;
|
|
52
70
|
isEmphasized: boolean;
|
|
53
71
|
isGradientVariant: boolean;
|
|
54
72
|
fillColor: string;
|
|
73
|
+
showRestingStroke?: boolean;
|
|
55
74
|
}): {
|
|
56
75
|
stroke: string;
|
|
57
76
|
strokeWidth: number | undefined;
|
|
58
77
|
strokeOpacity: number;
|
|
59
78
|
};
|
|
79
|
+
/**
|
|
80
|
+
* The hover glow-ring filter alone. Split out of `BarSeriesDefs` so a chart with FLAT
|
|
81
|
+
* fills can still render the premium hover ring without emitting a gradient def it
|
|
82
|
+
* never references — `BarSeriesDefs` composes it, so both paths stay single-sourced
|
|
83
|
+
* and the ring can't drift between them.
|
|
84
|
+
*/
|
|
85
|
+
export declare const BarRingDef: React.FC<{
|
|
86
|
+
ringId: string;
|
|
87
|
+
color: string;
|
|
88
|
+
}>;
|
|
60
89
|
/**
|
|
61
90
|
* Per-series SVG defs for the gradient variant: vertical gradient fill,
|
|
62
91
|
* colored drop shadow, and the hover glow-ring filter. Render inside <defs>.
|
|
@@ -16,9 +16,9 @@ const BAR_RING_STROKE_OPACITY = 0.24;
|
|
|
16
16
|
function barRingStrokeWidth(barWidth) {
|
|
17
17
|
return Math.min(14, Math.max(8, barWidth * 0.08));
|
|
18
18
|
}
|
|
19
|
-
function deriveBarEmphasis({ isHovered, isFocused, isAnyBarHovered, isGradientVariant, }) {
|
|
19
|
+
function deriveBarEmphasis({ isHovered, isFocused, isAnyBarHovered, isGradientVariant, premiumEmphasis = isGradientVariant, }) {
|
|
20
20
|
return {
|
|
21
|
-
isEmphasized:
|
|
21
|
+
isEmphasized: premiumEmphasis && (isHovered || isFocused),
|
|
22
22
|
shouldReduceOpacity: isAnyBarHovered && !isHovered,
|
|
23
23
|
};
|
|
24
24
|
}
|
|
@@ -41,29 +41,45 @@ function barFill({ isGradientVariant, gradientFill, isNull, shouldReduceOpacity,
|
|
|
41
41
|
? "var(--color-surface-sunken)"
|
|
42
42
|
: fillColor;
|
|
43
43
|
}
|
|
44
|
-
/**
|
|
45
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Stroke cascade: keyboard-focus ring › emphasis › resting hairline › none.
|
|
46
|
+
*
|
|
47
|
+
* `showRestingStroke` (default `true`) keeps the resting white hairline that gradient
|
|
48
|
+
* column bars carry. Set it `false` for bars that should read as flat shapes with no
|
|
49
|
+
* outline at rest — the focus and emphasis strokes still apply, so keyboard focus stays
|
|
50
|
+
* visible either way. Prefer this flag over re-deriving the cascade at a call site:
|
|
51
|
+
* the two hand-copies of this logic drifted once already (§19).
|
|
52
|
+
*/
|
|
53
|
+
function barStrokeStyle({ isFocused, isEmphasized, isGradientVariant, fillColor, showRestingStroke = true, }) {
|
|
54
|
+
const hasRestingStroke = isGradientVariant && showRestingStroke;
|
|
46
55
|
return {
|
|
47
56
|
stroke: isFocused
|
|
48
57
|
? "var(--color-primary)"
|
|
49
58
|
: isEmphasized
|
|
50
59
|
? fillColor
|
|
51
|
-
:
|
|
60
|
+
: hasRestingStroke
|
|
52
61
|
? BAR_RESTING_STROKE
|
|
53
62
|
: "none",
|
|
54
|
-
strokeWidth: isFocused ? 3 : isEmphasized ? 2 :
|
|
63
|
+
strokeWidth: isFocused ? 3 : isEmphasized ? 2 : hasRestingStroke ? 1 : undefined,
|
|
55
64
|
strokeOpacity: isEmphasized ? BAR_EMPHASIS_STROKE_OPACITY : 1,
|
|
56
65
|
};
|
|
57
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* The hover glow-ring filter alone. Split out of `BarSeriesDefs` so a chart with FLAT
|
|
69
|
+
* fills can still render the premium hover ring without emitting a gradient def it
|
|
70
|
+
* never references — `BarSeriesDefs` composes it, so both paths stay single-sourced
|
|
71
|
+
* and the ring can't drift between them.
|
|
72
|
+
*/
|
|
73
|
+
const BarRingDef = ({ ringId, color, }) => (jsxs("filter", { id: ringId, x: "-25%", y: "-25%", width: "150%", height: "165%", colorInterpolationFilters: "sRGB", children: [jsx("feDropShadow", { dx: "0", dy: "0", stdDeviation: "4", floodColor: color, floodOpacity: "0.42" }), jsx("feDropShadow", { dx: "0", dy: "10", stdDeviation: "8", floodColor: color, floodOpacity: "0.18" })] }));
|
|
58
74
|
/**
|
|
59
75
|
* Per-series SVG defs for the gradient variant: vertical gradient fill,
|
|
60
76
|
* colored drop shadow, and the hover glow-ring filter. Render inside <defs>.
|
|
61
77
|
*/
|
|
62
|
-
const BarSeriesDefs = ({ gradientId, shadowId, ringId, color }) => (jsxs(Fragment, { children: [jsxs("linearGradient", { id: gradientId, x1: "0", y1: "0", x2: "0", y2: "1", children: [jsx("stop", { offset: "0%", stopColor: color, stopOpacity: "0.46" }), jsx("stop", { offset: "14%", stopColor: color, stopOpacity: "0.9" }), jsx("stop", { offset: "42%", stopColor: color, stopOpacity: "1" }), jsx("stop", { offset: "72%", stopColor: color, stopOpacity: "0.96" }), jsx("stop", { offset: "100%", stopColor: color, stopOpacity: "0.82" })] }), jsx("filter", { id: shadowId, x: "-35%", y: "-35%", width: "170%", height: "190%", colorInterpolationFilters: "sRGB", children: jsx("feDropShadow", { dx: "0", dy: "10", stdDeviation: "8", floodColor: color, floodOpacity: "0.22" }) }),
|
|
78
|
+
const BarSeriesDefs = ({ gradientId, shadowId, ringId, color }) => (jsxs(Fragment, { children: [jsxs("linearGradient", { id: gradientId, x1: "0", y1: "0", x2: "0", y2: "1", children: [jsx("stop", { offset: "0%", stopColor: color, stopOpacity: "0.46" }), jsx("stop", { offset: "14%", stopColor: color, stopOpacity: "0.9" }), jsx("stop", { offset: "42%", stopColor: color, stopOpacity: "1" }), jsx("stop", { offset: "72%", stopColor: color, stopOpacity: "0.96" }), jsx("stop", { offset: "100%", stopColor: color, stopOpacity: "0.82" })] }), jsx("filter", { id: shadowId, x: "-35%", y: "-35%", width: "170%", height: "190%", colorInterpolationFilters: "sRGB", children: jsx("feDropShadow", { dx: "0", dy: "10", stdDeviation: "8", floodColor: color, floodOpacity: "0.22" }) }), jsx(BarRingDef, { ringId: ringId, color: color })] }));
|
|
63
79
|
/**
|
|
64
80
|
* Hover/focus glow ring behind an emphasized bar. Mount/unmount it via
|
|
65
81
|
* `show` — enter/exit fades are handled internally.
|
|
66
82
|
*/
|
|
67
83
|
const BarGlowRing = ({ show, pathD, color, barWidth, filter }) => (jsx(AnimatePresence, { children: show && (jsx(motion.path, { d: pathD, initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, transition: RING_FADE_TRANSITION, fill: "none", stroke: color, strokeWidth: barRingStrokeWidth(barWidth), strokeOpacity: BAR_RING_STROKE_OPACITY, strokeLinejoin: "round", vectorEffect: "non-scaling-stroke", filter: filter, style: { pointerEvents: "none" } })) }));
|
|
68
84
|
|
|
69
|
-
export { BAR_DIM_OPACITY_FLAT, BAR_DIM_OPACITY_GRADIENT, BAR_EMPHASIS_STROKE_OPACITY, BAR_RESTING_STROKE, BAR_RING_STROKE_OPACITY, BarGlowRing, BarSeriesDefs, barDimOpacity, barFill, barRingStrokeWidth, barStrokeStyle, deriveBarEmphasis };
|
|
85
|
+
export { BAR_DIM_OPACITY_FLAT, BAR_DIM_OPACITY_GRADIENT, BAR_EMPHASIS_STROKE_OPACITY, BAR_RESTING_STROKE, BAR_RING_STROKE_OPACITY, BarGlowRing, BarRingDef, BarSeriesDefs, barDimOpacity, barFill, barRingStrokeWidth, barStrokeStyle, deriveBarEmphasis };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { resolveSeriesColor } from "./series-color";
|
|
1
2
|
export { extractFillClass, extractStrokeClass, colorClassToVariable, combineClasses, createColorClass, generateSeriesColors, DEFAULT_CHART_COLORS, EXTENDED_CHART_COLORS, MINIMAL_CHART_COLORS, generateColorPalette, getContrastColor, } from './color-utils';
|
|
2
3
|
export { SafeMath, validateChart, validateChartData, validateChartConfig, validateDataConfigCompatibility, sanitizeChartData, calculateSafeScaleRange, niceNum, generateNiceTicks, type ChartValidationError, type ChartValidationResult, } from './chart-validation';
|
|
3
4
|
export { getSpringAnimation, getUseSpringConfig, getStaggerDelay, SPRING_PRESETS, CIRCULAR_CHART_ANIMATIONS, type SpringConfig, type NoAnimationConfig, type AnimationPreset, } from './animation-utils';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ChartConfig } from "../types/chart.types";
|
|
2
|
+
/**
|
|
3
|
+
* Resolves the paint color for series `key` at position `index`.
|
|
4
|
+
* Priority: explicit config[key].color (preserving the bare-token DX,
|
|
5
|
+
* e.g. "success" -> "var(--color-success)"), then palette[index % length].
|
|
6
|
+
*/
|
|
7
|
+
export declare function resolveSeriesColor(index: number, key: string | undefined, config: ChartConfig | undefined, palette: readonly string[]): string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves the paint color for series `key` at position `index`.
|
|
3
|
+
* Priority: explicit config[key].color (preserving the bare-token DX,
|
|
4
|
+
* e.g. "success" -> "var(--color-success)"), then palette[index % length].
|
|
5
|
+
*/
|
|
6
|
+
function resolveSeriesColor(index, key, config, palette) {
|
|
7
|
+
var _a;
|
|
8
|
+
const raw = key ? (_a = config === null || config === void 0 ? void 0 : config[key]) === null || _a === void 0 ? void 0 : _a.color : undefined;
|
|
9
|
+
if (raw) {
|
|
10
|
+
const isBareToken = !raw.startsWith("var(") &&
|
|
11
|
+
!raw.startsWith("#") &&
|
|
12
|
+
!raw.startsWith("rgb") &&
|
|
13
|
+
!raw.startsWith("hsl") &&
|
|
14
|
+
raw.includes("-");
|
|
15
|
+
return isBareToken ? `var(--color-${raw})` : raw;
|
|
16
|
+
}
|
|
17
|
+
return palette.length > 0 ? palette[index % palette.length] : "var(--color-chart-1)";
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { resolveSeriesColor };
|