@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,287 @@
|
|
|
1
|
+
import { buildDynamicCopy as v } from "../../../core/utils/Localization.es.js";
|
|
2
|
+
import { sanitizeHtml as f } from "../../../core/utils/SanitizeHtml.es.js";
|
|
3
|
+
import { DEFAULT_INSTITUTION_LOGO_URL as _ } from "../../../core/constants/InstitutionLogo.es.js";
|
|
4
|
+
import { formatCurrency as w } from "../../../core/utils/NumberFormatting.es.js";
|
|
5
|
+
import I from "../../blocks/ChartBlocks/DonutChartBlock/DonutChart.es.js";
|
|
6
|
+
import { UTILIZATION_BANDS as b, getUtilizationBand as g } from "./layout.es.js";
|
|
7
|
+
import d from "@mui/material/Stack";
|
|
8
|
+
import { Icon as C, InstitutionLogo as D, Text as l } from "@mxenabled/mxui";
|
|
9
|
+
import { Fragment as S, jsx as e, jsxs as o } from "react/jsx-runtime";
|
|
10
|
+
import { useTheme as x } from "@mui/material/styles";
|
|
11
|
+
import m from "@mui/material/Box";
|
|
12
|
+
var h = (t) => w(t, "0,0.00"), u = ({ children: t }) => /* @__PURE__ */ e(d, {
|
|
13
|
+
sx: {
|
|
14
|
+
bgcolor: "background.paper",
|
|
15
|
+
p: 24
|
|
16
|
+
},
|
|
17
|
+
children: t
|
|
18
|
+
}), p = ({ children: t, mb: r = 16 }) => /* @__PURE__ */ e(l, {
|
|
19
|
+
bold: !0,
|
|
20
|
+
component: "h3",
|
|
21
|
+
sx: { mb: r },
|
|
22
|
+
variant: "body1",
|
|
23
|
+
children: t
|
|
24
|
+
}), z = ({ copy: t, summary: { balance: r, limit: n, percentage: i } }) => {
|
|
25
|
+
const a = x(), c = v(t.total_credit_utilized_aria, h(r), h(n), String(i));
|
|
26
|
+
return /* @__PURE__ */ e(m, {
|
|
27
|
+
"aria-label": c,
|
|
28
|
+
role: "img",
|
|
29
|
+
children: /* @__PURE__ */ e(I, {
|
|
30
|
+
centerValue: `${i}%`,
|
|
31
|
+
data: [{
|
|
32
|
+
color: g(i).color(a),
|
|
33
|
+
label: t.total_credit_utilized,
|
|
34
|
+
labelValue: `${h(r)} / ${h(n)}`,
|
|
35
|
+
value: i
|
|
36
|
+
}, {
|
|
37
|
+
color: a.palette.divider,
|
|
38
|
+
value: 100 - i
|
|
39
|
+
}]
|
|
40
|
+
})
|
|
41
|
+
});
|
|
42
|
+
}, y = ({ copy: t }) => {
|
|
43
|
+
const r = x(), n = b.length - 1;
|
|
44
|
+
return /* @__PURE__ */ o(u, { children: [
|
|
45
|
+
/* @__PURE__ */ e(p, {
|
|
46
|
+
mb: 24,
|
|
47
|
+
children: t.what_does_this_mean
|
|
48
|
+
}),
|
|
49
|
+
/* @__PURE__ */ e(d, {
|
|
50
|
+
"aria-label": t.what_does_this_mean,
|
|
51
|
+
component: "ul",
|
|
52
|
+
role: "list",
|
|
53
|
+
sx: {
|
|
54
|
+
flexDirection: "row",
|
|
55
|
+
gap: 2,
|
|
56
|
+
listStyle: "none",
|
|
57
|
+
m: 0,
|
|
58
|
+
mb: 24,
|
|
59
|
+
p: 0
|
|
60
|
+
},
|
|
61
|
+
children: b.map(({ band: i, color: a, range: c }, s) => /* @__PURE__ */ o(m, {
|
|
62
|
+
component: "li",
|
|
63
|
+
sx: {
|
|
64
|
+
flex: 1,
|
|
65
|
+
minWidth: 0,
|
|
66
|
+
overflowWrap: "anywhere"
|
|
67
|
+
},
|
|
68
|
+
children: [
|
|
69
|
+
/* @__PURE__ */ e(m, {
|
|
70
|
+
"aria-hidden": !0,
|
|
71
|
+
sx: {
|
|
72
|
+
bgcolor: a(r),
|
|
73
|
+
borderRadius: s === 0 ? "8px 0 0 8px" : s === n ? "0 8px 8px 0" : void 0,
|
|
74
|
+
height: 12,
|
|
75
|
+
mb: 8
|
|
76
|
+
}
|
|
77
|
+
}),
|
|
78
|
+
/* @__PURE__ */ e(l, {
|
|
79
|
+
bold: !0,
|
|
80
|
+
component: "p",
|
|
81
|
+
variant: "caption",
|
|
82
|
+
children: c
|
|
83
|
+
}),
|
|
84
|
+
/* @__PURE__ */ e(l, {
|
|
85
|
+
component: "p",
|
|
86
|
+
variant: "caption",
|
|
87
|
+
children: t[i]
|
|
88
|
+
})
|
|
89
|
+
]
|
|
90
|
+
}, i))
|
|
91
|
+
}),
|
|
92
|
+
/* @__PURE__ */ e(l, {
|
|
93
|
+
component: "p",
|
|
94
|
+
variant: "body2",
|
|
95
|
+
children: t.ratio_explanation
|
|
96
|
+
}),
|
|
97
|
+
/* @__PURE__ */ e(l, {
|
|
98
|
+
component: "p",
|
|
99
|
+
sx: { mt: 16 },
|
|
100
|
+
variant: "body2",
|
|
101
|
+
children: t.recommendation
|
|
102
|
+
})
|
|
103
|
+
] });
|
|
104
|
+
}, T = ({ card: t, copy: r }) => {
|
|
105
|
+
const n = x(), { limit: i, percentage: a } = t, c = i !== null && a !== null, s = c ? g(a).color(n) : n.palette.text.disabled;
|
|
106
|
+
return /* @__PURE__ */ o(m, {
|
|
107
|
+
component: "li",
|
|
108
|
+
sx: {
|
|
109
|
+
border: "1px solid",
|
|
110
|
+
borderColor: "divider",
|
|
111
|
+
borderRadius: "8px",
|
|
112
|
+
p: 16
|
|
113
|
+
},
|
|
114
|
+
children: [/* @__PURE__ */ o(d, {
|
|
115
|
+
sx: {
|
|
116
|
+
alignItems: "center",
|
|
117
|
+
flexDirection: "row",
|
|
118
|
+
gap: 12
|
|
119
|
+
},
|
|
120
|
+
children: [/* @__PURE__ */ e(D, {
|
|
121
|
+
alt: "",
|
|
122
|
+
institutionGuid: t.institutionGuid,
|
|
123
|
+
logoUrl: t.institutionGuid ? void 0 : _,
|
|
124
|
+
size: 40
|
|
125
|
+
}), /* @__PURE__ */ o(d, {
|
|
126
|
+
sx: {
|
|
127
|
+
flexGrow: 1,
|
|
128
|
+
gap: 4,
|
|
129
|
+
minWidth: 0
|
|
130
|
+
},
|
|
131
|
+
children: [/* @__PURE__ */ e(l, {
|
|
132
|
+
bold: !0,
|
|
133
|
+
truncate: !0,
|
|
134
|
+
variant: "body2",
|
|
135
|
+
children: t.label
|
|
136
|
+
}), c ? /* @__PURE__ */ e(m, {
|
|
137
|
+
"aria-label": t.label,
|
|
138
|
+
"aria-valuemax": 100,
|
|
139
|
+
"aria-valuemin": 0,
|
|
140
|
+
"aria-valuenow": a,
|
|
141
|
+
"aria-valuetext": `${a}%`,
|
|
142
|
+
role: "meter",
|
|
143
|
+
sx: {
|
|
144
|
+
bgcolor: "neutral.light",
|
|
145
|
+
borderRadius: 999,
|
|
146
|
+
height: 8,
|
|
147
|
+
overflow: "hidden"
|
|
148
|
+
},
|
|
149
|
+
children: /* @__PURE__ */ e(m, { sx: {
|
|
150
|
+
bgcolor: s,
|
|
151
|
+
borderRadius: 999,
|
|
152
|
+
height: "100%",
|
|
153
|
+
width: `${a}%`
|
|
154
|
+
} })
|
|
155
|
+
}) : /* @__PURE__ */ o(d, {
|
|
156
|
+
sx: {
|
|
157
|
+
alignItems: "center",
|
|
158
|
+
flexDirection: "row",
|
|
159
|
+
gap: 4
|
|
160
|
+
},
|
|
161
|
+
children: [/* @__PURE__ */ e(C, {
|
|
162
|
+
name: "info",
|
|
163
|
+
size: 14,
|
|
164
|
+
sx: { color: "text.secondary" }
|
|
165
|
+
}), /* @__PURE__ */ e(l, {
|
|
166
|
+
color: "text.secondary",
|
|
167
|
+
variant: "caption",
|
|
168
|
+
children: r.credit_limit_not_shared
|
|
169
|
+
})]
|
|
170
|
+
})]
|
|
171
|
+
})]
|
|
172
|
+
}), /* @__PURE__ */ o(d, {
|
|
173
|
+
sx: {
|
|
174
|
+
gap: 12,
|
|
175
|
+
mt: 24,
|
|
176
|
+
pl: 52
|
|
177
|
+
},
|
|
178
|
+
children: [/* @__PURE__ */ o(d, {
|
|
179
|
+
sx: {
|
|
180
|
+
alignItems: "center",
|
|
181
|
+
borderBottom: "1px solid",
|
|
182
|
+
borderColor: "divider",
|
|
183
|
+
flexDirection: "row",
|
|
184
|
+
justifyContent: "space-between",
|
|
185
|
+
pb: 10
|
|
186
|
+
},
|
|
187
|
+
children: [/* @__PURE__ */ o(d, {
|
|
188
|
+
sx: {
|
|
189
|
+
alignItems: "center",
|
|
190
|
+
flexDirection: "row",
|
|
191
|
+
gap: 8
|
|
192
|
+
},
|
|
193
|
+
children: [/* @__PURE__ */ e(m, { sx: {
|
|
194
|
+
bgcolor: s,
|
|
195
|
+
borderRadius: "1px",
|
|
196
|
+
flexShrink: 0,
|
|
197
|
+
height: 8,
|
|
198
|
+
width: 8
|
|
199
|
+
} }), /* @__PURE__ */ e(l, {
|
|
200
|
+
variant: "caption",
|
|
201
|
+
children: r.credit_utilized
|
|
202
|
+
})]
|
|
203
|
+
}), /* @__PURE__ */ o(d, {
|
|
204
|
+
sx: {
|
|
205
|
+
flexDirection: "row",
|
|
206
|
+
fontVariantNumeric: "tabular-nums",
|
|
207
|
+
gap: 4
|
|
208
|
+
},
|
|
209
|
+
children: [/* @__PURE__ */ e(l, {
|
|
210
|
+
bold: !0,
|
|
211
|
+
variant: "caption",
|
|
212
|
+
children: h(t.amount)
|
|
213
|
+
}), c && /* @__PURE__ */ o(S, { children: [/* @__PURE__ */ e(l, {
|
|
214
|
+
variant: "caption",
|
|
215
|
+
children: "/"
|
|
216
|
+
}), /* @__PURE__ */ e(l, {
|
|
217
|
+
variant: "caption",
|
|
218
|
+
children: h(i)
|
|
219
|
+
})] })]
|
|
220
|
+
})]
|
|
221
|
+
}), c && /* @__PURE__ */ o(d, {
|
|
222
|
+
sx: {
|
|
223
|
+
flexDirection: "row",
|
|
224
|
+
justifyContent: "space-between"
|
|
225
|
+
},
|
|
226
|
+
children: [/* @__PURE__ */ e(l, {
|
|
227
|
+
variant: "caption",
|
|
228
|
+
children: r.credit_utilization_ratio
|
|
229
|
+
}), /* @__PURE__ */ o(l, {
|
|
230
|
+
bold: !0,
|
|
231
|
+
variant: "caption",
|
|
232
|
+
children: [a, "%"]
|
|
233
|
+
})]
|
|
234
|
+
})]
|
|
235
|
+
})]
|
|
236
|
+
});
|
|
237
|
+
}, L = (t) => {
|
|
238
|
+
const r = /* @__PURE__ */ new Map();
|
|
239
|
+
return t.map((n) => {
|
|
240
|
+
const i = (r.get(n.guid) ?? 0) + 1;
|
|
241
|
+
return r.set(n.guid, i), {
|
|
242
|
+
card: n,
|
|
243
|
+
key: i === 1 ? n.guid : `${n.guid}-${i}`
|
|
244
|
+
};
|
|
245
|
+
});
|
|
246
|
+
}, M = ({ cards: t, copy: r, descriptionHtml: n, summary: i, title: a }) => /* @__PURE__ */ o(d, {
|
|
247
|
+
sx: {
|
|
248
|
+
bgcolor: "background.default",
|
|
249
|
+
gap: 8,
|
|
250
|
+
pb: 24
|
|
251
|
+
},
|
|
252
|
+
children: [
|
|
253
|
+
(a || i || n) && /* @__PURE__ */ o(u, { children: [
|
|
254
|
+
a && /* @__PURE__ */ e(p, { children: a }),
|
|
255
|
+
i && /* @__PURE__ */ e(z, {
|
|
256
|
+
copy: r,
|
|
257
|
+
summary: i
|
|
258
|
+
}),
|
|
259
|
+
n && /* @__PURE__ */ e(l, {
|
|
260
|
+
component: "p",
|
|
261
|
+
dangerouslySetInnerHTML: { __html: f(n) },
|
|
262
|
+
sx: { mt: 16 },
|
|
263
|
+
variant: "body2"
|
|
264
|
+
})
|
|
265
|
+
] }),
|
|
266
|
+
/* @__PURE__ */ e(y, { copy: r }),
|
|
267
|
+
t.length > 0 && /* @__PURE__ */ o(u, { children: [/* @__PURE__ */ e(p, { children: r.per_card_header }), /* @__PURE__ */ e(d, {
|
|
268
|
+
component: "ul",
|
|
269
|
+
role: "list",
|
|
270
|
+
sx: {
|
|
271
|
+
gap: 16,
|
|
272
|
+
listStyle: "none",
|
|
273
|
+
m: 0,
|
|
274
|
+
p: 0
|
|
275
|
+
},
|
|
276
|
+
children: L(t).map(({ card: c, key: s }) => /* @__PURE__ */ e(T, {
|
|
277
|
+
card: c,
|
|
278
|
+
copy: r
|
|
279
|
+
}, s))
|
|
280
|
+
})] })
|
|
281
|
+
]
|
|
282
|
+
});
|
|
283
|
+
export {
|
|
284
|
+
M as default
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
//# sourceMappingURL=CreditUtilizationContent.es.js.map
|
package/dist/insights-v2/actionBlocks/CreditUtilizationBlock/CreditUtilizationContent.es.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CreditUtilizationContent.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/CreditUtilizationBlock/CreditUtilizationContent.tsx"],"sourcesContent":["import Box from '@mui/material/Box'\nimport Stack from '@mui/material/Stack'\nimport { useTheme } from '@mui/material/styles'\n\nimport { Icon, InstitutionLogo, Text } from '@mxenabled/mxui'\n\nimport { DEFAULT_INSTITUTION_LOGO_URL } from '../../../core/constants/InstitutionLogo'\nimport type { CreditUtilizationCopy } from '../../../core/types/localization/InsightsFeedCopy'\nimport { buildDynamicCopy } from '../../../core/utils/Localization'\nimport { formatCurrency } from '../../../core/utils/NumberFormatting'\nimport { sanitizeHtml } from '../../../core/utils/SanitizeHtml'\nimport DonutChartV2 from '../../blocks/ChartBlocks/DonutChartBlock/DonutChart'\n\nimport {\n getUtilizationBand,\n UTILIZATION_BANDS,\n type CreditCardRow,\n type CreditUtilizationSummary,\n} from './layout'\n\nexport interface CreditUtilizationCard extends CreditCardRow {\n /** Empty when no loaded account matches the row's guid. */\n institutionGuid: string\n}\n\nexport interface CreditUtilizationContentProps {\n title?: string\n descriptionHtml?: string\n summary?: CreditUtilizationSummary\n cards: CreditUtilizationCard[]\n copy: CreditUtilizationCopy\n}\n\nconst formatMoney = (amount: number) => formatCurrency(amount, '0,0.00')\n\nconst Section = ({ children }: { children: React.ReactNode }) => (\n <Stack sx={{ bgcolor: 'background.paper', p: 24 }}>{children}</Stack>\n)\n\nconst SectionHeading = ({ children, mb = 16 }: { children: string; mb?: number }) => (\n <Text bold={true} component=\"h3\" sx={{ mb }} variant=\"body1\">\n {children}\n </Text>\n)\n\nconst Summary = ({\n copy,\n summary: { balance, limit, percentage },\n}: {\n copy: CreditUtilizationCopy\n summary: CreditUtilizationSummary\n}) => {\n const theme = useTheme()\n const label = buildDynamicCopy(\n copy.total_credit_utilized_aria,\n formatMoney(balance),\n formatMoney(limit),\n String(percentage),\n ) as string\n\n return (\n <Box aria-label={label} role=\"img\">\n <DonutChartV2\n centerValue={`${percentage}%`}\n data={[\n {\n color: getUtilizationBand(percentage).color(theme),\n label: copy.total_credit_utilized,\n labelValue: `${formatMoney(balance)} / ${formatMoney(limit)}`,\n value: percentage,\n },\n { color: theme.palette.divider, value: 100 - percentage },\n ]}\n />\n </Box>\n )\n}\n\nconst Legend = ({ copy }: { copy: CreditUtilizationCopy }) => {\n const theme = useTheme()\n const last = UTILIZATION_BANDS.length - 1\n\n return (\n <Section>\n <SectionHeading mb={24}>{copy.what_does_this_mean}</SectionHeading>\n <Stack\n aria-label={copy.what_does_this_mean}\n component=\"ul\"\n role=\"list\"\n sx={{ flexDirection: 'row', gap: 2, listStyle: 'none', m: 0, mb: 24, p: 0 }}\n >\n {UTILIZATION_BANDS.map(({ band, color, range }, index) => (\n <Box component=\"li\" key={band} sx={{ flex: 1, minWidth: 0, overflowWrap: 'anywhere' }}>\n <Box\n aria-hidden={true}\n sx={{\n bgcolor: color(theme),\n borderRadius:\n index === 0 ? '8px 0 0 8px' : index === last ? '0 8px 8px 0' : undefined,\n height: 12,\n mb: 8,\n }}\n />\n <Text bold={true} component=\"p\" variant=\"caption\">\n {range}\n </Text>\n <Text component=\"p\" variant=\"caption\">\n {copy[band]}\n </Text>\n </Box>\n ))}\n </Stack>\n <Text component=\"p\" variant=\"body2\">\n {copy.ratio_explanation}\n </Text>\n <Text component=\"p\" sx={{ mt: 16 }} variant=\"body2\">\n {copy.recommendation}\n </Text>\n </Section>\n )\n}\n\nconst CardUtilization = ({\n card,\n copy,\n}: {\n card: CreditUtilizationCard\n copy: CreditUtilizationCopy\n}) => {\n const theme = useTheme()\n const { limit, percentage } = card\n const hasLimit = limit !== null && percentage !== null\n const color = hasLimit ? getUtilizationBand(percentage).color(theme) : theme.palette.text.disabled\n\n return (\n <Box\n component=\"li\"\n sx={{ border: '1px solid', borderColor: 'divider', borderRadius: '8px', p: 16 }}\n >\n <Stack sx={{ alignItems: 'center', flexDirection: 'row', gap: 12 }}>\n <InstitutionLogo\n alt=\"\"\n institutionGuid={card.institutionGuid}\n logoUrl={card.institutionGuid ? undefined : DEFAULT_INSTITUTION_LOGO_URL}\n size={40}\n />\n <Stack sx={{ flexGrow: 1, gap: 4, minWidth: 0 }}>\n <Text bold={true} truncate={true} variant=\"body2\">\n {card.label}\n </Text>\n {hasLimit ? (\n <Box\n aria-label={card.label}\n aria-valuemax={100}\n aria-valuemin={0}\n aria-valuenow={percentage}\n aria-valuetext={`${percentage}%`}\n role=\"meter\"\n sx={{ bgcolor: 'neutral.light', borderRadius: 999, height: 8, overflow: 'hidden' }}\n >\n <Box\n sx={{ bgcolor: color, borderRadius: 999, height: '100%', width: `${percentage}%` }}\n />\n </Box>\n ) : (\n <Stack sx={{ alignItems: 'center', flexDirection: 'row', gap: 4 }}>\n <Icon name=\"info\" size={14} sx={{ color: 'text.secondary' }} />\n <Text color=\"text.secondary\" variant=\"caption\">\n {copy.credit_limit_not_shared}\n </Text>\n </Stack>\n )}\n </Stack>\n </Stack>\n <Stack sx={{ gap: 12, mt: 24, pl: 52 }}>\n <Stack\n sx={{\n alignItems: 'center',\n borderBottom: '1px solid',\n borderColor: 'divider',\n flexDirection: 'row',\n justifyContent: 'space-between',\n pb: 10,\n }}\n >\n <Stack sx={{ alignItems: 'center', flexDirection: 'row', gap: 8 }}>\n <Box sx={{ bgcolor: color, borderRadius: '1px', flexShrink: 0, height: 8, width: 8 }} />\n <Text variant=\"caption\">{copy.credit_utilized}</Text>\n </Stack>\n <Stack sx={{ flexDirection: 'row', fontVariantNumeric: 'tabular-nums', gap: 4 }}>\n <Text bold={true} variant=\"caption\">\n {formatMoney(card.amount)}\n </Text>\n {hasLimit && (\n <>\n <Text variant=\"caption\">/</Text>\n <Text variant=\"caption\">{formatMoney(limit)}</Text>\n </>\n )}\n </Stack>\n </Stack>\n {hasLimit && (\n <Stack sx={{ flexDirection: 'row', justifyContent: 'space-between' }}>\n <Text variant=\"caption\">{copy.credit_utilization_ratio}</Text>\n <Text bold={true} variant=\"caption\">\n {percentage}%\n </Text>\n </Stack>\n )}\n </Stack>\n </Box>\n )\n}\n\n/** `data_series` makes no uniqueness promise for `guid`, so a repeat gets a numbered key. */\nconst keyedCards = (cards: CreditUtilizationCard[]) => {\n const seen = new Map<string, number>()\n\n return cards.map((card) => {\n const count = (seen.get(card.guid) ?? 0) + 1\n\n seen.set(card.guid, count)\n\n return { card, key: count === 1 ? card.guid : `${card.guid}-${count}` }\n })\n}\n\n/** Presentational body of the Credit Utilization drawer, minus the drawer header. */\nconst CreditUtilizationContent = ({\n cards,\n copy,\n descriptionHtml,\n summary,\n title,\n}: CreditUtilizationContentProps) => (\n <Stack sx={{ bgcolor: 'background.default', gap: 8, pb: 24 }}>\n {(title || summary || descriptionHtml) && (\n <Section>\n {title && <SectionHeading>{title}</SectionHeading>}\n {summary && <Summary copy={copy} summary={summary} />}\n {descriptionHtml && (\n <Text\n component=\"p\"\n dangerouslySetInnerHTML={{ __html: sanitizeHtml(descriptionHtml) }}\n sx={{ mt: 16 }}\n variant=\"body2\"\n />\n )}\n </Section>\n )}\n <Legend copy={copy} />\n {cards.length > 0 && (\n <Section>\n <SectionHeading>{copy.per_card_header}</SectionHeading>\n <Stack component=\"ul\" role=\"list\" sx={{ gap: 16, listStyle: 'none', m: 0, p: 0 }}>\n {keyedCards(cards).map(({ card, key }) => (\n <CardUtilization card={card} copy={copy} key={key} />\n ))}\n </Stack>\n </Section>\n )}\n </Stack>\n)\n\nexport default CreditUtilizationContent\n"],"mappings":";;;;;;;;;;;AAiCA,IAAM,IAAA,CAAe,MAAmB,EAAe,GAAQ,QAAQ,GAEjE,IAAA,CAAW,EAAE,UAAA,EAAA,MACjB,gBAAA,EAAC,GAAD;AAAA,E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import { DataSeries } from '../../../core';
|
|
3
|
+
import { InsightsInstanceSlotData } from '../../../core/types/InsightsInstanceSlotData';
|
|
4
|
+
export type UtilizationBand = 'excellent' | 'good' | 'fair' | 'needs_work';
|
|
5
|
+
export interface UtilizationBandSpec {
|
|
6
|
+
band: UtilizationBand;
|
|
7
|
+
range: string;
|
|
8
|
+
/** Highest whole percentage in the band. */
|
|
9
|
+
maxPercent: number;
|
|
10
|
+
color: (theme: Theme) => string;
|
|
11
|
+
}
|
|
12
|
+
/** Ordered from best to worst, as the legend shows them. */
|
|
13
|
+
export declare const UTILIZATION_BANDS: UtilizationBandSpec[];
|
|
14
|
+
/** Whole percent within 0-100, the only form the drawer shows, bands or announces. */
|
|
15
|
+
export declare const normalizePercent: (percent: number) => number;
|
|
16
|
+
export declare const getUtilizationBand: (percent: number) => UtilizationBandSpec;
|
|
17
|
+
export interface CreditUtilizationSummary {
|
|
18
|
+
balance: number;
|
|
19
|
+
limit: number;
|
|
20
|
+
percentage: number;
|
|
21
|
+
}
|
|
22
|
+
export interface CreditCardRow {
|
|
23
|
+
guid: string;
|
|
24
|
+
label: string;
|
|
25
|
+
amount: number;
|
|
26
|
+
/** `null` when the institution did not share the card's limit. */
|
|
27
|
+
limit: number | null;
|
|
28
|
+
percentage: number | null;
|
|
29
|
+
}
|
|
30
|
+
export declare const readSummary: (data?: InsightsInstanceSlotData) => CreditUtilizationSummary | undefined;
|
|
31
|
+
/** One object per `data` row, keyed by `names` (pulse's `buildDataSeries`). */
|
|
32
|
+
export declare const readCardRows: (series?: DataSeries | unknown[]) => CreditCardRow[];
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
var l = {
|
|
2
|
+
band: "needs_work",
|
|
3
|
+
range: ">30%",
|
|
4
|
+
maxPercent: 1 / 0,
|
|
5
|
+
color: (t) => t.palette.error.light
|
|
6
|
+
}, g = [
|
|
7
|
+
{
|
|
8
|
+
band: "excellent",
|
|
9
|
+
range: "0-10%",
|
|
10
|
+
maxPercent: 10,
|
|
11
|
+
color: (t) => t.palette.success.main
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
band: "good",
|
|
15
|
+
range: "11-20%",
|
|
16
|
+
maxPercent: 20,
|
|
17
|
+
color: (t) => t.palette.success.light
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
band: "fair",
|
|
21
|
+
range: "21-30%",
|
|
22
|
+
maxPercent: 30,
|
|
23
|
+
color: (t) => t.palette.warning.light
|
|
24
|
+
},
|
|
25
|
+
l
|
|
26
|
+
], c = (t) => Math.min(100, Math.max(0, Math.round(t))), s = (t) => g.find(({ maxPercent: a }) => c(t) <= a) ?? l, r = (t) => typeof t == "number" && Number.isFinite(t) ? t : void 0, p = (t) => {
|
|
27
|
+
const a = r(t?.accounts_balance_sum), n = r(t?.accounts_credit_limit_sum), e = r(t?.credit_utilization_percentage);
|
|
28
|
+
if (!(a === void 0 || n === void 0 || e === void 0))
|
|
29
|
+
return {
|
|
30
|
+
balance: a,
|
|
31
|
+
limit: n,
|
|
32
|
+
percentage: c(e)
|
|
33
|
+
};
|
|
34
|
+
}, b = (t) => {
|
|
35
|
+
if (!t || Array.isArray(t) || !t.names || !Array.isArray(t.data)) return [];
|
|
36
|
+
const { names: a } = t;
|
|
37
|
+
return t.data.flatMap((n) => {
|
|
38
|
+
const e = Object.fromEntries(a.map((m, d) => [m, n[d]]));
|
|
39
|
+
if (typeof e.guid != "string" || typeof e.label != "string") return [];
|
|
40
|
+
const o = r(e.amount) ?? 0, i = r(e.total_amount);
|
|
41
|
+
if (i === void 0 || i <= 0) return [{
|
|
42
|
+
amount: o,
|
|
43
|
+
guid: e.guid,
|
|
44
|
+
label: e.label,
|
|
45
|
+
limit: null,
|
|
46
|
+
percentage: null
|
|
47
|
+
}];
|
|
48
|
+
const u = r(e.percentage) ?? o / i * 100;
|
|
49
|
+
return [{
|
|
50
|
+
amount: o,
|
|
51
|
+
guid: e.guid,
|
|
52
|
+
label: e.label,
|
|
53
|
+
limit: i,
|
|
54
|
+
percentage: c(u)
|
|
55
|
+
}];
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
export {
|
|
59
|
+
g as UTILIZATION_BANDS,
|
|
60
|
+
s as getUtilizationBand,
|
|
61
|
+
c as normalizePercent,
|
|
62
|
+
b as readCardRows,
|
|
63
|
+
p as readSummary
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
//# sourceMappingURL=layout.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/CreditUtilizationBlock/layout.ts"],"sourcesContent":["import type { Theme } from '@mui/material/styles'\n\nimport type { DataSeries } from '../../../core'\nimport type { InsightsInstanceSlotData } from '../../../core/types/InsightsInstanceSlotData'\n\nexport type UtilizationBand = 'excellent' | 'good' | 'fair' | 'needs_work'\n\nexport interface UtilizationBandSpec {\n band: UtilizationBand\n range: string\n /** Highest whole percentage in the band. */\n maxPercent: number\n color: (theme: Theme) => string\n}\n\nconst NEEDS_WORK: UtilizationBandSpec = {\n band: 'needs_work',\n range: '>30%',\n maxPercent: Infinity,\n color: (theme) => theme.palette.error.light,\n}\n\n/** Ordered from best to worst, as the legend shows them. */\nexport const UTILIZATION_BANDS: UtilizationBandSpec[] = [\n {\n band: 'excellent',\n range: '0-10%',\n maxPercent: 10,\n color: (theme) => theme.palette.success.main,\n },\n { band: 'good', range: '11-20%', maxPercent: 20, color: (theme) => theme.palette.success.light },\n { band: 'fair', range: '21-30%', maxPercent: 30, color: (theme) => theme.palette.warning.light },\n NEEDS_WORK,\n]\n\n/** Whole percent within 0-100, the only form the drawer shows, bands or announces. */\nexport const normalizePercent = (percent: number): number =>\n Math.min(100, Math.max(0, Math.round(percent)))\n\nexport const getUtilizationBand = (percent: number): UtilizationBandSpec =>\n UTILIZATION_BANDS.find(({ maxPercent }) => normalizePercent(percent) <= maxPercent) ?? NEEDS_WORK\n\nexport interface CreditUtilizationSummary {\n balance: number\n limit: number\n percentage: number\n}\n\nexport interface CreditCardRow {\n guid: string\n label: string\n amount: number\n /** `null` when the institution did not share the card's limit. */\n limit: number | null\n percentage: number | null\n}\n\nconst toFiniteNumber = (value: unknown): number | undefined =>\n typeof value === 'number' && Number.isFinite(value) ? value : undefined\n\nexport const readSummary = (\n data?: InsightsInstanceSlotData,\n): CreditUtilizationSummary | undefined => {\n const balance = toFiniteNumber(data?.accounts_balance_sum)\n const limit = toFiniteNumber(data?.accounts_credit_limit_sum)\n const percentage = toFiniteNumber(data?.credit_utilization_percentage)\n\n if (balance === undefined || limit === undefined || percentage === undefined) return undefined\n\n return { balance, limit, percentage: normalizePercent(percentage) }\n}\n\n/** One object per `data` row, keyed by `names` (pulse's `buildDataSeries`). */\nexport const readCardRows = (series?: DataSeries | unknown[]): CreditCardRow[] => {\n if (!series || Array.isArray(series) || !series.names || !Array.isArray(series.data)) return []\n\n const { names } = series\n\n return series.data.flatMap((values: unknown[]): CreditCardRow[] => {\n const row = Object.fromEntries(names.map((name, index) => [name, values[index]]))\n\n if (typeof row.guid !== 'string' || typeof row.label !== 'string') return []\n\n const amount = toFiniteNumber(row.amount) ?? 0\n const limit = toFiniteNumber(row.total_amount)\n\n if (limit === undefined || limit <= 0) {\n return [{ amount, guid: row.guid, label: row.label, limit: null, percentage: null }]\n }\n\n const percentage = toFiniteNumber(row.percentage) ?? (amount / limit) * 100\n\n return [\n { amount, guid: row.guid, label: row.label, limit, percentage: normalizePercent(percentage) },\n ]\n })\n}\n"],"mappings":"AAeA,IAAM,IAAkC;AAAA,EACtC,MAAM;AAAA,EACN,OAAO;AAAA,EACP,YAAY;AAAA,EACZ,OAAA,CAAQ,MAAU,EAAM,QAAQ,MAAM;AACxC,GAGa,IAA2C;AAAA,EACtD;AAAA,IACE,MAAM;AAAA,IACN,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,OAAA,CAAQ,MAAU,EAAM,QAAQ,QAAQ;AAAA,EAC1C;AAAA,EACA;AAAA,IAAE,MAA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MAAM,KAAK,GACvC,IAAQ,EAAe,EAAI,YAAY;AAE7C,QAAI,MAAU,UAAa,KAAS,EAClC,QAAO,CAAC;AAAA,MAAE,QAAA;AAAA,MAAQ,MAAM,EAAI;AAAA,MAAM,OAAO,EAAI;AAAA,MAAO,OAAO;AAAA,MAAM,YAAY;AAAA,IAAK,CAAC;AAGrF,UAAM,IAAa,EAAe,EAAI,UAAU,KAAM,IAAS,IAAS;AAExE,WAAO,CACL;AAAA,MAAE,QAAA;AAAA,MAAQ,MAAM,EAAI;AAAA,MAAM,OAAO,EAAI;AAAA,MAAO,OAAA;AAAA,MAAO,YAAY,EAAiB,CAAU;AAAA,IAAE,CAC9F;AAAA,EACF,CAAC;AACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useCreditUtilizationPrepare: () => void;
|
package/dist/insights-v2/actionBlocks/CreditUtilizationBlock/useCreditUtilizationPrepare.es.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useAccountStore as e } from "../../../common/context/hooks.es.js";
|
|
2
|
+
import r from "react";
|
|
3
|
+
var i = () => {
|
|
4
|
+
const { accountsLoaded: o, loadAccounts: t } = e();
|
|
5
|
+
r.useEffect(() => {
|
|
6
|
+
o || t();
|
|
7
|
+
}, [o, t]);
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
i as useCreditUtilizationPrepare
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=useCreditUtilizationPrepare.es.js.map
|
package/dist/insights-v2/actionBlocks/CreditUtilizationBlock/useCreditUtilizationPrepare.es.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCreditUtilizationPrepare.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/CreditUtilizationBlock/useCreditUtilizationPrepare.ts"],"sourcesContent":["import React from 'react'\n\nimport { useAccountStore } from '../../../common'\n\nexport const useCreditUtilizationPrepare = () => {\n const { accountsLoaded, loadAccounts } = useAccountStore()\n\n React.useEffect(() => {\n if (!accountsLoaded) void loadAccounts()\n }, [accountsLoaded, loadAccounts])\n}\n"],"mappings":";;AAIA,IAAa,IAAA,MAAoC;AAC/C,QAAM,EAAE,gBAAA,GAAgB,cAAA,EAAA,IAAiB,EAAgB;AAEzD,EAAA,EAAM,UAAA,MAAgB;AACpB,IAAK,KAAgB,EAAkB;AAAA,EACzC,GAAG,CAAC,GAAgB,CAAY,CAAC;AACnC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { buildDynamicCopy as x } from "../../../core/utils/Localization.es.js";
|
|
2
|
+
import { useGlobalCopyStore as v } from "../../../common/context/hooks.es.js";
|
|
3
|
+
import { formatCurrency as c } from "../../../core/utils/NumberFormatting.es.js";
|
|
4
|
+
import { variants as _ } from "../../blocks/ChartBlocks/StepChartBlock/index.es.js";
|
|
5
|
+
import { stepForBalance as y } from "./layout.es.js";
|
|
6
|
+
import { SavingsCalculator as h } from "./SavingsCalculator.es.js";
|
|
7
|
+
import { observer as C } from "mobx-react-lite";
|
|
8
|
+
import e from "@mui/material/Stack";
|
|
9
|
+
import { Text as p } from "@mxenabled/mxui";
|
|
10
|
+
import { jsx as o, jsxs as n } from "react/jsx-runtime";
|
|
11
|
+
var m = ({ label: i, value: a }) => /* @__PURE__ */ n(e, {
|
|
12
|
+
"aria-label": i,
|
|
13
|
+
role: "group",
|
|
14
|
+
sx: {
|
|
15
|
+
border: "1px solid",
|
|
16
|
+
borderColor: "divider",
|
|
17
|
+
borderRadius: "8px",
|
|
18
|
+
flex: 1,
|
|
19
|
+
gap: 4,
|
|
20
|
+
p: 12
|
|
21
|
+
},
|
|
22
|
+
children: [/* @__PURE__ */ o(p, {
|
|
23
|
+
color: "text.secondary",
|
|
24
|
+
variant: "caption",
|
|
25
|
+
children: i
|
|
26
|
+
}), /* @__PURE__ */ o(p, {
|
|
27
|
+
bold: !0,
|
|
28
|
+
component: "p",
|
|
29
|
+
variant: "h3",
|
|
30
|
+
children: a
|
|
31
|
+
})]
|
|
32
|
+
}), A = C(function({ beat: a }) {
|
|
33
|
+
const { common: d, insights_feed: g } = v(), r = g?.emergency_savings;
|
|
34
|
+
if (!r) return /* @__PURE__ */ o(e, {
|
|
35
|
+
sx: { p: 24 },
|
|
36
|
+
children: /* @__PURE__ */ o(p, { children: d?.error_message })
|
|
37
|
+
});
|
|
38
|
+
const t = a.insights_payload?.drilldown_data?.savings_account_balance, l = typeof t == "number" && Number.isFinite(t) ? t : 0, { goal: s, index: u, labelKey: b } = y(l), { WithText: f } = _;
|
|
39
|
+
return /* @__PURE__ */ n(e, {
|
|
40
|
+
sx: {
|
|
41
|
+
bgcolor: "background.default",
|
|
42
|
+
gap: 24,
|
|
43
|
+
p: 24
|
|
44
|
+
},
|
|
45
|
+
children: [/* @__PURE__ */ n(e, {
|
|
46
|
+
sx: {
|
|
47
|
+
bgcolor: "background.paper",
|
|
48
|
+
borderRadius: "8px",
|
|
49
|
+
gap: 16,
|
|
50
|
+
p: 16
|
|
51
|
+
},
|
|
52
|
+
children: [/* @__PURE__ */ o(f, { slotData: {
|
|
53
|
+
completed_steps: u,
|
|
54
|
+
label_1: r[b].toUpperCase(),
|
|
55
|
+
label_2: x(r.amount_in_savings, c(s, "0"))
|
|
56
|
+
} }), /* @__PURE__ */ n(e, {
|
|
57
|
+
sx: {
|
|
58
|
+
flexDirection: "row",
|
|
59
|
+
gap: 12
|
|
60
|
+
},
|
|
61
|
+
children: [/* @__PURE__ */ o(m, {
|
|
62
|
+
label: r.total_savings_balance,
|
|
63
|
+
value: c(l, "0,0.00")
|
|
64
|
+
}), /* @__PURE__ */ o(m, {
|
|
65
|
+
label: r.savings_goal,
|
|
66
|
+
value: c(s, "0,0")
|
|
67
|
+
})]
|
|
68
|
+
})]
|
|
69
|
+
}), /* @__PURE__ */ o(h, {
|
|
70
|
+
balance: l,
|
|
71
|
+
copy: r,
|
|
72
|
+
goal: s
|
|
73
|
+
}, a.guid)]
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
export {
|
|
77
|
+
A as EmergencySavingsBlock
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
//# sourceMappingURL=EmergencySavingsBlock.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmergencySavingsBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/EmergencySavingsBlock/EmergencySavingsBlock.tsx"],"sourcesContent":["import Stack from '@mui/material/Stack'\n\nimport { Text } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport { useGlobalCopyStore } from '../../../common'\nimport { buildDynamicCopy } from '../../../core'\nimport { formatCurrency } from '../../../core/utils/NumberFormatting'\nimport { variants as stepChartVariants } from '../../blocks/ChartBlocks/StepChartBlock'\nimport type { ActionBlockProps } from '../../mappings/blocks'\n\nimport { SavingsCalculator } from './SavingsCalculator'\nimport { stepForBalance } from './layout'\n\nconst AmountBox = ({ label, value }: { label: string; value: string }) => (\n <Stack\n aria-label={label}\n role=\"group\"\n sx={{\n border: '1px solid',\n borderColor: 'divider',\n borderRadius: '8px',\n flex: 1,\n gap: 4,\n p: 12,\n }}\n >\n <Text color=\"text.secondary\" variant=\"caption\">\n {label}\n </Text>\n <Text bold={true} component=\"p\" variant=\"h3\">\n {value}\n </Text>\n </Stack>\n)\n\nexport const EmergencySavingsBlock = observer(function EmergencySavingsBlock({\n beat,\n}: ActionBlockProps) {\n const { common: commonCopy, insights_feed: insightsFeedCopy } = useGlobalCopyStore()\n const copy = insightsFeedCopy?.emergency_savings\n\n if (!copy) {\n return (\n <Stack sx={{ p: 24 }}>\n <Text>{commonCopy?.error_message}</Text>\n </Stack>\n )\n }\n\n const raw = beat.insights_payload?.drilldown_data?.savings_account_balance\n const balance = typeof raw === 'number' && Number.isFinite(raw) ? raw : 0\n const { goal, index, labelKey } = stepForBalance(balance)\n const { WithText: Stepper } = stepChartVariants\n\n return (\n <Stack sx={{ bgcolor: 'background.default', gap: 24, p: 24 }}>\n <Stack sx={{ bgcolor: 'background.paper', borderRadius: '8px', gap: 16, p: 16 }}>\n <Stepper\n slotData={{\n completed_steps: index,\n label_1: copy[labelKey].toUpperCase(),\n label_2: buildDynamicCopy(copy.amount_in_savings, formatCurrency(goal, '0')) as string,\n }}\n />\n <Stack sx={{ flexDirection: 'row', gap: 12 }}>\n <AmountBox label={copy.total_savings_balance} value={formatCurrency(balance, '0,0.00')} />\n <AmountBox label={copy.savings_goal} value={formatCurrency(goal, '0,0')} />\n </Stack>\n </Stack>\n <SavingsCalculator balance={balance} copy={copy} goal={goal} key={beat.guid} />\n </Stack>\n )\n})\n"],"mappings":";;;;;;;;;;AAcA,IAAM,IAAA,CAAa,EAAE,OAAA,GAAO,OAAA,EAAA,MAC1B,gBAAA,EAAC,GAAD;AAAA,EACE,cAAY;AAAA,EACZ,MAAK;AAAA,EACL,IAAI;AAAA,IACF,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,cAAc;AAAA,IACd,MAAM;AAAA,IACN,KAAK;AAAA,IACL,GAAG;AAAA,EACL;AAAA,EAVF,UAAA,CAYE,gBAAA,EAAC,GAAD;AAAA,IAAM,OAAM;AAAA,IAAiB,SAAQ;AAAA,IAClC,UAAA;AAAA,EACG,CAAA,GACN,gBAAA,EAAC,GAAD;AAAA,IAAM,MAAM;AAAA,IAAM,WAAU;AAAA,IAAI,SAAQ;AAAA,IACrC,UAAA;AAAA,EACG,CAAA,CACD;IAGI,IAAwB,EAAS,SAA+B,EAC3E,MAAA,EAAA,GACmB;AACnB,QAAM,EAAE,QAAQ,GAAY,eAAe,EAAA,IAAqB,EAAmB,GAC7E,IAAO,GAAkB;AAE/B,MAAI,CAAC,EACH,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,QAAM,IAAM,EAAK,kBAAkB,gBA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|
3
|
+
balance: number;
|
|
4
|
+
goal: number;
|
|
5
|
+
copy: EmergencySavingsCopy;
|
|
6
|
+
}
|
|
7
|
+
export declare const SavingsCalculator: ({ balance, copy, goal }: SavingsCalculatorProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|