@mx-cartographer/experiences 9.7.165 → 9.7.167
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/common/components/dialog/Dialog.es.js +26 -29
- package/dist/common/components/dialog/Dialog.es.js.map +1 -1
- package/dist/core/types/localization/InsightsFeedCopy.d.ts +0 -2
- package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/SaveEnoughToLiveOnBottomSection.es.js +1 -1
- package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/SaveEnoughToLiveOnBottomSection.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionDrillDown.d.ts +1 -5
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionDrillDown.es.js +53 -58
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionDrillDown.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js +92 -99
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.d.ts +1 -3
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js +72 -81
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistory.d.ts +5 -6
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistory.es.js +16 -16
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistory.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.d.ts +4 -32
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.es.js +59 -83
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/AccountSwitchBlock/layout.es.js +8 -7
- package/dist/insights-v2/blocks/ComponentBlocks/AccountSwitchBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/SavingsSummaryBlock/SavingsSummaryBlock.es.js +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/SavingsSummaryBlock/SavingsSummaryBlock.es.js.map +1 -1
- package/dist/insights-v2/components/celebrationGradients.d.ts +4 -3
- package/dist/insights-v2/components/celebrationGradients.es.js +14 -14
- package/dist/insights-v2/components/celebrationGradients.es.js.map +1 -1
- package/dist/insights-v2/mappings/blocks.es.js +0 -1
- package/dist/insights-v2/mappings/blocks.es.js.map +1 -1
- package/dist/transactions/components/shared/transactiondetails/actions/CategoryAction.es.js +51 -49
- package/dist/transactions/components/shared/transactiondetails/actions/CategoryAction.es.js.map +1 -1
- package/dist/transactions/components/transactionwidget/actions/EditCategoryAction.es.js +25 -23
- package/dist/transactions/components/transactionwidget/actions/EditCategoryAction.es.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,116 +1,110 @@
|
|
|
1
|
-
import { useGlobalCopyStore as
|
|
2
|
-
import { CURRENCY_FORMAT as
|
|
3
|
-
import
|
|
4
|
-
import { BAR_ARIA_LABEL as
|
|
5
|
-
import { BarChartV2 as
|
|
6
|
-
import { EmptyBarChart as
|
|
7
|
-
import { ANALYTICS_EVENTS_CONFIG as
|
|
8
|
-
import { useAnalyticsEvent as
|
|
9
|
-
import { DoubleBarChart as
|
|
10
|
-
import { toLegendItems as
|
|
11
|
-
import { getDefaultSelection as
|
|
12
|
-
import { useOpenedCta as
|
|
13
|
-
import { TransactionDrillDown as
|
|
14
|
-
import { useTransactionHistory as
|
|
15
|
-
import { TransactionDetailsBlock as
|
|
16
|
-
import { useRequiredCopy as
|
|
17
|
-
import { useLayoutEffect as
|
|
18
|
-
import { observer as
|
|
19
|
-
import { Fragment as
|
|
20
|
-
import { useTheme as
|
|
21
|
-
var
|
|
22
|
-
const
|
|
23
|
-
slotData: $,
|
|
24
|
-
beatTransactions: J
|
|
25
|
-
}, B?.drilldown_data), { common: ot } = yt(), s = Pt(Wt), [at, R] = d(!1), [nt, st] = d(!1), E = Rt(), { dataSeries: p, chartData: g, comparisonBars: r } = jt({
|
|
1
|
+
import { useGlobalCopyStore as ft, useInsightsV2Store as ht } from "../../../common/context/hooks.es.js";
|
|
2
|
+
import { CURRENCY_FORMAT as Ct, formatCurrency as _t } from "../../../core/utils/NumberFormatting.es.js";
|
|
3
|
+
import yt from "../../../common/components/drawer/Drawer.es.js";
|
|
4
|
+
import { BAR_ARIA_LABEL as Tt } from "../../blocks/ChartBlocks/BarchartBlock/utils.es.js";
|
|
5
|
+
import { BarChartV2 as At } from "../../components/chartblocks/BarchartV2.es.js";
|
|
6
|
+
import { EmptyBarChart as Dt } from "../../components/chartblocks/EmptyBarChart.es.js";
|
|
7
|
+
import { ANALYTICS_EVENTS_CONFIG as M } from "../../analytics/analyticsEventsConfig.es.js";
|
|
8
|
+
import { useAnalyticsEvent as St } from "../../analytics/useAnalyticsEvent.es.js";
|
|
9
|
+
import { DoubleBarChart as vt } from "../../components/chartblocks/DoubleBarChart.es.js";
|
|
10
|
+
import { toLegendItems as Bt } from "../../blocks/ChartBlocks/DoubleBarChartBlock/comparisonUtils.es.js";
|
|
11
|
+
import { getDefaultSelection as Lt, getDrillDownConfig as It, getFlattenedDataSeries as Et, resolveDrillDownSubHeader as Rt, toStoreFilter as xt } from "./utils.es.js";
|
|
12
|
+
import { useOpenedCta as Ft } from "../useOpenedCta.es.js";
|
|
13
|
+
import { TransactionDrillDown as Ot } from "./TransactionDrillDown.es.js";
|
|
14
|
+
import { useTransactionHistory as Gt } from "./useTransactionHistory.es.js";
|
|
15
|
+
import { TransactionDetailsBlock as Ht } from "../TransactionDetailsBlock/TransactionDetailsBlock.es.js";
|
|
16
|
+
import { useRequiredCopy as wt } from "../useRequiredCopy.es.js";
|
|
17
|
+
import { useLayoutEffect as Nt, useState as d } from "react";
|
|
18
|
+
import { observer as jt } from "mobx-react-lite";
|
|
19
|
+
import { Fragment as kt, jsx as l, jsxs as Mt } from "react/jsx-runtime";
|
|
20
|
+
import { useTheme as Kt } from "@mui/material/styles";
|
|
21
|
+
var Vt = (a) => a.insights_feed, me = jt(({ beat: a }) => {
|
|
22
|
+
const y = Kt(), { actionDrawer: K, setActionContext: T } = ht(), { insights_payload: A } = a, D = Ft(a), V = D?.variant, { top: e, filterMode: m, header: P, colors: z, filterStrategy: Y, tipSection: S, subTabAriaLabels: q, slotData: U, averageFormat: W, subTabs: $, boldLabel: J } = It(V ?? ""), { instanceSlotData: o, beatTransactions: u, spendCategoryGuids: v, allAccountGuids: B, categoryName: Q, displayedDateRange: f, transactionStore: X } = Gt(a, { slotData: U }, D?.drilldown_data), { common: Z } = ft(), r = wt(Vt), [tt, L] = d(!1), [et, ot] = d(!1), I = St(), { dataSeries: g, chartData: p, comparisonBars: s } = Et({
|
|
26
23
|
data: o?.data_series,
|
|
27
|
-
ariaLabel: e === "doubleBar" ?
|
|
24
|
+
ariaLabel: e === "doubleBar" ? r?.general?.in_month_you_had_a_category_of_amount ?? "_1{month}, _2{category}: _3{amount}" : Tt,
|
|
28
25
|
top: e,
|
|
29
26
|
beatTransactions: u
|
|
30
|
-
}), c = e === "doubleBar",
|
|
31
|
-
chartTabCount:
|
|
32
|
-
comparisonTabCount:
|
|
33
|
-
actionDrawer:
|
|
27
|
+
}), c = e === "doubleBar", at = e === "tabsOnly", i = c ? s : p, { chartBarIndex: E, subTabIndex: nt } = Lt({
|
|
28
|
+
chartTabCount: p.length,
|
|
29
|
+
comparisonTabCount: s.length,
|
|
30
|
+
actionDrawer: K,
|
|
34
31
|
beatGuid: a.guid
|
|
35
|
-
}), [n, h] = d(
|
|
36
|
-
i.length !==
|
|
37
|
-
const
|
|
32
|
+
}), [n, h] = d(E), [C, R] = d(nt), [rt, st] = d(i.length);
|
|
33
|
+
i.length !== rt && (st(i.length), h(E));
|
|
34
|
+
const x = (t) => Y({
|
|
38
35
|
beat: a,
|
|
39
36
|
beatTransactions: u,
|
|
40
|
-
dataSeries:
|
|
41
|
-
comparisonBars:
|
|
37
|
+
dataSeries: g,
|
|
38
|
+
comparisonBars: s,
|
|
42
39
|
selectedIndex: t,
|
|
43
40
|
subIndex: C,
|
|
44
41
|
isLastTab: t === i.length - 1,
|
|
45
42
|
instanceSlotData: o,
|
|
46
|
-
spendCategoryGuids:
|
|
43
|
+
spendCategoryGuids: v,
|
|
47
44
|
displayedDateRange: f
|
|
48
|
-
}),
|
|
45
|
+
}), it = u.map((t) => t.guid).join(","), lt = v.join(","), ct = B.join(","), dt = e === "list" || e === "tabsOnly" || e === "monthTabs" || g.length > 0, F = () => {
|
|
49
46
|
if (m !== "store") return;
|
|
50
|
-
const t =
|
|
47
|
+
const t = dt ? x(n) : {
|
|
51
48
|
accounts: [],
|
|
52
49
|
custom: () => !1
|
|
53
50
|
};
|
|
54
|
-
|
|
55
|
-
allAccountGuids:
|
|
51
|
+
X.setFilter(xt(t, {
|
|
52
|
+
allAccountGuids: B,
|
|
56
53
|
displayedDateRange: f
|
|
57
54
|
}));
|
|
58
55
|
};
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
Nt(() => {
|
|
57
|
+
F();
|
|
61
58
|
}, [
|
|
62
59
|
a.guid,
|
|
63
60
|
n,
|
|
64
61
|
C,
|
|
65
62
|
m,
|
|
66
|
-
|
|
63
|
+
g.length,
|
|
67
64
|
o,
|
|
68
65
|
f,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
66
|
+
lt,
|
|
67
|
+
ct,
|
|
68
|
+
it,
|
|
72
69
|
e
|
|
73
70
|
]);
|
|
74
|
-
const
|
|
75
|
-
title:
|
|
76
|
-
subHeader:
|
|
77
|
-
categoryName:
|
|
78
|
-
selectedDate:
|
|
71
|
+
const O = Rt(A), _ = P?.({
|
|
72
|
+
title: A?.title,
|
|
73
|
+
subHeader: O,
|
|
74
|
+
categoryName: Q,
|
|
75
|
+
selectedDate: p[n]?.date ?? void 0,
|
|
79
76
|
slotData: o
|
|
80
|
-
}),
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}, M = c ? xt([{
|
|
88
|
-
...G,
|
|
89
|
-
value: r[n]?.main
|
|
77
|
+
}), G = z(y, o?.category_guid), [H, w] = o?.legends ?? [], mt = m === "local" ? (t) => x(t).custom ?? (() => !0) : void 0, ut = m === "local" ? u : void 0, N = (t, b) => {
|
|
78
|
+
I(M.DRAWER_CHART_BAR_CLICKED), h(t), b !== void 0 && R(b);
|
|
79
|
+
}, gt = (t) => {
|
|
80
|
+
I(M.TAB_SELECTED), h(t);
|
|
81
|
+
}, j = c ? Bt([{
|
|
82
|
+
...H,
|
|
83
|
+
value: s[n]?.main
|
|
90
84
|
}, {
|
|
91
85
|
...w,
|
|
92
|
-
value:
|
|
93
|
-
}]) : void 0,
|
|
86
|
+
value: s[n]?.comparison
|
|
87
|
+
}]) : void 0, pt = q?.(r) ?? [], k = c ? (j ?? []).map((t, b) => ({
|
|
94
88
|
label: t.label,
|
|
95
|
-
ariaLabel:
|
|
96
|
-
})) :
|
|
89
|
+
ariaLabel: pt[b]
|
|
90
|
+
})) : at ? g.flatMap((t) => t.localized_label ? [{ label: t.localized_label }] : []) : $?.({
|
|
97
91
|
instanceSlotData: o,
|
|
98
|
-
copy:
|
|
99
|
-
}).map((t) => ({ label: t })) ?? [],
|
|
100
|
-
bars:
|
|
101
|
-
boldLabel:
|
|
102
|
-
colors:
|
|
92
|
+
copy: r
|
|
93
|
+
}).map((t) => ({ label: t })) ?? [], bt = c || e === "singleBar" || e === "upcomingBill" ? i.length ? c ? /* @__PURE__ */ l(vt, {
|
|
94
|
+
bars: s,
|
|
95
|
+
boldLabel: J,
|
|
96
|
+
colors: G,
|
|
103
97
|
legendPosition: "top",
|
|
104
|
-
legends:
|
|
105
|
-
onBarClick:
|
|
98
|
+
legends: j,
|
|
99
|
+
onBarClick: N,
|
|
106
100
|
selectedIndex: n
|
|
107
|
-
}) : /* @__PURE__ */ l(
|
|
101
|
+
}) : /* @__PURE__ */ l(At, {
|
|
108
102
|
amounts: {
|
|
109
103
|
average: o?.average_amount,
|
|
110
|
-
formattedAverage:
|
|
104
|
+
formattedAverage: _t(o?.average_amount ?? 0, W ?? Ct.cents)
|
|
111
105
|
},
|
|
112
|
-
color:
|
|
113
|
-
data:
|
|
106
|
+
color: G[0] ?? y.palette.primary.main,
|
|
107
|
+
data: p,
|
|
114
108
|
legendPosition: "top",
|
|
115
109
|
heightOverride: 172,
|
|
116
110
|
margin: {
|
|
@@ -119,44 +113,43 @@ var Wt = (a) => a.insights_feed, he = zt(({ beat: a }) => {
|
|
|
119
113
|
left: 24,
|
|
120
114
|
right: 24
|
|
121
115
|
},
|
|
122
|
-
monthlyAmountLabel:
|
|
123
|
-
onBarClick:
|
|
116
|
+
monthlyAmountLabel: H?.label ?? r.general.monthly_amount,
|
|
117
|
+
onBarClick: N,
|
|
124
118
|
selectedTabIndex: n,
|
|
125
|
-
trendAmountLabel: w?.label ??
|
|
126
|
-
}) : /* @__PURE__ */ l(
|
|
127
|
-
return /* @__PURE__ */
|
|
128
|
-
baseTransactions:
|
|
129
|
-
projectedRow: ht,
|
|
119
|
+
trendAmountLabel: w?.label ?? r.general.trend
|
|
120
|
+
}) : /* @__PURE__ */ l(Dt, {}) : null;
|
|
121
|
+
return /* @__PURE__ */ Mt(kt, { children: [/* @__PURE__ */ l(Ot, {
|
|
122
|
+
baseTransactions: ut,
|
|
130
123
|
heading: _?.heading,
|
|
131
124
|
icon: _?.icon,
|
|
132
|
-
onSelectionChange:
|
|
125
|
+
onSelectionChange: gt,
|
|
133
126
|
selectedIndex: n,
|
|
134
127
|
subHeadingText: _?.subHeadingText,
|
|
135
128
|
tabs: i,
|
|
136
|
-
top:
|
|
137
|
-
...
|
|
138
|
-
tabs:
|
|
129
|
+
top: bt,
|
|
130
|
+
...k.length > 0 && { subTabs: {
|
|
131
|
+
tabs: k,
|
|
139
132
|
selectedIndex: C,
|
|
140
|
-
onChange:
|
|
133
|
+
onChange: R
|
|
141
134
|
} },
|
|
142
|
-
...S && { tipSection: !
|
|
143
|
-
transactionFilter:
|
|
135
|
+
...S && { tipSection: !et && (S(ot, r, O?.text, o) ?? !1) },
|
|
136
|
+
transactionFilter: mt,
|
|
144
137
|
onEachRowClick: (t) => {
|
|
145
|
-
|
|
138
|
+
T({ transaction_guid: t }), L(!0);
|
|
146
139
|
}
|
|
147
|
-
}), /* @__PURE__ */ l(
|
|
148
|
-
ariaLabelClose:
|
|
149
|
-
isOpen:
|
|
140
|
+
}), /* @__PURE__ */ l(yt, {
|
|
141
|
+
ariaLabelClose: Z.close_aria,
|
|
142
|
+
isOpen: tt,
|
|
150
143
|
onClose: () => {
|
|
151
|
-
|
|
144
|
+
L(!1), T({ transaction_guid: void 0 }), F();
|
|
152
145
|
},
|
|
153
|
-
title:
|
|
154
|
-
children: /* @__PURE__ */ l(
|
|
146
|
+
title: r.general.transaction_details_title,
|
|
147
|
+
children: /* @__PURE__ */ l(Ht, { beat: a })
|
|
155
148
|
})] });
|
|
156
149
|
});
|
|
157
150
|
export {
|
|
158
|
-
|
|
159
|
-
|
|
151
|
+
me as TransactionHistoryBlock,
|
|
152
|
+
Vt as selectTransactionHistoryCopy
|
|
160
153
|
};
|
|
161
154
|
|
|
162
155
|
//# 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, GlobalCopy, 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 { Drawer, useInsightsV2Store, useGlobalCopyStore } from '../../../common'\nimport { TransactionDetailsBlock } from '../TransactionDetailsBlock'\nimport { useOpenedCta } from '../useOpenedCta'\nimport { useRequiredCopy } from '../useRequiredCopy'\n\ninterface TransactionHistoryProp {\n beat: Beat\n}\n\nexport const selectTransactionHistoryCopy = (copy: GlobalCopy) => copy.insights_feed\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 render.\n const openedCta = useOpenedCta(beat)\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 averageFormat,\n subTabs,\n boldLabel,\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 } = useGlobalCopyStore()\n const insightsCopy = useRequiredCopy(selectTransactionHistoryCopy)\n\n const [isTransactionDetailsOpen, setIsTransactionDetailsOpen] = useState(false)\n\n const [closeTipSection, setCloseTipSection] = useState(false)\n\n const fireAnalyticsEvent = useAnalyticsEvent()\n\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 slotData: instanceSlotData,\n })\n\n const barColors = colors(theme, instanceSlotData?.category_guid)\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 boldLabel={boldLabel}\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 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":";;;;;;;;;;;;;;;;;;;;AAoCA,IAAa,KAAA,CAAgC,MAAqB,EAAK,eAE1D,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,GAAa,CAAI,GAC7B,IAAoB,GAAW,SAE/B,EACJ,KAAA,GACA,YAAA,GACA,QAAA,GACA,QAAA,GACA,gBAAA,GACA,YAAA,GACA,kBAAA,GACA,UAAA,GACA,kBAAkB,GAClB,eAAA,GACA,SAAA,GACA,WAAA,EAAA,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,GAAA,IAAe,GAAmB,GAC5C,IAAe,GAAgB,EAA4B,GAE3D,CAAC,IAA0B,CAAA,IAA+B,EAAS,EAAK,GAExE,CAAC,IAAiB,EAAA,IAAsB,EAAS,EAAK,GAEtD,IAAqB,GAAkB,GAEvC,EAAE,YAAA,GAAY,WAAA,GAAW,gBAAA,EAAA,IAAmB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jF,SACE,gBAAA,GAAA,IAAA,EAAA,UAAA,CACE,gBAAA,EAAC,IAAD;AAAA,IACoB,kBAAA;AAAA,IACJ,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"}
|
|
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, GlobalCopy, 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 toStoreFilter,\n} from './utils'\nimport { Drawer, useInsightsV2Store, useGlobalCopyStore } from '../../../common'\nimport { TransactionDetailsBlock } from '../TransactionDetailsBlock'\nimport { useOpenedCta } from '../useOpenedCta'\nimport { useRequiredCopy } from '../useRequiredCopy'\n\ninterface TransactionHistoryProp {\n beat: Beat\n}\n\nexport const selectTransactionHistoryCopy = (copy: GlobalCopy) => copy.insights_feed\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 render.\n const openedCta = useOpenedCta(beat)\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 averageFormat,\n subTabs,\n boldLabel,\n } = getDrillDownConfig(dynamicCtaVariant ?? '')\n\n const {\n instanceSlotData,\n beatTransactions,\n spendCategoryGuids,\n allAccountGuids,\n categoryName,\n displayedDateRange,\n transactionStore,\n } = useTransactionHistory(beat, { slotData }, openedCta?.drilldown_data)\n\n const { common: commonCopy } = useGlobalCopyStore()\n const insightsCopy = useRequiredCopy(selectTransactionHistoryCopy)\n\n const [isTransactionDetailsOpen, setIsTransactionDetailsOpen] = useState(false)\n\n const [closeTipSection, setCloseTipSection] = useState(false)\n\n const fireAnalyticsEvent = useAnalyticsEvent()\n\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 slotData: instanceSlotData,\n })\n\n const barColors = colors(theme, instanceSlotData?.category_guid)\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 const baseTransactions: Transaction[] | undefined =\n filterMode === 'local' ? beatTransactions : 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 boldLabel={boldLabel}\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 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":";;;;;;;;;;;;;;;;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B,EAAW;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"}
|
|
@@ -6,7 +6,7 @@ import { DataSet } from '../../../core/types/InsightsInstanceSlotData';
|
|
|
6
6
|
import { CurrencyFormat } from '../../../core/utils/NumberFormatting';
|
|
7
7
|
import { ChartDataSeriesItem } from '../../blocks/ChartBlocks/BarchartBlock/utils';
|
|
8
8
|
import { TipSectionProps } from '../../../insights/components/shared/ChartDrawerTemplate/TipSection';
|
|
9
|
-
import {
|
|
9
|
+
import { DrillDownSlotData, SlotDataResolver } from './utils';
|
|
10
10
|
export interface DrillDownHeader {
|
|
11
11
|
heading?: string;
|
|
12
12
|
subHeadingText?: string;
|
|
@@ -71,7 +71,6 @@ export interface DrillDownVariantConfig {
|
|
|
71
71
|
header?: HeaderKind;
|
|
72
72
|
subTabs?: SubTabsKind;
|
|
73
73
|
slotData?: SlotDataResolver;
|
|
74
|
-
beatTransactions?: BeatTransactionsResolver;
|
|
75
74
|
fetchMissingTransactions?: (beat: Beat, ctaDrilldownData?: DrilldownData) => unknown;
|
|
76
75
|
tipSection?: (setCloseTipSection: (flag: boolean) => void, copy: InsightsFeedCopy, merchantName?: string, slotData?: DrillDownSlotData) => TipSectionProps | undefined;
|
|
77
76
|
scope: 'store' | 'beat';
|
|
@@ -85,6 +84,5 @@ export declare const resolveSavingsContributionsSlotData: SlotDataResolver;
|
|
|
85
84
|
export declare const resolveMerchantBudgetSlotData: SlotDataResolver;
|
|
86
85
|
export declare const resolveDepositSummarySlotData: SlotDataResolver;
|
|
87
86
|
export declare const resolveDebtToIncomeSlotData: SlotDataResolver;
|
|
88
|
-
export declare const resolveUpcomingBillTransactions: BeatTransactionsResolver;
|
|
89
87
|
export declare const layout: Partial<Record<DrillDownVariant, DrillDownVariantConfig>>;
|
|
90
88
|
export declare const FALLBACK: DrillDownVariantConfig;
|