@mx-cartographer/experiences 9.7.127 → 9.7.128
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 +6 -0
- package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetDetailsBlock.es.js +101 -105
- package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetDetailsBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/RemainingCashBlock/RemainingCashBlock.es.js +44 -43
- package/dist/insights-v2/actionBlocks/RemainingCashBlock/RemainingCashBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js +66 -65
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/BudgetBlock/BudgetBlock.es.js +24 -30
- package/dist/insights-v2/blocks/ComponentBlocks/BudgetBlock/BudgetBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/TransactionBlock.es.js +84 -101
- package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/TransactionBlock.es.js.map +1 -1
- package/dist/insights-v2/components/CategoryTile.d.ts +14 -0
- package/dist/insights-v2/components/CategoryTile.es.js +28 -0
- package/dist/insights-v2/components/CategoryTile.es.js.map +1 -0
- package/dist/insights-v2/components/LogoMark.d.ts +3 -3
- package/dist/insights-v2/components/LogoMark.es.js +11 -10
- package/dist/insights-v2/components/LogoMark.es.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,148 +1,131 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { slot as
|
|
3
|
-
import { formatCurrency as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
1
|
+
import { useGlobalCopyStore as j, useGlobalStore as q } from "../../../../common/context/hooks.es.js";
|
|
2
|
+
import { slot as a } from "../../../../core/types/Insights.es.js";
|
|
3
|
+
import { formatCurrency as x } from "../../../../core/utils/NumberFormatting.es.js";
|
|
4
|
+
import { useBeatActions as D } from "../../../beatActions.es.js";
|
|
5
|
+
import { resolveVariantConfig as H } from "../../resolveVariantConfig.es.js";
|
|
6
|
+
import { USER_RESPONSE as P, repeatingTransactionOf as V } from "../../../ctaActions/subscriptionAnswer.es.js";
|
|
7
|
+
import U from "../../../components/CategoryTile.es.js";
|
|
8
|
+
import W, { isKnownIcon as K } from "../../../components/LogoMark.es.js";
|
|
9
|
+
import { logoFromRef as Y } from "../../../components/shared/EntityLogo.es.js";
|
|
10
|
+
import J from "../../../components/LogoFromGuid.es.js";
|
|
11
|
+
import { statusIconName as Q, statusIconPalette as C } from "../../../components/statusIcon.es.js";
|
|
12
|
+
import X from "../../../components/TransactionListCard.es.js";
|
|
13
|
+
import oo from "../../../components/StatusMessageCard.es.js";
|
|
13
14
|
import { subscriptionFrequency as ro } from "../../../components/SubscriptionStatus/subscriptionFrequency.es.js";
|
|
14
|
-
import { getLayoutConfig as
|
|
15
|
+
import { getLayoutConfig as to, transactionBlockVariant as eo } from "./layout.es.js";
|
|
15
16
|
import { observer as no } from "mobx-react-lite";
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return i ? /* @__PURE__ */ e(m, {
|
|
17
|
+
import { Icon as S } from "@mxenabled/mx-icons";
|
|
18
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
19
|
+
import { alpha as io, useTheme as ao } from "@mui/material/styles";
|
|
20
|
+
import g from "@mui/material/Box";
|
|
21
|
+
var c = 32, so = Math.round(c * 0.625), co = 24, I = 32, mo = 20, uo = ({ icon: i }) => {
|
|
22
|
+
const e = Q(i?.guid);
|
|
23
|
+
return e ? /* @__PURE__ */ t(g, {
|
|
24
24
|
"aria-hidden": !0,
|
|
25
|
-
"data-icon":
|
|
25
|
+
"data-icon": e,
|
|
26
26
|
"data-testid": "subscription-badge",
|
|
27
27
|
sx: {
|
|
28
28
|
alignItems: "center",
|
|
29
|
-
bgcolor: `${
|
|
29
|
+
bgcolor: `${C(i?.color)}.main`,
|
|
30
30
|
borderRadius: "50%",
|
|
31
31
|
display: "flex",
|
|
32
|
-
height:
|
|
32
|
+
height: I,
|
|
33
33
|
justifyContent: "center",
|
|
34
|
-
width:
|
|
34
|
+
width: I
|
|
35
35
|
},
|
|
36
|
-
children: /* @__PURE__ */
|
|
36
|
+
children: /* @__PURE__ */ t(S, {
|
|
37
37
|
fill: !0,
|
|
38
|
-
name:
|
|
39
|
-
size:
|
|
40
|
-
sx: { color: `${
|
|
38
|
+
name: e,
|
|
39
|
+
size: mo,
|
|
40
|
+
sx: { color: `${C(i?.color)}.contrastText` }
|
|
41
41
|
})
|
|
42
42
|
}) : null;
|
|
43
|
-
},
|
|
44
|
-
const o =
|
|
43
|
+
}, lo = (i, e, m) => {
|
|
44
|
+
const o = Y(i.logo, i.primary_text);
|
|
45
45
|
if (o) {
|
|
46
46
|
if (o.logo_name) {
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
if (!K(o.logo_name)) return;
|
|
48
|
+
const s = !!o.logo_fill, n = o.logo_color ?? e.palette.chart.chart2 ?? e.palette.primary.main;
|
|
49
|
+
return /* @__PURE__ */ t(g, {
|
|
49
50
|
sx: {
|
|
50
51
|
alignItems: "center",
|
|
51
52
|
display: "flex",
|
|
52
|
-
height:
|
|
53
|
+
height: c,
|
|
53
54
|
justifyContent: "center",
|
|
54
|
-
width:
|
|
55
|
-
...
|
|
56
|
-
bgcolor:
|
|
57
|
-
borderRadius: `${
|
|
55
|
+
width: c,
|
|
56
|
+
...s && {
|
|
57
|
+
bgcolor: io(n, 0.15),
|
|
58
|
+
borderRadius: `${e.shape.borderRadius}px`
|
|
58
59
|
}
|
|
59
60
|
},
|
|
60
|
-
children: /* @__PURE__ */
|
|
61
|
+
children: /* @__PURE__ */ t(S, {
|
|
61
62
|
name: o.logo_name,
|
|
62
|
-
size:
|
|
63
|
-
sx: { color:
|
|
63
|
+
size: so,
|
|
64
|
+
sx: { color: s ? n : o.logo_color }
|
|
64
65
|
})
|
|
65
66
|
});
|
|
66
67
|
}
|
|
67
|
-
if (o.merchant_guid) return /* @__PURE__ */
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
merchantGuid: o.merchant_guid,
|
|
71
|
-
size: u
|
|
68
|
+
if (o.merchant_guid || o.institution_guid) return /* @__PURE__ */ t(W, {
|
|
69
|
+
logo: o,
|
|
70
|
+
size: c
|
|
72
71
|
});
|
|
73
|
-
if (o.
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
72
|
+
if (o.category_guid) return /* @__PURE__ */ t(U, {
|
|
73
|
+
categoryGuid: o.category_guid,
|
|
74
|
+
size: c,
|
|
75
|
+
tint: m
|
|
77
76
|
});
|
|
78
|
-
if (o.category_guid) {
|
|
79
|
-
const n = i(o.category_guid), r = V(n, c), l = d !== void 0 ? {
|
|
80
|
-
bgcolor: G(r, d),
|
|
81
|
-
border: `1px solid ${r}`,
|
|
82
|
-
color: "text.primary"
|
|
83
|
-
} : void 0;
|
|
84
|
-
return /* @__PURE__ */ e(m, {
|
|
85
|
-
"data-testid": `category-icon-${n}`,
|
|
86
|
-
sx: { display: "flex" },
|
|
87
|
-
children: /* @__PURE__ */ e(ao, {
|
|
88
|
-
categoryGuid: n,
|
|
89
|
-
size: u,
|
|
90
|
-
sx: l
|
|
91
|
-
})
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
77
|
}
|
|
95
|
-
},
|
|
96
|
-
const
|
|
97
|
-
beat:
|
|
98
|
-
stores:
|
|
99
|
-
}) : void 0,
|
|
78
|
+
}, Lo = no(({ payload: i }) => {
|
|
79
|
+
const e = ao(), m = q(), { recurring: o } = j(), { beat: s } = D(), { data: n, variant: T } = i.instance_slot, { answeredBackground: f, background: u, cardVariant: E, categoryTint: k, creditAmounts: B, elevated: R, followsSubscription: l, headerColor: O, raised: A, showFooter: G, showFrequency: p, showHeader: L, statusMessage: F, sx: N } = H(to(e), T, eo.NoHeader, "TransactionBlock"), _ = (p || l) && s ? V({
|
|
80
|
+
beat: s,
|
|
81
|
+
stores: m
|
|
82
|
+
}) : void 0, y = !!l && _?.user_response === P.CONFIRMED;
|
|
100
83
|
if (F) {
|
|
101
|
-
const
|
|
102
|
-
return typeof
|
|
103
|
-
icon: /* @__PURE__ */
|
|
84
|
+
const r = a(n, "message");
|
|
85
|
+
return typeof r != "string" || !r.trim() ? (console.warn("[TransactionBlock] status_message has no message — rendering nothing."), null) : /* @__PURE__ */ t(oo, {
|
|
86
|
+
icon: /* @__PURE__ */ t(g, {
|
|
104
87
|
"aria-hidden": "true",
|
|
105
88
|
sx: { display: "flex" },
|
|
106
|
-
children: /* @__PURE__ */
|
|
107
|
-
logo:
|
|
108
|
-
size:
|
|
89
|
+
children: /* @__PURE__ */ t(J, {
|
|
90
|
+
logo: a(n, "icon"),
|
|
91
|
+
size: co
|
|
109
92
|
})
|
|
110
93
|
}),
|
|
111
|
-
message:
|
|
112
|
-
sx:
|
|
113
|
-
backgroundImage:
|
|
94
|
+
message: r,
|
|
95
|
+
sx: u ? {
|
|
96
|
+
backgroundImage: u,
|
|
114
97
|
bgcolor: "background.paper"
|
|
115
98
|
} : void 0
|
|
116
99
|
});
|
|
117
100
|
}
|
|
118
|
-
const
|
|
119
|
-
if (!Array.isArray(
|
|
120
|
-
const
|
|
121
|
-
label:
|
|
122
|
-
amount:
|
|
123
|
-
} : void 0,
|
|
124
|
-
return /* @__PURE__ */
|
|
125
|
-
background:
|
|
126
|
-
badge:
|
|
127
|
-
elevated:
|
|
128
|
-
footer:
|
|
129
|
-
header:
|
|
101
|
+
const d = a(n, "series"), h = a(n, "header_text");
|
|
102
|
+
if (!Array.isArray(d) || !d.length) return null;
|
|
103
|
+
const w = L && typeof h == "string" ? h : void 0, b = a(n, "footer_text"), z = a(n, "footer_amount"), M = G && typeof b == "string" ? {
|
|
104
|
+
label: b,
|
|
105
|
+
amount: x(z, "0,0.00")
|
|
106
|
+
} : void 0, Z = p ? ro(o, _) : void 0, $ = l ? /* @__PURE__ */ t(uo, { icon: a(n, y ? "reviewed_icon" : "icon") }) : void 0, v = (r) => !!B && typeof r == "number" && r > 0;
|
|
107
|
+
return /* @__PURE__ */ t(X, {
|
|
108
|
+
background: y && f ? f : u,
|
|
109
|
+
badge: $,
|
|
110
|
+
elevated: R,
|
|
111
|
+
footer: M,
|
|
112
|
+
header: w,
|
|
130
113
|
headerColor: O,
|
|
131
114
|
raised: A,
|
|
132
115
|
sx: N,
|
|
133
|
-
variant:
|
|
134
|
-
rows:
|
|
135
|
-
amount: typeof
|
|
136
|
-
amountColor:
|
|
137
|
-
amountCaption:
|
|
138
|
-
leading:
|
|
139
|
-
subtitle:
|
|
140
|
-
title:
|
|
116
|
+
variant: E,
|
|
117
|
+
rows: d.map((r) => ({
|
|
118
|
+
amount: typeof r.amount == "number" ? `${v(r.amount) ? "+" : ""}${x(r.amount, "0,0.00")}` : "",
|
|
119
|
+
amountColor: v(r.amount) ? "success.main" : void 0,
|
|
120
|
+
amountCaption: Z,
|
|
121
|
+
leading: lo(r, e, k),
|
|
122
|
+
subtitle: r.secondary_text ?? "",
|
|
123
|
+
title: r.primary_text ?? ""
|
|
141
124
|
}))
|
|
142
125
|
});
|
|
143
126
|
});
|
|
144
127
|
export {
|
|
145
|
-
|
|
128
|
+
Lo as TransactionBlock
|
|
146
129
|
};
|
|
147
130
|
|
|
148
131
|
//# sourceMappingURL=TransactionBlock.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionBlock.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ComponentBlocks/TransactionBlock/TransactionBlock.tsx"],"sourcesContent":["import { observer } from 'mobx-react-lite'\n\nimport Box from '@mui/material/Box'\nimport { alpha, useTheme } from '@mui/material/styles'\nimport type { Theme } from '@mui/material/styles'\n\nimport { CategoryIcon, InstitutionLogo, MerchantLogo } from '@mxenabled/mxui'\nimport { Icon } from '@mxenabled/mx-icons'\n\nimport { useCategoryStore, useGlobalCopyStore, useGlobalStore } from '../../../../common'\nimport { slot } from '../../../../core'\nimport type { InsightsPayload, InstanceSlotRow, LogoRef } from '../../../../core'\nimport { getCategoryColor } from '../../../../core/utils/CategoryUtil'\nimport { formatCurrency } from '../../../../core/utils/NumberFormatting'\n\nimport { useBeatActions } from '../../../beatActions'\nimport LogoFromGuid from '../../../components/LogoFromGuid'\nimport StatusMessageCard from '../../../components/StatusMessageCard'\nimport TransactionListCard from '../../../components/TransactionListCard'\nimport { logoFromRef } from '../../../components/shared/EntityLogo'\nimport { statusIconName, statusIconPalette } from '../../../components/statusIcon'\nimport { subscriptionFrequency } from '../../../components/SubscriptionStatus/subscriptionFrequency'\nimport { repeatingTransactionOf, USER_RESPONSE } from '../../../ctaActions/subscriptionAnswer'\n\nimport { resolveVariantConfig } from '../../resolveVariantConfig'\nimport { getLayoutConfig, transactionBlockVariant } from './layout'\n\ninterface TransactionBlockProps {\n payload: InsightsPayload\n beatGuid?: string\n}\n\nconst ROW_LOGO_SIZE = 32\n// Same glyph-to-tile ratio mxui's `CategoryIcon` uses, so a status icon sits like the other logos.\nconst ROW_ICON_SIZE = Math.round(ROW_LOGO_SIZE * 0.625)\nconst STATUS_ICON_SIZE = 24\n// Status badge: palette disc, contrastText glyph.\nconst BADGE_SIZE = 32\nconst BADGE_GLYPH_SIZE = 20\n\n/** Status disc from `data.icon` / `data.reviewed_icon`. */\nconst SubscriptionBadge = ({ icon }: { icon?: LogoRef }) => {\n const name = statusIconName(icon?.guid)\n\n if (!name) return null\n\n return (\n <Box\n aria-hidden={true}\n data-icon={name}\n data-testid=\"subscription-badge\"\n sx={{\n alignItems: 'center',\n bgcolor: `${statusIconPalette(icon?.color)}.main`,\n borderRadius: '50%',\n display: 'flex',\n height: BADGE_SIZE,\n justifyContent: 'center',\n width: BADGE_SIZE,\n }}\n >\n <Icon\n fill={true}\n name={name}\n size={BADGE_GLYPH_SIZE}\n sx={{ color: `${statusIconPalette(icon?.color)}.contrastText` }}\n />\n </Box>\n )\n}\n\n/**\n * Renders the row's leading logo from its `LogoRef`: a status icon, or an entity guid whose prefix\n * names the entity. An unrecognized prefix renders no logo rather than guessing.\n *\n * `resolveTopLevelCategory`: mxui's `CategoryIcon` only knows the top-level category guids and\n * silently falls back to the Uncategorized icon for a sub-category. The details drawer avoids\n * this by passing `transaction.top_level_category_guid`; the row only has the raw guid, so it is\n * walked up to its parent here (identity until categories load). That resolution applies both to a\n * `CAT-` row logo and to a merchant's `fallback_guid`. The variant's `categoryTint` styles only the\n * `CAT-` row branch; a merchant's `fallback_guid` keeps `MerchantLogo`'s untinted fallback.\n */\nconst renderRowLogo = (\n row: InstanceSlotRow,\n resolveTopLevelCategory: (guid: string) => string,\n theme: Theme,\n categoryTint?: number,\n) => {\n const logo = logoFromRef(row.logo, row.primary_text)\n\n if (!logo) return undefined\n\n if (logo.logo_name) {\n // A `{ icon, color }` status logo (e.g. an overdraft warning) renders as a bare coloured glyph.\n // An ICO- fill logo (the Weekly New Merchants \"Others\" row - `logo_fill` is set for ICO- refs\n // only, in EntityLogo) renders as an accent tile: per the MX accent-icon pattern the background is\n // the tile colour at 15% opacity and the glyph is the full tile colour (Figma). The tile colour is\n // the logo's own colour when it carries one, else chart-2 - so tile and glyph always match.\n const accentTile = !!logo.logo_fill\n const tileColor = logo.logo_color ?? theme.palette.chart.chart2 ?? theme.palette.primary.main\n return (\n <Box\n sx={{\n alignItems: 'center',\n display: 'flex',\n height: ROW_LOGO_SIZE,\n justifyContent: 'center',\n width: ROW_LOGO_SIZE,\n ...(accentTile && {\n bgcolor: alpha(tileColor, 0.15),\n // Figma: match the row's other logo tiles.\n borderRadius: `${theme.shape.borderRadius}px`,\n }),\n }}\n >\n <Icon\n name={logo.logo_name}\n size={ROW_ICON_SIZE}\n sx={{ color: accentTile ? tileColor : logo.logo_color }}\n />\n </Box>\n )\n }\n\n if (logo.merchant_guid) {\n return (\n <MerchantLogo\n alt={logo.merchant_name ?? ''}\n categoryGuid={logo.category_guid ? resolveTopLevelCategory(logo.category_guid) : ''}\n merchantGuid={logo.merchant_guid}\n size={ROW_LOGO_SIZE}\n />\n )\n }\n\n if (logo.institution_guid) {\n return (\n <InstitutionLogo\n alt={logo.institution_name ?? ''}\n institutionGuid={logo.institution_guid}\n size={ROW_LOGO_SIZE}\n />\n )\n }\n\n if (logo.category_guid) {\n const topLevelGuid = resolveTopLevelCategory(logo.category_guid)\n const categoryColor = getCategoryColor(topLevelGuid, theme)\n const tintSx =\n categoryTint !== undefined\n ? {\n bgcolor: alpha(categoryColor, categoryTint),\n border: `1px solid ${categoryColor}`,\n color: 'text.primary',\n }\n : undefined\n return (\n <Box data-testid={`category-icon-${topLevelGuid}`} sx={{ display: 'flex' }}>\n <CategoryIcon categoryGuid={topLevelGuid} size={ROW_LOGO_SIZE} sx={tintSx} />\n </Box>\n )\n }\n\n return undefined\n}\n\n/**\n * The `transaction_block`: rows the backend already localized, carried inline on\n * `instance_slot.data.series` (`logo`, `primary_text`, `secondary_text`, `amount`). Only the\n * amount is formatted here, because the contract sends it as a number. `instance_slot.variant`\n * picks the header and slot treatment from `./layout.ts`.\n *\n * This is the full/mini shape. The reduced widgets (micro, embedded) resolve to the row logo\n * alone, carried flat on `data.logo` with no `series`, and are drawn by `CompactInsightCard`.\n *\n * `status_message` draws no rows: `data.message` beside the `data.icon` logo, as a\n * `StatusMessageCard` banner (Uncategorized Transactions V2 `complete`).\n *\n * A header, when the variant shows one, comes from `instance_slot.data.header_text` (the\n * transaction date, or \"{count} transactions\"). It deliberately does *not* come from the first\n * row: on a `with_merchant` card a row's `secondary_text` is the category, so reading it here\n * rendered the category twice and dropped the date entirely.\n *\n * A footer/summary row (Replenish Savings' \"Remaining Balance\", Weekly New Merchants' \"Total\")\n * renders when the variant's `showFooter` config is set (`with_header_footer`, `with_footer`), from\n * `data.footer_text` with `data.footer_amount` beside it, formatted like the row amounts (the\n * contract sends it as a number).\n */\nexport const TransactionBlock = observer(({ payload }: TransactionBlockProps) => {\n const theme = useTheme()\n const { getTopLevelCategoryGuid } = useCategoryStore()\n const stores = useGlobalStore()\n const { recurring: recurringCopy } = useGlobalCopyStore()\n const { beat } = useBeatActions()\n const { data, variant } = payload.instance_slot\n // The plain row is the safe default: it adds nothing a wrong variant could misstate.\n const {\n answeredBackground,\n background,\n cardVariant,\n categoryTint,\n creditAmounts,\n elevated,\n followsSubscription,\n headerColor,\n raised,\n showFooter,\n showFrequency,\n showHeader,\n statusMessage,\n sx,\n } = resolveVariantConfig(\n getLayoutConfig(theme),\n variant,\n transactionBlockVariant.NoHeader,\n 'TransactionBlock',\n )\n\n // The live repeating transaction (read-only), for the frequency and the badge / answered wash.\n const repeating =\n (showFrequency || followsSubscription) && beat\n ? repeatingTransactionOf({ beat, stores })\n : undefined\n const subscribed = !!followsSubscription && repeating?.user_response === USER_RESPONSE.CONFIRMED\n\n if (statusMessage) {\n const message = slot<string>(data, 'message')\n if (typeof message !== 'string' || !message.trim()) {\n console.warn('[TransactionBlock] status_message has no message — rendering nothing.')\n return null\n }\n\n // The icon only decorates the message, so it is hidden from the status announcement.\n return (\n <StatusMessageCard\n icon={\n <Box aria-hidden=\"true\" sx={{ display: 'flex' }}>\n <LogoFromGuid logo={slot<LogoRef>(data, 'icon')} size={STATUS_ICON_SIZE} />\n </Box>\n }\n message={message}\n // The 20% wash layers over paper, as Figma's slot does.\n sx={background ? { backgroundImage: background, bgcolor: 'background.paper' } : undefined}\n />\n )\n }\n\n const series = slot<InstanceSlotRow[]>(data, 'series')\n const headerText = slot<string>(data, 'header_text')\n\n if (!Array.isArray(series) || !series.length) return null\n\n const header = showHeader && typeof headerText === 'string' ? headerText : undefined\n\n const footerText = slot<string>(data, 'footer_text')\n const footerAmount = slot<number>(data, 'footer_amount')\n const footer =\n showFooter && typeof footerText === 'string'\n ? {\n label: footerText,\n amount: formatCurrency(footerAmount, '0,0.00'),\n }\n : undefined\n\n // Live, as pulse: the repeating transaction the CTA's `prepare` loads.\n const frequency = showFrequency ? subscriptionFrequency(recurringCopy, repeating) : undefined\n const badge = followsSubscription ? (\n <SubscriptionBadge icon={slot<LogoRef>(data, subscribed ? 'reviewed_icon' : 'icon')} />\n ) : undefined\n\n // Only a positive amount reads as a credit.\n const isCredit = (amount: unknown) => !!creditAmounts && typeof amount === 'number' && amount > 0\n\n return (\n <TransactionListCard\n background={subscribed && answeredBackground ? answeredBackground : background}\n badge={badge}\n elevated={elevated}\n footer={footer}\n header={header}\n headerColor={headerColor}\n raised={raised}\n sx={sx}\n variant={cardVariant}\n rows={series.map((row) => ({\n amount:\n typeof row.amount === 'number'\n ? `${isCredit(row.amount) ? '+' : ''}${formatCurrency(row.amount, '0,0.00')}`\n : '',\n amountColor: isCredit(row.amount) ? 'success.main' : undefined,\n amountCaption: frequency,\n leading: renderRowLogo(row, getTopLevelCategoryGuid, theme, categoryTint),\n subtitle: row.secondary_text ?? '',\n title: row.primary_text ?? '',\n }))}\n />\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAgCA,IAAM,IAAgB,IAEhB,KAAgB,KAAK,MAAM,IAAgB,KAAK,GAChD,KAAmB,IAEnB,IAAa,IACb,KAAmB,IAGnB,KAAA,CAAqB,EAAE,MAAA,EAAA,MAA+B;AAC1D,QAAM,IAAO,EAAe,GAAM,IAAI;AAEtC,SAAK,IAGH,gBAAA,EAAC,GAAD;AAAA,IACE,eAAa;AAAA,IACb,aAAW;AAAA,IACX,eAAY;AAAA,IACZ,IAAI;AAAA,MACF,YAAY;AAAA,MACZ,SAAS,GAAG,EAAkB,GAAM,KAAK,CAAA;AAAA,MACzC,cAAc;AAAA,MACd,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,gBAAgB;AAAA,MAChB,OAAO;AAAA,IACT;AAAA,IAEA,UAAA,gBAAA,EAAC,GAA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AAM,EAAA,GAAK,EAAe,EAAI,QAAQ,QAAQ,CAAA,KACxE;AAAA,MACN,aAAa,EAAS,EAAI,MAAM,IAAI,iBAAiB;AAAA,MACrD,eAAe;AAAA,MACf,SAAS,GAAc,GAAK,GAAyB,GAAO,CAAY;AAAA,MACxE,UAAU,EAAI,kBAAkB;AAAA,MAChC,OAAO,EAAI,gBAAgB;AAAA,IAC7B,EAAE;AAAA,EACH,CAAA;AAEL,CAAC"}
|
|
1
|
+
{"version":3,"file":"TransactionBlock.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ComponentBlocks/TransactionBlock/TransactionBlock.tsx"],"sourcesContent":["import { observer } from 'mobx-react-lite'\n\nimport Box from '@mui/material/Box'\nimport { alpha, useTheme } from '@mui/material/styles'\nimport type { Theme } from '@mui/material/styles'\n\nimport { Icon } from '@mxenabled/mx-icons'\n\nimport { useGlobalCopyStore, useGlobalStore } from '../../../../common'\nimport { slot } from '../../../../core'\nimport type { InsightsPayload, InstanceSlotRow, LogoRef } from '../../../../core'\nimport { formatCurrency } from '../../../../core/utils/NumberFormatting'\n\nimport { useBeatActions } from '../../../beatActions'\nimport CategoryTile from '../../../components/CategoryTile'\nimport LogoFromGuid from '../../../components/LogoFromGuid'\nimport LogoMark, { isKnownIcon } from '../../../components/LogoMark'\nimport StatusMessageCard from '../../../components/StatusMessageCard'\nimport TransactionListCard from '../../../components/TransactionListCard'\nimport { logoFromRef } from '../../../components/shared/EntityLogo'\nimport { statusIconName, statusIconPalette } from '../../../components/statusIcon'\nimport { subscriptionFrequency } from '../../../components/SubscriptionStatus/subscriptionFrequency'\nimport { repeatingTransactionOf, USER_RESPONSE } from '../../../ctaActions/subscriptionAnswer'\n\nimport { resolveVariantConfig } from '../../resolveVariantConfig'\nimport { getLayoutConfig, transactionBlockVariant } from './layout'\n\ninterface TransactionBlockProps {\n payload: InsightsPayload\n beatGuid?: string\n}\n\nconst ROW_LOGO_SIZE = 32\n// Same glyph-to-tile ratio mxui's `CategoryIcon` uses, so a status icon sits like the other logos.\nconst ROW_ICON_SIZE = Math.round(ROW_LOGO_SIZE * 0.625)\nconst STATUS_ICON_SIZE = 24\n// Status badge: palette disc, contrastText glyph.\nconst BADGE_SIZE = 32\nconst BADGE_GLYPH_SIZE = 20\n\n/** Status disc from `data.icon` / `data.reviewed_icon`. */\nconst SubscriptionBadge = ({ icon }: { icon?: LogoRef }) => {\n const name = statusIconName(icon?.guid)\n\n if (!name) return null\n\n return (\n <Box\n aria-hidden={true}\n data-icon={name}\n data-testid=\"subscription-badge\"\n sx={{\n alignItems: 'center',\n bgcolor: `${statusIconPalette(icon?.color)}.main`,\n borderRadius: '50%',\n display: 'flex',\n height: BADGE_SIZE,\n justifyContent: 'center',\n width: BADGE_SIZE,\n }}\n >\n <Icon\n fill={true}\n name={name}\n size={BADGE_GLYPH_SIZE}\n sx={{ color: `${statusIconPalette(icon?.color)}.contrastText` }}\n />\n </Box>\n )\n}\n\n/**\n * The row's leading logo from its `LogoRef`; an unrecognized guid prefix draws none rather than\n * guessing. The variant's `categoryTint` styles only a `CAT-` row; a merchant's `fallback_guid`\n * keeps `MerchantLogo`'s untinted fallback.\n */\nconst renderRowLogo = (row: InstanceSlotRow, theme: Theme, categoryTint?: number) => {\n const logo = logoFromRef(row.logo, row.primary_text)\n\n if (!logo) return undefined\n\n if (logo.logo_name) {\n if (!isKnownIcon(logo.logo_name)) return undefined\n\n // A status `{ icon, color }` logo is a bare coloured glyph. An `ICO-` fill logo (Weekly New\n // Merchants' \"Others\" row) is Figma's accent tile: its colour, else chart-2, at 15% behind the glyph.\n const accentTile = !!logo.logo_fill\n const tileColor = logo.logo_color ?? theme.palette.chart.chart2 ?? theme.palette.primary.main\n return (\n <Box\n sx={{\n alignItems: 'center',\n display: 'flex',\n height: ROW_LOGO_SIZE,\n justifyContent: 'center',\n width: ROW_LOGO_SIZE,\n ...(accentTile && {\n bgcolor: alpha(tileColor, 0.15),\n // Figma: match the row's other logo tiles.\n borderRadius: `${theme.shape.borderRadius}px`,\n }),\n }}\n >\n <Icon\n name={logo.logo_name}\n size={ROW_ICON_SIZE}\n sx={{ color: accentTile ? tileColor : logo.logo_color }}\n />\n </Box>\n )\n }\n\n if (logo.merchant_guid || logo.institution_guid) {\n return <LogoMark logo={logo} size={ROW_LOGO_SIZE} />\n }\n\n if (logo.category_guid) {\n return (\n <CategoryTile categoryGuid={logo.category_guid} size={ROW_LOGO_SIZE} tint={categoryTint} />\n )\n }\n\n return undefined\n}\n\n/**\n * The `transaction_block`: rows the backend already localized, carried inline on\n * `instance_slot.data.series` (`logo`, `primary_text`, `secondary_text`, `amount`). Only the\n * amount is formatted here, because the contract sends it as a number. `instance_slot.variant`\n * picks the header and slot treatment from `./layout.ts`.\n *\n * This is the full/mini shape. The reduced widgets (micro, embedded) resolve to the row logo\n * alone, carried flat on `data.logo` with no `series`, and are drawn by `CompactInsightCard`.\n *\n * `status_message` draws no rows: `data.message` beside the `data.icon` logo, as a\n * `StatusMessageCard` banner (Uncategorized Transactions V2 `complete`).\n *\n * A header, when the variant shows one, comes from `instance_slot.data.header_text` (the\n * transaction date, or \"{count} transactions\"). It deliberately does *not* come from the first\n * row: on a `with_merchant` card a row's `secondary_text` is the category, so reading it here\n * rendered the category twice and dropped the date entirely.\n *\n * A footer/summary row (Replenish Savings' \"Remaining Balance\", Weekly New Merchants' \"Total\")\n * renders when the variant's `showFooter` config is set (`with_header_footer`, `with_footer`), from\n * `data.footer_text` with `data.footer_amount` beside it, formatted like the row amounts (the\n * contract sends it as a number).\n */\nexport const TransactionBlock = observer(({ payload }: TransactionBlockProps) => {\n const theme = useTheme()\n const stores = useGlobalStore()\n const { recurring: recurringCopy } = useGlobalCopyStore()\n const { beat } = useBeatActions()\n const { data, variant } = payload.instance_slot\n // The plain row is the safe default: it adds nothing a wrong variant could misstate.\n const {\n answeredBackground,\n background,\n cardVariant,\n categoryTint,\n creditAmounts,\n elevated,\n followsSubscription,\n headerColor,\n raised,\n showFooter,\n showFrequency,\n showHeader,\n statusMessage,\n sx,\n } = resolveVariantConfig(\n getLayoutConfig(theme),\n variant,\n transactionBlockVariant.NoHeader,\n 'TransactionBlock',\n )\n\n // The live repeating transaction (read-only), for the frequency and the badge / answered wash.\n const repeating =\n (showFrequency || followsSubscription) && beat\n ? repeatingTransactionOf({ beat, stores })\n : undefined\n const subscribed = !!followsSubscription && repeating?.user_response === USER_RESPONSE.CONFIRMED\n\n if (statusMessage) {\n const message = slot<string>(data, 'message')\n if (typeof message !== 'string' || !message.trim()) {\n console.warn('[TransactionBlock] status_message has no message — rendering nothing.')\n return null\n }\n\n // The icon only decorates the message, so it is hidden from the status announcement.\n return (\n <StatusMessageCard\n icon={\n <Box aria-hidden=\"true\" sx={{ display: 'flex' }}>\n <LogoFromGuid logo={slot<LogoRef>(data, 'icon')} size={STATUS_ICON_SIZE} />\n </Box>\n }\n message={message}\n // The 20% wash layers over paper, as Figma's slot does.\n sx={background ? { backgroundImage: background, bgcolor: 'background.paper' } : undefined}\n />\n )\n }\n\n const series = slot<InstanceSlotRow[]>(data, 'series')\n const headerText = slot<string>(data, 'header_text')\n\n if (!Array.isArray(series) || !series.length) return null\n\n const header = showHeader && typeof headerText === 'string' ? headerText : undefined\n\n const footerText = slot<string>(data, 'footer_text')\n const footerAmount = slot<number>(data, 'footer_amount')\n const footer =\n showFooter && typeof footerText === 'string'\n ? {\n label: footerText,\n amount: formatCurrency(footerAmount, '0,0.00'),\n }\n : undefined\n\n // Live, as pulse: the repeating transaction the CTA's `prepare` loads.\n const frequency = showFrequency ? subscriptionFrequency(recurringCopy, repeating) : undefined\n const badge = followsSubscription ? (\n <SubscriptionBadge icon={slot<LogoRef>(data, subscribed ? 'reviewed_icon' : 'icon')} />\n ) : undefined\n\n // Only a positive amount reads as a credit.\n const isCredit = (amount: unknown) => !!creditAmounts && typeof amount === 'number' && amount > 0\n\n return (\n <TransactionListCard\n background={subscribed && answeredBackground ? answeredBackground : background}\n badge={badge}\n elevated={elevated}\n footer={footer}\n header={header}\n headerColor={headerColor}\n raised={raised}\n sx={sx}\n variant={cardVariant}\n rows={series.map((row) => ({\n amount:\n typeof row.amount === 'number'\n ? `${isCredit(row.amount) ? '+' : ''}${formatCurrency(row.amount, '0,0.00')}`\n : '',\n amountColor: isCredit(row.amount) ? 'success.main' : undefined,\n amountCaption: frequency,\n leading: renderRowLogo(row, theme, categoryTint),\n subtitle: row.secondary_text ?? '',\n title: row.primary_text ?? '',\n }))}\n />\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAgCA,IAAM,IAAgB,IAEhB,KAAgB,KAAK,MAAM,IAAgB,KAAK,GAChD,KAAmB,IAEnB,IAAa,IACb,KAAmB,IAGnB,KAAA,CAAqB,EAAE,MAAA,EAAA,MAA+B;AAC1D,QAAM,IAAO,EAAe,GAAM,IAAI;AAEtC,SAAK,IAGH,gBAAA,EAAC,GAAD;AAAA,IACE,eAAa;AAAA,IACb,aAAW;AAAA,IACX,eAAY;AAAA,IACZ,IAAI;AAAA,MACF,YAAY;AAAA,MACZ,SAAS,GAAG,EAAkB,GAAM,KAAK,CAAA;AAAA,MACzC,cAAc;AAAA,MACd,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,gBAAgB;AAAA,MAChB,OAAO;AAAA,IACT;AAAA,IAEA,UAAA,gBAAA,EAAC,GAAD;AAAA,MACE,MAAM;AAAA,MACA,MAAA;AAAA,MACN,MAAM;AAAA,MACN,IAAI,EAAE,OAAO,GAAG,EAAkB,GAAM,KAAK,CAAA,gBAAiB;AAAA,IAC/D,CAAA;AAAA,EACE,CAAA,IAvBW;AAyBpB,GAOM,KAAA,CAAiB,GAAsB,GAAc,MAA0B;AACnF,QAAM,IAAO,EAAY,EAAI,MAAM,EAAI,YAAY;AAEnD,MAAK,GAEL;AAAA,QAAI,EAAK,WAAW;AAClB,UAAI,CAAC,EAAY,EAAK,SAAS,EAAG;AAIlC,YAAM,IAAa,CAAC,CAAC,EAAK,WACpB,IAAY,EAAK,cAAc,EAAM,QAAQ,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AAc,IAAqB,IAAqB;AAAA,IAC7D,OAAA;AAAA,IACG,UAAA;AAAA,IACF,QAAA;AAAA,IACA,QAAA;AAAA,IACK,aAAA;AAAA,IACL,QAAA;AAAA,IACJ,IAAA;AAAA,IACJ,SAAS;AAAA,IACT,MAAM,EAAO,IAAA,CAAK,OAAS;AAAA,MACzB,QACE,OAAO,EAAI,UAAW,WAClB,GAAG,EAAS,EAAI,MAAM,IAAI,MAAM,EAAA,GAAK,EAAe,EAAI,QAAQ,QAAQ,CAAA,KACxE;AAAA,MACN,aAAa,EAAS,EAAI,MAAM,IAAI,iBAAiB;AAAA,MACrD,eAAe;AAAA,MACf,SAAS,GAAc,GAAK,GAAO,CAAY;AAAA,MAC/C,UAAU,EAAI,kBAAkB;AAAA,MAChC,OAAO,EAAI,gBAAgB;AAAA,IAC7B,EAAE;AAAA,EACH,CAAA;AAEL,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface CategoryTileProps {
|
|
2
|
+
categoryGuid: string;
|
|
3
|
+
size: number;
|
|
4
|
+
/** Opacity of the category colour behind the glyph, with a category-colour border; none = mxui's tile. */
|
|
5
|
+
tint?: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* A category's icon tile. The guid walks up to its top-level parent first: `CategoryIcon` and
|
|
9
|
+
* `getCategoryColor` only know those, and draw a sub-category as Uncategorized.
|
|
10
|
+
*/
|
|
11
|
+
declare const CategoryTile: (({ categoryGuid, size, tint }: CategoryTileProps) => import("react/jsx-runtime").JSX.Element) & {
|
|
12
|
+
displayName: string;
|
|
13
|
+
};
|
|
14
|
+
export default CategoryTile;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useCategoryStore as p } from "../../common/context/hooks.es.js";
|
|
2
|
+
import { getCategoryColor as s } from "../../core/utils/CategoryUtil.es.js";
|
|
3
|
+
import { observer as d } from "mobx-react-lite";
|
|
4
|
+
import { CategoryIcon as l } from "@mxenabled/mxui";
|
|
5
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
6
|
+
import { alpha as c, useTheme as g } from "@mui/material/styles";
|
|
7
|
+
import f from "@mui/material/Box";
|
|
8
|
+
var b = d(({ categoryGuid: i, size: m, tint: r }) => {
|
|
9
|
+
const a = g(), o = p().getTopLevelCategoryGuid(i), e = s(o, a);
|
|
10
|
+
return /* @__PURE__ */ t(f, {
|
|
11
|
+
"data-testid": `category-icon-${o}`,
|
|
12
|
+
sx: { display: "flex" },
|
|
13
|
+
children: /* @__PURE__ */ t(l, {
|
|
14
|
+
categoryGuid: o,
|
|
15
|
+
size: m,
|
|
16
|
+
sx: r === void 0 ? void 0 : {
|
|
17
|
+
bgcolor: c(e, r),
|
|
18
|
+
border: `1px solid ${e}`,
|
|
19
|
+
color: "text.primary"
|
|
20
|
+
}
|
|
21
|
+
})
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
export {
|
|
25
|
+
b as default
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=CategoryTile.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CategoryTile.es.js","names":[],"sources":["../../../src/insights-v2/components/CategoryTile.tsx"],"sourcesContent":["import { observer } from 'mobx-react-lite'\n\nimport Box from '@mui/material/Box'\nimport { alpha, useTheme } from '@mui/material/styles'\n\nimport { CategoryIcon } from '@mxenabled/mxui'\n\nimport { useCategoryStore } from '../../common'\nimport { getCategoryColor } from '../../core/utils/CategoryUtil'\n\ninterface CategoryTileProps {\n categoryGuid: string\n size: number\n /** Opacity of the category colour behind the glyph, with a category-colour border; none = mxui's tile. */\n tint?: number\n}\n\n/**\n * A category's icon tile. The guid walks up to its top-level parent first: `CategoryIcon` and\n * `getCategoryColor` only know those, and draw a sub-category as Uncategorized.\n */\nconst CategoryTile = observer(({ categoryGuid, size, tint }: CategoryTileProps) => {\n const theme = useTheme()\n const guid = useCategoryStore().getTopLevelCategoryGuid(categoryGuid)\n const color = getCategoryColor(guid, theme)\n\n return (\n <Box data-testid={`category-icon-${guid}`} sx={{ display: 'flex' }}>\n <CategoryIcon\n categoryGuid={guid}\n size={size}\n sx={\n tint === undefined\n ? undefined\n : { bgcolor: alpha(color, tint), border: `1px solid ${color}`, color: 'text.primary' }\n }\n />\n </Box>\n )\n})\n\nexport default CategoryTile\n"],"mappings":";;;;;;;AAqBA,IAAM,IAAe,EAAA,CAAU,EAAE,cAAA,GAAc,MAAA,GAAM,MAAA,EAAA,MAA8B;AACjF,QAAM,IAAQ,EAAS,GACjB,IAAO,EAAiB,EAAE,wBAAwB,CAAY,GAC9D,IAAQ,EAAiB,GAAM,CAAK;AAE1C,SACE,gBAAA,EAAC,GAAD;AAAA,IAAK,eAAa,iBAAiB,CAAA;AAAA,IAAQ,IAAI,EAAE,SAAS,OAAO;AAAA,IAC/D,UAAA,gBAAA,EAAC,GAAD;AAAA,MACE,cAAc;AAAA,MACR,MAAA;AAAA,MACN,IACE,MAAS,SACL,SACA;AAAA,QAAE,SAAS,EAAM,GAAO,CAAI;AAAA,QAAG,QAAQ,aAAa,CAAA;AAAA,QAAS,OAAO;AAAA,MAAe;AAAA,IAE1F,CAAA;AAAA,EACE,CAAA;AAET,CAAC"}
|
|
@@ -9,9 +9,9 @@ interface LogoMarkProps {
|
|
|
9
9
|
*/
|
|
10
10
|
export declare const isKnownIcon: (name: string) => boolean;
|
|
11
11
|
/**
|
|
12
|
-
* A resolved `Logo` as its mxui component.
|
|
13
|
-
* `
|
|
14
|
-
*
|
|
12
|
+
* A resolved `Logo` as its mxui component. A merchant's fallback category walks up to its top-level
|
|
13
|
+
* parent as `CategoryTile` does, since mxui only knows those. Reads the category store, so it renders
|
|
14
|
+
* inside the app's providers.
|
|
15
15
|
*/
|
|
16
16
|
declare const LogoMark: (({ logo, size }: LogoMarkProps) => import("react/jsx-runtime").JSX.Element | null) & {
|
|
17
17
|
displayName: string;
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { useCategoryStore as e } from "../../common/context/hooks.es.js";
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import o from "./CategoryTile.es.js";
|
|
3
|
+
import { observer as a } from "mobx-react-lite";
|
|
4
|
+
import { InstitutionLogo as u, MerchantLogo as m } from "@mxenabled/mxui";
|
|
5
|
+
import { Icon as c, IconList as f } from "@mxenabled/mx-icons";
|
|
5
6
|
import { jsx as n } from "react/jsx-runtime";
|
|
6
|
-
var
|
|
7
|
+
var s = (r) => Object.hasOwn(f, r) ? !0 : (console.warn(`[LogoMark] "${r}" names no mx-icons icon — rendering nothing.`), !1), h = a(({ logo: r, size: t }) => {
|
|
7
8
|
const { getTopLevelCategoryGuid: i } = e();
|
|
8
|
-
return r.logo_name ?
|
|
9
|
+
return r.logo_name ? s(r.logo_name) ? /* @__PURE__ */ n(c, {
|
|
9
10
|
fill: r.logo_fill,
|
|
10
11
|
name: r.logo_name,
|
|
11
12
|
size: t,
|
|
12
13
|
sx: { color: r.logo_color }
|
|
13
|
-
}) : null : r.merchant_guid ? /* @__PURE__ */ n(
|
|
14
|
+
}) : null : r.merchant_guid ? /* @__PURE__ */ n(m, {
|
|
14
15
|
alt: r.merchant_name ?? "",
|
|
15
16
|
categoryGuid: r.category_guid ? i(r.category_guid) : "",
|
|
16
17
|
merchantGuid: r.merchant_guid,
|
|
@@ -19,14 +20,14 @@ var d = (r) => Object.hasOwn(s, r) ? !0 : (console.warn(`[LogoMark] "${r}" names
|
|
|
19
20
|
alt: r.institution_name ?? "",
|
|
20
21
|
institutionGuid: r.institution_guid,
|
|
21
22
|
size: t
|
|
22
|
-
}) : r.category_guid ? /* @__PURE__ */ n(
|
|
23
|
-
categoryGuid:
|
|
23
|
+
}) : r.category_guid ? /* @__PURE__ */ n(o, {
|
|
24
|
+
categoryGuid: r.category_guid,
|
|
24
25
|
size: t
|
|
25
26
|
}) : null;
|
|
26
27
|
});
|
|
27
28
|
export {
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
h as default,
|
|
30
|
+
s as isKnownIcon
|
|
30
31
|
};
|
|
31
32
|
|
|
32
33
|
//# sourceMappingURL=LogoMark.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LogoMark.es.js","names":[],"sources":["../../../src/insights-v2/components/LogoMark.tsx"],"sourcesContent":["import { observer } from 'mobx-react-lite'\n\nimport { Icon, IconList } from '@mxenabled/mx-icons'\nimport {
|
|
1
|
+
{"version":3,"file":"LogoMark.es.js","names":[],"sources":["../../../src/insights-v2/components/LogoMark.tsx"],"sourcesContent":["import { observer } from 'mobx-react-lite'\n\nimport { Icon, IconList } from '@mxenabled/mx-icons'\nimport { InstitutionLogo, MerchantLogo } from '@mxenabled/mxui'\n\nimport { useCategoryStore } from '../../common'\nimport type { Logo } from '../../core'\n\nimport CategoryTile from './CategoryTile'\n\ninterface LogoMarkProps {\n logo: Logo\n size: number\n}\n\n/**\n * Whether mx-icons draws `name` (own keys only, so `constructor` is rejected). An unknown name would\n * draw an empty box, so it is logged and the caller draws nothing.\n */\nexport const isKnownIcon = (name: string): boolean => {\n if (Object.hasOwn(IconList, name)) return true\n\n console.warn(`[LogoMark] \"${name}\" names no mx-icons icon — rendering nothing.`)\n return false\n}\n\n/**\n * A resolved `Logo` as its mxui component. A merchant's fallback category walks up to its top-level\n * parent as `CategoryTile` does, since mxui only knows those. Reads the category store, so it renders\n * inside the app's providers.\n */\nconst LogoMark = observer(({ logo, size }: LogoMarkProps) => {\n const { getTopLevelCategoryGuid } = useCategoryStore()\n\n if (logo.logo_name) {\n if (!isKnownIcon(logo.logo_name)) return null\n\n return (\n <Icon\n fill={logo.logo_fill}\n name={logo.logo_name}\n size={size}\n sx={{ color: logo.logo_color }}\n />\n )\n }\n\n if (logo.merchant_guid) {\n return (\n <MerchantLogo\n alt={logo.merchant_name ?? ''}\n categoryGuid={logo.category_guid ? getTopLevelCategoryGuid(logo.category_guid) : ''}\n merchantGuid={logo.merchant_guid}\n size={size}\n />\n )\n }\n\n if (logo.institution_guid) {\n return (\n <InstitutionLogo\n alt={logo.institution_name ?? ''}\n institutionGuid={logo.institution_guid}\n size={size}\n />\n )\n }\n\n if (logo.category_guid) {\n return <CategoryTile categoryGuid={logo.category_guid} size={size} />\n }\n\n return null\n})\n\nexport default LogoMark\n"],"mappings":";;;;;;AAmBA,IAAa,IAAA,CAAe,MACtB,OAAO,OAAO,GAAU,CAAI,IAAU,MAE1C,QAAQ,KAAK,eAAe,CAAA,+CAAmD,GACxE,KAQH,IAAW,EAAA,CAAU,EAAE,MAAA,GAAM,MAAA,EAAA,MAA0B;AAC3D,QAAM,EAAE,yBAAA,EAAA,IAA4B,EAAiB;AAErD,SAAI,EAAK,YACF,EAAY,EAAK,SAAS,IAG7B,gBAAA,EAAC,GAAD;AAAA,IACE,MAAM,EAAK;AAAA,IACX,MAAM,EAAK;AAAA,IACL,MAAA;AAAA,IACN,IAAI,EAAE,OAAO,EAAK,WAAW;AAAA,EAC9B,CAAA,IARsC,OAYvC,EAAK,gBAEL,gBAAA,EAAC,GAAD;AAAA,IACE,KAAK,EAAK,iBAAiB;AAAA,IAC3B,cAAc,EAAK,gBAAgB,EAAwB,EAAK,aAAa,IAAI;AAAA,IACjF,cAAc,EAAK;AAAA,IACb,MAAA;AAAA,EACP,CAAA,IAID,EAAK,mBAEL,gBAAA,EAAC,GAAD;AAAA,IACE,KAAK,EAAK,oBAAoB;AAAA,IAC9B,iBAAiB,EAAK;AAAA,IAChB,MAAA;AAAA,EACP,CAAA,IAID,EAAK,gBACA,gBAAA,EAAC,GAAD;AAAA,IAAc,cAAc,EAAK;AAAA,IAAqB,MAAA;AAAA,EAAO,CAAA,IAG/D;AACT,CAAC"}
|