@mx-cartographer/experiences 9.7.196 → 9.7.198
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -1
- package/dist/core/types/localization/InsightsFeedCopy.d.ts +4 -0
- package/dist/insights/components/shared/Charts/BarChart/CustomBarPlotV2.d.ts +3 -1
- package/dist/insights/components/shared/Charts/BarChart/CustomBarPlotV2.es.js +29 -21
- package/dist/insights/components/shared/Charts/BarChart/CustomBarPlotV2.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionDrillDown.d.ts +3 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionDrillDown.es.js +68 -63
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionDrillDown.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js +94 -91
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.d.ts +3 -0
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js +218 -185
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/MerchantBlock.es.js +59 -56
- package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/MerchantBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/layout.d.ts +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/layout.es.js +22 -11
- package/dist/insights-v2/blocks/ComponentBlocks/MerchantBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/components/LogoClusterCard.es.js +9 -8
- package/dist/insights-v2/components/LogoClusterCard.es.js.map +1 -1
- package/dist/insights-v2/components/chartblocks/BarchartV2.d.ts +9 -1
- package/dist/insights-v2/components/chartblocks/BarchartV2.es.js +109 -85
- package/dist/insights-v2/components/chartblocks/BarchartV2.es.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,111 +1,111 @@
|
|
|
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 _ =
|
|
1
|
+
import { useGlobalCopyStore as Dt, useInsightsV2Store as Lt } from "../../../common/context/hooks.es.js";
|
|
2
|
+
import { CURRENCY_FORMAT as St, formatCurrency as vt } from "../../../core/utils/NumberFormatting.es.js";
|
|
3
|
+
import Bt from "../../../common/components/drawer/Drawer.es.js";
|
|
4
|
+
import { BAR_ARIA_LABEL as It } from "../../blocks/ChartBlocks/BarchartBlock/utils.es.js";
|
|
5
|
+
import { BarChartV2 as Et } from "../../components/chartblocks/BarchartV2.es.js";
|
|
6
|
+
import { EmptyBarChart as Rt } from "../../components/chartblocks/EmptyBarChart.es.js";
|
|
7
|
+
import { ANALYTICS_EVENTS_CONFIG as V } from "../../analytics/analyticsEventsConfig.es.js";
|
|
8
|
+
import { useAnalyticsEvent as xt } from "../../analytics/useAnalyticsEvent.es.js";
|
|
9
|
+
import { DoubleBarChart as Ft } from "../../components/chartblocks/DoubleBarChart.es.js";
|
|
10
|
+
import { toLegendItems as Ot } from "../../blocks/ChartBlocks/DoubleBarChartBlock/comparisonUtils.es.js";
|
|
11
|
+
import { getDefaultSelection as wt, getDrillDownConfig as Ht, getFlattenedDataSeries as Gt, resolveDrillDownSubHeader as Mt, toStoreFilter as kt } from "./utils.es.js";
|
|
12
|
+
import { useOpenedCta as Nt } from "../useOpenedCta.es.js";
|
|
13
|
+
import { TransactionDrillDown as jt } from "./TransactionDrillDown.es.js";
|
|
14
|
+
import { useTransactionHistory as Vt } from "./useTransactionHistory.es.js";
|
|
15
|
+
import { TransactionDetailsBlock as Kt } from "../TransactionDetailsBlock/TransactionDetailsBlock.es.js";
|
|
16
|
+
import { useRequiredCopy as Pt } from "../useRequiredCopy.es.js";
|
|
17
|
+
import { useLayoutEffect as zt, useState as d } from "react";
|
|
18
|
+
import { observer as Yt } from "mobx-react-lite";
|
|
19
|
+
import { Fragment as qt, jsx as l, jsxs as Ut } from "react/jsx-runtime";
|
|
20
|
+
import { useTheme as Wt } from "@mui/material/styles";
|
|
21
|
+
var $t = (a) => a.insights_feed, Ce = Yt(({ beat: a, cta: K }) => {
|
|
22
|
+
const _ = Wt(), { actionDrawer: P, setActionContext: A } = Lt(), { insights_payload: D } = a, z = Nt(a), L = K ?? z, Y = L?.variant, { top: e, filterMode: m, header: q, colors: U, filterStrategy: W, tipSection: S, subTabAriaLabels: $, slotData: J, averageFormat: Q, subTabs: X, boldLabel: Z, barLegendLabel: tt, showMonthlyAmount: et, showMonthTabs: ot = !0, showTransactionsHeader: at = !0 } = Ht(Y ?? ""), f = !ot && e === "singleBar", { instanceSlotData: o, beatTransactions: u, spendCategoryGuids: v, allAccountGuids: B, categoryName: nt, displayedDateRange: C, transactionStore: rt } = Vt(a, { slotData: J }, L?.drilldown_data), { common: st } = Dt(), n = Pt($t), [it, I] = d(!1), [lt, ct] = d(!1), E = xt(), { dataSeries: g, chartData: p, comparisonBars: i } = Gt({
|
|
23
23
|
data: o?.data_series,
|
|
24
|
-
ariaLabel: e === "doubleBar" ? n?.general?.in_month_you_had_a_category_of_amount ?? "_1{month}, _2{category}: _3{amount}" :
|
|
24
|
+
ariaLabel: e === "doubleBar" ? n?.general?.in_month_you_had_a_category_of_amount ?? "_1{month}, _2{category}: _3{amount}" : It,
|
|
25
25
|
top: e,
|
|
26
26
|
beatTransactions: u
|
|
27
|
-
}), c = e === "doubleBar",
|
|
27
|
+
}), c = e === "doubleBar", dt = e === "tabsOnly", s = c ? i : p, { chartBarIndex: R, subTabIndex: mt } = wt({
|
|
28
28
|
chartTabCount: p.length,
|
|
29
|
-
comparisonTabCount:
|
|
30
|
-
actionDrawer:
|
|
29
|
+
comparisonTabCount: i.length,
|
|
30
|
+
actionDrawer: P,
|
|
31
31
|
beatGuid: a.guid
|
|
32
|
-
}), [r,
|
|
33
|
-
|
|
34
|
-
const
|
|
32
|
+
}), [r, y] = d(R), [T, x] = d(mt), [ut, gt] = d(s.length);
|
|
33
|
+
s.length !== ut && (gt(s.length), y(R));
|
|
34
|
+
const F = (t) => W({
|
|
35
35
|
beat: a,
|
|
36
36
|
beatTransactions: u,
|
|
37
37
|
dataSeries: g,
|
|
38
|
-
comparisonBars:
|
|
38
|
+
comparisonBars: i,
|
|
39
39
|
selectedIndex: t,
|
|
40
|
-
subIndex:
|
|
41
|
-
isLastTab: t ===
|
|
40
|
+
subIndex: T,
|
|
41
|
+
isLastTab: t === s.length - 1,
|
|
42
42
|
instanceSlotData: o,
|
|
43
|
-
spendCategoryGuids:
|
|
44
|
-
displayedDateRange:
|
|
45
|
-
}),
|
|
43
|
+
spendCategoryGuids: v,
|
|
44
|
+
displayedDateRange: C
|
|
45
|
+
}), pt = u.map((t) => t.guid).join(","), bt = v.join(","), ht = B.join(","), ft = e === "list" || e === "tabsOnly" || e === "monthTabs" || g.length > 0, O = () => {
|
|
46
46
|
if (m !== "store") return;
|
|
47
|
-
const t =
|
|
47
|
+
const t = ft ? F(r) : {
|
|
48
48
|
accounts: [],
|
|
49
49
|
custom: () => !1
|
|
50
50
|
};
|
|
51
|
-
|
|
52
|
-
allAccountGuids:
|
|
53
|
-
displayedDateRange:
|
|
51
|
+
rt.setFilter(kt(t, {
|
|
52
|
+
allAccountGuids: B,
|
|
53
|
+
displayedDateRange: C
|
|
54
54
|
}));
|
|
55
55
|
};
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
zt(() => {
|
|
57
|
+
O();
|
|
58
58
|
}, [
|
|
59
59
|
a.guid,
|
|
60
60
|
r,
|
|
61
|
-
|
|
61
|
+
T,
|
|
62
62
|
m,
|
|
63
63
|
g.length,
|
|
64
64
|
o,
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
C,
|
|
66
|
+
bt,
|
|
67
|
+
ht,
|
|
68
|
+
pt,
|
|
69
69
|
e
|
|
70
70
|
]);
|
|
71
|
-
const
|
|
72
|
-
title:
|
|
73
|
-
subHeader:
|
|
74
|
-
categoryName:
|
|
71
|
+
const w = Mt(D), b = q?.({
|
|
72
|
+
title: D?.title,
|
|
73
|
+
subHeader: w,
|
|
74
|
+
categoryName: nt,
|
|
75
75
|
selectedDate: p[r]?.date ?? void 0,
|
|
76
76
|
slotData: o,
|
|
77
77
|
copy: n
|
|
78
|
-
}),
|
|
79
|
-
|
|
80
|
-
},
|
|
81
|
-
|
|
82
|
-
}, N = c ?
|
|
78
|
+
}), H = U(_, o?.category_guid), [G, M] = o?.legends ?? [], Ct = m === "local" ? (t) => F(t).custom ?? (() => !0) : void 0, yt = m === "local" ? u : void 0, k = (t, h) => {
|
|
79
|
+
E(V.DRAWER_CHART_BAR_CLICKED), y(t), h !== void 0 && x(h);
|
|
80
|
+
}, Tt = (t) => {
|
|
81
|
+
E(V.TAB_SELECTED), y(t);
|
|
82
|
+
}, N = c ? Ot([{
|
|
83
83
|
...G,
|
|
84
|
-
value:
|
|
84
|
+
value: i[r]?.main
|
|
85
85
|
}, {
|
|
86
|
-
...
|
|
87
|
-
value:
|
|
88
|
-
}]) : void 0,
|
|
86
|
+
...M,
|
|
87
|
+
value: i[r]?.comparison
|
|
88
|
+
}]) : void 0, _t = $?.(n) ?? [], j = c ? (N ?? []).map((t, h) => ({
|
|
89
89
|
label: t.label,
|
|
90
|
-
ariaLabel:
|
|
91
|
-
})) :
|
|
90
|
+
ariaLabel: _t[h]
|
|
91
|
+
})) : dt ? g.flatMap((t) => t.localized_label ? [{ label: t.localized_label }] : []) : X?.({
|
|
92
92
|
instanceSlotData: o,
|
|
93
93
|
copy: n
|
|
94
|
-
}).map((t) => ({ label: t })) ?? [],
|
|
95
|
-
bars:
|
|
96
|
-
boldLabel:
|
|
97
|
-
colors:
|
|
94
|
+
}).map((t) => ({ label: t })) ?? [], At = c || e === "singleBar" || e === "upcomingBill" ? s.length ? c ? /* @__PURE__ */ l(Ft, {
|
|
95
|
+
bars: i,
|
|
96
|
+
boldLabel: Z,
|
|
97
|
+
colors: H,
|
|
98
98
|
legendPosition: "top",
|
|
99
99
|
legendVariant: "body2",
|
|
100
100
|
legends: N,
|
|
101
|
-
onBarClick:
|
|
101
|
+
onBarClick: k,
|
|
102
102
|
selectedIndex: r
|
|
103
|
-
}) : /* @__PURE__ */ l(
|
|
103
|
+
}) : /* @__PURE__ */ l(Et, {
|
|
104
104
|
amounts: {
|
|
105
105
|
average: o?.average_amount,
|
|
106
|
-
formattedAverage:
|
|
106
|
+
formattedAverage: vt(o?.average_amount ?? 0, Q ?? St.cents)
|
|
107
107
|
},
|
|
108
|
-
color:
|
|
108
|
+
color: H[0] ?? _.palette.primary.main,
|
|
109
109
|
data: p,
|
|
110
110
|
legendPosition: "top",
|
|
111
111
|
heightOverride: 172,
|
|
@@ -115,45 +115,48 @@ var qt = (a) => a.insights_feed, be = Kt(({ beat: a, cta: V }) => {
|
|
|
115
115
|
left: 24,
|
|
116
116
|
right: 24
|
|
117
117
|
},
|
|
118
|
-
monthlyAmountLabel:
|
|
119
|
-
|
|
118
|
+
monthlyAmountLabel: tt?.(n) ?? G?.label ?? n.general.monthly_amount,
|
|
119
|
+
keyboardSelectable: f,
|
|
120
|
+
onBarClick: k,
|
|
120
121
|
selectedTabIndex: r,
|
|
121
|
-
showMonthlyAmount:
|
|
122
|
-
trendAmountLabel:
|
|
123
|
-
}) : /* @__PURE__ */ l(
|
|
124
|
-
return /* @__PURE__ */
|
|
125
|
-
baseTransactions:
|
|
122
|
+
showMonthlyAmount: et,
|
|
123
|
+
trendAmountLabel: M?.label ?? n.general.trend
|
|
124
|
+
}) : /* @__PURE__ */ l(Rt, {}) : null;
|
|
125
|
+
return /* @__PURE__ */ Ut(qt, { children: [/* @__PURE__ */ l(jt, {
|
|
126
|
+
baseTransactions: yt,
|
|
126
127
|
heading: b?.heading,
|
|
127
128
|
icon: b?.icon,
|
|
128
129
|
logo: b?.logo,
|
|
129
|
-
onSelectionChange:
|
|
130
|
+
onSelectionChange: Tt,
|
|
130
131
|
selectedIndex: r,
|
|
131
132
|
subHeadingText: b?.subHeadingText,
|
|
132
|
-
|
|
133
|
-
|
|
133
|
+
showTransactionsHeader: at,
|
|
134
|
+
tabs: f ? void 0 : s,
|
|
135
|
+
...f && { listLabel: s[r]?.label },
|
|
136
|
+
top: At,
|
|
134
137
|
...j.length > 0 && { subTabs: {
|
|
135
138
|
tabs: j,
|
|
136
|
-
selectedIndex:
|
|
137
|
-
onChange:
|
|
139
|
+
selectedIndex: T,
|
|
140
|
+
onChange: x
|
|
138
141
|
} },
|
|
139
|
-
...
|
|
140
|
-
transactionFilter:
|
|
142
|
+
...S && { tipSection: !lt && (S(ct, n, w?.text, o) ?? !1) },
|
|
143
|
+
transactionFilter: Ct,
|
|
141
144
|
onEachRowClick: (t) => {
|
|
142
|
-
|
|
145
|
+
A({ transaction_guid: t }), I(!0);
|
|
143
146
|
}
|
|
144
|
-
}), /* @__PURE__ */ l(
|
|
145
|
-
ariaLabelClose:
|
|
146
|
-
isOpen:
|
|
147
|
+
}), /* @__PURE__ */ l(Bt, {
|
|
148
|
+
ariaLabelClose: st.close_aria,
|
|
149
|
+
isOpen: it,
|
|
147
150
|
onClose: () => {
|
|
148
|
-
|
|
151
|
+
I(!1), A({ transaction_guid: void 0 }), O();
|
|
149
152
|
},
|
|
150
153
|
title: n.general.transaction_details_title,
|
|
151
|
-
children: /* @__PURE__ */ l(
|
|
154
|
+
children: /* @__PURE__ */ l(Kt, { beat: a })
|
|
152
155
|
})] });
|
|
153
156
|
});
|
|
154
157
|
export {
|
|
155
|
-
|
|
156
|
-
|
|
158
|
+
Ce as TransactionHistoryBlock,
|
|
159
|
+
$t as selectTransactionHistoryCopy
|
|
157
160
|
};
|
|
158
161
|
|
|
159
162
|
//# 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 toStoreFilter,\n} from './utils'\nimport { Drawer, useInsightsV2Store, useGlobalCopyStore } from '../../../common'\nimport { TransactionDetailsBlock } from '../TransactionDetailsBlock'\nimport { useOpenedCta } from '../useOpenedCta'\nimport type { OpenedCta } from '../util'\nimport { useRequiredCopy } from '../useRequiredCopy'\n\ninterface TransactionHistoryProp {\n beat: Beat\n /**\n * The CTA to draw, for a drawer nested inside another block's drawer (Top Merchants → Merchant\n * History). Absent: the CTA that opened the beat's drawer.\n */\n cta?: OpenedCta\n}\n\nexport const selectTransactionHistoryCopy = (copy: GlobalCopy) => copy.insights_feed\n\nexport const TransactionHistoryBlock = observer(({ beat, cta }: 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 drawerCta = useOpenedCta(beat)\n const openedCta = cta ?? drawerCta\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 barLegendLabel,\n showMonthlyAmount,\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 copy: insightsCopy,\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 legendVariant=\"body2\"\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={\n barLegendLabel?.(insightsCopy) ?? mainLegend?.label ?? insightsCopy.general.monthly_amount\n }\n onBarClick={selectBar}\n selectedTabIndex={selectedIndex}\n showMonthlyAmount={showMonthlyAmount}\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 logo={headerContent?.logo}\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,KAAA,CAAgC,MAAqB,EAAK,eAE1D,KAA0B,GAAA,CAAU,EAAE,MAAA,GAAM,KAAA,EAAA,MAAkC;AACzF,QAAM,IAAQ,GAAS,G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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 type { OpenedCta } from '../util'\nimport { useRequiredCopy } from '../useRequiredCopy'\n\ninterface TransactionHistoryProp {\n beat: Beat\n /**\n * The CTA to draw, for a drawer nested inside another block's drawer (Top Merchants → Merchant\n * History). Absent: the CTA that opened the beat's drawer.\n */\n cta?: OpenedCta\n}\n\nexport const selectTransactionHistoryCopy = (copy: GlobalCopy) => copy.insights_feed\n\nexport const TransactionHistoryBlock = observer(({ beat, cta }: 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 drawerCta = useOpenedCta(beat)\n const openedCta = cta ?? drawerCta\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 barLegendLabel,\n showMonthlyAmount,\n showMonthTabs = true,\n showTransactionsHeader = true,\n } = getDrillDownConfig(dynamicCtaVariant ?? '')\n // Only a single-bar chart can stand in for the month tabs (its bars take the keyboard).\n const barsPickMonth = !showMonthTabs && top === 'singleBar'\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 copy: insightsCopy,\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 legendVariant=\"body2\"\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={\n barLegendLabel?.(insightsCopy) ?? mainLegend?.label ?? insightsCopy.general.monthly_amount\n }\n keyboardSelectable={barsPickMonth}\n onBarClick={selectBar}\n selectedTabIndex={selectedIndex}\n showMonthlyAmount={showMonthlyAmount}\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 logo={headerContent?.logo}\n onSelectionChange={selectMonth}\n selectedIndex={selectedIndex}\n subHeadingText={headerContent?.subHeadingText}\n showTransactionsHeader={showTransactionsHeader}\n tabs={barsPickMonth ? undefined : bars}\n {...(barsPickMonth && { listLabel: bars[selectedIndex]?.label })}\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,KAAA,CAAgC,MAAqB,EAAK,eAE1D,KAA0B,GAAA,CAAU,EAAE,MAAA,GAAM,KAAA,EAAA,MAAkC;AACzF,QAAM,IAAQ,GAAS,GAEjB,EAAE,cAAA,G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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"}
|
|
@@ -83,6 +83,8 @@ export interface DrillDownVariantConfig {
|
|
|
83
83
|
boldLabel?: boolean;
|
|
84
84
|
barLegendLabel?: (copy: InsightsFeedCopy) => string | undefined;
|
|
85
85
|
showMonthlyAmount?: boolean;
|
|
86
|
+
showMonthTabs?: boolean;
|
|
87
|
+
showTransactionsHeader?: boolean;
|
|
86
88
|
title?: (copy: GlobalCopy, beat?: Beat) => string | undefined;
|
|
87
89
|
}
|
|
88
90
|
export declare const resolveUpcomingBillSlotData: SlotDataResolver;
|
|
@@ -90,6 +92,7 @@ export declare const resolveSavingsContributionsSlotData: SlotDataResolver;
|
|
|
90
92
|
export declare const resolveMerchantBudgetSlotData: SlotDataResolver;
|
|
91
93
|
export declare const resolveTopMerchantSlotData: SlotDataResolver;
|
|
92
94
|
export declare const resolveDepositSummarySlotData: SlotDataResolver;
|
|
95
|
+
export declare const resolveCategorySpendSlotData: SlotDataResolver;
|
|
93
96
|
export declare const resolveDebtToIncomeSlotData: SlotDataResolver;
|
|
94
97
|
export declare const layout: Partial<Record<DrillDownVariant, DrillDownVariantConfig>>;
|
|
95
98
|
export declare const FALLBACK: DrillDownVariantConfig;
|