@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
|
@@ -17,8 +17,10 @@ import { generateNiceTicks } from '../utils/chart-validation.js';
|
|
|
17
17
|
import { generateCurvePath } from '../utils/path-utils.js';
|
|
18
18
|
import { AREA_CHART_DEFAULTS } from './AreaChart.types.js';
|
|
19
19
|
import { X_AXIS_MARGIN } from '../types/chart.types.js';
|
|
20
|
-
import { areaChartTheme,
|
|
20
|
+
import { areaChartTheme, getSeriesColorClass } from './AreaChart.theme.js';
|
|
21
21
|
import { RISE_FROM_BASELINE, riseTransition, SCALE_FROM_CENTER, dotEntranceTransition, HALO_FADE_TRANSITION } from '../utils/animation-utils.js';
|
|
22
|
+
import { resolveSeriesColor } from '../utils/series-color.js';
|
|
23
|
+
import { chartTheme } from '../theme/chart.theme.js';
|
|
22
24
|
|
|
23
25
|
const sanitizeSvgId = (value) => value.replace(/[^a-zA-Z0-9_-]/g, "");
|
|
24
26
|
const AreaChart = ({ data, config,
|
|
@@ -34,18 +36,6 @@ svgClassName, areaClassName, lineClassName, gridClassName, axisClassName, width,
|
|
|
34
36
|
var _a;
|
|
35
37
|
// Resolve dotRadius with backward compatibility
|
|
36
38
|
const resolvedDotRadius = (_a = dotRadius !== null && dotRadius !== void 0 ? dotRadius : radius) !== null && _a !== void 0 ? _a : AREA_CHART_DEFAULTS.dotRadius;
|
|
37
|
-
const resolveColor = (color, fallback) => {
|
|
38
|
-
if (!color)
|
|
39
|
-
return fallback;
|
|
40
|
-
if (!color.startsWith("var(") &&
|
|
41
|
-
!color.startsWith("#") &&
|
|
42
|
-
!color.startsWith("rgb") &&
|
|
43
|
-
!color.startsWith("hsl") &&
|
|
44
|
-
color.includes("-")) {
|
|
45
|
-
return `var(--color-${color})`;
|
|
46
|
-
}
|
|
47
|
-
return color;
|
|
48
|
-
};
|
|
49
39
|
// Development warning for deprecated radius prop
|
|
50
40
|
if (process.env.NODE_ENV !== "production" && radius !== undefined) {
|
|
51
41
|
console.warn("[AreaChart]: The `radius` prop is deprecated and will be removed in a future version. " +
|
|
@@ -105,11 +95,11 @@ svgClassName, areaClassName, lineClassName, gridClassName, axisClassName, width,
|
|
|
105
95
|
const dataKeys = useMemo(() => Object.keys(config), [config]);
|
|
106
96
|
const resolvedLegendPosition = resolveLegendPosition(legend, config);
|
|
107
97
|
const legendItems = dataKeys.map((key, index) => {
|
|
108
|
-
var _a, _b
|
|
98
|
+
var _a, _b;
|
|
109
99
|
return ({
|
|
110
100
|
key,
|
|
111
101
|
label: (_b = (_a = config[key]) === null || _a === void 0 ? void 0 : _a.label) !== null && _b !== void 0 ? _b : key,
|
|
112
|
-
color:
|
|
102
|
+
color: resolveSeriesColor(index, key, config, chartTheme.baseStyle.colors.series),
|
|
113
103
|
});
|
|
114
104
|
});
|
|
115
105
|
// Calculate scales. Guarded for empty data (`Math.max(...[])` is `-Infinity`)
|
|
@@ -248,13 +238,11 @@ svgClassName, areaClassName, lineClassName, gridClassName, axisClassName, width,
|
|
|
248
238
|
setHoveredPoint(null);
|
|
249
239
|
handleMouseLeave();
|
|
250
240
|
}, ...props, children: [resolvedLegendPosition === "top" && (jsx(ChartLegend, { items: legendItems, className: "shrink-0 pb-2" })), descriptionProps && jsx("div", { ...descriptionProps }), jsx("div", { className: "relative flex-1 min-h-0", children: jsxs("svg", { width: "100%", height: "100%", viewBox: `0 0 ${dimensions.width} ${dimensions.height}`, className: cn(areaChartTheme.svgStyle, svgClassName), role: "presentation", children: [jsxs("defs", { children: [jsx("filter", { id: shadowFilterId, x: "-20%", y: "-20%", width: "140%", height: "140%", children: jsx("feDropShadow", { dx: "4", dy: "4", stdDeviation: "6", floodOpacity: "0.1", floodColor: "#000000" }) }), jsx("clipPath", { id: clipId, children: jsx("rect", { x: margin.left, y: margin.top, width: innerWidth, height: innerHeight }) }), dataKeys.map((key, keyIndex) => {
|
|
251
|
-
|
|
252
|
-
const fillColor = resolveColor((_a = config[key]) === null || _a === void 0 ? void 0 : _a.color, getSeriesFillColor(keyIndex));
|
|
241
|
+
const fillColor = resolveSeriesColor(keyIndex, key, config, chartTheme.baseStyle.colors.series);
|
|
253
242
|
return (jsx("linearGradient", { id: getAreaGradientId(keyIndex), gradientUnits: isGradientVariant ? "objectBoundingBox" : undefined, x1: "0", y1: "0", x2: "0", y2: "1", children: isGradientVariant ? (jsxs(Fragment, { children: [jsx("stop", { offset: "0%", stopColor: fillColor, stopOpacity: Math.min(0.42, fillOpacity * 1.15) }), jsx("stop", { offset: "32%", stopColor: fillColor, stopOpacity: Math.min(0.24, fillOpacity * 0.68) }), jsx("stop", { offset: "78%", stopColor: fillColor, stopOpacity: Math.min(0.08, fillOpacity * 0.22) }), jsx("stop", { offset: "100%", stopColor: fillColor, stopOpacity: "0" })] })) : (jsxs(Fragment, { children: [jsx("stop", { offset: "0%", stopColor: fillColor, stopOpacity: fillOpacity * 0.8 }), jsx("stop", { offset: "100%", stopColor: fillColor, stopOpacity: fillOpacity * 0.05 })] })) }, `gradient-${key}`));
|
|
254
243
|
}), isGradientVariant &&
|
|
255
244
|
dataKeys.map((key, keyIndex) => {
|
|
256
|
-
|
|
257
|
-
const fillColor = resolveColor((_a = config[key]) === null || _a === void 0 ? void 0 : _a.color, getSeriesFillColor(keyIndex));
|
|
245
|
+
const fillColor = resolveSeriesColor(keyIndex, key, config, chartTheme.baseStyle.colors.series);
|
|
258
246
|
return (jsxs(React__default.Fragment, { children: [jsx("filter", { id: getLineGlowId(keyIndex), x: "-12%", y: "-35%", width: "124%", height: "170%", colorInterpolationFilters: "sRGB", children: jsx("feDropShadow", { dx: "0", dy: "0", stdDeviation: "5", floodColor: fillColor, floodOpacity: "0.42" }) }), jsx("filter", { id: getMarkerGlowId(keyIndex), x: "-120%", y: "-120%", width: "340%", height: "340%", colorInterpolationFilters: "sRGB", children: jsx("feDropShadow", { dx: "0", dy: "0", stdDeviation: "5", floodColor: fillColor, floodOpacity: "0.45" }) })] }, `gradient-filters-${key}`));
|
|
259
247
|
}), jsxs("linearGradient", { id: "vertical-fade", x1: "0%", y1: "0%", x2: "0%", y2: "100%", children: [jsx("stop", { offset: "0%", stopColor: "#6b7280", stopOpacity: "0" }), jsx("stop", { offset: "40%", stopColor: "#6b7280", stopOpacity: "0.3" }), jsx("stop", { offset: "50%", stopColor: "#6b7280", stopOpacity: "0.5" }), jsx("stop", { offset: "60%", stopColor: "#6b7280", stopOpacity: "0.3" }), jsx("stop", { offset: "100%", stopColor: "#6b7280", stopOpacity: "0" })] }), jsxs("linearGradient", { id: "horizontal-fade", x1: "0%", y1: "0%", x2: "100%", y2: "0%", children: [jsx("stop", { offset: "0%", stopColor: "#6b7280", stopOpacity: "0" }), jsx("stop", { offset: "40%", stopColor: "#6b7280", stopOpacity: "0.3" }), jsx("stop", { offset: "50%", stopColor: "#6b7280", stopOpacity: "0.5" }), jsx("stop", { offset: "60%", stopColor: "#6b7280", stopOpacity: "0.3" }), jsx("stop", { offset: "100%", stopColor: "#6b7280", stopOpacity: "0" })] })] }), jsx(HorizontalGrid, { show: showGrid, x: margin.left, y: margin.top, width: innerWidth, height: innerHeight, lineCount: 5, className: gridClassName }), jsx(ChartCrosshair, { show: hoveredPoint !== null, x: hoveredPoint !== null
|
|
260
248
|
? data.length === 1
|
|
@@ -272,13 +260,15 @@ svgClassName, areaClassName, lineClassName, gridClassName, axisClassName, width,
|
|
|
272
260
|
((numValue - minValue) / (maxValue - minValue)) *
|
|
273
261
|
innerHeight);
|
|
274
262
|
})()
|
|
275
|
-
: undefined, margin: margin, innerWidth: innerWidth, innerHeight: innerHeight, showHorizontal: dataKeys.length === 1, strokeColor: isGradientVariant
|
|
263
|
+
: undefined, margin: margin, innerWidth: innerWidth, innerHeight: innerHeight, showHorizontal: dataKeys.length === 1, strokeColor: isGradientVariant
|
|
264
|
+
? resolveSeriesColor(0, undefined, undefined, chartTheme.baseStyle.colors.series)
|
|
265
|
+
: undefined, strokeWidth: isGradientVariant ? 1.5 : undefined, strokeDasharray: isGradientVariant ? "3 7" : undefined, opacity: isGradientVariant ? 0.28 : undefined }), jsx(YAxis, { show: showYAxis, min: minValue, max: maxValue, x: margin.left, y: margin.top, height: innerHeight, showGrid: false, gridWidth: innerWidth, className: axisClassName, tickFormatter: (value) => {
|
|
276
266
|
if (Math.abs(value) >= 1000)
|
|
277
267
|
return `${(value / 1000).toFixed(0)}k`;
|
|
278
268
|
return value.toString();
|
|
279
269
|
} }), minValue < 0 && maxValue > 0 && (jsx("line", { x1: margin.left, y1: margin.top + innerHeight - ((0 - minValue) / (maxValue - minValue)) * innerHeight, x2: margin.left + innerWidth, y2: margin.top + innerHeight - ((0 - minValue) / (maxValue - minValue)) * innerHeight, className: "stroke-[var(--color-text-secondary)]", strokeWidth: 1, opacity: 0.6 })), jsx("g", { className: cn(areaChartTheme.areaGroupStyle, areaClassName), clipPath: `url(#${clipId})`, children: measured &&
|
|
280
270
|
dataKeys.map((key, keyIndex) => {
|
|
281
|
-
var _a, _b
|
|
271
|
+
var _a, _b;
|
|
282
272
|
const paths = allPaths[key];
|
|
283
273
|
const colorClass = getSeriesColorClass(keyIndex);
|
|
284
274
|
if (!paths)
|
|
@@ -291,19 +281,19 @@ svgClassName, areaClassName, lineClassName, gridClassName, axisClassName, width,
|
|
|
291
281
|
// so the series grows UP from the x-axis — not from its own mid-height.
|
|
292
282
|
style: RISE_FROM_BASELINE, children: [jsx("rect", { x: margin.left, y: margin.top, width: innerWidth, height: innerHeight, fill: "none", stroke: "none", style: { pointerEvents: "none" } }), jsx("path", { d: paths.areaPath, fill: `url(#${getAreaGradientId(keyIndex)})`, className: "transition-colors duration-200", filter: isGradientVariant ? undefined : `url(#${shadowFilterId})`, transform: isGradientVariant
|
|
293
283
|
? `translate(0 ${gradientAreaGap})`
|
|
294
|
-
: undefined }), showStroke && (jsxs(Fragment, { children: [isGradientVariant && (jsx(motion.path, { d: paths.linePath, initial: { opacity: 1 }, animate: { opacity: 1 }, fill: "none", stroke:
|
|
284
|
+
: undefined }), showStroke && (jsxs(Fragment, { children: [isGradientVariant && (jsx(motion.path, { d: paths.linePath, initial: { opacity: 1 }, animate: { opacity: 1 }, fill: "none", stroke: resolveSeriesColor(keyIndex, key, config, chartTheme.baseStyle.colors.series), strokeWidth: gradientStrokeWidth + 1, strokeLinecap: "round", strokeLinejoin: "round",
|
|
295
285
|
// Stroke width must ignore the group's scaleY rise, else
|
|
296
286
|
// it squashes flat at the start of the animation.
|
|
297
|
-
vectorEffect: "non-scaling-stroke", opacity: 0.08, filter: `url(#${getLineGlowId(keyIndex)})`, style: { pointerEvents: "none" } })), jsx(motion.path, { d: paths.linePath, initial: { opacity: 1 }, animate: { opacity: 1 }, fill: "none", stroke: ((
|
|
287
|
+
vectorEffect: "non-scaling-stroke", opacity: 0.08, filter: `url(#${getLineGlowId(keyIndex)})`, style: { pointerEvents: "none" } })), jsx(motion.path, { d: paths.linePath, initial: { opacity: 1 }, animate: { opacity: 1 }, fill: "none", stroke: ((_a = config[key]) === null || _a === void 0 ? void 0 : _a.color) ? resolveSeriesColor(keyIndex, key, config, []) : (isGradientVariant ? resolveSeriesColor(keyIndex, undefined, undefined, chartTheme.baseStyle.colors.series) : undefined), strokeWidth: isGradientVariant ? gradientStrokeWidth : strokeWidth, strokeLinecap: "round", strokeLinejoin: "round",
|
|
298
288
|
// Constant stroke width through the scaleY rise (no squash).
|
|
299
289
|
vectorEffect: "non-scaling-stroke", className: cn("transition-colors duration-200", !isGradientVariant &&
|
|
300
290
|
(colorClass
|
|
301
291
|
.split(" ")
|
|
302
|
-
.find((cls) => cls.startsWith("stroke-")) || ""), lineClassName), style: { stroke: ((
|
|
292
|
+
.find((cls) => cls.startsWith("stroke-")) || ""), lineClassName), style: { stroke: ((_b = config[key]) === null || _b === void 0 ? void 0 : _b.color) ? resolveSeriesColor(keyIndex, key, config, []) : undefined } })] }))] }, `${key}${shouldReduceMotion ? "" : `-${dataSignature}`}`));
|
|
303
293
|
}) }), showDots && (jsx("g", { className: "chart-dots", children: dataKeys.map((key, keyIndex) => {
|
|
304
294
|
const colorClass = getSeriesColorClass(keyIndex);
|
|
305
295
|
return (jsx("g", { children: data.map((item, dataIndex) => {
|
|
306
|
-
var _a
|
|
296
|
+
var _a;
|
|
307
297
|
const rawValue = item[key];
|
|
308
298
|
const isNull = rawValue === null || rawValue === undefined;
|
|
309
299
|
// Don't render dots for null values
|
|
@@ -316,12 +306,12 @@ svgClassName, areaClassName, lineClassName, gridClassName, axisClassName, width,
|
|
|
316
306
|
const { x, y } = getPointPosition(dataIndex, topValue);
|
|
317
307
|
return (jsx(motion.g, { initial: { opacity: 0, scale: 0 }, animate: { opacity: 1, scale: 1 },
|
|
318
308
|
// Markers pop in left-to-right once the rise has finished.
|
|
319
|
-
transition: dotEntranceTransition(dataIndex, shouldReduceMotion), style: SCALE_FROM_CENTER, children: jsx(ChartMarker, { cx: x, cy: y, radius: resolvedDotRadius, colorClass: colorClass, strokeColor: ((_a = config[key]) === null || _a === void 0 ? void 0 : _a.color) ?
|
|
309
|
+
transition: dotEntranceTransition(dataIndex, shouldReduceMotion), style: SCALE_FROM_CENTER, children: jsx(ChartMarker, { cx: x, cy: y, radius: resolvedDotRadius, colorClass: colorClass, strokeColor: ((_a = config[key]) === null || _a === void 0 ? void 0 : _a.color) ? resolveSeriesColor(keyIndex, key, config, []) : undefined }) }, `${key}-${dataIndex}${shouldReduceMotion ? "" : `-${dataSignature}`}`));
|
|
320
310
|
}) }, key));
|
|
321
311
|
}) })), jsx("g", { className: "chart-hover-markers", children: jsx(AnimatePresence, { children: (!showDots || isGradientVariant) &&
|
|
322
312
|
hoveredPoint !== null &&
|
|
323
313
|
dataKeys.map((key, keyIndex) => {
|
|
324
|
-
var _a
|
|
314
|
+
var _a;
|
|
325
315
|
const item = data[hoveredPoint.index];
|
|
326
316
|
const rawValue = item[key];
|
|
327
317
|
const isNull = rawValue === null || rawValue === undefined;
|
|
@@ -338,11 +328,11 @@ svgClassName, areaClassName, lineClassName, gridClassName, axisClassName, width,
|
|
|
338
328
|
: value;
|
|
339
329
|
const { x, y } = getPointPosition(hoveredPoint.index, topValue);
|
|
340
330
|
const colorClass = getSeriesColorClass(keyIndex);
|
|
341
|
-
const markerColor =
|
|
331
|
+
const markerColor = resolveSeriesColor(keyIndex, key, config, chartTheme.baseStyle.colors.series);
|
|
342
332
|
if (isGradientVariant) {
|
|
343
333
|
return (jsxs(motion.g, { initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, transition: HALO_FADE_TRANSITION, filter: `url(#${getMarkerGlowId(keyIndex)})`, style: { pointerEvents: "none" }, children: [jsx("circle", { cx: x, cy: y, r: resolvedDotRadius + 9, fill: markerColor, opacity: 0.12 }), jsx("circle", { cx: x, cy: y, r: resolvedDotRadius + 4, fill: "white", stroke: markerColor, strokeWidth: 2.5 }), jsx("circle", { cx: x, cy: y, r: resolvedDotRadius, fill: markerColor })] }, `hover-${key}-${hoveredPoint.index}`));
|
|
344
334
|
}
|
|
345
|
-
return (jsx(ChartMarker, { cx: x, cy: y, radius: resolvedDotRadius, colorClass: colorClass, strokeColor: ((
|
|
335
|
+
return (jsx(ChartMarker, { cx: x, cy: y, radius: resolvedDotRadius, colorClass: colorClass, strokeColor: ((_a = config[key]) === null || _a === void 0 ? void 0 : _a.color) ? resolveSeriesColor(keyIndex, key, config, []) : undefined }, `hover-${key}-${hoveredPoint.index}`));
|
|
346
336
|
}) }) }), jsx("g", { className: "chart-hover-areas", children: data.map((item, dataIndex) => {
|
|
347
337
|
// Calculate hover area based on new point positioning
|
|
348
338
|
const pointX = data.length === 1
|
|
@@ -361,15 +351,14 @@ svgClassName, areaClassName, lineClassName, gridClassName, axisClassName, width,
|
|
|
361
351
|
setHoveredPoint({ index: dataIndex, key: dataKeys[0] });
|
|
362
352
|
// Create multi-series tooltip data
|
|
363
353
|
const seriesData = dataKeys.map((seriesKey, keyIndex) => {
|
|
364
|
-
var _a
|
|
354
|
+
var _a;
|
|
365
355
|
const seriesValue = item[seriesKey];
|
|
366
356
|
const numValue = typeof seriesValue === "number" ? seriesValue : 0;
|
|
367
357
|
return {
|
|
368
358
|
key: seriesKey,
|
|
369
359
|
label: ((_a = config[seriesKey]) === null || _a === void 0 ? void 0 : _a.label) || seriesKey,
|
|
370
360
|
value: numValue,
|
|
371
|
-
color: (
|
|
372
|
-
getSeriesFillColor(keyIndex),
|
|
361
|
+
color: resolveSeriesColor(keyIndex, seriesKey, config, chartTheme.baseStyle.colors.series),
|
|
373
362
|
};
|
|
374
363
|
});
|
|
375
364
|
const content = {
|
|
@@ -14,11 +14,6 @@ export interface AreaChartTheme {
|
|
|
14
14
|
export declare const areaChartTheme: AreaChartTheme;
|
|
15
15
|
/**
|
|
16
16
|
* Get series color class for stroke and fill
|
|
17
|
-
* Uses
|
|
17
|
+
* Uses the dedicated categorical chart-N tokens, not the semantic status colors
|
|
18
18
|
*/
|
|
19
19
|
export declare const getSeriesColorClass: (index: number) => string;
|
|
20
|
-
/**
|
|
21
|
-
* Get fill color for SVG gradients
|
|
22
|
-
* Returns CSS variable value directly for stopColor attribute
|
|
23
|
-
*/
|
|
24
|
-
export declare const getSeriesFillColor: (index: number) => string;
|
|
@@ -17,29 +17,17 @@ const areaChartTheme = {
|
|
|
17
17
|
};
|
|
18
18
|
/**
|
|
19
19
|
* Get series color class for stroke and fill
|
|
20
|
-
* Uses
|
|
20
|
+
* Uses the dedicated categorical chart-N tokens, not the semantic status colors
|
|
21
21
|
*/
|
|
22
22
|
const getSeriesColorClass = (index) => {
|
|
23
23
|
const colors = [
|
|
24
|
-
"stroke-[var(--color-
|
|
25
|
-
"stroke-[var(--color-
|
|
26
|
-
"stroke-[var(--color-
|
|
27
|
-
"stroke-[var(--color-
|
|
24
|
+
"stroke-[var(--color-chart-1)] fill-[var(--color-chart-1)]",
|
|
25
|
+
"stroke-[var(--color-chart-2)] fill-[var(--color-chart-2)]",
|
|
26
|
+
"stroke-[var(--color-chart-3)] fill-[var(--color-chart-3)]",
|
|
27
|
+
"stroke-[var(--color-chart-4)] fill-[var(--color-chart-4)]",
|
|
28
|
+
"stroke-[var(--color-chart-5)] fill-[var(--color-chart-5)]",
|
|
28
29
|
];
|
|
29
30
|
return colors[index % colors.length];
|
|
30
31
|
};
|
|
31
|
-
/**
|
|
32
|
-
* Get fill color for SVG gradients
|
|
33
|
-
* Returns CSS variable value directly for stopColor attribute
|
|
34
|
-
*/
|
|
35
|
-
const getSeriesFillColor = (index) => {
|
|
36
|
-
const colorVars = [
|
|
37
|
-
"var(--color-primary)",
|
|
38
|
-
"var(--color-warning)",
|
|
39
|
-
"var(--color-success)",
|
|
40
|
-
"var(--color-danger)",
|
|
41
|
-
];
|
|
42
|
-
return colorVars[index % colorVars.length];
|
|
43
|
-
};
|
|
44
32
|
|
|
45
|
-
export { areaChartTheme, getSeriesColorClass
|
|
33
|
+
export { areaChartTheme, getSeriesColorClass };
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { BaseChartProps, StandardChartDisplayProps, StandardVisualProps, ChartVariant } from '../types/chart.types';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Visual props that actually apply to an area chart.
|
|
4
|
+
*
|
|
5
|
+
* 🔴 Narrowed with `Omit` on purpose — see the note on `StandardVisualProps`.
|
|
6
|
+
* Dropped: the bar/cell-only props, which an area chart has nothing to apply them to.
|
|
7
|
+
*/
|
|
8
|
+
export type AreaVisualProps = Omit<StandardVisualProps, 'barRadius' | 'gap'>;
|
|
9
|
+
export interface AreaChartProps extends BaseChartProps, StandardChartDisplayProps, AreaVisualProps {
|
|
3
10
|
dotRadius?: number;
|
|
4
11
|
radius?: number;
|
|
5
12
|
strokeWidth?: number;
|
|
@@ -14,10 +21,19 @@ export interface AreaChartProps extends BaseChartProps, StandardChartDisplayProp
|
|
|
14
21
|
gridClassName?: string;
|
|
15
22
|
axisClassName?: string;
|
|
16
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Default values using centralized defaults.
|
|
26
|
+
*
|
|
27
|
+
* 🔴 Picks explicitly rather than spreading `...CHART_DEFAULTS` — see the note on
|
|
28
|
+
* `BAR_CHART_DEFAULTS`.
|
|
29
|
+
*/
|
|
17
30
|
export declare const AREA_CHART_DEFAULTS: {
|
|
31
|
+
readonly showGrid: true;
|
|
32
|
+
readonly showXAxis: true;
|
|
33
|
+
readonly showYAxis: true;
|
|
34
|
+
readonly enableKeyboardNavigation: true;
|
|
18
35
|
readonly variant: ChartVariant;
|
|
19
36
|
readonly dotRadius: 3;
|
|
20
|
-
readonly radius: 3;
|
|
21
37
|
readonly strokeWidth: 2;
|
|
22
38
|
readonly curved: true;
|
|
23
39
|
readonly curveType: import("..").CurveType;
|
|
@@ -25,15 +41,6 @@ export declare const AREA_CHART_DEFAULTS: {
|
|
|
25
41
|
readonly fillOpacity: 0.3;
|
|
26
42
|
readonly showStroke: true;
|
|
27
43
|
readonly stacked: false;
|
|
28
|
-
readonly showGrid: true;
|
|
29
|
-
readonly showXAxis: true;
|
|
30
|
-
readonly showYAxis: true;
|
|
31
|
-
readonly barRadius: 32;
|
|
32
|
-
readonly cellRadius: 4;
|
|
33
|
-
readonly gap: 4;
|
|
34
|
-
readonly categoryGap: 16;
|
|
35
|
-
readonly orientation: "vertical" | "horizontal";
|
|
36
|
-
readonly enableKeyboardNavigation: true;
|
|
37
44
|
};
|
|
38
45
|
export type AreaChartData = BaseChartProps['data'][0];
|
|
39
46
|
export type AreaChartConfig = BaseChartProps['config'];
|
|
@@ -1,11 +1,18 @@
|
|
|
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` — see the note on
|
|
7
|
+
* `BAR_CHART_DEFAULTS`.
|
|
8
|
+
*/
|
|
4
9
|
const AREA_CHART_DEFAULTS = {
|
|
5
|
-
|
|
10
|
+
showGrid: CHART_DEFAULTS.showGrid,
|
|
11
|
+
showXAxis: CHART_DEFAULTS.showXAxis,
|
|
12
|
+
showYAxis: CHART_DEFAULTS.showYAxis,
|
|
13
|
+
enableKeyboardNavigation: CHART_DEFAULTS.enableKeyboardNavigation,
|
|
6
14
|
variant: "gradient", // AreaChart defaults to the gradient (premium) look; use variant="default" for flat fills
|
|
7
15
|
dotRadius: CHART_DEFAULTS.dotRadius, // 20 - For dot markers
|
|
8
|
-
radius: CHART_DEFAULTS.dotRadius, // @deprecated - kept for backward compatibility
|
|
9
16
|
strokeWidth: CHART_DEFAULTS.strokeWidth,
|
|
10
17
|
curved: CHART_DEFAULTS.curved,
|
|
11
18
|
curveType: CHART_DEFAULTS.curveType,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { AreaChart } from './AreaChart';
|
|
2
2
|
export type { AreaChartProps, AreaChartData, AreaChartConfig } from './AreaChart.types';
|
|
3
|
-
export { areaChartTheme, getSeriesColorClass
|
|
3
|
+
export { areaChartTheme, getSeriesColorClass } from './AreaChart.theme';
|
|
4
4
|
export type { AreaChartTheme } from './AreaChart.theme';
|
|
@@ -17,7 +17,9 @@ import { BAR_CHART_DEFAULTS } from './BarChart.types.js';
|
|
|
17
17
|
import { X_AXIS_MARGIN } from '../types/chart.types.js';
|
|
18
18
|
import { BAR_GROUP_STAGGER, BAR_SPRING, barEntranceTransition } from '../utils/animation-utils.js';
|
|
19
19
|
import { BarSeriesDefs, BarGlowRing, barStrokeStyle, barFill, barDimOpacity, deriveBarEmphasis } from '../utils/bar-emphasis.js';
|
|
20
|
-
import {
|
|
20
|
+
import { resolveSeriesColor } from '../utils/series-color.js';
|
|
21
|
+
import { chartTheme } from '../theme/chart.theme.js';
|
|
22
|
+
import { Warning } from '@phosphor-icons/react';
|
|
21
23
|
|
|
22
24
|
// Pure helper functions moved to module level to avoid recreation per render
|
|
23
25
|
const createRoundedTopBarPath = (x, y, width, height, radius) => {
|
|
@@ -59,8 +61,6 @@ showGrid = BAR_CHART_DEFAULTS.showGrid, showXAxis = BAR_CHART_DEFAULTS.showXAxis
|
|
|
59
61
|
// Standardized visual props with defaults (renamed from bar-specific names)
|
|
60
62
|
barRadius, radius, // @deprecated Use barRadius instead
|
|
61
63
|
gap = BAR_CHART_DEFAULTS.gap, categoryGap = BAR_CHART_DEFAULTS.categoryGap,
|
|
62
|
-
// Bar-specific props
|
|
63
|
-
orientation,
|
|
64
64
|
// Animation props
|
|
65
65
|
showAnimation = BAR_CHART_DEFAULTS.showAnimation,
|
|
66
66
|
// Placeholder bar props
|
|
@@ -98,34 +98,15 @@ className, title, description, enableKeyboardNavigation = BAR_CHART_DEFAULTS.ena
|
|
|
98
98
|
const { validation, sanitizedData, isValid, hasWarnings, safeScale, safeMath, } = useChartValidation(data, config, {
|
|
99
99
|
autoSanitize: true,
|
|
100
100
|
});
|
|
101
|
-
// Simple color functions based on direct CSS variables (following guidelines)
|
|
102
101
|
const getSeriesFillColor = (index, key) => {
|
|
103
|
-
var _a, _b
|
|
104
|
-
|
|
105
|
-
const customColor = config[key].color;
|
|
106
|
-
if (!customColor.startsWith("var(") &&
|
|
107
|
-
!customColor.startsWith("#") &&
|
|
108
|
-
!customColor.startsWith("rgb") &&
|
|
109
|
-
!customColor.startsWith("hsl") &&
|
|
110
|
-
customColor.includes("-")) {
|
|
111
|
-
return `var(--color-${customColor})`;
|
|
112
|
-
}
|
|
113
|
-
return customColor;
|
|
114
|
-
}
|
|
115
|
-
const defaultColors = [
|
|
116
|
-
"var(--color-primary)",
|
|
117
|
-
"var(--color-warning)",
|
|
118
|
-
"var(--color-success)",
|
|
119
|
-
"var(--color-danger)",
|
|
120
|
-
];
|
|
121
|
-
// Use custom colors if provided, otherwise fall back to defaults
|
|
122
|
-
const themedColors = (_c = (_b = theme === null || theme === void 0 ? void 0 : theme.baseStyle) === null || _b === void 0 ? void 0 : _b.colors) === null || _c === void 0 ? void 0 : _c.series;
|
|
102
|
+
var _a, _b;
|
|
103
|
+
const themedColors = (_b = (_a = theme === null || theme === void 0 ? void 0 : theme.baseStyle) === null || _a === void 0 ? void 0 : _a.colors) === null || _b === void 0 ? void 0 : _b.series;
|
|
123
104
|
const palette = colors && colors.length > 0
|
|
124
105
|
? colors
|
|
125
106
|
: themedColors && themedColors.length > 0
|
|
126
107
|
? themedColors
|
|
127
|
-
:
|
|
128
|
-
return
|
|
108
|
+
: chartTheme.baseStyle.colors.series;
|
|
109
|
+
return resolveSeriesColor(index, key, config, palette);
|
|
129
110
|
};
|
|
130
111
|
const resolvedLegendPosition = resolveLegendPosition(legend, config);
|
|
131
112
|
const legendItems = Object.keys(config).map((key, index) => {
|
|
@@ -449,7 +430,7 @@ className, title, description, enableKeyboardNavigation = BAR_CHART_DEFAULTS.ena
|
|
|
449
430
|
// Rules of Hooks: "move it before the return."
|
|
450
431
|
// Invalid data: show an error message
|
|
451
432
|
if (!isValid) {
|
|
452
|
-
return (jsxs("div", { className: cn("chart-container flex flex-col items-center justify-center p-6 border border-[var(--color-border)] rounded-lg text-2xl", className), role: "alert", "aria-live": "polite", ...props, children: [jsxs("div", { className: "flex flex-col items-center gap-4 mb-1", children: [jsx(
|
|
433
|
+
return (jsxs("div", { className: cn("chart-container flex flex-col items-center justify-center p-6 border border-[var(--color-border)] rounded-lg text-2xl", className), role: "alert", "aria-live": "polite", ...props, children: [jsxs("div", { className: "flex flex-col items-center gap-4 mb-1", children: [jsx(Warning, { className: "size-6 text-[var(--color-danger)]" }), jsx("div", { className: "text-base font-semibold text-[var(--color-text-secondary)]", children: "Invalid Chart Data" })] }), jsx("p", { className: "text-base text-[var(--color-text-secondary)]/70 mb-2", children: ((_b = validation.errors[0]) === null || _b === void 0 ? void 0 : _b.message) ||
|
|
453
434
|
"Unable to render chart due to data validation errors" }), process.env.NODE_ENV === "development" &&
|
|
454
435
|
validation.errors.length > 1 && (jsxs("details", { className: "text-sm text-warning-500", children: [jsxs("summary", { className: "cursor-pointer", children: ["Show all errors (", validation.errors.length, ")"] }), jsx("ul", { className: "mt-2 text-left", children: validation.errors.map((error, index) => (jsxs("li", { children: ["\u2022 ", error.message] }, index))) })] }))] }));
|
|
455
436
|
}
|
|
@@ -466,7 +447,7 @@ className, title, description, enableKeyboardNavigation = BAR_CHART_DEFAULTS.ena
|
|
|
466
447
|
height: height !== undefined ? (typeof height === "number" ? `${height}px` : height) : undefined,
|
|
467
448
|
}, ...chartAccessibilityProps, onMouseEnter: handleMouseInteraction, onMouseMove: handleMouseInteraction, ...props, children: [resolvedLegendPosition === "top" && (jsx(ChartLegend, { items: legendItems, className: "shrink-0 pb-2" })), descriptionProps && jsx("div", { ...descriptionProps }), showValidationWarnings && hasWarnings && (jsxs("div", { className: "absolute top-2 left-2 right-2 z-10 p-2 bg-[var(--color-warning-50)] border border-[var(--color-warning-200)] rounded text-sm text-[var(--color-warning)] shadow-sm", children: [jsx("strong", { children: "Chart Warnings:" }), jsx("ul", { className: "mt-1", children: validation.warnings
|
|
468
449
|
.filter((warning) => !warning.message.includes("has no valid numeric values"))
|
|
469
|
-
.map((warning, index) => (jsxs("li", { children: ["\u2022 ", warning.message] }, index))) }), validation.warnings.some((warning) => warning.message.includes("has no valid numeric values")) && (jsx("div", { className: "mt-2 pt-2 border-t border-[var(--color-warning-200)]", children: jsx("span", { className: "text-[var(--color-warning)]", children: "\u2139\uFE0F Null/undefined values are handled by using averages from other data points" }) }))] })), jsx("div", { className: "relative flex-1 min-h-0", children: jsxs("svg", { width: "100%", height: "100%", viewBox: `0 0 ${dimensions.width} ${dimensions.height}`, style: { overflow: isGradientVariant ? "visible" : undefined }, children: [jsxs("defs", { children: [jsxs("pattern", { id: hatchPatternId, patternUnits: "userSpaceOnUse", width: "8", height: "8", children: [jsx("rect", { width: "8", height: "8", fill: "var(--color-
|
|
450
|
+
.map((warning, index) => (jsxs("li", { children: ["\u2022 ", warning.message] }, index))) }), validation.warnings.some((warning) => warning.message.includes("has no valid numeric values")) && (jsx("div", { className: "mt-2 pt-2 border-t border-[var(--color-warning-200)]", children: jsx("span", { className: "text-[var(--color-warning)]", children: "\u2139\uFE0F Null/undefined values are handled by using averages from other data points" }) }))] })), jsx("div", { className: "relative flex-1 min-h-0", children: jsxs("svg", { width: "100%", height: "100%", viewBox: `0 0 ${dimensions.width} ${dimensions.height}`, style: { overflow: isGradientVariant ? "visible" : undefined }, children: [jsxs("defs", { children: [jsxs("pattern", { id: hatchPatternId, patternUnits: "userSpaceOnUse", width: "8", height: "8", children: [jsx("rect", { width: "8", height: "8", fill: "var(--color-mono-50)" }), jsx("path", { d: "M-2,2 l4,-4\n M0,8 l8,-8\n M6,10 l4,-4", style: { stroke: "black", strokeWidth: 4, opacity: 0.1 } })] }), isGradientVariant &&
|
|
470
451
|
dataKeys.map((key, index) => {
|
|
471
452
|
const color = getSeriesFillColor(index, key);
|
|
472
453
|
return (jsx(BarSeriesDefs, { gradientId: getBarGradientId(index), shadowId: getBarShadowId(index), ringId: getBarRingId(index), color: color }, key));
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { BaseChartProps, StandardChartDisplayProps, StandardVisualProps, BarChartSpecificProps, ChartVariant } from "../types/chart.types";
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Visual props that actually apply to a vertical 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/cell radii, stroke width, and the line/area/stacked-only props.
|
|
8
|
+
*/
|
|
9
|
+
export type BarVisualProps = Omit<StandardVisualProps, "dotRadius" | "strokeWidth" | "curved" | "curveType" | "showDots" | "fillOpacity" | "showStroke" | "stacked">;
|
|
10
|
+
export interface BarChartProps extends BaseChartProps, StandardChartDisplayProps, BarVisualProps, BarChartSpecificProps {
|
|
3
11
|
barRadius?: number;
|
|
4
12
|
radius?: number;
|
|
5
13
|
gap?: number;
|
|
@@ -23,27 +31,23 @@ export interface BarChartProps extends BaseChartProps, StandardChartDisplayProps
|
|
|
23
31
|
*/
|
|
24
32
|
darkMode?: boolean;
|
|
25
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Default values using centralized defaults.
|
|
36
|
+
*
|
|
37
|
+
* 🔴 Picks explicitly rather than spreading `...CHART_DEFAULTS` — the spread pulled in a
|
|
38
|
+
* default for every other chart's props, so this object advertised values BarChart never
|
|
39
|
+
* reads. List only what the component actually consumes.
|
|
40
|
+
*/
|
|
26
41
|
export declare const BAR_CHART_DEFAULTS: {
|
|
42
|
+
readonly showGrid: true;
|
|
43
|
+
readonly showXAxis: true;
|
|
44
|
+
readonly showYAxis: true;
|
|
45
|
+
readonly enableKeyboardNavigation: true;
|
|
27
46
|
readonly variant: ChartVariant;
|
|
28
47
|
readonly barRadius: 32;
|
|
29
|
-
readonly radius: 32;
|
|
30
48
|
readonly gap: 4;
|
|
31
49
|
readonly categoryGap: 16;
|
|
32
|
-
readonly orientation: "horizontal" | "vertical";
|
|
33
50
|
readonly showAnimation: true;
|
|
34
51
|
readonly showPlaceholderBars: false;
|
|
35
|
-
readonly showGrid: true;
|
|
36
|
-
readonly showXAxis: true;
|
|
37
|
-
readonly showYAxis: true;
|
|
38
|
-
readonly dotRadius: 3;
|
|
39
|
-
readonly cellRadius: 4;
|
|
40
|
-
readonly strokeWidth: 2;
|
|
41
|
-
readonly curved: true;
|
|
42
|
-
readonly curveType: import("..").CurveType;
|
|
43
|
-
readonly fillOpacity: 0.3;
|
|
44
|
-
readonly showStroke: true;
|
|
45
|
-
readonly showDots: false;
|
|
46
|
-
readonly stacked: false;
|
|
47
|
-
readonly enableKeyboardNavigation: true;
|
|
48
52
|
};
|
|
49
53
|
export type BarChartData = BaseChartProps["data"][0];
|
|
@@ -1,14 +1,21 @@
|
|
|
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 BarChart never
|
|
8
|
+
* reads. List only what the component actually consumes.
|
|
9
|
+
*/
|
|
4
10
|
const BAR_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
|
variant: "gradient", // BarChart defaults to the gradient (premium) look; use variant="default" for flat fills
|
|
7
16
|
barRadius: CHART_DEFAULTS.barRadius, // 24 - For bar corner rounding
|
|
8
|
-
radius: CHART_DEFAULTS.barRadius, // @deprecated - kept for backward compatibility
|
|
9
17
|
gap: CHART_DEFAULTS.gap,
|
|
10
18
|
categoryGap: CHART_DEFAULTS.categoryGap,
|
|
11
|
-
orientation: CHART_DEFAULTS.orientation,
|
|
12
19
|
showAnimation: true, // Enable animations by default
|
|
13
20
|
showPlaceholderBars: false, // Opt-in feature for backward compatibility
|
|
14
21
|
};
|
|
@@ -7,14 +7,17 @@ import { BAR_STACK_CATEGORY_DELAY, BAR_STACK_SEGMENT_STAGGER, BAR_GROUP_STAGGER,
|
|
|
7
7
|
import { BarGlowRing, barStrokeStyle, barFill, barDimOpacity, BarSeriesDefs, deriveBarEmphasis } from '../utils/bar-emphasis.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* Fallback only — ComboChart always resolves a real color onto each series'
|
|
11
|
+
* config before it reaches this renderer (see ComboChart.tsx), so this array
|
|
12
|
+
* exists purely as a defensive default, not a live categorical palette.
|
|
11
13
|
*/
|
|
12
14
|
const getSeriesFillColor = (index) => {
|
|
13
15
|
const colorVars = [
|
|
14
|
-
"var(--color-
|
|
15
|
-
"var(--color-
|
|
16
|
-
"var(--color-
|
|
17
|
-
"var(--color-
|
|
16
|
+
"var(--color-chart-1)",
|
|
17
|
+
"var(--color-chart-2)",
|
|
18
|
+
"var(--color-chart-3)",
|
|
19
|
+
"var(--color-chart-4)",
|
|
20
|
+
"var(--color-chart-5)",
|
|
18
21
|
];
|
|
19
22
|
return colorVars[index % colorVars.length];
|
|
20
23
|
};
|
|
@@ -8,7 +8,9 @@ import { BarRenderer } from './BarRenderer.js';
|
|
|
8
8
|
import { LineRenderer } from './LineRenderer.js';
|
|
9
9
|
import { resolveLegendPosition, ChartLegend } from '../shared/ChartLegend/ChartLegend.js';
|
|
10
10
|
import { COMBO_CHART_DEFAULTS } from './ComboChart.types.js';
|
|
11
|
-
import {
|
|
11
|
+
import { Warning } from '@phosphor-icons/react';
|
|
12
|
+
import { resolveSeriesColor } from '../utils/series-color.js';
|
|
13
|
+
import { chartTheme } from '../theme/chart.theme.js';
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
* Internal component that uses context to render bars and lines
|
|
@@ -16,31 +18,22 @@ import { ExclamationTriangleIcon } from '@heroicons/react/20/solid';
|
|
|
16
18
|
const ComboChartRenderers = ({ barKeys, lineKeys, stacked, barRadius, dotRadius, gap, categoryGap, strokeWidth, curved, curveType, showDots, variant, }) => {
|
|
17
19
|
const context = useComboChartContext();
|
|
18
20
|
const dataKeys = Object.keys(context.config);
|
|
19
|
-
const seriesColors =
|
|
20
|
-
"var(--color-primary)",
|
|
21
|
-
"var(--color-warning)",
|
|
22
|
-
"var(--color-success)",
|
|
23
|
-
"var(--color-danger)",
|
|
24
|
-
];
|
|
21
|
+
const seriesColors = chartTheme.baseStyle.colors.series;
|
|
25
22
|
// Filter configs for bars and lines, and assign colors
|
|
26
23
|
const barConfig = {};
|
|
27
24
|
barKeys.forEach((key) => {
|
|
28
|
-
var _a;
|
|
29
25
|
const keyIndex = dataKeys.indexOf(key);
|
|
30
26
|
barConfig[key] = {
|
|
31
27
|
...context.config[key],
|
|
32
|
-
color: (
|
|
33
|
-
seriesColors[keyIndex % seriesColors.length],
|
|
28
|
+
color: resolveSeriesColor(keyIndex, key, context.config, seriesColors),
|
|
34
29
|
};
|
|
35
30
|
});
|
|
36
31
|
const lineConfig = {};
|
|
37
32
|
lineKeys.forEach((key) => {
|
|
38
|
-
var _a;
|
|
39
33
|
const keyIndex = dataKeys.indexOf(key);
|
|
40
34
|
lineConfig[key] = {
|
|
41
35
|
...context.config[key],
|
|
42
|
-
color: (
|
|
43
|
-
seriesColors[keyIndex % seriesColors.length],
|
|
36
|
+
color: resolveSeriesColor(keyIndex, key, context.config, seriesColors),
|
|
44
37
|
};
|
|
45
38
|
});
|
|
46
39
|
// Create custom tooltip handler that includes ALL series (bars + lines)
|
|
@@ -49,14 +42,14 @@ const ComboChartRenderers = ({ barKeys, lineKeys, stacked, barRadius, dotRadius,
|
|
|
49
42
|
const dataItem = context.data.find((d) => d.name === content.category);
|
|
50
43
|
if (dataItem) {
|
|
51
44
|
const allSeries = dataKeys.map((key, idx) => {
|
|
52
|
-
var _a
|
|
45
|
+
var _a;
|
|
53
46
|
const value = dataItem[key];
|
|
54
47
|
const isNull = value === null || value === undefined || (typeof value === 'number' && !isFinite(value));
|
|
55
48
|
return {
|
|
56
49
|
key,
|
|
57
50
|
label: ((_a = context.config[key]) === null || _a === void 0 ? void 0 : _a.label) || key,
|
|
58
51
|
value: isNull ? 0 : value,
|
|
59
|
-
color: (
|
|
52
|
+
color: resolveSeriesColor(idx, key, context.config, seriesColors),
|
|
60
53
|
};
|
|
61
54
|
}).filter(series => {
|
|
62
55
|
// Only show series that have valid non-zero values
|
|
@@ -117,19 +110,13 @@ className, title, description, enableKeyboardNavigation = COMBO_CHART_DEFAULTS.e
|
|
|
117
110
|
const seriesConfig = config[key];
|
|
118
111
|
return (seriesConfig === null || seriesConfig === void 0 ? void 0 : seriesConfig.type) === "line";
|
|
119
112
|
});
|
|
120
|
-
const legendSeriesColors = [
|
|
121
|
-
"var(--color-primary)",
|
|
122
|
-
"var(--color-warning)",
|
|
123
|
-
"var(--color-success)",
|
|
124
|
-
"var(--color-danger)",
|
|
125
|
-
];
|
|
126
113
|
const resolvedLegendPosition = resolveLegendPosition(legend, config || {});
|
|
127
114
|
const legendItems = dataKeys.map((key, index) => {
|
|
128
|
-
var _a, _b
|
|
115
|
+
var _a, _b;
|
|
129
116
|
return ({
|
|
130
117
|
key,
|
|
131
118
|
label: (_b = (_a = config[key]) === null || _a === void 0 ? void 0 : _a.label) !== null && _b !== void 0 ? _b : key,
|
|
132
|
-
color: (
|
|
119
|
+
color: resolveSeriesColor(index, key, config, chartTheme.baseStyle.colors.series),
|
|
133
120
|
});
|
|
134
121
|
});
|
|
135
122
|
// Use unified chart scales hook
|
|
@@ -146,7 +133,7 @@ className, title, description, enableKeyboardNavigation = COMBO_CHART_DEFAULTS.e
|
|
|
146
133
|
});
|
|
147
134
|
// Early return for invalid data with error message
|
|
148
135
|
if (!isValid) {
|
|
149
|
-
return (jsxs("div", { className: cn("chart-container flex flex-col items-center justify-center p-6 border border-border rounded-lg text-2xl", className), role: "alert", "aria-live": "polite", ...props, children: [jsxs("div", { className: "flex flex-col items-center gap-4 mb-1", children: [jsx(
|
|
136
|
+
return (jsxs("div", { className: cn("chart-container flex flex-col items-center justify-center p-6 border border-border rounded-lg text-2xl", className), role: "alert", "aria-live": "polite", ...props, children: [jsxs("div", { className: "flex flex-col items-center gap-4 mb-1", children: [jsx(Warning, { className: "size-6 text-[var(--color-danger)]" }), jsx("div", { className: "text-base font-semibold text-[var(--color-text-secondary)]", children: "Invalid Chart Data" })] }), jsx("p", { className: "text-base text-[var(--color-text-secondary)]/70 mb-2", children: "Unable to render chart due to data validation errors" })] }));
|
|
150
137
|
}
|
|
151
138
|
// Early return for empty data
|
|
152
139
|
if (!sanitizedData || sanitizedData.length === 0) {
|