@mantine/charts 9.5.2 → 9.6.0

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 (151) hide show
  1. package/cjs/AreaChart/AreaChart.cjs +49 -11
  2. package/cjs/AreaChart/AreaChart.cjs.map +1 -1
  3. package/cjs/AreaChart/AreaGradient.cjs.map +1 -1
  4. package/cjs/AreaChart/AreaSplit.cjs.map +1 -1
  5. package/cjs/BarChart/BarChart.cjs +44 -6
  6. package/cjs/BarChart/BarChart.cjs.map +1 -1
  7. package/cjs/BarsList/BarsList.cjs.map +1 -1
  8. package/cjs/BubbleChart/BubbleChart.cjs.map +1 -1
  9. package/cjs/BulletChart/BulletChart.cjs +7 -5
  10. package/cjs/BulletChart/BulletChart.cjs.map +1 -1
  11. package/cjs/CandlestickChart/CandlestickChart.cjs +340 -0
  12. package/cjs/CandlestickChart/CandlestickChart.cjs.map +1 -0
  13. package/cjs/CandlestickChart/get-candle-geometry/get-candle-geometry.cjs +30 -0
  14. package/cjs/CandlestickChart/get-candle-geometry/get-candle-geometry.cjs.map +1 -0
  15. package/cjs/CandlestickChart/get-candlestick-domain/get-candlestick-domain.cjs +40 -0
  16. package/cjs/CandlestickChart/get-candlestick-domain/get-candlestick-domain.cjs.map +1 -0
  17. package/cjs/ChartBrush/ChartBrush.cjs.map +1 -1
  18. package/cjs/ChartLegend/ChartLegend.cjs.map +1 -1
  19. package/cjs/ChartTooltip/ChartTooltip.cjs.map +1 -1
  20. package/cjs/CompositeChart/CompositeChart.cjs +44 -6
  21. package/cjs/CompositeChart/CompositeChart.cjs.map +1 -1
  22. package/cjs/DonutChart/DonutChart.cjs.map +1 -1
  23. package/cjs/FunnelChart/FunnelChart.cjs.map +1 -1
  24. package/cjs/GaugeChart/GaugeChart.cjs +208 -0
  25. package/cjs/GaugeChart/GaugeChart.cjs.map +1 -0
  26. package/cjs/GaugeChart/GaugeChart.module.cjs +10 -0
  27. package/cjs/GaugeChart/GaugeChart.module.cjs.map +1 -0
  28. package/cjs/Heatmap/Heatmap.cjs +5 -2
  29. package/cjs/Heatmap/Heatmap.cjs.map +1 -1
  30. package/cjs/Heatmap/HeatmapSplitWeeks.cjs +2 -1
  31. package/cjs/Heatmap/HeatmapSplitWeeks.cjs.map +1 -1
  32. package/cjs/Heatmap/HeatmapWeeks.cjs.map +1 -1
  33. package/cjs/LineChart/LineChart.cjs +44 -6
  34. package/cjs/LineChart/LineChart.cjs.map +1 -1
  35. package/cjs/MatrixChart/MatrixChart.cjs +211 -0
  36. package/cjs/MatrixChart/MatrixChart.cjs.map +1 -0
  37. package/cjs/MatrixChart/MatrixChart.module.cjs +14 -0
  38. package/cjs/MatrixChart/MatrixChart.module.cjs.map +1 -0
  39. package/cjs/MatrixChart/build-cell-map/build-cell-map.cjs +17 -0
  40. package/cjs/MatrixChart/build-cell-map/build-cell-map.cjs.map +1 -0
  41. package/cjs/MatrixChart/get-domain/get-domain.cjs +28 -0
  42. package/cjs/MatrixChart/get-domain/get-domain.cjs.map +1 -0
  43. package/cjs/MatrixChart/get-legend-width/get-legend-width.cjs +15 -0
  44. package/cjs/MatrixChart/get-legend-width/get-legend-width.cjs.map +1 -0
  45. package/cjs/MatrixChart/get-unique-values/get-unique-values.cjs +19 -0
  46. package/cjs/MatrixChart/get-unique-values/get-unique-values.cjs.map +1 -0
  47. package/cjs/PieChart/PieChart.cjs +2 -1
  48. package/cjs/PieChart/PieChart.cjs.map +1 -1
  49. package/cjs/PointLabel/PointLabel.cjs.map +1 -1
  50. package/cjs/RadarChart/RadarChart.cjs.map +1 -1
  51. package/cjs/RadialBarChart/RadialBarChart.cjs.map +1 -1
  52. package/cjs/SankeyChart/SankeyChart.cjs.map +1 -1
  53. package/cjs/ScatterChart/ScatterChart.cjs +43 -7
  54. package/cjs/ScatterChart/ScatterChart.cjs.map +1 -1
  55. package/cjs/Sparkline/Sparkline.cjs.map +1 -1
  56. package/cjs/SunburstChart/SunburstChart.cjs.map +1 -1
  57. package/cjs/Treemap/Treemap.cjs.map +1 -1
  58. package/cjs/WaffleChart/WaffleChart.cjs +189 -0
  59. package/cjs/WaffleChart/WaffleChart.cjs.map +1 -0
  60. package/cjs/WaffleChart/WaffleChart.module.cjs +14 -0
  61. package/cjs/WaffleChart/WaffleChart.module.cjs.map +1 -0
  62. package/cjs/_virtual/_rolldown/runtime.cjs +1 -1
  63. package/cjs/index.cjs +8 -0
  64. package/cjs/utils/get-pie-chart-data/get-pie-chart-data.cjs.map +1 -1
  65. package/esm/AreaChart/AreaChart.mjs +50 -12
  66. package/esm/AreaChart/AreaChart.mjs.map +1 -1
  67. package/esm/AreaChart/AreaGradient.mjs.map +1 -1
  68. package/esm/AreaChart/AreaSplit.mjs.map +1 -1
  69. package/esm/BarChart/BarChart.mjs +45 -7
  70. package/esm/BarChart/BarChart.mjs.map +1 -1
  71. package/esm/BarsList/BarsList.mjs.map +1 -1
  72. package/esm/BubbleChart/BubbleChart.mjs.map +1 -1
  73. package/esm/BulletChart/BulletChart.mjs +7 -5
  74. package/esm/BulletChart/BulletChart.mjs.map +1 -1
  75. package/esm/CandlestickChart/CandlestickChart.mjs +340 -0
  76. package/esm/CandlestickChart/CandlestickChart.mjs.map +1 -0
  77. package/esm/CandlestickChart/get-candle-geometry/get-candle-geometry.mjs +30 -0
  78. package/esm/CandlestickChart/get-candle-geometry/get-candle-geometry.mjs.map +1 -0
  79. package/esm/CandlestickChart/get-candlestick-domain/get-candlestick-domain.mjs +39 -0
  80. package/esm/CandlestickChart/get-candlestick-domain/get-candlestick-domain.mjs.map +1 -0
  81. package/esm/ChartLegend/ChartLegend.mjs.map +1 -1
  82. package/esm/ChartTooltip/ChartTooltip.mjs.map +1 -1
  83. package/esm/CompositeChart/CompositeChart.mjs +45 -7
  84. package/esm/CompositeChart/CompositeChart.mjs.map +1 -1
  85. package/esm/DonutChart/DonutChart.mjs.map +1 -1
  86. package/esm/FunnelChart/FunnelChart.mjs.map +1 -1
  87. package/esm/GaugeChart/GaugeChart.mjs +208 -0
  88. package/esm/GaugeChart/GaugeChart.mjs.map +1 -0
  89. package/esm/GaugeChart/GaugeChart.module.mjs +10 -0
  90. package/esm/GaugeChart/GaugeChart.module.mjs.map +1 -0
  91. package/esm/Heatmap/Heatmap.mjs +5 -2
  92. package/esm/Heatmap/Heatmap.mjs.map +1 -1
  93. package/esm/Heatmap/HeatmapSplitWeeks.mjs +2 -1
  94. package/esm/Heatmap/HeatmapSplitWeeks.mjs.map +1 -1
  95. package/esm/Heatmap/HeatmapWeeks.mjs.map +1 -1
  96. package/esm/LineChart/LineChart.mjs +45 -7
  97. package/esm/LineChart/LineChart.mjs.map +1 -1
  98. package/esm/MatrixChart/MatrixChart.mjs +211 -0
  99. package/esm/MatrixChart/MatrixChart.mjs.map +1 -0
  100. package/esm/MatrixChart/MatrixChart.module.mjs +14 -0
  101. package/esm/MatrixChart/MatrixChart.module.mjs.map +1 -0
  102. package/esm/MatrixChart/build-cell-map/build-cell-map.mjs +16 -0
  103. package/esm/MatrixChart/build-cell-map/build-cell-map.mjs.map +1 -0
  104. package/esm/MatrixChart/get-domain/get-domain.mjs +28 -0
  105. package/esm/MatrixChart/get-domain/get-domain.mjs.map +1 -0
  106. package/esm/MatrixChart/get-legend-width/get-legend-width.mjs +15 -0
  107. package/esm/MatrixChart/get-legend-width/get-legend-width.mjs.map +1 -0
  108. package/esm/MatrixChart/get-unique-values/get-unique-values.mjs +19 -0
  109. package/esm/MatrixChart/get-unique-values/get-unique-values.mjs.map +1 -0
  110. package/esm/PieChart/PieChart.mjs +2 -1
  111. package/esm/PieChart/PieChart.mjs.map +1 -1
  112. package/esm/PointLabel/PointLabel.mjs.map +1 -1
  113. package/esm/RadarChart/RadarChart.mjs.map +1 -1
  114. package/esm/RadialBarChart/RadialBarChart.mjs.map +1 -1
  115. package/esm/SankeyChart/SankeyChart.mjs.map +1 -1
  116. package/esm/ScatterChart/ScatterChart.mjs +44 -8
  117. package/esm/ScatterChart/ScatterChart.mjs.map +1 -1
  118. package/esm/Sparkline/Sparkline.mjs.map +1 -1
  119. package/esm/SunburstChart/SunburstChart.mjs.map +1 -1
  120. package/esm/Treemap/Treemap.mjs.map +1 -1
  121. package/esm/WaffleChart/WaffleChart.mjs +189 -0
  122. package/esm/WaffleChart/WaffleChart.mjs.map +1 -0
  123. package/esm/WaffleChart/WaffleChart.module.mjs +14 -0
  124. package/esm/WaffleChart/WaffleChart.module.mjs.map +1 -0
  125. package/esm/index.mjs +5 -1
  126. package/lib/AreaChart/AreaChart.d.ts +7 -3
  127. package/lib/AreaChart/AreaGradient.d.ts +1 -1
  128. package/lib/AreaChart/AreaSplit.d.ts +1 -1
  129. package/lib/CandlestickChart/CandlestickChart.d.ts +68 -0
  130. package/lib/CandlestickChart/get-candle-geometry/get-candle-geometry.d.ts +30 -0
  131. package/lib/CandlestickChart/get-candlestick-domain/get-candlestick-domain.d.ts +21 -0
  132. package/lib/CandlestickChart/index.d.ts +3 -0
  133. package/lib/GaugeChart/GaugeChart.d.ts +57 -0
  134. package/lib/GaugeChart/index.d.ts +10 -0
  135. package/lib/Heatmap/HeatmapSplitWeeks.d.ts +1 -1
  136. package/lib/Heatmap/HeatmapWeeks.d.ts +1 -1
  137. package/lib/MatrixChart/MatrixChart.d.ts +64 -0
  138. package/lib/MatrixChart/build-cell-map/build-cell-map.d.ts +3 -0
  139. package/lib/MatrixChart/get-domain/get-domain.d.ts +10 -0
  140. package/lib/MatrixChart/get-legend-width/get-legend-width.d.ts +9 -0
  141. package/lib/MatrixChart/get-unique-values/get-unique-values.d.ts +2 -0
  142. package/lib/MatrixChart/index.d.ts +8 -0
  143. package/lib/PointLabel/PointLabel.d.ts +1 -1
  144. package/lib/WaffleChart/WaffleChart.d.ts +57 -0
  145. package/lib/WaffleChart/index.d.ts +10 -0
  146. package/lib/index.d.mts +4 -0
  147. package/lib/index.d.ts +4 -0
  148. package/lib/types.d.ts +16 -2
  149. package/package.json +5 -5
  150. package/styles.css +109 -0
  151. package/styles.layer.css +109 -0
@@ -1 +1 @@
1
- {"version":3,"file":"ScatterChart.cjs","names":["ReferenceLine","Scatter","LabelList","Box","ResponsiveContainer","ReChartsScatterChart","CartesianGrid","XAxis","Label","YAxis","Tooltip","ChartTooltip","Legend","ChartLegend","classes"],"sources":["../../src/ScatterChart/ScatterChart.tsx"],"sourcesContent":["import { useState } from 'react';\nimport {\n CartesianGrid,\n Label,\n LabelList,\n Legend,\n ScatterChart as ReChartsScatterChart,\n ReferenceLine,\n ResponsiveContainer,\n Scatter,\n ScatterProps,\n Tooltip,\n XAxis,\n YAxis,\n} from 'recharts';\nimport {\n Box,\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n getThemeColor,\n MantineColor,\n StylesApiProps,\n useMantineTheme,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '@mantine/core';\nimport { ChartLegend, ChartLegendStylesNames } from '../ChartLegend';\nimport { ChartTooltip, ChartTooltipStylesNames } from '../ChartTooltip';\nimport { BaseChartStylesNames, GridChartBaseProps } from '../types';\nimport classes from '../grid-chart.module.css';\n\nexport interface ScatterChartSeries {\n color: MantineColor;\n name: string;\n data: Record<string, number>[];\n yAxisId?: string;\n}\n\nexport type ScatterChartStylesNames =\n | 'scatter'\n | Exclude<BaseChartStylesNames, 'brush'>\n | ChartLegendStylesNames\n | ChartTooltipStylesNames;\n\nexport type ScatterChartCssVariables = {\n root: '--chart-text-color' | '--chart-grid-color';\n};\n\nexport interface ScatterChartProps\n extends\n Omit<\n GridChartBaseProps,\n 'dataKey' | 'data' | 'unit' | 'valueFormatter' | 'withBrush' | 'brushProps'\n >,\n BoxProps,\n StylesApiProps<ScatterChartFactory>,\n ElementProps<'div'> {\n /** Keys that should be used to retrieve data from the data array on x and y axis */\n dataKey: { x: string; y: string };\n\n /** Data that is used to build the chart */\n data: ScatterChartSeries[];\n\n /** Units displayed after value on axis and inside the tooltip */\n unit?: { x?: string; y?: string };\n\n /** Labels that should be used instead of keys names in the tooltip */\n labels?: { x?: string; y?: string };\n\n /** A function to format values on x/y axis and in the tooltip */\n valueFormatter?:\n | GridChartBaseProps['valueFormatter']\n | { x?: GridChartBaseProps['valueFormatter']; y?: GridChartBaseProps['valueFormatter'] };\n\n /** Props passed down to recharts `ScatterChart` component */\n scatterChartProps?: React.ComponentProps<typeof ReChartsScatterChart>;\n\n /** Props passed down to recharts `Scatter` component */\n scatterProps?: Partial<Omit<ScatterProps, 'ref'>>;\n\n /** If set, displays labels next to points for the given axis */\n pointLabels?: 'x' | 'y';\n}\n\nfunction getAxis(key: string, dataKey: { x: string; y: string }) {\n return key === dataKey.x ? 'x' : 'y';\n}\n\nexport type ScatterChartFactory = Factory<{\n props: ScatterChartProps;\n ref: HTMLDivElement;\n stylesNames: ScatterChartStylesNames;\n vars: ScatterChartCssVariables;\n}>;\n\nconst defaultProps = {\n withXAxis: true,\n withYAxis: true,\n withTooltip: true,\n tooltipAnimationDuration: 0,\n tickLine: 'y',\n strokeDasharray: '5 5',\n gridAxis: 'x',\n accessibilityLayer: true,\n} satisfies Partial<ScatterChartProps>;\n\nconst varsResolver = createVarsResolver<ScatterChartFactory>((theme, { textColor, gridColor }) => ({\n root: {\n '--chart-text-color': textColor ? getThemeColor(textColor, theme) : undefined,\n '--chart-grid-color': gridColor ? getThemeColor(gridColor, theme) : undefined,\n },\n}));\n\nexport const ScatterChart = factory<ScatterChartFactory>((_props) => {\n const props = useProps('ScatterChart', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n referenceLines,\n dir,\n withLegend,\n withTooltip,\n withXAxis,\n withYAxis,\n withRightYAxis,\n xAxisProps,\n yAxisProps,\n rightYAxisProps,\n orientation,\n scatterChartProps,\n legendProps,\n data,\n gridAxis,\n tickLine,\n strokeDasharray,\n gridProps,\n tooltipAnimationDuration,\n tooltipProps,\n children,\n onMouseLeave,\n dataKey,\n textColor,\n gridColor,\n xAxisLabel,\n yAxisLabel,\n rightYAxisLabel,\n unit,\n labels,\n valueFormatter,\n scatterProps,\n pointLabels,\n attributes,\n accessibilityLayer,\n ...others\n } = props;\n\n const getFormatter = (axis: 'x' | 'y') =>\n typeof valueFormatter === 'function' ? valueFormatter : valueFormatter?.[axis];\n const xFormatter = getFormatter('x');\n const yFormatter = getFormatter('y');\n\n const theme = useMantineTheme();\n\n const mappedData = data.map((item) => ({\n ...item,\n data: item.data.map((point) => ({ ...point, name: item.name })),\n }));\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<ScatterChartFactory>({\n classNames,\n styles,\n props,\n });\n\n const getStyles = useStyles<ScatterChartFactory>({\n name: 'ScatterChart',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const withXTickLine = gridAxis !== 'none' && (tickLine === 'x' || tickLine === 'xy');\n const withYTickLine = gridAxis !== 'none' && (tickLine === 'y' || tickLine === 'xy');\n const [highlightedArea, setHighlightedArea] = useState<string | number | null>(null);\n const shouldHighlight = highlightedArea !== null;\n const handleMouseLeave = (event: React.MouseEvent<HTMLDivElement>) => {\n setHighlightedArea(null);\n onMouseLeave?.(event);\n };\n\n const referenceLinesItems = referenceLines?.map((line, index) => {\n const color = getThemeColor(line.color, theme);\n return (\n <ReferenceLine\n key={index}\n stroke={line.color ? color : 'var(--chart-grid-color)'}\n strokeWidth={1}\n {...line}\n label={{\n fill: line.color ? color : 'currentColor',\n fontSize: 12,\n position: line.labelPosition ?? 'insideBottomLeft',\n ...(typeof line.label === 'object' ? line.label : { value: line.label }),\n }}\n {...getStyles('referenceLine')}\n />\n );\n });\n\n const scatters = mappedData.map((item, index) => {\n const dimmed = shouldHighlight && highlightedArea !== item.name;\n return (\n <Scatter\n data={item.data}\n fill={getThemeColor(item.color, theme)}\n key={index}\n isAnimationActive={false}\n fillOpacity={dimmed ? 0.1 : 1}\n yAxisId={item.yAxisId || undefined}\n {...scatterProps}\n >\n {pointLabels && <LabelList dataKey={dataKey[pointLabels]} fontSize={8} dy={10} />}\n {scatterProps?.children}\n </Scatter>\n );\n });\n\n const sharedYAxisProps = {\n type: 'number' as const,\n axisLine: false,\n dataKey: dataKey.y,\n tickLine: withYTickLine ? { stroke: 'currentColor' } : false,\n allowDecimals: true,\n unit: unit?.y,\n tickFormatter: yFormatter,\n ...getStyles('axis'),\n };\n\n return (\n <Box {...getStyles('root')} onMouseLeave={handleMouseLeave} dir={dir || 'ltr'} {...others}>\n <ResponsiveContainer {...getStyles('container')}>\n <ReChartsScatterChart\n margin={{\n bottom: xAxisLabel ? 30 : undefined,\n left: yAxisLabel ? 10 : undefined,\n right: yAxisLabel || rightYAxisLabel ? 5 : undefined,\n }}\n accessibilityLayer={accessibilityLayer}\n {...scatterChartProps}\n >\n <CartesianGrid\n strokeDasharray={strokeDasharray as string}\n vertical={gridAxis === 'y' || gridAxis === 'xy'}\n horizontal={gridAxis === 'x' || gridAxis === 'xy'}\n {...getStyles('grid')}\n {...gridProps}\n />\n <XAxis\n type=\"number\"\n hide={!withXAxis}\n dataKey={dataKey.x}\n tick={{ transform: 'translate(0, 10)', fontSize: 12, fill: 'currentColor' }}\n stroke=\"\"\n interval=\"preserveStartEnd\"\n tickLine={withXTickLine ? { stroke: 'currentColor' } : false}\n minTickGap={5}\n unit={unit?.x}\n tickFormatter={xFormatter}\n {...getStyles('axis')}\n {...xAxisProps}\n >\n {xAxisLabel && (\n <Label position=\"insideBottom\" offset={-20} fontSize={12} {...getStyles('axisLabel')}>\n {xAxisLabel}\n </Label>\n )}\n {xAxisProps?.children}\n </XAxis>\n <YAxis\n hide={!withYAxis}\n tick={{ transform: 'translate(-10, 0)', fontSize: 12, fill: 'currentColor' }}\n {...sharedYAxisProps}\n {...yAxisProps}\n >\n {yAxisLabel && (\n <Label\n position=\"insideLeft\"\n angle={-90}\n textAnchor=\"middle\"\n fontSize={12}\n offset={-5}\n {...getStyles('axisLabel')}\n >\n {yAxisLabel}\n </Label>\n )}\n {yAxisProps?.children}\n </YAxis>\n\n <YAxis\n yAxisId=\"right\"\n orientation=\"right\"\n hide={!withRightYAxis}\n tick={{ transform: 'translate(10, 0)', fontSize: 12, fill: 'currentColor' }}\n {...sharedYAxisProps}\n {...rightYAxisProps}\n >\n {rightYAxisLabel && (\n <Label\n position=\"insideRight\"\n angle={90}\n textAnchor=\"middle\"\n fontSize={12}\n offset={-5}\n {...getStyles('axisLabel')}\n >\n {rightYAxisLabel}\n </Label>\n )}\n {rightYAxisProps?.children}\n </YAxis>\n\n {withTooltip && (\n <Tooltip\n animationDuration={tooltipAnimationDuration}\n isAnimationActive={tooltipAnimationDuration !== 0}\n position={{ y: 0 }}\n cursor={{\n stroke: 'var(--chart-grid-color)',\n strokeWidth: 1,\n strokeDasharray,\n }}\n content={({ label, payload, labelFormatter }) => (\n <ChartTooltip\n type=\"scatter\"\n label={labelFormatter && payload ? labelFormatter(label, payload) : label}\n payload={\n labels\n ? payload?.map((item) => ({\n ...item,\n name: labels[getAxis(item.name as string, dataKey)] || item.name,\n value:\n getFormatter(getAxis(item.name as string, dataKey))?.(\n item.value as number\n ) ?? item.value,\n }))\n : payload?.map((item) => ({\n ...item,\n value:\n getFormatter(getAxis(item.name as string, dataKey))?.(\n item.value as number\n ) ?? item.value,\n }))\n }\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n series={data}\n attributes={attributes}\n />\n )}\n {...tooltipProps}\n />\n )}\n\n {withLegend && (\n <Legend\n verticalAlign=\"top\"\n content={(payload) => (\n <ChartLegend\n payload={payload.payload?.map((item, index) => ({\n ...item,\n dataKey: data[index].name,\n }))}\n onHighlight={setHighlightedArea}\n legendPosition={legendProps?.verticalAlign || 'top'}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n series={data}\n attributes={attributes}\n />\n )}\n height={44}\n {...legendProps}\n />\n )}\n\n {referenceLinesItems}\n {scatters}\n </ReChartsScatterChart>\n </ResponsiveContainer>\n </Box>\n );\n});\n\nScatterChart.displayName = '@mantine/charts/ScatterChart';\nScatterChart.classes = classes;\nScatterChart.varsResolver = varsResolver;\n\nexport namespace ScatterChart {\n export type Props = ScatterChartProps;\n export type StylesNames = ScatterChartStylesNames;\n export type CssVariables = ScatterChartCssVariables;\n export type Factory = ScatterChartFactory;\n export type Series = ScatterChartSeries;\n}\n"],"mappings":";;;;;;;;;AAwFA,SAAS,QAAQ,KAAa,SAAmC;CAC/D,OAAO,QAAQ,QAAQ,IAAI,MAAM;AACnC;AASA,MAAM,eAAe;CACnB,WAAW;CACX,WAAW;CACX,aAAa;CACb,0BAA0B;CAC1B,UAAU;CACV,iBAAiB;CACjB,UAAU;CACV,oBAAoB;AACtB;AAEA,MAAM,gBAAA,GAAA,cAAA,mBAAA,EAAwD,OAAO,EAAE,WAAW,iBAAiB,EACjG,MAAM;CACJ,sBAAsB,aAAA,GAAA,cAAA,cAAA,CAA0B,WAAW,KAAK,IAAI,KAAA;CACpE,sBAAsB,aAAA,GAAA,cAAA,cAAA,CAA0B,WAAW,KAAK,IAAI,KAAA;AACtE,EACF,EAAE;AAEF,MAAa,gBAAA,GAAA,cAAA,QAAA,EAA6C,WAAW;CACnE,MAAM,SAAA,GAAA,cAAA,SAAA,CAAiB,gBAAgB,cAAc,MAAM;CAC3D,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA,gBACA,KACA,YACA,aACA,WACA,WACA,gBACA,YACA,YACA,iBACA,aACA,mBACA,aACA,MACA,UACA,UACA,iBACA,WACA,0BACA,cACA,UACA,cACA,SACA,WACA,WACA,YACA,YACA,iBACA,MACA,QACA,gBACA,cACA,aACA,YACA,oBACA,GAAG,WACD;CAEJ,MAAM,gBAAgB,SACpB,OAAO,mBAAmB,aAAa,iBAAiB,iBAAiB;CAC3E,MAAM,aAAa,aAAa,GAAG;CACnC,MAAM,aAAa,aAAa,GAAG;CAEnC,MAAM,SAAA,GAAA,cAAA,gBAAA,CAAwB;CAE9B,MAAM,aAAa,KAAK,KAAK,UAAU;EACrC,GAAG;EACH,MAAM,KAAK,KAAK,KAAK,WAAW;GAAE,GAAG;GAAO,MAAM,K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D,OACE,aAAa,QAAQ,KAAK,MAAgB,OAAO,CAAC,CAAC,GACjD,KAAK,KACP,KAAK,KAAK;OACd,EAAE,IACF,SAAS,KAAK,UAAU;QACtB,GAAG;QACH,OACE,aAAa,QAAQ,KAAK,MAAgB,OAAO,CAAC,CAAC,GACjD,KAAK,KACP,KAAK,KAAK;OACd,EAAE;OAER,YAAY;OACZ,QAAQ;OACR,QAAQ;OACI;MACb,CAAA;MAEH,GAAI;KACL,CAAA;KAGF,cACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,SAAAA,QAAD;MACE,eAAc;MACd,UAAU,YACR,iBAAA,GAAA,kBAAA,IAAA,CAACC,oBAAAA,aAAD;OACE,SAAS,QAAQ,SAAS,KAAK,MAAM,WAAW;QAC9C,GAAG;QACH,SAAS,KAAK,MAAM,CAAC;OACvB,EAAE;OACF,aAAa;OACb,gBAAgB,aAAa,iBAAiB;OAC9C,YAAY;OACZ,QAAQ;OACR,QAAQ;OACI;MACb,CAAA;MAEH,QAAQ;MACR,GAAI;KACL,CAAA;KAGF;KACA;IACmB;;EACH,CAAA;CAClB,CAAA;AAET,CAAC;AAED,aAAa,cAAc;AAC3B,aAAa,UAAUC,0BAAAA;AACvB,aAAa,eAAe"}
1
+ {"version":3,"file":"ScatterChart.cjs","names":["createVarsResolver","getThemeColor","factory","useProps","useMantineTheme","useResolvedStylesApi","useStyles","useState","ReferenceLine","ReferenceArea","ReferenceDot","Scatter","LabelList","Box","ResponsiveContainer","ReChartsScatterChart","CartesianGrid","XAxis","Label","YAxis","Tooltip","ChartTooltip","Legend","ChartLegend","classes"],"sources":["../../src/ScatterChart/ScatterChart.tsx"],"sourcesContent":["import { useState } from 'react';\nimport {\n CartesianGrid,\n Label,\n LabelList,\n Legend,\n ScatterChart as ReChartsScatterChart,\n ReferenceArea,\n ReferenceDot,\n ReferenceLine,\n ResponsiveContainer,\n Scatter,\n ScatterProps,\n Tooltip,\n XAxis,\n YAxis,\n} from 'recharts';\nimport {\n Box,\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n getThemeColor,\n MantineColor,\n StylesApiProps,\n useMantineTheme,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '@mantine/core';\nimport { ChartLegend, ChartLegendStylesNames } from '../ChartLegend';\nimport { ChartTooltip, ChartTooltipStylesNames } from '../ChartTooltip';\nimport { BaseChartStylesNames, GridChartBaseProps } from '../types';\nimport classes from '../grid-chart.module.css';\n\nexport interface ScatterChartSeries {\n color: MantineColor;\n name: string;\n data: Record<string, number>[];\n yAxisId?: string;\n}\n\nexport type ScatterChartStylesNames =\n | 'scatter'\n | Exclude<BaseChartStylesNames, 'brush'>\n | ChartLegendStylesNames\n | ChartTooltipStylesNames;\n\nexport type ScatterChartCssVariables = {\n root: '--chart-text-color' | '--chart-grid-color';\n};\n\nexport interface ScatterChartProps\n extends\n Omit<\n GridChartBaseProps,\n 'dataKey' | 'data' | 'unit' | 'valueFormatter' | 'withBrush' | 'brushProps'\n >,\n BoxProps,\n StylesApiProps<ScatterChartFactory>,\n ElementProps<'div'> {\n /** Keys that should be used to retrieve data from the data array on x and y axis */\n dataKey: { x: string; y: string };\n\n /** Data that is used to build the chart */\n data: ScatterChartSeries[];\n\n /** Units displayed after value on axis and inside the tooltip */\n unit?: { x?: string; y?: string };\n\n /** Labels that should be used instead of keys names in the tooltip */\n labels?: { x?: string; y?: string };\n\n /** A function to format values on x/y axis and in the tooltip */\n valueFormatter?:\n | GridChartBaseProps['valueFormatter']\n | { x?: GridChartBaseProps['valueFormatter']; y?: GridChartBaseProps['valueFormatter'] };\n\n /** Props passed down to recharts `ScatterChart` component */\n scatterChartProps?: React.ComponentProps<typeof ReChartsScatterChart>;\n\n /** Props passed down to recharts `Scatter` component */\n scatterProps?: Partial<Omit<ScatterProps, 'ref'>>;\n\n /** If set, displays labels next to points for the given axis */\n pointLabels?: 'x' | 'y';\n}\n\nfunction getAxis(key: string, dataKey: { x: string; y: string }) {\n return key === dataKey.x ? 'x' : 'y';\n}\n\nexport type ScatterChartFactory = Factory<{\n props: ScatterChartProps;\n ref: HTMLDivElement;\n stylesNames: ScatterChartStylesNames;\n vars: ScatterChartCssVariables;\n}>;\n\nconst defaultProps = {\n withXAxis: true,\n withYAxis: true,\n withTooltip: true,\n tooltipAnimationDuration: 0,\n tickLine: 'y',\n strokeDasharray: '5 5',\n gridAxis: 'x',\n accessibilityLayer: true,\n} satisfies Partial<ScatterChartProps>;\n\nconst varsResolver = createVarsResolver<ScatterChartFactory>((theme, { textColor, gridColor }) => ({\n root: {\n '--chart-text-color': textColor ? getThemeColor(textColor, theme) : undefined,\n '--chart-grid-color': gridColor ? getThemeColor(gridColor, theme) : undefined,\n },\n}));\n\nexport const ScatterChart = factory<ScatterChartFactory>((_props) => {\n const props = useProps('ScatterChart', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n referenceLines,\n referenceAreas,\n referenceDots,\n dir,\n withLegend,\n withTooltip,\n withXAxis,\n withYAxis,\n withRightYAxis,\n xAxisProps,\n yAxisProps,\n rightYAxisProps,\n orientation,\n scatterChartProps,\n legendProps,\n data,\n gridAxis,\n tickLine,\n strokeDasharray,\n gridProps,\n tooltipAnimationDuration,\n tooltipProps,\n children,\n onMouseLeave,\n dataKey,\n textColor,\n gridColor,\n xAxisLabel,\n yAxisLabel,\n rightYAxisLabel,\n unit,\n labels,\n valueFormatter,\n scatterProps,\n pointLabels,\n attributes,\n accessibilityLayer,\n ...others\n } = props;\n\n const getFormatter = (axis: 'x' | 'y') =>\n typeof valueFormatter === 'function' ? valueFormatter : valueFormatter?.[axis];\n const xFormatter = getFormatter('x');\n const yFormatter = getFormatter('y');\n\n const theme = useMantineTheme();\n\n const mappedData = data.map((item) => ({\n ...item,\n data: item.data.map((point) => ({ ...point, name: item.name })),\n }));\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<ScatterChartFactory>({\n classNames,\n styles,\n props,\n });\n\n const getStyles = useStyles<ScatterChartFactory>({\n name: 'ScatterChart',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const withXTickLine = gridAxis !== 'none' && (tickLine === 'x' || tickLine === 'xy');\n const withYTickLine = gridAxis !== 'none' && (tickLine === 'y' || tickLine === 'xy');\n const [highlightedArea, setHighlightedArea] = useState<string | number | null>(null);\n const shouldHighlight = highlightedArea !== null;\n const handleMouseLeave = (event: React.MouseEvent<HTMLDivElement>) => {\n setHighlightedArea(null);\n onMouseLeave?.(event);\n };\n\n const referenceLinesItems = referenceLines?.map(\n ({ color: lineColor, labelPosition, ...line }, index) => {\n const color = getThemeColor(lineColor, theme);\n return (\n <ReferenceLine\n key={index}\n stroke={lineColor ? color : 'var(--chart-grid-color)'}\n strokeWidth={1}\n {...line}\n label={{\n fill: lineColor ? color : 'currentColor',\n fontSize: 12,\n position: labelPosition ?? 'insideBottomLeft',\n ...(typeof line.label === 'object' ? line.label : { value: line.label }),\n }}\n {...getStyles('referenceLine')}\n />\n );\n }\n );\n\n const referenceAreasItems = referenceAreas?.map(\n ({ color: areaColor, labelPosition, ...area }, index) => {\n const color = getThemeColor(areaColor, theme);\n return (\n <ReferenceArea\n key={index}\n fill={areaColor ? color : 'var(--chart-grid-color)'}\n fillOpacity={0.2}\n stroke={areaColor ? color : 'var(--chart-grid-color)'}\n strokeOpacity={0.6}\n {...area}\n label={{\n fill: areaColor ? color : 'currentColor',\n fontSize: 12,\n position: labelPosition ?? 'insideTop',\n ...(typeof area.label === 'object' ? area.label : { value: area.label }),\n }}\n {...getStyles('referenceArea')}\n />\n );\n }\n );\n\n const referenceDotsItems = referenceDots?.map(\n ({ color: dotColor, labelPosition, ...dot }, index) => {\n const color = getThemeColor(dotColor, theme);\n return (\n <ReferenceDot\n key={index}\n r={5}\n fill={dotColor ? color : 'var(--chart-grid-color)'}\n stroke=\"var(--mantine-color-body)\"\n strokeWidth={2}\n {...dot}\n label={{\n fill: dotColor ? color : 'currentColor',\n fontSize: 12,\n position: labelPosition ?? 'top',\n ...(typeof dot.label === 'object' ? dot.label : { value: dot.label }),\n }}\n {...getStyles('referenceDot')}\n />\n );\n }\n );\n\n const scatters = mappedData.map((item, index) => {\n const dimmed = shouldHighlight && highlightedArea !== item.name;\n return (\n <Scatter\n data={item.data}\n fill={getThemeColor(item.color, theme)}\n key={index}\n isAnimationActive={false}\n fillOpacity={dimmed ? 0.1 : 1}\n yAxisId={item.yAxisId || undefined}\n {...scatterProps}\n >\n {pointLabels && <LabelList dataKey={dataKey[pointLabels]} fontSize={8} dy={10} />}\n {scatterProps?.children}\n </Scatter>\n );\n });\n\n const sharedYAxisProps = {\n type: 'number' as const,\n axisLine: false,\n dataKey: dataKey.y,\n tickLine: withYTickLine ? { stroke: 'currentColor' } : false,\n allowDecimals: true,\n unit: unit?.y,\n tickFormatter: yFormatter,\n ...getStyles('axis'),\n };\n\n return (\n <Box {...getStyles('root')} onMouseLeave={handleMouseLeave} dir={dir || 'ltr'} {...others}>\n <ResponsiveContainer {...getStyles('container')}>\n <ReChartsScatterChart\n margin={{\n bottom: xAxisLabel ? 30 : undefined,\n left: yAxisLabel ? 10 : undefined,\n right: yAxisLabel || rightYAxisLabel ? 5 : undefined,\n }}\n accessibilityLayer={accessibilityLayer}\n {...scatterChartProps}\n >\n {referenceAreasItems}\n <CartesianGrid\n strokeDasharray={strokeDasharray as string}\n vertical={gridAxis === 'y' || gridAxis === 'xy'}\n horizontal={gridAxis === 'x' || gridAxis === 'xy'}\n {...getStyles('grid')}\n {...gridProps}\n />\n <XAxis\n type=\"number\"\n hide={!withXAxis}\n dataKey={dataKey.x}\n tick={{ transform: 'translate(0, 10)', fontSize: 12, fill: 'currentColor' }}\n stroke=\"\"\n interval=\"preserveStartEnd\"\n tickLine={withXTickLine ? { stroke: 'currentColor' } : false}\n minTickGap={5}\n unit={unit?.x}\n tickFormatter={xFormatter}\n {...getStyles('axis')}\n {...xAxisProps}\n >\n {xAxisLabel && (\n <Label position=\"insideBottom\" offset={-20} fontSize={12} {...getStyles('axisLabel')}>\n {xAxisLabel}\n </Label>\n )}\n {xAxisProps?.children}\n </XAxis>\n <YAxis\n hide={!withYAxis}\n tick={{ transform: 'translate(-10, 0)', fontSize: 12, fill: 'currentColor' }}\n {...sharedYAxisProps}\n {...yAxisProps}\n >\n {yAxisLabel && (\n <Label\n position=\"insideLeft\"\n angle={-90}\n textAnchor=\"middle\"\n fontSize={12}\n offset={-5}\n {...getStyles('axisLabel')}\n >\n {yAxisLabel}\n </Label>\n )}\n {yAxisProps?.children}\n </YAxis>\n\n <YAxis\n yAxisId=\"right\"\n orientation=\"right\"\n hide={!withRightYAxis}\n tick={{ transform: 'translate(10, 0)', fontSize: 12, fill: 'currentColor' }}\n {...sharedYAxisProps}\n {...rightYAxisProps}\n >\n {rightYAxisLabel && (\n <Label\n position=\"insideRight\"\n angle={90}\n textAnchor=\"middle\"\n fontSize={12}\n offset={-5}\n {...getStyles('axisLabel')}\n >\n {rightYAxisLabel}\n </Label>\n )}\n {rightYAxisProps?.children}\n </YAxis>\n\n {withTooltip && (\n <Tooltip\n animationDuration={tooltipAnimationDuration}\n isAnimationActive={tooltipAnimationDuration !== 0}\n position={{ y: 0 }}\n cursor={{\n stroke: 'var(--chart-grid-color)',\n strokeWidth: 1,\n strokeDasharray,\n }}\n content={({ label, payload, labelFormatter }) => (\n <ChartTooltip\n type=\"scatter\"\n label={labelFormatter && payload ? labelFormatter(label, payload) : label}\n payload={\n labels\n ? payload?.map((item) => ({\n ...item,\n name: labels[getAxis(item.name as string, dataKey)] || item.name,\n value:\n getFormatter(getAxis(item.name as string, dataKey))?.(\n item.value as number\n ) ?? item.value,\n }))\n : payload?.map((item) => ({\n ...item,\n value:\n getFormatter(getAxis(item.name as string, dataKey))?.(\n item.value as number\n ) ?? item.value,\n }))\n }\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n series={data}\n attributes={attributes}\n />\n )}\n {...tooltipProps}\n />\n )}\n\n {withLegend && (\n <Legend\n verticalAlign=\"top\"\n content={(payload) => (\n <ChartLegend\n payload={payload.payload?.map((item, index) => ({\n ...item,\n dataKey: data[index].name,\n }))}\n onHighlight={setHighlightedArea}\n legendPosition={legendProps?.verticalAlign || 'top'}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n series={data}\n attributes={attributes}\n />\n )}\n height={44}\n {...legendProps}\n />\n )}\n\n {referenceLinesItems}\n {scatters}\n {referenceDotsItems}\n </ReChartsScatterChart>\n </ResponsiveContainer>\n </Box>\n );\n});\n\nScatterChart.displayName = '@mantine/charts/ScatterChart';\nScatterChart.classes = classes;\nScatterChart.varsResolver = varsResolver;\n\nexport namespace ScatterChart {\n export type Props = ScatterChartProps;\n export type StylesNames = ScatterChartStylesNames;\n export type CssVariables = ScatterChartCssVariables;\n export type Factory = ScatterChartFactory;\n export type Series = ScatterChartSeries;\n}\n"],"mappings":";;;;;;;;;AA0FA,SAAS,QAAQ,KAAa,SAAmC;CAC/D,OAAO,QAAQ,QAAQ,IAAI,MAAM;AACnC;AASA,MAAM,eAAe;CACnB,WAAW;CACX,WAAW;CACX,aAAa;CACb,0BAA0B;CAC1B,UAAU;CACV,iBAAiB;CACjB,UAAU;CACV,oBAAoB;AACtB;AAEA,MAAM,gBAAA,GAAeA,cAAAA,mBAAAA,EAAyC,OAAO,EAAE,WAAW,iBAAiB,EACjG,MAAM;CACJ,sBAAsB,aAAA,GAAYC,cAAAA,cAAAA,CAAc,WAAW,KAAK,IAAI,KAAA;CACpE,sBAAsB,aAAA,GAAYA,cAAAA,cAAAA,CAAc,WAAW,KAAK,IAAI,KAAA;AACtE,EACF,EAAE;AAEF,MAAa,gBAAA,GAAeC,cAAAA,QAAAA,EAA8B,WAAW;CACnE,MAAM,SAAA,GAAQC,cAAAA,SAAAA,CAAS,gBAAgB,cAAc,MAAM;CAC3D,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA,gBACA,gBACA,eACA,KACA,YACA,aACA,WACA,WACA,gBACA,YACA,YACA,iBAC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AAS,qBAC1B,iBAAA,GAAA,kBAAA,IAAA,CAACC,qBAAAA,cAAD;OACE,MAAK;OACL,OAAO,kBAAkB,UAAU,eAAe,OAAO,OAAO,IAAI;OACpE,SACE,SACI,SAAS,KAAK,UAAU;QACtB,GAAG;QACH,MAAM,OAAO,QAAQ,KAAK,MAAgB,OAAO,MAAM,KAAK;QAC5D,OACE,aAAa,QAAQ,KAAK,MAAgB,OAAO,CAAC,CAAC,GACjD,KAAK,KACP,KAAK,KAAK;OACd,EAAE,IACF,SAAS,KAAK,UAAU;QACtB,GAAG;QACH,OACE,aAAa,QAAQ,KAAK,MAAgB,OAAO,CAAC,CAAC,GACjD,KAAK,KACP,KAAK,KAAK;OACd,EAAE;OAER,YAAY;OACZ,QAAQ;OACR,QAAQ;OACI;MACb,CAAA;MAEH,GAAI;KACL,CAAA;KAGF,cACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,SAAAA,QAAD;MACE,eAAc;MACd,UAAU,YACR,iBAAA,GAAA,kBAAA,IAAA,CAACC,oBAAAA,aAAD;OACE,SAAS,QAAQ,SAAS,KAAK,MAAM,WAAW;QAC9C,GAAG;QACH,SAAS,KAAK,MAAM,CAAC;OACvB,EAAE;OACF,aAAa;OACb,gBAAgB,aAAa,iBAAiB;OAC9C,YAAY;OACZ,QAAQ;OACR,QAAQ;OACI;MACb,CAAA;MAEH,QAAQ;MACR,GAAI;KACL,CAAA;KAGF;KACA;KACA;IACmB;;EACH,CAAA;CAClB,CAAA;AAET,CAAC;AAED,aAAa,cAAc;AAC3B,aAAa,UAAUC,0BAAAA;AACvB,aAAa,eAAe"}
@@ -1 +1 @@
1
- {"version":3,"file":"Sparkline.cjs","names":["Box","ResponsiveContainer","ReChartsAreaChart","Area","AreaGradient","classes"],"sources":["../../src/Sparkline/Sparkline.tsx"],"sourcesContent":["import { useId, useMemo } from 'react';\nimport { Area, AreaProps, AreaChart as ReChartsAreaChart, ResponsiveContainer } from 'recharts';\nimport {\n Box,\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n getThemeColor,\n MantineColor,\n StylesApiProps,\n useProps,\n useStyles,\n} from '@mantine/core';\nimport { AreaChartCurveType, AreaGradient } from '../AreaChart';\nimport classes from './Sparkline.module.css';\n\nexport interface SparklineTrendColors {\n positive: MantineColor;\n negative: MantineColor;\n neutral?: MantineColor;\n}\n\nexport type SparklineStylesNames = 'root';\nexport type SparklineCssVariables = {\n root: '--chart-color';\n};\n\nexport interface SparklineProps\n extends BoxProps, StylesApiProps<SparklineFactory>, ElementProps<'div'> {\n /** Data used to render the chart */\n data: (number | null)[];\n\n /** Key of `theme.colors` or any valid CSS color @default theme.primaryColor */\n color?: MantineColor;\n\n /** Determines whether the chart fill should be a gradient @default true */\n withGradient?: boolean;\n\n /** Controls fill opacity of the area @default 0.6 */\n fillOpacity?: number;\n\n /** Type of the curve @default 'linear' */\n curveType?: AreaChartCurveType;\n\n /** Area stroke width @default 2 */\n strokeWidth?: number;\n\n /** If set, `color` prop is ignored and chart color is determined by the difference between first and last value. */\n trendColors?: SparklineTrendColors;\n\n /** Determines whether null values should be connected with other values @default true */\n connectNulls?: boolean;\n\n /** Props passed down to the underlying recharts `Area` component */\n areaProps?: Omit<AreaProps<any, any>, 'data' | 'dataKey' | 'ref'>;\n}\n\nexport type SparklineFactory = Factory<{\n props: SparklineProps;\n ref: HTMLDivElement;\n stylesNames: SparklineStylesNames;\n vars: SparklineCssVariables;\n}>;\n\nconst defaultProps = {\n withGradient: true,\n connectNulls: true,\n fillOpacity: 0.6,\n strokeWidth: 2,\n curveType: 'linear',\n} satisfies Partial<SparklineProps>;\n\nfunction getTrendColor(data: (number | null)[], trendColors: SparklineTrendColors) {\n const first = data[0];\n const last = data[data.length - 1];\n\n if (first === null || last === null) {\n return trendColors.neutral || trendColors.positive;\n }\n\n if (first < last) {\n return trendColors.positive;\n }\n\n if (first > last) {\n return trendColors.negative;\n }\n\n return trendColors.neutral || trendColors.positive;\n}\n\nconst varsResolver = createVarsResolver<SparklineFactory>(\n (theme, { color, data, trendColors }) => ({\n root: {\n '--chart-color': trendColors\n ? getThemeColor(getTrendColor(data, trendColors), theme)\n : color\n ? getThemeColor(color, theme)\n : undefined,\n },\n })\n);\n\nexport const Sparkline = factory<SparklineFactory>((_props) => {\n const props = useProps('Sparkline', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n data,\n withGradient,\n fillOpacity,\n curveType,\n strokeWidth,\n trendColors,\n connectNulls,\n areaProps,\n attributes,\n ...others\n } = props;\n\n const getStyles = useStyles<SparklineFactory>({\n name: 'Sparkline',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const id = useId();\n const mappedData = useMemo(() => data.map((value, index) => ({ value, index })), [data]);\n\n return (\n <Box {...getStyles('root')} {...others} dir=\"ltr\">\n <ResponsiveContainer>\n <ReChartsAreaChart data={mappedData}>\n <Area\n dataKey=\"value\"\n type={curveType}\n fill={`url(#${id})`}\n stroke=\"var(--chart-color, var(--mantine-color-blue-filled))\"\n isAnimationActive={false}\n connectNulls={connectNulls}\n strokeWidth={strokeWidth}\n fillOpacity={1}\n activeDot={false}\n {...areaProps}\n />\n\n <defs>\n <AreaGradient\n id={id}\n color=\"var(--chart-color, var(--mantine-color-blue-filled))\"\n fillOpacity={fillOpacity}\n withGradient={withGradient}\n />\n </defs>\n </ReChartsAreaChart>\n </ResponsiveContainer>\n </Box>\n );\n});\n\nSparkline.displayName = '@mantine/charts/Sparkline';\nSparkline.classes = classes;\nSparkline.varsResolver = varsResolver;\n\nexport namespace Sparkline {\n export type Props = SparklineProps;\n export type StylesNames = SparklineStylesNames;\n export type CssVariables = SparklineCssVariables;\n export type Factory = SparklineFactory;\n}\n"],"mappings":";;;;;;;;AAkEA,MAAM,eAAe;CACnB,cAAc;CACd,cAAc;CACd,aAAa;CACb,aAAa;CACb,WAAW;AACb;AAEA,SAAS,cAAc,MAAyB,aAAmC;CACjF,M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AAA,CAACC,SAAAA,MAAD;IACE,SAAQ;IACR,MAAM;IACN,MAAM,QAAQ,GAAG;IACjB,QAAO;IACP,mBAAmB;IACL;IACD;IACb,aAAa;IACb,WAAW;IACX,GAAI;GACL,CAAA,GAED,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD,EAAA,UACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,qBAAAA,cAAD;IACM;IACJ,OAAM;IACO;IACC;GACf,CAAA,EACG,CAAA,CACW;KACA,CAAA;CAClB,CAAA;AAET,CAAC;AAED,UAAU,cAAc;AACxB,UAAU,UAAUC,yBAAAA;AACpB,UAAU,eAAe"}
1
+ {"version":3,"file":"Sparkline.cjs","names":["createVarsResolver","getThemeColor","factory","useProps","useStyles","useId","useMemo","Box","ResponsiveContainer","ReChartsAreaChart","Area","AreaGradient","classes"],"sources":["../../src/Sparkline/Sparkline.tsx"],"sourcesContent":["import { useId, useMemo } from 'react';\nimport { Area, AreaProps, AreaChart as ReChartsAreaChart, ResponsiveContainer } from 'recharts';\nimport {\n Box,\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n getThemeColor,\n MantineColor,\n StylesApiProps,\n useProps,\n useStyles,\n} from '@mantine/core';\nimport { AreaChartCurveType, AreaGradient } from '../AreaChart';\nimport classes from './Sparkline.module.css';\n\nexport interface SparklineTrendColors {\n positive: MantineColor;\n negative: MantineColor;\n neutral?: MantineColor;\n}\n\nexport type SparklineStylesNames = 'root';\nexport type SparklineCssVariables = {\n root: '--chart-color';\n};\n\nexport interface SparklineProps\n extends BoxProps, StylesApiProps<SparklineFactory>, ElementProps<'div'> {\n /** Data used to render the chart */\n data: (number | null)[];\n\n /** Key of `theme.colors` or any valid CSS color @default theme.primaryColor */\n color?: MantineColor;\n\n /** Determines whether the chart fill should be a gradient @default true */\n withGradient?: boolean;\n\n /** Controls fill opacity of the area @default 0.6 */\n fillOpacity?: number;\n\n /** Type of the curve @default 'linear' */\n curveType?: AreaChartCurveType;\n\n /** Area stroke width @default 2 */\n strokeWidth?: number;\n\n /** If set, `color` prop is ignored and chart color is determined by the difference between first and last value. */\n trendColors?: SparklineTrendColors;\n\n /** Determines whether null values should be connected with other values @default true */\n connectNulls?: boolean;\n\n /** Props passed down to the underlying recharts `Area` component */\n areaProps?: Omit<AreaProps<any, any>, 'data' | 'dataKey' | 'ref'>;\n}\n\nexport type SparklineFactory = Factory<{\n props: SparklineProps;\n ref: HTMLDivElement;\n stylesNames: SparklineStylesNames;\n vars: SparklineCssVariables;\n}>;\n\nconst defaultProps = {\n withGradient: true,\n connectNulls: true,\n fillOpacity: 0.6,\n strokeWidth: 2,\n curveType: 'linear',\n} satisfies Partial<SparklineProps>;\n\nfunction getTrendColor(data: (number | null)[], trendColors: SparklineTrendColors) {\n const first = data[0];\n const last = data[data.length - 1];\n\n if (first === null || last === null) {\n return trendColors.neutral || trendColors.positive;\n }\n\n if (first < last) {\n return trendColors.positive;\n }\n\n if (first > last) {\n return trendColors.negative;\n }\n\n return trendColors.neutral || trendColors.positive;\n}\n\nconst varsResolver = createVarsResolver<SparklineFactory>(\n (theme, { color, data, trendColors }) => ({\n root: {\n '--chart-color': trendColors\n ? getThemeColor(getTrendColor(data, trendColors), theme)\n : color\n ? getThemeColor(color, theme)\n : undefined,\n },\n })\n);\n\nexport const Sparkline = factory<SparklineFactory>((_props) => {\n const props = useProps('Sparkline', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n data,\n withGradient,\n fillOpacity,\n curveType,\n strokeWidth,\n trendColors,\n connectNulls,\n areaProps,\n attributes,\n ...others\n } = props;\n\n const getStyles = useStyles<SparklineFactory>({\n name: 'Sparkline',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const id = useId();\n const mappedData = useMemo(() => data.map((value, index) => ({ value, index })), [data]);\n\n return (\n <Box {...getStyles('root')} {...others} dir=\"ltr\">\n <ResponsiveContainer>\n <ReChartsAreaChart data={mappedData}>\n <Area\n dataKey=\"value\"\n type={curveType}\n fill={`url(#${id})`}\n stroke=\"var(--chart-color, var(--mantine-color-blue-filled))\"\n isAnimationActive={false}\n connectNulls={connectNulls}\n strokeWidth={strokeWidth}\n fillOpacity={1}\n activeDot={false}\n {...areaProps}\n />\n\n <defs>\n <AreaGradient\n id={id}\n color=\"var(--chart-color, var(--mantine-color-blue-filled))\"\n fillOpacity={fillOpacity}\n withGradient={withGradient}\n />\n </defs>\n </ReChartsAreaChart>\n </ResponsiveContainer>\n </Box>\n );\n});\n\nSparkline.displayName = '@mantine/charts/Sparkline';\nSparkline.classes = classes;\nSparkline.varsResolver = varsResolver;\n\nexport namespace Sparkline {\n export type Props = SparklineProps;\n export type StylesNames = SparklineStylesNames;\n export type CssVariables = SparklineCssVariables;\n export type Factory = SparklineFactory;\n}\n"],"mappings":";;;;;;;;AAkEA,MAAM,eAAe;CACnB,cAAc;CACd,cAAc;CACd,aAAa;CACb,aAAa;CACb,WAAW;AACb;AAEA,SAAS,cAAc,MAAyB,aAAmC;CACjF,MAAM,QAAQ,KAAK;CACnB,MAAM,OAAO,KAAK,KAAK,SAAS;CAEhC,IAAI,UAAU,QAAQ,SAAS,MAC7B,OAAO,YAAY,WAAW,YAAY;CAG5C,IAAI,QAAQ,MACV,OAAO,YAAY;CAGrB,IAAI,QAAQ,MACV,OAAO,YAAY;CAGrB,OAAO,YAAY,WAAW,YAAY;AAC5C;AAEA,MAAM,gBAAA,GAAeA,cAAAA,mBAAAA,EAClB,OAAO,EAAE,OAAO,MAAM,mBAAmB,EACxC,MAAM,EACJ,iBAAiB,eAAA,GACbC,cAAAA,cAAAA,CAAc,cAAc,MAAM,WAAW,GAAG,KAAK,IACrD,SAAA,GACEA,cAAAA,cAAAA,CAAc,OAAO,KAAK,IAC1B,KAAA,EACR,EACF,EACF;AAEA,MAAa,aAAA,GAAYC,cAAAA,QAAAA,EAA2B,WAAW;CAC7D,MAAM,SAAA,GAAQC,cAAAA,SAAAA,CAAS,aAAa,cAAc,MAAM;CACxD,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA,MACA,cACA,aACA,WACA,aACA,aACA,cACA,WACA,YACA,GAAG,WACD;CAEJ,MAAM,aAAA,GAAYC,cAAAA,UAAAA,CAA4B;EAC5C,MAAM;EACN,SAAA,yBAAA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CAED,MAAM,MAAA,GAAKC,MAAAA,MAAAA,CAAM;CACjB,MAAM,cAAA,GAAaC,MAAAA,QAAAA,OAAc,KAAK,KAAK,OAAO,WAAW;EAAE;EAAO;CAAM,EAAE,GAAG,CAAC,IAAI,CAAC;CAEvF,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,cAAAA,KAAD;EAAK,GAAI,UAAU,MAAM;EAAG,GAAI;EAAQ,KAAI;EAC1C,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACC,SAAAA,qBAAD,EAAA,UACE,iBAAA,GAAA,kBAAA,KAAA,CAACC,SAAAA,WAAD;GAAmB,MAAM;GAAzB,UAAA,CACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,SAAAA,MAAD;IACE,SAAQ;IACR,MAAM;IACN,MAAM,QAAQ,GAAG;IACjB,QAAO;IACP,mBAAmB;IACL;IACD;IACb,aAAa;IACb,WAAW;IACX,GAAI;GACL,CAAA,GAED,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD,EAAA,UACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,qBAAAA,cAAD;IACM;IACJ,OAAM;IACO;IACC;GACf,CAAA,EACG,CAAA,CACW;EACA,CAAA,EAAA,CAAA;CAClB,CAAA;AAET,CAAC;AAED,UAAU,cAAc;AACxB,UAAU,UAAUC,yBAAAA;AACpB,UAAU,eAAe"}
@@ -1 +1 @@
1
- {"version":3,"file":"SunburstChart.cjs","names":["Box","ResponsiveContainer","RechartsSunburstChart","Tooltip","ChartTooltip","classes"],"sources":["../../src/SunburstChart/SunburstChart.tsx"],"sourcesContent":["import { useMemo } from 'react';\nimport {\n ResponsiveContainer,\n SunburstChart as RechartsSunburstChart,\n SunburstChartProps as RechartsSunburstChartProps,\n Tooltip,\n TooltipProps,\n} from 'recharts';\nimport {\n Box,\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n getThemeColor,\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 './SunburstChart.module.css';\n\nexport interface SunburstChartData {\n name: string;\n value?: number;\n color?: MantineColor;\n children?: SunburstChartData[];\n [key: string]: unknown;\n}\n\nexport type SunburstChartStylesNames = 'root' | ChartTooltipStylesNames;\nexport type SunburstChartCssVariables = {\n root: '--chart-stroke-color' | '--chart-size';\n};\n\nexport interface SunburstChartProps\n extends BoxProps, StylesApiProps<SunburstChartFactory>, ElementProps<'div'> {\n /** Data used to render chart */\n data: SunburstChartData[];\n\n /** Key in data object for the value @default 'value' */\n dataKey?: string;\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 `SunburstChart` component */\n sunburstChartProps?: Partial<Omit<RechartsSunburstChartProps, 'ref' | 'data' | 'dataKey'>>;\n\n /** Controls color of the sectors stroke, by default depends on color scheme */\n strokeColor?: MantineColor;\n\n /** Controls chart width and height @default 300 */\n size?: number;\n\n /** Controls the radius of the inner circle at the center of the chart @default 50 */\n innerRadius?: number;\n\n /** Gap between sectors and rings in px @default 1 */\n gap?: number;\n\n /** Angle in degrees from which the chart should start @default 0 */\n startAngle?: number;\n\n /** Angle in degrees at which the chart should end @default 360 */\n endAngle?: number;\n\n /** Determines whether value labels are displayed inside each sector @default false */\n withLabels?: boolean;\n\n /** A function to format values inside the tooltip and labels */\n valueFormatter?: (value: number) => string;\n\n /** Additional elements rendered inside `SunburstChart` component */\n children?: React.ReactNode;\n}\n\nexport type SunburstChartFactory = Factory<{\n props: SunburstChartProps;\n ref: HTMLDivElement;\n stylesNames: SunburstChartStylesNames;\n vars: SunburstChartCssVariables;\n}>;\n\nconst defaultProps = {\n dataKey: 'value',\n withTooltip: true,\n tooltipAnimationDuration: 0,\n size: 300,\n innerRadius: 50,\n gap: 1,\n startAngle: 0,\n endAngle: 360,\n} satisfies Partial<SunburstChartProps>;\n\nconst varsResolver = createVarsResolver<SunburstChartFactory>((theme, { strokeColor, size }) => ({\n root: {\n '--chart-stroke-color': strokeColor ? getThemeColor(strokeColor, theme) : undefined,\n '--chart-size': rem(size),\n },\n}));\n\nfunction resolveData(\n data: SunburstChartData[],\n theme: MantineTheme,\n dataKey: string,\n parentFill?: string\n): { resolved: any[]; total: number } {\n let total = 0;\n\n const resolved = data.map((item) => {\n const resolvedColor = item.color\n ? parseThemeColor({ color: item.color, theme }).value\n : parentFill;\n const fill = resolvedColor || undefined;\n\n const result: any = {\n ...item,\n fill,\n };\n\n if (item.children) {\n const child = resolveData(item.children, theme, dataKey, fill);\n result.children = child.resolved;\n if (result[dataKey] == null) {\n result[dataKey] = child.total;\n }\n total += child.total;\n } else {\n total += Number(item[dataKey]) || 0;\n }\n\n return result;\n });\n\n return { resolved, total };\n}\n\nexport const SunburstChart = factory<SunburstChartFactory>((_props) => {\n const props = useProps('SunburstChart', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n data,\n dataKey,\n withTooltip,\n tooltipAnimationDuration,\n tooltipProps,\n sunburstChartProps,\n strokeColor,\n size,\n innerRadius,\n gap,\n startAngle,\n endAngle,\n withLabels,\n valueFormatter,\n children,\n attributes,\n ...others\n } = props;\n\n const theme = useMantineTheme();\n\n const getStyles = useStyles<SunburstChartFactory>({\n name: 'SunburstChart',\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<SunburstChartFactory>({\n classNames,\n styles,\n props,\n });\n\n const rootData = useMemo(() => {\n const { resolved, total } = resolveData(data, theme, dataKey!);\n return {\n name: 'root',\n [dataKey!]: total,\n children: resolved,\n };\n }, [data, theme, dataKey]);\n\n return (\n <Box size={size} {...getStyles('root')} {...others}>\n <ResponsiveContainer>\n <RechartsSunburstChart\n data={rootData as any}\n dataKey={dataKey as any}\n innerRadius={innerRadius}\n padding={gap}\n ringPadding={0}\n startAngle={startAngle}\n endAngle={endAngle}\n stroke=\"var(--chart-stroke-color, var(--mantine-color-body))\"\n textOptions={\n withLabels\n ? {\n fontWeight: 'bold',\n fontSize: '.65rem',\n paintOrder: 'stroke fill',\n stroke: 'var(--chart-stroke-color, var(--mantine-color-body))',\n strokeWidth: 1,\n fill: 'var(--mantine-color-bright)',\n pointerEvents: 'none',\n }\n : { display: 'none' }\n }\n {...sunburstChartProps}\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: (item.payload as any)?.fill || '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 </RechartsSunburstChart>\n </ResponsiveContainer>\n </Box>\n );\n});\n\nSunburstChart.displayName = '@mantine/charts/SunburstChart';\nSunburstChart.classes = classes;\nSunburstChart.varsResolver = varsResolver;\n"],"mappings":";;;;;;;;AAiGA,MAAM,eAAe;CACnB,SAAS;CACT,aAAa;CACb,0BAA0B;CAC1B,MAAM;CACN,aAAa;C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AoB,oBAAA,GAAA,cAAA,qBAAA,CAA8D;EACxF;EACA;EACA;CACF,CAAC;CAED,MAAM,YAAA,GAAA,MAAA,QAAA,OAAyB;EAC7B,MAAM,EAAE,UAAU,UAAU,YAAY,MAAM,OAAO,OAAQ;EAC7D,OAAO;GACL,MAAM;IACL,UAAW;GACZ,UAAU;EACZ;CACF,GAAG;EAAC;EAAM;EAAO;CAAO,CAAC;CAEzB,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACA,cAAAA,KAAD;EAAW;EAAM,GAAI,UAAU,MAAM;EAAG,GAAI;YAC1C,iBAAA,GAAA,kBAAA,IAAA,CAACC,SAAAA,qBAAD,EAAA,UACE,iBAAA,GAAA,kBAAA,KAAA,CAACC,SAAAA,eAAD;GACE,MAAM;GACG;GACI;GACb,SAAS;GACT,aAAa;GACD;GACF;GACV,QAAO;GACP,aACE,aACI;IACE,YAAY;IACZ,UAAU;IACV,YAAY;IACZ,QAAQ;IACR,aAAa;IACb,MAAM;IACN,eAAe;GACjB,IACA,EAAE,SAAS,OAAO;GAExB,GAAI;aAtBN,CAwBG,eACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,SAAAA,SAAD;IACE,mBAAmB;IACnB,mBAAmB;IACnB,UAAU,EAAE,cACV,iBAAA,GAAA,kBAAA,IAAA,CAACC,qBAAAA,cAAD;KACE,SACE,SAAS,KAAK,UAAU;MACtB,MAAM,KAAK;MACX,OAAO,KAAK;MACZ,OAAQ,KAAK,SAAiB,QAAQ;KACxC,EAAE,KAAK,CAAC;KAEV,YAAY;KACZ,QAAQ;KACR,MAAK;KACW;KACJ;IACb,CAAA;IAEH,GAAI;GACL,CAAA,GAGF,QACoB;KACJ,CAAA;CAClB,CAAA;AAET,CAAC;AAED,cAAc,cAAc;AAC5B,cAAc,UAAUC,6BAAAA;AACxB,cAAc,eAAe"}
1
+ {"version":3,"file":"SunburstChart.cjs","names":["createVarsResolver","getThemeColor","rem","parseThemeColor","factory","useProps","useMantineTheme","useStyles","useResolvedStylesApi","useMemo","Box","ResponsiveContainer","RechartsSunburstChart","Tooltip","ChartTooltip","classes"],"sources":["../../src/SunburstChart/SunburstChart.tsx"],"sourcesContent":["import { useMemo } from 'react';\nimport {\n ResponsiveContainer,\n SunburstChart as RechartsSunburstChart,\n SunburstChartProps as RechartsSunburstChartProps,\n Tooltip,\n TooltipProps,\n} from 'recharts';\nimport {\n Box,\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n getThemeColor,\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 './SunburstChart.module.css';\n\nexport interface SunburstChartData {\n name: string;\n value?: number;\n color?: MantineColor;\n children?: SunburstChartData[];\n [key: string]: unknown;\n}\n\nexport type SunburstChartStylesNames = 'root' | ChartTooltipStylesNames;\nexport type SunburstChartCssVariables = {\n root: '--chart-stroke-color' | '--chart-size';\n};\n\nexport interface SunburstChartProps\n extends BoxProps, StylesApiProps<SunburstChartFactory>, ElementProps<'div'> {\n /** Data used to render chart */\n data: SunburstChartData[];\n\n /** Key in data object for the value @default 'value' */\n dataKey?: string;\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 `SunburstChart` component */\n sunburstChartProps?: Partial<Omit<RechartsSunburstChartProps, 'ref' | 'data' | 'dataKey'>>;\n\n /** Controls color of the sectors stroke, by default depends on color scheme */\n strokeColor?: MantineColor;\n\n /** Controls chart width and height @default 300 */\n size?: number;\n\n /** Controls the radius of the inner circle at the center of the chart @default 50 */\n innerRadius?: number;\n\n /** Gap between sectors and rings in px @default 1 */\n gap?: number;\n\n /** Angle in degrees from which the chart should start @default 0 */\n startAngle?: number;\n\n /** Angle in degrees at which the chart should end @default 360 */\n endAngle?: number;\n\n /** Determines whether value labels are displayed inside each sector @default false */\n withLabels?: boolean;\n\n /** A function to format values inside the tooltip and labels */\n valueFormatter?: (value: number) => string;\n\n /** Additional elements rendered inside `SunburstChart` component */\n children?: React.ReactNode;\n}\n\nexport type SunburstChartFactory = Factory<{\n props: SunburstChartProps;\n ref: HTMLDivElement;\n stylesNames: SunburstChartStylesNames;\n vars: SunburstChartCssVariables;\n}>;\n\nconst defaultProps = {\n dataKey: 'value',\n withTooltip: true,\n tooltipAnimationDuration: 0,\n size: 300,\n innerRadius: 50,\n gap: 1,\n startAngle: 0,\n endAngle: 360,\n} satisfies Partial<SunburstChartProps>;\n\nconst varsResolver = createVarsResolver<SunburstChartFactory>((theme, { strokeColor, size }) => ({\n root: {\n '--chart-stroke-color': strokeColor ? getThemeColor(strokeColor, theme) : undefined,\n '--chart-size': rem(size),\n },\n}));\n\nfunction resolveData(\n data: SunburstChartData[],\n theme: MantineTheme,\n dataKey: string,\n parentFill?: string\n): { resolved: any[]; total: number } {\n let total = 0;\n\n const resolved = data.map((item) => {\n const resolvedColor = item.color\n ? parseThemeColor({ color: item.color, theme }).value\n : parentFill;\n const fill = resolvedColor || undefined;\n\n const result: any = {\n ...item,\n fill,\n };\n\n if (item.children) {\n const child = resolveData(item.children, theme, dataKey, fill);\n result.children = child.resolved;\n if (result[dataKey] == null) {\n result[dataKey] = child.total;\n }\n total += child.total;\n } else {\n total += Number(item[dataKey]) || 0;\n }\n\n return result;\n });\n\n return { resolved, total };\n}\n\nexport const SunburstChart = factory<SunburstChartFactory>((_props) => {\n const props = useProps('SunburstChart', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n data,\n dataKey,\n withTooltip,\n tooltipAnimationDuration,\n tooltipProps,\n sunburstChartProps,\n strokeColor,\n size,\n innerRadius,\n gap,\n startAngle,\n endAngle,\n withLabels,\n valueFormatter,\n children,\n attributes,\n ...others\n } = props;\n\n const theme = useMantineTheme();\n\n const getStyles = useStyles<SunburstChartFactory>({\n name: 'SunburstChart',\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<SunburstChartFactory>({\n classNames,\n styles,\n props,\n });\n\n const rootData = useMemo(() => {\n const { resolved, total } = resolveData(data, theme, dataKey!);\n return {\n name: 'root',\n [dataKey!]: total,\n children: resolved,\n };\n }, [data, theme, dataKey]);\n\n return (\n <Box size={size} {...getStyles('root')} {...others}>\n <ResponsiveContainer>\n <RechartsSunburstChart\n data={rootData as any}\n dataKey={dataKey as any}\n innerRadius={innerRadius}\n padding={gap}\n ringPadding={0}\n startAngle={startAngle}\n endAngle={endAngle}\n stroke=\"var(--chart-stroke-color, var(--mantine-color-body))\"\n textOptions={\n withLabels\n ? {\n fontWeight: 'bold',\n fontSize: '.65rem',\n paintOrder: 'stroke fill',\n stroke: 'var(--chart-stroke-color, var(--mantine-color-body))',\n strokeWidth: 1,\n fill: 'var(--mantine-color-bright)',\n pointerEvents: 'none',\n }\n : { display: 'none' }\n }\n {...sunburstChartProps}\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: (item.payload as any)?.fill || '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 </RechartsSunburstChart>\n </ResponsiveContainer>\n </Box>\n );\n});\n\nSunburstChart.displayName = '@mantine/charts/SunburstChart';\nSunburstChart.classes = classes;\nSunburstChart.varsResolver = varsResolver;\n"],"mappings":";;;;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,cAAc;AAC5B,cAAc,UAAUC,6BAAAA;AACxB,cAAc,eAAe"}
@@ -1 +1 @@
1
- {"version":3,"file":"Treemap.cjs","names":["Box","ResponsiveContainer","RechartsTreemap","Tooltip","ChartTooltip","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,gBAAA,GAAA,cAAA,mBAAA,EAAmD,OAAO,EAAE,aAAa,cAAc,EAC3F,MAAM;CACJ,wBAAwB,eAAA,GAAA,cAAA,cAAA,CAA4B,aAAa,KAAK,IAAI,KAAA;CAC1E,mBAAA,GAAA,cAAA,IAAA,CAAsB,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,iBAAA,GAAA,kBAAA,K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,QAAQ,cAAc;AACtB,QAAQ,UAAUC,uBAAAA;AAClB,QAAQ,eAAe"}
1
+ {"version":3,"file":"Treemap.cjs","names":["createVarsResolver","getThemeColor","rem","parseThemeColor","isLightColor","factory","useProps","useMantineTheme","getAutoContrastValue","useStyles","useResolvedStylesApi","Box","ResponsiveContainer","RechartsTreemap","Tooltip","ChartTooltip","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,gBAAA,GAAeA,cAAAA,mBAAAA,EAAoC,OAAO,EAAE,aAAa,cAAc,EAC3F,MAAM;CACJ,wBAAwB,eAAA,GAAcC,cAAAA,cAAAA,CAAc,aAAa,KAAK,IAAI,KAAA;CAC1E,mBAAA,GAAkBC,cAAAA,IAAAA,CAAI,MAAM;AAC9B,EACF,EAAE;AAeF,SAAS,eAAe,EACtB,GACA,GACA,OACA,QACA,OACA,MACA,gBACA,qBACA,OACA,eACsB;CACtB,MAAM,OAAO,eAAe,SAAS,4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,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,QAAQ,cAAc;AACtB,QAAQ,UAAUC,uBAAAA;AAClB,QAAQ,eAAe"}
@@ -0,0 +1,189 @@
1
+ "use client";
2
+ const require_WaffleChart_module = require("./WaffleChart.module.cjs");
3
+ let _mantine_core = require("@mantine/core");
4
+ let react_jsx_runtime = require("react/jsx-runtime");
5
+ let react = require("react");
6
+ //#region packages/@mantine/charts/src/WaffleChart/WaffleChart.tsx
7
+ const defaultProps = {
8
+ rows: 10,
9
+ columns: 10,
10
+ gap: 2,
11
+ cellRadius: 0,
12
+ withTooltip: false,
13
+ withLegend: true,
14
+ legendPosition: "bottom",
15
+ fillDirection: "left-to-right"
16
+ };
17
+ const varsResolver = (0, _mantine_core.createVarsResolver)((theme, { cellRadius, emptyColor }) => ({ root: {
18
+ "--waffle-cell-radius": (0, _mantine_core.rem)(cellRadius),
19
+ "--waffle-empty-color": emptyColor ? (0, _mantine_core.getThemeColor)(emptyColor, theme) : void 0
20
+ } }));
21
+ /**
22
+ * A part-to-whole chart has no meaning for negative values, and letting them through would
23
+ * allocate more cells than the grid can hold. Non-finite values are normalized to zero as
24
+ * well – `Math.max(0, NaN)` is `NaN`, which would poison the sum and leave every segment
25
+ * without cells instead of dropping just the offending one.
26
+ */
27
+ function normalizeSegmentValue(value) {
28
+ return Number.isFinite(value) ? Math.max(0, value) : 0;
29
+ }
30
+ function allocateCells(data, gridCells, totalValue) {
31
+ const values = data.map((d) => normalizeSegmentValue(d.value));
32
+ const sum = values.reduce((acc, value) => acc + value, 0);
33
+ if (sum === 0) return Array.from({ length: gridCells }, () => ({ segmentIndex: -1 }));
34
+ const filledTarget = Math.round(sum / (totalValue != null ? Math.max(totalValue, sum) : sum) * gridCells);
35
+ const raw = values.map((value) => value / sum * filledTarget);
36
+ const floored = raw.map(Math.floor);
37
+ const remainder = filledTarget - floored.reduce((a, b) => a + b, 0);
38
+ const fractions = raw.map((v, i) => ({
39
+ i,
40
+ frac: v - floored[i]
41
+ }));
42
+ fractions.sort((a, b) => b.frac - a.frac);
43
+ for (let j = 0; j < Math.min(remainder, fractions.length); j++) floored[fractions[j].i]++;
44
+ const cells = [];
45
+ data.forEach((_, i) => {
46
+ for (let j = 0; j < floored[i] && cells.length < gridCells; j++) cells.push({ segmentIndex: i });
47
+ });
48
+ while (cells.length < gridCells) cells.push({ segmentIndex: -1 });
49
+ return cells;
50
+ }
51
+ const DEFAULT_CELL_SIZE = 20;
52
+ const WaffleChart = (0, _mantine_core.factory)((_props) => {
53
+ const props = (0, _mantine_core.useProps)("WaffleChart", defaultProps, _props);
54
+ const { classNames, className, style, styles, unstyled, vars, attributes, data, rows, columns, total, gap, cellRadius, emptyColor, withTooltip, getTooltipLabel, withLegend, legendPosition, fillDirection, size, variant, ...others } = props;
55
+ const theme = (0, _mantine_core.useMantineTheme)();
56
+ const getStyles = (0, _mantine_core.useStyles)({
57
+ name: "WaffleChart",
58
+ classes: require_WaffleChart_module.default,
59
+ props,
60
+ className,
61
+ style,
62
+ classNames,
63
+ styles,
64
+ unstyled,
65
+ attributes,
66
+ vars,
67
+ varsResolver
68
+ });
69
+ const [hoveredCell, setHoveredCell] = (0, react.useState)(null);
70
+ const [hoveredLegendIndex, setHoveredLegendIndex] = (0, react.useState)(null);
71
+ const resolvedRows = Math.max(1, Math.floor(rows));
72
+ const resolvedColumns = Math.max(1, Math.floor(columns));
73
+ const resolvedGap = Math.max(0, gap);
74
+ const totalCells = resolvedRows * resolvedColumns;
75
+ const hasSize = size != null;
76
+ const gapTotal = (resolvedColumns - 1) * resolvedGap;
77
+ const effectiveGap = hasSize && gapTotal > size && resolvedColumns > 1 ? size / (resolvedColumns - 1) : resolvedGap;
78
+ const cellSize = hasSize ? Math.max(0, (size - (resolvedColumns - 1) * effectiveGap) / resolvedColumns) : DEFAULT_CELL_SIZE;
79
+ const allocated = allocateCells(data, totalCells, total);
80
+ const cellCounts = /* @__PURE__ */ new Map();
81
+ for (const cell of allocated) if (cell.segmentIndex >= 0) cellCounts.set(cell.segmentIndex, (cellCounts.get(cell.segmentIndex) || 0) + 1);
82
+ const svgWidth = resolvedColumns * cellSize + (resolvedColumns - 1) * effectiveGap;
83
+ const svgHeight = resolvedRows * cellSize + (resolvedRows - 1) * effectiveGap;
84
+ const cellElements = allocated.map((cell, index) => {
85
+ let row;
86
+ let col;
87
+ if (fillDirection === "top-to-bottom") {
88
+ col = Math.floor(index / resolvedRows);
89
+ row = index % resolvedRows;
90
+ } else if (fillDirection === "bottom-to-top") {
91
+ col = Math.floor(index / resolvedRows);
92
+ row = resolvedRows - 1 - index % resolvedRows;
93
+ } else if (fillDirection === "right-to-left") {
94
+ row = Math.floor(index / resolvedColumns);
95
+ col = resolvedColumns - 1 - index % resolvedColumns;
96
+ } else {
97
+ row = Math.floor(index / resolvedColumns);
98
+ col = index % resolvedColumns;
99
+ }
100
+ const x = col * (cellSize + effectiveGap);
101
+ const y = row * (cellSize + effectiveGap);
102
+ const segmentIndex = cell.segmentIndex;
103
+ const isEmpty = segmentIndex < 0;
104
+ const color = isEmpty ? void 0 : (0, _mantine_core.getThemeColor)(data[segmentIndex].color, theme);
105
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("rect", {
106
+ ...getStyles("cell", { style: hoveredLegendIndex != null && segmentIndex !== hoveredLegendIndex ? { opacity: .4 } : void 0 }),
107
+ x,
108
+ y,
109
+ width: cellSize,
110
+ height: cellSize,
111
+ rx: cellRadius,
112
+ ry: cellRadius,
113
+ fill: color,
114
+ "data-empty": isEmpty || void 0,
115
+ onMouseEnter: withTooltip ? () => isEmpty ? setHoveredCell(null) : setHoveredCell({
116
+ ...data[segmentIndex],
117
+ count: cellCounts.get(segmentIndex) || 0
118
+ }) : void 0
119
+ }, index);
120
+ });
121
+ const tooltipLabel = getTooltipLabel && hoveredCell && withTooltip ? getTooltipLabel(hoveredCell) : hoveredCell?.name;
122
+ const legendItems = withLegend ? data.map((segment, index) => {
123
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
124
+ ...getStyles("legendItem", { style: hoveredLegendIndex != null && hoveredLegendIndex !== index ? { opacity: .4 } : void 0 }),
125
+ onMouseEnter: () => setHoveredLegendIndex(index),
126
+ onMouseLeave: () => setHoveredLegendIndex(null),
127
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { ...getStyles("legendSwatch", { style: { backgroundColor: (0, _mantine_core.getThemeColor)(segment.color, theme) } }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
128
+ ...getStyles("legendLabel"),
129
+ children: segment.name
130
+ })]
131
+ }, segment.key ?? index);
132
+ }) : null;
133
+ const isVertical = legendPosition === "left" || legendPosition === "right";
134
+ const segmentsLabel = data.map((segment) => `${segment.name}: ${normalizeSegmentValue(segment.value)}`).join(", ");
135
+ const segmentsTotal = data.reduce((acc, segment) => acc + normalizeSegmentValue(segment.value), 0);
136
+ const gridLabel = segmentsLabel ? `${segmentsLabel} of ${total != null ? Math.max(total, segmentsTotal) : segmentsTotal}` : "";
137
+ const hasCallerLabel = others["aria-label"] !== void 0 || others["aria-labelledby"] !== void 0;
138
+ const grid = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_mantine_core.Box, {
139
+ component: "svg",
140
+ width: svgWidth,
141
+ height: svgHeight,
142
+ role: gridLabel ? "img" : void 0,
143
+ "aria-label": gridLabel || void 0,
144
+ ...getStyles("grid"),
145
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_mantine_core.Tooltip.Floating, {
146
+ label: tooltipLabel,
147
+ disabled: !withTooltip || !hoveredCell,
148
+ position: "top",
149
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("g", {
150
+ onMouseLeave: withTooltip ? () => setHoveredCell(null) : void 0,
151
+ children: [withTooltip && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("rect", {
152
+ fill: "transparent",
153
+ width: svgWidth,
154
+ height: svgHeight
155
+ }), cellElements]
156
+ })
157
+ })
158
+ });
159
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_mantine_core.Box, {
160
+ ...getStyles("root"),
161
+ variant,
162
+ mod: {
163
+ "legend-position": withLegend ? legendPosition : void 0,
164
+ vertical: isVertical
165
+ },
166
+ role: hasCallerLabel ? "group" : void 0,
167
+ ...others,
168
+ children: [
169
+ withLegend && (legendPosition === "top" || legendPosition === "left") && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
170
+ ...getStyles("legend"),
171
+ "aria-hidden": true,
172
+ children: legendItems
173
+ }),
174
+ grid,
175
+ withLegend && (legendPosition === "bottom" || legendPosition === "right") && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
176
+ ...getStyles("legend"),
177
+ "aria-hidden": true,
178
+ children: legendItems
179
+ })
180
+ ]
181
+ });
182
+ });
183
+ WaffleChart.displayName = "@mantine/charts/WaffleChart";
184
+ WaffleChart.classes = require_WaffleChart_module.default;
185
+ WaffleChart.varsResolver = varsResolver;
186
+ //#endregion
187
+ exports.WaffleChart = WaffleChart;
188
+
189
+ //# sourceMappingURL=WaffleChart.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WaffleChart.cjs","names":["createVarsResolver","rem","getThemeColor","factory","useProps","useMantineTheme","useStyles","useState","Box","Tooltip","classes"],"sources":["../../src/WaffleChart/WaffleChart.tsx"],"sourcesContent":["import { useState } from 'react';\nimport {\n Box,\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n getThemeColor,\n MantineColor,\n rem,\n StylesApiProps,\n Tooltip,\n useMantineTheme,\n useProps,\n useStyles,\n} from '@mantine/core';\nimport classes from './WaffleChart.module.css';\n\nexport interface WaffleChartCell {\n /** Segment name */\n name: string;\n\n /** Segment value */\n value: number;\n\n /** Segment color */\n color: MantineColor;\n\n /** Unique key for the segment */\n key?: string | number;\n}\n\nexport type WaffleChartStylesNames =\n | 'root'\n | 'grid'\n | 'cell'\n | 'legend'\n | 'legendItem'\n | 'legendSwatch'\n | 'legendLabel';\n\nexport type WaffleChartCssVariables = {\n root: '--waffle-cell-radius' | '--waffle-empty-color';\n};\n\nexport interface WaffleChartProps\n extends BoxProps, StylesApiProps<WaffleChartFactory>, ElementProps<'div'> {\n /** Array of data segments with name, value, and color */\n data: WaffleChartCell[];\n\n /** Number of rows, @default 10 */\n rows?: number;\n\n /** Number of columns, @default 10 */\n columns?: number;\n\n /** Total value for the chart, determines how many cells are filled vs empty, sum of all values by default */\n total?: number;\n\n /** Gap between cells in px, @default 2 */\n gap?: number;\n\n /** Cell border radius, @default 0 */\n cellRadius?: number;\n\n /** Color of empty (unfilled) cells */\n emptyColor?: MantineColor;\n\n /** Whether to show tooltip on hover, @default false */\n withTooltip?: boolean;\n\n /** Custom tooltip label formatter */\n getTooltipLabel?: (cell: WaffleChartCell & { count: number }) => React.ReactNode;\n\n /** Whether to show legend, @default true */\n withLegend?: boolean;\n\n /** Legend position, @default 'bottom' */\n legendPosition?: 'top' | 'bottom' | 'left' | 'right';\n\n /** Fill direction, @default 'left-to-right' */\n fillDirection?: 'left-to-right' | 'right-to-left' | 'top-to-bottom' | 'bottom-to-top';\n\n /** Chart size (width), auto-calculated from columns if not set */\n size?: number;\n}\n\nexport type WaffleChartFactory = Factory<{\n props: WaffleChartProps;\n ref: HTMLDivElement;\n stylesNames: WaffleChartStylesNames;\n vars: WaffleChartCssVariables;\n}>;\n\nconst defaultProps = {\n rows: 10,\n columns: 10,\n gap: 2,\n cellRadius: 0,\n withTooltip: false,\n withLegend: true,\n legendPosition: 'bottom',\n fillDirection: 'left-to-right',\n} satisfies Partial<WaffleChartProps>;\n\nconst varsResolver = createVarsResolver<WaffleChartFactory>(\n (theme, { cellRadius, emptyColor }) => ({\n root: {\n '--waffle-cell-radius': rem(cellRadius),\n '--waffle-empty-color': emptyColor ? getThemeColor(emptyColor, theme) : undefined,\n },\n })\n);\n\ninterface AllocatedCell {\n segmentIndex: number;\n}\n\n/**\n * A part-to-whole chart has no meaning for negative values, and letting them through would\n * allocate more cells than the grid can hold. Non-finite values are normalized to zero as\n * well – `Math.max(0, NaN)` is `NaN`, which would poison the sum and leave every segment\n * without cells instead of dropping just the offending one.\n */\nfunction normalizeSegmentValue(value: number) {\n return Number.isFinite(value) ? Math.max(0, value) : 0;\n}\n\nfunction allocateCells(\n data: WaffleChartCell[],\n gridCells: number,\n totalValue?: number\n): AllocatedCell[] {\n const values = data.map((d) => normalizeSegmentValue(d.value));\n const sum = values.reduce((acc, value) => acc + value, 0);\n\n if (sum === 0) {\n return Array.from({ length: gridCells }, () => ({ segmentIndex: -1 }));\n }\n\n const denominator = totalValue != null ? Math.max(totalValue, sum) : sum;\n const filledTarget = Math.round((sum / denominator) * gridCells);\n const raw = values.map((value) => (value / sum) * filledTarget);\n const floored = raw.map(Math.floor);\n const remainder = filledTarget - floored.reduce((a, b) => a + b, 0);\n\n const fractions = raw.map((v, i) => ({ i, frac: v - floored[i] }));\n fractions.sort((a, b) => b.frac - a.frac);\n for (let j = 0; j < Math.min(remainder, fractions.length); j++) {\n floored[fractions[j].i]++;\n }\n\n const cells: AllocatedCell[] = [];\n data.forEach((_, i) => {\n for (let j = 0; j < floored[i] && cells.length < gridCells; j++) {\n cells.push({ segmentIndex: i });\n }\n });\n\n while (cells.length < gridCells) {\n cells.push({ segmentIndex: -1 });\n }\n\n return cells;\n}\n\nconst DEFAULT_CELL_SIZE = 20;\n\nexport const WaffleChart = factory<WaffleChartFactory>((_props) => {\n const props = useProps('WaffleChart', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n attributes,\n data,\n rows,\n columns,\n total,\n gap,\n cellRadius,\n emptyColor,\n withTooltip,\n getTooltipLabel,\n withLegend,\n legendPosition,\n fillDirection,\n size,\n variant,\n ...others\n } = props;\n\n const theme = useMantineTheme();\n\n const getStyles = useStyles<WaffleChartFactory>({\n name: 'WaffleChart',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const [hoveredCell, setHoveredCell] = useState<(WaffleChartCell & { count: number }) | null>(\n null\n );\n const [hoveredLegendIndex, setHoveredLegendIndex] = useState<number | null>(null);\n\n const resolvedRows = Math.max(1, Math.floor(rows!));\n const resolvedColumns = Math.max(1, Math.floor(columns!));\n const resolvedGap = Math.max(0, gap!);\n\n const totalCells = resolvedRows * resolvedColumns;\n\n // `size` is the total width of the grid, gaps included. When the gaps alone would exceed\n // it, the gap shrinks too – clamping only the cell size would render a grid wider than\n // the caller asked for. `size != null` rather than a truthiness check so `size={0}` is\n // honored instead of silently falling back to the default cell size.\n const hasSize = size != null;\n const gapTotal = (resolvedColumns - 1) * resolvedGap;\n const effectiveGap =\n hasSize && gapTotal > size! && resolvedColumns > 1\n ? size! / (resolvedColumns - 1)\n : resolvedGap;\n const cellSize = hasSize\n ? Math.max(0, (size! - (resolvedColumns - 1) * effectiveGap) / resolvedColumns)\n : DEFAULT_CELL_SIZE;\n const allocated = allocateCells(data, totalCells, total);\n\n const cellCounts = new Map<number, number>();\n for (const cell of allocated) {\n if (cell.segmentIndex >= 0) {\n cellCounts.set(cell.segmentIndex, (cellCounts.get(cell.segmentIndex) || 0) + 1);\n }\n }\n\n const svgWidth = resolvedColumns * cellSize + (resolvedColumns - 1) * effectiveGap;\n const svgHeight = resolvedRows * cellSize + (resolvedRows - 1) * effectiveGap;\n\n const cellElements = allocated.map((cell, index) => {\n let row: number;\n let col: number;\n\n if (fillDirection === 'top-to-bottom') {\n col = Math.floor(index / resolvedRows);\n row = index % resolvedRows;\n } else if (fillDirection === 'bottom-to-top') {\n col = Math.floor(index / resolvedRows);\n row = resolvedRows - 1 - (index % resolvedRows);\n } else if (fillDirection === 'right-to-left') {\n row = Math.floor(index / resolvedColumns);\n col = resolvedColumns - 1 - (index % resolvedColumns);\n } else {\n row = Math.floor(index / resolvedColumns);\n col = index % resolvedColumns;\n }\n\n const x = col * (cellSize + effectiveGap);\n const y = row * (cellSize + effectiveGap);\n const segmentIndex = cell.segmentIndex;\n const isEmpty = segmentIndex < 0;\n const color = isEmpty ? undefined : getThemeColor(data[segmentIndex].color, theme);\n\n const dimmed = hoveredLegendIndex != null && segmentIndex !== hoveredLegendIndex;\n\n return (\n <rect\n key={index}\n {...getStyles('cell', {\n style: dimmed ? { opacity: 0.4 } : undefined,\n })}\n x={x}\n y={y}\n width={cellSize}\n height={cellSize}\n rx={cellRadius}\n ry={cellRadius}\n fill={color}\n data-empty={isEmpty || undefined}\n onMouseEnter={\n withTooltip\n ? () =>\n isEmpty\n ? setHoveredCell(null)\n : setHoveredCell({\n ...data[segmentIndex],\n count: cellCounts.get(segmentIndex) || 0,\n })\n : undefined\n }\n />\n );\n });\n\n const tooltipLabel =\n getTooltipLabel && hoveredCell && withTooltip\n ? getTooltipLabel(hoveredCell)\n : hoveredCell?.name;\n\n const legendItems = withLegend\n ? data.map((segment, index) => {\n const legendDimmed = hoveredLegendIndex != null && hoveredLegendIndex !== index;\n\n return (\n <div\n key={segment.key ?? index}\n {...getStyles('legendItem', {\n style: legendDimmed ? { opacity: 0.4 } : undefined,\n })}\n onMouseEnter={() => setHoveredLegendIndex(index)}\n onMouseLeave={() => setHoveredLegendIndex(null)}\n >\n <span\n {...getStyles('legendSwatch', {\n style: { backgroundColor: getThemeColor(segment.color, theme) },\n })}\n />\n <span {...getStyles('legendLabel')}>{segment.name}</span>\n </div>\n );\n })\n : null;\n\n const isVertical = legendPosition === 'left' || legendPosition === 'right';\n\n // The cells carry no accessible information on their own, and the legend (when shown)\n // exposes segment names but not their values – this gives assistive tech one readable\n // summary of the data regardless of whether the legend is rendered. Values are reported\n // as they are drawn, so a clamped negative or non-finite value is announced as 0.\n const segmentsLabel = data\n .map((segment) => `${segment.name}: ${normalizeSegmentValue(segment.value)}`)\n .join(', ');\n\n // The denominator is what makes the filled/empty split readable – without it a listener\n // hears \"Completed: 68\" while a sighted user sees 68 of 100 cells filled.\n const segmentsTotal = data.reduce(\n (acc, segment) => acc + normalizeSegmentValue(segment.value),\n 0\n );\n const effectiveTotal = total != null ? Math.max(total, segmentsTotal) : segmentsTotal;\n const gridLabel = segmentsLabel ? `${segmentsLabel} of ${effectiveTotal}` : '';\n\n // A plain div has an implicit `generic` role, which cannot carry an accessible name, so\n // a caller-supplied label would be dropped. Promoting the root to a group lets their\n // label describe the chart while the grid keeps the generated data summary.\n const hasCallerLabel =\n others['aria-label'] !== undefined || others['aria-labelledby'] !== undefined;\n\n const grid = (\n <Box\n component=\"svg\"\n width={svgWidth}\n height={svgHeight}\n role={gridLabel ? 'img' : undefined}\n aria-label={gridLabel || undefined}\n {...getStyles('grid')}\n >\n <Tooltip.Floating label={tooltipLabel} disabled={!withTooltip || !hoveredCell} position=\"top\">\n <g onMouseLeave={withTooltip ? () => setHoveredCell(null) : undefined}>\n {withTooltip && <rect fill=\"transparent\" width={svgWidth} height={svgHeight} />}\n {cellElements}\n </g>\n </Tooltip.Floating>\n </Box>\n );\n\n return (\n <Box\n {...getStyles('root')}\n variant={variant}\n mod={{ 'legend-position': withLegend ? legendPosition : undefined, vertical: isVertical }}\n role={hasCallerLabel ? 'group' : undefined}\n {...others}\n >\n {withLegend && (legendPosition === 'top' || legendPosition === 'left') && (\n <div {...getStyles('legend')} aria-hidden>\n {legendItems}\n </div>\n )}\n {grid}\n {withLegend && (legendPosition === 'bottom' || legendPosition === 'right') && (\n <div {...getStyles('legend')} aria-hidden>\n {legendItems}\n </div>\n )}\n </Box>\n );\n});\n\nWaffleChart.displayName = '@mantine/charts/WaffleChart';\nWaffleChart.classes = classes;\nWaffleChart.varsResolver = varsResolver;\n"],"mappings":";;;;;;AA+FA,MAAM,eAAe;CACnB,MAAM;CACN,SAAS;CACT,KAAK;CACL,YAAY;CACZ,aAAa;CACb,YAAY;CACZ,gBAAgB;CAChB,eAAe;AACjB;AAEA,MAAM,gBAAA,GAAeA,cAA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AAA,GAAA,kBAAA,IAAA,CAACC,cAAAA,QAAQ,UAAT;GAAkB,OAAO;GAAc,UAAU,CAAC,eAAe,CAAC;GAAa,UAAS;GACtF,UAAA,iBAAA,GAAA,kBAAA,KAAA,CAAC,KAAD;IAAG,cAAc,oBAAoB,eAAe,IAAI,IAAI,KAAA;IAA5D,UAAA,CACG,eAAe,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;KAAM,MAAK;KAAc,OAAO;KAAU,QAAQ;IAAY,CAAA,GAC7E,YACA;;EACa,CAAA;CACf,CAAA;CAGP,OACE,iBAAA,GAAA,kBAAA,KAAA,CAACD,cAAAA,KAAD;EACE,GAAI,UAAU,MAAM;EACX;EACT,KAAK;GAAE,mBAAmB,aAAa,iBAAiB,KAAA;GAAW,UAAU;EAAW;EACxF,MAAM,iBAAiB,UAAU,KAAA;EACjC,GAAI;EALN,UAAA;GAOG,eAAe,mBAAmB,SAAS,mBAAmB,WAC7D,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;IAAK,GAAI,UAAU,QAAQ;IAAG,eAAA;IAC3B,UAAA;GACE,CAAA;GAEN;GACA,eAAe,mBAAmB,YAAY,mBAAmB,YAChE,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;IAAK,GAAI,UAAU,QAAQ;IAAG,eAAA;IAC3B,UAAA;GACE,CAAA;EAEJ;;AAET,CAAC;AAED,YAAY,cAAc;AAC1B,YAAY,UAAUE,2BAAAA;AACtB,YAAY,eAAe"}
@@ -0,0 +1,14 @@
1
+ "use client";
2
+ //#region packages/@mantine/charts/src/WaffleChart/WaffleChart.module.css
3
+ var WaffleChart_module_default = {
4
+ "root": "m_16f4c1f4",
5
+ "cell": "m_16edca74",
6
+ "legend": "m_21fe489f",
7
+ "legendItem": "m_f27dd052",
8
+ "legendSwatch": "m_5b8415bb",
9
+ "legendLabel": "m_5d5dd195"
10
+ };
11
+ //#endregion
12
+ exports.default = WaffleChart_module_default;
13
+
14
+ //# sourceMappingURL=WaffleChart.module.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WaffleChart.module.cjs","names":[],"sources":["../../src/WaffleChart/WaffleChart.module.css"],"sourcesContent":[".root {\n display: inline-flex;\n flex-direction: column;\n align-items: center;\n gap: var(--mantine-spacing-sm);\n\n &[data-vertical] {\n flex-direction: row;\n }\n}\n\n.cell {\n rx: var(--waffle-cell-radius);\n\n &[data-empty] {\n fill: var(--waffle-empty-color, var(--mantine-color-default-border));\n }\n}\n\n.legend {\n display: flex;\n flex-wrap: wrap;\n\n [data-vertical] > & {\n flex-direction: column;\n }\n}\n\n.legendItem {\n display: flex;\n align-items: center;\n gap: calc(var(--mantine-spacing-xs) / 2);\n cursor: default;\n padding: calc(var(--mantine-spacing-xs) / 2) calc(var(--mantine-spacing-sm) / 2);\n}\n\n.legendSwatch {\n display: block;\n width: rem(12px);\n height: rem(12px);\n border-radius: var(--waffle-cell-radius, rem(2px));\n flex-shrink: 0;\n}\n\n.legendLabel {\n font-size: var(--mantine-font-size-sm);\n color: var(--mantine-color-text);\n line-height: 1;\n}\n"],"mappings":""}
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
16
16
  }
17
17
  return to;
18
18
  };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
20
20
  value: mod,
21
21
  enumerable: true
22
22
  }) : target, mod));
package/cjs/index.cjs CHANGED
@@ -14,6 +14,7 @@ const require_RadarChart = require("./RadarChart/RadarChart.cjs");
14
14
  const require_ScatterChart = require("./ScatterChart/ScatterChart.cjs");
15
15
  const require_BubbleChart = require("./BubbleChart/BubbleChart.cjs");
16
16
  const require_CompositeChart = require("./CompositeChart/CompositeChart.cjs");
17
+ const require_CandlestickChart = require("./CandlestickChart/CandlestickChart.cjs");
17
18
  const require_RadialBarChart = require("./RadialBarChart/RadialBarChart.cjs");
18
19
  const require_FunnelChart = require("./FunnelChart/FunnelChart.cjs");
19
20
  const require_Heatmap = require("./Heatmap/Heatmap.cjs");
@@ -22,20 +23,26 @@ const require_Treemap = require("./Treemap/Treemap.cjs");
22
23
  const require_SankeyChart = require("./SankeyChart/SankeyChart.cjs");
23
24
  const require_SunburstChart = require("./SunburstChart/SunburstChart.cjs");
24
25
  const require_BulletChart = require("./BulletChart/BulletChart.cjs");
26
+ const require_GaugeChart = require("./GaugeChart/GaugeChart.cjs");
27
+ const require_WaffleChart = require("./WaffleChart/WaffleChart.cjs");
28
+ const require_MatrixChart = require("./MatrixChart/MatrixChart.cjs");
25
29
  exports.AreaChart = require_AreaChart.AreaChart;
26
30
  exports.AreaGradient = require_AreaGradient.AreaGradient;
27
31
  exports.BarChart = require_BarChart.BarChart;
28
32
  exports.BarsList = require_BarsList.BarsList;
29
33
  exports.BubbleChart = require_BubbleChart.BubbleChart;
30
34
  exports.BulletChart = require_BulletChart.BulletChart;
35
+ exports.CandlestickChart = require_CandlestickChart.CandlestickChart;
31
36
  exports.ChartBrush = require_ChartBrush.ChartBrush;
32
37
  exports.ChartLegend = require_ChartLegend.ChartLegend;
33
38
  exports.ChartTooltip = require_ChartTooltip.ChartTooltip;
34
39
  exports.CompositeChart = require_CompositeChart.CompositeChart;
35
40
  exports.DonutChart = require_DonutChart.DonutChart;
36
41
  exports.FunnelChart = require_FunnelChart.FunnelChart;
42
+ exports.GaugeChart = require_GaugeChart.GaugeChart;
37
43
  exports.Heatmap = require_Heatmap.Heatmap;
38
44
  exports.LineChart = require_LineChart.LineChart;
45
+ exports.MatrixChart = require_MatrixChart.MatrixChart;
39
46
  exports.PieChart = require_PieChart.PieChart;
40
47
  exports.RadarChart = require_RadarChart.RadarChart;
41
48
  exports.RadialBarChart = require_RadialBarChart.RadialBarChart;
@@ -44,6 +51,7 @@ exports.ScatterChart = require_ScatterChart.ScatterChart;
44
51
  exports.Sparkline = require_Sparkline.Sparkline;
45
52
  exports.SunburstChart = require_SunburstChart.SunburstChart;
46
53
  exports.Treemap = require_Treemap.Treemap;
54
+ exports.WaffleChart = require_WaffleChart.WaffleChart;
47
55
  exports.getFilteredChartLegendPayload = require_ChartLegend.getFilteredChartLegendPayload;
48
56
  exports.getFilteredChartTooltipPayload = require_ChartTooltip.getFilteredChartTooltipPayload;
49
57
  exports.getSplitOffset = require_get_split_offset.getSplitOffset;
@@ -1 +1 @@
1
- {"version":3,"file":"get-pie-chart-data.cjs","names":[],"sources":["../../../src/utils/get-pie-chart-data/get-pie-chart-data.ts"],"sourcesContent":["import { getThemeColor, MantineColor, MantineTheme } from '@mantine/core';\n\ninterface PieChartDataItem {\n color: MantineColor;\n [key: string]: any;\n}\n\ninterface GetPieChartDataInput<T extends PieChartDataItem> {\n data: T[];\n theme: MantineTheme;\n strokeWidth: number | undefined;\n highlightedIndex: number | null;\n cellProps:\n | ((item: T) => Partial<Omit<React.SVGProps<SVGElement>, 'ref'>>)\n | Partial<Omit<React.SVGProps<SVGElement>, 'ref'>>\n | undefined;\n}\n\nexport function getPieChartData<T extends PieChartDataItem>({\n data,\n theme,\n strokeWidth,\n highlightedIndex,\n cellProps,\n}: GetPieChartDataInput<T>) {\n return data.map((item, index) => ({\n ...item,\n __segmentIndex: index,\n fill: getThemeColor(item.color, theme),\n stroke: 'var(--chart-stroke-color, var(--mantine-color-body))',\n strokeWidth,\n ...(typeof cellProps === 'function' ? cellProps(item) : cellProps),\n ...(highlightedIndex !== null ? { fillOpacity: highlightedIndex === index ? 1 : 0.2 } : null),\n }));\n}\n"],"mappings":";;;AAkBA,SAAgB,gBAA4C,EAC1D,MACA,OACA,aACA,kBACA,aAC0B;CAC1B,OAAO,KAAK,KAAK,MAAM,WAAW;EAChC,GAAG;EACH,gBAAgB;EAChB,OAAA,GAAA,cAAA,cAAA,CAAoB,KAAK,OAAO,KAAK;EACrC,QAAQ;EACR;EACA,GAAI,OAAO,cAAc,aAAa,UAAU,IAAI,IAAI;EACxD,GAAI,qBAAqB,OAAO,EAAE,aAAa,qBAAqB,QAAQ,IAAI,GAAI,IAAI;CAC1F,EAAE;AACJ"}
1
+ {"version":3,"file":"get-pie-chart-data.cjs","names":["getThemeColor"],"sources":["../../../src/utils/get-pie-chart-data/get-pie-chart-data.ts"],"sourcesContent":["import { getThemeColor, MantineColor, MantineTheme } from '@mantine/core';\n\ninterface PieChartDataItem {\n color: MantineColor;\n [key: string]: any;\n}\n\ninterface GetPieChartDataInput<T extends PieChartDataItem> {\n data: T[];\n theme: MantineTheme;\n strokeWidth: number | undefined;\n highlightedIndex: number | null;\n cellProps:\n | ((item: T) => Partial<Omit<React.SVGProps<SVGElement>, 'ref'>>)\n | Partial<Omit<React.SVGProps<SVGElement>, 'ref'>>\n | undefined;\n}\n\nexport function getPieChartData<T extends PieChartDataItem>({\n data,\n theme,\n strokeWidth,\n highlightedIndex,\n cellProps,\n}: GetPieChartDataInput<T>) {\n return data.map((item, index) => ({\n ...item,\n __segmentIndex: index,\n fill: getThemeColor(item.color, theme),\n stroke: 'var(--chart-stroke-color, var(--mantine-color-body))',\n strokeWidth,\n ...(typeof cellProps === 'function' ? cellProps(item) : cellProps),\n ...(highlightedIndex !== null ? { fillOpacity: highlightedIndex === index ? 1 : 0.2 } : null),\n }));\n}\n"],"mappings":";;;AAkBA,SAAgB,gBAA4C,EAC1D,MACA,OACA,aACA,kBACA,aAC0B;CAC1B,OAAO,KAAK,KAAK,MAAM,WAAW;EAChC,GAAG;EACH,gBAAgB;EAChB,OAAA,GAAMA,cAAAA,cAAAA,CAAc,KAAK,OAAO,KAAK;EACrC,QAAQ;EACR;EACA,GAAI,OAAO,cAAc,aAAa,UAAU,IAAI,IAAI;EACxD,GAAI,qBAAqB,OAAO,EAAE,aAAa,qBAAqB,QAAQ,IAAI,GAAI,IAAI;CAC1F,EAAE;AACJ"}