@mx-cartographer/experiences 9.7.117 → 9.7.119
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 +12 -0
- package/dist/cashflow/CashflowMiniWidget.es.js +53 -19
- package/dist/cashflow/CashflowMiniWidget.es.js.map +1 -1
- package/dist/cashflow/components/CashflowWidgetContent.d.ts +1 -0
- package/dist/cashflow/components/CashflowWidgetContent.es.js +173 -137
- package/dist/cashflow/components/CashflowWidgetContent.es.js.map +1 -1
- package/dist/cashflow/components/RemainingCash.d.ts +1 -0
- package/dist/cashflow/components/RemainingCash.es.js +10 -9
- package/dist/cashflow/components/RemainingCash.es.js.map +1 -1
- package/dist/common/components/InformationTooltip.d.ts +1 -0
- package/dist/common/components/InformationTooltip.es.js +16 -16
- package/dist/common/components/InformationTooltip.es.js.map +1 -1
- package/dist/common/components/MiniWidgetContainer.d.ts +13 -0
- package/dist/common/components/MiniWidgetContainer.es.js +63 -55
- package/dist/common/components/MiniWidgetContainer.es.js.map +1 -1
- package/dist/common/components/charts/LineChart.d.ts +5 -1
- package/dist/common/components/charts/LineChart.es.js +124 -122
- package/dist/common/components/charts/LineChart.es.js.map +1 -1
- package/dist/common/components/charts/linechart/CustomLegend.es.js +53 -46
- package/dist/common/components/charts/linechart/CustomLegend.es.js.map +1 -1
- package/dist/common/components/charts/linechart/CustomMark.d.ts +2 -0
- package/dist/common/components/charts/linechart/CustomMark.es.js +72 -35
- package/dist/common/components/charts/linechart/CustomMark.es.js.map +1 -1
- package/dist/common/components/drawer/Drawer.d.ts +3 -0
- package/dist/common/components/drawer/Drawer.es.js +30 -29
- package/dist/common/components/drawer/Drawer.es.js.map +1 -1
- package/dist/common/components/drawer/Header.d.ts +3 -0
- package/dist/common/components/drawer/Header.es.js +51 -45
- package/dist/common/components/drawer/Header.es.js.map +1 -1
- package/dist/core/stores/InsightsV2Store.d.ts +10 -0
- package/dist/core/stores/InsightsV2Store.es.js +15 -7
- package/dist/core/stores/InsightsV2Store.es.js.map +1 -1
- package/dist/core/types/localization/CashflowCopy.d.ts +1 -0
- package/dist/core/types/localization/TrendsCopy.d.ts +1 -0
- package/dist/insights-v2/actionBlocks/ActionBlockLayer.es.js +44 -33
- package/dist/insights-v2/actionBlocks/ActionBlockLayer.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.d.ts +1 -9
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.es.js +96 -83
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/CreateBudgetDialog.d.ts +5 -0
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/CreateBudgetDialog.es.js +62 -0
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/CreateBudgetDialog.es.js.map +1 -0
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetDetailsBlock.es.js +212 -145
- package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetDetailsBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetSummary.d.ts +3 -1
- package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetSummary.es.js +36 -36
- package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetSummary.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/layout.d.ts +32 -2
- package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/layout.es.js +68 -22
- package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/useBudgetDetailsPrepare.d.ts +3 -0
- package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/useBudgetDetailsPrepare.es.js +34 -0
- package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/useBudgetDetailsPrepare.es.js.map +1 -0
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js +61 -61
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.d.ts +1 -0
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js +42 -40
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistoryPrepare.es.js +3 -3
- package/dist/insights-v2/actionBlocks/util.d.ts +2 -11
- package/dist/insights-v2/actionBlocks/util.es.js +16 -6
- package/dist/insights-v2/actionBlocks/util.es.js.map +1 -1
- package/dist/insights-v2/analytics/analyticsEventsConfig.d.ts +16 -0
- package/dist/insights-v2/analytics/analyticsEventsConfig.es.js +19 -2
- package/dist/insights-v2/analytics/analyticsEventsConfig.es.js.map +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/BarchartBlock.es.js +8 -8
- package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/BarchartBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/utils.d.ts +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/utils.es.js +28 -27
- package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/utils.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/AccountBlock.es.js +4 -4
- package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/TransactionBlock.es.js +4 -4
- package/dist/insights-v2/blocks/ImageBlocks/SVGImageBlock/SVGImageBlock.es.js +4 -4
- package/dist/insights-v2/components/BaseLayout.es.js +137 -118
- package/dist/insights-v2/components/BaseLayout.es.js.map +1 -1
- package/dist/insights-v2/mappings/blocks.d.ts +1 -0
- package/dist/insights-v2/mappings/blocks.es.js +131 -121
- package/dist/insights-v2/mappings/blocks.es.js.map +1 -1
- package/dist/trends/TrendsMiniWidget.es.js +29 -22
- package/dist/trends/TrendsMiniWidget.es.js.map +1 -1
- package/dist/trends/components/SpendingChart.es.js +53 -17
- package/dist/trends/components/SpendingChart.es.js.map +1 -1
- package/dist/trends/utils/SpendingData.d.ts +2 -0
- package/dist/trends/utils/SpendingData.es.js +70 -43
- package/dist/trends/utils/SpendingData.es.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,43 +1,50 @@
|
|
|
1
|
-
import { useAccountStore as
|
|
2
|
-
import { useWidgetLoadTimer as
|
|
1
|
+
import { useAccountStore as c, useCategoryStore as f, useGlobalCopyStore as u, useGlobalStore as p, useGlobalUiStore as y } from "../common/context/hooks.es.js";
|
|
2
|
+
import { useWidgetLoadTimer as g } from "../common/hooks/useWidgetLoadTimer.es.js";
|
|
3
3
|
import h from "../common/components/MiniWidgetContainer.es.js";
|
|
4
4
|
import b from "../common/components/Loader.es.js";
|
|
5
|
-
import
|
|
5
|
+
import x from "./components/SpendingChart.es.js";
|
|
6
6
|
import n from "react";
|
|
7
|
-
import { observer as
|
|
8
|
-
import { jsx as
|
|
9
|
-
var
|
|
10
|
-
const { isAccountDataLoaded: t, loadAccountData: d } =
|
|
7
|
+
import { observer as C } from "mobx-react-lite";
|
|
8
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
9
|
+
var L = ({ onPrimaryCtaClick: l, sx: s }) => {
|
|
10
|
+
const { isAccountDataLoaded: t, loadAccountData: d } = c(), { loadMonthlyCategoryTotals: m, monthlyTotalsLoaded: r } = f(), { isInitialized: e } = p(), { trends: i } = u(), { selectedAccounts: a } = y();
|
|
11
11
|
return n.useEffect(() => {
|
|
12
12
|
t || d().finally();
|
|
13
|
-
}, []),
|
|
13
|
+
}, []), g({
|
|
14
14
|
widgetName: "TrendsMiniWidget",
|
|
15
15
|
isLoaded: r
|
|
16
16
|
}), n.useEffect(() => {
|
|
17
|
-
e && t &&
|
|
17
|
+
e && t && m(a).finally();
|
|
18
18
|
}, [
|
|
19
19
|
t,
|
|
20
20
|
e,
|
|
21
21
|
a
|
|
22
|
-
]), !t || !e || !r ? /* @__PURE__ */
|
|
22
|
+
]), !t || !e || !r ? /* @__PURE__ */ o(b, {}) : /* @__PURE__ */ o(h, {
|
|
23
23
|
contentStyles: {
|
|
24
|
-
|
|
25
|
-
minHeight:
|
|
26
|
-
"
|
|
24
|
+
flex: 1,
|
|
25
|
+
minHeight: 0,
|
|
26
|
+
"&:last-child": { pb: 0 }
|
|
27
|
+
},
|
|
28
|
+
onPrimaryCtaClick: l,
|
|
29
|
+
primaryCtaLabel: i.primary_cta,
|
|
30
|
+
subTitle: i.mini_sub_title,
|
|
31
|
+
heightLimits: {
|
|
32
|
+
min: 320,
|
|
33
|
+
max: 360
|
|
27
34
|
},
|
|
28
|
-
onPrimaryCtaClick: s,
|
|
29
|
-
primaryCtaLabel: o.primary_cta,
|
|
30
|
-
subTitle: o.sub_title,
|
|
31
35
|
sx: {
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
display: "flex",
|
|
37
|
+
flexDirection: "column",
|
|
38
|
+
minWidth: 288,
|
|
39
|
+
maxWidth: 848,
|
|
40
|
+
...s
|
|
34
41
|
},
|
|
35
|
-
title:
|
|
36
|
-
children: /* @__PURE__ */
|
|
42
|
+
title: i.mini_title,
|
|
43
|
+
children: /* @__PURE__ */ o(x, {})
|
|
37
44
|
});
|
|
38
|
-
},
|
|
45
|
+
}, G = C(L);
|
|
39
46
|
export {
|
|
40
|
-
|
|
47
|
+
G as default
|
|
41
48
|
};
|
|
42
49
|
|
|
43
50
|
//# sourceMappingURL=TrendsMiniWidget.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TrendsMiniWidget.es.js","names":[],"sources":["../../src/trends/TrendsMiniWidget.tsx"],"sourcesContent":["import React from 'react'\nimport { observer } from 'mobx-react-lite'\n\nimport {\n Loader,\n MiniWidgetContainer,\n useAccountStore,\n useCategoryStore,\n useGlobalCopyStore,\n useGlobalStore,\n useGlobalUiStore,\n useWidgetLoadTimer,\n} from '../common'\nimport { MiniWidgetProps } from '../core'\n\nimport SpendingChart from './components/SpendingChart'\n\nconst TrendsMiniWidget: React.FC<MiniWidgetProps> = ({ onPrimaryCtaClick, sx }) => {\n const { isAccountDataLoaded, loadAccountData } = useAccountStore()\n const { loadMonthlyCategoryTotals, monthlyTotalsLoaded } = useCategoryStore()\n const { isInitialized } = useGlobalStore()\n const { trends: trendsCopy } = useGlobalCopyStore()\n const { selectedAccounts } = useGlobalUiStore()\n\n React.useEffect(() => {\n if (!isAccountDataLoaded) {\n loadAccountData().finally()\n }\n }, [])\n\n useWidgetLoadTimer({\n widgetName: 'TrendsMiniWidget',\n isLoaded: monthlyTotalsLoaded,\n })\n\n React.useEffect(() => {\n if (isInitialized && isAccountDataLoaded) {\n loadMonthlyCategoryTotals(selectedAccounts).finally()\n }\n }, [isAccountDataLoaded, isInitialized, selectedAccounts])\n\n if (!isAccountDataLoaded || !isInitialized || !monthlyTotalsLoaded) {\n return <Loader />\n }\n\n return (\n <MiniWidgetContainer\n contentStyles={{
|
|
1
|
+
{"version":3,"file":"TrendsMiniWidget.es.js","names":[],"sources":["../../src/trends/TrendsMiniWidget.tsx"],"sourcesContent":["import React from 'react'\nimport { observer } from 'mobx-react-lite'\n\nimport {\n Loader,\n MiniWidgetContainer,\n useAccountStore,\n useCategoryStore,\n useGlobalCopyStore,\n useGlobalStore,\n useGlobalUiStore,\n useWidgetLoadTimer,\n} from '../common'\nimport { MiniWidgetProps } from '../core'\n\nimport SpendingChart from './components/SpendingChart'\n\nconst TrendsMiniWidget: React.FC<MiniWidgetProps> = ({ onPrimaryCtaClick, sx }) => {\n const { isAccountDataLoaded, loadAccountData } = useAccountStore()\n const { loadMonthlyCategoryTotals, monthlyTotalsLoaded } = useCategoryStore()\n const { isInitialized } = useGlobalStore()\n const { trends: trendsCopy } = useGlobalCopyStore()\n const { selectedAccounts } = useGlobalUiStore()\n\n React.useEffect(() => {\n if (!isAccountDataLoaded) {\n loadAccountData().finally()\n }\n }, [])\n\n useWidgetLoadTimer({\n widgetName: 'TrendsMiniWidget',\n isLoaded: monthlyTotalsLoaded,\n })\n\n React.useEffect(() => {\n if (isInitialized && isAccountDataLoaded) {\n loadMonthlyCategoryTotals(selectedAccounts).finally()\n }\n }, [isAccountDataLoaded, isInitialized, selectedAccounts])\n\n if (!isAccountDataLoaded || !isInitialized || !monthlyTotalsLoaded) {\n return <Loader />\n }\n\n return (\n <MiniWidgetContainer\n contentStyles={{ flex: 1, minHeight: 0, '&:last-child': { pb: 0 } }}\n onPrimaryCtaClick={onPrimaryCtaClick}\n primaryCtaLabel={trendsCopy.primary_cta}\n subTitle={trendsCopy.mini_sub_title}\n heightLimits={{ min: 320, max: 360 }}\n sx={{ display: 'flex', flexDirection: 'column', minWidth: 288, maxWidth: 848, ...sx }}\n title={trendsCopy.mini_title}\n >\n <SpendingChart />\n </MiniWidgetContainer>\n )\n}\n\nexport default observer(TrendsMiniWidget)\n"],"mappings":";;;;;;;;AAiBA,IAAM,IAAA,CAA+C,EAAE,mBAAA,GAAmB,IAAA,EAAA,MAAS;AACjF,QAAM,EAAE,qBAAA,GAAqB,iBAAA,EAAA,IAAoB,EAAgB,GAC3D,EAAE,2BAAA,GAA2B,qBAAA,EAAA,IAAwB,EAAiB,GACtE,EAAE,eAAA,EAAA,IAAkB,EAAe,GACnC,EAAE,QAAQ,EAAA,IAAe,EAAmB,GAC5C,EAAE,kBAAA,EAAA,IAAqB,EAAiB;AAmB9C,SAjBA,EAAM,UAAA,MAAgB;AACpB,IAAK,KACH,EAAgB,EAAE,QAAQ;AAAA,EAE9B,GAAG,CAAC,CAAC,GAEL,EAAmB;AAAA,IACjB,YAAY;AAAA,IACZ,UAAU;AAAA,EACZ,CAAC,GAED,EAAM,UAAA,MAAgB;AACpB,IAAI,KAAiB,KACnB,EAA0B,CAAgB,EAAE,QAAQ;AAAA,EAExD,GAAG;AAAA,IAAC;AAAA,IAAqB;AAAA,IAAe;AAAA,EAAgB,CAAC,GAErD,CAAC,KAAuB,CAAC,KAAiB,CAAC,IACtC,gBAAA,EAAC,GAAD,CAAS,CAAA,IAIhB,gBAAA,EAAC,GAAD;AAAA,IACE,eAAe;AAAA,MAAE,MAAM;AAAA,MAAG,WAAW;AAAA,MAAG,gBAAgB,EAAE,IAAI,EAAE;AAAA,IAAE;AAAA,IAC/C,mBAAA;AAAA,IACnB,iBAAiB,EAAW;AAAA,IAC5B,UAAU,EAAW;AAAA,IACrB,cAAc;AAAA,MAAE,KAAK;AAAA,MAAK,KAAK;AAAA,IAAI;AAAA,IACnC,IAAI;AAAA,MAAE,SAAS;AAAA,MAAQ,eAAe;AAAA,MAAU,UAAU;AAAA,MAAK,UAAU;AAAA,MAAK,GAAG;AAAA,IAAG;AAAA,IACpF,OAAO,EAAW;AAAA,IAElB,UAAA,gBAAA,EAAC,GAAD,CAAgB,CAAA;AAAA,EACG,CAAA;AAEzB,GAEA,IAAe,EAAS,CAAgB"}
|
|
@@ -1,28 +1,64 @@
|
|
|
1
|
-
import { useCategoryStore as
|
|
2
|
-
import { LineChart as
|
|
3
|
-
import { getSpendingData as
|
|
4
|
-
import
|
|
5
|
-
import { observer as
|
|
6
|
-
import { jsx as
|
|
7
|
-
import { useTheme as
|
|
8
|
-
var
|
|
9
|
-
const { monthlyCategoryTotals:
|
|
10
|
-
|
|
1
|
+
import { useCategoryStore as p, useGlobalCopyStore as m, useWidgetContainerProvider as d } from "../../common/context/hooks.es.js";
|
|
2
|
+
import { LineChart as g } from "../../common/components/charts/LineChart.es.js";
|
|
3
|
+
import { formatSpendingYAxisLabel as c, getSpendingData as u, getSpendingYAxisTicks as h } from "../utils/SpendingData.es.js";
|
|
4
|
+
import x from "react";
|
|
5
|
+
import { observer as y } from "mobx-react-lite";
|
|
6
|
+
import { jsx as b } from "react/jsx-runtime";
|
|
7
|
+
import { getOverlayAlpha as S, lighten as f, useTheme as k } from "@mui/material/styles";
|
|
8
|
+
var C = 246, v = () => {
|
|
9
|
+
const { monthlyCategoryTotals: r } = p(), { trends: s } = m(), e = k(), { availableHeight: l = 0 } = d(), o = x.useMemo(() => u(r), [r]), a = h(o.map((t) => t.y)), i = e.palette.mode === "dark" ? f(e.palette.background.paper, S(1)) : e.palette.background.paper, n = (t) => ({
|
|
10
|
+
"& .MuiChartsAxis-tickLabel": {
|
|
11
|
+
fill: e.palette.text.secondary,
|
|
12
|
+
transform: t
|
|
13
|
+
},
|
|
14
|
+
"& .MuiChartsAxis-tickLabel tspan": { fontSize: e.typography.caption.fontSize }
|
|
15
|
+
});
|
|
16
|
+
return /* @__PURE__ */ b(g, {
|
|
17
|
+
areaGradientColor: e.palette.primary[500],
|
|
18
|
+
averageLineStyle: {
|
|
19
|
+
stroke: e.palette.grey[500],
|
|
20
|
+
strokeDasharray: "8, 8",
|
|
21
|
+
strokeLinecap: "round"
|
|
22
|
+
},
|
|
23
|
+
axisColor: e.palette.divider,
|
|
11
24
|
baseline: "min",
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
25
|
+
chartXaxisSx: n("translateY(11px)"),
|
|
26
|
+
chartYaxisSx: n("translateX(-2px)"),
|
|
27
|
+
colors: [e.palette.primary.main],
|
|
28
|
+
customLegendBoxSx: { borderRadius: "2px" },
|
|
29
|
+
customLegendSx: {
|
|
30
|
+
left: 24,
|
|
31
|
+
top: 4
|
|
32
|
+
},
|
|
33
|
+
customLegendVariant: "caption",
|
|
34
|
+
datasets: [o],
|
|
35
|
+
height: Math.max(l, C),
|
|
36
|
+
labelBackgroundColor: i,
|
|
37
|
+
labelFontSize: Number(e.typography.body2.fontSize),
|
|
38
|
+
labels: [s.spending_label],
|
|
39
|
+
margin: {
|
|
40
|
+
bottom: 28,
|
|
41
|
+
left: -4,
|
|
42
|
+
right: 24,
|
|
43
|
+
top: 64
|
|
44
|
+
},
|
|
45
|
+
markStyles: () => ({ fill: i }),
|
|
46
|
+
markVariant: "compact",
|
|
47
|
+
maxRange: a[2],
|
|
48
|
+
minRange: 0,
|
|
16
49
|
showArea: !0,
|
|
17
50
|
showAverage: !0,
|
|
18
51
|
showLegend: !0,
|
|
19
52
|
showMarkLabel: !0,
|
|
53
|
+
showXAxis: !0,
|
|
54
|
+
tickIntervals: a,
|
|
20
55
|
useCustomMark: !0,
|
|
21
|
-
valueFormatterString: "0,0"
|
|
56
|
+
valueFormatterString: "0,0",
|
|
57
|
+
yAxisValueFormatter: (t) => c(t, a[2])
|
|
22
58
|
});
|
|
23
|
-
},
|
|
59
|
+
}, H = y(v);
|
|
24
60
|
export {
|
|
25
|
-
|
|
61
|
+
H as default
|
|
26
62
|
};
|
|
27
63
|
|
|
28
64
|
//# sourceMappingURL=SpendingChart.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SpendingChart.es.js","names":[],"sources":["../../../src/trends/components/SpendingChart.tsx"],"sourcesContent":["import React from 'react'\nimport { observer } from 'mobx-react-lite'\n\nimport { useTheme } from '@mui/material/styles'\n\nimport { useCategoryStore, useGlobalCopyStore, useWidgetContainerProvider } from '../../common'\nimport { LineChart } from '../../common/components/charts/LineChart'\n\nimport {
|
|
1
|
+
{"version":3,"file":"SpendingChart.es.js","names":[],"sources":["../../../src/trends/components/SpendingChart.tsx"],"sourcesContent":["import React from 'react'\nimport { observer } from 'mobx-react-lite'\n\nimport { getOverlayAlpha, lighten, useTheme } from '@mui/material/styles'\n\nimport { useCategoryStore, useGlobalCopyStore, useWidgetContainerProvider } from '../../common'\nimport { LineChart } from '../../common/components/charts/LineChart'\n\nimport {\n formatSpendingYAxisLabel,\n getSpendingYAxisTicks,\n getSpendingData,\n} from '../utils/SpendingData'\n\n// A 74px header plus this height makes the 320px minimum card height. Safari ignores the card's\n// minimum height when the parent has no set height, so without this the chart is 0px tall there.\nconst MINI_CHART_HEIGHT = 246\n\nconst SpendingChart = () => {\n const { monthlyCategoryTotals } = useCategoryStore()\n const { trends: trendsCopy } = useGlobalCopyStore()\n const theme = useTheme()\n const { availableHeight = 0 } = useWidgetContainerProvider()\n\n const data = React.useMemo(() => getSpendingData(monthlyCategoryTotals), [monthlyCategoryTotals])\n const ticks = getSpendingYAxisTicks(data.map((point) => point.y))\n\n // With background.paper alone, label boxes and marks look darker than the card in dark mode.\n const cardColor =\n theme.palette.mode === 'dark'\n ? lighten(theme.palette.background.paper, getOverlayAlpha(1))\n : theme.palette.background.paper\n\n const axisLabelSx = (transform: string) => ({\n '& .MuiChartsAxis-tickLabel': { fill: theme.palette.text.secondary, transform },\n // Without the tspan selector, the inline 12px from x-charts wins and the axis labels stay at 12px.\n '& .MuiChartsAxis-tickLabel tspan': { fontSize: theme.typography.caption.fontSize },\n })\n\n return (\n <LineChart\n areaGradientColor={theme.palette.primary[500]}\n averageLineStyle={{\n stroke: theme.palette.grey[500],\n strokeDasharray: '8, 8',\n strokeLinecap: 'round',\n }}\n axisColor={theme.palette.divider}\n baseline=\"min\"\n chartXaxisSx={axisLabelSx('translateY(11px)')}\n chartYaxisSx={axisLabelSx('translateX(-2px)')}\n colors={[theme.palette.primary.main]}\n customLegendBoxSx={{ borderRadius: '2px' }}\n customLegendSx={{ left: 24, top: 4 }}\n customLegendVariant=\"caption\"\n datasets={[data]}\n height={Math.max(availableHeight, MINI_CHART_HEIGHT)}\n labelBackgroundColor={cardColor}\n labelFontSize={Number(theme.typography.body2.fontSize)}\n labels={[trendsCopy.spending_label]}\n margin={{ bottom: 28, left: -4, right: 24, top: 64 }}\n markStyles={() => ({ fill: cardColor })}\n markVariant=\"compact\"\n maxRange={ticks[2]}\n minRange={0}\n showArea={true}\n showAverage={true}\n showLegend={true}\n showMarkLabel={true}\n showXAxis={true}\n tickIntervals={ticks}\n useCustomMark={true}\n valueFormatterString=\"0,0\"\n yAxisValueFormatter={(value) => formatSpendingYAxisLabel(value, ticks[2])}\n />\n )\n}\n\nexport default observer(SpendingChart)\n"],"mappings":";;;;;;;AAgBA,IAAM,IAAoB,KAEpB,IAAA,MAAsB;AAC1B,QAAM,EAAE,uBAAA,EAAA,IAA0B,EAAiB,GAC7C,EAAE,QAAQ,EAAA,IAAe,EAAmB,GAC5C,IAAQ,EAAS,GACjB,EAAE,iBAAA,IAAkB,EAAA,IAAM,EAA2B,GAErD,IAAO,EAAM,QAAA,MAAc,EAAgB,CAAqB,GAAG,CAAC,CAAqB,CAAC,GAC1F,IAAQ,EAAsB,EAAK,IAAA,CAAK,MAAU,EAAM,CAAC,CAAC,GAG1D,IACJ,EAAM,QAAQ,SAAS,SACnB,EAAQ,EAAM,QAAQ,WAAW,OAAO,EAAgB,CAAC,CAAC,IAC1D,EAAM,QAAQ,WAAW,OAEzB,IAAA,CAAe,OAAuB;AAAA,IAC1C,8BAA8B;AAAA,MAAE,MAAM,EAAM,QAAQ,KAAK;AAAA,MAAW,WAAA;AAAA,IAAU;AAAA,IAE9E,oCAAoC,EAAE,UAAU,EAAM,WAAW,QAAQ,SAAS;AAAA,EACpF;AAEA,SACE,gBAAA,EAAC,GAAD;AAAA,IACE,mBAAmB,EAAM,QAAQ,QAAQ,GAAA;AAAA,IACzC,kBAAkB;AAAA,MAChB,QAAQ,EAAM,QAAQ,KAAK,GAAA;AAAA,MAC3B,iBAAiB;AAAA,MACjB,eAAe;AAAA,IACjB;AAAA,IACA,WAAW,EAAM,QAAQ;AAAA,IACzB,UAAS;AAAA,IACT,cAAc,EAAY,kBAAkB;AAAA,IAC5C,cAAc,EAAY,kBAAkB;AAAA,IAC5C,QAAQ,CAAC,EAAM,QAAQ,QAAQ,IAAI;AAAA,IACnC,mBAAmB,EAAE,cAAc,MAAM;AAAA,IACzC,gBAAgB;AAAA,MAAE,MAAM;AAAA,MAAI,KAAK;AAAA,IAAE;AAAA,IACnC,qBAAoB;AAAA,IACpB,UAAU,CAAC,CAAI;AAAA,IACf,QAAQ,KAAK,IAAI,GAAiB,CAAiB;AAAA,IACnD,sBAAsB;AAAA,IACtB,eAAe,OAAO,EAAM,WAAW,MAAM,QAAQ;AAAA,IACrD,QAAQ,CAAC,EAAW,cAAc;AAAA,IAClC,QAAQ;AAAA,MAAE,QAAQ;AAAA,MAAI,MAAM;AAAA,MAAI,OAAO;AAAA,MAAI,KAAK;AAAA,IAAG;AAAA,IACnD,YAAA,OAAmB,EAAE,MAAM,EAAU;AAAA,IACrC,aAAY;AAAA,IACZ,UAAU,EAAM,CAAA;AAAA,IAChB,UAAU;AAAA,IACV,UAAU;AAAA,IACV,aAAa;AAAA,IACb,YAAY;AAAA,IACZ,eAAe;AAAA,IACf,WAAW;AAAA,IACX,eAAe;AAAA,IACf,eAAe;AAAA,IACf,sBAAqB;AAAA,IACrB,qBAAA,CAAsB,MAAU,EAAyB,GAAO,EAAM,CAAA,CAAE;AAAA,EACzE,CAAA;AAEL,GAEA,IAAe,EAAS,CAAa"}
|
|
@@ -23,4 +23,6 @@ export declare const getSpendingData: (totals: MonthlyCategoryTotals[]) => {
|
|
|
23
23
|
x: string;
|
|
24
24
|
y: number;
|
|
25
25
|
}[];
|
|
26
|
+
export declare const getSpendingYAxisTicks: (values: number[]) => number[];
|
|
27
|
+
export declare const formatSpendingYAxisLabel: (value: number, top: number) => string;
|
|
26
28
|
export {};
|
|
@@ -1,53 +1,80 @@
|
|
|
1
|
-
import { CategoryGuids as
|
|
2
|
-
import { DATE_FORMATS_INTL as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
import { CategoryGuids as l } from "../../core/constants/Category.es.js";
|
|
2
|
+
import { DATE_FORMATS_INTL as f, formatDate as p } from "../../core/constants/DateFormats.es.js";
|
|
3
|
+
import { formatCurrency as m } from "../../core/utils/NumberFormatting.es.js";
|
|
4
|
+
import { isIncome as u, isPayment as T, isSpend as y } from "./shared.es.js";
|
|
5
|
+
import { addMonths as d } from "date-fns/addMonths";
|
|
6
|
+
import { endOfMonth as M } from "date-fns/endOfMonth";
|
|
7
|
+
import { isBefore as g } from "date-fns/isBefore";
|
|
8
|
+
import { startOfMonth as c } from "date-fns/startOfMonth";
|
|
9
|
+
import { subMonths as h } from "date-fns/subMonths";
|
|
10
|
+
var i = (r, e) => {
|
|
11
|
+
const o = [];
|
|
12
|
+
let t = c(e?.start ?? h(/* @__PURE__ */ new Date(), 5));
|
|
13
|
+
const n = e?.end ?? /* @__PURE__ */ new Date();
|
|
14
|
+
for (; g(t, n); )
|
|
15
|
+
o.push({
|
|
16
|
+
x: p(t, f.MONTH_SHORT),
|
|
17
|
+
y: r.filter((a) => a.year === t.getFullYear() && a.month === t.getMonth() + 1).reduce((a, s) => a + s.total, 0)
|
|
18
|
+
}), t = d(t, 1);
|
|
19
|
+
return o;
|
|
20
|
+
}, E = (r, e) => {
|
|
21
|
+
const o = r.filter(u);
|
|
22
|
+
return i(o, e).map((t) => ({
|
|
22
23
|
...t,
|
|
23
24
|
y: Math.abs(t.y)
|
|
24
25
|
}));
|
|
25
|
-
},
|
|
26
|
-
const
|
|
27
|
-
return
|
|
26
|
+
}, I = (r, e) => {
|
|
27
|
+
const o = r.filter(T);
|
|
28
|
+
return i(o, e).map((t) => ({
|
|
28
29
|
...t,
|
|
29
30
|
y: Math.abs(t.y)
|
|
30
31
|
}));
|
|
31
|
-
},
|
|
32
|
-
const
|
|
33
|
-
return
|
|
34
|
-
},
|
|
35
|
-
const
|
|
36
|
-
let t =
|
|
37
|
-
const n =
|
|
38
|
-
for (;
|
|
39
|
-
|
|
40
|
-
x: p(t,
|
|
41
|
-
y:
|
|
42
|
-
}), t =
|
|
43
|
-
return
|
|
44
|
-
}
|
|
32
|
+
}, R = (r, e) => {
|
|
33
|
+
const o = r.filter(y);
|
|
34
|
+
return i(o, e);
|
|
35
|
+
}, b = (r) => {
|
|
36
|
+
const e = [], o = r.filter((a) => a.top_level_category_guid !== l.INCOME && a.top_level_category_guid !== l.TRANSFER && a.total > 0);
|
|
37
|
+
let t = c(h(/* @__PURE__ */ new Date(), 5));
|
|
38
|
+
const n = M(/* @__PURE__ */ new Date());
|
|
39
|
+
for (; g(t, n); )
|
|
40
|
+
e.push({
|
|
41
|
+
x: p(t, f.MONTH_SHORT),
|
|
42
|
+
y: o.filter((a) => a.year === t.getFullYear() && a.month === t.getMonth() + 1).reduce((a, s) => a + s.total, 0)
|
|
43
|
+
}), t = d(t, 1);
|
|
44
|
+
return e;
|
|
45
|
+
}, D = [
|
|
46
|
+
1,
|
|
47
|
+
1.5,
|
|
48
|
+
2,
|
|
49
|
+
2.5,
|
|
50
|
+
3,
|
|
51
|
+
4,
|
|
52
|
+
5,
|
|
53
|
+
6,
|
|
54
|
+
7.5,
|
|
55
|
+
10
|
|
56
|
+
], F = (r) => {
|
|
57
|
+
const e = Math.max(...r, 0) / 2;
|
|
58
|
+
if (e <= 50) return [
|
|
59
|
+
0,
|
|
60
|
+
50,
|
|
61
|
+
100
|
|
62
|
+
];
|
|
63
|
+
const o = 10 ** Math.floor(Math.log10(e)), t = D.filter((n) => n * o >= e)[0] * o;
|
|
64
|
+
return [
|
|
65
|
+
0,
|
|
66
|
+
t,
|
|
67
|
+
t * 2
|
|
68
|
+
];
|
|
69
|
+
}, H = (r, e) => e >= 1e5 ? m(r, "0.[0]a").toUpperCase() : m(r, "0,0");
|
|
45
70
|
export {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
I as
|
|
50
|
-
|
|
71
|
+
H as formatSpendingYAxisLabel,
|
|
72
|
+
E as getIncomeTotals,
|
|
73
|
+
i as getMonthlyTotals,
|
|
74
|
+
I as getPaymentTotals,
|
|
75
|
+
b as getSpendingData,
|
|
76
|
+
R as getSpendingTotals,
|
|
77
|
+
F as getSpendingYAxisTicks
|
|
51
78
|
};
|
|
52
79
|
|
|
53
80
|
//# sourceMappingURL=SpendingData.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SpendingData.es.js","names":[],"sources":["../../../src/trends/utils/SpendingData.ts"],"sourcesContent":["import { addMonths } from 'date-fns/addMonths'\nimport { isBefore } from 'date-fns/isBefore'\nimport { startOfMonth } from 'date-fns/startOfMonth'\nimport { subMonths } from 'date-fns/subMonths'\nimport { endOfMonth } from 'date-fns/endOfMonth'\n\nimport { CategoryGuids, DATE_FORMATS_INTL, formatDate } from '../../core/constants'\nimport { MonthlyCategoryTotals } from '../../core'\nimport { isIncome, isPayment, isSpend } from './shared'\n\ntype DateRange = {\n start: Date\n end: Date\n}\n\nexport const getMonthlyTotals = (totals: MonthlyCategoryTotals[], range?: DateRange) => {\n const data: { x: string; y: number }[] = []\n let startDate = startOfMonth(range?.start ?? subMonths(new Date(), 5))\n const endDate = range?.end ?? new Date()\n\n while (isBefore(startDate, endDate)) {\n // Add total amount for each month\n data.push({\n x: formatDate(startDate, DATE_FORMATS_INTL.MONTH_SHORT),\n y: totals\n .filter((t) => t.year === startDate.getFullYear() && t.month === startDate.getMonth() + 1)\n .reduce((total, item) => total + item.total, 0),\n })\n startDate = addMonths(startDate, 1)\n }\n\n return data\n}\n\nexport const getIncomeTotals = (totals: MonthlyCategoryTotals[], range?: DateRange) => {\n const incomeTotals = totals.filter(isIncome)\n // Income totals are negative values, but we want to display them as positive\n return getMonthlyTotals(incomeTotals, range).map((t) => ({ ...t, y: Math.abs(t.y) }))\n}\n\nexport const getPaymentTotals = (totals: MonthlyCategoryTotals[], range?: DateRange) => {\n const paymentTotals = totals.filter(isPayment)\n // Payment totals are negative values, but we want to display them as positive\n return getMonthlyTotals(paymentTotals, range).map((t) => ({ ...t, y: Math.abs(t.y) }))\n}\n\nexport const getSpendingTotals = (totals: MonthlyCategoryTotals[], range?: DateRange) => {\n const spendingTotals = totals.filter(isSpend)\n return getMonthlyTotals(spendingTotals, range)\n}\n\nexport const getSpendingData = (totals: MonthlyCategoryTotals[]) => {\n const data: { x: string; y: number }[] = []\n\n // Filter out income and transfers\n const filteredTotals = totals.filter(\n (t) =>\n t.top_level_category_guid !== CategoryGuids.INCOME &&\n t.top_level_category_guid !== CategoryGuids.TRANSFER &&\n t.total > 0,\n )\n\n let startDate = startOfMonth(subMonths(new Date(), 5))\n const endDate = endOfMonth(new Date())\n while (isBefore(startDate, endDate)) {\n // Add total amount for each month\n data.push({\n x: formatDate(startDate, DATE_FORMATS_INTL.MONTH_SHORT),\n y: filteredTotals\n .filter((t) => t.year === startDate.getFullYear() && t.month === startDate.getMonth() + 1)\n .reduce((total, item) => total + item.total, 0),\n })\n startDate = addMonths(startDate, 1)\n }\n\n return data\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"SpendingData.es.js","names":[],"sources":["../../../src/trends/utils/SpendingData.ts"],"sourcesContent":["import { addMonths } from 'date-fns/addMonths'\nimport { isBefore } from 'date-fns/isBefore'\nimport { startOfMonth } from 'date-fns/startOfMonth'\nimport { subMonths } from 'date-fns/subMonths'\nimport { endOfMonth } from 'date-fns/endOfMonth'\n\nimport { CategoryGuids, DATE_FORMATS_INTL, formatDate } from '../../core/constants'\nimport { MonthlyCategoryTotals } from '../../core'\nimport { formatCurrency } from '../../core/utils/NumberFormatting'\nimport { isIncome, isPayment, isSpend } from './shared'\n\ntype DateRange = {\n start: Date\n end: Date\n}\n\nexport const getMonthlyTotals = (totals: MonthlyCategoryTotals[], range?: DateRange) => {\n const data: { x: string; y: number }[] = []\n let startDate = startOfMonth(range?.start ?? subMonths(new Date(), 5))\n const endDate = range?.end ?? new Date()\n\n while (isBefore(startDate, endDate)) {\n // Add total amount for each month\n data.push({\n x: formatDate(startDate, DATE_FORMATS_INTL.MONTH_SHORT),\n y: totals\n .filter((t) => t.year === startDate.getFullYear() && t.month === startDate.getMonth() + 1)\n .reduce((total, item) => total + item.total, 0),\n })\n startDate = addMonths(startDate, 1)\n }\n\n return data\n}\n\nexport const getIncomeTotals = (totals: MonthlyCategoryTotals[], range?: DateRange) => {\n const incomeTotals = totals.filter(isIncome)\n // Income totals are negative values, but we want to display them as positive\n return getMonthlyTotals(incomeTotals, range).map((t) => ({ ...t, y: Math.abs(t.y) }))\n}\n\nexport const getPaymentTotals = (totals: MonthlyCategoryTotals[], range?: DateRange) => {\n const paymentTotals = totals.filter(isPayment)\n // Payment totals are negative values, but we want to display them as positive\n return getMonthlyTotals(paymentTotals, range).map((t) => ({ ...t, y: Math.abs(t.y) }))\n}\n\nexport const getSpendingTotals = (totals: MonthlyCategoryTotals[], range?: DateRange) => {\n const spendingTotals = totals.filter(isSpend)\n return getMonthlyTotals(spendingTotals, range)\n}\n\nexport const getSpendingData = (totals: MonthlyCategoryTotals[]) => {\n const data: { x: string; y: number }[] = []\n\n // Filter out income and transfers\n const filteredTotals = totals.filter(\n (t) =>\n t.top_level_category_guid !== CategoryGuids.INCOME &&\n t.top_level_category_guid !== CategoryGuids.TRANSFER &&\n t.total > 0,\n )\n\n let startDate = startOfMonth(subMonths(new Date(), 5))\n const endDate = endOfMonth(new Date())\n while (isBefore(startDate, endDate)) {\n // Add total amount for each month\n data.push({\n x: formatDate(startDate, DATE_FORMATS_INTL.MONTH_SHORT),\n y: filteredTotals\n .filter((t) => t.year === startDate.getFullYear() && t.month === startDate.getMonth() + 1)\n .reduce((total, item) => total + item.total, 0),\n })\n startDate = addMonths(startDate, 1)\n }\n\n return data\n}\n\n// Nice numbers for graph labels\nconst NICE_STEPS = [1, 1.5, 2, 2.5, 3, 4, 5, 6, 7.5, 10]\n\n// Returns $0, a middle value, and a top value, with a rounded step so the labels read well.\nexport const getSpendingYAxisTicks = (values: number[]) => {\n const half = Math.max(...values, 0) / 2\n if (half <= 50) return [0, 50, 100]\n\n const magnitude = 10 ** Math.floor(Math.log10(half))\n // half / magnitude is from 1 to 10, so the last step (10) always matches.\n const step = NICE_STEPS.filter((n) => n * magnitude >= half)[0] * magnitude\n return [0, step, step * 2]\n}\n\n// From $100,000, full amounts do not fit the axis label column, so the labels use the short form ($500K, $1M).\nexport const formatSpendingYAxisLabel = (value: number, top: number) =>\n top >= 100000 ? formatCurrency(value, '0.[0]a').toUpperCase() : formatCurrency(value, '0,0')\n"],"mappings":";;;;;;;;;AAgBA,IAAa,IAAA,CAAoB,GAAiC,MAAsB;AACtF,QAAM,IAAmC,CAAC;AAC1C,MAAI,IAAY,EAAa,GAAO,SAAS,EAAU,oBAAI,KAAK,GAAG,CAAC,CAAC;AACrE,QAAM,IAAU,GAAO,OAAO,oBAAI,KAAK;AAEvC,SAAO,EAAS,GAAW,CAAO;AAEhC,IAAA,EAAK,KAAK;AAAA,MACR,GAAG,EAAW,GAAW,EAAkB,WAAW;AAAA,MACtD,GAAG,EACA,OAAA,CAAQ,MAAM,EAAE,SAAS,EAAU,YAAY,KAAK,EAAE,UAAU,EAAU,SAAS,IAAI,CAAC,EACxF,OAAA,CAAQ,GAAO,MAAS,IAAQ,EAAK,OAAO,CAAC;AAAA,IAClD,CAAC,GACD,IAAY,EAAU,GAAW,CAAC;AAGpC,SAAO;AACT,GAEa,IAAA,CAAmB,GAAiC,MAAsB;AACrF,QAAM,IAAe,EAAO,OAAO,CAAQ;AAE3C,SAAO,EAAiB,GAAc,CAAK,EAAE,IAAA,CAAK,OAAO;AAAA,IAAE,GAAG;AAAA,IAAG,GAAG,KAAK,IAAI,EAAE,CAAC;AAAA,EAAE,EAAE;AACtF,GAEa,IAAA,CAAoB,GAAiC,MAAsB;AACtF,QAAM,IAAgB,EAAO,OAAO,CAAS;AAE7C,SAAO,EAAiB,GAAe,CAAK,EAAE,IAAA,CAAK,OAAO;AAAA,IAAE,GAAG;AAAA,IAAG,GAAG,KAAK,IAAI,EAAE,CAAC;AAAA,EAAE,EAAE;AACvF,GAEa,IAAA,CAAqB,GAAiC,MAAsB;AACvF,QAAM,IAAiB,EAAO,OAAO,CAAO;AAC5C,SAAO,EAAiB,GAAgB,CAAK;AAC/C,GAEa,IAAA,CAAmB,MAAoC;AAClE,QAAM,IAAmC,CAAC,GAGpC,IAAiB,EAAO,OAAA,CAC3B,MACC,EAAE,4BAA4B,EAAc,UAC5C,EAAE,4BAA4B,EAAc,YAC5C,EAAE,QAAQ,CACd;AAEA,MAAI,IAAY,EAAa,EAAU,oBAAI,KAAK,GAAG,CAAC,CAAC;AACrD,QAAM,IAAU,EAAW,oBAAI,KAAK,CAAC;AACrC,SAAO,EAAS,GAAW,CAAO;AAEhC,IAAA,EAAK,KAAK;AAAA,MACR,GAAG,EAAW,GAAW,EAAkB,WAAW;AAAA,MACtD,GAAG,EACA,OAAA,CAAQ,MAAM,EAAE,SAAS,EAAU,YAAY,KAAK,EAAE,UAAU,EAAU,SAAS,IAAI,CAAC,EACxF,OAAA,CAAQ,GAAO,MAAS,IAAQ,EAAK,OAAO,CAAC;AAAA,IAClD,CAAC,GACD,IAAY,EAAU,GAAW,CAAC;AAGpC,SAAO;AACT,GAGM,IAAa;AAAA,EAAC;AAAA,EAAG;AAAA,EAAK;AAAA,EAAG;AAAA,EAAK;AAAA,EAAG;AAAA,EAAG;AAAA,EAAG;AAAA,EAAG;AAAA,EAAK;AAAE,GAG1C,IAAA,CAAyB,MAAqB;AACzD,QAAM,IAAO,KAAK,IAAI,GAAG,GAAQ,CAAC,IAAI;AACtC,MAAI,KAAQ,GAAI,QAAO;AAAA,IAAC;AAAA,IAAG;AAAA,IAAI;AAAA,EAAG;AAElC,QAAM,IAAY,MAAM,KAAK,MAAM,KAAK,MAAM,CAAI,CAAC,GAE7C,IAAO,EAAW,OAAA,CAAQ,MAAM,IAAI,KAAa,CAAI,EAAE,CAAA,IAAK;AAClE,SAAO;AAAA,IAAC;AAAA,IAAG;AAAA,IAAM,IAAO;AAAA,EAAC;AAC3B,GAGa,IAAA,CAA4B,GAAe,MACtD,KAAO,MAAS,EAAe,GAAO,QAAQ,EAAE,YAAY,IAAI,EAAe,GAAO,KAAK"}
|