@economic/taco 2.57.0-charts.6 → 2.57.0-charts.8

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/taco.css CHANGED
@@ -1594,3 +1594,22 @@ table[data-taco^='table'] tr[data-row-create] {
1594
1594
  .recharts-wrapper > svg g {
1595
1595
  @apply !outline-none;
1596
1596
  }
1597
+ [data-taco='chart-donut-total'] {
1598
+ container: wrapper / inline-size;
1599
+ }
1600
+
1601
+ [data-taco='chart-donut-total'] span:first-child {
1602
+ @apply text-xl;
1603
+ }
1604
+
1605
+ @container wrapper (width < 100px) {
1606
+ [data-taco='chart-donut-total'] span:first-child {
1607
+ @apply text-red text-lg;
1608
+ }
1609
+ }
1610
+
1611
+ @container wrapper (width < 80px) {
1612
+ [data-taco='chart-donut-total'] span:first-child {
1613
+ @apply text-base;
1614
+ }
1615
+ }
package/dist/taco.js CHANGED
@@ -82781,6 +82781,47 @@ function Tooltip(props) {
82781
82781
  }
82782
82782
  return null;
82783
82783
  }
82784
+ function Legend$1(props) {
82785
+ const { hoverIndex, items, onHover: handleHover, onToggle: handleToggle } = props;
82786
+ const handleMouseEnter = (item, index2) => {
82787
+ if (item.isHidden) {
82788
+ return;
82789
+ }
82790
+ handleHover(index2);
82791
+ };
82792
+ const handleMouseLeave = () => handleHover(void 0);
82793
+ const handleClick = (item) => {
82794
+ if (!item.isHidden) {
82795
+ handleHover(void 0);
82796
+ }
82797
+ handleToggle(item.dataKey);
82798
+ };
82799
+ const moreButton = (moreButtonText) => /* @__PURE__ */ React__default.createElement(Button$4, { appearance: "transparent", className: "text-grey-700 !h-5 !min-h-[1.25rem] !px-1.5 text-xs" }, moreButtonText);
82800
+ return /* @__PURE__ */ React__default.createElement(OverflowGroup, { className: "mt-3 w-full gap-x-1", moreButton }, items.map((item, index2) => {
82801
+ const className = clsx("mr-1 flex h-3 w-3 rounded-sm", {
82802
+ border: item.isHidden
82803
+ });
82804
+ let style;
82805
+ if (!item.isHidden) {
82806
+ style = { backgroundColor: item.color };
82807
+ }
82808
+ return /* @__PURE__ */ React__default.createElement(
82809
+ "button",
82810
+ {
82811
+ key: item.label,
82812
+ className: "hover:bg-grey-200 focus-visible:yt-focus flex items-center rounded px-1 !text-xs",
82813
+ onClick: (event) => {
82814
+ event == null ? void 0 : event.preventDefault();
82815
+ handleClick(item);
82816
+ },
82817
+ onMouseEnter: () => handleMouseEnter(item, index2),
82818
+ onMouseLeave: () => handleMouseLeave()
82819
+ },
82820
+ /* @__PURE__ */ React__default.createElement("span", { className, style }, hoverIndex === index2 ? /* @__PURE__ */ React__default.createElement(Icon$1, { name: "tick-bold", className: clsx("!h-full !w-full", { "text-white": !item.isHidden }) }) : null),
82821
+ item.label
82822
+ );
82823
+ }));
82824
+ }
82784
82825
  const THEME_COLORS = {
82785
82826
  transparent: "transparent",
82786
82827
  current: "currentColor",
@@ -82917,7 +82958,8 @@ const mapColor = (palette, prefix2 = "") => {
82917
82958
  };
82918
82959
  const colors = mapColor(THEME_COLORS);
82919
82960
  const getThemeColor = (color2, def = "") => colors[color2 ?? def];
82920
- const getInverseThemeColor = (themeColor) => {
82961
+ const getInverseThemeColor = (hexCode) => {
82962
+ const themeColor = Object.keys(colors)[Object.values(colors).indexOf(hexCode)];
82921
82963
  const [color2, number2] = String(themeColor).split("-");
82922
82964
  const shade = Number(number2);
82923
82965
  if (shade) {
@@ -82932,47 +82974,6 @@ const getInverseThemeColor = (themeColor) => {
82932
82974
  }
82933
82975
  return color2 === "black" ? "white" : "black";
82934
82976
  };
82935
- function Legend$1(props) {
82936
- const { hoverIndex, items, onHover: handleHover, onToggle: handleToggle } = props;
82937
- const handleMouseEnter = (item, index2) => {
82938
- if (item.isHidden) {
82939
- return;
82940
- }
82941
- handleHover(index2);
82942
- };
82943
- const handleMouseLeave = () => handleHover(void 0);
82944
- const handleClick = (item) => {
82945
- if (!item.isHidden) {
82946
- handleHover(void 0);
82947
- }
82948
- handleToggle(item.dataKey);
82949
- };
82950
- const moreButton = (moreButtonText) => /* @__PURE__ */ React__default.createElement(Button$4, { appearance: "transparent", className: "text-grey-700 !h-5 !min-h-[1.25rem] !px-1.5 text-xs" }, moreButtonText);
82951
- return /* @__PURE__ */ React__default.createElement(OverflowGroup, { className: "mt-2.5 w-full gap-x-1", moreButton }, items.map((item, index2) => {
82952
- const className = clsx("mr-1 flex h-3 w-3 rounded-sm", {
82953
- border: item.isHidden
82954
- });
82955
- let style;
82956
- if (!item.isHidden) {
82957
- style = { backgroundColor: getThemeColor(item.color) };
82958
- }
82959
- return /* @__PURE__ */ React__default.createElement(
82960
- "button",
82961
- {
82962
- key: item.label,
82963
- className: "hover:bg-grey-200 focus-visible:yt-focus flex items-center rounded px-1 !text-xs",
82964
- onClick: (event) => {
82965
- event == null ? void 0 : event.preventDefault();
82966
- handleClick(item);
82967
- },
82968
- onMouseEnter: () => handleMouseEnter(item, index2),
82969
- onMouseLeave: () => handleMouseLeave()
82970
- },
82971
- /* @__PURE__ */ React__default.createElement("span", { className, style }, hoverIndex === index2 ? /* @__PURE__ */ React__default.createElement(Icon$1, { name: "tick-bold", className: clsx("!h-full !w-full", { "text-white": !item.isHidden }) }) : null),
82972
- item.label
82973
- );
82974
- }));
82975
- }
82976
82977
  function useChart(children, options) {
82977
82978
  const [activeIndex, setActiveIndex] = React__default.useState();
82978
82979
  const [hiddenItems, toggleItem] = useChartDataHiddenState();
@@ -82984,28 +82985,28 @@ function useChart(children, options) {
82984
82985
  return {
82985
82986
  ...child.props,
82986
82987
  dataKey,
82988
+ color: getThemeColor(child.props.color, "blue-300"),
82987
82989
  formatter: child.props.formatter ?? (options == null ? void 0 : options.formatter) ?? defaultFormatter2,
82988
82990
  isHidden: !!hiddenItems[dataKey],
82989
82991
  unit: child.props.unit ?? (options == null ? void 0 : options.unit)
82990
82992
  };
82991
82993
  });
82992
82994
  const shapes2 = items2.filter((item) => !hiddenItems[item.dataKey]).map((item) => {
82993
- const color2 = getThemeColor(item.color, "blue-300");
82994
82995
  return {
82995
82996
  activeDot: {
82996
82997
  strokeWidth: 1
82997
82998
  },
82998
- color: color2,
82999
+ color: item.color,
82999
83000
  dataKey: item.dataKey,
83000
83001
  dot: {
83001
83002
  fillOpacity: 0.8
83002
83003
  },
83003
83004
  isAnimationActive: false,
83004
- fill: color2,
83005
- fillOpacity: 0.75,
83005
+ fill: item.color,
83006
+ fillOpacity: 0.8,
83006
83007
  formatter: item.formatter,
83007
83008
  name: item.label,
83008
- stroke: color2,
83009
+ stroke: item.color,
83009
83010
  strokeWidth: 1.5,
83010
83011
  unit: item.unit
83011
83012
  };
@@ -83049,7 +83050,7 @@ function AreaChart(props) {
83049
83050
  yAxisWidth,
83050
83051
  ...attributes
83051
83052
  } = props;
83052
- const className = clsx("relative aspect-video", { "pb-6": showLegend }, customClassName);
83053
+ const className = clsx("relative aspect-video", { "pb-8": showLegend }, customClassName);
83053
83054
  const { items, shapes, activeIndex, setActiveIndex, toggleItem } = useChart(children);
83054
83055
  return /* @__PURE__ */ React__default.createElement("div", { className, "data-taco": "chart-wrapper" }, /* @__PURE__ */ React__default.createElement(ChartWrapper, { ...attributes, className: "h-full w-full", "data-taco": "chart-area" }, /* @__PURE__ */ React__default.createElement(
83055
83056
  AreaChart$1,
@@ -83117,7 +83118,7 @@ function BarChart(props) {
83117
83118
  yAxisWidth,
83118
83119
  ...attributes
83119
83120
  } = props;
83120
- const className = clsx("relative aspect-video", { "pb-6": showLegend }, customClassName);
83121
+ const className = clsx("relative aspect-video", { "pb-8": showLegend }, customClassName);
83121
83122
  const { items, shapes, activeIndex, setActiveIndex, toggleItem } = useChart(children);
83122
83123
  return /* @__PURE__ */ React__default.createElement("div", { className, "data-taco": "chart-wrapper" }, /* @__PURE__ */ React__default.createElement(ChartWrapper, { ...attributes, className: "h-full w-full", "data-taco": "chart-bar" }, /* @__PURE__ */ React__default.createElement(
83123
83124
  BarChart$1,
@@ -83247,7 +83248,7 @@ function DonutChart(props) {
83247
83248
  unit: unit2
83248
83249
  });
83249
83250
  const className = clsx("aspect-square", attributes.className);
83250
- return /* @__PURE__ */ React__default.createElement("div", { className: "relative", "data-taco": "chart-wrapper" }, showTotal ? /* @__PURE__ */ React__default.createElement(
83251
+ return /* @__PURE__ */ React__default.createElement("div", { className: "relative", "data-taco": "chart-wrapper" }, /* @__PURE__ */ React__default.createElement(ChartWrapper, { ...attributes, className, "data-taco": "chart-donut", onSetWidth: setRadius }, /* @__PURE__ */ React__default.createElement(PieChart$1, null, /* @__PURE__ */ React__default.createElement(Tooltip$1, { content: /* @__PURE__ */ React__default.createElement(Tooltip$3, { title: tooltipTitle }) }), /* @__PURE__ */ React__default.createElement(Pie, { ...pieProps, innerRadius: radius - DONUT_WIDTH$1 }))), showTotal ? /* @__PURE__ */ React__default.createElement(
83251
83252
  Total,
83252
83253
  {
83253
83254
  formatter,
@@ -83255,7 +83256,7 @@ function DonutChart(props) {
83255
83256
  unit: unit2,
83256
83257
  style: { top: radius / 2 - 2, width: radius + DONUT_WIDTH$1 }
83257
83258
  }
83258
- ) : null, /* @__PURE__ */ React__default.createElement(ChartWrapper, { ...attributes, className, "data-taco": "chart-donut", onSetWidth: setRadius }, /* @__PURE__ */ React__default.createElement(PieChart$1, null, /* @__PURE__ */ React__default.createElement(Tooltip$1, { content: /* @__PURE__ */ React__default.createElement(Tooltip, { title: tooltipTitle }) }), /* @__PURE__ */ React__default.createElement(Pie, { ...pieProps, innerRadius: radius - DONUT_WIDTH$1 }))), showLegend ? /* @__PURE__ */ React__default.createElement(Legend$1, { items, hoverIndex: activeIndex, onHover: setActiveIndex, onToggle: toggleItem }) : null);
83259
+ ) : null, showLegend ? /* @__PURE__ */ React__default.createElement(Legend$1, { items, hoverIndex: activeIndex, onHover: setActiveIndex, onToggle: toggleItem }) : null);
83259
83260
  }
83260
83261
  function Segment$2(_) {
83261
83262
  return null;
@@ -83272,9 +83273,10 @@ function Total(props) {
83272
83273
  "div",
83273
83274
  {
83274
83275
  ...attributes,
83275
- className: "absolute-center-x flex aspect-square flex-col items-center justify-center rounded-full pt-[2px]"
83276
+ className: "absolute-center-x flex aspect-square flex-col items-center justify-center overflow-hidden rounded-full pt-[2px]",
83277
+ "data-taco": "chart-donut-total"
83276
83278
  },
83277
- /* @__PURE__ */ React__default.createElement("span", { className: "truncate text-2xl font-bold tabular-nums" }, total),
83279
+ /* @__PURE__ */ React__default.createElement(Tooltip$3, { title: total }, /* @__PURE__ */ React__default.createElement("span", { className: "w-full truncate text-center font-bold tabular-nums" }, total)),
83278
83280
  unit2 ? /* @__PURE__ */ React__default.createElement("span", { className: "text-grey-700 -mb-1 -mt-0.5 truncate text-xs" }, unit2) : null
83279
83281
  );
83280
83282
  }
@@ -83481,7 +83483,7 @@ function LineChart(props) {
83481
83483
  yAxisWidth,
83482
83484
  ...attributes
83483
83485
  } = props;
83484
- const className = clsx("relative aspect-video", { "pb-6": showLegend }, customClassName);
83486
+ const className = clsx("relative aspect-video", { "pb-8": showLegend }, customClassName);
83485
83487
  const { items, shapes, activeIndex, setActiveIndex, toggleItem } = useChart(children);
83486
83488
  return /* @__PURE__ */ React__default.createElement("div", { className, "data-taco": "chart-wrapper" }, /* @__PURE__ */ React__default.createElement(ChartWrapper, { ...attributes, className: "h-full w-full", "data-taco": "chart-line" }, /* @__PURE__ */ React__default.createElement(
83487
83489
  LineChart$1,