@mx-cartographer/experiences 9.7.24 → 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.
- package/CHANGELOG.md +8 -0
- package/dist/common/components/MiniWidgetContainer.es.js +35 -45
- package/dist/common/components/MiniWidgetContainer.es.js.map +1 -1
- package/dist/common/components/charts/LineChart.es.js +86 -85
- package/dist/common/components/charts/LineChart.es.js.map +1 -1
- package/dist/common/constants/Styles.d.ts +2 -0
- package/dist/common/constants/Styles.es.js +17 -0
- package/dist/common/constants/Styles.es.js.map +1 -0
- package/dist/common/constants/index.d.ts +1 -0
- package/dist/common/hooks/useAriaLive.es.js +12 -22
- package/dist/common/hooks/useAriaLive.es.js.map +1 -1
- package/dist/common/index.es.js +111 -109
- package/dist/core/stores/TrendsStore.d.ts +5 -0
- package/dist/core/utils/DateUtil.d.ts +2 -0
- package/dist/core/utils/DateUtil.es.js +37 -35
- package/dist/core/utils/DateUtil.es.js.map +1 -1
- package/dist/core/utils/NumberFormatting.d.ts +1 -0
- package/dist/core/utils/NumberFormatting.es.js +14 -13
- package/dist/core/utils/NumberFormatting.es.js.map +1 -1
- package/dist/core/utils/TrendsUtil.d.ts +5 -0
- package/dist/core/utils/TrendsUtil.es.js +67 -59
- package/dist/core/utils/TrendsUtil.es.js.map +1 -1
- package/dist/insights-v2/components/BaseLayout.es.js +47 -48
- package/dist/insights-v2/components/BaseLayout.es.js.map +1 -1
- package/dist/transactions/components/shared/TransactionList.d.ts +4 -0
- package/dist/transactions/components/shared/TransactionList.es.js +138 -84
- package/dist/transactions/components/shared/TransactionList.es.js.map +1 -1
- package/dist/trends/components/CategoryDetailChart.d.ts +2 -1
- package/dist/trends/components/CategoryDetailChart.es.js +55 -35
- package/dist/trends/components/CategoryDetailChart.es.js.map +1 -1
- package/dist/trends/components/CategoryDetails.es.js +68 -71
- package/dist/trends/components/CategoryDetails.es.js.map +1 -1
- package/dist/trends/utils/TrendsTable.es.js +25 -25
- package/dist/trends/utils/TrendsTable.es.js.map +1 -1
- package/package.json +1 -1
|
@@ -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'
|
|
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,E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AA;AAAA,MACzD,CAAA;AAAA,IACH;AAAA;AAEX,CAAC"}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { buildDynamicCopy as
|
|
2
|
-
import { DATE_FORMATS_INTL as d, formatDate as
|
|
3
|
-
import {
|
|
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
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
},
|
|
12
|
-
const a =
|
|
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
|
-
},
|
|
14
|
+
}, M = (n, o) => {
|
|
15
15
|
const r = [], a = new Date(n);
|
|
16
16
|
for (; a <= o; ) {
|
|
17
|
-
const e =
|
|
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
|
-
},
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
61
|
+
sortComparator: u
|
|
62
62
|
};
|
|
63
63
|
return [
|
|
64
64
|
r,
|
|
65
65
|
...a,
|
|
66
66
|
e
|
|
67
67
|
];
|
|
68
|
-
},
|
|
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(
|
|
78
|
-
monthlyAmounts: m.reduce(
|
|
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(
|
|
82
|
+
const t = e.monthlyAmounts.reduce(h(a), 0);
|
|
83
83
|
t !== 0 && l.push({
|
|
84
84
|
id: `sub-${e.guid}`,
|
|
85
|
-
category:
|
|
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(
|
|
90
|
+
monthlyAmounts: e.monthlyAmounts.reduce(c, {})
|
|
91
91
|
});
|
|
92
92
|
}
|
|
93
93
|
return l;
|
|
94
94
|
};
|
|
95
95
|
export {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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 {
|
|
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,S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