@semcore/d3-chart 17.3.1 → 18.0.0-prerelease.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/lib/cjs/Area.js +11 -11
- package/lib/cjs/Axis.js +55 -58
- package/lib/cjs/Axis.js.map +1 -1
- package/lib/cjs/Bar.js +16 -16
- package/lib/cjs/Bubble.js +14 -14
- package/lib/cjs/CompactHorizontalBar.js +16 -16
- package/lib/cjs/Donut.js +9 -9
- package/lib/cjs/Dots.js +14 -11
- package/lib/cjs/Dots.js.map +1 -1
- package/lib/cjs/HorizontalBar.js +16 -16
- package/lib/cjs/Hover.js +158 -39
- package/lib/cjs/Hover.js.map +1 -1
- package/lib/cjs/Line.js +9 -9
- package/lib/cjs/Plot.js +6 -4
- package/lib/cjs/Plot.js.map +1 -1
- package/lib/cjs/Radar.js +19 -19
- package/lib/cjs/RadialTree.js +12 -12
- package/lib/cjs/Reference.js +12 -12
- package/lib/cjs/ScatterPlot.js +9 -9
- package/lib/cjs/Tooltip.js +20 -11
- package/lib/cjs/Tooltip.js.map +1 -1
- package/lib/cjs/Venn.js +9 -9
- package/lib/cjs/a11y/PlotA11yModule.js +2 -2
- package/lib/cjs/a11y/PlotA11yView.js +2 -2
- package/lib/cjs/component/Chart/AbstractChart.js +139 -50
- package/lib/cjs/component/Chart/AbstractChart.js.map +1 -1
- package/lib/cjs/component/Chart/AbstractChart.type.js.map +1 -1
- package/lib/cjs/component/Chart/AreaChart.js +12 -10
- package/lib/cjs/component/Chart/AreaChart.js.map +1 -1
- package/lib/cjs/component/Chart/AreaChart.type.js.map +1 -1
- package/lib/cjs/component/Chart/BarChart.js +9 -7
- package/lib/cjs/component/Chart/BarChart.js.map +1 -1
- package/lib/cjs/component/Chart/BarChart.type.js.map +1 -1
- package/lib/cjs/component/Chart/BubbleChart.js +21 -8
- package/lib/cjs/component/Chart/BubbleChart.js.map +1 -1
- package/lib/cjs/component/Chart/BubbleChart.type.js.map +1 -1
- package/lib/cjs/component/Chart/CigaretteChart.js +33 -30
- package/lib/cjs/component/Chart/CigaretteChart.js.map +1 -1
- package/lib/cjs/component/Chart/CigaretteChart.type.js.map +1 -1
- package/lib/cjs/component/Chart/CompactHorizontalBarChart.js +2 -1
- package/lib/cjs/component/Chart/CompactHorizontalBarChart.js.map +1 -1
- package/lib/cjs/component/Chart/CompactHorizontalBarChart.type.js.map +1 -1
- package/lib/cjs/component/Chart/DonutChart.js +5 -4
- package/lib/cjs/component/Chart/DonutChart.js.map +1 -1
- package/lib/cjs/component/Chart/DonutChart.type.js.map +1 -1
- package/lib/cjs/component/Chart/HistogramChart.js +6 -4
- package/lib/cjs/component/Chart/HistogramChart.js.map +1 -1
- package/lib/cjs/component/Chart/HistogramChart.type.js.map +1 -1
- package/lib/cjs/component/Chart/LineChart.js +9 -7
- package/lib/cjs/component/Chart/LineChart.js.map +1 -1
- package/lib/cjs/component/Chart/LineChart.type.js.map +1 -1
- package/lib/cjs/component/Chart/RadarChart.js +3 -2
- package/lib/cjs/component/Chart/RadarChart.js.map +1 -1
- package/lib/cjs/component/Chart/RadarChart.type.js.map +1 -1
- package/lib/cjs/component/Chart/ScatterPlotChart.js +19 -7
- package/lib/cjs/component/Chart/ScatterPlotChart.js.map +1 -1
- package/lib/cjs/component/Chart/ScatterPlotChart.type.js.map +1 -1
- package/lib/cjs/component/Chart/VennChart.js +6 -5
- package/lib/cjs/component/Chart/VennChart.js.map +1 -1
- package/lib/cjs/component/Chart/VennChart.type.js.map +1 -1
- package/lib/cjs/component/ChartLegend/BaseLegend.js +4 -2
- package/lib/cjs/component/ChartLegend/BaseLegend.js.map +1 -1
- package/lib/cjs/component/ChartLegend/BaseLegend.type.js.map +1 -1
- package/lib/cjs/component/ChartLegend/LegendFlex/LegendFlex.js +4 -4
- package/lib/cjs/component/ChartLegend/LegendFlex/legend-flex.shadow.css +2 -2
- package/lib/cjs/component/ChartLegend/LegendItem/LegendItem.js +23 -18
- package/lib/cjs/component/ChartLegend/LegendItem/LegendItem.js.map +1 -1
- package/lib/cjs/component/ChartLegend/LegendItem/LegendItem.type.js +1 -1
- package/lib/cjs/component/ChartLegend/LegendItem/LegendItem.type.js.map +1 -1
- package/lib/cjs/component/ChartLegend/LegendItem/legend-item.shadow.css +16 -40
- package/lib/cjs/component/ChartLegend/LegendTable/LegendTable.js +12 -8
- package/lib/cjs/component/ChartLegend/LegendTable/LegendTable.js.map +1 -1
- package/lib/cjs/component/ChartLegend/LegendTable/LegendTable.type.js.map +1 -1
- package/lib/cjs/component/ChartLegend/LegendTable/legend-table.shadow.css +6 -2
- package/lib/cjs/style/abstract-chart.shadow.css +31 -1
- package/lib/cjs/style/area.shadow.css +6 -5
- package/lib/cjs/style/axis.shadow.css +2 -2
- package/lib/cjs/style/bar.shadow.css +7 -7
- package/lib/cjs/style/bubble.shadow.css +4 -4
- package/lib/cjs/style/donut.shadow.css +3 -3
- package/lib/cjs/style/dot.shadow.css +9 -3
- package/lib/cjs/style/hover.shadow.css +19 -1
- package/lib/cjs/style/line.shadow.css +4 -4
- package/lib/cjs/style/radar.shadow.css +5 -5
- package/lib/cjs/style/radial-tree.shadow.css +3 -3
- package/lib/cjs/style/reference.shadow.css +1 -1
- package/lib/cjs/style/scatterplot.shadow.css +1 -1
- package/lib/cjs/style/tooltip.shadow.css +23 -14
- package/lib/cjs/style/venn.shadow.css +3 -3
- package/lib/cjs/types/Hover.d.js.map +1 -1
- package/lib/cjs/utils/TextMeasurer.js +33 -0
- package/lib/cjs/utils/TextMeasurer.js.map +1 -0
- package/lib/es6/Area.js +11 -11
- package/lib/es6/Axis.js +55 -57
- package/lib/es6/Axis.js.map +1 -1
- package/lib/es6/Bar.js +16 -16
- package/lib/es6/Bubble.js +14 -14
- package/lib/es6/CompactHorizontalBar.js +16 -16
- package/lib/es6/Donut.js +9 -9
- package/lib/es6/Dots.js +14 -11
- package/lib/es6/Dots.js.map +1 -1
- package/lib/es6/HorizontalBar.js +16 -16
- package/lib/es6/Hover.js +158 -39
- package/lib/es6/Hover.js.map +1 -1
- package/lib/es6/Line.js +9 -9
- package/lib/es6/Plot.js +6 -4
- package/lib/es6/Plot.js.map +1 -1
- package/lib/es6/Radar.js +19 -19
- package/lib/es6/RadialTree.js +12 -12
- package/lib/es6/Reference.js +12 -12
- package/lib/es6/ScatterPlot.js +9 -9
- package/lib/es6/Tooltip.js +20 -11
- package/lib/es6/Tooltip.js.map +1 -1
- package/lib/es6/Venn.js +9 -9
- package/lib/es6/a11y/PlotA11yModule.js +2 -2
- package/lib/es6/a11y/PlotA11yView.js +2 -2
- package/lib/es6/component/Chart/AbstractChart.js +136 -48
- package/lib/es6/component/Chart/AbstractChart.js.map +1 -1
- package/lib/es6/component/Chart/AbstractChart.type.js.map +1 -1
- package/lib/es6/component/Chart/AreaChart.js +12 -10
- package/lib/es6/component/Chart/AreaChart.js.map +1 -1
- package/lib/es6/component/Chart/AreaChart.type.js.map +1 -1
- package/lib/es6/component/Chart/BarChart.js +9 -7
- package/lib/es6/component/Chart/BarChart.js.map +1 -1
- package/lib/es6/component/Chart/BarChart.type.js.map +1 -1
- package/lib/es6/component/Chart/BubbleChart.js +22 -9
- package/lib/es6/component/Chart/BubbleChart.js.map +1 -1
- package/lib/es6/component/Chart/BubbleChart.type.js.map +1 -1
- package/lib/es6/component/Chart/CigaretteChart.js +33 -30
- package/lib/es6/component/Chart/CigaretteChart.js.map +1 -1
- package/lib/es6/component/Chart/CigaretteChart.type.js.map +1 -1
- package/lib/es6/component/Chart/CompactHorizontalBarChart.js +2 -1
- package/lib/es6/component/Chart/CompactHorizontalBarChart.js.map +1 -1
- package/lib/es6/component/Chart/CompactHorizontalBarChart.type.js.map +1 -1
- package/lib/es6/component/Chart/DonutChart.js +5 -4
- package/lib/es6/component/Chart/DonutChart.js.map +1 -1
- package/lib/es6/component/Chart/DonutChart.type.js.map +1 -1
- package/lib/es6/component/Chart/HistogramChart.js +6 -4
- package/lib/es6/component/Chart/HistogramChart.js.map +1 -1
- package/lib/es6/component/Chart/HistogramChart.type.js.map +1 -1
- package/lib/es6/component/Chart/LineChart.js +9 -7
- package/lib/es6/component/Chart/LineChart.js.map +1 -1
- package/lib/es6/component/Chart/LineChart.type.js.map +1 -1
- package/lib/es6/component/Chart/RadarChart.js +3 -2
- package/lib/es6/component/Chart/RadarChart.js.map +1 -1
- package/lib/es6/component/Chart/RadarChart.type.js.map +1 -1
- package/lib/es6/component/Chart/ScatterPlotChart.js +20 -8
- package/lib/es6/component/Chart/ScatterPlotChart.js.map +1 -1
- package/lib/es6/component/Chart/ScatterPlotChart.type.js.map +1 -1
- package/lib/es6/component/Chart/VennChart.js +6 -5
- package/lib/es6/component/Chart/VennChart.js.map +1 -1
- package/lib/es6/component/Chart/VennChart.type.js.map +1 -1
- package/lib/es6/component/ChartLegend/BaseLegend.js +4 -2
- package/lib/es6/component/ChartLegend/BaseLegend.js.map +1 -1
- package/lib/es6/component/ChartLegend/BaseLegend.type.js.map +1 -1
- package/lib/es6/component/ChartLegend/LegendFlex/LegendFlex.js +4 -4
- package/lib/es6/component/ChartLegend/LegendFlex/legend-flex.shadow.css +2 -2
- package/lib/es6/component/ChartLegend/LegendItem/LegendItem.js +23 -18
- package/lib/es6/component/ChartLegend/LegendItem/LegendItem.js.map +1 -1
- package/lib/es6/component/ChartLegend/LegendItem/LegendItem.type.js +1 -1
- package/lib/es6/component/ChartLegend/LegendItem/LegendItem.type.js.map +1 -1
- package/lib/es6/component/ChartLegend/LegendItem/legend-item.shadow.css +16 -40
- package/lib/es6/component/ChartLegend/LegendTable/LegendTable.js +12 -8
- package/lib/es6/component/ChartLegend/LegendTable/LegendTable.js.map +1 -1
- package/lib/es6/component/ChartLegend/LegendTable/LegendTable.type.js.map +1 -1
- package/lib/es6/component/ChartLegend/LegendTable/legend-table.shadow.css +6 -2
- package/lib/es6/style/abstract-chart.shadow.css +31 -1
- package/lib/es6/style/area.shadow.css +6 -5
- package/lib/es6/style/axis.shadow.css +2 -2
- package/lib/es6/style/bar.shadow.css +7 -7
- package/lib/es6/style/bubble.shadow.css +4 -4
- package/lib/es6/style/donut.shadow.css +3 -3
- package/lib/es6/style/dot.shadow.css +9 -3
- package/lib/es6/style/hover.shadow.css +19 -1
- package/lib/es6/style/line.shadow.css +4 -4
- package/lib/es6/style/radar.shadow.css +5 -5
- package/lib/es6/style/radial-tree.shadow.css +3 -3
- package/lib/es6/style/reference.shadow.css +1 -1
- package/lib/es6/style/scatterplot.shadow.css +1 -1
- package/lib/es6/style/tooltip.shadow.css +23 -14
- package/lib/es6/style/venn.shadow.css +3 -3
- package/lib/es6/types/Hover.d.js.map +1 -1
- package/lib/es6/utils/TextMeasurer.js +25 -0
- package/lib/es6/utils/TextMeasurer.js.map +1 -0
- package/lib/esm/Area.mjs +12 -12
- package/lib/esm/Axis.mjs +56 -58
- package/lib/esm/Bar.mjs +17 -17
- package/lib/esm/Bubble.mjs +15 -15
- package/lib/esm/CompactHorizontalBar.mjs +17 -17
- package/lib/esm/Donut.mjs +10 -10
- package/lib/esm/Dots.mjs +15 -12
- package/lib/esm/HorizontalBar.mjs +17 -17
- package/lib/esm/Hover.mjs +157 -40
- package/lib/esm/Line.mjs +10 -10
- package/lib/esm/Plot.mjs +7 -5
- package/lib/esm/Radar.mjs +20 -20
- package/lib/esm/RadialTree.mjs +13 -13
- package/lib/esm/Reference.mjs +13 -13
- package/lib/esm/ScatterPlot.mjs +10 -10
- package/lib/esm/Tooltip.mjs +21 -12
- package/lib/esm/Venn.mjs +10 -10
- package/lib/esm/a11y/PlotA11yModule.mjs +3 -3
- package/lib/esm/a11y/PlotA11yView.mjs +3 -3
- package/lib/esm/component/Chart/AbstractChart.mjs +150 -54
- package/lib/esm/component/Chart/AreaChart.mjs +12 -10
- package/lib/esm/component/Chart/BarChart.mjs +9 -7
- package/lib/esm/component/Chart/BubbleChart.mjs +29 -9
- package/lib/esm/component/Chart/CigaretteChart.mjs +33 -30
- package/lib/esm/component/Chart/CompactHorizontalBarChart.mjs +2 -1
- package/lib/esm/component/Chart/DonutChart.mjs +5 -4
- package/lib/esm/component/Chart/HistogramChart.mjs +6 -4
- package/lib/esm/component/Chart/LineChart.mjs +9 -7
- package/lib/esm/component/Chart/RadarChart.mjs +3 -2
- package/lib/esm/component/Chart/ScatterPlotChart.mjs +25 -8
- package/lib/esm/component/Chart/VennChart.mjs +6 -5
- package/lib/esm/component/ChartLegend/BaseLegend.mjs +4 -2
- package/lib/esm/component/ChartLegend/LegendFlex/LegendFlex.mjs +5 -5
- package/lib/esm/component/ChartLegend/LegendFlex/legend-flex.shadow.css +2 -2
- package/lib/esm/component/ChartLegend/LegendItem/LegendItem.mjs +24 -19
- package/lib/esm/component/ChartLegend/LegendItem/LegendItem.type.mjs +1 -1
- package/lib/esm/component/ChartLegend/LegendItem/legend-item.shadow.css +16 -40
- package/lib/esm/component/ChartLegend/LegendTable/LegendTable.mjs +13 -9
- package/lib/esm/component/ChartLegend/LegendTable/legend-table.shadow.css +6 -2
- package/lib/esm/style/abstract-chart.shadow.css +31 -1
- package/lib/esm/style/area.shadow.css +6 -5
- package/lib/esm/style/axis.shadow.css +2 -2
- package/lib/esm/style/bar.shadow.css +7 -7
- package/lib/esm/style/bubble.shadow.css +4 -4
- package/lib/esm/style/donut.shadow.css +3 -3
- package/lib/esm/style/dot.shadow.css +9 -3
- package/lib/esm/style/hover.shadow.css +19 -1
- package/lib/esm/style/line.shadow.css +4 -4
- package/lib/esm/style/radar.shadow.css +5 -5
- package/lib/esm/style/radial-tree.shadow.css +3 -3
- package/lib/esm/style/reference.shadow.css +1 -1
- package/lib/esm/style/scatterplot.shadow.css +1 -1
- package/lib/esm/style/tooltip.shadow.css +23 -14
- package/lib/esm/style/venn.shadow.css +3 -3
- package/lib/esm/utils/TextMeasurer.mjs +27 -0
- package/lib/types/Hover.d.ts +2 -0
- package/lib/types/component/Chart/AbstractChart.d.ts +11 -6
- package/lib/types/component/Chart/AbstractChart.d.ts.map +1 -1
- package/lib/types/component/Chart/AbstractChart.type.d.ts +20 -2
- package/lib/types/component/Chart/AbstractChart.type.d.ts.map +1 -1
- package/lib/types/component/Chart/AreaChart.d.ts.map +1 -1
- package/lib/types/component/Chart/AreaChart.type.d.ts +1 -0
- package/lib/types/component/Chart/AreaChart.type.d.ts.map +1 -1
- package/lib/types/component/Chart/BarChart.d.ts.map +1 -1
- package/lib/types/component/Chart/BarChart.type.d.ts +1 -0
- package/lib/types/component/Chart/BarChart.type.d.ts.map +1 -1
- package/lib/types/component/Chart/BubbleChart.d.ts.map +1 -1
- package/lib/types/component/Chart/BubbleChart.type.d.ts +2 -1
- package/lib/types/component/Chart/BubbleChart.type.d.ts.map +1 -1
- package/lib/types/component/Chart/CigaretteChart.type.d.ts +2 -1
- package/lib/types/component/Chart/CigaretteChart.type.d.ts.map +1 -1
- package/lib/types/component/Chart/CompactHorizontalBarChart.d.ts.map +1 -1
- package/lib/types/component/Chart/CompactHorizontalBarChart.type.d.ts +2 -1
- package/lib/types/component/Chart/CompactHorizontalBarChart.type.d.ts.map +1 -1
- package/lib/types/component/Chart/DonutChart.d.ts.map +1 -1
- package/lib/types/component/Chart/DonutChart.type.d.ts +2 -1
- package/lib/types/component/Chart/DonutChart.type.d.ts.map +1 -1
- package/lib/types/component/Chart/HistogramChart.d.ts.map +1 -1
- package/lib/types/component/Chart/HistogramChart.type.d.ts +1 -0
- package/lib/types/component/Chart/HistogramChart.type.d.ts.map +1 -1
- package/lib/types/component/Chart/LineChart.d.ts.map +1 -1
- package/lib/types/component/Chart/LineChart.type.d.ts +1 -0
- package/lib/types/component/Chart/LineChart.type.d.ts.map +1 -1
- package/lib/types/component/Chart/RadarChart.d.ts.map +1 -1
- package/lib/types/component/Chart/RadarChart.type.d.ts +2 -1
- package/lib/types/component/Chart/RadarChart.type.d.ts.map +1 -1
- package/lib/types/component/Chart/ScatterPlotChart.d.ts.map +1 -1
- package/lib/types/component/Chart/ScatterPlotChart.type.d.ts +2 -1
- package/lib/types/component/Chart/ScatterPlotChart.type.d.ts.map +1 -1
- package/lib/types/component/Chart/VennChart.d.ts.map +1 -1
- package/lib/types/component/Chart/VennChart.type.d.ts +2 -1
- package/lib/types/component/Chart/VennChart.type.d.ts.map +1 -1
- package/lib/types/component/ChartLegend/BaseLegend.d.ts +5 -1
- package/lib/types/component/ChartLegend/BaseLegend.d.ts.map +1 -1
- package/lib/types/component/ChartLegend/BaseLegend.type.d.ts +1 -1
- package/lib/types/component/ChartLegend/LegendItem/LegendItem.d.ts.map +1 -1
- package/lib/types/component/ChartLegend/LegendItem/LegendItem.type.d.ts +3 -1
- package/lib/types/component/ChartLegend/LegendItem/LegendItem.type.d.ts.map +1 -1
- package/lib/types/component/ChartLegend/LegendTable/LegendTable.d.ts.map +1 -1
- package/lib/types/component/ChartLegend/LegendTable/LegendTable.type.d.ts +2 -0
- package/lib/types/component/ChartLegend/LegendTable/LegendTable.type.d.ts.map +1 -1
- package/lib/types/utils/TextMeasurer.d.ts +5 -0
- package/lib/types/utils/TextMeasurer.d.ts.map +1 -0
- package/package.json +15 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadarChart.js","names":["createComponent","i18nEnhance","scaleLinear","React","AbstractChart","Radar","localizedMessages","RadarChartComponent","renderChart","groupKey","showDots","circle","onClickRadar","asProps","dataDefinitions","state","createElement","onClick","scale","xScale","type","undefined","Axis","dataKey","Ticks","Labels","renderRadarTooltip","map","item","checked","Polygon","id","key","color","Line","Dots","data","showTooltip","Tooltip","wMin","index","children","Fragment","Title","value","Dot","tooltipValueFormatter","renderTooltip","dataKeys","props","legendKeys","Object","keys","filter","domain","yScale","getLegendAriaLabel","getI18nText","chartType","Math","min","flatValues","max","_defineProperty","direction","showXAxis","showYAxis","RadarChart"],"sources":["../../../../src/component/Chart/RadarChart.tsx"],"sourcesContent":["import { createComponent } from '@semcore/core';\nimport i18nEnhance from '@semcore/core/lib/utils/enhances/i18nEnhance';\nimport { scaleLinear, type ScaleLinear } from 'd3-scale';\nimport React from 'react';\n\nimport type { ChartState } from './AbstractChart';\nimport { AbstractChart } from './AbstractChart';\nimport type { RadarChartData, RadarChartDefaultProps, RadarChartProps, RadarChartType } from './RadarChart.type';\n// @ts-ignore\nimport { Radar } from '../..';\nimport { localizedMessages } from '../../translations/__intergalactic-dynamic-locales';\n\nclass RadarChartComponent extends AbstractChart<\n RadarChartData,\n RadarChartProps,\n typeof RadarChartComponent.enhance,\n {},\n ChartState,\n RadarChartDefaultProps\n> {\n static enhance = [i18nEnhance(localizedMessages)] as const;\n\n static defaultProps = {\n direction: 'column',\n showXAxis: true,\n showYAxis: true,\n showTooltip: true,\n } as const;\n\n protected renderChart(): React.ReactNode {\n const { groupKey, showDots, circle, onClickRadar } = this.asProps;\n const { dataDefinitions } = this.state;\n\n return (\n <Radar onClick={onClickRadar} scale={this.xScale} type={circle ? 'circle' : undefined}>\n <Radar.Axis dataKey={groupKey}>\n <Radar.Axis.Ticks />\n <Radar.Axis.Labels />\n </Radar.Axis>\n {this.renderRadarTooltip()}\n {dataDefinitions.map((item) => {\n return (\n item.checked && (\n <Radar.Polygon dataKey={item.id} key={item.id} color={item.color}>\n <Radar.Polygon.Line />\n {showDots && <Radar.Polygon.Dots />}\n </Radar.Polygon>\n )\n );\n })}\n </Radar>\n );\n }\n\n protected renderRadarTooltip(): React.ReactNode {\n const { data, groupKey, showTooltip } = this.asProps;\n const { dataDefinitions } = this.state;\n\n if (!showTooltip) {\n return null;\n }\n\n return (\n <Radar.Tooltip wMin={100}>\n {({ index }: any) => {\n return {\n children: (\n <>\n <Radar.Tooltip.Title>{data[groupKey]?.[index]}</Radar.Tooltip.Title>\n\n {dataDefinitions.map((item) => {\n const value = data[item.id]?.[index];\n\n return (\n item.checked && (\n <Radar.Tooltip.Dot color={item.color} key={item.id}>\n {this.tooltipValueFormatter(value)}\n </Radar.Tooltip.Dot>\n )\n );\n })}\n </>\n ),\n };\n }}\n </Radar.Tooltip>\n );\n }\n\n // By default, tooltip will render in Plot component.\n // In RadarChart, we need to render it in Radar component, so we use renderRadarTooltip method\n protected renderTooltip(): React.ReactNode {\n return null;\n }\n\n protected get dataKeys(): string[] {\n const { data, groupKey } = this.props;\n\n const legendKeys: string[] = Object.keys(data).filter((key) => key !== groupKey);\n\n return legendKeys;\n }\n\n protected get xScale(): ScaleLinear<any, any> {\n return this.asProps.scale ?? scaleLinear().domain(this.domain);\n }\n\n protected get yScale(): ScaleLinear<any, any> {\n return this.asProps.scale ?? scaleLinear().domain(this.domain);\n }\n\n protected getLegendAriaLabel(): string {\n return this.asProps.getI18nText('legendForChart', { chartType: 'Radar' });\n }\n\n private get domain(): [number, number] {\n return [Math.min(...super.flatValues), Math.max(...super.flatValues)];\n }\n}\n\n/**\n * RadarChart\n *\n * {@link https://developer.semrush.com/intergalactic/data-display/radar-chart/radar-chart-api/|API} | {@link https://developer.semrush.com/intergalactic/data-display/radar-chart/radar-chart-code/|Examples}\n */\nexport const RadarChart: RadarChartType = createComponent<\n RadarChartType,\n typeof RadarChartComponent\n>(RadarChartComponent);\n"],"mappings":";AAAA,SAASA,eAAe,QAAQ,eAAe;AAC/C,OAAOC,WAAW,MAAM,8CAA8C;AACtE,SAASC,WAAW,QAA0B,UAAU;AACxD,OAAOC,KAAK,MAAM,OAAO;AAGzB,SAASC,aAAa,QAAQ,iBAAiB;AAE/C;AACA,SAASC,KAAK,QAAQ,OAAO;AAC7B,SAASC,iBAAiB,QAAQ,oDAAoD;AAEtF,MAAMC,mBAAmB,SAASH,aAAa,CAO7C;
|
|
1
|
+
{"version":3,"file":"RadarChart.js","names":["createComponent","i18nEnhance","scaleLinear","React","AbstractChart","Radar","localizedMessages","RadarChartComponent","renderChart","groupKey","showDots","circle","onClickRadar","asProps","dataDefinitions","state","createElement","onClick","scale","xScale","type","undefined","Axis","dataKey","Ticks","Labels","renderRadarTooltip","map","item","checked","Polygon","id","key","color","Line","Dots","data","showTooltip","Tooltip","wMin","index","children","Fragment","Title","tooltipTitleFormatter","value","Dot","tooltipValueFormatter","renderTooltip","dataKeys","props","legendKeys","Object","keys","filter","domain","yScale","getLegendAriaLabel","getI18nText","chartType","Math","min","flatValues","max","_defineProperty","direction","showXAxis","showYAxis","locale","RadarChart"],"sources":["../../../../src/component/Chart/RadarChart.tsx"],"sourcesContent":["import { createComponent } from '@semcore/core';\nimport i18nEnhance from '@semcore/core/lib/utils/enhances/i18nEnhance';\nimport { scaleLinear, type ScaleLinear } from 'd3-scale';\nimport React from 'react';\n\nimport type { ChartState } from './AbstractChart';\nimport { AbstractChart } from './AbstractChart';\nimport type { RadarChartData, RadarChartDefaultProps, RadarChartProps, RadarChartType } from './RadarChart.type';\n// @ts-ignore\nimport { Radar } from '../..';\nimport { localizedMessages } from '../../translations/__intergalactic-dynamic-locales';\n\nclass RadarChartComponent extends AbstractChart<\n RadarChartData,\n RadarChartProps,\n typeof RadarChartComponent.enhance,\n {},\n ChartState,\n RadarChartDefaultProps\n> {\n static enhance = [i18nEnhance(localizedMessages)] as const;\n\n static defaultProps = {\n direction: 'column',\n showXAxis: true,\n showYAxis: true,\n showTooltip: true,\n locale: 'en',\n } as const;\n\n protected renderChart(): React.ReactNode {\n const { groupKey, showDots, circle, onClickRadar } = this.asProps;\n const { dataDefinitions } = this.state;\n\n return (\n <Radar onClick={onClickRadar} scale={this.xScale} type={circle ? 'circle' : undefined}>\n <Radar.Axis dataKey={groupKey}>\n <Radar.Axis.Ticks />\n <Radar.Axis.Labels />\n </Radar.Axis>\n {this.renderRadarTooltip()}\n {dataDefinitions.map((item) => {\n return (\n item.checked && (\n <Radar.Polygon dataKey={item.id} key={item.id} color={item.color}>\n <Radar.Polygon.Line />\n {showDots && <Radar.Polygon.Dots />}\n </Radar.Polygon>\n )\n );\n })}\n </Radar>\n );\n }\n\n protected renderRadarTooltip(): React.ReactNode {\n const { data, groupKey, showTooltip } = this.asProps;\n const { dataDefinitions } = this.state;\n\n if (!showTooltip) {\n return null;\n }\n\n return (\n <Radar.Tooltip wMin={100}>\n {({ index }: any) => {\n return {\n children: (\n <>\n <Radar.Tooltip.Title>{this.tooltipTitleFormatter(data[groupKey]?.[index])}</Radar.Tooltip.Title>\n\n {dataDefinitions.map((item) => {\n const value = data[item.id]?.[index];\n\n return (\n item.checked && (\n <Radar.Tooltip.Dot color={item.color} key={item.id}>\n {this.tooltipValueFormatter(value)}\n </Radar.Tooltip.Dot>\n )\n );\n })}\n </>\n ),\n };\n }}\n </Radar.Tooltip>\n );\n }\n\n // By default, tooltip will render in Plot component.\n // In RadarChart, we need to render it in Radar component, so we use renderRadarTooltip method\n protected renderTooltip(): React.ReactNode {\n return null;\n }\n\n protected get dataKeys(): string[] {\n const { data, groupKey } = this.props;\n\n const legendKeys: string[] = Object.keys(data).filter((key) => key !== groupKey);\n\n return legendKeys;\n }\n\n protected get xScale(): ScaleLinear<any, any> {\n return this.asProps.scale ?? scaleLinear().domain(this.domain);\n }\n\n protected get yScale(): ScaleLinear<any, any> {\n return this.asProps.scale ?? scaleLinear().domain(this.domain);\n }\n\n protected getLegendAriaLabel(): string {\n return this.asProps.getI18nText('legendForChart', { chartType: 'Radar' });\n }\n\n private get domain(): [number, number] {\n return [Math.min(...super.flatValues), Math.max(...super.flatValues)];\n }\n}\n\n/**\n * RadarChart\n *\n * {@link https://developer.semrush.com/intergalactic/data-display/radar-chart/radar-chart-api/|API} | {@link https://developer.semrush.com/intergalactic/data-display/radar-chart/radar-chart-code/|Examples}\n */\nexport const RadarChart: RadarChartType = createComponent<\n RadarChartType,\n typeof RadarChartComponent\n>(RadarChartComponent);\n"],"mappings":";AAAA,SAASA,eAAe,QAAQ,eAAe;AAC/C,OAAOC,WAAW,MAAM,8CAA8C;AACtE,SAASC,WAAW,QAA0B,UAAU;AACxD,OAAOC,KAAK,MAAM,OAAO;AAGzB,SAASC,aAAa,QAAQ,iBAAiB;AAE/C;AACA,SAASC,KAAK,QAAQ,OAAO;AAC7B,SAASC,iBAAiB,QAAQ,oDAAoD;AAEtF,MAAMC,mBAAmB,SAASH,aAAa,CAO7C;EAWUI,W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AAW,CAAC,CAAC,CAACqD,MAAM,CAAC,IAAI,CAACA,MAAM,CAAC;EAChE;EAEA,IAAcC,MAAMA,CAAA,EAA0B;IAC5C,OAAO,IAAI,CAAC3C,OAAO,CAACK,KAAK,IAAIhB,WAAW,CAAC,CAAC,CAACqD,MAAM,CAAC,IAAI,CAACA,MAAM,CAAC;EAChE;EAEUE,kBAAkBA,CAAA,EAAW;IACrC,OAAO,IAAI,CAAC5C,OAAO,CAAC6C,WAAW,CAAC,gBAAgB,EAAE;MAAEC,SAAS,EAAE;IAAQ,CAAC,CAAC;EAC3E;EAEA,IAAYJ,MAAMA,CAAA,EAAqB;IACrC,OAAO,CAACK,IAAI,CAACC,GAAG,CAAC,GAAG,KAAK,CAACC,UAAU,CAAC,EAAEF,IAAI,CAACG,GAAG,CAAC,GAAG,KAAK,CAACD,UAAU,CAAC,CAAC;EACvE;AACF;;AAEA;AACA;AACA;AACA;AACA;AAJAE,eAAA,CA7GMzD,mBAAmB,aAQN,CAACN,WAAW,CAACK,iBAAiB,CAAC,CAAC;AAAA0D,eAAA,CAR7CzD,mBAAmB,kBAUD;EACpB0D,SAAS,EAAE,QAAQ;EACnBC,SAAS,EAAE,IAAI;EACfC,SAAS,EAAE,IAAI;EACf9B,WAAW,EAAE,IAAI;EACjB+B,MAAM,EAAE;AACV,CAAC;AAkGH,OAAO,MAAMC,UAA0B,GAAGrE,eAAe,CAGvDO,mBAAmB,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadarChart.type.js","names":[],"sources":["../../../../src/component/Chart/RadarChart.type.ts"],"sourcesContent":["import type { Flex } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\nimport type { ScaleLinear } from 'd3-scale';\n\nimport type { BaseChartProps } from './AbstractChart.type';\n\nexport type RadarChartData = Record<string, string[] | number[]>;\n\nexport type RadarChartProps = Intergalactic.InternalTypings.EfficientOmit<\n BaseChartProps<RadarChartData>,\n 'showTotalInTooltip' | 'showPercentValueInTooltip'\n> & {\n groupKey: string;\n scale?: ScaleLinear<any, any>;\n xScale?: never;\n yScale?: never;\n showDots?: boolean;\n circle?: boolean;\n /** Callback triggered when a user clicks on a chart at a position corresponding to a category */\n onClickRadar?: (index: number, e: React.SyntheticEvent) => void;\n};\n\nexport type RadarChartDefaultProps = {\n direction: 'column';\n showXAxis: true;\n showYAxis: true;\n showTooltip: true;\n};\n\nexport type RadarChartType = Intergalactic.Component<typeof Flex, RadarChartProps>;\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"RadarChart.type.js","names":[],"sources":["../../../../src/component/Chart/RadarChart.type.ts"],"sourcesContent":["import type { Flex } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\nimport type { ScaleLinear } from 'd3-scale';\n\nimport type { BaseChartProps } from './AbstractChart.type';\n\nexport type RadarChartData = Record<string, string[] | number[]>;\n\nexport type RadarChartProps = Intergalactic.InternalTypings.EfficientOmit<\n BaseChartProps<RadarChartData>,\n 'showTotalInTooltip' | 'showPercentValueInTooltip' | 'showDeltaPercentInTooltip' | 'getPercentDelta'\n> & {\n groupKey: string;\n scale?: ScaleLinear<any, any>;\n xScale?: never;\n yScale?: never;\n showDots?: boolean;\n circle?: boolean;\n /** Callback triggered when a user clicks on a chart at a position corresponding to a category */\n onClickRadar?: (index: number, e: React.SyntheticEvent) => void;\n};\n\nexport type RadarChartDefaultProps = {\n direction: 'column';\n showXAxis: true;\n showYAxis: true;\n showTooltip: true;\n locale: 'en';\n};\n\nexport type RadarChartType = Intergalactic.Component<typeof Flex, RadarChartProps>;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import {
|
|
2
|
+
import { Box } from '@semcore/base-components';
|
|
3
|
+
import { createComponent, sstyled } from '@semcore/core';
|
|
3
4
|
import i18nEnhance from '@semcore/core/lib/utils/enhances/i18nEnhance';
|
|
4
5
|
import { Text } from '@semcore/typography';
|
|
5
6
|
import { scaleLinear, scaleTime } from 'd3-scale';
|
|
@@ -114,14 +115,24 @@ class ScatterPlotChartComponent extends AbstractChart {
|
|
|
114
115
|
x,
|
|
115
116
|
y
|
|
116
117
|
}) => {
|
|
118
|
+
var _ref;
|
|
119
|
+
const {
|
|
120
|
+
styles
|
|
121
|
+
} = this.asProps;
|
|
122
|
+
const STooltipChildrenWrapper = Box;
|
|
117
123
|
return {
|
|
118
|
-
children: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ScatterPlot.Tooltip.Dot, {
|
|
124
|
+
children: (_ref = sstyled(styles), /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ScatterPlot.Tooltip.Dot, {
|
|
119
125
|
color: item.color
|
|
120
|
-
}, "Data"), /*#__PURE__*/React.createElement(
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
126
|
+
}, "Data"), /*#__PURE__*/React.createElement(STooltipChildrenWrapper
|
|
127
|
+
// @ts-ignore
|
|
128
|
+
, _ref.cn("STooltipChildrenWrapper", {
|
|
129
|
+
"columnsCount": 2,
|
|
130
|
+
"mt": 2
|
|
131
|
+
}), /*#__PURE__*/React.createElement(Text, _ref.cn("Text", {}), "X axis"), /*#__PURE__*/React.createElement(Text, _ref.cn("Text", {
|
|
132
|
+
"textAlign": 'end'
|
|
133
|
+
}), this.tooltipValueFormatter(data[index][x])), /*#__PURE__*/React.createElement(Text, _ref.cn("Text", {}), "Y axis"), /*#__PURE__*/React.createElement(Text, _ref.cn("Text", {
|
|
134
|
+
"textAlign": 'end'
|
|
135
|
+
}), this.tooltipValueFormatter(data[index][y])))))
|
|
125
136
|
};
|
|
126
137
|
});
|
|
127
138
|
});
|
|
@@ -144,7 +155,8 @@ _defineProperty(ScatterPlotChartComponent, "defaultProps", {
|
|
|
144
155
|
showXAxis: true,
|
|
145
156
|
showYAxis: true,
|
|
146
157
|
showTooltip: true,
|
|
147
|
-
showLegend: false
|
|
158
|
+
showLegend: false,
|
|
159
|
+
locale: 'en'
|
|
148
160
|
});
|
|
149
161
|
_defineProperty(ScatterPlotChartComponent, "enhance", [i18nEnhance(localizedMessages)]);
|
|
150
162
|
export const ScatterPlotChart = createComponent(ScatterPlotChartComponent);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScatterPlotChart.js","names":["createComponent","i18nEnhance","Text","scaleLinear","scaleTime","React","minMax","ScatterPlot","getScatterPlotRadius","AbstractChart","localizedMessages","ScatterPlotChartComponent","dataKeys","data","groupKey","valueKey","props","Object","keys","filter","key","xScale","marginY","asProps","plotWidth","radius","getValueScale","flatValues","testItem","range","plotPadding","domain","Date","Number","isNaN","getMilliseconds","yScale","marginX","plotHeight","max","Math","min","reduce","result","item","entries","forEach","value","add","Set","renderChart","onClickScatterItem","dataDefinitions","state","map","checked","createElement","onClick","x","y","id","color","renderTooltip","Tooltip","wMin","index","children","Fragment","Dot","tag","tooltipValueFormatter","getLegendAriaLabel","getI18nText","chartType","_defineProperty","direction","showXAxis","showYAxis","showTooltip","showLegend","ScatterPlotChart"],"sources":["../../../../src/component/Chart/ScatterPlotChart.tsx"],"sourcesContent":["import { createComponent } from '@semcore/core';\nimport i18nEnhance from '@semcore/core/lib/utils/enhances/i18nEnhance';\nimport { Text } from '@semcore/typography';\nimport { type ScaleLinear, scaleLinear, scaleTime } from 'd3-scale';\nimport React from 'react';\n\n// @ts-ignore\nimport { minMax, ScatterPlot, getScatterPlotRadius } from '../..';\nimport type { ChartState } from './AbstractChart';\nimport { AbstractChart } from './AbstractChart';\nimport type {\n ScatterPlotChartData,\n ScatterPlotChartDefaultProps,\n ScatterPlotChartProps,\n ScatterPlotChartType,\n} from './ScatterPlotChart.type';\nimport { localizedMessages } from '../../translations/__intergalactic-dynamic-locales';\n\nclass ScatterPlotChartComponent extends AbstractChart<\n ScatterPlotChartData,\n ScatterPlotChartProps,\n typeof ScatterPlotChartComponent.enhance,\n {},\n ChartState,\n ScatterPlotChartDefaultProps\n> {\n static displayName = 'Chart.ScatterPlot';\n public static defaultProps = {\n direction: 'column',\n showXAxis: true,\n showYAxis: true,\n showTooltip: true,\n showLegend: false,\n } as const;\n\n static enhance = [i18nEnhance(localizedMessages)] as const;\n\n protected get dataKeys(): string[] {\n const { data, groupKey, valueKey } = this.props;\n\n return Object.keys(data[0]).filter((key) => key !== groupKey && key !== valueKey);\n }\n\n protected get xScale() {\n const { xScale, marginY = 30, data, groupKey, valueKey } = this.asProps;\n const { plotWidth } = this;\n\n if (xScale) {\n return xScale;\n }\n\n const radius = getScatterPlotRadius(valueKey) / this.getValueScale([...this.flatValues]);\n const testItem = data[0][groupKey];\n const range = [marginY, plotWidth - this.plotPadding];\n const domain = minMax(data, groupKey);\n\n if (testItem instanceof Date && !Number.isNaN(testItem.getMilliseconds())) {\n return scaleTime([domain[0] - radius, domain[1] + radius], range);\n }\n\n return scaleLinear([domain[0] - radius, domain[1] + radius], range);\n }\n\n protected get yScale(): ScaleLinear<any, any> {\n const { yScale, marginX = 30, valueKey } = this.asProps;\n const { plotHeight } = this;\n\n if (yScale) {\n return yScale;\n }\n\n const flatValues = this.flatValues;\n const radius = getScatterPlotRadius(valueKey) / this.getValueScale([...flatValues]);\n\n const max = Math.max(...flatValues) + radius;\n const min = Math.min(...flatValues) - radius;\n\n return scaleLinear()\n .range([plotHeight - marginX, this.plotPadding])\n .domain([min, max]);\n }\n\n protected get flatValues(): Set<number> {\n const { data, groupKey, valueKey } = this.asProps;\n\n const flatValues = data.reduce<Set<number>>((result, item) => {\n Object.entries(item).forEach(([key, value]) => {\n if (key !== groupKey && key !== valueKey && typeof value === 'number') {\n result.add(value);\n }\n });\n\n return result;\n }, new Set());\n\n return flatValues;\n }\n\n protected renderChart() {\n const { groupKey, valueKey, onClickScatterItem } = this.asProps;\n const { dataDefinitions } = this.state;\n\n return dataDefinitions.map((item) => {\n return (\n item.checked && (\n <ScatterPlot onClick={onClickScatterItem} x={groupKey} y={item.id} key={item.id} color={item.color} value={valueKey} />\n )\n );\n });\n }\n\n protected renderTooltip() {\n const { data, groupKey } = this.asProps;\n const { dataDefinitions } = this.state;\n\n return dataDefinitions\n .filter((item) => item.checked)\n .map((item) => {\n return (\n <ScatterPlot.Tooltip key={item.id} x={groupKey} y={item.id} wMin={100}>\n {({ index, x, y }: any) => {\n return {\n children: (\n <>\n <ScatterPlot.Tooltip.Dot color={item.color}>Data</ScatterPlot.Tooltip.Dot>\n <Text tag='div'>\n X axis\n {this.tooltipValueFormatter(data[index][x])}\n </Text>\n <Text tag='div'>\n Y axis\n {this.tooltipValueFormatter(data[index][y])}\n </Text>\n </>\n ),\n };\n }}\n </ScatterPlot.Tooltip>\n );\n });\n }\n\n protected getLegendAriaLabel(): string {\n return this.asProps.getI18nText('legendForChart', { chartType: 'ScatterPlot' });\n }\n}\n\n/**\n * ScatterPlotChart\n *\n * {@link https://developer.semrush.com/intergalactic/data-display/scatterplot-chart/scatterplot-chart-api/|API} | {@link https://developer.semrush.com/intergalactic/data-display/scatterplot-chart/scatterplot-chart-code/|Examples}\n */\nexport const ScatterPlotChart = createComponent<\n ScatterPlotChartType,\n typeof ScatterPlotChartComponent\n>(ScatterPlotChartComponent);\n"],"mappings":";AAAA,SAASA,eAAe,QAAQ,eAAe;AAC/C,OAAOC,WAAW,MAAM,8CAA8C;AACtE,SAASC,IAAI,QAAQ,qBAAqB;AAC1C,SAA2BC,WAAW,EAAEC,SAAS,QAAQ,UAAU;AACnE,OAAOC,KAAK,MAAM,OAAO;;AAEzB;AACA,SAASC,MAAM,EAAEC,WAAW,EAAEC,oBAAoB,QAAQ,OAAO;AAEjE,SAASC,aAAa,QAAQ,iBAAiB;AAO/C,SAASC,iBAAiB,QAAQ,oDAAoD;AAEtF,MAAMC,yBAAyB,SAASF,aAAa,CAOnD;EAYA,IAAcG,QAAQA,CAAA,EAAa;IACjC,MAAM;MAAEC,IAAI;MAAEC,QAAQ;MAAE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CAACjD,WAAW,CAACwD,OAAO,CAACK,GAAG;YAACP,KAAK,EAAEjB,IAAI,CAACiB;UAAM,GAAC,MAA6B,CAAC,eAC1ExD,KAAA,CAAAmD,aAAA,CAACtD,IAAI;YAACmE,GAAG,EAAC;UAAK,GAAC,QAEd,EAAC,IAAI,CAACC,qBAAqB,CAACzD,IAAI,CAACoD,KAAK,CAAC,CAACP,CAAC,CAAC,CACtC,CAAC,eACPrD,KAAA,CAAAmD,aAAA,CAACtD,IAAI;YAACmE,GAAG,EAAC;UAAK,GAAC,QAEd,EAAC,IAAI,CAACC,qBAAqB,CAACzD,IAAI,CAACoD,KAAK,CAAC,CAACN,CAAC,CAAC,CACtC,CACN;QAEN,CAAC;MACH,CACmB,CAAC;IAE1B,CAAC,CAAC;EACN;EAEUY,kBAAkBA,CAAA,EAAW;IACrC,OAAO,IAAI,CAAChD,OAAO,CAACiD,WAAW,CAAC,gBAAgB,EAAE;MAAEC,SAAS,EAAE;IAAc,CAAC,CAAC;EACjF;AACF;;AAEA;AACA;AACA;AACA;AACA;AAJAC,eAAA,CAjIM/D,yBAAyB,iBAQR,mBAAmB;AAAA+D,eAAA,CARpC/D,yBAAyB,kBASA;EAC3BgE,SAAS,EAAE,QAAQ;EACnBC,SAAS,EAAE,IAAI;EACfC,SAAS,EAAE,IAAI;EACfC,WAAW,EAAE,IAAI;EACjBC,UAAU,EAAE;AACd,CAAC;AAAAL,eAAA,CAfG/D,yBAAyB,aAiBZ,CAACV,WAAW,CAACS,iBAAiB,CAAC,CAAC;AAqHnD,OAAO,MAAMsE,gBAAgB,GAAGhF,eAAe,CAG7CW,yBAAyB,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ScatterPlotChart.js","names":["Box","createComponent","sstyled","i18nEnhance","Text","scaleLinear","scaleTime","React","minMax","ScatterPlot","getScatterPlotRadius","AbstractChart","localizedMessages","ScatterPlotChartComponent","dataKeys","data","groupKey","valueKey","props","Object","keys","filter","key","xScale","marginY","asProps","plotWidth","radius","getValueScale","flatValues","testItem","range","plotPadding","domain","Date","Number","isNaN","getMilliseconds","yScale","marginX","plotHeight","max","Math","min","reduce","result","item","entries","forEach","value","add","Set","renderChart","onClickScatterItem","dataDefinitions","state","map","checked","createElement","onClick","x","y","id","color","renderTooltip","Tooltip","wMin","index","_ref","styles","STooltipChildrenWrapper","children","Fragment","Dot","cn","tooltipValueFormatter","getLegendAriaLabel","getI18nText","chartType","_defineProperty","direction","showXAxis","showYAxis","showTooltip","showLegend","locale","ScatterPlotChart"],"sources":["../../../../src/component/Chart/ScatterPlotChart.tsx"],"sourcesContent":["import { Box } from '@semcore/base-components';\nimport { createComponent, sstyled } from '@semcore/core';\nimport i18nEnhance from '@semcore/core/lib/utils/enhances/i18nEnhance';\nimport { Text } from '@semcore/typography';\nimport { type ScaleLinear, scaleLinear, scaleTime } from 'd3-scale';\nimport React from 'react';\n\n// @ts-ignore\nimport { minMax, ScatterPlot, getScatterPlotRadius } from '../..';\nimport type { ChartState } from './AbstractChart';\nimport { AbstractChart } from './AbstractChart';\nimport type {\n ScatterPlotChartData,\n ScatterPlotChartDefaultProps,\n ScatterPlotChartProps,\n ScatterPlotChartType,\n} from './ScatterPlotChart.type';\nimport { localizedMessages } from '../../translations/__intergalactic-dynamic-locales';\n\nclass ScatterPlotChartComponent extends AbstractChart<\n ScatterPlotChartData,\n ScatterPlotChartProps,\n typeof ScatterPlotChartComponent.enhance,\n {},\n ChartState,\n ScatterPlotChartDefaultProps\n> {\n static displayName = 'Chart.ScatterPlot';\n public static defaultProps = {\n direction: 'column',\n showXAxis: true,\n showYAxis: true,\n showTooltip: true,\n showLegend: false,\n locale: 'en',\n } as const;\n\n static enhance = [i18nEnhance(localizedMessages)] as const;\n\n protected get dataKeys(): string[] {\n const { data, groupKey, valueKey } = this.props;\n\n return Object.keys(data[0]).filter((key) => key !== groupKey && key !== valueKey);\n }\n\n protected get xScale() {\n const { xScale, marginY = 30, data, groupKey, valueKey } = this.asProps;\n const { plotWidth } = this;\n\n if (xScale) {\n return xScale;\n }\n\n const radius = getScatterPlotRadius(valueKey) / this.getValueScale([...this.flatValues]);\n const testItem = data[0][groupKey];\n const range = [marginY, plotWidth - this.plotPadding];\n const domain = minMax(data, groupKey);\n\n if (testItem instanceof Date && !Number.isNaN(testItem.getMilliseconds())) {\n return scaleTime([domain[0] - radius, domain[1] + radius], range);\n }\n\n return scaleLinear([domain[0] - radius, domain[1] + radius], range);\n }\n\n protected get yScale(): ScaleLinear<any, any> {\n const { yScale, marginX = 30, valueKey } = this.asProps;\n const { plotHeight } = this;\n\n if (yScale) {\n return yScale;\n }\n\n const flatValues = this.flatValues;\n const radius = getScatterPlotRadius(valueKey) / this.getValueScale([...flatValues]);\n\n const max = Math.max(...flatValues) + radius;\n const min = Math.min(...flatValues) - radius;\n\n return scaleLinear()\n .range([plotHeight - marginX, this.plotPadding])\n .domain([min, max]);\n }\n\n protected get flatValues(): Set<number> {\n const { data, groupKey, valueKey } = this.asProps;\n\n const flatValues = data.reduce<Set<number>>((result, item) => {\n Object.entries(item).forEach(([key, value]) => {\n if (key !== groupKey && key !== valueKey && typeof value === 'number') {\n result.add(value);\n }\n });\n\n return result;\n }, new Set());\n\n return flatValues;\n }\n\n protected renderChart() {\n const { groupKey, valueKey, onClickScatterItem } = this.asProps;\n const { dataDefinitions } = this.state;\n\n return dataDefinitions.map((item) => {\n return (\n item.checked && (\n <ScatterPlot onClick={onClickScatterItem} x={groupKey} y={item.id} key={item.id} color={item.color} value={valueKey} />\n )\n );\n });\n }\n\n protected renderTooltip() {\n const { data, groupKey } = this.asProps;\n const { dataDefinitions } = this.state;\n\n return dataDefinitions\n .filter((item) => item.checked)\n .map((item) => {\n return (\n <ScatterPlot.Tooltip key={item.id} x={groupKey} y={item.id} wMin={100}>\n {({ index, x, y }: any) => {\n const { styles } = this.asProps;\n const STooltipChildrenWrapper = Box;\n\n return {\n children: sstyled(styles)(\n <>\n <ScatterPlot.Tooltip.Dot color={item.color}>Data</ScatterPlot.Tooltip.Dot>\n <STooltipChildrenWrapper\n // @ts-ignore\n columnsCount={2}\n mt={2}\n >\n <Text>X axis</Text>\n <Text textAlign='end'>{this.tooltipValueFormatter(data[index][x])}</Text>\n <Text>Y axis</Text>\n <Text textAlign='end'>{this.tooltipValueFormatter(data[index][y])}</Text>\n </STooltipChildrenWrapper>\n </>,\n ),\n };\n }}\n </ScatterPlot.Tooltip>\n );\n });\n }\n\n protected getLegendAriaLabel(): string {\n return this.asProps.getI18nText('legendForChart', { chartType: 'ScatterPlot' });\n }\n}\n\n/**\n * ScatterPlotChart\n *\n * {@link https://developer.semrush.com/intergalactic/data-display/scatterplot-chart/scatterplot-chart-api/|API} | {@link https://developer.semrush.com/intergalactic/data-display/scatterplot-chart/scatterplot-chart-code/|Examples}\n */\nexport const ScatterPlotChart = createComponent<\n ScatterPlotChartType,\n typeof ScatterPlotChartComponent\n>(ScatterPlotChartComponent);\n"],"mappings":";AAAA,SAASA,GAAG,QAAQ,0BAA0B;AAC9C,SAASC,eAAe,EAAEC,OAAO,QAAQ,eAAe;AACxD,OAAOC,WAAW,MAAM,8CAA8C;AACtE,SAASC,IAAI,QAAQ,qBAAqB;AAC1C,SAA2BC,WAAW,EAAEC,SAAS,QAAQ,UAAU;AACnE,OAAOC,KAAK,MAAM,OAAO;;AAEzB;AACA,SAASC,MAAM,EAAEC,WAAW,EAAEC,oBAAoB,QAAQ,OAAO;AAEjE,SAASC,aAAa,QAAQ,iBAAiB;AAO/C,SAASC,iBAAiB,QAAQ,oDAAoD;AAEtF,MAAMC,yBAAyB,SAASF,aAAa,CAOnD;EAaA,IAAcG,QAAQA,CAAA,EAAa;IACjC,MAAM;MAAEC,IAAI;MAAEC,QAAQ;MAAEC;IAAS,CAAC,GAAG,IAAI,CAACC,KAAK;IAE/C,OAAOC,MAAM,CAACC,IAAI,CAACL,IAAI,CAAC,CAAC,CAAC,CAAC,CAACM,MAAM,CAAEC,GAAG,IAAKA,GAAG,KAAKN,QAAQ,IAAIM,GA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yBAAyB,aAkBZ,CAACV,WAAW,CAACS,iBAAiB,CAAC,CAAC;AA0HnD,OAAO,MAAM0E,gBAAgB,GAAGrF,eAAe,CAG7CY,yBAAyB,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScatterPlotChart.type.js","names":[],"sources":["../../../../src/component/Chart/ScatterPlotChart.type.ts"],"sourcesContent":["import type { Flex } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\nimport type { ScaleLinear, ScaleTime } from 'd3-scale';\n\nimport type { BaseChartProps } from './AbstractChart.type';\nimport type { interpolateValue } from '../../utils';\n\nexport type ScatterPlotChartData = Array<Record<string, number | typeof interpolateValue | Date>>;\n\nexport type ScatterPlotChartProps = Intergalactic.InternalTypings.EfficientOmit<\n BaseChartProps<ScatterPlotChartData>,\n 'showTotalInTooltip'\n> & {\n /** Field name that groups the data points */\n groupKey: string;\n /** Custom x-axis scale */\n xScale?: ScaleLinear<any, any> | ScaleTime<any, any>;\n /** Custom y-axis scale */\n yScale?: ScaleLinear<any, any>;\n /** Optional field name for additional value data */\n valueKey?: string;\n /** Callback triggered when a user clicks on a scatter item */\n onClickScatterItem?: (index: number, event: React.SyntheticEvent) => void;\n};\n\nexport type ScatterPlotChartDefaultProps = {\n direction: 'column';\n showXAxis: true;\n showYAxis: true;\n showTooltip: true;\n showLegend: false;\n};\n\nexport type ScatterPlotChartType = Intergalactic.Component<typeof Flex, ScatterPlotChartProps>;\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ScatterPlotChart.type.js","names":[],"sources":["../../../../src/component/Chart/ScatterPlotChart.type.ts"],"sourcesContent":["import type { Flex } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\nimport type { ScaleLinear, ScaleTime } from 'd3-scale';\n\nimport type { BaseChartProps } from './AbstractChart.type';\nimport type { interpolateValue } from '../../utils';\n\nexport type ScatterPlotChartData = Array<Record<string, number | typeof interpolateValue | Date>>;\n\nexport type ScatterPlotChartProps = Intergalactic.InternalTypings.EfficientOmit<\n BaseChartProps<ScatterPlotChartData>,\n 'showTotalInTooltip' | 'showDeltaPercentInTooltip' | 'getPercentDelta'\n> & {\n /** Field name that groups the data points */\n groupKey: string;\n /** Custom x-axis scale */\n xScale?: ScaleLinear<any, any> | ScaleTime<any, any>;\n /** Custom y-axis scale */\n yScale?: ScaleLinear<any, any>;\n /** Optional field name for additional value data */\n valueKey?: string;\n /** Callback triggered when a user clicks on a scatter item */\n onClickScatterItem?: (index: number, event: React.SyntheticEvent) => void;\n};\n\nexport type ScatterPlotChartDefaultProps = {\n direction: 'column';\n showXAxis: true;\n showYAxis: true;\n showTooltip: true;\n showLegend: false;\n locale: 'en';\n};\n\nexport type ScatterPlotChartType = Intergalactic.Component<typeof Flex, ScatterPlotChartProps>;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -50,7 +50,7 @@ class VennChartComponent extends AbstractChart {
|
|
|
50
50
|
} = this.asProps;
|
|
51
51
|
const {
|
|
52
52
|
dataDefinitions,
|
|
53
|
-
|
|
53
|
+
highlightedItem
|
|
54
54
|
} = this.state;
|
|
55
55
|
const checkedLegendItems = dataDefinitions.filter(item => item.checked);
|
|
56
56
|
const checkedLegendItemsMap = checkedLegendItems.reduce((result, item) => {
|
|
@@ -72,7 +72,7 @@ class VennChartComponent extends AbstractChart {
|
|
|
72
72
|
dataKey: item.id,
|
|
73
73
|
name: item.label,
|
|
74
74
|
color: item.color,
|
|
75
|
-
transparent:
|
|
75
|
+
transparent: highlightedItem !== -1 && highlightedItem !== index
|
|
76
76
|
});
|
|
77
77
|
}), intersections.map(intersectionKey => {
|
|
78
78
|
const intersectionKeys = intersectionKey.split('/');
|
|
@@ -99,9 +99,9 @@ class VennChartComponent extends AbstractChart {
|
|
|
99
99
|
data
|
|
100
100
|
}) => {
|
|
101
101
|
return {
|
|
102
|
-
children: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Venn.Tooltip.Title, null, name), /*#__PURE__*/React.createElement(Text, {
|
|
102
|
+
children: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Venn.Tooltip.Title, null, this.tooltipTitleFormatter(name)), /*#__PURE__*/React.createElement(Text, {
|
|
103
103
|
bold: true
|
|
104
|
-
}, data[dataKey]))
|
|
104
|
+
}, this.tooltipValueFormatter(data[dataKey])))
|
|
105
105
|
};
|
|
106
106
|
});
|
|
107
107
|
}
|
|
@@ -122,7 +122,8 @@ _defineProperty(VennChartComponent, "defaultProps", {
|
|
|
122
122
|
direction: 'row-reverse',
|
|
123
123
|
alignItems: 'flex-start',
|
|
124
124
|
marginY: 0,
|
|
125
|
-
marginX: 0
|
|
125
|
+
marginX: 0,
|
|
126
|
+
locale: 'en'
|
|
126
127
|
});
|
|
127
128
|
_defineProperty(VennChartComponent, "enhance", [i18nEnhance(localizedMessages)]);
|
|
128
129
|
export const VennChart = createComponent(VennChartComponent);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VennChart.js","names":["createComponent","i18nEnhance","Text","scaleLinear","React","Venn","AbstractChart","localizedMessages","VennChartComponent","xScale","asProps","yScale","dataKeys","data","props","legendKeys","Object","keys","filter","item","isIntersection","test","defaultLegendProps","legendType","renderChart","onClickVennItem","dataDefinitions","
|
|
1
|
+
{"version":3,"file":"VennChart.js","names":["createComponent","i18nEnhance","Text","scaleLinear","React","Venn","AbstractChart","localizedMessages","VennChartComponent","xScale","asProps","yScale","dataKeys","data","props","legendKeys","Object","keys","filter","item","isIntersection","test","defaultLegendProps","legendType","renderChart","onClickVennItem","dataDefinitions","highlightedItem","state","checkedLegendItems","checked","checkedLegendItemsMap","reduce","result","id","intersections","dataKey","push","createElement","onClick","map","index","Circle","key","name","label","color","transparent","intersectionKey","intersectionKeys","split","hasDisabledItems","some","undefined","find","legendItem","join","Intersection","renderTooltip","Tooltip","children","Fragment","Title","tooltipTitleFormatter","bold","tooltipValueFormatter","getLegendAriaLabel","getI18nText","chartType","_defineProperty","direction","alignItems","marginY","marginX","locale","VennChart"],"sources":["../../../../src/component/Chart/VennChart.tsx"],"sourcesContent":["import { createComponent } from '@semcore/core';\nimport i18nEnhance from '@semcore/core/lib/utils/enhances/i18nEnhance';\nimport { Text } from '@semcore/typography';\nimport { scaleLinear } from 'd3-scale';\nimport React from 'react';\n\n// @ts-ignore\nimport { Venn } from '../..';\nimport type { ChartState } from './AbstractChart';\nimport { AbstractChart } from './AbstractChart';\nimport type { VennChartData, VennChartDefaultProps, VennChartProps, VennChartType } from './VennChart.type';\nimport { localizedMessages } from '../../translations/__intergalactic-dynamic-locales';\nimport type { LegendItem } from '../ChartLegend/LegendItem/LegendItem.type';\n\nclass VennChartComponent extends AbstractChart<\n VennChartData,\n VennChartProps,\n typeof VennChartComponent.enhance,\n {},\n ChartState,\n VennChartDefaultProps\n> {\n static displayName = 'Chart.Venn';\n\n static defaultProps = {\n direction: 'row-reverse',\n alignItems: 'flex-start',\n marginY: 0,\n marginX: 0,\n locale: 'en',\n } as const;\n\n static enhance = [i18nEnhance(localizedMessages)] as const;\n\n get xScale() {\n const { xScale } = this.asProps;\n\n if (xScale) {\n return xScale;\n }\n\n return scaleLinear();\n }\n\n get yScale() {\n const { yScale } = this.asProps;\n\n if (yScale) {\n return yScale;\n }\n\n return scaleLinear();\n }\n\n protected get dataKeys(): string[] {\n const { data } = this.props;\n\n const legendKeys: string[] = Object.keys(data).filter((item) => {\n const isIntersection = /\\//.test(item);\n\n return !isIntersection;\n });\n\n return legendKeys;\n }\n\n defaultLegendProps() {\n return {\n legendType: 'Table' as const,\n };\n }\n\n renderChart() {\n const { data, onClickVennItem } = this.asProps;\n const { dataDefinitions, highlightedItem } = this.state;\n\n const checkedLegendItems = dataDefinitions.filter((item) => item.checked);\n const checkedLegendItemsMap = checkedLegendItems.reduce<Record<string, LegendItem>>(\n (result, item) => {\n result[item.id] = item;\n\n return result;\n },\n {},\n );\n\n const intersections = Object.keys(data).reduce<string[]>((result, dataKey) => {\n const isIntersection = /\\//.test(dataKey);\n\n if (isIntersection) {\n result.push(dataKey);\n }\n\n return result;\n }, []);\n\n return (\n <Venn onClick={onClickVennItem}>\n {checkedLegendItems.map((item, index) => {\n return (\n <Venn.Circle\n key={item.id}\n dataKey={item.id}\n name={item.label}\n color={item.color}\n transparent={highlightedItem !== -1 && highlightedItem !== index}\n />\n );\n })}\n\n {intersections.map((intersectionKey) => {\n const intersectionKeys = intersectionKey.split('/');\n\n const hasDisabledItems = intersectionKeys.some((key) => {\n return checkedLegendItemsMap[key] === undefined;\n });\n\n if (hasDisabledItems) {\n return null;\n }\n\n const name = intersectionKeys\n .map((id) => {\n return dataDefinitions.find((legendItem) => legendItem.id === id)?.label || '';\n })\n .join(' & ');\n\n return <Venn.Intersection key={intersectionKey} dataKey={intersectionKey} name={name} />;\n })}\n </Venn>\n );\n }\n\n renderTooltip() {\n return (\n <Venn.Tooltip>\n {({ name, dataKey, data }: any) => {\n return {\n children: (\n <>\n <Venn.Tooltip.Title>{this.tooltipTitleFormatter(name)}</Venn.Tooltip.Title>\n <Text bold>{this.tooltipValueFormatter(data[dataKey])}</Text>\n </>\n ),\n };\n }}\n </Venn.Tooltip>\n );\n }\n\n protected getLegendAriaLabel(): string {\n return this.asProps.getI18nText('legendForChart', { chartType: 'Venn' });\n }\n}\n\n/**\n * VennChart\n *\n * {@link https://developer.semrush.com/intergalactic/data-display/venn-chart/venn-chart-api/|API} | {@link https://developer.semrush.com/intergalactic/data-display/venn-chart/venn-chart-code/|Examples}\n */\nexport const VennChart = createComponent<\n VennChartType,\n typeof VennChartComponent\n>(VennChartComponent);\n"],"mappings":";AAAA,SAASA,eAAe,QAAQ,eAAe;AAC/C,OAAOC,WAAW,MAAM,8CAA8C;AACtE,SAASC,IAAI,QAAQ,qBAAqB;AAC1C,SAASC,WAAW,QAAQ,UAAU;AACtC,OAAOC,KAAK,MAAM,OAAO;;AAEzB;AACA,SAASC,IAAI,QAAQ,OAAO;AAE5B,SAASC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AAAL,eAAA,CAhBG7D,kBAAkB,aAkBL,CAACP,WAAW,CAACM,iBAAiB,CAAC,CAAC;AAgInD,OAAO,MAAMoE,SAAS,GAAG3E,eAAe,CAGtCQ,kBAAkB,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VennChart.type.js","names":[],"sources":["../../../../src/component/Chart/VennChart.type.ts"],"sourcesContent":["import type { Flex } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\nimport type { ScaleLinear } from 'd3-scale';\n\nimport type { BaseChartProps } from './AbstractChart.type';\n\nexport type DataKey = string;\n\nexport type VennChartData = Record<DataKey, number>;\n\nexport type VennChartProps = Intergalactic.InternalTypings.EfficientOmit<\n BaseChartProps<VennChartData>,\n 'showTotalInTooltip'\n> & {\n /** Internal */\n groupKey?: never;\n /** Custom x-axis scale */\n xScale?: ScaleLinear<any, any>;\n /** Custom y-axis scale */\n yScale?: ScaleLinear<any, any>;\n /** Callback triggered when a user clicks on a circle */\n onClickVennItem?: (key: DataKey, e: React.SyntheticEvent) => void;\n};\n\nexport type VennChartDefaultProps = {\n direction: 'row-reverse';\n alignItems: 'flex-start';\n marginY: 0;\n marginX: 0;\n};\n\nexport type VennChartType = Intergalactic.Component<typeof Flex, VennChartProps>;\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"VennChart.type.js","names":[],"sources":["../../../../src/component/Chart/VennChart.type.ts"],"sourcesContent":["import type { Flex } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\nimport type { ScaleLinear } from 'd3-scale';\n\nimport type { BaseChartProps } from './AbstractChart.type';\n\nexport type DataKey = string;\n\nexport type VennChartData = Record<DataKey, number>;\n\nexport type VennChartProps = Intergalactic.InternalTypings.EfficientOmit<\n BaseChartProps<VennChartData>,\n 'showTotalInTooltip' | 'showDeltaPercentInTooltip' | 'getPercentDelta'\n> & {\n /** Internal */\n groupKey?: never;\n /** Custom x-axis scale */\n xScale?: ScaleLinear<any, any>;\n /** Custom y-axis scale */\n yScale?: ScaleLinear<any, any>;\n /** Callback triggered when a user clicks on a circle */\n onClickVennItem?: (key: DataKey, e: React.SyntheticEvent) => void;\n};\n\nexport type VennChartDefaultProps = {\n direction: 'row-reverse';\n alignItems: 'flex-start';\n marginY: 0;\n marginX: 0;\n locale: 'en';\n};\n\nexport type VennChartType = Intergalactic.Component<typeof Flex, VennChartProps>;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -62,7 +62,8 @@ export class BaseLegend extends Component {
|
|
|
62
62
|
const {
|
|
63
63
|
shape = 'Checkbox',
|
|
64
64
|
size = 'm',
|
|
65
|
-
patterns
|
|
65
|
+
patterns,
|
|
66
|
+
highlightedItem
|
|
66
67
|
} = this.asProps;
|
|
67
68
|
const line = this.getItem(index);
|
|
68
69
|
return {
|
|
@@ -78,7 +79,8 @@ export class BaseLegend extends Component {
|
|
|
78
79
|
gridRowStart: `${index + 1}`,
|
|
79
80
|
gridRowEnd: `${index + 2}`
|
|
80
81
|
},
|
|
81
|
-
patterns
|
|
82
|
+
patterns,
|
|
83
|
+
transparent: highlightedItem !== undefined && highlightedItem !== -1 && highlightedItem !== index
|
|
82
84
|
};
|
|
83
85
|
}
|
|
84
86
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseLegend.js","names":["Component","makeDataHintsHandlers","BaseLegend","constructor","args","_defineProperty","shape","id","checked","props","onChangeVisibleItem","onMouseEnterItem","onMouseLeaveItem","e","componentDidMount","setHints","componentDidUpdate","prevProps","items","dataHints","asProps","dataHintsHandler","undefined","forEach","legendItem","labelKey","label","getItem","index","line","Error","getLegendItemProps","_","size","patterns","onFocusLegendItem","onBlurLegendItem","onChangeLegendItem","onMouseEnter","bindOnMouseEnterItem","onMouseLeave","bindOnMouseLeaveItem","style","gridRowStart","gridRowEnd"],"sources":["../../../../src/component/ChartLegend/BaseLegend.tsx"],"sourcesContent":["import { Component, type Intergalactic } from '@semcore/core';\nimport type React from 'react';\n\nimport type { LegendProps } from './BaseLegend.type';\nimport { type LegendItemKey, type LegendItemProps, type ShapeType } from './LegendItem/LegendItem.type';\nimport { makeDataHintsHandlers } from '../../a11y/hints';\n\nexport abstract class BaseLegend<\n P extends LegendProps,\n E extends readonly ((...args: any[]) => any)[] = never[],\n DP extends Intergalactic.InternalTypings.ValidDefaultProps<DP, P> = never,\n> extends Component<P, E, never,
|
|
1
|
+
{"version":3,"file":"BaseLegend.js","names":["Component","makeDataHintsHandlers","BaseLegend","constructor","args","_defineProperty","shape","id","checked","props","onChangeVisibleItem","onMouseEnterItem","onMouseLeaveItem","e","componentDidMount","setHints","componentDidUpdate","prevProps","items","dataHints","asProps","dataHintsHandler","undefined","forEach","legendItem","labelKey","label","getItem","index","line","Error","getLegendItemProps","_","size","patterns","highlightedItem","onFocusLegendItem","onBlurLegendItem","onChangeLegendItem","onMouseEnter","bindOnMouseEnterItem","onMouseLeave","bindOnMouseLeaveItem","style","gridRowStart","gridRowEnd","transparent"],"sources":["../../../../src/component/ChartLegend/BaseLegend.tsx"],"sourcesContent":["import { Component, type Intergalactic } from '@semcore/core';\nimport type React from 'react';\n\nimport type { LegendProps } from './BaseLegend.type';\nimport { type LegendItemKey, type LegendItemProps, type ShapeType } from './LegendItem/LegendItem.type';\nimport { makeDataHintsHandlers } from '../../a11y/hints';\n\ntype InnerProps = {\n highlightedItem?: number;\n};\nexport abstract class BaseLegend<\n P extends LegendProps,\n E extends readonly ((...args: any[]) => any)[] = never[],\n DP extends Intergalactic.InternalTypings.ValidDefaultProps<DP, P> = never,\n> extends Component<P, E, never, InnerProps, {}, DP> {\n componentDidMount() {\n this.setHints();\n }\n\n componentDidUpdate(prevProps: P) {\n if (prevProps.items !== this.props.items || prevProps.dataHints !== this.props.dataHints) {\n this.setHints();\n }\n }\n\n setHints() {\n const { items, dataHints } = this.asProps;\n const dataHintsHandler = dataHints ? makeDataHintsHandlers(dataHints) : undefined;\n\n items.forEach((legendItem) => {\n dataHintsHandler?.labelKey('value', legendItem.id, legendItem.label);\n });\n }\n\n getItem(index: number) {\n const line = this.asProps.items[index];\n\n if (line === undefined) {\n throw new Error(`No index \"${index}\" in lines`);\n }\n\n return line;\n }\n\n getLegendItemProps(\n _: {},\n index: number,\n ): LegendItemProps & Intergalactic.InternalTypings.ComponentPropsNesting<'div'> {\n const { shape = 'Checkbox', size = 'm', patterns, highlightedItem } = this.asProps;\n const line = this.getItem(index);\n\n return {\n ...line,\n shape,\n size,\n onFocusLegendItem: this.onFocusLegendItem(line.checked),\n onBlurLegendItem: this.onBlurLegendItem,\n onChangeLegendItem: this.onChangeLegendItem(shape),\n onMouseEnter: line.checked ? this.bindOnMouseEnterItem(line.id) : undefined,\n onMouseLeave: this.bindOnMouseLeaveItem(line.id),\n style: { gridRowStart: `${index + 1}`, gridRowEnd: `${index + 2}` },\n patterns,\n transparent: highlightedItem !== undefined && (highlightedItem !== -1 && highlightedItem !== index),\n };\n }\n\n onChangeLegendItem = (shape: ShapeType) => (id: LegendItemKey, checked: boolean) => {\n if (shape !== 'Checkbox') return;\n\n this.props.onChangeVisibleItem?.(id, checked);\n\n if (checked) {\n this.props.onMouseEnterItem?.(id);\n } else {\n this.props.onMouseLeaveItem?.(id);\n }\n };\n\n onFocusLegendItem = (checked: boolean) => (id: LegendItemKey) => {\n if (!checked) {\n return this.props.onMouseLeaveItem?.(id);\n }\n\n this.props.onMouseEnterItem?.(id);\n };\n\n onBlurLegendItem = (id: LegendItemKey) => {\n this.props.onMouseLeaveItem?.(id);\n };\n\n bindOnMouseEnterItem = (id: LegendItemKey) => {\n return (e: React.SyntheticEvent) => {\n this.props.onMouseEnterItem?.(id, e);\n };\n };\n\n bindOnMouseLeaveItem = (id: LegendItemKey) => {\n return (e: React.SyntheticEvent) => {\n this.props.onMouseLeaveItem?.(id, e);\n };\n };\n}\n"],"mappings":";AAAA,SAASA,SAAS,QAA4B,eAAe;AAK7D,SAASC,qBAAqB,QAAQ,kBAAkB;AAKxD,OAAO,M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ACrB,OAAO,GAAG,IAAI,CAACgC,oBAAoB,CAACX,IAAI,CAACtB,EAAE,CAAC,GAAGe,SAAS;MAC3EmB,YAAY,EAAE,IAAI,CAACC,oBAAoB,CAACb,IAAI,CAACtB,EAAE,CAAC;MAChDoC,KAAK,EAAE;QAAEC,YAAY,EAAE,GAAGhB,KAAK,GAAG,CAAC,EAAE;QAAEiB,UAAU,EAAE,GAAGjB,KAAK,GAAG,CAAC;MAAG,CAAC;MACnEM,QAAQ;MACRY,WAAW,EAAEX,eAAe,KAAKb,SAAS,IAAKa,eAAe,KAAK,CAAC,CAAC,IAAIA,eAAe,KAAKP;IAC/F,CAAC;EACH;AAqCF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseLegend.type.js","names":[],"sources":["../../../../src/component/ChartLegend/BaseLegend.type.ts"],"sourcesContent":["import type { NSBox, NSFlex } from '@semcore/base-components';\n\nimport type { LegendItem, LegendItemKey, ShapeType } from './LegendItem/LegendItem.type';\nimport type { DataStructureHints } from '../../a11y/hints';\nimport type { PatternsConfig } from '../../Pattern';\nimport type { AriaNameProps } from '../Chart/AbstractChart.type';\n\nexport type LSize = 'm' | 'l';\n\nexport type BaseChartLegendProps = NSFlex.Props &\n AriaNameProps & {\n /**\n * Size for legend items\n */\n size?: LSize;\n /**\n * Shape of data item on Legend panel\n */\n shape?: ShapeType;\n /**\n * Handler for change visible for data items. Doesn't work if
|
|
1
|
+
{"version":3,"file":"BaseLegend.type.js","names":[],"sources":["../../../../src/component/ChartLegend/BaseLegend.type.ts"],"sourcesContent":["import type { NSBox, NSFlex } from '@semcore/base-components';\n\nimport type { LegendItem, LegendItemKey, ShapeType } from './LegendItem/LegendItem.type';\nimport type { DataStructureHints } from '../../a11y/hints';\nimport type { PatternsConfig } from '../../Pattern';\nimport type { AriaNameProps } from '../Chart/AbstractChart.type';\n\nexport type LSize = 'm' | 'l';\n\nexport type BaseChartLegendProps = NSFlex.Props &\n AriaNameProps & {\n /**\n * Size for legend items\n */\n size?: LSize;\n /**\n * Shape of data item on Legend panel\n */\n shape?: ShapeType;\n /**\n * Handler for change visible for data items. Doesn't work if `shape` is 'Circle'.\n */\n onChangeVisibleItem?: (key: LegendItemKey, isVisible: boolean) => void;\n\n onMouseEnterItem?: (key: LegendItemKey, e?: React.SyntheticEvent) => void;\n\n onMouseLeaveItem?: (key: LegendItemKey, e?: React.SyntheticEvent) => void;\n\n dataHints?: DataStructureHints;\n };\n\nexport type LegendProps = NSBox.Props &\n BaseChartLegendProps & {\n /**\n * Legend items\n */\n items: LegendItem[];\n\n /** Enables charts patterns that enhances charts accessibility */\n patterns?: PatternsConfig;\n };\n"],"mappings":"","ignoreList":[]}
|
|
@@ -8,12 +8,12 @@ import i18nEnhance from '@semcore/core/lib/utils/enhances/i18nEnhance';
|
|
|
8
8
|
import Divider from '@semcore/divider';
|
|
9
9
|
import React from 'react';
|
|
10
10
|
/*!__reshadow-styles__:"./legend-flex.shadow.css"*/
|
|
11
|
-
const style = (/*__reshadow_css_start__*/_sstyled.insert(/*__inner_css_start__*/".
|
|
11
|
+
const style = (/*__reshadow_css_start__*/_sstyled.insert(/*__inner_css_start__*/".___SLegendFlex_er9v1_gg_._direction_row_er9v1_gg_{align-items:flex-start;align-content:flex-start;flex-wrap:wrap;gap:var(--intergalactic-spacing-content-gap-large,8px) var(--intergalactic-spacing-content-gap-xxlarge,16px)}.___SLegendFlex_er9v1_gg_._direction_column_er9v1_gg_{align-items:flex-start;flex-wrap:wrap;gap:var(--intergalactic-spacing-content-gap-large,8px)}", /*__inner_css_end__*/"er9v1_gg_"),
|
|
12
12
|
/*__reshadow_css_end__*/
|
|
13
13
|
{
|
|
14
|
-
"__SLegendFlex": "
|
|
15
|
-
"_direction_row": "
|
|
16
|
-
"_direction_column": "
|
|
14
|
+
"__SLegendFlex": "___SLegendFlex_er9v1_gg_",
|
|
15
|
+
"_direction_row": "_direction_row_er9v1_gg_",
|
|
16
|
+
"_direction_column": "_direction_column_er9v1_gg_"
|
|
17
17
|
});
|
|
18
18
|
import { localizedMessages } from '../../../translations/__intergalactic-dynamic-locales';
|
|
19
19
|
import { BaseLegend } from '../BaseLegend';
|
|
@@ -2,11 +2,11 @@ SLegendFlex[direction='row'] {
|
|
|
2
2
|
align-items: flex-start;
|
|
3
3
|
align-content: flex-start;
|
|
4
4
|
flex-wrap: wrap;
|
|
5
|
-
gap: 8px 16px;
|
|
5
|
+
gap: var(--intergalactic-spacing-content-gap-large, 8px) var(--intergalactic-spacing-content-gap-xxlarge, 16px);
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
SLegendFlex[direction='column'] {
|
|
9
9
|
align-items: flex-start;
|
|
10
10
|
flex-wrap: wrap;
|
|
11
|
-
gap: 8px;
|
|
11
|
+
gap: var(--intergalactic-spacing-content-gap-large, 8px);
|
|
12
12
|
}
|
|
@@ -14,25 +14,24 @@ import uniqueIDEnhancement from '@semcore/core/lib/utils/uniqueID';
|
|
|
14
14
|
import { Text as TypographyText } from '@semcore/typography';
|
|
15
15
|
import React from 'react';
|
|
16
16
|
/*!__reshadow-styles__:"./legend-item.shadow.css"*/
|
|
17
|
-
const style = (/*__reshadow_css_start__*/_sstyled.insert(/*__inner_css_start__*/".
|
|
17
|
+
const style = (/*__reshadow_css_start__*/_sstyled.insert(/*__inner_css_start__*/".___SLegendItem_1g89n_gg_{min-width:0;align-items:flex-start}@media (hover:hover){.___SLegendItem_1g89n_gg_:hover{cursor:pointer}.___SLegendItem_1g89n_gg_.__disabled_1g89n_gg_:hover{cursor:default}}.___SLegendItem_1g89n_gg_.__transparent_1g89n_gg_{opacity:.3}.___SPointShape_1g89n_gg_.__color_1g89n_gg_{background-color:var(--color_1g89n);margin-right:var(--intergalactic-spacing-content-gap-medium,6px);flex-shrink:0}.___SPointShape_1g89n_gg_._shape_Circle_1g89n_gg_._size_l_1g89n_gg_{width:16px;height:16px;border-radius:8px;margin-top:var(--intergalactic-spacing-content-gap-small,4px)}.___SPointShape_1g89n_gg_._shape_Circle_1g89n_gg_._size_m_1g89n_gg_{width:12px;height:12px;border-radius:6px;margin-top:var(--intergalactic-spacing-content-gap-small,4px)}.___SPointShape_1g89n_gg_._shape_Pattern_1g89n_gg_{background-color:initial;margin-right:var(--intergalactic-spacing-content-gap-small,4px)}.___SIcon_1g89n_gg_{line-height:0;margin-right:var(--intergalactic-spacing-content-gap-small,4px)}.___SIcon_1g89n_gg_._size_l_1g89n_gg_{margin-top:var(--intergalactic-spacing-content-gap-small,4px)}.___SIcon_1g89n_gg_._size_m_1g89n_gg_{margin-top:var(--intergalactic-spacing-content-gap-xsmall,2px)}.___SLabel_1g89n_gg_{min-width:0}.___SAdditionalLabel_1g89n_gg_._size_l_1g89n_gg_,.___SCount_1g89n_gg_._size_l_1g89n_gg_,.___SLabel_1g89n_gg_._size_l_1g89n_gg_{font-size:var(--intergalactic-fs-300,16px);line-height:var(--intergalactic-lh-300,1.5)}.___SAdditionalLabel_1g89n_gg_._size_m_1g89n_gg_,.___SCount_1g89n_gg_._size_m_1g89n_gg_,.___SLabel_1g89n_gg_._size_m_1g89n_gg_{font-size:var(--intergalactic-fs-200,14px);line-height:var(--intergalactic-lh-200,1.4286)}.___SAdditionalLabel_1g89n_gg_,.___SCount_1g89n_gg_{margin-left:var(--intergalactic-spacing-content-gap-small,4px)}.___SAdditionalLabel_1g89n_gg_{white-space:nowrap;display:flex;align-items:flex-start}.___SAdditionalLabel_1g89n_gg_:before{content:\"\";display:inline-block;background-color:var(--intergalactic-text-secondary,oklch(.097 .023 156.5/.468));height:4px;width:4px;border-radius:2px;margin-right:var(--intergalactic-spacing-content-gap-small,4px)}.___SAdditionalLabel_1g89n_gg_._size_l_1g89n_gg_:before{margin-top:10px}.___SAdditionalLabel_1g89n_gg_._size_m_1g89n_gg_:before{margin-top:8px}.___SPatternSymbol_1g89n_gg_{transform:scale(.8)}", /*__inner_css_end__*/"1g89n_gg_"),
|
|
18
18
|
/*__reshadow_css_end__*/
|
|
19
19
|
{
|
|
20
|
-
"__SLegendItem": "
|
|
21
|
-
"_disabled": "
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"__SPatternSymbol": "___SPatternSymbol_de4s5_gg_"
|
|
20
|
+
"__SLegendItem": "___SLegendItem_1g89n_gg_",
|
|
21
|
+
"_disabled": "__disabled_1g89n_gg_",
|
|
22
|
+
"_transparent": "__transparent_1g89n_gg_",
|
|
23
|
+
"__SPointShape": "___SPointShape_1g89n_gg_",
|
|
24
|
+
"_color": "__color_1g89n_gg_",
|
|
25
|
+
"--color": "--color_1g89n",
|
|
26
|
+
"_shape_Circle": "_shape_Circle_1g89n_gg_",
|
|
27
|
+
"_size_l": "_size_l_1g89n_gg_",
|
|
28
|
+
"_size_m": "_size_m_1g89n_gg_",
|
|
29
|
+
"_shape_Pattern": "_shape_Pattern_1g89n_gg_",
|
|
30
|
+
"__SIcon": "___SIcon_1g89n_gg_",
|
|
31
|
+
"__SLabel": "___SLabel_1g89n_gg_",
|
|
32
|
+
"__SAdditionalLabel": "___SAdditionalLabel_1g89n_gg_",
|
|
33
|
+
"__SCount": "___SCount_1g89n_gg_",
|
|
34
|
+
"__SPatternSymbol": "___SPatternSymbol_1g89n_gg_"
|
|
36
35
|
});
|
|
37
36
|
import { StaticShapes } from './LegendItem.type';
|
|
38
37
|
import { PatternSymbol } from '../../../Pattern';
|
|
@@ -86,7 +85,11 @@ class LegendItemRoot extends Component {
|
|
|
86
85
|
};
|
|
87
86
|
}
|
|
88
87
|
getIconProps() {
|
|
89
|
-
const
|
|
88
|
+
const {
|
|
89
|
+
onMouseEnter,
|
|
90
|
+
onMouseLeave,
|
|
91
|
+
...props
|
|
92
|
+
} = this.asProps;
|
|
90
93
|
return {
|
|
91
94
|
...props,
|
|
92
95
|
children: props.icon,
|
|
@@ -104,6 +107,8 @@ class LegendItemRoot extends Component {
|
|
|
104
107
|
color: _color,
|
|
105
108
|
onChangeLegendItem,
|
|
106
109
|
shape: _shape,
|
|
110
|
+
onMouseEnter,
|
|
111
|
+
onMouseLeave,
|
|
107
112
|
...props
|
|
108
113
|
} = this.asProps;
|
|
109
114
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LegendItem.js","names":["Flex","Box","Checkbox","createComponent","Component","sstyled","Root","resolveColorEnhance","uniqueIDEnhancement","Text","TypographyText","React","style","_sstyled","insert","StaticShapes","PatternSymbol","getChartDefaultColorName","enhance","LegendItemRoot","getUniqueID","uid","asProps","getShapeProps","checked","color","shape","label","id","size","resolveColor","patterns","onChangeLegendItem","onFocusLegendItem","onBlurLegendItem","value","onFocus","onBlur","getIconProps","props","children","icon","onClick","getLabelProps","_color","_shape","getAdditionalLabelProps","additionalInfo","undefined","getCountProps","count","render","_ref","_ref7","SLegendItem","styles","Children","disabled","includes","createElement","cn","_assignProps","_defineProperty","Fragment","LegendItemComponent","Shape","Icon","Label","AdditionalLabel","Count","_ref2","arguments[0]","_ref0","SPointShape","SPatternSymbol","patternKey","hasChildren","onChange","_ref8","_ref9","_assignProps2","_ref3","_ref1","SIcon","_assignProps3","displayName","_ref4","_ref10","SLabel","_assignProps4","_ref5","_ref11","SAdditionalLabel","_assignProps5","_ref6","_ref12","SCount","_assignProps6"],"sources":["../../../../../src/component/ChartLegend/LegendItem/LegendItem.tsx"],"sourcesContent":["import { Flex, Box } from '@semcore/base-components';\nimport Checkbox from '@semcore/checkbox';\nimport { type Intergalactic, createComponent, Component, sstyled, Root } from '@semcore/core';\nimport resolveColorEnhance from '@semcore/core/lib/utils/enhances/resolveColorEnhance';\nimport uniqueIDEnhancement from '@semcore/core/lib/utils/uniqueID';\nimport { Text as TypographyText } from '@semcore/typography';\nimport React from 'react';\n\nimport style from './legend-item.shadow.css';\nimport {\n type LegendItemShapeType,\n type LegendItemDefaultProps,\n type LegendItemType,\n StaticShapes,\n type LegendItemIconType,\n type LegendItemLabelType,\n type LegendItemAdditionalLabelType,\n type LegendItemCountType,\n} from './LegendItem.type';\nimport { PatternSymbol } from '../../../Pattern';\nimport { getChartDefaultColorName } from '../../../utils';\n\nconst enhance = [resolveColorEnhance(), uniqueIDEnhancement()] as const;\nclass LegendItemRoot extends Component<\n Intergalactic.InternalTypings.InferComponentProps<LegendItemType>,\n typeof enhance,\n {},\n {},\n {},\n LegendItemDefaultProps\n> {\n static displayName = 'LegendItem';\n static style = style;\n\n static enhance = enhance;\n\n static defaultProps = () => ({\n children: (\n <>\n <LegendItemComponent.Shape />\n <LegendItemComponent.Icon />\n <LegendItemComponent.Label />\n <LegendItemComponent.AdditionalLabel />\n <LegendItemComponent.Count />\n </>\n ),\n });\n\n getUniqueID() {\n const { uid } = this.asProps;\n return `chart-legend-item-${uid}`;\n }\n\n getShapeProps() {\n const { checked, color, shape, label, id, size, resolveColor, patterns, onChangeLegendItem, onFocusLegendItem, onBlurLegendItem } =\n this.asProps;\n return {\n label,\n shape,\n checked,\n 'color': resolveColor(color),\n 'patternKey': color,\n patterns,\n size,\n 'onChange': (value: boolean) => {\n if (onChangeLegendItem && id) {\n onChangeLegendItem(id, value);\n }\n },\n 'onFocus': () => {\n if (onFocusLegendItem && id) {\n onFocusLegendItem(id);\n }\n },\n 'onBlur': () => {\n if (onBlurLegendItem && id) {\n onBlurLegendItem(id);\n }\n },\n 'aria-labelledby': shape === 'Checkbox' ? this.getUniqueID() : null,\n };\n }\n\n getIconProps() {\n const props = this.asProps;\n\n return {\n ...props,\n children: props.icon,\n onClick: () => {\n if (props.onChangeLegendItem && props.id) {\n props.onChangeLegendItem(props.id, !props.checked);\n }\n },\n };\n }\n\n getLabelProps() {\n const { id, checked, color: _color, onChangeLegendItem, shape: _shape, ...props } = this.asProps;\n\n return {\n ...props,\n id: this.getUniqueID(),\n checked,\n onClick: () => {\n if (onChangeLegendItem && id) {\n onChangeLegendItem(id, !checked);\n }\n },\n children: props.label,\n };\n }\n\n getAdditionalLabelProps() {\n const props = this.asProps;\n\n const { additionalInfo, onChangeLegendItem, id, checked } = props;\n\n return {\n ...props,\n children: additionalInfo && 'label' in additionalInfo ? `${additionalInfo.label}` : undefined,\n onClick: () => {\n if (onChangeLegendItem && id) {\n onChangeLegendItem(id, !checked);\n }\n },\n };\n }\n\n getCountProps() {\n const props = this.asProps;\n\n const { additionalInfo, onChangeLegendItem, id, checked } = props;\n\n return {\n ...props,\n children:\n additionalInfo && 'count' in additionalInfo ? `(${additionalInfo.count})` : undefined,\n onClick: () => {\n if (onChangeLegendItem && id) {\n onChangeLegendItem(id, !checked);\n }\n },\n };\n }\n\n render() {\n const SLegendItem = Root;\n const { styles, Children, shape } = this.asProps;\n\n // @ts-ignore\n const disabled = StaticShapes.includes(shape) || shape === undefined;\n\n return sstyled(styles)(\n <SLegendItem render={Flex} disabled={disabled} __excludeProps={['id']}>\n <Children />\n </SLegendItem>,\n );\n }\n}\n\nfunction Shape(\n props: Intergalactic.InternalTypings.InferChildComponentProps<LegendItemShapeType, typeof LegendItemRoot, 'Shape'>,\n) {\n const SPointShape = Root;\n const SPatternSymbol = PatternSymbol;\n const {\n styles,\n size,\n shape,\n checked,\n color,\n patternKey = getChartDefaultColorName(0),\n Children,\n children: hasChildren,\n patterns,\n onChange,\n onFocus,\n onBlur,\n } = props;\n\n if (hasChildren) {\n return <Children />;\n }\n\n if (shape === 'Pattern') {\n return sstyled(styles)(\n <Box mr={1}>\n <SPatternSymbol color={color} patternKey={patternKey} aria-hidden />\n </Box>,\n );\n }\n\n if (shape === 'Checkbox') {\n return sstyled(styles)(\n <>\n <Checkbox\n size={size}\n checked={checked}\n theme={color}\n onChange={onChange}\n onFocus={onFocus}\n onBlur={onBlur}\n aria-labelledby={props['aria-labelledby']}\n />\n {patterns && (\n <Box mt='2px' mr={1} onClick={() => onChange(!checked)}>\n <SPatternSymbol color={color} patternKey={patternKey} aria-hidden />\n </Box>\n )}\n </>,\n );\n }\n\n return sstyled(styles)(\n <SPointShape render={Box}>\n <Children />\n </SPointShape>,\n );\n}\n\nfunction Icon(\n props: Intergalactic.InternalTypings.InferChildComponentProps<LegendItemIconType, typeof LegendItemRoot, 'Icon'>,\n) {\n const { styles, children: hasChildren, Children } = props;\n const SIcon = Root;\n\n if (!hasChildren) {\n return null;\n }\n\n return sstyled(styles)(\n <SIcon render={Box} tag='span'>\n <Children />\n </SIcon>,\n );\n}\nIcon.displayName = 'Icon';\n\nfunction Label(\n props: Intergalactic.InternalTypings.InferChildComponentProps<LegendItemLabelType, typeof LegendItemRoot, 'Label'>,\n) {\n const { styles, children: hasChildren, Children } = props;\n const SLabel = Root;\n\n if (!hasChildren) {\n return null;\n }\n\n return sstyled(styles)(\n <SLabel render={TypographyText} use='primary'>\n <Children />\n </SLabel>,\n );\n}\nLabel.displayName = 'Label';\n\nfunction AdditionalLabel(\n props: Intergalactic.InternalTypings.InferChildComponentProps<LegendItemAdditionalLabelType, typeof LegendItemRoot, 'AdditionalLabel'>,\n) {\n const { styles, children: hasChildren, Children } = props;\n const SAdditionalLabel = Root;\n\n if (!hasChildren) {\n return null;\n }\n\n return sstyled(styles)(\n <SAdditionalLabel render={TypographyText} use='secondary'>\n <Children />\n </SAdditionalLabel>,\n );\n}\nAdditionalLabel.displayName = 'AdditionalLabel';\n\nfunction Count(\n props: Intergalactic.InternalTypings.InferChildComponentProps<LegendItemCountType, typeof LegendItemRoot, 'Count'>,\n) {\n const { styles, children: hasChildren, Children } = props;\n const SCount = Root;\n\n if (!hasChildren) {\n return null;\n }\n\n return sstyled(styles)(\n <SCount render={TypographyText} use='secondary'>\n <Children />\n </SCount>,\n );\n}\nCount.displayName = 'Count';\n\n/**\n * LegendItemComponent\n *\n * {@link https://developer.semrush.com/intergalactic/data-display/chart-legend/chart-legend-api/|API} | {@link https://developer.semrush.com/intergalactic/data-display/chart-legend/chart-legend-code/|Examples}\n */\nexport const LegendItem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;EACb;EAEA,OAAAmB,MAAA,GAAO1F,OAAO,CAACkD,MAAM,CAAC,eACpB5C,KAAA,CAAAgD,aAAA,CAACqC,MAAM,EAAAD,MAAA,CAAAnC,EAAA;IAAA,GAAAqC,aAAA;MAAA,OAA6B;IAAW,GAAAH,KAAA;EAAA,iBAC7CnF,KAAA,CAAAgD,aAAA,CAACH,QAAQ,EAAAuC,MAAA,CAAAnC,EAAA,gBAAE,CACL,CAAC;AAEb;AACAS,KAAK,CAACgB,WAAW,GAAG,OAAO;;AAE3B;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMrB,mBAAmB,GAAG7D,eAAe,CAGhDgB,cAAc,EAAE;EAChB8C,KAAK;EACLC,IAAI;EACJC,KAAK;EACLC,eAAe;EACfC;AACF,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"LegendItem.js","names":["Flex","Box","Checkbox","createComponent","Component","sstyled","Root","resolveColorEnhance","uniqueIDEnhancement","Text","TypographyText","React","style","_sstyled","insert","StaticShapes","PatternSymbol","getChartDefaultColorName","enhance","LegendItemRoot","getUniqueID","uid","asProps","getShapeProps","checked","color","shape","label","id","size","resolveColor","patterns","onChangeLegendItem","onFocusLegendItem","onBlurLegendItem","value","onFocus","onBlur","getIconProps","onMouseEnter","onMouseLeave","props","children","icon","onClick","getLabelProps","_color","_shape","getAdditionalLabelProps","additionalInfo","undefined","getCountProps","count","render","_ref","_ref7","SLegendItem","styles","Children","disabled","includes","createElement","cn","_assignProps","_defineProperty","Fragment","LegendItemComponent","Shape","Icon","Label","AdditionalLabel","Count","_ref2","arguments[0]","_ref0","SPointShape","SPatternSymbol","patternKey","hasChildren","onChange","_ref8","_ref9","_assignProps2","_ref3","_ref1","SIcon","_assignProps3","displayName","_ref4","_ref10","SLabel","_assignProps4","_ref5","_ref11","SAdditionalLabel","_assignProps5","_ref6","_ref12","SCount","_assignProps6"],"sources":["../../../../../src/component/ChartLegend/LegendItem/LegendItem.tsx"],"sourcesContent":["import { Flex, Box } from '@semcore/base-components';\nimport Checkbox from '@semcore/checkbox';\nimport { type Intergalactic, createComponent, Component, sstyled, Root } from '@semcore/core';\nimport resolveColorEnhance from '@semcore/core/lib/utils/enhances/resolveColorEnhance';\nimport uniqueIDEnhancement from '@semcore/core/lib/utils/uniqueID';\nimport { Text as TypographyText } from '@semcore/typography';\nimport React from 'react';\n\nimport style from './legend-item.shadow.css';\nimport {\n type LegendItemShapeType,\n type LegendItemDefaultProps,\n type LegendItemType,\n StaticShapes,\n type LegendItemIconType,\n type LegendItemLabelType,\n type LegendItemAdditionalLabelType,\n type LegendItemCountType,\n} from './LegendItem.type';\nimport { PatternSymbol } from '../../../Pattern';\nimport { getChartDefaultColorName } from '../../../utils';\n\nconst enhance = [resolveColorEnhance(), uniqueIDEnhancement()] as const;\nclass LegendItemRoot extends Component<\n Intergalactic.InternalTypings.InferComponentProps<LegendItemType>,\n typeof enhance,\n {},\n {},\n {},\n LegendItemDefaultProps\n> {\n static displayName = 'LegendItem';\n static style = style;\n\n static enhance = enhance;\n\n static defaultProps = () => ({\n children: (\n <>\n <LegendItemComponent.Shape />\n <LegendItemComponent.Icon />\n <LegendItemComponent.Label />\n <LegendItemComponent.AdditionalLabel />\n <LegendItemComponent.Count />\n </>\n ),\n });\n\n getUniqueID() {\n const { uid } = this.asProps;\n return `chart-legend-item-${uid}`;\n }\n\n getShapeProps() {\n const {\n checked,\n color,\n shape,\n label,\n id,\n size,\n resolveColor,\n patterns,\n onChangeLegendItem,\n onFocusLegendItem,\n onBlurLegendItem,\n } = this.asProps;\n\n return {\n label,\n shape,\n checked,\n 'color': resolveColor(color),\n 'patternKey': color,\n patterns,\n size,\n 'onChange': (value: boolean) => {\n if (onChangeLegendItem && id) {\n onChangeLegendItem(id, value);\n }\n },\n 'onFocus': () => {\n if (onFocusLegendItem && id) {\n onFocusLegendItem(id);\n }\n },\n 'onBlur': () => {\n if (onBlurLegendItem && id) {\n onBlurLegendItem(id);\n }\n },\n 'aria-labelledby': shape === 'Checkbox' ? this.getUniqueID() : null,\n };\n }\n\n getIconProps() {\n const { onMouseEnter, onMouseLeave, ...props } = this.asProps;\n\n return {\n ...props,\n children: props.icon,\n onClick: () => {\n if (props.onChangeLegendItem && props.id) {\n props.onChangeLegendItem(props.id, !props.checked);\n }\n },\n };\n }\n\n getLabelProps() {\n const { id, checked, color: _color, onChangeLegendItem, shape: _shape, onMouseEnter, onMouseLeave, ...props } = this.asProps;\n\n return {\n ...props,\n id: this.getUniqueID(),\n checked,\n onClick: () => {\n if (onChangeLegendItem && id) {\n onChangeLegendItem(id, !checked);\n }\n },\n children: props.label,\n };\n }\n\n getAdditionalLabelProps() {\n const props = this.asProps;\n\n const { additionalInfo, onChangeLegendItem, id, checked } = props;\n\n return {\n ...props,\n children: additionalInfo && 'label' in additionalInfo ? `${additionalInfo.label}` : undefined,\n onClick: () => {\n if (onChangeLegendItem && id) {\n onChangeLegendItem(id, !checked);\n }\n },\n };\n }\n\n getCountProps() {\n const props = this.asProps;\n\n const { additionalInfo, onChangeLegendItem, id, checked } = props;\n\n return {\n ...props,\n children:\n additionalInfo && 'count' in additionalInfo ? `(${additionalInfo.count})` : undefined,\n onClick: () => {\n if (onChangeLegendItem && id) {\n onChangeLegendItem(id, !checked);\n }\n },\n };\n }\n\n render() {\n const SLegendItem = Root;\n const { styles, Children, shape } = this.asProps;\n\n // @ts-ignore\n const disabled = StaticShapes.includes(shape) || shape === undefined;\n\n return sstyled(styles)(\n <SLegendItem render={Flex} disabled={disabled} __excludeProps={['id']}>\n <Children />\n </SLegendItem>,\n );\n }\n}\n\nfunction Shape(\n props: Intergalactic.InternalTypings.InferChildComponentProps<LegendItemShapeType, typeof LegendItemRoot, 'Shape'>,\n) {\n const SPointShape = Root;\n const SPatternSymbol = PatternSymbol;\n const {\n styles,\n size,\n shape,\n checked,\n color,\n patternKey = getChartDefaultColorName(0),\n Children,\n children: hasChildren,\n patterns,\n onChange,\n onFocus,\n onBlur,\n } = props;\n\n if (hasChildren) {\n return <Children />;\n }\n\n if (shape === 'Pattern') {\n return sstyled(styles)(\n <Box mr={1}>\n <SPatternSymbol color={color} patternKey={patternKey} aria-hidden />\n </Box>,\n );\n }\n\n if (shape === 'Checkbox') {\n return sstyled(styles)(\n <>\n <Checkbox\n size={size}\n checked={checked}\n theme={color}\n onChange={onChange}\n onFocus={onFocus}\n onBlur={onBlur}\n aria-labelledby={props['aria-labelledby']}\n />\n {patterns && (\n <Box mt='2px' mr={1} onClick={() => onChange(!checked)}>\n <SPatternSymbol color={color} patternKey={patternKey} aria-hidden />\n </Box>\n )}\n </>,\n );\n }\n\n return sstyled(styles)(\n <SPointShape render={Box}>\n <Children />\n </SPointShape>,\n );\n}\n\nfunction Icon(\n props: Intergalactic.InternalTypings.InferChildComponentProps<LegendItemIconType, typeof LegendItemRoot, 'Icon'>,\n) {\n const { styles, children: hasChildren, Children } = props;\n const SIcon = Root;\n\n if (!hasChildren) {\n return null;\n }\n\n return sstyled(styles)(\n <SIcon render={Box} tag='span'>\n <Children />\n </SIcon>,\n );\n}\nIcon.displayName = 'Icon';\n\nfunction Label(\n props: Intergalactic.InternalTypings.InferChildComponentProps<LegendItemLabelType, typeof LegendItemRoot, 'Label'>,\n) {\n const { styles, children: hasChildren, Children } = props;\n const SLabel = Root;\n\n if (!hasChildren) {\n return null;\n }\n\n return sstyled(styles)(\n <SLabel render={TypographyText} use='primary'>\n <Children />\n </SLabel>,\n );\n}\nLabel.displayName = 'Label';\n\nfunction AdditionalLabel(\n props: Intergalactic.InternalTypings.InferChildComponentProps<LegendItemAdditionalLabelType, typeof LegendItemRoot, 'AdditionalLabel'>,\n) {\n const { styles, children: hasChildren, Children } = props;\n const SAdditionalLabel = Root;\n\n if (!hasChildren) {\n return null;\n }\n\n return sstyled(styles)(\n <SAdditionalLabel render={TypographyText} use='secondary'>\n <Children />\n </SAdditionalLabel>,\n );\n}\nAdditionalLabel.displayName = 'AdditionalLabel';\n\nfunction Count(\n props: Intergalactic.InternalTypings.InferChildComponentProps<LegendItemCountType, typeof LegendItemRoot, 'Count'>,\n) {\n const { styles, children: hasChildren, Children } = props;\n const SCount = Root;\n\n if (!hasChildren) {\n return null;\n }\n\n return sstyled(styles)(\n <SCount render={TypographyText} use='secondary'>\n <Children />\n </SCount>,\n );\n}\nCount.displayName = 'Count';\n\n/**\n * LegendItemComponent\n *\n * {@link https://developer.semrush.com/intergalactic/data-display/chart-legend/chart-legend-api/|API} | {@link https://developer.semrush.com/intergalactic/data-display/chart-legend/chart-legend-code/|Examples}\n */\nexport const LegendItemComponent = createComponent<\n LegendItemType,\n typeof LegendItemRoot\n>(LegendItemRoot, {\n Shape,\n Icon,\n Label,\n AdditionalLabel,\n Count,\n});\n"],"mappings":";;;;;;;;AAAA,SAASA,IAAI,EAAEC,GAAG,QAAQ,0BAA0B;AACpD,OAAOC,QAAQ,MAAM,mBAAmB;AACxC,SAA6BC,eAAe,EAAEC,SAAS,EAAEC,OAAO,EAAEC,IAAI,QAAQ,eAAe;AAC7F,OAAOC,mBAAmB,MAAM,sDAAsD;AACtF,OAAOC,mBAAmB,MAAM,kCAAkC;AAClE,SAASC,IAAI,IAAIC,cAAc,QAAQ,qBAAqB;AAC5D,OAAOC,KAAK,MAAM,OAAO;AAAC;AAAA,MAAAC,KAAA,8BAAAC,QAAA,CAAAC,MAAA;AAAA;AAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAG1B,SAIEC,YAAY,QAKP,mBAAmB;AAC1B,SAASC,aAAa,QAAQ,kBAAkB;AAChD,SAASC,wBAAwB,QAAQ,gBAAgB;AAEzD,MAAMC,OAAO,GAAG,CAACX,mBAAmB,CAAC,CAAC,EAAEC,mBAAmB,CAAC,CAAC,CAAU;AACvE,MAAMW,cAAc,SAASf,SAAS,CAOpC;EAkBAgB,WAAWA,CAAA,EAAG;IACZ,MAAM;MAAEC;IAAI,CAAC,GAAG,IAAI,CAACC,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DjF,KAAA,CAAAkD,aAAA,CAACH,QAAQ,EAAAmC,MAAA,CAAA/B,EAAA,gBAAE,CACK,CAAC;AAEvB;AACAQ,eAAe,CAACiB,WAAW,GAAG,iBAAiB;AAE/C,SAAShB,KAAKA,CACZ9B,KAAkH,EAClH;EAAA,IAAAuD,KAAA,GAAAvB,YAAA;IAAAwB,MAAA;EACA,MAAM;IAAExC,MAAM;IAAEf,QAAQ,EAAEoC,WAAW;IAAEpB;EAAS,CAAC,GAAGjB,KAAK;EACzD,MAAMyD,MAAM,GAOMxF,cAAc;EALhC,IAAI,CAACoE,WAAW,EAAE;IAChB,OAAO,IAAI;EACb;EAEA,OAAAmB,MAAA,GAAO5F,OAAO,CAACoD,MAAM,CAAC,eACpB9C,KAAA,CAAAkD,aAAA,CAACqC,MAAM,EAAAD,MAAA,CAAAnC,EAAA;IAAA,GAAAqC,aAAA;MAAA,OAA6B;IAAW,GAAAH,KAAA;EAAA,iBAC7CrF,KAAA,CAAAkD,aAAA,CAACH,QAAQ,EAAAuC,MAAA,CAAAnC,EAAA,gBAAE,CACL,CAAC;AAEb;AACAS,KAAK,CAACgB,WAAW,GAAG,OAAO;;AAE3B;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMrB,mBAAmB,GAAG/D,eAAe,CAGhDgB,cAAc,EAAE;EAChBgD,KAAK;EACLC,IAAI;EACJC,KAAK;EACLC,eAAe;EACfC;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LegendItem.type.js","names":["StaticShapes"],"sources":["../../../../../src/component/ChartLegend/LegendItem/LegendItem.type.ts"],"sourcesContent":["import type { Box, Flex } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\nimport type Icon from '@semcore/icon';\nimport type { Text } from '@semcore/typography';\n\nimport type { PatternsConfig } from '../../../Pattern';\nimport type { LSize } from '../BaseLegend.type';\n\n/**\n * Key of chart data item\n */\nexport type LegendItemKey = string;\n\nexport type LegendItem = {\n /**\n * One of keys from data set\n */\n id: LegendItemKey;\n /**\n * Label for data item in Legend\n */\n label: string;\n /**\n * Flag for selected data item\n */\n checked: boolean;\n /**\n * Color of data item\n */\n color: string;\n /**\n * Icon before label\n */\n icon?: typeof Icon;\n /**\n * Additional info with sub-label or count\n */\n additionalInfo?: { label: string } | { count: number };\n\n patternKey?: string;\n\n /** Enables patterns symbols that enhances charts accessibility */\n patterns?: PatternsConfig;\n};\n\nexport type LegendItemProps = LegendItem & {\n /**\n * Size for legend item\n */\n size: LSize;\n /**\n * Shape of data item on Legend panel\n */\n shape: ShapeType;\n /**\n * Handler for select/deselect legend item.\n * !Need to redefine onClick, because we don't have `event` in it.\n * @deprecated\n */\n onClick?: () => void;\n\n /** Enables patterns symbols that enhances charts accessibility */\n patterns?: PatternsConfig;\n\n /**\n * Handler for select/deselect legend item\n */\n onChangeLegendItem: (id: LegendItemKey, checked: boolean) => void;\n\n /**\n * Handler for focus legend item\n */\n onFocusLegendItem: (id: LegendItemKey) => void;\n\n /**\n * Handler for focus out legend item\n */\n onBlurLegendItem: (id: LegendItemKey) => void;\n};\n\nexport type LegendItemDefaultProps = {\n children: React.JSX.Element;\n};\n\nexport type ShapeProps = LegendItem &\n (\n | {\n size: LSize;\n shape: Exclude<ShapeType, 'Checkbox'>;\n }\n | {\n 'size': LSize;\n 'shape': Extract<ShapeType, 'Checkbox'>;\n 'onChange': (checked: boolean, e?: React.SyntheticEvent<HTMLInputElement>) => void;\n 'aria-labelledby'?: string;\n }\n );\n\nexport const StaticShapes = ['Circle', '
|
|
1
|
+
{"version":3,"file":"LegendItem.type.js","names":["StaticShapes"],"sources":["../../../../../src/component/ChartLegend/LegendItem/LegendItem.type.ts"],"sourcesContent":["import type { Box, Flex } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\nimport type Icon from '@semcore/icon';\nimport type { Text } from '@semcore/typography';\n\nimport type { PatternsConfig } from '../../../Pattern';\nimport type { LSize } from '../BaseLegend.type';\n\n/**\n * Key of chart data item\n */\nexport type LegendItemKey = string;\n\nexport type LegendItem = {\n /**\n * One of keys from data set\n */\n id: LegendItemKey;\n /**\n * Label for data item in Legend\n */\n label: string;\n /**\n * Flag for selected data item\n */\n checked: boolean;\n /**\n * Color of data item\n */\n color: string;\n /**\n * Icon before label\n */\n icon?: typeof Icon;\n /**\n * Additional info with sub-label or count\n */\n additionalInfo?: { label: string } | { count: number };\n\n patternKey?: string;\n\n /** Enables patterns symbols that enhances charts accessibility */\n patterns?: PatternsConfig;\n};\n\nexport type LegendItemProps = LegendItem & {\n /**\n * Size for legend item\n */\n size: LSize;\n /**\n * Shape of data item on Legend panel\n */\n shape: ShapeType;\n /**\n * Handler for select/deselect legend item.\n * !Need to redefine onClick, because we don't have `event` in it.\n * @deprecated\n */\n onClick?: () => void;\n\n /** Enables patterns symbols that enhances charts accessibility */\n patterns?: PatternsConfig;\n\n /**\n * Handler for select/deselect legend item\n */\n onChangeLegendItem: (id: LegendItemKey, checked: boolean) => void;\n\n /**\n * Handler for focus legend item\n */\n onFocusLegendItem: (id: LegendItemKey) => void;\n\n /**\n * Handler for focus out legend item\n */\n onBlurLegendItem: (id: LegendItemKey) => void;\n /** Enables element transparency */\n transparent?: boolean;\n};\n\nexport type LegendItemDefaultProps = {\n children: React.JSX.Element;\n};\n\nexport type ShapeProps = LegendItem &\n (\n | {\n size: LSize;\n shape: Exclude<ShapeType, 'Checkbox'>;\n }\n | {\n 'size': LSize;\n 'shape': Extract<ShapeType, 'Checkbox'>;\n 'onChange': (checked: boolean, e?: React.SyntheticEvent<HTMLInputElement>) => void;\n 'aria-labelledby'?: string;\n }\n );\n\nexport const StaticShapes = ['Circle', 'Pattern'] as const;\n\nexport type ShapeType = 'Checkbox' | typeof StaticShapes[number];\n\nexport type LegendItemShapeType = Intergalactic.Component<typeof Box, Partial<ShapeProps>>;\nexport type LegendItemIconType = Intergalactic.Component<typeof Icon, Partial<LegendItem>>; ;\nexport type LegendItemLabelType = Intergalactic.Component<typeof Text, Partial<Omit<LegendItem, 'theme'>>>; ;\nexport type LegendItemAdditionalLabelType = Intergalactic.Component<typeof Text, Partial<LegendItem>>; ;\nexport type LegendItemCountType = Intergalactic.Component<typeof Text, Partial<LegendItem>>; ;\n\nexport type LegendItemType = Intergalactic.Component<typeof Flex, Partial<LegendItemProps>> & {\n Shape: LegendItemShapeType;\n Icon: LegendItemIconType;\n Label: LegendItemLabelType;\n AdditionalLabel: LegendItemAdditionalLabelType;\n Count: LegendItemCountType;\n};\n"],"mappings":"AAQA;AACA;AACA;;AA0FA,OAAO,MAAMA,YAAY,GAAG,CAAC,QAAQ,EAAE,SAAS,CAAU;AAKkC;AACgB;AACL;AACV","ignoreList":[]}
|