@sproutsocial/seeds-react-data-viz 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/index.js CHANGED
@@ -1473,6 +1473,19 @@ var donutChartStyles = css2`
1473
1473
  .highcharts-point-hover {
1474
1474
  fill-opacity: none;
1475
1475
  }
1476
+
1477
+ // apply cursor pointer when click functionality is turned on
1478
+ ${({ $hasOnClick }) => $hasOnClick && `
1479
+ .highcharts-series,
1480
+ .highcharts-point {
1481
+ cursor: pointer;
1482
+ }
1483
+ .highcharts-plot-background,
1484
+ .highcharts-crosshair,
1485
+ .highcharts-grid-line {
1486
+ fill: transparent;
1487
+ cursor: pointer;
1488
+ }`}
1476
1489
  `;
1477
1490
 
1478
1491
  // src/components/AreaChart/AreaChart.tsx
@@ -1615,6 +1628,7 @@ var DonutChartLegend = memo15(
1615
1628
  import { memo as memo16 } from "react";
1616
1629
  import { Box as Box10 } from "@sproutsocial/seeds-react-box";
1617
1630
  import { Duration as Duration2 } from "@sproutsocial/seeds-react-duration";
1631
+ import { Icon as Icon2 } from "@sproutsocial/seeds-react-icon";
1618
1632
  import { Numeral as Numeral2 } from "@sproutsocial/seeds-react-numeral";
1619
1633
  import { Text as Text5 } from "@sproutsocial/seeds-react-text";
1620
1634
  import { jsx as jsx17, jsxs as jsxs5 } from "react/jsx-runtime";
@@ -1628,7 +1642,9 @@ var DonutChartTooltip = memo16(
1628
1642
  value,
1629
1643
  currency,
1630
1644
  icon,
1631
- numberFormat
1645
+ numberFormat,
1646
+ onClick,
1647
+ tooltipClickLabel
1632
1648
  }) {
1633
1649
  const rows = [
1634
1650
  {
@@ -1663,7 +1679,13 @@ var DonutChartTooltip = memo16(
1663
1679
  ]
1664
1680
  }
1665
1681
  ];
1666
- return /* @__PURE__ */ jsx17(ChartTooltip, { children: /* @__PURE__ */ jsx17(ChartTooltipTable, { rows }) });
1682
+ return /* @__PURE__ */ jsxs5(ChartTooltip, { children: [
1683
+ /* @__PURE__ */ jsx17(ChartTooltipTable, { rows }),
1684
+ onClick && tooltipClickLabel ? /* @__PURE__ */ jsx17(ChartTooltipFooter, { children: typeof tooltipClickLabel === "string" ? /* @__PURE__ */ jsxs5(Box10, { display: "flex", alignItems: "center", gap: 300, children: [
1685
+ /* @__PURE__ */ jsx17(Icon2, { name: "hand-pointer-clicking-outline", color: "icon.base" }),
1686
+ /* @__PURE__ */ jsx17(Text5, { color: "text.subtext", fontSize: 200, children: tooltipClickLabel })
1687
+ ] }) : tooltipClickLabel }) : null
1688
+ ] });
1667
1689
  }
1668
1690
  );
1669
1691
 
@@ -1704,7 +1726,9 @@ var DonutChartWithData = memo17(
1704
1726
  disableTooltips = false,
1705
1727
  hideLegend = false,
1706
1728
  numberFormat = "decimal",
1707
- tooltip
1729
+ tooltip,
1730
+ onClick,
1731
+ tooltipClickLabel
1708
1732
  }) {
1709
1733
  const [options, setOptions] = useState4(donutChartOptions);
1710
1734
  const [chart, setChart] = useState4(null);
@@ -1745,7 +1769,12 @@ var DonutChartWithData = memo17(
1745
1769
  return {
1746
1770
  name: item.name,
1747
1771
  y: item.value,
1748
- colorIndex: index
1772
+ colorIndex: index,
1773
+ events: onClick ? {
1774
+ click: function() {
1775
+ onClick({ x: item.name });
1776
+ }
1777
+ } : void 0
1749
1778
  };
1750
1779
  })
1751
1780
  }
@@ -1760,40 +1789,50 @@ var DonutChartWithData = memo17(
1760
1789
  );
1761
1790
  return /* @__PURE__ */ jsxs6(Fragment3, { children: [
1762
1791
  /* @__PURE__ */ jsx18(GlobalChartStyleOverrides, {}),
1763
- /* @__PURE__ */ jsxs6(StyledBox4, { $colors: colors, bg: "container.background.base", children: [
1764
- /* @__PURE__ */ jsx18(
1765
- HighchartsReact2,
1766
- {
1767
- highcharts: Highcharts2,
1768
- options,
1769
- callback
1770
- }
1771
- ),
1772
- chart && !disableTooltips ? /* @__PURE__ */ jsx18(
1773
- ChartTooltipPortal,
1774
- {
1775
- chart,
1776
- renderContent: (context) => {
1777
- const { color, icon, name, percent, value } = transformDonutChartTooltipData({ context, data });
1778
- return tooltip ? tooltip({ color, icon, name, percent, value }) : /* @__PURE__ */ jsx18(
1779
- DonutChartTooltip,
1780
- {
1781
- color,
1782
- currency,
1783
- icon,
1784
- name,
1785
- numberFormat,
1786
- numberLocale,
1787
- percent,
1788
- textLocale,
1789
- value
1792
+ /* @__PURE__ */ jsxs6(
1793
+ StyledBox4,
1794
+ {
1795
+ $colors: colors,
1796
+ $hasOnClick: Boolean(onClick),
1797
+ bg: "container.background.base",
1798
+ children: [
1799
+ /* @__PURE__ */ jsx18(
1800
+ HighchartsReact2,
1801
+ {
1802
+ highcharts: Highcharts2,
1803
+ options,
1804
+ callback
1805
+ }
1806
+ ),
1807
+ chart && !disableTooltips ? /* @__PURE__ */ jsx18(
1808
+ ChartTooltipPortal,
1809
+ {
1810
+ chart,
1811
+ renderContent: (context) => {
1812
+ const { color, icon, name, percent, value } = transformDonutChartTooltipData({ context, data });
1813
+ return tooltip ? tooltip({ color, icon, name, percent, value }) : /* @__PURE__ */ jsx18(
1814
+ DonutChartTooltip,
1815
+ {
1816
+ color,
1817
+ currency,
1818
+ icon,
1819
+ name,
1820
+ numberFormat,
1821
+ numberLocale,
1822
+ percent,
1823
+ textLocale,
1824
+ value,
1825
+ onClick,
1826
+ tooltipClickLabel
1827
+ }
1828
+ );
1790
1829
  }
1791
- );
1792
- }
1793
- }
1794
- ) : null,
1795
- hideLegend ? null : /* @__PURE__ */ jsx18(Box11, { mt: 350, children: /* @__PURE__ */ jsx18(DonutChartLegend, { data }) })
1796
- ] })
1830
+ }
1831
+ ) : null,
1832
+ hideLegend ? null : /* @__PURE__ */ jsx18(Box11, { mt: 350, children: /* @__PURE__ */ jsx18(DonutChartLegend, { data }) })
1833
+ ]
1834
+ }
1835
+ )
1797
1836
  ] });
1798
1837
  }
1799
1838
  );
@@ -1918,7 +1957,7 @@ var LineChartLegend = memo19(
1918
1957
  import { memo as memo20 } from "react";
1919
1958
  import { Box as Box13 } from "@sproutsocial/seeds-react-box";
1920
1959
  import { Duration as Duration4 } from "@sproutsocial/seeds-react-duration";
1921
- import { Icon as Icon2 } from "@sproutsocial/seeds-react-icon";
1960
+ import { Icon as Icon3 } from "@sproutsocial/seeds-react-icon";
1922
1961
  import { Numeral as Numeral4 } from "@sproutsocial/seeds-react-numeral";
1923
1962
  import { Text as Text7 } from "@sproutsocial/seeds-react-text";
1924
1963
  import { jsx as jsx21, jsxs as jsxs8 } from "react/jsx-runtime";
@@ -1964,7 +2003,7 @@ var LineChartTooltip = memo20(
1964
2003
  /* @__PURE__ */ jsx21(ChartTooltipTitle, { children: tooltipDateFormatter({ x }) }),
1965
2004
  /* @__PURE__ */ jsx21(ChartTooltipTable, { rows }),
1966
2005
  onClick && tooltipClickLabel ? /* @__PURE__ */ jsx21(ChartTooltipFooter, { children: typeof tooltipClickLabel === "string" ? /* @__PURE__ */ jsxs8(Box13, { display: "flex", alignItems: "center", gap: 300, children: [
1967
- /* @__PURE__ */ jsx21(Icon2, { name: "hand-pointer-clicking-outline", color: "icon.base" }),
2006
+ /* @__PURE__ */ jsx21(Icon3, { name: "hand-pointer-clicking-outline", color: "icon.base" }),
1968
2007
  /* @__PURE__ */ jsx21(Text7, { color: "text.subtext", fontSize: 200, children: tooltipClickLabel })
1969
2008
  ] }) : tooltipClickLabel }) : null
1970
2009
  ] });