@mx-cartographer/experiences 9.7.0 → 9.7.2
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 +11 -0
- package/dist/core/types/InsightsInstanceSlotData.d.ts +6 -2
- package/dist/core/types/InsightsInstanceSlotData.es.js.map +1 -1
- package/dist/finstrong/components/ManageDOB.es.js +16 -16
- package/dist/goals/components/GoalList.es.js +1 -1
- package/dist/goals/components/actions/BirthdayAction.es.js +11 -11
- package/dist/insights/components/insights/BillAmountNotStandard/BillAmountNotStandard.es.js +9 -9
- package/dist/insights/components/insights/BillAmountNotStandard/BillAmountNotStandardMUI.es.js +8 -8
- package/dist/insights/components/insights/MonthlySpendingComparisonV2/MonthlySpendingComparisonV2.es.js +9 -9
- package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/MakeTransferActionBlockLayer.es.js +11 -11
- package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/MakeTransferActionBlockLayer.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/layout.d.ts +7 -1
- package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/layout.es.js +24 -11
- package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionDetailsBlock/TransactionDetailsBlock.es.js +4 -4
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js +58 -58
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistory.d.ts +1 -3
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistory.es.js +14 -13
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistory.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.d.ts +8 -2
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.es.js +56 -36
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.es.js.map +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/BarchartBlock.d.ts +7 -3
- package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/BarchartBlock.es.js +30 -32
- package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/BarchartBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/utils.d.ts +3 -2
- package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/utils.es.js +16 -15
- package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/utils.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/IconComponent.es.js +5 -5
- package/dist/insights-v2/blocks/ComponentBlocks/DebtsBlock/DebtsBlock.es.js +6 -6
- package/dist/insights-v2/blocks/ComponentBlocks/SaveExtraBlock/SaveExtraBlock.d.ts +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/SaveExtraBlock/SaveExtraBlock.es.js +24 -10
- package/dist/insights-v2/blocks/ComponentBlocks/SaveExtraBlock/SaveExtraBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/TransactionBlock.es.js +4 -4
- package/dist/insights-v2/blocks/ComponentBlocks/UpcomingBillBlock/UpcomingBillBlock.es.js +6 -6
- package/dist/insights-v2/blocks/ComponentBlocks/UpcomingSubscriptionBlock/UpcomingSubscriptionBlock.es.js +1 -1
- package/dist/insights-v2/components/BaseLayout.es.js +24 -24
- package/dist/insights-v2/components/CompactInsightCard.d.ts +4 -2
- package/dist/insights-v2/components/CompactInsightCard.es.js +91 -59
- package/dist/insights-v2/components/CompactInsightCard.es.js.map +1 -1
- package/dist/insights-v2/components/chartblocks/EmptyBarChart.es.js +4 -4
- package/dist/insights-v2/ctaActions/ctaPostMessages.es.js +16 -15
- package/dist/insights-v2/ctaActions/ctaPostMessages.es.js.map +1 -1
- package/dist/insights-v2/index.es.js +122 -121
- package/dist/insights-v2/mappings/blocks.es.js +112 -99
- package/dist/insights-v2/mappings/blocks.es.js.map +1 -1
- package/dist/microinsights/cards/InsightCard.es.js +10 -10
- package/dist/recurringtransactions/components/PaymentSchedule.es.js +11 -11
- package/dist/recurringtransactions/components/RecurringTransactionDetails.es.js +16 -16
- package/dist/settings/components/profile/ProfileTab.es.js +33 -33
- package/dist/transactions/components/shared/TransactionDetails.es.js +5 -4
- package/dist/transactions/components/shared/TransactionDetails.es.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,66 +1,96 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
|
|
1
|
+
import { useInsightsV2Store as w } from "../../common/context/hooks.es.js";
|
|
2
|
+
import { slot as f } from "../../core/types/Insights.es.js";
|
|
3
|
+
import { getCategoryColor as v } from "../../core/utils/CategoryUtil.es.js";
|
|
4
|
+
import { TinyBarChart as B } from "../../common/components/TinyBarChart.es.js";
|
|
5
|
+
import { BAR_ARIA_LABEL as S, buildChartData as A, buildDataSeries as V } from "../blocks/ChartBlocks/BarchartBlock/utils.es.js";
|
|
6
|
+
import { ThemedSVGImage as D } from "./chartblocks/ThemedSVGImage.es.js";
|
|
7
|
+
import L from "./LogoFromGuid.es.js";
|
|
8
|
+
import { createVariantBlock as P } from "../blocks/createVariantBlock.es.js";
|
|
9
|
+
import { ActionBlockLayer as z } from "../actionBlocks/ActionBlockLayer.es.js";
|
|
10
|
+
import x from "./BadgedTile.es.js";
|
|
11
|
+
import { InsightOptionsMenu as F } from "./InsightOptionsMenu.es.js";
|
|
12
|
+
import { ReactComponent as R } from "./shared/images/FeeDetected.es.js";
|
|
13
|
+
import T from "./StatusBadge.es.js";
|
|
14
|
+
import g from "@mui/material/Stack";
|
|
15
|
+
import { P as j, Text as E } from "@mxenabled/mxui";
|
|
16
|
+
import G from "@mui/material/Button";
|
|
17
|
+
import { Icon as O } from "@mxenabled/mx-icons";
|
|
18
|
+
import { Fragment as K, jsx as t, jsxs as n } from "react/jsx-runtime";
|
|
19
|
+
import h from "@mui/material/Box";
|
|
20
|
+
import N from "@mui/material/Card";
|
|
21
|
+
var l = 44, y = ({ logo: r }) => r ? /* @__PURE__ */ t(L, {
|
|
17
22
|
logo: r,
|
|
18
|
-
size:
|
|
19
|
-
}) : /* @__PURE__ */ t(
|
|
23
|
+
size: l
|
|
24
|
+
}) : /* @__PURE__ */ t(h, {
|
|
20
25
|
"data-testid": "compact-insight-card-fallback-icon",
|
|
21
26
|
sx: {
|
|
22
27
|
alignItems: "center",
|
|
23
28
|
bgcolor: "primary.lighter",
|
|
24
29
|
display: "flex",
|
|
25
|
-
height:
|
|
30
|
+
height: l,
|
|
26
31
|
justifyContent: "center",
|
|
27
|
-
width:
|
|
32
|
+
width: l
|
|
28
33
|
},
|
|
29
|
-
children: /* @__PURE__ */ t(
|
|
34
|
+
children: /* @__PURE__ */ t(O, {
|
|
30
35
|
color: "primary",
|
|
31
36
|
fill: !0,
|
|
32
37
|
name: "lightbulb",
|
|
33
38
|
size: 24
|
|
34
39
|
})
|
|
35
|
-
}),
|
|
36
|
-
center: /* @__PURE__ */ t(
|
|
37
|
-
size:
|
|
40
|
+
}), u = ({ logo: r }) => /* @__PURE__ */ t(x, {
|
|
41
|
+
center: /* @__PURE__ */ t(y, { logo: r }),
|
|
42
|
+
size: l,
|
|
38
43
|
sx: { flexShrink: 0 }
|
|
39
|
-
}),
|
|
40
|
-
center: /* @__PURE__ */ t(
|
|
41
|
-
size:
|
|
44
|
+
}), W = ({ logo: r }) => /* @__PURE__ */ t(x, {
|
|
45
|
+
center: /* @__PURE__ */ t(y, { logo: r }),
|
|
46
|
+
size: l,
|
|
42
47
|
sx: { flexShrink: 0 },
|
|
43
|
-
topRight: /* @__PURE__ */ t(
|
|
44
|
-
}),
|
|
48
|
+
topRight: /* @__PURE__ */ t(T, { tone: "warning" })
|
|
49
|
+
}), H = () => /* @__PURE__ */ t(D, {
|
|
45
50
|
divProps: { style: {
|
|
46
51
|
flexShrink: 0,
|
|
47
52
|
lineHeight: 0,
|
|
48
53
|
width: "max-content"
|
|
49
54
|
} },
|
|
50
|
-
image:
|
|
51
|
-
}),
|
|
55
|
+
image: R
|
|
56
|
+
}), M = ({ data: r }) => {
|
|
57
|
+
const a = V(f(r, "series"));
|
|
58
|
+
if (!a.length) return null;
|
|
59
|
+
const s = f(r, "category_guid"), e = A(a, S).slice(-3);
|
|
60
|
+
return /* @__PURE__ */ t(h, {
|
|
61
|
+
"data-testid": "compact-insight-card-bar-chart",
|
|
62
|
+
sx: { flexShrink: 0 },
|
|
63
|
+
children: /* @__PURE__ */ t(B, {
|
|
64
|
+
color: (o) => s ? v(s, o) : o.palette.primary.main,
|
|
65
|
+
data: e
|
|
66
|
+
})
|
|
67
|
+
});
|
|
68
|
+
}, Z = P({
|
|
52
69
|
variants: {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
70
|
+
category_color: M,
|
|
71
|
+
minimal: u,
|
|
72
|
+
with_illustration: H,
|
|
73
|
+
with_warning_badge: W
|
|
56
74
|
},
|
|
57
|
-
fallback:
|
|
75
|
+
fallback: u,
|
|
58
76
|
name: "InsightVisual"
|
|
59
|
-
}),
|
|
60
|
-
|
|
61
|
-
|
|
77
|
+
}), $ = { BillAmountNotStandard: {
|
|
78
|
+
key: "in_description_cta",
|
|
79
|
+
trigger: "inDescriptionCta"
|
|
80
|
+
} }, q = (r) => r.stopPropagation(), ut = ({ beat: r, isCtaDisabled: a = !1, onCtaClick: s, onTap: e, payload: o }) => {
|
|
81
|
+
const { openActionDrawer: C } = w(), { description: b, instance_slot: m, primary_cta: d, title: k } = o, c = $[o.template ?? ""], p = c ? o[c.key] : d, I = f(m.data, "logo"), _ = (i) => {
|
|
82
|
+
if (i.stopPropagation(), !(a || !p)) {
|
|
83
|
+
if (c) {
|
|
84
|
+
r && C({
|
|
85
|
+
guid: r.guid,
|
|
86
|
+
trigger: c.trigger
|
|
87
|
+
});
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
d && s?.(d);
|
|
91
|
+
}
|
|
62
92
|
};
|
|
63
|
-
return /* @__PURE__ */ n(
|
|
93
|
+
return /* @__PURE__ */ n(K, { children: [/* @__PURE__ */ n(N, {
|
|
64
94
|
"data-testid": "compact-insight-card",
|
|
65
95
|
...e ? {
|
|
66
96
|
onClick: e,
|
|
@@ -78,7 +108,7 @@ var a = 44, d = ({ logo: r }) => r ? /* @__PURE__ */ t(I, {
|
|
|
78
108
|
pt: 8,
|
|
79
109
|
...e && { cursor: "pointer" }
|
|
80
110
|
},
|
|
81
|
-
children: [/* @__PURE__ */ n(
|
|
111
|
+
children: [/* @__PURE__ */ n(g, {
|
|
82
112
|
sx: {
|
|
83
113
|
alignItems: "center",
|
|
84
114
|
flexDirection: "row",
|
|
@@ -87,57 +117,59 @@ var a = 44, d = ({ logo: r }) => r ? /* @__PURE__ */ t(I, {
|
|
|
87
117
|
pl: 8,
|
|
88
118
|
pt: 4
|
|
89
119
|
},
|
|
90
|
-
children: [/* @__PURE__ */ t(
|
|
120
|
+
children: [/* @__PURE__ */ t(E, {
|
|
91
121
|
bold: !0,
|
|
92
122
|
variant: "body1",
|
|
93
|
-
children:
|
|
94
|
-
}), /* @__PURE__ */ t(
|
|
95
|
-
onClick:
|
|
123
|
+
children: k ?? ""
|
|
124
|
+
}), /* @__PURE__ */ t(h, {
|
|
125
|
+
onClick: q,
|
|
96
126
|
sx: { display: "flex" },
|
|
97
|
-
children: /* @__PURE__ */ t(
|
|
127
|
+
children: /* @__PURE__ */ t(F, {})
|
|
98
128
|
})]
|
|
99
|
-
}), /* @__PURE__ */ n(
|
|
129
|
+
}), /* @__PURE__ */ n(g, {
|
|
100
130
|
sx: {
|
|
101
131
|
flexDirection: "row",
|
|
102
132
|
gap: 16,
|
|
103
133
|
pl: 8,
|
|
104
134
|
pt: 4
|
|
105
135
|
},
|
|
106
|
-
children: [/* @__PURE__ */ n(
|
|
136
|
+
children: [/* @__PURE__ */ n(g, {
|
|
107
137
|
sx: {
|
|
108
138
|
flex: 1,
|
|
109
139
|
gap: 8,
|
|
110
140
|
minWidth: 0
|
|
111
141
|
},
|
|
112
|
-
children: [/* @__PURE__ */ t(
|
|
113
|
-
dangerouslySetInnerHTML: { __html:
|
|
142
|
+
children: [/* @__PURE__ */ t(j, {
|
|
143
|
+
dangerouslySetInnerHTML: { __html: b.html_text },
|
|
114
144
|
"data-testid": "compact-insight-card-description",
|
|
115
145
|
variant: "subtitle2"
|
|
116
|
-
}),
|
|
117
|
-
"aria-disabled":
|
|
118
|
-
onClick:
|
|
146
|
+
}), p?.label && /* @__PURE__ */ t(G, {
|
|
147
|
+
"aria-disabled": a,
|
|
148
|
+
onClick: _,
|
|
119
149
|
size: "small",
|
|
120
150
|
sx: {
|
|
121
151
|
alignSelf: "flex-start",
|
|
152
|
+
mt: 5,
|
|
122
153
|
ml: -8,
|
|
123
154
|
px: 8,
|
|
124
|
-
...
|
|
155
|
+
...a && {
|
|
125
156
|
color: "text.disabled",
|
|
126
157
|
cursor: "default"
|
|
127
158
|
}
|
|
128
159
|
},
|
|
129
160
|
variant: "text",
|
|
130
|
-
children:
|
|
161
|
+
children: p.label
|
|
131
162
|
})]
|
|
132
|
-
}), /* @__PURE__ */ t(
|
|
133
|
-
|
|
134
|
-
|
|
163
|
+
}), /* @__PURE__ */ t(Z, {
|
|
164
|
+
data: m.data,
|
|
165
|
+
logo: I,
|
|
166
|
+
variant: m.variant
|
|
135
167
|
})]
|
|
136
168
|
})]
|
|
137
|
-
});
|
|
169
|
+
}), r && /* @__PURE__ */ t(z, { beat: r })] });
|
|
138
170
|
};
|
|
139
171
|
export {
|
|
140
|
-
|
|
172
|
+
ut as default
|
|
141
173
|
};
|
|
142
174
|
|
|
143
175
|
//# sourceMappingURL=CompactInsightCard.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompactInsightCard.es.js","names":[],"sources":["../../../src/insights-v2/components/CompactInsightCard.tsx"],"sourcesContent":["import type { KeyboardEvent, MouseEvent } from 'react'\n\nimport Box from '@mui/material/Box'\nimport Button from '@mui/material/Button'\nimport Card from '@mui/material/Card'\nimport Stack from '@mui/material/Stack'\n\nimport { Icon } from '@mxenabled/mx-icons'\nimport { P, Text } from '@mxenabled/mxui'\n\nimport { slot } from '../../core'\nimport type { InsightsPayload, LogoRef, PrimaryCTA } from '../../core'\nimport { createVariantBlock } from '../blocks/createVariantBlock'\nimport BadgedTile from './BadgedTile'\nimport InsightOptionsMenu from './InsightOptionsMenu'\nimport LogoFromGuid from './LogoFromGuid'\nimport { ReactComponent as FeeDetectedIllustration } from './shared/images/FeeDetected.svg'\nimport { ThemedSVGImage } from './chartblocks/ThemedSVGImage'\nimport StatusBadge from './StatusBadge'\n\n/** Figma 1941:111897: the tile the logo fills is 44px (rows are 32, the notification row 33). */\nconst ICON_SIZE = 44\n\ninterface InsightVisualProps {\n /** The slot's `logo`, when ditto's variant declares and fills one. */\n logo?: LogoRef | null\n}\n\n/** The slot's logo, or the neutral insight glyph when the slot carries none. */\nconst LogoOrFallback = ({ logo }: InsightVisualProps) =>\n logo ? (\n <LogoFromGuid logo={logo} size={ICON_SIZE} />\n ) : (\n <Box\n data-testid=\"compact-insight-card-fallback-icon\"\n sx={{\n alignItems: 'center',\n bgcolor: 'primary.lighter',\n display: 'flex',\n height: ICON_SIZE,\n justifyContent: 'center',\n width: ICON_SIZE,\n }}\n >\n <Icon color=\"primary\" fill={true} name=\"lightbulb\" size={24} />\n </Box>\n )\n\n/** Micro, and any variant not registered below: the logo alone. */\nconst PlainVisual = ({ logo }: InsightVisualProps) => (\n <BadgedTile center={<LogoOrFallback logo={logo} />} size={ICON_SIZE} sx={{ flexShrink: 0 }} />\n)\n\n/** ditto `with_warning_badge`: the logo badged with a status glyph (Figma 1941:111897). */\nconst WarningBadgeVisual = ({ logo }: InsightVisualProps) => (\n <BadgedTile\n center={<LogoOrFallback logo={logo} />}\n size={ICON_SIZE}\n sx={{ flexShrink: 0 }}\n topRight={<StatusBadge tone=\"warning\" />}\n />\n)\n\n/**\n * ditto `with_illustration`: artwork in place of the logo tile (Fee Detected's search illustration).\n * A single SVG themed at runtime by `ThemedSVGImage`: its `brand300` elements are recolored to the\n * theme's `primary.main` (so it follows dark mode), while `fill=\"white\"` areas stay white. The\n * slot's `logo` is deliberately unused: the illustration replaces the tile.\n */\nconst IllustrationVisual = () => {\n return (\n <ThemedSVGImage\n divProps={{ style: { flexShrink: 0, lineHeight: 0, width: 'max-content' } }}\n image={FeeDetectedIllustration}\n />\n )\n}\n\n/**\n * The card's right-hand visual, one component per ditto layout variant.\n *\n * A variant names a rendering *shape*, not an insight or a surface — `with_header` already serves\n * both Large Transaction and Fee Detected — so an insight wanting the badged logo reuses\n * `with_warning_badge`. Only a genuinely different visual registers a new entry, and existing ones\n * are never touched.\n *\n * `minimal` draws the plain logo and is registered explicitly even though it matches the fallback:\n * micro and notification resolve it on every render, and an unregistered variant warns. The\n * fallback is for variants we genuinely do not know.\n */\nconst InsightVisual = createVariantBlock<InsightVisualProps>({\n variants: {\n minimal: PlainVisual,\n with_illustration: IllustrationVisual,\n with_warning_badge: WarningBadgeVisual,\n },\n fallback: PlainVisual,\n name: 'InsightVisual',\n})\n\nexport interface CompactInsightCardProps {\n /** A `micro` or `embedded` envelope. */\n payload: InsightsPayload\n /**\n * Makes the whole card the tap target. What a tap does is the host's decision (post to the\n * host app, open a drawer, …); the card never opens anything itself. Omit for a static card.\n */\n onTap?: () => void\n /** Receives the primary CTA when tapped. The card does not resolve the CTA's block itself. */\n onCtaClick?: (cta: PrimaryCTA) => void\n /**\n * Renders the CTA disabled — label shown, `aria-disabled`, not tappable — for a host that cannot\n * honour it (e.g. `contact_support_block` when the client's `enable_support_requests` is off).\n */\n isCtaDisabled?: boolean\n}\n\nconst stopPropagation = (event: MouseEvent) => event.stopPropagation()\n\n/**\n * The one compact renderer the micro and embedded envelopes share (`insights_v2.2.md` §8.3).\n *\n * Figma 1941:111897 (Embedded | Large Transaction): a title row with the overflow slot, the HTML\n * description with the primary CTA under it, and on the right the slot's `logo` in a\n * `<BadgedTile>`. Under ditto's `with_warning_badge` variant the tile takes a status badge; under\n * `minimal` it draws the logo alone. The card lays out from the envelope alone and never reads\n * `widget_type`.\n *\n * The icon falls back to the neutral insight glyph **here**, not in `LogoFromGuid`, when the slot\n * carries no logo. The `pill` on the same envelope is the transaction row's, not the card's.\n */\nconst CompactInsightCard = ({\n isCtaDisabled = false,\n onCtaClick,\n onTap,\n payload,\n}: CompactInsightCardProps) => {\n const { description, instance_slot, primary_cta, title } = payload\n // Reduced variants (`minimal`, `with_warning_badge`) declare a bare `logo` slot.\n const rowLogo = slot<LogoRef>(instance_slot.data, 'logo')\n\n const handleCtaClick = (event: MouseEvent<HTMLButtonElement>) => {\n event.stopPropagation()\n if (isCtaDisabled || !primary_cta) return\n onCtaClick?.(primary_cta)\n }\n\n const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n // Only the card itself: Enter on the CTA button is the button's own click.\n if (event.target !== event.currentTarget) return\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault()\n onTap?.()\n }\n }\n\n const interactiveProps = onTap\n ? { onClick: onTap, onKeyDown: handleKeyDown, role: 'button', tabIndex: 0 }\n : {}\n\n return (\n <Card\n data-testid=\"compact-insight-card\"\n {...interactiveProps}\n sx={{\n minWidth: 288,\n pb: 12,\n pl: 8,\n pr: 16,\n pt: 8,\n ...(onTap && { cursor: 'pointer' }),\n }}\n >\n <Stack\n sx={{\n alignItems: 'center',\n flexDirection: 'row',\n gap: 8,\n justifyContent: 'space-between',\n pl: 8,\n pt: 4,\n }}\n >\n <Text bold={true} variant=\"body1\">\n {title ?? ''}\n </Text>\n {/* The menu renders only when the host wired `onMenuAction` (BeatActionsProvider). */}\n <Box onClick={stopPropagation} sx={{ display: 'flex' }}>\n <InsightOptionsMenu />\n </Box>\n </Stack>\n\n <Stack sx={{ flexDirection: 'row', gap: 16, pl: 8, pt: 4 }}>\n <Stack sx={{ flex: 1, gap: 8, minWidth: 0 }}>\n {/* `html_text` is rendered server-side by mrs_content from the ditto copy template (bold\n amount / merchant), not user-authored input; painted the same way `BaseLayout` paints\n the full card's description. */}\n <P\n dangerouslySetInnerHTML={{ __html: description.html_text }}\n data-testid=\"compact-insight-card-description\"\n variant=\"subtitle2\"\n />\n {primary_cta?.label && (\n <Button\n aria-disabled={isCtaDisabled}\n onClick={handleCtaClick}\n size=\"small\"\n sx={{\n alignSelf: 'flex-start',\n // Figma 1941:111897 lines the CTA label up with the description's left edge. The\n // column already pads 8, so the button's own 8 is pulled back out — padding kept so\n // the tap target does not shrink.\n ml: -8,\n px: 8,\n ...(isCtaDisabled && {\n color: 'text.disabled',\n cursor: 'default',\n }),\n }}\n variant=\"text\"\n >\n {primary_cta.label}\n </Button>\n )}\n </Stack>\n\n <InsightVisual logo={rowLogo} variant={instance_slot.variant} />\n </Stack>\n </Card>\n )\n}\n\nexport default CompactInsightCard\n"],"mappings":";;;;;;;;;;;;;;;AAqBA,IAAM,IAAY,IAQZ,IAAA,CAAkB,EAAE,MAAA,EAAA,MACxB,IACE,gBAAA,EAAC,GAAD;AAAA,EAAoB,MAAA;AAAA,EAAM,MAAM;AAAY,CAAA,IAE5C,gBAAA,EAAC,GAAD;AAAA,EACE,eAAY;AAAA,EACZ,IAAI;AAAA,IACF,YAAY;AAAA,IACZ,SAAS;AAAA,IACT,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,gBAAgB;AAAA,IAChB,OAAO;AAAA,EACT;AAAA,EAEA,UAAA,gBAAA,EAAC,GAAD;AAAA,IAAM,OAAM;AAAA,IAAU,MAAM;AAAA,IAA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AY;AAAA,UACZ,SAAQ;AAAA,QACT,CAAA,GACA,GAAa,SACZ,gBAAA,EAAC,GAAD;AAAA,UACE,iBAAe;AAAA,UACf,SAAS;AAAA,UACT,MAAK;AAAA,UACL,IAAI;AAAA,YACF,WAAW;AAAA,YAIX,IAAI;AAAA,YACJ,IAAI;AAAA,YACJ,GAAI,KAAiB;AAAA,cACnB,OAAO;AAAA,cACP,QAAQ;AAAA,YACV;AAAA,UACF;AAAA,UACA,SAAQ;AAAA,UAEP,UAAA,EAAY;AAAA,QACP,CAAA,CAEL;AAAA,MAEP,CAAA,GAAA,gBAAA,EAAC,GAAD;AAAA,QAAe,MAAM;AAAA,QAAS,SAAS,EAAc;AAAA,MAAU,CAAA,CAC1D;AAAA,IACH,CAAA,CAAA;AAAA;AAEV"}
|
|
1
|
+
{"version":3,"file":"CompactInsightCard.es.js","names":[],"sources":["../../../src/insights-v2/components/CompactInsightCard.tsx"],"sourcesContent":["import type { KeyboardEvent, MouseEvent } from 'react'\n\nimport Box from '@mui/material/Box'\nimport Button from '@mui/material/Button'\nimport Card from '@mui/material/Card'\nimport Stack from '@mui/material/Stack'\n\nimport { Icon } from '@mxenabled/mx-icons'\nimport { P, Text } from '@mxenabled/mxui'\n\nimport { useInsightsV2Store } from '../../common'\nimport { TinyBarChart } from '../../common/components/TinyBarChart'\nimport { slot } from '../../core'\nimport type {\n Beat,\n DataSeries,\n InsightsPayload,\n InstanceSlotData,\n LogoRef,\n PrimaryCTA,\n} from '../../core'\nimport type { ActionDrawerTrigger } from '../../core/stores'\nimport { getCategoryColor } from '../../core/utils/CategoryUtil'\nimport {\n BAR_ARIA_LABEL,\n buildChartData,\n buildDataSeries,\n} from '../blocks/ChartBlocks/BarchartBlock/utils'\nimport { ActionBlockLayer } from '../actionBlocks/ActionBlockLayer'\nimport { createVariantBlock } from '../blocks/createVariantBlock'\nimport BadgedTile from './BadgedTile'\nimport InsightOptionsMenu from './InsightOptionsMenu'\nimport LogoFromGuid from './LogoFromGuid'\nimport { ReactComponent as FeeDetectedIllustration } from './shared/images/FeeDetected.svg'\nimport { ThemedSVGImage } from './chartblocks/ThemedSVGImage'\nimport StatusBadge from './StatusBadge'\n\n/** Figma 1941:111897: the tile the logo fills is 44px (rows are 32, the notification row 33). */\nconst ICON_SIZE = 44\n\ninterface InsightVisualProps {\n /** The slot's `logo`, when ditto's variant declares and fills one. */\n logo?: LogoRef | null\n /** The slot's `data`, for a visual drawn from more than the logo (`category_color`'s bars). */\n data?: InstanceSlotData\n}\n\n/** Figma 222:33404 (Embedded | Bill Amount Not Standard) shows the latest three bars. */\nconst BAR_CHART_BAR_COUNT = 3\n\n/** The slot's logo, or the neutral insight glyph when the slot carries none. */\nconst LogoOrFallback = ({ logo }: InsightVisualProps) =>\n logo ? (\n <LogoFromGuid logo={logo} size={ICON_SIZE} />\n ) : (\n <Box\n data-testid=\"compact-insight-card-fallback-icon\"\n sx={{\n alignItems: 'center',\n bgcolor: 'primary.lighter',\n display: 'flex',\n height: ICON_SIZE,\n justifyContent: 'center',\n width: ICON_SIZE,\n }}\n >\n <Icon color=\"primary\" fill={true} name=\"lightbulb\" size={24} />\n </Box>\n )\n\n/** Micro, and any variant not registered below: the logo alone. */\nconst PlainVisual = ({ logo }: InsightVisualProps) => (\n <BadgedTile center={<LogoOrFallback logo={logo} />} size={ICON_SIZE} sx={{ flexShrink: 0 }} />\n)\n\n/** ditto `with_warning_badge`: the logo badged with a status glyph (Figma 1941:111897). */\nconst WarningBadgeVisual = ({ logo }: InsightVisualProps) => (\n <BadgedTile\n center={<LogoOrFallback logo={logo} />}\n size={ICON_SIZE}\n sx={{ flexShrink: 0 }}\n topRight={<StatusBadge tone=\"warning\" />}\n />\n)\n\n/**\n * ditto `with_illustration`: artwork in place of the logo tile (Fee Detected's search illustration).\n * A single SVG themed at runtime by `ThemedSVGImage`: its `brand300` elements are recolored to the\n * theme's `primary.main` (so it follows dark mode), while `fill=\"white\"` areas stay white. The\n * slot's `logo` is deliberately unused: the illustration replaces the tile.\n */\nconst IllustrationVisual = () => {\n return (\n <ThemedSVGImage\n divProps={{ style: { flexShrink: 0, lineHeight: 0, width: 'max-content' } }}\n image={FeeDetectedIllustration}\n />\n )\n}\n\n/**\n * ditto `category_color`: a tiny bar chart of the latest bars in place of the logo tile, tinted by\n * the slot's category, the newest bar solid (Figma 222:33404). Draws nothing without a series.\n */\nconst BarChartVisual = ({ data }: InsightVisualProps) => {\n const series = buildDataSeries(slot<DataSeries>(data, 'series'))\n if (!series.length) return null\n\n const categoryGuid = slot<string>(data, 'category_guid')\n const bars = buildChartData(series, BAR_ARIA_LABEL).slice(-BAR_CHART_BAR_COUNT)\n\n return (\n <Box data-testid=\"compact-insight-card-bar-chart\" sx={{ flexShrink: 0 }}>\n <TinyBarChart\n color={(theme) =>\n categoryGuid ? getCategoryColor(categoryGuid, theme) : theme.palette.primary.main\n }\n data={bars}\n />\n </Box>\n )\n}\n\n/**\n * The card's right-hand visual, one component per ditto layout variant.\n *\n * A variant names a rendering *shape*, not an insight or a surface — `with_header` already serves\n * both Large Transaction and Fee Detected — so an insight wanting the badged logo reuses\n * `with_warning_badge`. Only a genuinely different visual registers a new entry, and existing ones\n * are never touched.\n *\n * `minimal` draws the plain logo and is registered explicitly even though it matches the fallback:\n * micro and notification resolve it on every render, and an unregistered variant warns. The\n * fallback is for variants we genuinely do not know.\n */\nconst InsightVisual = createVariantBlock<InsightVisualProps>({\n variants: {\n category_color: BarChartVisual,\n minimal: PlainVisual,\n with_illustration: IllustrationVisual,\n with_warning_badge: WarningBadgeVisual,\n },\n fallback: PlainVisual,\n name: 'InsightVisual',\n})\n\n/**\n * Beats whose embedded CTA the card reads from its own envelope key and opens in this card's\n * `ActionBlockLayer`, as a bar click does on the full card. The trigger names that key, so the layer\n * resolves the same CTA. Every other beat keeps `primary_cta` and hands it to the host's `onCtaClick`\n * (e.g. `contact_support_block`). A new beat adds its template here.\n */\nconst BEAT_CTA_CONFIG: Record<\n string,\n { key: 'primary_cta' | 'in_description_cta'; trigger: ActionDrawerTrigger }\n> = {\n BillAmountNotStandard: { key: 'in_description_cta', trigger: 'inDescriptionCta' },\n}\n\nexport interface CompactInsightCardProps {\n /** A `micro` or `embedded` envelope. */\n payload: InsightsPayload\n /** The envelope's beat; when given, the card mounts its `ActionBlockLayer` for CTA drawers. */\n beat?: Beat\n /**\n * Makes the whole card the tap target. What a tap does is the host's decision (post to the\n * host app, open a drawer, …); the card never opens anything itself. Omit for a static card.\n */\n onTap?: () => void\n /** Receives the primary CTA when tapped. The card does not resolve the CTA's block itself. */\n onCtaClick?: (cta: PrimaryCTA) => void\n /**\n * Renders the CTA disabled — label shown, `aria-disabled`, not tappable — for a host that cannot\n * honour it (e.g. `contact_support_block` when the client's `enable_support_requests` is off).\n */\n isCtaDisabled?: boolean\n}\n\nconst stopPropagation = (event: MouseEvent) => event.stopPropagation()\n\n/**\n * The one compact renderer the micro and embedded envelopes share (`insights_v2.2.md` §8.3).\n *\n * Figma 1941:111897 (Embedded | Large Transaction): a title row with the overflow slot, the HTML\n * description with the primary CTA under it, and on the right the slot's `logo` in a\n * `<BadgedTile>`. Under ditto's `with_warning_badge` variant the tile takes a status badge; under\n * `minimal` it draws the logo alone. The card lays out from the envelope alone and never reads\n * `widget_type`.\n *\n * The icon falls back to the neutral insight glyph **here**, not in `LogoFromGuid`, when the slot\n * carries no logo. The `pill` on the same envelope is the transaction row's, not the card's.\n */\nconst CompactInsightCard = ({\n beat,\n isCtaDisabled = false,\n onCtaClick,\n onTap,\n payload,\n}: CompactInsightCardProps) => {\n const { openActionDrawer } = useInsightsV2Store()\n const { description, instance_slot, primary_cta, title } = payload\n const beatCta = BEAT_CTA_CONFIG[payload.template ?? '']\n const cta = beatCta ? payload[beatCta.key] : primary_cta\n // Reduced variants (`minimal`, `with_warning_badge`) declare a bare `logo` slot.\n const rowLogo = slot<LogoRef>(instance_slot.data, 'logo')\n\n const handleCtaClick = (event: MouseEvent<HTMLButtonElement>) => {\n event.stopPropagation()\n if (isCtaDisabled || !cta) return\n\n if (beatCta) {\n if (beat) openActionDrawer({ guid: beat.guid, trigger: beatCta.trigger })\n return\n }\n if (primary_cta) onCtaClick?.(primary_cta)\n }\n\n const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n // Only the card itself: Enter on the CTA button is the button's own click.\n if (event.target !== event.currentTarget) return\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault()\n onTap?.()\n }\n }\n\n const interactiveProps = onTap\n ? { onClick: onTap, onKeyDown: handleKeyDown, role: 'button', tabIndex: 0 }\n : {}\n\n return (\n <>\n <Card\n data-testid=\"compact-insight-card\"\n {...interactiveProps}\n sx={{\n minWidth: 288,\n pb: 12,\n pl: 8,\n pr: 16,\n pt: 8,\n ...(onTap && { cursor: 'pointer' }),\n }}\n >\n <Stack\n sx={{\n alignItems: 'center',\n flexDirection: 'row',\n gap: 8,\n justifyContent: 'space-between',\n pl: 8,\n pt: 4,\n }}\n >\n <Text bold={true} variant=\"body1\">\n {title ?? ''}\n </Text>\n {/* The menu renders only when the host wired `onMenuAction` (BeatActionsProvider). */}\n <Box onClick={stopPropagation} sx={{ display: 'flex' }}>\n <InsightOptionsMenu />\n </Box>\n </Stack>\n\n <Stack sx={{ flexDirection: 'row', gap: 16, pl: 8, pt: 4 }}>\n <Stack sx={{ flex: 1, gap: 8, minWidth: 0 }}>\n {/* `html_text` is rendered server-side by mrs_content from the ditto copy template (bold\n amount / merchant), not user-authored input; painted the same way `BaseLayout` paints\n the full card's description. */}\n <P\n dangerouslySetInnerHTML={{ __html: description.html_text }}\n data-testid=\"compact-insight-card-description\"\n variant=\"subtitle2\"\n />\n {cta?.label && (\n <Button\n aria-disabled={isCtaDisabled}\n onClick={handleCtaClick}\n size=\"small\"\n sx={{\n alignSelf: 'flex-start',\n // Figma 1941:111897 lines the CTA label up with the description's left edge. The\n // column already pads 8, so the button's own 8 is pulled back out — padding kept so\n // the tap target does not shrink.\n mt: 5,\n ml: -8,\n px: 8,\n ...(isCtaDisabled && {\n color: 'text.disabled',\n cursor: 'default',\n }),\n }}\n variant=\"text\"\n >\n {cta.label}\n </Button>\n )}\n </Stack>\n\n <InsightVisual data={instance_slot.data} logo={rowLogo} variant={instance_slot.variant} />\n </Stack>\n </Card>\n {/* Outside the Card: the drawer is a portal, and its clicks would otherwise bubble to `onTap`. */}\n {beat && <ActionBlockLayer beat={beat} />}\n </>\n )\n}\n\nexport default CompactInsightCard\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAsCA,IAAM,IAAY,IAaZ,IAAA,CAAkB,EAAE,MAAA,EAAA,MACxB,IACE,gBAAA,EAAC,GAAD;AAAA,EAAoB,MAAA;AAAA,EAAM,MAAM;AAAY,CAAA,IAE5C,gBAAA,EAAC,GAAD;AAAA,EACE,eAAY;AAAA,EACZ,IAAI;AAAA,IACF,YAAY;AAAA,IACZ,SAAS;AAAA,IACT,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,gBAAgB;AAAA,IAChB,OAAO;AAAA,EACT;AAAA,EAEA,UAAA,gBAAA,EAAC,GAAD;AAAA,IAAM,OAAM;AAAA,IAAU,MAAM;AAAA,IAAM,MAAK;AAAA,IAAY,MAAM;AAAA,EAAK,CAAA;AAC3D,CAAA,GAIH,IAAA,CAAe,EAAE,MAAA,EAAA,MACrB,gBAAA,EAAC,GAAD;AAAA,EAAY,QAAQ,gBAAA,EAAC,GAAD,EAAsB,MAAA,EAAO,CAAA;AAAA,EAAG,MAAM;AAAA,EAAW,IAAI,EAAE,YAAY,EAAE;AAAI,CAAA,GAIzF,IAAA,CAAsB,EAAE,MAAA,EAAA,MAC5B,gBAAA,EAAC,GAAD;AAAA,EACE,QAAQ,gBAAA,EAAC,GAAD,EAAsB,MAAA,EAAO,CAAA;AAAA,EACrC,MAAM;AAAA,EACN,IAAI,EAAE,YAAY,EAAE;AAAA,EACpB,UAAU,gBAAA,EAAC,GAAD,EAAa,MAAK,UAAW,CAAA;AACxC,CAAA,GASG,IAAA,MAEF,gBAAA,EAAC,G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AEP,CAAA,GAAA,gBAAA,EAAC,GAAD;AAAA,MAAO,IAAI;AAAA,QAAE,eAAe;AAAA,QAAO,KAAK;AAAA,QAAI,IAAI;AAAA,QAAG,IAAI;AAAA,MAAE;AAAA,MAAzD,UAAA,CACE,gBAAA,EAAC,GAAD;AAAA,QAAO,IAAI;AAAA,UAAE,MAAM;AAAA,UAAG,KAAK;AAAA,UAAG,UAAU;AAAA,QAAE;AAAA,QAA1C,UAAA,CAIE,gBAAA,EAAC,GAAD;AAAA,UACE,yBAAyB,EAAE,QAAQ,EAAY,UAAU;AAAA,UACzD,eAAY;AAAA,UACZ,SAAQ;AAAA,QACT,CAAA,GACA,GAAK,SACJ,gBAAA,EAAC,GAAD;AAAA,UACE,iBAAe;AAAA,UACf,SAAS;AAAA,UACT,MAAK;AAAA,UACL,IAAI;AAAA,YACF,WAAW;AAAA,YAIX,IAAI;AAAA,YACJ,IAAI;AAAA,YACJ,IAAI;AAAA,YACJ,GAAI,KAAiB;AAAA,cACnB,OAAO;AAAA,cACP,QAAQ;AAAA,YACV;AAAA,UACF;AAAA,UACA,SAAQ;AAAA,UAEP,UAAA,EAAI;AAAA,QACC,CAAA,CAEL;AAAA,MAEP,CAAA,GAAA,gBAAA,EAAC,GAAD;AAAA,QAAe,MAAM,EAAc;AAAA,QAAM,MAAM;AAAA,QAAS,SAAS,EAAc;AAAA,MAAU,CAAA,CACpF;AAAA,IACH,CAAA,CAAA;AAAA,EAEL,CAAA,GAAA,KAAQ,gBAAA,EAAC,GAAD,EAAwB,MAAA,EAAO,CAAA,CACxC,EAAA,CAAA;AAEN"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ReactComponent as r } from "../../../insights/components/shared/images/EmptyBarChart.es.js";
|
|
2
|
+
import { ThemedSVGImage as o } from "./ThemedSVGImage.es.js";
|
|
3
3
|
import { jsx as m } from "react/jsx-runtime";
|
|
4
4
|
function p() {
|
|
5
|
-
return /* @__PURE__ */ m(
|
|
5
|
+
return /* @__PURE__ */ m(o, {
|
|
6
6
|
divProps: { style: {} },
|
|
7
|
-
image:
|
|
7
|
+
image: r
|
|
8
8
|
});
|
|
9
9
|
}
|
|
10
10
|
export {
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { AccountType as
|
|
2
|
-
import { BEAT_OPERATION_1 as n, BEAT_OPERATION_2 as
|
|
3
|
-
var
|
|
1
|
+
import { AccountType as s } from "../../core/types/Account.es.js";
|
|
2
|
+
import { BEAT_OPERATION_1 as n, BEAT_OPERATION_2 as l } from "../../common/utils/PostMessage.es.js";
|
|
3
|
+
var c = (a) => !a.is_hidden && !a.is_deleted && !a.is_closed, r = ({ beat: a, stores: t }) => a.primary_account ?? t.accountStore.accounts.find((o) => o.guid === a.primary_account_guid), d = ({ beat: a, stores: t }) => {
|
|
4
4
|
const o = new Set(a.account_guids);
|
|
5
|
-
return t.accountStore.accounts.filter((e) => o.has(e.guid) &&
|
|
6
|
-
},
|
|
7
|
-
SaveAnExtra100Dollars:
|
|
5
|
+
return t.accountStore.accounts.filter((e) => o.has(e.guid) && c(e));
|
|
6
|
+
}, _ = ({ stores: a }) => a.accountStore.accounts.filter((t) => t.account_type === s.SAVINGS && c(t)), i = { primary: () => ({ action: n }) }, g = {
|
|
7
|
+
SaveAnExtra100Dollars: i,
|
|
8
|
+
SaveAnExtra100DollarsV2: i,
|
|
8
9
|
PaydayCashLeftOverStatus: { primary: () => ({ action: n }) },
|
|
9
10
|
LowAccountBalance: { primary: (a) => {
|
|
10
|
-
const t =
|
|
11
|
+
const t = r(a);
|
|
11
12
|
return t ? {
|
|
12
13
|
action: n,
|
|
13
14
|
payload: { account_guid: t.external_guid }
|
|
@@ -19,16 +20,16 @@ var r = (a) => !a.is_hidden && !a.is_deleted && !a.is_closed, i = ({ beat: a, st
|
|
|
19
20
|
action: n,
|
|
20
21
|
payload: {
|
|
21
22
|
total_amount_withdrawn: a.beat.payload?.total_amount,
|
|
22
|
-
accounts:
|
|
23
|
+
accounts: d(a).map((t) => ({
|
|
23
24
|
account_guid: t.external_guid,
|
|
24
25
|
account_name: a.beat.payload?.account_name?.default
|
|
25
26
|
}))
|
|
26
27
|
}
|
|
27
28
|
}) },
|
|
28
29
|
SavingsOpportunityV2: { primary: (a) => {
|
|
29
|
-
const t =
|
|
30
|
+
const t = r(a);
|
|
30
31
|
if (!t) return null;
|
|
31
|
-
const o =
|
|
32
|
+
const o = _(a), e = {
|
|
32
33
|
amount: a.beat.payload?.suggested_savings_amount,
|
|
33
34
|
source_account_id: t.external_guid
|
|
34
35
|
};
|
|
@@ -36,17 +37,17 @@ var r = (a) => !a.is_hidden && !a.is_deleted && !a.is_closed, i = ({ beat: a, st
|
|
|
36
37
|
action: n,
|
|
37
38
|
payload: {
|
|
38
39
|
...e,
|
|
39
|
-
destination_account_ids: o.map((
|
|
40
|
+
destination_account_ids: o.map((u) => u.external_guid)
|
|
40
41
|
}
|
|
41
42
|
} : {
|
|
42
|
-
action:
|
|
43
|
+
action: l,
|
|
43
44
|
payload: e
|
|
44
45
|
};
|
|
45
46
|
} }
|
|
46
|
-
},
|
|
47
|
+
}, y = (a) => a.cta.metadata ?? g[a.beat.template]?.[a.slot]?.(a) ?? null;
|
|
47
48
|
export {
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
g as ctaPostMessages,
|
|
50
|
+
y as resolveCtaMetadata
|
|
50
51
|
};
|
|
51
52
|
|
|
52
53
|
//# sourceMappingURL=ctaPostMessages.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ctaPostMessages.es.js","names":[],"sources":["../../../src/insights-v2/ctaActions/ctaPostMessages.ts"],"sourcesContent":["import { BEAT_OPERATION_1, BEAT_OPERATION_2 } from '../../common/utils/PostMessage'\nimport { AccountType, type Account, type CtaPostMessageMetadata } from '../../core'\nimport type { CtaSlot, CtaStateContext } from './types'\n\n/**\n * Interim per-template post messages, carried over from the pulse beats, for CTAs the backend\n * does not yet describe with `cta.metadata`. Each resolver returns the same shape the backend\n * will send, or `null` for \"no message\" (the default then only opens the drawer for a block).\n * Backend `metadata` always wins, so entries become dead the moment tupac ships the key for\n * their template.\n *\n * Remove once every template here has `metadata` from the backend: delete this file, its test\n * and README section, and the `resolveCtaMetadata` call in `runCtaAction.ts`.\n */\nexport type CtaPostMessageResolver = (ctx: CtaStateContext) => CtaPostMessageMetadata | null\n\ntype BeatContext = Pick<CtaStateContext, 'beat' | 'stores'>\n\nconst isUsable = (account: Account) =>\n !account.is_hidden && !account.is_deleted && !account.is_closed\n\n/** The beat's primary account: from the beat when the host attached it, else the account store. */\nconst primaryAccountOf = ({ beat, stores }: BeatContext): Account | undefined =>\n beat.primary_account ??\n stores.accountStore.accounts.find((account) => account.guid === beat.primary_account_guid)\n\n/** The accounts the beat points at (`account_guids`), as loaded in the account store. */\nconst beatAccountsOf = ({ beat, stores }: BeatContext): Account[] => {\n const guids = new Set<string>(beat.account_guids)\n\n return stores.accountStore.accounts.filter(\n (account) => guids.has(account.guid) && isUsable(account),\n )\n}\n\nconst savingsAccountsOf = ({ stores }: BeatContext): Account[] =>\n stores.accountStore.accounts.filter(\n (account) => account.account_type === AccountType.SAVINGS && isUsable(account),\n )\n\
|
|
1
|
+
{"version":3,"file":"ctaPostMessages.es.js","names":[],"sources":["../../../src/insights-v2/ctaActions/ctaPostMessages.ts"],"sourcesContent":["import { BEAT_OPERATION_1, BEAT_OPERATION_2 } from '../../common/utils/PostMessage'\nimport { AccountType, type Account, type CtaPostMessageMetadata } from '../../core'\nimport type { CtaSlot, CtaStateContext } from './types'\n\n/**\n * Interim per-template post messages, carried over from the pulse beats, for CTAs the backend\n * does not yet describe with `cta.metadata`. Each resolver returns the same shape the backend\n * will send, or `null` for \"no message\" (the default then only opens the drawer for a block).\n * Backend `metadata` always wins, so entries become dead the moment tupac ships the key for\n * their template.\n *\n * Remove once every template here has `metadata` from the backend: delete this file, its test\n * and README section, and the `resolveCtaMetadata` call in `runCtaAction.ts`.\n */\nexport type CtaPostMessageResolver = (ctx: CtaStateContext) => CtaPostMessageMetadata | null\n\ntype BeatContext = Pick<CtaStateContext, 'beat' | 'stores'>\n\nconst isUsable = (account: Account) =>\n !account.is_hidden && !account.is_deleted && !account.is_closed\n\n/** The beat's primary account: from the beat when the host attached it, else the account store. */\nconst primaryAccountOf = ({ beat, stores }: BeatContext): Account | undefined =>\n beat.primary_account ??\n stores.accountStore.accounts.find((account) => account.guid === beat.primary_account_guid)\n\n/** The accounts the beat points at (`account_guids`), as loaded in the account store. */\nconst beatAccountsOf = ({ beat, stores }: BeatContext): Account[] => {\n const guids = new Set<string>(beat.account_guids)\n\n return stores.accountStore.accounts.filter(\n (account) => guids.has(account.guid) && isUsable(account),\n )\n}\n\nconst savingsAccountsOf = ({ stores }: BeatContext): Account[] =>\n stores.accountStore.accounts.filter(\n (account) => account.account_type === AccountType.SAVINGS && isUsable(account),\n )\n\n/** \"Make Transfer\": the base `beat/cta` op_1, nothing beat-specific. */\nconst saveAnExtra100Dollars: Partial<Record<CtaSlot, CtaPostMessageResolver>> = {\n primary: () => ({ action: BEAT_OPERATION_1 }),\n}\n\nexport const ctaPostMessages: Record<string, Partial<Record<CtaSlot, CtaPostMessageResolver>>> = {\n SaveAnExtra100Dollars: saveAnExtra100Dollars,\n /** The Insights 2.0 template: the same \"Make a Transfer\" op_1 as V1. */\n SaveAnExtra100DollarsV2: saveAnExtra100Dollars,\n\n /** \"Transfer to Savings\" / \"Transfer Funds\": the base `beat/cta` op_1 on both variants. */\n PaydayCashLeftOverStatus: {\n primary: () => ({ action: BEAT_OPERATION_1 }),\n },\n\n /** \"Transfer\": op_1 with the primary account's external id. No primary account → default. */\n LowAccountBalance: {\n primary: (ctx) => {\n const account = primaryAccountOf(ctx)\n\n return account\n ? { action: BEAT_OPERATION_1, payload: { account_guid: account.external_guid } }\n : null\n },\n },\n\n /** Posts only while off track (negative remaining); on track the CTA opens the drawer. */\n MonthlyObligationsStatus: {\n primary: ({ beat }) =>\n (beat.payload?.total_remaining ?? 0) < 0 ? { action: BEAT_OPERATION_1 } : null,\n },\n\n /**\n * \"Open savings account\": only when nothing is designated and there is no savings account to\n * pick from. The other states save the pick through an `action_key` (see `ctaConfig.ts`).\n */\n DesignateEmergencySavingsAccount: {\n primary: ({ beat }) =>\n !beat.payload?.emergency_savings_account_guid && !beat.account_guids.length\n ? { action: BEAT_OPERATION_1 }\n : null,\n },\n\n /** op_1 with the withdrawn total and the beat's accounts (external ids). */\n ReplenishSavings: {\n primary: (ctx) => ({\n action: BEAT_OPERATION_1,\n payload: {\n total_amount_withdrawn: ctx.beat.payload?.total_amount,\n accounts: beatAccountsOf(ctx).map((account) => ({\n account_guid: account.external_guid,\n account_name: ctx.beat.payload?.account_name?.default,\n })),\n },\n }),\n },\n\n /** op_1 = transfer into the user's savings accounts; op_2 = open one when there are none. */\n SavingsOpportunityV2: {\n primary: (ctx) => {\n const source = primaryAccountOf(ctx)\n\n if (!source) return null\n\n const savings = savingsAccountsOf(ctx)\n const payload = {\n amount: ctx.beat.payload?.suggested_savings_amount,\n source_account_id: source.external_guid,\n }\n\n return savings.length\n ? {\n action: BEAT_OPERATION_1,\n payload: {\n ...payload,\n destination_account_ids: savings.map((account) => account.external_guid),\n },\n }\n : { action: BEAT_OPERATION_2, payload }\n },\n },\n}\n\n/** Backend `cta.metadata` first, else this template's interim resolver for the slot, else null. */\nexport const resolveCtaMetadata = (ctx: CtaStateContext): CtaPostMessageMetadata | null =>\n ctx.cta.metadata ?? ctaPostMessages[ctx.beat.template]?.[ctx.slot]?.(ctx) ?? null\n"],"mappings":";;AAkBA,IAAM,IAAA,CAAY,MAChB,CAAC,EAAQ,aAAa,CAAC,EAAQ,cAAc,CAAC,EAAQ,WAGlD,IAAA,CAAoB,EAAE,MAAA,GAAM,QAAA,EAAA,MAChC,EAAK,mBACL,EAAO,aAAa,SAAS,KAAA,CAAM,MAAY,EAAQ,SAAS,EAAK,oBAAoB,GAGrF,IAAA,CAAkB,EAAE,M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