@mx-cartographer/experiences 9.7.24 → 9.7.26

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 (35) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/common/components/MiniWidgetContainer.es.js +35 -45
  3. package/dist/common/components/MiniWidgetContainer.es.js.map +1 -1
  4. package/dist/common/components/charts/LineChart.es.js +86 -85
  5. package/dist/common/components/charts/LineChart.es.js.map +1 -1
  6. package/dist/common/constants/Styles.d.ts +2 -0
  7. package/dist/common/constants/Styles.es.js +17 -0
  8. package/dist/common/constants/Styles.es.js.map +1 -0
  9. package/dist/common/constants/index.d.ts +1 -0
  10. package/dist/common/hooks/useAriaLive.es.js +12 -22
  11. package/dist/common/hooks/useAriaLive.es.js.map +1 -1
  12. package/dist/common/index.es.js +111 -109
  13. package/dist/core/stores/TrendsStore.d.ts +5 -0
  14. package/dist/core/utils/DateUtil.d.ts +2 -0
  15. package/dist/core/utils/DateUtil.es.js +37 -35
  16. package/dist/core/utils/DateUtil.es.js.map +1 -1
  17. package/dist/core/utils/NumberFormatting.d.ts +1 -0
  18. package/dist/core/utils/NumberFormatting.es.js +14 -13
  19. package/dist/core/utils/NumberFormatting.es.js.map +1 -1
  20. package/dist/core/utils/TrendsUtil.d.ts +5 -0
  21. package/dist/core/utils/TrendsUtil.es.js +67 -59
  22. package/dist/core/utils/TrendsUtil.es.js.map +1 -1
  23. package/dist/insights-v2/components/BaseLayout.es.js +47 -48
  24. package/dist/insights-v2/components/BaseLayout.es.js.map +1 -1
  25. package/dist/transactions/components/shared/TransactionList.d.ts +4 -0
  26. package/dist/transactions/components/shared/TransactionList.es.js +138 -84
  27. package/dist/transactions/components/shared/TransactionList.es.js.map +1 -1
  28. package/dist/trends/components/CategoryDetailChart.d.ts +2 -1
  29. package/dist/trends/components/CategoryDetailChart.es.js +55 -35
  30. package/dist/trends/components/CategoryDetailChart.es.js.map +1 -1
  31. package/dist/trends/components/CategoryDetails.es.js +68 -71
  32. package/dist/trends/components/CategoryDetails.es.js.map +1 -1
  33. package/dist/trends/utils/TrendsTable.es.js +25 -25
  34. package/dist/trends/utils/TrendsTable.es.js.map +1 -1
  35. package/package.json +1 -1
@@ -1,72 +1,80 @@
1
- import { CategoryColors as y, CategoryGuidToName as b, CategoryGuids as _ } from "../constants/Category.es.js";
2
- var d = (e) => y[e] ?? y.default, f = (e) => b[e];
3
- function C(e, t) {
4
- const o = [], a = new Date(e);
5
- for (; a <= t; ) {
6
- const n = a.getFullYear(), r = String(a.getMonth() + 1).padStart(2, "0");
7
- o.push(+`${n}${r}`), a.setMonth(a.getMonth() + 1);
1
+ import { CategoryColors as y, CategoryGuidToName as T, CategoryGuids as b } from "../constants/Category.es.js";
2
+ import { DATE_FORMATS_INTL as i } from "../constants/DateFormats.es.js";
3
+ import { formatIsoDate as p } from "./DateUtil.es.js";
4
+ import { roundedAverage as f } from "./NumberFormatting.es.js";
5
+ var C = (t) => y[t] ?? y.default, M = (t) => T[t];
6
+ function A(t, o) {
7
+ const r = [], e = new Date(t);
8
+ for (; e <= o; ) {
9
+ const n = e.getFullYear(), a = String(e.getMonth() + 1).padStart(2, "0");
10
+ r.push(+`${n}${a}`), e.setMonth(e.getMonth() + 1);
8
11
  }
9
- return o;
12
+ return r;
10
13
  }
11
- var M = (e) => e.reduce((t, o) => {
12
- const a = {
13
- top_level_category_guid: o.top_level_category_guid,
14
- category_guid: o.category_guid,
15
- amount: o.total,
16
- year_month: o.year_month
17
- }, { top_level_category_guid: n, category_guid: r } = a;
18
- return t[r] || (t[r] = []), t[r].push(a), n !== r && (t[n] || (t[n] = []), t[n].push(a)), t;
19
- }, {}), A = (e, t, o) => {
20
- const a = M(e), n = C(t, o);
21
- return Object.entries(a).map(([r, l]) => {
22
- const c = l[0].top_level_category_guid, i = n.map((s) => {
23
- const u = l.filter((m) => m.year_month === s).reduce((m, h) => m + Math.abs(h.amount), 0), g = Number(String(s).slice(0, 4)), p = Number(String(s).slice(4));
14
+ var v = (t) => t.reduce((o, r) => {
15
+ const e = {
16
+ top_level_category_guid: r.top_level_category_guid,
17
+ category_guid: r.category_guid,
18
+ amount: r.total,
19
+ year_month: r.year_month
20
+ }, { top_level_category_guid: n, category_guid: a } = e;
21
+ return o[a] || (o[a] = []), o[a].push(e), n !== a && (o[n] || (o[n] = []), o[n].push(e)), o;
22
+ }, {}), E = (t, o, r) => {
23
+ const e = v(t), n = A(o, r);
24
+ return Object.entries(e).map(([a, u]) => {
25
+ const s = u[0].top_level_category_guid, m = n.map((l) => {
26
+ const c = u.filter((g) => g.year_month === l).reduce((g, d) => g + Math.abs(d.amount), 0), _ = Number(String(l).slice(0, 4)), h = Number(String(l).slice(4));
24
27
  return {
25
- x: new Date(g, p - 1),
26
- y: u
28
+ x: new Date(_, h - 1),
29
+ y: c
27
30
  };
28
- }).sort((s, u) => s.x.getTime() - u.x.getTime());
31
+ }).sort((l, c) => l.x.getTime() - c.x.getTime());
29
32
  return {
30
- top_level_category_guid: c,
31
- category_guid: r,
32
- category_name: f(r),
33
- category_color: d(c),
34
- dataset: i
33
+ top_level_category_guid: s,
34
+ category_guid: a,
35
+ category_name: M(a),
36
+ category_color: C(s),
37
+ dataset: m
35
38
  };
36
39
  });
37
- }, S = (e, t) => {
38
- const o = typeof e == "string" ? parseFloat(e.replace(/[^0-9.-]+/g, "")) : e, a = typeof t == "string" ? parseFloat(t.replace(/[^0-9.-]+/g, "")) : t;
39
- return (o || 0) - (a || 0);
40
- }, N = (e, t) => e.indexOf("General") >= 0 ? 1 : e.localeCompare(t), v = (e, t) => {
41
- const o = e.subCategories.filter((r) => r.currentAmount !== 0), a = e.totalMonthlyAmounts.slice(-t), n = (r) => r.substring(0, 3) + " " + r.slice(-4);
42
- return a.map((r) => {
43
- const l = n(r.label), c = o.map((s) => {
44
- const u = s.monthlyAmounts.slice(-t).find((g) => n(g.label) === l);
45
- return {
46
- label: s.name,
47
- amount: Math.abs(u?.amount || 0),
48
- header: l
49
- };
50
- }), i = e.monthlyAmounts.slice(-t).find((s) => n(s.label) === l);
40
+ }, R = (t, o) => {
41
+ const r = typeof t == "string" ? parseFloat(t.replace(/[^0-9.-]+/g, "")) : t, e = typeof o == "string" ? parseFloat(o.replace(/[^0-9.-]+/g, "")) : o;
42
+ return (r || 0) - (e || 0);
43
+ }, F = (t, o) => t.indexOf("General") >= 0 ? 1 : t.localeCompare(o), N = (t, o) => {
44
+ const r = t.subCategories.filter((e) => e.currentAmount !== 0);
45
+ return o.map(({ isoDate: e }) => {
46
+ const n = p(e, i.MONTH_SHORT_YEAR), a = (s) => Math.abs(s.find((m) => m.isoDate === e)?.amount || 0), u = r.map((s) => ({
47
+ label: s.name,
48
+ amount: a(s.monthlyAmounts),
49
+ header: n
50
+ }));
51
51
  return [{
52
- label: e.name,
53
- amount: Math.abs(i?.amount || 0),
54
- header: l
55
- }, ...c].sort((s, u) => u.amount - s.amount);
52
+ label: t.name,
53
+ amount: a(t.monthlyAmounts),
54
+ header: n
55
+ }, ...u].sort((s, m) => m.amount - s.amount);
56
56
  });
57
- }, x = (e, t) => ({
58
- monthlyAmounts: e ? e.totalMonthlyAmounts.slice(-t).map((o) => ({
59
- x: o.label.substring(0, 3),
60
- y: Math.abs(o.amount)
61
- })) : [],
62
- tooltipLabels: e ? v(e, t) : []
63
- }), D = (e) => e.slice().filter((t) => t.totalAmount !== 0 && !t.isTransfer && t.guid !== _.INVESTMENTS).sort((t, o) => Math.abs(o.totalAmount) - Math.abs(t.totalAmount));
57
+ }, H = (t, o) => {
58
+ const r = t ? t.totalMonthlyAmounts.slice(-o) : [], e = r.map(({ amount: u, isoDate: s }) => ({
59
+ x: p(s, i.MONTH_SHORT),
60
+ y: Math.abs(u)
61
+ })), n = r.map(({ amount: u, isoDate: s }) => ({
62
+ label: p(s, i.MONTH_YEAR),
63
+ amount: Math.abs(u)
64
+ })), a = t ? N(t, r) : [];
65
+ return {
66
+ average: f(e.map(({ y: u }) => u)),
67
+ monthlyAmounts: e,
68
+ monthlyTotals: n,
69
+ tooltipLabels: a
70
+ };
71
+ }, L = (t) => t.slice().filter((o) => o.totalAmount !== 0 && !o.isTransfer && o.guid !== b.INVESTMENTS).sort((o, r) => Math.abs(r.totalAmount) - Math.abs(o.totalAmount));
64
72
  export {
65
- S as amountComparator,
66
- x as buildCategoryDetailsChartData,
67
- N as categoryComparator,
68
- D as filterAndSortCategoriesWithTransactions,
69
- A as getStackedLineChartData
73
+ R as amountComparator,
74
+ H as buildCategoryDetailsChartData,
75
+ F as categoryComparator,
76
+ L as filterAndSortCategoriesWithTransactions,
77
+ E as getStackedLineChartData
70
78
  };
71
79
 
72
80
  //# sourceMappingURL=TrendsUtil.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TrendsUtil.es.js","names":[],"sources":["../../../src/core/utils/TrendsUtil.ts"],"sourcesContent":["import { GridComparatorFn } from '@mui/x-data-grid-pro'\n\nimport { CategoryColors, CategoryGuids, CategoryGuidToName } from '../constants'\nimport { DetailedCategoryWithTransactions, MonthlyCategoryTotals } from '../types'\n\ntype DataPoint = { x: Date; y: number }\ntype Dataset = DataPoint[]\n\ntype CategoryTotalData = {\n top_level_category_guid: string\n category_guid: string\n amount: number\n year_month: number // e.g. 202409\n}\n\ntype GroupedCategoryTotalData = {\n [categoryGuid: string]: CategoryTotalData[]\n}\n\nexport interface StackedLineChartData {\n top_level_category_guid: string\n category_guid: string\n category_name: string\n category_color: string\n dataset: Dataset\n}\n\nconst getCategoryColor = (categoryGuid: string): string => {\n return CategoryColors[categoryGuid] ?? CategoryColors.default\n}\n\nconst getCategoryName = (categoryGuid: string): string => {\n return CategoryGuidToName[categoryGuid]\n}\n\nfunction createYearMonthRange(start: Date, end: Date): number[] {\n const result = []\n const current = new Date(start)\n\n while (current <= end) {\n const year = current.getFullYear()\n const month = String(current.getMonth() + 1).padStart(2, '0')\n result.push(Number(`${year}${month}`))\n current.setMonth(current.getMonth() + 1)\n }\n\n return result\n}\n\nconst createGroupedCategoryTotals = (totals: MonthlyCategoryTotals[]): GroupedCategoryTotalData => {\n return totals.reduce((result, item) => {\n const totalData: CategoryTotalData = {\n top_level_category_guid: item.top_level_category_guid,\n category_guid: item.category_guid,\n amount: item.total,\n year_month: item.year_month,\n }\n\n const { top_level_category_guid, category_guid } = totalData\n\n // Ensure category bucket exists\n if (!result[category_guid]) {\n result[category_guid] = []\n }\n result[category_guid].push(totalData)\n\n // Ensure top-level category bucket exists (if different than category)\n if (top_level_category_guid !== category_guid) {\n if (!result[top_level_category_guid]) {\n result[top_level_category_guid] = []\n }\n result[top_level_category_guid].push(totalData)\n }\n\n return result\n }, {} as GroupedCategoryTotalData)\n}\n\nexport const getStackedLineChartData = (\n totals: MonthlyCategoryTotals[],\n start: Date,\n end: Date,\n): StackedLineChartData[] => {\n const groupedTotals = createGroupedCategoryTotals(totals)\n const yearMonths = createYearMonthRange(start, end)\n\n return Object.entries(groupedTotals).map(([categoryGuid, totals]) => {\n const topLevelCategoryGuid = totals[0].top_level_category_guid\n // Build dataset for current category\n const dataset: Dataset = yearMonths\n // Build chart coordinates and fill missing totals with 0\n .map((yearMonth) => {\n // Sum category totals for same month\n // (totals with same top_level_category_guid but different category_guid)\n // And fill missing totals with 0\n // (necessary for StackedLineChart lines to be smooth)\n const sumTotal = totals\n .filter((total) => total.year_month === yearMonth)\n .reduce((sum, total) => sum + Math.abs(total.amount), 0)\n\n const year = Number(String(yearMonth).slice(0, 4))\n const month = Number(String(yearMonth).slice(4))\n const date = new Date(year, month - 1)\n\n return { x: date, y: sumTotal }\n })\n .sort((a, b) => a.x.getTime() - b.x.getTime())\n\n return {\n top_level_category_guid: topLevelCategoryGuid,\n category_guid: categoryGuid,\n category_name: getCategoryName(categoryGuid),\n category_color: getCategoryColor(topLevelCategoryGuid),\n dataset: dataset,\n }\n })\n}\n\nexport const amountComparator: GridComparatorFn<string | number> = (v1, v2) => {\n const num1 = typeof v1 === 'string' ? parseFloat(v1.replace(/[^0-9.-]+/g, '')) : v1\n const num2 = typeof v2 === 'string' ? parseFloat(v2.replace(/[^0-9.-]+/g, '')) : v2\n\n return (num1 || 0) - (num2 || 0)\n}\n\nexport const categoryComparator: GridComparatorFn<string> = (cat1, cat2) => {\n // Always keep \"General\" categories at the bottom of the list\n return cat1.indexOf('General') >= 0 ? 1 : cat1.localeCompare(cat2)\n}\n\nconst buildTooltipLabels = (data: DetailedCategoryWithTransactions, monthsCount: number) => {\n const subcategories = data.subCategories.filter((subcategory) => subcategory.currentAmount !== 0)\n const monthsData = data.totalMonthlyAmounts.slice(-monthsCount)\n\n const formatMonthLabel = (label: string) => label.substring(0, 3) + ' ' + label.slice(-4)\n\n return monthsData.map((monthData) => {\n const monthLabel = formatMonthLabel(monthData.label)\n\n const subcategoryEntries = subcategories.map((subcategory) => {\n const monthEntry = subcategory.monthlyAmounts\n .slice(-monthsCount)\n .find((entry) => formatMonthLabel(entry.label) === monthLabel)\n\n return {\n label: subcategory.name,\n amount: Math.abs(monthEntry?.amount || 0),\n header: monthLabel,\n }\n })\n\n const parentMonthEntry = data.monthlyAmounts\n .slice(-monthsCount)\n .find((entry) => formatMonthLabel(entry.label) === monthLabel)\n\n const parentEntry = {\n label: data.name,\n amount: Math.abs(parentMonthEntry?.amount || 0),\n header: monthLabel,\n }\n\n return [parentEntry, ...subcategoryEntries].sort((a, b) => b.amount - a.amount)\n })\n}\n\nexport const buildCategoryDetailsChartData = (\n data: DetailedCategoryWithTransactions | null,\n monthsCount: number,\n) => {\n const monthlyAmounts = data\n ? data.totalMonthlyAmounts.slice(-monthsCount).map((monthData) => ({\n x: monthData.label.substring(0, 3),\n y: Math.abs(monthData.amount),\n }))\n : []\n\n const tooltipLabels = data ? buildTooltipLabels(data, monthsCount) : []\n\n return { monthlyAmounts, tooltipLabels }\n}\n\nexport const filterAndSortCategoriesWithTransactions = (\n categories: DetailedCategoryWithTransactions[],\n): DetailedCategoryWithTransactions[] => {\n return categories\n .slice()\n .filter(\n (category) =>\n category.totalAmount !== 0 &&\n !category.isTransf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from '@mui/x-data-grid-pro'\n\nimport { CategoryColors, CategoryGuids, CategoryGuidToName, DATE_FORMATS_INTL } from '../constants'\nimport { DetailedCategoryWithTransactions, MonthlyAmount, MonthlyCategoryTotals } from '../types'\nimport { formatIsoDate } from './DateUtil'\nimport { roundedAverage } from './NumberFormatting'\n\ntype DataPoint = { x: Date; y: number }\ntype Dataset = DataPoint[]\n\ntype CategoryTotalData = {\n top_level_category_guid: string\n category_guid: string\n amount: number\n year_month: number // e.g. 202409\n}\n\ntype GroupedCategoryTotalData = {\n [categoryGuid: string]: CategoryTotalData[]\n}\n\nexport interface StackedLineChartData {\n top_level_category_guid: string\n category_guid: string\n category_name: string\n category_color: string\n dataset: Dataset\n}\n\nconst getCategoryColor = (categoryGuid: string): string => {\n return CategoryColors[categoryGuid] ?? CategoryColors.default\n}\n\nconst getCategoryName = (categoryGuid: string): string => {\n return CategoryGuidToName[categoryGuid]\n}\n\nfunction createYearMonthRange(start: Date, end: Date): number[] {\n const result = []\n const current = new Date(start)\n\n while (current <= end) {\n const year = current.getFullYear()\n const month = String(current.getMonth() + 1).padStart(2, '0')\n result.push(Number(`${year}${month}`))\n current.setMonth(current.getMonth() + 1)\n }\n\n return result\n}\n\nconst createGroupedCategoryTotals = (totals: MonthlyCategoryTotals[]): GroupedCategoryTotalData => {\n return totals.reduce((result, item) => {\n const totalData: CategoryTotalData = {\n top_level_category_guid: item.top_level_category_guid,\n category_guid: item.category_guid,\n amount: item.total,\n year_month: item.year_month,\n }\n\n const { top_level_category_guid, category_guid } = totalData\n\n // Ensure category bucket exists\n if (!result[category_guid]) {\n result[category_guid] = []\n }\n result[category_guid].push(totalData)\n\n // Ensure top-level category bucket exists (if different than category)\n if (top_level_category_guid !== category_guid) {\n if (!result[top_level_category_guid]) {\n result[top_level_category_guid] = []\n }\n result[top_level_category_guid].push(totalData)\n }\n\n return result\n }, {} as GroupedCategoryTotalData)\n}\n\nexport const getStackedLineChartData = (\n totals: MonthlyCategoryTotals[],\n start: Date,\n end: Date,\n): StackedLineChartData[] => {\n const groupedTotals = createGroupedCategoryTotals(totals)\n const yearMonths = createYearMonthRange(start, end)\n\n return Object.entries(groupedTotals).map(([categoryGuid, totals]) => {\n const topLevelCategoryGuid = totals[0].top_level_category_guid\n // Build dataset for current category\n const dataset: Dataset = yearMonths\n // Build chart coordinates and fill missing totals with 0\n .map((yearMonth) => {\n // Sum category totals for same month\n // (totals with same top_level_category_guid but different category_guid)\n // And fill missing totals with 0\n // (necessary for StackedLineChart lines to be smooth)\n const sumTotal = totals\n .filter((total) => total.year_month === yearMonth)\n .reduce((sum, total) => sum + Math.abs(total.amount), 0)\n\n const year = Number(String(yearMonth).slice(0, 4))\n const month = Number(String(yearMonth).slice(4))\n const date = new Date(year, month - 1)\n\n return { x: date, y: sumTotal }\n })\n .sort((a, b) => a.x.getTime() - b.x.getTime())\n\n return {\n top_level_category_guid: topLevelCategoryGuid,\n category_guid: categoryGuid,\n category_name: getCategoryName(categoryGuid),\n category_color: getCategoryColor(topLevelCategoryGuid),\n dataset: dataset,\n }\n })\n}\n\nexport const amountComparator: GridComparatorFn<string | number> = (v1, v2) => {\n const num1 = typeof v1 === 'string' ? parseFloat(v1.replace(/[^0-9.-]+/g, '')) : v1\n const num2 = typeof v2 === 'string' ? parseFloat(v2.replace(/[^0-9.-]+/g, '')) : v2\n\n return (num1 || 0) - (num2 || 0)\n}\n\nexport const categoryComparator: GridComparatorFn<string> = (cat1, cat2) => {\n // Always keep \"General\" categories at the bottom of the list\n return cat1.indexOf('General') >= 0 ? 1 : cat1.localeCompare(cat2)\n}\n\nconst buildTooltipLabels = (data: DetailedCategoryWithTransactions, months: MonthlyAmount[]) => {\n const subcategories = data.subCategories.filter((subcategory) => subcategory.currentAmount !== 0)\n\n return months.map(({ isoDate }) => {\n const header = formatIsoDate(isoDate, DATE_FORMATS_INTL.MONTH_SHORT_YEAR)\n const amountFor = (amounts: MonthlyAmount[]) =>\n Math.abs(amounts.find((entry) => entry.isoDate === isoDate)?.amount || 0)\n\n const subcategoryEntries = subcategories.map((subcategory) => ({\n label: subcategory.name,\n amount: amountFor(subcategory.monthlyAmounts),\n header,\n }))\n\n const parentEntry = { label: data.name, amount: amountFor(data.monthlyAmounts), header }\n\n return [parentEntry, ...subcategoryEntries].sort((a, b) => b.amount - a.amount)\n })\n}\n\nexport const buildCategoryDetailsChartData = (\n data: DetailedCategoryWithTransactions | null,\n monthsCount: number,\n) => {\n const months = data ? data.totalMonthlyAmounts.slice(-monthsCount) : []\n\n const monthlyAmounts = months.map(({ amount, isoDate }) => ({\n x: formatIsoDate(isoDate, DATE_FORMATS_INTL.MONTH_SHORT),\n y: Math.abs(amount),\n }))\n\n const monthlyTotals = months.map(({ amount, isoDate }) => ({\n label: formatIsoDate(isoDate, DATE_FORMATS_INTL.MONTH_YEAR),\n amount: Math.abs(amount),\n }))\n\n const tooltipLabels = data ? buildTooltipLabels(data, months) : []\n\n return {\n average: roundedAverage(monthlyAmounts.map(({ y }) => y)),\n monthlyAmounts,\n monthlyTotals,\n tooltipLabels,\n }\n}\n\nexport const filterAndSortCategoriesWithTransactions = (\n categories: DetailedCategoryWithTransactions[],\n): DetailedCategoryWithTransactions[] => {\n return categories\n .slice()\n .filter(\n (category) =>\n category.totalAmount !== 0 &&\n !category.isTransfer &&\n category.guid !== CategoryGuids.INVESTMENTS,\n )\n .sort((a, b) => Math.abs(b.totalAmount) - Math.abs(a.totalAmount))\n}\n"],"mappings":";;;;AA6BA,IAAM,IAAA,CAAoB,MACjB,EAAe,CAAA,KAAiB,EAAe,SAGlD,IAAA,CAAmB,MAChB,EAAmB,CAAA;AAG5B,SAAS,EAAqB,GAAa,GAAqB;AAC9D,QAAM,IAAS,CAAC,GACV,IAAU,IAAI,KAAK,CAAK;AAE9B,SAAO,KAAW,KAAK;AACrB,UAAM,IAAO,EAAQ,YAAY,GAC3B,IAAQ,OAAO,EAAQ,SAAS,IAAI,CAAC,EAAE,SAAS,GAAG,GAAG;AAC5D,IAAA,EAAO,KAA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BAAoB,MAAM,CAAC,CAAW,IAAI,CAAC,GAEhE,IAAiB,EAAO,IAAA,CAAK,EAAE,QAAA,GAAQ,SAAA,EAAA,OAAe;AAAA,IAC1D,GAAG,EAAc,GAAS,EAAkB,WAAW;AAAA,IACvD,GAAG,KAAK,IAAI,CAAM;AAAA,EACpB,EAAE,GAEI,IAAgB,EAAO,IAAA,CAAK,EAAE,QAAA,GAAQ,SAAA,EAAA,OAAe;AAAA,IACzD,OAAO,EAAc,GAAS,EAAkB,UAAU;AAAA,IAC1D,QAAQ,KAAK,IAAI,CAAM;AAAA,EACzB,EAAE,GAEI,IAAgB,IAAO,EAAmB,GAAM,CAAM,IAAI,CAAC;AAEjE,SAAO;AAAA,IACL,SAAS,EAAe,EAAe,IAAA,CAAK,EAAE,GAAA,EAAA,MAAQ,CAAC,CAAC;AAAA,IACxD,gBAAA;AAAA,IACA,eAAA;AAAA,IACA,eAAA;AAAA,EACF;AACF,GAEa,IAAA,CACX,MAEO,EACJ,MAAM,EACN,OAAA,CACE,MACC,EAAS,gBAAgB,KACzB,CAAC,EAAS,cACV,EAAS,SAAS,EAAc,WACpC,EACC,KAAA,CAAM,GAAG,MAAM,KAAK,IAAI,EAAE,WAAW,IAAI,KAAK,IAAI,EAAE,WAAW,CAAC"}
@@ -12,21 +12,21 @@ import { ActionBlockLayer as to } from "../actionBlocks/ActionBlockLayer.es.js";
12
12
  import io from "./Footer.es.js";
13
13
  import eo from "./Header.es.js";
14
14
  import { FeedbackBar as ro } from "./FeedbackBar.es.js";
15
- import { DismissInsightDialog as no } from "./DismissInsightDialog.es.js";
16
- import { HiddenConfirmationCard as so } from "./HiddenConfirmationCard.es.js";
15
+ import { DismissInsightDialog as so } from "./DismissInsightDialog.es.js";
16
+ import { HiddenConfirmationCard as no } from "./HiddenConfirmationCard.es.js";
17
17
  import { LoadingCard as ao } from "./LoadingCard.es.js";
18
18
  import { ObsolesceBanner as lo } from "./ObsolesceBanner.es.js";
19
19
  import { useBeatFeedbackFlow as co } from "../hooks/useBeatFeedbackFlow.es.js";
20
- import { useMemo as mo } from "react";
21
- import { observer as po } from "mobx-react-lite";
20
+ import { useMemo as po } from "react";
21
+ import { observer as mo } from "mobx-react-lite";
22
22
  import g from "@mui/material/Stack";
23
- import { P as uo, Text as fo } from "@mxenabled/mxui";
24
- import p from "@mui/material/Button";
25
- import { ChevronRight as D } from "@mxenabled/mx-icons";
26
- import { Fragment as bo, jsx as t, jsxs as l } from "react/jsx-runtime";
27
- import Co from "@mui/material/Box";
28
- import ho from "@mui/material/Card";
29
- var yo = {}, go = {
23
+ import { P as fo } from "@mxenabled/mxui";
24
+ import l from "@mui/material/Button";
25
+ import { ChevronRight as T } from "@mxenabled/mx-icons";
26
+ import { Fragment as uo, jsx as t, jsxs as c } from "react/jsx-runtime";
27
+ import bo from "@mui/material/Box";
28
+ import Co from "@mui/material/Card";
29
+ var ho = {}, yo = {
30
30
  position: "absolute",
31
31
  top: 0,
32
32
  left: 0,
@@ -35,7 +35,7 @@ var yo = {}, go = {
35
35
  backgroundColor: "background.default",
36
36
  opacity: 0.7,
37
37
  zIndex: 1
38
- }, ko = {
38
+ }, go = {
39
39
  alignItems: "center",
40
40
  alignSelf: "flex-start",
41
41
  display: "flex",
@@ -43,44 +43,44 @@ var yo = {}, go = {
43
43
  height: 44,
44
44
  px: 2,
45
45
  textTransform: "none"
46
- }, $o = po(({ beat: i, beatActions: n = yo, obsolete: u, isLoading: L = !1, isError: O = !1 }) => {
47
- const I = j(), w = K(), { config: A } = U(), o = co(i, n), F = z(), { runCta: E, primary: k, secondary: x } = $(i, n, i.insights_payload?.primary_cta, i.insights_payload?.secondary_cta), c = i.insights_payload?.widget_type === "mini", M = mo(() => ({
46
+ }, Yo = mo(({ beat: i, beatActions: s = ho, obsolete: f, isLoading: L = !1, isError: O = !1 }) => {
47
+ const I = j(), w = K(), { config: A } = U(), o = co(i, s), F = z(), { runCta: E, primary: k, secondary: x } = $(i, s, i.insights_payload?.primary_cta, i.insights_payload?.secondary_cta), d = i.insights_payload?.widget_type === "mini", M = po(() => ({
48
48
  ...o.wrappedActions,
49
49
  beat: i
50
50
  }), [o.wrappedActions, i]);
51
51
  if (O) return /* @__PURE__ */ t(Z, {});
52
52
  const e = i.insights_payload;
53
53
  if (!e || o.cardState === "dismissed") return null;
54
- const { instance_slot: N, primary_cta: r, secondary_cta: s, sub_title: R, title: H, guid: _, dismissed_at: P } = e, { block: V } = N, G = R ?? (e.subtitle ? {
54
+ const { instance_slot: N, primary_cta: r, secondary_cta: n, sub_title: R, title: H, guid: _, dismissed_at: P } = e, { block: V } = N, G = R ?? (e.subtitle ? {
55
55
  logo: J(e.logo),
56
56
  text: e.subtitle
57
- } : void 0), d = (m) => W(m, A, n.onContactSupport), v = async (m, y) => {
58
- if (!d(y.block)) {
57
+ } : void 0), p = (m) => W(m, A, s.onContactSupport), v = async (m, y) => {
58
+ if (!p(y.block)) {
59
59
  if (y.block === q.CONTACT_SUPPORT_ACTION_BLOCK) {
60
60
  Y({
61
61
  beat: i,
62
62
  stores: F,
63
- hostActions: n,
63
+ hostActions: s,
64
64
  slot: m
65
- }), n.onContactSupport?.();
65
+ }), s.onContactSupport?.();
66
66
  return;
67
67
  }
68
68
  await E(m, y);
69
69
  }
70
- }, S = oo[V], a = e.in_description_cta, f = !c && a?.label && a.block ? a : void 0, b = r?.label || (f ? void 0 : a?.label) || void 0, B = !c && !!r?.label, T = !c && !!s?.label, C = I.insights_feed?.general, h = u?.state === "not_refreshable" && !P && !!C;
70
+ }, S = oo[V], a = e.in_description_cta, u = !d && a?.label && a.block ? a : void 0, b = r?.label || (u ? void 0 : a?.label) || void 0, B = !d && !!r?.label, D = !d && !!n?.label, C = I.insights_feed?.general, h = f?.state === "not_refreshable" && !P && !!C;
71
71
  return /* @__PURE__ */ t(X, {
72
72
  value: M,
73
- children: /* @__PURE__ */ l(g, {
73
+ children: /* @__PURE__ */ c(g, {
74
74
  sx: { mb: 16 },
75
75
  children: [
76
- o.cardState === "confirming" ? /* @__PURE__ */ t(so, {
76
+ o.cardState === "confirming" ? /* @__PURE__ */ t(no, {
77
77
  onClose: o.collapseConfirmation,
78
78
  onLeaveFeedback: o.openHideSurvey,
79
79
  onUndo: o.undoDismiss
80
- }) : /* @__PURE__ */ l(bo, { children: [u && C && /* @__PURE__ */ t(lo, {
81
- ...u,
80
+ }) : /* @__PURE__ */ c(uo, { children: [f && C && /* @__PURE__ */ t(lo, {
81
+ ...f,
82
82
  copy: C
83
- }), /* @__PURE__ */ l(ho, {
83
+ }), /* @__PURE__ */ c(Co, {
84
84
  inert: h,
85
85
  sx: { ...h && {
86
86
  position: "relative",
@@ -88,9 +88,9 @@ var yo = {}, go = {
88
88
  pointerEvents: "none"
89
89
  } },
90
90
  children: [
91
- h && /* @__PURE__ */ t(Co, { sx: go }),
91
+ h && /* @__PURE__ */ t(bo, { sx: yo }),
92
92
  /* @__PURE__ */ t(eo, {
93
- isMini: c,
93
+ isMini: d,
94
94
  subtitle: G,
95
95
  title: H ?? ""
96
96
  }),
@@ -98,7 +98,7 @@ var yo = {}, go = {
98
98
  beatGuid: _,
99
99
  payload: e
100
100
  }),
101
- /* @__PURE__ */ l(g, {
101
+ /* @__PURE__ */ c(g, {
102
102
  sx: {
103
103
  gap: 6,
104
104
  pb: 16,
@@ -106,12 +106,12 @@ var yo = {}, go = {
106
106
  px: 16
107
107
  },
108
108
  children: [
109
- /* @__PURE__ */ t(uo, {
109
+ /* @__PURE__ */ t(fo, {
110
110
  dangerouslySetInnerHTML: { __html: e.description.html_text },
111
111
  variant: "subtitle2"
112
112
  }),
113
- f && /* @__PURE__ */ t(p, {
114
- endIcon: /* @__PURE__ */ t(D, {}),
113
+ u && /* @__PURE__ */ t(l, {
114
+ endIcon: /* @__PURE__ */ t(T, {}),
115
115
  onClick: () => w.openActionDrawer({
116
116
  guid: _,
117
117
  trigger: "inDescriptionCta"
@@ -121,10 +121,10 @@ var yo = {}, go = {
121
121
  p: 4,
122
122
  width: "max-content"
123
123
  },
124
- children: f.label
124
+ children: u.label
125
125
  }),
126
- !a?.label && i?.in_description_cta && /* @__PURE__ */ t(p, {
127
- endIcon: /* @__PURE__ */ t(D, {}),
126
+ !a?.label && i?.in_description_cta && /* @__PURE__ */ t(l, {
127
+ endIcon: /* @__PURE__ */ t(T, {}),
128
128
  onClick: () => {
129
129
  },
130
130
  sx: {
@@ -136,33 +136,32 @@ var yo = {}, go = {
136
136
  })
137
137
  ]
138
138
  }),
139
- (b || T) && /* @__PURE__ */ l(g, {
139
+ (b || D) && /* @__PURE__ */ c(g, {
140
140
  sx: {
141
141
  gap: 8,
142
142
  pb: 16,
143
143
  px: 16
144
144
  },
145
145
  children: [
146
- b && !B && /* @__PURE__ */ t(fo, {
147
- color: "primary.main",
148
- sx: ko,
149
- variant: "button",
146
+ b && !B && /* @__PURE__ */ t(l, {
147
+ sx: go,
148
+ variant: "text",
150
149
  children: b
151
150
  }),
152
- B && r && /* @__PURE__ */ t(p, {
153
- "aria-disabled": d(r.block) || k.disabled,
151
+ B && r && /* @__PURE__ */ t(l, {
152
+ "aria-disabled": p(r.block) || k.disabled,
154
153
  disabled: k.disabled,
155
154
  onClick: () => v("primary", r),
156
- sx: { ...d(r.block) && { color: "text.disabled" } },
155
+ sx: { ...p(r.block) && { color: "text.disabled" } },
157
156
  variant: "outlined",
158
157
  children: r.label
159
158
  }),
160
- T && s && /* @__PURE__ */ t(p, {
161
- "aria-disabled": d(s.block) || x.disabled,
159
+ D && n && /* @__PURE__ */ t(l, {
160
+ "aria-disabled": p(n.block) || x.disabled,
162
161
  color: "secondary",
163
162
  disabled: x.disabled,
164
- onClick: () => v("secondary", s),
165
- children: s.label
163
+ onClick: () => v("secondary", n),
164
+ children: n.label
166
165
  })
167
166
  ]
168
167
  }),
@@ -173,7 +172,7 @@ var yo = {}, go = {
173
172
  ]
174
173
  })] }),
175
174
  /* @__PURE__ */ t(to, { beat: i }),
176
- /* @__PURE__ */ t(no, {
175
+ /* @__PURE__ */ t(so, {
177
176
  isOpen: o.isDismissOpen,
178
177
  onClose: o.closeDismissDialog,
179
178
  onDismiss: o.confirmDismiss
@@ -197,7 +196,7 @@ var yo = {}, go = {
197
196
  });
198
197
  });
199
198
  export {
200
- $o as default
199
+ Yo as default
201
200
  };
202
201
 
203
202
  //# sourceMappingURL=BaseLayout.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BaseLayout.es.js","names":[],"sources":["../../../src/insights-v2/components/BaseLayout.tsx"],"sourcesContent":["import { useMemo } from 'react'\n\nimport { observer } from 'mobx-react-lite'\n\nimport Box from '@mui/material/Box'\nimport Button from '@mui/material/Button'\nimport Card from '@mui/material/Card'\nimport Stack from '@mui/material/Stack'\n\nimport { ChevronRight } from '@mxenabled/mx-icons'\nimport { P, Text } from '@mxenabled/mxui'\n\nimport { blocks } from '../mappings/blocks'\nimport { actionBlocksKey } from '../mappings/actionBlocksKey'\nimport { isContactSupportCtaDisabled } from '../actionBlocks/ContactSupportActionBlock'\nimport { logoFromRef } from './shared/EntityLogo'\n\nimport Footer from './Footer'\nimport Header from './Header'\nimport FeedbackBar from './FeedbackBar'\nimport FeedbackDialog from './FeedbackDialog'\nimport DismissInsightDialog from './DismissInsightDialog'\nimport HiddenConfirmationCard from './HiddenConfirmationCard'\nimport ErrorCard from './ErrorCard'\nimport LoadingCard from './LoadingCard'\nimport { ObsolesceBanner, type ObsolesceBannerState } from './ObsolesceBanner'\nimport { useAppConfig, useGlobalCopyStore, useGlobalStore, useInsightsV2Store } from '../../common'\nimport type { Beat, PrimaryCTA, SecondaryCTA } from '../../core'\nimport { BeatActionsProvider, type BeatActions } from '../beatActions'\nimport { ActionBlockLayer } from '../actionBlocks/ActionBlockLayer'\nimport { reportCtaClick, useBeatCtaActions } from '../ctaActions'\nimport { useBeatFeedbackFlow } from '../hooks/useBeatFeedbackFlow'\n\nexport interface ObsoleteState {\n state: ObsolesceBannerState\n onRefresh: () => void\n onDismiss: () => void\n}\n\ninterface BaseLayoutProps {\n beat: Beat\n beatActions?: BeatActions\n obsolete?: ObsoleteState\n /** Swap only the block slot for a LoadingCard (e.g. while a sampled beat loads). */\n isLoading?: boolean\n /** Replace the entire card with an ErrorCard (e.g. when the sample fails to load). */\n isError?: boolean\n}\n\nconst NO_BEAT_ACTIONS: BeatActions = {}\n\nconst OBSOLETE_OVERLAY_SX = {\n position: 'absolute',\n top: 0,\n left: 0,\n width: '100%',\n height: '100%',\n backgroundColor: 'background.default',\n opacity: 0.7,\n zIndex: 1,\n} as const\n\n// Mini CTA label styled like a Button.\nconst MINI_CTA_SX = {\n alignItems: 'center',\n alignSelf: 'flex-start',\n display: 'flex',\n fontWeight: 600,\n height: 44,\n px: 2,\n textTransform: 'none',\n} as const\n\nconst BaseLayout = observer(\n ({\n beat,\n beatActions = NO_BEAT_ACTIONS,\n obsolete,\n isLoading = false,\n isError = false,\n }: BaseLayoutProps) => {\n const copy = useGlobalCopyStore()\n const insightsV2Store = useInsightsV2Store()\n const { config } = useAppConfig()\n const flow = useBeatFeedbackFlow(beat, beatActions)\n\n const stores = useGlobalStore()\n const {\n runCta: handleCtaClick,\n primary: primaryCtaState,\n secondary: secondaryCtaState,\n } = useBeatCtaActions(\n beat,\n beatActions,\n beat.insights_payload?.primary_cta,\n beat.insights_payload?.secondary_cta,\n )\n\n // Guard: payload may not be loaded yet (isLoading/isError states).\n const isMini = beat.insights_payload?.widget_type === 'mini'\n\n // Memoized: an inline object here would change identity every render, making every\n // useAnalyticsEvent() consumer's callback (and its effect deps) unstable too.\n const beatActionsValue = useMemo(\n () => ({ ...flow.wrappedActions, beat }),\n [flow.wrappedActions, beat],\n )\n\n // Error replaces the entire card; loading only swaps the block slot (below).\n if (isError) return <ErrorCard />\n\n const insights_payload = beat.insights_payload\n\n if (!insights_payload) return null\n if (flow.cardState === 'dismissed') return null\n\n const { instance_slot, primary_cta, secondary_cta, sub_title, title, guid, dismissed_at } =\n insights_payload\n const { block } = instance_slot\n\n // Rebuild V1 subtitle shape; sub_title wins if present.\n const subtitle =\n sub_title ??\n (insights_payload.subtitle\n ? {\n logo: logoFromRef(insights_payload.logo),\n text: insights_payload.subtitle,\n }\n : undefined)\n\n // CTAs run via ctaActions; contact_support_block bypasses it.\n const isCtaDisabled = (ctaBlock: string | null | undefined) =>\n isContactSupportCtaDisabled(ctaBlock, config, beatActions.onContactSupport)\n\n const onCtaClick = async (slot: 'primary' | 'secondary', cta: PrimaryCTA | SecondaryCTA) => {\n if (isCtaDisabled(cta.block)) return\n\n if (cta.block === actionBlocksKey.CONTACT_SUPPORT_ACTION_BLOCK) {\n // Bypasses the runner, but still reports the press like any other CTA: the generic\n // press event, and (on a first primary press) FIRST_TIME_PRIMARY_ACTION_SELECTED +\n // cta_clicked_at.\n reportCtaClick({ beat, stores, hostActions: beatActions, slot })\n beatActions.onContactSupport?.()\n return\n }\n\n await handleCtaClick(slot, cta)\n }\n\n const Block = blocks[block as keyof typeof blocks]\n\n const inDescriptionCta = insights_payload.in_description_cta\n // Full card: the envelope's link opens the drawer its block names. A link with no block (mini's\n // \"Make a Transfer\") is the card's action, drawn as the mini label below, never a dead link.\n const envelopeLink =\n !isMini && inDescriptionCta?.label && inDescriptionCta.block ? inDescriptionCta : undefined\n // The card's action label: the primary CTA's, else a block-less envelope link's (ditto ≥ 1.4.3\n // sends mini's action as in_description_cta). `||`, not `??`: the copy may send the primary label\n // as \"\" rather than omit it, and an empty string must fall through. It is a button only on a full\n // card with a primary CTA; otherwise a label, so a tap reaches the host's card handler.\n const ctaLabel =\n primary_cta?.label || (envelopeLink ? undefined : inDescriptionCta?.label) || undefined\n const isCtaButton = !isMini && !!primary_cta?.label\n const showSecondaryCta = !isMini && !!secondary_cta?.label\n const obsoleteCopy = copy.insights_feed?.general\n const isObsoleteDimmed =\n obsolete?.state === 'not_refreshable' && !dismissed_at && !!obsoleteCopy\n\n return (\n <BeatActionsProvider value={beatActionsValue}>\n <Stack sx={{ mb: 16 }}>\n {flow.cardState === 'confirming' ? (\n <HiddenConfirmationCard\n onClose={flow.collapseConfirmation}\n onLeaveFeedback={flow.openHideSurvey}\n onUndo={flow.undoDismiss}\n />\n ) : (\n <>\n {obsolete && obsoleteCopy && <ObsolesceBanner {...obsolete} copy={obsoleteCopy} />}\n <Card\n inert={isObsoleteDimmed}\n sx={{\n ...(isObsoleteDimmed && {\n position: 'relative',\n zIndex: 2,\n pointerEvents: 'none',\n }),\n }}\n >\n {isObsoleteDimmed && <Box sx={OBSOLETE_OVERLAY_SX} />}\n <Header isMini={isMini} subtitle={subtitle} title={title ?? ''} />\n {isLoading ? (\n <LoadingCard />\n ) : (\n Block && <Block beatGuid={guid} payload={insights_payload} />\n )}\n\n <Stack sx={{ gap: 6, pb: 16, pt: 12, px: 16 }}>\n <P\n dangerouslySetInnerHTML={{\n __html: insights_payload.description.html_text,\n }}\n variant=\"subtitle2\"\n />\n {/* V2: the envelope's link opens the action block it names. */}\n {envelopeLink && (\n <Button\n endIcon={<ChevronRight />}\n onClick={() =>\n insightsV2Store.openActionDrawer({ guid, trigger: 'inDescriptionCta' })\n }\n sx={{ height: 24, p: 4, width: 'max-content' }}\n >\n {envelopeLink.label}\n </Button>\n )}\n {/* V1: the legacy field, shown for beats that do not send the envelope link. */}\n {!inDescriptionCta?.label && beat?.in_description_cta && (\n <Button\n endIcon={<ChevronRight />}\n onClick={() => {}}\n sx={{ height: 24, p: 4, width: 'max-content' }}\n >\n {beat.in_description_cta}\n </Button>\n )}\n </Stack>\n\n {(ctaLabel || showSecondaryCta) && (\n <Stack sx={{ gap: 8, pb: 16, px: 16 }}>\n {ctaLabel &&\n !isCtaButton && (\n // Mini is a tap target, as in V1: the card, not this label, is the control. The label\n // is deliberately not a button, so a tap on it reaches the host's card handler (Pulse\n // posts `carousel/cta`, the same redirect a V1 mini card sends) instead of opening\n // the action drawer the full card's CTA opens.\n <Text color=\"primary.main\" sx={MINI_CTA_SX} variant=\"button\">\n {ctaLabel}\n </Text>\n )}\n {isCtaButton && primary_cta && (\n <Button\n aria-disabled={isCtaDisabled(primary_cta.block) || primaryCtaState.disabled}\n disabled={primaryCtaState.disabled}\n onClick={() => onCtaClick('primary', primary_cta)}\n sx={{\n ...(isCtaDisabled(primary_cta.block) && { color: 'text.disabled' }),\n }}\n variant=\"outlined\"\n >\n {primary_cta.label}\n </Button>\n )}\n {/* Mini has room for one CTA. */}\n {showSecondaryCta && secondary_cta && (\n <Button\n aria-disabled={\n isCtaDisabled(secondary_cta.block) || secondaryCtaState.disabled\n }\n color=\"secondary\"\n disabled={secondaryCtaState.disabled}\n onClick={() => onCtaClick('secondary', secondary_cta)}\n >\n {secondary_cta.label}\n </Button>\n )}\n </Stack>\n )}\n\n <FeedbackBar onTellUsMore={flow.openRatingSurvey} show={flow.isFeedbackBarShown} />\n </Card>\n </>\n )}\n\n <ActionBlockLayer beat={beat} />\n\n <DismissInsightDialog\n isOpen={flow.isDismissOpen}\n onClose={flow.closeDismissDialog}\n onDismiss={flow.confirmDismiss}\n />\n\n {flow.isSurveyOpen && (\n <FeedbackDialog\n characterLimitLabel={flow.survey.characterLimitLabel}\n closeAriaLabel={flow.survey.closeAriaLabel}\n isOpen={true}\n onBackClick={flow.feedbackDialogCallbacks.onBackClick}\n onClose={flow.closeSurvey}\n onSubmit={flow.submitSurvey}\n onTextInputFocus={flow.feedbackDialogCallbacks.onTextInputFocus}\n options={flow.survey.options}\n primaryText={flow.survey.submitText}\n secondaryText={flow.survey.backText}\n title={flow.survey.title}\n />\n )}\n\n {flow.cardState === 'visible' && insights_payload.footer && (\n <Footer footer={insights_payload.footer} />\n )}\n </Stack>\n </BeatActionsProvider>\n )\n },\n)\n\nexport default BaseLayout\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,IAAM,KAA+B,CAAC,GAEhC,KAAsB;AAAA,EAC1B,UAAU;AAAA,EACV,KAAK;AAAA,EACL,MAAM;AAAA,EACN,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,iBAAiB;AAAA,EACjB,SAAS;AAAA,EACT,QAAQ;AACV,GAGM,K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C,SAAS,EAAK,OAAO;AAAA,UACrB,aAAa,EAAK,OAAO;AAAA,UACzB,eAAe,EAAK,OAAO;AAAA,UAC3B,OAAO,EAAK,OAAO;AAAA,QACpB,CAAA;AAAA,QAGF,EAAK,cAAc,aAAa,EAAiB,UAChD,gBAAA,EAAC,IAAD,EAAQ,QAAQ,EAAiB,OAAS,CAAA;AAAA,MAEvC;AAAA;EACY,CAAA;AAEzB,CACF"}
1
+ {"version":3,"file":"BaseLayout.es.js","names":[],"sources":["../../../src/insights-v2/components/BaseLayout.tsx"],"sourcesContent":["import { useMemo } from 'react'\n\nimport { observer } from 'mobx-react-lite'\n\nimport Box from '@mui/material/Box'\nimport Button from '@mui/material/Button'\nimport Card from '@mui/material/Card'\nimport Stack from '@mui/material/Stack'\n\nimport { ChevronRight } from '@mxenabled/mx-icons'\nimport { P } from '@mxenabled/mxui'\n\nimport { blocks } from '../mappings/blocks'\nimport { actionBlocksKey } from '../mappings/actionBlocksKey'\nimport { isContactSupportCtaDisabled } from '../actionBlocks/ContactSupportActionBlock'\nimport { logoFromRef } from './shared/EntityLogo'\n\nimport Footer from './Footer'\nimport Header from './Header'\nimport FeedbackBar from './FeedbackBar'\nimport FeedbackDialog from './FeedbackDialog'\nimport DismissInsightDialog from './DismissInsightDialog'\nimport HiddenConfirmationCard from './HiddenConfirmationCard'\nimport ErrorCard from './ErrorCard'\nimport LoadingCard from './LoadingCard'\nimport { ObsolesceBanner, type ObsolesceBannerState } from './ObsolesceBanner'\nimport { useAppConfig, useGlobalCopyStore, useGlobalStore, useInsightsV2Store } from '../../common'\nimport type { Beat, PrimaryCTA, SecondaryCTA } from '../../core'\nimport { BeatActionsProvider, type BeatActions } from '../beatActions'\nimport { ActionBlockLayer } from '../actionBlocks/ActionBlockLayer'\nimport { reportCtaClick, useBeatCtaActions } from '../ctaActions'\nimport { useBeatFeedbackFlow } from '../hooks/useBeatFeedbackFlow'\n\nexport interface ObsoleteState {\n state: ObsolesceBannerState\n onRefresh: () => void\n onDismiss: () => void\n}\n\ninterface BaseLayoutProps {\n beat: Beat\n beatActions?: BeatActions\n obsolete?: ObsoleteState\n /** Swap only the block slot for a LoadingCard (e.g. while a sampled beat loads). */\n isLoading?: boolean\n /** Replace the entire card with an ErrorCard (e.g. when the sample fails to load). */\n isError?: boolean\n}\n\nconst NO_BEAT_ACTIONS: BeatActions = {}\n\nconst OBSOLETE_OVERLAY_SX = {\n position: 'absolute',\n top: 0,\n left: 0,\n width: '100%',\n height: '100%',\n backgroundColor: 'background.default',\n opacity: 0.7,\n zIndex: 1,\n} as const\n\n// Mini CTA label styled like a Button.\nconst MINI_CTA_SX = {\n alignItems: 'center',\n alignSelf: 'flex-start',\n display: 'flex',\n fontWeight: 600,\n height: 44,\n px: 2,\n textTransform: 'none',\n} as const\n\nconst BaseLayout = observer(\n ({\n beat,\n beatActions = NO_BEAT_ACTIONS,\n obsolete,\n isLoading = false,\n isError = false,\n }: BaseLayoutProps) => {\n const copy = useGlobalCopyStore()\n const insightsV2Store = useInsightsV2Store()\n const { config } = useAppConfig()\n const flow = useBeatFeedbackFlow(beat, beatActions)\n\n const stores = useGlobalStore()\n const {\n runCta: handleCtaClick,\n primary: primaryCtaState,\n secondary: secondaryCtaState,\n } = useBeatCtaActions(\n beat,\n beatActions,\n beat.insights_payload?.primary_cta,\n beat.insights_payload?.secondary_cta,\n )\n\n // Guard: payload may not be loaded yet (isLoading/isError states).\n const isMini = beat.insights_payload?.widget_type === 'mini'\n\n // Memoized: an inline object here would change identity every render, making every\n // useAnalyticsEvent() consumer's callback (and its effect deps) unstable too.\n const beatActionsValue = useMemo(\n () => ({ ...flow.wrappedActions, beat }),\n [flow.wrappedActions, beat],\n )\n\n // Error replaces the entire card; loading only swaps the block slot (below).\n if (isError) return <ErrorCard />\n\n const insights_payload = beat.insights_payload\n\n if (!insights_payload) return null\n if (flow.cardState === 'dismissed') return null\n\n const { instance_slot, primary_cta, secondary_cta, sub_title, title, guid, dismissed_at } =\n insights_payload\n const { block } = instance_slot\n\n // Rebuild V1 subtitle shape; sub_title wins if present.\n const subtitle =\n sub_title ??\n (insights_payload.subtitle\n ? {\n logo: logoFromRef(insights_payload.logo),\n text: insights_payload.subtitle,\n }\n : undefined)\n\n // CTAs run via ctaActions; contact_support_block bypasses it.\n const isCtaDisabled = (ctaBlock: string | null | undefined) =>\n isContactSupportCtaDisabled(ctaBlock, config, beatActions.onContactSupport)\n\n const onCtaClick = async (slot: 'primary' | 'secondary', cta: PrimaryCTA | SecondaryCTA) => {\n if (isCtaDisabled(cta.block)) return\n\n if (cta.block === actionBlocksKey.CONTACT_SUPPORT_ACTION_BLOCK) {\n // Bypasses the runner, but still reports the press like any other CTA: the generic\n // press event, and (on a first primary press) FIRST_TIME_PRIMARY_ACTION_SELECTED +\n // cta_clicked_at.\n reportCtaClick({ beat, stores, hostActions: beatActions, slot })\n beatActions.onContactSupport?.()\n return\n }\n\n await handleCtaClick(slot, cta)\n }\n\n const Block = blocks[block as keyof typeof blocks]\n\n const inDescriptionCta = insights_payload.in_description_cta\n // Full card: the envelope's link opens the drawer its block names. A link with no block (mini's\n // \"Make a Transfer\") is the card's action, drawn as the mini label below, never a dead link.\n const envelopeLink =\n !isMini && inDescriptionCta?.label && inDescriptionCta.block ? inDescriptionCta : undefined\n // The card's action label: the primary CTA's, else a block-less envelope link's (ditto ≥ 1.4.3\n // sends mini's action as in_description_cta). `||`, not `??`: the copy may send the primary label\n // as \"\" rather than omit it, and an empty string must fall through. It is a button only on a full\n // card with a primary CTA; otherwise a label, so a tap reaches the host's card handler.\n const ctaLabel =\n primary_cta?.label || (envelopeLink ? undefined : inDescriptionCta?.label) || undefined\n const isCtaButton = !isMini && !!primary_cta?.label\n const showSecondaryCta = !isMini && !!secondary_cta?.label\n const obsoleteCopy = copy.insights_feed?.general\n const isObsoleteDimmed =\n obsolete?.state === 'not_refreshable' && !dismissed_at && !!obsoleteCopy\n\n return (\n <BeatActionsProvider value={beatActionsValue}>\n <Stack sx={{ mb: 16 }}>\n {flow.cardState === 'confirming' ? (\n <HiddenConfirmationCard\n onClose={flow.collapseConfirmation}\n onLeaveFeedback={flow.openHideSurvey}\n onUndo={flow.undoDismiss}\n />\n ) : (\n <>\n {obsolete && obsoleteCopy && <ObsolesceBanner {...obsolete} copy={obsoleteCopy} />}\n <Card\n inert={isObsoleteDimmed}\n sx={{\n ...(isObsoleteDimmed && {\n position: 'relative',\n zIndex: 2,\n pointerEvents: 'none',\n }),\n }}\n >\n {isObsoleteDimmed && <Box sx={OBSOLETE_OVERLAY_SX} />}\n <Header isMini={isMini} subtitle={subtitle} title={title ?? ''} />\n {isLoading ? (\n <LoadingCard />\n ) : (\n Block && <Block beatGuid={guid} payload={insights_payload} />\n )}\n\n <Stack sx={{ gap: 6, pb: 16, pt: 12, px: 16 }}>\n <P\n dangerouslySetInnerHTML={{\n __html: insights_payload.description.html_text,\n }}\n variant=\"subtitle2\"\n />\n {/* V2: the envelope's link opens the action block it names. */}\n {envelopeLink && (\n <Button\n endIcon={<ChevronRight />}\n onClick={() =>\n insightsV2Store.openActionDrawer({ guid, trigger: 'inDescriptionCta' })\n }\n sx={{ height: 24, p: 4, width: 'max-content' }}\n >\n {envelopeLink.label}\n </Button>\n )}\n {/* V1: the legacy field, shown for beats that do not send the envelope link. */}\n {!inDescriptionCta?.label && beat?.in_description_cta && (\n <Button\n endIcon={<ChevronRight />}\n onClick={() => {}}\n sx={{ height: 24, p: 4, width: 'max-content' }}\n >\n {beat.in_description_cta}\n </Button>\n )}\n </Stack>\n\n {(ctaLabel || showSecondaryCta) && (\n <Stack sx={{ gap: 8, pb: 16, px: 16 }}>\n {ctaLabel &&\n !isCtaButton && (\n // The card's action when it has no primary CTA button (mini always; a full card whose\n // only link names no block). What the tap does is the host's decision (Pulse posts\n // `carousel/cta`, the same redirect a V1 mini card sends), never the action drawer the\n // full card's CTA opens. It is a real (blue, focusable) button for that tap, but has no\n // handler of its own and does not stop the click, so it reaches the host's card handler\n // exactly as a tap on the card does.\n <Button sx={MINI_CTA_SX} variant=\"text\">\n {ctaLabel}\n </Button>\n )}\n {isCtaButton && primary_cta && (\n <Button\n aria-disabled={isCtaDisabled(primary_cta.block) || primaryCtaState.disabled}\n disabled={primaryCtaState.disabled}\n onClick={() => onCtaClick('primary', primary_cta)}\n sx={{\n ...(isCtaDisabled(primary_cta.block) && { color: 'text.disabled' }),\n }}\n variant=\"outlined\"\n >\n {primary_cta.label}\n </Button>\n )}\n {/* Mini has room for one CTA. */}\n {showSecondaryCta && secondary_cta && (\n <Button\n aria-disabled={\n isCtaDisabled(secondary_cta.block) || secondaryCtaState.disabled\n }\n color=\"secondary\"\n disabled={secondaryCtaState.disabled}\n onClick={() => onCtaClick('secondary', secondary_cta)}\n >\n {secondary_cta.label}\n </Button>\n )}\n </Stack>\n )}\n\n <FeedbackBar onTellUsMore={flow.openRatingSurvey} show={flow.isFeedbackBarShown} />\n </Card>\n </>\n )}\n\n <ActionBlockLayer beat={beat} />\n\n <DismissInsightDialog\n isOpen={flow.isDismissOpen}\n onClose={flow.closeDismissDialog}\n onDismiss={flow.confirmDismiss}\n />\n\n {flow.isSurveyOpen && (\n <FeedbackDialog\n characterLimitLabel={flow.survey.characterLimitLabel}\n closeAriaLabel={flow.survey.closeAriaLabel}\n isOpen={true}\n onBackClick={flow.feedbackDialogCallbacks.onBackClick}\n onClose={flow.closeSurvey}\n onSubmit={flow.submitSurvey}\n onTextInputFocus={flow.feedbackDialogCallbacks.onTextInputFocus}\n options={flow.survey.options}\n primaryText={flow.survey.submitText}\n secondaryText={flow.survey.backText}\n title={flow.survey.title}\n />\n )}\n\n {flow.cardState === 'visible' && insights_payload.footer && (\n <Footer footer={insights_payload.footer} />\n )}\n </Stack>\n </BeatActionsProvider>\n )\n },\n)\n\nexport default BaseLayout\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,IAAM,KAA+B,CAAC,GAEhC,KAAsB;AAAA,EAC1B,UAAU;AAAA,EACV,KAAK;AAAA,EACL,MAAM;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UAC1C,SAAS,EAAK;AAAA,UACd,UAAU,EAAK;AAAA,UACf,kBAAkB,EAAK,wBAAwB;AAAA,UAC/C,SAAS,EAAK,OAAO;AAAA,UACrB,aAAa,EAAK,OAAO;AAAA,UACzB,eAAe,EAAK,OAAO;AAAA,UAC3B,OAAO,EAAK,OAAO;AAAA,QACpB,CAAA;AAAA,QAGF,EAAK,cAAc,aAAa,EAAiB,UAChD,gBAAA,EAAC,IAAD,EAAQ,QAAQ,EAAiB,OAAS,CAAA;AAAA,MAEvC;AAAA;EACY,CAAA;AAEzB,CACF"}
@@ -11,6 +11,10 @@ export interface TransactionListProps {
11
11
  isRowDisabled?: (t: Transaction) => boolean;
12
12
  loader?: React.JSX.Element;
13
13
  onClick?: (guid: string) => void;
14
+ /** Virtualize against the nearest scrolling ancestor instead of an own fixed-height scroll box. */
15
+ scrollsWithParent?: boolean;
16
+ /** Rendered above the rows; stays at the top of the scroll area when used with scrollsWithParent. */
17
+ stickyHeader?: React.ReactNode;
14
18
  showInsights?: boolean;
15
19
  showLoader?: boolean;
16
20
  transaction?: Transaction[];