@mx-cartographer/experiences 9.7.198 → 9.7.199-alpha-moratorium
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 +7 -1
- package/dist/core/types/Insights.d.ts +1 -1
- package/dist/core/types/Insights.es.js.map +1 -1
- package/dist/core/types/localization/InsightsFeedCopy.d.ts +2 -0
- package/dist/insights/components/insights/BillAmountNotStandard/BillAmountNotStandard.es.js +4 -4
- package/dist/insights/components/insights/BillAmountNotStandard/BillAmountNotStandardMUI.es.js +4 -4
- package/dist/insights/components/insights/MonthlySpendingComparisonV2/MonthlySpendingComparisonV2.es.js +4 -4
- package/dist/insights/components/insights/WeeklyNoSpendDays/WeeklyNoSpendDays.es.js +8 -8
- package/dist/insights/components/shared/Charts/EmptyBarChart.es.js +4 -4
- package/dist/insights/components/shared/ZeroState/LinedCardZeroState.es.js +4 -4
- package/dist/insights/index.es.js +84 -84
- package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/EmergencySavingsV2.es.js +17 -17
- package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/EmergencySavingsV2.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TopMerchantsBlock/TopMerchantsBlock.d.ts +1 -5
- package/dist/insights-v2/actionBlocks/TopMerchantsBlock/TopMerchantsBlock.es.js +37 -36
- package/dist/insights-v2/actionBlocks/TopMerchantsBlock/TopMerchantsBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionDetailsBlock/layout.d.ts +9 -11
- package/dist/insights-v2/actionBlocks/TransactionDetailsBlock/layout.es.js +12 -6
- package/dist/insights-v2/actionBlocks/TransactionDetailsBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListHeaderIconTile.d.ts +3 -1
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListHeaderIconTile.es.js +12 -11
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListHeaderIconTile.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListSummaryCard.d.ts +2 -2
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListSummaryCard.es.js +13 -13
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListSummaryCard.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionListBlock/layout.d.ts +10 -4
- package/dist/insights-v2/actionBlocks/TransactionListBlock/layout.es.js +78 -71
- package/dist/insights-v2/actionBlocks/TransactionListBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/StepChartBlock/variants/MilestoneProgress.d.ts +2 -4
- package/dist/insights-v2/blocks/ChartBlocks/StepChartBlock/variants/MilestoneProgress.es.js +78 -82
- package/dist/insights-v2/blocks/ChartBlocks/StepChartBlock/variants/MilestoneProgress.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/layout.es.js +30 -24
- package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/CompactDirectDepositBlock/CompactDirectDepositBlock.d.ts +7 -0
- package/dist/insights-v2/blocks/ComponentBlocks/CompactDirectDepositBlock/CompactDirectDepositBlock.es.js +46 -0
- package/dist/insights-v2/blocks/ComponentBlocks/CompactDirectDepositBlock/CompactDirectDepositBlock.es.js.map +1 -0
- package/dist/insights-v2/blocks/ComponentBlocks/CompactDirectDepositBlock/index.d.ts +3 -0
- package/dist/insights-v2/blocks/ComponentBlocks/CompactDirectDepositBlock/layout.d.ts +10 -0
- package/dist/insights-v2/blocks/ComponentBlocks/CompactDirectDepositBlock/layout.es.js +17 -0
- package/dist/insights-v2/blocks/ComponentBlocks/CompactDirectDepositBlock/layout.es.js.map +1 -0
- package/dist/insights-v2/blocks/ComponentBlocks/DetailedAccountBlock/DetailedAccountBlock.es.js +25 -25
- package/dist/insights-v2/blocks/ComponentBlocks/DetailedAccountBlock/DetailedAccountBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/DetailedAccountBlock/layout.d.ts +0 -2
- package/dist/insights-v2/blocks/ComponentBlocks/DetailedAccountBlock/layout.es.js +17 -21
- package/dist/insights-v2/blocks/ComponentBlocks/DetailedAccountBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/MerchantBlock.es.js +46 -63
- package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/MerchantBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/layout.d.ts +3 -3
- package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/layout.es.js +44 -53
- package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/QuizBlock/QuizBlock.d.ts +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/QuizBlock/QuizBlock.es.js +30 -31
- package/dist/insights-v2/blocks/ComponentBlocks/QuizBlock/QuizBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/TransactionBlock.es.js +54 -53
- package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/TransactionBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/layout.d.ts +5 -3
- package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/layout.es.js +11 -9
- package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/WeeklySmallPurchasesBlock/WeeklySmallPurchasesBlock.es.js +28 -27
- package/dist/insights-v2/blocks/ComponentBlocks/WeeklySmallPurchasesBlock/WeeklySmallPurchasesBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/index.d.ts +1 -0
- package/dist/insights-v2/components/AccountHeroCard.d.ts +3 -1
- package/dist/insights-v2/components/AccountHeroCard.es.js.map +1 -1
- package/dist/insights-v2/components/CompactDirectDepositCard.d.ts +26 -0
- package/dist/insights-v2/components/CompactDirectDepositCard.es.js +73 -0
- package/dist/insights-v2/components/CompactDirectDepositCard.es.js.map +1 -0
- package/dist/insights-v2/components/DirectDepositCard.d.ts +6 -1
- package/dist/insights-v2/components/DirectDepositCard.es.js +22 -20
- package/dist/insights-v2/components/DirectDepositCard.es.js.map +1 -1
- package/dist/insights-v2/components/LogoFromGuid.d.ts +1 -1
- package/dist/insights-v2/components/LogoFromGuid.es.js.map +1 -1
- package/dist/insights-v2/components/MerchantHighlightCard.es.js +4 -4
- package/dist/insights-v2/components/TransactionListCard.d.ts +3 -1
- package/dist/insights-v2/components/TransactionListCard.es.js +25 -25
- package/dist/insights-v2/components/TransactionListCard.es.js.map +1 -1
- package/dist/insights-v2/components/TransferLogoCard.es.js +1 -0
- package/dist/insights-v2/components/TransferLogoCard.es.js.map +1 -1
- package/dist/insights-v2/index.es.js +120 -116
- package/dist/insights-v2/mappings/blocks.es.js +118 -116
- package/dist/insights-v2/mappings/blocks.es.js.map +1 -1
- package/dist/microinsights/cards/InsightCard.es.js +53 -53
- package/dist/microinsights/cards/InsightCard.es.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { buildDynamicCopy as W } from "../../../core/utils/Localization.es.js";
|
|
2
|
-
import { CURRENCY_FORMAT as
|
|
2
|
+
import { CURRENCY_FORMAT as T, formatCurrency as I } from "../../../core/utils/NumberFormatting.es.js";
|
|
3
3
|
import { Select as S } from "../../../common/components/Select.es.js";
|
|
4
4
|
import { SMALL_CARD_SHADOW as H } from "../../components/shared/elevation.es.js";
|
|
5
|
-
import { CADENCES as V, DEADLINE_UNITS as
|
|
5
|
+
import { CADENCES as V, DEADLINE_UNITS as f, calculateContribution as q } from "./layout.es.js";
|
|
6
6
|
import g from "react";
|
|
7
7
|
import { observer as F } from "mobx-react-lite";
|
|
8
8
|
import o from "@mui/material/Stack";
|
|
@@ -30,7 +30,7 @@ var z = [
|
|
|
30
30
|
"add_timeline",
|
|
31
31
|
"weekly",
|
|
32
32
|
"monthly"
|
|
33
|
-
],
|
|
33
|
+
], fe = (n) => z.every((e) => typeof n[e] == "string"), [$, Q, Z] = V, x = [
|
|
34
34
|
{
|
|
35
35
|
cadence: $,
|
|
36
36
|
labelKey: "weekly",
|
|
@@ -46,17 +46,17 @@ var z = [
|
|
|
46
46
|
labelKey: "monthly",
|
|
47
47
|
suffixKey: "per_month"
|
|
48
48
|
}
|
|
49
|
-
], G =
|
|
49
|
+
], G = x.findIndex(({ labelKey: n }) => n === "monthly"), J = f.findIndex(({ labelKey: n }) => n === "months"), X = "6", u = (n, ...e) => W(n, ...e), ee = (n) => n.replace(/[^0-9]/g, ""), m = (n) => I(n, T.whole), R = (n) => I(n, T.cents), xe = F(function({ copy: e, facts: k }) {
|
|
50
50
|
const { balance: s, goal: d, monthContribution: _, monthlyContribution: D, remaining: M } = k, v = s <= 0, y = d > 0 ? Math.round(Math.min(100, Math.max(0, s / d * 100))) : 0, [h, N] = g.useState(v ? "" : G), [p, K] = g.useState(v ? "" : X), [b, L] = g.useState(J), [w, O] = g.useState({
|
|
51
51
|
amount: D,
|
|
52
52
|
suffix: e.per_month
|
|
53
53
|
}), A = h !== "" && p !== "" && Number(p) > 0, B = (a) => {
|
|
54
54
|
if (a.preventDefault(), h === "") return;
|
|
55
|
-
const { cadence: c, suffixKey: Y } =
|
|
55
|
+
const { cadence: c, suffixKey: Y } = x[h], E = q({
|
|
56
56
|
balance: s,
|
|
57
57
|
goal: d,
|
|
58
58
|
cadence: c,
|
|
59
|
-
deadline:
|
|
59
|
+
deadline: f[b],
|
|
60
60
|
deadlineQuantity: Number(p)
|
|
61
61
|
});
|
|
62
62
|
E !== void 0 && O({
|
|
@@ -198,8 +198,8 @@ var z = [
|
|
|
198
198
|
onSubmit: B,
|
|
199
199
|
sx: {
|
|
200
200
|
bgcolor: "background.paper",
|
|
201
|
-
borderColor: "divider",
|
|
202
201
|
borderTop: "1px solid",
|
|
202
|
+
borderTopColor: "divider",
|
|
203
203
|
gap: 32,
|
|
204
204
|
p: 24
|
|
205
205
|
},
|
|
@@ -221,16 +221,16 @@ var z = [
|
|
|
221
221
|
children: /* @__PURE__ */ r(i, {
|
|
222
222
|
color: "text.secondary",
|
|
223
223
|
sx: {
|
|
224
|
-
letterSpacing: "0.
|
|
224
|
+
letterSpacing: "0.33px",
|
|
225
225
|
textTransform: "uppercase"
|
|
226
226
|
},
|
|
227
227
|
variant: "caption",
|
|
228
228
|
children: u(e.next_savings_goal, /* @__PURE__ */ r(i, {
|
|
229
|
-
bold: !0,
|
|
230
229
|
component: "span",
|
|
231
230
|
sx: {
|
|
232
231
|
color: "text.primary",
|
|
233
|
-
fontSize: "inherit"
|
|
232
|
+
fontSize: "inherit",
|
|
233
|
+
fontWeight: "fontWeightBold"
|
|
234
234
|
},
|
|
235
235
|
children: m(d)
|
|
236
236
|
}, "goal"))
|
|
@@ -239,8 +239,8 @@ var z = [
|
|
|
239
239
|
sx: {
|
|
240
240
|
alignItems: "center",
|
|
241
241
|
bgcolor: "background.default",
|
|
242
|
-
borderColor: "divider",
|
|
243
242
|
borderTop: "1px solid",
|
|
243
|
+
borderTopColor: "divider",
|
|
244
244
|
p: 12
|
|
245
245
|
},
|
|
246
246
|
children: [/* @__PURE__ */ t(o, {
|
|
@@ -279,7 +279,7 @@ var z = [
|
|
|
279
279
|
/* @__PURE__ */ r(S, {
|
|
280
280
|
label: e.how_often_will_you_contribute,
|
|
281
281
|
onChange: N,
|
|
282
|
-
options:
|
|
282
|
+
options: x.map(({ labelKey: a }, c) => ({
|
|
283
283
|
id: c,
|
|
284
284
|
label: e[a]
|
|
285
285
|
})),
|
|
@@ -288,7 +288,7 @@ var z = [
|
|
|
288
288
|
inputLabel: { shrink: !0 },
|
|
289
289
|
select: {
|
|
290
290
|
displayEmpty: !0,
|
|
291
|
-
renderValue: (a) => a === "" ? e.select_frequency : e[
|
|
291
|
+
renderValue: (a) => a === "" ? e.select_frequency : e[x[a].labelKey]
|
|
292
292
|
}
|
|
293
293
|
},
|
|
294
294
|
value: h
|
|
@@ -317,8 +317,8 @@ var z = [
|
|
|
317
317
|
}), /* @__PURE__ */ r(S, {
|
|
318
318
|
label: "",
|
|
319
319
|
onChange: L,
|
|
320
|
-
slotProps: { select: { SelectDisplayProps: { "aria-label": e[
|
|
321
|
-
options:
|
|
320
|
+
slotProps: { select: { SelectDisplayProps: { "aria-label": e[f[b].labelKey] } } },
|
|
321
|
+
options: f.map(({ labelKey: a }, c) => ({
|
|
322
322
|
id: c,
|
|
323
323
|
label: e[a]
|
|
324
324
|
})),
|
|
@@ -345,8 +345,8 @@ var z = [
|
|
|
345
345
|
});
|
|
346
346
|
});
|
|
347
347
|
export {
|
|
348
|
-
|
|
349
|
-
|
|
348
|
+
xe as EmergencySavingsV2,
|
|
349
|
+
fe as hasV2Copy
|
|
350
350
|
};
|
|
351
351
|
|
|
352
352
|
//# sourceMappingURL=EmergencySavingsV2.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmergencySavingsV2.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/EmergencySavingsBlock/EmergencySavingsV2.tsx"],"sourcesContent":["import React, { type ReactNode } from 'react'\nimport { observer } from 'mobx-react-lite'\n\nimport Box from '@mui/material/Box'\nimport Button from '@mui/material/Button'\nimport Stack from '@mui/material/Stack'\nimport TextField from '@mui/material/TextField'\nimport { alpha } from '@mui/material/styles'\n\nimport { Text } from '@mxenabled/mxui'\nimport { Icon } from '@mxenabled/mx-icons'\n\nimport { Select } from '../../../common'\nimport { buildDynamicCopy } from '../../../core'\nimport type { EmergencySavingsCopy } from '../../../core'\nimport { CURRENCY_FORMAT, formatCurrency } from '../../../core/utils/NumberFormatting'\nimport { SMALL_CARD_SHADOW } from '../../components/shared/elevation'\n\nimport { CADENCES, calculateContribution, DEADLINE_UNITS } from './layout'\n\nconst V2_COPY_KEYS = [\n 'your_progress',\n 'more_to_go',\n 'saved_amount',\n 'goal_amount',\n 'contributed_this_month',\n 'increase_your_transfer',\n 'next_savings_goal',\n 'per_month',\n 'per_week',\n 'per_two_weeks',\n 'use_the_calculator',\n 'how_often_will_you_contribute',\n 'select_frequency',\n 'add_timeline',\n 'weekly',\n 'monthly',\n] as const\n\n/** The drawer's copy with every V2 key present. */\nexport type EmergencySavingsV2Copy = EmergencySavingsCopy &\n Required<Pick<EmergencySavingsCopy, (typeof V2_COPY_KEYS)[number]>>\n\n/** True once mrs_content ships the V2 drawer's words; otherwise the legacy drawer opens. */\nexport const hasV2Copy = (copy: EmergencySavingsCopy): copy is EmergencySavingsV2Copy =>\n V2_COPY_KEYS.every((key) => typeof copy[key] === 'string')\n\n/** The figures the V2 card's CTA carries (ditto monthly_emergency_savings_reminder_v2.yml). */\nexport interface EmergencySavingsFacts {\n balance: number\n goal: number\n remaining: number\n monthlyContribution: number\n monthContribution: number\n}\n\nconst [WEEKLY, EVERY_OTHER_WEEK, MONTHLY_CADENCE] = CADENCES\n\n// Figma 1152:27224: the frequency select (weekly / every other week / monthly).\nconst FREQUENCIES = [\n { cadence: WEEKLY, labelKey: 'weekly', suffixKey: 'per_week' },\n { cadence: EVERY_OTHER_WEEK, labelKey: 'every_other_week', suffixKey: 'per_two_weeks' },\n { cadence: MONTHLY_CADENCE, labelKey: 'monthly', suffixKey: 'per_month' },\n] as const\nconst MONTHLY = FREQUENCIES.findIndex(({ labelKey }) => labelKey === 'monthly')\nconst MONTHS = DEADLINE_UNITS.findIndex(({ labelKey }) => labelKey === 'months')\n// The card's monthly_contribution spreads what's left over six months, so the form starts there.\nconst DEFAULT_TIMELINE_MONTHS = '6'\n\n/** Rich copy (`_1{amount}` with an element) as a node. */\nconst rich = (copy: string, ...args: Parameters<typeof buildDynamicCopy>[1][]) =>\n buildDynamicCopy(copy, ...args) as ReactNode\n\nconst toDigits = (value: string) => value.replace(/[^0-9]/g, '')\nconst whole = (amount: number) => formatCurrency(amount, CURRENCY_FORMAT.whole)\nconst cents = (amount: number) => formatCurrency(amount, CURRENCY_FORMAT.cents)\n\ninterface Props {\n copy: EmergencySavingsV2Copy\n facts: EmergencySavingsFacts\n}\n\n/** The Build Emergency Savings drawer (Figma 1152:27224): progress, the month banner, the estimate and calculator. */\nexport const EmergencySavingsV2 = observer(function EmergencySavingsV2({ copy, facts }: Props) {\n const { balance, goal, monthContribution, monthlyContribution, remaining } = facts\n const isZeroState = balance <= 0\n const percent = goal > 0 ? Math.round(Math.min(100, Math.max(0, (balance / goal) * 100))) : 0\n\n // The zero state opens empty (Select frequency / Add timeline).\n const [frequency, setFrequency] = React.useState<number | ''>(isZeroState ? '' : MONTHLY)\n const [timeline, setTimeline] = React.useState(isZeroState ? '' : DEFAULT_TIMELINE_MONTHS)\n const [unit, setUnit] = React.useState(MONTHS)\n const [estimate, setEstimate] = React.useState({\n amount: monthlyContribution,\n suffix: copy.per_month,\n })\n\n const canCalculate = frequency !== '' && timeline !== '' && Number(timeline) > 0\n\n const handleSubmit = (event: React.FormEvent) => {\n event.preventDefault()\n if (frequency === '') return\n\n const { cadence, suffixKey } = FREQUENCIES[frequency]\n const amount = calculateContribution({\n balance,\n goal,\n cadence,\n deadline: DEADLINE_UNITS[unit],\n deadlineQuantity: Number(timeline),\n })\n if (amount !== undefined) setEstimate({ amount, suffix: copy[suffixKey] })\n }\n\n return (\n <Stack sx={{ bgcolor: 'background.default' }}>\n <Box sx={{ p: 24 }}>\n <Stack\n aria-label={copy.your_progress}\n role=\"region\"\n sx={{\n bgcolor: 'background.paper',\n borderRadius: '8px',\n boxShadow: SMALL_CARD_SHADOW,\n gap: 16,\n p: 16,\n }}\n >\n <Stack sx={{ gap: 12 }}>\n <Stack sx={{ alignItems: 'center', flexDirection: 'row', gap: 8 }}>\n <Box\n aria-hidden={true}\n sx={(theme) => ({\n alignItems: 'center',\n bgcolor: alpha(theme.palette.primary.main, 0.15),\n borderRadius: '4px',\n display: 'flex',\n flexShrink: 0,\n height: 40,\n justifyContent: 'center',\n width: 40,\n })}\n >\n <Icon color=\"primary\" name=\"savings\" size={20} />\n </Box>\n <Stack>\n <Text variant=\"caption\">{copy.your_progress}</Text>\n <Text component=\"p\" variant=\"body2\">\n {rich(\n copy.more_to_go,\n <Text\n component=\"span\"\n key=\"amount\"\n sx={{ fontWeight: 'fontWeightBold' }}\n variant=\"h2\"\n >\n {whole(remaining)}\n </Text>,\n )}\n </Text>\n </Stack>\n </Stack>\n <Stack sx={{ gap: 4 }}>\n <Box\n aria-label={buildDynamicCopy(copy.saved_amount, whole(balance)) as string}\n aria-valuemax={100}\n aria-valuemin={0}\n aria-valuenow={percent}\n role=\"progressbar\"\n sx={{ bgcolor: 'divider', borderRadius: '6px', height: 8, overflow: 'hidden' }}\n >\n <Box\n sx={{\n bgcolor: 'primary.main',\n borderRadius: '6px',\n height: '100%',\n width: `${percent}%`,\n }}\n />\n </Box>\n <Stack sx={{ flexDirection: 'row', justifyContent: 'space-between' }}>\n <Text color=\"text.secondary\" variant=\"caption\">\n {rich(copy.saved_amount, whole(balance))}\n </Text>\n <Text color=\"text.secondary\" variant=\"caption\">\n {rich(copy.goal_amount, whole(goal))}\n </Text>\n </Stack>\n </Stack>\n </Stack>\n {monthContribution > 0 && (\n <Stack\n role=\"note\"\n sx={{\n alignItems: 'flex-start',\n bgcolor: 'primary.lighter',\n borderRadius: '8px',\n flexDirection: 'row',\n gap: 8,\n p: 12,\n }}\n >\n <Box sx={{ pt: 2, px: 4 }}>\n <Icon aria-hidden={true} color=\"primary\" name=\"celebration\" size={20} />\n </Box>\n <Text\n color=\"primary.dark\"\n component=\"p\"\n sx={{ fontWeight: 'fontWeightRegular' }}\n variant=\"subtitle2\"\n >\n {rich(\n copy.contributed_this_month,\n <Text\n component=\"span\"\n key=\"amount\"\n sx={{ fontSize: 'inherit', fontWeight: 'fontWeightBold' }}\n >\n {cents(monthContribution)}\n </Text>,\n )}{' '}\n {copy.increase_your_transfer}\n </Text>\n </Stack>\n )}\n </Stack>\n </Box>\n <Stack\n component=\"form\"\n onSubmit={handleSubmit}\n sx={{\n bgcolor: 'background.paper',\n borderColor: 'divider',\n borderTop: '1px solid',\n gap: 32,\n p: 24,\n }}\n >\n <Stack sx={{ gap: 8 }}>\n <Stack\n aria-label={copy.estimated_contribution}\n role=\"group\"\n sx={{ border: '1px solid', borderColor: 'divider', borderRadius: '4px' }}\n >\n <Box sx={{ px: 8, py: 4 }}>\n <Text\n color=\"text.secondary\"\n sx={{ letterSpacing: '0.4px', textTransform: 'uppercase' }}\n variant=\"caption\"\n >\n {rich(\n copy.next_savings_goal,\n <Text\n bold={true}\n component=\"span\"\n key=\"goal\"\n sx={{ color: 'text.primary', fontSize: 'inherit' }}\n >\n {whole(goal)}\n </Text>,\n )}\n </Text>\n </Box>\n <Stack\n sx={{\n alignItems: 'center',\n bgcolor: 'background.default',\n borderColor: 'divider',\n borderTop: '1px solid',\n p: 12,\n }}\n >\n <Stack sx={{ alignItems: 'flex-end', flexDirection: 'row', gap: 4 }}>\n <Text component=\"p\" sx={{ fontWeight: 'fontWeightBold' }} variant=\"h2\">\n {cents(estimate.amount)}\n </Text>\n <Text sx={{ fontWeight: 'fontWeightRegular' }} variant=\"subtitle2\">\n {estimate.suffix}\n </Text>\n </Stack>\n <Text\n color=\"text.secondary\"\n sx={{ fontWeight: 'fontWeightRegular' }}\n variant=\"subtitle2\"\n >\n {copy.estimated_contribution}\n </Text>\n </Stack>\n </Stack>\n <Text\n color=\"text.secondary\"\n sx={{ textAlign: 'center' }}\n truncate={false}\n variant=\"caption\"\n >\n {copy.use_the_calculator}\n </Text>\n </Stack>\n <Stack sx={{ gap: 16 }}>\n <Select\n label={copy.how_often_will_you_contribute}\n onChange={setFrequency}\n options={FREQUENCIES.map(({ labelKey }, id) => ({ id, label: copy[labelKey] }))}\n required={true}\n slotProps={{\n inputLabel: { shrink: true },\n select: {\n displayEmpty: true,\n renderValue: (v: unknown) =>\n v === '' ? copy.select_frequency : copy[FREQUENCIES[v as number].labelKey],\n },\n }}\n value={frequency}\n />\n <Stack aria-label={copy.meet_your_goal_within} role=\"group\" sx={{ flexDirection: 'row' }}>\n <TextField\n fullWidth={true}\n label={copy.meet_your_goal_within}\n onChange={(event) => setTimeline(toDigits(event.target.value))}\n placeholder={copy.add_timeline}\n slotProps={{\n htmlInput: { inputMode: 'numeric', pattern: '[0-9]*' },\n inputLabel: { shrink: true },\n }}\n sx={{\n '& .MuiOutlinedInput-root': { borderBottomRightRadius: 0, borderTopRightRadius: 0 },\n }}\n value={timeline}\n />\n <Select\n label=\"\"\n onChange={setUnit}\n slotProps={{\n select: {\n SelectDisplayProps: { 'aria-label': copy[DEADLINE_UNITS[unit].labelKey] },\n },\n }}\n options={DEADLINE_UNITS.map(({ labelKey }, id) => ({ id, label: copy[labelKey] }))}\n sx={{\n minWidth: 120,\n '& .MuiOutlinedInput-root': { borderBottomLeftRadius: 0, borderTopLeftRadius: 0 },\n }}\n value={unit}\n />\n </Stack>\n <Button disabled={!canCalculate} fullWidth={true} type=\"submit\" variant=\"contained\">\n {copy.calculate}\n </Button>\n </Stack>\n </Stack>\n </Stack>\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;AAoBA,IAAM,IAAe;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAOa,KAAA,CAAa,MACxB,EAAa,MAAA,CAAO,MAAQ,OAAO,EAAK,CAAA,KAAS,QAAQ,GAWrD,CAAC,GAAQ,GAAkB,CAAA,IAAmB,GAG9C,IAAc;AAAA,EAClB;AAAA,IAAE,SAAS;AAAA,IAAQ,UAAU;AAAA,IAAU,WAAW;AAAA,EAAW;AAAA,EAC7D;AAAA,IAAE,SAAS;AAAA,IAAkB,UAAU;AAAA,IAAoB,WAAW;AAAA,EAAgB;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,aAAa,EAAK;AAAA,cAClB,WAAW;AAAA,gBACT,WAAW;AAAA,kBAAE,WAAW;AAAA,kBAAW,SAAS;AAAA,gBAAS;AAAA,gBACrD,YAAY,EAAE,QAAQ,GAAK;AAAA,cAC7B;AAAA,cACA,IAAI,EACF,4BAA4B;AAAA,gBAAE,yBAAyB;AAAA,gBAAG,sBAAsB;AAAA,cAAE,EACpF;AAAA,cACA,OAAO;AAAA,YACR,CAAA,GACD,gBAAA,EAAC,GAAD;AAAA,cACE,OAAM;AAAA,cACN,UAAU;AAAA,cACV,WAAW,EACT,QAAQ,EACN,oBAAoB,EAAE,cAAc,EAAK,EAAe,CAAA,EAAM,QAAA,EAAU,EAC1E,EACF;AAAA,cACA,SAAS,EAAe,IAAA,CAAK,EAAE,UAAA,EAAA,GAAY,OAAQ;AAAA,gBAAE,IAAA;AAAA,gBAAI,OAAO,EAAK,CAAA;AAAA,cAAU,EAAE;AAAA,cACjF,IAAI;AAAA,gBACF,UAAU;AAAA,gBACV,4BAA4B;AAAA,kBAAE,wBAAwB;AAAA,kBAAG,qBAAqB;AAAA,gBAAE;AAAA,cAClF;AAAA,cACA,OAAO;AAAA,YACR,CAAA,CACI;AAAA;UACP,gBAAA,EAAC,GAAD;AAAA,YAAQ,UAAU,CAAC;AAAA,YAAc,WAAW;AAAA,YAAM,MAAK;AAAA,YAAS,SAAQ;AAAA,YACrE,UAAA,EAAK;AAAA,UACA,CAAA;AAAA,QACH;AAAA,MACF,CAAA,CAAA;AAAA,IACF,CAAA,CAAA;AAAA;AAEX,CAAC"}
|
|
1
|
+
{"version":3,"file":"EmergencySavingsV2.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/EmergencySavingsBlock/EmergencySavingsV2.tsx"],"sourcesContent":["import React, { type ReactNode } from 'react'\nimport { observer } from 'mobx-react-lite'\n\nimport Box from '@mui/material/Box'\nimport Button from '@mui/material/Button'\nimport Stack from '@mui/material/Stack'\nimport TextField from '@mui/material/TextField'\nimport { alpha } from '@mui/material/styles'\n\nimport { Text } from '@mxenabled/mxui'\nimport { Icon } from '@mxenabled/mx-icons'\n\nimport { Select } from '../../../common'\nimport { buildDynamicCopy } from '../../../core'\nimport type { EmergencySavingsCopy } from '../../../core'\nimport { CURRENCY_FORMAT, formatCurrency } from '../../../core/utils/NumberFormatting'\nimport { SMALL_CARD_SHADOW } from '../../components/shared/elevation'\n\nimport { CADENCES, calculateContribution, DEADLINE_UNITS } from './layout'\n\nconst V2_COPY_KEYS = [\n 'your_progress',\n 'more_to_go',\n 'saved_amount',\n 'goal_amount',\n 'contributed_this_month',\n 'increase_your_transfer',\n 'next_savings_goal',\n 'per_month',\n 'per_week',\n 'per_two_weeks',\n 'use_the_calculator',\n 'how_often_will_you_contribute',\n 'select_frequency',\n 'add_timeline',\n 'weekly',\n 'monthly',\n] as const\n\n/** The drawer's copy with every V2 key present. */\nexport type EmergencySavingsV2Copy = EmergencySavingsCopy &\n Required<Pick<EmergencySavingsCopy, (typeof V2_COPY_KEYS)[number]>>\n\n/** True once mrs_content ships the V2 drawer's words; otherwise the legacy drawer opens. */\nexport const hasV2Copy = (copy: EmergencySavingsCopy): copy is EmergencySavingsV2Copy =>\n V2_COPY_KEYS.every((key) => typeof copy[key] === 'string')\n\n/** The figures the V2 card's CTA carries (ditto monthly_emergency_savings_reminder_v2.yml). */\nexport interface EmergencySavingsFacts {\n balance: number\n goal: number\n remaining: number\n monthlyContribution: number\n monthContribution: number\n}\n\nconst [WEEKLY, EVERY_OTHER_WEEK, MONTHLY_CADENCE] = CADENCES\n\n// Figma 1152:27224: the frequency select (weekly / every other week / monthly).\nconst FREQUENCIES = [\n { cadence: WEEKLY, labelKey: 'weekly', suffixKey: 'per_week' },\n { cadence: EVERY_OTHER_WEEK, labelKey: 'every_other_week', suffixKey: 'per_two_weeks' },\n { cadence: MONTHLY_CADENCE, labelKey: 'monthly', suffixKey: 'per_month' },\n] as const\nconst MONTHLY = FREQUENCIES.findIndex(({ labelKey }) => labelKey === 'monthly')\nconst MONTHS = DEADLINE_UNITS.findIndex(({ labelKey }) => labelKey === 'months')\n// The card's monthly_contribution spreads what's left over six months, so the form starts there.\nconst DEFAULT_TIMELINE_MONTHS = '6'\n\n/** Rich copy (`_1{amount}` with an element) as a node. */\nconst rich = (copy: string, ...args: Parameters<typeof buildDynamicCopy>[1][]) =>\n buildDynamicCopy(copy, ...args) as ReactNode\n\nconst toDigits = (value: string) => value.replace(/[^0-9]/g, '')\nconst whole = (amount: number) => formatCurrency(amount, CURRENCY_FORMAT.whole)\nconst cents = (amount: number) => formatCurrency(amount, CURRENCY_FORMAT.cents)\n\ninterface Props {\n copy: EmergencySavingsV2Copy\n facts: EmergencySavingsFacts\n}\n\n/** The Build Emergency Savings drawer (Figma 1152:27224): progress, the month banner, the estimate and calculator. */\nexport const EmergencySavingsV2 = observer(function EmergencySavingsV2({ copy, facts }: Props) {\n const { balance, goal, monthContribution, monthlyContribution, remaining } = facts\n const isZeroState = balance <= 0\n const percent = goal > 0 ? Math.round(Math.min(100, Math.max(0, (balance / goal) * 100))) : 0\n\n // The zero state opens empty (Select frequency / Add timeline).\n const [frequency, setFrequency] = React.useState<number | ''>(isZeroState ? '' : MONTHLY)\n const [timeline, setTimeline] = React.useState(isZeroState ? '' : DEFAULT_TIMELINE_MONTHS)\n const [unit, setUnit] = React.useState(MONTHS)\n const [estimate, setEstimate] = React.useState({\n amount: monthlyContribution,\n suffix: copy.per_month,\n })\n\n const canCalculate = frequency !== '' && timeline !== '' && Number(timeline) > 0\n\n const handleSubmit = (event: React.FormEvent) => {\n event.preventDefault()\n if (frequency === '') return\n\n const { cadence, suffixKey } = FREQUENCIES[frequency]\n const amount = calculateContribution({\n balance,\n goal,\n cadence,\n deadline: DEADLINE_UNITS[unit],\n deadlineQuantity: Number(timeline),\n })\n if (amount !== undefined) setEstimate({ amount, suffix: copy[suffixKey] })\n }\n\n return (\n <Stack sx={{ bgcolor: 'background.default' }}>\n <Box sx={{ p: 24 }}>\n <Stack\n aria-label={copy.your_progress}\n role=\"region\"\n sx={{\n bgcolor: 'background.paper',\n borderRadius: '8px',\n boxShadow: SMALL_CARD_SHADOW,\n gap: 16,\n p: 16,\n }}\n >\n <Stack sx={{ gap: 12 }}>\n <Stack sx={{ alignItems: 'center', flexDirection: 'row', gap: 8 }}>\n <Box\n aria-hidden={true}\n sx={(theme) => ({\n alignItems: 'center',\n bgcolor: alpha(theme.palette.primary.main, 0.15),\n borderRadius: '4px',\n display: 'flex',\n flexShrink: 0,\n height: 40,\n justifyContent: 'center',\n width: 40,\n })}\n >\n <Icon color=\"primary\" name=\"savings\" size={20} />\n </Box>\n <Stack>\n <Text variant=\"caption\">{copy.your_progress}</Text>\n <Text component=\"p\" variant=\"body2\">\n {rich(\n copy.more_to_go,\n <Text\n component=\"span\"\n key=\"amount\"\n sx={{ fontWeight: 'fontWeightBold' }}\n variant=\"h2\"\n >\n {whole(remaining)}\n </Text>,\n )}\n </Text>\n </Stack>\n </Stack>\n <Stack sx={{ gap: 4 }}>\n <Box\n aria-label={buildDynamicCopy(copy.saved_amount, whole(balance)) as string}\n aria-valuemax={100}\n aria-valuemin={0}\n aria-valuenow={percent}\n role=\"progressbar\"\n sx={{ bgcolor: 'divider', borderRadius: '6px', height: 8, overflow: 'hidden' }}\n >\n <Box\n sx={{\n bgcolor: 'primary.main',\n borderRadius: '6px',\n height: '100%',\n width: `${percent}%`,\n }}\n />\n </Box>\n <Stack sx={{ flexDirection: 'row', justifyContent: 'space-between' }}>\n <Text color=\"text.secondary\" variant=\"caption\">\n {rich(copy.saved_amount, whole(balance))}\n </Text>\n <Text color=\"text.secondary\" variant=\"caption\">\n {rich(copy.goal_amount, whole(goal))}\n </Text>\n </Stack>\n </Stack>\n </Stack>\n {monthContribution > 0 && (\n <Stack\n role=\"note\"\n sx={{\n alignItems: 'flex-start',\n bgcolor: 'primary.lighter',\n borderRadius: '8px',\n flexDirection: 'row',\n gap: 8,\n p: 12,\n }}\n >\n <Box sx={{ pt: 2, px: 4 }}>\n <Icon aria-hidden={true} color=\"primary\" name=\"celebration\" size={20} />\n </Box>\n <Text\n color=\"primary.dark\"\n component=\"p\"\n sx={{ fontWeight: 'fontWeightRegular' }}\n variant=\"subtitle2\"\n >\n {rich(\n copy.contributed_this_month,\n <Text\n component=\"span\"\n key=\"amount\"\n sx={{ fontSize: 'inherit', fontWeight: 'fontWeightBold' }}\n >\n {cents(monthContribution)}\n </Text>,\n )}{' '}\n {copy.increase_your_transfer}\n </Text>\n </Stack>\n )}\n </Stack>\n </Box>\n <Stack\n component=\"form\"\n onSubmit={handleSubmit}\n sx={{\n bgcolor: 'background.paper',\n borderTop: '1px solid',\n borderTopColor: 'divider',\n gap: 32,\n p: 24,\n }}\n >\n <Stack sx={{ gap: 8 }}>\n <Stack\n aria-label={copy.estimated_contribution}\n role=\"group\"\n sx={{ border: '1px solid', borderColor: 'divider', borderRadius: '4px' }}\n >\n <Box sx={{ px: 8, py: 4 }}>\n <Text\n color=\"text.secondary\"\n sx={{ letterSpacing: '0.33px', textTransform: 'uppercase' }}\n variant=\"caption\"\n >\n {rich(\n copy.next_savings_goal,\n <Text\n component=\"span\"\n key=\"goal\"\n sx={{\n color: 'text.primary',\n fontSize: 'inherit',\n fontWeight: 'fontWeightBold',\n }}\n >\n {whole(goal)}\n </Text>,\n )}\n </Text>\n </Box>\n <Stack\n sx={{\n alignItems: 'center',\n bgcolor: 'background.default',\n borderTop: '1px solid',\n borderTopColor: 'divider',\n p: 12,\n }}\n >\n <Stack sx={{ alignItems: 'flex-end', flexDirection: 'row', gap: 4 }}>\n <Text component=\"p\" sx={{ fontWeight: 'fontWeightBold' }} variant=\"h2\">\n {cents(estimate.amount)}\n </Text>\n <Text sx={{ fontWeight: 'fontWeightRegular' }} variant=\"subtitle2\">\n {estimate.suffix}\n </Text>\n </Stack>\n <Text\n color=\"text.secondary\"\n sx={{ fontWeight: 'fontWeightRegular' }}\n variant=\"subtitle2\"\n >\n {copy.estimated_contribution}\n </Text>\n </Stack>\n </Stack>\n <Text\n color=\"text.secondary\"\n sx={{ textAlign: 'center' }}\n truncate={false}\n variant=\"caption\"\n >\n {copy.use_the_calculator}\n </Text>\n </Stack>\n <Stack sx={{ gap: 16 }}>\n <Select\n label={copy.how_often_will_you_contribute}\n onChange={setFrequency}\n options={FREQUENCIES.map(({ labelKey }, id) => ({ id, label: copy[labelKey] }))}\n required={true}\n slotProps={{\n inputLabel: { shrink: true },\n select: {\n displayEmpty: true,\n renderValue: (v: unknown) =>\n v === '' ? copy.select_frequency : copy[FREQUENCIES[v as number].labelKey],\n },\n }}\n value={frequency}\n />\n <Stack aria-label={copy.meet_your_goal_within} role=\"group\" sx={{ flexDirection: 'row' }}>\n <TextField\n fullWidth={true}\n label={copy.meet_your_goal_within}\n onChange={(event) => setTimeline(toDigits(event.target.value))}\n placeholder={copy.add_timeline}\n slotProps={{\n htmlInput: { inputMode: 'numeric', pattern: '[0-9]*' },\n inputLabel: { shrink: true },\n }}\n sx={{\n '& .MuiOutlinedInput-root': { borderBottomRightRadius: 0, borderTopRightRadius: 0 },\n }}\n value={timeline}\n />\n <Select\n label=\"\"\n onChange={setUnit}\n slotProps={{\n select: {\n SelectDisplayProps: { 'aria-label': copy[DEADLINE_UNITS[unit].labelKey] },\n },\n }}\n options={DEADLINE_UNITS.map(({ labelKey }, id) => ({ id, label: copy[labelKey] }))}\n sx={{\n minWidth: 120,\n '& .MuiOutlinedInput-root': { borderBottomLeftRadius: 0, borderTopLeftRadius: 0 },\n }}\n value={unit}\n />\n </Stack>\n <Button disabled={!canCalculate} fullWidth={true} type=\"submit\" variant=\"contained\">\n {copy.calculate}\n </Button>\n </Stack>\n </Stack>\n </Stack>\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;AAoBA,IAAM,IAAe;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,E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,MACF,CAAA,CAAA;AAAA,IACF,CAAA,CAAA;AAAA;AAEX,CAAC"}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { GlobalCopy, TopMerchantsCopy } from '../../../core';
|
|
2
2
|
import { ActionBlockProps } from '../../mappings/blocks';
|
|
3
3
|
export declare const selectTopMerchantsCopy: (copy: GlobalCopy) => TopMerchantsCopy | undefined;
|
|
4
|
-
/**
|
|
5
|
-
* Monthly Top Merchant Spending's Top Merchants drawer (Figma 1273:34553): the month's total over
|
|
6
|
-
* up to ten ranked merchants. A row opens that merchant's Merchant History (Transaction History,
|
|
7
|
-
* `top_merchant` variant) in a nested drawer, whose rows open Transaction Details.
|
|
8
|
-
*/
|
|
4
|
+
/** Top Merchants drawer: the month's total over the ranked merchants; a row opens its Merchant History. */
|
|
9
5
|
export declare const TopMerchantsBlock: (({ beat }: ActionBlockProps) => import("react/jsx-runtime").JSX.Element) & {
|
|
10
6
|
displayName: string;
|
|
11
7
|
};
|
|
@@ -3,23 +3,23 @@ import { useGlobalCopyStore as R, useTransactionStore as A } from "../../../comm
|
|
|
3
3
|
import { CURRENCY_FORMAT as _, formatCurrency as x } from "../../../core/utils/NumberFormatting.es.js";
|
|
4
4
|
import E from "../../../common/components/drawer/Drawer.es.js";
|
|
5
5
|
import { ELEVATION_SHADOW as F } from "../../components/shared/elevation.es.js";
|
|
6
|
-
import
|
|
7
|
-
import { useOpenedCta as
|
|
8
|
-
import { useRequiredCopy as
|
|
6
|
+
import H from "../../components/LogoMark.es.js";
|
|
7
|
+
import { useOpenedCta as N } from "../useOpenedCta.es.js";
|
|
8
|
+
import { useRequiredCopy as G } from "../useRequiredCopy.es.js";
|
|
9
9
|
import { TransactionHistoryBlock as L } from "../TransactionHistoryBlock/TransactionHistoryBlock.es.js";
|
|
10
10
|
import { TransactionListHeaderIconTile as D } from "../TransactionListBlock/TransactionListHeaderIconTile.es.js";
|
|
11
11
|
import { merchantHistoryCta as I, readTopMerchants as U } from "./layout.es.js";
|
|
12
|
-
import
|
|
12
|
+
import l from "react";
|
|
13
13
|
import { observer as j } from "mobx-react-lite";
|
|
14
|
-
import
|
|
15
|
-
import { Text as
|
|
14
|
+
import d from "@mui/material/Stack";
|
|
15
|
+
import { H2 as z, Text as m } from "@mxenabled/mxui";
|
|
16
16
|
import { Icon as P } from "@mxenabled/mx-icons";
|
|
17
|
-
import { Fragment as W, jsx as o, jsxs as
|
|
17
|
+
import { Fragment as W, jsx as o, jsxs as i } from "react/jsx-runtime";
|
|
18
18
|
import f from "@mui/material/Box";
|
|
19
19
|
import Y from "@mui/material/ButtonBase";
|
|
20
|
-
var $ = (
|
|
21
|
-
const
|
|
22
|
-
return /* @__PURE__ */
|
|
20
|
+
var $ = (a) => a.insights_feed?.top_merchants, V = "_1{count} transactions", q = "_1{count} transaction", J = ({ copy: a, countCopy: n, merchant: t, onClick: p }) => {
|
|
21
|
+
const c = w(a.rank_merchant, String(t.rank), t.merchantName), u = B(n.one, n.many, t.transactionCount, String(t.transactionCount));
|
|
22
|
+
return /* @__PURE__ */ i(Y, {
|
|
23
23
|
onClick: () => p(t),
|
|
24
24
|
sx: {
|
|
25
25
|
borderBottom: 1,
|
|
@@ -40,7 +40,7 @@ var $ = (c) => c.insights_feed?.top_merchants, z = "_1{count} transactions", V =
|
|
|
40
40
|
display: "flex",
|
|
41
41
|
flexShrink: 0
|
|
42
42
|
},
|
|
43
|
-
children: /* @__PURE__ */ o(
|
|
43
|
+
children: /* @__PURE__ */ o(H, {
|
|
44
44
|
logo: {
|
|
45
45
|
category_guid: t.categoryGuid,
|
|
46
46
|
merchant_guid: t.merchantGuid,
|
|
@@ -49,24 +49,24 @@ var $ = (c) => c.insights_feed?.top_merchants, z = "_1{count} transactions", V =
|
|
|
49
49
|
size: 32
|
|
50
50
|
})
|
|
51
51
|
}),
|
|
52
|
-
/* @__PURE__ */
|
|
52
|
+
/* @__PURE__ */ i(d, {
|
|
53
53
|
sx: {
|
|
54
54
|
flexGrow: 1,
|
|
55
55
|
minWidth: 0
|
|
56
56
|
},
|
|
57
|
-
children: [/* @__PURE__ */ o(
|
|
57
|
+
children: [/* @__PURE__ */ o(m, {
|
|
58
58
|
bold: !0,
|
|
59
59
|
component: "span",
|
|
60
60
|
truncate: !0,
|
|
61
61
|
variant: "body1",
|
|
62
|
-
children:
|
|
63
|
-
}), /* @__PURE__ */ o(
|
|
62
|
+
children: c
|
|
63
|
+
}), /* @__PURE__ */ o(m, {
|
|
64
64
|
component: "span",
|
|
65
65
|
variant: "caption",
|
|
66
66
|
children: u
|
|
67
67
|
})]
|
|
68
68
|
}),
|
|
69
|
-
/* @__PURE__ */ o(
|
|
69
|
+
/* @__PURE__ */ o(m, {
|
|
70
70
|
component: "span",
|
|
71
71
|
sx: { flexShrink: 0 },
|
|
72
72
|
variant: "body1",
|
|
@@ -80,24 +80,24 @@ var $ = (c) => c.insights_feed?.top_merchants, z = "_1{count} transactions", V =
|
|
|
80
80
|
})
|
|
81
81
|
]
|
|
82
82
|
});
|
|
83
|
-
},
|
|
84
|
-
const t =
|
|
85
|
-
many:
|
|
86
|
-
one:
|
|
83
|
+
}, go = j(function({ beat: n }) {
|
|
84
|
+
const t = G($), { common: p, insights_feed: c } = R(), u = N(n), s = A(), r = l.useRef(null), [h, g] = l.useState(), [C, y] = l.useState(), { describedMonth: b, merchants: k, merchantHistory: S, totalAmount: T } = U(u?.drilldown_data ?? n.insights_payload?.drilldown_data), v = {
|
|
85
|
+
many: c?.general?.transaction_count ?? V,
|
|
86
|
+
one: c?.general?.transaction_count_one ?? q
|
|
87
87
|
}, O = (e) => {
|
|
88
|
-
r.current = { ...
|
|
88
|
+
r.current = { ...s.filter }, g(e), y(I(e, S, b));
|
|
89
89
|
}, M = () => {
|
|
90
|
-
g(void 0), y(void 0), r.current !== null && (
|
|
90
|
+
g(void 0), y(void 0), r.current !== null && (s.setFilter(r.current), r.current = null);
|
|
91
91
|
};
|
|
92
|
-
return
|
|
93
|
-
r.current !== null && (
|
|
94
|
-
}, [
|
|
92
|
+
return l.useEffect(() => () => {
|
|
93
|
+
r.current !== null && (s.setFilter(r.current), r.current = null);
|
|
94
|
+
}, [s]), /* @__PURE__ */ i(W, { children: [
|
|
95
95
|
/* @__PURE__ */ o(f, {
|
|
96
96
|
sx: {
|
|
97
97
|
bgcolor: "background.default",
|
|
98
98
|
p: 24
|
|
99
99
|
},
|
|
100
|
-
children: /* @__PURE__ */
|
|
100
|
+
children: /* @__PURE__ */ i(d, {
|
|
101
101
|
direction: "row",
|
|
102
102
|
sx: {
|
|
103
103
|
alignItems: "center",
|
|
@@ -107,17 +107,18 @@ var $ = (c) => c.insights_feed?.top_merchants, z = "_1{count} transactions", V =
|
|
|
107
107
|
gap: 12,
|
|
108
108
|
p: 16
|
|
109
109
|
},
|
|
110
|
-
children: [/* @__PURE__ */ o(D, {
|
|
110
|
+
children: [/* @__PURE__ */ o(D, {
|
|
111
|
+
name: "payments",
|
|
112
|
+
size: 32
|
|
113
|
+
}), /* @__PURE__ */ i(d, {
|
|
111
114
|
sx: {
|
|
112
115
|
gap: 4,
|
|
113
116
|
minWidth: 0
|
|
114
117
|
},
|
|
115
|
-
children: [/* @__PURE__ */ o(
|
|
116
|
-
bold: !0,
|
|
118
|
+
children: [/* @__PURE__ */ o(z, {
|
|
117
119
|
component: "p",
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}), /* @__PURE__ */ o(i, {
|
|
120
|
+
children: x(T, _.cents)
|
|
121
|
+
}), /* @__PURE__ */ o(m, {
|
|
121
122
|
color: "text.secondary",
|
|
122
123
|
component: "p",
|
|
123
124
|
variant: "body2",
|
|
@@ -126,7 +127,7 @@ var $ = (c) => c.insights_feed?.top_merchants, z = "_1{count} transactions", V =
|
|
|
126
127
|
})]
|
|
127
128
|
})
|
|
128
129
|
}),
|
|
129
|
-
/* @__PURE__ */ o(
|
|
130
|
+
/* @__PURE__ */ o(d, {
|
|
130
131
|
component: "ul",
|
|
131
132
|
sx: {
|
|
132
133
|
bgcolor: "background.paper",
|
|
@@ -136,9 +137,9 @@ var $ = (c) => c.insights_feed?.top_merchants, z = "_1{count} transactions", V =
|
|
|
136
137
|
},
|
|
137
138
|
children: k.map((e) => /* @__PURE__ */ o(f, {
|
|
138
139
|
component: "li",
|
|
139
|
-
children: /* @__PURE__ */ o(
|
|
140
|
+
children: /* @__PURE__ */ o(J, {
|
|
140
141
|
copy: t,
|
|
141
|
-
countCopy:
|
|
142
|
+
countCopy: v,
|
|
142
143
|
merchant: e,
|
|
143
144
|
onClick: O
|
|
144
145
|
})
|
|
@@ -157,7 +158,7 @@ var $ = (c) => c.insights_feed?.top_merchants, z = "_1{count} transactions", V =
|
|
|
157
158
|
] });
|
|
158
159
|
});
|
|
159
160
|
export {
|
|
160
|
-
|
|
161
|
+
go as TopMerchantsBlock,
|
|
161
162
|
$ as selectTopMerchantsCopy
|
|
162
163
|
};
|
|
163
164
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TopMerchantsBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TopMerchantsBlock/TopMerchantsBlock.tsx"],"sourcesContent":["import React from 'react'\n\nimport Box from '@mui/material/Box'\nimport ButtonBase from '@mui/material/ButtonBase'\nimport Stack from '@mui/material/Stack'\n\nimport { Icon } from '@mxenabled/mx-icons'\nimport { Text } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport { Drawer, useGlobalCopyStore, useTransactionStore } from '../../../common'\nimport type { GlobalCopy, PrimaryCTA, TopMerchantsCopy } from '../../../core'\nimport type { TransactionFilter } from '../../../core/stores/TransactionStore'\nimport { buildDynamicCopy, buildPluralCopy } from '../../../core/utils/Localization'\nimport { CURRENCY_FORMAT, formatCurrency } from '../../../core/utils/NumberFormatting'\nimport LogoMark from '../../components/LogoMark'\nimport { ELEVATION_SHADOW } from '../../components/shared/elevation'\nimport type { ActionBlockProps } from '../../mappings/blocks'\nimport { TransactionHistoryBlock } from '../TransactionHistoryBlock/TransactionHistoryBlock'\nimport { TransactionListHeaderIconTile } from '../TransactionListBlock/TransactionListHeaderIconTile'\nimport { useOpenedCta } from '../useOpenedCta'\nimport { useRequiredCopy } from '../useRequiredCopy'\n\nimport { merchantHistoryCta, readTopMerchants, type TopMerchant } from './layout'\n\nexport const selectTopMerchantsCopy = (copy: GlobalCopy) => copy.insights_feed?.top_merchants\n\n// English defaults until the localized-content service ships the pill copy in every locale, as the\n// Transaction List summary card does.\nconst DEFAULT_COUNT_COPY = '_1{count} transactions'\nconst DEFAULT_COUNT_ONE_COPY = '_1{count} transaction'\n\ninterface MerchantRowProps {\n copy: TopMerchantsCopy\n countCopy: { many: string; one: string }\n merchant: TopMerchant\n onClick: (merchant: TopMerchant) => void\n}\n\n/** Figma `<ListItem> | Utility Row`: logo, \"{rank} - {merchant}\" over its count, total, chevron. */\nconst MerchantRow = ({ copy, countCopy, merchant, onClick }: MerchantRowProps) => {\n const title = buildDynamicCopy(\n copy.rank_merchant,\n String(merchant.rank),\n merchant.merchantName,\n ) as string\n const count = buildPluralCopy(\n countCopy.one,\n countCopy.many,\n merchant.transactionCount,\n String(merchant.transactionCount),\n ) as string\n\n return (\n <ButtonBase\n onClick={() => onClick(merchant)}\n sx={{\n borderBottom: 1,\n borderColor: 'divider',\n gap: 12,\n justifyContent: 'flex-start',\n minHeight: 64,\n px: 16,\n py: 12,\n textAlign: 'left',\n width: '100%',\n '&.Mui-focusVisible': { bgcolor: 'action.focus' },\n }}\n >\n <Box aria-hidden={true} sx={{ display: 'flex', flexShrink: 0 }}>\n <LogoMark\n logo={{\n category_guid: merchant.categoryGuid,\n merchant_guid: merchant.merchantGuid,\n merchant_name: merchant.merchantName,\n }}\n size={32}\n />\n </Box>\n <Stack sx={{ flexGrow: 1, minWidth: 0 }}>\n <Text bold={true} component=\"span\" truncate={true} variant=\"body1\">\n {title}\n </Text>\n <Text component=\"span\" variant=\"caption\">\n {count}\n </Text>\n </Stack>\n <Text component=\"span\" sx={{ flexShrink: 0 }} variant=\"body1\">\n {formatCurrency(merchant.total, CURRENCY_FORMAT.cents)}\n </Text>\n <Icon aria-hidden={true} name=\"chevron_right\" size={20} sx={{ flexShrink: 0 }} />\n </ButtonBase>\n )\n}\n\n/**\n * Monthly Top Merchant Spending's Top Merchants drawer (Figma 1273:34553): the month's total over\n * up to ten ranked merchants. A row opens that merchant's Merchant History (Transaction History,\n * `top_merchant` variant) in a nested drawer, whose rows open Transaction Details.\n */\nexport const TopMerchantsBlock = observer(function TopMerchantsBlock({ beat }: ActionBlockProps) {\n const copy = useRequiredCopy(selectTopMerchantsCopy)\n const { common: commonCopy, insights_feed: insightsCopy } = useGlobalCopyStore()\n const openedCta = useOpenedCta(beat)\n const transactionStore = useTransactionStore()\n const filterBeforeOpen = React.useRef<TransactionFilter | null>(null)\n const [selected, setSelected] = React.useState<TopMerchant>()\n const [selectedCta, setSelectedCta] = React.useState<PrimaryCTA>()\n\n const { describedMonth, merchants, merchantHistory, totalAmount } = readTopMerchants(\n openedCta?.drilldown_data ?? beat.insights_payload?.drilldown_data,\n )\n const countCopy = {\n many: insightsCopy?.general?.transaction_count ?? DEFAULT_COUNT_COPY,\n one: insightsCopy?.general?.transaction_count_one ?? DEFAULT_COUNT_ONE_COPY,\n }\n\n const handleMerchantClick = (merchant: TopMerchant) => {\n filterBeforeOpen.current = { ...transactionStore.filter }\n setSelected(merchant)\n setSelectedCta(merchantHistoryCta(merchant, merchantHistory, describedMonth))\n }\n\n const handleClose = () => {\n setSelected(undefined)\n setSelectedCta(undefined)\n if (filterBeforeOpen.current !== null) {\n transactionStore.setFilter(filterBeforeOpen.current)\n filterBeforeOpen.current = null\n }\n }\n\n React.useEffect(\n () => () => {\n if (filterBeforeOpen.current !== null) {\n transactionStore.setFilter(filterBeforeOpen.current)\n filterBeforeOpen.current = null\n }\n },\n [transactionStore],\n )\n\n return (\n <>\n <Box sx={{ bgcolor: 'background.default', p: 24 }}>\n <Stack\n direction=\"row\"\n sx={{\n alignItems: 'center',\n bgcolor: 'background.paper',\n borderRadius: '8px',\n boxShadow: ELEVATION_SHADOW[1],\n gap: 12,\n p: 16,\n }}\n >\n <TransactionListHeaderIconTile name=\"payments\" />\n <Stack sx={{ gap: 4, minWidth: 0 }}>\n <Text bold={true} component=\"p\" variant=\"h2\">\n {formatCurrency(totalAmount, CURRENCY_FORMAT.cents)}\n </Text>\n <Text color=\"text.secondary\" component=\"p\" variant=\"body2\">\n {copy.total_spending}\n </Text>\n </Stack>\n </Stack>\n </Box>\n <Stack component=\"ul\" sx={{ bgcolor: 'background.paper', listStyle: 'none', m: 0, p: 0 }}>\n {merchants.map((merchant) => (\n <Box component=\"li\" key={merchant.merchantGuid}>\n <MerchantRow\n copy={copy}\n countCopy={countCopy}\n merchant={merchant}\n onClick={handleMerchantClick}\n />\n </Box>\n ))}\n </Stack>\n <Drawer\n ariaLabelClose={commonCopy.close_aria}\n isOpen={!!selected}\n onClose={handleClose}\n title={copy.merchant_history_title}\n >\n {selected && selectedCta && (\n <TransactionHistoryBlock beat={beat} cta={selectedCta} key={selected.merchantGuid} />\n )}\n </Drawer>\n </>\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAyBA,IAAa,IAAA,CAA0B,MAAqB,EAAK,eAAe,eAI1E,IAAqB,0BACrB,IAAyB,yBAUzB,IAAA,CAAe,EAAE,MAAA,GAAM,WAAA,GAAW,UAAA,GAAU,SAAA,EAAA,MAAgC;AAChF,QAAM,IAAQ,EACZ,EAAK,eACL,OAAO,EAAS,IAAI,GACpB,EAAS,YACX,GACM,IAAQ,EACZ,EAAU,KACV,EAAU,MACV,EAAS,kBACT,OAAO,EAAS,gBAAgB,CAClC;AAEA,SACE,gBAAA,EAAC,GAAD;AAAA,IACE,SAAA,MAAe,EAAQ,CAAQ;AAAA,IAC/B,IAAI;AAAA,MACF,cAAc;AAAA,MACd,aAAa;AAAA,MACb,KAAK;AAAA,MACL,gBAAgB;AAAA,MAChB,WAAW;AAAA,MACX,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ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"sourcesContent":["import React from 'react'\n\nimport Box from '@mui/material/Box'\nimport ButtonBase from '@mui/material/ButtonBase'\nimport Stack from '@mui/material/Stack'\n\nimport { Icon } from '@mxenabled/mx-icons'\nimport { H2, Text } from '@mxenabled/mxui'\nimport { observer } from 'mobx-react-lite'\n\nimport { Drawer, useGlobalCopyStore, useTransactionStore } from '../../../common'\nimport type { GlobalCopy, PrimaryCTA, TopMerchantsCopy } from '../../../core'\nimport type { TransactionFilter } from '../../../core/stores/TransactionStore'\nimport { buildDynamicCopy, buildPluralCopy } from '../../../core/utils/Localization'\nimport { CURRENCY_FORMAT, formatCurrency } from '../../../core/utils/NumberFormatting'\nimport LogoMark from '../../components/LogoMark'\nimport { ELEVATION_SHADOW } from '../../components/shared/elevation'\nimport type { ActionBlockProps } from '../../mappings/blocks'\nimport { TransactionHistoryBlock } from '../TransactionHistoryBlock/TransactionHistoryBlock'\nimport { TransactionListHeaderIconTile } from '../TransactionListBlock/TransactionListHeaderIconTile'\nimport { useOpenedCta } from '../useOpenedCta'\nimport { useRequiredCopy } from '../useRequiredCopy'\n\nimport { merchantHistoryCta, readTopMerchants, type TopMerchant } from './layout'\n\nexport const selectTopMerchantsCopy = (copy: GlobalCopy) => copy.insights_feed?.top_merchants\n\n// English defaults until the localized-content service ships the pill copy in every locale, as the\n// Transaction List summary card does.\nconst DEFAULT_COUNT_COPY = '_1{count} transactions'\nconst DEFAULT_COUNT_ONE_COPY = '_1{count} transaction'\n\ninterface MerchantRowProps {\n copy: TopMerchantsCopy\n countCopy: { many: string; one: string }\n merchant: TopMerchant\n onClick: (merchant: TopMerchant) => void\n}\n\n/** Figma `<ListItem> | Utility Row`: logo, \"{rank} - {merchant}\" over its count, total, chevron. */\nconst MerchantRow = ({ copy, countCopy, merchant, onClick }: MerchantRowProps) => {\n const title = buildDynamicCopy(\n copy.rank_merchant,\n String(merchant.rank),\n merchant.merchantName,\n ) as string\n const count = buildPluralCopy(\n countCopy.one,\n countCopy.many,\n merchant.transactionCount,\n String(merchant.transactionCount),\n ) as string\n\n return (\n <ButtonBase\n onClick={() => onClick(merchant)}\n sx={{\n borderBottom: 1,\n borderColor: 'divider',\n gap: 12,\n justifyContent: 'flex-start',\n minHeight: 64,\n px: 16,\n py: 12,\n textAlign: 'left',\n width: '100%',\n '&.Mui-focusVisible': { bgcolor: 'action.focus' },\n }}\n >\n <Box aria-hidden={true} sx={{ display: 'flex', flexShrink: 0 }}>\n <LogoMark\n logo={{\n category_guid: merchant.categoryGuid,\n merchant_guid: merchant.merchantGuid,\n merchant_name: merchant.merchantName,\n }}\n size={32}\n />\n </Box>\n <Stack sx={{ flexGrow: 1, minWidth: 0 }}>\n <Text bold={true} component=\"span\" truncate={true} variant=\"body1\">\n {title}\n </Text>\n <Text component=\"span\" variant=\"caption\">\n {count}\n </Text>\n </Stack>\n <Text component=\"span\" sx={{ flexShrink: 0 }} variant=\"body1\">\n {formatCurrency(merchant.total, CURRENCY_FORMAT.cents)}\n </Text>\n <Icon aria-hidden={true} name=\"chevron_right\" size={20} sx={{ flexShrink: 0 }} />\n </ButtonBase>\n )\n}\n\n/** Top Merchants drawer: the month's total over the ranked merchants; a row opens its Merchant History. */\nexport const TopMerchantsBlock = observer(function TopMerchantsBlock({ beat }: ActionBlockProps) {\n const copy = useRequiredCopy(selectTopMerchantsCopy)\n const { common: commonCopy, insights_feed: insightsCopy } = useGlobalCopyStore()\n const openedCta = useOpenedCta(beat)\n const transactionStore = useTransactionStore()\n const filterBeforeOpen = React.useRef<TransactionFilter | null>(null)\n const [selected, setSelected] = React.useState<TopMerchant>()\n const [selectedCta, setSelectedCta] = React.useState<PrimaryCTA>()\n\n const { describedMonth, merchants, merchantHistory, totalAmount } = readTopMerchants(\n openedCta?.drilldown_data ?? beat.insights_payload?.drilldown_data,\n )\n const countCopy = {\n many: insightsCopy?.general?.transaction_count ?? DEFAULT_COUNT_COPY,\n one: insightsCopy?.general?.transaction_count_one ?? DEFAULT_COUNT_ONE_COPY,\n }\n\n const handleMerchantClick = (merchant: TopMerchant) => {\n filterBeforeOpen.current = { ...transactionStore.filter }\n setSelected(merchant)\n setSelectedCta(merchantHistoryCta(merchant, merchantHistory, describedMonth))\n }\n\n const handleClose = () => {\n setSelected(undefined)\n setSelectedCta(undefined)\n if (filterBeforeOpen.current !== null) {\n transactionStore.setFilter(filterBeforeOpen.current)\n filterBeforeOpen.current = null\n }\n }\n\n React.useEffect(\n () => () => {\n if (filterBeforeOpen.current !== null) {\n transactionStore.setFilter(filterBeforeOpen.current)\n filterBeforeOpen.current = null\n }\n },\n [transactionStore],\n )\n\n return (\n <>\n <Box sx={{ bgcolor: 'background.default', p: 24 }}>\n <Stack\n direction=\"row\"\n sx={{\n alignItems: 'center',\n bgcolor: 'background.paper',\n borderRadius: '8px',\n boxShadow: ELEVATION_SHADOW[1],\n gap: 12,\n p: 16,\n }}\n >\n <TransactionListHeaderIconTile name=\"payments\" size={32} />\n <Stack sx={{ gap: 4, minWidth: 0 }}>\n <H2 component=\"p\">{formatCurrency(totalAmount, CURRENCY_FORMAT.cents)}</H2>\n <Text color=\"text.secondary\" component=\"p\" variant=\"body2\">\n {copy.total_spending}\n </Text>\n </Stack>\n </Stack>\n </Box>\n <Stack component=\"ul\" sx={{ bgcolor: 'background.paper', listStyle: 'none', m: 0, p: 0 }}>\n {merchants.map((merchant) => (\n <Box component=\"li\" key={merchant.merchantGuid}>\n <MerchantRow\n copy={copy}\n countCopy={countCopy}\n merchant={merchant}\n onClick={handleMerchantClick}\n />\n </Box>\n ))}\n </Stack>\n <Drawer\n ariaLabelClose={commonCopy.close_aria}\n isOpen={!!selected}\n onClose={handleClose}\n title={copy.merchant_history_title}\n >\n {selected && selectedCta && (\n <TransactionHistoryBlock beat={beat} cta={selectedCta} key={selected.merchantGuid} />\n )}\n </Drawer>\n </>\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAyBA,IAAa,IAAA,CAA0B,MAAqB,EAAK,eAAe,eAI1E,IAAqB,0BACrB,IAAyB,yB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AS,YAO7B,CACN;AAAA,IACI,CAAA;AAAA,IACP,gBAAA,EAAC,GAAD;AAAA,MACE,gBAAgB,EAAW;AAAA,MAC3B,QAAQ,CAAC,CAAC;AAAA,MACV,SAAS;AAAA,MACT,OAAO,EAAK;AAAA,MAEX,UAAA,KAAY,KACX,gBAAA,EAAC,GAAD;AAAA,QAA+B,MAAA;AAAA,QAAM,KAAK;AAAA,MAA0C,GAAxB,EAAS,YAAe;AAAA,IAEhF,CAAA;AAAA,EACR,EAAA,CAAA;AAEN,CAAC"}
|
|
@@ -1,27 +1,25 @@
|
|
|
1
|
+
import { GlobalCopy } from '../../../core';
|
|
1
2
|
import { BottomActions } from '../../../transactions/constants/Actions';
|
|
2
3
|
export interface TransactionDetailsLayoutConfig {
|
|
3
4
|
/** Bottom action rows rendered in the drawer. */
|
|
4
5
|
bottomActions: BottomActions[];
|
|
6
|
+
/** The drawer title; absent or blank falls back to the Transaction Details copy. */
|
|
7
|
+
title?: (copy: GlobalCopy) => string | undefined;
|
|
5
8
|
}
|
|
6
9
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* does). Names describe the behavior, not the originating beat, so any beat whose CTA wants the same
|
|
10
|
-
* drilldown reuses the value. Extend `TransactionDetailsLayoutConfig` (styles, top actions, …) as
|
|
11
|
-
* variants need to differ, rather than branching on the variant string across the block.
|
|
10
|
+
* Transaction Details drawer variations, keyed by the opening CTA's `variant` and named by behaviour.
|
|
11
|
+
* Add a field to `TransactionDetailsLayoutConfig` when variants differ, rather than branching on the string.
|
|
12
12
|
*
|
|
13
13
|
* - `MerchantBudget` — shows the "Add a Merchant Budget" row.
|
|
14
14
|
* - `NoMerchantBudget` — drops the "Add a Merchant Budget" row.
|
|
15
|
+
* - `DepositDetails` — the merchant-budget set, titled "Deposit Details".
|
|
15
16
|
*/
|
|
16
17
|
export declare const transactionDetailsVariant: {
|
|
17
18
|
readonly MerchantBudget: "merchant_budget";
|
|
18
19
|
readonly NoMerchantBudget: "no_merchant_budget";
|
|
20
|
+
readonly DepositDetails: "deposit_details";
|
|
19
21
|
};
|
|
20
22
|
export type TransactionDetailsVariant = (typeof transactionDetailsVariant)[keyof typeof transactionDetailsVariant];
|
|
21
|
-
/**
|
|
22
|
-
* Resolve a CTA variant's drawer config. Any variant without its own entry — including `null` and
|
|
23
|
-
* unknown values — falls back to the full action set (merchant budget included). That default is the
|
|
24
|
-
* common case, not a misconfiguration, so this does not warn. `Object.hasOwn` avoids inherited keys
|
|
25
|
-
* (e.g. `constructor`) resolving to a non-config.
|
|
26
|
-
*/
|
|
23
|
+
/** A variant without its own row (null or unknown) gets the full action set; that's the common case, so no warning. */
|
|
27
24
|
export declare const resolveLayoutConfig: (variant: string | null | undefined) => TransactionDetailsLayoutConfig;
|
|
25
|
+
export declare const getTransactionDetailsDrawerTitle: (variant: string | null | undefined, copy: GlobalCopy) => string;
|
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
import { BottomActions as
|
|
2
|
-
var a = { bottomActions: [
|
|
1
|
+
import { BottomActions as r, DEFAULT_BOTTOM_ACTIONS as n } from "../../../transactions/constants/Actions.es.js";
|
|
2
|
+
var a = { bottomActions: [r.MerchantBudget, ...n] }, s = { bottomActions: n }, e = {
|
|
3
3
|
MerchantBudget: "merchant_budget",
|
|
4
|
-
NoMerchantBudget: "no_merchant_budget"
|
|
4
|
+
NoMerchantBudget: "no_merchant_budget",
|
|
5
|
+
DepositDetails: "deposit_details"
|
|
5
6
|
}, o = {
|
|
6
7
|
[e.MerchantBudget]: a,
|
|
7
|
-
[e.NoMerchantBudget]:
|
|
8
|
-
|
|
8
|
+
[e.NoMerchantBudget]: s,
|
|
9
|
+
[e.DepositDetails]: {
|
|
10
|
+
...a,
|
|
11
|
+
title: (t) => t.insights_feed?.general?.deposit_details_title
|
|
12
|
+
}
|
|
13
|
+
}, l = (t) => t != null && Object.hasOwn(o, t) ? o[t] : a, d = (t, i) => l(t).title?.(i) || i.insights_feed?.general?.transaction_details_title || "";
|
|
9
14
|
export {
|
|
10
|
-
|
|
15
|
+
d as getTransactionDetailsDrawerTitle,
|
|
16
|
+
l as resolveLayoutConfig,
|
|
11
17
|
e as transactionDetailsVariant
|
|
12
18
|
};
|
|
13
19
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionDetailsBlock/layout.ts"],"sourcesContent":["import { BottomActions, DEFAULT_BOTTOM_ACTIONS } from '../../../transactions/constants/Actions'\n\nexport interface TransactionDetailsLayoutConfig {\n /** Bottom action rows rendered in the drawer. */\n bottomActions: BottomActions[]\n}\n\n// Reusable configs named by intent, not by any one beat, so any CTA variant can point at them.\nconst WITH_MERCHANT_BUDGET: TransactionDetailsLayoutConfig = {\n bottomActions: [BottomActions.MerchantBudget, ...DEFAULT_BOTTOM_ACTIONS],\n}\nconst WITHOUT_MERCHANT_BUDGET: TransactionDetailsLayoutConfig = {\n bottomActions: DEFAULT_BOTTOM_ACTIONS,\n}\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionDetailsBlock/layout.ts"],"sourcesContent":["import type { GlobalCopy } from '../../../core'\nimport { BottomActions, DEFAULT_BOTTOM_ACTIONS } from '../../../transactions/constants/Actions'\n\nexport interface TransactionDetailsLayoutConfig {\n /** Bottom action rows rendered in the drawer. */\n bottomActions: BottomActions[]\n /** The drawer title; absent or blank falls back to the Transaction Details copy. */\n title?: (copy: GlobalCopy) => string | undefined\n}\n\n// Reusable configs named by intent, not by any one beat, so any CTA variant can point at them.\nconst WITH_MERCHANT_BUDGET: TransactionDetailsLayoutConfig = {\n bottomActions: [BottomActions.MerchantBudget, ...DEFAULT_BOTTOM_ACTIONS],\n}\nconst WITHOUT_MERCHANT_BUDGET: TransactionDetailsLayoutConfig = {\n bottomActions: DEFAULT_BOTTOM_ACTIONS,\n}\n\n/**\n * Transaction Details drawer variations, keyed by the opening CTA's `variant` and named by behaviour.\n * Add a field to `TransactionDetailsLayoutConfig` when variants differ, rather than branching on the string.\n *\n * - `MerchantBudget` — shows the \"Add a Merchant Budget\" row.\n * - `NoMerchantBudget` — drops the \"Add a Merchant Budget\" row.\n * - `DepositDetails` — the merchant-budget set, titled \"Deposit Details\".\n */\nexport const transactionDetailsVariant = {\n MerchantBudget: 'merchant_budget',\n NoMerchantBudget: 'no_merchant_budget',\n DepositDetails: 'deposit_details',\n} as const\n\nexport type TransactionDetailsVariant =\n (typeof transactionDetailsVariant)[keyof typeof transactionDetailsVariant]\n\nconst VARIANT_CONFIG: Record<string, TransactionDetailsLayoutConfig> = {\n [transactionDetailsVariant.MerchantBudget]: WITH_MERCHANT_BUDGET,\n [transactionDetailsVariant.NoMerchantBudget]: WITHOUT_MERCHANT_BUDGET,\n [transactionDetailsVariant.DepositDetails]: {\n ...WITH_MERCHANT_BUDGET,\n title: (copy) => copy.insights_feed?.general?.deposit_details_title,\n },\n}\n\n/** A variant without its own row (null or unknown) gets the full action set; that's the common case, so no warning. */\nexport const resolveLayoutConfig = (\n variant: string | null | undefined,\n): TransactionDetailsLayoutConfig =>\n variant != null && Object.hasOwn(VARIANT_CONFIG, variant)\n ? VARIANT_CONFIG[variant]\n : WITH_MERCHANT_BUDGET\n\nexport const getTransactionDetailsDrawerTitle = (\n variant: string | null | undefined,\n copy: GlobalCopy,\n): string =>\n resolveLayoutConfig(variant).title?.(copy) ||\n copy.insights_feed?.general?.transaction_details_title ||\n ''\n"],"mappings":";AAWA,IAAM,IAAuD,EAC3D,eAAe,CAAC,EAAc,gBAAgB,GAAG,CAAsB,EACzE,GACM,IAA0D,EAC9D,eAAe,EACjB,GAUa,IAA4B;AAAA,EACvC,gBAAgB;AAAA,EAChB,kBAAkB;AAAA,EAClB,gBAAgB;AAClB,GAKM,IAAiE;AAAA,EACpE,CAAA,EAA0B,cAAA,GAAiB;AAAA,EAC3C,CAAA,EAA0B,gBAAA,GAAmB;AAAA,EAC7C,CAAA,EAA0B,cAAA,GAAiB;AAAA,IAC1C,GAAG;AAAA,IACH,OAAA,CAAQ,MAAS,EAAK,eAAe,SAAS;AAAA,EAChD;AACF,GAGa,IAAA,CACX,MAEA,KAAW,QAAQ,OAAO,OAAO,GAAgB,CAAO,IACpD,EAAe,CAAA,IACf,GAEO,IAAA,CACX,GACA,MAEA,EAAoB,CAAO,EAAE,QAAQ,CAAI,KACzC,EAAK,eAAe,SAAS,6BAC7B"}
|
package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListHeaderIconTile.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export interface TransactionListHeaderIconTileProps {
|
|
2
2
|
/** An mx-icons name. */
|
|
3
3
|
name: string;
|
|
4
|
+
/** Glyph size in px, inside the fixed 56px tile. Default 24. */
|
|
5
|
+
size?: 24 | 32;
|
|
4
6
|
}
|
|
5
7
|
/** The icon tile that leads the Transaction List header cards. */
|
|
6
|
-
export declare const TransactionListHeaderIconTile: ({ name }: TransactionListHeaderIconTileProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare const TransactionListHeaderIconTile: ({ name, size, }: TransactionListHeaderIconTileProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
9
|
export default TransactionListHeaderIconTile;
|
package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListHeaderIconTile.es.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Icon as
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { alpha as
|
|
4
|
-
import
|
|
5
|
-
var
|
|
1
|
+
import { Icon as a } from "@mxenabled/mx-icons";
|
|
2
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
3
|
+
import { alpha as e } from "@mui/material/styles";
|
|
4
|
+
import n from "@mui/material/Box";
|
|
5
|
+
var c = ({ name: r, size: t = 24 }) => /* @__PURE__ */ i(n, {
|
|
6
6
|
sx: {
|
|
7
7
|
alignItems: "center",
|
|
8
|
-
bgcolor: (
|
|
8
|
+
bgcolor: (o) => e(o.palette.primary.main, 0.15),
|
|
9
9
|
borderRadius: "4px",
|
|
10
10
|
color: "primary.main",
|
|
11
11
|
display: "flex",
|
|
@@ -13,16 +13,17 @@ var s = ({ name: i }) => /* @__PURE__ */ r(a, {
|
|
|
13
13
|
justifyContent: "center",
|
|
14
14
|
width: 56
|
|
15
15
|
},
|
|
16
|
-
children: /* @__PURE__ */
|
|
16
|
+
children: /* @__PURE__ */ i(a, {
|
|
17
17
|
"aria-hidden": !0,
|
|
18
|
+
"data-icon": r,
|
|
18
19
|
fill: !0,
|
|
19
|
-
name:
|
|
20
|
-
size:
|
|
20
|
+
name: r,
|
|
21
|
+
size: t
|
|
21
22
|
})
|
|
22
23
|
});
|
|
23
24
|
export {
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
c as TransactionListHeaderIconTile,
|
|
26
|
+
c as default
|
|
26
27
|
};
|
|
27
28
|
|
|
28
29
|
//# sourceMappingURL=TransactionListHeaderIconTile.es.js.map
|
package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListHeaderIconTile.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionListHeaderIconTile.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionListBlock/TransactionListHeaderIconTile.tsx"],"sourcesContent":["import Box from '@mui/material/Box'\nimport { alpha } from '@mui/material/styles'\n\nimport { Icon } from '@mxenabled/mx-icons'\n\nexport interface TransactionListHeaderIconTileProps {\n /** An mx-icons name. */\n name: string\n}\n\n/** The icon tile that leads the Transaction List header cards. */\nexport const TransactionListHeaderIconTile = ({
|
|
1
|
+
{"version":3,"file":"TransactionListHeaderIconTile.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionListBlock/TransactionListHeaderIconTile.tsx"],"sourcesContent":["import Box from '@mui/material/Box'\nimport { alpha } from '@mui/material/styles'\n\nimport { Icon } from '@mxenabled/mx-icons'\n\nexport interface TransactionListHeaderIconTileProps {\n /** An mx-icons name. */\n name: string\n /** Glyph size in px, inside the fixed 56px tile. Default 24. */\n size?: 24 | 32\n}\n\n/** The icon tile that leads the Transaction List header cards. */\nexport const TransactionListHeaderIconTile = ({\n name,\n size = 24,\n}: TransactionListHeaderIconTileProps) => (\n <Box\n sx={{\n alignItems: 'center',\n bgcolor: (theme) => alpha(theme.palette.primary.main, 0.15),\n borderRadius: '4px',\n color: 'primary.main',\n display: 'flex',\n height: 56,\n justifyContent: 'center',\n width: 56,\n }}\n >\n <Icon aria-hidden={true} data-icon={name} fill={true} name={name} size={size} />\n </Box>\n)\n\nexport default TransactionListHeaderIconTile\n"],"mappings":";;;;AAaA,IAAa,IAAA,CAAiC,EAC5C,MAAA,GACA,MAAA,IAAO,GAAA,MAEP,gBAAA,EAAC,GAAD;AAAA,EACE,IAAI;AAAA,IACF,YAAY;AAAA,IACZ,SAAA,CAAU,MAAU,EAAM,EAAM,QAAQ,QAAQ,MAAM,IAAI;AAAA,IAC1D,cAAc;AAAA,IACd,OAAO;AAAA,IACP,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,gBAAgB;AAAA,IAChB,OAAO;AAAA,EACT;AAAA,EAEA,UAAA,gBAAA,EAAC,GAAD;AAAA,IAAM,eAAa;AAAA,IAAM,aAAW;AAAA,IAAM,MAAM;AAAA,IAAY,MAAA;AAAA,IAAY,MAAA;AAAA,EAAO,CAAA;AAC5E,CAAA"}
|
|
@@ -12,8 +12,8 @@ export interface TransactionListSummaryCardProps {
|
|
|
12
12
|
* range, the headline amount, and a `{count} transactions` pill. Driven by the beat's summary
|
|
13
13
|
* figures (see `readSummary` in layout.ts). Theme-aware tokens keep it correct in dark mode.
|
|
14
14
|
*
|
|
15
|
-
* Figma: Drilldown | Replenish Savings ("Savings Withdrawal")
|
|
16
|
-
*
|
|
15
|
+
* Figma: Drilldown | Replenish Savings ("Savings Withdrawal"), Weekly Small Purchases Summary. The
|
|
16
|
+
* tile is the summary's own icon (`drilldown_data.logo`), else Replenish Savings' `savings`.
|
|
17
17
|
*/
|
|
18
18
|
export declare const TransactionListSummaryCard: ({ summary, count, copy, }: TransactionListSummaryCardProps) => import("react/jsx-runtime").JSX.Element;
|
|
19
19
|
export default TransactionListSummaryCard;
|