@mx-cartographer/experiences 9.7.160 → 9.7.162
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 +9 -0
- package/dist/common/components/CurrencyDialog.d.ts +11 -1
- package/dist/common/components/CurrencyDialog.es.js +50 -44
- package/dist/common/components/CurrencyDialog.es.js.map +1 -1
- package/dist/common/components/index.d.ts +1 -1
- package/dist/core/types/localization/InsightsFeedCopy.d.ts +8 -0
- package/dist/insights/components/shared/Charts/BarChart/ChartLegendV2.es.js +6 -6
- package/dist/insights/components/shared/Charts/BarChart/ChartLegendV2.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.d.ts +1 -1
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.es.js +91 -91
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/layout.d.ts +42 -2
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/layout.es.js +75 -15
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/QuizMerchantBlock/QuizMerchantBlock.es.js +3 -3
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListBlock.es.js +64 -59
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListCreditLimitHeader.d.ts +11 -0
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListCreditLimitHeader.es.js +138 -0
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListCreditLimitHeader.es.js.map +1 -0
- package/dist/insights-v2/actionBlocks/TransactionListBlock/layout.d.ts +13 -0
- package/dist/insights-v2/actionBlocks/TransactionListBlock/layout.es.js +80 -63
- package/dist/insights-v2/actionBlocks/TransactionListBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/DonutChartBlock.es.js +14 -14
- package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/DonutChartBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/layout.d.ts +9 -2
- package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/layout.es.js +14 -7
- package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/utils.d.ts +7 -1
- package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/utils.es.js +14 -7
- package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/utils.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/SavingsSummaryBlock/SavingsSummaryBlock.es.js +1 -1
- package/dist/insights-v2/blocks/ImageBlocks/SVGImageBlock/SVGImageBlock.es.js +16 -19
- package/dist/insights-v2/blocks/ImageBlocks/SVGImageBlock/SVGImageBlock.es.js.map +1 -1
- package/dist/insights-v2/components/CompactInsightCard.es.js +164 -138
- package/dist/insights-v2/components/CompactInsightCard.es.js.map +1 -1
- package/package.json +1 -1
package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListCreditLimitHeader.es.js
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { buildDynamicCopy as v } from "../../../core/utils/Localization.es.js";
|
|
2
|
+
import { useUserStore as _ } from "../../../common/context/hooks.es.js";
|
|
3
|
+
import { CURRENCY_FORMAT as h, formatCurrency as u } from "../../../core/utils/NumberFormatting.es.js";
|
|
4
|
+
import w from "../../components/LogoFromGuid.es.js";
|
|
5
|
+
import { resolveCreditLimitAlertPercent as C } from "../AmountInputModalBlock/layout.es.js";
|
|
6
|
+
import { observer as $ } from "mobx-react-lite";
|
|
7
|
+
import r from "@mui/material/Stack";
|
|
8
|
+
import { Text as e } from "@mxenabled/mxui";
|
|
9
|
+
import { jsx as i, jsxs as t } from "react/jsx-runtime";
|
|
10
|
+
import n from "@mui/material/Box";
|
|
11
|
+
var k = $(function({ copy: a, header: x }) {
|
|
12
|
+
const { userInsightProfile: p } = _(), o = C(p), { accountName: c, balance: f, institutionGuid: s, institutionName: b, limit: g, utilization: l } = x, m = Math.min(l, 100), d = a?.credit_limit_header_utilization ? v(a.credit_limit_header_utilization, `${l}%`) : void 0;
|
|
13
|
+
return /* @__PURE__ */ t(r, {
|
|
14
|
+
"data-testid": "credit-limit-header",
|
|
15
|
+
sx: {
|
|
16
|
+
bgcolor: "background.paper",
|
|
17
|
+
borderBottom: 1,
|
|
18
|
+
borderColor: "divider",
|
|
19
|
+
gap: 16,
|
|
20
|
+
pb: 16,
|
|
21
|
+
pt: 24,
|
|
22
|
+
px: 24
|
|
23
|
+
},
|
|
24
|
+
children: [/* @__PURE__ */ t(r, {
|
|
25
|
+
sx: {
|
|
26
|
+
alignItems: "center",
|
|
27
|
+
flexDirection: "row",
|
|
28
|
+
gap: 12
|
|
29
|
+
},
|
|
30
|
+
children: [/* @__PURE__ */ i(w, {
|
|
31
|
+
logo: s ? {
|
|
32
|
+
guid: s,
|
|
33
|
+
alt: b
|
|
34
|
+
} : null,
|
|
35
|
+
size: 40
|
|
36
|
+
}), /* @__PURE__ */ t(r, {
|
|
37
|
+
sx: {
|
|
38
|
+
flexDirection: "row",
|
|
39
|
+
flexGrow: 1,
|
|
40
|
+
gap: 12,
|
|
41
|
+
minWidth: 0
|
|
42
|
+
},
|
|
43
|
+
children: [/* @__PURE__ */ t(r, {
|
|
44
|
+
sx: {
|
|
45
|
+
flexGrow: 1,
|
|
46
|
+
gap: 2,
|
|
47
|
+
minWidth: 0
|
|
48
|
+
},
|
|
49
|
+
children: [/* @__PURE__ */ i(e, {
|
|
50
|
+
bold: !0,
|
|
51
|
+
truncate: !0,
|
|
52
|
+
variant: "body1",
|
|
53
|
+
children: c ?? ""
|
|
54
|
+
}), a?.credit_limit_header_credit_limit && /* @__PURE__ */ i(e, {
|
|
55
|
+
color: "text.secondary",
|
|
56
|
+
variant: "body2",
|
|
57
|
+
children: a.credit_limit_header_credit_limit
|
|
58
|
+
})]
|
|
59
|
+
}), /* @__PURE__ */ t(r, {
|
|
60
|
+
sx: {
|
|
61
|
+
alignItems: "flex-end",
|
|
62
|
+
fontVariantNumeric: "tabular-nums",
|
|
63
|
+
gap: 2
|
|
64
|
+
},
|
|
65
|
+
children: [/* @__PURE__ */ i(e, {
|
|
66
|
+
bold: !0,
|
|
67
|
+
variant: "body1",
|
|
68
|
+
children: u(f, h.cents)
|
|
69
|
+
}), /* @__PURE__ */ i(e, {
|
|
70
|
+
color: "text.secondary",
|
|
71
|
+
variant: "body2",
|
|
72
|
+
children: u(g, h.cents)
|
|
73
|
+
})]
|
|
74
|
+
})]
|
|
75
|
+
})]
|
|
76
|
+
}), /* @__PURE__ */ t(r, {
|
|
77
|
+
sx: { gap: 2 },
|
|
78
|
+
children: [
|
|
79
|
+
/* @__PURE__ */ i(n, {
|
|
80
|
+
"aria-label": c ?? d,
|
|
81
|
+
"aria-valuemax": 100,
|
|
82
|
+
"aria-valuemin": 0,
|
|
83
|
+
"aria-valuenow": m,
|
|
84
|
+
"aria-valuetext": `${l}%`,
|
|
85
|
+
role: "meter",
|
|
86
|
+
sx: {
|
|
87
|
+
bgcolor: "neutral.light",
|
|
88
|
+
borderRadius: "4px",
|
|
89
|
+
height: 12,
|
|
90
|
+
overflow: "hidden"
|
|
91
|
+
},
|
|
92
|
+
children: /* @__PURE__ */ i(n, { sx: {
|
|
93
|
+
bgcolor: "warning.main",
|
|
94
|
+
borderRadius: "4px",
|
|
95
|
+
height: "100%",
|
|
96
|
+
width: `${m}%`
|
|
97
|
+
} })
|
|
98
|
+
}),
|
|
99
|
+
/* @__PURE__ */ t(n, {
|
|
100
|
+
sx: {
|
|
101
|
+
height: 24,
|
|
102
|
+
position: "relative"
|
|
103
|
+
},
|
|
104
|
+
children: [/* @__PURE__ */ i(n, {
|
|
105
|
+
"aria-hidden": !0,
|
|
106
|
+
sx: {
|
|
107
|
+
bgcolor: "divider",
|
|
108
|
+
height: 8,
|
|
109
|
+
left: `${o}%`,
|
|
110
|
+
position: "absolute",
|
|
111
|
+
transform: `translateX(-${o}%)`,
|
|
112
|
+
width: "1px"
|
|
113
|
+
}
|
|
114
|
+
}), /* @__PURE__ */ i(e, {
|
|
115
|
+
sx: {
|
|
116
|
+
left: `${o}%`,
|
|
117
|
+
position: "absolute",
|
|
118
|
+
top: 8,
|
|
119
|
+
transform: `translateX(-${o}%)`
|
|
120
|
+
},
|
|
121
|
+
variant: "caption",
|
|
122
|
+
children: `${o}%`
|
|
123
|
+
})]
|
|
124
|
+
}),
|
|
125
|
+
d && /* @__PURE__ */ i(e, {
|
|
126
|
+
variant: "caption",
|
|
127
|
+
children: d
|
|
128
|
+
})
|
|
129
|
+
]
|
|
130
|
+
})]
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
export {
|
|
134
|
+
k as TransactionListCreditLimitHeader,
|
|
135
|
+
k as default
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
//# sourceMappingURL=TransactionListCreditLimitHeader.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TransactionListCreditLimitHeader.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionListBlock/TransactionListCreditLimitHeader.tsx"],"sourcesContent":["import Box from '@mui/material/Box'\nimport Stack from '@mui/material/Stack'\n\nimport { Text } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport { useUserStore } from '../../../common'\n\nimport type { TransactionListBlockCopy } from '../../../core/types/localization/InsightsFeedCopy'\nimport { buildDynamicCopy } from '../../../core/utils/Localization'\nimport { CURRENCY_FORMAT, formatCurrency } from '../../../core/utils/NumberFormatting'\nimport LogoFromGuid from '../../components/LogoFromGuid'\nimport { resolveCreditLimitAlertPercent } from '../AmountInputModalBlock/layout'\n\nimport type { CreditLimitHeader } from './layout'\n\nexport interface TransactionListCreditLimitHeaderProps {\n header: CreditLimitHeader\n copy?: TransactionListBlockCopy\n}\n\n/** The Spending list's credit-limit header: card, balance, limit and utilization against the user's alert percentage. */\nexport const TransactionListCreditLimitHeader = observer(function TransactionListCreditLimitHeader({\n copy,\n header,\n}: TransactionListCreditLimitHeaderProps) {\n const { userInsightProfile } = useUserStore()\n const alertPercent = resolveCreditLimitAlertPercent(userInsightProfile)\n const { accountName, balance, institutionGuid, institutionName, limit, utilization } = header\n const fillPercent = Math.min(utilization, 100)\n const utilizationText = copy?.credit_limit_header_utilization\n ? (buildDynamicCopy(copy.credit_limit_header_utilization, `${utilization}%`) as string)\n : undefined\n\n return (\n <Stack\n data-testid=\"credit-limit-header\"\n sx={{\n bgcolor: 'background.paper',\n borderBottom: 1,\n borderColor: 'divider',\n gap: 16,\n pb: 16,\n pt: 24,\n px: 24,\n }}\n >\n <Stack sx={{ alignItems: 'center', flexDirection: 'row', gap: 12 }}>\n <LogoFromGuid\n logo={institutionGuid ? { guid: institutionGuid, alt: institutionName } : null}\n size={40}\n />\n <Stack sx={{ flexDirection: 'row', flexGrow: 1, gap: 12, minWidth: 0 }}>\n <Stack sx={{ flexGrow: 1, gap: 2, minWidth: 0 }}>\n <Text bold={true} truncate={true} variant=\"body1\">\n {accountName ?? ''}\n </Text>\n {copy?.credit_limit_header_credit_limit && (\n <Text color=\"text.secondary\" variant=\"body2\">\n {copy.credit_limit_header_credit_limit}\n </Text>\n )}\n </Stack>\n <Stack sx={{ alignItems: 'flex-end', fontVariantNumeric: 'tabular-nums', gap: 2 }}>\n <Text bold={true} variant=\"body1\">\n {formatCurrency(balance, CURRENCY_FORMAT.cents)}\n </Text>\n <Text color=\"text.secondary\" variant=\"body2\">\n {formatCurrency(limit, CURRENCY_FORMAT.cents)}\n </Text>\n </Stack>\n </Stack>\n </Stack>\n\n <Stack sx={{ gap: 2 }}>\n <Box\n aria-label={accountName ?? utilizationText}\n aria-valuemax={100}\n aria-valuemin={0}\n aria-valuenow={fillPercent}\n aria-valuetext={`${utilization}%`}\n role=\"meter\"\n sx={{ bgcolor: 'neutral.light', borderRadius: '4px', height: 12, overflow: 'hidden' }}\n >\n <Box\n sx={{\n bgcolor: 'warning.main',\n borderRadius: '4px',\n height: '100%',\n width: `${fillPercent}%`,\n }}\n />\n </Box>\n {/* Own row, so a low alert can't overlap the caption; tick and label shift to stay inside the bar. */}\n <Box sx={{ height: 24, position: 'relative' }}>\n <Box\n aria-hidden={true}\n sx={{\n bgcolor: 'divider',\n height: 8,\n left: `${alertPercent}%`,\n position: 'absolute',\n transform: `translateX(-${alertPercent}%)`,\n width: '1px',\n }}\n />\n <Text\n sx={{\n left: `${alertPercent}%`,\n position: 'absolute',\n top: 8,\n transform: `translateX(-${alertPercent}%)`,\n }}\n variant=\"caption\"\n >\n {`${alertPercent}%`}\n </Text>\n </Box>\n {utilizationText && <Text variant=\"caption\">{utilizationText}</Text>}\n </Stack>\n </Stack>\n )\n})\n\nexport default TransactionListCreditLimitHeader\n"],"mappings":";;;;;;;;;;AAsBA,IAAa,IAAmC,EAAS,SAA0C,EACjG,MAAA,GACA,QAAA,EAAA,GACwC;AACxC,QAAM,EAAE,oBAAA,EAAA,IAAuB,EAAa,GACtC,IAAe,EAA+B,CAAkB,GAChE,EAAE,aAAA,GAAa,SAAA,GAAS,iBAAA,GAAiB,iBAAA,GAAiB,OAAA,GAAO,aAAA,EAAA,IAAgB,GACjF,IAAc,KAAK,IAAI,GAAa,GAAG,GACvC,IAAkB,GAAM,kCACzB,EAAiB,EAAK,iCAAiC,GAAG,CAAA,GAAc,IACzE;AAEJ,SACE,gBAAA,EAAC,GAAD;AAAA,IACE,eAAY;AAAA,IACZ,IAAI;AAAA,MACF,SAAS;AAAA,MACT,cAAc;AAAA,MACd,aAAa;AAAA,MACb,KAAK;AAAA,MACL,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,IACN;AAAA,IAVF,UAAA,C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@@ -9,6 +9,8 @@ export declare const TRANSACTION_LIST_VARIANTS: {
|
|
|
9
9
|
readonly HELP_HEADER: "help_header";
|
|
10
10
|
/** Opens Micro Deposits' Deposit History list. */
|
|
11
11
|
readonly DEPOSIT_HISTORY: "deposit_history";
|
|
12
|
+
/** Opens Credit Card Close to Limit's Spending list under the card's credit-limit header. */
|
|
13
|
+
readonly CREDIT_LIMIT_HEADER: "credit_limit_header";
|
|
12
14
|
/** Opens Monthly Subscription Aggregate's Subscriptions list under a count tile and a tip. */
|
|
13
15
|
readonly SUBSCRIPTION_LIST: "subscription_list";
|
|
14
16
|
};
|
|
@@ -53,6 +55,17 @@ export interface TransactionListSummary {
|
|
|
53
55
|
* `count` (number of transactions).
|
|
54
56
|
*/
|
|
55
57
|
export declare const readSummary: (cta: DrilldownCta | undefined) => TransactionListSummary | undefined;
|
|
58
|
+
export interface CreditLimitHeader {
|
|
59
|
+
balance: number;
|
|
60
|
+
limit: number;
|
|
61
|
+
/** Whole percent of the limit used; over 100 when the card is over its limit. */
|
|
62
|
+
utilization: number;
|
|
63
|
+
institutionGuid?: string;
|
|
64
|
+
institutionName?: string;
|
|
65
|
+
accountName?: string;
|
|
66
|
+
}
|
|
67
|
+
/** The credit-limit header from the clicked CTA's `drilldown_data`; only `credit_limit_header`, with a positive limit. */
|
|
68
|
+
export declare const readCreditLimitHeader: (cta: DrilldownCta | undefined) => CreditLimitHeader | undefined;
|
|
56
69
|
/** Each listed transaction's schedule, from `drilldown_data.transaction_frequencies`; malformed rows are dropped. */
|
|
57
70
|
export declare const readTransactionFrequencies: (cta: DrilldownCta | undefined) => Map<string, number> | undefined;
|
|
58
71
|
export interface SubscriptionListHeader {
|
|
@@ -1,107 +1,124 @@
|
|
|
1
|
-
import { asNonEmptyText as
|
|
2
|
-
import { readHelp as
|
|
3
|
-
import { parseISO as
|
|
1
|
+
import { asNonEmptyText as s, asNumber as _ } from "../../blocks/slotReaders.es.js";
|
|
2
|
+
import { readHelp as I } from "../HelpBlock/layout.es.js";
|
|
3
|
+
import { parseISO as m } from "date-fns/parseISO";
|
|
4
4
|
var a = {
|
|
5
5
|
SUMMARY_HEADER: "summary_header",
|
|
6
6
|
GENERIC_LIST: "generic_list",
|
|
7
7
|
HELP_HEADER: "help_header",
|
|
8
8
|
DEPOSIT_HISTORY: "deposit_history",
|
|
9
|
+
CREDIT_LIMIT_HEADER: "credit_limit_header",
|
|
9
10
|
SUBSCRIPTION_LIST: "subscription_list"
|
|
10
|
-
}, b = /* @__PURE__ */ new Set([a.SUMMARY_HEADER, a.SUBSCRIPTION_LIST]),
|
|
11
|
-
switch (
|
|
11
|
+
}, b = /* @__PURE__ */ new Set([a.SUMMARY_HEADER, a.SUBSCRIPTION_LIST]), E = a.HELP_HEADER, D = (e, t, r) => {
|
|
12
|
+
switch (e) {
|
|
12
13
|
case a.GENERIC_LIST:
|
|
13
14
|
case a.HELP_HEADER:
|
|
14
|
-
return
|
|
15
|
+
return t.transactions?.transactions_title ?? "";
|
|
15
16
|
case a.DEPOSIT_HISTORY:
|
|
16
|
-
return
|
|
17
|
+
return t.insights_feed?.transaction_list_block?.deposit_history_drawer_title ?? "";
|
|
18
|
+
case a.CREDIT_LIMIT_HEADER:
|
|
19
|
+
return t.insights_feed?.transaction_list_block?.credit_limit_header_drawer_title ?? "";
|
|
17
20
|
case a.SUBSCRIPTION_LIST:
|
|
18
|
-
return
|
|
21
|
+
return t.insights_feed?.transaction_list_block?.subscriptions_drawer_title ?? "";
|
|
19
22
|
default:
|
|
20
|
-
return
|
|
23
|
+
return r?.insights_payload?.title ?? "";
|
|
21
24
|
}
|
|
22
|
-
}, H = (
|
|
23
|
-
if (
|
|
24
|
-
const
|
|
25
|
+
}, H = (e, t) => {
|
|
26
|
+
if (e?.variant !== E) return;
|
|
27
|
+
const r = s(t?.help_label), n = I(t);
|
|
25
28
|
return {
|
|
26
|
-
descriptionHtml:
|
|
27
|
-
...
|
|
29
|
+
descriptionHtml: s(t?.description_html),
|
|
30
|
+
...r && n && { learnMore: {
|
|
28
31
|
...n,
|
|
29
|
-
label:
|
|
32
|
+
label: r
|
|
30
33
|
} }
|
|
31
34
|
};
|
|
32
|
-
},
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
},
|
|
36
|
-
if (
|
|
35
|
+
}, f = (e) => typeof e == "number" && Number.isInteger(e) && e > 0 ? e : void 0, p = Date.UTC(2e3, 0, 1), S = Date.UTC(2100, 0, 1), T = /* @__PURE__ */ new WeakMap(), c = (e, t) => {
|
|
36
|
+
const r = T.get(e) ?? /* @__PURE__ */ new Set();
|
|
37
|
+
r.has(t) || (T.set(e, r.add(t)), console.warn(t));
|
|
38
|
+
}, u = (e, t, r) => {
|
|
39
|
+
if (e == null || e === "") return;
|
|
37
40
|
let n;
|
|
38
|
-
if (typeof
|
|
39
|
-
else if (typeof
|
|
40
|
-
const i =
|
|
41
|
+
if (typeof e == "number" && Number.isFinite(e)) n = e < 1e12 ? e * 1e3 : e;
|
|
42
|
+
else if (typeof e == "string") {
|
|
43
|
+
const i = m(e).getTime();
|
|
41
44
|
n = Number.isNaN(i) ? void 0 : i;
|
|
42
45
|
}
|
|
43
|
-
if (n === void 0 || n <
|
|
44
|
-
|
|
46
|
+
if (n === void 0 || n < p || n > S) {
|
|
47
|
+
c(r, `[TransactionListBlock] drilldown_data.${t} is unparseable or out of range (${typeof e})`);
|
|
45
48
|
return;
|
|
46
49
|
}
|
|
47
50
|
return new Date(n);
|
|
48
|
-
}, L = (
|
|
49
|
-
if (
|
|
50
|
-
const
|
|
51
|
-
if (!
|
|
52
|
-
const
|
|
53
|
-
if (
|
|
54
|
-
Object.keys(
|
|
51
|
+
}, L = (e) => {
|
|
52
|
+
if (e?.variant !== a.SUMMARY_HEADER) return;
|
|
53
|
+
const t = e?.drilldown_data;
|
|
54
|
+
if (!t) return;
|
|
55
|
+
const r = _(t.amount);
|
|
56
|
+
if (r === void 0) {
|
|
57
|
+
Object.keys(t).length > 0 && c(t, "[TransactionListBlock] drilldown_data has no finite `amount` — no summary header.");
|
|
55
58
|
return;
|
|
56
59
|
}
|
|
57
60
|
return {
|
|
58
|
-
amount:
|
|
59
|
-
startDate:
|
|
60
|
-
endDate:
|
|
61
|
-
count:
|
|
61
|
+
amount: r,
|
|
62
|
+
startDate: u(t.start_date, "start_date", t),
|
|
63
|
+
endDate: u(t.end_date, "end_date", t),
|
|
64
|
+
count: f(t.count)
|
|
62
65
|
};
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
66
|
+
}, w = (e) => {
|
|
67
|
+
if (e?.variant !== a.CREDIT_LIMIT_HEADER) return;
|
|
68
|
+
const t = e.drilldown_data, r = _(t?.current_balance), n = _(t?.credit_limit);
|
|
69
|
+
if (r === void 0 || n === void 0 || n <= 0) return;
|
|
70
|
+
const i = s(t?.institution_guid), o = s(t?.institution_name), d = s(t?.account_name);
|
|
71
|
+
return {
|
|
72
|
+
balance: r,
|
|
73
|
+
limit: n,
|
|
74
|
+
utilization: Math.max(0, Math.round(r / n * 100)),
|
|
75
|
+
...i && { institutionGuid: i },
|
|
76
|
+
...o && { institutionName: o },
|
|
77
|
+
...d && { accountName: d }
|
|
78
|
+
};
|
|
79
|
+
}, v = /^(\d{4})-(\d{2})-\d{2}$/, h = (e, t) => {
|
|
80
|
+
const r = typeof e == "string" ? v.exec(e) : null, n = r ? Number(r[2]) : 0;
|
|
81
|
+
if (r && n >= 1 && n <= 12) return new Date(Number(r[1]), n - 1, 1);
|
|
82
|
+
const i = u(e, "date", t);
|
|
67
83
|
return i && new Date(i.getUTCFullYear(), i.getUTCMonth(), 1);
|
|
68
|
-
},
|
|
69
|
-
if (
|
|
70
|
-
const
|
|
71
|
-
if (
|
|
72
|
-
if (!Array.isArray(
|
|
73
|
-
|
|
84
|
+
}, y = (e) => {
|
|
85
|
+
if (e?.variant !== a.SUBSCRIPTION_LIST) return;
|
|
86
|
+
const t = e.drilldown_data, r = t?.transaction_frequencies;
|
|
87
|
+
if (r == null) return;
|
|
88
|
+
if (!Array.isArray(r)) {
|
|
89
|
+
c(t, "[TransactionListBlock] drilldown_data.transaction_frequencies is not a list — captioning no rows.");
|
|
74
90
|
return;
|
|
75
91
|
}
|
|
76
92
|
const n = /* @__PURE__ */ new Map();
|
|
77
93
|
let i = 0;
|
|
78
|
-
return
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
}), i > 0 &&
|
|
82
|
-
},
|
|
83
|
-
if (
|
|
84
|
-
const
|
|
85
|
-
if (!
|
|
86
|
-
const
|
|
87
|
-
if (
|
|
88
|
-
Object.keys(
|
|
94
|
+
return r.forEach((o) => {
|
|
95
|
+
const d = typeof o == "object" && o !== null ? s(o.transaction_guid) : void 0, l = typeof o == "object" && o !== null ? _(o.recurrence_type) : void 0;
|
|
96
|
+
d && l !== void 0 ? n.set(d, l) : i += 1;
|
|
97
|
+
}), i > 0 && c(t, `[TransactionListBlock] dropped ${i} malformed drilldown_data.transaction_frequencies row(s).`), n.size > 0 ? n : void 0;
|
|
98
|
+
}, C = (e) => {
|
|
99
|
+
if (e?.variant !== a.SUBSCRIPTION_LIST) return;
|
|
100
|
+
const t = e.drilldown_data;
|
|
101
|
+
if (!t) return;
|
|
102
|
+
const r = f(t.count);
|
|
103
|
+
if (r === void 0) {
|
|
104
|
+
Object.keys(t).length > 0 && c(t, "[TransactionListBlock] drilldown_data has no positive integer `count` — no subscription header.");
|
|
89
105
|
return;
|
|
90
106
|
}
|
|
91
107
|
return {
|
|
92
|
-
count:
|
|
93
|
-
month:
|
|
108
|
+
count: r,
|
|
109
|
+
month: h(t.date, t)
|
|
94
110
|
};
|
|
95
111
|
};
|
|
96
112
|
export {
|
|
97
113
|
b as ACCOUNT_SUBLINE_VARIANTS,
|
|
98
|
-
|
|
114
|
+
E as HELP_HEADER_VARIANT,
|
|
99
115
|
a as TRANSACTION_LIST_VARIANTS,
|
|
100
|
-
|
|
116
|
+
D as getTransactionListDrawerTitle,
|
|
117
|
+
w as readCreditLimitHeader,
|
|
101
118
|
H as readHelpHeader,
|
|
102
|
-
|
|
119
|
+
C as readSubscriptionHeader,
|
|
103
120
|
L as readSummary,
|
|
104
|
-
|
|
121
|
+
y as readTransactionFrequencies
|
|
105
122
|
};
|
|
106
123
|
|
|
107
124
|
//# sourceMappingURL=layout.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionListBlock/layout.ts"],"sourcesContent":["import { parseISO } from 'date-fns/parseISO'\n\nimport type {\n Beat,\n DrilldownData,\n GlobalCopy,\n InDescriptionCTA,\n PrimaryCTA,\n SecondaryCTA,\n} from '../../../core'\nimport { asNonEmptyText, asNumber } from '../../blocks/slotReaders'\nimport { readHelp, type HelpContent } from '../HelpBlock/layout'\n\ntype DrilldownCta = PrimaryCTA | SecondaryCTA | InDescriptionCTA\n\n/** The transaction_list_block CTA variants. */\nexport const TRANSACTION_LIST_VARIANTS = {\n SUMMARY_HEADER: 'summary_header',\n GENERIC_LIST: 'generic_list',\n /** Opens the list under the beat's title, description and \"Learn More\". */\n HELP_HEADER: 'help_header',\n /** Opens Micro Deposits' Deposit History list. */\n DEPOSIT_HISTORY: 'deposit_history',\n /** Opens Monthly Subscription Aggregate's Subscriptions list under a count tile and a tip. */\n SUBSCRIPTION_LIST: 'subscription_list',\n} as const\n\n/** Variants whose rows are subtitled with the account (institution logo and name), not the category. */\nexport const ACCOUNT_SUBLINE_VARIANTS: ReadonlySet<string | null | undefined> = new Set([\n TRANSACTION_LIST_VARIANTS.SUMMARY_HEADER,\n TRANSACTION_LIST_VARIANTS.SUBSCRIPTION_LIST,\n])\n\nexport const HELP_HEADER_VARIANT = TRANSACTION_LIST_VARIANTS.HELP_HEADER\n\n/** Drawer title: the variant's title when it has one, otherwise the beat's own title. Add new variants here. */\nexport const getTransactionListDrawerTitle = (\n variant: string | null | undefined,\n copy: GlobalCopy,\n beat?: Beat,\n): string => {\n switch (variant) {\n case TRANSACTION_LIST_VARIANTS.GENERIC_LIST:\n case TRANSACTION_LIST_VARIANTS.HELP_HEADER:\n return copy.transactions?.transactions_title ?? ''\n case TRANSACTION_LIST_VARIANTS.DEPOSIT_HISTORY:\n return copy.insights_feed?.transaction_list_block?.deposit_history_drawer_title ?? ''\n case TRANSACTION_LIST_VARIANTS.SUBSCRIPTION_LIST:\n return copy.insights_feed?.transaction_list_block?.subscriptions_drawer_title ?? ''\n default:\n return beat?.insights_payload?.title ?? ''\n }\n}\n\nexport interface HelpHeaderContent {\n /** Pre-localized HTML under the title, from the payload's `drilldown_data.description_html`. */\n descriptionHtml?: string\n /** The \"Learn More\" link and the help drawer it opens; absent when the beat carries no help. */\n learnMore?: HelpContent & { label: string }\n}\n\n/**\n * The help-header variant's text, read from the payload's `drilldown_data` (shared by every CTA\n * of the card): `description_html`, and `help_label` with the `help_title` / `help_html` that\n * `readHelp` reads. Only the `help_header` variant renders the block.\n */\nexport const readHelpHeader = (\n cta: DrilldownCta | undefined,\n drilldown: DrilldownData | undefined,\n): HelpHeaderContent | undefined => {\n if (cta?.variant !== HELP_HEADER_VARIANT) return undefined\n\n const label = asNonEmptyText(drilldown?.help_label)\n const help = readHelp(drilldown)\n\n return {\n descriptionHtml: asNonEmptyText(drilldown?.description_html),\n ...(label && help && { learnMore: { ...help, label } }),\n }\n}\n\nexport interface TransactionListSummary {\n /** Headline figure (e.g. total withdrawn). */\n amount: number\n /** Validated range endpoints; rendered as `{start} – {end}`. Omitted when the payload value is\n * missing or unparseable (so the drawer never crashes on an Invalid Date). */\n startDate?: Date\n endDate?: Date\n /** Number of transactions for the pill, from the CTA's `drilldown_data.count`. */\n count?: number\n}\n\n// `> 0`: the card only shows with >= 1 guid, so a `count` of 0 is dropped and falls back to the\n// guid count rather than rendering \"0 transactions\".\nconst toCount = (value: unknown): number | undefined =>\n typeof value === 'number' && Number.isInteger(value) && value > 0 ? value : undefined\n\n// Sane epoch window so a bad/typo payload can't render a far-past/future date.\nconst EPOCH_MIN = Date.UTC(2000, 0, 1)\nconst EPOCH_MAX = Date.UTC(2100, 0, 1)\n\n// The readers run on every observer re-render, so each distinct warning fires once per payload object.\nconst warnedPayloads = new WeakMap<object, Set<string>>()\nconst warnOncePerPayload = (source: object, message: string): void => {\n const warned = warnedPayloads.get(source) ?? new Set<string>()\n if (warned.has(message)) return\n warnedPayloads.set(source, warned.add(message))\n console.warn(message)\n}\n\n/**\n * Parse a payload date value to a validated `Date`, or `undefined`. Accepts unix seconds or\n * milliseconds (auto-detected) and ISO strings. Fails closed (no throw): an unparseable or\n * out-of-range value returns undefined and warns, so `formatDate`/`intlFormat` never sees an Invalid\n * Date (which throws `RangeError` and takes down the whole drawer render).\n */\nconst toDate = (value: unknown, field: string, source: object): Date | undefined => {\n // Missing/empty is a normal \"no range\" case — return quietly, don't warn.\n if (value === undefined || value === null || value === '') return undefined\n\n let ms: number | undefined\n if (typeof value === 'number' && Number.isFinite(value)) {\n // < 1e12 is treated as seconds (1e12 ms is year 33658). Trade-off: genuine ms timestamps from\n // ~2000-2001 would be misread as seconds and fall outside the window below (dropped, not shown).\n ms = value < 1e12 ? value * 1000 : value\n } else if (typeof value === 'string') {\n const parsed = parseISO(value).getTime()\n ms = Number.isNaN(parsed) ? undefined : parsed\n }\n\n if (ms === undefined || ms < EPOCH_MIN || ms > EPOCH_MAX) {\n warnOncePerPayload(\n source,\n `[TransactionListBlock] drilldown_data.${field} is unparseable or out of range (${typeof value})`,\n )\n return undefined\n }\n return new Date(ms)\n}\n\n/**\n * Summary-header figures for the drawer, read from the clicked CTA's `drilldown_data` (the backend\n * hangs a drilldown's own data off the CTA that opens it). Fails closed throughout: only the\n * `summary_header` variant renders a header (so figures from a different CTA that `getDynamicCta…`\n * fell back to can't be misattributed), then without a finite `amount` there is still no header, and\n * each date is validated to a real `Date` or dropped — an unparseable value never reaches\n * `formatDate` (which throws on an Invalid Date).\n *\n * `drilldown_data` fields: `amount` (number), `start_date`/`end_date` (unix seconds|ms or ISO),\n * `count` (number of transactions).\n */\nexport const readSummary = (cta: DrilldownCta | undefined): TransactionListSummary | undefined => {\n // Defense-in-depth on financial figures: only the summary-header variant shows the card.\n if (cta?.variant !== TRANSACTION_LIST_VARIANTS.SUMMARY_HEADER) return undefined\n\n const source = cta?.drilldown_data\n if (!source) return undefined\n\n const amount = asNumber(source.amount)\n if (amount === undefined) {\n // `drilldown_data` present but no usable amount -> surface the likely contract drift (field\n // rename) instead of a silently missing header.\n if (Object.keys(source).length > 0) {\n warnOncePerPayload(\n source,\n '[TransactionListBlock] drilldown_data has no finite `amount` — no summary header.',\n )\n }\n return undefined\n }\n\n return {\n amount,\n startDate: toDate(source.start_date, 'start_date', source),\n endDate: toDate(source.end_date, 'end_date', source),\n count: toCount(source.count),\n }\n}\n\nconst DATE_ONLY = /^(\\d{4})-(\\d{2})-\\d{2}$/\n\n/** The month a drilldown date names, as local midnight on the 1st. A date-only string already names its month. */\nconst toMonthStart = (value: unknown, source: object): Date | undefined => {\n const dateOnly = typeof value === 'string' ? DATE_ONLY.exec(value) : null\n const month = dateOnly ? Number(dateOnly[2]) : 0\n if (dateOnly && month >= 1 && month <= 12) return new Date(Number(dateOnly[1]), month - 1, 1)\n\n // An epoch or a timestamp is an instant: its UTC month is the one tupac meant.\n const date = toDate(value, 'date', source)\n return date && new Date(date.getUTCFullYear(), date.getUTCMonth(), 1)\n}\n\n/** Each listed transaction's schedule, from `drilldown_data.transaction_frequencies`; malformed rows are dropped. */\nexport const readTransactionFrequencies = (\n cta: DrilldownCta | undefined,\n): Map<string, number> | undefined => {\n if (cta?.variant !== TRANSACTION_LIST_VARIANTS.SUBSCRIPTION_LIST) return undefined\n\n const source = cta.drilldown_data\n const rows = source?.transaction_frequencies\n if (rows === undefined || rows === null) return undefined\n\n if (!Array.isArray(rows)) {\n warnOncePerPayload(\n source as object,\n '[TransactionListBlock] drilldown_data.transaction_frequencies is not a list — captioning no rows.',\n )\n return undefined\n }\n\n const byGuid = new Map<string, number>()\n let dropped = 0\n rows.forEach((row) => {\n const guid =\n typeof row === 'object' && row !== null ? asNonEmptyText(row.transaction_guid) : undefined\n const type = typeof row === 'object' && row !== null ? asNumber(row.recurrence_type) : undefined\n\n if (guid && type !== undefined) byGuid.set(guid, type)\n else dropped += 1\n })\n\n if (dropped > 0) {\n warnOncePerPayload(\n source as object,\n `[TransactionListBlock] dropped ${dropped} malformed drilldown_data.transaction_frequencies row(s).`,\n )\n }\n\n return byGuid.size > 0 ? byGuid : undefined\n}\n\nexport interface SubscriptionListHeader {\n /** Subscriptions paid in the month, from the CTA's `drilldown_data.count`. */\n count: number\n /** The month paid in, as local midnight on the 1st; omitted when missing or unparseable. */\n month?: Date\n}\n\n/** The count tile's figures; only for `subscription_list` with a positive integer `count`. */\nexport const readSubscriptionHeader = (\n cta: DrilldownCta | undefined,\n): SubscriptionListHeader | undefined => {\n if (cta?.variant !== TRANSACTION_LIST_VARIANTS.SUBSCRIPTION_LIST) return undefined\n\n const source = cta.drilldown_data\n if (!source) return undefined\n\n const count = toCount(source.count)\n if (count === undefined) {\n if (Object.keys(source).length > 0) {\n warnOncePerPayload(\n source,\n '[TransactionListBlock] drilldown_data has no positive integer `count` — no subscription header.',\n )\n }\n return undefined\n }\n\n return {\n count,\n month: toMonthStart(source.date, source),\n }\n}\n"],"mappings":";;;AAgBA,IAAa,IAA4B;AAAA,EACvC,gBAAgB;AAAA,EAChB,cAAc;AAAA,EAEd,aAAa;AAAA,EAEb,iBAAiB;AAAA,EAEjB,mBAAmB;AACrB,GAGa,IAAmE,oBAAI,IAAI,CACtF,EAA0B,gBAC1B,EAA0B,iBAC5B,CAAC,GAEY,IAAsB,EAA0B,aAGhD,IAAA,CACX,GACA,GACA,MACW;AACX,UAAQ,GAAR;AAAA,IACE,KAAK,EAA0B;AAAA,IAC/B,KAAK,EAA0B;AAC7B,aAAO,EAAK,cAAc,sBAAsB;AAAA,IAClD,KAAK,EAA0B;AAC7B,aAAO,EAAK,eAAe,wBAAwB,gCAAgC;AAAA,IACrF,KAAK,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Q,OAAO,EAAe,EAAI,gBAAgB,IAAI,QAC7E,IAAO,OAAO,KAAQ,YAAY,MAAQ,OAAO,EAAS,EAAI,eAAe,IAAI;AAEvF,IAAI,KAAQ,MAAS,SAAW,EAAO,IAAI,GAAM,CAAI,IAChD,KAAW;AAAA,EAClB,CAAC,GAEG,IAAU,KACZ,EACE,GACA,kCAAkC,CAAA,2DACpC,GAGK,EAAO,OAAO,IAAI,IAAS;AACpC,GAUa,IAAA,CACX,MACuC;AACvC,MAAI,GAAK,YAAY,EAA0B,kBAAmB;AAElE,QAAM,IAAS,EAAI;AACnB,MAAI,CAAC,EAAQ;AAEb,QAAM,IAAQ,EAAQ,EAAO,KAAK;AAClC,MAAI,MAAU,QAAW;AACvB,IAAI,OAAO,KAAK,CAAM,EAAE,SAAS,KAC/B,EACE,GACA,iGACF;AAEF;AAAA,EACF;AAEA,SAAO;AAAA,IACL,OAAA;AAAA,IACA,OAAO,EAAa,EAAO,MAAM,CAAM;AAAA,EACzC;AACF"}
|
|
1
|
+
{"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionListBlock/layout.ts"],"sourcesContent":["import { parseISO } from 'date-fns/parseISO'\n\nimport type {\n Beat,\n DrilldownData,\n GlobalCopy,\n InDescriptionCTA,\n PrimaryCTA,\n SecondaryCTA,\n} from '../../../core'\nimport { asNonEmptyText, asNumber } from '../../blocks/slotReaders'\nimport { readHelp, type HelpContent } from '../HelpBlock/layout'\n\ntype DrilldownCta = PrimaryCTA | SecondaryCTA | InDescriptionCTA\n\n/** The transaction_list_block CTA variants. */\nexport const TRANSACTION_LIST_VARIANTS = {\n SUMMARY_HEADER: 'summary_header',\n GENERIC_LIST: 'generic_list',\n /** Opens the list under the beat's title, description and \"Learn More\". */\n HELP_HEADER: 'help_header',\n /** Opens Micro Deposits' Deposit History list. */\n DEPOSIT_HISTORY: 'deposit_history',\n /** Opens Credit Card Close to Limit's Spending list under the card's credit-limit header. */\n CREDIT_LIMIT_HEADER: 'credit_limit_header',\n /** Opens Monthly Subscription Aggregate's Subscriptions list under a count tile and a tip. */\n SUBSCRIPTION_LIST: 'subscription_list',\n} as const\n\n/** Variants whose rows are subtitled with the account (institution logo and name), not the category. */\nexport const ACCOUNT_SUBLINE_VARIANTS: ReadonlySet<string | null | undefined> = new Set([\n TRANSACTION_LIST_VARIANTS.SUMMARY_HEADER,\n TRANSACTION_LIST_VARIANTS.SUBSCRIPTION_LIST,\n])\n\nexport const HELP_HEADER_VARIANT = TRANSACTION_LIST_VARIANTS.HELP_HEADER\n\n/** Drawer title: the variant's title when it has one, otherwise the beat's own title. Add new variants here. */\nexport const getTransactionListDrawerTitle = (\n variant: string | null | undefined,\n copy: GlobalCopy,\n beat?: Beat,\n): string => {\n switch (variant) {\n case TRANSACTION_LIST_VARIANTS.GENERIC_LIST:\n case TRANSACTION_LIST_VARIANTS.HELP_HEADER:\n return copy.transactions?.transactions_title ?? ''\n case TRANSACTION_LIST_VARIANTS.DEPOSIT_HISTORY:\n return copy.insights_feed?.transaction_list_block?.deposit_history_drawer_title ?? ''\n case TRANSACTION_LIST_VARIANTS.CREDIT_LIMIT_HEADER:\n return copy.insights_feed?.transaction_list_block?.credit_limit_header_drawer_title ?? ''\n case TRANSACTION_LIST_VARIANTS.SUBSCRIPTION_LIST:\n return copy.insights_feed?.transaction_list_block?.subscriptions_drawer_title ?? ''\n default:\n return beat?.insights_payload?.title ?? ''\n }\n}\n\nexport interface HelpHeaderContent {\n /** Pre-localized HTML under the title, from the payload's `drilldown_data.description_html`. */\n descriptionHtml?: string\n /** The \"Learn More\" link and the help drawer it opens; absent when the beat carries no help. */\n learnMore?: HelpContent & { label: string }\n}\n\n/**\n * The help-header variant's text, read from the payload's `drilldown_data` (shared by every CTA\n * of the card): `description_html`, and `help_label` with the `help_title` / `help_html` that\n * `readHelp` reads. Only the `help_header` variant renders the block.\n */\nexport const readHelpHeader = (\n cta: DrilldownCta | undefined,\n drilldown: DrilldownData | undefined,\n): HelpHeaderContent | undefined => {\n if (cta?.variant !== HELP_HEADER_VARIANT) return undefined\n\n const label = asNonEmptyText(drilldown?.help_label)\n const help = readHelp(drilldown)\n\n return {\n descriptionHtml: asNonEmptyText(drilldown?.description_html),\n ...(label && help && { learnMore: { ...help, label } }),\n }\n}\n\nexport interface TransactionListSummary {\n /** Headline figure (e.g. total withdrawn). */\n amount: number\n /** Validated range endpoints; rendered as `{start} – {end}`. Omitted when the payload value is\n * missing or unparseable (so the drawer never crashes on an Invalid Date). */\n startDate?: Date\n endDate?: Date\n /** Number of transactions for the pill, from the CTA's `drilldown_data.count`. */\n count?: number\n}\n\n// `> 0`: the card only shows with >= 1 guid, so a `count` of 0 is dropped and falls back to the\n// guid count rather than rendering \"0 transactions\".\nconst toCount = (value: unknown): number | undefined =>\n typeof value === 'number' && Number.isInteger(value) && value > 0 ? value : undefined\n\n// Sane epoch window so a bad/typo payload can't render a far-past/future date.\nconst EPOCH_MIN = Date.UTC(2000, 0, 1)\nconst EPOCH_MAX = Date.UTC(2100, 0, 1)\n\n// The readers run on every observer re-render, so each distinct warning fires once per payload object.\nconst warnedPayloads = new WeakMap<object, Set<string>>()\nconst warnOncePerPayload = (source: object, message: string): void => {\n const warned = warnedPayloads.get(source) ?? new Set<string>()\n if (warned.has(message)) return\n warnedPayloads.set(source, warned.add(message))\n console.warn(message)\n}\n\n/**\n * Parse a payload date value to a validated `Date`, or `undefined`. Accepts unix seconds or\n * milliseconds (auto-detected) and ISO strings. Fails closed (no throw): an unparseable or\n * out-of-range value returns undefined and warns, so `formatDate`/`intlFormat` never sees an Invalid\n * Date (which throws `RangeError` and takes down the whole drawer render).\n */\nconst toDate = (value: unknown, field: string, source: object): Date | undefined => {\n // Missing/empty is a normal \"no range\" case — return quietly, don't warn.\n if (value === undefined || value === null || value === '') return undefined\n\n let ms: number | undefined\n if (typeof value === 'number' && Number.isFinite(value)) {\n // < 1e12 is treated as seconds (1e12 ms is year 33658). Trade-off: genuine ms timestamps from\n // ~2000-2001 would be misread as seconds and fall outside the window below (dropped, not shown).\n ms = value < 1e12 ? value * 1000 : value\n } else if (typeof value === 'string') {\n const parsed = parseISO(value).getTime()\n ms = Number.isNaN(parsed) ? undefined : parsed\n }\n\n if (ms === undefined || ms < EPOCH_MIN || ms > EPOCH_MAX) {\n warnOncePerPayload(\n source,\n `[TransactionListBlock] drilldown_data.${field} is unparseable or out of range (${typeof value})`,\n )\n return undefined\n }\n return new Date(ms)\n}\n\n/**\n * Summary-header figures for the drawer, read from the clicked CTA's `drilldown_data` (the backend\n * hangs a drilldown's own data off the CTA that opens it). Fails closed throughout: only the\n * `summary_header` variant renders a header (so figures from a different CTA that `getDynamicCta…`\n * fell back to can't be misattributed), then without a finite `amount` there is still no header, and\n * each date is validated to a real `Date` or dropped — an unparseable value never reaches\n * `formatDate` (which throws on an Invalid Date).\n *\n * `drilldown_data` fields: `amount` (number), `start_date`/`end_date` (unix seconds|ms or ISO),\n * `count` (number of transactions).\n */\nexport const readSummary = (cta: DrilldownCta | undefined): TransactionListSummary | undefined => {\n // Defense-in-depth on financial figures: only the summary-header variant shows the card.\n if (cta?.variant !== TRANSACTION_LIST_VARIANTS.SUMMARY_HEADER) return undefined\n\n const source = cta?.drilldown_data\n if (!source) return undefined\n\n const amount = asNumber(source.amount)\n if (amount === undefined) {\n // `drilldown_data` present but no usable amount -> surface the likely contract drift (field\n // rename) instead of a silently missing header.\n if (Object.keys(source).length > 0) {\n warnOncePerPayload(\n source,\n '[TransactionListBlock] drilldown_data has no finite `amount` — no summary header.',\n )\n }\n return undefined\n }\n\n return {\n amount,\n startDate: toDate(source.start_date, 'start_date', source),\n endDate: toDate(source.end_date, 'end_date', source),\n count: toCount(source.count),\n }\n}\n\nexport interface CreditLimitHeader {\n balance: number\n limit: number\n /** Whole percent of the limit used; over 100 when the card is over its limit. */\n utilization: number\n institutionGuid?: string\n institutionName?: string\n accountName?: string\n}\n\n/** The credit-limit header from the clicked CTA's `drilldown_data`; only `credit_limit_header`, with a positive limit. */\nexport const readCreditLimitHeader = (\n cta: DrilldownCta | undefined,\n): CreditLimitHeader | undefined => {\n if (cta?.variant !== TRANSACTION_LIST_VARIANTS.CREDIT_LIMIT_HEADER) return undefined\n\n const source = cta.drilldown_data\n const balance = asNumber(source?.current_balance)\n const limit = asNumber(source?.credit_limit)\n if (balance === undefined || limit === undefined || limit <= 0) return undefined\n\n const institutionGuid = asNonEmptyText(source?.institution_guid)\n const institutionName = asNonEmptyText(source?.institution_name)\n const accountName = asNonEmptyText(source?.account_name)\n\n return {\n balance,\n limit,\n utilization: Math.max(0, Math.round((balance / limit) * 100)),\n ...(institutionGuid && { institutionGuid }),\n ...(institutionName && { institutionName }),\n ...(accountName && { accountName }),\n }\n}\n\nconst DATE_ONLY = /^(\\d{4})-(\\d{2})-\\d{2}$/\n\n/** The month a drilldown date names, as local midnight on the 1st. A date-only string already names its month. */\nconst toMonthStart = (value: unknown, source: object): Date | undefined => {\n const dateOnly = typeof value === 'string' ? DATE_ONLY.exec(value) : null\n const month = dateOnly ? Number(dateOnly[2]) : 0\n if (dateOnly && month >= 1 && month <= 12) return new Date(Number(dateOnly[1]), month - 1, 1)\n\n // An epoch or a timestamp is an instant: its UTC month is the one tupac meant.\n const date = toDate(value, 'date', source)\n return date && new Date(date.getUTCFullYear(), date.getUTCMonth(), 1)\n}\n\n/** Each listed transaction's schedule, from `drilldown_data.transaction_frequencies`; malformed rows are dropped. */\nexport const readTransactionFrequencies = (\n cta: DrilldownCta | undefined,\n): Map<string, number> | undefined => {\n if (cta?.variant !== TRANSACTION_LIST_VARIANTS.SUBSCRIPTION_LIST) return undefined\n\n const source = cta.drilldown_data\n const rows = source?.transaction_frequencies\n if (rows === undefined || rows === null) return undefined\n\n if (!Array.isArray(rows)) {\n warnOncePerPayload(\n source as object,\n '[TransactionListBlock] drilldown_data.transaction_frequencies is not a list — captioning no rows.',\n )\n return undefined\n }\n\n const byGuid = new Map<string, number>()\n let dropped = 0\n rows.forEach((row) => {\n const guid =\n typeof row === 'object' && row !== null ? asNonEmptyText(row.transaction_guid) : undefined\n const type = typeof row === 'object' && row !== null ? asNumber(row.recurrence_type) : undefined\n\n if (guid && type !== undefined) byGuid.set(guid, type)\n else dropped += 1\n })\n\n if (dropped > 0) {\n warnOncePerPayload(\n source as object,\n `[TransactionListBlock] dropped ${dropped} malformed drilldown_data.transaction_frequencies row(s).`,\n )\n }\n\n return byGuid.size > 0 ? byGuid : undefined\n}\n\nexport interface SubscriptionListHeader {\n /** Subscriptions paid in the month, from the CTA's `drilldown_data.count`. */\n count: number\n /** The month paid in, as local midnight on the 1st; omitted when missing or unparseable. */\n month?: Date\n}\n\n/** The count tile's figures; only for `subscription_list` with a positive integer `count`. */\nexport const readSubscriptionHeader = (\n cta: DrilldownCta | undefined,\n): SubscriptionListHeader | undefined => {\n if (cta?.variant !== TRANSACTION_LIST_VARIANTS.SUBSCRIPTION_LIST) return undefined\n\n const source = cta.drilldown_data\n if (!source) return undefined\n\n const count = toCount(source.count)\n if (count === undefined) {\n if (Object.keys(source).length > 0) {\n warnOncePerPayload(\n source,\n '[TransactionListBlock] drilldown_data has no positive integer `count` — no subscription header.',\n )\n }\n return undefined\n }\n\n return {\n count,\n month: toMonthStart(source.date, source),\n }\n}\n"],"mappings":";;;AAgBA,IAAa,IAA4B;AAAA,EACvC,gBAAgB;AAAA,EAChB,cAAc;AAAA,EAEd,aAAa;AAAA,EAEb,iBAAiB;AAAA,EAEjB,qBAAqB;AAAA,EAErB,mBAAmB;AACrB,GAGa,IAAmE,oBAAI,IAAI,CACtF,EAA0B,gBAC1B,EAA0B,iBAC5B,CAAC,GAEY,IAAsB,EAA0B,aAGhD,IAAA,CACX,GACA,GACA,MACW;AACX,UAAQ,GAAR;AAAA,IACE,KAAK,EAA0B;AAAA,IAC/B,KAAK,EAA0B;AAC7B,aAAO,EAAK,cAAc,sBAAsB;AAAA,IAClD,KAAK,EAA0B;AAC7B,aAAO,EAAK,eAAe,wBAAwB,gCAAgC;AAAA,IACrF,KA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AAa,EAAO,MAAM,CAAM;AAAA,EACzC;AACF"}
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
import { CURRENCY_FORMAT as e } from "../../../../core/utils/NumberFormatting.es.js";
|
|
2
|
+
import f from "./DonutChart.es.js";
|
|
3
|
+
import { getDonutSegments as b } from "./utils.es.js";
|
|
2
4
|
import { formatValueByType as r } from "../../../CommonUtils.es.js";
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var T = ({ payload: i }) => {
|
|
8
|
-
const c = C(), { instance_slot: l, instance_slot_data: n } = i, { variant: m } = l, s = l.data, t = s?.main ? s : n ?? {}, _ = Array.isArray(t.legends) ? t.legends : [], { main: o } = t;
|
|
5
|
+
import { Fragment as h, jsx as i, jsxs as g } from "react/jsx-runtime";
|
|
6
|
+
import { useTheme as D } from "@mui/material/styles";
|
|
7
|
+
var k = ({ payload: m }) => {
|
|
8
|
+
const _ = D(), { instance_slot: l, instance_slot_data: n } = m, { variant: d } = l, s = l.data, t = s?.main ? s : n ?? {}, u = Array.isArray(t.legends) ? t.legends : [], { main: o } = t;
|
|
9
9
|
if (!o) return null;
|
|
10
|
-
const
|
|
10
|
+
const { colors: p, arcs: v } = b(d, {
|
|
11
11
|
...t,
|
|
12
12
|
category_guid: t.category_guid ?? n?.category_guid
|
|
13
|
-
},
|
|
14
|
-
value:
|
|
15
|
-
color:
|
|
13
|
+
}, u, _), y = u.map((a, c) => ({
|
|
14
|
+
value: v[c],
|
|
15
|
+
color: p[c],
|
|
16
16
|
label: a.label,
|
|
17
|
-
labelValue: /* @__PURE__ */ h
|
|
17
|
+
labelValue: /* @__PURE__ */ g(h, { children: [/* @__PURE__ */ i("b", { children: r(a.value, a.value_type ?? "amount", e.cents) }), a.additional_value && a.additional_value_type ? ` (${r(a.additional_value, a.additional_value_type, e.cents)})` : null] })
|
|
18
18
|
}));
|
|
19
|
-
return /* @__PURE__ */
|
|
19
|
+
return /* @__PURE__ */ i(f, {
|
|
20
20
|
centerLabel: o.label,
|
|
21
21
|
centerValue: r(Number(o.value), o.value_type, e.whole),
|
|
22
|
-
data:
|
|
22
|
+
data: y
|
|
23
23
|
});
|
|
24
24
|
};
|
|
25
25
|
export {
|
|
26
|
-
|
|
26
|
+
k as default
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
//# sourceMappingURL=DonutChartBlock.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DonutChartBlock.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ChartBlocks/DonutChartBlock/DonutChartBlock.tsx"],"sourcesContent":["import { useTheme } from '@mui/material/styles'\n\nimport type { DonutChartBlockData } from '../../../../core/types/InsightsInstanceSlotData'\nimport { CURRENCY_FORMAT } from '../../../../core/utils/NumberFormatting'\n\nimport { formatValueByType } from '../../../CommonUtils'\n\nimport type { BlockProps } from '../../types'\n\nimport DonutChartV2 from './DonutChart'\nimport {
|
|
1
|
+
{"version":3,"file":"DonutChartBlock.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ChartBlocks/DonutChartBlock/DonutChartBlock.tsx"],"sourcesContent":["import { useTheme } from '@mui/material/styles'\n\nimport type { DonutChartBlockData } from '../../../../core/types/InsightsInstanceSlotData'\nimport { CURRENCY_FORMAT } from '../../../../core/utils/NumberFormatting'\n\nimport { formatValueByType } from '../../../CommonUtils'\n\nimport type { BlockProps } from '../../types'\n\nimport DonutChartV2 from './DonutChart'\nimport { getDonutSegments } from './utils'\n\n/** `donut_chart_block`: a donut with a centre total and a two-row legend; V1 `instance_slot_data` is the fallback. */\nconst DonutChartBlock = ({ payload }: BlockProps<Partial<DonutChartBlockData>>) => {\n const theme = useTheme()\n const { instance_slot, instance_slot_data } = payload\n const { variant } = instance_slot\n // V2 contract first (`instance_slot.data`), V1 `instance_slot_data` as the legacy alias.\n const slotData = instance_slot.data as Partial<DonutChartBlockData> | undefined\n const blockData: Partial<DonutChartBlockData> = slotData?.main\n ? slotData\n : (instance_slot_data ?? {})\n const legends = Array.isArray(blockData.legends) ? blockData.legends : []\n const { main } = blockData\n\n if (!main) return null\n\n const { colors, arcs } = getDonutSegments(\n variant,\n { ...blockData, category_guid: blockData.category_guid ?? instance_slot_data?.category_guid },\n legends,\n theme,\n )\n\n const data = legends.map((legend, index) => ({\n value: arcs[index],\n color: colors[index],\n label: legend.label,\n labelValue: (\n <>\n <b>\n {formatValueByType(legend.value, legend.value_type ?? 'amount', CURRENCY_FORMAT.cents)}\n </b>\n {legend.additional_value && legend.additional_value_type\n ? ` (${formatValueByType(legend.additional_value, legend.additional_value_type, CURRENCY_FORMAT.cents)})`\n : null}\n </>\n ),\n }))\n\n return (\n <DonutChartV2\n centerLabel={main.label}\n centerValue={formatValueByType(Number(main.value), main.value_type, CURRENCY_FORMAT.whole)}\n data={data}\n />\n )\n}\n\nexport default DonutChartBlock\n"],"mappings":";;;;;;AAaA,IAAM,IAAA,CAAmB,EAAE,SAAA,EAAA,MAAwD;AACjF,QAAM,IAAQ,EAAS,GACjB,EAAE,eAAA,GAAe,oBAAA,EAAA,IAAuB,GACxC,EAAE,SAAA,EAAA,IAAY,GAEd,IAAW,EAAc,MACzB,IAA0C,GAAU,OACtD,IACC,KAAsB,CAAC,GACtB,IAAU,MAAM,QAAQ,EAAU,OAAO,IAAI,EAAU,UAAU,CAAC,GAClE,EAAE,MAAA,EAAA,IAAS;AAEjB,MAAI,CAAC,EAAM,QAAO;AAElB,QAAM,EAAE,QAAA,GAAQ,MAAA,EAAA,IAAS,EACvB,GACA;AAAA,IAAE,GAAG;AAAA,IAAW,eAAe,EAAU,iBAAiB,GAAoB;AAAA,EAAc,GAC5F,GACA,CACF,GAEM,IAAO,EAAQ,IAAA,CAAK,GAAQ,OAAW;AAAA,IAC3C,OAAO,EAAK,CAAA;AAAA,IACZ,OAAO,EAAO,CAAA;AAAA,IACd,OAAO,EAAO;AAAA,IACd,YACE,gBAAA,EAAA,GAAA,EAAA,UAAA,CACE,gBAAA,EAAC,KAAD,EAAA,UACG,EAAkB,EAAO,OAAO,EAAO,cAAc,UAAU,EAAgB,KAAK,EACpF,CAAA,GACF,EAAO,oBAAoB,EAAO,wBAC/B,KAAK,EAAkB,EAAO,kBAAkB,EAAO,uBAAuB,EAAgB,KAAK,CAAA,MACnG,IACJ,EAAA,CAAA;AAAA,EAEN,EAAE;AAEF,SACE,gBAAA,EAAC,GAAD;AAAA,IACE,aAAa,EAAK;AAAA,IAClB,aAAa,EAAkB,OAAO,EAAK,KAAK,GAAG,EAAK,YAAY,EAAgB,KAAK;AAAA,IACnF,MAAA;AAAA,EACP,CAAA;AAEL"}
|
|
@@ -2,14 +2,21 @@ import { Theme } from '@mui/material/styles';
|
|
|
2
2
|
/** Ditto's `donut_chart_block` variants; the template-name keys below are V1 aliases. */
|
|
3
3
|
export declare const donutChartVariant: {
|
|
4
4
|
readonly DepositSummary: "deposit_summary";
|
|
5
|
+
/** Credit Card Close to Limit; the embedded card's small donut reuses it. */
|
|
6
|
+
readonly CreditLimit: "credit_limit";
|
|
5
7
|
};
|
|
6
8
|
export type DonutChartVariant = (typeof donutChartVariant)[keyof typeof donutChartVariant];
|
|
7
|
-
|
|
9
|
+
/** `remainderOfTotal`: the second arc is what is left of the second legend value after the first. */
|
|
10
|
+
type DonutArcs = {
|
|
11
|
+
arcs?: 'remainderOfTotal';
|
|
12
|
+
};
|
|
13
|
+
export type DonutChartLayoutConfig = DonutArcs & ({
|
|
8
14
|
colors: [string, string];
|
|
9
15
|
} | {
|
|
10
16
|
secondaryColor: string;
|
|
11
17
|
} | {
|
|
12
18
|
dynamicPrimary: 'creditUtilization';
|
|
13
19
|
secondaryColor: string;
|
|
14
|
-
};
|
|
20
|
+
});
|
|
15
21
|
export declare const getLayoutConfig: (theme: Theme) => Record<string, DonutChartLayoutConfig>;
|
|
22
|
+
export {};
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
1
|
+
var r = {
|
|
2
|
+
DepositSummary: "deposit_summary",
|
|
3
|
+
CreditLimit: "credit_limit"
|
|
4
|
+
}, a = (t) => {
|
|
5
|
+
const i = { colors: [t.palette.success.main, t.palette.success.light] }, o = [t.palette.warning.main, t.palette.divider];
|
|
3
6
|
return {
|
|
4
|
-
[
|
|
7
|
+
[r.DepositSummary]: i,
|
|
8
|
+
[r.CreditLimit]: {
|
|
9
|
+
colors: o,
|
|
10
|
+
arcs: "remainderOfTotal"
|
|
11
|
+
},
|
|
5
12
|
CostOfLivingToIncome: { secondaryColor: t.palette.divider },
|
|
6
|
-
MonthlyDepositSummaryV2:
|
|
13
|
+
MonthlyDepositSummaryV2: i,
|
|
7
14
|
MonthlyNonEssentialCategorySummaryV2: { colors: [t.palette.chartMono.chartMono3 ?? t.palette.text.primary, t.palette.chartMono.chartMono5 ?? t.palette.divider] },
|
|
8
|
-
CreditCardCloseToLimit: { colors:
|
|
15
|
+
CreditCardCloseToLimit: { colors: o },
|
|
9
16
|
CreditUtilization: {
|
|
10
17
|
dynamicPrimary: "creditUtilization",
|
|
11
18
|
secondaryColor: t.palette.divider
|
|
@@ -13,8 +20,8 @@ var a = { DepositSummary: "deposit_summary" }, r = (t) => {
|
|
|
13
20
|
};
|
|
14
21
|
};
|
|
15
22
|
export {
|
|
16
|
-
|
|
17
|
-
|
|
23
|
+
r as donutChartVariant,
|
|
24
|
+
a as getLayoutConfig
|
|
18
25
|
};
|
|
19
26
|
|
|
20
27
|
//# sourceMappingURL=layout.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ChartBlocks/DonutChartBlock/layout.ts"],"sourcesContent":["import { type Theme } from '@mui/material/styles'\n\n/** Ditto's `donut_chart_block` variants; the template-name keys below are V1 aliases. */\nexport const donutChartVariant = {\n DepositSummary: 'deposit_summary',\n} as const\n\nexport type DonutChartVariant = (typeof donutChartVariant)[keyof typeof donutChartVariant]\n\nexport type DonutChartLayoutConfig
|
|
1
|
+
{"version":3,"file":"layout.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ChartBlocks/DonutChartBlock/layout.ts"],"sourcesContent":["import { type Theme } from '@mui/material/styles'\n\n/** Ditto's `donut_chart_block` variants; the template-name keys below are V1 aliases. */\nexport const donutChartVariant = {\n DepositSummary: 'deposit_summary',\n /** Credit Card Close to Limit; the embedded card's small donut reuses it. */\n CreditLimit: 'credit_limit',\n} as const\n\nexport type DonutChartVariant = (typeof donutChartVariant)[keyof typeof donutChartVariant]\n\n/** `remainderOfTotal`: the second arc is what is left of the second legend value after the first. */\ntype DonutArcs = { arcs?: 'remainderOfTotal' }\n\nexport type DonutChartLayoutConfig = DonutArcs &\n (\n | { colors: [string, string] }\n | { secondaryColor: string }\n | { dynamicPrimary: 'creditUtilization'; secondaryColor: string }\n )\n\nexport const getLayoutConfig = (theme: Theme): Record<string, DonutChartLayoutConfig> => {\n const depositSummary: DonutChartLayoutConfig = {\n colors: [theme.palette.success.main, theme.palette.success.light],\n }\n\n const creditLimitColors: [string, string] = [theme.palette.warning.main, theme.palette.divider]\n\n return {\n [donutChartVariant.DepositSummary]: depositSummary,\n // Spending and the rest of the limit, while the legend shows the full limit (pulse Chart.js).\n [donutChartVariant.CreditLimit]: { colors: creditLimitColors, arcs: 'remainderOfTotal' },\n\n // V1 aliases: the template name as the variant.\n CostOfLivingToIncome: {\n secondaryColor: theme.palette.divider,\n },\n MonthlyDepositSummaryV2: depositSummary,\n MonthlyNonEssentialCategorySummaryV2: {\n colors: [\n theme.palette.chartMono.chartMono3 ?? theme.palette.text.primary,\n theme.palette.chartMono.chartMono5 ?? theme.palette.divider,\n ],\n },\n CreditCardCloseToLimit: { colors: creditLimitColors },\n CreditUtilization: {\n dynamicPrimary: 'creditUtilization',\n secondaryColor: theme.palette.divider,\n },\n }\n}\n"],"mappings":"AAGA,IAAa,IAAoB;AAAA,EAC/B,gBAAgB;AAAA,EAEhB,aAAa;AACf,GAca,IAAA,CAAmB,MAAyD;AACvF,QAAM,IAAyC,EAC7C,QAAQ,CAAC,EAAM,QAAQ,QAAQ,MAAM,EAAM,QAAQ,QAAQ,KAAK,EAClE,GAEM,IAAsC,CAAC,EAAM,QAAQ,QAAQ,MAAM,EAAM,QAAQ,OAAO;AAE9F,SAAO;AAAA,IACJ,CAAA,EAAkB,cAAA,GAAiB;AAAA,IAEnC,CAAA,EAAkB,WAAA,GAAc;AAAA,MAAE,QAAQ;AAAA,MAAmB,MAAM;AAAA,IAAmB;AAAA,IAGvF,sBAAsB,EACpB,gBAAgB,EAAM,QAAQ,QAChC;AAAA,IACA,yBAAyB;AAAA,IACzB,sCAAsC,EACpC,QAAQ,CACN,EAAM,QAAQ,UAAU,cAAc,EAAM,QAAQ,KAAK,SACzD,EAAM,QAAQ,UAAU,cAAc,EAAM,QAAQ,OACtD,EACF;AAAA,IACA,wBAAwB,EAAE,QAAQ,EAAkB;AAAA,IACpD,mBAAmB;AAAA,MACjB,gBAAgB;AAAA,MAChB,gBAAgB,EAAM,QAAQ;AAAA,IAChC;AAAA,EACF;AACF"}
|
|
@@ -4,4 +4,10 @@ import { DonutChartBlockData } from '../../../../core/types/InsightsInstanceSlot
|
|
|
4
4
|
export type DonutColorData = Partial<DonutChartBlockData> & {
|
|
5
5
|
category_guid?: string;
|
|
6
6
|
};
|
|
7
|
-
|
|
7
|
+
/** The variant's palette and arcs, from one lookup so an unknown variant warns once. */
|
|
8
|
+
export declare const getDonutSegments: (variant: string | null | undefined, blockData: DonutColorData, legends: {
|
|
9
|
+
value: number;
|
|
10
|
+
}[], theme: Theme) => {
|
|
11
|
+
colors: [string, string];
|
|
12
|
+
arcs: number[];
|
|
13
|
+
};
|