@mx-cartographer/experiences 7.4.15 → 7.5.0-alpha.bb1

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.
@@ -14,6 +14,7 @@ export interface StackedLineChartData {
14
14
  }
15
15
  export declare const getStackedLineChartData: (totals: MonthlyCategoryTotals[], start: Date, end: Date) => StackedLineChartData[];
16
16
  export declare const amountComparator: GridComparatorFn<string | number>;
17
+ export declare const categoryComparator: GridComparatorFn<string | number>;
17
18
  export declare const buildCategoryDetailsChartData: (data: DetailedCategoryWithTransactions | null, monthsCount: number) => {
18
19
  monthlyAmounts: {
19
20
  x: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mx-cartographer/experiences",
3
- "version": "7.4.15",
3
+ "version": "7.5.0-alpha.bb1",
4
4
  "description": "Library containing experience widgets",
5
5
  "author": "MX",
6
6
  "license": "MIT",
@@ -1,55 +0,0 @@
1
- import { addMonths as u } from "date-fns/addMonths";
2
- import { isBefore as d } from "date-fns/isBefore";
3
- import { startOfMonth as _ } from "date-fns/startOfMonth";
4
- import { subMonths as y } from "date-fns/subMonths";
5
- import { endOfMonth as M } from "date-fns/endOfMonth";
6
- import { b as n, P as l } from "./Category-CevNQ03n.mjs";
7
- import { f as m, a as T } from "./Dialog-BPTr3qHE.mjs";
8
- const i = (e) => (e.top_level_category_guid === n.INCOME || e.category_guid === n.INCOME) && !h(e), C = (e) => !i(e) && !f(e), p = (e) => l.includes(e.top_level_category_guid) || l.includes(e.category_guid), f = (e) => e.top_level_category_guid === n.TRANSFER || e.category_guid === n.TRANSFER, h = (e) => e.top_level_category_guid === n.INVESTMENTS || e.category_guid === n.INVESTMENTS, N = (e) => !i(e) && !p(e) && !f(e) && !h(e), w = (e) => e.filter((r) => r.category_guid === r.top_level_category_guid), F = (e, r) => {
9
- if (r === 0) return 0;
10
- const a = (e - r) / r;
11
- return isNaN(a) ? 0 : a;
12
- }, g = (e, r) => {
13
- const a = [];
14
- let t = _(r?.start ?? y(/* @__PURE__ */ new Date(), 5));
15
- const s = r?.end ?? /* @__PURE__ */ new Date();
16
- for (; d(t, s); )
17
- a.push({
18
- x: m(t, T.MONTH_SHORT),
19
- y: e.filter((o) => o.year === t.getFullYear() && o.month === t.getMonth() + 1).reduce((o, c) => o + c.total, 0)
20
- }), t = u(t, 1);
21
- return a;
22
- }, b = (e, r) => {
23
- const a = e.filter(i);
24
- return g(a, r).map((t) => ({ ...t, y: Math.abs(t.y) }));
25
- }, A = (e, r) => {
26
- const a = e.filter(p);
27
- return g(a, r).map((t) => ({ ...t, y: Math.abs(t.y) }));
28
- }, x = (e, r) => {
29
- const a = e.filter(N);
30
- return g(a, r);
31
- }, H = (e) => {
32
- const r = [], a = e.filter(
33
- (o) => o.top_level_category_guid !== n.INCOME && o.top_level_category_guid !== n.TRANSFER && o.total > 0
34
- );
35
- let t = _(y(/* @__PURE__ */ new Date(), 5));
36
- const s = M(/* @__PURE__ */ new Date());
37
- for (; d(t, s); )
38
- r.push({
39
- x: m(t, T.MONTH_SHORT),
40
- y: a.filter((o) => o.year === t.getFullYear() && o.month === t.getMonth() + 1).reduce((o, c) => o + c.total, 0)
41
- }), t = u(t, 1);
42
- return r;
43
- };
44
- export {
45
- A as a,
46
- x as b,
47
- f as c,
48
- w as d,
49
- C as e,
50
- i as f,
51
- b as g,
52
- H as h,
53
- h as i,
54
- F as j
55
- };
@@ -1,182 +0,0 @@
1
- import { jsxs as d, jsx as l } from "react/jsx-runtime";
2
- import x from "react";
3
- import S from "@mui/material/ListItem";
4
- import R from "@mui/material/ListItemButton";
5
- import f from "@mui/material/ListItemIcon";
6
- import A from "@mui/material/ListItemText";
7
- import h from "@mui/material/Stack";
8
- import { Text as y } from "@mxenabled/mxui";
9
- import { makeAutoObservable as N } from "mobx";
10
- import { addSeconds as v } from "date-fns/addSeconds";
11
- import { differenceInCalendarMonths as w } from "date-fns/differenceInCalendarMonths";
12
- import { endOfMonth as D } from "date-fns/endOfMonth";
13
- import { subMonths as I } from "date-fns/subMonths";
14
- import { b as E, C as _, c as O } from "./Category-CevNQ03n.mjs";
15
- import { f as L, a as T } from "./Dialog-BPTr3qHE.mjs";
16
- const at = ({
17
- onClick: e,
18
- leftIcon: t,
19
- rightIcon: o,
20
- title: r,
21
- subtitle: a,
22
- rightContent: n,
23
- titleBold: s = !0,
24
- rightContentBold: m = !0
25
- }) => {
26
- const c = /* @__PURE__ */ d(x.Fragment, { children: [
27
- t && /* @__PURE__ */ l(f, { sx: { ml: 0 }, children: t }),
28
- /* @__PURE__ */ l(A, { children: /* @__PURE__ */ d(
29
- h,
30
- {
31
- sx: {
32
- alignItems: "center",
33
- flexDirection: "row",
34
- marginLeft: 12
35
- },
36
- children: [
37
- /* @__PURE__ */ d(h, { sx: { flex: 1, minWidth: 0 }, children: [
38
- /* @__PURE__ */ l(y, { bold: s, variant: "body1", children: r }),
39
- a && /* @__PURE__ */ l(y, { variant: "caption", children: a })
40
- ] }),
41
- /* @__PURE__ */ d(h, { sx: { flexDirection: "row", alignItems: "center", gap: 1 }, children: [
42
- n && /* @__PURE__ */ l(y, { bold: m, display: "flex", variant: "body1", children: n }),
43
- o && /* @__PURE__ */ l(f, { children: o })
44
- ] })
45
- ]
46
- }
47
- ) })
48
- ] });
49
- return /* @__PURE__ */ l(S, { sx: { bgcolor: "background.paper" }, children: e ? /* @__PURE__ */ l(
50
- R,
51
- {
52
- onClick: e,
53
- sx: {
54
- py: 14
55
- },
56
- children: c
57
- }
58
- ) : /* @__PURE__ */ l(
59
- h,
60
- {
61
- sx: {
62
- py: 14,
63
- px: 24,
64
- width: "100%",
65
- flexDirection: "row",
66
- alignItems: "center"
67
- },
68
- children: c
69
- }
70
- ) });
71
- }, W = (e) => _[e] ?? _.default, F = (e) => O[e];
72
- function G(e, t) {
73
- const o = [], r = new Date(e);
74
- for (; r <= t; ) {
75
- const a = r.getFullYear(), n = String(r.getMonth() + 1).padStart(2, "0");
76
- o.push(+`${a}${n}`), r.setMonth(r.getMonth() + 1);
77
- }
78
- return o;
79
- }
80
- const $ = (e) => e.reduce((o, r) => {
81
- const a = {
82
- top_level_category_guid: r.top_level_category_guid,
83
- category_guid: r.category_guid,
84
- amount: r.total,
85
- year_month: r.year_month
86
- }, { top_level_category_guid: n, category_guid: s } = a;
87
- return o[s] || (o[s] = []), o[s].push(a), n !== s && (o[n] || (o[n] = []), o[n].push(a)), o;
88
- }, {}), nt = (e, t, o) => {
89
- const r = $(e), a = G(t, o);
90
- return Object.entries(r).map(([s, m]) => {
91
- const c = m[0].top_level_category_guid, b = a.map((i) => {
92
- const g = m.filter((p) => p.year_month === i).reduce((p, M) => p + Math.abs(M.amount), 0), u = Number(String(i).slice(0, 4)), C = Number(String(i).slice(4));
93
- return { x: new Date(u, C - 1), y: g };
94
- }).sort((i, g) => i.x.getTime() - g.x.getTime());
95
- return {
96
- top_level_category_guid: c,
97
- category_guid: s,
98
- category_name: F(s),
99
- category_color: W(c),
100
- dataset: b
101
- };
102
- });
103
- }, st = (e, t) => {
104
- const o = typeof e == "string" ? parseFloat(e.replace(/[^0-9.-]+/g, "")) : e, r = typeof t == "string" ? parseFloat(t.replace(/[^0-9.-]+/g, "")) : t;
105
- return (o || 0) - (r || 0);
106
- }, j = (e, t) => {
107
- const o = e.subCategories.filter((n) => n.currentAmount !== 0), r = e.totalMonthlyAmounts.slice(-t), a = (n) => n.substring(0, 3) + " " + n.slice(-4);
108
- return r.map((n) => {
109
- const s = a(n.label), m = o.map((i) => {
110
- const g = i.monthlyAmounts.slice(-t).find((u) => a(u.label) === s);
111
- return {
112
- label: i.name,
113
- amount: Math.abs(g?.amount || 0),
114
- header: s
115
- };
116
- }), c = e.monthlyAmounts.slice(-t).find((i) => a(i.label) === s);
117
- return [{
118
- label: e.name,
119
- amount: Math.abs(c?.amount || 0),
120
- header: s
121
- }, ...m].sort((i, g) => g.amount - i.amount);
122
- });
123
- }, k = (e, t) => {
124
- const o = e ? e.totalMonthlyAmounts.slice(-t).map((a) => ({
125
- x: a.label.substring(0, 3),
126
- y: Math.abs(a.amount)
127
- })) : [], r = e ? j(e, t) : [];
128
- return { monthlyAmounts: o, tooltipLabels: r };
129
- }, H = (e) => e.slice().filter(
130
- (t) => t.totalAmount !== 0 && t.isTransfer === !1 && t.guid !== E.INVESTMENTS
131
- ).sort((t, o) => Math.abs(o.totalAmount) - Math.abs(t.totalAmount));
132
- class it {
133
- globalStore;
134
- selectedCategoryData = null;
135
- selectedDateRange;
136
- visibleListLength = 5;
137
- constructor(t) {
138
- this.globalStore = t, this.selectedDateRange = {
139
- start: v(D(I(/* @__PURE__ */ new Date(), 6)), 1),
140
- end: D(/* @__PURE__ */ new Date())
141
- }, N(this);
142
- }
143
- setSelectedCategoryData = (t) => {
144
- this.selectedCategoryData = t;
145
- };
146
- setSelectedDateRange = (t) => {
147
- this.selectedDateRange = t;
148
- };
149
- setVisibleListLength = (t) => {
150
- this.visibleListLength = t;
151
- };
152
- get sortedDetailedCategoriesWithTransactions() {
153
- return H(
154
- this.globalStore.categoryStore.detailedCategoriesWithTransactions
155
- );
156
- }
157
- get selectedDateRangeMonthCount() {
158
- return w(this.selectedDateRange.end, this.selectedDateRange.start) + 1;
159
- }
160
- get selectedDateRangeMonthRange() {
161
- const t = L(this.selectedDateRange.start, T.MONTH_LONG), o = L(this.selectedDateRange.end, T.MONTH_LONG);
162
- return `${t} - ${o}`;
163
- }
164
- get visibleCategories() {
165
- return this.sortedDetailedCategoriesWithTransactions.slice(0, this.visibleListLength);
166
- }
167
- get collapsedCategories() {
168
- return this.sortedDetailedCategoriesWithTransactions.slice(this.visibleListLength);
169
- }
170
- get categoryDetailsChartData() {
171
- return k(
172
- this.selectedCategoryData,
173
- this.selectedDateRangeMonthCount
174
- );
175
- }
176
- }
177
- export {
178
- at as L,
179
- it as T,
180
- st as a,
181
- nt as g
182
- };