@mx-cartographer/experiences 9.7.40 → 9.7.42

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 (35) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/core/types/InsightsInstanceSlotData.d.ts +6 -1
  3. package/dist/core/types/InsightsInstanceSlotData.es.js.map +1 -1
  4. package/dist/core/types/localization/InsightsFeedCopy.d.ts +2 -0
  5. package/dist/insights-v2/actionBlocks/ConnectWidgetActionBlock.es.js +20 -14
  6. package/dist/insights-v2/actionBlocks/ConnectWidgetActionBlock.es.js.map +1 -1
  7. package/dist/insights-v2/actionBlocks/FeedbackModalActionBlock.d.ts +4 -4
  8. package/dist/insights-v2/actionBlocks/FeedbackModalActionBlock.es.js +45 -31
  9. package/dist/insights-v2/actionBlocks/FeedbackModalActionBlock.es.js.map +1 -1
  10. package/dist/insights-v2/analytics/analyticsEventsConfig.d.ts +6 -0
  11. package/dist/insights-v2/analytics/analyticsEventsConfig.es.js +4 -0
  12. package/dist/insights-v2/analytics/analyticsEventsConfig.es.js.map +1 -1
  13. package/dist/insights-v2/analytics/resolveAnalyticsEvent.es.js +7 -6
  14. package/dist/insights-v2/analytics/resolveAnalyticsEvent.es.js.map +1 -1
  15. package/dist/insights-v2/beatActions.d.ts +7 -2
  16. package/dist/insights-v2/beatActions.es.js.map +1 -1
  17. package/dist/insights-v2/blocks/ComponentBlocks/AccountSwitchBlock/AccountSwitchBlock.d.ts +5 -2
  18. package/dist/insights-v2/blocks/ComponentBlocks/AccountSwitchBlock/AccountSwitchBlock.es.js +21 -23
  19. package/dist/insights-v2/blocks/ComponentBlocks/AccountSwitchBlock/AccountSwitchBlock.es.js.map +1 -1
  20. package/dist/insights-v2/blocks/ComponentBlocks/DetailedAccountBlock/DetailedAccountBlock.es.js +29 -20
  21. package/dist/insights-v2/blocks/ComponentBlocks/DetailedAccountBlock/DetailedAccountBlock.es.js.map +1 -1
  22. package/dist/insights-v2/blocks/ComponentBlocks/DetailedAccountBlock/layout.es.js +27 -24
  23. package/dist/insights-v2/blocks/ComponentBlocks/DetailedAccountBlock/layout.es.js.map +1 -1
  24. package/dist/insights-v2/components/BaseLayout.es.js +1 -1
  25. package/dist/insights-v2/components/BaseLayout.es.js.map +1 -1
  26. package/dist/insights-v2/components/CompactInsightCard.es.js +148 -82
  27. package/dist/insights-v2/components/CompactInsightCard.es.js.map +1 -1
  28. package/dist/insights-v2/components/FeedbackModal.d.ts +5 -1
  29. package/dist/insights-v2/components/FeedbackModal.es.js +29 -28
  30. package/dist/insights-v2/components/FeedbackModal.es.js.map +1 -1
  31. package/dist/insights-v2/hooks/useBeatFeedbackFlow.es.js +27 -25
  32. package/dist/insights-v2/hooks/useBeatFeedbackFlow.es.js.map +1 -1
  33. package/dist/microinsights/beatActions.es.js +4 -4
  34. package/dist/microinsights/beatActions.es.js.map +1 -1
  35. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"CompactInsightCard.es.js","names":[],"sources":["../../../src/insights-v2/components/CompactInsightCard.tsx"],"sourcesContent":["import type { KeyboardEvent, MouseEvent } from 'react'\n\nimport Box from '@mui/material/Box'\nimport Button from '@mui/material/Button'\nimport Card from '@mui/material/Card'\nimport Stack from '@mui/material/Stack'\n\nimport { Icon } from '@mxenabled/mx-icons'\nimport { P, Text } from '@mxenabled/mxui'\n\nimport { useInsightsV2Store } from '../../common'\nimport { TinyBarChart } from '../../common/components/TinyBarChart'\nimport { slot } from '../../core'\nimport type {\n Beat,\n DataSeries,\n InsightsPayload,\n InstanceSlotData,\n LogoRef,\n PrimaryCTA,\n} from '../../core'\nimport type { ActionDrawerTrigger } from '../../core/stores'\nimport { getCategoryColor } from '../../core/utils/CategoryUtil'\nimport {\n BAR_ARIA_LABEL,\n buildChartData,\n buildDataSeries,\n} from '../blocks/ChartBlocks/BarchartBlock/utils'\nimport { ActionBlockLayer } from '../actionBlocks/ActionBlockLayer'\nimport { createVariantBlock } from '../blocks/createVariantBlock'\nimport BadgedTile from './BadgedTile'\nimport InsightOptionsMenu from './InsightOptionsMenu'\nimport LogoFromGuid from './LogoFromGuid'\nimport { ReactComponent as FeeDetectedIllustration } from './shared/images/FeeDetected.svg'\nimport { ThemedSVGImage } from './chartblocks/ThemedSVGImage'\nimport StatusBadge from './StatusBadge'\n\n/** Figma 1941:111897: the tile the logo fills is 44px (rows are 32, the notification row 33). */\nconst ICON_SIZE = 44\n\ninterface InsightVisualProps {\n /** The slot's `logo`, when ditto's variant declares and fills one. */\n logo?: LogoRef | null\n /** The slot's `data`, for a visual drawn from more than the logo (`category_color`'s bars). */\n data?: InstanceSlotData\n}\n\n/** Figma 222:33404 (Embedded | Bill Amount Not Standard) shows the latest three bars. */\nconst BAR_CHART_BAR_COUNT = 3\n\n/** The slot's logo, or the neutral insight glyph when the slot carries none. */\nconst LogoOrFallback = ({ logo }: InsightVisualProps) =>\n logo ? (\n <LogoFromGuid logo={logo} size={ICON_SIZE} />\n ) : (\n <Box\n data-testid=\"compact-insight-card-fallback-icon\"\n sx={{\n alignItems: 'center',\n bgcolor: 'primary.lighter',\n display: 'flex',\n height: ICON_SIZE,\n justifyContent: 'center',\n width: ICON_SIZE,\n }}\n >\n <Icon color=\"primary\" fill={true} name=\"lightbulb\" size={24} />\n </Box>\n )\n\n/** Micro, and any variant not registered below: the logo alone. */\nconst PlainVisual = ({ logo }: InsightVisualProps) => (\n <BadgedTile center={<LogoOrFallback logo={logo} />} size={ICON_SIZE} sx={{ flexShrink: 0 }} />\n)\n\n/** ditto `with_warning_badge`: the logo badged with a status glyph (Figma 1941:111897). */\nconst WarningBadgeVisual = ({ logo }: InsightVisualProps) => (\n <BadgedTile\n center={<LogoOrFallback logo={logo} />}\n size={ICON_SIZE}\n sx={{ flexShrink: 0 }}\n topRight={<StatusBadge tone=\"warning\" />}\n />\n)\n\n/**\n * ditto `with_illustration`: artwork in place of the logo tile (Fee Detected's search illustration).\n * A single SVG themed at runtime by `ThemedSVGImage`: its `brand300` elements are recolored to the\n * theme's `primary.main` (so it follows dark mode), while `fill=\"white\"` areas stay white. The\n * slot's `logo` is deliberately unused: the illustration replaces the tile.\n */\nconst IllustrationVisual = () => {\n return (\n <ThemedSVGImage\n divProps={{ style: { flexShrink: 0, lineHeight: 0, width: 'max-content' } }}\n image={FeeDetectedIllustration}\n />\n )\n}\n\n/**\n * ditto `category_color`: a tiny bar chart of the latest bars in place of the logo tile, tinted by\n * the slot's category, the newest bar solid (Figma 222:33404). Draws nothing without a series.\n */\nconst BarChartVisual = ({ data }: InsightVisualProps) => {\n const series = buildDataSeries(slot<DataSeries>(data, 'series'))\n if (!series.length) return null\n\n const categoryGuid = slot<string>(data, 'category_guid')\n const bars = buildChartData(series, BAR_ARIA_LABEL).slice(-BAR_CHART_BAR_COUNT)\n\n return (\n <Box data-testid=\"compact-insight-card-bar-chart\" sx={{ flexShrink: 0 }}>\n <TinyBarChart\n color={(theme) =>\n categoryGuid ? getCategoryColor(categoryGuid, theme) : theme.palette.primary.main\n }\n data={bars}\n />\n </Box>\n )\n}\n\n/**\n * The card's right-hand visual, one component per ditto layout variant.\n *\n * A variant names a rendering *shape*, not an insight or a surface — `with_header` already serves\n * both Large Transaction and Fee Detected — so an insight wanting the badged logo reuses\n * `with_warning_badge`. Only a genuinely different visual registers a new entry, and existing ones\n * are never touched.\n *\n * `minimal` draws the plain logo and is registered explicitly even though it matches the fallback:\n * micro and notification resolve it on every render, and an unregistered variant warns. The\n * fallback is for variants we genuinely do not know.\n */\nconst InsightVisual = createVariantBlock<InsightVisualProps>({\n variants: {\n category_color: BarChartVisual,\n minimal: PlainVisual,\n with_illustration: IllustrationVisual,\n with_warning_badge: WarningBadgeVisual,\n },\n fallback: PlainVisual,\n name: 'InsightVisual',\n})\n\n/**\n * Beats whose embedded CTA the card reads from its own envelope key and opens in this card's\n * `ActionBlockLayer`, as a bar click does on the full card. The trigger names that key, so the layer\n * resolves the same CTA. Every other beat keeps `primary_cta` and hands it to the host's `onCtaClick`\n * (e.g. `contact_support_block`). A new beat adds its template here.\n */\nconst BEAT_CTA_CONFIG: Record<\n string,\n { key: 'primary_cta' | 'in_description_cta'; trigger: ActionDrawerTrigger }\n> = {\n BillAmountNotStandard: { key: 'in_description_cta', trigger: 'inDescriptionCta' },\n}\n\nexport interface CompactInsightCardProps {\n /** A `micro` or `embedded` envelope. */\n payload: InsightsPayload\n /** The envelope's beat; when given, the card mounts its `ActionBlockLayer` for CTA drawers. */\n beat?: Beat\n /**\n * Makes the whole card the tap target. What a tap does is the host's decision (post to the\n * host app, open a drawer, …); the card never opens anything itself. Omit for a static card.\n */\n onTap?: () => void\n /** Receives the primary CTA when tapped. The card does not resolve the CTA's block itself. */\n onCtaClick?: (cta: PrimaryCTA) => void\n /**\n * Renders the CTA disabled — label shown, `aria-disabled`, not tappable — for a host that cannot\n * honour it (e.g. `contact_support_block` when the client's `enable_support_requests` is off).\n */\n isCtaDisabled?: boolean\n}\n\nconst stopPropagation = (event: MouseEvent) => event.stopPropagation()\n\n/**\n * The one compact renderer the micro and embedded envelopes share (`insights_v2.2.md` §8.3).\n *\n * Figma 1941:111897 (Embedded | Large Transaction): a title row with the overflow slot, the HTML\n * description with the primary CTA under it, and on the right the slot's `logo` in a\n * `<BadgedTile>`. Under ditto's `with_warning_badge` variant the tile takes a status badge; under\n * `minimal` it draws the logo alone. The card lays out from the envelope alone and never reads\n * `widget_type`.\n *\n * The icon falls back to the neutral insight glyph **here**, not in `LogoFromGuid`, when the slot\n * carries no logo. The `pill` on the same envelope is the transaction row's, not the card's.\n */\nconst CompactInsightCard = ({\n beat,\n isCtaDisabled = false,\n onCtaClick,\n onTap,\n payload,\n}: CompactInsightCardProps) => {\n const { openActionDrawer } = useInsightsV2Store()\n const { description, instance_slot, primary_cta, title } = payload\n const beatCta = BEAT_CTA_CONFIG[payload.template ?? '']\n const cta = beatCta ? payload[beatCta.key] : primary_cta\n // Reduced variants (`minimal`, `with_warning_badge`) declare a bare `logo` slot.\n const rowLogo = slot<LogoRef>(instance_slot.data, 'logo')\n\n const handleCtaClick = (event: MouseEvent<HTMLButtonElement>) => {\n event.stopPropagation()\n if (isCtaDisabled || !cta) return\n\n if (beatCta) {\n if (beat) openActionDrawer({ guid: beat.guid, trigger: beatCta.trigger })\n return\n }\n if (primary_cta) onCtaClick?.(primary_cta)\n }\n\n const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n // Only the card itself: Enter on the CTA button is the button's own click.\n if (event.target !== event.currentTarget) return\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault()\n onTap?.()\n }\n }\n\n const interactiveProps = onTap\n ? { onClick: onTap, onKeyDown: handleKeyDown, role: 'button', tabIndex: 0 }\n : {}\n\n return (\n <>\n <Card\n data-testid=\"compact-insight-card\"\n {...interactiveProps}\n sx={{\n minWidth: 288,\n pb: 12,\n pl: 8,\n pr: 16,\n pt: 8,\n ...(onTap && { cursor: 'pointer' }),\n }}\n >\n <Stack\n sx={{\n alignItems: 'center',\n flexDirection: 'row',\n gap: 8,\n justifyContent: 'space-between',\n pl: 8,\n pt: 4,\n }}\n >\n <Text bold={true} variant=\"body1\">\n {title ?? ''}\n </Text>\n {/* The menu renders only when the host wired `onMenuAction` (BeatActionsProvider). */}\n <Box onClick={stopPropagation} sx={{ display: 'flex' }}>\n <InsightOptionsMenu />\n </Box>\n </Stack>\n\n <Stack sx={{ flexDirection: 'row', gap: 16, pl: 8, pt: 4 }}>\n <Stack sx={{ flex: 1, gap: 8, minWidth: 0 }}>\n {/* `html_text` is rendered server-side by mrs_content from the ditto copy template (bold\n amount / merchant), not user-authored input; painted the same way `BaseLayout` paints\n the full card's description. */}\n <P\n dangerouslySetInnerHTML={{ __html: description.html_text }}\n data-testid=\"compact-insight-card-description\"\n variant=\"subtitle2\"\n />\n {cta?.label && (\n <Button\n aria-disabled={isCtaDisabled}\n onClick={handleCtaClick}\n size=\"small\"\n sx={{\n alignSelf: 'flex-start',\n // Figma 1941:111897 lines the CTA label up with the description's left edge. The\n // column already pads 8, so the button's own 8 is pulled back out — padding kept so\n // the tap target does not shrink.\n mt: 5,\n ml: -8,\n px: 8,\n ...(isCtaDisabled && {\n color: 'text.disabled',\n cursor: 'default',\n }),\n }}\n variant=\"text\"\n >\n {cta.label}\n </Button>\n )}\n </Stack>\n\n <InsightVisual data={instance_slot.data} logo={rowLogo} variant={instance_slot.variant} />\n </Stack>\n </Card>\n {/* Outside the Card: the drawer is a portal, and its clicks would otherwise bubble to `onTap`. */}\n {beat && <ActionBlockLayer beat={beat} />}\n </>\n )\n}\n\nexport default CompactInsightCard\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAsCA,IAAM,IAAY,IAaZ,IAAA,CAAkB,EAAE,MAAA,EAAA,MACxB,IACE,gBAAA,EAAC,GAAD;AAAA,EAAoB,MAAA;AAAA,EAAM,MAAM;AAAY,CAAA,IAE5C,gBAAA,EAAC,GAAD;AAAA,EACE,eAAY;AAAA,EACZ,IAAI;AAAA,IACF,YAAY;AAAA,IACZ,SAAS;AAAA,IACT,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,gBAAgB;AAAA,IAChB,OAAO;AAAA,EACT;AAAA,EAEA,UAAA,gBAAA,EAAC,GAAD;AAAA,IAAM,OAAM;AAAA,IAAU,MAAM;AAAA,IAAM,MAAK;AAAA,IAAY,MAAM;AAAA,EAAK,CAAA;AAC3D,CAAA,GAIH,IAAA,CAAe,EAAE,MAAA,EAAA,MACrB,gBAAA,EAAC,GAAD;AAAA,EAAY,QAAQ,gBAAA,EAAC,GAAD,EAAsB,MAAA,EAAO,CAAA;AAAA,EAAG,MAAM;AAAA,EAAW,IAAI,EAAE,YAAY,EAAE;AAAI,CAAA,GAIzF,IAAA,CAAsB,EAAE,MAAA,EAAA,MAC5B,gBAAA,EAAC,GAAD;AAAA,EACE,QAAQ,gBAAA,EAAC,GAAD,EAAsB,MAAA,EAAO,CAAA;AAAA,EACrC,MAAM;AAAA,EACN,IAAI,EAAE,YAAY,EAAE;AAAA,EACpB,UAAU,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OAAO;AAAA,QACnD,UAAA,gBAAA,EAAC,GAAD,CAAqB,CAAA;AAAA,MAClB,CAAA,CACA;AAAA,IAEP,CAAA,GAAA,gBAAA,EAAC,GAAD;AAAA,MAAO,IAAI;AAAA,QAAE,eAAe;AAAA,QAAO,KAAK;AAAA,QAAI,IAAI;AAAA,QAAG,IAAI;AAAA,MAAE;AAAA,MAAzD,UAAA,CACE,gBAAA,EAAC,GAAD;AAAA,QAAO,IAAI;AAAA,UAAE,MAAM;AAAA,UAAG,KAAK;AAAA,UAAG,UAAU;AAAA,QAAE;AAAA,QAA1C,UAAA,CAIE,gBAAA,EAAC,GAAD;AAAA,UACE,yBAAyB,EAAE,QAAQ,EAAY,UAAU;AAAA,UACzD,eAAY;AAAA,UACZ,SAAQ;AAAA,QACT,CAAA,GACA,GAAK,SACJ,gBAAA,EAAC,GAAD;AAAA,UACE,iBAAe;AAAA,UACf,SAAS;AAAA,UACT,MAAK;AAAA,UACL,IAAI;AAAA,YACF,WAAW;AAAA,YAIX,IAAI;AAAA,YACJ,IAAI;AAAA,YACJ,IAAI;AAAA,YACJ,GAAI,KAAiB;AAAA,cACnB,OAAO;AAAA,cACP,QAAQ;AAAA,YACV;AAAA,UACF;AAAA,UACA,SAAQ;AAAA,UAEP,UAAA,EAAI;AAAA,QACC,CAAA,CAEL;AAAA,MAEP,CAAA,GAAA,gBAAA,EAAC,GAAD;AAAA,QAAe,MAAM,EAAc;AAAA,QAAM,MAAM;AAAA,QAAS,SAAS,EAAc;AAAA,MAAU,CAAA,CACpF;AAAA,IACH,CAAA,CAAA;AAAA,EAEL,CAAA,GAAA,KAAQ,gBAAA,EAAC,GAAD,EAAwB,MAAA,EAAO,CAAA,CACxC,EAAA,CAAA;AAEN"}
1
+ {"version":3,"file":"CompactInsightCard.es.js","names":[],"sources":["../../../src/insights-v2/components/CompactInsightCard.tsx"],"sourcesContent":["import type { KeyboardEvent, MouseEvent } from 'react'\n\nimport Box from '@mui/material/Box'\nimport Button from '@mui/material/Button'\nimport Card from '@mui/material/Card'\nimport Stack from '@mui/material/Stack'\n\nimport { Icon } from '@mxenabled/mx-icons'\nimport { P, Text } from '@mxenabled/mxui'\n\nimport { useInsightsV2Store } from '../../common'\nimport { TinyBarChart } from '../../common/components/TinyBarChart'\nimport { slot } from '../../core'\nimport type {\n Beat,\n DataSeries,\n InsightsPayload,\n InstanceSlotData,\n LogoRef,\n PrimaryCTA,\n} from '../../core'\nimport type { ActionDrawerTrigger } from '../../core/stores'\nimport type { AccountSwitchBlockV2Data } from '../../core/types/InsightsInstanceSlotData'\nimport { getCategoryColor } from '../../core/utils/CategoryUtil'\nimport {\n BAR_ARIA_LABEL,\n buildChartData,\n buildDataSeries,\n} from '../blocks/ChartBlocks/BarchartBlock/utils'\nimport { ActionBlockLayer } from '../actionBlocks/ActionBlockLayer'\nimport { createVariantBlock } from '../blocks/createVariantBlock'\nimport BadgedTile from './BadgedTile'\nimport InsightOptionsMenu from './InsightOptionsMenu'\nimport LogoFromGuid from './LogoFromGuid'\nimport { ReactComponent as FeeDetectedIllustration } from './shared/images/FeeDetected.svg'\nimport { ThemedSVGImage } from './chartblocks/ThemedSVGImage'\nimport StatusBadge from './StatusBadge'\n\n/** Figma 1941:111897: the tile the logo fills is 44px (rows are 32, the notification row 33). */\nconst ICON_SIZE = 44\n\ninterface InsightVisualProps {\n /** The slot's `logo`, when ditto's variant declares and fills one. */\n logo?: LogoRef | null\n /** The slot's whole `data`, for a visual drawn from more than the logo (`category_color`, `linked_logos`). */\n data?: InstanceSlotData\n}\n\nconst LINKED_LOGO_SIZE = 32\n\n/** Figma 222:33404 (Embedded | Bill Amount Not Standard) shows the latest three bars. */\nconst BAR_CHART_BAR_COUNT = 3\n\n/** The slot's logo, or the neutral insight glyph when the slot carries none. */\nconst LogoOrFallback = ({ logo }: InsightVisualProps) =>\n logo ? (\n <LogoFromGuid logo={logo} size={ICON_SIZE} />\n ) : (\n <Box\n data-testid=\"compact-insight-card-fallback-icon\"\n sx={{\n alignItems: 'center',\n bgcolor: 'primary.lighter',\n display: 'flex',\n height: ICON_SIZE,\n justifyContent: 'center',\n width: ICON_SIZE,\n }}\n >\n <Icon color=\"primary\" fill={true} name=\"lightbulb\" size={24} />\n </Box>\n )\n\n/** Micro, and any variant not registered below: the logo alone. */\nconst PlainVisual = ({ logo }: InsightVisualProps) => (\n <BadgedTile center={<LogoOrFallback logo={logo} />} size={ICON_SIZE} sx={{ flexShrink: 0 }} />\n)\n\n/** ditto `with_warning_badge`: the logo badged with a status glyph (Figma 1941:111897). */\nconst WarningBadgeVisual = ({ logo }: InsightVisualProps) => (\n <BadgedTile\n center={<LogoOrFallback logo={logo} />}\n size={ICON_SIZE}\n sx={{ flexShrink: 0 }}\n topRight={<StatusBadge tone=\"warning\" />}\n />\n)\n\n/**\n * ditto `with_illustration`: artwork in place of the logo tile (Fee Detected's search illustration).\n * A single SVG themed at runtime by `ThemedSVGImage`: its `brand300` elements are recolored to the\n * theme's `primary.main` (so it follows dark mode), while `fill=\"white\"` areas stay white. The\n * slot's `logo` is deliberately unused: the illustration replaces the tile.\n */\nconst IllustrationVisual = () => {\n return (\n <ThemedSVGImage\n divProps={{ style: { flexShrink: 0, lineHeight: 0, width: 'max-content' } }}\n image={FeeDetectedIllustration}\n />\n )\n}\n\n/**\n * ditto `linked_logos` (Figma 1943:219166, Embedded | Discovered Accounts): the two institutions\n * overlapping on a diagonal — `from_logo` top-left, `to_logo` bottom-right — with a link badge where\n * they meet. The badge is decorative (`aria-hidden`); each logo's accessible name is its `alt`.\n */\nconst LinkedLogosVisual = ({ data }: InsightVisualProps) => {\n const { from_logo, to_logo } = (data ?? {}) as AccountSwitchBlockV2Data\n\n return (\n <Box sx={{ flexShrink: 0, height: 64, position: 'relative', width: 64 }}>\n <Box sx={{ borderRadius: '6px', left: 0, overflow: 'hidden', position: 'absolute', top: 0 }}>\n <LogoFromGuid logo={from_logo} size={LINKED_LOGO_SIZE} />\n </Box>\n <Box\n aria-hidden={true}\n sx={{\n alignItems: 'center',\n bgcolor: 'text.secondary',\n borderRadius: '50%',\n display: 'flex',\n height: 20,\n justifyContent: 'center',\n left: 22,\n position: 'absolute',\n top: 22,\n width: 20,\n zIndex: 1,\n }}\n >\n <Icon name=\"link\" size={14} sx={{ color: 'primary.contrastText' }} />\n </Box>\n <Box\n sx={{ borderRadius: '6px', bottom: 0, overflow: 'hidden', position: 'absolute', right: 0 }}\n >\n <LogoFromGuid logo={to_logo} size={LINKED_LOGO_SIZE} />\n </Box>\n </Box>\n )\n}\n\n/**\n * ditto `category_color`: a tiny bar chart of the latest bars in place of the logo tile, tinted by\n * the slot's category, the newest bar solid (Figma 222:33404). Draws nothing without a series.\n */\nconst BarChartVisual = ({ data }: InsightVisualProps) => {\n const series = buildDataSeries(slot<DataSeries>(data, 'series'))\n if (!series.length) return null\n\n const categoryGuid = slot<string>(data, 'category_guid')\n const bars = buildChartData(series, BAR_ARIA_LABEL).slice(-BAR_CHART_BAR_COUNT)\n\n return (\n <Box data-testid=\"compact-insight-card-bar-chart\" sx={{ flexShrink: 0 }}>\n <TinyBarChart\n color={(theme) =>\n categoryGuid ? getCategoryColor(categoryGuid, theme) : theme.palette.primary.main\n }\n data={bars}\n />\n </Box>\n )\n}\n\n/**\n * The card's right-hand visual, one component per ditto layout variant.\n *\n * A variant names a rendering *shape*, not an insight or a surface — `with_header` already serves\n * both Large Transaction and Fee Detected — so an insight wanting the badged logo reuses\n * `with_warning_badge`. Only a genuinely different visual registers a new entry, and existing ones\n * are never touched.\n *\n * `minimal` draws the plain logo and is registered explicitly even though it matches the fallback:\n * micro and notification resolve it on every render, and an unregistered variant warns. The\n * fallback is for variants we genuinely do not know.\n */\nconst InsightVisual = createVariantBlock<InsightVisualProps>({\n variants: {\n category_color: BarChartVisual,\n linked_logos: LinkedLogosVisual,\n minimal: PlainVisual,\n with_illustration: IllustrationVisual,\n with_warning_badge: WarningBadgeVisual,\n },\n fallback: PlainVisual,\n name: 'InsightVisual',\n})\n\n/**\n * Beats whose embedded CTA the card reads from its own envelope key and opens in this card's\n * `ActionBlockLayer`, as a bar click does on the full card. The trigger names that key, so the layer\n * resolves the same CTA. Every other beat keeps `primary_cta` and hands it to the host's `onCtaClick`\n * (e.g. `contact_support_block`). A new beat adds its template here.\n */\nconst BEAT_CTA_CONFIG: Record<\n string,\n { key: 'primary_cta' | 'in_description_cta'; trigger: ActionDrawerTrigger }\n> = {\n BillAmountNotStandard: { key: 'in_description_cta', trigger: 'inDescriptionCta' },\n ConnectDiscoveredAccountsV2: { key: 'in_description_cta', trigger: 'inDescriptionCta' },\n}\n\nexport interface CompactInsightCardProps {\n /** A `micro` or `embedded` envelope. */\n payload: InsightsPayload\n /** The envelope's beat; when given, the card mounts its `ActionBlockLayer` for CTA drawers. */\n beat?: Beat\n /**\n * Makes the whole card the tap target. What a tap does is the host's decision (post to the\n * host app, open a drawer, …); the card never opens anything itself. Omit for a static card.\n */\n onTap?: () => void\n /** Receives the primary CTA when tapped. The card does not resolve the CTA's block itself. */\n onCtaClick?: (cta: PrimaryCTA) => void\n /**\n * Renders the CTA disabled — label shown, `aria-disabled`, not tappable — for a host that cannot\n * honour it (e.g. `contact_support_block` when the client's `enable_support_requests` is off).\n */\n isCtaDisabled?: boolean\n}\n\nconst stopPropagation = (event: MouseEvent) => event.stopPropagation()\n\n/**\n * The one compact renderer the micro and embedded envelopes share (`insights_v2.2.md` §8.3).\n *\n * Figma 1941:111897 (Embedded | Large Transaction): a title row with the overflow slot, the HTML\n * description with the primary CTA under it, and on the right the slot's `logo` in a\n * `<BadgedTile>`. Under ditto's `with_warning_badge` variant the tile takes a status badge; under\n * `minimal` it draws the logo alone. The card lays out from the envelope alone and never reads\n * `widget_type`.\n *\n * The icon falls back to the neutral insight glyph **here**, not in `LogoFromGuid`, when the slot\n * carries no logo. The `pill` on the same envelope is the transaction row's, not the card's.\n */\nconst CompactInsightCard = ({\n beat,\n isCtaDisabled = false,\n onCtaClick,\n onTap,\n payload,\n}: CompactInsightCardProps) => {\n const { openActionDrawer } = useInsightsV2Store()\n const { description, instance_slot, primary_cta, title } = payload\n const beatCta = BEAT_CTA_CONFIG[payload.template ?? '']\n const cta = beatCta ? payload[beatCta.key] : primary_cta\n // Reduced variants (`minimal`, `with_warning_badge`) declare a bare `logo` slot.\n const rowLogo = slot<LogoRef>(instance_slot.data, 'logo')\n\n const handleCtaClick = (event: MouseEvent<HTMLButtonElement>) => {\n event.stopPropagation()\n if (isCtaDisabled || !cta) return\n\n if (beatCta) {\n if (beat) openActionDrawer({ guid: beat.guid, trigger: beatCta.trigger })\n return\n }\n if (primary_cta) onCtaClick?.(primary_cta)\n }\n\n const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n // Only the card itself: Enter on the CTA button is the button's own click.\n if (event.target !== event.currentTarget) return\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault()\n onTap?.()\n }\n }\n\n const interactiveProps = onTap\n ? { onClick: onTap, onKeyDown: handleKeyDown, role: 'button', tabIndex: 0 }\n : {}\n\n return (\n <>\n <Card\n data-testid=\"compact-insight-card\"\n {...interactiveProps}\n sx={{\n minWidth: 288,\n pb: 12,\n pl: 8,\n pr: 16,\n pt: 8,\n ...(onTap && { cursor: 'pointer' }),\n }}\n >\n <Stack\n sx={{\n alignItems: 'center',\n flexDirection: 'row',\n gap: 8,\n justifyContent: 'space-between',\n pl: 8,\n pt: 4,\n }}\n >\n <Text bold={true} variant=\"body1\">\n {title ?? ''}\n </Text>\n {/* The menu renders only when the host wired `onMenuAction` (BeatActionsProvider). */}\n <Box onClick={stopPropagation} sx={{ display: 'flex' }}>\n <InsightOptionsMenu />\n </Box>\n </Stack>\n\n <Stack sx={{ flexDirection: 'row', gap: 16, pl: 8, pt: 4 }}>\n <Stack sx={{ flex: 1, gap: 8, minWidth: 0 }}>\n {/* `html_text` is rendered server-side by mrs_content from the ditto copy template (bold\n amount / merchant), not user-authored input; painted the same way `BaseLayout` paints\n the full card's description. */}\n <P\n dangerouslySetInnerHTML={{ __html: description.html_text }}\n data-testid=\"compact-insight-card-description\"\n variant=\"subtitle2\"\n />\n {cta?.label && (\n <Button\n aria-disabled={isCtaDisabled}\n onClick={handleCtaClick}\n size=\"small\"\n sx={{\n alignSelf: 'flex-start',\n // Figma 1941:111897 lines the CTA label up with the description's left edge. The\n // column already pads 8, so the button's own 8 is pulled back out — padding kept so\n // the tap target does not shrink.\n mt: 5,\n ml: -8,\n px: 8,\n ...(isCtaDisabled && {\n color: 'text.disabled',\n cursor: 'default',\n }),\n }}\n variant=\"text\"\n >\n {cta.label}\n </Button>\n )}\n </Stack>\n\n <InsightVisual data={instance_slot.data} logo={rowLogo} variant={instance_slot.variant} />\n </Stack>\n </Card>\n {/* Outside the Card: the drawer is a portal, and its clicks would otherwise bubble to `onTap`. */}\n {beat && <ActionBlockLayer beat={beat} />}\n </>\n )\n}\n\nexport default CompactInsightCard\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuCA,IAAM,IAAY,IASZ,IAAmB,IAMnB,IAAA,CAAkB,EAAE,MAAA,EAAA,MACxB,IACE,gBAAA,EAAC,GAAD;AAAA,EAAoB,MAAA;AAAA,EAAM,MAAM;AAAY,CAAA,IAE5C,gBAAA,EAAC,GAAD;AAAA,EACE,eAAY;AAAA,EACZ,IAAI;AAAA,IACF,YAAY;AAAA,IACZ,SAAS;AAAA,IACT,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,gBAAgB;AAAA,IAChB,OAAO;AAAA,EACT;AAAA,EAEA,UAAA,gBAAA,EAAC,GAAD;AAAA,IAAM,OAAM;AAAA,IAAU,MAAM;AAAA,IAAM,MAAK;AAAA,IAAY,MAAM;AAAA,EAAK,CAAA;AAC3D,CAAA,GAIH,IAAA,CAAe,EAAE,MAAA,EAAA,MACrB,gBAAA,EAAC,GAAD;AAAA,EAAY,QAAQ,gBAAA,EAAC,GAAD,EAAsB,MAAA,EAAO,CAAA;AAAA,EAAG,MAAM;AAAA,EAAW,IAAI,EAAE,YAAY,EAAE;AAAI,CAAA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A,CACpF;AAAA,IACH,CAAA,CAAA;AAAA,EAEL,CAAA,GAAA,KAAQ,gBAAA,EAAC,GAAD,EAAwB,MAAA,EAAO,CAAA,CACxC,EAAA,CAAA;AAEN"}
@@ -45,6 +45,10 @@ interface FeedbackModalProps {
45
45
  * step). When absent, the secondary ("No thanks") ends the flow as before.
46
46
  */
47
47
  onBack?: () => void;
48
+ /** First focus of the free-text box (analytics). */
49
+ onTextInputFocus?: () => void;
50
+ /** Default true. When false a successful submit calls `onClose` (the host confirms); errors still show. */
51
+ showSuccessMessage?: boolean;
48
52
  }
49
53
  /**
50
54
  * The CTA feedback drilldown (Figma `1941:192803`): a "Can you tell us why?"
@@ -56,5 +60,5 @@ interface FeedbackModalProps {
56
60
  * the `feedback_modal_block` action block wires it to the copy store, the beat
57
61
  * actions, and the action-drawer session.
58
62
  */
59
- declare const FeedbackModal: ({ copy, isOpen, onBack, onClose, onSubmit }: FeedbackModalProps) => import("react/jsx-runtime").JSX.Element;
63
+ declare const FeedbackModal: ({ copy, isOpen, onBack, onClose, onSubmit, onTextInputFocus, showSuccessMessage, }: FeedbackModalProps) => import("react/jsx-runtime").JSX.Element;
60
64
  export default FeedbackModal;
@@ -1,61 +1,62 @@
1
- import g from "./shared/StatusSnackbar.es.js";
2
- import k from "./FeedbackDialog.es.js";
3
- import { useEffect as L, useRef as u, useState as T } from "react";
4
- import { Fragment as A, jsx as b, jsxs as S } from "react/jsx-runtime";
5
- var D = ({ copy: e, isOpen: a, onBack: l, onClose: m, onSubmit: d }) => {
6
- const [t, i] = T("survey"), n = u(!1), s = u(null);
7
- L(() => {
8
- a && (i("survey"), n.current = !1, s.current = null);
1
+ import L from "./shared/StatusSnackbar.es.js";
2
+ import T from "./FeedbackDialog.es.js";
3
+ import { useEffect as A, useRef as l, useState as S } from "react";
4
+ import { Fragment as C, jsx as b, jsxs as F } from "react/jsx-runtime";
5
+ var y = ({ copy: e, isOpen: a, onBack: m, onClose: c, onSubmit: d, onTextInputFocus: h, showSuccessMessage: v = !0 }) => {
6
+ const [t, o] = S("survey"), n = l(!1), s = l(null);
7
+ A(() => {
8
+ a && (o("survey"), n.current = !1, s.current = null);
9
9
  }, [a]);
10
- const f = async (r, c) => {
10
+ const f = async (r, i) => {
11
11
  n.current = !0, s.current = {
12
12
  option: r,
13
- detail: c
13
+ detail: i
14
14
  };
15
15
  try {
16
- await d(r, c), i("success");
16
+ await d(r, i), v ? o("success") : c();
17
17
  } catch {
18
- i("error");
18
+ o("error");
19
19
  }
20
- }, h = () => {
20
+ }, x = () => {
21
21
  s.current && f(s.current.option, s.current.detail);
22
- }, o = u(!1), v = l ? () => {
23
- o.current = !0, l();
24
- } : void 0, x = (r) => {
22
+ }, u = l(!1), g = m ? () => {
23
+ u.current = !0, m();
24
+ } : void 0, k = (r) => {
25
25
  if (!n.current) {
26
- if (o.current) {
27
- o.current = !1;
26
+ if (u.current) {
27
+ u.current = !1;
28
28
  return;
29
29
  }
30
- m(r);
30
+ c(r);
31
31
  }
32
32
  };
33
- return /* @__PURE__ */ S(A, { children: [/* @__PURE__ */ b(k, {
33
+ return /* @__PURE__ */ F(C, { children: [/* @__PURE__ */ b(T, {
34
34
  characterLimitLabel: e.characterLimitLabel,
35
35
  closeAriaLabel: e.closeAriaLabel,
36
36
  description: e.description,
37
37
  isOpen: a && t === "survey" && !n.current,
38
- onBackClick: v,
39
- onClose: x,
40
- onSubmit: (r, c) => {
41
- f(r, c);
38
+ onBackClick: g,
39
+ onClose: k,
40
+ onSubmit: (r, i) => {
41
+ f(r, i);
42
42
  },
43
+ onTextInputFocus: h,
43
44
  options: e.options,
44
45
  primaryText: e.submitText,
45
46
  secondaryText: e.cancelText,
46
47
  title: e.title
47
- }), /* @__PURE__ */ b(g, {
48
+ }), /* @__PURE__ */ b(L, {
48
49
  actionText: t === "error" ? e.tryAgainText : void 0,
49
50
  closeAriaLabel: e.toastCloseAriaLabel,
50
51
  message: t === "error" ? e.errorMessage : e.successMessage,
51
- onActionClick: h,
52
- onClose: () => m(),
52
+ onActionClick: x,
53
+ onClose: () => c(),
53
54
  open: a && t !== "survey",
54
55
  severity: t === "error" ? "error" : "success"
55
56
  })] });
56
57
  };
57
58
  export {
58
- D as default
59
+ y as default
59
60
  };
60
61
 
61
62
  //# sourceMappingURL=FeedbackModal.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FeedbackModal.es.js","names":[],"sources":["../../../src/insights-v2/components/FeedbackModal.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react'\n\nimport StatusSnackbar from './shared/StatusSnackbar'\n\nimport FeedbackDialog, { type FeedbackDialogCloseReason } from './FeedbackDialog'\n\n/** Localized strings the modal renders — resolved by the caller (see FeedbackModalActionBlock). */\nexport interface FeedbackModalContent {\n /** Dialog title, e.g. \"Can you tell us why?\". */\n title: string\n /** Optional paragraph under the title, e.g. \"We'd love to hear why…\". */\n description?: string\n /** Survey reasons; the last option reveals the free-text detail field. */\n options: string[]\n /** Primary (Submit) button label. */\n submitText: string\n /** Secondary (No thanks) button label. */\n cancelText: string\n /** ARIA label for the dialog close button. */\n closeAriaLabel: string\n /** Helper text under the detail field, e.g. \"250 character limit\". */\n characterLimitLabel?: string\n /** Success snackbar message, e.g. \"Your feedback has been submitted.\". */\n successMessage: string\n /** Error snackbar message, e.g. \"Your feedback could not be submitted.\". */\n errorMessage: string\n /** Error snackbar action label, e.g. \"Try Again\". */\n tryAgainText: string\n /** ARIA label for the snackbar close button. */\n toastCloseAriaLabel: string\n}\n\ninterface FeedbackModalProps {\n isOpen: boolean\n copy: FeedbackModalContent\n /**\n * Fired when the survey is submitted. May return a promise: a rejection\n * switches to the error snackbar (Figma `1941:167637`), whose Try Again\n * action re-submits the same selection. Sync/resolved submissions show the\n * success snackbar.\n */\n onSubmit: (option: string, detail?: string) => void | Promise<void>\n /**\n * Fired when the whole flow ends: the dialog is dismissed without submitting\n * (reason set), or either snackbar is closed / auto-hides (no reason).\n */\n onClose: (reason?: FeedbackDialogCloseReason) => void\n /**\n * When provided, the secondary button acts as \"Back\" — it fires this instead\n * of ending the flow via `onClose` (e.g. SurveyModal returning to its survey\n * step). When absent, the secondary (\"No thanks\") ends the flow as before.\n */\n onBack?: () => void\n}\n\ntype Phase = 'survey' | 'success' | 'error'\n\n/**\n * The CTA feedback drilldown (Figma `1941:192803`): a \"Can you tell us why?\"\n * survey dialog followed by a success snackbar (Figma `1941:167636`) — or an\n * error snackbar with a Try Again action (Figma `1941:167637`) when the\n * submission fails.\n *\n * Purely presentational — copy arrives resolved via `FeedbackModalContent`;\n * the `feedback_modal_block` action block wires it to the copy store, the beat\n * actions, and the action-drawer session.\n */\nconst FeedbackModal = ({ copy, isOpen, onBack, onClose, onSubmit }: FeedbackModalProps) => {\n const [phase, setPhase] = useState<Phase>('survey')\n // Ref, not state: the shared Dialog fires `onClose()` synchronously right\n // after `onPrimaryAction()`, before the state update lands. Without the ref\n // that close would end the whole flow and the snackbar could never show.\n const hasSubmitted = useRef(false)\n // Kept for the error snackbar's Try Again, which re-submits the selection.\n const lastSubmission = useRef<{ option: string; detail?: string } | null>(null)\n\n // A new flow session starts from the survey, not a stale snackbar.\n useEffect(() => {\n if (isOpen) {\n setPhase('survey')\n hasSubmitted.current = false\n lastSubmission.current = null\n }\n }, [isOpen])\n\n const submit = async (option: string, detail?: string) => {\n hasSubmitted.current = true\n lastSubmission.current = { option, detail }\n try {\n await onSubmit(option, detail)\n setPhase('success')\n } catch {\n setPhase('error')\n }\n }\n\n const retry = () => {\n if (lastSubmission.current) {\n void submit(lastSubmission.current.option, lastSubmission.current.detail)\n }\n }\n\n // Ref for the same reason as hasSubmitted: the back-click's trailing Dialog\n // close fires synchronously, before any state lands.\n const backTaken = useRef(false)\n\n const handleBack = onBack\n ? () => {\n backTaken.current = true\n onBack()\n }\n : undefined\n\n // Only user-initiated closes (X / backdrop / escape / No thanks) end the\n // flow — the post-submit close hands over to the snackbar, and a back-click's\n // trailing close belongs to the caller's back navigation.\n const handleDialogClose = (reason?: FeedbackDialogCloseReason) => {\n if (hasSubmitted.current) return\n if (backTaken.current) {\n backTaken.current = false\n return\n }\n onClose(reason)\n }\n\n return (\n <>\n <FeedbackDialog\n characterLimitLabel={copy.characterLimitLabel}\n closeAriaLabel={copy.closeAriaLabel}\n description={copy.description}\n isOpen={isOpen && phase === 'survey' && !hasSubmitted.current}\n onBackClick={handleBack}\n onClose={handleDialogClose}\n onSubmit={(option, detail) => void submit(option, detail)}\n options={copy.options}\n primaryText={copy.submitText}\n secondaryText={copy.cancelText}\n title={copy.title}\n />\n <StatusSnackbar\n actionText={phase === 'error' ? copy.tryAgainText : undefined}\n closeAriaLabel={copy.toastCloseAriaLabel}\n message={phase === 'error' ? copy.errorMessage : copy.successMessage}\n onActionClick={retry}\n onClose={() => onClose()}\n open={isOpen && phase !== 'survey'}\n severity={phase === 'error' ? 'error' : 'success'}\n />\n </>\n )\n}\n\nexport default FeedbackModal\n"],"mappings":";;;;AAmEA,IAAM,IAAA,CAAiB,EAAE,MAAA,GAAM,QAAA,GAAQ,QAAA,GAAQ,SAAA,GAAS,UAAA,EAAA,MAAmC;AACzF,QAAM,CAAC,GAAO,CAAA,IAAY,EAAgB,QAAQ,GAI5C,IAAe,EAAO,EAAK,GAE3B,IAAiB,EAAmD,IAAI;AAG9E,EAAA,EAAA,MAAgB;AACd,IAAI,MACF,EAAS,QAAQ,GACjB,EAAa,UAAU,IACvB,EAAe,UAAU;AAAA,EAE7B,GAAG,CAAC,CAAM,CAAC;AAEX,QAAM,IAAS,OAAO,GAAgB,MAAoB;AACxD,IAAA,EAAa,UAAU,IACvB,EAAe,UAAU;AAAA,MAAE,QAAA;AAAA,MAAQ,QAAA;AAAA,IAAO;AAC1C,QAAI;AACF,YAAM,EAAS,GAAQ,CAAM,GAC7B,EAAS,SAAS;AAAA,IACpB,QAAQ;AACN,MAAA,EAAS,OAAO;AAAA,IAClB;AAAA,EACF,GAEM,IAAA,MAAc;AAClB,IAAI,EAAe,WACjB,EAAY,EAAe,QAAQ,QAAQ,EAAe,QAAQ,MAAM;AAAA,EAE5E,GAIM,IAAY,EAAO,EAAK,GAExB,IAAa,IAAA,MACT;AACJ,IAAA,EAAU,UAAU,IACpB,EAAO;AAAA,EACT,IACA,QAKE,IAAA,CAAqB,MAAuC;AAChE,QAAI,CAAA,EAAa,SACjB;AAAA,UAAI,EAAU,SAAS;AACrB,QAAA,EAAU,UAAU;AACpB;AAAA,MACF;AACA,MAAA,EAAQ,CAAM;AAAA;AAAA,EAChB;AAEA,SACE,gBAAA,EAAA,GAAA,EAAA,UAAA,CACE,gBAAA,EAAC,GAAD;AAAA,IACE,qBAAqB,EAAK;AAAA,IAC1B,gBAAgB,EAAK;AAAA,IACrB,aAAa,EAAK;AAAA,IAClB,QAAQ,KAAU,MAAU,YAAY,CAAC,EAAa;AAAA,IACtD,aAAa;AAAA,IACb,SAAS;AAAA,IACT,UAAA,CAAW,GAAQ,MAAA;AAAW,MAAK,EAAO,GAAQ,CAAM;AAAA;AAAA,IACxD,SAAS,EAAK;AAAA,IACd,aAAa,EAAK;AAAA,IAClB,eAAe,EAAK;AAAA,IACpB,OAAO,EAAK;AAAA,EACb,CAAA,GACD,gBAAA,EAAC,GAAD;AAAA,IACE,YAAY,MAAU,UAAU,EAAK,eAAe;AAAA,IACpD,gBAAgB,EAAK;AAAA,IACrB,SAAS,MAAU,UAAU,EAAK,eAAe,EAAK;AAAA,IACtD,eAAe;AAAA,IACf,SAAA,MAAe,EAAQ;AAAA,IACvB,MAAM,KAAU,MAAU;AAAA,IAC1B,UAAU,MAAU,UAAU,UAAU;AAAA,EACzC,CAAA,CACD,EAAA,CAAA;AAEN"}
1
+ {"version":3,"file":"FeedbackModal.es.js","names":[],"sources":["../../../src/insights-v2/components/FeedbackModal.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react'\n\nimport StatusSnackbar from './shared/StatusSnackbar'\n\nimport FeedbackDialog, { type FeedbackDialogCloseReason } from './FeedbackDialog'\n\n/** Localized strings the modal renders — resolved by the caller (see FeedbackModalActionBlock). */\nexport interface FeedbackModalContent {\n /** Dialog title, e.g. \"Can you tell us why?\". */\n title: string\n /** Optional paragraph under the title, e.g. \"We'd love to hear why…\". */\n description?: string\n /** Survey reasons; the last option reveals the free-text detail field. */\n options: string[]\n /** Primary (Submit) button label. */\n submitText: string\n /** Secondary (No thanks) button label. */\n cancelText: string\n /** ARIA label for the dialog close button. */\n closeAriaLabel: string\n /** Helper text under the detail field, e.g. \"250 character limit\". */\n characterLimitLabel?: string\n /** Success snackbar message, e.g. \"Your feedback has been submitted.\". */\n successMessage: string\n /** Error snackbar message, e.g. \"Your feedback could not be submitted.\". */\n errorMessage: string\n /** Error snackbar action label, e.g. \"Try Again\". */\n tryAgainText: string\n /** ARIA label for the snackbar close button. */\n toastCloseAriaLabel: string\n}\n\ninterface FeedbackModalProps {\n isOpen: boolean\n copy: FeedbackModalContent\n /**\n * Fired when the survey is submitted. May return a promise: a rejection\n * switches to the error snackbar (Figma `1941:167637`), whose Try Again\n * action re-submits the same selection. Sync/resolved submissions show the\n * success snackbar.\n */\n onSubmit: (option: string, detail?: string) => void | Promise<void>\n /**\n * Fired when the whole flow ends: the dialog is dismissed without submitting\n * (reason set), or either snackbar is closed / auto-hides (no reason).\n */\n onClose: (reason?: FeedbackDialogCloseReason) => void\n /**\n * When provided, the secondary button acts as \"Back\" — it fires this instead\n * of ending the flow via `onClose` (e.g. SurveyModal returning to its survey\n * step). When absent, the secondary (\"No thanks\") ends the flow as before.\n */\n onBack?: () => void\n /** First focus of the free-text box (analytics). */\n onTextInputFocus?: () => void\n /** Default true. When false a successful submit calls `onClose` (the host confirms); errors still show. */\n showSuccessMessage?: boolean\n}\n\ntype Phase = 'survey' | 'success' | 'error'\n\n/**\n * The CTA feedback drilldown (Figma `1941:192803`): a \"Can you tell us why?\"\n * survey dialog followed by a success snackbar (Figma `1941:167636`) — or an\n * error snackbar with a Try Again action (Figma `1941:167637`) when the\n * submission fails.\n *\n * Purely presentational — copy arrives resolved via `FeedbackModalContent`;\n * the `feedback_modal_block` action block wires it to the copy store, the beat\n * actions, and the action-drawer session.\n */\nconst FeedbackModal = ({\n copy,\n isOpen,\n onBack,\n onClose,\n onSubmit,\n onTextInputFocus,\n showSuccessMessage = true,\n}: FeedbackModalProps) => {\n const [phase, setPhase] = useState<Phase>('survey')\n // Ref, not state: the shared Dialog fires `onClose()` synchronously right\n // after `onPrimaryAction()`, before the state update lands. Without the ref\n // that close would end the whole flow and the snackbar could never show.\n const hasSubmitted = useRef(false)\n // Kept for the error snackbar's Try Again, which re-submits the selection.\n const lastSubmission = useRef<{ option: string; detail?: string } | null>(null)\n\n // A new flow session starts from the survey, not a stale snackbar.\n useEffect(() => {\n if (isOpen) {\n setPhase('survey')\n hasSubmitted.current = false\n lastSubmission.current = null\n }\n }, [isOpen])\n\n const submit = async (option: string, detail?: string) => {\n hasSubmitted.current = true\n lastSubmission.current = { option, detail }\n try {\n await onSubmit(option, detail)\n if (showSuccessMessage) setPhase('success')\n else onClose()\n } catch {\n setPhase('error')\n }\n }\n\n const retry = () => {\n if (lastSubmission.current) {\n void submit(lastSubmission.current.option, lastSubmission.current.detail)\n }\n }\n\n // Ref for the same reason as hasSubmitted: the back-click's trailing Dialog\n // close fires synchronously, before any state lands.\n const backTaken = useRef(false)\n\n const handleBack = onBack\n ? () => {\n backTaken.current = true\n onBack()\n }\n : undefined\n\n // Only user-initiated closes (X / backdrop / escape / No thanks) end the\n // flow — the post-submit close hands over to the snackbar, and a back-click's\n // trailing close belongs to the caller's back navigation.\n const handleDialogClose = (reason?: FeedbackDialogCloseReason) => {\n if (hasSubmitted.current) return\n if (backTaken.current) {\n backTaken.current = false\n return\n }\n onClose(reason)\n }\n\n return (\n <>\n <FeedbackDialog\n characterLimitLabel={copy.characterLimitLabel}\n closeAriaLabel={copy.closeAriaLabel}\n description={copy.description}\n isOpen={isOpen && phase === 'survey' && !hasSubmitted.current}\n onBackClick={handleBack}\n onClose={handleDialogClose}\n onSubmit={(option, detail) => void submit(option, detail)}\n onTextInputFocus={onTextInputFocus}\n options={copy.options}\n primaryText={copy.submitText}\n secondaryText={copy.cancelText}\n title={copy.title}\n />\n <StatusSnackbar\n actionText={phase === 'error' ? copy.tryAgainText : undefined}\n closeAriaLabel={copy.toastCloseAriaLabel}\n message={phase === 'error' ? copy.errorMessage : copy.successMessage}\n onActionClick={retry}\n onClose={() => onClose()}\n open={isOpen && phase !== 'survey'}\n severity={phase === 'error' ? 'error' : 'success'}\n />\n </>\n )\n}\n\nexport default FeedbackModal\n"],"mappings":";;;;AAuEA,IAAM,IAAA,CAAiB,EACrB,MAAA,GACA,QAAA,GACA,QAAA,GACA,SAAA,GACA,UAAA,GACA,kBAAA,GACA,oBAAA,IAAqB,GAAA,MACG;AACxB,QAAM,CAAC,GAAO,CAAA,IAAY,EAAgB,QAAQ,GAI5C,IAAe,EAAO,EAAK,GAE3B,IAAiB,EAAmD,IAAI;AAG9E,EAAA,EAAA,MAAgB;AACd,IAAI,MACF,EAAS,QAAQ,GACjB,EAAa,UAAU,IACvB,EAAe,UAAU;AAAA,EAE7B,GAAG,CAAC,CAAM,CAAC;AAEX,QAAM,IAAS,OAAO,GAAgB,MAAoB;AACxD,IAAA,EAAa,UAAU,IACvB,EAAe,UAAU;AAAA,MAAE,QAAA;AAAA,MAAQ,QAAA;AAAA,IAAO;AAC1C,QAAI;AACF,YAAM,EAAS,GAAQ,CAAM,GACzB,IAAoB,EAAS,SAAS,IACrC,EAAQ;AAAA,IACf,QAAQ;AACN,MAAA,EAAS,OAAO;AAAA,IAClB;AAAA,EACF,GAEM,IAAA,MAAc;AAClB,IAAI,EAAe,WACjB,EAAY,EAAe,QAAQ,QAAQ,EAAe,QAAQ,MAAM;AAAA,EAE5E,GAIM,IAAY,EAAO,EAAK,GAExB,IAAa,IAAA,MACT;AACJ,IAAA,EAAU,UAAU,IACpB,EAAO;AAAA,EACT,IACA,QAKE,IAAA,CAAqB,MAAuC;AAChE,QAAI,CAAA,EAAa,SACjB;AAAA,UAAI,EAAU,SAAS;AACrB,QAAA,EAAU,UAAU;AACpB;AAAA,MACF;AACA,MAAA,EAAQ,CAAM;AAAA;AAAA,EAChB;AAEA,SACE,gBAAA,EAAA,GAAA,EAAA,UAAA,CACE,gBAAA,EAAC,GAAD;AAAA,IACE,qBAAqB,EAAK;AAAA,IAC1B,gBAAgB,EAAK;AAAA,IACrB,aAAa,EAAK;AAAA,IAClB,QAAQ,KAAU,MAAU,YAAY,CAAC,EAAa;AAAA,IACtD,aAAa;AAAA,IACb,SAAS;AAAA,IACT,UAAA,CAAW,GAAQ,MAAA;AAAW,MAAK,EAAO,GAAQ,CAAM;AAAA;AAAA,IACtC,kBAAA;AAAA,IAClB,SAAS,EAAK;AAAA,IACd,aAAa,EAAK;AAAA,IAClB,eAAe,EAAK;AAAA,IACpB,OAAO,EAAK;AAAA,EACb,CAAA,GACD,gBAAA,EAAC,GAAD;AAAA,IACE,YAAY,MAAU,UAAU,EAAK,eAAe;AAAA,IACpD,gBAAgB,EAAK;AAAA,IACrB,SAAS,MAAU,UAAU,EAAK,eAAe,EAAK;AAAA,IACtD,eAAe;AAAA,IACf,SAAA,MAAe,EAAQ;AAAA,IACvB,MAAM,KAAU,MAAU;AAAA,IAC1B,UAAU,MAAU,UAAU,UAAU;AAAA,EACzC,CAAA,CACD,EAAA,CAAA;AAEN"}
@@ -1,11 +1,11 @@
1
1
  import { useGlobalCopyStore as y } from "../../common/context/hooks.es.js";
2
- import { useEffect as S, useMemo as p, useState as u } from "react";
3
- var H = (h, n) => {
4
- const a = y(), [r, t] = u(null), [i, l] = u(null), [b, d] = u(!1), [f, c] = u(!1), o = h.insights_payload;
5
- S(() => {
6
- o?.is_dismissed || c(!1);
7
- }, [o?.is_dismissed]);
8
- const k = p(() => o?.is_dismissed && f ? "dismissed" : o?.is_dismissed ? "confirming" : "visible", [o?.is_dismissed, f]), _ = (() => {
2
+ import { useEffect as g, useMemo as p, useState as u } from "react";
3
+ var H = (h, o) => {
4
+ const a = y(), [r, t] = u(null), [i, l] = u(null), [b, d] = u(!1), [f, c] = u(!1), n = h.insights_payload;
5
+ g(() => {
6
+ n?.is_dismissed || c(!1);
7
+ }, [n?.is_dismissed]);
8
+ const k = p(() => n?.is_dismissed && f ? "dismissed" : n?.is_dismissed ? "confirming" : "visible", [n?.is_dismissed, f]), v = (() => {
9
9
  const e = a.insights_feed?.feedback, s = a.insights_feed?.hide_feedback, m = {
10
10
  characterLimitLabel: (i === "hide" ? s : e)?.character_limit,
11
11
  closeAriaLabel: (i === "hide" ? s : e)?.close_aria ?? "Close",
@@ -17,62 +17,64 @@ var H = (h, n) => {
17
17
  options: Object.values(s.options),
18
18
  ...m
19
19
  };
20
- const g = Object.values(i === "not_helpful" ? e?.not_helpful_options ?? {} : e?.helpful_options ?? {});
20
+ const _ = Object.values(i === "not_helpful" ? e?.not_helpful_options ?? {} : e?.helpful_options ?? {});
21
21
  return {
22
22
  title: e?.tell_us_more_title ?? "Tell us more",
23
- options: g,
23
+ options: _,
24
24
  ...m
25
25
  };
26
- })(), v = p(() => {
27
- const e = n.onMenuAction;
26
+ })(), S = p(() => {
27
+ const e = o.onMenuAction;
28
28
  return e ? {
29
- ...n,
29
+ ...o,
30
30
  onMenuAction: {
31
31
  ...e,
32
32
  onAction: (s) => {
33
33
  s === "helpful" || s === "not_helpful" ? t(s) : s === "hide" && d(!0), e.onAction(s);
34
34
  }
35
35
  }
36
- } : n;
37
- }, [n]);
36
+ } : o;
37
+ }, [o]);
38
38
  return {
39
39
  cardState: k,
40
40
  isDismissOpen: b,
41
41
  isSurveyOpen: i !== null,
42
42
  isFeedbackBarShown: r !== null,
43
- survey: _,
44
- wrappedActions: v,
43
+ survey: v,
44
+ wrappedActions: S,
45
45
  openRatingSurvey: () => {
46
46
  r && l(r);
47
47
  },
48
- openHideSurvey: () => l("hide"),
48
+ openHideSurvey: () => {
49
+ o.onFeedbackSurveyShown?.("hide"), l("hide");
50
+ },
49
51
  closeSurvey: (e) => {
50
- e && n.onFeedbackDialogClose?.(e), i !== "hide" && t(null), l(null);
52
+ e && o.onFeedbackDialogClose?.(e, i ?? void 0), i !== "hide" && t(null), l(null);
51
53
  },
52
54
  submitSurvey: (e, s) => {
53
- !i || !o || (n.onSubmitFeedback?.({
54
- beatGuid: o.guid,
55
+ !i || !n || (o.onSubmitFeedback?.({
56
+ beatGuid: n.guid,
55
57
  source: i,
56
58
  option: e,
57
59
  detail: s
58
60
  }), l(null), i === "hide" ? c(!0) : t(null));
59
61
  },
60
62
  confirmDismiss: (e) => {
61
- o && n.onDismissInsight?.({
62
- beatGuid: o.guid,
63
+ n && o.onDismissInsight?.({
64
+ beatGuid: n.guid,
63
65
  type: e
64
66
  });
65
67
  },
66
68
  undoDismiss: () => {
67
- o && (n.onUndoDismiss?.({ beatGuid: o.guid }), t(null));
69
+ n && (o.onUndoDismiss?.({ beatGuid: n.guid }), t(null));
68
70
  },
69
71
  collapseConfirmation: () => {
70
72
  c(!0);
71
73
  },
72
74
  closeDismissDialog: () => d(!1),
73
75
  feedbackDialogCallbacks: {
74
- onBackClick: n.onFeedbackDialogBack,
75
- onTextInputFocus: n.onFeedbackTextFocus
76
+ onBackClick: o.onFeedbackDialogBack,
77
+ onTextInputFocus: o.onFeedbackTextFocus
76
78
  }
77
79
  };
78
80
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useBeatFeedbackFlow.es.js","names":[],"sources":["../../../src/insights-v2/hooks/useBeatFeedbackFlow.ts"],"sourcesContent":["import { useEffect, useMemo, useState } from 'react'\n\nimport { useGlobalCopyStore } from '../../common'\nimport type { Beat } from '../../core'\nimport type { BeatActions, InsightRating } from '../beatActions'\nimport type { DismissType } from '../components/DismissInsightDialog'\nimport type { FeedbackDialogCloseReason } from '../components/FeedbackDialog'\n\nexport type FeedbackVariant = InsightRating | 'hide'\nexport type CardState = 'visible' | 'confirming' | 'dismissed'\n\n/**\n * Manages feedback and dismiss UI state for a beat card.\n * Handles feedback bar, dismiss dialog, confirmation card, and survey dialogs.\n */\nexport const useBeatFeedbackFlow = (beat: Beat, beatActions: BeatActions) => {\n const copyStore = useGlobalCopyStore()\n\n const [feedbackRating, setFeedbackRating] = useState<InsightRating | null>(null)\n const [feedbackVariant, setFeedbackVariant] = useState<FeedbackVariant | null>(null)\n const [isDismissOpen, setIsDismissOpen] = useState(false)\n const [hasClosedConfirmation, setHasClosedConfirmation] = useState(false)\n\n const insights_payload = beat.insights_payload\n\n // Reset the confirmation-closed flag whenever the beat is no longer dismissed\n // (undo or a host reload flipping is_dismissed), so a fresh dismiss always\n // starts at the confirmation card instead of jumping to 'dismissed'.\n useEffect(() => {\n if (!insights_payload?.is_dismissed) setHasClosedConfirmation(false)\n }, [insights_payload?.is_dismissed])\n\n const cardState: CardState = useMemo(() => {\n if (insights_payload?.is_dismissed && hasClosedConfirmation) return 'dismissed'\n if (insights_payload?.is_dismissed) return 'confirming'\n return 'visible'\n }, [insights_payload?.is_dismissed, hasClosedConfirmation])\n\n const resolveSurvey = () => {\n const feedbackCopy = copyStore.insights_feed?.feedback\n const hideCopy = copyStore.insights_feed?.hide_feedback\n\n const chrome = {\n characterLimitLabel: (feedbackVariant === 'hide' ? hideCopy : feedbackCopy)?.character_limit,\n closeAriaLabel: (feedbackVariant === 'hide' ? hideCopy : feedbackCopy)?.close_aria ?? 'Close',\n submitText: (feedbackVariant === 'hide' ? hideCopy : feedbackCopy)?.submit ?? 'Submit',\n backText: (feedbackVariant === 'hide' ? hideCopy : feedbackCopy)?.back ?? 'Back',\n }\n\n if (feedbackVariant === 'hide' && hideCopy) {\n return {\n title: hideCopy.title,\n options: Object.values(hideCopy.options),\n ...chrome,\n }\n }\n\n const options =\n feedbackVariant === 'not_helpful'\n ? Object.values(feedbackCopy?.not_helpful_options ?? {})\n : Object.values(feedbackCopy?.helpful_options ?? {})\n\n return {\n title: feedbackCopy?.tell_us_more_title ?? 'Tell us more',\n options,\n ...chrome,\n }\n }\n\n const survey = resolveSurvey()\n\n const wrappedActions = useMemo<BeatActions>(() => {\n const menu = beatActions.onMenuAction\n if (!menu) return beatActions\n return {\n ...beatActions,\n onMenuAction: {\n ...menu,\n onAction: (action) => {\n if (action === 'helpful' || action === 'not_helpful') {\n setFeedbackRating(action)\n } else if (action === 'hide') {\n setIsDismissOpen(true)\n }\n menu.onAction(action)\n },\n },\n }\n }, [beatActions])\n\n const openRatingSurvey = () => {\n if (feedbackRating) setFeedbackVariant(feedbackRating)\n }\n\n const openHideSurvey = () => setFeedbackVariant('hide')\n\n const closeSurvey = (reason?: FeedbackDialogCloseReason) => {\n if (reason) beatActions.onFeedbackDialogClose?.(reason)\n if (feedbackVariant !== 'hide') setFeedbackRating(null)\n setFeedbackVariant(null)\n }\n\n const submitSurvey = (option: string, detail?: string) => {\n if (!feedbackVariant || !insights_payload) return\n beatActions.onSubmitFeedback?.({\n beatGuid: insights_payload.guid,\n source: feedbackVariant,\n option,\n detail,\n })\n setFeedbackVariant(null)\n if (feedbackVariant === 'hide') {\n setHasClosedConfirmation(true)\n } else {\n setFeedbackRating(null)\n }\n }\n\n const confirmDismiss = (type: DismissType) => {\n if (!insights_payload) return\n beatActions.onDismissInsight?.({ beatGuid: insights_payload.guid, type })\n }\n\n const undoDismiss = () => {\n if (!insights_payload) return\n beatActions.onUndoDismiss?.({ beatGuid: insights_payload.guid })\n setFeedbackRating(null)\n }\n\n const collapseConfirmation = () => {\n setHasClosedConfirmation(true)\n }\n\n const closeDismissDialog = () => setIsDismissOpen(false)\n\n return {\n cardState,\n isDismissOpen,\n isSurveyOpen: feedbackVariant !== null,\n isFeedbackBarShown: feedbackRating !== null,\n survey,\n wrappedActions,\n openRatingSurvey,\n openHideSurvey,\n closeSurvey,\n submitSurvey,\n confirmDismiss,\n undoDismiss,\n collapseConfirmation,\n closeDismissDialog,\n feedbackDialogCallbacks: {\n onBackClick: beatActions.onFeedbackDialogBack,\n onTextInputFocus: beatActions.onFeedbackTextFocus,\n },\n }\n}\n"],"mappings":";;AAeA,IAAa,IAAA,CAAuB,GAAY,MAA6B;AAC3E,Q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AiBrD,yBAAyB;AAAA,MACvB,aAAa,EAAY;AAAA,MACzB,kBAAkB,EAAY;AAAA,IAChC;AAAA,EACF;AACF"}
1
+ {"version":3,"file":"useBeatFeedbackFlow.es.js","names":[],"sources":["../../../src/insights-v2/hooks/useBeatFeedbackFlow.ts"],"sourcesContent":["import { useEffect, useMemo, useState } from 'react'\n\nimport { useGlobalCopyStore } from '../../common'\nimport type { Beat } from '../../core'\nimport type { BeatActions, InsightRating } from '../beatActions'\nimport type { DismissType } from '../components/DismissInsightDialog'\nimport type { FeedbackDialogCloseReason } from '../components/FeedbackDialog'\n\nexport type FeedbackVariant = InsightRating | 'hide'\nexport type CardState = 'visible' | 'confirming' | 'dismissed'\n\n/**\n * Manages feedback and dismiss UI state for a beat card.\n * Handles feedback bar, dismiss dialog, confirmation card, and survey dialogs.\n */\nexport const useBeatFeedbackFlow = (beat: Beat, beatActions: BeatActions) => {\n const copyStore = useGlobalCopyStore()\n\n const [feedbackRating, setFeedbackRating] = useState<InsightRating | null>(null)\n const [feedbackVariant, setFeedbackVariant] = useState<FeedbackVariant | null>(null)\n const [isDismissOpen, setIsDismissOpen] = useState(false)\n const [hasClosedConfirmation, setHasClosedConfirmation] = useState(false)\n\n const insights_payload = beat.insights_payload\n\n // Reset the confirmation-closed flag whenever the beat is no longer dismissed\n // (undo or a host reload flipping is_dismissed), so a fresh dismiss always\n // starts at the confirmation card instead of jumping to 'dismissed'.\n useEffect(() => {\n if (!insights_payload?.is_dismissed) setHasClosedConfirmation(false)\n }, [insights_payload?.is_dismissed])\n\n const cardState: CardState = useMemo(() => {\n if (insights_payload?.is_dismissed && hasClosedConfirmation) return 'dismissed'\n if (insights_payload?.is_dismissed) return 'confirming'\n return 'visible'\n }, [insights_payload?.is_dismissed, hasClosedConfirmation])\n\n const resolveSurvey = () => {\n const feedbackCopy = copyStore.insights_feed?.feedback\n const hideCopy = copyStore.insights_feed?.hide_feedback\n\n const chrome = {\n characterLimitLabel: (feedbackVariant === 'hide' ? hideCopy : feedbackCopy)?.character_limit,\n closeAriaLabel: (feedbackVariant === 'hide' ? hideCopy : feedbackCopy)?.close_aria ?? 'Close',\n submitText: (feedbackVariant === 'hide' ? hideCopy : feedbackCopy)?.submit ?? 'Submit',\n backText: (feedbackVariant === 'hide' ? hideCopy : feedbackCopy)?.back ?? 'Back',\n }\n\n if (feedbackVariant === 'hide' && hideCopy) {\n return {\n title: hideCopy.title,\n options: Object.values(hideCopy.options),\n ...chrome,\n }\n }\n\n const options =\n feedbackVariant === 'not_helpful'\n ? Object.values(feedbackCopy?.not_helpful_options ?? {})\n : Object.values(feedbackCopy?.helpful_options ?? {})\n\n return {\n title: feedbackCopy?.tell_us_more_title ?? 'Tell us more',\n options,\n ...chrome,\n }\n }\n\n const survey = resolveSurvey()\n\n const wrappedActions = useMemo<BeatActions>(() => {\n const menu = beatActions.onMenuAction\n if (!menu) return beatActions\n return {\n ...beatActions,\n onMenuAction: {\n ...menu,\n onAction: (action) => {\n if (action === 'helpful' || action === 'not_helpful') {\n setFeedbackRating(action)\n } else if (action === 'hide') {\n setIsDismissOpen(true)\n }\n menu.onAction(action)\n },\n },\n }\n }, [beatActions])\n\n const openRatingSurvey = () => {\n if (feedbackRating) setFeedbackVariant(feedbackRating)\n }\n\n const openHideSurvey = () => {\n beatActions.onFeedbackSurveyShown?.('hide')\n setFeedbackVariant('hide')\n }\n\n const closeSurvey = (reason?: FeedbackDialogCloseReason) => {\n if (reason) beatActions.onFeedbackDialogClose?.(reason, feedbackVariant ?? undefined)\n if (feedbackVariant !== 'hide') setFeedbackRating(null)\n setFeedbackVariant(null)\n }\n\n const submitSurvey = (option: string, detail?: string) => {\n if (!feedbackVariant || !insights_payload) return\n beatActions.onSubmitFeedback?.({\n beatGuid: insights_payload.guid,\n source: feedbackVariant,\n option,\n detail,\n })\n setFeedbackVariant(null)\n if (feedbackVariant === 'hide') {\n setHasClosedConfirmation(true)\n } else {\n setFeedbackRating(null)\n }\n }\n\n const confirmDismiss = (type: DismissType) => {\n if (!insights_payload) return\n beatActions.onDismissInsight?.({ beatGuid: insights_payload.guid, type })\n }\n\n const undoDismiss = () => {\n if (!insights_payload) return\n beatActions.onUndoDismiss?.({ beatGuid: insights_payload.guid })\n setFeedbackRating(null)\n }\n\n const collapseConfirmation = () => {\n setHasClosedConfirmation(true)\n }\n\n const closeDismissDialog = () => setIsDismissOpen(false)\n\n return {\n cardState,\n isDismissOpen,\n isSurveyOpen: feedbackVariant !== null,\n isFeedbackBarShown: feedbackRating !== null,\n survey,\n wrappedActions,\n openRatingSurvey,\n openHideSurvey,\n closeSurvey,\n submitSurvey,\n confirmDismiss,\n undoDismiss,\n collapseConfirmation,\n closeDismissDialog,\n feedbackDialogCallbacks: {\n onBackClick: beatActions.onFeedbackDialogBack,\n onTextInputFocus: beatActions.onFeedbackTextFocus,\n },\n }\n}\n"],"mappings":";;AAeA,IAAa,IAAA,CAAuB,GAAY,MAA6B;AAC3E,QAAM,IAAY,EAAmB,GAE/B,CAAC,GAAgB,CAAA,IAAqB,EAA+B,IAAI,GACzE,CAAC,GAAiB,CAAA,IAAsB,EAAiC,IAAI,GAC7E,CAAC,GAAe,CAAA,IAAoB,EAAS,EAAK,GAClD,CAAC,GAAuB,CAAA,IAA4B,EAAS,EAAK,GAElE,IAAmB,EAAK;AAK9B,EAAA,EAAA,MAAgB;AACd,IAAK,GAAkB,gBAAc,EAAyB,EAAK;AAAA,EACrE,GAAG,CAAC,GAAkB,YAAY,CAAC;AAEnC,QAAM,IAAuB,EAAA,MACvB,GAAkB,gBAAgB,IAA8B,cAChE,GAAkB,eAAqB,eACpC,WACN,CAAC,GAAkB,cAAc,CAAqB,CAAC,GAiCpD,KA/BA,MAAsB;AAC1B,UAAM,IAAe,EAAU,eAAe,UACxC,IAAW,EAAU,eAAe,eAEpC,IAAS;AAAA,MACb,sBAAsB,MAAoB,SAAS,IAAW,IAAe;AAAA,MAC7E,iBAAiB,MAAoB,SAAS,IAAW,IAAe,cAAc;AAAA,MACtF,aAA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CE,cA3CI,CAAgB,GAAgB,MAAoB;AACxD,MAAI,CAAC,KAAmB,CAAC,MACzB,EAAY,mBAAmB;AAAA,QAC7B,UAAU,EAAiB;AAAA,QAC3B,QAAQ;AAAA,QACR,QAAA;AAAA,QACA,QAAA;AAAA,MACF,CAAC,GACD,EAAmB,IAAI,GACnB,MAAoB,SACtB,EAAyB,EAAI,IAE7B,EAAkB,IAAI;AAAA,IAE1B;AAAA,IA8BE,gBA5BI,CAAkB,MAAsB;AAC5C,MAAK,KACL,EAAY,mBAAmB;AAAA,QAAE,UAAU,EAAiB;AAAA,QAAM,MAAA;AAAA,MAAK,CAAC;AAAA,IAC1E;AAAA,IA0BE,aAxBI,MAAoB;AACxB,MAAK,MACL,EAAY,gBAAgB,EAAE,UAAU,EAAiB,KAAK,CAAC,GAC/D,EAAkB,IAAI;AAAA,IACxB;AAAA,IAqBE,sBAnBI,MAA6B;AACjC,MAAA,EAAyB,EAAI;AAAA,IAC/B;AAAA,IAkBE,oBAhBI,MAA2B,EAAiB,EAAK;AAAA,IAiBrD,yBAAyB;AAAA,MACvB,aAAa,EAAY;AAAA,MACzB,kBAAkB,EAAY;AAAA,IAChC;AAAA,EACF;AACF"}
@@ -1,10 +1,10 @@
1
- var d = ({ store: i, template: c, posthog: s }) => ({
2
- onAnalyticsEvent: ({ action: e, category: a, label: n, postHog: t }) => {
1
+ var l = ({ store: i, template: c, posthog: s }) => ({
2
+ onAnalyticsEvent: ({ action: e, category: a, label: n, postHog: t, value: d }) => {
3
3
  i.session && (e || a) && i.session.sendAnalyticEvent({
4
4
  action: e ?? "",
5
5
  category: a ?? "",
6
6
  label: n ?? "",
7
- value: null
7
+ value: d ?? null
8
8
  }).catch(() => {
9
9
  }), t?.eventName && s?.capture(t.eventName, t.properties);
10
10
  },
@@ -17,7 +17,7 @@ var d = ({ store: i, template: c, posthog: s }) => ({
17
17
  }
18
18
  });
19
19
  export {
20
- d as buildMicroBeatActions
20
+ l as buildMicroBeatActions
21
21
  };
22
22
 
23
23
  //# sourceMappingURL=beatActions.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"beatActions.es.js","names":[],"sources":["../../src/microinsights/beatActions.ts"],"sourcesContent":["import type { BeatActions } from '../insights-v2/beatActions'\n\nimport type { AppStore } from './stores/AppStore'\nimport type { TheWholeHog } from './interfaces'\n\ninterface MicroBeatActionsDeps {\n store: Pick<AppStore, 'session' | 'insightsMicroWidgetStore'>\n template: string\n posthog?: TheWholeHog\n}\n\n/**\n * Host callbacks for an action block opened from a micro card, built from what the widget already\n * owns (analytics session, beat API, `posthog`), so the host supplies nothing more.\n *\n * - `onAnalyticsEvent`: Firefly half via the analytics session, PostHog half via `posthog`.\n * Fire-and-forget.\n * - `onSubmitFeedback`: `POST /beat_feedback` with pulse's body (`detail`, else the option, else\n * `No feedback`). A rejection drives the survey's error state.\n *\n * Other host effects (`onCtaAction`, `onUpdate`, ...) are not provided and no-op.\n */\nexport const buildMicroBeatActions = ({\n store,\n template,\n posthog,\n}: MicroBeatActionsDeps): BeatActions => ({\n onAnalyticsEvent: ({ action, category, label, postHog }) => {\n if (store.session && (action || category)) {\n store.session\n .sendAnalyticEvent({\n action: action ?? '',\n category: category ?? '',\n label: label ?? '',\n value: null,\n })\n .catch(() => {})\n }\n\n if (postHog?.eventName) {\n posthog?.capture(postHog.eventName, postHog.properties)\n }\n },\n onSubmitFeedback: async ({ beatGuid, option, detail }) => {\n await store.insightsMicroWidgetStore.sendBeatFeedback({\n beat_guid: beatGuid,\n template,\n comments: detail || option || 'No feedback',\n })\n },\n})\n"],"mappings":"AAsBA,IAAa,IAAA,CAAyB,EACpC,OAAA,GACA,UAAA,GACA,SAAA,EAAA,OACwC;AAAA,EACxC,kBAAA,CAAmB,EAAE,QAAA,GAAQ,UAAA,GAAU,OAAA,GAAO,SAAA,EAAA,MAAc;AAC1D,IAAI,EAAM,YAAY,KAAU,MAC9B,EAAM,QACH,kBAAkB;AAAA,MACjB,QAAQ,KAAU;AAAA,MAClB,UAAU,KAAY;AAAA,MACtB,OAAO,KAAS;AAAA,MAChB,OAAO;AAAA,IACT,CAAC,EACA,MAAA,MAAY;AAAA,IAAC,CAAC,GAGf,GAAS,aACX,GAAS,QAAQ,EAAQ,WAAW,EAAQ,UAAU;AAAA,EAE1D;AAAA,EACA,kBAAkB,OAAO,EAAE,UAAA,GAAU,QAAA,GAAQ,QAAA,EAAA,MAAa;AACxD,UAAM,EAAM,yBAAyB,iBAAiB;AAAA,MACpD,WAAW;AAAA,MACX,UAAA;AAAA,MACA,UAAU,KAAU,KAAU;AAAA,IAChC,CAAC;AAAA,EACH;AACF"}
1
+ {"version":3,"file":"beatActions.es.js","names":[],"sources":["../../src/microinsights/beatActions.ts"],"sourcesContent":["import type { BeatActions } from '../insights-v2/beatActions'\n\nimport type { AppStore } from './stores/AppStore'\nimport type { TheWholeHog } from './interfaces'\n\ninterface MicroBeatActionsDeps {\n store: Pick<AppStore, 'session' | 'insightsMicroWidgetStore'>\n template: string\n posthog?: TheWholeHog\n}\n\n/**\n * Host callbacks for an action block opened from a micro card, built from what the widget already\n * owns (analytics session, beat API, `posthog`), so the host supplies nothing more.\n *\n * - `onAnalyticsEvent`: Firefly half via the analytics session, PostHog half via `posthog`.\n * Fire-and-forget.\n * - `onSubmitFeedback`: `POST /beat_feedback` with pulse's body (`detail`, else the option, else\n * `No feedback`). A rejection drives the survey's error state.\n *\n * Other host effects (`onCtaAction`, `onUpdate`, ...) are not provided and no-op.\n */\nexport const buildMicroBeatActions = ({\n store,\n template,\n posthog,\n}: MicroBeatActionsDeps): BeatActions => ({\n onAnalyticsEvent: ({ action, category, label, postHog, value }) => {\n if (store.session && (action || category)) {\n store.session\n .sendAnalyticEvent({\n action: action ?? '',\n category: category ?? '',\n label: label ?? '',\n value: value ?? null,\n })\n .catch(() => {})\n }\n\n if (postHog?.eventName) {\n posthog?.capture(postHog.eventName, postHog.properties)\n }\n },\n onSubmitFeedback: async ({ beatGuid, option, detail }) => {\n await store.insightsMicroWidgetStore.sendBeatFeedback({\n beat_guid: beatGuid,\n template,\n comments: detail || option || 'No feedback',\n })\n },\n})\n"],"mappings":"AAsBA,IAAa,IAAA,CAAyB,EACpC,OAAA,GACA,UAAA,GACA,SAAA,EAAA,OACwC;AAAA,EACxC,kBAAA,CAAmB,EAAE,QAAA,GAAQ,UAAA,GAAU,OAAA,GAAO,SAAA,GAAS,OAAA,EAAA,MAAY;AACjE,IAAI,EAAM,YAAY,KAAU,MAC9B,EAAM,QACH,kBAAkB;AAAA,MACjB,QAAQ,KAAU;AAAA,MAClB,UAAU,KAAY;AAAA,MACtB,OAAO,KAAS;AAAA,MAChB,OAAO,KAAS;AAAA,IAClB,CAAC,EACA,MAAA,MAAY;AAAA,IAAC,CAAC,GAGf,GAAS,aACX,GAAS,QAAQ,EAAQ,WAAW,EAAQ,UAAU;AAAA,EAE1D;AAAA,EACA,kBAAkB,OAAO,EAAE,UAAA,GAAU,QAAA,GAAQ,QAAA,EAAA,MAAa;AACxD,UAAM,EAAM,yBAAyB,iBAAiB;AAAA,MACpD,WAAW;AAAA,MACX,UAAA;AAAA,MACA,UAAU,KAAU,KAAU;AAAA,IAChC,CAAC;AAAA,EACH;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mx-cartographer/experiences",
3
- "version": "9.7.40",
3
+ "version": "9.7.42",
4
4
  "description": "Library containing experience widgets",
5
5
  "author": "MX",
6
6
  "license": "MIT",