@mx-cartographer/experiences 9.7.25 → 9.7.26

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 (33) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/common/components/MiniWidgetContainer.es.js +35 -45
  3. package/dist/common/components/MiniWidgetContainer.es.js.map +1 -1
  4. package/dist/common/components/charts/LineChart.es.js +86 -85
  5. package/dist/common/components/charts/LineChart.es.js.map +1 -1
  6. package/dist/common/constants/Styles.d.ts +2 -0
  7. package/dist/common/constants/Styles.es.js +17 -0
  8. package/dist/common/constants/Styles.es.js.map +1 -0
  9. package/dist/common/constants/index.d.ts +1 -0
  10. package/dist/common/hooks/useAriaLive.es.js +12 -22
  11. package/dist/common/hooks/useAriaLive.es.js.map +1 -1
  12. package/dist/common/index.es.js +111 -109
  13. package/dist/core/stores/TrendsStore.d.ts +5 -0
  14. package/dist/core/utils/DateUtil.d.ts +2 -0
  15. package/dist/core/utils/DateUtil.es.js +37 -35
  16. package/dist/core/utils/DateUtil.es.js.map +1 -1
  17. package/dist/core/utils/NumberFormatting.d.ts +1 -0
  18. package/dist/core/utils/NumberFormatting.es.js +14 -13
  19. package/dist/core/utils/NumberFormatting.es.js.map +1 -1
  20. package/dist/core/utils/TrendsUtil.d.ts +5 -0
  21. package/dist/core/utils/TrendsUtil.es.js +67 -59
  22. package/dist/core/utils/TrendsUtil.es.js.map +1 -1
  23. package/dist/transactions/components/shared/TransactionList.d.ts +4 -0
  24. package/dist/transactions/components/shared/TransactionList.es.js +138 -84
  25. package/dist/transactions/components/shared/TransactionList.es.js.map +1 -1
  26. package/dist/trends/components/CategoryDetailChart.d.ts +2 -1
  27. package/dist/trends/components/CategoryDetailChart.es.js +55 -35
  28. package/dist/trends/components/CategoryDetailChart.es.js.map +1 -1
  29. package/dist/trends/components/CategoryDetails.es.js +68 -71
  30. package/dist/trends/components/CategoryDetails.es.js.map +1 -1
  31. package/dist/trends/utils/TrendsTable.es.js +25 -25
  32. package/dist/trends/utils/TrendsTable.es.js.map +1 -1
  33. package/package.json +1 -1
@@ -1,72 +1,80 @@
1
- import { CategoryColors as y, CategoryGuidToName as b, CategoryGuids as _ } from "../constants/Category.es.js";
2
- var d = (e) => y[e] ?? y.default, f = (e) => b[e];
3
- function C(e, t) {
4
- const o = [], a = new Date(e);
5
- for (; a <= t; ) {
6
- const n = a.getFullYear(), r = String(a.getMonth() + 1).padStart(2, "0");
7
- o.push(+`${n}${r}`), a.setMonth(a.getMonth() + 1);
1
+ import { CategoryColors as y, CategoryGuidToName as T, CategoryGuids as b } from "../constants/Category.es.js";
2
+ import { DATE_FORMATS_INTL as i } from "../constants/DateFormats.es.js";
3
+ import { formatIsoDate as p } from "./DateUtil.es.js";
4
+ import { roundedAverage as f } from "./NumberFormatting.es.js";
5
+ var C = (t) => y[t] ?? y.default, M = (t) => T[t];
6
+ function A(t, o) {
7
+ const r = [], e = new Date(t);
8
+ for (; e <= o; ) {
9
+ const n = e.getFullYear(), a = String(e.getMonth() + 1).padStart(2, "0");
10
+ r.push(+`${n}${a}`), e.setMonth(e.getMonth() + 1);
8
11
  }
9
- return o;
12
+ return r;
10
13
  }
11
- var M = (e) => e.reduce((t, o) => {
12
- const a = {
13
- top_level_category_guid: o.top_level_category_guid,
14
- category_guid: o.category_guid,
15
- amount: o.total,
16
- year_month: o.year_month
17
- }, { top_level_category_guid: n, category_guid: r } = a;
18
- return t[r] || (t[r] = []), t[r].push(a), n !== r && (t[n] || (t[n] = []), t[n].push(a)), t;
19
- }, {}), A = (e, t, o) => {
20
- const a = M(e), n = C(t, o);
21
- return Object.entries(a).map(([r, l]) => {
22
- const c = l[0].top_level_category_guid, i = n.map((s) => {
23
- const u = l.filter((m) => m.year_month === s).reduce((m, h) => m + Math.abs(h.amount), 0), g = Number(String(s).slice(0, 4)), p = Number(String(s).slice(4));
14
+ var v = (t) => t.reduce((o, r) => {
15
+ const e = {
16
+ top_level_category_guid: r.top_level_category_guid,
17
+ category_guid: r.category_guid,
18
+ amount: r.total,
19
+ year_month: r.year_month
20
+ }, { top_level_category_guid: n, category_guid: a } = e;
21
+ return o[a] || (o[a] = []), o[a].push(e), n !== a && (o[n] || (o[n] = []), o[n].push(e)), o;
22
+ }, {}), E = (t, o, r) => {
23
+ const e = v(t), n = A(o, r);
24
+ return Object.entries(e).map(([a, u]) => {
25
+ const s = u[0].top_level_category_guid, m = n.map((l) => {
26
+ const c = u.filter((g) => g.year_month === l).reduce((g, d) => g + Math.abs(d.amount), 0), _ = Number(String(l).slice(0, 4)), h = Number(String(l).slice(4));
24
27
  return {
25
- x: new Date(g, p - 1),
26
- y: u
28
+ x: new Date(_, h - 1),
29
+ y: c
27
30
  };
28
- }).sort((s, u) => s.x.getTime() - u.x.getTime());
31
+ }).sort((l, c) => l.x.getTime() - c.x.getTime());
29
32
  return {
30
- top_level_category_guid: c,
31
- category_guid: r,
32
- category_name: f(r),
33
- category_color: d(c),
34
- dataset: i
33
+ top_level_category_guid: s,
34
+ category_guid: a,
35
+ category_name: M(a),
36
+ category_color: C(s),
37
+ dataset: m
35
38
  };
36
39
  });
37
- }, S = (e, t) => {
38
- const o = typeof e == "string" ? parseFloat(e.replace(/[^0-9.-]+/g, "")) : e, a = typeof t == "string" ? parseFloat(t.replace(/[^0-9.-]+/g, "")) : t;
39
- return (o || 0) - (a || 0);
40
- }, N = (e, t) => e.indexOf("General") >= 0 ? 1 : e.localeCompare(t), v = (e, t) => {
41
- const o = e.subCategories.filter((r) => r.currentAmount !== 0), a = e.totalMonthlyAmounts.slice(-t), n = (r) => r.substring(0, 3) + " " + r.slice(-4);
42
- return a.map((r) => {
43
- const l = n(r.label), c = o.map((s) => {
44
- const u = s.monthlyAmounts.slice(-t).find((g) => n(g.label) === l);
45
- return {
46
- label: s.name,
47
- amount: Math.abs(u?.amount || 0),
48
- header: l
49
- };
50
- }), i = e.monthlyAmounts.slice(-t).find((s) => n(s.label) === l);
40
+ }, R = (t, o) => {
41
+ const r = typeof t == "string" ? parseFloat(t.replace(/[^0-9.-]+/g, "")) : t, e = typeof o == "string" ? parseFloat(o.replace(/[^0-9.-]+/g, "")) : o;
42
+ return (r || 0) - (e || 0);
43
+ }, F = (t, o) => t.indexOf("General") >= 0 ? 1 : t.localeCompare(o), N = (t, o) => {
44
+ const r = t.subCategories.filter((e) => e.currentAmount !== 0);
45
+ return o.map(({ isoDate: e }) => {
46
+ const n = p(e, i.MONTH_SHORT_YEAR), a = (s) => Math.abs(s.find((m) => m.isoDate === e)?.amount || 0), u = r.map((s) => ({
47
+ label: s.name,
48
+ amount: a(s.monthlyAmounts),
49
+ header: n
50
+ }));
51
51
  return [{
52
- label: e.name,
53
- amount: Math.abs(i?.amount || 0),
54
- header: l
55
- }, ...c].sort((s, u) => u.amount - s.amount);
52
+ label: t.name,
53
+ amount: a(t.monthlyAmounts),
54
+ header: n
55
+ }, ...u].sort((s, m) => m.amount - s.amount);
56
56
  });
57
- }, x = (e, t) => ({
58
- monthlyAmounts: e ? e.totalMonthlyAmounts.slice(-t).map((o) => ({
59
- x: o.label.substring(0, 3),
60
- y: Math.abs(o.amount)
61
- })) : [],
62
- tooltipLabels: e ? v(e, t) : []
63
- }), D = (e) => e.slice().filter((t) => t.totalAmount !== 0 && !t.isTransfer && t.guid !== _.INVESTMENTS).sort((t, o) => Math.abs(o.totalAmount) - Math.abs(t.totalAmount));
57
+ }, H = (t, o) => {
58
+ const r = t ? t.totalMonthlyAmounts.slice(-o) : [], e = r.map(({ amount: u, isoDate: s }) => ({
59
+ x: p(s, i.MONTH_SHORT),
60
+ y: Math.abs(u)
61
+ })), n = r.map(({ amount: u, isoDate: s }) => ({
62
+ label: p(s, i.MONTH_YEAR),
63
+ amount: Math.abs(u)
64
+ })), a = t ? N(t, r) : [];
65
+ return {
66
+ average: f(e.map(({ y: u }) => u)),
67
+ monthlyAmounts: e,
68
+ monthlyTotals: n,
69
+ tooltipLabels: a
70
+ };
71
+ }, L = (t) => t.slice().filter((o) => o.totalAmount !== 0 && !o.isTransfer && o.guid !== b.INVESTMENTS).sort((o, r) => Math.abs(r.totalAmount) - Math.abs(o.totalAmount));
64
72
  export {
65
- S as amountComparator,
66
- x as buildCategoryDetailsChartData,
67
- N as categoryComparator,
68
- D as filterAndSortCategoriesWithTransactions,
69
- A as getStackedLineChartData
73
+ R as amountComparator,
74
+ H as buildCategoryDetailsChartData,
75
+ F as categoryComparator,
76
+ L as filterAndSortCategoriesWithTransactions,
77
+ E as getStackedLineChartData
70
78
  };
71
79
 
72
80
  //# sourceMappingURL=TrendsUtil.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TrendsUtil.es.js","names":[],"sources":["../../../src/core/utils/TrendsUtil.ts"],"sourcesContent":["import { GridComparatorFn } from '@mui/x-data-grid-pro'\n\nimport { CategoryColors, CategoryGuids, CategoryGuidToName } from '../constants'\nimport { DetailedCategoryWithTransactions, MonthlyCategoryTotals } from '../types'\n\ntype DataPoint = { x: Date; y: number }\ntype Dataset = DataPoint[]\n\ntype CategoryTotalData = {\n top_level_category_guid: string\n category_guid: string\n amount: number\n year_month: number // e.g. 202409\n}\n\ntype GroupedCategoryTotalData = {\n [categoryGuid: string]: CategoryTotalData[]\n}\n\nexport interface StackedLineChartData {\n top_level_category_guid: string\n category_guid: string\n category_name: string\n category_color: string\n dataset: Dataset\n}\n\nconst getCategoryColor = (categoryGuid: string): string => {\n return CategoryColors[categoryGuid] ?? CategoryColors.default\n}\n\nconst getCategoryName = (categoryGuid: string): string => {\n return CategoryGuidToName[categoryGuid]\n}\n\nfunction createYearMonthRange(start: Date, end: Date): number[] {\n const result = []\n const current = new Date(start)\n\n while (current <= end) {\n const year = current.getFullYear()\n const month = String(current.getMonth() + 1).padStart(2, '0')\n result.push(Number(`${year}${month}`))\n current.setMonth(current.getMonth() + 1)\n }\n\n return result\n}\n\nconst createGroupedCategoryTotals = (totals: MonthlyCategoryTotals[]): GroupedCategoryTotalData => {\n return totals.reduce((result, item) => {\n const totalData: CategoryTotalData = {\n top_level_category_guid: item.top_level_category_guid,\n category_guid: item.category_guid,\n amount: item.total,\n year_month: item.year_month,\n }\n\n const { top_level_category_guid, category_guid } = totalData\n\n // Ensure category bucket exists\n if (!result[category_guid]) {\n result[category_guid] = []\n }\n result[category_guid].push(totalData)\n\n // Ensure top-level category bucket exists (if different than category)\n if (top_level_category_guid !== category_guid) {\n if (!result[top_level_category_guid]) {\n result[top_level_category_guid] = []\n }\n result[top_level_category_guid].push(totalData)\n }\n\n return result\n }, {} as GroupedCategoryTotalData)\n}\n\nexport const getStackedLineChartData = (\n totals: MonthlyCategoryTotals[],\n start: Date,\n end: Date,\n): StackedLineChartData[] => {\n const groupedTotals = createGroupedCategoryTotals(totals)\n const yearMonths = createYearMonthRange(start, end)\n\n return Object.entries(groupedTotals).map(([categoryGuid, totals]) => {\n const topLevelCategoryGuid = totals[0].top_level_category_guid\n // Build dataset for current category\n const dataset: Dataset = yearMonths\n // Build chart coordinates and fill missing totals with 0\n .map((yearMonth) => {\n // Sum category totals for same month\n // (totals with same top_level_category_guid but different category_guid)\n // And fill missing totals with 0\n // (necessary for StackedLineChart lines to be smooth)\n const sumTotal = totals\n .filter((total) => total.year_month === yearMonth)\n .reduce((sum, total) => sum + Math.abs(total.amount), 0)\n\n const year = Number(String(yearMonth).slice(0, 4))\n const month = Number(String(yearMonth).slice(4))\n const date = new Date(year, month - 1)\n\n return { x: date, y: sumTotal }\n })\n .sort((a, b) => a.x.getTime() - b.x.getTime())\n\n return {\n top_level_category_guid: topLevelCategoryGuid,\n category_guid: categoryGuid,\n category_name: getCategoryName(categoryGuid),\n category_color: getCategoryColor(topLevelCategoryGuid),\n dataset: dataset,\n }\n })\n}\n\nexport const amountComparator: GridComparatorFn<string | number> = (v1, v2) => {\n const num1 = typeof v1 === 'string' ? parseFloat(v1.replace(/[^0-9.-]+/g, '')) : v1\n const num2 = typeof v2 === 'string' ? parseFloat(v2.replace(/[^0-9.-]+/g, '')) : v2\n\n return (num1 || 0) - (num2 || 0)\n}\n\nexport const categoryComparator: GridComparatorFn<string> = (cat1, cat2) => {\n // Always keep \"General\" categories at the bottom of the list\n return cat1.indexOf('General') >= 0 ? 1 : cat1.localeCompare(cat2)\n}\n\nconst buildTooltipLabels = (data: DetailedCategoryWithTransactions, monthsCount: number) => {\n const subcategories = data.subCategories.filter((subcategory) => subcategory.currentAmount !== 0)\n const monthsData = data.totalMonthlyAmounts.slice(-monthsCount)\n\n const formatMonthLabel = (label: string) => label.substring(0, 3) + ' ' + label.slice(-4)\n\n return monthsData.map((monthData) => {\n const monthLabel = formatMonthLabel(monthData.label)\n\n const subcategoryEntries = subcategories.map((subcategory) => {\n const monthEntry = subcategory.monthlyAmounts\n .slice(-monthsCount)\n .find((entry) => formatMonthLabel(entry.label) === monthLabel)\n\n return {\n label: subcategory.name,\n amount: Math.abs(monthEntry?.amount || 0),\n header: monthLabel,\n }\n })\n\n const parentMonthEntry = data.monthlyAmounts\n .slice(-monthsCount)\n .find((entry) => formatMonthLabel(entry.label) === monthLabel)\n\n const parentEntry = {\n label: data.name,\n amount: Math.abs(parentMonthEntry?.amount || 0),\n header: monthLabel,\n }\n\n return [parentEntry, ...subcategoryEntries].sort((a, b) => b.amount - a.amount)\n })\n}\n\nexport const buildCategoryDetailsChartData = (\n data: DetailedCategoryWithTransactions | null,\n monthsCount: number,\n) => {\n const monthlyAmounts = data\n ? data.totalMonthlyAmounts.slice(-monthsCount).map((monthData) => ({\n x: monthData.label.substring(0, 3),\n y: Math.abs(monthData.amount),\n }))\n : []\n\n const tooltipLabels = data ? buildTooltipLabels(data, monthsCount) : []\n\n return { monthlyAmounts, tooltipLabels }\n}\n\nexport const filterAndSortCategoriesWithTransactions = (\n categories: DetailedCategoryWithTransactions[],\n): DetailedCategoryWithTransactions[] => {\n return categories\n .slice()\n .filter(\n (category) =>\n category.totalAmount !== 0 &&\n !category.isTransfer &&\n category.guid !== CategoryGuids.INVESTMENTS,\n )\n .sort((a, b) => Math.abs(b.totalAmount) - Math.abs(a.tot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5D,YAAM,IAAa,EAAY,eAC5B,MAAM,CAAC,CAAW,EAClB,KAAA,CAAM,MAAU,EAAiB,EAAM,KAAK,MAAM,CAAU;AAE/D,aAAO;AAAA,QACL,OAAO,EAAY;AAAA,QACnB,QAAQ,KAAK,IAAI,GAAY,UAAU,CAAC;AAAA,QACxC,QAAQ;AAAA,MACV;AAAA,IACF,CAAC,GAEK,IAAmB,EAAK,eAC3B,MAAM,CAAC,CAAW,EAClB,KAAA,CAAM,MAAU,EAAiB,EAAM,KAAK,MAAM,CAAU;AAQ/D,WAAO,CAAC;AAAA,MALN,OAAO,EAAK;AAAA,MACZ,QAAQ,KAAK,IAAI,GAAkB,UAAU,CAAC;AAAA,MAC9C,QAAQ;AAAA,IAGF,GAAa,GAAG,CAAkB,EAAE,KAAA,CAAM,GAAG,MAAM,EAAE,SAAS,EAAE,MAAM;AAAA,EAChF,CAAC;AACH,GAEa,IAAA,CACX,GACA,OAWO;AAAA,EAAE,gBATc,IACnB,EAAK,oBAAoB,MAAM,CAAC,CAAW,EAAE,IAAA,CAAK,OAAe;AAAA,IAC/D,GAAG,EAAU,MAAM,UAAU,GAAG,CAAC;AAAA,IACjC,GAAG,KAAK,IAAI,EAAU,MAAM;AAAA,EAC9B,EAAE,IACF,CAAC;AAAA,EAIoB,eAFH,IAAO,EAAmB,GAAM,CAAW,IAAI,CAAC;AAE/B,IAG5B,IAAA,CACX,MAEO,EACJ,MAAM,EACN,OAAA,CACE,MACC,EAAS,gBAAgB,KACzB,CAAC,EAAS,cACV,EAAS,SAAS,EAAc,WACpC,EACC,KAAA,CAAM,GAAG,MAAM,KAAK,IAAI,EAAE,WAAW,IAAI,KAAK,IAAI,EAAE,WAAW,CAAC"}
1
+ {"version":3,"file":"TrendsUtil.es.js","names":[],"sources":["../../../src/core/utils/TrendsUtil.ts"],"sourcesContent":["import { GridComparatorFn } from '@mui/x-data-grid-pro'\n\nimport { CategoryColors, CategoryGuids, CategoryGuidToName, DATE_FORMATS_INTL } from '../constants'\nimport { DetailedCategoryWithTransactions, MonthlyAmount, MonthlyCategoryTotals } from '../types'\nimport { formatIsoDate } from './DateUtil'\nimport { roundedAverage } from './NumberFormatting'\n\ntype DataPoint = { x: Date; y: number }\ntype Dataset = DataPoint[]\n\ntype CategoryTotalData = {\n top_level_category_guid: string\n category_guid: string\n amount: number\n year_month: number // e.g. 202409\n}\n\ntype GroupedCategoryTotalData = {\n [categoryGuid: string]: CategoryTotalData[]\n}\n\nexport interface StackedLineChartData {\n top_level_category_guid: string\n category_guid: string\n category_name: string\n category_color: string\n dataset: Dataset\n}\n\nconst getCategoryColor = (categoryGuid: string): string => {\n return CategoryColors[categoryGuid] ?? CategoryColors.default\n}\n\nconst getCategoryName = (categoryGuid: string): string => {\n return CategoryGuidToName[categoryGuid]\n}\n\nfunction createYearMonthRange(start: Date, end: Date): number[] {\n const result = []\n const current = new Date(start)\n\n while (current <= end) {\n const year = current.getFullYear()\n const month = String(current.getMonth() + 1).padStart(2, '0')\n result.push(Number(`${year}${month}`))\n current.setMonth(current.getMonth() + 1)\n }\n\n return result\n}\n\nconst createGroupedCategoryTotals = (totals: MonthlyCategoryTotals[]): GroupedCategoryTotalData => {\n return totals.reduce((result, item) => {\n const totalData: CategoryTotalData = {\n top_level_category_guid: item.top_level_category_guid,\n category_guid: item.category_guid,\n amount: item.total,\n year_month: item.year_month,\n }\n\n const { top_level_category_guid, category_guid } = totalData\n\n // Ensure category bucket exists\n if (!result[category_guid]) {\n result[category_guid] = []\n }\n result[category_guid].push(totalData)\n\n // Ensure top-level category bucket exists (if different than category)\n if (top_level_category_guid !== category_guid) {\n if (!result[top_level_category_guid]) {\n result[top_level_category_guid] = []\n }\n result[top_level_category_guid].push(totalData)\n }\n\n return result\n }, {} as GroupedCategoryTotalData)\n}\n\nexport const getStackedLineChartData = (\n totals: MonthlyCategoryTotals[],\n start: Date,\n end: Date,\n): StackedLineChartData[] => {\n const groupedTotals = createGroupedCategoryTotals(totals)\n const yearMonths = createYearMonthRange(start, end)\n\n return Object.entries(groupedTotals).map(([categoryGuid, totals]) => {\n const topLevelCategoryGuid = totals[0].top_level_category_guid\n // Build dataset for current category\n const dataset: Dataset = yearMonths\n // Build chart coordinates and fill missing totals with 0\n .map((yearMonth) => {\n // Sum category totals for same month\n // (totals with same top_level_category_guid but different category_guid)\n // And fill missing totals with 0\n // (necessary for StackedLineChart lines to be smooth)\n const sumTotal = totals\n .filter((total) => total.year_month === yearMonth)\n .reduce((sum, total) => sum + Math.abs(total.amount), 0)\n\n const year = Number(String(yearMonth).slice(0, 4))\n const month = Number(String(yearMonth).slice(4))\n const date = new Date(year, month - 1)\n\n return { x: date, y: sumTotal }\n })\n .sort((a, b) => a.x.getTime() - b.x.getTime())\n\n return {\n top_level_category_guid: topLevelCategoryGuid,\n category_guid: categoryGuid,\n category_name: getCategoryName(categoryGuid),\n category_color: getCategoryColor(topLevelCategoryGuid),\n dataset: dataset,\n }\n })\n}\n\nexport const amountComparator: GridComparatorFn<string | number> = (v1, v2) => {\n const num1 = typeof v1 === 'string' ? parseFloat(v1.replace(/[^0-9.-]+/g, '')) : v1\n const num2 = typeof v2 === 'string' ? parseFloat(v2.replace(/[^0-9.-]+/g, '')) : v2\n\n return (num1 || 0) - (num2 || 0)\n}\n\nexport const categoryComparator: GridComparatorFn<string> = (cat1, cat2) => {\n // Always keep \"General\" categories at the bottom of the list\n return cat1.indexOf('General') >= 0 ? 1 : cat1.localeCompare(cat2)\n}\n\nconst buildTooltipLabels = (data: DetailedCategoryWithTransactions, months: MonthlyAmount[]) => {\n const subcategories = data.subCategories.filter((subcategory) => subcategory.currentAmount !== 0)\n\n return months.map(({ isoDate }) => {\n const header = formatIsoDate(isoDate, DATE_FORMATS_INTL.MONTH_SHORT_YEAR)\n const amountFor = (amounts: MonthlyAmount[]) =>\n Math.abs(amounts.find((entry) => entry.isoDate === isoDate)?.amount || 0)\n\n const subcategoryEntries = subcategories.map((subcategory) => ({\n label: subcategory.name,\n amount: amountFor(subcategory.monthlyAmounts),\n header,\n }))\n\n const parentEntry = { label: data.name, amount: amountFor(data.monthlyAmounts), header }\n\n return [parentEntry, ...subcategoryEntries].sort((a, b) => b.amount - a.amount)\n })\n}\n\nexport const buildCategoryDetailsChartData = (\n data: DetailedCategoryWithTransactions | null,\n monthsCount: number,\n) => {\n const months = data ? data.totalMonthlyAmounts.slice(-monthsCount) : []\n\n const monthlyAmounts = months.map(({ amount, isoDate }) => ({\n x: formatIsoDate(isoDate, DATE_FORMATS_INTL.MONTH_SHORT),\n y: Math.abs(amount),\n }))\n\n const monthlyTotals = months.map(({ amount, isoDate }) => ({\n label: formatIsoDate(isoDate, DATE_FORMATS_INTL.MONTH_YEAR),\n amount: Math.abs(amount),\n }))\n\n const tooltipLabels = data ? buildTooltipLabels(data, months) : []\n\n return {\n average: roundedAverage(monthlyAmounts.map(({ y }) => y)),\n monthlyAmounts,\n monthlyTotals,\n tooltipLabels,\n }\n}\n\nexport const filterAndSortCategoriesWithTransactions = (\n categories: DetailedCategoryWithTransactions[],\n): DetailedCategoryWithTransactions[] => {\n return categories\n .slice()\n .filter(\n (category) =>\n category.totalAmount !== 0 &&\n !category.isTransfer &&\n category.guid !== CategoryGuids.INVESTMENTS,\n )\n .sort((a, b) => Math.abs(b.totalAmount) - Math.abs(a.totalAmount))\n}\n"],"mappings":";;;;AA6BA,IAAM,IAAA,CAAoB,MACjB,EAAe,CAAA,KAAiB,EAAe,SAGlD,IAAA,CAAmB,MAChB,EAAmB,CAAA;AAG5B,SAAS,EAAqB,GAAa,GAAqB;AAC9D,QAAM,IAAS,CAAC,GACV,IAAU,IAAI,KAAK,CAAK;AAE9B,SAAO,KAAW,KAAK;AACrB,UAAM,IAAO,EAAQ,YAAY,GAC3B,IAAQ,OAAO,EAAQ,SAAS,IAAI,CAAC,EAAE,SAAS,GAAG,GAAG;AAC5D,IAAA,EAAO,KAAK,CAAO,GAAG,CAAA,GAAO,CAAA,EAAQ,GACrC,EAAQ,SAAS,EAAQ,SAAS,IAAI,C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A,GAAQ,SAAA,EAAA,OAAe;AAAA,IAC1D,GAAG,EAAc,GAAS,EAAkB,WAAW;AAAA,IACvD,GAAG,KAAK,IAAI,CAAM;AAAA,EACpB,EAAE,GAEI,IAAgB,EAAO,IAAA,CAAK,EAAE,QAAA,GAAQ,SAAA,EAAA,OAAe;AAAA,IACzD,OAAO,EAAc,GAAS,EAAkB,UAAU;AAAA,IAC1D,QAAQ,KAAK,IAAI,CAAM;AAAA,EACzB,EAAE,GAEI,IAAgB,IAAO,EAAmB,GAAM,CAAM,IAAI,CAAC;AAEjE,SAAO;AAAA,IACL,SAAS,EAAe,EAAe,IAAA,CAAK,EAAE,GAAA,EAAA,MAAQ,CAAC,CAAC;AAAA,IACxD,gBAAA;AAAA,IACA,eAAA;AAAA,IACA,eAAA;AAAA,EACF;AACF,GAEa,IAAA,CACX,MAEO,EACJ,MAAM,EACN,OAAA,CACE,MACC,EAAS,gBAAgB,KACzB,CAAC,EAAS,cACV,EAAS,SAAS,EAAc,WACpC,EACC,KAAA,CAAM,GAAG,MAAM,KAAK,IAAI,EAAE,WAAW,IAAI,KAAK,IAAI,EAAE,WAAW,CAAC"}
@@ -11,6 +11,10 @@ export interface TransactionListProps {
11
11
  isRowDisabled?: (t: Transaction) => boolean;
12
12
  loader?: React.JSX.Element;
13
13
  onClick?: (guid: string) => void;
14
+ /** Virtualize against the nearest scrolling ancestor instead of an own fixed-height scroll box. */
15
+ scrollsWithParent?: boolean;
16
+ /** Rendered above the rows; stays at the top of the scroll area when used with scrollsWithParent. */
17
+ stickyHeader?: React.ReactNode;
14
18
  showInsights?: boolean;
15
19
  showLoader?: boolean;
16
20
  transaction?: Transaction[];
@@ -1,97 +1,151 @@
1
- import { useEvent as N, useTransactionStore as O } from "../../../common/context/hooks.es.js";
2
- import { fromUnixUTCToDayOfWeekAndDate as H } from "../../../core/utils/DateUtil.es.js";
3
- import { ANALYTICS_EVENTS as U } from "../../../common/constants/Analytics.es.js";
4
- import k from "../../../common/components/Loader.es.js";
5
- import W from "../../../common/components/ZeroState.es.js";
6
- import { useTransactionsUiStore as j } from "../../context/hooks.es.js";
7
- import w from "./transactionlist/TransactionRow.es.js";
8
- import B from "../../../common/components/SubheaderRow.es.js";
9
- import { hasInsetBorder as G, shouldShowDate as T } from "../../utils/Transactions.es.js";
10
- import i from "react";
11
- import { observer as Y } from "mobx-react-lite";
12
- import { jsx as o, jsxs as S } from "react/jsx-runtime";
1
+ import { useEvent as Q, useGlobalCopyStore as W, useTransactionStore as ee } from "../../../common/context/hooks.es.js";
2
+ import { fromUnixUTCToDayOfWeekAndDate as te } from "../../../core/utils/DateUtil.es.js";
3
+ import { VISUALLY_HIDDEN_SX as oe } from "../../../common/constants/Styles.es.js";
4
+ import { ANALYTICS_EVENTS as ne } from "../../../common/constants/Analytics.es.js";
5
+ import re from "../../../common/components/Loader.es.js";
6
+ import se from "../../../common/components/ZeroState.es.js";
7
+ import { useTransactionsUiStore as ie } from "../../context/hooks.es.js";
8
+ import ae from "./transactionlist/TransactionRow.es.js";
9
+ import ce from "../../../common/components/SubheaderRow.es.js";
10
+ import { hasInsetBorder as le, shouldShowDate as H } from "../../utils/Transactions.es.js";
11
+ import o from "react";
12
+ import { observer as ue } from "mobx-react-lite";
13
+ import { Fragment as de, jsx as s, jsxs as b } from "react/jsx-runtime";
13
14
  import u from "@mui/material/Box";
14
- import y from "@mui/material/Divider";
15
- import K from "@mui/material/List";
16
- import { useVirtualizer as M } from "@tanstack/react-virtual";
17
- var _ = 65, v = 32, Z = ({ bgcolor: x, filter: s, height: E = "calc(100dvh - 36px)", isRowDisabled: I, loader: b = /* @__PURE__ */ o(k, {
15
+ import fe from "@mui/material/Divider";
16
+ import me from "@mui/material/List";
17
+ import { useVirtualizer as pe } from "@tanstack/react-virtual";
18
+ var z = 65, y = 32, ge = (h) => {
19
+ for (let r = h?.parentElement; r; r = r.parentElement) if (/(auto|scroll)/.test(getComputedStyle(r).overflowY)) return r;
20
+ return null;
21
+ }, he = ({ bgcolor: h, filter: r, height: N = "calc(100dvh - 36px)", isRowDisabled: O, loader: k = /* @__PURE__ */ s(re, {
18
22
  label: "Loading",
19
23
  size: 40
20
- }), onClick: d, showInsights: f = !1, showLoader: l = !1, transaction: p, width: g = "100%", zeroState: A = /* @__PURE__ */ o(W, {}) }) => {
21
- const { isLoading: c, sortedTransactions: m } = O(), r = i.useMemo(() => {
22
- const t = s ? m.filter(s) : m;
23
- return p ?? t;
24
+ }), onClick: E, scrollsWithParent: a = !1, showInsights: I = !1, showLoader: B = !1, stickyHeader: x, transaction: _, width: S = "100%", zeroState: U = /* @__PURE__ */ s(se, {}) }) => {
25
+ const { isLoading: V, sortedTransactions: v } = ee(), n = o.useMemo(() => {
26
+ const e = r ? v.filter(r) : v;
27
+ return _ ?? e;
24
28
  }, [
25
- m,
26
- s,
27
- p
28
- ]), { clearExpandedSplits: C, setShowInsights: R, toggleSplit: D } = j(), { onEvent: L } = N(), V = (t) => {
29
- const e = r.find((a) => a.guid === t);
30
- if (e?.has_been_split) {
31
- D(e.guid);
29
+ v,
30
+ r,
31
+ _
32
+ ]), { clearExpandedSplits: $, setShowInsights: F, toggleSplit: M } = ie(), { onEvent: Y } = Q(), { common: G } = W(), [d, C] = o.useState(null), j = (e) => {
33
+ const t = n.find((i) => i.guid === e);
34
+ if (t?.has_been_split) {
35
+ M(t.guid);
32
36
  return;
33
37
  }
34
- L(U.ACCOUNT_DETAILS_CLICK_TRANSACTION, {
35
- account_guid: e?.account_guid,
36
- transaction_guid: t
37
- }), d?.(t);
38
- }, h = i.useRef(null), n = M({
39
- count: r.length,
40
- getScrollElement: () => h.current,
41
- estimateSize: (t) => _ + (T(t, r) ? v : 0),
42
- overscan: 5
43
- });
44
- return i.useEffect(() => n.measure(), [r]), i.useEffect(() => R(f), [f]), i.useEffect(() => () => C(), []), /* @__PURE__ */ o(K, {
45
- component: "div",
46
- role: "list",
47
- sx: { width: g },
48
- children: /* @__PURE__ */ o(u, {
49
- height: E,
50
- overflow: "auto",
51
- ref: h,
52
- role: "presentation",
53
- width: g,
54
- children: /* @__PURE__ */ S(u, {
55
- height: n.getVirtualItems().length === 0 ? "auto" : n.getTotalSize(),
56
- position: "relative",
38
+ Y(ne.ACCOUNT_DETAILS_CLICK_TRANSACTION, {
39
+ account_guid: t?.account_guid,
40
+ transaction_guid: e
41
+ }), E?.(e);
42
+ }, f = o.useRef(null), q = !!x, [R, K] = o.useState(null), [L, X] = o.useState(0), m = o.useRef(null), [w, Z] = o.useState(0);
43
+ o.useLayoutEffect(() => {
44
+ if (!a) return;
45
+ const e = f.current;
46
+ if (!e) return;
47
+ const t = ge(e) ?? e, i = () => {
48
+ X(e.getBoundingClientRect().top - t.getBoundingClientRect().top + t.scrollTop), Z(m.current?.offsetHeight ?? 0);
49
+ };
50
+ K(t), i();
51
+ const l = new ResizeObserver(i);
52
+ return l.observe(t.firstElementChild ?? t), m.current && l.observe(m.current), () => l.disconnect();
53
+ }, [a, q]);
54
+ const p = pe({
55
+ count: n.length,
56
+ getScrollElement: () => a ? R : f.current,
57
+ estimateSize: (e) => z + (H(e, n) ? y : 0),
58
+ overscan: 5,
59
+ scrollMargin: L,
60
+ scrollPaddingStart: w
61
+ }), g = p.getVirtualItems(), c = g.at(-1)?.index ?? -1, A = n.length - (c + 1), T = !V && !B, D = T && g.length > 0, J = () => {
62
+ const e = c + 1;
63
+ p.scrollToIndex(e, { align: "start" }), C({
64
+ index: e,
65
+ from: c
66
+ });
67
+ };
68
+ return o.useEffect(() => {
69
+ if (!d) return;
70
+ const e = f.current?.querySelector(`[data-index="${d.index}"]`);
71
+ e?.focus(), (e || c !== d.from) && C(null);
72
+ }, [d, c]), o.useEffect(() => p.measure(), [n, R]), o.useEffect(() => F(I), [I]), o.useEffect(() => () => $(), []), /* @__PURE__ */ b(de, { children: [
73
+ x && /* @__PURE__ */ s(u, {
74
+ ref: m,
75
+ sx: {
76
+ bgcolor: "background.paper",
77
+ position: a ? "sticky" : void 0,
78
+ top: 0,
79
+ width: S,
80
+ zIndex: 1
81
+ },
82
+ children: x
83
+ }),
84
+ /* @__PURE__ */ s(me, {
85
+ component: "div",
86
+ role: "list",
87
+ sx: { width: S },
88
+ children: /* @__PURE__ */ s(u, {
89
+ height: a ? void 0 : N,
90
+ overflow: a ? void 0 : "auto",
91
+ ref: f,
57
92
  role: "presentation",
58
- width: "100%",
59
- children: [
60
- (c || l) && b,
61
- !c && !l && n.getVirtualItems().length === 0 && A,
62
- !c && !l && n.getVirtualItems().length > 0 && n.getVirtualItems().map((t) => {
63
- const e = r[t.index], a = T(t.index, r), z = G(t.index, r);
64
- return /* @__PURE__ */ S(u, {
65
- role: "listitem",
66
- sx: {
67
- height: _ + (a ? v : 0),
68
- position: "absolute",
69
- transform: `translateY(${t.start}px)`,
70
- width: "100%",
71
- bgcolor: "background.paper"
72
- },
73
- children: [
74
- a && /* @__PURE__ */ o(B, {
75
- bgcolor: x,
76
- children: H(e.date)
77
- }),
78
- /* @__PURE__ */ o(w, {
79
- component: "div",
80
- disabled: I?.(e),
81
- ...d && { onClick: V },
82
- transaction: e
83
- }),
84
- /* @__PURE__ */ o(y, { sx: { ml: z ? 68 : 0 } })
85
- ]
86
- }, e.guid);
87
- })
88
- ]
93
+ width: S,
94
+ children: /* @__PURE__ */ b(u, {
95
+ height: g.length === 0 ? "auto" : p.getTotalSize(),
96
+ position: "relative",
97
+ role: "presentation",
98
+ width: "100%",
99
+ children: [
100
+ !T && k,
101
+ T && n.length === 0 && U,
102
+ D && g.map((e) => {
103
+ const t = n[e.index], i = H(e.index, n), l = le(e.index, n), P = z + (i ? y : 0);
104
+ return /* @__PURE__ */ b(u, {
105
+ "aria-posinset": e.index + 1,
106
+ "aria-setsize": n.length,
107
+ "data-index": e.index,
108
+ role: "listitem",
109
+ tabIndex: -1,
110
+ sx: {
111
+ height: P,
112
+ position: "absolute",
113
+ scrollMarginTop: w,
114
+ transform: `translateY(${e.start - L}px)`,
115
+ width: "100%",
116
+ bgcolor: "background.paper"
117
+ },
118
+ children: [
119
+ i && /* @__PURE__ */ s(ce, {
120
+ bgcolor: h,
121
+ children: te(t.date)
122
+ }),
123
+ /* @__PURE__ */ s(ae, {
124
+ component: "div",
125
+ disabled: O?.(t),
126
+ ...E && { onClick: j },
127
+ transaction: t
128
+ }),
129
+ /* @__PURE__ */ s(fe, { sx: { ml: l ? 68 : 0 } })
130
+ ]
131
+ }, t.guid);
132
+ })
133
+ ]
134
+ })
89
135
  })
136
+ }),
137
+ D && A > 0 && /* @__PURE__ */ s(u, {
138
+ component: "button",
139
+ onClick: J,
140
+ sx: oe,
141
+ tabIndex: -1,
142
+ type: "button",
143
+ children: `${G.view_more} (${A})`
90
144
  })
91
- });
92
- }, ct = Y(Z);
145
+ ] });
146
+ }, Ne = ue(he);
93
147
  export {
94
- ct as default
148
+ Ne as default
95
149
  };
96
150
 
97
151
  //# sourceMappingURL=TransactionList.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TransactionList.es.js","names":[],"sources":["../../../../src/transactions/components/shared/TransactionList.tsx"],"sourcesContent":["import React from 'react'\nimport { observer } from 'mobx-react-lite'\nimport { useVirtualizer } from '@tanstack/react-virtual'\n\nimport Box from '@mui/material/Box'\nimport Divider from '@mui/material/Divider'\nimport List from '@mui/material/List'\n\nimport { ANALYTICS_EVENTS, Loader, useEvent, ZeroState } from '../../../common'\nimport { type Transaction } from '../../../core'\n\nimport { useTransactionsUiStore } from '../../context/hooks'\nimport { useTransactionStore } from '../../../common'\n\nimport SubheaderRow from '../../../common/components/SubheaderRow'\nimport TransactionRow from './transactionlist/TransactionRow'\n\nimport { hasInsetBorder, shouldShowDate } from '../../utils/Transactions'\nimport { fromUnixUTCToDayOfWeekAndDate } from '../../../core/utils/DateUtil'\n\nconst ROW_HEIGHT = 65\nconst DATE_ROW_HEIGHT = 32\n\nexport interface TransactionListProps {\n bgcolor?: string\n filter?: (t: Transaction) => boolean\n height?: number | string\n /**\n * Marks rows that stay in the list but cannot be acted on. Disabled rows are rendered greyed\n * out and inert instead of being removed, so list membership and ordering are unaffected.\n */\n isRowDisabled?: (t: Transaction) => boolean\n loader?: React.JSX.Element\n onClick?: (guid: string) => void\n showInsights?: boolean\n showLoader?: boolean\n transaction?: Transaction[]\n width?: number | string\n zeroState?: React.JSX.Element\n}\n\nconst TransactionList: React.FC<TransactionListProps> = ({\n bgcolor,\n filter,\n height = 'calc(100dvh - 36px)',\n isRowDisabled,\n loader = <Loader label=\"Loading\" size={40} />,\n onClick,\n showInsights = false,\n showLoader = false,\n transaction,\n width = '100%',\n zeroState = <ZeroState />,\n}) => {\n const { isLoading, sortedTransactions: allTransactions } = useTransactionStore()\n const transactions = React.useMemo(() => {\n const updatedTransactions = filter ? allTransactions.filter(filter) : allTransactions\n return transaction ?? updatedTransactions\n }, [allTransactions, filter, transaction])\n\n const { clearExpandedSplits, setShowInsights, toggleSplit } = useTransactionsUiStore()\n const { onEvent } = useEvent()\n\n const handleClick = (guid: string) => {\n const transaction = transactions.find((t) => t.guid === guid)\n\n if (transaction?.has_been_split) {\n toggleSplit(transaction.guid)\n return\n }\n\n onEvent(ANALYTICS_EVENTS.ACCOUNT_DETAILS_CLICK_TRANSACTION, {\n account_guid: transaction?.account_guid,\n transaction_guid: guid,\n })\n onClick?.(guid)\n }\n\n const parentRef = React.useRef<HTMLDivElement>(null)\n const rowVirtualizer = useVirtualizer({\n count: transactions.length,\n getScrollElement: () => parentRef.current,\n estimateSize: (i) => ROW_HEIGHT + (shouldShowDate(i, transactions) ? DATE_ROW_HEIGHT : 0),\n overscan: 5,\n })\n\n React.useEffect(() => rowVirtualizer.measure(), [transactions])\n React.useEffect(() => setShowInsights(showInsights), [showInsights])\n\n React.useEffect(() => {\n return () => clearExpandedSplits()\n }, [])\n\n return (\n <List component=\"div\" role=\"list\" sx={{ width: width }}>\n <Box height={height} overflow=\"auto\" ref={parentRef} role=\"presentation\" width={width}>\n <Box\n height={\n // set the height to auto when there are no transactions so the zero state isn't set to 0\n rowVirtualizer.getVirtualItems().length === 0 ? 'auto' : rowVirtualizer.getTotalSize()\n }\n position=\"relative\"\n role=\"presentation\"\n width=\"100%\"\n >\n {(isLoading || showLoader) && loader}\n {!isLoading && !showLoader && rowVirtualizer.getVirtualItems().length === 0 && zeroState}\n {!isLoading &&\n !showLoader &&\n rowVirtualizer.getVirtualItems().length > 0 &&\n rowVirtualizer.getVirtualItems().map((row) => {\n const transaction = transactions[row.index]\n const showDate = shouldShowDate(row.index, transactions)\n const isInset = hasInsetBorder(row.index, transactions)\n const rowHeight = ROW_HEIGHT + (showDate ? DATE_ROW_HEIGHT : 0)\n\n return (\n <Box\n key={transaction.guid}\n role=\"listitem\"\n sx={{\n height: rowHeight,\n position: 'absolute',\n transform: `translateY(${row.start}px)`,\n width: '100%',\n bgcolor: 'background.paper',\n }}\n >\n {showDate && (\n <SubheaderRow bgcolor={bgcolor}>\n {fromUnixUTCToDayOfWeekAndDate(transaction.date)}\n </SubheaderRow>\n )}\n <TransactionRow\n component=\"div\"\n disabled={isRowDisabled?.(transaction)}\n {...(onClick && { onClick: handleClick })}\n transaction={transaction}\n />\n <Divider sx={{ ml: isInset ? 68 : 0 }} />\n </Box>\n )\n })}\n </Box>\n </Box>\n </List>\n )\n}\n\nexport default observer(TransactionList)\n"],"mappings":";;;;;;;;;;;;;;;;AAoBA,IAAM,IAAa,IACb,IAAkB,IAoBlB,IAAA,CAAmD,EACvD,SAAA,GACA,QAAA,GACA,QAAA,IAAS,uBACT,eAAA,GACA,QAAA,IAAS,gBAAA,EAAC,GAAD;AAAA,EAAQ,OAAM;AAAA,EAAU,MAAM;AAAK,CAAA,GAC5C,SAAA,GACA,cAAA,IAAe,IACf,YAAA,IAAa,IACb,aAAA,GACA,OAAA,IAAQ,QACR,WAAA,IAAY,gBAAA,EAAC,GAAD,CAAY,CAAA,EAAA,MACpB;AACJ,QAAM,EAAE,WAAA,GAAW,oBAAoB,EAAA,IAAoB,EAAoB,GACzE,IAAe,EAAM,QAAA,MAAc;AACvC,UAAM,IAAsB,IAAS,EAAg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EAAe,aAAa;AAAA,QAEvF,UAAS;AAAA,QACT,MAAK;AAAA,QACL,OAAM;AAAA,QAPR,UAAA;AAAA,WASI,KAAa,MAAe;AAAA,UAC7B,CAAC,KAAa,CAAC,KAAc,EAAe,gBAAgB,EAAE,WAAW,KAAK;AAAA,UAC9E,CAAC,KACA,CAAC,KACD,EAAe,gBAAgB,EAAE,SAAS,KAC1C,EAAe,gBAAgB,EAAE,IAAA,CAAK,MAAQ;AAC5C,kBAAM,IAAc,EAAa,EAAI,KAAA,GAC/B,IAAW,EAAe,EAAI,OAAO,CAAY,GACjD,IAAU,EAAe,EAAI,OAAO,CAAY;AAGtD,mBACE,gBAAA,EAAC,GAAD;AAAA,cAEE,MAAK;AAAA,cACL,IAAI;AAAA,gBACF,QAPY,KAAc,IAAW,IAAkB;AAAA,gBAQvD,UAAU;AAAA,gBACV,WAAW,cAAc,EAAI,KAAA;AAAA,gBAC7B,OAAO;AAAA,gBACP,SAAS;AAAA,cACX;AAAA,cATF,UAAA;AAAA,gBAWG,KACC,gBAAA,EAAC,GAAD;AAAA,kBAAuB,SAAA;AAAA,kBACpB,UAAA,EAA8B,EAAY,IAAI;AAAA,gBACnC,CAAA;AAAA,gBAEhB,gBAAA,EAAC,GAAD;AAAA,kBACE,WAAU;AAAA,kBACV,UAAU,IAAgB,CAAW;AAAA,kBACrC,GAAK,KAAW,EAAE,SAAS,EAAY;AAAA,kBAC1B,aAAA;AAAA,gBACd,CAAA;AAAA,gBACD,gBAAA,EAAC,GAAD,EAAS,IAAI,EAAE,IAAI,IAAU,KAAK,EAAE,EAAI,CAAA;AAAA,cACrC;AAAA,YAtBE,GAAA,EAAY,IAsBd;AAAA,UAET,CAAC;AAAA,QACA;AAAA;IACF,CAAA;AAAA,EACD,CAAA;AAEV,GAEA,KAAe,EAAS,CAAe"}
1
+ {"version":3,"file":"TransactionList.es.js","names":[],"sources":["../../../../src/transactions/components/shared/TransactionList.tsx"],"sourcesContent":["import React from 'react'\nimport { observer } from 'mobx-react-lite'\nimport { useVirtualizer } from '@tanstack/react-virtual'\n\nimport Box from '@mui/material/Box'\nimport Divider from '@mui/material/Divider'\nimport List from '@mui/material/List'\n\nimport {\n ANALYTICS_EVENTS,\n Loader,\n useEvent,\n useGlobalCopyStore,\n VISUALLY_HIDDEN_SX,\n ZeroState,\n} from '../../../common'\nimport { type Transaction } from '../../../core'\n\nimport { useTransactionsUiStore } from '../../context/hooks'\nimport { useTransactionStore } from '../../../common'\n\nimport SubheaderRow from '../../../common/components/SubheaderRow'\nimport TransactionRow from './transactionlist/TransactionRow'\n\nimport { hasInsetBorder, shouldShowDate } from '../../utils/Transactions'\nimport { fromUnixUTCToDayOfWeekAndDate } from '../../../core/utils/DateUtil'\n\nconst ROW_HEIGHT = 65\nconst DATE_ROW_HEIGHT = 32\n\nconst findScrollParent = (node: HTMLElement | null): HTMLElement | null => {\n for (let el = node?.parentElement; el; el = el.parentElement) {\n if (/(auto|scroll)/.test(getComputedStyle(el).overflowY)) return el\n }\n return null\n}\n\nexport interface TransactionListProps {\n bgcolor?: string\n filter?: (t: Transaction) => boolean\n height?: number | string\n /**\n * Marks rows that stay in the list but cannot be acted on. Disabled rows are rendered greyed\n * out and inert instead of being removed, so list membership and ordering are unaffected.\n */\n isRowDisabled?: (t: Transaction) => boolean\n loader?: React.JSX.Element\n onClick?: (guid: string) => void\n /** Virtualize against the nearest scrolling ancestor instead of an own fixed-height scroll box. */\n scrollsWithParent?: boolean\n /** Rendered above the rows; stays at the top of the scroll area when used with scrollsWithParent. */\n stickyHeader?: React.ReactNode\n showInsights?: boolean\n showLoader?: boolean\n transaction?: Transaction[]\n width?: number | string\n zeroState?: React.JSX.Element\n}\n\nconst TransactionList: React.FC<TransactionListProps> = ({\n bgcolor,\n filter,\n height = 'calc(100dvh - 36px)',\n isRowDisabled,\n loader = <Loader label=\"Loading\" size={40} />,\n onClick,\n scrollsWithParent = false,\n showInsights = false,\n showLoader = false,\n stickyHeader,\n transaction,\n width = '100%',\n zeroState = <ZeroState />,\n}) => {\n const { isLoading, sortedTransactions: allTransactions } = useTransactionStore()\n const transactions = React.useMemo(() => {\n const updatedTransactions = filter ? allTransactions.filter(filter) : allTransactions\n return transaction ?? updatedTransactions\n }, [allTransactions, filter, transaction])\n\n const { clearExpandedSplits, setShowInsights, toggleSplit } = useTransactionsUiStore()\n const { onEvent } = useEvent()\n const { common: commonCopy } = useGlobalCopyStore()\n const [pendingFocus, setPendingFocus] = React.useState<{ index: number; from: number } | null>(\n null,\n )\n\n const handleClick = (guid: string) => {\n const transaction = transactions.find((t) => t.guid === guid)\n\n if (transaction?.has_been_split) {\n toggleSplit(transaction.guid)\n return\n }\n\n onEvent(ANALYTICS_EVENTS.ACCOUNT_DETAILS_CLICK_TRANSACTION, {\n account_guid: transaction?.account_guid,\n transaction_guid: guid,\n })\n onClick?.(guid)\n }\n\n const parentRef = React.useRef<HTMLDivElement>(null)\n const hasStickyHeader = Boolean(stickyHeader)\n const [scrollParent, setScrollParent] = React.useState<HTMLElement | null>(null)\n const [scrollMargin, setScrollMargin] = React.useState(0)\n const headerRef = React.useRef<HTMLDivElement>(null)\n const [headerHeight, setHeaderHeight] = React.useState(0)\n\n React.useLayoutEffect(() => {\n if (!scrollsWithParent) return\n const list = parentRef.current\n if (!list) return\n // With no scrolling ancestor the list itself is the viewport, so every row renders.\n const scroller = findScrollParent(list) ?? list\n\n const measureOffset = () => {\n setScrollMargin(\n list.getBoundingClientRect().top -\n scroller.getBoundingClientRect().top +\n scroller.scrollTop,\n )\n setHeaderHeight(headerRef.current?.offsetHeight ?? 0)\n }\n\n setScrollParent(scroller)\n measureOffset()\n const observer = new ResizeObserver(measureOffset)\n observer.observe(scroller.firstElementChild ?? scroller)\n if (headerRef.current) observer.observe(headerRef.current)\n return () => observer.disconnect()\n }, [scrollsWithParent, hasStickyHeader])\n\n const rowVirtualizer = useVirtualizer({\n count: transactions.length,\n getScrollElement: () => (scrollsWithParent ? scrollParent : parentRef.current),\n estimateSize: (i) => ROW_HEIGHT + (shouldShowDate(i, transactions) ? DATE_ROW_HEIGHT : 0),\n overscan: 5,\n scrollMargin,\n scrollPaddingStart: headerHeight,\n })\n\n const virtualItems = rowVirtualizer.getVirtualItems()\n const lastRenderedIndex = virtualItems.at(-1)?.index ?? -1\n const unrenderedCount = transactions.length - (lastRenderedIndex + 1)\n const isSettled = !isLoading && !showLoader\n const showRows = isSettled && virtualItems.length > 0\n\n // Screen reader reading modes do not scroll the list, so rows past the rendered window\n // are unreachable without this control.\n const showNextRows = () => {\n const nextIndex = lastRenderedIndex + 1\n rowVirtualizer.scrollToIndex(nextIndex, { align: 'start' })\n setPendingFocus({ index: nextIndex, from: lastRenderedIndex })\n }\n\n React.useEffect(() => {\n if (!pendingFocus) return\n const row = parentRef.current?.querySelector<HTMLElement>(\n `[data-index=\"${pendingFocus.index}\"]`,\n )\n row?.focus()\n // Give up once the window moves, so a missed row cannot take focus later.\n if (row || lastRenderedIndex !== pendingFocus.from) setPendingFocus(null)\n }, [pendingFocus, lastRenderedIndex])\n\n React.useEffect(() => rowVirtualizer.measure(), [transactions, scrollParent])\n React.useEffect(() => setShowInsights(showInsights), [showInsights])\n\n React.useEffect(() => {\n return () => clearExpandedSplits()\n }, [])\n\n return (\n <>\n {stickyHeader && (\n <Box\n ref={headerRef}\n sx={{\n bgcolor: 'background.paper',\n position: scrollsWithParent ? 'sticky' : undefined,\n top: 0,\n width,\n zIndex: 1,\n }}\n >\n {stickyHeader}\n </Box>\n )}\n <List component=\"div\" role=\"list\" sx={{ width: width }}>\n <Box\n height={scrollsWithParent ? undefined : height}\n overflow={scrollsWithParent ? undefined : 'auto'}\n ref={parentRef}\n role=\"presentation\"\n width={width}\n >\n <Box\n height={\n // set the height to auto when there are no transactions so the zero state isn't set to 0\n virtualItems.length === 0 ? 'auto' : rowVirtualizer.getTotalSize()\n }\n position=\"relative\"\n role=\"presentation\"\n width=\"100%\"\n >\n {!isSettled && loader}\n {isSettled && transactions.length === 0 && zeroState}\n {showRows &&\n virtualItems.map((row) => {\n const transaction = transactions[row.index]\n const showDate = shouldShowDate(row.index, transactions)\n const isInset = hasInsetBorder(row.index, transactions)\n const rowHeight = ROW_HEIGHT + (showDate ? DATE_ROW_HEIGHT : 0)\n\n return (\n <Box\n aria-posinset={row.index + 1}\n aria-setsize={transactions.length}\n data-index={row.index}\n key={transaction.guid}\n role=\"listitem\"\n tabIndex={-1}\n sx={{\n height: rowHeight,\n position: 'absolute',\n // Keeps a focused row from scrolling under the sticky header.\n scrollMarginTop: headerHeight,\n transform: `translateY(${row.start - scrollMargin}px)`,\n width: '100%',\n bgcolor: 'background.paper',\n }}\n >\n {showDate && (\n <SubheaderRow bgcolor={bgcolor}>\n {fromUnixUTCToDayOfWeekAndDate(transaction.date)}\n </SubheaderRow>\n )}\n <TransactionRow\n component=\"div\"\n disabled={isRowDisabled?.(transaction)}\n {...(onClick && { onClick: handleClick })}\n transaction={transaction}\n />\n <Divider sx={{ ml: isInset ? 68 : 0 }} />\n </Box>\n )\n })}\n </Box>\n </Box>\n </List>\n {showRows && unrenderedCount > 0 && (\n <Box\n component=\"button\"\n onClick={showNextRows}\n sx={VISUALLY_HIDDEN_SX}\n tabIndex={-1}\n type=\"button\"\n >\n {`${commonCopy.view_more} (${unrenderedCount})`}\n </Box>\n )}\n </>\n )\n}\n\nexport default observer(TransactionList)\n"],"mappings":";;;;;;;;;;;;;;;;;AA2BA,IAAM,IAAa,IACb,IAAkB,IAElB,KAAA,CAAoB,MAAiD;AACzE,WAAS,IAAK,GAAM,eAAe,GAAI,IAAK,EAAG,cAC7C,KAAI,gBAAgB,KAAK,iBAAiB,CAAE,EAAE,SAAS,EAAG,QAAO;AAEnE,SAAO;AACT,GAwBM,KAAA,CAAmD,EACvD,SAAA,GACA,QAAA,GACA,QAAA,IAAS,uBACT,eAAA,GACA,QAAA,IAAS,gBAAA,EAAC,IAAD;AAAA,EAAQ,OAAM;AAAA,EAAU,MAAM;AAAK,CAAA,GAC5C,SAAA,GACA,mBAAA,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UAAU;AAAA,gBACV,IAAI;AAAA,kBACF,QAAQ;AAAA,kBACR,UAAU;AAAA,kBAEV,iBAAiB;AAAA,kBACjB,WAAW,cAAc,EAAI,QAAQ,CAAA;AAAA,kBACrC,OAAO;AAAA,kBACP,SAAS;AAAA,gBACX;AAAA,gBAfF,UAAA;AAAA,kBAiBG,KACC,gBAAA,EAAC,IAAD;AAAA,oBAAuB,SAAA;AAAA,oBACpB,UAAA,GAA8B,EAAY,IAAI;AAAA,kBACnC,CAAA;AAAA,kBAEhB,gBAAA,EAAC,IAAD;AAAA,oBACE,WAAU;AAAA,oBACV,UAAU,IAAgB,CAAW;AAAA,oBACrC,GAAK,KAAW,EAAE,SAAS,EAAY;AAAA,oBAC1B,aAAA;AAAA,kBACd,CAAA;AAAA,kBACD,gBAAA,EAAC,IAAD,EAAS,IAAI,EAAE,IAAI,IAAU,KAAK,EAAE,EAAI,CAAA;AAAA,gBACrC;AAAA,cAzBE,GAAA,EAAY,IAyBd;AAAA,YAET,CAAC;AAAA,UACA;AAAA;MACF,CAAA;AAAA,IACD,CAAA;AAAA,IACL,KAAY,IAAkB,KAC7B,gBAAA,EAAC,GAAD;AAAA,MACE,WAAU;AAAA,MACV,SAAS;AAAA,MACT,IAAI;AAAA,MACJ,UAAU;AAAA,MACV,MAAK;AAAA,MAEJ,UAAA,GAAG,EAAW,SAAA,KAAc,CAAA;AAAA,IAC1B,CAAA;AAAA,EAEP,EAAA,CAAA;AAEN,GAEA,KAAe,GAAS,EAAe"}
@@ -1,8 +1,9 @@
1
1
  interface CategoryDetailChartProps {
2
2
  chartColor: string;
3
3
  chartLabel: string;
4
+ chartTitle: string;
4
5
  }
5
- declare const CategoryDetailChart: (({ chartLabel, chartColor }: CategoryDetailChartProps) => import("react/jsx-runtime").JSX.Element) & {
6
+ declare const CategoryDetailChart: (({ chartColor, chartLabel, chartTitle }: CategoryDetailChartProps) => import("react/jsx-runtime").JSX.Element) & {
6
7
  displayName: string;
7
8
  };
8
9
  export default CategoryDetailChart;
@@ -1,45 +1,65 @@
1
- import { useEvent as a, useTrendsStore as m } from "../../common/context/hooks.es.js";
2
- import { ANALYTICS_EVENTS as l } from "../../common/constants/Analytics.es.js";
3
- import { LineChart as u } from "../../common/components/charts/LineChart.es.js";
4
- import { TRENDS_ANALYTICS_METADATA as h } from "../constants/TrendsWidget.es.js";
5
- import { observer as n } from "mobx-react-lite";
6
- import A from "@mui/material/Stack";
7
- import { jsx as e } from "react/jsx-runtime";
8
- var f = n(({ chartLabel: r, chartColor: t }) => {
9
- const { onEvent: o } = a(), { categoryDetailsChartData: { monthlyAmounts: s, tooltipLabels: i } } = m();
10
- return /* @__PURE__ */ e(A, {
1
+ import { useEvent as T, useGlobalCopyStore as C, useTrendsStore as f } from "../../common/context/hooks.es.js";
2
+ import { formatCurrency as s } from "../../core/utils/NumberFormatting.es.js";
3
+ import { VISUALLY_HIDDEN_SX as w } from "../../common/constants/Styles.es.js";
4
+ import { ANALYTICS_EVENTS as S } from "../../common/constants/Analytics.es.js";
5
+ import { LineChart as x } from "../../common/components/charts/LineChart.es.js";
6
+ import { TRENDS_ANALYTICS_METADATA as g } from "../constants/TrendsWidget.es.js";
7
+ import { observer as v } from "mobx-react-lite";
8
+ import y from "@mui/material/Stack";
9
+ import { jsx as t, jsxs as r } from "react/jsx-runtime";
10
+ import m from "@mui/material/Box";
11
+ var e = "0,0", M = v(({ chartColor: o, chartLabel: n, chartTitle: a }) => {
12
+ const { onEvent: h } = T(), { common: l } = C(), { categoryDetailsChartData: { average: c, monthlyAmounts: d, monthlyTotals: p, tooltipLabels: u } } = f();
13
+ return /* @__PURE__ */ r(y, {
11
14
  sx: {
12
15
  pt: 12,
13
16
  width: "100%"
14
17
  },
15
- children: /* @__PURE__ */ e(u, {
16
- baseline: "min",
17
- colors: [t],
18
- curveType: "bump",
19
- customTooltipLabels: i,
20
- datasets: [s],
21
- height: 265,
22
- labels: [r],
23
- markStyles: () => ({ stroke: t }),
24
- onItemClick: () => {
25
- o(l.TRENDS_CLICK_CHART, h);
26
- },
27
- showArea: !0,
28
- showAverage: !0,
29
- showAxisHighlight: !0,
30
- showLegend: !0,
31
- showTooltip: !0,
32
- showXAxis: !0,
33
- showXAxisTicks: !0,
34
- showYAxis: !0,
35
- showYAxisTicks: !0,
36
- useCustomMark: !0,
37
- valueFormatterString: "0,0"
38
- })
18
+ children: [/* @__PURE__ */ t(m, {
19
+ "aria-hidden": !0,
20
+ children: /* @__PURE__ */ t(x, {
21
+ baseline: "min",
22
+ colors: [o],
23
+ curveType: "bump",
24
+ customTooltipLabels: u,
25
+ datasets: [d],
26
+ height: 265,
27
+ labels: [n],
28
+ markStyles: () => ({ stroke: o }),
29
+ onItemClick: () => {
30
+ h(S.TRENDS_CLICK_CHART, g);
31
+ },
32
+ showArea: !0,
33
+ showAverage: !0,
34
+ showAxisHighlight: !0,
35
+ showLegend: !0,
36
+ showTooltip: !0,
37
+ showXAxis: !0,
38
+ showXAxisTicks: !0,
39
+ showYAxis: !0,
40
+ showYAxisTicks: !0,
41
+ useCustomMark: !0,
42
+ valueFormatterString: e
43
+ })
44
+ }), /* @__PURE__ */ r(m, {
45
+ component: "table",
46
+ sx: w,
47
+ children: [
48
+ /* @__PURE__ */ t("caption", { children: a }),
49
+ /* @__PURE__ */ t("tbody", { children: p.map(({ amount: A, label: i }) => /* @__PURE__ */ r("tr", { children: [/* @__PURE__ */ t("th", {
50
+ scope: "row",
51
+ children: i
52
+ }), /* @__PURE__ */ t("td", { children: s(A, e) })] }, i)) }),
53
+ /* @__PURE__ */ t("tfoot", { children: /* @__PURE__ */ r("tr", { children: [/* @__PURE__ */ t("th", {
54
+ scope: "row",
55
+ children: l.average
56
+ }), /* @__PURE__ */ t("td", { children: s(c, e) })] }) })
57
+ ]
58
+ })]
39
59
  });
40
60
  });
41
61
  export {
42
- f as default
62
+ M as default
43
63
  };
44
64
 
45
65
  //# sourceMappingURL=CategoryDetailChart.es.js.map