@mx-cartographer/experiences 9.7.118 → 9.7.120

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 (36) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/cashflow/CashflowMiniWidget.es.js +53 -19
  3. package/dist/cashflow/CashflowMiniWidget.es.js.map +1 -1
  4. package/dist/cashflow/components/CashflowWidgetContent.d.ts +1 -0
  5. package/dist/cashflow/components/CashflowWidgetContent.es.js +173 -137
  6. package/dist/cashflow/components/CashflowWidgetContent.es.js.map +1 -1
  7. package/dist/cashflow/components/RemainingCash.d.ts +1 -0
  8. package/dist/cashflow/components/RemainingCash.es.js +10 -9
  9. package/dist/cashflow/components/RemainingCash.es.js.map +1 -1
  10. package/dist/common/components/InformationTooltip.d.ts +1 -0
  11. package/dist/common/components/InformationTooltip.es.js +16 -16
  12. package/dist/common/components/InformationTooltip.es.js.map +1 -1
  13. package/dist/common/components/MiniWidgetContainer.d.ts +13 -0
  14. package/dist/common/components/MiniWidgetContainer.es.js +63 -55
  15. package/dist/common/components/MiniWidgetContainer.es.js.map +1 -1
  16. package/dist/common/components/charts/LineChart.d.ts +5 -1
  17. package/dist/common/components/charts/LineChart.es.js +124 -122
  18. package/dist/common/components/charts/LineChart.es.js.map +1 -1
  19. package/dist/common/components/charts/linechart/CustomLegend.es.js +53 -46
  20. package/dist/common/components/charts/linechart/CustomLegend.es.js.map +1 -1
  21. package/dist/common/components/charts/linechart/CustomMark.d.ts +2 -0
  22. package/dist/common/components/charts/linechart/CustomMark.es.js +72 -35
  23. package/dist/common/components/charts/linechart/CustomMark.es.js.map +1 -1
  24. package/dist/core/constants/repeatingTransactions.d.ts +1 -0
  25. package/dist/core/constants/repeatingTransactions.es.js +13 -11
  26. package/dist/core/constants/repeatingTransactions.es.js.map +1 -1
  27. package/dist/core/types/localization/CashflowCopy.d.ts +1 -0
  28. package/dist/core/types/localization/TrendsCopy.d.ts +1 -0
  29. package/dist/trends/TrendsMiniWidget.es.js +29 -22
  30. package/dist/trends/TrendsMiniWidget.es.js.map +1 -1
  31. package/dist/trends/components/SpendingChart.es.js +53 -17
  32. package/dist/trends/components/SpendingChart.es.js.map +1 -1
  33. package/dist/trends/utils/SpendingData.d.ts +2 -0
  34. package/dist/trends/utils/SpendingData.es.js +70 -43
  35. package/dist/trends/utils/SpendingData.es.js.map +1 -1
  36. package/package.json +1 -1
@@ -5,10 +5,12 @@ export type MarkHandlers = {
5
5
  onMouseEnter?: (dataIndex: number) => void;
6
6
  onMouseLeave?: () => void;
7
7
  };
8
+ export type MarkVariant = 'default' | 'compact';
8
9
  interface CustomMarkProps extends MarkElementProps {
9
10
  handlers?: MarkHandlers;
10
11
  showLabel: boolean;
11
12
  showMark?: boolean;
13
+ variant?: MarkVariant;
12
14
  yData: number[];
13
15
  style?: React.CSSProperties & {
14
16
  markLabelStyles?: React.CSSProperties;
@@ -1,56 +1,93 @@
1
- import { formatCurrency as M } from "../../../../core/utils/NumberFormatting.es.js";
2
- import { MARKER_SHAPE_PATHS as C } from "./utils/markerShapes.es.js";
3
- import "react";
4
- import { Fragment as m, jsx as n, jsxs as d } from "react/jsx-runtime";
5
- import { useTheme as L } from "@mui/material/styles";
6
- import F from "@mui/material/useMediaQuery";
7
- var I = (e) => {
8
- const a = L(), s = e.showLabel, t = e.style, h = t?.markLabelStyles, l = Number(e.x), r = Number(e.y), o = e.handlers?.onMarkClick, u = e.handlers?.onMouseEnter, x = e.handlers?.onMouseLeave, y = F(a.breakpoints.up("sm")), f = e.valueFormatterString ? M(e.yData[e.dataIndex], e.valueFormatterString) : String(e.yData[e.dataIndex]), b = y ? a.typography.body2?.fontSize : a.typography.caption?.fontSize, i = 30, c = 24, k = l - i / 2, S = r - 30;
9
- return /* @__PURE__ */ d(m, { children: [s && /* @__PURE__ */ d(m, { children: [e.labelBackgroundColor && /* @__PURE__ */ n("rect", {
10
- fill: e.labelBackgroundColor,
11
- height: c,
12
- rx: "3",
13
- width: i,
14
- x: k,
15
- y: S
16
- }), /* @__PURE__ */ n("text", {
1
+ import { formatCurrency as F } from "../../../../core/utils/NumberFormatting.es.js";
2
+ import { MARKER_SHAPE_PATHS as T } from "./utils/markerShapes.es.js";
3
+ import x from "react";
4
+ import { Fragment as k, jsx as h, jsxs as S } from "react/jsx-runtime";
5
+ import { useTheme as B } from "@mui/material/styles";
6
+ import I from "@mui/material/useMediaQuery";
7
+ var P = "M4,0A4,4,0,1,1,-4,0A4,4,0,1,1,4,0", s = 5, R = 12, u = 16, K = (t) => {
8
+ const a = B(), o = t.showLabel, e = t.style, A = e?.markLabelStyles, l = Number(t.x), d = Number(t.y), r = t.variant === "compact", y = t.handlers?.onMarkClick, L = t.handlers?.onMouseEnter, v = t.handlers?.onMouseLeave, _ = I(a.breakpoints.up("sm")), f = x.useRef(null), [w, E] = x.useState(0), b = t.valueFormatterString ? F(t.yData[t.dataIndex], t.valueFormatterString) : String(t.yData[t.dataIndex]), M = _ ? a.typography.body2?.fontSize : a.typography.caption?.fontSize;
9
+ x.useLayoutEffect(() => {
10
+ r && o && E(f.current?.getBBox?.().width ?? 0);
11
+ }, [
12
+ r,
13
+ o,
14
+ b,
15
+ M,
16
+ t.labelFontSize
17
+ ]);
18
+ let n = {
19
+ height: 24,
20
+ rx: 3,
21
+ width: 30,
22
+ x: l - 15,
23
+ y: d - 30
24
+ }, c = {
25
+ x: l,
26
+ y: d - 16
27
+ };
28
+ if (r) {
29
+ const m = t.dataIndex === 0 ? "start" : t.dataIndex === t.yData.length - 1 ? "end" : "middle", i = w + 4, g = {
30
+ start: l - s,
31
+ middle: l - i / 2,
32
+ end: l + s - i
33
+ }[m], C = d - s - R;
34
+ n = {
35
+ height: u,
36
+ rx: 2,
37
+ width: i,
38
+ x: g,
39
+ y: C - u
40
+ }, c = {
41
+ x: g + i / 2,
42
+ y: C - u / 2
43
+ };
44
+ }
45
+ return /* @__PURE__ */ S(k, { children: [o && /* @__PURE__ */ S(k, { children: [t.labelBackgroundColor && /* @__PURE__ */ h("rect", {
46
+ fill: t.labelBackgroundColor,
47
+ height: n.height,
48
+ rx: n.rx,
49
+ width: n.width,
50
+ x: n.x,
51
+ y: n.y
52
+ }), /* @__PURE__ */ h("text", {
17
53
  className: "MuiLineChart-markLabel",
18
54
  dominantBaseline: "middle",
19
- fill: e.labelFontColor ? e.labelFontColor : a.palette.text.primary,
55
+ fill: t.labelFontColor ? t.labelFontColor : a.palette.text.primary,
56
+ ref: f,
20
57
  style: {
21
- fontSize: e.labelFontSize ? e.labelFontSize : b,
22
- ...h
58
+ fontSize: t.labelFontSize ? t.labelFontSize : M,
59
+ ...A
23
60
  },
24
61
  textAnchor: "middle",
25
- x: l,
26
- y: r - 28 + c / 2,
27
- children: f
28
- })] }), e.showMark && /* @__PURE__ */ n("path", {
29
- cursor: o ? "pointer" : "unset",
30
- d: C[e.shape ?? "circle"],
62
+ x: c.x,
63
+ y: c.y,
64
+ children: b
65
+ })] }), t.showMark && /* @__PURE__ */ h("path", {
66
+ cursor: y ? "pointer" : "unset",
67
+ d: r ? P : T[t.shape ?? "circle"],
31
68
  height: "20px",
32
- onClick: (g) => {
33
- o?.(g, e.dataIndex);
69
+ onClick: (m) => {
70
+ y?.(m, t.dataIndex);
34
71
  },
35
72
  onMouseEnter: () => {
36
- u?.(e.dataIndex);
73
+ L?.(t.dataIndex);
37
74
  },
38
75
  onMouseLeave: () => {
39
- x?.();
76
+ v?.();
40
77
  },
41
78
  style: {
42
- fill: t?.fill ? t.fill : a.palette.background.paper,
43
- stroke: t?.stroke ? t.stroke : a.palette.primary.main,
79
+ fill: e?.fill ? e.fill : a.palette.background.paper,
80
+ stroke: e?.stroke ? e.stroke : a.palette.primary.main,
44
81
  strokeWidth: 2,
45
- transform: `translate(${e.x}px, ${e.y}px)`,
46
- transformOrigin: `${e.x}px, ${e.y}px`,
47
- filter: t?.filter ? t.filter : "none"
82
+ transform: `translate(${t.x}px, ${t.y}px)`,
83
+ transformOrigin: `${t.x}px, ${t.y}px`,
84
+ filter: e?.filter ? e.filter : "none"
48
85
  },
49
86
  width: "20px"
50
87
  })] });
51
88
  };
52
89
  export {
53
- I as CustomMark
90
+ K as CustomMark
54
91
  };
55
92
 
56
93
  //# sourceMappingURL=CustomMark.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CustomMark.es.js","names":[],"sources":["../../../../../src/common/components/charts/linechart/CustomMark.tsx"],"sourcesContent":["import React from 'react'\n\nimport { useTheme } from '@mui/material/styles'\nimport useMediaQuery from '@mui/material/useMediaQuery'\n\nimport type { MarkElementProps } from '@mui/x-charts'\n\nimport { MARKER_SHAPE_PATHS } from './utils/markerShapes'\nimport { formatCurrency } from '../../../../core/utils/NumberFormatting'\n\nexport type MarkHandlers = {\n onMarkClick?: (event: React.MouseEvent<SVGPathElement, MouseEvent>, dataIndex: number) => void\n onMouseEnter?: (dataIndex: number) => void\n onMouseLeave?: () => void\n}\n\ninterface CustomMarkProps extends MarkElementProps {\n handlers?: MarkHandlers\n showLabel: boolean\n showMark?: boolean\n yData: number[]\n style?: React.CSSProperties & {\n markLabelStyles?: React.CSSProperties\n }\n labelBackgroundColor?: string\n labelFontColor?: string\n labelFontSize?: number\n valueFormatterString?: string\n}\n\nexport const CustomMark: React.FC<CustomMarkProps> = (props) => {\n const theme = useTheme()\n const showLabel = props.showLabel\n const styles = props.style\n const markLabelStyles = styles?.markLabelStyles\n const xNumber = Number(props.x)\n const yNumber = Number(props.y)\n\n const handleMarkClick = props.handlers?.onMarkClick\n const handleMouseEnter = props.handlers?.onMouseEnter\n const handleMouseLeave = props.handlers?.onMouseLeave\n\n const isSmallScreenUp = useMediaQuery(theme.breakpoints.up('sm'))\n\n // Calculate text dimensions for proper background sizing\n const formattedValue = props.valueFormatterString\n ? formatCurrency(props.yData[props.dataIndex], props.valueFormatterString)\n : String(props.yData[props.dataIndex])\n const fontSize = isSmallScreenUp\n ? theme.typography.body2?.fontSize\n : theme.typography.caption?.fontSize\n const rectWidth = 30\n const rectHeight = 24\n\n // Center the rectangle around the text\n const rectX = xNumber - rectWidth / 2\n const rectY = yNumber - 30\n return (\n <>\n {showLabel && (\n <>\n {props.labelBackgroundColor && (\n <rect\n fill={props.labelBackgroundColor}\n height={rectHeight}\n rx=\"3\"\n width={rectWidth}\n x={rectX}\n y={rectY}\n />\n )}\n\n <text\n className=\"MuiLineChart-markLabel\"\n dominantBaseline=\"middle\"\n fill={props.labelFontColor ? props.labelFontColor : theme.palette.text.primary}\n style={{\n fontSize: props.labelFontSize ? props.labelFontSize : fontSize,\n ...markLabelStyles,\n }}\n textAnchor=\"middle\"\n x={xNumber}\n y={yNumber - 28 + rectHeight / 2}\n >\n {formattedValue}\n </text>\n </>\n )}\n {props.showMark && (\n <path\n cursor={handleMarkClick ? 'pointer' : 'unset'}\n d={MARKER_SHAPE_PATHS[props.shape ?? 'circle']}\n height=\"20px\"\n onClick={(event) => {\n handleMarkClick?.(event, props.dataIndex)\n }}\n onMouseEnter={() => {\n handleMouseEnter?.(props.dataIndex)\n }}\n onMouseLeave={() => {\n handleMouseLeave?.()\n }}\n style={{\n fill: styles?.fill ? styles.fill : theme.palette.background.paper,\n stroke: styles?.stroke ? styles.stroke : theme.palette.primary.main,\n strokeWidth: 2,\n transform: `translate(${props.x}px, ${props.y}px)`,\n transformOrigin: `${props.x}px, ${props.y}px`,\n filter: styles?.filter ? styles.filter : 'none',\n }}\n width=\"20px\"\n />\n )}\n </>\n )\n}\n"],"mappings":";;;;;;AA8BA,IAAa,IAAA,CAAyC,MAAU;AAC9D,QAAM,IAAQ,EAAS,GACjB,IAAY,EAAM,WAClB,IAAS,EAAM,OACf,IAAkB,GAAQ,iBAC1B,IAAU,OAAO,EAAM,CAAC,GACxB,IAAU,OAAO,EAAM,CAAC,GAExB,IAAkB,EAAM,UAAU,aAClC,IAAmB,EAAM,UAAU,cACnC,IAAmB,EAAM,UAAU,cAEnC,IAAkB,EAAc,EAAM,YAAY,GAAG,IAAI,CAAC,GAG1D,IAAiB,EAAM,uBACz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D,QAAQ,GAAQ,SAAS,EAAO,SAAS,EAAM,QAAQ,QAAQ;AAAA,MAC/D,aAAa;AAAA,MACb,WAAW,aAAa,EAAM,CAAA,OAAQ,EAAM,CAAA;AAAA,MAC5C,iBAAiB,GAAG,EAAM,CAAA,OAAQ,EAAM,CAAA;AAAA,MACxC,QAAQ,GAAQ,SAAS,EAAO,SAAS;AAAA,IAC3C;AAAA,IACA,OAAM;AAAA,EACP,CAAA,CAEH,EAAA,CAAA;AAEN"}
1
+ {"version":3,"file":"CustomMark.es.js","names":[],"sources":["../../../../../src/common/components/charts/linechart/CustomMark.tsx"],"sourcesContent":["import React from 'react'\n\nimport { useTheme } from '@mui/material/styles'\nimport useMediaQuery from '@mui/material/useMediaQuery'\n\nimport type { MarkElementProps } from '@mui/x-charts'\n\nimport { MARKER_SHAPE_PATHS } from './utils/markerShapes'\nimport { formatCurrency } from '../../../../core/utils/NumberFormatting'\n\nexport type MarkHandlers = {\n onMarkClick?: (event: React.MouseEvent<SVGPathElement, MouseEvent>, dataIndex: number) => void\n onMouseEnter?: (dataIndex: number) => void\n onMouseLeave?: () => void\n}\n\n// compact: a 10px mark, and a 16px label box that fits its text, 12px above the mark.\n// The first and last label alignment assumes a single series.\nexport type MarkVariant = 'default' | 'compact'\n\nconst COMPACT_MARK_PATH = 'M4,0A4,4,0,1,1,-4,0A4,4,0,1,1,4,0'\nconst COMPACT_MARK_RADIUS = 5\nconst COMPACT_LABEL_GAP = 12\nconst COMPACT_LABEL_HEIGHT = 16\nconst COMPACT_LABEL_PADDING = 2\n\ninterface CustomMarkProps extends MarkElementProps {\n handlers?: MarkHandlers\n showLabel: boolean\n showMark?: boolean\n variant?: MarkVariant\n yData: number[]\n style?: React.CSSProperties & {\n markLabelStyles?: React.CSSProperties\n }\n labelBackgroundColor?: string\n labelFontColor?: string\n labelFontSize?: number\n valueFormatterString?: string\n}\n\nexport const CustomMark: React.FC<CustomMarkProps> = (props) => {\n const theme = useTheme()\n const showLabel = props.showLabel\n const styles = props.style\n const markLabelStyles = styles?.markLabelStyles\n const xNumber = Number(props.x)\n const yNumber = Number(props.y)\n const isCompact = props.variant === 'compact'\n\n const handleMarkClick = props.handlers?.onMarkClick\n const handleMouseEnter = props.handlers?.onMouseEnter\n const handleMouseLeave = props.handlers?.onMouseLeave\n\n const isSmallScreenUp = useMediaQuery(theme.breakpoints.up('sm'))\n const textRef = React.useRef<SVGTextElement>(null)\n const [textWidth, setTextWidth] = React.useState(0)\n\n // Calculate text dimensions for proper background sizing\n const formattedValue = props.valueFormatterString\n ? formatCurrency(props.yData[props.dataIndex], props.valueFormatterString)\n : String(props.yData[props.dataIndex])\n const fontSize = isSmallScreenUp\n ? theme.typography.body2?.fontSize\n : theme.typography.caption?.fontSize\n\n React.useLayoutEffect(() => {\n if (isCompact && showLabel) setTextWidth(textRef.current?.getBBox?.().width ?? 0)\n }, [isCompact, showLabel, formattedValue, fontSize, props.labelFontSize])\n\n let rect = { height: 24, rx: 3, width: 30, x: xNumber - 15, y: yNumber - 30 }\n let text = { x: xNumber, y: yNumber - 16 }\n\n if (isCompact) {\n // The first and last labels line up with the outer edge of their mark, so they stay inside the plot.\n const align =\n props.dataIndex === 0\n ? 'start'\n : props.dataIndex === props.yData.length - 1\n ? 'end'\n : 'middle'\n const width = textWidth + COMPACT_LABEL_PADDING * 2\n const boxX = {\n start: xNumber - COMPACT_MARK_RADIUS,\n middle: xNumber - width / 2,\n end: xNumber + COMPACT_MARK_RADIUS - width,\n }[align]\n const boxBottom = yNumber - COMPACT_MARK_RADIUS - COMPACT_LABEL_GAP\n\n rect = {\n height: COMPACT_LABEL_HEIGHT,\n rx: 2,\n width,\n x: boxX,\n y: boxBottom - COMPACT_LABEL_HEIGHT,\n }\n text = { x: boxX + width / 2, y: boxBottom - COMPACT_LABEL_HEIGHT / 2 }\n }\n\n return (\n <>\n {showLabel && (\n <>\n {props.labelBackgroundColor && (\n <rect\n fill={props.labelBackgroundColor}\n height={rect.height}\n rx={rect.rx}\n width={rect.width}\n x={rect.x}\n y={rect.y}\n />\n )}\n\n <text\n className=\"MuiLineChart-markLabel\"\n dominantBaseline=\"middle\"\n fill={props.labelFontColor ? props.labelFontColor : theme.palette.text.primary}\n ref={textRef}\n style={{\n fontSize: props.labelFontSize ? props.labelFontSize : fontSize,\n ...markLabelStyles,\n }}\n textAnchor=\"middle\"\n x={text.x}\n y={text.y}\n >\n {formattedValue}\n </text>\n </>\n )}\n {props.showMark && (\n <path\n cursor={handleMarkClick ? 'pointer' : 'unset'}\n d={isCompact ? COMPACT_MARK_PATH : MARKER_SHAPE_PATHS[props.shape ?? 'circle']}\n height=\"20px\"\n onClick={(event) => {\n handleMarkClick?.(event, props.dataIndex)\n }}\n onMouseEnter={() => {\n handleMouseEnter?.(props.dataIndex)\n }}\n onMouseLeave={() => {\n handleMouseLeave?.()\n }}\n style={{\n fill: styles?.fill ? styles.fill : theme.palette.background.paper,\n stroke: styles?.stroke ? styles.stroke : theme.palette.primary.main,\n strokeWidth: 2,\n transform: `translate(${props.x}px, ${props.y}px)`,\n transformOrigin: `${props.x}px, ${props.y}px`,\n filter: styles?.filter ? styles.filter : 'none',\n }}\n width=\"20px\"\n />\n )}\n </>\n )\n}\n"],"mappings":";;;;;;AAoBA,IAAM,IAAoB,qCACpB,IAAsB,GACtB,IAAoB,IACpB,IAAuB,IAkBhB,IAAA,CAAyC,MAAU;AAC9D,QAAM,IAAQ,EAAS,GACjB,IAAY,EAAM,WAClB,IAAS,EAAM,OACf,IAAkB,GAAQ,iBAC1B,IAAU,OAAO,EAAM,CAAC,GACxB,IAAU,OAAO,EAAM,CAAC,GACxB,IAAY,EAAM,YAAY,WAE9B,IAAkB,EAAM,UAAU,aAClC,IAAmB,EAAM,UAAU,cACnC,IAAmB,EAAM,UAAU,cAEnC,IAAkB,EAAc,EAAM,YAAY,GAAG,IAAI,CAAC,GAC1D,IAAU,EAAM,OAAuB,IAAI,GAC3C,CAAC,GAAW,CAAA,IAAgB,EAAM,SAAS,CAAC,GA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assGuids: {
13
13
  readonly PAYROLL: "MNC-bfc102ab-d4c3-41a7-9cf6-fdbf2e1ed7ea";
14
14
  readonly PAYROLL_QA: "MNC-cc857751-2758-4f50-bdfe-d1210f40a155";
15
15
  readonly PAYROLL_SAND: "MNC-404e437a-5472-4501-b781-28a718005e71";
16
+ readonly DEPOSIT_PAYROLL: "MNC-3ad50f86-60d0-4545-a1f9-e66c2ac40f69";
16
17
  };
17
18
  export declare const ALLOWED_MERCHANTLESS_BILL_CATEGORIES: readonly string[];
18
19
  export declare const ALLOWED_MERCHANTLESS_INCOME_MAIN_CLASSES: readonly string[];
@@ -2,11 +2,12 @@ import { CategoryGuids as L } from "./Category.es.js";
2
2
  import { AccountType as A } from "../types/Account.es.js";
3
3
  var N = /* @__PURE__ */ (function(E) {
4
4
  return E[E.Unknown = 0] = "Unknown", E[E.EveryWeek = 1] = "EveryWeek", E[E.EveryOtherWeek = 2] = "EveryOtherWeek", E[E.EveryMonth = 3] = "EveryMonth", E[E.EveryOtherMonth = 4] = "EveryOtherMonth", E[E.EveryQuarter = 5] = "EveryQuarter", E[E.EveryOtherQuarter = 6] = "EveryOtherQuarter", E[E.EveryYear = 7] = "EveryYear", E;
5
- })({}), I = {
5
+ })({}), O = {
6
6
  PAYROLL: "MNC-bfc102ab-d4c3-41a7-9cf6-fdbf2e1ed7ea",
7
7
  PAYROLL_QA: "MNC-cc857751-2758-4f50-bdfe-d1210f40a155",
8
- PAYROLL_SAND: "MNC-404e437a-5472-4501-b781-28a718005e71"
9
- }, C = [
8
+ PAYROLL_SAND: "MNC-404e437a-5472-4501-b781-28a718005e71",
9
+ DEPOSIT_PAYROLL: "MNC-3ad50f86-60d0-4545-a1f9-e66c2ac40f69"
10
+ }, a = [
10
11
  L.MORTGAGE_RENT,
11
12
  L.BILLS_AND_UTILITIES,
12
13
  L.HOME_PHONE,
@@ -14,11 +15,12 @@ var N = /* @__PURE__ */ (function(E) {
14
15
  L.MOBILE_PHONE,
15
16
  L.TELEVISION,
16
17
  L.UTILITIES
18
+ ], C = [
19
+ O.PAYROLL,
20
+ O.PAYROLL_QA,
21
+ O.PAYROLL_SAND,
22
+ O.DEPOSIT_PAYROLL
17
23
  ], t = [
18
- I.PAYROLL,
19
- I.PAYROLL_QA,
20
- I.PAYROLL_SAND
21
- ], a = [
22
24
  A.CHECKING,
23
25
  A.SAVINGS,
24
26
  A.CREDIT_CARD,
@@ -28,11 +30,11 @@ var N = /* @__PURE__ */ (function(E) {
28
30
  A.CHECKING_LINE_OF_CREDIT
29
31
  ];
30
32
  export {
31
- C as ALLOWED_MERCHANTLESS_BILL_CATEGORIES,
32
- t as ALLOWED_MERCHANTLESS_INCOME_MAIN_CLASSES,
33
- I as MainClassGuids,
33
+ a as ALLOWED_MERCHANTLESS_BILL_CATEGORIES,
34
+ C as ALLOWED_MERCHANTLESS_INCOME_MAIN_CLASSES,
35
+ O as MainClassGuids,
34
36
  N as RecurrenceTypes,
35
- a as VALID_REPEATING_TRANSACTION_ACCOUNT_TYPES
37
+ t as VALID_REPEATING_TRANSACTION_ACCOUNT_TYPES
36
38
  };
37
39
 
38
40
  //# sourceMappingURL=repeatingTransactions.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"repeatingTransactions.es.js","names":[],"sources":["../../../src/core/constants/repeatingTransactions.ts"],"sourcesContent":["import { AccountType } from '../types/Account'\n\nimport { CategoryGuids } from './Category'\n\nexport enum RecurrenceTypes {\n Unknown = 0,\n EveryWeek = 1,\n EveryOtherWeek = 2,\n EveryMonth = 3,\n EveryOtherMonth = 4,\n EveryQuarter = 5,\n EveryOtherQuarter = 6,\n EveryYear = 7,\n}\n\nexport const MainClassGuids = {\n PAYROLL: 'MNC-bfc102ab-d4c3-41a7-9cf6-fdbf2e1ed7ea',\n PAYROLL_QA: 'MNC-cc857751-2758-4f50-bdfe-d1210f40a155',\n PAYROLL_SAND: 'MNC-404e437a-5472-4501-b781-28a718005e71',\n} as const\n\nexport const ALLOWED_MERCHANTLESS_BILL_CATEGORIES: readonly string[] = [\n CategoryGuids.MORTGAGE_RENT,\n CategoryGuids.BILLS_AND_UTILITIES,\n CategoryGuids.HOME_PHONE,\n CategoryGuids.INTERNET,\n CategoryGuids.MOBILE_PHONE,\n CategoryGuids.TELEVISION,\n CategoryGuids.UTILITIES,\n]\n\nexport const ALLOWED_MERCHANTLESS_INCOME_MAIN_CLASSES: readonly string[] = [\n MainClassGuids.PAYROLL,\n MainClassGuids.PAYROLL_QA,\n MainClassGuids.PAYROLL_SAND,\n]\n\n// Mirrors Sherlock::Recurrence::VALID_ACCOUNT_TYPES — only transaction-bearing deposit/credit\n// accounts can produce recurrences.\nexport const VALID_REPEATING_TRANSACTION_ACCOUNT_TYPES: readonly AccountType[] = [\n AccountType.CHECKING,\n AccountType.SAVINGS,\n AccountType.CREDIT_CARD,\n AccountType.LINE_OF_CREDIT,\n AccountType.CASH,\n AccountType.PREPAID,\n AccountType.CHECKING_LINE_OF_CREDIT,\n]\n"],"mappings":";;AAIA,IAAY,IAAL,0BAAA,GAAA;AACL,SAAA,EAAA,EAAA,UAAA,CAAA,IAAA,WACA,EAAA,EAAA,YAAA,CAAA,IAAA,aACA,EAAA,EAAA,iBAAA,CAAA,IAAA,kBACA,EAAA,EAAA,aAAA,CAAA,IAAA,cACA,EAAA,EAAA,kBAAA,CAAA,IAAA,mBACA,EAAA,EAAA,eAAA,CAAA,IAAA,gBACA,EAAA,EAAA,oBAAA,CAAA,IAAA,qBACA,EAAA,EAAA,YAAA,CAAA,IAAA;AACF,GAAA,CAAA,CAAA,GAEa,IAAiB;AAAA,EAC5B,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,cAAc;AAChB,GAEa,IAA0D;AAAA,EACrE,EAAc;AAAA,EACd,EAAc;AAAA,EACd,EAAc;AAAA,EACd,EAAc;AAAA,EACd,EAAc;AAAA,EACd,EAAc;AAAA,EACd,EAAc;AAChB,GAEa,IAA8D;AAAA,EACzE,EAAe;AAAA,EACf,EAAe;AAAA,EACf,EAAe;AACjB,GAIa,IAAoE;AAAA,EAC/E,EAAY;AAAA,EACZ,EAAY;AAAA,EACZ,EAAY;AAAA,EACZ,EAAY;AAAA,EACZ,EAAY;AAAA,EACZ,EAAY;AAAA,EACZ,EAAY;AACd"}
1
+ {"version":3,"file":"repeatingTransactions.es.js","names":[],"sources":["../../../src/core/constants/repeatingTransactions.ts"],"sourcesContent":["import { AccountType } from '../types/Account'\n\nimport { CategoryGuids } from './Category'\n\nexport enum RecurrenceTypes {\n Unknown = 0,\n EveryWeek = 1,\n EveryOtherWeek = 2,\n EveryMonth = 3,\n EveryOtherMonth = 4,\n EveryQuarter = 5,\n EveryOtherQuarter = 6,\n EveryYear = 7,\n}\n\nexport const MainClassGuids = {\n PAYROLL: 'MNC-bfc102ab-d4c3-41a7-9cf6-fdbf2e1ed7ea', // Payroll (Prod/Int)\n PAYROLL_QA: 'MNC-cc857751-2758-4f50-bdfe-d1210f40a155', // Payroll (QA)\n PAYROLL_SAND: 'MNC-404e437a-5472-4501-b781-28a718005e71', // Payroll (Sand)\n DEPOSIT_PAYROLL: 'MNC-3ad50f86-60d0-4545-a1f9-e66c2ac40f69', // Deposit Payroll (Prod/Int)\n} as const\n\nexport const ALLOWED_MERCHANTLESS_BILL_CATEGORIES: readonly string[] = [\n CategoryGuids.MORTGAGE_RENT,\n CategoryGuids.BILLS_AND_UTILITIES,\n CategoryGuids.HOME_PHONE,\n CategoryGuids.INTERNET,\n CategoryGuids.MOBILE_PHONE,\n CategoryGuids.TELEVISION,\n CategoryGuids.UTILITIES,\n]\n\nexport const ALLOWED_MERCHANTLESS_INCOME_MAIN_CLASSES: readonly string[] = [\n MainClassGuids.PAYROLL,\n MainClassGuids.PAYROLL_QA,\n MainClassGuids.PAYROLL_SAND,\n MainClassGuids.DEPOSIT_PAYROLL,\n]\n\n// Mirrors Sherlock::Recurrence::VALID_ACCOUNT_TYPES — only transaction-bearing deposit/credit\n// accounts can produce recurrences.\nexport const VALID_REPEATING_TRANSACTION_ACCOUNT_TYPES: readonly AccountType[] = [\n AccountType.CHECKING,\n AccountType.SAVINGS,\n AccountType.CREDIT_CARD,\n AccountType.LINE_OF_CREDIT,\n AccountType.CASH,\n AccountType.PREPAID,\n AccountType.CHECKING_LINE_OF_CREDIT,\n]\n"],"mappings":";;AAIA,IAAY,IAAL,0BAAA,GAAA;AACL,SAAA,EAAA,EAAA,UAAA,CAAA,IAAA,WACA,EAAA,EAAA,YAAA,CAAA,IAAA,aACA,EAAA,EAAA,iBAAA,CAAA,IAAA,kBACA,EAAA,EAAA,aAAA,CAAA,IAAA,cACA,EAAA,EAAA,kBAAA,CAAA,IAAA,mBACA,EAAA,EAAA,eAAA,CAAA,IAAA,gBACA,EAAA,EAAA,oBAAA,CAAA,IAAA,qBACA,EAAA,EAAA,YAAA,CAAA,IAAA;AACF,GAAA,CAAA,CAAA,GAEa,IAAiB;AAAA,EAC5B,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,iBAAiB;AACnB,GAEa,IAA0D;AAAA,EACrE,EAAc;AAAA,EACd,EAAc;AAAA,EACd,EAAc;AAAA,EACd,EAAc;AAAA,EACd,EAAc;AAAA,EACd,EAAc;AAAA,EACd,EAAc;AAChB,GAEa,IAA8D;AAAA,EACzE,EAAe;AAAA,EACf,EAAe;AAAA,EACf,EAAe;AAAA,EACf,EAAe;AACjB,GAIa,IAAoE;AAAA,EAC/E,EAAY;AAAA,EACZ,EAAY;AAAA,EACZ,EAAY;AAAA,EACZ,EAAY;AAAA,EACZ,EAAY;AAAA,EACZ,EAAY;AAAA,EACZ,EAAY;AACd"}
@@ -29,6 +29,7 @@ export interface CashflowCopy extends AccountFilterCopy {
29
29
  create_description: string;
30
30
  current_balance: string;
31
31
  days: string;
32
+ day: string;
32
33
  days_of_week_label: string;
33
34
  details: string;
34
35
  expenses: string;
@@ -13,6 +13,7 @@ export interface TrendsCopy {
13
13
  micro_primary_cta_label: string;
14
14
  micro_subheader: string;
15
15
  micro_secondary_label: string;
16
+ mini_sub_title: string;
16
17
  mini_title: string;
17
18
  monthly_income: string;
18
19
  monthly_spending: string;
@@ -1,43 +1,50 @@
1
- import { useAccountStore as m, useCategoryStore as f, useGlobalCopyStore as u, useGlobalStore as p, useGlobalUiStore as g } from "../common/context/hooks.es.js";
2
- import { useWidgetLoadTimer as y } from "../common/hooks/useWidgetLoadTimer.es.js";
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 C from "./components/SpendingChart.es.js";
5
+ import x from "./components/SpendingChart.es.js";
6
6
  import n from "react";
7
- import { observer as S } from "mobx-react-lite";
8
- import { jsx as i } from "react/jsx-runtime";
9
- var T = ({ onPrimaryCtaClick: s, sx: l }) => {
10
- const { isAccountDataLoaded: t, loadAccountData: d } = m(), { loadMonthlyCategoryTotals: c, monthlyTotalsLoaded: r } = f(), { isInitialized: e } = p(), { trends: o } = u(), { selectedAccounts: a } = g();
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
- }, []), y({
13
+ }, []), g({
14
14
  widgetName: "TrendsMiniWidget",
15
15
  isLoaded: r
16
16
  }), n.useEffect(() => {
17
- e && t && c(a).finally();
17
+ e && t && m(a).finally();
18
18
  }, [
19
19
  t,
20
20
  e,
21
21
  a
22
- ]), !t || !e || !r ? /* @__PURE__ */ i(b, {}) : /* @__PURE__ */ i(h, {
22
+ ]), !t || !e || !r ? /* @__PURE__ */ o(b, {}) : /* @__PURE__ */ o(h, {
23
23
  contentStyles: {
24
- height: "calc(100% - 72px)",
25
- minHeight: 300,
26
- ":last-child": { pb: 0 }
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
- height: "100%",
33
- ...l
36
+ display: "flex",
37
+ flexDirection: "column",
38
+ minWidth: 288,
39
+ maxWidth: 848,
40
+ ...s
34
41
  },
35
- title: o.mini_title,
36
- children: /* @__PURE__ */ i(C, {})
42
+ title: i.mini_title,
43
+ children: /* @__PURE__ */ o(x, {})
37
44
  });
38
- }, D = S(T);
45
+ }, G = C(L);
39
46
  export {
40
- D as default
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={{ height: 'calc(100% - 72px)', minHeight: 300, ':last-child': { pb: 0 } }}\n onPrimaryCtaClick={onPrimaryCtaClick}\n primaryCtaLabel={trendsCopy.primary_cta}\n subTitle={trendsCopy.sub_title}\n sx={{ height: '100%', ...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,QAAQ;AAAA,MAAqB,WAAW;AAAA,MAAK,eAAe,EAAE,IAAI,EAAE;AAAA,IAAE;AAAA,IACpE,mBAAA;AAAA,IACnB,iBAAiB,EAAW;AAAA,IAC5B,UAAU,EAAW;AAAA,IACrB,IAAI;AAAA,MAAE,QAAQ;AAAA,MAAQ,GAAG;AAAA,IAAG;AAAA,IAC5B,OAAO,EAAW;AAAA,IAElB,UAAA,gBAAA,EAAC,GAAD,CAAgB,CAAA;AAAA,EACG,CAAA;AAEzB,GAEA,IAAe,EAAS,CAAgB"}
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 s, useGlobalCopyStore as n, useWidgetContainerProvider as i } from "../../common/context/hooks.es.js";
2
- import { LineChart as m } from "../../common/components/charts/LineChart.es.js";
3
- import { getSpendingData as l } from "../utils/SpendingData.es.js";
4
- import p from "react";
5
- import { observer as u } from "mobx-react-lite";
6
- import { jsx as d } from "react/jsx-runtime";
7
- import { useTheme as g } from "@mui/material/styles";
8
- var h = () => {
9
- const { monthlyCategoryTotals: e } = s(), { trends: t } = n(), r = g(), { availableHeight: o = 300 } = i(), a = p.useMemo(() => l(e), [e]);
10
- return /* @__PURE__ */ d(m, {
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
- colors: [r.palette.primary.main],
13
- datasets: [a],
14
- height: o,
15
- labels: [t.spending_label],
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
- }, w = u(h);
59
+ }, H = y(v);
24
60
  export {
25
- w as default
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 { getSpendingData } from '../utils/SpendingData'\n\nconst SpendingChart = () => {\n const { monthlyCategoryTotals } = useCategoryStore()\n const { trends: trendsCopy } = useGlobalCopyStore()\n const theme = useTheme()\n const { availableHeight = 300 } = useWidgetContainerProvider()\n\n const data = React.useMemo(() => getSpendingData(monthlyCategoryTotals), [monthlyCategoryTotals])\n\n return (\n <LineChart\n baseline=\"min\"\n colors={[theme.palette.primary.main]}\n datasets={[data]}\n height={availableHeight}\n labels={[trendsCopy.spending_label]}\n showArea={true}\n showAverage={true}\n showLegend={true}\n showMarkLabel={true}\n useCustomMark={true}\n valueFormatterString=\"0,0\"\n />\n )\n}\n\nexport default observer(SpendingChart)\n"],"mappings":";;;;;;;AAUA,IAAM,IAAA,MAAsB;AAC1B,QAAM,EAAE,uBAAA,EAAA,IAA0B,EAAiB,GAC7C,EAAE,QAAQ,EAAA,IAAe,EAAmB,GAC5C,IAAQ,EAAS,GACjB,EAAE,iBAAA,IAAkB,IAAA,IAAQ,EAA2B,GAEvD,IAAO,EAAM,QAAA,MAAc,EAAgB,CAAqB,GAAG,CAAC,CAAqB,CAAC;AAEhG,SACE,gBAAA,EAAC,GAAD;AAAA,IACE,UAAS;AAAA,IACT,QAAQ,CAAC,EAAM,QAAQ,QAAQ,IAAI;AAAA,IACnC,UAAU,CAAC,CAAI;AAAA,IACf,QAAQ;AAAA,IACR,QAAQ,CAAC,EAAW,cAAc;AAAA,IAClC,UAAU;AAAA,IACV,aAAa;AAAA,IACb,YAAY;AAAA,IACZ,eAAe;AAAA,IACf,eAAe;AAAA,IACf,sBAAqB;AAAA,EACtB,CAAA;AAEL,GAEA,IAAe,EAAS,CAAa"}
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 i } from "../../core/constants/Category.es.js";
2
- import { DATE_FORMATS_INTL as m, formatDate as p } from "../../core/constants/DateFormats.es.js";
3
- import { isIncome as c, isPayment as h, isSpend as u } from "./shared.es.js";
4
- import { addMonths as f } from "date-fns/addMonths";
5
- import { endOfMonth as y } from "date-fns/endOfMonth";
6
- import { isBefore as d } from "date-fns/isBefore";
7
- import { startOfMonth as g } from "date-fns/startOfMonth";
8
- import { subMonths as T } from "date-fns/subMonths";
9
- var l = (a, o) => {
10
- const r = [];
11
- let t = g(o?.start ?? T(/* @__PURE__ */ new Date(), 5));
12
- const n = o?.end ?? /* @__PURE__ */ new Date();
13
- for (; d(t, n); )
14
- r.push({
15
- x: p(t, m.MONTH_SHORT),
16
- y: a.filter((e) => e.year === t.getFullYear() && e.month === t.getMonth() + 1).reduce((e, s) => e + s.total, 0)
17
- }), t = f(t, 1);
18
- return r;
19
- }, R = (a, o) => {
20
- const r = a.filter(c);
21
- return l(r, o).map((t) => ({
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
- }, F = (a, o) => {
26
- const r = a.filter(h);
27
- return l(r, o).map((t) => ({
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
- }, H = (a, o) => {
32
- const r = a.filter(u);
33
- return l(r, o);
34
- }, I = (a) => {
35
- const o = [], r = a.filter((e) => e.top_level_category_guid !== i.INCOME && e.top_level_category_guid !== i.TRANSFER && e.total > 0);
36
- let t = g(T(/* @__PURE__ */ new Date(), 5));
37
- const n = y(/* @__PURE__ */ new Date());
38
- for (; d(t, n); )
39
- o.push({
40
- x: p(t, m.MONTH_SHORT),
41
- y: r.filter((e) => e.year === t.getFullYear() && e.month === t.getMonth() + 1).reduce((e, s) => e + s.total, 0)
42
- }), t = f(t, 1);
43
- return o;
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
- R as getIncomeTotals,
47
- l as getMonthlyTotals,
48
- F as getPaymentTotals,
49
- I as getSpendingData,
50
- H as getSpendingTotals
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":";;;;;;;;AAeA,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,CAA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AACT"}
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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