@mx-cartographer/experiences 9.4.14 → 9.4.16

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.
Files changed (51) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/core/types/Insights.d.ts +14 -14
  3. package/dist/core/types/InsightsInstanceSlotData.d.ts +5 -1
  4. package/dist/core/types/InsightsInstanceSlotData.es.js.map +1 -1
  5. package/dist/core/types/localization/InsightsFeedCopy.d.ts +21 -0
  6. package/dist/core/types/localization/index.d.ts +1 -1
  7. package/dist/insights-v2/CommonUtils.d.ts +2 -0
  8. package/dist/insights-v2/CommonUtils.es.js +8 -3
  9. package/dist/insights-v2/CommonUtils.es.js.map +1 -1
  10. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionDrillDown.d.ts +22 -0
  11. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionDrillDown.es.js +108 -0
  12. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionDrillDown.es.js.map +1 -0
  13. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.d.ts +8 -0
  14. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js +89 -0
  15. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js.map +1 -0
  16. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.d.ts +68 -0
  17. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js +118 -0
  18. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js.map +1 -0
  19. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistory.d.ts +15 -0
  20. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistory.es.js +20 -0
  21. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistory.es.js.map +1 -0
  22. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.d.ts +64 -0
  23. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.es.js +67 -0
  24. package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/utils.es.js.map +1 -0
  25. package/dist/insights-v2/beatActions.d.ts +30 -0
  26. package/dist/insights-v2/beatActions.es.js +12 -0
  27. package/dist/insights-v2/beatActions.es.js.map +1 -0
  28. package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/layout.d.ts +2 -2
  29. package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/layout.es.js +2 -2
  30. package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/layout.es.js.map +1 -1
  31. package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/utils.d.ts +14 -3
  32. package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/utils.es.js +26 -25
  33. package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/utils.es.js.map +1 -1
  34. package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/DonutChartBlock.es.js +3 -3
  35. package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/DonutChartBlock.es.js.map +1 -1
  36. package/dist/insights-v2/components/BaseLayout.d.ts +5 -1
  37. package/dist/insights-v2/components/BaseLayout.es.js +68 -64
  38. package/dist/insights-v2/components/BaseLayout.es.js.map +1 -1
  39. package/dist/insights-v2/components/Header.es.js +23 -33
  40. package/dist/insights-v2/components/Header.es.js.map +1 -1
  41. package/dist/insights-v2/components/InsightOptionsMenu.d.ts +10 -0
  42. package/dist/insights-v2/components/InsightOptionsMenu.es.js +54 -0
  43. package/dist/insights-v2/components/InsightOptionsMenu.es.js.map +1 -0
  44. package/dist/insights-v2/components/OverflowMenu.d.ts +32 -0
  45. package/dist/insights-v2/components/OverflowMenu.es.js +73 -0
  46. package/dist/insights-v2/components/OverflowMenu.es.js.map +1 -0
  47. package/dist/insights-v2/index.d.ts +3 -0
  48. package/dist/insights-v2/index.es.js +51 -45
  49. package/dist/insights-v2/mappings/blocks.es.js +45 -38
  50. package/dist/insights-v2/mappings/blocks.es.js.map +1 -1
  51. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionHistoryBlock/layout.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport type { Theme } from '@mui/material/styles'\nimport { endOfMonth, startOfMonth } from 'date-fns'\nimport { getCategoryColor } from '../../../core/utils/CategoryUtil'\nimport type { Beat, Transaction } from '../../../core'\nimport type { TransactionFilter } from '../../../core/stores/TransactionStore'\nimport type { InsightsInstanceSlotData } from '../../../core/types/InsightsInstanceSlotData'\nimport { MerchantLogo } from '@mxenabled/mxui'\nimport { DATE_FORMATS_INTL, formatDate } from '../../../core/constants'\nimport { Icon } from '@mxenabled/mx-icons'\nimport { ChartDataSeriesItem } from '../../blocks'\n\nexport interface DrillDownHeader {\n heading?: string\n subHeadingText?: string\n icon?: ReactNode\n}\n\nexport interface DrillDownHeaderContext {\n htmlTitle?: string\n primaryTransaction?: Transaction\n categoryName: string\n selectedDate?: string | Date\n}\n\nexport const DRILLDOWN_VARIANTS = {\n TRANSACTION: 'bill_amount_not_standard',\n CATEGORY_SPEND: 'category_spend',\n MONTHLY_SPEND: 'monthly_spend_comparison',\n ACCOUNT_BALANCE: 'savings_account_balances_summary',\n UPCOMING_BILL: 'upcoming_bill',\n SPEND_TO_INCOME: 'monthly_spend_to_income',\n SAVINGS_TO_INCOME: 'monthly_savings_to_income',\n DEBT_TO_INCOME: 'monthly_debt_to_income',\n COST_OF_LIVING: 'cost_living_to_income',\n NON_ESSENTIAL_CATEGORY: 'non_essential_category_summary',\n DEPOSIT_SUMMARY: 'monthly_deposit_summary',\n} as const\n\nexport type DrillDownVariant = (typeof DRILLDOWN_VARIANTS)[keyof typeof DRILLDOWN_VARIANTS]\n\n/**\n * One row of the flattened data_series a filterStrategy indexes into: a single-bar monthly total or a\n * synthesized upcoming-bill bar. Fields are optional because the backend keys each row dynamically\n * from data_series.names and not every variant carries a guid/category. Double-bar comparison rows\n * will extend this in the next MR.\n */\n\n// Resolves the top-chart palette from the theme (and the beat's category, when relevant).\nexport type ColorKind = (theme: Theme, categoryGuid?: string) => string[]\n\n// Resolves the dynamic drawer header (heading/sub-heading/icon JSX) from the selection context.\nexport type HeaderKind = (ctx: DrillDownHeaderContext) => DrillDownHeader\n\n/**\n * Everything a filterStrategy needs to turn the currently-selected bar/sub-tab into a\n * TransactionFilter. Data-only so strategies stay pure and testable.\n */\nexport interface FilterContext {\n beat: Beat\n beatTransactions: Transaction[]\n dataSeries: ChartDataSeriesItem[]\n selectedIndex: number\n subIndex: number\n isLastTab: boolean\n instanceSlotData: InsightsInstanceSlotData\n spendCategoryGuids: string[]\n displayedDateRange: { start: Date; end: Date }\n}\n\n// Resolves the current selection into a TransactionFilter. Carried on each config row so behavior\n// lives next to the variant it belongs to (no separate strategy registry to chase).\nexport type FilterStrategy = (ctx: FilterContext) => TransactionFilter\n\nexport interface DrillDownVariantConfig {\n top: 'singleBar' | 'upcomingBill' | 'doubleBar' | 'tabsOnly'\n filterStrategy: FilterStrategy\n colors: ColorKind\n header?: HeaderKind\n scope: 'store' | 'beat'\n filterMode: 'store' | 'local'\n}\nconst categoryColor = (theme: Theme, categoryGuid?: string): string =>\n (categoryGuid && getCategoryColor(categoryGuid, theme)) || theme.palette.primary.main\n\nconst monthRange = (date: string | number | Date | undefined) => ({\n start: startOfMonth(new Date(date ?? NaN)),\n end: endOfMonth(new Date(date ?? NaN)),\n})\n\n// Scopes a filter to the beat's accounts when the beat carries account_guids; otherwise leaves\n// accounts unset so the store default (all accounts) applies.\nconst accountScope = (accountGuids?: string[]): Pick<TransactionFilter, 'accounts'> =>\n accountGuids?.length ? { accounts: accountGuids } : {}\n\n// ── Single-bar filter strategies (this MR) ────────────────────────────────────────────────────\n\n// BillAmountNotStandard / UpcomingBill — the series carries a transaction (TRN) guid; match a single\n// transaction by guid within its month.\nconst transactionGuidStrategy: FilterStrategy = ({\n beatTransactions,\n dataSeries,\n selectedIndex,\n}) => {\n const seriesItem = dataSeries[selectedIndex]\n const seriesGuid = seriesItem?.guid\n const hasBeenSplit = beatTransactions.find((trn) => trn.guid === seriesGuid)?.has_been_split\n\n return {\n custom: (trn) => trn.guid === seriesGuid,\n dateRange: monthRange(seriesItem?.date),\n showSplits: !hasBeenSplit,\n }\n}\n\n// CategorySpendingV2 — match transactions in the beat's category (or whose top-level category is that\n// guid) within the month.\nconst categoryStrategy: FilterStrategy = ({ dataSeries, selectedIndex, instanceSlotData }) => {\n const seriesItem = dataSeries[selectedIndex]\n const categoryGuid = instanceSlotData.category_guid ?? seriesItem?.guid\n\n return {\n custom: (trn) =>\n trn.category_guid === categoryGuid || trn.top_level_category_guid === categoryGuid,\n dateRange: monthRange(seriesItem?.date),\n }\n}\n\n// MonthlySpendComparisonV2 — no per-bar guid; show all spending-category transactions\n// (income/transfers/investments excluded via spendCategoryGuids) within the month.\nconst spendCategoriesStrategy: FilterStrategy = ({\n dataSeries,\n selectedIndex,\n spendCategoryGuids,\n instanceSlotData,\n}) => {\n const seriesItem = dataSeries[selectedIndex]\n\n return {\n custom: (trn) =>\n !!trn.top_level_category_guid && spendCategoryGuids.includes(trn.top_level_category_guid),\n dateRange: monthRange(seriesItem?.date),\n ...accountScope(instanceSlotData.account_guids),\n }\n}\n\n// SavingsAccountBalancesSummary — balances, not categorized spend. Filter by month only; the most\n// recent month is capped at the beat's creation time to match the snapshot the balance was computed\n// from.\nconst accountDateStrategy: FilterStrategy = ({\n beat,\n dataSeries,\n selectedIndex,\n isLastTab,\n instanceSlotData,\n}) => {\n const seriesItem = dataSeries[selectedIndex]\n const { start, end } = monthRange(seriesItem?.date)\n\n return {\n dateRange: {\n start,\n end: isLastTab && beat.created_at ? new Date(beat.created_at) : end,\n },\n ...accountScope(instanceSlotData.account_guids),\n }\n}\n\n// ── Double-bar + tabsOnly strategies (NEXT MR) ───────────────────────────────────────────────────\n// TODO(next MR — double bar): comparisonAggregatedGuidsStrategy — month × sub-tab membership over the\n// comparison bars' precomputed subGuids. Needs comparisonBars in FilterContext.\n// TODO(next MR — tabsOnly): aggregatedGuids / depositSummary strategies for the donut-drawer beats.\n\nexport const layout: Partial<Record<DrillDownVariant, DrillDownVariantConfig>> = {\n [DRILLDOWN_VARIANTS.TRANSACTION]: {\n top: 'singleBar',\n scope: 'store',\n filterMode: 'store',\n filterStrategy: transactionGuidStrategy,\n colors: (theme: Theme, categoryGuid?: string) => [categoryColor(theme, categoryGuid)],\n header: (ctx: DrillDownHeaderContext) => {\n return {\n heading: ctx.htmlTitle,\n subHeadingText: ctx.primaryTransaction?.description || undefined,\n icon: (\n <MerchantLogo\n alt={ctx.primaryTransaction?.description}\n categoryGuid={ctx.primaryTransaction?.category_guid || ''}\n merchantGuid={ctx.primaryTransaction?.merchant_guid || ''}\n size={16}\n />\n ),\n }\n },\n },\n [DRILLDOWN_VARIANTS.CATEGORY_SPEND]: {\n top: 'singleBar',\n filterStrategy: categoryStrategy,\n scope: 'store',\n filterMode: 'store',\n colors: (theme: Theme, categoryGuid?: string) => [categoryColor(theme, categoryGuid)],\n header: (ctx: DrillDownHeaderContext) => {\n return {\n heading: ctx.categoryName,\n subHeadingText: ctx.selectedDate\n ? formatDate(ctx.selectedDate, DATE_FORMATS_INTL.MONTH_LONG) || ''\n : '',\n icon: <Icon name=\"calendar_month\" size={16} />,\n }\n },\n },\n [DRILLDOWN_VARIANTS.MONTHLY_SPEND]: {\n top: 'singleBar',\n filterStrategy: spendCategoriesStrategy,\n scope: 'store',\n filterMode: 'store',\n colors: (theme: Theme) => [theme.palette.chart.chart2 ?? theme.palette.primary.main],\n },\n [DRILLDOWN_VARIANTS.ACCOUNT_BALANCE]: {\n top: 'singleBar',\n filterStrategy: accountDateStrategy,\n scope: 'store',\n filterMode: 'store',\n colors: (theme: Theme) => [theme.palette.success.main],\n },\n [DRILLDOWN_VARIANTS.UPCOMING_BILL]: {\n top: 'upcomingBill',\n filterStrategy: transactionGuidStrategy,\n scope: 'beat',\n filterMode: 'local',\n colors: (theme: Theme, categoryGuid?: string) => [categoryColor(theme, categoryGuid)],\n },\n\n // ── NEXT MR: double-bar comparison beats (month tabs + spend/income sub-tabs) ────────────────\n // [DRILLDOWN_VARIANTS.SPEND_TO_INCOME]: comparison('spendVsIncome'),\n // [DRILLDOWN_VARIANTS.SAVINGS_TO_INCOME]: comparison('savingsVsIncome'),\n // [DRILLDOWN_VARIANTS.DEBT_TO_INCOME]: comparison('debtVsIncome'),\n // [DRILLDOWN_VARIANTS.COST_OF_LIVING]: comparison('costOfLiving'),\n //\n // ── NEXT MR: tabsOnly donut-drawer beats (no top chart) ───────────────────────────────────\n // [DRILLDOWN_VARIANTS.NON_ESSENTIAL_CATEGORY]: { top: 'tabsOnly', ... },\n // [DRILLDOWN_VARIANTS.DEPOSIT_SUMMARY]: { top: 'tabsOnly', ... },\n}\n\n// Fallback for a missing/typo'd backend variant: a single-bar, store-scoped drawer filtered by the\n// beat's transaction guid and colored by category, so the drawer still renders instead of crashing.\nexport const FALLBACK: DrillDownVariantConfig = {\n top: 'singleBar',\n filterStrategy: transactionGuidStrategy,\n scope: 'store',\n filterMode: 'store',\n colors: (theme: Theme, categoryGuid?: string) => [categoryColor(theme, categoryGuid)],\n}\n"],"mappings":"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"}
@@ -0,0 +1,15 @@
1
+ import { Beat } from '../../../core';
2
+ import { InsightsInstanceSlotData } from '../../../core/types/InsightsInstanceSlotData';
3
+ export declare const useTransactionHistory: (beat: Beat) => {
4
+ instanceSlotData: InsightsInstanceSlotData;
5
+ beatTransactions: import('../../../core').Transaction[];
6
+ primaryTransaction: import('../../../core').Transaction | undefined;
7
+ spendCategoryGuids: string[];
8
+ allAccountGuids: string[];
9
+ categoryName: string;
10
+ displayedDateRange: {
11
+ start: Date;
12
+ end: Date;
13
+ };
14
+ transactionStore: import('../../../core').TransactionStore;
15
+ };
@@ -0,0 +1,20 @@
1
+ import { useAccountStore as i, useCategoryStore as c, useGlobalUiStore as d, useTransactionStore as u } from "../../../common/context/hooks.es.js";
2
+ import { selectTransactionsByGuids as g } from "../../CommonUtils.es.js";
3
+ var p = (e) => {
4
+ const a = e.insights_payload?.instance_slot_data, o = u(), n = i(), s = c(), { displayedDateRange: r } = d();
5
+ return {
6
+ instanceSlotData: a,
7
+ beatTransactions: g(o.detailedTransactions, a?.transaction_guids),
8
+ primaryTransaction: o.detailedTransactions.find((t) => t.guid === a?.primary_transaction_guid),
9
+ spendCategoryGuids: s.spendCategories.map((t) => t.guid),
10
+ allAccountGuids: n.accounts.map((t) => t.guid),
11
+ categoryName: s.getCategoryName(a?.category_guid ?? "") || "",
12
+ displayedDateRange: r,
13
+ transactionStore: o
14
+ };
15
+ };
16
+ export {
17
+ p as useTransactionHistory
18
+ };
19
+
20
+ //# sourceMappingURL=useTransactionHistory.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTransactionHistory.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionHistoryBlock/useTransactionHistory.ts"],"sourcesContent":["import {\n useAccountStore,\n useCategoryStore,\n useGlobalUiStore,\n useTransactionStore,\n} from '../../../common'\nimport type { Beat } from '../../../core'\nimport type { InsightsInstanceSlotData } from '../../../core/types/InsightsInstanceSlotData'\nimport { selectTransactionsByGuids } from '../../CommonUtils'\n\nexport const useTransactionHistory = (beat: Beat) => {\n const instanceSlotData = beat.insights_payload?.instance_slot_data as InsightsInstanceSlotData\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 primaryTransaction = transactionStore.detailedTransactions.find(\n (transaction) => transaction.guid === instanceSlotData?.primary_transaction_guid,\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 primaryTransaction,\n spendCategoryGuids,\n allAccountGuids,\n categoryName,\n displayedDateRange,\n transactionStore,\n }\n}\n"],"mappings":";;AAUA,IAAa,IAAA,CAAyB,MAAe;AACnD,QAAM,IAAmB,EAAK,kBAAkB,oBAE1C,IAAmB,EAAoB,GACvC,IAAe,EAAgB,GAC/B,IAAgB,EAAiB,GACjC,EAAE,oBAAA,EAAA,IAAuB,EAAiB;AAehD,SAAO;AAAA,IACL,kBAAA;AAAA,IACA,kBAfuB,EACvB,EAAiB,sBACjB,GAAkB,iBAalB;AAAA,IACA,oBAXyB,EAAiB,qBAAqB,KAAA,CAC9D,MAAgB,EAAY,SAAS,GAAkB,wBAUxD;AAAA,IACA,oBARyB,EAAc,gBAAgB,IAAA,CAAK,MAAa,EAAS,IAQlF;AAAA,IACA,iBARsB,EAAa,SAAS,IAAA,CAAK,MAAY,EAAQ,IAQrE;AAAA,IACA,cARmB,EAAc,gBAAgB,GAAkB,iBAAiB,EAAE,KAAK;AAAA,IAS3F,oBAAA;AAAA,IACA,kBAAA;AAAA,EACF;AACF"}
@@ -0,0 +1,64 @@
1
+ import { ActionDrawerState, DataSeries, GlobalCopy, Transaction } from '../../../core';
2
+ import { DataSet } from '../../../core/types/InsightsInstanceSlotData';
3
+ import { TransactionFilter } from '../../../core/stores/TransactionStore';
4
+ import { buildChartData, ChartDataSeriesItem } from '../../blocks';
5
+ import { DrillDownVariantConfig } from './layout';
6
+ interface DefaultSelectionProp {
7
+ chartTabCount: number;
8
+ comparisonTabCount: number;
9
+ actionDrawer: ActionDrawerState;
10
+ beatGuid: string;
11
+ }
12
+ export declare const getDrillDownConfig: (variant?: string) => DrillDownVariantConfig;
13
+ export interface FlattenedDataSeries {
14
+ dataSeries: ChartDataSeriesItem[];
15
+ chartData: ReturnType<typeof buildChartData>;
16
+ comparisonBars: DataSet[];
17
+ }
18
+ /**
19
+ * Shapes the beat's raw data_series into the chart inputs for the variant's top kind. This MR handles
20
+ * the single-bar family (singleBar / upcomingBill); the double-bar and tabsOnly branches are stubbed
21
+ * for the next MR so the call site is already wired.
22
+ */
23
+ interface FlattenedDataSeriesInput {
24
+ data: DataSeries | undefined;
25
+ ariaLabel: string;
26
+ top: DrillDownVariantConfig['top'];
27
+ beatTransactions: Transaction[];
28
+ payload: {
29
+ date?: string;
30
+ amount?: number;
31
+ } | undefined;
32
+ }
33
+ export declare const getFlattenedDataSeries: ({ data, ariaLabel, top, beatTransactions, payload, }: FlattenedDataSeriesInput) => FlattenedDataSeries;
34
+ export declare const PROJECTED_BILL_GUID = "TRN-projected-bill";
35
+ export interface UpcomingBillBar {
36
+ date: string;
37
+ amount: number;
38
+ guid: string;
39
+ category_guid?: string;
40
+ }
41
+ /**
42
+ * UpcomingBill has no data_series: build the bar series straight from the beat's recurring-bill
43
+ * transactions plus the synthesized projected bill from payload (mirrors pulse's magicTransactions).
44
+ * Historical bills are de-duped by date and each keeps its real transaction guid so the guid filter
45
+ * finds it in the store; the projected bar (cloned category from the latest bill) carries the
46
+ * PROJECTED_BILL_GUID sentinel. The result is sorted date-ascending so the projected bill lands last.
47
+ */
48
+ export declare const buildUpcomingBillSeries: (transactions: Transaction[] | undefined, payload: {
49
+ date?: string;
50
+ amount?: number;
51
+ } | undefined) => UpcomingBillBar[];
52
+ export declare const getDrawerHeaderTitle: (variant: string | null | undefined, copy: GlobalCopy) => string;
53
+ export declare const toStoreFilter: (filter: TransactionFilter, defaults: {
54
+ allAccountGuids: string[];
55
+ displayedDateRange: {
56
+ start: Date;
57
+ end: Date;
58
+ };
59
+ }) => TransactionFilter;
60
+ export declare const getDefaultSelection: ({ chartTabCount, actionDrawer, beatGuid, }: DefaultSelectionProp) => {
61
+ chartBarIndex: number;
62
+ subTabIndex: number;
63
+ };
64
+ export {};
@@ -0,0 +1,67 @@
1
+ import { DATE_FORMATS_INTL as u } from "../../../core/constants/DateFormats.es.js";
2
+ import { buildChartData as s, buildDataSeries as g } from "../../blocks/ChartBlocks/BarchartBlock/utils.es.js";
3
+ import { DRILLDOWN_VARIANTS as l, FALLBACK as m, layout as _ } from "./layout.es.js";
4
+ import { format as h, fromUnixTime as D } from "date-fns";
5
+ var I = (t) => _[t] ?? m, A = ({ data: t, ariaLabel: e, top: r, beatTransactions: a, payload: o }) => {
6
+ if (r === "upcomingBill") {
7
+ const d = T(a, o);
8
+ return {
9
+ dataSeries: d,
10
+ chartData: s(d, e, u.MONTH_DAY),
11
+ comparisonBars: []
12
+ };
13
+ }
14
+ const n = [...g(t)].sort((d, i) => !d.date || !i.date ? 0 : new Date(d.date).getTime() - new Date(i.date).getTime());
15
+ return {
16
+ dataSeries: n,
17
+ chartData: s(n, e),
18
+ comparisonBars: []
19
+ };
20
+ }, p = "TRN-projected-bill", f = (t) => ({
21
+ date: h(D(t.date), "yyyy-MM-dd"),
22
+ amount: t.amount,
23
+ guid: t.guid,
24
+ category_guid: t.top_level_category_guid ?? t.category_guid
25
+ }), T = (t = [], e) => {
26
+ if (!t.length || e?.date == null || e?.amount == null) return [];
27
+ const r = [...t].sort((i, c) => i.date - c.date), a = /* @__PURE__ */ new Set(), o = [];
28
+ for (const i of r)
29
+ a.has(i.date) || (a.add(i.date), o.push(f(i)));
30
+ const n = r[r.length - 1], d = {
31
+ date: e.date,
32
+ amount: e.amount,
33
+ guid: p,
34
+ category_guid: n.top_level_category_guid ?? n.category_guid
35
+ };
36
+ return [...o, d];
37
+ }, v = (t, e) => {
38
+ const r = e.insights_feed?.general?.transaction_history_title ?? "", a = e.insights_feed?.transaction_history_block;
39
+ if (t === l.TRANSACTION) return r;
40
+ const o = `${t}_drawer_title`;
41
+ return a?.[o] ?? r;
42
+ }, R = (t, e) => ({
43
+ accounts: t.accounts ?? e.allAccountGuids,
44
+ dateRange: t.dateRange ?? e.displayedDateRange,
45
+ custom: t.custom ?? (() => !0),
46
+ showSplits: t.showSplits ?? !1
47
+ }), M = ({ chartTabCount: t, actionDrawer: e, beatGuid: r }) => {
48
+ const a = e.guid === r && e.trigger === "chartBar", o = e.context, n = a ? o?.tabIndex ?? 0 : 0;
49
+ return a ? {
50
+ chartBarIndex: Math.min(Math.max(o?.chartBarIndex ?? 0, 0), Math.max(0, t - 1)),
51
+ subTabIndex: n
52
+ } : {
53
+ chartBarIndex: Math.max(0, t - 1),
54
+ subTabIndex: n
55
+ };
56
+ };
57
+ export {
58
+ p as PROJECTED_BILL_GUID,
59
+ T as buildUpcomingBillSeries,
60
+ M as getDefaultSelection,
61
+ v as getDrawerHeaderTitle,
62
+ I as getDrillDownConfig,
63
+ A as getFlattenedDataSeries,
64
+ R as toStoreFilter
65
+ };
66
+
67
+ //# sourceMappingURL=utils.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.es.js","names":[],"sources":["../../../../src/insights-v2/actionBlocks/TransactionHistoryBlock/utils.ts"],"sourcesContent":["import { format, fromUnixTime } from 'date-fns'\n\nimport type {\n ActionDrawerState,\n DataSeries,\n DrilldownPayload,\n GlobalCopy,\n Transaction,\n} from '../../../core'\nimport { DATE_FORMATS_INTL } from '../../../core/constants'\nimport type { DataSet } from '../../../core/types/InsightsInstanceSlotData'\nimport type { TransactionFilter } from '../../../core/stores/TransactionStore'\nimport { buildChartData, buildDataSeries, ChartDataSeriesItem } from '../../blocks'\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` is reserved for the double-bar MR (empty until then).\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. This MR handles\n * the single-bar family (singleBar / upcomingBill); the double-bar and tabsOnly branches are stubbed\n * for the next MR so the call site is already wired.\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.\n beatTransactions: Transaction[]\n payload: { date?: string; amount?: number } | undefined\n}\n\nexport const getFlattenedDataSeries = ({\n data,\n ariaLabel,\n top,\n beatTransactions,\n payload,\n}: FlattenedDataSeriesInput): FlattenedDataSeries => {\n // UpcomingBill has no backend data_series: synthesize the bars from the beat's recurring-bill\n // transactions + the projected bill, and label each bar by day (MONTH_DAY) since a bar is one bill.\n if (top === 'upcomingBill') {\n const dataSeries = buildUpcomingBillSeries(beatTransactions, payload)\n return {\n dataSeries,\n chartData: buildChartData(dataSeries, ariaLabel, DATE_FORMATS_INTL.MONTH_DAY),\n comparisonBars: [],\n }\n }\n\n // Single-bar family (THIS MR): the backend sends data_series newest-first, so normalize it\n // date-ascending here. chartData/tabs and the filter's dataSeries[selectedIndex] indexing both read\n // this one 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 // NEXT MR — double bar: comparison beats build paired bars instead of chartData.\n // if (top === \"doubleBar\") {\n // return { dataSeries, chartData: [], comparisonBars: buildComparisonSeries(data, ariaLabel) };\n // }\n //\n // NEXT MR — tabsOnly: donut-drawer beats render no top chart.\n // if (top === \"tabsOnly\") {\n // return { dataSeries, chartData: [], comparisonBars: [] };\n // }\n\n return { dataSeries, chartData: buildChartData(dataSeries, ariaLabel), comparisonBars: [] }\n}\n\n// Sentinel guid for the synthesized projected bill. It intentionally matches no real store\n// transaction, so the projected tab's guid filter yields an empty list (projected-bar-only scope).\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 both\n// historical unix timestamps and the ISO payload date after normalization here.\nexport interface UpcomingBillBar {\n date: string\n amount: number\n guid: string\n category_guid?: string\n}\n\nconst toUpcomingBillBar = (transaction: Transaction): UpcomingBillBar => ({\n date: format(fromUnixTime(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 straight from the beat's recurring-bill\n * transactions plus the synthesized projected bill from payload (mirrors pulse's magicTransactions).\n * Historical bills are de-duped by date and each keeps its real transaction guid so the guid filter\n * finds it in the store; the projected bar (cloned category from the latest bill) carries the\n * PROJECTED_BILL_GUID sentinel. The result is sorted date-ascending so the projected bill lands last.\n */\nexport const buildUpcomingBillSeries = (\n transactions: Transaction[] = [],\n payload: { date?: string; amount?: number } | undefined,\n): UpcomingBillBar[] => {\n if (!transactions.length || payload?.date == null || payload?.amount == null) {\n return []\n }\n\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 latestBill = sorted[sorted.length - 1]\n const projected: UpcomingBillBar = {\n date: payload.date,\n amount: payload.amount,\n guid: PROJECTED_BILL_GUID,\n category_guid: latestBill.top_level_category_guid ?? latestBill.category_guid,\n }\n\n return [...history, projected]\n}\n\nexport const getDrawerHeaderTitle = (\n variant: string | null | undefined,\n copy: GlobalCopy,\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 // Safely access the drawer title from transaction_history_block\n const key = `${variant}_drawer_title` 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 actionDrawer,\n beatGuid,\n}: DefaultSelectionProp): { chartBarIndex: number; subTabIndex: number } => {\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(\n Math.max(context?.chartBarIndex ?? 0, 0),\n Math.max(0, chartTabCount - 1),\n )\n return { chartBarIndex: clamped, subTabIndex }\n }\n\n return { chartBarIndex: Math.max(0, chartTabCount - 1), subTabIndex }\n}\n"],"mappings":";;;;AA4BA,IAAa,IAAA,CAAsB,MACjC,EAAO,CAAA,KAAgC,GAyB5B,IAAA,CAA0B,EACrC,MAAA,GACA,WAAA,GACA,KAAA,GACA,kBAAA,GACA,SAAA,EAAA,MACmD;AAGnD,MAAI,MAAQ,gBAAgB;AAC1B,UAAM,IAAa,EAAwB,GAAkB,CAAO;AACpE,WAAO;AAAA,MACL,YAAA;AAAA,MACA,WAAW,EAAe,GAAY,GAAW,EAAkB,SAAS;AAAA,MAC5E,gBAAgB,CAAC;AAAA,IACnB;AAAA,EACF;AAKA,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;AAYD,SAAO;AAAA,IAAE,YAAA;AAAA,IAAY,WAAW,EAAe,GAAY,CAAS;AAAA,IAAG,gBAAgB,CAAC;AAAA,EAAE;AAC5F,GAIa,IAAsB,sBAW7B,IAAA,CAAqB,OAA+C;AAAA,EACxE,MAAM,EAAO,EAAa,EAAY,IAAI,GAAG,YAAY;AAAA,EACzD,QAAQ,EAAY;AAAA,EACpB,MAAM,EAAY;AAAA,EAClB,eAAe,EAAY,2BAA2B,EAAY;AACpE,IASa,IAAA,CACX,IAA8B,CAAC,GAC/B,MACsB;AACtB,MAAI,CAAC,EAAa,UAAU,GAAS,QAAQ,QAAQ,GAAS,UAAU,KACtE,QAAO,CAAC;AAGV,QAAM,IAAS,CAAC,GAAG,CAAY,EAAE,KAAA,CAAM,GAAG,MAAM,EAAE,OAAO,EAAE,IAAI,GAEzD,IAAY,oBAAI,IAAY,GAC5B,IAA6B,CAAC;AACpC,aAAW,KAAe;AACxB,IAAI,EAAU,IAAI,EAAY,IAAI,MAClC,EAAU,IAAI,EAAY,IAAI,GAC9B,EAAQ,KAAK,EAAkB,CAAW,CAAC;AAG7C,QAAM,IAAa,EAAO,EAAO,SAAS,CAAA,GACpC,IAA6B;AAAA,IACjC,MAAM,EAAQ;AAAA,IACd,QAAQ,EAAQ;AAAA,IAChB,MAAM;AAAA,IACN,eAAe,EAAW,2BAA2B,EAAW;AAAA,EAClE;AAEA,SAAO,CAAC,GAAG,GAAS,CAAS;AAC/B,GAEa,IAAA,CACX,GACA,MACW;AACX,QAAM,IAA0B,EAAK,eAAe,SAAS,6BAA6B,IACpF,IAAkB,EAAK,eAAe;AAE5C,MAAI,MAAY,EAAmB,YAAa,QAAO;AAGvD,QAAM,IAAM,GAAG,CAAA;AACf,SAAQ,IAAkB,CAAA,KAAmB;AAC/C,GAEa,IAAA,CACX,GACA,OACuB;AAAA,EACvB,UAAU,EAAO,YAAY,EAAS;AAAA,EACtC,WAAW,EAAO,aAAa,EAAS;AAAA,EACxC,QAAQ,EAAO,WAAA,MAAiB;AAAA,EAChC,YAAY,EAAO,cAAc;AACnC,IAEa,IAAA,CAAuB,EAClC,eAAA,GACA,cAAA,GACA,UAAA,EAAA,MAC0E;AAC1E,QAAM,IAAoB,EAAa,SAAS,KAAY,EAAa,YAAY,YAG/E,IAAU,EAAa,SACvB,IAAc,IAAqB,GAAS,YAAY,IAAK;AAEnE,SAAI,IAKK;AAAA,IAAE,eAJO,KAAK,IACnB,KAAK,IAAI,GAAS,iBAAiB,GAAG,CAAC,GACvC,KAAK,IAAI,GAAG,IAAgB,CAAC,CAEP;AAAA,IAAS,aAAA;AAAA,EAAY,IAGxC;AAAA,IAAE,eAAe,KAAK,IAAI,GAAG,IAAgB,CAAC;AAAA,IAAG,aAAA;AAAA,EAAY;AACtE"}
@@ -0,0 +1,30 @@
1
+ import { ReactNode } from 'react';
2
+ /** Overflow-menu action keys emitted to the host. */
3
+ export type InsightMenuAction = 'helpful' | 'not_helpful' | 'hide';
4
+ export interface MenuActionHandlers {
5
+ /** Invoked with the chosen overflow-menu action key. */
6
+ onAction: (action: InsightMenuAction) => void;
7
+ /** Called when the overflow menu opens (e.g. analytics). */
8
+ onOpen?: () => void;
9
+ /** Disables the overflow menu trigger (e.g. an obsolete beat). */
10
+ disabled?: boolean;
11
+ }
12
+ export interface UpdateParams {
13
+ beatGuid: string;
14
+ }
15
+ /**
16
+ * Host callbacks for a beat card, grouped under one prop and delivered via
17
+ * context so any descendant (header menu, blocks, variants) can reach the
18
+ * handler it needs without prop drilling. Each concern is its own typed slot —
19
+ * add new callbacks here as they arise.
20
+ */
21
+ export interface BeatActions {
22
+ onMenuAction?: MenuActionHandlers;
23
+ onUpdate?: (params: UpdateParams) => void;
24
+ }
25
+ export declare const BeatActionsProvider: ({ value, children, }: {
26
+ value: BeatActions;
27
+ children: ReactNode;
28
+ }) => import("react/jsx-runtime").JSX.Element;
29
+ /** Read the host callbacks for the current beat card. */
30
+ export declare const useBeatActions: () => BeatActions;
@@ -0,0 +1,12 @@
1
+ import { createContext as r, useContext as a } from "react";
2
+ import { jsx as i } from "react/jsx-runtime";
3
+ var t = r({}), v = ({ value: e, children: o }) => /* @__PURE__ */ i(t.Provider, {
4
+ value: e,
5
+ children: o
6
+ }), x = () => a(t);
7
+ export {
8
+ v as BeatActionsProvider,
9
+ x as useBeatActions
10
+ };
11
+
12
+ //# sourceMappingURL=beatActions.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"beatActions.es.js","names":[],"sources":["../../src/insights-v2/beatActions.tsx"],"sourcesContent":["import { createContext, useContext, type ReactNode } from 'react'\n\n/** Overflow-menu action keys emitted to the host. */\nexport type InsightMenuAction = 'helpful' | 'not_helpful' | 'hide'\n\nexport interface MenuActionHandlers {\n /** Invoked with the chosen overflow-menu action key. */\n onAction: (action: InsightMenuAction) => void\n /** Called when the overflow menu opens (e.g. analytics). */\n onOpen?: () => void\n /** Disables the overflow menu trigger (e.g. an obsolete beat). */\n disabled?: boolean\n}\n\nexport interface UpdateParams {\n beatGuid: string\n // …extend with whatever the host's updateBeat needs.\n}\n\n/**\n * Host callbacks for a beat card, grouped under one prop and delivered via\n * context so any descendant (header menu, blocks, variants) can reach the\n * handler it needs without prop drilling. Each concern is its own typed slot —\n * add new callbacks here as they arise.\n */\nexport interface BeatActions {\n onMenuAction?: MenuActionHandlers\n onUpdate?: (params: UpdateParams) => void\n}\n\nconst BeatActionsContext = createContext<BeatActions>({})\n\nexport const BeatActionsProvider = ({\n value,\n children,\n}: {\n value: BeatActions\n children: ReactNode\n}) => <BeatActionsContext.Provider value={value}>{children}</BeatActionsContext.Provider>\n\n/** Read the host callbacks for the current beat card. */\nexport const useBeatActions = () => useContext(BeatActionsContext)\n"],"mappings":";;AA8BA,IAAM,IAAqB,EAA2B,CAAC,CAAC,GAE3C,IAAA,CAAuB,EAClC,OAAA,GACA,UAAA,EAAA,MAII,gBAAA,EAAC,EAAmB,UAApB;AAAA,EAAoC,OAAA;AAAA,EAAQ,UAAA;AAAsC,CAAA,GAG3E,IAAA,MAAuB,EAAW,CAAkB"}
@@ -1,9 +1,9 @@
1
1
  import { Theme } from '@mui/material/styles';
2
2
  export declare const getLayoutConfig: (theme: Theme) => {
3
- SavingsAccountBalancesSummary: {
3
+ savings_account_balances_summary: {
4
4
  color: string;
5
5
  };
6
- MonthlySpendComparison: {
6
+ monthly_spend_comparison: {
7
7
  color: string | undefined;
8
8
  };
9
9
  };
@@ -1,6 +1,6 @@
1
1
  var o = (a) => ({
2
- SavingsAccountBalancesSummary: { color: a.palette.success.main },
3
- MonthlySpendComparison: { color: a.palette.chart.chart2 }
2
+ savings_account_balances_summary: { color: a.palette.success.main },
3
+ monthly_spend_comparison: { color: a.palette.chart.chart2 }
4
4
  });
5
5
  export {
6
6
  o as getLayoutConfig
@@ -1 +1 @@
1
- {"version":3,"file":"layout.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ChartBlocks/BarchartBlock/layout.ts"],"sourcesContent":["import { type Theme } from '@mui/material/styles'\nexport const getLayoutConfig = (theme: Theme) => {\n return {\n SavingsAccountBalancesSummary: {\n color: theme.palette.success.main,\n },\n MonthlySpendComparison: {\n color: theme.palette.chart.chart2,\n },\n }\n}\n"],"mappings":"AACA,IAAa,IAAA,CAAmB,OACvB;AAAA,EACL,+BAA+B,EAC7B,OAAO,EAAM,QAAQ,QAAQ,KAC/B;AAAA,EACA,wBAAwB,EACtB,OAAO,EAAM,QAAQ,MAAM,OAC7B;AACF"}
1
+ {"version":3,"file":"layout.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ChartBlocks/BarchartBlock/layout.ts"],"sourcesContent":["import { type Theme } from '@mui/material/styles'\nexport const getLayoutConfig = (theme: Theme) => {\n return {\n savings_account_balances_summary: {\n color: theme.palette.success.main,\n },\n monthly_spend_comparison: {\n color: theme.palette.chart.chart2,\n },\n }\n}\n"],"mappings":"AACA,IAAa,IAAA,CAAmB,OACvB;AAAA,EACL,kCAAkC,EAChC,OAAO,EAAM,QAAQ,QAAQ,KAC/B;AAAA,EACA,0BAA0B,EACxB,OAAO,EAAM,QAAQ,MAAM,OAC7B;AACF"}
@@ -1,4 +1,5 @@
1
1
  import { Theme } from '@mui/material/styles';
2
+ import { formatDate } from '../../../../core/constants';
2
3
  import { DataSeries, InstanceSlot } from '../../../../core';
3
4
  import { InsightsInstanceSlotData } from '../../../../core/types/InsightsInstanceSlotData';
4
5
  export declare const BAR_CHART_VARIANTS: {
@@ -6,11 +7,21 @@ export declare const BAR_CHART_VARIANTS: {
6
7
  SAVINGS_ACCOUNT_BALANCES_SUMMARY: string;
7
8
  MONTHLY_SPEND_COMPARISON: string;
8
9
  };
9
- export declare const buildDataSeries: (data: DataSeries | undefined) => any[];
10
- export declare const buildChartData: (dataSeries: any[], ariaLabel: string) => {
10
+ export interface ChartDataSeriesItem {
11
+ date?: string;
12
+ amount?: number;
13
+ guid?: string;
14
+ label?: string;
15
+ aggregated_guids?: string[];
16
+ localized_label?: string;
17
+ category_guid?: string;
18
+ }
19
+ export declare const buildDataSeries: (data: DataSeries | undefined) => ChartDataSeriesItem[];
20
+ export declare const buildChartData: (dataSeries: ChartDataSeriesItem[], ariaLabel: string, dateFormat?: Parameters<typeof formatDate>[1]) => {
11
21
  ariaLabel: string;
22
+ date: string | null;
12
23
  label: string;
13
- value: any;
24
+ value: number;
14
25
  formattedAmount: string;
15
26
  }[];
16
27
  export declare const barChartVariant: (instanceSlot: InstanceSlot, instanceSlotData: InsightsInstanceSlotData, theme: Theme) => {
@@ -1,35 +1,36 @@
1
- import { buildDynamicCopy as n } from "../../../../core/utils/Localization.es.js";
2
- import { DATE_FORMATS_INTL as i, formatDate as u } from "../../../../core/constants/DateFormats.es.js";
3
- import { getCategoryColor as C } from "../../../../core/utils/CategoryUtil.es.js";
1
+ import { buildDynamicCopy as i } from "../../../../core/utils/Localization.es.js";
2
+ import { DATE_FORMATS_INTL as u, formatDate as _ } from "../../../../core/constants/DateFormats.es.js";
3
+ import { getCategoryColor as c } from "../../../../core/utils/CategoryUtil.es.js";
4
4
  import { formatCurrency as m } from "../../../../core/utils/NumberFormatting.es.js";
5
- import { getLayoutConfig as p } from "./layout.es.js";
6
- import { parseISO as A } from "date-fns/parseISO";
7
- var O = {
8
- CATEGORY_COLOR: "CategoryColor",
9
- SAVINGS_ACCOUNT_BALANCES_SUMMARY: "SavingsAccountBalancesSummary",
10
- MONTHLY_SPEND_COMPARISON: "MonthlySpendComparison"
11
- }, l = (t) => t ? t.data ? t.data.map((o) => {
12
- const r = {};
13
- return t.names?.map((a, e) => {
14
- r[a] = o[e];
15
- }), r;
16
- }) : [] : [], y = (t, o) => [...t].sort((r, a) => new Date(r.date).getTime() - new Date(a.date).getTime()).map((r) => {
17
- const a = u(A(r.date), i.MONTH_SHORT);
5
+ import { getLayoutConfig as C } from "./layout.es.js";
6
+ import { parseISO as p } from "date-fns/parseISO";
7
+ var l = {
8
+ CATEGORY_COLOR: "category_color",
9
+ SAVINGS_ACCOUNT_BALANCES_SUMMARY: "savings_account_balances_summary",
10
+ MONTHLY_SPEND_COMPARISON: "monthly_spend_comparison"
11
+ }, g = (t) => t ? t.data ? t.data.map((o) => {
12
+ const e = {};
13
+ return t.names?.map((r, a) => {
14
+ e[r] = o[a];
15
+ }), e;
16
+ }) : [] : [], y = (t, o, e = u.MONTH_SHORT) => [...t].sort((r, a) => !r.date || !a.date ? 0 : new Date(r.date).getTime() - new Date(a.date).getTime()).map((r) => {
17
+ const a = r.date ? _(p(r.date), e) : r.label ?? "", n = r.amount ?? 0;
18
18
  return {
19
- ariaLabel: n(o, a, m(r.amount, "0.00")),
19
+ ariaLabel: i(o, a, m(n, "0.00")),
20
+ date: r.date ?? null,
20
21
  label: a,
21
- value: r.amount,
22
- formattedAmount: m(r.amount, "0,0")
22
+ value: n,
23
+ formattedAmount: m(n, "0,0")
23
24
  };
24
- }), s = (t, o, r) => {
25
- const { variant: a } = t, e = p(r);
26
- return a === O.CATEGORY_COLOR && o.category_guid ? { color: C(o.category_guid, r) } : { color: e[a]?.color ?? r.palette.primary.main };
25
+ }), R = (t, o, e) => {
26
+ const { variant: r } = t, a = C(e);
27
+ return r === l.CATEGORY_COLOR && o.category_guid ? { color: c(o.category_guid, e) } : { color: a[r]?.color ?? e.palette.primary.main };
27
28
  };
28
29
  export {
29
- O as BAR_CHART_VARIANTS,
30
- s as barChartVariant,
30
+ l as BAR_CHART_VARIANTS,
31
+ R as barChartVariant,
31
32
  y as buildChartData,
32
- l as buildDataSeries
33
+ g as buildDataSeries
33
34
  };
34
35
 
35
36
  //# sourceMappingURL=utils.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ChartBlocks/BarchartBlock/utils.ts"],"sourcesContent":["import { type Theme } from '@mui/material/styles'\n\nimport { parseISO } from 'date-fns/parseISO'\n\nimport { getCategoryColor } from '../../../../core/utils/CategoryUtil'\nimport { buildDynamicCopy } from '../../../../core/utils/Localization'\nimport { formatCurrency } from '../../../../core/utils/NumberFormatting'\nimport { DATE_FORMATS_INTL, formatDate } from '../../../../core/constants'\nimport type { DataSeries, InstanceSlot } from '../../../../core'\nimport type { InsightsInstanceSlotData } from '../../../../core/types/InsightsInstanceSlotData'\nimport { getLayoutConfig } from './layout'\n\nexport const BAR_CHART_VARIANTS = {\n CATEGORY_COLOR: 'CategoryColor',\n SAVINGS_ACCOUNT_BALANCES_SUMMARY: 'SavingsAccountBalancesSummary',\n MONTHLY_SPEND_COMPARISON: 'MonthlySpendComparison',\n}\n\nexport const buildDataSeries = (data: DataSeries | undefined) => {\n if (!data) {\n return []\n }\n\n if (data.data) {\n return data.data.map((d) => {\n const item: any = {}\n\n data.names?.map((name, index) => {\n item[name] = d[index]\n })\n return item\n })\n } else {\n return []\n }\n}\n\nexport const buildChartData = (dataSeries: any[], ariaLabel: string) => {\n // Bars render oldest→newest (Jan→Dec, left→right, per Figma). The single-bar backend sends\n // data_series newest-first, so normalize date-ascending here — the single source of truth for both\n // the card (BarchartBlock) and the drill-down. This keeps their bar/tab indices aligned, which the\n // card relies on when it forwards a clicked bar index straight to the drill-down (openActionDrawer).\n const data = [...dataSeries]\n .sort((a, b) => new Date(a.date).getTime() - new Date(b.date).getTime())\n .map((total) => {\n const label = formatDate(parseISO(total.date), DATE_FORMATS_INTL.MONTH_SHORT)\n\n return {\n ariaLabel: buildDynamicCopy(\n ariaLabel,\n label,\n formatCurrency(total.amount, '0.00'),\n ) as string,\n label,\n value: total.amount,\n formattedAmount: formatCurrency(total.amount, '0,0'),\n }\n })\n\n return data\n}\n\nexport const barChartVariant = (\n instanceSlot: InstanceSlot,\n instanceSlotData: InsightsInstanceSlotData,\n theme: Theme,\n) => {\n const { variant } = instanceSlot\n const barChartLayout = getLayoutConfig(theme)\n if (variant === BAR_CHART_VARIANTS.CATEGORY_COLOR && instanceSlotData.category_guid) {\n const categoryColor = getCategoryColor(instanceSlotData.category_guid, theme)\n return {\n color: categoryColor,\n }\n }\n return {\n color:\n barChartLayout[variant as keyof typeof barChartLayout]?.color ?? theme.palette.primary.main,\n }\n}\n"],"mappings":";;;;;;AAYA,IAAa,IAAqB;AAAA,EAChC,gBAAgB;AAAA,EAChB,kCAAkC;AAAA,EAClC,0BAA0B;AAC5B,GAEa,IAAA,CAAmB,MACzB,IAID,EAAK,OACA,EAAK,KAAK,IAAA,CAAK,MAAM;AAC1B,QAAM,IAAY,CAAC;AAEnB,SAAA,EAAK,OAAO,IAAA,CAAK,GAAM,MAAU;AAC/B,IAAA,EAAK,CAAA,IAAQ,EAAE,CAAA;AAAA,EACjB,CAAC,GACM;AACT,CAAC,IAEM,CAAC,IAbD,CAAC,GAiBC,IAAA,CAAkB,GAAmB,MAKnC,CAAC,GAAG,CAAU,EACxB,KAAA,CAAM,GAAG,MAAM,IAAI,KAAK,EAAE,IAAI,EAAE,QAAQ,IAAI,IAAI,KAAK,EAAE,IAAI,EAAE,QAAQ,CAAC,EACtE,IAAA,CAAK,MAAU;AACd,QAAM,IAAQ,EAAW,EAAS,EAAM,IAAI,GAAG,EAAkB,WAAW;AAE5E,SAAO;AAAA,IACL,WAAW,EACT,GACA,GACA,EAAe,EAAM,QAAQ,MAAM,CACrC;AAAA,IACA,OAAA;AAAA,IACA,OAAO,EAAM;AAAA,IACb,iBAAiB,EAAe,EAAM,QAAQ,KAAK;AAAA,EACrD;AACF,CAEK,GAGI,IAAA,CACX,GACA,GACA,MACG;AACH,QAAM,EAAE,SAAA,EAAA,IAAY,GACd,IAAiB,EAAgB,CAAK;AAC5C,SAAI,MAAY,EAAmB,kBAAkB,EAAiB,gBAE7D,EACL,OAFoB,EAAiB,EAAiB,eAAe,CAE9D,EACT,IAEK,EACL,OACE,EAAe,CAAA,GAAyC,SAAS,EAAM,QAAQ,QAAQ,KAC3F;AACF"}
1
+ {"version":3,"file":"utils.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ChartBlocks/BarchartBlock/utils.ts"],"sourcesContent":["import { type Theme } from '@mui/material/styles'\n\nimport { parseISO } from 'date-fns/parseISO'\n\nimport { getCategoryColor } from '../../../../core/utils/CategoryUtil'\nimport { buildDynamicCopy } from '../../../../core/utils/Localization'\nimport { formatCurrency } from '../../../../core/utils/NumberFormatting'\nimport { DATE_FORMATS_INTL, formatDate } from '../../../../core/constants'\nimport type { DataSeries, InstanceSlot } from '../../../../core'\nimport type { InsightsInstanceSlotData } from '../../../../core/types/InsightsInstanceSlotData'\nimport { getLayoutConfig } from './layout'\n\nexport const BAR_CHART_VARIANTS = {\n CATEGORY_COLOR: 'category_color',\n SAVINGS_ACCOUNT_BALANCES_SUMMARY: 'savings_account_balances_summary',\n MONTHLY_SPEND_COMPARISON: 'monthly_spend_comparison',\n}\n\nexport interface ChartDataSeriesItem {\n date?: string\n amount?: number\n guid?: string\n label?: string\n aggregated_guids?: string[]\n localized_label?: string\n category_guid?: string\n}\n\nexport const buildDataSeries = (data: DataSeries | undefined): ChartDataSeriesItem[] => {\n if (!data) {\n return []\n }\n\n if (data.data) {\n return data.data.map((d) => {\n const item: any = {}\n\n data.names?.map((name, index) => {\n item[name] = d[index]\n })\n return item\n })\n } else {\n return []\n }\n}\n\nexport const buildChartData = (\n dataSeries: ChartDataSeriesItem[],\n ariaLabel: string,\n dateFormat: Parameters<typeof formatDate>[1] = DATE_FORMATS_INTL.MONTH_SHORT,\n) => {\n const data = [...dataSeries]\n .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 .map((total) => {\n const label = total.date ? formatDate(parseISO(total.date), dateFormat) : (total.label ?? '')\n const amount = total.amount ?? 0\n\n return {\n ariaLabel: buildDynamicCopy(ariaLabel, label, formatCurrency(amount, '0.00')) as string,\n date: total.date ?? null,\n label,\n value: amount,\n formattedAmount: formatCurrency(amount, '0,0'),\n }\n })\n\n return data\n}\n\nexport const barChartVariant = (\n instanceSlot: InstanceSlot,\n instanceSlotData: InsightsInstanceSlotData,\n theme: Theme,\n) => {\n const { variant } = instanceSlot\n const barChartLayout = getLayoutConfig(theme)\n if (variant === BAR_CHART_VARIANTS.CATEGORY_COLOR && instanceSlotData.category_guid) {\n const categoryColor = getCategoryColor(instanceSlotData.category_guid, theme)\n return {\n color: categoryColor,\n }\n }\n return {\n color:\n barChartLayout[variant as keyof typeof barChartLayout]?.color ?? theme.palette.primary.main,\n }\n}\n"],"mappings":";;;;;;AAYA,IAAa,IAAqB;AAAA,EAChC,gBAAgB;AAAA,EAChB,kCAAkC;AAAA,EAClC,0BAA0B;AAC5B,GAYa,IAAA,CAAmB,MACzB,IAID,EAAK,OACA,EAAK,KAAK,IAAA,CAAK,MAAM;AAC1B,QAAM,IAAY,CAAC;AAEnB,SAAA,EAAK,OAAO,IAAA,CAAK,GAAM,MAAU;AAC/B,IAAA,EAAK,CAAA,IAAQ,EAAE,CAAA;AAAA,EACjB,CAAC,GACM;AACT,CAAC,IAEM,CAAC,IAbD,CAAC,GAiBC,IAAA,CACX,GACA,GACA,IAA+C,EAAkB,gBAEpD,CAAC,GAAG,CAAU,EACxB,KAAA,CAAM,GAAG,MACJ,CAAC,EAAE,QAAQ,CAAC,EAAE,OAAa,IAExB,IAAI,KAAK,EAAE,IAAI,EAAE,QAAQ,IAAI,IAAI,KAAK,EAAE,IAAI,EAAE,QAAQ,CAC9D,EACA,IAAA,CAAK,MAAU;AACd,QAAM,IAAQ,EAAM,OAAO,EAAW,EAAS,EAAM,IAAI,GAAG,CAAU,IAAK,EAAM,SAAS,IACpF,IAAS,EAAM,UAAU;AAE/B,SAAO;AAAA,IACL,WAAW,EAAiB,GAAW,GAAO,EAAe,GAAQ,MAAM,CAAC;AAAA,IAC5E,MAAM,EAAM,QAAQ;AAAA,IACpB,OAAA;AAAA,IACA,OAAO;AAAA,IACP,iBAAiB,EAAe,GAAQ,KAAK;AAAA,EAC/C;AACF,CAEK,GAGI,IAAA,CACX,GACA,GACA,MACG;AACH,QAAM,EAAE,SAAA,EAAA,IAAY,GACd,IAAiB,EAAgB,CAAK;AAC5C,SAAI,MAAY,EAAmB,kBAAkB,EAAiB,gBAE7D,EACL,OAFoB,EAAiB,EAAiB,eAAe,CAE9D,EACT,IAEK,EACL,OACE,EAAe,CAAA,GAAyC,SAAS,EAAM,QAAQ,QAAQ,KAC3F;AACF"}
@@ -4,11 +4,11 @@ import { getDonutChartColors as _ } from "./utils.es.js";
4
4
  import { Fragment as b, jsx as e, jsxs as d } from "react/jsx-runtime";
5
5
  import { useTheme as f } from "@mui/material/styles";
6
6
  var D = ({ payload: r }) => {
7
- const u = f(), { instance_slot: n, instance_slot_data: l } = r, { variant: i } = n, { legends: s = [], main: t } = l, m = _(i, l, u), c = s.map((a, p) => ({
7
+ const u = f(), { instance_slot: n, instance_slot_data: l } = r, { variant: i } = n, { legends: m = [], main: t } = l, s = _(i, l, u), c = m.map((a, p) => ({
8
8
  value: a.value,
9
- color: m[p],
9
+ color: s[p],
10
10
  label: a.label,
11
- labelValue: /* @__PURE__ */ d(b, { children: [/* @__PURE__ */ e("b", { children: o(a.value, a.value_type, "0,0.00") }), a.additional_value && a.additional_value_type ? ` (${o(a.additional_value, a.additional_value_type, "0,0.00")})` : null] })
11
+ labelValue: /* @__PURE__ */ d(b, { children: [/* @__PURE__ */ e("b", { children: o(a.value, a.value_type ?? "amount", "0,0.00") }), a.additional_value && a.additional_value_type ? ` (${o(a.additional_value, a.additional_value_type, "0,0.00")})` : null] })
12
12
  }));
13
13
  return /* @__PURE__ */ e(v, {
14
14
  centerLabel: t.label,
@@ -1 +1 @@
1
- {"version":3,"file":"DonutChartBlock.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ChartBlocks/DonutChartBlock/DonutChartBlock.tsx"],"sourcesContent":["import { useTheme } from '@mui/material/styles'\n\nimport type { DonutChartBlockData } from '../../../../core/types/InsightsInstanceSlotData'\n\nimport { formatValueByType } from '../../../CommonUtils'\n\nimport type { BlockProps } from '../../types'\n\nimport DonutChartV2 from './DonutChart'\nimport { getDonutChartColors } from './utils'\n\nconst DonutChartBlock = ({ payload }: BlockProps<DonutChartBlockData>) => {\n const theme = useTheme()\n const { instance_slot, instance_slot_data } = payload\n const { variant } = instance_slot\n const { legends = [], main } = instance_slot_data\n const colors = getDonutChartColors(variant, instance_slot_data, theme)\n\n const data = legends.map((legend: (typeof legends)[number], index: number) => ({\n value: legend.value,\n color: colors[index],\n label: legend.label,\n labelValue: (\n <>\n <b>{formatValueByType(legend.value, legend.value_type, '0,0.00')}</b>\n {legend.additional_value && legend.additional_value_type\n ? ` (${formatValueByType(legend.additional_value, legend.additional_value_type, '0,0.00')})`\n : null}\n </>\n ),\n }))\n\n return (\n <DonutChartV2\n centerLabel={main.label}\n centerValue={formatValueByType(Number(main.value), main.value_type, '0,0')}\n data={data}\n />\n )\n}\n\nexport default DonutChartBlock\n"],"mappings":";;;;;AAWA,IAAM,IAAA,CAAmB,EAAE,SAAA,EAAA,MAA+C;AACxE,QAAM,IAAQ,EAAS,GACjB,EAAE,eAAA,GAAe,oBAAA,EAAA,IAAuB,GACxC,EAAE,SAAA,EAAA,IAAY,GACd,EAAE,SAAA,IAAU,CAAC,GAAG,MAAA,EAAA,IAAS,GACzB,IAAS,EAAoB,GAAS,GAAoB,CAAK,GAE/D,IAAO,EAAQ,IAAA,CAAK,GAAkC,OAAmB;AAAA,IAC7E,OAAO,EAAO;AAAA,IACd,OAAO,EAAO,CAAA;AAAA,IACd,OAAO,EAAO;AAAA,IACd,YACE,gBAAA,EAAA,GAAA,EAAA,UAAA,CACE,gBAAA,EAAC,KAAD,EAAA,UAAI,EAAkB,EAAO,OAAO,EAAO,YAAY,QAAQ,EAAK,CAAA,GACnE,EAAO,oBAAoB,EAAO,wBAC/B,KAAK,EAAkB,EAAO,kBAAkB,EAAO,uBAAuB,QAAQ,CAAA,MACtF,IACJ,EAAA,CAAA;AAAA,EAEN,EAAE;AAEF,SACE,gBAAA,EAAC,GAAD;AAAA,IACE,aAAa,EAAK;AAAA,IAClB,aAAa,EAAkB,OAAO,EAAK,KAAK,GAAG,EAAK,YAAY,KAAK;AAAA,IACnE,MAAA;AAAA,EACP,CAAA;AAEL"}
1
+ {"version":3,"file":"DonutChartBlock.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ChartBlocks/DonutChartBlock/DonutChartBlock.tsx"],"sourcesContent":["import { useTheme } from '@mui/material/styles'\n\nimport type { DonutChartBlockData } from '../../../../core/types/InsightsInstanceSlotData'\n\nimport { formatValueByType } from '../../../CommonUtils'\n\nimport type { BlockProps } from '../../types'\n\nimport DonutChartV2 from './DonutChart'\nimport { getDonutChartColors } from './utils'\n\nconst DonutChartBlock = ({ payload }: BlockProps<DonutChartBlockData>) => {\n const theme = useTheme()\n const { instance_slot, instance_slot_data } = payload\n const { variant } = instance_slot\n const { legends = [], main } = instance_slot_data\n const colors = getDonutChartColors(variant, instance_slot_data, theme)\n\n const data = legends.map((legend: (typeof legends)[number], index: number) => ({\n value: legend.value,\n color: colors[index],\n label: legend.label,\n labelValue: (\n <>\n <b>{formatValueByType(legend.value, legend.value_type ?? 'amount', '0,0.00')}</b>\n {legend.additional_value && legend.additional_value_type\n ? ` (${formatValueByType(legend.additional_value, legend.additional_value_type, '0,0.00')})`\n : null}\n </>\n ),\n }))\n\n return (\n <DonutChartV2\n centerLabel={main.label}\n centerValue={formatValueByType(Number(main.value), main.value_type, '0,0')}\n data={data}\n />\n )\n}\n\nexport default DonutChartBlock\n"],"mappings":";;;;;AAWA,IAAM,IAAA,CAAmB,EAAE,SAAA,EAAA,MAA+C;AACxE,QAAM,IAAQ,EAAS,GACjB,EAAE,eAAA,GAAe,oBAAA,EAAA,IAAuB,GACxC,EAAE,SAAA,EAAA,IAAY,GACd,EAAE,SAAA,IAAU,CAAC,GAAG,MAAA,EAAA,IAAS,GACzB,IAAS,EAAoB,GAAS,GAAoB,CAAK,GAE/D,IAAO,EAAQ,IAAA,CAAK,GAAkC,OAAmB;AAAA,IAC7E,OAAO,EAAO;AAAA,IACd,OAAO,EAAO,CAAA;AAAA,IACd,OAAO,EAAO;AAAA,IACd,YACE,gBAAA,EAAA,GAAA,EAAA,UAAA,CACE,gBAAA,EAAC,KAAD,EAAA,UAAI,EAAkB,EAAO,OAAO,EAAO,cAAc,UAAU,QAAQ,EAAK,CAAA,GAC/E,EAAO,oBAAoB,EAAO,wBAC/B,KAAK,EAAkB,EAAO,kBAAkB,EAAO,uBAAuB,QAAQ,CAAA,MACtF,IACJ,EAAA,CAAA;AAAA,EAEN,EAAE;AAEF,SACE,gBAAA,EAAC,GAAD;AAAA,IACE,aAAa,EAAK;AAAA,IAClB,aAAa,EAAkB,OAAO,EAAK,KAAK,GAAG,EAAK,YAAY,KAAK;AAAA,IACnE,MAAA;AAAA,EACP,CAAA;AAEL"}
@@ -1,6 +1,10 @@
1
1
  import { Beat } from '../../core';
2
+ import { BeatActions } from '../beatActions';
2
3
  interface BaseLayoutProps {
3
4
  beat: Beat;
5
+ /** Host callbacks (menu actions, updateBeat, …) delivered to the card subtree
6
+ * via context, so blocks/variants can reach them without prop drilling. */
7
+ beatActions?: BeatActions;
4
8
  }
5
- declare const BaseLayout: ({ beat }: BaseLayoutProps) => import("react/jsx-runtime").JSX.Element | null;
9
+ declare const BaseLayout: ({ beat, beatActions }: BaseLayoutProps) => import("react/jsx-runtime").JSX.Element | null;
6
10
  export default BaseLayout;