@headless-adminapp/fluent 1.4.3 → 1.4.5

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.
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AreaChart = AreaChart;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_components_1 = require("@fluentui/react-components");
6
+ const locale_1 = require("@headless-adminapp/app/locale");
6
7
  const react_1 = require("react");
7
8
  const recharts_1 = require("recharts");
8
9
  const CustomTooltipContent_1 = require("./CustomTooltipContent");
@@ -10,12 +11,13 @@ const formatters_1 = require("./formatters");
10
11
  const renderers_1 = require("./renderers");
11
12
  function AreaChart({ dataset, chartInfo, }) {
12
13
  const id = (0, react_1.useId)();
14
+ const locale = (0, locale_1.useLocale)();
13
15
  const xAxis = chartInfo.xAxis;
14
16
  const yAxis = chartInfo.yAxis;
15
17
  const areas = chartInfo.areas;
16
- const xAxisFullFormatter = (0, formatters_1.createLongAxisFormatter)(xAxis.tick);
17
- const yAxisFullFormatter = (0, formatters_1.createLongAxisFormatter)(yAxis.tick);
18
- return ((0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { width: "100%", height: "100%", children: (0, jsx_runtime_1.jsxs)(recharts_1.AreaChart, { data: dataset[0], children: [(0, renderers_1.renderGrid)(), (0, renderers_1.renderXAxis)(xAxis), (0, renderers_1.renderYAxis)(yAxis), (0, renderers_1.renderAreas)(areas, id), (0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { cursor: {
18
+ const xAxisFullFormatter = (0, formatters_1.createLongAxisFormatter)(locale, xAxis.tick);
19
+ const yAxisFullFormatter = (0, formatters_1.createLongAxisFormatter)(locale, yAxis.tick);
20
+ return ((0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { width: "100%", height: "100%", children: (0, jsx_runtime_1.jsxs)(recharts_1.AreaChart, { data: dataset[0], children: [(0, renderers_1.renderGrid)(), (0, renderers_1.renderXAxis)(locale, xAxis), (0, renderers_1.renderYAxis)(locale, yAxis), (0, renderers_1.renderAreas)(areas, id), (0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { cursor: {
19
21
  stroke: react_components_1.tokens.colorNeutralBackground6,
20
22
  opacity: 0.5,
21
23
  }, content: ({ active, payload, label }) => ((0, jsx_runtime_1.jsx)(CustomTooltipContent_1.CustomTooltipContent, { xAxisFormatter: xAxisFullFormatter, yAxisFormatter: yAxisFullFormatter, active: active, payload: payload, label: label })) })] }) }));
@@ -3,17 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BarChart = BarChart;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_components_1 = require("@fluentui/react-components");
6
+ const locale_1 = require("@headless-adminapp/app/locale");
6
7
  const recharts_1 = require("recharts");
7
8
  const CustomTooltipContent_1 = require("./CustomTooltipContent");
8
9
  const formatters_1 = require("./formatters");
9
10
  const renderers_1 = require("./renderers");
10
11
  function BarChart({ dataset, chartInfo, }) {
12
+ const locale = (0, locale_1.useLocale)();
11
13
  const xAxis = chartInfo.xAxis;
12
14
  const yAxis = chartInfo.yAxis;
13
15
  const bars = chartInfo.bars;
14
- const xAxisFullFormatter = (0, formatters_1.createLongAxisFormatter)(xAxis.tick);
15
- const yAxisFullFormatter = (0, formatters_1.createLongAxisFormatter)(yAxis.tick);
16
- return ((0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { width: "100%", height: "100%", children: (0, jsx_runtime_1.jsxs)(recharts_1.BarChart, { data: dataset[0], stackOffset: chartInfo.stackOffset, children: [(0, renderers_1.renderGrid)(), (0, renderers_1.renderYAxis)(yAxis), (0, renderers_1.renderXAxis)(xAxis), (0, renderers_1.renderBars)(bars, dataset), (0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { cursor: {
16
+ const xAxisFullFormatter = (0, formatters_1.createLongAxisFormatter)(locale, xAxis.tick);
17
+ const yAxisFullFormatter = (0, formatters_1.createLongAxisFormatter)(locale, yAxis.tick);
18
+ return ((0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { width: "100%", height: "100%", children: (0, jsx_runtime_1.jsxs)(recharts_1.BarChart, { data: dataset[0], stackOffset: chartInfo.stackOffset, children: [(0, renderers_1.renderGrid)(), (0, renderers_1.renderYAxis)(locale, yAxis), (0, renderers_1.renderXAxis)(locale, xAxis), (0, renderers_1.renderBars)(bars, dataset), (0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { cursor: {
17
19
  fill: react_components_1.tokens.colorNeutralBackground6,
18
20
  opacity: 0.2,
19
21
  }, content: ({ active, payload, label }) => ((0, jsx_runtime_1.jsx)(CustomTooltipContent_1.CustomTooltipContent, { xAxisFormatter: xAxisFullFormatter, yAxisFormatter: yAxisFullFormatter, active: active, payload: payload, label: label })) })] }) }));
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ComposedChart = ComposedChart;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_components_1 = require("@fluentui/react-components");
6
+ const locale_1 = require("@headless-adminapp/app/locale");
6
7
  const react_1 = require("react");
7
8
  const recharts_1 = require("recharts");
8
9
  const CustomTooltipContent_1 = require("./CustomTooltipContent");
@@ -10,12 +11,13 @@ const formatters_1 = require("./formatters");
10
11
  const renderers_1 = require("./renderers");
11
12
  function ComposedChart({ dataset, chartInfo, }) {
12
13
  const id = (0, react_1.useId)();
14
+ const locale = (0, locale_1.useLocale)();
13
15
  const xAxis = chartInfo.xAxis;
14
16
  const yAxis = chartInfo.yAxis;
15
17
  const rightYAxis = chartInfo.rightYAxis;
16
- const xAxisFullFormatter = (0, formatters_1.createLongAxisFormatter)(xAxis.tick);
17
- const yAxisFullFormatter = (0, formatters_1.createLongAxisFormatter)(yAxis.tick);
18
- const rightYAxisFullFormatter = (0, formatters_1.createLongAxisFormatter)(rightYAxis?.tick ?? yAxis.tick);
18
+ const xAxisFullFormatter = (0, formatters_1.createLongAxisFormatter)(locale, xAxis.tick);
19
+ const yAxisFullFormatter = (0, formatters_1.createLongAxisFormatter)(locale, yAxis.tick);
20
+ const rightYAxisFullFormatter = (0, formatters_1.createLongAxisFormatter)(locale, rightYAxis?.tick ?? yAxis.tick);
19
21
  const yAxisIdMapping = (0, react_1.useMemo)(() => {
20
22
  const mapping = {};
21
23
  chartInfo.bars?.forEach((bar) => {
@@ -32,7 +34,7 @@ function ComposedChart({ dataset, chartInfo, }) {
32
34
  const yAxisIdResolver = (0, react_1.useCallback)((dataKey) => {
33
35
  return yAxisIdMapping[dataKey] ?? 'left';
34
36
  }, [yAxisIdMapping]);
35
- return ((0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { width: "100%", height: "100%", children: (0, jsx_runtime_1.jsxs)(recharts_1.ComposedChart, { data: dataset[0], children: [(0, renderers_1.renderGrid)(), (0, renderers_1.renderYAxis)(yAxis), !!rightYAxis && (0, renderers_1.renderYAxis)(rightYAxis, 'right'), (0, renderers_1.renderXAxis)(xAxis, !!chartInfo.bars?.length), (0, renderers_1.renderLines)(chartInfo.lines ?? []), (0, renderers_1.renderAreas)(chartInfo.areas ?? [], id), (0, renderers_1.renderBars)(chartInfo.bars ?? [], dataset), (0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { cursor: {
37
+ return ((0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { width: "100%", height: "100%", children: (0, jsx_runtime_1.jsxs)(recharts_1.ComposedChart, { data: dataset[0], children: [(0, renderers_1.renderGrid)(), (0, renderers_1.renderYAxis)(locale, yAxis), !!rightYAxis && (0, renderers_1.renderYAxis)(locale, rightYAxis, 'right'), (0, renderers_1.renderXAxis)(locale, xAxis, !!chartInfo.bars?.length), (0, renderers_1.renderLines)(chartInfo.lines ?? []), (0, renderers_1.renderAreas)(chartInfo.areas ?? [], id), (0, renderers_1.renderBars)(chartInfo.bars ?? [], dataset), (0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { cursor: {
36
38
  stroke: react_components_1.tokens.colorNeutralBackground6,
37
39
  opacity: 0.5,
38
40
  }, content: ({ active, payload, label }) => ((0, jsx_runtime_1.jsx)(CustomTooltipContent_1.CustomTooltipContent, { xAxisFormatter: xAxisFullFormatter, yAxisFormatter: yAxisFullFormatter, yAxisIdResolver: yAxisIdResolver, rightYAxisFormatter: rightYAxisFullFormatter, active: active, payload: payload, label: label })) })] }) }));
@@ -3,21 +3,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FunnelChart = FunnelChart;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_components_1 = require("@fluentui/react-components");
6
+ const locale_1 = require("@headless-adminapp/app/locale");
6
7
  const react_1 = require("react");
7
8
  const recharts_1 = require("recharts");
8
9
  const constants_1 = require("./constants");
9
10
  const formatters_1 = require("./formatters");
10
11
  const FunnelCustomTooltipContent_1 = require("./FunnelCustomTooltipContent");
11
12
  function FunnelChart({ dataset, chartInfo, }) {
13
+ const locale = (0, locale_1.useLocale)();
12
14
  const item = chartInfo;
13
- const nameFormatter = (0, formatters_1.createLongAxisFormatter)({
15
+ const nameFormatter = (0, formatters_1.createLongAxisFormatter)(locale, {
14
16
  type: 'category',
15
17
  options: item.nameTick?.options,
16
18
  });
17
19
  const nameFormatterRef = (0, react_1.useRef)(nameFormatter);
18
20
  nameFormatterRef.current = nameFormatter;
19
21
  const data = dataset[0];
20
- const valueFormatter = (0, formatters_1.createLongAxisFormatter)(item.dataTick);
22
+ const valueFormatter = (0, formatters_1.createLongAxisFormatter)(locale, item.dataTick);
21
23
  const transformedData = (0, react_1.useMemo)(() => {
22
24
  if (!data?.length) {
23
25
  return [];
@@ -3,8 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FunnelCustomTooltipContent = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_components_1 = require("@fluentui/react-components");
6
+ const locale_1 = require("@headless-adminapp/app/locale");
6
7
  const formatters_1 = require("./formatters");
7
8
  const FunnelCustomTooltipContent = ({ active, payload, valueFormatter, }) => {
9
+ const locale = (0, locale_1.useLocale)();
8
10
  if (!active || !payload?.length) {
9
11
  return null;
10
12
  }
@@ -22,6 +24,8 @@ const FunnelCustomTooltipContent = ({ active, payload, valueFormatter, }) => {
22
24
  height: 8,
23
25
  background: firstPayload.payload.fill,
24
26
  borderRadius: 4,
25
- } }), (0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4, marginLeft: 8 }, children: valueFormatter(firstPayload.value) }), (0, jsx_runtime_1.jsx)("div", { style: { flex: 1, minWidth: 50 } }), (0, jsx_runtime_1.jsxs)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4 }, children: [(0, formatters_1.formatNumber)(firstPayload.payload.perc * 100, { maxDigit: 2 }), "%"] })] }) })] }));
27
+ } }), (0, jsx_runtime_1.jsx)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4, marginLeft: 8 }, children: valueFormatter(firstPayload.value) }), (0, jsx_runtime_1.jsx)("div", { style: { flex: 1, minWidth: 50 } }), (0, jsx_runtime_1.jsxs)(react_components_1.Caption1, { style: { color: react_components_1.tokens.colorNeutralForeground4 }, children: [(0, formatters_1.formatNumber)(locale, firstPayload.payload.perc * 100, {
28
+ maxDigit: 2,
29
+ }), "%"] })] }) })] }));
26
30
  };
27
31
  exports.FunnelCustomTooltipContent = FunnelCustomTooltipContent;
@@ -3,17 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LineChart = LineChart;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_components_1 = require("@fluentui/react-components");
6
+ const locale_1 = require("@headless-adminapp/app/locale");
6
7
  const recharts_1 = require("recharts");
7
8
  const CustomTooltipContent_1 = require("./CustomTooltipContent");
8
9
  const formatters_1 = require("./formatters");
9
10
  const renderers_1 = require("./renderers");
10
11
  function LineChart({ dataset, chartInfo, }) {
12
+ const locale = (0, locale_1.useLocale)();
11
13
  const xAxis = chartInfo.xAxis;
12
14
  const yAxis = chartInfo.yAxis;
13
15
  const lines = chartInfo.lines;
14
- const xAxisFullFormatter = (0, formatters_1.createLongAxisFormatter)(xAxis.tick);
15
- const yAxisFullFormatter = (0, formatters_1.createLongAxisFormatter)(yAxis.tick);
16
- return ((0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { width: "100%", height: "100%", children: (0, jsx_runtime_1.jsxs)(recharts_1.LineChart, { data: dataset[0], children: [(0, renderers_1.renderGrid)(), (0, renderers_1.renderYAxis)(yAxis), (0, renderers_1.renderXAxis)(xAxis), (0, renderers_1.renderLines)(lines), (0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { cursor: {
16
+ const xAxisFullFormatter = (0, formatters_1.createLongAxisFormatter)(locale, xAxis.tick);
17
+ const yAxisFullFormatter = (0, formatters_1.createLongAxisFormatter)(locale, yAxis.tick);
18
+ return ((0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { width: "100%", height: "100%", children: (0, jsx_runtime_1.jsxs)(recharts_1.LineChart, { data: dataset[0], children: [(0, renderers_1.renderGrid)(), (0, renderers_1.renderYAxis)(locale, yAxis), (0, renderers_1.renderXAxis)(locale, xAxis), (0, renderers_1.renderLines)(lines), (0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { cursor: {
17
19
  stroke: react_components_1.tokens.colorNeutralBackground6,
18
20
  opacity: 0.5,
19
21
  }, content: ({ active, payload, label }) => ((0, jsx_runtime_1.jsx)(CustomTooltipContent_1.CustomTooltipContent, { xAxisFormatter: xAxisFullFormatter, yAxisFormatter: yAxisFullFormatter, active: active, payload: payload, label: label })) })] }) }));
@@ -4,6 +4,7 @@ exports.barSizeInTime = void 0;
4
4
  exports.OhlcChart = OhlcChart;
5
5
  const jsx_runtime_1 = require("react/jsx-runtime");
6
6
  const react_components_1 = require("@fluentui/react-components");
7
+ const locale_1 = require("@headless-adminapp/app/locale");
7
8
  const insights_1 = require("@headless-adminapp/core/experience/insights");
8
9
  const react_1 = require("react");
9
10
  const recharts_1 = require("recharts");
@@ -29,6 +30,7 @@ const barSizeInTime = (interval) => {
29
30
  };
30
31
  exports.barSizeInTime = barSizeInTime;
31
32
  function OhlcChart({ dataset, chartInfo, }) {
33
+ const locale = (0, locale_1.useLocale)();
32
34
  const bar = chartInfo.bars[0];
33
35
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
34
36
  const data = dataset[bar.dataIndex ?? 0];
@@ -43,10 +45,10 @@ function OhlcChart({ dataset, chartInfo, }) {
43
45
  return [dataMin, dataMax];
44
46
  }, [bar, chartInfo.yAxis.domain, data]);
45
47
  const xAxis = chartInfo.xAxis;
46
- const xAxisFormatter = (0, formatters_1.createAxisFormatter)(xAxis.tick);
47
- const xAxisLongFormatter = (0, formatters_1.createLongAxisFormatter)(chartInfo.xAxis.tick);
48
- const yAxisLongFormatter = (0, formatters_1.createLongAxisFormatter)(chartInfo.yAxis.tick);
49
- return ((0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { width: "100%", height: "100%", children: (0, jsx_runtime_1.jsxs)(recharts_1.ScatterChart, { data: data, children: [(0, renderers_1.renderGrid)(), (0, renderers_1.renderYAxis)({
48
+ const xAxisFormatter = (0, formatters_1.createAxisFormatter)(locale, xAxis.tick);
49
+ const xAxisLongFormatter = (0, formatters_1.createLongAxisFormatter)(locale, chartInfo.xAxis.tick);
50
+ const yAxisLongFormatter = (0, formatters_1.createLongAxisFormatter)(locale, chartInfo.yAxis.tick);
51
+ return ((0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { width: "100%", height: "100%", children: (0, jsx_runtime_1.jsxs)(recharts_1.ScatterChart, { data: data, children: [(0, renderers_1.renderGrid)(), (0, renderers_1.renderYAxis)(locale, {
50
52
  ...chartInfo.yAxis,
51
53
  domain,
52
54
  }), (0, jsx_runtime_1.jsx)(recharts_1.XAxis, { dataKey: xAxis.dataKey, name: xAxis.name, tickFormatter: xAxisFormatter, tickLine: false, minTickGap: 10, padding: "gap", axisLine: {
@@ -4,10 +4,12 @@ exports.PieChart = PieChart;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  /* eslint-disable @typescript-eslint/no-explicit-any */
6
6
  const react_components_1 = require("@fluentui/react-components");
7
+ const locale_1 = require("@headless-adminapp/app/locale");
7
8
  const recharts_1 = require("recharts");
8
9
  const constants_1 = require("./constants");
9
10
  const formatters_1 = require("./formatters");
10
11
  function PieChart({ dataset, chartInfo, }) {
12
+ const locale = (0, locale_1.useLocale)();
11
13
  const RADIAN = Math.PI / 180;
12
14
  const renderCustomizedLabel = ({ cx, cy, midAngle, innerRadius, outerRadius, percent, }) => {
13
15
  const radius = innerRadius + (outerRadius - innerRadius) * 0.5;
@@ -19,8 +21,8 @@ function PieChart({ dataset, chartInfo, }) {
19
21
  return ((0, jsx_runtime_1.jsx)("text", { x: x, y: y, fill: "white", textAnchor: x > cx ? 'start' : 'end', dominantBaseline: "central", fontSize: react_components_1.tokens.fontSizeBase100, children: `${(percent * 100).toFixed(0)}%` }));
20
22
  };
21
23
  const item = chartInfo.pie[0];
22
- const nameFormatter = (0, formatters_1.createLongAxisFormatter)(item.nameTick);
23
- const valueFormatter = (0, formatters_1.createLongAxisFormatter)(item.dataTick);
24
+ const nameFormatter = (0, formatters_1.createLongAxisFormatter)(locale, item.nameTick);
25
+ const valueFormatter = (0, formatters_1.createLongAxisFormatter)(locale, item.dataTick);
24
26
  return ((0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { width: "100%", height: "100%", children: (0, jsx_runtime_1.jsxs)(recharts_1.PieChart, { children: [(0, jsx_runtime_1.jsx)(recharts_1.Pie, { data: dataset[item.dataIndex ?? 0], cx: "50%", cy: "50%", labelLine: false, label: renderCustomizedLabel, outerRadius: 80, dataKey: item.dataKey, nameKey: item.nameKey, blendStroke: true, legendType: "circle", children: dataset[item.dataIndex ?? 0].map((entry, index) => ((0, jsx_runtime_1.jsx)(recharts_1.Cell, { fill: item.colorKey && entry[item.colorKey]
25
27
  ? entry[item.colorKey]
26
28
  : (item.colors ?? constants_1.defaultColors)[index % (item.colors ?? constants_1.defaultColors).length] }, 'cell-' + String(index)))) }), chartInfo.showLegend && ((0, jsx_runtime_1.jsx)(recharts_1.Legend, { align: "right", layout: "vertical", verticalAlign: "top", wrapperStyle: {
@@ -4,14 +4,16 @@ exports.RadarChart = RadarChart;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  /* eslint-disable @typescript-eslint/no-explicit-any */
6
6
  const react_components_1 = require("@fluentui/react-components");
7
+ const locale_1 = require("@headless-adminapp/app/locale");
7
8
  const recharts_1 = require("recharts");
8
9
  const formatters_1 = require("./formatters");
9
10
  function RadarChart({ dataset, chartInfo, }) {
11
+ const locale = (0, locale_1.useLocale)();
10
12
  const data = dataset[0];
11
13
  const radar = chartInfo.radar[0];
12
- const nameFormatter = (0, formatters_1.createLongAxisFormatter)(radar.nameTick);
13
- const valueFormatter = (0, formatters_1.createLongAxisFormatter)(radar.dataTick);
14
- const tickFormatter = (0, formatters_1.createAxisFormatter)(radar.dataTick);
14
+ const nameFormatter = (0, formatters_1.createLongAxisFormatter)(locale, radar.nameTick);
15
+ const valueFormatter = (0, formatters_1.createLongAxisFormatter)(locale, radar.dataTick);
16
+ const tickFormatter = (0, formatters_1.createAxisFormatter)(locale, radar.dataTick);
15
17
  return ((0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { width: "100%", height: "100%", children: (0, jsx_runtime_1.jsxs)(recharts_1.RadarChart, { cx: "50%", cy: "50%", outerRadius: "80%", data: data, children: [(0, jsx_runtime_1.jsx)(recharts_1.PolarGrid, { stroke: react_components_1.tokens.colorNeutralBackground6, opacity: 0.5 }), (0, jsx_runtime_1.jsx)(recharts_1.PolarAngleAxis, { dataKey: radar.nameKey, fontSize: react_components_1.tokens.fontSizeBase100, tickFormatter: nameFormatter }), (0, jsx_runtime_1.jsx)(recharts_1.PolarRadiusAxis, { fontSize: react_components_1.tokens.fontSizeBase100, tickFormatter: tickFormatter }), (0, jsx_runtime_1.jsx)(recharts_1.Radar, { dataKey: radar.dataKey, stroke: radar.color ?? '#8884d8', fill: radar.color ?? '#8884d8', fillOpacity: 0.6 }), (0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { cursor: {
16
18
  stroke: react_components_1.tokens.colorNeutralBackground6,
17
19
  opacity: 0.5,
@@ -3,13 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ScatterChart = ScatterChart;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_components_1 = require("@fluentui/react-components");
6
+ const locale_1 = require("@headless-adminapp/app/locale");
6
7
  const react_1 = require("react");
7
8
  const recharts_1 = require("recharts");
8
9
  const constants_1 = require("./constants");
9
10
  const formatters_1 = require("./formatters");
10
11
  const renderers_1 = require("./renderers");
11
12
  function ScatterChart({ dataset, chartInfo, }) {
12
- return ((0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { width: "100%", height: "100%", children: (0, jsx_runtime_1.jsxs)(recharts_1.ScatterChart, { children: [(0, renderers_1.renderGrid)(), (0, renderers_1.renderXAxis)(chartInfo.xAxis, false, { left: 10, right: 10 }), (0, renderers_1.renderYAxis)(chartInfo.yAxis), (0, jsx_runtime_1.jsx)(recharts_1.ZAxis, { type: "number", dataKey: chartInfo.zAxis.dataKey, range: chartInfo.zAxis.range, name: chartInfo.zAxis.name }), chartInfo.scatters.map((scatter, index) => ((0, jsx_runtime_1.jsx)(recharts_1.Scatter, { yAxisId: "left", name: scatter.dataLabel, data: dataset[scatter.dataIndex ?? 0], dataKey: scatter.dataKey, fill: scatter.color ?? constants_1.defaultColors[index] }, index))), (0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { cursor: false, content: (props) => {
13
+ const locale = (0, locale_1.useLocale)();
14
+ return ((0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { width: "100%", height: "100%", children: (0, jsx_runtime_1.jsxs)(recharts_1.ScatterChart, { children: [(0, renderers_1.renderGrid)(), (0, renderers_1.renderXAxis)(locale, chartInfo.xAxis, false, { left: 10, right: 10 }), (0, renderers_1.renderYAxis)(locale, chartInfo.yAxis), (0, jsx_runtime_1.jsx)(recharts_1.ZAxis, { type: "number", dataKey: chartInfo.zAxis.dataKey, range: chartInfo.zAxis.range, name: chartInfo.zAxis.name }), chartInfo.scatters.map((scatter, index) => ((0, jsx_runtime_1.jsx)(recharts_1.Scatter, { yAxisId: "left", name: scatter.dataLabel, data: dataset[scatter.dataIndex ?? 0], dataKey: scatter.dataKey, fill: scatter.color ?? constants_1.defaultColors[index] }, index))), (0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { cursor: false, content: (props) => {
13
15
  if (!props.active || !props.payload?.length) {
14
16
  return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
15
17
  }
@@ -17,6 +19,7 @@ function ScatterChart({ dataset, chartInfo, }) {
17
19
  } })] }) }));
18
20
  }
19
21
  const ScatterTooltipContent = (props) => {
22
+ const locale = (0, locale_1.useLocale)();
20
23
  const chartInfo = props.chartInfo;
21
24
  const dataset = props.dataset;
22
25
  const xAxis = chartInfo.xAxis;
@@ -61,9 +64,9 @@ const ScatterTooltipContent = (props) => {
61
64
  yAxis.dataKey,
62
65
  zAxis.dataKey,
63
66
  ]);
64
- const xAxisFormatter = (0, formatters_1.createLongAxisFormatter)(xAxis.tick);
65
- const yAxisFormatter = (0, formatters_1.createLongAxisFormatter)(yAxis.tick);
66
- const zAxisFormatter = (0, formatters_1.createLongAxisFormatter)(zAxis.tick);
67
+ const xAxisFormatter = (0, formatters_1.createLongAxisFormatter)(locale, xAxis.tick);
68
+ const yAxisFormatter = (0, formatters_1.createLongAxisFormatter)(locale, yAxis.tick);
69
+ const zAxisFormatter = (0, formatters_1.createLongAxisFormatter)(locale, zAxis.tick);
67
70
  return ((0, jsx_runtime_1.jsx)("div", { style: {
68
71
  display: 'flex',
69
72
  flexDirection: 'column',
@@ -1,14 +1,15 @@
1
1
  import { AllAxisTick } from '@headless-adminapp/core/experience/insights';
2
+ import { Locale } from '@headless-adminapp/core/experience/locale';
2
3
  interface FormatNumberOptions {
3
4
  digit?: number;
4
5
  minDigit?: number;
5
6
  maxDigit?: number;
6
7
  }
7
- export declare const formatCurrencyWithSuffix: (input: number | undefined | null, digit?: number | FormatNumberOptions) => string;
8
+ export declare const formatCurrencyWithSuffix: (locale: Locale, input: number | undefined | null, digit?: number | FormatNumberOptions) => string;
8
9
  export declare const formatDate: (input: Date | string | number | undefined | null, format: string) => string;
9
- export declare const formatCurrency: (input: number | undefined | null, digit?: number | FormatNumberOptions) => string;
10
- export declare const formatNumber: (input: number | undefined | null, digit?: number | FormatNumberOptions) => string;
11
- export declare function createAxisFormatter(tick: AllAxisTick): (value: number) => string;
10
+ export declare const formatCurrency: (locale: Locale, input: number | undefined | null, digit?: number | FormatNumberOptions) => string;
11
+ export declare const formatNumber: (locale: Locale, input: number | undefined | null, digit?: number | FormatNumberOptions) => string;
12
+ export declare function createAxisFormatter(locale: Locale, tick: AllAxisTick): (value: number) => string;
12
13
  export type Formatter = (value: unknown) => string;
13
- export declare function createLongAxisFormatter(tick: AllAxisTick): Formatter;
14
+ export declare function createLongAxisFormatter(locale: Locale, tick: AllAxisTick): Formatter;
14
15
  export {};
@@ -28,7 +28,7 @@ function extractNumberInfo(value) {
28
28
  };
29
29
  }
30
30
  }
31
- const formatCurrencyWithSuffix = (input, digit = 2) => {
31
+ const formatCurrencyWithSuffix = (locale, input, digit = 2) => {
32
32
  const suffix = ['K', 'M', 'B', 'T'];
33
33
  if (input === null || input === undefined) {
34
34
  return '';
@@ -37,10 +37,11 @@ const formatCurrencyWithSuffix = (input, digit = 2) => {
37
37
  const sign = Math.sign(input);
38
38
  if (abs >= 1000) {
39
39
  const i = Math.floor(Math.log(abs) / Math.log(1000));
40
- return ((0, exports.formatCurrency)(sign * (abs / Math.pow(1000, i)), digit) + suffix[i - 1]);
40
+ return ((0, exports.formatCurrency)(locale, sign * (abs / Math.pow(1000, i)), digit) +
41
+ suffix[i - 1]);
41
42
  }
42
43
  else {
43
- return (0, exports.formatCurrency)(input, digit);
44
+ return (0, exports.formatCurrency)(locale, input, digit);
44
45
  }
45
46
  };
46
47
  exports.formatCurrencyWithSuffix = formatCurrencyWithSuffix;
@@ -51,28 +52,28 @@ const formatDate = (input, format) => {
51
52
  return (0, dayjs_1.default)(new Date(input)).format(format);
52
53
  };
53
54
  exports.formatDate = formatDate;
54
- const formatCurrency = (input, digit = 2) => {
55
+ const formatCurrency = (locale, input, digit = 2) => {
55
56
  if (input === null || input === undefined) {
56
57
  return '';
57
58
  }
58
59
  const minDigit = typeof digit === 'object' ? digit.minDigit ?? digit.digit : digit;
59
60
  const maxDigit = typeof digit === 'object' ? digit.maxDigit ?? digit.digit : digit;
60
- const formatter = new Intl.NumberFormat('en-IN', {
61
- currency: 'INR',
61
+ const formatter = new Intl.NumberFormat(locale.locale, {
62
62
  style: 'currency',
63
+ currency: locale.currency.currency,
63
64
  minimumFractionDigits: minDigit,
64
65
  maximumFractionDigits: maxDigit,
65
66
  });
66
67
  return formatter.format(input || 0);
67
68
  };
68
69
  exports.formatCurrency = formatCurrency;
69
- const formatNumber = (input, digit = 2) => {
70
+ const formatNumber = (locale, input, digit = 2) => {
70
71
  if (input === null || input === undefined) {
71
72
  return '';
72
73
  }
73
74
  const minDigit = typeof digit === 'object' ? digit.minDigit ?? digit.digit : digit;
74
75
  const maxDigit = typeof digit === 'object' ? digit.maxDigit ?? digit.digit : digit;
75
- const formatter = new Intl.NumberFormat('en-IN', {
76
+ const formatter = new Intl.NumberFormat(locale.locale, {
76
77
  minimumFractionDigits: minDigit,
77
78
  maximumFractionDigits: maxDigit,
78
79
  });
@@ -118,27 +119,38 @@ function createFullTimeAxisFormatter(format) {
118
119
  const formatString = timeLongAxisFormats[format];
119
120
  return (value) => (0, exports.formatDate)(new Date(value), formatString);
120
121
  }
121
- function createNumberAxisFormatter(options) {
122
+ function createNumberAxisFormatter(locale, options) {
122
123
  return (value) => {
123
124
  const info = extractNumberInfo(value);
124
125
  if (!info) {
125
126
  return '';
126
127
  }
127
- return (0, exports.formatNumber)(info.value, options) + info.symbol;
128
+ return (0, exports.formatNumber)(locale, info.value, options) + info.symbol;
128
129
  };
129
130
  }
130
- function createLongNumberAxisFormatter(options) {
131
+ function createLongNumberAxisFormatter(locale, options) {
131
132
  return (value) => {
132
- return (0, exports.formatNumber)(value, options);
133
+ return (0, exports.formatNumber)(locale, value, options);
133
134
  };
134
135
  }
135
- function createCurrencyAxisFormatter() {
136
+ function createCurrencyAxisFormatter(locale) {
136
137
  return (value) => {
137
138
  const info = extractNumberInfo(value);
138
139
  if (!info) {
139
140
  return '';
140
141
  }
141
- return (0, exports.formatCurrency)(info.value, 0) + info.symbol;
142
+ let maxDigit = 0;
143
+ if (info.symbol) {
144
+ if (Math.abs(info.value) < 10) {
145
+ maxDigit = 2;
146
+ }
147
+ else if (Math.abs(info.value) < 100) {
148
+ maxDigit = 1;
149
+ }
150
+ }
151
+ return ((0, exports.formatCurrency)(locale, info.value, {
152
+ maxDigit,
153
+ }) + info.symbol);
142
154
  };
143
155
  }
144
156
  function createCategoryAxisFormatter(options) {
@@ -152,14 +164,14 @@ function createCategoryAxisFormatter(options) {
152
164
  return typeof value === 'string' ? value : String(value);
153
165
  };
154
166
  }
155
- function createAxisFormatter(tick) {
167
+ function createAxisFormatter(locale, tick) {
156
168
  switch (tick.type) {
157
169
  case 'time':
158
170
  return createTimeAxisFormatter(tick.format);
159
171
  case 'number':
160
- return createNumberAxisFormatter(tick);
172
+ return createNumberAxisFormatter(locale, tick);
161
173
  case 'currency':
162
- return createCurrencyAxisFormatter();
174
+ return createCurrencyAxisFormatter(locale);
163
175
  case 'category':
164
176
  return createCategoryAxisFormatter(tick.options);
165
177
  case 'weekday':
@@ -168,14 +180,14 @@ function createAxisFormatter(tick) {
168
180
  return (value) => String(value);
169
181
  }
170
182
  }
171
- function createLongAxisFormatter(tick) {
183
+ function createLongAxisFormatter(locale, tick) {
172
184
  switch (tick.type) {
173
185
  case 'time':
174
186
  return createFullTimeAxisFormatter(tick.format);
175
187
  case 'number':
176
- return createLongNumberAxisFormatter(tick);
188
+ return createLongNumberAxisFormatter(locale, tick);
177
189
  case 'currency':
178
- return createCurrencyAxisFormatter();
190
+ return createCurrencyAxisFormatter(locale);
179
191
  case 'category':
180
192
  return createCategoryAxisFormatter(tick.options);
181
193
  case 'weekday':
@@ -1,7 +1,8 @@
1
1
  import { AreaInfo, BarInfo, LineInfo, XAxis, YAxis } from '@headless-adminapp/core/experience/insights';
2
+ import { Locale } from '@headless-adminapp/core/experience/locale';
2
3
  import { XAxisProps } from 'recharts';
3
- export declare function renderXAxis(axis: XAxis, forceCategory?: boolean, padding?: XAxisProps['padding']): import("react/jsx-runtime").JSX.Element;
4
- export declare function renderYAxis(axis: YAxis, axisId?: 'left' | 'right'): import("react/jsx-runtime").JSX.Element;
4
+ export declare function renderXAxis(locale: Locale, axis: XAxis, forceCategory?: boolean, padding?: XAxisProps['padding']): import("react/jsx-runtime").JSX.Element;
5
+ export declare function renderYAxis(locale: Locale, axis: YAxis, axisId?: 'left' | 'right'): import("react/jsx-runtime").JSX.Element;
5
6
  export declare function renderGrid(): import("react/jsx-runtime").JSX.Element;
6
7
  export declare function renderLine(line: LineInfo): import("react/jsx-runtime").JSX.Element;
7
8
  export declare function renderLines(lines: LineInfo[]): import("react/jsx-runtime").JSX.Element[];
@@ -14,8 +14,8 @@ const react_components_1 = require("@fluentui/react-components");
14
14
  const react_1 = require("react");
15
15
  const recharts_1 = require("recharts");
16
16
  const formatters_1 = require("./formatters");
17
- function renderXAxis(axis, forceCategory = false, padding = 'gap') {
18
- const xAxisFormatter = (0, formatters_1.createAxisFormatter)(axis.tick);
17
+ function renderXAxis(locale, axis, forceCategory = false, padding = 'gap') {
18
+ const xAxisFormatter = (0, formatters_1.createAxisFormatter)(locale, axis.tick);
19
19
  return ((0, jsx_runtime_1.jsx)(recharts_1.XAxis, { dataKey: axis.dataKey, name: axis.name, tickFormatter: xAxisFormatter, tickLine: false, minTickGap: 10,
20
20
  // padding={{ left: 10, right: 10 }}
21
21
  padding: padding, axisLine: {
@@ -25,8 +25,8 @@ function renderXAxis(axis, forceCategory = false, padding = 'gap') {
25
25
  opacity: 0.5,
26
26
  }, scale: !forceCategory && axis.tick.type === 'time' ? 'time' : 'auto', type: forceCategory || axis.tick.type === 'category' ? 'category' : 'number', domain: axis.domain, height: 16 }));
27
27
  }
28
- function renderYAxis(axis, axisId = 'left') {
29
- const yAxisFormatter = (0, formatters_1.createAxisFormatter)(axis.tick);
28
+ function renderYAxis(locale, axis, axisId = 'left') {
29
+ const yAxisFormatter = (0, formatters_1.createAxisFormatter)(locale, axis.tick);
30
30
  return ((0, jsx_runtime_1.jsx)(recharts_1.YAxis, { yAxisId: axisId, dataKey: axis.dataKey, orientation: axisId === 'right' ? 'right' : 'left', tickFormatter: yAxisFormatter, name: axis.name, tickLine: false, fontSize: react_components_1.tokens.fontSizeBase100, axisLine: false, tickMargin: 0, minTickGap: 0, accentHeight: 0, width: 40, scale: "auto", type: "number", domain: axis.domain, tick: {
31
31
  fill: react_components_1.tokens.colorNeutralForeground1,
32
32
  opacity: 0.5,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@headless-adminapp/fluent",
3
- "version": "1.4.3",
3
+ "version": "1.4.5",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -52,5 +52,5 @@
52
52
  "uuid": "11.0.3",
53
53
  "yup": "^1.4.0"
54
54
  },
55
- "gitHead": "5c5739c442d4690430997c7f375fed5966cde046"
55
+ "gitHead": "5f91697e5b3d509091ea75d4c2e61e64a492aa91"
56
56
  }