@mx-cartographer/experiences 9.7.30 → 9.7.32
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/core/constants/InstitutionLogo.d.ts +2 -0
- package/dist/core/constants/InstitutionLogo.es.js +6 -0
- package/dist/core/constants/InstitutionLogo.es.js.map +1 -0
- package/dist/core/constants/index.d.ts +1 -0
- package/dist/core/index.es.js +137 -135
- package/dist/core/types/InsightsInstanceSlotData.d.ts +6 -1
- package/dist/core/types/InsightsInstanceSlotData.es.js.map +1 -1
- package/dist/core/types/localization/InsightsFeedCopy.d.ts +46 -0
- package/dist/core/types/localization/index.d.ts +1 -1
- package/dist/core/utils/SanitizeHtml.d.ts +2 -0
- package/dist/core/utils/SanitizeHtml.es.js +44 -0
- package/dist/core/utils/SanitizeHtml.es.js.map +1 -0
- package/dist/core/utils/index.d.ts +1 -0
- package/dist/dashboard/WelcomeDialog.es.js +78 -115
- package/dist/dashboard/WelcomeDialog.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/CreditUtilizationBlock/CreditUtilizationBlock.d.ts +10 -0
- package/dist/insights-v2/actionBlocks/CreditUtilizationBlock/CreditUtilizationBlock.es.js +32 -0
- package/dist/insights-v2/actionBlocks/CreditUtilizationBlock/CreditUtilizationBlock.es.js.map +1 -0
- package/dist/insights-v2/actionBlocks/CreditUtilizationBlock/CreditUtilizationContent.d.ts +16 -0
- package/dist/insights-v2/actionBlocks/CreditUtilizationBlock/CreditUtilizationContent.es.js +287 -0
- package/dist/insights-v2/actionBlocks/CreditUtilizationBlock/CreditUtilizationContent.es.js.map +1 -0
- package/dist/insights-v2/actionBlocks/CreditUtilizationBlock/index.d.ts +2 -0
- package/dist/insights-v2/actionBlocks/CreditUtilizationBlock/layout.d.ts +32 -0
- package/dist/insights-v2/actionBlocks/CreditUtilizationBlock/layout.es.js +66 -0
- package/dist/insights-v2/actionBlocks/CreditUtilizationBlock/layout.es.js.map +1 -0
- package/dist/insights-v2/actionBlocks/CreditUtilizationBlock/useCreditUtilizationPrepare.d.ts +1 -0
- package/dist/insights-v2/actionBlocks/CreditUtilizationBlock/useCreditUtilizationPrepare.es.js +13 -0
- package/dist/insights-v2/actionBlocks/CreditUtilizationBlock/useCreditUtilizationPrepare.es.js.map +1 -0
- package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/EmergencySavingsBlock.d.ts +4 -0
- package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/EmergencySavingsBlock.es.js +80 -0
- package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/EmergencySavingsBlock.es.js.map +1 -0
- package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/SavingsCalculator.d.ts +8 -0
- package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/SavingsCalculator.es.js +138 -0
- package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/SavingsCalculator.es.js.map +1 -0
- package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/index.d.ts +1 -0
- package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/layout.d.ts +52 -0
- package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/layout.es.js +72 -0
- package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/layout.es.js.map +1 -0
- package/dist/insights-v2/actionBlocks/RemainingCashBlock/RemainingCashBlock.es.js +31 -30
- package/dist/insights-v2/actionBlocks/RemainingCashBlock/RemainingCashBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/RemainingCashBlock/layout.d.ts +0 -6
- package/dist/insights-v2/actionBlocks/RemainingCashBlock/layout.es.js +13 -14
- package/dist/insights-v2/actionBlocks/RemainingCashBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/mappings/actionBlocksKey.d.ts +2 -0
- package/dist/insights-v2/mappings/actionBlocksKey.es.js +2 -0
- package/dist/insights-v2/mappings/actionBlocksKey.es.js.map +1 -1
- package/dist/insights-v2/mappings/blocks.es.js +91 -78
- package/dist/insights-v2/mappings/blocks.es.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { formatCurrency as E } from "../../../core/utils/NumberFormatting.es.js";
|
|
2
|
+
import { Select as g } from "../../../common/components/Select.es.js";
|
|
3
|
+
import { CADENCES as v, DEADLINE_UNITS as _, calculateContribution as A } from "./layout.es.js";
|
|
4
|
+
import i from "react";
|
|
5
|
+
import l from "@mui/material/Stack";
|
|
6
|
+
import { Text as d } from "@mxenabled/mxui";
|
|
7
|
+
import L from "@mui/material/Button";
|
|
8
|
+
import { jsx as a, jsxs as r } from "react/jsx-runtime";
|
|
9
|
+
import f from "@mui/material/TextField";
|
|
10
|
+
var U = 2, j = 2, M = "6", x = (o) => {
|
|
11
|
+
const [e, ...s] = o.replace(/[^0-9.]/g, "").split(".");
|
|
12
|
+
return s.length ? `${e}.${s.join("")}` : e;
|
|
13
|
+
}, S = (o) => o === "" ? NaN : Number(o), I = { htmlInput: {
|
|
14
|
+
inputMode: "decimal",
|
|
15
|
+
pattern: "[0-9]*[.]?[0-9]*"
|
|
16
|
+
} }, O = ({ balance: o, copy: e, goal: s }) => {
|
|
17
|
+
const [c, C] = i.useState(String(s)), [m, N] = i.useState(U), [p, D] = i.useState(j), [h, w] = i.useState(M), [u, T] = i.useState();
|
|
18
|
+
return /* @__PURE__ */ r(l, {
|
|
19
|
+
component: "form",
|
|
20
|
+
onSubmit: (t) => {
|
|
21
|
+
t.preventDefault();
|
|
22
|
+
const n = v[m], b = A({
|
|
23
|
+
balance: o,
|
|
24
|
+
goal: S(c),
|
|
25
|
+
cadence: n,
|
|
26
|
+
deadline: _[p],
|
|
27
|
+
deadlineQuantity: S(h)
|
|
28
|
+
});
|
|
29
|
+
T(b === void 0 ? void 0 : {
|
|
30
|
+
amount: b,
|
|
31
|
+
period: e[n.periodKey]
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
sx: {
|
|
35
|
+
bgcolor: "background.paper",
|
|
36
|
+
borderRadius: "8px",
|
|
37
|
+
gap: 24,
|
|
38
|
+
p: 16
|
|
39
|
+
},
|
|
40
|
+
children: [
|
|
41
|
+
/* @__PURE__ */ r(l, {
|
|
42
|
+
sx: { gap: 8 },
|
|
43
|
+
children: [/* @__PURE__ */ a(d, {
|
|
44
|
+
component: "h3",
|
|
45
|
+
variant: "h3",
|
|
46
|
+
children: e.how_to_get_there
|
|
47
|
+
}), /* @__PURE__ */ a(d, {
|
|
48
|
+
color: "text.secondary",
|
|
49
|
+
truncate: !1,
|
|
50
|
+
variant: "body2",
|
|
51
|
+
children: e.adjust_the_inputs_below_to_find_a_comfortable_amount
|
|
52
|
+
})]
|
|
53
|
+
}),
|
|
54
|
+
/* @__PURE__ */ a(f, {
|
|
55
|
+
fullWidth: !0,
|
|
56
|
+
label: e.savings_goal,
|
|
57
|
+
onChange: (t) => C(x(t.target.value)),
|
|
58
|
+
slotProps: I,
|
|
59
|
+
value: c
|
|
60
|
+
}),
|
|
61
|
+
/* @__PURE__ */ a(g, {
|
|
62
|
+
label: e.how_often_can_you_contribute,
|
|
63
|
+
onChange: N,
|
|
64
|
+
options: v.map(({ labelKey: t }, n) => ({
|
|
65
|
+
id: n,
|
|
66
|
+
label: e[t]
|
|
67
|
+
})),
|
|
68
|
+
value: m
|
|
69
|
+
}),
|
|
70
|
+
/* @__PURE__ */ r(l, {
|
|
71
|
+
sx: {
|
|
72
|
+
flexDirection: "row",
|
|
73
|
+
gap: 8
|
|
74
|
+
},
|
|
75
|
+
children: [/* @__PURE__ */ a(f, {
|
|
76
|
+
fullWidth: !0,
|
|
77
|
+
label: e.meet_your_goal_within,
|
|
78
|
+
onChange: (t) => w(x(t.target.value)),
|
|
79
|
+
slotProps: I,
|
|
80
|
+
value: h
|
|
81
|
+
}), /* @__PURE__ */ a(g, {
|
|
82
|
+
inputProps: { "aria-label": e.meet_your_goal_within },
|
|
83
|
+
label: "",
|
|
84
|
+
onChange: D,
|
|
85
|
+
options: _.map(({ labelKey: t }, n) => ({
|
|
86
|
+
id: n,
|
|
87
|
+
label: e[t]
|
|
88
|
+
})),
|
|
89
|
+
sx: { minWidth: 128 },
|
|
90
|
+
value: p
|
|
91
|
+
})]
|
|
92
|
+
}),
|
|
93
|
+
u && /* @__PURE__ */ r(l, {
|
|
94
|
+
role: "status",
|
|
95
|
+
sx: {
|
|
96
|
+
alignItems: "center",
|
|
97
|
+
border: "1px solid",
|
|
98
|
+
borderColor: "divider",
|
|
99
|
+
borderRadius: "8px",
|
|
100
|
+
gap: 4,
|
|
101
|
+
p: 12
|
|
102
|
+
},
|
|
103
|
+
children: [/* @__PURE__ */ a(d, {
|
|
104
|
+
bold: !0,
|
|
105
|
+
variant: "body1",
|
|
106
|
+
children: e.estimated_contribution
|
|
107
|
+
}), /* @__PURE__ */ r(l, {
|
|
108
|
+
sx: {
|
|
109
|
+
alignItems: "baseline",
|
|
110
|
+
flexDirection: "row",
|
|
111
|
+
gap: 8
|
|
112
|
+
},
|
|
113
|
+
children: [/* @__PURE__ */ a(d, {
|
|
114
|
+
bold: !0,
|
|
115
|
+
color: "success.main",
|
|
116
|
+
component: "p",
|
|
117
|
+
variant: "h2",
|
|
118
|
+
children: E(u.amount, "0,0.00")
|
|
119
|
+
}), /* @__PURE__ */ r(d, {
|
|
120
|
+
variant: "body1",
|
|
121
|
+
children: ["/ ", u.period.toLowerCase()]
|
|
122
|
+
})]
|
|
123
|
+
})]
|
|
124
|
+
}),
|
|
125
|
+
/* @__PURE__ */ a(L, {
|
|
126
|
+
fullWidth: !0,
|
|
127
|
+
type: "submit",
|
|
128
|
+
variant: "contained",
|
|
129
|
+
children: e.calculate
|
|
130
|
+
})
|
|
131
|
+
]
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
export {
|
|
135
|
+
O as SavingsCalculator
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
//# sourceMappingURL=SavingsCalculator.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SavingsCalculator.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/EmergencySavingsBlock/SavingsCalculator.tsx"],"sourcesContent":["import React from 'react'\n\nimport Button from '@mui/material/Button'\nimport Stack from '@mui/material/Stack'\nimport TextField from '@mui/material/TextField'\n\nimport { Text } from '@mxenabled/mxui'\n\nimport { Select } from '../../../common'\nimport type { EmergencySavingsCopy } from '../../../core'\nimport { formatCurrency } from '../../../core/utils/NumberFormatting'\n\nimport { CADENCES, DEADLINE_UNITS, calculateContribution } from './layout'\n\nconst MONTHLY = 2\nconst MONTHS = 2\nconst DEFAULT_DEADLINE_QUANTITY = '6'\n\nconst toDecimalInput = (value: string) => {\n const [whole, ...fraction] = value.replace(/[^0-9.]/g, '').split('.')\n\n return fraction.length ? `${whole}.${fraction.join('')}` : whole\n}\n\nconst toNumber = (input: string) => (input === '' ? Number.NaN : Number(input))\n\nconst NUMERIC_INPUT = { htmlInput: { inputMode: 'decimal', pattern: '[0-9]*[.]?[0-9]*' } } as const\n\ninterface SavingsCalculatorProps {\n balance: number\n goal: number\n copy: EmergencySavingsCopy\n}\n\ninterface Solution {\n amount: number\n period: string\n}\n\nexport const SavingsCalculator = ({ balance, copy, goal }: SavingsCalculatorProps) => {\n const [savingsGoal, setSavingsGoal] = React.useState(String(goal))\n const [cadenceIndex, setCadenceIndex] = React.useState(MONTHLY)\n const [deadlineIndex, setDeadlineIndex] = React.useState(MONTHS)\n const [deadlineQuantity, setDeadlineQuantity] = React.useState(DEFAULT_DEADLINE_QUANTITY)\n const [solution, setSolution] = React.useState<Solution>()\n\n const handleSubmit = (event: React.FormEvent) => {\n event.preventDefault()\n\n const cadence = CADENCES[cadenceIndex]\n const amount = calculateContribution({\n balance,\n goal: toNumber(savingsGoal),\n cadence,\n deadline: DEADLINE_UNITS[deadlineIndex],\n deadlineQuantity: toNumber(deadlineQuantity),\n })\n\n setSolution(amount === undefined ? undefined : { amount, period: copy[cadence.periodKey] })\n }\n\n return (\n <Stack\n component=\"form\"\n onSubmit={handleSubmit}\n sx={{ bgcolor: 'background.paper', borderRadius: '8px', gap: 24, p: 16 }}\n >\n <Stack sx={{ gap: 8 }}>\n <Text component=\"h3\" variant=\"h3\">\n {copy.how_to_get_there}\n </Text>\n <Text color=\"text.secondary\" truncate={false} variant=\"body2\">\n {copy.adjust_the_inputs_below_to_find_a_comfortable_amount}\n </Text>\n </Stack>\n <TextField\n fullWidth={true}\n label={copy.savings_goal}\n onChange={(event) => setSavingsGoal(toDecimalInput(event.target.value))}\n slotProps={NUMERIC_INPUT}\n value={savingsGoal}\n />\n <Select\n label={copy.how_often_can_you_contribute}\n onChange={setCadenceIndex}\n options={CADENCES.map(({ labelKey }, id) => ({ id, label: copy[labelKey] }))}\n value={cadenceIndex}\n />\n <Stack sx={{ flexDirection: 'row', gap: 8 }}>\n <TextField\n fullWidth={true}\n label={copy.meet_your_goal_within}\n onChange={(event) => setDeadlineQuantity(toDecimalInput(event.target.value))}\n slotProps={NUMERIC_INPUT}\n value={deadlineQuantity}\n />\n <Select\n inputProps={{ 'aria-label': copy.meet_your_goal_within }}\n label=\"\"\n onChange={setDeadlineIndex}\n options={DEADLINE_UNITS.map(({ labelKey }, id) => ({ id, label: copy[labelKey] }))}\n sx={{ minWidth: 128 }}\n value={deadlineIndex}\n />\n </Stack>\n {solution && (\n <Stack\n role=\"status\"\n sx={{\n alignItems: 'center',\n border: '1px solid',\n borderColor: 'divider',\n borderRadius: '8px',\n gap: 4,\n p: 12,\n }}\n >\n <Text bold={true} variant=\"body1\">\n {copy.estimated_contribution}\n </Text>\n <Stack sx={{ alignItems: 'baseline', flexDirection: 'row', gap: 8 }}>\n <Text bold={true} color=\"success.main\" component=\"p\" variant=\"h2\">\n {formatCurrency(solution.amount, '0,0.00')}\n </Text>\n <Text variant=\"body1\">/ {solution.period.toLowerCase()}</Text>\n </Stack>\n </Stack>\n )}\n <Button fullWidth={true} type=\"submit\" variant=\"contained\">\n {copy.calculate}\n </Button>\n </Stack>\n )\n}\n"],"mappings":";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AQ;AAAA,YAAE,IAAA;AAAA,YAAI,OAAO,EAAK,CAAA;AAAA,UAAU,EAAE;AAAA,UACjF,IAAI,EAAE,UAAU,IAAI;AAAA,UACpB,OAAO;AAAA,QACR,CAAA,CACI;AAAA;MACN,KACC,gBAAA,EAAC,GAAD;AAAA,QACE,MAAK;AAAA,QACL,IAAI;AAAA,UACF,YAAY;AAAA,UACZ,QAAQ;AAAA,UACR,aAAa;AAAA,UACb,cAAc;AAAA,UACd,KAAK;AAAA,UACL,GAAG;AAAA,QACL;AAAA,QATF,UAAA,CAWE,gBAAA,EAAC,GAAD;AAAA,UAAM,MAAM;AAAA,UAAM,SAAQ;AAAA,UACvB,UAAA,EAAK;AAAA,QACF,CAAA,GACN,gBAAA,EAAC,GAAD;AAAA,UAAO,IAAI;AAAA,YAAE,YAAY;AAAA,YAAY,eAAe;AAAA,YAAO,KAAK;AAAA,UAAE;AAAA,UAAlE,UAAA,CACE,gBAAA,EAAC,GAAD;AAAA,YAAM,MAAM;AAAA,YAAM,OAAM;AAAA,YAAe,WAAU;AAAA,YAAI,SAAQ;AAAA,YAC1D,UAAA,EAAe,EAAS,QAAQ,QAAQ;AAAA,UACrC,CAAA,GACN,gBAAA,EAAC,GAAD;AAAA,YAAM,SAAQ;AAAA,YAAd,UAAA,CAAsB,MAAG,EAAS,OAAO,YAAY,CAAQ;AAAA,UACxD,CAAA,CAAA;AAAA,QACF,CAAA,CAAA;AAAA;MAET,gBAAA,EAAC,GAAD;AAAA,QAAQ,WAAW;AAAA,QAAM,MAAK;AAAA,QAAS,SAAQ;AAAA,QAC5C,UAAA,EAAK;AAAA,MACA,CAAA;AAAA,IACH;AAAA;AAEX"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { EmergencySavingsBlock } from './EmergencySavingsBlock';
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export declare const stepForBalance: (balance: number) => {
|
|
2
|
+
below: 100;
|
|
3
|
+
goal: 100;
|
|
4
|
+
labelKey: "step_one";
|
|
5
|
+
index: number;
|
|
6
|
+
} | {
|
|
7
|
+
below: 500;
|
|
8
|
+
goal: 500;
|
|
9
|
+
labelKey: "step_two";
|
|
10
|
+
index: number;
|
|
11
|
+
} | {
|
|
12
|
+
below: number;
|
|
13
|
+
goal: 1000;
|
|
14
|
+
labelKey: "final_step";
|
|
15
|
+
index: number;
|
|
16
|
+
};
|
|
17
|
+
export declare const CADENCES: readonly [{
|
|
18
|
+
readonly labelKey: "once_per_week";
|
|
19
|
+
readonly periodKey: "week";
|
|
20
|
+
readonly months: 0.25;
|
|
21
|
+
}, {
|
|
22
|
+
readonly labelKey: "every_other_week";
|
|
23
|
+
readonly periodKey: "every_other_week_period";
|
|
24
|
+
readonly months: 0.5;
|
|
25
|
+
}, {
|
|
26
|
+
readonly labelKey: "once_per_month";
|
|
27
|
+
readonly periodKey: "month";
|
|
28
|
+
readonly months: 1;
|
|
29
|
+
}, {
|
|
30
|
+
readonly labelKey: "every_three_months";
|
|
31
|
+
readonly periodKey: "three_month_period";
|
|
32
|
+
readonly months: 3;
|
|
33
|
+
}];
|
|
34
|
+
export declare const DEADLINE_UNITS: readonly [{
|
|
35
|
+
readonly labelKey: "days";
|
|
36
|
+
readonly months: 0.0323;
|
|
37
|
+
}, {
|
|
38
|
+
readonly labelKey: "weeks";
|
|
39
|
+
readonly months: 0.25;
|
|
40
|
+
}, {
|
|
41
|
+
readonly labelKey: "months";
|
|
42
|
+
readonly months: 1;
|
|
43
|
+
}];
|
|
44
|
+
interface ContributionInput {
|
|
45
|
+
balance: number;
|
|
46
|
+
goal: number;
|
|
47
|
+
cadence: (typeof CADENCES)[number];
|
|
48
|
+
deadline: (typeof DEADLINE_UNITS)[number];
|
|
49
|
+
deadlineQuantity: number;
|
|
50
|
+
}
|
|
51
|
+
export declare const calculateContribution: ({ balance, goal, cadence, deadline, deadlineQuantity, }: ContributionInput) => number | undefined;
|
|
52
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
var a = [
|
|
2
|
+
{
|
|
3
|
+
below: 100,
|
|
4
|
+
goal: 100,
|
|
5
|
+
labelKey: "step_one"
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
below: 500,
|
|
9
|
+
goal: 500,
|
|
10
|
+
labelKey: "step_two"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
below: 1 / 0,
|
|
14
|
+
goal: 1e3,
|
|
15
|
+
labelKey: "final_step"
|
|
16
|
+
}
|
|
17
|
+
], m = (t) => {
|
|
18
|
+
const e = a.findIndex(({ below: n }) => t < n);
|
|
19
|
+
return {
|
|
20
|
+
index: e,
|
|
21
|
+
...a[e]
|
|
22
|
+
};
|
|
23
|
+
}, y = [
|
|
24
|
+
{
|
|
25
|
+
labelKey: "once_per_week",
|
|
26
|
+
periodKey: "week",
|
|
27
|
+
months: 0.25
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
labelKey: "every_other_week",
|
|
31
|
+
periodKey: "every_other_week_period",
|
|
32
|
+
months: 0.5
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
labelKey: "once_per_month",
|
|
36
|
+
periodKey: "month",
|
|
37
|
+
months: 1
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
labelKey: "every_three_months",
|
|
41
|
+
periodKey: "three_month_period",
|
|
42
|
+
months: 3
|
|
43
|
+
}
|
|
44
|
+
], h = [
|
|
45
|
+
{
|
|
46
|
+
labelKey: "days",
|
|
47
|
+
months: 0.0323
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
labelKey: "weeks",
|
|
51
|
+
months: 0.25
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
labelKey: "months",
|
|
55
|
+
months: 1
|
|
56
|
+
}
|
|
57
|
+
], b = ({ balance: t, goal: e, cadence: n, deadline: l, deadlineQuantity: i }) => {
|
|
58
|
+
const o = e - t;
|
|
59
|
+
if (Number.isNaN(o)) return;
|
|
60
|
+
if (o <= 0) return 0;
|
|
61
|
+
const s = i * l.months / n.months, r = Number((o / s).toFixed(2));
|
|
62
|
+
if (!Number.isNaN(r))
|
|
63
|
+
return Math.min(r, Number(o.toFixed(2)));
|
|
64
|
+
};
|
|
65
|
+
export {
|
|
66
|
+
y as CADENCES,
|
|
67
|
+
h as DEADLINE_UNITS,
|
|
68
|
+
b as calculateContribution,
|
|
69
|
+
m as stepForBalance
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
//# sourceMappingURL=layout.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/EmergencySavingsBlock/layout.ts"],"sourcesContent":["const STEPS = [\n { below: 100, goal: 100, labelKey: 'step_one' },\n { below: 500, goal: 500, labelKey: 'step_two' },\n { below: Infinity, goal: 1000, labelKey: 'final_step' },\n] as const\n\nexport const stepForBalance = (balance: number) => {\n const index = STEPS.findIndex(({ below }) => balance < below)\n\n return { index, ...STEPS[index] }\n}\n\nexport const CADENCES = [\n { labelKey: 'once_per_week', periodKey: 'week', months: 0.25 },\n { labelKey: 'every_other_week', periodKey: 'every_other_week_period', months: 0.5 },\n { labelKey: 'once_per_month', periodKey: 'month', months: 1 },\n { labelKey: 'every_three_months', periodKey: 'three_month_period', months: 3 },\n] as const\n\nexport const DEADLINE_UNITS = [\n { labelKey: 'days', months: 0.0323 },\n { labelKey: 'weeks', months: 0.25 },\n { labelKey: 'months', months: 1 },\n] as const\n\ninterface ContributionInput {\n balance: number\n goal: number\n cadence: (typeof CADENCES)[number]\n deadline: (typeof DEADLINE_UNITS)[number]\n deadlineQuantity: number\n}\n\nexport const calculateContribution = ({\n balance,\n goal,\n cadence,\n deadline,\n deadlineQuantity,\n}: ContributionInput): number | undefined => {\n const remainingToSave = goal - balance\n\n if (Number.isNaN(remainingToSave)) return undefined\n if (remainingToSave <= 0) return 0\n\n const periods = (deadlineQuantity * deadline.months) / cadence.months\n const payment = Number((remainingToSave / periods).toFix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AACnC,MAAI,KAAmB,EAAG,QAAO;AAEjC,QAAM,IAAW,IAAmB,EAAS,SAAU,EAAQ,QACzD,IAAU,QAAQ,IAAkB,GAAS,QAAQ,CAAC,CAAC;AAE7D,MAAI,QAAO,MAAM,CAAO;AAExB,WAAO,KAAK,IAAI,GAAS,OAAO,EAAgB,QAAQ,CAAC,CAAC,CAAC;AAC7D"}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { CategoryGuids as T } from "../../../core/constants/Category.es.js";
|
|
2
|
-
import R from "../../../
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import b from "../../../
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
2
|
+
import { DEFAULT_INSTITUTION_LOGO_URL as R } from "../../../core/constants/InstitutionLogo.es.js";
|
|
3
|
+
import G from "../../../common/utils/AccountDisplayName.es.js";
|
|
4
|
+
import { useAccountStore as S, useActionContext as w, useAppConfig as A, useCashflowStore as I, useCategoryStore as U, useGlobalCopyStore as v, useRecurringTransactionsStore as E, useTransactionStore as O } from "../../../common/context/hooks.es.js";
|
|
5
|
+
import { getAccountStartingBalance as b } from "../../../core/utils/AccountUtils.es.js";
|
|
6
|
+
import k from "../../../common/components/Loader.es.js";
|
|
7
|
+
import { ErrorCard as N } from "../../components/ErrorCard.es.js";
|
|
8
|
+
import { useRecurringTransactionLoad as D } from "../RecurringTransactionBlock/useRecurringTransactionPrepare.es.js";
|
|
9
|
+
import { getCaption as F, getOtherLabel as z, groupRows as B } from "./layout.es.js";
|
|
9
10
|
import H from "./RemainingCashContent.es.js";
|
|
10
11
|
import { observer as P } from "mobx-react-lite";
|
|
11
12
|
import $ from "@mui/material/Stack";
|
|
12
13
|
import { CategoryIcon as d, InstitutionLogo as g, Text as j } from "@mxenabled/mxui";
|
|
13
|
-
import { jsx as
|
|
14
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
14
15
|
var p = (m, i, s) => {
|
|
15
16
|
const { others: a, shown: r } = B(m);
|
|
16
17
|
return a ? [...r, {
|
|
@@ -19,37 +20,37 @@ var p = (m, i, s) => {
|
|
|
19
20
|
leading: s,
|
|
20
21
|
name: z(i.one, i.multi, a.count)
|
|
21
22
|
}] : r;
|
|
22
|
-
},
|
|
23
|
-
const { common: s, insights_feed: a } =
|
|
24
|
-
if (a?.general && !o) return /* @__PURE__ */
|
|
23
|
+
}, ao = P(function(i) {
|
|
24
|
+
const { common: s, insights_feed: a } = v(), { config: r } = A(), { uiStore: n } = I(), { getTopLevelCategoryGuid: l } = U(), { accountsLoaded: h } = S(), { transactionsLoaded: u, transactionsLoading: y } = O(), { isDataLoaded: c } = E(), _ = w()?.recurringLoadFailed === !0, f = D(), C = c && !u && !y, o = a?.remaining_cash;
|
|
25
|
+
if (a?.general && !o) return /* @__PURE__ */ t($, {
|
|
25
26
|
sx: { p: 24 },
|
|
26
|
-
children: /* @__PURE__ */
|
|
27
|
+
children: /* @__PURE__ */ t(j, { children: s?.error_message })
|
|
27
28
|
});
|
|
28
|
-
if (_ && !c || C) return /* @__PURE__ */
|
|
29
|
+
if (_ && !c || C) return /* @__PURE__ */ t(N, { onRetry: () => {
|
|
29
30
|
f();
|
|
30
31
|
} });
|
|
31
|
-
if (!c || !h || !u || !o) return /* @__PURE__ */
|
|
32
|
-
const L = p(
|
|
33
|
-
amount:
|
|
32
|
+
if (!c || !h || !u || !o) return /* @__PURE__ */ t(k, {});
|
|
33
|
+
const L = p(n.selectedCashAccounts.map((e) => ({
|
|
34
|
+
amount: b(e, r.display_available_balance_in_accounts),
|
|
34
35
|
key: e.guid,
|
|
35
|
-
leading: /* @__PURE__ */
|
|
36
|
+
leading: /* @__PURE__ */ t(g, {
|
|
36
37
|
alt: "",
|
|
37
38
|
institutionGuid: e.institution_guid ?? "",
|
|
38
39
|
size: 32
|
|
39
40
|
}),
|
|
40
|
-
name:
|
|
41
|
+
name: G(e)
|
|
41
42
|
})), {
|
|
42
43
|
multi: o.other_accounts,
|
|
43
44
|
one: o.other_accounts_one
|
|
44
|
-
}, /* @__PURE__ */
|
|
45
|
+
}, /* @__PURE__ */ t(g, {
|
|
45
46
|
alt: "",
|
|
46
47
|
institutionGuid: "",
|
|
47
|
-
logoUrl:
|
|
48
|
+
logoUrl: R,
|
|
48
49
|
size: 32
|
|
49
|
-
})), x = p(
|
|
50
|
+
})), x = p(n.expensesTilNextIncome.map((e) => ({
|
|
50
51
|
amount: e.amount,
|
|
51
52
|
key: `${e.repeatingTransactionGuid}-${e.expectedDate.getTime()}`,
|
|
52
|
-
leading: /* @__PURE__ */
|
|
53
|
+
leading: /* @__PURE__ */ t(d, {
|
|
53
54
|
categoryGuid: l(e.categoryGuid),
|
|
54
55
|
size: 32
|
|
55
56
|
}),
|
|
@@ -57,11 +58,11 @@ var p = (m, i, s) => {
|
|
|
57
58
|
})), {
|
|
58
59
|
multi: o.other_expenses,
|
|
59
60
|
one: o.other_expenses_one
|
|
60
|
-
}, /* @__PURE__ */
|
|
61
|
+
}, /* @__PURE__ */ t(d, {
|
|
61
62
|
categoryGuid: T.UNCATEGORIZED,
|
|
62
63
|
size: 32
|
|
63
64
|
}));
|
|
64
|
-
return /* @__PURE__ */
|
|
65
|
+
return /* @__PURE__ */ t(H, {
|
|
65
66
|
accounts: {
|
|
66
67
|
header: o.accounts_header,
|
|
67
68
|
rows: L
|
|
@@ -71,19 +72,19 @@ var p = (m, i, s) => {
|
|
|
71
72
|
rows: x
|
|
72
73
|
},
|
|
73
74
|
summary: {
|
|
74
|
-
remaining:
|
|
75
|
-
amount:
|
|
76
|
-
caption: F(o,
|
|
75
|
+
remaining: n.hasUpcomingPayday ? {
|
|
76
|
+
amount: n.remainingUntilPayday,
|
|
77
|
+
caption: F(o, n.daysUntilNextIncome)
|
|
77
78
|
} : void 0,
|
|
78
|
-
cashOnHand:
|
|
79
|
+
cashOnHand: n.selectedCashBalance,
|
|
79
80
|
cashOnHandLabel: o.cash_on_hand,
|
|
80
|
-
upcomingExpenses:
|
|
81
|
+
upcomingExpenses: n.upcomingExpensesTotal,
|
|
81
82
|
upcomingExpensesLabel: o.upcoming_expenses
|
|
82
83
|
}
|
|
83
84
|
});
|
|
84
85
|
});
|
|
85
86
|
export {
|
|
86
|
-
|
|
87
|
+
ao as RemainingCashBlock
|
|
87
88
|
};
|
|
88
89
|
|
|
89
90
|
//# sourceMappingURL=RemainingCashBlock.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RemainingCashBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/RemainingCashBlock/RemainingCashBlock.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\n\nimport Stack from '@mui/material/Stack'\n\nimport { CategoryIcon, InstitutionLogo, Text } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport {\n Loader,\n useAccountStore,\n useActionContext,\n useAppConfig,\n useCashflowStore,\n useCategoryStore,\n useGlobalCopyStore,\n useRecurringTransactionsStore,\n useTransactionStore,\n} from '../../../common'\nimport getAccountDisplayName from '../../../common/utils/AccountDisplayName'\nimport { CategoryGuids } from '../../../core/constants/Category'\nimport { getAccountStartingBalance } from '../../../core/utils/AccountUtils'\nimport { ErrorCard } from '../../components/ErrorCard'\nimport type { ActionBlockProps } from '../../mappings/blocks'\nimport {\n type RecurringTransactionActionContext,\n useRecurringTransactionLoad,\n} from '../RecurringTransactionBlock'\n\nimport {
|
|
1
|
+
{"version":3,"file":"RemainingCashBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/RemainingCashBlock/RemainingCashBlock.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\n\nimport Stack from '@mui/material/Stack'\n\nimport { CategoryIcon, InstitutionLogo, Text } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport {\n Loader,\n useAccountStore,\n useActionContext,\n useAppConfig,\n useCashflowStore,\n useCategoryStore,\n useGlobalCopyStore,\n useRecurringTransactionsStore,\n useTransactionStore,\n} from '../../../common'\nimport getAccountDisplayName from '../../../common/utils/AccountDisplayName'\nimport { CategoryGuids } from '../../../core/constants/Category'\nimport { DEFAULT_INSTITUTION_LOGO_URL } from '../../../core/constants/InstitutionLogo'\nimport { getAccountStartingBalance } from '../../../core/utils/AccountUtils'\nimport { ErrorCard } from '../../components/ErrorCard'\nimport type { ActionBlockProps } from '../../mappings/blocks'\nimport {\n type RecurringTransactionActionContext,\n useRecurringTransactionLoad,\n} from '../RecurringTransactionBlock'\n\nimport { getCaption, getOtherLabel, groupRows } from './layout'\nimport RemainingCashContent from './RemainingCashContent'\nimport type { RemainingCashRow } from './RemainingCashContent'\n\n/** Top rows by amount, then one \"Other (#)\" row with the rest's count and total. */\nconst toSectionRows = (\n rows: RemainingCashRow[],\n otherLabel: { one: string; multi: string },\n otherLeading: ReactNode,\n): RemainingCashRow[] => {\n const { others, shown } = groupRows(rows)\n\n if (!others) return shown\n\n return [\n ...shown,\n {\n amount: others.total,\n key: 'other',\n leading: otherLeading,\n name: getOtherLabel(otherLabel.one, otherLabel.multi, others.count),\n },\n ]\n}\n\n/**\n * Remaining Cash drawer (WEC-1880) for the Payday Cash Left Over Status beat. Store-driven: the\n * figures are today's, from CashflowStore's UiStore, not the card's generation-time numbers\n * (accepted trade-off, see docs/action-blocks/remaining-cash-block.md).\n *\n * `observer` is required: everything rendered is read from MobX stores and computeds.\n */\nexport const RemainingCashBlock = observer(function RemainingCashBlock(_props: ActionBlockProps) {\n const { common: commonCopy, insights_feed: insightsFeedCopy } = useGlobalCopyStore()\n const { config } = useAppConfig()\n const { uiStore } = useCashflowStore()\n const { getTopLevelCategoryGuid } = useCategoryStore()\n const { accountsLoaded } = useAccountStore()\n const { transactionsLoaded, transactionsLoading } = useTransactionStore()\n const { isDataLoaded } = useRecurringTransactionsStore()\n const loadFailed =\n useActionContext<RecurringTransactionActionContext>()?.recurringLoadFailed === true\n const retryLoad = useRecurringTransactionLoad()\n\n // TransactionStore swallows a failed request, which would silently zero every expense (see the\n // States table in docs/action-blocks/remaining-cash-block.md). `transactionsLoading` excludes another\n // widget's request still in flight: loadTransactions returns early without awaiting it.\n const transactionsFailed = isDataLoaded && !transactionsLoaded && !transactionsLoading\n const copy = insightsFeedCopy?.remaining_cash\n\n // Copy loaded but without this namespace (the copy service has not shipped it). Copy loads once at\n // app start, so a retry cannot clear it: a plain message like ActionBlockLayer's unknown-block\n // state, not ErrorCard's Try Again, and never an endless loader.\n if (insightsFeedCopy?.general && !copy) {\n return (\n <Stack sx={{ p: 24 }}>\n <Text>{commonCopy?.error_message}</Text>\n </Stack>\n )\n }\n\n if ((loadFailed && !isDataLoaded) || transactionsFailed) {\n return <ErrorCard onRetry={() => void retryLoad()} />\n }\n\n // `accountsLoaded` / `transactionsLoaded` cover another widget's request still in flight.\n if (!isDataLoaded || !accountsLoaded || !transactionsLoaded || !copy) return <Loader />\n\n const accountRows = toSectionRows(\n uiStore.selectedCashAccounts.map((account) => ({\n amount: getAccountStartingBalance(account, config.display_available_balance_in_accounts),\n key: account.guid,\n // Decorative: the row's visible name already says which account it is.\n leading: (\n <InstitutionLogo alt=\"\" institutionGuid={account.institution_guid ?? ''} size={32} />\n ),\n name: getAccountDisplayName(account),\n })),\n { multi: copy.other_accounts, one: copy.other_accounts_one },\n <InstitutionLogo alt=\"\" institutionGuid=\"\" logoUrl={DEFAULT_INSTITUTION_LOGO_URL} size={32} />,\n )\n const expenseRows = toSectionRows(\n uiStore.expensesTilNextIncome.map((expense) => ({\n amount: expense.amount,\n key: `${expense.repeatingTransactionGuid}-${expense.expectedDate.getTime()}`,\n leading: (\n <CategoryIcon categoryGuid={getTopLevelCategoryGuid(expense.categoryGuid)} size={32} />\n ),\n name: expense.name,\n })),\n { multi: copy.other_expenses, one: copy.other_expenses_one },\n <CategoryIcon categoryGuid={CategoryGuids.UNCATEGORIZED} size={32} />,\n )\n\n return (\n <RemainingCashContent\n accounts={{ header: copy.accounts_header, rows: accountRows }}\n expenses={{ header: copy.recurring_expenses_header, rows: expenseRows }}\n summary={{\n remaining: uiStore.hasUpcomingPayday\n ? {\n amount: uiStore.remainingUntilPayday,\n caption: getCaption(copy, uiStore.daysUntilNextIncome),\n }\n : undefined,\n cashOnHand: uiStore.selectedCashBalance,\n cashOnHandLabel: copy.cash_on_hand,\n upcomingExpenses: uiStore.upcomingExpensesTotal,\n upcomingExpensesLabel: copy.upcoming_expenses,\n }}\n />\n )\n})\n"],"mappings":";;;;;;;;;;;;;;AAkCA,IAAM,IAAA,CACJ,GACA,GACA,MACuB;AACvB,QAAM,EAAE,QAAA,GAAQ,OAAA,EAAA,IAAU,EAAU,CAAI;AAExC,SAAK,IAEE,CACL,GAAG,GACH;AAAA,IACE,QAAQ,EAAO;AAAA,IACf,KAAK;AAAA,IACL,SAAS;AAAA,IACT,MAAM,EAAc,EAAW,KAAK,EAAW,OAAO,EAAO,KAAK;AAAA,EACpE,CACF,IAVoB;AAWtB,GASa,KAAqB,EAAS,SAA4B,GAA0B;AAC/F,QAAM,EAAE,QAAQ,GAAY,eAAe,EAAA,IAAqB,EAAmB,GAC7E,EAAE,QAAA,EAAA,IAAW,EAAa,GAC1B,EAAE,SAAA,EAAA,IAAY,EAAiB,GAC/B,EAAE,yBAAA,EAAA,IAA4B,EAAiB,GAC/C,EAAE,gBAAA,EAAA,IAAmB,EAAgB,GACrC,EAAE,oBAAA,GAAoB,qBAAA,EAAA,IAAwB,EAAoB,GAClE,EAAE,cAAA,EAAA,IAAiB,EAA8B,GACjD,IACJ,EAAoD,GAAG,wBAAwB,IAC3E,IAAY,EAA4B,GAKxC,IAAqB,KAAgB,CAAC,KAAsB,CAAC,GAC7D,IAAO,GAAkB;AAK/B,MAAI,GAAkB,WAAW,CAAC,EAChC,QACE,gBAAA,EAAC,GAAD;AAAA,IAAO,IAAI,EAAE,GAAG,GAAG;AAAA,IACjB,UAAA,gBAAA,EAAC,GAAD,EAAA,UAAO,GAAY,cAAoB,CAAA;AAAA,EAClC,CAAA;AAIX,MAAK,KAAc,CAAC,KAAiB,EACnC,QAAO,gBAAA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AAA,IAAY;AAAA,IAC5D,UAAU;AAAA,MAAE,QAAQ,EAAK;AAAA,MAA2B,MAAM;AAAA,IAAY;AAAA,IACtE,SAAS;AAAA,MACP,WAAW,EAAQ,oBACf;AAAA,QACE,QAAQ,EAAQ;AAAA,QAChB,SAAS,EAAW,GAAM,EAAQ,mBAAmB;AAAA,MACvD,IACA;AAAA,MACJ,YAAY,EAAQ;AAAA,MACpB,iBAAiB,EAAK;AAAA,MACtB,kBAAkB,EAAQ;AAAA,MAC1B,uBAAuB,EAAK;AAAA,IAC9B;AAAA,EACD,CAAA;AAEL,CAAC"}
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { RemainingCashCopy } from '../../../core';
|
|
2
2
|
/** Rows shown per section before the rest fold into an "Other (#)" row (Figma shows two). */
|
|
3
3
|
export declare const ROW_LIMIT = 2;
|
|
4
|
-
/**
|
|
5
|
-
* The grey bank tile on the "Other Accounts" row (Figma). It is MXUI's own `InstitutionLogo` fallback
|
|
6
|
-
* image; passing it as `logoUrl` shows it straight away, instead of after a failed request for an
|
|
7
|
-
* empty institution guid.
|
|
8
|
-
*/
|
|
9
|
-
export declare const DEFAULT_INSTITUTION_LOGO_URL = "https://content.moneydesktop.com/storage/MD_Assets/serenity/default_institution_logo.png";
|
|
10
4
|
export interface GroupedRows<T> {
|
|
11
5
|
shown: T[];
|
|
12
6
|
others?: {
|
|
@@ -1,26 +1,25 @@
|
|
|
1
1
|
import { buildDynamicCopy as a, buildPluralCopy as i } from "../../../core/utils/Localization.es.js";
|
|
2
|
-
import { formatCurrency as
|
|
3
|
-
var m =
|
|
4
|
-
const
|
|
5
|
-
if (
|
|
6
|
-
const n =
|
|
2
|
+
import { formatCurrency as u } from "../../../core/utils/NumberFormatting.es.js";
|
|
3
|
+
var m = (t) => {
|
|
4
|
+
const r = [...t].sort((e, o) => o.amount - e.amount);
|
|
5
|
+
if (r.length <= 2) return { shown: r };
|
|
6
|
+
const n = r.slice(2);
|
|
7
7
|
return {
|
|
8
|
-
shown:
|
|
8
|
+
shown: r.slice(0, 2),
|
|
9
9
|
others: {
|
|
10
10
|
count: n.length,
|
|
11
11
|
total: n.reduce((e, o) => e + o.amount, 0)
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
|
-
}, c = (
|
|
15
|
-
const
|
|
16
|
-
return
|
|
17
|
-
},
|
|
14
|
+
}, c = (t) => {
|
|
15
|
+
const r = Math.round(Math.abs(t) * 100), n = u(r / 100, "0,0.00");
|
|
16
|
+
return t < 0 && r > 0 ? `-${n}` : n;
|
|
17
|
+
}, g = (t, r) => r === 1 ? t.remaining_until_payday_one : a(t.remaining_until_payday, String(r)), d = (t, r, n) => i(t, r, n, String(n));
|
|
18
18
|
export {
|
|
19
|
-
m as DEFAULT_INSTITUTION_LOGO_URL,
|
|
20
19
|
c as formatSignedCurrency,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
g as getCaption,
|
|
21
|
+
d as getOtherLabel,
|
|
22
|
+
m as groupRows
|
|
24
23
|
};
|
|
25
24
|
|
|
26
25
|
//# sourceMappingURL=layout.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/RemainingCashBlock/layout.ts"],"sourcesContent":["import type { RemainingCashCopy } from '../../../core'\nimport { buildDynamicCopy, buildPluralCopy } from '../../../core/utils/Localization'\nimport { formatCurrency } from '../../../core/utils/NumberFormatting'\n\n/** Rows shown per section before the rest fold into an \"Other (#)\" row (Figma shows two). */\nexport const ROW_LIMIT = 2\n\
|
|
1
|
+
{"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/RemainingCashBlock/layout.ts"],"sourcesContent":["import type { RemainingCashCopy } from '../../../core'\nimport { buildDynamicCopy, buildPluralCopy } from '../../../core/utils/Localization'\nimport { formatCurrency } from '../../../core/utils/NumberFormatting'\n\n/** Rows shown per section before the rest fold into an \"Other (#)\" row (Figma shows two). */\nexport const ROW_LIMIT = 2\n\nexport interface GroupedRows<T> {\n shown: T[]\n others?: { count: number; total: number }\n}\n\n/** Largest rows first (stable for ties), capped at `ROW_LIMIT`; the remainder as a count and total. */\nexport const groupRows = <T extends { amount: number }>(rows: T[]): GroupedRows<T> => {\n const sorted = [...rows].sort((a, b) => b.amount - a.amount)\n\n if (sorted.length <= ROW_LIMIT) return { shown: sorted }\n\n const rest = sorted.slice(ROW_LIMIT)\n\n return {\n shown: sorted.slice(0, ROW_LIMIT),\n others: { count: rest.length, total: rest.reduce((total, r) => total + r.amount, 0) },\n }\n}\n\n/**\n * `-$220.00`, not `$-220.00`: the sign goes before the currency symbol. Rounded to cents first so a\n * sub-cent negative (or `-0`) reads `$0.00`, never `-$0.00`.\n */\nexport const formatSignedCurrency = (amount: number): string => {\n const cents = Math.round(Math.abs(amount) * 100)\n const formatted = formatCurrency(cents / 100, '0,0.00')\n\n return amount < 0 && cents > 0 ? `-${formatted}` : formatted\n}\n\nexport const getCaption = (copy: RemainingCashCopy, days: number): string => {\n if (days === 1) return copy.remaining_until_payday_one\n\n return buildDynamicCopy(copy.remaining_until_payday, String(days)) as string\n}\n\nexport const getOtherLabel = (templateOne: string, templateMulti: string, count: number): string =>\n buildPluralCopy(templateOne, templateMulti, count, String(count)) as string\n"],"mappings":";;AAaA,IAAa,IAAA,CAA2C,MAA8B;AACpF,QAAM,IAAS,CAAC,GAAG,CAAI,EAAE,KAAA,CAAM,GAAG,MAAM,EAAE,SAAS,EAAE,MAAM;AAE3D,MAAI,EAAO,UAAA,EAAqB,QAAO,EAAE,OAAO,EAAO;AAEvD,QAAM,IAAO,EAAO,MAAA,CAAe;AAEnC,SAAO;AAAA,IACL,OAAO,EAAO,MAAM,GAAA,CAAY;AAAA,IAChC,QAAQ;AAAA,MAAE,OAAO,EAAK;AAAA,MAAQ,OAAO,EAAK,OAAA,CAAQ,GAAO,MAAM,IAAQ,EAAE,QAAQ,CAAC;AAAA,IAAE;AAAA,EACtF;AACF,GAMa,IAAA,CAAwB,MAA2B;AAC9D,QAAM,IAAQ,KAAK,MAAM,KAAK,IAAI,CAAM,IAAI,GAAG,GACzC,IAAY,EAAe,IAAQ,KAAK,QAAQ;AAEtD,SAAO,IAAS,KAAK,IAAQ,IAAI,IAAI,CAAA,KAAc;AACrD,GAEa,IAAA,CAAc,GAAyB,MAC9C,MAAS,IAAU,EAAK,6BAErB,EAAiB,EAAK,wBAAwB,OAAO,CAAI,CAAC,GAGtD,IAAA,CAAiB,GAAqB,GAAuB,MACxE,EAAgB,GAAa,GAAe,GAAO,OAAO,CAAK,CAAC"}
|
|
@@ -12,5 +12,7 @@ export declare const actionBlocksKey: {
|
|
|
12
12
|
TRANSACTION_LIST_ACTION_BLOCK: string;
|
|
13
13
|
REMAINING_CASH_ACTION_BLOCK: string;
|
|
14
14
|
AMOUNT_INPUT_MODAL_ACTION_BLOCK: string;
|
|
15
|
+
CREDIT_UTILIZATION_ACTION_BLOCK: string;
|
|
16
|
+
EMERGENCY_SAVINGS_ACTION_BLOCK: string;
|
|
15
17
|
PAYOFF_CALCULATOR_ACTION_BLOCK: string;
|
|
16
18
|
};
|
|
@@ -12,6 +12,8 @@ var _ = {
|
|
|
12
12
|
TRANSACTION_LIST_ACTION_BLOCK: "transaction_list_block",
|
|
13
13
|
REMAINING_CASH_ACTION_BLOCK: "remaining_cash_block",
|
|
14
14
|
AMOUNT_INPUT_MODAL_ACTION_BLOCK: "amount_input_modal_block",
|
|
15
|
+
CREDIT_UTILIZATION_ACTION_BLOCK: "credit_utilization_block",
|
|
16
|
+
EMERGENCY_SAVINGS_ACTION_BLOCK: "emergency_savings_block",
|
|
15
17
|
PAYOFF_CALCULATOR_ACTION_BLOCK: "payoff_calculator_block"
|
|
16
18
|
};
|
|
17
19
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actionBlocksKey.es.js","names":[],"sources":["../../../src/insights-v2/mappings/actionBlocksKey.ts"],"sourcesContent":["// Keys for the drawer drilldown registry in `blocks.ts`, extracted into their own module.\n//\n// Why: chart blocks (e.g. BarchartBlock, DoubleBarChartBlock) need\n// `TRANSCATION_HISTORY_ACTION_BLOCK` to tag a chart bar's drilldown context, but they are\n// themselves re-exported through `../blocks` -> `mappings/blocks.ts` imports from that same\n// barrel to build its `blocks` registry. Importing the key straight from `mappings/blocks.ts`\n// closed that loop into a circular import: evaluating `mappings/blocks.ts` pulled in the\n// `blocks` barrel, which (before it got to `ComponentBlocks`/`AccountBlock`) loaded\n// `BarchartBlock`, which imported back into the still-initializing `mappings/blocks.ts` —\n// tripping a \"Cannot access 'AccountBlock' before initialization\" TDZ error in Storybook/Vite.\n//\n// Keeping the keys here (no dependency on `mappings/blocks.ts`) lets chart blocks reference\n// them without re-entering that module.\n//\n// Names follow ditto: its registry ends every CTA block in `_block` and the V2 envelope copies those\n// names verbatim (`transaction_details_block`, `contact_support_block`, `make_transfer_block`).\nexport const actionBlocksKey = {\n PLACEHOLDER_ACTION_BLOCK: 'placeholder_block',\n MAKE_TRANSFER_ACTION_BLOCK: 'make_transfer_block',\n TRANSCATION_HISTORY_ACTION_BLOCK: 'transaction_history_block',\n TRANSACTION_DETAILS_ACTION_BLOCK: 'transaction_details_block',\n CONTACT_SUPPORT_ACTION_BLOCK: 'contact_support_block',\n FEEDBACK_MODAL_ACTION_BLOCK: 'feedback_modal_block',\n CONNECTION_DETAIL_ACTION_BLOCK: 'connection_detail_block',\n CONNECT_WIDGET_ACTION_BLOCK: 'connect_widget_block',\n SURVEY_MODAL_ACTION_BLOCK: 'survey_modal_block',\n RECURRING_TRANSACTION_ACTION_BLOCK: 'recurring_transaction_block',\n TRANSACTION_LIST_ACTION_BLOCK: 'transaction_list_block',\n REMAINING_CASH_ACTION_BLOCK: 'remaining_cash_block',\n AMOUNT_INPUT_MODAL_ACTION_BLOCK: 'amount_input_modal_block',\n PAYOFF_CALCULATOR_ACTION_BLOCK: 'payoff_calculator_block',\n}\n"],"mappings":"AAgBA,IAAa,IAAkB;AAAA,EAC7B,0BAA0B;AAAA,EAC1B,4BAA4B;AAAA,EAC5B,kCAAkC;AAAA,EAClC,kCAAkC;AAAA,EAClC,8BAA8B;AAAA,EAC9B,6BAA6B;AAAA,EAC7B,gCAAgC;AAAA,EAChC,6BAA6B;AAAA,EAC7B,2BAA2B;AAAA,EAC3B,oCAAoC;AAAA,EACpC,+BAA+B;AAAA,EAC/B,6BAA6B;AAAA,EAC7B,iCAAiC;AAAA,EACjC,gCAAgC;AAClC"}
|
|
1
|
+
{"version":3,"file":"actionBlocksKey.es.js","names":[],"sources":["../../../src/insights-v2/mappings/actionBlocksKey.ts"],"sourcesContent":["// Keys for the drawer drilldown registry in `blocks.ts`, extracted into their own module.\n//\n// Why: chart blocks (e.g. BarchartBlock, DoubleBarChartBlock) need\n// `TRANSCATION_HISTORY_ACTION_BLOCK` to tag a chart bar's drilldown context, but they are\n// themselves re-exported through `../blocks` -> `mappings/blocks.ts` imports from that same\n// barrel to build its `blocks` registry. Importing the key straight from `mappings/blocks.ts`\n// closed that loop into a circular import: evaluating `mappings/blocks.ts` pulled in the\n// `blocks` barrel, which (before it got to `ComponentBlocks`/`AccountBlock`) loaded\n// `BarchartBlock`, which imported back into the still-initializing `mappings/blocks.ts` —\n// tripping a \"Cannot access 'AccountBlock' before initialization\" TDZ error in Storybook/Vite.\n//\n// Keeping the keys here (no dependency on `mappings/blocks.ts`) lets chart blocks reference\n// them without re-entering that module.\n//\n// Names follow ditto: its registry ends every CTA block in `_block` and the V2 envelope copies those\n// names verbatim (`transaction_details_block`, `contact_support_block`, `make_transfer_block`).\nexport const actionBlocksKey = {\n PLACEHOLDER_ACTION_BLOCK: 'placeholder_block',\n MAKE_TRANSFER_ACTION_BLOCK: 'make_transfer_block',\n TRANSCATION_HISTORY_ACTION_BLOCK: 'transaction_history_block',\n TRANSACTION_DETAILS_ACTION_BLOCK: 'transaction_details_block',\n CONTACT_SUPPORT_ACTION_BLOCK: 'contact_support_block',\n FEEDBACK_MODAL_ACTION_BLOCK: 'feedback_modal_block',\n CONNECTION_DETAIL_ACTION_BLOCK: 'connection_detail_block',\n CONNECT_WIDGET_ACTION_BLOCK: 'connect_widget_block',\n SURVEY_MODAL_ACTION_BLOCK: 'survey_modal_block',\n RECURRING_TRANSACTION_ACTION_BLOCK: 'recurring_transaction_block',\n TRANSACTION_LIST_ACTION_BLOCK: 'transaction_list_block',\n REMAINING_CASH_ACTION_BLOCK: 'remaining_cash_block',\n AMOUNT_INPUT_MODAL_ACTION_BLOCK: 'amount_input_modal_block',\n CREDIT_UTILIZATION_ACTION_BLOCK: 'credit_utilization_block',\n EMERGENCY_SAVINGS_ACTION_BLOCK: 'emergency_savings_block',\n PAYOFF_CALCULATOR_ACTION_BLOCK: 'payoff_calculator_block',\n}\n"],"mappings":"AAgBA,IAAa,IAAkB;AAAA,EAC7B,0BAA0B;AAAA,EAC1B,4BAA4B;AAAA,EAC5B,kCAAkC;AAAA,EAClC,kCAAkC;AAAA,EAClC,8BAA8B;AAAA,EAC9B,6BAA6B;AAAA,EAC7B,gCAAgC;AAAA,EAChC,6BAA6B;AAAA,EAC7B,2BAA2B;AAAA,EAC3B,oCAAoC;AAAA,EACpC,+BAA+B;AAAA,EAC/B,6BAA6B;AAAA,EAC7B,iCAAiC;AAAA,EACjC,iCAAiC;AAAA,EACjC,gCAAgC;AAAA,EAChC,gCAAgC;AAClC"}
|