@mx-cartographer/experiences 9.7.131 → 9.7.132
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 +5 -0
- package/dist/core/utils/NumberFormatting.d.ts +6 -0
- package/dist/core/utils/NumberFormatting.es.js +20 -16
- package/dist/core/utils/NumberFormatting.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/CreateBudgetDialog.es.js +17 -17
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/CreateBudgetDialog.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetSummary.es.js +38 -38
- package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetSummary.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/CreditUtilizationBlock/CreditUtilizationContent.es.js +14 -14
- package/dist/insights-v2/actionBlocks/CreditUtilizationBlock/CreditUtilizationContent.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/EmergencySavingsBlock.es.js +26 -26
- package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/EmergencySavingsBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/SavingsCalculator.es.js +22 -22
- package/dist/insights-v2/actionBlocks/EmergencySavingsBlock/SavingsCalculator.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/MakeTransferActionBlock.es.js +47 -47
- package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/MakeTransferActionBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/OverdraftBlock/OverdraftBlock.es.js +18 -18
- package/dist/insights-v2/actionBlocks/OverdraftBlock/OverdraftBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/PayoffResults.es.js +28 -28
- package/dist/insights-v2/actionBlocks/PayoffCalculatorBlock/PayoffResults.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/SubscriptionStatusModalBlock.es.js +57 -56
- package/dist/insights-v2/actionBlocks/SubscriptionStatusModalBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js +50 -50
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.d.ts +2 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js +52 -51
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListSummaryCard.es.js +17 -17
- package/dist/insights-v2/actionBlocks/TransactionListBlock/TransactionListSummaryCard.es.js.map +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/BarchartBlock.es.js +20 -20
- package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/BarchartBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/utils.es.js +25 -25
- package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/utils.es.js.map +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/DonutChartBlock.es.js +17 -16
- package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/DonutChartBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/comparisonUtils.es.js +34 -34
- package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/comparisonUtils.es.js.map +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/DoubleProgressBarBlock/ProgressBar.es.js +7 -7
- package/dist/insights-v2/blocks/ChartBlocks/DoubleProgressBarBlock/ProgressBar.es.js.map +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/StepChartBlock/variants/WithText.es.js +13 -13
- package/dist/insights-v2/blocks/ChartBlocks/StepChartBlock/variants/WithText.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/AccountBlock.es.js +39 -39
- package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/AccountBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/BudgetBlock/BudgetBlock.es.js +20 -20
- package/dist/insights-v2/blocks/ComponentBlocks/BudgetBlock/BudgetBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/DebtsBlock/DebtsBlock.es.js +44 -44
- package/dist/insights-v2/blocks/ComponentBlocks/DebtsBlock/DebtsBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/DetailedAccountBlock/DetailedAccountBlock.es.js +14 -14
- package/dist/insights-v2/blocks/ComponentBlocks/DetailedAccountBlock/DetailedAccountBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/GasPurchaseBlock/GasPurchaseBlock.es.js +8 -8
- package/dist/insights-v2/blocks/ComponentBlocks/GasPurchaseBlock/GasPurchaseBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/GoalsBlock/GoalsBlock.es.js +25 -25
- package/dist/insights-v2/blocks/ComponentBlocks/GoalsBlock/GoalsBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/MerchantBlock.es.js +39 -46
- package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/MerchantBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/RepeatingTransactionBlock/RepeatingTransactionBlock.es.js +18 -18
- package/dist/insights-v2/blocks/ComponentBlocks/RepeatingTransactionBlock/RepeatingTransactionBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/SaveExtraBlock/SaveExtraBlock.es.js +19 -19
- package/dist/insights-v2/blocks/ComponentBlocks/SaveExtraBlock/SaveExtraBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/SavingsOpportunityBlock/SavingsOpportunityBlock.es.js +9 -9
- package/dist/insights-v2/blocks/ComponentBlocks/SavingsOpportunityBlock/SavingsOpportunityBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/SavingsSummaryBlock/SavingsSummaryBlock.es.js +12 -12
- package/dist/insights-v2/blocks/ComponentBlocks/SavingsSummaryBlock/SavingsSummaryBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/TransactionBlock.es.js +58 -57
- package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/TransactionBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/UpcomingSubscriptionBlock/UpcomingSubscriptionBlock.es.js +18 -18
- package/dist/insights-v2/blocks/ComponentBlocks/UpcomingSubscriptionBlock/UpcomingSubscriptionBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/WeeklySmallPurchasesBlock/WeeklySmallPurchasesBlock.es.js +10 -10
- package/dist/insights-v2/blocks/ComponentBlocks/WeeklySmallPurchasesBlock/WeeklySmallPurchasesBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ImageBlocks/ImageBlock.es.js +13 -13
- package/dist/insights-v2/blocks/ImageBlocks/ImageBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/slotReaders.d.ts +3 -1
- package/dist/insights-v2/blocks/slotReaders.es.js +17 -6
- package/dist/insights-v2/blocks/slotReaders.es.js.map +1 -1
- package/dist/insights-v2/components/CompactInsightCard.es.js +44 -43
- package/dist/insights-v2/components/CompactInsightCard.es.js.map +1 -1
- package/dist/insights-v2/components/SaveAnExtraCard.es.js +6 -6
- package/dist/insights-v2/components/SaveAnExtraCard.es.js.map +1 -1
- package/dist/insights-v2/components/WithdrawalCard.es.js +20 -20
- package/dist/insights-v2/components/WithdrawalCard.es.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,40 +1,40 @@
|
|
|
1
1
|
import { useGlobalCopyStore as Dt, useGlobalUiStore as St, useInsightsV2Store as vt } from "../../../common/context/hooks.es.js";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { BAR_ARIA_LABEL as
|
|
6
|
-
import { BarChartV2 as
|
|
7
|
-
import { EmptyBarChart as
|
|
2
|
+
import { CURRENCY_FORMAT as Bt, formatCurrency as Lt } from "../../../core/utils/NumberFormatting.es.js";
|
|
3
|
+
import It from "../../../common/components/drawer/Drawer.es.js";
|
|
4
|
+
import Et from "../../../common/components/Loader.es.js";
|
|
5
|
+
import { BAR_ARIA_LABEL as Rt } from "../../blocks/ChartBlocks/BarchartBlock/utils.es.js";
|
|
6
|
+
import { BarChartV2 as xt } from "../../components/chartblocks/BarchartV2.es.js";
|
|
7
|
+
import { EmptyBarChart as Ft } from "../../components/chartblocks/EmptyBarChart.es.js";
|
|
8
8
|
import { ANALYTICS_EVENTS_CONFIG as V } from "../../analytics/analyticsEventsConfig.es.js";
|
|
9
|
-
import { useAnalyticsEvent as
|
|
10
|
-
import { DoubleBarChart as
|
|
11
|
-
import { toLegendItems as
|
|
12
|
-
import { getDefaultSelection as
|
|
13
|
-
import { getDynamicCtaBasedOnTriggers as
|
|
14
|
-
import { TransactionDrillDown as
|
|
15
|
-
import { useTransactionHistory as
|
|
16
|
-
import { TransactionDetailsBlock as
|
|
17
|
-
import { useLayoutEffect as
|
|
9
|
+
import { useAnalyticsEvent as Ot } from "../../analytics/useAnalyticsEvent.es.js";
|
|
10
|
+
import { DoubleBarChart as jt } from "../../components/chartblocks/DoubleBarChart.es.js";
|
|
11
|
+
import { toLegendItems as Gt } from "../../blocks/ChartBlocks/DoubleBarChartBlock/comparisonUtils.es.js";
|
|
12
|
+
import { getDefaultSelection as Ht, getDrillDownConfig as wt, getFlattenedDataSeries as Nt, resolveDrillDownSubHeader as kt, splitProjectedTransaction as Mt, toStoreFilter as Kt } from "./utils.es.js";
|
|
13
|
+
import { getDynamicCtaBasedOnTriggers as Pt } from "../util.es.js";
|
|
14
|
+
import { TransactionDrillDown as Vt } from "./TransactionDrillDown.es.js";
|
|
15
|
+
import { useTransactionHistory as zt } from "./useTransactionHistory.es.js";
|
|
16
|
+
import { TransactionDetailsBlock as Ut } from "../TransactionDetailsBlock/TransactionDetailsBlock.es.js";
|
|
17
|
+
import { useLayoutEffect as Yt, useState as m } from "react";
|
|
18
18
|
import { observer as Wt } from "mobx-react-lite";
|
|
19
|
-
import { Fragment as
|
|
20
|
-
import { useTheme as
|
|
21
|
-
var
|
|
22
|
-
const D =
|
|
19
|
+
import { Fragment as $t, jsx as r, jsxs as qt } from "react/jsx-runtime";
|
|
20
|
+
import { useTheme as Jt } from "@mui/material/styles";
|
|
21
|
+
var _e = Wt(({ beat: s }) => {
|
|
22
|
+
const D = Jt(), { actionDrawer: S, setActionContext: v } = vt(), { insights_payload: c } = s, B = Pt(S, c?.primary_cta, c?.secondary_cta, c?.in_description_cta), z = B?.variant, { top: e, filterMode: u, header: U, colors: Y, filterStrategy: W, tipSection: L, subTabAriaLabels: $, slotData: q, beatTransactions: J, hideListHeader: Q, tipAboveSubTabs: X, averageFormat: Z, subTabs: tt } = wt(z ?? ""), { instanceSlotData: o, beatTransactions: g, spendCategoryGuids: I, allAccountGuids: E, categoryName: et, displayedDateRange: h, transactionStore: ot } = zt(s, {
|
|
23
23
|
slotData: q,
|
|
24
24
|
beatTransactions: J
|
|
25
|
-
}, B?.drilldown_data), { common: at, insights_feed: n } = Dt(), { isCopyLoaded: nt } = St(), [rt,
|
|
25
|
+
}, B?.drilldown_data), { common: at, insights_feed: n } = Dt(), { isCopyLoaded: nt } = St(), [rt, R] = m(!1), [st, it] = m(!1), x = Ot(), { dataSeries: p, chartData: b, comparisonBars: i } = Nt({
|
|
26
26
|
data: o?.data_series,
|
|
27
|
-
ariaLabel: e === "doubleBar" ? n?.general?.in_month_you_had_a_category_of_amount ?? "_1{month}, _2{category}: _3{amount}" :
|
|
27
|
+
ariaLabel: e === "doubleBar" ? n?.general?.in_month_you_had_a_category_of_amount ?? "_1{month}, _2{category}: _3{amount}" : Rt,
|
|
28
28
|
top: e,
|
|
29
29
|
beatTransactions: g
|
|
30
|
-
}), d = e === "doubleBar", lt = e === "tabsOnly", l = d ? i : b, { chartBarIndex: F, subTabIndex: ct } =
|
|
30
|
+
}), d = e === "doubleBar", lt = e === "tabsOnly", l = d ? i : b, { chartBarIndex: F, subTabIndex: ct } = Ht({
|
|
31
31
|
chartTabCount: b.length,
|
|
32
32
|
comparisonTabCount: i.length,
|
|
33
33
|
actionDrawer: S,
|
|
34
34
|
beatGuid: s.guid
|
|
35
35
|
}), [a, T] = m(F), [_, O] = m(ct), [dt, mt] = m(l.length);
|
|
36
36
|
l.length !== dt && (mt(l.length), T(F));
|
|
37
|
-
const C = (t) =>
|
|
37
|
+
const C = (t) => W({
|
|
38
38
|
beat: s,
|
|
39
39
|
beatTransactions: g,
|
|
40
40
|
dataSeries: p,
|
|
@@ -45,18 +45,18 @@ var Te = Wt(({ beat: s }) => {
|
|
|
45
45
|
instanceSlotData: o,
|
|
46
46
|
spendCategoryGuids: I,
|
|
47
47
|
displayedDateRange: h
|
|
48
|
-
}), ut = g.map((t) => t.guid).join(","), gt = I.join(","), pt =
|
|
48
|
+
}), ut = g.map((t) => t.guid).join(","), gt = I.join(","), pt = E.join(","), bt = e === "list" || e === "tabsOnly" || e === "monthTabs" || p.length > 0, j = () => {
|
|
49
49
|
if (u !== "store") return;
|
|
50
50
|
const t = bt ? C(a) : {
|
|
51
51
|
accounts: [],
|
|
52
52
|
custom: () => !1
|
|
53
53
|
};
|
|
54
54
|
ot.setFilter(Kt(t, {
|
|
55
|
-
allAccountGuids:
|
|
55
|
+
allAccountGuids: E,
|
|
56
56
|
displayedDateRange: h
|
|
57
57
|
}));
|
|
58
58
|
};
|
|
59
|
-
|
|
59
|
+
Yt(() => {
|
|
60
60
|
j();
|
|
61
61
|
}, [
|
|
62
62
|
s.guid,
|
|
@@ -76,38 +76,38 @@ var Te = Wt(({ beat: s }) => {
|
|
|
76
76
|
subHeader: G,
|
|
77
77
|
categoryName: et,
|
|
78
78
|
selectedDate: b[a]?.date ?? void 0
|
|
79
|
-
}), H =
|
|
80
|
-
if (!nt) return /* @__PURE__ */ r(
|
|
81
|
-
const [w,
|
|
82
|
-
heading:
|
|
79
|
+
}), H = Y(D, o?.category_guid);
|
|
80
|
+
if (!nt) return /* @__PURE__ */ r(Et, {});
|
|
81
|
+
const [w, N] = o?.legends ?? [], ft = u === "local" ? (t) => C(t).custom ?? (() => !0) : void 0, { transactions: ht, projectedTransaction: A } = Mt(g), Tt = u === "local" ? ht : void 0, k = n.general.projected_amount, _t = A && k && C(a).custom?.(A) ? {
|
|
82
|
+
heading: k,
|
|
83
83
|
transaction: A
|
|
84
|
-
} : void 0,
|
|
85
|
-
|
|
84
|
+
} : void 0, M = (t, f) => {
|
|
85
|
+
x(V.DRAWER_CHART_BAR_CLICKED), T(t), f !== void 0 && O(f);
|
|
86
86
|
}, Ct = (t) => {
|
|
87
|
-
|
|
88
|
-
},
|
|
87
|
+
x(V.TAB_SELECTED), T(t);
|
|
88
|
+
}, K = d ? Gt([{
|
|
89
89
|
...w,
|
|
90
90
|
value: i[a]?.main
|
|
91
91
|
}, {
|
|
92
|
-
...
|
|
92
|
+
...N,
|
|
93
93
|
value: i[a]?.comparison
|
|
94
|
-
}]) : void 0, yt = $?.(n) ?? [], P = d ? (
|
|
94
|
+
}]) : void 0, yt = $?.(n) ?? [], P = d ? (K ?? []).map((t, f) => ({
|
|
95
95
|
label: t.label,
|
|
96
96
|
ariaLabel: yt[f]
|
|
97
97
|
})) : lt ? p.flatMap((t) => t.localized_label ? [{ label: t.localized_label }] : []) : tt?.({
|
|
98
98
|
instanceSlotData: o,
|
|
99
99
|
copy: n
|
|
100
|
-
}).map((t) => ({ label: t })) ?? [], At = d || e === "singleBar" || e === "upcomingBill" ? l.length ? d ? /* @__PURE__ */ r(
|
|
100
|
+
}).map((t) => ({ label: t })) ?? [], At = d || e === "singleBar" || e === "upcomingBill" ? l.length ? d ? /* @__PURE__ */ r(jt, {
|
|
101
101
|
bars: i,
|
|
102
102
|
colors: H,
|
|
103
103
|
legendPosition: "top",
|
|
104
|
-
legends:
|
|
105
|
-
onBarClick:
|
|
104
|
+
legends: K,
|
|
105
|
+
onBarClick: M,
|
|
106
106
|
selectedIndex: a
|
|
107
|
-
}) : /* @__PURE__ */ r(
|
|
107
|
+
}) : /* @__PURE__ */ r(xt, {
|
|
108
108
|
amounts: {
|
|
109
109
|
average: o?.average_amount,
|
|
110
|
-
formattedAverage:
|
|
110
|
+
formattedAverage: Lt(o?.average_amount ?? 0, Z ?? Bt.cents)
|
|
111
111
|
},
|
|
112
112
|
color: H[0] ?? D.palette.primary.main,
|
|
113
113
|
data: b,
|
|
@@ -120,11 +120,11 @@ var Te = Wt(({ beat: s }) => {
|
|
|
120
120
|
right: 24
|
|
121
121
|
},
|
|
122
122
|
monthlyAmountLabel: w?.label ?? n.general.monthly_amount,
|
|
123
|
-
onBarClick:
|
|
123
|
+
onBarClick: M,
|
|
124
124
|
selectedTabIndex: a,
|
|
125
|
-
trendAmountLabel:
|
|
126
|
-
}) : /* @__PURE__ */ r(
|
|
127
|
-
return /* @__PURE__ */ $t
|
|
125
|
+
trendAmountLabel: N?.label ?? n.general.trend
|
|
126
|
+
}) : /* @__PURE__ */ r(Ft, {}) : null;
|
|
127
|
+
return /* @__PURE__ */ qt($t, { children: [/* @__PURE__ */ r(Vt, {
|
|
128
128
|
baseTransactions: Tt,
|
|
129
129
|
hideListHeader: Q,
|
|
130
130
|
tipAboveSubTabs: X,
|
|
@@ -144,20 +144,20 @@ var Te = Wt(({ beat: s }) => {
|
|
|
144
144
|
...L && { tipSection: !st && (L(it, n, G?.text, o) ?? !1) },
|
|
145
145
|
transactionFilter: ft,
|
|
146
146
|
onEachRowClick: (t) => {
|
|
147
|
-
v({ transaction_guid: t }),
|
|
147
|
+
v({ transaction_guid: t }), R(!0);
|
|
148
148
|
}
|
|
149
|
-
}), /* @__PURE__ */ r(
|
|
149
|
+
}), /* @__PURE__ */ r(It, {
|
|
150
150
|
ariaLabelClose: at.close_aria,
|
|
151
151
|
isOpen: rt,
|
|
152
152
|
onClose: () => {
|
|
153
|
-
|
|
153
|
+
R(!1), v({ transaction_guid: void 0 }), j();
|
|
154
154
|
},
|
|
155
155
|
title: n.general.transaction_details_title,
|
|
156
|
-
children: /* @__PURE__ */ r(
|
|
156
|
+
children: /* @__PURE__ */ r(Ut, { beat: s })
|
|
157
157
|
})] });
|
|
158
158
|
});
|
|
159
159
|
export {
|
|
160
|
-
|
|
160
|
+
_e as TransactionHistoryBlock
|
|
161
161
|
};
|
|
162
162
|
|
|
163
163
|
//# sourceMappingURL=TransactionHistoryBlock.es.js.map
|
package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionHistoryBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.tsx"],"sourcesContent":["import { useLayoutEffect, useState } from 'react'\n\nimport { useTheme } from '@mui/material/styles'\nimport { observer } from 'mobx-react-lite'\n\nimport type { Beat, DataSeries, Transaction } from '../../../core'\nimport { formatCurrency } from '../../../core/utils/NumberFormatting'\nimport { ANALYTICS_EVENTS_CONFIG, useAnalyticsEvent } from '../../analytics'\nimport { BarChartV2 } from '../../components/chartblocks/BarchartV2'\nimport { DoubleBarChart } from '../../components/chartblocks/DoubleBarChart'\nimport { EmptyBarChart } from '../../components/chartblocks/EmptyBarChart'\nimport { BAR_ARIA_LABEL } from '../../blocks/ChartBlocks/BarchartBlock/utils'\nimport {\n COMPARISON_BAR_ARIA_LABEL,\n toLegendItems,\n} from '../../blocks/ChartBlocks/DoubleBarChartBlock/comparisonUtils'\n\nimport { TransactionDrillDown } from './TransactionDrillDown'\nimport { useTransactionHistory } from './useTransactionHistory'\nimport {\n getDefaultSelection,\n getDrillDownConfig,\n getFlattenedDataSeries,\n resolveDrillDownSubHeader,\n splitProjectedTransaction,\n toStoreFilter,\n} from './utils'\nimport {\n Drawer,\n useInsightsV2Store,\n useGlobalCopyStore,\n useGlobalUiStore,\n Loader,\n} from '../../../common'\nimport { TransactionDetailsBlock } from '../TransactionDetailsBlock'\nimport { getDynamicCtaBasedOnTriggers } from '../util'\n\ninterface TransactionHistoryProp {\n beat: Beat\n}\n\nexport const TransactionHistoryBlock = observer(({ beat }: TransactionHistoryProp) => {\n const theme = useTheme()\n\n const { actionDrawer, setActionContext } = useInsightsV2Store()\n\n const { insights_payload } = beat\n\n // The CTA that opened the drawer: its variant picks the view, and its drilldown_data feeds a\n // variant that reads its facts from the opener (Monthly Debt to Income). Only drilldown_data is passed\n // on: it is the payload's own object, stable across renders, while the opener may be rebuilt per call.\n const openedCta = getDynamicCtaBasedOnTriggers(\n actionDrawer,\n insights_payload?.primary_cta,\n insights_payload?.secondary_cta,\n insights_payload?.in_description_cta,\n )\n const dynamicCtaVariant = openedCta?.variant\n\n const {\n top,\n filterMode,\n header,\n colors,\n filterStrategy,\n tipSection,\n subTabAriaLabels,\n slotData,\n beatTransactions: resolveBeatTransactions,\n hideListHeader,\n tipAboveSubTabs,\n averageFormat,\n subTabs,\n } = getDrillDownConfig(dynamicCtaVariant ?? '')\n\n const {\n instanceSlotData,\n beatTransactions,\n spendCategoryGuids,\n allAccountGuids,\n categoryName,\n displayedDateRange,\n transactionStore,\n } = useTransactionHistory(\n beat,\n { slotData, beatTransactions: resolveBeatTransactions },\n openedCta?.drilldown_data,\n )\n\n const { common: commonCopy, insights_feed: insightsCopy } = useGlobalCopyStore()\n\n const { isCopyLoaded } = useGlobalUiStore()\n\n const [isTransactionDetailsOpen, setIsTransactionDetailsOpen] = useState(false)\n\n const [closeTipSection, setCloseTipSection] = useState(false)\n\n const fireAnalyticsEvent = useAnalyticsEvent()\n\n // `getFlattenedDataSeries` runs ahead of the copy-loaded guard below, hence the literal fallback.\n const { dataSeries, chartData, comparisonBars } = getFlattenedDataSeries({\n data: instanceSlotData?.data_series as DataSeries,\n ariaLabel:\n top === 'doubleBar'\n ? (insightsCopy?.general?.in_month_you_had_a_category_of_amount ??\n COMPARISON_BAR_ARIA_LABEL)\n : BAR_ARIA_LABEL,\n top,\n beatTransactions,\n })\n\n const isDoubleBar = top === 'doubleBar'\n const isTabsOnly = top === 'tabsOnly'\n // The drawer's columns (and tabs): the double bar's month pairs, or the single bar's bars.\n const bars = isDoubleBar ? comparisonBars : chartData\n\n const { chartBarIndex, subTabIndex } = getDefaultSelection({\n chartTabCount: chartData.length,\n comparisonTabCount: comparisonBars.length,\n actionDrawer,\n beatGuid: beat.guid,\n })\n\n const [selectedIndex, setSelectedIndex] = useState(chartBarIndex)\n // The double-bar drawer's series tab (0 = main, e.g. Spend; 1 = comparison, e.g. Income).\n const [subIndex, setSubIndex] = useState(subTabIndex)\n\n // Bars built from the transaction store (Upcoming Bill's paid bills) can arrive after the drawer\n // opens: re-select the default when the bar count changes. Payload-built bars never change count.\n const [defaultedTabCount, setDefaultedTabCount] = useState(bars.length)\n if (bars.length !== defaultedTabCount) {\n setDefaultedTabCount(bars.length)\n setSelectedIndex(chartBarIndex)\n }\n\n const resolveFilter = (index: number) =>\n filterStrategy({\n beat,\n beatTransactions,\n dataSeries,\n comparisonBars,\n selectedIndex: index,\n subIndex,\n isLastTab: index === bars.length - 1,\n instanceSlotData,\n spendCategoryGuids,\n displayedDateRange,\n })\n\n // Content keys for the effect deps: these arrays get a new identity every render (MEW-3732).\n const beatTransactionGuidsKey = beatTransactions.map((transaction) => transaction.guid).join(',')\n const spendCategoryGuidsKey = spendCategoryGuids.join(',')\n const allAccountGuidsKey = allAccountGuids.join(',')\n\n // Re-applied on selection change and when the nested details drawer closes: AddMerchantBudgetAction\n // overwrites transactionStore.filter and never restores it. Chartless tops filter with no bars.\n const canApplyFilter =\n top === 'list' || top === 'tabsOnly' || top === 'monthTabs' || dataSeries.length > 0\n const applyCurrentSelectionFilter = () => {\n if (filterMode !== 'store') return\n // A chart drawer with no bars can name no rows: fail closed rather than keep the store's default\n // (every account) or a previous drawer's filter.\n const filter = canApplyFilter\n ? resolveFilter(selectedIndex)\n : { accounts: [], custom: () => false }\n transactionStore.setFilter(toStoreFilter(filter, { allAccountGuids, displayedDateRange }))\n }\n\n // store variants route the selection through the shared store filter; local (upcomingBill) variants\n // filter beatTransactions directly, so there's nothing to push to the store for them.\n useLayoutEffect(() => {\n applyCurrentSelectionFilter()\n }, [\n beat.guid,\n selectedIndex,\n subIndex,\n filterMode,\n dataSeries.length,\n instanceSlotData,\n displayedDateRange,\n spendCategoryGuidsKey,\n allAccountGuidsKey,\n beatTransactionGuidsKey,\n top,\n ])\n\n const subHeader = resolveDrillDownSubHeader(insights_payload)\n\n const headerContent = header?.({\n title: insights_payload?.title,\n subHeader,\n categoryName,\n selectedDate: chartData[selectedIndex]?.date ?? undefined,\n })\n\n const barColors = colors(theme, instanceSlotData?.category_guid)\n\n if (!isCopyLoaded) return <Loader />\n\n // `legends` is the block's additional_data ([0] main, [1] second series), as BarchartBlock reads it.\n const [mainLegend, comparisonLegend] = instanceSlotData?.legends ?? []\n\n const transactionFilter =\n filterMode === 'local'\n ? (index: number) => resolveFilter(index).custom ?? (() => true)\n : undefined\n\n // Upcoming Bill appends a synthesized projected bill: it draws the last bar and its own labelled\n // row, but is never a plain list row or a CSV line.\n const { transactions: listTransactions, projectedTransaction } =\n splitProjectedTransaction(beatTransactions)\n\n const baseTransactions: Transaction[] | undefined =\n filterMode === 'local' ? listTransactions : undefined\n\n const projectedHeading = insightsCopy.general.projected_amount\n const projectedRow =\n projectedTransaction &&\n projectedHeading &&\n resolveFilter(selectedIndex).custom?.(projectedTransaction)\n ? { heading: projectedHeading, transaction: projectedTransaction }\n : undefined\n\n // A chart bar click selects its column (and, on the double bar, its series); a month tab change\n // selects the month. MUI Tabs only fires onChange on real user selection, not on mount. The\n // series (Spend / Income) tab fires its own analytics via the shared SubTabs component.\n const selectBar = (index: number, seriesIndex?: number) => {\n fireAnalyticsEvent(ANALYTICS_EVENTS_CONFIG.DRAWER_CHART_BAR_CLICKED)\n setSelectedIndex(index)\n if (seriesIndex !== undefined) setSubIndex(seriesIndex)\n }\n const selectMonth = (index: number) => {\n fireAnalyticsEvent(ANALYTICS_EVENTS_CONFIG.TAB_SELECTED)\n setSelectedIndex(index)\n }\n\n // Double bar: the Spend / Income labels come from copy (additional_data); the legend carries the\n // selected month's two totals, and its labels name the series tabs.\n const doubleBarLegends = isDoubleBar\n ? toLegendItems([\n { ...mainLegend, value: comparisonBars[selectedIndex]?.main },\n { ...comparisonLegend, value: comparisonBars[selectedIndex]?.comparison },\n ])\n : undefined\n\n // Legacy pulse named these tabs \"Spend transactions\" / \"Income transactions\" for screen readers.\n const seriesAriaLabels = subTabAriaLabels?.(insightsCopy) ?? []\n\n // The second tab row: the double bar's series, a tabs-only drawer's sides, or the variant's `subTabs`.\n const sideTabs = isDoubleBar\n ? (doubleBarLegends ?? []).map((legend, index) => ({\n label: legend.label,\n ariaLabel: seriesAriaLabels[index],\n }))\n : isTabsOnly\n ? dataSeries.flatMap((row) => (row.localized_label ? [{ label: row.localized_label }] : []))\n : (subTabs?.({ instanceSlotData, copy: insightsCopy }).map((label) => ({ label })) ?? [])\n\n const renderChart = () => {\n if (!bars.length) return <EmptyBarChart />\n\n return isDoubleBar ? (\n <DoubleBarChart\n bars={comparisonBars}\n colors={barColors}\n legendPosition=\"top\"\n legends={doubleBarLegends}\n onBarClick={selectBar}\n selectedIndex={selectedIndex}\n />\n ) : (\n <BarChartV2\n amounts={{\n average: instanceSlotData?.average_amount,\n formattedAverage: formatCurrency(\n instanceSlotData?.average_amount ?? 0,\n averageFormat ?? '0,0.00',\n ),\n }}\n color={barColors[0] ?? theme.palette.primary.main}\n data={chartData}\n legendPosition=\"top\"\n // Figma's chart drawer: 172px of bars under the 24px legend, 200px in all.\n heightOverride={172}\n margin={{\n bottom: 8,\n top: 24,\n left: 24,\n right: 24,\n }}\n // TODO: Temporary fallback while the backend doesn't always send `legends` on every\n // beat/variant. Remove this once the backend guarantees `legends` on the payload.\n monthlyAmountLabel={mainLegend?.label ?? insightsCopy.general.monthly_amount}\n onBarClick={selectBar}\n selectedTabIndex={selectedIndex}\n trendAmountLabel={comparisonLegend?.label ?? insightsCopy.general.trend}\n />\n )\n }\n\n // `list` (Low Account Balance), `tabsOnly` (Non-Essential Category Summary) and `monthTabs`\n // (Monthly Subscription Aggregate) drawers have no chart above their transaction list.\n const chartTop =\n isDoubleBar || top === 'singleBar' || top === 'upcomingBill' ? renderChart() : null\n\n return (\n <>\n <TransactionDrillDown\n baseTransactions={baseTransactions}\n hideListHeader={hideListHeader}\n tipAboveSubTabs={tipAboveSubTabs}\n projectedRow={projectedRow}\n heading={headerContent?.heading}\n icon={headerContent?.icon}\n onSelectionChange={selectMonth}\n selectedIndex={selectedIndex}\n subHeadingText={headerContent?.subHeadingText}\n tabs={bars}\n top={chartTop}\n {...(sideTabs.length > 0 && {\n subTabs: { tabs: sideTabs, selectedIndex: subIndex, onChange: setSubIndex },\n })}\n {...(tipSection && {\n tipSection:\n !closeTipSection &&\n (tipSection(setCloseTipSection, insightsCopy, subHeader?.text, instanceSlotData) ??\n false),\n })}\n transactionFilter={transactionFilter}\n onEachRowClick={(guid) => {\n setActionContext({ transaction_guid: guid })\n setIsTransactionDetailsOpen(true)\n }}\n />\n <Drawer\n ariaLabelClose={commonCopy.close_aria}\n isOpen={isTransactionDetailsOpen}\n onClose={() => {\n setIsTransactionDetailsOpen(false)\n // Clear only the key this nested drawer owns — setActionContext merges, so an\n // explicit `{}` would be a no-op and leave transaction_guid stuck in the shared\n // context, and the outer drawer's own context (e.g. chartBarIndex) must survive.\n setActionContext({ transaction_guid: undefined })\n // Re-apply this block's own filter: a further-nested AddMerchantBudgetAction drawer may\n // have overwritten transactionStore.filter (merchant_guid-only) without restoring it.\n applyCurrentSelectionFilter()\n }}\n title={insightsCopy.general.transaction_details_title}\n >\n <TransactionDetailsBlock beat={beat} />\n </Drawer>\n </>\n )\n})\n"],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K,EAAS,SAAS,KAAK,EAC1B,SAAS;AAAA,MAAE,MAAM;AAAA,MAAU,eAAe;AAAA,MAAU,UAAU;AAAA,IAAY,EAC5E;AAAA,IACA,GAAK,KAAc,EACjB,YACE,CAAC,OACA,EAAW,IAAoB,GAAc,GAAW,MAAM,CAAgB,KAC7E,IACN;AAAA,IACmB,mBAAA;AAAA,IACnB,gBAAA,CAAiB,MAAS;AACxB,MAAA,EAAiB,EAAE,kBAAkB,EAAK,CAAC,GAC3C,EAA4B,EAAI;AAAA,IAClC;AAAA,EACD,CAAA,GACD,gBAAA,EAAC,IAAD;AAAA,IACE,gBAAgB,GAAW;AAAA,IAC3B,QAAQ;AAAA,IACR,SAAA,MAAe;AACb,MAAA,EAA4B,EAAK,GAIjC,EAAiB,EAAE,kBAAkB,OAAU,CAAC,GAGhD,EAA4B;AAAA,IAC9B;AAAA,IACA,OAAO,EAAa,QAAQ;AAAA,IAE5B,UAAA,gBAAA,EAAC,IAAD,EAA+B,MAAA,EAAO,CAAA;AAAA,EAChC,CAAA,CACR,EAAA,CAAA;AAEN,CAAC"}
|
|
1
|
+
{"version":3,"file":"TransactionHistoryBlock.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.tsx"],"sourcesContent":["import { useLayoutEffect, useState } from 'react'\n\nimport { useTheme } from '@mui/material/styles'\nimport { observer } from 'mobx-react-lite'\n\nimport type { Beat, DataSeries, Transaction } from '../../../core'\nimport { CURRENCY_FORMAT, formatCurrency } from '../../../core/utils/NumberFormatting'\nimport { ANALYTICS_EVENTS_CONFIG, useAnalyticsEvent } from '../../analytics'\nimport { BarChartV2 } from '../../components/chartblocks/BarchartV2'\nimport { DoubleBarChart } from '../../components/chartblocks/DoubleBarChart'\nimport { EmptyBarChart } from '../../components/chartblocks/EmptyBarChart'\nimport { BAR_ARIA_LABEL } from '../../blocks/ChartBlocks/BarchartBlock/utils'\nimport {\n COMPARISON_BAR_ARIA_LABEL,\n toLegendItems,\n} from '../../blocks/ChartBlocks/DoubleBarChartBlock/comparisonUtils'\n\nimport { TransactionDrillDown } from './TransactionDrillDown'\nimport { useTransactionHistory } from './useTransactionHistory'\nimport {\n getDefaultSelection,\n getDrillDownConfig,\n getFlattenedDataSeries,\n resolveDrillDownSubHeader,\n splitProjectedTransaction,\n toStoreFilter,\n} from './utils'\nimport {\n Drawer,\n useInsightsV2Store,\n useGlobalCopyStore,\n useGlobalUiStore,\n Loader,\n} from '../../../common'\nimport { TransactionDetailsBlock } from '../TransactionDetailsBlock'\nimport { getDynamicCtaBasedOnTriggers } from '../util'\n\ninterface TransactionHistoryProp {\n beat: Beat\n}\n\nexport const TransactionHistoryBlock = observer(({ beat }: TransactionHistoryProp) => {\n const theme = useTheme()\n\n const { actionDrawer, setActionContext } = useInsightsV2Store()\n\n const { insights_payload } = beat\n\n // The CTA that opened the drawer: its variant picks the view, and its drilldown_data feeds a\n // variant that reads its facts from the opener (Monthly Debt to Income). Only drilldown_data is passed\n // on: it is the payload's own object, stable across renders, while the opener may be rebuilt per call.\n const openedCta = getDynamicCtaBasedOnTriggers(\n actionDrawer,\n insights_payload?.primary_cta,\n insights_payload?.secondary_cta,\n insights_payload?.in_description_cta,\n )\n const dynamicCtaVariant = openedCta?.variant\n\n const {\n top,\n filterMode,\n header,\n colors,\n filterStrategy,\n tipSection,\n subTabAriaLabels,\n slotData,\n beatTransactions: resolveBeatTransactions,\n hideListHeader,\n tipAboveSubTabs,\n averageFormat,\n subTabs,\n } = getDrillDownConfig(dynamicCtaVariant ?? '')\n\n const {\n instanceSlotData,\n beatTransactions,\n spendCategoryGuids,\n allAccountGuids,\n categoryName,\n displayedDateRange,\n transactionStore,\n } = useTransactionHistory(\n beat,\n { slotData, beatTransactions: resolveBeatTransactions },\n openedCta?.drilldown_data,\n )\n\n const { common: commonCopy, insights_feed: insightsCopy } = useGlobalCopyStore()\n\n const { isCopyLoaded } = useGlobalUiStore()\n\n const [isTransactionDetailsOpen, setIsTransactionDetailsOpen] = useState(false)\n\n const [closeTipSection, setCloseTipSection] = useState(false)\n\n const fireAnalyticsEvent = useAnalyticsEvent()\n\n // `getFlattenedDataSeries` runs ahead of the copy-loaded guard below, hence the literal fallback.\n const { dataSeries, chartData, comparisonBars } = getFlattenedDataSeries({\n data: instanceSlotData?.data_series as DataSeries,\n ariaLabel:\n top === 'doubleBar'\n ? (insightsCopy?.general?.in_month_you_had_a_category_of_amount ??\n COMPARISON_BAR_ARIA_LABEL)\n : BAR_ARIA_LABEL,\n top,\n beatTransactions,\n })\n\n const isDoubleBar = top === 'doubleBar'\n const isTabsOnly = top === 'tabsOnly'\n // The drawer's columns (and tabs): the double bar's month pairs, or the single bar's bars.\n const bars = isDoubleBar ? comparisonBars : chartData\n\n const { chartBarIndex, subTabIndex } = getDefaultSelection({\n chartTabCount: chartData.length,\n comparisonTabCount: comparisonBars.length,\n actionDrawer,\n beatGuid: beat.guid,\n })\n\n const [selectedIndex, setSelectedIndex] = useState(chartBarIndex)\n // The double-bar drawer's series tab (0 = main, e.g. Spend; 1 = comparison, e.g. Income).\n const [subIndex, setSubIndex] = useState(subTabIndex)\n\n // Bars built from the transaction store (Upcoming Bill's paid bills) can arrive after the drawer\n // opens: re-select the default when the bar count changes. Payload-built bars never change count.\n const [defaultedTabCount, setDefaultedTabCount] = useState(bars.length)\n if (bars.length !== defaultedTabCount) {\n setDefaultedTabCount(bars.length)\n setSelectedIndex(chartBarIndex)\n }\n\n const resolveFilter = (index: number) =>\n filterStrategy({\n beat,\n beatTransactions,\n dataSeries,\n comparisonBars,\n selectedIndex: index,\n subIndex,\n isLastTab: index === bars.length - 1,\n instanceSlotData,\n spendCategoryGuids,\n displayedDateRange,\n })\n\n // Content keys for the effect deps: these arrays get a new identity every render (MEW-3732).\n const beatTransactionGuidsKey = beatTransactions.map((transaction) => transaction.guid).join(',')\n const spendCategoryGuidsKey = spendCategoryGuids.join(',')\n const allAccountGuidsKey = allAccountGuids.join(',')\n\n // Re-applied on selection change and when the nested details drawer closes: AddMerchantBudgetAction\n // overwrites transactionStore.filter and never restores it. Chartless tops filter with no bars.\n const canApplyFilter =\n top === 'list' || top === 'tabsOnly' || top === 'monthTabs' || dataSeries.length > 0\n const applyCurrentSelectionFilter = () => {\n if (filterMode !== 'store') return\n // A chart drawer with no bars can name no rows: fail closed rather than keep the store's default\n // (every account) or a previous drawer's filter.\n const filter = canApplyFilter\n ? resolveFilter(selectedIndex)\n : { accounts: [], custom: () => false }\n transactionStore.setFilter(toStoreFilter(filter, { allAccountGuids, displayedDateRange }))\n }\n\n // store variants route the selection through the shared store filter; local (upcomingBill) variants\n // filter beatTransactions directly, so there's nothing to push to the store for them.\n useLayoutEffect(() => {\n applyCurrentSelectionFilter()\n }, [\n beat.guid,\n selectedIndex,\n subIndex,\n filterMode,\n dataSeries.length,\n instanceSlotData,\n displayedDateRange,\n spendCategoryGuidsKey,\n allAccountGuidsKey,\n beatTransactionGuidsKey,\n top,\n ])\n\n const subHeader = resolveDrillDownSubHeader(insights_payload)\n\n const headerContent = header?.({\n title: insights_payload?.title,\n subHeader,\n categoryName,\n selectedDate: chartData[selectedIndex]?.date ?? undefined,\n })\n\n const barColors = colors(theme, instanceSlotData?.category_guid)\n\n if (!isCopyLoaded) return <Loader />\n\n // `legends` is the block's additional_data ([0] main, [1] second series), as BarchartBlock reads it.\n const [mainLegend, comparisonLegend] = instanceSlotData?.legends ?? []\n\n const transactionFilter =\n filterMode === 'local'\n ? (index: number) => resolveFilter(index).custom ?? (() => true)\n : undefined\n\n // Upcoming Bill appends a synthesized projected bill: it draws the last bar and its own labelled\n // row, but is never a plain list row or a CSV line.\n const { transactions: listTransactions, projectedTransaction } =\n splitProjectedTransaction(beatTransactions)\n\n const baseTransactions: Transaction[] | undefined =\n filterMode === 'local' ? listTransactions : undefined\n\n const projectedHeading = insightsCopy.general.projected_amount\n const projectedRow =\n projectedTransaction &&\n projectedHeading &&\n resolveFilter(selectedIndex).custom?.(projectedTransaction)\n ? { heading: projectedHeading, transaction: projectedTransaction }\n : undefined\n\n // A chart bar click selects its column (and, on the double bar, its series); a month tab change\n // selects the month. MUI Tabs only fires onChange on real user selection, not on mount. The\n // series (Spend / Income) tab fires its own analytics via the shared SubTabs component.\n const selectBar = (index: number, seriesIndex?: number) => {\n fireAnalyticsEvent(ANALYTICS_EVENTS_CONFIG.DRAWER_CHART_BAR_CLICKED)\n setSelectedIndex(index)\n if (seriesIndex !== undefined) setSubIndex(seriesIndex)\n }\n const selectMonth = (index: number) => {\n fireAnalyticsEvent(ANALYTICS_EVENTS_CONFIG.TAB_SELECTED)\n setSelectedIndex(index)\n }\n\n // Double bar: the Spend / Income labels come from copy (additional_data); the legend carries the\n // selected month's two totals, and its labels name the series tabs.\n const doubleBarLegends = isDoubleBar\n ? toLegendItems([\n { ...mainLegend, value: comparisonBars[selectedIndex]?.main },\n { ...comparisonLegend, value: comparisonBars[selectedIndex]?.comparison },\n ])\n : undefined\n\n // Legacy pulse named these tabs \"Spend transactions\" / \"Income transactions\" for screen readers.\n const seriesAriaLabels = subTabAriaLabels?.(insightsCopy) ?? []\n\n // The second tab row: the double bar's series, a tabs-only drawer's sides, or the variant's `subTabs`.\n const sideTabs = isDoubleBar\n ? (doubleBarLegends ?? []).map((legend, index) => ({\n label: legend.label,\n ariaLabel: seriesAriaLabels[index],\n }))\n : isTabsOnly\n ? dataSeries.flatMap((row) => (row.localized_label ? [{ label: row.localized_label }] : []))\n : (subTabs?.({ instanceSlotData, copy: insightsCopy }).map((label) => ({ label })) ?? [])\n\n const renderChart = () => {\n if (!bars.length) return <EmptyBarChart />\n\n return isDoubleBar ? (\n <DoubleBarChart\n bars={comparisonBars}\n colors={barColors}\n legendPosition=\"top\"\n legends={doubleBarLegends}\n onBarClick={selectBar}\n selectedIndex={selectedIndex}\n />\n ) : (\n <BarChartV2\n amounts={{\n average: instanceSlotData?.average_amount,\n formattedAverage: formatCurrency(\n instanceSlotData?.average_amount ?? 0,\n averageFormat ?? CURRENCY_FORMAT.cents,\n ),\n }}\n color={barColors[0] ?? theme.palette.primary.main}\n data={chartData}\n legendPosition=\"top\"\n // Figma's chart drawer: 172px of bars under the 24px legend, 200px in all.\n heightOverride={172}\n margin={{\n bottom: 8,\n top: 24,\n left: 24,\n right: 24,\n }}\n // TODO: Temporary fallback while the backend doesn't always send `legends` on every\n // beat/variant. Remove this once the backend guarantees `legends` on the payload.\n monthlyAmountLabel={mainLegend?.label ?? insightsCopy.general.monthly_amount}\n onBarClick={selectBar}\n selectedTabIndex={selectedIndex}\n trendAmountLabel={comparisonLegend?.label ?? insightsCopy.general.trend}\n />\n )\n }\n\n // `list` (Low Account Balance), `tabsOnly` (Non-Essential Category Summary) and `monthTabs`\n // (Monthly Subscription Aggregate) drawers have no chart above their transaction list.\n const chartTop =\n isDoubleBar || top === 'singleBar' || top === 'upcomingBill' ? renderChart() : null\n\n return (\n <>\n <TransactionDrillDown\n baseTransactions={baseTransactions}\n hideListHeader={hideListHeader}\n tipAboveSubTabs={tipAboveSubTabs}\n projectedRow={projectedRow}\n heading={headerContent?.heading}\n icon={headerContent?.icon}\n onSelectionChange={selectMonth}\n selectedIndex={selectedIndex}\n subHeadingText={headerContent?.subHeadingText}\n tabs={bars}\n top={chartTop}\n {...(sideTabs.length > 0 && {\n subTabs: { tabs: sideTabs, selectedIndex: subIndex, onChange: setSubIndex },\n })}\n {...(tipSection && {\n tipSection:\n !closeTipSection &&\n (tipSection(setCloseTipSection, insightsCopy, subHeader?.text, instanceSlotData) ??\n false),\n })}\n transactionFilter={transactionFilter}\n onEachRowClick={(guid) => {\n setActionContext({ transaction_guid: guid })\n setIsTransactionDetailsOpen(true)\n }}\n />\n <Drawer\n ariaLabelClose={commonCopy.close_aria}\n isOpen={isTransactionDetailsOpen}\n onClose={() => {\n setIsTransactionDetailsOpen(false)\n // Clear only the key this nested drawer owns — setActionContext merges, so an\n // explicit `{}` would be a no-op and leave transaction_guid stuck in the shared\n // context, and the outer drawer's own context (e.g. chartBarIndex) must survive.\n setActionContext({ transaction_guid: undefined })\n // Re-apply this block's own filter: a further-nested AddMerchantBudgetAction drawer may\n // have overwritten transactionStore.filter (merchant_guid-only) without restoring it.\n applyCurrentSelectionFilter()\n }}\n title={insightsCopy.general.transaction_details_title}\n >\n <TransactionDetailsBlock beat={beat} />\n </Drawer>\n </>\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAyCA,IAAa,KAA0B,GAAA,CAAU,EAAE,MAAA,EAAA,MAAmC;AACpF,QAAM,IAAQ,GAAS,GAEjB,EAAE,cAAA,GAAc,kBAAA,EAAA,IAAqB,GAAmB,GAExD,EAAE,kBAAA,EAAA,IAAqB,GAKvB,IAAY,GAChB,GACA,GAAkB,aAClB,GAAkB,eAClB,GAAkB,kBACpB,GACM,IAAoB,GAAW,SAE/B,EACJ,KAAA,GACA,YAAA,GACA,QAAA,GACA,QAAA,GACA,gBAAA,GACA,YAAA,GACA,kBAAA,GACA,UAAA,GACA,kBAAkB,GAClB,gBAAA,GACA,iBAAA,GACA,eAAA,GACA,SAAA,GAAA,IACE,GAAmB,KAAqB,EAAE,GAExC,EACJ,kBAAA,GACA,kBAAA,GACA,oBAAA,GACA,iBAAA,GACA,cAAA,IACA,oBAAA,GACA,kBAAA,GAAA,IACE,GACF,GACA;AAAA,IAAE,UAAA;AAAA,IAAU,kBAAkB;AAAA,EAAwB,GACtD,GAAW,cACb,GAEM,EAAE,QAAQ,IAAY,eAAe,EAAA,IAAiB,GAAmB,GAEzE,EAAE,cAAA,GAAA,IAAiB,GAAiB,GAEpC,CAAC,IAA0B,CAAA,IAA+B,EAAS,EAAK,GAExE,CAAC,IAAiB,EAAA,IAAsB,EAAS,EAAK,GAEtD,IAAqB,GAAkB,GAGvC,EAAE,YAAA,GAAY,WAAA,GAAW,gBAAA,EAAA,IAAmB,GAAuB;AAAA,IACvE,MAAM,GAAkB;AAAA,IACxB,WACE,MAAQ,cACH,GAAc,SAAS,yCAAA,wCAExB;AAAA,IACN,KAAA;AAAA,IACA,kB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A,IACF,gBAAA;AAAA,IACC,iBAAA;AAAA,IACH,cAAA;AAAA,IACd,SAAS,GAAe;AAAA,IACxB,MAAM,GAAe;AAAA,IACrB,mBAAmB;AAAA,IACJ,eAAA;AAAA,IACf,gBAAgB,GAAe;AAAA,IAC/B,MAAM;AAAA,IACN,KAAK;AAAA,IACL,GAAK,EAAS,SAAS,KAAK,EAC1B,SAAS;AAAA,MAAE,MAAM;AAAA,MAAU,eAAe;AAAA,MAAU,UAAU;AAAA,IAAY,EAC5E;AAAA,IACA,GAAK,KAAc,EACjB,YACE,CAAC,OACA,EAAW,IAAoB,GAAc,GAAW,MAAM,CAAgB,KAC7E,IACN;AAAA,IACmB,mBAAA;AAAA,IACnB,gBAAA,CAAiB,MAAS;AACxB,MAAA,EAAiB,EAAE,kBAAkB,EAAK,CAAC,GAC3C,EAA4B,EAAI;AAAA,IAClC;AAAA,EACD,CAAA,GACD,gBAAA,EAAC,IAAD;AAAA,IACE,gBAAgB,GAAW;AAAA,IAC3B,QAAQ;AAAA,IACR,SAAA,MAAe;AACb,MAAA,EAA4B,EAAK,GAIjC,EAAiB,EAAE,kBAAkB,OAAU,CAAC,GAGhD,EAA4B;AAAA,IAC9B;AAAA,IACA,OAAO,EAAa,QAAQ;AAAA,IAE5B,UAAA,gBAAA,EAAC,IAAD,EAA+B,MAAA,EAAO,CAAA;AAAA,EAChC,CAAA,CACR,EAAA,CAAA;AAEN,CAAC"}
|
|
@@ -3,6 +3,7 @@ import { Theme } from '@mui/material/styles';
|
|
|
3
3
|
import { Beat, DrilldownData, InsightsFeedCopy, Subtitle, Transaction } from '../../../core';
|
|
4
4
|
import { TransactionFilter } from '../../../core/stores/TransactionStore';
|
|
5
5
|
import { DataSet } from '../../../core/types/InsightsInstanceSlotData';
|
|
6
|
+
import { CurrencyFormat } from '../../../core/utils/NumberFormatting';
|
|
6
7
|
import { ChartDataSeriesItem } from '../../blocks/ChartBlocks/BarchartBlock/utils';
|
|
7
8
|
import { TipSectionProps } from '../../../insights/components/shared/ChartDrawerTemplate/TipSection';
|
|
8
9
|
import { BeatTransactionsResolver, DrillDownSlotData, SlotDataResolver } from './utils';
|
|
@@ -76,7 +77,7 @@ export interface DrillDownVariantConfig {
|
|
|
76
77
|
subTabAriaLabels?: (copy: InsightsFeedCopy) => (string | undefined)[];
|
|
77
78
|
hideListHeader?: boolean;
|
|
78
79
|
tipAboveSubTabs?: boolean;
|
|
79
|
-
averageFormat?:
|
|
80
|
+
averageFormat?: CurrencyFormat;
|
|
80
81
|
}
|
|
81
82
|
export declare const resolveUpcomingBillSlotData: SlotDataResolver;
|
|
82
83
|
export declare const resolveSavingsContributionsSlotData: SlotDataResolver;
|
|
@@ -2,15 +2,16 @@ import { buildDynamicCopy as h } from "../../../core/utils/Localization.es.js";
|
|
|
2
2
|
import { DATE_FORMATS_INTL as D, formatDate as E } from "../../../core/constants/DateFormats.es.js";
|
|
3
3
|
import { TransactionStatus as U } from "../../../core/types/Transaction.es.js";
|
|
4
4
|
import { fromUnixUTC as A } from "../../../core/utils/DateUtil.es.js";
|
|
5
|
-
import {
|
|
5
|
+
import { CURRENCY_FORMAT as P } from "../../../core/utils/NumberFormatting.es.js";
|
|
6
|
+
import { getCategoryColor as w } from "../../../core/utils/CategoryUtil.es.js";
|
|
6
7
|
import { buildDataSeries as M } from "../../blocks/ChartBlocks/BarchartBlock/utils.es.js";
|
|
7
8
|
import { asGuidList as N, asNonEmptyText as b, asNumber as u } from "../../blocks/slotReaders.es.js";
|
|
8
9
|
import { getLayoutConfig as I } from "../../blocks/ChartBlocks/DoubleBarChartBlock/layout.es.js";
|
|
9
|
-
import
|
|
10
|
-
import { buildProjectedBillTransaction as
|
|
11
|
-
import { Icon as
|
|
10
|
+
import Y from "../../components/LogoMark.es.js";
|
|
11
|
+
import { buildProjectedBillTransaction as F, calendarDateOf as H } from "./utils.es.js";
|
|
12
|
+
import { Icon as x } from "@mxenabled/mx-icons";
|
|
12
13
|
import { jsx as c } from "react/jsx-runtime";
|
|
13
|
-
import { endOfMonth as C, fromUnixTime as
|
|
14
|
+
import { endOfMonth as C, fromUnixTime as V, isValid as L, parseISO as p, startOfMonth as B } from "date-fns";
|
|
14
15
|
var i = {
|
|
15
16
|
TRANSACTION: "not_standard_amount",
|
|
16
17
|
CATEGORY_SPEND: "category_spend",
|
|
@@ -25,10 +26,10 @@ var i = {
|
|
|
25
26
|
DEPOSIT_SUMMARY: "monthly_deposit_summary",
|
|
26
27
|
LOW_BALANCE: "low_balance",
|
|
27
28
|
SUBSCRIPTION_AGGREGATE: "monthly_subscription_aggregate"
|
|
28
|
-
}, d = (t, e) => e &&
|
|
29
|
+
}, d = (t, e) => e && w(e, t) || t.palette.primary.main, T = (t) => typeof t == "string" ? p(t) : new Date(t ?? NaN), S = (t) => ({
|
|
29
30
|
start: B(T(t)),
|
|
30
31
|
end: C(T(t))
|
|
31
|
-
}), G = (t) => t?.length ? { accounts: t } : {},
|
|
32
|
+
}), G = (t) => t?.length ? { accounts: t } : {}, W = ({ beat: t }) => {
|
|
32
33
|
const { account_guid: e, from_date: a, to_date: o } = t.insights_payload?.drilldown_data ?? {};
|
|
33
34
|
return typeof e != "string" || typeof a != "number" || typeof o != "number" || !Number.isFinite(a) || !Number.isFinite(o) || o <= a ? {
|
|
34
35
|
accounts: [],
|
|
@@ -42,11 +43,11 @@ var i = {
|
|
|
42
43
|
end: A(o - 1)
|
|
43
44
|
}
|
|
44
45
|
};
|
|
45
|
-
},
|
|
46
|
+
}, k = (t) => {
|
|
46
47
|
const e = t?.drilldown_data ?? {};
|
|
47
48
|
return {
|
|
48
49
|
transaction_guids: N(e.transaction_guids),
|
|
49
|
-
date:
|
|
50
|
+
date: H(e.due_date),
|
|
50
51
|
amount: u(e.amount),
|
|
51
52
|
category_guid: b(e.category_guid),
|
|
52
53
|
average_amount: u(e.average_amount),
|
|
@@ -55,14 +56,14 @@ var i = {
|
|
|
55
56
|
}, _ = (t) => {
|
|
56
57
|
const e = t;
|
|
57
58
|
return Array.isArray(e?.names) && Array.isArray(e?.data) ? e : void 0;
|
|
58
|
-
},
|
|
59
|
+
}, j = (t) => {
|
|
59
60
|
const e = t?.drilldown_data ?? {};
|
|
60
61
|
return {
|
|
61
62
|
account_guids: N(e.account_guids),
|
|
62
63
|
data_series: _(e.data_series),
|
|
63
64
|
average_amount: u(e.average_amount)
|
|
64
65
|
};
|
|
65
|
-
}, R = ["income", "other"],
|
|
66
|
+
}, R = ["income", "other"], z = (t) => {
|
|
66
67
|
const e = t?.drilldown_data ?? {}, a = t?.instance_slot?.data?.legends?.map(({ label: o }) => o);
|
|
67
68
|
return {
|
|
68
69
|
data_series: _(e.data_series),
|
|
@@ -70,26 +71,26 @@ var i = {
|
|
|
70
71
|
income_transaction_guids: N(e.income_transaction_guids),
|
|
71
72
|
sub_tab_labels: a?.length === R.length ? a : void 0
|
|
72
73
|
};
|
|
73
|
-
},
|
|
74
|
+
}, K = 2, q = (t, e) => {
|
|
74
75
|
const a = e ?? {}, o = _(a.series), r = Array.isArray(a.labels) ? a.labels.map(b) : [];
|
|
75
|
-
return !o || r.length !==
|
|
76
|
+
return !o || r.length !== K || !r.every((s) => !!s) ? {} : {
|
|
76
77
|
data_series: o,
|
|
77
78
|
legends: r.map((s) => ({
|
|
78
79
|
label: s,
|
|
79
80
|
value: 0
|
|
80
81
|
}))
|
|
81
82
|
};
|
|
82
|
-
},
|
|
83
|
+
}, J = (t, e) => M(_(e?.series)).flatMap((a) => a.aggregated_guids ?? []), Q = (t, e) => {
|
|
83
84
|
const a = e.transaction_history_block?.monthly_debt_to_income_tip_message, o = e.transaction_history_block?.monthly_debt_to_income_tip_limit;
|
|
84
85
|
if (!(!a || !o))
|
|
85
86
|
return {
|
|
86
87
|
message: h(a, /* @__PURE__ */ c("strong", { children: e.general.tip_section_title }), /* @__PURE__ */ c("strong", { children: o })),
|
|
87
88
|
onDismiss: () => t(!0)
|
|
88
89
|
};
|
|
89
|
-
},
|
|
90
|
-
const a =
|
|
90
|
+
}, X = (t) => M(_(t.insights_payload?.drilldown_data?.data_series)).flatMap((e) => e.aggregated_guids ?? []), Z = (t, e) => {
|
|
91
|
+
const a = F(t, e);
|
|
91
92
|
return a ? [...t, a] : t;
|
|
92
|
-
},
|
|
93
|
+
}, $ = (t, e, a, o) => {
|
|
93
94
|
const r = o?.merchant_name, s = o?.date;
|
|
94
95
|
if (!r || !s) return;
|
|
95
96
|
const n = e.transaction_history_block?.upcoming_bill_tip_message;
|
|
@@ -105,21 +106,21 @@ var i = {
|
|
|
105
106
|
dateRange: S(o?.date),
|
|
106
107
|
showSplits: !s
|
|
107
108
|
};
|
|
108
|
-
},
|
|
109
|
+
}, tt = ({ dataSeries: t, selectedIndex: e, instanceSlotData: a }) => {
|
|
109
110
|
const o = t[e], r = a.category_guid ?? o?.guid;
|
|
110
111
|
return {
|
|
111
112
|
custom: (s) => s.category_guid === r || s.top_level_category_guid === r,
|
|
112
113
|
dateRange: S(o?.date)
|
|
113
114
|
};
|
|
114
|
-
},
|
|
115
|
+
}, et = ({ dataSeries: t, selectedIndex: e, spendCategoryGuids: a, instanceSlotData: o }) => {
|
|
115
116
|
const r = t[e];
|
|
116
117
|
return {
|
|
117
118
|
custom: (s) => !!s.top_level_category_guid && a.includes(s.top_level_category_guid),
|
|
118
119
|
dateRange: S(r?.date),
|
|
119
120
|
...G(o.account_guids)
|
|
120
121
|
};
|
|
121
|
-
},
|
|
122
|
-
const s = e[a], { start: n, end: g } = S(s?.date), l =
|
|
122
|
+
}, at = (t) => typeof t == "number" ? V(t) : p(t ?? ""), ot = ({ beat: t, dataSeries: e, selectedIndex: a, isLastTab: o, instanceSlotData: r }) => {
|
|
123
|
+
const s = e[a], { start: n, end: g } = S(s?.date), l = at(t.created_at), m = r.account_guids, O = {
|
|
123
124
|
start: n,
|
|
124
125
|
end: o && L(l) && l < g ? l : g
|
|
125
126
|
};
|
|
@@ -144,13 +145,13 @@ var i = {
|
|
|
144
145
|
},
|
|
145
146
|
...G(a)
|
|
146
147
|
};
|
|
147
|
-
},
|
|
148
|
+
}, rt = ({ beat: t, dataSeries: e, selectedIndex: a }) => f(e[a]?.aggregated_guids, e[a]?.date, t.account_guids), y = ({ beat: t, comparisonBars: e, selectedIndex: a, subIndex: o }) => {
|
|
148
149
|
const r = e[a];
|
|
149
150
|
return f(o === 1 ? r?.comparisonGuids : r?.mainGuids, r?.date, t.account_guids);
|
|
150
|
-
},
|
|
151
|
+
}, st = ({ beat: t, dataSeries: e, subIndex: a }) => f(e[a]?.aggregated_guids, e[a]?.date, t.account_guids), it = (t) => {
|
|
151
152
|
const { dataSeries: e, selectedIndex: a, subIndex: o, instanceSlotData: r } = t, s = e[a], n = new Set(r.income_transaction_guids), g = R[o] === "income", l = r.sub_tab_labels ? s?.aggregated_guids?.filter((m) => n.has(m) === g) : s?.aggregated_guids;
|
|
152
153
|
return f(l, s?.date);
|
|
153
|
-
},
|
|
154
|
+
}, vt = {
|
|
154
155
|
[i.TRANSACTION]: {
|
|
155
156
|
top: "singleBar",
|
|
156
157
|
scope: "store",
|
|
@@ -162,7 +163,7 @@ var i = {
|
|
|
162
163
|
return {
|
|
163
164
|
heading: e,
|
|
164
165
|
subHeadingText: a?.text || void 0,
|
|
165
|
-
icon: /* @__PURE__ */ c(
|
|
166
|
+
icon: /* @__PURE__ */ c(Y, {
|
|
166
167
|
logo: {
|
|
167
168
|
...a?.logo,
|
|
168
169
|
merchant_name: a?.text ?? a?.logo?.merchant_name
|
|
@@ -178,15 +179,15 @@ var i = {
|
|
|
178
179
|
},
|
|
179
180
|
[i.CATEGORY_SPEND]: {
|
|
180
181
|
top: "singleBar",
|
|
181
|
-
averageFormat:
|
|
182
|
-
filterStrategy:
|
|
182
|
+
averageFormat: P.whole,
|
|
183
|
+
filterStrategy: tt,
|
|
183
184
|
scope: "store",
|
|
184
185
|
filterMode: "store",
|
|
185
186
|
colors: (t, e) => [d(t, e)],
|
|
186
187
|
header: (t) => ({
|
|
187
188
|
heading: t.categoryName,
|
|
188
189
|
subHeadingText: t.selectedDate && E(T(t.selectedDate), D.MONTH_LONG) || "",
|
|
189
|
-
icon: /* @__PURE__ */ c(
|
|
190
|
+
icon: /* @__PURE__ */ c(x, {
|
|
190
191
|
color: "primary",
|
|
191
192
|
name: "calendar_month",
|
|
192
193
|
size: 16
|
|
@@ -195,15 +196,15 @@ var i = {
|
|
|
195
196
|
},
|
|
196
197
|
[i.MONTHLY_SPEND]: {
|
|
197
198
|
top: "singleBar",
|
|
198
|
-
filterStrategy:
|
|
199
|
+
filterStrategy: et,
|
|
199
200
|
scope: "store",
|
|
200
201
|
filterMode: "store",
|
|
201
202
|
colors: (t) => [t.palette.chart.chart2 ?? t.palette.primary.main]
|
|
202
203
|
},
|
|
203
204
|
[i.ACCOUNT_BALANCE]: {
|
|
204
205
|
top: "singleBar",
|
|
205
|
-
filterStrategy:
|
|
206
|
-
slotData:
|
|
206
|
+
filterStrategy: ot,
|
|
207
|
+
slotData: j,
|
|
207
208
|
scope: "store",
|
|
208
209
|
filterMode: "store",
|
|
209
210
|
colors: (t) => [t.palette.success.main]
|
|
@@ -214,24 +215,24 @@ var i = {
|
|
|
214
215
|
scope: "beat",
|
|
215
216
|
filterMode: "local",
|
|
216
217
|
colors: (t, e) => [d(t, e)],
|
|
217
|
-
slotData:
|
|
218
|
-
beatTransactions:
|
|
218
|
+
slotData: k,
|
|
219
|
+
beatTransactions: Z,
|
|
219
220
|
fetchMissingTransactions: (t) => t.insights_payload?.drilldown_data?.transaction_guids,
|
|
220
|
-
tipSection:
|
|
221
|
+
tipSection: $
|
|
221
222
|
},
|
|
222
223
|
[i.DEPOSIT_SUMMARY]: {
|
|
223
224
|
top: "singleBar",
|
|
224
|
-
filterStrategy:
|
|
225
|
+
filterStrategy: it,
|
|
225
226
|
scope: "store",
|
|
226
227
|
filterMode: "store",
|
|
227
228
|
colors: (t) => [t.palette.success.main],
|
|
228
|
-
slotData:
|
|
229
|
-
fetchMissingTransactions:
|
|
229
|
+
slotData: z,
|
|
230
|
+
fetchMissingTransactions: X,
|
|
230
231
|
subTabs: ({ instanceSlotData: t }) => t.sub_tab_labels ?? []
|
|
231
232
|
},
|
|
232
233
|
[i.LOW_BALANCE]: {
|
|
233
234
|
top: "list",
|
|
234
|
-
filterStrategy:
|
|
235
|
+
filterStrategy: W,
|
|
235
236
|
scope: "store",
|
|
236
237
|
filterMode: "store",
|
|
237
238
|
colors: (t) => [t.palette.primary.main],
|
|
@@ -239,7 +240,7 @@ var i = {
|
|
|
239
240
|
},
|
|
240
241
|
[i.SUBSCRIPTION_AGGREGATE]: {
|
|
241
242
|
top: "monthTabs",
|
|
242
|
-
filterStrategy:
|
|
243
|
+
filterStrategy: rt,
|
|
243
244
|
scope: "store",
|
|
244
245
|
filterMode: "store",
|
|
245
246
|
colors: (t) => [t.palette.primary.main]
|
|
@@ -267,20 +268,20 @@ var i = {
|
|
|
267
268
|
filterMode: "store",
|
|
268
269
|
colors: (t) => I(t, "debt_to_income")?.color ?? [],
|
|
269
270
|
subTabAriaLabels: (t) => [void 0, t.general.income_transactions],
|
|
270
|
-
slotData:
|
|
271
|
-
fetchMissingTransactions:
|
|
272
|
-
tipSection:
|
|
271
|
+
slotData: q,
|
|
272
|
+
fetchMissingTransactions: J,
|
|
273
|
+
tipSection: Q,
|
|
273
274
|
tipAboveSubTabs: !0,
|
|
274
275
|
hideListHeader: !0
|
|
275
276
|
},
|
|
276
277
|
[i.NON_ESSENTIAL_CATEGORY]: {
|
|
277
278
|
top: "tabsOnly",
|
|
278
|
-
filterStrategy:
|
|
279
|
+
filterStrategy: st,
|
|
279
280
|
scope: "store",
|
|
280
281
|
filterMode: "store",
|
|
281
282
|
colors: (t) => [t.palette.primary.main]
|
|
282
283
|
}
|
|
283
|
-
},
|
|
284
|
+
}, ht = {
|
|
284
285
|
top: "singleBar",
|
|
285
286
|
filterStrategy: v,
|
|
286
287
|
scope: "store",
|
|
@@ -289,13 +290,13 @@ var i = {
|
|
|
289
290
|
};
|
|
290
291
|
export {
|
|
291
292
|
i as DRILLDOWN_VARIANTS,
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
293
|
+
ht as FALLBACK,
|
|
294
|
+
vt as layout,
|
|
295
|
+
q as resolveDebtToIncomeSlotData,
|
|
296
|
+
z as resolveDepositSummarySlotData,
|
|
297
|
+
j as resolveSavingsContributionsSlotData,
|
|
298
|
+
k as resolveUpcomingBillSlotData,
|
|
299
|
+
Z as resolveUpcomingBillTransactions
|
|
299
300
|
};
|
|
300
301
|
|
|
301
302
|
//# sourceMappingURL=layout.es.js.map
|