@semcore/d3-chart 17.1.0 → 17.2.0-prerelease.3
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 +14 -14
|
@@ -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","plotWidth","asProps","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 { 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,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;AACjE,SAASC,aAAa,QAAQ,iBAAiB;AAO/C,SAASC,i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AAA,CAAAmD,aAAA,CAAAnD,KAAA,CAAA8D,QAAA,qBACE9D,KAAA,CAAAmD,aAAA,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,CAAC/C,OAAO,CAACgD,WAAW,CAAC,gBAAgB,EAAE;MAAEC,SAAS,EAAE;IAAc,CAAC,CAAC;EACjF;AACF;AAACC,eAAA,CA1HK/D,yBAAyB,iBAKR,mBAAmB;AAAA+D,eAAA,CALpC/D,yBAAyB,kBAMmC;EAC9DgE,SAAS,EAAE,QAAQ;EACnBC,SAAS,EAAE,IAAI;EACfC,SAAS,EAAE,IAAI;EACfC,WAAW,EAAE,IAAI;EACjBC,UAAU,EAAE;AACd,CAAC;AAAAL,eAAA,CAZG/D,yBAAyB,aAcZ,CAACV,WAAW,CAACS,iBAAiB,CAAC,CAAC;AA8GnD,OAAO,MAAMsE,gBAAsC,GAAGhF,eAAe,CAACW,yBAAyB,CAAC","ignoreList":[]}
|
|
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","plotWidth","asProps","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, 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 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;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,OAAO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1B,CAAC,CAAC;EACN;EAEUY,kBAAkBA,CAAA,EAAW;IACrC,OAAO,IAAI,CAAC/C,OAAO,CAACgD,WAAW,CAAC,gBAAgB,EAAE;MAAEC,SAAS,EAAE;IAAc,CAAC,CAAC;EACjF;AACF;;AAEA;AACA;AACA;AACA;AACA;AAJAC,eAAA,CA/HM/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;AAmHnD,OAAO,MAAMsE,gBAAgB,GAAGhF,eAAe,CAG7CW,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":[]}
|
|
@@ -4,6 +4,7 @@ import i18nEnhance from '@semcore/core/lib/utils/enhances/i18nEnhance';
|
|
|
4
4
|
import { Text } from '@semcore/typography';
|
|
5
5
|
import { scaleLinear } from 'd3-scale';
|
|
6
6
|
import React from 'react';
|
|
7
|
+
|
|
7
8
|
// @ts-ignore
|
|
8
9
|
import { Venn } from '../..';
|
|
9
10
|
import { AbstractChart } from './AbstractChart';
|
|
@@ -110,6 +111,12 @@ class VennChartComponent extends AbstractChart {
|
|
|
110
111
|
});
|
|
111
112
|
}
|
|
112
113
|
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* VennChart
|
|
117
|
+
*
|
|
118
|
+
* {@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}
|
|
119
|
+
*/
|
|
113
120
|
_defineProperty(VennChartComponent, "displayName", 'Chart.Venn');
|
|
114
121
|
_defineProperty(VennChartComponent, "defaultProps", {
|
|
115
122
|
direction: 'row-reverse',
|
|
@@ -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","highlightedLine","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","bold","getLegendAriaLabel","getI18nText","chartType","_defineProperty","direction","alignItems","marginY","marginX","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\nimport
|
|
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","highlightedLine","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","bold","getLegendAriaLabel","getI18nText","chartType","_defineProperty","direction","alignItems","marginY","marginX","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 } 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,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,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AO,MAAMiE,SAAS,GAAGxE,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 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":["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 {
|
|
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, {}, {}, 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,SAASA,SAAS,QAA4B,eAAe;AAK7D,SAASC,qBAAqB,QAAQ,kBAAkB;AAExD,OAAO,MAAeC,UAAU,SAItBF,SAAS,CAA0B;EAAAG,YAAA,GAAAC,IAAA;IAAA,SAAAA,IAAA;IAAAC,eAAA,6BAmDrBC,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;IAAAF,eAAA,4BAEoBG,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;IAAAF,eAAA,2BAEmBE,EAAiB,IAAK;MACxC,IAAI,CAACE,KAAK,CAACG,gBAAgB,GAAGL,EAAE,CAAC;IACnC,CAAC;IAAAF,eAAA,+BAEuBE,EAAiB,IAAK;MAC5C,OAAQM,CAAuB,IAAK;QAClC,IAAI,CAACJ,KAAK,CAACE,gBAAgB,GAAGJ,EAAE,EAAEM,CAAC,CAAC;MACtC,CAAC;IACH,CAAC;IAAAR,eAAA,+BAEuBE,EAAiB,IAAK;MAC5C,OAAQM,CAAuB,IAAK;QAClC,IAAI,CAACJ,KAAK,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E,iBAAiB,EAAE,IAAI,CAACA,iBAAiB,CAACN,IAAI,CAACrB,OAAO,CAAC;MACvD4B,gBAAgB,EAAE,IAAI,CAACA,gBAAgB;MACvCC,kBAAkB,EAAE,IAAI,CAACA,kBAAkB,CAAC/B,KAAK,CAAC;MAClDgC,YAAY,EAAET,IAAI,CAACrB,OAAO,GAAG,IAAI,CAAC+B,oBAAoB,CAACV,IAAI,CAACtB,EAAE,CAAC,GAAGe,SAAS;MAC3EkB,YAAY,EAAE,IAAI,CAACC,oBAAoB,CAACZ,IAAI,CAACtB,EAAE,CAAC;MAChDmC,KAAK,EAAE;QAAEC,YAAY,EAAE,GAAGf,KAAK,GAAG,CAAC,EAAE;QAAEgB,UAAU,EAAE,GAAGhB,KAAK,GAAG,CAAC;MAAG,CAAC;MACnEM;IACF,CAAC;EACH;AAqCF","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_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_"),
|
|
12
12
|
/*__reshadow_css_end__*/
|
|
13
13
|
{
|
|
14
|
-
"__SLegendFlex": "
|
|
15
|
-
"_direction_row": "
|
|
16
|
-
"_direction_column": "
|
|
14
|
+
"__SLegendFlex": "___SLegendFlex_1fc9g_gg_",
|
|
15
|
+
"_direction_row": "_direction_row_1fc9g_gg_",
|
|
16
|
+
"_direction_column": "_direction_column_1fc9g_gg_"
|
|
17
17
|
});
|
|
18
18
|
import { localizedMessages } from '../../../translations/__intergalactic-dynamic-locales';
|
|
19
19
|
import { BaseLegend } from '../BaseLegend';
|
|
@@ -63,6 +63,12 @@ class LegendFlexRoot extends BaseLegend {
|
|
|
63
63
|
})), withTrend && this.renderTrend(), suffix ? suffix : null);
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* LegendFlex
|
|
69
|
+
*
|
|
70
|
+
* {@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}
|
|
71
|
+
*/
|
|
66
72
|
_defineProperty(LegendFlexRoot, "displayName", 'LegendFlex');
|
|
67
73
|
_defineProperty(LegendFlexRoot, "style", style);
|
|
68
74
|
_defineProperty(LegendFlexRoot, "enhance", [i18nEnhance(localizedMessages)]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LegendFlex.js","names":["Flex","Checkbox","createComponent","sstyled","Root","i18nEnhance","Divider","React","style","_sstyled","insert","localizedMessages","BaseLegend","LegendItemComponent","LegendFlexRoot","renderTrend","onTrendIsVisibleChange","trendIsVisible","trendLabel","size","getI18nText","asProps","createElement","checked","onChange","theme","label","render","_ref","_ref2","SLegendFlex","styles","Children","direction","withTrend","suffix","items","orientation","cn","_assignProps","map","id","key","_defineProperty","children","LegendFlex","LegendItem"],"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":["Flex","Checkbox","createComponent","sstyled","Root","i18nEnhance","Divider","React","style","_sstyled","insert","localizedMessages","BaseLegend","LegendItemComponent","LegendFlexRoot","renderTrend","onTrendIsVisibleChange","trendIsVisible","trendLabel","size","getI18nText","asProps","createElement","checked","onChange","theme","label","render","_ref","_ref2","SLegendFlex","styles","Children","direction","withTrend","suffix","items","orientation","cn","_assignProps","map","id","key","_defineProperty","children","LegendFlex","LegendItem"],"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":";;;AAAA,SAASA,IAAI,QAAQ,0BAA0B;AAC/C,OAAOC,QAAQ,MAAM,mBAAmB;AACxC,SAASC,eAAe,EAAEC,OAAO,EAAEC,IAAI,QAAQ,eAAe;AAC9D,OAAOC,WAAW,MAAM,8CAA8C;AACtE,OAAOC,OAAO,MAAM,kBAAkB;AACtC,OAAOC,KAAK,MAAM,OAAO;AAAC;AAAA,MAAAC,KAAA,8BAAAC,QAAA,CAAAC,MAAA;AAAA;AAAA;EAAA;EAAA;EAAA;AAAA;AAI1B,SAASC,iBAAiB,QAAQ,uDAAuD;AACzF,SAASC,UAAU,QAAQ,eAAe;AAC1C,SAASC,mBAAmB,QAAQ,0BAA0B;AAE9D,MAAMC,cAAc,SAASF,UAAU,CAIrC;EAWAG,WAAWA,CAAA,EAAG;IACZ,MAAM;MAAEC,sBAAsB;MAAEC,cAAc;MAAEC,UAAU;MAAEC,IAAI;MAAEC;IAAY,CAAC,GAAG,IAAI,CACnFC,OAA2F;IAE9F,oBACEd,KAAA,CAAAe,aAAA,CAACrB,QAAQ;MACPsB,OAAO,EAAEN,cAAe;MACx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;AAAAgC,eAAA,CAR7C7B,cAAc,kBAUI,OAAO;EAC3BmB,SAAS,EAAE,KAAK;EAChBW,QAAQ,eAAErC,KAAA,CAAAe,aAAA,CAACuB,UAAU,CAACC,UAAU,MAAE;AACpC,CAAC,CAAU;AAwCb,OAAO,MAAMD,UAAU,GAAG3C,eAAe,CAGvCY,cAAc,EAAE;EAChBgC,UAAU,EAAEjC;AACd,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
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 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":[]}
|
|
@@ -14,25 +14,25 @@ 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_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_"),
|
|
18
18
|
/*__reshadow_css_end__*/
|
|
19
19
|
{
|
|
20
|
-
"__SLegendItem": "
|
|
21
|
-
"_disabled": "
|
|
22
|
-
"__SPointShape": "
|
|
23
|
-
"_color": "
|
|
24
|
-
"--color": "--
|
|
25
|
-
"_shape_Circle": "
|
|
26
|
-
"_size_l": "
|
|
27
|
-
"_size_m": "
|
|
28
|
-
"_shape_Line": "
|
|
29
|
-
"_shape_Square": "
|
|
30
|
-
"_shape_Pattern": "
|
|
31
|
-
"__SIcon": "
|
|
32
|
-
"__SLabel": "
|
|
33
|
-
"__SAdditionalLabel": "
|
|
34
|
-
"__SCount": "
|
|
35
|
-
"__SPatternSymbol": "
|
|
20
|
+
"__SLegendItem": "___SLegendItem_uk6mx_gg_",
|
|
21
|
+
"_disabled": "__disabled_uk6mx_gg_",
|
|
22
|
+
"__SPointShape": "___SPointShape_uk6mx_gg_",
|
|
23
|
+
"_color": "__color_uk6mx_gg_",
|
|
24
|
+
"--color": "--color_uk6mx",
|
|
25
|
+
"_shape_Circle": "_shape_Circle_uk6mx_gg_",
|
|
26
|
+
"_size_l": "_size_l_uk6mx_gg_",
|
|
27
|
+
"_size_m": "_size_m_uk6mx_gg_",
|
|
28
|
+
"_shape_Line": "_shape_Line_uk6mx_gg_",
|
|
29
|
+
"_shape_Square": "_shape_Square_uk6mx_gg_",
|
|
30
|
+
"_shape_Pattern": "_shape_Pattern_uk6mx_gg_",
|
|
31
|
+
"__SIcon": "___SIcon_uk6mx_gg_",
|
|
32
|
+
"__SLabel": "___SLabel_uk6mx_gg_",
|
|
33
|
+
"__SAdditionalLabel": "___SAdditionalLabel_uk6mx_gg_",
|
|
34
|
+
"__SCount": "___SCount_uk6mx_gg_",
|
|
35
|
+
"__SPatternSymbol": "___SPatternSymbol_uk6mx_gg_"
|
|
36
36
|
});
|
|
37
37
|
import { StaticShapes } from './LegendItem.type';
|
|
38
38
|
import { PatternSymbol } from '../../../Pattern';
|
|
@@ -68,10 +68,20 @@ class LegendItemRoot extends 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 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 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 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 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
|
..._assignProps2({}, _ref2)
|
|
211
237
|
}), /*#__PURE__*/React.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 = Box;
|
|
221
248
|
if (!hasChildren) {
|
|
222
249
|
return null;
|
|
@@ -228,13 +255,14 @@ function Icon({
|
|
|
228
255
|
}), /*#__PURE__*/React.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 = TypographyText;
|
|
239
267
|
if (!hasChildren) {
|
|
240
268
|
return null;
|
|
@@ -246,13 +274,14 @@ function Label({
|
|
|
246
274
|
}), /*#__PURE__*/React.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 = TypographyText;
|
|
257
286
|
if (!hasChildren) {
|
|
258
287
|
return null;
|
|
@@ -264,13 +293,14 @@ function AdditionalLabel({
|
|
|
264
293
|
}), /*#__PURE__*/React.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 = TypographyText;
|
|
275
305
|
if (!hasChildren) {
|
|
276
306
|
return null;
|
|
@@ -282,6 +312,12 @@ function Count({
|
|
|
282
312
|
}), /*#__PURE__*/React.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
|
export const LegendItemComponent = createComponent(LegendItemRoot, {
|
|
286
322
|
Shape,
|
|
287
323
|
Icon,
|
|
@@ -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 { 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":";;;;;;;;AAAA,SAASA,IAAI,EAAEC,GAAG,QAAQ,0BAA0B;AACpD,OAAOC,QAAQ,MAAM,mBAAmB;AACxC,SAASC,eAAe,EAAEC,SAAS,EAAEC,OAAO,EAAEC,IAAI,QAAkC,eAAe;AACnG,OAAOC,mBAAmB,MAAM,sDAAsD;AACtF,OAAOC,mBAAmB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,EAAAmC,MAAA,CAAA/B,EAAA,gBAAE,CACK,CAAC;AAEvB;AACAQ,eAAe,CAACiB,WAAW,GAAG,iBAAiB;AAE/C,SAAShB,KAAKA,CAAC;EAAEd,MAAM;EAAEf,QAAQ,EAAEoC,WAAW;EAAEpB;AAA8B,CAAC,EAAE;EAAA,IAAAsC,KAAA,GAAAvB,YAAA;IAAAwB,MAAA;EAC/E,MAAMC,MAAM,GAOMtF,cAAc;EALhC,IAAI,CAACkE,WAAW,EAAE;IAChB,OAAO,IAAI;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,OAAO,MAAMrB,mBAAmB,GAAG7D,eAAe,CAACgB,cAAc,EAAE;EACjE8C,KAAK;EACLC,IAAI;EACJC,KAAK;EACLC,eAAe;EACfC;AACF,CAAC,CAAmB","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","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 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;EAAA;AAAA;AAG1B,SAIEC,YAAY,QAKP,mBAAmB;AAC1B,SAASC,aAAa,QAAQ,kBAAkB;AAChD,SAASC,wBAAwB,QAAQ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AAM,CAAC,eACpB5C,KAAA,CAAAgD,aAAA,CAACiC,gBAAgB,EAAAD,MAAA,CAAA/B,EAAA;IAAA,GAAAiC,aAAA;MAAA,OAA6B;IAAW,GAAAH,KAAA;EAAA,iBACvD/E,KAAA,CAAAgD,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,GAOMtF,cAAc;EALhC,IAAI,CAACkE,WAAW,EAAE;IAChB,OAAO,IAAI;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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LegendItem.type.js","names":["StaticShapes"],"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"],"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;;AAwFA,OAAO,MAAMA,YAAY,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,CAAU;AAKgB;AACgB;AACL;AACV","ignoreList":[]}
|