@semcore/d3-chart 17.1.0 → 17.2.0-prerelease.5
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 +17 -11
- package/lib/cjs/Area.js.map +1 -1
- package/lib/cjs/Axis.js +28 -16
- package/lib/cjs/Axis.js.map +1 -1
- package/lib/cjs/Bar.js +22 -16
- package/lib/cjs/Bar.js.map +1 -1
- package/lib/cjs/Bubble.js +20 -14
- package/lib/cjs/Bubble.js.map +1 -1
- package/lib/cjs/CompactHorizontalBar.js +22 -16
- package/lib/cjs/CompactHorizontalBar.js.map +1 -1
- package/lib/cjs/Donut.js +15 -9
- package/lib/cjs/Donut.js.map +1 -1
- package/lib/cjs/Dots.js +8 -8
- package/lib/cjs/GroupBar.js +6 -0
- package/lib/cjs/GroupBar.js.map +1 -1
- package/lib/cjs/HorizontalBar.js +22 -16
- package/lib/cjs/HorizontalBar.js.map +1 -1
- package/lib/cjs/Hover.js +3 -3
- package/lib/cjs/Line.js +15 -9
- package/lib/cjs/Line.js.map +1 -1
- package/lib/cjs/Plot.js +8 -2
- package/lib/cjs/Plot.js.map +1 -1
- package/lib/cjs/Radar.js +25 -19
- package/lib/cjs/Radar.js.map +1 -1
- package/lib/cjs/RadialTree.js +17 -12
- package/lib/cjs/RadialTree.js.map +1 -1
- package/lib/cjs/Reference.js +12 -12
- package/lib/cjs/ResponsiveContainer.js +6 -0
- package/lib/cjs/ResponsiveContainer.js.map +1 -1
- package/lib/cjs/ScatterPlot.js +15 -9
- package/lib/cjs/ScatterPlot.js.map +1 -1
- package/lib/cjs/StackBar.js +6 -0
- package/lib/cjs/StackBar.js.map +1 -1
- package/lib/cjs/StackedArea.js +6 -0
- package/lib/cjs/StackedArea.js.map +1 -1
- package/lib/cjs/Tooltip.js +10 -9
- package/lib/cjs/Tooltip.js.map +1 -1
- package/lib/cjs/Venn.js +15 -9
- package/lib/cjs/Venn.js.map +1 -1
- package/lib/cjs/a11y/PlotA11yModule.js +2 -2
- package/lib/cjs/a11y/PlotA11yView.js +2 -2
- package/lib/cjs/component/Chart/AbstractChart.js +4 -10
- package/lib/cjs/component/Chart/AbstractChart.js.map +1 -1
- package/lib/cjs/component/Chart/AreaChart.js +12 -0
- 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 +12 -0
- 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 +12 -0
- 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 +9 -3
- 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 +7 -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 +6 -0
- 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 +12 -0
- 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 +12 -0
- 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 +12 -0
- 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 +6 -0
- 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 -0
- 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.map +1 -1
- package/lib/cjs/component/ChartLegend/LegendFlex/LegendFlex.js +10 -4
- package/lib/cjs/component/ChartLegend/LegendFlex/LegendFlex.js.map +1 -1
- package/lib/cjs/component/ChartLegend/LegendFlex/LegendFlex.type.js.map +1 -1
- package/lib/cjs/component/ChartLegend/LegendItem/LegendItem.js +80 -44
- package/lib/cjs/component/ChartLegend/LegendItem/LegendItem.js.map +1 -1
- package/lib/cjs/component/ChartLegend/LegendItem/LegendItem.type.js +4 -0
- package/lib/cjs/component/ChartLegend/LegendItem/LegendItem.type.js.map +1 -1
- package/lib/cjs/component/ChartLegend/LegendTable/LegendTable.js +12 -6
- 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/Cigarette/Cigarette.js +6 -0
- package/lib/cjs/component/Cigarette/Cigarette.js.map +1 -1
- package/lib/cjs/style/plot.shadow.css +1 -1
- package/lib/es6/Area.js +17 -11
- package/lib/es6/Area.js.map +1 -1
- package/lib/es6/Axis.js +28 -16
- package/lib/es6/Axis.js.map +1 -1
- package/lib/es6/Bar.js +22 -16
- package/lib/es6/Bar.js.map +1 -1
- package/lib/es6/Bubble.js +20 -14
- package/lib/es6/Bubble.js.map +1 -1
- package/lib/es6/CompactHorizontalBar.js +22 -16
- package/lib/es6/CompactHorizontalBar.js.map +1 -1
- package/lib/es6/Donut.js +15 -9
- package/lib/es6/Donut.js.map +1 -1
- package/lib/es6/Dots.js +8 -8
- package/lib/es6/GroupBar.js +6 -0
- package/lib/es6/GroupBar.js.map +1 -1
- package/lib/es6/HorizontalBar.js +22 -16
- package/lib/es6/HorizontalBar.js.map +1 -1
- package/lib/es6/Hover.js +3 -3
- package/lib/es6/Line.js +15 -9
- package/lib/es6/Line.js.map +1 -1
- package/lib/es6/Plot.js +8 -2
- package/lib/es6/Plot.js.map +1 -1
- package/lib/es6/Radar.js +25 -19
- package/lib/es6/Radar.js.map +1 -1
- package/lib/es6/RadialTree.js +17 -12
- package/lib/es6/RadialTree.js.map +1 -1
- package/lib/es6/Reference.js +12 -12
- package/lib/es6/ResponsiveContainer.js +6 -0
- package/lib/es6/ResponsiveContainer.js.map +1 -1
- package/lib/es6/ScatterPlot.js +15 -9
- package/lib/es6/ScatterPlot.js.map +1 -1
- package/lib/es6/StackBar.js +6 -0
- package/lib/es6/StackBar.js.map +1 -1
- package/lib/es6/StackedArea.js +6 -0
- package/lib/es6/StackedArea.js.map +1 -1
- package/lib/es6/Tooltip.js +10 -9
- package/lib/es6/Tooltip.js.map +1 -1
- package/lib/es6/Venn.js +15 -9
- package/lib/es6/Venn.js.map +1 -1
- package/lib/es6/a11y/PlotA11yModule.js +2 -2
- package/lib/es6/a11y/PlotA11yView.js +2 -2
- package/lib/es6/component/Chart/AbstractChart.js +4 -10
- package/lib/es6/component/Chart/AbstractChart.js.map +1 -1
- package/lib/es6/component/Chart/AreaChart.js +12 -0
- 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 +12 -0
- 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 +12 -0
- 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 +9 -3
- 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 +7 -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 +6 -0
- 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 +12 -0
- 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 +12 -0
- 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 +12 -0
- 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 +6 -0
- 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 +7 -0
- 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.map +1 -1
- package/lib/es6/component/ChartLegend/LegendFlex/LegendFlex.js +10 -4
- package/lib/es6/component/ChartLegend/LegendFlex/LegendFlex.js.map +1 -1
- package/lib/es6/component/ChartLegend/LegendFlex/LegendFlex.type.js.map +1 -1
- package/lib/es6/component/ChartLegend/LegendItem/LegendItem.js +80 -44
- package/lib/es6/component/ChartLegend/LegendItem/LegendItem.js.map +1 -1
- package/lib/es6/component/ChartLegend/LegendItem/LegendItem.type.js +4 -0
- package/lib/es6/component/ChartLegend/LegendItem/LegendItem.type.js.map +1 -1
- package/lib/es6/component/ChartLegend/LegendTable/LegendTable.js +12 -6
- 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/Cigarette/Cigarette.js +6 -0
- package/lib/es6/component/Cigarette/Cigarette.js.map +1 -1
- package/lib/es6/style/plot.shadow.css +1 -1
- package/lib/esm/AnimatedClipPath.mjs +2 -2
- package/lib/esm/Area.mjs +13 -13
- package/lib/esm/Axis.mjs +19 -19
- package/lib/esm/Bar.mjs +18 -18
- package/lib/esm/Bubble.mjs +16 -16
- package/lib/esm/CompactHorizontalBar.mjs +18 -18
- package/lib/esm/Donut.mjs +11 -11
- package/lib/esm/Dots.mjs +9 -9
- package/lib/esm/GroupBar.mjs +1 -1
- package/lib/esm/HorizontalBar.mjs +18 -18
- package/lib/esm/Hover.mjs +5 -5
- package/lib/esm/Line.mjs +11 -11
- package/lib/esm/Pattern.mjs +1 -1
- package/lib/esm/Plot.mjs +4 -4
- package/lib/esm/Radar.mjs +21 -21
- package/lib/esm/RadialTree.mjs +14 -14
- package/lib/esm/Reference.mjs +14 -14
- package/lib/esm/ResponsiveContainer.mjs +1 -1
- package/lib/esm/ScatterPlot.mjs +11 -11
- package/lib/esm/StackBar.mjs +1 -1
- package/lib/esm/StackedArea.mjs +1 -1
- package/lib/esm/Tooltip.mjs +12 -11
- package/lib/esm/Venn.mjs +12 -12
- package/lib/esm/a11y/PlotA11yModule.mjs +4 -4
- package/lib/esm/a11y/PlotA11yView.mjs +3 -3
- package/lib/esm/component/Chart/AbstractChart.mjs +6 -12
- package/lib/esm/component/Chart/AreaChart.mjs +7 -1
- package/lib/esm/component/Chart/BarChart.mjs +8 -2
- package/lib/esm/component/Chart/BubbleChart.mjs +7 -1
- package/lib/esm/component/Chart/CigaretteChart.mjs +3 -3
- package/lib/esm/component/Chart/CompactHorizontalBarChart.mjs +2 -2
- package/lib/esm/component/Chart/DonutChart.mjs +1 -1
- package/lib/esm/component/Chart/HistogramChart.mjs +8 -2
- package/lib/esm/component/Chart/LineChart.mjs +7 -1
- package/lib/esm/component/Chart/RadarChart.mjs +7 -1
- package/lib/esm/component/Chart/ScatterPlotChart.mjs +1 -1
- package/lib/esm/component/Chart/VennChart.mjs +1 -1
- package/lib/esm/component/ChartLegend/BaseLegend.mjs +1 -1
- package/lib/esm/component/ChartLegend/LegendFlex/LegendFlex.mjs +6 -6
- package/lib/esm/component/ChartLegend/LegendItem/LegendItem.mjs +76 -46
- package/lib/esm/component/ChartLegend/LegendItem/LegendItem.type.mjs +4 -0
- package/lib/esm/component/ChartLegend/LegendTable/LegendTable.mjs +8 -8
- package/lib/esm/component/Cigarette/Cigarette.mjs +1 -1
- package/lib/esm/component/StackGroupBar/StackGroupBar.mjs +1 -1
- package/lib/esm/createElement.mjs +1 -1
- package/lib/esm/style/plot.shadow.css +1 -1
- package/lib/types/RadialTree.d.ts +5 -0
- package/lib/types/component/Chart/AbstractChart.d.ts +2 -2
- package/lib/types/component/Chart/AreaChart.d.ts +5 -0
- package/lib/types/component/Chart/AreaChart.type.d.ts +6 -0
- package/lib/types/component/Chart/BarChart.d.ts +5 -0
- package/lib/types/component/Chart/BarChart.type.d.ts +6 -0
- package/lib/types/component/Chart/BubbleChart.d.ts +5 -0
- package/lib/types/component/Chart/BubbleChart.type.d.ts +6 -0
- package/lib/types/component/Chart/CigaretteChart.d.ts +5 -0
- package/lib/types/component/Chart/CigaretteChart.type.d.ts +14 -0
- package/lib/types/component/Chart/CompactHorizontalBarChart.d.ts +5 -0
- package/lib/types/component/Chart/CompactHorizontalBarChart.type.d.ts +7 -0
- package/lib/types/component/Chart/DonutChart.d.ts +5 -0
- package/lib/types/component/Chart/DonutChart.type.d.ts +7 -0
- package/lib/types/component/Chart/HistogramChart.d.ts +5 -0
- package/lib/types/component/Chart/HistogramChart.type.d.ts +6 -0
- package/lib/types/component/Chart/LineChart.d.ts +5 -0
- package/lib/types/component/Chart/LineChart.type.d.ts +6 -0
- package/lib/types/component/Chart/RadarChart.d.ts +5 -0
- package/lib/types/component/Chart/RadarChart.type.d.ts +6 -0
- package/lib/types/component/Chart/ScatterPlotChart.d.ts +5 -0
- package/lib/types/component/Chart/ScatterPlotChart.type.d.ts +7 -0
- package/lib/types/component/Chart/VennChart.d.ts +5 -0
- package/lib/types/component/Chart/VennChart.type.d.ts +6 -0
- package/lib/types/component/ChartLegend/BaseLegend.d.ts +2 -2
- package/lib/types/component/ChartLegend/LegendFlex/LegendFlex.d.ts +5 -0
- package/lib/types/component/ChartLegend/LegendFlex/LegendFlex.type.d.ts +4 -0
- package/lib/types/component/ChartLegend/LegendItem/LegendItem.d.ts +5 -0
- package/lib/types/component/ChartLegend/LegendItem/LegendItem.type.d.ts +15 -7
- package/lib/types/component/ChartLegend/LegendTable/LegendTable.d.ts +5 -0
- package/lib/types/component/ChartLegend/LegendTable/LegendTable.type.d.ts +3 -0
- package/lib/types/component/Cigarette/Cigarette.d.ts +5 -0
- package/package.json +13 -13
|
@@ -135,6 +135,12 @@ class ScatterPlotChartComponent extends _AbstractChart.AbstractChart {
|
|
|
135
135
|
});
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* ScatterPlotChart
|
|
141
|
+
*
|
|
142
|
+
* {@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}
|
|
143
|
+
*/
|
|
138
144
|
(0, _defineProperty2.default)(ScatterPlotChartComponent, "displayName", 'Chart.ScatterPlot');
|
|
139
145
|
(0, _defineProperty2.default)(ScatterPlotChartComponent, "defaultProps", {
|
|
140
146
|
direction: 'column',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScatterPlotChart.js","names":["_core","require","_i18nEnhance","_interopRequireDefault","_typography","_d3Scale","_react","_","_AbstractChart","_intergalacticDynamicLocales","ScatterPlotChartComponent","AbstractChart","dataKeys","data","groupKey","valueKey","props","Object","keys","filter","key","xScale","marginY","plotWidth","asProps","radius","getScatterPlotRadius","getValueScale","flatValues","testItem","range","plotPadding","domain","minMax","Date","Number","isNaN","getMilliseconds","scaleTime","scaleLinear","yScale","marginX","plotHeight","max","Math","min","reduce","result","item","entries","forEach","value","add","Set","renderChart","onClickScatterItem","dataDefinitions","state","map","checked","default","createElement","ScatterPlot","onClick","x","y","id","color","renderTooltip","Tooltip","wMin","index","children","Fragment","Dot","Text","tag","tooltipValueFormatter","getLegendAriaLabel","getI18nText","chartType","_defineProperty2","direction","showXAxis","showYAxis","showTooltip","showLegend","i18nEnhance","localizedMessages","ScatterPlotChart","exports","createComponent"],"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 { AbstractChart } from './AbstractChart';\nimport type { BaseChartProps, ListData } from './AbstractChart.type';\nimport type {\n ScatterPlotChartData,\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 static displayName = 'Chart.ScatterPlot';\n public static defaultProps: Partial<BaseChartProps<ListData>> = {\n direction: 'column',\n showXAxis: true,\n showYAxis: true,\n showTooltip: true,\n showLegend: false,\n };\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, plotWidth, data, groupKey, valueKey } = this.asProps;\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, plotHeight, valueKey } = this.asProps;\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\nexport const ScatterPlotChart: ScatterPlotChartType = createComponent(ScatterPlotChartComponent);\n"],"mappings":";;;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAH,sBAAA,CAAAF,OAAA;AAGA,IAAAM,CAAA,GAAAN,OAAA;AACA,IAAAO,cAAA,GAAAP,OAAA;AAOA,IAAAQ,4BAAA,GAAAR,OAAA;AATA;;AAWA,MAAMS,yBAAyB,SAASC,4BAAa,CAInD;EAYA,IAAcC,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,GAAG,KAAKL,QAAQ,CAAC;EACnF;EAEA,IAAcM,MAAMA,CAAA,EAAG;IACrB,MAAM;MAAEA,MAAM;MAAEC,OAAO,GAAG,EAAE;MAAEC,SAAS;MAAEV,IAAI;MAAEC,QAAQ;MAAEC;IAAS,CAAC,GAAG,IAAI,CAACS,OAAO;IAElF,IAAIH,MAAM,EAAE;MACV,OAAOA,MAAM;IACf;IAEA,MAAMI,MAAM,GAAG,IAAAC,sBAAoB,EAACX,QAAQ,CAAC,GAAG,IAAI,CAACY,aAAa,CAAC,CAAC,GAAG,IAAI,CAACC,UAAU,CAAC,CAAC;IACxF,MAAMC,Q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N,CAAC;MACH,CACmB,CAAC;IAE1B,CAAC,CAAC;EACN;EAEUa,kBAAkBA,CAAA,EAAW;IACrC,OAAO,IAAI,CAACtD,OAAO,CAACuD,WAAW,CAAC,gBAAgB,EAAE;MAAEC,SAAS,EAAE;IAAc,CAAC,CAAC;EACjF;AACF;AAAC,IAAAC,gBAAA,CAAArB,OAAA,EA1HKlD,yBAAyB,iBAKR,mBAAmB;AAAA,IAAAuE,gBAAA,CAAArB,OAAA,EALpClD,yBAAyB,kBAMmC;EAC9DwE,SAAS,EAAE,QAAQ;EACnBC,SAAS,EAAE,IAAI;EACfC,SAAS,EAAE,IAAI;EACfC,WAAW,EAAE,IAAI;EACjBC,UAAU,EAAE;AACd,CAAC;AAAA,IAAAL,gBAAA,CAAArB,OAAA,EAZGlD,yBAAyB,aAcZ,CAAC,IAAA6E,oBAAW,EAACC,8CAAiB,CAAC,CAAC;AA8G5C,MAAMC,gBAAsC,GAAAC,OAAA,CAAAD,gBAAA,GAAG,IAAAE,qBAAe,EAACjF,yBAAyB,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ScatterPlotChart.js","names":["_core","require","_i18nEnhance","_interopRequireDefault","_typography","_d3Scale","_react","_","_AbstractChart","_intergalacticDynamicLocales","ScatterPlotChartComponent","AbstractChart","dataKeys","data","groupKey","valueKey","props","Object","keys","filter","key","xScale","marginY","plotWidth","asProps","radius","getScatterPlotRadius","getValueScale","flatValues","testItem","range","plotPadding","domain","minMax","Date","Number","isNaN","getMilliseconds","scaleTime","scaleLinear","yScale","marginX","plotHeight","max","Math","min","reduce","result","item","entries","forEach","value","add","Set","renderChart","onClickScatterItem","dataDefinitions","state","map","checked","default","createElement","ScatterPlot","onClick","x","y","id","color","renderTooltip","Tooltip","wMin","index","children","Fragment","Dot","Text","tag","tooltipValueFormatter","getLegendAriaLabel","getI18nText","chartType","_defineProperty2","direction","showXAxis","showYAxis","showTooltip","showLegend","i18nEnhance","localizedMessages","ScatterPlotChart","exports","createComponent"],"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, plotWidth, data, groupKey, valueKey } = this.asProps;\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, plotHeight, valueKey } = this.asProps;\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 ScatterPlotChart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AAEA;AACA;AACA;AACA;AACA;AAJA,IAAAC,gBAAA,CAAArB,OAAA,EA/HMlD,yBAAyB,iBAQR,mBAAmB;AAAA,IAAAuE,gBAAA,CAAArB,OAAA,EARpClD,yBAAyB,kBASA;EAC3BwE,SAAS,EAAE,QAAQ;EACnBC,SAAS,EAAE,IAAI;EACfC,SAAS,EAAE,IAAI;EACfC,WAAW,EAAE,IAAI;EACjBC,UAAU,EAAE;AACd,CAAC;AAAA,IAAAL,gBAAA,CAAArB,OAAA,EAfGlD,yBAAyB,aAiBZ,CAAC,IAAA6E,oBAAW,EAACC,8CAAiB,CAAC,CAAC;AAmH5C,MAAMC,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,GAAG,IAAAE,qBAAe,EAG7CjF,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 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'\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":[]}
|
|
@@ -118,6 +118,12 @@ class VennChartComponent extends _AbstractChart.AbstractChart {
|
|
|
118
118
|
});
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* VennChart
|
|
124
|
+
*
|
|
125
|
+
* {@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}
|
|
126
|
+
*/
|
|
121
127
|
(0, _defineProperty2.default)(VennChartComponent, "displayName", 'Chart.Venn');
|
|
122
128
|
(0, _defineProperty2.default)(VennChartComponent, "defaultProps", {
|
|
123
129
|
direction: 'row-reverse',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VennChart.js","names":["_core","require","_i18nEnhance","_interopRequireDefault","_typography","_d3Scale","_react","_","_AbstractChart","_intergalacticDynamicLocales","VennChartComponent","AbstractChart","xScale","asProps","scaleLinear","yScale","dataKeys","data","props","legendKeys","Object","keys","filter","item","isIntersection","test","defaultLegendProps","legendType","renderChart","onClickVennItem","dataDefinitions","highlightedLine","state","checkedLegendItems","checked","checkedLegendItemsMap","reduce","result","id","intersections","dataKey","push","default","createElement","Venn","onClick","map","index","Circle","key","name","label","color","transparent","intersectionKey","intersectionKeys","split","hasDisabledItems","some","undefined","find","legendItem","join","Intersection","renderTooltip","Tooltip","children","Fragment","Title","Text","bold","getLegendAriaLabel","getI18nText","chartType","_defineProperty2","direction","alignItems","marginY","marginX","i18nEnhance","localizedMessages","VennChart","exports","createComponent"],"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\nimport
|
|
1
|
+
{"version":3,"file":"VennChart.js","names":["_core","require","_i18nEnhance","_interopRequireDefault","_typography","_d3Scale","_react","_","_AbstractChart","_intergalacticDynamicLocales","VennChartComponent","AbstractChart","xScale","asProps","scaleLinear","yScale","dataKeys","data","props","legendKeys","Object","keys","filter","item","isIntersection","test","defaultLegendProps","legendType","renderChart","onClickVennItem","dataDefinitions","highlightedLine","state","checkedLegendItems","checked","checkedLegendItemsMap","reduce","result","id","intersections","dataKey","push","default","createElement","Venn","onClick","map","index","Circle","key","name","label","color","transparent","intersectionKey","intersectionKeys","split","hasDisabledItems","some","undefined","find","legendItem","join","Intersection","renderTooltip","Tooltip","children","Fragment","Title","Text","bold","getLegendAriaLabel","getI18nText","chartType","_defineProperty2","direction","alignItems","marginY","marginX","i18nEnhance","localizedMessages","VennChart","exports","createComponent"],"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 } 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, highlightedLine } = 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={highlightedLine !== -1 && highlightedLine !== 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>{name}</Venn.Tooltip.Title>\n <Text bold>{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,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAH,sBAAA,CAAAF,OAAA;AAGA,IAAAM,CAAA,GAAAN,OAAA;AAEA,IAAAO,cAAA,GAAAP,OAAA;AAEA,IAAAQ,4BAAA,GAAAR,OAAA;AALA;;AAQA,MAAMS,kBAAkB,SAASC,4BAAa,CAO5C;E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Y;EACxBC,OAAO,EAAE,CAAC;EACVC,OAAO,EAAE;AACX,CAAC;AAAA,IAAAJ,gBAAA,CAAAhC,OAAA,EAfGhC,kBAAkB,aAiBL,CAAC,IAAAqE,oBAAW,EAACC,8CAAiB,CAAC,CAAC;AAgI5C,MAAMC,SAAS,GAAAC,OAAA,CAAAD,SAAA,GAAG,IAAAE,qBAAe,EAGtCzE,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 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'\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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseLegend.js","names":["_core","require","_hints","BaseLegend","Component","constructor","args","_defineProperty2","default","shape","id","checked","props","onChangeVisibleItem","onMouseEnterItem","onMouseLeaveItem","e","componentDidMount","setHints","componentDidUpdate","prevProps","items","dataHints","asProps","dataHintsHandler","makeDataHintsHandlers","undefined","forEach","legendItem","labelKey","label","getItem","index","line","Error","getLegendItemProps","_","size","patterns","onFocusLegendItem","onBlurLegendItem","onChangeLegendItem","onMouseEnter","bindOnMouseEnterItem","onMouseLeave","bindOnMouseLeaveItem","style","gridRowStart","gridRowEnd","exports"],"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 {
|
|
1
|
+
{"version":3,"file":"BaseLegend.js","names":["_core","require","_hints","BaseLegend","Component","constructor","args","_defineProperty2","default","shape","id","checked","props","onChangeVisibleItem","onMouseEnterItem","onMouseLeaveItem","e","componentDidMount","setHints","componentDidUpdate","prevProps","items","dataHints","asProps","dataHintsHandler","makeDataHintsHandlers","undefined","forEach","legendItem","labelKey","label","getItem","index","line","Error","getLegendItemProps","_","size","patterns","onFocusLegendItem","onBlurLegendItem","onChangeLegendItem","onMouseEnter","bindOnMouseEnterItem","onMouseLeave","bindOnMouseLeaveItem","style","gridRowStart","gridRowEnd","exports"],"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, {}, {}, 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 } = 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 };\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,IAAAA,KAAA,GAAAC,OAAA;AAKA,IAAAC,MAAA,GAAAD,OAAA;AAEO,MAAeE,UAAU,SAItBC,eAAS,CAA0B;EAAAC,YAAA,GAAAC,IAAA;IAAA,SAAAA,IAAA;IAAA,IAAAC,gBAAA,CAAAC,OAAA,8BAmDrBC,KAAgB,IAAK,CAACC,EAAiB,EAAEC,OAAgB,KAAK;MAClF,IAAIF,KAAK,KAAK,UAAU,EAAE;MAE1B,IAAI,CAACG,KAAK,CAACC,mBAAmB,GAAGH,EAAE,EAAEC,OAAO,CAAC;MAE7C,IAAIA,OAAO,EAAE;QACX,IAAI,CAACC,KAAK,CAACE,gBAAgB,GAAGJ,EAAE,CAAC;MACnC,CAAC,MAAM;QACL,IAAI,CAACE,KAAK,CAACG,gBAAgB,GAAGL,EAAE,CAAC;MACnC;IACF,CAAC;IAAA,IAAAH,gBAAA,CAAAC,OAAA,6BAEoBG,OAAgB,IAAMD,EAAiB,IAAK;MAC/D,IAAI,CAACC,OAAO,EAAE;QACZ,OAAO,IAAI,CAACC,KAAK,CAACG,gBAAgB,GAAGL,EAAE,CAAC;MAC1C;MAEA,IAAI,CAACE,KAAK,CAACE,gBAAgB,GAAGJ,EAAE,CAAC;IACnC,CAAC;IAAA,IAAAH,gBAAA,CAAAC,OAAA,4BAEmBE,EAAiB,IAAK;MACxC,IAAI,CAACE,KAA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AAC,aAAaF,KAAK,YAAY,CAAC;IACjD;IAEA,OAAOC,IAAI;EACb;EAEAE,kBAAkBA,CAChBC,CAAK,EACLJ,KAAa,EACiE;IAC9E,MAAM;MAAEvB,KAAK,GAAG,UAAU;MAAE4B,IAAI,GAAG,GAAG;MAAEC;IAAS,CAAC,GAAG,IAAI,CAACf,OAAO;IACjE,MAAMU,IAAI,GAAG,IAAI,CAACF,OAAO,CAACC,KAAK,CAAC;IAEhC,OAAO;MACL,GAAGC,IAAI;MACPxB,KAAK;MACL4B,IAAI;MACJE,iBAAiB,EAAE,IAAI,CAACA,iBAAiB,CAACN,IAAI,CAACtB,OAAO,CAAC;MACvD6B,gBAAgB,EAAE,IAAI,CAACA,gBAAgB;MACvCC,kBAAkB,EAAE,IAAI,CAACA,kBAAkB,CAAChC,KAAK,CAAC;MAClDiC,YAAY,EAAET,IAAI,CAACtB,OAAO,GAAG,IAAI,CAACgC,oBAAoB,CAACV,IAAI,CAACvB,EAAE,CAAC,GAAGgB,SAAS;MAC3EkB,YAAY,EAAE,IAAI,CAACC,oBAAoB,CAACZ,IAAI,CAACvB,EAAE,CAAC;MAChDoC,KAAK,EAAE;QAAEC,YAAY,EAAE,GAAGf,KAAK,GAAG,CAAC,EAAE;QAAEgB,UAAU,EAAE,GAAGhB,KAAK,GAAG,CAAC;MAAG,CAAC;MACnEM;IACF,CAAC;EACH;AAqCF;AAACW,OAAA,CAAA9C,UAAA,GAAAA,UAAA","ignoreList":[]}
|
|
@@ -16,12 +16,12 @@ var _intergalacticDynamicLocales = require("../../../translations/__intergalacti
|
|
|
16
16
|
var _BaseLegend = require("../BaseLegend");
|
|
17
17
|
var _LegendItem = require("../LegendItem/LegendItem");
|
|
18
18
|
/*!__reshadow-styles__:"./legend-flex.shadow.css"*/
|
|
19
|
-
const style = (/*__reshadow_css_start__*/_core.sstyled.insert(/*__inner_css_start__*/".
|
|
19
|
+
const style = (/*__reshadow_css_start__*/_core.sstyled.insert(/*__inner_css_start__*/".___SLegendFlex_1fc9g_gg_._direction_row_1fc9g_gg_{align-items:flex-start;align-content:flex-start;flex-wrap:wrap;gap:8px 16px}.___SLegendFlex_1fc9g_gg_._direction_column_1fc9g_gg_{align-items:flex-start;flex-wrap:wrap;gap:8px}", /*__inner_css_end__*/"1fc9g_gg_"),
|
|
20
20
|
/*__reshadow_css_end__*/
|
|
21
21
|
{
|
|
22
|
-
"__SLegendFlex": "
|
|
23
|
-
"_direction_row": "
|
|
24
|
-
"_direction_column": "
|
|
22
|
+
"__SLegendFlex": "___SLegendFlex_1fc9g_gg_",
|
|
23
|
+
"_direction_row": "_direction_row_1fc9g_gg_",
|
|
24
|
+
"_direction_column": "_direction_column_1fc9g_gg_"
|
|
25
25
|
});
|
|
26
26
|
class LegendFlexRoot extends _BaseLegend.BaseLegend {
|
|
27
27
|
renderTrend() {
|
|
@@ -68,6 +68,12 @@ class LegendFlexRoot extends _BaseLegend.BaseLegend {
|
|
|
68
68
|
})), withTrend && this.renderTrend(), suffix ? suffix : null);
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* LegendFlex
|
|
74
|
+
*
|
|
75
|
+
* {@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}
|
|
76
|
+
*/
|
|
71
77
|
(0, _defineProperty2.default)(LegendFlexRoot, "displayName", 'LegendFlex');
|
|
72
78
|
(0, _defineProperty2.default)(LegendFlexRoot, "style", style);
|
|
73
79
|
(0, _defineProperty2.default)(LegendFlexRoot, "enhance", [(0, _i18nEnhance.default)(_intergalacticDynamicLocales.localizedMessages)]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LegendFlex.js","names":["_core","require","_baseComponents","_checkbox","_interopRequireDefault","_i18nEnhance","_divider","_react","_intergalacticDynamicLocales","_BaseLegend","_LegendItem","style","sstyled","insert","LegendFlexRoot","BaseLegend","renderTrend","onTrendIsVisibleChange","trendIsVisible","trendLabel","size","getI18nText","asProps","default","createElement","checked","onChange","theme","label","render","_ref","_ref2","SLegendFlex","Flex","styles","Children","direction","withTrend","suffix","items","orientation","cn","assignProps","map","id","key","_defineProperty2","i18nEnhance","localizedMessages","children","LegendFlex","LegendItem","exports","createComponent","LegendItemComponent"],"sources":["../../../../../src/component/ChartLegend/LegendFlex/LegendFlex.tsx"],"sourcesContent":["import { Flex } from '@semcore/base-components';\nimport Checkbox from '@semcore/checkbox';\nimport { createComponent, sstyled, Root } from '@semcore/core';\nimport i18nEnhance from '@semcore/core/lib/utils/enhances/i18nEnhance';\nimport Divider from '@semcore/divider';\nimport React from 'react';\n\nimport style from './legend-flex.shadow.css';\nimport type { LegendFlexType, LegendFlexProps, TrendProps } from './LegendFlex.type';\nimport { localizedMessages } from '../../../translations/__intergalactic-dynamic-locales';\nimport { BaseLegend } from '../BaseLegend';\nimport { LegendItemComponent } from '../LegendItem/LegendItem';\n\nclass LegendFlexRoot extends BaseLegend
|
|
1
|
+
{"version":3,"file":"LegendFlex.js","names":["_core","require","_baseComponents","_checkbox","_interopRequireDefault","_i18nEnhance","_divider","_react","_intergalacticDynamicLocales","_BaseLegend","_LegendItem","style","sstyled","insert","LegendFlexRoot","BaseLegend","renderTrend","onTrendIsVisibleChange","trendIsVisible","trendLabel","size","getI18nText","asProps","default","createElement","checked","onChange","theme","label","render","_ref","_ref2","SLegendFlex","Flex","styles","Children","direction","withTrend","suffix","items","orientation","cn","assignProps","map","id","key","_defineProperty2","i18nEnhance","localizedMessages","children","LegendFlex","LegendItem","exports","createComponent","LegendItemComponent"],"sources":["../../../../../src/component/ChartLegend/LegendFlex/LegendFlex.tsx"],"sourcesContent":["import { Flex } from '@semcore/base-components';\nimport Checkbox from '@semcore/checkbox';\nimport { createComponent, sstyled, Root } from '@semcore/core';\nimport i18nEnhance from '@semcore/core/lib/utils/enhances/i18nEnhance';\nimport Divider from '@semcore/divider';\nimport React from 'react';\n\nimport style from './legend-flex.shadow.css';\nimport type { LegendFlexType, LegendFlexProps, TrendProps, LegendFlexDefaultProps } from './LegendFlex.type';\nimport { localizedMessages } from '../../../translations/__intergalactic-dynamic-locales';\nimport { BaseLegend } from '../BaseLegend';\nimport { LegendItemComponent } from '../LegendItem/LegendItem';\n\nclass LegendFlexRoot extends BaseLegend<\n LegendFlexProps,\n typeof LegendFlexRoot.enhance,\n LegendFlexDefaultProps\n> {\n static displayName = 'LegendFlex';\n static style = style;\n\n static enhance = [i18nEnhance(localizedMessages)] as const;\n\n static defaultProps = () => ({\n direction: 'row',\n children: <LegendFlex.LegendItem />,\n } as const);\n\n renderTrend() {\n const { onTrendIsVisibleChange, trendIsVisible, trendLabel, size, getI18nText } = this\n .asProps as unknown as TrendProps & LegendFlexProps & { getI18nText: (s: string) => string };\n\n return (\n <Checkbox\n checked={trendIsVisible}\n onChange={onTrendIsVisibleChange}\n theme='gray-400'\n label={trendLabel ?? getI18nText('trend')}\n size={size}\n />\n );\n }\n\n render() {\n const SLegendFlex = Root;\n const { styles, Children, direction, withTrend, suffix, items } = this.asProps;\n const orientation = direction === 'row' ? 'vertical' : 'horizontal';\n\n return sstyled(styles)(\n <SLegendFlex render={Flex} role='group'>\n {items.map(({ id }) => {\n return <Children key={id} />;\n })}\n {(withTrend || suffix) && <Divider orientation={orientation} />}\n {withTrend && this.renderTrend()}\n {suffix ? suffix : null}\n </SLegendFlex>,\n );\n }\n}\n\n/**\n * LegendFlex\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 LegendFlex = createComponent<\n LegendFlexType,\n typeof LegendFlexRoot\n>(LegendFlexRoot, {\n LegendItem: LegendItemComponent,\n});\n"],"mappings":";;;;;;;;AAEA,IAAAA,KAAA,GAAAC,OAAA;AAFA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAC,sBA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.type.ts"],"sourcesContent":["import type { Flex, FlexProps } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\n\nimport type { LegendProps } from '../BaseLegend.type';\nimport type { LegendItemType } from '../LegendItem/LegendItem.type';\n\nexport type TrendProps = {\n /**\n * Flag for include trend LegendItem in Legend\n */\n withTrend: true;\n /**\n * Trend label (for localization)\n */\n trendLabel?: string;\n /**\n * Flag for describe are trend is visible\n */\n trendIsVisible: boolean;\n /**\n * Handler for change trend visibility\n */\n onTrendIsVisibleChange: (isVisible: boolean) => void;\n};\n\ntype SuffixProps = {\n /**\n * Element after all Legend items\n */\n suffix?: React.ReactElement;\n};\n\ntype AddonProps = ({ withTrend?: never } & SuffixProps) | ({ suffix?: never } & TrendProps);\n\nexport type LegendFlexProps = LegendProps & AddonProps & FlexProps;\n\nexport type LegendFlexType = Intergalactic.Component<typeof Flex, LegendFlexProps> & {\n LegendItem: LegendItemType;\n};\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"LegendFlex.type.js","names":[],"sources":["../../../../../src/component/ChartLegend/LegendFlex/LegendFlex.type.ts"],"sourcesContent":["import type { Flex, FlexProps } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\n\nimport type { LegendProps } from '../BaseLegend.type';\nimport type { LegendItemType } from '../LegendItem/LegendItem.type';\n\nexport type TrendProps = {\n /**\n * Flag for include trend LegendItem in Legend\n */\n withTrend: true;\n /**\n * Trend label (for localization)\n */\n trendLabel?: string;\n /**\n * Flag for describe are trend is visible\n */\n trendIsVisible: boolean;\n /**\n * Handler for change trend visibility\n */\n onTrendIsVisibleChange: (isVisible: boolean) => void;\n};\n\ntype SuffixProps = {\n /**\n * Element after all Legend items\n */\n suffix?: React.ReactElement;\n};\n\ntype AddonProps = ({ withTrend?: never } & SuffixProps) | ({ suffix?: never } & TrendProps);\n\nexport type LegendFlexProps = LegendProps & AddonProps & FlexProps;\n\nexport type LegendFlexDefaultProps = {\n direction: 'row';\n children: React.JSX.Element;\n};\n\nexport type LegendFlexType = Intergalactic.Component<typeof Flex, LegendFlexProps> & {\n LegendItem: LegendItemType;\n};\n"],"mappings":"","ignoreList":[]}
|
|
@@ -17,25 +17,25 @@ var _LegendItem = require("./LegendItem.type");
|
|
|
17
17
|
var _Pattern = require("../../../Pattern");
|
|
18
18
|
var _utils = require("../../../utils");
|
|
19
19
|
/*!__reshadow-styles__:"./legend-item.shadow.css"*/
|
|
20
|
-
const style = (/*__reshadow_css_start__*/_core.sstyled.insert(/*__inner_css_start__*/".
|
|
20
|
+
const style = (/*__reshadow_css_start__*/_core.sstyled.insert(/*__inner_css_start__*/".___SLegendItem_uk6mx_gg_{min-width:0;align-items:flex-start}@media (hover:hover){.___SLegendItem_uk6mx_gg_:hover{cursor:pointer}.___SLegendItem_uk6mx_gg_.__disabled_uk6mx_gg_:hover{cursor:default}}.___SPointShape_uk6mx_gg_.__color_uk6mx_gg_{background-color:var(--color_uk6mx);margin-right:8px;flex-shrink:0}.___SPointShape_uk6mx_gg_._shape_Circle_uk6mx_gg_._size_l_uk6mx_gg_{width:16px;height:16px;border-radius:8px;margin-top:4px}.___SPointShape_uk6mx_gg_._shape_Circle_uk6mx_gg_._size_m_uk6mx_gg_{width:12px;height:12px;border-radius:6px;margin-top:4px}.___SPointShape_uk6mx_gg_._shape_Line_uk6mx_gg_._size_l_uk6mx_gg_{width:16px;height:4px;border-radius:3px;margin-top:9px}.___SPointShape_uk6mx_gg_._shape_Line_uk6mx_gg_._size_m_uk6mx_gg_{width:12px;height:4px;border-radius:3px;margin-top:8px}.___SPointShape_uk6mx_gg_._shape_Square_uk6mx_gg_._size_l_uk6mx_gg_{width:16px;height:16px;border-radius:2px;margin-top:4px}.___SPointShape_uk6mx_gg_._shape_Square_uk6mx_gg_._size_m_uk6mx_gg_{width:12px;height:12px;border-radius:2px;margin-top:4px}.___SPointShape_uk6mx_gg_._shape_Pattern_uk6mx_gg_{background-color:initial;margin-right:4px}.___SIcon_uk6mx_gg_{line-height:0;margin-right:4px}.___SIcon_uk6mx_gg_._size_l_uk6mx_gg_{margin-top:4px}.___SIcon_uk6mx_gg_._size_m_uk6mx_gg_{margin-top:2px}.___SLabel_uk6mx_gg_{min-width:0}.___SAdditionalLabel_uk6mx_gg_._size_l_uk6mx_gg_,.___SCount_uk6mx_gg_._size_l_uk6mx_gg_,.___SLabel_uk6mx_gg_._size_l_uk6mx_gg_{font-size:var(--intergalactic-fs-300,16px);line-height:var(--intergalactic-lh-300,150%)}.___SAdditionalLabel_uk6mx_gg_._size_m_uk6mx_gg_,.___SCount_uk6mx_gg_._size_m_uk6mx_gg_,.___SLabel_uk6mx_gg_._size_m_uk6mx_gg_{font-size:var(--intergalactic-fs-200,14px);line-height:var(--intergalactic-lh-200,142%)}.___SAdditionalLabel_uk6mx_gg_,.___SCount_uk6mx_gg_{margin-left:4px}.___SAdditionalLabel_uk6mx_gg_{white-space:nowrap;display:flex;align-items:flex-start}.___SAdditionalLabel_uk6mx_gg_:before{content:\"\";display:inline-block;background-color:var(--intergalactic-text-secondary,#00030095);height:4px;width:4px;border-radius:2px;margin-right:4px}@supports (color:color(display-p3 0 0 0%)){.___SAdditionalLabel_uk6mx_gg_:before{background-color:var(--intergalactic-text-secondary,#00030095)}@media (color-gamut:p3){.___SAdditionalLabel_uk6mx_gg_:before{background-color:var(--intergalactic-text-secondary,color(display-p3 .00228 .01289 .00252/.583))}}}.___SAdditionalLabel_uk6mx_gg_._size_l_uk6mx_gg_:before{margin-top:10px}.___SAdditionalLabel_uk6mx_gg_._size_m_uk6mx_gg_:before{margin-top:8px}.___SPatternSymbol_uk6mx_gg_{transform:scale(.8)}", /*__inner_css_end__*/"uk6mx_gg_"),
|
|
21
21
|
/*__reshadow_css_end__*/
|
|
22
22
|
{
|
|
23
|
-
"__SLegendItem": "
|
|
24
|
-
"_disabled": "
|
|
25
|
-
"__SPointShape": "
|
|
26
|
-
"_color": "
|
|
27
|
-
"--color": "--
|
|
28
|
-
"_shape_Circle": "
|
|
29
|
-
"_size_l": "
|
|
30
|
-
"_size_m": "
|
|
31
|
-
"_shape_Line": "
|
|
32
|
-
"_shape_Square": "
|
|
33
|
-
"_shape_Pattern": "
|
|
34
|
-
"__SIcon": "
|
|
35
|
-
"__SLabel": "
|
|
36
|
-
"__SAdditionalLabel": "
|
|
37
|
-
"__SCount": "
|
|
38
|
-
"__SPatternSymbol": "
|
|
23
|
+
"__SLegendItem": "___SLegendItem_uk6mx_gg_",
|
|
24
|
+
"_disabled": "__disabled_uk6mx_gg_",
|
|
25
|
+
"__SPointShape": "___SPointShape_uk6mx_gg_",
|
|
26
|
+
"_color": "__color_uk6mx_gg_",
|
|
27
|
+
"--color": "--color_uk6mx",
|
|
28
|
+
"_shape_Circle": "_shape_Circle_uk6mx_gg_",
|
|
29
|
+
"_size_l": "_size_l_uk6mx_gg_",
|
|
30
|
+
"_size_m": "_size_m_uk6mx_gg_",
|
|
31
|
+
"_shape_Line": "_shape_Line_uk6mx_gg_",
|
|
32
|
+
"_shape_Square": "_shape_Square_uk6mx_gg_",
|
|
33
|
+
"_shape_Pattern": "_shape_Pattern_uk6mx_gg_",
|
|
34
|
+
"__SIcon": "___SIcon_uk6mx_gg_",
|
|
35
|
+
"__SLabel": "___SLabel_uk6mx_gg_",
|
|
36
|
+
"__SAdditionalLabel": "___SAdditionalLabel_uk6mx_gg_",
|
|
37
|
+
"__SCount": "___SCount_uk6mx_gg_",
|
|
38
|
+
"__SPatternSymbol": "___SPatternSymbol_uk6mx_gg_"
|
|
39
39
|
});
|
|
40
40
|
const enhance = [(0, _resolveColorEnhance.default)(), (0, _uniqueID.default)()];
|
|
41
41
|
class LegendItemRoot extends _core.Component {
|
|
@@ -68,10 +68,20 @@ class LegendItemRoot extends _core.Component {
|
|
|
68
68
|
patterns,
|
|
69
69
|
size,
|
|
70
70
|
'onChange': value => {
|
|
71
|
-
onChangeLegendItem
|
|
71
|
+
if (onChangeLegendItem && id) {
|
|
72
|
+
onChangeLegendItem(id, value);
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
'onFocus': () => {
|
|
76
|
+
if (onFocusLegendItem && id) {
|
|
77
|
+
onFocusLegendItem(id);
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
'onBlur': () => {
|
|
81
|
+
if (onBlurLegendItem && id) {
|
|
82
|
+
onBlurLegendItem(id);
|
|
83
|
+
}
|
|
72
84
|
},
|
|
73
|
-
'onFocus': () => onFocusLegendItem(id),
|
|
74
|
-
'onBlur': () => onBlurLegendItem(id),
|
|
75
85
|
'aria-labelledby': shape === 'Checkbox' ? this.getUniqueID() : null
|
|
76
86
|
};
|
|
77
87
|
}
|
|
@@ -80,7 +90,11 @@ class LegendItemRoot extends _core.Component {
|
|
|
80
90
|
return {
|
|
81
91
|
...props,
|
|
82
92
|
children: props.icon,
|
|
83
|
-
onClick: () =>
|
|
93
|
+
onClick: () => {
|
|
94
|
+
if (props.onChangeLegendItem && props.id) {
|
|
95
|
+
props.onChangeLegendItem(props.id, !props.checked);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
84
98
|
};
|
|
85
99
|
}
|
|
86
100
|
getLabelProps() {
|
|
@@ -96,7 +110,11 @@ class LegendItemRoot extends _core.Component {
|
|
|
96
110
|
...props,
|
|
97
111
|
id: this.getUniqueID(),
|
|
98
112
|
checked,
|
|
99
|
-
onClick: () =>
|
|
113
|
+
onClick: () => {
|
|
114
|
+
if (onChangeLegendItem && id) {
|
|
115
|
+
onChangeLegendItem(id, !checked);
|
|
116
|
+
}
|
|
117
|
+
},
|
|
100
118
|
children: props.label
|
|
101
119
|
};
|
|
102
120
|
}
|
|
@@ -111,7 +129,11 @@ class LegendItemRoot extends _core.Component {
|
|
|
111
129
|
return {
|
|
112
130
|
...props,
|
|
113
131
|
children: additionalInfo && 'label' in additionalInfo ? `${additionalInfo.label}` : undefined,
|
|
114
|
-
onClick: () =>
|
|
132
|
+
onClick: () => {
|
|
133
|
+
if (onChangeLegendItem && id) {
|
|
134
|
+
onChangeLegendItem(id, !checked);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
115
137
|
};
|
|
116
138
|
}
|
|
117
139
|
getCountProps() {
|
|
@@ -125,7 +147,11 @@ class LegendItemRoot extends _core.Component {
|
|
|
125
147
|
return {
|
|
126
148
|
...props,
|
|
127
149
|
children: additionalInfo && 'count' in additionalInfo ? `(${additionalInfo.count})` : undefined,
|
|
128
|
-
onClick: () =>
|
|
150
|
+
onClick: () => {
|
|
151
|
+
if (onChangeLegendItem && id) {
|
|
152
|
+
onChangeLegendItem(id, !checked);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
129
155
|
};
|
|
130
156
|
}
|
|
131
157
|
render() {
|
|
@@ -210,13 +236,14 @@ function Shape(props) {
|
|
|
210
236
|
...(0, _core.assignProps)({}, _ref2)
|
|
211
237
|
}), /*#__PURE__*/_react.default.createElement(Children, _ref0.cn("Children", {})));
|
|
212
238
|
}
|
|
213
|
-
function Icon({
|
|
214
|
-
styles,
|
|
215
|
-
children: hasChildren,
|
|
216
|
-
Children
|
|
217
|
-
}) {
|
|
239
|
+
function Icon(props) {
|
|
218
240
|
var _ref3 = arguments[0],
|
|
219
241
|
_ref1;
|
|
242
|
+
const {
|
|
243
|
+
styles,
|
|
244
|
+
children: hasChildren,
|
|
245
|
+
Children
|
|
246
|
+
} = props;
|
|
220
247
|
const SIcon = _baseComponents.Box;
|
|
221
248
|
if (!hasChildren) {
|
|
222
249
|
return null;
|
|
@@ -228,13 +255,14 @@ function Icon({
|
|
|
228
255
|
}), /*#__PURE__*/_react.default.createElement(Children, _ref1.cn("Children", {})));
|
|
229
256
|
}
|
|
230
257
|
Icon.displayName = 'Icon';
|
|
231
|
-
function Label({
|
|
232
|
-
styles,
|
|
233
|
-
children: hasChildren,
|
|
234
|
-
Children
|
|
235
|
-
}) {
|
|
258
|
+
function Label(props) {
|
|
236
259
|
var _ref4 = arguments[0],
|
|
237
260
|
_ref10;
|
|
261
|
+
const {
|
|
262
|
+
styles,
|
|
263
|
+
children: hasChildren,
|
|
264
|
+
Children
|
|
265
|
+
} = props;
|
|
238
266
|
const SLabel = _typography.Text;
|
|
239
267
|
if (!hasChildren) {
|
|
240
268
|
return null;
|
|
@@ -246,13 +274,14 @@ function Label({
|
|
|
246
274
|
}), /*#__PURE__*/_react.default.createElement(Children, _ref10.cn("Children", {})));
|
|
247
275
|
}
|
|
248
276
|
Label.displayName = 'Label';
|
|
249
|
-
function AdditionalLabel({
|
|
250
|
-
styles,
|
|
251
|
-
children: hasChildren,
|
|
252
|
-
Children
|
|
253
|
-
}) {
|
|
277
|
+
function AdditionalLabel(props) {
|
|
254
278
|
var _ref5 = arguments[0],
|
|
255
279
|
_ref11;
|
|
280
|
+
const {
|
|
281
|
+
styles,
|
|
282
|
+
children: hasChildren,
|
|
283
|
+
Children
|
|
284
|
+
} = props;
|
|
256
285
|
const SAdditionalLabel = _typography.Text;
|
|
257
286
|
if (!hasChildren) {
|
|
258
287
|
return null;
|
|
@@ -264,13 +293,14 @@ function AdditionalLabel({
|
|
|
264
293
|
}), /*#__PURE__*/_react.default.createElement(Children, _ref11.cn("Children", {})));
|
|
265
294
|
}
|
|
266
295
|
AdditionalLabel.displayName = 'AdditionalLabel';
|
|
267
|
-
function Count({
|
|
268
|
-
styles,
|
|
269
|
-
children: hasChildren,
|
|
270
|
-
Children
|
|
271
|
-
}) {
|
|
296
|
+
function Count(props) {
|
|
272
297
|
var _ref6 = arguments[0],
|
|
273
298
|
_ref12;
|
|
299
|
+
const {
|
|
300
|
+
styles,
|
|
301
|
+
children: hasChildren,
|
|
302
|
+
Children
|
|
303
|
+
} = props;
|
|
274
304
|
const SCount = _typography.Text;
|
|
275
305
|
if (!hasChildren) {
|
|
276
306
|
return null;
|
|
@@ -282,6 +312,12 @@ function Count({
|
|
|
282
312
|
}), /*#__PURE__*/_react.default.createElement(Children, _ref12.cn("Children", {})));
|
|
283
313
|
}
|
|
284
314
|
Count.displayName = 'Count';
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* LegendItemComponent
|
|
318
|
+
*
|
|
319
|
+
* {@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}
|
|
320
|
+
*/
|
|
285
321
|
const LegendItemComponent = exports.LegendItemComponent = (0, _core.createComponent)(LegendItemRoot, {
|
|
286
322
|
Shape,
|
|
287
323
|
Icon,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LegendItem.js","names":["_core","require","_baseComponents","_checkbox","_interopRequireDefault","_resolveColorEnhance","_uniqueID","_typography","_react","_LegendItem","_Pattern","_utils","style","sstyled","insert","enhance","resolveColorEnhance","uniqueIDEnhancement","LegendItemRoot","Component","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","Flex","styles","Children","disabled","StaticShapes","includes","default","createElement","cn","assignProps","_defineProperty2","Fragment","LegendItemComponent","Shape","Icon","Label","AdditionalLabel","Count","_ref2","arguments[0]","_ref0","SPointShape","Box","SPatternSymbol","PatternSymbol","patternKey","getChartDefaultColorName","hasChildren","onChange","_ref8","_ref9","_ref3","_ref1","SIcon","displayName","_ref4","_ref10","SLabel","TypographyText","_ref5","_ref11","SAdditionalLabel","_ref6","_ref12","SCount","exports","createComponent"],"sources":["../../../../../src/component/ChartLegend/LegendItem/LegendItem.tsx"],"sourcesContent":["import { Flex, Box } from '@semcore/base-components';\nimport Checkbox from '@semcore/checkbox';\nimport { createComponent, Component, sstyled, Root, type IRootComponentProps } 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 type { DOMAttributes } from 'react';\nimport React from 'react';\n\nimport style from './legend-item.shadow.css';\nimport {\n type ShapeProps,\n type LegendItemProps,\n type LegendItemType,\n type LegendItem,\n StaticShapes,\n} from './LegendItem.type';\nimport { PatternSymbol } from '../../../Pattern';\nimport { getChartDefaultColorName } from '../../../utils';\n\nconst enhance = [resolveColorEnhance(), uniqueIDEnhancement()] as const;\nclass LegendItemRoot extends Component<LegendItemProps, typeof enhance> {\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 onChangeLegendItem(id, value);\n },\n 'onFocus': () => onFocusLegendItem(id),\n 'onBlur': () => onBlurLegendItem(id),\n 'aria-labelledby': shape === 'Checkbox' ? this.getUniqueID() : null,\n };\n }\n\n getIconProps(): LegendItem & IRootComponentProps & { onClick: () => void } {\n const props = this.asProps;\n\n return {\n ...props,\n children: props.icon,\n onClick: () => props.onChangeLegendItem(props.id, !props.checked),\n };\n }\n\n getLabelProps(): Omit<LegendItem, 'color'> & IRootComponentProps & { onClick: () => void } {\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: () => onChangeLegendItem(id, !checked),\n children: props.label,\n };\n }\n\n getAdditionalLabelProps(): LegendItem & IRootComponentProps & { onClick: () => void } {\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: () => onChangeLegendItem(id, !checked),\n };\n }\n\n getCountProps(): LegendItem & IRootComponentProps & { onClick: () => void } {\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: () => onChangeLegendItem(id, !checked),\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(props: IRootComponentProps & ShapeProps & DOMAttributes<HTMLLabelElement>) {\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({ styles, children: hasChildren, Children }: IRootComponentProps) {\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({ styles, children: hasChildren, Children }: IRootComponentProps) {\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({ styles, children: hasChildren, Children }: IRootComponentProps) {\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({ styles, children: hasChildren, Children }: IRootComponentProps) {\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\nexport const LegendItemComponent = createComponent(LegendItemRoot, {\n Shape,\n Icon,\n Label,\n AdditionalLabel,\n Count,\n}) as LegendItemType;\n"],"mappings":";;;;;;;;AAEA,IAAAA,KAAA,GAAAC,OAAA;AAFA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,oBAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,SAAA,GAAAF,sBAAA,CAAAH,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AAEA,IAAAO,MAAA,GAAAJ,sBAAA,CAAAH,OAAA;AAGA,IAAAQ,WAAA,GAAAR,OAAA;AAOA,IAAAS,QAAA,GAAAT,OAAA;AACA,IAAAU,MAAA,GAAAV,OAAA;AAA0D;AAAA,MAAAW,KAAA,8BAAAZ,KAAA,CAAAa,OAAA,CAAAC,MAAA;AAAA;AAAA;EAAA;EAAA;EAAA;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Item.js","names":["_core","require","_baseComponents","_checkbox","_interopRequireDefault","_resolveColorEnhance","_uniqueID","_typography","_react","_LegendItem","_Pattern","_utils","style","sstyled","insert","enhance","resolveColorEnhance","uniqueIDEnhancement","LegendItemRoot","Component","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","Flex","styles","Children","disabled","StaticShapes","includes","default","createElement","cn","assignProps","_defineProperty2","Fragment","LegendItemComponent","Shape","Icon","Label","AdditionalLabel","Count","_ref2","arguments[0]","_ref0","SPointShape","Box","SPatternSymbol","PatternSymbol","patternKey","getChartDefaultColorName","hasChildren","onChange","_ref8","_ref9","_ref3","_ref1","SIcon","displayName","_ref4","_ref10","SLabel","TypographyText","_ref5","_ref11","SAdditionalLabel","_ref6","_ref12","SCount","exports","createComponent"],"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 LegendItemComponent = createComponent<\n LegendItemType,\n typeof LegendItemRoot\n>(LegendItemRoot, {\n Shape,\n Icon,\n Label,\n AdditionalLabel,\n Count,\n});\n"],"mappings":";;;;;;;;AAEA,IAAAA,KAAA,GAAAC,OAAA;AAFA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,oBAAA,GAAAD,sBAA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AAE,CACK,CAAC;AAEvB;AACAQ,eAAe,CAACkB,WAAW,GAAG,iBAAiB;AAE/C,SAASjB,KAAKA,CACZjC,KAAkH,EAClH;EAAA,IAAA0D,KAAA,GAAAvB,YAAA;IAAAwB,MAAA;EACA,MAAM;IAAE1C,MAAM;IAAEhB,QAAQ,EAAE0C,WAAW;IAAEzB;EAAS,CAAC,GAAGlB,KAAK;EACzD,MAAM4D,MAAM,GAOMN,gBAAc;EALhC,IAAI,CAACX,WAAW,EAAE;IAChB,OAAO,IAAI;EACb;EAEA,OAAAgB,MAAA,GAAO,IAAArF,aAAO,EAAC2C,MAAM,CAAC,eACpBhD,MAAA,CAAAqD,OAAA,CAAAC,aAAA,CAACqC,MAAM,EAAAD,MAAA,CAAAnC,EAAA;IAAA,OAAA/D,KAAA,CAAAgE,WAAA;MAAA,OAA6B;IAAW,GAAAiC,KAAA;EAAA,iBAC7CzF,MAAA,CAAAqD,OAAA,CAAAC,aAAA,CAACL,QAAQ,EAAAyC,MAAA,CAAAnC,EAAA,gBAAE,CACL,CAAC;AAEb;AACAS,KAAK,CAACiB,WAAW,GAAG,OAAO;;AAE3B;AACA;AACA;AACA;AACA;AACO,MAAMtB,mBAAmB,GAAAiC,OAAA,CAAAjC,mBAAA,GAAG,IAAAkC,qBAAe,EAGhDnF,cAAc,EAAE;EAChBkD,KAAK;EACLC,IAAI;EACJC,KAAK;EACLC,eAAe;EACfC;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LegendItem.type.js","names":["StaticShapes","exports"],"sources":["../../../../../src/component/ChartLegend/LegendItem/LegendItem.type.ts"],"sourcesContent":["import type { Flex } from '@semcore/base-components';\nimport type { Intergalactic
|
|
1
|
+
{"version":3,"file":"LegendItem.type.js","names":["StaticShapes","exports"],"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', 'Line', 'Square', '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;;AAwFO,MAAMA,YAAY,GAAAC,OAAA,CAAAD,YAAA,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,CAAU;AAKgB;AACgB;AACL;AACV","ignoreList":[]}
|