@mx-cartographer/experiences 9.4.37 → 9.4.39
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/ListItemRow.d.ts +1 -1
- package/dist/common/components/ListItemRow.es.js.map +1 -1
- package/dist/common/components/charts/LineChart.d.ts +2 -0
- package/dist/common/components/charts/LineChart.es.js +120 -109
- package/dist/common/components/charts/LineChart.es.js.map +1 -1
- package/dist/core/stores/TrendsStore.d.ts +2 -0
- package/dist/core/stores/TrendsStore.es.js +24 -15
- package/dist/core/stores/TrendsStore.es.js.map +1 -1
- package/dist/trends/TrendsWidget.es.js +131 -128
- package/dist/trends/TrendsWidget.es.js.map +1 -1
- package/dist/trends/components/CategoriesListItem.es.js +34 -29
- package/dist/trends/components/CategoriesListItem.es.js.map +1 -1
- package/dist/trends/components/TrendsChartTotals.es.js +45 -37
- package/dist/trends/components/TrendsChartTotals.es.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { useEvent as
|
|
2
|
-
import { useScreenSize as
|
|
3
|
-
import { ANALYTICS_EVENTS as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
1
|
+
import { useEvent as E, useGlobalCopyStore as H } from "../../common/context/hooks.es.js";
|
|
2
|
+
import { useScreenSize as I } from "../../common/hooks/useScreenSize.es.js";
|
|
3
|
+
import { ANALYTICS_EVENTS as N } from "../../common/constants/Analytics.es.js";
|
|
4
|
+
import { useDimensions as D } from "../../common/hooks/useDimensions.es.js";
|
|
5
|
+
import { LineChart as M } from "../../common/components/charts/LineChart.es.js";
|
|
6
|
+
import { getIncomeTotals as k, getSpendingTotals as R } from "../utils/SpendingData.es.js";
|
|
7
|
+
import { TRENDS_ANALYTICS_METADATA as X } from "../constants/TrendsWidget.es.js";
|
|
8
|
+
import p from "react";
|
|
9
|
+
import { observer as Y } from "mobx-react-lite";
|
|
10
|
+
import { jsx as T } from "react/jsx-runtime";
|
|
11
|
+
import { useTheme as y } from "@mui/material/styles";
|
|
12
|
+
import B from "@mui/material/Box";
|
|
13
|
+
var W = 12, O = 380, j = (t, e) => [k(t, e), R(t, e)].filter((o) => o.length > 0), z = (t, e) => {
|
|
12
14
|
const [o, c] = t, s = o, l = c ?? o, r = [];
|
|
13
15
|
if (s) {
|
|
14
16
|
const a = s.reduce((n, i) => n + i.y, 0);
|
|
@@ -25,34 +27,40 @@ var N = (t, e) => [I(t, e), _(t, e)].filter((o) => o.length > 0), y = (t, e) =>
|
|
|
25
27
|
});
|
|
26
28
|
}
|
|
27
29
|
return r;
|
|
28
|
-
},
|
|
29
|
-
const s =
|
|
30
|
-
return
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
}, [t]), /* @__PURE__ */
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
30
|
+
}, F = ({ availableHeight: t = 0, minHeight: e = 500, selectedDateRange: o, totals: c }) => {
|
|
31
|
+
const s = y(), { onEvent: l } = E(), { trends: r } = H(), { isSmallMobile: a, isMobile: n, isSmallTablet: i, isTablet: d } = I(), [A, { width: u }] = D(), f = [s.palette.chart?.chart1, s.palette.chart?.chart2], h = j(c, o), b = z(h, r), g = Math.max(0, ...h.map((m) => m.length)), C = u > 0 && u <= O && g >= W, [S, w] = p.useState(0), x = 458, _ = 195, L = 56, v = n || a ? _ : i || d ? x : S;
|
|
32
|
+
return p.useEffect(() => {
|
|
33
|
+
const m = Math.max(t - L, e);
|
|
34
|
+
w(m);
|
|
35
|
+
}, [t]), /* @__PURE__ */ T(B, {
|
|
36
|
+
ref: A,
|
|
37
|
+
sx: { width: "100%" },
|
|
38
|
+
children: /* @__PURE__ */ T(M, {
|
|
39
|
+
baseline: "min",
|
|
40
|
+
colors: f,
|
|
41
|
+
curveType: "bump",
|
|
42
|
+
datasets: h,
|
|
43
|
+
height: v,
|
|
44
|
+
labels: b,
|
|
45
|
+
narrowXAxisLabels: C,
|
|
46
|
+
onItemClick: () => {
|
|
47
|
+
l(N.TRENDS_CLICK_CHART, X);
|
|
48
|
+
},
|
|
49
|
+
showAllXAxisLabels: !0,
|
|
50
|
+
showArea: !0,
|
|
51
|
+
showAxisHighlight: !0,
|
|
52
|
+
showLegend: !0,
|
|
53
|
+
showTooltip: !0,
|
|
54
|
+
showXAxis: !0,
|
|
55
|
+
showXAxisTicks: !0,
|
|
56
|
+
showYAxis: !0,
|
|
57
|
+
showYAxisTicks: !0,
|
|
58
|
+
valueFormatterString: "0.0a"
|
|
59
|
+
})
|
|
52
60
|
});
|
|
53
|
-
},
|
|
61
|
+
}, st = Y(F);
|
|
54
62
|
export {
|
|
55
|
-
|
|
63
|
+
st as default
|
|
56
64
|
};
|
|
57
65
|
|
|
58
66
|
//# sourceMappingURL=TrendsChartTotals.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TrendsChartTotals.es.js","names":[],"sources":["../../../src/trends/components/TrendsChartTotals.tsx"],"sourcesContent":["import React from 'react'\nimport { observer } from 'mobx-react-lite'\n\nimport { useTheme } from '@mui/material/styles'\n\nimport { ANALYTICS_EVENTS, useEvent, useGlobalCopyStore, useScreenSize } from '../../common'\nimport { DateRange, MonthlyCategoryTotals, TrendsCopy } from '../../core'\nimport { LineChart } from '../../common/components/charts/LineChart'\nimport type { LineChartDataset, LineChartLabel } from '../../common/components/charts/LineChart'\n\nimport { TRENDS_ANALYTICS_METADATA } from '../constants/TrendsWidget'\nimport { getIncomeTotals, getSpendingTotals } from '../utils/SpendingData'\n\nconst getDatasets = (totals: MonthlyCategoryTotals[], dateRange: DateRange): LineChartDataset[] => {\n const incomeData = getIncomeTotals(totals, dateRange)\n const spendingData = getSpendingTotals(totals, dateRange)\n return [incomeData, spendingData].filter((data) => data.length > 0)\n}\n\nconst getLabels = (datasets: LineChartDataset[], copy: TrendsCopy) => {\n const [dataA, dataB] = datasets\n const credits = dataA\n const debits = dataB ?? dataA\n const labels: LineChartLabel[] = []\n\n if (credits) {\n const totalIncome = credits.reduce((sum, item) => sum + item.y, 0)\n labels.push({ label: copy.income_label, amount: totalIncome })\n }\n\n if (debits) {\n const totalSpending = debits.reduce((sum, item) => sum + item.y, 0)\n labels.push({ label: copy.spending_label, amount: totalSpending })\n }\n\n return labels\n}\n\ninterface TrendsChartTotalsProps {\n availableHeight?: number\n minHeight?: number\n selectedDateRange: DateRange\n totals: MonthlyCategoryTotals[]\n}\n\nconst TrendsChartTotals: React.FC<TrendsChartTotalsProps> = ({\n availableHeight = 0,\n minHeight = 500,\n selectedDateRange,\n totals,\n}) => {\n const theme = useTheme()\n const { onEvent } = useEvent()\n const { trends: trendsCopy } = useGlobalCopyStore()\n const { isSmallMobile, isMobile, isSmallTablet, isTablet } = useScreenSize()\n\n const colors = [theme.palette.chart?.chart1, theme.palette.chart?.chart2]\n const datasets = getDatasets(totals, selectedDateRange)\n const labels = getLabels(datasets, trendsCopy)\n\n const [chartDesktopHeight, setChartDesktopHeight] = React.useState<number>(0)\n const chartTabletHeight = 458\n const chartMobileHeight = 195\n const legendHeight = 56\n\n // prettier-ignore\n // eslint-disable-next-line no-nested-ternary\n const chartHeight = (isMobile || isSmallMobile) ? chartMobileHeight :\n (isSmallTablet || isTablet) ? chartTabletHeight : chartDesktopHeight;\n\n // Control responsive chart height based on available height\n React.useEffect(() => {\n const newChartHeight = Math.max(availableHeight - legendHeight, minHeight)\n setChartDesktopHeight(newChartHeight)\n }, [availableHeight])\n\n const handleItemClick = () => {\n onEvent(ANALYTICS_EVENTS.TRENDS_CLICK_CHART, TRENDS_ANALYTICS_METADATA)\n }\n\n return (\n <LineChart\n
|
|
1
|
+
{"version":3,"file":"TrendsChartTotals.es.js","names":[],"sources":["../../../src/trends/components/TrendsChartTotals.tsx"],"sourcesContent":["import React from 'react'\nimport { observer } from 'mobx-react-lite'\n\nimport Box from '@mui/material/Box'\nimport { useTheme } from '@mui/material/styles'\n\nimport { ANALYTICS_EVENTS, useEvent, useGlobalCopyStore, useScreenSize } from '../../common'\nimport { DateRange, MonthlyCategoryTotals, TrendsCopy } from '../../core'\nimport { useDimensions } from '../../common/hooks/useDimensions'\nimport { LineChart } from '../../common/components/charts/LineChart'\nimport type { LineChartDataset, LineChartLabel } from '../../common/components/charts/LineChart'\n\nimport { TRENDS_ANALYTICS_METADATA } from '../constants/TrendsWidget'\nimport { getIncomeTotals, getSpendingTotals } from '../utils/SpendingData'\n\n// Single-letter month labels only kick in for the 12-month (1 Year) view once\n// the chart container is this narrow; wider containers keep full labels.\nconst MONTHS_IN_YEAR = 12\nconst NARROW_LABELS_MAX_WIDTH_PX = 380\n\nconst getDatasets = (totals: MonthlyCategoryTotals[], dateRange: DateRange): LineChartDataset[] => {\n const incomeData = getIncomeTotals(totals, dateRange)\n const spendingData = getSpendingTotals(totals, dateRange)\n return [incomeData, spendingData].filter((data) => data.length > 0)\n}\n\nconst getLabels = (datasets: LineChartDataset[], copy: TrendsCopy) => {\n const [dataA, dataB] = datasets\n const credits = dataA\n const debits = dataB ?? dataA\n const labels: LineChartLabel[] = []\n\n if (credits) {\n const totalIncome = credits.reduce((sum, item) => sum + item.y, 0)\n labels.push({ label: copy.income_label, amount: totalIncome })\n }\n\n if (debits) {\n const totalSpending = debits.reduce((sum, item) => sum + item.y, 0)\n labels.push({ label: copy.spending_label, amount: totalSpending })\n }\n\n return labels\n}\n\ninterface TrendsChartTotalsProps {\n availableHeight?: number\n minHeight?: number\n selectedDateRange: DateRange\n totals: MonthlyCategoryTotals[]\n}\n\nconst TrendsChartTotals: React.FC<TrendsChartTotalsProps> = ({\n availableHeight = 0,\n minHeight = 500,\n selectedDateRange,\n totals,\n}) => {\n const theme = useTheme()\n const { onEvent } = useEvent()\n const { trends: trendsCopy } = useGlobalCopyStore()\n const { isSmallMobile, isMobile, isSmallTablet, isTablet } = useScreenSize()\n const [chartRef, { width: chartWidth }] = useDimensions()\n\n const colors = [theme.palette.chart?.chart1, theme.palette.chart?.chart2]\n const datasets = getDatasets(totals, selectedDateRange)\n const labels = getLabels(datasets, trendsCopy)\n\n // Measured from the chart container, not the device, so it also handles the\n // widget embedded in a small iframe on a larger screen.\n const monthCount = Math.max(0, ...datasets.map((data) => data.length))\n const useNarrowXAxisLabels =\n chartWidth > 0 && chartWidth <= NARROW_LABELS_MAX_WIDTH_PX && monthCount >= MONTHS_IN_YEAR\n\n const [chartDesktopHeight, setChartDesktopHeight] = React.useState<number>(0)\n const chartTabletHeight = 458\n const chartMobileHeight = 195\n const legendHeight = 56\n\n // prettier-ignore\n // eslint-disable-next-line no-nested-ternary\n const chartHeight = (isMobile || isSmallMobile) ? chartMobileHeight :\n (isSmallTablet || isTablet) ? chartTabletHeight : chartDesktopHeight;\n\n // Control responsive chart height based on available height\n React.useEffect(() => {\n const newChartHeight = Math.max(availableHeight - legendHeight, minHeight)\n setChartDesktopHeight(newChartHeight)\n }, [availableHeight])\n\n const handleItemClick = () => {\n onEvent(ANALYTICS_EVENTS.TRENDS_CLICK_CHART, TRENDS_ANALYTICS_METADATA)\n }\n\n return (\n <Box ref={chartRef} sx={{ width: '100%' }}>\n <LineChart\n baseline=\"min\"\n colors={colors}\n curveType=\"bump\"\n datasets={datasets}\n height={chartHeight}\n labels={labels}\n narrowXAxisLabels={useNarrowXAxisLabels}\n onItemClick={handleItemClick}\n showAllXAxisLabels={true}\n showArea={true}\n showAxisHighlight={true}\n showLegend={true}\n showTooltip={true}\n showXAxis={true}\n showXAxisTicks={true}\n showYAxis={true}\n showYAxisTicks={true}\n valueFormatterString=\"0.0a\"\n />\n </Box>\n )\n}\n\nexport default observer(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