@mx-cartographer/experiences 9.4.64 → 9.4.66
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 +13 -0
- package/dist/core/stores/InsightsV2Store.d.ts +19 -0
- package/dist/core/stores/InsightsV2Store.es.js +31 -14
- package/dist/core/stores/InsightsV2Store.es.js.map +1 -1
- package/dist/core/types/Beat.d.ts +2 -0
- package/dist/core/types/Beat.es.js.map +1 -1
- package/dist/core/types/Insights.d.ts +16 -0
- package/dist/insights-v2/actionBlocks/RecurringTransactionBlock/RecurringTransactionBlock.d.ts +17 -0
- package/dist/insights-v2/actionBlocks/RecurringTransactionBlock/RecurringTransactionBlock.es.js +39 -0
- package/dist/insights-v2/actionBlocks/RecurringTransactionBlock/RecurringTransactionBlock.es.js.map +1 -0
- package/dist/insights-v2/actionBlocks/RecurringTransactionBlock/index.d.ts +2 -0
- package/dist/insights-v2/actionBlocks/RecurringTransactionBlock/subscriptionBeats.d.ts +19 -0
- package/dist/insights-v2/actionBlocks/RecurringTransactionBlock/subscriptionBeats.es.js +12 -0
- package/dist/insights-v2/actionBlocks/RecurringTransactionBlock/subscriptionBeats.es.js.map +1 -0
- package/dist/insights-v2/actionBlocks/RecurringTransactionBlock/useRecurringTransactionBlock.d.ts +23 -0
- package/dist/insights-v2/actionBlocks/RecurringTransactionBlock/useRecurringTransactionBlock.es.js +21 -0
- package/dist/insights-v2/actionBlocks/RecurringTransactionBlock/useRecurringTransactionBlock.es.js.map +1 -0
- package/dist/insights-v2/actionBlocks/RecurringTransactionBlock/useRecurringTransactionPrepare.d.ts +25 -0
- package/dist/insights-v2/actionBlocks/RecurringTransactionBlock/useRecurringTransactionPrepare.es.js +24 -0
- package/dist/insights-v2/actionBlocks/RecurringTransactionBlock/useRecurringTransactionPrepare.es.js.map +1 -0
- package/dist/insights-v2/beatActions.d.ts +11 -0
- package/dist/insights-v2/beatActions.es.js.map +1 -1
- package/dist/insights-v2/components/BaseLayout.es.js +84 -80
- package/dist/insights-v2/components/BaseLayout.es.js.map +1 -1
- package/dist/insights-v2/ctaActions/ctaConfig.d.ts +7 -0
- package/dist/insights-v2/ctaActions/ctaConfig.es.js +10 -0
- package/dist/insights-v2/ctaActions/ctaConfig.es.js.map +1 -0
- package/dist/insights-v2/ctaActions/ctaHandlers.d.ts +44 -0
- package/dist/insights-v2/ctaActions/ctaHandlers.es.js +107 -0
- package/dist/insights-v2/ctaActions/ctaHandlers.es.js.map +1 -0
- package/dist/insights-v2/ctaActions/hostActions.d.ts +17 -0
- package/dist/insights-v2/ctaActions/hostActions.es.js +16 -0
- package/dist/insights-v2/ctaActions/hostActions.es.js.map +1 -0
- package/dist/insights-v2/ctaActions/index.d.ts +6 -0
- package/dist/insights-v2/ctaActions/runCtaAction.d.ts +12 -0
- package/dist/insights-v2/ctaActions/runCtaAction.es.js +79 -0
- package/dist/insights-v2/ctaActions/runCtaAction.es.js.map +1 -0
- package/dist/insights-v2/ctaActions/types.d.ts +57 -0
- package/dist/insights-v2/ctaActions/useCtaAction.d.ts +19 -0
- package/dist/insights-v2/ctaActions/useCtaAction.es.js +44 -0
- package/dist/insights-v2/ctaActions/useCtaAction.es.js.map +1 -0
- package/dist/insights-v2/index.d.ts +3 -1
- package/dist/insights-v2/index.es.js +59 -54
- package/dist/insights-v2/mappings/actionBlocksKey.d.ts +1 -0
- package/dist/insights-v2/mappings/actionBlocksKey.es.js +2 -1
- package/dist/insights-v2/mappings/actionBlocksKey.es.js.map +1 -1
- package/dist/insights-v2/mappings/blocks.es.js +52 -45
- package/dist/insights-v2/mappings/blocks.es.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { sendBeatCta as l } from "../../common/utils/PostMessage.es.js";
|
|
2
|
+
import { hasDrawerBlock as p } from "../mappings/blocks.es.js";
|
|
3
|
+
import { HOST_ACTIONS as d } from "./hostActions.es.js";
|
|
4
|
+
import { ctaActions as f } from "./ctaConfig.es.js";
|
|
5
|
+
import { ctaHandlers as m } from "./ctaHandlers.es.js";
|
|
6
|
+
var C = {}, n = ({ cta: t }) => t.action_key && f[t.action_key] || C, A = (t) => {
|
|
7
|
+
const e = n(t);
|
|
8
|
+
return { disabled: t.stores.insightsV2Store.ctaStatus[t.beat.guid] === "pending" || (e.disabledWhen?.(t) ?? !1) };
|
|
9
|
+
}, o = ({ beat: t, slot: e, stores: a }) => {
|
|
10
|
+
a.insightsV2Store.openCtaDrawer(t.guid, e === "primary" ? "primaryCta" : "secondaryCta");
|
|
11
|
+
}, g = (t) => {
|
|
12
|
+
const { beat: e, cta: a, stores: r } = t;
|
|
13
|
+
if (p(a.block)) {
|
|
14
|
+
o(t);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const { is_mobile_webview: s, clientConfig: i } = r.appDataStore.appConfig;
|
|
18
|
+
l(e, {
|
|
19
|
+
isMobileWebview: s,
|
|
20
|
+
webviewScheme: i?.master?.ui_message_webview_url_scheme,
|
|
21
|
+
userGuid: e.insights_payload?.user_guid ?? e.user_guid
|
|
22
|
+
});
|
|
23
|
+
}, w = (t, { beat: e, stores: a }) => {
|
|
24
|
+
t === "refreshBeat" && a.emitUpdate({ staleBeatGuid: e.guid });
|
|
25
|
+
}, v = ({ beat: t, slot: e, hostActions: a }) => {
|
|
26
|
+
e !== "primary" || t.cta_clicked_at || Promise.resolve().then(() => a.onCtaAction?.({
|
|
27
|
+
beatGuid: t.guid,
|
|
28
|
+
name: d.markCtaClicked
|
|
29
|
+
})).catch(() => {
|
|
30
|
+
});
|
|
31
|
+
}, c = async (t, e, a) => {
|
|
32
|
+
const r = m[e];
|
|
33
|
+
if (!r) throw new Error(`Unknown CTA handler "${e}"`);
|
|
34
|
+
await r(t);
|
|
35
|
+
for (const s of a) w(s, t);
|
|
36
|
+
}, u = async ({ beat: t, stores: e }, a, r = {}) => {
|
|
37
|
+
const { insightsV2Store: s } = e;
|
|
38
|
+
s.setCtaStatus(t.guid, "pending");
|
|
39
|
+
try {
|
|
40
|
+
return await a(), s.setCtaStatus(t.guid, "done"), !0;
|
|
41
|
+
} catch (i) {
|
|
42
|
+
return s.setCtaStatus(t.guid, "error"), e.captureException(i, {
|
|
43
|
+
store: "ctaActions",
|
|
44
|
+
template: t.template,
|
|
45
|
+
...r
|
|
46
|
+
}), !1;
|
|
47
|
+
}
|
|
48
|
+
}, T = async (t) => {
|
|
49
|
+
const e = n(t), a = typeof e.params == "function" ? e.params(t) : e.params, r = {
|
|
50
|
+
...t,
|
|
51
|
+
params: {
|
|
52
|
+
...a,
|
|
53
|
+
...t.params
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
e.skipCtaClicked || v(r), await u(r, async () => {
|
|
57
|
+
e.run && await c(r, e.run, e.onSuccess ?? []);
|
|
58
|
+
const s = e.next ?? (e.run ? "none" : "default");
|
|
59
|
+
s === "default" ? g(r) : s === "drawer" && o(r);
|
|
60
|
+
});
|
|
61
|
+
}, h = {
|
|
62
|
+
label: "",
|
|
63
|
+
block: ""
|
|
64
|
+
}, D = (t, e, { onSuccess: a = [] } = {}) => {
|
|
65
|
+
const r = {
|
|
66
|
+
...t,
|
|
67
|
+
cta: h,
|
|
68
|
+
slot: "primary"
|
|
69
|
+
};
|
|
70
|
+
return u(r, () => c(r, e, a), { handler: e });
|
|
71
|
+
};
|
|
72
|
+
export {
|
|
73
|
+
A as resolveCtaState,
|
|
74
|
+
n as resolveStep,
|
|
75
|
+
T as runCtaAction,
|
|
76
|
+
D as runCtaHandler
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
//# sourceMappingURL=runCtaAction.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runCtaAction.es.js","names":[],"sources":["../../../src/insights-v2/ctaActions/runCtaAction.ts"],"sourcesContent":["import { sendBeatCta } from '../../common/utils/PostMessage'\nimport { hasDrawerBlock } from '../mappings/blocks'\nimport { ctaActions } from './ctaConfig'\nimport { ctaHandlers, type CtaHandlerName } from './ctaHandlers'\nimport { HOST_ACTIONS } from './hostActions'\nimport type {\n CtaContext,\n CtaEffect,\n CtaHandler,\n CtaHandlerContext,\n CtaState,\n CtaStateContext,\n CtaStep,\n RunHandlerOptions,\n} from './types'\n\nconst DEFAULT_STEP: CtaStep = {}\n\n// ─── Resolution ─────────────────────────────────────────────────────────────\n\n/** The beat's own context (input a block collected for it), `{}` until something is written. */\nexport const beatContextOf = ({ beat, stores }: Pick<CtaStateContext, 'beat' | 'stores'>) =>\n stores.insightsV2Store.beatContext[beat.guid] ?? {}\n\n/** The step named by the CTA's `action_key`, or the empty default (no key / unknown key). */\nexport const resolveStep = ({ cta }: Pick<CtaStateContext, 'cta'>): CtaStep =>\n (cta.action_key && ctaActions[cta.action_key]) || DEFAULT_STEP\n\n/** Pending always disables; the step's `disabledWhen` may add to that. */\nexport const resolveCtaState = (ctx: CtaStateContext): CtaState => {\n const step = resolveStep(ctx)\n const pending = ctx.stores.insightsV2Store.ctaStatus[ctx.beat.guid] === 'pending'\n\n return { disabled: pending || (step.disabledWhen?.(ctx) ?? false) }\n}\n\n// ─── Targets and effects ────────────────────────────────────────────────────\n\n/** Opens the beat's drawer for whichever slot triggered the current step. */\nconst openDrawerForSlot = ({\n beat,\n slot,\n stores,\n}: Pick<CtaContext, 'beat' | 'slot' | 'stores'>) => {\n stores.insightsV2Store.openCtaDrawer(\n beat.guid,\n slot === 'primary' ? 'primaryCta' : 'secondaryCta',\n )\n}\n\n/** Pre-existing BaseLayout behaviour: drawer for a real block, otherwise beat/cta message. */\nconst runDefaultTarget = (ctx: CtaContext) => {\n const { beat, cta, stores } = ctx\n\n if (hasDrawerBlock(cta.block)) {\n openDrawerForSlot(ctx)\n return\n }\n\n const { is_mobile_webview, clientConfig } = stores.appDataStore.appConfig\n\n sendBeatCta(beat, {\n isMobileWebview: is_mobile_webview,\n webviewScheme: clientConfig?.master?.ui_message_webview_url_scheme,\n userGuid: beat.insights_payload?.user_guid ?? beat.user_guid,\n })\n}\n\nconst runEffect = (effect: CtaEffect, { beat, stores }: CtaContext) => {\n switch (effect) {\n case 'refreshBeat':\n stores.emitUpdate({ staleBeatGuid: beat.guid })\n break\n }\n}\n\n/**\n * First primary click records `cta_clicked_at` through the host. Fire-and-forget: whatever the\n * host does (reject, throw, return nothing) must never fail the user's action.\n */\nconst markCtaClicked = ({ beat, slot, hostActions }: CtaContext) => {\n if (slot !== 'primary' || beat.cta_clicked_at) return\n\n // Wrapping the call in `.then` turns a synchronous throw into a rejection, and the `.catch`\n // swallows both: a failed cta_clicked_at write is not the user's action.\n Promise.resolve()\n .then(() =>\n hostActions.onCtaAction?.({ beatGuid: beat.guid, name: HOST_ACTIONS.markCtaClicked }),\n )\n .catch(() => {})\n}\n\n// ─── Shared bookkeeping ─────────────────────────────────────────────────────\n\n/** Runs a named handler, then its `onSuccess` effects. Shared by card CTAs and drawer saves. */\nconst runHandlerWithEffects = async (\n ctx: CtaContext,\n handlerName: CtaHandlerName,\n onSuccess: CtaEffect[],\n): Promise<void> => {\n // Names are typed, but the map is still indexed defensively: config can come from anywhere.\n const handler = (ctaHandlers as Record<string, CtaHandler>)[handlerName]\n\n if (!handler) throw new Error(`Unknown CTA handler \"${handlerName}\"`)\n\n await handler(ctx)\n\n for (const effect of onSuccess) runEffect(effect, ctx)\n}\n\n/** Per-beat status around `work`: `pending` -> `done` | `error` (+ captureException). */\nconst withCtaStatus = async (\n { beat, stores }: Pick<CtaContext, 'beat' | 'stores'>,\n work: () => Promise<void>,\n captureContext: Record<string, string> = {},\n): Promise<boolean> => {\n const { insightsV2Store } = stores\n\n insightsV2Store.setCtaStatus(beat.guid, 'pending')\n\n try {\n await work()\n insightsV2Store.setCtaStatus(beat.guid, 'done')\n\n return true\n } catch (error) {\n insightsV2Store.setCtaStatus(beat.guid, 'error')\n stores.captureException(error, {\n store: 'ctaActions',\n template: beat.template,\n ...captureContext,\n })\n\n return false\n }\n}\n\n// ─── Entry points ───────────────────────────────────────────────────────────\n\n/** Runs the CTA's step: `run` handler, `onSuccess` effects, then the `next` target. */\nexport const runCtaAction = async (ctx: CtaContext): Promise<void> => {\n const step = resolveStep(ctx)\n const stepParams = typeof step.params === 'function' ? step.params(ctx) : step.params\n const stepCtx: CtaContext = { ...ctx, params: { ...stepParams, ...ctx.params } }\n\n if (!step.skipCtaClicked) markCtaClicked(stepCtx)\n\n await withCtaStatus(stepCtx, async () => {\n if (step.run) await runHandlerWithEffects(stepCtx, step.run, step.onSuccess ?? [])\n\n const target = step.next ?? (step.run ? 'none' : 'default')\n\n if (target === 'default') runDefaultTarget(stepCtx)\n else if (target === 'drawer') openDrawerForSlot(stepCtx)\n })\n}\n\n/** Placeholder CTA for handlers run from inside a drawer, where no card slot is involved. */\nconst DIRECT_CTA = { label: '', block: '' }\n\n/** Runs a handler directly (drawer Save buttons): same bookkeeping as a card CTA. True on success. */\nexport const runCtaHandler = (\n ctx: CtaHandlerContext,\n handlerName: CtaHandlerName,\n { onSuccess = [] }: RunHandlerOptions = {},\n): Promise<boolean> => {\n const fullCtx: CtaContext = { ...ctx, cta: DIRECT_CTA, slot: 'primary' }\n\n return withCtaStatus(fullCtx, () => runHandlerWithEffects(fullCtx, handlerName, onSuccess), {\n handler: handlerName,\n })\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Beat, PrimaryCTA, SecondaryCTA } from '../../core';
|
|
2
|
+
import { GlobalStore } from '../../core/stores/GlobalStore';
|
|
3
|
+
import { BeatActions } from '../beatActions';
|
|
4
|
+
import { CtaHandlerName } from './ctaHandlers';
|
|
5
|
+
export type CtaSlot = 'primary' | 'secondary';
|
|
6
|
+
/** Handler inputs: control values at the top level, the write set under `fields`. */
|
|
7
|
+
export type CtaParams = Record<string, unknown>;
|
|
8
|
+
/** Read-only view for state predicates evaluated during render. */
|
|
9
|
+
export type CtaStateContext = Pick<CtaContext, 'beat' | 'cta' | 'slot' | 'stores'>;
|
|
10
|
+
export interface CtaState {
|
|
11
|
+
disabled: boolean;
|
|
12
|
+
}
|
|
13
|
+
/** Everything a step guard or handler can read while running. */
|
|
14
|
+
export interface CtaContext {
|
|
15
|
+
beat: Beat;
|
|
16
|
+
cta: PrimaryCTA | SecondaryCTA;
|
|
17
|
+
slot: CtaSlot;
|
|
18
|
+
stores: GlobalStore;
|
|
19
|
+
hostActions: BeatActions;
|
|
20
|
+
/** Free-form data declared on the step (or passed by an in-drawer caller). */
|
|
21
|
+
params: Record<string, unknown>;
|
|
22
|
+
}
|
|
23
|
+
/** Runner-owned after-effects. `refreshBeat`: tell the host the beat is stale (it refetches). */
|
|
24
|
+
export type CtaEffect = 'refreshBeat';
|
|
25
|
+
/** What a CTA does when its `action_key` names this step. The backend picks the key per state. */
|
|
26
|
+
export interface CtaStep {
|
|
27
|
+
/** Handler to await first (typed: a misspelt name fails typecheck). */
|
|
28
|
+
run?: CtaHandlerName;
|
|
29
|
+
/**
|
|
30
|
+
* Forwarded to the handler as `ctx.params`. A function computes them at press time from the
|
|
31
|
+
* beat and stores (e.g. a user pick from `beatContextOf(ctx)`); keep it to reading values, the
|
|
32
|
+
* backend picks behaviour per state via `action_key`.
|
|
33
|
+
*/
|
|
34
|
+
params?: CtaParams | ((ctx: CtaStateContext) => CtaParams);
|
|
35
|
+
/** Effects executed after `run` resolves successfully. */
|
|
36
|
+
onSuccess?: CtaEffect[];
|
|
37
|
+
/**
|
|
38
|
+
* After `run`: `default` = drawer if the CTA has a block, else post; `drawer` forces the
|
|
39
|
+
* drawer; `none` stops. Omitted = `none` with `run`, `default` without.
|
|
40
|
+
*/
|
|
41
|
+
next?: 'default' | 'drawer' | 'none';
|
|
42
|
+
/** Skip the first-click `markCtaClicked` host effect. */
|
|
43
|
+
skipCtaClicked?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Disable while true. Only for client-only state (a pick not yet made, a store loading);
|
|
46
|
+
* data-derived rules belong to the backend, which omits the label instead.
|
|
47
|
+
*/
|
|
48
|
+
disabledWhen?: (ctx: CtaStateContext) => boolean;
|
|
49
|
+
}
|
|
50
|
+
/** Context for a handler run directly from a drawer (no card CTA / slot involved). */
|
|
51
|
+
export type CtaHandlerContext = Omit<CtaContext, 'cta' | 'slot'>;
|
|
52
|
+
export interface RunHandlerOptions {
|
|
53
|
+
/** Runner-owned effects executed after the handler resolves. */
|
|
54
|
+
onSuccess?: CtaEffect[];
|
|
55
|
+
}
|
|
56
|
+
/** A named side effect. Must throw (or reject) on failure so the runner can report it. */
|
|
57
|
+
export type CtaHandler = (ctx: CtaContext) => Promise<void> | void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Beat, PrimaryCTA, SecondaryCTA } from '../../core';
|
|
2
|
+
import { BeatActions } from '../beatActions';
|
|
3
|
+
import { CtaHandlerName } from './ctaHandlers';
|
|
4
|
+
import { CtaSlot, CtaState, RunHandlerOptions } from './types';
|
|
5
|
+
export interface BeatCtaActions {
|
|
6
|
+
runCta: (slot: CtaSlot, cta: PrimaryCTA | SecondaryCTA, params?: Record<string, unknown>) => Promise<void>;
|
|
7
|
+
primary: CtaState;
|
|
8
|
+
secondary: CtaState;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The card's click runner plus per-slot enabled state. Call from an `observer` so `disabledWhen`
|
|
12
|
+
* store reads re-render. `beatActions` is a parameter: BaseLayout mounts its provider below this.
|
|
13
|
+
*/
|
|
14
|
+
export declare const useBeatCtaActions: (beat: Beat, beatActions?: BeatActions, primaryCta?: PrimaryCTA | SecondaryCTA, secondaryCta?: PrimaryCTA | SecondaryCTA) => BeatCtaActions;
|
|
15
|
+
/**
|
|
16
|
+
* Runs a handler from inside a drawer, e.g. `runHandler('createBudget', { categoryGuid, amount },
|
|
17
|
+
* { onSuccess: ['refreshBeat'] })`. Inside a block, pass `useBeatActions()` as `beatActions`.
|
|
18
|
+
*/
|
|
19
|
+
export declare const useCtaHandler: (beat: Beat, beatActions?: BeatActions) => (handlerName: CtaHandlerName, params?: Record<string, unknown>, options?: RunHandlerOptions) => Promise<boolean>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { useGlobalStore as l } from "../../common/context/hooks.es.js";
|
|
2
|
+
import { resolveCtaState as n, runCtaAction as C, runCtaHandler as m } from "./runCtaAction.es.js";
|
|
3
|
+
var c = {
|
|
4
|
+
label: "",
|
|
5
|
+
block: ""
|
|
6
|
+
}, d = (r, o = {}, a = c, s = c) => {
|
|
7
|
+
const t = l();
|
|
8
|
+
return {
|
|
9
|
+
runCta: (e, i, u = {}) => C({
|
|
10
|
+
beat: r,
|
|
11
|
+
cta: i,
|
|
12
|
+
slot: e,
|
|
13
|
+
stores: t,
|
|
14
|
+
hostActions: o,
|
|
15
|
+
params: u
|
|
16
|
+
}),
|
|
17
|
+
primary: n({
|
|
18
|
+
beat: r,
|
|
19
|
+
cta: a,
|
|
20
|
+
slot: "primary",
|
|
21
|
+
stores: t
|
|
22
|
+
}),
|
|
23
|
+
secondary: n({
|
|
24
|
+
beat: r,
|
|
25
|
+
cta: s,
|
|
26
|
+
slot: "secondary",
|
|
27
|
+
stores: t
|
|
28
|
+
})
|
|
29
|
+
};
|
|
30
|
+
}, v = (r, o = {}) => {
|
|
31
|
+
const a = l();
|
|
32
|
+
return (s, t = {}, e) => m({
|
|
33
|
+
beat: r,
|
|
34
|
+
stores: a,
|
|
35
|
+
hostActions: o,
|
|
36
|
+
params: t
|
|
37
|
+
}, s, e);
|
|
38
|
+
};
|
|
39
|
+
export {
|
|
40
|
+
d as useBeatCtaActions,
|
|
41
|
+
v as useCtaHandler
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=useCtaAction.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCtaAction.es.js","names":[],"sources":["../../../src/insights-v2/ctaActions/useCtaAction.ts"],"sourcesContent":["import type { Beat, PrimaryCTA, SecondaryCTA } from '../../core'\nimport { useGlobalStore } from '../../common'\nimport type { BeatActions } from '../beatActions'\nimport type { CtaHandlerName } from './ctaHandlers'\nimport { resolveCtaState, runCtaAction, runCtaHandler } from './runCtaAction'\nimport type { CtaSlot, CtaState, RunHandlerOptions } from './types'\n\nconst EMPTY_CTA: PrimaryCTA = { label: '', block: '' }\n\nexport interface BeatCtaActions {\n runCta: (\n slot: CtaSlot,\n cta: PrimaryCTA | SecondaryCTA,\n params?: Record<string, unknown>,\n ) => Promise<void>\n primary: CtaState\n secondary: CtaState\n}\n\n/**\n * The card's click runner plus per-slot enabled state. Call from an `observer` so `disabledWhen`\n * store reads re-render. `beatActions` is a parameter: BaseLayout mounts its provider below this.\n */\nexport const useBeatCtaActions = (\n beat: Beat,\n beatActions: BeatActions = {},\n primaryCta: PrimaryCTA | SecondaryCTA = EMPTY_CTA,\n secondaryCta: PrimaryCTA | SecondaryCTA = EMPTY_CTA,\n): BeatCtaActions => {\n const stores = useGlobalStore()\n\n return {\n runCta: (slot, cta, params = {}) =>\n runCtaAction({ beat, cta, slot, stores, hostActions: beatActions, params }),\n primary: resolveCtaState({ beat, cta: primaryCta, slot: 'primary', stores }),\n secondary: resolveCtaState({ beat, cta: secondaryCta, slot: 'secondary', stores }),\n }\n}\n\n/**\n * Runs a handler from inside a drawer, e.g. `runHandler('createBudget', { categoryGuid, amount },\n * { onSuccess: ['refreshBeat'] })`. Inside a block, pass `useBeatActions()` as `beatActions`.\n */\nexport const useCtaHandler = (beat: Beat, beatActions: BeatActions = {}) => {\n const stores = useGlobalStore()\n\n return (\n handlerName: CtaHandlerName,\n params: Record<string, unknown> = {},\n options?: RunHandlerOptions,\n ) => runCtaHandler({ beat, stores, hostActions: beatActions, params }, handlerName, options)\n}\n"],"mappings":";;AAOA,IAAM,IAAwB;AAAA,EAAE,OAAO;AAAA,EAAI,OAAO;AAAG,GAgBxC,IAAA,CACX,GACA,IAA2B,CAAC,GAC5B,IAAwC,GACxC,IAA0C,MACvB;AACnB,QAAM,IAAS,EAAe;AAE9B,SAAO;AAAA,IACL,QAAA,CAAS,GAAM,GAAK,IAAS,CAAC,MAC5B,EAAa;AAAA,MAAE,MAAA;AAAA,MAAM,KAAA;AAAA,MAAK,MAAA;AAAA,MAAM,QAAA;AAAA,MAAQ,aAAa;AAAA,MAAa,QAAA;AAAA,IAAO,CAAC;AAAA,IAC5E,SAAS,EAAgB;AAAA,MAAE,MAAA;AAAA,MAAM,KAAK;AAAA,MAAY,MAAM;AAAA,MAAW,QAAA;AAAA,IAAO,CAAC;AAAA,IAC3E,WAAW,EAAgB;AAAA,MAAE,MAAA;AAAA,MAAM,KAAK;AAAA,MAAc,MAAM;AAAA,MAAa,QAAA;AAAA,IAAO,CAAC;AAAA,EACnF;AACF,GAMa,IAAA,CAAiB,GAAY,IAA2B,CAAC,MAAM;AAC1E,QAAM,IAAS,EAAe;AAE9B,SAAA,CACE,GACA,IAAkC,CAAC,GACnC,MACG,EAAc;AAAA,IAAE,MAAA;AAAA,IAAM,QAAA;AAAA,IAAQ,aAAa;AAAA,IAAa,QAAA;AAAA,EAAO,GAAG,GAAa,CAAO;AAC7F"}
|
|
@@ -22,7 +22,9 @@ export { default as HiddenConfirmationCard, type HiddenConfirmationCardProps, }
|
|
|
22
22
|
export { default as FeedbackDialog, type FeedbackDialogCloseReason, type FeedbackDialogProps, } from './components/FeedbackDialog';
|
|
23
23
|
export { default as FeedbackBar, type FeedbackBarProps } from './components/FeedbackBar';
|
|
24
24
|
export { ObsolesceBanner, type ObsolesceBannerProps, type ObsolesceBannerState, type ObsolesceBannerCopy, } from './components/ObsolesceBanner';
|
|
25
|
-
export {
|
|
25
|
+
export { HOST_ACTIONS, useBeatCtaActions, useCtaHandler } from './ctaActions';
|
|
26
|
+
export type { BeatCtaActions, CtaContext, CtaEffect, CtaHandlerName, CtaParams, CtaStateContext, CtaStep, HostActionName, RunHandlerOptions, } from './ctaActions';
|
|
27
|
+
export { useBeatActions, type BeatActions, type CtaActionParams, type MenuActionHandlers, type UpdateParams, type FeedbackParams, type DismissParams, type InsightMenuAction, type InsightRating, } from './beatActions';
|
|
26
28
|
export { default as LogoTile } from './components/LogoTile';
|
|
27
29
|
export { default as MerchantHighlightCard } from './components/MerchantHighlightCard';
|
|
28
30
|
export { default as P2PLogoStack } from './components/P2PLogoStack';
|
|
@@ -1,101 +1,106 @@
|
|
|
1
1
|
import o from "./components/StatusPill.es.js";
|
|
2
|
-
import { resolveInsightRender as
|
|
2
|
+
import { resolveInsightRender as m } from "./resolveInsightRender.es.js";
|
|
3
3
|
import { useBeatActions as a } from "./beatActions.es.js";
|
|
4
4
|
import f from "./components/BadgedTile.es.js";
|
|
5
5
|
import { OverflowMenu as n } from "./components/OverflowMenu.es.js";
|
|
6
6
|
import { InsightOptionsMenu as c } from "./components/InsightOptionsMenu.es.js";
|
|
7
|
-
import d, { isLogoGuid as
|
|
7
|
+
import d, { isLogoGuid as C } from "./components/LogoFromGuid.es.js";
|
|
8
8
|
import B from "./components/StatusBadge.es.js";
|
|
9
9
|
import h from "./components/CompactInsightCard.es.js";
|
|
10
10
|
import S from "./components/InsightErrorCard.es.js";
|
|
11
|
-
import { BAR_CHART_VARIANTS as
|
|
12
|
-
import { BarchartBlock as
|
|
13
|
-
import { DoubleBarChartBlock as
|
|
14
|
-
import
|
|
15
|
-
import
|
|
11
|
+
import { BAR_CHART_VARIANTS as T, barChartVariant as b, buildChartData as D, buildDataSeries as I } from "./blocks/ChartBlocks/BarchartBlock/utils.es.js";
|
|
12
|
+
import { BarchartBlock as H } from "./blocks/ChartBlocks/BarchartBlock/BarchartBlock.es.js";
|
|
13
|
+
import { DoubleBarChartBlock as O } from "./blocks/ChartBlocks/DoubleBarChartBlock/DoubleBarChartBlock.es.js";
|
|
14
|
+
import E from "./blocks/ChartBlocks/StepChartBlock/StepChartBlock.es.js";
|
|
15
|
+
import R from "./blocks/ChartBlocks/DonutChartBlock/DonutChartBlock.es.js";
|
|
16
16
|
import V from "./blocks/ChartBlocks/DoubleProgressBarBlock/DoubleProgressBarBlock.es.js";
|
|
17
17
|
import y from "./blocks/ComponentBlocks/AccountBlock/AccountBlock.es.js";
|
|
18
18
|
import G from "./components/TransferLogoCard.es.js";
|
|
19
|
-
import
|
|
19
|
+
import N from "./blocks/ComponentBlocks/AccountSwitchBlock/AccountSwitchBlock.es.js";
|
|
20
20
|
import { BudgetBlock as U } from "./blocks/ComponentBlocks/BudgetBlock/BudgetBlock.es.js";
|
|
21
21
|
import q from "./components/SaveAnExtraCard.es.js";
|
|
22
22
|
import J from "./blocks/ComponentBlocks/SaveExtraBlock/SaveExtraBlock.es.js";
|
|
23
23
|
import Q from "./components/InsightTransactionRow.es.js";
|
|
24
24
|
import Y from "./components/TransactionListCard.es.js";
|
|
25
25
|
import { TransactionBlock as $, TransactionBlockVariant as rr } from "./blocks/ComponentBlocks/TransactionBlock/TransactionBlock.es.js";
|
|
26
|
-
import
|
|
26
|
+
import tr from "./components/WithdrawalCard.es.js";
|
|
27
27
|
import ir from "./blocks/ComponentBlocks/WithdrawalBlock/WithdrawalBlock.es.js";
|
|
28
28
|
import { SVGImageBlock as pr } from "./blocks/ImageBlocks/SVGImageBlock/SVGImageBlock.es.js";
|
|
29
29
|
import er from "./components/AccountHeroCard.es.js";
|
|
30
30
|
import sr from "./components/AmountPill.es.js";
|
|
31
31
|
import lr from "./components/DesignateEmergencySavingsCard.es.js";
|
|
32
|
-
import {
|
|
33
|
-
import Br from "./components/
|
|
34
|
-
import
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
import { LoadingCard as
|
|
38
|
-
import { ObsolesceBanner as
|
|
39
|
-
import
|
|
40
|
-
import
|
|
41
|
-
import Rr from "./components/
|
|
42
|
-
import
|
|
43
|
-
import
|
|
44
|
-
import
|
|
45
|
-
import
|
|
46
|
-
import
|
|
47
|
-
import
|
|
32
|
+
import { ErrorCard as Cr } from "./components/ErrorCard.es.js";
|
|
33
|
+
import { FeedbackBar as Br } from "./components/FeedbackBar.es.js";
|
|
34
|
+
import hr from "./components/FeedbackDialog.es.js";
|
|
35
|
+
import { DismissInsightDialog as Sr } from "./components/DismissInsightDialog.es.js";
|
|
36
|
+
import { HiddenConfirmationCard as Tr } from "./components/HiddenConfirmationCard.es.js";
|
|
37
|
+
import { LoadingCard as Dr } from "./components/LoadingCard.es.js";
|
|
38
|
+
import { ObsolesceBanner as Lr } from "./components/ObsolesceBanner.es.js";
|
|
39
|
+
import { HOST_ACTIONS as vr } from "./ctaActions/hostActions.es.js";
|
|
40
|
+
import { useBeatCtaActions as wr, useCtaHandler as Er } from "./ctaActions/useCtaAction.es.js";
|
|
41
|
+
import Rr from "./components/BaseLayout.es.js";
|
|
42
|
+
import Vr from "./components/StatusMessageCard.es.js";
|
|
43
|
+
import yr from "./components/LogoTile.es.js";
|
|
44
|
+
import Gr from "./components/LogoClusterCard.es.js";
|
|
45
|
+
import Nr from "./components/MerchantHighlightCard.es.js";
|
|
46
|
+
import Ur from "./components/P2PLogoStack.es.js";
|
|
47
|
+
import qr from "./components/SavingsOpportunityCard.es.js";
|
|
48
|
+
import Jr from "./components/SubscriptionHeroCard.es.js";
|
|
49
|
+
import Qr from "./components/UpcomingBillCard.es.js";
|
|
48
50
|
export {
|
|
49
51
|
y as AccountBlock,
|
|
50
52
|
er as AccountHeroCard,
|
|
51
|
-
|
|
53
|
+
N as AccountSwitchBlock,
|
|
52
54
|
sr as AmountPill,
|
|
53
|
-
|
|
55
|
+
T as BAR_CHART_VARIANTS,
|
|
54
56
|
f as BadgedTile,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
+
H as BarchartBlock,
|
|
58
|
+
Rr as BaseLayout,
|
|
57
59
|
U as BudgetBlock,
|
|
58
60
|
h as CompactInsightCard,
|
|
59
61
|
lr as DesignateEmergencySavingsCard,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
Sr as DismissInsightDialog,
|
|
63
|
+
R as DonutChartBlock,
|
|
64
|
+
O as DoubleBarChartBlock,
|
|
63
65
|
V as DoubleProgressBarBlock,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
Cr as ErrorCard,
|
|
67
|
+
Br as FeedbackBar,
|
|
68
|
+
hr as FeedbackDialog,
|
|
69
|
+
vr as HOST_ACTIONS,
|
|
70
|
+
Tr as HiddenConfirmationCard,
|
|
68
71
|
S as InsightErrorCard,
|
|
69
72
|
c as InsightOptionsMenu,
|
|
70
73
|
Q as InsightTransactionRow,
|
|
71
|
-
|
|
72
|
-
|
|
74
|
+
Dr as LoadingCard,
|
|
75
|
+
Gr as LogoClusterCard,
|
|
73
76
|
d as LogoFromGuid,
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
+
yr as LogoTile,
|
|
78
|
+
Nr as MerchantHighlightCard,
|
|
79
|
+
Lr as ObsolesceBanner,
|
|
77
80
|
n as OverflowMenu,
|
|
78
|
-
|
|
81
|
+
Ur as P2PLogoStack,
|
|
79
82
|
pr as SVGImageBlock,
|
|
80
83
|
q as SaveAnExtraCard,
|
|
81
84
|
J as SaveExtraBlock,
|
|
82
|
-
|
|
85
|
+
qr as SavingsOpportunityCard,
|
|
83
86
|
B as StatusBadge,
|
|
84
|
-
|
|
87
|
+
Vr as StatusMessageCard,
|
|
85
88
|
o as StatusPill,
|
|
86
|
-
|
|
87
|
-
|
|
89
|
+
E as StepChartBlock,
|
|
90
|
+
Jr as SubscriptionHeroCard,
|
|
88
91
|
$ as TransactionBlock,
|
|
89
92
|
rr as TransactionBlockVariant,
|
|
90
93
|
Y as TransactionListCard,
|
|
91
94
|
G as TransferLogoCard,
|
|
92
|
-
|
|
95
|
+
Qr as UpcomingBillCard,
|
|
93
96
|
ir as WithdrawalBlock,
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
a as useBeatActions
|
|
97
|
+
tr as WithdrawalCard,
|
|
98
|
+
b as barChartVariant,
|
|
99
|
+
D as buildChartData,
|
|
100
|
+
I as buildDataSeries,
|
|
101
|
+
C as isLogoGuid,
|
|
102
|
+
m as resolveInsightRender,
|
|
103
|
+
a as useBeatActions,
|
|
104
|
+
wr as useBeatCtaActions,
|
|
105
|
+
Er as useCtaHandler
|
|
101
106
|
};
|
|
@@ -3,7 +3,8 @@ var _ = {
|
|
|
3
3
|
MAKE_TRANSFER_ACTION_BLOCK: "make_transfer",
|
|
4
4
|
TRANSCATION_HISTORY_ACTION_BLOCK: "transaction_history_block",
|
|
5
5
|
TRANSACTION_DETAILS_ACTION_BLOCK: "transaction_details_block",
|
|
6
|
-
CONTACT_SUPPORT_ACTION_BLOCK: "contact_support_block"
|
|
6
|
+
CONTACT_SUPPORT_ACTION_BLOCK: "contact_support_block",
|
|
7
|
+
RECURRING_TRANSACTION_ACTION_BLOCK: "recurring_transaction_block"
|
|
7
8
|
};
|
|
8
9
|
export {
|
|
9
10
|
_ as actionBlocksKey
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actionBlocksKey.es.js","names":[],"sources":["../../../src/insights-v2/mappings/actionBlocksKey.ts"],"sourcesContent":["// Keys for the drawer drilldown registry in `blocks.ts`, extracted into their own module.\n//\n// Why: chart blocks (e.g. BarchartBlock, DoubleBarChartBlock) need\n// `TRANSCATION_HISTORY_ACTION_BLOCK` to tag a chart bar's drilldown context, but they are\n// themselves re-exported through `../blocks` -> `mappings/blocks.ts` imports from that same\n// barrel to build its `blocks` registry. Importing the key straight from `mappings/blocks.ts`\n// closed that loop into a circular import: evaluating `mappings/blocks.ts` pulled in the\n// `blocks` barrel, which (before it got to `ComponentBlocks`/`AccountBlock`) loaded\n// `BarchartBlock`, which imported back into the still-initializing `mappings/blocks.ts` —\n// tripping a \"Cannot access 'AccountBlock' before initialization\" TDZ error in Storybook/Vite.\n//\n// Keeping the keys here (no dependency on `mappings/blocks.ts`) lets chart blocks reference\n// them without re-entering that module.\n//\n// Names follow ditto: its registry ends every CTA block in `_block` and the V2 envelope copies those\n// names verbatim (`transaction_details_block`, `contact_support_block`). `make_transfer` is a legacy\n// name that stays as an alias until the last legacy payload is gone.\nexport const actionBlocksKey = {\n PLACEHOLDER_ACTION_BLOCK: 'PlaceholderActionBlock',\n MAKE_TRANSFER_ACTION_BLOCK: 'make_transfer',\n TRANSCATION_HISTORY_ACTION_BLOCK: 'transaction_history_block',\n TRANSACTION_DETAILS_ACTION_BLOCK: 'transaction_details_block',\n CONTACT_SUPPORT_ACTION_BLOCK: 'contact_support_block',\n}\n"],"mappings":"AAiBA,IAAa,IAAkB;AAAA,EAC7B,0BAA0B;AAAA,EAC1B,4BAA4B;AAAA,EAC5B,kCAAkC;AAAA,EAClC,kCAAkC;AAAA,EAClC,8BAA8B;
|
|
1
|
+
{"version":3,"file":"actionBlocksKey.es.js","names":[],"sources":["../../../src/insights-v2/mappings/actionBlocksKey.ts"],"sourcesContent":["// Keys for the drawer drilldown registry in `blocks.ts`, extracted into their own module.\n//\n// Why: chart blocks (e.g. BarchartBlock, DoubleBarChartBlock) need\n// `TRANSCATION_HISTORY_ACTION_BLOCK` to tag a chart bar's drilldown context, but they are\n// themselves re-exported through `../blocks` -> `mappings/blocks.ts` imports from that same\n// barrel to build its `blocks` registry. Importing the key straight from `mappings/blocks.ts`\n// closed that loop into a circular import: evaluating `mappings/blocks.ts` pulled in the\n// `blocks` barrel, which (before it got to `ComponentBlocks`/`AccountBlock`) loaded\n// `BarchartBlock`, which imported back into the still-initializing `mappings/blocks.ts` —\n// tripping a \"Cannot access 'AccountBlock' before initialization\" TDZ error in Storybook/Vite.\n//\n// Keeping the keys here (no dependency on `mappings/blocks.ts`) lets chart blocks reference\n// them without re-entering that module.\n//\n// Names follow ditto: its registry ends every CTA block in `_block` and the V2 envelope copies those\n// names verbatim (`transaction_details_block`, `contact_support_block`). `make_transfer` is a legacy\n// name that stays as an alias until the last legacy payload is gone.\nexport const actionBlocksKey = {\n PLACEHOLDER_ACTION_BLOCK: 'PlaceholderActionBlock',\n MAKE_TRANSFER_ACTION_BLOCK: 'make_transfer',\n TRANSCATION_HISTORY_ACTION_BLOCK: 'transaction_history_block',\n TRANSACTION_DETAILS_ACTION_BLOCK: 'transaction_details_block',\n CONTACT_SUPPORT_ACTION_BLOCK: 'contact_support_block',\n RECURRING_TRANSACTION_ACTION_BLOCK: 'recurring_transaction_block',\n}\n"],"mappings":"AAiBA,IAAa,IAAkB;AAAA,EAC7B,0BAA0B;AAAA,EAC1B,4BAA4B;AAAA,EAC5B,kCAAkC;AAAA,EAClC,kCAAkC;AAAA,EAClC,8BAA8B;AAAA,EAC9B,oCAAoC;AACtC"}
|
|
@@ -1,78 +1,85 @@
|
|
|
1
1
|
import { ContactSupportActionBlock as a } from "../actionBlocks/ContactSupportActionBlock.es.js";
|
|
2
|
-
import { actionBlocksKey as
|
|
2
|
+
import { actionBlocksKey as r } from "./actionBlocksKey.es.js";
|
|
3
3
|
import { BarchartBlock as c } from "../blocks/ChartBlocks/BarchartBlock/BarchartBlock.es.js";
|
|
4
|
-
import { DoubleBarChartBlock as
|
|
5
|
-
import
|
|
4
|
+
import { DoubleBarChartBlock as i } from "../blocks/ChartBlocks/DoubleBarChartBlock/DoubleBarChartBlock.es.js";
|
|
5
|
+
import l from "../blocks/ChartBlocks/StepChartBlock/StepChartBlock.es.js";
|
|
6
6
|
import m from "../blocks/ChartBlocks/DonutChartBlock/DonutChartBlock.es.js";
|
|
7
7
|
import n from "../blocks/ChartBlocks/DoubleProgressBarBlock/DoubleProgressBarBlock.es.js";
|
|
8
8
|
import p from "../blocks/ComponentBlocks/AccountBlock/AccountBlock.es.js";
|
|
9
9
|
import _ from "../blocks/ComponentBlocks/AccountSwitchBlock/AccountSwitchBlock.es.js";
|
|
10
|
-
import { BudgetBlock as
|
|
11
|
-
import
|
|
10
|
+
import { BudgetBlock as s } from "../blocks/ComponentBlocks/BudgetBlock/BudgetBlock.es.js";
|
|
11
|
+
import k from "../blocks/ComponentBlocks/SaveExtraBlock/SaveExtraBlock.es.js";
|
|
12
12
|
import { TransactionBlock as B } from "../blocks/ComponentBlocks/TransactionBlock/TransactionBlock.es.js";
|
|
13
13
|
import C from "../blocks/ComponentBlocks/WithdrawalBlock/WithdrawalBlock.es.js";
|
|
14
|
-
import
|
|
15
|
-
import { SVGImageBlock as
|
|
16
|
-
import { PlaceholderActionBlock as
|
|
17
|
-
import { getMakeTransferDrawerTitle as
|
|
18
|
-
import { MakeTransferActionBlockLayer as
|
|
14
|
+
import u from "../blocks/ImageBlocks/ImageBlock.es.js";
|
|
15
|
+
import { SVGImageBlock as T } from "../blocks/ImageBlocks/SVGImageBlock/SVGImageBlock.es.js";
|
|
16
|
+
import { PlaceholderActionBlock as f } from "../actionBlocks/PlaceholderActionBlock.es.js";
|
|
17
|
+
import { getMakeTransferDrawerTitle as A } from "../actionBlocks/MakeTransferActionBlock/layout.es.js";
|
|
18
|
+
import { MakeTransferActionBlockLayer as b } from "../actionBlocks/MakeTransferActionBlock/MakeTransferActionBlockLayer.es.js";
|
|
19
19
|
import { getDrawerHeaderTitle as O } from "../actionBlocks/TransactionHistoryBlock/utils.es.js";
|
|
20
|
-
import { TransactionDetailsBlock as
|
|
21
|
-
import { useTransactionDetailsPrepare as
|
|
22
|
-
import { TransactionHistoryBlock as
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
import { TransactionDetailsBlock as N } from "../actionBlocks/TransactionDetailsBlock/TransactionDetailsBlock.es.js";
|
|
21
|
+
import { useTransactionDetailsPrepare as h } from "../actionBlocks/TransactionDetailsBlock/useTransactionDetailsPrepare.es.js";
|
|
22
|
+
import { TransactionHistoryBlock as d } from "../actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js";
|
|
23
|
+
import { useRecurringTransactionPrepare as g } from "../actionBlocks/RecurringTransactionBlock/useRecurringTransactionPrepare.es.js";
|
|
24
|
+
import { RecurringTransactionBlock as I } from "../actionBlocks/RecurringTransactionBlock/RecurringTransactionBlock.es.js";
|
|
25
|
+
var e = (t) => {
|
|
26
|
+
}, L = /* @__PURE__ */ new Set([
|
|
25
27
|
"",
|
|
26
28
|
"null",
|
|
27
29
|
"undefined"
|
|
28
|
-
]),
|
|
29
|
-
const
|
|
30
|
-
return !!
|
|
31
|
-
},
|
|
32
|
-
[
|
|
33
|
-
Component:
|
|
34
|
-
usePrepare:
|
|
30
|
+
]), Z = (t) => {
|
|
31
|
+
const o = t?.trim().toLowerCase();
|
|
32
|
+
return !!o && !L.has(o);
|
|
33
|
+
}, $ = {
|
|
34
|
+
[r.PLACEHOLDER_ACTION_BLOCK]: {
|
|
35
|
+
Component: f,
|
|
36
|
+
usePrepare: e,
|
|
35
37
|
title: () => "Action Block Layer Drilldown"
|
|
36
38
|
},
|
|
37
|
-
[
|
|
38
|
-
Component:
|
|
39
|
-
usePrepare:
|
|
40
|
-
title:
|
|
39
|
+
[r.MAKE_TRANSFER_ACTION_BLOCK]: {
|
|
40
|
+
Component: b,
|
|
41
|
+
usePrepare: e,
|
|
42
|
+
title: A
|
|
41
43
|
},
|
|
42
|
-
[
|
|
43
|
-
Component:
|
|
44
|
-
usePrepare:
|
|
44
|
+
[r.TRANSCATION_HISTORY_ACTION_BLOCK]: {
|
|
45
|
+
Component: d,
|
|
46
|
+
usePrepare: e,
|
|
45
47
|
title: O
|
|
46
48
|
},
|
|
47
|
-
[
|
|
48
|
-
Component:
|
|
49
|
-
usePrepare:
|
|
49
|
+
[r.TRANSACTION_DETAILS_ACTION_BLOCK]: {
|
|
50
|
+
Component: N,
|
|
51
|
+
usePrepare: h,
|
|
50
52
|
title: () => "Transaction Details"
|
|
51
53
|
},
|
|
52
|
-
[
|
|
54
|
+
[r.RECURRING_TRANSACTION_ACTION_BLOCK]: {
|
|
55
|
+
Component: I,
|
|
56
|
+
usePrepare: g,
|
|
57
|
+
title: (t, o) => o.recurring?.expense_details ?? ""
|
|
58
|
+
},
|
|
59
|
+
[r.CONTACT_SUPPORT_ACTION_BLOCK]: {
|
|
53
60
|
Component: a,
|
|
54
|
-
usePrepare:
|
|
55
|
-
title: (
|
|
61
|
+
usePrepare: e,
|
|
62
|
+
title: (t, o) => o.help?.request_support ?? ""
|
|
56
63
|
}
|
|
57
|
-
},
|
|
64
|
+
}, oo = {
|
|
58
65
|
account_block: p,
|
|
59
66
|
account_switch_block: _,
|
|
60
67
|
bar_chart_block: c,
|
|
61
|
-
budget_block:
|
|
68
|
+
budget_block: s,
|
|
62
69
|
donut_chart_block: m,
|
|
63
|
-
double_bar_chart_block:
|
|
70
|
+
double_bar_chart_block: i,
|
|
64
71
|
double_progress_bar_block: n,
|
|
65
|
-
image_block:
|
|
66
|
-
save_extra_block:
|
|
67
|
-
step_chart_block:
|
|
68
|
-
svg_image_block:
|
|
72
|
+
image_block: u,
|
|
73
|
+
save_extra_block: k,
|
|
74
|
+
step_chart_block: l,
|
|
75
|
+
svg_image_block: T,
|
|
69
76
|
withdrawal_block: C,
|
|
70
77
|
transaction_block: B
|
|
71
78
|
};
|
|
72
79
|
export {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
80
|
+
$ as actionBlocks,
|
|
81
|
+
oo as blocks,
|
|
82
|
+
Z as hasDrawerBlock
|
|
76
83
|
};
|
|
77
84
|
|
|
78
85
|
//# sourceMappingURL=blocks.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blocks.es.js","names":[],"sources":["../../../src/insights-v2/mappings/blocks.ts"],"sourcesContent":["import {\n AccountBlock,\n AccountSwitchBlock,\n BarchartBlock,\n BudgetBlock,\n DonutChartBlock,\n DoubleBarChartBlock,\n DoubleProgressBarBlock,\n SaveExtraBlock,\n SVGImageBlock,\n WithdrawalBlock,\n TransactionBlock,\n} from '../blocks'\nimport StepChartBlock from '../blocks/ChartBlocks/StepChartBlock'\nimport ImageBlock from '../blocks/ImageBlocks/ImageBlock'\n\nimport type { Beat, GlobalCopy, InsightsPayload } from '../../core'\nimport { ContactSupportActionBlock } from '../actionBlocks/ContactSupportActionBlock'\nimport { PlaceholderActionBlock } from '../actionBlocks/PlaceholderActionBlock'\nimport { MakeTransferActionBlockLayer } from '../actionBlocks/MakeTransferActionBlock/MakeTransferActionBlockLayer'\nimport { getMakeTransferDrawerTitle } from '../actionBlocks/MakeTransferActionBlock/layout'\nimport { TransactionHistoryBlock } from '../actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock'\nimport { getDrawerHeaderTitle } from '../actionBlocks/TransactionHistoryBlock/utils'\nimport {\n TransactionDetailsBlock,\n useTransactionDetailsPrepare,\n} from '../actionBlocks/TransactionDetailsBlock'\n// Keys live in ./actionBlocksKey (imported directly by chart blocks/tests too) to avoid a\n// circular import between this module and the chart blocks — see that file for details.\nimport { actionBlocksKey } from './actionBlocksKey'\n\n// Drilldown indexes are not passed down: action blocks read them from\n// InsightsV2Store (useInsightsV2Store().actionDrawer).\nexport interface ActionBlockProps {\n beat: Beat\n}\n\nconst noop = (_: ActionBlockProps) => {}\n\n// A CTA opens a drawer only when it carries a real `block`. The backend may send\n// an empty/absent block (or the literal strings \"null\"/\"undefined\") for CTAs\n// that trigger something else (e.g. a postMessage) instead of a drilldown.\nconst NON_BLOCK_VALUES = new Set(['', 'null', 'undefined'])\nexport const hasDrawerBlock = (block?: string | null): boolean => {\n const normalized = block?.trim().toLowerCase()\n return !!normalized && !NON_BLOCK_VALUES.has(normalized)\n}\n\nexport interface ActionBlockEntry {\n Component: React.ComponentType<ActionBlockProps>\n usePrepare: (props: ActionBlockProps) => void // required; default to noop in each entry\n // Resolves the drawer title from the clicked CTA's variant + copy (e.g.\n // MakeTransfer reads its variant title from layout.ts). Falls back to the CTA label.\n title?: (variant: string | null | undefined, copy: GlobalCopy) => string\n}\n\n// Registry of drawer drilldowns, keyed by the `block` name the backend sends\n// on a beat's CTA. To add one: create a component taking ActionBlockProps,\n// read the clicked indexes from useInsightsV2Store().actionDrawer, and\n// register it here. Add\n// `usePrepare` when the block needs to load data before rendering.\n\nexport const actionBlocks = {\n [actionBlocksKey.PLACEHOLDER_ACTION_BLOCK]: {\n Component: PlaceholderActionBlock,\n usePrepare: noop,\n title: () => 'Action Block Layer Drilldown',\n },\n [actionBlocksKey.MAKE_TRANSFER_ACTION_BLOCK]: {\n Component: MakeTransferActionBlockLayer,\n usePrepare: noop,\n title: getMakeTransferDrawerTitle,\n },\n [actionBlocksKey.TRANSCATION_HISTORY_ACTION_BLOCK]: {\n Component: TransactionHistoryBlock,\n usePrepare: noop,\n title: getDrawerHeaderTitle,\n },\n [actionBlocksKey.TRANSACTION_DETAILS_ACTION_BLOCK]: {\n Component: TransactionDetailsBlock,\n usePrepare: useTransactionDetailsPrepare,\n title: () => 'Transaction Details',\n },\n // The block renders its own drawer (the help module's RequestSupport) on top of the action\n // drawer, so the action drawer's title is the CTA label.\n [actionBlocksKey.CONTACT_SUPPORT_ACTION_BLOCK]: {\n Component: ContactSupportActionBlock,\n usePrepare: noop,\n title: (_variant, copy) => copy.help?.request_support ?? '',\n },\n} as Record<string, ActionBlockEntry>\n\nexport const blocks = {\n account_block: AccountBlock,\n account_switch_block: AccountSwitchBlock,\n bar_chart_block: BarchartBlock,\n budget_block: BudgetBlock,\n donut_chart_block: DonutChartBlock,\n double_bar_chart_block: DoubleBarChartBlock,\n double_progress_bar_block: DoubleProgressBarBlock,\n image_block: ImageBlock,\n save_extra_block: SaveExtraBlock,\n step_chart_block: StepChartBlock,\n svg_image_block: SVGImageBlock,\n withdrawal_block: WithdrawalBlock,\n transaction_block: TransactionBlock,\n} as Record<string, React.ComponentType<{ payload: InsightsPayload; beatGuid?: string }>>\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"blocks.es.js","names":[],"sources":["../../../src/insights-v2/mappings/blocks.ts"],"sourcesContent":["import {\n AccountBlock,\n AccountSwitchBlock,\n BarchartBlock,\n BudgetBlock,\n DonutChartBlock,\n DoubleBarChartBlock,\n DoubleProgressBarBlock,\n SaveExtraBlock,\n SVGImageBlock,\n WithdrawalBlock,\n TransactionBlock,\n} from '../blocks'\nimport StepChartBlock from '../blocks/ChartBlocks/StepChartBlock'\nimport ImageBlock from '../blocks/ImageBlocks/ImageBlock'\n\nimport type { Beat, GlobalCopy, InsightsPayload } from '../../core'\nimport { ContactSupportActionBlock } from '../actionBlocks/ContactSupportActionBlock'\nimport { PlaceholderActionBlock } from '../actionBlocks/PlaceholderActionBlock'\nimport { MakeTransferActionBlockLayer } from '../actionBlocks/MakeTransferActionBlock/MakeTransferActionBlockLayer'\nimport { getMakeTransferDrawerTitle } from '../actionBlocks/MakeTransferActionBlock/layout'\nimport { TransactionHistoryBlock } from '../actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock'\nimport { getDrawerHeaderTitle } from '../actionBlocks/TransactionHistoryBlock/utils'\nimport {\n TransactionDetailsBlock,\n useTransactionDetailsPrepare,\n} from '../actionBlocks/TransactionDetailsBlock'\nimport {\n RecurringTransactionBlock,\n useRecurringTransactionPrepare,\n} from '../actionBlocks/RecurringTransactionBlock'\n// Keys live in ./actionBlocksKey (imported directly by chart blocks/tests too) to avoid a\n// circular import between this module and the chart blocks — see that file for details.\nimport { actionBlocksKey } from './actionBlocksKey'\n\n// Drilldown indexes are not passed down: action blocks read them from\n// InsightsV2Store (useInsightsV2Store().actionDrawer).\nexport interface ActionBlockProps {\n beat: Beat\n}\n\nconst noop = (_: ActionBlockProps) => {}\n\n// A CTA opens a drawer only when it carries a real `block`. The backend may send\n// an empty/absent block (or the literal strings \"null\"/\"undefined\") for CTAs\n// that trigger something else (e.g. a postMessage) instead of a drilldown.\nconst NON_BLOCK_VALUES = new Set(['', 'null', 'undefined'])\nexport const hasDrawerBlock = (block?: string | null): boolean => {\n const normalized = block?.trim().toLowerCase()\n return !!normalized && !NON_BLOCK_VALUES.has(normalized)\n}\n\nexport interface ActionBlockEntry {\n Component: React.ComponentType<ActionBlockProps>\n usePrepare: (props: ActionBlockProps) => void // required; default to noop in each entry\n // Resolves the drawer title from the clicked CTA's variant + copy (e.g.\n // MakeTransfer reads its variant title from layout.ts). Falls back to the CTA label.\n title?: (variant: string | null | undefined, copy: GlobalCopy) => string\n}\n\n// Registry of drawer drilldowns, keyed by the `block` name the backend sends\n// on a beat's CTA. To add one: create a component taking ActionBlockProps,\n// read the clicked indexes from useInsightsV2Store().actionDrawer, and\n// register it here. Add\n// `usePrepare` when the block needs to load data before rendering.\n\nexport const actionBlocks = {\n [actionBlocksKey.PLACEHOLDER_ACTION_BLOCK]: {\n Component: PlaceholderActionBlock,\n usePrepare: noop,\n title: () => 'Action Block Layer Drilldown',\n },\n [actionBlocksKey.MAKE_TRANSFER_ACTION_BLOCK]: {\n Component: MakeTransferActionBlockLayer,\n usePrepare: noop,\n title: getMakeTransferDrawerTitle,\n },\n [actionBlocksKey.TRANSCATION_HISTORY_ACTION_BLOCK]: {\n Component: TransactionHistoryBlock,\n usePrepare: noop,\n title: getDrawerHeaderTitle,\n },\n [actionBlocksKey.TRANSACTION_DETAILS_ACTION_BLOCK]: {\n Component: TransactionDetailsBlock,\n usePrepare: useTransactionDetailsPrepare,\n title: () => 'Transaction Details',\n },\n // Expense Details for one recurring subscription. Which subscription a beat names is resolved in\n // `RecurringTransactionBlock/subscriptionBeats.ts`, not through this registry.\n [actionBlocksKey.RECURRING_TRANSACTION_ACTION_BLOCK]: {\n Component: RecurringTransactionBlock,\n usePrepare: useRecurringTransactionPrepare,\n title: (_variant, copy) => copy.recurring?.expense_details ?? '',\n },\n // The block renders its own drawer (the help module's RequestSupport) on top of the action\n // drawer, so the action drawer's title is the CTA label.\n [actionBlocksKey.CONTACT_SUPPORT_ACTION_BLOCK]: {\n Component: ContactSupportActionBlock,\n usePrepare: noop,\n title: (_variant, copy) => copy.help?.request_support ?? '',\n },\n} as Record<string, ActionBlockEntry>\n\nexport const blocks = {\n account_block: AccountBlock,\n account_switch_block: AccountSwitchBlock,\n bar_chart_block: BarchartBlock,\n budget_block: BudgetBlock,\n donut_chart_block: DonutChartBlock,\n double_bar_chart_block: DoubleBarChartBlock,\n double_progress_bar_block: DoubleProgressBarBlock,\n image_block: ImageBlock,\n save_extra_block: SaveExtraBlock,\n step_chart_block: StepChartBlock,\n svg_image_block: SVGImageBlock,\n withdrawal_block: WithdrawalBlock,\n transaction_block: TransactionBlock,\n} as Record<string, React.ComponentType<{ payload: InsightsPayload; beatGuid?: string }>>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAyCA,IAAM,IAAA,CAAQ,MAAwB;AAAC,GAKjC,IAAmB,oBAAI,IAAI;AAAA,EAAC;AAAA,EAAI;AAAA,EAAQ;AAAW,CAAC,GAC7C,IAAA,CAAkB,MAAmC;AAChE,QAAM,IAAa,GAAO,KAAK,EAAE,YAAY;AAC7C,SAAO,CAAC,CAAC,KAAc,CAAC,EAAiB,IAAI,CAAU;AACzD,GAgBa,IAAe;AAAA,EACzB,CAAA,EAAgB,wBAAA,GAA2B;AAAA,IAC1C,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,OAAA,MAAa;AAAA,EACf;AAAA,EACC,CAAA,EAAgB,0BAAA,GAA6B;AAAA,IAC5C,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,OAAO;AAAA,EACT;AAAA,EACC,CAAA,EAAgB,gCAAA,GAAmC;AAAA,IAClD,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,OAAO;AAAA,EACT;AAAA,EACC,CAAA,EAAgB,gCAAA,GAAmC;AAAA,IAClD,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,OAAA,MAAa;AAAA,EACf;AAAA,EAGC,CAAA,EAAgB,kCAAA,GAAqC;AAAA,IACpD,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,OAAA,CAAQ,GAAU,MAAS,EAAK,WAAW,mBAAmB;AAAA,EAChE;AAAA,EAGC,CAAA,EAAgB,4BAAA,GAA+B;AAAA,IAC9C,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,OAAA,CAAQ,GAAU,MAAS,EAAK,MAAM,mBAAmB;AAAA,EAC3D;AACF,GAEa,KAAS;AAAA,EACpB,eAAe;AAAA,EACf,sBAAsB;AAAA,EACtB,iBAAiB;AAAA,EACjB,cAAc;AAAA,EACd,mBAAmB;AAAA,EACnB,wBAAwB;AAAA,EACxB,2BAA2B;AAAA,EAC3B,aAAa;AAAA,EACb,kBAAkB;AAAA,EAClB,kBAAkB;AAAA,EAClB,iBAAiB;AAAA,EACjB,kBAAkB;AAAA,EAClB,mBAAmB;AACrB"}
|