@mx-cartographer/experiences 9.7.40 → 9.7.41
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.
- package/CHANGELOG.md +11 -0
- package/dist/core/types/localization/InsightsFeedCopy.d.ts +2 -0
- package/dist/insights-v2/actionBlocks/FeedbackModalActionBlock.d.ts +4 -4
- package/dist/insights-v2/actionBlocks/FeedbackModalActionBlock.es.js +45 -31
- package/dist/insights-v2/actionBlocks/FeedbackModalActionBlock.es.js.map +1 -1
- package/dist/insights-v2/analytics/analyticsEventsConfig.d.ts +6 -0
- package/dist/insights-v2/analytics/analyticsEventsConfig.es.js +4 -0
- package/dist/insights-v2/analytics/analyticsEventsConfig.es.js.map +1 -1
- package/dist/insights-v2/analytics/resolveAnalyticsEvent.es.js +7 -6
- package/dist/insights-v2/analytics/resolveAnalyticsEvent.es.js.map +1 -1
- package/dist/insights-v2/beatActions.d.ts +7 -2
- package/dist/insights-v2/beatActions.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/DetailedAccountBlock/DetailedAccountBlock.es.js +29 -20
- package/dist/insights-v2/blocks/ComponentBlocks/DetailedAccountBlock/DetailedAccountBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/DetailedAccountBlock/layout.es.js +27 -24
- package/dist/insights-v2/blocks/ComponentBlocks/DetailedAccountBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/components/BaseLayout.es.js +1 -1
- package/dist/insights-v2/components/BaseLayout.es.js.map +1 -1
- package/dist/insights-v2/components/FeedbackModal.d.ts +5 -1
- package/dist/insights-v2/components/FeedbackModal.es.js +29 -28
- package/dist/insights-v2/components/FeedbackModal.es.js.map +1 -1
- package/dist/insights-v2/hooks/useBeatFeedbackFlow.es.js +27 -25
- package/dist/insights-v2/hooks/useBeatFeedbackFlow.es.js.map +1 -1
- package/dist/microinsights/beatActions.es.js +4 -4
- package/dist/microinsights/beatActions.es.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
## [9.7.41] - 10-26-2026
|
|
2
|
+
|
|
3
|
+
- **FIXED** - The neutral status pill on the Set Up Direct Deposit card (`direct_deposit_block`, `set_up_direct_deposit` and `detailed_neutral`) is `grey.100` in light mode and `grey.800` in dark mode, so `text.primary` reads on it in both. It was `grey.200` in both, which left the dark-mode label at about 1.4:1 contrast because the grey tokens do not change with the mode (WEC-2059)
|
|
4
|
+
- **ADDED** - `BeatActions.onFeedbackSurveyShown(variant)` fires when the hide survey opens ("Leave feedback" on the hidden-confirmation card), and `onFeedbackDialogClose` now receives the survey's `variant` as a second argument. Both are optional, so hosts that ignore them are unchanged. Pulse uses them for PostHog `survey shown` / `survey dismissed`, which the legacy dismissed card sent and V2 did not. Applies to every Insights 2.0 beat with the hide survey (WEC-2059)
|
|
5
|
+
- **FIXED** - The obsolete "not refreshable" dimming overlay sits above every block's own stacking (`zIndex` 3, was 1), so a raised section such as the Set Up Direct Deposit hero card is dimmed with the rest of the card instead of showing through (WEC-2059)
|
|
6
|
+
- **CHANGED** - `DetailedAccountBlock` (`direct_deposit_block`) reads the account facts (`account_name`, `account_type`, `status_text`, `institution_guid`, `institution_name`) from `instance_slot.data` first, and keeps the flat slot fields as the fallback, so the V1 payload and the existing fixtures render unchanged. A missing fact is omitted, never drawn blank or as `undefined`. Insights 2.0 Set Up Direct Deposit sends them in `data` (WEC-2059)
|
|
7
|
+
- **CHANGED** - The tile's logo alt is the localized "{institution} Institution Logo" (the legacy wording, `insights_feed.general.institution_Logo`), built from the name in the logo's own `alt` or the flat `institution_name`; it falls back to the envelope's alt when the copy or name is missing, and a micro widget with no `GlobalDataProvider` keeps working (WEC-2059)
|
|
8
|
+
- **CHANGED** - `FeedbackModalActionBlock` ("Not Interested") now behaves as the legacy Set Up Direct Deposit modal did. It records the dismissal once through the host's `onDismissInsight` (`always`, which hides the card and disables the template), reports `Beat Dismissed` with the picked reason, then sends the feedback as a dismissal survey (`source: 'not_interested'`, new on `FeedbackParams.source`, so the host records the reason as legacy did; a host that does not know it must handle it first, see the pulse MR); a failed send leaves the beat dismissed and Try Again re-sends only the feedback. A host that can dismiss shows the hidden-confirmation card instead of the success snackbar (`FeedbackModal` gains `showSuccessMessage`, default true, and `onTextInputFocus`); the error snackbar with Try Again is unchanged, and a host that cannot dismiss (the micro widget) keeps the success snackbar. The first focus of the free-text box reaches the host's `onFeedbackTextFocus`. The dialog names the account from `instance_slot.data.account_name`, falling back to the flat name (WEC-2059)
|
|
9
|
+
- **ADDED** - `AnalyticsEventPayload` and the analytics catalogue entries can carry an optional `value` (stored with the Firefly event), and the catalogue has `BEAT_DISMISSED`. The micro widget's host sends the value instead of `null`. Pulse must forward `value` in its `onAnalyticsEvent` for the reason to reach Firefly (WEC-2059)
|
|
10
|
+
- **ADDED** - Insights 2.0 fixtures and stories for Set Up Direct Deposit (`SetUpDirectDepositV2`, `DirectDepositCompleteV2`) with the slot data under `instance_slot.data`; `insights_feed.general.institution_Logo` added to the typed copy and the mock copy (WEC-2059)
|
|
11
|
+
|
|
1
12
|
## [9.7.40] - 10-23-2026
|
|
2
13
|
|
|
3
14
|
- **FIXED** - date range year in the trends category details (MEW-4019)
|
|
@@ -23,6 +23,8 @@ interface GeneralInsightsFeedCopy {
|
|
|
23
23
|
update: string;
|
|
24
24
|
updating: string;
|
|
25
25
|
dollar_bill?: string;
|
|
26
|
+
/** `_1{institution}` — the alt text of an institution's logo, e.g. "Chase Institution Logo". */
|
|
27
|
+
institution_Logo?: string;
|
|
26
28
|
weekly_no_spending_component_alt_text?: DynamicKeyValue;
|
|
27
29
|
}
|
|
28
30
|
interface SettingsMenuCopy {
|
|
@@ -4,10 +4,10 @@ import { ActionBlockProps } from '../mappings/blocks';
|
|
|
4
4
|
* block; its content is a MODAL (the dialog portals over the drawer).
|
|
5
5
|
*
|
|
6
6
|
* Flow: the CTA (e.g. Set Up Direct Deposit's "Not Interested") opens the
|
|
7
|
-
* "Can you tell us why?" survey (Figma `1941:192803`). Submit
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* "Can you tell us why?" survey (Figma `1941:192803`). Submit dismisses the insight
|
|
8
|
+
* (`onDismissInsight`), then forwards the selection via `onSubmitFeedback` (source
|
|
9
|
+
* `hide`). A host that can dismiss shows its own confirmation; otherwise the dialog
|
|
10
|
+
* swaps for the success snackbar (Figma `1941:167636`). Closing ends the drawer session.
|
|
11
11
|
*
|
|
12
12
|
* Copy comes from `insights_feed.feedback_modal` in GlobalCopy; the
|
|
13
13
|
* description interpolates the beat's account name (`_1{account_name}`).
|
|
@@ -1,39 +1,53 @@
|
|
|
1
|
-
import { buildDynamicCopy as
|
|
2
|
-
import { useGlobalCopyStore as
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
import { buildDynamicCopy as p } from "../../core/utils/Localization.es.js";
|
|
2
|
+
import { useGlobalCopyStore as b, useInsightsV2Store as _ } from "../../common/context/hooks.es.js";
|
|
3
|
+
import { slot as f } from "../../core/types/Insights.es.js";
|
|
4
|
+
import { useBeatActions as y } from "../beatActions.es.js";
|
|
5
|
+
import { ANALYTICS_EVENTS_CONFIG as g } from "../analytics/analyticsEventsConfig.es.js";
|
|
6
|
+
import { useAnalyticsEvent as S } from "../analytics/useAnalyticsEvent.es.js";
|
|
7
|
+
import h from "../components/FeedbackModal.es.js";
|
|
8
|
+
import { useRef as A } from "react";
|
|
9
|
+
import { observer as k } from "mobx-react-lite";
|
|
10
|
+
import { jsx as F } from "react/jsx-runtime";
|
|
11
|
+
var N = k(function({ beat: i }) {
|
|
12
|
+
const { closeActionDrawer: r } = _(), { onDismissInsight: o, onFeedbackTextFocus: n, onSubmitFeedback: c } = y(), l = b(), m = S(), s = A(!1), t = i.insights_payload, e = l.insights_feed?.feedback_modal;
|
|
13
|
+
if (!t || !e) return null;
|
|
14
|
+
const u = {
|
|
15
|
+
title: e.title,
|
|
16
|
+
description: p(e.description, f(t.instance_slot?.data, "account_name") ?? t.instance_slot?.account_name ?? ""),
|
|
17
|
+
options: Object.values(e.options ?? {}),
|
|
18
|
+
submitText: e.submit,
|
|
19
|
+
cancelText: e.no_thanks,
|
|
20
|
+
closeAriaLabel: e.close_aria,
|
|
21
|
+
characterLimitLabel: e.character_limit,
|
|
22
|
+
successMessage: e.success_message,
|
|
23
|
+
errorMessage: e.error_message,
|
|
24
|
+
tryAgainText: e.try_again,
|
|
25
|
+
toastCloseAriaLabel: e.toast_close_aria
|
|
22
26
|
};
|
|
23
|
-
return /* @__PURE__ */
|
|
24
|
-
copy:
|
|
27
|
+
return /* @__PURE__ */ F(h, {
|
|
28
|
+
copy: u,
|
|
25
29
|
isOpen: !0,
|
|
26
|
-
onClose: () =>
|
|
27
|
-
onSubmit: (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
onClose: () => r(),
|
|
31
|
+
onSubmit: async (a, d) => {
|
|
32
|
+
s.current || (s.current = !0, o?.({
|
|
33
|
+
beatGuid: t.guid,
|
|
34
|
+
type: "always"
|
|
35
|
+
}), m({
|
|
36
|
+
...g.BEAT_DISMISSED,
|
|
37
|
+
value: a
|
|
38
|
+
})), await c?.({
|
|
39
|
+
beatGuid: t.guid,
|
|
40
|
+
source: "not_interested",
|
|
41
|
+
option: a,
|
|
42
|
+
detail: d
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
onTextInputFocus: n,
|
|
46
|
+
showSuccessMessage: !o
|
|
33
47
|
});
|
|
34
48
|
});
|
|
35
49
|
export {
|
|
36
|
-
|
|
50
|
+
N as FeedbackModalActionBlock
|
|
37
51
|
};
|
|
38
52
|
|
|
39
53
|
//# sourceMappingURL=FeedbackModalActionBlock.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FeedbackModalActionBlock.es.js","names":[],"sources":["../../../src/insights-v2/actionBlocks/FeedbackModalActionBlock.tsx"],"sourcesContent":["import { observer } from 'mobx-react-lite'\n\nimport { useGlobalCopyStore, useInsightsV2Store } from '../../common'\nimport { buildDynamicCopy } from '../../core/utils/Localization'\nimport FeedbackModal, { type FeedbackModalContent } from '../components/FeedbackModal'\nimport { useBeatActions } from '../beatActions'\nimport type { ActionBlockProps } from '../mappings/blocks'\n\n/**\n * `feedback_modal_block` — a CTA drilldown registered like any other drawer\n * block; its content is a MODAL (the dialog portals over the drawer).\n *\n * Flow: the CTA (e.g. Set Up Direct Deposit's \"Not Interested\") opens the\n * \"Can you tell us why?\" survey (Figma `1941:192803`). Submit
|
|
1
|
+
{"version":3,"file":"FeedbackModalActionBlock.es.js","names":[],"sources":["../../../src/insights-v2/actionBlocks/FeedbackModalActionBlock.tsx"],"sourcesContent":["import { useRef } from 'react'\n\nimport { observer } from 'mobx-react-lite'\n\nimport { useGlobalCopyStore, useInsightsV2Store } from '../../common'\nimport { slot } from '../../core'\nimport { buildDynamicCopy } from '../../core/utils/Localization'\nimport FeedbackModal, { type FeedbackModalContent } from '../components/FeedbackModal'\nimport { ANALYTICS_EVENTS_CONFIG, useAnalyticsEvent } from '../analytics'\nimport { useBeatActions } from '../beatActions'\nimport type { ActionBlockProps } from '../mappings/blocks'\n\n/**\n * `feedback_modal_block` — a CTA drilldown registered like any other drawer\n * block; its content is a MODAL (the dialog portals over the drawer).\n *\n * Flow: the CTA (e.g. Set Up Direct Deposit's \"Not Interested\") opens the\n * \"Can you tell us why?\" survey (Figma `1941:192803`). Submit dismisses the insight\n * (`onDismissInsight`), then forwards the selection via `onSubmitFeedback` (source\n * `hide`). A host that can dismiss shows its own confirmation; otherwise the dialog\n * swaps for the success snackbar (Figma `1941:167636`). Closing ends the drawer session.\n *\n * Copy comes from `insights_feed.feedback_modal` in GlobalCopy; the\n * description interpolates the beat's account name (`_1{account_name}`).\n */\nexport const FeedbackModalActionBlock = observer(function FeedbackModalActionBlock({\n beat,\n}: ActionBlockProps) {\n const { closeActionDrawer } = useInsightsV2Store()\n const { onDismissInsight, onFeedbackTextFocus, onSubmitFeedback } = useBeatActions()\n const copyStore = useGlobalCopyStore()\n const fireAnalyticsEvent = useAnalyticsEvent()\n // So a retry does not dismiss twice.\n const hasDismissed = useRef(false)\n\n const insights_payload = beat.insights_payload\n const modalCopy = copyStore.insights_feed?.feedback_modal\n\n if (!insights_payload || !modalCopy) return null\n\n const copy: FeedbackModalContent = {\n title: modalCopy.title,\n description: buildDynamicCopy(\n modalCopy.description,\n // `data` first, the flat name is the earlier shape.\n slot<string>(insights_payload.instance_slot?.data, 'account_name') ??\n insights_payload.instance_slot?.account_name ??\n '',\n ) as string,\n options: Object.values(modalCopy.options ?? {}),\n submitText: modalCopy.submit,\n cancelText: modalCopy.no_thanks,\n closeAriaLabel: modalCopy.close_aria,\n characterLimitLabel: modalCopy.character_limit,\n successMessage: modalCopy.success_message,\n errorMessage: modalCopy.error_message,\n tryAgainText: modalCopy.try_again,\n toastCloseAriaLabel: modalCopy.toast_close_aria,\n }\n\n // As legacy: dismiss first (once), then send the survey. A failed send keeps the beat dismissed and\n // Try Again re-sends only the feedback. Awaited so a rejection drives the error snackbar.\n const handleSubmit = async (option: string, detail?: string) => {\n if (!hasDismissed.current) {\n hasDismissed.current = true\n onDismissInsight?.({ beatGuid: insights_payload.guid, type: 'always' })\n // The reason is the event's value, as legacy.\n fireAnalyticsEvent({ ...ANALYTICS_EVENTS_CONFIG.BEAT_DISMISSED, value: option })\n }\n\n await onSubmitFeedback?.({\n beatGuid: insights_payload.guid,\n source: 'not_interested',\n option,\n detail,\n })\n }\n\n return (\n <FeedbackModal\n copy={copy}\n isOpen={true}\n onClose={() => closeActionDrawer()}\n onSubmit={handleSubmit}\n onTextInputFocus={onFeedbackTextFocus}\n // A host that dismisses shows its own confirmation; the micro widget keeps the snackbar.\n showSuccessMessage={!onDismissInsight}\n />\n )\n})\n"],"mappings":";;;;;;;;;;AAyBA,IAAa,IAA2B,EAAS,SAAkC,EACjF,MAAA,EAAA,GACmB;AACnB,QAAM,EAAE,mBAAA,EAAA,IAAsB,EAAmB,GAC3C,EAAE,kBAAA,GAAkB,qBAAA,GAAqB,kBAAA,EAAA,IAAqB,EAAe,GAC7E,IAAY,EAAmB,GAC/B,IAAqB,EAAkB,GAEvC,IAAe,EAAO,EAAK,GAE3B,IAAmB,EAAK,kBACxB,IAAY,EAAU,eAAe;AAE3C,MAAI,CAAC,KAAoB,CAAC,EAAW,QAAO;AAE5C,QAAM,IAA6B;AAAA,IACjC,OAAO,EAAU;AAAA,IACjB,aAAa,EACX,EAAU,aAEV,EAAa,EAAiB,eAAe,MAAM,cAAc,KAC/D,EAAiB,eAAe,gBAChC,EACJ;AAAA,IACA,SAAS,OAAO,OAAO,EAAU,WAAW,CAAC,CAAC;AAAA,IAC9C,YAAY,EAAU;AAAA,IACtB,YAAY,EAAU;AAAA,IACtB,gBAAgB,EAAU;AAAA,IAC1B,qBAAqB,EAAU;AAAA,IAC/B,gBAAgB,EAAU;AAAA,IAC1B,cAAc,EAAU;AAAA,IACxB,cAAc,EAAU;AAAA,IACxB,qBAAqB,EAAU;AAAA,EACjC;AAoBA,SACE,gBAAA,EAAC,GAAD;AAAA,IACQ,MAAA;AAAA,IACN,QAAQ;AAAA,IACR,SAAA,MAAe,EAAkB;AAAA,IACjC,UArBiB,OAAO,GAAgB,MAAoB;AAC9D,MAAK,EAAa,YAChB,EAAa,UAAU,IACvB,IAAmB;AAAA,QAAE,UAAU,EAAiB;AAAA,QAAM,MAAM;AAAA,MAAS,CAAC,GAEtE,EAAmB;AAAA,QAAE,GAAG,EAAwB;AAAA,QAAgB,OAAO;AAAA,MAAO,CAAC,IAGjF,MAAM,IAAmB;AAAA,QACvB,UAAU,EAAiB;AAAA,QAC3B,QAAQ;AAAA,QACR,QAAA;AAAA,QACA,QAAA;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IAQI,kBAAkB;AAAA,IAElB,oBAAoB,CAAC;AAAA,EACtB,CAAA;AAEL,CAAC"}
|
|
@@ -4,6 +4,8 @@ type Resolvable = string | ((beat: Beat) => string);
|
|
|
4
4
|
export interface AnalyticsEventConfigEntry {
|
|
5
5
|
category?: Resolvable;
|
|
6
6
|
action?: Resolvable;
|
|
7
|
+
/** Detail stored with the Firefly event, e.g. a survey reason. */
|
|
8
|
+
value?: Resolvable;
|
|
7
9
|
postHog?: {
|
|
8
10
|
eventName: string;
|
|
9
11
|
properties?: (beat: Beat) => Record<string, unknown>;
|
|
@@ -22,6 +24,10 @@ export declare const ANALYTICS_EVENTS_CONFIG: {
|
|
|
22
24
|
readonly category: "Beat Interaction";
|
|
23
25
|
readonly action: "First Time Primary Action Selected";
|
|
24
26
|
};
|
|
27
|
+
readonly BEAT_DISMISSED: {
|
|
28
|
+
readonly category: "Beat Interaction";
|
|
29
|
+
readonly action: "Beat Dismissed";
|
|
30
|
+
};
|
|
25
31
|
readonly CHART_BAR_CLICKED: {
|
|
26
32
|
readonly category: "Beat Chart";
|
|
27
33
|
readonly action: (beat: Beat) => string;
|
|
@@ -11,6 +11,10 @@ var t = (e) => e?.replace(/([A-Z]+)/g, " $1")?.replace(/^ /, "") ?? "", a = {
|
|
|
11
11
|
category: "Beat Interaction",
|
|
12
12
|
action: "First Time Primary Action Selected"
|
|
13
13
|
},
|
|
14
|
+
BEAT_DISMISSED: {
|
|
15
|
+
category: "Beat Interaction",
|
|
16
|
+
action: "Beat Dismissed"
|
|
17
|
+
},
|
|
14
18
|
CHART_BAR_CLICKED: {
|
|
15
19
|
category: "Beat Chart",
|
|
16
20
|
action: (e) => `${t(e.template)} - Bar Clicked`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyticsEventsConfig.es.js","names":[],"sources":["../../../src/insights-v2/analytics/analyticsEventsConfig.ts"],"sourcesContent":["import type { Beat } from '../../core'\n\n// PascalCase template to label, ported from Pulse.\nexport const sentenceCaseTemplate = (template?: string | null): string =>\n template?.replace(/([A-Z]+)/g, ' $1')?.replace(/^ /, '') ?? ''\n\n// Fixed or beat-computed value.\ntype Resolvable = string | ((beat: Beat) => string)\n\n// Source of truth for insights-v2 analytics events. Mirrors Pulse's strings.\n// Entry has a Firefly half (action/category) and/or a postHog half.\nexport interface AnalyticsEventConfigEntry {\n category?: Resolvable\n action?: Resolvable\n postHog?: {\n eventName: string\n properties?: (beat: Beat) => Record<string, unknown>\n }\n}\n\nexport const ANALYTICS_EVENTS_CONFIG = {\n // Primary/secondary CTA click, fired via sendCtaAnalytics.\n PRIMARY_ACTION_SELECTED: {\n category: 'Beat Interaction',\n action: 'Primary Action Selected',\n },\n SECONDARY_ACTION_SELECTED: {\n category: 'Beat Interaction',\n action: 'Secondary Action Selected',\n },\n // Fires once, gated on !beat.cta_clicked_at.\n FIRST_TIME_PRIMARY_ACTION_SELECTED: {\n category: 'Beat Interaction',\n action: 'First Time Primary Action Selected',\n },\n\n // Bar click on the card's inline chart.\n CHART_BAR_CLICKED: {\n category: 'Beat Chart',\n action: (beat) => `${sentenceCaseTemplate(beat.template)} - Bar Clicked`,\n },\n // Bar click inside the drill-down drawer.\n DRAWER_CHART_BAR_CLICKED: {\n category: 'Drawer Chart',\n action: (beat) => `${sentenceCaseTemplate(beat.template)} - Bar Clicked`,\n },\n // Month/tab change inside the drill-down drawer.\n TAB_SELECTED: {\n category: 'Drawer Chart',\n action: (beat) => `${sentenceCaseTemplate(beat.template)} - Month Tab Selected`,\n },\n\n // LowAccountBalance threshold dialog.\n EDIT_INSIGHT_THRESHOLD_SAVE: {\n category: 'User Configurable Settings',\n action: 'Edit Insight Threshold Save',\n },\n EDIT_INSIGHT_THRESHOLD_CANCELED: {\n category: 'User Configurable Settings',\n action: 'Edit Insight Threshold Canceled',\n },\n EDIT_INSIGHT_THRESHOLD_INPUT_SELECTED: {\n category: 'User Configurable Settings',\n action: 'Edit Insight Threshold Input Selected',\n },\n\n // SavingsOpportunityV2 safety-net dialog.\n EDIT_SAFETY_NET_SAVE: {\n category: 'Safety Net',\n action: 'Edit Safety Net',\n },\n // Ported verbatim from Pulse (uses '=' not '-').\n EDIT_SAFETY_NET_CANCEL: {\n category: 'Safety Net',\n action: (beat) => `${sentenceCaseTemplate(beat.template)} = Edit Safety Net - Cancel`,\n },\n\n // Designate Emergency Savings Account (picker pick, Save, Open a Savings Account). Pulse's strings.\n EMERGENCY_SAVINGS_ACCT_SELECTED: {\n category: 'Emergency Savings',\n action: 'Designate Emergency Savings Account Selected',\n },\n EMERGENCY_SAVINGS_ACCT_SAVED: {\n category: 'Emergency Savings',\n action: 'Designate Emergency Savings Account Saved',\n },\n EMERGENCY_SAVINGS_ACCT_CREATED: {\n category: 'Emergency Savings',\n action: 'Designate Emergency Savings Account - Savings Account Created',\n },\n\n // Connect drawer opened. PostHog-only.\n OPENED_CONNECT_DRAWER: {\n postHog: {\n eventName: 'opened_connect_drawer',\n properties: (beat) => ({ beat_guid: beat.guid, template: beat.template }),\n },\n },\n} as const satisfies Record<string, AnalyticsEventConfigEntry>\n"],"mappings":"AAGA,IAAa,IAAA,CAAwB,MACnC,GAAU,QAAQ,aAAa,KAAK,GAAG,QAAQ,MAAM,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"analyticsEventsConfig.es.js","names":[],"sources":["../../../src/insights-v2/analytics/analyticsEventsConfig.ts"],"sourcesContent":["import type { Beat } from '../../core'\n\n// PascalCase template to label, ported from Pulse.\nexport const sentenceCaseTemplate = (template?: string | null): string =>\n template?.replace(/([A-Z]+)/g, ' $1')?.replace(/^ /, '') ?? ''\n\n// Fixed or beat-computed value.\ntype Resolvable = string | ((beat: Beat) => string)\n\n// Source of truth for insights-v2 analytics events. Mirrors Pulse's strings.\n// Entry has a Firefly half (action/category) and/or a postHog half.\nexport interface AnalyticsEventConfigEntry {\n category?: Resolvable\n action?: Resolvable\n /** Detail stored with the Firefly event, e.g. a survey reason. */\n value?: Resolvable\n postHog?: {\n eventName: string\n properties?: (beat: Beat) => Record<string, unknown>\n }\n}\n\nexport const ANALYTICS_EVENTS_CONFIG = {\n // Primary/secondary CTA click, fired via sendCtaAnalytics.\n PRIMARY_ACTION_SELECTED: {\n category: 'Beat Interaction',\n action: 'Primary Action Selected',\n },\n SECONDARY_ACTION_SELECTED: {\n category: 'Beat Interaction',\n action: 'Secondary Action Selected',\n },\n // Fires once, gated on !beat.cta_clicked_at.\n FIRST_TIME_PRIMARY_ACTION_SELECTED: {\n category: 'Beat Interaction',\n action: 'First Time Primary Action Selected',\n },\n\n // \"Not Interested\" survey submitted; the call site sets the picked reason as `value`.\n BEAT_DISMISSED: {\n category: 'Beat Interaction',\n action: 'Beat Dismissed',\n },\n\n // Bar click on the card's inline chart.\n CHART_BAR_CLICKED: {\n category: 'Beat Chart',\n action: (beat) => `${sentenceCaseTemplate(beat.template)} - Bar Clicked`,\n },\n // Bar click inside the drill-down drawer.\n DRAWER_CHART_BAR_CLICKED: {\n category: 'Drawer Chart',\n action: (beat) => `${sentenceCaseTemplate(beat.template)} - Bar Clicked`,\n },\n // Month/tab change inside the drill-down drawer.\n TAB_SELECTED: {\n category: 'Drawer Chart',\n action: (beat) => `${sentenceCaseTemplate(beat.template)} - Month Tab Selected`,\n },\n\n // LowAccountBalance threshold dialog.\n EDIT_INSIGHT_THRESHOLD_SAVE: {\n category: 'User Configurable Settings',\n action: 'Edit Insight Threshold Save',\n },\n EDIT_INSIGHT_THRESHOLD_CANCELED: {\n category: 'User Configurable Settings',\n action: 'Edit Insight Threshold Canceled',\n },\n EDIT_INSIGHT_THRESHOLD_INPUT_SELECTED: {\n category: 'User Configurable Settings',\n action: 'Edit Insight Threshold Input Selected',\n },\n\n // SavingsOpportunityV2 safety-net dialog.\n EDIT_SAFETY_NET_SAVE: {\n category: 'Safety Net',\n action: 'Edit Safety Net',\n },\n // Ported verbatim from Pulse (uses '=' not '-').\n EDIT_SAFETY_NET_CANCEL: {\n category: 'Safety Net',\n action: (beat) => `${sentenceCaseTemplate(beat.template)} = Edit Safety Net - Cancel`,\n },\n\n // Designate Emergency Savings Account (picker pick, Save, Open a Savings Account). Pulse's strings.\n EMERGENCY_SAVINGS_ACCT_SELECTED: {\n category: 'Emergency Savings',\n action: 'Designate Emergency Savings Account Selected',\n },\n EMERGENCY_SAVINGS_ACCT_SAVED: {\n category: 'Emergency Savings',\n action: 'Designate Emergency Savings Account Saved',\n },\n EMERGENCY_SAVINGS_ACCT_CREATED: {\n category: 'Emergency Savings',\n action: 'Designate Emergency Savings Account - Savings Account Created',\n },\n\n // Connect drawer opened. PostHog-only.\n OPENED_CONNECT_DRAWER: {\n postHog: {\n eventName: 'opened_connect_drawer',\n properties: (beat) => ({ beat_guid: beat.guid, template: beat.template }),\n },\n },\n} as const satisfies Record<string, AnalyticsEventConfigEntry>\n"],"mappings":"AAGA,IAAa,IAAA,CAAwB,MACnC,GAAU,QAAQ,aAAa,KAAK,GAAG,QAAQ,MAAM,EAAE,KAAK,IAkBjD,IAA0B;AAAA,EAErC,yBAAyB;AAAA,IACvB,UAAU;AAAA,IACV,QAAQ;AAAA,EACV;AAAA,EACA,2BAA2B;AAAA,IACzB,UAAU;AAAA,IACV,QAAQ;AAAA,EACV;AAAA,EAEA,oCAAoC;AAAA,IAClC,UAAU;AAAA,IACV,QAAQ;AAAA,EACV;AAAA,EAGA,gBAAgB;AAAA,IACd,UAAU;AAAA,IACV,QAAQ;AAAA,EACV;AAAA,EAGA,mBAAmB;AAAA,IACjB,UAAU;AAAA,IACV,QAAA,CAAS,MAAS,GAAG,EAAqB,EAAK,QAAQ,CAAA;AAAA,EACzD;AAAA,EAEA,0BAA0B;AAAA,IACxB,UAAU;AAAA,IACV,QAAA,CAAS,MAAS,GAAG,EAAqB,EAAK,QAAQ,CAAA;AAAA,EACzD;AAAA,EAEA,cAAc;AAAA,IACZ,UAAU;AAAA,IACV,QAAA,CAAS,MAAS,GAAG,EAAqB,EAAK,QAAQ,CAAA;AAAA,EACzD;AAAA,EAGA,6BAA6B;AAAA,IAC3B,UAAU;AAAA,IACV,QAAQ;AAAA,EACV;AAAA,EACA,iCAAiC;AAAA,IAC/B,UAAU;AAAA,IACV,QAAQ;AAAA,EACV;AAAA,EACA,uCAAuC;AAAA,IACrC,UAAU;AAAA,IACV,QAAQ;AAAA,EACV;AAAA,EAGA,sBAAsB;AAAA,IACpB,UAAU;AAAA,IACV,QAAQ;AAAA,EACV;AAAA,EAEA,wBAAwB;AAAA,IACtB,UAAU;AAAA,IACV,QAAA,CAAS,MAAS,GAAG,EAAqB,EAAK,QAAQ,CAAA;AAAA,EACzD;AAAA,EAGA,iCAAiC;AAAA,IAC/B,UAAU;AAAA,IACV,QAAQ;AAAA,EACV;AAAA,EACA,8BAA8B;AAAA,IAC5B,UAAU;AAAA,IACV,QAAQ;AAAA,EACV;AAAA,EACA,gCAAgC;AAAA,IAC9B,UAAU;AAAA,IACV,QAAQ;AAAA,EACV;AAAA,EAGA,uBAAuB,EACrB,SAAS;AAAA,IACP,WAAW;AAAA,IACX,YAAA,CAAa,OAAU;AAAA,MAAE,WAAW,EAAK;AAAA,MAAM,UAAU,EAAK;AAAA,IAAS;AAAA,EACzE,EACF;AACF"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { sentenceCaseTemplate as
|
|
2
|
-
var
|
|
3
|
-
const o =
|
|
1
|
+
import { sentenceCaseTemplate as a } from "./analyticsEventsConfig.es.js";
|
|
2
|
+
var s = (e, t) => typeof e == "function" ? e(t) : e, l = (e, t) => {
|
|
3
|
+
const o = s(e.action, t), r = s(e.category, t), p = s(e.value, t);
|
|
4
4
|
return {
|
|
5
5
|
...o && { action: o },
|
|
6
6
|
...r && { category: r },
|
|
7
|
-
...(o || r) && { label:
|
|
7
|
+
...(o || r) && { label: a(t.template) },
|
|
8
|
+
...p && { value: p },
|
|
8
9
|
...e.postHog && { postHog: {
|
|
9
10
|
eventName: e.postHog.eventName,
|
|
10
11
|
properties: e.postHog.properties?.(t) ?? {}
|
|
@@ -12,8 +13,8 @@ var p = (e, t) => typeof e == "function" ? e(t) : e, a = (e, t) => {
|
|
|
12
13
|
};
|
|
13
14
|
};
|
|
14
15
|
export {
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
l as resolveAnalyticsEvent,
|
|
17
|
+
a as sentenceCaseTemplate
|
|
17
18
|
};
|
|
18
19
|
|
|
19
20
|
//# sourceMappingURL=resolveAnalyticsEvent.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveAnalyticsEvent.es.js","names":[],"sources":["../../../src/insights-v2/analytics/resolveAnalyticsEvent.ts"],"sourcesContent":["import type { AnalyticsEventPayload } from '../beatActions'\nimport type { Beat } from '../../core'\nimport { sentenceCaseTemplate, type AnalyticsEventConfigEntry } from './analyticsEventsConfig'\n\nexport { sentenceCaseTemplate }\n\nconst resolve = (\n value: string | ((beat: Beat) => string) | undefined,\n beat: Beat,\n): string | undefined => (typeof value === 'function' ? value(beat) : value)\n\n// Resolves a catalogue entry (e.g. ANALYTICS_EVENTS_CONFIG.PRIMARY_ACTION_SELECTED) + beat into\n// a final analytics payload. Takes the entry directly, not a lookup key: the call site already\n// has the entry via property access, so there is nothing to look up and nothing to mistype.\nexport const resolveAnalyticsEvent = (\n config: AnalyticsEventConfigEntry,\n beat: Beat,\n): AnalyticsEventPayload => {\n const action = resolve(config.action, beat)\n const category = resolve(config.category, beat)\n\n return {\n ...(action && { action }),\n ...(category && { category }),\n ...((action || category) && { label: sentenceCaseTemplate(beat.template) }),\n ...(config.postHog && {\n postHog: {\n eventName: config.postHog.eventName,\n properties: config.postHog.properties?.(beat) ?? {},\n },\n }),\n }\n}\n"],"mappings":";AAMA,IAAM,IAAA,CACJ,GACA,MACwB,OAAO,KAAU,aAAa,EAAM,CAAI,IAAI,GAKzD,IAAA,CACX,GACA,MAC0B;AAC1B,QAAM,IAAS,EAAQ,EAAO,QAAQ,CAAI,GACpC,IAAW,EAAQ,EAAO,UAAU,CAAI;
|
|
1
|
+
{"version":3,"file":"resolveAnalyticsEvent.es.js","names":[],"sources":["../../../src/insights-v2/analytics/resolveAnalyticsEvent.ts"],"sourcesContent":["import type { AnalyticsEventPayload } from '../beatActions'\nimport type { Beat } from '../../core'\nimport { sentenceCaseTemplate, type AnalyticsEventConfigEntry } from './analyticsEventsConfig'\n\nexport { sentenceCaseTemplate }\n\nconst resolve = (\n value: string | ((beat: Beat) => string) | undefined,\n beat: Beat,\n): string | undefined => (typeof value === 'function' ? value(beat) : value)\n\n// Resolves a catalogue entry (e.g. ANALYTICS_EVENTS_CONFIG.PRIMARY_ACTION_SELECTED) + beat into\n// a final analytics payload. Takes the entry directly, not a lookup key: the call site already\n// has the entry via property access, so there is nothing to look up and nothing to mistype.\nexport const resolveAnalyticsEvent = (\n config: AnalyticsEventConfigEntry,\n beat: Beat,\n): AnalyticsEventPayload => {\n const action = resolve(config.action, beat)\n const category = resolve(config.category, beat)\n const value = resolve(config.value, beat)\n\n return {\n ...(action && { action }),\n ...(category && { category }),\n ...((action || category) && { label: sentenceCaseTemplate(beat.template) }),\n ...(value && { value }),\n ...(config.postHog && {\n postHog: {\n eventName: config.postHog.eventName,\n properties: config.postHog.properties?.(beat) ?? {},\n },\n }),\n }\n}\n"],"mappings":";AAMA,IAAM,IAAA,CACJ,GACA,MACwB,OAAO,KAAU,aAAa,EAAM,CAAI,IAAI,GAKzD,IAAA,CACX,GACA,MAC0B;AAC1B,QAAM,IAAS,EAAQ,EAAO,QAAQ,CAAI,GACpC,IAAW,EAAQ,EAAO,UAAU,CAAI,GACxC,IAAQ,EAAQ,EAAO,OAAO,CAAI;AAExC,SAAO;AAAA,IACL,GAAI,KAAU,EAAE,QAAA,EAAO;AAAA,IACvB,GAAI,KAAY,EAAE,UAAA,EAAS;AAAA,IAC3B,IAAK,KAAU,MAAa,EAAE,OAAO,EAAqB,EAAK,QAAQ,EAAE;AAAA,IACzE,GAAI,KAAS,EAAE,OAAA,EAAM;AAAA,IACrB,GAAI,EAAO,WAAW,EACpB,SAAS;AAAA,MACP,WAAW,EAAO,QAAQ;AAAA,MAC1B,YAAY,EAAO,QAAQ,aAAa,CAAI,KAAK,CAAC;AAAA,IACpD,EACF;AAAA,EACF;AACF"}
|
|
@@ -14,7 +14,7 @@ export interface UpdateParams {
|
|
|
14
14
|
}
|
|
15
15
|
export interface FeedbackParams {
|
|
16
16
|
beatGuid: string;
|
|
17
|
-
source: InsightRating | 'hide' | 'cta';
|
|
17
|
+
source: InsightRating | 'hide' | 'cta' | 'not_interested';
|
|
18
18
|
option: string;
|
|
19
19
|
detail?: string;
|
|
20
20
|
}
|
|
@@ -26,6 +26,8 @@ export interface AnalyticsEventPayload {
|
|
|
26
26
|
action?: string;
|
|
27
27
|
category?: string;
|
|
28
28
|
label?: string;
|
|
29
|
+
/** Detail stored with the Firefly event, e.g. a survey reason. */
|
|
30
|
+
value?: string;
|
|
29
31
|
postHog?: {
|
|
30
32
|
eventName: string;
|
|
31
33
|
properties?: Record<string, unknown>;
|
|
@@ -46,7 +48,10 @@ export interface BeatActions {
|
|
|
46
48
|
onUndoDismiss?: (params: {
|
|
47
49
|
beatGuid: string;
|
|
48
50
|
}) => void;
|
|
49
|
-
|
|
51
|
+
/** The survey for `variant` opened (the hide survey, from "Leave feedback"). */
|
|
52
|
+
onFeedbackSurveyShown?: (variant: InsightRating | 'hide') => void;
|
|
53
|
+
/** The survey closed unsent; `variant` says which one it was. */
|
|
54
|
+
onFeedbackDialogClose?: (reason: FeedbackDialogCloseReason, variant?: InsightRating | 'hide') => void;
|
|
50
55
|
onFeedbackDialogBack?: () => void;
|
|
51
56
|
onFeedbackTextFocus?: () => void;
|
|
52
57
|
onAnalyticsEvent?: (payload: AnalyticsEventPayload) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"beatActions.es.js","names":[],"sources":["../../src/insights-v2/beatActions.tsx"],"sourcesContent":["import { createContext, useContext, type ReactNode } from 'react'\n\nimport type { Beat } from '../core'\nimport type { DismissType } from './components/DismissInsightDialog'\nimport type { FeedbackDialogCloseReason } from './components/FeedbackDialog'\n\nexport type InsightMenuAction = 'helpful' | 'not_helpful' | 'hide'\nexport type InsightRating = 'helpful' | 'not_helpful'\n\nexport interface MenuActionHandlers {\n onAction: (action: InsightMenuAction) => void\n onOpen?: () => void\n disabled?: boolean\n}\n\nexport interface UpdateParams {\n beatGuid: string\n}\n\nexport interface FeedbackParams {\n beatGuid: string\n source: InsightRating | 'hide' | 'cta'\n option: string\n detail?: string\n}\n\nexport interface DismissParams {\n beatGuid: string\n type: DismissType\n}\n\n// Raw analytics payload for the host.\nexport interface AnalyticsEventPayload {\n action?: string\n category?: string\n label?: string\n postHog?: {\n eventName: string\n properties?: Record<string, unknown>\n }\n}\n/** A host-side CTA effect. See ctaActions/README.md. */\nexport interface CtaActionParams {\n beatGuid: string\n name: string\n params?: Record<string, unknown>\n}\n\n/** Host callbacks for a beat card. */\nexport interface BeatActions {\n onMenuAction?: MenuActionHandlers\n onUpdate?: (params: UpdateParams) => void\n onSubmitFeedback?: (params: FeedbackParams) => void | Promise<void>\n onDismissInsight?: (params: DismissParams) => void\n onUndoDismiss?: (params: { beatGuid: string }) => void\n onFeedbackDialogClose?: (reason: FeedbackDialogCloseReason) => void\n onFeedbackDialogBack?: () => void\n onFeedbackTextFocus?: () => void\n // Raw analytics callback; use useAnalyticsEvent() instead.\n onAnalyticsEvent?: (payload: AnalyticsEventPayload) => void\n // Host's contact-support flow for a contact_support_block CTA.\n onContactSupport?: () => void\n onCtaAction?: (params: CtaActionParams) => Promise<void> | void\n}\n\n// BeatActions plus beat, for useAnalyticsEvent().\ninterface BeatActionsContextValue extends BeatActions {\n beat?: Beat\n}\n\nconst BeatActionsContext = createContext<BeatActionsContextValue>({})\n\nexport const BeatActionsProvider = ({\n value,\n children,\n}: {\n value: BeatActionsContextValue\n children: ReactNode\n}) => <BeatActionsContext.Provider value={value}>{children}</BeatActionsContext.Provider>\n\nexport const useBeatActions = () => useContext(BeatActionsContext)\n"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"beatActions.es.js","names":[],"sources":["../../src/insights-v2/beatActions.tsx"],"sourcesContent":["import { createContext, useContext, type ReactNode } from 'react'\n\nimport type { Beat } from '../core'\nimport type { DismissType } from './components/DismissInsightDialog'\nimport type { FeedbackDialogCloseReason } from './components/FeedbackDialog'\n\nexport type InsightMenuAction = 'helpful' | 'not_helpful' | 'hide'\nexport type InsightRating = 'helpful' | 'not_helpful'\n\nexport interface MenuActionHandlers {\n onAction: (action: InsightMenuAction) => void\n onOpen?: () => void\n disabled?: boolean\n}\n\nexport interface UpdateParams {\n beatGuid: string\n}\n\nexport interface FeedbackParams {\n beatGuid: string\n source: InsightRating | 'hide' | 'cta' | 'not_interested'\n option: string\n detail?: string\n}\n\nexport interface DismissParams {\n beatGuid: string\n type: DismissType\n}\n\n// Raw analytics payload for the host.\nexport interface AnalyticsEventPayload {\n action?: string\n category?: string\n label?: string\n /** Detail stored with the Firefly event, e.g. a survey reason. */\n value?: string\n postHog?: {\n eventName: string\n properties?: Record<string, unknown>\n }\n}\n/** A host-side CTA effect. See ctaActions/README.md. */\nexport interface CtaActionParams {\n beatGuid: string\n name: string\n params?: Record<string, unknown>\n}\n\n/** Host callbacks for a beat card. */\nexport interface BeatActions {\n onMenuAction?: MenuActionHandlers\n onUpdate?: (params: UpdateParams) => void\n onSubmitFeedback?: (params: FeedbackParams) => void | Promise<void>\n onDismissInsight?: (params: DismissParams) => void\n onUndoDismiss?: (params: { beatGuid: string }) => void\n /** The survey for `variant` opened (the hide survey, from \"Leave feedback\"). */\n onFeedbackSurveyShown?: (variant: InsightRating | 'hide') => void\n /** The survey closed unsent; `variant` says which one it was. */\n onFeedbackDialogClose?: (\n reason: FeedbackDialogCloseReason,\n variant?: InsightRating | 'hide',\n ) => void\n onFeedbackDialogBack?: () => void\n onFeedbackTextFocus?: () => void\n // Raw analytics callback; use useAnalyticsEvent() instead.\n onAnalyticsEvent?: (payload: AnalyticsEventPayload) => void\n // Host's contact-support flow for a contact_support_block CTA.\n onContactSupport?: () => void\n onCtaAction?: (params: CtaActionParams) => Promise<void> | void\n}\n\n// BeatActions plus beat, for useAnalyticsEvent().\ninterface BeatActionsContextValue extends BeatActions {\n beat?: Beat\n}\n\nconst BeatActionsContext = createContext<BeatActionsContextValue>({})\n\nexport const BeatActionsProvider = ({\n value,\n children,\n}: {\n value: BeatActionsContextValue\n children: ReactNode\n}) => <BeatActionsContext.Provider value={value}>{children}</BeatActionsContext.Provider>\n\nexport const useBeatActions = () => useContext(BeatActionsContext)\n"],"mappings":";;AA8EA,IAAM,IAAqB,EAAuC,CAAC,CAAC,GAEvD,IAAA,CAAuB,EAClC,OAAA,GACA,UAAA,EAAA,MAII,gBAAA,EAAC,EAAmB,UAApB;AAAA,EAAoC,OAAA;AAAA,EAAQ,UAAA;AAAsC,CAAA,GAE3E,IAAA,MAAuB,EAAW,CAAkB"}
|
package/dist/insights-v2/blocks/ComponentBlocks/DetailedAccountBlock/DetailedAccountBlock.es.js
CHANGED
|
@@ -1,28 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { buildDynamicCopy as l } from "../../../../core/utils/Localization.es.js";
|
|
2
|
+
import { GlobalDataContext as u } from "../../../../common/context/GlobalDataProvider.es.js";
|
|
3
|
+
import { slot as s } from "../../../../core/types/Insights.es.js";
|
|
4
|
+
import c from "../../../components/LogoFromGuid.es.js";
|
|
5
|
+
import { resolveVariantConfig as d } from "../../resolveVariantConfig.es.js";
|
|
6
|
+
import g from "../../../components/DirectDepositCard.es.js";
|
|
7
|
+
import { detailedAccountVariant as p, getLayoutConfig as f } from "./layout.es.js";
|
|
8
|
+
import { useContext as _ } from "react";
|
|
9
|
+
import { jsx as m } from "react/jsx-runtime";
|
|
10
|
+
import { useTheme as v } from "@mui/material/styles";
|
|
11
|
+
var n = (o, r) => s(o.data, r) ?? o[r], y = (o, r) => {
|
|
12
|
+
const t = s(o.data, "logo"), e = n(o, "institution_guid"), a = t?.alt ?? n(o, "institution_name"), i = t ?? (e ? {
|
|
13
|
+
guid: e,
|
|
14
|
+
alt: a ?? e
|
|
15
|
+
} : void 0);
|
|
16
|
+
return !i || !a ? i : {
|
|
17
|
+
...i,
|
|
18
|
+
alt: r ? l(r, a) : a
|
|
19
|
+
};
|
|
20
|
+
}, G = ({ payload: o }) => {
|
|
21
|
+
const r = v(), { instance_slot: t } = o, e = _(u)?.globalStore.copyStore.copy.insights_feed?.general?.institution_Logo, a = y(t, e), i = d(f(r), t.variant, p.Neutral, "DetailedAccountBlock");
|
|
22
|
+
return /* @__PURE__ */ m(g, {
|
|
23
|
+
...i,
|
|
24
|
+
logo: a?.guid ? /* @__PURE__ */ m(c, {
|
|
25
|
+
logo: a,
|
|
17
26
|
size: 48
|
|
18
27
|
}) : null,
|
|
19
|
-
name:
|
|
20
|
-
statusLabel:
|
|
21
|
-
subtitle: n
|
|
28
|
+
name: n(t, "account_name"),
|
|
29
|
+
statusLabel: n(t, "status_text"),
|
|
30
|
+
subtitle: n(t, "account_type")
|
|
22
31
|
});
|
|
23
32
|
};
|
|
24
33
|
export {
|
|
25
|
-
|
|
34
|
+
G as default
|
|
26
35
|
};
|
|
27
36
|
|
|
28
37
|
//# sourceMappingURL=DetailedAccountBlock.es.js.map
|
package/dist/insights-v2/blocks/ComponentBlocks/DetailedAccountBlock/DetailedAccountBlock.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DetailedAccountBlock.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ComponentBlocks/DetailedAccountBlock/DetailedAccountBlock.tsx"],"sourcesContent":["import { useTheme } from '@mui/material/styles'\n\nimport { slot, type InsightsPayload, type LogoRef } from '../../../../core'\nimport DirectDepositCard from '../../../components/DirectDepositCard'\nimport LogoFromGuid from '../../../components/LogoFromGuid'\n\nimport { resolveVariantConfig } from '../../resolveVariantConfig'\n\nimport { detailedAccountVariant, getLayoutConfig } from './layout'\n\ninterface DetailedAccountBlockProps {\n payload: InsightsPayload\n}\n\nconst
|
|
1
|
+
{"version":3,"file":"DetailedAccountBlock.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ComponentBlocks/DetailedAccountBlock/DetailedAccountBlock.tsx"],"sourcesContent":["import { useContext } from 'react'\n\nimport { useTheme } from '@mui/material/styles'\n\nimport { GlobalDataContext } from '../../../../common/context/GlobalDataProvider'\nimport { slot, type InsightsPayload, type LogoRef } from '../../../../core'\nimport { buildDynamicCopy } from '../../../../core/utils/Localization'\nimport DirectDepositCard from '../../../components/DirectDepositCard'\nimport LogoFromGuid from '../../../components/LogoFromGuid'\n\nimport { resolveVariantConfig } from '../../resolveVariantConfig'\n\nimport { detailedAccountVariant, getLayoutConfig } from './layout'\n\ninterface DetailedAccountBlockProps {\n payload: InsightsPayload\n}\n\ntype InstanceSlot = InsightsPayload['instance_slot']\n\n/** `data` first; the flat field is the earlier shape. */\nconst readFact = (instanceSlot: InstanceSlot, name: keyof InstanceSlot): string | undefined =>\n slot<string>(instanceSlot.data, name) ?? (instanceSlot[name] as string | undefined)\n\n/** The slot's logo, else one built from the guid; the alt is worded as legacy (\"{institution} Institution Logo\"). */\nconst resolveLogo = (instanceSlot: InstanceSlot, altCopy?: string): LogoRef | undefined => {\n const dataLogo = slot<LogoRef>(instanceSlot.data, 'logo')\n const guid = readFact(instanceSlot, 'institution_guid')\n const name = dataLogo?.alt ?? readFact(instanceSlot, 'institution_name')\n\n const logo = dataLogo ?? (guid ? { guid, alt: name ?? guid } : undefined)\n if (!logo || !name) return logo\n\n return { ...logo, alt: altCopy ? (buildDynamicCopy(altCopy, name) as string) : name }\n}\n\nconst DetailedAccountBlock = ({ payload }: DetailedAccountBlockProps) => {\n const theme = useTheme()\n const { instance_slot } = payload\n // Optional: the micro widget renders this block without a GlobalDataProvider.\n const altCopy =\n useContext(GlobalDataContext)?.globalStore.copyStore.copy.insights_feed?.general\n ?.institution_Logo\n const logo = resolveLogo(instance_slot, altCopy)\n const layout = resolveVariantConfig(\n getLayoutConfig(theme),\n instance_slot.variant,\n detailedAccountVariant.Neutral,\n 'DetailedAccountBlock',\n )\n\n return (\n <DirectDepositCard\n {...layout}\n logo={logo?.guid ? <LogoFromGuid logo={logo} size={48} /> : null}\n name={readFact(instance_slot, 'account_name')}\n statusLabel={readFact(instance_slot, 'status_text')}\n subtitle={readFact(instance_slot, 'account_type')}\n />\n )\n}\n\nexport default DetailedAccountBlock\n"],"mappings":";;;;;;;;;;AAqBA,IAAM,IAAA,CAAY,GAA4B,MAC5C,EAAa,EAAa,MAAM,CAAI,KAAM,EAAa,CAAA,GAGnD,IAAA,CAAe,GAA4B,MAA0C;AACzF,QAAM,IAAW,EAAc,EAAa,MAAM,MAAM,GAClD,IAAO,EAAS,GAAc,kBAAkB,GAChD,IAAO,GAAU,OAAO,EAAS,GAAc,kBAAkB,GAEjE,IAAO,MAAa,IAAO;AAAA,IAAE,MAAA;AAAA,IAAM,KAAK,KAAQ;AAAA,EAAK,IAAI;AAC/D,SAAI,CAAC,KAAQ,CAAC,IAAa,IAEpB;AAAA,IAAE,GAAG;AAAA,IAAM,KAAK,IAAW,EAAiB,GAAS,CAAI,IAAe;AAAA,EAAK;AACtF,GAEM,IAAA,CAAwB,EAAE,SAAA,EAAA,MAAyC;AACvE,QAAM,IAAQ,EAAS,GACjB,EAAE,eAAA,EAAA,IAAkB,GAEpB,IACJ,EAAW,CAAiB,GAAG,YAAY,UAAU,KAAK,eAAe,SACrE,kBACA,IAAO,EAAY,GAAe,CAAO,GACzC,IAAS,EACb,EAAgB,CAAK,GACrB,EAAc,SACd,EAAuB,SACvB,sBACF;AAEA,SACE,gBAAA,EAAC,GAAD;AAAA,IACE,GAAI;AAAA,IACJ,MAAM,GAAM,OAAO,gBAAA,EAAC,GAAD;AAAA,MAAoB,MAAA;AAAA,MAAM,MAAM;AAAA,IAAK,CAAA,IAAI;AAAA,IAC5D,MAAM,EAAS,GAAe,cAAc;AAAA,IAC5C,aAAa,EAAS,GAAe,aAAa;AAAA,IAClD,UAAU,EAAS,GAAe,cAAc;AAAA,EACjD,CAAA;AAEL"}
|
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
import { WARM_LIME_ACCENT_GRADIENT as d } from "../../../components/celebrationGradients.es.js";
|
|
2
|
-
var
|
|
2
|
+
var t = {
|
|
3
3
|
Neutral: "detailed_neutral",
|
|
4
4
|
Primary: "detailed_primary",
|
|
5
5
|
Success: "detailed_success",
|
|
6
6
|
Celebration: "detailed_celebration"
|
|
7
|
-
},
|
|
7
|
+
}, a = {
|
|
8
8
|
SetUpDirectDeposit: "set_up_direct_deposit",
|
|
9
9
|
DirectDepositComplete: "direct_deposit_complete",
|
|
10
10
|
MissingInterestRate: "missing_interest_rate",
|
|
11
11
|
InterestRateAdded: "interest_rate_added"
|
|
12
|
-
}, s = /* @__PURE__ */ new Set([...Object.values(
|
|
12
|
+
}, s = /* @__PURE__ */ new Set([...Object.values(t), ...Object.values(a)]), _ = (e) => e != null && s.has(e), g = {
|
|
13
13
|
light: "linear-gradient(180deg, #A0B9F8 0%, #2C64EF 100%)",
|
|
14
14
|
dark: "linear-gradient(180deg, #1F46A7 0%, #6B92F4 100%)"
|
|
15
15
|
}, p = {
|
|
16
16
|
light: "linear-gradient(180deg, #94C9B7 0%, #12875E 100%)",
|
|
17
17
|
dark: "linear-gradient(180deg, #0D5F42 0%, #59AB8E 100%)"
|
|
18
|
-
}, b = {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
}, b = (e) => {
|
|
19
|
+
const r = e === "dark" ? "grey.800" : "grey.100";
|
|
20
|
+
return {
|
|
21
|
+
bgcolor: r,
|
|
22
|
+
borderColor: r,
|
|
23
|
+
labelColor: "text.primary"
|
|
24
|
+
};
|
|
25
|
+
}, u = {
|
|
23
26
|
bgcolor: "primary.lighter",
|
|
24
27
|
borderColor: "primary.lighter",
|
|
25
28
|
labelColor: "text.primary"
|
|
@@ -27,18 +30,18 @@ var e = {
|
|
|
27
30
|
bgcolor: "success.main",
|
|
28
31
|
borderColor: "success.main",
|
|
29
32
|
labelColor: "success.contrastText"
|
|
30
|
-
}, A = (
|
|
31
|
-
const
|
|
33
|
+
}, A = (e) => {
|
|
34
|
+
const r = e.palette.mode, i = {
|
|
32
35
|
bgcolor: "primary.lighter",
|
|
33
36
|
nameVariant: "body2",
|
|
34
|
-
pill: b
|
|
37
|
+
pill: b(r)
|
|
35
38
|
}, o = {
|
|
36
|
-
backgroundImage: g[
|
|
39
|
+
backgroundImage: g[r],
|
|
37
40
|
bgcolor: "background.paper",
|
|
38
41
|
nameVariant: "body1",
|
|
39
|
-
pill:
|
|
42
|
+
pill: u
|
|
40
43
|
}, l = {
|
|
41
|
-
backgroundImage: p[
|
|
44
|
+
backgroundImage: p[r],
|
|
42
45
|
bgcolor: "background.paper",
|
|
43
46
|
nameVariant: "body1",
|
|
44
47
|
pill: c
|
|
@@ -53,19 +56,19 @@ var e = {
|
|
|
53
56
|
showConfetti: !0
|
|
54
57
|
};
|
|
55
58
|
return {
|
|
56
|
-
[
|
|
57
|
-
[
|
|
58
|
-
[
|
|
59
|
-
[
|
|
60
|
-
[
|
|
61
|
-
[
|
|
62
|
-
[
|
|
63
|
-
[
|
|
59
|
+
[t.Neutral]: i,
|
|
60
|
+
[t.Primary]: o,
|
|
61
|
+
[t.Success]: l,
|
|
62
|
+
[t.Celebration]: n,
|
|
63
|
+
[a.SetUpDirectDeposit]: i,
|
|
64
|
+
[a.MissingInterestRate]: o,
|
|
65
|
+
[a.InterestRateAdded]: l,
|
|
66
|
+
[a.DirectDepositComplete]: n
|
|
64
67
|
};
|
|
65
68
|
};
|
|
66
69
|
export {
|
|
67
|
-
|
|
68
|
-
|
|
70
|
+
t as detailedAccountVariant,
|
|
71
|
+
a as directDepositVariant,
|
|
69
72
|
A as getLayoutConfig,
|
|
70
73
|
_ as isDetailedAccountVariant
|
|
71
74
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ComponentBlocks/DetailedAccountBlock/layout.ts"],"sourcesContent":["import type { Theme } from '@mui/material/styles'\n\nimport { WARM_LIME_ACCENT_GRADIENT } from '../../../components/celebrationGradients'\nimport type {\n DirectDepositCardStyleProps,\n DirectDepositPillConfig,\n} from '../../../components/DirectDepositCard'\n\nexport const detailedAccountVariant = {\n Neutral: 'detailed_neutral',\n Primary: 'detailed_primary',\n Success: 'detailed_success',\n Celebration: 'detailed_celebration',\n} as const\n\nexport type DetailedAccountVariant =\n (typeof detailedAccountVariant)[keyof typeof detailedAccountVariant]\n\nexport const directDepositVariant = {\n SetUpDirectDeposit: 'set_up_direct_deposit',\n DirectDepositComplete: 'direct_deposit_complete',\n MissingInterestRate: 'missing_interest_rate',\n InterestRateAdded: 'interest_rate_added',\n} as const\n\nexport type DirectDepositVariant = (typeof directDepositVariant)[keyof typeof directDepositVariant]\n\nconst VARIANTS = new Set<string>([\n ...Object.values(detailedAccountVariant),\n ...Object.values(directDepositVariant),\n])\n\nexport const isDetailedAccountVariant = (\n variant?: string | null,\n): variant is DetailedAccountVariant | DirectDepositVariant =>\n variant != null && VARIANTS.has(variant)\n\nconst MISSING_RATE_GRADIENTS = {\n light: 'linear-gradient(180deg, #A0B9F8 0%, #2C64EF 100%)',\n dark: 'linear-gradient(180deg, #1F46A7 0%, #6B92F4 100%)',\n} as const\n\nconst RATE_ADDED_GRADIENTS = {\n light: 'linear-gradient(180deg, #94C9B7 0%, #12875E 100%)',\n dark: 'linear-gradient(180deg, #0D5F42 0%, #59AB8E 100%)',\n} as const\n\nconst
|
|
1
|
+
{"version":3,"file":"layout.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ComponentBlocks/DetailedAccountBlock/layout.ts"],"sourcesContent":["import type { Theme } from '@mui/material/styles'\n\nimport { WARM_LIME_ACCENT_GRADIENT } from '../../../components/celebrationGradients'\nimport type {\n DirectDepositCardStyleProps,\n DirectDepositPillConfig,\n} from '../../../components/DirectDepositCard'\n\nexport const detailedAccountVariant = {\n Neutral: 'detailed_neutral',\n Primary: 'detailed_primary',\n Success: 'detailed_success',\n Celebration: 'detailed_celebration',\n} as const\n\nexport type DetailedAccountVariant =\n (typeof detailedAccountVariant)[keyof typeof detailedAccountVariant]\n\nexport const directDepositVariant = {\n SetUpDirectDeposit: 'set_up_direct_deposit',\n DirectDepositComplete: 'direct_deposit_complete',\n MissingInterestRate: 'missing_interest_rate',\n InterestRateAdded: 'interest_rate_added',\n} as const\n\nexport type DirectDepositVariant = (typeof directDepositVariant)[keyof typeof directDepositVariant]\n\nconst VARIANTS = new Set<string>([\n ...Object.values(detailedAccountVariant),\n ...Object.values(directDepositVariant),\n])\n\nexport const isDetailedAccountVariant = (\n variant?: string | null,\n): variant is DetailedAccountVariant | DirectDepositVariant =>\n variant != null && VARIANTS.has(variant)\n\nconst MISSING_RATE_GRADIENTS = {\n light: 'linear-gradient(180deg, #A0B9F8 0%, #2C64EF 100%)',\n dark: 'linear-gradient(180deg, #1F46A7 0%, #6B92F4 100%)',\n} as const\n\nconst RATE_ADDED_GRADIENTS = {\n light: 'linear-gradient(180deg, #94C9B7 0%, #12875E 100%)',\n dark: 'linear-gradient(180deg, #0D5F42 0%, #59AB8E 100%)',\n} as const\n\n// Grey tokens don't change with the mode, so pick the one `text.primary` reads on.\nconst neutralPill = (mode: Theme['palette']['mode']): DirectDepositPillConfig => {\n const bgcolor = mode === 'dark' ? 'grey.800' : 'grey.100'\n\n return { bgcolor, borderColor: bgcolor, labelColor: 'text.primary' }\n}\n\nconst PRIMARY_TINT_PILL: DirectDepositPillConfig = {\n bgcolor: 'primary.lighter',\n borderColor: 'primary.lighter',\n labelColor: 'text.primary',\n}\n\nconst SUCCESS_PILL: DirectDepositPillConfig = {\n bgcolor: 'success.main',\n borderColor: 'success.main',\n labelColor: 'success.contrastText',\n}\n\nexport const getLayoutConfig = (\n theme: Theme,\n): Record<DetailedAccountVariant | DirectDepositVariant, DirectDepositCardStyleProps> => {\n const mode = theme.palette.mode\n const neutral: DirectDepositCardStyleProps = {\n bgcolor: 'primary.lighter',\n nameVariant: 'body2',\n pill: neutralPill(mode),\n }\n const primary: DirectDepositCardStyleProps = {\n backgroundImage: MISSING_RATE_GRADIENTS[mode],\n bgcolor: 'background.paper',\n nameVariant: 'body1',\n pill: PRIMARY_TINT_PILL,\n }\n const success: DirectDepositCardStyleProps = {\n backgroundImage: RATE_ADDED_GRADIENTS[mode],\n bgcolor: 'background.paper',\n nameVariant: 'body1',\n pill: SUCCESS_PILL,\n }\n const celebration: DirectDepositCardStyleProps = {\n backgroundImage: WARM_LIME_ACCENT_GRADIENT,\n bgcolor: 'background.paper',\n nameVariant: 'body2',\n pill: { ...SUCCESS_PILL, icon: 'check_circle' },\n showConfetti: true,\n }\n\n return {\n [detailedAccountVariant.Neutral]: neutral,\n [detailedAccountVariant.Primary]: primary,\n [detailedAccountVariant.Success]: success,\n [detailedAccountVariant.Celebration]: celebration,\n [directDepositVariant.SetUpDirectDeposit]: neutral,\n [directDepositVariant.MissingInterestRate]: primary,\n [directDepositVariant.InterestRateAdded]: success,\n [directDepositVariant.DirectDepositComplete]: celebration,\n }\n}\n"],"mappings":";AAQA,IAAa,IAAyB;AAAA,EACpC,SAAS;AAAA,EACT,SAAS;AAAA,EACT,SAAS;AAAA,EACT,aAAa;AACf,GAKa,IAAuB;AAAA,EAClC,oBAAoB;AAAA,EACpB,uBAAuB;AAAA,EACvB,qBAAqB;AAAA,EACrB,mBAAmB;AACrB,GAIM,IAAW,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AAA,IACrC,CAAA,EAAqB,kBAAA,GAAqB;AAAA,IAC1C,CAAA,EAAqB,mBAAA,GAAsB;AAAA,IAC3C,CAAA,EAAqB,iBAAA,GAAoB;AAAA,IACzC,CAAA,EAAqB,qBAAA,GAAwB;AAAA,EAChD;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseLayout.es.js","names":[],"sources":["../../../src/insights-v2/components/BaseLayout.tsx"],"sourcesContent":["import { useMemo } from 'react'\n\nimport { observer } from 'mobx-react-lite'\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 { ChevronRight } from '@mxenabled/mx-icons'\nimport { P } from '@mxenabled/mxui'\n\nimport { blocks } from '../mappings/blocks'\nimport { actionBlocksKey } from '../mappings/actionBlocksKey'\nimport { isContactSupportCtaDisabled } from '../actionBlocks/ContactSupportActionBlock'\nimport { logoFromRef } from './shared/EntityLogo'\n\nimport Footer from './Footer'\nimport Header from './Header'\nimport FeedbackBar from './FeedbackBar'\nimport FeedbackDialog from './FeedbackDialog'\nimport DismissInsightDialog from './DismissInsightDialog'\nimport HiddenConfirmationCard from './HiddenConfirmationCard'\nimport ErrorCard from './ErrorCard'\nimport LoadingCard from './LoadingCard'\nimport { ObsolesceBanner, type ObsolesceBannerState } from './ObsolesceBanner'\nimport { useAppConfig, useGlobalCopyStore, useGlobalStore, useInsightsV2Store } from '../../common'\nimport type { Beat, PrimaryCTA, SecondaryCTA } from '../../core'\nimport { BeatActionsProvider, type BeatActions } from '../beatActions'\nimport { ActionBlockLayer } from '../actionBlocks/ActionBlockLayer'\nimport { reportCtaClick, useBeatCtaActions } from '../ctaActions'\nimport { useBeatFeedbackFlow } from '../hooks/useBeatFeedbackFlow'\n\nexport interface ObsoleteState {\n state: ObsolesceBannerState\n onRefresh: () => void\n onDismiss: () => void\n}\n\ninterface BaseLayoutProps {\n beat: Beat\n beatActions?: BeatActions\n obsolete?: ObsoleteState\n /** Swap only the block slot for a LoadingCard (e.g. while a sampled beat loads). */\n isLoading?: boolean\n /** Replace the entire card with an ErrorCard (e.g. when the sample fails to load). */\n isError?: boolean\n}\n\nconst NO_BEAT_ACTIONS: BeatActions = {}\n\nconst OBSOLETE_OVERLAY_SX = {\n position: 'absolute',\n top: 0,\n left: 0,\n width: '100%',\n height: '100%',\n backgroundColor: 'background.default',\n opacity: 0.7,\n zIndex: 1,\n} as const\n\n// Mini CTA label styled like a Button.\nconst MINI_CTA_SX = {\n alignItems: 'center',\n alignSelf: 'flex-start',\n display: 'flex',\n fontWeight: 600,\n height: 44,\n px: 2,\n textTransform: 'none',\n} as const\n\nconst BaseLayout = observer(\n ({\n beat,\n beatActions = NO_BEAT_ACTIONS,\n obsolete,\n isLoading = false,\n isError = false,\n }: BaseLayoutProps) => {\n const copy = useGlobalCopyStore()\n const insightsV2Store = useInsightsV2Store()\n const { config } = useAppConfig()\n const flow = useBeatFeedbackFlow(beat, beatActions)\n\n const stores = useGlobalStore()\n const {\n runCta: handleCtaClick,\n primary: primaryCtaState,\n secondary: secondaryCtaState,\n } = useBeatCtaActions(\n beat,\n beatActions,\n beat.insights_payload?.primary_cta,\n beat.insights_payload?.secondary_cta,\n )\n\n // Guard: payload may not be loaded yet (isLoading/isError states).\n const isMini = beat.insights_payload?.widget_type === 'mini'\n\n // Memoized: an inline object here would change identity every render, making every\n // useAnalyticsEvent() consumer's callback (and its effect deps) unstable too.\n const beatActionsValue = useMemo(\n () => ({ ...flow.wrappedActions, beat }),\n [flow.wrappedActions, beat],\n )\n\n // Error replaces the entire card; loading only swaps the block slot (below).\n if (isError) return <ErrorCard />\n\n const insights_payload = beat.insights_payload\n\n if (!insights_payload) return null\n if (flow.cardState === 'dismissed') return null\n\n const { instance_slot, primary_cta, secondary_cta, sub_title, title, guid, dismissed_at } =\n insights_payload\n const { block } = instance_slot\n\n // Rebuild V1 subtitle shape; sub_title wins if present.\n const subtitle =\n sub_title ??\n (insights_payload.subtitle\n ? {\n logo: logoFromRef(insights_payload.logo),\n text: insights_payload.subtitle,\n }\n : undefined)\n\n // CTAs run via ctaActions; contact_support_block bypasses it.\n const isCtaDisabled = (ctaBlock: string | null | undefined) =>\n isContactSupportCtaDisabled(ctaBlock, config, beatActions.onContactSupport)\n\n const onCtaClick = async (slot: 'primary' | 'secondary', cta: PrimaryCTA | SecondaryCTA) => {\n if (isCtaDisabled(cta.block)) return\n\n if (cta.block === actionBlocksKey.CONTACT_SUPPORT_ACTION_BLOCK) {\n // Bypasses the runner, but still reports the press like any other CTA: the generic\n // press event, and (on a first primary press) FIRST_TIME_PRIMARY_ACTION_SELECTED +\n // cta_clicked_at.\n reportCtaClick({ beat, stores, hostActions: beatActions, slot })\n beatActions.onContactSupport?.()\n return\n }\n\n await handleCtaClick(slot, cta)\n }\n\n const Block = blocks[block as keyof typeof blocks]\n\n const inDescriptionCta = insights_payload.in_description_cta\n // Full card: the envelope's link opens the drawer its block names. A link with no block (mini's\n // \"Make a Transfer\") is the card's action, drawn as the mini label below, never a dead link.\n const envelopeLink =\n !isMini && inDescriptionCta?.label && inDescriptionCta.block ? inDescriptionCta : undefined\n // The card's action label: the primary CTA's, else a block-less envelope link's (ditto ≥ 1.4.3\n // sends mini's action as in_description_cta). `||`, not `??`: the copy may send the primary label\n // as \"\" rather than omit it, and an empty string must fall through. It is a button only on a full\n // card with a primary CTA; otherwise a label, so a tap reaches the host's card handler.\n const ctaLabel =\n primary_cta?.label || (envelopeLink ? undefined : inDescriptionCta?.label) || undefined\n const isCtaButton = !isMini && !!primary_cta?.label\n const showSecondaryCta = !isMini && !!secondary_cta?.label\n const obsoleteCopy = copy.insights_feed?.general\n const isObsoleteDimmed =\n obsolete?.state === 'not_refreshable' && !dismissed_at && !!obsoleteCopy\n\n return (\n <BeatActionsProvider value={beatActionsValue}>\n <Stack sx={{ mb: 16 }}>\n {flow.cardState === 'confirming' ? (\n <HiddenConfirmationCard\n onClose={flow.collapseConfirmation}\n onLeaveFeedback={flow.openHideSurvey}\n onUndo={flow.undoDismiss}\n />\n ) : (\n <>\n {obsolete && obsoleteCopy && <ObsolesceBanner {...obsolete} copy={obsoleteCopy} />}\n <Card\n inert={isObsoleteDimmed}\n sx={{\n ...(isObsoleteDimmed && {\n position: 'relative',\n zIndex: 2,\n pointerEvents: 'none',\n }),\n }}\n >\n {isObsoleteDimmed && <Box sx={OBSOLETE_OVERLAY_SX} />}\n <Header isMini={isMini} subtitle={subtitle} title={title ?? ''} />\n {isLoading ? (\n <LoadingCard />\n ) : (\n Block && <Block beatGuid={guid} payload={insights_payload} />\n )}\n\n <Stack sx={{ gap: 6, pb: 16, pt: 12, px: 16 }}>\n <P\n dangerouslySetInnerHTML={{\n __html: insights_payload.description.html_text,\n }}\n variant=\"subtitle2\"\n />\n {/* V2: the envelope's link opens the action block it names. */}\n {envelopeLink && (\n <Button\n endIcon={<ChevronRight />}\n onClick={() =>\n insightsV2Store.openActionDrawer({ guid, trigger: 'inDescriptionCta' })\n }\n sx={{ height: 24, p: 4, width: 'max-content' }}\n >\n {envelopeLink.label}\n </Button>\n )}\n {/* V1: the legacy field, shown for beats that do not send the envelope link. */}\n {!inDescriptionCta?.label && beat?.in_description_cta && (\n <Button\n endIcon={<ChevronRight />}\n onClick={() => {}}\n sx={{ height: 24, p: 4, width: 'max-content' }}\n >\n {beat.in_description_cta}\n </Button>\n )}\n </Stack>\n\n {(ctaLabel || showSecondaryCta) && (\n <Stack sx={{ gap: 8, pb: 16, px: 16 }}>\n {ctaLabel &&\n !isCtaButton && (\n // The card's action when it has no primary CTA button (mini always; a full card whose\n // only link names no block). What the tap does is the host's decision (Pulse posts\n // `carousel/cta`, the same redirect a V1 mini card sends), never the action drawer the\n // full card's CTA opens. It is a real (blue, focusable) button for that tap, but has no\n // handler of its own and does not stop the click, so it reaches the host's card handler\n // exactly as a tap on the card does.\n <Button sx={MINI_CTA_SX} variant=\"text\">\n {ctaLabel}\n </Button>\n )}\n {isCtaButton && primary_cta && (\n <Button\n aria-disabled={isCtaDisabled(primary_cta.block) || primaryCtaState.disabled}\n disabled={primaryCtaState.disabled}\n onClick={() => onCtaClick('primary', primary_cta)}\n sx={{\n ...(isCtaDisabled(primary_cta.block) && { color: 'text.disabled' }),\n }}\n variant=\"outlined\"\n >\n {primary_cta.label}\n </Button>\n )}\n {/* Mini has room for one CTA. */}\n {showSecondaryCta && secondary_cta && (\n <Button\n aria-disabled={\n isCtaDisabled(secondary_cta.block) || secondaryCtaState.disabled\n }\n color=\"secondary\"\n disabled={secondaryCtaState.disabled}\n onClick={() => onCtaClick('secondary', secondary_cta)}\n >\n {secondary_cta.label}\n </Button>\n )}\n </Stack>\n )}\n\n <FeedbackBar onTellUsMore={flow.openRatingSurvey} show={flow.isFeedbackBarShown} />\n </Card>\n </>\n )}\n\n <ActionBlockLayer beat={beat} />\n\n <DismissInsightDialog\n isOpen={flow.isDismissOpen}\n onClose={flow.closeDismissDialog}\n onDismiss={flow.confirmDismiss}\n />\n\n {flow.isSurveyOpen && (\n <FeedbackDialog\n characterLimitLabel={flow.survey.characterLimitLabel}\n closeAriaLabel={flow.survey.closeAriaLabel}\n isOpen={true}\n onBackClick={flow.feedbackDialogCallbacks.onBackClick}\n onClose={flow.closeSurvey}\n onSubmit={flow.submitSurvey}\n onTextInputFocus={flow.feedbackDialogCallbacks.onTextInputFocus}\n options={flow.survey.options}\n primaryText={flow.survey.submitText}\n secondaryText={flow.survey.backText}\n title={flow.survey.title}\n />\n )}\n\n {flow.cardState === 'visible' && insights_payload.footer && (\n <Footer footer={insights_payload.footer} />\n )}\n </Stack>\n </BeatActionsProvider>\n )\n },\n)\n\nexport default BaseLayout\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,IAAM,KAA+B,CAAC,GAEhC,KAAsB;AAAA,EAC1B,UAAU;AAAA,EACV,KAAK;AAAA,EACL,MAAM;AAAA,EACN,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,iBAAiB;AAAA,EAC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AAK,wBAAwB;AAAA,UAC/C,SAAS,EAAK,OAAO;AAAA,UACrB,aAAa,EAAK,OAAO;AAAA,UACzB,eAAe,EAAK,OAAO;AAAA,UAC3B,OAAO,EAAK,OAAO;AAAA,QACpB,CAAA;AAAA,QAGF,EAAK,cAAc,aAAa,EAAiB,UAChD,gBAAA,EAAC,IAAD,EAAQ,QAAQ,EAAiB,OAAS,CAAA;AAAA,MAEvC;AAAA;EACY,CAAA;AAEzB,CACF"}
|
|
1
|
+
{"version":3,"file":"BaseLayout.es.js","names":[],"sources":["../../../src/insights-v2/components/BaseLayout.tsx"],"sourcesContent":["import { useMemo } from 'react'\n\nimport { observer } from 'mobx-react-lite'\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 { ChevronRight } from '@mxenabled/mx-icons'\nimport { P } from '@mxenabled/mxui'\n\nimport { blocks } from '../mappings/blocks'\nimport { actionBlocksKey } from '../mappings/actionBlocksKey'\nimport { isContactSupportCtaDisabled } from '../actionBlocks/ContactSupportActionBlock'\nimport { logoFromRef } from './shared/EntityLogo'\n\nimport Footer from './Footer'\nimport Header from './Header'\nimport FeedbackBar from './FeedbackBar'\nimport FeedbackDialog from './FeedbackDialog'\nimport DismissInsightDialog from './DismissInsightDialog'\nimport HiddenConfirmationCard from './HiddenConfirmationCard'\nimport ErrorCard from './ErrorCard'\nimport LoadingCard from './LoadingCard'\nimport { ObsolesceBanner, type ObsolesceBannerState } from './ObsolesceBanner'\nimport { useAppConfig, useGlobalCopyStore, useGlobalStore, useInsightsV2Store } from '../../common'\nimport type { Beat, PrimaryCTA, SecondaryCTA } from '../../core'\nimport { BeatActionsProvider, type BeatActions } from '../beatActions'\nimport { ActionBlockLayer } from '../actionBlocks/ActionBlockLayer'\nimport { reportCtaClick, useBeatCtaActions } from '../ctaActions'\nimport { useBeatFeedbackFlow } from '../hooks/useBeatFeedbackFlow'\n\nexport interface ObsoleteState {\n state: ObsolesceBannerState\n onRefresh: () => void\n onDismiss: () => void\n}\n\ninterface BaseLayoutProps {\n beat: Beat\n beatActions?: BeatActions\n obsolete?: ObsoleteState\n /** Swap only the block slot for a LoadingCard (e.g. while a sampled beat loads). */\n isLoading?: boolean\n /** Replace the entire card with an ErrorCard (e.g. when the sample fails to load). */\n isError?: boolean\n}\n\nconst NO_BEAT_ACTIONS: BeatActions = {}\n\nconst OBSOLETE_OVERLAY_SX = {\n position: 'absolute',\n top: 0,\n left: 0,\n width: '100%',\n height: '100%',\n backgroundColor: 'background.default',\n opacity: 0.7,\n // Above every block's own z-index (hero card 1, AccountBlock 2), or that section shows through.\n zIndex: 3,\n} as const\n\n// Mini CTA label styled like a Button.\nconst MINI_CTA_SX = {\n alignItems: 'center',\n alignSelf: 'flex-start',\n display: 'flex',\n fontWeight: 600,\n height: 44,\n px: 2,\n textTransform: 'none',\n} as const\n\nconst BaseLayout = observer(\n ({\n beat,\n beatActions = NO_BEAT_ACTIONS,\n obsolete,\n isLoading = false,\n isError = false,\n }: BaseLayoutProps) => {\n const copy = useGlobalCopyStore()\n const insightsV2Store = useInsightsV2Store()\n const { config } = useAppConfig()\n const flow = useBeatFeedbackFlow(beat, beatActions)\n\n const stores = useGlobalStore()\n const {\n runCta: handleCtaClick,\n primary: primaryCtaState,\n secondary: secondaryCtaState,\n } = useBeatCtaActions(\n beat,\n beatActions,\n beat.insights_payload?.primary_cta,\n beat.insights_payload?.secondary_cta,\n )\n\n // Guard: payload may not be loaded yet (isLoading/isError states).\n const isMini = beat.insights_payload?.widget_type === 'mini'\n\n // Memoized: an inline object here would change identity every render, making every\n // useAnalyticsEvent() consumer's callback (and its effect deps) unstable too.\n const beatActionsValue = useMemo(\n () => ({ ...flow.wrappedActions, beat }),\n [flow.wrappedActions, beat],\n )\n\n // Error replaces the entire card; loading only swaps the block slot (below).\n if (isError) return <ErrorCard />\n\n const insights_payload = beat.insights_payload\n\n if (!insights_payload) return null\n if (flow.cardState === 'dismissed') return null\n\n const { instance_slot, primary_cta, secondary_cta, sub_title, title, guid, dismissed_at } =\n insights_payload\n const { block } = instance_slot\n\n // Rebuild V1 subtitle shape; sub_title wins if present.\n const subtitle =\n sub_title ??\n (insights_payload.subtitle\n ? {\n logo: logoFromRef(insights_payload.logo),\n text: insights_payload.subtitle,\n }\n : undefined)\n\n // CTAs run via ctaActions; contact_support_block bypasses it.\n const isCtaDisabled = (ctaBlock: string | null | undefined) =>\n isContactSupportCtaDisabled(ctaBlock, config, beatActions.onContactSupport)\n\n const onCtaClick = async (slot: 'primary' | 'secondary', cta: PrimaryCTA | SecondaryCTA) => {\n if (isCtaDisabled(cta.block)) return\n\n if (cta.block === actionBlocksKey.CONTACT_SUPPORT_ACTION_BLOCK) {\n // Bypasses the runner, but still reports the press like any other CTA: the generic\n // press event, and (on a first primary press) FIRST_TIME_PRIMARY_ACTION_SELECTED +\n // cta_clicked_at.\n reportCtaClick({ beat, stores, hostActions: beatActions, slot })\n beatActions.onContactSupport?.()\n return\n }\n\n await handleCtaClick(slot, cta)\n }\n\n const Block = blocks[block as keyof typeof blocks]\n\n const inDescriptionCta = insights_payload.in_description_cta\n // Full card: the envelope's link opens the drawer its block names. A link with no block (mini's\n // \"Make a Transfer\") is the card's action, drawn as the mini label below, never a dead link.\n const envelopeLink =\n !isMini && inDescriptionCta?.label && inDescriptionCta.block ? inDescriptionCta : undefined\n // The card's action label: the primary CTA's, else a block-less envelope link's (ditto ≥ 1.4.3\n // sends mini's action as in_description_cta). `||`, not `??`: the copy may send the primary label\n // as \"\" rather than omit it, and an empty string must fall through. It is a button only on a full\n // card with a primary CTA; otherwise a label, so a tap reaches the host's card handler.\n const ctaLabel =\n primary_cta?.label || (envelopeLink ? undefined : inDescriptionCta?.label) || undefined\n const isCtaButton = !isMini && !!primary_cta?.label\n const showSecondaryCta = !isMini && !!secondary_cta?.label\n const obsoleteCopy = copy.insights_feed?.general\n const isObsoleteDimmed =\n obsolete?.state === 'not_refreshable' && !dismissed_at && !!obsoleteCopy\n\n return (\n <BeatActionsProvider value={beatActionsValue}>\n <Stack sx={{ mb: 16 }}>\n {flow.cardState === 'confirming' ? (\n <HiddenConfirmationCard\n onClose={flow.collapseConfirmation}\n onLeaveFeedback={flow.openHideSurvey}\n onUndo={flow.undoDismiss}\n />\n ) : (\n <>\n {obsolete && obsoleteCopy && <ObsolesceBanner {...obsolete} copy={obsoleteCopy} />}\n <Card\n inert={isObsoleteDimmed}\n sx={{\n ...(isObsoleteDimmed && {\n position: 'relative',\n zIndex: 2,\n pointerEvents: 'none',\n }),\n }}\n >\n {isObsoleteDimmed && <Box sx={OBSOLETE_OVERLAY_SX} />}\n <Header isMini={isMini} subtitle={subtitle} title={title ?? ''} />\n {isLoading ? (\n <LoadingCard />\n ) : (\n Block && <Block beatGuid={guid} payload={insights_payload} />\n )}\n\n <Stack sx={{ gap: 6, pb: 16, pt: 12, px: 16 }}>\n <P\n dangerouslySetInnerHTML={{\n __html: insights_payload.description.html_text,\n }}\n variant=\"subtitle2\"\n />\n {/* V2: the envelope's link opens the action block it names. */}\n {envelopeLink && (\n <Button\n endIcon={<ChevronRight />}\n onClick={() =>\n insightsV2Store.openActionDrawer({ guid, trigger: 'inDescriptionCta' })\n }\n sx={{ height: 24, p: 4, width: 'max-content' }}\n >\n {envelopeLink.label}\n </Button>\n )}\n {/* V1: the legacy field, shown for beats that do not send the envelope link. */}\n {!inDescriptionCta?.label && beat?.in_description_cta && (\n <Button\n endIcon={<ChevronRight />}\n onClick={() => {}}\n sx={{ height: 24, p: 4, width: 'max-content' }}\n >\n {beat.in_description_cta}\n </Button>\n )}\n </Stack>\n\n {(ctaLabel || showSecondaryCta) && (\n <Stack sx={{ gap: 8, pb: 16, px: 16 }}>\n {ctaLabel &&\n !isCtaButton && (\n // The card's action when it has no primary CTA button (mini always; a full card whose\n // only link names no block). What the tap does is the host's decision (Pulse posts\n // `carousel/cta`, the same redirect a V1 mini card sends), never the action drawer the\n // full card's CTA opens. It is a real (blue, focusable) button for that tap, but has no\n // handler of its own and does not stop the click, so it reaches the host's card handler\n // exactly as a tap on the card does.\n <Button sx={MINI_CTA_SX} variant=\"text\">\n {ctaLabel}\n </Button>\n )}\n {isCtaButton && primary_cta && (\n <Button\n aria-disabled={isCtaDisabled(primary_cta.block) || primaryCtaState.disabled}\n disabled={primaryCtaState.disabled}\n onClick={() => onCtaClick('primary', primary_cta)}\n sx={{\n ...(isCtaDisabled(primary_cta.block) && { color: 'text.disabled' }),\n }}\n variant=\"outlined\"\n >\n {primary_cta.label}\n </Button>\n )}\n {/* Mini has room for one CTA. */}\n {showSecondaryCta && secondary_cta && (\n <Button\n aria-disabled={\n isCtaDisabled(secondary_cta.block) || secondaryCtaState.disabled\n }\n color=\"secondary\"\n disabled={secondaryCtaState.disabled}\n onClick={() => onCtaClick('secondary', secondary_cta)}\n >\n {secondary_cta.label}\n </Button>\n )}\n </Stack>\n )}\n\n <FeedbackBar onTellUsMore={flow.openRatingSurvey} show={flow.isFeedbackBarShown} />\n </Card>\n </>\n )}\n\n <ActionBlockLayer beat={beat} />\n\n <DismissInsightDialog\n isOpen={flow.isDismissOpen}\n onClose={flow.closeDismissDialog}\n onDismiss={flow.confirmDismiss}\n />\n\n {flow.isSurveyOpen && (\n <FeedbackDialog\n characterLimitLabel={flow.survey.characterLimitLabel}\n closeAriaLabel={flow.survey.closeAriaLabel}\n isOpen={true}\n onBackClick={flow.feedbackDialogCallbacks.onBackClick}\n onClose={flow.closeSurvey}\n onSubmit={flow.submitSurvey}\n onTextInputFocus={flow.feedbackDialogCallbacks.onTextInputFocus}\n options={flow.survey.options}\n primaryText={flow.survey.submitText}\n secondaryText={flow.survey.backText}\n title={flow.survey.title}\n />\n )}\n\n {flow.cardState === 'visible' && insights_payload.footer && (\n <Footer footer={insights_payload.footer} />\n )}\n </Stack>\n </BeatActionsProvider>\n )\n },\n)\n\nexport default BaseLayout\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,IAAM,KAA+B,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gB,EAAK,OAAO;AAAA,UAC5B,QAAQ;AAAA,UACR,aAAa,EAAK,wBAAwB;AAAA,UAC1C,SAAS,EAAK;AAAA,UACd,UAAU,EAAK;AAAA,UACf,kBAAkB,EAAK,wBAAwB;AAAA,UAC/C,SAAS,EAAK,OAAO;AAAA,UACrB,aAAa,EAAK,OAAO;AAAA,UACzB,eAAe,EAAK,OAAO;AAAA,UAC3B,OAAO,EAAK,OAAO;AAAA,QACpB,CAAA;AAAA,QAGF,EAAK,cAAc,aAAa,EAAiB,UAChD,gBAAA,EAAC,IAAD,EAAQ,QAAQ,EAAiB,OAAS,CAAA;AAAA,MAEvC;AAAA;EACY,CAAA;AAEzB,CACF"}
|
|
@@ -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
|
|
2
|
-
import
|
|
3
|
-
import { useEffect as
|
|
4
|
-
import { Fragment as
|
|
5
|
-
var
|
|
6
|
-
const [t,
|
|
7
|
-
|
|
8
|
-
a && (
|
|
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,
|
|
10
|
+
const f = async (r, i) => {
|
|
11
11
|
n.current = !0, s.current = {
|
|
12
12
|
option: r,
|
|
13
|
-
detail:
|
|
13
|
+
detail: i
|
|
14
14
|
};
|
|
15
15
|
try {
|
|
16
|
-
await d(r,
|
|
16
|
+
await d(r, i), v ? o("success") : c();
|
|
17
17
|
} catch {
|
|
18
|
-
|
|
18
|
+
o("error");
|
|
19
19
|
}
|
|
20
|
-
},
|
|
20
|
+
}, x = () => {
|
|
21
21
|
s.current && f(s.current.option, s.current.detail);
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
} : void 0,
|
|
22
|
+
}, u = l(!1), g = m ? () => {
|
|
23
|
+
u.current = !0, m();
|
|
24
|
+
} : void 0, k = (r) => {
|
|
25
25
|
if (!n.current) {
|
|
26
|
-
if (
|
|
27
|
-
|
|
26
|
+
if (u.current) {
|
|
27
|
+
u.current = !1;
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
|
-
|
|
30
|
+
c(r);
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
|
-
return /* @__PURE__ */
|
|
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:
|
|
39
|
-
onClose:
|
|
40
|
-
onSubmit: (r,
|
|
41
|
-
f(r,
|
|
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(
|
|
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:
|
|
52
|
-
onClose: () =>
|
|
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
|
-
|
|
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 = ({
|
|
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
|
|
3
|
-
var H = (h,
|
|
4
|
-
const a = y(), [r, t] = u(null), [i, l] = u(null), [b, d] = u(!1), [f, c] = u(!1),
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}, [
|
|
8
|
-
const k = p(() =>
|
|
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
|
|
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:
|
|
23
|
+
options: _,
|
|
24
24
|
...m
|
|
25
25
|
};
|
|
26
|
-
})(),
|
|
27
|
-
const e =
|
|
26
|
+
})(), S = p(() => {
|
|
27
|
+
const e = o.onMenuAction;
|
|
28
28
|
return e ? {
|
|
29
|
-
...
|
|
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
|
-
} :
|
|
37
|
-
}, [
|
|
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:
|
|
43
|
+
survey: v,
|
|
44
|
+
wrappedActions: S,
|
|
45
45
|
openRatingSurvey: () => {
|
|
46
46
|
r && l(r);
|
|
47
47
|
},
|
|
48
|
-
openHideSurvey: () =>
|
|
48
|
+
openHideSurvey: () => {
|
|
49
|
+
o.onFeedbackSurveyShown?.("hide"), l("hide");
|
|
50
|
+
},
|
|
49
51
|
closeSurvey: (e) => {
|
|
50
|
-
e &&
|
|
52
|
+
e && o.onFeedbackDialogClose?.(e, i ?? void 0), i !== "hide" && t(null), l(null);
|
|
51
53
|
},
|
|
52
54
|
submitSurvey: (e, s) => {
|
|
53
|
-
!i || !
|
|
54
|
-
beatGuid:
|
|
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
|
-
|
|
62
|
-
beatGuid:
|
|
63
|
+
n && o.onDismissInsight?.({
|
|
64
|
+
beatGuid: n.guid,
|
|
63
65
|
type: e
|
|
64
66
|
});
|
|
65
67
|
},
|
|
66
68
|
undoDismiss: () => {
|
|
67
|
-
|
|
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:
|
|
75
|
-
onTextInputFocus:
|
|
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,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,aAAa,MAAoB,SAAS,IAAW,IAAe,UAAU;AAAA,MAC9E,WAAW,MAAoB,SAAS,IAAW,IAAe,QAAQ;AAAA,IAC5E;AAEA,QAAI,MAAoB,UAAU,EAChC,QAAO;AAAA,MACL,OAAO,EAAS;AAAA,MAChB,SAAS,OAAO,OAAO,EAAS,OAAO;AAAA,MACvC,GAAG;AAAA,IACL;AAGF,UAAM,IAEA,OAAO,OADX,MAAoB,gBACF,GAAc,uBAAuB,CAAC,IACtC,GAAc,mBAAmB,CAAC,CADK;AAG3D,WAAO;AAAA,MACL,OAAO,GAAc,sBAAsB;AAAA,MAC3C,SAAA;AAAA,MACA,GAAG;AAAA,IACL;AAAA,EACF,GAE6B,GAEvB,IAAiB,EAAA,MAA2B;AAChD,UAAM,IAAO,EAAY;AACzB,WAAK,IACE;AAAA,MACL,GAAG;AAAA,MACH,cAAc;AAAA,QACZ,GAAG;AAAA,QACH,UAAA,CAAW,MAAW;AACpB,UAAI,MAAW,aAAa,MAAW,gBACrC,EAAkB,CAAM,IACf,MAAW,UACpB,EAAiB,EAAI,GAEvB,EAAK,SAAS,CAAM;AAAA,QACtB;AAAA,MACF;AAAA,IACF,IAdkB;AAAA,EAepB,GAAG,CAAC,CAAW,CAAC;
|
|
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,EAAi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AAY;AAAA,MACzB,kBAAkB,EAAY;AAAA,IAChC;AAAA,EACF;AACF"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var
|
|
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
|
-
|
|
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,
|
|
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"}
|