@flikk/ui 1.0.0-beta.27 → 1.0.0-beta.29
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/dist/bg/1.webp +0 -0
- package/dist/bg/10.webp +0 -0
- package/dist/bg/11.webp +0 -0
- package/dist/bg/12.webp +0 -0
- package/dist/bg/13.webp +0 -0
- package/dist/bg/14.webp +0 -0
- package/dist/bg/15.webp +0 -0
- package/dist/bg/16.webp +0 -0
- package/dist/bg/17.webp +0 -0
- package/dist/bg/18.webp +0 -0
- package/dist/bg/19.webp +0 -0
- package/dist/bg/2.webp +0 -0
- package/dist/bg/20.webp +0 -0
- package/dist/bg/21.webp +0 -0
- package/dist/bg/22.webp +0 -0
- package/dist/bg/3.webp +0 -0
- package/dist/bg/4.webp +0 -0
- package/dist/bg/5.webp +0 -0
- package/dist/bg/6.webp +0 -0
- package/dist/bg/7.webp +0 -0
- package/dist/bg/8.webp +0 -0
- package/dist/bg/9.webp +0 -0
- package/dist/components/ai/CodeBlock/CodeBlock.theme.js +1 -1
- package/dist/components/ai/PromptInput/PromptInput.js +7 -143
- package/dist/components/ai/PromptInput/VoiceRecorder.js +0 -88
- package/dist/components/ai/TokenCounter/TokenCounter.theme.js +1 -1
- package/dist/components/canvas/Background.d.ts +19 -0
- package/dist/components/canvas/Background.js +23 -0
- package/dist/components/canvas/BaseNode.d.ts +15 -0
- package/dist/components/canvas/BaseNode.js +20 -0
- package/dist/components/canvas/CanvasToolbar.d.ts +34 -0
- package/dist/components/canvas/CanvasToolbar.js +34 -0
- package/dist/components/canvas/Edge.d.ts +35 -0
- package/dist/components/canvas/Edge.js +97 -0
- package/dist/components/canvas/EdgeLayer.d.ts +18 -0
- package/dist/components/canvas/EdgeLayer.js +111 -0
- package/dist/components/canvas/Handle.d.ts +11 -0
- package/dist/components/canvas/Handle.js +63 -0
- package/dist/components/canvas/MiniMap.d.ts +22 -0
- package/dist/components/canvas/MiniMap.js +105 -0
- package/dist/components/canvas/NodeCanvas.d.ts +10 -0
- package/dist/components/canvas/NodeCanvas.js +477 -0
- package/dist/components/canvas/NodeCanvas.theme.d.ts +7 -0
- package/dist/components/canvas/NodeCanvas.theme.js +9 -0
- package/dist/components/canvas/NodeCanvas.types.d.ts +187 -0
- package/dist/components/canvas/NodeControls.d.ts +25 -0
- package/dist/components/canvas/NodeControls.js +40 -0
- package/dist/components/canvas/NodeRenderer.d.ts +19 -0
- package/dist/components/canvas/NodeRenderer.js +117 -0
- package/dist/components/canvas/changes.d.ts +11 -0
- package/dist/components/canvas/changes.js +76 -0
- package/dist/components/canvas/context/CanvasContext.d.ts +32 -0
- package/dist/components/canvas/context/CanvasContext.js +14 -0
- package/dist/components/canvas/context/ConnectionContext.d.ts +33 -0
- package/dist/components/canvas/context/ConnectionContext.js +13 -0
- package/dist/components/canvas/context/HandleRegistry.d.ts +24 -0
- package/dist/components/canvas/context/HandleRegistry.js +15 -0
- package/dist/components/canvas/context/InteractionContext.d.ts +18 -0
- package/dist/components/canvas/context/InteractionContext.js +14 -0
- package/dist/components/canvas/context/NodeIdContext.d.ts +3 -0
- package/dist/components/canvas/context/NodeIdContext.js +15 -0
- package/dist/components/canvas/hooks/useConnection.d.ts +17 -0
- package/dist/components/canvas/hooks/useConnection.js +29 -0
- package/dist/components/canvas/hooks/useMarquee.d.ts +25 -0
- package/dist/components/canvas/hooks/useMarquee.js +91 -0
- package/dist/components/canvas/hooks/useNodeDrag.d.ts +23 -0
- package/dist/components/canvas/hooks/useNodeDrag.js +110 -0
- package/dist/components/canvas/hooks/usePanZoom.d.ts +30 -0
- package/dist/components/canvas/hooks/usePanZoom.js +189 -0
- package/dist/components/canvas/hooks/useViewport.d.ts +21 -0
- package/dist/components/canvas/hooks/useViewport.js +35 -0
- package/dist/components/canvas/index.d.ts +14 -0
- package/dist/components/canvas/index.js +12 -0
- package/dist/components/canvas/layout.d.ts +22 -0
- package/dist/components/canvas/layout.js +67 -0
- package/dist/components/canvas/utils.d.ts +4 -0
- package/dist/components/canvas/utils.js +16 -0
- package/dist/components/charts/AreaChart/AreaChart.js +136 -101
- package/dist/components/charts/AreaChart/AreaChart.types.d.ts +5 -5
- package/dist/components/charts/AreaChart/AreaChart.types.js +1 -0
- package/dist/components/charts/BarChart/BarChart.js +207 -143
- package/dist/components/charts/BarChart/BarChart.types.d.ts +4 -4
- package/dist/components/charts/BarChart/BarChart.types.js +1 -0
- package/dist/components/charts/ComboChart/ComboChart.types.d.ts +2 -2
- package/dist/components/charts/LineChart/LineChart.js +88 -72
- package/dist/components/charts/LineChart/LineChart.types.d.ts +3 -3
- package/dist/components/charts/RadarChart/RadarChart.js +1 -1
- package/dist/components/charts/RadarChart/RadarChart.theme.js +5 -2
- package/dist/components/charts/ScatterPlot/ScatterPlot.js +62 -72
- package/dist/components/charts/ScatterPlot/ScatterPlot.theme.js +10 -1
- package/dist/components/charts/ScatterPlot/ScatterPlot.types.d.ts +3 -9
- package/dist/components/charts/StackedBarChart/StackedBarChart.js +33 -33
- package/dist/components/charts/StackedBarChart/StackedBarChart.types.d.ts +2 -2
- package/dist/components/charts/hooks/index.d.ts +2 -0
- package/dist/components/charts/hooks/useChartDimensions.d.ts +29 -0
- package/dist/components/charts/hooks/useChartDimensions.js +42 -0
- package/dist/components/charts/shared/ChartTooltip/ChartTooltip.theme.js +1 -1
- package/dist/components/charts/types/chart.types.d.ts +11 -2
- package/dist/components/charts/types/chart.types.js +10 -3
- package/dist/components/core/Avatar/Avatar.js +5 -1
- package/dist/components/core/AvatarGroup/AvatarGroup.js +5 -1
- package/dist/components/core/AvatarGroup/AvatarGroup.theme.js +4 -2
- package/dist/components/core/Badge/Badge.js +1 -1
- package/dist/components/core/Badge/Badge.theme.js +16 -15
- package/dist/components/core/Button/Button.js +1 -1
- package/dist/components/core/Button/Button.theme.js +2 -2
- package/dist/components/core/Calendar/Calendar.theme.js +1 -1
- package/dist/components/core/Card/Card.js +7 -3
- package/dist/components/core/Card/Card.theme.js +3 -3
- package/dist/components/core/Card/Card.types.d.ts +27 -2
- package/dist/components/core/CommandPalette/CommandPalette.theme.js +2 -2
- package/dist/components/core/ContextMenu/ContextMenu.theme.js +2 -2
- package/dist/components/core/ContextMenu/ContextMenuItem.js +1 -1
- package/dist/components/core/ContextMenu/ContextMenuSubTrigger.js +1 -1
- package/dist/components/core/Dropdown/Dropdown.theme.js +3 -3
- package/dist/components/core/Dropdown/DropdownMenu.js +57 -29
- package/dist/components/core/HeroCard/HeroCard.d.ts +5 -0
- package/dist/components/core/HeroCard/HeroCard.js +99 -0
- package/dist/components/core/HeroCard/HeroCard.theme.d.ts +3 -0
- package/dist/components/core/HeroCard/HeroCard.theme.js +8 -0
- package/dist/components/core/HeroCard/HeroCard.types.d.ts +70 -0
- package/dist/components/core/HeroCard/index.d.ts +4 -0
- package/dist/components/core/Kbd/Kbd.theme.js +1 -1
- package/dist/components/core/Modal/Modal.d.ts +1 -1
- package/dist/components/core/Modal/Modal.js +2 -7
- package/dist/components/core/Modal/Modal.theme.js +4 -8
- package/dist/components/core/Modal/Modal.types.d.ts +0 -10
- package/dist/components/core/Modal/index.d.ts +1 -1
- package/dist/components/core/ModalStack/ModalStack.d.ts +1 -1
- package/dist/components/core/ModalStack/ModalStack.types.d.ts +1 -2
- package/dist/components/core/ModalStack/ModalStackModal.d.ts +1 -1
- package/dist/components/core/ModalStack/ModalStackModal.js +2 -7
- package/dist/components/core/PageHeading/PageHeading.theme.js +2 -2
- package/dist/components/core/Popover/Popover.theme.js +1 -1
- package/dist/components/core/ScrollArea/ScrollArea.js +242 -4
- package/dist/components/core/ScrollArea/ScrollArea.types.d.ts +12 -1
- package/dist/components/core/ScrollArea/smooth/SmoothScrollEngine.d.ts +4 -0
- package/dist/components/core/ScrollArea/smooth/SmoothScrollEngine.js +23 -0
- package/dist/components/core/ScrollArea/smooth/useSmoothScroll.js +4 -0
- package/dist/components/core/ScrollArea/smooth/useSmoothScroll.types.d.ts +5 -0
- package/dist/components/core/Segmented/Segmented.theme.js +2 -2
- package/dist/components/core/Tooltip/Tooltip.theme.js +1 -1
- package/dist/components/core/index.d.ts +1 -0
- package/dist/components/core/index.js +2 -0
- package/dist/components/data-display/DescriptionList/DescriptionList.js +23 -7
- package/dist/components/data-display/DescriptionList/DescriptionList.theme.js +10 -3
- package/dist/components/data-display/DescriptionList/DescriptionList.types.d.ts +49 -10
- package/dist/components/data-display/DescriptionList/index.d.ts +1 -1
- package/dist/components/data-display/Feed/Feed.js +28 -5
- package/dist/components/data-display/Feed/Feed.theme.js +1 -1
- package/dist/components/data-display/Feed/Feed.types.d.ts +32 -1
- package/dist/components/data-display/Feed/index.d.ts +1 -1
- package/dist/components/data-display/Metric/Metric.js +8 -8
- package/dist/components/data-display/Metric/Metric.theme.d.ts +3 -2
- package/dist/components/data-display/Metric/Metric.theme.js +50 -68
- package/dist/components/data-display/Metric/Metric.types.d.ts +19 -21
- package/dist/components/data-display/Table/Table.js +2 -2
- package/dist/components/data-display/Table/Table.theme.js +24 -4
- package/dist/components/data-display/Table/Table.types.d.ts +8 -0
- package/dist/components/data-display/Table/TableBody.js +2 -2
- package/dist/components/data-display/Table/TableCell.js +1 -1
- package/dist/components/data-display/Table/TableRow.d.ts +1 -1
- package/dist/components/data-display/Table/TableRow.js +9 -2
- package/dist/components/data-display/Timeline/Timeline.js +27 -5
- package/dist/components/data-display/Timeline/Timeline.theme.d.ts +10 -2
- package/dist/components/data-display/Timeline/Timeline.theme.js +14 -8
- package/dist/components/data-display/Timeline/Timeline.types.d.ts +48 -16
- package/dist/components/data-display/Timeline/Timeline.utils.d.ts +6 -0
- package/dist/components/data-display/Timeline/Timeline.utils.js +11 -0
- package/dist/components/data-display/Timeline/TimelineItem.js +13 -20
- package/dist/components/data-display/Timeline/TimelineMarker.js +10 -8
- package/dist/components/data-display/Timeline/index.d.ts +2 -2
- package/dist/components/effects/3d/index.d.ts +0 -2
- package/dist/components/effects/3d/index.js +0 -1
- package/dist/components/effects/DotPattern/DotPattern.js +1 -1
- package/dist/components/effects/Overlay/Overlay.theme.js +1 -2
- package/dist/components/effects/Preloader/Preloader.animations.d.ts +23 -0
- package/dist/components/effects/Preloader/Preloader.animations.js +150 -0
- package/dist/components/effects/Preloader/Preloader.d.ts +3 -0
- package/dist/components/effects/Preloader/Preloader.js +119 -0
- package/dist/components/effects/Preloader/Preloader.types.d.ts +63 -0
- package/dist/components/effects/Preloader/index.d.ts +2 -0
- package/dist/components/effects/ProgressiveBlur/ProgressiveBlur.js +25 -14
- package/dist/components/effects/ProgressiveBlur/ProgressiveBlur.types.d.ts +2 -0
- package/dist/components/effects/TiltCard/TiltCard.d.ts +12 -0
- package/dist/components/effects/TiltCard/TiltCard.glow.d.ts +28 -0
- package/dist/components/effects/TiltCard/TiltCard.glow.js +114 -0
- package/dist/components/effects/TiltCard/TiltCard.js +177 -0
- package/dist/components/effects/{SpotlightBorder/SpotlightBorder.shaders.d.ts → TiltCard/TiltCard.shaders.d.ts} +1 -1
- package/dist/components/effects/{SpotlightBorder/SpotlightBorder.shaders.js → TiltCard/TiltCard.shaders.js} +1 -1
- package/dist/components/effects/TiltCard/TiltCard.types.d.ts +88 -0
- package/dist/components/effects/TiltCard/index.d.ts +2 -0
- package/dist/components/effects/index.d.ts +4 -12
- package/dist/components/effects/index.js +2 -6
- package/dist/components/forms/Checkbox/Checkbox.js +7 -1
- package/dist/components/forms/DatePicker/DatePicker.theme.js +2 -2
- package/dist/components/forms/DateRangePicker/DateRangePicker.theme.js +1 -1
- package/dist/components/forms/FileUpload/FileUpload.js +1 -89
- package/dist/components/forms/FormLabel/FormLabel.theme.js +1 -1
- package/dist/components/forms/RichTextEditor/RichTextEditor.theme.js +2 -2
- package/dist/components/forms/Slider/Slider.theme.js +1 -1
- package/dist/components/forms/Switch/Switch.js +27 -15
- package/dist/components/forms/Switch/Switch.theme.d.ts +36 -6
- package/dist/components/forms/Switch/Switch.theme.js +33 -4
- package/dist/components/forms/Switch/Switch.types.d.ts +12 -2
- package/dist/components/forms/TimePicker/TimePicker.theme.js +1 -2
- package/dist/components/forms/TimePicker/TimePickerContent.js +1 -90
- package/dist/components/forms/forms.theme.js +1 -1
- package/dist/components/forms/index.d.ts +0 -4
- package/dist/components/forms/index.js +0 -92
- package/dist/components/generative/GenerativeView.d.ts +21 -0
- package/dist/components/generative/GenerativeView.js +116 -0
- package/dist/components/generative/actions.d.ts +26 -0
- package/dist/components/generative/actions.js +51 -0
- package/dist/components/generative/index.d.ts +11 -0
- package/dist/components/generative/index.js +9 -0
- package/dist/components/generative/registry.d.ts +43 -0
- package/dist/components/generative/registry.js +114 -0
- package/dist/components/generative/resolvers.d.ts +35 -0
- package/dist/components/generative/resolvers.js +93 -0
- package/dist/components/generative/schema.generated.d.ts +2 -0
- package/dist/components/generative/schema.generated.js +1639 -0
- package/dist/components/generative/schemaTypes.d.ts +30 -0
- package/dist/components/generative/streaming.d.ts +39 -0
- package/dist/components/generative/streaming.js +283 -0
- package/dist/components/generative/tools.d.ts +21 -0
- package/dist/components/generative/tools.js +54 -0
- package/dist/components/generative/types.d.ts +41 -0
- package/dist/components/generative/useGenerativeStream.d.ts +37 -0
- package/dist/components/generative/useGenerativeStream.js +36 -0
- package/dist/components/generative/validate.d.ts +24 -0
- package/dist/components/generative/validate.js +259 -0
- package/dist/components/layout/AppShell/AppShell.theme.js +2 -2
- package/dist/components/layout/FormLayout/FormLayout.js +1 -90
- package/dist/components/layout/Grid/Grid.d.ts +3 -0
- package/dist/components/layout/Grid/Grid.js +50 -0
- package/dist/components/layout/Grid/Grid.theme.d.ts +2 -0
- package/dist/components/layout/Grid/Grid.theme.js +35 -0
- package/dist/components/layout/Grid/Grid.types.d.ts +57 -0
- package/dist/components/layout/Grid/index.d.ts +3 -0
- package/dist/components/layout/Section/Section.d.ts +3 -0
- package/dist/components/layout/Section/Section.js +18 -0
- package/dist/components/layout/Section/Section.theme.d.ts +2 -0
- package/dist/components/layout/Section/Section.theme.js +10 -0
- package/dist/components/layout/Section/Section.types.d.ts +34 -0
- package/dist/components/layout/Section/index.d.ts +3 -0
- package/dist/components/layout/Stack/Stack.d.ts +3 -0
- package/dist/components/layout/Stack/Stack.js +19 -0
- package/dist/components/layout/Stack/Stack.theme.d.ts +2 -0
- package/dist/components/layout/Stack/Stack.theme.js +10 -0
- package/dist/components/layout/Stack/Stack.types.d.ts +39 -0
- package/dist/components/layout/Stack/index.d.ts +3 -0
- package/dist/components/layout/index.d.ts +3 -0
- package/dist/components/layout/index.js +6 -0
- package/dist/generative.schema.json +1637 -0
- package/dist/index.js +180 -180
- package/dist/registry.json +648 -464
- package/dist/styles.css +1 -1
- package/dist/tools.json +1731 -0
- package/package.json +17 -4
- package/src/global.scss +53 -101
- package/src/styles/theme.css +687 -493
- package/dist/bg/1.jpg +0 -0
- package/dist/bg/10.jpg +0 -0
- package/dist/bg/11.jpg +0 -0
- package/dist/bg/14.jpg +0 -0
- package/dist/bg/15.jpg +0 -0
- package/dist/bg/16.jpg +0 -0
- package/dist/bg/17.jpg +0 -0
- package/dist/bg/18.jpg +0 -0
- package/dist/bg/19.jpg +0 -0
- package/dist/bg/2.jpg +0 -0
- package/dist/bg/20.jpg +0 -0
- package/dist/bg/21.jpg +0 -0
- package/dist/bg/22.jpg +0 -0
- package/dist/bg/23.jpg +0 -0
- package/dist/bg/24.jpg +0 -0
- package/dist/bg/3.jpg +0 -0
- package/dist/bg/4.jpg +0 -0
- package/dist/bg/5.jpg +0 -0
- package/dist/bg/6.jpg +0 -0
- package/dist/bg/7.jpg +0 -0
- package/dist/bg/8.jpg +0 -0
- package/dist/bg/9.jpg +0 -0
- package/dist/components/effects/MorphingText/MorphingText.d.ts +0 -17
- package/dist/components/effects/MorphingText/MorphingText.js +0 -125
- package/dist/components/effects/MorphingText/MorphingText.types.d.ts +0 -18
- package/dist/components/effects/MorphingText/index.d.ts +0 -2
- package/dist/components/effects/PageTransition/PageTransition.animations.d.ts +0 -8
- package/dist/components/effects/PageTransition/PageTransition.animations.js +0 -53
- package/dist/components/effects/PageTransition/PageTransition.d.ts +0 -3
- package/dist/components/effects/PageTransition/PageTransition.js +0 -82
- package/dist/components/effects/PageTransition/PageTransition.types.d.ts +0 -15
- package/dist/components/effects/PageTransition/index.d.ts +0 -2
- package/dist/components/effects/ParallaxSection/ParallaxSection.d.ts +0 -26
- package/dist/components/effects/ParallaxSection/ParallaxSection.js +0 -71
- package/dist/components/effects/ParallaxSection/ParallaxSection.types.d.ts +0 -11
- package/dist/components/effects/ParallaxSection/index.d.ts +0 -2
- package/dist/components/effects/Spotlight/Spotlight.d.ts +0 -36
- package/dist/components/effects/Spotlight/Spotlight.js +0 -112
- package/dist/components/effects/Spotlight/Spotlight.types.d.ts +0 -29
- package/dist/components/effects/Spotlight/index.d.ts +0 -2
- package/dist/components/effects/SpotlightBorder/SpotlightBorder.d.ts +0 -18
- package/dist/components/effects/SpotlightBorder/SpotlightBorder.js +0 -213
- package/dist/components/effects/SpotlightBorder/SpotlightBorder.types.d.ts +0 -61
- package/dist/components/effects/SpotlightBorder/index.d.ts +0 -2
- package/dist/components/effects/StickyScroll/StickyScroll.d.ts +0 -30
- package/dist/components/effects/StickyScroll/StickyScroll.js +0 -128
- package/dist/components/effects/StickyScroll/StickyScroll.types.d.ts +0 -19
- package/dist/components/effects/StickyScroll/index.d.ts +0 -2
- package/dist/components/forms/CronInput/CronInput.d.ts +0 -3
- package/dist/components/forms/CronInput/CronInput.js +0 -113
- package/dist/components/forms/CronInput/CronInput.theme.d.ts +0 -6
- package/dist/components/forms/CronInput/CronInput.theme.js +0 -75
- package/dist/components/forms/CronInput/CronInput.types.d.ts +0 -109
- package/dist/components/forms/CronInput/CronInput.utils.d.ts +0 -67
- package/dist/components/forms/CronInput/CronInput.utils.js +0 -505
- package/dist/components/forms/CronInput/index.d.ts +0 -4
- /package/dist/components/effects/{SpotlightBorder/SpotlightBorder.types.js → TiltCard/TiltCard.types.js} +0 -0
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { useState, useEffect, useRef, useMemo } from 'react';
|
|
3
|
-
import { useReducedMotion, motion } from 'motion/react';
|
|
2
|
+
import React__default, { useId, useState, useEffect, useRef, useMemo } from 'react';
|
|
3
|
+
import { useReducedMotion, motion, AnimatePresence } from 'motion/react';
|
|
4
4
|
import { cn } from '../../../utils/cn.js';
|
|
5
5
|
import { useTooltipPosition } from '../hooks/useTooltipPosition.js';
|
|
6
6
|
import { useChartAccessibility } from '../hooks/useChartAccessibility.js';
|
|
7
7
|
import { useChartValidation } from '../hooks/useChartValidation.js';
|
|
8
|
+
import { useChartDimensions } from '../hooks/useChartDimensions.js';
|
|
8
9
|
import { ChartErrorBoundary } from '../shared/ChartErrorBoundary/ChartErrorBoundary.js';
|
|
9
10
|
import { XAxis } from '../shared/ChartAxis/XAxis.js';
|
|
10
11
|
import { YAxis } from '../shared/ChartAxis/YAxis.js';
|
|
11
12
|
import { HorizontalGrid } from '../shared/ChartGrid/HorizontalGrid.js';
|
|
12
13
|
import { ChartTooltip } from '../shared/ChartTooltip/ChartTooltip.js';
|
|
13
14
|
import { BAR_CHART_DEFAULTS } from './BarChart.types.js';
|
|
15
|
+
import { X_AXIS_MARGIN } from '../types/chart.types.js';
|
|
14
16
|
import { ExclamationTriangleIcon } from '@heroicons/react/20/solid';
|
|
15
17
|
|
|
16
18
|
// Pure helper functions moved to module level to avoid recreation per render
|
|
@@ -62,10 +64,16 @@ showPlaceholderBars = BAR_CHART_DEFAULTS.showPlaceholderBars, placeholderData,
|
|
|
62
64
|
// Color customization
|
|
63
65
|
colors,
|
|
64
66
|
// Base props
|
|
65
|
-
className, title, description, enableKeyboardNavigation = BAR_CHART_DEFAULTS.enableKeyboardNavigation, showValidationWarnings = process.env.NODE_ENV === "development", darkMode = false, children, ...props }) => {
|
|
67
|
+
className, title, description, enableKeyboardNavigation = BAR_CHART_DEFAULTS.enableKeyboardNavigation, showValidationWarnings = process.env.NODE_ENV === "development", darkMode = false, width, height, children, ...props }) => {
|
|
66
68
|
var _a, _b;
|
|
67
69
|
// Resolve barRadius with backward compatibility
|
|
68
70
|
const resolvedBarRadius = (_a = barRadius !== null && barRadius !== void 0 ? barRadius : radius) !== null && _a !== void 0 ? _a : BAR_CHART_DEFAULTS.barRadius;
|
|
71
|
+
const chartId = useId().replace(/[^a-zA-Z0-9_-]/g, "");
|
|
72
|
+
const isGradientVariant = variant === "gradient";
|
|
73
|
+
const hatchPatternId = `${chartId}-diagonal-hatch`;
|
|
74
|
+
const getBarGradientId = (index) => `${chartId}-bar-gradient-${index}`;
|
|
75
|
+
const getBarShadowId = (index) => `${chartId}-bar-shadow-${index}`;
|
|
76
|
+
const getBarRingId = (index) => `${chartId}-bar-ring-${index}`;
|
|
69
77
|
// Development warning for deprecated radius prop
|
|
70
78
|
if (process.env.NODE_ENV !== "production" && radius !== undefined) {
|
|
71
79
|
console.warn("[BarChart]: The `radius` prop is deprecated and will be removed in a future version. " +
|
|
@@ -98,7 +106,19 @@ className, title, description, enableKeyboardNavigation = BAR_CHART_DEFAULTS.ena
|
|
|
98
106
|
return (jsx("div", { className: cn("chart-container flex items-center justify-center text-[var(--color-text-muted)]", className), role: "img", "aria-label": "Empty bar chart", ...props, children: jsx("span", { children: "No data available" }) }));
|
|
99
107
|
}
|
|
100
108
|
// Simple color functions based on direct CSS variables (following guidelines)
|
|
101
|
-
const getSeriesFillColor = (index) => {
|
|
109
|
+
const getSeriesFillColor = (index, key) => {
|
|
110
|
+
var _a, _b, _c;
|
|
111
|
+
if (key && ((_a = config[key]) === null || _a === void 0 ? void 0 : _a.color)) {
|
|
112
|
+
const customColor = config[key].color;
|
|
113
|
+
if (!customColor.startsWith("var(") &&
|
|
114
|
+
!customColor.startsWith("#") &&
|
|
115
|
+
!customColor.startsWith("rgb") &&
|
|
116
|
+
!customColor.startsWith("hsl") &&
|
|
117
|
+
customColor.includes("-")) {
|
|
118
|
+
return `var(--color-${customColor})`;
|
|
119
|
+
}
|
|
120
|
+
return customColor;
|
|
121
|
+
}
|
|
102
122
|
const defaultColors = [
|
|
103
123
|
"var(--color-primary)",
|
|
104
124
|
"var(--color-warning)",
|
|
@@ -106,11 +126,19 @@ className, title, description, enableKeyboardNavigation = BAR_CHART_DEFAULTS.ena
|
|
|
106
126
|
"var(--color-danger)",
|
|
107
127
|
];
|
|
108
128
|
// Use custom colors if provided, otherwise fall back to defaults
|
|
109
|
-
const
|
|
129
|
+
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;
|
|
130
|
+
const palette = colors && colors.length > 0
|
|
131
|
+
? colors
|
|
132
|
+
: themedColors && themedColors.length > 0
|
|
133
|
+
? themedColors
|
|
134
|
+
: defaultColors;
|
|
110
135
|
return palette[index % palette.length];
|
|
111
136
|
};
|
|
112
137
|
const containerRef = useRef(null);
|
|
113
|
-
|
|
138
|
+
// Bars must not mount before the real container size is known (cold-load bug:
|
|
139
|
+
// motion captures geometry in the 600×400 fallback space, so the entrance
|
|
140
|
+
// animation rises from below the real baseline). `measured` gates the mount.
|
|
141
|
+
const { dimensions, measured } = useChartDimensions(containerRef);
|
|
114
142
|
const [hoveredCategory, setHoveredCategory] = useState(null);
|
|
115
143
|
// Detect if device is mobile/touch
|
|
116
144
|
const isMobile = typeof window !== "undefined" &&
|
|
@@ -129,31 +157,11 @@ className, title, description, enableKeyboardNavigation = BAR_CHART_DEFAULTS.ena
|
|
|
129
157
|
description,
|
|
130
158
|
enableKeyboardNavigation,
|
|
131
159
|
});
|
|
132
|
-
// Measure container dimensions
|
|
133
|
-
useEffect(() => {
|
|
134
|
-
const updateDimensions = () => {
|
|
135
|
-
if (containerRef.current) {
|
|
136
|
-
const { width, height } = containerRef.current.getBoundingClientRect();
|
|
137
|
-
setDimensions({
|
|
138
|
-
width: width || 600,
|
|
139
|
-
height: height || 400,
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
updateDimensions();
|
|
144
|
-
const resizeObserver = new ResizeObserver(updateDimensions);
|
|
145
|
-
if (containerRef.current) {
|
|
146
|
-
resizeObserver.observe(containerRef.current);
|
|
147
|
-
}
|
|
148
|
-
return () => {
|
|
149
|
-
resizeObserver.disconnect();
|
|
150
|
-
};
|
|
151
|
-
}, []);
|
|
152
160
|
// Calculate dimensions with safe math
|
|
153
161
|
const margin = useMemo(() => ({
|
|
154
162
|
top: 15,
|
|
155
163
|
right: showYAxis ? 20 : 0,
|
|
156
|
-
bottom: showXAxis ?
|
|
164
|
+
bottom: showXAxis ? X_AXIS_MARGIN : 0,
|
|
157
165
|
left: showYAxis ? 60 : 0,
|
|
158
166
|
}), [showYAxis, showXAxis]);
|
|
159
167
|
const innerWidth = Math.max(0, dimensions.width - margin.left - margin.right);
|
|
@@ -182,7 +190,7 @@ className, title, description, enableKeyboardNavigation = BAR_CHART_DEFAULTS.ena
|
|
|
182
190
|
const individualBarWidth = safeMath.divide(availableBarWidth, dataKeys.length, 0);
|
|
183
191
|
// Handle keyboard focus tooltips
|
|
184
192
|
useEffect(() => {
|
|
185
|
-
var _a
|
|
193
|
+
var _a;
|
|
186
194
|
if (isKeyboardMode &&
|
|
187
195
|
focusedElementIndex >= 0 &&
|
|
188
196
|
focusedElementIndex < sanitizedData.length) {
|
|
@@ -201,7 +209,7 @@ className, title, description, enableKeyboardNavigation = BAR_CHART_DEFAULTS.ena
|
|
|
201
209
|
const isNeg = value < 0;
|
|
202
210
|
const y = isNeg ? zeroY : zeroY - barHeight;
|
|
203
211
|
// Get the fill color for the first series (index 0)
|
|
204
|
-
const fillColor = getSeriesFillColor(0);
|
|
212
|
+
const fillColor = getSeriesFillColor(0, key);
|
|
205
213
|
const content = {
|
|
206
214
|
category: item.name || `Category ${focusedElementIndex + 1}`,
|
|
207
215
|
series: [
|
|
@@ -209,7 +217,7 @@ className, title, description, enableKeyboardNavigation = BAR_CHART_DEFAULTS.ena
|
|
|
209
217
|
key,
|
|
210
218
|
label: ((_a = config[key]) === null || _a === void 0 ? void 0 : _a.label) || key,
|
|
211
219
|
value: value,
|
|
212
|
-
color:
|
|
220
|
+
color: fillColor,
|
|
213
221
|
},
|
|
214
222
|
],
|
|
215
223
|
};
|
|
@@ -278,11 +286,12 @@ className, title, description, enableKeyboardNavigation = BAR_CHART_DEFAULTS.ena
|
|
|
278
286
|
rawValue === undefined ||
|
|
279
287
|
(typeof rawValue === "number" && !isFinite(rawValue));
|
|
280
288
|
// Get fill color for this data series using direct CSS variables
|
|
281
|
-
const fillColor = getSeriesFillColor(keyIndex);
|
|
289
|
+
const fillColor = getSeriesFillColor(keyIndex, key);
|
|
282
290
|
const isHovered = hoveredCategory === index;
|
|
283
291
|
const isAnyBarHovered = hoveredCategory !== null;
|
|
284
292
|
const shouldReduceOpacity = isAnyBarHovered && !isHovered;
|
|
285
293
|
const isFocused = isKeyboardMode && focusedElementIndex === index;
|
|
294
|
+
const isEmphasized = isHovered || isFocused;
|
|
286
295
|
// Handle null bars - either skip or show placeholder
|
|
287
296
|
if (isNull) {
|
|
288
297
|
if (!showPlaceholderBars) {
|
|
@@ -327,7 +336,7 @@ className, title, description, enableKeyboardNavigation = BAR_CHART_DEFAULTS.ena
|
|
|
327
336
|
}, className: "transition-opacity duration-200", style: {
|
|
328
337
|
originY: 1,
|
|
329
338
|
transformOrigin: "bottom",
|
|
330
|
-
fill:
|
|
339
|
+
fill: `url(#${hatchPatternId})`,
|
|
331
340
|
opacity: 0.75,
|
|
332
341
|
}, "aria-label": `${item.name || `Category ${index + 1}`} - ${((_a = config[key]) === null || _a === void 0 ? void 0 : _a.label) || key}: No data` }, keyIndex));
|
|
333
342
|
}
|
|
@@ -339,122 +348,177 @@ className, title, description, enableKeyboardNavigation = BAR_CHART_DEFAULTS.ena
|
|
|
339
348
|
? createRoundedBottomBarPath(barX, barY, individualBarWidth, barHeight, resolvedBarRadius)
|
|
340
349
|
: createRoundedTopBarPath(barX, barY, individualBarWidth, barHeight, resolvedBarRadius);
|
|
341
350
|
const delay = (index * dataKeys.length + keyIndex) * BAR_STAGGER;
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
351
|
+
const gradientFill = `url(#${getBarGradientId(keyIndex)})`;
|
|
352
|
+
const shadowFilter = `url(#${getBarShadowId(keyIndex)})`;
|
|
353
|
+
const ringFilter = `url(#${getBarRingId(keyIndex)})`;
|
|
354
|
+
const commonInitial = shouldAnimate && showAnimation && !shouldReduceMotion
|
|
355
|
+
? { scaleY: 0, opacity: 0 }
|
|
356
|
+
: { scaleY: 1, opacity: 1 };
|
|
357
|
+
const commonTransition = {
|
|
358
|
+
type: "spring",
|
|
359
|
+
stiffness: 100,
|
|
360
|
+
damping: 20,
|
|
361
|
+
delay,
|
|
362
|
+
// Opacity carries both the mount fade-in and the hover dim. On mount it
|
|
363
|
+
// must wait out the same stagger delay as scaleY — a visible bar at
|
|
364
|
+
// scaleY≈0 renders as a glowing stub straddling the x-axis. After mount
|
|
365
|
+
// (hasAnimated), hover dims must respond with no delay. Motion re-reads
|
|
366
|
+
// this only when the opacity target changes, so the switch is safe.
|
|
367
|
+
opacity: {
|
|
368
|
+
type: "tween",
|
|
369
|
+
duration: 0.25,
|
|
370
|
+
ease: "easeOut",
|
|
371
|
+
delay: hasAnimated ? 0 : delay,
|
|
372
|
+
},
|
|
373
|
+
};
|
|
374
|
+
return (jsxs(React__default.Fragment, { children: [jsx(AnimatePresence, { children: isGradientVariant && isEmphasized && (jsx(motion.path, { d: pathD, initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, transition: {
|
|
375
|
+
opacity: {
|
|
376
|
+
duration: 0.45,
|
|
377
|
+
ease: "easeOut",
|
|
378
|
+
},
|
|
379
|
+
}, fill: "none", stroke: fillColor, strokeWidth: Math.min(14, Math.max(8, individualBarWidth * 0.08)), strokeOpacity: 0.24, strokeLinejoin: "round", vectorEffect: "non-scaling-stroke", filter: ringFilter, style: {
|
|
380
|
+
pointerEvents: "none",
|
|
381
|
+
} })) }), jsx(motion.path, { d: pathD, initial: commonInitial, animate: {
|
|
382
|
+
scaleY: 1,
|
|
383
|
+
// Hover dim lives in `animate`, not `style`: motion.path freezes
|
|
384
|
+
// plain style values at mount and ignores re-render changes
|
|
385
|
+
opacity: shouldReduceOpacity ? (isGradientVariant ? 0.42 : 0.9) : 1,
|
|
386
|
+
}, transition: commonTransition, className: cn(isGradientVariant
|
|
387
|
+
? "transition-all duration-300 ease-out"
|
|
388
|
+
: "transition-colors duration-200", !isNull && "cursor-pointer", isFocused && "stroke-2"), style: {
|
|
389
|
+
originY: isNegative ? 0 : 1,
|
|
390
|
+
transformOrigin: isNegative ? "top" : "bottom",
|
|
391
|
+
fill: isGradientVariant
|
|
392
|
+
? gradientFill
|
|
393
|
+
: isNull
|
|
394
|
+
? "var(--color-surface-sunken)"
|
|
395
|
+
: shouldReduceOpacity
|
|
396
|
+
? "var(--color-surface-sunken)"
|
|
397
|
+
: fillColor,
|
|
398
|
+
// Element opacity applies post-filter, so the animated hover dim
|
|
399
|
+
// fades the shadow along with the bar — no need to toggle it here
|
|
400
|
+
filter: isGradientVariant ? shadowFilter : undefined,
|
|
401
|
+
stroke: isFocused
|
|
402
|
+
? "var(--color-primary)"
|
|
403
|
+
: isGradientVariant && isEmphasized
|
|
404
|
+
? fillColor
|
|
405
|
+
: isGradientVariant
|
|
406
|
+
? "rgba(255,255,255,0.24)"
|
|
407
|
+
: "none",
|
|
408
|
+
strokeWidth: isFocused
|
|
409
|
+
? 3
|
|
410
|
+
: isGradientVariant && isEmphasized
|
|
411
|
+
? 2
|
|
412
|
+
: isGradientVariant
|
|
413
|
+
? 1
|
|
414
|
+
: undefined,
|
|
415
|
+
strokeOpacity: isGradientVariant && isEmphasized ? 0.78 : 1,
|
|
416
|
+
strokeLinejoin: "round",
|
|
417
|
+
vectorEffect: "non-scaling-stroke",
|
|
418
|
+
}, onMouseEnter: !isNull
|
|
419
|
+
? (e) => {
|
|
420
|
+
setHoveredCategory(index);
|
|
421
|
+
// Create content with ALL series for this category
|
|
422
|
+
const series = dataKeys
|
|
423
|
+
.map((dataKey, idx) => {
|
|
424
|
+
var _a;
|
|
425
|
+
const seriesValue = item[dataKey];
|
|
426
|
+
const isSeriesNull = seriesValue === null ||
|
|
427
|
+
seriesValue === undefined ||
|
|
428
|
+
(typeof seriesValue === "number" &&
|
|
429
|
+
!isFinite(seriesValue));
|
|
430
|
+
return {
|
|
431
|
+
key: dataKey,
|
|
432
|
+
label: ((_a = config[dataKey]) === null || _a === void 0 ? void 0 : _a.label) || dataKey,
|
|
433
|
+
value: isSeriesNull ? 0 : seriesValue,
|
|
434
|
+
color: getSeriesFillColor(idx, dataKey),
|
|
435
|
+
};
|
|
436
|
+
})
|
|
437
|
+
.filter((series) => {
|
|
438
|
+
// Only include non-null and non-zero values in tooltip
|
|
439
|
+
const rawVal = item[series.key];
|
|
440
|
+
return (rawVal != null &&
|
|
441
|
+
typeof rawVal === "number" &&
|
|
442
|
+
isFinite(rawVal) &&
|
|
443
|
+
rawVal !== 0);
|
|
444
|
+
});
|
|
445
|
+
const content = {
|
|
446
|
+
category: item.name || `Category ${index + 1}`,
|
|
447
|
+
series,
|
|
448
|
+
};
|
|
449
|
+
const svgCoordinates = {
|
|
450
|
+
x: barX + individualBarWidth / 2,
|
|
451
|
+
y: barY,
|
|
452
|
+
dimensions,
|
|
453
|
+
};
|
|
454
|
+
handleMouseEnter(e, content, svgCoordinates);
|
|
455
|
+
}
|
|
456
|
+
: undefined, onMouseMove: !isNull
|
|
457
|
+
? (e) => {
|
|
458
|
+
if (hoveredCategory === index) {
|
|
459
|
+
const svgCoordinates = {
|
|
460
|
+
x: barX + individualBarWidth / 2,
|
|
461
|
+
y: barY,
|
|
462
|
+
dimensions,
|
|
463
|
+
};
|
|
464
|
+
handleMouseMove(e, svgCoordinates);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
: undefined, onMouseLeave: !isNull
|
|
468
|
+
? () => {
|
|
469
|
+
setHoveredCategory(null);
|
|
470
|
+
handleMouseLeave();
|
|
471
|
+
}
|
|
472
|
+
: undefined })] }, keyIndex));
|
|
417
473
|
};
|
|
418
|
-
return (jsx(ChartErrorBoundary, { className: className, showErrorDetails: process.env.NODE_ENV === "development", children: jsxs("div", { ref: containerRef, className: cn("chart-container w-full h-full", darkMode && "dark", className),
|
|
474
|
+
return (jsx(ChartErrorBoundary, { className: className, showErrorDetails: process.env.NODE_ENV === "development", children: jsxs("div", { ref: containerRef, className: cn("chart-container w-full h-full", darkMode && "dark", className), style: {
|
|
475
|
+
width: width !== undefined ? (typeof width === "number" ? `${width}px` : width) : undefined,
|
|
476
|
+
height: height !== undefined ? (typeof height === "number" ? `${height}px` : height) : undefined,
|
|
477
|
+
}, ...chartAccessibilityProps, onMouseEnter: handleMouseInteraction, onMouseMove: handleMouseInteraction, ...props, children: [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
|
|
419
478
|
.filter((warning) => !warning.message.includes("has no valid numeric values"))
|
|
420
|
-
.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" }) }))] })), jsxs("svg", { width: "100%", height: "100%", viewBox: `0 0 ${dimensions.width} ${dimensions.height}`, children: [
|
|
479
|
+
.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" }) }))] })), 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-neutral-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 &&
|
|
480
|
+
dataKeys.map((key, index) => {
|
|
481
|
+
const color = getSeriesFillColor(index, key);
|
|
482
|
+
return (jsxs(React__default.Fragment, { children: [jsxs("linearGradient", { id: getBarGradientId(index), 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: getBarShadowId(index), x: "-35%", y: "-35%", width: "170%", height: "190%", colorInterpolationFilters: "sRGB", children: jsx("feDropShadow", { dx: "0", dy: "10", stdDeviation: "8", floodColor: color, floodOpacity: "0.22" }) }), jsxs("filter", { id: getBarRingId(index), 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" })] })] }, key));
|
|
483
|
+
})] }), jsx(HorizontalGrid, { show: showGrid, x: margin.left, y: margin.top, width: innerWidth, height: innerHeight, lineCount: 5 }), jsx(YAxis, { show: showYAxis, min: minValue, max: maxValue, x: margin.left, y: margin.top, height: innerHeight, showGrid: false, gridWidth: innerWidth, tickFormatter: (value) => {
|
|
421
484
|
if (Math.abs(value) >= 1000)
|
|
422
485
|
return `${(value / 1000).toFixed(0)}k`;
|
|
423
486
|
return value.toString();
|
|
424
|
-
} }), 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: "chart-bars", children:
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
rawValue ===
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
487
|
+
} }), 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: "chart-bars", children: measured &&
|
|
488
|
+
(() => {
|
|
489
|
+
// Calculate the zero baseline position (where value=0 maps to in pixel space)
|
|
490
|
+
const range = maxValue - minValue;
|
|
491
|
+
const scaledZero = range > 0
|
|
492
|
+
? safeMath.scale(0, minValue, maxValue, 0, innerHeight)
|
|
493
|
+
: 0;
|
|
494
|
+
const zeroY = margin.top + innerHeight - scaledZero;
|
|
495
|
+
return sanitizedData.map((item, index) => {
|
|
496
|
+
const x = margin.left + index * (barWidth + categoryGap);
|
|
497
|
+
return (jsx("g", { children: dataKeys.map((key, keyIndex) => {
|
|
498
|
+
const rawValue = item[key];
|
|
499
|
+
const value = typeof rawValue === "number" && isFinite(rawValue)
|
|
500
|
+
? rawValue
|
|
501
|
+
: 0;
|
|
502
|
+
const isNull = rawValue === null ||
|
|
503
|
+
rawValue === undefined ||
|
|
504
|
+
(typeof rawValue === "number" && !isFinite(rawValue));
|
|
505
|
+
// For null values, use the average of non-null values
|
|
506
|
+
const actualValue = isNull
|
|
507
|
+
? calculateAverageForKey(sanitizedData, key, safeMath.divide)
|
|
508
|
+
: value;
|
|
509
|
+
const scaledValue = range > 0
|
|
510
|
+
? safeMath.scale(actualValue, minValue, maxValue, 0, innerHeight)
|
|
511
|
+
: 0;
|
|
512
|
+
const barHeight = Math.abs(scaledValue - scaledZero);
|
|
513
|
+
const isNeg = actualValue < 0;
|
|
514
|
+
const barX = x + keyIndex * (individualBarWidth + gap);
|
|
515
|
+
// Positive: bar extends upward from zero baseline
|
|
516
|
+
// Negative: bar extends downward from zero baseline
|
|
517
|
+
const barY = isNeg ? zeroY : zeroY - barHeight;
|
|
518
|
+
return renderBarPath(item, index, key, keyIndex, barX, barY, barHeight, true, isNeg);
|
|
519
|
+
}) }, index));
|
|
520
|
+
});
|
|
521
|
+
})() }), jsx(XAxis, { show: showXAxis, data: sanitizedData, x: margin.left, y: margin.top + innerHeight, width: innerWidth, categoryWidth: barWidth, categoryGap: categoryGap })] }), jsx(ChartTooltip, { tooltipRef: tooltipRef, content: tooltipData === null || tooltipData === void 0 ? void 0 : tooltipData.content, active: !!tooltipData, position: tooltipData
|
|
458
522
|
? { x: tooltipData.x, y: tooltipData.y }
|
|
459
523
|
: { x: 0, y: 0 } }), children] }) }));
|
|
460
524
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseChartProps, StandardChartDisplayProps, StandardVisualProps, BarChartSpecificProps } from "../types/chart.types";
|
|
1
|
+
import { BaseChartProps, StandardChartDisplayProps, StandardVisualProps, BarChartSpecificProps, ChartVariant } from "../types/chart.types";
|
|
2
2
|
export interface BarChartProps extends BaseChartProps, StandardChartDisplayProps, StandardVisualProps, BarChartSpecificProps {
|
|
3
3
|
barRadius?: number;
|
|
4
4
|
radius?: number;
|
|
@@ -24,6 +24,7 @@ export interface BarChartProps extends BaseChartProps, StandardChartDisplayProps
|
|
|
24
24
|
darkMode?: boolean;
|
|
25
25
|
}
|
|
26
26
|
export declare const BAR_CHART_DEFAULTS: {
|
|
27
|
+
readonly variant: ChartVariant;
|
|
27
28
|
readonly barRadius: 32;
|
|
28
29
|
readonly radius: 32;
|
|
29
30
|
readonly gap: 4;
|
|
@@ -34,16 +35,15 @@ export declare const BAR_CHART_DEFAULTS: {
|
|
|
34
35
|
readonly showGrid: true;
|
|
35
36
|
readonly showXAxis: true;
|
|
36
37
|
readonly showYAxis: true;
|
|
37
|
-
readonly dotRadius:
|
|
38
|
+
readonly dotRadius: 3;
|
|
38
39
|
readonly cellRadius: 4;
|
|
39
40
|
readonly strokeWidth: 2;
|
|
40
41
|
readonly curved: true;
|
|
41
42
|
readonly curveType: import("..").CurveType;
|
|
42
43
|
readonly fillOpacity: 0.3;
|
|
43
44
|
readonly showStroke: true;
|
|
44
|
-
readonly showDots:
|
|
45
|
+
readonly showDots: false;
|
|
45
46
|
readonly stacked: false;
|
|
46
|
-
readonly variant: import("..").ChartVariant;
|
|
47
47
|
readonly enableKeyboardNavigation: true;
|
|
48
48
|
};
|
|
49
49
|
export type BarChartData = BaseChartProps["data"][0];
|
|
@@ -3,6 +3,7 @@ import { CHART_DEFAULTS } from '../types/chart.types.js';
|
|
|
3
3
|
// Default values using centralized defaults
|
|
4
4
|
const BAR_CHART_DEFAULTS = {
|
|
5
5
|
...CHART_DEFAULTS,
|
|
6
|
+
variant: "gradient", // BarChart defaults to the gradient (premium) look; use variant="default" for flat fills
|
|
6
7
|
barRadius: CHART_DEFAULTS.barRadius, // 24 - For bar corner rounding
|
|
7
8
|
radius: CHART_DEFAULTS.barRadius, // @deprecated - kept for backward compatibility
|
|
8
9
|
gap: CHART_DEFAULTS.gap,
|
|
@@ -29,11 +29,11 @@ export interface ComboChartProps extends BaseChartProps, StandardChartDisplayPro
|
|
|
29
29
|
}
|
|
30
30
|
export declare const COMBO_CHART_DEFAULTS: {
|
|
31
31
|
readonly barRadius: 32;
|
|
32
|
-
readonly dotRadius:
|
|
32
|
+
readonly dotRadius: 3;
|
|
33
33
|
readonly categoryGap: 16;
|
|
34
34
|
readonly curved: true;
|
|
35
35
|
readonly curveType: import("..").CurveType;
|
|
36
|
-
readonly showDots:
|
|
36
|
+
readonly showDots: false;
|
|
37
37
|
readonly showDualAxis: false;
|
|
38
38
|
readonly showGrid: true;
|
|
39
39
|
readonly showXAxis: true;
|