@mx-cartographer/experiences 9.7.17 → 9.7.18

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 (32) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/core/api/BeatApi.d.ts +15 -2
  3. package/dist/core/api/BeatApi.es.js +8 -7
  4. package/dist/core/api/BeatApi.es.js.map +1 -1
  5. package/dist/core/constants/ApiEndpoints.d.ts +1 -0
  6. package/dist/core/constants/ApiEndpoints.es.js +1 -0
  7. package/dist/core/constants/ApiEndpoints.es.js.map +1 -1
  8. package/dist/core/stores/BeatStore.d.ts +2 -2
  9. package/dist/core/stores/BeatStore.es.js +29 -29
  10. package/dist/core/stores/BeatStore.es.js.map +1 -1
  11. package/dist/microinsights/InsightsMicroWidget.es.js +39 -38
  12. package/dist/microinsights/InsightsMicroWidget.es.js.map +1 -1
  13. package/dist/microinsights/beatActions.d.ts +21 -0
  14. package/dist/microinsights/beatActions.es.js +23 -0
  15. package/dist/microinsights/beatActions.es.js.map +1 -0
  16. package/dist/microinsights/cards/InlineActionBlock.d.ts +16 -0
  17. package/dist/microinsights/cards/InlineActionBlock.es.js +41 -0
  18. package/dist/microinsights/cards/InlineActionBlock.es.js.map +1 -0
  19. package/dist/microinsights/cards/InsightCard.es.js +68 -61
  20. package/dist/microinsights/cards/InsightCard.es.js.map +1 -1
  21. package/dist/microinsights/carousel/BeatList.es.js +17 -16
  22. package/dist/microinsights/carousel/BeatList.es.js.map +1 -1
  23. package/dist/microinsights/carousel/MicroBeatCarousel.d.ts +1 -0
  24. package/dist/microinsights/carousel/MicroBeatCarousel.es.js +34 -33
  25. package/dist/microinsights/carousel/MicroBeatCarousel.es.js.map +1 -1
  26. package/dist/microinsights/context/hooks.es.js +11 -6
  27. package/dist/microinsights/context/hooks.es.js.map +1 -1
  28. package/dist/microinsights/interfaces.d.ts +12 -0
  29. package/dist/microinsights/stores/InsightsMicroWidgetStore.d.ts +3 -1
  30. package/dist/microinsights/stores/InsightsMicroWidgetStore.es.js +18 -17
  31. package/dist/microinsights/stores/InsightsMicroWidgetStore.es.js.map +1 -1
  32. package/package.json +1 -1
@@ -1,30 +1,33 @@
1
- import { slot as T } from "../../core/types/Insights.es.js";
2
- import { resolveInsightRender as S } from "../../insights-v2/resolveInsightRender.es.js";
3
- import F from "../../insights-v2/components/LogoFromGuid.es.js";
4
- import { statusIconName as O, statusIconPalette as v } from "../../insights-v2/components/statusIcon.es.js";
5
- import { ON_CLICK_EVENT as A, ON_VIEW_EVENT as L, ON_VIEW_FIRST_TIME_EVENT as j } from "../constants/Analytics.es.js";
6
- import V from "../beaticons/BeatMaterialIcon.es.js";
7
- import { BeatIcon as w } from "../beaticons/BeatIcon.es.js";
8
- import { useCopyStore as z, useEvent as G, useInsightsMicroWidgetStore as K } from "../context/hooks.es.js";
9
- import k from "../MicroCardTemplate.es.js";
10
- import Z from "../../insights-v2/components/InsightErrorCard.es.js";
11
- import { useEffect as x } from "react";
12
- import { jsx as o } from "react/jsx-runtime";
13
- import { alpha as B, useTheme as $ } from "@mui/material/styles";
14
- import q from "@mui/material/Box";
15
- import { useInView as D } from "react-intersection-observer";
16
- var H = 32, li = ({ ariaLabel: a, beat: i, elevation: g, index: c, isActiveCard: l, onCardClick: u, posthog: r, widthOverrides: n, variant: f, showIcon: h, heightOverrides: p }) => {
17
- const { ref: _, inView: m } = D({ threshold: 1 }), I = $(), { cardsCopy: M } = z(), { onEvent: d } = G(), { updateBeat: P, updateOffer: R } = K();
18
- x(() => {
19
- m && (i.has_been_displayed ? d(L(i.template)) : (i.guid.startsWith("OFR") ? R({
1
+ import { GlobalDataContext as G } from "../../common/context/GlobalDataProvider.es.js";
2
+ import { slot as B } from "../../core/types/Insights.es.js";
3
+ import { resolveInsightRender as j } from "../../insights-v2/resolveInsightRender.es.js";
4
+ import { hasDrawerBlock as v } from "../../insights-v2/mappings/hasDrawerBlock.es.js";
5
+ import w from "../../insights-v2/components/LogoFromGuid.es.js";
6
+ import { statusIconName as L, statusIconPalette as $ } from "../../insights-v2/components/statusIcon.es.js";
7
+ import { ON_CLICK_EVENT as z, ON_VIEW_EVENT as K, ON_VIEW_FIRST_TIME_EVENT as Z } from "../constants/Analytics.es.js";
8
+ import R from "../beaticons/BeatMaterialIcon.es.js";
9
+ import { BeatIcon as H } from "../beaticons/BeatIcon.es.js";
10
+ import { useCopyStore as J, useEvent as Q, useInsightsMicroWidgetStore as U } from "../context/hooks.es.js";
11
+ import V from "../MicroCardTemplate.es.js";
12
+ import X from "./InlineActionBlock.es.js";
13
+ import Y from "../../insights-v2/components/InsightErrorCard.es.js";
14
+ import b, { useEffect as M, useState as ii } from "react";
15
+ import { Fragment as ti, jsx as e, jsxs as ei } from "react/jsx-runtime";
16
+ import { alpha as F, useTheme as oi } from "@mui/material/styles";
17
+ import ri from "@mui/material/Box";
18
+ import { useInView as ni } from "react-intersection-observer";
19
+ var si = 32, Ti = ({ ariaLabel: m, beat: i, elevation: u, inDescriptionCtaBehavior: O = "external", index: l, isActiveCard: c, onCardClick: g, posthog: r, widthOverrides: n, variant: f, showIcon: h, heightOverrides: p }) => {
20
+ const { ref: _, inView: s } = ni({ threshold: 1 }), I = oi(), { cardsCopy: P } = J(), { onEvent: d } = Q(), { updateBeat: S, updateOffer: W } = U();
21
+ M(() => {
22
+ s && (i.has_been_displayed ? d(K(i.template)) : (i.guid.startsWith("OFR") ? W({
20
23
  ...i,
21
24
  has_been_displayed: !0
22
- }) : P({
25
+ }) : S({
23
26
  ...i,
24
27
  has_been_displayed: !0
25
- }), d(j(i.template))));
26
- }, [m]), x(() => {
27
- if (m && i) if (i.template === "MarketingOffer") {
28
+ }), d(Z(i.template))));
29
+ }, [s]), M(() => {
30
+ if (s && i) if (i.template === "MarketingOffer") {
28
31
  const t = i;
29
32
  r?.capture("viewed_messaging_insight", {
30
33
  template: i.template,
@@ -36,15 +39,15 @@ var H = 32, li = ({ ariaLabel: a, beat: i, elevation: g, index: c, isActiveCard:
36
39
  } else r?.capture("viewed_insight", {
37
40
  beat_guid: i.guid,
38
41
  template: i.template,
39
- position: c
42
+ position: l
40
43
  });
41
44
  }, [
42
45
  i,
43
- c,
44
- m
46
+ l,
47
+ s
45
48
  ]);
46
- const s = () => {
47
- if (u && u(i), d(A(i.template)), i.template === "MarketingOffer") {
49
+ const y = j(i), o = y === "v2" ? i.insights_payload : void 0, q = b.useContext(G) !== null, C = O === "internal" && q && v(o?.in_description_cta?.block), [E, A] = ii(0), a = () => {
50
+ if (C ? A((t) => t + 1) : g && g(i), d(z(i.template)), i.template === "MarketingOffer") {
48
51
  const t = i;
49
52
  r?.capture("clicked_messaging_insight", {
50
53
  template: i.template,
@@ -56,12 +59,12 @@ var H = 32, li = ({ ariaLabel: a, beat: i, elevation: g, index: c, isActiveCard:
56
59
  } else r?.capture("clicked_insight", {
57
60
  beat_guid: i.guid,
58
61
  template: i.template,
59
- position: c
62
+ position: l
60
63
  });
61
- }, y = S(i), e = y === "v2" ? i.insights_payload : void 0;
62
- if (y === "error") return /* @__PURE__ */ o(q, {
63
- "aria-hidden": !l,
64
- "aria-label": a,
64
+ };
65
+ if (y === "error") return /* @__PURE__ */ e(ri, {
66
+ "aria-hidden": !c,
67
+ "aria-label": m,
65
68
  "aria-roledescription": "slide",
66
69
  ref: _,
67
70
  role: "group",
@@ -70,48 +73,52 @@ var H = 32, li = ({ ariaLabel: a, beat: i, elevation: g, index: c, isActiveCard:
70
73
  minWidth: n ? `${n}px` : "100%",
71
74
  my: 1
72
75
  },
73
- children: /* @__PURE__ */ o(Z, { beat: i })
76
+ children: /* @__PURE__ */ e(Y, { beat: i })
74
77
  });
75
- if (e) {
76
- const t = T(e.instance_slot.data, "logo"), E = T(e.instance_slot.data, "icon"), C = O(E?.guid), N = v(E?.color), W = e.primary_cta?.label || e.in_description_cta?.label || void 0;
77
- return /* @__PURE__ */ o(k, {
78
+ if (o) {
79
+ const t = B(o.instance_slot.data, "logo"), x = B(o.instance_slot.data, "icon"), k = L(x?.guid), N = $(x?.color), D = o.primary_cta?.label || o.in_description_cta?.label || void 0, T = /* @__PURE__ */ e(V, {
78
80
  "aria-roledescription": "slide",
79
- ariaLabel: a,
80
- description: e.description.html_text,
81
- elevation: g,
81
+ ariaLabel: m,
82
+ description: o.description.html_text,
83
+ elevation: u,
82
84
  heightOverrides: p,
83
- icon: h && (t ? /* @__PURE__ */ o(F, {
85
+ icon: h && (t ? /* @__PURE__ */ e(w, {
84
86
  logo: t,
85
- size: H
86
- }) : C ? /* @__PURE__ */ o(V, {
87
- bgColor: B(I.palette[N].main, 0.15),
87
+ size: si
88
+ }) : k ? /* @__PURE__ */ e(R, {
89
+ bgColor: F(I.palette[N].main, 0.15),
88
90
  iconColor: N,
89
- name: C
90
- }) : /* @__PURE__ */ o(V, {
91
- bgColor: B(I.palette.primary.main, 0.15),
91
+ name: k
92
+ }) : /* @__PURE__ */ e(R, {
93
+ bgColor: F(I.palette.primary.main, 0.15),
92
94
  name: "lightbulb"
93
95
  })),
94
- isActiveCard: l,
95
- onCardClick: s,
96
- onPrimaryAction: s,
97
- primaryActionText: W,
96
+ isActiveCard: c,
97
+ onCardClick: a,
98
+ onPrimaryAction: a,
99
+ primaryActionText: D,
98
100
  ref: _,
99
- title: e.title ?? "",
101
+ title: o.title ?? "",
100
102
  variant: f,
101
103
  widthOverrides: n
102
104
  });
105
+ return C ? /* @__PURE__ */ ei(ti, { children: [T, E > 0 && /* @__PURE__ */ e(X, {
106
+ beat: i,
107
+ openRequest: E,
108
+ posthog: r
109
+ })] }) : T;
103
110
  }
104
- return /* @__PURE__ */ o(k, {
111
+ return /* @__PURE__ */ e(V, {
105
112
  "aria-roledescription": "slide",
106
- ariaLabel: a,
113
+ ariaLabel: m,
107
114
  description: i?.html_micro_description && i?.html_micro_description.length > 0 ? i.html_micro_description : i.html_description || "",
108
- elevation: g,
115
+ elevation: u,
109
116
  heightOverrides: p,
110
- icon: h && /* @__PURE__ */ o(w, { beat: i }),
111
- isActiveCard: l,
112
- onCardClick: s,
113
- onPrimaryAction: s,
114
- primaryActionText: i.micro_call_to_action || M?.micro_card_cta,
117
+ icon: h && /* @__PURE__ */ e(H, { beat: i }),
118
+ isActiveCard: c,
119
+ onCardClick: a,
120
+ onPrimaryAction: a,
121
+ primaryActionText: i.micro_call_to_action || P?.micro_card_cta,
115
122
  ref: _,
116
123
  title: i.micro_title && i.micro_title.length > 0 ? i.micro_title : i.title,
117
124
  variant: f,
@@ -119,7 +126,7 @@ var H = 32, li = ({ ariaLabel: a, beat: i, elevation: g, index: c, isActiveCard:
119
126
  });
120
127
  };
121
128
  export {
122
- li as InsightCard
129
+ Ti as InsightCard
123
130
  };
124
131
 
125
132
  //# 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 } 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 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 { 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 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 // ************** 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))\n } else {\n onEvent(ON_VIEW_EVENT(beat.template))\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 })\n }\n }\n }, [beat, index, inView])\n\n // *************** Click handlers ************************\n const handleClick = () => {\n /* eslint-disable no-unused-expressions */\n onCardClick && onCardClick(beat)\n onEvent(ON_CLICK_EVENT(beat.template))\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 })\n }\n }\n\n const insightRender = resolveInsightRender(beat as Beat)\n const v2Payload = insightRender === 'v2' ? beat.insights_payload : undefined\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 const rowLogo = slot<LogoRef>(v2Payload.instance_slot.data, 'logo')\n const statusIcon = slot<LogoRef>(v2Payload.instance_slot.data, 'icon')\n const statusName = statusIconName(statusIcon?.guid)\n const statusPalette = statusIconPalette(statusIcon?.color)\n const actionLabel =\n v2Payload.primary_cta?.label || v2Payload.in_description_cta?.label || undefined\n\n return (\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 bgColor={alpha(theme.palette.primary.main, 0.15)} name=\"lightbulb\" />\n ))\n }\n isActiveCard={isActiveCard}\n onCardClick={handleClick}\n onPrimaryAction={handleClick}\n primaryActionText={actionLabel}\n ref={ref}\n title={v2Payload.title ?? ''}\n variant={variant}\n widthOverrides={widthOverrides}\n />\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":";;;;;;;;;;;;;;;AA4BA,IAAM,IAAY,IAOL,KAAA,CAA2C,EACtD,WAAA,GACA,MAAA,GACA,WAAA,GACA,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,EAAU,EAChC,WAAA,EACF,CAAC,GAEK,IAAQ,EAAS,GAGjB,EAAE,WAAA,EAAA,IAAc,EAAa,GAC7B,EAAE,SAAA,EAAA,IAAY,EAAS,GACvB,EAAE,YAAA,GAAY,aAAA,EAAA,IAAgB,EAA4B;AAGhE,EAAA,EAAA,MAAgB;AACd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;AAAA,MACjB,SAAA;AAAA,MACO,gBAAA;AAAA,IACjB,CAAA;AAAA,EAEL;AAEA,SACE,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"}
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'\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 // ************** 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))\n } else {\n onEvent(ON_VIEW_EVENT(beat.template))\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 })\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))\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 })\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 const rowLogo = slot<LogoRef>(v2Payload.instance_slot.data, 'logo')\n const statusIcon = slot<LogoRef>(v2Payload.instance_slot.data, 'icon')\n const statusName = statusIconName(statusIcon?.guid)\n const statusPalette = statusIconPalette(statusIcon?.color)\n const actionLabel =\n v2Payload.primary_cta?.label || v2Payload.in_description_cta?.label || undefined\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 bgColor={alpha(theme.palette.primary.main, 0.15)} name=\"lightbulb\" />\n ))\n }\n isActiveCard={isActiveCard}\n onCardClick={handleClick}\n onPrimaryAction={handleClick}\n primaryActionText={actionLabel}\n ref={ref}\n 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 <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":";;;;;;;;;;;;;;;;;;AAkCA,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,EAAa,GAC7B,EAAE,SAAA,EAAA,IAAY,EAAS,GACvB,EAAE,YAAA,GAAY,aAAA,EAAA,IAAgB,EAA4B;AAGhE,EAAA,EAAA,MAAgB;AACd,IAAI,MACG,EAAK,qBAcR,EAAQ,EAAc,EAAK,QAAQ,CAAC,KAbhC,EAAK,KAAK,WAAW,KAAK,IAC5B,EAAY;AAAA,MACV,GAAG;AAAA,MACH,oBAAoB;AAAA,IACtB,CAAC,IAED,EAAW;AAAA,MACT,GAAG;AAAA,MACH,oBAAoB;AAAA,IACtB,CAAC,GAEH,EAAQ,EAAyB,EAAK,QAAQ,CAAC;AAAA,EAKrD,GAAG,CAAC,CAAM,CAAC,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AEA,IAAoB,KACnB,gBAAA,EAAC,GAAD;AAAA,MACQ,MAAA;AAAA,MACN,aAAa;AAAA,MACJ,SAAA;AAAA,IACV,CAAA,CAEH,EAAA,CAAA,IAbqB;AAAA,EAe3B;AAEA,SACE,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"}
@@ -1,21 +1,22 @@
1
- import { buildDynamicCopy as x } from "../../core/utils/Localization.es.js";
2
- import { useCopyStore as M } from "../context/hooks.es.js";
3
- import { InsightCard as P } from "../cards/InsightCard.es.js";
4
- import w from "../cards/ViewMoreMicroCard.es.js";
1
+ import { buildDynamicCopy as M } from "../../core/utils/Localization.es.js";
2
+ import { useCopyStore as P } from "../context/hooks.es.js";
3
+ import { InsightCard as w } from "../cards/InsightCard.es.js";
4
+ import D from "../cards/ViewMoreMicroCard.es.js";
5
5
  import "react";
6
- import { Fragment as D, jsx as l, jsxs as L } from "react/jsx-runtime";
7
- var I = ({ activeCardIndex: s, beats: r, cardWidth: n, elevation: a, heightOverrides: m, onCardClick: e, posthog: p, showIcon: d, variant: _ }) => {
8
- const { carouselCopy: g } = M(), c = {
6
+ import { Fragment as L, jsx as l, jsxs as S } from "react/jsx-runtime";
7
+ var R = ({ activeCardIndex: s, beats: r, cardWidth: n, elevation: a, heightOverrides: m, inDescriptionCtaBehavior: p, onCardClick: e, posthog: d, showIcon: _, variant: g }) => {
8
+ const { carouselCopy: h } = P(), c = {
9
9
  elevation: a,
10
10
  heightOverrides: m,
11
- posthog: p,
12
- showIcon: d,
13
- variant: _
11
+ inDescriptionCtaBehavior: p,
12
+ posthog: d,
13
+ showIcon: _,
14
+ variant: g
14
15
  };
15
- return /* @__PURE__ */ L(D, { children: [r.map((i, o) => {
16
- const h = o + 1, u = r.length + 1, v = x(g?.card_position_in_carousel_aria, h.toString(), u.toString()), f = i.micro_title && i.micro_title.length > 0, y = i.micro_description && i.micro_description.length > 0, t = i.is_insights_v2 ? i.insights_payload : void 0, $ = t ? t.title : f ? i.micro_title : i.title, C = t ? t.description?.text : y ? i.micro_description : i.description;
17
- return /* @__PURE__ */ l(P, {
18
- ariaLabel: `${v}: ${$}, ${C}`,
16
+ return /* @__PURE__ */ S(L, { children: [r.map((i, o) => {
17
+ const u = o + 1, v = r.length + 1, f = M(h?.card_position_in_carousel_aria, u.toString(), v.toString()), y = i.micro_title && i.micro_title.length > 0, $ = i.micro_description && i.micro_description.length > 0, t = i.is_insights_v2 ? i.insights_payload : void 0, C = t ? t.title : y ? i.micro_title : i.title, x = t ? t.description?.text : $ ? i.micro_description : i.description;
18
+ return /* @__PURE__ */ l(w, {
19
+ ariaLabel: `${f}: ${C}, ${x}`,
19
20
  beat: i,
20
21
  index: o,
21
22
  isActiveCard: o === s,
@@ -23,7 +24,7 @@ var I = ({ activeCardIndex: s, beats: r, cardWidth: n, elevation: a, heightOverr
23
24
  widthOverrides: n || void 0,
24
25
  ...c
25
26
  }, `${i.guid} ${o}`);
26
- }), /* @__PURE__ */ l(w, {
27
+ }), /* @__PURE__ */ l(D, {
27
28
  isActiveCard: s === r.length,
28
29
  onCardClick: e,
29
30
  widthOverrides: n || void 0,
@@ -31,7 +32,7 @@ var I = ({ activeCardIndex: s, beats: r, cardWidth: n, elevation: a, heightOverr
31
32
  })] });
32
33
  };
33
34
  export {
34
- I as default
35
+ R as default
35
36
  };
36
37
 
37
38
  //# sourceMappingURL=BeatList.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BeatList.es.js","names":[],"sources":["../../../src/microinsights/carousel/BeatList.tsx"],"sourcesContent":["import React from 'react'\n\nimport { InsightCard, ViewMoreMicroCard } from '..'\nimport type { MicroInsightCardProps } from '../interfaces'\n\nimport { useCopyStore } from '../context/hooks'\n\nimport type { Beat } from '../../core/types/Beat'\nimport { buildDynamicCopy } from '../../core/utils/Localization'\n\nexport interface BeatListProps extends MicroInsightCardProps {\n activeCardIndex: number\n beats: Beat[]\n cardWidth: number | null\n}\n\nconst BeatList: React.FC<BeatListProps> = ({\n activeCardIndex,\n beats,\n cardWidth,\n elevation,\n heightOverrides,\n onCardClick,\n posthog,\n showIcon,\n variant,\n}) => {\n const { carouselCopy: copy } = useCopyStore()\n\n const generalProps = {\n elevation,\n heightOverrides,\n posthog,\n showIcon,\n variant,\n }\n\n return (\n <>\n {beats.map((beat: Beat, i) => {\n const beatPosition = i + 1\n const totalBeats = beats.length + 1\n const ariaLabelPositionInCarousel = buildDynamicCopy(\n copy?.card_position_in_carousel_aria,\n beatPosition.toString(),\n totalBeats.toString(),\n )\n\n const hasMicroTitle = beat.micro_title && beat.micro_title.length > 0\n const hasMicroDescription = beat.micro_description && beat.micro_description.length > 0\n\n // An Insights 2.0 beat's copy lives on its envelope; the legacy micro fields are blank.\n const v2Payload = beat.is_insights_v2 ? beat.insights_payload : undefined\n\n const beatTitle = v2Payload\n ? v2Payload.title\n : hasMicroTitle\n ? beat.micro_title\n : beat.title\n const beatDescription = v2Payload\n ? v2Payload.description?.text\n : hasMicroDescription\n ? beat.micro_description\n : beat.description\n\n return (\n <InsightCard\n ariaLabel={`${ariaLabelPositionInCarousel}: ${beatTitle}, ${beatDescription}`}\n beat={beat}\n index={i}\n isActiveCard={i === activeCardIndex}\n key={`${beat.guid} ${i}`}\n onCardClick={onCardClick}\n widthOverrides={cardWidth || undefined}\n {...generalProps}\n />\n )\n })}\n <ViewMoreMicroCard\n isActiveCard={activeCardIndex === beats.length}\n onCardClick={onCardClick}\n widthOverrides={cardWidth || undefined}\n {...generalProps}\n />\n </>\n )\n}\n\nexport default BeatList\n"],"mappings":";;;;;;AAgBA,IAAM,IAAA,CAAqC,EACzC,iBAAA,GACA,OAAA,GACA,WAAA,GACA,WAAA,GACA,iBAAA,GACA,aAAA,GACA,SAAA,GACA,UAAA,GACA,SAAA,EAAA,MACI;AACJ,QAAM,EAAE,cAAc,EAAA,IAAS,EAAa,GAEtC,IAAe;AAAA,IACnB,WAAA;AAAA,IACA,iBAAA;AAAA,IACA,SAAA;AAAA,IACA,UAAA;AAAA,IACA,SAAA;AAAA,EACF;AAEA,SACE,gBAAA,EAAA,GAAA,EAAA,UAAA,CACG,EAAM,IAAA,CAAK,GAAY,MAAM;AAC5B,UAAM,IAAe,IAAI,GACnB,IAAa,EAAM,SAAS,GAC5B,IAA8B,EAClC,GAAM,gCACN,EAAa,SAAS,GACtB,EAAW,SAAS,CACtB,GAEM,IAAgB,EAAK,eAAe,EAAK,YAAY,SAAS,GAC9D,IAAsB,EAAK,qBAAqB,EAAK,kBAAkB,SAAS,GAGhF,IAAY,EAAK,iBAAiB,EAAK,mBAAmB,QAE1D,IAAY,IACd,EAAU,QACV,IACE,EAAK,cACL,EAAK,OACL,IAAkB,IACpB,EAAU,aAAa,OACvB,IACE,EAAK,oBACL,EAAK;AAEX,WACE,gBAAA,EAAC,GAAD;AAAA,MACE,WAAW,GAAG,CAAA,KAAgC,CAAA,KAAc,CAAA;AAAA,MACtD,MAAA;AAAA,MACN,OAAO;AAAA,MACP,cAAc,MAAM;AAAA,MAEP,aAAA;AAAA,MACb,gBAAgB,KAAa;AAAA,MAC7B,GAAI;AAAA,IACL,GAJM,GAAG,EAAK,IAAA,IAAQ,CAAA,EAItB;AAAA,EAEL,CAAC,GACD,gBAAA,EAAC,GAAD;AAAA,IACE,cAAc,MAAoB,EAAM;AAAA,IAC3B,aAAA;AAAA,IACb,gBAAgB,KAAa;AAAA,IAC7B,GAAI;AAAA,EACL,CAAA,CACD,EAAA,CAAA;AAEN"}
1
+ {"version":3,"file":"BeatList.es.js","names":[],"sources":["../../../src/microinsights/carousel/BeatList.tsx"],"sourcesContent":["import React from 'react'\n\nimport { InsightCard, ViewMoreMicroCard } from '..'\nimport type { MicroInsightCardProps } from '../interfaces'\n\nimport { useCopyStore } from '../context/hooks'\n\nimport type { Beat } from '../../core/types/Beat'\nimport { buildDynamicCopy } from '../../core/utils/Localization'\n\nexport interface BeatListProps extends MicroInsightCardProps {\n activeCardIndex: number\n beats: Beat[]\n cardWidth: number | null\n}\n\nconst BeatList: React.FC<BeatListProps> = ({\n activeCardIndex,\n beats,\n cardWidth,\n elevation,\n heightOverrides,\n inDescriptionCtaBehavior,\n onCardClick,\n posthog,\n showIcon,\n variant,\n}) => {\n const { carouselCopy: copy } = useCopyStore()\n\n const generalProps = {\n elevation,\n heightOverrides,\n inDescriptionCtaBehavior,\n posthog,\n showIcon,\n variant,\n }\n\n return (\n <>\n {beats.map((beat: Beat, i) => {\n const beatPosition = i + 1\n const totalBeats = beats.length + 1\n const ariaLabelPositionInCarousel = buildDynamicCopy(\n copy?.card_position_in_carousel_aria,\n beatPosition.toString(),\n totalBeats.toString(),\n )\n\n const hasMicroTitle = beat.micro_title && beat.micro_title.length > 0\n const hasMicroDescription = beat.micro_description && beat.micro_description.length > 0\n\n // An Insights 2.0 beat's copy lives on its envelope; the legacy micro fields are blank.\n const v2Payload = beat.is_insights_v2 ? beat.insights_payload : undefined\n\n const beatTitle = v2Payload\n ? v2Payload.title\n : hasMicroTitle\n ? beat.micro_title\n : beat.title\n const beatDescription = v2Payload\n ? v2Payload.description?.text\n : hasMicroDescription\n ? beat.micro_description\n : beat.description\n\n return (\n <InsightCard\n ariaLabel={`${ariaLabelPositionInCarousel}: ${beatTitle}, ${beatDescription}`}\n beat={beat}\n index={i}\n isActiveCard={i === activeCardIndex}\n key={`${beat.guid} ${i}`}\n onCardClick={onCardClick}\n widthOverrides={cardWidth || undefined}\n {...generalProps}\n />\n )\n })}\n <ViewMoreMicroCard\n isActiveCard={activeCardIndex === beats.length}\n onCardClick={onCardClick}\n widthOverrides={cardWidth || undefined}\n {...generalProps}\n />\n </>\n )\n}\n\nexport default BeatList\n"],"mappings":";;;;;;AAgBA,IAAM,IAAA,CAAqC,EACzC,iBAAA,GACA,OAAA,GACA,WAAA,GACA,WAAA,GACA,iBAAA,GACA,0BAAA,GACA,aAAA,GACA,SAAA,GACA,UAAA,GACA,SAAA,EAAA,MACI;AACJ,QAAM,EAAE,cAAc,EAAA,IAAS,EAAa,GAEtC,IAAe;AAAA,IACnB,WAAA;AAAA,IACA,iBAAA;AAAA,IACA,0BAAA;AAAA,IACA,SAAA;AAAA,IACA,UAAA;AAAA,IACA,SAAA;AAAA,EACF;AAEA,SACE,gBAAA,EAAA,GAAA,EAAA,UAAA,CACG,EAAM,IAAA,CAAK,GAAY,MAAM;AAC5B,UAAM,IAAe,IAAI,GACnB,IAAa,EAAM,SAAS,GAC5B,IAA8B,EAClC,GAAM,gCACN,EAAa,SAAS,GACtB,EAAW,SAAS,CACtB,GAEM,IAAgB,EAAK,eAAe,EAAK,YAAY,SAAS,GAC9D,IAAsB,EAAK,qBAAqB,EAAK,kBAAkB,SAAS,GAGhF,IAAY,EAAK,iBAAiB,EAAK,mBAAmB,QAE1D,IAAY,IACd,EAAU,QACV,IACE,EAAK,cACL,EAAK,OACL,IAAkB,IACpB,EAAU,aAAa,OACvB,IACE,EAAK,oBACL,EAAK;AAEX,WACE,gBAAA,EAAC,GAAD;AAAA,MACE,WAAW,GAAG,CAAA,KAAgC,CAAA,KAAc,CAAA;AAAA,MACtD,MAAA;AAAA,MACN,OAAO;AAAA,MACP,cAAc,MAAM;AAAA,MAEP,aAAA;AAAA,MACb,gBAAgB,KAAa;AAAA,MAC7B,GAAI;AAAA,IACL,GAJM,GAAG,EAAK,IAAA,IAAQ,CAAA,EAItB;AAAA,EAEL,CAAC,GACD,gBAAA,EAAC,GAAD;AAAA,IACE,cAAc,MAAoB,EAAM;AAAA,IAC3B,aAAA;AAAA,IACb,gBAAgB,KAAa;AAAA,IAC7B,GAAI;AAAA,EACL,CAAA,CACD,EAAA,CAAA;AAEN"}
@@ -7,6 +7,7 @@ interface MicroBeatCarouselProps {
7
7
  beats?: Beat[];
8
8
  elevation?: number;
9
9
  heightOverrides?: MicroWidgetProps['heightOverrides'];
10
+ inDescriptionCtaBehavior?: MicroWidgetProps['inDescriptionCtaBehavior'];
10
11
  onCardClick?: MicroWidgetProps['onCardClick'];
11
12
  posthog?: MicroWidgetProps['posthog'];
12
13
  showCarouselControls?: boolean;
@@ -1,13 +1,13 @@
1
1
  import { ANALYTICS_CLICK_EVENTS as a } from "../constants/Analytics.es.js";
2
- import { useCopyStore as G, useEvent as H } from "../context/hooks.es.js";
3
- import { CarouselControls as J } from "./CarouselControls.es.js";
4
- import Q from "./BeatList.es.js";
2
+ import { useCopyStore as H, useEvent as J } from "../context/hooks.es.js";
3
+ import { CarouselControls as Q } from "./CarouselControls.es.js";
4
+ import Z from "./BeatList.es.js";
5
5
  import n from "react";
6
- import { observer as Z } from "mobx-react-lite";
6
+ import { observer as $ } from "mobx-react-lite";
7
7
  import I from "@mui/material/Stack";
8
- import { jsx as R, jsxs as $ } from "react/jsx-runtime";
9
- var tt = ({ analyticsMetadata: i, allowSingleCardPeeking: h, beats: E = [], elevation: y, heightOverrides: f, onCardClick: b, posthog: z, showCarouselControls: N, showIcon: g, showWithMargin: m = !0, variant: k, widthOverrides: _, visibleCardsCount: e = 1 }) => {
10
- const t = n.useRef(null), s = n.useRef(null), [u, K] = n.useState(0), [v, A] = n.useState(null), [L, X] = n.useState(null), [o, T] = n.useState(null), { carouselCopy: U } = G(), { onEvent: d } = H();
8
+ import { jsx as R, jsxs as tt } from "react/jsx-runtime";
9
+ var et = ({ analyticsMetadata: i, allowSingleCardPeeking: h, beats: E = [], elevation: y, heightOverrides: f, inDescriptionCtaBehavior: b, onCardClick: z, posthog: N, showCarouselControls: g, showIcon: k, showWithMargin: m = !0, variant: K, widthOverrides: _, visibleCardsCount: e = 1 }) => {
10
+ const t = n.useRef(null), s = n.useRef(null), [u, X] = n.useState(0), [v, A] = n.useState(null), [L, U] = n.useState(null), [o, T] = n.useState(null), { carouselCopy: D } = H(), { onEvent: d } = J();
11
11
  n.useEffect(() => {
12
12
  const r = (p) => {
13
13
  const c = s.current;
@@ -39,7 +39,7 @@ var tt = ({ analyticsMetadata: i, allowSingleCardPeeking: h, beats: E = [], elev
39
39
  maxWidth: 900,
40
40
  cardWidth: 600
41
41
  }
42
- ].find((q) => l <= q.maxWidth);
42
+ ].find((G) => l <= G.maxWidth);
43
43
  T(w ? w.cardWidth : 750);
44
44
  return;
45
45
  }
@@ -63,29 +63,29 @@ var tt = ({ analyticsMetadata: i, allowSingleCardPeeking: h, beats: E = [], elev
63
63
  e,
64
64
  m
65
65
  ]);
66
- const D = () => {
66
+ const j = () => {
67
67
  d(a.ON_CAROUSEL_FORWARD_CLICK, i), t.current && o && t.current.scrollTo({
68
68
  left: u + o + 8,
69
69
  top: 0,
70
70
  behavior: "smooth"
71
71
  });
72
- }, j = () => {
72
+ }, F = () => {
73
73
  d(a.ON_CAROUSEL_BACK_CLICK, i), t.current && o && t.current.scrollTo({
74
74
  left: Math.max(0, u - (o + 8)),
75
75
  top: 0,
76
76
  behavior: "smooth"
77
77
  });
78
- }, F = () => {
79
- t.current && K(t.current.scrollLeft);
80
78
  }, M = () => {
79
+ t.current && X(t.current.scrollLeft);
80
+ }, P = () => {
81
81
  !L || !v || (L - v > 50 ? d(a.ON_CAROUSEL_FORWARD_SWIPE, i) : d(a.ON_CAROUSEL_BACK_SWIPE, i));
82
- }, P = (r) => {
83
- A(r.targetTouches[0].clientX);
84
82
  }, Y = (r) => {
85
- A(null), X(r.targetTouches[0].clientX);
86
- }, B = o ? Math.round(u / (o + 8)) : 0, V = t.current ? t.current.scrollWidth - t.current.offsetWidth : 0;
87
- return /* @__PURE__ */ $(I, {
88
- "aria-label": U?.carousel_title,
83
+ A(r.targetTouches[0].clientX);
84
+ }, V = (r) => {
85
+ A(null), U(r.targetTouches[0].clientX);
86
+ }, B = o ? Math.round(u / (o + 8)) : 0, q = t.current ? t.current.scrollWidth - t.current.offsetWidth : 0;
87
+ return /* @__PURE__ */ tt(I, {
88
+ "aria-label": D?.carousel_title,
89
89
  "aria-roledescription": "carousel",
90
90
  ref: s,
91
91
  role: "region",
@@ -97,10 +97,10 @@ var tt = ({ analyticsMetadata: i, allowSingleCardPeeking: h, beats: E = [], elev
97
97
  },
98
98
  children: [/* @__PURE__ */ R(I, {
99
99
  direction: "row",
100
- onScroll: F,
101
- onTouchEnd: M,
102
- onTouchMove: P,
103
- onTouchStart: Y,
100
+ onScroll: M,
101
+ onTouchEnd: P,
102
+ onTouchMove: Y,
103
+ onTouchStart: V,
104
104
  ref: t,
105
105
  sx: {
106
106
  alignItems: "center",
@@ -117,31 +117,32 @@ var tt = ({ analyticsMetadata: i, allowSingleCardPeeking: h, beats: E = [], elev
117
117
  WebkitOverflowScrolling: "touch",
118
118
  "&::-webkit-scrollbar": { display: "none" }
119
119
  },
120
- children: /* @__PURE__ */ R(Q, {
120
+ children: /* @__PURE__ */ R(Z, {
121
121
  activeCardIndex: B,
122
122
  beats: E,
123
123
  cardWidth: o,
124
124
  elevation: y,
125
125
  heightOverrides: f,
126
- onCardClick: b,
127
- posthog: z,
128
- showIcon: g,
129
- variant: k
126
+ inDescriptionCtaBehavior: b,
127
+ onCardClick: z,
128
+ posthog: N,
129
+ showIcon: k,
130
+ variant: K
130
131
  })
131
- }), N && /* @__PURE__ */ R(J, {
132
+ }), g && /* @__PURE__ */ R(Q, {
132
133
  currentBeatIndex: B + e - 1,
133
134
  numBeats: E.length + 1,
134
- onNextClick: D,
135
- onPreviousClick: j,
136
- scrollRightBoundary: V,
135
+ onNextClick: j,
136
+ onPreviousClick: F,
137
+ scrollRightBoundary: q,
137
138
  scrollX: u,
138
139
  shouldApplyDotAnimation: h,
139
140
  visibleCardsCount: e
140
141
  })]
141
142
  });
142
- }, ut = Z(tt);
143
+ }, dt = $(et);
143
144
  export {
144
- ut as default
145
+ dt as default
145
146
  };
146
147
 
147
148
  //# sourceMappingURL=MicroBeatCarousel.es.js.map
@@ -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 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 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 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":";;;;;;;;AAkCA,IAAM,KAAA,CAAuD,EAC3D,mBAAA,GACA,wBAAA,GACA,OAAA,IAAQ,CAAC,GACT,WAAA,GACA,iBAAA,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;A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ACZ,QAAQ,KAAmB;AAAA,QAC3B,KAAK;AAAA,QACL,eAAe;AAAA,QACf,GAAG;AAAA,QACH,UAAU,IAAiB,sBAAsB;AAAA,QACjD,WAAW;AAAA,QACX,WAAW;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,QACJ,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 { 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,OA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,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,14 +1,18 @@
1
1
  import { InsightsMicroWidgetDataContext as e } from "./InsightsMicroWidgetDataProvider.es.js";
2
2
  import r from "react";
3
3
  var s = () => {
4
+ const t = r.useContext(e);
5
+ if (!t) throw new Error("useStore() must be used within the InsightsMicroWidgetDataProvider");
6
+ return t.store;
7
+ }, n = () => {
4
8
  const t = r.useContext(e);
5
9
  if (!t) throw new Error("useCopyStore() must be used within the InsightsMicroWidgetDataProvider");
6
10
  return t.store.copyStore;
7
- }, n = () => {
11
+ }, u = () => {
8
12
  const t = r.useContext(e);
9
13
  if (!t?.store?.insightsMicroWidgetStore) throw new Error("useInsightsMicroWidgetStore() must be used within the InsightsMicroWidgetDataProvider");
10
14
  return t.store.insightsMicroWidgetStore;
11
- }, u = () => {
15
+ }, h = () => {
12
16
  const t = r.useContext(e);
13
17
  if (!t) throw new Error("useEvent() must be used within the InsightsMicroWidgetDataProvider");
14
18
  return { onEvent: t.onEvent };
@@ -18,10 +22,11 @@ var s = () => {
18
22
  return { onPageview: t.onPageview };
19
23
  };
20
24
  export {
21
- s as useCopyStore,
22
- u as useEvent,
23
- n as useInsightsMicroWidgetStore,
24
- g as usePageview
25
+ n as useCopyStore,
26
+ h as useEvent,
27
+ u as useInsightsMicroWidgetStore,
28
+ g as usePageview,
29
+ s as useStore
25
30
  };
26
31
 
27
32
  //# sourceMappingURL=hooks.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.es.js","names":[],"sources":["../../../src/microinsights/context/hooks.tsx"],"sourcesContent":["import React from 'react'\n\nimport { InsightsMicroWidgetDataContext } from './InsightsMicroWidgetDataProvider'\n\nexport const useDataContext = () => {\n const context = React.useContext(InsightsMicroWidgetDataContext)\n\n if (!context) {\n throw new Error('useDataContext() must be used within the InsightsMicroWidgetDataProvider')\n }\n\n return context\n}\n\nexport const useStore = () => {\n const context = React.useContext(InsightsMicroWidgetDataContext)\n\n if (!context) {\n throw new Error('useStore() must be used within the InsightsMicroWidgetDataProvider')\n }\n\n return context.store\n}\n\nexport const useCopyStore = () => {\n const context = React.useContext(InsightsMicroWidgetDataContext)\n\n if (!context) {\n throw new Error('useCopyStore() must be used within the InsightsMicroWidgetDataProvider')\n }\n\n return context.store.copyStore\n}\n\nexport const useInsightsMicroWidgetStore = () => {\n const context = React.useContext(InsightsMicroWidgetDataContext)\n\n if (!context?.store?.insightsMicroWidgetStore) {\n throw new Error(\n 'useInsightsMicroWidgetStore() must be used within the InsightsMicroWidgetDataProvider',\n )\n }\n\n return context.store.insightsMicroWidgetStore\n}\n\nexport const useEvent = () => {\n const context = React.useContext(InsightsMicroWidgetDataContext)\n\n if (!context) {\n throw new Error('useEvent() must be used within the InsightsMicroWidgetDataProvider')\n }\n\n return { onEvent: context.onEvent }\n}\n\nexport const usePageview = () => {\n const context = React.useContext(InsightsMicroWidgetDataContext)\n\n if (!context) {\n throw new Error('usePageview() must be used within the InsightsMicroWidgetDataProvider')\n }\n\n return { onPageview: context.onPageview }\n}\n"],"mappings":";;AAwBA,IAAa,IAAA,MAAqB;AAChC,QAAM,IAAU,EAAM,WAAW,CAA8B;AAE/D,MAAI,CAAC,EACH,OAAM,IAAI,MAAM,wEAAwE;AAG1F,SAAO,EAAQ,MAAM;AACvB,GAEa,IAAA,MAAoC;AAC/C,QAAM,IAAU,EAAM,WAAW,CAA8B;AAE/D,MAAI,CAAC,GAAS,OAAO,yBACnB,OAAM,IAAI,MACR,uFACF;AAGF,SAAO,EAAQ,MAAM;AACvB,GAEa,IAAA,MAAiB;AAC5B,QAAM,IAAU,EAAM,WAAW,CAA8B;AAE/D,MAAI,CAAC,EACH,OAAM,IAAI,MAAM,oEAAoE;AAGtF,SAAO,EAAE,SAAS,EAAQ,QAAQ;AACpC,GAEa,IAAA,MAAoB;AAC/B,QAAM,IAAU,EAAM,WAAW,CAA8B;AAE/D,MAAI,CAAC,EACH,OAAM,IAAI,MAAM,uEAAuE;AAGzF,SAAO,EAAE,YAAY,EAAQ,WAAW;AAC1C"}
1
+ {"version":3,"file":"hooks.es.js","names":[],"sources":["../../../src/microinsights/context/hooks.tsx"],"sourcesContent":["import React from 'react'\n\nimport { InsightsMicroWidgetDataContext } from './InsightsMicroWidgetDataProvider'\n\nexport const useDataContext = () => {\n const context = React.useContext(InsightsMicroWidgetDataContext)\n\n if (!context) {\n throw new Error('useDataContext() must be used within the InsightsMicroWidgetDataProvider')\n }\n\n return context\n}\n\nexport const useStore = () => {\n const context = React.useContext(InsightsMicroWidgetDataContext)\n\n if (!context) {\n throw new Error('useStore() must be used within the InsightsMicroWidgetDataProvider')\n }\n\n return context.store\n}\n\nexport const useCopyStore = () => {\n const context = React.useContext(InsightsMicroWidgetDataContext)\n\n if (!context) {\n throw new Error('useCopyStore() must be used within the InsightsMicroWidgetDataProvider')\n }\n\n return context.store.copyStore\n}\n\nexport const useInsightsMicroWidgetStore = () => {\n const context = React.useContext(InsightsMicroWidgetDataContext)\n\n if (!context?.store?.insightsMicroWidgetStore) {\n throw new Error(\n 'useInsightsMicroWidgetStore() must be used within the InsightsMicroWidgetDataProvider',\n )\n }\n\n return context.store.insightsMicroWidgetStore\n}\n\nexport const useEvent = () => {\n const context = React.useContext(InsightsMicroWidgetDataContext)\n\n if (!context) {\n throw new Error('useEvent() must be used within the InsightsMicroWidgetDataProvider')\n }\n\n return { onEvent: context.onEvent }\n}\n\nexport const usePageview = () => {\n const context = React.useContext(InsightsMicroWidgetDataContext)\n\n if (!context) {\n throw new Error('usePageview() must be used within the InsightsMicroWidgetDataProvider')\n }\n\n return { onPageview: context.onPageview }\n}\n"],"mappings":";;AAcA,IAAa,IAAA,MAAiB;AAC5B,QAAM,IAAU,EAAM,WAAW,CAA8B;AAE/D,MAAI,CAAC,EACH,OAAM,IAAI,MAAM,oEAAoE;AAGtF,SAAO,EAAQ;AACjB,GAEa,IAAA,MAAqB;AAChC,QAAM,IAAU,EAAM,WAAW,CAA8B;AAE/D,MAAI,CAAC,EACH,OAAM,IAAI,MAAM,wEAAwE;AAG1F,SAAO,EAAQ,MAAM;AACvB,GAEa,IAAA,MAAoC;AAC/C,QAAM,IAAU,EAAM,WAAW,CAA8B;AAE/D,MAAI,CAAC,GAAS,OAAO,yBACnB,OAAM,IAAI,MACR,uFACF;AAGF,SAAO,EAAQ,MAAM;AACvB,GAEa,IAAA,MAAiB;AAC5B,QAAM,IAAU,EAAM,WAAW,CAA8B;AAE/D,MAAI,CAAC,EACH,OAAM,IAAI,MAAM,oEAAoE;AAGtF,SAAO,EAAE,SAAS,EAAQ,QAAQ;AACpC,GAEa,IAAA,MAAoB;AAC/B,QAAM,IAAU,EAAM,WAAW,CAA8B;AAE/D,MAAI,CAAC,EACH,OAAM,IAAI,MAAM,uEAAuE;AAGzF,SAAO,EAAE,YAAY,EAAQ,WAAW;AAC1C"}
@@ -1,5 +1,15 @@
1
1
  import { Beat, Offer } from '../core';
2
2
  import { SxProps } from '@mui/material/styles';
3
+ /**
4
+ * What an Insights 2.0 card's in-description CTA does when the card is tapped.
5
+ * - `external` (default): the host decides, through `onCardClick` (pulse posts a message, the money
6
+ * dashboard navigates to the full insights feed).
7
+ * - `internal`: the widget opens the CTA's own action block in place (its `in_description_cta.block`
8
+ * and `variant`), fires its analytics, and does NOT call `onCardClick`.
9
+ * Only a beat that carries a real block on `in_description_cta` opens in place; every other beat
10
+ * (legacy, or no block) keeps the `external` behavior. Needs the host's `GlobalDataProvider`.
11
+ */
12
+ export type InDescriptionCtaBehavior = 'internal' | 'external';
3
13
  export interface MicroWidgetProps {
4
14
  allowSingleCardPeeking?: boolean;
5
15
  areBeatsLoading?: boolean;
@@ -8,6 +18,7 @@ export interface MicroWidgetProps {
8
18
  endpoint?: string;
9
19
  headerSx?: SxProps;
10
20
  heightOverrides?: number | string;
21
+ inDescriptionCtaBehavior?: InDescriptionCtaBehavior;
11
22
  logOutUser?: () => void;
12
23
  onCardClick?: (beat?: Beat | undefined) => void;
13
24
  onEvent?: (event?: string | undefined) => void;
@@ -26,6 +37,7 @@ export interface MicroInsightCardProps {
26
37
  ariaLabel?: string;
27
38
  elevation?: number;
28
39
  heightOverrides?: number | string;
40
+ inDescriptionCtaBehavior?: InDescriptionCtaBehavior;
29
41
  isActiveCard?: boolean;
30
42
  onCardClick?: (beat?: Beat | undefined) => void;
31
43
  posthog?: TheWholeHog;