@mx-cartographer/experiences 9.7.167 → 9.7.169

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 CHANGED
@@ -1,3 +1,11 @@
1
+ ## [9.7.169] - 11-17-2026
2
+
3
+ - **CHANGED** - Monthly Credit Card Interest Summary drilldown matches Figma: tabbed Standard / +0 / +0 payoff scenarios (WEC-2332)
4
+
5
+ ## [9.7.168] - 11-16-2026
6
+
7
+ - **ADDED** - `clientConfig.transactions.hide_export_csv` client setting to hide Export CSV in the spending, budgets, and trends widgets (WELL-131)
8
+
1
9
  ## [9.7.167] - 11-16-2026
2
10
 
3
11
  - **FIXED** - Shared dialog titles are read by screen readers and wrap instead of being cut off, and dialogs use the paper background (WELL-202)
@@ -1,72 +1,72 @@
1
- import { useAppConfig as k, useBudgetsStore as D, useGlobalCopyStore as j, useTransactionStore as G } from "../../../common/context/hooks.es.js";
2
- import { useScreenSize as I } from "../../../common/hooks/useScreenSize.es.js";
3
- import L from "../../../common/components/drawer/Drawer.es.js";
4
- import { exportTransactionsToCSV as z } from "../../../core/utils/TransactionUtils.es.js";
5
- import A from "../../../transactions/components/shared/TransactionList.es.js";
6
- import E from "../../../transactions/components/shared/TransactionDetails.es.js";
7
- import { Header as W } from "./Header.es.js";
8
- import { SubBudgetList as H } from "./SubBudgetList.es.js";
1
+ import { useAppConfig as D, useBudgetsStore as j, useGlobalCopyStore as G, useTransactionStore as I } from "../../../common/context/hooks.es.js";
2
+ import { useScreenSize as L } from "../../../common/hooks/useScreenSize.es.js";
3
+ import z from "../../../common/components/drawer/Drawer.es.js";
4
+ import { exportTransactionsToCSV as A } from "../../../core/utils/TransactionUtils.es.js";
5
+ import E from "../../../transactions/components/shared/TransactionList.es.js";
6
+ import W from "../../../transactions/components/shared/TransactionDetails.es.js";
7
+ import { Header as H } from "./Header.es.js";
8
+ import { SubBudgetList as M } from "./SubBudgetList.es.js";
9
9
  import c from "react";
10
- import { observer as M } from "mobx-react-lite";
10
+ import { observer as O } from "mobx-react-lite";
11
11
  import e from "@mui/material/Stack";
12
- import { Icon as O } from "@mxenabled/mxui";
13
- import R from "@mui/material/Button";
12
+ import { Icon as R } from "@mxenabled/mxui";
13
+ import V from "@mui/material/Button";
14
14
  import { jsx as t, jsxs as r } from "react/jsx-runtime";
15
15
  import p from "@mui/material/Tab";
16
- import V from "@mui/material/Tabs";
17
- var st = M(({ budget: l }) => {
18
- const { is_mobile_webview: u } = k(), { setAlert: f } = D(), { budgets: o, common: b, transactions: h } = j(), { isDesktop: T, isSmallTablet: _, isTablet: C } = I(), { sortedTransactions: s, sortedTransactionsWithSplits: g, tags: S } = G(), [a, v] = c.useState(0), [m, n] = c.useState(""), i = c.useMemo(() => s.find((d) => d.guid === m), [m, s]), x = (d, B) => {
19
- v(B);
20
- }, w = () => {
21
- z(g, S), f({
16
+ import $ from "@mui/material/Tabs";
17
+ var nt = O(({ budget: l }) => {
18
+ const { clientConfig: u, is_mobile_webview: f } = D(), { setAlert: h } = j(), { budgets: o, common: b, transactions: _ } = G(), { isDesktop: T, isSmallTablet: C, isTablet: g } = L(), { sortedTransactions: s, sortedTransactionsWithSplits: S, tags: v } = I(), [n, x] = c.useState(0), [m, a] = c.useState(""), i = c.useMemo(() => s.find((d) => d.guid === m), [m, s]), w = (d, k) => {
19
+ x(k);
20
+ }, y = () => {
21
+ A(S, v), h({
22
22
  msg: o.alert_csv_downloaded,
23
23
  severity: "success"
24
24
  });
25
- }, y = s.length > 0 && !u && (T || C && !_);
25
+ }, B = s.length > 0 && !f && !u?.transactions?.hide_export_csv && (T || g && !C);
26
26
  return /* @__PURE__ */ r(e, {
27
27
  gap: 24,
28
- children: [/* @__PURE__ */ t(W, { budget: l }), /* @__PURE__ */ r(e, { children: [
29
- /* @__PURE__ */ r(V, {
30
- onChange: x,
28
+ children: [/* @__PURE__ */ t(H, { budget: l }), /* @__PURE__ */ r(e, { children: [
29
+ /* @__PURE__ */ r($, {
30
+ onChange: w,
31
31
  sx: { width: "100%" },
32
32
  textColor: "primary",
33
- value: a,
33
+ value: n,
34
34
  variant: "fullWidth",
35
35
  children: [/* @__PURE__ */ t(p, { label: o.details_transactions_tab }), /* @__PURE__ */ t(p, { label: o.details_subbudgets_tab })]
36
36
  }),
37
- a === 0 && /* @__PURE__ */ r(e, { children: [y && /* @__PURE__ */ t(e, {
37
+ n === 0 && /* @__PURE__ */ r(e, { children: [B && /* @__PURE__ */ t(e, {
38
38
  direction: "row",
39
39
  justifyContent: "right",
40
40
  mb: -24,
41
41
  mr: 8,
42
42
  mt: 8,
43
43
  zIndex: 1,
44
- children: /* @__PURE__ */ t(R, {
45
- onClick: w,
46
- startIcon: /* @__PURE__ */ t(O, { name: "ios_share" }),
44
+ children: /* @__PURE__ */ t(V, {
45
+ onClick: y,
46
+ startIcon: /* @__PURE__ */ t(R, { name: "ios_share" }),
47
47
  variant: "text",
48
- children: h.export_csv_btn
48
+ children: _.export_csv_btn
49
49
  })
50
- }), /* @__PURE__ */ t(A, {
50
+ }), /* @__PURE__ */ t(E, {
51
51
  height: "100%",
52
- onClick: n
52
+ onClick: a
53
53
  })] }),
54
- a === 1 && /* @__PURE__ */ t(H, {
54
+ n === 1 && /* @__PURE__ */ t(M, {
55
55
  budget: l,
56
- onTransactionClick: n
56
+ onTransactionClick: a
57
57
  }),
58
- /* @__PURE__ */ t(L, {
58
+ /* @__PURE__ */ t(z, {
59
59
  ariaLabelClose: b.close_aria,
60
60
  isOpen: !!i,
61
- onClose: () => n(""),
61
+ onClose: () => a(""),
62
62
  title: o.details_transaction_drawer,
63
- children: i && /* @__PURE__ */ t(E, { transaction: i })
63
+ children: i && /* @__PURE__ */ t(W, { transaction: i })
64
64
  })
65
65
  ] })]
66
66
  });
67
67
  });
68
68
  export {
69
- st as BudgetDetails
69
+ nt as BudgetDetails
70
70
  };
71
71
 
72
72
  //# sourceMappingURL=BudgetDetails.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BudgetDetails.es.js","names":[],"sources":["../../../../src/budgets/components/budgetdetails/BudgetDetails.tsx"],"sourcesContent":["import React from 'react'\nimport { observer } from 'mobx-react-lite'\n\nimport Button from '@mui/material/Button'\nimport Stack from '@mui/material/Stack'\nimport Tab from '@mui/material/Tab'\nimport Tabs from '@mui/material/Tabs'\n\nimport { Icon } from '@mxenabled/mxui'\n\nimport {\n Drawer,\n useAppConfig,\n useBudgetsStore,\n useGlobalCopyStore,\n useScreenSize,\n useTransactionStore,\n} from '../../../common'\nimport { type DetailedBudget } from '../../../core'\nimport { exportTransactionsToCSV } from '../../../core/utils/TransactionUtils'\n\nimport { TransactionDetails, TransactionList } from '../../../transactions'\n\nimport { Header } from './Header'\nimport { SubBudgetList } from './SubBudgetList'\n\ninterface BudgetDetailsProps {\n budget: DetailedBudget\n}\n\nexport const BudgetDetails: React.FC<BudgetDetailsProps> = observer(({ budget }) => {\n const { is_mobile_webview } = useAppConfig()\n const { setAlert } = useBudgetsStore()\n const { budgets: copy, common: commonCopy, transactions: transactionCopy } = useGlobalCopyStore()\n const { isDesktop, isSmallTablet, isTablet } = useScreenSize()\n const {\n sortedTransactions: transactions,\n sortedTransactionsWithSplits,\n tags,\n } = useTransactionStore()\n\n const [selectedTab, setSelectedTab] = React.useState(0)\n const [transactionGuid, setTransactionGuid] = React.useState('')\n\n const transaction = React.useMemo(\n () => transactions.find((t) => t.guid === transactionGuid),\n [transactionGuid, transactions],\n )\n\n const handleTabChange = (_event: React.SyntheticEvent, newValue: number) => {\n setSelectedTab(newValue)\n }\n\n const handleExportToCsv = () => {\n exportTransactionsToCSV(sortedTransactionsWithSplits, tags)\n setAlert({ msg: copy.alert_csv_downloaded, severity: 'success' })\n }\n\n const shouldShowExportButton =\n transactions.length > 0 && !is_mobile_webview && (isDesktop || (isTablet && !isSmallTablet))\n\n return (\n <Stack gap={24}>\n <Header budget={budget} />\n\n <Stack>\n <Tabs\n onChange={handleTabChange}\n sx={{ width: '100%' }}\n textColor=\"primary\"\n value={selectedTab}\n variant=\"fullWidth\"\n >\n <Tab label={copy.details_transactions_tab} />\n <Tab label={copy.details_subbudgets_tab} />\n </Tabs>\n {selectedTab === 0 && (\n <Stack>\n {shouldShowExportButton && (\n <Stack direction=\"row\" justifyContent=\"right\" mb={-24} mr={8} mt={8} zIndex={1}>\n <Button\n onClick={handleExportToCsv}\n startIcon={<Icon name=\"ios_share\" />}\n variant=\"text\"\n >\n {transactionCopy.export_csv_btn}\n </Button>\n </Stack>\n )}\n <TransactionList height=\"100%\" onClick={setTransactionGuid} />\n </Stack>\n )}\n {selectedTab === 1 && (\n <SubBudgetList budget={budget} onTransactionClick={setTransactionGuid} />\n )}\n\n <Drawer\n ariaLabelClose={commonCopy.close_aria}\n isOpen={Boolean(transaction)}\n onClose={() => setTransactionGuid('')}\n title={copy.details_transaction_drawer}\n >\n {transaction && <TransactionDetails transaction={transaction} />}\n </Drawer>\n </Stack>\n </Stack>\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;AA8BA,IAAa,KAA8C,EAAA,CAAU,EAAE,QAAA,EAAA,MAAa;AAClF,QAAM,EAAE,mBAAA,EAAA,IAAsB,EAAa,GACrC,EAAE,UAAA,EAAA,IAAa,EAAgB,GAC/B,EAAE,SAAS,GAAM,QAAQ,GAAY,cAAc,EAAA,IAAoB,EAAmB,GAC1F,EAAE,WAAA,GAAW,eAAA,GAAe,UAAA,EAAA,IAAa,EAAc,GACvD,EACJ,oBAAoB,GACpB,8BAAA,GACA,MAAA,EAAA,IACE,EAAoB,GAElB,CAAC,GAAa,CAAA,IAAkB,EAAM,SAAS,CAAC,GAChD,CAAC,GAAiB,CAAA,IAAsB,EAAM,SAAS,EAAE,GAEzD,IAAc,EAAM,QAAA,MAClB,EAAa,KAAA,CAAM,MAAM,EAAE,SAAS,CAAe,GACzD,CAAC,GAAiB,CAAY,CAChC,GAEM,IAAA,CAAmB,GAA8B,MAAqB;AAC1E,IAAA,EAAe,CAAQ;AAAA,EACzB,GAEM,IAAA,MAA0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AAD;AAAA,QACE,gBAAgB,EAAW;AAAA,QAC3B,QAAQ,EAAQ;AAAA,QAChB,SAAA,MAAe,EAAmB,EAAE;AAAA,QACpC,OAAO,EAAK;AAAA,QAEX,UAAA,KAAe,gBAAA,EAAC,GAAD,EAAiC,aAAA,EAAc,CAAA;AAAA,MACzD,CAAA;AAAA,IACH,EAAA,CAAA,CACF;AAAA;AAEX,CAAC"}
1
+ {"version":3,"file":"BudgetDetails.es.js","names":[],"sources":["../../../../src/budgets/components/budgetdetails/BudgetDetails.tsx"],"sourcesContent":["import React from 'react'\nimport { observer } from 'mobx-react-lite'\n\nimport Button from '@mui/material/Button'\nimport Stack from '@mui/material/Stack'\nimport Tab from '@mui/material/Tab'\nimport Tabs from '@mui/material/Tabs'\n\nimport { Icon } from '@mxenabled/mxui'\n\nimport {\n Drawer,\n useAppConfig,\n useBudgetsStore,\n useGlobalCopyStore,\n useScreenSize,\n useTransactionStore,\n} from '../../../common'\nimport { type DetailedBudget } from '../../../core'\nimport { exportTransactionsToCSV } from '../../../core/utils/TransactionUtils'\n\nimport { TransactionDetails, TransactionList } from '../../../transactions'\n\nimport { Header } from './Header'\nimport { SubBudgetList } from './SubBudgetList'\n\ninterface BudgetDetailsProps {\n budget: DetailedBudget\n}\n\nexport const BudgetDetails: React.FC<BudgetDetailsProps> = observer(({ budget }) => {\n const { clientConfig, is_mobile_webview } = useAppConfig()\n const { setAlert } = useBudgetsStore()\n const { budgets: copy, common: commonCopy, transactions: transactionCopy } = useGlobalCopyStore()\n const { isDesktop, isSmallTablet, isTablet } = useScreenSize()\n const {\n sortedTransactions: transactions,\n sortedTransactionsWithSplits,\n tags,\n } = useTransactionStore()\n\n const [selectedTab, setSelectedTab] = React.useState(0)\n const [transactionGuid, setTransactionGuid] = React.useState('')\n\n const transaction = React.useMemo(\n () => transactions.find((t) => t.guid === transactionGuid),\n [transactionGuid, transactions],\n )\n\n const handleTabChange = (_event: React.SyntheticEvent, newValue: number) => {\n setSelectedTab(newValue)\n }\n\n const handleExportToCsv = () => {\n exportTransactionsToCSV(sortedTransactionsWithSplits, tags)\n setAlert({ msg: copy.alert_csv_downloaded, severity: 'success' })\n }\n\n const shouldShowExportButton =\n transactions.length > 0 &&\n !is_mobile_webview &&\n !clientConfig?.transactions?.hide_export_csv &&\n (isDesktop || (isTablet && !isSmallTablet))\n\n return (\n <Stack gap={24}>\n <Header budget={budget} />\n\n <Stack>\n <Tabs\n onChange={handleTabChange}\n sx={{ width: '100%' }}\n textColor=\"primary\"\n value={selectedTab}\n variant=\"fullWidth\"\n >\n <Tab label={copy.details_transactions_tab} />\n <Tab label={copy.details_subbudgets_tab} />\n </Tabs>\n {selectedTab === 0 && (\n <Stack>\n {shouldShowExportButton && (\n <Stack direction=\"row\" justifyContent=\"right\" mb={-24} mr={8} mt={8} zIndex={1}>\n <Button\n onClick={handleExportToCsv}\n startIcon={<Icon name=\"ios_share\" />}\n variant=\"text\"\n >\n {transactionCopy.export_csv_btn}\n </Button>\n </Stack>\n )}\n <TransactionList height=\"100%\" onClick={setTransactionGuid} />\n </Stack>\n )}\n {selectedTab === 1 && (\n <SubBudgetList budget={budget} onTransactionClick={setTransactionGuid} />\n )}\n\n <Drawer\n ariaLabelClose={commonCopy.close_aria}\n isOpen={Boolean(transaction)}\n onClose={() => setTransactionGuid('')}\n title={copy.details_transaction_drawer}\n >\n {transaction && <TransactionDetails transaction={transaction} />}\n </Drawer>\n </Stack>\n </Stack>\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;AA8BA,IAAa,KAA8C,EAAA,CAAU,EAAE,QAAA,EAAA,MAAa;AAClF,QAAM,EAAE,cAAA,GAAc,mBAAA,EAAA,IAAsB,EAAa,GACnD,EAAE,UAAA,EAAA,IAAa,EAAgB,GAC/B,EAAE,SAAS,GAAM,QAAQ,GAAY,cAAc,EAAA,IAAoB,EAAmB,GAC1F,EAAE,WAAA,GAAW,eAAA,GAAe,UAAA,EAAA,IAAa,EAAc,GACvD,EACJ,oBAAoB,GACp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WAAW,gBAAA,EAAC,GAAD,EAAM,MAAK,YAAa,CAAA;AAAA,UACnC,SAAQ;AAAA,UAEP,UAAA,EAAgB;AAAA,QACX,CAAA;AAAA,MACH,CAAA,GAET,gBAAA,EAAC,GAAD;AAAA,QAAiB,QAAO;AAAA,QAAO,SAAS;AAAA,MAAqB,CAAA,CACxD,EAAA,CAAA;AAAA,MAER,MAAgB,KACf,gBAAA,EAAC,GAAD;AAAA,QAAuB,QAAA;AAAA,QAAQ,oBAAoB;AAAA,MAAqB,CAAA;AAAA,MAG1E,gBAAA,EAAC,GAAD;AAAA,QACE,gBAAgB,EAAW;AAAA,QAC3B,QAAQ,EAAQ;AAAA,QAChB,SAAA,MAAe,EAAmB,EAAE;AAAA,QACpC,OAAO,EAAK;AAAA,QAEX,UAAA,KAAe,gBAAA,EAAC,GAAD,EAAiC,aAAA,EAAc,CAAA;AAAA,MACzD,CAAA;AAAA,IACH,EAAA,CAAA,CACF;AAAA;AAEX,CAAC"}
@@ -33,6 +33,7 @@ export interface Banner {
33
33
  deep_link_type?: number | null;
34
34
  }
35
35
  interface TransactionConfig {
36
+ hide_export_csv?: boolean;
36
37
  selected_account_guid?: string;
37
38
  }
38
39
  export interface ClientConfig {
@@ -438,8 +438,10 @@ export interface CreditUtilizationCopy {
438
438
  }
439
439
  /** The credit card payoff calculator drawer (`payoff_calculator_block`). */
440
440
  export interface PayoffCalculatorCopy {
441
- /** Drawer title, e.g. "Credit card payoff calculator". */
441
+ /** Drawer title, e.g. "Interest Charges". */
442
442
  title: string;
443
+ /** Form heading above the account line, e.g. "See Where You Can Save". */
444
+ heading?: string;
443
445
  description: string;
444
446
  credit_card_balance: string;
445
447
  interest_rate: string;
@@ -448,9 +450,16 @@ export interface PayoffCalculatorCopy {
448
450
  your_results: string;
449
451
  time_to_payoff: string;
450
452
  total_interest_paid: string;
453
+ /** Scenario tabs and figures; each falls back to an older key until mrs_content sends it. */
454
+ standard?: string;
455
+ extra_payment?: string;
456
+ payoff?: string;
457
+ interest_paid?: string;
451
458
  /** Time to payoff, `_1{number}` months: singular and plural. */
452
459
  month: string;
453
460
  months: string;
461
+ /** Short time to payoff, e.g. "_1{number} mo"; falls back to `month` / `months`. */
462
+ months_short?: string;
454
463
  calculation_failed: string;
455
464
  calculation_failed_description: string;
456
465
  /** Validation messages; `_1{value}` is the field label and `_2{amount}` the bound. */
@@ -1,134 +1,150 @@
1
- import _ from "../../../common/utils/AccountDisplayName.es.js";
2
- import { useAccountStore as d } from "../../../common/context/hooks.es.js";
3
- import { useRequiredCopy as S } from "../useRequiredCopy.es.js";
4
- import { isPayoffPossible as A } from "./payoff.es.js";
5
- import { buildPayoffRows as w, initialPayoffInputs as R, parsePayoffInputs as k, resolvePrimaryAccount as D, validatePayoffInputs as F } from "./layout.es.js";
6
- import { CalculationFailed as L, PayoffResults as $ } from "./PayoffResults.es.js";
7
- import l from "react";
8
- import { observer as j } from "mobx-react-lite";
9
- import c from "@mui/material/Stack";
10
- import { InstitutionLogo as B, Text as b, TextField as E } from "@mxenabled/mxui";
1
+ import S from "../../../common/utils/AccountDisplayName.es.js";
2
+ import { useAccountStore as m } from "../../../common/context/hooks.es.js";
3
+ import { useRequiredCopy as w } from "../useRequiredCopy.es.js";
4
+ import A from "../../components/SubHeader.es.js";
5
+ import { isPayoffPossible as I } from "./payoff.es.js";
6
+ import { buildPayoffRows as k, initialPayoffInputs as R, parsePayoffInputs as B, resolvePrimaryAccount as D, validatePayoffInputs as F } from "./layout.es.js";
7
+ import { CalculationFailed as $, PayoffResults as j } from "./PayoffResults.es.js";
8
+ import c from "react";
9
+ import { observer as E } from "mobx-react-lite";
10
+ import l from "@mui/material/Stack";
11
+ import { Text as g, TextField as L } from "@mxenabled/mxui";
11
12
  import T from "@mui/material/Button";
12
- import { jsx as r, jsxs as u } from "react/jsx-runtime";
13
- import N from "@mui/material/InputAdornment";
14
- var tt = ({ beat: o }) => {
15
- const { accountsLoaded: t, loadAccounts: i } = d();
16
- l.useEffect(() => {
17
- !o.primary_account && !t && i();
13
+ import { jsx as e, jsxs as u } from "react/jsx-runtime";
14
+ import G from "@mui/material/Box";
15
+ import N from "@mui/material/Divider";
16
+ import O from "@mui/material/InputAdornment";
17
+ var it = ({ beat: o }) => {
18
+ const { accountsLoaded: t, loadAccounts: s } = m();
19
+ c.useEffect(() => {
20
+ !o.primary_account && !t && s();
18
21
  }, []);
19
- }, ot = ({ beat: o }) => {
20
- const { accountsLoaded: t } = d();
22
+ }, st = ({ beat: o }) => {
23
+ const { accountsLoaded: t } = m();
21
24
  return { ready: !!o.primary_account || t };
22
- }, O = ({ account: o, copy: t }) => {
23
- const i = l.useId(), [n, x] = l.useState(() => R(o)), [p, v] = l.useState({}), [f, g] = l.useState({ status: "idle" }), y = o ? _(o) : "", C = (e) => (s) => x((a) => ({
25
+ }, W = ({ account: o, copy: t }) => {
26
+ const s = c.useId(), [n, x] = c.useState(() => R(o)), [p, P] = c.useState({}), [d, v] = c.useState({ status: "idle" }), h = o ? S(o) : "", _ = (r) => (i) => x((a) => ({
24
27
  ...a,
25
- [e]: s.target.value
26
- })), I = (e) => {
27
- e.preventDefault();
28
- const s = F(n, t);
29
- if (v(s), Object.keys(s).length > 0) return;
30
- const { balance: a, interestRate: h, monthlyPayment: P } = k(n);
31
- g(A(h, a, P) ? {
28
+ [r]: i.target.value
29
+ })), C = (r) => {
30
+ r.preventDefault();
31
+ const i = F(n, t);
32
+ if (P(i), Object.keys(i).length > 0) return;
33
+ const { balance: a, interestRate: y, monthlyPayment: b } = B(n);
34
+ v(I(y, a, b) ? {
32
35
  status: "calculated",
33
- rows: w(h, a, P)
36
+ rows: k(y, a, b)
34
37
  } : { status: "failed" });
35
- }, m = (e, s, a) => /* @__PURE__ */ r(E, {
36
- error: !!p[e],
38
+ }, f = (r, i, a) => /* @__PURE__ */ e(L, {
39
+ error: !!p[r],
37
40
  fullWidth: !0,
38
- helperText: p[e],
39
- id: `${i}-${e}`,
40
- label: s,
41
- onChange: C(e),
41
+ helperText: p[r],
42
+ id: `${s}-${r}`,
43
+ label: i,
44
+ onChange: _(r),
42
45
  slotProps: {
43
46
  htmlInput: { inputMode: "decimal" },
44
- input: { [a.position === "start" ? "startAdornment" : "endAdornment"]: /* @__PURE__ */ r(N, {
47
+ input: { [a.position === "start" ? "startAdornment" : "endAdornment"]: /* @__PURE__ */ e(O, {
45
48
  "aria-hidden": "true",
46
49
  position: a.position,
47
50
  children: a.symbol
48
51
  }) }
49
52
  },
50
- value: n[e]
53
+ value: n[r]
51
54
  });
52
- return /* @__PURE__ */ u(c, {
53
- component: "form",
54
- noValidate: !0,
55
- onSubmit: I,
56
- sx: { p: 16 },
55
+ return /* @__PURE__ */ u(l, {
56
+ sx: { flexGrow: 1 },
57
57
  children: [
58
- y && /* @__PURE__ */ u(c, {
58
+ /* @__PURE__ */ u(l, {
59
+ component: "form",
60
+ noValidate: !0,
61
+ onSubmit: C,
59
62
  sx: {
60
- alignItems: "center",
61
- flexDirection: "row",
62
- gap: 8
63
- },
64
- children: [/* @__PURE__ */ r(B, {
65
- alt: "",
66
- institutionGuid: o?.institution_guid ?? "",
67
- size: 24
68
- }), /* @__PURE__ */ r(b, {
69
- component: "p",
70
- variant: "body2",
71
- children: y
72
- })]
73
- }),
74
- /* @__PURE__ */ r(b, {
75
- color: "text.secondary",
76
- component: "p",
77
- sx: { mt: 16 },
78
- variant: "body2",
79
- children: t.description
80
- }),
81
- /* @__PURE__ */ u(c, {
82
- sx: {
83
- gap: 24,
63
+ bgcolor: "background.paper",
84
64
  pb: 24,
85
- pt: 32
65
+ px: 24
86
66
  },
87
- children: [m("balance", t.credit_card_balance, {
88
- position: "start",
89
- symbol: "$"
90
- }), /* @__PURE__ */ u(c, {
91
- sx: {
92
- flexDirection: "row",
93
- gap: 16
94
- },
95
- children: [m("interestRate", t.interest_rate, {
96
- position: "end",
97
- symbol: "%"
98
- }), m("monthlyPayment", t.monthly_payment, {
99
- position: "start",
100
- symbol: "$"
101
- })]
102
- })]
67
+ children: [
68
+ /* @__PURE__ */ u(l, {
69
+ sx: {
70
+ gap: 4,
71
+ pb: 12,
72
+ pt: 16
73
+ },
74
+ children: [t.heading && /* @__PURE__ */ e(g, {
75
+ bold: !0,
76
+ component: "h3",
77
+ variant: "h3",
78
+ children: t.heading
79
+ }), h && /* @__PURE__ */ e(A, { subtitle: {
80
+ logo: o?.institution_guid ? { institution_guid: o.institution_guid } : void 0,
81
+ text: h
82
+ } })]
83
+ }),
84
+ /* @__PURE__ */ e(g, {
85
+ color: "text.secondary",
86
+ component: "p",
87
+ variant: "body2",
88
+ children: t.description
89
+ }),
90
+ /* @__PURE__ */ u(l, {
91
+ sx: {
92
+ gap: 24,
93
+ pb: 24,
94
+ pt: 36
95
+ },
96
+ children: [f("balance", t.credit_card_balance, {
97
+ position: "start",
98
+ symbol: "$"
99
+ }), /* @__PURE__ */ u(l, {
100
+ sx: {
101
+ flexDirection: "row",
102
+ gap: 16
103
+ },
104
+ children: [f("interestRate", t.interest_rate, {
105
+ position: "end",
106
+ symbol: "%"
107
+ }), f("monthlyPayment", t.monthly_payment, {
108
+ position: "start",
109
+ symbol: "$"
110
+ })]
111
+ })]
112
+ }),
113
+ /* @__PURE__ */ e(T, {
114
+ fullWidth: !0,
115
+ size: "large",
116
+ type: "submit",
117
+ variant: "contained",
118
+ children: t.calculate
119
+ })
120
+ ]
103
121
  }),
104
- /* @__PURE__ */ r(T, {
105
- fullWidth: !0,
122
+ /* @__PURE__ */ e(N, {}),
123
+ /* @__PURE__ */ e(G, {
106
124
  sx: {
107
- mb: 24,
108
- mt: 8
125
+ bgcolor: "background.default",
126
+ flexGrow: 1,
127
+ p: 24
109
128
  },
110
- type: "submit",
111
- variant: "contained",
112
- children: t.calculate
113
- }),
114
- f.status === "failed" ? /* @__PURE__ */ r(L, { copy: t }) : /* @__PURE__ */ r($, {
115
- copy: t,
116
- rows: f.status === "calculated" ? f.rows : void 0
129
+ children: d.status === "failed" ? /* @__PURE__ */ e($, { copy: t }) : /* @__PURE__ */ e(j, {
130
+ copy: t,
131
+ rows: d.status === "calculated" ? d.rows : void 0
132
+ })
117
133
  })
118
134
  ]
119
135
  });
120
- }, W = (o) => o.insights_feed?.payoff_calculator, et = j(function({ beat: t }) {
121
- const { accounts: i } = d(), n = S(W);
122
- return /* @__PURE__ */ r(O, {
123
- account: D(t, i),
136
+ }, q = (o) => o.insights_feed?.payoff_calculator, nt = E(function({ beat: t }) {
137
+ const { accounts: s } = m(), n = w(q);
138
+ return /* @__PURE__ */ e(W, {
139
+ account: D(t, s),
124
140
  copy: n
125
141
  }, t.guid);
126
142
  });
127
143
  export {
128
- et as PayoffCalculatorBlock,
129
- W as selectPayoffCalculatorCopy,
130
- ot as usePayoffCalculatorLoadState,
131
- tt as usePayoffCalculatorPrepare
144
+ nt as PayoffCalculatorBlock,
145
+ q as selectPayoffCalculatorCopy,
146
+ st as usePayoffCalculatorLoadState,
147
+ it as usePayoffCalculatorPrepare
132
148
  };
133
149
 
134
150
  //# sourceMappingURL=PayoffCalculatorBlock.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PayoffCalculatorBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/PayoffCalculatorBlock/PayoffCalculatorBlock.tsx"],"sourcesContent":["import React from 'react'\n\nimport Button from '@mui/material/Button'\nimport InputAdornment from '@mui/material/InputAdornment'\nimport Stack from '@mui/material/Stack'\n\nimport { InstitutionLogo, Text, TextField } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport { useAccountStore } from '../../../common'\nimport getAccountDisplayName from '../../../common/utils/AccountDisplayName'\nimport type { Account, GlobalCopy, PayoffCalculatorCopy } from '../../../core'\nimport type { ActionBlockProps, BlockLoadState } from '../../mappings/blocks'\nimport { useRequiredCopy } from '../useRequiredCopy'\n\nimport {\n buildPayoffRows,\n initialPayoffInputs,\n parsePayoffInputs,\n resolvePrimaryAccount,\n validatePayoffInputs,\n type PayoffErrors,\n type PayoffField,\n type PayoffInputs,\n type PayoffRow,\n} from './layout'\nimport { isPayoffPossible } from './payoff'\nimport { CalculationFailed, PayoffResults } from './PayoffResults'\n\n/** Loads accounts once per open when the host did not attach the beat's primary account. */\nexport const usePayoffCalculatorPrepare = ({ beat }: ActionBlockProps) => {\n const { accountsLoaded, loadAccounts } = useAccountStore()\n\n React.useEffect(() => {\n if (!beat.primary_account && !accountsLoaded) void loadAccounts()\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [])\n}\n\n/** Ready at once when the host attached the beat's account, else once the accounts load. */\nexport const usePayoffCalculatorLoadState = ({ beat }: ActionBlockProps): BlockLoadState => {\n const { accountsLoaded } = useAccountStore()\n\n return { ready: !!beat.primary_account || accountsLoaded }\n}\n\ntype Outcome =\n | { status: 'idle' }\n | { status: 'calculated'; rows: PayoffRow[] }\n | { status: 'failed' }\n\ninterface PayoffCalculatorFormProps {\n account?: Account\n copy: PayoffCalculatorCopy\n}\n\nconst PayoffCalculatorForm = ({ account, copy }: PayoffCalculatorFormProps) => {\n const id = React.useId()\n const [inputs, setInputs] = React.useState<PayoffInputs>(() => initialPayoffInputs(account))\n const [errors, setErrors] = React.useState<PayoffErrors>({})\n const [outcome, setOutcome] = React.useState<Outcome>({ status: 'idle' })\n\n const accountName = account ? getAccountDisplayName(account) : ''\n\n const setField = (field: PayoffField) => (event: React.ChangeEvent<HTMLInputElement>) =>\n setInputs((previous) => ({ ...previous, [field]: event.target.value }))\n\n const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => {\n event.preventDefault()\n\n const nextErrors = validatePayoffInputs(inputs, copy)\n\n setErrors(nextErrors)\n if (Object.keys(nextErrors).length > 0) return\n\n const { balance, interestRate, monthlyPayment } = parsePayoffInputs(inputs)\n\n setOutcome(\n isPayoffPossible(interestRate, balance, monthlyPayment)\n ? { status: 'calculated', rows: buildPayoffRows(interestRate, balance, monthlyPayment) }\n : { status: 'failed' },\n )\n }\n\n const field = (\n name: PayoffField,\n label: string,\n adornment: { position: 'start' | 'end'; symbol: string },\n ) => (\n <TextField\n error={!!errors[name]}\n fullWidth={true}\n helperText={errors[name]}\n id={`${id}-${name}`}\n label={label}\n onChange={setField(name)}\n slotProps={{\n htmlInput: { inputMode: 'decimal' },\n input: {\n [adornment.position === 'start' ? 'startAdornment' : 'endAdornment']: (\n <InputAdornment aria-hidden=\"true\" position={adornment.position}>\n {adornment.symbol}\n </InputAdornment>\n ),\n },\n }}\n value={inputs[name]}\n />\n )\n\n return (\n <Stack component=\"form\" noValidate={true} onSubmit={handleSubmit} sx={{ p: 16 }}>\n {accountName && (\n <Stack sx={{ alignItems: 'center', flexDirection: 'row', gap: 8 }}>\n <InstitutionLogo alt=\"\" institutionGuid={account?.institution_guid ?? ''} size={24} />\n <Text component=\"p\" variant=\"body2\">\n {accountName}\n </Text>\n </Stack>\n )}\n <Text color=\"text.secondary\" component=\"p\" sx={{ mt: 16 }} variant=\"body2\">\n {copy.description}\n </Text>\n <Stack sx={{ gap: 24, pb: 24, pt: 32 }}>\n {field('balance', copy.credit_card_balance, { position: 'start', symbol: '$' })}\n <Stack sx={{ flexDirection: 'row', gap: 16 }}>\n {field('interestRate', copy.interest_rate, { position: 'end', symbol: '%' })}\n {field('monthlyPayment', copy.monthly_payment, { position: 'start', symbol: '$' })}\n </Stack>\n </Stack>\n <Button fullWidth={true} sx={{ mb: 24, mt: 8 }} type=\"submit\" variant=\"contained\">\n {copy.calculate}\n </Button>\n {outcome.status === 'failed' ? (\n <CalculationFailed copy={copy} />\n ) : (\n <PayoffResults\n copy={copy}\n rows={outcome.status === 'calculated' ? outcome.rows : undefined}\n />\n )}\n </Stack>\n )\n}\n\nexport const selectPayoffCalculatorCopy = (copy: GlobalCopy) =>\n copy.insights_feed?.payoff_calculator\n\n/**\n * Monthly Credit Card Interest Summary's \"Learn how to save\" drawer: the credit card payoff\n * calculator. The beat's account prefills the balance, interest rate and minimum payment; the\n * user edits them and compares the payoff at that payment, $10 more and $20 more.\n */\nexport const PayoffCalculatorBlock = observer(function PayoffCalculatorBlock({\n beat,\n}: ActionBlockProps) {\n const { accounts } = useAccountStore()\n const copy = useRequiredCopy(selectPayoffCalculatorCopy)\n\n return (\n <PayoffCalculatorForm\n account={resolvePrimaryAccount(beat, accounts)}\n copy={copy}\n key={beat.guid}\n />\n )\n})\n"],"mappings":";;;;;;;;;;;;;AA8BA,IAAa,KAAA,CAA8B,EAAE,MAAA,EAAA,MAA6B;AACxE,QAAM,EAAE,gBAAA,GAAgB,cAAA,EAAA,IAAiB,EAAgB;AAEzD,EAAA,EAAM,UAAA,MAAgB;AACpB,IAAI,CAAC,EAAK,mBAAmB,CAAC,KAAgB,EAAkB;AAAA,EAElE,GAAG,CAAC,CAAC;AACP,GAGa,KAAA,CAAgC,EAAE,MAAA,EAAA,MAA6C;AAC1F,QAAM,EAAE,gBAAA,EAAA,IAAmB,EAAgB;AAE3C,SAAO,EAAE,OAAO,CAAC,CAAC,EAAK,mBAAmB,EAAe;AAC3D,GAYM,IAAA,CAAwB,EAAE,SAAA,GAAS,MAAA,EAAA,MAAsC;AAC7E,QAAM,IAAK,EAAM,MAAM,GACjB,CAAC,GAAQ,CAAA,IAAa,EAAM,SAAA,MAA6B,EAAoB,CAAO,CAAC,GACrF,CAAC,GAAQ,CAAA,IAAa,EAAM,SAAuB,CAAC,CAAC,GACrD,CAAC,GAAS,CAAA,IAAc,EAAM,SAAkB,EAAE,QAAQ,OAAO,CAAC,GAElE,IAAc,IAAU,EAAsB,CAAO,IAAI,IAEzD,IAAA,CAAY,MAAA,CAAwB,MACxC,EAAA,CAAW,OAAc;AAAA,IAAE,GAAG;AAAA,IAAW,CAAA,CAAA,GAAQ,EAAM,OAAO;AAAA,EAAM,EAAE,GAElE,IAAA,CAAgB,MAA4C;AAChE,IAAA,EAAM,eAAe;AAErB,UAAM,IAAa,EAAqB,GAAQ,CAAI;AAGpD,QADA,EAAU,CAAU,GAChB,OAAO,KAAK,CAAU,EAAE,SAAS,EAAG;AAExC,UAAM,EAAE,SAAA,GAAS,cAAA,GAAc,gBAAA,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,CAA0B;AAEvD,SACE,gBAAA,EAAC,GAAD;AAAA,IACE,SAAS,EAAsB,GAAM,CAAQ;AAAA,IACvC,MAAA;AAAA,EAEP,GADM,EAAK,IACX;AAEL,CAAC"}
1
+ {"version":3,"file":"PayoffCalculatorBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/PayoffCalculatorBlock/PayoffCalculatorBlock.tsx"],"sourcesContent":["import React from 'react'\n\nimport Box from '@mui/material/Box'\nimport Button from '@mui/material/Button'\nimport Divider from '@mui/material/Divider'\nimport InputAdornment from '@mui/material/InputAdornment'\nimport Stack from '@mui/material/Stack'\n\nimport { Text, TextField } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport { useAccountStore } from '../../../common'\nimport getAccountDisplayName from '../../../common/utils/AccountDisplayName'\nimport type { Account, GlobalCopy, PayoffCalculatorCopy } from '../../../core'\nimport type { ActionBlockProps, BlockLoadState } from '../../mappings/blocks'\nimport SubHeader from '../../components/SubHeader'\nimport { useRequiredCopy } from '../useRequiredCopy'\n\nimport {\n buildPayoffRows,\n initialPayoffInputs,\n parsePayoffInputs,\n resolvePrimaryAccount,\n validatePayoffInputs,\n type PayoffErrors,\n type PayoffField,\n type PayoffInputs,\n type PayoffRow,\n} from './layout'\nimport { isPayoffPossible } from './payoff'\nimport { CalculationFailed, PayoffResults } from './PayoffResults'\n\n/** Loads accounts once per open when the host did not attach the beat's primary account. */\nexport const usePayoffCalculatorPrepare = ({ beat }: ActionBlockProps) => {\n const { accountsLoaded, loadAccounts } = useAccountStore()\n\n React.useEffect(() => {\n if (!beat.primary_account && !accountsLoaded) void loadAccounts()\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [])\n}\n\n/** Ready at once when the host attached the beat's account, else once the accounts load. */\nexport const usePayoffCalculatorLoadState = ({ beat }: ActionBlockProps): BlockLoadState => {\n const { accountsLoaded } = useAccountStore()\n\n return { ready: !!beat.primary_account || accountsLoaded }\n}\n\ntype Outcome =\n | { status: 'idle' }\n | { status: 'calculated'; rows: PayoffRow[] }\n | { status: 'failed' }\n\ninterface PayoffCalculatorFormProps {\n account?: Account\n copy: PayoffCalculatorCopy\n}\n\nconst PayoffCalculatorForm = ({ account, copy }: PayoffCalculatorFormProps) => {\n const id = React.useId()\n const [inputs, setInputs] = React.useState<PayoffInputs>(() => initialPayoffInputs(account))\n const [errors, setErrors] = React.useState<PayoffErrors>({})\n const [outcome, setOutcome] = React.useState<Outcome>({ status: 'idle' })\n\n const accountName = account ? getAccountDisplayName(account) : ''\n\n const setField = (field: PayoffField) => (event: React.ChangeEvent<HTMLInputElement>) =>\n setInputs((previous) => ({ ...previous, [field]: event.target.value }))\n\n const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => {\n event.preventDefault()\n\n const nextErrors = validatePayoffInputs(inputs, copy)\n\n setErrors(nextErrors)\n if (Object.keys(nextErrors).length > 0) return\n\n const { balance, interestRate, monthlyPayment } = parsePayoffInputs(inputs)\n\n setOutcome(\n isPayoffPossible(interestRate, balance, monthlyPayment)\n ? { status: 'calculated', rows: buildPayoffRows(interestRate, balance, monthlyPayment) }\n : { status: 'failed' },\n )\n }\n\n const field = (\n name: PayoffField,\n label: string,\n adornment: { position: 'start' | 'end'; symbol: string },\n ) => (\n <TextField\n error={!!errors[name]}\n fullWidth={true}\n helperText={errors[name]}\n id={`${id}-${name}`}\n label={label}\n onChange={setField(name)}\n slotProps={{\n htmlInput: { inputMode: 'decimal' },\n input: {\n [adornment.position === 'start' ? 'startAdornment' : 'endAdornment']: (\n <InputAdornment aria-hidden=\"true\" position={adornment.position}>\n {adornment.symbol}\n </InputAdornment>\n ),\n },\n }}\n value={inputs[name]}\n />\n )\n\n // Figma `Monthly CC Interest Summary/Drilldown`: the form on paper, a divider, then the scenario\n // card on the grey wash.\n return (\n <Stack sx={{ flexGrow: 1 }}>\n <Stack\n component=\"form\"\n noValidate={true}\n onSubmit={handleSubmit}\n sx={{ bgcolor: 'background.paper', pb: 24, px: 24 }}\n >\n <Stack sx={{ gap: 4, pb: 12, pt: 16 }}>\n {copy.heading && (\n <Text bold={true} component=\"h3\" variant=\"h3\">\n {copy.heading}\n </Text>\n )}\n {accountName && (\n <SubHeader\n subtitle={{\n logo: account?.institution_guid\n ? { institution_guid: account.institution_guid }\n : undefined,\n text: accountName,\n }}\n />\n )}\n </Stack>\n <Text color=\"text.secondary\" component=\"p\" variant=\"body2\">\n {copy.description}\n </Text>\n <Stack sx={{ gap: 24, pb: 24, pt: 36 }}>\n {field('balance', copy.credit_card_balance, { position: 'start', symbol: '$' })}\n <Stack sx={{ flexDirection: 'row', gap: 16 }}>\n {field('interestRate', copy.interest_rate, { position: 'end', symbol: '%' })}\n {field('monthlyPayment', copy.monthly_payment, { position: 'start', symbol: '$' })}\n </Stack>\n </Stack>\n <Button fullWidth={true} size=\"large\" type=\"submit\" variant=\"contained\">\n {copy.calculate}\n </Button>\n </Stack>\n <Divider />\n <Box sx={{ bgcolor: 'background.default', flexGrow: 1, p: 24 }}>\n {outcome.status === 'failed' ? (\n <CalculationFailed copy={copy} />\n ) : (\n <PayoffResults\n copy={copy}\n rows={outcome.status === 'calculated' ? outcome.rows : undefined}\n />\n )}\n </Box>\n </Stack>\n )\n}\n\nexport const selectPayoffCalculatorCopy = (copy: GlobalCopy) =>\n copy.insights_feed?.payoff_calculator\n\n/**\n * Monthly Credit Card Interest Summary's \"Learn how to save\" drawer: the credit card payoff\n * calculator. The beat's account prefills the balance, interest rate and minimum payment; the\n * user edits them and compares the payoff at that payment, $10 more and $20 more.\n */\nexport const PayoffCalculatorBlock = observer(function PayoffCalculatorBlock({\n beat,\n}: ActionBlockProps) {\n const { accounts } = useAccountStore()\n const copy = useRequiredCopy(selectPayoffCalculatorCopy)\n\n return (\n <PayoffCalculatorForm\n account={resolvePrimaryAccount(beat, accounts)}\n copy={copy}\n key={beat.guid}\n />\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;AAiCA,IAAa,KAAA,CAA8B,EAAE,MAAA,EAAA,M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,MAAA,EAAA,GACmB;AACnB,QAAM,EAAE,UAAA,EAAA,IAAa,EAAgB,GAC/B,IAAO,EAAgB,CAA0B;AAEvD,SACE,gBAAA,EAAC,GAAD;AAAA,IACE,SAAS,EAAsB,GAAM,CAAQ;AAAA,IACvC,MAAA;AAAA,EAEP,GADM,EAAK,IACX;AAEL,CAAC"}
@@ -1,10 +1,17 @@
1
1
  import { PayoffCalculatorCopy } from '../../../core';
2
2
  import { PayoffRow } from './layout';
3
+ /** "_1{number} mo" when the copy has the short form, else the "month"/"months" plural. */
4
+ export declare const formatPayoffTime: (copy: PayoffCalculatorCopy, paymentCount: number) => string;
3
5
  interface PayoffResultsProps {
4
6
  copy: PayoffCalculatorCopy;
5
- /** Undefined until the user has calculated: the rows then show placeholders. */
7
+ /** Undefined until the user has calculated: the figures then show placeholders. */
6
8
  rows?: PayoffRow[];
7
9
  }
10
+ /**
11
+ * The scenario card (Figma `Monthly CC Prediction Summary/Drilldown Content`): one tab per payment
12
+ * increment — Standard, +$10, +$20 — each showing the entered payment plus the extra, then the
13
+ * time to payoff and the interest paid at that payment.
14
+ */
8
15
  export declare const PayoffResults: ({ copy, rows }: PayoffResultsProps) => import("react/jsx-runtime").JSX.Element;
9
16
  export declare const CalculationFailed: ({ copy }: {
10
17
  copy: PayoffCalculatorCopy;