@mx-cartographer/experiences 9.7.117 → 9.7.119
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 +12 -0
- package/dist/cashflow/CashflowMiniWidget.es.js +53 -19
- package/dist/cashflow/CashflowMiniWidget.es.js.map +1 -1
- package/dist/cashflow/components/CashflowWidgetContent.d.ts +1 -0
- package/dist/cashflow/components/CashflowWidgetContent.es.js +173 -137
- package/dist/cashflow/components/CashflowWidgetContent.es.js.map +1 -1
- package/dist/cashflow/components/RemainingCash.d.ts +1 -0
- package/dist/cashflow/components/RemainingCash.es.js +10 -9
- package/dist/cashflow/components/RemainingCash.es.js.map +1 -1
- package/dist/common/components/InformationTooltip.d.ts +1 -0
- package/dist/common/components/InformationTooltip.es.js +16 -16
- package/dist/common/components/InformationTooltip.es.js.map +1 -1
- package/dist/common/components/MiniWidgetContainer.d.ts +13 -0
- package/dist/common/components/MiniWidgetContainer.es.js +63 -55
- package/dist/common/components/MiniWidgetContainer.es.js.map +1 -1
- package/dist/common/components/charts/LineChart.d.ts +5 -1
- package/dist/common/components/charts/LineChart.es.js +124 -122
- package/dist/common/components/charts/LineChart.es.js.map +1 -1
- package/dist/common/components/charts/linechart/CustomLegend.es.js +53 -46
- package/dist/common/components/charts/linechart/CustomLegend.es.js.map +1 -1
- package/dist/common/components/charts/linechart/CustomMark.d.ts +2 -0
- package/dist/common/components/charts/linechart/CustomMark.es.js +72 -35
- package/dist/common/components/charts/linechart/CustomMark.es.js.map +1 -1
- package/dist/common/components/drawer/Drawer.d.ts +3 -0
- package/dist/common/components/drawer/Drawer.es.js +30 -29
- package/dist/common/components/drawer/Drawer.es.js.map +1 -1
- package/dist/common/components/drawer/Header.d.ts +3 -0
- package/dist/common/components/drawer/Header.es.js +51 -45
- package/dist/common/components/drawer/Header.es.js.map +1 -1
- package/dist/core/stores/InsightsV2Store.d.ts +10 -0
- package/dist/core/stores/InsightsV2Store.es.js +15 -7
- package/dist/core/stores/InsightsV2Store.es.js.map +1 -1
- package/dist/core/types/localization/CashflowCopy.d.ts +1 -0
- package/dist/core/types/localization/TrendsCopy.d.ts +1 -0
- package/dist/insights-v2/actionBlocks/ActionBlockLayer.es.js +44 -33
- package/dist/insights-v2/actionBlocks/ActionBlockLayer.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.d.ts +1 -9
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.es.js +96 -83
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/CreateBudgetDialog.d.ts +5 -0
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/CreateBudgetDialog.es.js +62 -0
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/CreateBudgetDialog.es.js.map +1 -0
- package/dist/insights-v2/actionBlocks/AmountInputModalBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetDetailsBlock.es.js +212 -145
- package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetDetailsBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetSummary.d.ts +3 -1
- package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetSummary.es.js +36 -36
- package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetSummary.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/layout.d.ts +32 -2
- package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/layout.es.js +68 -22
- package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/useBudgetDetailsPrepare.d.ts +3 -0
- package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/useBudgetDetailsPrepare.es.js +34 -0
- package/dist/insights-v2/actionBlocks/BudgetDetailsBlock/useBudgetDetailsPrepare.es.js.map +1 -0
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js +61 -61
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.d.ts +1 -0
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js +42 -40
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistoryPrepare.es.js +3 -3
- package/dist/insights-v2/actionBlocks/util.d.ts +2 -11
- package/dist/insights-v2/actionBlocks/util.es.js +16 -6
- package/dist/insights-v2/actionBlocks/util.es.js.map +1 -1
- package/dist/insights-v2/analytics/analyticsEventsConfig.d.ts +16 -0
- package/dist/insights-v2/analytics/analyticsEventsConfig.es.js +19 -2
- package/dist/insights-v2/analytics/analyticsEventsConfig.es.js.map +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/BarchartBlock.es.js +8 -8
- package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/BarchartBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/utils.d.ts +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/utils.es.js +28 -27
- package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/utils.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/AccountBlock.es.js +4 -4
- package/dist/insights-v2/blocks/ComponentBlocks/TransactionBlock/TransactionBlock.es.js +4 -4
- package/dist/insights-v2/blocks/ImageBlocks/SVGImageBlock/SVGImageBlock.es.js +4 -4
- package/dist/insights-v2/components/BaseLayout.es.js +137 -118
- package/dist/insights-v2/components/BaseLayout.es.js.map +1 -1
- package/dist/insights-v2/mappings/blocks.d.ts +1 -0
- package/dist/insights-v2/mappings/blocks.es.js +131 -121
- package/dist/insights-v2/mappings/blocks.es.js.map +1 -1
- package/dist/trends/TrendsMiniWidget.es.js +29 -22
- package/dist/trends/TrendsMiniWidget.es.js.map +1 -1
- package/dist/trends/components/SpendingChart.es.js +53 -17
- package/dist/trends/components/SpendingChart.es.js.map +1 -1
- package/dist/trends/utils/SpendingData.d.ts +2 -0
- package/dist/trends/utils/SpendingData.es.js +70 -43
- package/dist/trends/utils/SpendingData.es.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BudgetSummary.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetSummary.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\n\nimport Alert from '@mui/material/Alert'\nimport Box from '@mui/material/Box'\nimport Stack from '@mui/material/Stack'\n\nimport { Text } from '@mxenabled/mxui'\n\nimport { buildDynamicCopy, buildPluralCopy } from '../../../core/utils/Localization'\nimport { formatCurrency } from '../../../core/utils/NumberFormatting'\nimport type { BudgetsCopy } from '../../../core/types/localization'\nimport type { BudgetDetailsCopy } from '../../../core/types/localization/InsightsFeedCopy'\nimport StatusIndicator from '../../components/ComponentBlocks/StatusIndicator'\n\nimport { calculateBudgetPercent, calculateBudgetTier, tierColor } from './layout'\n\ninterface BudgetSummaryProps {\n budgetsCopy: BudgetsCopy\n copy: BudgetDetailsCopy\n daysLeft?: number\n icon: ReactNode\n limit: number\n spent: number\n}\n\nexport const BudgetSummary = ({\n budgetsCopy,\n copy,\n daysLeft,\n icon,\n limit,\n spent,\n}: BudgetSummaryProps) => {\n const percent = calculateBudgetPercent(spent, limit)\n const tier = calculateBudgetTier(percent)\n const color = tierColor(tier)\n const periodLine =\n daysLeft === undefined ? (\n <Alert severity=\"info\">{copy.previous_month_notice}</Alert>\n ) : (\n <Text color=\"text.secondary\" variant=\"body2\">\n {\n buildPluralCopy(\n copy.days_left_until_end_of_month_one,\n copy.days_left_until_end_of_month,\n daysLeft,\n String(daysLeft),\n ) as string\n }\n </Text>\n )\n\n if (limit <= 0) {\n return (\n <Stack sx={{ gap: 16 }}>\n <Stack sx={{ alignItems: 'center', flexDirection: 'row', gap: 12 }}>\n <Box>{icon}</Box>\n <Stack>\n <Text color=\"text.secondary\" variant=\"body2\">\n {budgetsCopy.spent_label}\n </Text>\n <Text bold={true} component=\"p\" variant=\"h2\">\n {formatCurrency(spent, '0,0.00')}\n </Text>\n </Stack>\n </Stack>\n {periodLine}\n </Stack>\n )\n }\n\n return (\n <Stack sx={{ gap: 16 }}>\n <Box\n aria-label={\n buildDynamicCopy(\n copy.total_out_of_limit_aria,\n formatCurrency(spent, '0,0.00'),\n formatCurrency(limit, '0,0.00'),\n ) as string\n }\n data-tier={tier ?? 'none'}\n role=\"group\"\n >\n <StatusIndicator\n amount={\n <Stack sx={{ alignItems: 'baseline', flexDirection: 'row', gap: 4 }}>\n <Text bold={true} component=\"p\" variant=\"h2\">\n {formatCurrency(spent, '0,0.00')}\n </Text>\n <Text color=\"text.secondary\" variant=\"body2\">\n / {formatCurrency(limit, '0,0.00')}\n </Text>\n </Stack>\n }\n borderRadius=\"8px\"\n completeColor={color}\n icon={icon}\n label={\n <Stack sx={{ alignItems: 'center', flexDirection: 'row', gap: 6 }}>\n <Box sx={{ bgcolor: color, borderRadius: '50%', height: 8, width: 8 }} />\n <Text color=\"text.secondary\" variant=\"body2\">\n {budgetsCopy.spent_label}\n </Text>\n </Stack>\n }\n leftLabel={buildDynamicCopy(budgetsCopy.percent_spent, String(percent)) as string}\n percentComplete={Math.min(100, percent)}\n rightLabel={\n
|
|
1
|
+
{"version":3,"file":"BudgetSummary.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/BudgetDetailsBlock/BudgetSummary.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\n\nimport Alert from '@mui/material/Alert'\nimport Box from '@mui/material/Box'\nimport Stack from '@mui/material/Stack'\n\nimport { Text } from '@mxenabled/mxui'\n\nimport { buildDynamicCopy, buildPluralCopy } from '../../../core/utils/Localization'\nimport { formatCurrency } from '../../../core/utils/NumberFormatting'\nimport type { BudgetsCopy } from '../../../core/types/localization'\nimport type { BudgetDetailsCopy } from '../../../core/types/localization/InsightsFeedCopy'\nimport StatusIndicator from '../../components/ComponentBlocks/StatusIndicator'\n\nimport { calculateBudgetPercent, calculateBudgetTier, tierColor } from './layout'\n\ninterface BudgetSummaryProps {\n budgetsCopy: BudgetsCopy\n copy: BudgetDetailsCopy\n daysLeft?: number\n icon: ReactNode\n limit: number\n /** The days-left / previous-month line under the bar (off for Figma's Budget Details insights). */\n showPeriodLine?: boolean\n spent: number\n}\n\nexport const BudgetSummary = ({\n budgetsCopy,\n copy,\n daysLeft,\n icon,\n limit,\n showPeriodLine = true,\n spent,\n}: BudgetSummaryProps) => {\n const percent = calculateBudgetPercent(spent, limit)\n const tier = calculateBudgetTier(percent)\n const color = tierColor(tier)\n const periodLine =\n daysLeft === undefined ? (\n <Alert severity=\"info\">{copy.previous_month_notice}</Alert>\n ) : (\n <Text color=\"text.secondary\" variant=\"body2\">\n {\n buildPluralCopy(\n copy.days_left_until_end_of_month_one,\n copy.days_left_until_end_of_month,\n daysLeft,\n String(daysLeft),\n ) as string\n }\n </Text>\n )\n\n if (limit <= 0) {\n return (\n <Stack sx={{ gap: 16 }}>\n <Stack sx={{ alignItems: 'center', flexDirection: 'row', gap: 12 }}>\n <Box>{icon}</Box>\n <Stack>\n <Text color=\"text.secondary\" variant=\"body2\">\n {budgetsCopy.spent_label}\n </Text>\n <Text bold={true} component=\"p\" variant=\"h2\">\n {formatCurrency(spent, '0,0.00')}\n </Text>\n </Stack>\n </Stack>\n {showPeriodLine && periodLine}\n </Stack>\n )\n }\n\n return (\n <Stack sx={{ gap: 16 }}>\n <Box\n aria-label={\n buildDynamicCopy(\n copy.total_out_of_limit_aria,\n formatCurrency(spent, '0,0.00'),\n formatCurrency(limit, '0,0.00'),\n ) as string\n }\n data-tier={tier ?? 'none'}\n role=\"group\"\n >\n <StatusIndicator\n amount={\n <Stack sx={{ alignItems: 'baseline', flexDirection: 'row', gap: 4 }}>\n <Text bold={true} component=\"p\" variant=\"h2\">\n {formatCurrency(spent, '0,0.00')}\n </Text>\n <Text color=\"text.secondary\" variant=\"body2\">\n / {formatCurrency(limit, '0,0.00')}\n </Text>\n </Stack>\n }\n borderRadius=\"8px\"\n completeColor={color}\n icon={icon}\n label={\n <Stack sx={{ alignItems: 'center', flexDirection: 'row', gap: 6 }}>\n <Box sx={{ bgcolor: color, borderRadius: '50%', height: 8, width: 8 }} />\n <Text color=\"text.secondary\" variant=\"body2\">\n {budgetsCopy.spent_label}\n </Text>\n </Stack>\n }\n leftLabel={buildDynamicCopy(budgetsCopy.percent_spent, String(percent)) as string}\n percentComplete={Math.min(100, percent)}\n rightLabel={\n buildDynamicCopy(\n // Figma's \"$amount Left\"; $0.00 once over, as the Budgets drawer shows it.\n budgetsCopy.balance_left,\n formatCurrency(Math.max(0, limit - spent), '0,0.00'),\n ) as string\n }\n sx={{ p: 0 }}\n />\n </Box>\n {showPeriodLine && periodLine}\n </Stack>\n )\n}\n"],"mappings":";;;;;;;;;AA2BA,IAAa,IAAA,CAAiB,EAC5B,aAAA,GACA,MAAA,GACA,UAAA,GACA,MAAA,GACA,OAAA,GACA,gBAAA,IAAiB,IACjB,OAAA,EAAA,MACwB;AACxB,QAAM,IAAU,EAAuB,GAAO,CAAK,GAC7C,IAAO,EAAoB,CAAO,GAClC,IAAQ,EAAU,CAAI,GACtB,IACJ,MAAa,SACX,gBAAA,EAAC,GAAD;AAAA,IAAO,UAAS;AAAA,IAAQ,UAAA,EAAK;AAAA,EAA6B,CAAA,IAE1D,gBAAA,EAAC,GAAD;AAAA,IAAM,OAAM;AAAA,IAAiB,SAAQ;AAAA,IAEjC,UAAA,EACE,EAAK,kCACL,EAAK,8BACL,GACA,OAAO,CAAQ,CACjB;AAAA,EAEE,CAAA;AAGV,SAAI,KAAS,IAET,gBAAA,EAA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,CAC7B;AAAA,UACD,CAAA,CAAA;AAAA;QAET,cAAa;AAAA,QACb,eAAe;AAAA,QACT,MAAA;AAAA,QACN,OACE,gBAAA,EAAC,GAAD;AAAA,UAAO,IAAI;AAAA,YAAE,YAAY;AAAA,YAAU,eAAe;AAAA,YAAO,KAAK;AAAA,UAAE;AAAA,UAAhE,UAAA,CACE,gBAAA,EAAC,GAAD,EAAK,IAAI;AAAA,YAAE,SAAS;AAAA,YAAO,cAAc;AAAA,YAAO,QAAQ;AAAA,YAAG,OAAO;AAAA,UAAE,EAAI,CAAA,GACxE,gBAAA,EAAC,GAAD;AAAA,YAAM,OAAM;AAAA,YAAiB,SAAQ;AAAA,YAClC,UAAA,EAAY;AAAA,UACT,CAAA,CACD;AAAA;QAET,WAAW,EAAiB,EAAY,eAAe,OAAO,CAAO,CAAC;AAAA,QACtE,iBAAiB,KAAK,IAAI,KAAK,CAAO;AAAA,QACtC,YACE,EAEE,EAAY,cACZ,EAAe,KAAK,IAAI,GAAG,IAAQ,CAAK,GAAG,QAAQ,CACrD;AAAA,QAEF,IAAI,EAAE,GAAG,EAAE;AAAA,MACZ,CAAA;AAAA,IACE,CAAA,GACJ,KAAkB,CACd;AAAA;AAEX"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { Beat } from '../../../core';
|
|
1
|
+
import { Beat, GlobalCopy } from '../../../core';
|
|
2
|
+
import { InsightsV2Store } from '../../../core/stores/InsightsV2Store';
|
|
3
|
+
import { TransactionFilter } from '../../../core/stores/TransactionStore';
|
|
2
4
|
export type BudgetTier = 'LOW' | 'MEDIUM' | 'HIGH' | 'OFF_TRACK';
|
|
3
5
|
export declare const BUDGET_TIER_COLORS: Record<BudgetTier, string>;
|
|
4
6
|
export declare const DEFAULT_TIER_COLOR = "success.main";
|
|
@@ -12,4 +14,32 @@ export interface BudgetFacts {
|
|
|
12
14
|
budgeted?: number;
|
|
13
15
|
}
|
|
14
16
|
export declare const resolveBudgetFacts: (beat: Beat) => BudgetFacts;
|
|
15
|
-
export declare const
|
|
17
|
+
export declare const resolveBudgetSubject: (variant: string | null | undefined, beat: Beat, copy: GlobalCopy) => string | undefined;
|
|
18
|
+
type ActiveAt = Beat['active_at'] | number | null | undefined;
|
|
19
|
+
/** A beat's `active_at` (epoch seconds or ISO) as a date; undefined when absent or invalid. */
|
|
20
|
+
export declare const activeAtDate: (raw: ActiveAt) => Date | undefined;
|
|
21
|
+
/** The beat's own `active_at`: on the beat, else on its envelope. */
|
|
22
|
+
export declare const beatActiveAt: (beat: Beat) => ActiveAt;
|
|
23
|
+
/** The `active_at` the card recorded on render; a sampled beat is re-read without it after a CTA. */
|
|
24
|
+
export declare const recordedActiveAtOf: (store: Pick<InsightsV2Store, "beatContext">, beat: Beat) => ActiveAt;
|
|
25
|
+
/** The budget month's anchor: the recorded `active_at`, else the beat's, else now. */
|
|
26
|
+
export declare const budgetMonthOf: (beat: Beat, recordedActiveAt?: ActiveAt, now?: Date) => Date;
|
|
27
|
+
export declare const daysLeftInBudgetMonth: (beat: Beat, now?: Date, recordedActiveAt?: ActiveAt) => number | undefined;
|
|
28
|
+
/** The month a budget drawer shows (see budgetMonthOf). */
|
|
29
|
+
export declare const budgetMonthRange: (beat: Beat, recordedActiveAt?: ActiveAt) => {
|
|
30
|
+
start: Date;
|
|
31
|
+
end: Date;
|
|
32
|
+
};
|
|
33
|
+
/** The budget month and category (own or top-level) or merchant; none without either, so no rows. */
|
|
34
|
+
export declare const budgetTransactionFilter: (facts: BudgetFacts, dateRange: {
|
|
35
|
+
start: Date;
|
|
36
|
+
end: Date;
|
|
37
|
+
}) => TransactionFilter | undefined;
|
|
38
|
+
export interface BudgetDetailsLayout {
|
|
39
|
+
/** The "N days until the end of the month" / previous-month notice under the summary. */
|
|
40
|
+
showPeriodLine: boolean;
|
|
41
|
+
}
|
|
42
|
+
export declare const resolveBudgetDetailsLayout: (variant: string | null | undefined) => BudgetDetailsLayout;
|
|
43
|
+
/** A budget amount the dialogs accept: a finite number above zero. */
|
|
44
|
+
export declare const isPositiveAmount: (value: string) => boolean;
|
|
45
|
+
export {};
|
|
@@ -1,37 +1,83 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { BEAT_ACTIVE_AT_KEY as m } from "../../../core/stores/InsightsV2Store.es.js";
|
|
2
|
+
import { resolveVariantConfig as g } from "../../blocks/resolveVariantConfig.es.js";
|
|
3
|
+
import { endOfMonth as o } from "date-fns/endOfMonth";
|
|
4
|
+
import { startOfMonth as c } from "date-fns/startOfMonth";
|
|
5
|
+
import { differenceInCalendarDays as v } from "date-fns/differenceInCalendarDays";
|
|
6
|
+
var l = {
|
|
5
7
|
LOW: "success.light",
|
|
6
8
|
MEDIUM: "warning.light",
|
|
7
9
|
HIGH: "warning.main",
|
|
8
10
|
OFF_TRACK: "error.main"
|
|
9
|
-
},
|
|
11
|
+
}, T = "success.main", R = (t, e) => Math.ceil((e ? t / e : 0) * 100), b = (t) => {
|
|
10
12
|
if (t > 100) return "OFF_TRACK";
|
|
11
13
|
if (t >= 75) return "HIGH";
|
|
12
14
|
if (t >= 50) return "MEDIUM";
|
|
13
15
|
if (t >= 25) return "LOW";
|
|
14
|
-
},
|
|
15
|
-
const
|
|
16
|
+
}, N = (t) => t ? l[t] : T, n = (t) => typeof t == "number" && Number.isFinite(t) ? t : void 0, d = (t) => typeof t == "string" && t ? t : void 0, E = (t) => {
|
|
17
|
+
const e = t.insights_payload, r = e?.instance_slot?.data ?? e?.instance_slot_data ?? {};
|
|
16
18
|
return {
|
|
17
|
-
categoryGuid:
|
|
18
|
-
merchantGuid:
|
|
19
|
-
spent: n(
|
|
20
|
-
budgeted: n(
|
|
19
|
+
categoryGuid: d(r.category_guid) ?? e?.primary_category_guid ?? t.primary_category_guid ?? void 0,
|
|
20
|
+
merchantGuid: d(r.merchant_guid) ?? e?.primary_merchant_guid ?? t.primary_merchant_guid ?? void 0,
|
|
21
|
+
spent: n(r.spent_amount),
|
|
22
|
+
budgeted: n(r.budgeted_amount)
|
|
21
23
|
};
|
|
22
|
-
},
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
}, i = (t, e) => {
|
|
25
|
+
const { categoryGuid: r } = E(t);
|
|
26
|
+
return (r ? e.categories?.default_categories?.[r] : void 0)?.replace(/&/g, "&");
|
|
27
|
+
}, a = {
|
|
28
|
+
CATEGORY_SPEND: "category_spend",
|
|
29
|
+
CATEGORY_BUDGET: "category_budget",
|
|
30
|
+
MERCHANT_BUDGET: "merchant_budget"
|
|
31
|
+
}, f = {
|
|
32
|
+
default: i,
|
|
33
|
+
[a.CATEGORY_SPEND]: i,
|
|
34
|
+
[a.CATEGORY_BUDGET]: i
|
|
35
|
+
}, L = (t, e, r) => g(f, t, "default", "BudgetDetailsBlock")(e, r), u = (t) => {
|
|
36
|
+
if (t == null || t === "") return;
|
|
37
|
+
const e = new Date(typeof t == "number" ? t * 1e3 : t);
|
|
38
|
+
return Number.isNaN(e.getTime()) ? void 0 : e;
|
|
39
|
+
}, y = (t) => t.active_at ?? t.insights_payload?.active_at, M = (t, e) => t.beatContext[e.guid]?.[m], s = (t, e, r = /* @__PURE__ */ new Date()) => u(e) ?? u(y(t)) ?? r, U = (t, e = /* @__PURE__ */ new Date(), r) => {
|
|
40
|
+
const _ = s(t, r, e);
|
|
41
|
+
if (!(o(_) < c(e)))
|
|
42
|
+
return v(o(e), e) + 1;
|
|
43
|
+
}, I = (t, e) => {
|
|
44
|
+
const r = s(t, e);
|
|
45
|
+
return {
|
|
46
|
+
start: c(r),
|
|
47
|
+
end: o(r)
|
|
48
|
+
};
|
|
49
|
+
}, A = (t) => (e) => e.category_guid === t || e.top_level_category_guid === t, h = (t) => (e) => e.merchant_guid === t, F = (t, e) => {
|
|
50
|
+
const r = t.categoryGuid ? A(t.categoryGuid) : t.merchantGuid ? h(t.merchantGuid) : void 0;
|
|
51
|
+
return r && {
|
|
52
|
+
custom: r,
|
|
53
|
+
dateRange: e
|
|
54
|
+
};
|
|
55
|
+
}, D = {
|
|
56
|
+
default: { showPeriodLine: !0 },
|
|
57
|
+
[a.CATEGORY_SPEND]: { showPeriodLine: !1 },
|
|
58
|
+
[a.CATEGORY_BUDGET]: { showPeriodLine: !1 },
|
|
59
|
+
[a.MERCHANT_BUDGET]: { showPeriodLine: !1 }
|
|
60
|
+
}, P = (t) => g(D, t, "default", "BudgetDetailsBlock"), S = (t) => {
|
|
61
|
+
const e = Number(t);
|
|
62
|
+
return t.trim() !== "" && Number.isFinite(e) && e > 0;
|
|
26
63
|
};
|
|
27
64
|
export {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
65
|
+
l as BUDGET_TIER_COLORS,
|
|
66
|
+
T as DEFAULT_TIER_COLOR,
|
|
67
|
+
u as activeAtDate,
|
|
68
|
+
y as beatActiveAt,
|
|
69
|
+
s as budgetMonthOf,
|
|
70
|
+
I as budgetMonthRange,
|
|
71
|
+
F as budgetTransactionFilter,
|
|
72
|
+
R as calculateBudgetPercent,
|
|
73
|
+
b as calculateBudgetTier,
|
|
74
|
+
U as daysLeftInBudgetMonth,
|
|
75
|
+
S as isPositiveAmount,
|
|
76
|
+
M as recordedActiveAtOf,
|
|
77
|
+
P as resolveBudgetDetailsLayout,
|
|
78
|
+
E as resolveBudgetFacts,
|
|
79
|
+
L as resolveBudgetSubject,
|
|
80
|
+
N as tierColor
|
|
35
81
|
};
|
|
36
82
|
|
|
37
83
|
//# sourceMappingURL=layout.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/BudgetDetailsBlock/layout.ts"],"sourcesContent":["import { differenceInCalendarDays } from 'date-fns/differenceInCalendarDays'\nimport { endOfMonth } from 'date-fns/endOfMonth'\nimport { startOfMonth } from 'date-fns/startOfMonth'\n\nimport type { Beat } from '../../../core'\n\nexport type BudgetTier = 'LOW' | 'MEDIUM' | 'HIGH' | 'OFF_TRACK'\n\nexport const BUDGET_TIER_COLORS: Record<BudgetTier, string> = {\n LOW: 'success.light',\n MEDIUM: 'warning.light',\n HIGH: 'warning.main',\n OFF_TRACK: 'error.main',\n}\n\nexport const DEFAULT_TIER_COLOR = 'success.main'\n\nexport const calculateBudgetPercent = (total: number, limit: number) =>\n Math.ceil((limit ? total / limit : 0) * 100)\n\nexport const calculateBudgetTier = (percent: number): BudgetTier | undefined => {\n if (percent > 100) return 'OFF_TRACK'\n if (percent >= 75) return 'HIGH'\n if (percent >= 50) return 'MEDIUM'\n if (percent >= 25) return 'LOW'\n\n return undefined\n}\n\nexport const tierColor = (tier: BudgetTier | undefined) =>\n tier ? BUDGET_TIER_COLORS[tier] : DEFAULT_TIER_COLOR\n\nexport interface BudgetFacts {\n categoryGuid?: string\n merchantGuid?: string\n spent?: number\n budgeted?: number\n}\n\nconst finiteNumber = (value: unknown) =>\n typeof value === 'number' && Number.isFinite(value) ? value : undefined\n\nconst nonEmptyString = (value: unknown) => (typeof value === 'string' && value ? value : undefined)\n\nexport const resolveBudgetFacts = (beat: Beat): BudgetFacts => {\n const payload = beat.insights_payload\n const data = (payload?.instance_slot?.data ?? payload?.instance_slot_data ?? {}) as Record<\n string,\n unknown\n >\n\n return {\n categoryGuid:\n nonEmptyString(data.category_guid) ??\n payload?.primary_category_guid ??\n beat.primary_category_guid ??\n undefined,\n merchantGuid:\n nonEmptyString(data.merchant_guid) ??\n payload?.primary_merchant_guid ??\n beat.primary_merchant_guid ??\n undefined,\n spent: finiteNumber(data.spent_amount),\n budgeted: finiteNumber(data.budgeted_amount),\n }\n}\n\
|
|
1
|
+
{"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/BudgetDetailsBlock/layout.ts"],"sourcesContent":["import { differenceInCalendarDays } from 'date-fns/differenceInCalendarDays'\nimport { endOfMonth } from 'date-fns/endOfMonth'\nimport { startOfMonth } from 'date-fns/startOfMonth'\n\nimport type { Beat, GlobalCopy, Transaction } from '../../../core'\nimport { BEAT_ACTIVE_AT_KEY, type InsightsV2Store } from '../../../core/stores/InsightsV2Store'\nimport type { TransactionFilter } from '../../../core/stores/TransactionStore'\nimport { resolveVariantConfig } from '../../blocks/resolveVariantConfig'\n\nexport type BudgetTier = 'LOW' | 'MEDIUM' | 'HIGH' | 'OFF_TRACK'\n\nexport const BUDGET_TIER_COLORS: Record<BudgetTier, string> = {\n LOW: 'success.light',\n MEDIUM: 'warning.light',\n HIGH: 'warning.main',\n OFF_TRACK: 'error.main',\n}\n\nexport const DEFAULT_TIER_COLOR = 'success.main'\n\nexport const calculateBudgetPercent = (total: number, limit: number) =>\n Math.ceil((limit ? total / limit : 0) * 100)\n\nexport const calculateBudgetTier = (percent: number): BudgetTier | undefined => {\n if (percent > 100) return 'OFF_TRACK'\n if (percent >= 75) return 'HIGH'\n if (percent >= 50) return 'MEDIUM'\n if (percent >= 25) return 'LOW'\n\n return undefined\n}\n\nexport const tierColor = (tier: BudgetTier | undefined) =>\n tier ? BUDGET_TIER_COLORS[tier] : DEFAULT_TIER_COLOR\n\nexport interface BudgetFacts {\n categoryGuid?: string\n merchantGuid?: string\n spent?: number\n budgeted?: number\n}\n\nconst finiteNumber = (value: unknown) =>\n typeof value === 'number' && Number.isFinite(value) ? value : undefined\n\nconst nonEmptyString = (value: unknown) => (typeof value === 'string' && value ? value : undefined)\n\nexport const resolveBudgetFacts = (beat: Beat): BudgetFacts => {\n const payload = beat.insights_payload\n const data = (payload?.instance_slot?.data ?? payload?.instance_slot_data ?? {}) as Record<\n string,\n unknown\n >\n\n return {\n categoryGuid:\n nonEmptyString(data.category_guid) ??\n payload?.primary_category_guid ??\n beat.primary_category_guid ??\n undefined,\n merchantGuid:\n nonEmptyString(data.merchant_guid) ??\n payload?.primary_merchant_guid ??\n beat.primary_merchant_guid ??\n undefined,\n spent: finiteNumber(data.spent_amount),\n budgeted: finiteNumber(data.budgeted_amount),\n }\n}\n\ntype BudgetSubject = (beat: Beat, copy: GlobalCopy) => string | undefined\n\nconst categoryName: BudgetSubject = (beat, copy) => {\n const { categoryGuid } = resolveBudgetFacts(beat)\n const name = categoryGuid ? copy.categories?.default_categories?.[categoryGuid] : undefined\n\n return name?.replace(/&/g, '&')\n}\n\n/** The CTA variants `budget_details_block` serves (ditto names one on each beat's CTA). */\nconst BUDGET_DETAILS_VARIANTS = {\n CATEGORY_SPEND: 'category_spend',\n CATEGORY_BUDGET: 'category_budget',\n MERCHANT_BUDGET: 'merchant_budget',\n} as const\n\n// The drawer's \"{subject} Budget\" title, keyed by the CTA variant; the card's subtitle never names it.\nconst BUDGET_SUBJECT: Record<string, BudgetSubject> = {\n default: categoryName,\n [BUDGET_DETAILS_VARIANTS.CATEGORY_SPEND]: categoryName,\n [BUDGET_DETAILS_VARIANTS.CATEGORY_BUDGET]: categoryName,\n // merchant_budget: the merchant name, when Merchant Budget moves to Insights 2.0.\n}\n\nexport const resolveBudgetSubject = (\n variant: string | null | undefined,\n beat: Beat,\n copy: GlobalCopy,\n): string | undefined =>\n resolveVariantConfig(BUDGET_SUBJECT, variant, 'default', 'BudgetDetailsBlock')(beat, copy)\n\ntype ActiveAt = Beat['active_at'] | number | null | undefined\n\n/** A beat's `active_at` (epoch seconds or ISO) as a date; undefined when absent or invalid. */\nexport const activeAtDate = (raw: ActiveAt): Date | undefined => {\n if (raw == null || raw === '') return undefined\n const at = new Date(typeof raw === 'number' ? raw * 1000 : raw)\n\n return Number.isNaN(at.getTime()) ? undefined : at\n}\n\n/** The beat's own `active_at`: on the beat, else on its envelope. */\nexport const beatActiveAt = (beat: Beat): ActiveAt =>\n beat.active_at ?? beat.insights_payload?.active_at\n\n/** The `active_at` the card recorded on render; a sampled beat is re-read without it after a CTA. */\nexport const recordedActiveAtOf = (\n store: Pick<InsightsV2Store, 'beatContext'>,\n beat: Beat,\n): ActiveAt => store.beatContext[beat.guid]?.[BEAT_ACTIVE_AT_KEY] as ActiveAt\n\n/** The budget month's anchor: the recorded `active_at`, else the beat's, else now. */\nexport const budgetMonthOf = (beat: Beat, recordedActiveAt?: ActiveAt, now = new Date()) =>\n activeAtDate(recordedActiveAt) ?? activeAtDate(beatActiveAt(beat)) ?? now\n\nexport const daysLeftInBudgetMonth = (\n beat: Beat,\n now = new Date(),\n recordedActiveAt?: ActiveAt,\n) => {\n const activeAt = budgetMonthOf(beat, recordedActiveAt, now)\n if (endOfMonth(activeAt) < startOfMonth(now)) return undefined\n\n return differenceInCalendarDays(endOfMonth(now), now) + 1\n}\n\n/** The month a budget drawer shows (see budgetMonthOf). */\nexport const budgetMonthRange = (beat: Beat, recordedActiveAt?: ActiveAt) => {\n const month = budgetMonthOf(beat, recordedActiveAt)\n\n return { start: startOfMonth(month), end: endOfMonth(month) }\n}\n\nconst inCategory = (categoryGuid: string) => (transaction: Transaction) =>\n transaction.category_guid === categoryGuid || transaction.top_level_category_guid === categoryGuid\n\nconst atMerchant = (merchantGuid: string) => (transaction: Transaction) =>\n transaction.merchant_guid === merchantGuid\n\n/** The budget month and category (own or top-level) or merchant; none without either, so no rows. */\nexport const budgetTransactionFilter = (\n facts: BudgetFacts,\n dateRange: { start: Date; end: Date },\n): TransactionFilter | undefined => {\n const custom = facts.categoryGuid\n ? inCategory(facts.categoryGuid)\n : facts.merchantGuid\n ? atMerchant(facts.merchantGuid)\n : undefined\n\n return custom && { custom, dateRange }\n}\n\nexport interface BudgetDetailsLayout {\n /** The \"N days until the end of the month\" / previous-month notice under the summary. */\n showPeriodLine: boolean\n}\n\n// Figma's Budget Details for these three insights has no period line; any other caller keeps it.\nconst LAYOUT: Record<string, BudgetDetailsLayout> = {\n default: { showPeriodLine: true },\n [BUDGET_DETAILS_VARIANTS.CATEGORY_SPEND]: { showPeriodLine: false },\n [BUDGET_DETAILS_VARIANTS.CATEGORY_BUDGET]: { showPeriodLine: false },\n [BUDGET_DETAILS_VARIANTS.MERCHANT_BUDGET]: { showPeriodLine: false },\n}\n\nexport const resolveBudgetDetailsLayout = (variant: string | null | undefined) =>\n resolveVariantConfig(LAYOUT, variant, 'default', 'BudgetDetailsBlock')\n\n/** A budget amount the dialogs accept: a finite number above zero. */\nexport const isPositiveAmount = (value: string): boolean => {\n const amount = Number(value)\n return value.trim() !== '' && Number.isFinite(amount) && amount > 0\n}\n"],"mappings":";;;;;AAWA,IAAa,IAAiD;AAAA,EAC5D,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,WAAW;AACb,GAEa,IAAqB,gBAErB,IAAA,CAA0B,GAAe,MACpD,KAAK,MAAM,IAAQ,IAAQ,IAAQ,KAAK,GAAG,GAEhC,IAAA,CAAuB,MAA4C;AAC9E,MAAI,IAAU,IAAK,QAAO;AAC1B,MAAI,KAAW,GAAI,QAAO;AAC1B,MAAI,KAAW,GAAI,QAAO;AAC1B,MAAI,KAAW,GAAI,QAAO;AAG5B,GAEa,IAAA,CAAa,MACxB,IAAO,EAAmB,CAAA,IAAQ,GAS9B,IAAA,CAAgB,MACpB,OAAO,KAAU,YAAY,OAAO,SAAS,CAAK,IAAI,IAAQ,QAE1D,IAAA,CAAkB,MAAoB,OAAO,KAAU,YAAY,IAAQ,IAAQ,QAE5E,IAAA,CAAsB,MAA4B;AAC7D,QAAM,IAAU,EAAK,kBACf,IAAQ,GAAS,eAAe,QAAQ,GAAS,sBAAsB,CAAC;AAK9E,SAAO;AAAA,IACL,cACE,EAAe,EAAK,aAAa,KACjC,GAAS,yBACT,EAAK,yBACL;AAAA,IACF,cACE,EAAe,EAAK,aAAa,KACjC,GAAS,yBACT,EAAK,yBACL;AAAA,IACF,OAAO,EAAa,EAAK,YAAY;AAAA,IACrC,UAAU,EAAa,EAAK,eAAe;AAAA,EAC7C;AACF,GAIM,IAAA,CAA+B,GAAM,MAAS;AAClD,QAAM,EAAE,cAAA,EAAA,IAAiB,EAAmB,CAAI;AAGhD,UAFa,IAAe,EAAK,YAAY,qBAAqB,CAAA,IAAgB,SAErE,QAAQ,UAAU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ACA,MACkC;AAClC,QAAM,IAAS,EAAM,eACjB,EAAW,EAAM,YAAY,IAC7B,EAAM,eACJ,EAAW,EAAM,YAAY,IAC7B;AAEN,SAAO,KAAU;AAAA,IAAE,QAAA;AAAA,IAAQ,WAAA;AAAA,EAAU;AACvC,GAQM,IAA8C;AAAA,EAClD,SAAS,EAAE,gBAAgB,GAAK;AAAA,EAC/B,CAAA,EAAwB,cAAA,GAAiB,EAAE,gBAAgB,GAAM;AAAA,EACjE,CAAA,EAAwB,eAAA,GAAkB,EAAE,gBAAgB,GAAM;AAAA,EAClE,CAAA,EAAwB,eAAA,GAAkB,EAAE,gBAAgB,GAAM;AACrE,GAEa,IAAA,CAA8B,MACzC,EAAqB,GAAQ,GAAS,WAAW,oBAAoB,GAG1D,IAAA,CAAoB,MAA2B;AAC1D,QAAM,IAAS,OAAO,CAAK;AAC3B,SAAO,EAAM,KAAK,MAAM,MAAM,OAAO,SAAS,CAAM,KAAK,IAAS;AACpE"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useAccountStore as m, useBudgetsStore as p, useCategoryStore as S, useInsightsV2Store as v, useTransactionStore as A } from "../../../common/context/hooks.es.js";
|
|
2
|
+
import { budgetMonthRange as h, budgetTransactionFilter as y, recordedActiveAtOf as B, resolveBudgetFacts as D } from "./layout.es.js";
|
|
3
|
+
import { toStoreFilter as F } from "../TransactionHistoryBlock/utils.es.js";
|
|
4
|
+
import { useEffect as u, useRef as R } from "react";
|
|
5
|
+
import { reaction as T } from "mobx";
|
|
6
|
+
var M = ({ beat: e }) => {
|
|
7
|
+
const d = m(), r = p(), a = S(), l = v(), t = A(), s = R(null);
|
|
8
|
+
s.current === null && (s.current = { ...t.filter }), u(() => (r.isDataLoaded || r.loadBudgets().catch(() => {
|
|
9
|
+
}), a.categoriesLoaded || a.loadCategories(), t.isTransactionDataLoaded || t.loadMissingTransactionData(), () => t.setFilter(s.current ?? {})), [
|
|
10
|
+
r,
|
|
11
|
+
a,
|
|
12
|
+
t
|
|
13
|
+
]);
|
|
14
|
+
const i = D(e), n = B(l, e), f = String(n ?? e.active_at ?? e.insights_payload?.active_at ?? "");
|
|
15
|
+
u(() => {
|
|
16
|
+
const c = h(e, n), g = y(i, c) ?? {
|
|
17
|
+
dateRange: c,
|
|
18
|
+
custom: () => !0
|
|
19
|
+
};
|
|
20
|
+
return T(() => d.accounts.map(({ guid: o }) => o).join(","), (o) => t.setFilter(F(g, {
|
|
21
|
+
allAccountGuids: o ? o.split(",") : [],
|
|
22
|
+
displayedDateRange: c
|
|
23
|
+
})), { fireImmediately: !0 });
|
|
24
|
+
}, [
|
|
25
|
+
f,
|
|
26
|
+
i.categoryGuid,
|
|
27
|
+
i.merchantGuid
|
|
28
|
+
]);
|
|
29
|
+
};
|
|
30
|
+
export {
|
|
31
|
+
M as useBudgetDetailsPrepare
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=useBudgetDetailsPrepare.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBudgetDetailsPrepare.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/BudgetDetailsBlock/useBudgetDetailsPrepare.ts"],"sourcesContent":["import { useEffect, useRef } from 'react'\n\nimport { reaction } from 'mobx'\n\nimport {\n useAccountStore,\n useBudgetsStore,\n useCategoryStore,\n useInsightsV2Store,\n useTransactionStore,\n} from '../../../common'\nimport type { TransactionFilter } from '../../../core/stores/TransactionStore'\nimport type { ActionBlockProps } from '../../mappings/blocks'\nimport { toStoreFilter } from '../TransactionHistoryBlock/utils'\n\nimport {\n budgetMonthRange,\n budgetTransactionFilter,\n recordedActiveAtOf,\n resolveBudgetFacts,\n} from './layout'\n\n/** Loads the budget data and points the store's filter at the budget month and category or merchant. */\nexport const useBudgetDetailsPrepare = ({ beat }: ActionBlockProps) => {\n const accountStore = useAccountStore()\n const budgetsStore = useBudgetsStore()\n const categoryStore = useCategoryStore()\n const insightsV2Store = useInsightsV2Store()\n const transactionStore = useTransactionStore()\n\n // Other widgets share the store's filter: snapshot it by value on open and put it back on close.\n const filterBeforeOpen = useRef<TransactionFilter | null>(null)\n if (filterBeforeOpen.current === null) filterBeforeOpen.current = { ...transactionStore.filter }\n\n useEffect(() => {\n if (!budgetsStore.isDataLoaded) void budgetsStore.loadBudgets().catch(() => undefined)\n if (!categoryStore.categoriesLoaded) void categoryStore.loadCategories()\n if (!transactionStore.isTransactionDataLoaded) {\n void transactionStore.loadMissingTransactionData()\n }\n\n return () => transactionStore.setFilter(filterBeforeOpen.current ?? {})\n }, [budgetsStore, categoryStore, transactionStore])\n\n const facts = resolveBudgetFacts(beat)\n const recordedActiveAt = recordedActiveAtOf(insightsV2Store, beat)\n const activeAtKey = String(\n recordedActiveAt ?? beat.active_at ?? beat.insights_payload?.active_at ?? '',\n )\n\n useEffect(() => {\n const dateRange = budgetMonthRange(beat, recordedActiveAt)\n // No category or merchant: the month alone (sortAndFilterTransactions' own default for custom).\n const filter = budgetTransactionFilter(facts, dateRange) ?? { dateRange, custom: () => true }\n\n // Not an observer: a reaction re-applies the filter once the accounts load.\n return reaction(\n () => accountStore.accounts.map(({ guid }) => guid).join(','),\n (guidsKey) =>\n transactionStore.setFilter(\n toStoreFilter(filter, {\n allAccountGuids: guidsKey ? guidsKey.split(',') : [],\n displayedDateRange: dateRange,\n }),\n ),\n { fireImmediately: true },\n )\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [activeAtKey, facts.categoryGuid, facts.merchantGuid])\n}\n"],"mappings":";;;;;AAuBA,IAAa,IAAA,CAA2B,EAAE,MAAA,EAAA,MAA6B;AACrE,QAAM,IAAe,EAAgB,GAC/B,IAAe,EAAgB,GAC/B,IAAgB,EAAiB,GACjC,IAAkB,EAAmB,GACrC,IAAmB,EAAoB,GAGvC,IAAmB,EAAiC,IAAI;AAC9D,EAAI,EAAiB,YAAY,SAAM,EAAiB,UAAU,EAAE,GAAG,EAAiB,OAAO,IAE/F,EAAA,OACO,EAAa,gBAAc,EAAkB,YAAY,EAAE,MAAA,MAAA;AAAA,GAAqB,GAChF,EAAc,oBAAkB,EAAmB,eAAe,GAClE,EAAiB,2BACpB,EAAsB,2BAA2B,GAGnD,MAAa,EAAiB,UAAU,EAAiB,WAAW,CAAC,CAAC,IACrE;AAAA,IAAC;AAAA,IAAc;AAAA,IAAe;AAAA,EAAgB,CAAC;AAElD,QAAM,IAAQ,EAAmB,CAAI,GAC/B,IAAmB,EAAmB,GAAiB,CAAI,GAC3D,IAAc,OAClB,KAAoB,EAAK,aAAa,EAAK,kBAAkB,aAAa,EAC5E;AAEA,EAAA,EAAA,MAAgB;AACd,UAAM,IAAY,EAAiB,GAAM,CAAgB,GAEnD,IAAS,EAAwB,GAAO,CAAS,KAAK;AAAA,MAAE,WAAA;AAAA,MAAW,QAAA,MAAc;AAAA,IAAK;AAG5F,WAAO,EAAA,MACC,EAAa,SAAS,IAAA,CAAK,EAAE,MAAA,EAAA,MAAW,CAAI,EAAE,KAAK,GAAG,GAAA,CAC3D,MACC,EAAiB,UACf,EAAc,GAAQ;AAAA,MACpB,iBAAiB,IAAW,EAAS,MAAM,GAAG,IAAI,CAAC;AAAA,MACnD,oBAAoB;AAAA,IACtB,CAAC,CACH,GACF,EAAE,iBAAiB,GAAK,CAC1B;AAAA,EAEF,GAAG;AAAA,IAAC;AAAA,IAAa,EAAM;AAAA,IAAc,EAAM;AAAA,EAAY,CAAC;AAC1D"}
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import { useGlobalCopyStore as
|
|
2
|
-
import { formatCurrency as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import { useGlobalCopyStore as yt, useGlobalUiStore as At, useInsightsV2Store as Dt } from "../../../common/context/hooks.es.js";
|
|
2
|
+
import { formatCurrency as Bt } from "../../../core/utils/NumberFormatting.es.js";
|
|
3
|
+
import St from "../../../common/components/drawer/Drawer.es.js";
|
|
4
|
+
import vt from "../../../common/components/Loader.es.js";
|
|
5
5
|
import { BAR_ARIA_LABEL as Lt } from "../../blocks/ChartBlocks/BarchartBlock/utils.es.js";
|
|
6
|
-
import { BarChartV2 as
|
|
7
|
-
import { EmptyBarChart as
|
|
6
|
+
import { BarChartV2 as It } from "../../components/chartblocks/BarchartV2.es.js";
|
|
7
|
+
import { EmptyBarChart as xt } from "../../components/chartblocks/EmptyBarChart.es.js";
|
|
8
8
|
import { ANALYTICS_EVENTS_CONFIG as P } from "../../analytics/analyticsEventsConfig.es.js";
|
|
9
|
-
import { useAnalyticsEvent as
|
|
10
|
-
import { DoubleBarChart as
|
|
11
|
-
import { toLegendItems as
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { useTransactionHistory as
|
|
16
|
-
import { TransactionDetailsBlock as
|
|
17
|
-
import { useLayoutEffect as
|
|
18
|
-
import { observer as
|
|
19
|
-
import { Fragment as
|
|
20
|
-
import { useTheme as
|
|
21
|
-
var
|
|
22
|
-
const D =
|
|
9
|
+
import { useAnalyticsEvent as Et } from "../../analytics/useAnalyticsEvent.es.js";
|
|
10
|
+
import { DoubleBarChart as Rt } from "../../components/chartblocks/DoubleBarChart.es.js";
|
|
11
|
+
import { toLegendItems as Ft } from "../../blocks/ChartBlocks/DoubleBarChartBlock/comparisonUtils.es.js";
|
|
12
|
+
import { getDefaultSelection as Ot, getDrillDownConfig as jt, getFlattenedDataSeries as Gt, resolveDrillDownSubHeader as Ht, splitProjectedTransaction as wt, toStoreFilter as kt } from "./utils.es.js";
|
|
13
|
+
import { getDynamicCtaBasedOnTriggers as Nt } from "../util.es.js";
|
|
14
|
+
import { TransactionDrillDown as Kt } from "./TransactionDrillDown.es.js";
|
|
15
|
+
import { useTransactionHistory as Mt } from "./useTransactionHistory.es.js";
|
|
16
|
+
import { TransactionDetailsBlock as Pt } from "../TransactionDetailsBlock/TransactionDetailsBlock.es.js";
|
|
17
|
+
import { useLayoutEffect as Vt, useState as m } from "react";
|
|
18
|
+
import { observer as zt } from "mobx-react-lite";
|
|
19
|
+
import { Fragment as Ut, jsx as r, jsxs as Wt } from "react/jsx-runtime";
|
|
20
|
+
import { useTheme as Yt } from "@mui/material/styles";
|
|
21
|
+
var fe = zt(({ beat: s }) => {
|
|
22
|
+
const D = Yt(), { actionDrawer: B, setActionContext: S } = Dt(), { insights_payload: c } = s, V = Nt(B, c?.primary_cta, c?.secondary_cta, c?.in_description_cta)?.variant, { top: e, filterMode: u, header: z, colors: U, filterStrategy: W, tipSection: v, subTabAriaLabels: Y, slotData: $, beatTransactions: q, hideListHeader: J, averageFormat: Q, subTabs: X } = jt(V ?? ""), { instanceSlotData: o, beatTransactions: g, spendCategoryGuids: L, allAccountGuids: I, categoryName: Z, displayedDateRange: h, transactionStore: tt } = Mt(s, {
|
|
23
23
|
slotData: $,
|
|
24
24
|
beatTransactions: q
|
|
25
|
-
}), { common:
|
|
25
|
+
}), { common: et, insights_feed: n } = yt(), { isCopyLoaded: ot } = At(), [at, x] = m(!1), [nt, rt] = m(!1), E = Et(), { dataSeries: p, chartData: b, comparisonBars: i } = Gt({
|
|
26
26
|
data: o?.data_series,
|
|
27
27
|
ariaLabel: e === "doubleBar" ? n?.general?.in_month_you_had_a_category_of_amount ?? "_1{month}, _2{category}: _3{amount}" : Lt,
|
|
28
28
|
top: e,
|
|
29
29
|
beatTransactions: g
|
|
30
|
-
}), d = e === "doubleBar",
|
|
30
|
+
}), d = e === "doubleBar", st = e === "tabsOnly", l = d ? i : b, { chartBarIndex: R, subTabIndex: it } = Ot({
|
|
31
31
|
chartTabCount: b.length,
|
|
32
32
|
comparisonTabCount: i.length,
|
|
33
33
|
actionDrawer: B,
|
|
34
34
|
beatGuid: s.guid
|
|
35
|
-
}), [a, T] = m(R), [_,
|
|
36
|
-
l.length !==
|
|
35
|
+
}), [a, T] = m(R), [_, F] = m(it), [lt, ct] = m(l.length);
|
|
36
|
+
l.length !== lt && (ct(l.length), T(R));
|
|
37
37
|
const C = (t) => W({
|
|
38
38
|
beat: s,
|
|
39
39
|
beatTransactions: g,
|
|
@@ -43,21 +43,21 @@ var be = Vt(({ beat: s }) => {
|
|
|
43
43
|
subIndex: _,
|
|
44
44
|
isLastTab: t === l.length - 1,
|
|
45
45
|
instanceSlotData: o,
|
|
46
|
-
spendCategoryGuids:
|
|
46
|
+
spendCategoryGuids: L,
|
|
47
47
|
displayedDateRange: h
|
|
48
|
-
}),
|
|
48
|
+
}), dt = g.map((t) => t.guid).join(","), mt = L.join(","), ut = I.join(","), gt = e === "list" || e === "tabsOnly" || e === "monthTabs" || p.length > 0, O = () => {
|
|
49
49
|
if (u !== "store") return;
|
|
50
|
-
const t =
|
|
50
|
+
const t = gt ? C(a) : {
|
|
51
51
|
accounts: [],
|
|
52
52
|
custom: () => !1
|
|
53
53
|
};
|
|
54
|
-
|
|
54
|
+
tt.setFilter(kt(t, {
|
|
55
55
|
allAccountGuids: I,
|
|
56
56
|
displayedDateRange: h
|
|
57
57
|
}));
|
|
58
58
|
};
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
Vt(() => {
|
|
60
|
+
O();
|
|
61
61
|
}, [
|
|
62
62
|
s.guid,
|
|
63
63
|
a,
|
|
@@ -66,48 +66,48 @@ var be = Vt(({ beat: s }) => {
|
|
|
66
66
|
p.length,
|
|
67
67
|
o,
|
|
68
68
|
h,
|
|
69
|
-
dt,
|
|
70
69
|
mt,
|
|
71
|
-
|
|
70
|
+
ut,
|
|
71
|
+
dt,
|
|
72
72
|
e
|
|
73
73
|
]);
|
|
74
|
-
const
|
|
74
|
+
const j = Ht(c), y = z?.({
|
|
75
75
|
title: c?.title,
|
|
76
|
-
subHeader:
|
|
77
|
-
categoryName:
|
|
76
|
+
subHeader: j,
|
|
77
|
+
categoryName: Z,
|
|
78
78
|
selectedDate: b[a]?.date ?? void 0
|
|
79
79
|
}), G = U(D, o?.category_guid);
|
|
80
|
-
if (!
|
|
81
|
-
const [H, w] = o?.legends ?? [],
|
|
80
|
+
if (!ot) return /* @__PURE__ */ r(vt, {});
|
|
81
|
+
const [H, w] = o?.legends ?? [], pt = u === "local" ? (t) => C(t).custom ?? (() => !0) : void 0, { transactions: bt, projectedTransaction: A } = wt(g), ft = u === "local" ? bt : void 0, k = n.general.projected_amount, ht = A && k && C(a).custom?.(A) ? {
|
|
82
82
|
heading: k,
|
|
83
83
|
transaction: A
|
|
84
84
|
} : void 0, N = (t, f) => {
|
|
85
|
-
E(P.DRAWER_CHART_BAR_CLICKED), T(t), f !== void 0 &&
|
|
86
|
-
},
|
|
85
|
+
E(P.DRAWER_CHART_BAR_CLICKED), T(t), f !== void 0 && F(f);
|
|
86
|
+
}, Tt = (t) => {
|
|
87
87
|
E(P.TAB_SELECTED), T(t);
|
|
88
|
-
}, K = d ?
|
|
88
|
+
}, K = d ? Ft([{
|
|
89
89
|
...H,
|
|
90
90
|
value: i[a]?.main
|
|
91
91
|
}, {
|
|
92
92
|
...w,
|
|
93
93
|
value: i[a]?.comparison
|
|
94
|
-
}]) : void 0,
|
|
94
|
+
}]) : void 0, _t = Y?.(n) ?? [], M = d ? (K ?? []).map((t, f) => ({
|
|
95
95
|
label: t.label,
|
|
96
|
-
ariaLabel:
|
|
97
|
-
})) :
|
|
96
|
+
ariaLabel: _t[f]
|
|
97
|
+
})) : st ? p.flatMap((t) => t.localized_label ? [{ label: t.localized_label }] : []) : X?.({
|
|
98
98
|
instanceSlotData: o,
|
|
99
99
|
copy: n
|
|
100
|
-
}).map((t) => ({ label: t })) ?? [],
|
|
100
|
+
}).map((t) => ({ label: t })) ?? [], Ct = d || e === "singleBar" || e === "upcomingBill" ? l.length ? d ? /* @__PURE__ */ r(Rt, {
|
|
101
101
|
bars: i,
|
|
102
102
|
colors: G,
|
|
103
103
|
legendPosition: "top",
|
|
104
104
|
legends: K,
|
|
105
105
|
onBarClick: N,
|
|
106
106
|
selectedIndex: a
|
|
107
|
-
}) : /* @__PURE__ */ r(
|
|
107
|
+
}) : /* @__PURE__ */ r(It, {
|
|
108
108
|
amounts: {
|
|
109
109
|
average: o?.average_amount,
|
|
110
|
-
formattedAverage:
|
|
110
|
+
formattedAverage: Bt(o?.average_amount ?? 0, Q ?? "0,0.00")
|
|
111
111
|
},
|
|
112
112
|
color: G[0] ?? D.palette.primary.main,
|
|
113
113
|
data: b,
|
|
@@ -123,40 +123,40 @@ var be = Vt(({ beat: s }) => {
|
|
|
123
123
|
onBarClick: N,
|
|
124
124
|
selectedTabIndex: a,
|
|
125
125
|
trendAmountLabel: w?.label ?? n.general.trend
|
|
126
|
-
}) : /* @__PURE__ */ r(
|
|
127
|
-
return /* @__PURE__ */ Ut
|
|
128
|
-
baseTransactions:
|
|
126
|
+
}) : /* @__PURE__ */ r(xt, {}) : null;
|
|
127
|
+
return /* @__PURE__ */ Wt(Ut, { children: [/* @__PURE__ */ r(Kt, {
|
|
128
|
+
baseTransactions: ft,
|
|
129
129
|
hideListHeader: J,
|
|
130
|
-
projectedRow:
|
|
130
|
+
projectedRow: ht,
|
|
131
131
|
heading: y?.heading,
|
|
132
132
|
icon: y?.icon,
|
|
133
|
-
onSelectionChange:
|
|
133
|
+
onSelectionChange: Tt,
|
|
134
134
|
selectedIndex: a,
|
|
135
135
|
subHeadingText: y?.subHeadingText,
|
|
136
136
|
tabs: l,
|
|
137
|
-
top:
|
|
137
|
+
top: Ct,
|
|
138
138
|
...M.length > 0 && { subTabs: {
|
|
139
139
|
tabs: M,
|
|
140
140
|
selectedIndex: _,
|
|
141
|
-
onChange:
|
|
141
|
+
onChange: F
|
|
142
142
|
} },
|
|
143
|
-
...
|
|
144
|
-
transactionFilter:
|
|
143
|
+
...v && { tipSection: !nt && (v(rt, n, j?.text, o) ?? !1) },
|
|
144
|
+
transactionFilter: pt,
|
|
145
145
|
onEachRowClick: (t) => {
|
|
146
146
|
S({ transaction_guid: t }), x(!0);
|
|
147
147
|
}
|
|
148
|
-
}), /* @__PURE__ */ r(
|
|
149
|
-
ariaLabelClose:
|
|
150
|
-
isOpen:
|
|
148
|
+
}), /* @__PURE__ */ r(St, {
|
|
149
|
+
ariaLabelClose: et.close_aria,
|
|
150
|
+
isOpen: at,
|
|
151
151
|
onClose: () => {
|
|
152
|
-
x(!1), S({ transaction_guid: void 0 }),
|
|
152
|
+
x(!1), S({ transaction_guid: void 0 }), O();
|
|
153
153
|
},
|
|
154
154
|
title: n.general.transaction_details_title,
|
|
155
|
-
children: /* @__PURE__ */ r(
|
|
155
|
+
children: /* @__PURE__ */ r(Pt, { beat: s })
|
|
156
156
|
})] });
|
|
157
157
|
});
|
|
158
158
|
export {
|
|
159
|
-
|
|
159
|
+
fe as TransactionHistoryBlock
|
|
160
160
|
};
|
|
161
161
|
|
|
162
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, 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 const dynamicCtaVariant = getDynamicCtaBasedOnTriggers(\n actionDrawer,\n insights_payload?.primary_cta,\n insights_payload?.secondary_cta,\n insights_payload?.in_description_cta,\n )?.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 subTabs,\n } = getDrillDownConfig(dynamicCtaVariant ?? '')\n\n const {\n instanceSlotData,\n beatTransactions,\n spendCategoryGuids,\n allAccountGuids,\n categoryName,\n displayedDateRange,\n transactionStore,\n } = useTransactionHistory(beat, { slotData, beatTransactions: resolveBeatTransactions })\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(instanceSlotData?.average_amount ?? 0, '0,0.00'),\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 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,GAEvB,IAAoB,GACxB,GACA,GAAkB,a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AAC,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 { 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 const dynamicCtaVariant = getDynamicCtaBasedOnTriggers(\n actionDrawer,\n insights_payload?.primary_cta,\n insights_payload?.secondary_cta,\n insights_payload?.in_description_cta,\n )?.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 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(beat, { slotData, beatTransactions: resolveBeatTransactions })\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 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,GAEvB,IAAoB,GACxB,GACA,GAAkB,aAClB,GAAkB,eAClB,GAAkB,kBACpB,GAAG,SAEG,EACJ,KAAA,GACA,YAAA,GACA,QAAA,GACA,QAAA,GACA,gBAAA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ACE,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"}
|
|
@@ -75,6 +75,7 @@ export interface DrillDownVariantConfig {
|
|
|
75
75
|
filterMode: 'store' | 'local';
|
|
76
76
|
subTabAriaLabels?: (copy: InsightsFeedCopy) => (string | undefined)[];
|
|
77
77
|
hideListHeader?: boolean;
|
|
78
|
+
averageFormat?: string;
|
|
78
79
|
}
|
|
79
80
|
export declare const resolveUpcomingBillSlotData: SlotDataResolver;
|
|
80
81
|
export declare const resolveSavingsContributionsSlotData: SlotDataResolver;
|