@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 +1 @@
1
- {"version":3,"file":"CategoryDetailChart.es.js","names":[],"sources":["../../../src/trends/components/CategoryDetailChart.tsx"],"sourcesContent":["import { observer } from 'mobx-react-lite'\n\nimport Stack from '@mui/material/Stack'\n\nimport { ANALYTICS_EVENTS, useEvent, useTrendsStore } from '../../common'\nimport { LineChart } from '../../common/components/charts/LineChart'\n\nimport { TRENDS_ANALYTICS_METADATA } from '../constants/TrendsWidget'\ninterface CategoryDetailChartProps {\n chartColor: string\n chartLabel: string\n}\nconst CategoryDetailChart = observer(({ chartLabel, chartColor }: CategoryDetailChartProps) => {\n const { onEvent } = useEvent()\n const {\n categoryDetailsChartData: { monthlyAmounts, tooltipLabels },\n } = useTrendsStore()\n\n const handleItemClick = () => {\n onEvent(ANALYTICS_EVENTS.TRENDS_CLICK_CHART, TRENDS_ANALYTICS_METADATA)\n }\n\n return (\n <Stack sx={{ pt: 12, width: '100%' }}>\n <LineChart\n baseline=\"min\"\n colors={[chartColor]}\n curveType=\"bump\"\n customTooltipLabels={tooltipLabels}\n datasets={[monthlyAmounts]}\n height={265}\n labels={[chartLabel]}\n markStyles={() => ({\n stroke: chartColor,\n })}\n onItemClick={handleItemClick}\n showArea={true}\n showAverage={true}\n showAxisHighlight={true}\n showLegend={true}\n showTooltip={true}\n showXAxis={true}\n showXAxisTicks={true}\n showYAxis={true}\n showYAxisTicks={true}\n useCustomMark={true}\n valueFormatterString=\"0,0\"\n />\n </Stack>\n )\n})\nexport default CategoryDetailChart\n"],"mappings":";;;;;;;AAYA,IAAM,IAAsB,EAAA,CAAU,EAAE,YAAA,GAAY,YAAA,EAAA,MAA2C;AAC7F,QAAM,EAAE,SAAA,EAAA,IAAY,EAAS,GACvB,EACJ,0BAA0B,EAAE,gBAAA,GAAgB,eAAA,EAAA,EAAA,IAC1C,EAAe;AAMnB,SACE,gBAAA,EAAC,GAAD;AAAA,IAAO,IAAI;AAAA,MAAE,IAAI;AAAA,MAAI,OAAO;AAAA,IAAO;AAAA,IACjC,UAAA,gBAAA,EAAC,GAAD;AAAA,MACE,UAAS;AAAA,MACT,QAAQ,CAAC,CAAU;AAAA,MACnB,WAAU;AAAA,MACV,qBAAqB;AAAA,MACrB,UAAU,CAAC,CAAc;AAAA,MACzB,QAAQ;AAAA,MACR,QAAQ,CAAC,CAAU;AAAA,MACnB,YAAA,OAAmB,EACjB,QAAQ,EACV;AAAA,MACA,aAjBA,MAAwB;AAC5B,QAAA,EAAQ,EAAiB,oBAAoB,CAAyB;AAAA,MACxE;AAAA,MAgBM,UAAU;AAAA,MACV,aAAa;AAAA,MACb,mBAAmB;AAAA,MACnB,YAAY;AAAA,MACZ,aAAa;AAAA,MACb,WAAW;AAAA,MACX,gBAAgB;AAAA,MAChB,WAAW;AAAA,MACX,gBAAgB;AAAA,MAChB,eAAe;AAAA,MACf,sBAAqB;AAAA,IACtB,CAAA;AAAA,EACI,CAAA;AAEX,CAAC"}
1
+ {"version":3,"file":"CategoryDetailChart.es.js","names":[],"sources":["../../../src/trends/components/CategoryDetailChart.tsx"],"sourcesContent":["import { observer } from 'mobx-react-lite'\n\nimport Box from '@mui/material/Box'\nimport Stack from '@mui/material/Stack'\n\nimport {\n ANALYTICS_EVENTS,\n useEvent,\n useGlobalCopyStore,\n useTrendsStore,\n VISUALLY_HIDDEN_SX,\n} from '../../common'\nimport { LineChart } from '../../common/components/charts/LineChart'\nimport { formatCurrency } from '../../core/utils/NumberFormatting'\n\nimport { TRENDS_ANALYTICS_METADATA } from '../constants/TrendsWidget'\n\nconst VALUE_FORMAT = '0,0'\n\ninterface CategoryDetailChartProps {\n chartColor: string\n chartLabel: string\n chartTitle: string\n}\nconst CategoryDetailChart = observer(\n ({ chartColor, chartLabel, chartTitle }: CategoryDetailChartProps) => {\n const { onEvent } = useEvent()\n const { common: commonCopy } = useGlobalCopyStore()\n const {\n categoryDetailsChartData: { average, monthlyAmounts, monthlyTotals, tooltipLabels },\n } = useTrendsStore()\n\n const handleItemClick = () => {\n onEvent(ANALYTICS_EVENTS.TRENDS_CLICK_CHART, TRENDS_ANALYTICS_METADATA)\n }\n\n return (\n <Stack sx={{ pt: 12, width: '100%' }}>\n <Box aria-hidden={true}>\n <LineChart\n baseline=\"min\"\n colors={[chartColor]}\n curveType=\"bump\"\n customTooltipLabels={tooltipLabels}\n datasets={[monthlyAmounts]}\n height={265}\n labels={[chartLabel]}\n markStyles={() => ({\n stroke: chartColor,\n })}\n onItemClick={handleItemClick}\n showArea={true}\n showAverage={true}\n showAxisHighlight={true}\n showLegend={true}\n showTooltip={true}\n showXAxis={true}\n showXAxisTicks={true}\n showYAxis={true}\n showYAxisTicks={true}\n useCustomMark={true}\n valueFormatterString={VALUE_FORMAT}\n />\n </Box>\n <Box component=\"table\" sx={VISUALLY_HIDDEN_SX}>\n <caption>{chartTitle}</caption>\n <tbody>\n {monthlyTotals.map(({ amount, label }) => (\n <tr key={label}>\n <th scope=\"row\">{label}</th>\n <td>{formatCurrency(amount, VALUE_FORMAT)}</td>\n </tr>\n ))}\n </tbody>\n <tfoot>\n <tr>\n <th scope=\"row\">{commonCopy.average}</th>\n <td>{formatCurrency(average, VALUE_FORMAT)}</td>\n </tr>\n </tfoot>\n </Box>\n </Stack>\n )\n },\n)\nexport default CategoryDetailChart\n"],"mappings":";;;;;;;;;;AAiBA,IAAM,IAAe,OAOf,IAAsB,EAAA,CACzB,EAAE,YAAA,GAAY,YAAA,GAAY,YAAA,EAAA,MAA2C;AACpE,QAAM,EAAE,SAAA,EAAA,IAAY,EAAS,GACvB,EAAE,QAAQ,EAAA,IAAe,EAAmB,GAC5C,EACJ,0BAA0B,EAAE,SAAA,GAAS,gBAAA,GAAgB,eAAA,GAAe,eAAA,EAAA,EAAA,IAClE,EAAe;AAMnB,SACE,gBAAA,EAAC,GAAD;AAAA,IAAO,IAAI;AAAA,MAAE,IAAI;AAAA,MAAI,OAAO;AAAA,IAAO;AAAA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GACxC,gBAAA,EAAC,MAAD,EAAA,UAAK,EAAe,GAAS,CAAY,EAAM,CAAA,CAC7C,EAAA,CAAA,EACC,CAAA;AAAA,MACJ;AAAA,IACA,CAAA,CAAA;AAAA;AAEX,CACF"}
@@ -1,104 +1,101 @@
1
- import { useAppConfig as I, useGlobalCopyStore as k, useTransactionStore as A, useTrendsStore as G } from "../../common/context/hooks.es.js";
1
+ import { useAppConfig as k, useGlobalCopyStore as $, useTransactionStore as A, useTrendsStore as G } from "../../common/context/hooks.es.js";
2
2
  import { useScreenSize as R } from "../../common/hooks/useScreenSize.es.js";
3
3
  import { formatCurrency as j } from "../../core/utils/NumberFormatting.es.js";
4
4
  import z from "../../common/components/drawer/Drawer.es.js";
5
5
  import { getCategoryColor as M } from "../../core/utils/CategoryUtil.es.js";
6
- import $ from "../../transactions/components/transactionwidget/actions/ExportCsvAction.es.js";
7
- import B from "../../transactions/components/shared/TransactionList.es.js";
8
- import E from "../../transactions/components/shared/TransactionDetails.es.js";
9
- import F from "./CategoryDetailChart.es.js";
10
- import d from "react";
11
- import { observer as O } from "mobx-react-lite";
6
+ import B from "../../transactions/components/transactionwidget/actions/ExportCsvAction.es.js";
7
+ import E from "../../transactions/components/shared/TransactionList.es.js";
8
+ import P from "../../transactions/components/shared/TransactionDetails.es.js";
9
+ import W from "./CategoryDetailChart.es.js";
10
+ import u from "react";
11
+ import { observer as F } from "mobx-react-lite";
12
12
  import c from "@mui/material/Stack";
13
- import { CategoryIcon as P, Text as f } from "@mxenabled/mxui";
13
+ import { CategoryIcon as H, Text as h } from "@mxenabled/mxui";
14
14
  import { jsx as t, jsxs as i } from "react/jsx-runtime";
15
- import { useTheme as W } from "@mui/material/styles";
15
+ import { useTheme as O } from "@mui/material/styles";
16
16
  import q from "@mui/material/List";
17
- import H from "@mui/material/ListItem";
18
- import J from "@mui/material/ListItemAvatar";
19
- import K from "@mui/material/ListItemText";
20
- var dt = O(() => {
21
- const u = W(), { is_mobile_webview: h } = I(), { isDesktop: g, isSmallTablet: b, isTablet: y } = R(), { common: C, trends: o } = k(), { selectedCategoryData: e, selectedDateRangeMonthRange: x } = G(), { sortedTransactions: a } = A(), [m, l] = d.useState(null);
17
+ import J from "@mui/material/ListItem";
18
+ import K from "@mui/material/ListItemAvatar";
19
+ import N from "@mui/material/ListItemText";
20
+ var ft = F(() => {
21
+ const g = O(), { is_mobile_webview: y } = k(), { isDesktop: b, isSmallTablet: C, isTablet: _ } = R(), { common: x, trends: o } = $(), { selectedCategoryData: e, selectedDateRangeMonthRange: v } = G(), { sortedTransactions: a } = A(), [m, l] = u.useState(null);
22
22
  if (!e) return null;
23
- const { guid: r, name: v, is_income: _, totalAmount: S } = e, T = M(r, u), L = _ ? o.income_label : o.spending_label, w = ` ${e.transactions.length === 1 ? o.transaction : o.transactions} (${e.transactions.length})`, s = d.useMemo(() => a.find((n) => n.guid === m), [m, a]), D = a.length > 0 && !h && (g || y && !b), p = (n) => n.category_guid === r || n.top_level_category_guid === r;
23
+ const { guid: r, name: p, is_income: d, totalAmount: T } = e, S = M(r, g), L = d ? o.income_label : o.spending_label, w = `${p}, ${d ? o.monthly_income : o.monthly_spending}`, D = ` ${e.transactions.length === 1 ? o.transaction : o.transactions} (${e.transactions.length})`, s = u.useMemo(() => a.find((n) => n.guid === m), [m, a]), I = a.length > 0 && !y && (b || _ && !C), f = (n) => n.category_guid === r || n.top_level_category_guid === r;
24
24
  return /* @__PURE__ */ i(c, {
25
- sx: {
26
- alignItems: "center",
27
- height: "100%"
28
- },
25
+ sx: { alignItems: "center" },
29
26
  children: [
30
27
  /* @__PURE__ */ i(c, {
31
28
  sx: {
32
29
  bgcolor: "background.paper",
33
30
  borderRadius: 0,
34
- pb: 4,
35
31
  pt: 16,
36
32
  px: 12,
37
33
  width: "100%"
38
34
  },
39
- children: [
40
- /* @__PURE__ */ t(q, {
41
- sx: { px: 12 },
42
- children: /* @__PURE__ */ i(H, { children: [
43
- /* @__PURE__ */ t(J, { children: /* @__PURE__ */ t(P, { categoryGuid: r }) }),
44
- /* @__PURE__ */ t(K, {
45
- primary: v,
46
- secondary: x,
47
- slotProps: {
48
- primary: {
49
- component: "div",
50
- variant: "h3",
51
- fontSize: 18,
52
- fontWeight: 700
53
- },
54
- secondary: {
55
- component: "div",
56
- variant: "body2",
57
- fontSize: 13
58
- }
35
+ children: [/* @__PURE__ */ t(q, {
36
+ sx: { px: 12 },
37
+ children: /* @__PURE__ */ i(J, { children: [
38
+ /* @__PURE__ */ t(K, { children: /* @__PURE__ */ t(H, { categoryGuid: r }) }),
39
+ /* @__PURE__ */ t(N, {
40
+ primary: p,
41
+ secondary: v,
42
+ slotProps: {
43
+ primary: {
44
+ component: "div",
45
+ variant: "h3",
46
+ fontSize: 18,
47
+ fontWeight: 700
48
+ },
49
+ secondary: {
50
+ component: "div",
51
+ variant: "body2",
52
+ fontSize: 13
59
53
  }
60
- }),
61
- /* @__PURE__ */ t(f, {
62
- component: "div",
63
- variant: "h3",
64
- children: j(Math.abs(S), "0,0.00")
65
- })
66
- ] })
67
- }),
68
- /* @__PURE__ */ t(F, {
69
- chartColor: T,
70
- chartLabel: L
71
- }),
72
- /* @__PURE__ */ i(c, {
73
- alignItems: "center",
74
- direction: "row",
75
- justifyContent: "space-between",
76
- sx: { mx: 12 },
77
- children: [/* @__PURE__ */ t(f, {
78
- bold: !0,
79
- variant: "body1",
80
- children: w
81
- }), D && /* @__PURE__ */ t($, { filter: p })]
82
- })
83
- ]
54
+ }
55
+ }),
56
+ /* @__PURE__ */ t(h, {
57
+ component: "div",
58
+ variant: "h3",
59
+ children: j(Math.abs(T), "0,0.00")
60
+ })
61
+ ] })
62
+ }), /* @__PURE__ */ t(W, {
63
+ chartColor: S,
64
+ chartLabel: L,
65
+ chartTitle: w
66
+ })]
84
67
  }),
85
- /* @__PURE__ */ t(B, {
86
- filter: p,
87
- height: "calc(100vh - 475px)",
88
- onClick: l
68
+ /* @__PURE__ */ t(E, {
69
+ filter: f,
70
+ onClick: l,
71
+ scrollsWithParent: !0,
72
+ stickyHeader: /* @__PURE__ */ i(c, {
73
+ alignItems: "center",
74
+ direction: "row",
75
+ justifyContent: "space-between",
76
+ sx: {
77
+ px: 24,
78
+ py: 4
79
+ },
80
+ children: [/* @__PURE__ */ t(h, {
81
+ bold: !0,
82
+ variant: "body1",
83
+ children: D
84
+ }), I && /* @__PURE__ */ t(B, { filter: f })]
85
+ })
89
86
  }),
90
87
  /* @__PURE__ */ t(z, {
91
- ariaLabelClose: C.close_aria,
88
+ ariaLabelClose: x.close_aria,
92
89
  isOpen: !!s,
93
90
  onClose: () => l(""),
94
91
  title: o.transaction,
95
- children: s && /* @__PURE__ */ t(E, { transaction: s })
92
+ children: s && /* @__PURE__ */ t(P, { transaction: s })
96
93
  })
97
94
  ]
98
95
  });
99
96
  });
100
97
  export {
101
- dt as CategoryDetails
98
+ ft as CategoryDetails
102
99
  };
103
100
 
104
101
  //# sourceMappingURL=CategoryDetails.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CategoryDetails.es.js","names":[],"sources":["../../../src/trends/components/CategoryDetails.tsx"],"sourcesContent":["import React from 'react'\nimport { observer } from 'mobx-react-lite'\n\nimport List from '@mui/material/List'\nimport ListItem from '@mui/material/ListItem'\nimport ListItemAvatar from '@mui/material/ListItemAvatar'\nimport ListItemText from '@mui/material/ListItemText'\nimport Stack from '@mui/material/Stack'\nimport { useTheme } from '@mui/material/styles'\n\nimport { CategoryIcon, Text } from '@mxenabled/mxui'\n\nimport {\n Drawer,\n useAppConfig,\n useGlobalCopyStore,\n useTrendsStore,\n useTransactionStore,\n useScreenSize,\n} from '../../common'\nimport { type Transaction } from '../../core'\n\nimport { getCategoryColor } from '../../core/utils/CategoryUtil'\nimport { ExportCsvAction, TransactionDetails, TransactionList } from '../../transactions'\n\nimport CategoryDetailChart from './CategoryDetailChart'\nimport { formatCurrency } from '../../core/utils/NumberFormatting'\n\nexport const CategoryDetails = observer(() => {\n const theme = useTheme()\n const { is_mobile_webview } = useAppConfig()\n const { isDesktop, isSmallTablet, isTablet } = useScreenSize()\n const { common: commonCopy, trends: copy } = useGlobalCopyStore()\n const { selectedCategoryData, selectedDateRangeMonthRange } = useTrendsStore()\n const { sortedTransactions: transactions } = useTransactionStore()\n\n const [transactionGuid, setTransactionGuid] = React.useState<string | null>(null)\n\n if (!selectedCategoryData) {\n return null\n }\n\n const { guid, name, is_income, totalAmount } = selectedCategoryData\n\n const chartColor = getCategoryColor(guid, theme)\n const chartLabel = is_income ? copy.income_label : copy.spending_label\n const transactionCountLabel = ` ${\n selectedCategoryData.transactions.length === 1 ? copy.transaction : copy.transactions\n } (${selectedCategoryData.transactions.length})`\n\n const transaction = React.useMemo(\n () => transactions.find((t) => t.guid === transactionGuid),\n [transactionGuid, transactions],\n )\n\n const shouldShowExportButton =\n transactions.length > 0 && !is_mobile_webview && (isDesktop || (isTablet && !isSmallTablet))\n\n const categoryFilter = (t: Transaction) =>\n t.category_guid === guid || t.top_level_category_guid === guid\n\n return (\n <Stack sx={{ alignItems: 'center', height: '100%' }}>\n <Stack\n sx={{ bgcolor: 'background.paper', borderRadius: 0, pb: 4, pt: 16, px: 12, width: '100%' }}\n >\n <List sx={{ px: 12 }}>\n <ListItem>\n <ListItemAvatar>\n <CategoryIcon categoryGuid={guid} />\n </ListItemAvatar>\n <ListItemText\n primary={name}\n secondary={selectedDateRangeMonthRange}\n slotProps={{\n primary: { component: 'div', variant: 'h3', fontSize: 18, fontWeight: 700 },\n secondary: { component: 'div', variant: 'body2', fontSize: 13 },\n }}\n />\n <Text component=\"div\" variant=\"h3\">\n {formatCurrency(Math.abs(totalAmount), '0,0.00')}\n </Text>\n </ListItem>\n </List>\n\n <CategoryDetailChart chartColor={chartColor} chartLabel={chartLabel} />\n\n <Stack alignItems=\"center\" direction=\"row\" justifyContent=\"space-between\" sx={{ mx: 12 }}>\n <Text bold={true} variant=\"body1\">\n {transactionCountLabel}\n </Text>\n {shouldShowExportButton && <ExportCsvAction filter={categoryFilter} />}\n </Stack>\n </Stack>\n <TransactionList\n filter={categoryFilter}\n height=\"calc(100vh - 475px)\"\n onClick={setTransactionGuid}\n />\n <Drawer\n ariaLabelClose={commonCopy.close_aria}\n isOpen={Boolean(transaction)}\n onClose={() => setTransactionGuid('')}\n title={copy.transaction}\n >\n {transaction && <TransactionDetails transaction={transaction} />}\n </Drawer>\n </Stack>\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA4BA,IAAa,KAAkB,EAAA,MAAe;AAC5C,QAAM,IAAQ,EAAS,GACjB,EAAE,mBAAA,EAAA,IAAsB,EAAa,GACrC,EAAE,WAAA,GAAW,eAAA,GAAe,UAAA,EAAA,IAAa,EAAc,GACvD,EAAE,QAAQ,GAAY,QAAQ,EAAA,IAAS,EAAmB,GAC1D,EAAE,sBAAA,GAAsB,6BAAA,EAAA,IAAgC,EAAe,GACvE,EAAE,oBAAoB,EAAA,IAAiB,EAAoB,GAE3D,CAAC,GAAiB,CAAA,IAAsB,EAAM,SAAwB,IAAI;AAEhF,MAAI,CAAC,EACH,QAAO;AAGT,QAAM,EAAE,MAAA,GAAM,MAAA,GAAM,WAAA,GAAW,aAAA,EAAA,IAAgB,GAEzC,IAAa,EAAiB,GAAM,CAAK,GACzC,IAAa,IAAY,EAAK,eAAe,EAAK,gBAClD,IAAwB,IAC5B,EAAqB,aAAa,WAAW,IAAI,EAAK,cAAc,EAAK,YAAA,KACtE,EAAqB,aAAa,MAAA,KAEjC,IAAc,EAAM,QAAA,MAClB,EAAa,KAAA,CAAM,MAAM,EAAE,SAAS,CAAe,GACzD,CAAC,GAAiB,CAAY,CAChC,GAEM,IACJ,EAAa,SAAS,KAAK,CAAC,MAAsB,KAAc,KAAY,CAAC,IAEzE,IAAA,CAAkB,MACtB,EAAE,kBAAkB,KAAQ,EAAE,4BAA4B;AAE5D,SACE,gBAAA,EAAC,GAAD;AAAA,IAAO,IAAI;AAAA,MAAE,YAAY;AAAA,MAAU,QAAQ;AAAA,IAAO;AAAA,IAAlD,UAAA;AA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,KAA0B,gBAAA,EAAC,GAAD,EAAiB,QAAQ,EAAiB,CAAA,CAChE;AAAA;QACF;AAAA;MACP,gBAAA,EAAC,GAAD;AAAA,QACE,QAAQ;AAAA,QACR,QAAO;AAAA,QACP,SAAS;AAAA,MACV,CAAA;AAAA,MACD,gBAAA,EAAC,GAAD;AAAA,QACE,gBAAgB,EAAW;AAAA,QAC3B,QAAQ,EAAQ;AAAA,QAChB,SAAA,MAAe,EAAmB,EAAE;AAAA,QACpC,OAAO,EAAK;AAAA,QAEX,UAAA,KAAe,gBAAA,EAAC,GAAD,EAAiC,aAAA,EAAc,CAAA;AAAA,MACzD,CAAA;AAAA,IACH;AAAA;AAEX,CAAC"}
1
+ {"version":3,"file":"CategoryDetails.es.js","names":[],"sources":["../../../src/trends/components/CategoryDetails.tsx"],"sourcesContent":["import React from 'react'\nimport { observer } from 'mobx-react-lite'\n\nimport List from '@mui/material/List'\nimport ListItem from '@mui/material/ListItem'\nimport ListItemAvatar from '@mui/material/ListItemAvatar'\nimport ListItemText from '@mui/material/ListItemText'\nimport Stack from '@mui/material/Stack'\nimport { useTheme } from '@mui/material/styles'\n\nimport { CategoryIcon, Text } from '@mxenabled/mxui'\n\nimport {\n Drawer,\n useAppConfig,\n useGlobalCopyStore,\n useTrendsStore,\n useTransactionStore,\n useScreenSize,\n} from '../../common'\nimport { type Transaction } from '../../core'\n\nimport { getCategoryColor } from '../../core/utils/CategoryUtil'\nimport { ExportCsvAction, TransactionDetails, TransactionList } from '../../transactions'\n\nimport CategoryDetailChart from './CategoryDetailChart'\nimport { formatCurrency } from '../../core/utils/NumberFormatting'\n\nexport const CategoryDetails = observer(() => {\n const theme = useTheme()\n const { is_mobile_webview } = useAppConfig()\n const { isDesktop, isSmallTablet, isTablet } = useScreenSize()\n const { common: commonCopy, trends: copy } = useGlobalCopyStore()\n const { selectedCategoryData, selectedDateRangeMonthRange } = useTrendsStore()\n const { sortedTransactions: transactions } = useTransactionStore()\n\n const [transactionGuid, setTransactionGuid] = React.useState<string | null>(null)\n\n if (!selectedCategoryData) {\n return null\n }\n\n const { guid, name, is_income, totalAmount } = selectedCategoryData\n\n const chartColor = getCategoryColor(guid, theme)\n const chartLabel = is_income ? copy.income_label : copy.spending_label\n const chartTitle = `${name}, ${is_income ? copy.monthly_income : copy.monthly_spending}`\n const transactionCountLabel = ` ${\n selectedCategoryData.transactions.length === 1 ? copy.transaction : copy.transactions\n } (${selectedCategoryData.transactions.length})`\n\n const transaction = React.useMemo(\n () => transactions.find((t) => t.guid === transactionGuid),\n [transactionGuid, transactions],\n )\n\n const shouldShowExportButton =\n transactions.length > 0 && !is_mobile_webview && (isDesktop || (isTablet && !isSmallTablet))\n\n const categoryFilter = (t: Transaction) =>\n t.category_guid === guid || t.top_level_category_guid === guid\n\n return (\n <Stack sx={{ alignItems: 'center' }}>\n <Stack sx={{ bgcolor: 'background.paper', borderRadius: 0, pt: 16, px: 12, width: '100%' }}>\n <List sx={{ px: 12 }}>\n <ListItem>\n <ListItemAvatar>\n <CategoryIcon categoryGuid={guid} />\n </ListItemAvatar>\n <ListItemText\n primary={name}\n secondary={selectedDateRangeMonthRange}\n slotProps={{\n primary: { component: 'div', variant: 'h3', fontSize: 18, fontWeight: 700 },\n secondary: { component: 'div', variant: 'body2', fontSize: 13 },\n }}\n />\n <Text component=\"div\" variant=\"h3\">\n {formatCurrency(Math.abs(totalAmount), '0,0.00')}\n </Text>\n </ListItem>\n </List>\n\n <CategoryDetailChart\n chartColor={chartColor}\n chartLabel={chartLabel}\n chartTitle={chartTitle}\n />\n </Stack>\n <TransactionList\n filter={categoryFilter}\n onClick={setTransactionGuid}\n scrollsWithParent={true}\n stickyHeader={\n <Stack\n alignItems=\"center\"\n direction=\"row\"\n justifyContent=\"space-between\"\n sx={{ px: 24, py: 4 }}\n >\n <Text bold={true} variant=\"body1\">\n {transactionCountLabel}\n </Text>\n {shouldShowExportButton && <ExportCsvAction filter={categoryFilter} />}\n </Stack>\n }\n />\n <Drawer\n ariaLabelClose={commonCopy.close_aria}\n isOpen={Boolean(transaction)}\n onClose={() => setTransactionGuid('')}\n title={copy.transaction}\n >\n {transaction && <TransactionDetails transaction={transaction} />}\n </Drawer>\n </Stack>\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA4BA,IAAa,KAAkB,EAAA,MAAe;AAC5C,QAAM,IAAQ,EAAS,GACjB,EAAE,mBAAA,EAAA,IAAsB,EAAa,GACrC,EAAE,WAAA,GAAW,eAAA,GAAe,UAAA,EAAA,IAAa,EAAc,GACvD,EAAE,QAAQ,GAAY,QAAQ,EAAA,IAAS,EAAmB,GAC1D,EAAE,sBAAA,GAAsB,6BAAA,EAAA,IAAgC,EAAe,GACvE,EAAE,oBAAoB,EAAA,IAAiB,EAAoB,GAE3D,CAAC,GAAiB,CAAA,IAAsB,EAAM,SAAwB,IAAI;AAEhF,MAAI,CAAC,EACH,QAAO;AAGT,QAAM,EAAE,MAAA,GAAM,MAAA,GAAM,WAAA,GAAW,aAAA,EAAA,IAAgB,GAEzC,IAAa,EAAiB,GAAM,CAAK,GACzC,IAAa,IAAY,EAAK,eAAe,EAAK,gBAClD,IAAa,GAAG,CAAA,KAAS,IAAY,EAAK,iBAAiB,EAAK,gBAAA,IAChE,IAAwB,IAC5B,EAAqB,aAAa,WAAW,IAAI,EAAK,cAAc,EAAK,YAAA,KACtE,EAAqB,aAAa,MAAA,KAEjC,IAAc,EAAM,QAAA,MAClB,EAAa,KAAA,CAAM,MAAM,EAAE,SAAS,CAAe,GACzD,CAAC,GAAiB,CAAY,CAChC,GAEM,IACJ,EAAa,SAAS,KAAK,CAAC,MAAsB,KAAc,KAAY,CAAC,IAEzE,IAAA,CAAkB,MACtB,EAAE,kBAAkB,KAAQ,EAAE,4BAA4B;AAE5D,SACE,gBAAA,EAAC,GAAD;AAAA,IAAO,IAAI,EAAE,YAAY,SAAS;AAAA,IAAlC,UAAA;AAAA,MACE,gBAAA,EAAC,GAAD;AAAA,QAAO,IAAI;AAAA,UAAE,S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vB,UAAA;AAAA,UACG,CAAA,GACL,KAA0B,gBAAA,EAAC,GAAD,EAAiB,QAAQ,EAAiB,CAAA,CAChE;AAAA;MAEV,CAAA;AAAA,MACD,gBAAA,EAAC,GAAD;AAAA,QACE,gBAAgB,EAAW;AAAA,QAC3B,QAAQ,EAAQ;AAAA,QAChB,SAAA,MAAe,EAAmB,EAAE;AAAA,QACpC,OAAO,EAAK;AAAA,QAEX,UAAA,KAAe,gBAAA,EAAC,GAAD,EAAiC,aAAA,EAAc,CAAA;AAAA,MACzD,CAAA;AAAA,IACH;AAAA;AAEX,CAAC"}
@@ -1,24 +1,24 @@
1
- import { buildDynamicCopy as g } from "../../core/utils/Localization.es.js";
2
- import { DATE_FORMATS_INTL as d, formatDate as u } from "../../core/constants/DateFormats.es.js";
3
- import { amountComparator as i, categoryComparator as p } from "../../core/utils/TrendsUtil.es.js";
1
+ import { buildDynamicCopy as _ } from "../../core/utils/Localization.es.js";
2
+ import { DATE_FORMATS_INTL as d, formatDate as g } from "../../core/constants/DateFormats.es.js";
3
+ import { formatIsoDate as f } from "../../core/utils/DateUtil.es.js";
4
+ import { amountComparator as u, categoryComparator as p } from "../../core/utils/TrendsUtil.es.js";
4
5
  import { HeaderCell as s } from "../components/trendstable/HeaderCell.es.js";
5
6
  import { CategoryCell as b } from "../components/trendstable/CategoryCell.es.js";
6
- import { AmountCell as c } from "../components/trendstable/AmountCell.es.js";
7
- import { parseISO as _ } from "date-fns/parseISO";
8
- var h = (n, o) => {
9
- const r = u(_(o.isoDate), d.MONTH_LONG);
7
+ import { AmountCell as i } from "../components/trendstable/AmountCell.es.js";
8
+ var c = (n, o) => {
9
+ const r = f(o.isoDate, d.MONTH_LONG);
10
10
  return n[r] = o.amount, n;
11
- }, f = (n) => (o, r) => {
12
- const a = u(_(r.isoDate), d.MONTH_LONG);
11
+ }, h = (n) => (o, r) => {
12
+ const a = f(r.isoDate, d.MONTH_LONG);
13
13
  return o + (n.includes(a) ? r.amount : 0);
14
- }, O = (n, o) => {
14
+ }, M = (n, o) => {
15
15
  const r = [], a = new Date(n);
16
16
  for (; a <= o; ) {
17
- const e = u(a, d.MONTH_LONG);
17
+ const e = g(a, d.MONTH_LONG);
18
18
  r.push(e), a.setMonth(a.getMonth() + 1);
19
19
  }
20
20
  return r;
21
- }, D = (n, o) => {
21
+ }, H = (n, o) => {
22
22
  const r = {
23
23
  field: "category",
24
24
  flex: 1,
@@ -37,13 +37,13 @@ var h = (n, o) => {
37
37
  headerName: l,
38
38
  minWidth: 100,
39
39
  renderHeader: s,
40
- renderCell: c,
40
+ renderCell: i,
41
41
  align: "center",
42
42
  headerAlign: "center",
43
43
  sortable: !0,
44
44
  hideSortIcons: !1,
45
45
  type: "number",
46
- sortComparator: i,
46
+ sortComparator: u,
47
47
  valueGetter: (t, m) => m.monthlyAmounts?.[l] ?? 0
48
48
  })), e = {
49
49
  field: "total",
@@ -52,20 +52,20 @@ var h = (n, o) => {
52
52
  headerName: o.table_column_total,
53
53
  minWidth: 100,
54
54
  renderHeader: s,
55
- renderCell: c,
55
+ renderCell: i,
56
56
  align: "center",
57
57
  headerAlign: "center",
58
58
  sortable: !0,
59
59
  hideSortIcons: !1,
60
60
  type: "number",
61
- sortComparator: i
61
+ sortComparator: u
62
62
  };
63
63
  return [
64
64
  r,
65
65
  ...a,
66
66
  e
67
67
  ];
68
- }, H = (n, o, r, a, e) => {
68
+ }, O = (n, o, r, a, e) => {
69
69
  const l = n.filter((t) => t.is_income === r).map((t) => {
70
70
  let m = t.totalMonthlyAmounts;
71
71
  return e && (m = t.monthlyAmounts), {
@@ -74,28 +74,28 @@ var h = (n, o) => {
74
74
  category_guid: t.guid,
75
75
  isParent: !1,
76
76
  top_level_category_guid: t.parent_guid || t.guid,
77
- total: m.reduce(f(a), 0),
78
- monthlyAmounts: m.reduce(h, {})
77
+ total: m.reduce(h(a), 0),
78
+ monthlyAmounts: m.reduce(c, {})
79
79
  };
80
80
  });
81
81
  if (e && e.is_income === r) {
82
- const t = e.monthlyAmounts.reduce(f(a), 0);
82
+ const t = e.monthlyAmounts.reduce(h(a), 0);
83
83
  t !== 0 && l.push({
84
84
  id: `sub-${e.guid}`,
85
- category: g(o.category_general, e.name),
85
+ category: _(o.category_general, e.name),
86
86
  category_guid: e.guid,
87
87
  isParent: !0,
88
88
  top_level_category_guid: e.guid,
89
89
  total: t,
90
- monthlyAmounts: e.monthlyAmounts.reduce(h, {})
90
+ monthlyAmounts: e.monthlyAmounts.reduce(c, {})
91
91
  });
92
92
  }
93
93
  return l;
94
94
  };
95
95
  export {
96
- O as generateMonthHeaders,
97
- D as getTrendsTableColumns,
98
- H as getTrendsTableRows
96
+ M as generateMonthHeaders,
97
+ H as getTrendsTableColumns,
98
+ O as getTrendsTableRows
99
99
  };
100
100
 
101
101
  //# sourceMappingURL=TrendsTable.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TrendsTable.es.js","names":[],"sources":["../../../src/trends/utils/TrendsTable.ts"],"sourcesContent":["import { parseISO } from 'date-fns/parseISO'\nimport { GridColDef } from '@mui/x-data-grid-pro'\nimport { HeaderCell } from '../components/trendstable/HeaderCell'\nimport { CategoryCell } from '../components/trendstable/CategoryCell'\nimport { amountComparator, categoryComparator } from '../../core/utils/TrendsUtil'\nimport { AmountCell } from '../components/trendstable/AmountCell'\nimport { DATE_FORMATS_INTL, formatDate } from '../../core/constants'\nimport { DetailedCategory, type MonthlyAmount, TrendsCopy } from '../../core'\nimport { buildDynamicCopy } from '../../core/utils/Localization'\n\nconst amountsReducer = (records: Record<string, number>, monthlyAmount: MonthlyAmount) => {\n const monthHeader = formatDate(parseISO(monthlyAmount.isoDate), DATE_FORMATS_INTL.MONTH_LONG)\n records[monthHeader] = monthlyAmount.amount\n return records\n}\n\nconst totalReducer = (monthHeaders: string[]) => (sum: number, ma: MonthlyAmount) => {\n const monthHeader = formatDate(parseISO(ma.isoDate), DATE_FORMATS_INTL.MONTH_LONG)\n return sum + (monthHeaders.includes(monthHeader) ? ma.amount : 0)\n}\n\nexport const generateMonthHeaders = (start: Date, end: Date): string[] => {\n const result: string[] = []\n const current = new Date(start)\n\n while (current <= end) {\n const formattedDate = formatDate(current, DATE_FORMATS_INTL.MONTH_LONG)\n result.push(formattedDate)\n current.setMonth(current.getMonth() + 1)\n }\n\n return result\n}\n\nexport const getTrendsTableColumns = (monthHeaders: string[], copy: TrendsCopy) => {\n const categoryColumn: GridColDef = {\n field: 'category',\n flex: 1,\n headerClassName: 'trends-table-header',\n headerName: copy.category_title,\n minWidth: 210,\n renderHeader: HeaderCell,\n renderCell: CategoryCell,\n sortable: true,\n sortComparator: categoryComparator,\n type: 'string',\n }\n\n const monthColumns: GridColDef[] = monthHeaders.map((monthHeader) => ({\n field: monthHeader,\n flex: 1,\n headerClassName: 'trends-table-header',\n headerName: monthHeader,\n minWidth: 100,\n renderHeader: HeaderCell,\n renderCell: AmountCell,\n align: 'center',\n headerAlign: 'center',\n sortable: true,\n hideSortIcons: false,\n type: 'number',\n sortComparator: amountComparator,\n valueGetter: (_value: unknown, row: TrendsTableRow) => row.monthlyAmounts?.[monthHeader] ?? 0,\n }))\n\n const totalColumn: GridColDef = {\n field: 'total',\n flex: 1,\n headerClassName: 'trends-table-header',\n headerName: copy.table_column_total,\n minWidth: 100,\n renderHeader: HeaderCell,\n renderCell: AmountCell,\n align: 'center',\n headerAlign: 'center',\n sortable: true,\n hideSortIcons: false,\n type: 'number',\n sortComparator: amountComparator,\n }\n\n return [categoryColumn, ...monthColumns, totalColumn]\n}\n\nexport type TrendsTableRow = {\n id: string\n category: string\n category_guid: string\n isParent: boolean\n top_level_category_guid: string\n total: number\n monthlyAmounts: Record<string, number>\n}\n\nexport const getTrendsTableRows = (\n categories: DetailedCategory[],\n copy: TrendsCopy,\n isIncome: boolean,\n monthHeaders: string[],\n parentCategory?: DetailedCategory,\n): TrendsTableRow[] => {\n const categoryRows = categories\n .filter((category) => category.is_income === isIncome)\n .map((category) => {\n let amounts = category.totalMonthlyAmounts\n if (parentCategory) {\n amounts = category.monthlyAmounts\n }\n\n return {\n id: category.guid,\n category: category.name,\n category_guid: category.guid,\n isParent: false,\n top_level_category_guid: category.parent_guid || category.guid,\n total: amounts.reduce(totalReducer(monthHeaders), 0),\n monthlyAmounts: amounts.reduce(amountsReducer, {}),\n }\n })\n\n // Add General category row when viewing sub-categories\n if (parentCategory && parentCategory.is_income === isIncome) {\n const total = parentCategory.monthlyAmounts.reduce(totalReducer(monthHeaders), 0)\n if (total !== 0) {\n categoryRows.push({\n id: `sub-${parentCategory.guid}`,\n category: buildDynamicCopy(copy.category_general, parentCategory.name) as string,\n category_guid: parentCategory.guid,\n isParent: true,\n top_level_category_guid: parentCategory.guid,\n total,\n monthlyAmounts: parentCategory.monthlyAmounts.reduce(amountsReducer, {}),\n })\n }\n }\n\n return categoryRows\n}\n"],"mappings":";;;;;;;AAUA,IAAM,IAAA,CAAkB,GAAiC,MAAiC;AACxF,QAAM,IAAc,EAAW,EAAS,EAAc,OAAO,GAAG,EAAkB,UAAU;AAC5F,SAAA,EAAQ,CAAA,IAAe,EAAc,QAC9B;AACT,GAEM,IAAA,CAAgB,MAAA,CAA4B,GAAa,MAAsB;AACnF,QAAM,IAAc,EAAW,EAAS,EAAG,OAAO,GAAG,EAAkB,UAAU;AACjF,SAAO,KAAO,EAAa,SAAS,CAAW,IAAI,EAAG,SAAS;AACjE,GAEa,IAAA,CAAwB,GAAa,MAAwB;AACxE,QAAM,IAAmB,CAAC,GACpB,IAAU,IAAI,KAAK,CAAK;AAE9B,SAAO,KAAW,KAAK;AACrB,UAAM,IAAgB,EAAW,GAAS,EAAkB,UAAU;AACtE,IAAA,EAAO,KAAK,CAAa,GACzB,EAAQ,SAAS,EAAQ,SAAS,IAAI,CAAC;AAAA,EACzC;AAEA,SAAO;AACT,GAEa,IAAA,CAAyB,GAAwB,MAAqB;AACjF,QAAM,IAA6B;AAAA,IACjC,OAAO;AAAA,IACP,MAAM;AAAA,IACN,iBAAiB;AAAA,IACjB,YAAY,EAAK;A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,IACnD;AAAA,EACF,CAAC;AAGH,MAAI,KAAkB,EAAe,cAAc,GAAU;AAC3D,UAAM,IAAQ,EAAe,eAAe,OAAO,EAAa,CAAY,GAAG,CAAC;AAChF,IAAI,MAAU,KACZ,EAAa,KAAK;AAAA,MAChB,IAAI,OAAO,EAAe,IAAA;AAAA,MAC1B,UAAU,EAAiB,EAAK,kBAAkB,EAAe,IAAI;AAAA,MACrE,eAAe,EAAe;AAAA,MAC9B,UAAU;AAAA,MACV,yBAAyB,EAAe;AAAA,MACxC,OAAA;AAAA,MACA,gBAAgB,EAAe,eAAe,OAAO,GAAgB,CAAC,CAAC;AAAA,IACzE,CAAC;AAAA,EAEL;AAEA,SAAO;AACT"}
1
+ {"version":3,"file":"TrendsTable.es.js","names":[],"sources":["../../../src/trends/utils/TrendsTable.ts"],"sourcesContent":["import { GridColDef } from '@mui/x-data-grid-pro'\nimport { HeaderCell } from '../components/trendstable/HeaderCell'\nimport { CategoryCell } from '../components/trendstable/CategoryCell'\nimport { amountComparator, categoryComparator } from '../../core/utils/TrendsUtil'\nimport { AmountCell } from '../components/trendstable/AmountCell'\nimport { DATE_FORMATS_INTL, formatDate } from '../../core/constants'\nimport { formatIsoDate } from '../../core/utils/DateUtil'\nimport { DetailedCategory, type MonthlyAmount, TrendsCopy } from '../../core'\nimport { buildDynamicCopy } from '../../core/utils/Localization'\n\nconst amountsReducer = (records: Record<string, number>, monthlyAmount: MonthlyAmount) => {\n const monthHeader = formatIsoDate(monthlyAmount.isoDate, DATE_FORMATS_INTL.MONTH_LONG)\n records[monthHeader] = monthlyAmount.amount\n return records\n}\n\nconst totalReducer = (monthHeaders: string[]) => (sum: number, ma: MonthlyAmount) => {\n const monthHeader = formatIsoDate(ma.isoDate, DATE_FORMATS_INTL.MONTH_LONG)\n return sum + (monthHeaders.includes(monthHeader) ? ma.amount : 0)\n}\n\nexport const generateMonthHeaders = (start: Date, end: Date): string[] => {\n const result: string[] = []\n const current = new Date(start)\n\n while (current <= end) {\n const formattedDate = formatDate(current, DATE_FORMATS_INTL.MONTH_LONG)\n result.push(formattedDate)\n current.setMonth(current.getMonth() + 1)\n }\n\n return result\n}\n\nexport const getTrendsTableColumns = (monthHeaders: string[], copy: TrendsCopy) => {\n const categoryColumn: GridColDef = {\n field: 'category',\n flex: 1,\n headerClassName: 'trends-table-header',\n headerName: copy.category_title,\n minWidth: 210,\n renderHeader: HeaderCell,\n renderCell: CategoryCell,\n sortable: true,\n sortComparator: categoryComparator,\n type: 'string',\n }\n\n const monthColumns: GridColDef[] = monthHeaders.map((monthHeader) => ({\n field: monthHeader,\n flex: 1,\n headerClassName: 'trends-table-header',\n headerName: monthHeader,\n minWidth: 100,\n renderHeader: HeaderCell,\n renderCell: AmountCell,\n align: 'center',\n headerAlign: 'center',\n sortable: true,\n hideSortIcons: false,\n type: 'number',\n sortComparator: amountComparator,\n valueGetter: (_value: unknown, row: TrendsTableRow) => row.monthlyAmounts?.[monthHeader] ?? 0,\n }))\n\n const totalColumn: GridColDef = {\n field: 'total',\n flex: 1,\n headerClassName: 'trends-table-header',\n headerName: copy.table_column_total,\n minWidth: 100,\n renderHeader: HeaderCell,\n renderCell: AmountCell,\n align: 'center',\n headerAlign: 'center',\n sortable: true,\n hideSortIcons: false,\n type: 'number',\n sortComparator: amountComparator,\n }\n\n return [categoryColumn, ...monthColumns, totalColumn]\n}\n\nexport type TrendsTableRow = {\n id: string\n category: string\n category_guid: string\n isParent: boolean\n top_level_category_guid: string\n total: number\n monthlyAmounts: Record<string, number>\n}\n\nexport const getTrendsTableRows = (\n categories: DetailedCategory[],\n copy: TrendsCopy,\n isIncome: boolean,\n monthHeaders: string[],\n parentCategory?: DetailedCategory,\n): TrendsTableRow[] => {\n const categoryRows = categories\n .filter((category) => category.is_income === isIncome)\n .map((category) => {\n let amounts = category.totalMonthlyAmounts\n if (parentCategory) {\n amounts = category.monthlyAmounts\n }\n\n return {\n id: category.guid,\n category: category.name,\n category_guid: category.guid,\n isParent: false,\n top_level_category_guid: category.parent_guid || category.guid,\n total: amounts.reduce(totalReducer(monthHeaders), 0),\n monthlyAmounts: amounts.reduce(amountsReducer, {}),\n }\n })\n\n // Add General category row when viewing sub-categories\n if (parentCategory && parentCategory.is_income === isIncome) {\n const total = parentCategory.monthlyAmounts.reduce(totalReducer(monthHeaders), 0)\n if (total !== 0) {\n categoryRows.push({\n id: `sub-${parentCategory.guid}`,\n category: buildDynamicCopy(copy.category_general, parentCategory.name) as string,\n category_guid: parentCategory.guid,\n isParent: true,\n top_level_category_guid: parentCategory.guid,\n total,\n monthlyAmounts: parentCategory.monthlyAmounts.reduce(amountsReducer, {}),\n })\n }\n }\n\n return categoryRows\n}\n"],"mappings":";;;;;;;AAUA,IAAM,IAAA,CAAkB,GAAiC,MAAiC;AACxF,QAAM,IAAc,EAAc,EAAc,SAAS,EAAkB,UAAU;AACrF,SAAA,EAAQ,CAAA,IAAe,EAAc,QAC9B;AACT,GAEM,IAAA,CAAgB,MAAA,CAA4B,GAAa,MAAsB;AACnF,QAAM,IAAc,EAAc,EAAG,SAAS,EAAkB,UAAU;AAC1E,SAAO,KAAO,EAAa,SAAS,CAAW,IAAI,EAAG,SAAS;AACjE,GAEa,IAAA,CAAwB,GAAa,MAAwB;AACxE,QAAM,IAAmB,CAAC,GACpB,IAAU,IAAI,KAAK,CAAK;AAE9B,SAAO,KAAW,KAAK;AACrB,UAAM,IAAgB,EAAW,GAAS,EAAkB,UAAU;AACtE,IAAA,EAAO,KAAK,CAAa,GACzB,EAAQ,SAAS,EAAQ,SAAS,IAAI,CAAC;AAAA,EACzC;AAEA,SAAO;AACT,GAEa,IAAA,CAAyB,GAAwB,MAAqB;AACjF,QAAM,IAA6B;AAAA,IACjC,OAAO;AAAA,IACP,MAAM;AAAA,IACN,iBAAiB;AAAA,IACjB,YAAY,EAAK;AAAA,IACjB,UAAU;AAAA,IACV,cAAc;AAAA,IACd,YAAY;AAAA,IACZ,UAAU;AAAA,IACV,gBAAgB;AAAA,IAChB,MAAM;AAA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Y,GAAG,CAAC;AAChF,IAAI,MAAU,KACZ,EAAa,KAAK;AAAA,MAChB,IAAI,OAAO,EAAe,IAAA;AAAA,MAC1B,UAAU,EAAiB,EAAK,kBAAkB,EAAe,IAAI;AAAA,MACrE,eAAe,EAAe;AAAA,MAC9B,UAAU;AAAA,MACV,yBAAyB,EAAe;AAAA,MACxC,OAAA;AAAA,MACA,gBAAgB,EAAe,eAAe,OAAO,GAAgB,CAAC,CAAC;AAAA,IACzE,CAAC;AAAA,EAEL;AAEA,SAAO;AACT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mx-cartographer/experiences",
3
- "version": "9.7.25",
3
+ "version": "9.7.26",
4
4
  "description": "Library containing experience widgets",
5
5
  "author": "MX",
6
6
  "license": "MIT",