@mx-cartographer/experiences 9.7.112 → 9.7.114

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 +14 -0
  2. package/dist/insights/types/Charts/BarChart.d.ts +2 -0
  3. package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/BarchartBlock.es.js +28 -26
  4. package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/BarchartBlock.es.js.map +1 -1
  5. package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/layout.d.ts +2 -0
  6. package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/layout.es.js +8 -4
  7. package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/layout.es.js.map +1 -1
  8. package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/utils.d.ts +6 -2
  9. package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/utils.es.js +31 -29
  10. package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/utils.es.js.map +1 -1
  11. package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/TransactionBlock.es.js +16 -16
  12. package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/TransactionBlock.es.js.map +1 -1
  13. package/dist/insights-v2/components/chartblocks/BarchartV2.d.ts +1 -1
  14. package/dist/insights-v2/components/chartblocks/BarchartV2.es.js +58 -57
  15. package/dist/insights-v2/components/chartblocks/BarchartV2.es.js.map +1 -1
  16. package/dist/microinsights/MicroCardTemplate.d.ts +2 -0
  17. package/dist/microinsights/MicroCardTemplate.es.js +81 -59
  18. package/dist/microinsights/MicroCardTemplate.es.js.map +1 -1
  19. package/dist/microinsights/cards/InsightCard.es.js +61 -59
  20. package/dist/microinsights/cards/InsightCard.es.js.map +1 -1
  21. package/dist/microinsights/carousel/MicroBeatCarousel.es.js +2 -2
  22. package/dist/microinsights/carousel/MicroBeatCarousel.es.js.map +1 -1
  23. package/dist/microinsights/constants/App.d.ts +4 -0
  24. package/dist/microinsights/constants/App.es.js.map +1 -1
  25. package/dist/microinsights/utils/cardWidth.d.ts +5 -0
  26. package/dist/microinsights/utils/cardWidth.es.js +9 -0
  27. package/dist/microinsights/utils/cardWidth.es.js.map +1 -0
  28. package/package.json +1 -1
@@ -1,34 +1,35 @@
1
- import { GlobalDataContext as H } from "../../common/context/GlobalDataProvider.es.js";
1
+ import { GlobalDataContext as K } from "../../common/context/GlobalDataProvider.es.js";
2
2
  import { slot as I } from "../../core/types/Insights.es.js";
3
- import { resolveInsightRender as K } from "../../insights-v2/resolveInsightRender.es.js";
4
- import { hasDrawerBlock as Z } from "../../insights-v2/mappings/hasDrawerBlock.es.js";
5
- import J from "../../insights-v2/components/LogoFromGuid.es.js";
6
- import { statusIconName as Q, statusIconPalette as U } from "../../insights-v2/components/statusIcon.es.js";
7
- import { ON_CLICK_EVENT as w, ON_VIEW_EVENT as X, ON_VIEW_FIRST_TIME_EVENT as Y } from "../constants/Analytics.es.js";
3
+ import { resolveInsightRender as $ } from "../../insights-v2/resolveInsightRender.es.js";
4
+ import { hasDrawerBlock as J } from "../../insights-v2/mappings/hasDrawerBlock.es.js";
5
+ import Q from "../../insights-v2/components/LogoFromGuid.es.js";
6
+ import { statusIconName as U, statusIconPalette as X } from "../../insights-v2/components/statusIcon.es.js";
7
+ import { ON_CLICK_EVENT as W, ON_VIEW_EVENT as Y, ON_VIEW_FIRST_TIME_EVENT as Z } from "../constants/Analytics.es.js";
8
8
  import F from "../beaticons/BeatMaterialIcon.es.js";
9
9
  import { BeatIcon as b } from "../beaticons/BeatIcon.es.js";
10
10
  import { useCopyStore as ii, useEvent as ti, useInsightsMicroWidgetStore as ei } from "../context/hooks.es.js";
11
+ import { microCardMinWidth as oi } from "../utils/cardWidth.es.js";
11
12
  import O from "../MicroCardTemplate.es.js";
12
- import oi from "./InlineActionBlock.es.js";
13
- import { MicroCtaStatusGate as ri } from "./MicroCtaStatus.es.js";
14
- import ni from "../../insights-v2/components/InsightErrorCard.es.js";
15
- import si, { useEffect as W, useState as ai } from "react";
16
- import { Fragment as ci, jsx as e, jsxs as li } from "react/jsx-runtime";
17
- import { alpha as G, useTheme as mi } from "@mui/material/styles";
18
- import _i from "@mui/material/Box";
19
- import { useInView as pi } from "react-intersection-observer";
20
- var di = 32, wi = ({ ariaLabel: u, beat: i, elevation: y, inDescriptionCtaBehavior: q = "external", index: s, isActiveCard: g, onCardClick: a, posthog: r, widthOverrides: c, variant: C, showIcon: E, heightOverrides: f }) => {
21
- const { ref: h, inView: l } = pi({ threshold: 1 }), v = mi(), { cardsCopy: A } = ii(), { onEvent: m } = ti(), { updateBeat: D, updateOffer: j } = ei(), _ = "is_insights_v2" in i && i.is_insights_v2, p = _ ? { metadata: { is_insights_v2: !0 } } : void 0;
22
- W(() => {
23
- l && (i.has_been_displayed ? m(X(i.template), p) : (i.guid.startsWith("OFR") ? j({
13
+ import ri from "./InlineActionBlock.es.js";
14
+ import { MicroCtaStatusGate as ni } from "./MicroCtaStatus.es.js";
15
+ import si from "../../insights-v2/components/InsightErrorCard.es.js";
16
+ import mi, { useEffect as S, useState as ci } from "react";
17
+ import { Fragment as ai, jsx as e, jsxs as li } from "react/jsx-runtime";
18
+ import { alpha as G, useTheme as _i } from "@mui/material/styles";
19
+ import pi from "@mui/material/Box";
20
+ import { useInView as di } from "react-intersection-observer";
21
+ var Fi = ({ ariaLabel: d, beat: i, elevation: y, inDescriptionCtaBehavior: q = "external", index: s, isActiveCard: u, onCardClick: m, posthog: r, widthOverrides: g, variant: C, showIcon: v, heightOverrides: f }) => {
22
+ const { ref: h, inView: c } = di({ threshold: 1 }), E = _i(), { cardsCopy: A } = ii(), { onEvent: a } = ti(), { updateBeat: D, updateOffer: j } = ei(), l = "is_insights_v2" in i && i.is_insights_v2, _ = l ? { metadata: { is_insights_v2: !0 } } : void 0;
23
+ S(() => {
24
+ c && (i.has_been_displayed ? a(Y(i.template), _) : (i.guid.startsWith("OFR") ? j({
24
25
  ...i,
25
26
  has_been_displayed: !0
26
27
  }) : D({
27
28
  ...i,
28
29
  has_been_displayed: !0
29
- }), m(Y(i.template), p)));
30
- }, [l]), W(() => {
31
- if (l && i) if (i.template === "MarketingOffer") {
30
+ }), a(Z(i.template), _)));
31
+ }, [c]), S(() => {
32
+ if (c && i) if (i.template === "MarketingOffer") {
32
33
  const t = i;
33
34
  r?.capture("viewed_messaging_insight", {
34
35
  template: i.template,
@@ -41,15 +42,15 @@ var di = 32, wi = ({ ariaLabel: u, beat: i, elevation: y, inDescriptionCtaBehavi
41
42
  beat_guid: i.guid,
42
43
  template: i.template,
43
44
  position: s,
44
- ..._ && { is_insights_v2: !0 }
45
+ ...l && { is_insights_v2: !0 }
45
46
  });
46
47
  }, [
47
48
  i,
48
49
  s,
49
- l
50
+ c
50
51
  ]);
51
- const k = K(i), o = k === "v2" ? i.insights_payload : void 0, L = si.useContext(H) !== null, x = q === "internal" && L && Z(o?.in_description_cta?.block), [N, $] = ai(0), d = () => {
52
- if (x ? $((t) => t + 1) : a && a(i), m(w(i.template), p), i.template === "MarketingOffer") {
52
+ const k = $(i), o = k === "v2" ? i.insights_payload : void 0, L = mi.useContext(K) !== null, T = q === "internal" && L && J(o?.in_description_cta?.block), [V, z] = ci(0), p = () => {
53
+ if (T ? z((t) => t + 1) : m && m(i), a(W(i.template), _), i.template === "MarketingOffer") {
53
54
  const t = i;
54
55
  r?.capture("clicked_messaging_insight", {
55
56
  template: i.template,
@@ -62,83 +63,84 @@ var di = 32, wi = ({ ariaLabel: u, beat: i, elevation: y, inDescriptionCtaBehavi
62
63
  beat_guid: i.guid,
63
64
  template: i.template,
64
65
  position: s,
65
- ..._ && { is_insights_v2: !0 }
66
+ ...l && { is_insights_v2: !0 }
66
67
  });
67
68
  };
68
- return k === "error" ? /* @__PURE__ */ e(_i, {
69
- "aria-hidden": !g,
70
- "aria-label": u,
69
+ return k === "error" ? /* @__PURE__ */ e(pi, {
70
+ "aria-hidden": !u,
71
+ "aria-label": d,
71
72
  "aria-roledescription": "slide",
72
73
  ref: h,
73
74
  role: "group",
74
75
  sx: {
75
76
  height: f ? "100%" : 120,
76
- minWidth: c ? `${c}px` : "100%",
77
+ minWidth: oi(g),
77
78
  my: 1
78
79
  },
79
- children: /* @__PURE__ */ e(ni, { beat: i })
80
- }) : o ? /* @__PURE__ */ e(ri, {
80
+ children: /* @__PURE__ */ e(si, { beat: i })
81
+ }) : o ? /* @__PURE__ */ e(ni, {
81
82
  beat: i,
82
83
  posthog: r,
83
84
  children: ({ presentation: n }) => {
84
- const T = n?.kind === "status" ? n : void 0, B = I(o.instance_slot.data, "logo"), R = I(o.instance_slot.data, T && I(o.instance_slot.data, "reviewed_icon") ? "reviewed_icon" : "icon"), V = Q(R?.guid), M = U(R?.color), z = n ? T?.action?.label : o.primary_cta?.label || o.in_description_cta?.label || void 0, P = () => {
85
- a && a(i), m(w(i.template), p), r?.capture("clicked_insight", {
85
+ const x = n?.kind === "status" ? n : void 0, B = I(o.instance_slot.data, "logo"), M = I(o.instance_slot.data, x && I(o.instance_slot.data, "reviewed_icon") ? "reviewed_icon" : "icon"), N = U(M?.guid), R = X(M?.color), H = n ? x?.action?.label : o.primary_cta?.label || o.in_description_cta?.label || void 0, w = () => {
86
+ m && m(i), a(W(i.template), _), r?.capture("clicked_insight", {
86
87
  beat_guid: i.guid,
87
88
  template: i.template,
88
89
  position: s,
89
- ..._ && { is_insights_v2: !0 }
90
+ ...l && { is_insights_v2: !0 }
90
91
  });
91
- }, S = /* @__PURE__ */ e(O, {
92
+ }, P = /* @__PURE__ */ e(O, {
92
93
  "aria-roledescription": "slide",
93
- ariaLabel: u,
94
+ ariaLabel: d,
94
95
  description: o.description.html_text,
95
96
  elevation: y,
96
97
  heightOverrides: f,
97
- icon: E && (B ? /* @__PURE__ */ e(J, {
98
+ icon: v && (B ? /* @__PURE__ */ e(Q, {
98
99
  logo: B,
99
- size: di
100
- }) : V ? /* @__PURE__ */ e(F, {
101
- bgColor: G(v.palette[M].main, 0.15),
102
- iconColor: M,
103
- name: V
100
+ size: 32
101
+ }) : N ? /* @__PURE__ */ e(F, {
102
+ bgColor: G(E.palette[R].main, 0.15),
103
+ iconColor: R,
104
+ name: N
104
105
  }) : /* @__PURE__ */ e(F, {
105
- bgColor: G(v.palette.primary.main, 0.15),
106
+ bgColor: G(E.palette.primary.main, 0.15),
106
107
  name: "lightbulb"
107
108
  })),
108
- isActiveCard: g,
109
- onCardClick: n ? P : d,
110
- onPrimaryAction: n ? P : d,
111
- primaryActionText: z,
109
+ isActiveCard: u,
110
+ isInsightsV2: !0,
111
+ onCardClick: n ? w : p,
112
+ onPrimaryAction: n ? w : p,
113
+ primaryActionText: H,
112
114
  ref: h,
113
115
  title: n?.title || o.title || "",
114
116
  variant: C,
115
- widthOverrides: c
117
+ widthOverrides: g
116
118
  });
117
- return x ? /* @__PURE__ */ li(ci, { children: [S, N > 0 && /* @__PURE__ */ e(oi, {
119
+ return T ? /* @__PURE__ */ li(ai, { children: [P, V > 0 && /* @__PURE__ */ e(ri, {
118
120
  beat: i,
119
- openRequest: N,
121
+ openRequest: V,
120
122
  posthog: r
121
- })] }) : S;
123
+ })] }) : P;
122
124
  }
123
125
  }) : /* @__PURE__ */ e(O, {
124
126
  "aria-roledescription": "slide",
125
- ariaLabel: u,
127
+ ariaLabel: d,
126
128
  description: i?.html_micro_description && i?.html_micro_description.length > 0 ? i.html_micro_description : i.html_description || "",
127
129
  elevation: y,
128
130
  heightOverrides: f,
129
- icon: E && /* @__PURE__ */ e(b, { beat: i }),
130
- isActiveCard: g,
131
- onCardClick: d,
132
- onPrimaryAction: d,
131
+ icon: v && /* @__PURE__ */ e(b, { beat: i }),
132
+ isActiveCard: u,
133
+ onCardClick: p,
134
+ onPrimaryAction: p,
133
135
  primaryActionText: i.micro_call_to_action || A?.micro_card_cta,
134
136
  ref: h,
135
137
  title: i.micro_title && i.micro_title.length > 0 ? i.micro_title : i.title,
136
138
  variant: C,
137
- widthOverrides: c
139
+ widthOverrides: g
138
140
  });
139
141
  };
140
142
  export {
141
- wi as InsightCard
143
+ Fi as InsightCard
142
144
  };
143
145
 
144
146
  //# sourceMappingURL=InsightCard.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"InsightCard.es.js","names":[],"sources":["../../../src/microinsights/cards/InsightCard.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react'\nimport { useInView } from 'react-intersection-observer'\n\nimport Box from '@mui/material/Box'\nimport { alpha, useTheme } from '@mui/material/styles'\n\nimport { BeatIcon } from '../beaticons'\nimport BeatMaterialIcon from '../beaticons/BeatMaterialIcon'\n\nimport { useCopyStore, useEvent, useInsightsMicroWidgetStore } from '../context/hooks'\n\nimport { ON_CLICK_EVENT, ON_VIEW_EVENT, ON_VIEW_FIRST_TIME_EVENT } from '../constants/Analytics'\nimport { VIEW_THRESHOLD } from '../constants/App'\n\nimport type { BeatLikeOffer, MicroInsightCardProps } from '../interfaces'\nimport type { Beat } from '../../core/types/Beat'\n// Leaf imports, not the `core` barrel: that pulls GlobalStore and every feature store into the\n// micro bundle, and through `core/stores` it reintroduces a circular path this module avoids.\nimport { slot } from '../../core/types/Insights'\nimport type { LogoRef } from '../../core/types/Insights'\nimport MicroCardTemplate from '../MicroCardTemplate'\n// Leaf import, not the `common` barrel, which would pull the shared layer into the micro bundle.\nimport { GlobalDataContext } from '../../common/context/GlobalDataProvider'\n// TODO: load this with `React.lazy` to keep the block registry and charts out of the micro bundle,\n// once it is verified in every host that embeds the micro widget.\nimport InlineActionBlock from './InlineActionBlock'\nimport MicroCtaStatusGate, { type MicroCtaStatus } from './MicroCtaStatus'\n// Leaf imports on purpose: the `insights-v2` barrel pulls in `mappings/blocks` and its charts.\nimport InsightErrorCard from '../../insights-v2/components/InsightErrorCard'\nimport LogoFromGuid from '../../insights-v2/components/LogoFromGuid'\nimport { statusIconName, statusIconPalette } from '../../insights-v2/components/statusIcon'\nimport { hasDrawerBlock } from '../../insights-v2/mappings/hasDrawerBlock'\nimport { resolveInsightRender } from '../../insights-v2/resolveInsightRender'\n\n/** The legacy micro card's icon tile size (BeatMaterialIcon). */\nconst ICON_SIZE = 32\n\nexport interface InsightCardProps extends MicroInsightCardProps {\n beat: Beat | BeatLikeOffer\n index?: number\n}\n\nexport const InsightCard: React.FC<InsightCardProps> = ({\n ariaLabel,\n beat,\n elevation,\n inDescriptionCtaBehavior = 'external',\n index,\n isActiveCard,\n onCardClick,\n posthog,\n widthOverrides,\n variant,\n showIcon,\n heightOverrides,\n}) => {\n const { ref, inView } = useInView({\n threshold: VIEW_THRESHOLD,\n })\n\n const theme = useTheme()\n\n // *************** Context functions *********************\n const { cardsCopy } = useCopyStore()\n const { onEvent } = useEvent()\n const { updateBeat, updateOffer } = useInsightsMicroWidgetStore()\n\n const isV2 = 'is_insights_v2' in beat && beat.is_insights_v2\n const eventProps = isV2 ? { metadata: { is_insights_v2: true } } : undefined\n\n // ************** Use Effects Hooks **********************\n useEffect(() => {\n if (inView) {\n if (!beat.has_been_displayed) {\n if (beat.guid.startsWith('OFR')) {\n updateOffer({\n ...beat,\n has_been_displayed: true,\n })\n } else {\n updateBeat({\n ...beat,\n has_been_displayed: true,\n })\n }\n onEvent(ON_VIEW_FIRST_TIME_EVENT(beat.template), eventProps)\n } else {\n onEvent(ON_VIEW_EVENT(beat.template), eventProps)\n }\n }\n }, [inView])\n\n useEffect(() => {\n if (inView && beat) {\n if (beat.template === 'MarketingOffer') {\n const offerBeat = beat as BeatLikeOffer\n posthog?.capture('viewed_messaging_insight', {\n template: beat.template,\n campaign_guid: offerBeat.campaign_guid,\n campaign_name: offerBeat.pulse_campaign_name,\n offer_guid: offerBeat.guid,\n user_guid: offerBeat.user_guid,\n })\n } else {\n posthog?.capture('viewed_insight', {\n beat_guid: beat.guid,\n template: beat.template,\n position: index,\n ...(isV2 && { is_insights_v2: true }),\n })\n }\n }\n }, [beat, index, inView])\n\n const insightRender = resolveInsightRender(beat as Beat)\n const v2Payload = insightRender === 'v2' ? beat.insights_payload : undefined\n // Only a V2 beat whose `in_description_cta` names a drawer block opens in place; everything else\n // keeps the host's behavior. Micro sends its one action as `in_description_cta`.\n // It also needs the host's `GlobalDataProvider`; without one the tap goes to the host instead.\n const hasGlobalData = React.useContext(GlobalDataContext) !== null\n const opensInline =\n inDescriptionCtaBehavior === 'internal' &&\n hasGlobalData &&\n hasDrawerBlock(v2Payload?.in_description_cta?.block)\n\n // *************** Click handlers ************************\n // Taps that opened the beat's own action block.\n const [inlineOpenRequest, setInlineOpenRequest] = useState(0)\n\n const handleClick = () => {\n /* eslint-disable no-unused-expressions */\n // Internal opens the block here and skips the host's `onCardClick`; analytics are unchanged.\n if (opensInline) {\n setInlineOpenRequest((count) => count + 1)\n } else {\n onCardClick && onCardClick(beat)\n }\n onEvent(ON_CLICK_EVENT(beat.template), eventProps)\n\n if (beat.template === 'MarketingOffer') {\n const offerBeat = beat as BeatLikeOffer\n posthog?.capture('clicked_messaging_insight', {\n template: beat.template,\n campaign_guid: offerBeat.campaign_guid,\n campaign_name: offerBeat.pulse_campaign_name,\n offer_guid: offerBeat.guid,\n user_guid: offerBeat.user_guid,\n })\n } else {\n posthog?.capture('clicked_insight', {\n beat_guid: beat.guid,\n template: beat.template,\n position: index,\n ...(isV2 && { is_insights_v2: true }),\n })\n }\n }\n\n if (insightRender === 'error') {\n // Keeps the carousel's slot sizing; the error card does not know about it.\n return (\n <Box\n aria-hidden={!isActiveCard}\n aria-label={ariaLabel}\n aria-roledescription=\"slide\"\n ref={ref}\n role=\"group\"\n sx={{\n height: heightOverrides ? '100%' : 120,\n minWidth: widthOverrides ? `${widthOverrides}px` : '100%',\n my: 1,\n }}\n >\n <InsightErrorCard beat={beat} />\n </Box>\n )\n }\n\n if (v2Payload) {\n // Figma (Micro Widget | Large Transaction) is the legacy micro card's layout fed from the envelope:\n // the slot's logo on the left (merchant, or the category without one), title, description, and the\n // primary CTA as a link. The logo falls back to the insight glyph when the slot carries none.\n // ditto ≥ 1.4.3 words micro's action as in_description_cta instead of primary_cta; either way\n // the label stays the card's tap (`micro-carousel/cta`), never a drawer.\n // A block with no row logo may name a status icon instead (account_block `minimal`: `ICO-error`),\n // drawn in the legacy card's tinted tile (Figma Micro | Low Account Balance).\n // The status tile takes the palette the slot names (Payday's on-track check is `success.main`),\n // falling back to error. `||` on the label: the copy may send the primary label as \"\".\n // Answered (mirrors the full card): reviewed title, icon and the Undo label. Display only: the card\n // and its label tap go to the host, which opens the insight with its block; nothing runs here.\n const renderCard = ({ presentation }: MicroCtaStatus) => {\n const answered = presentation?.kind === 'status' ? presentation : undefined\n const rowLogo = slot<LogoRef>(v2Payload.instance_slot.data, 'logo')\n const statusIcon = slot<LogoRef>(\n v2Payload.instance_slot.data,\n answered && slot<LogoRef>(v2Payload.instance_slot.data, 'reviewed_icon')\n ? 'reviewed_icon'\n : 'icon',\n )\n const statusName = statusIconName(statusIcon?.guid)\n const statusPalette = statusIconPalette(statusIcon?.color)\n const actionLabel = presentation\n ? answered?.action?.label\n : v2Payload.primary_cta?.label || v2Payload.in_description_cta?.label || undefined\n const handleHostClick = () => {\n onCardClick && onCardClick(beat)\n onEvent(ON_CLICK_EVENT(beat.template), eventProps)\n posthog?.capture('clicked_insight', {\n beat_guid: beat.guid,\n template: beat.template,\n position: index,\n ...(isV2 && { is_insights_v2: true }),\n })\n }\n\n const card = (\n <MicroCardTemplate\n aria-roledescription=\"slide\"\n ariaLabel={ariaLabel}\n description={v2Payload.description.html_text}\n elevation={elevation}\n heightOverrides={heightOverrides}\n icon={\n showIcon &&\n (rowLogo ? (\n <LogoFromGuid logo={rowLogo} size={ICON_SIZE} />\n ) : statusName ? (\n <BeatMaterialIcon\n bgColor={alpha(theme.palette[statusPalette].main, 0.15)}\n iconColor={statusPalette}\n name={statusName}\n />\n ) : (\n <BeatMaterialIcon\n bgColor={alpha(theme.palette.primary.main, 0.15)}\n name=\"lightbulb\"\n />\n ))\n }\n isActiveCard={isActiveCard}\n onCardClick={presentation ? handleHostClick : handleClick}\n onPrimaryAction={presentation ? handleHostClick : handleClick}\n primaryActionText={actionLabel}\n ref={ref}\n title={presentation?.title || v2Payload.title || ''}\n variant={variant}\n widthOverrides={widthOverrides}\n />\n )\n\n if (!opensInline) return card\n\n return (\n <>\n {card}\n {/* Nothing renders until the first tap. */}\n {inlineOpenRequest > 0 && (\n <InlineActionBlock\n beat={beat as Beat}\n openRequest={inlineOpenRequest}\n posthog={posthog}\n />\n )}\n </>\n )\n }\n\n return (\n <MicroCtaStatusGate beat={beat as Beat} posthog={posthog}>\n {renderCard}\n </MicroCtaStatusGate>\n )\n }\n\n return (\n <MicroCardTemplate\n aria-roledescription=\"slide\"\n ariaLabel={ariaLabel}\n description={\n beat?.html_micro_description && beat?.html_micro_description.length > 0\n ? beat.html_micro_description\n : beat.html_description || ''\n }\n elevation={elevation}\n heightOverrides={heightOverrides}\n icon={showIcon && <BeatIcon beat={beat} />}\n isActiveCard={isActiveCard}\n onCardClick={handleClick}\n onPrimaryAction={handleClick}\n primaryActionText={beat.micro_call_to_action || cardsCopy?.micro_card_cta}\n ref={ref}\n title={beat.micro_title && beat.micro_title.length > 0 ? beat.micro_title : beat.title}\n variant={variant}\n widthOverrides={widthOverrides}\n />\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAmCA,IAAM,KAAY,IAOL,KAAA,CAA2C,EACtD,WAAA,GACA,MAAA,GACA,WAAA,GACA,0BAAA,IAA2B,YAC3B,OAAA,GACA,cAAA,GACA,aAAA,GACA,SAAA,GACA,gBAAA,GACA,SAAA,GACA,UAAA,GACA,iBAAA,EAAA,MACI;AACJ,QAAM,EAAE,KAAA,GAAK,QAAA,EAAA,IAAW,GAAU,EAChC,WAAA,EACF,CAAC,GAEK,IAAQ,GAAS,GAGjB,EAAE,WAAA,EAAA,IAAc,GAAa,GAC7B,EAAE,SAAA,EAAA,IAAY,GAAS,GACvB,EAAE,YAAA,GAAY,aAAA,EAAA,IAAgB,GAA4B,GAE1D,IAAO,oBAAoB,KAAQ,EAAK,gBACxC,IAAa,IAAO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AM,0BAA0B,GAAM,uBAAuB,SAAS,IAClE,EAAK,yBACL,EAAK,oBAAoB;AAAA,IAEpB,WAAA;AAAA,IACM,iBAAA;AAAA,IACjB,MAAM,KAAY,gBAAA,EAAC,GAAD,EAAgB,MAAA,EAAO,CAAA;AAAA,IAC3B,cAAA;AAAA,IACd,aAAa;AAAA,IACb,iBAAiB;AAAA,IACjB,mBAAmB,EAAK,wBAAwB,GAAW;AAAA,IACtD,KAAA;AAAA,IACL,OAAO,EAAK,eAAe,EAAK,YAAY,SAAS,IAAI,EAAK,cAAc,EAAK;AAAA,IACxE,SAAA;AAAA,IACO,gBAAA;AAAA,EACjB,CAAA;AAEL"}
1
+ {"version":3,"file":"InsightCard.es.js","names":[],"sources":["../../../src/microinsights/cards/InsightCard.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react'\nimport { useInView } from 'react-intersection-observer'\n\nimport Box from '@mui/material/Box'\nimport { alpha, useTheme } from '@mui/material/styles'\n\nimport { BeatIcon } from '../beaticons'\nimport BeatMaterialIcon from '../beaticons/BeatMaterialIcon'\n\nimport { useCopyStore, useEvent, useInsightsMicroWidgetStore } from '../context/hooks'\n\nimport { ON_CLICK_EVENT, ON_VIEW_EVENT, ON_VIEW_FIRST_TIME_EVENT } from '../constants/Analytics'\nimport { ICON_SIZE, VIEW_THRESHOLD } from '../constants/App'\nimport { microCardMinWidth } from '../utils/cardWidth'\n\nimport type { BeatLikeOffer, MicroInsightCardProps } from '../interfaces'\nimport type { Beat } from '../../core/types/Beat'\n// Leaf imports, not the `core` barrel: that pulls GlobalStore and every feature store into the\n// micro bundle, and through `core/stores` it reintroduces a circular path this module avoids.\nimport { slot } from '../../core/types/Insights'\nimport type { LogoRef } from '../../core/types/Insights'\nimport MicroCardTemplate from '../MicroCardTemplate'\n// Leaf import, not the `common` barrel, which would pull the shared layer into the micro bundle.\nimport { GlobalDataContext } from '../../common/context/GlobalDataProvider'\n// TODO: load this with `React.lazy` to keep the block registry and charts out of the micro bundle,\n// once it is verified in every host that embeds the micro widget.\nimport InlineActionBlock from './InlineActionBlock'\nimport MicroCtaStatusGate, { type MicroCtaStatus } from './MicroCtaStatus'\n// Leaf imports on purpose: the `insights-v2` barrel pulls in `mappings/blocks` and its charts.\nimport InsightErrorCard from '../../insights-v2/components/InsightErrorCard'\nimport LogoFromGuid from '../../insights-v2/components/LogoFromGuid'\nimport { statusIconName, statusIconPalette } from '../../insights-v2/components/statusIcon'\nimport { hasDrawerBlock } from '../../insights-v2/mappings/hasDrawerBlock'\nimport { resolveInsightRender } from '../../insights-v2/resolveInsightRender'\n\nexport interface InsightCardProps extends MicroInsightCardProps {\n beat: Beat | BeatLikeOffer\n index?: number\n}\n\nexport const InsightCard: React.FC<InsightCardProps> = ({\n ariaLabel,\n beat,\n elevation,\n inDescriptionCtaBehavior = 'external',\n index,\n isActiveCard,\n onCardClick,\n posthog,\n widthOverrides,\n variant,\n showIcon,\n heightOverrides,\n}) => {\n const { ref, inView } = useInView({\n threshold: VIEW_THRESHOLD,\n })\n\n const theme = useTheme()\n\n // *************** Context functions *********************\n const { cardsCopy } = useCopyStore()\n const { onEvent } = useEvent()\n const { updateBeat, updateOffer } = useInsightsMicroWidgetStore()\n\n const isV2 = 'is_insights_v2' in beat && beat.is_insights_v2\n const eventProps = isV2 ? { metadata: { is_insights_v2: true } } : undefined\n\n // ************** Use Effects Hooks **********************\n useEffect(() => {\n if (inView) {\n if (!beat.has_been_displayed) {\n if (beat.guid.startsWith('OFR')) {\n updateOffer({\n ...beat,\n has_been_displayed: true,\n })\n } else {\n updateBeat({\n ...beat,\n has_been_displayed: true,\n })\n }\n onEvent(ON_VIEW_FIRST_TIME_EVENT(beat.template), eventProps)\n } else {\n onEvent(ON_VIEW_EVENT(beat.template), eventProps)\n }\n }\n }, [inView])\n\n useEffect(() => {\n if (inView && beat) {\n if (beat.template === 'MarketingOffer') {\n const offerBeat = beat as BeatLikeOffer\n posthog?.capture('viewed_messaging_insight', {\n template: beat.template,\n campaign_guid: offerBeat.campaign_guid,\n campaign_name: offerBeat.pulse_campaign_name,\n offer_guid: offerBeat.guid,\n user_guid: offerBeat.user_guid,\n })\n } else {\n posthog?.capture('viewed_insight', {\n beat_guid: beat.guid,\n template: beat.template,\n position: index,\n ...(isV2 && { is_insights_v2: true }),\n })\n }\n }\n }, [beat, index, inView])\n\n const insightRender = resolveInsightRender(beat as Beat)\n const v2Payload = insightRender === 'v2' ? beat.insights_payload : undefined\n // Only a V2 beat whose `in_description_cta` names a drawer block opens in place; everything else\n // keeps the host's behavior. Micro sends its one action as `in_description_cta`.\n // It also needs the host's `GlobalDataProvider`; without one the tap goes to the host instead.\n const hasGlobalData = React.useContext(GlobalDataContext) !== null\n const opensInline =\n inDescriptionCtaBehavior === 'internal' &&\n hasGlobalData &&\n hasDrawerBlock(v2Payload?.in_description_cta?.block)\n\n // *************** Click handlers ************************\n // Taps that opened the beat's own action block.\n const [inlineOpenRequest, setInlineOpenRequest] = useState(0)\n\n const handleClick = () => {\n /* eslint-disable no-unused-expressions */\n // Internal opens the block here and skips the host's `onCardClick`; analytics are unchanged.\n if (opensInline) {\n setInlineOpenRequest((count) => count + 1)\n } else {\n onCardClick && onCardClick(beat)\n }\n onEvent(ON_CLICK_EVENT(beat.template), eventProps)\n\n if (beat.template === 'MarketingOffer') {\n const offerBeat = beat as BeatLikeOffer\n posthog?.capture('clicked_messaging_insight', {\n template: beat.template,\n campaign_guid: offerBeat.campaign_guid,\n campaign_name: offerBeat.pulse_campaign_name,\n offer_guid: offerBeat.guid,\n user_guid: offerBeat.user_guid,\n })\n } else {\n posthog?.capture('clicked_insight', {\n beat_guid: beat.guid,\n template: beat.template,\n position: index,\n ...(isV2 && { is_insights_v2: true }),\n })\n }\n }\n\n if (insightRender === 'error') {\n // Keeps the carousel's slot sizing; the error card does not know about it.\n return (\n <Box\n aria-hidden={!isActiveCard}\n aria-label={ariaLabel}\n aria-roledescription=\"slide\"\n ref={ref}\n role=\"group\"\n sx={{\n height: heightOverrides ? '100%' : 120,\n minWidth: microCardMinWidth(widthOverrides),\n my: 1,\n }}\n >\n <InsightErrorCard beat={beat} />\n </Box>\n )\n }\n\n if (v2Payload) {\n // Figma (Micro Widget | Large Transaction) is the legacy micro card's layout fed from the envelope:\n // the slot's logo on the left (merchant, or the category without one), title, description, and the\n // primary CTA as a link. The logo falls back to the insight glyph when the slot carries none.\n // ditto ≥ 1.4.3 words micro's action as in_description_cta instead of primary_cta; either way\n // the label stays the card's tap (`micro-carousel/cta`), never a drawer.\n // A block with no row logo may name a status icon instead (account_block `minimal`: `ICO-error`),\n // drawn in the legacy card's tinted tile (Figma Micro | Low Account Balance).\n // The status tile takes the palette the slot names (Payday's on-track check is `success.main`),\n // falling back to error. `||` on the label: the copy may send the primary label as \"\".\n // Answered (mirrors the full card): reviewed title, icon and the Undo label. Display only: the card\n // and its label tap go to the host, which opens the insight with its block; nothing runs here.\n const renderCard = ({ presentation }: MicroCtaStatus) => {\n const answered = presentation?.kind === 'status' ? presentation : undefined\n const rowLogo = slot<LogoRef>(v2Payload.instance_slot.data, 'logo')\n const statusIcon = slot<LogoRef>(\n v2Payload.instance_slot.data,\n answered && slot<LogoRef>(v2Payload.instance_slot.data, 'reviewed_icon')\n ? 'reviewed_icon'\n : 'icon',\n )\n const statusName = statusIconName(statusIcon?.guid)\n const statusPalette = statusIconPalette(statusIcon?.color)\n const actionLabel = presentation\n ? answered?.action?.label\n : v2Payload.primary_cta?.label || v2Payload.in_description_cta?.label || undefined\n const handleHostClick = () => {\n onCardClick && onCardClick(beat)\n onEvent(ON_CLICK_EVENT(beat.template), eventProps)\n posthog?.capture('clicked_insight', {\n beat_guid: beat.guid,\n template: beat.template,\n position: index,\n ...(isV2 && { is_insights_v2: true }),\n })\n }\n\n const card = (\n <MicroCardTemplate\n aria-roledescription=\"slide\"\n ariaLabel={ariaLabel}\n description={v2Payload.description.html_text}\n elevation={elevation}\n heightOverrides={heightOverrides}\n icon={\n showIcon &&\n (rowLogo ? (\n <LogoFromGuid logo={rowLogo} size={ICON_SIZE} />\n ) : statusName ? (\n <BeatMaterialIcon\n bgColor={alpha(theme.palette[statusPalette].main, 0.15)}\n iconColor={statusPalette}\n name={statusName}\n />\n ) : (\n <BeatMaterialIcon\n bgColor={alpha(theme.palette.primary.main, 0.15)}\n name=\"lightbulb\"\n />\n ))\n }\n isActiveCard={isActiveCard}\n isInsightsV2={true}\n onCardClick={presentation ? handleHostClick : handleClick}\n onPrimaryAction={presentation ? handleHostClick : handleClick}\n primaryActionText={actionLabel}\n ref={ref}\n title={presentation?.title || v2Payload.title || ''}\n variant={variant}\n widthOverrides={widthOverrides}\n />\n )\n\n if (!opensInline) return card\n\n return (\n <>\n {card}\n {/* Nothing renders until the first tap. */}\n {inlineOpenRequest > 0 && (\n <InlineActionBlock\n beat={beat as Beat}\n openRequest={inlineOpenRequest}\n posthog={posthog}\n />\n )}\n </>\n )\n }\n\n return (\n <MicroCtaStatusGate beat={beat as Beat} posthog={posthog}>\n {renderCard}\n </MicroCtaStatusGate>\n )\n }\n\n return (\n <MicroCardTemplate\n aria-roledescription=\"slide\"\n ariaLabel={ariaLabel}\n description={\n beat?.html_micro_description && beat?.html_micro_description.length > 0\n ? beat.html_micro_description\n : beat.html_description || ''\n }\n elevation={elevation}\n heightOverrides={heightOverrides}\n icon={showIcon && <BeatIcon beat={beat} />}\n isActiveCard={isActiveCard}\n onCardClick={handleClick}\n onPrimaryAction={handleClick}\n primaryActionText={beat.micro_call_to_action || cardsCopy?.micro_card_cta}\n ref={ref}\n title={beat.micro_title && beat.micro_title.length > 0 ? beat.micro_title : beat.title}\n variant={variant}\n widthOverrides={widthOverrides}\n />\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAwCA,IAAa,KAAA,CAA2C,EACtD,WAAA,GACA,MAAA,GACA,WAAA,GACA,0BAAA,IAA2B,YAC3B,OAAA,GACA,cAAA,GACA,aAAA,GACA,SAAA,GACA,gBAAA,GACA,SAAA,GACA,UAAA,GACA,iBAAA,EAAA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GH,gBAAA,GAAA,IAAA,EAAA,UAAA,CACG,GAEA,IAAoB,KACnB,gBAAA,EAAC,IAAD;AAAA,QACQ,MAAA;AAAA,QACN,aAAa;AAAA,QACJ,SAAA;AAAA,MACV,CAAA,CAEH,EAAA,CAAA,IAbqB;AAAA,IAe3B;AAAA,EAKsB,CAAA,IAKtB,gBAAA,EAAC,GAAD;AAAA,IACE,wBAAqB;AAAA,IACV,WAAA;AAAA,IACX,aACE,GAAM,0BAA0B,GAAM,uBAAuB,SAAS,IAClE,EAAK,yBACL,EAAK,oBAAoB;AAAA,IAEpB,WAAA;AAAA,IACM,iBAAA;AAAA,IACjB,MAAM,KAAY,gBAAA,EAAC,GAAD,EAAgB,MAAA,EAAO,CAAA;AAAA,IAC3B,cAAA;AAAA,IACd,aAAa;AAAA,IACb,iBAAiB;AAAA,IACjB,mBAAmB,EAAK,wBAAwB,GAAW;AAAA,IACtD,KAAA;AAAA,IACL,OAAO,EAAK,eAAe,EAAK,YAAY,SAAS,IAAI,EAAK,cAAc,EAAK;AAAA,IACxE,SAAA;AAAA,IACO,gBAAA;AAAA,EACjB,CAAA;AAEL"}
@@ -17,7 +17,7 @@ var et = ({ analyticsMetadata: i, allowSingleCardPeeking: h, beats: E = [], elev
17
17
  const w = [
18
18
  {
19
19
  maxWidth: 320,
20
- cardWidth: 220
20
+ cardWidth: 240
21
21
  },
22
22
  {
23
23
  maxWidth: 375,
@@ -45,7 +45,7 @@ var et = ({ analyticsMetadata: i, allowSingleCardPeeking: h, beats: E = [], elev
45
45
  }
46
46
  const x = m ? Math.max(0, l - 32) : l, O = 8;
47
47
  let S;
48
- e > 1 ? S = (x - (x - (e - 1) * O) / e / 3 - (e - 1) * O) / e : S = x, T(Math.max(0, S));
48
+ e > 1 ? S = (x - (x - (e - 1) * O) / e / 3 - (e - 1) * O) / e : S = x, T(Math.max(240, S));
49
49
  };
50
50
  r();
51
51
  const C = () => r();
@@ -1 +1 @@
1
- {"version":3,"file":"MicroBeatCarousel.es.js","names":[],"sources":["../../../src/microinsights/carousel/MicroBeatCarousel.tsx"],"sourcesContent":["/* eslint-disable consistent-return */\nimport React from 'react'\nimport { observer } from 'mobx-react-lite'\n\nimport Stack from '@mui/material/Stack'\n\nimport { CarouselControls } from './CarouselControls'\nimport BeatList from './BeatList'\n\nimport type { MicroWidgetProps } from '..'\n\nimport { useCopyStore, useEvent } from '../context/hooks'\n\nimport type { Beat } from '../../core/types/Beat'\n\nimport { ANALYTICS_CLICK_EVENTS } from '../constants/Analytics'\nimport { MINIMUM_SWIPE_DISTANCE } from '../constants/App'\n\ninterface MicroBeatCarouselProps {\n allowSingleCardPeeking?: boolean\n analyticsMetadata?: Record<string, string>\n beats?: Beat[]\n elevation?: number\n heightOverrides?: MicroWidgetProps['heightOverrides']\n inDescriptionCtaBehavior?: MicroWidgetProps['inDescriptionCtaBehavior']\n onCardClick?: MicroWidgetProps['onCardClick']\n posthog?: MicroWidgetProps['posthog']\n showCarouselControls?: boolean\n showIcon?: boolean\n showWithMargin?: boolean\n variant?: 'outlined' | 'elevation' | undefined\n visibleCardsCount?: number\n widthOverrides?: number\n}\n\nconst MicroBeatCarousel: React.FC<MicroBeatCarouselProps> = ({\n analyticsMetadata,\n allowSingleCardPeeking,\n beats = [],\n elevation,\n heightOverrides,\n inDescriptionCtaBehavior,\n onCardClick,\n posthog,\n showCarouselControls,\n showIcon,\n showWithMargin = true,\n variant,\n widthOverrides,\n visibleCardsCount = 1, // Default to 1 card visible\n}) => {\n // ************** Use Ref Hooks **************************\n const ref = React.useRef<HTMLDivElement | null>(null)\n const carouselRef = React.useRef<HTMLDivElement | null>(null)\n\n // ************** Use States Hooks ***********************\n const [scrollX, setScrollX] = React.useState<number>(0)\n const [touchEnd, setTouchEnd] = React.useState<number | null>(null)\n const [touchStart, setTouchStart] = React.useState<number | null>(null)\n const [cardWidth, setCardWidth] = React.useState<number | null>(null)\n\n // *************** Context functions *********************\n const { carouselCopy: copy } = useCopyStore()\n const { onEvent } = useEvent()\n\n // ************** Use Effects Hooks **********************\n\n React.useEffect(() => {\n // Single source of truth for card-width sizing. The two layout modes\n // (breakpoint-based peeking vs. proportional visible-cards math) are\n // mutually exclusive on `allowSingleCardPeeking`, so they share one\n // ResizeObserver/effect to keep resize tracking in one place.\n //\n // Observe the outer, structurally stable container (carouselRef) rather\n // than the inner shrink-wrapped flex row (ref). The inner row's width\n // depends on cardWidth, so observing it would feed back into itself and\n // cause a shrinking ResizeObserver loop / stuck-small layout.\n const computeCardWidth = (observedWidth?: number) => {\n const node = carouselRef.current\n if (!node) return\n\n // Prefer the width reported by the ResizeObserver entry to avoid an\n // extra layout read (thrashing); fall back to a DOM read on mount and\n // on the window-resize fallback path.\n const rawWidth = observedWidth ?? node.offsetWidth\n\n if (allowSingleCardPeeking) {\n // Use until token sizes are actually implemented in the mxui repo\n const breakpoints = [\n { maxWidth: 320, cardWidth: 220 },\n { maxWidth: 375, cardWidth: 268 },\n { maxWidth: 444, cardWidth: 300 },\n { maxWidth: 599, cardWidth: 350 },\n { maxWidth: 749, cardWidth: 450 },\n { maxWidth: 900, cardWidth: 600 },\n ]\n\n const matchingBreakpoint = breakpoints.find((bp) => rawWidth <= bp.maxWidth)\n setCardWidth(matchingBreakpoint ? matchingBreakpoint.cardWidth : 750)\n return\n }\n\n // The inner row is constrained to `calc(100% - 32px)` when showWithMargin\n // is set, so subtract that margin to match the actual available width.\n // Clamp to 0 so a tiny/unmeasured container never yields a negative width.\n const containerWidth = showWithMargin ? Math.max(0, rawWidth - 32) : rawWidth\n const gap = 8 // gap between cards\n\n // When visibleCardsCount > 1, make each card narrower to fit multiple cards and show a peek of the next card\n // When visibleCardsCount is 1, use full container width\n let calculatedCardWidth\n if (visibleCardsCount > 1) {\n // First calculate what a single full card width would be\n const fullCardWidth = (containerWidth - (visibleCardsCount - 1) * gap) / visibleCardsCount\n // Set the peek area to be 1/3 of a card width instead of fixed 60px\n const peekAreaWidth = fullCardWidth / 3\n // Calculate final card width, accounting for the peek area and gaps\n calculatedCardWidth =\n (containerWidth - peekAreaWidth - (visibleCardsCount - 1) * gap) / visibleCardsCount\n } else {\n calculatedCardWidth = containerWidth\n }\n\n // Clamp to prevent negative widths.\n setCardWidth(Math.max(0, calculatedCardWidth))\n }\n\n computeCardWidth()\n\n // Recompute on container resize via ResizeObserver, falling back to the\n // window resize event only when ResizeObserver is unavailable.\n const handleResize = () => computeCardWidth()\n let observer: ResizeObserver | null = null\n if (typeof ResizeObserver !== 'undefined' && carouselRef.current) {\n observer = new ResizeObserver((entries) => {\n const entry = entries[0]\n if (!entry) return\n const width = entry.borderBoxSize?.[0]?.inlineSize ?? entry.contentRect.width\n computeCardWidth(width)\n })\n observer.observe(carouselRef.current)\n } else {\n window.addEventListener('resize', handleResize)\n }\n\n return () => {\n window.removeEventListener('resize', handleResize)\n observer?.disconnect()\n }\n }, [allowSingleCardPeeking, visibleCardsCount, showWithMargin])\n\n // *************** Click handlers ************************\n const handleNextClick = () => {\n onEvent(ANALYTICS_CLICK_EVENTS.ON_CAROUSEL_FORWARD_CLICK, analyticsMetadata)\n\n if (ref.current && cardWidth) {\n // Scroll by one card width + gap\n ref.current.scrollTo({\n left: scrollX + cardWidth + 8,\n top: 0,\n behavior: 'smooth',\n })\n }\n }\n\n const handlePreviousClick = () => {\n onEvent(ANALYTICS_CLICK_EVENTS.ON_CAROUSEL_BACK_CLICK, analyticsMetadata)\n\n if (ref.current && cardWidth) {\n // Scroll by one card width + gap\n ref.current.scrollTo({\n left: Math.max(0, scrollX - (cardWidth + 8)),\n top: 0,\n behavior: 'smooth',\n })\n }\n }\n\n const handleScroll = () => {\n if (ref.current) {\n setScrollX(ref.current.scrollLeft)\n }\n }\n\n // *************** Mobile handlers ************************\n const onTouchEnd = () => {\n if (!touchStart || !touchEnd) return\n const distance = touchStart - touchEnd\n\n // swiping left\n if (distance > MINIMUM_SWIPE_DISTANCE) {\n onEvent(ANALYTICS_CLICK_EVENTS.ON_CAROUSEL_FORWARD_SWIPE, analyticsMetadata)\n } else {\n // swiping right\n onEvent(ANALYTICS_CLICK_EVENTS.ON_CAROUSEL_BACK_SWIPE, analyticsMetadata)\n }\n }\n\n const onTouchMove = (e: React.TouchEvent) => {\n setTouchEnd(e.targetTouches[0].clientX)\n }\n\n const onTouchStart = (e: React.TouchEvent) => {\n // otherwise the swipe is fired even with usual touch events\n setTouchEnd(null)\n setTouchStart(e.targetTouches[0].clientX)\n }\n\n // Calculate active card index based on scroll position and card width\n const activeCardIndex = cardWidth ? Math.round(scrollX / (cardWidth + 8)) : 0\n const scrollBoundry = ref.current ? ref.current.scrollWidth - ref.current.offsetWidth : 0\n\n return (\n <Stack\n aria-label={copy?.carousel_title}\n aria-roledescription=\"carousel\"\n ref={carouselRef}\n role=\"region\"\n sx={{\n alignItems: 'center',\n boxSizing: 'border-box',\n height: heightOverrides,\n width: widthOverrides ? widthOverrides : '100%',\n }}\n >\n <Stack\n direction=\"row\"\n onScroll={handleScroll}\n onTouchEnd={onTouchEnd}\n onTouchMove={onTouchMove}\n onTouchStart={onTouchStart}\n ref={ref}\n sx={{\n alignItems: 'center',\n height: heightOverrides && '100%',\n gap: 8,\n listStyleType: 'none',\n m: 0,\n maxWidth: showWithMargin ? `calc(100% - 32px)` : '100%',\n overflowX: 'auto',\n overflowY: 'hidden',\n p: 0,\n scrollbarWidth: 'none',\n msOverflowStyle: 'none',\n WebkitOverflowScrolling: 'touch',\n '&::-webkit-scrollbar': {\n display: 'none',\n },\n }}\n >\n <BeatList\n activeCardIndex={activeCardIndex}\n beats={beats}\n cardWidth={cardWidth}\n elevation={elevation}\n heightOverrides={heightOverrides}\n inDescriptionCtaBehavior={inDescriptionCtaBehavior}\n onCardClick={onCardClick}\n posthog={posthog}\n showIcon={showIcon}\n variant={variant}\n />\n </Stack>\n {showCarouselControls && (\n <CarouselControls\n currentBeatIndex={activeCardIndex + visibleCardsCount - 1}\n numBeats={beats.length + 1}\n onNextClick={handleNextClick}\n onPreviousClick={handlePreviousClick}\n scrollRightBoundary={scrollBoundry}\n scrollX={scrollX}\n shouldApplyDotAnimation={allowSingleCardPeeking}\n visibleCardsCount={visibleCardsCount}\n />\n )}\n </Stack>\n )\n}\n\nexport default observer(MicroBeatCarousel)\n"],"mappings":";;;;;;;;AAmCA,IAAM,KAAA,CAAuD,EAC3D,mBAAA,GACA,wBAAA,GACA,OAAA,IAAQ,CAAC,GACT,WAAA,GACA,iBAAA,GACA,0BAAA,GACA,aAAA,GACA,SAAA,GACA,sBAAA,GACA,UAAA,GACA,gBAAA,IAAiB,IACjB,SAAA,GACA,gBAAA,GACA,mBAAA,IAAoB,EAAA,MAChB;AAEJ,QAAM,IAAM,EAAM,OAA8B,IAAI,GAC9C,IAAc,EAAM,OAA8B,IAAI,GAGtD,CAAC,GAAS,CAAA,IAAc,EAAM,SAAiB,CAAC,GAChD,CAAC,GAAU,CAAA,IAAe,EAAM,SAAwB,IAAI,GAC5D,CAAC,GAAY,CAAA,IAAiB,EAAM,SAAwB,IAAI,GAChE,CAAC,GAAW,CAAA,IAAgB,EAAM,SAAwB,IAAI,GAG9D,EAAE,cAAc,EAAA,IAAS,EAAa,GACtC,EAAE,SAAA,EAAA,IAAY,EAAS;AAI7B,EAAA,EAAM,UAAA,MAAgB;AAUpB,UAAM,IAAA,CAAoB,MAA2B;AACnD,YAAM,IAAO,EAAY;AACzB,UAAI,CAAC,EAAM;AAKX,YAAM,IAAW,KAAiB,EAAK;AAEvC,UAAI,GAAwB;AAW1B,cAAM,IAAqB;AAAA,UARzB;AAAA,YAAE,UAAU;AAAA,YAAK,WAAW;AAAA,UAAI;AAAA,UAChC;AAAA,YAAE,UAAU;AAAA,YAAK,WAAW;AAAA,UAAI;AAAA,UAChC;AAAA,YAAE,UAAU;AAAA,YAAK,WAAW;AAAA,UAAI;AAAA,UAChC;AAAA,YAAE,UAAU;AAAA,YAAK,WAAW;AAAA,UAAI;AAAA,UAChC;AAAA,YAAE,UAAU;AAAA,YAAK,WAAW;AAAA,UAAI;AAAA,UAChC;AAAA,YA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AAAA,QACX,GAAG;AAAA,QACH,gBAAgB;AAAA,QAChB,iBAAiB;AAAA,QACjB,yBAAyB;AAAA,QACzB,wBAAwB,EACtB,SAAS,OACX;AAAA,MACF;AAAA,MAEA,UAAA,gBAAA,EAAC,GAAD;AAAA,QACmB,iBAAA;AAAA,QACV,OAAA;AAAA,QACI,WAAA;AAAA,QACA,WAAA;AAAA,QACM,iBAAA;AAAA,QACS,0BAAA;AAAA,QACb,aAAA;AAAA,QACJ,SAAA;AAAA,QACC,UAAA;AAAA,QACD,SAAA;AAAA,MACV,CAAA;AAAA,IACI,CAAA,GACN,KACC,gBAAA,EAAC,GAAD;AAAA,MACE,kBAAkB,IAAkB,IAAoB;AAAA,MACxD,UAAU,EAAM,SAAS;AAAA,MACzB,aAAa;AAAA,MACb,iBAAiB;AAAA,MACjB,qBAAqB;AAAA,MACZ,SAAA;AAAA,MACT,yBAAyB;AAAA,MACN,mBAAA;AAAA,IACpB,CAAA,CAEE;AAAA;AAEX,GAEA,KAAe,EAAS,EAAiB"}
1
+ {"version":3,"file":"MicroBeatCarousel.es.js","names":[],"sources":["../../../src/microinsights/carousel/MicroBeatCarousel.tsx"],"sourcesContent":["/* eslint-disable consistent-return */\nimport React from 'react'\nimport { observer } from 'mobx-react-lite'\n\nimport Stack from '@mui/material/Stack'\n\nimport { CarouselControls } from './CarouselControls'\nimport BeatList from './BeatList'\n\nimport type { MicroWidgetProps } from '..'\n\nimport { useCopyStore, useEvent } from '../context/hooks'\n\nimport type { Beat } from '../../core/types/Beat'\n\nimport { ANALYTICS_CLICK_EVENTS } from '../constants/Analytics'\nimport { MIN_CARD_WIDTH, MINIMUM_SWIPE_DISTANCE } from '../constants/App'\n\ninterface MicroBeatCarouselProps {\n allowSingleCardPeeking?: boolean\n analyticsMetadata?: Record<string, string>\n beats?: Beat[]\n elevation?: number\n heightOverrides?: MicroWidgetProps['heightOverrides']\n inDescriptionCtaBehavior?: MicroWidgetProps['inDescriptionCtaBehavior']\n onCardClick?: MicroWidgetProps['onCardClick']\n posthog?: MicroWidgetProps['posthog']\n showCarouselControls?: boolean\n showIcon?: boolean\n showWithMargin?: boolean\n variant?: 'outlined' | 'elevation' | undefined\n visibleCardsCount?: number\n widthOverrides?: number\n}\n\nconst MicroBeatCarousel: React.FC<MicroBeatCarouselProps> = ({\n analyticsMetadata,\n allowSingleCardPeeking,\n beats = [],\n elevation,\n heightOverrides,\n inDescriptionCtaBehavior,\n onCardClick,\n posthog,\n showCarouselControls,\n showIcon,\n showWithMargin = true,\n variant,\n widthOverrides,\n visibleCardsCount = 1, // Default to 1 card visible\n}) => {\n // ************** Use Ref Hooks **************************\n const ref = React.useRef<HTMLDivElement | null>(null)\n const carouselRef = React.useRef<HTMLDivElement | null>(null)\n\n // ************** Use States Hooks ***********************\n const [scrollX, setScrollX] = React.useState<number>(0)\n const [touchEnd, setTouchEnd] = React.useState<number | null>(null)\n const [touchStart, setTouchStart] = React.useState<number | null>(null)\n const [cardWidth, setCardWidth] = React.useState<number | null>(null)\n\n // *************** Context functions *********************\n const { carouselCopy: copy } = useCopyStore()\n const { onEvent } = useEvent()\n\n // ************** Use Effects Hooks **********************\n\n React.useEffect(() => {\n // Single source of truth for card-width sizing. The two layout modes\n // (breakpoint-based peeking vs. proportional visible-cards math) are\n // mutually exclusive on `allowSingleCardPeeking`, so they share one\n // ResizeObserver/effect to keep resize tracking in one place.\n //\n // Observe the outer, structurally stable container (carouselRef) rather\n // than the inner shrink-wrapped flex row (ref). The inner row's width\n // depends on cardWidth, so observing it would feed back into itself and\n // cause a shrinking ResizeObserver loop / stuck-small layout.\n const computeCardWidth = (observedWidth?: number) => {\n const node = carouselRef.current\n if (!node) return\n\n // Prefer the width reported by the ResizeObserver entry to avoid an\n // extra layout read (thrashing); fall back to a DOM read on mount and\n // on the window-resize fallback path.\n const rawWidth = observedWidth ?? node.offsetWidth\n\n if (allowSingleCardPeeking) {\n // Use until token sizes are actually implemented in the mxui repo\n const breakpoints = [\n { maxWidth: 320, cardWidth: MIN_CARD_WIDTH },\n { maxWidth: 375, cardWidth: 268 },\n { maxWidth: 444, cardWidth: 300 },\n { maxWidth: 599, cardWidth: 350 },\n { maxWidth: 749, cardWidth: 450 },\n { maxWidth: 900, cardWidth: 600 },\n ]\n\n const matchingBreakpoint = breakpoints.find((bp) => rawWidth <= bp.maxWidth)\n setCardWidth(matchingBreakpoint ? matchingBreakpoint.cardWidth : 750)\n return\n }\n\n // The inner row is constrained to `calc(100% - 32px)` when showWithMargin\n // is set, so subtract that margin to match the actual available width.\n // Clamp to 0 so a tiny/unmeasured container never yields a negative width.\n const containerWidth = showWithMargin ? Math.max(0, rawWidth - 32) : rawWidth\n const gap = 8 // gap between cards\n\n // When visibleCardsCount > 1, make each card narrower to fit multiple cards and show a peek of the next card\n // When visibleCardsCount is 1, use full container width\n let calculatedCardWidth\n if (visibleCardsCount > 1) {\n // First calculate what a single full card width would be\n const fullCardWidth = (containerWidth - (visibleCardsCount - 1) * gap) / visibleCardsCount\n // Set the peek area to be 1/3 of a card width instead of fixed 60px\n const peekAreaWidth = fullCardWidth / 3\n // Calculate final card width, accounting for the peek area and gaps\n calculatedCardWidth =\n (containerWidth - peekAreaWidth - (visibleCardsCount - 1) * gap) / visibleCardsCount\n } else {\n calculatedCardWidth = containerWidth\n }\n\n setCardWidth(Math.max(MIN_CARD_WIDTH, calculatedCardWidth))\n }\n\n computeCardWidth()\n\n // Recompute on container resize via ResizeObserver, falling back to the\n // window resize event only when ResizeObserver is unavailable.\n const handleResize = () => computeCardWidth()\n let observer: ResizeObserver | null = null\n if (typeof ResizeObserver !== 'undefined' && carouselRef.current) {\n observer = new ResizeObserver((entries) => {\n const entry = entries[0]\n if (!entry) return\n const width = entry.borderBoxSize?.[0]?.inlineSize ?? entry.contentRect.width\n computeCardWidth(width)\n })\n observer.observe(carouselRef.current)\n } else {\n window.addEventListener('resize', handleResize)\n }\n\n return () => {\n window.removeEventListener('resize', handleResize)\n observer?.disconnect()\n }\n }, [allowSingleCardPeeking, visibleCardsCount, showWithMargin])\n\n // *************** Click handlers ************************\n const handleNextClick = () => {\n onEvent(ANALYTICS_CLICK_EVENTS.ON_CAROUSEL_FORWARD_CLICK, analyticsMetadata)\n\n if (ref.current && cardWidth) {\n // Scroll by one card width + gap\n ref.current.scrollTo({\n left: scrollX + cardWidth + 8,\n top: 0,\n behavior: 'smooth',\n })\n }\n }\n\n const handlePreviousClick = () => {\n onEvent(ANALYTICS_CLICK_EVENTS.ON_CAROUSEL_BACK_CLICK, analyticsMetadata)\n\n if (ref.current && cardWidth) {\n // Scroll by one card width + gap\n ref.current.scrollTo({\n left: Math.max(0, scrollX - (cardWidth + 8)),\n top: 0,\n behavior: 'smooth',\n })\n }\n }\n\n const handleScroll = () => {\n if (ref.current) {\n setScrollX(ref.current.scrollLeft)\n }\n }\n\n // *************** Mobile handlers ************************\n const onTouchEnd = () => {\n if (!touchStart || !touchEnd) return\n const distance = touchStart - touchEnd\n\n // swiping left\n if (distance > MINIMUM_SWIPE_DISTANCE) {\n onEvent(ANALYTICS_CLICK_EVENTS.ON_CAROUSEL_FORWARD_SWIPE, analyticsMetadata)\n } else {\n // swiping right\n onEvent(ANALYTICS_CLICK_EVENTS.ON_CAROUSEL_BACK_SWIPE, analyticsMetadata)\n }\n }\n\n const onTouchMove = (e: React.TouchEvent) => {\n setTouchEnd(e.targetTouches[0].clientX)\n }\n\n const onTouchStart = (e: React.TouchEvent) => {\n // otherwise the swipe is fired even with usual touch events\n setTouchEnd(null)\n setTouchStart(e.targetTouches[0].clientX)\n }\n\n // Calculate active card index based on scroll position and card width\n const activeCardIndex = cardWidth ? Math.round(scrollX / (cardWidth + 8)) : 0\n const scrollBoundry = ref.current ? ref.current.scrollWidth - ref.current.offsetWidth : 0\n\n return (\n <Stack\n aria-label={copy?.carousel_title}\n aria-roledescription=\"carousel\"\n ref={carouselRef}\n role=\"region\"\n sx={{\n alignItems: 'center',\n boxSizing: 'border-box',\n height: heightOverrides,\n width: widthOverrides ? widthOverrides : '100%',\n }}\n >\n <Stack\n direction=\"row\"\n onScroll={handleScroll}\n onTouchEnd={onTouchEnd}\n onTouchMove={onTouchMove}\n onTouchStart={onTouchStart}\n ref={ref}\n sx={{\n alignItems: 'center',\n height: heightOverrides && '100%',\n gap: 8,\n listStyleType: 'none',\n m: 0,\n maxWidth: showWithMargin ? `calc(100% - 32px)` : '100%',\n overflowX: 'auto',\n overflowY: 'hidden',\n p: 0,\n scrollbarWidth: 'none',\n msOverflowStyle: 'none',\n WebkitOverflowScrolling: 'touch',\n '&::-webkit-scrollbar': {\n display: 'none',\n },\n }}\n >\n <BeatList\n activeCardIndex={activeCardIndex}\n beats={beats}\n cardWidth={cardWidth}\n elevation={elevation}\n heightOverrides={heightOverrides}\n inDescriptionCtaBehavior={inDescriptionCtaBehavior}\n onCardClick={onCardClick}\n posthog={posthog}\n showIcon={showIcon}\n variant={variant}\n />\n </Stack>\n {showCarouselControls && (\n <CarouselControls\n currentBeatIndex={activeCardIndex + visibleCardsCount - 1}\n numBeats={beats.length + 1}\n onNextClick={handleNextClick}\n onPreviousClick={handlePreviousClick}\n scrollRightBoundary={scrollBoundry}\n scrollX={scrollX}\n shouldApplyDotAnimation={allowSingleCardPeeking}\n visibleCardsCount={visibleCardsCount}\n />\n )}\n </Stack>\n )\n}\n\nexport default observer(MicroBeatCarousel)\n"],"mappings":";;;;;;;;AAmCA,IAAM,KAAA,CAAuD,EAC3D,mBAAA,GACA,wBAAA,GACA,OAAA,IAAQ,CAAC,GACT,WAAA,GACA,iBAAA,GACA,0BAAA,GACA,aAAA,GACA,SAAA,GACA,sBAAA,GACA,UAAA,GACA,gBAAA,IAAiB,IACjB,SAAA,GACA,gBAAA,GACA,mBAAA,IAAoB,EAAA,MAChB;AAEJ,QAAM,IAAM,EAAM,OAA8B,IAAI,GAC9C,IAAc,EAAM,OAA8B,IAAI,GAGtD,CAAC,GAAS,CAAA,IAAc,EAAM,SAAiB,CAAC,GAChD,CAAC,GAAU,CAAA,IAAe,EAAM,S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SAAA;AAAA,MACT,yBAAyB;AAAA,MACN,mBAAA;AAAA,IACpB,CAAA,CAEE;AAAA;AAEX,GAEA,KAAe,EAAS,EAAiB"}
@@ -1,3 +1,7 @@
1
1
  export declare const SUPPORTED_CAROUSEL_HEIGHTS: any;
2
2
  export declare const MINIMUM_SWIPE_DISTANCE = 50;
3
3
  export declare const VIEW_THRESHOLD = 1;
4
+ /** A micro card never gets narrower than this (px); the carousel scrolls instead. */
5
+ export declare const MIN_CARD_WIDTH = 240;
6
+ /** The micro card's icon tile (px). */
7
+ export declare const ICON_SIZE = 32;
@@ -1 +1 @@
1
- {"version":3,"file":"App.es.js","names":[],"sources":["../../../src/microinsights/constants/App.ts"],"sourcesContent":["export const SUPPORTED_CAROUSEL_HEIGHTS: any = {\n LARGE: 180,\n STANDARD: 154,\n XLARGE: 200,\n XXLARGE: 248,\n}\n\nexport const MINIMUM_SWIPE_DISTANCE = 50\n\nexport const VIEW_THRESHOLD = 1 // card is 100% in view\n"],"mappings":"AAAA,IAAa,IAAkC;AAAA,EAC7C,OAAO;AAAA,EACP,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,SAAS;AACX"}
1
+ {"version":3,"file":"App.es.js","names":[],"sources":["../../../src/microinsights/constants/App.ts"],"sourcesContent":["export const SUPPORTED_CAROUSEL_HEIGHTS: any = {\n LARGE: 180,\n STANDARD: 154,\n XLARGE: 200,\n XXLARGE: 248,\n}\n\nexport const MINIMUM_SWIPE_DISTANCE = 50\n\nexport const VIEW_THRESHOLD = 1 // card is 100% in view\n\n/** A micro card never gets narrower than this (px); the carousel scrolls instead. */\nexport const MIN_CARD_WIDTH = 240\n\n/** The micro card's icon tile (px). */\nexport const ICON_SIZE = 32\n"],"mappings":"AAAA,IAAa,IAAkC;AAAA,EAC7C,OAAO;AAAA,EACP,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,SAAS;AACX"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * A micro card's CSS `min-width`: the carousel's width, or the container's (`100%`) without one,
3
+ * never below `MIN_CARD_WIDTH`. A numeric string (`'300'`, `'300px'`) reads as its px value.
4
+ */
5
+ export declare const microCardMinWidth: (widthOverrides?: string | number) => string;
@@ -0,0 +1,9 @@
1
+ var o = (a) => {
2
+ const t = typeof a == "number" ? a : parseFloat(a ?? "");
3
+ return t ? `${Math.max(t, 240)}px` : "max(100%, 240px)";
4
+ };
5
+ export {
6
+ o as microCardMinWidth
7
+ };
8
+
9
+ //# sourceMappingURL=cardWidth.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cardWidth.es.js","names":[],"sources":["../../../src/microinsights/utils/cardWidth.ts"],"sourcesContent":["import { MIN_CARD_WIDTH } from '../constants/App'\n\n/**\n * A micro card's CSS `min-width`: the carousel's width, or the container's (`100%`) without one,\n * never below `MIN_CARD_WIDTH`. A numeric string (`'300'`, `'300px'`) reads as its px value.\n */\nexport const microCardMinWidth = (widthOverrides?: string | number): string => {\n const width =\n typeof widthOverrides === 'number' ? widthOverrides : parseFloat(widthOverrides ?? '')\n\n return width ? `${Math.max(width, MIN_CARD_WIDTH)}px` : `max(100%, ${MIN_CARD_WIDTH}px)`\n}\n"],"mappings":"AAMA,IAAa,IAAA,CAAqB,MAA6C;AAC7E,QAAM,IACJ,OAAO,KAAmB,WAAW,IAAiB,WAAW,KAAkB,EAAE;AAEvF,SAAO,IAAQ,GAAG,KAAK,IAAI,GAAA,GAAqB,CAAA,OAAQ;AAC1D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mx-cartographer/experiences",
3
- "version": "9.7.112",
3
+ "version": "9.7.114",
4
4
  "description": "Library containing experience widgets",
5
5
  "author": "MX",
6
6
  "license": "MIT",