@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.
@@ -1,148 +1,131 @@
1
- import { useCategoryStore as D, useGlobalCopyStore as H, useGlobalStore as P } from "../../../../common/context/hooks.es.js";
2
- import { slot as s } from "../../../../core/types/Insights.es.js";
3
- import { formatCurrency as I } from "../../../../core/utils/NumberFormatting.es.js";
4
- import { getCategoryColor as V } from "../../../../core/utils/CategoryUtil.es.js";
5
- import { useBeatActions as U } from "../../../beatActions.es.js";
6
- import { resolveVariantConfig as W } from "../../resolveVariantConfig.es.js";
7
- import { USER_RESPONSE as Y, repeatingTransactionOf as J } from "../../../ctaActions/subscriptionAnswer.es.js";
8
- import { logoFromRef as K } from "../../../components/shared/EntityLogo.es.js";
9
- import Q from "../../../components/LogoFromGuid.es.js";
10
- import { statusIconName as X, statusIconPalette as S } from "../../../components/statusIcon.es.js";
11
- import oo from "../../../components/TransactionListCard.es.js";
12
- import to from "../../../components/StatusMessageCard.es.js";
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 eo, transactionBlockVariant as io } from "./layout.es.js";
15
+ import { getLayoutConfig as to, transactionBlockVariant as eo } from "./layout.es.js";
15
16
  import { observer as no } from "mobx-react-lite";
16
- import { CategoryIcon as ao, InstitutionLogo as so, MerchantLogo as co } from "@mxenabled/mxui";
17
- import { Icon as E } from "@mxenabled/mx-icons";
18
- import { jsx as e } from "react/jsx-runtime";
19
- import { alpha as G, useTheme as uo } from "@mui/material/styles";
20
- import m from "@mui/material/Box";
21
- var u = 32, mo = Math.round(u * 0.625), lo = 24, T = 32, go = 20, fo = ({ icon: a }) => {
22
- const i = X(a?.guid);
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": i,
25
+ "data-icon": e,
26
26
  "data-testid": "subscription-badge",
27
27
  sx: {
28
28
  alignItems: "center",
29
- bgcolor: `${S(a?.color)}.main`,
29
+ bgcolor: `${C(i?.color)}.main`,
30
30
  borderRadius: "50%",
31
31
  display: "flex",
32
- height: T,
32
+ height: I,
33
33
  justifyContent: "center",
34
- width: T
34
+ width: I
35
35
  },
36
- children: /* @__PURE__ */ e(E, {
36
+ children: /* @__PURE__ */ t(S, {
37
37
  fill: !0,
38
- name: i,
39
- size: go,
40
- sx: { color: `${S(a?.color)}.contrastText` }
38
+ name: e,
39
+ size: mo,
40
+ sx: { color: `${C(i?.color)}.contrastText` }
41
41
  })
42
42
  }) : null;
43
- }, po = (a, i, c, d) => {
44
- const o = K(a.logo, a.primary_text);
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
- const n = !!o.logo_fill, r = o.logo_color ?? c.palette.chart.chart2 ?? c.palette.primary.main;
48
- return /* @__PURE__ */ e(m, {
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: u,
53
+ height: c,
53
54
  justifyContent: "center",
54
- width: u,
55
- ...n && {
56
- bgcolor: G(r, 0.15),
57
- borderRadius: `${c.shape.borderRadius}px`
55
+ width: c,
56
+ ...s && {
57
+ bgcolor: io(n, 0.15),
58
+ borderRadius: `${e.shape.borderRadius}px`
58
59
  }
59
60
  },
60
- children: /* @__PURE__ */ e(E, {
61
+ children: /* @__PURE__ */ t(S, {
61
62
  name: o.logo_name,
62
- size: mo,
63
- sx: { color: n ? r : o.logo_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__ */ e(co, {
68
- alt: o.merchant_name ?? "",
69
- categoryGuid: o.category_guid ? i(o.category_guid) : "",
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.institution_guid) return /* @__PURE__ */ e(so, {
74
- alt: o.institution_name ?? "",
75
- institutionGuid: o.institution_guid,
76
- size: u
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
- }, Fo = no(({ payload: a }) => {
96
- const i = uo(), { getTopLevelCategoryGuid: c } = D(), d = P(), { recurring: o } = H(), { beat: n } = U(), { data: r, variant: l } = a.instance_slot, { answeredBackground: y, background: g, cardVariant: B, categoryTint: R, creditAmounts: k, elevated: L, followsSubscription: f, headerColor: O, raised: A, showFooter: $, showFrequency: _, showHeader: z, statusMessage: F, sx: N } = W(eo(i), l, io.NoHeader, "TransactionBlock"), h = (_ || f) && n ? J({
97
- beat: n,
98
- stores: d
99
- }) : void 0, b = !!f && h?.user_response === Y.CONFIRMED;
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 t = s(r, "message");
102
- return typeof t != "string" || !t.trim() ? (console.warn("[TransactionBlock] status_message has no message — rendering nothing."), null) : /* @__PURE__ */ e(to, {
103
- icon: /* @__PURE__ */ e(m, {
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__ */ e(Q, {
107
- logo: s(r, "icon"),
108
- size: lo
89
+ children: /* @__PURE__ */ t(J, {
90
+ logo: a(n, "icon"),
91
+ size: co
109
92
  })
110
93
  }),
111
- message: t,
112
- sx: g ? {
113
- backgroundImage: g,
94
+ message: r,
95
+ sx: u ? {
96
+ backgroundImage: u,
114
97
  bgcolor: "background.paper"
115
98
  } : void 0
116
99
  });
117
100
  }
118
- const p = s(r, "series"), x = s(r, "header_text");
119
- if (!Array.isArray(p) || !p.length) return null;
120
- const M = z && typeof x == "string" ? x : void 0, v = s(r, "footer_text"), Z = s(r, "footer_amount"), w = $ && typeof v == "string" ? {
121
- label: v,
122
- amount: I(Z, "0,0.00")
123
- } : void 0, j = _ ? ro(o, h) : void 0, q = f ? /* @__PURE__ */ e(fo, { icon: s(r, b ? "reviewed_icon" : "icon") }) : void 0, C = (t) => !!k && typeof t == "number" && t > 0;
124
- return /* @__PURE__ */ e(oo, {
125
- background: b && y ? y : g,
126
- badge: q,
127
- elevated: L,
128
- footer: w,
129
- header: M,
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: B,
134
- rows: p.map((t) => ({
135
- amount: typeof t.amount == "number" ? `${C(t.amount) ? "+" : ""}${I(t.amount, "0,0.00")}` : "",
136
- amountColor: C(t.amount) ? "success.main" : void 0,
137
- amountCaption: j,
138
- leading: po(t, c, i, R),
139
- subtitle: t.secondary_text ?? "",
140
- title: t.primary_text ?? ""
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
- Fo as TransactionBlock
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 }))}\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GA,IAAY,IAAgB,GAAsB,GAAe,CAAS,IAAI,QAC9E,IAAQ,IACZ,gBAAA,EAAC,IAAD,EAAmB,MAAM,EAAc,GAAM,IAAa,kBAAkB,MAAM,EAAI,CAAA,IACpF,QAGE,IAAA,CAAY,MAAoB,CAAC,CAAC,KAAiB,OAAO,KAAW,YAAY,IAAS;AAEhG,SACE,gBAAA,EAAC,IAAD;AAAA,IACE,YAAY,KAAc,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,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,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QAAQ,CAAM,KAAK,CAAC,EAAO,OAAQ,QAAO;AAErD,QAAM,IAAS,KAAc,OAAO,KAAe,WAAW,IAAa,QAErE,IAAa,EAAa,GAAM,aAAa,GAC7C,IAAe,EAAa,GAAM,eAAe,GACjD,IACJ,KAAc,OAAO,KAAe,WAChC;AAAA,IACE,OAAO;AAAA,IACP,QAAQ,EAAe,GAAc,QAAQ;AAAA,EAC/C,IACA,QAGA,IAAY,IAAgB,GAAsB,GAAe,CAAS,IAAI,QAC9E,IAAQ,IACZ,gBAAA,EAAC,IAAD,EAAmB,MAAM,EAAc,GAAM,IAAa,kBAAkB,MAAM,EAAI,CAAA,IACpF,QAGE,IAAA,CAAY,MAAoB,CAAC,CAAC,KAAiB,OAAO,KAAW,YAAY,IAAS;AAEhG,SACE,gBAAA,EAAC,GAAD;AAAA,IACE,YAAY,KAAc,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. Categories walk up to their top-level parent first:
13
- * `CategoryIcon` only knows those and shows the Uncategorized glyph for a sub-category. Reads the
14
- * category store, so it renders inside the app's providers.
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 { observer as o } from "mobx-react-lite";
3
- import { CategoryIcon as a, InstitutionLogo as u, MerchantLogo as c } from "@mxenabled/mxui";
4
- import { Icon as m, IconList as s } from "@mxenabled/mx-icons";
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 d = (r) => Object.hasOwn(s, r) ? !0 : (console.warn(`[LogoMark] "${r}" names no mx-icons icon — rendering nothing.`), !1), l = o(({ logo: r, size: t }) => {
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 ? d(r.logo_name) ? /* @__PURE__ */ n(m, {
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(c, {
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(a, {
23
- categoryGuid: i(r.category_guid),
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
- l as default,
29
- d as isKnownIcon
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 { CategoryIcon, InstitutionLogo, MerchantLogo } from '@mxenabled/mxui'\n\nimport { useCategoryStore } from '../../common'\nimport type { Logo } from '../../core'\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. Categories walk up to their top-level parent first:\n * `CategoryIcon` only knows those and shows the Uncategorized glyph for a sub-category. Reads the\n * category store, so it renders 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 <CategoryIcon categoryGuid={getTopLevelCategoryGuid(logo.category_guid)} size={size} />\n }\n\n return null\n})\n\nexport default LogoMark\n"],"mappings":";;;;;AAiBA,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,EAAwB,EAAK,aAAa;AAAA,IAAS,MAAA;AAAA,EAAO,CAAA,IAGxF;AACT,CAAC"}
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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mx-cartographer/experiences",
3
- "version": "9.7.127",
3
+ "version": "9.7.128",
4
4
  "description": "Library containing experience widgets",
5
5
  "author": "MX",
6
6
  "license": "MIT",