@economic/taco 2.57.0-charts.12 → 2.57.0-charts.14
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.cjs +32 -14
- package/dist/taco.cjs.map +1 -1
- package/dist/taco.d.ts +10 -0
- package/dist/taco.js +32 -14
- package/dist/taco.js.map +1 -1
- package/package.json +2 -2
package/dist/taco.d.ts
CHANGED
@@ -459,6 +459,11 @@ export declare type CardProps = Omit<React_2.HTMLAttributes<HTMLDivElement>, 'ti
|
|
459
459
|
menu?: (props: Partial<MenuProps>) => JSX.Element;
|
460
460
|
};
|
461
461
|
|
462
|
+
export declare type CardTexts = {
|
463
|
+
/** Text and aria-label for menu button in Card */
|
464
|
+
menu: string;
|
465
|
+
};
|
466
|
+
|
462
467
|
declare interface ChartChildProps<TData extends object> {
|
463
468
|
dataKey: keyof TData;
|
464
469
|
label: string;
|
@@ -740,6 +745,9 @@ export declare const defaultLocalisationTexts: {
|
|
740
745
|
today: string;
|
741
746
|
};
|
742
747
|
};
|
748
|
+
card: {
|
749
|
+
menu: string;
|
750
|
+
};
|
743
751
|
combobox: {
|
744
752
|
tooltip: string;
|
745
753
|
};
|
@@ -2174,6 +2182,8 @@ export declare type LocalizationTexts = {
|
|
2174
2182
|
banner: BannerTexts;
|
2175
2183
|
/** Localized texts and aria-labels for [Calendar](component:calendar) component */
|
2176
2184
|
calendar: CalendarTexts;
|
2185
|
+
/** Localized texts and aria-labels for [Card](component:card) component */
|
2186
|
+
card: CardTexts;
|
2177
2187
|
/** Localized texts and aria-labels for [Combobox](component:combobox) component */
|
2178
2188
|
combobox: ComboboxTexts;
|
2179
2189
|
/** Localized texts and aria-labels for [DatePicker](component:datepicker) component */
|
package/dist/taco.js
CHANGED
@@ -7719,6 +7719,9 @@ const defaultLocalisationTexts = {
|
|
7719
7719
|
today: "Today"
|
7720
7720
|
}
|
7721
7721
|
},
|
7722
|
+
card: {
|
7723
|
+
menu: "Open menu"
|
7724
|
+
},
|
7722
7725
|
combobox: {
|
7723
7726
|
tooltip: "Search in list"
|
7724
7727
|
},
|
@@ -8017,7 +8020,7 @@ const defaultLocalisationTexts = {
|
|
8017
8020
|
}
|
8018
8021
|
};
|
8019
8022
|
const defaultLocalizationContext = {
|
8020
|
-
locale: "
|
8023
|
+
locale: "da-DK",
|
8021
8024
|
texts: defaultLocalisationTexts,
|
8022
8025
|
formatting: {
|
8023
8026
|
date: "dd.mm.yy"
|
@@ -11630,11 +11633,21 @@ const Content$8 = React.forwardRef(function CardContent(externalProps, ref) {
|
|
11630
11633
|
});
|
11631
11634
|
const Card = React.forwardRef(function Card2(props, ref) {
|
11632
11635
|
const { title, menu, children, className, ...otherProps } = props;
|
11636
|
+
const localization = useLocalization();
|
11633
11637
|
const cardClassName = clsx(
|
11634
11638
|
"bg-white flex flex-col rounded-xl border border-solid border-radius-[12px] border-grey-300 hover:border-grey-500",
|
11635
11639
|
className
|
11636
11640
|
);
|
11637
|
-
return /* @__PURE__ */ React.createElement("div", { ...otherProps, className: cardClassName, "data-taco": "card", ref }, /* @__PURE__ */ React.createElement("div", { className: "flex justify-between px-4 pb-2 pt-4" }, title && /* @__PURE__ */ React.createElement(Truncate, { tooltip: title }, /* @__PURE__ */ React.createElement("h4", { className: "mb-0 flex-grow truncate text-left" }, title)), menu ? /* @__PURE__ */ React.createElement(
|
11641
|
+
return /* @__PURE__ */ React.createElement("div", { ...otherProps, className: cardClassName, "data-taco": "card", ref }, /* @__PURE__ */ React.createElement("div", { className: "flex justify-between px-4 pb-2 pt-4" }, title && /* @__PURE__ */ React.createElement(Truncate, { tooltip: title }, /* @__PURE__ */ React.createElement("h4", { className: "mb-0 flex-grow truncate text-left" }, title)), menu ? /* @__PURE__ */ React.createElement(
|
11642
|
+
IconButton,
|
11643
|
+
{
|
11644
|
+
"aria-label": localization.texts.card.menu,
|
11645
|
+
icon: "ellipsis-horizontal",
|
11646
|
+
appearance: "discrete",
|
11647
|
+
menu,
|
11648
|
+
className: "-mt-[4px]"
|
11649
|
+
}
|
11650
|
+
) : null), children);
|
11638
11651
|
});
|
11639
11652
|
Card.Content = Content$8;
|
11640
11653
|
function $010c2913dbd2fe3d$export$5cae361ad82dce8b(value) {
|
@@ -82978,7 +82991,10 @@ function useChart(children, options) {
|
|
82978
82991
|
const [activeIndex, setActiveIndex] = React__default.useState();
|
82979
82992
|
const [hiddenItems, toggleItem] = useChartDataHiddenState();
|
82980
82993
|
const localization = useLocalization();
|
82981
|
-
const defaultFormatter2 = (value) => new Intl.NumberFormat(localization.locale).format(
|
82994
|
+
const defaultFormatter2 = (value) => new Intl.NumberFormat(localization.locale, { minimumFractionDigits: 2, trailingZeroDisplay: "stripIfInteger" }).format(
|
82995
|
+
value
|
82996
|
+
);
|
82997
|
+
const globalFormatter = (options == null ? void 0 : options.formatter) ?? defaultFormatter2;
|
82982
82998
|
const { items, shapes } = React__default.useMemo(() => {
|
82983
82999
|
const items2 = React__default.Children.toArray(children).filter((child) => React__default.isValidElement(child)).map((child) => {
|
82984
83000
|
const dataKey = child.props.dataKey ?? child.props.label;
|
@@ -82986,7 +83002,7 @@ function useChart(children, options) {
|
|
82986
83002
|
...child.props,
|
82987
83003
|
dataKey,
|
82988
83004
|
color: getThemeColor(child.props.color, "blue-300"),
|
82989
|
-
formatter: child.props.formatter ??
|
83005
|
+
formatter: child.props.formatter ?? globalFormatter,
|
82990
83006
|
isHidden: !!hiddenItems[dataKey],
|
82991
83007
|
unit: child.props.unit ?? (options == null ? void 0 : options.unit)
|
82992
83008
|
};
|
@@ -83013,7 +83029,7 @@ function useChart(children, options) {
|
|
83013
83029
|
});
|
83014
83030
|
return { items: items2, shapes: shapes2 };
|
83015
83031
|
}, [children, hiddenItems]);
|
83016
|
-
return { items, shapes, activeIndex, setActiveIndex, toggleItem };
|
83032
|
+
return { items, shapes, activeIndex, setActiveIndex, globalFormatter, toggleItem };
|
83017
83033
|
}
|
83018
83034
|
function useChartDataHiddenState() {
|
83019
83035
|
const [state, setState] = React__default.useState({});
|
@@ -83204,7 +83220,7 @@ BarChart.Bar = Bar;
|
|
83204
83220
|
const PIE_ACTIVE_WIDTH = 10;
|
83205
83221
|
const PIE_ACTIVE_WIDTH_OFFSET = 2;
|
83206
83222
|
function usePieChart(children, options) {
|
83207
|
-
const { items, shapes, activeIndex, setActiveIndex, toggleItem } = useChart(children, options);
|
83223
|
+
const { items, shapes, activeIndex, setActiveIndex, globalFormatter, toggleItem } = useChart(children, options);
|
83208
83224
|
const [radius, _setRadius] = React__default.useState(0);
|
83209
83225
|
function setRadius(width) {
|
83210
83226
|
_setRadius((width - 2 * (PIE_ACTIVE_WIDTH + PIE_ACTIVE_WIDTH_OFFSET)) / 2);
|
@@ -83225,7 +83241,7 @@ function usePieChart(children, options) {
|
|
83225
83241
|
labelLine: false,
|
83226
83242
|
outerRadius: radius
|
83227
83243
|
};
|
83228
|
-
return { pieProps, radius, setRadius, items, activeIndex, setActiveIndex, toggleItem, shapes };
|
83244
|
+
return { pieProps, radius, setRadius, items, activeIndex, setActiveIndex, globalFormatter, toggleItem, shapes };
|
83229
83245
|
}
|
83230
83246
|
const PIE_CHART_HOVER = 10;
|
83231
83247
|
const PIE_CHART_HOVER_OFFSET = 2;
|
@@ -83244,15 +83260,18 @@ function ActiveShape$1(props) {
|
|
83244
83260
|
const DONUT_WIDTH$1 = 20;
|
83245
83261
|
function DonutChart(props) {
|
83246
83262
|
const { children, formatter, showLegend = false, showTotal = false, tooltipTitle, unit: unit2, ...attributes } = props;
|
83247
|
-
const { pieProps, radius, setRadius, items, activeIndex, setActiveIndex, toggleItem } = usePieChart(
|
83248
|
-
|
83249
|
-
|
83250
|
-
|
83263
|
+
const { pieProps, radius, setRadius, items, activeIndex, setActiveIndex, globalFormatter, toggleItem } = usePieChart(
|
83264
|
+
children,
|
83265
|
+
{
|
83266
|
+
formatter,
|
83267
|
+
unit: unit2
|
83268
|
+
}
|
83269
|
+
);
|
83251
83270
|
const className = clsx("aspect-square", attributes.className);
|
83252
83271
|
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, { title: tooltipTitle }) }), /* @__PURE__ */ React__default.createElement(Pie, { ...pieProps, innerRadius: radius - DONUT_WIDTH$1 }))), showTotal ? /* @__PURE__ */ React__default.createElement(
|
83253
83272
|
Total,
|
83254
83273
|
{
|
83255
|
-
formatter,
|
83274
|
+
formatter: globalFormatter,
|
83256
83275
|
items,
|
83257
83276
|
unit: unit2,
|
83258
83277
|
style: { top: radius + DONUT_WIDTH$1 / 2, width: radius + DONUT_WIDTH$1 * 2 }
|
@@ -83265,10 +83284,9 @@ function Segment$2(_) {
|
|
83265
83284
|
DonutChart.Segment = Segment$2;
|
83266
83285
|
function Total(props) {
|
83267
83286
|
const { formatter, items, unit: unit2, ...attributes } = props;
|
83268
|
-
const localization = useLocalization();
|
83269
83287
|
const total = React__default.useMemo(() => {
|
83270
83288
|
const total2 = items.filter((item) => !item.isHidden).reduce((acc, curr) => acc + curr.value, 0);
|
83271
|
-
return
|
83289
|
+
return formatter(total2);
|
83272
83290
|
}, [items]);
|
83273
83291
|
return /* @__PURE__ */ React__default.createElement(
|
83274
83292
|
"div",
|