@mx-cartographer/experiences 9.7.42 → 9.7.43

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.
Files changed (36) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/core/types/InsightsInstanceSlotData.d.ts +3 -0
  3. package/dist/core/types/InsightsInstanceSlotData.es.js.map +1 -1
  4. package/dist/core/types/localization/InsightsFeedCopy.d.ts +3 -0
  5. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionDrillDown.d.ts +3 -1
  6. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionDrillDown.es.js +85 -75
  7. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionDrillDown.es.js.map +1 -1
  8. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js +115 -93
  9. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js.map +1 -1
  10. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.d.ts +3 -1
  11. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js +66 -44
  12. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js.map +1 -1
  13. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.d.ts +1 -1
  14. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.es.js +49 -44
  15. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.es.js.map +1 -1
  16. package/dist/insights-v2/analytics/analyticsEventsConfig.d.ts +4 -0
  17. package/dist/insights-v2/analytics/analyticsEventsConfig.es.js +4 -0
  18. package/dist/insights-v2/analytics/analyticsEventsConfig.es.js.map +1 -1
  19. package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/DoubleBarChartBlock.d.ts +1 -1
  20. package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/DoubleBarChartBlock.es.js +19 -19
  21. package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/DoubleBarChartBlock.es.js.map +1 -1
  22. package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/comparisonUtils.d.ts +8 -1
  23. package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/comparisonUtils.es.js +47 -31
  24. package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/comparisonUtils.es.js.map +1 -1
  25. package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/layout.d.ts +1 -5
  26. package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/layout.es.js +10 -6
  27. package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/layout.es.js.map +1 -1
  28. package/dist/insights-v2/components/SubTabs.d.ts +22 -0
  29. package/dist/insights-v2/components/SubTabs.es.js +38 -0
  30. package/dist/insights-v2/components/SubTabs.es.js.map +1 -0
  31. package/dist/insights-v2/components/chartblocks/ChartLegend.es.js +14 -18
  32. package/dist/insights-v2/components/chartblocks/ChartLegend.es.js.map +1 -1
  33. package/dist/insights-v2/components/chartblocks/DoubleBarChart.d.ts +5 -3
  34. package/dist/insights-v2/components/chartblocks/DoubleBarChart.es.js +108 -104
  35. package/dist/insights-v2/components/chartblocks/DoubleBarChart.es.js.map +1 -1
  36. package/package.json +1 -1
@@ -1,117 +1,121 @@
1
- import { EmptyBarChart as u } from "./EmptyBarChart.es.js";
2
- import { useContainerDimensions as C } from "../../hooks/useContainerDimensions.es.js";
3
- import { CustomDoubleBarPlotMXUI as k } from "./CustomDoubleBar.es.js";
4
- import { Legend as S } from "./ChartLegend.es.js";
5
- import w from "react";
6
- import I from "@mui/material/Stack";
7
- import { jsx as o, jsxs as c } from "react/jsx-runtime";
8
- import A from "@mui/material/Box";
9
- import { BarPlot as B } from "@mui/x-charts/BarChart";
10
- import { ChartContainer as R } from "@mui/x-charts/ChartContainer";
11
- import { ChartsXAxis as L } from "@mui/x-charts/ChartsXAxis";
12
- var E = ({ bars: r, colors: n, legends: d, isMini: l = !1, onBarClick: h }) => {
13
- const s = r.length - 1, p = 5e-3, f = 0.16, m = w.useRef(null), { height: x, width: y } = C(m), g = ({ dataIndex: e, seriesId: t }) => {
14
- h(e, Number(t.split("-").pop()));
15
- }, i = d?.map((e, t) => ({
16
- color: n[t] ?? "transparent",
1
+ import { EmptyBarChart as S } from "./EmptyBarChart.es.js";
2
+ import { useContainerDimensions as w } from "../../hooks/useContainerDimensions.es.js";
3
+ import { CustomDoubleBarPlotMXUI as I } from "./CustomDoubleBar.es.js";
4
+ import { Legend as A } from "./ChartLegend.es.js";
5
+ import B from "react";
6
+ import R from "@mui/material/Stack";
7
+ import { jsx as o, jsxs as d } from "react/jsx-runtime";
8
+ import L from "@mui/material/Box";
9
+ import { BarPlot as T } from "@mui/x-charts/BarChart";
10
+ import { ChartContainer as D } from "@mui/x-charts/ChartContainer";
11
+ import { ChartsXAxis as K } from "@mui/x-charts/ChartsXAxis";
12
+ var _ = ({ bars: r, colors: a, legends: h, isMini: p = !1, legendPosition: n = "bottom", selectedIndex: f, onBarClick: x }) => {
13
+ const l = f ?? r.length - 1, y = 5e-3, b = 0.16, s = B.useRef(null), { height: g, width: u } = w(s), C = ({ dataIndex: e, seriesId: t }) => {
14
+ x(e, Number(t.split("-").pop()));
15
+ }, m = h?.map((e, t) => ({
16
+ color: a[t] ?? "transparent",
17
17
  ...e
18
- }));
19
- return r.length > 0 ? /* @__PURE__ */ c(I, {
18
+ })), c = !!m?.length && /* @__PURE__ */ o(A, {
19
+ legendItems: m,
20
+ legendStyle: { ml: 24 }
21
+ });
22
+ return r.length > 0 ? /* @__PURE__ */ d(R, {
20
23
  sx: {
21
24
  mb: 0,
22
25
  width: "100%",
23
26
  p: 0
24
27
  },
25
- children: [/* @__PURE__ */ o(A, {
26
- ref: m,
27
- sx: {
28
- height: l ? 120 : 172,
29
- touchAction: "pan-y",
30
- width: "100%",
31
- p: 0,
32
- m: 0,
33
- "& svg": {
28
+ children: [
29
+ n === "top" && c,
30
+ /* @__PURE__ */ o(L, {
31
+ ref: s,
32
+ sx: {
33
+ height: p ? 120 : 172,
34
34
  touchAction: "pan-y",
35
- userSelect: "none"
36
- }
37
- },
38
- children: /* @__PURE__ */ c(R, {
39
- colors: n,
40
- dataset: r,
41
- height: x,
42
- margin: {
43
- bottom: 16,
44
- left: 24,
45
- right: 24,
46
- top: 0
47
- },
48
- series: [{
49
- dataKey: "main",
50
- type: "bar"
51
- }, {
52
- dataKey: "comparison",
53
- type: "bar"
54
- }],
55
- width: y,
56
- xAxis: [{
57
- barGapRatio: p,
58
- categoryGapRatio: f,
59
- dataKey: "label",
60
- scaleType: "band"
61
- }],
62
- yAxis: [{ width: 0 }],
63
- children: [/* @__PURE__ */ o(L, {
64
- disableTicks: !1,
65
- slots: { axisTickLabel: ({ text: e, ...t }) => {
66
- const a = r[s]?.label;
67
- return /* @__PURE__ */ o("text", {
68
- ...t,
69
- style: {
70
- ...t.style,
71
- fontWeight: a === e ? 700 : 400
72
- },
73
- children: e
74
- });
75
- } },
76
- sx: { ".MuiChartsAxis-line": { stroke: "border.darker" } },
77
- tickLabelStyle: {
78
- fontSize: 11,
79
- fill: "text.secondary",
80
- fontWeight: 400
35
+ width: "100%",
36
+ p: 0,
37
+ m: 0,
38
+ "& svg": {
39
+ touchAction: "pan-y",
40
+ userSelect: "none"
81
41
  }
82
- }), /* @__PURE__ */ o(B, {
83
- onItemClick: (e, { dataIndex: t, seriesId: a }) => g({
84
- dataIndex: t,
85
- seriesId: a.toString()
86
- }),
87
- slots: { bar: (e) => {
88
- const { ownerState: t, ...a } = e, b = s === t.dataIndex ? t.color : `${t.color}50`;
89
- return /* @__PURE__ */ o(k, {
90
- ...a,
91
- color: b,
92
- data: r,
93
- series: {
94
- index: t.dataIndex,
95
- type: Number(t.id?.toString().split("-").pop() ?? 0)
96
- },
97
- style: {
98
- height: e.height,
99
- x: e.x,
100
- y: e.y,
101
- width: e.width
102
- }
103
- });
104
- } }
105
- })]
106
- })
107
- }), i && !l && i.length > 0 && /* @__PURE__ */ o(S, {
108
- legendItems: i,
109
- legendStyle: { ml: 24 }
110
- })]
111
- }) : /* @__PURE__ */ o(u, {});
42
+ },
43
+ children: /* @__PURE__ */ d(D, {
44
+ colors: a,
45
+ dataset: r,
46
+ height: g,
47
+ margin: {
48
+ bottom: 16,
49
+ left: 24,
50
+ right: 24,
51
+ top: 0
52
+ },
53
+ series: [{
54
+ dataKey: "main",
55
+ type: "bar"
56
+ }, {
57
+ dataKey: "comparison",
58
+ type: "bar"
59
+ }],
60
+ width: u,
61
+ xAxis: [{
62
+ barGapRatio: y,
63
+ categoryGapRatio: b,
64
+ dataKey: "label",
65
+ scaleType: "band"
66
+ }],
67
+ yAxis: [{ width: 0 }],
68
+ children: [/* @__PURE__ */ o(K, {
69
+ disableTicks: !1,
70
+ slots: { axisTickLabel: ({ text: e, ...t }) => {
71
+ const i = r[l]?.label;
72
+ return /* @__PURE__ */ o("text", {
73
+ ...t,
74
+ style: {
75
+ ...t.style,
76
+ fontWeight: i === e ? 700 : 400
77
+ },
78
+ children: e
79
+ });
80
+ } },
81
+ sx: { ".MuiChartsAxis-line": { stroke: "border.darker" } },
82
+ tickLabelStyle: {
83
+ fontSize: 11,
84
+ fill: "text.secondary",
85
+ fontWeight: 400
86
+ }
87
+ }), /* @__PURE__ */ o(T, {
88
+ onItemClick: (e, { dataIndex: t, seriesId: i }) => C({
89
+ dataIndex: t,
90
+ seriesId: i.toString()
91
+ }),
92
+ slots: { bar: (e) => {
93
+ const { ownerState: t, ...i } = e, k = l === t.dataIndex ? t.color : `${t.color}50`;
94
+ return /* @__PURE__ */ o(I, {
95
+ ...i,
96
+ color: k,
97
+ data: r,
98
+ series: {
99
+ index: t.dataIndex,
100
+ type: Number(t.id?.toString().split("-").pop() ?? 0)
101
+ },
102
+ style: {
103
+ height: e.height,
104
+ x: e.x,
105
+ y: e.y,
106
+ width: e.width
107
+ }
108
+ });
109
+ } }
110
+ })]
111
+ })
112
+ }),
113
+ n === "bottom" && c
114
+ ]
115
+ }) : /* @__PURE__ */ o(S, {});
112
116
  };
113
117
  export {
114
- E as DoubleBarChart
118
+ _ as DoubleBarChart
115
119
  };
116
120
 
117
121
  //# sourceMappingURL=DoubleBarChart.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DoubleBarChart.es.js","names":[],"sources":["../../../../src/insights-v2/components/chartblocks/DoubleBarChart.tsx"],"sourcesContent":["import React from 'react'\n\nimport Box from '@mui/material/Box'\nimport Stack from '@mui/material/Stack'\n\nimport { BarPlot } from '@mui/x-charts/BarChart'\nimport { ChartContainer } from '@mui/x-charts/ChartContainer'\nimport { ChartsXAxis } from '@mui/x-charts/ChartsXAxis'\n\nimport { useContainerDimensions } from '../../hooks/useContainerDimensions'\nimport type { Legends } from '../../../core'\nimport type { DataSet, LegendProps } from '../../../core/types/InsightsInstanceSlotData'\n\nimport { CustomDoubleBarPlotMXUI } from './CustomDoubleBar'\nimport { Legend } from './ChartLegend'\nimport { EmptyBarChart } from './EmptyBarChart'\n\ninterface DoubleBarChartProps {\n // Shaped comparison series (one entry per month column), built by the caller (buildComparisonSeries)\n // \\u2014 mirroring how BarchartBlock builds `data` for BarChartV2.\n bars: DataSet[]\n // Two-entry palette [main, comparison]. Resolved by the caller (the card via getLayoutConfig). This\n // prop is the only color hook \\u2014 getLayoutConfig itself is never modified.\n colors: string[]\n // Same shape as instance_slot_data.legends; mapped onto the palette below.\n legends?: (Legends | LegendProps)[]\n isMini?: boolean\n // Called on a bar click with the clicked column and its sub-series (0 = main, 1 = comparison); the\n // caller decides what a click does (card opens the drawer, drill-down updates its selection).\n onBarClick: (columnIndex: number, subIndex: number) => void\n}\n\n/**\n * Pure double-bar chart (month columns x main/comparison). Presentational and self-contained \\u2014 it\n * receives shaped data + palette as props and reports clicks via onBarClick, holding no store,\n * selection, or data-shaping of its own. This mirrors BarChartV2; the DoubleBarChartBlock card\n * wrapper builds the data and injects the store behavior, exactly as BarchartBlock wraps BarChartV2.\n */\nexport const DoubleBarChart = ({\n bars,\n colors,\n legends,\n isMini = false,\n onBarClick,\n}: DoubleBarChartProps) => {\n // The most recent (last) column is emphasized; the others are dimmed.\n const selectedTabIndex = bars.length - 1\n const barGapRatio = 0.005\n const categoryGapRatio = 0.16\n\n const containerRef = React.useRef<HTMLDivElement>(null)\n const { height, width } = useContainerDimensions(containerRef)\n\n const handleBarClick = ({ dataIndex, seriesId }: { dataIndex: number; seriesId: string }) => {\n const seriesType = Number(seriesId.split('-').pop())\n onBarClick(dataIndex, seriesType)\n }\n\n // colors can be empty for an unregistered variant (getLayoutConfig miss); fall back to transparent\n // so a swatch never renders as default-black.\n const legendItems = legends?.map((legend, index) => ({\n color: colors[index] ?? 'transparent',\n ...legend,\n })) as LegendProps[]\n\n return bars.length > 0 ? (\n <Stack sx={{ mb: 0, width: '100%', p: 0 }}>\n <Box\n ref={containerRef}\n sx={{\n height: isMini ? 120 : 172,\n touchAction: 'pan-y',\n width: '100%',\n p: 0,\n m: 0,\n '& svg': {\n touchAction: 'pan-y',\n userSelect: 'none',\n },\n }}\n >\n <ChartContainer\n colors={colors}\n dataset={bars as any[]}\n height={height}\n margin={{\n bottom: 16,\n left: 24,\n right: 24,\n top: 0,\n }}\n series={[\n { dataKey: 'main', type: 'bar' },\n { dataKey: 'comparison', type: 'bar' },\n ]}\n width={width}\n xAxis={[\n {\n barGapRatio,\n categoryGapRatio,\n dataKey: 'label',\n scaleType: 'band',\n },\n ]}\n yAxis={[{ width: 0 }]}\n >\n <ChartsXAxis\n disableTicks={false}\n slots={{\n axisTickLabel: ({ text, ...restProps }) => {\n const selectedLabel = bars[selectedTabIndex]?.label\n return (\n <text\n {...restProps}\n style={\n {\n ...restProps.style,\n fontWeight: selectedLabel === text ? 700 : 400,\n } as React.CSSProperties\n }\n >\n {text}\n </text>\n )\n },\n }}\n sx={{\n '.MuiChartsAxis-line': {\n stroke: 'border.darker',\n },\n }}\n tickLabelStyle={{\n fontSize: 11,\n fill: 'text.secondary',\n fontWeight: 400,\n }}\n />\n <BarPlot\n onItemClick={(_, { dataIndex, seriesId }) =>\n handleBarClick({ dataIndex, seriesId: seriesId.toString() })\n }\n slots={{\n bar: (props) => {\n const { ownerState, ...defaultProps } = props\n const isSelected = selectedTabIndex === ownerState.dataIndex\n const barColor = isSelected ? ownerState.color : `${ownerState.color}50`\n\n return (\n <CustomDoubleBarPlotMXUI\n {...defaultProps}\n color={barColor}\n data={bars}\n series={{\n index: ownerState.dataIndex,\n type: Number(ownerState.id?.toString().split('-').pop() ?? 0),\n }}\n style={{\n height: props.height,\n x: props.x,\n y: props.y,\n width: props.width,\n }}\n />\n )\n },\n }}\n />\n </ChartContainer>\n </Box>\n\n {legendItems && !isMini && legendItems.length > 0 && (\n <Legend legendItems={legendItems} legendStyle={{ ml: 24 }} />\n )}\n </Stack>\n ) : (\n <EmptyBarChart />\n )\n}\n"],"mappings":";;;;;;;;;;;AAsCA,IAAa,IAAA,CAAkB,EAC7B,MAAA,GACA,QAAA,GACA,SAAA,GACA,QAAA,IAAS,IACT,YAAA,EAAA,MACyB;AAEzB,QAAM,IAAmB,EAAK,SAAS,GACjC,IAAc,MACd,IAAmB,MAEnB,IAAe,EAAM,OAAuB,IAAI,GAChD,EAAE,QAAA,GAAQ,OAAA,EAAA,IAAU,EAAuB,CAAY,GAEvD,IAAA,CAAkB,EAAE,WAAA,GAAW,UAAA,EAAA,MAAwD;AAE3F,IAAA,EAAW,GADQ,OAAO,EAAS,MAAM,GAAG,EAAE,IAAI,CAC5B,CAAU;AAAA,EAClC,GAIM,IAAc,GAAS,IAAA,CAAK,GAAQ,OAAW;AAAA,IACnD,OAAO,EAAO,CAAA,KAAU;AAAA,IACxB,GAAG;AAAA,EACL,EAAE;AAEF,SAAO,EAAK,SAAS,IACnB,gBAAA,EAAC,GAAD;AAAA,IAAO,IAAI;AAAA,MAAE,IAAI;AAAA,MAAG,OAAO;AAAA,MAAQ,GAAG;AAAA,IAAE;AAAA,IAAxC,UAAA,CAC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A,GACD,gBAAA,EAAC,GAAD;AAAA,UACE,aAAA,CAAc,GAAG,EAAE,WAAA,GAAW,UAAA,EAAA,MAC5B,EAAe;AAAA,YAAE,WAAA;AAAA,YAAW,UAAU,EAAS,SAAS;AAAA,UAAE,CAAC;AAAA,UAE7D,OAAO,EACL,KAAA,CAAM,MAAU;AACd,kBAAM,EAAE,YAAA,GAAY,GAAG,EAAA,IAAiB,GAElC,IADa,MAAqB,EAAW,YACrB,EAAW,QAAQ,GAAG,EAAW,KAAA;AAE/D,mBACE,gBAAA,EAAC,GAAD;AAAA,cACE,GAAI;AAAA,cACJ,OAAO;AAAA,cACP,MAAM;AAAA,cACN,QAAQ;AAAA,gBACN,OAAO,EAAW;AAAA,gBAClB,MAAM,OAAO,EAAW,IAAI,SAAS,EAAE,MAAM,GAAG,EAAE,IAAI,KAAK,CAAC;AAAA,cAC9D;AAAA,cACA,OAAO;AAAA,gBACL,QAAQ,EAAM;AAAA,gBACd,GAAG,EAAM;AAAA,gBACT,GAAG,EAAM;AAAA,gBACT,OAAO,EAAM;AAAA,cACf;AAAA,YACD,CAAA;AAAA,UAEL,EACF;AAAA,QACD,CAAA,CACa;AAAA;IACb,CAAA,GAEJ,KAAe,CAAC,KAAU,EAAY,SAAS,KAC9C,gBAAA,EAAC,GAAD;AAAA,MAAqB,aAAA;AAAA,MAAa,aAAa,EAAE,IAAI,GAAG;AAAA,IAAI,CAAA,CAEzD;AAAA,EAEP,CAAA,IAAA,gBAAA,EAAC,GAAD,CAAgB,CAAA;AAEpB"}
1
+ {"version":3,"file":"DoubleBarChart.es.js","names":[],"sources":["../../../../src/insights-v2/components/chartblocks/DoubleBarChart.tsx"],"sourcesContent":["import React from 'react'\n\nimport Box from '@mui/material/Box'\nimport Stack from '@mui/material/Stack'\n\nimport { BarPlot } from '@mui/x-charts/BarChart'\nimport { ChartContainer } from '@mui/x-charts/ChartContainer'\nimport { ChartsXAxis } from '@mui/x-charts/ChartsXAxis'\n\nimport { useContainerDimensions } from '../../hooks/useContainerDimensions'\nimport type { Legends } from '../../../core'\nimport type { DataSet, LegendProps } from '../../../core/types/InsightsInstanceSlotData'\n\nimport { CustomDoubleBarPlotMXUI } from './CustomDoubleBar'\nimport { Legend } from './ChartLegend'\nimport { EmptyBarChart } from './EmptyBarChart'\n\ninterface DoubleBarChartProps {\n // Shaped comparison series (one entry per month column), built by the caller (buildComparisonSeries)\n // \\u2014 mirroring how BarchartBlock builds `data` for BarChartV2.\n bars: DataSet[]\n // Two-entry palette [main, comparison]. Resolved by the caller (the card via getLayoutConfig). This\n // prop is the only color hook \\u2014 getLayoutConfig itself is never modified.\n colors: string[]\n // Legend items (toLegendItems over the block's additional_data); mapped onto the palette below.\n legends?: Legends[]\n isMini?: boolean\n // Where the legend sits, as BarChartV2's prop of the same name: below the chart (card) by default,\n // above it in the drawer.\n legendPosition?: 'top' | 'bottom'\n // The emphasized column (the drawer's selected month); defaults to the most recent (last) column.\n selectedIndex?: number\n // Called on a bar click with the clicked column and its sub-series (0 = main, 1 = comparison); the\n // caller decides what a click does (card opens the drawer, drill-down updates its selection).\n onBarClick: (columnIndex: number, subIndex: number) => void\n}\n\n/**\n * Pure double-bar chart (month columns x main/comparison). Presentational and self-contained \\u2014 it\n * receives shaped data + palette as props and reports clicks via onBarClick, holding no store,\n * selection, or data-shaping of its own. This mirrors BarChartV2; the DoubleBarChartBlock card\n * wrapper builds the data and injects the store behavior, exactly as BarchartBlock wraps BarChartV2.\n */\nexport const DoubleBarChart = ({\n bars,\n colors,\n legends,\n isMini = false,\n legendPosition = 'bottom',\n selectedIndex,\n onBarClick,\n}: DoubleBarChartProps) => {\n // The selected column (default: the most recent, last) is emphasized; the others are dimmed.\n const selectedTabIndex = selectedIndex ?? bars.length - 1\n const barGapRatio = 0.005\n const categoryGapRatio = 0.16\n\n const containerRef = React.useRef<HTMLDivElement>(null)\n const { height, width } = useContainerDimensions(containerRef)\n\n const handleBarClick = ({ dataIndex, seriesId }: { dataIndex: number; seriesId: string }) => {\n const seriesType = Number(seriesId.split('-').pop())\n onBarClick(dataIndex, seriesType)\n }\n\n // colors can be empty for an unregistered variant (getLayoutConfig miss); fall back to transparent\n // so a swatch never renders as default-black.\n const legendItems = legends?.map((legend, index) => ({\n color: colors[index] ?? 'transparent',\n ...legend,\n })) as LegendProps[]\n\n const legend = !!legendItems?.length && (\n <Legend legendItems={legendItems} legendStyle={{ ml: 24 }} />\n )\n\n return bars.length > 0 ? (\n <Stack sx={{ mb: 0, width: '100%', p: 0 }}>\n {legendPosition === 'top' && legend}\n <Box\n ref={containerRef}\n sx={{\n height: isMini ? 120 : 172,\n touchAction: 'pan-y',\n width: '100%',\n p: 0,\n m: 0,\n '& svg': {\n touchAction: 'pan-y',\n userSelect: 'none',\n },\n }}\n >\n <ChartContainer\n colors={colors}\n dataset={bars as any[]}\n height={height}\n margin={{\n bottom: 16,\n left: 24,\n right: 24,\n top: 0,\n }}\n series={[\n { dataKey: 'main', type: 'bar' },\n { dataKey: 'comparison', type: 'bar' },\n ]}\n width={width}\n xAxis={[\n {\n barGapRatio,\n categoryGapRatio,\n dataKey: 'label',\n scaleType: 'band',\n },\n ]}\n yAxis={[{ width: 0 }]}\n >\n <ChartsXAxis\n disableTicks={false}\n slots={{\n axisTickLabel: ({ text, ...restProps }) => {\n const selectedLabel = bars[selectedTabIndex]?.label\n return (\n <text\n {...restProps}\n style={\n {\n ...restProps.style,\n fontWeight: selectedLabel === text ? 700 : 400,\n } as React.CSSProperties\n }\n >\n {text}\n </text>\n )\n },\n }}\n sx={{\n '.MuiChartsAxis-line': {\n stroke: 'border.darker',\n },\n }}\n tickLabelStyle={{\n fontSize: 11,\n fill: 'text.secondary',\n fontWeight: 400,\n }}\n />\n <BarPlot\n onItemClick={(_, { dataIndex, seriesId }) =>\n handleBarClick({ dataIndex, seriesId: seriesId.toString() })\n }\n slots={{\n bar: (props) => {\n const { ownerState, ...defaultProps } = props\n const isSelected = selectedTabIndex === ownerState.dataIndex\n const barColor = isSelected ? ownerState.color : `${ownerState.color}50`\n\n return (\n <CustomDoubleBarPlotMXUI\n {...defaultProps}\n color={barColor}\n data={bars}\n series={{\n index: ownerState.dataIndex,\n type: Number(ownerState.id?.toString().split('-').pop() ?? 0),\n }}\n style={{\n height: props.height,\n x: props.x,\n y: props.y,\n width: props.width,\n }}\n />\n )\n },\n }}\n />\n </ChartContainer>\n </Box>\n\n {legendPosition === 'bottom' && legend}\n </Stack>\n ) : (\n <EmptyBarChart />\n )\n}\n"],"mappings":";;;;;;;;;;;AA2CA,IAAa,IAAA,CAAkB,EAC7B,MAAA,GACA,QAAA,GACA,SAAA,GACA,QAAA,IAAS,IACT,gBAAA,IAAiB,UACjB,eAAA,GACA,YAAA,EAAA,MACyB;AAEzB,QAAM,IAAmB,KAAiB,EAAK,SAAS,GAClD,IAAc,MACd,IAAmB,MAEnB,IAAe,EAAM,OAAuB,IAAI,GAChD,EAAE,QAAA,GAAQ,OAAA,EAAA,IAAU,EAAuB,CAAY,GAEvD,IAAA,CAAkB,EAAE,WAAA,GAAW,UAAA,EAAA,MAAwD;AAE3F,IAAA,EAAW,GADQ,OAAO,EAAS,MAAM,GAAG,EAAE,IAAI,CAC5B,CAAU;AAAA,EAClC,GAIM,IAAc,GAAS,IAAA,CAAK,GAAQ,OAAW;AAAA,IACnD,OAAO,EAAO,CAAA,KAAU;AAAA,IACxB,GAAG;AAAA,EACL,EAAE,GAEI,IAAS,CAAC,CAAC,GAAa,UAC5B,gBAAA,EAAC,GAAD;AAAA,IAAqB,aAAA;AAAA,IAAa,aAAa,EAAE,IAAI,GAAG;AAAA,EAAI,CAAA;AAG9D,SAAO,EAAK,SAAS,IACnB,gBAAA,EAAC,GAAD;AAAA,IAAO,IAAI;AAAA,MAAE,IAAI;AAAA,MAAG,OAAO;AAAA,MAAQ,GAAG;AAAA,IAAE;AAAA,IAAxC,UAAA;AAAA,MACG,MAAmB,SAAS;AAAA,MAC7B,gBAAA,EAAC,GAAD;AAAA,QACE,KAAK;AAAA,QACL,IA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c,GAAG,EAAE,WAAA,GAAW,UAAA,EAAA,MAC5B,EAAe;AAAA,cAAE,WAAA;AAAA,cAAW,UAAU,EAAS,SAAS;AAAA,YAAE,CAAC;AAAA,YAE7D,OAAO,EACL,KAAA,CAAM,MAAU;AACd,oBAAM,EAAE,YAAA,GAAY,GAAG,EAAA,IAAiB,GAElC,IADa,MAAqB,EAAW,YACrB,EAAW,QAAQ,GAAG,EAAW,KAAA;AAE/D,qBACE,gBAAA,EAAC,GAAD;AAAA,gBACE,GAAI;AAAA,gBACJ,OAAO;AAAA,gBACP,MAAM;AAAA,gBACN,QAAQ;AAAA,kBACN,OAAO,EAAW;AAAA,kBAClB,MAAM,OAAO,EAAW,IAAI,SAAS,EAAE,MAAM,GAAG,EAAE,IAAI,KAAK,CAAC;AAAA,gBAC9D;AAAA,gBACA,OAAO;AAAA,kBACL,QAAQ,EAAM;AAAA,kBACd,GAAG,EAAM;AAAA,kBACT,GAAG,EAAM;AAAA,kBACT,OAAO,EAAM;AAAA,gBACf;AAAA,cACD,CAAA;AAAA,YAEL,EACF;AAAA,UACD,CAAA,CACa;AAAA;MACb,CAAA;AAAA,MAEJ,MAAmB,YAAY;AAAA,IAC3B;AAAA,EAEP,CAAA,IAAA,gBAAA,EAAC,GAAD,CAAgB,CAAA;AAEpB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mx-cartographer/experiences",
3
- "version": "9.7.42",
3
+ "version": "9.7.43",
4
4
  "description": "Library containing experience widgets",
5
5
  "author": "MX",
6
6
  "license": "MIT",