@mantine/charts 9.2.0 → 9.2.1

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.
Files changed (65) hide show
  1. package/cjs/AreaChart/AreaChart.cjs.map +1 -1
  2. package/cjs/AreaChart/AreaGradient.cjs.map +1 -1
  3. package/cjs/AreaChart/AreaSplit.cjs.map +1 -1
  4. package/cjs/AreaChart/get-split-offset.cjs.map +1 -1
  5. package/cjs/BarChart/BarChart.cjs.map +1 -1
  6. package/cjs/BarsList/BarsList.cjs.map +1 -1
  7. package/cjs/BubbleChart/BubbleChart.cjs.map +1 -1
  8. package/cjs/ChartLegend/ChartLegend.cjs +4 -1
  9. package/cjs/ChartLegend/ChartLegend.cjs.map +1 -1
  10. package/cjs/ChartTooltip/ChartTooltip.cjs.map +1 -1
  11. package/cjs/CompositeChart/CompositeChart.cjs.map +1 -1
  12. package/cjs/DonutChart/DonutChart.cjs.map +1 -1
  13. package/cjs/FunnelChart/FunnelChart.cjs.map +1 -1
  14. package/cjs/Heatmap/Heatmap.cjs.map +1 -1
  15. package/cjs/Heatmap/HeatmapSplitWeeks.cjs.map +1 -1
  16. package/cjs/Heatmap/HeatmapWeeks.cjs.map +1 -1
  17. package/cjs/Heatmap/get-boundaries/get-boundaries.cjs.map +1 -1
  18. package/cjs/Heatmap/get-columns/get-columns.cjs.map +1 -1
  19. package/cjs/Heatmap/get-dates-range/get-dates-range.cjs.map +1 -1
  20. package/cjs/Heatmap/get-heat-color/get-heat-color.cjs.map +1 -1
  21. package/cjs/Heatmap/get-months-range/get-months-range.cjs.map +1 -1
  22. package/cjs/Heatmap/rotate-weekdays-names/rotate-weekdays-names.cjs.map +1 -1
  23. package/cjs/LineChart/LineChart.cjs.map +1 -1
  24. package/cjs/PieChart/PieChart.cjs.map +1 -1
  25. package/cjs/PointLabel/PointLabel.cjs.map +1 -1
  26. package/cjs/RadarChart/RadarChart.cjs.map +1 -1
  27. package/cjs/RadialBarChart/RadialBarChart.cjs.map +1 -1
  28. package/cjs/SankeyChart/SankeyChart.cjs.map +1 -1
  29. package/cjs/ScatterChart/ScatterChart.cjs.map +1 -1
  30. package/cjs/Sparkline/Sparkline.cjs.map +1 -1
  31. package/cjs/Treemap/Treemap.cjs.map +1 -1
  32. package/cjs/utils/get-series-labels/get-series-labels.cjs.map +1 -1
  33. package/esm/AreaChart/AreaChart.mjs.map +1 -1
  34. package/esm/AreaChart/AreaGradient.mjs.map +1 -1
  35. package/esm/AreaChart/AreaSplit.mjs.map +1 -1
  36. package/esm/AreaChart/get-split-offset.mjs.map +1 -1
  37. package/esm/BarChart/BarChart.mjs.map +1 -1
  38. package/esm/BarsList/BarsList.mjs.map +1 -1
  39. package/esm/BubbleChart/BubbleChart.mjs.map +1 -1
  40. package/esm/ChartLegend/ChartLegend.mjs +4 -1
  41. package/esm/ChartLegend/ChartLegend.mjs.map +1 -1
  42. package/esm/ChartTooltip/ChartTooltip.mjs.map +1 -1
  43. package/esm/CompositeChart/CompositeChart.mjs.map +1 -1
  44. package/esm/DonutChart/DonutChart.mjs.map +1 -1
  45. package/esm/FunnelChart/FunnelChart.mjs.map +1 -1
  46. package/esm/Heatmap/Heatmap.mjs.map +1 -1
  47. package/esm/Heatmap/HeatmapSplitWeeks.mjs.map +1 -1
  48. package/esm/Heatmap/HeatmapWeeks.mjs.map +1 -1
  49. package/esm/Heatmap/get-boundaries/get-boundaries.mjs.map +1 -1
  50. package/esm/Heatmap/get-columns/get-columns.mjs.map +1 -1
  51. package/esm/Heatmap/get-dates-range/get-dates-range.mjs.map +1 -1
  52. package/esm/Heatmap/get-heat-color/get-heat-color.mjs.map +1 -1
  53. package/esm/Heatmap/get-months-range/get-months-range.mjs.map +1 -1
  54. package/esm/Heatmap/rotate-weekdays-names/rotate-weekdays-names.mjs.map +1 -1
  55. package/esm/LineChart/LineChart.mjs.map +1 -1
  56. package/esm/PieChart/PieChart.mjs.map +1 -1
  57. package/esm/PointLabel/PointLabel.mjs.map +1 -1
  58. package/esm/RadarChart/RadarChart.mjs.map +1 -1
  59. package/esm/RadialBarChart/RadialBarChart.mjs.map +1 -1
  60. package/esm/SankeyChart/SankeyChart.mjs.map +1 -1
  61. package/esm/ScatterChart/ScatterChart.mjs.map +1 -1
  62. package/esm/Sparkline/Sparkline.mjs.map +1 -1
  63. package/esm/Treemap/Treemap.mjs.map +1 -1
  64. package/esm/utils/get-series-labels/get-series-labels.mjs.map +1 -1
  65. package/package.json +5 -5
@@ -1 +1 @@
1
- {"version":3,"file":"Treemap.mjs","names":["Treemap","RechartsTreemap","Tooltip","classes"],"sources":["../../src/Treemap/Treemap.tsx"],"sourcesContent":["import React from 'react';\nimport {\n Treemap as RechartsTreemap,\n TreemapProps as RechartsTreemapProps,\n ResponsiveContainer,\n Tooltip,\n TooltipProps,\n} from 'recharts';\nimport {\n Box,\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n getAutoContrastValue,\n getThemeColor,\n isLightColor,\n MantineColor,\n MantineTheme,\n parseThemeColor,\n rem,\n StylesApiProps,\n useMantineTheme,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '@mantine/core';\nimport { ChartTooltip, ChartTooltipStylesNames } from '../ChartTooltip/ChartTooltip';\nimport classes from './Treemap.module.css';\n\nexport interface TreemapData {\n name: string;\n value?: number;\n color?: MantineColor;\n children?: TreemapData[];\n [key: string]: unknown;\n}\n\nexport type TreemapStylesNames = 'root' | ChartTooltipStylesNames;\nexport type TreemapCssVariables = {\n root: '--chart-stroke-color' | '--chart-height';\n};\n\nexport interface TreemapProps\n extends BoxProps, StylesApiProps<TreemapFactory>, ElementProps<'div'> {\n /** Data used to render chart */\n data: TreemapData[];\n\n /** Key in data object for the value @default 'value' */\n dataKey?: string;\n\n /** The treemap will try to keep every single rectangle's aspect ratio near the aspectRatio given @default 1.618033988749895 */\n aspectRatio?: number;\n\n /** Determines whether the tooltip should be displayed when a node is hovered @default true */\n withTooltip?: boolean;\n\n /** Tooltip animation duration in ms @default 0 */\n tooltipAnimationDuration?: number;\n\n /** Props passed down to `Tooltip` recharts component */\n tooltipProps?: Omit<TooltipProps<any, any>, 'ref'>;\n\n /** Props passed down to recharts `Treemap` component */\n treemapProps?: Partial<Omit<RechartsTreemapProps, 'ref' | 'data' | 'dataKey'>>;\n\n /** Controls color of the node stroke, by default depends on color scheme */\n strokeColor?: MantineColor;\n\n /** Controls text color of labels @default dimmed */\n textColor?: MantineColor;\n\n /** Controls chart height @default 300 */\n height?: number;\n\n /** Controls width of node stroke @default 1 */\n strokeWidth?: number;\n\n /** A function to format values inside the tooltip */\n valueFormatter?: (value: number) => string;\n\n /** Determines whether text color should be adjusted based on background color to improve contrast */\n autoContrast?: boolean;\n\n /** Additional elements rendered inside `Treemap` component */\n children?: React.ReactNode;\n}\n\nexport type TreemapFactory = Factory<{\n props: TreemapProps;\n ref: HTMLDivElement;\n stylesNames: TreemapStylesNames;\n vars: TreemapCssVariables;\n}>;\n\nconst defaultProps = {\n dataKey: 'value',\n withTooltip: true,\n tooltipAnimationDuration: 0,\n height: 300,\n strokeWidth: 1,\n aspectRatio: 0.5 * (1 + Math.sqrt(5)),\n} satisfies Partial<TreemapProps>;\n\nconst varsResolver = createVarsResolver<TreemapFactory>((theme, { strokeColor, height }) => ({\n root: {\n '--chart-stroke-color': strokeColor ? getThemeColor(strokeColor, theme) : undefined,\n '--chart-height': rem(height),\n },\n}));\n\ninterface TreemapContentProps {\n x: number;\n y: number;\n width: number;\n height: number;\n depth: number;\n name: string;\n resolvedColors: Record<string, string>;\n resolvedLabelColors: Record<string, string>;\n index: number;\n strokeWidth: number;\n}\n\nfunction TreemapContent({\n x,\n y,\n width,\n height,\n depth,\n name,\n resolvedColors,\n resolvedLabelColors,\n index,\n strokeWidth,\n}: TreemapContentProps) {\n const fill = resolvedColors[name] || `var(--mantine-color-blue-${(index % 9) + 1})`;\n const labelColor = resolvedLabelColors[name] || 'var(--mantine-color-white)';\n const showLabel = width > 30 && height > 20;\n\n return (\n <g>\n <rect\n x={x}\n y={y}\n width={width}\n height={height}\n fill={depth >= 1 ? fill : 'transparent'}\n stroke=\"var(--chart-stroke-color, var(--mantine-color-body))\"\n strokeWidth={depth >= 1 ? strokeWidth : 0}\n />\n {depth >= 1 && showLabel && (\n <text\n x={x + width / 2}\n y={y + height / 2}\n textAnchor=\"middle\"\n dominantBaseline=\"central\"\n fill={labelColor}\n fontSize={12}\n fontFamily=\"var(--mantine-font-family)\"\n >\n {name}\n </text>\n )}\n </g>\n );\n}\n\nfunction resolveColors(\n data: TreemapData[],\n theme: MantineTheme,\n parentColor?: string\n): Record<string, string> {\n const result: Record<string, string> = {};\n for (const item of data) {\n const color = item.color || parentColor;\n if (color) {\n result[item.name] = parseThemeColor({ color, theme }).value;\n }\n if (item.children) {\n Object.assign(result, resolveColors(item.children, theme, color));\n }\n }\n return result;\n}\n\nfunction resolveLabelColors(\n resolvedColors: Record<string, string>,\n autoContrast: boolean,\n luminanceThreshold: number,\n textColor?: string\n): Record<string, string> {\n const result: Record<string, string> = {};\n for (const [name, color] of Object.entries(resolvedColors)) {\n if (textColor) {\n result[name] = textColor;\n } else if (autoContrast) {\n result[name] = isLightColor(color, luminanceThreshold)\n ? 'var(--mantine-color-black)'\n : 'var(--mantine-color-white)';\n }\n }\n return result;\n}\n\nexport const Treemap = factory<TreemapFactory>((_props) => {\n const props = useProps('Treemap', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n data,\n dataKey,\n aspectRatio,\n withTooltip,\n tooltipAnimationDuration,\n tooltipProps,\n treemapProps,\n strokeColor,\n textColor,\n height: chartHeight,\n strokeWidth,\n valueFormatter,\n autoContrast,\n children,\n attributes,\n ...others\n } = props;\n\n const theme = useMantineTheme();\n const resolvedColors = resolveColors(data, theme);\n const _autoContrast = getAutoContrastValue(autoContrast, theme);\n const _textColor = textColor ? getThemeColor(textColor, theme) : undefined;\n const resolvedLabelColors = resolveLabelColors(\n resolvedColors,\n _autoContrast,\n theme.luminanceThreshold,\n _textColor\n );\n\n const getStyles = useStyles<TreemapFactory>({\n name: 'Treemap',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<TreemapFactory>({\n classNames,\n styles,\n props,\n });\n\n return (\n <Box {...getStyles('root')} {...others}>\n <ResponsiveContainer height={chartHeight}>\n <RechartsTreemap\n data={data as any}\n dataKey={dataKey as any}\n aspectRatio={aspectRatio}\n isAnimationActive={false}\n content={(nodeProps: any) => (\n <TreemapContent\n {...nodeProps}\n resolvedColors={resolvedColors}\n resolvedLabelColors={resolvedLabelColors}\n strokeWidth={strokeWidth!}\n />\n )}\n {...treemapProps}\n >\n {withTooltip && (\n <Tooltip\n animationDuration={tooltipAnimationDuration}\n isAnimationActive={false}\n content={({ payload }) => (\n <ChartTooltip\n payload={\n payload?.map((item) => ({\n name: item.name as string,\n value: item.value as number,\n color: resolvedColors[item.name as string] || 'var(--mantine-color-blue-6)',\n })) || []\n }\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n type=\"radial\"\n valueFormatter={valueFormatter}\n attributes={attributes}\n />\n )}\n {...tooltipProps}\n />\n )}\n\n {children}\n </RechartsTreemap>\n </ResponsiveContainer>\n </Box>\n );\n});\n\nTreemap.displayName = '@mantine/charts/Treemap';\nTreemap.classes = classes;\nTreemap.varsResolver = varsResolver;\n"],"mappings":";;;;;;;;AAgGA,MAAM,eAAe;CACnB,SAAS;CACT,aAAa;CACb,0BAA0B;CAC1B,QAAQ;CACR,aAAa;CACb,aAAa,MAAO,IAAI,KAAK,KAAK,EAAE;CACrC;AAED,MAAM,eAAe,oBAAoC,OAAO,EAAE,aAAa,cAAc,EAC3F,MAAM;CACJ,wBAAwB,cAAc,cAAc,aAAa,MAAM,GAAG,KAAA;CAC1E,kBAAkB,IAAI,OAAO;CAC9B,EACF,EAAE;AAeH,SAAS,eAAe,EACtB,GACA,GACA,OACA,QACA,O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CAC/B,MAAM,iBAAiB,cAAc,MAAM,MAAM;CACjD,MAAM,gBAAgB,qBAAqB,cAAc,MAAM;CAC/D,MAAM,aAAa,YAAY,cAAc,WAAW,MAAM,GAAG,KAAA;CACjE,MAAM,sBAAsB,mBAC1B,gBACA,eACA,MAAM,oBACN,WACD;CAED,MAAM,YAAY,UAA0B;EAC1C,MAAM;EACN,SAAA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;CAEF,MAAM,EAAE,oBAAoB,mBAAmB,qBAAqC;EAClF;EACA;EACA;EACD,CAAC;AAEF,QACE,oBAAC,KAAD;EAAK,GAAI,UAAU,OAAO;EAAE,GAAI;YAC9B,oBAAC,qBAAD;GAAqB,QAAQ;aAC3B,qBAACC,SAAD;IACQ;IACG;IACI;IACb,mBAAmB;IACnB,UAAU,cACR,oBAAC,gBAAD;KACE,GAAI;KACY;KACK;KACR;KACb,CAAA;IAEJ,GAAI;cAbN,CAeG,eACC,oBAACC,WAAD;KACE,mBAAmB;KACnB,mBAAmB;KACnB,UAAU,EAAE,cACV,oBAAC,cAAD;MACE,SACE,SAAS,KAAK,UAAU;OACtB,MAAM,KAAK;OACX,OAAO,KAAK;OACZ,OAAO,eAAe,KAAK,SAAmB;OAC/C,EAAE,IAAI,EAAE;MAEX,YAAY;MACZ,QAAQ;MACR,MAAK;MACW;MACJ;MACZ,CAAA;KAEJ,GAAI;KACJ,CAAA,EAGH,SACe;;GACE,CAAA;EAClB,CAAA;EAER;AAEF,UAAQ,cAAc;AACtB,UAAQ,UAAUC;AAClB,UAAQ,eAAe"}
1
+ {"version":3,"file":"Treemap.mjs","names":["Treemap","RechartsTreemap","Tooltip","classes"],"sources":["../../src/Treemap/Treemap.tsx"],"sourcesContent":["import React from 'react';\nimport {\n Treemap as RechartsTreemap,\n TreemapProps as RechartsTreemapProps,\n ResponsiveContainer,\n Tooltip,\n TooltipProps,\n} from 'recharts';\nimport {\n Box,\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n getAutoContrastValue,\n getThemeColor,\n isLightColor,\n MantineColor,\n MantineTheme,\n parseThemeColor,\n rem,\n StylesApiProps,\n useMantineTheme,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '@mantine/core';\nimport { ChartTooltip, ChartTooltipStylesNames } from '../ChartTooltip/ChartTooltip';\nimport classes from './Treemap.module.css';\n\nexport interface TreemapData {\n name: string;\n value?: number;\n color?: MantineColor;\n children?: TreemapData[];\n [key: string]: unknown;\n}\n\nexport type TreemapStylesNames = 'root' | ChartTooltipStylesNames;\nexport type TreemapCssVariables = {\n root: '--chart-stroke-color' | '--chart-height';\n};\n\nexport interface TreemapProps\n extends BoxProps, StylesApiProps<TreemapFactory>, ElementProps<'div'> {\n /** Data used to render chart */\n data: TreemapData[];\n\n /** Key in data object for the value @default 'value' */\n dataKey?: string;\n\n /** The treemap will try to keep every single rectangle's aspect ratio near the aspectRatio given @default 1.618033988749895 */\n aspectRatio?: number;\n\n /** Determines whether the tooltip should be displayed when a node is hovered @default true */\n withTooltip?: boolean;\n\n /** Tooltip animation duration in ms @default 0 */\n tooltipAnimationDuration?: number;\n\n /** Props passed down to `Tooltip` recharts component */\n tooltipProps?: Omit<TooltipProps<any, any>, 'ref'>;\n\n /** Props passed down to recharts `Treemap` component */\n treemapProps?: Partial<Omit<RechartsTreemapProps, 'ref' | 'data' | 'dataKey'>>;\n\n /** Controls color of the node stroke, by default depends on color scheme */\n strokeColor?: MantineColor;\n\n /** Controls text color of labels @default dimmed */\n textColor?: MantineColor;\n\n /** Controls chart height @default 300 */\n height?: number;\n\n /** Controls width of node stroke @default 1 */\n strokeWidth?: number;\n\n /** A function to format values inside the tooltip */\n valueFormatter?: (value: number) => string;\n\n /** Determines whether text color should be adjusted based on background color to improve contrast */\n autoContrast?: boolean;\n\n /** Additional elements rendered inside `Treemap` component */\n children?: React.ReactNode;\n}\n\nexport type TreemapFactory = Factory<{\n props: TreemapProps;\n ref: HTMLDivElement;\n stylesNames: TreemapStylesNames;\n vars: TreemapCssVariables;\n}>;\n\nconst defaultProps = {\n dataKey: 'value',\n withTooltip: true,\n tooltipAnimationDuration: 0,\n height: 300,\n strokeWidth: 1,\n aspectRatio: 0.5 * (1 + Math.sqrt(5)),\n} satisfies Partial<TreemapProps>;\n\nconst varsResolver = createVarsResolver<TreemapFactory>((theme, { strokeColor, height }) => ({\n root: {\n '--chart-stroke-color': strokeColor ? getThemeColor(strokeColor, theme) : undefined,\n '--chart-height': rem(height),\n },\n}));\n\ninterface TreemapContentProps {\n x: number;\n y: number;\n width: number;\n height: number;\n depth: number;\n name: string;\n resolvedColors: Record<string, string>;\n resolvedLabelColors: Record<string, string>;\n index: number;\n strokeWidth: number;\n}\n\nfunction TreemapContent({\n x,\n y,\n width,\n height,\n depth,\n name,\n resolvedColors,\n resolvedLabelColors,\n index,\n strokeWidth,\n}: TreemapContentProps) {\n const fill = resolvedColors[name] || `var(--mantine-color-blue-${(index % 9) + 1})`;\n const labelColor = resolvedLabelColors[name] || 'var(--mantine-color-white)';\n const showLabel = width > 30 && height > 20;\n\n return (\n <g>\n <rect\n x={x}\n y={y}\n width={width}\n height={height}\n fill={depth >= 1 ? fill : 'transparent'}\n stroke=\"var(--chart-stroke-color, var(--mantine-color-body))\"\n strokeWidth={depth >= 1 ? strokeWidth : 0}\n />\n {depth >= 1 && showLabel && (\n <text\n x={x + width / 2}\n y={y + height / 2}\n textAnchor=\"middle\"\n dominantBaseline=\"central\"\n fill={labelColor}\n fontSize={12}\n fontFamily=\"var(--mantine-font-family)\"\n >\n {name}\n </text>\n )}\n </g>\n );\n}\n\nfunction resolveColors(\n data: TreemapData[],\n theme: MantineTheme,\n parentColor?: string\n): Record<string, string> {\n const result: Record<string, string> = {};\n for (const item of data) {\n const color = item.color || parentColor;\n if (color) {\n result[item.name] = parseThemeColor({ color, theme }).value;\n }\n if (item.children) {\n Object.assign(result, resolveColors(item.children, theme, color));\n }\n }\n return result;\n}\n\nfunction resolveLabelColors(\n resolvedColors: Record<string, string>,\n autoContrast: boolean,\n luminanceThreshold: number,\n textColor?: string\n): Record<string, string> {\n const result: Record<string, string> = {};\n for (const [name, color] of Object.entries(resolvedColors)) {\n if (textColor) {\n result[name] = textColor;\n } else if (autoContrast) {\n result[name] = isLightColor(color, luminanceThreshold)\n ? 'var(--mantine-color-black)'\n : 'var(--mantine-color-white)';\n }\n }\n return result;\n}\n\nexport const Treemap = factory<TreemapFactory>((_props) => {\n const props = useProps('Treemap', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n data,\n dataKey,\n aspectRatio,\n withTooltip,\n tooltipAnimationDuration,\n tooltipProps,\n treemapProps,\n strokeColor,\n textColor,\n height: chartHeight,\n strokeWidth,\n valueFormatter,\n autoContrast,\n children,\n attributes,\n ...others\n } = props;\n\n const theme = useMantineTheme();\n const resolvedColors = resolveColors(data, theme);\n const _autoContrast = getAutoContrastValue(autoContrast, theme);\n const _textColor = textColor ? getThemeColor(textColor, theme) : undefined;\n const resolvedLabelColors = resolveLabelColors(\n resolvedColors,\n _autoContrast,\n theme.luminanceThreshold,\n _textColor\n );\n\n const getStyles = useStyles<TreemapFactory>({\n name: 'Treemap',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<TreemapFactory>({\n classNames,\n styles,\n props,\n });\n\n return (\n <Box {...getStyles('root')} {...others}>\n <ResponsiveContainer height={chartHeight}>\n <RechartsTreemap\n data={data as any}\n dataKey={dataKey as any}\n aspectRatio={aspectRatio}\n isAnimationActive={false}\n content={(nodeProps: any) => (\n <TreemapContent\n {...nodeProps}\n resolvedColors={resolvedColors}\n resolvedLabelColors={resolvedLabelColors}\n strokeWidth={strokeWidth!}\n />\n )}\n {...treemapProps}\n >\n {withTooltip && (\n <Tooltip\n animationDuration={tooltipAnimationDuration}\n isAnimationActive={false}\n content={({ payload }) => (\n <ChartTooltip\n payload={\n payload?.map((item) => ({\n name: item.name as string,\n value: item.value as number,\n color: resolvedColors[item.name as string] || 'var(--mantine-color-blue-6)',\n })) || []\n }\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n type=\"radial\"\n valueFormatter={valueFormatter}\n attributes={attributes}\n />\n )}\n {...tooltipProps}\n />\n )}\n\n {children}\n </RechartsTreemap>\n </ResponsiveContainer>\n </Box>\n );\n});\n\nTreemap.displayName = '@mantine/charts/Treemap';\nTreemap.classes = classes;\nTreemap.varsResolver = varsResolver;\n"],"mappings":";;;;;;;;AAgGA,MAAM,eAAe;CACnB,SAAS;CACT,aAAa;CACb,0BAA0B;CAC1B,QAAQ;CACR,aAAa;CACb,aAAa,MAAO,IAAI,KAAK,KAAK,CAAC;AACrC;AAEA,MAAM,eAAe,oBAAoC,OAAO,EAAE,aAAa,cAAc,EAC3F,MAAM;CACJ,wBAAwB,cAAc,cAAc,aAAa,KAAK,IAAI,KAAA;CAC1E,kBAAkB,IAAI,MAAM;AAC9B,EACF,EAAE;AAeF,SAAS,eAAe,EACtB,GACA,GACA,OACA,QACA,OACA,MACA,gBACA,qBACA,OACA,eACsB;CACtB,MAAM,OAAO,eAAe,SAAS,4BAA6B,QAAQ,IAAK,EAAE;CACjF,MAAM,aAAa,oBAAoB,SAAS;CAGhD,OACE,qBAAC,KAAD,EAAA,UAAA,CACE,oBAAC,QAAD;EACK;EACA;EACI;EACC;EACR,MAAM,SAAS,IAAI,OAAO;EAC1B,QAAO;EACP,aAAa,SAAS,IAAI,cAAc;CACzC,CAAA,GACA,SAAS,KAbI,QAAQ,MAAM,SAAS,MAcnC,oBAAC,QAAD;EACE,GAAG,IAAI,QAAQ;EACf,GAAG,IAAI,SAAS;EAChB,YAAW;EACX,kBAAiB;EACjB,MAAM;EACN,UAAU;EACV,YAAW;YAEV;CACG,CAAA,CAEP,EAAA,CAAA;AAEP;AAEA,SAAS,cACP,MACA,OACA,aACwB;CACxB,MAAM,SAAiC,CAAC;CACxC,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,oBAAC,gBAAD;KACE,GAAI;KACY;KACK;KACR;IACd,CAAA;IAEH,GAAI;cAbN,CAeG,eACC,oBAACC,WAAD;KACE,mBAAmB;KACnB,mBAAmB;KACnB,UAAU,EAAE,cACV,oBAAC,cAAD;MACE,SACE,SAAS,KAAK,UAAU;OACtB,MAAM,KAAK;OACX,OAAO,KAAK;OACZ,OAAO,eAAe,KAAK,SAAmB;MAChD,EAAE,KAAK,CAAC;MAEV,YAAY;MACZ,QAAQ;MACR,MAAK;MACW;MACJ;KACb,CAAA;KAEH,GAAI;IACL,CAAA,GAGF,QACc;;EACE,CAAA;CAClB,CAAA;AAET,CAAC;AAED,UAAQ,cAAc;AACtB,UAAQ,UAAUC;AAClB,UAAQ,eAAe"}
@@ -1 +1 @@
1
- {"version":3,"file":"get-series-labels.mjs","names":[],"sources":["../../../src/utils/get-series-labels/get-series-labels.ts"],"sourcesContent":["import { ChartSeries } from '../../types';\n\ntype ChartSeriesLabels = Record<string, string | undefined>;\n\nexport function getSeriesLabels(series: ChartSeries[] | undefined): ChartSeriesLabels {\n if (!series) {\n return {};\n }\n\n return series.reduce<ChartSeriesLabels>((acc, item) => {\n const matchFound = item.name.search(/\\./);\n if (matchFound >= 0) {\n const key = item.name.substring(matchFound + 1);\n acc[key] = item.label;\n return acc;\n }\n acc[item.name] = item.label;\n return acc;\n }, {});\n}\n"],"mappings":";;AAIA,SAAgB,gBAAgB,QAAsD;AACpF,KAAI,CAAC,OACH,QAAO,EAAE;AAGX,QAAO,OAAO,QAA2B,KAAK,SAAS;EACrD,MAAM,aAAa,KAAK,KAAK,OAAO,KAAK;AACzC,MAAI,cAAc,GAAG;GACnB,MAAM,MAAM,KAAK,KAAK,UAAU,aAAa,EAAE;AAC/C,OAAI,OAAO,KAAK;AAChB,UAAO;;AAET,MAAI,KAAK,QAAQ,KAAK;AACtB,SAAO;IACN,EAAE,CAAC"}
1
+ {"version":3,"file":"get-series-labels.mjs","names":[],"sources":["../../../src/utils/get-series-labels/get-series-labels.ts"],"sourcesContent":["import { ChartSeries } from '../../types';\n\ntype ChartSeriesLabels = Record<string, string | undefined>;\n\nexport function getSeriesLabels(series: ChartSeries[] | undefined): ChartSeriesLabels {\n if (!series) {\n return {};\n }\n\n return series.reduce<ChartSeriesLabels>((acc, item) => {\n const matchFound = item.name.search(/\\./);\n if (matchFound >= 0) {\n const key = item.name.substring(matchFound + 1);\n acc[key] = item.label;\n return acc;\n }\n acc[item.name] = item.label;\n return acc;\n }, {});\n}\n"],"mappings":";;AAIA,SAAgB,gBAAgB,QAAsD;CACpF,IAAI,CAAC,QACH,OAAO,CAAC;CAGV,OAAO,OAAO,QAA2B,KAAK,SAAS;EACrD,MAAM,aAAa,KAAK,KAAK,OAAO,IAAI;EACxC,IAAI,cAAc,GAAG;GACnB,MAAM,MAAM,KAAK,KAAK,UAAU,aAAa,CAAC;GAC9C,IAAI,OAAO,KAAK;GAChB,OAAO;EACT;EACA,IAAI,KAAK,QAAQ,KAAK;EACtB,OAAO;CACT,GAAG,CAAC,CAAC;AACP"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mantine/charts",
3
- "version": "9.2.0",
3
+ "version": "9.2.1",
4
4
  "description": "Charts components built with recharts and Mantine",
5
5
  "homepage": "https://mantine.dev/",
6
6
  "license": "MIT",
@@ -35,8 +35,8 @@
35
35
  "directory": "packages/@mantine/charts"
36
36
  },
37
37
  "peerDependencies": {
38
- "@mantine/core": "9.2.0",
39
- "@mantine/hooks": "9.2.0",
38
+ "@mantine/core": "9.2.1",
39
+ "@mantine/hooks": "9.2.1",
40
40
  "react": "^19.2.0",
41
41
  "react-dom": "^19.2.0",
42
42
  "recharts": ">=3.2.1"
@@ -45,7 +45,7 @@
45
45
  "@mantine-tests/core": "workspace:*",
46
46
  "@mantine/core": "workspace:*",
47
47
  "@mantine/hooks": "workspace:*",
48
- "react": "19.2.5",
49
- "react-dom": "19.2.5"
48
+ "react": "19.2.6",
49
+ "react-dom": "19.2.6"
50
50
  }
51
51
  }