@mx-cartographer/experiences 9.7.17 → 9.7.19
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 +10 -0
- package/dist/core/api/BeatApi.d.ts +15 -2
- package/dist/core/api/BeatApi.es.js +8 -7
- package/dist/core/api/BeatApi.es.js.map +1 -1
- package/dist/core/constants/ApiEndpoints.d.ts +1 -0
- package/dist/core/constants/ApiEndpoints.es.js +1 -0
- package/dist/core/constants/ApiEndpoints.es.js.map +1 -1
- package/dist/core/stores/BeatStore.d.ts +2 -2
- package/dist/core/stores/BeatStore.es.js +29 -29
- package/dist/core/stores/BeatStore.es.js.map +1 -1
- package/dist/core/stores/InsightsV2Store.d.ts +19 -5
- package/dist/core/stores/InsightsV2Store.es.js +12 -10
- package/dist/core/stores/InsightsV2Store.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/util.es.js +6 -3
- package/dist/insights-v2/actionBlocks/util.es.js.map +1 -1
- package/dist/microinsights/InsightsMicroWidget.es.js +39 -38
- package/dist/microinsights/InsightsMicroWidget.es.js.map +1 -1
- package/dist/microinsights/beatActions.d.ts +21 -0
- package/dist/microinsights/beatActions.es.js +23 -0
- package/dist/microinsights/beatActions.es.js.map +1 -0
- package/dist/microinsights/cards/InlineActionBlock.d.ts +16 -0
- package/dist/microinsights/cards/InlineActionBlock.es.js +41 -0
- package/dist/microinsights/cards/InlineActionBlock.es.js.map +1 -0
- package/dist/microinsights/cards/InsightCard.es.js +68 -61
- package/dist/microinsights/cards/InsightCard.es.js.map +1 -1
- package/dist/microinsights/carousel/BeatList.es.js +17 -16
- package/dist/microinsights/carousel/BeatList.es.js.map +1 -1
- package/dist/microinsights/carousel/MicroBeatCarousel.d.ts +1 -0
- package/dist/microinsights/carousel/MicroBeatCarousel.es.js +34 -33
- package/dist/microinsights/carousel/MicroBeatCarousel.es.js.map +1 -1
- package/dist/microinsights/context/hooks.es.js +11 -6
- package/dist/microinsights/context/hooks.es.js.map +1 -1
- package/dist/microinsights/interfaces.d.ts +12 -0
- package/dist/microinsights/stores/InsightsMicroWidgetStore.d.ts +3 -1
- package/dist/microinsights/stores/InsightsMicroWidgetStore.es.js +18 -17
- package/dist/microinsights/stores/InsightsMicroWidgetStore.es.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
## [9.7.19] - 10-21-2026
|
|
2
|
+
|
|
3
|
+
- **ADDED** - `openActionDrawer` takes an optional `cta` (a `block` and `variant`) for the `inDescriptionCta` trigger. The drawer then runs that block and variant instead of the beat's own `in_description_cta`, so a host that opens a beat's action from other data (pulse, from the beat's micro envelope) does not have to rewrite the beat. It is typed to that trigger only, kept in `actionDrawer.cta` through close for the slide-out, and replaced by the next open. Documented in `docs/action-blocks/README.md` (WEC-2000)
|
|
4
|
+
|
|
5
|
+
## [9.7.18] - 10-21-2026
|
|
6
|
+
|
|
7
|
+
- **ADDED** - `inDescriptionCtaBehavior?: 'internal' | 'external'` (default `'external'`) on `InsightsMicroWidget`. With `'internal'`, tapping an Insights 2.0 card opens the `insights_payload.in_description_cta` block in place instead of calling `onCardClick`; legacy beats and V2 beats with no drawer block there keep the host redirect. Analytics still fire. Without a `GlobalDataProvider` around the widget, a tap keeps the host's `onCardClick` instead of throwing (WEC-1999)
|
|
8
|
+
- **CHANGED** - `BeatApi.getBeats` and `BeatStore.loadBeats` take a `widgetType` (default `'micro'`) and send it as `widget_type` on `GET /beats`, so firefly returns the micro envelope for Insights 2.0 beats. Callers that pass nothing now get `micro` (WEC-1999)
|
|
9
|
+
- **ADDED** - `buildMicroBeatActions` supplies the host actions for the in-place block: `onAnalyticsEvent` routes to the micro analytics session and PostHog, and `onSubmitFeedback` posts the survey answer to firefly (`BeatApi.sendBeatFeedback`, `POST /beat_feedback`; a failed request rejects so the survey shows its error and Try Again) (WEC-1999)
|
|
10
|
+
|
|
1
11
|
## [9.7.17] - 10-20-2026
|
|
2
12
|
|
|
3
13
|
- **CHANGED** - `withdrawal_block` reads the Emergency Fund Withdrawal card flat from `instance_slot` (`amount`, `amount_label`, `withdrawal_date`, `balance`, `balance_label` beside `block` and `variant`, no `data.series`), matching ditto's `WithdrawalBlock`. `InstanceSlot` declares the four new fields and the mock mirrors the envelope tupac sends (WEC-1941)
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import { Fetch } from '../utils';
|
|
2
|
-
import { Beat, GlobalErrorHandler } from '..';
|
|
2
|
+
import { Beat, GlobalErrorHandler, WidgetType } from '..';
|
|
3
|
+
/** Body of `POST /beat_feedback` (firefly permits these four; `rating` is 1 to 5 and optional). */
|
|
4
|
+
export interface BeatFeedbackRequest {
|
|
5
|
+
beat_guid: string;
|
|
6
|
+
template: string;
|
|
7
|
+
comments: string;
|
|
8
|
+
rating?: number;
|
|
9
|
+
}
|
|
3
10
|
export declare class BeatApi {
|
|
4
11
|
fetchInstance: Fetch;
|
|
5
12
|
constructor(endpoint: string, token: string, onError?: GlobalErrorHandler);
|
|
6
|
-
|
|
13
|
+
/** `widgetType` picks the envelope firefly returns for an Insights 2.0 beat; defaults to `micro`. */
|
|
14
|
+
getBeats: (pageNum?: number, perPage?: number, widgetType?: WidgetType) => Promise<any>;
|
|
7
15
|
/**
|
|
8
16
|
* The transactions widget's one beat fetch: the row pill and the details-drawer card both render
|
|
9
17
|
* from what it returns, so it asks for the `embedded` envelope (Insights 2.0). A flagged beat
|
|
@@ -14,4 +22,9 @@ export declare class BeatApi {
|
|
|
14
22
|
getOffers: () => Promise<any>;
|
|
15
23
|
updateBeat: (beat: Beat) => Promise<any>;
|
|
16
24
|
updateOffer: (beat: Beat) => Promise<any>;
|
|
25
|
+
/**
|
|
26
|
+
* Rejects with an `ApiError` when firefly does not accept the feedback, so a caller (the survey
|
|
27
|
+
* dialog) can show its error state and offer a retry.
|
|
28
|
+
*/
|
|
29
|
+
sendBeatFeedback: (feedback: BeatFeedbackRequest) => Promise<any>;
|
|
17
30
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { ApiEndpoints as n } from "../constants/ApiEndpoints.es.js";
|
|
2
|
-
import { Fetch as
|
|
3
|
-
var
|
|
2
|
+
import { Fetch as r } from "../utils/Fetch.es.js";
|
|
3
|
+
var o = class {
|
|
4
4
|
fetchInstance;
|
|
5
5
|
constructor(t, e, s) {
|
|
6
|
-
this.fetchInstance = new
|
|
6
|
+
this.fetchInstance = new r(t, e, void 0, s);
|
|
7
7
|
}
|
|
8
|
-
getBeats = async (t, e) => {
|
|
9
|
-
const
|
|
10
|
-
return this.fetchInstance.get(`${n.BEATS}?${
|
|
8
|
+
getBeats = async (t, e, s = "micro") => {
|
|
9
|
+
const a = `page=${t || 1}&per_page=${e || 5}&widget_type=${s}`;
|
|
10
|
+
return this.fetchInstance.get(`${n.BEATS}?${a}`).then((c) => c.beats);
|
|
11
11
|
};
|
|
12
12
|
getBeatsWithAssociatedTransaction = async (t) => {
|
|
13
13
|
let e = "has_associated_transaction_guid=true&widget_type=embedded";
|
|
@@ -16,9 +16,10 @@ var h = class {
|
|
|
16
16
|
getOffers = async () => this.fetchInstance.get(`${n.OFFERS}/${n.PULSE_COMMUNICATIONS}`).then((t) => t.pulse_communications);
|
|
17
17
|
updateBeat = async (t) => this.fetchInstance.put(`${n.BEATS}/${t.guid}`, t).then((e) => e.beat);
|
|
18
18
|
updateOffer = async (t) => this.fetchInstance.put(`${n.OFFERS}/${t.guid}`, t).then((e) => e.beat);
|
|
19
|
+
sendBeatFeedback = async (t) => this.fetchInstance.post(n.BEAT_FEEDBACK, t);
|
|
19
20
|
};
|
|
20
21
|
export {
|
|
21
|
-
|
|
22
|
+
o as BeatApi
|
|
22
23
|
};
|
|
23
24
|
|
|
24
25
|
//# sourceMappingURL=BeatApi.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BeatApi.es.js","names":[],"sources":["../../../src/core/api/BeatApi.ts"],"sourcesContent":["import { Fetch } from '../utils'\nimport { ApiEndpoints } from '../constants'\nimport type { Beat, GlobalErrorHandler } from '..'\n\nexport class BeatApi {\n fetchInstance: Fetch\n\n constructor(endpoint: string, token: string, onError?: GlobalErrorHandler) {\n this.fetchInstance = new Fetch(endpoint, token, undefined, onError)\n }\n\n getBeats = async (pageNum?: number, perPage?: number) => {\n const beatParams = `page=${pageNum ? pageNum : 1}&per_page=${perPage ? perPage : 5}`\n\n return this.fetchInstance.get(`${ApiEndpoints.BEATS}?${beatParams}`).then((data) => data.beats)\n }\n\n /**\n * The transactions widget's one beat fetch: the row pill and the details-drawer card both render\n * from what it returns, so it asks for the `embedded` envelope (Insights 2.0). A flagged beat\n * arrives with `is_insights_v2: true` and its `insights_payload` (`pill`, compact slot); a legacy\n * beat is unchanged. There is deliberately no per-drawer fetch and no pills endpoint.\n */\n getBeatsWithAssociatedTransaction = async (fromDate?: string) => {\n let beatParams = 'has_associated_transaction_guid=true&widget_type=embedded'\n beatParams += fromDate ? `&from_date=${fromDate}` : ''\n\n return this.fetchInstance.get(`${ApiEndpoints.BEATS}?${beatParams}`).then((data) => data.beats)\n }\n\n getOffers = async () => {\n return this.fetchInstance\n .get(`${ApiEndpoints.OFFERS}/${ApiEndpoints.PULSE_COMMUNICATIONS}`)\n .then((data) => data.pulse_communications)\n }\n\n updateBeat = async (beat: Beat) => {\n return this.fetchInstance\n .put(`${ApiEndpoints.BEATS}/${beat.guid}`, beat)\n .then((data) => data.beat)\n }\n\n updateOffer = async (beat: Beat) => {\n return this.fetchInstance\n .put(`${ApiEndpoints.OFFERS}/${beat.guid}`, beat)\n .then((data) => data.beat)\n }\n}\n"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"BeatApi.es.js","names":[],"sources":["../../../src/core/api/BeatApi.ts"],"sourcesContent":["import { Fetch } from '../utils'\nimport { ApiEndpoints } from '../constants'\nimport type { Beat, GlobalErrorHandler, WidgetType } from '..'\n\n/** Body of `POST /beat_feedback` (firefly permits these four; `rating` is 1 to 5 and optional). */\nexport interface BeatFeedbackRequest {\n beat_guid: string\n template: string\n comments: string\n rating?: number\n}\n\nexport class BeatApi {\n fetchInstance: Fetch\n\n constructor(endpoint: string, token: string, onError?: GlobalErrorHandler) {\n this.fetchInstance = new Fetch(endpoint, token, undefined, onError)\n }\n\n /** `widgetType` picks the envelope firefly returns for an Insights 2.0 beat; defaults to `micro`. */\n getBeats = async (pageNum?: number, perPage?: number, widgetType: WidgetType = 'micro') => {\n const beatParams = `page=${pageNum ? pageNum : 1}&per_page=${perPage ? perPage : 5}&widget_type=${widgetType}`\n\n return this.fetchInstance.get(`${ApiEndpoints.BEATS}?${beatParams}`).then((data) => data.beats)\n }\n\n /**\n * The transactions widget's one beat fetch: the row pill and the details-drawer card both render\n * from what it returns, so it asks for the `embedded` envelope (Insights 2.0). A flagged beat\n * arrives with `is_insights_v2: true` and its `insights_payload` (`pill`, compact slot); a legacy\n * beat is unchanged. There is deliberately no per-drawer fetch and no pills endpoint.\n */\n getBeatsWithAssociatedTransaction = async (fromDate?: string) => {\n let beatParams = 'has_associated_transaction_guid=true&widget_type=embedded'\n beatParams += fromDate ? `&from_date=${fromDate}` : ''\n\n return this.fetchInstance.get(`${ApiEndpoints.BEATS}?${beatParams}`).then((data) => data.beats)\n }\n\n getOffers = async () => {\n return this.fetchInstance\n .get(`${ApiEndpoints.OFFERS}/${ApiEndpoints.PULSE_COMMUNICATIONS}`)\n .then((data) => data.pulse_communications)\n }\n\n updateBeat = async (beat: Beat) => {\n return this.fetchInstance\n .put(`${ApiEndpoints.BEATS}/${beat.guid}`, beat)\n .then((data) => data.beat)\n }\n\n updateOffer = async (beat: Beat) => {\n return this.fetchInstance\n .put(`${ApiEndpoints.OFFERS}/${beat.guid}`, beat)\n .then((data) => data.beat)\n }\n\n /**\n * Rejects with an `ApiError` when firefly does not accept the feedback, so a caller (the survey\n * dialog) can show its error state and offer a retry.\n */\n sendBeatFeedback = async (feedback: BeatFeedbackRequest) => {\n return this.fetchInstance.post(ApiEndpoints.BEAT_FEEDBACK, feedback)\n }\n}\n"],"mappings":";;AAYA,IAAa,IAAb,MAAqB;AAAA,EACnB;AAAA,EAEA,YAAY,GAAkB,GAAe,GAA8B;AACzE,SAAK,gBAAgB,IAAI,EAAM,GAAU,GAAO,QAAW,CAAO;AAAA,EACpE;AAAA,EAGA,WAAW,OAAO,GAAkB,GAAkB,IAAyB,YAAY;AACzF,UAAM,IAAa,QAAQ,KAAoB,CAAA,aAAc,KAAoB,CAAA,gBAAiB,CAAA;AAElG,WAAO,KAAK,cAAc,IAAI,GAAG,EAAa,KAAA,IAAS,CAAA,EAAY,EAAE,KAAA,CAAM,MAAS,EAAK,KAAK;AAAA,EAChG;AAAA,EAQA,oCAAoC,OAAO,MAAsB;AAC/D,QAAI,IAAa;AACjB,WAAA,KAAc,IAAW,cAAc,CAAA,KAAa,IAE7C,KAAK,cAAc,IAAI,GAAG,EAAa,KAAA,IAAS,CAAA,EAAY,EAAE,KAAA,CAAM,MAAS,EAAK,KAAK;AAAA,EAChG;AAAA,EAEA,YAAY,YACH,KAAK,cACT,IAAI,GAAG,EAAa,MAAA,IAAU,EAAa,oBAAA,EAAsB,EACjE,KAAA,CAAM,MAAS,EAAK,oBAAoB;AAAA,EAG7C,aAAa,OAAO,MACX,KAAK,cACT,IAAI,GAAG,EAAa,KAAA,IAAS,EAAK,IAAA,IAAQ,CAAI,EAC9C,KAAA,CAAM,MAAS,EAAK,IAAI;AAAA,EAG7B,cAAc,OAAO,MACZ,KAAK,cACT,IAAI,GAAG,EAAa,MAAA,IAAU,EAAK,IAAA,IAAQ,CAAI,EAC/C,KAAA,CAAM,MAAS,EAAK,IAAI;AAAA,EAO7B,mBAAmB,OAAO,MACjB,KAAK,cAAc,KAAK,EAAa,eAAe,CAAQ;AAEvE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiEndpoints.es.js","names":[],"sources":["../../../src/core/constants/ApiEndpoints.ts"],"sourcesContent":["export const ApiEndpoints = {\n ACCOUNTS: 'accounts',\n AGREEMENT: 'agreement',\n ANALYTICS_EVENTS: 'analytics_events',\n ANALYTICS_FEATURE_VISITS: 'feature_visits',\n ANALYTICS_PAGEVIEWS: 'analytics_pageviews',\n ANALYTICS_SESSION: 'analytics_sessions',\n APP_DATA: 'raja/data?type=master',\n BEATS: 'beats',\n BUDGETS: 'budgets',\n CATEGORIES: 'categories',\n CHANGE_PASSWORD: 'user/change_password',\n DATE_RANGE_CATEGORY_TOTALS: 'date_range_category_totals',\n DEVICES: 'devices',\n EMAIL_VERIFICATIONS: 'email_verifications',\n GOALS: 'goals',\n HEALTH_SCORES: 'health_scores',\n HOLDINGS: 'holdings',\n INSTITUTIONS: 'institutions',\n INSIGHTS_NOTIFICATION_PROFILES: 'insight_notification_profiles',\n LOCALIZED_COPY: 'localized_copies',\n LOCALIZED_CONTENT: 'localized_content',\n MEMBERS: 'members',\n MERCHANTS: 'merchants',\n MERCHANT_BUDGETS: 'merchant_budgets',\n MONTHLY_CASH_FLOW_PROFILE: 'monthly_cash_flow_profile',\n MONTHLY_CATEGORY_TOTALS: 'monthly_category_totals',\n OFFERS: 'offers',\n NOTIFICATION_PROFILES: 'notification_profiles',\n NOTIFICATIONS: 'notifications',\n PHONE_VERIFICATIONS: 'sms_verification',\n PULSE_COMMUNICATIONS: 'pulse_communications',\n REPEATING_TRANSACTIONS: 'repeating_transactions',\n RETIREMENT_GOALS: 'retirement_goals',\n RETIREMENT_GOAL_ACCOUNTS: 'retirement_goal_accounts',\n SCHEDULED_PAYMENTS: 'scheduled_payments',\n SPENDING_PLANS: 'spending_plans',\n SUPPORT_TICKETS: 'support_tickets',\n TAGGINGS: 'taggings',\n TAGS: 'tags',\n TRANSACTION_RULES: 'transaction_rules',\n TRANSACTIONS: 'transactions',\n USER: 'user',\n USER_COMMUNICATION_PROFILE: 'user_communication_profile',\n USER_FEATURES: 'user_features',\n USER_INSIGHT_PROFILE: 'user_insight_profile',\n USER_PROFILES: 'user_profiles',\n WIDGET_URLS: 'widget_urls',\n}\n"],"mappings":"AAAA,IAAa,IAAe;AAAA,EAC1B,UAAU;AAAA,EACV,WAAW;AAAA,EACX,kBAAkB;AAAA,EAClB,0BAA0B;AAAA,EAC1B,qBAAqB;AAAA,EACrB,mBAAmB;AAAA,EACnB,UAAU;AAAA,EACV,OAAO;AAAA,EACP,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,4BAA4B;AAAA,EAC5B,SAAS;AAAA,EACT,qBAAqB;AAAA,EACrB,OAAO;AAAA,EACP,eAAe;AAAA,EACf,UAAU;AAAA,EACV,cAAc;AAAA,EACd,gCAAgC;AAAA,EAChC,gBAAgB;AAAA,EAChB,mBAAmB;AAAA,EACnB,SAAS;AAAA,EACT,WAAW;AAAA,EACX,kBAAkB;AAAA,EAClB,2BAA2B;AAAA,EAC3B,yBAAyB;AAAA,EACzB,QAAQ;AAAA,EACR,uBAAuB;AAAA,EACvB,eAAe;AAAA,EACf,qBAAqB;AAAA,EACrB,sBAAsB;AAAA,EACtB,wBAAwB;AAAA,EACxB,kBAAkB;AAAA,EAClB,0BAA0B;AAAA,EAC1B,oBAAoB;AAAA,EACpB,gBAAgB;AAAA,EAChB,iBAAiB;AAAA,EACjB,UAAU;AAAA,EACV,MAAM;AAAA,EACN,mBAAmB;AAAA,EACnB,cAAc;AAAA,EACd,MAAM;AAAA,EACN,4BAA4B;AAAA,EAC5B,eAAe;AAAA,EACf,sBAAsB;AAAA,EACtB,eAAe;AAAA,EACf,aAAa;AACf"}
|
|
1
|
+
{"version":3,"file":"ApiEndpoints.es.js","names":[],"sources":["../../../src/core/constants/ApiEndpoints.ts"],"sourcesContent":["export const ApiEndpoints = {\n ACCOUNTS: 'accounts',\n AGREEMENT: 'agreement',\n ANALYTICS_EVENTS: 'analytics_events',\n ANALYTICS_FEATURE_VISITS: 'feature_visits',\n ANALYTICS_PAGEVIEWS: 'analytics_pageviews',\n ANALYTICS_SESSION: 'analytics_sessions',\n APP_DATA: 'raja/data?type=master',\n BEAT_FEEDBACK: 'beat_feedback',\n BEATS: 'beats',\n BUDGETS: 'budgets',\n CATEGORIES: 'categories',\n CHANGE_PASSWORD: 'user/change_password',\n DATE_RANGE_CATEGORY_TOTALS: 'date_range_category_totals',\n DEVICES: 'devices',\n EMAIL_VERIFICATIONS: 'email_verifications',\n GOALS: 'goals',\n HEALTH_SCORES: 'health_scores',\n HOLDINGS: 'holdings',\n INSTITUTIONS: 'institutions',\n INSIGHTS_NOTIFICATION_PROFILES: 'insight_notification_profiles',\n LOCALIZED_COPY: 'localized_copies',\n LOCALIZED_CONTENT: 'localized_content',\n MEMBERS: 'members',\n MERCHANTS: 'merchants',\n MERCHANT_BUDGETS: 'merchant_budgets',\n MONTHLY_CASH_FLOW_PROFILE: 'monthly_cash_flow_profile',\n MONTHLY_CATEGORY_TOTALS: 'monthly_category_totals',\n OFFERS: 'offers',\n NOTIFICATION_PROFILES: 'notification_profiles',\n NOTIFICATIONS: 'notifications',\n PHONE_VERIFICATIONS: 'sms_verification',\n PULSE_COMMUNICATIONS: 'pulse_communications',\n REPEATING_TRANSACTIONS: 'repeating_transactions',\n RETIREMENT_GOALS: 'retirement_goals',\n RETIREMENT_GOAL_ACCOUNTS: 'retirement_goal_accounts',\n SCHEDULED_PAYMENTS: 'scheduled_payments',\n SPENDING_PLANS: 'spending_plans',\n SUPPORT_TICKETS: 'support_tickets',\n TAGGINGS: 'taggings',\n TAGS: 'tags',\n TRANSACTION_RULES: 'transaction_rules',\n TRANSACTIONS: 'transactions',\n USER: 'user',\n USER_COMMUNICATION_PROFILE: 'user_communication_profile',\n USER_FEATURES: 'user_features',\n USER_INSIGHT_PROFILE: 'user_insight_profile',\n USER_PROFILES: 'user_profiles',\n WIDGET_URLS: 'widget_urls',\n}\n"],"mappings":"AAAA,IAAa,IAAe;AAAA,EAC1B,UAAU;AAAA,EACV,WAAW;AAAA,EACX,kBAAkB;AAAA,EAClB,0BAA0B;AAAA,EAC1B,qBAAqB;AAAA,EACrB,mBAAmB;AAAA,EACnB,UAAU;AAAA,EACV,eAAe;AAAA,EACf,OAAO;AAAA,EACP,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,4BAA4B;AAAA,EAC5B,SAAS;AAAA,EACT,qBAAqB;AAAA,EACrB,OAAO;AAAA,EACP,eAAe;AAAA,EACf,UAAU;AAAA,EACV,cAAc;AAAA,EACd,gCAAgC;AAAA,EAChC,gBAAgB;AAAA,EAChB,mBAAmB;AAAA,EACnB,SAAS;AAAA,EACT,WAAW;AAAA,EACX,kBAAkB;AAAA,EAClB,2BAA2B;AAAA,EAC3B,yBAAyB;AAAA,EACzB,QAAQ;AAAA,EACR,uBAAuB;AAAA,EACvB,eAAe;AAAA,EACf,qBAAqB;AAAA,EACrB,sBAAsB;AAAA,EACtB,wBAAwB;AAAA,EACxB,kBAAkB;AAAA,EAClB,0BAA0B;AAAA,EAC1B,oBAAoB;AAAA,EACpB,gBAAgB;AAAA,EAChB,iBAAiB;AAAA,EACjB,UAAU;AAAA,EACV,MAAM;AAAA,EACN,mBAAmB;AAAA,EACnB,cAAc;AAAA,EACd,MAAM;AAAA,EACN,4BAA4B;AAAA,EAC5B,eAAe;AAAA,EACf,sBAAsB;AAAA,EACtB,eAAe;AAAA,EACf,aAAa;AACf"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BeatApi } from '../api';
|
|
2
|
-
import { Beat } from '../types';
|
|
2
|
+
import { Beat, WidgetType } from '../types';
|
|
3
3
|
import { GlobalStore } from './GlobalStore';
|
|
4
4
|
export declare class BeatStore {
|
|
5
5
|
globalStore: GlobalStore;
|
|
@@ -7,7 +7,7 @@ export declare class BeatStore {
|
|
|
7
7
|
beats: Beat[];
|
|
8
8
|
isLoading: boolean;
|
|
9
9
|
constructor(globalStore: GlobalStore);
|
|
10
|
-
loadBeats: () => Promise<void>;
|
|
10
|
+
loadBeats: (widgetType?: WidgetType) => Promise<void>;
|
|
11
11
|
/**
|
|
12
12
|
* Persists changes to an offer-backed beat (pulse marketing offers, `PUT offers/:guid`),
|
|
13
13
|
* e.g. flagging `has_been_clicked` when its CTA is pressed. Rethrows so callers driving
|
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
import { BeatApi as
|
|
1
|
+
import { BeatApi as s } from "../api/BeatApi.es.js";
|
|
2
2
|
import { orderArray as o, transformOfferIntoBeatLikeObject as n } from "../utils/BeatUtils.es.js";
|
|
3
|
-
import { makeAutoObservable as f, runInAction as
|
|
4
|
-
var
|
|
3
|
+
import { makeAutoObservable as f, runInAction as i } from "mobx";
|
|
4
|
+
var d = class {
|
|
5
5
|
globalStore;
|
|
6
|
-
api = new
|
|
6
|
+
api = new s("/", "");
|
|
7
7
|
beats = [];
|
|
8
8
|
isLoading = !1;
|
|
9
|
-
constructor(
|
|
10
|
-
this.globalStore =
|
|
9
|
+
constructor(e) {
|
|
10
|
+
this.globalStore = e, this.api = new s(e.endpoint, e.sessionToken, e.onError), f(this);
|
|
11
11
|
}
|
|
12
|
-
loadBeats = async () => {
|
|
12
|
+
loadBeats = async (e = "micro") => {
|
|
13
13
|
this.isLoading = !0;
|
|
14
14
|
try {
|
|
15
|
-
const t = await this.api.getBeats(
|
|
16
|
-
|
|
17
|
-
this.beats = o(t,
|
|
15
|
+
const t = await this.api.getBeats(void 0, void 0, e), r = (await this.api.getOffers()).map((a) => n(a));
|
|
16
|
+
i(() => {
|
|
17
|
+
this.beats = o(t, r, "active_at", "desc");
|
|
18
18
|
});
|
|
19
19
|
} catch (t) {
|
|
20
20
|
this.captureError("loadBeats", t);
|
|
21
21
|
} finally {
|
|
22
|
-
|
|
22
|
+
i(() => {
|
|
23
23
|
this.isLoading = !1;
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
|
-
updateOffer = async (
|
|
27
|
+
updateOffer = async (e) => {
|
|
28
28
|
try {
|
|
29
|
-
const
|
|
30
|
-
return
|
|
31
|
-
this.beats = this.beats.map((r) => r.guid ===
|
|
29
|
+
const t = await this.api.updateOffer(e);
|
|
30
|
+
return i(() => {
|
|
31
|
+
this.beats = this.beats.map((r) => r.guid === e.guid ? {
|
|
32
32
|
...r,
|
|
33
|
-
...
|
|
33
|
+
...t
|
|
34
34
|
} : r);
|
|
35
|
-
}),
|
|
36
|
-
} catch (
|
|
37
|
-
throw this.captureError("updateOffer",
|
|
35
|
+
}), t;
|
|
36
|
+
} catch (t) {
|
|
37
|
+
throw this.captureError("updateOffer", t), t;
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
|
-
getFilteredBeats(
|
|
41
|
-
const { categoryGuids:
|
|
40
|
+
getFilteredBeats(e) {
|
|
41
|
+
const { categoryGuids: t, templates: r } = e;
|
|
42
42
|
let a = this.beats;
|
|
43
|
-
return
|
|
43
|
+
return t && (a = this.filterBeatsByCategory(a, t)), r && (a = this.filterBeatsByTemplate(a, r)), a;
|
|
44
44
|
}
|
|
45
|
-
filterBeatsByCategory(
|
|
46
|
-
return
|
|
45
|
+
filterBeatsByCategory(e, t) {
|
|
46
|
+
return e.filter((r) => r.category_guids?.some((a) => t.includes(a)));
|
|
47
47
|
}
|
|
48
|
-
filterBeatsByTemplate(
|
|
49
|
-
return
|
|
48
|
+
filterBeatsByTemplate(e, t) {
|
|
49
|
+
return e.filter((r) => t.some((a) => r.template === a));
|
|
50
50
|
}
|
|
51
|
-
captureError = (
|
|
51
|
+
captureError = (e, t) => this.globalStore.captureException(t, {
|
|
52
52
|
store: "BeatStore",
|
|
53
|
-
action:
|
|
53
|
+
action: e
|
|
54
54
|
});
|
|
55
55
|
};
|
|
56
56
|
export {
|
|
57
|
-
|
|
57
|
+
d as BeatStore
|
|
58
58
|
};
|
|
59
59
|
|
|
60
60
|
//# sourceMappingURL=BeatStore.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BeatStore.es.js","names":[],"sources":["../../../src/core/stores/BeatStore.ts"],"sourcesContent":["import { makeAutoObservable, runInAction } from 'mobx'\n\nimport { BeatApi } from '../api'\nimport type { Beat, Offer } from '../types'\nimport { orderArray, transformOfferIntoBeatLikeObject } from '../utils/BeatUtils'\n\nimport { GlobalStore } from './GlobalStore'\n\nexport class BeatStore {\n globalStore: GlobalStore\n api: BeatApi = new BeatApi('/', '')\n beats: Beat[] = []\n isLoading = false\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n this.api = new BeatApi(globalStore.endpoint, globalStore.sessionToken, globalStore.onError)\n\n makeAutoObservable(this)\n }\n\n loadBeats = async () => {\n this.isLoading = true\n try {\n const beats = await this.api.getBeats()\n const offers = await this.api.getOffers()\n const beatLikeOffers = offers.map((o: Offer) => transformOfferIntoBeatLikeObject(o))\n\n runInAction(() => {\n this.beats = orderArray(beats, beatLikeOffers, 'active_at', 'desc')\n })\n } catch (error) {\n this.captureError('loadBeats', error)\n } finally {\n runInAction(() => {\n this.isLoading = false\n })\n }\n }\n\n /**\n * Persists changes to an offer-backed beat (pulse marketing offers, `PUT offers/:guid`),\n * e.g. flagging `has_been_clicked` when its CTA is pressed. Rethrows so callers driving\n * UI state can surface the failure.\n */\n updateOffer = async (beat: Beat) => {\n try {\n const updated = await this.api.updateOffer(beat)\n\n runInAction(() => {\n this.beats = this.beats.map((b) => (b.guid === beat.guid ? { ...b, ...updated } : b))\n })\n\n return updated\n } catch (error) {\n this.captureError('updateOffer', error)\n throw error\n }\n }\n\n getFilteredBeats(filter: { categoryGuids?: string[]; templates?: string[] }): Beat[] {\n const { categoryGuids, templates } = filter\n let filteredBeats = this.beats\n if (categoryGuids) filteredBeats = this.filterBeatsByCategory(filteredBeats, categoryGuids)\n if (templates) filteredBeats = this.filterBeatsByTemplate(filteredBeats, templates)\n return filteredBeats\n }\n\n // Return beats with any beat.category_guids that are in categoryGuids\n filterBeatsByCategory(beats: Beat[], categoryGuids: string[]): Beat[] {\n return beats.filter((beat) => {\n return beat.category_guids?.some((guid) => categoryGuids.includes(guid))\n })\n }\n\n // Return beats with a beat.template that is in templates\n filterBeatsByTemplate(beats: Beat[], templates: string[]): Beat[] {\n return beats.filter((beat) => {\n return templates.some((template) => beat.template === template)\n })\n }\n\n private captureError = (action: string, error: unknown) =>\n this.globalStore.captureException(error, { store: 'BeatStore', action })\n}\n"],"mappings":";;;AAQA,IAAa,IAAb,MAAuB;AAAA,EACrB;AAAA,EACA,MAAe,IAAI,EAAQ,KAAK,EAAE;AAAA,EAClC,QAAgB,CAAC;AAAA,EACjB,YAAY;AAAA,EAEZ,YAAY,GAA0B;AACpC,SAAK,cAAc,GACnB,KAAK,MAAM,IAAI,EAAQ,EAAY,UAAU,EAAY,cAAc,EAAY,OAAO,GAE1F,EAAmB,IAAI;AAAA,EACzB;AAAA,EAEA,YAAY,YAAY;
|
|
1
|
+
{"version":3,"file":"BeatStore.es.js","names":[],"sources":["../../../src/core/stores/BeatStore.ts"],"sourcesContent":["import { makeAutoObservable, runInAction } from 'mobx'\n\nimport { BeatApi } from '../api'\nimport type { Beat, Offer, WidgetType } from '../types'\nimport { orderArray, transformOfferIntoBeatLikeObject } from '../utils/BeatUtils'\n\nimport { GlobalStore } from './GlobalStore'\n\nexport class BeatStore {\n globalStore: GlobalStore\n api: BeatApi = new BeatApi('/', '')\n beats: Beat[] = []\n isLoading = false\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n this.api = new BeatApi(globalStore.endpoint, globalStore.sessionToken, globalStore.onError)\n\n makeAutoObservable(this)\n }\n\n loadBeats = async (widgetType: WidgetType = 'micro') => {\n this.isLoading = true\n try {\n const beats = await this.api.getBeats(undefined, undefined, widgetType)\n const offers = await this.api.getOffers()\n const beatLikeOffers = offers.map((o: Offer) => transformOfferIntoBeatLikeObject(o))\n\n runInAction(() => {\n this.beats = orderArray(beats, beatLikeOffers, 'active_at', 'desc')\n })\n } catch (error) {\n this.captureError('loadBeats', error)\n } finally {\n runInAction(() => {\n this.isLoading = false\n })\n }\n }\n\n /**\n * Persists changes to an offer-backed beat (pulse marketing offers, `PUT offers/:guid`),\n * e.g. flagging `has_been_clicked` when its CTA is pressed. Rethrows so callers driving\n * UI state can surface the failure.\n */\n updateOffer = async (beat: Beat) => {\n try {\n const updated = await this.api.updateOffer(beat)\n\n runInAction(() => {\n this.beats = this.beats.map((b) => (b.guid === beat.guid ? { ...b, ...updated } : b))\n })\n\n return updated\n } catch (error) {\n this.captureError('updateOffer', error)\n throw error\n }\n }\n\n getFilteredBeats(filter: { categoryGuids?: string[]; templates?: string[] }): Beat[] {\n const { categoryGuids, templates } = filter\n let filteredBeats = this.beats\n if (categoryGuids) filteredBeats = this.filterBeatsByCategory(filteredBeats, categoryGuids)\n if (templates) filteredBeats = this.filterBeatsByTemplate(filteredBeats, templates)\n return filteredBeats\n }\n\n // Return beats with any beat.category_guids that are in categoryGuids\n filterBeatsByCategory(beats: Beat[], categoryGuids: string[]): Beat[] {\n return beats.filter((beat) => {\n return beat.category_guids?.some((guid) => categoryGuids.includes(guid))\n })\n }\n\n // Return beats with a beat.template that is in templates\n filterBeatsByTemplate(beats: Beat[], templates: string[]): Beat[] {\n return beats.filter((beat) => {\n return templates.some((template) => beat.template === template)\n })\n }\n\n private captureError = (action: string, error: unknown) =>\n this.globalStore.captureException(error, { store: 'BeatStore', action })\n}\n"],"mappings":";;;AAQA,IAAa,IAAb,MAAuB;AAAA,EACrB;AAAA,EACA,MAAe,IAAI,EAAQ,KAAK,EAAE;AAAA,EAClC,QAAgB,CAAC;AAAA,EACjB,YAAY;AAAA,EAEZ,YAAY,GAA0B;AACpC,SAAK,cAAc,GACnB,KAAK,MAAM,IAAI,EAAQ,EAAY,UAAU,EAAY,cAAc,EAAY,OAAO,GAE1F,EAAmB,IAAI;AAAA,EACzB;AAAA,EAEA,YAAY,OAAO,IAAyB,YAAY;AACtD,SAAK,YAAY;AACjB,QAAI;AACF,YAAM,IAAQ,MAAM,KAAK,IAAI,SAAS,QAAW,QAAW,CAAU,GAEhE,KAAiB,MADF,KAAK,IAAI,UAAU,GACV,IAAA,CAAK,MAAa,EAAiC,CAAC,CAAC;AAEnF,MAAA,EAAA,MAAkB;AAChB,aAAK,QAAQ,EAAW,GAAO,GAAgB,aAAa,MAAM;AAAA,MACpE,CAAC;AAAA,IACH,SAAS,GAAO;AACd,WAAK,aAAa,aAAa,CAAK;AAAA,IACtC,UAAA;AACE,MAAA,EAAA,MAAkB;AAChB,aAAK,YAAY;AAAA,MACnB,CAAC;AAAA,IACH;AAAA,EACF;AAAA,EAOA,cAAc,OAAO,MAAe;AAClC,QAAI;AACF,YAAM,IAAU,MAAM,KAAK,IAAI,YAAY,CAAI;AAE/C,aAAA,EAAA,MAAkB;AAChB,aAAK,QAAQ,KAAK,MAAM,IAAA,CAAK,MAAO,EAAE,SAAS,EAAK,OAAO;AAAA,UAAE,GAAG;AAAA,UAAG,GAAG;AAAA,QAAQ,IAAI,CAAE;AAAA,MACtF,CAAC,GAEM;AAAA,IACT,SAAS,GAAO;AACd,iBAAK,aAAa,eAAe,CAAK,GAChC;AAAA,IACR;AAAA,EACF;AAAA,EAEA,iBAAiB,GAAoE;AACnF,UAAM,EAAE,eAAA,GAAe,WAAA,EAAA,IAAc;AACrC,QAAI,IAAgB,KAAK;AACzB,WAAI,MAAe,IAAgB,KAAK,sBAAsB,GAAe,CAAa,IACtF,MAAW,IAAgB,KAAK,sBAAsB,GAAe,CAAS,IAC3E;AAAA,EACT;AAAA,EAGA,sBAAsB,GAAe,GAAiC;AACpE,WAAO,EAAM,OAAA,CAAQ,MACZ,EAAK,gBAAgB,KAAA,CAAM,MAAS,EAAc,SAAS,CAAI,CAAC,CACxE;AAAA,EACH;AAAA,EAGA,sBAAsB,GAAe,GAA6B;AAChE,WAAO,EAAM,OAAA,CAAQ,MACZ,EAAU,KAAA,CAAM,MAAa,EAAK,aAAa,CAAQ,CAC/D;AAAA,EACH;AAAA,EAEA,eAAA,CAAwB,GAAgB,MACtC,KAAK,YAAY,iBAAiB,GAAO;AAAA,IAAE,OAAO;AAAA,IAAa,QAAA;AAAA,EAAO,CAAC;AAC3E"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { InDescriptionCTA } from '../types/Insights';
|
|
1
2
|
import { GlobalStore } from './GlobalStore';
|
|
2
3
|
export type ActionDrawerTrigger = 'primaryCta' | 'secondaryCta' | 'chartBar' | 'inDescriptionCta';
|
|
3
4
|
export interface ActionDrawerState {
|
|
@@ -19,13 +20,25 @@ export interface ActionDrawerState {
|
|
|
19
20
|
* envelope) — not on every `setActionContext` call.
|
|
20
21
|
*/
|
|
21
22
|
context: unknown;
|
|
23
|
+
/**
|
|
24
|
+
* Block and variant an `inDescriptionCta` drawer runs; without it the beat's own
|
|
25
|
+
* `in_description_cta` is used. Replaced on each open, kept through close like `trigger`.
|
|
26
|
+
*/
|
|
27
|
+
cta?: DrawerCta;
|
|
22
28
|
}
|
|
23
29
|
export declare const CLOSED_ACTION_DRAWER: ActionDrawerState;
|
|
24
|
-
|
|
30
|
+
/** The block and variant an opener picks for an `inDescriptionCta` drawer. */
|
|
31
|
+
export type DrawerCta = Pick<InDescriptionCTA, 'block' | 'variant'>;
|
|
32
|
+
type OpenActionDrawerArgs = {
|
|
25
33
|
guid: string;
|
|
26
|
-
trigger: ActionDrawerTrigger;
|
|
27
34
|
context?: unknown;
|
|
28
|
-
}
|
|
35
|
+
} & ({
|
|
36
|
+
trigger: 'inDescriptionCta';
|
|
37
|
+
cta?: DrawerCta;
|
|
38
|
+
} | {
|
|
39
|
+
trigger: Exclude<ActionDrawerTrigger, 'inDescriptionCta'>;
|
|
40
|
+
cta?: never;
|
|
41
|
+
});
|
|
29
42
|
/** Lifecycle of a beat's CTA action (see insights-v2/ctaActions), keyed by beat guid. */
|
|
30
43
|
export type CtaStatus = 'pending' | 'done' | 'error';
|
|
31
44
|
/**
|
|
@@ -69,9 +82,10 @@ export declare class InsightsV2Store {
|
|
|
69
82
|
/**
|
|
70
83
|
* Generic drawer opener — the only opener a new action block needs. Pass the
|
|
71
84
|
* beat guid, the CTA/source that triggered it, and (optionally) a block-specific
|
|
72
|
-
* context object the block reads back via useActionContext.
|
|
85
|
+
* context object the block reads back via useActionContext. `cta` overrides the CTA an
|
|
86
|
+
* `inDescriptionCta` drawer runs, for this session only.
|
|
73
87
|
*/
|
|
74
|
-
openActionDrawer: ({ guid, trigger, context }: OpenActionDrawerArgs) => void;
|
|
88
|
+
openActionDrawer: ({ guid, trigger, context, cta }: OpenActionDrawerArgs) => void;
|
|
75
89
|
/** Convenience opener for CTA drawers (no drilldown context). */
|
|
76
90
|
openCtaDrawer: (guid: string, trigger: "primaryCta" | "secondaryCta") => void;
|
|
77
91
|
closeActionDrawer: () => void;
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { makeAutoObservable as
|
|
2
|
-
var
|
|
1
|
+
import { makeAutoObservable as o } from "mobx";
|
|
2
|
+
var i = {
|
|
3
3
|
isDrawerOpen: !1,
|
|
4
4
|
trigger: "primaryCta",
|
|
5
5
|
guid: "",
|
|
6
|
-
context: void 0
|
|
7
|
-
|
|
6
|
+
context: void 0,
|
|
7
|
+
cta: void 0
|
|
8
|
+
}, n = class {
|
|
8
9
|
globalStore;
|
|
9
|
-
actionDrawer =
|
|
10
|
+
actionDrawer = i;
|
|
10
11
|
ctaStatus = {};
|
|
11
12
|
beatContext = {};
|
|
12
13
|
constructor(t) {
|
|
13
|
-
this.globalStore = t,
|
|
14
|
+
this.globalStore = t, o(this);
|
|
14
15
|
}
|
|
15
16
|
setCtaStatus = (t, e) => {
|
|
16
17
|
this.ctaStatus = {
|
|
@@ -36,12 +37,13 @@ var o = {
|
|
|
36
37
|
}
|
|
37
38
|
};
|
|
38
39
|
};
|
|
39
|
-
openActionDrawer = ({ guid: t, trigger: e, context: a }) => {
|
|
40
|
+
openActionDrawer = ({ guid: t, trigger: e, context: a, cta: r }) => {
|
|
40
41
|
this.actionDrawer = {
|
|
41
42
|
isDrawerOpen: !0,
|
|
42
43
|
trigger: e,
|
|
43
44
|
guid: t,
|
|
44
|
-
context: a
|
|
45
|
+
context: a,
|
|
46
|
+
cta: r
|
|
45
47
|
};
|
|
46
48
|
};
|
|
47
49
|
openCtaDrawer = (t, e) => {
|
|
@@ -59,8 +61,8 @@ var o = {
|
|
|
59
61
|
};
|
|
60
62
|
};
|
|
61
63
|
export {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
+
i as CLOSED_ACTION_DRAWER,
|
|
65
|
+
n as InsightsV2Store
|
|
64
66
|
};
|
|
65
67
|
|
|
66
68
|
//# sourceMappingURL=InsightsV2Store.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InsightsV2Store.es.js","names":[],"sources":["../../../src/core/stores/InsightsV2Store.ts"],"sourcesContent":["import { makeAutoObservable } from 'mobx'\n\nimport type { GlobalStore } from './GlobalStore'\n\n// `inDescriptionCta`: the link inside a card's description (`insights_payload.in_description_cta`).\nexport type ActionDrawerTrigger = 'primaryCta' | 'secondaryCta' | 'chartBar' | 'inDescriptionCta'\n\nexport interface ActionDrawerState {\n isDrawerOpen: boolean\n trigger: ActionDrawerTrigger\n guid: string\n /**\n * Block-specific drilldown data for the current drawer SESSION, opaque to the\n * store. Each action block defines and reads its own shape (via\n * useActionContext<T>()). Chart drilldowns put `{ chartBarIndex, tabIndex }`\n * here; CTAs carry none.\n *\n * This is an accumulating bag, not a single owner's value: a nested drawer\n * (e.g. TransactionDetailsBlock opened from a row inside TransactionHistory\n * Block) adds its own key via `setActionContext` ON TOP of whatever the outer\n * drawer already put here, so the outer block's own context survives while the\n * nested block is open. It resets to a clean slate only when a NEW drawer\n * session starts (`openActionDrawer`/`openCtaDrawer`, which fully replace the\n * envelope) — not on every `setActionContext` call.\n */\n context: unknown\n}\n\nexport const CLOSED_ACTION_DRAWER: ActionDrawerState = {\n isDrawerOpen: false,\n trigger: 'primaryCta',\n guid: '',\n context: undefined,\n}\n\
|
|
1
|
+
{"version":3,"file":"InsightsV2Store.es.js","names":[],"sources":["../../../src/core/stores/InsightsV2Store.ts"],"sourcesContent":["import { makeAutoObservable } from 'mobx'\n\nimport type { InDescriptionCTA } from '../types/Insights'\n\nimport type { GlobalStore } from './GlobalStore'\n\n// `inDescriptionCta`: the link inside a card's description (`insights_payload.in_description_cta`).\nexport type ActionDrawerTrigger = 'primaryCta' | 'secondaryCta' | 'chartBar' | 'inDescriptionCta'\n\nexport interface ActionDrawerState {\n isDrawerOpen: boolean\n trigger: ActionDrawerTrigger\n guid: string\n /**\n * Block-specific drilldown data for the current drawer SESSION, opaque to the\n * store. Each action block defines and reads its own shape (via\n * useActionContext<T>()). Chart drilldowns put `{ chartBarIndex, tabIndex }`\n * here; CTAs carry none.\n *\n * This is an accumulating bag, not a single owner's value: a nested drawer\n * (e.g. TransactionDetailsBlock opened from a row inside TransactionHistory\n * Block) adds its own key via `setActionContext` ON TOP of whatever the outer\n * drawer already put here, so the outer block's own context survives while the\n * nested block is open. It resets to a clean slate only when a NEW drawer\n * session starts (`openActionDrawer`/`openCtaDrawer`, which fully replace the\n * envelope) — not on every `setActionContext` call.\n */\n context: unknown\n /**\n * Block and variant an `inDescriptionCta` drawer runs; without it the beat's own\n * `in_description_cta` is used. Replaced on each open, kept through close like `trigger`.\n */\n cta?: DrawerCta\n}\n\nexport const CLOSED_ACTION_DRAWER: ActionDrawerState = {\n isDrawerOpen: false,\n trigger: 'primaryCta',\n guid: '',\n context: undefined,\n cta: undefined,\n}\n\n/** The block and variant an opener picks for an `inDescriptionCta` drawer. */\nexport type DrawerCta = Pick<InDescriptionCTA, 'block' | 'variant'>\n\n// Only the `inDescriptionCta` trigger accepts a `cta`.\ntype OpenActionDrawerArgs = {\n guid: string\n context?: unknown\n} & (\n | { trigger: 'inDescriptionCta'; cta?: DrawerCta }\n | { trigger: Exclude<ActionDrawerTrigger, 'inDescriptionCta'>; cta?: never }\n)\n\n/** Lifecycle of a beat's CTA action (see insights-v2/ctaActions), keyed by beat guid. */\nexport type CtaStatus = 'pending' | 'done' | 'error'\n\n/**\n * UI state shared across the insights-v2 widget tree. Owns the action drawer so\n * cards, charts, and action blocks coordinate through the store instead of prop\n * drilling. The drawer state is a fixed envelope (isDrawerOpen/guid/trigger) plus\n * an opaque `context` bag, so per-block drilldown data never leaks into this shape.\n */\nexport class InsightsV2Store {\n globalStore: GlobalStore\n\n actionDrawer: ActionDrawerState = CLOSED_ACTION_DRAWER\n\n /**\n * CTA action status per beat guid. Keyed by guid (not block) so a block shared by many\n * insights never reflects another card's pending or error state.\n */\n ctaStatus: Record<string, CtaStatus> = {}\n\n /**\n * Per-beat scratch input collected on the card or in its blocks (e.g. the account a user\n * picked before pressing Save), keyed by beat guid. Unlike `actionDrawer.context`, which is\n * replaced whenever any drawer session starts, this survives other cards' drawers opening.\n * CTA steps read it via `disabledWhen` and their `params` callback (`beatContextOf`). Ships\n * ahead of its first block writer (Designate's account picker) on purpose: it is the layer's\n * only way to keep a pick alive across other cards' drawer sessions.\n */\n beatContext: Record<string, Record<string, unknown>> = {}\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n\n makeAutoObservable(this)\n }\n\n setCtaStatus = (guid: string, status: CtaStatus) => {\n this.ctaStatus = { ...this.ctaStatus, [guid]: status }\n }\n\n /** Merges `values` into the beat's scratch input. */\n setBeatContext = (guid: string, values: Record<string, unknown>) => {\n this.beatContext = { ...this.beatContext, [guid]: { ...this.beatContext[guid], ...values } }\n }\n\n /**\n * Merges keys into the current drawer session's context bag — it does NOT\n * replace it. A nested drawer (e.g. a row click inside TransactionHistoryBlock\n * opening TransactionDetailsBlock) calls this to layer its own key (e.g.\n * `transaction_guid`) on top of whatever context the outer drawer already set\n * (e.g. `chartBarIndex`), so the outer block keeps reading its own keys via\n * useActionContext while the nested block is open. The bag only returns to a\n * clean slate when a new drawer session starts via `openActionDrawer`/\n * `openCtaDrawer`, which fully replace the envelope.\n */\n setActionContext = (context: Record<string, unknown>) => {\n this.actionDrawer = {\n ...this.actionDrawer,\n context: {\n ...(this.actionDrawer.context as Record<string, unknown> | undefined),\n ...context,\n },\n }\n }\n\n /**\n * Generic drawer opener — the only opener a new action block needs. Pass the\n * beat guid, the CTA/source that triggered it, and (optionally) a block-specific\n * context object the block reads back via useActionContext. `cta` overrides the CTA an\n * `inDescriptionCta` drawer runs, for this session only.\n */\n openActionDrawer = ({ guid, trigger, context, cta }: OpenActionDrawerArgs) => {\n this.actionDrawer = { isDrawerOpen: true, trigger, guid, context, cta }\n }\n\n /** Convenience opener for CTA drawers (no drilldown context). */\n openCtaDrawer = (guid: string, trigger: 'primaryCta' | 'secondaryCta') => {\n this.openActionDrawer({ guid, trigger })\n }\n\n closeActionDrawer = () => {\n // Preserve `trigger`, `context` and `cta` so the drawer keeps its variant-specific\n // title/content through the slide-out animation (ActionBlockLayer stays\n // mounted while closing). Only flip isDrawerOpen off and clear the beat guid.\n this.actionDrawer = { ...this.actionDrawer, isDrawerOpen: false, guid: '' }\n }\n}\n"],"mappings":";AAmCA,IAAa,IAA0C;AAAA,EACrD,cAAc;AAAA,EACd,SAAS;AAAA,EACT,MAAM;AAAA,EACN,SAAS;AAAA,EACT,KAAK;AACP,GAuBa,IAAb,MAA6B;AAAA,EAC3B;AAAA,EAEA,eAAkC;AAAA,EAMlC,YAAuC,CAAC;AAAA,EAUxC,cAAuD,CAAC;AAAA,EAExD,YAAY,GAA0B;AACpC,SAAK,cAAc,GAEnB,EAAmB,IAAI;AAAA,EACzB;AAAA,EAEA,eAAA,CAAgB,GAAc,MAAsB;AAClD,SAAK,YAAY;AAAA,MAAE,GAAG,KAAK;AAAA,MAAY,CAAA,CAAA,GAAO;AAAA,IAAO;AAAA,EACvD;AAAA,EAGA,iBAAA,CAAkB,GAAc,MAAoC;AAClE,SAAK,cAAc;AAAA,MAAE,GAAG,KAAK;AAAA,MAAc,CAAA,CAAA,GAAO;AAAA,QAAE,GAAG,KAAK,YAAY,CAAA;AAAA,QAAO,GAAG;AAAA,MAAO;AAAA,IAAE;AAAA,EAC7F;AAAA,EAYA,mBAAA,CAAoB,MAAqC;AACvD,SAAK,eAAe;AAAA,MAClB,GAAG,KAAK;AAAA,MACR,SAAS;AAAA,QACP,GAAI,KAAK,aAAa;AAAA,QACtB,GAAG;AAAA,MACL;AAAA,IACF;AAAA,EACF;AAAA,EAQA,mBAAA,CAAoB,EAAE,MAAA,GAAM,SAAA,GAAS,SAAA,GAAS,KAAA,EAAA,MAAgC;AAC5E,SAAK,eAAe;AAAA,MAAE,cAAc;AAAA,MAAM,SAAA;AAAA,MAAS,MAAA;AAAA,MAAM,SAAA;AAAA,MAAS,KAAA;AAAA,IAAI;AAAA,EACxE;AAAA,EAGA,gBAAA,CAAiB,GAAc,MAA2C;AACxE,SAAK,iBAAiB;AAAA,MAAE,MAAA;AAAA,MAAM,SAAA;AAAA,IAAQ,CAAC;AAAA,EACzC;AAAA,EAEA,oBAAA,MAA0B;AAIxB,SAAK,eAAe;AAAA,MAAE,GAAG,KAAK;AAAA,MAAc,cAAc;AAAA,MAAO,MAAM;AAAA,IAAG;AAAA,EAC5E;AACF"}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
var
|
|
1
|
+
var C = (t, e, r) => t.context?.block === e?.block ? e : r, n = (t, e, r, g) => t.trigger === "inDescriptionCta" ? t.cta ? {
|
|
2
|
+
label: "",
|
|
3
|
+
...t.cta
|
|
4
|
+
} : g : t.trigger === "secondaryCta" ? r ?? e : t.trigger === "primaryCta" ? e : C(t, e, r) ?? e;
|
|
2
5
|
export {
|
|
3
|
-
|
|
4
|
-
|
|
6
|
+
C as getCtaForChartBarClick,
|
|
7
|
+
n as getDynamicCtaBasedOnTriggers
|
|
5
8
|
};
|
|
6
9
|
|
|
7
10
|
//# sourceMappingURL=util.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.es.js","names":[],"sources":["../../../src/insights-v2/actionBlocks/util.ts"],"sourcesContent":["import type {\n ActionDrawerState,\n DrilldownPayload,\n InDescriptionCTA,\n PrimaryCTA,\n SecondaryCTA,\n} from '../../core'\n\n/**\n * A chart-bar drilldown's context carries which block it targets (see BarchartBlock /\n * DoubleBarChartBlock), since either CTA could in principle open the same drawer. Match that\n * against `primary_cta.block`; anything else is assumed to be the secondary CTA's block.\n */\nexport const getCtaForChartBarClick = (\n actionDrawer: ActionDrawerState,\n primary_cta: PrimaryCTA | undefined,\n secondary_cta: SecondaryCTA | undefined,\n): PrimaryCTA | SecondaryCTA | undefined => {\n const context = actionDrawer.context as DrilldownPayload | undefined\n const blockName = context?.block\n\n if (blockName === primary_cta?.block) {\n return primary_cta\n }\n return secondary_cta\n}\n\n/**\n * Resolves which CTA (primary/secondary/in-description) drives the currently open drawer's\n * title/variant, based on what triggered it. Falls back to `primary_cta` whenever resolution comes\n * up empty (e.g. a `secondaryCta` trigger with no configured secondary CTA), so callers never have\n * to null-check.\n */\nexport const getDynamicCtaBasedOnTriggers = (\n actionDrawer: ActionDrawerState,\n primary_cta: PrimaryCTA | undefined,\n secondary_cta: SecondaryCTA | undefined,\n in_description_cta?: InDescriptionCTA,\n): PrimaryCTA | SecondaryCTA | InDescriptionCTA | undefined => {\n // The
|
|
1
|
+
{"version":3,"file":"util.es.js","names":[],"sources":["../../../src/insights-v2/actionBlocks/util.ts"],"sourcesContent":["import type {\n ActionDrawerState,\n DrilldownPayload,\n InDescriptionCTA,\n PrimaryCTA,\n SecondaryCTA,\n} from '../../core'\n\n/**\n * A chart-bar drilldown's context carries which block it targets (see BarchartBlock /\n * DoubleBarChartBlock), since either CTA could in principle open the same drawer. Match that\n * against `primary_cta.block`; anything else is assumed to be the secondary CTA's block.\n */\nexport const getCtaForChartBarClick = (\n actionDrawer: ActionDrawerState,\n primary_cta: PrimaryCTA | undefined,\n secondary_cta: SecondaryCTA | undefined,\n): PrimaryCTA | SecondaryCTA | undefined => {\n const context = actionDrawer.context as DrilldownPayload | undefined\n const blockName = context?.block\n\n if (blockName === primary_cta?.block) {\n return primary_cta\n }\n return secondary_cta\n}\n\n/**\n * Resolves which CTA (primary/secondary/in-description) drives the currently open drawer's\n * title/variant, based on what triggered it. Falls back to `primary_cta` whenever resolution comes\n * up empty (e.g. a `secondaryCta` trigger with no configured secondary CTA), so callers never have\n * to null-check.\n */\nexport const getDynamicCtaBasedOnTriggers = (\n actionDrawer: ActionDrawerState,\n primary_cta: PrimaryCTA | undefined,\n secondary_cta: SecondaryCTA | undefined,\n in_description_cta?: InDescriptionCTA,\n): PrimaryCTA | SecondaryCTA | InDescriptionCTA | undefined => {\n // The opener may supply the block and variant, else the beat's link names them. Nothing to fall\n // back to: only the link's own button fires this trigger.\n if (actionDrawer.trigger === 'inDescriptionCta') {\n return actionDrawer.cta ? { label: '', ...actionDrawer.cta } : in_description_cta\n }\n if (actionDrawer.trigger === 'secondaryCta') {\n return secondary_cta ?? primary_cta\n }\n if (actionDrawer.trigger === 'primaryCta') {\n return primary_cta\n }\n return getCtaForChartBarClick(actionDrawer, primary_cta, secondary_cta) ?? primary_cta\n}\n"],"mappings":"AAaA,IAAa,IAAA,CACX,GACA,GACA,MAEgB,EAAa,SACF,UAET,GAAa,QACtB,IAEF,GASI,IAAA,CACX,GACA,GACA,GACA,MAII,EAAa,YAAY,qBACpB,EAAa,MAAM;AAAA,EAAE,OAAO;AAAA,EAAI,GAAG,EAAa;AAAI,IAAI,IAE7D,EAAa,YAAY,iBACpB,KAAiB,IAEtB,EAAa,YAAY,eACpB,IAEF,EAAuB,GAAc,GAAa,CAAa,KAAK"}
|
|
@@ -1,55 +1,56 @@
|
|
|
1
|
-
import { useCombineEvents as
|
|
2
|
-
import { useWidgetLoadTimer as
|
|
3
|
-
import { AppStore as
|
|
4
|
-
import { InsightsMicroWidgetDataProvider as
|
|
5
|
-
import { SUPPORTED_CAROUSEL_HEIGHTS as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import { NoRelevantInsightsCard as
|
|
10
|
-
import { ZeroStateCard as
|
|
11
|
-
import
|
|
1
|
+
import { useCombineEvents as j, useCombinePageviews as $ } from "../common/hooks/useCombineEvents.es.js";
|
|
2
|
+
import { useWidgetLoadTimer as U } from "../common/hooks/useWidgetLoadTimer.es.js";
|
|
3
|
+
import { AppStore as Y } from "./stores/AppStore.es.js";
|
|
4
|
+
import { InsightsMicroWidgetDataProvider as Z } from "./context/InsightsMicroWidgetDataProvider.es.js";
|
|
5
|
+
import { SUPPORTED_CAROUSEL_HEIGHTS as q } from "./constants/App.es.js";
|
|
6
|
+
import B from "./carousel/MicroBeatCarousel.es.js";
|
|
7
|
+
import F from "./carousel/CarouselHeader.es.js";
|
|
8
|
+
import J from "./MicroWidgetContainer.es.js";
|
|
9
|
+
import { NoRelevantInsightsCard as K } from "./cards/NoRelevantInsightsCard.es.js";
|
|
10
|
+
import { ZeroStateCard as Q } from "./cards/ZeroStateCard.es.js";
|
|
11
|
+
import y from "./Spinner.es.js";
|
|
12
12
|
import { TRENDS_ANALYTICS_METADATA as D } from "../trends/constants/TrendsWidget.es.js";
|
|
13
13
|
import c, { useState as p } from "react";
|
|
14
|
-
import { observer as
|
|
14
|
+
import { observer as k } from "mobx-react-lite";
|
|
15
15
|
import M from "@mui/material/Stack";
|
|
16
|
-
import { jsx as e, jsxs as
|
|
17
|
-
var t = new
|
|
16
|
+
import { jsx as e, jsxs as O } from "react/jsx-runtime";
|
|
17
|
+
var t = new Y(), ee = ({ allowSingleCardPeeking: P = !0, areBeatsLoading: d = !1, beats: l = [], cardStyle: a = "elevation 1", endpoint: u = "/", headerSx: L, heightOverrides: n, inDescriptionCtaBehavior: _ = "external", logOutUser: g = () => {
|
|
18
18
|
}, onCardClick: f = () => {
|
|
19
|
-
}, onEvent:
|
|
20
|
-
}, onPageview:
|
|
21
|
-
}, posthog: m, showCarouselControls:
|
|
19
|
+
}, onEvent: C = () => {
|
|
20
|
+
}, onPageview: H = () => {
|
|
21
|
+
}, posthog: m, showCarouselControls: N, showHeader: h, showIcon: v, showWithMargin: E = !0, token: A = "", userHasFullInsightFeedBeats: W, visibleCardsCount: w = 1, widthOverrides: i }) => {
|
|
22
22
|
const I = (() => {
|
|
23
23
|
if (a === "border") return "outlined";
|
|
24
24
|
if (a === "elevation 1") return "elevation";
|
|
25
25
|
if (a !== "flat")
|
|
26
26
|
return "elevation";
|
|
27
|
-
})(), R = a === "flat" ? 0 : 1, [S, s] = p("STANDARD"), [r,
|
|
28
|
-
|
|
27
|
+
})(), R = a === "flat" ? 0 : 1, [S, s] = p("STANDARD"), [r, G] = p(!1), [x, z] = p(!1), V = j([C], t), X = $([H], t);
|
|
28
|
+
U({
|
|
29
29
|
widgetName: "InsightsMicroWidget",
|
|
30
30
|
isLoaded: r
|
|
31
31
|
}), c.useEffect(() => {
|
|
32
|
-
!t.isInitialized && !
|
|
32
|
+
!t.isInitialized && !x && (t.initialize(u, A, g).catch(() => z(!1)), z(!0));
|
|
33
33
|
}, [
|
|
34
34
|
u,
|
|
35
35
|
A,
|
|
36
36
|
g,
|
|
37
37
|
t.isInitialized,
|
|
38
|
-
|
|
38
|
+
x
|
|
39
39
|
]), c.useEffect(() => {
|
|
40
40
|
const o = window.innerHeight;
|
|
41
41
|
o < 180 ? s("STANDARD") : o >= 180 && o < 200 ? s("LARGE") : o >= 200 && o < 248 ? s("XLARGE") : o >= 248 && s("XXLARGE");
|
|
42
42
|
}, [window.innerHeight]), c.useEffect(() => {
|
|
43
|
-
|
|
43
|
+
G(!d && t.isInitialized);
|
|
44
44
|
}, [d, t.isInitialized]);
|
|
45
|
-
const
|
|
45
|
+
const b = {
|
|
46
46
|
heightOverrides: n,
|
|
47
|
+
inDescriptionCtaBehavior: _,
|
|
47
48
|
onCardClick: f,
|
|
48
49
|
posthog: m,
|
|
49
50
|
showIcon: v,
|
|
50
51
|
showWithMargin: E,
|
|
51
52
|
widthOverrides: i
|
|
52
|
-
},
|
|
53
|
+
}, T = {
|
|
53
54
|
carouselSize: S,
|
|
54
55
|
elevation: R,
|
|
55
56
|
variant: I,
|
|
@@ -58,31 +59,31 @@ var t = new U(), O = ({ allowSingleCardPeeking: P = !0, areBeatsLoading: d = !1,
|
|
|
58
59
|
posthog: m,
|
|
59
60
|
showIcon: v
|
|
60
61
|
};
|
|
61
|
-
return /* @__PURE__ */ e(
|
|
62
|
-
onEvent:
|
|
63
|
-
onPageview:
|
|
62
|
+
return /* @__PURE__ */ e(Z, {
|
|
63
|
+
onEvent: V,
|
|
64
|
+
onPageview: X,
|
|
64
65
|
store: t,
|
|
65
|
-
children: /* @__PURE__ */
|
|
66
|
+
children: /* @__PURE__ */ O(J, {
|
|
66
67
|
heightOverrides: n,
|
|
67
68
|
widthOverrides: i,
|
|
68
69
|
children: [
|
|
69
|
-
!r && /* @__PURE__ */ e(
|
|
70
|
-
r &&
|
|
70
|
+
!r && /* @__PURE__ */ e(y, {}),
|
|
71
|
+
r && h && /* @__PURE__ */ e(F, {
|
|
71
72
|
analyticsMetadata: D,
|
|
72
73
|
headerSx: L,
|
|
73
74
|
onCardClick: f,
|
|
74
75
|
posthog: m,
|
|
75
76
|
widthOverrides: i
|
|
76
77
|
}),
|
|
77
|
-
r && !!l.length && /* @__PURE__ */ e(
|
|
78
|
+
r && !!l.length && /* @__PURE__ */ e(B, {
|
|
78
79
|
allowSingleCardPeeking: P,
|
|
79
80
|
analyticsMetadata: D,
|
|
80
81
|
beats: l,
|
|
81
82
|
elevation: R,
|
|
82
|
-
showCarouselControls:
|
|
83
|
+
showCarouselControls: N,
|
|
83
84
|
variant: I,
|
|
84
|
-
visibleCardsCount:
|
|
85
|
-
...
|
|
85
|
+
visibleCardsCount: w,
|
|
86
|
+
...b
|
|
86
87
|
}),
|
|
87
88
|
r && !l.length && /* @__PURE__ */ e(M, {
|
|
88
89
|
sx: {
|
|
@@ -92,18 +93,18 @@ var t = new U(), O = ({ allowSingleCardPeeking: P = !0, areBeatsLoading: d = !1,
|
|
|
92
93
|
},
|
|
93
94
|
children: /* @__PURE__ */ e(M, {
|
|
94
95
|
sx: {
|
|
95
|
-
height: `calc(${
|
|
96
|
+
height: `calc(${q[S]}px - 44px)`,
|
|
96
97
|
width: E ? `calc(${i}px - 32px)` : "100%"
|
|
97
98
|
},
|
|
98
|
-
children:
|
|
99
|
+
children: W ? /* @__PURE__ */ e(K, { ...T }) : /* @__PURE__ */ e(Q, { ...T })
|
|
99
100
|
})
|
|
100
101
|
})
|
|
101
102
|
]
|
|
102
103
|
})
|
|
103
104
|
});
|
|
104
|
-
},
|
|
105
|
+
}, Ae = k(ee);
|
|
105
106
|
export {
|
|
106
|
-
|
|
107
|
+
Ae as default
|
|
107
108
|
};
|
|
108
109
|
|
|
109
110
|
//# sourceMappingURL=InsightsMicroWidget.es.js.map
|