@mx-cartographer/experiences 9.7.165 → 9.7.167
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/common/components/dialog/Dialog.es.js +26 -29
- package/dist/common/components/dialog/Dialog.es.js.map +1 -1
- package/dist/core/types/localization/InsightsFeedCopy.d.ts +0 -2
- package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/SaveEnoughToLiveOnBottomSection.es.js +1 -1
- package/dist/insights-v2/actionBlocks/MakeTransferActionBlock/SaveEnoughToLiveOnBottomSection.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionDrillDown.d.ts +1 -5
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionDrillDown.es.js +53 -58
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionDrillDown.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js +92 -99
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.d.ts +1 -3
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js +72 -81
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistory.d.ts +5 -6
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistory.es.js +16 -16
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistory.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.d.ts +4 -32
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.es.js +59 -83
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/AccountSwitchBlock/layout.es.js +8 -7
- package/dist/insights-v2/blocks/ComponentBlocks/AccountSwitchBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/SavingsSummaryBlock/SavingsSummaryBlock.es.js +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/SavingsSummaryBlock/SavingsSummaryBlock.es.js.map +1 -1
- package/dist/insights-v2/components/celebrationGradients.d.ts +4 -3
- package/dist/insights-v2/components/celebrationGradients.es.js +14 -14
- package/dist/insights-v2/components/celebrationGradients.es.js.map +1 -1
- package/dist/insights-v2/mappings/blocks.es.js +0 -1
- package/dist/insights-v2/mappings/blocks.es.js.map +1 -1
- package/dist/transactions/components/shared/transactiondetails/actions/CategoryAction.es.js +51 -49
- package/dist/transactions/components/shared/transactiondetails/actions/CategoryAction.es.js.map +1 -1
- package/dist/transactions/components/transactionwidget/actions/EditCategoryAction.es.js +25 -23
- package/dist/transactions/components/transactionwidget/actions/EditCategoryAction.es.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { useAccountStore as
|
|
2
|
-
import { selectTransactionsByGuids as
|
|
3
|
-
import { toDrillDownSlotData as
|
|
4
|
-
import { useMemo as
|
|
5
|
-
var
|
|
6
|
-
const
|
|
7
|
-
|
|
1
|
+
import { useAccountStore as d, useCategoryStore as g, useGlobalUiStore as m, useTransactionStore as l } from "../../../common/context/hooks.es.js";
|
|
2
|
+
import { selectTransactionsByGuids as p } from "../../CommonUtils.es.js";
|
|
3
|
+
import { toDrillDownSlotData as y } from "./utils.es.js";
|
|
4
|
+
import { useMemo as S } from "react";
|
|
5
|
+
var f = (t) => y(t?.instance_slot?.data ?? {}), D = (t, { slotData: s = f } = {}, e) => {
|
|
6
|
+
const n = t.insights_payload, o = S(() => s(n, e), [
|
|
7
|
+
n,
|
|
8
8
|
s,
|
|
9
9
|
e
|
|
10
|
-
]),
|
|
10
|
+
]), r = l(), c = d(), i = g(), { displayedDateRange: u } = m();
|
|
11
11
|
return {
|
|
12
|
-
instanceSlotData:
|
|
13
|
-
beatTransactions:
|
|
14
|
-
spendCategoryGuids:
|
|
15
|
-
allAccountGuids:
|
|
16
|
-
categoryName:
|
|
17
|
-
displayedDateRange:
|
|
18
|
-
transactionStore:
|
|
12
|
+
instanceSlotData: o,
|
|
13
|
+
beatTransactions: p(r.detailedTransactions, o?.transaction_guids),
|
|
14
|
+
spendCategoryGuids: i.spendCategories.map((a) => a.guid),
|
|
15
|
+
allAccountGuids: c.accounts.map((a) => a.guid),
|
|
16
|
+
categoryName: i.getCategoryName(o?.category_guid ?? "") || "",
|
|
17
|
+
displayedDateRange: u,
|
|
18
|
+
transactionStore: r
|
|
19
19
|
};
|
|
20
20
|
};
|
|
21
21
|
export {
|
|
22
|
-
|
|
22
|
+
D as useTransactionHistory
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
//# sourceMappingURL=useTransactionHistory.es.js.map
|
package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistory.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTransactionHistory.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistory.ts"],"sourcesContent":["import { useMemo } from 'react'\n\nimport {\n useAccountStore,\n useCategoryStore,\n useGlobalUiStore,\n useTransactionStore,\n} from '../../../common'\nimport type { Beat } from '../../../core'\nimport type { BarChartBlockData } from '../../../core/types/InsightsInstanceSlotData'\nimport { selectTransactionsByGuids } from '../../CommonUtils'\nimport type { DrillDownVariantConfig } from './layout'\nimport type { DrilldownData } from '../../../core'\nimport { type SlotDataResolver, toDrillDownSlotData } from './utils'\n\n// The default source of the drawer's facts: the bar chart's `instance_slot.data`.\nconst fromInstanceSlot: SlotDataResolver = (payload) =>\n toDrillDownSlotData((payload?.instance_slot?.data ?? {}) as BarChartBlockData)\n\n/**\n * The drawer's facts and store reads. `slotData`
|
|
1
|
+
{"version":3,"file":"useTransactionHistory.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistory.ts"],"sourcesContent":["import { useMemo } from 'react'\n\nimport {\n useAccountStore,\n useCategoryStore,\n useGlobalUiStore,\n useTransactionStore,\n} from '../../../common'\nimport type { Beat } from '../../../core'\nimport type { BarChartBlockData } from '../../../core/types/InsightsInstanceSlotData'\nimport { selectTransactionsByGuids } from '../../CommonUtils'\nimport type { DrillDownVariantConfig } from './layout'\nimport type { DrilldownData } from '../../../core'\nimport { type SlotDataResolver, toDrillDownSlotData } from './utils'\n\n// The default source of the drawer's facts: the bar chart's `instance_slot.data`.\nconst fromInstanceSlot: SlotDataResolver = (payload) =>\n toDrillDownSlotData((payload?.instance_slot?.data ?? {}) as BarChartBlockData)\n\n/**\n * The drawer's facts and store reads. `slotData` is the variant's resolver from the drilldown\n * registry (layout.tsx): a variant that names none reads `instance_slot.data`. `ctaDrilldownData` is\n * the drilldown_data of the CTA that opened the drawer, for a resolver that reads its facts from the\n * opener.\n */\nexport const useTransactionHistory = (\n beat: Beat,\n { slotData: resolveSlotData = fromInstanceSlot }: Pick<DrillDownVariantConfig, 'slotData'> = {},\n ctaDrilldownData?: DrilldownData,\n) => {\n // Memoised: the drawer's filter effect depends on this object's identity.\n const insightsPayload = beat.insights_payload\n const instanceSlotData = useMemo(\n () => resolveSlotData(insightsPayload, ctaDrilldownData),\n [insightsPayload, resolveSlotData, ctaDrilldownData],\n )\n\n const transactionStore = useTransactionStore()\n const accountStore = useAccountStore()\n const categoryStore = useCategoryStore()\n const { displayedDateRange } = useGlobalUiStore()\n\n const beatTransactions = selectTransactionsByGuids(\n transactionStore.detailedTransactions,\n instanceSlotData?.transaction_guids,\n )\n\n const spendCategoryGuids = categoryStore.spendCategories.map((category) => category.guid)\n const allAccountGuids = accountStore.accounts.map((account) => account.guid)\n const categoryName = categoryStore.getCategoryName(instanceSlotData?.category_guid ?? '') || ''\n\n return {\n instanceSlotData,\n beatTransactions,\n spendCategoryGuids,\n allAccountGuids,\n categoryName,\n displayedDateRange,\n transactionStore,\n }\n}\n"],"mappings":";;;;AAgBA,IAAM,IAAA,CAAsC,MAC1C,EAAqB,GAAS,eAAe,QAAQ,CAAC,CAAuB,GAQlE,IAAA,CACX,GACA,EAAE,UAAU,IAAkB,EAAA,IAA+D,CAAC,GAC9F,MACG;AAEH,QAAM,IAAkB,EAAK,kBACvB,IAAmB,EAAA,MACjB,EAAgB,GAAiB,CAAgB,GACvD;AAAA,IAAC;AAAA,IAAiB;AAAA,IAAiB;AAAA,EAAgB,CACrD,GAEM,IAAmB,EAAoB,GACvC,IAAe,EAAgB,GAC/B,IAAgB,EAAiB,GACjC,EAAE,oBAAA,EAAA,IAAuB,EAAiB;AAWhD,SAAO;AAAA,IACL,kBAAA;AAAA,IACA,kBAXuB,EACvB,EAAiB,sBACjB,GAAkB,iBASlB;AAAA,IACA,oBAPyB,EAAc,gBAAgB,IAAA,CAAK,MAAa,EAAS,IAOlF;AAAA,IACA,iBAPsB,EAAa,SAAS,IAAA,CAAK,MAAY,EAAQ,IAOrE;AAAA,IACA,cAPmB,EAAc,gBAAgB,GAAkB,iBAAiB,EAAE,KAAK;AAAA,IAQ3F,oBAAA;AAAA,IACA,kBAAA;AAAA,EACF;AACF"}
|
|
@@ -26,7 +26,6 @@ interface FlattenedDataSeriesInput {
|
|
|
26
26
|
beatTransactions: Transaction[];
|
|
27
27
|
}
|
|
28
28
|
export declare const getFlattenedDataSeries: ({ data, ariaLabel, top, beatTransactions, }: FlattenedDataSeriesInput) => FlattenedDataSeries;
|
|
29
|
-
export declare const PROJECTED_BILL_GUID = "TRN-projected-bill";
|
|
30
29
|
export interface UpcomingBillBar {
|
|
31
30
|
date: string;
|
|
32
31
|
amount: number;
|
|
@@ -35,33 +34,12 @@ export interface UpcomingBillBar {
|
|
|
35
34
|
label?: string;
|
|
36
35
|
}
|
|
37
36
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
|
|
42
|
-
export declare const splitProjectedTransaction: (transactions: Transaction[]) => {
|
|
43
|
-
transactions: Transaction[];
|
|
44
|
-
projectedTransaction?: Transaction;
|
|
45
|
-
};
|
|
46
|
-
/**
|
|
47
|
-
* UpcomingBill has no data_series: build the bar series from the drawer's transactions, its paid
|
|
48
|
-
* bills plus the projected bill last (mirrors pulse's magicTransactions). Paid bills are sorted and
|
|
49
|
-
* de-duped by date, each keeping its real guid so the guid filter finds it; the projected bar keeps
|
|
50
|
-
* the PROJECTED_BILL_GUID sentinel and lands last. No projected bill (a missing due date or amount),
|
|
51
|
-
* no bars. Bars are named by month; when two share a month, every bar is named by its day so no two
|
|
52
|
-
* tabs read the same.
|
|
37
|
+
* UpcomingBill has no data_series: build the bar series from its paid bills, oldest first, so the
|
|
38
|
+
* drawer opens on the latest (Figma: history only). Bills are de-duped by date, each keeping its real
|
|
39
|
+
* guid so the guid filter finds it. Bars are named by month; when two share a month, every bar is
|
|
40
|
+
* named by its day so no two tabs read the same.
|
|
53
41
|
*/
|
|
54
42
|
export declare const buildUpcomingBillSeries: (transactions?: Transaction[]) => UpcomingBillBar[];
|
|
55
|
-
/**
|
|
56
|
-
* The transaction behind UpcomingBill's projected bar, as legacy pulse's drawer lists it under
|
|
57
|
-
* "Projected amount": the latest paid bill's merchant and category with the due date and projected
|
|
58
|
-
* amount, on the PROJECTED_BILL_GUID sentinel. Its split / hidden / flagged state is cleared so the
|
|
59
|
-
* inert row never shows the paid bill's badges. Undefined without paid bills, a due date or amount.
|
|
60
|
-
*/
|
|
61
|
-
export declare const buildProjectedBillTransaction: (transactions: Transaction[] | undefined, payload: {
|
|
62
|
-
date?: string;
|
|
63
|
-
amount?: number;
|
|
64
|
-
} | undefined) => Transaction | undefined;
|
|
65
43
|
export declare const getDrawerHeaderTitle: (variant: string | null | undefined, copy: GlobalCopy, beat?: Beat) => string;
|
|
66
44
|
export declare const toStoreFilter: (filter: TransactionFilter, defaults: {
|
|
67
45
|
allAccountGuids: string[];
|
|
@@ -84,18 +62,12 @@ export type DrillDownSlotData = InsightsInstanceSlotData & Pick<BarChartBlockDat
|
|
|
84
62
|
income_transaction_guids?: string[];
|
|
85
63
|
sub_tab_labels?: string[];
|
|
86
64
|
};
|
|
87
|
-
export declare const utcDayToUnix: (day: string) => number;
|
|
88
65
|
export declare const calendarDateOf: (value: unknown) => string | undefined;
|
|
89
66
|
/**
|
|
90
67
|
* Resolves the drawer's facts (bars, guids, colour, average, tip values) from the beat's payload, or
|
|
91
68
|
* from the drilldown_data of the CTA that opened the drawer (`ctaDrilldownData`).
|
|
92
69
|
*/
|
|
93
70
|
export type SlotDataResolver = (payload: Partial<InsightsPayload> | undefined, ctaDrilldownData?: DrilldownData) => DrillDownSlotData;
|
|
94
|
-
/**
|
|
95
|
-
* Builds the drawer's transactions from the beat's own (its `transaction_guids` in the store) and
|
|
96
|
-
* its facts, e.g. Upcoming Bill appends its projected bill. Absent: the beat's own, as they are.
|
|
97
|
-
*/
|
|
98
|
-
export type BeatTransactionsResolver = (transactions: Transaction[], slotData: DrillDownSlotData) => Transaction[];
|
|
99
71
|
/** The drawer's facts from a bar chart's `instance_slot.data` (variants with no `slotData`). */
|
|
100
72
|
export declare const toDrillDownSlotData: ({ series, category_guid, average_amount, additional_data, }: BarChartBlockData) => DrillDownSlotData;
|
|
101
73
|
/** The drawer's sub-heading: the merchant name and logo. */
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { DATE_FORMATS_INTL as
|
|
2
|
-
import { fromUnixUTC as
|
|
3
|
-
import { buildChartData as
|
|
4
|
-
import { buildComparisonSeries as
|
|
5
|
-
import { DRILLDOWN_VARIANTS as
|
|
6
|
-
import { format as
|
|
7
|
-
var
|
|
1
|
+
import { DATE_FORMATS_INTL as m, formatDate as g } from "../../../core/constants/DateFormats.es.js";
|
|
2
|
+
import { fromUnixUTC as h } from "../../../core/utils/DateUtil.es.js";
|
|
3
|
+
import { buildChartData as c, buildDataSeries as l } from "../../blocks/ChartBlocks/BarchartBlock/utils.es.js";
|
|
4
|
+
import { buildComparisonSeries as _ } from "../../blocks/ChartBlocks/DoubleBarChartBlock/comparisonUtils.es.js";
|
|
5
|
+
import { DRILLDOWN_VARIANTS as d, FALLBACK as f, layout as D } from "./layout.es.js";
|
|
6
|
+
import { format as p, isValid as S, parseISO as u } from "date-fns";
|
|
7
|
+
var I = (t) => D[t] ?? f, O = ({ data: t, ariaLabel: r, top: a, beatTransactions: i }) => {
|
|
8
8
|
if (a === "upcomingBill") {
|
|
9
|
-
const
|
|
9
|
+
const e = T(i);
|
|
10
10
|
return {
|
|
11
|
-
dataSeries:
|
|
12
|
-
chartData:
|
|
11
|
+
dataSeries: e,
|
|
12
|
+
chartData: c(e, r).map((n, s) => e[s].label ? {
|
|
13
13
|
...n,
|
|
14
|
-
label:
|
|
14
|
+
label: e[s].label
|
|
15
15
|
} : n),
|
|
16
16
|
comparisonBars: []
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
19
|
if (a === "tabsOnly") return {
|
|
20
|
-
dataSeries:
|
|
20
|
+
dataSeries: l(t).filter((e) => e.localized_label),
|
|
21
21
|
chartData: [],
|
|
22
22
|
comparisonBars: []
|
|
23
23
|
};
|
|
@@ -26,87 +26,67 @@ var M = (t) => B[t] ?? T, U = ({ data: t, ariaLabel: e, top: a, beatTransactions
|
|
|
26
26
|
chartData: [],
|
|
27
27
|
comparisonBars: []
|
|
28
28
|
};
|
|
29
|
-
const
|
|
29
|
+
const o = [...l(t)].sort((e, n) => !e.date || !n.date ? 0 : new Date(e.date).getTime() - new Date(n.date).getTime());
|
|
30
30
|
switch (a) {
|
|
31
31
|
case "doubleBar":
|
|
32
32
|
return {
|
|
33
|
-
dataSeries:
|
|
33
|
+
dataSeries: o,
|
|
34
34
|
chartData: [],
|
|
35
|
-
comparisonBars:
|
|
35
|
+
comparisonBars: _(t, r)
|
|
36
36
|
};
|
|
37
37
|
case "singleBar":
|
|
38
38
|
case "monthTabs":
|
|
39
39
|
return {
|
|
40
|
-
dataSeries:
|
|
41
|
-
chartData:
|
|
40
|
+
dataSeries: o,
|
|
41
|
+
chartData: c(o, r),
|
|
42
42
|
comparisonBars: []
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
|
-
},
|
|
46
|
-
date:
|
|
45
|
+
}, B = (t) => ({
|
|
46
|
+
date: p(h(t.date), "yyyy-MM-dd"),
|
|
47
47
|
amount: t.amount,
|
|
48
48
|
guid: t.guid,
|
|
49
49
|
category_guid: t.top_level_category_guid ?? t.category_guid
|
|
50
|
-
}),
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (!a || !e.length) return [];
|
|
59
|
-
const o = [...e].sort((s, _) => s.date - _.date), i = /* @__PURE__ */ new Set(), r = [];
|
|
60
|
-
for (const s of o)
|
|
61
|
-
i.has(s.date) || (i.add(s.date), r.push(g(s)));
|
|
62
|
-
const n = [...r, g(a)], d = n.map((s) => s.date.slice(0, 7));
|
|
63
|
-
return new Set(d).size === d.length ? n : n.map((s) => ({
|
|
64
|
-
...s,
|
|
65
|
-
label: f(m(s.date), h.MONTH_DAY)
|
|
50
|
+
}), T = (t = []) => {
|
|
51
|
+
const r = [...t].sort((e, n) => e.date - n.date), a = /* @__PURE__ */ new Set(), i = [];
|
|
52
|
+
for (const e of r)
|
|
53
|
+
a.has(e.date) || (a.add(e.date), i.push(B(e)));
|
|
54
|
+
const o = i.map((e) => e.date.slice(0, 7));
|
|
55
|
+
return new Set(o).size === o.length ? i : i.map((e) => ({
|
|
56
|
+
...e,
|
|
57
|
+
label: g(u(e.date), m.MONTH_DAY)
|
|
66
58
|
}));
|
|
67
|
-
},
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
parent_guid: null
|
|
78
|
-
};
|
|
79
|
-
}, E = (t, e, a) => {
|
|
80
|
-
const o = e.insights_feed?.general?.transaction_history_title ?? "", i = e.insights_feed?.transaction_history_block;
|
|
81
|
-
if (t === l.TRANSACTION) return o;
|
|
82
|
-
const r = a?.insights_payload?.title;
|
|
83
|
-
if (t === l.ACCOUNT_BALANCE && r) return r;
|
|
84
|
-
const n = t === l.DEBT_TO_INCOME ? "monthly_debt_to_income_drawer_title" : `${t}_drawer_title`;
|
|
85
|
-
return i?.[n] ?? o;
|
|
86
|
-
}, L = (t, e) => ({
|
|
87
|
-
accounts: t.accounts ?? e.allAccountGuids,
|
|
88
|
-
dateRange: t.dateRange ?? e.displayedDateRange,
|
|
59
|
+
}, v = (t, r, a) => {
|
|
60
|
+
const i = r.insights_feed?.general?.transaction_history_title ?? "", o = r.insights_feed?.transaction_history_block;
|
|
61
|
+
if (t === d.TRANSACTION) return i;
|
|
62
|
+
const e = a?.insights_payload?.title;
|
|
63
|
+
if (t === d.ACCOUNT_BALANCE && e) return e;
|
|
64
|
+
const n = t === d.DEBT_TO_INCOME ? "monthly_debt_to_income_drawer_title" : `${t}_drawer_title`;
|
|
65
|
+
return o?.[n] ?? i;
|
|
66
|
+
}, M = (t, r) => ({
|
|
67
|
+
accounts: t.accounts ?? r.allAccountGuids,
|
|
68
|
+
dateRange: t.dateRange ?? r.displayedDateRange,
|
|
89
69
|
custom: t.custom ?? (() => !0),
|
|
90
70
|
showSplits: t.showSplits ?? !1
|
|
91
|
-
}),
|
|
92
|
-
const
|
|
93
|
-
return
|
|
94
|
-
chartBarIndex: Math.min(Math.max(n?.chartBarIndex ?? 0, 0), Math.max(0,
|
|
95
|
-
subTabIndex:
|
|
71
|
+
}), N = ({ chartTabCount: t, comparisonTabCount: r, actionDrawer: a, beatGuid: i }) => {
|
|
72
|
+
const o = r || t, e = a.guid === i && a.trigger === "chartBar", n = a.context, s = e ? n?.tabIndex ?? 0 : 0;
|
|
73
|
+
return e ? {
|
|
74
|
+
chartBarIndex: Math.min(Math.max(n?.chartBarIndex ?? 0, 0), Math.max(0, o - 1)),
|
|
75
|
+
subTabIndex: s
|
|
96
76
|
} : {
|
|
97
|
-
chartBarIndex: Math.max(0,
|
|
98
|
-
subTabIndex:
|
|
77
|
+
chartBarIndex: Math.max(0, o - 1),
|
|
78
|
+
subTabIndex: s
|
|
99
79
|
};
|
|
100
|
-
},
|
|
101
|
-
const
|
|
80
|
+
}, R = (t) => typeof t == "string" && /^\d{4}-\d{2}-\d{2}$/.test(t) && S(u(t)) ? t : void 0, U = ({ series: t, category_guid: r, average_amount: a, additional_data: i }) => {
|
|
81
|
+
const o = l(t).map(({ guid: e }) => e).filter((e) => !!e);
|
|
102
82
|
return {
|
|
103
83
|
data_series: t,
|
|
104
|
-
category_guid:
|
|
84
|
+
category_guid: r,
|
|
105
85
|
average_amount: a,
|
|
106
|
-
legends:
|
|
107
|
-
transaction_guids:
|
|
86
|
+
legends: i,
|
|
87
|
+
transaction_guids: o.length ? o : void 0
|
|
108
88
|
};
|
|
109
|
-
},
|
|
89
|
+
}, E = (t) => {
|
|
110
90
|
if (t)
|
|
111
91
|
return {
|
|
112
92
|
text: t.subtitle ?? "",
|
|
@@ -117,19 +97,15 @@ var M = (t) => B[t] ?? T, U = ({ data: t, ariaLabel: e, top: a, beatTransactions
|
|
|
117
97
|
};
|
|
118
98
|
};
|
|
119
99
|
export {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
U as
|
|
128
|
-
|
|
129
|
-
v as splitProjectedTransaction,
|
|
130
|
-
G as toDrillDownSlotData,
|
|
131
|
-
L as toStoreFilter,
|
|
132
|
-
x as utcDayToUnix
|
|
100
|
+
T as buildUpcomingBillSeries,
|
|
101
|
+
R as calendarDateOf,
|
|
102
|
+
N as getDefaultSelection,
|
|
103
|
+
v as getDrawerHeaderTitle,
|
|
104
|
+
I as getDrillDownConfig,
|
|
105
|
+
O as getFlattenedDataSeries,
|
|
106
|
+
E as resolveDrillDownSubHeader,
|
|
107
|
+
U as toDrillDownSlotData,
|
|
108
|
+
M as toStoreFilter
|
|
133
109
|
};
|
|
134
110
|
|
|
135
111
|
//# sourceMappingURL=utils.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionHistoryBlock/utils.ts"],"sourcesContent":["import { format, isValid, parseISO } from 'date-fns'\n\nimport type {\n ActionDrawerState,\n Beat,\n DataSeries,\n DrilldownPayload,\n DrilldownData,\n GlobalCopy,\n InsightsPayload,\n Subtitle,\n Transaction,\n} from '../../../core'\nimport type {\n BarChartBlockData,\n DataSet,\n InsightsInstanceSlotData,\n} from '../../../core/types/InsightsInstanceSlotData'\nimport { DATE_FORMATS_INTL, formatDate } from '../../../core/constants'\nimport type { TransactionFilter } from '../../../core/stores/TransactionStore'\nimport { fromUnixUTC } from '../../../core/utils/DateUtil'\nimport {\n buildChartData,\n buildDataSeries,\n type ChartDataSeriesItem,\n} from '../../blocks/ChartBlocks/BarchartBlock/utils'\nimport { buildComparisonSeries } from '../../blocks/ChartBlocks/DoubleBarChartBlock/comparisonUtils'\nimport {\n layout,\n FALLBACK,\n DRILLDOWN_VARIANTS,\n DrillDownVariant,\n DrillDownVariantConfig,\n} from './layout'\nimport { TransactionHistoryBlock } from '../../../core/types/localization/InsightsFeedCopy'\n\ninterface DefaultSelectionProp {\n chartTabCount: number\n comparisonTabCount: number\n actionDrawer: ActionDrawerState\n beatGuid: string\n}\nexport const getDrillDownConfig = (variant?: string): DrillDownVariantConfig =>\n layout[variant as DrillDownVariant] ?? FALLBACK\n\n// The shaped chart inputs a drill-down needs, derived once from the beat's data_series. `dataSeries`\n// is the flat per-bar source (indexes the filterStrategy); `chartData` feeds the single-bar chart;\n// `comparisonBars` feeds the double-bar chart and its month tabs (empty for every other top kind).\nexport interface FlattenedDataSeries {\n dataSeries: ChartDataSeriesItem[]\n chartData: ReturnType<typeof buildChartData>\n comparisonBars: DataSet[]\n}\n\n/**\n * Shapes the beat's raw data_series into the chart inputs for the variant's top kind: the single-bar\n * family (singleBar / upcomingBill), the double bar's month columns, or a tabs-only drawer's sides.\n */\ninterface FlattenedDataSeriesInput {\n data: DataSeries | undefined\n ariaLabel: string\n top: DrillDownVariantConfig['top']\n // UpcomingBill has no data_series; it builds its bars from these instead (its paid bills plus the\n // projected bill its `beatTransactions` resolver appends).\n beatTransactions: Transaction[]\n}\n\nexport const getFlattenedDataSeries = ({\n data,\n ariaLabel,\n top,\n beatTransactions,\n}: FlattenedDataSeriesInput): FlattenedDataSeries => {\n // UpcomingBill has no backend data_series: a bar per month of paid bills plus the projected bill,\n // each named by its month (buildChartData's default MONTH_SHORT) as the design labels it. A\n // projected bill sharing the latest paid month keeps its own day label.\n if (top === 'upcomingBill') {\n const dataSeries = buildUpcomingBillSeries(beatTransactions)\n const chartData = buildChartData(dataSeries, ariaLabel).map((bar, index) =>\n dataSeries[index].label ? { ...bar, label: dataSeries[index].label } : bar,\n )\n return { dataSeries, chartData, comparisonBars: [] }\n }\n\n // Tabs only: the rows are the sides of one month, not bars. They keep their wire order, which the\n // side tabs and the filter's dataSeries[subIndex] both index; there is no chart and no month tab.\n if (top === 'tabsOnly') {\n return {\n dataSeries: buildDataSeries(data).filter((row) => row.localized_label),\n chartData: [],\n comparisonBars: [],\n }\n }\n\n // List: one account over a window the strategy reads from the beat; no series, chart or tabs.\n if (top === 'list') {\n return { dataSeries: [], chartData: [], comparisonBars: [] }\n }\n\n // The month families: the backend sends data_series newest-first, so normalize it date-ascending\n // here. chartData/tabs and the filter's dataSeries[selectedIndex] indexing both read this one\n // array, so they stay aligned and the last tab is the most recent month.\n const dataSeries = [...buildDataSeries(data)].sort((a, b) => {\n if (!a.date || !b.date) return 0\n\n return new Date(a.date).getTime() - new Date(b.date).getTime()\n })\n\n switch (top) {\n // Double bar: comparison beats build paired month columns (with their guids) instead of chartData.\n case 'doubleBar':\n return { dataSeries, chartData: [], comparisonBars: buildComparisonSeries(data, ariaLabel) }\n // Single bar draws chartData as bars; month tabs reads the same chartData for its tabs only.\n case 'singleBar':\n case 'monthTabs':\n return { dataSeries, chartData: buildChartData(dataSeries, ariaLabel), comparisonBars: [] }\n }\n}\n\n// Sentinel guid for the synthesized projected bill. It intentionally matches no real store\n// transaction, so the projected tab lists only its Projected amount row.\nexport const PROJECTED_BILL_GUID = 'TRN-projected-bill'\n\n// One bar in the UpcomingBill chart. `date` is 'yyyy-MM-dd' so buildChartData/parseISO can read it.\n// `label` is set only when two bars share a month, so they are named by their day.\nexport interface UpcomingBillBar {\n date: string\n amount: number\n guid: string\n category_guid?: string\n label?: string\n}\n\n// The bill's UTC calendar day, the day the transaction list heads its row with\n// (fromUnixUTCToDayOfWeekAndDate); a local-time date put a UTC-midnight bill on the day before.\nconst toUpcomingBillBar = (transaction: Transaction): UpcomingBillBar => ({\n date: format(fromUnixUTC(transaction.date), 'yyyy-MM-dd'),\n amount: transaction.amount,\n guid: transaction.guid,\n category_guid: transaction.top_level_category_guid ?? transaction.category_guid,\n})\n\n/**\n * Splits a drawer's transactions into the real ones and the synthesized projected bill, which a\n * `beatTransactions` resolver (Upcoming Bill's) appends last under PROJECTED_BILL_GUID. Every other\n * variant has no projected bill, so its transactions pass through untouched.\n */\nexport const splitProjectedTransaction = (\n transactions: Transaction[],\n): { transactions: Transaction[]; projectedTransaction?: Transaction } => {\n const last = transactions[transactions.length - 1]\n if (last?.guid !== PROJECTED_BILL_GUID) return { transactions }\n\n return { transactions: transactions.slice(0, -1), projectedTransaction: last }\n}\n\n/**\n * UpcomingBill has no data_series: build the bar series from the drawer's transactions, its paid\n * bills plus the projected bill last (mirrors pulse's magicTransactions). Paid bills are sorted and\n * de-duped by date, each keeping its real guid so the guid filter finds it; the projected bar keeps\n * the PROJECTED_BILL_GUID sentinel and lands last. No projected bill (a missing due date or amount),\n * no bars. Bars are named by month; when two share a month, every bar is named by its day so no two\n * tabs read the same.\n */\nexport const buildUpcomingBillSeries = (transactions: Transaction[] = []): UpcomingBillBar[] => {\n const { transactions: paidBills, projectedTransaction } = splitProjectedTransaction(transactions)\n if (!projectedTransaction || !paidBills.length) return []\n\n const sorted = [...paidBills].sort((a, b) => a.date - b.date)\n\n const seenDates = new Set<number>()\n const history: UpcomingBillBar[] = []\n for (const transaction of sorted) {\n if (seenDates.has(transaction.date)) continue\n seenDates.add(transaction.date)\n history.push(toUpcomingBillBar(transaction))\n }\n\n const bars = [...history, toUpcomingBillBar(projectedTransaction)]\n\n const months = bars.map((bar) => bar.date.slice(0, 7))\n if (new Set(months).size === months.length) return bars\n\n return bars.map((bar) => ({\n ...bar,\n label: formatDate(parseISO(bar.date), DATE_FORMATS_INTL.MONTH_DAY),\n }))\n}\n\n/**\n * The transaction behind UpcomingBill's projected bar, as legacy pulse's drawer lists it under\n * \"Projected amount\": the latest paid bill's merchant and category with the due date and projected\n * amount, on the PROJECTED_BILL_GUID sentinel. Its split / hidden / flagged state is cleared so the\n * inert row never shows the paid bill's badges. Undefined without paid bills, a due date or amount.\n */\nexport const buildProjectedBillTransaction = (\n transactions: Transaction[] = [],\n payload: { date?: string; amount?: number } | undefined,\n): Transaction | undefined => {\n if (!transactions.length || payload?.date == null || payload?.amount == null) return undefined\n\n const latestBill = transactions.reduce((latest, t) => (t.date > latest.date ? t : latest))\n\n return {\n ...latestBill,\n guid: PROJECTED_BILL_GUID,\n amount: payload.amount,\n date: utcDayToUnix(payload.date),\n has_been_split: false,\n is_hidden: false,\n is_flagged: false,\n parent_guid: null,\n }\n}\n\nexport const getDrawerHeaderTitle = (\n variant: string | null | undefined,\n copy: GlobalCopy,\n beat?: Beat,\n): string => {\n const transactionHistoryTitle = copy.insights_feed?.general?.transaction_history_title ?? ''\n const drawerTitleCopy = copy.insights_feed?.transaction_history_block as TransactionHistoryBlock\n\n if (variant === DRILLDOWN_VARIANTS.TRANSACTION) return transactionHistoryTitle\n\n // Savings Account Balances Summary: the drawer reads as the card it opens from (\"Savings\n // Contributions\", Figma 1135:50175), whatever the host's drawer copy says.\n const beatTitle = beat?.insights_payload?.title\n if (variant === DRILLDOWN_VARIANTS.ACCOUNT_BALANCE && beatTitle) return beatTitle\n\n // Safely access the drawer title from transaction_history_block. Debt to Income's ditto variant\n // (debt_to_income) keeps the host copy's existing monthly_debt_to_income_drawer_title. Savings to\n // Income's variant is savings_to_income, so it resolves savings_to_income_drawer_title through the\n // generic path below (it deliberately drops the monthly_ prefix; do not re-add it).\n const key = (\n variant === DRILLDOWN_VARIANTS.DEBT_TO_INCOME\n ? 'monthly_debt_to_income_drawer_title'\n : `${variant}_drawer_title`\n ) as keyof TransactionHistoryBlock\n return (drawerTitleCopy?.[key] as string) ?? transactionHistoryTitle\n}\n\nexport const toStoreFilter = (\n filter: TransactionFilter,\n defaults: { allAccountGuids: string[]; displayedDateRange: { start: Date; end: Date } },\n): TransactionFilter => ({\n accounts: filter.accounts ?? defaults.allAccountGuids,\n dateRange: filter.dateRange ?? defaults.displayedDateRange,\n custom: filter.custom ?? (() => true),\n showSplits: filter.showSplits ?? false,\n})\n\nexport const getDefaultSelection = ({\n chartTabCount,\n comparisonTabCount,\n actionDrawer,\n beatGuid,\n}: DefaultSelectionProp): { chartBarIndex: number; subTabIndex: number } => {\n // A double-bar drawer's tabs are its comparison columns; every other drawer's are its chart bars.\n const tabCount = comparisonTabCount || chartTabCount\n const openedViaChartBar = actionDrawer.guid === beatGuid && actionDrawer.trigger === 'chartBar'\n\n // actionDrawer.context is an opaque `unknown` bag; narrow it to the shape the chart blocks write.\n const context = actionDrawer.context as DrilldownPayload | undefined\n const subTabIndex = openedViaChartBar ? (context?.tabIndex ?? 0) : 0\n\n if (openedViaChartBar) {\n const clamped = Math.min(Math.max(context?.chartBarIndex ?? 0, 0), Math.max(0, tabCount - 1))\n return { chartBarIndex: clamped, subTabIndex }\n }\n\n return { chartBarIndex: Math.max(0, tabCount - 1), subTabIndex }\n}\n\n/**\n * The drawer's facts: the generic slot facts plus the bar chart's average, and the merchant a\n * variant's tip names.\n */\nexport type DrillDownSlotData = InsightsInstanceSlotData &\n Pick<BarChartBlockData, 'average_amount'> & {\n merchant_name?: string\n // Merchant Budget: the merchant whose transactions the drawer lists.\n merchant_guid?: string\n // Monthly Deposit Summary: the deposits on the Income sub-tab, across every month.\n income_transaction_guids?: string[]\n // A drawer's own sub-tab names when the card's legend rows aren't the chart's (Income / Other Deposits).\n sub_tab_labels?: string[]\n }\n\n// A YYYY-MM-DD day as the epoch seconds of its UTC midnight: the day a transaction row is dated on\n// (fromUnixUTCToDayOfWeekAndDate), so a synthesized row agrees with the bars in every zone.\nexport const utcDayToUnix = (day: string): number => Date.parse(`${day}T00:00:00Z`) / 1000\n\n// parseISO rejects impossible days such as 2026-02-30.\nexport const calendarDateOf = (value: unknown): string | undefined =>\n typeof value === 'string' && /^\\d{4}-\\d{2}-\\d{2}$/.test(value) && isValid(parseISO(value))\n ? value\n : undefined\n\n/**\n * Resolves the drawer's facts (bars, guids, colour, average, tip values) from the beat's payload, or\n * from the drilldown_data of the CTA that opened the drawer (`ctaDrilldownData`).\n */\nexport type SlotDataResolver = (\n payload: Partial<InsightsPayload> | undefined,\n ctaDrilldownData?: DrilldownData,\n) => DrillDownSlotData\n\n/**\n * Builds the drawer's transactions from the beat's own (its `transaction_guids` in the store) and\n * its facts, e.g. Upcoming Bill appends its projected bill. Absent: the beat's own, as they are.\n */\nexport type BeatTransactionsResolver = (\n transactions: Transaction[],\n slotData: DrillDownSlotData,\n) => Transaction[]\n\n/** The drawer's facts from a bar chart's `instance_slot.data` (variants with no `slotData`). */\nexport const toDrillDownSlotData = ({\n series,\n category_guid,\n average_amount,\n additional_data,\n}: BarChartBlockData): DrillDownSlotData => {\n const transactionGuids = buildDataSeries(series)\n .map(({ guid }) => guid)\n .filter((guid): guid is string => !!guid)\n\n return {\n data_series: series,\n category_guid,\n average_amount,\n legends: additional_data,\n transaction_guids: transactionGuids.length ? transactionGuids : undefined,\n }\n}\n\n/** The drawer's sub-heading: the merchant name and logo. */\nexport const resolveDrillDownSubHeader = (\n payload: Partial<InsightsPayload> | undefined,\n): Subtitle | undefined => {\n if (!payload) return undefined\n\n return {\n text: payload.subtitle ?? '',\n logo: { merchant_guid: payload.logo?.guid, category_guid: '' },\n }\n}\n"],"mappings":";;;;;;AA0CA,IAAa,IAAA,CAAsB,MACjC,EAAO,CAAA,KAAgC,GAwB5B,IAAA,CAA0B,EACrC,MAAA,GACA,WAAA,GACA,KAAA,GACA,kBAAA,EAAA,MACmD;AAInD,MAAI,MAAQ,gBAAgB;AAC1B,UAAM,IAAa,EAAwB,CAAgB;AAI3D,WAAO;AAAA,MAAE,YAAA;AAAA,MAAY,WAHH,EAAe,GAAY,CAAS,EAAE,IAAA,CAAK,GAAK,MAChE,EAAW,CAAA,EAAO,QAAQ;AAAA,QAAE,GAAG;AAAA,QAAK,OAAO,EAAW,CAAA,EAAO;AAAA,MAAM,IAAI,CAEpD;AAAA,MAAW,gBAAgB,CAAC;AAAA,IAAE;AAAA,EACrD;AAIA,MAAI,MAAQ,WACV,QAAO;AAAA,IACL,YAAY,EAAgB,CAAI,EAAE,OAAA,CAAQ,MAAQ,EAAI,eAAe;AAAA,IACrE,WAAW,CAAC;AAAA,IACZ,gBAAgB,CAAC;AAAA,EACnB;AAIF,MAAI,MAAQ,OACV,QAAO;AAAA,IAAE,YAAY,CAAC;AAAA,IAAG,WAAW,CAAC;AAAA,IAAG,gBAAgB,CAAC;AAAA,EAAE;AAM7D,QAAM,IAAa,CAAC,GAAG,EAAgB,CAAI,CAAC,EAAE,KAAA,CAAM,GAAG,MACjD,CAAC,EAAE,QAAQ,CAAC,EAAE,OAAa,IAExB,IAAI,KAAK,EAAE,IAAI,EAAE,QAAQ,IAAI,IAAI,KAAK,EAAE,IAAI,EAAE,QAAQ,CAC9D;AAED,UAAQ,GAAR;AAAA,IAEE,KAAK;AACH,aAAO;AAAA,QAAE,YAAA;AAAA,QAAY,WAAW,CAAC;AAAA,QAAG,gBAAgB,EAAsB,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AAiB,GAAG,CAAC,GAAG,KAAK,IAAI,GAAG,IAAW,CAAC,CACnE;AAAA,IAAS,aAAA;AAAA,EAAY,IAGxC;AAAA,IAAE,eAAe,KAAK,IAAI,GAAG,IAAW,CAAC;AAAA,IAAG,aAAA;AAAA,EAAY;AACjE,GAmBa,IAAA,CAAgB,MAAwB,KAAK,MAAM,GAAG,CAAA,YAAe,IAAI,KAGzE,IAAA,CAAkB,MAC7B,OAAO,KAAU,YAAY,sBAAsB,KAAK,CAAK,KAAK,EAAQ,EAAS,CAAK,CAAC,IACrF,IACA,QAqBO,IAAA,CAAuB,EAClC,QAAA,GACA,eAAA,GACA,gBAAA,GACA,iBAAA,EAAA,MAC0C;AAC1C,QAAM,IAAmB,EAAgB,CAAM,EAC5C,IAAA,CAAK,EAAE,MAAA,EAAA,MAAW,CAAI,EACtB,OAAA,CAAQ,MAAyB,CAAC,CAAC,CAAI;AAE1C,SAAO;AAAA,IACL,aAAa;AAAA,IACb,eAAA;AAAA,IACA,gBAAA;AAAA,IACA,SAAS;AAAA,IACT,mBAAmB,EAAiB,SAAS,IAAmB;AAAA,EAClE;AACF,GAGa,IAAA,CACX,MACyB;AACzB,MAAK;AAEL,WAAO;AAAA,MACL,MAAM,EAAQ,YAAY;AAAA,MAC1B,MAAM;AAAA,QAAE,eAAe,EAAQ,MAAM;AAAA,QAAM,eAAe;AAAA,MAAG;AAAA,IAC/D;AACF"}
|
|
1
|
+
{"version":3,"file":"utils.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionHistoryBlock/utils.ts"],"sourcesContent":["import { format, isValid, parseISO } from 'date-fns'\n\nimport type {\n ActionDrawerState,\n Beat,\n DataSeries,\n DrilldownPayload,\n DrilldownData,\n GlobalCopy,\n InsightsPayload,\n Subtitle,\n Transaction,\n} from '../../../core'\nimport type {\n BarChartBlockData,\n DataSet,\n InsightsInstanceSlotData,\n} from '../../../core/types/InsightsInstanceSlotData'\nimport { DATE_FORMATS_INTL, formatDate } from '../../../core/constants'\nimport type { TransactionFilter } from '../../../core/stores/TransactionStore'\nimport { fromUnixUTC } from '../../../core/utils/DateUtil'\nimport {\n buildChartData,\n buildDataSeries,\n type ChartDataSeriesItem,\n} from '../../blocks/ChartBlocks/BarchartBlock/utils'\nimport { buildComparisonSeries } from '../../blocks/ChartBlocks/DoubleBarChartBlock/comparisonUtils'\nimport {\n layout,\n FALLBACK,\n DRILLDOWN_VARIANTS,\n DrillDownVariant,\n DrillDownVariantConfig,\n} from './layout'\nimport { TransactionHistoryBlock } from '../../../core/types/localization/InsightsFeedCopy'\n\ninterface DefaultSelectionProp {\n chartTabCount: number\n comparisonTabCount: number\n actionDrawer: ActionDrawerState\n beatGuid: string\n}\nexport const getDrillDownConfig = (variant?: string): DrillDownVariantConfig =>\n layout[variant as DrillDownVariant] ?? FALLBACK\n\n// The shaped chart inputs a drill-down needs, derived once from the beat's data_series. `dataSeries`\n// is the flat per-bar source (indexes the filterStrategy); `chartData` feeds the single-bar chart;\n// `comparisonBars` feeds the double-bar chart and its month tabs (empty for every other top kind).\nexport interface FlattenedDataSeries {\n dataSeries: ChartDataSeriesItem[]\n chartData: ReturnType<typeof buildChartData>\n comparisonBars: DataSet[]\n}\n\n/**\n * Shapes the beat's raw data_series into the chart inputs for the variant's top kind: the single-bar\n * family (singleBar / upcomingBill), the double bar's month columns, or a tabs-only drawer's sides.\n */\ninterface FlattenedDataSeriesInput {\n data: DataSeries | undefined\n ariaLabel: string\n top: DrillDownVariantConfig['top']\n // UpcomingBill has no data_series; it builds its bars from these instead (its paid bills).\n beatTransactions: Transaction[]\n}\n\nexport const getFlattenedDataSeries = ({\n data,\n ariaLabel,\n top,\n beatTransactions,\n}: FlattenedDataSeriesInput): FlattenedDataSeries => {\n // UpcomingBill has no backend data_series: a bar per paid bill, each named by its month\n // (buildChartData's default MONTH_SHORT) as the design labels it, or by its day when two share one.\n if (top === 'upcomingBill') {\n const dataSeries = buildUpcomingBillSeries(beatTransactions)\n const chartData = buildChartData(dataSeries, ariaLabel).map((bar, index) =>\n dataSeries[index].label ? { ...bar, label: dataSeries[index].label } : bar,\n )\n return { dataSeries, chartData, comparisonBars: [] }\n }\n\n // Tabs only: the rows are the sides of one month, not bars. They keep their wire order, which the\n // side tabs and the filter's dataSeries[subIndex] both index; there is no chart and no month tab.\n if (top === 'tabsOnly') {\n return {\n dataSeries: buildDataSeries(data).filter((row) => row.localized_label),\n chartData: [],\n comparisonBars: [],\n }\n }\n\n // List: one account over a window the strategy reads from the beat; no series, chart or tabs.\n if (top === 'list') {\n return { dataSeries: [], chartData: [], comparisonBars: [] }\n }\n\n // The month families: the backend sends data_series newest-first, so normalize it date-ascending\n // here. chartData/tabs and the filter's dataSeries[selectedIndex] indexing both read this one\n // array, so they stay aligned and the last tab is the most recent month.\n const dataSeries = [...buildDataSeries(data)].sort((a, b) => {\n if (!a.date || !b.date) return 0\n\n return new Date(a.date).getTime() - new Date(b.date).getTime()\n })\n\n switch (top) {\n // Double bar: comparison beats build paired month columns (with their guids) instead of chartData.\n case 'doubleBar':\n return { dataSeries, chartData: [], comparisonBars: buildComparisonSeries(data, ariaLabel) }\n // Single bar draws chartData as bars; month tabs reads the same chartData for its tabs only.\n case 'singleBar':\n case 'monthTabs':\n return { dataSeries, chartData: buildChartData(dataSeries, ariaLabel), comparisonBars: [] }\n }\n}\n\n// One bar in the UpcomingBill chart. `date` is 'yyyy-MM-dd' so buildChartData/parseISO can read it.\n// `label` is set only when two bars share a month, so they are named by their day.\nexport interface UpcomingBillBar {\n date: string\n amount: number\n guid: string\n category_guid?: string\n label?: string\n}\n\n// The bill's UTC calendar day, the day the transaction list heads its row with\n// (fromUnixUTCToDayOfWeekAndDate); a local-time date put a UTC-midnight bill on the day before.\nconst toUpcomingBillBar = (transaction: Transaction): UpcomingBillBar => ({\n date: format(fromUnixUTC(transaction.date), 'yyyy-MM-dd'),\n amount: transaction.amount,\n guid: transaction.guid,\n category_guid: transaction.top_level_category_guid ?? transaction.category_guid,\n})\n\n/**\n * UpcomingBill has no data_series: build the bar series from its paid bills, oldest first, so the\n * drawer opens on the latest (Figma: history only). Bills are de-duped by date, each keeping its real\n * guid so the guid filter finds it. Bars are named by month; when two share a month, every bar is\n * named by its day so no two tabs read the same.\n */\nexport const buildUpcomingBillSeries = (transactions: Transaction[] = []): UpcomingBillBar[] => {\n const sorted = [...transactions].sort((a, b) => a.date - b.date)\n\n const seenDates = new Set<number>()\n const history: UpcomingBillBar[] = []\n for (const transaction of sorted) {\n if (seenDates.has(transaction.date)) continue\n seenDates.add(transaction.date)\n history.push(toUpcomingBillBar(transaction))\n }\n\n const months = history.map((bar) => bar.date.slice(0, 7))\n if (new Set(months).size === months.length) return history\n\n return history.map((bar) => ({\n ...bar,\n label: formatDate(parseISO(bar.date), DATE_FORMATS_INTL.MONTH_DAY),\n }))\n}\n\nexport const getDrawerHeaderTitle = (\n variant: string | null | undefined,\n copy: GlobalCopy,\n beat?: Beat,\n): string => {\n const transactionHistoryTitle = copy.insights_feed?.general?.transaction_history_title ?? ''\n const drawerTitleCopy = copy.insights_feed?.transaction_history_block as TransactionHistoryBlock\n\n if (variant === DRILLDOWN_VARIANTS.TRANSACTION) return transactionHistoryTitle\n\n // Savings Account Balances Summary: the drawer reads as the card it opens from (\"Savings\n // Contributions\", Figma 1135:50175), whatever the host's drawer copy says.\n const beatTitle = beat?.insights_payload?.title\n if (variant === DRILLDOWN_VARIANTS.ACCOUNT_BALANCE && beatTitle) return beatTitle\n\n // Safely access the drawer title from transaction_history_block. Debt to Income's ditto variant\n // (debt_to_income) keeps the host copy's existing monthly_debt_to_income_drawer_title. Savings to\n // Income's variant is savings_to_income, so it resolves savings_to_income_drawer_title through the\n // generic path below (it deliberately drops the monthly_ prefix; do not re-add it).\n const key = (\n variant === DRILLDOWN_VARIANTS.DEBT_TO_INCOME\n ? 'monthly_debt_to_income_drawer_title'\n : `${variant}_drawer_title`\n ) as keyof TransactionHistoryBlock\n return (drawerTitleCopy?.[key] as string) ?? transactionHistoryTitle\n}\n\nexport const toStoreFilter = (\n filter: TransactionFilter,\n defaults: { allAccountGuids: string[]; displayedDateRange: { start: Date; end: Date } },\n): TransactionFilter => ({\n accounts: filter.accounts ?? defaults.allAccountGuids,\n dateRange: filter.dateRange ?? defaults.displayedDateRange,\n custom: filter.custom ?? (() => true),\n showSplits: filter.showSplits ?? false,\n})\n\nexport const getDefaultSelection = ({\n chartTabCount,\n comparisonTabCount,\n actionDrawer,\n beatGuid,\n}: DefaultSelectionProp): { chartBarIndex: number; subTabIndex: number } => {\n // A double-bar drawer's tabs are its comparison columns; every other drawer's are its chart bars.\n const tabCount = comparisonTabCount || chartTabCount\n const openedViaChartBar = actionDrawer.guid === beatGuid && actionDrawer.trigger === 'chartBar'\n\n // actionDrawer.context is an opaque `unknown` bag; narrow it to the shape the chart blocks write.\n const context = actionDrawer.context as DrilldownPayload | undefined\n const subTabIndex = openedViaChartBar ? (context?.tabIndex ?? 0) : 0\n\n if (openedViaChartBar) {\n const clamped = Math.min(Math.max(context?.chartBarIndex ?? 0, 0), Math.max(0, tabCount - 1))\n return { chartBarIndex: clamped, subTabIndex }\n }\n\n return { chartBarIndex: Math.max(0, tabCount - 1), subTabIndex }\n}\n\n/**\n * The drawer's facts: the generic slot facts plus the bar chart's average, and the merchant a\n * variant's tip names.\n */\nexport type DrillDownSlotData = InsightsInstanceSlotData &\n Pick<BarChartBlockData, 'average_amount'> & {\n merchant_name?: string\n // Merchant Budget: the merchant whose transactions the drawer lists.\n merchant_guid?: string\n // Monthly Deposit Summary: the deposits on the Income sub-tab, across every month.\n income_transaction_guids?: string[]\n // A drawer's own sub-tab names when the card's legend rows aren't the chart's (Income / Other Deposits).\n sub_tab_labels?: string[]\n }\n\n// parseISO rejects impossible days such as 2026-02-30.\nexport const calendarDateOf = (value: unknown): string | undefined =>\n typeof value === 'string' && /^\\d{4}-\\d{2}-\\d{2}$/.test(value) && isValid(parseISO(value))\n ? value\n : undefined\n\n/**\n * Resolves the drawer's facts (bars, guids, colour, average, tip values) from the beat's payload, or\n * from the drilldown_data of the CTA that opened the drawer (`ctaDrilldownData`).\n */\nexport type SlotDataResolver = (\n payload: Partial<InsightsPayload> | undefined,\n ctaDrilldownData?: DrilldownData,\n) => DrillDownSlotData\n\n/** The drawer's facts from a bar chart's `instance_slot.data` (variants with no `slotData`). */\nexport const toDrillDownSlotData = ({\n series,\n category_guid,\n average_amount,\n additional_data,\n}: BarChartBlockData): DrillDownSlotData => {\n const transactionGuids = buildDataSeries(series)\n .map(({ guid }) => guid)\n .filter((guid): guid is string => !!guid)\n\n return {\n data_series: series,\n category_guid,\n average_amount,\n legends: additional_data,\n transaction_guids: transactionGuids.length ? transactionGuids : undefined,\n }\n}\n\n/** The drawer's sub-heading: the merchant name and logo. */\nexport const resolveDrillDownSubHeader = (\n payload: Partial<InsightsPayload> | undefined,\n): Subtitle | undefined => {\n if (!payload) return undefined\n\n return {\n text: payload.subtitle ?? '',\n logo: { merchant_guid: payload.logo?.guid, category_guid: '' },\n }\n}\n"],"mappings":";;;;;;AA0CA,IAAa,IAAA,CAAsB,MACjC,EAAO,CAAA,KAAgC,GAuB5B,IAAA,CAA0B,EACrC,MAAA,GACA,WAAA,GACA,KAAA,GACA,kBAAA,EAAA,MACmD;AAGnD,MAAI,MAAQ,gBAAgB;AAC1B,UAAM,IAAa,EAAwB,CAAgB;AAI3D,WAAO;AAAA,MAAE,YAAA;AAAA,MAAY,WAHH,EAAe,GAAY,CAAS,EAAE,IAAA,CAAK,GAAK,MAChE,EAAW,CAAA,EAAO,QAAQ;AAAA,QAAE,GAAG;AAAA,QAAK,OAAO,EAAW,CAAA,EAAO;AAAA,MAAM,IAAI,CAEpD;AAAA,MAAW,gBAAgB,CAAC;AAAA,IAAE;AAAA,EACrD;AAIA,MAAI,MAAQ,WACV,QAAO;AAAA,IACL,YAAY,EAAgB,CAAI,EAAE,OAAA,CAAQ,MAAQ,EAAI,eAAe;AAAA,IACrE,WAAW,CAAC;AAAA,IACZ,gBAAgB,CAAC;AAA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,QAAA,GACA,eAAA,GACA,gBAAA,GACA,iBAAA,EAAA,MAC0C;AAC1C,QAAM,IAAmB,EAAgB,CAAM,EAC5C,IAAA,CAAK,EAAE,MAAA,EAAA,MAAW,CAAI,EACtB,OAAA,CAAQ,MAAyB,CAAC,CAAC,CAAI;AAE1C,SAAO;AAAA,IACL,aAAa;AAAA,IACb,eAAA;AAAA,IACA,gBAAA;AAAA,IACA,SAAS;AAAA,IACT,mBAAmB,EAAiB,SAAS,IAAmB;AAAA,EAClE;AACF,GAGa,IAAA,CACX,MACyB;AACzB,MAAK;AAEL,WAAO;AAAA,MACL,MAAM,EAAQ,YAAY;AAAA,MAC1B,MAAM;AAAA,QAAE,eAAe,EAAQ,MAAM;AAAA,QAAM,eAAe;AAAA,MAAG;AAAA,IAC/D;AACF"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ACCOUNT_CONNECTED_GRADIENT as
|
|
1
|
+
import { ACCOUNT_CONNECTED_GRADIENT as n, getPrimaryWashGradient as e } from "../../../components/celebrationGradients.es.js";
|
|
2
2
|
var o = {
|
|
3
3
|
AccountConnect: "account_connect",
|
|
4
4
|
AccountConnected: "account_connected",
|
|
5
5
|
SwitchDirectDeposit: "switch_direct_deposit"
|
|
6
|
-
}, r = (
|
|
7
|
-
const
|
|
8
|
-
backgroundImage:
|
|
6
|
+
}, r = (c) => {
|
|
7
|
+
const t = {
|
|
8
|
+
backgroundImage: e(c),
|
|
9
9
|
bgcolor: "background.paper",
|
|
10
10
|
badgeBgColor: "common.black",
|
|
11
11
|
badgeIconColor: "common.white",
|
|
@@ -15,11 +15,11 @@ var o = {
|
|
|
15
15
|
};
|
|
16
16
|
return {
|
|
17
17
|
[o.AccountConnect]: {
|
|
18
|
-
...
|
|
18
|
+
...t,
|
|
19
19
|
badgeIcon: "link"
|
|
20
20
|
},
|
|
21
21
|
[o.AccountConnected]: {
|
|
22
|
-
backgroundImage:
|
|
22
|
+
backgroundImage: n,
|
|
23
23
|
bgcolor: "background.paper",
|
|
24
24
|
badgeBgColor: "success.main",
|
|
25
25
|
badgeIcon: "check",
|
|
@@ -30,7 +30,8 @@ var o = {
|
|
|
30
30
|
showConfetti: !0
|
|
31
31
|
},
|
|
32
32
|
[o.SwitchDirectDeposit]: {
|
|
33
|
-
...
|
|
33
|
+
...t,
|
|
34
|
+
backgroundImage: e(c, 127),
|
|
34
35
|
badgeIcon: "arrow_right_alt"
|
|
35
36
|
}
|
|
36
37
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ComponentBlocks/AccountSwitchBlock/layout.ts"],"sourcesContent":["import type { Theme } from '@mui/material/styles'\n\nimport {\n ACCOUNT_CONNECTED_GRADIENT,\n getPrimaryWashGradient,\n} from '../../../components/celebrationGradients'\n\n/**\n * Account Switch block variants, keyed by the backend `instance_slot.variant`. All share\n * `TransferLogoCard`; only the slot surface, center badge and connector dots differ.\n *\n * - `AccountConnect` — Discovered Accounts pending: blue gradient, black link badge.\n * - `AccountConnected` — Discovered Accounts success: pink wash, confetti, check badge.\n * - `SwitchDirectDeposit` — Switch Direct Deposit pending: the same look with an arrow badge.\n * Its complete state is a different layout, served by `direct_deposit_block`.\n */\nexport const accountSwitchVariant = {\n AccountConnect: 'account_connect',\n AccountConnected: 'account_connected',\n SwitchDirectDeposit: 'switch_direct_deposit',\n} as const\n\nexport type AccountSwitchVariant = (typeof accountSwitchVariant)[keyof typeof accountSwitchVariant]\n\nexport interface AccountSwitchLayoutConfig {\n /** Slot surface color token. */\n bgcolor: string\n /** Optional gradient layered over `bgcolor`. */\n backgroundImage?: string\n /** Center badge background color token. */\n badgeBgColor: string\n /** mx-icons glyph rendered in the center badge. */\n badgeIcon: string\n /** Color token for the badge glyph. */\n badgeIconColor: string\n /** Badge glyph size in px. */\n badgeIconSize: number\n /** Connector-dot color token. */\n dotColor: string\n /** Enlarge the inner connector dots (6px vs 4px). */\n hasBigDots: boolean\n /** Confetti burst filling the slot (success states). */\n showConfetti?: boolean\n}\n\n/** Per-variant `TransferLogoCard` props (mirrors DetailedAccountBlock's `getLayoutConfig`). */\nexport const getLayoutConfig = (\n theme: Theme,\n): Record<AccountSwitchVariant, AccountSwitchLayoutConfig> => {\n // Figma's pending look, shared by Discovered Accounts and Switch Direct Deposit: the blue wash,\n // text.secondary dots with the bigger inner pair, and a black badge with a 16px white glyph.\n const pending = {\n backgroundImage: getPrimaryWashGradient(theme),\n bgcolor: 'background.paper',\n badgeBgColor: 'common.black',\n badgeIconColor: 'common.white',\n badgeIconSize: 16,\n dotColor: 'text.secondary',\n hasBigDots: true,\n }\n\n return {\n [accountSwitchVariant.AccountConnect]: { ...pending, badgeIcon: 'link' },\n [accountSwitchVariant.AccountConnected]: {\n backgroundImage: ACCOUNT_CONNECTED_GRADIENT,\n bgcolor: 'background.paper',\n badgeBgColor: 'success.main',\n // Figma \"Common/Check\": a bare 20px check on the solid success badge (not `check_circle`).\n badgeIcon: 'check',\n badgeIconColor: 'common.white',\n badgeIconSize: 20,\n dotColor: 'text.secondary',\n hasBigDots: true,\n showConfetti: true,\n },\n [accountSwitchVariant.SwitchDirectDeposit]: {
|
|
1
|
+
{"version":3,"file":"layout.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ComponentBlocks/AccountSwitchBlock/layout.ts"],"sourcesContent":["import type { Theme } from '@mui/material/styles'\n\nimport {\n ACCOUNT_CONNECTED_GRADIENT,\n getPrimaryWashGradient,\n} from '../../../components/celebrationGradients'\n\n/**\n * Account Switch block variants, keyed by the backend `instance_slot.variant`. All share\n * `TransferLogoCard`; only the slot surface, center badge and connector dots differ.\n *\n * - `AccountConnect` — Discovered Accounts pending: blue gradient, black link badge.\n * - `AccountConnected` — Discovered Accounts success: pink wash, confetti, check badge.\n * - `SwitchDirectDeposit` — Switch Direct Deposit pending: the same look with an arrow badge.\n * Its complete state is a different layout, served by `direct_deposit_block`.\n */\nexport const accountSwitchVariant = {\n AccountConnect: 'account_connect',\n AccountConnected: 'account_connected',\n SwitchDirectDeposit: 'switch_direct_deposit',\n} as const\n\nexport type AccountSwitchVariant = (typeof accountSwitchVariant)[keyof typeof accountSwitchVariant]\n\nexport interface AccountSwitchLayoutConfig {\n /** Slot surface color token. */\n bgcolor: string\n /** Optional gradient layered over `bgcolor`. */\n backgroundImage?: string\n /** Center badge background color token. */\n badgeBgColor: string\n /** mx-icons glyph rendered in the center badge. */\n badgeIcon: string\n /** Color token for the badge glyph. */\n badgeIconColor: string\n /** Badge glyph size in px. */\n badgeIconSize: number\n /** Connector-dot color token. */\n dotColor: string\n /** Enlarge the inner connector dots (6px vs 4px). */\n hasBigDots: boolean\n /** Confetti burst filling the slot (success states). */\n showConfetti?: boolean\n}\n\n/** Per-variant `TransferLogoCard` props (mirrors DetailedAccountBlock's `getLayoutConfig`). */\nexport const getLayoutConfig = (\n theme: Theme,\n): Record<AccountSwitchVariant, AccountSwitchLayoutConfig> => {\n // Figma's pending look, shared by Discovered Accounts and Switch Direct Deposit: the blue wash,\n // text.secondary dots with the bigger inner pair, and a black badge with a 16px white glyph.\n const pending = {\n backgroundImage: getPrimaryWashGradient(theme),\n bgcolor: 'background.paper',\n badgeBgColor: 'common.black',\n badgeIconColor: 'common.white',\n badgeIconSize: 16,\n dotColor: 'text.secondary',\n hasBigDots: true,\n }\n\n return {\n [accountSwitchVariant.AccountConnect]: { ...pending, badgeIcon: 'link' },\n [accountSwitchVariant.AccountConnected]: {\n backgroundImage: ACCOUNT_CONNECTED_GRADIENT,\n bgcolor: 'background.paper',\n badgeBgColor: 'success.main',\n // Figma \"Common/Check\": a bare 20px check on the solid success badge (not `check_circle`).\n badgeIcon: 'check',\n badgeIconColor: 'common.white',\n badgeIconSize: 20,\n dotColor: 'text.secondary',\n hasBigDots: true,\n showConfetti: true,\n },\n // Figma 1941:167577: the Switch default's wash is at 127°.\n [accountSwitchVariant.SwitchDirectDeposit]: {\n ...pending,\n backgroundImage: getPrimaryWashGradient(theme, 127),\n badgeIcon: 'arrow_right_alt',\n },\n }\n}\n"],"mappings":";AAgBA,IAAa,IAAuB;AAAA,EAClC,gBAAgB;AAAA,EAChB,kBAAkB;AAAA,EAClB,qBAAqB;AACvB,GA0Ba,IAAA,CACX,MAC4D;AAG5D,QAAM,IAAU;AAAA,IACd,iBAAiB,EAAuB,CAAK;AAAA,IAC7C,SAAS;AAAA,IACT,cAAc;AAAA,IACd,gBAAgB;AAAA,IAChB,eAAe;AAAA,IACf,UAAU;AAAA,IACV,YAAY;AAAA,EACd;AAEA,SAAO;AAAA,IACJ,CAAA,EAAqB,cAAA,GAAiB;AAAA,MAAE,GAAG;AAAA,MAAS,WAAW;AAAA,IAAO;AAAA,IACtE,CAAA,EAAqB,gBAAA,GAAmB;AAAA,MACvC,iBAAiB;AAAA,MACjB,SAAS;AAAA,MACT,cAAc;AAAA,MAEd,WAAW;AAAA,MACX,gBAAgB;AAAA,MAChB,eAAe;AAAA,MACf,UAAU;AAAA,MACV,YAAY;AAAA,MACZ,cAAc;AAAA,IAChB;AAAA,IAEC,CAAA,EAAqB,mBAAA,GAAsB;AAAA,MAC1C,GAAG;AAAA,MACH,iBAAiB,EAAuB,GAAO,GAAG;AAAA,MAClD,WAAW;AAAA,IACb;AAAA,EACF;AACF"}
|
package/dist/insights-v2/blocks/ComponentBlocks/SavingsSummaryBlock/SavingsSummaryBlock.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SavingsSummaryBlock.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ComponentBlocks/SavingsSummaryBlock/SavingsSummaryBlock.tsx"],"sourcesContent":["import Box from '@mui/material/Box'\nimport Stack from '@mui/material/Stack'\n\nimport { H2, Text } from '@mxenabled/mxui'\n\nimport { useGlobalCopyStore } from '../../../../common'\nimport { formatWholeCurrency } from '../../../../core/utils/NumberFormatting'\nimport { ThemedSVGImage } from '../../../components/chartblocks/ThemedSVGImage'\nimport { ReactComponent as BrushStroke } from '../../../components/shared/images/SaveEnoughToLiveOnBottom.svg'\nimport { ReactComponent as CalendarGraphic } from '../../../components/shared/images/SaveEnoughToLiveOnTop.svg'\nimport { resolveVariantConfig } from '../../resolveVariantConfig'\nimport { asNumber, asText, slotOrFlat } from '../../slotReaders'\nimport type { BlockProps } from '../../types'\nimport { SAVINGS_SUMMARY_LAYOUT, savingsSummaryBlockVariant } from './layout'\n\nconst Row = ({ label, amount }: { label: string; amount: number }) => (\n <Stack\n direction=\"row\"\n sx={{ alignItems: 'center', gap: 16, justifyContent: 'space-between', minHeight: 40, px: 16 }}\n >\n <Text color=\"text.secondary\" component=\"dt\" variant=\"caption\">\n {label}\n </Text>\n <Text bold={true} color=\"text.primary\" component=\"dd\" sx={{ m: 0 }} variant=\"body2\">\n {formatWholeCurrency(amount)}\n </Text>\n </Stack>\n)\n\nconst SavingsSummaryBlock = ({ payload }: BlockProps) => {\n const copy = useGlobalCopyStore().insights_feed?.make_transfer\n const balanceLabel = copy?.available_balance_text\n const spendLabel = copy?.avg_monthly_spend_text\n\n const { instance_slot = {} } = payload\n const { showCalendar } = resolveVariantConfig(\n SAVINGS_SUMMARY_LAYOUT,\n instance_slot.variant,\n savingsSummaryBlockVariant.NoIllustration,\n 'SavingsSummaryBlock',\n )\n const balance = asNumber(slotOrFlat(instance_slot, 'available_balance'))\n const spend = asNumber(slotOrFlat(instance_slot, 'avg_monthly_spend'))\n const timePeriod = asText(slotOrFlat(instance_slot, 'time_period'))\n const hasTimePeriod = !!timePeriod\n\n // Both figures need a label and a real number; never show a made-up $0.\n if (!balanceLabel || !spendLabel || balance === undefined || spend === undefined) {\n return null\n }\n\n return (\n <Stack sx={{ alignItems: 'center', gap: showCalendar ? 20 : 12, px: 16, width: '100%' }}>\n {(showCalendar || hasTimePeriod) && (\n <Stack sx={{ alignItems: 'center' }}>\n {showCalendar && (\n <ThemedSVGImage\n divProps={{ style: { maxWidth: '100%', width: 264 } }}\n image={CalendarGraphic}\n />\n )}\n {hasTimePeriod && (\n <Box sx={{ display: 'grid', mt: showCalendar ? -58 : 0, placeItems: 'center' }}>\n <ThemedSVGImage\n divProps={{\n style: { gridArea: '1 / 1', lineHeight: 0, maxWidth: 'none', width: 262 },\n }}\n image={BrushStroke}\n />\n <H2 sx={{ color: 'neutral.contrastText', gridArea: '1 / 1', textAlign: 'center' }}>\n {timePeriod}\n </H2>\n </Box>\n )}\n </Stack>\n )}\n <Stack\n component=\"dl\"\n sx={{\n '& > div + div': { borderTop: 1, borderColor: 'divider' },\n // Drawn inside, so the two 40px rows make Figma's 80px table.\n boxShadow: (theme) => `inset 0 0 0 1px ${theme.palette.divider}`,\n borderRadius:
|
|
1
|
+
{"version":3,"file":"SavingsSummaryBlock.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ComponentBlocks/SavingsSummaryBlock/SavingsSummaryBlock.tsx"],"sourcesContent":["import Box from '@mui/material/Box'\nimport Stack from '@mui/material/Stack'\n\nimport { H2, Text } from '@mxenabled/mxui'\n\nimport { useGlobalCopyStore } from '../../../../common'\nimport { formatWholeCurrency } from '../../../../core/utils/NumberFormatting'\nimport { ThemedSVGImage } from '../../../components/chartblocks/ThemedSVGImage'\nimport { ReactComponent as BrushStroke } from '../../../components/shared/images/SaveEnoughToLiveOnBottom.svg'\nimport { ReactComponent as CalendarGraphic } from '../../../components/shared/images/SaveEnoughToLiveOnTop.svg'\nimport { resolveVariantConfig } from '../../resolveVariantConfig'\nimport { asNumber, asText, slotOrFlat } from '../../slotReaders'\nimport type { BlockProps } from '../../types'\nimport { SAVINGS_SUMMARY_LAYOUT, savingsSummaryBlockVariant } from './layout'\n\nconst Row = ({ label, amount }: { label: string; amount: number }) => (\n <Stack\n direction=\"row\"\n sx={{ alignItems: 'center', gap: 16, justifyContent: 'space-between', minHeight: 40, px: 16 }}\n >\n <Text color=\"text.secondary\" component=\"dt\" variant=\"caption\">\n {label}\n </Text>\n <Text bold={true} color=\"text.primary\" component=\"dd\" sx={{ m: 0 }} variant=\"body2\">\n {formatWholeCurrency(amount)}\n </Text>\n </Stack>\n)\n\nconst SavingsSummaryBlock = ({ payload }: BlockProps) => {\n const copy = useGlobalCopyStore().insights_feed?.make_transfer\n const balanceLabel = copy?.available_balance_text\n const spendLabel = copy?.avg_monthly_spend_text\n\n const { instance_slot = {} } = payload\n const { showCalendar } = resolveVariantConfig(\n SAVINGS_SUMMARY_LAYOUT,\n instance_slot.variant,\n savingsSummaryBlockVariant.NoIllustration,\n 'SavingsSummaryBlock',\n )\n const balance = asNumber(slotOrFlat(instance_slot, 'available_balance'))\n const spend = asNumber(slotOrFlat(instance_slot, 'avg_monthly_spend'))\n const timePeriod = asText(slotOrFlat(instance_slot, 'time_period'))\n const hasTimePeriod = !!timePeriod\n\n // Both figures need a label and a real number; never show a made-up $0.\n if (!balanceLabel || !spendLabel || balance === undefined || spend === undefined) {\n return null\n }\n\n return (\n <Stack sx={{ alignItems: 'center', gap: showCalendar ? 20 : 12, px: 16, width: '100%' }}>\n {(showCalendar || hasTimePeriod) && (\n <Stack sx={{ alignItems: 'center' }}>\n {showCalendar && (\n <ThemedSVGImage\n divProps={{ style: { maxWidth: '100%', width: 264 } }}\n image={CalendarGraphic}\n />\n )}\n {hasTimePeriod && (\n <Box sx={{ display: 'grid', mt: showCalendar ? -58 : 0, placeItems: 'center' }}>\n <ThemedSVGImage\n divProps={{\n style: { gridArea: '1 / 1', lineHeight: 0, maxWidth: 'none', width: 262 },\n }}\n image={BrushStroke}\n />\n <H2 sx={{ color: 'neutral.contrastText', gridArea: '1 / 1', textAlign: 'center' }}>\n {timePeriod}\n </H2>\n </Box>\n )}\n </Stack>\n )}\n <Stack\n component=\"dl\"\n sx={{\n '& > div + div': { borderTop: 1, borderColor: 'divider' },\n // Drawn inside, so the two 40px rows make Figma's 80px table.\n boxShadow: (theme) => `inset 0 0 0 1px ${theme.palette.divider}`,\n borderRadius: 2,\n m: 0,\n width: '100%',\n }}\n >\n <Row amount={balance} label={balanceLabel} />\n <Row amount={spend} label={spendLabel} />\n </St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-12,7 +12,7 @@ import { Theme } from '@mui/material/styles';
|
|
|
12
12
|
* - ERROR_WASH_GRADIENT: low balance, off-track status.
|
|
13
13
|
* - FEES_WASH_GRADIENT: fees and interest charges.
|
|
14
14
|
* - PRIMARY_TILE_GRADIENTS / SUCCESS_TILE_GRADIENTS: blue and green tiles, per theme mode.
|
|
15
|
-
* - getPrimaryWashGradient(theme): pending connect / detected subscription, from the palette.
|
|
15
|
+
* - getPrimaryWashGradient(theme, angle?): pending connect / detected subscription, from the palette.
|
|
16
16
|
*/
|
|
17
17
|
/**
|
|
18
18
|
* Warm → lime accent wash at 20% opacity. Used as a tinted background behind
|
|
@@ -58,6 +58,7 @@ export declare const SUCCESS_TILE_GRADIENTS: {
|
|
|
58
58
|
};
|
|
59
59
|
/**
|
|
60
60
|
* Blue slot wash behind a pending connect / detected-subscription row: `primary.light` →
|
|
61
|
-
* `primary.main` at 75% over paper, built from the live palette so it follows the theme.
|
|
61
|
+
* `primary.main` at 75% over paper, built from the live palette so it follows the theme. Figma's
|
|
62
|
+
* angle follows the slot's shape, so a slot passes its own.
|
|
62
63
|
*/
|
|
63
|
-
export declare const getPrimaryWashGradient: ({ palette }: Theme) => string;
|
|
64
|
+
export declare const getPrimaryWashGradient: ({ palette }: Theme, angleDeg?: number) => string;
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { alpha as a } from "@mui/material/styles";
|
|
2
|
-
var
|
|
2
|
+
var d = "linear-gradient(200.73deg, rgba(255, 223, 152, 0.2) 1.86%, rgba(173, 248, 43, 0.2) 101.54%)", E = "linear-gradient(257deg, rgba(255, 224, 153, 0.2) 1.86%, rgba(173, 248, 44, 0.2) 101.54%)", n = "linear-gradient(200.73deg, rgba(255, 223, 152, 0.2) 1.86%, rgba(255, 128, 229, 0.2) 101.54%)", e = (r) => `linear-gradient(${r}deg, rgba(255, 224, 153, 0.2) 1.86%, rgba(255, 129, 230, 0.2) 101.54%)`, A = e(200.73), t = "linear-gradient(201deg, rgba(255, 170, 0, 0.25) 1.86%, rgba(255, 68, 0, 0.25) 101.54%)", _ = "linear-gradient(256.82deg, rgba(255, 47, 40, 0.2) 1.86%, rgba(255, 0, 72, 0.2) 101.54%)", R = "linear-gradient(256.82deg, rgba(227, 39, 39, 0.2) 1.86%, rgba(255, 123, 0, 0.2) 101.54%)", T = {
|
|
3
3
|
light: "linear-gradient(180deg, #A0B9F8 0%, #2C64EF 100%)",
|
|
4
4
|
dark: "linear-gradient(180deg, #1F46A7 0%, #6B92F4 100%)"
|
|
5
|
-
},
|
|
5
|
+
}, I = {
|
|
6
6
|
light: "linear-gradient(180deg, #94C9B7 0%, #12875E 100%)",
|
|
7
7
|
dark: "linear-gradient(180deg, #0D5F42 0%, #59AB8E 100%)"
|
|
8
|
-
},
|
|
8
|
+
}, l = ({ palette: r }, g = 173) => `linear-gradient(${g}deg, ${a(r.primary.light, 0.75)} 46.41%, ${a(r.primary.main, 0.75)} 78.14%)`;
|
|
9
9
|
export {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
A as ACCOUNT_CONNECTED_GRADIENT,
|
|
11
|
+
n as CELEBRATION_GRADIENT,
|
|
12
|
+
E as DIRECT_DEPOSIT_COMPLETE_GRADIENT,
|
|
13
|
+
_ as ERROR_WASH_GRADIENT,
|
|
14
|
+
R as FEES_WASH_GRADIENT,
|
|
15
|
+
T as PRIMARY_TILE_GRADIENTS,
|
|
16
|
+
I as SUCCESS_TILE_GRADIENTS,
|
|
17
|
+
d as WARM_LIME_ACCENT_GRADIENT,
|
|
18
|
+
t as WARNING_WASH_GRADIENT,
|
|
19
|
+
e as celebrateGradient,
|
|
20
|
+
l as getPrimaryWashGradient
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
//# sourceMappingURL=celebrationGradients.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"celebrationGradients.es.js","names":[],"sources":["../../../src/insights-v2/components/celebrationGradients.ts"],"sourcesContent":["import { alpha, type Theme } from '@mui/material/styles'\n\n/**\n * Decorative slot washes shared by the block layouts and the presentational components, so\n * one source holds each gradient. The 20%–25% washes layer over `background.paper` via\n * `backgroundImage`; `DISCOVERED_ACCOUNTS_GRADIENT` and the tile gradients are opaque and stand alone.\n *\n * - WARM_LIME_ACCENT_GRADIENT: merchant categorization and deposit celebration states.\n * - DIRECT_DEPOSIT_COMPLETE_GRADIENT: the direct deposit complete tile.\n * - CELEBRATION_GRADIENT / ACCOUNT_CONNECTED_GRADIENT: balance milestones, account connected.\n * - celebrateGradient(angle): Figma's Celebrate Gradient at any angle.\n * - WARNING_WASH_GRADIENT: a flagged charge (Unexpected Subscription Payment).\n * - ERROR_WASH_GRADIENT: low balance, off-track status.\n * - FEES_WASH_GRADIENT: fees and interest charges.\n * - PRIMARY_TILE_GRADIENTS / SUCCESS_TILE_GRADIENTS: blue and green tiles, per theme mode.\n * - getPrimaryWashGradient(theme): pending connect / detected subscription, from the palette.\n */\n\n/**\n * Warm → lime accent wash at 20% opacity. Used as a tinted background behind\n * merchant categorization highlights and deposit celebration callouts.\n */\nexport const WARM_LIME_ACCENT_GRADIENT =\n 'linear-gradient(200.73deg, rgba(255, 223, 152, 0.2) 1.86%, rgba(173, 248, 43, 0.2) 101.54%)'\n\n/**\n * Warm → lime wash at 20% behind the Direct Deposit complete tile (Set Up / Switch Direct Deposit).\n * Figma gives it its own angle and stops, so it does not reuse WARM_LIME_ACCENT_GRADIENT.\n */\nexport const DIRECT_DEPOSIT_COMPLETE_GRADIENT =\n 'linear-gradient(257deg, rgba(255, 224, 153, 0.2) 1.86%, rgba(173, 248, 44, 0.2) 101.54%)'\n\n/** Warm → pink wash behind balance/savings milestones. */\nexport const CELEBRATION_GRADIENT =\n 'linear-gradient(200.73deg, rgba(255, 223, 152, 0.2) 1.86%, rgba(255, 128, 229, 0.2) 101.54%)'\n\n/** Figma Celebrate Gradient; its angle varies per slot. */\nexport const celebrateGradient = (angleDeg: number) =>\n `linear-gradient(${angleDeg}deg, rgba(255, 224, 153, 0.2) 1.86%, rgba(255, 129, 230, 0.2) 101.54%)`\n\n/** Peach → pink gradient for Discovered Accounts success state. */\nexport const DISCOVERED_ACCOUNTS_GRADIENT =\n 'linear-gradient(200.73deg, rgba(255, 224, 153, 1) 1.86%, rgba(255, 129, 230, 1) 101.54%)'\n\n/**\n * Warm → pink wash at 20% opacity for the account-connected success state.\n * Layer over `background.paper` (the Figma spec's `#FFF` base), not the\n * `background` shorthand — a 20% gradient over transparency renders wrong.\n */\nexport const ACCOUNT_CONNECTED_GRADIENT = celebrateGradient(200.73)\n\n/**\n * Orange → red-orange wash at 25% opacity behind a flagged charge (Unexpected Subscription\n * Payment). Figma \"Warning Gradient 1\": a bespoke two-stop blend with no palette token, so it\n * stays a literal like the other washes here rather than being derived from `palette.warning`.\n */\nexport const WARNING_WASH_GRADIENT =\n 'linear-gradient(201deg, rgba(255, 170, 0, 0.25) 1.86%, rgba(255, 68, 0, 0.25) 101.54%)'\n\n/** Red wash at 20%: low balance, off-track status. */\nexport const ERROR_WASH_GRADIENT =\n 'linear-gradient(256.82deg, rgba(255, 47, 40, 0.2) 1.86%, rgba(255, 0, 72, 0.2) 101.54%)'\n\n/** Red → orange wash at 20%: fees and interest charges. */\nexport const FEES_WASH_GRADIENT =\n 'linear-gradient(256.82deg, rgba(227, 39, 39, 0.2) 1.86%, rgba(255, 123, 0, 0.2) 101.54%)'\n\n/** Blue tile, per theme mode (Missing Interest Rate before the rate is added). */\nexport const PRIMARY_TILE_GRADIENTS = {\n light: 'linear-gradient(180deg, #A0B9F8 0%, #2C64EF 100%)',\n dark: 'linear-gradient(180deg, #1F46A7 0%, #6B92F4 100%)',\n} as const\n\n/** Green tile, per theme mode (Missing Interest Rate once the rate is added). */\nexport const SUCCESS_TILE_GRADIENTS = {\n light: 'linear-gradient(180deg, #94C9B7 0%, #12875E 100%)',\n dark: 'linear-gradient(180deg, #0D5F42 0%, #59AB8E 100%)',\n} as const\n\n/**\n * Blue slot wash behind a pending connect / detected-subscription row: `primary.light` →\n * `primary.main` at 75% over paper, built from the live palette so it follows the theme.\n */\nexport const getPrimaryWashGradient = ({ palette }: Theme) =>\n `linear-gradient(
|
|
1
|
+
{"version":3,"file":"celebrationGradients.es.js","names":[],"sources":["../../../src/insights-v2/components/celebrationGradients.ts"],"sourcesContent":["import { alpha, type Theme } from '@mui/material/styles'\n\n/**\n * Decorative slot washes shared by the block layouts and the presentational components, so\n * one source holds each gradient. The 20%–25% washes layer over `background.paper` via\n * `backgroundImage`; `DISCOVERED_ACCOUNTS_GRADIENT` and the tile gradients are opaque and stand alone.\n *\n * - WARM_LIME_ACCENT_GRADIENT: merchant categorization and deposit celebration states.\n * - DIRECT_DEPOSIT_COMPLETE_GRADIENT: the direct deposit complete tile.\n * - CELEBRATION_GRADIENT / ACCOUNT_CONNECTED_GRADIENT: balance milestones, account connected.\n * - celebrateGradient(angle): Figma's Celebrate Gradient at any angle.\n * - WARNING_WASH_GRADIENT: a flagged charge (Unexpected Subscription Payment).\n * - ERROR_WASH_GRADIENT: low balance, off-track status.\n * - FEES_WASH_GRADIENT: fees and interest charges.\n * - PRIMARY_TILE_GRADIENTS / SUCCESS_TILE_GRADIENTS: blue and green tiles, per theme mode.\n * - getPrimaryWashGradient(theme, angle?): pending connect / detected subscription, from the palette.\n */\n\n/**\n * Warm → lime accent wash at 20% opacity. Used as a tinted background behind\n * merchant categorization highlights and deposit celebration callouts.\n */\nexport const WARM_LIME_ACCENT_GRADIENT =\n 'linear-gradient(200.73deg, rgba(255, 223, 152, 0.2) 1.86%, rgba(173, 248, 43, 0.2) 101.54%)'\n\n/**\n * Warm → lime wash at 20% behind the Direct Deposit complete tile (Set Up / Switch Direct Deposit).\n * Figma gives it its own angle and stops, so it does not reuse WARM_LIME_ACCENT_GRADIENT.\n */\nexport const DIRECT_DEPOSIT_COMPLETE_GRADIENT =\n 'linear-gradient(257deg, rgba(255, 224, 153, 0.2) 1.86%, rgba(173, 248, 44, 0.2) 101.54%)'\n\n/** Warm → pink wash behind balance/savings milestones. */\nexport const CELEBRATION_GRADIENT =\n 'linear-gradient(200.73deg, rgba(255, 223, 152, 0.2) 1.86%, rgba(255, 128, 229, 0.2) 101.54%)'\n\n/** Figma Celebrate Gradient; its angle varies per slot. */\nexport const celebrateGradient = (angleDeg: number) =>\n `linear-gradient(${angleDeg}deg, rgba(255, 224, 153, 0.2) 1.86%, rgba(255, 129, 230, 0.2) 101.54%)`\n\n/** Peach → pink gradient for Discovered Accounts success state. */\nexport const DISCOVERED_ACCOUNTS_GRADIENT =\n 'linear-gradient(200.73deg, rgba(255, 224, 153, 1) 1.86%, rgba(255, 129, 230, 1) 101.54%)'\n\n/**\n * Warm → pink wash at 20% opacity for the account-connected success state.\n * Layer over `background.paper` (the Figma spec's `#FFF` base), not the\n * `background` shorthand — a 20% gradient over transparency renders wrong.\n */\nexport const ACCOUNT_CONNECTED_GRADIENT = celebrateGradient(200.73)\n\n/**\n * Orange → red-orange wash at 25% opacity behind a flagged charge (Unexpected Subscription\n * Payment). Figma \"Warning Gradient 1\": a bespoke two-stop blend with no palette token, so it\n * stays a literal like the other washes here rather than being derived from `palette.warning`.\n */\nexport const WARNING_WASH_GRADIENT =\n 'linear-gradient(201deg, rgba(255, 170, 0, 0.25) 1.86%, rgba(255, 68, 0, 0.25) 101.54%)'\n\n/** Red wash at 20%: low balance, off-track status. */\nexport const ERROR_WASH_GRADIENT =\n 'linear-gradient(256.82deg, rgba(255, 47, 40, 0.2) 1.86%, rgba(255, 0, 72, 0.2) 101.54%)'\n\n/** Red → orange wash at 20%: fees and interest charges. */\nexport const FEES_WASH_GRADIENT =\n 'linear-gradient(256.82deg, rgba(227, 39, 39, 0.2) 1.86%, rgba(255, 123, 0, 0.2) 101.54%)'\n\n/** Blue tile, per theme mode (Missing Interest Rate before the rate is added). */\nexport const PRIMARY_TILE_GRADIENTS = {\n light: 'linear-gradient(180deg, #A0B9F8 0%, #2C64EF 100%)',\n dark: 'linear-gradient(180deg, #1F46A7 0%, #6B92F4 100%)',\n} as const\n\n/** Green tile, per theme mode (Missing Interest Rate once the rate is added). */\nexport const SUCCESS_TILE_GRADIENTS = {\n light: 'linear-gradient(180deg, #94C9B7 0%, #12875E 100%)',\n dark: 'linear-gradient(180deg, #0D5F42 0%, #59AB8E 100%)',\n} as const\n\n/**\n * Blue slot wash behind a pending connect / detected-subscription row: `primary.light` →\n * `primary.main` at 75% over paper, built from the live palette so it follows the theme. Figma's\n * angle follows the slot's shape, so a slot passes its own.\n */\nexport const getPrimaryWashGradient = ({ palette }: Theme, angleDeg = 173) =>\n `linear-gradient(${angleDeg}deg, ${alpha(palette.primary.light, 0.75)} 46.41%, ${alpha(palette.primary.main, 0.75)} 78.14%)`\n"],"mappings":";AAsBA,IAAa,IACX,+FAMW,IACX,4FAGW,IACX,gGAGW,IAAA,CAAqB,MAChC,mBAAmB,CAAA,0EAWR,IAA6B,EAAkB,MAAM,GAOrD,IACX,0FAGW,IACX,2FAGW,IACX,4FAGW,IAAyB;AAAA,EACpC,OAAO;AAAA,EACP,MAAM;AACR,GAGa,IAAyB;AAAA,EACpC,OAAO;AAAA,EACP,MAAM;AACR,GAOa,IAAA,CAA0B,EAAE,SAAA,EAAA,GAAkB,IAAW,QACpE,mBAAmB,CAAA,QAAgB,EAAM,EAAQ,QAAQ,OAAO,IAAI,CAAA,YAAa,EAAM,EAAQ,QAAQ,MAAM,IAAI,CAAA"}
|