@mx-cartographer/experiences 9.7.126 → 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.
Files changed (28) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetDetailsBlock.es.js +101 -105
  3. package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetDetailsBlock.es.js.map +1 -1
  4. package/dist/insights-v2/actionBlocks/RemainingCashBlock/RemainingCashBlock.es.js +44 -43
  5. package/dist/insights-v2/actionBlocks/RemainingCashBlock/RemainingCashBlock.es.js.map +1 -1
  6. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js +66 -65
  7. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js.map +1 -1
  8. package/dist/insights-v2/blocks/ComponentBlocks/BudgetBlock/BudgetBlock.es.js +24 -30
  9. package/dist/insights-v2/blocks/ComponentBlocks/BudgetBlock/BudgetBlock.es.js.map +1 -1
  10. package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/TransactionBlock.es.js +84 -101
  11. package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/TransactionBlock.es.js.map +1 -1
  12. package/dist/insights-v2/components/CategoryTile.d.ts +14 -0
  13. package/dist/insights-v2/components/CategoryTile.es.js +28 -0
  14. package/dist/insights-v2/components/CategoryTile.es.js.map +1 -0
  15. package/dist/insights-v2/components/ComponentBlocks/DepositLogo.d.ts +5 -16
  16. package/dist/insights-v2/components/ComponentBlocks/DepositLogo.es.js +14 -17
  17. package/dist/insights-v2/components/ComponentBlocks/DepositLogo.es.js.map +1 -1
  18. package/dist/insights-v2/components/LogoFromGuid.d.ts +3 -13
  19. package/dist/insights-v2/components/LogoFromGuid.es.js +21 -46
  20. package/dist/insights-v2/components/LogoFromGuid.es.js.map +1 -1
  21. package/dist/insights-v2/components/LogoMark.d.ts +19 -0
  22. package/dist/insights-v2/components/LogoMark.es.js +33 -0
  23. package/dist/insights-v2/components/LogoMark.es.js.map +1 -0
  24. package/dist/insights-v2/components/SubHeader.es.js +13 -27
  25. package/dist/insights-v2/components/SubHeader.es.js.map +1 -1
  26. package/dist/insights-v2/components/shared/EntityLogo.d.ts +2 -2
  27. package/dist/insights-v2/components/shared/EntityLogo.es.js.map +1 -1
  28. package/package.json +1 -1
@@ -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 }))}\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,GAaM,KAAA,CACJ,GACA,GACA,GACA,MACG;AACH,QAAM,IAAO,EAAY,EAAI,MAAM,EAAI,YAAY;AAEnD,MAAK,GAEL;AAAA,QAAI,EAAK,WAAW;AAMlB,YAAM,IAAa,CAAC,CAAC,EAAK,WACpB,IAAY,EAAK,cAAc,EAAM,QAAQ,MAAM,UAAU,EAAM,QAAQ,QAAQ;AACzF,aACE,gBAAA,EAAC,GAAD;AAAA,QACE,IAAI;AAAA,UACF,YAAY;AAAA,UACZ,SAAS;AAAA,UACT,QAAQ;AAAA,UACR,gBAAgB;AAAA,UAChB,OAAO;AAAA,UACP,GAAI,KAAc;AAAA,YA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AM,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,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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TileProps {
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"}
@@ -1,22 +1,11 @@
1
1
  interface DepositLogoProps {
2
- /** Category guid, required alongside `merchantGuid` for the merchant logo lookup. */
3
- categoryGuid?: string;
4
- /** Fallback mx-icons ligature glyph for the generic tile when no guid is present. */
2
+ /** mx-icons glyph for the generic tile when no institution guid is sent. */
5
3
  iconName?: string;
6
- /** Institution guid — renders an `InstitutionLogo` when present and no merchant guid. */
4
+ /** Renders the institution's logo when present. */
7
5
  institutionGuid?: string;
8
- /** Institution display name, used as the logo's alt text. */
6
+ /** The institution's name, used as the logo's alt text. */
9
7
  institutionName?: string;
10
- /** Merchant guid — renders a `MerchantLogo` when present (highest priority). */
11
- merchantGuid?: string;
12
- /** Merchant display name, used as the logo's alt text. */
13
- merchantName?: string;
14
8
  }
15
- /**
16
- * Logo shown in a deposit callout. Mirrors the spec's per-variant sourcing: a real
17
- * merchant logo when a `merchantGuid` is sent (Payroll, Merchant Credit, Payroll Advance),
18
- * an institution logo for institution-sourced deposits (Check, Large Deposit), and a themed
19
- * generic tile otherwise (Government, Tax).
20
- */
21
- export declare const DepositLogo: ({ categoryGuid, iconName, institutionGuid, institutionName, merchantGuid, merchantName, }: DepositLogoProps) => import("react/jsx-runtime").JSX.Element;
9
+ /** Logo shown in a deposit callout: the institution's logo, or a themed generic tile without one. */
10
+ export declare const DepositLogo: ({ iconName, institutionGuid, institutionName, }: DepositLogoProps) => import("react/jsx-runtime").JSX.Element;
22
11
  export default DepositLogo;
@@ -1,8 +1,8 @@
1
- import c from "@mui/material/Stack";
2
- import { InstitutionLogo as m, MerchantLogo as f } from "@mxenabled/mxui";
3
- import { Icon as g } from "@mxenabled/mx-icons";
1
+ import s from "../LogoMark.es.js";
2
+ import i from "@mui/material/Stack";
3
+ import { Icon as n } from "@mxenabled/mx-icons";
4
4
  import { jsx as o } from "react/jsx-runtime";
5
- var s = 48, l = ({ iconName: t }) => /* @__PURE__ */ o(c, {
5
+ var a = 48, m = ({ iconName: t }) => /* @__PURE__ */ o(i, {
6
6
  sx: {
7
7
  alignItems: "center",
8
8
  bgcolor: "success.main",
@@ -10,24 +10,21 @@ var s = 48, l = ({ iconName: t }) => /* @__PURE__ */ o(c, {
10
10
  justifyContent: "center",
11
11
  width: "100%"
12
12
  },
13
- children: /* @__PURE__ */ o(g, {
13
+ children: /* @__PURE__ */ o(n, {
14
14
  name: t,
15
15
  size: 24,
16
16
  sx: { color: "success.contrastText" }
17
17
  })
18
- }), h = ({ categoryGuid: t, iconName: i = "payments", institutionGuid: e, institutionName: a, merchantGuid: r, merchantName: n }) => r ? /* @__PURE__ */ o(f, {
19
- alt: n ?? "",
20
- categoryGuid: t ?? "",
21
- merchantGuid: r,
22
- size: s
23
- }) : e ? /* @__PURE__ */ o(m, {
24
- alt: a ?? "",
25
- institutionGuid: e,
26
- size: s
27
- }) : /* @__PURE__ */ o(l, { iconName: i });
18
+ }), f = ({ iconName: t = "payments", institutionGuid: e, institutionName: r }) => e ? /* @__PURE__ */ o(s, {
19
+ logo: {
20
+ institution_guid: e,
21
+ institution_name: r
22
+ },
23
+ size: a
24
+ }) : /* @__PURE__ */ o(m, { iconName: t });
28
25
  export {
29
- h as DepositLogo,
30
- h as default
26
+ f as DepositLogo,
27
+ f as default
31
28
  };
32
29
 
33
30
  //# sourceMappingURL=DepositLogo.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DepositLogo.es.js","names":[],"sources":["../../../../src/insights-v2/components/ComponentBlocks/DepositLogo.tsx"],"sourcesContent":["import Stack from '@mui/material/Stack'\n\nimport { InstitutionLogo, MerchantLogo } from '@mxenabled/mxui'\nimport { Icon } from '@mxenabled/mx-icons'\n\ninterface DepositLogoProps {\n /** Category guid, required alongside `merchantGuid` for the merchant logo lookup. */\n categoryGuid?: string\n /** Fallback mx-icons ligature glyph for the generic tile when no guid is present. */\n iconName?: string\n /** Institution guid — renders an `InstitutionLogo` when present and no merchant guid. */\n institutionGuid?: string\n /** Institution display name, used as the logo's alt text. */\n institutionName?: string\n /** Merchant guid — renders a `MerchantLogo` when present (highest priority). */\n merchantGuid?: string\n /** Merchant display name, used as the logo's alt text. */\n merchantName?: string\n}\n\nconst SIZE = 48\n\n/**\n * Square themed tile standing in for a merchant/institution logo when no guid is sent.\n * Drawn with theme colors so it stays correct in dark mode.\n */\nconst DepositLogoTile = ({ iconName }: { iconName: string }) => (\n <Stack\n sx={{\n alignItems: 'center',\n bgcolor: 'success.main',\n height: '100%',\n justifyContent: 'center',\n width: '100%',\n }}\n >\n <Icon name={iconName} size={24} sx={{ color: 'success.contrastText' }} />\n </Stack>\n)\n\n/**\n * Logo shown in a deposit callout. Mirrors the spec's per-variant sourcing: a real\n * merchant logo when a `merchantGuid` is sent (Payroll, Merchant Credit, Payroll Advance),\n * an institution logo for institution-sourced deposits (Check, Large Deposit), and a themed\n * generic tile otherwise (Government, Tax).\n */\nexport const DepositLogo = ({\n categoryGuid,\n iconName = 'payments',\n institutionGuid,\n institutionName,\n merchantGuid,\n merchantName,\n}: DepositLogoProps) => {\n if (merchantGuid) {\n return (\n <MerchantLogo\n alt={merchantName ?? ''}\n categoryGuid={categoryGuid ?? ''}\n merchantGuid={merchantGuid}\n size={SIZE}\n />\n )\n }\n\n if (institutionGuid) {\n return (\n <InstitutionLogo alt={institutionName ?? ''} institutionGuid={institutionGuid} size={SIZE} />\n )\n }\n\n return <DepositLogoTile iconName={iconName} />\n}\n\nexport default DepositLogo\n"],"mappings":";;;;AAoBA,IAAM,IAAO,IAMP,IAAA,CAAmB,EAAE,UAAA,EAAA,MACzB,gBAAA,EAAC,GAAD;AAAA,EACE,IAAI;AAAA,IACF,YAAY;AAAA,IACZ,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,gBAAgB;AAAA,IAChB,OAAO;AAAA,EACT;AAAA,EAEA,UAAA,gBAAA,EAAC,GAAD;AAAA,IAAM,MAAM;AAAA,IAAU,MAAM;AAAA,IAAI,IAAI,EAAE,OAAO,uBAAuB;AAAA,EAAI,CAAA;AACnE,CAAA,GASI,IAAA,CAAe,EAC1B,cAAA,GACA,UAAA,IAAW,YACX,iBAAA,GACA,iBAAA,GACA,cAAA,GACA,cAAA,EAAA,MAEI,IAEA,gBAAA,EAAC,GAAD;AAAA,EACE,KAAK,KAAgB;AAAA,EACrB,cAAc,KAAgB;AAAA,EAChB,cAAA;AAAA,EACd,MAAM;AACP,CAAA,IAID,IAEA,gBAAA,EAAC,GAAD;AAAA,EAAiB,KAAK,KAAmB;AAAA,EAAqB,iBAAA;AAAA,EAAiB,MAAM;AAAO,CAAA,IAIzF,gBAAA,EAAC,GAAD,EAA2B,UAAA,EAAW,CAAA"}
1
+ {"version":3,"file":"DepositLogo.es.js","names":[],"sources":["../../../../src/insights-v2/components/ComponentBlocks/DepositLogo.tsx"],"sourcesContent":["import Stack from '@mui/material/Stack'\n\nimport { Icon } from '@mxenabled/mx-icons'\n\nimport LogoMark from '../LogoMark'\n\ninterface DepositLogoProps {\n /** mx-icons glyph for the generic tile when no institution guid is sent. */\n iconName?: string\n /** Renders the institution's logo when present. */\n institutionGuid?: string\n /** The institution's name, used as the logo's alt text. */\n institutionName?: string\n}\n\nconst SIZE = 48\n\n/** Themed tile standing in for the logo when no guid is sent; theme colors keep it right in dark mode. */\nconst DepositLogoTile = ({ iconName }: { iconName: string }) => (\n <Stack\n sx={{\n alignItems: 'center',\n bgcolor: 'success.main',\n height: '100%',\n justifyContent: 'center',\n width: '100%',\n }}\n >\n <Icon name={iconName} size={24} sx={{ color: 'success.contrastText' }} />\n </Stack>\n)\n\n/** Logo shown in a deposit callout: the institution's logo, or a themed generic tile without one. */\nexport const DepositLogo = ({\n iconName = 'payments',\n institutionGuid,\n institutionName,\n}: DepositLogoProps) =>\n institutionGuid ? (\n <LogoMark\n logo={{ institution_guid: institutionGuid, institution_name: institutionName }}\n size={SIZE}\n />\n ) : (\n <DepositLogoTile iconName={iconName} />\n )\n\nexport default DepositLogo\n"],"mappings":";;;;AAeA,IAAM,IAAO,IAGP,IAAA,CAAmB,EAAE,UAAA,EAAA,MACzB,gBAAA,EAAC,GAAD;AAAA,EACE,IAAI;AAAA,IACF,YAAY;AAAA,IACZ,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,gBAAgB;AAAA,IAChB,OAAO;AAAA,EACT;AAAA,EAEA,UAAA,gBAAA,EAAC,GAAD;AAAA,IAAM,MAAM;AAAA,IAAU,MAAM;AAAA,IAAI,IAAI,EAAE,OAAO,uBAAuB;AAAA,EAAI,CAAA;AACnE,CAAA,GAII,IAAA,CAAe,EAC1B,UAAA,IAAW,YACX,iBAAA,GACA,iBAAA,EAAA,MAEA,IACE,gBAAA,EAAC,GAAD;AAAA,EACE,MAAM;AAAA,IAAE,kBAAkB;AAAA,IAAiB,kBAAkB;AAAA,EAAgB;AAAA,EAC7E,MAAM;AACP,CAAA,IAED,gBAAA,EAAC,GAAD,EAA2B,UAAA,EAAW,CAAA"}
@@ -9,18 +9,8 @@ export interface LogoFromGuidProps {
9
9
  }
10
10
  /**
11
11
  * One component for every V2 logo. The envelope sends a single `{ guid, fallback_guid?, alt? }`
12
- * object whose prefix says what it is; this maps it onto the mxui component's props and renders
13
- * nothing — never a guess — for anything else (`PARENT-ENTITY`, an `ACT-`/`BGT-` guid, an empty guid).
14
- *
15
- * The fallback chain is mxui's, not ours: asset for `guid` → category tile for `fallback_guid`
16
- * (`MerchantLogo`'s `categoryGuid`, applied only when it is a `CAT-` guid because a category tile is
17
- * the only fallback `MerchantLogo` has) → `alt`. Nothing here probes whether an asset exists.
18
- *
19
- * Categories are walked up to their top-level parent before reaching mxui: `CategoryIcon` only knows
20
- * the top-level guids and silently shows the Uncategorized glyph for a sub-category (identity until
21
- * categories load). That applies to a `CAT-` logo and to a merchant's `fallback_guid` alike.
12
+ * object whose prefix says what it is; anything else (`PARENT-ENTITY`, an `ACT-`/`BGT-` guid, an
13
+ * empty guid) renders nothing, never a guess. The asset → category tile → `alt` fallback is mxui's.
22
14
  */
23
- declare const LogoFromGuid: (({ className, logo, size }: LogoFromGuidProps) => import("react/jsx-runtime").JSX.Element | null) & {
24
- displayName: string;
25
- };
15
+ declare const LogoFromGuid: ({ className, logo, size }: LogoFromGuidProps) => import("react/jsx-runtime").JSX.Element | null;
26
16
  export default LogoFromGuid;
@@ -1,45 +1,17 @@
1
- import { useCategoryStore as l } from "../../common/context/hooks.es.js";
2
- import { logoFromRef as u } from "./shared/EntityLogo.es.js";
3
- import { observer as g } from "mobx-react-lite";
4
- import { CategoryIcon as m, InstitutionLogo as c, MerchantLogo as d } from "@mxenabled/mxui";
5
- import { Icon as f, IconList as s } from "@mxenabled/mx-icons";
6
- import { jsx as n } from "react/jsx-runtime";
7
- import _ from "@mui/material/Box";
8
- var h = /^(MCH|CAT|INS)-|^ICO-[a-z0-9_-]+$/, y = (e) => !!e && h.test(e), F = g(({ className: e, logo: t, size: i }) => {
9
- const { getTopLevelCategoryGuid: a } = l();
10
- if (!t || !y(t.guid)) return null;
11
- const o = u({
12
- alt: t.alt,
13
- color: t.color,
14
- fallback_guid: t.fallback_guid,
15
- guid: t.guid
1
+ import l, { isKnownIcon as n } from "./LogoMark.es.js";
2
+ import { logoFromRef as a } from "./shared/EntityLogo.es.js";
3
+ import { jsx as e } from "react/jsx-runtime";
4
+ import u from "@mui/material/Box";
5
+ var f = /^(MCH|CAT|INS)-|^ICO-[a-z0-9_-]+$/, d = (o) => !!o && f.test(o), _ = ({ className: o, logo: r, size: i }) => {
6
+ if (!r || !d(r.guid)) return null;
7
+ const t = a({
8
+ alt: r.alt,
9
+ color: r.color,
10
+ fallback_guid: r.fallback_guid,
11
+ guid: r.guid
16
12
  });
17
- if (!o) return null;
18
- let r = null;
19
- if (o.logo_name) {
20
- if (!(o.logo_name in s))
21
- return console.warn(`[LogoFromGuid] "${t.guid}" names no mx-icons icon — rendering nothing.`), null;
22
- r = /* @__PURE__ */ n(f, {
23
- fill: o.logo_fill,
24
- name: o.logo_name,
25
- size: i,
26
- sx: { color: o.logo_color }
27
- });
28
- } else o.merchant_guid ? r = /* @__PURE__ */ n(d, {
29
- alt: o.merchant_name ?? "",
30
- categoryGuid: o.category_guid ? a(o.category_guid) : "",
31
- merchantGuid: o.merchant_guid,
32
- size: i
33
- }) : o.institution_guid ? r = /* @__PURE__ */ n(c, {
34
- alt: o.institution_name ?? "",
35
- institutionGuid: o.institution_guid,
36
- size: i
37
- }) : o.category_guid && (r = /* @__PURE__ */ n(m, {
38
- categoryGuid: a(o.category_guid),
39
- size: i
40
- }));
41
- return r ? /* @__PURE__ */ n(_, {
42
- className: e,
13
+ return !t || t.logo_name && !n(t.logo_name) ? null : /* @__PURE__ */ e(u, {
14
+ className: o,
43
15
  "data-testid": "logo-from-guid",
44
16
  sx: {
45
17
  alignItems: "center",
@@ -49,12 +21,15 @@ var h = /^(MCH|CAT|INS)-|^ICO-[a-z0-9_-]+$/, y = (e) => !!e && h.test(e), F = g(
49
21
  justifyContent: "center",
50
22
  width: i
51
23
  },
52
- children: r
53
- }) : null;
54
- });
24
+ children: /* @__PURE__ */ e(l, {
25
+ logo: t,
26
+ size: i
27
+ })
28
+ });
29
+ };
55
30
  export {
56
- F as default,
57
- y as isLogoGuid
31
+ _ as default,
32
+ d as isLogoGuid
58
33
  };
59
34
 
60
35
  //# sourceMappingURL=LogoFromGuid.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LogoFromGuid.es.js","names":[],"sources":["../../../src/insights-v2/components/LogoFromGuid.tsx"],"sourcesContent":["import { observer } from 'mobx-react-lite'\n\nimport Box from '@mui/material/Box'\n\nimport { Icon, IconList } from '@mxenabled/mx-icons'\nimport { CategoryIcon, InstitutionLogo, MerchantLogo } from '@mxenabled/mxui'\n\nimport { useCategoryStore } from '../../common'\nimport type { LogoRef } from '../../core'\nimport { logoFromRef } from './shared/EntityLogo'\n\n/**\n * The guid prefixes that name a logo entity. A prefix heuristic by design: the V2 envelope carries\n * the entity only in the guid, and the notification row relies on non-insight rows carrying account\n * or budget guids and legacy insight rows carrying the `\"PARENT-ENTITY\"` sentinel. Exported beside\n * the component so a caller's branch (`NotificationCard`) and the dispatch here cannot drift apart.\n */\nconst LOGO_GUID_PREFIX = /^(MCH|CAT|INS)-|^ICO-[a-z0-9_-]+$/\n\nexport const isLogoGuid = (guid?: string | null): guid is string =>\n !!guid && LOGO_GUID_PREFIX.test(guid)\n\nexport interface LogoFromGuidProps {\n /** The envelope's logo object: `{ guid, fallback_guid?, alt?, color? }` (`color` is read for `ICO-` icons). */\n logo?: Pick<LogoRef, 'alt' | 'color' | 'fallback_guid' | 'guid'> | null\n /** Rendered square size in px (32 on rows, 40 on the compact card, 33 on the notification row). */\n size: number\n className?: string\n}\n\n/**\n * One component for every V2 logo. The envelope sends a single `{ guid, fallback_guid?, alt? }`\n * object whose prefix says what it is; this maps it onto the mxui component's props and renders\n * nothing — never a guess — for anything else (`PARENT-ENTITY`, an `ACT-`/`BGT-` guid, an empty guid).\n *\n * The fallback chain is mxui's, not ours: asset for `guid` → category tile for `fallback_guid`\n * (`MerchantLogo`'s `categoryGuid`, applied only when it is a `CAT-` guid because a category tile is\n * the only fallback `MerchantLogo` has) → `alt`. Nothing here probes whether an asset exists.\n *\n * Categories are walked up to their top-level parent before reaching mxui: `CategoryIcon` only knows\n * the top-level guids and silently shows the Uncategorized glyph for a sub-category (identity until\n * categories load). That applies to a `CAT-` logo and to a merchant's `fallback_guid` alike.\n */\nconst LogoFromGuid = observer(({ className, logo, size }: LogoFromGuidProps) => {\n const { getTopLevelCategoryGuid } = useCategoryStore()\n\n if (!logo || !isLogoGuid(logo.guid)) return null\n\n // Guid-only on purpose: `logoFromRef` lets a status `icon` win over `guid`, which is right for a\n // row but would silently turn this component into an icon renderer.\n const resolved = logoFromRef({\n alt: logo.alt,\n color: logo.color,\n fallback_guid: logo.fallback_guid,\n guid: logo.guid,\n })\n\n if (!resolved) return null\n\n let content: React.ReactNode = null\n\n if (resolved.logo_name) {\n // An unmapped name would draw an empty box; say so and draw nothing instead.\n if (!(resolved.logo_name in IconList)) {\n console.warn(`[LogoFromGuid] \"${logo.guid}\" names no mx-icons icon — rendering nothing.`)\n return null\n }\n content = (\n <Icon\n fill={resolved.logo_fill}\n name={resolved.logo_name}\n size={size}\n sx={{ color: resolved.logo_color }}\n />\n )\n } else if (resolved.merchant_guid) {\n content = (\n <MerchantLogo\n alt={resolved.merchant_name ?? ''}\n categoryGuid={resolved.category_guid ? getTopLevelCategoryGuid(resolved.category_guid) : ''}\n merchantGuid={resolved.merchant_guid}\n size={size}\n />\n )\n } else if (resolved.institution_guid) {\n content = (\n <InstitutionLogo\n alt={resolved.institution_name ?? ''}\n institutionGuid={resolved.institution_guid}\n size={size}\n />\n )\n } else if (resolved.category_guid) {\n content = (\n <CategoryIcon categoryGuid={getTopLevelCategoryGuid(resolved.category_guid)} size={size} />\n )\n }\n\n if (!content) return null\n\n return (\n <Box\n className={className}\n data-testid=\"logo-from-guid\"\n sx={{\n alignItems: 'center',\n display: 'flex',\n flexShrink: 0,\n height: size,\n justifyContent: 'center',\n width: size,\n }}\n >\n {content}\n </Box>\n )\n})\n\nexport default LogoFromGuid\n"],"mappings":";;;;;;;AAiBA,IAAM,IAAmB,qCAEZ,IAAA,CAAc,MACzB,CAAC,CAAC,KAAQ,EAAiB,KAAK,CAAI,GAuBhC,IAAe,EAAA,CAAU,EAAE,WAAA,GAAW,MAAA,GAAM,MAAA,EAAA,MAA8B;AAC9E,QAAM,EAAE,yBAAA,EAAA,IAA4B,EAAiB;AAErD,MAAI,CAAC,KAAQ,CAAC,EAAW,EAAK,IAAI,EAAG,QAAO;AAI5C,QAAM,IAAW,EAAY;AAAA,IAC3B,KAAK,EAAK;AAAA,IACV,OAAO,EAAK;AAAA,IACZ,eAAe,EAAK;AAAA,IACpB,MAAM,EAAK;AAAA,EACb,CAAC;AAED,MAAI,CAAC,EAAU,QAAO;AAEtB,MAAI,IAA2B;AAE/B,MAAI,EAAS,WAAW;AAEtB,QAAI,EAAE,EAAS,aAAa;AAC1B,qBAAQ,KAAK,mBAAmB,EAAK,IAAA,+CAAmD,GACjF;AAET,IAAA,IACE,gBAAA,EAAC,GAAD;AAAA,MACE,MAAM,EAAS;AAAA,MACf,MAAM,EAAS;AAAA,MACT,MAAA;AAAA,MACN,IAAI,EAAE,OAAO,EAAS,WAAW;AAAA,IAClC,CAAA;AAAA,EAEL,MAAO,CAAI,EAAS,gBAClB,IACE,gBAAA,EAAC,GAAD;AAAA,IACE,KAAK,EAAS,iBAAiB;AAAA,IAC/B,cAAc,EAAS,gBAAgB,EAAwB,EAAS,aAAa,IAAI;AAAA,IACzF,cAAc,EAAS;AAAA,IACjB,MAAA;AAAA,EACP,CAAA,IAEM,EAAS,mBAClB,IACE,gBAAA,EAAC,GAAD;AAAA,IACE,KAAK,EAAS,oBAAoB;AAAA,IAClC,iBAAiB,EAAS;AAAA,IACpB,MAAA;AAAA,EACP,CAAA,IAEM,EAAS,kBAClB,IACE,gBAAA,EAAC,GAAD;AAAA,IAAc,cAAc,EAAwB,EAAS,aAAa;AAAA,IAAS,MAAA;AAAA,EAAO,CAAA;AAI9F,SAAK,IAGH,gBAAA,EAAC,GAAD;AAAA,IACa,WAAA;AAAA,IACX,eAAY;AAAA,IACZ,IAAI;AAAA,MACF,YAAY;AAAA,MACZ,SAAS;AAAA,MACT,YAAY;AAAA,MACZ,QAAQ;AAAA,MACR,gBAAgB;AAAA,MAChB,OAAO;AAAA,IACT;AAAA,IAEC,UAAA;AAAA,EACE,CAAA,IAhBc;AAkBvB,CAAC"}
1
+ {"version":3,"file":"LogoFromGuid.es.js","names":[],"sources":["../../../src/insights-v2/components/LogoFromGuid.tsx"],"sourcesContent":["import Box from '@mui/material/Box'\n\nimport type { LogoRef } from '../../core'\nimport LogoMark, { isKnownIcon } from './LogoMark'\nimport { logoFromRef } from './shared/EntityLogo'\n\n/**\n * The guid prefixes that name a logo entity. A prefix heuristic by design: the V2 envelope carries\n * the entity only in the guid, and the notification row relies on non-insight rows carrying account\n * or budget guids and legacy insight rows carrying the `\"PARENT-ENTITY\"` sentinel. Exported beside\n * the component so a caller's branch (`NotificationCard`) and the dispatch here cannot drift apart.\n */\nconst LOGO_GUID_PREFIX = /^(MCH|CAT|INS)-|^ICO-[a-z0-9_-]+$/\n\nexport const isLogoGuid = (guid?: string | null): guid is string =>\n !!guid && LOGO_GUID_PREFIX.test(guid)\n\nexport interface LogoFromGuidProps {\n /** The envelope's logo object: `{ guid, fallback_guid?, alt?, color? }` (`color` is read for `ICO-` icons). */\n logo?: Pick<LogoRef, 'alt' | 'color' | 'fallback_guid' | 'guid'> | null\n /** Rendered square size in px (32 on rows, 40 on the compact card, 33 on the notification row). */\n size: number\n className?: string\n}\n\n/**\n * One component for every V2 logo. The envelope sends a single `{ guid, fallback_guid?, alt? }`\n * object whose prefix says what it is; anything else (`PARENT-ENTITY`, an `ACT-`/`BGT-` guid, an\n * empty guid) renders nothing, never a guess. The asset → category tile → `alt` fallback is mxui's.\n */\nconst LogoFromGuid = ({ className, logo, size }: LogoFromGuidProps) => {\n if (!logo || !isLogoGuid(logo.guid)) return null\n\n // Guid-only on purpose: `logoFromRef` lets a status `icon` win over `guid`, which is right for a\n // row but would silently turn this component into an icon renderer.\n const resolved = logoFromRef({\n alt: logo.alt,\n color: logo.color,\n fallback_guid: logo.fallback_guid,\n guid: logo.guid,\n })\n\n if (!resolved) return null\n\n // Checked before the sized box, so an unknown icon leaves no empty gap.\n if (resolved.logo_name && !isKnownIcon(resolved.logo_name)) return null\n\n return (\n <Box\n className={className}\n data-testid=\"logo-from-guid\"\n sx={{\n alignItems: 'center',\n display: 'flex',\n flexShrink: 0,\n height: size,\n justifyContent: 'center',\n width: size,\n }}\n >\n <LogoMark logo={resolved} size={size} />\n </Box>\n )\n}\n\nexport default LogoFromGuid\n"],"mappings":";;;;AAYA,IAAM,IAAmB,qCAEZ,IAAA,CAAc,MACzB,CAAC,CAAC,KAAQ,EAAiB,KAAK,CAAI,GAehC,IAAA,CAAgB,EAAE,WAAA,GAAW,MAAA,GAAM,MAAA,EAAA,MAA8B;AACrE,MAAI,CAAC,KAAQ,CAAC,EAAW,EAAK,IAAI,EAAG,QAAO;AAI5C,QAAM,IAAW,EAAY;AAAA,IAC3B,KAAK,EAAK;AAAA,IACV,OAAO,EAAK;AAAA,IACZ,eAAe,EAAK;AAAA,IACpB,MAAM,EAAK;AAAA,EACb,CAAC;AAKD,SAHI,CAAC,KAGD,EAAS,aAAa,CAAC,EAAY,EAAS,SAAS,IAAU,OAGjE,gBAAA,EAAC,GAAD;AAAA,IACa,WAAA;AAAA,IACX,eAAY;AAAA,IACZ,IAAI;AAAA,MACF,YAAY;AAAA,MACZ,SAAS;AAAA,MACT,YAAY;AAAA,MACZ,QAAQ;AAAA,MACR,gBAAgB;AAAA,MAChB,OAAO;AAAA,IACT;AAAA,IAEA,UAAA,gBAAA,EAAC,GAAD;AAAA,MAAU,MAAM;AAAA,MAAgB,MAAA;AAAA,IAAO,CAAA;AAAA,EACpC,CAAA;AAET"}
@@ -0,0 +1,19 @@
1
+ import { Logo } from '../../core';
2
+ interface LogoMarkProps {
3
+ logo: Logo;
4
+ size: number;
5
+ }
6
+ /**
7
+ * Whether mx-icons draws `name` (own keys only, so `constructor` is rejected). An unknown name would
8
+ * draw an empty box, so it is logged and the caller draws nothing.
9
+ */
10
+ export declare const isKnownIcon: (name: string) => boolean;
11
+ /**
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
+ */
16
+ declare const LogoMark: (({ logo, size }: LogoMarkProps) => import("react/jsx-runtime").JSX.Element | null) & {
17
+ displayName: string;
18
+ };
19
+ export default LogoMark;