@mx-cartographer/experiences 8.1.10 → 8.1.11

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/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [8.1.11] - 05-05-2026
2
+
3
+ - **FIXED** - Spending chart crash on chart color index overflow
4
+
1
5
  ## [8.1.10] - 05-05-2026
2
6
 
3
7
  - **UPDATED** - Error component UI and no network fallback
@@ -13,72 +13,72 @@ import { u as R } from "./useAriaLive-MkYebyUR.mjs";
13
13
  import { u as v } from "./hooks-RzCoiTd0.mjs";
14
14
  import { u as V } from "./useScreenSize-CeFhWTt_.mjs";
15
15
  import { f as b } from "./NumberFormatting-CyrvFgfd.mjs";
16
- const D = 5, B = (i, l, g, m) => m.reduce((o, n) => {
17
- const a = i.find((s) => s.guid === n.category_guid);
18
- if (!a) return o;
19
- const t = a.parent_guid ?? a.guid, r = i.find((s) => s.guid === t);
20
- if (!r || n.total <= 0) return o;
16
+ const D = 5, B = (i, l, s, m) => m.reduce((o, n) => {
17
+ const r = i.find((u) => u.guid === n.category_guid);
18
+ if (!r) return o;
19
+ const t = r.parent_guid ?? r.guid, a = i.find((u) => u.guid === t);
20
+ if (!a || n.total <= 0) return o;
21
21
  const c = {
22
- guid: a.guid,
23
- name: a.guid === t ? `${l.parent_category_totals_label_general} ${a.name}` : a.name,
24
- color: _(r.guid, g),
22
+ guid: r.guid,
23
+ name: r.guid === t ? `${l.parent_category_totals_label_general} ${r.name}` : r.name,
24
+ color: _(a.guid, s),
25
25
  amount: n.total
26
- }, e = o.find((s) => s.guid === t);
26
+ }, e = o.find((u) => u.guid === t);
27
27
  return e ? (e.amount += n.total, e.categoryTotals?.push(c)) : o.push({
28
28
  guid: t,
29
- name: r.name,
30
- color: _(r.guid, g),
29
+ name: a.name,
30
+ color: _(a.guid, s),
31
31
  categoryTotals: [c],
32
32
  amount: n.total
33
33
  }), o;
34
- }, []), nt = (i, l, g, m) => {
35
- const n = B(i, l, g, m).filter(
34
+ }, []), nt = (i, l, s, m) => {
35
+ const n = B(i, l, s, m).filter(
36
36
  (e) => e.guid !== p.INCOME && e.guid !== p.INVESTMENTS && e.guid !== p.TRANSFER && e.amount > 0
37
- ).sort((e, s) => s.amount - e.amount), a = n.reduce(
38
- (e, s) => e + s.amount,
37
+ ).sort((e, u) => u.amount - e.amount), r = n.reduce(
38
+ (e, u) => e + u.amount,
39
39
  0
40
- ), t = n.length > D ? D : n.length, r = n.slice(0, t), c = r.map((e) => ({
40
+ ), t = n.length > D ? D : n.length, a = n.slice(0, t), c = a.map((e) => ({
41
41
  id: e.guid,
42
- color: _(e.guid, g),
42
+ color: _(e.guid, s),
43
43
  label: e.name,
44
- value: e.amount / a * 100
44
+ value: e.amount / r * 100
45
45
  }));
46
46
  if (n.length > 5) {
47
- const e = n.slice(D), s = e.reduce(
48
- (C, u) => C + u.amount,
47
+ const e = n.slice(D), u = e.reduce(
48
+ (C, g) => C + g.amount,
49
49
  0
50
50
  );
51
- r.push({
51
+ a.push({
52
52
  guid: "other",
53
- color: g.palette.categories.others || "",
53
+ color: s.palette.categories.others || "",
54
54
  name: l.saving_goal_other,
55
55
  categoryTotals: e,
56
- amount: s
56
+ amount: u
57
57
  }), c.push({
58
58
  id: "other",
59
- color: g.palette.categories.others || "",
59
+ color: s.palette.categories.others || "",
60
60
  label: l.saving_goal_other,
61
- value: s / a * 100
61
+ value: u / r * 100
62
62
  });
63
63
  }
64
64
  return {
65
- categoryData: r,
65
+ categoryData: a,
66
66
  donutData: c,
67
- totalAmount: a
67
+ totalAmount: r
68
68
  };
69
- }, et = (i, l, g) => {
69
+ }, et = (i, l, s) => {
70
70
  const m = i.filter(
71
71
  (t) => t.guid === p.INCOME || t.parent_guid === p.INCOME
72
- ), o = l.filter((t) => m.some((r) => r.guid === t.category_guid)).sort((t, r) => t.total - r.total).map((t, r) => ({
72
+ ), o = l.filter((t) => m.some((a) => a.guid === t.category_guid)).sort((t, a) => t.total - a.total).map((t, a) => ({
73
73
  guid: t.category_guid,
74
74
  name: i.find((c) => c.guid === t.category_guid)?.name,
75
- color: g[r],
75
+ color: s[a % s.length],
76
76
  categoryTotals: [],
77
77
  amount: Math.abs(t.total)
78
78
  })), n = o.reduce(
79
- (t, r) => t + r.amount,
79
+ (t, a) => t + a.amount,
80
80
  0
81
- ), a = o.map((t) => ({
81
+ ), r = o.map((t) => ({
82
82
  id: t.guid,
83
83
  color: t.color,
84
84
  label: t.name,
@@ -86,36 +86,36 @@ const D = 5, B = (i, l, g, m) => m.reduce((o, n) => {
86
86
  }));
87
87
  return {
88
88
  categoryData: o,
89
- donutData: a,
89
+ donutData: r,
90
90
  totalAmount: n
91
91
  };
92
92
  }, P = ({
93
93
  data: i,
94
94
  isIncome: l = !1,
95
- onSelected: g,
95
+ onSelected: s,
96
96
  onViewTransactions: m,
97
97
  selectedId: o,
98
98
  size: n = 150,
99
- totalLabel: a,
99
+ totalLabel: r,
100
100
  variant: t = "mini"
101
101
  }) => {
102
- const { spending: r } = v(), c = M(), { isTablet: e } = V(), { announce: s, ariaLive: C } = R(), u = T.useMemo(
102
+ const { spending: a } = v(), c = M(), { isTablet: e } = V(), { announce: u, ariaLive: C } = R(), g = T.useMemo(
103
103
  () => o ? i.categoryData.find((x) => x.guid === o) : void 0,
104
104
  [o]
105
105
  );
106
106
  T.useEffect(() => {
107
- if (u) {
108
- const x = b(u.amount, t === "mini" ? "0,0" : "0,0.00");
109
- s(`${u.name}: ${x}`);
107
+ if (g) {
108
+ const x = b(g.amount, t === "mini" ? "0,0" : "0,0.00");
109
+ u(`${g.name}: ${x}`);
110
110
  }
111
- }, [u, s, t]);
111
+ }, [g, u, t]);
112
112
  const E = i.donutData.length > 0 ? i.donutData : [{ id: "0", color: c.palette.divider, value: 100 }], I = () => {
113
113
  m?.(o);
114
114
  }, w = e ? 32 : 48;
115
115
  return /* @__PURE__ */ f(N, { children: [
116
116
  C,
117
- /* @__PURE__ */ d(j, { data: E, onClick: g, selectedId: o, size: n, children: /* @__PURE__ */ d(h, { alignItems: "center", height: "100%", justifyContent: "center", width: "100%", children: /* @__PURE__ */ f(h, { alignItems: "center", justifyContent: "center", minHeight: n, minWidth: n, children: [
118
- u && /* @__PURE__ */ f(
117
+ /* @__PURE__ */ d(j, { data: E, onClick: s, selectedId: o, size: n, children: /* @__PURE__ */ d(h, { alignItems: "center", height: "100%", justifyContent: "center", width: "100%", children: /* @__PURE__ */ f(h, { alignItems: "center", justifyContent: "center", minHeight: n, minWidth: n, children: [
118
+ g && /* @__PURE__ */ f(
119
119
  h,
120
120
  {
121
121
  alignItems: "center",
@@ -127,7 +127,7 @@ const D = 5, B = (i, l, g, m) => m.reduce((o, n) => {
127
127
  /* @__PURE__ */ d(S, { "aria-hidden": "true", role: "presentation", children: /* @__PURE__ */ d(
128
128
  G,
129
129
  {
130
- categoryGuid: l ? p.INCOME : u.guid,
130
+ categoryGuid: l ? p.INCOME : g.guid,
131
131
  size: t === "mini" ? 24 : w,
132
132
  variant: O.Transparent
133
133
  }
@@ -138,29 +138,29 @@ const D = 5, B = (i, l, g, m) => m.reduce((o, n) => {
138
138
  color: "text.secondary",
139
139
  noWrap: !0,
140
140
  variant: t === "mini" ? "tiny" : "body1",
141
- children: u ? u.name : a
141
+ children: g ? g.name : r
142
142
  }
143
143
  )
144
144
  ]
145
145
  }
146
146
  ),
147
- !u && t === "full" && /* @__PURE__ */ d(y, { bold: !0, color: "text.secondary", sx: { mb: { xs: 4, xl: 8 } }, children: a }),
148
- /* @__PURE__ */ d($, { variant: t === "mini" ? "h2" : "h1", children: u ? b(u.amount, t === "mini" ? "0,0" : "0,0.00") : b(i.totalAmount, t === "mini" ? "0,0" : "0,0.00") }),
149
- !u && t === "mini" && /* @__PURE__ */ d(y, { color: "text.secondary", noWrap: !0, variant: "tiny", children: a }),
147
+ !g && t === "full" && /* @__PURE__ */ d(y, { bold: !0, color: "text.secondary", sx: { mb: { xs: 4, xl: 8 } }, children: r }),
148
+ /* @__PURE__ */ d($, { variant: t === "mini" ? "h2" : "h1", children: g ? b(g.amount, t === "mini" ? "0,0" : "0,0.00") : b(i.totalAmount, t === "mini" ? "0,0" : "0,0.00") }),
149
+ !g && t === "mini" && /* @__PURE__ */ d(y, { color: "text.secondary", noWrap: !0, variant: "tiny", children: r }),
150
150
  t === "full" && /* @__PURE__ */ d(
151
151
  A,
152
152
  {
153
- "aria-label": `View ${u?.name || ""} Transactions`,
153
+ "aria-label": `View ${g?.name || ""} Transactions`,
154
154
  disabled: i.categoryData.length === 0,
155
155
  onClick: I,
156
156
  sx: { mt: { xl: 4, xs: 0 }, zIndex: 1 },
157
157
  variant: "text",
158
- children: r.view_transactions
158
+ children: a.view_transactions
159
159
  }
160
160
  )
161
161
  ] }) }) })
162
162
  ] });
163
- }, rt = k(P), at = ({ data: i, onSelected: l, selectedId: g }) => {
163
+ }, at = k(P), rt = ({ data: i, onSelected: l, selectedId: s }) => {
164
164
  const m = (o, n) => {
165
165
  (o.key === "Enter" || o.key === " ") && (o.preventDefault(), l(n));
166
166
  };
@@ -169,7 +169,7 @@ const D = 5, B = (i, l, g, m) => m.reduce((o, n) => {
169
169
  {
170
170
  alignItems: "center",
171
171
  "aria-label": o.name,
172
- "aria-pressed": o.guid === g,
172
+ "aria-pressed": o.guid === s,
173
173
  direction: "row",
174
174
  gap: 8,
175
175
  onClick: () => l(o.guid),
@@ -179,15 +179,15 @@ const D = 5, B = (i, l, g, m) => m.reduce((o, n) => {
179
179
  tabIndex: 0,
180
180
  children: [
181
181
  /* @__PURE__ */ d(S, { borderRadius: 4, height: 8, sx: { backgroundColor: o.color }, width: 8 }),
182
- /* @__PURE__ */ d(y, { bold: o.guid === g, variant: "caption", children: o.name })
182
+ /* @__PURE__ */ d(y, { bold: o.guid === s, variant: "caption", children: o.name })
183
183
  ]
184
184
  },
185
185
  o.guid
186
186
  )) });
187
187
  };
188
188
  export {
189
- rt as S,
189
+ at as S,
190
190
  et as a,
191
- at as b,
191
+ rt as b,
192
192
  nt as g
193
193
  };
@@ -51,7 +51,7 @@ import { ChartsXAxis as Zn } from "@mui/x-charts/ChartsXAxis";
51
51
  import { ChartsYAxis as Jn } from "@mui/x-charts/ChartsYAxis";
52
52
  import { startOfMonth as Dt } from "date-fns/startOfMonth";
53
53
  import { endOfMonth as It } from "date-fns/endOfMonth";
54
- import { g as eo, S as to, b as no } from "../SpendingLegend-DLElSvH0.mjs";
54
+ import { g as eo, S as to, b as no } from "../SpendingLegend-BS8mHUbu.mjs";
55
55
  import { formatISO as oo } from "date-fns/formatISO";
56
56
  import { fromUnixTime as ro } from "date-fns/fromUnixTime";
57
57
  import { startOfToday as st } from "date-fns/startOfToday";
@@ -8,7 +8,7 @@ import y from "@mui/material/Stack";
8
8
  import O from "@mui/material/Tab";
9
9
  import it from "@mui/material/Tabs";
10
10
  import _t from "@mui/material/styles/useTheme";
11
- import { g as rt, a as st, S as k, b as Y } from "../SpendingLegend-DLElSvH0.mjs";
11
+ import { g as rt, a as st, S as k, b as Y } from "../SpendingLegend-BS8mHUbu.mjs";
12
12
  import { Text as T, Icon as bt } from "@mxenabled/mxui";
13
13
  import { f as N } from "../NumberFormatting-CyrvFgfd.mjs";
14
14
  import { u as A, l as W, d as lt, b as z, a as V, h as ct, g as yt } from "../hooks-RzCoiTd0.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mx-cartographer/experiences",
3
- "version": "8.1.10",
3
+ "version": "8.1.11",
4
4
  "description": "Library containing experience widgets",
5
5
  "author": "MX",
6
6
  "license": "MIT",