@razorpay/blade 12.57.0 → 12.59.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/lib/native/components/Charts/CommonChartComponents/CommonChartComponents.native.js +1 -1
- package/build/lib/native/components/Charts/CommonChartComponents/CommonChartComponents.native.js.map +1 -1
- package/build/lib/native/components/Charts/DonutChart/DonutChart.native.js +12 -0
- package/build/lib/native/components/Charts/DonutChart/DonutChart.native.js.map +1 -0
- package/build/lib/native/components/index.js +1 -0
- package/build/lib/native/components/index.js.map +1 -1
- package/build/lib/native/tokens/theme/bladeTheme.js +1 -1
- package/build/lib/native/tokens/theme/bladeTheme.js.map +1 -1
- package/build/lib/web/development/components/Charts/AreaChart/AreaChart.web.js +1 -1
- package/build/lib/web/development/components/Charts/AreaChart/AreaChart.web.js.map +1 -1
- package/build/lib/web/development/components/Charts/BarChart/BarChart.web.js +2 -2
- package/build/lib/web/development/components/Charts/BarChart/BarChart.web.js.map +1 -1
- package/build/lib/web/development/components/Charts/BarChart/BarChartContext.js +1 -1
- package/build/lib/web/development/components/Charts/BarChart/BarChartContext.js.map +1 -1
- package/build/lib/web/development/components/Charts/CommonChartComponents/CommonChartComponents.web.js +21 -6
- package/build/lib/web/development/components/Charts/CommonChartComponents/CommonChartComponents.web.js.map +1 -1
- package/build/lib/web/development/components/Charts/CommonChartComponents/tokens.js +4 -1
- package/build/lib/web/development/components/Charts/CommonChartComponents/tokens.js.map +1 -1
- package/build/lib/web/development/components/Charts/DonutChart/DonutChart.web.js +256 -0
- package/build/lib/web/development/components/Charts/DonutChart/DonutChart.web.js.map +1 -0
- package/build/lib/web/development/components/Charts/DonutChart/index.js +2 -0
- package/build/lib/web/development/components/Charts/DonutChart/index.js.map +1 -0
- package/build/lib/web/development/components/Charts/DonutChart/tokens.js +78 -0
- package/build/lib/web/development/components/Charts/DonutChart/tokens.js.map +1 -0
- package/build/lib/web/development/components/Charts/LineChart/LineChart.web.js +1 -1
- package/build/lib/web/development/components/Charts/LineChart/LineChart.web.js.map +1 -1
- package/build/lib/web/development/components/Charts/index.js +1 -0
- package/build/lib/web/development/components/Charts/index.js.map +1 -1
- package/build/lib/web/development/components/Charts/utils/useColorTheme.js +13 -5
- package/build/lib/web/development/components/Charts/utils/useColorTheme.js.map +1 -1
- package/build/lib/web/development/components/index.js +1 -0
- package/build/lib/web/development/components/index.js.map +1 -1
- package/build/lib/web/development/tokens/theme/bladeTheme.js +22 -22
- package/build/lib/web/development/tokens/theme/bladeTheme.js.map +1 -1
- package/build/lib/web/production/components/Charts/AreaChart/AreaChart.web.js +1 -1
- package/build/lib/web/production/components/Charts/AreaChart/AreaChart.web.js.map +1 -1
- package/build/lib/web/production/components/Charts/BarChart/BarChart.web.js +2 -2
- package/build/lib/web/production/components/Charts/BarChart/BarChart.web.js.map +1 -1
- package/build/lib/web/production/components/Charts/BarChart/BarChartContext.js +1 -1
- package/build/lib/web/production/components/Charts/BarChart/BarChartContext.js.map +1 -1
- package/build/lib/web/production/components/Charts/CommonChartComponents/CommonChartComponents.web.js +21 -6
- package/build/lib/web/production/components/Charts/CommonChartComponents/CommonChartComponents.web.js.map +1 -1
- package/build/lib/web/production/components/Charts/CommonChartComponents/tokens.js +4 -1
- package/build/lib/web/production/components/Charts/CommonChartComponents/tokens.js.map +1 -1
- package/build/lib/web/production/components/Charts/DonutChart/DonutChart.web.js +256 -0
- package/build/lib/web/production/components/Charts/DonutChart/DonutChart.web.js.map +1 -0
- package/build/lib/web/production/components/Charts/DonutChart/index.js +2 -0
- package/build/lib/web/production/components/Charts/DonutChart/index.js.map +1 -0
- package/build/lib/web/production/components/Charts/DonutChart/tokens.js +78 -0
- package/build/lib/web/production/components/Charts/DonutChart/tokens.js.map +1 -0
- package/build/lib/web/production/components/Charts/LineChart/LineChart.web.js +1 -1
- package/build/lib/web/production/components/Charts/LineChart/LineChart.web.js.map +1 -1
- package/build/lib/web/production/components/Charts/index.js +1 -0
- package/build/lib/web/production/components/Charts/index.js.map +1 -1
- package/build/lib/web/production/components/Charts/utils/useColorTheme.js +13 -5
- package/build/lib/web/production/components/Charts/utils/useColorTheme.js.map +1 -1
- package/build/lib/web/production/components/index.js +1 -0
- package/build/lib/web/production/components/index.js.map +1 -1
- package/build/lib/web/production/tokens/theme/bladeTheme.js +22 -22
- package/build/lib/web/production/tokens/theme/bladeTheme.js.map +1 -1
- package/build/types/components/index.d.ts +89 -16
- package/build/types/components/index.native.d.ts +89 -16
- package/package.json +67 -68
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BarChart.web.js","sources":["../../../../../../../src/components/Charts/BarChart/BarChart.web.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport {\n BarChart as RechartsBarChart,\n Bar as RechartsBar,\n ResponsiveContainer as RechartsResponsiveContainer,\n} from 'recharts';\nimport { useChartsColorTheme } from '../utils';\nimport { BarChartContext, useBarChartContext } from './BarChartContext';\nimport type { ChartBarProps, ChartBarWrapperProps } from './types';\nimport {\n BAR_CHART_CORNER_RADIUS,\n DISTANCE_BETWEEN_STACKED_BARS,\n componentIds,\n BAR_SIZE,\n DISTANCE_BETWEEN_BARS,\n DISTANCE_BETWEEN_CATEGORY_BARS,\n} from './tokens';\nimport { useTheme } from '~components/BladeProvider';\nimport BaseBox from '~components/Box/BaseBox';\nimport { metaAttribute } from '~utils/metaAttribute';\nimport getIn from '~utils/lodashButBetter/get';\nimport isNumber from '~utils/lodashButBetter/isNumber';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { getComponentId } from '~utils/isValidAllowedChildren';\nimport { makeAnalyticsAttribute } from '~utils/makeAnalyticsAttribute';\nimport type { DataAnalyticsAttribute, TestID } from '~utils/types';\n\nexport type RechartsShapeProps = {\n x: number;\n y: number;\n width: number;\n height: number;\n fill: string;\n index: number;\n};\n\n// Bar component - resolves Blade color tokens to actual colors\nconst _ChartBar: React.FC<ChartBarProps> = ({\n color,\n name,\n dataKey,\n activeBar = false,\n label = false,\n showLegend = true,\n _index = 0,\n ...rest\n}) => {\n const { theme } = useTheme();\n const { layout, activeIndex, colorTheme: _colorTheme, totalBars } = useBarChartContext();\n const defaultColorArray = useChartsColorTheme({ colorTheme: _colorTheme ?? 'default' });\n const fill = color ? getIn(theme.colors, color) : defaultColorArray[_index];\n const isStacked = rest.stackId !== undefined;\n const animationBegin = isStacked\n ? (theme.motion.duration.gentle / totalBars) * _index\n : theme.motion.duration.gentle;\n const animationDuration = isStacked\n ? theme.motion.duration.gentle / totalBars\n : theme.motion.duration.gentle;\n\n return (\n <RechartsBar\n {...rest}\n fill={fill}\n legendType={showLegend ? 'rect' : 'none'}\n activeBar={activeBar}\n label={label}\n animationBegin={animationBegin}\n animationDuration={animationDuration}\n animationEasing=\"linear\"\n dataKey={dataKey}\n name={name}\n shape={(props: unknown) => {\n const { fill, x, y, width, height, index: barIndex } = props as RechartsShapeProps;\n const fillOpacity = isNumber(activeIndex) ? (barIndex === activeIndex ? 1 : 0.2) : 1;\n const gap = DISTANCE_BETWEEN_STACKED_BARS;\n const isVertical = layout === 'vertical';\n\n if (isVertical) {\n return (\n <rect\n fill={fill}\n x={x + gap / 2}\n y={y}\n width={width - gap}\n height={height}\n rx={BAR_CHART_CORNER_RADIUS}\n ry={BAR_CHART_CORNER_RADIUS}\n fillOpacity={fillOpacity}\n />\n );\n }\n return (\n <rect\n fill={fill}\n x={x}\n y={y + gap / 2}\n width={width}\n height={height > gap ? height - gap : 0}\n rx={BAR_CHART_CORNER_RADIUS}\n ry={BAR_CHART_CORNER_RADIUS}\n fillOpacity={fillOpacity}\n />\n );\n }}\n />\n );\n};\n\nconst ChartBar = assignWithoutSideEffects(_ChartBar, {\n componentId: componentIds.chartBar,\n});\n\n// BarChart wrapper with default margin, auto-color assignment, and max bars guard\nconst ChartBarWrapper: React.FC<ChartBarWrapperProps & TestID & DataAnalyticsAttribute> = ({\n children,\n colorTheme = 'default',\n layout = 'horizontal',\n testID,\n data = [],\n ...restProps\n}) => {\n const [activeIndex, setActiveIndex] = useState<number | undefined>(undefined);\n\n const { barChartModifiedChildrens, totalBars } = React.useMemo(() => {\n let BarChartIndex = 0;\n const modifiedChildren = React.Children.map(children, (child) => {\n if (React.isValidElement(child) && getComponentId(child) === componentIds.chartBar) {\n return React.cloneElement(child, {\n _index: BarChartIndex++,\n } as Partial<ChartBarProps>);\n }\n return child;\n });\n\n return {\n barChartModifiedChildrens: modifiedChildren,\n totalBars: BarChartIndex,\n };\n }, [children]);\n\n return (\n <BaseBox\n {...metaAttribute({ name: 'bar-chart', testID })}\n {...makeAnalyticsAttribute(restProps)}\n width=\"100%\"\n height=\"100%\"\n {...restProps}\n >\n <BarChartContext.Provider\n value={{\n layout,\n activeIndex,\n colorTheme,\n totalBars,\n }}\n >\n <RechartsResponsiveContainer width=\"100%\" height=\"100%\">\n <RechartsBarChart\n barSize={BAR_SIZE}\n barGap={DISTANCE_BETWEEN_BARS}\n barCategoryGap={DISTANCE_BETWEEN_CATEGORY_BARS}\n onMouseMove={(state) => {\n setActiveIndex(state?.activeIndex ? Number(state?.activeIndex) : undefined);\n }}\n layout={layout}\n data={data}\n >\n {barChartModifiedChildrens}\n </RechartsBarChart>\n </RechartsResponsiveContainer>\n </BarChartContext.Provider>\n </BaseBox>\n );\n};\n\nexport { ChartBarWrapper, ChartBar };\nexport type { ChartBarProps, ChartBarWrapperProps };\n"],"names":["_ChartBar","_ref","color","name","dataKey","_ref$activeBar","activeBar","_ref$label","label","_ref$showLegend","showLegend","_ref$_index","_index","rest","_objectWithoutProperties","_excluded","_useTheme","useTheme","theme","_useBarChartContext","useBarChartContext","layout","activeIndex","_colorTheme","colorTheme","totalBars","defaultColorArray","useChartsColorTheme","fill","getIn","colors","isStacked","stackId","undefined","animationBegin","motion","duration","gentle","animationDuration","_jsx","RechartsBar","_objectSpread","legendType","animationEasing","shape","props","_ref2","x","y","width","height","barIndex","index","fillOpacity","isNumber","gap","DISTANCE_BETWEEN_STACKED_BARS","isVertical","rx","BAR_CHART_CORNER_RADIUS","ry","ChartBar","assignWithoutSideEffects","componentId","componentIds","chartBar","ChartBarWrapper","_ref3","children","_ref3$colorTheme","_ref3$layout","testID","_ref3$data","data","restProps","_excluded2","_useState","useState","_useState2","_slicedToArray","setActiveIndex","_React$useMemo","React","useMemo","BarChartIndex","modifiedChildren","Children","map","child","isValidElement","getComponentId","cloneElement","barChartModifiedChildrens","BaseBox","metaAttribute","makeAnalyticsAttribute","BarChartContext","Provider","value","RechartsResponsiveContainer","RechartsBarChart","barSize","BAR_SIZE","barGap","DISTANCE_BETWEEN_BARS","barCategoryGap","DISTANCE_BETWEEN_CATEGORY_BARS","onMouseMove","state","Number"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA;AACA,IAAMA,SAAkC,GAAG,SAArCA,SAAkCA,CAAAC,IAAA,EASlC;AAAA,EAAA,IARJC,KAAK,GAAAD,IAAA,CAALC,KAAK;IACLC,IAAI,GAAAF,IAAA,CAAJE,IAAI;IACJC,OAAO,GAAAH,IAAA,CAAPG,OAAO;IAAAC,cAAA,GAAAJ,IAAA,CACPK,SAAS;AAATA,IAAAA,SAAS,GAAAD,cAAA,KAAG,KAAA,CAAA,GAAA,KAAK,GAAAA,cAAA;IAAAE,UAAA,GAAAN,IAAA,CACjBO,KAAK;AAALA,IAAAA,KAAK,GAAAD,UAAA,KAAG,KAAA,CAAA,GAAA,KAAK,GAAAA,UAAA;IAAAE,eAAA,GAAAR,IAAA,CACbS,UAAU;AAAVA,IAAAA,UAAU,GAAAD,eAAA,KAAG,KAAA,CAAA,GAAA,IAAI,GAAAA,eAAA;IAAAE,WAAA,GAAAV,IAAA,CACjBW,MAAM;AAANA,IAAAA,MAAM,GAAAD,WAAA,KAAG,KAAA,CAAA,GAAA,CAAC,GAAAA,WAAA;AACPE,IAAAA,IAAI,GAAAC,wBAAA,CAAAb,IAAA,EAAAc,SAAA,CAAA,CAAA;AAEP,EAAA,IAAAC,SAAA,GAAkBC,QAAQ,EAAE;IAApBC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wB,SAAS,CAAA,EAAA,EAAA,EAAA;AAAAN,IAAAA,QAAA,eAEb7B,GAAA,CAACyD,eAAe,CAACC,QAAQ,EAAA;AACvBC,MAAAA,KAAK,EAAE;AACL7E,QAAAA,MAAM,EAANA,MAAM;AACNC,QAAAA,WAAW,EAAXA,WAAW;AACXE,QAAAA,UAAU,EAAVA,UAAU;AACVC,QAAAA,SAAS,EAATA,SAAAA;OACA;MAAA2C,QAAA,eAEF7B,GAAA,CAAC4D,mBAA2B,EAAA;AAAClD,QAAAA,KAAK,EAAC,MAAM;AAACC,QAAAA,MAAM,EAAC,MAAM;QAAAkB,QAAA,eACrD7B,GAAA,CAAC6D,QAAgB,EAAA;AACfC,UAAAA,OAAO,EAAEC,QAAS;AAClBC,UAAAA,MAAM,EAAEC,qBAAsB;AAC9BC,UAAAA,cAAc,EAAEC,8BAA+B;AAC/CC,UAAAA,WAAW,EAAE,SAAbA,WAAWA,CAAGC,KAAK,EAAK;YACtB5B,cAAc,CAAC4B,KAAK,KAALA,IAAAA,IAAAA,KAAK,eAALA,KAAK,CAAEtF,WAAW,GAAGuF,MAAM,CAACD,KAAK,KAAA,IAAA,IAALA,KAAK,KAALA,KAAAA,CAAAA,GAAAA,KAAAA,CAAAA,GAAAA,KAAK,CAAEtF,WAAW,CAAC,GAAGW,SAAS,CAAC,CAAA;WAC3E;AACFZ,UAAAA,MAAM,EAAEA,MAAO;AACfoD,UAAAA,IAAI,EAAEA,IAAK;AAAAL,UAAAA,QAAA,EAEVwB,yBAAAA;SACe,CAAA;OACS,CAAA;KACL,CAAA;AAAC,GAAA,CACpB,CAAC,CAAA;AAEd;;;;"}
|
|
1
|
+
{"version":3,"file":"BarChart.web.js","sources":["../../../../../../../src/components/Charts/BarChart/BarChart.web.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport {\n BarChart as RechartsBarChart,\n Bar as RechartsBar,\n ResponsiveContainer as RechartsResponsiveContainer,\n} from 'recharts';\nimport { useChartsColorTheme } from '../utils';\nimport { BarChartContext, useBarChartContext } from './BarChartContext';\nimport type { ChartBarProps, ChartBarWrapperProps } from './types';\nimport {\n BAR_CHART_CORNER_RADIUS,\n DISTANCE_BETWEEN_STACKED_BARS,\n componentIds,\n BAR_SIZE,\n DISTANCE_BETWEEN_BARS,\n DISTANCE_BETWEEN_CATEGORY_BARS,\n} from './tokens';\nimport { useTheme } from '~components/BladeProvider';\nimport BaseBox from '~components/Box/BaseBox';\nimport { metaAttribute } from '~utils/metaAttribute';\nimport getIn from '~utils/lodashButBetter/get';\nimport isNumber from '~utils/lodashButBetter/isNumber';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { getComponentId } from '~utils/isValidAllowedChildren';\nimport { makeAnalyticsAttribute } from '~utils/makeAnalyticsAttribute';\nimport type { DataAnalyticsAttribute, TestID } from '~utils/types';\n\nexport type RechartsShapeProps = {\n x: number;\n y: number;\n width: number;\n height: number;\n fill: string;\n index: number;\n};\n\n// Bar component - resolves Blade color tokens to actual colors\nconst _ChartBar: React.FC<ChartBarProps> = ({\n color,\n name,\n dataKey,\n activeBar = false,\n label = false,\n showLegend = true,\n _index = 0,\n ...rest\n}) => {\n const { theme } = useTheme();\n const { layout, activeIndex, colorTheme: _colorTheme, totalBars } = useBarChartContext();\n const defaultColorArray = useChartsColorTheme({ colorTheme: _colorTheme });\n const fill = color ? getIn(theme.colors, color) : defaultColorArray[_index];\n const isStacked = rest.stackId !== undefined;\n const animationBegin = isStacked\n ? (theme.motion.duration.gentle / totalBars) * _index\n : theme.motion.duration.gentle;\n const animationDuration = isStacked\n ? theme.motion.duration.gentle / totalBars\n : theme.motion.duration.gentle;\n\n return (\n <RechartsBar\n {...rest}\n fill={fill}\n legendType={showLegend ? 'rect' : 'none'}\n activeBar={activeBar}\n label={label}\n animationBegin={animationBegin}\n animationDuration={animationDuration}\n animationEasing=\"linear\"\n dataKey={dataKey}\n name={name}\n shape={(props: unknown) => {\n const { fill, x, y, width, height, index: barIndex } = props as RechartsShapeProps;\n const fillOpacity = isNumber(activeIndex) ? (barIndex === activeIndex ? 1 : 0.2) : 1;\n const gap = DISTANCE_BETWEEN_STACKED_BARS;\n const isVertical = layout === 'vertical';\n\n if (isVertical) {\n return (\n <rect\n fill={fill}\n x={x + gap / 2}\n y={y}\n width={width - gap}\n height={height}\n rx={BAR_CHART_CORNER_RADIUS}\n ry={BAR_CHART_CORNER_RADIUS}\n fillOpacity={fillOpacity}\n />\n );\n }\n return (\n <rect\n fill={fill}\n x={x}\n y={y + gap / 2}\n width={width}\n height={height > gap ? height - gap : 0}\n rx={BAR_CHART_CORNER_RADIUS}\n ry={BAR_CHART_CORNER_RADIUS}\n fillOpacity={fillOpacity}\n />\n );\n }}\n />\n );\n};\n\nconst ChartBar = assignWithoutSideEffects(_ChartBar, {\n componentId: componentIds.chartBar,\n});\n\n// BarChart wrapper with default margin, auto-color assignment, and max bars guard\nconst ChartBarWrapper: React.FC<ChartBarWrapperProps & TestID & DataAnalyticsAttribute> = ({\n children,\n colorTheme = 'categorical',\n layout = 'horizontal',\n testID,\n data = [],\n ...restProps\n}) => {\n const [activeIndex, setActiveIndex] = useState<number | undefined>(undefined);\n\n const { barChartModifiedChildrens, totalBars } = React.useMemo(() => {\n let BarChartIndex = 0;\n const modifiedChildren = React.Children.map(children, (child) => {\n if (React.isValidElement(child) && getComponentId(child) === componentIds.chartBar) {\n return React.cloneElement(child, {\n _index: BarChartIndex++,\n } as Partial<ChartBarProps>);\n }\n return child;\n });\n\n return {\n barChartModifiedChildrens: modifiedChildren,\n totalBars: BarChartIndex,\n };\n }, [children]);\n\n return (\n <BaseBox\n {...metaAttribute({ name: 'bar-chart', testID })}\n {...makeAnalyticsAttribute(restProps)}\n width=\"100%\"\n height=\"100%\"\n {...restProps}\n >\n <BarChartContext.Provider\n value={{\n layout,\n activeIndex,\n colorTheme,\n totalBars,\n }}\n >\n <RechartsResponsiveContainer width=\"100%\" height=\"100%\">\n <RechartsBarChart\n barSize={BAR_SIZE}\n barGap={DISTANCE_BETWEEN_BARS}\n barCategoryGap={DISTANCE_BETWEEN_CATEGORY_BARS}\n onMouseMove={(state) => {\n setActiveIndex(state?.activeIndex ? Number(state?.activeIndex) : undefined);\n }}\n layout={layout}\n data={data}\n >\n {barChartModifiedChildrens}\n </RechartsBarChart>\n </RechartsResponsiveContainer>\n </BarChartContext.Provider>\n </BaseBox>\n );\n};\n\nexport { ChartBarWrapper, ChartBar };\nexport type { ChartBarProps, ChartBarWrapperProps };\n"],"names":["_ChartBar","_ref","color","name","dataKey","_ref$activeBar","activeBar","_ref$label","label","_ref$showLegend","showLegend","_ref$_index","_index","rest","_objectWithoutProperties","_excluded","_useTheme","useTheme","theme","_useBarChartContext","useBarChartContext","layout","activeIndex","_colorTheme","colorTheme","totalBars","defaultColorArray","useChartsColorTheme","fill","getIn","colors","isStacked","stackId","undefined","animationBegin","motion","duration","gentle","animationDuration","_jsx","RechartsBar","_objectSpread","legendType","animationEasing","shape","props","_ref2","x","y","width","height","barIndex","index","fillOpacity","isNumber","gap","DISTANCE_BETWEEN_STACKED_BARS","isVertical","rx","BAR_CHART_CORNER_RADIUS","ry","ChartBar","assignWithoutSideEffects","componentId","componentIds","chartBar","ChartBarWrapper","_ref3","children","_ref3$colorTheme","_ref3$layout","testID","_ref3$data","data","restProps","_excluded2","_useState","useState","_useState2","_slicedToArray","setActiveIndex","_React$useMemo","React","useMemo","BarChartIndex","modifiedChildren","Children","map","child","isValidElement","getComponentId","cloneElement","barChartModifiedChildrens","BaseBox","metaAttribute","makeAnalyticsAttribute","BarChartContext","Provider","value","RechartsResponsiveContainer","RechartsBarChart","barSize","BAR_SIZE","barGap","DISTANCE_BETWEEN_BARS","barCategoryGap","DISTANCE_BETWEEN_CATEGORY_BARS","onMouseMove","state","Number"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA;AACA,IAAMA,SAAkC,GAAG,SAArCA,SAAkCA,CAAAC,IAAA,EASlC;AAAA,EAAA,IARJC,KAAK,GAAAD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C4B,KAAK,KAALA,IAAAA,IAAAA,KAAK,eAALA,KAAK,CAAEtF,WAAW,GAAGuF,MAAM,CAACD,KAAK,KAAA,IAAA,IAALA,KAAK,KAALA,KAAAA,CAAAA,GAAAA,KAAAA,CAAAA,GAAAA,KAAK,CAAEtF,WAAW,CAAC,GAAGW,SAAS,CAAC,CAAA;WAC3E;AACFZ,UAAAA,MAAM,EAAEA,MAAO;AACfoD,UAAAA,IAAI,EAAEA,IAAK;AAAAL,UAAAA,QAAA,EAEVwB,yBAAAA;SACe,CAAA;OACS,CAAA;KACL,CAAA;AAAC,GAAA,CACpB,CAAC,CAAA;AAEd;;;;"}
|
|
@@ -3,7 +3,7 @@ import { createContext, useContext } from 'react';
|
|
|
3
3
|
var BarChartContext = /*#__PURE__*/createContext({
|
|
4
4
|
layout: 'horizontal',
|
|
5
5
|
activeIndex: undefined,
|
|
6
|
-
colorTheme: '
|
|
6
|
+
colorTheme: 'categorical',
|
|
7
7
|
totalBars: 0
|
|
8
8
|
});
|
|
9
9
|
var useBarChartContext = function useBarChartContext() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BarChartContext.js","sources":["../../../../../../../src/components/Charts/BarChart/BarChartContext.ts"],"sourcesContent":["import { createContext, useContext } from 'react';\nimport type { BarChartContextType } from './types';\n\nexport const BarChartContext = createContext<BarChartContextType>({\n layout: 'horizontal',\n activeIndex: undefined,\n colorTheme: '
|
|
1
|
+
{"version":3,"file":"BarChartContext.js","sources":["../../../../../../../src/components/Charts/BarChart/BarChartContext.ts"],"sourcesContent":["import { createContext, useContext } from 'react';\nimport type { BarChartContextType } from './types';\n\nexport const BarChartContext = createContext<BarChartContextType>({\n layout: 'horizontal',\n activeIndex: undefined,\n colorTheme: 'categorical',\n totalBars: 0,\n});\n\nexport const useBarChartContext = (): BarChartContextType => useContext(BarChartContext);\n"],"names":["BarChartContext","createContext","layout","activeIndex","undefined","colorTheme","totalBars","useBarChartContext","useContext"],"mappings":";;AAGaA,IAAAA,eAAe,gBAAGC,aAAa,CAAsB;AAChEC,EAAAA,MAAM,EAAE,YAAY;AACpBC,EAAAA,WAAW,EAAEC,SAAS;AACtBC,EAAAA,UAAU,EAAE,aAAa;AACzBC,EAAAA,SAAS,EAAE,CAAA;AACb,CAAC,EAAC;AAEWC,IAAAA,kBAAkB,GAAG,SAArBA,kBAAkBA,GAAA;EAAA,OAA8BC,UAAU,CAACR,eAAe,CAAC,CAAA;AAAA;;;;"}
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
2
|
import 'react';
|
|
3
3
|
import { XAxis, YAxis, CartesianGrid, Tooltip, Legend, ReferenceLine } from 'recharts';
|
|
4
|
-
import { X_OFFSET, Y_OFFSET, X_AXIS_TEXT_BASELINE, TEXT_BASELINE, PADDING_HORIZONTAL, PADDING_VERTICAL, RECT_HEIGHT } from './tokens.js';
|
|
4
|
+
import { X_OFFSET, Y_OFFSET, X_AXIS_TEXT_BASELINE, componentId, TEXT_BASELINE, PADDING_HORIZONTAL, PADDING_VERTICAL, RECT_HEIGHT } from './tokens.js';
|
|
5
5
|
import { calculateTextWidth } from './utils.js';
|
|
6
6
|
import '../../Typography/index.js';
|
|
7
7
|
import '../../Box/index.js';
|
|
8
8
|
import '../../BladeProvider/index.js';
|
|
9
|
+
import '../../../utils/assignWithoutSideEffects/index.js';
|
|
9
10
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
10
11
|
import useTheme from '../../BladeProvider/useTheme.js';
|
|
11
12
|
import { Heading } from '../../Typography/Heading/Heading.js';
|
|
12
13
|
import { Box } from '../../Box/Box.js';
|
|
13
14
|
import { Text } from '../../Typography/Text/Text.js';
|
|
15
|
+
import { assignWithoutSideEffects } from '../../../utils/assignWithoutSideEffects/assignWithoutSideEffects.js';
|
|
14
16
|
|
|
15
17
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
16
18
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -101,7 +103,7 @@ var ChartTooltip = function ChartTooltip(props) {
|
|
|
101
103
|
color: "surface.text.staticWhite.normal",
|
|
102
104
|
children: label
|
|
103
105
|
}), /*#__PURE__*/jsx(Box, {
|
|
104
|
-
paddingTop:
|
|
106
|
+
paddingTop: label ? 'spacing.4' : undefined,
|
|
105
107
|
children: payload.map(function (item) {
|
|
106
108
|
return /*#__PURE__*/jsxs(Box, {
|
|
107
109
|
display: "flex",
|
|
@@ -117,7 +119,7 @@ var ChartTooltip = function ChartTooltip(props) {
|
|
|
117
119
|
style: {
|
|
118
120
|
width: theme.spacing[4],
|
|
119
121
|
height: theme.spacing[4],
|
|
120
|
-
backgroundColor: item.color,
|
|
122
|
+
backgroundColor: item.color || item.payload.fill,
|
|
121
123
|
borderRadius: theme.border.radius.small
|
|
122
124
|
}
|
|
123
125
|
}), /*#__PURE__*/jsx(Text, {
|
|
@@ -144,12 +146,14 @@ var ChartTooltip = function ChartTooltip(props) {
|
|
|
144
146
|
}, props));
|
|
145
147
|
};
|
|
146
148
|
var CustomSquareLegend = function CustomSquareLegend(props) {
|
|
147
|
-
var payload = props.payload
|
|
149
|
+
var payload = props.payload,
|
|
150
|
+
layout = props.layout;
|
|
148
151
|
var _useTheme5 = useTheme(),
|
|
149
152
|
theme = _useTheme5.theme;
|
|
150
153
|
if (!payload || payload.length === 0) {
|
|
151
154
|
return null;
|
|
152
155
|
}
|
|
156
|
+
|
|
153
157
|
/*
|
|
154
158
|
This is a custom legend component that is used to display the legend for the chart.
|
|
155
159
|
we need to show the legend only if the legendType is not none. (for example in line chart we don't want to show the legend for the reference line)
|
|
@@ -159,10 +163,14 @@ var CustomSquareLegend = function CustomSquareLegend(props) {
|
|
|
159
163
|
var _entry$payload;
|
|
160
164
|
return (entry === null || entry === void 0 || (_entry$payload = entry.payload) === null || _entry$payload === void 0 ? void 0 : _entry$payload.legendType) !== 'none';
|
|
161
165
|
});
|
|
166
|
+
var isVerticalLayout = layout === 'vertical';
|
|
162
167
|
return /*#__PURE__*/jsx(Box, {
|
|
163
168
|
display: "flex",
|
|
164
169
|
justifyContent: "center",
|
|
165
170
|
gap: "spacing.5",
|
|
171
|
+
flexDirection: isVerticalLayout ? 'column' : 'row',
|
|
172
|
+
width: isVerticalLayout ? '100%' : 'auto',
|
|
173
|
+
flexWrap: "wrap",
|
|
166
174
|
children: filteredPayload.map(function (entry, index) {
|
|
167
175
|
return /*#__PURE__*/jsx(Box, {
|
|
168
176
|
display: "flex",
|
|
@@ -193,7 +201,8 @@ var CustomSquareLegend = function CustomSquareLegend(props) {
|
|
|
193
201
|
})
|
|
194
202
|
});
|
|
195
203
|
};
|
|
196
|
-
var
|
|
204
|
+
var _ChartLegend = function _ChartLegend(props) {
|
|
205
|
+
var _props$layout;
|
|
197
206
|
var _useTheme6 = useTheme(),
|
|
198
207
|
theme = _useTheme6.theme;
|
|
199
208
|
return /*#__PURE__*/jsx(Legend, _objectSpread({
|
|
@@ -204,9 +213,15 @@ var ChartLegend = function ChartLegend(props) {
|
|
|
204
213
|
paddingTop: theme.spacing[5]
|
|
205
214
|
},
|
|
206
215
|
align: "center",
|
|
207
|
-
|
|
216
|
+
verticalAlign: props.layout === 'vertical' ? 'middle' : 'bottom',
|
|
217
|
+
content: /*#__PURE__*/jsx(CustomSquareLegend, {
|
|
218
|
+
layout: (_props$layout = props.layout) !== null && _props$layout !== void 0 ? _props$layout : 'horizontal'
|
|
219
|
+
})
|
|
208
220
|
}, props));
|
|
209
221
|
};
|
|
222
|
+
var ChartLegend = /*#__PURE__*/assignWithoutSideEffects(_ChartLegend, {
|
|
223
|
+
componentId: componentId.chartLegend
|
|
224
|
+
});
|
|
210
225
|
var CustomReferenceLabel = function CustomReferenceLabel(_ref3) {
|
|
211
226
|
var viewBox = _ref3.viewBox,
|
|
212
227
|
value = _ref3.value,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommonChartComponents.web.js","sources":["../../../../../../../src/components/Charts/CommonChartComponents/CommonChartComponents.web.tsx"],"sourcesContent":["import React from 'react';\nimport {\n XAxis as RechartsXAxis,\n YAxis as RechartsYAxis,\n CartesianGrid as RechartsCartesianGrid,\n Tooltip as RechartsTooltip,\n Legend as RechartsLegend,\n ReferenceLine as RechartsReferenceLine,\n} from 'recharts';\nimport type {\n ChartReferenceLineProps,\n ChartXAxisProps,\n ChartYAxisProps,\n ChartTooltipProps,\n ChartLegendProps,\n ChartCartesianGridProps,\n} from './types';\nimport {\n RECT_HEIGHT,\n TEXT_BASELINE,\n PADDING_VERTICAL,\n PADDING_HORIZONTAL,\n X_AXIS_TEXT_BASELINE,\n Y_OFFSET,\n X_OFFSET,\n} from './tokens';\nimport { calculateTextWidth } from './utils';\nimport { Heading, Text } from '~components/Typography';\nimport { Box } from '~components/Box';\nimport { useTheme } from '~components/BladeProvider';\n\nconst ChartXAxis: React.FC<ChartXAxisProps> = (props) => {\n const { theme } = useTheme();\n\n return (\n <RechartsXAxis\n {...props}\n tick={{\n fill: theme.colors.surface.text.gray.normal,\n fontSize: theme.typography.fonts.size[75],\n fontFamily: theme.typography.fonts.family.text,\n fontWeight: theme.typography.fonts.weight.regular,\n letterSpacing: theme.typography.letterSpacings[100],\n }}\n stroke={theme.colors.surface.border.gray.muted}\n label={({ viewBox }: { viewBox: { x: number; y: number; width: number } }) => (\n <text\n x={viewBox.x + viewBox.width / 2 - X_OFFSET}\n y={viewBox.y + Y_OFFSET + X_AXIS_TEXT_BASELINE}\n textAnchor=\"middle\"\n fill={theme.colors.surface.text.gray.subtle}\n fontSize={theme.typography.fonts.size[75]}\n fontFamily={theme.typography.fonts.family.text}\n fontWeight={theme.typography.fonts.weight.medium}\n letterSpacing={theme.typography.letterSpacings[100]}\n >\n {props?.label}\n </text>\n )}\n dataKey={props?.dataKey}\n />\n );\n};\n\nconst ChartYAxis: React.FC<ChartYAxisProps> = (props) => {\n const { theme } = useTheme();\n\n return (\n <RechartsYAxis\n {...props}\n tick={{\n fill: theme.colors.surface.text.gray.normal,\n fontSize: theme.typography.fonts.size[75],\n fontFamily: theme.typography.fonts.family.text,\n fontWeight: theme.typography.fonts.weight.regular,\n letterSpacing: theme.typography.letterSpacings[100],\n }}\n stroke={theme.colors.surface.border.gray.muted}\n label={{\n value: props?.label,\n position: 'insideLeft',\n style: {\n textAnchor: 'middle',\n fill: theme.colors.surface.text.gray.subtle,\n fontSize: theme.typography.fonts.size[75],\n fontWeight: theme.typography.fonts.weight.medium,\n fontFamily: theme.typography.fonts.family.text,\n letterSpacing: theme.typography.letterSpacings[100],\n lineHeight: theme.typography.lineHeights[500],\n },\n angle: -90,\n fill: theme.colors.surface.text.gray.subtle,\n }}\n dataKey={props?.dataKey}\n />\n );\n};\n\nconst ChartCartesianGrid: React.FC<ChartCartesianGridProps> = (props) => {\n const { theme } = useTheme();\n\n return (\n <RechartsCartesianGrid\n stroke={theme.colors.surface.border.gray.muted}\n vertical={false}\n {...props}\n />\n );\n};\n\nconst ChartTooltip: React.FC<ChartTooltipProps> = (props) => {\n const { theme } = useTheme();\n\n return (\n <RechartsTooltip\n content={({ payload, label }) => {\n return (\n <div\n style={{\n backgroundColor: theme.colors.surface.icon.staticBlack.normal,\n borderRadius: theme.border.radius.large,\n border: `1px solid ${theme.colors.surface.border.gray.muted}`,\n padding: theme.spacing[4],\n }}\n >\n <Heading size=\"small\" weight=\"semibold\" color=\"surface.text.staticWhite.normal\">\n {label}\n </Heading>\n <Box paddingTop=\"spacing.4\">\n {payload.map((item) => (\n <Box\n display=\"flex\"\n alignItems=\"center\"\n justifyContent=\"space-between\"\n gap=\"spacing.4\"\n key={item.name}\n >\n <Box display=\"flex\" gap=\"spacing.3\" alignItems=\"center\" justifyContent=\"center\">\n <div\n style={{\n width: theme.spacing[4],\n height: theme.spacing[4],\n backgroundColor: item.color,\n borderRadius: theme.border.radius.small,\n }}\n />\n <Text size=\"small\" weight=\"regular\" color=\"surface.text.staticWhite.normal\">\n {item.name}\n </Text>\n </Box>\n <Text size=\"small\" weight=\"regular\" color=\"surface.text.staticWhite.normal\">\n {item.value}\n </Text>\n </Box>\n ))}\n </Box>\n </div>\n );\n }}\n cursor={{ fill: 'transparent', stroke: 'transparent' }}\n {...props}\n />\n );\n};\n\nconst CustomSquareLegend = (props: {\n payload?: Array<{\n payload: {\n legendType: 'none' | 'line';\n };\n value: string;\n color: string;\n }>;\n}): JSX.Element | null => {\n const { payload } = props;\n const { theme } = useTheme();\n\n if (!payload || payload.length === 0) {\n return null;\n }\n /*\n This is a custom legend component that is used to display the legend for the chart.\n we need to show the legend only if the legendType is not none. (for example in line chart we don't want to show the legend for the reference line)\n so we are filtering the payload and then mapping over it to display the legend.\n */\n const filteredPayload = payload.filter((entry) => entry?.payload?.legendType !== 'none');\n\n return (\n <Box display=\"flex\" justifyContent=\"center\" gap=\"spacing.5\">\n {filteredPayload.map((entry, index) => (\n <Box key={`item-${index}`} display=\"flex\" alignItems=\"center\">\n <Box display=\"flex\" gap=\"spacing.3\" justifyContent=\"center\" alignItems=\"center\">\n <span\n style={{\n backgroundColor: entry.color, // Uses the color of the line/bar\n width: theme.spacing[4], // Size of the square\n height: theme.spacing[4], // Size of the square\n display: 'inline-block',\n borderRadius: theme.border.radius.small,\n }}\n />\n {/* Legend text with custom color and size */}\n <Text size=\"medium\" color=\"surface.text.gray.muted\">\n {entry.value}\n </Text>\n </Box>\n </Box>\n ))}\n </Box>\n );\n};\n\nconst ChartLegend: React.FC<ChartLegendProps> = (props) => {\n const { theme } = useTheme();\n\n return (\n <RechartsLegend\n wrapperStyle={{\n fontFamily: theme.typography.fonts.family.text,\n fontSize: theme.typography.fonts.size[100],\n color: theme.colors.surface.text.gray.normal,\n paddingTop: theme.spacing[5],\n }}\n align=\"center\"\n content={<CustomSquareLegend />}\n {...props}\n />\n );\n};\n\nconst CustomReferenceLabel = ({\n viewBox,\n value,\n isVertical,\n}: {\n viewBox?: { x: number; y: number; width: number };\n value: string | undefined;\n isVertical: boolean;\n}): JSX.Element => {\n // Extract viewBox coordinates with fallback values to prevent undefined errors.\n // viewBox contains the positioning information for the reference line label from Recharts.\n const { x, y, width } = viewBox ?? { x: 0, y: 0, width: 0 };\n const { theme } = useTheme();\n\n // Calculate dynamic text width to ensure the background rectangle fits the text perfectly.\n // This prevents text overflow for long labels and avoids unnecessarily large rectangles for short text.\n // The function also handles text truncation with ellipsis if the text exceeds the maximum width.\n const { width: RECT_WIDTH, displayText } = value\n ? calculateTextWidth(value, theme)\n : { width: 80, displayText: value ?? '' };\n\n const rect_x = isVertical ? x + width - RECT_WIDTH / 2 : x + width - RECT_WIDTH;\n const rect_y = isVertical ? y : y - TEXT_BASELINE;\n // Text position with padding inside the rectangle\n const text_x = rect_x + PADDING_HORIZONTAL + (RECT_WIDTH - PADDING_HORIZONTAL * 2) / 2;\n const text_y = rect_y + PADDING_VERTICAL + TEXT_BASELINE; // +15 for text baseline\n\n return (\n <g>\n <rect\n x={rect_x}\n y={rect_y}\n width={RECT_WIDTH}\n height={RECT_HEIGHT}\n rx={theme.border.radius.medium}\n fill={theme.colors.surface.background.gray.subtle}\n stroke={theme.colors.surface.border.gray.muted}\n strokeWidth=\"1\"\n />\n <text\n x={text_x}\n y={text_y}\n textAnchor=\"middle\"\n fill={theme.colors.surface.text.gray.normal}\n fontSize={theme.typography.fonts.size[50]}\n fontFamily={theme.typography.fonts.family.text}\n fontWeight={theme.typography.fonts.weight.medium}\n letterSpacing={theme.typography.letterSpacings[100]}\n >\n {displayText}\n </text>\n </g>\n );\n};\n\nconst ChartReferenceLine: React.FC<ChartReferenceLineProps> = ({ label, x, y }) => {\n const { theme } = useTheme();\n return (\n <RechartsReferenceLine\n stroke={theme.colors.chart.background.categorical.gray.intense}\n strokeWidth={2}\n strokeDasharray=\"4 4\"\n label={<CustomReferenceLabel value={label} isVertical={Boolean(x)} />}\n x={x}\n y={y}\n />\n );\n};\n\nexport {\n ChartXAxis,\n ChartYAxis,\n ChartCartesianGrid,\n ChartLegend,\n ChartTooltip,\n ChartReferenceLine,\n};\n"],"names":["ChartXAxis","props","_useTheme","useTheme","theme","_jsx","RechartsXAxis","_objectSpread","tick","fill","colors","surface","text","gray","normal","fontSize","typography","fonts","size","fontFamily","family","fontWeight","weight","regular","letterSpacing","letterSpacings","stroke","border","muted","label","_ref","viewBox","x","width","X_OFFSET","y","Y_OFFSET","X_AXIS_TEXT_BASELINE","textAnchor","subtle","medium","children","dataKey","ChartYAxis","_useTheme2","RechartsYAxis","value","position","style","lineHeight","lineHeights","angle","ChartCartesianGrid","_useTheme3","RechartsCartesianGrid","vertical","ChartTooltip","_useTheme4","RechartsTooltip","content","_ref2","payload","_jsxs","backgroundColor","icon","staticBlack","borderRadius","radius","large","concat","padding","spacing","Heading","color","Box","paddingTop","map","item","display","alignItems","justifyContent","gap","height","small","Text","name","cursor","CustomSquareLegend","_useTheme5","length","filteredPayload","filter","entry","_entry$payload","legendType","index","ChartLegend","_useTheme6","RechartsLegend","wrapperStyle","align","CustomReferenceLabel","_ref3","isVertical","_ref4","_useTheme7","_ref5","calculateTextWidth","displayText","RECT_WIDTH","rect_x","rect_y","TEXT_BASELINE","text_x","PADDING_HORIZONTAL","text_y","PADDING_VERTICAL","RECT_HEIGHT","rx","background","strokeWidth","ChartReferenceLine","_ref6","_useTheme8","RechartsReferenceLine","chart","categorical","intense","strokeDasharray","Boolean"],"mappings":";;;;;;;;;;;;;;;;AA+BA,IAAMA,UAAqC,GAAG,SAAxCA,UAAqCA,CAAIC,KAAK,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,eAAExB,GAAA,CAACgG,oBAAoB,EAAA;AAACvD,MAAAA,KAAK,EAAEjB,KAAM;MAAC0E,UAAU,EAAE0B,OAAO,CAACjG,CAAC,CAAA;AAAE,KAAE,CAAE;AACtEA,IAAAA,CAAC,EAAEA,CAAE;AACLG,IAAAA,CAAC,EAAEA,CAAAA;AAAE,GACN,CAAC,CAAA;AAEN;;;;"}
|
|
1
|
+
{"version":3,"file":"CommonChartComponents.web.js","sources":["../../../../../../../src/components/Charts/CommonChartComponents/CommonChartComponents.web.tsx"],"sourcesContent":["import React from 'react';\nimport {\n XAxis as RechartsXAxis,\n YAxis as RechartsYAxis,\n CartesianGrid as RechartsCartesianGrid,\n Tooltip as RechartsTooltip,\n Legend as RechartsLegend,\n ReferenceLine as RechartsReferenceLine,\n} from 'recharts';\nimport type {\n ChartReferenceLineProps,\n ChartXAxisProps,\n ChartYAxisProps,\n ChartTooltipProps,\n ChartLegendProps,\n ChartCartesianGridProps,\n Layout,\n} from './types';\nimport {\n RECT_HEIGHT,\n TEXT_BASELINE,\n PADDING_VERTICAL,\n PADDING_HORIZONTAL,\n X_AXIS_TEXT_BASELINE,\n Y_OFFSET,\n X_OFFSET,\n componentId,\n} from './tokens';\nimport { calculateTextWidth } from './utils';\nimport { Heading, Text } from '~components/Typography';\nimport { Box } from '~components/Box';\nimport { useTheme } from '~components/BladeProvider';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\n\nconst ChartXAxis: React.FC<ChartXAxisProps> = (props) => {\n const { theme } = useTheme();\n\n return (\n <RechartsXAxis\n {...props}\n tick={{\n fill: theme.colors.surface.text.gray.normal,\n fontSize: theme.typography.fonts.size[75],\n fontFamily: theme.typography.fonts.family.text,\n fontWeight: theme.typography.fonts.weight.regular,\n letterSpacing: theme.typography.letterSpacings[100],\n }}\n stroke={theme.colors.surface.border.gray.muted}\n label={({ viewBox }: { viewBox: { x: number; y: number; width: number } }) => (\n <text\n x={viewBox.x + viewBox.width / 2 - X_OFFSET}\n y={viewBox.y + Y_OFFSET + X_AXIS_TEXT_BASELINE}\n textAnchor=\"middle\"\n fill={theme.colors.surface.text.gray.subtle}\n fontSize={theme.typography.fonts.size[75]}\n fontFamily={theme.typography.fonts.family.text}\n fontWeight={theme.typography.fonts.weight.medium}\n letterSpacing={theme.typography.letterSpacings[100]}\n >\n {props?.label}\n </text>\n )}\n dataKey={props?.dataKey}\n />\n );\n};\n\nconst ChartYAxis: React.FC<ChartYAxisProps> = (props) => {\n const { theme } = useTheme();\n\n return (\n <RechartsYAxis\n {...props}\n tick={{\n fill: theme.colors.surface.text.gray.normal,\n fontSize: theme.typography.fonts.size[75],\n fontFamily: theme.typography.fonts.family.text,\n fontWeight: theme.typography.fonts.weight.regular,\n letterSpacing: theme.typography.letterSpacings[100],\n }}\n stroke={theme.colors.surface.border.gray.muted}\n label={{\n value: props?.label,\n position: 'insideLeft',\n style: {\n textAnchor: 'middle',\n fill: theme.colors.surface.text.gray.subtle,\n fontSize: theme.typography.fonts.size[75],\n fontWeight: theme.typography.fonts.weight.medium,\n fontFamily: theme.typography.fonts.family.text,\n letterSpacing: theme.typography.letterSpacings[100],\n lineHeight: theme.typography.lineHeights[500],\n },\n angle: -90,\n fill: theme.colors.surface.text.gray.subtle,\n }}\n dataKey={props?.dataKey}\n />\n );\n};\n\nconst ChartCartesianGrid: React.FC<ChartCartesianGridProps> = (props) => {\n const { theme } = useTheme();\n\n return (\n <RechartsCartesianGrid\n stroke={theme.colors.surface.border.gray.muted}\n vertical={false}\n {...props}\n />\n );\n};\n\nconst ChartTooltip: React.FC<ChartTooltipProps> = (props) => {\n const { theme } = useTheme();\n\n return (\n <RechartsTooltip\n content={({ payload, label }) => {\n return (\n <div\n style={{\n backgroundColor: theme.colors.surface.icon.staticBlack.normal,\n borderRadius: theme.border.radius.large,\n border: `1px solid ${theme.colors.surface.border.gray.muted}`,\n padding: theme.spacing[4],\n }}\n >\n <Heading size=\"small\" weight=\"semibold\" color=\"surface.text.staticWhite.normal\">\n {label}\n </Heading>\n <Box paddingTop={label ? 'spacing.4' : undefined}>\n {payload.map((item) => (\n <Box\n display=\"flex\"\n alignItems=\"center\"\n justifyContent=\"space-between\"\n gap=\"spacing.4\"\n key={item.name}\n >\n <Box display=\"flex\" gap=\"spacing.3\" alignItems=\"center\" justifyContent=\"center\">\n <div\n style={{\n width: theme.spacing[4],\n height: theme.spacing[4],\n backgroundColor: item.color || item.payload.fill,\n borderRadius: theme.border.radius.small,\n }}\n />\n <Text size=\"small\" weight=\"regular\" color=\"surface.text.staticWhite.normal\">\n {item.name}\n </Text>\n </Box>\n <Text size=\"small\" weight=\"regular\" color=\"surface.text.staticWhite.normal\">\n {item.value}\n </Text>\n </Box>\n ))}\n </Box>\n </div>\n );\n }}\n cursor={{ fill: 'transparent', stroke: 'transparent' }}\n {...props}\n />\n );\n};\n\nconst CustomSquareLegend = (props: {\n payload?: Array<{\n payload: {\n legendType: 'none' | 'line';\n };\n value: string;\n color: string;\n }>;\n layout: Layout;\n}): JSX.Element | null => {\n const { payload, layout } = props;\n const { theme } = useTheme();\n\n if (!payload || payload.length === 0) {\n return null;\n }\n\n /*\n This is a custom legend component that is used to display the legend for the chart.\n we need to show the legend only if the legendType is not none. (for example in line chart we don't want to show the legend for the reference line)\n so we are filtering the payload and then mapping over it to display the legend.\n */\n const filteredPayload = payload.filter((entry) => entry?.payload?.legendType !== 'none');\n const isVerticalLayout = layout === 'vertical';\n\n return (\n <Box\n display=\"flex\"\n justifyContent=\"center\"\n gap=\"spacing.5\"\n flexDirection={isVerticalLayout ? 'column' : 'row'}\n width={isVerticalLayout ? '100%' : 'auto'}\n flexWrap=\"wrap\"\n >\n {filteredPayload.map((entry, index) => (\n <Box key={`item-${index}`} display=\"flex\" alignItems=\"center\">\n <Box display=\"flex\" gap=\"spacing.3\" justifyContent=\"center\" alignItems=\"center\">\n <span\n style={{\n backgroundColor: entry.color, // Uses the color of the line/bar\n width: theme.spacing[4], // Size of the square\n height: theme.spacing[4], // Size of the square\n display: 'inline-block',\n borderRadius: theme.border.radius.small,\n }}\n />\n {/* Legend text with custom color and size */}\n <Text size=\"medium\" color=\"surface.text.gray.muted\">\n {entry.value}\n </Text>\n </Box>\n </Box>\n ))}\n </Box>\n );\n};\n\nconst _ChartLegend: React.FC<ChartLegendProps> = (props) => {\n const { theme } = useTheme();\n\n return (\n <RechartsLegend\n wrapperStyle={{\n fontFamily: theme.typography.fonts.family.text,\n fontSize: theme.typography.fonts.size[100],\n color: theme.colors.surface.text.gray.normal,\n paddingTop: theme.spacing[5],\n }}\n align=\"center\"\n verticalAlign={props.layout === 'vertical' ? 'middle' : 'bottom'}\n content={<CustomSquareLegend layout={props.layout ?? 'horizontal'} />}\n {...props}\n />\n );\n};\n\nconst ChartLegend = assignWithoutSideEffects(_ChartLegend, {\n componentId: componentId.chartLegend,\n});\n\nconst CustomReferenceLabel = ({\n viewBox,\n value,\n isVertical,\n}: {\n viewBox?: { x: number; y: number; width: number };\n value: string | undefined;\n isVertical: boolean;\n}): JSX.Element => {\n // Extract viewBox coordinates with fallback values to prevent undefined errors.\n // viewBox contains the positioning information for the reference line label from Recharts.\n const { x, y, width } = viewBox ?? { x: 0, y: 0, width: 0 };\n const { theme } = useTheme();\n\n // Calculate dynamic text width to ensure the background rectangle fits the text perfectly.\n // This prevents text overflow for long labels and avoids unnecessarily large rectangles for short text.\n // The function also handles text truncation with ellipsis if the text exceeds the maximum width.\n const { width: RECT_WIDTH, displayText } = value\n ? calculateTextWidth(value, theme)\n : { width: 80, displayText: value ?? '' };\n\n const rect_x = isVertical ? x + width - RECT_WIDTH / 2 : x + width - RECT_WIDTH;\n const rect_y = isVertical ? y : y - TEXT_BASELINE;\n // Text position with padding inside the rectangle\n const text_x = rect_x + PADDING_HORIZONTAL + (RECT_WIDTH - PADDING_HORIZONTAL * 2) / 2;\n const text_y = rect_y + PADDING_VERTICAL + TEXT_BASELINE; // +15 for text baseline\n\n return (\n <g>\n <rect\n x={rect_x}\n y={rect_y}\n width={RECT_WIDTH}\n height={RECT_HEIGHT}\n rx={theme.border.radius.medium}\n fill={theme.colors.surface.background.gray.subtle}\n stroke={theme.colors.surface.border.gray.muted}\n strokeWidth=\"1\"\n />\n <text\n x={text_x}\n y={text_y}\n textAnchor=\"middle\"\n fill={theme.colors.surface.text.gray.normal}\n fontSize={theme.typography.fonts.size[50]}\n fontFamily={theme.typography.fonts.family.text}\n fontWeight={theme.typography.fonts.weight.medium}\n letterSpacing={theme.typography.letterSpacings[100]}\n >\n {displayText}\n </text>\n </g>\n );\n};\n\nconst ChartReferenceLine: React.FC<ChartReferenceLineProps> = ({ label, x, y }) => {\n const { theme } = useTheme();\n return (\n <RechartsReferenceLine\n stroke={theme.colors.chart.background.categorical.gray.intense}\n strokeWidth={2}\n strokeDasharray=\"4 4\"\n label={<CustomReferenceLabel value={label} isVertical={Boolean(x)} />}\n x={x}\n y={y}\n />\n );\n};\n\nexport {\n ChartXAxis,\n ChartYAxis,\n ChartCartesianGrid,\n ChartLegend,\n ChartTooltip,\n ChartReferenceLine,\n};\n"],"names":["ChartXAxis","props","_useTheme","useTheme","theme","_jsx","RechartsXAxis","_objectSpread","tick","fill","colors","surface","text","gray","normal","fontSize","typography","fonts","size","fontFamily","family","fontWeight","weight","regular","letterSpacing","letterSpacings","stroke","border","muted","label","_ref","viewBox","x","width","X_OFFSET","y","Y_OFFSET","X_AXIS_TEXT_BASELINE","textAnchor","subtle","medium","children","dataKey","ChartYAxis","_useTheme2","RechartsYAxis","value","position","style","lineHeight","lineHeights","angle","ChartCartesianGrid","_useTheme3","RechartsCartesianGrid","vertical","ChartTooltip","_useTheme4","RechartsTooltip","content","_ref2","payload","_jsxs","backgroundColor","icon","staticBlack","borderRadius","radius","large","concat","padding","spacing","Heading","color","Box","paddingTop","undefined","map","item","display","alignItems","justifyContent","gap","height","small","Text","name","cursor","CustomSquareLegend","layout","_useTheme5","length","filteredPayload","filter","entry","_entry$payload","legendType","isVerticalLayout","flexDirection","flexWrap","index","_ChartLegend","_props$layout","_useTheme6","RechartsLegend","wrapperStyle","align","verticalAlign","ChartLegend","assignWithoutSideEffects","componentId","chartLegend","CustomReferenceLabel","_ref3","isVertical","_ref4","_useTheme7","_ref5","calculateTextWidth","displayText","RECT_WIDTH","rect_x","rect_y","TEXT_BASELINE","text_x","PADDING_HORIZONTAL","text_y","PADDING_VERTICAL","RECT_HEIGHT","rx","background","strokeWidth","ChartReferenceLine","_ref6","_useTheme8","RechartsReferenceLine","chart","categorical","intense","strokeDasharray","Boolean"],"mappings":";;;;;;;;;;;;;;;;;;AAkCA,IAAMA,UAAqC,GAAG,SAAxCA,UAAqCA,CAAIC,KAAK,EAAK;AACvD,EAAA,IAAAC,SAAA,GAAkBC,QAAQ,EAAE;IAApBC,KAAK,GAAAF,SAAA,CAALE,KAAK,CAAA;EAEb,oBACEC,GAAA,CAACC,KAAa,EAAAC,aAAA,CAAAA,aAAA,KACRN,KAAK,CAAA,EAAA,EAAA,EAAA;AACTO,IAAAA,IAAI,EAAE;MACJC,IAAI,EAAEL,KAAK,CAACM,MAAM,CAACC,OAAO,CAACC,IAAI,CAACC,IAAI,CAACC,MAAM;MAC3CC,QAAQ,EAAEX,KAAK,CAACY,UAAU,CAACC,KAAK,CAACC,IAAI,CAAC,EAAE,CAAC;MACzCC,UAAU,EAAEf,KAAK,CAACY,UAAU,CAACC,KAAK,CAACG,MAAM,CAACR,IAAI;MAC9CS,UAAU,EAAEjB,KAAK,CAACY,UAAU,CAACC,KAAK,CAACK,MAAM,CAACC,OAAO;AACjDC,MAAAA,aAAa,EAAEpB,KAAK,CAACY,UAAU,CAACS,cAAc,CAAC,GAAG,CAAA;KAClD;IACFC,MAAM,EAAEtB,KAAK,CAACM,MAAM,CAACC,OAAO,CAACgB,MAAM,CAACd,IAAI,CAACe,KAAM;AAC/CC,IAAAA,KAAK,EAAE,SAAPA,KAAKA,CAAAC,IAAA,EAAA;AAAA,MAAA,IAAKC,OAAO,GAAAD,IAAA,CAAPC,OAAO,CAAA;AAAA,M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AAC,EAAEA,CAAE;AACLG,IAAAA,CAAC,EAAEA,CAAAA;AAAE,GACN,CAAC,CAAA;AAEN;;;;"}
|
|
@@ -10,6 +10,9 @@ var Y_OFFSET = 14.5;
|
|
|
10
10
|
var X_AXIS_TEXT_BASELINE = 24;
|
|
11
11
|
var MIN_WIDTH = RECT_WIDTH;
|
|
12
12
|
var MAX_WIDTH = 200;
|
|
13
|
+
var componentId = {
|
|
14
|
+
chartLegend: 'chart-legend'
|
|
15
|
+
};
|
|
13
16
|
|
|
14
|
-
export { MAX_WIDTH, MIN_WIDTH, PADDING_HORIZONTAL, PADDING_VERTICAL, RECT_HEIGHT, RECT_WIDTH, TEXT_BASELINE, X_AXIS_TEXT_BASELINE, X_OFFSET, Y_OFFSET };
|
|
17
|
+
export { MAX_WIDTH, MIN_WIDTH, PADDING_HORIZONTAL, PADDING_VERTICAL, RECT_HEIGHT, RECT_WIDTH, TEXT_BASELINE, X_AXIS_TEXT_BASELINE, X_OFFSET, Y_OFFSET, componentId };
|
|
15
18
|
//# sourceMappingURL=tokens.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.js","sources":["../../../../../../../src/components/Charts/CommonChartComponents/tokens.ts"],"sourcesContent":["const RECT_WIDTH = 80;\nconst RECT_HEIGHT = 30;\nconst TEXT_BASELINE = 15;\n\n// Padding for text inside the rectangle (4px vertical, 8px horizontal)\nconst PADDING_VERTICAL = 4;\nconst PADDING_HORIZONTAL = 8;\n\nconst X_OFFSET = 32;\nconst Y_OFFSET = 14.5;\nconst X_AXIS_TEXT_BASELINE = 24;\n\nconst MIN_WIDTH = RECT_WIDTH;\nconst MAX_WIDTH = 200;\nexport {\n RECT_WIDTH,\n RECT_HEIGHT,\n TEXT_BASELINE,\n PADDING_VERTICAL,\n PADDING_HORIZONTAL,\n X_OFFSET,\n Y_OFFSET,\n X_AXIS_TEXT_BASELINE,\n MIN_WIDTH,\n MAX_WIDTH,\n};\n"],"names":["RECT_WIDTH","RECT_HEIGHT","TEXT_BASELINE","PADDING_VERTICAL","PADDING_HORIZONTAL","X_OFFSET","Y_OFFSET","X_AXIS_TEXT_BASELINE","MIN_WIDTH","MAX_WIDTH"],"mappings":"AAAMA,IAAAA,UAAU,GAAG,GAAE;AACfC,IAAAA,WAAW,GAAG,GAAE;AAChBC,IAAAA,aAAa,GAAG,GAAE;;AAExB;AACMC,IAAAA,gBAAgB,GAAG,EAAC;AACpBC,IAAAA,kBAAkB,GAAG,EAAC;AAEtBC,IAAAA,QAAQ,GAAG,GAAE;AACbC,IAAAA,QAAQ,GAAG,KAAI;AACfC,IAAAA,oBAAoB,GAAG,GAAE;AAEzBC,IAAAA,SAAS,GAAGR,WAAU;AACtBS,IAAAA,SAAS,GAAG;;;;"}
|
|
1
|
+
{"version":3,"file":"tokens.js","sources":["../../../../../../../src/components/Charts/CommonChartComponents/tokens.ts"],"sourcesContent":["const RECT_WIDTH = 80;\nconst RECT_HEIGHT = 30;\nconst TEXT_BASELINE = 15;\n\n// Padding for text inside the rectangle (4px vertical, 8px horizontal)\nconst PADDING_VERTICAL = 4;\nconst PADDING_HORIZONTAL = 8;\n\nconst X_OFFSET = 32;\nconst Y_OFFSET = 14.5;\nconst X_AXIS_TEXT_BASELINE = 24;\n\nconst MIN_WIDTH = RECT_WIDTH;\nconst MAX_WIDTH = 200;\n\nconst componentId = {\n chartLegend: 'chart-legend',\n};\n\nexport {\n componentId,\n RECT_WIDTH,\n RECT_HEIGHT,\n TEXT_BASELINE,\n PADDING_VERTICAL,\n PADDING_HORIZONTAL,\n X_OFFSET,\n Y_OFFSET,\n X_AXIS_TEXT_BASELINE,\n MIN_WIDTH,\n MAX_WIDTH,\n};\n"],"names":["RECT_WIDTH","RECT_HEIGHT","TEXT_BASELINE","PADDING_VERTICAL","PADDING_HORIZONTAL","X_OFFSET","Y_OFFSET","X_AXIS_TEXT_BASELINE","MIN_WIDTH","MAX_WIDTH","componentId","chartLegend"],"mappings":"AAAMA,IAAAA,UAAU,GAAG,GAAE;AACfC,IAAAA,WAAW,GAAG,GAAE;AAChBC,IAAAA,aAAa,GAAG,GAAE;;AAExB;AACMC,IAAAA,gBAAgB,GAAG,EAAC;AACpBC,IAAAA,kBAAkB,GAAG,EAAC;AAEtBC,IAAAA,QAAQ,GAAG,GAAE;AACbC,IAAAA,QAAQ,GAAG,KAAI;AACfC,IAAAA,oBAAoB,GAAG,GAAE;AAEzBC,IAAAA,SAAS,GAAGR,WAAU;AACtBS,IAAAA,SAAS,GAAG,IAAG;AAErB,IAAMC,WAAW,GAAG;AAClBC,EAAAA,WAAW,EAAE,cAAA;AACf;;;;"}
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import _typeof from '@babel/runtime/helpers/typeof';
|
|
2
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
3
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
4
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
5
|
+
import _objectDestructuringEmpty from '@babel/runtime/helpers/objectDestructuringEmpty';
|
|
6
|
+
import _extends from '@babel/runtime/helpers/extends';
|
|
7
|
+
import { useState, useRef, useEffect, useMemo, isValidElement, createElement } from 'react';
|
|
8
|
+
import { Cell, ResponsiveContainer, PieChart, Label, Pie } from 'recharts';
|
|
9
|
+
import '../utils/index.js';
|
|
10
|
+
import { componentId as componentId$1 } from '../CommonChartComponents/tokens.js';
|
|
11
|
+
import { componentId, LABEL_FONT_STYLES, LABEL_DISTANCE_FROM_CENTER, RADIUS_MAPPING, START_AND_END_ANGLES } from './tokens.js';
|
|
12
|
+
import '../../BladeProvider/index.js';
|
|
13
|
+
import '../../Box/BaseBox/index.js';
|
|
14
|
+
import '../../../utils/metaAttribute/index.js';
|
|
15
|
+
import getIn from '../../../utils/lodashButBetter/get.js';
|
|
16
|
+
import '../../../utils/makeAnalyticsAttribute/index.js';
|
|
17
|
+
import '../../../utils/assignWithoutSideEffects/index.js';
|
|
18
|
+
import '../../../utils/isValidAllowedChildren/index.js';
|
|
19
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
20
|
+
import { assignWithoutSideEffects } from '../../../utils/assignWithoutSideEffects/assignWithoutSideEffects.js';
|
|
21
|
+
import useTheme from '../../BladeProvider/useTheme.js';
|
|
22
|
+
import { getComponentId } from '../../../utils/isValidAllowedChildren/isValidAllowedChildren.js';
|
|
23
|
+
import { BaseBox } from '../../Box/BaseBox/BaseBox.web.js';
|
|
24
|
+
import { metaAttribute } from '../../../utils/metaAttribute/metaAttribute.web.js';
|
|
25
|
+
import { makeAnalyticsAttribute } from '../../../utils/makeAnalyticsAttribute/makeAnalyticsAttribute.js';
|
|
26
|
+
import useChartsColorTheme from '../utils/useColorTheme.js';
|
|
27
|
+
|
|
28
|
+
var _excluded = ["children", "content", "testID"],
|
|
29
|
+
_excluded2 = ["cx", "cy", "radius", "dataKey", "nameKey", "children", "data", "colorTheme", "type"];
|
|
30
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
31
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
32
|
+
var _Cell = function _Cell(_ref) {
|
|
33
|
+
var rest = _extends({}, (_objectDestructuringEmpty(_ref), _ref));
|
|
34
|
+
return /*#__PURE__*/jsx(Cell, _objectSpread({}, rest));
|
|
35
|
+
};
|
|
36
|
+
var ChartDonutCell = /*#__PURE__*/assignWithoutSideEffects(_Cell, {
|
|
37
|
+
componentId: componentId.cell
|
|
38
|
+
});
|
|
39
|
+
var getTranslate = function getTranslate(legendLayout, legendAlignment, legendWidth, legendHeight) {
|
|
40
|
+
if (legendLayout === 'vertical') {
|
|
41
|
+
return "translate(calc(-50% + ".concat(legendAlignment === 'right' ? -legendWidth / 2 : legendWidth / 2, "px) , calc(-50%))");
|
|
42
|
+
}
|
|
43
|
+
return "translate(-50%, calc(-50% - ".concat(legendHeight / 2, "px))");
|
|
44
|
+
};
|
|
45
|
+
var ChartDonutWrapper = function ChartDonutWrapper(_ref2) {
|
|
46
|
+
var children = _ref2.children,
|
|
47
|
+
content = _ref2.content,
|
|
48
|
+
testID = _ref2.testID,
|
|
49
|
+
restProps = _objectWithoutProperties(_ref2, _excluded);
|
|
50
|
+
var _useTheme = useTheme(),
|
|
51
|
+
theme = _useTheme.theme;
|
|
52
|
+
var _useState = useState(0),
|
|
53
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
54
|
+
legendHeight = _useState2[0],
|
|
55
|
+
setLegendHeight = _useState2[1];
|
|
56
|
+
var _useState3 = useState(0),
|
|
57
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
58
|
+
legendWidth = _useState4[0],
|
|
59
|
+
setLegendWidth = _useState4[1];
|
|
60
|
+
var chartRef = useRef(null);
|
|
61
|
+
var isValuePresentInContent = content && _typeof(content) === 'object' && 'value' in content;
|
|
62
|
+
var isLabelPresentInContent = content && _typeof(content) === 'object' && 'label' in content;
|
|
63
|
+
useEffect(function () {
|
|
64
|
+
var observer = new MutationObserver(function (mutations) {
|
|
65
|
+
mutations.forEach(function (mutation) {
|
|
66
|
+
if (mutation.type === 'childList') {
|
|
67
|
+
var _chartRef$current;
|
|
68
|
+
var legendWrapper = (_chartRef$current = chartRef.current) === null || _chartRef$current === void 0 ? void 0 : _chartRef$current.querySelector('.recharts-legend-wrapper');
|
|
69
|
+
if (legendWrapper) {
|
|
70
|
+
var height = legendWrapper.getBoundingClientRect().height;
|
|
71
|
+
var width = legendWrapper.getBoundingClientRect().width;
|
|
72
|
+
setLegendHeight(height);
|
|
73
|
+
setLegendWidth(width);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
if (chartRef.current) {
|
|
79
|
+
observer.observe(chartRef.current, {
|
|
80
|
+
childList: true,
|
|
81
|
+
subtree: true
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
return function () {
|
|
85
|
+
return observer.disconnect();
|
|
86
|
+
};
|
|
87
|
+
}, []);
|
|
88
|
+
var pieChartRadius = useMemo(function () {
|
|
89
|
+
if (Array.isArray(children)) {
|
|
90
|
+
var _donutChild$props;
|
|
91
|
+
var donutChild = children.find(function (child) {
|
|
92
|
+
return getComponentId(child) === componentId.chartDonut;
|
|
93
|
+
});
|
|
94
|
+
if (!donutChild || ! /*#__PURE__*/isValidElement(donutChild)) {
|
|
95
|
+
return 'medium';
|
|
96
|
+
}
|
|
97
|
+
return (donutChild === null || donutChild === void 0 || (_donutChild$props = donutChild.props) === null || _donutChild$props === void 0 ? void 0 : _donutChild$props.radius) || 'medium';
|
|
98
|
+
}
|
|
99
|
+
return 'medium';
|
|
100
|
+
}, [children]);
|
|
101
|
+
var legendLayout = useMemo(function () {
|
|
102
|
+
if (Array.isArray(children)) {
|
|
103
|
+
var _legendChild$props;
|
|
104
|
+
var legendChild = children.find(function (child) {
|
|
105
|
+
return getComponentId(child) === componentId$1.chartLegend;
|
|
106
|
+
});
|
|
107
|
+
if (!legendChild || ! /*#__PURE__*/isValidElement(legendChild)) {
|
|
108
|
+
return 'horizontal';
|
|
109
|
+
}
|
|
110
|
+
return (legendChild === null || legendChild === void 0 || (_legendChild$props = legendChild.props) === null || _legendChild$props === void 0 ? void 0 : _legendChild$props.layout) || 'horizontal';
|
|
111
|
+
}
|
|
112
|
+
return 'horizontal';
|
|
113
|
+
}, [children]);
|
|
114
|
+
var legendAlignment = useMemo(function () {
|
|
115
|
+
if (Array.isArray(children)) {
|
|
116
|
+
var _legendChild$props2;
|
|
117
|
+
var legendChild = children.find(function (child) {
|
|
118
|
+
return getComponentId(child) === componentId$1.chartLegend;
|
|
119
|
+
});
|
|
120
|
+
if (!legendChild || ! /*#__PURE__*/isValidElement(legendChild)) {
|
|
121
|
+
return 'right';
|
|
122
|
+
}
|
|
123
|
+
return (legendChild === null || legendChild === void 0 || (_legendChild$props2 = legendChild.props) === null || _legendChild$props2 === void 0 ? void 0 : _legendChild$props2.align) || 'right';
|
|
124
|
+
}
|
|
125
|
+
return 'right';
|
|
126
|
+
}, [children]);
|
|
127
|
+
return /*#__PURE__*/jsxs(BaseBox, _objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
128
|
+
ref: chartRef
|
|
129
|
+
}, metaAttribute({
|
|
130
|
+
name: 'donut-chart',
|
|
131
|
+
testID: testID
|
|
132
|
+
})), makeAnalyticsAttribute(restProps)), {}, {
|
|
133
|
+
width: "100%",
|
|
134
|
+
height: "100%"
|
|
135
|
+
}, restProps), {}, {
|
|
136
|
+
position: /*#__PURE__*/isValidElement(content) ? 'relative' : undefined,
|
|
137
|
+
children: [/*#__PURE__*/jsx(ResponsiveContainer, {
|
|
138
|
+
width: "100%",
|
|
139
|
+
height: "100%",
|
|
140
|
+
children: /*#__PURE__*/jsxs(PieChart, {
|
|
141
|
+
children: [children, isLabelPresentInContent && /*#__PURE__*/jsx(Label, {
|
|
142
|
+
position: "center",
|
|
143
|
+
fill: theme.colors.surface.text.gray.muted,
|
|
144
|
+
fontSize: theme.typography.fonts.size[LABEL_FONT_STYLES[pieChartRadius].fontSize.label],
|
|
145
|
+
fontFamily: theme.typography.fonts.family.text,
|
|
146
|
+
fontWeight: theme.typography.fonts.weight.medium,
|
|
147
|
+
letterSpacing: theme.typography.letterSpacings[100],
|
|
148
|
+
dy: isValuePresentInContent ? LABEL_DISTANCE_FROM_CENTER[pieChartRadius].withText : LABEL_DISTANCE_FROM_CENTER[pieChartRadius].normal,
|
|
149
|
+
children: content === null || content === void 0 ? void 0 : content.label
|
|
150
|
+
}), isValuePresentInContent && /*#__PURE__*/jsx(Label, {
|
|
151
|
+
position: "center",
|
|
152
|
+
fill: theme.colors.surface.text.gray.normal,
|
|
153
|
+
fontSize: theme.typography.fonts.size[LABEL_FONT_STYLES[pieChartRadius].fontSize.text],
|
|
154
|
+
fontFamily: theme.typography.fonts.family.heading,
|
|
155
|
+
fontWeight: theme.typography.fonts.weight.bold,
|
|
156
|
+
letterSpacing: theme.typography.letterSpacings[100],
|
|
157
|
+
dy: isLabelPresentInContent ? LABEL_DISTANCE_FROM_CENTER[pieChartRadius].withLabel : LABEL_DISTANCE_FROM_CENTER[pieChartRadius].normal,
|
|
158
|
+
children: content === null || content === void 0 ? void 0 : content.value
|
|
159
|
+
})]
|
|
160
|
+
})
|
|
161
|
+
}), /*#__PURE__*/isValidElement(content) && /*#__PURE__*/jsx(BaseBox, {
|
|
162
|
+
position: "absolute",
|
|
163
|
+
top: "50%",
|
|
164
|
+
left: "50%",
|
|
165
|
+
transform: getTranslate(legendLayout, legendAlignment, legendWidth, legendHeight),
|
|
166
|
+
zIndex: 10,
|
|
167
|
+
textAlign: "center",
|
|
168
|
+
children: content
|
|
169
|
+
})]
|
|
170
|
+
}));
|
|
171
|
+
};
|
|
172
|
+
var _ChartDonut = function _ChartDonut(_ref3) {
|
|
173
|
+
var _ref3$cx = _ref3.cx,
|
|
174
|
+
cx = _ref3$cx === void 0 ? '50%' : _ref3$cx,
|
|
175
|
+
_ref3$cy = _ref3.cy,
|
|
176
|
+
cy = _ref3$cy === void 0 ? '50%' : _ref3$cy,
|
|
177
|
+
_ref3$radius = _ref3.radius,
|
|
178
|
+
radius = _ref3$radius === void 0 ? 'medium' : _ref3$radius,
|
|
179
|
+
dataKey = _ref3.dataKey,
|
|
180
|
+
nameKey = _ref3.nameKey,
|
|
181
|
+
children = _ref3.children,
|
|
182
|
+
data = _ref3.data,
|
|
183
|
+
_ref3$colorTheme = _ref3.colorTheme,
|
|
184
|
+
colorTheme = _ref3$colorTheme === void 0 ? 'categorical' : _ref3$colorTheme,
|
|
185
|
+
_ref3$type = _ref3.type,
|
|
186
|
+
type = _ref3$type === void 0 ? 'circle' : _ref3$type,
|
|
187
|
+
rest = _objectWithoutProperties(_ref3, _excluded2);
|
|
188
|
+
var radiusConfig = RADIUS_MAPPING[radius];
|
|
189
|
+
var themeColors = useChartsColorTheme({
|
|
190
|
+
colorTheme: colorTheme
|
|
191
|
+
});
|
|
192
|
+
var _useState5 = useState(null),
|
|
193
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
194
|
+
hoveredIndex = _useState6[0],
|
|
195
|
+
setHoveredIndex = _useState6[1];
|
|
196
|
+
var _useTheme2 = useTheme(),
|
|
197
|
+
theme = _useTheme2.theme;
|
|
198
|
+
var getCellOpacity = function getCellOpacity(hoveredIndex, currentIndex) {
|
|
199
|
+
if (hoveredIndex === null) return 1;
|
|
200
|
+
if (hoveredIndex === currentIndex) return 1;
|
|
201
|
+
return 0.2;
|
|
202
|
+
};
|
|
203
|
+
var modifiedChildren = useMemo(function () {
|
|
204
|
+
if (Array.isArray(children)) {
|
|
205
|
+
return children.map(function (child, index) {
|
|
206
|
+
if (getComponentId(child) === componentId.cell) {
|
|
207
|
+
/*
|
|
208
|
+
Why we are not using React.cloneElement ? just use ChartDonutCell no?
|
|
209
|
+
cell can never be custom component in recharts. (as of v3.1.2)
|
|
210
|
+
(https://github.com/recharts/recharts/issues/2788)
|
|
211
|
+
https://github.com/recharts/recharts/discussions/5474
|
|
212
|
+
So we have placeholder component ChartDonutCell. which we replaced by RechartsCell internally so dev can see hover effects
|
|
213
|
+
working out of box.
|
|
214
|
+
*/
|
|
215
|
+
var fill = getIn(theme.colors, child.props.color) || themeColors[index];
|
|
216
|
+
return /*#__PURE__*/createElement(Cell, _objectSpread(_objectSpread({}, child.props), {}, {
|
|
217
|
+
fill: fill,
|
|
218
|
+
key: index,
|
|
219
|
+
opacity: getCellOpacity(hoveredIndex, index)
|
|
220
|
+
}));
|
|
221
|
+
} else {
|
|
222
|
+
return child;
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
return data === null || data === void 0 ? void 0 : data.map(function (_, index) {
|
|
227
|
+
return /*#__PURE__*/jsx(Cell, {
|
|
228
|
+
fill: themeColors[index],
|
|
229
|
+
opacity: getCellOpacity(hoveredIndex, index)
|
|
230
|
+
}, index);
|
|
231
|
+
});
|
|
232
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
233
|
+
}, [children, data, colorTheme, hoveredIndex, themeColors]);
|
|
234
|
+
return /*#__PURE__*/jsx(Pie, _objectSpread(_objectSpread({}, rest), {}, {
|
|
235
|
+
cx: cx,
|
|
236
|
+
cy: cy,
|
|
237
|
+
outerRadius: radiusConfig.outerRadius,
|
|
238
|
+
innerRadius: radiusConfig.innerRadius,
|
|
239
|
+
data: data,
|
|
240
|
+
startAngle: START_AND_END_ANGLES[type].startAngle,
|
|
241
|
+
endAngle: START_AND_END_ANGLES[type].endAngle,
|
|
242
|
+
onMouseEnter: function onMouseEnter(data, index) {
|
|
243
|
+
setHoveredIndex(index);
|
|
244
|
+
},
|
|
245
|
+
onMouseLeave: function onMouseLeave() {
|
|
246
|
+
setHoveredIndex(null);
|
|
247
|
+
},
|
|
248
|
+
children: modifiedChildren
|
|
249
|
+
}));
|
|
250
|
+
};
|
|
251
|
+
var ChartDonut = /*#__PURE__*/assignWithoutSideEffects(_ChartDonut, {
|
|
252
|
+
componentId: componentId.chartDonut
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
export { ChartDonut, ChartDonutCell, ChartDonutWrapper };
|
|
256
|
+
//# sourceMappingURL=DonutChart.web.js.map
|